@plitzi/sdk-mcp 0.33.2 → 0.34.1
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 +77 -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,3 +1,4 @@
|
|
|
1
|
+
import { actionOps } from "./actions/index.js";
|
|
1
2
|
import { connectorOps } from "./connectors/index.js";
|
|
2
3
|
import { elementOps } from "./schema/operations.js";
|
|
3
4
|
import { registerSharedSchemaIds } from "./schemaIds.js";
|
|
@@ -13,6 +14,8 @@ var documentOps = [
|
|
|
13
14
|
elementOps.moveElement,
|
|
14
15
|
elementOps.upsertPage,
|
|
15
16
|
elementOps.deletePage,
|
|
17
|
+
elementOps.upsertLayout,
|
|
18
|
+
elementOps.deleteLayout,
|
|
16
19
|
elementOps.upsertFolder,
|
|
17
20
|
elementOps.deleteFolder,
|
|
18
21
|
elementOps.upsertVariable,
|
|
@@ -35,17 +38,23 @@ var documentOps = [
|
|
|
35
38
|
styleOps.patchIdStyle,
|
|
36
39
|
styleOps.deleteIdStyle,
|
|
37
40
|
styleOps.upsertStyleVariable,
|
|
38
|
-
styleOps.deleteStyleVariable
|
|
41
|
+
styleOps.deleteStyleVariable,
|
|
42
|
+
styleOps.upsertFont,
|
|
43
|
+
styleOps.deleteFont
|
|
39
44
|
];
|
|
40
45
|
var documentOperation = z.discriminatedUnion("type", documentOps);
|
|
41
46
|
var operation = z.discriminatedUnion("type", [
|
|
42
47
|
...documentOps,
|
|
43
48
|
connectorOps.upsertConnector,
|
|
44
49
|
connectorOps.patchConnector,
|
|
45
|
-
connectorOps.deleteConnector
|
|
50
|
+
connectorOps.deleteConnector,
|
|
51
|
+
actionOps.upsertAction,
|
|
52
|
+
actionOps.patchAction,
|
|
53
|
+
actionOps.deleteAction
|
|
46
54
|
]);
|
|
47
55
|
var STYLE_OP_TYPES = new Set(Object.keys(styleOps));
|
|
48
56
|
new Set(Object.keys(connectorOps));
|
|
57
|
+
new Set(Object.keys(actionOps));
|
|
49
58
|
var isStyleOp = (type) => STYLE_OP_TYPES.has(type);
|
|
50
59
|
var MAX_OPS = 1e3;
|
|
51
60
|
var environment = z.string().optional().describe("Environment; default main");
|
|
@@ -6,8 +6,8 @@ import { z } from "zod";
|
|
|
6
6
|
//#region src/modules/mcp/tools/operations/schema/bindings/deleteBinding.ts
|
|
7
7
|
var deleteBindingOp = z.object({
|
|
8
8
|
type: z.literal("deleteBinding"),
|
|
9
|
-
pageRef: z.string().describe("
|
|
10
|
-
ref: z.string().describe("
|
|
9
|
+
pageRef: z.string().describe("The page, by name"),
|
|
10
|
+
ref: z.string().describe("The element, by name"),
|
|
11
11
|
category: bindingCategory,
|
|
12
12
|
to: z.string().describe("Target of the binding to remove"),
|
|
13
13
|
id: z.string().optional().describe("Match by id instead of to")
|
|
@@ -18,7 +18,7 @@ export declare const patchBindingOp: z.ZodObject<{
|
|
|
18
18
|
params: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
19
19
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
20
20
|
}, z.core.$strip>>>;
|
|
21
|
-
when: z.ZodOptional<z.ZodType<import('@plitzi/
|
|
21
|
+
when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
|
|
22
22
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
23
23
|
}, z.core.$strip>;
|
|
24
24
|
export type PatchBinding = z.infer<typeof patchBindingOp>;
|
|
@@ -6,8 +6,8 @@ import { z } from "zod";
|
|
|
6
6
|
//#region src/modules/mcp/tools/operations/schema/bindings/patchBinding.ts
|
|
7
7
|
var patchBindingOp = z.object({
|
|
8
8
|
type: z.literal("patchBinding"),
|
|
9
|
-
pageRef: z.string().describe("
|
|
10
|
-
ref: z.string().describe("
|
|
9
|
+
pageRef: z.string().describe("The page, by name"),
|
|
10
|
+
ref: z.string().describe("The element, by name"),
|
|
11
11
|
category: bindingCategory,
|
|
12
12
|
to: z.string().describe("Target of the binding to patch"),
|
|
13
13
|
id: z.string().optional().describe("Match by id instead of to"),
|
|
@@ -19,7 +19,7 @@ export declare const upsertBindingOp: z.ZodObject<{
|
|
|
19
19
|
params: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
20
20
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
21
21
|
}, z.core.$strip>>>;
|
|
22
|
-
when: z.ZodOptional<z.ZodType<import('@plitzi/
|
|
22
|
+
when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
|
|
23
23
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
24
24
|
}, z.core.$strip>;
|
|
25
25
|
}, z.core.$strip>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { generateObjectId } from "../../../../helpers/space.js";
|
|
2
1
|
import { pageUri } from "../../../../helpers/uris.js";
|
|
3
2
|
import { empty } from "../../../../helpers/opResult.js";
|
|
4
3
|
import { bindingCategory, bindingInput } from "../shared.js";
|
|
5
4
|
import { resolveElement } from "../write.js";
|
|
6
5
|
import { z } from "zod";
|
|
6
|
+
import { positionalElementId } from "@plitzi/sdk-schema/helpers/elementId";
|
|
7
7
|
//#region src/modules/mcp/tools/operations/schema/bindings/upsertBinding.ts
|
|
8
8
|
var upsertBindingOp = z.object({
|
|
9
9
|
type: z.literal("upsertBinding"),
|
|
10
|
-
pageRef: z.string().describe("
|
|
11
|
-
ref: z.string().describe("
|
|
10
|
+
pageRef: z.string().describe("The page, by name"),
|
|
11
|
+
ref: z.string().describe("The element, by name"),
|
|
12
12
|
category: bindingCategory,
|
|
13
13
|
binding: bindingInput
|
|
14
14
|
}).describe("Add a data binding to an element, or replace the one already feeding the same target (matched by binding.id when given, else by binding.to). Connects a data source to a prop, style value, or initialState key.");
|
|
@@ -19,7 +19,7 @@ var upsertBinding = (space, env, op) => {
|
|
|
19
19
|
const list = bindings[op.category] ??= [];
|
|
20
20
|
const index = list.findIndex((b) => op.binding.id ? b.id === op.binding.id : b.to === op.binding.to);
|
|
21
21
|
const binding = {
|
|
22
|
-
id: op.binding.id ?? (index >= 0 ? list[index].id :
|
|
22
|
+
id: op.binding.id ?? (index >= 0 ? list[index].id : positionalElementId(op.category, (candidate) => list.some((b) => b.id === candidate))),
|
|
23
23
|
to: op.binding.to,
|
|
24
24
|
source: op.binding.source
|
|
25
25
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { descendantIds,
|
|
1
|
+
import { descendantIds, findRootByRef, indexRemoveElements, resolveRef } from "../../../../helpers/space.js";
|
|
2
2
|
import { pageUri } from "../../../../helpers/uris.js";
|
|
3
3
|
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
4
4
|
import { removeFromParent } from "../write.js";
|
|
@@ -6,12 +6,12 @@ import { z } from "zod";
|
|
|
6
6
|
//#region src/modules/mcp/tools/operations/schema/elements/deleteElement.ts
|
|
7
7
|
var deleteElementOp = z.object({
|
|
8
8
|
type: z.literal("deleteElement"),
|
|
9
|
-
pageRef: z.string().describe("
|
|
10
|
-
ref: z.string().describe("
|
|
9
|
+
pageRef: z.string().describe("The page, by name"),
|
|
10
|
+
ref: z.string().describe("The element to delete, by name")
|
|
11
11
|
}).describe("Delete an element and all of its descendants from a page.");
|
|
12
12
|
var deleteElement = (space, env, op) => {
|
|
13
|
-
const page =
|
|
14
|
-
if (!page) return fail("pageRef", `Page "${op.pageRef}" not found`, "Read the pages resource for valid refs");
|
|
13
|
+
const page = findRootByRef(space.schema, op.pageRef);
|
|
14
|
+
if (!page) return fail("pageRef", `Page or layout "${op.pageRef}" not found`, "Read the pages resource for valid refs");
|
|
15
15
|
const el = resolveRef(space.schema, page, op.ref);
|
|
16
16
|
if (!el || el.id === page.id) return fail("ref", `Element "${op.ref}" not found in page "${op.pageRef}"`, "Read the page resource for valid refs");
|
|
17
17
|
const ids = [...descendantIds(space.schema, el.id), el.id];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findRootByRef, indexInvalidateDetails, resolveRef } from "../../../../helpers/space.js";
|
|
2
2
|
import { pageUri } from "../../../../helpers/uris.js";
|
|
3
3
|
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
4
4
|
import { position } from "../shared.js";
|
|
@@ -7,14 +7,14 @@ import { z } from "zod";
|
|
|
7
7
|
//#region src/modules/mcp/tools/operations/schema/elements/moveElement.ts
|
|
8
8
|
var moveElementOp = z.object({
|
|
9
9
|
type: z.literal("moveElement"),
|
|
10
|
-
pageRef: z.string().describe("
|
|
11
|
-
ref: z.string().describe("
|
|
12
|
-
toParentRef: z.string().describe("
|
|
10
|
+
pageRef: z.string().describe("The page, by name"),
|
|
11
|
+
ref: z.string().describe("The element to move, by name"),
|
|
12
|
+
toParentRef: z.string().describe("The anchor it moves relative to, by name (see position)"),
|
|
13
13
|
position
|
|
14
14
|
}).describe("Move an existing element to a new parent, or reorder it — its placement is set by position.");
|
|
15
15
|
var moveElement = (space, env, op) => {
|
|
16
|
-
const page =
|
|
17
|
-
if (!page) return fail("pageRef", `Page "${op.pageRef}" not found`, "Read the pages resource for valid refs");
|
|
16
|
+
const page = findRootByRef(space.schema, op.pageRef);
|
|
17
|
+
if (!page) return fail("pageRef", `Page or layout "${op.pageRef}" not found`, "Read the pages resource for valid refs");
|
|
18
18
|
const el = resolveRef(space.schema, page, op.ref);
|
|
19
19
|
const anchor = resolveRef(space.schema, page, op.toParentRef);
|
|
20
20
|
if (!el || el.id === page.id) return fail("ref", `Element "${op.ref}" not found`, "Read the page resource for valid refs");
|
|
@@ -5,7 +5,7 @@ export declare const patchElementOp: z.ZodObject<{
|
|
|
5
5
|
type: z.ZodLiteral<"patchElement">;
|
|
6
6
|
pageRef: z.ZodString;
|
|
7
7
|
ref: z.ZodString;
|
|
8
|
-
|
|
8
|
+
rename: z.ZodOptional<z.ZodString>;
|
|
9
9
|
label: z.ZodOptional<z.ZodString>;
|
|
10
10
|
subType: z.ZodOptional<z.ZodString>;
|
|
11
11
|
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findRootByRef, invalidateIndex, resolveRef } from "../../../../helpers/space.js";
|
|
2
2
|
import { pageUri } from "../../../../helpers/uris.js";
|
|
3
3
|
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
4
4
|
import { elementRuntime, initialStateInput, styleRefs } from "../shared.js";
|
|
5
5
|
import { guardNewRef, writeInitialState } from "../write.js";
|
|
6
6
|
import { z } from "zod";
|
|
7
|
-
import {
|
|
7
|
+
import { repointIds } from "@plitzi/sdk-schema/helpers/elementId";
|
|
8
8
|
//#region src/modules/mcp/tools/operations/schema/elements/patchElement.ts
|
|
9
9
|
var patchElementOp = z.object({
|
|
10
10
|
type: z.literal("patchElement"),
|
|
11
|
-
pageRef: z.string().describe("
|
|
12
|
-
ref: z.string().describe("
|
|
13
|
-
|
|
11
|
+
pageRef: z.string().describe("The page, by name"),
|
|
12
|
+
ref: z.string().describe("An existing element, by name"),
|
|
13
|
+
rename: z.string().optional().describe("A new name for this element ([A-Za-z0-9_-], starting with a letter, unique in the space). The name IS the id: the key everything addresses it by, the source name it publishes under, the target an interaction fires on. A rename moves all of that with it — every binding and interaction that named the old one is repointed for you."),
|
|
14
14
|
label: z.string().optional(),
|
|
15
15
|
subType: z.string().optional(),
|
|
16
16
|
props: z.record(z.string(), z.unknown()).optional().describe("Merged onto existing props: listed keys change, null unsets a key, others are preserved"),
|
|
@@ -19,16 +19,15 @@ var patchElementOp = z.object({
|
|
|
19
19
|
runtime: elementRuntime.optional()
|
|
20
20
|
}).describe("Partially update an EXISTING element: only the fields you pass change (props/style/initialState are merged, not replaced). Never creates — fails if ref does not resolve. Use upsertElement to create or fully replace.");
|
|
21
21
|
var patchElement = (space, env, op) => {
|
|
22
|
-
const page =
|
|
23
|
-
if (!page) return fail("pageRef", `Page "${op.pageRef}" not found`, "Read plitzi://schema/" + env + "/pages for valid refs");
|
|
22
|
+
const page = findRootByRef(space.schema, op.pageRef);
|
|
23
|
+
if (!page) return fail("pageRef", `Page or layout "${op.pageRef}" not found`, "Read plitzi://schema/" + env + "/pages for valid refs");
|
|
24
24
|
const el = resolveRef(space.schema, page, op.ref);
|
|
25
25
|
if (!el || el.id === page.id) return fail("ref", `Element "${op.ref}" not found in page "${op.pageRef}"`, "patchElement only updates an existing element; use upsertElement to create one");
|
|
26
|
-
if (op.
|
|
27
|
-
const guard = guardNewRef(space, op.
|
|
26
|
+
if (op.rename !== void 0 && op.rename !== el.id) {
|
|
27
|
+
const guard = guardNewRef(space, op.rename, "rename");
|
|
28
28
|
if (guard) return guard;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (previous) repointIdRefs(space.schema.flat, { [previous]: op.idRef });
|
|
29
|
+
repointIds(space.schema.flat, { [el.id]: op.rename }, space.schema.pages);
|
|
30
|
+
invalidateIndex(space.schema);
|
|
32
31
|
}
|
|
33
32
|
if (op.label !== void 0) el.definition.label = op.label;
|
|
34
33
|
if (op.subType !== void 0) el.attributes = {
|
|
@@ -14,7 +14,7 @@ var templateElement = z.lazy(() => z.object({
|
|
|
14
14
|
}));
|
|
15
15
|
var repeatElementOp = z.object({
|
|
16
16
|
type: z.literal("repeatElement"),
|
|
17
|
-
pageRef: z.string().describe("
|
|
17
|
+
pageRef: z.string().describe("The page, by name"),
|
|
18
18
|
ref: z.string().describe("Ref of the WRAPPER element this creates; the rows become its children"),
|
|
19
19
|
elementType: z.string().optional().describe("Type of the wrapper; defaults to container"),
|
|
20
20
|
label: z.string().optional(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findRootByRef, resolveRef } from "../../../../helpers/space.js";
|
|
2
2
|
import { pageUri } from "../../../../helpers/uris.js";
|
|
3
3
|
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
4
4
|
import { elementInput, position } from "../shared.js";
|
|
@@ -7,14 +7,14 @@ import { z } from "zod";
|
|
|
7
7
|
//#region src/modules/mcp/tools/operations/schema/elements/upsertElement.ts
|
|
8
8
|
var upsertElementOp = z.object({
|
|
9
9
|
type: z.literal("upsertElement"),
|
|
10
|
-
pageRef: z.string().describe("
|
|
10
|
+
pageRef: z.string().describe("The page, by name"),
|
|
11
11
|
element: elementInput,
|
|
12
12
|
parentRef: z.string().optional().describe("Anchor ref/id; defaults to page root"),
|
|
13
13
|
position: position.optional()
|
|
14
14
|
}).describe("Add an element to a page, or fully update it when element.ref already exists (props and style are REPLACED, not merged). To change only some fields of an existing element, use patchElement instead.");
|
|
15
15
|
var upsertElement = (space, env, op) => {
|
|
16
|
-
const page =
|
|
17
|
-
if (!page) return fail("pageRef", `Page "${op.pageRef}" not found`, "Read plitzi://schema/" + env + "/pages for valid refs");
|
|
16
|
+
const page = findRootByRef(space.schema, op.pageRef);
|
|
17
|
+
if (!page) return fail("pageRef", `Page or layout "${op.pageRef}" not found`, "Read plitzi://schema/" + env + "/pages for valid refs");
|
|
18
18
|
const existing = resolveRef(space.schema, page, op.element.ref);
|
|
19
19
|
if (existing && existing.id !== page.id) {
|
|
20
20
|
if (op.element.label !== void 0) existing.definition.label = op.element.label;
|
|
@@ -7,6 +7,8 @@ export * from './elements/patchElement';
|
|
|
7
7
|
export * from './elements/deleteElement';
|
|
8
8
|
export * from './elements/moveElement';
|
|
9
9
|
export * from './pages/upsertPage';
|
|
10
|
+
export * from './pages/upsertLayout';
|
|
11
|
+
export * from './pages/deleteLayout';
|
|
10
12
|
export * from './pages/deletePage';
|
|
11
13
|
export * from './folders/upsertFolder';
|
|
12
14
|
export * from './folders/deleteFolder';
|
|
@@ -5,8 +5,8 @@ import { z } from "zod";
|
|
|
5
5
|
//#region src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.ts
|
|
6
6
|
var deleteInteractionOp = z.object({
|
|
7
7
|
type: z.literal("deleteInteraction"),
|
|
8
|
-
pageRef: z.string().describe("
|
|
9
|
-
ref: z.string().describe("
|
|
8
|
+
pageRef: z.string().describe("The page, by name"),
|
|
9
|
+
ref: z.string().describe("The element, by name"),
|
|
10
10
|
flowId: z.string().optional().describe("Remove the whole flow with this id (the trigger node id)"),
|
|
11
11
|
nodeId: z.string().optional().describe("Remove a single step; its neighbors are re-linked. Deleting a trigger removes its flow")
|
|
12
12
|
}).describe("DESTRUCTIVE, not undoable — remove a flow (by flowId) or a single step (by nodeId); provide exactly one. To turn a step OFF instead, patchInteractionNode { enabled: false }. Confirm with the user first.");
|
|
@@ -10,7 +10,7 @@ export declare const patchInteractionNodeOp: z.ZodObject<{
|
|
|
10
10
|
action: z.ZodOptional<z.ZodString>;
|
|
11
11
|
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
12
12
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
-
when: z.ZodOptional<z.ZodType<import('@plitzi/
|
|
13
|
+
when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
|
|
14
14
|
elementId: z.ZodOptional<z.ZodString>;
|
|
15
15
|
preview: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
16
16
|
}, z.core.$strip>;
|
|
@@ -8,8 +8,8 @@ import { z } from "zod";
|
|
|
8
8
|
var { title, action, params, enabled, when, elementId, preview } = interactionNode.shape;
|
|
9
9
|
var patchInteractionNodeOp = z.object({
|
|
10
10
|
type: z.literal("patchInteractionNode"),
|
|
11
|
-
pageRef: z.string().describe("
|
|
12
|
-
ref: z.string().describe("
|
|
11
|
+
pageRef: z.string().describe("The page, by name"),
|
|
12
|
+
ref: z.string().describe("The element, by name"),
|
|
13
13
|
nodeId: z.string().describe("Id of the interaction node to update"),
|
|
14
14
|
title: title.optional(),
|
|
15
15
|
action: action.optional(),
|
|
@@ -18,7 +18,7 @@ export declare const upsertInteractionFlowOp: z.ZodObject<{
|
|
|
18
18
|
action: z.ZodString;
|
|
19
19
|
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
20
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
-
when: z.ZodOptional<z.ZodType<import('@plitzi/
|
|
21
|
+
when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
|
|
22
22
|
elementId: z.ZodOptional<z.ZodString>;
|
|
23
23
|
preview: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
24
24
|
}, z.core.$strip>>;
|
|
@@ -2,20 +2,20 @@ import { pageUri } from "../../../../helpers/uris.js";
|
|
|
2
2
|
import { materializeFlow } from "../../../../helpers/interactions.js";
|
|
3
3
|
import { empty } from "../../../../helpers/opResult.js";
|
|
4
4
|
import { interactionNode } from "../shared.js";
|
|
5
|
-
import {
|
|
5
|
+
import { resolveElement, resolveTargetRef } from "../write.js";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
//#region src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.ts
|
|
8
8
|
var upsertInteractionFlowOp = z.object({
|
|
9
9
|
type: z.literal("upsertInteractionFlow"),
|
|
10
|
-
pageRef: z.string().describe("
|
|
11
|
-
ref: z.string().describe("
|
|
10
|
+
pageRef: z.string().describe("The page, by name"),
|
|
11
|
+
ref: z.string().describe("The element, by name"),
|
|
12
12
|
flowId: z.string().optional().describe("Existing flow to replace (the trigger node id). Omit to create a new flow"),
|
|
13
13
|
nodes: z.array(interactionNode).min(1).describe("Ordered steps of the flow: the FIRST must be a trigger, the rest run after it in order")
|
|
14
14
|
}).describe("Create or replace one interaction flow on an element from an ordered list of steps — pass them in execution order, the beforeNode/afterNode/flowId links are computed for you. For a globalCallback OMIT elementId: it is registered on a source module, not the host element, and the source and default params are filled in for you. To edit a single step in place use patchInteractionNode.");
|
|
15
15
|
var upsertInteractionFlow = (space, env, op) => {
|
|
16
16
|
const found = resolveElement(space, env, op.pageRef, op.ref);
|
|
17
17
|
if ("error" in found) return found.error;
|
|
18
|
-
const ownerRef =
|
|
18
|
+
const ownerRef = found.el.id;
|
|
19
19
|
const nodes = (op.flowId && !op.nodes[0].id ? [{
|
|
20
20
|
...op.nodes[0],
|
|
21
21
|
id: op.flowId
|
|
@@ -33,7 +33,7 @@ export declare const elementOps: {
|
|
|
33
33
|
type: import('zod').ZodLiteral<"patchElement">;
|
|
34
34
|
pageRef: import('zod').ZodString;
|
|
35
35
|
ref: import('zod').ZodString;
|
|
36
|
-
|
|
36
|
+
rename: import('zod').ZodOptional<import('zod').ZodString>;
|
|
37
37
|
label: import('zod').ZodOptional<import('zod').ZodString>;
|
|
38
38
|
subType: import('zod').ZodOptional<import('zod').ZodString>;
|
|
39
39
|
props: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>>;
|
|
@@ -74,12 +74,35 @@ export declare const elementOps: {
|
|
|
74
74
|
slug: import('zod').ZodOptional<import('zod').ZodString>;
|
|
75
75
|
folder: import('zod').ZodOptional<import('zod').ZodNullable<import('zod').ZodString>>;
|
|
76
76
|
default: import('zod').ZodOptional<import('zod').ZodBoolean>;
|
|
77
|
+
layout: import('zod').ZodOptional<import('zod').ZodNullable<import('zod').ZodString>>;
|
|
78
|
+
layoutContainer: import('zod').ZodOptional<import('zod').ZodNullable<import('zod').ZodString>>;
|
|
77
79
|
enabled: import('zod').ZodOptional<import('zod').ZodBoolean>;
|
|
78
80
|
}, import('zod/v4/core').$strip>;
|
|
79
81
|
deletePage: import('zod').ZodObject<{
|
|
80
82
|
type: import('zod').ZodLiteral<"deletePage">;
|
|
81
83
|
ref: import('zod').ZodString;
|
|
82
84
|
}, import('zod/v4/core').$strip>;
|
|
85
|
+
upsertLayout: import('zod').ZodObject<{
|
|
86
|
+
type: import('zod').ZodLiteral<"upsertLayout">;
|
|
87
|
+
ref: import('zod').ZodString;
|
|
88
|
+
label: import('zod').ZodOptional<import('zod').ZodString>;
|
|
89
|
+
subType: import('zod').ZodOptional<import('zod').ZodEnum<{
|
|
90
|
+
footer: "footer";
|
|
91
|
+
main: "main";
|
|
92
|
+
header: "header";
|
|
93
|
+
div: "div";
|
|
94
|
+
nav: "nav";
|
|
95
|
+
section: "section";
|
|
96
|
+
article: "article";
|
|
97
|
+
aside: "aside";
|
|
98
|
+
address: "address";
|
|
99
|
+
figure: "figure";
|
|
100
|
+
}>>;
|
|
101
|
+
}, import('zod/v4/core').$strip>;
|
|
102
|
+
deleteLayout: import('zod').ZodObject<{
|
|
103
|
+
type: import('zod').ZodLiteral<"deleteLayout">;
|
|
104
|
+
ref: import('zod').ZodString;
|
|
105
|
+
}, import('zod/v4/core').$strip>;
|
|
83
106
|
upsertFolder: import('zod').ZodObject<{
|
|
84
107
|
type: import('zod').ZodLiteral<"upsertFolder">;
|
|
85
108
|
ref: import('zod').ZodString;
|
|
@@ -124,7 +147,7 @@ export declare const elementOps: {
|
|
|
124
147
|
params: import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodString>;
|
|
125
148
|
enabled: import('zod').ZodOptional<import('zod').ZodBoolean>;
|
|
126
149
|
}, import('zod/v4/core').$strip>>>;
|
|
127
|
-
when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/
|
|
150
|
+
when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, import('zod/v4/core').$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
|
|
128
151
|
enabled: import('zod').ZodOptional<import('zod').ZodBoolean>;
|
|
129
152
|
}, import('zod/v4/core').$strip>;
|
|
130
153
|
}, import('zod/v4/core').$strip>;
|
|
@@ -145,7 +168,7 @@ export declare const elementOps: {
|
|
|
145
168
|
params: import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodString>;
|
|
146
169
|
enabled: import('zod').ZodOptional<import('zod').ZodBoolean>;
|
|
147
170
|
}, import('zod/v4/core').$strip>>>;
|
|
148
|
-
when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/
|
|
171
|
+
when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, import('zod/v4/core').$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
|
|
149
172
|
enabled: import('zod').ZodOptional<import('zod').ZodBoolean>;
|
|
150
173
|
}, import('zod/v4/core').$strip>;
|
|
151
174
|
deleteBinding: import('zod').ZodObject<{
|
|
@@ -177,7 +200,7 @@ export declare const elementOps: {
|
|
|
177
200
|
action: import('zod').ZodString;
|
|
178
201
|
params: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>>;
|
|
179
202
|
enabled: import('zod').ZodOptional<import('zod').ZodBoolean>;
|
|
180
|
-
when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/
|
|
203
|
+
when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, import('zod/v4/core').$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
|
|
181
204
|
elementId: import('zod').ZodOptional<import('zod').ZodString>;
|
|
182
205
|
preview: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>>;
|
|
183
206
|
}, import('zod/v4/core').$strip>>;
|
|
@@ -191,7 +214,7 @@ export declare const elementOps: {
|
|
|
191
214
|
action: import('zod').ZodOptional<import('zod').ZodString>;
|
|
192
215
|
params: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>>;
|
|
193
216
|
enabled: import('zod').ZodOptional<import('zod').ZodBoolean>;
|
|
194
|
-
when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/
|
|
217
|
+
when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, import('zod/v4/core').$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
|
|
195
218
|
elementId: import('zod').ZodOptional<import('zod').ZodString>;
|
|
196
219
|
preview: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>>;
|
|
197
220
|
}, import('zod/v4/core').$strip>;
|
|
@@ -11,7 +11,9 @@ import { upsertFolderOp } from "./folders/upsertFolder.js";
|
|
|
11
11
|
import { deleteInteractionOp } from "./interactions/deleteInteraction.js";
|
|
12
12
|
import { patchInteractionNodeOp } from "./interactions/patchInteractionNode.js";
|
|
13
13
|
import { upsertInteractionFlowOp } from "./interactions/upsertInteractionFlow.js";
|
|
14
|
+
import { deleteLayoutOp } from "./pages/deleteLayout.js";
|
|
14
15
|
import { deletePageOp } from "./pages/deletePage.js";
|
|
16
|
+
import { upsertLayoutOp } from "./pages/upsertLayout.js";
|
|
15
17
|
import { upsertPageOp } from "./pages/upsertPage.js";
|
|
16
18
|
import { patchSettingsOp } from "./settings/patchSettings.js";
|
|
17
19
|
import { deleteVariableOp } from "./variables/deleteVariable.js";
|
|
@@ -25,6 +27,8 @@ var elementOps = {
|
|
|
25
27
|
moveElement: moveElementOp,
|
|
26
28
|
upsertPage: upsertPageOp,
|
|
27
29
|
deletePage: deletePageOp,
|
|
30
|
+
upsertLayout: upsertLayoutOp,
|
|
31
|
+
deleteLayout: deleteLayoutOp,
|
|
28
32
|
upsertFolder: upsertFolderOp,
|
|
29
33
|
deleteFolder: deleteFolderOp,
|
|
30
34
|
upsertVariable: upsertVariableOp,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OpResult, Space } from '../../../../helpers';
|
|
3
|
+
import { Env } from '../../../../types';
|
|
4
|
+
export declare const deleteLayoutOp: z.ZodObject<{
|
|
5
|
+
type: z.ZodLiteral<"deleteLayout">;
|
|
6
|
+
ref: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type DeleteLayout = z.infer<typeof deleteLayoutOp>;
|
|
9
|
+
export declare const deleteLayout: (space: Space, env: Env, op: DeleteLayout) => OpResult;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { descendantIds, findLayoutByRef, indexRemoveLayout, pagesUsingLayout } from "../../../../helpers/space.js";
|
|
2
|
+
import { layoutsUri, pageUri } from "../../../../helpers/uris.js";
|
|
3
|
+
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/modules/mcp/tools/operations/schema/pages/deleteLayout.ts
|
|
6
|
+
var deleteLayoutOp = z.object({
|
|
7
|
+
type: z.literal("deleteLayout"),
|
|
8
|
+
ref: z.string().describe("The layout shell, by name")
|
|
9
|
+
}).describe("Delete a layout shell and everything in it. Refused while a page still renders inside it (detach with upsertPage { layout: null }). Destructive: what it holds is on every page that uses it — confirm first.");
|
|
10
|
+
var deleteLayout = (space, env, op) => {
|
|
11
|
+
const layout = findLayoutByRef(space.schema, op.ref);
|
|
12
|
+
if (!layout) return fail("ref", `Layout "${op.ref}" not found`, `Read plitzi://schema/${env}/layouts for valid refs`);
|
|
13
|
+
/**
|
|
14
|
+
* A shell still in use is not deleted, it is REFUSED — and the pages are named.
|
|
15
|
+
*
|
|
16
|
+
* Deleting it anyway leaves every one of them pointing at a shell that is gone: they render their own body with
|
|
17
|
+
* no chrome at all, and nothing in the document says why. Detaching them silently is no better, because that is
|
|
18
|
+
* a decision about pages the caller did not mention.
|
|
19
|
+
*/
|
|
20
|
+
const inUse = pagesUsingLayout(space.schema, layout.id);
|
|
21
|
+
if (inUse.length > 0) return fail("ref", `Layout "${op.ref}" is still used by ${inUse.length} page(s): ${inUse.map((page) => page.id).join(", ")}`, "Detach them first with upsertPage { layout: null }, or point them at another shell");
|
|
22
|
+
const descendantElementIds = descendantIds(space.schema, layout.id);
|
|
23
|
+
const descendants = descendantElementIds.map((id) => space.schema.flat[id]);
|
|
24
|
+
for (const id of [...descendantElementIds, layout.id]) Reflect.deleteProperty(space.schema.flat, id);
|
|
25
|
+
indexRemoveLayout(space.schema, layout, descendants);
|
|
26
|
+
return {
|
|
27
|
+
...empty(),
|
|
28
|
+
deleted: 1,
|
|
29
|
+
staleResources: [pageUri(env, op.ref), layoutsUri(env)]
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { deleteLayout, deleteLayoutOp };
|
|
@@ -5,7 +5,7 @@ import { z } from "zod";
|
|
|
5
5
|
//#region src/modules/mcp/tools/operations/schema/pages/deletePage.ts
|
|
6
6
|
var deletePageOp = z.object({
|
|
7
7
|
type: z.literal("deletePage"),
|
|
8
|
-
ref: z.string().describe("
|
|
8
|
+
ref: z.string().describe("The page, by name")
|
|
9
9
|
}).describe("Delete a page and every element on it.");
|
|
10
10
|
var deletePage = (space, env, op) => {
|
|
11
11
|
const page = findPageByRef(space.schema, op.ref);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OpResult, Space } from '../../../../helpers';
|
|
3
|
+
import { Env } from '../../../../types';
|
|
4
|
+
export declare const upsertLayoutOp: z.ZodObject<{
|
|
5
|
+
type: z.ZodLiteral<"upsertLayout">;
|
|
6
|
+
ref: z.ZodString;
|
|
7
|
+
label: z.ZodOptional<z.ZodString>;
|
|
8
|
+
subType: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
footer: "footer";
|
|
10
|
+
main: "main";
|
|
11
|
+
header: "header";
|
|
12
|
+
div: "div";
|
|
13
|
+
nav: "nav";
|
|
14
|
+
section: "section";
|
|
15
|
+
article: "article";
|
|
16
|
+
aside: "aside";
|
|
17
|
+
address: "address";
|
|
18
|
+
figure: "figure";
|
|
19
|
+
}>>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export type UpsertLayout = z.infer<typeof upsertLayoutOp>;
|
|
22
|
+
export declare const upsertLayout: (space: Space, env: Env, op: UpsertLayout) => OpResult;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { findLayoutByRef, indexAddLayout } from "../../../../helpers/space.js";
|
|
2
|
+
import { layoutsUri, pageUri } from "../../../../helpers/uris.js";
|
|
3
|
+
import { empty } from "../../../../helpers/opResult.js";
|
|
4
|
+
import { guardNewRef } from "../write.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region src/modules/mcp/tools/operations/schema/pages/upsertLayout.ts
|
|
7
|
+
var upsertLayoutOp = z.object({
|
|
8
|
+
type: z.literal("upsertLayout"),
|
|
9
|
+
ref: z.string().describe("Layout id to update, or a new id to create one. Pages reference it by this name."),
|
|
10
|
+
label: z.string().optional(),
|
|
11
|
+
subType: z.enum([
|
|
12
|
+
"div",
|
|
13
|
+
"header",
|
|
14
|
+
"footer",
|
|
15
|
+
"nav",
|
|
16
|
+
"main",
|
|
17
|
+
"section",
|
|
18
|
+
"article",
|
|
19
|
+
"aside",
|
|
20
|
+
"address",
|
|
21
|
+
"figure"
|
|
22
|
+
]).optional()
|
|
23
|
+
}).describe("Create/update a shared layout shell: the chrome (header, sidebar, footer) several pages render INSIDE. It is a root like a page — fill it with upsertElement using pageRef: \"<this ref>\", then attach pages with upsertPage { layout, layoutContainer }. See \"Shared layouts\" in plitzi://guide.");
|
|
24
|
+
var upsertLayout = (space, env, op) => {
|
|
25
|
+
const existing = findLayoutByRef(space.schema, op.ref);
|
|
26
|
+
if (existing) {
|
|
27
|
+
if (op.label !== void 0) existing.definition.label = op.label;
|
|
28
|
+
if (op.subType !== void 0) existing.attributes = {
|
|
29
|
+
...existing.attributes,
|
|
30
|
+
subType: op.subType
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
...empty(),
|
|
34
|
+
updated: 1,
|
|
35
|
+
staleResources: [pageUri(env, op.ref), layoutsUri(env)]
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const guard = guardNewRef(space, op.ref, "ref");
|
|
39
|
+
if (guard) return guard;
|
|
40
|
+
const id = op.ref;
|
|
41
|
+
const layout = {
|
|
42
|
+
id,
|
|
43
|
+
attributes: { subType: op.subType ?? "div" },
|
|
44
|
+
definition: {
|
|
45
|
+
rootId: id,
|
|
46
|
+
label: op.label ?? op.ref,
|
|
47
|
+
type: "layoutContainer",
|
|
48
|
+
items: [],
|
|
49
|
+
styleSelectors: { base: "" }
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
space.schema.flat[id] = layout;
|
|
53
|
+
indexAddLayout(space.schema, layout);
|
|
54
|
+
return {
|
|
55
|
+
...empty(),
|
|
56
|
+
created: 1,
|
|
57
|
+
staleResources: [pageUri(env, op.ref), layoutsUri(env)]
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
export { upsertLayout, upsertLayoutOp };
|
|
@@ -8,6 +8,8 @@ export declare const upsertPageOp: z.ZodObject<{
|
|
|
8
8
|
slug: z.ZodOptional<z.ZodString>;
|
|
9
9
|
folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
10
10
|
default: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
layout: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
12
|
+
layoutContainer: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
11
13
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
12
14
|
}, z.core.$strip>;
|
|
13
15
|
export type UpsertPage = z.infer<typeof upsertPageOp>;
|