@zanfia/cli 0.2.0 → 0.3.5

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 (3) hide show
  1. package/dist/index.js +41 -7
  2. package/package.json +2 -2
  3. package/README.md +0 -33
package/dist/index.js CHANGED
@@ -6305,9 +6305,9 @@ var require_retry2 = __commonJS({
6305
6305
  }
6306
6306
  });
6307
6307
 
6308
- // ../../node_modules/proper-lockfile/node_modules/signal-exit/signals.js
6308
+ // ../../node_modules/signal-exit/signals.js
6309
6309
  var require_signals = __commonJS({
6310
- "../../node_modules/proper-lockfile/node_modules/signal-exit/signals.js"(exports, module) {
6310
+ "../../node_modules/signal-exit/signals.js"(exports, module) {
6311
6311
  "use strict";
6312
6312
  module.exports = [
6313
6313
  "SIGABRT",
@@ -6343,9 +6343,9 @@ var require_signals = __commonJS({
6343
6343
  }
6344
6344
  });
6345
6345
 
6346
- // ../../node_modules/proper-lockfile/node_modules/signal-exit/index.js
6346
+ // ../../node_modules/signal-exit/index.js
6347
6347
  var require_signal_exit = __commonJS({
6348
- "../../node_modules/proper-lockfile/node_modules/signal-exit/index.js"(exports, module) {
6348
+ "../../node_modules/signal-exit/index.js"(exports, module) {
6349
6349
  "use strict";
6350
6350
  var process2 = global.process;
6351
6351
  var processOk = function(process3) {
@@ -6908,7 +6908,8 @@ var CONFIG_DIR = join(homedir(), ".config", "zanfia");
6908
6908
  var CREDENTIALS_FILE = join(CONFIG_DIR, "credentials.json");
6909
6909
  var orUndefined = (value) => value.length > 0 ? value : void 0;
6910
6910
  var backendDefaults = {
6911
- apiUrl: true ? orUndefined("https://europe-central2-mailingr-54736.cloudfunctions.net/api-v1") : void 0,
6911
+ apiUrl: true ? orUndefined("https://api.zanfia.com") : void 0,
6912
+ communityApiUrl: true ? orUndefined("https://api.zanfia.com/community") : void 0,
6912
6913
  loginUrl: true ? orUndefined("https://app.zanfia.com/cli/auth") : void 0,
6913
6914
  exchangeUrl: true ? orUndefined("https://europe-central2-mailingr-54736.cloudfunctions.net/users-v1/cli/auth/exchange") : void 0,
6914
6915
  memberExchangeUrl: true ? orUndefined("https://europe-central2-mailingr-54736.cloudfunctions.net/users-v1/member/cli/auth/exchange") : void 0,
@@ -6974,7 +6975,7 @@ function resolveCommunityApiUrl() {
6974
6975
  if (!apiUrl) return null;
6975
6976
  if (/\/api-community\/?$/.test(apiUrl)) return apiUrl.replace(/\/$/, "");
6976
6977
  if (/\/api-v1\/?$/.test(apiUrl)) return apiUrl.replace(/\/api-v1\/?$/, "/api-community");
6977
- return null;
6978
+ return backendDefaults.communityApiUrl ?? null;
6978
6979
  }
6979
6980
  function isMockMode() {
6980
6981
  if (process.env.ZANFIA_CLI_MOCK === "1" || process.env.ZANFIA_CLI_MOCK === "true") {
@@ -7786,6 +7787,9 @@ function createMockClient() {
7786
7787
  async updateCourseLesson(_productId, lessonId, input) {
7787
7788
  return mockBackend.updateCourseLesson(lessonId, input);
7788
7789
  },
7790
+ async setCourseLessonThumbnail() {
7791
+ throw new ApiError(501, "lesson thumbnails are not available in mock mode");
7792
+ },
7789
7793
  async addCourseModule(_productId, input) {
7790
7794
  return mockBackend.addCourseModule(input);
7791
7795
  },
@@ -8554,6 +8558,11 @@ function createHttpClient(config) {
8554
8558
  `/products/${encodeURIComponent(productId)}/course/lessons/${encodeURIComponent(lessonId)}`,
8555
8559
  input
8556
8560
  ),
8561
+ setCourseLessonThumbnail: (productId, lessonId, input) => request(
8562
+ "PUT",
8563
+ `/products/${encodeURIComponent(productId)}/course/lessons/${encodeURIComponent(lessonId)}/thumbnail`,
8564
+ input
8565
+ ),
8557
8566
  addCourseModule: (productId, input) => request("POST", `/products/${encodeURIComponent(productId)}/course/modules`, input),
8558
8567
  updateCourseModule: (productId, moduleId, input) => request(
8559
8568
  "PATCH",
@@ -12459,6 +12468,31 @@ function registerCoursesCommands(program3) {
12459
12468
  });
12460
12469
  }
12461
12470
  );
12471
+ lesson.command("set-thumbnail").description(
12472
+ "Set or clear the lesson thumbnail; Bunny video lessons also get it as the player thumbnail"
12473
+ ).argument("<productId>", "course product id").argument("<lessonId>", "lesson id").option("--media <mediaId>", "media-library IMAGE id (from `media upload`)").option("--url <httpsUrl>", "already-hosted https image URL").option("--clear", "remove the thumbnail (video lessons fall back to the generated frame)").action(
12474
+ async (productId, lessonId, options, command) => {
12475
+ const flags = getGlobalFlags(command);
12476
+ const picked = [options.media, options.url, options.clear].filter(
12477
+ (value) => value !== void 0 && value !== false
12478
+ );
12479
+ if (picked.length !== 1) {
12480
+ throw new Error("Pass exactly one of --media <mediaId>, --url <httpsUrl>, --clear.");
12481
+ }
12482
+ const result = await clientFor2(flags).setCourseLessonThumbnail(productId, lessonId, {
12483
+ ...options.media !== void 0 ? { mediaId: options.media } : {},
12484
+ ...options.url !== void 0 ? { thumbnailUrl: options.url } : {},
12485
+ ...options.clear ? { thumbnailUrl: null } : {}
12486
+ });
12487
+ emit(flags, result, () => {
12488
+ process.stdout.write(
12489
+ result.thumbnailUrl ? `Set thumbnail for lesson ${result.lessonId}: ${result.thumbnailUrl}
12490
+ ` : `Cleared thumbnail for lesson ${result.lessonId}
12491
+ `
12492
+ );
12493
+ });
12494
+ }
12495
+ );
12462
12496
  lesson.command("update").description("Update a lesson (title, description, status, Markdown content)").argument("<productId>", "course product id").argument("<lessonId>", "lesson id").option("--title <title>", "new lesson title").option("--description <text>", "new lesson description").option("--status <status>", `new status (${LESSON_STATUSES.join("|")})`).option("--content <markdown>", "new lesson body (Markdown)").option("--content-file <path>", "read the new lesson body (Markdown) from a file").action(
12463
12497
  async (productId, lessonId, options, command) => {
12464
12498
  const flags = getGlobalFlags(command);
@@ -19932,7 +19966,7 @@ function formatSteps(steps) {
19932
19966
  // src/index.ts
19933
19967
  var PROGRAM_NAME = "zanfia".length > 0 ? "zanfia" : "zanfia";
19934
19968
  var program2 = new Command();
19935
- program2.name(PROGRAM_NAME).description("Zanfia CLI \u2014 manage products, clients, orders and more from your terminal").version("0.1.6").option("--api-key <key>", "override stored API key for this invocation").option("--json", "emit JSON output instead of human-readable tables").option("--verbose", "log request/response debug info").showHelpAfterError().addHelpText(
19969
+ program2.name(PROGRAM_NAME).description("Zanfia CLI \u2014 manage products, clients, orders and more from your terminal").version("0.3.5").option("--api-key <key>", "override stored API key for this invocation").option("--json", "emit JSON output instead of human-readable tables").option("--verbose", "log request/response debug info").showHelpAfterError().addHelpText(
19936
19970
  "after",
19937
19971
  `
19938
19972
  New to Zanfia?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zanfia/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.5",
4
4
  "private": false,
5
5
  "description": "Zanfia CLI — thin HTTP client over the Zanfia Public API",
6
6
  "type": "module",
@@ -28,7 +28,7 @@
28
28
  "tus-js-client": "^4.3.1"
29
29
  },
30
30
  "devDependencies": {
31
- "@mailingr/typescript-config": "^1.1.0",
31
+ "@mailingr/typescript-config": "^1.1.1",
32
32
  "@types/node": "^22.19.17",
33
33
  "tsup": "^8.3.0",
34
34
  "tsx": "^4.23.1",
package/README.md DELETED
@@ -1,33 +0,0 @@
1
- # @zanfia/cli (`zanfia`)
2
-
3
- Thin HTTP client over the Zanfia Public API.
4
-
5
- > **Status:** scaffolded. Until the Public API service (`api-service`) is deployed, commands run against a local in-memory mock. Set `ZANFIA_API_URL` to point at a real service, or leave it unset to use the mock.
6
-
7
- ## Local usage
8
-
9
- ```bash
10
- # from the monorepo root, after `pnpm install`
11
- pnpm --filter @zanfia/cli dev products list
12
-
13
- # or run a one-off
14
- pnpm --filter @zanfia/cli dev auth whoami
15
-
16
- # global flags (--json, --verbose, --api-key) must come BEFORE the subcommand:
17
- pnpm --filter @zanfia/cli dev --json products list
18
- ```
19
-
20
- ## Auth resolution order
21
-
22
- 1. `--api-key` flag
23
- 2. `ZANFIA_API_KEY` environment variable
24
- 3. Stored key in `~/.config/zanfia/credentials.json`
25
- 4. Prompt to run `zanfia auth set-key`
26
-
27
- ## Environment
28
-
29
- | Variable | Purpose |
30
- |---|---|
31
- | `ZANFIA_API_URL` | Public API base URL. Unset → mock mode. |
32
- | `ZANFIA_API_KEY` | API key (overrides stored credentials). |
33
- | `ZANFIA_CLI_MOCK` | Force mock mode even if `ZANFIA_API_URL` is set. |