Skip to content

Commit

Permalink
fix(cli): Remove limit from array length when listing bookmarks. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed May 5, 2024
1 parent 79777bd commit 2ed134e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@hoarderapp/cli",
"version": "0.13.2",
"version": "0.13.3",
"description": "Command Line Interface (CLI) for Hoarder",
"license": "GNU Affero General Public License version 3",
"keywords": [
Expand Down
6 changes: 4 additions & 2 deletions apps/cli/src/commands/bookmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Command } from "@commander-js/extra-typings";
import chalk from "chalk";

import type { ZBookmark } from "@hoarder/shared/types/bookmarks";
import { MAX_NUM_BOOKMARKS_PER_PAGE } from "@hoarder/shared/types/bookmarks";

export const bookmarkCmd = new Command()
.name("bookmarks")
Expand Down Expand Up @@ -121,10 +122,11 @@ bookmarkCmd
const request = {
archived: opts.includeArchived ? undefined : false,
listId: opts.listId,
limit: MAX_NUM_BOOKMARKS_PER_PAGE,
};

let results: ZBookmark[] = [];
let resp = await api.bookmarks.getBookmarks.query(request);
let results: ZBookmark[] = resp.bookmarks;

while (resp.nextCursor) {
resp = await api.bookmarks.getBookmarks.query({
Expand All @@ -134,7 +136,7 @@ bookmarkCmd
results = [...results, ...resp.bookmarks];
}

console.log(results.map(normalizeBookmark));
console.dir(results.map(normalizeBookmark), { maxArrayLength: null });
});

bookmarkCmd
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/types/bookmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@ export type ZNewBookmarkRequest = z.infer<typeof zNewBookmarkRequestSchema>;
// GET /v1/bookmarks

export const DEFAULT_NUM_BOOKMARKS_PER_PAGE = 20;
export const MAX_NUM_BOOKMARKS_PER_PAGE = 100;

export const zGetBookmarksRequestSchema = z.object({
ids: z.array(z.string()).optional(),
archived: z.boolean().optional(),
favourited: z.boolean().optional(),
tagId: z.string().optional(),
listId: z.string().optional(),
limit: z.number().max(100).optional(),
limit: z.number().max(MAX_NUM_BOOKMARKS_PER_PAGE).optional(),
cursor: z.date().nullish(),
});
export type ZGetBookmarksRequest = z.infer<typeof zGetBookmarksRequestSchema>;
Expand Down

0 comments on commit 2ed134e

Please sign in to comment.