@numericoach/gskills-admin-cli 0.1.11 → 0.1.12

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
@@ -47,6 +47,18 @@ gskills-admin topics help --output json
47
47
 
48
48
  Use the listed `cache.scopes` with `gskills-admin cache invalidate` after create, update, or delete when the end-user view must reflect the change immediately.
49
49
 
50
+ AI translation is available for content that has native AI translation in the editor:
51
+
52
+ ```bash
53
+ gskills-admin translate pages <pageId> --to en,es --dry-run --output json
54
+ gskills-admin translate pages --ids <pageId,pageId> --from fr --to en --dry-run --output json
55
+ gskills-admin translate pages --all --instance global --from fr --to en --take 100 --dry-run --output json
56
+ gskills-admin translate quizzes <quizId> --to en --yes --output json
57
+ gskills-admin translate knowledge-video <knowledgeId> --from en --to es --yes --output json
58
+ ```
59
+
60
+ Supported kinds are `pages`, `quizzes`, `topics`, `badges`, `menus`, `menu-sections`, `internal-knowledge`, `knowledge-video`, `learning-paths`, and `chromebook-exercises`.
61
+
50
62
  Operational helpers are available for the admin-only flows agents should not improvise:
51
63
 
52
64
  ```bash
@@ -776,6 +776,8 @@ var runCommand = async (ctx) => {
776
776
  return runSyncCommand(actionOrResource, ctx);
777
777
  if (group === "cache")
778
778
  return runCacheCommand(actionOrResource, ctx);
779
+ if (group === "translate")
780
+ return runTranslateCommand(actionOrResource, maybeAction, ctx);
779
781
  if (group === "feedback")
780
782
  return runFeedbackCommand(actionOrResource, maybeAction, ctx);
781
783
  if (group === "access")
@@ -1237,6 +1239,37 @@ var runCacheCommand = async (action, ctx) => {
1237
1239
  body: JSON.stringify(payload)
1238
1240
  });
1239
1241
  };
1242
+ var runTranslateCommand = async (kind, id, ctx) => {
1243
+ if (!kind || kind === "help")
1244
+ return translateHelp();
1245
+ const ids = splitCsv(getStringFlag(ctx, "ids"));
1246
+ const all = hasFlag(ctx, "all");
1247
+ if (!id && ids.length === 0 && !all)
1248
+ throw new CliError("Missing source content id, --ids, or --all", 2);
1249
+ if (all && (id || ids.length > 0))
1250
+ throw new CliError("Use either an id/--ids or --all, not both", 2);
1251
+ const targetLanguages = splitCsv(getStringFlag(ctx, "to") ?? getStringFlag(ctx, "languages"));
1252
+ if (targetLanguages.length === 0)
1253
+ throw new CliError("Missing --to", 2);
1254
+ if (!hasFlag(ctx, "yes") && !hasFlag(ctx, "dry-run")) {
1255
+ throw new CliError("AI translation writes content. Add --yes or use --dry-run.", 2);
1256
+ }
1257
+ return requestApi(`/api/cli/translate/${kind}`, {
1258
+ method: "POST",
1259
+ body: JSON.stringify({
1260
+ id,
1261
+ ids,
1262
+ all,
1263
+ where: parseJsonObject(getStringFlag(ctx, "where"), "--where"),
1264
+ instanceId: getStringFlag(ctx, "instance"),
1265
+ take: getNumberFlag(ctx, "take"),
1266
+ targetLanguages,
1267
+ sourceLanguage: getStringFlag(ctx, "from") ?? getStringFlag(ctx, "source-language"),
1268
+ mode: getStringFlag(ctx, "mode") ?? "upsert",
1269
+ dryRun: hasFlag(ctx, "dry-run")
1270
+ })
1271
+ });
1272
+ };
1240
1273
  var syncLogs = (ctx) => {
1241
1274
  const searchParams = new URLSearchParams;
1242
1275
  const targetInstanceId = getStringFlag(ctx, "target") ?? getStringFlag(ctx, "instance");
@@ -1476,7 +1509,8 @@ var rootHelp = () => ({
1476
1509
  "gskills-admin auth whoami",
1477
1510
  "gskills-admin pages list",
1478
1511
  `gskills-admin pages update <id> --data '{"disabled":true}'`,
1479
- "gskills-admin sync run --target <instanceId> --only pages,quizzes --yes"
1512
+ "gskills-admin sync run --target <instanceId> --only pages,quizzes --yes",
1513
+ "gskills-admin translate pages <id> --to en,es --dry-run"
1480
1514
  ],
1481
1515
  resources: resources.map((resource) => resource.name),
1482
1516
  output: "Use --output json, --output jsonl, --output table, or --output markdown. Piped output defaults to JSON.",
@@ -1508,6 +1542,7 @@ var schemaHelp = () => ({
1508
1542
  { name: "sync presets", writes: false },
1509
1543
  { name: "cache scopes", writes: false },
1510
1544
  { name: "cache invalidate", required: ["--instance"], flags: ["--scope", "--languages", "--yes", "--dry-run"], writes: true },
1545
+ { name: "translate", args: ["kind", "id?"], required: ["--to"], flags: ["--ids", "--all", "--instance", "--from", "--where", "--take", "--mode", "--yes", "--dry-run"], writes: true },
1511
1546
  { name: "feedback claim", args: ["feedbackId"], flags: ["--dry-run"], writes: true },
1512
1547
  { name: "feedback send-claim", args: ["feedbackId"], flags: ["--recipient-email", "--recipient-name", "--cc", "--subject", "--body", "--yes", "--dry-run"], writes: true },
1513
1548
  { name: "feedback send-reply", args: ["feedbackId"], flags: ["--subject", "--subject-file", "--body-file", "--translated-subject", "--translated-subject-file", "--translated-body-file", "--user-language", "--current-language", "--yes", "--dry-run"], writes: true },
@@ -1587,6 +1622,37 @@ var cacheHelp = () => ({
1587
1622
  scopes: ["all", "pages", "pages-knowledge", "menu-bundle", "applications"],
1588
1623
  note: "Uses the same deploy-cache version bump system as the super-admin content settings screen."
1589
1624
  });
1625
+ var translateHelp = () => ({
1626
+ usage: [
1627
+ "gskills-admin translate pages <pageId> --to en,es --dry-run",
1628
+ "gskills-admin translate pages --ids <pageId,pageId> --to en --dry-run",
1629
+ "gskills-admin translate pages --all --instance global --from fr --to en --take 100 --dry-run",
1630
+ "gskills-admin translate quizzes <quizId> --to en --yes",
1631
+ "gskills-admin translate topics <topicId> --to en --yes",
1632
+ "gskills-admin translate badges <badgeId> --to en --yes",
1633
+ "gskills-admin translate menus <menuItemId> --to en --yes",
1634
+ "gskills-admin translate menu-sections <menuSectionId> --to en --yes",
1635
+ "gskills-admin translate internal-knowledge <knowledgeId> --to en --yes",
1636
+ "gskills-admin translate knowledge-video <knowledgeId> --from en --to es --yes",
1637
+ "gskills-admin translate learning-paths <pathId> --to en --yes",
1638
+ "gskills-admin translate chromebook-exercises <exerciseId> --to en --yes"
1639
+ ],
1640
+ contentKinds: [
1641
+ "pages",
1642
+ "quizzes",
1643
+ "topics",
1644
+ "badges",
1645
+ "menus",
1646
+ "menu-sections",
1647
+ "internal-knowledge",
1648
+ "knowledge-video",
1649
+ "learning-paths",
1650
+ "chromebook-exercises"
1651
+ ],
1652
+ modes: ["upsert", "create", "update"],
1653
+ selection: "Pass one id, --ids for several source rows, or --all with optional --instance, --from, --where and --take.",
1654
+ note: "Uses the same AI translation helpers as the editors. Dry-run plans the write without calling AI."
1655
+ });
1590
1656
  var feedbackHelp = () => ({
1591
1657
  usage: [
1592
1658
  "gskills-admin feedback send-reply <feedbackId> --subject 'GSkills - ...' --body-file ./reply.fr.txt --dry-run",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@numericoach/gskills-admin-cli",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin-only CLI for GSkills super-admin operations.",
@@ -145,6 +145,41 @@ gskills-admin pages create --data @page.json --output json
145
145
 
146
146
  If the CLI version does not support `@file` JSON yet, inline compact JSON or use a small repo script that calls the authenticated API. Do not switch to raw DB access for convenience.
147
147
 
148
+ ## AI Translation
149
+
150
+ Use `translate` when content already has AI translation in its editor and the same operation is needed from the CLI.
151
+
152
+ Supported content kinds:
153
+
154
+ - `pages`
155
+ - `quizzes`
156
+ - `topics`
157
+ - `badges`
158
+ - `menus`
159
+ - `menu-sections`
160
+ - `internal-knowledge`
161
+ - `knowledge-video`
162
+ - `learning-paths`
163
+ - `chromebook-exercises`
164
+
165
+ Selection can be one source row, several source rows, or all matching rows:
166
+
167
+ ```bash
168
+ gskills-admin translate pages <pageId> --to en,es --dry-run --output json
169
+ gskills-admin translate pages --ids <pageId,pageId> --from fr --to en --dry-run --output json
170
+ gskills-admin translate pages --all --instance global --from fr --to en --take 100 --dry-run --output json
171
+ gskills-admin translate quizzes <quizId> --to en --yes --output json
172
+ gskills-admin translate knowledge-video <knowledgeId> --from en --to es --yes --output json
173
+ ```
174
+
175
+ Always dry-run first. Dry-run lists planned rows and target languages without calling AI or writing data. Real runs require `--yes`.
176
+
177
+ For quizzes, the CLI mirrors the quiz thematic through `categoryId` across translations.
178
+
179
+ For internal knowledge videos, use `knowledge-video`. It queues the same native video localization workflow as the editor, so it creates a localization job instead of copying the original media.
180
+
181
+ After visible content translation, read the cache hint in the response and invalidate the narrow scope before checking the deploy UI.
182
+
148
183
  ## Sync
149
184
 
150
185
  Global is the source by default.