@karakeep/cli 0.29.0 → 0.30.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.
Files changed (2) hide show
  1. package/dist/index.mjs +75 -5
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import * as require$$3 from "node:fs";
3
- import require$$3__default from "node:fs";
4
2
  import process$1, { stdout, stdin } from "node:process";
5
3
  import os from "node:os";
6
4
  import tty from "node:tty";
7
5
  import require$$0 from "node:events";
8
6
  import require$$1, { spawn } from "node:child_process";
9
7
  import path from "node:path";
8
+ import * as require$$3 from "node:fs";
9
+ import require$$3__default from "node:fs";
10
10
  import fsp from "node:fs/promises";
11
11
  import readline from "node:readline/promises";
12
12
  let globalOpts = void 0;
@@ -11216,6 +11216,70 @@ function requireSrc() {
11216
11216
  return src;
11217
11217
  }
11218
11218
  var srcExports = /* @__PURE__ */ requireSrc();
11219
+ const adminCmd = new Command().name("admin").description("admin commands");
11220
+ function toHumanReadableSize(size) {
11221
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
11222
+ if (size === 0) return "0 Bytes";
11223
+ const i = Math.floor(Math.log(size) / Math.log(1024));
11224
+ return (size / Math.pow(1024, i)).toFixed(2) + " " + sizes[i];
11225
+ }
11226
+ const usersCmd = new Command().name("users").description("user management commands");
11227
+ usersCmd.command("list").description("list all users").action(async () => {
11228
+ const api2 = getAPIClient();
11229
+ try {
11230
+ const [usersResp, userStats] = await Promise.all([
11231
+ api2.users.list.query(),
11232
+ api2.admin.userStats.query()
11233
+ ]);
11234
+ if (getGlobalOptions().json) {
11235
+ printObject({
11236
+ users: usersResp.users.map((u) => ({
11237
+ ...u,
11238
+ numBookmarks: userStats[u.id]?.numBookmarks ?? 0,
11239
+ assetSizes: userStats[u.id]?.assetSizes ?? 0
11240
+ }))
11241
+ });
11242
+ } else {
11243
+ const data = [
11244
+ [
11245
+ "Name",
11246
+ "Email",
11247
+ "Num Bookmarks",
11248
+ "Asset Sizes",
11249
+ "Role",
11250
+ "Local User"
11251
+ ]
11252
+ ];
11253
+ usersResp.users.forEach((user) => {
11254
+ const stats = userStats[user.id] ?? {
11255
+ numBookmarks: 0,
11256
+ assetSizes: 0
11257
+ };
11258
+ const numBookmarksDisplay = `${stats.numBookmarks} / ${user.bookmarkQuota?.toString() ?? "Unlimited"}`;
11259
+ const assetSizesDisplay = `${toHumanReadableSize(stats.assetSizes)} / ${user.storageQuota ? toHumanReadableSize(user.storageQuota) : "Unlimited"}`;
11260
+ data.push([
11261
+ user.name,
11262
+ user.email,
11263
+ numBookmarksDisplay,
11264
+ assetSizesDisplay,
11265
+ user.role ?? "",
11266
+ user.localUser ? "✓" : "✗"
11267
+ ]);
11268
+ });
11269
+ console.log(
11270
+ srcExports.table(data, {
11271
+ border: srcExports.getBorderCharacters("ramac"),
11272
+ drawHorizontalLine: (lineIndex, rowCount) => {
11273
+ return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount;
11274
+ }
11275
+ })
11276
+ );
11277
+ }
11278
+ } catch (error2) {
11279
+ printErrorMessageWithReason("Failed to list all users", error2);
11280
+ }
11281
+ });
11282
+ adminCmd.addCommand(usersCmd);
11219
11283
  function listsToTree(lists) {
11220
11284
  const idToList = lists.reduce((acc, list) => {
11221
11285
  acc[list.id] = list;
@@ -15488,6 +15552,7 @@ const zSortOrder = z.enum(["asc", "desc", "relevance"]);
15488
15552
  const zAssetTypesSchema = z.enum([
15489
15553
  "linkHtmlContent",
15490
15554
  "screenshot",
15555
+ "pdf",
15491
15556
  "assetScreenshot",
15492
15557
  "bannerImage",
15493
15558
  "fullPageArchive",
@@ -15495,6 +15560,7 @@ const zAssetTypesSchema = z.enum([
15495
15560
  "bookmarkAsset",
15496
15561
  "precrawledArchive",
15497
15562
  "userUploaded",
15563
+ "avatar",
15498
15564
  "unknown"
15499
15565
  ]);
15500
15566
  const zAssetSchema = z.object({
@@ -15513,6 +15579,7 @@ const zBookmarkedLinkSchema = z.object({
15513
15579
  imageUrl: z.string().nullish(),
15514
15580
  imageAssetId: z.string().nullish(),
15515
15581
  screenshotAssetId: z.string().nullish(),
15582
+ pdfAssetId: z.string().nullish(),
15516
15583
  fullPageArchiveAssetId: z.string().nullish(),
15517
15584
  precrawledArchiveAssetId: z.string().nullish(),
15518
15585
  videoAssetId: z.string().nullish(),
@@ -15520,6 +15587,7 @@ const zBookmarkedLinkSchema = z.object({
15520
15587
  htmlContent: z.string().nullish(),
15521
15588
  contentAssetId: z.string().nullish(),
15522
15589
  crawledAt: z.date().nullish(),
15590
+ crawlStatus: z.enum(["success", "failure", "pending"]).nullish(),
15523
15591
  author: z.string().nullish(),
15524
15592
  publisher: z.string().nullish(),
15525
15593
  datePublished: z.date().nullish(),
@@ -16772,7 +16840,8 @@ async function migrateBookmarks(src2, dest, opts) {
16772
16840
  note: b.note ?? void 0,
16773
16841
  summary: b.summary ?? void 0,
16774
16842
  createdAt: b.createdAt,
16775
- crawlPriority: "low"
16843
+ crawlPriority: "low",
16844
+ source: b.source === null ? void 0 : b.source
16776
16845
  };
16777
16846
  let createdId = null;
16778
16847
  switch (b.content.type) {
@@ -17237,7 +17306,7 @@ async function wipeTags(api2) {
17237
17306
  throw error2;
17238
17307
  }
17239
17308
  }
17240
- const __vite_import_meta_env__ = { "BASE_URL": "/", "CLI_VERSION": "0.29.0", "DEV": false, "MODE": "production", "PROD": true, "SSR": true };
17309
+ const __vite_import_meta_env__ = { "BASE_URL": "/", "CLI_VERSION": "0.30.0", "DEV": false, "MODE": "production", "PROD": true, "SSR": true };
17241
17310
  const program = new Command().name("karakeep").description("A CLI interface to interact with the karakeep api").addOption(
17242
17311
  new Option("--api-key <key>", "the API key to interact with the API").makeOptionMandatory(true).env("KARAKEEP_API_KEY")
17243
17312
  ).addOption(
@@ -17246,8 +17315,9 @@ const program = new Command().name("karakeep").description("A CLI interface to i
17246
17315
  "the address of the server to connect to"
17247
17316
  ).makeOptionMandatory(true).env("KARAKEEP_SERVER_ADDR")
17248
17317
  ).addOption(new Option("--json", "to output the result as JSON")).version(
17249
- __vite_import_meta_env__ && "CLI_VERSION" in __vite_import_meta_env__ ? "0.29.0" : "0.0.0"
17318
+ __vite_import_meta_env__ && "CLI_VERSION" in __vite_import_meta_env__ ? "0.30.0" : "0.0.0"
17250
17319
  );
17320
+ program.addCommand(adminCmd);
17251
17321
  program.addCommand(bookmarkCmd);
17252
17322
  program.addCommand(listsCmd);
17253
17323
  program.addCommand(tagsCmd);
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.29.0",
4
+ "version": "0.30.0",
5
5
  "description": "Command Line Interface (CLI) for Karakeep",
6
6
  "license": "GNU Affero General Public License version 3",
7
7
  "type": "module",