@plitzi/sdk-server 0.32.4 → 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 +19 -0
- package/dist/adapters/jsonAdapters.js +6 -1
- package/dist/core/createServer.js +8 -44
- package/dist/core/health.js +15 -0
- package/dist/core/http/dispatcher.js +29 -0
- package/dist/core/http/securityHeaders.js +15 -0
- package/dist/core/http/stages/authRoutes.js +41 -0
- package/dist/core/http/stages/health.js +12 -0
- package/dist/core/http/stages/middlewares.js +16 -0
- package/dist/core/http/stages/pluginAssets.js +20 -0
- package/dist/core/http/stages/static.js +30 -0
- package/dist/core/server/baseServer.js +29 -0
- package/dist/core/server/mcpServer.js +29 -0
- package/dist/core/server/ssrServer.js +54 -0
- package/dist/core/services/mcp.js +22 -0
- package/dist/core/services/preview.js +37 -0
- package/dist/core/services/registry.js +30 -0
- package/dist/core/services/resolve.js +12 -0
- package/dist/core/services/rsc.js +11 -0
- package/dist/core/services/ssr.js +13 -0
- package/dist/core/transports.js +9 -9
- package/dist/helpers/buildServerInfo.js +3 -9
- package/dist/index.js +20 -6
- package/dist/modules/ai/AIEngine.js +4 -4
- package/dist/modules/ai/toolkit.js +58 -0
- 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/catalogs/cssCatalog.js +205 -0
- 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/constants.js +4 -0
- package/dist/modules/mcp/handler.js +24 -20
- package/dist/modules/mcp/helpers/agentPrompt.js +104 -0
- package/dist/modules/mcp/helpers/computeVersion.js +16 -0
- package/dist/modules/mcp/helpers/guide.js +449 -0
- package/dist/modules/mcp/helpers/interactions.js +123 -0
- package/dist/modules/mcp/helpers/log.js +54 -0
- package/dist/modules/mcp/helpers/opResult.js +18 -0
- package/dist/modules/mcp/helpers/space.js +262 -0
- package/dist/modules/mcp/helpers/uris.js +44 -0
- package/dist/modules/mcp/previewClient.js +31 -0
- package/dist/modules/mcp/resources/canonical.js +30 -0
- package/dist/modules/mcp/resources/core.js +15 -0
- package/dist/modules/mcp/resources/envelope.js +14 -0
- package/dist/modules/mcp/resources/primer.js +30 -0
- package/dist/modules/mcp/resources/register.js +174 -0
- package/dist/modules/mcp/resources/router.js +25 -0
- package/dist/modules/mcp/resources/schema.js +43 -0
- package/dist/modules/mcp/resources/style.js +34 -0
- package/dist/modules/mcp/screenshotClient.js +47 -0
- package/dist/modules/mcp/server.js +66 -20
- package/dist/modules/mcp/tools/apply/dispatch.js +103 -0
- package/dist/modules/mcp/tools/apply/index.js +136 -0
- package/dist/modules/mcp/tools/apply/writeResult.js +37 -0
- package/dist/modules/mcp/tools/index.js +20 -148
- package/dist/modules/mcp/tools/operations/index.js +41 -0
- 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/elements/deleteElement.js +29 -0
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +41 -0
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +58 -0
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +65 -0
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +30 -0
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +49 -0
- 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 +39 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +25 -0
- 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 +119 -0
- package/dist/modules/mcp/tools/operations/schema/translator.js +215 -0
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +18 -0
- package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +42 -0
- package/dist/modules/mcp/tools/operations/schema/write.js +109 -0
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +21 -0
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +28 -0
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +24 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +21 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +28 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +24 -0
- 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 +27 -0
- package/dist/modules/mcp/tools/operations/style/shared.js +59 -0
- package/dist/modules/mcp/tools/operations/style/translator.js +101 -0
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +21 -0
- package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +22 -0
- package/dist/modules/mcp/tools/operations/style/write.js +108 -0
- package/dist/modules/mcp/tools/preview.js +37 -0
- package/dist/modules/mcp/tools/read.js +33 -0
- package/dist/modules/mcp/tools/screenshot.js +83 -0
- package/dist/modules/mcp/tools/search.js +115 -0
- package/dist/modules/mcp/tools/shared/tool.js +26 -0
- 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 +39 -0
- package/dist/modules/ssr/buildBody.js +2 -2
- package/dist/modules/ssr/handler.js +6 -4
- package/dist/modules/ssr/prepareRender.js +5 -5
- package/dist/modules/ssr/preview.js +106 -0
- package/dist/modules/ssr/registerExternalPlugins.js +1 -1
- package/dist/modules/ssr/streamBody.js +3 -3
- package/dist/modules/ssr/template.js +1 -1
- package/dist/modules/ssr/views/template.ejs +2 -0
- package/dist/plugins/compile.js +1 -1
- package/dist/plugins/copy.js +1 -1
- package/dist/plugins/manager.js +1 -1
- package/dist/server.js +34 -9
- package/dist/src/core/createServer.d.ts +5 -1
- package/dist/src/core/health.d.ts +10 -0
- package/dist/src/core/http/dispatcher.d.ts +7 -0
- package/dist/src/core/http/securityHeaders.d.ts +2 -0
- package/dist/src/core/http/stages/authRoutes.d.ts +4 -0
- package/dist/src/core/http/stages/health.d.ts +2 -0
- package/dist/src/core/http/stages/middlewares.d.ts +2 -0
- package/dist/src/core/http/stages/pluginAssets.d.ts +2 -0
- package/dist/src/core/http/stages/static.d.ts +5 -0
- package/dist/src/core/http/types.d.ts +19 -0
- package/dist/src/core/server/baseServer.d.ts +9 -0
- package/dist/src/core/server/mcpServer.d.ts +2 -0
- package/dist/src/core/server/ssrServer.d.ts +2 -0
- package/dist/src/core/services/mcp.d.ts +3 -0
- package/dist/src/core/services/preview.d.ts +2 -0
- package/dist/src/core/services/registry.d.ts +4 -0
- package/dist/src/core/services/resolve.d.ts +3 -0
- package/dist/src/core/services/rsc.d.ts +2 -0
- package/dist/src/core/services/ssr.d.ts +3 -0
- package/dist/src/core/transports.d.ts +2 -2
- package/dist/src/index.d.ts +12 -3
- package/dist/src/modules/ai/index.d.ts +1 -0
- package/dist/src/modules/ai/toolkit.d.ts +17 -0
- 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/builtinUtilities.d.ts +18 -0
- package/dist/src/modules/mcp/catalogs/cssCatalog.d.ts +14 -0
- 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/constants.d.ts +1 -0
- package/dist/src/modules/mcp/handler.d.ts +6 -3
- package/dist/src/modules/mcp/helpers/agentPrompt.d.ts +4 -0
- package/dist/src/modules/mcp/helpers/computeVersion.d.ts +1 -0
- package/dist/src/modules/mcp/helpers/guide.d.ts +3 -0
- package/dist/src/modules/mcp/helpers/index.d.ts +8 -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/opResult.d.ts +13 -0
- package/dist/src/modules/mcp/helpers/space.d.ts +105 -0
- package/dist/src/modules/mcp/helpers/uris.d.ts +28 -0
- package/dist/src/modules/mcp/index.d.ts +12 -5
- package/dist/src/modules/mcp/previewClient.d.ts +13 -0
- package/dist/src/modules/mcp/resources/canonical.d.ts +6 -0
- package/dist/src/modules/mcp/resources/core.d.ts +5 -0
- package/dist/src/modules/mcp/resources/envelope.d.ts +10 -0
- package/dist/src/modules/mcp/resources/index.d.ts +7 -10
- package/dist/src/modules/mcp/resources/primer.d.ts +7 -0
- package/dist/src/modules/mcp/resources/register.d.ts +6 -0
- package/dist/src/modules/mcp/resources/router.d.ts +6 -0
- package/dist/src/modules/mcp/resources/schema.d.ts +5 -0
- package/dist/src/modules/mcp/resources/style.d.ts +5 -0
- package/dist/src/modules/mcp/screenshotClient.d.ts +13 -0
- package/dist/src/modules/mcp/server.d.ts +21 -3
- package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +6 -0
- package/dist/src/modules/mcp/tools/apply/index.d.ts +420 -0
- package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +8 -0
- package/dist/src/modules/mcp/tools/index.d.ts +17 -6
- package/dist/src/modules/mcp/tools/operations/index.d.ts +828 -0
- 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/elements/deleteElement.d.ts +10 -0
- package/dist/src/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +22 -0
- package/dist/src/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +20 -0
- 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 +210 -0
- package/dist/src/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +14 -0
- 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 +77 -0
- package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +42 -0
- package/dist/src/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +37 -0
- 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 +14 -0
- package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +231 -0
- package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +115 -0
- package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +15 -0
- package/dist/src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +20 -0
- package/dist/src/modules/mcp/tools/operations/style/write.d.ts +12 -0
- package/dist/src/modules/mcp/tools/preview.d.ts +415 -0
- package/dist/src/modules/mcp/tools/read.d.ts +8 -0
- package/dist/src/modules/mcp/tools/screenshot.d.ts +420 -0
- package/dist/src/modules/mcp/tools/search.d.ts +15 -0
- package/dist/src/modules/mcp/tools/shared/tool.d.ts +50 -0
- 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 +417 -0
- package/dist/src/modules/mcp/types/aiSchema.d.ts +218 -0
- package/dist/src/modules/mcp/types/index.d.ts +4 -0
- package/dist/src/modules/mcp/types/previewTypes.d.ts +25 -0
- package/dist/src/modules/mcp/types/screenshotTypes.d.ts +29 -0
- package/dist/src/modules/mcp/types/toolTypes.d.ts +138 -0
- package/dist/src/modules/ssr/buildBody.d.ts +2 -2
- package/dist/src/modules/ssr/prepareRender.d.ts +2 -2
- package/dist/src/modules/ssr/preview.d.ts +16 -0
- package/dist/src/modules/ssr/streamBody.d.ts +2 -2
- package/package.json +16 -14
- package/dist/_virtual/_rolldown/runtime.js +0 -13
- package/dist/core/requestHandler.js +0 -126
- package/dist/modules/mcp/helpers.js +0 -75
- package/dist/modules/mcp/resources/glossary/binding.js +0 -73
- package/dist/modules/mcp/resources/glossary/collection.js +0 -76
- package/dist/modules/mcp/resources/glossary/displayMode.js +0 -50
- package/dist/modules/mcp/resources/glossary/element.js +0 -68
- package/dist/modules/mcp/resources/glossary/environment.js +0 -48
- package/dist/modules/mcp/resources/glossary/interaction.js +0 -62
- package/dist/modules/mcp/resources/glossary/page.js +0 -70
- package/dist/modules/mcp/resources/glossary/plugin.js +0 -96
- package/dist/modules/mcp/resources/glossary/resource.js +0 -75
- package/dist/modules/mcp/resources/glossary/schema.js +0 -69
- package/dist/modules/mcp/resources/glossary/schemaVariable.js +0 -60
- package/dist/modules/mcp/resources/glossary/segment.js +0 -59
- package/dist/modules/mcp/resources/glossary/space.js +0 -73
- package/dist/modules/mcp/resources/glossary/style.js +0 -81
- package/dist/modules/mcp/resources/glossary/styleSelector.js +0 -77
- package/dist/modules/mcp/resources/glossary/styleVariable.js +0 -72
- package/dist/modules/mcp/resources/index.js +0 -71
- package/dist/modules/mcp/resources/workflows/data.js +0 -49
- package/dist/modules/mcp/resources/workflows/elements.js +0 -53
- package/dist/modules/mcp/resources/workflows/segments.js +0 -55
- package/dist/modules/mcp/resources/workflows/styles.js +0 -91
- package/dist/modules/mcp/tools/collections/createCollection.js +0 -25
- package/dist/modules/mcp/tools/collections/createCollectionRecord.js +0 -27
- package/dist/modules/mcp/tools/collections/deleteCollection.js +0 -16
- package/dist/modules/mcp/tools/collections/deleteCollectionRecord.js +0 -16
- package/dist/modules/mcp/tools/collections/getCollection.js +0 -21
- package/dist/modules/mcp/tools/collections/getCollectionRecord.js +0 -25
- package/dist/modules/mcp/tools/collections/getCollectionRecords.js +0 -29
- package/dist/modules/mcp/tools/collections/getCollections.js +0 -19
- package/dist/modules/mcp/tools/collections/updateCollection.js +0 -28
- package/dist/modules/mcp/tools/collections/updateCollectionRecord.js +0 -31
- package/dist/modules/mcp/tools/docs/listResources.js +0 -16
- package/dist/modules/mcp/tools/docs/readResource.js +0 -23
- package/dist/modules/mcp/tools/plugins/addPlugin.js +0 -24
- package/dist/modules/mcp/tools/plugins/listPlugins.js +0 -20
- package/dist/modules/mcp/tools/plugins/removePlugin.js +0 -16
- package/dist/modules/mcp/tools/plugins/updatePlugin.js +0 -23
- package/dist/modules/mcp/tools/resources/addResource.js +0 -33
- package/dist/modules/mcp/tools/resources/getResource.js +0 -29
- package/dist/modules/mcp/tools/resources/getResources.js +0 -27
- package/dist/modules/mcp/tools/resources/moveResource.js +0 -30
- package/dist/modules/mcp/tools/resources/removeResource.js +0 -19
- package/dist/modules/mcp/tools/segment/createSegment.js +0 -27
- package/dist/modules/mcp/tools/segment/deleteSegment.js +0 -16
- package/dist/modules/mcp/tools/segment/getSegment.js +0 -19
- package/dist/modules/mcp/tools/segment/getSegments.js +0 -27
- package/dist/modules/mcp/tools/segment/schema/elements/createSegmentElement.js +0 -24
- package/dist/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.js +0 -19
- package/dist/modules/mcp/tools/segment/schema/elements/moveSegmentElement.js +0 -28
- package/dist/modules/mcp/tools/segment/schema/elements/updateSegmentElement.js +0 -23
- package/dist/modules/mcp/tools/segment/schema/variables/createSegmentVariable.js +0 -41
- package/dist/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.js +0 -19
- package/dist/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.js +0 -41
- package/dist/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.js +0 -34
- package/dist/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.js +0 -21
- package/dist/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.js +0 -34
- package/dist/modules/mcp/tools/segment/updateSegment.js +0 -30
- package/dist/modules/mcp/tools/space/schema/applyPreview.js +0 -33
- package/dist/modules/mcp/tools/space/schema/elements/cloneElement.js +0 -34
- package/dist/modules/mcp/tools/space/schema/elements/createElement.js +0 -50
- package/dist/modules/mcp/tools/space/schema/elements/deleteElement.js +0 -16
- package/dist/modules/mcp/tools/space/schema/elements/getElement.js +0 -17
- package/dist/modules/mcp/tools/space/schema/elements/getElements.js +0 -21
- package/dist/modules/mcp/tools/space/schema/elements/listElements.js +0 -28
- package/dist/modules/mcp/tools/space/schema/elements/moveElement.js +0 -27
- package/dist/modules/mcp/tools/space/schema/elements/updateElement.js +0 -49
- package/dist/modules/mcp/tools/space/schema/getSpaceSettings.js +0 -46
- package/dist/modules/mcp/tools/space/schema/pageFolders/createPageFolder.js +0 -24
- package/dist/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.js +0 -16
- package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolder.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolders.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.js +0 -28
- package/dist/modules/mcp/tools/space/schema/pages/createPage.js +0 -37
- package/dist/modules/mcp/tools/space/schema/pages/deletePage.js +0 -16
- package/dist/modules/mcp/tools/space/schema/pages/getPage.js +0 -28
- package/dist/modules/mcp/tools/space/schema/pages/getPageBySlug.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pages/getPages.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pages/updatePage.js +0 -25
- package/dist/modules/mcp/tools/space/schema/schemas.js +0 -53
- package/dist/modules/mcp/tools/space/schema/updateSpaceSettings.js +0 -23
- package/dist/modules/mcp/tools/space/schema/variables/createVariable.js +0 -38
- package/dist/modules/mcp/tools/space/schema/variables/deleteVariable.js +0 -16
- package/dist/modules/mcp/tools/space/schema/variables/getVariable.js +0 -17
- package/dist/modules/mcp/tools/space/schema/variables/getVariables.js +0 -17
- package/dist/modules/mcp/tools/space/schema/variables/updateVariable.js +0 -38
- package/dist/modules/mcp/tools/space/style/selectors/createStyleSelector.js +0 -37
- package/dist/modules/mcp/tools/space/style/selectors/deleteStyleSelector.js +0 -24
- package/dist/modules/mcp/tools/space/style/selectors/getStyleSelectors.js +0 -20
- package/dist/modules/mcp/tools/space/style/selectors/updateStyleSelector.js +0 -37
- package/dist/modules/mcp/tools/space/style/variables/createStyleVariable.js +0 -33
- package/dist/modules/mcp/tools/space/style/variables/deleteStyleVariable.js +0 -20
- package/dist/modules/mcp/tools/space/style/variables/getStyleVariable.js +0 -19
- package/dist/modules/mcp/tools/space/style/variables/getStyleVariables.js +0 -16
- package/dist/modules/mcp/tools/space/style/variables/updateStyleVariable.js +0 -33
- package/dist/package.js +0 -77
- package/dist/package.json.d.ts +0 -67
- package/dist/src/core/requestHandler.d.ts +0 -5
- package/dist/src/modules/mcp/helpers.d.ts +0 -9
- package/dist/src/modules/mcp/resources/glossary/binding.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/collection.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/displayMode.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/element.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/environment.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/interaction.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/page.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/plugin.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/resource.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/schema.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/schemaVariable.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/segment.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/space.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/style.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/styleSelector.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/styleVariable.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/data.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/elements.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/segments.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/styles.d.ts +0 -7
- package/dist/src/modules/mcp/tools/collections/createCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/createCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/deleteCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/deleteCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollectionRecords.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollections.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/index.d.ts +0 -10
- package/dist/src/modules/mcp/tools/collections/updateCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/updateCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/docs/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/docs/listResources.d.ts +0 -3
- package/dist/src/modules/mcp/tools/docs/readResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/addPlugin.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/index.d.ts +0 -5
- package/dist/src/modules/mcp/tools/plugins/listPlugins.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/removePlugin.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/updatePlugin.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/addResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/getResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/getResources.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/resources/moveResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/removeResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/createSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/deleteSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/getSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/getSegments.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/index.d.ts +0 -8
- package/dist/src/modules/mcp/tools/segment/schema/elements/createSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/elements/index.d.ts +0 -5
- package/dist/src/modules/mcp/tools/segment/schema/elements/moveSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/elements/updateSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/segment/schema/variables/createSegmentVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/variables/index.d.ts +0 -4
- package/dist/src/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/segment.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/style/index.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/style/variables/index.d.ts +0 -4
- package/dist/src/modules/mcp/tools/segment/style/variables/segmentStyleVariables.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/updateSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/space/schema/applyPreview.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/cloneElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/createElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/deleteElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/elements.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/schema/elements/getElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/getElements.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/index.d.ts +0 -9
- package/dist/src/modules/mcp/tools/space/schema/elements/listElements.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/moveElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/updateElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/getSpaceSettings.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/index.d.ts +0 -8
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/createPageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolders.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/pageFolders.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/createPage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/deletePage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/getPage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/getPageBySlug.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/getPages.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/index.d.ts +0 -7
- package/dist/src/modules/mcp/tools/space/schema/pages/pages.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/schema/pages/updatePage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/schemas.d.ts +0 -66
- package/dist/src/modules/mcp/tools/space/schema/updateSpaceSettings.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/createVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/deleteVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/getVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/getVariables.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/space/schema/variables/updateVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/variables.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/space.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/style/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/space/style/selectors/createStyleSelector.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/selectors/deleteStyleSelector.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/selectors/getStyleSelectors.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/selectors/index.d.ts +0 -5
- package/dist/src/modules/mcp/tools/space/style/selectors/styleSelectors.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/style/selectors/updateStyleSelector.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/createStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/deleteStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariables.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/space/style/variables/styleVariables.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/style/variables/updateStyleVariable.d.ts +0 -3
- /package/dist/src/{modules/mcp/helpers.test.d.ts → core/server/mcpServer.test.d.ts} +0 -0
- /package/dist/src/modules/{mcp/tools/collections/collections.test.d.ts → ai/toolkit.test.d.ts} +0 -0
- /package/dist/src/modules/mcp/{tools/plugins/plugins.test.d.ts → catalogs/builtinTransformers.test.d.ts} +0 -0
- /package/dist/src/modules/mcp/{tools/resources/resources.test.d.ts → helpers/log.test.d.ts} +0 -0
- /package/dist/src/modules/mcp/{tools/segment/schema/elements/segmentElements.test.d.ts → mcp.bench.d.ts} +0 -0
- /package/dist/src/modules/mcp/{tools/segment/schema/variables/segmentVariables.test.d.ts → mcp.test.d.ts} +0 -0
|
@@ -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 };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { reconcileParams } from "./paramSpec.js";
|
|
2
|
+
//#region src/modules/mcp/catalogs/builtinUtilities.ts
|
|
3
|
+
var BUILTIN_UTILITIES = {
|
|
4
|
+
delayTime: {
|
|
5
|
+
title: "Delay Time",
|
|
6
|
+
strictParams: true,
|
|
7
|
+
params: { time: {
|
|
8
|
+
type: "number",
|
|
9
|
+
description: "Milliseconds to wait before the next step runs. The key is \"time\" (not \"delay\")."
|
|
10
|
+
} }
|
|
11
|
+
},
|
|
12
|
+
twigTemplate: {
|
|
13
|
+
title: "Twig Template",
|
|
14
|
+
strictParams: true,
|
|
15
|
+
params: {
|
|
16
|
+
returnMode: {
|
|
17
|
+
type: "select",
|
|
18
|
+
description: "How the rendered template is returned.",
|
|
19
|
+
default: "text",
|
|
20
|
+
options: [
|
|
21
|
+
"text",
|
|
22
|
+
"json",
|
|
23
|
+
"jsonObject"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
template: {
|
|
27
|
+
type: "textarea",
|
|
28
|
+
description: "The Twig template string to render against the flow/global params."
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
webHook: {
|
|
33
|
+
title: "Webhook",
|
|
34
|
+
strictParams: true,
|
|
35
|
+
params: {
|
|
36
|
+
url: {
|
|
37
|
+
type: "text",
|
|
38
|
+
description: "The URL to call."
|
|
39
|
+
},
|
|
40
|
+
method: {
|
|
41
|
+
type: "select",
|
|
42
|
+
description: "HTTP method.",
|
|
43
|
+
default: "get",
|
|
44
|
+
options: [
|
|
45
|
+
"get",
|
|
46
|
+
"post",
|
|
47
|
+
"put",
|
|
48
|
+
"delete",
|
|
49
|
+
"patch",
|
|
50
|
+
"head"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
body: {
|
|
54
|
+
type: "textarea",
|
|
55
|
+
description: "Request body."
|
|
56
|
+
},
|
|
57
|
+
authorizationToken: {
|
|
58
|
+
type: "text",
|
|
59
|
+
description: "Value sent as the Authorization header."
|
|
60
|
+
},
|
|
61
|
+
credentials: {
|
|
62
|
+
type: "select",
|
|
63
|
+
description: "fetch credentials mode.",
|
|
64
|
+
default: "same-origin",
|
|
65
|
+
options: [
|
|
66
|
+
"include",
|
|
67
|
+
"omit",
|
|
68
|
+
"same-origin"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
/** The built-in utility for an action, or undefined when the action is not a known built-in utility. */
|
|
75
|
+
var getUtility = (action) => Object.hasOwn(BUILTIN_UTILITIES, action) ? BUILTIN_UTILITIES[action] : void 0;
|
|
76
|
+
/** Reconcile a `utility` action against the utility catalog: unknown keys dropped for a closed utility, then missing
|
|
77
|
+
* defaults filled. An unknown action yields unchanged params. */
|
|
78
|
+
var applyUtility = (action, params) => {
|
|
79
|
+
const utility = getUtility(action);
|
|
80
|
+
if (!utility) return {
|
|
81
|
+
known: false,
|
|
82
|
+
params
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
known: true,
|
|
86
|
+
params: reconcileParams(params, utility.params, utility.strictParams)
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
export { BUILTIN_UTILITIES, applyUtility, getUtility };
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import styleConstants from "@plitzi/sdk-shared/style/styleConstants";
|
|
2
|
+
//#region src/modules/mcp/catalogs/cssCatalog.ts
|
|
3
|
+
/** Every kebab-case CSS property Plitzi's style engine understands. Values written to a definition
|
|
4
|
+
* must use these exact keys — camelCase or unknown keys are rejected by the validator. */
|
|
5
|
+
var cssProperties = Array.from(new Set(Object.values(styleConstants))).sort();
|
|
6
|
+
var cssPropertySet = new Set(cssProperties);
|
|
7
|
+
var isCssProperty = (key) => cssPropertySet.has(key);
|
|
8
|
+
var toKebab = (key) => key.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
9
|
+
/** If a camelCase key maps to a known kebab-case property, return it — used to teach the agent the correct key. */
|
|
10
|
+
var suggestCssProperty = (key) => {
|
|
11
|
+
const kebab = toKebab(key);
|
|
12
|
+
return cssPropertySet.has(kebab) ? kebab : void 0;
|
|
13
|
+
};
|
|
14
|
+
var splitTokens = (value) => {
|
|
15
|
+
const tokens = [];
|
|
16
|
+
let depth = 0;
|
|
17
|
+
let current = "";
|
|
18
|
+
for (const ch of value.trim()) {
|
|
19
|
+
if (ch === "(") depth += 1;
|
|
20
|
+
else if (ch === ")") depth = Math.max(0, depth - 1);
|
|
21
|
+
if (/\s/.test(ch) && depth === 0) {
|
|
22
|
+
if (current) {
|
|
23
|
+
tokens.push(current);
|
|
24
|
+
current = "";
|
|
25
|
+
}
|
|
26
|
+
} else current += ch;
|
|
27
|
+
}
|
|
28
|
+
if (current) tokens.push(current);
|
|
29
|
+
return tokens;
|
|
30
|
+
};
|
|
31
|
+
var COMPOUND_SHORTHANDS = {
|
|
32
|
+
flex: [
|
|
33
|
+
"flex-grow",
|
|
34
|
+
"flex-shrink",
|
|
35
|
+
"flex-basis"
|
|
36
|
+
],
|
|
37
|
+
"flex-flow": ["flex-direction", "flex-wrap"],
|
|
38
|
+
background: [
|
|
39
|
+
"background-color",
|
|
40
|
+
"background-image",
|
|
41
|
+
"background-position",
|
|
42
|
+
"background-size",
|
|
43
|
+
"background-repeat"
|
|
44
|
+
],
|
|
45
|
+
font: [
|
|
46
|
+
"font-family",
|
|
47
|
+
"font-size",
|
|
48
|
+
"font-weight",
|
|
49
|
+
"line-height"
|
|
50
|
+
],
|
|
51
|
+
transition: [
|
|
52
|
+
"transition-property",
|
|
53
|
+
"transition-duration",
|
|
54
|
+
"transition-timing-function",
|
|
55
|
+
"transition-delay"
|
|
56
|
+
],
|
|
57
|
+
animation: [
|
|
58
|
+
"animation-name",
|
|
59
|
+
"animation-duration",
|
|
60
|
+
"animation-timing-function",
|
|
61
|
+
"animation-delay",
|
|
62
|
+
"animation-iteration-count"
|
|
63
|
+
],
|
|
64
|
+
grid: [
|
|
65
|
+
"grid-template-columns",
|
|
66
|
+
"grid-template-rows",
|
|
67
|
+
"grid-template-areas"
|
|
68
|
+
],
|
|
69
|
+
"grid-template": [
|
|
70
|
+
"grid-template-columns",
|
|
71
|
+
"grid-template-rows",
|
|
72
|
+
"grid-template-areas"
|
|
73
|
+
],
|
|
74
|
+
"grid-area": [
|
|
75
|
+
"grid-row-start",
|
|
76
|
+
"grid-column-start",
|
|
77
|
+
"grid-row-end",
|
|
78
|
+
"grid-column-end"
|
|
79
|
+
],
|
|
80
|
+
"place-content": ["align-content", "justify-content"],
|
|
81
|
+
"place-items": ["align-items", "justify-items"],
|
|
82
|
+
"place-self": ["align-self", "justify-self"],
|
|
83
|
+
"list-style": [
|
|
84
|
+
"list-style-type",
|
|
85
|
+
"list-style-position",
|
|
86
|
+
"list-style-image"
|
|
87
|
+
],
|
|
88
|
+
"text-decoration": [
|
|
89
|
+
"text-decoration-line",
|
|
90
|
+
"text-decoration-color",
|
|
91
|
+
"text-decoration-style"
|
|
92
|
+
],
|
|
93
|
+
outline: [
|
|
94
|
+
"outline-width",
|
|
95
|
+
"outline-style",
|
|
96
|
+
"outline-color"
|
|
97
|
+
],
|
|
98
|
+
columns: ["column-width", "column-count"],
|
|
99
|
+
overflow: ["overflow-x", "overflow-y"]
|
|
100
|
+
};
|
|
101
|
+
/** The atomic longhands to write instead of a compound shorthand, or undefined when the key is not a compound
|
|
102
|
+
* shorthand. `flex` layout in particular is NOT `display` + `flex-direction` (those are their own properties). */
|
|
103
|
+
var compoundLonghands = (key) => Object.hasOwn(COMPOUND_SHORTHANDS, key) ? COMPOUND_SHORTHANDS[key] : void 0;
|
|
104
|
+
var SIDES = [
|
|
105
|
+
"top",
|
|
106
|
+
"right",
|
|
107
|
+
"bottom",
|
|
108
|
+
"left"
|
|
109
|
+
];
|
|
110
|
+
var box4 = (tokens) => {
|
|
111
|
+
const [a, b = a, c = a, d = b] = tokens;
|
|
112
|
+
return [
|
|
113
|
+
a,
|
|
114
|
+
b,
|
|
115
|
+
c,
|
|
116
|
+
d
|
|
117
|
+
];
|
|
118
|
+
};
|
|
119
|
+
var radius4 = (tokens) => {
|
|
120
|
+
const [a, b = a, c = a, d = b] = tokens;
|
|
121
|
+
return [
|
|
122
|
+
a,
|
|
123
|
+
b,
|
|
124
|
+
c,
|
|
125
|
+
d
|
|
126
|
+
];
|
|
127
|
+
};
|
|
128
|
+
var BORDER_STYLES = /* @__PURE__ */ new Set([
|
|
129
|
+
"none",
|
|
130
|
+
"hidden",
|
|
131
|
+
"dotted",
|
|
132
|
+
"dashed",
|
|
133
|
+
"solid",
|
|
134
|
+
"double",
|
|
135
|
+
"groove",
|
|
136
|
+
"ridge",
|
|
137
|
+
"inset",
|
|
138
|
+
"outset"
|
|
139
|
+
]);
|
|
140
|
+
var BORDER_WIDTH_KEYWORDS = /* @__PURE__ */ new Set([
|
|
141
|
+
"thin",
|
|
142
|
+
"medium",
|
|
143
|
+
"thick"
|
|
144
|
+
]);
|
|
145
|
+
var LENGTH_RE = /^-?[\d.]+([a-z%]*)$/;
|
|
146
|
+
var classifyBorderToken = (token) => {
|
|
147
|
+
if (BORDER_STYLES.has(token)) return "style";
|
|
148
|
+
if (BORDER_WIDTH_KEYWORDS.has(token) || LENGTH_RE.test(token)) return "width";
|
|
149
|
+
return "color";
|
|
150
|
+
};
|
|
151
|
+
var expandBorder = (key, value, out) => {
|
|
152
|
+
const sides = key === "border" ? SIDES : [key.slice(7)];
|
|
153
|
+
for (const token of splitTokens(value)) {
|
|
154
|
+
const kind = classifyBorderToken(token);
|
|
155
|
+
for (const side of sides) out[`border-${side}-${kind}`] = token;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
var BORDER_SIDE_KEYS = new Set(SIDES.map((s) => `border-${s}`));
|
|
159
|
+
var expandOne = (key, raw, out) => {
|
|
160
|
+
const value = String(raw);
|
|
161
|
+
if (key === "padding" || key === "margin" || key === "inset") {
|
|
162
|
+
const [t, r, b, l] = box4(splitTokens(value));
|
|
163
|
+
const prefix = key === "inset" ? "" : `${key}-`;
|
|
164
|
+
out[`${prefix}top`] = t;
|
|
165
|
+
out[`${prefix}right`] = r;
|
|
166
|
+
out[`${prefix}bottom`] = b;
|
|
167
|
+
out[`${prefix}left`] = l;
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
if (key === "border-radius" && !value.includes("/")) {
|
|
171
|
+
const [tl, tr, br, bl] = radius4(splitTokens(value));
|
|
172
|
+
const corners = [
|
|
173
|
+
["top-left", tl],
|
|
174
|
+
["top-right", tr],
|
|
175
|
+
["bottom-right", br],
|
|
176
|
+
["bottom-left", bl]
|
|
177
|
+
];
|
|
178
|
+
for (const [corner, v] of corners) out[`border-${corner}-radius`] = v;
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
if (key === "gap") {
|
|
182
|
+
const [row, col = row] = splitTokens(value);
|
|
183
|
+
out["row-gap"] = row;
|
|
184
|
+
out["column-gap"] = col;
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
if (key === "border" || BORDER_SIDE_KEYS.has(key)) {
|
|
188
|
+
expandBorder(key, value, out);
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
return false;
|
|
192
|
+
};
|
|
193
|
+
/** Expand supported CSS shorthands to their longhand keys. Explicit longhands in the same map win over any
|
|
194
|
+
* expansion (so `{ padding: 8, padding-left: 0 }` keeps padding-left: 0). Unrecognized keys pass through. */
|
|
195
|
+
var expandShorthand = (css) => {
|
|
196
|
+
const expanded = {};
|
|
197
|
+
const direct = {};
|
|
198
|
+
for (const [key, value] of Object.entries(css)) if (!expandOne(key, value, expanded)) direct[key] = value;
|
|
199
|
+
return {
|
|
200
|
+
...expanded,
|
|
201
|
+
...direct
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
//#endregion
|
|
205
|
+
export { COMPOUND_SHORTHANDS, compoundLonghands, cssProperties, expandShorthand, isCssProperty, suggestCssProperty };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { BUILTIN_GLOBAL_CALLBACKS } from "./builtinCallbacks.js";
|
|
2
|
+
import { BUILTIN_ELEMENT_CALLBACKS } from "./builtinElementCallbacks.js";
|
|
3
|
+
import { BUILTIN_UTILITIES } from "./builtinUtilities.js";
|
|
4
|
+
import { transformerCatalog } from "./builtinTransformers.js";
|
|
5
|
+
//#region src/modules/mcp/catalogs/observed.ts
|
|
6
|
+
var INTERACTION_NOTE = "Interaction actions observed on this space, grouped by node type. A flow is a trigger followed by ordered callbacks/utilities; write one with upsertInteractionFlow. Names not listed may still be valid plugin actions.";
|
|
7
|
+
var GLOBAL_CALLBACKS_NOTE = "Built-in global callbacks always available in every space. A globalCallback is registered on its SOURCE MODULE, so its node `elementId` is the listed `source` (e.g. \"space\" for addNotification) — NOT the element that hosts the flow. Omit `elementId` and the MCP sets the right source and fills the param defaults for you. Use ONLY the params listed under each callback (with the exact spelling shown) — for addNotification the visible text goes in `content`; there is no title/message/type param. When strictParams is true, any other key is rejected.";
|
|
8
|
+
var ELEMENT_CALLBACKS_NOTE = "Built-in `callback`-type actions every element registers on ITSELF. Unlike a globalCallback, an element callback runs against a real element, so its node `elementId` is that element (the flow host by default, or another element to act on) and its nodeType is \"callback\". `setState` here changes the element's own attribute/state (params category/key/value/revertOnFinish) — NOT the global state setState (which is a globalCallback on source \"state\" with params key/type/value). Set revertOnFinish:true for a TEMPORARY change (e.g. a \"loading…\" label): it is undone automatically when the flow finishes, so you do NOT add manual restore steps. A specific element type may register more callbacks beyond these defaults.";
|
|
9
|
+
var UTILITIES_NOTE = "Built-in `utility`-type actions (no element/source module). Use nodeType \"utility\". Use the EXACT param names — e.g. delayTime waits `time` milliseconds (not `delay`).";
|
|
10
|
+
var toParamInfo = (params) => Object.entries(params).map(([name, spec]) => ({
|
|
11
|
+
name,
|
|
12
|
+
type: spec.type,
|
|
13
|
+
description: spec.description,
|
|
14
|
+
...spec.default !== void 0 ? { default: spec.default } : {},
|
|
15
|
+
...spec.options ? { options: spec.options } : {},
|
|
16
|
+
...spec.when ? { conditional: true } : {}
|
|
17
|
+
}));
|
|
18
|
+
var builtinGlobalCallbacks = () => Object.entries(BUILTIN_GLOBAL_CALLBACKS).map(([action, { source, title, strictParams, params }]) => ({
|
|
19
|
+
action,
|
|
20
|
+
source,
|
|
21
|
+
title,
|
|
22
|
+
strictParams,
|
|
23
|
+
params: toParamInfo(params)
|
|
24
|
+
}));
|
|
25
|
+
var builtinElementCallbacks = () => Object.entries(BUILTIN_ELEMENT_CALLBACKS).map(([action, { title, strictParams, params }]) => ({
|
|
26
|
+
action,
|
|
27
|
+
title,
|
|
28
|
+
strictParams,
|
|
29
|
+
params: toParamInfo(params)
|
|
30
|
+
}));
|
|
31
|
+
var builtinUtilities = () => Object.entries(BUILTIN_UTILITIES).map(([action, { title, strictParams, params }]) => ({
|
|
32
|
+
action,
|
|
33
|
+
title,
|
|
34
|
+
strictParams,
|
|
35
|
+
params: toParamInfo(params)
|
|
36
|
+
}));
|
|
37
|
+
var DATA_SOURCE_NOTE = "Data-source paths and binding targets observed on this space. Bind a source to an element field with upsertBinding (category attributes|style|initialState). Paths not listed may still be valid. A binding may post-process its value through `transformers` (see below) and be gated by a `when` QueryBuilder guard.";
|
|
38
|
+
var DATA_SOURCE_SCOPE_NOTE = "SCOPE: an element source named `<type>_<idRef>` (e.g. `apiContainer_products`, `list_food-list`) is provided by that element to its DESCENDANTS ONLY — the provider wraps its subtree in the source’s scope, so only elements INSIDE the provider can bind to it. Binding a sibling or unrelated element to it is schema-valid but broken at runtime (the source is not in scope), and validate/apply REJECT it as an error. To consume `apiContainer_x.data`, the bound element must live under that apiContainer. Module sources (no `<type>_<idRef>` head — e.g. state/space/navigation/auth/collection) are global and bindable anywhere.";
|
|
39
|
+
var TRANSFORMERS_NOTE = "Built-in transformers that post-process a binding value before it reaches the field: `source → t₁ → t₂ → field`. Set them on a binding as `transformers: [{ action, params }]` (params are strings). The runtime resolves each by its `action` alone, so an UNKNOWN action is silently skipped (the value passes through unchanged) — use the exact action names below. Common formatting is `twigTemplate` (the value is the {{source}} token, not {{value}}).";
|
|
40
|
+
var buildInteractionCatalog = (schema) => {
|
|
41
|
+
const actions = {};
|
|
42
|
+
const flows = /* @__PURE__ */ new Set();
|
|
43
|
+
for (const el of Object.values(schema.flat)) for (const node of Object.values(el.definition.interactions ?? {})) {
|
|
44
|
+
(actions[node.type] ??= /* @__PURE__ */ new Set()).add(node.action);
|
|
45
|
+
flows.add(node.flowId || node.id);
|
|
46
|
+
}
|
|
47
|
+
const grouped = {};
|
|
48
|
+
for (const [nodeType, set] of Object.entries(actions)) grouped[nodeType] = [...set].sort();
|
|
49
|
+
return {
|
|
50
|
+
note: INTERACTION_NOTE,
|
|
51
|
+
actions: grouped,
|
|
52
|
+
globalCallbacksNote: GLOBAL_CALLBACKS_NOTE,
|
|
53
|
+
globalCallbacks: builtinGlobalCallbacks(),
|
|
54
|
+
elementCallbacksNote: ELEMENT_CALLBACKS_NOTE,
|
|
55
|
+
elementCallbacks: builtinElementCallbacks(),
|
|
56
|
+
utilitiesNote: UTILITIES_NOTE,
|
|
57
|
+
utilities: builtinUtilities(),
|
|
58
|
+
flowCount: flows.size
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
var buildDataSourceCatalog = (schema) => {
|
|
62
|
+
const sources = /* @__PURE__ */ new Set();
|
|
63
|
+
const targets = {};
|
|
64
|
+
for (const el of Object.values(schema.flat)) for (const [category, list] of Object.entries(el.definition.bindings ?? {})) for (const binding of list) {
|
|
65
|
+
sources.add(binding.source);
|
|
66
|
+
(targets[category] ??= /* @__PURE__ */ new Set()).add(binding.to);
|
|
67
|
+
}
|
|
68
|
+
const groupedTargets = {};
|
|
69
|
+
for (const [category, set] of Object.entries(targets)) groupedTargets[category] = [...set].sort();
|
|
70
|
+
return {
|
|
71
|
+
note: DATA_SOURCE_NOTE,
|
|
72
|
+
scopeNote: DATA_SOURCE_SCOPE_NOTE,
|
|
73
|
+
sources: [...sources].sort(),
|
|
74
|
+
targets: groupedTargets,
|
|
75
|
+
transformersNote: TRANSFORMERS_NOTE,
|
|
76
|
+
transformers: transformerCatalog()
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
var observedInteractionActions = (schema) => {
|
|
80
|
+
const actions = /* @__PURE__ */ new Set();
|
|
81
|
+
for (const el of Object.values(schema.flat)) for (const node of Object.values(el.definition.interactions ?? {})) actions.add(node.action);
|
|
82
|
+
return actions;
|
|
83
|
+
};
|
|
84
|
+
var observedDataSources = (schema) => {
|
|
85
|
+
const sources = /* @__PURE__ */ new Set();
|
|
86
|
+
for (const el of Object.values(schema.flat)) for (const list of Object.values(el.definition.bindings ?? {})) for (const binding of list) sources.add(binding.source);
|
|
87
|
+
return sources;
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
export { buildDataSourceCatalog, buildInteractionCatalog, observedDataSources, observedInteractionActions };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { hasValidToken } from "@plitzi/sdk-shared/helpers/twigWrapper";
|
|
2
|
+
//#region src/modules/mcp/catalogs/paramSpec.ts
|
|
3
|
+
/** Declared params the agent supplied that end up HIDDEN because their own `when` guard is false against the
|
|
4
|
+
* effective params — they are silently ignored (e.g. a global setState `value` with no `type`, or an
|
|
5
|
+
* addNotification `autoDismissTimeout` with autoDismiss:false). Evaluated against the effective params so a param
|
|
6
|
+
* the default fills in (e.g. category:"attribute") does not false-report a value as hidden. */
|
|
7
|
+
var hiddenParams = (provided, effective, spec) => {
|
|
8
|
+
const hidden = [];
|
|
9
|
+
for (const [key, param] of Object.entries(spec)) if (param.when && provided[key] !== void 0 && !param.when(effective)) hidden.push(key);
|
|
10
|
+
return hidden;
|
|
11
|
+
};
|
|
12
|
+
/** Declared params marked `required` that the agent did NOT supply, and whose `when` guard holds against the
|
|
13
|
+
* effective params (so they are actually in play). Evaluated against the effective params so a required param
|
|
14
|
+
* gated by a companion (e.g. setState `value`, shown only once `category` is set) is not reported when its guard
|
|
15
|
+
* is not met. */
|
|
16
|
+
var missingRequiredParams = (provided, effective, spec) => {
|
|
17
|
+
const missing = [];
|
|
18
|
+
for (const [key, param] of Object.entries(spec)) if (param.required && provided[key] === void 0 && (!param.when || param.when(effective))) missing.push(key);
|
|
19
|
+
return missing;
|
|
20
|
+
};
|
|
21
|
+
var isNumeric = (value) => value.trim() !== "" && Number.isFinite(Number(value));
|
|
22
|
+
var isBindingToken = (value) => typeof value === "string" && hasValidToken(value);
|
|
23
|
+
var matchesType = (value, param) => {
|
|
24
|
+
switch (param.type) {
|
|
25
|
+
case "boolean": return typeof value === "boolean";
|
|
26
|
+
case "number": return typeof value === "number" || typeof value === "string" && isNumeric(value);
|
|
27
|
+
case "select": return typeof value === "string" && (!param.options || param.options.includes(value));
|
|
28
|
+
case "scalar": return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
29
|
+
case "text":
|
|
30
|
+
case "textarea": return typeof value === "string";
|
|
31
|
+
default: return true;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
/** Declared params the agent supplied whose value is the WRONG type for the catalog — the check that catches a
|
|
35
|
+
* malformed node the unknown/missing/hidden checks miss (a boolean stored as a string, a select value not in its
|
|
36
|
+
* options, a leftover `null`). Only params actually in play are checked: undefined values (the param is absent) and
|
|
37
|
+
* params hidden by their own `when` guard against the effective params are skipped, so this never fires on a param
|
|
38
|
+
* that is not really used. Callers gate this to CLOSED (strict) catalogs, whose types we own authoritatively. */
|
|
39
|
+
var invalidParams = (provided, effective, spec) => {
|
|
40
|
+
const invalid = [];
|
|
41
|
+
for (const [key, param] of Object.entries(spec)) {
|
|
42
|
+
const value = provided[key];
|
|
43
|
+
if (value === void 0 || isBindingToken(value) || param.when && !param.when(effective)) continue;
|
|
44
|
+
if (!matchesType(value, param)) invalid.push({
|
|
45
|
+
key,
|
|
46
|
+
expected: param.type,
|
|
47
|
+
got: value === null ? "null" : typeof value,
|
|
48
|
+
...param.options ? { options: param.options } : {}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return invalid;
|
|
52
|
+
};
|
|
53
|
+
/** Reconcile supplied params to a catalog schema: drop unknown keys when the set is CLOSED (strict), then fill the
|
|
54
|
+
* builder's defaults for any declared param the agent omitted whose `when` guard holds. Mirrors what the builder
|
|
55
|
+
* stores, so the persisted node round-trips cleanly. */
|
|
56
|
+
var reconcileParams = (params, spec, strict) => {
|
|
57
|
+
const next = {};
|
|
58
|
+
for (const [key, value] of Object.entries(params)) {
|
|
59
|
+
if (strict && !(key in spec)) continue;
|
|
60
|
+
next[key] = value;
|
|
61
|
+
}
|
|
62
|
+
for (const [key, param] of Object.entries(spec)) {
|
|
63
|
+
if (param.default === void 0 || next[key] !== void 0 || param.when && !param.when(next)) continue;
|
|
64
|
+
next[key] = param.default;
|
|
65
|
+
}
|
|
66
|
+
return next;
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
export { hiddenParams, invalidParams, missingRequiredParams, reconcileParams };
|