@ikas/component-cli 1.4.0-beta.40 → 1.4.0-beta.41
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/dist/commands/add-sections-to-page.d.ts +3 -0
- package/dist/commands/add-sections-to-page.d.ts.map +1 -0
- package/dist/commands/add-sections-to-page.js +39 -0
- package/dist/commands/add-sections-to-page.js.map +1 -0
- package/dist/commands/create-design-tokens.d.ts +7 -0
- package/dist/commands/create-design-tokens.d.ts.map +1 -0
- package/dist/commands/create-design-tokens.js +127 -0
- package/dist/commands/create-design-tokens.js.map +1 -0
- package/dist/commands/create-global-variable.d.ts +3 -0
- package/dist/commands/create-global-variable.d.ts.map +1 -0
- package/dist/commands/create-global-variable.js +53 -0
- package/dist/commands/create-global-variable.js.map +1 -0
- package/dist/commands/create-page.d.ts +3 -0
- package/dist/commands/create-page.d.ts.map +1 -0
- package/dist/commands/create-page.js +31 -0
- package/dist/commands/create-page.js.map +1 -0
- package/dist/commands/create.d.ts +8 -3
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +8 -175
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/delete-theme-globals.d.ts +4 -0
- package/dist/commands/delete-theme-globals.d.ts.map +1 -0
- package/dist/commands/delete-theme-globals.js +48 -0
- package/dist/commands/delete-theme-globals.js.map +1 -0
- package/dist/commands/get-component-props.d.ts +3 -0
- package/dist/commands/get-component-props.d.ts.map +1 -0
- package/dist/commands/get-component-props.js +32 -0
- package/dist/commands/get-component-props.js.map +1 -0
- package/dist/commands/get-page-by-type.d.ts +3 -0
- package/dist/commands/get-page-by-type.d.ts.map +1 -0
- package/dist/commands/get-page-by-type.js +25 -0
- package/dist/commands/get-page-by-type.js.map +1 -0
- package/dist/commands/get-section-values.d.ts +3 -0
- package/dist/commands/get-section-values.d.ts.map +1 -0
- package/dist/commands/get-section-values.js +39 -0
- package/dist/commands/get-section-values.js.map +1 -0
- package/dist/commands/list-entities.d.ts +3 -0
- package/dist/commands/list-entities.d.ts.map +1 -0
- package/dist/commands/list-entities.js +32 -0
- package/dist/commands/list-entities.js.map +1 -0
- package/dist/commands/list-page-sections.d.ts +3 -0
- package/dist/commands/list-page-sections.d.ts.map +1 -0
- package/dist/commands/list-page-sections.js +25 -0
- package/dist/commands/list-page-sections.js.map +1 -0
- package/dist/commands/list-theme-globals.d.ts +3 -0
- package/dist/commands/list-theme-globals.d.ts.map +1 -0
- package/dist/commands/list-theme-globals.js +22 -0
- package/dist/commands/list-theme-globals.js.map +1 -0
- package/dist/commands/proxy.d.ts +39 -0
- package/dist/commands/proxy.d.ts.map +1 -0
- package/dist/commands/proxy.js +212 -0
- package/dist/commands/proxy.js.map +1 -0
- package/dist/commands/publish-theme.d.ts +3 -0
- package/dist/commands/publish-theme.d.ts.map +1 -0
- package/dist/commands/publish-theme.js +29 -0
- package/dist/commands/publish-theme.js.map +1 -0
- package/dist/commands/search-products.d.ts +3 -0
- package/dist/commands/search-products.d.ts.map +1 -0
- package/dist/commands/search-products.js +40 -0
- package/dist/commands/search-products.js.map +1 -0
- package/dist/commands/update-global-variable.d.ts +3 -0
- package/dist/commands/update-global-variable.d.ts.map +1 -0
- package/dist/commands/update-global-variable.js +47 -0
- package/dist/commands/update-global-variable.js.map +1 -0
- package/dist/commands/update-page-sections.d.ts +3 -0
- package/dist/commands/update-page-sections.d.ts.map +1 -0
- package/dist/commands/update-page-sections.js +39 -0
- package/dist/commands/update-page-sections.js.map +1 -0
- package/dist/commands/update-section-prop.d.ts +3 -0
- package/dist/commands/update-section-prop.d.ts.map +1 -0
- package/dist/commands/update-section-prop.js +59 -0
- package/dist/commands/update-section-prop.js.map +1 -0
- package/dist/commands/upload-image.d.ts +3 -0
- package/dist/commands/upload-image.d.ts.map +1 -0
- package/dist/commands/upload-image.js +38 -0
- package/dist/commands/upload-image.js.map +1 -0
- package/dist/commands/upload-images.d.ts +3 -0
- package/dist/commands/upload-images.d.ts.map +1 -0
- package/dist/commands/upload-images.js +48 -0
- package/dist/commands/upload-images.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/editor-action-client.d.ts +1 -1
- package/dist/utils/editor-action-client.d.ts.map +1 -1
- package/dist/utils/editor-action-client.js +23 -8
- package/dist/utils/editor-action-client.js.map +1 -1
- package/dist/utils/load-image.d.ts +16 -0
- package/dist/utils/load-image.d.ts.map +1 -0
- package/dist/utils/load-image.js +50 -0
- package/dist/utils/load-image.js.map +1 -0
- package/dist/utils/websocket-server.d.ts +2 -2
- package/dist/utils/websocket-server.d.ts.map +1 -1
- package/dist/utils/websocket-server.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-products.js","sourceRoot":"","sources":["../../src/commands/search-products.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAU1C,KAAK,UAAU,iBAAiB,CAAC,OAA8B;IAC7D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG;QAC5B,CAAC,CAAC,OAAO,CAAC,GAAG;aACR,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aAClB,MAAM,CAAC,OAAO,CAAC;QACpB,CAAC,CAAC,SAAS,CAAC;IACd,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,MA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CAAC;SACvE,MAAM,CAAC,aAAa,EAAE,iDAAiD,CAAC;SACxE,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,CAAC;SAC5C,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC;SACnC,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAC7B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-global-variable.d.ts","sourceRoot":"","sources":["../../src/commands/update-global-variable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiDpC,wBAAgB,iCAAiC,IAAI,OAAO,CAW3D"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction } from "../utils/editor-action-client.js";
|
|
3
|
+
const VALID_TYPES = ["TEXT", "RICH_TEXT", "IMAGE", "COLOR", "NUMBER", "BOOLEAN", "BORDER", "SHADOW"];
|
|
4
|
+
function parseValue(raw) {
|
|
5
|
+
if (raw == null)
|
|
6
|
+
return undefined;
|
|
7
|
+
try {
|
|
8
|
+
return JSON.parse(raw);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return raw;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async function runUpdateGlobalVariable(options) {
|
|
15
|
+
if (!options.name) {
|
|
16
|
+
printErrorAndExit(new Error("--name is required (the variable's runtime key, from list-theme-globals)"));
|
|
17
|
+
}
|
|
18
|
+
if (options.type && !VALID_TYPES.includes(options.type)) {
|
|
19
|
+
printErrorAndExit(new Error(`--type must be one of: ${VALID_TYPES.join(", ")}`));
|
|
20
|
+
}
|
|
21
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
22
|
+
try {
|
|
23
|
+
const result = await runEditorAction("update-global-variable", {
|
|
24
|
+
name: options.name,
|
|
25
|
+
...(options.displayName !== undefined ? { displayName: options.displayName } : {}),
|
|
26
|
+
...(options.type !== undefined ? { type: options.type } : {}),
|
|
27
|
+
...(options.value !== undefined ? { value: parseValue(options.value) } : {}),
|
|
28
|
+
}, port ? { port } : {});
|
|
29
|
+
printResultAndExit(result);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
printErrorAndExit(e);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function createUpdateGlobalVariableCommand() {
|
|
36
|
+
const cmd = new Command("update-global-variable");
|
|
37
|
+
cmd
|
|
38
|
+
.description("Update a global variable's value, display name, and/or type in the connected editor")
|
|
39
|
+
.requiredOption("--name <key>", "The variable's runtime key (from `list-theme-globals`)")
|
|
40
|
+
.option("--display-name <name>", "New human-facing label")
|
|
41
|
+
.option("--type <type>", `New value type: ${VALID_TYPES.join(" | ")}`)
|
|
42
|
+
.option("--value <json>", "New value (JSON for objects/null; plain string also accepted)")
|
|
43
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
44
|
+
.action(runUpdateGlobalVariable);
|
|
45
|
+
return cmd;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=update-global-variable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-global-variable.js","sourceRoot":"","sources":["../../src/commands/update-global-variable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAE1G,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAUrG,SAAS,UAAU,CAAC,GAAY;IAC9B,IAAI,GAAG,IAAI,IAAI;QAAE,OAAO,SAAS,CAAC;I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AC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CACrB,CAAC;QACF,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iCAAiC;IAC/C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAClD,GAAG;SACA,WAAW,CAAC,qFAAqF,CAAC;SAClG,cAAc,CAAC,cAAc,EAAE,wDAAwD,CAAC;SACxF,MAAM,CAAC,uBAAuB,EAAE,wBAAwB,CAAC;SACzD,MAAM,CAAC,eAAe,EAAE,mBAAmB,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;SACrE,MAAM,CAAC,gBAAgB,EAAE,+DAA+D,CAAC;SACzF,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,uBAAuB,CAAC,CAAC;IACnC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-page-sections.d.ts","sourceRoot":"","sources":["../../src/commands/update-page-sections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiDpC,wBAAgB,+BAA+B,IAAI,OAAO,CAczD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
async function runUpdatePageSections(options) {
|
|
4
|
+
if (!options.pageId || typeof options.pageId !== "string") {
|
|
5
|
+
printErrorAndExit(new Error("--page-id is required (use `ikas-component list-pages`)"));
|
|
6
|
+
}
|
|
7
|
+
if (options.sections === undefined) {
|
|
8
|
+
printErrorAndExit(new Error('--sections is required: a JSON array, e.g. \'[{"elementId":"<id>","updates":[{"propName":"heading","value":{"value":"Hi"}}]}]\''));
|
|
9
|
+
}
|
|
10
|
+
let sections;
|
|
11
|
+
try {
|
|
12
|
+
sections = JSON.parse(options.sections);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
printErrorAndExit(new Error(`--sections must be valid JSON. Received: ${options.sections}`));
|
|
16
|
+
}
|
|
17
|
+
if (!Array.isArray(sections) || sections.length === 0) {
|
|
18
|
+
printErrorAndExit(new Error('--sections must be a non-empty JSON array of { elementId, updates: [...] } objects.'));
|
|
19
|
+
}
|
|
20
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
21
|
+
try {
|
|
22
|
+
const result = await runEditorAction("update-page-sections", { pageId: options.pageId, sections }, { ...(port ? { port } : {}), timeoutMs: 30_000 });
|
|
23
|
+
printResultAndExit(result);
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
printErrorAndExit(e);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function createUpdatePageSectionsCommand() {
|
|
30
|
+
const cmd = new Command("update-page-sections");
|
|
31
|
+
cmd
|
|
32
|
+
.description("Fill MANY placed sections of a page in one call. --sections is a JSON array of { elementId, updates: [{ propId|propName, value }] }, each value using the same per-type shape as update-section-prop. All-or-nothing across the whole page: every value is resolved and validated before any is written.")
|
|
33
|
+
.requiredOption("--page-id <id>", "Page id (from `ikas-component list-pages`)")
|
|
34
|
+
.requiredOption("--sections <json>", 'JSON array, e.g. \'[{"elementId":"<id>","updates":[{"propName":"heading","value":{"value":"Hi"}}]}]\'')
|
|
35
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
36
|
+
.action(runUpdatePageSections);
|
|
37
|
+
return cmd;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=update-page-sections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-page-sections.js","sourceRoot":"","sources":["../../src/commands/update-page-s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AAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CACjD,CAAC;QACF,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC7C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAChD,GAAG;SACA,WAAW,CACV,0SAA0S,CAC3S;SACA,cAAc,CAAC,gBAAgB,EAAE,4CAA4C,CAAC;SAC9E,cAAc,CACb,mBAAmB,EACnB,uGAAuG,CACxG;SACA,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACjC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-section-prop.d.ts","sourceRoot":"","sources":["../../src/commands/update-section-prop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4DpC,wBAAgB,8BAA8B,IAAI,OAAO,CAsBxD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
async function runUpdateSectionProp(options) {
|
|
4
|
+
if (!options.pageId || typeof options.pageId !== "string") {
|
|
5
|
+
printErrorAndExit(new Error("--page-id is required (use `ikas-component list-pages` to discover ids)"));
|
|
6
|
+
}
|
|
7
|
+
if (!options.elementId || typeof options.elementId !== "string") {
|
|
8
|
+
printErrorAndExit(new Error("--element-id is required (use `ikas-component list-page-sections` to discover ids)"));
|
|
9
|
+
}
|
|
10
|
+
if (!options.propId && !options.propName) {
|
|
11
|
+
printErrorAndExit(new Error("Provide --prop-id or --prop-name (see `ikas-component list-page-sections`)"));
|
|
12
|
+
}
|
|
13
|
+
if (options.value === undefined) {
|
|
14
|
+
printErrorAndExit(new Error("--value is required (JSON, e.g. '{\"value\":\"Hello\"}')"));
|
|
15
|
+
}
|
|
16
|
+
let value;
|
|
17
|
+
try {
|
|
18
|
+
value = JSON.parse(options.value);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
printErrorAndExit(new Error(`--value must be valid JSON (e.g. '{"value":"Hello"}'). Received: ${options.value}`));
|
|
22
|
+
}
|
|
23
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
24
|
+
try {
|
|
25
|
+
const result = await runEditorAction("update-section-prop", {
|
|
26
|
+
pageId: options.pageId,
|
|
27
|
+
elementId: options.elementId,
|
|
28
|
+
...(options.propId ? { propId: options.propId } : {}),
|
|
29
|
+
...(options.propName ? { propName: options.propName } : {}),
|
|
30
|
+
value,
|
|
31
|
+
}, port ? { port } : {});
|
|
32
|
+
printResultAndExit(result);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
printErrorAndExit(e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function createUpdateSectionPropCommand() {
|
|
39
|
+
const cmd = new Command("update-section-prop");
|
|
40
|
+
cmd
|
|
41
|
+
.description([
|
|
42
|
+
"Change a single prop value of a section placed on a page. Target the placement by its elementId (from `ikas-component list-page-sections`) and the prop by --prop-id or --prop-name.",
|
|
43
|
+
"--value is the JSON-encoded prop value. Shape depends on the prop type:",
|
|
44
|
+
" Scalars (TEXT/RICH_TEXT/BOOLEAN/NUMBER/COLOR/ENUM/DATE) are { \"value\": <scalar> } — e.g. '{\"value\":\"Hello\"}', '{\"value\":true}', '{\"value\":\"#FF0000\"}'.",
|
|
45
|
+
" Object props are NOT wrapped: IMAGE/VIDEO/SVG = '{\"id\":\"<asset-id>\",\"altText\":\"...\"}' (get id via `ikas-component upload-image`); PRODUCT = '{\"productId\":\"...\"}'.",
|
|
46
|
+
" LINK = a single link object needing id + linkType + label + subLinks: PAGE = '{\"id\":\"<unique>\",\"linkType\":\"PAGE\",\"label\":\"Home\",\"pageId\":\"<id>\",\"pageType\":\"INDEX\",\"subLinks\":[]}'; EXTERNAL = '{\"id\":\"<unique>\",\"linkType\":\"EXTERNAL\",\"label\":\"Docs\",\"externalLink\":\"https://...\",\"subLinks\":[]}'. (pageId/pageType from `list-pages`.) LIST_OF_LINK = '{\"links\":[<link>,...]}'.",
|
|
47
|
+
" COMPONENT_LIST = '{\"components\":[{\"id\":\"<unique>\",\"codeComponentId\":\"<child-id>\",\"propValues\":{\"<childProp>\":<value>}}]}' (single COMPONENT = one such entry). Each entry needs a unique id and codeComponentId (or componentId); child propValues use the same per-type shapes recursively.",
|
|
48
|
+
" The value REPLACES the whole prop — to edit a COMPONENT_LIST, read the current value from `list-page-sections` and resend the entire array. Wrong shapes are rejected with an error, not stored silently.",
|
|
49
|
+
].join("\n"))
|
|
50
|
+
.requiredOption("--page-id <id>", "Page id (from `ikas-component list-pages`)")
|
|
51
|
+
.requiredOption("--element-id <id>", "Placed section elementId (from `ikas-component list-page-sections`)")
|
|
52
|
+
.option("--prop-id <id>", "Blueprint prop id to update")
|
|
53
|
+
.option("--prop-name <name>", "Blueprint prop name to update (alternative to --prop-id)")
|
|
54
|
+
.requiredOption("--value <json>", 'JSON-encoded prop value, e.g. \'{"value":"Hello"}\'')
|
|
55
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
56
|
+
.action(runUpdateSectionProp);
|
|
57
|
+
return cmd;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=update-section-prop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-section-prop.js","sourceRoot":"","sources":["../../src/commands/update-section-prop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,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"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAyCpC,wBAAgB,wBAAwB,IAAI,OAAO,CAYlD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
import { loadImageSource } from "../utils/load-image.js";
|
|
4
|
+
async function runUploadImage(options) {
|
|
5
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
6
|
+
if (!options.file && !options.url) {
|
|
7
|
+
printErrorAndExit(new Error("Provide --file <path> or --url <url>"));
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const { base64, mimeType, fileName } = await loadImageSource({ file: options.file, url: options.url });
|
|
11
|
+
const result = await runEditorAction("upload-image", {
|
|
12
|
+
base64,
|
|
13
|
+
mimeType,
|
|
14
|
+
fileName,
|
|
15
|
+
...(options.alt ? { altText: options.alt } : {}),
|
|
16
|
+
isVideo: false,
|
|
17
|
+
},
|
|
18
|
+
// Uploads carry the full image payload and round-trip to the host, so give
|
|
19
|
+
// them a far more generous timeout than the default 10s.
|
|
20
|
+
{ ...(port ? { port } : {}), timeoutMs: 60_000 });
|
|
21
|
+
printResultAndExit(result);
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
printErrorAndExit(e);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function createUploadImageCommand() {
|
|
28
|
+
const cmd = new Command("upload-image");
|
|
29
|
+
cmd
|
|
30
|
+
.description("Upload an image to the connected editor's project and return its image id. Supply the image with --file (local path) or --url. The returned id can be used as the `id` of an IMAGE prop value via `ikas-component update-section-prop`. Requires the editor to be embedded in the ikas admin panel (the host performs the actual upload).")
|
|
31
|
+
.option("--file <path>", "Local image file path (.png, .jpg, .jpeg, .webp, .gif)")
|
|
32
|
+
.option("--url <url>", "Image URL to fetch and upload")
|
|
33
|
+
.option("--alt <text>", "Alt text for the image")
|
|
34
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
35
|
+
.action(runUploadImage);
|
|
36
|
+
return cmd;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=upload-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-image.js","sourceRoot":"","sources":["../../src/commands/upload-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AASzD,KAAK,UAAU,cAAc,CAAC,OAA2B;IACvD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QAClC,iBAAiB,CAAC,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,eAAe,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACvG,MAAM,MAAM,GAAG,MAAM,eAAe,CAClC,cAAc,EACd;YACE,MAAM;YACN,QAAQ;YACR,QAAQ;YACR,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChD,OAAO,EAAE,KAAK;SACf;QACD,2EAA2E;QAC3E,yDAAyD;QACzD,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CACjD,CAAC;QACF,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,wBAAwB;IACtC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;IACxC,GAAG;SACA,WAAW,CACV,2UAA2U,CAC5U;SACA,MAAM,CAAC,eAAe,EAAE,wDAAwD,CAAC;SACjF,MAAM,CAAC,aAAa,EAAE,+BAA+B,CAAC;SACtD,MAAM,CAAC,cAAc,EAAE,wBAAwB,CAAC;SAChD,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,cAAc,CAAC,CAAC;IAC1B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-images.d.ts","sourceRoot":"","sources":["../../src/commands/upload-images.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8DpC,wBAAgB,yBAAyB,IAAI,OAAO,CAanD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
import { loadImageSource } from "../utils/load-image.js";
|
|
4
|
+
async function runUploadImages(options) {
|
|
5
|
+
if (options.manifest === undefined) {
|
|
6
|
+
printErrorAndExit(new Error('--manifest is required: a JSON array, e.g. \'[{"file":"/a.png","alt":"A"},{"url":"https://...","alt":"B"}]\''));
|
|
7
|
+
}
|
|
8
|
+
let manifest;
|
|
9
|
+
try {
|
|
10
|
+
manifest = JSON.parse(options.manifest);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
printErrorAndExit(new Error(`--manifest must be valid JSON. Received: ${options.manifest}`));
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!Array.isArray(manifest) || manifest.length === 0) {
|
|
17
|
+
printErrorAndExit(new Error("--manifest must be a non-empty JSON array of { file|url, alt? } objects."));
|
|
18
|
+
}
|
|
19
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
20
|
+
try {
|
|
21
|
+
// Read/encode all sources in parallel, then send one batch editor-action.
|
|
22
|
+
const images = await Promise.all(manifest.map(async (entry) => {
|
|
23
|
+
const { base64, mimeType, fileName } = await loadImageSource({ file: entry.file, url: entry.url });
|
|
24
|
+
return {
|
|
25
|
+
base64,
|
|
26
|
+
mimeType,
|
|
27
|
+
fileName,
|
|
28
|
+
...(entry.alt ? { altText: entry.alt } : {}),
|
|
29
|
+
isVideo: false,
|
|
30
|
+
};
|
|
31
|
+
}));
|
|
32
|
+
const result = await runEditorAction("upload-images", { images }, { ...(port ? { port } : {}), timeoutMs: 60_000 });
|
|
33
|
+
printResultAndExit(result);
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
printErrorAndExit(e);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function createUploadImagesCommand() {
|
|
40
|
+
const cmd = new Command("upload-images");
|
|
41
|
+
cmd
|
|
42
|
+
.description("Upload MANY images in one call (batch upload-image) and return their ids in order. --manifest is a JSON array of { file|url, alt? }. The host uploads them all in a single round-trip. Requires the editor embedded in the ikas admin panel.")
|
|
43
|
+
.requiredOption("--manifest <json>", 'JSON array, e.g. \'[{"file":"/a.png","alt":"A"},{"url":"https://x/b.jpg"}]\'')
|
|
44
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
45
|
+
.action(runUploadImages);
|
|
46
|
+
return cmd;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=upload-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,EAAE,GAAG,MAAM,eAAe,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YACnG,OAAO;gBACL,MAAM;gBACN,QAAQ;gBACR,QAAQ;gBACR,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC5C,OAAO,EAAE,KAAK;aACf,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;QACF,MAAM,MAAM,GAAG,MAAM,eAAe,CAClC,eAAe,EACf,EAAE,MAAM,EAAE,EACV,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CACjD,CAAC;QACF,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;IACzC,GAAG;SACA,WAAW,CACV,8OAA8O,CAC/O;SACA,cAAc,CACb,mBAAmB,EACnB,8EAA8E,CAC/E;SACA,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,eAAe,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiFpC,wBAAgB,GAAG,qBAElB;AAED,cAAc,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import {
|
|
2
|
+
import { createAddSectionsToPageCommand } from "./commands/add-sections-to-page.js";
|
|
3
3
|
import { createAddToPageCommand } from "./commands/add-to-page.js";
|
|
4
|
+
import { createAddCommand } from "./commands/add.js";
|
|
4
5
|
import { createBuildCommand } from "./commands/build.js";
|
|
5
6
|
import { createCheckCommand } from "./commands/check.js";
|
|
6
7
|
import { createConfigCommand } from "./commands/config.js";
|
|
8
|
+
import { createCreateBreakpointCommand, createCreateColorCommand, createCreateColorSchemeCommand, createCreateKeyframeCommand, createCreateTextStyleCommand, } from "./commands/create-design-tokens.js";
|
|
9
|
+
import { createCreateGlobalVariableCommand } from "./commands/create-global-variable.js";
|
|
10
|
+
import { createCreatePageCommand } from "./commands/create-page.js";
|
|
11
|
+
import { createDeleteDesignTokenCommand, createDeleteGlobalVariableCommand, } from "./commands/delete-theme-globals.js";
|
|
7
12
|
import { createDevCommand } from "./commands/dev.js";
|
|
13
|
+
import { createGetComponentPropsCommand } from "./commands/get-component-props.js";
|
|
14
|
+
import { createGetPageByTypeCommand } from "./commands/get-page-by-type.js";
|
|
15
|
+
import { createGetSectionValuesCommand } from "./commands/get-section-values.js";
|
|
8
16
|
import { createImportCommand } from "./commands/import.js";
|
|
17
|
+
import { createListEntitiesCommand } from "./commands/list-entities.js";
|
|
9
18
|
import { createListImportedCommand } from "./commands/list-imported.js";
|
|
19
|
+
import { createListPageSectionsCommand } from "./commands/list-page-sections.js";
|
|
10
20
|
import { createListPagesCommand } from "./commands/list-pages.js";
|
|
21
|
+
import { createListThemeGlobalsCommand } from "./commands/list-theme-globals.js";
|
|
22
|
+
import { createPublishThemeCommand } from "./commands/publish-theme.js";
|
|
11
23
|
import { createPublishCommand } from "./commands/publish.js";
|
|
24
|
+
import { createSearchProductsCommand } from "./commands/search-products.js";
|
|
25
|
+
import { createUpdateGlobalVariableCommand } from "./commands/update-global-variable.js";
|
|
26
|
+
import { createUpdatePageSectionsCommand } from "./commands/update-page-sections.js";
|
|
27
|
+
import { createUpdateSectionPropCommand } from "./commands/update-section-prop.js";
|
|
28
|
+
import { createUploadImageCommand } from "./commands/upload-image.js";
|
|
29
|
+
import { createUploadImagesCommand } from "./commands/upload-images.js";
|
|
12
30
|
const program = new Command();
|
|
13
31
|
program
|
|
14
32
|
.name("ikas-component")
|
|
@@ -25,6 +43,29 @@ program.addCommand(createListPagesCommand());
|
|
|
25
43
|
program.addCommand(createListImportedCommand());
|
|
26
44
|
program.addCommand(createImportCommand());
|
|
27
45
|
program.addCommand(createAddToPageCommand());
|
|
46
|
+
program.addCommand(createListThemeGlobalsCommand());
|
|
47
|
+
program.addCommand(createCreateGlobalVariableCommand());
|
|
48
|
+
program.addCommand(createCreateColorCommand());
|
|
49
|
+
program.addCommand(createCreateTextStyleCommand());
|
|
50
|
+
program.addCommand(createCreateBreakpointCommand());
|
|
51
|
+
program.addCommand(createCreateKeyframeCommand());
|
|
52
|
+
program.addCommand(createCreateColorSchemeCommand());
|
|
53
|
+
program.addCommand(createUpdateGlobalVariableCommand());
|
|
54
|
+
program.addCommand(createDeleteGlobalVariableCommand());
|
|
55
|
+
program.addCommand(createDeleteDesignTokenCommand());
|
|
56
|
+
program.addCommand(createAddSectionsToPageCommand());
|
|
57
|
+
program.addCommand(createListPageSectionsCommand());
|
|
58
|
+
program.addCommand(createGetSectionValuesCommand());
|
|
59
|
+
program.addCommand(createGetComponentPropsCommand());
|
|
60
|
+
program.addCommand(createGetPageByTypeCommand());
|
|
61
|
+
program.addCommand(createCreatePageCommand());
|
|
62
|
+
program.addCommand(createPublishThemeCommand());
|
|
63
|
+
program.addCommand(createUpdateSectionPropCommand());
|
|
64
|
+
program.addCommand(createUpdatePageSectionsCommand());
|
|
65
|
+
program.addCommand(createUploadImageCommand());
|
|
66
|
+
program.addCommand(createUploadImagesCommand());
|
|
67
|
+
program.addCommand(createSearchProductsCommand());
|
|
68
|
+
program.addCommand(createListEntitiesCommand());
|
|
28
69
|
export function run() {
|
|
29
70
|
return program.parseAsync(process.argv);
|
|
30
71
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,EACxB,8BAA8B,EAC9B,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,iCAAiC,EAAE,MAAM,sCAAsC,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACL,8BAA8B,EAC9B,iCAAiC,GAClC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AACn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,UAAU,CAAC,uBAAuB,EAAE,CAAC,CAAC;AAC9C,OAAO,CAAC,UAAU,CAAC,yBAAyB,EAAE,CAAC,CAAC;AAChD,OAAO,CAAC,UAAU,CAAC,8BAA8B,EAAE,CAAC,CAAC;AACrD,OAAO,CAAC,UAAU,CAAC,+BAA+B,EAAE,CAAC,CAAC;AACtD,OAAO,CAAC,UAAU,CAAC,wBAAwB,EAAE,CAAC,CAAC;AAC/C,OAAO,CAAC,UAAU,CAAC,yBAAyB,EAAE,CAAC,CAAC;AAChD,OAAO,CAAC,UAAU,CAAC,2BAA2B,EAAE,CAAC,CAAC;AAClD,OAAO,CAAC,UAAU,CAAC,yBAAyB,EAAE,CAAC,CAAC;AAEhD,MAAM,UAAU,GAAG;IACjB,OAAO,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED,cAAc,YAAY,CAAC"}
|
|
@@ -10,7 +10,7 @@ export interface EditorActionResult {
|
|
|
10
10
|
* The dev server forwards the action to its connected editor client and routes
|
|
11
11
|
* the result back to this socket (matched by requestId).
|
|
12
12
|
*/
|
|
13
|
-
export declare function runEditorAction(action: "list-pages" | "list-imported-components" | "import-component" | "add-section-to-page", payload?: Record<string, unknown>, options?: {
|
|
13
|
+
export declare function runEditorAction(action: "list-pages" | "list-imported-components" | "import-component" | "add-section-to-page" | "list-theme-globals" | "create-global-variable" | "create-design-token" | "update-global-variable" | "delete-global-variable" | "delete-design-token" | "add-sections-to-page" | "list-page-sections" | "get-section-values" | "get-component-props" | "update-section-prop" | "upload-image" | "search-products" | "list-entities" | "get-page-by-type" | "create-page" | "publish-theme" | "update-page-sections" | "upload-images", payload?: Record<string, unknown>, options?: {
|
|
14
14
|
port?: number;
|
|
15
15
|
timeoutMs?: number;
|
|
16
16
|
}): Promise<EditorActionResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-action-client.d.ts","sourceRoot":"","sources":["../../src/utils/editor-action-client.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,MAAM,
|
|
1
|
+
{"version":3,"file":"editor-action-client.d.ts","sourceRoot":"","sources":["../../src/utils/editor-action-client.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EACF,YAAY,GACZ,0BAA0B,GAC1B,kBAAkB,GAClB,qBAAqB,GACrB,oBAAoB,GACpB,wBAAwB,GACxB,qBAAqB,GACrB,wBAAwB,GACxB,wBAAwB,GACxB,qBAAqB,GACrB,sBAAsB,GACtB,oBAAoB,GACpB,oBAAoB,GACpB,qBAAqB,GACrB,qBAAqB,GACrB,cAAc,GACd,iBAAiB,GACjB,eAAe,GACf,kBAAkB,GAClB,aAAa,GACb,eAAe,GACf,sBAAsB,GACtB,eAAe,EACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAClD,OAAO,CAAC,kBAAkB,CAAC,CAiF7B;AAED,MAAM,WAAW,YAAY;IAC3B,wFAAwF;IACxF,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAuBD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,KAAK,CAKpE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAGvD"}
|
|
@@ -78,6 +78,26 @@ export function runEditorAction(action, payload, options = {}) {
|
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Write a single JSON line to stdout and exit — but only AFTER the write has
|
|
83
|
+
* fully flushed to the pipe.
|
|
84
|
+
*
|
|
85
|
+
* Why not `process.stdout.write(...); process.exit(code)`? When stdout is a pipe
|
|
86
|
+
* (which it always is when the MCP server shells out via `execFile`), writes are
|
|
87
|
+
* asynchronous. Calling `process.exit()` immediately after a large write tears
|
|
88
|
+
* the process down before the OS drains the pipe, truncating the JSON mid-stream.
|
|
89
|
+
* The MCP then sees an incomplete object and reports "no parseable JSON". This
|
|
90
|
+
* bites exactly the big batch responses (get-component-props for many ids,
|
|
91
|
+
* list-entities on a large store, add-sections-to-page echoing many sections).
|
|
92
|
+
*
|
|
93
|
+
* Passing the exit to the write callback guarantees the full line is flushed
|
|
94
|
+
* first. The pending write keeps the event loop alive until the callback fires.
|
|
95
|
+
*/
|
|
96
|
+
function writeJsonLineAndExit(obj, code) {
|
|
97
|
+
process.stdout.write(JSON.stringify(obj) + "\n", () => process.exit(code));
|
|
98
|
+
// The write callback ends the process; control never meaningfully returns here.
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
81
101
|
/**
|
|
82
102
|
* Standard JSON printer for control commands. Always emits a single line of
|
|
83
103
|
* JSON to stdout; sets exit code 0 on success, 1 on failure. The shape is
|
|
@@ -85,17 +105,12 @@ export function runEditorAction(action, payload, options = {}) {
|
|
|
85
105
|
*/
|
|
86
106
|
export function printResultAndExit(result) {
|
|
87
107
|
if (result.success) {
|
|
88
|
-
|
|
89
|
-
process.exit(0);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
process.stdout.write(JSON.stringify({ ok: false, error: result.error ?? "Unknown error" }) + "\n");
|
|
93
|
-
process.exit(1);
|
|
108
|
+
return writeJsonLineAndExit({ ok: true, ...(result.payload ?? {}) }, 0);
|
|
94
109
|
}
|
|
110
|
+
return writeJsonLineAndExit({ ok: false, error: result.error ?? "Unknown error" }, 1);
|
|
95
111
|
}
|
|
96
112
|
export function printErrorAndExit(error) {
|
|
97
113
|
const message = error instanceof Error ? error.message : String(error);
|
|
98
|
-
|
|
99
|
-
process.exit(1);
|
|
114
|
+
return writeJsonLineAndExit({ ok: false, error: message }, 1);
|
|
100
115
|
}
|
|
101
116
|
//# sourceMappingURL=editor-action-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-action-client.js","sourceRoot":"","sources":["../../src/utils/editor-action-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAE/B,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAQlC;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,
|
|
1
|
+
{"version":3,"file":"editor-action-client.js","sourceRoot":"","sources":["../../src/utils/editor-action-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAE/B,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAQlC;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,MAuBmB,EACnB,OAAiC,EACjC,UAAiD,EAAE;IAEnD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,YAAY,CAAC;IAC1C,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,kBAAkB,CAAC;IAC1D,MAAM,SAAS,GAAG,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IAEhF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,EAAE,GAAG,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C,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,gFAAgF;IAChF,OAAO,SAAkB,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA0B;IAC3D,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,oBAAoB,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,oBAAoB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC;AACxF,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,oBAAoB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const VALID_IMAGE_TYPES: string[];
|
|
2
|
+
export interface ImageSource {
|
|
3
|
+
file?: string;
|
|
4
|
+
url?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface LoadedImage {
|
|
7
|
+
base64: string;
|
|
8
|
+
mimeType: string;
|
|
9
|
+
fileName: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Read an image from a local file path or URL and return its base64 (raw, no
|
|
13
|
+
* data: prefix), mime type, and a file name. Validates type and the 10MB limit.
|
|
14
|
+
*/
|
|
15
|
+
export declare function loadImageSource(src: ImageSource): Promise<LoadedImage>;
|
|
16
|
+
//# sourceMappingURL=load-image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-image.d.ts","sourceRoot":"","sources":["../../src/utils/load-image.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,iBAAiB,UAA6B,CAAC;AAG5D,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAsC5E"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { basename, extname } from "node:path";
|
|
3
|
+
const MIME_BY_EXT = {
|
|
4
|
+
".png": "image/png",
|
|
5
|
+
".jpg": "image/jpeg",
|
|
6
|
+
".jpeg": "image/jpeg",
|
|
7
|
+
".webp": "image/webp",
|
|
8
|
+
".gif": "image/gif",
|
|
9
|
+
};
|
|
10
|
+
export const VALID_IMAGE_TYPES = Object.values(MIME_BY_EXT);
|
|
11
|
+
const MAX_SIZE_BYTES = 10 * 1024 * 1024; // 10MB, mirrors the editor's IMAGE_UPLOAD_LIMIT_SIZE
|
|
12
|
+
/**
|
|
13
|
+
* Read an image from a local file path or URL and return its base64 (raw, no
|
|
14
|
+
* data: prefix), mime type, and a file name. Validates type and the 10MB limit.
|
|
15
|
+
*/
|
|
16
|
+
export async function loadImageSource(src) {
|
|
17
|
+
if (src.file && src.url) {
|
|
18
|
+
throw new Error("Provide only one of file or url, not both");
|
|
19
|
+
}
|
|
20
|
+
if (src.file) {
|
|
21
|
+
const buffer = await readFile(src.file);
|
|
22
|
+
const ext = extname(src.file).toLowerCase();
|
|
23
|
+
const mimeType = MIME_BY_EXT[ext];
|
|
24
|
+
if (!mimeType) {
|
|
25
|
+
throw new Error(`Unsupported image extension "${ext || "(none)"}" for ${src.file}. Supported: ${Object.keys(MIME_BY_EXT).join(", ")}`);
|
|
26
|
+
}
|
|
27
|
+
if (buffer.byteLength > MAX_SIZE_BYTES) {
|
|
28
|
+
throw new Error(`${src.file} is ${(buffer.byteLength / 1024 / 1024).toFixed(1)}MB; the limit is 10MB`);
|
|
29
|
+
}
|
|
30
|
+
return { base64: buffer.toString("base64"), mimeType, fileName: basename(src.file) };
|
|
31
|
+
}
|
|
32
|
+
if (src.url) {
|
|
33
|
+
const res = await fetch(src.url);
|
|
34
|
+
if (!res.ok) {
|
|
35
|
+
throw new Error(`Failed to fetch ${src.url}: ${res.status} ${res.statusText}`);
|
|
36
|
+
}
|
|
37
|
+
const mimeType = (res.headers.get("content-type") || "").split(";")[0].trim();
|
|
38
|
+
if (!VALID_IMAGE_TYPES.includes(mimeType)) {
|
|
39
|
+
throw new Error(`${src.url} returned content-type "${mimeType || "(none)"}". Supported: ${VALID_IMAGE_TYPES.join(", ")}`);
|
|
40
|
+
}
|
|
41
|
+
const buffer = Buffer.from(await res.arrayBuffer());
|
|
42
|
+
if (buffer.byteLength > MAX_SIZE_BYTES) {
|
|
43
|
+
throw new Error(`${src.url} is ${(buffer.byteLength / 1024 / 1024).toFixed(1)}MB; the limit is 10MB`);
|
|
44
|
+
}
|
|
45
|
+
const urlName = basename(new URL(src.url).pathname) || "image";
|
|
46
|
+
return { base64: buffer.toString("base64"), mimeType, fileName: urlName };
|
|
47
|
+
}
|
|
48
|
+
throw new Error("Provide a file path or url");
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=load-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-image.js","sourceRoot":"","sources":["../../src/utils/load-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,C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ACD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC;QAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAC5E,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -151,7 +151,7 @@ export type DevServerMessage = {
|
|
|
151
151
|
} | {
|
|
152
152
|
type: "editor-action";
|
|
153
153
|
requestId: string;
|
|
154
|
-
action: "list-pages" | "list-imported-components" | "import-component" | "add-section-to-page";
|
|
154
|
+
action: "list-pages" | "list-imported-components" | "import-component" | "add-section-to-page" | "add-sections-to-page" | "list-page-sections" | "get-section-values" | "get-component-props" | "update-section-prop" | "upload-image" | "search-products" | "list-entities" | "get-page-by-type" | "update-page-sections" | "upload-images";
|
|
155
155
|
payload?: any;
|
|
156
156
|
} | {
|
|
157
157
|
type: "editor-action-result";
|
|
@@ -286,7 +286,7 @@ export type EditorMessage = {
|
|
|
286
286
|
} | {
|
|
287
287
|
type: "editor-action";
|
|
288
288
|
requestId: string;
|
|
289
|
-
action: "list-pages" | "list-imported-components" | "import-component" | "add-section-to-page";
|
|
289
|
+
action: "list-pages" | "list-imported-components" | "import-component" | "add-section-to-page" | "add-sections-to-page" | "list-page-sections" | "get-section-values" | "get-component-props" | "update-section-prop" | "upload-image" | "search-products" | "list-entities" | "get-page-by-type" | "update-page-sections" | "upload-images";
|
|
290
290
|
payload?: any;
|
|
291
291
|
} | {
|
|
292
292
|
type: "editor-action-result";
|