@numericoach/gskills-admin-cli 0.1.26 → 0.1.28
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 +57 -3
- package/dist/gskills-admin.js +1342 -22
- package/package.json +1 -1
- package/skills/gskills-admin-cli/SKILL.md +45 -4
- package/skills/gskills-page-content-blocks/SKILL.md +107 -0
package/dist/gskills-admin.js
CHANGED
|
@@ -472,7 +472,17 @@ var resources = [
|
|
|
472
472
|
delegate: "changelog",
|
|
473
473
|
label: "Changelogs",
|
|
474
474
|
aliases: ["changelog"],
|
|
475
|
-
defaultFields: ["id", "title", "slug", "target", "status", "language", "updatedAt"],
|
|
475
|
+
defaultFields: ["id", "title", "slug", "groupId", "target", "status", "language", "parentId", "publishedAt", "updatedAt"],
|
|
476
|
+
instanceField: null,
|
|
477
|
+
dangerousDelete: true
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
name: "changelog-groups",
|
|
481
|
+
delegate: "changelogGroup",
|
|
482
|
+
label: "Changelog groups",
|
|
483
|
+
aliases: ["changelog-group", "changelog-groupe", "changelog-groups"],
|
|
484
|
+
defaultFields: ["id", "name", "releaseDate", "createdAt", "updatedAt"],
|
|
485
|
+
instanceField: null,
|
|
476
486
|
dangerousDelete: true
|
|
477
487
|
},
|
|
478
488
|
{
|
|
@@ -545,6 +555,105 @@ var resources = [
|
|
|
545
555
|
aliases: ["alpha", "alpha-program", "alphas"],
|
|
546
556
|
defaultFields: ["id", "key", "name", "provider", "status", "updatedAt"]
|
|
547
557
|
},
|
|
558
|
+
{
|
|
559
|
+
name: "skill-applications",
|
|
560
|
+
delegate: "skillApplication",
|
|
561
|
+
label: "Skill applications",
|
|
562
|
+
aliases: ["skill-application", "skill-apps", "skill-app"],
|
|
563
|
+
defaultFields: ["id", "key", "name", "scope", "instanceId", "sourceLanguage", "status", "provider", "requiresAI", "alphaProgramIds", "updatedAt"],
|
|
564
|
+
dangerousDelete: true,
|
|
565
|
+
cacheScopes: ["pages", "pages-knowledge"]
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
name: "skill-capabilities",
|
|
569
|
+
delegate: "skillCapability",
|
|
570
|
+
label: "Skill capabilities",
|
|
571
|
+
aliases: ["skill-capability"],
|
|
572
|
+
defaultFields: ["id", "applicationId", "key", "name", "scope", "instanceId", "sourceLanguage", "status", "order", "requiresAI", "alphaProgramIds", "updatedAt"],
|
|
573
|
+
instanceField: "instanceId",
|
|
574
|
+
dangerousDelete: true,
|
|
575
|
+
cacheScopes: ["pages", "pages-knowledge"]
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
name: "skill-clusters",
|
|
579
|
+
delegate: "skillCluster",
|
|
580
|
+
label: "Skill clusters",
|
|
581
|
+
aliases: ["skill-cluster", "skill-domains", "skill-domain"],
|
|
582
|
+
defaultFields: ["id", "capabilityId", "key", "name", "scope", "instanceId", "sourceLanguage", "status", "order", "requiresAI", "alphaProgramIds", "updatedAt"],
|
|
583
|
+
instanceField: "instanceId",
|
|
584
|
+
dangerousDelete: true,
|
|
585
|
+
cacheScopes: ["pages", "pages-knowledge"]
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
name: "skills",
|
|
589
|
+
delegate: "skill",
|
|
590
|
+
label: "Skills",
|
|
591
|
+
aliases: ["skill", "gskills-skills", "catalog-skills", "skill-catalog-skills"],
|
|
592
|
+
defaultFields: ["id", "clusterId", "key", "name", "scope", "instanceId", "sourceLanguage", "difficulty", "status", "validationTypes", "requiresAI", "alphaProgramIds", "updatedAt"],
|
|
593
|
+
instanceField: "instanceId",
|
|
594
|
+
dangerousDelete: true,
|
|
595
|
+
cacheScopes: ["pages", "pages-knowledge"]
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
name: "skill-translations",
|
|
599
|
+
delegate: "skillTranslation",
|
|
600
|
+
label: "Skill translations",
|
|
601
|
+
aliases: ["skill-translation"],
|
|
602
|
+
defaultFields: ["id", "skillId", "language", "name", "source", "translatedAt", "updatedAt"],
|
|
603
|
+
instanceField: null,
|
|
604
|
+
dangerousDelete: true,
|
|
605
|
+
cacheScopes: ["pages", "pages-knowledge"]
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
name: "skill-dependencies",
|
|
609
|
+
delegate: "skillDependency",
|
|
610
|
+
label: "Skill dependencies",
|
|
611
|
+
aliases: ["skill-dependency"],
|
|
612
|
+
defaultFields: ["id", "skillId", "dependsOnSkillId", "type", "weight", "createdAt"],
|
|
613
|
+
instanceField: null,
|
|
614
|
+
dangerousDelete: true,
|
|
615
|
+
cacheScopes: ["pages", "pages-knowledge"]
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
name: "skill-content-links",
|
|
619
|
+
delegate: "skillContentLink",
|
|
620
|
+
label: "Skill content links",
|
|
621
|
+
aliases: ["skill-content-link", "content-skill-links", "content-skill-link"],
|
|
622
|
+
defaultFields: ["id", "skillId", "contentType", "contentId", "contentFamilyId", "contentLanguage", "role", "canValidate", "canMaster", "updatedAt"],
|
|
623
|
+
instanceField: null,
|
|
624
|
+
dangerousDelete: true,
|
|
625
|
+
cacheScopes: ["pages", "pages-knowledge"]
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
name: "skill-sets",
|
|
629
|
+
delegate: "skillSet",
|
|
630
|
+
label: "Skill sets",
|
|
631
|
+
aliases: ["skill-set"],
|
|
632
|
+
defaultFields: ["id", "key", "name", "scope", "instanceId", "sourceLanguage", "status", "badgeId", "requiresAI", "alphaProgramIds", "updatedAt"],
|
|
633
|
+
instanceField: "instanceId",
|
|
634
|
+
dangerousDelete: true,
|
|
635
|
+
cacheScopes: ["pages", "pages-knowledge"]
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
name: "skill-set-skills",
|
|
639
|
+
delegate: "skillSetSkill",
|
|
640
|
+
label: "Skill set skills",
|
|
641
|
+
aliases: ["skill-set-skill"],
|
|
642
|
+
defaultFields: ["id", "skillSetId", "skillId", "requiredStatus", "weight"],
|
|
643
|
+
instanceField: null,
|
|
644
|
+
dangerousDelete: true,
|
|
645
|
+
cacheScopes: ["pages", "pages-knowledge"]
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
name: "skill-objectives",
|
|
649
|
+
delegate: "skillObjective",
|
|
650
|
+
label: "Skill objectives",
|
|
651
|
+
aliases: ["skill-objective"],
|
|
652
|
+
defaultFields: ["id", "instanceId", "key", "name", "skillSetId", "skillIds", "isActive", "dueAt", "updatedAt"],
|
|
653
|
+
instanceField: "instanceId",
|
|
654
|
+
dangerousDelete: true,
|
|
655
|
+
cacheScopes: ["pages", "pages-knowledge"]
|
|
656
|
+
},
|
|
548
657
|
{
|
|
549
658
|
name: "quizzes",
|
|
550
659
|
delegate: "quiz",
|
|
@@ -677,6 +786,16 @@ var resources = [
|
|
|
677
786
|
dangerousDelete: true,
|
|
678
787
|
cacheScopes: ["pages", "pages-knowledge"]
|
|
679
788
|
},
|
|
789
|
+
{
|
|
790
|
+
name: "workflow-actions",
|
|
791
|
+
delegate: "workflowAction",
|
|
792
|
+
label: "Workflow actions",
|
|
793
|
+
aliases: ["workflow-action", "actions", "workflow-steps", "workflow-step"],
|
|
794
|
+
defaultFields: ["id", "workflowId", "actionType", "order", "isActive", "sourceActionId", "updatedAt"],
|
|
795
|
+
instanceField: null,
|
|
796
|
+
dangerousDelete: true,
|
|
797
|
+
cacheScopes: ["pages", "pages-knowledge"]
|
|
798
|
+
},
|
|
680
799
|
{
|
|
681
800
|
name: "imported-sheets",
|
|
682
801
|
delegate: "importedSheet",
|
|
@@ -873,19 +992,912 @@ var resourceHelpRows = () => resources.map((resource) => ({
|
|
|
873
992
|
cacheScopes: resource.cacheScopes?.join(", ") || "",
|
|
874
993
|
aliases: resource.aliases.join(", ")
|
|
875
994
|
}));
|
|
995
|
+
// ../../src/cli/page-content-schema.ts
|
|
996
|
+
var block = (type, input) => ({ type, ...input });
|
|
997
|
+
var pageContentSchema = {
|
|
998
|
+
name: "gskills-page-content-blocks",
|
|
999
|
+
version: 1,
|
|
1000
|
+
command: "gskills-admin pages content-schema --output json",
|
|
1001
|
+
storage: {
|
|
1002
|
+
field: "Pages.content",
|
|
1003
|
+
format: "JSON.stringify(EditorJS OutputData)",
|
|
1004
|
+
topLevelShape: {
|
|
1005
|
+
time: "optional number",
|
|
1006
|
+
version: "optional string",
|
|
1007
|
+
blocks: "array of EditorJS blocks"
|
|
1008
|
+
},
|
|
1009
|
+
blockShape: {
|
|
1010
|
+
id: "stable EditorJS block id. Preserve existing ids when patching.",
|
|
1011
|
+
type: "one of blockTypes[].type",
|
|
1012
|
+
data: "block-specific object"
|
|
1013
|
+
}
|
|
1014
|
+
},
|
|
1015
|
+
agentRules: [
|
|
1016
|
+
"Before creating or patching page content, read this schema and inspect nearby real pages.",
|
|
1017
|
+
"Prefer gskills-admin pages block commands for granular single-block edits.",
|
|
1018
|
+
"Use gskills-admin pages patch-content with RFC 6902 patches for expert multi-path edits.",
|
|
1019
|
+
"Use JSON Patch test operations on type, id, or expected text before replace/remove.",
|
|
1020
|
+
"Do not rewrite the whole content field for ordinary page edits.",
|
|
1021
|
+
"Never translate IDs, URLs, slugs, quiz ids, page ids, resource ids, importedSheetId, or file metadata.",
|
|
1022
|
+
"Preserve block ids and nested structure unless the user explicitly asks to restructure the page.",
|
|
1023
|
+
"Run dry-run first, then write with --expect-version or --expect-content-sha1."
|
|
1024
|
+
],
|
|
1025
|
+
patching: {
|
|
1026
|
+
preferredBlockCommand: "gskills-admin pages block replace-text <pageId> --block-id <blockId> --text-file ./block.txt --dry-run --output json",
|
|
1027
|
+
preferredCommand: "gskills-admin pages patch-content <pageId> --patch-file ./page.patch.json --dry-run --output json",
|
|
1028
|
+
writeCommand: "gskills-admin pages patch-content <pageId> --patch-file ./page.patch.json --expect-version <version> --yes --output json",
|
|
1029
|
+
patchFormat: "RFC 6902 JSON Patch against the parsed EditorJS object",
|
|
1030
|
+
examplePatch: [
|
|
1031
|
+
{ op: "test", path: "/blocks/0/type", value: "paragraph" },
|
|
1032
|
+
{ op: "replace", path: "/blocks/0/data/text", value: "Texte mis a jour." }
|
|
1033
|
+
]
|
|
1034
|
+
},
|
|
1035
|
+
nestedContainers: [
|
|
1036
|
+
{
|
|
1037
|
+
blockTypes: ["columns"],
|
|
1038
|
+
childBlocksPath: "/blocks/<i>/data/cols/<j>/blocks",
|
|
1039
|
+
note: "Each column owns its own EditorJS block array."
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
blockTypes: ["accordion_tool", "vertical_accordion"],
|
|
1043
|
+
childBlocksPath: "/blocks/<i>/data/sections/<j>/content/blocks",
|
|
1044
|
+
note: "Each section has a title and a nested EditorJS content object."
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
blockTypes: ["section_tool"],
|
|
1048
|
+
childBlocksPath: "/blocks/<i>/data/content/blocks",
|
|
1049
|
+
note: "A section is a visual wrapper around nested blocks. Gemini sections set data.gemini=true."
|
|
1050
|
+
},
|
|
1051
|
+
{
|
|
1052
|
+
blockTypes: ["tabs"],
|
|
1053
|
+
childBlocksPath: "/blocks/<i>/data/tabs/<j>/content/blocks",
|
|
1054
|
+
note: "Each tab has its own nested EditorJS content object."
|
|
1055
|
+
},
|
|
1056
|
+
{
|
|
1057
|
+
blockTypes: ["slider"],
|
|
1058
|
+
childBlocksPath: "/blocks/<i>/data/slides/<j>/content/blocks",
|
|
1059
|
+
note: "Each slide has its own nested EditorJS content object."
|
|
1060
|
+
}
|
|
1061
|
+
],
|
|
1062
|
+
immutableReferenceFields: [
|
|
1063
|
+
"quiz.quizId",
|
|
1064
|
+
"pageTag.pageId",
|
|
1065
|
+
"learningPathTag.pathId",
|
|
1066
|
+
"resourceTag.resourceId",
|
|
1067
|
+
"importedSheet.importedSheetId",
|
|
1068
|
+
"pointRedemption.blockId",
|
|
1069
|
+
"image.file.url",
|
|
1070
|
+
"video.file.url",
|
|
1071
|
+
"vimeo.videoId",
|
|
1072
|
+
"boardly.dashboardId"
|
|
1073
|
+
],
|
|
1074
|
+
blockTypes: [
|
|
1075
|
+
block("paragraph", {
|
|
1076
|
+
label: "Paragraph",
|
|
1077
|
+
category: "text",
|
|
1078
|
+
purpose: "Plain prose. Inline HTML from EditorJS may appear in text.",
|
|
1079
|
+
data: { text: "string" },
|
|
1080
|
+
example: { text: "Un paragraphe court et utile." }
|
|
1081
|
+
}),
|
|
1082
|
+
block("header", {
|
|
1083
|
+
label: "Heading",
|
|
1084
|
+
category: "text",
|
|
1085
|
+
purpose: "Section heading. Also used as an anchor source when the block has an id.",
|
|
1086
|
+
data: { text: "string", level: "number, usually 2 or 3" },
|
|
1087
|
+
example: { text: "Comprendre les partages Drive", level: 2 }
|
|
1088
|
+
}),
|
|
1089
|
+
block("list", {
|
|
1090
|
+
label: "List",
|
|
1091
|
+
category: "text",
|
|
1092
|
+
purpose: "Ordered, unordered, or checklist content.",
|
|
1093
|
+
data: { style: "unordered | ordered | checklist", items: "array of strings or list item objects" },
|
|
1094
|
+
example: { style: "unordered", items: ["Verifier le destinataire", "Controler les droits"] }
|
|
1095
|
+
}),
|
|
1096
|
+
block("quote", {
|
|
1097
|
+
label: "Quote",
|
|
1098
|
+
category: "text",
|
|
1099
|
+
purpose: "Callout-like quote from EditorJS.",
|
|
1100
|
+
data: { text: "string", caption: "optional string", alignment: "optional string" },
|
|
1101
|
+
example: { text: "Astuce: commencez par un dossier de test.", caption: "", alignment: "left" }
|
|
1102
|
+
}),
|
|
1103
|
+
block("table", {
|
|
1104
|
+
label: "Table",
|
|
1105
|
+
category: "text",
|
|
1106
|
+
purpose: "Simple tabular data.",
|
|
1107
|
+
data: { withHeadings: "boolean", content: "array of row arrays" },
|
|
1108
|
+
example: { withHeadings: true, content: [["Action", "Quand"], ["Partager", "Projet lance"]] }
|
|
1109
|
+
}),
|
|
1110
|
+
block("code", {
|
|
1111
|
+
label: "Code",
|
|
1112
|
+
category: "text",
|
|
1113
|
+
purpose: "Code snippet. The sanitizer preserves data.code as raw text.",
|
|
1114
|
+
data: { code: "string" },
|
|
1115
|
+
example: { code: "console.log('Hello GSkills')" }
|
|
1116
|
+
}),
|
|
1117
|
+
block("image", {
|
|
1118
|
+
label: "Image",
|
|
1119
|
+
category: "media",
|
|
1120
|
+
purpose: "Page image uploaded or linked through the editor image tool.",
|
|
1121
|
+
data: { file: "object with url", caption: "optional string", withBorder: "optional boolean", stretched: "optional boolean", withBackground: "optional boolean" },
|
|
1122
|
+
example: { file: { url: "https://storage.googleapis.com/..." }, caption: "Capture d'ecran", withBorder: false },
|
|
1123
|
+
notes: ["Do not invent storage URLs. Upload or reuse a real asset."]
|
|
1124
|
+
}),
|
|
1125
|
+
block("video", {
|
|
1126
|
+
label: "Video",
|
|
1127
|
+
category: "media",
|
|
1128
|
+
purpose: "Page video uploaded or linked through the editor video tool.",
|
|
1129
|
+
data: { file: "object with url", caption: "optional string" },
|
|
1130
|
+
example: { file: { url: "https://storage.googleapis.com/..." }, caption: "Demonstration" },
|
|
1131
|
+
notes: ["Use CLI signed uploads for local videos."]
|
|
1132
|
+
}),
|
|
1133
|
+
block("iframe", {
|
|
1134
|
+
label: "Iframe",
|
|
1135
|
+
category: "embed",
|
|
1136
|
+
purpose: "Embedded external frame.",
|
|
1137
|
+
data: { url: "string", height: "optional number" },
|
|
1138
|
+
example: { url: "https://example.com/embed", height: 480 }
|
|
1139
|
+
}),
|
|
1140
|
+
block("vimeo", {
|
|
1141
|
+
label: "Vimeo",
|
|
1142
|
+
category: "embed",
|
|
1143
|
+
purpose: "Vimeo video embed.",
|
|
1144
|
+
data: { url: "string", videoId: "string", title: "optional string" },
|
|
1145
|
+
example: { url: "https://vimeo.com/123456789", videoId: "123456789", title: "Replay" }
|
|
1146
|
+
}),
|
|
1147
|
+
block("anchor", {
|
|
1148
|
+
label: "Anchor",
|
|
1149
|
+
category: "system",
|
|
1150
|
+
purpose: "Named anchor for menu or learning-path section links.",
|
|
1151
|
+
data: { title: "string" },
|
|
1152
|
+
example: { title: "Configurer les acces" }
|
|
1153
|
+
}),
|
|
1154
|
+
block("columns", {
|
|
1155
|
+
label: "Columns",
|
|
1156
|
+
category: "layout",
|
|
1157
|
+
purpose: "Multi-column layout. Each column contains nested blocks.",
|
|
1158
|
+
data: { cols: "array of { blocks: EditorBlock[] }" },
|
|
1159
|
+
example: { cols: [{ blocks: [{ type: "paragraph", data: { text: "Colonne gauche" } }] }, { blocks: [{ type: "paragraph", data: { text: "Colonne droite" } }] }] },
|
|
1160
|
+
notes: ["Avoid deep nesting. The editor limits recursive tools to prevent loops."]
|
|
1161
|
+
}),
|
|
1162
|
+
block("accordion_tool", {
|
|
1163
|
+
label: "Accordion",
|
|
1164
|
+
category: "layout",
|
|
1165
|
+
purpose: "Primary course module layout. Each section is a collapsible mini-module.",
|
|
1166
|
+
data: { sections: "array of { title, content, isOpen }", color: "hex color string" },
|
|
1167
|
+
example: { color: "#388ae5", sections: [{ title: "1. Comprendre", content: { blocks: [{ type: "paragraph", data: { text: "Explication." } }] }, isOpen: false }] },
|
|
1168
|
+
notes: ["Common for courses. Keep each section rich enough to stand alone."]
|
|
1169
|
+
}),
|
|
1170
|
+
block("vertical_accordion", {
|
|
1171
|
+
label: "Vertical Accordion",
|
|
1172
|
+
category: "layout",
|
|
1173
|
+
purpose: "Vertical variant of accordion, usually for compact sequences.",
|
|
1174
|
+
data: { sections: "array of { title, content, isOpen }", color: "hex color string", orientation: "vertical" },
|
|
1175
|
+
example: { color: "#2E5FAC", orientation: "vertical", sections: [{ title: "Etape 1", content: { blocks: [] }, isOpen: false }] }
|
|
1176
|
+
}),
|
|
1177
|
+
block("section_tool", {
|
|
1178
|
+
label: "Section",
|
|
1179
|
+
category: "layout",
|
|
1180
|
+
purpose: "Visual section wrapper. Gemini sections use gemini=true.",
|
|
1181
|
+
data: { backgroundColor: "hex color string", padding: "number", content: "EditorJS OutputData", gemini: "boolean" },
|
|
1182
|
+
example: { backgroundColor: "#eff6ff", padding: 16, gemini: true, content: { blocks: [{ type: "header", data: { text: "Avec Gemini", level: 2 } }] } }
|
|
1183
|
+
}),
|
|
1184
|
+
block("tabs", {
|
|
1185
|
+
label: "Tabs",
|
|
1186
|
+
category: "layout",
|
|
1187
|
+
purpose: "Tabbed layout, each tab containing nested blocks.",
|
|
1188
|
+
data: { tabs: "array of { id, title, content }", activeTab: "string" },
|
|
1189
|
+
example: { activeTab: "tab-1", tabs: [{ id: "tab-1", title: "Admin", content: { blocks: [] } }] }
|
|
1190
|
+
}),
|
|
1191
|
+
block("slider", {
|
|
1192
|
+
label: "Slider",
|
|
1193
|
+
category: "layout",
|
|
1194
|
+
purpose: "Slide-based layout, each slide containing nested blocks.",
|
|
1195
|
+
data: { slides: "array of { id, title, content }", activeSlide: "string", sliderColor: "hex color string" },
|
|
1196
|
+
example: { activeSlide: "slide-1", sliderColor: "#2E5FAC", slides: [{ id: "slide-1", title: "Avant", content: { blocks: [] } }] }
|
|
1197
|
+
}),
|
|
1198
|
+
block("quiz", {
|
|
1199
|
+
label: "Embedded Quiz",
|
|
1200
|
+
category: "interactive",
|
|
1201
|
+
purpose: "Embeds an existing quiz in a page.",
|
|
1202
|
+
data: { quizId: "string", quizTitle: "string", quizLang: "string" },
|
|
1203
|
+
example: { quizId: "quiz_abc123", quizTitle: "Quiz Gmail", quizLang: "fr" },
|
|
1204
|
+
notes: ["Use a real quiz id. Translate/relink to same-language quiz when translating page content."]
|
|
1205
|
+
}),
|
|
1206
|
+
block("pointRedemption", {
|
|
1207
|
+
label: "Point Redemption",
|
|
1208
|
+
category: "interactive",
|
|
1209
|
+
purpose: "Completion/reward button tied to a block id.",
|
|
1210
|
+
data: { text: "string", points: "number", blockId: "string", color: "string", redeemedText: "string" },
|
|
1211
|
+
example: { text: "Completer cette etape", points: 10, blockId: "drive-share-step", color: "#2E5FAC", redeemedText: "Etape terminee" }
|
|
1212
|
+
}),
|
|
1213
|
+
block("pageTag", {
|
|
1214
|
+
label: "Page Tag",
|
|
1215
|
+
category: "reference",
|
|
1216
|
+
purpose: "Reference card linking to another GSkills page.",
|
|
1217
|
+
data: { pageId: "string", pageName: "string", pageSlug: "string", description: "optional string", pageIcon: "optional string", categoryIcon: "optional string" },
|
|
1218
|
+
example: { pageId: "page_abc123", pageName: "Gmail", pageSlug: "gmail", description: "Aller plus loin" }
|
|
1219
|
+
}),
|
|
1220
|
+
block("learningPathTag", {
|
|
1221
|
+
label: "Learning Path Tag",
|
|
1222
|
+
category: "reference",
|
|
1223
|
+
purpose: "Reference card linking to a parcours.",
|
|
1224
|
+
data: { pathId: "string", pathName: "string", pathSlug: "string", description: "optional string" },
|
|
1225
|
+
example: { pathId: "lp_abc123", pathName: "Parcours Gemini", pathSlug: "parcours-gemini" }
|
|
1226
|
+
}),
|
|
1227
|
+
block("resourceTag", {
|
|
1228
|
+
label: "Resource Tag",
|
|
1229
|
+
category: "reference",
|
|
1230
|
+
purpose: "Reference card linking to a resource.",
|
|
1231
|
+
data: { resourceId: "string", resourceName: "string", description: "optional string", resourceType: "optional string" },
|
|
1232
|
+
example: { resourceId: "resource_abc123", resourceName: "Replay webinar", resourceType: "WEBINAR" }
|
|
1233
|
+
}),
|
|
1234
|
+
block("card", {
|
|
1235
|
+
label: "Card",
|
|
1236
|
+
category: "reference",
|
|
1237
|
+
purpose: "Manual card-style callout.",
|
|
1238
|
+
data: { title: "string", description: "string", iconUrl: "optional string", url: "optional string" },
|
|
1239
|
+
example: { title: "A retenir", description: "Un conseil actionnable.", iconUrl: "" }
|
|
1240
|
+
}),
|
|
1241
|
+
block("importedSheet", {
|
|
1242
|
+
label: "Imported Sheet",
|
|
1243
|
+
category: "reference",
|
|
1244
|
+
purpose: "Embeds an imported Google Sheet widget.",
|
|
1245
|
+
data: { importedSheetId: "string", locale: "language code" },
|
|
1246
|
+
example: { importedSheetId: "sheet_abc123", locale: "fr" },
|
|
1247
|
+
notes: ["Use imported-sheets CLI commands to create or inspect the sheet first."]
|
|
1248
|
+
}),
|
|
1249
|
+
block("boardly", {
|
|
1250
|
+
label: "Boardly",
|
|
1251
|
+
category: "embed",
|
|
1252
|
+
purpose: "Embeds a Boardly dashboard.",
|
|
1253
|
+
data: { dashboardId: "string", title: "optional string" },
|
|
1254
|
+
example: { dashboardId: "boardly_abc123", title: "Tableau de bord" }
|
|
1255
|
+
}),
|
|
1256
|
+
block("keystroke", {
|
|
1257
|
+
label: "Keystroke",
|
|
1258
|
+
category: "interactive",
|
|
1259
|
+
purpose: "Displays keyboard shortcuts.",
|
|
1260
|
+
data: { keys: "array or string depending on saved editor state", description: "string", borderColor: "optional string" },
|
|
1261
|
+
example: { keys: ["Ctrl", "K"], description: "Ouvrir la recherche", borderColor: "#2E5FAC" }
|
|
1262
|
+
}),
|
|
1263
|
+
block("actualitesNumeriblog", {
|
|
1264
|
+
label: "Numeriblog News",
|
|
1265
|
+
category: "embed",
|
|
1266
|
+
purpose: "Embeds Numeriblog news feed.",
|
|
1267
|
+
data: { title: "optional string", limit: "optional number" },
|
|
1268
|
+
example: { title: "Actualites Numeriblog", limit: 4 }
|
|
1269
|
+
}),
|
|
1270
|
+
block("googleWorkspaceNews", {
|
|
1271
|
+
label: "Google Workspace News",
|
|
1272
|
+
category: "embed",
|
|
1273
|
+
purpose: "Embeds Google Workspace news feed.",
|
|
1274
|
+
data: { title: "optional string", limit: "optional number" },
|
|
1275
|
+
example: { title: "Actualites Google Workspace", limit: 4 }
|
|
1276
|
+
}),
|
|
1277
|
+
block("sustainability", {
|
|
1278
|
+
label: "Sustainability",
|
|
1279
|
+
category: "interactive",
|
|
1280
|
+
purpose: "Sustainability impact calculator/content block.",
|
|
1281
|
+
data: { title: "string", description: "optional string", values: "tool-specific object" },
|
|
1282
|
+
example: { title: "Impact environnemental", description: "Estimation indicative" }
|
|
1283
|
+
}),
|
|
1284
|
+
block("rankingBadge", {
|
|
1285
|
+
label: "Ranking Badge",
|
|
1286
|
+
category: "interactive",
|
|
1287
|
+
purpose: "Badge/ranking visual block.",
|
|
1288
|
+
data: { title: "string", rank: "optional number", label: "optional string" },
|
|
1289
|
+
example: { title: "Champion Drive", rank: 1, label: "Top contributeur" }
|
|
1290
|
+
}),
|
|
1291
|
+
block("headerStyle", {
|
|
1292
|
+
label: "Header Style",
|
|
1293
|
+
category: "system",
|
|
1294
|
+
purpose: "Custom heading style tool. Prefer normal header unless matching an existing page.",
|
|
1295
|
+
data: { text: "string", level: "optional number", style: "optional string" },
|
|
1296
|
+
example: { text: "Titre stylise", level: 2, style: "default" }
|
|
1297
|
+
})
|
|
1298
|
+
],
|
|
1299
|
+
highRiskBlocks: [
|
|
1300
|
+
"quiz",
|
|
1301
|
+
"pageTag",
|
|
1302
|
+
"learningPathTag",
|
|
1303
|
+
"resourceTag",
|
|
1304
|
+
"importedSheet",
|
|
1305
|
+
"pointRedemption",
|
|
1306
|
+
"image",
|
|
1307
|
+
"video",
|
|
1308
|
+
"vimeo",
|
|
1309
|
+
"boardly"
|
|
1310
|
+
],
|
|
1311
|
+
validationChecklist: [
|
|
1312
|
+
"JSON parses and top-level blocks is an array.",
|
|
1313
|
+
"Every block has type and data.",
|
|
1314
|
+
"Nested containers use EditorJS OutputData objects with blocks arrays.",
|
|
1315
|
+
"Reference blocks use real ids from CLI reads, never invented ids.",
|
|
1316
|
+
"A dry-run page patch shows expected block/text deltas.",
|
|
1317
|
+
"After write, verify currentVersion changed and cache scopes are clear when visible content changed."
|
|
1318
|
+
]
|
|
1319
|
+
};
|
|
1320
|
+
|
|
1321
|
+
// ../../src/cli/page-blocks.ts
|
|
1322
|
+
import { createHash, randomUUID as randomUUID2 } from "node:crypto";
|
|
1323
|
+
var blockTypeSet = new Set(pageContentSchema.blockTypes.map((block2) => block2.type));
|
|
1324
|
+
var sha1String = (value) => createHash("sha1").update(value, "utf8").digest("hex");
|
|
1325
|
+
var parseEditorDocument = (rawContent) => {
|
|
1326
|
+
if (typeof rawContent !== "string") {
|
|
1327
|
+
throw new CliError("Page row does not include a string content field", 2);
|
|
1328
|
+
}
|
|
1329
|
+
let parsed;
|
|
1330
|
+
try {
|
|
1331
|
+
parsed = JSON.parse(rawContent);
|
|
1332
|
+
} catch {
|
|
1333
|
+
throw new CliError("Page content is not valid JSON", 2);
|
|
1334
|
+
}
|
|
1335
|
+
if (!isPlainRecord(parsed) || !Array.isArray(parsed.blocks)) {
|
|
1336
|
+
throw new CliError("Page content must be an EditorJS object with a blocks array", 2);
|
|
1337
|
+
}
|
|
1338
|
+
return parsed;
|
|
1339
|
+
};
|
|
1340
|
+
var validatePageContent = (content) => {
|
|
1341
|
+
const errors = [];
|
|
1342
|
+
const warnings = [];
|
|
1343
|
+
const blockIds = new Map;
|
|
1344
|
+
const unsupportedTypes = new Set;
|
|
1345
|
+
const locations = collectBlockLocations(content);
|
|
1346
|
+
for (const location of locations) {
|
|
1347
|
+
const path = toJsonPointer(location.blockPath);
|
|
1348
|
+
const block2 = location.block;
|
|
1349
|
+
if (!isPlainRecord(block2)) {
|
|
1350
|
+
errors.push(`${path} must be an object`);
|
|
1351
|
+
continue;
|
|
1352
|
+
}
|
|
1353
|
+
if (typeof block2.type !== "string" || block2.type.trim() === "") {
|
|
1354
|
+
errors.push(`${path}/type must be a non-empty string`);
|
|
1355
|
+
} else if (!blockTypeSet.has(block2.type)) {
|
|
1356
|
+
errors.push(`${path}/type "${block2.type}" is not in pages content-schema`);
|
|
1357
|
+
unsupportedTypes.add(block2.type);
|
|
1358
|
+
}
|
|
1359
|
+
if (block2.data === undefined) {
|
|
1360
|
+
errors.push(`${path}/data is required`);
|
|
1361
|
+
} else if (!isPlainRecord(block2.data)) {
|
|
1362
|
+
errors.push(`${path}/data must be an object`);
|
|
1363
|
+
}
|
|
1364
|
+
if (typeof block2.id === "string" && block2.id.trim()) {
|
|
1365
|
+
const firstPath = blockIds.get(block2.id);
|
|
1366
|
+
if (firstPath) {
|
|
1367
|
+
warnings.push(`${path}/id duplicates ${firstPath}/id (${block2.id})`);
|
|
1368
|
+
} else {
|
|
1369
|
+
blockIds.set(block2.id, path);
|
|
1370
|
+
}
|
|
1371
|
+
} else {
|
|
1372
|
+
warnings.push(`${path}/id is missing. Granular updates work best with stable block ids.`);
|
|
1373
|
+
}
|
|
1374
|
+
validateContainerShape(block2, path, errors);
|
|
1375
|
+
}
|
|
1376
|
+
return {
|
|
1377
|
+
ok: errors.length === 0,
|
|
1378
|
+
schema: {
|
|
1379
|
+
name: pageContentSchema.name,
|
|
1380
|
+
version: pageContentSchema.version
|
|
1381
|
+
},
|
|
1382
|
+
blockCount: locations.length,
|
|
1383
|
+
errors,
|
|
1384
|
+
warnings,
|
|
1385
|
+
unsupportedTypes: Array.from(unsupportedTypes).sort()
|
|
1386
|
+
};
|
|
1387
|
+
};
|
|
1388
|
+
var summarizeBlocks = (content) => collectBlockLocations(content).map((location) => ({
|
|
1389
|
+
id: location.block.id ?? null,
|
|
1390
|
+
type: location.block.type ?? null,
|
|
1391
|
+
path: toJsonPointer(location.blockPath),
|
|
1392
|
+
depth: location.depth,
|
|
1393
|
+
dataKeys: isPlainRecord(location.block.data) ? Object.keys(location.block.data).sort() : [],
|
|
1394
|
+
textPreview: getBlockTextPreview(location.block)
|
|
1395
|
+
}));
|
|
1396
|
+
var getBlockById = (content, blockId) => {
|
|
1397
|
+
const location = findBlockLocationById(content, blockId);
|
|
1398
|
+
if (!location) {
|
|
1399
|
+
throw new CliError(`Block not found: ${blockId}`, 2);
|
|
1400
|
+
}
|
|
1401
|
+
return {
|
|
1402
|
+
id: location.block.id ?? null,
|
|
1403
|
+
type: location.block.type ?? null,
|
|
1404
|
+
path: toJsonPointer(location.blockPath),
|
|
1405
|
+
depth: location.depth,
|
|
1406
|
+
dataKeys: isPlainRecord(location.block.data) ? Object.keys(location.block.data).sort() : [],
|
|
1407
|
+
textPreview: getBlockTextPreview(location.block),
|
|
1408
|
+
block: location.block
|
|
1409
|
+
};
|
|
1410
|
+
};
|
|
1411
|
+
var planReplaceText = (content, input) => {
|
|
1412
|
+
const beforeValidation = validatePageContent(content);
|
|
1413
|
+
const beforeBlock = requireBlock(content, input.blockId, input.expectType);
|
|
1414
|
+
const fieldSegments = resolveTextFieldSegments(beforeBlock.block, input.field);
|
|
1415
|
+
const currentValue = getObjectPathValue(beforeBlock.block, fieldSegments);
|
|
1416
|
+
if (typeof currentValue !== "string") {
|
|
1417
|
+
throw new CliError(`${toJsonPointer(beforeBlock.blockPath.concat(fieldSegments))} is not a string`, 2);
|
|
1418
|
+
}
|
|
1419
|
+
if (input.expectText !== undefined && currentValue !== input.expectText) {
|
|
1420
|
+
throw new CliError("Current block text does not match --expect-text", 2, {
|
|
1421
|
+
blockId: input.blockId,
|
|
1422
|
+
expected: input.expectText,
|
|
1423
|
+
actual: currentValue
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
const patch = [
|
|
1427
|
+
{ op: "test", path: `${toJsonPointer(beforeBlock.blockPath)}/id`, value: input.blockId },
|
|
1428
|
+
{ op: "test", path: `${toJsonPointer(beforeBlock.blockPath)}/type`, value: beforeBlock.block.type },
|
|
1429
|
+
{ op: "test", path: toJsonPointer(beforeBlock.blockPath.concat(fieldSegments)), value: currentValue },
|
|
1430
|
+
{ op: "replace", path: toJsonPointer(beforeBlock.blockPath.concat(fieldSegments)), value: input.text }
|
|
1431
|
+
];
|
|
1432
|
+
const afterContent = cloneEditorDocument(content);
|
|
1433
|
+
const afterTarget = requireBlock(afterContent, input.blockId, input.expectType);
|
|
1434
|
+
setObjectPathValue(afterTarget.block, fieldSegments, input.text);
|
|
1435
|
+
const afterValidation = validatePageContent(afterContent);
|
|
1436
|
+
assertNoNewValidationErrors(beforeValidation, afterValidation);
|
|
1437
|
+
return {
|
|
1438
|
+
patch,
|
|
1439
|
+
beforeContent: content,
|
|
1440
|
+
afterContent,
|
|
1441
|
+
beforeValidation,
|
|
1442
|
+
afterValidation,
|
|
1443
|
+
beforeBlock,
|
|
1444
|
+
afterBlock: requireBlock(afterContent, input.blockId, input.expectType),
|
|
1445
|
+
changedBlockId: input.blockId
|
|
1446
|
+
};
|
|
1447
|
+
};
|
|
1448
|
+
var planReplaceBlock = (content, input) => {
|
|
1449
|
+
const beforeValidation = validatePageContent(content);
|
|
1450
|
+
const beforeBlock = requireBlock(content, input.blockId, input.expectType);
|
|
1451
|
+
const nextBlock = normalizeInputBlock(input.block, beforeBlock.block.id ?? input.blockId);
|
|
1452
|
+
if (!input.allowIdChange && nextBlock.id !== input.blockId) {
|
|
1453
|
+
throw new CliError("Replacement block id must match --block-id unless --allow-id-change is passed", 2);
|
|
1454
|
+
}
|
|
1455
|
+
const blockValidation = validateStandaloneBlock(nextBlock);
|
|
1456
|
+
if (!blockValidation.ok) {
|
|
1457
|
+
throw new CliError("Replacement block does not match the page block schema", 2, {
|
|
1458
|
+
errors: blockValidation.errors,
|
|
1459
|
+
warnings: blockValidation.warnings
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
const patch = [
|
|
1463
|
+
{ op: "test", path: `${toJsonPointer(beforeBlock.blockPath)}/id`, value: input.blockId },
|
|
1464
|
+
{ op: "test", path: `${toJsonPointer(beforeBlock.blockPath)}/type`, value: beforeBlock.block.type },
|
|
1465
|
+
{ op: "replace", path: toJsonPointer(beforeBlock.blockPath), value: nextBlock }
|
|
1466
|
+
];
|
|
1467
|
+
const afterContent = cloneEditorDocument(content);
|
|
1468
|
+
const afterTarget = requireBlock(afterContent, input.blockId, input.expectType);
|
|
1469
|
+
const container = getArrayAtPath(afterContent, afterTarget.containerPath);
|
|
1470
|
+
container[afterTarget.index] = nextBlock;
|
|
1471
|
+
const afterValidation = validatePageContent(afterContent);
|
|
1472
|
+
assertNoNewValidationErrors(beforeValidation, afterValidation);
|
|
1473
|
+
return {
|
|
1474
|
+
patch,
|
|
1475
|
+
beforeContent: content,
|
|
1476
|
+
afterContent,
|
|
1477
|
+
beforeValidation,
|
|
1478
|
+
afterValidation,
|
|
1479
|
+
beforeBlock,
|
|
1480
|
+
afterBlock: findBlockLocationById(afterContent, nextBlock.id ?? input.blockId) ?? undefined,
|
|
1481
|
+
changedBlockId: nextBlock.id ?? input.blockId
|
|
1482
|
+
};
|
|
1483
|
+
};
|
|
1484
|
+
var planInsertAfterBlock = (content, input) => {
|
|
1485
|
+
const beforeValidation = validatePageContent(content);
|
|
1486
|
+
const beforeBlock = requireBlock(content, input.anchorBlockId);
|
|
1487
|
+
const nextBlock = normalizeInputBlock(input.block);
|
|
1488
|
+
const blockValidation = validateStandaloneBlock(nextBlock);
|
|
1489
|
+
if (!blockValidation.ok) {
|
|
1490
|
+
throw new CliError("Inserted block does not match the page block schema", 2, {
|
|
1491
|
+
errors: blockValidation.errors,
|
|
1492
|
+
warnings: blockValidation.warnings
|
|
1493
|
+
});
|
|
1494
|
+
}
|
|
1495
|
+
const insertPath = beforeBlock.containerPath.concat(beforeBlock.index + 1);
|
|
1496
|
+
const patch = [
|
|
1497
|
+
{ op: "test", path: `${toJsonPointer(beforeBlock.blockPath)}/id`, value: input.anchorBlockId },
|
|
1498
|
+
{ op: "test", path: `${toJsonPointer(beforeBlock.blockPath)}/type`, value: beforeBlock.block.type },
|
|
1499
|
+
{ op: "add", path: toJsonPointer(insertPath), value: nextBlock }
|
|
1500
|
+
];
|
|
1501
|
+
const afterContent = cloneEditorDocument(content);
|
|
1502
|
+
const afterAnchor = requireBlock(afterContent, input.anchorBlockId);
|
|
1503
|
+
getArrayAtPath(afterContent, afterAnchor.containerPath).splice(afterAnchor.index + 1, 0, nextBlock);
|
|
1504
|
+
const afterValidation = validatePageContent(afterContent);
|
|
1505
|
+
assertNoNewValidationErrors(beforeValidation, afterValidation);
|
|
1506
|
+
return {
|
|
1507
|
+
patch,
|
|
1508
|
+
beforeContent: content,
|
|
1509
|
+
afterContent,
|
|
1510
|
+
beforeValidation,
|
|
1511
|
+
afterValidation,
|
|
1512
|
+
beforeBlock,
|
|
1513
|
+
afterBlock: nextBlock.id ? findBlockLocationById(afterContent, nextBlock.id) ?? undefined : undefined,
|
|
1514
|
+
changedBlockId: nextBlock.id
|
|
1515
|
+
};
|
|
1516
|
+
};
|
|
1517
|
+
var planInsertBeforeBlock = (content, input) => {
|
|
1518
|
+
const beforeValidation = validatePageContent(content);
|
|
1519
|
+
const beforeBlock = requireBlock(content, input.anchorBlockId);
|
|
1520
|
+
const nextBlock = normalizeInputBlock(input.block);
|
|
1521
|
+
const blockValidation = validateStandaloneBlock(nextBlock);
|
|
1522
|
+
if (!blockValidation.ok) {
|
|
1523
|
+
throw new CliError("Inserted block does not match the page block schema", 2, {
|
|
1524
|
+
errors: blockValidation.errors,
|
|
1525
|
+
warnings: blockValidation.warnings
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
const insertPath = beforeBlock.containerPath.concat(beforeBlock.index);
|
|
1529
|
+
const patch = [
|
|
1530
|
+
{ op: "test", path: `${toJsonPointer(beforeBlock.blockPath)}/id`, value: input.anchorBlockId },
|
|
1531
|
+
{ op: "test", path: `${toJsonPointer(beforeBlock.blockPath)}/type`, value: beforeBlock.block.type },
|
|
1532
|
+
{ op: "add", path: toJsonPointer(insertPath), value: nextBlock }
|
|
1533
|
+
];
|
|
1534
|
+
const afterContent = cloneEditorDocument(content);
|
|
1535
|
+
const afterAnchor = requireBlock(afterContent, input.anchorBlockId);
|
|
1536
|
+
getArrayAtPath(afterContent, afterAnchor.containerPath).splice(afterAnchor.index, 0, nextBlock);
|
|
1537
|
+
const afterValidation = validatePageContent(afterContent);
|
|
1538
|
+
assertNoNewValidationErrors(beforeValidation, afterValidation);
|
|
1539
|
+
return {
|
|
1540
|
+
patch,
|
|
1541
|
+
beforeContent: content,
|
|
1542
|
+
afterContent,
|
|
1543
|
+
beforeValidation,
|
|
1544
|
+
afterValidation,
|
|
1545
|
+
beforeBlock,
|
|
1546
|
+
afterBlock: nextBlock.id ? findBlockLocationById(afterContent, nextBlock.id) ?? undefined : undefined,
|
|
1547
|
+
changedBlockId: nextBlock.id
|
|
1548
|
+
};
|
|
1549
|
+
};
|
|
1550
|
+
var planRemoveBlock = (content, input) => {
|
|
1551
|
+
const beforeValidation = validatePageContent(content);
|
|
1552
|
+
const beforeBlock = requireBlock(content, input.blockId, input.expectType);
|
|
1553
|
+
const patch = [
|
|
1554
|
+
{ op: "test", path: `${toJsonPointer(beforeBlock.blockPath)}/id`, value: input.blockId },
|
|
1555
|
+
{ op: "test", path: `${toJsonPointer(beforeBlock.blockPath)}/type`, value: beforeBlock.block.type },
|
|
1556
|
+
{ op: "remove", path: toJsonPointer(beforeBlock.blockPath) }
|
|
1557
|
+
];
|
|
1558
|
+
const afterContent = cloneEditorDocument(content);
|
|
1559
|
+
const afterTarget = requireBlock(afterContent, input.blockId, input.expectType);
|
|
1560
|
+
getArrayAtPath(afterContent, afterTarget.containerPath).splice(afterTarget.index, 1);
|
|
1561
|
+
const afterValidation = validatePageContent(afterContent);
|
|
1562
|
+
assertNoNewValidationErrors(beforeValidation, afterValidation);
|
|
1563
|
+
return {
|
|
1564
|
+
patch,
|
|
1565
|
+
beforeContent: content,
|
|
1566
|
+
afterContent,
|
|
1567
|
+
beforeValidation,
|
|
1568
|
+
afterValidation,
|
|
1569
|
+
beforeBlock,
|
|
1570
|
+
changedBlockId: input.blockId
|
|
1571
|
+
};
|
|
1572
|
+
};
|
|
1573
|
+
var validateStandaloneBlock = (block2) => validatePageContent({ blocks: [block2] });
|
|
1574
|
+
var assertNoNewValidationErrors = (before, after) => {
|
|
1575
|
+
const beforeErrors = new Set(before.errors);
|
|
1576
|
+
const newErrors = after.errors.filter((error) => !beforeErrors.has(error));
|
|
1577
|
+
if (newErrors.length > 0) {
|
|
1578
|
+
throw new CliError("Block operation would make page content invalid", 2, {
|
|
1579
|
+
errors: newErrors,
|
|
1580
|
+
warnings: after.warnings
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
};
|
|
1584
|
+
var requireBlock = (content, blockId, expectType) => {
|
|
1585
|
+
const location = findBlockLocationById(content, blockId);
|
|
1586
|
+
if (!location) {
|
|
1587
|
+
throw new CliError(`Block not found: ${blockId}`, 2);
|
|
1588
|
+
}
|
|
1589
|
+
if (expectType && location.block.type !== expectType) {
|
|
1590
|
+
throw new CliError("Block type does not match --expect-type", 2, {
|
|
1591
|
+
blockId,
|
|
1592
|
+
expected: expectType,
|
|
1593
|
+
actual: location.block.type ?? null
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
if (typeof location.block.type !== "string") {
|
|
1597
|
+
throw new CliError(`Block ${blockId} has no type`, 2);
|
|
1598
|
+
}
|
|
1599
|
+
return location;
|
|
1600
|
+
};
|
|
1601
|
+
var findBlockLocationById = (content, blockId) => collectBlockLocations(content).find((location) => location.block.id === blockId);
|
|
1602
|
+
var collectBlockLocations = (content) => {
|
|
1603
|
+
const locations = [];
|
|
1604
|
+
visitBlockArray(content.blocks, ["blocks"], 0, locations);
|
|
1605
|
+
return locations;
|
|
1606
|
+
};
|
|
1607
|
+
var visitBlockArray = (blocks, containerPath, depth, locations) => {
|
|
1608
|
+
blocks.forEach((candidate, index) => {
|
|
1609
|
+
if (!isPlainRecord(candidate)) {
|
|
1610
|
+
locations.push({
|
|
1611
|
+
block: candidate,
|
|
1612
|
+
index,
|
|
1613
|
+
depth,
|
|
1614
|
+
blockPath: containerPath.concat(index),
|
|
1615
|
+
containerPath
|
|
1616
|
+
});
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
const block2 = candidate;
|
|
1620
|
+
const blockPath = containerPath.concat(index);
|
|
1621
|
+
locations.push({ block: block2, index, depth, blockPath, containerPath });
|
|
1622
|
+
for (const childContainer of childBlockContainers(block2, blockPath)) {
|
|
1623
|
+
visitBlockArray(childContainer.blocks, childContainer.path, depth + 1, locations);
|
|
1624
|
+
}
|
|
1625
|
+
});
|
|
1626
|
+
};
|
|
1627
|
+
var childBlockContainers = (block2, blockPath) => {
|
|
1628
|
+
const containers = [];
|
|
1629
|
+
const data = isPlainRecord(block2.data) ? block2.data : null;
|
|
1630
|
+
if (!data)
|
|
1631
|
+
return containers;
|
|
1632
|
+
if (block2.type === "columns" && Array.isArray(data.cols)) {
|
|
1633
|
+
data.cols.forEach((column, columnIndex) => {
|
|
1634
|
+
if (isPlainRecord(column) && Array.isArray(column.blocks)) {
|
|
1635
|
+
containers.push({
|
|
1636
|
+
path: blockPath.concat(["data", "cols", columnIndex, "blocks"]),
|
|
1637
|
+
blocks: column.blocks
|
|
1638
|
+
});
|
|
1639
|
+
}
|
|
1640
|
+
});
|
|
1641
|
+
}
|
|
1642
|
+
if ((block2.type === "accordion_tool" || block2.type === "vertical_accordion") && Array.isArray(data.sections)) {
|
|
1643
|
+
data.sections.forEach((section, sectionIndex) => {
|
|
1644
|
+
if (isPlainRecord(section) && isPlainRecord(section.content) && Array.isArray(section.content.blocks)) {
|
|
1645
|
+
containers.push({
|
|
1646
|
+
path: blockPath.concat(["data", "sections", sectionIndex, "content", "blocks"]),
|
|
1647
|
+
blocks: section.content.blocks
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
if (block2.type === "section_tool" && isPlainRecord(data.content) && Array.isArray(data.content.blocks)) {
|
|
1653
|
+
containers.push({
|
|
1654
|
+
path: blockPath.concat(["data", "content", "blocks"]),
|
|
1655
|
+
blocks: data.content.blocks
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
if (block2.type === "tabs" && Array.isArray(data.tabs)) {
|
|
1659
|
+
data.tabs.forEach((tab, tabIndex) => {
|
|
1660
|
+
if (isPlainRecord(tab) && isPlainRecord(tab.content) && Array.isArray(tab.content.blocks)) {
|
|
1661
|
+
containers.push({
|
|
1662
|
+
path: blockPath.concat(["data", "tabs", tabIndex, "content", "blocks"]),
|
|
1663
|
+
blocks: tab.content.blocks
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
if (block2.type === "slider" && Array.isArray(data.slides)) {
|
|
1669
|
+
data.slides.forEach((slide, slideIndex) => {
|
|
1670
|
+
if (isPlainRecord(slide) && isPlainRecord(slide.content) && Array.isArray(slide.content.blocks)) {
|
|
1671
|
+
containers.push({
|
|
1672
|
+
path: blockPath.concat(["data", "slides", slideIndex, "content", "blocks"]),
|
|
1673
|
+
blocks: slide.content.blocks
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
return containers;
|
|
1679
|
+
};
|
|
1680
|
+
var validateContainerShape = (block2, path, errors) => {
|
|
1681
|
+
const data = isPlainRecord(block2.data) ? block2.data : null;
|
|
1682
|
+
if (!data)
|
|
1683
|
+
return;
|
|
1684
|
+
if (block2.type === "columns") {
|
|
1685
|
+
if (!Array.isArray(data.cols)) {
|
|
1686
|
+
errors.push(`${path}/data/cols must be an array`);
|
|
1687
|
+
return;
|
|
1688
|
+
}
|
|
1689
|
+
data.cols.forEach((column, index) => {
|
|
1690
|
+
if (!isPlainRecord(column) || !Array.isArray(column.blocks)) {
|
|
1691
|
+
errors.push(`${path}/data/cols/${index}/blocks must be an array`);
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
if (block2.type === "accordion_tool" || block2.type === "vertical_accordion") {
|
|
1696
|
+
if (!Array.isArray(data.sections)) {
|
|
1697
|
+
errors.push(`${path}/data/sections must be an array`);
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1700
|
+
data.sections.forEach((section, index) => {
|
|
1701
|
+
if (!isPlainRecord(section) || !isPlainRecord(section.content) || !Array.isArray(section.content.blocks)) {
|
|
1702
|
+
errors.push(`${path}/data/sections/${index}/content/blocks must be an array`);
|
|
1703
|
+
}
|
|
1704
|
+
});
|
|
1705
|
+
}
|
|
1706
|
+
if (block2.type === "section_tool" && (!isPlainRecord(data.content) || !Array.isArray(data.content.blocks))) {
|
|
1707
|
+
errors.push(`${path}/data/content/blocks must be an array`);
|
|
1708
|
+
}
|
|
1709
|
+
if (block2.type === "tabs") {
|
|
1710
|
+
if (!Array.isArray(data.tabs)) {
|
|
1711
|
+
errors.push(`${path}/data/tabs must be an array`);
|
|
1712
|
+
return;
|
|
1713
|
+
}
|
|
1714
|
+
data.tabs.forEach((tab, index) => {
|
|
1715
|
+
if (!isPlainRecord(tab) || !isPlainRecord(tab.content) || !Array.isArray(tab.content.blocks)) {
|
|
1716
|
+
errors.push(`${path}/data/tabs/${index}/content/blocks must be an array`);
|
|
1717
|
+
}
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
if (block2.type === "slider") {
|
|
1721
|
+
if (!Array.isArray(data.slides)) {
|
|
1722
|
+
errors.push(`${path}/data/slides must be an array`);
|
|
1723
|
+
return;
|
|
1724
|
+
}
|
|
1725
|
+
data.slides.forEach((slide, index) => {
|
|
1726
|
+
if (!isPlainRecord(slide) || !isPlainRecord(slide.content) || !Array.isArray(slide.content.blocks)) {
|
|
1727
|
+
errors.push(`${path}/data/slides/${index}/content/blocks must be an array`);
|
|
1728
|
+
}
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1731
|
+
};
|
|
1732
|
+
var normalizeInputBlock = (input, fallbackId = randomUUID2().replaceAll("-", "").slice(0, 12)) => {
|
|
1733
|
+
if (typeof input.type !== "string" || input.type.trim() === "") {
|
|
1734
|
+
throw new CliError("Block JSON must include a non-empty type", 2);
|
|
1735
|
+
}
|
|
1736
|
+
if (!isPlainRecord(input.data)) {
|
|
1737
|
+
throw new CliError("Block JSON must include a data object", 2);
|
|
1738
|
+
}
|
|
1739
|
+
return {
|
|
1740
|
+
...input,
|
|
1741
|
+
id: typeof input.id === "string" && input.id.trim() ? input.id : fallbackId,
|
|
1742
|
+
type: input.type,
|
|
1743
|
+
data: input.data
|
|
1744
|
+
};
|
|
1745
|
+
};
|
|
1746
|
+
var resolveTextFieldSegments = (block2, field) => {
|
|
1747
|
+
if (field)
|
|
1748
|
+
return parseFieldPath(field);
|
|
1749
|
+
if (isPlainRecord(block2.data)) {
|
|
1750
|
+
if (typeof block2.data.text === "string")
|
|
1751
|
+
return ["data", "text"];
|
|
1752
|
+
if (typeof block2.data.code === "string")
|
|
1753
|
+
return ["data", "code"];
|
|
1754
|
+
if (typeof block2.data.title === "string")
|
|
1755
|
+
return ["data", "title"];
|
|
1756
|
+
if (typeof block2.data.caption === "string")
|
|
1757
|
+
return ["data", "caption"];
|
|
1758
|
+
if (typeof block2.data.description === "string")
|
|
1759
|
+
return ["data", "description"];
|
|
1760
|
+
}
|
|
1761
|
+
throw new CliError("Could not infer a text field. Pass --field, for example --field data.text.", 2);
|
|
1762
|
+
};
|
|
1763
|
+
var parseFieldPath = (field) => {
|
|
1764
|
+
const trimmed = field.trim();
|
|
1765
|
+
if (!trimmed)
|
|
1766
|
+
throw new CliError("--field cannot be empty", 2);
|
|
1767
|
+
if (trimmed.startsWith("/"))
|
|
1768
|
+
return parseJsonPointer(trimmed);
|
|
1769
|
+
const rawSegments = trimmed.startsWith("data.") ? trimmed.split(".") : ["data", ...trimmed.split(".")];
|
|
1770
|
+
return rawSegments.map((segment) => {
|
|
1771
|
+
if (!segment)
|
|
1772
|
+
throw new CliError("--field contains an empty path segment", 2);
|
|
1773
|
+
return segment;
|
|
1774
|
+
});
|
|
1775
|
+
};
|
|
1776
|
+
var getBlockTextPreview = (block2) => {
|
|
1777
|
+
const data = isPlainRecord(block2.data) ? block2.data : {};
|
|
1778
|
+
const candidates = [data.text, data.title, data.description, data.code, data.caption];
|
|
1779
|
+
const text = candidates.find((value) => typeof value === "string");
|
|
1780
|
+
if (text)
|
|
1781
|
+
return text.replace(/\s+/g, " ").slice(0, 160);
|
|
1782
|
+
if (Array.isArray(data.items))
|
|
1783
|
+
return data.items.map((item) => String(item)).join(" ").slice(0, 160);
|
|
1784
|
+
return "";
|
|
1785
|
+
};
|
|
1786
|
+
var cloneEditorDocument = (content) => JSON.parse(JSON.stringify(content));
|
|
1787
|
+
var toJsonPointer = (segments) => `/${segments.map((segment) => String(segment).replaceAll("~", "~0").replaceAll("/", "~1")).join("/")}`;
|
|
1788
|
+
var parseJsonPointer = (pointer) => {
|
|
1789
|
+
if (pointer === "")
|
|
1790
|
+
return [];
|
|
1791
|
+
if (!pointer.startsWith("/"))
|
|
1792
|
+
throw new CliError(`Invalid JSON pointer: ${pointer}`, 2);
|
|
1793
|
+
return pointer.slice(1).split("/").map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"));
|
|
1794
|
+
};
|
|
1795
|
+
var getArrayAtPath = (root, path) => {
|
|
1796
|
+
const value = getObjectPathValue(root, path);
|
|
1797
|
+
if (!Array.isArray(value)) {
|
|
1798
|
+
throw new CliError(`${toJsonPointer(path)} is not an array`, 2);
|
|
1799
|
+
}
|
|
1800
|
+
return value;
|
|
1801
|
+
};
|
|
1802
|
+
var getObjectPathValue = (root, path) => {
|
|
1803
|
+
let cursor = root;
|
|
1804
|
+
for (const segment of path) {
|
|
1805
|
+
if (Array.isArray(cursor)) {
|
|
1806
|
+
const index = Number(segment);
|
|
1807
|
+
cursor = cursor[index];
|
|
1808
|
+
continue;
|
|
1809
|
+
}
|
|
1810
|
+
if (!isPlainRecord(cursor)) {
|
|
1811
|
+
return;
|
|
1812
|
+
}
|
|
1813
|
+
cursor = cursor[String(segment)];
|
|
1814
|
+
}
|
|
1815
|
+
return cursor;
|
|
1816
|
+
};
|
|
1817
|
+
var setObjectPathValue = (root, path, value) => {
|
|
1818
|
+
const target = getObjectPathParent(root, path);
|
|
1819
|
+
if (Array.isArray(target.parent)) {
|
|
1820
|
+
target.parent[Number(target.key)] = value;
|
|
1821
|
+
return;
|
|
1822
|
+
}
|
|
1823
|
+
target.parent[String(target.key)] = value;
|
|
1824
|
+
};
|
|
1825
|
+
var getObjectPathParent = (root, path) => {
|
|
1826
|
+
if (path.length === 0)
|
|
1827
|
+
throw new CliError("Cannot mutate document root in a block helper", 2);
|
|
1828
|
+
const parentPath = path.slice(0, -1);
|
|
1829
|
+
const key = path[path.length - 1];
|
|
1830
|
+
const parent = getObjectPathValue(root, parentPath);
|
|
1831
|
+
if (!isPlainRecord(parent) && !Array.isArray(parent)) {
|
|
1832
|
+
throw new CliError(`${toJsonPointer(parentPath)} is not mutable`, 2);
|
|
1833
|
+
}
|
|
1834
|
+
return { parent, key };
|
|
1835
|
+
};
|
|
1836
|
+
var isPlainRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1837
|
+
|
|
876
1838
|
// ../../src/cli/commands.ts
|
|
877
1839
|
import { createReadStream } from "node:fs";
|
|
878
1840
|
import { cp, mkdir as mkdir2, readFile as readFile2, readdir, stat } from "node:fs/promises";
|
|
879
1841
|
import { basename, dirname as dirname2, extname, join as join2, resolve } from "node:path";
|
|
880
1842
|
import { homedir as homedir2 } from "node:os";
|
|
881
1843
|
import { fileURLToPath } from "node:url";
|
|
1844
|
+
|
|
1845
|
+
// ../../src/lib/supported-locales.ts
|
|
1846
|
+
var supportedLocales = [
|
|
1847
|
+
"ar",
|
|
1848
|
+
"bg",
|
|
1849
|
+
"cs",
|
|
1850
|
+
"da",
|
|
1851
|
+
"de",
|
|
1852
|
+
"el",
|
|
1853
|
+
"en",
|
|
1854
|
+
"es",
|
|
1855
|
+
"et",
|
|
1856
|
+
"fa",
|
|
1857
|
+
"fi",
|
|
1858
|
+
"fil",
|
|
1859
|
+
"fr",
|
|
1860
|
+
"fr-CA",
|
|
1861
|
+
"he",
|
|
1862
|
+
"hi",
|
|
1863
|
+
"hr",
|
|
1864
|
+
"hu",
|
|
1865
|
+
"id",
|
|
1866
|
+
"is",
|
|
1867
|
+
"it",
|
|
1868
|
+
"ja",
|
|
1869
|
+
"ko",
|
|
1870
|
+
"lt",
|
|
1871
|
+
"lv",
|
|
1872
|
+
"ms",
|
|
1873
|
+
"nl",
|
|
1874
|
+
"no",
|
|
1875
|
+
"pl",
|
|
1876
|
+
"pt",
|
|
1877
|
+
"pt-BR",
|
|
1878
|
+
"ro",
|
|
1879
|
+
"ru",
|
|
1880
|
+
"sk",
|
|
1881
|
+
"sl",
|
|
1882
|
+
"sq",
|
|
1883
|
+
"sr",
|
|
1884
|
+
"sv",
|
|
1885
|
+
"th",
|
|
1886
|
+
"tr",
|
|
1887
|
+
"uk",
|
|
1888
|
+
"ur",
|
|
1889
|
+
"vi",
|
|
1890
|
+
"zh"
|
|
1891
|
+
];
|
|
1892
|
+
|
|
1893
|
+
// ../../src/cli/commands.ts
|
|
882
1894
|
var runCommand = async (ctx) => {
|
|
883
1895
|
const [group, actionOrResource, maybeAction, ...rest] = ctx.args;
|
|
884
1896
|
if (!group || group === "help")
|
|
885
1897
|
return rootHelp();
|
|
886
1898
|
if (group === "schema")
|
|
887
1899
|
return schemaHelp();
|
|
888
|
-
if (group === "skills")
|
|
1900
|
+
if (group === "skills" && isBundledSkillsCommand(actionOrResource))
|
|
889
1901
|
return runSkillsCommand(actionOrResource, ctx);
|
|
890
1902
|
if (group === "auth")
|
|
891
1903
|
return runAuthCommand(actionOrResource, ctx);
|
|
@@ -954,7 +1966,7 @@ var runAuthCommand = async (action, ctx) => {
|
|
|
954
1966
|
}
|
|
955
1967
|
throw new CliError(`Unknown auth command "${action}"`, 2);
|
|
956
1968
|
};
|
|
957
|
-
var runResourceCommand = async (resource, action, maybeId,
|
|
1969
|
+
var runResourceCommand = async (resource, action, maybeId, rest, ctx) => {
|
|
958
1970
|
if (!action || action === "help")
|
|
959
1971
|
return resourceHelp(resource);
|
|
960
1972
|
if (resource.name === "internal-knowledge" && action === "sync-media") {
|
|
@@ -963,6 +1975,17 @@ var runResourceCommand = async (resource, action, maybeId, _rest, ctx) => {
|
|
|
963
1975
|
if (resource.name === "pages" && action === "backfill-field") {
|
|
964
1976
|
return runPagesBackfillFieldCommand(ctx);
|
|
965
1977
|
}
|
|
1978
|
+
if (resource.name === "pages" && (action === "block" || action === "blocks" && maybeId && isPageBlockAction(maybeId))) {
|
|
1979
|
+
return runPagesBlockCommand(maybeId, rest[0], ctx);
|
|
1980
|
+
}
|
|
1981
|
+
if (resource.name === "pages" && (action === "content-schema" || action === "block-schema" || action === "blocks")) {
|
|
1982
|
+
return pageContentSchema;
|
|
1983
|
+
}
|
|
1984
|
+
if (resource.name === "pages" && action === "patch-content") {
|
|
1985
|
+
if (!maybeId)
|
|
1986
|
+
throw new CliError("Missing pages id", 2);
|
|
1987
|
+
return runPagesPatchContentCommand(maybeId, ctx);
|
|
1988
|
+
}
|
|
966
1989
|
if (action === "list")
|
|
967
1990
|
return listResource(resource, ctx);
|
|
968
1991
|
if (action === "get") {
|
|
@@ -1012,14 +2035,15 @@ var listResource = async (resource, ctx) => {
|
|
|
1012
2035
|
return requestApi(`/api/cli/${resource.name}?${searchParams.toString()}`);
|
|
1013
2036
|
};
|
|
1014
2037
|
var createResource = async (resource, ctx) => {
|
|
1015
|
-
|
|
2038
|
+
requireWriteConfirmation(`${resource.label} creation writes data. Add --yes or use --dry-run.`, ctx);
|
|
2039
|
+
const data = await parseJsonObjectFlag(ctx, "data", "data-file");
|
|
1016
2040
|
const instanceId = getStringFlag(ctx, "instance") ?? defaultInstanceId(resource);
|
|
1017
2041
|
const instanceField = resource.instanceField === undefined ? "instanceId" : resource.instanceField;
|
|
1018
2042
|
if (instanceId && instanceField && !instanceField.includes(".") && data[instanceField] === undefined)
|
|
1019
2043
|
data[instanceField] = instanceId;
|
|
1020
2044
|
await applyUploadFileData(resource, data, ctx, { id: null, instanceId: getInstanceIdFromData(data) ?? instanceId });
|
|
1021
2045
|
if (Object.keys(data).length === 0)
|
|
1022
|
-
throw new CliError("Missing --data JSON", 2);
|
|
2046
|
+
throw new CliError("Missing --data or --data-file JSON", 2);
|
|
1023
2047
|
if (hasFlag(ctx, "dry-run"))
|
|
1024
2048
|
return { dryRun: true, resource: resource.name, data };
|
|
1025
2049
|
return requestApi(`/api/cli/${resource.name}`, {
|
|
@@ -1028,10 +2052,11 @@ var createResource = async (resource, ctx) => {
|
|
|
1028
2052
|
});
|
|
1029
2053
|
};
|
|
1030
2054
|
var updateResource = async (resource, id, ctx) => {
|
|
1031
|
-
|
|
2055
|
+
requireWriteConfirmation(`${resource.label} update writes data. Add --yes or use --dry-run.`, ctx);
|
|
2056
|
+
const data = await parseJsonObjectFlag(ctx, "data", "data-file");
|
|
1032
2057
|
await applyUploadFileData(resource, data, ctx, { id, instanceId: getStringFlag(ctx, "instance") ?? getInstanceIdFromData(data) });
|
|
1033
2058
|
if (Object.keys(data).length === 0)
|
|
1034
|
-
throw new CliError("Missing --data JSON", 2);
|
|
2059
|
+
throw new CliError("Missing --data or --data-file JSON", 2);
|
|
1035
2060
|
if (hasFlag(ctx, "dry-run"))
|
|
1036
2061
|
return { dryRun: true, resource: resource.name, id, data };
|
|
1037
2062
|
return requestApi(`/api/cli/${resource.name}/${id}`, {
|
|
@@ -1587,6 +2612,215 @@ var runPagesBackfillFieldCommand = async (ctx) => {
|
|
|
1587
2612
|
})
|
|
1588
2613
|
});
|
|
1589
2614
|
};
|
|
2615
|
+
var runPagesPatchContentCommand = async (pageId, ctx) => {
|
|
2616
|
+
requireWriteConfirmation("Page content patch writes content. Add --yes or use --dry-run.", ctx);
|
|
2617
|
+
const patch = await parseJsonArrayFlag(ctx, "patch", "patch-file");
|
|
2618
|
+
if (patch.length === 0)
|
|
2619
|
+
throw new CliError("Missing --patch or --patch-file JSON array", 2);
|
|
2620
|
+
return requestApi(`/api/cli/pages/${pageId}/patch-content`, {
|
|
2621
|
+
method: "POST",
|
|
2622
|
+
body: JSON.stringify({
|
|
2623
|
+
patch,
|
|
2624
|
+
reason: getStringFlag(ctx, "reason"),
|
|
2625
|
+
expectedUpdatedAt: getStringFlag(ctx, "expect-updated-at"),
|
|
2626
|
+
expectedCurrentVersion: getNumberFlag(ctx, "expect-version"),
|
|
2627
|
+
expectedContentSha1: getStringFlag(ctx, "expect-content-sha1"),
|
|
2628
|
+
dryRun: hasFlag(ctx, "dry-run")
|
|
2629
|
+
})
|
|
2630
|
+
});
|
|
2631
|
+
};
|
|
2632
|
+
var PAGE_BLOCK_ACTIONS = new Set(["list", "get", "replace-text", "replace", "insert-before", "insert-after", "remove", "help"]);
|
|
2633
|
+
var isPageBlockAction = (value) => typeof value === "string" && PAGE_BLOCK_ACTIONS.has(value);
|
|
2634
|
+
var runPagesBlockCommand = async (action, pageId, ctx) => {
|
|
2635
|
+
if (!action || action === "help")
|
|
2636
|
+
return pagesBlockHelp();
|
|
2637
|
+
if (!pageId)
|
|
2638
|
+
throw new CliError("Missing page id", 2);
|
|
2639
|
+
const page = await loadPageForBlockCommand(pageId);
|
|
2640
|
+
const content = parseEditorDocument(page.content);
|
|
2641
|
+
const pageSummary = summarizePageForBlockCommand(page, content);
|
|
2642
|
+
const includeContent = hasFlag(ctx, "include-content");
|
|
2643
|
+
if (action === "list") {
|
|
2644
|
+
return {
|
|
2645
|
+
page: pageSummary,
|
|
2646
|
+
fullContentRead: true,
|
|
2647
|
+
validation: validatePageContent(content),
|
|
2648
|
+
blocks: summarizeBlocks(content),
|
|
2649
|
+
...includeContent ? { content } : {}
|
|
2650
|
+
};
|
|
2651
|
+
}
|
|
2652
|
+
if (action === "get") {
|
|
2653
|
+
const blockId = requireStringFlag(ctx, "block-id");
|
|
2654
|
+
return {
|
|
2655
|
+
page: pageSummary,
|
|
2656
|
+
fullContentRead: true,
|
|
2657
|
+
validation: validatePageContent(content),
|
|
2658
|
+
block: getBlockById(content, blockId),
|
|
2659
|
+
...includeContent ? { content } : {}
|
|
2660
|
+
};
|
|
2661
|
+
}
|
|
2662
|
+
requireWriteConfirmation("Page block operation writes content. Add --yes or use --dry-run.", ctx);
|
|
2663
|
+
const plan = await buildPageBlockOperationPlan(action, content, ctx);
|
|
2664
|
+
const expectedContentSha1 = getStringFlag(ctx, "expect-content-sha1") ?? pageSummary.contentSha1;
|
|
2665
|
+
const expectedCurrentVersion = getNumberFlag(ctx, "expect-version") ?? pageSummary.currentVersion;
|
|
2666
|
+
const serverResult = await requestApi(`/api/cli/pages/${pageId}/patch-content`, {
|
|
2667
|
+
method: "POST",
|
|
2668
|
+
body: JSON.stringify({
|
|
2669
|
+
patch: plan.patch,
|
|
2670
|
+
reason: getStringFlag(ctx, "reason") ?? `CLI ${action} block ${plan.changedBlockId ?? ""}`.trim(),
|
|
2671
|
+
expectedUpdatedAt: getStringFlag(ctx, "expect-updated-at"),
|
|
2672
|
+
expectedCurrentVersion,
|
|
2673
|
+
expectedContentSha1,
|
|
2674
|
+
dryRun: hasFlag(ctx, "dry-run")
|
|
2675
|
+
})
|
|
2676
|
+
});
|
|
2677
|
+
if (hasFlag(ctx, "dry-run")) {
|
|
2678
|
+
return {
|
|
2679
|
+
success: true,
|
|
2680
|
+
dryRun: true,
|
|
2681
|
+
operation: {
|
|
2682
|
+
action,
|
|
2683
|
+
pageId,
|
|
2684
|
+
blockId: plan.changedBlockId ?? null,
|
|
2685
|
+
patchOperationCount: plan.patch.length
|
|
2686
|
+
},
|
|
2687
|
+
page: pageSummary,
|
|
2688
|
+
fullContentRead: true,
|
|
2689
|
+
block: summarizeBeforeAfterBlocks(plan.beforeContent, plan.afterContent, plan.changedBlockId),
|
|
2690
|
+
patch: plan.patch,
|
|
2691
|
+
validation: {
|
|
2692
|
+
before: plan.beforeValidation,
|
|
2693
|
+
after: plan.afterValidation
|
|
2694
|
+
},
|
|
2695
|
+
server: serverResult,
|
|
2696
|
+
...includeContent ? { predictedContent: plan.afterContent } : {}
|
|
2697
|
+
};
|
|
2698
|
+
}
|
|
2699
|
+
const afterPage = await loadPageForBlockCommand(pageId);
|
|
2700
|
+
const afterContent = parseEditorDocument(afterPage.content);
|
|
2701
|
+
const afterValidation = validatePageContent(afterContent);
|
|
2702
|
+
return {
|
|
2703
|
+
success: true,
|
|
2704
|
+
dryRun: false,
|
|
2705
|
+
operation: {
|
|
2706
|
+
action,
|
|
2707
|
+
pageId,
|
|
2708
|
+
blockId: plan.changedBlockId ?? null,
|
|
2709
|
+
patchOperationCount: plan.patch.length
|
|
2710
|
+
},
|
|
2711
|
+
page: summarizePageForBlockCommand(afterPage, afterContent),
|
|
2712
|
+
fullContentRead: true,
|
|
2713
|
+
block: plan.changedBlockId ? getBlockById(afterContent, plan.changedBlockId) : null,
|
|
2714
|
+
patch: plan.patch,
|
|
2715
|
+
validation: {
|
|
2716
|
+
before: plan.beforeValidation,
|
|
2717
|
+
predicted: plan.afterValidation,
|
|
2718
|
+
after: afterValidation
|
|
2719
|
+
},
|
|
2720
|
+
server: serverResult,
|
|
2721
|
+
...includeContent ? { content: afterContent } : {}
|
|
2722
|
+
};
|
|
2723
|
+
};
|
|
2724
|
+
var buildPageBlockOperationPlan = async (action, content, ctx) => {
|
|
2725
|
+
if (action === "replace-text") {
|
|
2726
|
+
const text = await getTextFlag(ctx, "text", "text-file");
|
|
2727
|
+
if (text === undefined)
|
|
2728
|
+
throw new CliError("Missing --text or --text-file", 2);
|
|
2729
|
+
const expectText = await getTextFlag(ctx, "expect-text", "expect-text-file");
|
|
2730
|
+
return planReplaceText(content, {
|
|
2731
|
+
blockId: requireStringFlag(ctx, "block-id"),
|
|
2732
|
+
text,
|
|
2733
|
+
field: getStringFlag(ctx, "field"),
|
|
2734
|
+
expectText,
|
|
2735
|
+
expectType: getStringFlag(ctx, "expect-type")
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
if (action === "replace") {
|
|
2739
|
+
const block2 = await parseJsonObjectFlag(ctx, "block", "block-file");
|
|
2740
|
+
if (Object.keys(block2).length === 0)
|
|
2741
|
+
throw new CliError("Missing --block or --block-file JSON object", 2);
|
|
2742
|
+
return planReplaceBlock(content, {
|
|
2743
|
+
blockId: requireStringFlag(ctx, "block-id"),
|
|
2744
|
+
block: block2,
|
|
2745
|
+
expectType: getStringFlag(ctx, "expect-type"),
|
|
2746
|
+
allowIdChange: hasFlag(ctx, "allow-id-change")
|
|
2747
|
+
});
|
|
2748
|
+
}
|
|
2749
|
+
if (action === "insert-after") {
|
|
2750
|
+
const block2 = await parseJsonObjectFlag(ctx, "block", "block-file");
|
|
2751
|
+
if (Object.keys(block2).length === 0)
|
|
2752
|
+
throw new CliError("Missing --block or --block-file JSON object", 2);
|
|
2753
|
+
return planInsertAfterBlock(content, {
|
|
2754
|
+
anchorBlockId: requireStringFlag(ctx, "block-id"),
|
|
2755
|
+
block: block2
|
|
2756
|
+
});
|
|
2757
|
+
}
|
|
2758
|
+
if (action === "insert-before") {
|
|
2759
|
+
const block2 = await parseJsonObjectFlag(ctx, "block", "block-file");
|
|
2760
|
+
if (Object.keys(block2).length === 0)
|
|
2761
|
+
throw new CliError("Missing --block or --block-file JSON object", 2);
|
|
2762
|
+
return planInsertBeforeBlock(content, {
|
|
2763
|
+
anchorBlockId: requireStringFlag(ctx, "block-id"),
|
|
2764
|
+
block: block2
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2767
|
+
if (action === "remove") {
|
|
2768
|
+
return planRemoveBlock(content, {
|
|
2769
|
+
blockId: requireStringFlag(ctx, "block-id"),
|
|
2770
|
+
expectType: getStringFlag(ctx, "expect-type")
|
|
2771
|
+
});
|
|
2772
|
+
}
|
|
2773
|
+
throw new CliError(`Unknown pages block command "${action}"`, 2);
|
|
2774
|
+
};
|
|
2775
|
+
var loadPageForBlockCommand = async (pageId) => {
|
|
2776
|
+
const page = await requestApi(`/api/cli/pages/${pageId}`);
|
|
2777
|
+
if (!isRecord(page) || typeof page.id !== "string" || typeof page.content !== "string") {
|
|
2778
|
+
throw new CliError("CLI page response did not include id and content", 1);
|
|
2779
|
+
}
|
|
2780
|
+
return {
|
|
2781
|
+
id: page.id,
|
|
2782
|
+
name: typeof page.name === "string" ? page.name : null,
|
|
2783
|
+
slug: typeof page.slug === "string" ? page.slug : null,
|
|
2784
|
+
language: typeof page.language === "string" ? page.language : null,
|
|
2785
|
+
instanceId: typeof page.instanceId === "string" ? page.instanceId : null,
|
|
2786
|
+
updatedAt: typeof page.updatedAt === "string" || page.updatedAt instanceof Date ? page.updatedAt : null,
|
|
2787
|
+
currentVersion: typeof page.currentVersion === "number" ? page.currentVersion : null,
|
|
2788
|
+
content: page.content
|
|
2789
|
+
};
|
|
2790
|
+
};
|
|
2791
|
+
var summarizePageForBlockCommand = (page, content) => ({
|
|
2792
|
+
id: page.id,
|
|
2793
|
+
name: page.name ?? null,
|
|
2794
|
+
slug: page.slug ?? null,
|
|
2795
|
+
language: page.language ?? null,
|
|
2796
|
+
instanceId: page.instanceId ?? null,
|
|
2797
|
+
updatedAt: page.updatedAt instanceof Date ? page.updatedAt.toISOString() : page.updatedAt ?? null,
|
|
2798
|
+
currentVersion: page.currentVersion ?? undefined,
|
|
2799
|
+
contentSha1: sha1String(page.content),
|
|
2800
|
+
blockCount: summarizeBlocks(content).length
|
|
2801
|
+
});
|
|
2802
|
+
var summarizeBeforeAfterBlocks = (beforeContent, afterContent, blockId) => {
|
|
2803
|
+
if (!blockId)
|
|
2804
|
+
return null;
|
|
2805
|
+
return {
|
|
2806
|
+
before: tryGetBlockById(beforeContent, blockId),
|
|
2807
|
+
after: tryGetBlockById(afterContent, blockId)
|
|
2808
|
+
};
|
|
2809
|
+
};
|
|
2810
|
+
var tryGetBlockById = (content, blockId) => {
|
|
2811
|
+
try {
|
|
2812
|
+
return getBlockById(content, blockId);
|
|
2813
|
+
} catch {
|
|
2814
|
+
return null;
|
|
2815
|
+
}
|
|
2816
|
+
};
|
|
2817
|
+
var requireStringFlag = (ctx, name) => {
|
|
2818
|
+
const value = getStringFlag(ctx, name);
|
|
2819
|
+
if (!value)
|
|
2820
|
+
throw new CliError(`Missing --${name}`, 2);
|
|
2821
|
+
return value;
|
|
2822
|
+
};
|
|
2823
|
+
var isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1590
2824
|
var runEntitiesCommand = async (action, entityId, ctx) => {
|
|
1591
2825
|
if (!action || action === "help")
|
|
1592
2826
|
return entitiesHelp();
|
|
@@ -1790,11 +3024,11 @@ var runTranslateCommand = async (kind, id, ctx) => {
|
|
|
1790
3024
|
throw new CliError("Missing source content id, --ids, or --all", 2);
|
|
1791
3025
|
if (all && (id || ids.length > 0))
|
|
1792
3026
|
throw new CliError("Use either an id/--ids or --all, not both", 2);
|
|
1793
|
-
|
|
3027
|
+
let targetLanguages = splitCsv(getStringFlag(ctx, "to") ?? getStringFlag(ctx, "languages"));
|
|
1794
3028
|
if (targetLanguages.length === 0)
|
|
1795
3029
|
throw new CliError("Missing --to", 2);
|
|
1796
3030
|
if (targetLanguages.some((language) => language.toLowerCase() === "all")) {
|
|
1797
|
-
|
|
3031
|
+
targetLanguages = [...supportedLocales];
|
|
1798
3032
|
}
|
|
1799
3033
|
if (!hasFlag(ctx, "yes") && !hasFlag(ctx, "dry-run")) {
|
|
1800
3034
|
throw new CliError("AI translation writes content. Add --yes or use --dry-run.", 2);
|
|
@@ -1813,6 +3047,7 @@ var runTranslateCommand = async (kind, id, ctx) => {
|
|
|
1813
3047
|
sourceLanguage: getStringFlag(ctx, "from") ?? getStringFlag(ctx, "source-language"),
|
|
1814
3048
|
sourceHistoryEntryId: getStringFlag(ctx, "source-history") ?? getStringFlag(ctx, "source-history-entry"),
|
|
1815
3049
|
mode,
|
|
3050
|
+
concurrency: getNumberFlag(ctx, "concurrency"),
|
|
1816
3051
|
dryRun: hasFlag(ctx, "dry-run")
|
|
1817
3052
|
})
|
|
1818
3053
|
});
|
|
@@ -2469,7 +3704,13 @@ var GLOBAL_DEFAULT_RESOURCES = new Set([
|
|
|
2469
3704
|
"menus",
|
|
2470
3705
|
"menu-sections",
|
|
2471
3706
|
"workflows",
|
|
2472
|
-
"chromebook-exercises"
|
|
3707
|
+
"chromebook-exercises",
|
|
3708
|
+
"skill-applications",
|
|
3709
|
+
"skill-capabilities",
|
|
3710
|
+
"skill-clusters",
|
|
3711
|
+
"skills",
|
|
3712
|
+
"skill-sets",
|
|
3713
|
+
"skill-objectives"
|
|
2473
3714
|
]);
|
|
2474
3715
|
var defaultInstanceId = (resource) => GLOBAL_DEFAULT_RESOURCES.has(resource.name) ? "global" : undefined;
|
|
2475
3716
|
var skillsSourceRootDir = async () => {
|
|
@@ -2522,6 +3763,23 @@ var parseJsonObjectFlag = async (ctx, inlineName, fileName) => {
|
|
|
2522
3763
|
const text = await getTextFlag(ctx, inlineName, fileName);
|
|
2523
3764
|
return parseJsonObject(text, `--${inlineName}`);
|
|
2524
3765
|
};
|
|
3766
|
+
var parseJsonArrayFlag = async (ctx, inlineName, fileName) => {
|
|
3767
|
+
const text = await getTextFlag(ctx, inlineName, fileName);
|
|
3768
|
+
if (!text)
|
|
3769
|
+
return [];
|
|
3770
|
+
try {
|
|
3771
|
+
const parsed = JSON.parse(text);
|
|
3772
|
+
if (!Array.isArray(parsed)) {
|
|
3773
|
+
throw new CliError(`--${inlineName} must be a JSON array`, 2);
|
|
3774
|
+
}
|
|
3775
|
+
return parsed;
|
|
3776
|
+
} catch (error) {
|
|
3777
|
+
if (error instanceof CliError)
|
|
3778
|
+
throw error;
|
|
3779
|
+
throw new CliError(`Could not parse --${inlineName} as JSON`, 2);
|
|
3780
|
+
}
|
|
3781
|
+
};
|
|
3782
|
+
var isBundledSkillsCommand = (action) => !action || action === "help" || action === "install" || action === "path";
|
|
2525
3783
|
var getNumberFlag = (ctx, name) => {
|
|
2526
3784
|
const value = getStringFlag(ctx, name);
|
|
2527
3785
|
if (!value)
|
|
@@ -2544,10 +3802,15 @@ var rootHelp = () => ({
|
|
|
2544
3802
|
"gskills-admin auth whoami",
|
|
2545
3803
|
"gskills-admin pages list",
|
|
2546
3804
|
`gskills-admin pages update <id> --data '{"disabled":true}'`,
|
|
3805
|
+
"gskills-admin pages content-schema --output json",
|
|
3806
|
+
"gskills-admin pages patch-content <id> --patch-file ./page.patch.json --dry-run",
|
|
3807
|
+
"gskills-admin pages block replace-text <id> --block-id <blockId> --text-file ./block.txt --dry-run",
|
|
2547
3808
|
"gskills-admin pages delete <id> --force --confirm-delete pages:<id> # soft-disables only",
|
|
2548
3809
|
"gskills-admin sync run --target <instanceId> --only pages,quizzes --yes",
|
|
2549
3810
|
"gskills-admin sync repair-source-links --target <instanceId> --dry-run",
|
|
2550
3811
|
"gskills-admin translate pages <id> --to en,es --dry-run",
|
|
3812
|
+
"gskills-admin translate changelogs <id> --to all --concurrency 8 --yes",
|
|
3813
|
+
`gskills-admin changelog-groups create --data '{"name":"...","releaseDate":"2026-06-08T10:00:00.000Z"}' --yes`,
|
|
2551
3814
|
"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",
|
|
2552
3815
|
`gskills-admin internal-knowledge create --instance <instanceId> --upload-file ./video.mp4 --data '{"title":"...","language":"fr"}' --yes`,
|
|
2553
3816
|
`gskills-admin resources create --instance <instanceId> --upload-file ./webinar.mp4 --data '{"title":"...","type":"WEBINAR","language":"fr"}' --yes`,
|
|
@@ -2587,7 +3850,7 @@ var schemaHelp = () => ({
|
|
|
2587
3850
|
{ name: "sync repair-source-links", required: ["--target"], flags: ["--source", "--yes", "--dry-run"], writes: true },
|
|
2588
3851
|
{ name: "cache scopes", writes: false },
|
|
2589
3852
|
{ name: "cache invalidate", required: ["--instance"], flags: ["--scope", "--languages", "--yes", "--dry-run"], writes: true },
|
|
2590
|
-
{ name: "translate", args: ["kind", "id?"], required: ["--to"], flags: ["--ids", "--all", "--instance", "--from", "--where", "--take", "--mode", "--source-history", "--yes", "--dry-run"], writes: true },
|
|
3853
|
+
{ name: "translate", args: ["kind", "id?"], required: ["--to"], flags: ["--ids", "--all", "--instance", "--from", "--where", "--take", "--mode", "--source-history", "--concurrency", "--yes", "--dry-run"], writes: true },
|
|
2591
3854
|
{ name: "imported-sheets list", required: ["--instance"], writes: false },
|
|
2592
3855
|
{ name: "imported-sheets get", args: ["id"], required: ["--instance"], flags: ["--locale", "--page", "--page-size"], writes: false },
|
|
2593
3856
|
{ name: "imported-sheets locales", args: ["id"], required: ["--instance"], writes: false },
|
|
@@ -2610,6 +3873,15 @@ var schemaHelp = () => ({
|
|
|
2610
3873
|
{ name: "imported-sheets delete", args: ["id"], required: ["--instance", "--force", "--confirm-delete"], flags: ["--yes", "--dry-run"], writes: true, destructive: true },
|
|
2611
3874
|
{ name: "internal-knowledge sync-media", flags: ["--source", "--target", "--targets", "--all-targets", "--languages", "--since", "--updated-after", "--fields", "--mime", "--source-type", "--include-disabled", "--include-archived", "--no-cache", "--yes", "--dry-run"], writes: true },
|
|
2612
3875
|
{ name: "pages backfill-field", required: ["--field", "--target or --targets or --all-targets"], flags: ["--source", "--languages", "--no-cache", "--yes", "--dry-run"], writes: true },
|
|
3876
|
+
{ name: "pages content-schema", aliases: ["pages blocks", "pages block-schema"], writes: false },
|
|
3877
|
+
{ name: "pages patch-content", args: ["id"], required: ["--patch or --patch-file", "--yes or --dry-run"], flags: ["--reason", "--expect-updated-at", "--expect-version", "--expect-content-sha1"], writes: true },
|
|
3878
|
+
{ name: "pages block list", args: ["id"], flags: ["--include-content"], writes: false },
|
|
3879
|
+
{ name: "pages block get", args: ["id"], required: ["--block-id"], flags: ["--include-content"], writes: false },
|
|
3880
|
+
{ name: "pages block replace-text", args: ["id"], required: ["--block-id", "--text or --text-file", "--yes or --dry-run"], flags: ["--field", "--expect-text", "--expect-text-file", "--expect-type", "--expect-updated-at", "--expect-version", "--expect-content-sha1", "--reason", "--include-content"], writes: true },
|
|
3881
|
+
{ name: "pages block replace", args: ["id"], required: ["--block-id", "--block or --block-file", "--yes or --dry-run"], flags: ["--expect-type", "--allow-id-change", "--expect-updated-at", "--expect-version", "--expect-content-sha1", "--reason", "--include-content"], writes: true },
|
|
3882
|
+
{ 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
|
+
{ 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
|
+
{ 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 },
|
|
2613
3885
|
{ name: "feedback inspect", args: ["feedbackId or URL"], writes: false },
|
|
2614
3886
|
{ name: "feedback translation-status", args: ["feedbackId or URL"], writes: false },
|
|
2615
3887
|
{ name: "feedback import-email", flags: ["--data", "--data-file", "--yes", "--dry-run"], writes: true },
|
|
@@ -2640,9 +3912,9 @@ var schemaHelp = () => ({
|
|
|
2640
3912
|
...resources.flatMap((resource) => [
|
|
2641
3913
|
{ name: `${resource.name} list`, writes: false, flags: ["--where", "--fields", "--take", "--skip", "--order-by", "--instance", "--dry-run"] },
|
|
2642
3914
|
{ name: `${resource.name} get`, args: ["id"], writes: false },
|
|
2643
|
-
{ name: `${resource.name} create`, flags: ["--data", "--instance", ...UPLOADABLE_RESOURCE_NAMES.has(resource.name) ? ["--upload-file", "--upload-name", "--mime-type"] : [], "--dry-run"], writes: true },
|
|
2644
|
-
{ name: `${resource.name} update`, args: ["id"], flags: ["--data", "--instance", ...UPLOADABLE_RESOURCE_NAMES.has(resource.name) ? ["--upload-file", "--upload-name", "--mime-type"] : [], "--dry-run"], writes: true },
|
|
2645
|
-
{ name: `${resource.name} delete`, args: ["id"], flags: ["--force", "--confirm-delete", "--dry-run"], writes: true, destructive: false, softOnly: true }
|
|
3915
|
+
{ name: `${resource.name} create`, flags: ["--data", "--data-file", "--instance", ...UPLOADABLE_RESOURCE_NAMES.has(resource.name) ? ["--upload-file", "--upload-name", "--mime-type"] : [], "--yes", "--dry-run"], writes: true },
|
|
3916
|
+
{ name: `${resource.name} update`, args: ["id"], flags: ["--data", "--data-file", "--instance", ...UPLOADABLE_RESOURCE_NAMES.has(resource.name) ? ["--upload-file", "--upload-name", "--mime-type"] : [], "--yes", "--dry-run"], writes: true },
|
|
3917
|
+
{ name: `${resource.name} delete`, args: ["id"], flags: ["--force", "--confirm-delete", "--yes", "--dry-run"], writes: true, destructive: false, softOnly: true }
|
|
2646
3918
|
])
|
|
2647
3919
|
],
|
|
2648
3920
|
resources: resources.map((resource) => ({
|
|
@@ -2715,7 +3987,8 @@ var translateHelp = () => ({
|
|
|
2715
3987
|
"gskills-admin translate internal-knowledge <knowledgeId> --to en --yes",
|
|
2716
3988
|
"gskills-admin translate knowledge-video <knowledgeId> --from en --to es --yes",
|
|
2717
3989
|
"gskills-admin translate learning-paths <pathId> --to en --yes",
|
|
2718
|
-
"gskills-admin translate chromebook-exercises <exerciseId> --to en --yes"
|
|
3990
|
+
"gskills-admin translate chromebook-exercises <exerciseId> --to en --yes",
|
|
3991
|
+
"gskills-admin translate changelogs <changelogId> --to all --concurrency 8 --yes"
|
|
2719
3992
|
],
|
|
2720
3993
|
contentKinds: [
|
|
2721
3994
|
"pages",
|
|
@@ -2727,13 +4000,14 @@ var translateHelp = () => ({
|
|
|
2727
4000
|
"internal-knowledge",
|
|
2728
4001
|
"knowledge-video",
|
|
2729
4002
|
"learning-paths",
|
|
2730
|
-
"chromebook-exercises"
|
|
4003
|
+
"chromebook-exercises",
|
|
4004
|
+
"changelogs"
|
|
2731
4005
|
],
|
|
2732
4006
|
modes: ["upsert", "create", "update", "patch"],
|
|
2733
4007
|
selection: "Pass one id, --ids for several source rows, or --all with optional --instance, --from, --where and --take.",
|
|
2734
4008
|
warning: PAGE_TRANSLATION_REWRITE_WARNING,
|
|
2735
4009
|
patchMode: "For pages, --mode patch uses source page history to update changed translatable text while preserving target non-text block data such as activity ids, quiz ids, embedded ids, files, and future custom fields. It updates existing translations only and fails when no previous source history exists.",
|
|
2736
|
-
note: "Uses the same AI translation helpers as the editors. Dry-run plans the write without calling AI.
|
|
4010
|
+
note: "Uses the same AI translation helpers as the editors. Dry-run plans the write without calling AI. --to all expands to every supported locale. Changelogs support --concurrency 1-20."
|
|
2737
4011
|
});
|
|
2738
4012
|
var importedSheetsHelp = () => ({
|
|
2739
4013
|
usage: [
|
|
@@ -2930,13 +4204,16 @@ var resourceHelp = (resource) => ({
|
|
|
2930
4204
|
usage: [
|
|
2931
4205
|
`gskills-admin ${resource.name} list --instance global`,
|
|
2932
4206
|
`gskills-admin ${resource.name} get <id>`,
|
|
2933
|
-
`gskills-admin ${resource.name} create --data
|
|
2934
|
-
`gskills-admin ${resource.name} update <id> --data '{"disabled":true}'`,
|
|
2935
|
-
`gskills-admin ${resource.name} delete <id> --force --confirm-delete ${resource.name}:<id
|
|
4207
|
+
`gskills-admin ${resource.name} create --data-file ./payload.json --dry-run`,
|
|
4208
|
+
`gskills-admin ${resource.name} update <id> --data '{"disabled":true}' --yes`,
|
|
4209
|
+
`gskills-admin ${resource.name} delete <id> --force --confirm-delete ${resource.name}:<id> --yes`,
|
|
2936
4210
|
...resource.name === "internal-knowledge" ? [`gskills-admin ${resource.name} create --instance <instanceId> --upload-file ./video.mp4 --data '{"title":"Video","language":"fr","isActive":true}' --dry-run`] : [],
|
|
2937
4211
|
...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`] : [],
|
|
2938
4212
|
...resource.name === "internal-knowledge" ? [`gskills-admin ${resource.name} sync-media --since today --languages fr --all-targets --dry-run`] : [],
|
|
2939
|
-
...resource.name === "pages" ? [`gskills-admin ${resource.name} backfill-field --field headerColor --all-targets --dry-run`] : []
|
|
4213
|
+
...resource.name === "pages" ? [`gskills-admin ${resource.name} backfill-field --field headerColor --all-targets --dry-run`] : [],
|
|
4214
|
+
...resource.name === "pages" ? [`gskills-admin ${resource.name} content-schema --output json`] : [],
|
|
4215
|
+
...resource.name === "pages" ? [`gskills-admin ${resource.name} patch-content <id> --patch-file ./page.patch.json --dry-run`] : [],
|
|
4216
|
+
...resource.name === "pages" ? [`gskills-admin ${resource.name} block replace-text <id> --block-id <blockId> --text-file ./block.txt --dry-run`] : []
|
|
2940
4217
|
],
|
|
2941
4218
|
defaultFields: resource.defaultFields,
|
|
2942
4219
|
cache: {
|
|
@@ -2944,7 +4221,50 @@ var resourceHelp = (resource) => ({
|
|
|
2944
4221
|
invalidate: resource.cacheScopes?.length ? `gskills-admin cache invalidate --instance <instanceId> --scope ${resource.cacheScopes[0]} --dry-run` : null,
|
|
2945
4222
|
note: resource.cacheScopes?.length ? "After create/update/soft-delete, deploy views may still show cached content. Dry-run and invalidate the relevant scope, then verify the visible page." : "No deploy-cache scope is listed for this raw resource. If the write affects visible content indirectly, use cache scopes to choose a broader invalidation."
|
|
2946
4223
|
},
|
|
2947
|
-
deleteWarning: "Delete is soft-only in the CLI. It writes disabled, archived, isActive=false, or active=false when the resource supports it."
|
|
4224
|
+
deleteWarning: "Delete is soft-only in the CLI. It writes disabled, archived, isActive=false, or active=false when the resource supports it.",
|
|
4225
|
+
...resource.name === "pages" ? {
|
|
4226
|
+
patchContent: {
|
|
4227
|
+
format: "RFC 6902 JSON Patch applied to the parsed EditorJS content object.",
|
|
4228
|
+
guardRails: ["dry-run preview", "test operations", "optional updatedAt/version/content SHA checks", "page history snapshot"],
|
|
4229
|
+
schema: "gskills-admin pages content-schema --output json",
|
|
4230
|
+
examplePatch: [
|
|
4231
|
+
{ op: "test", path: "/blocks/0/type", value: "paragraph" },
|
|
4232
|
+
{ op: "replace", path: "/blocks/0/data/text", value: "New paragraph text" }
|
|
4233
|
+
]
|
|
4234
|
+
},
|
|
4235
|
+
blockHelpers: {
|
|
4236
|
+
usage: [
|
|
4237
|
+
"gskills-admin pages block list <pageId>",
|
|
4238
|
+
"gskills-admin pages block get <pageId> --block-id <blockId>",
|
|
4239
|
+
"gskills-admin pages block replace-text <pageId> --block-id <blockId> --text-file ./block.txt --dry-run",
|
|
4240
|
+
"gskills-admin pages block replace <pageId> --block-id <blockId> --block-file ./block.json --dry-run",
|
|
4241
|
+
"gskills-admin pages block insert-before <pageId> --block-id <anchorBlockId> --block-file ./block.json --dry-run",
|
|
4242
|
+
"gskills-admin pages block insert-after <pageId> --block-id <anchorBlockId> --block-file ./block.json --dry-run",
|
|
4243
|
+
"gskills-admin pages block remove <pageId> --block-id <blockId> --dry-run"
|
|
4244
|
+
],
|
|
4245
|
+
note: "Block helpers read the full page content, find nested blocks by id, generate guarded JSON Patch, validate against pages content-schema, and use pages patch-content for the write."
|
|
4246
|
+
}
|
|
4247
|
+
} : {}
|
|
4248
|
+
});
|
|
4249
|
+
var pagesBlockHelp = () => ({
|
|
4250
|
+
usage: [
|
|
4251
|
+
"gskills-admin pages block list <pageId> --output json",
|
|
4252
|
+
"gskills-admin pages block get <pageId> --block-id <blockId> --output json",
|
|
4253
|
+
"gskills-admin pages block replace-text <pageId> --block-id <blockId> --text-file ./block.txt --dry-run --output json",
|
|
4254
|
+
"gskills-admin pages block replace <pageId> --block-id <blockId> --block-file ./block.json --dry-run --output json",
|
|
4255
|
+
"gskills-admin pages block insert-before <pageId> --block-id <anchorBlockId> --block-file ./block.json --dry-run --output json",
|
|
4256
|
+
"gskills-admin pages block insert-after <pageId> --block-id <anchorBlockId> --block-file ./block.json --dry-run --output json",
|
|
4257
|
+
"gskills-admin pages block remove <pageId> --block-id <blockId> --dry-run --output json"
|
|
4258
|
+
],
|
|
4259
|
+
safety: [
|
|
4260
|
+
"Reads the full page content before planning.",
|
|
4261
|
+
"Finds blocks recursively by stable block id.",
|
|
4262
|
+
"Generates JSON Patch with id, type, and old-value test guards.",
|
|
4263
|
+
"Validates the predicted full page against pages content-schema.",
|
|
4264
|
+
"Uses pages patch-content so history, vector refresh, cache, personalization refresh, and admin logs still happen.",
|
|
4265
|
+
"After real writes, rereads the full page content and validates it again."
|
|
4266
|
+
],
|
|
4267
|
+
note: "Use --include-content only when the agent needs the full parsed content in the CLI output."
|
|
2948
4268
|
});
|
|
2949
4269
|
|
|
2950
4270
|
// ../../src/cli/gskills-admin.ts
|