@plitzi/sdk-mcp 0.33.2 → 0.34.0
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/CHANGELOG.md +62 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -2
- package/dist/modules/mcp/catalogs/index.d.ts +2 -7
- package/dist/modules/mcp/catalogs/index.js +4 -0
- package/dist/modules/mcp/catalogs/observed.d.ts +1 -1
- package/dist/modules/mcp/catalogs/observed.js +2 -5
- package/dist/modules/mcp/catalogs/pluginCatalog.d.ts +17 -0
- package/dist/modules/mcp/catalogs/pluginCatalog.js +91 -0
- package/dist/modules/mcp/catalogs/registry.js +2 -3
- package/dist/modules/mcp/helpers/agentPrompt.js +9 -9
- package/dist/modules/mcp/helpers/guide.d.ts +2 -2
- package/dist/modules/mcp/helpers/guide.js +117 -50
- package/dist/modules/mcp/helpers/interactions.d.ts +5 -1
- package/dist/modules/mcp/helpers/interactions.js +15 -6
- package/dist/modules/mcp/helpers/space.d.ts +45 -28
- package/dist/modules/mcp/helpers/space.js +87 -87
- package/dist/modules/mcp/helpers/uris.d.ts +9 -0
- package/dist/modules/mcp/helpers/uris.js +10 -1
- package/dist/modules/mcp/index.d.ts +2 -0
- package/dist/modules/mcp/localScreenshotClient.d.ts +51 -0
- package/dist/modules/mcp/localScreenshotClient.js +106 -0
- package/dist/modules/mcp/proxy/rewrite.js +15 -1
- package/dist/modules/mcp/resources/actions.d.ts +25 -0
- package/dist/modules/mcp/resources/actions.js +54 -0
- package/dist/modules/mcp/resources/canonical.d.ts +1 -1
- package/dist/modules/mcp/resources/canonical.js +1 -1
- package/dist/modules/mcp/resources/connectors.d.ts +1 -1
- package/dist/modules/mcp/resources/core.js +1 -1
- package/dist/modules/mcp/resources/index.d.ts +1 -0
- package/dist/modules/mcp/resources/primer.d.ts +8 -1
- package/dist/modules/mcp/resources/primer.js +139 -15
- package/dist/modules/mcp/resources/register.js +24 -4
- package/dist/modules/mcp/resources/renderGuide.js +66 -14
- package/dist/modules/mcp/resources/router.js +3 -1
- package/dist/modules/mcp/resources/schema.js +6 -5
- package/dist/modules/mcp/resources/style.d.ts +2 -1
- package/dist/modules/mcp/resources/style.js +10 -3
- package/dist/modules/mcp/screenshotClient.js +3 -2
- package/dist/modules/mcp/server.js +12 -6
- package/dist/modules/mcp/tests/agentRoundtrip.test.d.ts +1 -0
- package/dist/modules/mcp/tests/layouts.test.d.ts +1 -0
- package/dist/modules/mcp/tools/apply/dispatch.js +30 -1
- package/dist/modules/mcp/tools/apply/index.d.ts +149 -15
- package/dist/modules/mcp/tools/apply/index.js +12 -2
- package/dist/modules/mcp/tools/operations/actions/actions.test.d.ts +1 -0
- package/dist/modules/mcp/tools/operations/actions/deleteAction.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/actions/deleteAction.js +20 -0
- package/dist/modules/mcp/tools/operations/actions/document.d.ts +69 -0
- package/dist/modules/mcp/tools/operations/actions/document.js +73 -0
- package/dist/modules/mcp/tools/operations/actions/index.d.ts +90 -0
- package/dist/modules/mcp/tools/operations/actions/index.js +12 -0
- package/dist/modules/mcp/tools/operations/actions/patchAction.d.ts +45 -0
- package/dist/modules/mcp/tools/operations/actions/patchAction.js +71 -0
- package/dist/modules/mcp/tools/operations/actions/upsertAction.d.ts +47 -0
- package/dist/modules/mcp/tools/operations/actions/upsertAction.js +83 -0
- package/dist/modules/mcp/tools/operations/connectors/index.d.ts +10 -10
- package/dist/modules/mcp/tools/operations/connectors/manifest.d.ts +5 -5
- package/dist/modules/mcp/tools/operations/connectors/patchConnector.d.ts +5 -5
- package/dist/modules/mcp/tools/operations/connectors/upsertConnector.d.ts +5 -5
- package/dist/modules/mcp/tools/operations/index.d.ts +415 -40
- package/dist/modules/mcp/tools/operations/index.js +11 -2
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +4 -4
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +5 -5
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +6 -6
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +11 -12
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +4 -4
- package/dist/modules/mcp/tools/operations/schema/index.d.ts +2 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +4 -4
- package/dist/modules/mcp/tools/operations/schema/operations.d.ts +28 -5
- package/dist/modules/mcp/tools/operations/schema/operations.js +4 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.js +33 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/pages/upsertLayout.d.ts +22 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertLayout.js +61 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +2 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +53 -18
- package/dist/modules/mcp/tools/operations/schema/shared.d.ts +5 -1
- package/dist/modules/mcp/tools/operations/schema/shared.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/translator.d.ts +2 -1
- package/dist/modules/mcp/tools/operations/schema/translator.js +21 -9
- package/dist/modules/mcp/tools/operations/schema/write.d.ts +9 -22
- package/dist/modules/mcp/tools/operations/schema/write.js +23 -43
- package/dist/modules/mcp/tools/operations/schemaIds.js +7 -1
- package/dist/modules/mcp/tools/operations/style/fonts/deleteFont.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/style/fonts/deleteFont.js +21 -0
- package/dist/modules/mcp/tools/operations/style/fonts/fonts.test.d.ts +1 -0
- package/dist/modules/mcp/tools/operations/style/fonts/upsertFont.d.ts +35 -0
- package/dist/modules/mcp/tools/operations/style/fonts/upsertFont.js +66 -0
- package/dist/modules/mcp/tools/operations/style/index.d.ts +2 -0
- package/dist/modules/mcp/tools/operations/style/operations.d.ts +34 -0
- package/dist/modules/mcp/tools/operations/style/operations.js +5 -1
- package/dist/modules/mcp/tools/operations/style/translator.d.ts +13 -1
- package/dist/modules/mcp/tools/operations/style/translator.js +18 -1
- package/dist/modules/mcp/tools/operations/style/write.js +1 -1
- package/dist/modules/mcp/tools/preview.d.ts +58 -5
- package/dist/modules/mcp/tools/preview.js +1 -1
- package/dist/modules/mcp/tools/render.d.ts +61 -5
- package/dist/modules/mcp/tools/render.js +10 -3
- package/dist/modules/mcp/tools/screenshot.d.ts +151 -16
- package/dist/modules/mcp/tools/screenshot.js +22 -13
- package/dist/modules/mcp/tools/search.js +3 -3
- package/dist/modules/mcp/tools/shared/interactionReport.d.ts +7 -0
- package/dist/modules/mcp/tools/shared/interactionReport.js +48 -0
- package/dist/modules/mcp/tools/shared/validator/audit.js +4 -4
- package/dist/modules/mcp/tools/shared/validator/batch.d.ts +1 -0
- package/dist/modules/mcp/tools/shared/validator/batch.js +11 -2
- package/dist/modules/mcp/tools/shared/validator/bindings.js +6 -6
- package/dist/modules/mcp/tools/shared/validator/connectors.js +1 -1
- package/dist/modules/mcp/tools/shared/validator/context.d.ts +3 -0
- package/dist/modules/mcp/tools/shared/validator/css.js +1 -1
- package/dist/modules/mcp/tools/shared/validator/index.js +29 -9
- package/dist/modules/mcp/tools/shared/validator/interactions.js +41 -7
- package/dist/modules/mcp/tools/shared/validator/refs.js +4 -4
- package/dist/modules/mcp/tools/validate.d.ts +149 -15
- package/dist/modules/mcp/types/aiSchema.d.ts +33 -4
- package/dist/modules/mcp/types/previewTypes.d.ts +19 -0
- package/dist/modules/mcp/types/screenshotTypes.d.ts +1 -0
- package/dist/modules/mcp/types/toolTypes.d.ts +6 -1
- package/dist/pipeline.js +1 -1
- package/dist/preview/createPreview.d.ts +4 -2
- package/dist/preview/createPreview.js +16 -6
- package/dist/server.d.ts +3 -0
- package/dist/server.js +3 -1
- package/dist/stages/preview.js +20 -1
- package/dist/tests/httpRequest.d.ts +2 -0
- package/package.json +20 -16
- package/skills/plitzi-render/SKILL.md +84 -11
- package/dist/modules/mcp/catalogs/builtinCallbacks.d.ts +0 -19
- package/dist/modules/mcp/catalogs/builtinCallbacks.js +0 -139
- package/dist/modules/mcp/catalogs/builtinComponents.d.ts +0 -4
- package/dist/modules/mcp/catalogs/builtinComponents.js +0 -165
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.d.ts +0 -17
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +0 -50
- package/dist/modules/mcp/catalogs/builtinTransformers.d.ts +0 -28
- package/dist/modules/mcp/catalogs/builtinTransformers.js +0 -148
- package/dist/modules/mcp/catalogs/builtinUtilities.d.ts +0 -15
- package/dist/modules/mcp/catalogs/builtinUtilities.js +0 -90
- package/dist/modules/mcp/catalogs/cssCatalog/border.d.ts +0 -4
- package/dist/modules/mcp/catalogs/cssCatalog/border.js +0 -30
- package/dist/modules/mcp/catalogs/cssCatalog/box.d.ts +0 -4
- package/dist/modules/mcp/catalogs/cssCatalog/box.js +0 -31
- package/dist/modules/mcp/catalogs/cssCatalog/helpers.d.ts +0 -34
- package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +0 -185
- package/dist/modules/mcp/catalogs/cssCatalog/index.d.ts +0 -18
- package/dist/modules/mcp/catalogs/cssCatalog/index.js +0 -131
- package/dist/modules/mcp/catalogs/cssCatalog/layout.d.ts +0 -9
- package/dist/modules/mcp/catalogs/cssCatalog/layout.js +0 -99
- package/dist/modules/mcp/catalogs/cssCatalog/visual.d.ts +0 -8
- package/dist/modules/mcp/catalogs/cssCatalog/visual.js +0 -147
- package/dist/modules/mcp/catalogs/paramSpec.d.ts +0 -39
- package/dist/modules/mcp/catalogs/paramSpec.js +0 -69
- package/dist/modules/oauth/authorize.d.ts +0 -7
- package/dist/modules/oauth/authorize.js +0 -177
- package/dist/modules/oauth/challenge.d.ts +0 -11
- package/dist/modules/oauth/challenge.js +0 -33
- package/dist/modules/oauth/consentPage.d.ts +0 -7
- package/dist/modules/oauth/consentPage.js +0 -118
- package/dist/modules/oauth/metadata.d.ts +0 -40
- package/dist/modules/oauth/metadata.js +0 -69
- package/dist/modules/oauth/params.d.ts +0 -5
- package/dist/modules/oauth/params.js +0 -5
- package/dist/modules/oauth/pkce.d.ts +0 -6
- package/dist/modules/oauth/pkce.js +0 -15
- package/dist/modules/oauth/records.d.ts +0 -71
- package/dist/modules/oauth/records.js +0 -46
- package/dist/modules/oauth/register.d.ts +0 -5
- package/dist/modules/oauth/register.js +0 -55
- package/dist/modules/oauth/respond.d.ts +0 -13
- package/dist/modules/oauth/respond.js +0 -44
- package/dist/modules/oauth/token.d.ts +0 -5
- package/dist/modules/oauth/token.js +0 -100
- package/dist/stages/oauth.d.ts +0 -19
- package/dist/stages/oauth.js +0 -114
- /package/dist/modules/mcp/catalogs/{builtinTransformers.test.d.ts → pluginCatalog.test.d.ts} +0 -0
- /package/dist/modules/mcp/{catalogs/cssCatalog/cssCatalog.test.d.ts → localScreenshotClient.test.d.ts} +0 -0
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { findFolderByRef,
|
|
2
|
-
import { pageUri, pagesUri } from "../../../../helpers/uris.js";
|
|
1
|
+
import { findFolderByRef, findLayoutByRef, findPageByRef, indexAddPage, resolveRef } from "../../../../helpers/space.js";
|
|
2
|
+
import { layoutsUri, pageUri, pagesUri } from "../../../../helpers/uris.js";
|
|
3
3
|
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
4
4
|
import { guardNewRef } from "../write.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
//#region src/modules/mcp/tools/operations/schema/pages/upsertPage.ts
|
|
7
7
|
var upsertPageOp = z.object({
|
|
8
8
|
type: z.literal("upsertPage"),
|
|
9
|
-
ref: z.string().describe("Page id
|
|
9
|
+
ref: z.string().describe("Page id to update, or a new id you choose to create one. The id IS the page name — starts with a letter, then letters, numbers, hyphens and underscores (\"pricing\"), unique across the space."),
|
|
10
10
|
label: z.string().optional(),
|
|
11
11
|
slug: z.string().optional().describe("The page URL path, RELATIVE — never start it with \"/\" (parent folder slugs prepend it; a leading \"/\" is stripped). Set one on create for a stable route: \"pricing\", \"posts/:postId\". A \":name\" segment is a route param, readable as {{name}} and as navigation.routeParams.name. Omitted → the page ref is used."),
|
|
12
12
|
folder: z.string().nullable().optional().describe("Ref of an existing folder to place this page in; \"\" or null moves it to the root. Unknown → error"),
|
|
13
13
|
default: z.boolean().optional(),
|
|
14
|
+
layout: z.string().nullable().optional().describe("Ref of the layout shell this page renders inside; \"\" or null detaches it. See plitzi://schema/{env}/layouts."),
|
|
15
|
+
layoutContainer: z.string().nullable().optional().describe("Ref of the container INSIDE that shell where this page body goes — the slot. Must belong to it."),
|
|
14
16
|
enabled: z.boolean().optional().describe("false disables the page in the published SDK runtime (not routable/accessible to end users); it stays editable here. Defaults to true")
|
|
15
17
|
}).describe("Create a page, or update it when ref already exists (only the fields you pass change).");
|
|
16
18
|
var upsertPage = (space, env, op) => {
|
|
@@ -24,38 +26,67 @@ var upsertPage = (space, env, op) => {
|
|
|
24
26
|
folderValue = resolved.id;
|
|
25
27
|
}
|
|
26
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The two halves of "this page is rendered inside that shell", resolved together because they are one decision.
|
|
31
|
+
*
|
|
32
|
+
* `layout` names the shell — a root of its own — and `layoutContainer` names the slot INSIDE it. Naming a slot
|
|
33
|
+
* that belongs to some other tree is the failure worth catching here: it stores fine, and the page then renders
|
|
34
|
+
* its body into a container the shell never shows.
|
|
35
|
+
*/
|
|
36
|
+
let layoutValue;
|
|
37
|
+
let slotValue;
|
|
38
|
+
if (op.layout !== void 0) {
|
|
39
|
+
if (op.layout === null || op.layout === "") layoutValue = "";
|
|
40
|
+
else if (!findLayoutByRef(space.schema, op.layout)) return fail("layout", `Layout "${op.layout}" not found`, "Create it with upsertLayout, or read plitzi://schema/" + env + "/layouts");
|
|
41
|
+
else layoutValue = op.layout;
|
|
42
|
+
}
|
|
43
|
+
if (op.layoutContainer !== void 0) {
|
|
44
|
+
if (op.layoutContainer === null || op.layoutContainer === "") slotValue = "";
|
|
45
|
+
else {
|
|
46
|
+
const existingPage = findPageByRef(space.schema, op.ref);
|
|
47
|
+
const shellRef = layoutValue ?? existingPage?.attributes.layout;
|
|
48
|
+
const shell = shellRef ? findLayoutByRef(space.schema, shellRef) : void 0;
|
|
49
|
+
if (!shell) return fail("layoutContainer", "A slot needs a layout to be part of", "Pass `layout` in the same op (or set it first) so the slot can be checked against that shell");
|
|
50
|
+
if (!resolveRef(space.schema, shell, op.layoutContainer)) return fail("layoutContainer", `"${op.layoutContainer}" is not an element of layout "${shell.id}"`, `Read plitzi://schema/${env}/pages/${shell.id} and name a container from that tree`);
|
|
51
|
+
slotValue = op.layoutContainer;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
27
54
|
const existing = findPageByRef(space.schema, op.ref);
|
|
28
55
|
if (existing) {
|
|
29
|
-
const oldRef = pageRefOf(existing);
|
|
30
56
|
existing.attributes = {
|
|
31
57
|
...existing.attributes,
|
|
32
58
|
...slug !== void 0 ? { slug } : {},
|
|
33
59
|
...op.label !== void 0 ? { name: op.label } : {},
|
|
34
60
|
...op.default !== void 0 ? { default: op.default } : {},
|
|
35
61
|
...op.enabled !== void 0 ? { enabled: op.enabled } : {},
|
|
36
|
-
...folderValue !== void 0 ? { folder: folderValue } : {}
|
|
62
|
+
...folderValue !== void 0 ? { folder: folderValue } : {},
|
|
63
|
+
...layoutValue !== void 0 ? { layout: layoutValue } : {},
|
|
64
|
+
...slotValue !== void 0 ? { layoutContainer: slotValue } : {}
|
|
37
65
|
};
|
|
38
|
-
indexReRefPage(space.schema, existing, oldRef);
|
|
39
66
|
return {
|
|
40
67
|
...empty(),
|
|
41
68
|
updated: 1,
|
|
42
|
-
staleResources: [
|
|
69
|
+
staleResources: [
|
|
70
|
+
pageUri(env, op.ref),
|
|
71
|
+
pagesUri(env),
|
|
72
|
+
...layoutValue === void 0 ? [] : [layoutsUri(env)]
|
|
73
|
+
]
|
|
43
74
|
};
|
|
44
75
|
}
|
|
45
76
|
const guard = guardNewRef(space, op.ref, "ref");
|
|
46
77
|
if (guard) return guard;
|
|
47
|
-
const id =
|
|
48
|
-
const attributes = {
|
|
49
|
-
slug: slug ?? op.ref,
|
|
50
|
-
name: op.label ?? op.ref,
|
|
51
|
-
default: op.default ?? false,
|
|
52
|
-
enabled: op.enabled ?? true,
|
|
53
|
-
folder: folderValue ?? ""
|
|
54
|
-
};
|
|
78
|
+
const id = op.ref;
|
|
55
79
|
const page = {
|
|
56
80
|
id,
|
|
57
|
-
|
|
58
|
-
|
|
81
|
+
attributes: {
|
|
82
|
+
slug: slug ?? op.ref,
|
|
83
|
+
name: op.label ?? op.ref,
|
|
84
|
+
default: op.default ?? false,
|
|
85
|
+
enabled: op.enabled ?? true,
|
|
86
|
+
folder: folderValue ?? "",
|
|
87
|
+
layout: layoutValue ?? "",
|
|
88
|
+
layoutContainer: slotValue ?? ""
|
|
89
|
+
},
|
|
59
90
|
definition: {
|
|
60
91
|
rootId: id,
|
|
61
92
|
label: op.label ?? op.ref,
|
|
@@ -70,7 +101,11 @@ var upsertPage = (space, env, op) => {
|
|
|
70
101
|
return {
|
|
71
102
|
...empty(),
|
|
72
103
|
created: 1,
|
|
73
|
-
staleResources: [
|
|
104
|
+
staleResources: [
|
|
105
|
+
pageUri(env, op.ref),
|
|
106
|
+
pagesUri(env),
|
|
107
|
+
...layoutValue ? [layoutsUri(env)] : []
|
|
108
|
+
]
|
|
74
109
|
};
|
|
75
110
|
};
|
|
76
111
|
//#endregion
|
|
@@ -103,4 +103,8 @@ export declare const interactionNode: z.ZodObject<{
|
|
|
103
103
|
elementId: z.ZodOptional<z.ZodString>;
|
|
104
104
|
preview: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
105
105
|
}, z.core.$strip>;
|
|
106
|
-
|
|
106
|
+
/** What the validator checks: an authored node, or one read back from storage — which may carry a `task` type the
|
|
107
|
+
* write vocabulary above does not offer. Checking the stored shape is the point; refusing it is the validator's. */
|
|
108
|
+
export type InteractionNodeInput = Omit<z.infer<typeof interactionNode>, 'nodeType'> & {
|
|
109
|
+
nodeType: z.infer<typeof interactionNodeType> | 'task';
|
|
110
|
+
};
|
|
@@ -69,7 +69,7 @@ var initialStateInput = z.object({
|
|
|
69
69
|
visibility: z.boolean().optional().describe("Initial visibility of the element")
|
|
70
70
|
});
|
|
71
71
|
var elementShape = {
|
|
72
|
-
ref: z.string().describe("
|
|
72
|
+
ref: z.string().describe("The name of the element. On a new one it BECOMES its id — the one key everything addresses it by: its data source is `<type>_<name>` and interactions target it by this. Letters, digits, `-` and `_`, starting with a letter; no dots (they would split that source path). Unique across the space."),
|
|
73
73
|
type: z.string().describe("Type from plitzi://types"),
|
|
74
74
|
label: z.string().optional(),
|
|
75
75
|
subType: z.string().optional(),
|
|
@@ -124,7 +124,7 @@ var interactionNode = z.object({
|
|
|
124
124
|
params: z.record(z.string(), z.unknown()).optional(),
|
|
125
125
|
enabled: z.boolean().optional(),
|
|
126
126
|
when: ruleGroup.optional().describe("QueryBuilder RuleGroup gating this step (validated structurally)"),
|
|
127
|
-
elementId: z.string().optional().describe("Element whose callback this step invokes; defaults to this element
|
|
127
|
+
elementId: z.string().optional().describe("Element whose callback this step invokes, by name; defaults to this element"),
|
|
128
128
|
preview: z.record(z.string(), z.unknown()).optional()
|
|
129
129
|
});
|
|
130
130
|
//#endregion
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ElementVersion } from '../../../helpers';
|
|
2
|
-
import { AIElementDetail, AIFolder, AIPageSkeleton, AIPageStyles, AIPageSummary, AISchemaVariable, AISettings } from '../../../types';
|
|
2
|
+
import { AIElementDetail, AIFolder, AILayoutSummary, AIPageSkeleton, AIPageStyles, AIPageSummary, AISchemaVariable, AISettings } from '../../../types';
|
|
3
3
|
import { Element, Schema, Style } from '@plitzi/sdk-shared';
|
|
4
4
|
export declare const pageSummariesToAI: (schema: Schema) => AIPageSummary[];
|
|
5
|
+
export declare const layoutSummariesToAI: (schema: Schema) => AILayoutSummary[];
|
|
5
6
|
export declare const foldersToAI: (schema: Schema) => AIFolder[];
|
|
6
7
|
export declare const folderRefToAI: (schema: Schema, ref: string) => AIFolder | undefined;
|
|
7
8
|
export declare const elementView: (schema: Schema, el: Element, style: Style) => ElementVersion;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computeVersion } from "../../../helpers/computeVersion.js";
|
|
2
|
-
import { descendantCount, descendantIds, elementById,
|
|
2
|
+
import { descendantCount, descendantIds, elementById, getLayoutElements, getPageElements, nameOf, orderedChildren, pageFoldersOf, pageRefOfElement, pagesUsingLayout, slugRouteParams, spaceIndex, strOr } from "../../../helpers/space.js";
|
|
3
3
|
import { bindingsToAI, flowsFromInteractions } from "../../../helpers/interactions.js";
|
|
4
4
|
import { definitionToAI, globalStylesForType, idStyleToAI } from "../style/translator.js";
|
|
5
5
|
//#region src/modules/mcp/tools/operations/schema/translator.ts
|
|
@@ -14,14 +14,26 @@ var slotClasses = (selectors) => {
|
|
|
14
14
|
return slots;
|
|
15
15
|
};
|
|
16
16
|
var pageSummariesToAI = (schema) => getPageElements(schema).map((page) => ({
|
|
17
|
-
ref:
|
|
17
|
+
ref: page.id,
|
|
18
18
|
label: nameOf(page),
|
|
19
19
|
slug: strOr(page.attributes.slug) ?? "",
|
|
20
20
|
default: page.attributes.default === true,
|
|
21
21
|
enabled: page.attributes.enabled !== false,
|
|
22
22
|
folder: strOr(page.attributes.folder) || void 0,
|
|
23
|
+
layout: strOr(page.attributes.layout) || void 0,
|
|
24
|
+
layoutSlot: strOr(page.attributes.layoutContainer) || void 0,
|
|
23
25
|
elementCount: descendantCount(schema, page.id)
|
|
24
26
|
}));
|
|
27
|
+
var layoutSummariesToAI = (schema) => getLayoutElements(schema).map((layout) => {
|
|
28
|
+
const pages = pagesUsingLayout(schema, layout.id);
|
|
29
|
+
return {
|
|
30
|
+
ref: layout.id,
|
|
31
|
+
label: nameOf(layout),
|
|
32
|
+
usedBy: pages.map((page) => page.id),
|
|
33
|
+
slots: [...new Set(pages.map((page) => strOr(page.attributes.layoutContainer)).filter(Boolean))],
|
|
34
|
+
elementCount: descendantCount(schema, layout.id)
|
|
35
|
+
};
|
|
36
|
+
});
|
|
25
37
|
var folderToAI = (folder) => ({
|
|
26
38
|
ref: folder.id,
|
|
27
39
|
name: folder.name,
|
|
@@ -51,7 +63,7 @@ var skeletonNode = (schema, el, style) => {
|
|
|
51
63
|
const base = splitClasses(el.definition.styleSelectors.base);
|
|
52
64
|
const slots = slotClasses(el.definition.styleSelectors);
|
|
53
65
|
return {
|
|
54
|
-
ref:
|
|
66
|
+
ref: el.id,
|
|
55
67
|
type: el.definition.type,
|
|
56
68
|
label: el.definition.label,
|
|
57
69
|
subType: strOr(el.attributes.subType),
|
|
@@ -65,7 +77,7 @@ var skeletonNode = (schema, el, style) => {
|
|
|
65
77
|
var pageSkeletonToAI = (schema, pageEl, style) => {
|
|
66
78
|
const slug = strOr(pageEl.attributes.slug) ?? "";
|
|
67
79
|
return {
|
|
68
|
-
ref:
|
|
80
|
+
ref: pageEl.id,
|
|
69
81
|
label: nameOf(pageEl),
|
|
70
82
|
slug,
|
|
71
83
|
default: pageEl.attributes.default === true,
|
|
@@ -103,7 +115,7 @@ var pageStylesToAI = (schema, style, pageEl) => {
|
|
|
103
115
|
globalStyles.push(global);
|
|
104
116
|
}
|
|
105
117
|
return {
|
|
106
|
-
ref:
|
|
118
|
+
ref: pageEl.id,
|
|
107
119
|
definitions,
|
|
108
120
|
globalStyles
|
|
109
121
|
};
|
|
@@ -155,18 +167,18 @@ var elementDetailToAI = (schema, el, style) => {
|
|
|
155
167
|
const base = splitClasses(el.definition.styleSelectors.base);
|
|
156
168
|
const slots = slotClasses(el.definition.styleSelectors);
|
|
157
169
|
const detail = {
|
|
158
|
-
ref:
|
|
170
|
+
ref: el.id,
|
|
159
171
|
type: el.definition.type,
|
|
160
172
|
subType: strOr(el.attributes.subType),
|
|
161
173
|
label: el.definition.label,
|
|
162
174
|
pageRef: pageRefOfElement(schema, el),
|
|
163
|
-
parentRef: parent
|
|
175
|
+
parentRef: parent?.id,
|
|
164
176
|
props: propsOf(el),
|
|
165
177
|
style: {
|
|
166
178
|
base,
|
|
167
179
|
slots
|
|
168
180
|
},
|
|
169
|
-
childRefs: children.length > 0 ? children.map(
|
|
181
|
+
childRefs: children.length > 0 ? children.map((child) => child.id) : void 0
|
|
170
182
|
};
|
|
171
183
|
if (el.definition.runtime) detail.runtime = el.definition.runtime;
|
|
172
184
|
const initialState = initialStateToAI(el);
|
|
@@ -213,4 +225,4 @@ var settingsToAI = (schema) => {
|
|
|
213
225
|
return result;
|
|
214
226
|
};
|
|
215
227
|
//#endregion
|
|
216
|
-
export { elementDetailToAI, elementView, folderRefToAI, foldersToAI, pageSkeletonToAI, pageStylesToAI, pageSummariesToAI, schemaVariablesToAI, settingsToAI };
|
|
228
|
+
export { elementDetailToAI, elementView, folderRefToAI, foldersToAI, layoutSummariesToAI, pageSkeletonToAI, pageStylesToAI, pageSummariesToAI, schemaVariablesToAI, settingsToAI };
|
|
@@ -3,34 +3,21 @@ import { OpResult, Space } from '../../../helpers';
|
|
|
3
3
|
import { Env } from '../../../types';
|
|
4
4
|
import { Element } from '@plitzi/sdk-shared';
|
|
5
5
|
export declare const ID_REF_HINT: string;
|
|
6
|
-
/** Every
|
|
6
|
+
/** Every name in an element input tree (the element plus its nested children) — each becomes an element's id. */
|
|
7
7
|
export declare const collectInputRefs: (input: ElementInput) => string[];
|
|
8
|
-
/** Validate a
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* Uniqueness is checked with the ref lookups rather than `FlatMap.idRefConflict`, and deliberately so: these are
|
|
13
|
-
* a superset of it. FlatMap asks whether another element holds this idRef; the MCP must also refuse a ref that
|
|
14
|
-
* shadows a raw id or a page slug, because its handlers resolve refs through those too — calling both would just
|
|
15
|
-
* run the same rule twice. Null when the ref is usable.
|
|
16
|
-
*
|
|
17
|
-
* Enforced here, at every point a ref BECOMES an idRef — addressing an existing element by its raw id is not
|
|
18
|
-
* charset-checked, which is why the validator cannot simply tighten its own REF_RE for every ref it sees. */
|
|
8
|
+
/** Validate a name that is about to become an element's id: the charset, then whether anything already answers to
|
|
9
|
+
* it. Both rules are sdk-schema's `elementIdConflict` — never restated here, so the MCP cannot drift from what
|
|
10
|
+
* the builder and the schema validator enforce. Null when the name is usable. */
|
|
19
11
|
export declare const guardNewRef: (space: Space, ref: string, field: string) => OpResult | null;
|
|
20
|
-
export { folderUri, foldersUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from '../../../helpers';
|
|
12
|
+
export { folderUri, foldersUri, layoutsUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from '../../../helpers';
|
|
21
13
|
export declare const removeFromParent: (space: Space, child: Element) => void;
|
|
22
14
|
export declare const placeChild: (parent: Element, childId: string, index?: number) => void;
|
|
23
15
|
export declare const writeInitialState: (el: Element, input: InitialStateInput, merge: boolean) => void;
|
|
24
16
|
export declare const createElement: (space: Space, page: Element, input: ElementInput, parent: Element, index: number | undefined) => void;
|
|
25
|
-
/** The
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
export declare const ensureIdRef: (space: Space, el: Element) => string;
|
|
30
|
-
/** The key an interaction node must store to reach a target element. Every ref field also accepts a raw id, so a
|
|
31
|
-
* target given as an id is resolved to the element's idRef — the key the runtime registers callbacks under. A
|
|
32
|
-
* target that has no idRef is given one (see `ensureIdRef`), since it must be reachable to be wired to. A target
|
|
33
|
-
* that resolves to no element is left as written — it is already a ref, or a key only a plugin knows. */
|
|
17
|
+
/** The key an interaction node must store to reach a target element — which is simply that element's name, since
|
|
18
|
+
* the name it is addressed by and the key the runtime registers callbacks under are now the same thing. A target
|
|
19
|
+
* that resolves to no element is left as written: it is a source module (`space`, `state`) or a key only a plugin
|
|
20
|
+
* knows. */
|
|
34
21
|
export declare const resolveTargetRef: (space: Space, elementId: string) => string;
|
|
35
22
|
/** Resolve a non-page element within a page for the element-scoped ops (bindings, interactions). Returns the
|
|
36
23
|
* element, or a teachable OpResult when the page or element ref does not resolve — so each op reports the same
|
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { folderUri, foldersUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from "../../../helpers/uris.js";
|
|
1
|
+
import { findRootByRef, indexAddElement, resolveRef } from "../../../helpers/space.js";
|
|
2
|
+
import { folderUri, foldersUri, layoutsUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from "../../../helpers/uris.js";
|
|
3
3
|
import { fail } from "../../../helpers/opResult.js";
|
|
4
|
-
import {
|
|
4
|
+
import { elementIdConflict, isValidElementId } from "@plitzi/sdk-schema/helpers/elementId";
|
|
5
5
|
//#region src/modules/mcp/tools/operations/schema/write.ts
|
|
6
|
-
var ID_REF_HINT = "Start with a letter, then letters, numbers, hyphens and underscores (e.g. \"hero-cta\" or \"food_item\"). The
|
|
7
|
-
var TAKEN_HINT = "
|
|
8
|
-
/** Every
|
|
6
|
+
var ID_REF_HINT = "Start with a letter, then letters, numbers, hyphens and underscores (e.g. \"hero-cta\" or \"food_item\"). The name IS the element id, which the runtime embeds in source names like `apiContainer_<id>.field` and in interaction targets — a dot would split those paths (an underscore is fine: the FIRST `_` separates the type from the id, and element types carry none, so extra underscores are unambiguous).";
|
|
7
|
+
var TAKEN_HINT = "A name must be unique across the space — pick a different one, or address the existing element by this name.";
|
|
8
|
+
/** Every name in an element input tree (the element plus its nested children) — each becomes an element's id. */
|
|
9
9
|
var collectInputRefs = (input) => [input.ref, ...(input.children ?? []).flatMap(collectInputRefs)];
|
|
10
|
-
/** Validate a
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Uniqueness is checked with the ref lookups rather than `FlatMap.idRefConflict`, and deliberately so: these are
|
|
15
|
-
* a superset of it. FlatMap asks whether another element holds this idRef; the MCP must also refuse a ref that
|
|
16
|
-
* shadows a raw id or a page slug, because its handlers resolve refs through those too — calling both would just
|
|
17
|
-
* run the same rule twice. Null when the ref is usable.
|
|
18
|
-
*
|
|
19
|
-
* Enforced here, at every point a ref BECOMES an idRef — addressing an existing element by its raw id is not
|
|
20
|
-
* charset-checked, which is why the validator cannot simply tighten its own REF_RE for every ref it sees. */
|
|
10
|
+
/** Validate a name that is about to become an element's id: the charset, then whether anything already answers to
|
|
11
|
+
* it. Both rules are sdk-schema's `elementIdConflict` — never restated here, so the MCP cannot drift from what
|
|
12
|
+
* the builder and the schema validator enforce. Null when the name is usable. */
|
|
21
13
|
var guardNewRef = (space, ref, field) => {
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
return
|
|
14
|
+
const conflict = elementIdConflict(space.schema.flat, ref);
|
|
15
|
+
if (!conflict) return null;
|
|
16
|
+
return isValidElementId(ref) ? fail(field, conflict, TAKEN_HINT) : fail(field, conflict, ID_REF_HINT);
|
|
25
17
|
};
|
|
26
18
|
var removeFromParent = (space, child) => {
|
|
27
19
|
const parent = child.definition.parentId ? space.schema.flat[child.definition.parentId] : void 0;
|
|
@@ -49,16 +41,15 @@ var writeInitialState = (el, input, merge) => {
|
|
|
49
41
|
el.definition.initialState = next;
|
|
50
42
|
};
|
|
51
43
|
var createElement = (space, page, input, parent, index) => {
|
|
52
|
-
const id = generateObjectId();
|
|
53
44
|
const { subType, ...props } = {
|
|
54
45
|
subType: input.subType,
|
|
55
46
|
...input.props
|
|
56
47
|
};
|
|
57
48
|
const styleSelectors = { base: (input.style?.base ?? []).join(" ") };
|
|
58
49
|
for (const [slot, classes] of Object.entries(input.style?.slots ?? {})) styleSelectors[slot] = classes.join(" ");
|
|
50
|
+
const id = input.ref;
|
|
59
51
|
const el = {
|
|
60
52
|
id,
|
|
61
|
-
idRef: input.ref,
|
|
62
53
|
attributes: subType === void 0 ? props : {
|
|
63
54
|
subType,
|
|
64
55
|
...props
|
|
@@ -79,34 +70,23 @@ var createElement = (space, page, input, parent, index) => {
|
|
|
79
70
|
if (input.initialState) writeInitialState(el, input.initialState, false);
|
|
80
71
|
for (const child of input.children ?? []) createElement(space, page, child, el, void 0);
|
|
81
72
|
};
|
|
82
|
-
/** The
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
var ensureIdRef = (space, el) => {
|
|
87
|
-
if (el.idRef) return el.idRef;
|
|
88
|
-
const index = spaceIndex(space.schema);
|
|
89
|
-
el.idRef = makeIdRef(el.definition.type, (candidate) => index.elementByRef.has(candidate) || index.pageByRef.has(candidate));
|
|
90
|
-
indexReRefElement(space.schema, el);
|
|
91
|
-
return el.idRef;
|
|
92
|
-
};
|
|
93
|
-
/** The key an interaction node must store to reach a target element. Every ref field also accepts a raw id, so a
|
|
94
|
-
* target given as an id is resolved to the element's idRef — the key the runtime registers callbacks under. A
|
|
95
|
-
* target that has no idRef is given one (see `ensureIdRef`), since it must be reachable to be wired to. A target
|
|
96
|
-
* that resolves to no element is left as written — it is already a ref, or a key only a plugin knows. */
|
|
73
|
+
/** The key an interaction node must store to reach a target element — which is simply that element's name, since
|
|
74
|
+
* the name it is addressed by and the key the runtime registers callbacks under are now the same thing. A target
|
|
75
|
+
* that resolves to no element is left as written: it is a source module (`space`, `state`) or a key only a plugin
|
|
76
|
+
* knows. */
|
|
97
77
|
var resolveTargetRef = (space, elementId) => {
|
|
98
|
-
const el = space.schema.flat[elementId]
|
|
99
|
-
return el ?
|
|
78
|
+
const el = space.schema.flat[elementId];
|
|
79
|
+
return el ? el.id : elementId;
|
|
100
80
|
};
|
|
101
81
|
/** Resolve a non-page element within a page for the element-scoped ops (bindings, interactions). Returns the
|
|
102
82
|
* element, or a teachable OpResult when the page or element ref does not resolve — so each op reports the same
|
|
103
83
|
* errors as patchElement without repeating them. */
|
|
104
84
|
var resolveElement = (space, env, pageRef, ref) => {
|
|
105
|
-
const page =
|
|
106
|
-
if (!page) return { error: fail("pageRef", `Page "${pageRef}" not found`, `Read plitzi://schema/${env}/pages for valid refs`) };
|
|
85
|
+
const page = findRootByRef(space.schema, pageRef);
|
|
86
|
+
if (!page) return { error: fail("pageRef", `Page or layout "${pageRef}" not found`, `Read plitzi://schema/${env}/pages for valid refs — a layout shell is named there too`) };
|
|
107
87
|
const el = resolveRef(space.schema, page, ref);
|
|
108
|
-
if (!el || el.id === page.id) return { error: fail("ref", `Element "${ref}" not found in page "${pageRef}"`, "
|
|
88
|
+
if (!el || el.id === page.id) return { error: fail("ref", `Element "${ref}" not found in page "${pageRef}"`, "Name an element this page holds") };
|
|
109
89
|
return { el };
|
|
110
90
|
};
|
|
111
91
|
//#endregion
|
|
112
|
-
export { ID_REF_HINT, collectInputRefs, createElement,
|
|
92
|
+
export { ID_REF_HINT, collectInputRefs, createElement, folderUri, foldersUri, guardNewRef, layoutsUri, pageUri, pagesUri, placeChild, removeFromParent, resolveElement, resolveTargetRef, schemaVarsUri, settingsUri, writeInitialState };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { actionAccess, actionField, actionLimits, actionNode, actionTriggerParams } from "./actions/document.js";
|
|
1
2
|
import { connectorConnection, readEndpoint, writeEndpoint } from "./connectors/manifest.js";
|
|
2
3
|
import { bindingInput, elementInput, initialStateInput, interactionNode, position, ruleGroup, styleRefs, styleVariantInput } from "./schema/shared.js";
|
|
3
4
|
import { cssMap, cssPatchMap, definitionSlot, definitionSlotPatch, displayModeCss, displayModeCssPatch, themeValue } from "./style/shared.js";
|
|
@@ -38,7 +39,12 @@ var SHARED_SCHEMAS = [
|
|
|
38
39
|
[themeValue, "ThemeValue"],
|
|
39
40
|
[readEndpoint, "ConnectorRead"],
|
|
40
41
|
[writeEndpoint, "ConnectorWrite"],
|
|
41
|
-
[connectorConnection, "ConnectorConnection"]
|
|
42
|
+
[connectorConnection, "ConnectorConnection"],
|
|
43
|
+
[actionAccess, "ActionAccess"],
|
|
44
|
+
[actionTriggerParams, "ActionTriggerParams"],
|
|
45
|
+
[actionField, "ActionField"],
|
|
46
|
+
[actionNode, "ActionStep"],
|
|
47
|
+
[actionLimits, "ActionLimits"]
|
|
42
48
|
];
|
|
43
49
|
var claimSchemaId = (schema, id) => {
|
|
44
50
|
const taken = z.globalRegistry._idmap.get(id);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OpResult, Space } from '../../../../helpers';
|
|
3
|
+
import { Env } from '../../../../types';
|
|
4
|
+
export declare const deleteFontOp: z.ZodObject<{
|
|
5
|
+
type: z.ZodLiteral<"deleteFont">;
|
|
6
|
+
family: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type DeleteFont = z.infer<typeof deleteFontOp>;
|
|
9
|
+
export declare const deleteFont: (space: Space, env: Env, op: DeleteFont) => OpResult;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { fontUri, fontsUri } from "../../../../helpers/uris.js";
|
|
2
|
+
import { empty } from "../../../../helpers/opResult.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/modules/mcp/tools/operations/style/fonts/deleteFont.ts
|
|
5
|
+
var deleteFontOp = z.object({
|
|
6
|
+
type: z.literal("deleteFont"),
|
|
7
|
+
family: z.string()
|
|
8
|
+
}).describe("Stop loading a family. Rules still naming it are left alone and render in their fallback.");
|
|
9
|
+
var deleteFont = (space, env, op) => {
|
|
10
|
+
const fonts = space.style.fonts ?? [];
|
|
11
|
+
const index = fonts.findIndex((item) => item.family === op.family);
|
|
12
|
+
if (index === -1) return empty();
|
|
13
|
+
fonts.splice(index, 1);
|
|
14
|
+
return {
|
|
15
|
+
...empty(),
|
|
16
|
+
deleted: 1,
|
|
17
|
+
staleResources: [fontUri(env, op.family), fontsUri(env)]
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { deleteFont, deleteFontOp };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OpResult, Space } from '../../../../helpers';
|
|
3
|
+
import { Env } from '../../../../types';
|
|
4
|
+
export declare const upsertFontOp: z.ZodObject<{
|
|
5
|
+
type: z.ZodLiteral<"upsertFont">;
|
|
6
|
+
family: z.ZodString;
|
|
7
|
+
source: z.ZodEnum<{
|
|
8
|
+
system: "system";
|
|
9
|
+
hosted: "hosted";
|
|
10
|
+
google: "google";
|
|
11
|
+
remote: "remote";
|
|
12
|
+
}>;
|
|
13
|
+
fallback: z.ZodString;
|
|
14
|
+
weights: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
15
|
+
styles: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
16
|
+
normal: "normal";
|
|
17
|
+
italic: "italic";
|
|
18
|
+
}>>>;
|
|
19
|
+
stylesheet: z.ZodOptional<z.ZodString>;
|
|
20
|
+
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
21
|
+
weight: z.ZodNumber;
|
|
22
|
+
style: z.ZodEnum<{
|
|
23
|
+
normal: "normal";
|
|
24
|
+
italic: "italic";
|
|
25
|
+
}>;
|
|
26
|
+
format: z.ZodEnum<{
|
|
27
|
+
woff2: "woff2";
|
|
28
|
+
woff: "woff";
|
|
29
|
+
}>;
|
|
30
|
+
url: z.ZodOptional<z.ZodString>;
|
|
31
|
+
path: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strip>>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type UpsertFont = z.infer<typeof upsertFontOp>;
|
|
35
|
+
export declare const upsertFont: (space: Space, env: Env, op: UpsertFont) => OpResult;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { fontUri, fontsUri } from "../../../../helpers/uris.js";
|
|
2
|
+
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
3
|
+
import { FontValidationError, parseSpaceFont } from "@plitzi/sdk-shared/style";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/modules/mcp/tools/operations/style/fonts/upsertFont.ts
|
|
6
|
+
/**
|
|
7
|
+
* What an AGENT can say about a font, which is less than a manifest entry can hold.
|
|
8
|
+
*
|
|
9
|
+
* `display`, `preload`, `subsets` and per-face unicode ranges are left out on purpose: every field here is carried
|
|
10
|
+
* in four tool schemas, in the model's context, on every request — and those four are tuning a person makes in the
|
|
11
|
+
* Fonts panel, never something an agent has a reason to decide. The manifest still holds them; this vocabulary
|
|
12
|
+
* simply does not offer them.
|
|
13
|
+
*/
|
|
14
|
+
var fontFile = z.object({
|
|
15
|
+
weight: z.number().int(),
|
|
16
|
+
style: z.enum(["normal", "italic"]),
|
|
17
|
+
format: z.enum(["woff2", "woff"]),
|
|
18
|
+
url: z.string().optional().describe("remote: https URL of the file"),
|
|
19
|
+
path: z.string().optional().describe("hosted: path in the font store")
|
|
20
|
+
});
|
|
21
|
+
var upsertFontOp = z.object({
|
|
22
|
+
type: z.literal("upsertFont"),
|
|
23
|
+
family: z.string().describe("What font-family names. Unique per space."),
|
|
24
|
+
source: z.enum([
|
|
25
|
+
"system",
|
|
26
|
+
"google",
|
|
27
|
+
"remote",
|
|
28
|
+
"hosted"
|
|
29
|
+
]).describe("system loads nothing; remote needs a URL"),
|
|
30
|
+
fallback: z.string().describe("Read until the face arrives, e.g. \"system-ui, sans-serif\""),
|
|
31
|
+
weights: z.array(z.number().int()).optional().describe("Each one is a file. Default [400]."),
|
|
32
|
+
styles: z.array(z.enum(["normal", "italic"])).optional(),
|
|
33
|
+
stylesheet: z.string().optional().describe("remote: https URL declaring the @font-face rules"),
|
|
34
|
+
files: z.array(fontFile).optional()
|
|
35
|
+
}).describe("Declare a family the space loads. A font-family naming one that is not declared renders in a fallback.");
|
|
36
|
+
var upsertFont = (space, env, op) => {
|
|
37
|
+
let font;
|
|
38
|
+
try {
|
|
39
|
+
font = parseSpaceFont({
|
|
40
|
+
...op,
|
|
41
|
+
type: void 0,
|
|
42
|
+
display: "swap"
|
|
43
|
+
});
|
|
44
|
+
} catch (err) {
|
|
45
|
+
if (!(err instanceof FontValidationError)) throw err;
|
|
46
|
+
return fail("font", err.message, "Fix the field the message names and send the operation again.");
|
|
47
|
+
}
|
|
48
|
+
const fonts = space.style.fonts ??= [];
|
|
49
|
+
const index = fonts.findIndex((item) => item.family === font.family);
|
|
50
|
+
if (index === -1) {
|
|
51
|
+
fonts.push(font);
|
|
52
|
+
return {
|
|
53
|
+
...empty(),
|
|
54
|
+
created: 1,
|
|
55
|
+
staleResources: [fontUri(env, font.family), fontsUri(env)]
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
fonts[index] = font;
|
|
59
|
+
return {
|
|
60
|
+
...empty(),
|
|
61
|
+
updated: 1,
|
|
62
|
+
staleResources: [fontUri(env, font.family), fontsUri(env)]
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
//#endregion
|
|
66
|
+
export { upsertFont, upsertFontOp };
|
|
@@ -12,4 +12,6 @@ export * from './idStyles/upsertIdStyle';
|
|
|
12
12
|
export * from './idStyles/patchIdStyle';
|
|
13
13
|
export * from './idStyles/deleteIdStyle';
|
|
14
14
|
export * from './variables/upsertStyleVariable';
|
|
15
|
+
export * from './fonts/upsertFont';
|
|
16
|
+
export * from './fonts/deleteFont';
|
|
15
17
|
export * from './variables/deleteStyleVariable';
|
|
@@ -261,4 +261,38 @@ export declare const styleOps: {
|
|
|
261
261
|
}>;
|
|
262
262
|
name: import('zod').ZodString;
|
|
263
263
|
}, import('zod/v4/core').$strip>;
|
|
264
|
+
upsertFont: import('zod').ZodObject<{
|
|
265
|
+
type: import('zod').ZodLiteral<"upsertFont">;
|
|
266
|
+
family: import('zod').ZodString;
|
|
267
|
+
source: import('zod').ZodEnum<{
|
|
268
|
+
system: "system";
|
|
269
|
+
hosted: "hosted";
|
|
270
|
+
google: "google";
|
|
271
|
+
remote: "remote";
|
|
272
|
+
}>;
|
|
273
|
+
fallback: import('zod').ZodString;
|
|
274
|
+
weights: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodNumber>>;
|
|
275
|
+
styles: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodEnum<{
|
|
276
|
+
normal: "normal";
|
|
277
|
+
italic: "italic";
|
|
278
|
+
}>>>;
|
|
279
|
+
stylesheet: import('zod').ZodOptional<import('zod').ZodString>;
|
|
280
|
+
files: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodObject<{
|
|
281
|
+
weight: import('zod').ZodNumber;
|
|
282
|
+
style: import('zod').ZodEnum<{
|
|
283
|
+
normal: "normal";
|
|
284
|
+
italic: "italic";
|
|
285
|
+
}>;
|
|
286
|
+
format: import('zod').ZodEnum<{
|
|
287
|
+
woff2: "woff2";
|
|
288
|
+
woff: "woff";
|
|
289
|
+
}>;
|
|
290
|
+
url: import('zod').ZodOptional<import('zod').ZodString>;
|
|
291
|
+
path: import('zod').ZodOptional<import('zod').ZodString>;
|
|
292
|
+
}, import('zod/v4/core').$strip>>>;
|
|
293
|
+
}, import('zod/v4/core').$strip>;
|
|
294
|
+
deleteFont: import('zod').ZodObject<{
|
|
295
|
+
type: import('zod').ZodLiteral<"deleteFont">;
|
|
296
|
+
family: import('zod').ZodString;
|
|
297
|
+
}, import('zod/v4/core').$strip>;
|
|
264
298
|
};
|
|
@@ -2,6 +2,8 @@ import { deleteDefinitionOp } from "./definitions/deleteDefinition.js";
|
|
|
2
2
|
import { patchDefinitionOp } from "./definitions/patchDefinition.js";
|
|
3
3
|
import { upsertDefinitionOp } from "./definitions/upsertDefinition.js";
|
|
4
4
|
import { upsertDefinitionsOp } from "./definitions/upsertDefinitions.js";
|
|
5
|
+
import { deleteFontOp } from "./fonts/deleteFont.js";
|
|
6
|
+
import { upsertFontOp } from "./fonts/upsertFont.js";
|
|
5
7
|
import { deleteGlobalStyleOp } from "./globalStyles/deleteGlobalStyle.js";
|
|
6
8
|
import { patchGlobalStyleOp } from "./globalStyles/patchGlobalStyle.js";
|
|
7
9
|
import { upsertGlobalStyleOp } from "./globalStyles/upsertGlobalStyle.js";
|
|
@@ -23,7 +25,9 @@ var styleOps = {
|
|
|
23
25
|
patchIdStyle: patchIdStyleOp,
|
|
24
26
|
deleteIdStyle: deleteIdStyleOp,
|
|
25
27
|
upsertStyleVariable: upsertStyleVariableOp,
|
|
26
|
-
deleteStyleVariable: deleteStyleVariableOp
|
|
28
|
+
deleteStyleVariable: deleteStyleVariableOp,
|
|
29
|
+
upsertFont: upsertFontOp,
|
|
30
|
+
deleteFont: deleteFontOp
|
|
27
31
|
};
|
|
28
32
|
//#endregion
|
|
29
33
|
export { styleOps };
|