@plitzi/sdk-server 0.32.5 → 0.32.6
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 +10 -0
- package/dist/core/services/mcp.js +1 -1
- package/dist/helpers/buildServerInfo.js +3 -9
- package/dist/index.js +2 -1
- package/dist/modules/mcp/catalogs/builtinCallbacks.js +204 -0
- package/dist/modules/mcp/catalogs/builtinComponents.js +170 -0
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +50 -0
- package/dist/modules/mcp/catalogs/builtinTransformers.js +148 -0
- package/dist/modules/mcp/catalogs/builtinUtilities.js +90 -0
- package/dist/modules/mcp/{tools/operations/style → catalogs}/cssCatalog.js +75 -2
- package/dist/modules/mcp/catalogs/observed.js +90 -0
- package/dist/modules/mcp/catalogs/paramSpec.js +69 -0
- package/dist/modules/mcp/catalogs/registry.js +89 -0
- package/dist/modules/mcp/handler.js +12 -2
- package/dist/modules/mcp/helpers/agentPrompt.js +104 -0
- package/dist/modules/mcp/helpers/guide.js +334 -15
- package/dist/modules/mcp/helpers/interactions.js +123 -0
- package/dist/modules/mcp/helpers/log.js +54 -0
- package/dist/modules/mcp/helpers/space.js +158 -33
- package/dist/modules/mcp/helpers/uris.js +44 -0
- package/dist/modules/mcp/resources/canonical.js +6 -21
- package/dist/modules/mcp/resources/core.js +4 -3
- package/dist/modules/mcp/resources/primer.js +13 -8
- package/dist/modules/mcp/resources/register.js +37 -5
- package/dist/modules/mcp/resources/schema.js +30 -20
- package/dist/modules/mcp/resources/style.js +18 -11
- package/dist/modules/mcp/server.js +21 -7
- package/dist/modules/mcp/tools/apply/dispatch.js +38 -18
- package/dist/modules/mcp/tools/apply/index.js +19 -4
- package/dist/modules/mcp/tools/apply/writeResult.js +2 -1
- package/dist/modules/mcp/tools/index.js +1 -1
- package/dist/modules/mcp/tools/operations/index.js +13 -2
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +32 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +36 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +47 -0
- package/dist/modules/mcp/tools/operations/schema/{deleteElement.js → elements/deleteElement.js} +10 -6
- package/dist/modules/mcp/tools/operations/schema/{moveElement.js → elements/moveElement.js} +8 -6
- package/dist/modules/mcp/tools/operations/schema/{patchElement.js → elements/patchElement.js} +19 -7
- package/dist/modules/mcp/tools/operations/schema/{upsertElement.js → elements/upsertElement.js} +11 -5
- package/dist/modules/mcp/tools/operations/schema/{deleteFolder.js → folders/deleteFolder.js} +4 -4
- package/dist/modules/mcp/tools/operations/schema/{upsertFolder.js → folders/upsertFolder.js} +4 -4
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +52 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +47 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +43 -0
- package/dist/modules/mcp/tools/operations/schema/operations.js +25 -11
- package/dist/modules/mcp/tools/operations/schema/{deletePage.js → pages/deletePage.js} +8 -5
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +75 -0
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +45 -0
- package/dist/modules/mcp/tools/operations/schema/shared.js +94 -2
- package/dist/modules/mcp/tools/operations/schema/translator.js +77 -10
- package/dist/modules/mcp/tools/operations/schema/{deleteVariable.js → variables/deleteVariable.js} +3 -3
- package/dist/modules/mcp/tools/operations/schema/{upsertVariable.js → variables/upsertVariable.js} +4 -4
- package/dist/modules/mcp/tools/operations/schema/write.js +78 -13
- package/dist/modules/mcp/tools/operations/style/{deleteDefinition.js → definitions/deleteDefinition.js} +4 -3
- package/dist/modules/mcp/tools/operations/style/{patchDefinition.js → definitions/patchDefinition.js} +6 -5
- package/dist/modules/mcp/tools/operations/style/{upsertDefinition.js → definitions/upsertDefinition.js} +5 -4
- package/dist/modules/mcp/tools/operations/style/{deleteGlobalStyle.js → globalStyles/deleteGlobalStyle.js} +4 -3
- package/dist/modules/mcp/tools/operations/style/{patchGlobalStyle.js → globalStyles/patchGlobalStyle.js} +6 -5
- package/dist/modules/mcp/tools/operations/style/{upsertGlobalStyle.js → globalStyles/upsertGlobalStyle.js} +5 -4
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +21 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +28 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +24 -0
- package/dist/modules/mcp/tools/operations/style/operations.js +14 -8
- package/dist/modules/mcp/tools/operations/style/translator.js +25 -1
- package/dist/modules/mcp/tools/operations/style/{deleteStyleVariable.js → variables/deleteStyleVariable.js} +4 -4
- package/dist/modules/mcp/tools/operations/style/{upsertStyleVariable.js → variables/upsertStyleVariable.js} +4 -4
- package/dist/modules/mcp/tools/operations/style/write.js +19 -11
- package/dist/modules/mcp/tools/read.js +1 -1
- package/dist/modules/mcp/tools/search.js +34 -27
- package/dist/modules/mcp/tools/shared/validator/audit.js +124 -0
- package/dist/modules/mcp/tools/shared/validator/batch.js +30 -0
- package/dist/modules/mcp/tools/shared/validator/bindings.js +70 -0
- package/dist/modules/mcp/tools/shared/validator/context.js +35 -0
- package/dist/modules/mcp/tools/shared/validator/css.js +47 -0
- package/dist/modules/mcp/tools/shared/validator/elements.js +55 -0
- package/dist/modules/mcp/tools/shared/validator/index.js +226 -0
- package/dist/modules/mcp/tools/shared/validator/interactions.js +106 -0
- package/dist/modules/mcp/tools/shared/validator/refs.js +28 -0
- package/dist/modules/mcp/tools/validate.js +23 -3
- package/dist/modules/ssr/preview.js +1 -1
- package/dist/modules/ssr/views/template.ejs +2 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/modules/mcp/catalogs/builtinCallbacks.d.ts +23 -0
- package/dist/src/modules/mcp/catalogs/builtinComponents.d.ts +4 -0
- package/dist/src/modules/mcp/catalogs/builtinElementCallbacks.d.ts +20 -0
- package/dist/src/modules/mcp/catalogs/builtinTransformers.d.ts +28 -0
- package/dist/src/modules/mcp/catalogs/builtinTransformers.test.d.ts +1 -0
- package/dist/src/modules/mcp/catalogs/builtinUtilities.d.ts +18 -0
- package/dist/src/modules/mcp/{tools/operations/style → catalogs}/cssCatalog.d.ts +5 -1
- package/dist/src/modules/mcp/catalogs/index.d.ts +9 -0
- package/dist/src/modules/mcp/catalogs/observed.d.ts +48 -0
- package/dist/src/modules/mcp/catalogs/paramSpec.d.ts +42 -0
- package/dist/src/modules/mcp/catalogs/registry.d.ts +35 -0
- package/dist/src/modules/mcp/handler.d.ts +2 -2
- package/dist/src/modules/mcp/helpers/agentPrompt.d.ts +4 -0
- package/dist/src/modules/mcp/helpers/guide.d.ts +2 -1
- package/dist/src/modules/mcp/helpers/index.d.ts +4 -0
- package/dist/src/modules/mcp/helpers/interactions.d.ts +30 -0
- package/dist/src/modules/mcp/helpers/log.d.ts +8 -0
- package/dist/src/modules/mcp/helpers/log.test.d.ts +1 -0
- package/dist/src/modules/mcp/helpers/space.d.ts +67 -11
- package/dist/src/modules/mcp/helpers/uris.d.ts +28 -0
- package/dist/src/modules/mcp/index.d.ts +1 -1
- package/dist/src/modules/mcp/mcp.bench.d.ts +1 -0
- package/dist/src/modules/mcp/resources/canonical.d.ts +0 -1
- package/dist/src/modules/mcp/resources/index.d.ts +2 -3
- package/dist/src/modules/mcp/resources/primer.d.ts +2 -1
- package/dist/src/modules/mcp/resources/register.d.ts +2 -2
- package/dist/src/modules/mcp/server.d.ts +5 -2
- package/dist/src/modules/mcp/tools/apply/index.d.ts +191 -2
- package/dist/src/modules/mcp/tools/operations/index.d.ts +383 -4
- package/dist/src/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +17 -0
- package/dist/src/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +25 -0
- package/dist/src/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +27 -0
- package/dist/src/modules/mcp/tools/operations/schema/{deleteElement.d.ts → elements/deleteElement.d.ts} +2 -2
- package/dist/src/modules/mcp/tools/operations/schema/{moveElement.d.ts → elements/moveElement.d.ts} +2 -2
- package/dist/src/modules/mcp/tools/operations/schema/{patchElement.d.ts → elements/patchElement.d.ts} +7 -2
- package/dist/src/modules/mcp/tools/operations/schema/{upsertElement.d.ts → elements/upsertElement.d.ts} +3 -3
- package/dist/src/modules/mcp/tools/operations/schema/{deleteFolder.d.ts → folders/deleteFolder.d.ts} +2 -2
- package/dist/src/modules/mcp/tools/operations/schema/{upsertFolder.d.ts → folders/upsertFolder.d.ts} +2 -2
- package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +17 -11
- package/dist/src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +18 -0
- package/dist/src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +27 -0
- package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +131 -0
- package/dist/src/modules/mcp/tools/operations/schema/{deletePage.d.ts → pages/deletePage.d.ts} +2 -2
- package/dist/src/modules/mcp/tools/operations/schema/{upsertPage.d.ts → pages/upsertPage.d.ts} +3 -2
- package/dist/src/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +34 -0
- package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +53 -0
- package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +5 -2
- package/dist/src/modules/mcp/tools/operations/schema/{deleteVariable.d.ts → variables/deleteVariable.d.ts} +2 -2
- package/dist/src/modules/mcp/tools/operations/schema/{upsertVariable.d.ts → variables/upsertVariable.d.ts} +2 -2
- package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +38 -8
- package/dist/src/modules/mcp/tools/operations/style/{deleteDefinition.d.ts → definitions/deleteDefinition.d.ts} +2 -2
- package/dist/src/modules/mcp/tools/operations/style/{patchDefinition.d.ts → definitions/patchDefinition.d.ts} +2 -2
- package/dist/src/modules/mcp/tools/operations/style/{upsertDefinition.d.ts → definitions/upsertDefinition.d.ts} +2 -2
- package/dist/src/modules/mcp/tools/operations/style/{deleteGlobalStyle.d.ts → globalStyles/deleteGlobalStyle.d.ts} +2 -2
- package/dist/src/modules/mcp/tools/operations/style/{patchGlobalStyle.d.ts → globalStyles/patchGlobalStyle.d.ts} +2 -2
- package/dist/src/modules/mcp/tools/operations/style/{upsertGlobalStyle.d.ts → globalStyles/upsertGlobalStyle.d.ts} +2 -2
- package/dist/src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/index.d.ts +11 -9
- package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +70 -2
- package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +1 -1
- package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +4 -1
- package/dist/src/modules/mcp/tools/operations/style/{deleteStyleVariable.d.ts → variables/deleteStyleVariable.d.ts} +3 -3
- package/dist/src/modules/mcp/tools/operations/style/{upsertStyleVariable.d.ts → variables/upsertStyleVariable.d.ts} +3 -3
- package/dist/src/modules/mcp/tools/operations/style/write.d.ts +2 -7
- package/dist/src/modules/mcp/tools/preview.d.ts +191 -2
- package/dist/src/modules/mcp/tools/screenshot.d.ts +191 -2
- package/dist/src/modules/mcp/tools/shared/validator/audit.d.ts +4 -0
- package/dist/src/modules/mcp/tools/shared/validator/batch.d.ts +5 -0
- package/dist/src/modules/mcp/tools/shared/validator/bindings.d.ts +6 -0
- package/dist/src/modules/mcp/tools/shared/validator/context.d.ts +34 -0
- package/dist/src/modules/mcp/tools/shared/validator/css.d.ts +4 -0
- package/dist/src/modules/mcp/tools/shared/validator/elements.d.ts +6 -0
- package/dist/src/modules/mcp/tools/shared/validator/index.d.ts +8 -0
- package/dist/src/modules/mcp/tools/shared/validator/interactions.d.ts +3 -0
- package/dist/src/modules/mcp/tools/shared/validator/refs.d.ts +4 -0
- package/dist/src/modules/mcp/tools/validate.d.ts +191 -2
- package/dist/src/modules/mcp/types/aiSchema.d.ts +93 -1
- package/package.json +12 -10
- package/dist/modules/mcp/tools/operations/schema/registry.js +0 -55
- package/dist/modules/mcp/tools/operations/schema/upsertPage.js +0 -64
- package/dist/modules/mcp/tools/shared/validator.js +0 -262
- package/dist/src/modules/mcp/tools/operations/schema/registry.d.ts +0 -22
- package/dist/src/modules/mcp/tools/shared/validator.d.ts +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,7 @@ var serveMcp = (ctx) => {
|
|
|
7
7
|
const { previewClient, screenshot } = ctx.config;
|
|
8
8
|
const preview = previewClient ? createHttpPreviewClient(previewClient) : void 0;
|
|
9
9
|
const screenshotClient = screenshot ? createHttpScreenshotClient(screenshot) : void 0;
|
|
10
|
-
return handleMcp(ctx.raw, ctx.rawRes, ctx.req, ctx.config.adapters, preview, screenshotClient);
|
|
10
|
+
return handleMcp(ctx.raw, ctx.rawRes, ctx.req, ctx.config.adapters, preview, screenshotClient, ctx.config.mcpLogger);
|
|
11
11
|
};
|
|
12
12
|
var mcpStage = async (ctx) => {
|
|
13
13
|
if (!ctx.req.path.startsWith(mcpPathOf(ctx.config.mcp?.path))) return false;
|
|
@@ -5,9 +5,7 @@ var getEnvironment = (env = "production", server) => {
|
|
|
5
5
|
case "staging": return {
|
|
6
6
|
apiServer: "https://api-stg.plitzi.com",
|
|
7
7
|
ssrServer: "https://ssr-stg.plitzi.com",
|
|
8
|
-
|
|
9
|
-
aiServer: "https://mcp-stg.plitzi.com",
|
|
10
|
-
graphqlServer: "https://server-stg.plitzi.com",
|
|
8
|
+
serverUrl: "https://server-stg.plitzi.com",
|
|
11
9
|
websocketServer: "wss://server-stg.plitzi.com",
|
|
12
10
|
subscriptionServer: "wss://server-stg.plitzi.com/subscriptions",
|
|
13
11
|
...server
|
|
@@ -15,9 +13,7 @@ var getEnvironment = (env = "production", server) => {
|
|
|
15
13
|
case "development": return {
|
|
16
14
|
apiServer: "https://api-dev.plitzi.com",
|
|
17
15
|
ssrServer: "https://ssr-dev.plitzi.com",
|
|
18
|
-
|
|
19
|
-
aiServer: "https://mcp-dev.plitzi.com",
|
|
20
|
-
graphqlServer: "https://server-dev.plitzi.com",
|
|
16
|
+
serverUrl: "https://server-dev.plitzi.com",
|
|
21
17
|
websocketServer: "wss://server-dev.plitzi.com",
|
|
22
18
|
subscriptionServer: "wss://server-dev.plitzi.com/subscriptions",
|
|
23
19
|
...server
|
|
@@ -25,9 +21,7 @@ var getEnvironment = (env = "production", server) => {
|
|
|
25
21
|
default: return {
|
|
26
22
|
apiServer: "https://api.plitzi.local",
|
|
27
23
|
ssrServer: "https://ssr.plitzi.local",
|
|
28
|
-
|
|
29
|
-
aiServer: "https://mcp.plitzi.local",
|
|
30
|
-
graphqlServer: "https://server.plitzi.local",
|
|
24
|
+
serverUrl: "https://server.plitzi.local",
|
|
31
25
|
websocketServer: "wss://server.plitzi.local",
|
|
32
26
|
subscriptionServer: "wss://server.plitzi.local/subscriptions",
|
|
33
27
|
...server
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildAgentGuide } from "./modules/mcp/helpers/agentPrompt.js";
|
|
1
2
|
import { operation } from "./modules/mcp/tools/operations/index.js";
|
|
2
3
|
import { apply, applyShape } from "./modules/mcp/tools/apply/index.js";
|
|
3
4
|
import { read, readShape } from "./modules/mcp/tools/read.js";
|
|
@@ -18,4 +19,4 @@ import { createSSRServer } from "./core/server/ssrServer.js";
|
|
|
18
19
|
import { createServer } from "./core/createServer.js";
|
|
19
20
|
import { createJsonAdapters } from "./adapters/jsonAdapters.js";
|
|
20
21
|
import AIEngine from "./modules/ai/AIEngine.js";
|
|
21
|
-
export { AIEngine, PREVIEW_TOKEN_PARAM, apply, applyShape, bindTools, buildHealthPayload, createHttpPreviewClient, createHttpScreenshotClient, createJsonAdapters, createMCPServer, createMcpServer, createMemoryDraftStore, createPreview, createSSRServer, createServer, getAllowedModes, handleMcp, isCallToolResult, isToolActive, operation, read, readMcpBody, readShape, registerHealthCheck, resolveServices, resolveToolHandler, search, searchShape, serveMcp, toolResponseErr, toolResponseFromResult, toolResponseOk, tools, validate, validateShape, zodToJsonSchema };
|
|
22
|
+
export { AIEngine, PREVIEW_TOKEN_PARAM, apply, applyShape, bindTools, buildAgentGuide, buildHealthPayload, createHttpPreviewClient, createHttpScreenshotClient, createJsonAdapters, createMCPServer, createMcpServer, createMemoryDraftStore, createPreview, createSSRServer, createServer, getAllowedModes, handleMcp, isCallToolResult, isToolActive, operation, read, readMcpBody, readShape, registerHealthCheck, resolveServices, resolveToolHandler, search, searchShape, serveMcp, toolResponseErr, toolResponseFromResult, toolResponseOk, tools, validate, validateShape, zodToJsonSchema };
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { reconcileParams } from "./paramSpec.js";
|
|
2
|
+
//#region src/modules/mcp/catalogs/builtinCallbacks.ts
|
|
3
|
+
var BUILTIN_GLOBAL_CALLBACKS = {
|
|
4
|
+
addNotification: {
|
|
5
|
+
source: "space",
|
|
6
|
+
title: "Add Notification",
|
|
7
|
+
strictParams: true,
|
|
8
|
+
params: {
|
|
9
|
+
content: {
|
|
10
|
+
type: "textarea",
|
|
11
|
+
description: "The notification text shown to the user — this is the message body. There is no separate title/message/type param.",
|
|
12
|
+
default: "Content"
|
|
13
|
+
},
|
|
14
|
+
placement: {
|
|
15
|
+
type: "select",
|
|
16
|
+
description: "Where the toast appears on screen.",
|
|
17
|
+
default: "top-right",
|
|
18
|
+
options: [
|
|
19
|
+
"top-right",
|
|
20
|
+
"top-center",
|
|
21
|
+
"top-left",
|
|
22
|
+
"bottom-right",
|
|
23
|
+
"bottom-center",
|
|
24
|
+
"bottom-left"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
appeareance: {
|
|
28
|
+
type: "select",
|
|
29
|
+
description: "Visual style of the notification. NOTE: the key is spelled \"appeareance\".",
|
|
30
|
+
default: "success",
|
|
31
|
+
options: [
|
|
32
|
+
"success",
|
|
33
|
+
"danger",
|
|
34
|
+
"warning",
|
|
35
|
+
"info"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
autoDismiss: {
|
|
39
|
+
type: "boolean",
|
|
40
|
+
description: "Whether the notification dismisses itself after a timeout.",
|
|
41
|
+
default: true
|
|
42
|
+
},
|
|
43
|
+
autoDismissTimeout: {
|
|
44
|
+
type: "number",
|
|
45
|
+
description: "Milliseconds before auto-dismiss. Only applies when autoDismiss is true.",
|
|
46
|
+
default: 5e3,
|
|
47
|
+
when: (params) => params.autoDismiss === true
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
setState: {
|
|
52
|
+
source: "state",
|
|
53
|
+
title: "Set State",
|
|
54
|
+
strictParams: true,
|
|
55
|
+
params: {
|
|
56
|
+
key: {
|
|
57
|
+
type: "text",
|
|
58
|
+
description: "The state key/path to set.",
|
|
59
|
+
default: ""
|
|
60
|
+
},
|
|
61
|
+
type: {
|
|
62
|
+
type: "select",
|
|
63
|
+
description: "The value type.",
|
|
64
|
+
options: [
|
|
65
|
+
"boolean",
|
|
66
|
+
"number",
|
|
67
|
+
"text"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
value: {
|
|
71
|
+
type: "scalar",
|
|
72
|
+
description: "The value to store — its type follows the `type` param (a real boolean/number, or text).",
|
|
73
|
+
when: (params) => Boolean(params.type)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
clearState: {
|
|
78
|
+
source: "state",
|
|
79
|
+
title: "Clear State",
|
|
80
|
+
strictParams: true,
|
|
81
|
+
params: {}
|
|
82
|
+
},
|
|
83
|
+
navigate: {
|
|
84
|
+
source: "navigation",
|
|
85
|
+
title: "Navigate",
|
|
86
|
+
strictParams: true,
|
|
87
|
+
params: {
|
|
88
|
+
urlType: {
|
|
89
|
+
type: "select",
|
|
90
|
+
description: "Target kind: a space page, an internal space path, or an external URL.",
|
|
91
|
+
options: [
|
|
92
|
+
"page",
|
|
93
|
+
"internal",
|
|
94
|
+
"external"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
url: {
|
|
98
|
+
type: "text",
|
|
99
|
+
description: "Destination — a page id when urlType is \"page\", otherwise a URL/path.",
|
|
100
|
+
when: (params) => Boolean(params.urlType)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
authLogin: {
|
|
105
|
+
source: "auth",
|
|
106
|
+
title: "Auth Login",
|
|
107
|
+
strictParams: true,
|
|
108
|
+
params: {}
|
|
109
|
+
},
|
|
110
|
+
authLogout: {
|
|
111
|
+
source: "auth",
|
|
112
|
+
title: "Auth Logout",
|
|
113
|
+
strictParams: true,
|
|
114
|
+
params: {}
|
|
115
|
+
},
|
|
116
|
+
authRefreshDetails: {
|
|
117
|
+
source: "auth",
|
|
118
|
+
title: "Auth Refresh Details",
|
|
119
|
+
strictParams: true,
|
|
120
|
+
params: {}
|
|
121
|
+
},
|
|
122
|
+
addCollectionRecord: {
|
|
123
|
+
source: "collection",
|
|
124
|
+
title: "Add Collection Record",
|
|
125
|
+
strictParams: false,
|
|
126
|
+
params: {
|
|
127
|
+
collectionId: {
|
|
128
|
+
type: "select",
|
|
129
|
+
description: "The collection to add the record to."
|
|
130
|
+
},
|
|
131
|
+
recordStatus: {
|
|
132
|
+
type: "select",
|
|
133
|
+
description: "Status of the new record.",
|
|
134
|
+
default: "draft",
|
|
135
|
+
options: [
|
|
136
|
+
"published",
|
|
137
|
+
"draft",
|
|
138
|
+
"archived",
|
|
139
|
+
"deleted",
|
|
140
|
+
"created"
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
updateCollectionRecord: {
|
|
146
|
+
source: "collection",
|
|
147
|
+
title: "Update Collection Record",
|
|
148
|
+
strictParams: false,
|
|
149
|
+
params: {
|
|
150
|
+
collectionId: {
|
|
151
|
+
type: "select",
|
|
152
|
+
description: "The collection the record belongs to."
|
|
153
|
+
},
|
|
154
|
+
recordId: {
|
|
155
|
+
type: "select",
|
|
156
|
+
description: "The record to update."
|
|
157
|
+
},
|
|
158
|
+
recordStatus: {
|
|
159
|
+
type: "select",
|
|
160
|
+
description: "New status for the record.",
|
|
161
|
+
default: "draft",
|
|
162
|
+
options: [
|
|
163
|
+
"published",
|
|
164
|
+
"draft",
|
|
165
|
+
"archived",
|
|
166
|
+
"deleted",
|
|
167
|
+
"created"
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
removeCollectionRecord: {
|
|
173
|
+
source: "collection",
|
|
174
|
+
title: "Remove Collection Record",
|
|
175
|
+
strictParams: false,
|
|
176
|
+
params: {
|
|
177
|
+
collectionId: {
|
|
178
|
+
type: "select",
|
|
179
|
+
description: "The collection the record belongs to."
|
|
180
|
+
},
|
|
181
|
+
recordId: {
|
|
182
|
+
type: "select",
|
|
183
|
+
description: "The record to remove."
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
/** The built-in globalCallback for an action, or undefined when the action is not a known built-in (a plugin
|
|
189
|
+
* callback whose source/schema is not knowable here). */
|
|
190
|
+
var getGlobalCallback = (action) => Object.hasOwn(BUILTIN_GLOBAL_CALLBACKS, action) ? BUILTIN_GLOBAL_CALLBACKS[action] : void 0;
|
|
191
|
+
/** Resolve a `globalCallback` action against the built-in catalog: returns the module id it is registered under
|
|
192
|
+
* (`source`) and the params reconciled to the callback's schema — unknown keys dropped for a closed callback, then
|
|
193
|
+
* missing defaults filled. An action the catalog does not know (e.g. a plugin callback) yields no source and
|
|
194
|
+
* unchanged params, so the caller keeps its own behavior for it. */
|
|
195
|
+
var applyBuiltinCallback = (action, params) => {
|
|
196
|
+
if (!(action in BUILTIN_GLOBAL_CALLBACKS)) return { params };
|
|
197
|
+
const builtin = BUILTIN_GLOBAL_CALLBACKS[action];
|
|
198
|
+
return {
|
|
199
|
+
source: builtin.source,
|
|
200
|
+
params: reconcileParams(params, builtin.params, builtin.strictParams)
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
//#endregion
|
|
204
|
+
export { BUILTIN_GLOBAL_CALLBACKS, applyBuiltinCallback, getGlobalCallback };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
//#region src/modules/mcp/catalogs/builtinComponents.ts
|
|
2
|
+
var BUILTIN_COMPONENTS = {
|
|
3
|
+
container: {
|
|
4
|
+
label: "Container",
|
|
5
|
+
category: "structure",
|
|
6
|
+
description: "Generic layout box (a div). The primary building block for structure: groups and positions child elements with flex/grid. Reach for it whenever you need to wrap or arrange other elements."
|
|
7
|
+
},
|
|
8
|
+
list: {
|
|
9
|
+
label: "List",
|
|
10
|
+
category: "structure",
|
|
11
|
+
description: "Repeats a template (its listItem/link child) once per entry of a data array — the way to render a dynamic collection. Bind its items to a data source (e.g. an apiContainer/collectionContainer response)."
|
|
12
|
+
},
|
|
13
|
+
listItem: {
|
|
14
|
+
label: "List Item",
|
|
15
|
+
category: "structure",
|
|
16
|
+
description: "The repeated template rendered once per row inside a list; its fields bind to each array entry."
|
|
17
|
+
},
|
|
18
|
+
dialogContainer: {
|
|
19
|
+
label: "Dialog Container",
|
|
20
|
+
category: "structure",
|
|
21
|
+
description: "A native <dialog> container shown or hidden through interactions (e.g. an onClick open/close)."
|
|
22
|
+
},
|
|
23
|
+
modalContainer: {
|
|
24
|
+
label: "Modal Container",
|
|
25
|
+
category: "structure",
|
|
26
|
+
description: "A modal overlay container opened and closed through interactions; use for dialogs over the page."
|
|
27
|
+
},
|
|
28
|
+
tabContainer: {
|
|
29
|
+
label: "Tab Container",
|
|
30
|
+
category: "structure",
|
|
31
|
+
description: "A tabbed container that switches between panels; composed of header/body/item parts."
|
|
32
|
+
},
|
|
33
|
+
tabContainerHeader: {
|
|
34
|
+
label: "Tab Container Header",
|
|
35
|
+
category: "structure",
|
|
36
|
+
description: "The row of tab triggers inside a tabContainer."
|
|
37
|
+
},
|
|
38
|
+
tabContainerBody: {
|
|
39
|
+
label: "Tab Container Body",
|
|
40
|
+
category: "structure",
|
|
41
|
+
description: "The panel area inside a tabContainer that shows the active tab item."
|
|
42
|
+
},
|
|
43
|
+
tabContainerItem: {
|
|
44
|
+
label: "Tab Container Item",
|
|
45
|
+
category: "structure",
|
|
46
|
+
description: "One selectable tab (trigger + panel) inside a tabContainer."
|
|
47
|
+
},
|
|
48
|
+
apiContainer: {
|
|
49
|
+
label: "Api Container",
|
|
50
|
+
category: "provider",
|
|
51
|
+
description: "Fetches data from a backend HTTP API (its `query`/`method`/`credentials`) and exposes the response as a data source ITS DESCENDANTS bind to (source `apiContainer_<idRef>.data`; only elements inside it can consume it). This is how you get backend data into the frontend. Its `mockData` prop is builder-only sample data — the published runtime fetches the real `query`, so always set a real query for production."
|
|
52
|
+
},
|
|
53
|
+
collectionContainer: {
|
|
54
|
+
label: "Collection Container",
|
|
55
|
+
category: "provider",
|
|
56
|
+
description: "Exposes a Plitzi Collection (built-in CMS) as a data source for its descendants to bind to — the CMS-backed counterpart of apiContainer."
|
|
57
|
+
},
|
|
58
|
+
text: {
|
|
59
|
+
label: "Text",
|
|
60
|
+
category: "basic",
|
|
61
|
+
description: "Inline plain-text content. Use for short runs of copy; bind its content to data for dynamic text."
|
|
62
|
+
},
|
|
63
|
+
paragraph: {
|
|
64
|
+
label: "Paragraph",
|
|
65
|
+
category: "basic",
|
|
66
|
+
description: "A block of body text (a <p>). Use for longer prose passages."
|
|
67
|
+
},
|
|
68
|
+
heading: {
|
|
69
|
+
label: "Heading",
|
|
70
|
+
category: "basic",
|
|
71
|
+
description: "A section heading (<h1>–<h6>) for titles and document hierarchy."
|
|
72
|
+
},
|
|
73
|
+
button: {
|
|
74
|
+
label: "Button",
|
|
75
|
+
category: "basic",
|
|
76
|
+
description: "A clickable button. On its own it only renders; wire an interaction flow (trigger onClick → callbacks) to make it DO something."
|
|
77
|
+
},
|
|
78
|
+
link: {
|
|
79
|
+
label: "Link",
|
|
80
|
+
category: "basic",
|
|
81
|
+
description: "Navigation. Moves the user between pages of the site or to an external URL (its `mode`/`href` decide which). Use this to go page-to-page rather than a button + interaction."
|
|
82
|
+
},
|
|
83
|
+
markdown: {
|
|
84
|
+
label: "Markdown",
|
|
85
|
+
category: "basic",
|
|
86
|
+
description: "Renders a Markdown source string as formatted HTML."
|
|
87
|
+
},
|
|
88
|
+
dropdown: {
|
|
89
|
+
label: "Dropdown",
|
|
90
|
+
category: "basic",
|
|
91
|
+
description: "A trigger that toggles an attached popup panel (dropdownPopup) — menus, selects, flyouts."
|
|
92
|
+
},
|
|
93
|
+
dropdownPopup: {
|
|
94
|
+
label: "Dropdown Popup",
|
|
95
|
+
category: "basic",
|
|
96
|
+
description: "The floating panel revealed by a dropdown."
|
|
97
|
+
},
|
|
98
|
+
form: {
|
|
99
|
+
label: "Form",
|
|
100
|
+
category: "form",
|
|
101
|
+
description: "A <form> that groups form controls and handles submission; wire its submit through an interaction flow."
|
|
102
|
+
},
|
|
103
|
+
formControl: {
|
|
104
|
+
label: "Form Control",
|
|
105
|
+
category: "form",
|
|
106
|
+
description: "A single labelled input (text/select/checkbox/… per its subType) inside a form; captures one field of user input."
|
|
107
|
+
},
|
|
108
|
+
image: {
|
|
109
|
+
label: "Image",
|
|
110
|
+
category: "media",
|
|
111
|
+
description: "Displays an image from a URL."
|
|
112
|
+
},
|
|
113
|
+
video: {
|
|
114
|
+
label: "Video",
|
|
115
|
+
category: "media",
|
|
116
|
+
description: "Embeds a video from a URL."
|
|
117
|
+
},
|
|
118
|
+
fontAwesome: {
|
|
119
|
+
label: "Font Awesome",
|
|
120
|
+
category: "media",
|
|
121
|
+
description: "Renders a Font Awesome icon by its icon name."
|
|
122
|
+
},
|
|
123
|
+
page: {
|
|
124
|
+
label: "Page",
|
|
125
|
+
category: "internal",
|
|
126
|
+
description: "The root of a routable screen. Managed through the page ops (upsertPage/deletePage), not added as a child element."
|
|
127
|
+
},
|
|
128
|
+
layoutContainer: {
|
|
129
|
+
label: "Layout Container",
|
|
130
|
+
category: "internal",
|
|
131
|
+
description: "A reusable layout shell (header/footer chrome) shared across pages."
|
|
132
|
+
},
|
|
133
|
+
notFound: {
|
|
134
|
+
label: "Not Found",
|
|
135
|
+
category: "internal",
|
|
136
|
+
description: "The 404 screen shown when no route matches."
|
|
137
|
+
},
|
|
138
|
+
loading: {
|
|
139
|
+
label: "Loading",
|
|
140
|
+
category: "internal",
|
|
141
|
+
description: "A loading placeholder shown while data or a suspense boundary resolves."
|
|
142
|
+
},
|
|
143
|
+
reference: {
|
|
144
|
+
label: "Reference",
|
|
145
|
+
category: "advanced",
|
|
146
|
+
description: "Reuses another element or template by id, rendering it in place."
|
|
147
|
+
},
|
|
148
|
+
custom: {
|
|
149
|
+
label: "Custom",
|
|
150
|
+
category: "advanced",
|
|
151
|
+
description: "A custom element slot whose behaviour is supplied by a host/plugin component."
|
|
152
|
+
},
|
|
153
|
+
blockHtml: {
|
|
154
|
+
label: "HTML Block",
|
|
155
|
+
category: "advanced",
|
|
156
|
+
description: "Renders an arbitrary raw HTML string as a block. Escape hatch when no structured element fits."
|
|
157
|
+
},
|
|
158
|
+
nodeHtml: {
|
|
159
|
+
label: "Html Node",
|
|
160
|
+
category: "advanced",
|
|
161
|
+
description: "A single raw HTML tag with custom attributes."
|
|
162
|
+
},
|
|
163
|
+
blockJsx: {
|
|
164
|
+
label: "Block JSX",
|
|
165
|
+
category: "advanced",
|
|
166
|
+
description: "A compiled JSX block for advanced authoring."
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
//#endregion
|
|
170
|
+
export { BUILTIN_COMPONENTS };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { reconcileParams } from "./paramSpec.js";
|
|
2
|
+
//#region src/modules/mcp/catalogs/builtinElementCallbacks.ts
|
|
3
|
+
var BUILTIN_ELEMENT_CALLBACKS = { setState: {
|
|
4
|
+
title: "Update Element (set attribute / state)",
|
|
5
|
+
strictParams: true,
|
|
6
|
+
params: {
|
|
7
|
+
category: {
|
|
8
|
+
type: "select",
|
|
9
|
+
description: "What to change on the element: \"attribute\" sets one of its props (the common case — e.g. content, disabled); \"state\" sets element state (visibility or a style selector). REQUIRED — always set it.",
|
|
10
|
+
default: "attribute",
|
|
11
|
+
options: ["attribute", "state"],
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
key: {
|
|
15
|
+
type: "text",
|
|
16
|
+
description: "The field to set. When category=\"attribute\", an attribute/prop key of THIS element (e.g. \"content\", \"disabled\"). When category=\"state\", \"visibility\" or \"styleSelectors.<selector>\". REQUIRED.",
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
value: {
|
|
20
|
+
type: "scalar",
|
|
21
|
+
description: "The value to set — its type follows the target attribute: a real boolean (true/false) for a boolean attribute, a number for a numeric one, otherwise a string (the strings \"true\"/\"false\" also coerce). There is NO separate `type` param (that belongs to the global state setState, not this one). REQUIRED.",
|
|
22
|
+
when: (params) => Boolean(params.category),
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
revertOnFinish: {
|
|
26
|
+
type: "boolean",
|
|
27
|
+
description: "When true, this change is UNDONE automatically when the whole flow finishes. Use it for a TEMPORARY change (a \"loading…\" label, disabling a button while it works) instead of adding manual restore steps at the end of the flow.",
|
|
28
|
+
default: false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} };
|
|
32
|
+
/** The built-in element callback for an action, or undefined when the action is not a known built-in (an
|
|
33
|
+
* element-type-specific/plugin callback whose schema is not knowable here). */
|
|
34
|
+
var getElementCallback = (action) => Object.hasOwn(BUILTIN_ELEMENT_CALLBACKS, action) ? BUILTIN_ELEMENT_CALLBACKS[action] : void 0;
|
|
35
|
+
/** Reconcile a `callback` action against the element-callback catalog: unknown keys dropped for a closed callback,
|
|
36
|
+
* then missing defaults filled (category:"attribute", revertOnFinish:false). An unknown action yields unchanged
|
|
37
|
+
* params, so a plugin/element-specific callback keeps whatever the agent passed. */
|
|
38
|
+
var applyElementCallback = (action, params) => {
|
|
39
|
+
const builtin = getElementCallback(action);
|
|
40
|
+
if (!builtin) return {
|
|
41
|
+
known: false,
|
|
42
|
+
params
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
known: true,
|
|
46
|
+
params: reconcileParams(params, builtin.params, builtin.strictParams)
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { BUILTIN_ELEMENT_CALLBACKS, applyElementCallback, getElementCallback };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
//#region src/modules/mcp/catalogs/builtinTransformers.ts
|
|
2
|
+
var boolParam = (description, dflt) => ({
|
|
3
|
+
type: "select",
|
|
4
|
+
description,
|
|
5
|
+
default: dflt,
|
|
6
|
+
options: ["true", "false"]
|
|
7
|
+
});
|
|
8
|
+
var BUILTIN_TRANSFORMERS = {
|
|
9
|
+
twigTemplate: {
|
|
10
|
+
title: "Twig Template",
|
|
11
|
+
description: "Render a Twig template around the bound value — the way to format/wrap a value (add units, compose a label). The incoming value is the token {{source}} (NOT {{value}}); {{sourceTo}} is the field’s previous value, and other data-source tokens are in scope too.",
|
|
12
|
+
strictParams: true,
|
|
13
|
+
params: { template: {
|
|
14
|
+
type: "textarea",
|
|
15
|
+
required: true,
|
|
16
|
+
description: "The Twig template string. Reference the incoming value as {{source}} — e.g. \"{{source}} min de cocción\". There is NO {{value}} token; {{sourceTo}} is the field’s original value."
|
|
17
|
+
} }
|
|
18
|
+
},
|
|
19
|
+
dateConverter: {
|
|
20
|
+
title: "Date Converter",
|
|
21
|
+
description: "Format a date/timestamp value. Reads a unix-seconds number (isUnix) or a parseable date string and outputs a formatted date, or a relative \"x ago\" string (asAge).",
|
|
22
|
+
strictParams: true,
|
|
23
|
+
params: {
|
|
24
|
+
format: {
|
|
25
|
+
type: "text",
|
|
26
|
+
default: "dd/MM/yyyy",
|
|
27
|
+
description: "date-fns format pattern, e.g. \"dd/MM/yyyy\" or \"PPpp\". Ignored when asAge is true."
|
|
28
|
+
},
|
|
29
|
+
asAge: boolParam("Output a relative \"x ago\" string instead of a formatted date.", "false"),
|
|
30
|
+
isUnix: boolParam("The source value is a unix timestamp in SECONDS (not milliseconds).", "true"),
|
|
31
|
+
isUtc: boolParam("Format in UTC instead of local time.", "false"),
|
|
32
|
+
locale: {
|
|
33
|
+
type: "select",
|
|
34
|
+
default: "en",
|
|
35
|
+
options: [
|
|
36
|
+
"en",
|
|
37
|
+
"es",
|
|
38
|
+
"pt"
|
|
39
|
+
],
|
|
40
|
+
description: "Locale for month/day names and relative text."
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
capitalize: {
|
|
45
|
+
title: "Capitalize",
|
|
46
|
+
description: "Capitalize the first letter of a string value. Takes no params.",
|
|
47
|
+
strictParams: true,
|
|
48
|
+
params: {}
|
|
49
|
+
},
|
|
50
|
+
staticValue: {
|
|
51
|
+
title: "Static Value",
|
|
52
|
+
description: "Ignore the source and emit a fixed value — use to hard-code a bound field. With valueType \"select\" the value is coerced to a boolean (\"true\"→true).",
|
|
53
|
+
strictParams: true,
|
|
54
|
+
params: {
|
|
55
|
+
valueType: {
|
|
56
|
+
type: "select",
|
|
57
|
+
default: "text",
|
|
58
|
+
options: [
|
|
59
|
+
"text",
|
|
60
|
+
"textarea",
|
|
61
|
+
"select"
|
|
62
|
+
],
|
|
63
|
+
description: "How `value` is interpreted: \"text\"/\"textarea\" → string, \"select\" → boolean (\"true\"/\"false\")."
|
|
64
|
+
},
|
|
65
|
+
value: {
|
|
66
|
+
type: "text",
|
|
67
|
+
description: "The constant value to emit (a string; \"true\"/\"false\" when valueType is select)."
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
arrayMap: {
|
|
72
|
+
title: "Array Map",
|
|
73
|
+
description: "Reshape each object of a source array by remapping keys — pick/rename fields for a list. Input must be an array; a non-array passes through unchanged.",
|
|
74
|
+
strictParams: true,
|
|
75
|
+
params: { keys: {
|
|
76
|
+
type: "textarea",
|
|
77
|
+
required: true,
|
|
78
|
+
default: "[{\"from\": \"\", \"to\": \"\"}]",
|
|
79
|
+
description: "A JSON array of { \"from\": <source path>, \"to\": <output key> } mappings, e.g. [{\"from\":\"title\",\"to\":\"label\"},{\"from\":\"id\",\"to\":\"value\"}]."
|
|
80
|
+
} }
|
|
81
|
+
},
|
|
82
|
+
stringToArray: {
|
|
83
|
+
title: "Text to List",
|
|
84
|
+
description: "Split a string into an array on a separator (each item trimmed). A non-string passes through unchanged.",
|
|
85
|
+
strictParams: true,
|
|
86
|
+
params: { separator: {
|
|
87
|
+
type: "text",
|
|
88
|
+
default: ",",
|
|
89
|
+
description: "The delimiter to split on, e.g. \",\" or \"|\"."
|
|
90
|
+
} }
|
|
91
|
+
},
|
|
92
|
+
styleSelector: {
|
|
93
|
+
title: "Style Selector",
|
|
94
|
+
description: "Compute a style-class selector from data — bind a `style` target to switch an element’s class at runtime. Builder-oriented (its `selector` options come from the style schema); prefer style variants for most cases.",
|
|
95
|
+
strictParams: true,
|
|
96
|
+
params: {
|
|
97
|
+
append: boolParam("Append `selector` to the existing selector instead of replacing it.", "false"),
|
|
98
|
+
originalSelector: boolParam("When appending, keep the element’s original base selector (requires append).", "false"),
|
|
99
|
+
selector: {
|
|
100
|
+
type: "text",
|
|
101
|
+
description: "The class-selector name to apply (a class from the style schema)."
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
styleVariant: {
|
|
106
|
+
title: "Style Variant",
|
|
107
|
+
description: "Compute an applied style-variant map from data — bind an `initialState` target to switch a variant at runtime. Builder-oriented (key/variant options come from the element’s style schema); prefer static variants for most cases.",
|
|
108
|
+
strictParams: true,
|
|
109
|
+
params: {
|
|
110
|
+
key: {
|
|
111
|
+
type: "text",
|
|
112
|
+
description: "The selector key to target, e.g. \"<type>.base\"."
|
|
113
|
+
},
|
|
114
|
+
variant: {
|
|
115
|
+
type: "text",
|
|
116
|
+
description: "The variant name to apply under `key`."
|
|
117
|
+
},
|
|
118
|
+
append: boolParam("Merge with the existing variant map instead of replacing it.", "false")
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
/** The built-in transformer for an action, or undefined when the action is not a known built-in transformer. */
|
|
123
|
+
var getTransformer = (action) => Object.hasOwn(BUILTIN_TRANSFORMERS, action) ? BUILTIN_TRANSFORMERS[action] : void 0;
|
|
124
|
+
/** The closest known transformer action to a mistyped one (substring match either way), so a wrong action like
|
|
125
|
+
* "template" teaches "twigTemplate". Undefined when nothing is close. */
|
|
126
|
+
var suggestTransformer = (action) => {
|
|
127
|
+
const needle = action.toLowerCase();
|
|
128
|
+
return Object.keys(BUILTIN_TRANSFORMERS).find((name) => {
|
|
129
|
+
const known = name.toLowerCase();
|
|
130
|
+
return known.includes(needle) || needle.includes(known);
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
/** The transformer catalog projected for the data-sources resource / primer, so the agent knows the exact action
|
|
134
|
+
* names and params up front (the real fix for the "agent can't write transformers" problem). */
|
|
135
|
+
var transformerCatalog = () => Object.entries(BUILTIN_TRANSFORMERS).map(([action, { title, description, params }]) => ({
|
|
136
|
+
action,
|
|
137
|
+
title,
|
|
138
|
+
description,
|
|
139
|
+
params: Object.entries(params).map(([name, spec]) => ({
|
|
140
|
+
name,
|
|
141
|
+
type: spec.type,
|
|
142
|
+
description: spec.description,
|
|
143
|
+
...spec.default !== void 0 ? { default: spec.default } : {},
|
|
144
|
+
...spec.options ? { options: spec.options } : {}
|
|
145
|
+
}))
|
|
146
|
+
}));
|
|
147
|
+
//#endregion
|
|
148
|
+
export { BUILTIN_TRANSFORMERS, getTransformer, suggestTransformer, transformerCatalog };
|