@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,27 +1,43 @@
|
|
|
1
|
+
import { buildOfflineDataCacheKey } from "../../helpers/cache/keys.js";
|
|
1
2
|
import { loadPluginComponents } from "./loadPluginComponents.js";
|
|
3
|
+
import { createOfflineDataLoader } from "../../helpers/offlineDataLoader.js";
|
|
2
4
|
import { registerExternalPlugins } from "./registerExternalPlugins.js";
|
|
5
|
+
import { sdkAssetVersion } from "../../core/sdkAssets.js";
|
|
3
6
|
import { buildServerInfo } from "../../helpers/buildServerInfo.js";
|
|
4
|
-
import { buildOfflineDataCacheKey } from "../../helpers/cache/keys.js";
|
|
5
7
|
import { escapeJson } from "../../helpers/escapeJson.js";
|
|
6
8
|
import { readCookie } from "../../helpers/readCookie.js";
|
|
9
|
+
import { resolveDebugMode } from "../../helpers/resolveDebugMode.js";
|
|
7
10
|
//#region src/modules/ssr/prepareRender.tsx
|
|
8
11
|
var prepareRender = async (req, config, spaceId, environment, revision, pluginManager, offlineDataCache, metrics, offlineDataOverride) => {
|
|
9
12
|
const m = (name, fn) => metrics ? metrics.measure(name, fn) : Promise.resolve(fn());
|
|
10
13
|
const offlineCacheKey = environment !== "main" ? buildOfflineDataCacheKey(spaceId, environment, revision) : void 0;
|
|
11
14
|
const cachedOfflineStr = offlineDataOverride === void 0 && offlineCacheKey ? offlineDataCache?.get(offlineCacheKey) : void 0;
|
|
12
|
-
const
|
|
15
|
+
const loadOfflineData = createOfflineDataLoader(() => {
|
|
16
|
+
if (offlineDataOverride !== void 0) return Promise.resolve(offlineDataOverride);
|
|
17
|
+
if (cachedOfflineStr) return Promise.resolve(JSON.parse(cachedOfflineStr));
|
|
18
|
+
return m("schema", () => config.adapters.getOfflineData(spaceId, environment, revision));
|
|
19
|
+
});
|
|
20
|
+
const [offlineData, server] = await Promise.all([loadOfflineData(), m("rsc", () => buildServerInfo(req, config, loadOfflineData))]);
|
|
13
21
|
if (offlineDataOverride === void 0 && !cachedOfflineStr && offlineCacheKey && offlineData !== void 0) offlineDataCache?.set(offlineCacheKey, JSON.stringify(offlineData));
|
|
14
|
-
const
|
|
22
|
+
const version = config.assetVersion ?? sdkAssetVersion();
|
|
23
|
+
const v = version ? `?v=${version}` : "";
|
|
15
24
|
const sdkDevToolsStylePath = `/sdk-assets/plitzi-sdk-devtools.css${v}`;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
25
|
+
const debugMode = resolveDebugMode(config.debugMode ?? config.devMode, readCookie(req.headers.cookie, "plitzi_debug"));
|
|
26
|
+
const { degrade, analytics } = req.ctx.meter ?? {};
|
|
27
|
+
const clientAnalytics = analytics ? {
|
|
28
|
+
...analytics,
|
|
29
|
+
firstViewCounted: true
|
|
30
|
+
} : void 0;
|
|
31
|
+
const branding = degrade ? true : void 0;
|
|
18
32
|
const offlineDataStr = escapeJson(JSON.stringify({
|
|
19
33
|
offlineData,
|
|
20
34
|
offlineMode: true,
|
|
21
35
|
environment,
|
|
22
36
|
renderMode: "raw",
|
|
23
37
|
server,
|
|
24
|
-
sdkDevToolsStylePath
|
|
38
|
+
sdkDevToolsStylePath,
|
|
39
|
+
...clientAnalytics ? { analytics: clientAnalytics } : {},
|
|
40
|
+
...branding ? { branding } : {}
|
|
25
41
|
}));
|
|
26
42
|
const pluginNames = req.ctx.spaceDeployment?.pluginNames ?? [];
|
|
27
43
|
const pluginSources = req.ctx.spaceDeployment?.pluginSources;
|
|
@@ -48,7 +64,8 @@ var prepareRender = async (req, config, spaceId, environment, revision, pluginMa
|
|
|
48
64
|
server,
|
|
49
65
|
environment: req.ctx.spaceDeployment?.environment ?? environment,
|
|
50
66
|
debugMode,
|
|
51
|
-
sdkDevToolsStylePath
|
|
67
|
+
sdkDevToolsStylePath,
|
|
68
|
+
branding
|
|
52
69
|
},
|
|
53
70
|
entries,
|
|
54
71
|
templateParams: {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DraftStore, OfflineDataRaw, SSRRequest, SSRServerConfig } from '@plitzi/sdk-shared';
|
|
2
|
+
/** The READ side of draft-preview: a render resolving a stashed draft from its one-shot token. The write side —
|
|
3
|
+
* applying unsaved operations and rendering the result — lives in `@plitzi/sdk-mcp`, which is what knows how to
|
|
4
|
+
* interpret an operation; a page-only deployment keeps this much and never loads that. */
|
|
5
|
+
/** In-memory one-shot draft store — the default when the consumer injects none. Fine for a single replica;
|
|
6
|
+
* a multi-replica deployment must inject a shared store so a preview URL resolves on any replica. */
|
|
7
|
+
export declare const createMemoryDraftStore: () => DraftStore;
|
|
8
|
+
/** Consume the draft override for a render, if the request carries a valid preview token. Returns undefined on
|
|
9
|
+
* a normal request (renders persisted state) or when the token is unknown/expired (one-shot / TTL). */
|
|
10
|
+
export declare const takeDraftOverride: (req: SSRRequest, config: SSRServerConfig) => Promise<OfflineDataRaw | undefined>;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { cloneSpace, findPageByRef, getPageElements } from "../mcp/helpers/space.js";
|
|
3
|
-
import { applyOperations } from "../mcp/tools/apply/dispatch.js";
|
|
4
|
-
import { validateOperations } from "../mcp/tools/shared/validator/index.js";
|
|
5
|
-
import { PREVIEW_TOKEN_PARAM } from "../mcp/constants.js";
|
|
6
|
-
import { buildBody } from "./buildBody.js";
|
|
7
|
-
import { randomUUID } from "node:crypto";
|
|
1
|
+
import { PREVIEW_TOKEN_PARAM } from "../../core/previewToken.js";
|
|
8
2
|
//#region src/modules/ssr/preview.ts
|
|
3
|
+
/** The READ side of draft-preview: a render resolving a stashed draft from its one-shot token. The write side —
|
|
4
|
+
* applying unsaved operations and rendering the result — lives in `@plitzi/sdk-mcp`, which is what knows how to
|
|
5
|
+
* interpret an operation; a page-only deployment keeps this much and never loads that. */
|
|
9
6
|
/** In-memory one-shot draft store — the default when the consumer injects none. Fine for a single replica;
|
|
10
7
|
* a multi-replica deployment must inject a shared store so a preview URL resolves on any replica. */
|
|
11
8
|
var createMemoryDraftStore = () => {
|
|
@@ -32,75 +29,5 @@ var takeDraftOverride = async (req, config) => {
|
|
|
32
29
|
if (!token || !config.draftStore) return;
|
|
33
30
|
return config.draftStore.take(token);
|
|
34
31
|
};
|
|
35
|
-
var resolvePagePath = (schema, pageRef) => {
|
|
36
|
-
const pages = getPageElements(schema);
|
|
37
|
-
const page = pageRef ? findPageByRef(schema, pageRef) : pages.find((p) => p.attributes.default) ?? pages[0];
|
|
38
|
-
const slug = page && typeof page.attributes.slug === "string" ? page.attributes.slug : "";
|
|
39
|
-
return slug.startsWith("/") ? slug : `/${slug}`;
|
|
40
|
-
};
|
|
41
|
-
var syntheticRequest = (pagePath) => ({
|
|
42
|
-
method: "GET",
|
|
43
|
-
path: pagePath,
|
|
44
|
-
search: "",
|
|
45
|
-
url: pagePath,
|
|
46
|
-
hostname: "localhost",
|
|
47
|
-
protocol: "https",
|
|
48
|
-
headers: {},
|
|
49
|
-
query: {},
|
|
50
|
-
ctx: {}
|
|
51
|
-
});
|
|
52
|
-
/** Build a preview of a page: apply any unsaved `operations` to a clone (never persisted), render the resulting
|
|
53
|
-
* draft to full HTML via the SSR pipeline, and stash the draft under a one-shot token so a browser can fetch
|
|
54
|
-
* the exact same render at `?__pt=<token>` (for screenshots). With no operations it previews persisted state. */
|
|
55
|
-
var createPreview = async (body, config, renderFn, pluginManager, caches) => {
|
|
56
|
-
const env = body.env ?? "main";
|
|
57
|
-
const revision = 0;
|
|
58
|
-
const offlineData = await config.adapters.getOfflineData(body.spaceId, env, revision);
|
|
59
|
-
if (!offlineData) return {
|
|
60
|
-
ok: false,
|
|
61
|
-
error: "NO_DATA",
|
|
62
|
-
message: `No offline data for space ${body.spaceId} (${env}).`
|
|
63
|
-
};
|
|
64
|
-
let draftOffline = offlineData;
|
|
65
|
-
if (body.operations && body.operations.length > 0) {
|
|
66
|
-
const draft = cloneSpace({
|
|
67
|
-
schema: offlineData.schema,
|
|
68
|
-
style: offlineData.style
|
|
69
|
-
});
|
|
70
|
-
const validation = validateOperations(draft, body.operations);
|
|
71
|
-
if (!validation.valid) return {
|
|
72
|
-
ok: false,
|
|
73
|
-
error: "INVALID_OPERATIONS",
|
|
74
|
-
message: "The operations did not validate.",
|
|
75
|
-
errors: validation.errors
|
|
76
|
-
};
|
|
77
|
-
const outcome = applyOperations(draft, env, body.operations);
|
|
78
|
-
if (outcome.errors.length > 0) return {
|
|
79
|
-
ok: false,
|
|
80
|
-
error: "APPLY_FAILED",
|
|
81
|
-
message: "The operations could not be applied.",
|
|
82
|
-
errors: outcome.errors
|
|
83
|
-
};
|
|
84
|
-
draftOffline = {
|
|
85
|
-
...offlineData,
|
|
86
|
-
schema: draft.schema,
|
|
87
|
-
style: draft.style
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
const pagePath = resolvePagePath(draftOffline.schema, body.pageRef);
|
|
91
|
-
const { body: html } = await buildBody(syntheticRequest(pagePath), config, body.spaceId, env, revision, renderFn, pluginManager, caches.offlineData, void 0, draftOffline);
|
|
92
|
-
let token;
|
|
93
|
-
if (config.draftStore) {
|
|
94
|
-
token = randomUUID();
|
|
95
|
-
await config.draftStore.put(token, draftOffline, config.preview?.ttlMs ?? 6e4);
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
ok: true,
|
|
99
|
-
token,
|
|
100
|
-
pagePath,
|
|
101
|
-
html: html ?? "",
|
|
102
|
-
stateVersion: computeVersion(draftOffline)
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
32
|
//#endregion
|
|
106
|
-
export {
|
|
33
|
+
export { createMemoryDraftStore, takeDraftOverride };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import crypto from "node:crypto";
|
|
3
2
|
import fs from "node:fs/promises";
|
|
3
|
+
import crypto from "node:crypto";
|
|
4
4
|
//#region src/modules/ssr/registerExternalPlugins.ts
|
|
5
5
|
var MANIFEST_TTL_MS = 6e5;
|
|
6
6
|
var manifestCache = /* @__PURE__ */ new Map();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TtlCache } from '../../helpers/cache';
|
|
2
|
+
import { RequestMetrics } from '../../helpers/metrics';
|
|
3
|
+
import { PluginManager } from '../../plugins/manager';
|
|
4
|
+
import { Environment, OfflineDataRaw, SSRPageServerConfig, SSRRequest, SSRResponseHelpers, SSRTemplateFn } from '@plitzi/sdk-shared';
|
|
5
|
+
export declare const streamBody: (req: SSRRequest, res: SSRResponseHelpers, config: SSRPageServerConfig, spaceId: number, environment: Environment, revision: number, renderFn: SSRTemplateFn, pluginManager: PluginManager, offlineDataCache?: TtlCache<string>, htmlCache?: TtlCache<string>, cacheKey?: string, metrics?: RequestMetrics, offlineDataOverride?: OfflineDataRaw) => Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { applySSRResult } from "./applySSRResult.js";
|
|
1
2
|
import Component from "./Component.js";
|
|
2
3
|
import { prepareRender } from "./prepareRender.js";
|
|
3
|
-
import { applySSRResult } from "./applySSRResult.js";
|
|
4
4
|
import { renderToPipeableStream } from "react-dom/server";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { Writable } from "node:stream";
|
package/dist/plugins/compile.js
CHANGED
package/dist/plugins/manager.js
CHANGED
|
@@ -136,10 +136,12 @@ var PluginManager = class {
|
|
|
136
136
|
if (action === "compile") {
|
|
137
137
|
const { hasCSS } = await compilePlugin(jsPath, dir, this.devMode);
|
|
138
138
|
if (hasCSS) cssUrl = `${this.urlPrefix}/${name}/index.css`;
|
|
139
|
-
else if (cssPath)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
else if (cssPath) {
|
|
140
|
+
if (this.isWebUrl(cssPath)) cssUrl = cssPath;
|
|
141
|
+
else {
|
|
142
|
+
await copyPlugin(cssPath, dir, "index.css");
|
|
143
|
+
cssUrl = `${this.urlPrefix}/${name}/index.css`;
|
|
144
|
+
}
|
|
143
145
|
}
|
|
144
146
|
} else if (action === "download") {
|
|
145
147
|
const jsRes = await fetch(jsPath);
|
|
@@ -156,10 +158,12 @@ var PluginManager = class {
|
|
|
156
158
|
}
|
|
157
159
|
} else {
|
|
158
160
|
await copyPlugin(jsPath, dir, "index.js");
|
|
159
|
-
if (cssPath)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
if (cssPath) {
|
|
162
|
+
if (this.isWebUrl(cssPath)) cssUrl = cssPath;
|
|
163
|
+
else {
|
|
164
|
+
await copyPlugin(cssPath, dir, "index.css");
|
|
165
|
+
cssUrl = `${this.urlPrefix}/${name}/index.css`;
|
|
166
|
+
}
|
|
163
167
|
}
|
|
164
168
|
}
|
|
165
169
|
const compiledAt = Date.now();
|
package/dist/ssr.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The render primitives a stage needs to produce a page, for packages that extend the page pipeline.
|
|
2
|
+
*
|
|
3
|
+
* Import it as `@plitzi/sdk-server/ssr`. A stage injected into a page server receives `SSRContext` and so
|
|
4
|
+
* already holds the render singletons; this entry is what lets it USE them — `buildBody` renders offline data
|
|
5
|
+
* to HTML, `takeDraftOverride` is the read side of the draft store. `@plitzi/sdk-mcp`'s draft-preview endpoint
|
|
6
|
+
* is the in-tree consumer.
|
|
7
|
+
*
|
|
8
|
+
* Separate from the root barrel on purpose: that one also pulls RSC, connectors and the adapters, none of which
|
|
9
|
+
* an injected render stage needs. */
|
|
10
|
+
export { buildBody } from './modules/ssr/buildBody';
|
|
11
|
+
export { createMemoryDraftStore, takeDraftOverride } from './modules/ssr/preview';
|
|
12
|
+
export { PREVIEW_TOKEN_PARAM } from './core/previewToken';
|
|
13
|
+
export type { PluginManager } from './plugins/manager';
|
|
14
|
+
export type { ServerCaches } from './helpers/cache';
|
|
15
|
+
export type { BaseContext, PipelineExtensions, SSRContext, Stage } from './core/http/types';
|
package/dist/ssr.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PREVIEW_TOKEN_PARAM } from "./core/previewToken.js";
|
|
2
|
+
import { createMemoryDraftStore, takeDraftOverride } from "./modules/ssr/preview.js";
|
|
3
|
+
import { buildBody } from "./modules/ssr/buildBody.js";
|
|
4
|
+
export { PREVIEW_TOKEN_PARAM, buildBody, createMemoryDraftStore, takeDraftOverride };
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.1",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
|
-
"dist"
|
|
7
|
-
"skills"
|
|
6
|
+
"dist"
|
|
8
7
|
],
|
|
9
8
|
"main": "dist/index.js",
|
|
10
9
|
"module": "dist/index.js",
|
|
@@ -15,10 +14,20 @@
|
|
|
15
14
|
"import": "./dist/index.js",
|
|
16
15
|
"default": "./dist/index.js"
|
|
17
16
|
},
|
|
18
|
-
"./
|
|
19
|
-
"types": "./dist/
|
|
20
|
-
"import": "./dist/
|
|
21
|
-
"default": "./dist/
|
|
17
|
+
"./kernel": {
|
|
18
|
+
"types": "./dist/kernel.d.ts",
|
|
19
|
+
"import": "./dist/kernel.js",
|
|
20
|
+
"default": "./dist/kernel.js"
|
|
21
|
+
},
|
|
22
|
+
"./handlers": {
|
|
23
|
+
"types": "./dist/handlers.d.ts",
|
|
24
|
+
"import": "./dist/handlers.js",
|
|
25
|
+
"default": "./dist/handlers.js"
|
|
26
|
+
},
|
|
27
|
+
"./ssr": {
|
|
28
|
+
"types": "./dist/ssr.d.ts",
|
|
29
|
+
"import": "./dist/ssr.js",
|
|
30
|
+
"default": "./dist/ssr.js"
|
|
22
31
|
}
|
|
23
32
|
},
|
|
24
33
|
"repository": {
|
|
@@ -28,14 +37,11 @@
|
|
|
28
37
|
"type": "module",
|
|
29
38
|
"sideEffects": false,
|
|
30
39
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@plitzi/plitzi-sdk": "0.32.25",
|
|
34
|
-
"@plitzi/sdk-schema": "0.32.25",
|
|
35
|
-
"@plitzi/sdk-shared": "0.32.25",
|
|
40
|
+
"@plitzi/plitzi-sdk": "0.33.1",
|
|
41
|
+
"@plitzi/sdk-shared": "0.33.1",
|
|
36
42
|
"ejs": "^6.0.1",
|
|
37
|
-
"esbuild": "^0.28.
|
|
38
|
-
"
|
|
43
|
+
"esbuild": "^0.28.2",
|
|
44
|
+
"jsonwebtoken": "^9.0.3"
|
|
39
45
|
},
|
|
40
46
|
"peerDependencies": {
|
|
41
47
|
"react": "^19",
|
|
@@ -43,33 +49,31 @@
|
|
|
43
49
|
},
|
|
44
50
|
"devDependencies": {
|
|
45
51
|
"@types/ejs": "^3.1.5",
|
|
46
|
-
"@types/
|
|
47
|
-
"@types/node": "^26.
|
|
52
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
53
|
+
"@types/node": "^26.2.0",
|
|
48
54
|
"@types/react": "^19.2.18",
|
|
49
55
|
"@vitejs/plugin-react": "^6.0.5",
|
|
50
56
|
"@vitest/coverage-v8": "^4.1.10",
|
|
51
57
|
"eslint": "^9.39.5",
|
|
52
58
|
"eslint-plugin-import": "^2.32.0",
|
|
53
|
-
"jsdom": "^30.0.1",
|
|
54
59
|
"react": "^19.2.8",
|
|
55
60
|
"react-dom": "^19.2.8",
|
|
56
|
-
"tsx": "^4.23.
|
|
61
|
+
"tsx": "^4.23.12",
|
|
57
62
|
"typescript": "^6.0.3",
|
|
58
|
-
"vite": "^8.2.
|
|
63
|
+
"vite": "^8.2.1",
|
|
59
64
|
"vite-plugin-dts": "^5.0.3",
|
|
60
65
|
"vitest": "^4.1.10"
|
|
61
66
|
},
|
|
62
67
|
"scripts": {
|
|
63
|
-
"start:dev": "node --import ./
|
|
64
|
-
"start": "TSX_TSCONFIG_PATH=tsconfig.app.json node --import tsx
|
|
65
|
-
"start:watch": "TSX_TSCONFIG_PATH=tsconfig.app.json node --import tsx --watch
|
|
66
|
-
"start:inspect": "TSX_TSCONFIG_PATH=tsconfig.app.json node --import tsx --inspect
|
|
68
|
+
"start:dev": "node --import ./dev/register-alias.mjs --watch dev/main.ts",
|
|
69
|
+
"start": "TSX_TSCONFIG_PATH=tsconfig.app.json node --import tsx dev/main.ts",
|
|
70
|
+
"start:watch": "TSX_TSCONFIG_PATH=tsconfig.app.json node --import tsx --watch dev/main.ts",
|
|
71
|
+
"start:inspect": "TSX_TSCONFIG_PATH=tsconfig.app.json node --import tsx --inspect dev/main.ts",
|
|
67
72
|
"build:dev": "vite build --mode development",
|
|
68
73
|
"build:prod": "vite build",
|
|
69
|
-
"lint": "TIMING=1 eslint ./src",
|
|
74
|
+
"lint": "TIMING=1 eslint ./src ./dev",
|
|
70
75
|
"typecheck": "tsc -p tsconfig.app.json --noEmit",
|
|
71
76
|
"test": "vitest run",
|
|
72
|
-
"test:e2e": "vitest run src/modules/mcp/e2e",
|
|
73
77
|
"test:coverage": "vitest run --coverage",
|
|
74
78
|
"bench": "vitest bench --run"
|
|
75
79
|
}
|
package/dist/.gitkeep
DELETED
|
File without changes
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { createHttpServer } from "./baseServer.js";
|
|
2
|
-
import { makeHandler } from "../http/dispatcher.js";
|
|
3
|
-
import { buildMCPPipeline } from "../services/registry.js";
|
|
4
|
-
//#region src/core/server/mcpServer.ts
|
|
5
|
-
var noPlugins = {
|
|
6
|
-
register: () => void 0,
|
|
7
|
-
invalidate: () => Promise.resolve()
|
|
8
|
-
};
|
|
9
|
-
var createMCPServer = (config) => {
|
|
10
|
-
const stages = buildMCPPipeline();
|
|
11
|
-
const makeHandlerForPort = (port) => {
|
|
12
|
-
const buildContext = (raw, rawRes, req, res) => ({
|
|
13
|
-
raw,
|
|
14
|
-
rawRes,
|
|
15
|
-
req,
|
|
16
|
-
res,
|
|
17
|
-
config,
|
|
18
|
-
port
|
|
19
|
-
});
|
|
20
|
-
return makeHandler("MCP", buildContext, stages);
|
|
21
|
-
};
|
|
22
|
-
return createHttpServer(config, makeHandlerForPort, {
|
|
23
|
-
label: "MCP",
|
|
24
|
-
cache: null,
|
|
25
|
-
plugins: noPlugins
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
//#endregion
|
|
29
|
-
export { createMCPServer };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { requestProxy } from "../../modules/mcp/proxy/config.js";
|
|
2
|
-
import { handleMcp } from "../../modules/mcp/handler.js";
|
|
3
|
-
import { createHttpPreviewClient } from "../../modules/mcp/previewClient.js";
|
|
4
|
-
import { createHttpScreenshotClient } from "../../modules/mcp/screenshotClient.js";
|
|
5
|
-
//#region src/core/services/mcp.ts
|
|
6
|
-
var mcpPathOf = (config) => config.mcpAi?.path ?? config.mcp?.path ?? "/mcp";
|
|
7
|
-
var serveMcp = async (ctx) => {
|
|
8
|
-
const { previewClient, screenshot, adapters, logger } = ctx.config;
|
|
9
|
-
ctx.operation = await handleMcp(ctx.raw, ctx.rawRes, ctx.req, adapters, {
|
|
10
|
-
preview: previewClient ? createHttpPreviewClient(previewClient) : void 0,
|
|
11
|
-
screenshot: screenshot ? createHttpScreenshotClient(screenshot) : void 0,
|
|
12
|
-
logger,
|
|
13
|
-
renderStreaming: ctx.config.mcpAi?.renderStreaming,
|
|
14
|
-
proxy: requestProxy(ctx.config, ctx.req)
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
var mcpStage = async (ctx) => {
|
|
18
|
-
if (!ctx.req.path.startsWith(mcpPathOf(ctx.config))) return false;
|
|
19
|
-
await serveMcp(ctx);
|
|
20
|
-
return true;
|
|
21
|
-
};
|
|
22
|
-
var mcpOnlyStage = async (ctx) => {
|
|
23
|
-
await serveMcp(ctx);
|
|
24
|
-
return true;
|
|
25
|
-
};
|
|
26
|
-
//#endregion
|
|
27
|
-
export { mcpOnlyStage, mcpStage };
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { readRawBody } from "../requestParser.js";
|
|
2
|
-
import { authorizationServerMetadata, protectedResourceMetadata } from "../../modules/oauth/metadata.js";
|
|
3
|
-
import { getAccess } from "../../modules/oauth/records.js";
|
|
4
|
-
import { sendErrorJson, sendJson } from "../../modules/oauth/respond.js";
|
|
5
|
-
import { handleAuthorizeStart, handleAuthorizeSubmit } from "../../modules/oauth/authorize.js";
|
|
6
|
-
import { bearerOf, sendChallenge } from "../../modules/oauth/challenge.js";
|
|
7
|
-
import { handleRegister } from "../../modules/oauth/register.js";
|
|
8
|
-
import { handleToken } from "../../modules/oauth/token.js";
|
|
9
|
-
//#region src/core/services/oauth.ts
|
|
10
|
-
var matchesWellKnown = (path, wellKnown) => path === wellKnown || path.startsWith(`${wellKnown}/`);
|
|
11
|
-
var isOAuthPath = (path) => matchesWellKnown(path, "/.well-known/oauth-protected-resource") || matchesWellKnown(path, "/.well-known/oauth-authorization-server") || path === "/register" || path === "/authorize" || path === "/token";
|
|
12
|
-
var formParams = (req, body) => {
|
|
13
|
-
const params = { ...req.query };
|
|
14
|
-
for (const [key, value] of new URLSearchParams(body).entries()) params[key] = value;
|
|
15
|
-
return params;
|
|
16
|
-
};
|
|
17
|
-
var parseJson = (body) => {
|
|
18
|
-
try {
|
|
19
|
-
return JSON.parse(body);
|
|
20
|
-
} catch {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
/** OAuth 2.1 authorization for the MCP server, mounted ONLY when a deployment configures `oauth`. Without it the
|
|
25
|
-
* stage falls straight through and the server keeps its anonymous contract: discovery 404s, the public surface
|
|
26
|
-
* (handshake, listings, the guide, plitzi_render) answers without a token, and nothing below changes.
|
|
27
|
-
*
|
|
28
|
-
* It sits before the MCP stage because that one answers every path on a dedicated MCP server — these endpoints
|
|
29
|
-
* would otherwise be swallowed by the JSON-RPC transport, which is exactly the 406 a host hits on /register. */
|
|
30
|
-
var oauthStage = async (ctx) => {
|
|
31
|
-
const { oauth } = ctx.config;
|
|
32
|
-
const { path, method } = ctx.req;
|
|
33
|
-
if (!oauth || !isOAuthPath(path)) return false;
|
|
34
|
-
const { res } = ctx;
|
|
35
|
-
if (path !== "/authorize") {
|
|
36
|
-
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
37
|
-
res.setHeader("Access-Control-Allow-Headers", "*");
|
|
38
|
-
res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
|
|
39
|
-
}
|
|
40
|
-
if (method === "OPTIONS") {
|
|
41
|
-
res.setStatus(204);
|
|
42
|
-
res.end();
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
if (method === "GET" && matchesWellKnown(path, "/.well-known/oauth-protected-resource")) {
|
|
46
|
-
sendJson(res, 200, protectedResourceMetadata(oauth, ctx.req));
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
if (method === "GET" && matchesWellKnown(path, "/.well-known/oauth-authorization-server")) {
|
|
50
|
-
sendJson(res, 200, authorizationServerMetadata(oauth, ctx.req));
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
if (path === "/authorize" && method === "GET") {
|
|
54
|
-
await handleAuthorizeStart(oauth, res, ctx.req.query);
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
if (path === "/authorize" && method === "POST") {
|
|
58
|
-
await handleAuthorizeSubmit(oauth, res, formParams(ctx.req, await readRawBody(ctx.raw)));
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
if (path === "/token" && method === "POST") {
|
|
62
|
-
await handleToken(oauth, res, formParams(ctx.req, await readRawBody(ctx.raw)));
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
if (path === "/register" && method === "POST") {
|
|
66
|
-
await handleRegister(oauth, res, parseJson(await readRawBody(ctx.raw)));
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
sendErrorJson(res, 405, "invalid_request", `${method} is not allowed on ${path}.`);
|
|
70
|
-
return true;
|
|
71
|
-
};
|
|
72
|
-
var CHALLENGE_DESCRIPTIONS = {
|
|
73
|
-
"no-credential": "Authorization is required to use this server.",
|
|
74
|
-
"unknown-credential": "The access token is invalid, expired or revoked.",
|
|
75
|
-
"store-unreachable": "The access token could not be verified right now.",
|
|
76
|
-
"adapter-failed": "The access token could not be verified right now."
|
|
77
|
-
};
|
|
78
|
-
var challengeReason = async (oauth, ctx, token) => {
|
|
79
|
-
if (!token) return "no-credential";
|
|
80
|
-
try {
|
|
81
|
-
const record = await getAccess(oauth.adapters.store, token);
|
|
82
|
-
if (record) {
|
|
83
|
-
const credential = record.credential ?? token;
|
|
84
|
-
ctx.req.headers["x-access-token"] = credential;
|
|
85
|
-
ctx.req.headers.authorization = `Bearer ${credential}`;
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
} catch {
|
|
89
|
-
return "store-unreachable";
|
|
90
|
-
}
|
|
91
|
-
try {
|
|
92
|
-
return await ctx.config.adapters.getSpaceId?.(ctx.req) === void 0 ? "unknown-credential" : void 0;
|
|
93
|
-
} catch {
|
|
94
|
-
return "adapter-failed";
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
/** The protected-resource half of OAuth: an MCP call that presents no bearer this server can verify is refused
|
|
98
|
-
* with RFC 6750's challenge instead of being served the anonymous surface. That 401 is the whole handshake — it
|
|
99
|
-
* is how a host learns the server needs authorization, where its metadata lives and which scopes to ask for, and
|
|
100
|
-
* a 200 tells it none of that. Only the JSON-RPC POST is guarded: the CORS preflight, the GET 405 and the
|
|
101
|
-
* discovery probes carry no credential and must keep answering as they do.
|
|
102
|
-
*
|
|
103
|
-
* Mounted only when `oauth` is configured. A deployment that configures none keeps the open server it had, where
|
|
104
|
-
* the whole public surface — handshake, listings, the guide, plitzi_render — answers without a token; with OAuth
|
|
105
|
-
* on, the grant that carries no space is what covers that same ground. */
|
|
106
|
-
var oauthGuardStage = async (ctx) => {
|
|
107
|
-
const { oauth } = ctx.config;
|
|
108
|
-
if (!oauth || ctx.req.method !== "POST") return false;
|
|
109
|
-
const reason = await challengeReason(oauth, ctx, bearerOf(ctx.req));
|
|
110
|
-
if (!reason) return false;
|
|
111
|
-
ctx.operation = `oauth-challenge:${reason}`;
|
|
112
|
-
sendChallenge(oauth, ctx.req, ctx.res, CHALLENGE_DESCRIPTIONS[reason]);
|
|
113
|
-
return true;
|
|
114
|
-
};
|
|
115
|
-
//#endregion
|
|
116
|
-
export { oauthGuardStage, oauthStage };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { readRawBody } from "../requestParser.js";
|
|
2
|
-
import { createPreview } from "../../modules/ssr/preview.js";
|
|
3
|
-
//#region src/core/services/preview.ts
|
|
4
|
-
var PREVIEW_PATH_DEFAULT = "/__preview";
|
|
5
|
-
var json = (ctx, status, payload) => {
|
|
6
|
-
ctx.res.setHeader("Content-Type", "application/json");
|
|
7
|
-
ctx.res.setStatus(status);
|
|
8
|
-
ctx.res.send(JSON.stringify(payload));
|
|
9
|
-
return true;
|
|
10
|
-
};
|
|
11
|
-
var previewStage = async (ctx) => {
|
|
12
|
-
const preview = ctx.config.preview;
|
|
13
|
-
const path = preview?.path ?? PREVIEW_PATH_DEFAULT;
|
|
14
|
-
if (!preview?.enabled || ctx.req.method !== "POST" || ctx.req.path !== path) return false;
|
|
15
|
-
if (preview.secret && ctx.req.headers["x-preview-secret"] !== preview.secret) return json(ctx, 403, {
|
|
16
|
-
error: "FORBIDDEN",
|
|
17
|
-
message: "Invalid or missing preview secret."
|
|
18
|
-
});
|
|
19
|
-
ctx.req.body = await readRawBody(ctx.raw);
|
|
20
|
-
let body;
|
|
21
|
-
try {
|
|
22
|
-
body = JSON.parse(ctx.req.body || "{}");
|
|
23
|
-
} catch {
|
|
24
|
-
return json(ctx, 400, {
|
|
25
|
-
error: "BAD_REQUEST",
|
|
26
|
-
message: "Request body must be JSON."
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
if (typeof body.spaceId !== "number") return json(ctx, 400, {
|
|
30
|
-
error: "BAD_REQUEST",
|
|
31
|
-
message: "spaceId (number) is required."
|
|
32
|
-
});
|
|
33
|
-
const result = await createPreview(body, ctx.config, ctx.renderFn, ctx.pluginManager, ctx.caches);
|
|
34
|
-
return json(ctx, result.ok ? 200 : 422, result);
|
|
35
|
-
};
|
|
36
|
-
//#endregion
|
|
37
|
-
export { previewStage };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { proxySettings } from "../../modules/mcp/proxy/config.js";
|
|
2
|
-
import { handleProxyRequest } from "../../modules/mcp/proxy/handler.js";
|
|
3
|
-
//#region src/core/services/proxy.ts
|
|
4
|
-
var widgetProxyStage = async (ctx) => {
|
|
5
|
-
const settings = proxySettings(ctx.config);
|
|
6
|
-
if (!settings || ctx.req.path !== settings.path) return false;
|
|
7
|
-
ctx.operation = "proxy";
|
|
8
|
-
await handleProxyRequest(ctx.req, ctx.res, settings);
|
|
9
|
-
return true;
|
|
10
|
-
};
|
|
11
|
-
//#endregion
|
|
12
|
-
export { widgetProxyStage };
|
package/dist/mcp.d.ts
DELETED
package/dist/mcp.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { consoleLogger, renderLogEvent } from "./helpers/serverLog.js";
|
|
2
|
-
import { createMcpServer } from "./modules/mcp/server.js";
|
|
3
|
-
import { handleMcp, readMcpBody, serveMcp } from "./modules/mcp/handler.js";
|
|
4
|
-
import { createHttpPreviewClient } from "./modules/mcp/previewClient.js";
|
|
5
|
-
import { createHttpScreenshotClient } from "./modules/mcp/screenshotClient.js";
|
|
6
|
-
import { createMCPServer } from "./core/server/mcpServer.js";
|
|
7
|
-
export { consoleLogger, createHttpPreviewClient, createHttpScreenshotClient, createMCPServer, createMcpServer, handleMcp, readMcpBody, renderLogEvent, serveMcp };
|