@numericoach/gskills-admin-cli 0.1.28 → 0.1.29

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/README.md CHANGED
@@ -99,6 +99,20 @@ gskills-admin resources update <resourceId> --upload-file ./webinar-v2.mp4 --dat
99
99
 
100
100
  Use `--mime-type` when the extension is ambiguous, and `--upload-name` when the stored file name needs a cleaner label.
101
101
 
102
+ Learning path icons can use the same three sources as the super-admin editor:
103
+
104
+ ```bash
105
+ gskills-admin learning-paths icons --query Gmail --output json
106
+ gskills-admin learning-paths set-icon <learningPathId> --app Gmail --dry-run --output json
107
+ gskills-admin learning-paths set-icon <learningPathId> --upload-file ./icon.png --instance <instanceId> --dry-run --output json
108
+ gskills-admin learning-paths generate-icon <learningPathId> --prompt "flat central handshake, transparent background" --dry-run --output json
109
+ gskills-admin learning-paths generate-icon <learningPathId> --prompt-file ./icon-prompt.txt --yes --output json
110
+ ```
111
+
112
+ `icons` reads only French global category app icons. `set-icon --upload-file` streams the local image to storage with a signed URL and writes `LearningPath.iconUrl`. `generate-icon` calls the same server-side image generator used by the editor, then stores the generated URL on the learning path.
113
+
114
+ Do not pass `--use-app-icon` unless the user explicitly asks for the app logo to appear. It is off by default because most parcours icons should be symbolic. Repeating app logos across every learning path gets visually heavy and often produces cluttered, low-quality icons.
115
+
102
116
  AI translation is available for content that has native AI translation in the editor:
103
117
 
104
118
  Warning: `translate pages` rewrites each translated page from the source page. It is not a diff update. Recreating translated pages this way can lose activity-specific fields, quiz ids, embedded ids, or future custom block data if the translator does not preserve them. Prefer the app diff update flow for pages with activities or custom blocks.
@@ -442,7 +442,7 @@ var resources = [
442
442
  delegate: "learningPath",
443
443
  label: "Learning paths",
444
444
  aliases: ["learning-path", "paths", "path"],
445
- defaultFields: ["id", "name", "slug", "language", "instanceId", "isActive", "mandatory", "disabled", "archived", "alphaProgramIds", "updatedAt"],
445
+ defaultFields: ["id", "name", "slug", "language", "instanceId", "iconUrl", "isActive", "mandatory", "disabled", "archived", "alphaProgramIds", "updatedAt"],
446
446
  syncable: true,
447
447
  dangerousDelete: true,
448
448
  cacheScopes: ["pages", "pages-knowledge"]
@@ -1986,6 +1986,9 @@ var runResourceCommand = async (resource, action, maybeId, rest, ctx) => {
1986
1986
  throw new CliError("Missing pages id", 2);
1987
1987
  return runPagesPatchContentCommand(maybeId, ctx);
1988
1988
  }
1989
+ if (resource.name === "learning-paths" && isLearningPathIconAction(action)) {
1990
+ return runLearningPathIconCommand(resource, action, maybeId, ctx);
1991
+ }
1989
1992
  if (action === "list")
1990
1993
  return listResource(resource, ctx);
1991
1994
  if (action === "get") {
@@ -2064,7 +2067,142 @@ var updateResource = async (resource, id, ctx) => {
2064
2067
  body: JSON.stringify({ data })
2065
2068
  });
2066
2069
  };
2067
- var UPLOADABLE_RESOURCE_NAMES = new Set(["internal-knowledge", "resources"]);
2070
+ var runLearningPathIconCommand = async (resource, action, learningPathId, ctx) => {
2071
+ if (action === "icons") {
2072
+ const searchParams = new URLSearchParams;
2073
+ const query = getStringFlag(ctx, "query") ?? getStringFlag(ctx, "search");
2074
+ const take = getNumberFlag(ctx, "take");
2075
+ if (query)
2076
+ searchParams.set("query", query);
2077
+ if (take)
2078
+ searchParams.set("take", String(take));
2079
+ if (hasFlag(ctx, "dry-run")) {
2080
+ return {
2081
+ dryRun: true,
2082
+ resource: "learning-path-icons",
2083
+ source: "global-french-category-app-icons",
2084
+ query: query ?? null,
2085
+ take: take ?? 50
2086
+ };
2087
+ }
2088
+ const suffix = searchParams.size > 0 ? `?${searchParams.toString()}` : "";
2089
+ return requestApi(`/api/cli/learning-path-icons${suffix}`);
2090
+ }
2091
+ if (!learningPathId)
2092
+ throw new CliError("Missing learning path id", 2);
2093
+ if (action === "set-icon") {
2094
+ requireWriteConfirmation("Learning path icon update writes data. Add --yes or use --dry-run.", ctx);
2095
+ const categoryRef = getStringFlag(ctx, "category") ?? getStringFlag(ctx, "app") ?? getStringFlag(ctx, "icon");
2096
+ const uploadFilePath = getStringFlag(ctx, "upload-file") ?? getStringFlag(ctx, "icon-file");
2097
+ if (categoryRef && uploadFilePath) {
2098
+ throw new CliError("Use either --category/--app or --upload-file, not both", 2);
2099
+ }
2100
+ if (!categoryRef && !uploadFilePath) {
2101
+ throw new CliError("Missing --category, --app, --upload-file, or --icon-file", 2);
2102
+ }
2103
+ if (categoryRef) {
2104
+ if (hasFlag(ctx, "dry-run")) {
2105
+ return {
2106
+ dryRun: true,
2107
+ resource: resource.name,
2108
+ id: learningPathId,
2109
+ mode: "category",
2110
+ categoryRef,
2111
+ data: {
2112
+ iconUrl: "<resolved global French category app icon>"
2113
+ }
2114
+ };
2115
+ }
2116
+ const category = await resolveLearningPathIconCategory(categoryRef);
2117
+ return requestApi(`/api/cli/${resource.name}/${learningPathId}`, {
2118
+ method: "PATCH",
2119
+ body: JSON.stringify({
2120
+ data: {
2121
+ iconUrl: category.icon
2122
+ }
2123
+ })
2124
+ });
2125
+ }
2126
+ const data = {};
2127
+ const resolvedUploadFilePath = uploadFilePath;
2128
+ if (!resolvedUploadFilePath) {
2129
+ throw new CliError("Missing --upload-file or --icon-file", 2);
2130
+ }
2131
+ const uploadCtx = {
2132
+ ...ctx,
2133
+ flags: {
2134
+ ...ctx.flags,
2135
+ "upload-file": resolvedUploadFilePath
2136
+ }
2137
+ };
2138
+ await applyUploadFileData(resource, data, uploadCtx, {
2139
+ id: learningPathId,
2140
+ instanceId: getStringFlag(ctx, "instance")
2141
+ });
2142
+ if (hasFlag(ctx, "dry-run")) {
2143
+ return {
2144
+ dryRun: true,
2145
+ resource: resource.name,
2146
+ id: learningPathId,
2147
+ mode: "upload",
2148
+ data
2149
+ };
2150
+ }
2151
+ return requestApi(`/api/cli/${resource.name}/${learningPathId}`, {
2152
+ method: "PATCH",
2153
+ body: JSON.stringify({ data })
2154
+ });
2155
+ }
2156
+ if (action === "generate-icon") {
2157
+ requireWriteConfirmation("Learning path icon generation writes data. Add --yes or use --dry-run.", ctx);
2158
+ const appRef = getStringFlag(ctx, "app") ?? getStringFlag(ctx, "category");
2159
+ const extraPrompt = await getTextFlag(ctx, "prompt", "prompt-file") ?? getStringFlag(ctx, "extra-prompt") ?? "";
2160
+ const useAppIcon = hasFlag(ctx, "use-app-icon");
2161
+ const app = appRef && !hasFlag(ctx, "dry-run") ? await resolveLearningPathIconCategory(appRef) : null;
2162
+ const payload = {
2163
+ extraPrompt,
2164
+ useAppIcon,
2165
+ appName: app?.name ?? appRef ?? getStringFlag(ctx, "app-name") ?? "",
2166
+ appIconUrl: useAppIcon ? app?.icon ?? getStringFlag(ctx, "app-icon-url") ?? "" : "",
2167
+ dryRun: hasFlag(ctx, "dry-run")
2168
+ };
2169
+ if (payload.dryRun) {
2170
+ return {
2171
+ dryRun: true,
2172
+ resource: resource.name,
2173
+ id: learningPathId,
2174
+ operation: "generate-icon",
2175
+ payload
2176
+ };
2177
+ }
2178
+ return requestApi(`/api/cli/${resource.name}/${learningPathId}/generate-icon`, {
2179
+ method: "POST",
2180
+ body: JSON.stringify(payload)
2181
+ });
2182
+ }
2183
+ throw new CliError(`Unknown learning-paths icon command "${action}"`, 2);
2184
+ };
2185
+ var isLearningPathIconAction = (action) => action === "icons" || action === "set-icon" || action === "generate-icon";
2186
+ var resolveLearningPathIconCategory = async (categoryRef) => {
2187
+ const searchParams = new URLSearchParams;
2188
+ searchParams.set("query", categoryRef);
2189
+ searchParams.set("take", "25");
2190
+ const result = await requestApi(`/api/cli/learning-path-icons?${searchParams.toString()}`);
2191
+ const categories = Array.isArray(result.icons) ? result.icons : [];
2192
+ const normalizedRef = normalizeCliSearchText(categoryRef);
2193
+ const category = categories.find((item) => [item.id, item.slug, item.name].some((value) => typeof value === "string" && normalizeCliSearchText(value) === normalizedRef)) ?? categories[0];
2194
+ if (!category || typeof category.icon !== "string") {
2195
+ throw new CliError(`No global French category app icon found for "${categoryRef}"`, 2);
2196
+ }
2197
+ return {
2198
+ id: String(category.id ?? ""),
2199
+ name: String(category.name ?? categoryRef),
2200
+ slug: String(category.slug ?? ""),
2201
+ icon: category.icon
2202
+ };
2203
+ };
2204
+ var normalizeCliSearchText = (value) => value.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim();
2205
+ var UPLOADABLE_RESOURCE_NAMES = new Set(["internal-knowledge", "resources", "learning-paths"]);
2068
2206
  var applyUploadFileData = async (resource, data, ctx, target) => {
2069
2207
  const uploadFilePath = getStringFlag(ctx, "upload-file");
2070
2208
  if (!uploadFilePath)
@@ -2094,6 +2232,9 @@ var prepareDirectUpload = async (resource, uploadFilePath, ctx, target) => {
2094
2232
  throw new CliError(`Upload file not found: ${uploadFilePath}`, 2);
2095
2233
  }
2096
2234
  const contentType = getStringFlag(ctx, "mime-type") ?? inferMimeType(filePath);
2235
+ if (resource.name === "learning-paths" && !contentType.startsWith("image/")) {
2236
+ throw new CliError("Learning path icon uploads must be image files. Use --mime-type image/png if the extension is ambiguous.", 2);
2237
+ }
2097
2238
  const instanceId = await resolveUploadInstanceId(resource, target);
2098
2239
  const fileName = getStringFlag(ctx, "upload-name") ?? basename(filePath);
2099
2240
  if (hasFlag(ctx, "dry-run")) {
@@ -2154,6 +2295,10 @@ var applyUploadedMediaData = (resource, data, upload) => {
2154
2295
  data.sourceType = "UPLOAD";
2155
2296
  data.fileUrl = upload.fileUrl;
2156
2297
  data.linkUrl = upload.fileUrl;
2298
+ return;
2299
+ }
2300
+ if (resource.name === "learning-paths") {
2301
+ data.iconUrl = upload.fileUrl;
2157
2302
  }
2158
2303
  };
2159
2304
  var setUploadInstanceData = (resource, data, instanceId) => {
@@ -2214,6 +2359,12 @@ var inferMimeType = (filePath) => {
2214
2359
  ".md": "text/markdown",
2215
2360
  ".html": "text/html",
2216
2361
  ".htm": "text/html",
2362
+ ".png": "image/png",
2363
+ ".jpg": "image/jpeg",
2364
+ ".jpeg": "image/jpeg",
2365
+ ".webp": "image/webp",
2366
+ ".gif": "image/gif",
2367
+ ".svg": "image/svg+xml",
2217
2368
  ".doc": "application/msword",
2218
2369
  ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
2219
2370
  };
@@ -3814,6 +3965,10 @@ var rootHelp = () => ({
3814
3965
  "gskills-admin imported-sheets create --instance <id> --source <url> --tab <name> --default-locale en --locales fr,en --owner-email admin@example.com --enable-vectorization --dry-run",
3815
3966
  `gskills-admin internal-knowledge create --instance <instanceId> --upload-file ./video.mp4 --data '{"title":"...","language":"fr"}' --yes`,
3816
3967
  `gskills-admin resources create --instance <instanceId> --upload-file ./webinar.mp4 --data '{"title":"...","type":"WEBINAR","language":"fr"}' --yes`,
3968
+ "gskills-admin learning-paths icons --query Gmail",
3969
+ "gskills-admin learning-paths set-icon <id> --app Gmail --yes",
3970
+ "gskills-admin learning-paths set-icon <id> --upload-file ./icon.png --yes",
3971
+ "gskills-admin learning-paths generate-icon <id> --prompt 'flat handshake, transparent background' --yes",
3817
3972
  "gskills-admin internal-knowledge sync-media --since today --languages fr --all-targets --dry-run",
3818
3973
  "gskills-admin progress learning-path-quiz-mismatches --instance <instanceId>",
3819
3974
  "gskills-admin sessions invalidate --email user@example.com --dry-run",
@@ -3882,6 +4037,9 @@ var schemaHelp = () => ({
3882
4037
  { name: "pages block insert-before", args: ["id"], required: ["--block-id", "--block or --block-file", "--yes or --dry-run"], flags: ["--expect-updated-at", "--expect-version", "--expect-content-sha1", "--reason", "--include-content"], writes: true },
3883
4038
  { name: "pages block insert-after", args: ["id"], required: ["--block-id", "--block or --block-file", "--yes or --dry-run"], flags: ["--expect-updated-at", "--expect-version", "--expect-content-sha1", "--reason", "--include-content"], writes: true },
3884
4039
  { name: "pages block remove", args: ["id"], required: ["--block-id", "--yes or --dry-run"], flags: ["--expect-type", "--expect-updated-at", "--expect-version", "--expect-content-sha1", "--reason", "--include-content"], writes: true },
4040
+ { name: "learning-paths icons", flags: ["--query", "--take"], writes: false },
4041
+ { name: "learning-paths set-icon", args: ["id"], required: ["--app or --category or --upload-file", "--yes or --dry-run"], flags: ["--instance", "--app", "--category", "--upload-file", "--icon-file", "--upload-name", "--mime-type"], writes: true },
4042
+ { name: "learning-paths generate-icon", args: ["id"], required: ["--yes or --dry-run"], flags: ["--prompt", "--prompt-file", "--extra-prompt", "--app", "--category", "--app-name", "--use-app-icon"], writes: true },
3885
4043
  { name: "feedback inspect", args: ["feedbackId or URL"], writes: false },
3886
4044
  { name: "feedback translation-status", args: ["feedbackId or URL"], writes: false },
3887
4045
  { name: "feedback import-email", flags: ["--data", "--data-file", "--yes", "--dry-run"], writes: true },
@@ -4209,6 +4367,12 @@ var resourceHelp = (resource) => ({
4209
4367
  `gskills-admin ${resource.name} delete <id> --force --confirm-delete ${resource.name}:<id> --yes`,
4210
4368
  ...resource.name === "internal-knowledge" ? [`gskills-admin ${resource.name} create --instance <instanceId> --upload-file ./video.mp4 --data '{"title":"Video","language":"fr","isActive":true}' --dry-run`] : [],
4211
4369
  ...resource.name === "resources" ? [`gskills-admin ${resource.name} create --instance <instanceId> --upload-file ./webinar.mp4 --data '{"title":"Webinar","type":"WEBINAR","language":"fr","isActive":true}' --dry-run`] : [],
4370
+ ...resource.name === "learning-paths" ? [
4371
+ `gskills-admin ${resource.name} icons --query Gmail`,
4372
+ `gskills-admin ${resource.name} set-icon <id> --app Gmail --dry-run`,
4373
+ `gskills-admin ${resource.name} set-icon <id> --upload-file ./icon.png --instance <instanceId> --dry-run`,
4374
+ `gskills-admin ${resource.name} generate-icon <id> --prompt "flat central symbol" --dry-run`
4375
+ ] : [],
4212
4376
  ...resource.name === "internal-knowledge" ? [`gskills-admin ${resource.name} sync-media --since today --languages fr --all-targets --dry-run`] : [],
4213
4377
  ...resource.name === "pages" ? [`gskills-admin ${resource.name} backfill-field --field headerColor --all-targets --dry-run`] : [],
4214
4378
  ...resource.name === "pages" ? [`gskills-admin ${resource.name} content-schema --output json`] : [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@numericoach/gskills-admin-cli",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin-only CLI for GSkills super-admin operations.",
@@ -116,6 +116,20 @@ gskills-admin resources update <resourceId> --instance dev-numericoach --upload-
116
116
 
117
117
  Use `--mime-type` when the extension is ambiguous and `--upload-name` when the stored file name should differ from the local basename. Always pass `--instance` for client-specific content; otherwise content-like creates default to `global`.
118
118
 
119
+ Learning path icons support the same sources as the super-admin editor:
120
+
121
+ ```bash
122
+ gskills-admin learning-paths icons --query Gmail --output json
123
+ gskills-admin learning-paths set-icon <learningPathId> --app Gmail --dry-run --output json
124
+ gskills-admin learning-paths set-icon <learningPathId> --upload-file ./icon.png --instance dev-numericoach --dry-run --output json
125
+ gskills-admin learning-paths generate-icon <learningPathId> --prompt "flat central handshake, transparent background" --dry-run --output json
126
+ gskills-admin learning-paths generate-icon <learningPathId> --prompt-file ./icon-prompt.txt --yes --output json
127
+ ```
128
+
129
+ `icons` reads only French global category app icons. `set-icon --upload-file` streams the local image through the signed upload path and writes `LearningPath.iconUrl`. `generate-icon` calls the same server-side image generator used by the editor, including the same prompt and post-processing.
130
+
131
+ Do not pass `--use-app-icon` unless the user explicitly asks for the app logo to appear. It is off by default because most parcours icons should be symbolic. Repeating app logos across every learning path gets visually heavy and often produces cluttered, low-quality icons.
132
+
119
133
  Delete commands are soft-only. They require both `--force` and an exact confirmation token, then write the safest inactive field available, such as `disabled: true`, `archived: true`, `isActive: false`, or `active: false`. If a resource cannot be safely disabled, the CLI refuses the delete command.
120
134
 
121
135
  ```bash