@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
|
@@ -33,7 +33,7 @@ export declare const screenshotShape: {
|
|
|
33
33
|
type: z.ZodLiteral<"patchElement">;
|
|
34
34
|
pageRef: z.ZodString;
|
|
35
35
|
ref: z.ZodString;
|
|
36
|
-
|
|
36
|
+
rename: z.ZodOptional<z.ZodString>;
|
|
37
37
|
label: z.ZodOptional<z.ZodString>;
|
|
38
38
|
subType: z.ZodOptional<z.ZodString>;
|
|
39
39
|
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -71,10 +71,31 @@ export declare const screenshotShape: {
|
|
|
71
71
|
slug: z.ZodOptional<z.ZodString>;
|
|
72
72
|
folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
73
73
|
default: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
+
layout: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
75
|
+
layoutContainer: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
74
76
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
75
77
|
}, z.core.$strip>, z.ZodObject<{
|
|
76
78
|
type: z.ZodLiteral<"deletePage">;
|
|
77
79
|
ref: z.ZodString;
|
|
80
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
81
|
+
type: z.ZodLiteral<"upsertLayout">;
|
|
82
|
+
ref: z.ZodString;
|
|
83
|
+
label: z.ZodOptional<z.ZodString>;
|
|
84
|
+
subType: z.ZodOptional<z.ZodEnum<{
|
|
85
|
+
footer: "footer";
|
|
86
|
+
main: "main";
|
|
87
|
+
header: "header";
|
|
88
|
+
div: "div";
|
|
89
|
+
nav: "nav";
|
|
90
|
+
section: "section";
|
|
91
|
+
article: "article";
|
|
92
|
+
aside: "aside";
|
|
93
|
+
address: "address";
|
|
94
|
+
figure: "figure";
|
|
95
|
+
}>>;
|
|
96
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
97
|
+
type: z.ZodLiteral<"deleteLayout">;
|
|
98
|
+
ref: z.ZodString;
|
|
78
99
|
}, z.core.$strip>, z.ZodObject<{
|
|
79
100
|
type: z.ZodLiteral<"upsertFolder">;
|
|
80
101
|
ref: z.ZodString;
|
|
@@ -115,7 +136,7 @@ export declare const screenshotShape: {
|
|
|
115
136
|
params: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
116
137
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
117
138
|
}, z.core.$strip>>>;
|
|
118
|
-
when: z.ZodOptional<z.ZodType<import('@plitzi/
|
|
139
|
+
when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
|
|
119
140
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
120
141
|
}, z.core.$strip>;
|
|
121
142
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -135,7 +156,7 @@ export declare const screenshotShape: {
|
|
|
135
156
|
params: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
136
157
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
137
158
|
}, z.core.$strip>>>;
|
|
138
|
-
when: z.ZodOptional<z.ZodType<import('@plitzi/
|
|
159
|
+
when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
|
|
139
160
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
140
161
|
}, z.core.$strip>, z.ZodObject<{
|
|
141
162
|
type: z.ZodLiteral<"deleteBinding">;
|
|
@@ -165,7 +186,7 @@ export declare const screenshotShape: {
|
|
|
165
186
|
action: z.ZodString;
|
|
166
187
|
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
167
188
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
168
|
-
when: z.ZodOptional<z.ZodType<import('@plitzi/
|
|
189
|
+
when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
|
|
169
190
|
elementId: z.ZodOptional<z.ZodString>;
|
|
170
191
|
preview: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
171
192
|
}, z.core.$strip>>;
|
|
@@ -178,7 +199,7 @@ export declare const screenshotShape: {
|
|
|
178
199
|
action: z.ZodOptional<z.ZodString>;
|
|
179
200
|
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
180
201
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
181
|
-
when: z.ZodOptional<z.ZodType<import('@plitzi/
|
|
202
|
+
when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
|
|
182
203
|
elementId: z.ZodOptional<z.ZodString>;
|
|
183
204
|
preview: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
184
205
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -467,6 +488,38 @@ export declare const screenshotShape: {
|
|
|
467
488
|
custom: "custom";
|
|
468
489
|
}>;
|
|
469
490
|
name: z.ZodString;
|
|
491
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
492
|
+
type: z.ZodLiteral<"upsertFont">;
|
|
493
|
+
family: z.ZodString;
|
|
494
|
+
source: z.ZodEnum<{
|
|
495
|
+
system: "system";
|
|
496
|
+
hosted: "hosted";
|
|
497
|
+
google: "google";
|
|
498
|
+
remote: "remote";
|
|
499
|
+
}>;
|
|
500
|
+
fallback: z.ZodString;
|
|
501
|
+
weights: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
502
|
+
styles: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
503
|
+
normal: "normal";
|
|
504
|
+
italic: "italic";
|
|
505
|
+
}>>>;
|
|
506
|
+
stylesheet: z.ZodOptional<z.ZodString>;
|
|
507
|
+
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
508
|
+
weight: z.ZodNumber;
|
|
509
|
+
style: z.ZodEnum<{
|
|
510
|
+
normal: "normal";
|
|
511
|
+
italic: "italic";
|
|
512
|
+
}>;
|
|
513
|
+
format: z.ZodEnum<{
|
|
514
|
+
woff2: "woff2";
|
|
515
|
+
woff: "woff";
|
|
516
|
+
}>;
|
|
517
|
+
url: z.ZodOptional<z.ZodString>;
|
|
518
|
+
path: z.ZodOptional<z.ZodString>;
|
|
519
|
+
}, z.core.$strip>>>;
|
|
520
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
521
|
+
type: z.ZodLiteral<"deleteFont">;
|
|
522
|
+
family: z.ZodString;
|
|
470
523
|
}, z.core.$strip>, z.ZodObject<{
|
|
471
524
|
type: z.ZodLiteral<"upsertConnector">;
|
|
472
525
|
ref: z.ZodString;
|
|
@@ -485,8 +538,8 @@ export declare const screenshotShape: {
|
|
|
485
538
|
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
486
539
|
pagination: z.ZodOptional<z.ZodEnum<{
|
|
487
540
|
page: "page";
|
|
488
|
-
cursor: "cursor";
|
|
489
541
|
offset: "offset";
|
|
542
|
+
cursor: "cursor";
|
|
490
543
|
}>>;
|
|
491
544
|
operators: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
492
545
|
mediaBaseUrl: z.ZodOptional<z.ZodString>;
|
|
@@ -495,14 +548,14 @@ export declare const screenshotShape: {
|
|
|
495
548
|
file: "file";
|
|
496
549
|
text: "text";
|
|
497
550
|
color: "color";
|
|
498
|
-
link: "link";
|
|
499
|
-
image: "image";
|
|
500
|
-
video: "video";
|
|
501
551
|
switch: "switch";
|
|
502
552
|
email: "email";
|
|
503
553
|
date: "date";
|
|
504
554
|
richText: "richText";
|
|
555
|
+
image: "image";
|
|
505
556
|
multiImage: "multiImage";
|
|
557
|
+
video: "video";
|
|
558
|
+
link: "link";
|
|
506
559
|
phone: "phone";
|
|
507
560
|
option: "option";
|
|
508
561
|
}>>>;
|
|
@@ -529,8 +582,8 @@ export declare const screenshotShape: {
|
|
|
529
582
|
body: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
530
583
|
pagination: z.ZodOptional<z.ZodEnum<{
|
|
531
584
|
page: "page";
|
|
532
|
-
cursor: "cursor";
|
|
533
585
|
offset: "offset";
|
|
586
|
+
cursor: "cursor";
|
|
534
587
|
}>>;
|
|
535
588
|
}, z.core.$strip>>;
|
|
536
589
|
write: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -573,8 +626,8 @@ export declare const screenshotShape: {
|
|
|
573
626
|
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
574
627
|
pagination: z.ZodOptional<z.ZodEnum<{
|
|
575
628
|
page: "page";
|
|
576
|
-
cursor: "cursor";
|
|
577
629
|
offset: "offset";
|
|
630
|
+
cursor: "cursor";
|
|
578
631
|
}>>;
|
|
579
632
|
operators: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
580
633
|
mediaBaseUrl: z.ZodOptional<z.ZodString>;
|
|
@@ -583,14 +636,14 @@ export declare const screenshotShape: {
|
|
|
583
636
|
file: "file";
|
|
584
637
|
text: "text";
|
|
585
638
|
color: "color";
|
|
586
|
-
link: "link";
|
|
587
|
-
image: "image";
|
|
588
|
-
video: "video";
|
|
589
639
|
switch: "switch";
|
|
590
640
|
email: "email";
|
|
591
641
|
date: "date";
|
|
592
642
|
richText: "richText";
|
|
643
|
+
image: "image";
|
|
593
644
|
multiImage: "multiImage";
|
|
645
|
+
video: "video";
|
|
646
|
+
link: "link";
|
|
594
647
|
phone: "phone";
|
|
595
648
|
option: "option";
|
|
596
649
|
}>>>;
|
|
@@ -617,8 +670,8 @@ export declare const screenshotShape: {
|
|
|
617
670
|
body: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
618
671
|
pagination: z.ZodOptional<z.ZodEnum<{
|
|
619
672
|
page: "page";
|
|
620
|
-
cursor: "cursor";
|
|
621
673
|
offset: "offset";
|
|
674
|
+
cursor: "cursor";
|
|
622
675
|
}>>;
|
|
623
676
|
}, z.core.$strip>>>>;
|
|
624
677
|
write: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodObject<{
|
|
@@ -646,11 +699,93 @@ export declare const screenshotShape: {
|
|
|
646
699
|
}, z.core.$strip>, z.ZodObject<{
|
|
647
700
|
type: z.ZodLiteral<"deleteConnector">;
|
|
648
701
|
ref: z.ZodString;
|
|
702
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
703
|
+
type: z.ZodLiteral<"upsertAction">;
|
|
704
|
+
ref: z.ZodString;
|
|
705
|
+
name: z.ZodString;
|
|
706
|
+
description: z.ZodOptional<z.ZodString>;
|
|
707
|
+
output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
708
|
+
type: z.ZodEnum<{
|
|
709
|
+
number: "number";
|
|
710
|
+
boolean: "boolean";
|
|
711
|
+
file: "file";
|
|
712
|
+
json: "json";
|
|
713
|
+
text: "text";
|
|
714
|
+
date: "date";
|
|
715
|
+
}>;
|
|
716
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
717
|
+
defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
718
|
+
label: z.ZodOptional<z.ZodString>;
|
|
719
|
+
}, z.core.$strip>>>;
|
|
720
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
721
|
+
id: z.ZodString;
|
|
722
|
+
title: z.ZodString;
|
|
723
|
+
type: z.ZodEnum<{
|
|
724
|
+
trigger: "trigger";
|
|
725
|
+
task: "task";
|
|
726
|
+
}>;
|
|
727
|
+
action: z.ZodString;
|
|
728
|
+
params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
729
|
+
afterNode: z.ZodDefault<z.ZodString>;
|
|
730
|
+
beforeNode: z.ZodDefault<z.ZodString>;
|
|
731
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
732
|
+
when: z.ZodOptional<z.ZodUnknown>;
|
|
733
|
+
remove: z.ZodOptional<z.ZodBoolean>;
|
|
734
|
+
}, z.core.$strip>>;
|
|
735
|
+
limits: z.ZodOptional<z.ZodObject<{
|
|
736
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
737
|
+
streamTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
738
|
+
maxNodes: z.ZodOptional<z.ZodNumber>;
|
|
739
|
+
maxRequests: z.ZodOptional<z.ZodNumber>;
|
|
740
|
+
}, z.core.$strip>>;
|
|
741
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
742
|
+
type: z.ZodLiteral<"patchAction">;
|
|
743
|
+
ref: z.ZodString;
|
|
744
|
+
name: z.ZodOptional<z.ZodString>;
|
|
745
|
+
description: z.ZodOptional<z.ZodString>;
|
|
746
|
+
output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodObject<{
|
|
747
|
+
type: z.ZodEnum<{
|
|
748
|
+
number: "number";
|
|
749
|
+
boolean: "boolean";
|
|
750
|
+
file: "file";
|
|
751
|
+
json: "json";
|
|
752
|
+
text: "text";
|
|
753
|
+
date: "date";
|
|
754
|
+
}>;
|
|
755
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
756
|
+
defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
757
|
+
label: z.ZodOptional<z.ZodString>;
|
|
758
|
+
}, z.core.$strip>>>>;
|
|
759
|
+
nodes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
760
|
+
id: z.ZodString;
|
|
761
|
+
title: z.ZodString;
|
|
762
|
+
type: z.ZodEnum<{
|
|
763
|
+
trigger: "trigger";
|
|
764
|
+
task: "task";
|
|
765
|
+
}>;
|
|
766
|
+
action: z.ZodString;
|
|
767
|
+
params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
768
|
+
afterNode: z.ZodDefault<z.ZodString>;
|
|
769
|
+
beforeNode: z.ZodDefault<z.ZodString>;
|
|
770
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
771
|
+
when: z.ZodOptional<z.ZodUnknown>;
|
|
772
|
+
remove: z.ZodOptional<z.ZodBoolean>;
|
|
773
|
+
}, z.core.$strip>>>;
|
|
774
|
+
limits: z.ZodOptional<z.ZodObject<{
|
|
775
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
776
|
+
streamTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
777
|
+
maxNodes: z.ZodOptional<z.ZodNumber>;
|
|
778
|
+
maxRequests: z.ZodOptional<z.ZodNumber>;
|
|
779
|
+
}, z.core.$strip>>;
|
|
780
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
781
|
+
type: z.ZodLiteral<"deleteAction">;
|
|
782
|
+
ref: z.ZodString;
|
|
649
783
|
}, z.core.$strip>], "type">>>;
|
|
650
784
|
viewport: z.ZodOptional<z.ZodEnum<{
|
|
651
|
-
both: "both";
|
|
652
785
|
desktop: "desktop";
|
|
653
786
|
mobile: "mobile";
|
|
787
|
+
both: "both";
|
|
654
788
|
}>>;
|
|
789
|
+
fullPage: z.ZodOptional<z.ZodBoolean>;
|
|
655
790
|
};
|
|
656
791
|
export declare const screenshotTool: import('.').ToolDef;
|
|
@@ -20,13 +20,14 @@ var resolveViewports = (choice) => {
|
|
|
20
20
|
return [VIEWPORTS.desktop];
|
|
21
21
|
};
|
|
22
22
|
var screenshotShape = {
|
|
23
|
-
pageRef: z.string().optional().describe("
|
|
23
|
+
pageRef: z.string().optional().describe("The page to capture, by name; defaults to the space default page"),
|
|
24
24
|
operations: z.array(operation).max(100).optional().describe("Unsaved edits to apply before rendering, so you can screenshot a proposed change WITHOUT persisting it (same op vocabulary as plitzi_apply). Omit to capture the current saved state."),
|
|
25
25
|
viewport: z.enum([
|
|
26
26
|
"desktop",
|
|
27
27
|
"mobile",
|
|
28
28
|
"both"
|
|
29
|
-
]).optional().describe("Which viewport(s) to capture. \"both\" catches responsive issues (e.g. overflow at one width). Default desktop.")
|
|
29
|
+
]).optional().describe("Which viewport(s) to capture. \"both\" catches responsive issues (e.g. overflow at one width). Default desktop."),
|
|
30
|
+
fullPage: z.boolean().optional().describe("Capture the full scrollable page instead of only the visible viewport. Default false.")
|
|
30
31
|
};
|
|
31
32
|
var screenshotTool = defineTool({
|
|
32
33
|
name: "plitzi_screenshot",
|
|
@@ -41,11 +42,15 @@ var screenshotTool = defineTool({
|
|
|
41
42
|
message: "Visual preview is not enabled on this server.",
|
|
42
43
|
hint: "Preview needs the SSR render service; it is unavailable in MCP-only mode."
|
|
43
44
|
};
|
|
44
|
-
const
|
|
45
|
+
const draft = {
|
|
45
46
|
spaceId: ctx.spaceId,
|
|
46
47
|
env: ctx.env,
|
|
47
48
|
pageRef: input.pageRef,
|
|
48
49
|
operations: input.operations
|
|
50
|
+
};
|
|
51
|
+
const pv = await ctx.preview.render({
|
|
52
|
+
...draft,
|
|
53
|
+
includeHtml: !ctx.screenshot
|
|
49
54
|
});
|
|
50
55
|
if (!pv.ok) return pv;
|
|
51
56
|
const viewports = resolveViewports(input.viewport);
|
|
@@ -60,17 +65,21 @@ var screenshotTool = defineTool({
|
|
|
60
65
|
const shot = await ctx.screenshot.capture({
|
|
61
66
|
pagePath: pv.pagePath,
|
|
62
67
|
token: pv.token,
|
|
63
|
-
viewports
|
|
68
|
+
viewports,
|
|
69
|
+
fullPage: input.fullPage
|
|
64
70
|
});
|
|
65
|
-
if (!shot.ok)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
if (!shot.ok) {
|
|
72
|
+
const fallback = await ctx.preview.render(draft);
|
|
73
|
+
return {
|
|
74
|
+
warning: "SCREENSHOT_UNAVAILABLE",
|
|
75
|
+
message: `The screenshot service failed (${shot.message}); returning the HTML preview instead.`,
|
|
76
|
+
hint: "The dedicated browser service is down or unreachable. Inspect the HTML, or retry later.",
|
|
77
|
+
pageRef: input.pageRef ?? "default",
|
|
78
|
+
pagePath: pv.pagePath,
|
|
79
|
+
stateVersion: pv.stateVersion,
|
|
80
|
+
html: fallback.ok ? fallback.html : ""
|
|
81
|
+
};
|
|
82
|
+
}
|
|
74
83
|
return imageResult(shot.images, {
|
|
75
84
|
pageRef: input.pageRef ?? "default",
|
|
76
85
|
pagePath: pv.pagePath,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computeVersion } from "../helpers/computeVersion.js";
|
|
2
|
-
import {
|
|
2
|
+
import { getPageElements, isPageElement, nameOf, pageRefOfElement } from "../helpers/space.js";
|
|
3
3
|
import { elementUri, pageUri } from "../helpers/uris.js";
|
|
4
4
|
import { definitionRefs, definitionToAI } from "./operations/style/translator.js";
|
|
5
5
|
import { elementView, pageSkeletonToAI } from "./operations/schema/translator.js";
|
|
@@ -43,7 +43,7 @@ var search = (input, space, env) => {
|
|
|
43
43
|
matched.push({
|
|
44
44
|
el,
|
|
45
45
|
pageRef,
|
|
46
|
-
ref:
|
|
46
|
+
ref: el.id,
|
|
47
47
|
matches
|
|
48
48
|
});
|
|
49
49
|
}
|
|
@@ -83,7 +83,7 @@ var search = (input, space, env) => {
|
|
|
83
83
|
if (label.toLowerCase().includes(query)) matches.push(`label: ${label}`);
|
|
84
84
|
if (slug && slug.toLowerCase().includes(query)) matches.push(`slug: ${slug}`);
|
|
85
85
|
if (matches.length === 0) continue;
|
|
86
|
-
const ref =
|
|
86
|
+
const ref = page.id;
|
|
87
87
|
pages.push({
|
|
88
88
|
ref,
|
|
89
89
|
uri: pageUri(env, ref),
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Space } from '../../helpers';
|
|
2
|
+
export interface InteractionReport {
|
|
3
|
+
/** One line per flow: `<host> <trigger> → <step>, <step>`. Omitted when the widget has no flows. */
|
|
4
|
+
flows?: string[];
|
|
5
|
+
warnings: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare const interactionReport: (space: Space) => InteractionReport;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { flowsFromInteractions } from "../../helpers/interactions.js";
|
|
2
|
+
//#region src/modules/mcp/tools/shared/interactionReport.ts
|
|
3
|
+
var TRIGGER = "trigger";
|
|
4
|
+
var stepLabel = (step) => {
|
|
5
|
+
if (step.nodeType !== "callback") return step.action;
|
|
6
|
+
const key = step.params?.key;
|
|
7
|
+
const target = step.elementId ? ` ${step.elementId}` : "";
|
|
8
|
+
return `${step.action}${target}${typeof key === "string" ? `[${key}]` : ""}`;
|
|
9
|
+
};
|
|
10
|
+
var flowLines = (element) => flowsFromInteractions(element.definition.interactions).map((flow) => {
|
|
11
|
+
const [head, ...rest] = flow.nodes;
|
|
12
|
+
const trigger = head.nodeType === TRIGGER ? head.action : "no trigger";
|
|
13
|
+
const steps = (head.nodeType === TRIGGER ? rest : flow.nodes).filter((node) => node.enabled !== false).map(stepLabel);
|
|
14
|
+
return `${element.id} ${trigger} → ${steps.length > 0 ? steps.join(", ") : "nothing (flow has no steps)"}`;
|
|
15
|
+
});
|
|
16
|
+
var triggerActions = (element) => new Set(Object.values(element.definition.interactions ?? {}).filter((node) => node.type === TRIGGER).map((node) => node.action));
|
|
17
|
+
/** Two elements on the same ancestry line listening for the same event both run: the browser bubbles the event up
|
|
18
|
+
* and Plitzi flows do not stop it. It is the one interaction bug that looks like a working widget (the inner flow
|
|
19
|
+
* runs, and so does the outer), so the pair is named rather than left to be discovered by clicking. */
|
|
20
|
+
var nestingWarnings = (space) => {
|
|
21
|
+
const flat = space.schema.flat;
|
|
22
|
+
const parentOf = (element) => {
|
|
23
|
+
const parentId = element.definition.parentId;
|
|
24
|
+
return parentId === void 0 ? void 0 : flat[parentId];
|
|
25
|
+
};
|
|
26
|
+
const warnings = [];
|
|
27
|
+
for (const element of Object.values(flat)) {
|
|
28
|
+
const own = triggerActions(element);
|
|
29
|
+
if (own.size === 0) continue;
|
|
30
|
+
const seen = /* @__PURE__ */ new Set([element.id]);
|
|
31
|
+
let parent = parentOf(element);
|
|
32
|
+
while (parent && !seen.has(parent.id)) {
|
|
33
|
+
seen.add(parent.id);
|
|
34
|
+
for (const action of triggerActions(parent)) if (own.has(action)) warnings.push(`"${element.id}" and its ancestor "${parent.id}" both listen for ${action} — the event bubbles, so a ${action} on "${element.id}" runs BOTH flows. Move the trigger to one of them, or gate the outer flow with a \`when\` guard.`);
|
|
35
|
+
parent = parentOf(parent);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return warnings;
|
|
39
|
+
};
|
|
40
|
+
var interactionReport = (space) => {
|
|
41
|
+
const flows = Object.values(space.schema.flat).flatMap(flowLines);
|
|
42
|
+
return {
|
|
43
|
+
...flows.length > 0 ? { flows } : {},
|
|
44
|
+
warnings: nestingWarnings(space)
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { interactionReport };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findElementByRef } from "../../../helpers/space.js";
|
|
2
2
|
import { definitionToAI, globalStyleToAI, idStyleToAI } from "../../operations/style/translator.js";
|
|
3
3
|
import { checkBindingSourceScope, checkBindingTarget, checkBindingTransformers } from "./bindings.js";
|
|
4
4
|
import { checkSlotCss } from "./css.js";
|
|
@@ -37,7 +37,7 @@ var toNode = (id, node) => ({
|
|
|
37
37
|
preview: node.preview
|
|
38
38
|
});
|
|
39
39
|
var auditElement = (space, sub, el) => {
|
|
40
|
-
const hostRef =
|
|
40
|
+
const hostRef = el.id;
|
|
41
41
|
const base = `element "${hostRef}"`;
|
|
42
42
|
for (const [category, list] of Object.entries(el.definition.bindings ?? {})) for (const binding of list) {
|
|
43
43
|
const path = `${base}.bindings.${category}[to=${binding.to}]`;
|
|
@@ -49,7 +49,7 @@ var auditElement = (space, sub, el) => {
|
|
|
49
49
|
checkVariantApplication(el.definition.initialState, `${base}.initialState`, sub);
|
|
50
50
|
};
|
|
51
51
|
var auditDefinitionCss = (sub, label, def) => {
|
|
52
|
-
const { ref
|
|
52
|
+
const { ref, slots, ...slot } = def;
|
|
53
53
|
checkSlotCss(slot, label, sub);
|
|
54
54
|
for (const [name, slotDef] of Object.entries(slots ?? {})) checkSlotCss(slotDef, `${label}.slots.${name}`, sub);
|
|
55
55
|
};
|
|
@@ -103,7 +103,7 @@ var auditResources = (space, ops) => {
|
|
|
103
103
|
const el = findElementByRef(space.schema, ref);
|
|
104
104
|
if (!el || seenElements.has(el.id)) continue;
|
|
105
105
|
seenElements.add(el.id);
|
|
106
|
-
harvest(ctx, result, `element "${
|
|
106
|
+
harvest(ctx, result, `element "${el.id}"`, (sub) => auditElement(space, sub, el));
|
|
107
107
|
}
|
|
108
108
|
for (const ref of touched.definitions) {
|
|
109
109
|
const def = definitionToAI(space.style, ref);
|
|
@@ -3,3 +3,4 @@ export declare const batchDeclaredVars: (ops: Operation[]) => string[];
|
|
|
3
3
|
export declare const batchDeclaredPages: (ops: Operation[]) => Set<string>;
|
|
4
4
|
export declare const batchDeclaredFolders: (ops: Operation[]) => Set<string>;
|
|
5
5
|
export declare const batchDeclaredVariants: (ops: Operation[]) => Map<string, Set<string>>;
|
|
6
|
+
export declare const batchDeclaredElements: (ops: Operation[]) => Set<string>;
|
|
@@ -8,7 +8,7 @@ var batchDeclaredVars = (ops) => {
|
|
|
8
8
|
};
|
|
9
9
|
var batchDeclaredPages = (ops) => {
|
|
10
10
|
const refs = /* @__PURE__ */ new Set();
|
|
11
|
-
for (const op of ops) if (op.type === "upsertPage") refs.add(op.ref);
|
|
11
|
+
for (const op of ops) if (op.type === "upsertPage" || op.type === "upsertLayout") refs.add(op.ref);
|
|
12
12
|
return refs;
|
|
13
13
|
};
|
|
14
14
|
var batchDeclaredFolders = (ops) => {
|
|
@@ -35,5 +35,14 @@ var batchDeclaredVariants = (ops) => {
|
|
|
35
35
|
}
|
|
36
36
|
return map;
|
|
37
37
|
};
|
|
38
|
+
var batchDeclaredElements = (ops) => {
|
|
39
|
+
const refs = /* @__PURE__ */ new Set();
|
|
40
|
+
const walk = (input) => {
|
|
41
|
+
refs.add(input.ref);
|
|
42
|
+
for (const child of input.children ?? []) walk(child);
|
|
43
|
+
};
|
|
44
|
+
for (const op of ops) if (op.type === "upsertElement") walk(op.element);
|
|
45
|
+
return refs;
|
|
46
|
+
};
|
|
38
47
|
//#endregion
|
|
39
|
-
export { batchDeclaredFolders, batchDeclaredPages, batchDeclaredVariants, batchDeclaredVars };
|
|
48
|
+
export { batchDeclaredElements, batchDeclaredFolders, batchDeclaredPages, batchDeclaredVariants, batchDeclaredVars };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getTransformer, suggestTransformer } from "../../../catalogs/
|
|
2
|
-
import { descendantIds,
|
|
1
|
+
import { getTransformer, suggestTransformer } from "../../../catalogs/index.js";
|
|
2
|
+
import { descendantIds, findElementByRef } from "../../../helpers/space.js";
|
|
3
3
|
import { warnOnce } from "./context.js";
|
|
4
4
|
import getSourceName from "@plitzi/sdk-shared/dataSource/helpers/getSourceName";
|
|
5
5
|
//#region src/modules/mcp/tools/shared/validator/bindings.ts
|
|
@@ -7,11 +7,11 @@ var providerOfSource = (space, source) => {
|
|
|
7
7
|
const head = source.split(".")[0];
|
|
8
8
|
const sep = head.indexOf("_");
|
|
9
9
|
if (sep < 0) return;
|
|
10
|
-
const
|
|
11
|
-
const el = findElementByRef(space.schema,
|
|
12
|
-
if (!el || getSourceName(el.definition.type, el) !== head) return;
|
|
10
|
+
const elementId = head.slice(sep + 1);
|
|
11
|
+
const el = findElementByRef(space.schema, elementId);
|
|
12
|
+
if (!el || getSourceName(el.definition.type, el.id) !== head) return;
|
|
13
13
|
return {
|
|
14
|
-
ref:
|
|
14
|
+
ref: el.id,
|
|
15
15
|
id: el.id
|
|
16
16
|
};
|
|
17
17
|
};
|
|
@@ -27,7 +27,7 @@ var checkConnectorOp = (space, op, base, ctx) => {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
if (op.type !== "deleteConnector") return;
|
|
30
|
-
const inUse = Object.values(space.schema.flat).filter((el) => el.attributes.connector === op.ref).map((el) => el.
|
|
30
|
+
const inUse = Object.values(space.schema.flat).filter((el) => el.attributes.connector === op.ref).map((el) => el.id);
|
|
31
31
|
if (inUse.length > 0) warnOnce(ctx, `Connector "${op.ref}" still feeds ${inUse.length} element(s) (${inUse.join(", ")}). Deleting it leaves them resolving to no data. Confirm with the user, and repoint or remove those elements too.`);
|
|
32
32
|
};
|
|
33
33
|
var asString = (value) => typeof value === "string" && value ? value : void 0;
|
|
@@ -25,6 +25,9 @@ export interface ValidationCtx {
|
|
|
25
25
|
typeProps: Map<string, Set<string>>;
|
|
26
26
|
typeMeta: Map<string, TypeMeta>;
|
|
27
27
|
elementType: (ref: string) => string | undefined;
|
|
28
|
+
/** Whether a ref names a real element/page — in the space OR created by this same batch. A step that
|
|
29
|
+
* targets anything else resolves to nothing at runtime and silently does nothing. */
|
|
30
|
+
elementExists: (ref: string) => boolean;
|
|
28
31
|
schemaVars: Set<string>;
|
|
29
32
|
styleVars: Set<string>;
|
|
30
33
|
style: Style;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { expandShorthand, isCssProperty, suggestCssProperty } from "../../../catalogs/
|
|
1
|
+
import { expandShorthand, isCssProperty, suggestCssProperty } from "../../../catalogs/index.js";
|
|
2
2
|
import { checkStyleVarRefs, checkVarRefs } from "./context.js";
|
|
3
3
|
//#region src/modules/mcp/tools/shared/validator/css.ts
|
|
4
4
|
var checkCss = (css, path, ctx) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BUILTIN_COMPONENTS } from "../../../catalogs/builtinComponents.js";
|
|
2
1
|
import { observedDataSources, observedInteractionActions } from "../../../catalogs/observed.js";
|
|
3
2
|
import { buildTypeRegistry } from "../../../catalogs/registry.js";
|
|
4
|
-
import {
|
|
3
|
+
import { elementTypeNames } from "../../../catalogs/index.js";
|
|
4
|
+
import { findElementByRef, findFolderByRef, findPageByRef, findRootByRef, folderAncestorIds, getLayoutElements, getPageElements, pageFoldersOf, resolveRef, routeParamNames } from "../../../helpers/space.js";
|
|
5
5
|
import { MAX_OPS } from "../../operations/index.js";
|
|
6
|
-
import { batchDeclaredFolders, batchDeclaredPages, batchDeclaredVariants, batchDeclaredVars } from "./batch.js";
|
|
6
|
+
import { batchDeclaredElements, batchDeclaredFolders, batchDeclaredPages, batchDeclaredVariants, batchDeclaredVars } from "./batch.js";
|
|
7
7
|
import { checkObservedName, checkVarRefs, warnOnce } from "./context.js";
|
|
8
8
|
import { checkBindingSourceScope, checkBindingTarget, checkBindingTransformers } from "./bindings.js";
|
|
9
9
|
import { batchDeclaredConnectors, checkConnectorOp, checkProviderElement } from "./connectors.js";
|
|
@@ -11,6 +11,7 @@ import { checkSlotCss } from "./css.js";
|
|
|
11
11
|
import { checkRef } from "./refs.js";
|
|
12
12
|
import { checkElementInput, checkRawMarkup, checkTypeProps, checkVariantApplication } from "./elements.js";
|
|
13
13
|
import { checkInteractionNode } from "./interactions.js";
|
|
14
|
+
import { isValidElementId } from "@plitzi/sdk-schema/helpers/elementId";
|
|
14
15
|
//#region src/modules/mcp/tools/shared/validator/index.ts
|
|
15
16
|
var STYLE_CATEGORIES = [
|
|
16
17
|
"color",
|
|
@@ -41,15 +42,17 @@ var buildTypeMeta = (catalog) => {
|
|
|
41
42
|
* the post-apply resource audit (auditResources) can run the same checks against the resulting draft. */
|
|
42
43
|
var buildValidationCtx = (space, ops, mode = "space") => {
|
|
43
44
|
const registry = buildTypeRegistry(space.schema, space.catalog);
|
|
45
|
+
const batchElements = batchDeclaredElements(ops);
|
|
44
46
|
return {
|
|
45
47
|
mode,
|
|
46
48
|
errors: [],
|
|
47
49
|
warnings: [],
|
|
48
50
|
warned: /* @__PURE__ */ new Set(),
|
|
49
|
-
knownTypes: /* @__PURE__ */ new Set([...Object.keys(registry.types), ...
|
|
51
|
+
knownTypes: /* @__PURE__ */ new Set([...Object.keys(registry.types), ...elementTypeNames]),
|
|
50
52
|
typeProps: new Map(Object.entries(registry.types).map(([type, info]) => [type, new Set(Object.keys(info.props))])),
|
|
51
53
|
typeMeta: buildTypeMeta(space.catalog),
|
|
52
54
|
elementType: (ref) => (findElementByRef(space.schema, ref) ?? findPageByRef(space.schema, ref))?.definition.type,
|
|
55
|
+
elementExists: (ref) => batchElements.has(ref) || Boolean(findElementByRef(space.schema, ref) ?? findPageByRef(space.schema, ref)),
|
|
53
56
|
schemaVars: /* @__PURE__ */ new Set([
|
|
54
57
|
...space.schema.variables.map((v) => v.name),
|
|
55
58
|
...routeParamNames(space.schema),
|
|
@@ -80,12 +83,12 @@ var validateOperations = (space, ops, mode = "space") => {
|
|
|
80
83
|
ops.forEach((op, i) => {
|
|
81
84
|
const base = `operations[${i}]`;
|
|
82
85
|
if ((op.type === "upsertElement" || op.type === "patchElement" || op.type === "deleteElement" || op.type === "moveElement" || op.type === "upsertBinding" || op.type === "patchBinding" || op.type === "deleteBinding" || op.type === "upsertInteractionFlow" || op.type === "patchInteractionNode" || op.type === "deleteInteraction") && op.pageRef) {
|
|
83
|
-
if (!
|
|
84
|
-
const validRefs = getPageElements(space.schema).map(
|
|
86
|
+
if (!findRootByRef(space.schema, op.pageRef) && !batchPages.has(op.pageRef)) {
|
|
87
|
+
const validRefs = [...getPageElements(space.schema).map((page) => page.id), ...getLayoutElements(space.schema).map((layout) => layout.id)];
|
|
85
88
|
ctx.errors.push({
|
|
86
89
|
path: `${base}.pageRef`,
|
|
87
|
-
message: `Page "${op.pageRef}" does not exist`,
|
|
88
|
-
hint: "Use an existing page ref, or create
|
|
90
|
+
message: `Page or layout "${op.pageRef}" does not exist`,
|
|
91
|
+
hint: "Use an existing page or layout ref, or create the page with upsertPage earlier in the same batch",
|
|
89
92
|
validValues: validRefs
|
|
90
93
|
});
|
|
91
94
|
}
|
|
@@ -98,7 +101,7 @@ var validateOperations = (space, ops, mode = "space") => {
|
|
|
98
101
|
break;
|
|
99
102
|
case "patchElement": {
|
|
100
103
|
checkRef(op.ref, `${base}.ref`, ctx);
|
|
101
|
-
const page =
|
|
104
|
+
const page = findRootByRef(space.schema, op.pageRef);
|
|
102
105
|
const target = page ? resolveRef(space.schema, page, op.ref) : void 0;
|
|
103
106
|
if (op.props) {
|
|
104
107
|
for (const [key, value] of Object.entries(op.props)) if (typeof value === "string") checkVarRefs(value, `${base}.props.${key}`, ctx);
|
|
@@ -219,6 +222,23 @@ var validateOperations = (space, ops, mode = "space") => {
|
|
|
219
222
|
message: "The first node of a flow must be a trigger",
|
|
220
223
|
hint: "Put the trigger first; the callbacks/utilities that run after it follow in order"
|
|
221
224
|
});
|
|
225
|
+
{
|
|
226
|
+
const named = /* @__PURE__ */ new Set();
|
|
227
|
+
op.nodes.forEach((node, n) => {
|
|
228
|
+
if (!node.id) return;
|
|
229
|
+
if (!isValidElementId(node.id)) ctx.errors.push({
|
|
230
|
+
path: `${base}.nodes[${n}].id`,
|
|
231
|
+
message: `"${node.id}" is not a valid step name`,
|
|
232
|
+
hint: "Letters, numbers, hyphens and underscores, starting with a letter. A later step reads this one as {{ <id>.field }}, so a dot would split that path"
|
|
233
|
+
});
|
|
234
|
+
if (named.has(node.id)) ctx.errors.push({
|
|
235
|
+
path: `${base}.nodes[${n}].id`,
|
|
236
|
+
message: `Two steps of this flow are called "${node.id}"`,
|
|
237
|
+
hint: "A flow is keyed by step id, so the second would replace the first. Name them apart"
|
|
238
|
+
});
|
|
239
|
+
named.add(node.id);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
222
242
|
op.nodes.forEach((node, n) => checkInteractionNode(node, `${base}.nodes[${n}]`, ctx, op.ref));
|
|
223
243
|
break;
|
|
224
244
|
case "patchInteractionNode": {
|