@karakeep/cli 0.27.1 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +99 -15
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -15408,6 +15408,7 @@ const zCursorV2 = z.object({
|
|
|
15408
15408
|
function normalizeTagName(raw) {
|
|
15409
15409
|
return raw.trim().replace(/^#+/, "");
|
|
15410
15410
|
}
|
|
15411
|
+
const MAX_NUM_TAGS_PER_PAGE = 1e3;
|
|
15411
15412
|
const zTagNameSchemaWithValidation = z.string().transform((s) => normalizeTagName(s).trim()).pipe(z.string().min(1));
|
|
15412
15413
|
z.object({
|
|
15413
15414
|
name: zTagNameSchemaWithValidation
|
|
@@ -15418,7 +15419,7 @@ const zBookmarkTagSchema = z.object({
|
|
|
15418
15419
|
name: z.string(),
|
|
15419
15420
|
attachedBy: zAttachedByEnumSchema
|
|
15420
15421
|
});
|
|
15421
|
-
z.object({
|
|
15422
|
+
const zGetTagResponseSchema = z.object({
|
|
15422
15423
|
id: z.string(),
|
|
15423
15424
|
name: z.string(),
|
|
15424
15425
|
numBookmarks: z.number(),
|
|
@@ -15432,6 +15433,49 @@ z.object({
|
|
|
15432
15433
|
id: z.string(),
|
|
15433
15434
|
name: z.string()
|
|
15434
15435
|
});
|
|
15436
|
+
const zTagCursorSchema = z.object({
|
|
15437
|
+
page: z.number().int().min(0)
|
|
15438
|
+
});
|
|
15439
|
+
const zTagListRequestSchema = z.object({
|
|
15440
|
+
nameContains: z.string().optional(),
|
|
15441
|
+
attachedBy: z.enum([...zAttachedByEnumSchema.options, "none"]).optional(),
|
|
15442
|
+
sortBy: z.enum(["name", "usage", "relevance"]).optional().default("usage"),
|
|
15443
|
+
cursor: zTagCursorSchema.nullish().default({ page: 0 }),
|
|
15444
|
+
// TODO: Remove the optional to enforce a limit after the next release
|
|
15445
|
+
limit: z.number().int().min(1).max(MAX_NUM_TAGS_PER_PAGE).optional()
|
|
15446
|
+
});
|
|
15447
|
+
zTagListRequestSchema.refine(
|
|
15448
|
+
(val) => val.sortBy != "relevance" || val.nameContains !== void 0,
|
|
15449
|
+
{
|
|
15450
|
+
message: "Relevance sorting requires a nameContains filter",
|
|
15451
|
+
path: ["sortBy"]
|
|
15452
|
+
}
|
|
15453
|
+
);
|
|
15454
|
+
const zTagListResponseSchema = z.object({
|
|
15455
|
+
tags: z.array(zGetTagResponseSchema),
|
|
15456
|
+
nextCursor: zTagCursorSchema.nullish()
|
|
15457
|
+
});
|
|
15458
|
+
z.object({
|
|
15459
|
+
nameContains: zTagListRequestSchema.shape.nameContains,
|
|
15460
|
+
sort: zTagListRequestSchema.shape.sortBy,
|
|
15461
|
+
attachedBy: zTagListRequestSchema.shape.attachedBy,
|
|
15462
|
+
cursor: z.string().transform((val, ctx) => {
|
|
15463
|
+
try {
|
|
15464
|
+
return JSON.parse(Buffer.from(val, "base64url").toString("utf8"));
|
|
15465
|
+
} catch {
|
|
15466
|
+
ctx.addIssue({
|
|
15467
|
+
code: "custom",
|
|
15468
|
+
message: "Invalid cursor"
|
|
15469
|
+
});
|
|
15470
|
+
return z.NEVER;
|
|
15471
|
+
}
|
|
15472
|
+
}).optional().pipe(zTagListRequestSchema.shape.cursor),
|
|
15473
|
+
limit: z.coerce.number().optional()
|
|
15474
|
+
});
|
|
15475
|
+
z.object({
|
|
15476
|
+
tags: zTagListResponseSchema.shape.tags,
|
|
15477
|
+
nextCursor: z.string().nullish()
|
|
15478
|
+
});
|
|
15435
15479
|
const MAX_BOOKMARK_TITLE_LENGTH = 1e3;
|
|
15436
15480
|
var BookmarkTypes = /* @__PURE__ */ ((BookmarkTypes2) => {
|
|
15437
15481
|
BookmarkTypes2["LINK"] = "link";
|
|
@@ -15450,11 +15494,13 @@ const zAssetTypesSchema = z.enum([
|
|
|
15450
15494
|
"video",
|
|
15451
15495
|
"bookmarkAsset",
|
|
15452
15496
|
"precrawledArchive",
|
|
15497
|
+
"userUploaded",
|
|
15453
15498
|
"unknown"
|
|
15454
15499
|
]);
|
|
15455
15500
|
const zAssetSchema = z.object({
|
|
15456
15501
|
id: z.string(),
|
|
15457
|
-
assetType: zAssetTypesSchema
|
|
15502
|
+
assetType: zAssetTypesSchema,
|
|
15503
|
+
fileName: z.string().nullish()
|
|
15458
15504
|
});
|
|
15459
15505
|
const zBookmarkedLinkSchema = z.object({
|
|
15460
15506
|
type: z.literal(
|
|
@@ -15508,6 +15554,16 @@ const zBookmarkContentSchema = z.discriminatedUnion("type", [
|
|
|
15508
15554
|
/* UNKNOWN */
|
|
15509
15555
|
) })
|
|
15510
15556
|
]);
|
|
15557
|
+
const zBookmarkSourceSchema = z.enum([
|
|
15558
|
+
"api",
|
|
15559
|
+
"web",
|
|
15560
|
+
"cli",
|
|
15561
|
+
"mobile",
|
|
15562
|
+
"extension",
|
|
15563
|
+
"singlefile",
|
|
15564
|
+
"rss",
|
|
15565
|
+
"import"
|
|
15566
|
+
]);
|
|
15511
15567
|
const zBareBookmarkSchema = z.object({
|
|
15512
15568
|
id: z.string(),
|
|
15513
15569
|
createdAt: z.date(),
|
|
@@ -15518,7 +15574,9 @@ const zBareBookmarkSchema = z.object({
|
|
|
15518
15574
|
taggingStatus: z.enum(["success", "failure", "pending"]).nullable(),
|
|
15519
15575
|
summarizationStatus: z.enum(["success", "failure", "pending"]).nullable(),
|
|
15520
15576
|
note: z.string().nullish(),
|
|
15521
|
-
summary: z.string().nullish()
|
|
15577
|
+
summary: z.string().nullish(),
|
|
15578
|
+
source: zBookmarkSourceSchema.nullish(),
|
|
15579
|
+
userId: z.string()
|
|
15522
15580
|
});
|
|
15523
15581
|
const zBookmarkSchema = zBareBookmarkSchema.merge(
|
|
15524
15582
|
z.object({
|
|
@@ -15557,7 +15615,9 @@ z.object({
|
|
|
15557
15615
|
createdAt: z.coerce.date().optional(),
|
|
15558
15616
|
// A mechanism to prioritize crawling of bookmarks depending on whether
|
|
15559
15617
|
// they were created by a user interaction or by a bulk import.
|
|
15560
|
-
crawlPriority: z.enum(["low", "normal"]).optional()
|
|
15618
|
+
crawlPriority: z.enum(["low", "normal"]).optional(),
|
|
15619
|
+
importSessionId: z.string().optional(),
|
|
15620
|
+
source: zBookmarkSourceSchema.optional()
|
|
15561
15621
|
}).and(
|
|
15562
15622
|
z.discriminatedUnion("type", [
|
|
15563
15623
|
z.object({
|
|
@@ -15734,12 +15794,22 @@ bookmarkCmd.command("add").description("creates a new bookmark").option(
|
|
|
15734
15794
|
const results = [];
|
|
15735
15795
|
const promises = [
|
|
15736
15796
|
...opts.link.map(
|
|
15737
|
-
(url) => api2.bookmarks.createBookmark.mutate({
|
|
15797
|
+
(url) => api2.bookmarks.createBookmark.mutate({
|
|
15798
|
+
type: BookmarkTypes.LINK,
|
|
15799
|
+
url,
|
|
15800
|
+
title: opts.title,
|
|
15801
|
+
source: "cli"
|
|
15802
|
+
}).then((bookmark) => {
|
|
15738
15803
|
results.push(normalizeBookmark(bookmark));
|
|
15739
15804
|
}).catch(printError(`Failed to add a link bookmark for url "${url}"`))
|
|
15740
15805
|
),
|
|
15741
15806
|
...opts.note.map(
|
|
15742
|
-
(text) => api2.bookmarks.createBookmark.mutate({
|
|
15807
|
+
(text) => api2.bookmarks.createBookmark.mutate({
|
|
15808
|
+
type: BookmarkTypes.TEXT,
|
|
15809
|
+
text,
|
|
15810
|
+
title: opts.title,
|
|
15811
|
+
source: "cli"
|
|
15812
|
+
}).then((bookmark) => {
|
|
15743
15813
|
results.push(normalizeBookmark(bookmark));
|
|
15744
15814
|
}).catch(
|
|
15745
15815
|
printError(
|
|
@@ -15751,7 +15821,12 @@ bookmarkCmd.command("add").description("creates a new bookmark").option(
|
|
|
15751
15821
|
if (opts.stdin) {
|
|
15752
15822
|
const text = require$$3.readFileSync(0, "utf-8");
|
|
15753
15823
|
promises.push(
|
|
15754
|
-
api2.bookmarks.createBookmark.mutate({
|
|
15824
|
+
api2.bookmarks.createBookmark.mutate({
|
|
15825
|
+
type: BookmarkTypes.TEXT,
|
|
15826
|
+
text,
|
|
15827
|
+
title: opts.title,
|
|
15828
|
+
source: "cli"
|
|
15829
|
+
}).then((bookmark) => {
|
|
15755
15830
|
results.push(normalizeBookmark(bookmark));
|
|
15756
15831
|
}).catch(
|
|
15757
15832
|
printError(
|
|
@@ -15989,9 +16064,18 @@ const dumpCmd = new Command().name("dump").description("dump all account data an
|
|
|
15989
16064
|
}
|
|
15990
16065
|
if (!opts.excludeTags) {
|
|
15991
16066
|
stepStart$2("Exporting tags");
|
|
15992
|
-
|
|
15993
|
-
|
|
15994
|
-
|
|
16067
|
+
let cursor = null;
|
|
16068
|
+
let allTags = [];
|
|
16069
|
+
do {
|
|
16070
|
+
const { tags, nextCursor } = await api2.tags.list.query({
|
|
16071
|
+
limit: MAX_NUM_TAGS_PER_PAGE,
|
|
16072
|
+
cursor
|
|
16073
|
+
});
|
|
16074
|
+
allTags.push(...tags);
|
|
16075
|
+
cursor = nextCursor;
|
|
16076
|
+
} while (cursor);
|
|
16077
|
+
await writeJson(path.join(workRoot, "tags", "index.json"), allTags);
|
|
16078
|
+
manifest.counts.tags = allTags.length;
|
|
15995
16079
|
stepEndSuccess$2();
|
|
15996
16080
|
}
|
|
15997
16081
|
if (!opts.excludeRules) {
|
|
@@ -16539,7 +16623,7 @@ async function migrateWebhooks(src2, dest, onProgress) {
|
|
|
16539
16623
|
}
|
|
16540
16624
|
async function migrateTags(src2, dest, onProgress) {
|
|
16541
16625
|
try {
|
|
16542
|
-
const { tags: srcTags } = await src2.tags.list.query();
|
|
16626
|
+
const { tags: srcTags } = await src2.tags.list.query({});
|
|
16543
16627
|
let ensured = 0;
|
|
16544
16628
|
for (const t of srcTags) {
|
|
16545
16629
|
try {
|
|
@@ -16549,7 +16633,7 @@ async function migrateTags(src2, dest, onProgress) {
|
|
|
16549
16633
|
ensured++;
|
|
16550
16634
|
onProgress?.(ensured, srcTags.length);
|
|
16551
16635
|
}
|
|
16552
|
-
const { tags: destTags } = await dest.tags.list.query();
|
|
16636
|
+
const { tags: destTags } = await dest.tags.list.query({});
|
|
16553
16637
|
const nameToDestId = destTags.reduce((acc, t) => {
|
|
16554
16638
|
acc[t.name] = t.id;
|
|
16555
16639
|
return acc;
|
|
@@ -16802,7 +16886,7 @@ const tagsCmd = new Command().name("tags").description("manipulating tags");
|
|
|
16802
16886
|
tagsCmd.command("list").description("lists all tags").action(async () => {
|
|
16803
16887
|
const api2 = getAPIClient();
|
|
16804
16888
|
try {
|
|
16805
|
-
const tags = (await api2.tags.list.query()).tags;
|
|
16889
|
+
const tags = (await api2.tags.list.query({})).tags;
|
|
16806
16890
|
tags.sort((a, b) => b.numBookmarks - a.numBookmarks);
|
|
16807
16891
|
if (getGlobalOptions().json) {
|
|
16808
16892
|
printObject(tags);
|
|
@@ -17153,7 +17237,7 @@ async function wipeTags(api2) {
|
|
|
17153
17237
|
throw error2;
|
|
17154
17238
|
}
|
|
17155
17239
|
}
|
|
17156
|
-
const __vite_import_meta_env__ = { "BASE_URL": "/", "CLI_VERSION": "0.
|
|
17240
|
+
const __vite_import_meta_env__ = { "BASE_URL": "/", "CLI_VERSION": "0.29.0", "DEV": false, "MODE": "production", "PROD": true, "SSR": true };
|
|
17157
17241
|
const program = new Command().name("karakeep").description("A CLI interface to interact with the karakeep api").addOption(
|
|
17158
17242
|
new Option("--api-key <key>", "the API key to interact with the API").makeOptionMandatory(true).env("KARAKEEP_API_KEY")
|
|
17159
17243
|
).addOption(
|
|
@@ -17162,7 +17246,7 @@ const program = new Command().name("karakeep").description("A CLI interface to i
|
|
|
17162
17246
|
"the address of the server to connect to"
|
|
17163
17247
|
).makeOptionMandatory(true).env("KARAKEEP_SERVER_ADDR")
|
|
17164
17248
|
).addOption(new Option("--json", "to output the result as JSON")).version(
|
|
17165
|
-
__vite_import_meta_env__ && "CLI_VERSION" in __vite_import_meta_env__ ? "0.
|
|
17249
|
+
__vite_import_meta_env__ && "CLI_VERSION" in __vite_import_meta_env__ ? "0.29.0" : "0.0.0"
|
|
17166
17250
|
);
|
|
17167
17251
|
program.addCommand(bookmarkCmd);
|
|
17168
17252
|
program.addCommand(listsCmd);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@karakeep/cli",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.29.0",
|
|
5
5
|
"description": "Command Line Interface (CLI) for Karakeep",
|
|
6
6
|
"license": "GNU Affero General Public License version 3",
|
|
7
7
|
"type": "module",
|