@plitzi/sdk-mcp 0.37.8 → 0.37.10
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 +837 -0
- package/README.md +7 -2
- package/dist/modules/mcp/apps/render/view/streamProgress.ts +1 -3
- package/dist/modules/mcp/helpers/agentPrompt.js +7 -5
- package/dist/modules/mcp/helpers/components.d.ts +14 -0
- package/dist/modules/mcp/helpers/components.js +32 -0
- package/dist/modules/mcp/helpers/guide.js +170 -6
- package/dist/modules/mcp/helpers/index.d.ts +1 -0
- package/dist/modules/mcp/helpers/space.d.ts +5 -0
- package/dist/modules/mcp/helpers/space.js +2 -1
- package/dist/modules/mcp/helpers/uris.d.ts +3 -0
- package/dist/modules/mcp/helpers/uris.js +4 -1
- package/dist/modules/mcp/resources/explain.d.ts +19 -0
- package/dist/modules/mcp/resources/explain.js +22 -0
- package/dist/modules/mcp/resources/explain.test.d.ts +1 -0
- package/dist/modules/mcp/resources/primer.js +12 -1
- package/dist/modules/mcp/resources/register.js +10 -0
- package/dist/modules/mcp/resources/schema.js +17 -10
- package/dist/modules/mcp/server.js +1 -1
- package/dist/modules/mcp/tests/components.test.d.ts +1 -0
- package/dist/modules/mcp/tests/flags.test.d.ts +1 -0
- package/dist/modules/mcp/tools/apply/dispatch.js +30 -1
- package/dist/modules/mcp/tools/apply/index.d.ts +27 -0
- package/dist/modules/mcp/tools/apply/index.js +5 -3
- package/dist/modules/mcp/tools/operations/index.d.ts +108 -0
- package/dist/modules/mcp/tools/operations/index.js +4 -0
- package/dist/modules/mcp/tools/operations/schema/components/deleteComponent.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/schema/components/deleteComponent.js +21 -0
- package/dist/modules/mcp/tools/operations/schema/components/index.d.ts +2 -0
- package/dist/modules/mcp/tools/operations/schema/components/upsertComponent.d.ts +14 -0
- package/dist/modules/mcp/tools/operations/schema/components/upsertComponent.js +147 -0
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +2 -0
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +9 -2
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +3 -0
- package/dist/modules/mcp/tools/operations/schema/flags/deleteFlag.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/schema/flags/deleteFlag.js +21 -0
- package/dist/modules/mcp/tools/operations/schema/flags/upsertFlag.d.ts +15 -0
- package/dist/modules/mcp/tools/operations/schema/flags/upsertFlag.js +38 -0
- package/dist/modules/mcp/tools/operations/schema/index.d.ts +3 -0
- package/dist/modules/mcp/tools/operations/schema/operations.d.ts +31 -0
- package/dist/modules/mcp/tools/operations/schema/operations.js +9 -1
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +1 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +8 -2
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +1 -0
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +28 -2
- package/dist/modules/mcp/tools/operations/schema/shared.d.ts +8 -0
- package/dist/modules/mcp/tools/operations/schema/shared.js +10 -2
- package/dist/modules/mcp/tools/operations/schema/translator.js +8 -0
- package/dist/modules/mcp/tools/operations/schema/write.js +7 -2
- package/dist/modules/mcp/tools/operations/schemaIds.js +3 -1
- package/dist/modules/mcp/tools/preview.d.ts +27 -0
- package/dist/modules/mcp/tools/render.d.ts +27 -0
- package/dist/modules/mcp/tools/screenshot.d.ts +27 -0
- package/dist/modules/mcp/tools/shared/draftBatch.d.ts +2 -0
- package/dist/modules/mcp/tools/shared/draftBatch.js +3 -1
- package/dist/modules/mcp/tools/shared/lintDraft.js +16 -4
- package/dist/modules/mcp/tools/shared/newSuggestions.d.ts +7 -0
- package/dist/modules/mcp/tools/shared/newSuggestions.js +20 -0
- package/dist/modules/mcp/tools/shared/validator/batch.js +1 -1
- package/dist/modules/mcp/tools/shared/validator/index.js +17 -9
- package/dist/modules/mcp/tools/validate.d.ts +27 -0
- package/dist/modules/mcp/tools/validate.js +8 -6
- package/dist/modules/mcp/types/aiSchema.d.ts +26 -1
- package/dist/modules/mcp/types/toolTypes.d.ts +4 -0
- package/package.json +9 -9
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { buildDataSourceCatalog, buildInteractionCatalog } from "../catalogs/observed.js";
|
|
2
|
+
import { componentSummariesToAI, componentView, findComponentByRef } from "../helpers/components.js";
|
|
2
3
|
import { findElementByRef, findRootByRef } from "../helpers/space.js";
|
|
3
|
-
import { afterPrefix, dataSourcesUri, elementUri, folderUri, foldersUri, interactionsUri, layoutsUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from "../helpers/uris.js";
|
|
4
|
+
import { afterPrefix, componentsUri, dataSourcesUri, elementUri, flagsUri, folderUri, foldersUri, interactionsUri, layoutsUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from "../helpers/uris.js";
|
|
4
5
|
import { envelope } from "./envelope.js";
|
|
5
6
|
import { elementView, folderRefToAI, foldersToAI, layoutSummariesToAI, pageSkeletonToAI, pageStylesToAI, pageSummariesToAI, schemaVariablesToAI, settingsToAI } from "../tools/operations/schema/translator.js";
|
|
7
|
+
import { treeOf } from "@plitzi/sdk-schema/helpers/components";
|
|
6
8
|
//#region src/modules/mcp/resources/schema.ts
|
|
7
9
|
/** Element-schema reads: page listings/skeletons/styles, folders, single elements and schema variables. Returns
|
|
8
10
|
* undefined when the URI belongs to another domain, null when the shape is ours but the ref does not resolve. */
|
|
9
11
|
var readSchemaResource = (space, env, uri) => {
|
|
10
12
|
if (uri === pagesUri(env)) return envelope(pageSummariesToAI(space.schema));
|
|
11
13
|
if (uri === layoutsUri(env)) return envelope(layoutSummariesToAI(space.schema));
|
|
14
|
+
if (uri === componentsUri(env)) return envelope(componentSummariesToAI(space.schema));
|
|
12
15
|
if (uri === foldersUri(env)) return envelope(foldersToAI(space.schema));
|
|
13
16
|
const folderRef = afterPrefix(uri, folderUri(env, ""));
|
|
14
17
|
if (folderRef !== void 0) {
|
|
@@ -17,25 +20,29 @@ var readSchemaResource = (space, env, uri) => {
|
|
|
17
20
|
}
|
|
18
21
|
const pageItem = afterPrefix(uri, pageUri(env, ""));
|
|
19
22
|
if (pageItem !== void 0) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return
|
|
23
|
+
const styles = pageItem.endsWith("/styles");
|
|
24
|
+
const ref = styles ? pageItem.slice(0, -7) : pageItem;
|
|
25
|
+
const component = findComponentByRef(space.schema, ref);
|
|
26
|
+
const target = component ? componentView(space, component) : space;
|
|
27
|
+
const page = findRootByRef(target.schema, component ? component.rootId : ref);
|
|
28
|
+
if (!page) return null;
|
|
29
|
+
return envelope(styles ? pageStylesToAI(target.schema, target.style, page) : pageSkeletonToAI(target.schema, page, target.style));
|
|
27
30
|
}
|
|
28
31
|
const elementRef = afterPrefix(uri, elementUri(env, ""));
|
|
29
32
|
if (elementRef !== void 0) {
|
|
30
|
-
const
|
|
33
|
+
const componentId = treeOf(space.schema, elementRef)?.componentId;
|
|
34
|
+
const component = componentId ? findComponentByRef(space.schema, componentId) : void 0;
|
|
35
|
+
const target = component ? componentView(space, component) : space;
|
|
36
|
+
const el = findElementByRef(target.schema, elementRef);
|
|
31
37
|
if (!el) return null;
|
|
32
|
-
const view = elementView(
|
|
38
|
+
const view = elementView(target.schema, el, target.style);
|
|
33
39
|
return {
|
|
34
40
|
stateVersion: view.version,
|
|
35
41
|
data: view.detail
|
|
36
42
|
};
|
|
37
43
|
}
|
|
38
44
|
if (uri === schemaVarsUri(env)) return envelope(schemaVariablesToAI(space.schema));
|
|
45
|
+
if (uri === flagsUri(env)) return envelope(space.schema.flags ?? {});
|
|
39
46
|
if (uri === settingsUri(env)) return envelope(settingsToAI(space.schema));
|
|
40
47
|
if (uri === interactionsUri(env)) return envelope(buildInteractionCatalog(space.schema));
|
|
41
48
|
if (uri === dataSourcesUri(env)) return envelope(buildDataSourceCatalog(space.schema));
|
|
@@ -69,7 +69,7 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
|
|
|
69
69
|
const getSpace = () => spacePromise ??= loadSpace();
|
|
70
70
|
const server = new McpServer({
|
|
71
71
|
name: "plitzi-mcp",
|
|
72
|
-
version: "0.37.
|
|
72
|
+
version: "0.37.10"
|
|
73
73
|
}, { instructions: hasSpace ? serverInstructions : widgetsOnlyInstructions });
|
|
74
74
|
const { getChanges } = adapters;
|
|
75
75
|
registerResources(server, getSpace, MCP_ENV, log, hasSpace, getChanges ? (query) => getChanges(requireSpaceId(), MCP_ENV, query) : void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { componentView, findComponentByRef } from "../../helpers/components.js";
|
|
2
|
+
import { pageUri } from "../../helpers/uris.js";
|
|
1
3
|
import { fail } from "../../helpers/opResult.js";
|
|
2
4
|
import { deleteAction } from "../operations/actions/deleteAction.js";
|
|
3
5
|
import { patchAction } from "../operations/actions/patchAction.js";
|
|
@@ -9,10 +11,14 @@ import { deleteFunctionFile, upsertFunctionFile } from "../operations/functions/
|
|
|
9
11
|
import { deleteBinding } from "../operations/schema/bindings/deleteBinding.js";
|
|
10
12
|
import { patchBinding } from "../operations/schema/bindings/patchBinding.js";
|
|
11
13
|
import { upsertBinding } from "../operations/schema/bindings/upsertBinding.js";
|
|
14
|
+
import { deleteComponent } from "../operations/schema/components/deleteComponent.js";
|
|
15
|
+
import { upsertComponent } from "../operations/schema/components/upsertComponent.js";
|
|
12
16
|
import { deleteElement } from "../operations/schema/elements/deleteElement.js";
|
|
13
17
|
import { moveElement } from "../operations/schema/elements/moveElement.js";
|
|
14
18
|
import { patchElement } from "../operations/schema/elements/patchElement.js";
|
|
15
19
|
import { upsertElement } from "../operations/schema/elements/upsertElement.js";
|
|
20
|
+
import { deleteFlag } from "../operations/schema/flags/deleteFlag.js";
|
|
21
|
+
import { upsertFlag } from "../operations/schema/flags/upsertFlag.js";
|
|
16
22
|
import { deleteFolder } from "../operations/schema/folders/deleteFolder.js";
|
|
17
23
|
import { upsertFolder } from "../operations/schema/folders/upsertFolder.js";
|
|
18
24
|
import { deleteInteraction } from "../operations/schema/interactions/deleteInteraction.js";
|
|
@@ -41,6 +47,25 @@ import { deleteStyleVariable } from "../operations/style/variables/deleteStyleVa
|
|
|
41
47
|
import { upsertStyleVariable } from "../operations/style/variables/upsertStyleVariable.js";
|
|
42
48
|
import { isStyleOp } from "../operations/index.js";
|
|
43
49
|
//#region src/modules/mcp/tools/apply/dispatch.ts
|
|
50
|
+
var isRooted = (op) => "pageRef" in op;
|
|
51
|
+
/**
|
|
52
|
+
* An element op names its root with `pageRef`, and a component is one: the op runs on the component's tree as if it
|
|
53
|
+
* were the space's only one — rooted at the component's root — so every element op works inside a component with no
|
|
54
|
+
* code of its own. What it made stale is the component, read as `pages/<component>`.
|
|
55
|
+
*/
|
|
56
|
+
var executeRooted = (space, env, op) => {
|
|
57
|
+
const component = isRooted(op) ? findComponentByRef(space.schema, op.pageRef) : void 0;
|
|
58
|
+
if (!component || !isRooted(op)) return executeOp(space, env, op);
|
|
59
|
+
const retargeted = {
|
|
60
|
+
...op,
|
|
61
|
+
pageRef: component.rootId
|
|
62
|
+
};
|
|
63
|
+
const result = executeOp(componentView(space, component), env, retargeted);
|
|
64
|
+
return {
|
|
65
|
+
...result,
|
|
66
|
+
staleResources: result.staleResources.map((uri) => uri === pageUri(env, component.rootId) ? pageUri(env, component.id) : uri)
|
|
67
|
+
};
|
|
68
|
+
};
|
|
44
69
|
var executeOp = (space, env, op) => {
|
|
45
70
|
switch (op.type) {
|
|
46
71
|
case "upsertElement": return upsertElement(space, env, op);
|
|
@@ -55,6 +80,8 @@ var executeOp = (space, env, op) => {
|
|
|
55
80
|
case "deleteFolder": return deleteFolder(space, env, op);
|
|
56
81
|
case "upsertVariable": return upsertVariable(space, env, op);
|
|
57
82
|
case "deleteVariable": return deleteVariable(space, env, op);
|
|
83
|
+
case "upsertFlag": return upsertFlag(space, env, op);
|
|
84
|
+
case "deleteFlag": return deleteFlag(space, env, op);
|
|
58
85
|
case "upsertBinding": return upsertBinding(space, env, op);
|
|
59
86
|
case "patchBinding": return patchBinding(space, env, op);
|
|
60
87
|
case "deleteBinding": return deleteBinding(space, env, op);
|
|
@@ -62,6 +89,8 @@ var executeOp = (space, env, op) => {
|
|
|
62
89
|
case "patchInteractionNode": return patchInteractionNode(space, env, op);
|
|
63
90
|
case "deleteInteraction": return deleteInteraction(space, env, op);
|
|
64
91
|
case "patchSettings": return patchSettings(space, env, op);
|
|
92
|
+
case "upsertComponent": return upsertComponent(space, env, op);
|
|
93
|
+
case "deleteComponent": return deleteComponent(space, env, op);
|
|
65
94
|
case "upsertDefinition": return upsertDefinition(space, env, op);
|
|
66
95
|
case "upsertDefinitions": return upsertDefinitions(space, env, op);
|
|
67
96
|
case "patchDefinition": return patchDefinition(space, env, op);
|
|
@@ -113,7 +142,7 @@ var applyOperations = (space, env, ops) => {
|
|
|
113
142
|
const droppedActions = /* @__PURE__ */ new Set();
|
|
114
143
|
for (let i = 0; i < ops.length; i++) {
|
|
115
144
|
const op = ops[i];
|
|
116
|
-
const result =
|
|
145
|
+
const result = executeRooted(space, env, op);
|
|
117
146
|
if (result.errors) {
|
|
118
147
|
outcome.errors.push(...result.errors.map((e) => ({
|
|
119
148
|
...e,
|
|
@@ -54,6 +54,8 @@ export declare const applyShape: {
|
|
|
54
54
|
client: "client";
|
|
55
55
|
shared: "shared";
|
|
56
56
|
}>>;
|
|
57
|
+
flag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
58
|
+
anchor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
57
59
|
}, z.core.$strip>, z.ZodObject<{
|
|
58
60
|
type: z.ZodLiteral<"deleteElement">;
|
|
59
61
|
pageRef: z.ZodString;
|
|
@@ -78,6 +80,7 @@ export declare const applyShape: {
|
|
|
78
80
|
layout: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
79
81
|
layoutContainer: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
80
82
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
flag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
81
84
|
}, z.core.$strip>, z.ZodObject<{
|
|
82
85
|
type: z.ZodLiteral<"deletePage">;
|
|
83
86
|
ref: z.ZodString;
|
|
@@ -122,6 +125,18 @@ export declare const applyShape: {
|
|
|
122
125
|
}, z.core.$strip>, z.ZodObject<{
|
|
123
126
|
type: z.ZodLiteral<"deleteVariable">;
|
|
124
127
|
name: z.ZodString;
|
|
128
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
129
|
+
type: z.ZodLiteral<"upsertFlag">;
|
|
130
|
+
name: z.ZodString;
|
|
131
|
+
description: z.ZodOptional<z.ZodString>;
|
|
132
|
+
value: z.ZodBoolean;
|
|
133
|
+
rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
134
|
+
when: z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>;
|
|
135
|
+
value: z.ZodBoolean;
|
|
136
|
+
}, z.core.$strip>>>;
|
|
137
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
138
|
+
type: z.ZodLiteral<"deleteFlag">;
|
|
139
|
+
name: z.ZodString;
|
|
125
140
|
}, z.core.$strip>, z.ZodObject<{
|
|
126
141
|
type: z.ZodLiteral<"upsertBinding">;
|
|
127
142
|
pageRef: z.ZodString;
|
|
@@ -225,6 +240,7 @@ export declare const applyShape: {
|
|
|
225
240
|
}, z.core.$strip>, z.ZodObject<{
|
|
226
241
|
type: z.ZodLiteral<"patchSettings">;
|
|
227
242
|
customCss: z.ZodOptional<z.ZodString>;
|
|
243
|
+
notifications: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>>;
|
|
228
244
|
keepState: z.ZodOptional<z.ZodBoolean>;
|
|
229
245
|
stateStorage: z.ZodOptional<z.ZodEnum<{
|
|
230
246
|
localStorage: "localStorage";
|
|
@@ -269,6 +285,17 @@ export declare const applyShape: {
|
|
|
269
285
|
}>>;
|
|
270
286
|
presence: z.ZodOptional<z.ZodBoolean>;
|
|
271
287
|
}, z.core.$strip>>>>;
|
|
288
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
289
|
+
type: z.ZodLiteral<"upsertComponent">;
|
|
290
|
+
ref: z.ZodString;
|
|
291
|
+
label: z.ZodOptional<z.ZodString>;
|
|
292
|
+
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
293
|
+
slots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
294
|
+
fromRef: z.ZodOptional<z.ZodString>;
|
|
295
|
+
instanceRef: z.ZodOptional<z.ZodString>;
|
|
296
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
297
|
+
type: z.ZodLiteral<"deleteComponent">;
|
|
298
|
+
ref: z.ZodString;
|
|
272
299
|
}, z.core.$strip>, z.ZodObject<{
|
|
273
300
|
desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
274
301
|
tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
@@ -53,7 +53,7 @@ var apply = async (input, space, persisters) => {
|
|
|
53
53
|
errors: result.errors,
|
|
54
54
|
warnings: noWarnings(result.warnings)
|
|
55
55
|
};
|
|
56
|
-
const { draft, outcome, warnings } = result;
|
|
56
|
+
const { draft, outcome, warnings, suggestions } = result;
|
|
57
57
|
if (input.dryRun) return {
|
|
58
58
|
applied: false,
|
|
59
59
|
dryRun: true,
|
|
@@ -64,7 +64,8 @@ var apply = async (input, space, persisters) => {
|
|
|
64
64
|
},
|
|
65
65
|
changed: changedResources(draft, env, outcome.staleResources),
|
|
66
66
|
elements: resolvedElements(draft, env, outcome.elementRefs),
|
|
67
|
-
warnings: noWarnings(warnings)
|
|
67
|
+
warnings: noWarnings(warnings),
|
|
68
|
+
suggestions: noWarnings(suggestions)
|
|
68
69
|
};
|
|
69
70
|
let persisted = true;
|
|
70
71
|
if (outcome.changedFunctions && draft.functions) {
|
|
@@ -118,7 +119,8 @@ var apply = async (input, space, persisters) => {
|
|
|
118
119
|
},
|
|
119
120
|
changed: changedResources(draft, env, outcome.staleResources),
|
|
120
121
|
elements: resolvedElements(draft, env, outcome.elementRefs),
|
|
121
|
-
warnings: noWarnings(warnings)
|
|
122
|
+
warnings: noWarnings(warnings),
|
|
123
|
+
suggestions: noWarnings(suggestions)
|
|
122
124
|
};
|
|
123
125
|
};
|
|
124
126
|
var applyTool = defineTool({
|
|
@@ -50,6 +50,8 @@ export declare const documentOperation: z.ZodDiscriminatedUnion<readonly [z.ZodO
|
|
|
50
50
|
client: "client";
|
|
51
51
|
shared: "shared";
|
|
52
52
|
}>>;
|
|
53
|
+
flag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
54
|
+
anchor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
55
|
}, z.core.$strip>, z.ZodObject<{
|
|
54
56
|
type: z.ZodLiteral<"deleteElement">;
|
|
55
57
|
pageRef: z.ZodString;
|
|
@@ -74,6 +76,7 @@ export declare const documentOperation: z.ZodDiscriminatedUnion<readonly [z.ZodO
|
|
|
74
76
|
layout: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
75
77
|
layoutContainer: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
76
78
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
flag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
77
80
|
}, z.core.$strip>, z.ZodObject<{
|
|
78
81
|
type: z.ZodLiteral<"deletePage">;
|
|
79
82
|
ref: z.ZodString;
|
|
@@ -118,6 +121,18 @@ export declare const documentOperation: z.ZodDiscriminatedUnion<readonly [z.ZodO
|
|
|
118
121
|
}, z.core.$strip>, z.ZodObject<{
|
|
119
122
|
type: z.ZodLiteral<"deleteVariable">;
|
|
120
123
|
name: z.ZodString;
|
|
124
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
125
|
+
type: z.ZodLiteral<"upsertFlag">;
|
|
126
|
+
name: z.ZodString;
|
|
127
|
+
description: z.ZodOptional<z.ZodString>;
|
|
128
|
+
value: z.ZodBoolean;
|
|
129
|
+
rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
130
|
+
when: z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>;
|
|
131
|
+
value: z.ZodBoolean;
|
|
132
|
+
}, z.core.$strip>>>;
|
|
133
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
134
|
+
type: z.ZodLiteral<"deleteFlag">;
|
|
135
|
+
name: z.ZodString;
|
|
121
136
|
}, z.core.$strip>, z.ZodObject<{
|
|
122
137
|
type: z.ZodLiteral<"upsertBinding">;
|
|
123
138
|
pageRef: z.ZodString;
|
|
@@ -221,6 +236,7 @@ export declare const documentOperation: z.ZodDiscriminatedUnion<readonly [z.ZodO
|
|
|
221
236
|
}, z.core.$strip>, z.ZodObject<{
|
|
222
237
|
type: z.ZodLiteral<"patchSettings">;
|
|
223
238
|
customCss: z.ZodOptional<z.ZodString>;
|
|
239
|
+
notifications: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>>;
|
|
224
240
|
keepState: z.ZodOptional<z.ZodBoolean>;
|
|
225
241
|
stateStorage: z.ZodOptional<z.ZodEnum<{
|
|
226
242
|
localStorage: "localStorage";
|
|
@@ -265,6 +281,17 @@ export declare const documentOperation: z.ZodDiscriminatedUnion<readonly [z.ZodO
|
|
|
265
281
|
}>>;
|
|
266
282
|
presence: z.ZodOptional<z.ZodBoolean>;
|
|
267
283
|
}, z.core.$strip>>>>;
|
|
284
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
285
|
+
type: z.ZodLiteral<"upsertComponent">;
|
|
286
|
+
ref: z.ZodString;
|
|
287
|
+
label: z.ZodOptional<z.ZodString>;
|
|
288
|
+
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
289
|
+
slots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
290
|
+
fromRef: z.ZodOptional<z.ZodString>;
|
|
291
|
+
instanceRef: z.ZodOptional<z.ZodString>;
|
|
292
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
293
|
+
type: z.ZodLiteral<"deleteComponent">;
|
|
294
|
+
ref: z.ZodString;
|
|
268
295
|
}, z.core.$strip>, z.ZodObject<{
|
|
269
296
|
desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
270
297
|
tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
@@ -807,6 +834,8 @@ export declare const operation: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
807
834
|
client: "client";
|
|
808
835
|
shared: "shared";
|
|
809
836
|
}>>;
|
|
837
|
+
flag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
838
|
+
anchor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
810
839
|
}, z.core.$strip>, z.ZodObject<{
|
|
811
840
|
type: z.ZodLiteral<"deleteElement">;
|
|
812
841
|
pageRef: z.ZodString;
|
|
@@ -831,6 +860,7 @@ export declare const operation: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
831
860
|
layout: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
832
861
|
layoutContainer: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
833
862
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
863
|
+
flag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
834
864
|
}, z.core.$strip>, z.ZodObject<{
|
|
835
865
|
type: z.ZodLiteral<"deletePage">;
|
|
836
866
|
ref: z.ZodString;
|
|
@@ -875,6 +905,18 @@ export declare const operation: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
875
905
|
}, z.core.$strip>, z.ZodObject<{
|
|
876
906
|
type: z.ZodLiteral<"deleteVariable">;
|
|
877
907
|
name: z.ZodString;
|
|
908
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
909
|
+
type: z.ZodLiteral<"upsertFlag">;
|
|
910
|
+
name: z.ZodString;
|
|
911
|
+
description: z.ZodOptional<z.ZodString>;
|
|
912
|
+
value: z.ZodBoolean;
|
|
913
|
+
rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
914
|
+
when: z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>;
|
|
915
|
+
value: z.ZodBoolean;
|
|
916
|
+
}, z.core.$strip>>>;
|
|
917
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
918
|
+
type: z.ZodLiteral<"deleteFlag">;
|
|
919
|
+
name: z.ZodString;
|
|
878
920
|
}, z.core.$strip>, z.ZodObject<{
|
|
879
921
|
type: z.ZodLiteral<"upsertBinding">;
|
|
880
922
|
pageRef: z.ZodString;
|
|
@@ -978,6 +1020,7 @@ export declare const operation: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
978
1020
|
}, z.core.$strip>, z.ZodObject<{
|
|
979
1021
|
type: z.ZodLiteral<"patchSettings">;
|
|
980
1022
|
customCss: z.ZodOptional<z.ZodString>;
|
|
1023
|
+
notifications: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>>;
|
|
981
1024
|
keepState: z.ZodOptional<z.ZodBoolean>;
|
|
982
1025
|
stateStorage: z.ZodOptional<z.ZodEnum<{
|
|
983
1026
|
localStorage: "localStorage";
|
|
@@ -1022,6 +1065,17 @@ export declare const operation: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1022
1065
|
}>>;
|
|
1023
1066
|
presence: z.ZodOptional<z.ZodBoolean>;
|
|
1024
1067
|
}, z.core.$strip>>>>;
|
|
1068
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1069
|
+
type: z.ZodLiteral<"upsertComponent">;
|
|
1070
|
+
ref: z.ZodString;
|
|
1071
|
+
label: z.ZodOptional<z.ZodString>;
|
|
1072
|
+
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1073
|
+
slots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1074
|
+
fromRef: z.ZodOptional<z.ZodString>;
|
|
1075
|
+
instanceRef: z.ZodOptional<z.ZodString>;
|
|
1076
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1077
|
+
type: z.ZodLiteral<"deleteComponent">;
|
|
1078
|
+
ref: z.ZodString;
|
|
1025
1079
|
}, z.core.$strip>, z.ZodObject<{
|
|
1026
1080
|
desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
1027
1081
|
tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
@@ -1836,6 +1890,8 @@ export declare const operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
1836
1890
|
client: "client";
|
|
1837
1891
|
shared: "shared";
|
|
1838
1892
|
}>>;
|
|
1893
|
+
flag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1894
|
+
anchor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1839
1895
|
}, z.core.$strip>, z.ZodObject<{
|
|
1840
1896
|
type: z.ZodLiteral<"deleteElement">;
|
|
1841
1897
|
pageRef: z.ZodString;
|
|
@@ -1860,6 +1916,7 @@ export declare const operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
1860
1916
|
layout: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1861
1917
|
layoutContainer: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1862
1918
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
1919
|
+
flag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1863
1920
|
}, z.core.$strip>, z.ZodObject<{
|
|
1864
1921
|
type: z.ZodLiteral<"deletePage">;
|
|
1865
1922
|
ref: z.ZodString;
|
|
@@ -1904,6 +1961,18 @@ export declare const operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
1904
1961
|
}, z.core.$strip>, z.ZodObject<{
|
|
1905
1962
|
type: z.ZodLiteral<"deleteVariable">;
|
|
1906
1963
|
name: z.ZodString;
|
|
1964
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1965
|
+
type: z.ZodLiteral<"upsertFlag">;
|
|
1966
|
+
name: z.ZodString;
|
|
1967
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1968
|
+
value: z.ZodBoolean;
|
|
1969
|
+
rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1970
|
+
when: z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>;
|
|
1971
|
+
value: z.ZodBoolean;
|
|
1972
|
+
}, z.core.$strip>>>;
|
|
1973
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1974
|
+
type: z.ZodLiteral<"deleteFlag">;
|
|
1975
|
+
name: z.ZodString;
|
|
1907
1976
|
}, z.core.$strip>, z.ZodObject<{
|
|
1908
1977
|
type: z.ZodLiteral<"upsertBinding">;
|
|
1909
1978
|
pageRef: z.ZodString;
|
|
@@ -2007,6 +2076,7 @@ export declare const operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
2007
2076
|
}, z.core.$strip>, z.ZodObject<{
|
|
2008
2077
|
type: z.ZodLiteral<"patchSettings">;
|
|
2009
2078
|
customCss: z.ZodOptional<z.ZodString>;
|
|
2079
|
+
notifications: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>>;
|
|
2010
2080
|
keepState: z.ZodOptional<z.ZodBoolean>;
|
|
2011
2081
|
stateStorage: z.ZodOptional<z.ZodEnum<{
|
|
2012
2082
|
localStorage: "localStorage";
|
|
@@ -2051,6 +2121,17 @@ export declare const operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
2051
2121
|
}>>;
|
|
2052
2122
|
presence: z.ZodOptional<z.ZodBoolean>;
|
|
2053
2123
|
}, z.core.$strip>>>>;
|
|
2124
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
2125
|
+
type: z.ZodLiteral<"upsertComponent">;
|
|
2126
|
+
ref: z.ZodString;
|
|
2127
|
+
label: z.ZodOptional<z.ZodString>;
|
|
2128
|
+
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2129
|
+
slots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2130
|
+
fromRef: z.ZodOptional<z.ZodString>;
|
|
2131
|
+
instanceRef: z.ZodOptional<z.ZodString>;
|
|
2132
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
2133
|
+
type: z.ZodLiteral<"deleteComponent">;
|
|
2134
|
+
ref: z.ZodString;
|
|
2054
2135
|
}, z.core.$strip>, z.ZodObject<{
|
|
2055
2136
|
desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
2056
2137
|
tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
@@ -2860,6 +2941,8 @@ export declare const documentOperations: z.ZodArray<z.ZodDiscriminatedUnion<read
|
|
|
2860
2941
|
client: "client";
|
|
2861
2942
|
shared: "shared";
|
|
2862
2943
|
}>>;
|
|
2944
|
+
flag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2945
|
+
anchor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2863
2946
|
}, z.core.$strip>, z.ZodObject<{
|
|
2864
2947
|
type: z.ZodLiteral<"deleteElement">;
|
|
2865
2948
|
pageRef: z.ZodString;
|
|
@@ -2884,6 +2967,7 @@ export declare const documentOperations: z.ZodArray<z.ZodDiscriminatedUnion<read
|
|
|
2884
2967
|
layout: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2885
2968
|
layoutContainer: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2886
2969
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
2970
|
+
flag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2887
2971
|
}, z.core.$strip>, z.ZodObject<{
|
|
2888
2972
|
type: z.ZodLiteral<"deletePage">;
|
|
2889
2973
|
ref: z.ZodString;
|
|
@@ -2928,6 +3012,18 @@ export declare const documentOperations: z.ZodArray<z.ZodDiscriminatedUnion<read
|
|
|
2928
3012
|
}, z.core.$strip>, z.ZodObject<{
|
|
2929
3013
|
type: z.ZodLiteral<"deleteVariable">;
|
|
2930
3014
|
name: z.ZodString;
|
|
3015
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
3016
|
+
type: z.ZodLiteral<"upsertFlag">;
|
|
3017
|
+
name: z.ZodString;
|
|
3018
|
+
description: z.ZodOptional<z.ZodString>;
|
|
3019
|
+
value: z.ZodBoolean;
|
|
3020
|
+
rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
3021
|
+
when: z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>;
|
|
3022
|
+
value: z.ZodBoolean;
|
|
3023
|
+
}, z.core.$strip>>>;
|
|
3024
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
3025
|
+
type: z.ZodLiteral<"deleteFlag">;
|
|
3026
|
+
name: z.ZodString;
|
|
2931
3027
|
}, z.core.$strip>, z.ZodObject<{
|
|
2932
3028
|
type: z.ZodLiteral<"upsertBinding">;
|
|
2933
3029
|
pageRef: z.ZodString;
|
|
@@ -3031,6 +3127,7 @@ export declare const documentOperations: z.ZodArray<z.ZodDiscriminatedUnion<read
|
|
|
3031
3127
|
}, z.core.$strip>, z.ZodObject<{
|
|
3032
3128
|
type: z.ZodLiteral<"patchSettings">;
|
|
3033
3129
|
customCss: z.ZodOptional<z.ZodString>;
|
|
3130
|
+
notifications: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>>;
|
|
3034
3131
|
keepState: z.ZodOptional<z.ZodBoolean>;
|
|
3035
3132
|
stateStorage: z.ZodOptional<z.ZodEnum<{
|
|
3036
3133
|
localStorage: "localStorage";
|
|
@@ -3075,6 +3172,17 @@ export declare const documentOperations: z.ZodArray<z.ZodDiscriminatedUnion<read
|
|
|
3075
3172
|
}>>;
|
|
3076
3173
|
presence: z.ZodOptional<z.ZodBoolean>;
|
|
3077
3174
|
}, z.core.$strip>>>>;
|
|
3175
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
3176
|
+
type: z.ZodLiteral<"upsertComponent">;
|
|
3177
|
+
ref: z.ZodString;
|
|
3178
|
+
label: z.ZodOptional<z.ZodString>;
|
|
3179
|
+
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3180
|
+
slots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
3181
|
+
fromRef: z.ZodOptional<z.ZodString>;
|
|
3182
|
+
instanceRef: z.ZodOptional<z.ZodString>;
|
|
3183
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
3184
|
+
type: z.ZodLiteral<"deleteComponent">;
|
|
3185
|
+
ref: z.ZodString;
|
|
3078
3186
|
}, z.core.$strip>, z.ZodObject<{
|
|
3079
3187
|
desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
3080
3188
|
tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
@@ -21,6 +21,8 @@ var documentOps = [
|
|
|
21
21
|
elementOps.deleteFolder,
|
|
22
22
|
elementOps.upsertVariable,
|
|
23
23
|
elementOps.deleteVariable,
|
|
24
|
+
elementOps.upsertFlag,
|
|
25
|
+
elementOps.deleteFlag,
|
|
24
26
|
elementOps.upsertBinding,
|
|
25
27
|
elementOps.patchBinding,
|
|
26
28
|
elementOps.deleteBinding,
|
|
@@ -28,6 +30,8 @@ var documentOps = [
|
|
|
28
30
|
elementOps.patchInteractionNode,
|
|
29
31
|
elementOps.deleteInteraction,
|
|
30
32
|
elementOps.patchSettings,
|
|
33
|
+
elementOps.upsertComponent,
|
|
34
|
+
elementOps.deleteComponent,
|
|
31
35
|
styleOps.upsertDefinition,
|
|
32
36
|
styleOps.upsertDefinitions,
|
|
33
37
|
styleOps.patchDefinition,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OpResult, Space } from '../../../../helpers';
|
|
3
|
+
import { Env } from '../../../../types';
|
|
4
|
+
export declare const deleteComponentOp: z.ZodObject<{
|
|
5
|
+
type: z.ZodLiteral<"deleteComponent">;
|
|
6
|
+
ref: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type DeleteComponent = z.infer<typeof deleteComponentOp>;
|
|
9
|
+
export declare const deleteComponent: (space: Space, env: Env, op: DeleteComponent) => OpResult;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { componentsUri } from "../../../../helpers/uris.js";
|
|
2
|
+
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
3
|
+
import { componentNamed, instancesOf, removeComponent } from "@plitzi/sdk-schema/helpers/components";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/modules/mcp/tools/operations/schema/components/deleteComponent.ts
|
|
6
|
+
var deleteComponentOp = z.object({
|
|
7
|
+
type: z.literal("deleteComponent"),
|
|
8
|
+
ref: z.string()
|
|
9
|
+
}).describe("Remove a component nothing places any more.");
|
|
10
|
+
var deleteComponent = (space, env, op) => {
|
|
11
|
+
if (!componentNamed(space.schema, op.ref)) return fail("ref", `Component "${op.ref}" not found`, `Read plitzi://schema/${env}/components for valid refs`);
|
|
12
|
+
const placed = instancesOf(space.schema, op.ref);
|
|
13
|
+
if (placed.length > 0 || !removeComponent(space.schema, op.ref)) return fail("ref", `Component "${op.ref}" is still placed by ${placed.map((instance) => `"${instance.id}"`).join(", ")}`, "detachInstance or deleteElement each of them first");
|
|
14
|
+
return {
|
|
15
|
+
...empty(),
|
|
16
|
+
deleted: 1,
|
|
17
|
+
staleResources: [componentsUri(env)]
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { deleteComponent, deleteComponentOp };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OpResult, Space } from '../../../../helpers';
|
|
3
|
+
import { Env } from '../../../../types';
|
|
4
|
+
export declare const upsertComponentOp: z.ZodObject<{
|
|
5
|
+
type: z.ZodLiteral<"upsertComponent">;
|
|
6
|
+
ref: z.ZodString;
|
|
7
|
+
label: z.ZodOptional<z.ZodString>;
|
|
8
|
+
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
9
|
+
slots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
+
fromRef: z.ZodOptional<z.ZodString>;
|
|
11
|
+
instanceRef: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
export type UpsertComponent = z.infer<typeof upsertComponentOp>;
|
|
14
|
+
export declare const upsertComponent: (space: Space, env: Env, op: UpsertComponent) => OpResult;
|