@plitzi/sdk-server 0.32.25 → 0.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +326 -162
- package/dist/adapters/authAdapters.d.ts +21 -0
- package/dist/adapters/authAdapters.js +12 -0
- package/dist/adapters/jsonAdapters.d.ts +15 -0
- package/dist/adapters/jsonAdapters.js +9 -4
- package/dist/core/auth/api.d.ts +148 -0
- package/dist/core/auth/api.js +286 -0
- package/dist/core/auth/authorize.d.ts +96 -0
- package/dist/core/auth/authorize.js +92 -0
- package/dist/core/auth/createAuth.d.ts +165 -0
- package/dist/core/auth/createAuth.js +105 -0
- package/dist/core/auth/credentials.d.ts +29 -0
- package/dist/core/auth/credentials.js +48 -0
- package/dist/core/auth/domains.d.ts +41 -0
- package/dist/core/auth/domains.js +78 -0
- package/dist/core/auth/identity.d.ts +108 -0
- package/dist/core/auth/identity.js +164 -0
- package/dist/core/auth/oauth/client.d.ts +5 -0
- package/dist/core/auth/oauth/client.js +47 -0
- package/dist/core/auth/oauth/index.d.ts +78 -0
- package/dist/core/auth/oauth/index.js +113 -0
- package/dist/core/auth/oauth/providers/github.d.ts +2 -0
- package/dist/core/auth/oauth/providers/github.js +48 -0
- package/dist/core/auth/oauth/providers/google.d.ts +2 -0
- package/dist/core/auth/oauth/providers/google.js +30 -0
- package/dist/core/auth/oauth/state.d.ts +23 -0
- package/dist/core/auth/oauth/state.js +55 -0
- package/dist/core/auth/oauth/types.d.ts +51 -0
- package/dist/core/auth/oauth/types.js +13 -0
- package/dist/core/auth/routes.d.ts +50 -0
- package/dist/core/auth/routes.js +129 -0
- package/dist/core/auth/session.d.ts +128 -0
- package/dist/core/auth/session.js +165 -0
- package/dist/core/auth/spaceTokens.d.ts +137 -0
- package/dist/core/auth/spaceTokens.js +212 -0
- package/dist/core/auth/tokens.d.ts +151 -0
- package/dist/core/auth/tokens.js +221 -0
- package/dist/core/createServer.d.ts +29 -0
- package/dist/core/createServer.js +28 -14
- package/dist/core/handlers/authMiddleware.d.ts +27 -0
- package/dist/core/handlers/authMiddleware.js +38 -0
- package/dist/core/handlers/authRouteHandlers.d.ts +46 -0
- package/dist/core/handlers/authRouteHandlers.js +75 -0
- package/dist/core/handlers/types.d.ts +37 -0
- package/dist/{src/core → core}/http/dispatcher.d.ts +2 -2
- package/dist/core/http/dispatcher.js +8 -6
- package/dist/core/http/navigation.d.ts +11 -0
- package/dist/core/http/navigation.js +16 -0
- package/dist/core/http/securityHeaders.js +6 -4
- package/dist/core/http/stages/authApi.d.ts +17 -0
- package/dist/core/http/stages/authApi.js +66 -0
- package/dist/core/http/stages/authRoutes.js +40 -11
- package/dist/core/http/stages/exchangeRoute.d.ts +15 -0
- package/dist/core/http/stages/exchangeRoute.js +67 -0
- package/dist/core/http/stages/health.d.ts +11 -0
- package/dist/core/http/stages/health.js +25 -3
- package/dist/core/http/stages/middlewares.d.ts +2 -0
- package/dist/core/http/stages/static.d.ts +13 -0
- package/dist/core/http/stages/static.js +21 -6
- package/dist/core/http/types.d.ts +35 -0
- package/dist/{modules/mcp/constants.js → core/previewToken.js} +1 -1
- package/dist/core/sdkAssets.d.ts +16 -0
- package/dist/core/sdkAssets.js +46 -0
- package/dist/core/server/baseServer.js +40 -5
- package/dist/core/server/pageServer.d.ts +7 -0
- package/dist/core/server/pageServer.js +13 -17
- package/dist/core/services/action.d.ts +9 -0
- package/dist/core/services/action.js +21 -0
- package/dist/core/services/registry.d.ts +3 -0
- package/dist/core/services/registry.js +9 -19
- package/dist/{src/core → core}/services/resolve.d.ts +1 -0
- package/dist/core/services/resolve.js +6 -4
- package/dist/core/services/rsc.js +3 -2
- package/dist/core/staticFiles.js +1 -1
- package/dist/{src/core → core}/transports.d.ts +3 -0
- package/dist/core/transports.js +7 -6
- package/dist/handlers.d.ts +58 -0
- package/dist/handlers.js +3 -0
- package/dist/{src/helpers → helpers}/buildResponseHelpers.d.ts +2 -1
- package/dist/helpers/buildResponseHelpers.js +13 -4
- package/dist/helpers/buildServerInfo.d.ts +3 -0
- package/dist/helpers/buildServerInfo.js +25 -3
- package/dist/{src/helpers → helpers}/cache/keys.d.ts +5 -1
- package/dist/helpers/cache/keys.js +1 -1
- package/dist/helpers/compress.d.ts +18 -0
- package/dist/helpers/compress.js +47 -11
- package/dist/helpers/offlineDataLoader.d.ts +11 -0
- package/dist/helpers/offlineDataLoader.js +15 -0
- package/dist/helpers/resolveDebugMode.d.ts +10 -0
- package/dist/helpers/resolveDebugMode.js +13 -0
- package/dist/index.d.ts +16 -2
- package/dist/index.js +9 -20
- package/dist/kernel.d.ts +41 -0
- package/dist/kernel.js +22 -0
- package/dist/middlewares/spaceDeployment.d.ts +2 -0
- package/dist/middlewares/spaceDeployment.js +2 -1
- package/dist/modules/actions/handler.d.ts +11 -0
- package/dist/modules/actions/handler.js +77 -0
- package/dist/modules/connectors/engine.d.ts +42 -0
- package/dist/modules/connectors/engine.js +221 -0
- package/dist/modules/connectors/getByPath.d.ts +8 -0
- package/dist/modules/connectors/getByPath.js +21 -0
- package/dist/modules/connectors/index.d.ts +7 -0
- package/dist/modules/connectors/projection.d.ts +18 -0
- package/dist/modules/connectors/projection.js +108 -0
- package/dist/modules/connectors/resolver.d.ts +18 -0
- package/dist/modules/connectors/resolver.js +68 -0
- package/dist/modules/connectors/types.d.ts +19 -0
- package/dist/{src/modules → modules}/rsc/handler.d.ts +2 -2
- package/dist/modules/rsc/handler.js +54 -2
- package/dist/modules/rsc/resolveRscData.d.ts +35 -0
- package/dist/modules/rsc/resolveRscData.js +74 -0
- package/dist/{src/modules → modules}/ssr/Component.d.ts +4 -1
- package/dist/modules/ssr/Component.js +10 -3
- package/dist/modules/ssr/buildBody.d.ts +9 -0
- package/dist/modules/ssr/handler.d.ts +4 -0
- package/dist/modules/ssr/handler.js +18 -1
- package/dist/{src/modules → modules}/ssr/loadPluginComponents.d.ts +5 -2
- package/dist/modules/ssr/loadPluginComponents.js +20 -2
- package/dist/{src/modules → modules}/ssr/prepareRender.d.ts +2 -2
- package/dist/modules/ssr/prepareRender.js +24 -7
- package/dist/modules/ssr/preview.d.ts +10 -0
- package/dist/modules/ssr/preview.js +5 -78
- package/dist/modules/ssr/registerExternalPlugins.js +1 -1
- package/dist/modules/ssr/streamBody.d.ts +5 -0
- package/dist/modules/ssr/streamBody.js +1 -1
- package/dist/modules/ssr/template.d.ts +2 -0
- package/dist/modules/ssr/template.js +1 -1
- package/dist/plugins/compile.js +1 -1
- package/dist/plugins/manager.js +12 -8
- package/dist/ssr.d.ts +15 -0
- package/dist/ssr.js +4 -0
- package/package.json +29 -25
- package/dist/.gitkeep +0 -0
- package/dist/core/server/mcpServer.js +0 -29
- package/dist/core/services/mcp.js +0 -27
- package/dist/core/services/oauth.js +0 -116
- package/dist/core/services/preview.js +0 -37
- package/dist/core/services/proxy.js +0 -12
- package/dist/mcp.d.ts +0 -2
- package/dist/mcp.js +0 -7
- package/dist/modules/ai/AIEngine.js +0 -120
- package/dist/modules/ai/toolkit.js +0 -59
- package/dist/modules/mcp/apps/example/view/index.tsx +0 -70
- package/dist/modules/mcp/apps/index.js +0 -16
- package/dist/modules/mcp/apps/render/index.js +0 -17
- package/dist/modules/mcp/apps/render/styles.js +0 -54
- package/dist/modules/mcp/apps/render/view/heldBatch.ts +0 -107
- package/dist/modules/mcp/apps/render/view/index.tsx +0 -314
- package/dist/modules/mcp/apps/render/view/streamProgress.ts +0 -137
- package/dist/modules/mcp/apps/shared/assets.js +0 -10
- package/dist/modules/mcp/apps/shared/bundle.js +0 -23
- package/dist/modules/mcp/apps/shared/page.js +0 -34
- package/dist/modules/mcp/apps/shared/registerApp.js +0 -43
- package/dist/modules/mcp/apps/shared/resolve.js +0 -5
- package/dist/modules/mcp/apps/shared/shell.ejs +0 -59
- package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +0 -23
- package/dist/modules/mcp/catalogs/builtinCallbacks.js +0 -204
- package/dist/modules/mcp/catalogs/builtinComponents.js +0 -170
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +0 -50
- package/dist/modules/mcp/catalogs/builtinTransformers.js +0 -148
- package/dist/modules/mcp/catalogs/builtinUtilities.js +0 -90
- package/dist/modules/mcp/catalogs/cssCatalog/border.js +0 -30
- package/dist/modules/mcp/catalogs/cssCatalog/box.js +0 -31
- package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +0 -185
- package/dist/modules/mcp/catalogs/cssCatalog/index.js +0 -131
- package/dist/modules/mcp/catalogs/cssCatalog/layout.js +0 -98
- package/dist/modules/mcp/catalogs/cssCatalog/visual.js +0 -144
- package/dist/modules/mcp/catalogs/observed.js +0 -90
- package/dist/modules/mcp/catalogs/paramSpec.js +0 -69
- package/dist/modules/mcp/catalogs/registry.js +0 -89
- package/dist/modules/mcp/handler.js +0 -83
- package/dist/modules/mcp/helpers/agentPrompt.js +0 -104
- package/dist/modules/mcp/helpers/computeVersion.js +0 -16
- package/dist/modules/mcp/helpers/guide.js +0 -467
- package/dist/modules/mcp/helpers/interactions.js +0 -123
- package/dist/modules/mcp/helpers/log.js +0 -64
- package/dist/modules/mcp/helpers/opResult.js +0 -18
- package/dist/modules/mcp/helpers/space.js +0 -300
- package/dist/modules/mcp/helpers/uris.js +0 -44
- package/dist/modules/mcp/previewClient.js +0 -31
- package/dist/modules/mcp/proxy/config.js +0 -63
- package/dist/modules/mcp/proxy/fetch.js +0 -91
- package/dist/modules/mcp/proxy/grant.js +0 -67
- package/dist/modules/mcp/proxy/guard.js +0 -38
- package/dist/modules/mcp/proxy/handler.js +0 -99
- package/dist/modules/mcp/proxy/payload.js +0 -29
- package/dist/modules/mcp/proxy/rewrite.js +0 -138
- package/dist/modules/mcp/proxy/sign.js +0 -15
- package/dist/modules/mcp/proxy/types.js +0 -9
- package/dist/modules/mcp/resources/canonical.js +0 -30
- package/dist/modules/mcp/resources/core.js +0 -18
- package/dist/modules/mcp/resources/envelope.js +0 -14
- package/dist/modules/mcp/resources/primer.js +0 -31
- package/dist/modules/mcp/resources/register.js +0 -190
- package/dist/modules/mcp/resources/renderGuide.js +0 -451
- package/dist/modules/mcp/resources/router.js +0 -37
- package/dist/modules/mcp/resources/schema.js +0 -43
- package/dist/modules/mcp/resources/style.js +0 -34
- package/dist/modules/mcp/screenshotClient.js +0 -47
- package/dist/modules/mcp/server.js +0 -113
- package/dist/modules/mcp/tools/apply/dispatch.js +0 -105
- package/dist/modules/mcp/tools/apply/index.js +0 -150
- package/dist/modules/mcp/tools/apply/writeResult.js +0 -37
- package/dist/modules/mcp/tools/index.js +0 -24
- package/dist/modules/mcp/tools/operations/index.js +0 -45
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +0 -32
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +0 -36
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +0 -47
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +0 -29
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +0 -41
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +0 -58
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +0 -148
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +0 -65
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +0 -30
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +0 -49
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +0 -52
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +0 -47
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +0 -44
- package/dist/modules/mcp/tools/operations/schema/operations.js +0 -41
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +0 -25
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +0 -75
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +0 -45
- package/dist/modules/mcp/tools/operations/schema/shared.js +0 -122
- package/dist/modules/mcp/tools/operations/schema/translator.js +0 -215
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +0 -18
- package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +0 -42
- package/dist/modules/mcp/tools/operations/schema/write.js +0 -109
- package/dist/modules/mcp/tools/operations/schemaIds.js +0 -54
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +0 -21
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +0 -28
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +0 -24
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +0 -40
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +0 -21
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +0 -28
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +0 -24
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +0 -21
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +0 -28
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +0 -24
- package/dist/modules/mcp/tools/operations/style/operations.js +0 -29
- package/dist/modules/mcp/tools/operations/style/shared.js +0 -59
- package/dist/modules/mcp/tools/operations/style/translator.js +0 -101
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +0 -21
- package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +0 -22
- package/dist/modules/mcp/tools/operations/style/write.js +0 -108
- package/dist/modules/mcp/tools/preview.js +0 -37
- package/dist/modules/mcp/tools/read.js +0 -51
- package/dist/modules/mcp/tools/render.js +0 -184
- package/dist/modules/mcp/tools/screenshot.js +0 -83
- package/dist/modules/mcp/tools/search.js +0 -115
- package/dist/modules/mcp/tools/shared/expandOperations.js +0 -44
- package/dist/modules/mcp/tools/shared/tool.js +0 -33
- package/dist/modules/mcp/tools/shared/validator/audit.js +0 -124
- package/dist/modules/mcp/tools/shared/validator/batch.js +0 -39
- package/dist/modules/mcp/tools/shared/validator/bindings.js +0 -70
- package/dist/modules/mcp/tools/shared/validator/context.js +0 -35
- package/dist/modules/mcp/tools/shared/validator/css.js +0 -39
- package/dist/modules/mcp/tools/shared/validator/elements.js +0 -68
- package/dist/modules/mcp/tools/shared/validator/index.js +0 -246
- package/dist/modules/mcp/tools/shared/validator/interactions.js +0 -103
- package/dist/modules/mcp/tools/shared/validator/refs.js +0 -28
- package/dist/modules/mcp/tools/validate.js +0 -47
- package/dist/modules/oauth/authorize.js +0 -177
- package/dist/modules/oauth/challenge.js +0 -33
- package/dist/modules/oauth/consentPage.js +0 -118
- package/dist/modules/oauth/metadata.js +0 -69
- package/dist/modules/oauth/params.js +0 -5
- package/dist/modules/oauth/pkce.js +0 -15
- package/dist/modules/oauth/records.js +0 -46
- package/dist/modules/oauth/register.js +0 -55
- package/dist/modules/oauth/respond.js +0 -44
- package/dist/modules/oauth/token.js +0 -100
- package/dist/public/.gitkeep +0 -0
- package/dist/src/adapters/jsonAdapters.d.ts +0 -7
- package/dist/src/core/createServer.d.ts +0 -14
- package/dist/src/core/http/stages/health.d.ts +0 -2
- package/dist/src/core/http/stages/middlewares.d.ts +0 -2
- package/dist/src/core/http/stages/static.d.ts +0 -5
- package/dist/src/core/http/types.d.ts +0 -22
- package/dist/src/core/server/mcpServer.d.ts +0 -2
- package/dist/src/core/server/pageServer.d.ts +0 -10
- package/dist/src/core/services/mcp.d.ts +0 -3
- package/dist/src/core/services/oauth.d.ts +0 -18
- package/dist/src/core/services/preview.d.ts +0 -2
- package/dist/src/core/services/proxy.d.ts +0 -2
- package/dist/src/core/services/registry.d.ts +0 -4
- package/dist/src/helpers/buildServerInfo.d.ts +0 -2
- package/dist/src/helpers/compress.d.ts +0 -3
- package/dist/src/index.d.ts +0 -15
- package/dist/src/mcp.d.ts +0 -14
- package/dist/src/middlewares/spaceDeployment.d.ts +0 -2
- package/dist/src/modules/ai/AIEngine.d.ts +0 -20
- package/dist/src/modules/ai/index.d.ts +0 -4
- package/dist/src/modules/ai/toolkit.d.ts +0 -17
- package/dist/src/modules/mcp/apps/example/index.d.ts +0 -8
- package/dist/src/modules/mcp/apps/index.d.ts +0 -11
- package/dist/src/modules/mcp/apps/render/index.d.ts +0 -4
- package/dist/src/modules/mcp/apps/render/styles.d.ts +0 -10
- package/dist/src/modules/mcp/apps/shared/assets.d.ts +0 -10
- package/dist/src/modules/mcp/apps/shared/bundle.d.ts +0 -4
- package/dist/src/modules/mcp/apps/shared/index.d.ts +0 -3
- package/dist/src/modules/mcp/apps/shared/page.d.ts +0 -2
- package/dist/src/modules/mcp/apps/shared/registerApp.d.ts +0 -5
- package/dist/src/modules/mcp/apps/shared/resolve.d.ts +0 -1
- package/dist/src/modules/mcp/apps/shared/zodEnglishOnly.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/builtinCallbacks.d.ts +0 -23
- package/dist/src/modules/mcp/catalogs/builtinComponents.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/builtinElementCallbacks.d.ts +0 -20
- package/dist/src/modules/mcp/catalogs/builtinTransformers.d.ts +0 -28
- package/dist/src/modules/mcp/catalogs/builtinUtilities.d.ts +0 -18
- package/dist/src/modules/mcp/catalogs/cssCatalog/border.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/cssCatalog/box.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/cssCatalog/helpers.d.ts +0 -34
- package/dist/src/modules/mcp/catalogs/cssCatalog/index.d.ts +0 -19
- package/dist/src/modules/mcp/catalogs/cssCatalog/layout.d.ts +0 -9
- package/dist/src/modules/mcp/catalogs/cssCatalog/visual.d.ts +0 -8
- package/dist/src/modules/mcp/catalogs/index.d.ts +0 -9
- package/dist/src/modules/mcp/catalogs/observed.d.ts +0 -48
- package/dist/src/modules/mcp/catalogs/paramSpec.d.ts +0 -42
- package/dist/src/modules/mcp/catalogs/registry.d.ts +0 -35
- package/dist/src/modules/mcp/e2e/index.d.ts +0 -6
- package/dist/src/modules/mcp/e2e/mcpEndpoint.d.ts +0 -27
- package/dist/src/modules/mcp/e2e/postMessageChannel.d.ts +0 -22
- package/dist/src/modules/mcp/e2e/renderingHost.d.ts +0 -34
- package/dist/src/modules/mcp/handler.d.ts +0 -22
- package/dist/src/modules/mcp/helpers/agentPrompt.d.ts +0 -4
- package/dist/src/modules/mcp/helpers/computeVersion.d.ts +0 -1
- package/dist/src/modules/mcp/helpers/guide.d.ts +0 -4
- package/dist/src/modules/mcp/helpers/index.d.ts +0 -8
- package/dist/src/modules/mcp/helpers/interactions.d.ts +0 -30
- package/dist/src/modules/mcp/helpers/log.d.ts +0 -8
- package/dist/src/modules/mcp/helpers/opResult.d.ts +0 -13
- package/dist/src/modules/mcp/helpers/space.d.ts +0 -115
- package/dist/src/modules/mcp/helpers/uris.d.ts +0 -28
- package/dist/src/modules/mcp/index.d.ts +0 -13
- package/dist/src/modules/mcp/previewClient.d.ts +0 -13
- package/dist/src/modules/mcp/proxy/config.d.ts +0 -19
- package/dist/src/modules/mcp/proxy/fetch.d.ts +0 -18
- package/dist/src/modules/mcp/proxy/grant.d.ts +0 -25
- package/dist/src/modules/mcp/proxy/guard.d.ts +0 -6
- package/dist/src/modules/mcp/proxy/handler.d.ts +0 -8
- package/dist/src/modules/mcp/proxy/index.d.ts +0 -8
- package/dist/src/modules/mcp/proxy/payload.d.ts +0 -8
- package/dist/src/modules/mcp/proxy/rewrite.d.ts +0 -18
- package/dist/src/modules/mcp/proxy/sign.d.ts +0 -6
- package/dist/src/modules/mcp/proxy/types.d.ts +0 -45
- package/dist/src/modules/mcp/resources/canonical.d.ts +0 -6
- package/dist/src/modules/mcp/resources/core.d.ts +0 -5
- package/dist/src/modules/mcp/resources/envelope.d.ts +0 -10
- package/dist/src/modules/mcp/resources/index.d.ts +0 -8
- package/dist/src/modules/mcp/resources/primer.d.ts +0 -7
- package/dist/src/modules/mcp/resources/register.d.ts +0 -10
- package/dist/src/modules/mcp/resources/renderGuide.d.ts +0 -10
- package/dist/src/modules/mcp/resources/router.d.ts +0 -10
- package/dist/src/modules/mcp/resources/schema.d.ts +0 -5
- package/dist/src/modules/mcp/resources/style.d.ts +0 -5
- package/dist/src/modules/mcp/screenshotClient.d.ts +0 -13
- package/dist/src/modules/mcp/server.d.ts +0 -31
- package/dist/src/modules/mcp/tests/helpers.d.ts +0 -13
- package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +0 -6
- package/dist/src/modules/mcp/tools/apply/index.d.ts +0 -470
- package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +0 -8
- package/dist/src/modules/mcp/tools/index.d.ts +0 -18
- package/dist/src/modules/mcp/tools/operations/index.d.ts +0 -928
- package/dist/src/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +0 -17
- package/dist/src/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +0 -25
- package/dist/src/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +0 -27
- package/dist/src/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +0 -10
- package/dist/src/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +0 -22
- package/dist/src/modules/mcp/tools/operations/schema/elements/repeatElement.d.ts +0 -55
- package/dist/src/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +0 -21
- package/dist/src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +0 -18
- package/dist/src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +0 -27
- package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +0 -229
- package/dist/src/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +0 -14
- package/dist/src/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +0 -34
- package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +0 -92
- package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +0 -42
- package/dist/src/modules/mcp/tools/operations/schemaIds.d.ts +0 -6
- package/dist/src/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinitions.d.ts +0 -41
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/index.d.ts +0 -15
- package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +0 -264
- package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +0 -116
- package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +0 -15
- package/dist/src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +0 -20
- package/dist/src/modules/mcp/tools/operations/style/write.d.ts +0 -12
- package/dist/src/modules/mcp/tools/preview.d.ts +0 -465
- package/dist/src/modules/mcp/tools/read.d.ts +0 -9
- package/dist/src/modules/mcp/tools/render.d.ts +0 -499
- package/dist/src/modules/mcp/tools/render.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/screenshot.d.ts +0 -470
- package/dist/src/modules/mcp/tools/search.d.ts +0 -15
- package/dist/src/modules/mcp/tools/shared/expandOperations.d.ts +0 -13
- package/dist/src/modules/mcp/tools/shared/tool.d.ts +0 -72
- package/dist/src/modules/mcp/tools/shared/validator/audit.d.ts +0 -4
- package/dist/src/modules/mcp/tools/shared/validator/batch.d.ts +0 -5
- package/dist/src/modules/mcp/tools/shared/validator/bindings.d.ts +0 -6
- package/dist/src/modules/mcp/tools/shared/validator/context.d.ts +0 -38
- package/dist/src/modules/mcp/tools/shared/validator/css.d.ts +0 -4
- package/dist/src/modules/mcp/tools/shared/validator/elements.d.ts +0 -7
- package/dist/src/modules/mcp/tools/shared/validator/index.d.ts +0 -8
- package/dist/src/modules/mcp/tools/shared/validator/interactions.d.ts +0 -3
- package/dist/src/modules/mcp/tools/shared/validator/refs.d.ts +0 -4
- package/dist/src/modules/mcp/tools/validate.d.ts +0 -467
- package/dist/src/modules/mcp/types/aiSchema.d.ts +0 -218
- package/dist/src/modules/mcp/types/appTypes.d.ts +0 -26
- package/dist/src/modules/mcp/types/index.d.ts +0 -5
- package/dist/src/modules/mcp/types/previewTypes.d.ts +0 -25
- package/dist/src/modules/mcp/types/screenshotTypes.d.ts +0 -29
- package/dist/src/modules/mcp/types/toolTypes.d.ts +0 -138
- package/dist/src/modules/oauth/authorize.d.ts +0 -7
- package/dist/src/modules/oauth/challenge.d.ts +0 -11
- package/dist/src/modules/oauth/consentPage.d.ts +0 -7
- package/dist/src/modules/oauth/metadata.d.ts +0 -40
- package/dist/src/modules/oauth/params.d.ts +0 -5
- package/dist/src/modules/oauth/pkce.d.ts +0 -6
- package/dist/src/modules/oauth/records.d.ts +0 -71
- package/dist/src/modules/oauth/register.d.ts +0 -5
- package/dist/src/modules/oauth/respond.d.ts +0 -13
- package/dist/src/modules/oauth/token.d.ts +0 -5
- package/dist/src/modules/ssr/buildBody.d.ts +0 -9
- package/dist/src/modules/ssr/handler.d.ts +0 -4
- package/dist/src/modules/ssr/preview.d.ts +0 -16
- package/dist/src/modules/ssr/streamBody.d.ts +0 -5
- package/dist/src/modules/ssr/template.d.ts +0 -6
- package/dist/src/standalone/alias-loader.d.mts +0 -2
- package/dist/src/standalone/plugins/ClientInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/ServerInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/SharedInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/styles.d.ts +0 -5
- package/dist/src/standalone/register-alias.d.mts +0 -1
- package/dist/src/standalone/server.d.ts +0 -1
- package/dist/src/standalone/stubs/react-syntax-highlighter.d.mts +0 -31
- package/skills/plitzi-render/SKILL.md +0 -174
- /package/dist/{src/core/http/dispatcher.test.d.ts → core/auth/api.test.d.ts} +0 -0
- /package/dist/{src/core/server/mcpServer.test.d.ts → core/auth/authorize.test.d.ts} +0 -0
- /package/dist/{src/modules/ai/toolkit.test.d.ts → core/auth/createAuth.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/apps/apps.test.d.ts → core/auth/domains.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/apps/render/styles.test.d.ts → core/auth/identity.test.d.ts} +0 -0
- /package/dist/{src/modules → core/auth}/oauth/oauth.test.d.ts +0 -0
- /package/dist/{src/modules/mcp/catalogs/builtinTransformers.test.d.ts → core/auth/routes.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/catalogs/cssCatalog/cssCatalog.test.d.ts → core/auth/session.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/connector.test.d.ts → core/auth/spaceTokens.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/host.test.d.ts → core/auth/tokens.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/oauthConnector.test.d.ts → core/createServer.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/helpers/log.test.d.ts → core/handlers/handlers.test.d.ts} +0 -0
- /package/dist/{src/core → core}/health.d.ts +0 -0
- /package/dist/{src/modules/mcp/mcp.bench.d.ts → core/http/dispatcher.test.d.ts} +0 -0
- /package/dist/{src/core → core}/http/securityHeaders.d.ts +0 -0
- /package/dist/{src/core → core}/http/stages/authRoutes.d.ts +0 -0
- /package/dist/{src/core → core}/http/stages/pluginAssets.d.ts +0 -0
- /package/dist/{src/core → core}/mimeTypes.d.ts +0 -0
- /package/dist/{src/modules/mcp/constants.d.ts → core/previewToken.d.ts} +0 -0
- /package/dist/{src/core → core}/requestParser.d.ts +0 -0
- /package/dist/{src/core → core}/server/baseServer.d.ts +0 -0
- /package/dist/{src/modules/mcp/proxy/endpoint.test.d.ts → core/server/baseServer.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/proxy/proxy.test.d.ts → core/services/resolve.test.d.ts} +0 -0
- /package/dist/{src/core → core}/services/rsc.d.ts +0 -0
- /package/dist/{src/core → core}/services/ssr.d.ts +0 -0
- /package/dist/{src/core → core}/staticFiles.d.ts +0 -0
- /package/dist/{src/modules/mcp/proxy/wiring.test.d.ts → helpers/buildResponseHelpers.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/cache/TtlCache.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/cacheManager.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/defaults.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/index.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/apply.test.d.ts → helpers/cache/keys.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/cache/serverCaches.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/bindings.test.d.ts → helpers/compress.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/escapeJson.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/metrics.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/normalizePlugins.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/css.test.d.ts → helpers/offlineDataLoader.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/readCookie.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/interactions.test.d.ts → helpers/resolveDebugMode.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/runMiddlewares.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/serverLog.d.ts +0 -0
- /package/dist/{src/middlewares → middlewares}/auth.d.ts +0 -0
- /package/dist/{src/middlewares → middlewares}/basicAuth.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/pages.test.d.ts → middlewares/spaceDeployment.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/reads.test.d.ts → modules/actions/handler.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/schemaIds.test.d.ts → modules/connectors/engine.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/search.test.d.ts → modules/connectors/projection.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/skill.test.d.ts → modules/connectors/resolver.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/styles.test.d.ts → modules/rsc/resolveRscData.test.d.ts} +0 -0
- /package/dist/{src/modules → modules}/ssr/applySSRResult.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/tools.test.d.ts → modules/ssr/loadPluginComponents.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/validation.test.d.ts → modules/ssr/metering.test.d.ts} +0 -0
- /package/dist/{src/modules → modules}/ssr/registerExternalPlugins.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/compile.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/copy.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/detect.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/manager.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/validate.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/validate.test.d.ts +0 -0
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { findElementByRef, findPageByRef, generateObjectId, indexAddElement, indexReRefElement, resolveRef, spaceIndex } from "../../../helpers/space.js";
|
|
2
|
-
import { folderUri, foldersUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from "../../../helpers/uris.js";
|
|
3
|
-
import { fail } from "../../../helpers/opResult.js";
|
|
4
|
-
import { isValidIdRef, makeIdRef } from "@plitzi/sdk-schema/helpers/idRef";
|
|
5
|
-
//#region src/modules/mcp/tools/operations/schema/write.ts
|
|
6
|
-
var ID_REF_HINT = "Start with a letter, then letters, numbers, hyphens and underscores (e.g. \"hero-cta\" or \"food_item\"). The ref becomes the element idRef, which the runtime embeds in source names like `apiContainer_<idRef>.field` and in interaction targets — a dot would split those paths (an underscore is fine: the FIRST `_` separates the type from the idRef, and element types carry none, so extra underscores are unambiguous).";
|
|
7
|
-
var TAKEN_HINT = "An idRef must be unique across the space — pick a different ref, or address the existing element by this ref.";
|
|
8
|
-
/** Every ref in an element input tree (the element plus its nested children) — each becomes a new element's idRef. */
|
|
9
|
-
var collectInputRefs = (input) => [input.ref, ...(input.children ?? []).flatMap(collectInputRefs)];
|
|
10
|
-
/** Validate a ref that is about to become an element's idRef: the charset, then whether anything already answers
|
|
11
|
-
* to it. The charset rule is sdk-schema's `isValidIdRef` — never a regex restated here, so the MCP cannot drift
|
|
12
|
-
* from what the builder and the schema validator enforce.
|
|
13
|
-
*
|
|
14
|
-
* Uniqueness is checked with the ref lookups rather than `FlatMap.idRefConflict`, and deliberately so: these are
|
|
15
|
-
* a superset of it. FlatMap asks whether another element holds this idRef; the MCP must also refuse a ref that
|
|
16
|
-
* shadows a raw id or a page slug, because its handlers resolve refs through those too — calling both would just
|
|
17
|
-
* run the same rule twice. Null when the ref is usable.
|
|
18
|
-
*
|
|
19
|
-
* Enforced here, at every point a ref BECOMES an idRef — addressing an existing element by its raw id is not
|
|
20
|
-
* charset-checked, which is why the validator cannot simply tighten its own REF_RE for every ref it sees. */
|
|
21
|
-
var guardNewRef = (space, ref, field) => {
|
|
22
|
-
if (!isValidIdRef(ref)) return fail(field, `"${ref}" is not a valid idRef`, ID_REF_HINT);
|
|
23
|
-
if (findElementByRef(space.schema, ref) || findPageByRef(space.schema, ref)) return fail(field, `"${ref}" is already used by another element in this space`, TAKEN_HINT);
|
|
24
|
-
return null;
|
|
25
|
-
};
|
|
26
|
-
var removeFromParent = (space, child) => {
|
|
27
|
-
const parent = child.definition.parentId ? space.schema.flat[child.definition.parentId] : void 0;
|
|
28
|
-
if (parent?.definition.items) parent.definition.items = parent.definition.items.filter((id) => id !== child.id);
|
|
29
|
-
};
|
|
30
|
-
var placeChild = (parent, childId, index) => {
|
|
31
|
-
const items = parent.definition.items ?? (parent.definition.items = []);
|
|
32
|
-
if (index === void 0 || index < 0 || index >= items.length) items.push(childId);
|
|
33
|
-
else items.splice(index, 0, childId);
|
|
34
|
-
};
|
|
35
|
-
var writeInitialState = (el, input, merge) => {
|
|
36
|
-
const current = el.definition.initialState ?? {};
|
|
37
|
-
const next = { ...current };
|
|
38
|
-
if (input.styleVariant !== void 0) if (merge) {
|
|
39
|
-
const merged = { ...current.styleVariant };
|
|
40
|
-
for (const [cls, selectors] of Object.entries(input.styleVariant)) merged[cls] = {
|
|
41
|
-
...merged[cls],
|
|
42
|
-
...selectors
|
|
43
|
-
};
|
|
44
|
-
next.styleVariant = merged;
|
|
45
|
-
} else next.styleVariant = input.styleVariant;
|
|
46
|
-
if (input.visibility !== void 0) next.visibility = input.visibility;
|
|
47
|
-
el.definition.initialState = next;
|
|
48
|
-
};
|
|
49
|
-
var createElement = (space, page, input, parent, index) => {
|
|
50
|
-
const id = generateObjectId();
|
|
51
|
-
const { subType, ...props } = {
|
|
52
|
-
subType: input.subType,
|
|
53
|
-
...input.props
|
|
54
|
-
};
|
|
55
|
-
const styleSelectors = { base: (input.style?.base ?? []).join(" ") };
|
|
56
|
-
for (const [slot, classes] of Object.entries(input.style?.slots ?? {})) styleSelectors[slot] = classes.join(" ");
|
|
57
|
-
const el = {
|
|
58
|
-
id,
|
|
59
|
-
idRef: input.ref,
|
|
60
|
-
attributes: subType === void 0 ? props : {
|
|
61
|
-
subType,
|
|
62
|
-
...props
|
|
63
|
-
},
|
|
64
|
-
definition: {
|
|
65
|
-
rootId: page.id,
|
|
66
|
-
parentId: parent.id,
|
|
67
|
-
label: input.label ?? input.ref,
|
|
68
|
-
type: input.type,
|
|
69
|
-
items: [],
|
|
70
|
-
styleSelectors
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
space.schema.flat[id] = el;
|
|
74
|
-
placeChild(parent, id, index);
|
|
75
|
-
indexAddElement(space.schema, el, page.id);
|
|
76
|
-
if (input.initialState) writeInitialState(el, input.initialState, false);
|
|
77
|
-
for (const child of input.children ?? []) createElement(space, page, child, el, void 0);
|
|
78
|
-
};
|
|
79
|
-
/** The idRef an element is wired by, minting one when it has none. Interactions are keyed by idRef, so an element
|
|
80
|
-
* that is about to host or be targeted by a flow must have one — rather than make the agent assign it with a
|
|
81
|
-
* separate patchElement, the MCP gives it a free `<type>-<n>` ref (unique across the space) and proceeds. An
|
|
82
|
-
* element that already has an idRef keeps it. Mutates the element in place and returns the ref. */
|
|
83
|
-
var ensureIdRef = (space, el) => {
|
|
84
|
-
if (el.idRef) return el.idRef;
|
|
85
|
-
const index = spaceIndex(space.schema);
|
|
86
|
-
el.idRef = makeIdRef(el.definition.type, (candidate) => index.elementByRef.has(candidate) || index.pageByRef.has(candidate));
|
|
87
|
-
indexReRefElement(space.schema, el);
|
|
88
|
-
return el.idRef;
|
|
89
|
-
};
|
|
90
|
-
/** The key an interaction node must store to reach a target element. Every ref field also accepts a raw id, so a
|
|
91
|
-
* target given as an id is resolved to the element's idRef — the key the runtime registers callbacks under. A
|
|
92
|
-
* target that has no idRef is given one (see `ensureIdRef`), since it must be reachable to be wired to. A target
|
|
93
|
-
* that resolves to no element is left as written — it is already a ref, or a key only a plugin knows. */
|
|
94
|
-
var resolveTargetRef = (space, elementId) => {
|
|
95
|
-
const el = space.schema.flat[elementId] ?? findElementByRef(space.schema, elementId);
|
|
96
|
-
return el ? ensureIdRef(space, el) : elementId;
|
|
97
|
-
};
|
|
98
|
-
/** Resolve a non-page element within a page for the element-scoped ops (bindings, interactions). Returns the
|
|
99
|
-
* element, or a teachable OpResult when the page or element ref does not resolve — so each op reports the same
|
|
100
|
-
* errors as patchElement without repeating them. */
|
|
101
|
-
var resolveElement = (space, env, pageRef, ref) => {
|
|
102
|
-
const page = findPageByRef(space.schema, pageRef);
|
|
103
|
-
if (!page) return { error: fail("pageRef", `Page "${pageRef}" not found`, `Read plitzi://schema/${env}/pages for valid refs`) };
|
|
104
|
-
const el = resolveRef(space.schema, page, ref);
|
|
105
|
-
if (!el || el.id === page.id) return { error: fail("ref", `Element "${ref}" not found in page "${pageRef}"`, "Use an existing element ref or id") };
|
|
106
|
-
return { el };
|
|
107
|
-
};
|
|
108
|
-
//#endregion
|
|
109
|
-
export { ID_REF_HINT, collectInputRefs, createElement, ensureIdRef, folderUri, foldersUri, guardNewRef, pageUri, pagesUri, placeChild, removeFromParent, resolveElement, resolveTargetRef, schemaVarsUri, settingsUri, writeInitialState };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { bindingInput, elementInput, initialStateInput, interactionNode, position, ruleGroup, styleRefs, styleVariantInput } from "./schema/shared.js";
|
|
2
|
-
import { cssMap, cssPatchMap, definitionSlot, definitionSlotPatch, displayModeCss, displayModeCssPatch, themeValue } from "./style/shared.js";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
//#region src/modules/mcp/tools/operations/schemaIds.ts
|
|
5
|
-
/** The op union is the tool input of plitzi_apply, plitzi_validate, plitzi_render AND plitzi_preview, and every
|
|
6
|
-
* host reads it as JSON Schema on tools/list — four copies of the same 30 operations in the model's context, on
|
|
7
|
-
* EVERY request of every conversation the server is connected to. It measured ~25k tokens PER TOOL (~100k in
|
|
8
|
-
* total), which dwarfs anything a widget payload ever costs.
|
|
9
|
-
*
|
|
10
|
-
* Most of that weight is one subschema pasted over and over: an element tree appears in upsertElement,
|
|
11
|
-
* patchElement and both repeat templates; a breakpoint CSS block in every style op; a rule group in every binding
|
|
12
|
-
* and interaction step. Zod emits a named `definitions` entry (and `$ref`s to it) for any schema carrying an `id`
|
|
13
|
-
* in the global registry, so registering the shared ones here collapses those copies — without touching the ops,
|
|
14
|
-
* the tools, or the MCP SDK, whose own converter honours the registry (it is given no options otherwise).
|
|
15
|
-
*
|
|
16
|
-
* An id only pays when the schema is REUSED: giving one to a subschema that appears once makes the listing bigger,
|
|
17
|
-
* because the `definitions` entry and the ref cost more than the single copy they replace (measured, and reverted).
|
|
18
|
-
*
|
|
19
|
-
* The ids are the names the MODEL reads in the refs, so they are written for it: `Element`, not `ElementInput`.
|
|
20
|
-
* This runs once, at module load of the op vocabulary, so every conversion path benefits — the MCP tools list and
|
|
21
|
-
* the co-worker's own tool-schema converter alike. */
|
|
22
|
-
var SHARED_SCHEMAS = [
|
|
23
|
-
[elementInput, "Element"],
|
|
24
|
-
[ruleGroup, "RuleGroup"],
|
|
25
|
-
[styleRefs, "StyleRefs"],
|
|
26
|
-
[initialStateInput, "InitialState"],
|
|
27
|
-
[styleVariantInput, "StyleVariant"],
|
|
28
|
-
[interactionNode, "InteractionNode"],
|
|
29
|
-
[bindingInput, "Binding"],
|
|
30
|
-
[position, "Position"],
|
|
31
|
-
[cssMap, "Css"],
|
|
32
|
-
[cssPatchMap, "CssPatch"],
|
|
33
|
-
[definitionSlot, "StyleSlot"],
|
|
34
|
-
[definitionSlotPatch, "StyleSlotPatch"],
|
|
35
|
-
[displayModeCss, "BreakpointCss"],
|
|
36
|
-
[displayModeCssPatch, "BreakpointCssPatch"],
|
|
37
|
-
[themeValue, "ThemeValue"]
|
|
38
|
-
];
|
|
39
|
-
var claimSchemaId = (schema, id) => {
|
|
40
|
-
const taken = z.globalRegistry._idmap.get(id);
|
|
41
|
-
if (taken !== void 0 && taken !== schema) {
|
|
42
|
-
z.globalRegistry.add(schema, { id: `Plitzi${id}` });
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
z.globalRegistry.add(schema, { id });
|
|
46
|
-
};
|
|
47
|
-
/** Idempotent: the module can be imported more than once in a test run, and a schema that already carries its id
|
|
48
|
-
* is left alone (re-adding the same one is harmless but pointless). Runs at module load, never per request — the
|
|
49
|
-
* MCP builds a server per request and this must not grow with them (pinned in the statelessness test). */
|
|
50
|
-
var registerSharedSchemaIds = () => {
|
|
51
|
-
for (const [schema, id] of SHARED_SCHEMAS) if (z.globalRegistry.get(schema)?.id === void 0) claimSchemaId(schema, id);
|
|
52
|
-
};
|
|
53
|
-
//#endregion
|
|
54
|
-
export { claimSchemaId, registerSharedSchemaIds };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { defUri, defsUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty } from "../../../../helpers/opResult.js";
|
|
3
|
-
import { MODES, guardKind } from "../write.js";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
//#region src/modules/mcp/tools/operations/style/definitions/deleteDefinition.ts
|
|
6
|
-
var deleteDefinitionOp = z.object({
|
|
7
|
-
type: z.literal("deleteDefinition"),
|
|
8
|
-
ref: z.string().describe("Class ref of the definition to delete")
|
|
9
|
-
}).describe("Delete a style class definition by ref (does not detach it from elements that still list it).");
|
|
10
|
-
var deleteDefinition = (space, env, op) => {
|
|
11
|
-
const guard = guardKind(space.style, op.ref, "class");
|
|
12
|
-
if (guard) return guard;
|
|
13
|
-
for (const mode of MODES) Reflect.deleteProperty(space.style.platform[mode], op.ref);
|
|
14
|
-
return {
|
|
15
|
-
...empty(),
|
|
16
|
-
deleted: 1,
|
|
17
|
-
staleResources: [defUri(env, op.ref), defsUri(env)]
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
export { deleteDefinition, deleteDefinitionOp };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { defUri, defsUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
3
|
-
import { definitionToAI } from "../translator.js";
|
|
4
|
-
import { patchCssShape } from "../shared.js";
|
|
5
|
-
import { guardKind, mergePatch, writeStyleItem } from "../write.js";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
//#region src/modules/mcp/tools/operations/style/definitions/patchDefinition.ts
|
|
8
|
-
var patchDefinitionOp = z.object({
|
|
9
|
-
type: z.literal("patchDefinition"),
|
|
10
|
-
ref: z.string().describe("Existing class ref to patch"),
|
|
11
|
-
...patchCssShape
|
|
12
|
-
}).describe("Partially update an existing style class: the CSS you pass is merged (a null value removes that property, others are kept). Never creates — use upsertDefinition for that.");
|
|
13
|
-
var patchDefinition = (space, env, op) => {
|
|
14
|
-
const guard = guardKind(space.style, op.ref, "class");
|
|
15
|
-
if (guard) return guard;
|
|
16
|
-
const existing = definitionToAI(space.style, op.ref);
|
|
17
|
-
if (!existing) return fail("ref", `Definition "${op.ref}" not found`, "patchDefinition only updates an existing definition; use upsertDefinition to create one");
|
|
18
|
-
const { type, ref, slots: slotsPatch, ...basePatch } = op;
|
|
19
|
-
const { base, slots } = mergePatch(existing, basePatch, slotsPatch);
|
|
20
|
-
writeStyleItem(space.style, ref, base, slots, "class", void 0);
|
|
21
|
-
return {
|
|
22
|
-
...empty(),
|
|
23
|
-
updated: 1,
|
|
24
|
-
staleResources: [defUri(env, ref), defsUri(env)]
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
//#endregion
|
|
28
|
-
export { patchDefinition, patchDefinitionOp };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { defUri, defsUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty } from "../../../../helpers/opResult.js";
|
|
3
|
-
import { upsertCssShape } from "../shared.js";
|
|
4
|
-
import { guardKind, writeStyleItem } from "../write.js";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
//#region src/modules/mcp/tools/operations/style/definitions/upsertDefinition.ts
|
|
7
|
-
var upsertDefinitionOp = z.object({
|
|
8
|
-
type: z.literal("upsertDefinition"),
|
|
9
|
-
ref: z.string().describe("Class name you choose (kebab-case), or an existing class ref to fully replace"),
|
|
10
|
-
...upsertCssShape
|
|
11
|
-
}).describe("Create a reusable style class (CSS), or fully replace it when ref exists. Apply it by attaching ref to an element via its style.base. Use patchDefinition to change only some CSS.");
|
|
12
|
-
var upsertDefinition = (space, env, op) => {
|
|
13
|
-
const { type, ref, slots, ...base } = op;
|
|
14
|
-
const guard = guardKind(space.style, ref, "class");
|
|
15
|
-
if (guard) return guard;
|
|
16
|
-
writeStyleItem(space.style, ref, base, slots, "class", void 0);
|
|
17
|
-
return {
|
|
18
|
-
...empty(),
|
|
19
|
-
updated: 1,
|
|
20
|
-
staleResources: [defUri(env, ref), defsUri(env)]
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { upsertDefinition, upsertDefinitionOp };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { defUri, defsUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty } from "../../../../helpers/opResult.js";
|
|
3
|
-
import { upsertCssShape } from "../shared.js";
|
|
4
|
-
import { guardKind, writeStyleItem } from "../write.js";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
//#region src/modules/mcp/tools/operations/style/definitions/upsertDefinitions.ts
|
|
7
|
-
var definitionBody = z.object(upsertCssShape);
|
|
8
|
-
var upsertDefinitionsOp = z.object({
|
|
9
|
-
type: z.literal("upsertDefinitions"),
|
|
10
|
-
definitions: z.record(z.string(), definitionBody).describe("Every class keyed by the class name you choose (kebab-case); the value is that class CSS")
|
|
11
|
-
}).describe("Create or fully replace SEVERAL style classes in ONE operation — identical to a run of upsertDefinition, minus the repeated envelope, so prefer it whenever a batch declares more than one class. Apply each by attaching its name to an element via style.base. Use patchDefinition to change only some CSS of one class.");
|
|
12
|
-
/** Writes each entry exactly as {@link upsertDefinition} would. Entries are independent: one bad class reports its
|
|
13
|
-
* own error under `definitions.<ref>` and the rest still write — nothing is persisted while the batch carries
|
|
14
|
-
* errors, so a partial write cannot escape. */
|
|
15
|
-
var upsertDefinitions = (space, env, op) => {
|
|
16
|
-
const result = {
|
|
17
|
-
...empty(),
|
|
18
|
-
staleResources: [defsUri(env)]
|
|
19
|
-
};
|
|
20
|
-
const errors = [];
|
|
21
|
-
for (const [ref, { slots, ...base }] of Object.entries(op.definitions)) {
|
|
22
|
-
const guard = guardKind(space.style, ref, "class");
|
|
23
|
-
if (guard?.errors) {
|
|
24
|
-
errors.push(...guard.errors.map((error) => ({
|
|
25
|
-
...error,
|
|
26
|
-
path: `definitions.${ref}`
|
|
27
|
-
})));
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
writeStyleItem(space.style, ref, base, slots, "class", void 0);
|
|
31
|
-
result.updated += 1;
|
|
32
|
-
result.staleResources.push(defUri(env, ref));
|
|
33
|
-
}
|
|
34
|
-
return errors.length > 0 ? {
|
|
35
|
-
...result,
|
|
36
|
-
errors
|
|
37
|
-
} : result;
|
|
38
|
-
};
|
|
39
|
-
//#endregion
|
|
40
|
-
export { upsertDefinitions, upsertDefinitionsOp };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { globalUri, globalsUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty } from "../../../../helpers/opResult.js";
|
|
3
|
-
import { MODES, guardKind } from "../write.js";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
//#region src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.ts
|
|
6
|
-
var deleteGlobalStyleOp = z.object({
|
|
7
|
-
type: z.literal("deleteGlobalStyle"),
|
|
8
|
-
componentType: z.string().describe("Element type whose site-wide style to remove")
|
|
9
|
-
}).describe("Remove the site-wide style for an element type (elements of that type keep their own classes).");
|
|
10
|
-
var deleteGlobalStyle = (space, env, op) => {
|
|
11
|
-
const guard = guardKind(space.style, op.componentType, "element");
|
|
12
|
-
if (guard) return guard;
|
|
13
|
-
for (const mode of MODES) Reflect.deleteProperty(space.style.platform[mode], op.componentType);
|
|
14
|
-
return {
|
|
15
|
-
...empty(),
|
|
16
|
-
deleted: 1,
|
|
17
|
-
staleResources: [globalUri(env, op.componentType), globalsUri(env)]
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
export { deleteGlobalStyle, deleteGlobalStyleOp };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { globalUri, globalsUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
3
|
-
import { globalStyleToAI } from "../translator.js";
|
|
4
|
-
import { patchCssShape } from "../shared.js";
|
|
5
|
-
import { guardKind, mergePatch, writeStyleItem } from "../write.js";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
//#region src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.ts
|
|
8
|
-
var patchGlobalStyleOp = z.object({
|
|
9
|
-
type: z.literal("patchGlobalStyle"),
|
|
10
|
-
componentType: z.string().describe("Element type whose global style to merge into; affects ALL of that type"),
|
|
11
|
-
...patchCssShape
|
|
12
|
-
}).describe("Partially update the site-wide style for an element type: CSS is merged (a null value removes a property). Never creates — use upsertGlobalStyle for that.");
|
|
13
|
-
var patchGlobalStyle = (space, env, op) => {
|
|
14
|
-
const guard = guardKind(space.style, op.componentType, "element");
|
|
15
|
-
if (guard) return guard;
|
|
16
|
-
const existing = globalStyleToAI(space.style, op.componentType);
|
|
17
|
-
if (!existing) return fail("componentType", `No global style for "${op.componentType}"`, "patchGlobalStyle only updates an existing global; use upsertGlobalStyle to create one");
|
|
18
|
-
const { type, componentType, slots: slotsPatch, ...basePatch } = op;
|
|
19
|
-
const { base, slots } = mergePatch(existing, basePatch, slotsPatch);
|
|
20
|
-
writeStyleItem(space.style, componentType, base, slots, "element", componentType);
|
|
21
|
-
return {
|
|
22
|
-
...empty(),
|
|
23
|
-
updated: 1,
|
|
24
|
-
staleResources: [globalUri(env, componentType), globalsUri(env)]
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
//#endregion
|
|
28
|
-
export { patchGlobalStyle, patchGlobalStyleOp };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { globalUri, globalsUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty } from "../../../../helpers/opResult.js";
|
|
3
|
-
import { upsertCssShape } from "../shared.js";
|
|
4
|
-
import { guardKind, writeStyleItem } from "../write.js";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
//#region src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.ts
|
|
7
|
-
var upsertGlobalStyleOp = z.object({
|
|
8
|
-
type: z.literal("upsertGlobalStyle"),
|
|
9
|
-
componentType: z.string().describe("Element type to style site-wide (e.g. \"button\"); affects ALL of that type"),
|
|
10
|
-
...upsertCssShape
|
|
11
|
-
}).describe("Create or fully replace the site-wide style for an element TYPE — its CSS applies to every element of that type. To style one element only, use upsertDefinition + attach it. Use patchGlobalStyle for a partial change.");
|
|
12
|
-
var upsertGlobalStyle = (space, env, op) => {
|
|
13
|
-
const { type, componentType, slots, ...base } = op;
|
|
14
|
-
const guard = guardKind(space.style, componentType, "element");
|
|
15
|
-
if (guard) return guard;
|
|
16
|
-
writeStyleItem(space.style, componentType, base, slots, "element", componentType);
|
|
17
|
-
return {
|
|
18
|
-
...empty(),
|
|
19
|
-
updated: 1,
|
|
20
|
-
staleResources: [globalUri(env, componentType), globalsUri(env)]
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { upsertGlobalStyle, upsertGlobalStyleOp };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { idUri, idsUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty } from "../../../../helpers/opResult.js";
|
|
3
|
-
import { MODES, guardKind } from "../write.js";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
//#region src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.ts
|
|
6
|
-
var deleteIdStyleOp = z.object({
|
|
7
|
-
type: z.literal("deleteIdStyle"),
|
|
8
|
-
targetId: z.string().describe("DOM id whose id rule to remove (without the # prefix)")
|
|
9
|
-
}).describe("Remove the id rule (`#id`) for a single element (the element keeps its own classes).");
|
|
10
|
-
var deleteIdStyle = (space, env, op) => {
|
|
11
|
-
const guard = guardKind(space.style, op.targetId, "id");
|
|
12
|
-
if (guard) return guard;
|
|
13
|
-
for (const mode of MODES) Reflect.deleteProperty(space.style.platform[mode], op.targetId);
|
|
14
|
-
return {
|
|
15
|
-
...empty(),
|
|
16
|
-
deleted: 1,
|
|
17
|
-
staleResources: [idUri(env, op.targetId), idsUri(env)]
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
export { deleteIdStyle, deleteIdStyleOp };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { idUri, idsUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty, fail } from "../../../../helpers/opResult.js";
|
|
3
|
-
import { idStyleToAI } from "../translator.js";
|
|
4
|
-
import { patchCssShape } from "../shared.js";
|
|
5
|
-
import { guardKind, mergePatch, writeStyleItem } from "../write.js";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
//#region src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.ts
|
|
8
|
-
var patchIdStyleOp = z.object({
|
|
9
|
-
type: z.literal("patchIdStyle"),
|
|
10
|
-
targetId: z.string().describe("DOM id whose id rule to merge into (without the # prefix)"),
|
|
11
|
-
...patchCssShape
|
|
12
|
-
}).describe("Partially update the CSS of an id rule (`#id`): CSS is merged (a null value removes a property). Never creates — use upsertIdStyle for that.");
|
|
13
|
-
var patchIdStyle = (space, env, op) => {
|
|
14
|
-
const guard = guardKind(space.style, op.targetId, "id");
|
|
15
|
-
if (guard) return guard;
|
|
16
|
-
const existing = idStyleToAI(space.style, op.targetId);
|
|
17
|
-
if (!existing) return fail("targetId", `No id rule for "${op.targetId}"`, "patchIdStyle only updates an existing id rule; use upsertIdStyle to create one");
|
|
18
|
-
const { type, targetId, slots: slotsPatch, ...basePatch } = op;
|
|
19
|
-
const { base, slots } = mergePatch(existing, basePatch, slotsPatch);
|
|
20
|
-
writeStyleItem(space.style, targetId, base, slots, "id", void 0);
|
|
21
|
-
return {
|
|
22
|
-
...empty(),
|
|
23
|
-
updated: 1,
|
|
24
|
-
staleResources: [idUri(env, targetId), idsUri(env)]
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
//#endregion
|
|
28
|
-
export { patchIdStyle, patchIdStyleOp };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { idUri, idsUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty } from "../../../../helpers/opResult.js";
|
|
3
|
-
import { upsertCssShape } from "../shared.js";
|
|
4
|
-
import { guardKind, writeStyleItem } from "../write.js";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
//#region src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.ts
|
|
7
|
-
var upsertIdStyleOp = z.object({
|
|
8
|
-
type: z.literal("upsertIdStyle"),
|
|
9
|
-
targetId: z.string().describe("DOM id of the element to style (without the # prefix); matches its `id` attribute"),
|
|
10
|
-
...upsertCssShape
|
|
11
|
-
}).describe("Create or fully replace the CSS for a single element addressed by its DOM id (`#id`). The element must carry that `id` attribute. To style by reusable class instead, use upsertDefinition. Use patchIdStyle for a partial change.");
|
|
12
|
-
var upsertIdStyle = (space, env, op) => {
|
|
13
|
-
const { type, targetId, slots, ...base } = op;
|
|
14
|
-
const guard = guardKind(space.style, targetId, "id");
|
|
15
|
-
if (guard) return guard;
|
|
16
|
-
writeStyleItem(space.style, targetId, base, slots, "id", void 0);
|
|
17
|
-
return {
|
|
18
|
-
...empty(),
|
|
19
|
-
updated: 1,
|
|
20
|
-
staleResources: [idUri(env, targetId), idsUri(env)]
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { upsertIdStyle, upsertIdStyleOp };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { deleteDefinitionOp } from "./definitions/deleteDefinition.js";
|
|
2
|
-
import { patchDefinitionOp } from "./definitions/patchDefinition.js";
|
|
3
|
-
import { upsertDefinitionOp } from "./definitions/upsertDefinition.js";
|
|
4
|
-
import { upsertDefinitionsOp } from "./definitions/upsertDefinitions.js";
|
|
5
|
-
import { deleteGlobalStyleOp } from "./globalStyles/deleteGlobalStyle.js";
|
|
6
|
-
import { patchGlobalStyleOp } from "./globalStyles/patchGlobalStyle.js";
|
|
7
|
-
import { upsertGlobalStyleOp } from "./globalStyles/upsertGlobalStyle.js";
|
|
8
|
-
import { deleteIdStyleOp } from "./idStyles/deleteIdStyle.js";
|
|
9
|
-
import { patchIdStyleOp } from "./idStyles/patchIdStyle.js";
|
|
10
|
-
import { upsertIdStyleOp } from "./idStyles/upsertIdStyle.js";
|
|
11
|
-
import { deleteStyleVariableOp } from "./variables/deleteStyleVariable.js";
|
|
12
|
-
import { upsertStyleVariableOp } from "./variables/upsertStyleVariable.js";
|
|
13
|
-
//#region src/modules/mcp/tools/operations/style/operations.ts
|
|
14
|
-
var styleOps = {
|
|
15
|
-
upsertDefinition: upsertDefinitionOp,
|
|
16
|
-
upsertDefinitions: upsertDefinitionsOp,
|
|
17
|
-
patchDefinition: patchDefinitionOp,
|
|
18
|
-
deleteDefinition: deleteDefinitionOp,
|
|
19
|
-
upsertGlobalStyle: upsertGlobalStyleOp,
|
|
20
|
-
patchGlobalStyle: patchGlobalStyleOp,
|
|
21
|
-
deleteGlobalStyle: deleteGlobalStyleOp,
|
|
22
|
-
upsertIdStyle: upsertIdStyleOp,
|
|
23
|
-
patchIdStyle: patchIdStyleOp,
|
|
24
|
-
deleteIdStyle: deleteIdStyleOp,
|
|
25
|
-
upsertStyleVariable: upsertStyleVariableOp,
|
|
26
|
-
deleteStyleVariable: deleteStyleVariableOp
|
|
27
|
-
};
|
|
28
|
-
//#endregion
|
|
29
|
-
export { styleOps };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
//#region src/modules/mcp/tools/operations/style/shared.ts
|
|
3
|
-
var cssMap = z.record(z.string(), z.union([z.string(), z.number()])).describe("Plain kebab-case CSS. Shorthands are welcome — `border: 1px solid red`, `padding: 8px 16px`, `font: bold 16px/1.5 Arial`, `transition: opacity 200ms ease` — and are stored as their longhands so a breakpoint/state/variant can override each property on its own. Use var(--name) for style tokens and {{name}} for schema vars.");
|
|
4
|
-
var displayModeCss = z.object({
|
|
5
|
-
desktop: cssMap.optional(),
|
|
6
|
-
tablet: cssMap.optional(),
|
|
7
|
-
mobile: cssMap.optional()
|
|
8
|
-
});
|
|
9
|
-
var definitionSlot = displayModeCss.extend({
|
|
10
|
-
states: z.record(z.string(), displayModeCss).optional(),
|
|
11
|
-
variants: z.record(z.string(), displayModeCss).optional()
|
|
12
|
-
});
|
|
13
|
-
var cssPatchMap = z.record(z.string(), z.union([
|
|
14
|
-
z.string(),
|
|
15
|
-
z.number(),
|
|
16
|
-
z.null()
|
|
17
|
-
])).describe("Plain kebab-case CSS merged onto the existing declarations; shorthands are accepted and expanded, so `padding: 8px` replaces all four sides. A value of null removes the property — null on a shorthand (`border: null`) removes every longhand it controls.");
|
|
18
|
-
var displayModeCssPatch = z.object({
|
|
19
|
-
desktop: cssPatchMap.optional(),
|
|
20
|
-
tablet: cssPatchMap.optional(),
|
|
21
|
-
mobile: cssPatchMap.optional()
|
|
22
|
-
});
|
|
23
|
-
var definitionSlotPatch = displayModeCssPatch.extend({
|
|
24
|
-
states: z.record(z.string(), displayModeCssPatch).optional(),
|
|
25
|
-
variants: z.record(z.string(), displayModeCssPatch).optional()
|
|
26
|
-
});
|
|
27
|
-
var styleCategory = z.enum([
|
|
28
|
-
"color",
|
|
29
|
-
"spacing",
|
|
30
|
-
"shadow",
|
|
31
|
-
"custom"
|
|
32
|
-
]);
|
|
33
|
-
var themeValue = z.union([
|
|
34
|
-
z.string(),
|
|
35
|
-
z.number(),
|
|
36
|
-
z.object({
|
|
37
|
-
light: z.string().optional(),
|
|
38
|
-
dark: z.string().optional(),
|
|
39
|
-
default: z.string().optional()
|
|
40
|
-
})
|
|
41
|
-
]);
|
|
42
|
-
var upsertCssShape = {
|
|
43
|
-
desktop: cssMap.optional(),
|
|
44
|
-
tablet: cssMap.optional(),
|
|
45
|
-
mobile: cssMap.optional(),
|
|
46
|
-
states: z.record(z.string(), displayModeCss).optional(),
|
|
47
|
-
variants: z.record(z.string(), displayModeCss).optional(),
|
|
48
|
-
slots: z.record(z.string(), definitionSlot).optional()
|
|
49
|
-
};
|
|
50
|
-
var patchCssShape = {
|
|
51
|
-
desktop: cssPatchMap.optional(),
|
|
52
|
-
tablet: cssPatchMap.optional(),
|
|
53
|
-
mobile: cssPatchMap.optional(),
|
|
54
|
-
states: z.record(z.string(), displayModeCssPatch).optional(),
|
|
55
|
-
variants: z.record(z.string(), displayModeCssPatch).optional(),
|
|
56
|
-
slots: z.record(z.string(), definitionSlotPatch).optional()
|
|
57
|
-
};
|
|
58
|
-
//#endregion
|
|
59
|
-
export { cssMap, cssPatchMap, definitionSlot, definitionSlotPatch, displayModeCss, displayModeCssPatch, patchCssShape, styleCategory, themeValue, upsertCssShape };
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
//#region src/modules/mcp/tools/operations/style/translator.ts
|
|
2
|
-
var DISPLAY_MODES = [
|
|
3
|
-
"desktop",
|
|
4
|
-
"tablet",
|
|
5
|
-
"mobile"
|
|
6
|
-
];
|
|
7
|
-
var isClassDefinition = (item) => item.type === "class";
|
|
8
|
-
var definitionRefs = (style) => {
|
|
9
|
-
const refs = /* @__PURE__ */ new Set();
|
|
10
|
-
for (const mode of DISPLAY_MODES) for (const [name, item] of Object.entries(style.platform[mode])) if (isClassDefinition(item)) refs.add(name);
|
|
11
|
-
return Array.from(refs).sort();
|
|
12
|
-
};
|
|
13
|
-
var fillSlot = (target, mode, block) => {
|
|
14
|
-
if (block.default && Object.keys(block.default).length > 0) target[mode] = block.default;
|
|
15
|
-
if (block.states) {
|
|
16
|
-
for (const [state, obj] of Object.entries(block.states)) if (Object.keys(obj).length > 0) {
|
|
17
|
-
(target.states ??= {})[state] ??= {};
|
|
18
|
-
target.states[state][mode] = obj;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
if (block.variants) {
|
|
22
|
-
for (const [name, variant] of Object.entries(block.variants)) if (variant.default && Object.keys(variant.default).length > 0) {
|
|
23
|
-
(target.variants ??= {})[name] ??= {};
|
|
24
|
-
target.variants[name][mode] = variant.default;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var projectItem = (style, ref, accept) => {
|
|
29
|
-
const def = { ref };
|
|
30
|
-
let found = false;
|
|
31
|
-
for (const mode of DISPLAY_MODES) {
|
|
32
|
-
const item = style.platform[mode][ref];
|
|
33
|
-
if (!item || !accept(item)) continue;
|
|
34
|
-
found = true;
|
|
35
|
-
for (const [slot, block] of Object.entries(item.attributes)) if (slot === "base") fillSlot(def, mode, block);
|
|
36
|
-
else fillSlot((def.slots ??= {})[slot] ??= {}, mode, block);
|
|
37
|
-
}
|
|
38
|
-
return found ? def : void 0;
|
|
39
|
-
};
|
|
40
|
-
var definitionToAI = (style, ref) => projectItem(style, ref, isClassDefinition);
|
|
41
|
-
var definitionVariantNames = (style, ref) => {
|
|
42
|
-
const def = definitionToAI(style, ref);
|
|
43
|
-
if (!def) return;
|
|
44
|
-
const result = {};
|
|
45
|
-
const baseVariants = Object.keys(def.variants ?? {});
|
|
46
|
-
if (baseVariants.length > 0) result.base = baseVariants.sort();
|
|
47
|
-
for (const [slot, slotDef] of Object.entries(def.slots ?? {})) {
|
|
48
|
-
const variants = Object.keys(slotDef.variants ?? {});
|
|
49
|
-
if (variants.length > 0) result[slot] = variants.sort();
|
|
50
|
-
}
|
|
51
|
-
return Object.keys(result).length > 0 ? result : void 0;
|
|
52
|
-
};
|
|
53
|
-
var globalStylesForType = (style, componentType) => {
|
|
54
|
-
const isGlobal = (item) => item.type === "element" && item.componentType === componentType;
|
|
55
|
-
const refs = /* @__PURE__ */ new Set();
|
|
56
|
-
for (const mode of DISPLAY_MODES) for (const [name, item] of Object.entries(style.platform[mode])) if (isGlobal(item)) refs.add(name);
|
|
57
|
-
const globals = [];
|
|
58
|
-
for (const ref of Array.from(refs).sort()) {
|
|
59
|
-
const def = projectItem(style, ref, isGlobal);
|
|
60
|
-
if (def) globals.push({
|
|
61
|
-
...def,
|
|
62
|
-
appliesToType: componentType
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return globals;
|
|
66
|
-
};
|
|
67
|
-
var globalStyleToAI = (style, componentType) => {
|
|
68
|
-
const def = projectItem(style, componentType, (item) => item.type === "element" && item.componentType === componentType);
|
|
69
|
-
return def ? {
|
|
70
|
-
...def,
|
|
71
|
-
appliesToType: componentType
|
|
72
|
-
} : void 0;
|
|
73
|
-
};
|
|
74
|
-
var globalStyleTypes = (style) => {
|
|
75
|
-
const types = /* @__PURE__ */ new Set();
|
|
76
|
-
for (const mode of DISPLAY_MODES) for (const item of Object.values(style.platform[mode])) if (item.type === "element" && item.componentType) types.add(item.componentType);
|
|
77
|
-
return Array.from(types).sort();
|
|
78
|
-
};
|
|
79
|
-
var idStyleIds = (style) => {
|
|
80
|
-
const ids = /* @__PURE__ */ new Set();
|
|
81
|
-
for (const mode of DISPLAY_MODES) for (const [name, item] of Object.entries(style.platform[mode])) if (item.type === "id") ids.add(name);
|
|
82
|
-
return Array.from(ids).sort();
|
|
83
|
-
};
|
|
84
|
-
var idStyleToAI = (style, targetId) => {
|
|
85
|
-
const def = projectItem(style, targetId, (item) => item.type === "id");
|
|
86
|
-
return def ? {
|
|
87
|
-
...def,
|
|
88
|
-
targetId
|
|
89
|
-
} : void 0;
|
|
90
|
-
};
|
|
91
|
-
var styleVariablesToAI = (style) => {
|
|
92
|
-
const data = {};
|
|
93
|
-
for (const [category, group] of Object.entries(style.variables)) data[category] = Object.entries(group).map(([name, value]) => ({
|
|
94
|
-
name,
|
|
95
|
-
reference: `var(--${name})`,
|
|
96
|
-
value
|
|
97
|
-
}));
|
|
98
|
-
return data;
|
|
99
|
-
};
|
|
100
|
-
//#endregion
|
|
101
|
-
export { definitionRefs, definitionToAI, definitionVariantNames, globalStyleToAI, globalStyleTypes, globalStylesForType, idStyleIds, idStyleToAI, isClassDefinition, styleVariablesToAI };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { styleVarUri, styleVarsUri } from "../../../../helpers/uris.js";
|
|
2
|
-
import { empty } from "../../../../helpers/opResult.js";
|
|
3
|
-
import { styleCategory } from "../shared.js";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
//#region src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.ts
|
|
6
|
-
var deleteStyleVariableOp = z.object({
|
|
7
|
-
type: z.literal("deleteStyleVariable"),
|
|
8
|
-
category: styleCategory,
|
|
9
|
-
name: z.string().describe("Token name without the -- prefix")
|
|
10
|
-
}).describe("Delete a design token by category + name.");
|
|
11
|
-
var deleteStyleVariable = (space, env, op) => {
|
|
12
|
-
const group = space.style.variables[op.category];
|
|
13
|
-
if (group) Reflect.deleteProperty(group, op.name);
|
|
14
|
-
return {
|
|
15
|
-
...empty(),
|
|
16
|
-
deleted: 1,
|
|
17
|
-
staleResources: [styleVarUri(env, op.category), styleVarsUri(env)]
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
export { deleteStyleVariable, deleteStyleVariableOp };
|