@plitzi/sdk-mcp 0.33.0
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 +15 -0
- package/README.md +175 -0
- package/dist/createServer.d.ts +11 -0
- package/dist/createServer.js +36 -0
- package/dist/createServer.test.d.ts +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +21 -0
- package/dist/modules/ai/AIEngine.d.ts +20 -0
- package/dist/modules/ai/AIEngine.js +120 -0
- package/dist/modules/ai/index.d.ts +4 -0
- package/dist/modules/ai/toolkit.d.ts +17 -0
- package/dist/modules/ai/toolkit.js +59 -0
- package/dist/modules/ai/toolkit.test.d.ts +1 -0
- package/dist/modules/mcp/apps/apps.test.d.ts +1 -0
- package/dist/modules/mcp/apps/example/index.d.ts +8 -0
- package/dist/modules/mcp/apps/example/view/index.tsx +70 -0
- package/dist/modules/mcp/apps/index.d.ts +11 -0
- package/dist/modules/mcp/apps/index.js +16 -0
- package/dist/modules/mcp/apps/render/index.d.ts +4 -0
- package/dist/modules/mcp/apps/render/index.js +17 -0
- package/dist/modules/mcp/apps/render/styles.d.ts +10 -0
- package/dist/modules/mcp/apps/render/styles.js +54 -0
- package/dist/modules/mcp/apps/render/styles.test.d.ts +1 -0
- package/dist/modules/mcp/apps/render/view/heldBatch.ts +107 -0
- package/dist/modules/mcp/apps/render/view/index.tsx +314 -0
- package/dist/modules/mcp/apps/render/view/streamProgress.ts +137 -0
- package/dist/modules/mcp/apps/shared/assets.d.ts +10 -0
- package/dist/modules/mcp/apps/shared/assets.js +10 -0
- package/dist/modules/mcp/apps/shared/bundle.d.ts +4 -0
- package/dist/modules/mcp/apps/shared/bundle.js +23 -0
- package/dist/modules/mcp/apps/shared/index.d.ts +3 -0
- package/dist/modules/mcp/apps/shared/page.d.ts +2 -0
- package/dist/modules/mcp/apps/shared/page.js +34 -0
- package/dist/modules/mcp/apps/shared/registerApp.d.ts +5 -0
- package/dist/modules/mcp/apps/shared/registerApp.js +43 -0
- package/dist/modules/mcp/apps/shared/resolve.d.ts +1 -0
- package/dist/modules/mcp/apps/shared/resolve.js +5 -0
- package/dist/modules/mcp/apps/shared/shell.ejs +59 -0
- package/dist/modules/mcp/apps/shared/zodEnglishOnly.d.ts +4 -0
- package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +23 -0
- package/dist/modules/mcp/catalogs/builtinCallbacks.d.ts +19 -0
- package/dist/modules/mcp/catalogs/builtinCallbacks.js +139 -0
- package/dist/modules/mcp/catalogs/builtinComponents.d.ts +4 -0
- package/dist/modules/mcp/catalogs/builtinComponents.js +165 -0
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.d.ts +17 -0
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +50 -0
- package/dist/modules/mcp/catalogs/builtinTransformers.d.ts +28 -0
- package/dist/modules/mcp/catalogs/builtinTransformers.js +148 -0
- package/dist/modules/mcp/catalogs/builtinTransformers.test.d.ts +1 -0
- package/dist/modules/mcp/catalogs/builtinUtilities.d.ts +15 -0
- package/dist/modules/mcp/catalogs/builtinUtilities.js +90 -0
- package/dist/modules/mcp/catalogs/cssCatalog/border.d.ts +4 -0
- package/dist/modules/mcp/catalogs/cssCatalog/border.js +30 -0
- package/dist/modules/mcp/catalogs/cssCatalog/box.d.ts +4 -0
- package/dist/modules/mcp/catalogs/cssCatalog/box.js +31 -0
- package/dist/modules/mcp/catalogs/cssCatalog/cssCatalog.test.d.ts +1 -0
- package/dist/modules/mcp/catalogs/cssCatalog/helpers.d.ts +34 -0
- package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +185 -0
- package/dist/modules/mcp/catalogs/cssCatalog/index.d.ts +18 -0
- package/dist/modules/mcp/catalogs/cssCatalog/index.js +131 -0
- package/dist/modules/mcp/catalogs/cssCatalog/layout.d.ts +9 -0
- package/dist/modules/mcp/catalogs/cssCatalog/layout.js +99 -0
- package/dist/modules/mcp/catalogs/cssCatalog/visual.d.ts +8 -0
- package/dist/modules/mcp/catalogs/cssCatalog/visual.js +147 -0
- package/dist/modules/mcp/catalogs/index.d.ts +9 -0
- package/dist/modules/mcp/catalogs/observed.d.ts +46 -0
- package/dist/modules/mcp/catalogs/observed.js +90 -0
- package/dist/modules/mcp/catalogs/paramSpec.d.ts +39 -0
- package/dist/modules/mcp/catalogs/paramSpec.js +69 -0
- package/dist/modules/mcp/catalogs/registry.d.ts +35 -0
- package/dist/modules/mcp/catalogs/registry.js +89 -0
- package/dist/modules/mcp/e2e/connector.test.d.ts +1 -0
- package/dist/modules/mcp/e2e/host.test.d.ts +1 -0
- package/dist/modules/mcp/e2e/index.d.ts +6 -0
- package/dist/modules/mcp/e2e/mcpEndpoint.d.ts +27 -0
- package/dist/modules/mcp/e2e/oauthConnector.test.d.ts +1 -0
- package/dist/modules/mcp/e2e/postMessageChannel.d.ts +22 -0
- package/dist/modules/mcp/e2e/renderingHost.d.ts +39 -0
- package/dist/modules/mcp/handler.d.ts +22 -0
- package/dist/modules/mcp/handler.js +83 -0
- package/dist/modules/mcp/helpers/agentPrompt.d.ts +4 -0
- package/dist/modules/mcp/helpers/agentPrompt.js +104 -0
- package/dist/modules/mcp/helpers/computeVersion.d.ts +1 -0
- package/dist/modules/mcp/helpers/computeVersion.js +16 -0
- package/dist/modules/mcp/helpers/guide.d.ts +4 -0
- package/dist/modules/mcp/helpers/guide.js +608 -0
- package/dist/modules/mcp/helpers/index.d.ts +8 -0
- package/dist/modules/mcp/helpers/interactions.d.ts +30 -0
- package/dist/modules/mcp/helpers/interactions.js +123 -0
- package/dist/modules/mcp/helpers/log.d.ts +8 -0
- package/dist/modules/mcp/helpers/log.js +64 -0
- package/dist/modules/mcp/helpers/log.test.d.ts +1 -0
- package/dist/modules/mcp/helpers/opResult.d.ts +13 -0
- package/dist/modules/mcp/helpers/opResult.js +18 -0
- package/dist/modules/mcp/helpers/space.d.ts +126 -0
- package/dist/modules/mcp/helpers/space.js +314 -0
- package/dist/modules/mcp/helpers/uris.d.ts +33 -0
- package/dist/modules/mcp/helpers/uris.js +50 -0
- package/dist/modules/mcp/index.d.ts +13 -0
- package/dist/modules/mcp/mcp.bench.d.ts +1 -0
- package/dist/modules/mcp/previewClient.d.ts +13 -0
- package/dist/modules/mcp/previewClient.js +31 -0
- package/dist/modules/mcp/proxy/config.d.ts +20 -0
- package/dist/modules/mcp/proxy/config.js +62 -0
- package/dist/modules/mcp/proxy/endpoint.test.d.ts +1 -0
- package/dist/modules/mcp/proxy/fetch.d.ts +18 -0
- package/dist/modules/mcp/proxy/fetch.js +91 -0
- package/dist/modules/mcp/proxy/grant.d.ts +25 -0
- package/dist/modules/mcp/proxy/grant.js +67 -0
- package/dist/modules/mcp/proxy/guard.d.ts +6 -0
- package/dist/modules/mcp/proxy/guard.js +38 -0
- package/dist/modules/mcp/proxy/handler.d.ts +8 -0
- package/dist/modules/mcp/proxy/handler.js +99 -0
- package/dist/modules/mcp/proxy/index.d.ts +8 -0
- package/dist/modules/mcp/proxy/payload.d.ts +8 -0
- package/dist/modules/mcp/proxy/payload.js +29 -0
- package/dist/modules/mcp/proxy/proxy.test.d.ts +1 -0
- package/dist/modules/mcp/proxy/rewrite.d.ts +18 -0
- package/dist/modules/mcp/proxy/rewrite.js +138 -0
- package/dist/modules/mcp/proxy/sign.d.ts +6 -0
- package/dist/modules/mcp/proxy/sign.js +15 -0
- package/dist/modules/mcp/proxy/types.d.ts +45 -0
- package/dist/modules/mcp/proxy/types.js +9 -0
- package/dist/modules/mcp/proxy/wiring.test.d.ts +1 -0
- package/dist/modules/mcp/resources/canonical.d.ts +6 -0
- package/dist/modules/mcp/resources/canonical.js +30 -0
- package/dist/modules/mcp/resources/connectors.d.ts +22 -0
- package/dist/modules/mcp/resources/connectors.js +46 -0
- package/dist/modules/mcp/resources/core.d.ts +5 -0
- package/dist/modules/mcp/resources/core.js +18 -0
- package/dist/modules/mcp/resources/envelope.d.ts +10 -0
- package/dist/modules/mcp/resources/envelope.js +14 -0
- package/dist/modules/mcp/resources/index.d.ts +9 -0
- package/dist/modules/mcp/resources/primer.d.ts +7 -0
- package/dist/modules/mcp/resources/primer.js +33 -0
- package/dist/modules/mcp/resources/register.d.ts +10 -0
- package/dist/modules/mcp/resources/register.js +205 -0
- package/dist/modules/mcp/resources/renderGuide.d.ts +10 -0
- package/dist/modules/mcp/resources/renderGuide.js +451 -0
- package/dist/modules/mcp/resources/router.d.ts +10 -0
- package/dist/modules/mcp/resources/router.js +39 -0
- package/dist/modules/mcp/resources/schema.d.ts +5 -0
- package/dist/modules/mcp/resources/schema.js +43 -0
- package/dist/modules/mcp/resources/style.d.ts +5 -0
- package/dist/modules/mcp/resources/style.js +34 -0
- package/dist/modules/mcp/screenshotClient.d.ts +13 -0
- package/dist/modules/mcp/screenshotClient.js +47 -0
- package/dist/modules/mcp/server.d.ts +31 -0
- package/dist/modules/mcp/server.js +127 -0
- package/dist/modules/mcp/tests/apply.test.d.ts +1 -0
- package/dist/modules/mcp/tests/bindings.test.d.ts +1 -0
- package/dist/modules/mcp/tests/connectors.test.d.ts +1 -0
- package/dist/modules/mcp/tests/css.test.d.ts +1 -0
- package/dist/modules/mcp/tests/helpers.d.ts +13 -0
- package/dist/modules/mcp/tests/interactions.test.d.ts +1 -0
- package/dist/modules/mcp/tests/pages.test.d.ts +1 -0
- package/dist/modules/mcp/tests/reads.test.d.ts +1 -0
- package/dist/modules/mcp/tests/schemaIds.test.d.ts +1 -0
- package/dist/modules/mcp/tests/search.test.d.ts +1 -0
- package/dist/modules/mcp/tests/skill.test.d.ts +1 -0
- package/dist/modules/mcp/tests/styles.test.d.ts +1 -0
- package/dist/modules/mcp/tests/tools.test.d.ts +1 -0
- package/dist/modules/mcp/tests/validation.test.d.ts +1 -0
- package/dist/modules/mcp/tools/apply/dispatch.d.ts +6 -0
- package/dist/modules/mcp/tools/apply/dispatch.js +128 -0
- package/dist/modules/mcp/tools/apply/index.d.ts +656 -0
- package/dist/modules/mcp/tools/apply/index.js +161 -0
- package/dist/modules/mcp/tools/apply/writeResult.d.ts +8 -0
- package/dist/modules/mcp/tools/apply/writeResult.js +37 -0
- package/dist/modules/mcp/tools/index.d.ts +18 -0
- package/dist/modules/mcp/tools/index.js +24 -0
- package/dist/modules/mcp/tools/operations/connectors/deleteConnector.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/connectors/deleteConnector.js +20 -0
- package/dist/modules/mcp/tools/operations/connectors/index.d.ts +188 -0
- package/dist/modules/mcp/tools/operations/connectors/index.js +12 -0
- package/dist/modules/mcp/tools/operations/connectors/manifest.d.ts +89 -0
- package/dist/modules/mcp/tools/operations/connectors/manifest.js +70 -0
- package/dist/modules/mcp/tools/operations/connectors/patchConnector.d.ts +94 -0
- package/dist/modules/mcp/tools/operations/connectors/patchConnector.js +58 -0
- package/dist/modules/mcp/tools/operations/connectors/upsertConnector.d.ts +98 -0
- package/dist/modules/mcp/tools/operations/connectors/upsertConnector.js +64 -0
- package/dist/modules/mcp/tools/operations/index.d.ts +2235 -0
- package/dist/modules/mcp/tools/operations/index.js +55 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +17 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +32 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +25 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +36 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +27 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +47 -0
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +10 -0
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +29 -0
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +16 -0
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +41 -0
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +27 -0
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +60 -0
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.d.ts +55 -0
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +148 -0
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +16 -0
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +66 -0
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +32 -0
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +12 -0
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +49 -0
- package/dist/modules/mcp/tools/operations/schema/index.d.ts +21 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +12 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +52 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +18 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +47 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +27 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +44 -0
- package/dist/modules/mcp/tools/operations/schema/operations.d.ts +236 -0
- package/dist/modules/mcp/tools/operations/schema/operations.js +41 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +25 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +14 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +77 -0
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +36 -0
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +44 -0
- package/dist/modules/mcp/tools/operations/schema/shared.d.ts +106 -0
- package/dist/modules/mcp/tools/operations/schema/shared.js +131 -0
- package/dist/modules/mcp/tools/operations/schema/translator.d.ts +12 -0
- package/dist/modules/mcp/tools/operations/schema/translator.js +216 -0
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +18 -0
- package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +16 -0
- package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +42 -0
- package/dist/modules/mcp/tools/operations/schema/write.d.ts +42 -0
- package/dist/modules/mcp/tools/operations/schema/write.js +112 -0
- package/dist/modules/mcp/tools/operations/schemaIds.d.ts +6 -0
- package/dist/modules/mcp/tools/operations/schemaIds.js +58 -0
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +21 -0
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +37 -0
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +28 -0
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +37 -0
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +24 -0
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.d.ts +41 -0
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +40 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +21 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +37 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +28 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +37 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +24 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +21 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +37 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +28 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +37 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +24 -0
- package/dist/modules/mcp/tools/operations/style/index.d.ts +15 -0
- package/dist/modules/mcp/tools/operations/style/operations.d.ts +264 -0
- package/dist/modules/mcp/tools/operations/style/operations.js +29 -0
- package/dist/modules/mcp/tools/operations/style/shared.d.ts +116 -0
- package/dist/modules/mcp/tools/operations/style/shared.js +59 -0
- package/dist/modules/mcp/tools/operations/style/translator.d.ts +12 -0
- package/dist/modules/mcp/tools/operations/style/translator.js +101 -0
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +15 -0
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +21 -0
- package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +20 -0
- package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +22 -0
- package/dist/modules/mcp/tools/operations/style/write.d.ts +12 -0
- package/dist/modules/mcp/tools/operations/style/write.js +108 -0
- package/dist/modules/mcp/tools/preview.d.ts +472 -0
- package/dist/modules/mcp/tools/preview.js +37 -0
- package/dist/modules/mcp/tools/read.d.ts +9 -0
- package/dist/modules/mcp/tools/read.js +51 -0
- package/dist/modules/mcp/tools/render.d.ts +506 -0
- package/dist/modules/mcp/tools/render.js +184 -0
- package/dist/modules/mcp/tools/render.test.d.ts +1 -0
- package/dist/modules/mcp/tools/screenshot.d.ts +656 -0
- package/dist/modules/mcp/tools/screenshot.js +83 -0
- package/dist/modules/mcp/tools/search.d.ts +15 -0
- package/dist/modules/mcp/tools/search.js +115 -0
- package/dist/modules/mcp/tools/shared/expandOperations.d.ts +13 -0
- package/dist/modules/mcp/tools/shared/expandOperations.js +44 -0
- package/dist/modules/mcp/tools/shared/tool.d.ts +72 -0
- package/dist/modules/mcp/tools/shared/tool.js +33 -0
- package/dist/modules/mcp/tools/shared/validator/audit.d.ts +4 -0
- package/dist/modules/mcp/tools/shared/validator/audit.js +124 -0
- package/dist/modules/mcp/tools/shared/validator/batch.d.ts +5 -0
- package/dist/modules/mcp/tools/shared/validator/batch.js +39 -0
- package/dist/modules/mcp/tools/shared/validator/bindings.d.ts +6 -0
- package/dist/modules/mcp/tools/shared/validator/bindings.js +70 -0
- package/dist/modules/mcp/tools/shared/validator/connectors.d.ts +19 -0
- package/dist/modules/mcp/tools/shared/validator/connectors.js +76 -0
- package/dist/modules/mcp/tools/shared/validator/context.d.ts +38 -0
- package/dist/modules/mcp/tools/shared/validator/context.js +35 -0
- package/dist/modules/mcp/tools/shared/validator/css.d.ts +4 -0
- package/dist/modules/mcp/tools/shared/validator/css.js +39 -0
- package/dist/modules/mcp/tools/shared/validator/elements.d.ts +7 -0
- package/dist/modules/mcp/tools/shared/validator/elements.js +68 -0
- package/dist/modules/mcp/tools/shared/validator/index.d.ts +8 -0
- package/dist/modules/mcp/tools/shared/validator/index.js +268 -0
- package/dist/modules/mcp/tools/shared/validator/interactions.d.ts +3 -0
- package/dist/modules/mcp/tools/shared/validator/interactions.js +103 -0
- package/dist/modules/mcp/tools/shared/validator/refs.d.ts +4 -0
- package/dist/modules/mcp/tools/shared/validator/refs.js +28 -0
- package/dist/modules/mcp/tools/validate.d.ts +653 -0
- package/dist/modules/mcp/tools/validate.js +47 -0
- package/dist/modules/mcp/types/aiSchema.d.ts +226 -0
- package/dist/modules/mcp/types/appTypes.d.ts +26 -0
- package/dist/modules/mcp/types/index.d.ts +5 -0
- package/dist/modules/mcp/types/previewTypes.d.ts +25 -0
- package/dist/modules/mcp/types/screenshotTypes.d.ts +29 -0
- package/dist/modules/mcp/types/toolTypes.d.ts +145 -0
- package/dist/modules/oauth/authorize.d.ts +7 -0
- package/dist/modules/oauth/authorize.js +177 -0
- package/dist/modules/oauth/challenge.d.ts +11 -0
- package/dist/modules/oauth/challenge.js +33 -0
- package/dist/modules/oauth/consentPage.d.ts +7 -0
- package/dist/modules/oauth/consentPage.js +118 -0
- package/dist/modules/oauth/metadata.d.ts +40 -0
- package/dist/modules/oauth/metadata.js +69 -0
- package/dist/modules/oauth/oauth.test.d.ts +1 -0
- package/dist/modules/oauth/params.d.ts +5 -0
- package/dist/modules/oauth/params.js +5 -0
- package/dist/modules/oauth/pkce.d.ts +6 -0
- package/dist/modules/oauth/pkce.js +15 -0
- package/dist/modules/oauth/records.d.ts +71 -0
- package/dist/modules/oauth/records.js +46 -0
- package/dist/modules/oauth/register.d.ts +5 -0
- package/dist/modules/oauth/register.js +55 -0
- package/dist/modules/oauth/respond.d.ts +13 -0
- package/dist/modules/oauth/respond.js +44 -0
- package/dist/modules/oauth/token.d.ts +5 -0
- package/dist/modules/oauth/token.js +100 -0
- package/dist/options.d.ts +73 -0
- package/dist/packageBoundary.test.d.ts +1 -0
- package/dist/pipeline.d.ts +12 -0
- package/dist/pipeline.js +29 -0
- package/dist/pipeline.test.d.ts +1 -0
- package/dist/preview/createPreview.d.ts +10 -0
- package/dist/preview/createPreview.js +83 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.js +7 -0
- package/dist/stages/mcp.d.ts +4 -0
- package/dist/stages/mcp.js +30 -0
- package/dist/stages/oauth.d.ts +19 -0
- package/dist/stages/oauth.js +114 -0
- package/dist/stages/preview.d.ts +2 -0
- package/dist/stages/preview.js +37 -0
- package/dist/stages/proxy.d.ts +3 -0
- package/dist/stages/proxy.js +14 -0
- package/dist/tests/httpRequest.d.ts +14 -0
- package/package.json +77 -0
- package/skills/plitzi-render/SKILL.md +174 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { PREVIEW_TOKEN_PARAM } from "@plitzi/sdk-server/kernel";
|
|
2
|
+
//#region src/modules/mcp/screenshotClient.ts
|
|
3
|
+
var composeUrl = (base, pagePath, token) => {
|
|
4
|
+
const url = new URL(pagePath, base);
|
|
5
|
+
if (token) url.searchParams.set(PREVIEW_TOKEN_PARAM, token);
|
|
6
|
+
return url.toString();
|
|
7
|
+
};
|
|
8
|
+
/** Default `ScreenshotClient`: composes the navigable preview URL (renderBaseUrl + pagePath + `?__pt=token`) and
|
|
9
|
+
* POSTs it to the browser service. Any network/HTTP failure surfaces as `ok:false` so the tool can fall back to
|
|
10
|
+
* the HTML preview instead of hard-failing. */
|
|
11
|
+
var createHttpScreenshotClient = ({ serviceUrl, renderBaseUrl, fetchImpl = fetch }) => ({ async capture({ pagePath, token, viewports }) {
|
|
12
|
+
const url = composeUrl(renderBaseUrl, pagePath, token);
|
|
13
|
+
let res;
|
|
14
|
+
try {
|
|
15
|
+
res = await fetchImpl(serviceUrl, {
|
|
16
|
+
method: "POST",
|
|
17
|
+
headers: { "content-type": "application/json" },
|
|
18
|
+
body: JSON.stringify({
|
|
19
|
+
url,
|
|
20
|
+
viewports
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
} catch (err) {
|
|
24
|
+
return {
|
|
25
|
+
ok: false,
|
|
26
|
+
error: "SCREENSHOT_UNREACHABLE",
|
|
27
|
+
message: `Browser service unreachable: ${String(err)}`
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (!res.ok) return {
|
|
31
|
+
ok: false,
|
|
32
|
+
error: "SCREENSHOT_FAILED",
|
|
33
|
+
message: `Browser service returned ${res.status}.`
|
|
34
|
+
};
|
|
35
|
+
const body = await res.json();
|
|
36
|
+
if (!body.images || body.images.length === 0) return {
|
|
37
|
+
ok: false,
|
|
38
|
+
error: "SCREENSHOT_EMPTY",
|
|
39
|
+
message: "Browser service returned no images."
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
ok: true,
|
|
43
|
+
images: body.images
|
|
44
|
+
};
|
|
45
|
+
} });
|
|
46
|
+
//#endregion
|
|
47
|
+
export { createHttpScreenshotClient };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { ResourceProxy } from './proxy';
|
|
3
|
+
import { PreviewClient, ScreenshotClient } from './types';
|
|
4
|
+
import { SSRAdapters, ServerLogger, SSRGrant } from '@plitzi/sdk-shared';
|
|
5
|
+
/** The MCP service is stateless: every request resolves its own `spaceId` (from the request JWT) and reads the
|
|
6
|
+
* space fresh through the adapters — schema and style are two documents, read/written independently. The spaceId
|
|
7
|
+
* is resolved once per request, up front, because it decides what this connection IS: with a space, the full
|
|
8
|
+
* editing server; without one (no auth, a guest connection, a widgets-only grant), a widget server that offers
|
|
9
|
+
* only what works there. The space documents themselves still load lazily — the handshake and the listings never
|
|
10
|
+
* touch the store. */
|
|
11
|
+
export interface McpServerContext {
|
|
12
|
+
adapters: SSRAdapters;
|
|
13
|
+
getGrant: () => Promise<SSRGrant | undefined>;
|
|
14
|
+
/** How the visual-preview tools (plitzi_preview / plitzi_screenshot) reach the renderer. Absent → those tools
|
|
15
|
+
* report PREVIEW_UNAVAILABLE, so an MCP-only deployment without a renderer still runs every other tool. */
|
|
16
|
+
preview?: PreviewClient;
|
|
17
|
+
/** The dedicated browser service for plitzi_screenshot. Absent → the tool is not registered (only the HTML
|
|
18
|
+
* plitzi_preview is offered). */
|
|
19
|
+
screenshot?: ScreenshotClient;
|
|
20
|
+
/** Structured request-log sink. When set, every tool call and resource read emits an McpLogEvent to it (the
|
|
21
|
+
* consumer renders them); otherwise logging falls back to the console when MCP_DEBUG=1. */
|
|
22
|
+
logger?: ServerLogger;
|
|
23
|
+
/** May the plitzi_render view paint from tool arguments the host is still streaming (see `mcpAi.renderStreaming`)?
|
|
24
|
+
* Defaults to true. */
|
|
25
|
+
renderStreaming?: boolean;
|
|
26
|
+
/** Where a rendered widget loads everything external from (see `mcpAi.proxy`). It reaches two places: the render
|
|
27
|
+
* tool, which rewrites the URLs the agent authored, and the App's CSP, which declares the origin those URLs
|
|
28
|
+
* point at. Absent → neither happens, and a widget's resources load only where the host allows their origin. */
|
|
29
|
+
proxy?: ResourceProxy;
|
|
30
|
+
}
|
|
31
|
+
export declare const createMcpServer: ({ adapters, getGrant, preview, screenshot, logger, renderStreaming, proxy }: McpServerContext) => Promise<McpServer>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { registerApps } from "./apps/index.js";
|
|
2
|
+
import { NoSpaceError, ReadOnlyGrantError, emptySpace, emptySpaceMessage, noSpaceErrorCode, readOnlyGrantErrorCode } from "./helpers/space.js";
|
|
3
|
+
import { serverInstructions, widgetsOnlyInstructions } from "./helpers/guide.js";
|
|
4
|
+
import { createMcpLog } from "./helpers/log.js";
|
|
5
|
+
import { proxyForTool } from "./proxy/config.js";
|
|
6
|
+
import { registerResources } from "./resources/register.js";
|
|
7
|
+
import { tools } from "./tools/index.js";
|
|
8
|
+
import { isCallToolResult } from "../ai/toolkit.js";
|
|
9
|
+
import { registerAppTool } from "@modelcontextprotocol/ext-apps/server";
|
|
10
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
11
|
+
//#region src/modules/mcp/server.ts
|
|
12
|
+
var MCP_ENV = "main";
|
|
13
|
+
var asText = (data) => ({ content: [{
|
|
14
|
+
type: "text",
|
|
15
|
+
text: JSON.stringify(data)
|
|
16
|
+
}] });
|
|
17
|
+
var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger, renderStreaming = true, proxy }) => {
|
|
18
|
+
const log = createMcpLog(logger);
|
|
19
|
+
const grant = await getGrant().catch(() => void 0);
|
|
20
|
+
const spaceId = grant?.spaceId;
|
|
21
|
+
const hasSpace = spaceId !== void 0;
|
|
22
|
+
const requireSpaceId = () => {
|
|
23
|
+
if (spaceId === void 0) throw new NoSpaceError();
|
|
24
|
+
return spaceId;
|
|
25
|
+
};
|
|
26
|
+
const requireWritableSpaceId = () => {
|
|
27
|
+
const id = requireSpaceId();
|
|
28
|
+
if (!grant?.canWrite) throw new ReadOnlyGrantError();
|
|
29
|
+
return id;
|
|
30
|
+
};
|
|
31
|
+
const loadSpace = async () => {
|
|
32
|
+
const id = requireSpaceId();
|
|
33
|
+
const [schema, style, catalog, connectors] = await Promise.all([
|
|
34
|
+
adapters.getSchema?.(id, MCP_ENV),
|
|
35
|
+
adapters.getStyle?.(id, MCP_ENV),
|
|
36
|
+
adapters.getComponentCatalog?.(id, MCP_ENV).catch(() => void 0),
|
|
37
|
+
adapters.getConnectors?.(id).catch(() => void 0)
|
|
38
|
+
]);
|
|
39
|
+
if (!schema || !style) throw new Error(emptySpaceMessage);
|
|
40
|
+
return {
|
|
41
|
+
schema,
|
|
42
|
+
style,
|
|
43
|
+
catalog,
|
|
44
|
+
connectors: connectors ?? []
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
const { saveSchema, saveStyle, saveConnector, deleteConnector } = adapters;
|
|
48
|
+
const persisters = {
|
|
49
|
+
schema: saveSchema ? (schema) => saveSchema(requireWritableSpaceId(), MCP_ENV, schema) : void 0,
|
|
50
|
+
style: saveStyle ? (style) => saveStyle(requireWritableSpaceId(), MCP_ENV, style) : void 0,
|
|
51
|
+
saveConnector: saveConnector ? (entry) => saveConnector(requireWritableSpaceId(), entry) : void 0,
|
|
52
|
+
deleteConnector: deleteConnector ? (id) => deleteConnector(requireWritableSpaceId(), id) : void 0
|
|
53
|
+
};
|
|
54
|
+
let spacePromise;
|
|
55
|
+
const getSpace = () => spacePromise ??= loadSpace();
|
|
56
|
+
const server = new McpServer({
|
|
57
|
+
name: "plitzi-mcp",
|
|
58
|
+
version: "0.33.0"
|
|
59
|
+
}, { instructions: hasSpace ? serverInstructions : widgetsOnlyInstructions });
|
|
60
|
+
registerResources(server, getSpace, MCP_ENV, log, hasSpace);
|
|
61
|
+
registerApps(server, {
|
|
62
|
+
streaming: renderStreaming,
|
|
63
|
+
proxyEndpoint: proxy?.endpoint
|
|
64
|
+
});
|
|
65
|
+
const toolContext = async (tool) => ({
|
|
66
|
+
space: await getSpace(),
|
|
67
|
+
env: MCP_ENV,
|
|
68
|
+
persisters,
|
|
69
|
+
spaceId: requireSpaceId(),
|
|
70
|
+
preview,
|
|
71
|
+
screenshot,
|
|
72
|
+
proxy: proxyForTool(proxy, tool)
|
|
73
|
+
});
|
|
74
|
+
const spacelessContext = (tool) => ({
|
|
75
|
+
space: emptySpace(),
|
|
76
|
+
env: MCP_ENV,
|
|
77
|
+
persisters,
|
|
78
|
+
preview,
|
|
79
|
+
screenshot,
|
|
80
|
+
proxy: proxyForTool(proxy, tool)
|
|
81
|
+
});
|
|
82
|
+
const behaviorOf = (tool) => {
|
|
83
|
+
if (tool.spaceless) return (args) => tool.execute(args, spacelessContext(tool.name));
|
|
84
|
+
if (hasSpace) return async (args) => tool.execute(args, await toolContext(tool.name));
|
|
85
|
+
return tool.executePublic ? (args) => tool.executePublic?.(args, MCP_ENV) : void 0;
|
|
86
|
+
};
|
|
87
|
+
for (const tool of tools) {
|
|
88
|
+
if (tool.requires === "screenshot" && !screenshot) continue;
|
|
89
|
+
const behavior = behaviorOf(tool);
|
|
90
|
+
if (!behavior) continue;
|
|
91
|
+
const run = async (args) => {
|
|
92
|
+
const start = performance.now();
|
|
93
|
+
try {
|
|
94
|
+
const result = await behavior(args);
|
|
95
|
+
log.toolCall(tool.name, args, performance.now() - start);
|
|
96
|
+
return isCallToolResult(result) ? result : asText(result);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
log.toolCall(tool.name, args, performance.now() - start, error);
|
|
99
|
+
if (error instanceof NoSpaceError) return asText({
|
|
100
|
+
error: noSpaceErrorCode,
|
|
101
|
+
message: error.message
|
|
102
|
+
});
|
|
103
|
+
if (error instanceof ReadOnlyGrantError) return asText({
|
|
104
|
+
error: readOnlyGrantErrorCode,
|
|
105
|
+
message: error.message
|
|
106
|
+
});
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const config = {
|
|
111
|
+
title: tool.title,
|
|
112
|
+
description: tool.description,
|
|
113
|
+
inputSchema: tool.inputShape
|
|
114
|
+
};
|
|
115
|
+
if (tool.ui) {
|
|
116
|
+
registerAppTool(server, tool.name, {
|
|
117
|
+
...config,
|
|
118
|
+
_meta: { ui: tool.ui }
|
|
119
|
+
}, run);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
server.registerTool(tool.name, config, run);
|
|
123
|
+
}
|
|
124
|
+
return server;
|
|
125
|
+
};
|
|
126
|
+
//#endregion
|
|
127
|
+
export { createMcpServer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Space } from '../helpers';
|
|
2
|
+
import { Operation } from '../tools';
|
|
3
|
+
import { Persisters } from '../types';
|
|
4
|
+
declare const buildSpace: () => Space;
|
|
5
|
+
declare const capturing: (space: Space) => {
|
|
6
|
+
persisters: Persisters;
|
|
7
|
+
saved: () => Space;
|
|
8
|
+
};
|
|
9
|
+
declare const spaceWithRoute: () => Space;
|
|
10
|
+
declare const varOp: (pageRef: string, type: string, value: string) => Operation;
|
|
11
|
+
declare const scopeSpace: () => Space;
|
|
12
|
+
declare const malformedSpace: () => Space;
|
|
13
|
+
export { buildSpace, capturing, spaceWithRoute, varOp, scopeSpace, malformedSpace };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Space } from '../../helpers';
|
|
2
|
+
import { Env, MutationOutcome } from '../../types';
|
|
3
|
+
import { Operation } from '../operations';
|
|
4
|
+
/** Apply operations in order to the space (mutating it). Records which schema(s) changed so the caller can
|
|
5
|
+
* persist each independently. Stops collecting counts for a failed op but records its errors. */
|
|
6
|
+
export declare const applyOperations: (space: Space, env: Env, ops: Operation[]) => MutationOutcome;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { fail } from "../../helpers/opResult.js";
|
|
2
|
+
import { deleteConnector } from "../operations/connectors/deleteConnector.js";
|
|
3
|
+
import { patchConnector } from "../operations/connectors/patchConnector.js";
|
|
4
|
+
import { upsertConnector } from "../operations/connectors/upsertConnector.js";
|
|
5
|
+
import { deleteBinding } from "../operations/schema/bindings/deleteBinding.js";
|
|
6
|
+
import { patchBinding } from "../operations/schema/bindings/patchBinding.js";
|
|
7
|
+
import { upsertBinding } from "../operations/schema/bindings/upsertBinding.js";
|
|
8
|
+
import { deleteElement } from "../operations/schema/elements/deleteElement.js";
|
|
9
|
+
import { moveElement } from "../operations/schema/elements/moveElement.js";
|
|
10
|
+
import { patchElement } from "../operations/schema/elements/patchElement.js";
|
|
11
|
+
import { upsertElement } from "../operations/schema/elements/upsertElement.js";
|
|
12
|
+
import { deleteFolder } from "../operations/schema/folders/deleteFolder.js";
|
|
13
|
+
import { upsertFolder } from "../operations/schema/folders/upsertFolder.js";
|
|
14
|
+
import { deleteInteraction } from "../operations/schema/interactions/deleteInteraction.js";
|
|
15
|
+
import { patchInteractionNode } from "../operations/schema/interactions/patchInteractionNode.js";
|
|
16
|
+
import { upsertInteractionFlow } from "../operations/schema/interactions/upsertInteractionFlow.js";
|
|
17
|
+
import { deletePage } from "../operations/schema/pages/deletePage.js";
|
|
18
|
+
import { upsertPage } from "../operations/schema/pages/upsertPage.js";
|
|
19
|
+
import { patchSettings } from "../operations/schema/settings/patchSettings.js";
|
|
20
|
+
import { deleteVariable } from "../operations/schema/variables/deleteVariable.js";
|
|
21
|
+
import { upsertVariable } from "../operations/schema/variables/upsertVariable.js";
|
|
22
|
+
import { deleteDefinition } from "../operations/style/definitions/deleteDefinition.js";
|
|
23
|
+
import { patchDefinition } from "../operations/style/definitions/patchDefinition.js";
|
|
24
|
+
import { upsertDefinition } from "../operations/style/definitions/upsertDefinition.js";
|
|
25
|
+
import { upsertDefinitions } from "../operations/style/definitions/upsertDefinitions.js";
|
|
26
|
+
import { deleteGlobalStyle } from "../operations/style/globalStyles/deleteGlobalStyle.js";
|
|
27
|
+
import { patchGlobalStyle } from "../operations/style/globalStyles/patchGlobalStyle.js";
|
|
28
|
+
import { upsertGlobalStyle } from "../operations/style/globalStyles/upsertGlobalStyle.js";
|
|
29
|
+
import { deleteIdStyle } from "../operations/style/idStyles/deleteIdStyle.js";
|
|
30
|
+
import { patchIdStyle } from "../operations/style/idStyles/patchIdStyle.js";
|
|
31
|
+
import { upsertIdStyle } from "../operations/style/idStyles/upsertIdStyle.js";
|
|
32
|
+
import { deleteStyleVariable } from "../operations/style/variables/deleteStyleVariable.js";
|
|
33
|
+
import { upsertStyleVariable } from "../operations/style/variables/upsertStyleVariable.js";
|
|
34
|
+
import { isStyleOp } from "../operations/index.js";
|
|
35
|
+
//#region src/modules/mcp/tools/apply/dispatch.ts
|
|
36
|
+
var executeOp = (space, env, op) => {
|
|
37
|
+
switch (op.type) {
|
|
38
|
+
case "upsertElement": return upsertElement(space, env, op);
|
|
39
|
+
case "patchElement": return patchElement(space, env, op);
|
|
40
|
+
case "deleteElement": return deleteElement(space, env, op);
|
|
41
|
+
case "moveElement": return moveElement(space, env, op);
|
|
42
|
+
case "upsertPage": return upsertPage(space, env, op);
|
|
43
|
+
case "deletePage": return deletePage(space, env, op);
|
|
44
|
+
case "upsertFolder": return upsertFolder(space, env, op);
|
|
45
|
+
case "deleteFolder": return deleteFolder(space, env, op);
|
|
46
|
+
case "upsertVariable": return upsertVariable(space, env, op);
|
|
47
|
+
case "deleteVariable": return deleteVariable(space, env, op);
|
|
48
|
+
case "upsertBinding": return upsertBinding(space, env, op);
|
|
49
|
+
case "patchBinding": return patchBinding(space, env, op);
|
|
50
|
+
case "deleteBinding": return deleteBinding(space, env, op);
|
|
51
|
+
case "upsertInteractionFlow": return upsertInteractionFlow(space, env, op);
|
|
52
|
+
case "patchInteractionNode": return patchInteractionNode(space, env, op);
|
|
53
|
+
case "deleteInteraction": return deleteInteraction(space, env, op);
|
|
54
|
+
case "patchSettings": return patchSettings(space, env, op);
|
|
55
|
+
case "upsertDefinition": return upsertDefinition(space, env, op);
|
|
56
|
+
case "upsertDefinitions": return upsertDefinitions(space, env, op);
|
|
57
|
+
case "patchDefinition": return patchDefinition(space, env, op);
|
|
58
|
+
case "deleteDefinition": return deleteDefinition(space, env, op);
|
|
59
|
+
case "upsertGlobalStyle": return upsertGlobalStyle(space, env, op);
|
|
60
|
+
case "patchGlobalStyle": return patchGlobalStyle(space, env, op);
|
|
61
|
+
case "deleteGlobalStyle": return deleteGlobalStyle(space, env, op);
|
|
62
|
+
case "upsertIdStyle": return upsertIdStyle(space, env, op);
|
|
63
|
+
case "patchIdStyle": return patchIdStyle(space, env, op);
|
|
64
|
+
case "deleteIdStyle": return deleteIdStyle(space, env, op);
|
|
65
|
+
case "upsertStyleVariable": return upsertStyleVariable(space, env, op);
|
|
66
|
+
case "deleteStyleVariable": return deleteStyleVariable(space, env, op);
|
|
67
|
+
case "upsertConnector": return upsertConnector(space, env, op);
|
|
68
|
+
case "patchConnector": return patchConnector(space, env, op);
|
|
69
|
+
case "deleteConnector": return deleteConnector(space, env, op);
|
|
70
|
+
default: return fail("type", `Unknown operation "${op.type}"`, "See the Operation union");
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
/** Apply operations in order to the space (mutating it). Records which schema(s) changed so the caller can
|
|
74
|
+
* persist each independently. Stops collecting counts for a failed op but records its errors. */
|
|
75
|
+
var applyOperations = (space, env, ops) => {
|
|
76
|
+
const outcome = {
|
|
77
|
+
created: 0,
|
|
78
|
+
updated: 0,
|
|
79
|
+
deleted: 0,
|
|
80
|
+
staleResources: [],
|
|
81
|
+
elementRefs: [],
|
|
82
|
+
errors: [],
|
|
83
|
+
changedSchema: false,
|
|
84
|
+
changedStyle: false,
|
|
85
|
+
changedConnectors: [],
|
|
86
|
+
deletedConnectors: []
|
|
87
|
+
};
|
|
88
|
+
const stale = /* @__PURE__ */ new Set();
|
|
89
|
+
const elements = /* @__PURE__ */ new Set();
|
|
90
|
+
const savedConnectors = /* @__PURE__ */ new Set();
|
|
91
|
+
const droppedConnectors = /* @__PURE__ */ new Set();
|
|
92
|
+
for (let i = 0; i < ops.length; i++) {
|
|
93
|
+
const op = ops[i];
|
|
94
|
+
const result = executeOp(space, env, op);
|
|
95
|
+
if (result.errors) {
|
|
96
|
+
outcome.errors.push(...result.errors.map((e) => ({
|
|
97
|
+
...e,
|
|
98
|
+
path: `operations[${i}].${e.path}`
|
|
99
|
+
})));
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
switch (op.type) {
|
|
103
|
+
case "upsertConnector":
|
|
104
|
+
case "patchConnector":
|
|
105
|
+
droppedConnectors.delete(op.ref);
|
|
106
|
+
savedConnectors.add(op.ref);
|
|
107
|
+
break;
|
|
108
|
+
case "deleteConnector":
|
|
109
|
+
savedConnectors.delete(op.ref);
|
|
110
|
+
droppedConnectors.add(op.ref);
|
|
111
|
+
break;
|
|
112
|
+
default: if (isStyleOp(op.type)) outcome.changedStyle = true;
|
|
113
|
+
else outcome.changedSchema = true;
|
|
114
|
+
}
|
|
115
|
+
outcome.created += result.created;
|
|
116
|
+
outcome.updated += result.updated;
|
|
117
|
+
outcome.deleted += result.deleted;
|
|
118
|
+
for (const uri of result.staleResources) stale.add(uri);
|
|
119
|
+
for (const ref of result.elementRefs ?? []) elements.add(ref);
|
|
120
|
+
}
|
|
121
|
+
outcome.staleResources = Array.from(stale);
|
|
122
|
+
outcome.elementRefs = Array.from(elements);
|
|
123
|
+
outcome.changedConnectors = Array.from(savedConnectors);
|
|
124
|
+
outcome.deletedConnectors = Array.from(droppedConnectors);
|
|
125
|
+
return outcome;
|
|
126
|
+
};
|
|
127
|
+
//#endregion
|
|
128
|
+
export { applyOperations };
|