@plitzi/sdk-server 0.32.4 → 0.32.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/adapters/jsonAdapters.js +6 -1
- package/dist/core/createServer.js +8 -44
- package/dist/core/health.js +15 -0
- package/dist/core/http/dispatcher.js +29 -0
- package/dist/core/http/securityHeaders.js +15 -0
- package/dist/core/http/stages/authRoutes.js +41 -0
- package/dist/core/http/stages/health.js +12 -0
- package/dist/core/http/stages/middlewares.js +16 -0
- package/dist/core/http/stages/pluginAssets.js +20 -0
- package/dist/core/http/stages/static.js +30 -0
- package/dist/core/server/baseServer.js +29 -0
- package/dist/core/server/mcpServer.js +29 -0
- package/dist/core/server/ssrServer.js +54 -0
- package/dist/core/services/mcp.js +22 -0
- package/dist/core/services/preview.js +37 -0
- package/dist/core/services/registry.js +30 -0
- package/dist/core/services/resolve.js +12 -0
- package/dist/core/services/rsc.js +11 -0
- package/dist/core/services/ssr.js +13 -0
- package/dist/core/transports.js +9 -9
- package/dist/helpers/buildServerInfo.js +3 -9
- package/dist/index.js +20 -6
- package/dist/modules/ai/AIEngine.js +4 -4
- package/dist/modules/ai/toolkit.js +58 -0
- package/dist/modules/mcp/catalogs/builtinCallbacks.js +204 -0
- package/dist/modules/mcp/catalogs/builtinComponents.js +170 -0
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +50 -0
- package/dist/modules/mcp/catalogs/builtinTransformers.js +148 -0
- package/dist/modules/mcp/catalogs/builtinUtilities.js +90 -0
- package/dist/modules/mcp/catalogs/cssCatalog.js +205 -0
- package/dist/modules/mcp/catalogs/observed.js +90 -0
- package/dist/modules/mcp/catalogs/paramSpec.js +69 -0
- package/dist/modules/mcp/catalogs/registry.js +89 -0
- package/dist/modules/mcp/constants.js +4 -0
- package/dist/modules/mcp/handler.js +24 -20
- package/dist/modules/mcp/helpers/agentPrompt.js +104 -0
- package/dist/modules/mcp/helpers/computeVersion.js +16 -0
- package/dist/modules/mcp/helpers/guide.js +449 -0
- package/dist/modules/mcp/helpers/interactions.js +123 -0
- package/dist/modules/mcp/helpers/log.js +54 -0
- package/dist/modules/mcp/helpers/opResult.js +18 -0
- package/dist/modules/mcp/helpers/space.js +262 -0
- package/dist/modules/mcp/helpers/uris.js +44 -0
- package/dist/modules/mcp/previewClient.js +31 -0
- package/dist/modules/mcp/resources/canonical.js +30 -0
- package/dist/modules/mcp/resources/core.js +15 -0
- package/dist/modules/mcp/resources/envelope.js +14 -0
- package/dist/modules/mcp/resources/primer.js +30 -0
- package/dist/modules/mcp/resources/register.js +174 -0
- package/dist/modules/mcp/resources/router.js +25 -0
- package/dist/modules/mcp/resources/schema.js +43 -0
- package/dist/modules/mcp/resources/style.js +34 -0
- package/dist/modules/mcp/screenshotClient.js +47 -0
- package/dist/modules/mcp/server.js +66 -20
- package/dist/modules/mcp/tools/apply/dispatch.js +103 -0
- package/dist/modules/mcp/tools/apply/index.js +136 -0
- package/dist/modules/mcp/tools/apply/writeResult.js +37 -0
- package/dist/modules/mcp/tools/index.js +20 -148
- package/dist/modules/mcp/tools/operations/index.js +41 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +32 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +36 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +47 -0
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +29 -0
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +41 -0
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +58 -0
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +65 -0
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +30 -0
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +49 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +52 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +47 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +43 -0
- package/dist/modules/mcp/tools/operations/schema/operations.js +39 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +25 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +75 -0
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +45 -0
- package/dist/modules/mcp/tools/operations/schema/shared.js +119 -0
- package/dist/modules/mcp/tools/operations/schema/translator.js +215 -0
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +18 -0
- package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +42 -0
- package/dist/modules/mcp/tools/operations/schema/write.js +109 -0
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +21 -0
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +28 -0
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +24 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +21 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +28 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +24 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +21 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +28 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +24 -0
- package/dist/modules/mcp/tools/operations/style/operations.js +27 -0
- package/dist/modules/mcp/tools/operations/style/shared.js +59 -0
- package/dist/modules/mcp/tools/operations/style/translator.js +101 -0
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +21 -0
- package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +22 -0
- package/dist/modules/mcp/tools/operations/style/write.js +108 -0
- package/dist/modules/mcp/tools/preview.js +37 -0
- package/dist/modules/mcp/tools/read.js +33 -0
- package/dist/modules/mcp/tools/screenshot.js +83 -0
- package/dist/modules/mcp/tools/search.js +115 -0
- package/dist/modules/mcp/tools/shared/tool.js +26 -0
- package/dist/modules/mcp/tools/shared/validator/audit.js +124 -0
- package/dist/modules/mcp/tools/shared/validator/batch.js +30 -0
- package/dist/modules/mcp/tools/shared/validator/bindings.js +70 -0
- package/dist/modules/mcp/tools/shared/validator/context.js +35 -0
- package/dist/modules/mcp/tools/shared/validator/css.js +47 -0
- package/dist/modules/mcp/tools/shared/validator/elements.js +55 -0
- package/dist/modules/mcp/tools/shared/validator/index.js +226 -0
- package/dist/modules/mcp/tools/shared/validator/interactions.js +106 -0
- package/dist/modules/mcp/tools/shared/validator/refs.js +28 -0
- package/dist/modules/mcp/tools/validate.js +39 -0
- package/dist/modules/ssr/buildBody.js +2 -2
- package/dist/modules/ssr/handler.js +6 -4
- package/dist/modules/ssr/prepareRender.js +5 -5
- package/dist/modules/ssr/preview.js +106 -0
- package/dist/modules/ssr/registerExternalPlugins.js +1 -1
- package/dist/modules/ssr/streamBody.js +3 -3
- package/dist/modules/ssr/template.js +1 -1
- package/dist/modules/ssr/views/template.ejs +2 -0
- package/dist/plugins/compile.js +1 -1
- package/dist/plugins/copy.js +1 -1
- package/dist/plugins/manager.js +1 -1
- package/dist/server.js +34 -9
- package/dist/src/core/createServer.d.ts +5 -1
- package/dist/src/core/health.d.ts +10 -0
- package/dist/src/core/http/dispatcher.d.ts +7 -0
- package/dist/src/core/http/securityHeaders.d.ts +2 -0
- package/dist/src/core/http/stages/authRoutes.d.ts +4 -0
- package/dist/src/core/http/stages/health.d.ts +2 -0
- package/dist/src/core/http/stages/middlewares.d.ts +2 -0
- package/dist/src/core/http/stages/pluginAssets.d.ts +2 -0
- package/dist/src/core/http/stages/static.d.ts +5 -0
- package/dist/src/core/http/types.d.ts +19 -0
- package/dist/src/core/server/baseServer.d.ts +9 -0
- package/dist/src/core/server/mcpServer.d.ts +2 -0
- package/dist/src/core/server/ssrServer.d.ts +2 -0
- package/dist/src/core/services/mcp.d.ts +3 -0
- package/dist/src/core/services/preview.d.ts +2 -0
- package/dist/src/core/services/registry.d.ts +4 -0
- package/dist/src/core/services/resolve.d.ts +3 -0
- package/dist/src/core/services/rsc.d.ts +2 -0
- package/dist/src/core/services/ssr.d.ts +3 -0
- package/dist/src/core/transports.d.ts +2 -2
- package/dist/src/index.d.ts +12 -3
- package/dist/src/modules/ai/index.d.ts +1 -0
- package/dist/src/modules/ai/toolkit.d.ts +17 -0
- package/dist/src/modules/mcp/catalogs/builtinCallbacks.d.ts +23 -0
- package/dist/src/modules/mcp/catalogs/builtinComponents.d.ts +4 -0
- package/dist/src/modules/mcp/catalogs/builtinElementCallbacks.d.ts +20 -0
- package/dist/src/modules/mcp/catalogs/builtinTransformers.d.ts +28 -0
- package/dist/src/modules/mcp/catalogs/builtinUtilities.d.ts +18 -0
- package/dist/src/modules/mcp/catalogs/cssCatalog.d.ts +14 -0
- package/dist/src/modules/mcp/catalogs/index.d.ts +9 -0
- package/dist/src/modules/mcp/catalogs/observed.d.ts +48 -0
- package/dist/src/modules/mcp/catalogs/paramSpec.d.ts +42 -0
- package/dist/src/modules/mcp/catalogs/registry.d.ts +35 -0
- package/dist/src/modules/mcp/constants.d.ts +1 -0
- package/dist/src/modules/mcp/handler.d.ts +6 -3
- package/dist/src/modules/mcp/helpers/agentPrompt.d.ts +4 -0
- package/dist/src/modules/mcp/helpers/computeVersion.d.ts +1 -0
- package/dist/src/modules/mcp/helpers/guide.d.ts +3 -0
- package/dist/src/modules/mcp/helpers/index.d.ts +8 -0
- package/dist/src/modules/mcp/helpers/interactions.d.ts +30 -0
- package/dist/src/modules/mcp/helpers/log.d.ts +8 -0
- package/dist/src/modules/mcp/helpers/opResult.d.ts +13 -0
- package/dist/src/modules/mcp/helpers/space.d.ts +105 -0
- package/dist/src/modules/mcp/helpers/uris.d.ts +28 -0
- package/dist/src/modules/mcp/index.d.ts +12 -5
- package/dist/src/modules/mcp/previewClient.d.ts +13 -0
- package/dist/src/modules/mcp/resources/canonical.d.ts +6 -0
- package/dist/src/modules/mcp/resources/core.d.ts +5 -0
- package/dist/src/modules/mcp/resources/envelope.d.ts +10 -0
- package/dist/src/modules/mcp/resources/index.d.ts +7 -10
- package/dist/src/modules/mcp/resources/primer.d.ts +7 -0
- package/dist/src/modules/mcp/resources/register.d.ts +6 -0
- package/dist/src/modules/mcp/resources/router.d.ts +6 -0
- package/dist/src/modules/mcp/resources/schema.d.ts +5 -0
- package/dist/src/modules/mcp/resources/style.d.ts +5 -0
- package/dist/src/modules/mcp/screenshotClient.d.ts +13 -0
- package/dist/src/modules/mcp/server.d.ts +21 -3
- package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +6 -0
- package/dist/src/modules/mcp/tools/apply/index.d.ts +420 -0
- package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +8 -0
- package/dist/src/modules/mcp/tools/index.d.ts +17 -6
- package/dist/src/modules/mcp/tools/operations/index.d.ts +828 -0
- package/dist/src/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +17 -0
- package/dist/src/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +25 -0
- package/dist/src/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +27 -0
- package/dist/src/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +10 -0
- package/dist/src/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +22 -0
- package/dist/src/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +20 -0
- package/dist/src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +18 -0
- package/dist/src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +27 -0
- package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +210 -0
- package/dist/src/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +14 -0
- package/dist/src/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +34 -0
- package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +77 -0
- package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +42 -0
- package/dist/src/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/index.d.ts +14 -0
- package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +231 -0
- package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +115 -0
- package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +15 -0
- package/dist/src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +20 -0
- package/dist/src/modules/mcp/tools/operations/style/write.d.ts +12 -0
- package/dist/src/modules/mcp/tools/preview.d.ts +415 -0
- package/dist/src/modules/mcp/tools/read.d.ts +8 -0
- package/dist/src/modules/mcp/tools/screenshot.d.ts +420 -0
- package/dist/src/modules/mcp/tools/search.d.ts +15 -0
- package/dist/src/modules/mcp/tools/shared/tool.d.ts +50 -0
- package/dist/src/modules/mcp/tools/shared/validator/audit.d.ts +4 -0
- package/dist/src/modules/mcp/tools/shared/validator/batch.d.ts +5 -0
- package/dist/src/modules/mcp/tools/shared/validator/bindings.d.ts +6 -0
- package/dist/src/modules/mcp/tools/shared/validator/context.d.ts +34 -0
- package/dist/src/modules/mcp/tools/shared/validator/css.d.ts +4 -0
- package/dist/src/modules/mcp/tools/shared/validator/elements.d.ts +6 -0
- package/dist/src/modules/mcp/tools/shared/validator/index.d.ts +8 -0
- package/dist/src/modules/mcp/tools/shared/validator/interactions.d.ts +3 -0
- package/dist/src/modules/mcp/tools/shared/validator/refs.d.ts +4 -0
- package/dist/src/modules/mcp/tools/validate.d.ts +417 -0
- package/dist/src/modules/mcp/types/aiSchema.d.ts +218 -0
- package/dist/src/modules/mcp/types/index.d.ts +4 -0
- package/dist/src/modules/mcp/types/previewTypes.d.ts +25 -0
- package/dist/src/modules/mcp/types/screenshotTypes.d.ts +29 -0
- package/dist/src/modules/mcp/types/toolTypes.d.ts +138 -0
- package/dist/src/modules/ssr/buildBody.d.ts +2 -2
- package/dist/src/modules/ssr/prepareRender.d.ts +2 -2
- package/dist/src/modules/ssr/preview.d.ts +16 -0
- package/dist/src/modules/ssr/streamBody.d.ts +2 -2
- package/package.json +16 -14
- package/dist/_virtual/_rolldown/runtime.js +0 -13
- package/dist/core/requestHandler.js +0 -126
- package/dist/modules/mcp/helpers.js +0 -75
- package/dist/modules/mcp/resources/glossary/binding.js +0 -73
- package/dist/modules/mcp/resources/glossary/collection.js +0 -76
- package/dist/modules/mcp/resources/glossary/displayMode.js +0 -50
- package/dist/modules/mcp/resources/glossary/element.js +0 -68
- package/dist/modules/mcp/resources/glossary/environment.js +0 -48
- package/dist/modules/mcp/resources/glossary/interaction.js +0 -62
- package/dist/modules/mcp/resources/glossary/page.js +0 -70
- package/dist/modules/mcp/resources/glossary/plugin.js +0 -96
- package/dist/modules/mcp/resources/glossary/resource.js +0 -75
- package/dist/modules/mcp/resources/glossary/schema.js +0 -69
- package/dist/modules/mcp/resources/glossary/schemaVariable.js +0 -60
- package/dist/modules/mcp/resources/glossary/segment.js +0 -59
- package/dist/modules/mcp/resources/glossary/space.js +0 -73
- package/dist/modules/mcp/resources/glossary/style.js +0 -81
- package/dist/modules/mcp/resources/glossary/styleSelector.js +0 -77
- package/dist/modules/mcp/resources/glossary/styleVariable.js +0 -72
- package/dist/modules/mcp/resources/index.js +0 -71
- package/dist/modules/mcp/resources/workflows/data.js +0 -49
- package/dist/modules/mcp/resources/workflows/elements.js +0 -53
- package/dist/modules/mcp/resources/workflows/segments.js +0 -55
- package/dist/modules/mcp/resources/workflows/styles.js +0 -91
- package/dist/modules/mcp/tools/collections/createCollection.js +0 -25
- package/dist/modules/mcp/tools/collections/createCollectionRecord.js +0 -27
- package/dist/modules/mcp/tools/collections/deleteCollection.js +0 -16
- package/dist/modules/mcp/tools/collections/deleteCollectionRecord.js +0 -16
- package/dist/modules/mcp/tools/collections/getCollection.js +0 -21
- package/dist/modules/mcp/tools/collections/getCollectionRecord.js +0 -25
- package/dist/modules/mcp/tools/collections/getCollectionRecords.js +0 -29
- package/dist/modules/mcp/tools/collections/getCollections.js +0 -19
- package/dist/modules/mcp/tools/collections/updateCollection.js +0 -28
- package/dist/modules/mcp/tools/collections/updateCollectionRecord.js +0 -31
- package/dist/modules/mcp/tools/docs/listResources.js +0 -16
- package/dist/modules/mcp/tools/docs/readResource.js +0 -23
- package/dist/modules/mcp/tools/plugins/addPlugin.js +0 -24
- package/dist/modules/mcp/tools/plugins/listPlugins.js +0 -20
- package/dist/modules/mcp/tools/plugins/removePlugin.js +0 -16
- package/dist/modules/mcp/tools/plugins/updatePlugin.js +0 -23
- package/dist/modules/mcp/tools/resources/addResource.js +0 -33
- package/dist/modules/mcp/tools/resources/getResource.js +0 -29
- package/dist/modules/mcp/tools/resources/getResources.js +0 -27
- package/dist/modules/mcp/tools/resources/moveResource.js +0 -30
- package/dist/modules/mcp/tools/resources/removeResource.js +0 -19
- package/dist/modules/mcp/tools/segment/createSegment.js +0 -27
- package/dist/modules/mcp/tools/segment/deleteSegment.js +0 -16
- package/dist/modules/mcp/tools/segment/getSegment.js +0 -19
- package/dist/modules/mcp/tools/segment/getSegments.js +0 -27
- package/dist/modules/mcp/tools/segment/schema/elements/createSegmentElement.js +0 -24
- package/dist/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.js +0 -19
- package/dist/modules/mcp/tools/segment/schema/elements/moveSegmentElement.js +0 -28
- package/dist/modules/mcp/tools/segment/schema/elements/updateSegmentElement.js +0 -23
- package/dist/modules/mcp/tools/segment/schema/variables/createSegmentVariable.js +0 -41
- package/dist/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.js +0 -19
- package/dist/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.js +0 -41
- package/dist/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.js +0 -34
- package/dist/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.js +0 -21
- package/dist/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.js +0 -34
- package/dist/modules/mcp/tools/segment/updateSegment.js +0 -30
- package/dist/modules/mcp/tools/space/schema/applyPreview.js +0 -33
- package/dist/modules/mcp/tools/space/schema/elements/cloneElement.js +0 -34
- package/dist/modules/mcp/tools/space/schema/elements/createElement.js +0 -50
- package/dist/modules/mcp/tools/space/schema/elements/deleteElement.js +0 -16
- package/dist/modules/mcp/tools/space/schema/elements/getElement.js +0 -17
- package/dist/modules/mcp/tools/space/schema/elements/getElements.js +0 -21
- package/dist/modules/mcp/tools/space/schema/elements/listElements.js +0 -28
- package/dist/modules/mcp/tools/space/schema/elements/moveElement.js +0 -27
- package/dist/modules/mcp/tools/space/schema/elements/updateElement.js +0 -49
- package/dist/modules/mcp/tools/space/schema/getSpaceSettings.js +0 -46
- package/dist/modules/mcp/tools/space/schema/pageFolders/createPageFolder.js +0 -24
- package/dist/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.js +0 -16
- package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolder.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolders.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.js +0 -28
- package/dist/modules/mcp/tools/space/schema/pages/createPage.js +0 -37
- package/dist/modules/mcp/tools/space/schema/pages/deletePage.js +0 -16
- package/dist/modules/mcp/tools/space/schema/pages/getPage.js +0 -28
- package/dist/modules/mcp/tools/space/schema/pages/getPageBySlug.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pages/getPages.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pages/updatePage.js +0 -25
- package/dist/modules/mcp/tools/space/schema/schemas.js +0 -53
- package/dist/modules/mcp/tools/space/schema/updateSpaceSettings.js +0 -23
- package/dist/modules/mcp/tools/space/schema/variables/createVariable.js +0 -38
- package/dist/modules/mcp/tools/space/schema/variables/deleteVariable.js +0 -16
- package/dist/modules/mcp/tools/space/schema/variables/getVariable.js +0 -17
- package/dist/modules/mcp/tools/space/schema/variables/getVariables.js +0 -17
- package/dist/modules/mcp/tools/space/schema/variables/updateVariable.js +0 -38
- package/dist/modules/mcp/tools/space/style/selectors/createStyleSelector.js +0 -37
- package/dist/modules/mcp/tools/space/style/selectors/deleteStyleSelector.js +0 -24
- package/dist/modules/mcp/tools/space/style/selectors/getStyleSelectors.js +0 -20
- package/dist/modules/mcp/tools/space/style/selectors/updateStyleSelector.js +0 -37
- package/dist/modules/mcp/tools/space/style/variables/createStyleVariable.js +0 -33
- package/dist/modules/mcp/tools/space/style/variables/deleteStyleVariable.js +0 -20
- package/dist/modules/mcp/tools/space/style/variables/getStyleVariable.js +0 -19
- package/dist/modules/mcp/tools/space/style/variables/getStyleVariables.js +0 -16
- package/dist/modules/mcp/tools/space/style/variables/updateStyleVariable.js +0 -33
- package/dist/package.js +0 -77
- package/dist/package.json.d.ts +0 -67
- package/dist/src/core/requestHandler.d.ts +0 -5
- package/dist/src/modules/mcp/helpers.d.ts +0 -9
- package/dist/src/modules/mcp/resources/glossary/binding.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/collection.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/displayMode.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/element.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/environment.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/interaction.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/page.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/plugin.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/resource.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/schema.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/schemaVariable.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/segment.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/space.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/style.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/styleSelector.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/styleVariable.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/data.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/elements.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/segments.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/styles.d.ts +0 -7
- package/dist/src/modules/mcp/tools/collections/createCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/createCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/deleteCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/deleteCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollectionRecords.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollections.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/index.d.ts +0 -10
- package/dist/src/modules/mcp/tools/collections/updateCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/updateCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/docs/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/docs/listResources.d.ts +0 -3
- package/dist/src/modules/mcp/tools/docs/readResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/addPlugin.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/index.d.ts +0 -5
- package/dist/src/modules/mcp/tools/plugins/listPlugins.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/removePlugin.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/updatePlugin.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/addResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/getResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/getResources.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/resources/moveResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/removeResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/createSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/deleteSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/getSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/getSegments.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/index.d.ts +0 -8
- package/dist/src/modules/mcp/tools/segment/schema/elements/createSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/elements/index.d.ts +0 -5
- package/dist/src/modules/mcp/tools/segment/schema/elements/moveSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/elements/updateSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/segment/schema/variables/createSegmentVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/variables/index.d.ts +0 -4
- package/dist/src/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/segment.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/style/index.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/style/variables/index.d.ts +0 -4
- package/dist/src/modules/mcp/tools/segment/style/variables/segmentStyleVariables.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/updateSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/space/schema/applyPreview.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/cloneElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/createElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/deleteElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/elements.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/schema/elements/getElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/getElements.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/index.d.ts +0 -9
- package/dist/src/modules/mcp/tools/space/schema/elements/listElements.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/moveElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/updateElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/getSpaceSettings.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/index.d.ts +0 -8
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/createPageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolders.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/pageFolders.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/createPage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/deletePage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/getPage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/getPageBySlug.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/getPages.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/index.d.ts +0 -7
- package/dist/src/modules/mcp/tools/space/schema/pages/pages.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/schema/pages/updatePage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/schemas.d.ts +0 -66
- package/dist/src/modules/mcp/tools/space/schema/updateSpaceSettings.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/createVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/deleteVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/getVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/getVariables.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/space/schema/variables/updateVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/variables.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/space.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/style/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/space/style/selectors/createStyleSelector.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/selectors/deleteStyleSelector.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/selectors/getStyleSelectors.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/selectors/index.d.ts +0 -5
- package/dist/src/modules/mcp/tools/space/style/selectors/styleSelectors.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/style/selectors/updateStyleSelector.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/createStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/deleteStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariables.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/space/style/variables/styleVariables.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/style/variables/updateStyleVariable.d.ts +0 -3
- /package/dist/src/{modules/mcp/helpers.test.d.ts → core/server/mcpServer.test.d.ts} +0 -0
- /package/dist/src/modules/{mcp/tools/collections/collections.test.d.ts → ai/toolkit.test.d.ts} +0 -0
- /package/dist/src/modules/mcp/{tools/plugins/plugins.test.d.ts → catalogs/builtinTransformers.test.d.ts} +0 -0
- /package/dist/src/modules/mcp/{tools/resources/resources.test.d.ts → helpers/log.test.d.ts} +0 -0
- /package/dist/src/modules/mcp/{tools/segment/schema/elements/segmentElements.test.d.ts → mcp.bench.d.ts} +0 -0
- /package/dist/src/modules/mcp/{tools/segment/schema/variables/segmentVariables.test.d.ts → mcp.test.d.ts} +0 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { Environment } from '@plitzi/sdk-shared';
|
|
2
|
+
export type Env = Environment;
|
|
3
|
+
/** CSS declarations for one selector state. Keys are kebab-case CSS properties (see plitzi://css-properties). */
|
|
4
|
+
export type CssProps = Record<string, string | number>;
|
|
5
|
+
export interface DisplayModeCss {
|
|
6
|
+
desktop?: CssProps;
|
|
7
|
+
tablet?: CssProps;
|
|
8
|
+
mobile?: CssProps;
|
|
9
|
+
}
|
|
10
|
+
export interface ResourceEnvelope<T> {
|
|
11
|
+
stateVersion: string;
|
|
12
|
+
data: T;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Read projections follow a filesystem model: list cheap summaries/skeletons, then read one element's detail
|
|
16
|
+
* on demand. Heavy per-element data (props, style) lives only in AIElementDetail, never in the listings.
|
|
17
|
+
*/
|
|
18
|
+
export interface AIPageSummary {
|
|
19
|
+
ref: string;
|
|
20
|
+
label: string;
|
|
21
|
+
slug: string;
|
|
22
|
+
default: boolean;
|
|
23
|
+
/** Whether the page is served by the published SDK runtime. A disabled page (`false`) is not routable/accessible
|
|
24
|
+
* to end users, but stays fully editable here. Defaults to true. */
|
|
25
|
+
enabled: boolean;
|
|
26
|
+
/** The ref of the folder this page lives in (a PageFolder id), or undefined for a root-level page. */
|
|
27
|
+
folder?: string;
|
|
28
|
+
elementCount: number;
|
|
29
|
+
}
|
|
30
|
+
/** A page folder in the sidebar tree. `ref` is the folder's id (there is no separate idRef); pages reference it
|
|
31
|
+
* by that id via their `folder`, and nested folders via `parentId`. */
|
|
32
|
+
export interface AIFolder {
|
|
33
|
+
ref: string;
|
|
34
|
+
name: string;
|
|
35
|
+
slug: string;
|
|
36
|
+
parentId?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface AISkeletonNode {
|
|
39
|
+
ref: string;
|
|
40
|
+
type: string;
|
|
41
|
+
label: string;
|
|
42
|
+
subType?: string;
|
|
43
|
+
/** This element's version — identical to the stateVersion a direct element read or search hit returns for it. Diff
|
|
44
|
+
* it against a version you already hold to re-read (plitzi_read) only the nodes that actually changed. */
|
|
45
|
+
stateVersion?: string;
|
|
46
|
+
/** The class refs this node attaches on its base selector — names only, no CSS. Lets an agent map element →
|
|
47
|
+
* class straight from the page skeleton, without a per-element read just to learn which class it uses. */
|
|
48
|
+
base?: string[];
|
|
49
|
+
/** Class refs attached on non-base slots (slot → class refs), names only. */
|
|
50
|
+
slots?: Record<string, string[]>;
|
|
51
|
+
childCount: number;
|
|
52
|
+
children?: AISkeletonNode[];
|
|
53
|
+
}
|
|
54
|
+
export interface AIPageSkeleton {
|
|
55
|
+
ref: string;
|
|
56
|
+
label: string;
|
|
57
|
+
slug: string;
|
|
58
|
+
default: boolean;
|
|
59
|
+
/** Whether the page is served by the published SDK runtime. A disabled page (`false`) is not routable/accessible
|
|
60
|
+
* to end users, but stays fully editable here. Defaults to true. */
|
|
61
|
+
enabled: boolean;
|
|
62
|
+
/** Route params bound by the slug (e.g. ":spaceId" → ["spaceId"]). Valid as {{name}} references on this page,
|
|
63
|
+
* alongside the space-level plitzi://schema-variables. */
|
|
64
|
+
routeParams: string[];
|
|
65
|
+
tree: AISkeletonNode[];
|
|
66
|
+
}
|
|
67
|
+
/** Every style a page uses in one payload: the class definitions its elements attach (deduplicated, with CSS)
|
|
68
|
+
* and the global element selectors that affect any element type present on the page. Collapses "what styles
|
|
69
|
+
* does this page use" to a single read, with no reliance on a shared class-naming prefix. */
|
|
70
|
+
export interface AIPageStyles {
|
|
71
|
+
ref: string;
|
|
72
|
+
definitions: AIDefinition[];
|
|
73
|
+
globalStyles: AIGlobalStyle[];
|
|
74
|
+
}
|
|
75
|
+
/** Which variant each attached class/selector currently uses on this element (element.definition.initialState
|
|
76
|
+
* .styleVariant). Outer key = class ref, inner key = selector (`base` or a slot), value = variant name(s). */
|
|
77
|
+
export type AIStyleVariantSelection = Record<string, Record<string, string | string[]>>;
|
|
78
|
+
/** The element's initial (default) state overrides. `styleVariant` picks which variant of its classes is active;
|
|
79
|
+
* `visibility` hides/shows it initially. Kept minimal — the two fields agents actually set. */
|
|
80
|
+
export interface AIInitialState {
|
|
81
|
+
styleVariant?: AIStyleVariantSelection;
|
|
82
|
+
visibility?: boolean;
|
|
83
|
+
}
|
|
84
|
+
/** One data binding: connect a data `source` to the element field named by `to` (a prop, a style value, or an
|
|
85
|
+
* initial-state key, per its category). `transformers` reshape the value; `when` gates the binding. */
|
|
86
|
+
export interface AIBinding {
|
|
87
|
+
id: string;
|
|
88
|
+
to: string;
|
|
89
|
+
source: string;
|
|
90
|
+
transformers?: Array<{
|
|
91
|
+
action: string;
|
|
92
|
+
params: Record<string, string>;
|
|
93
|
+
enabled?: boolean;
|
|
94
|
+
}>;
|
|
95
|
+
when?: unknown;
|
|
96
|
+
enabled?: boolean;
|
|
97
|
+
}
|
|
98
|
+
/** Data bindings on an element, grouped by what they feed: element props (`attributes`), style values (`style`),
|
|
99
|
+
* or initial-state keys (`initialState`). */
|
|
100
|
+
export type AIBindings = Partial<Record<'attributes' | 'style' | 'initialState', AIBinding[]>>;
|
|
101
|
+
export type AIInteractionNodeType = 'trigger' | 'globalCallback' | 'callback' | 'utility';
|
|
102
|
+
/** One step of an interaction flow, projected from the stored doubly-linked node. Order is conveyed by the
|
|
103
|
+
* position in `AIInteractionFlow.nodes`; the stored beforeNode/afterNode/flowId links are computed on write. */
|
|
104
|
+
export interface AIInteractionNode {
|
|
105
|
+
id: string;
|
|
106
|
+
title: string;
|
|
107
|
+
nodeType: AIInteractionNodeType;
|
|
108
|
+
action: string;
|
|
109
|
+
params?: Record<string, unknown>;
|
|
110
|
+
enabled?: boolean;
|
|
111
|
+
when?: unknown;
|
|
112
|
+
/** Source element the callback targets (globalCallback/utility). Defaults to this element on write. */
|
|
113
|
+
elementId?: string;
|
|
114
|
+
preview?: Record<string, unknown>;
|
|
115
|
+
}
|
|
116
|
+
/** One interaction flow on an element: a trigger (first node) followed by the callbacks/utilities it runs, in
|
|
117
|
+
* order. `flowId` equals the trigger node id. */
|
|
118
|
+
export interface AIInteractionFlow {
|
|
119
|
+
flowId: string;
|
|
120
|
+
nodes: AIInteractionNode[];
|
|
121
|
+
}
|
|
122
|
+
export interface AIElementDetail {
|
|
123
|
+
ref: string;
|
|
124
|
+
type: string;
|
|
125
|
+
subType?: string;
|
|
126
|
+
label: string;
|
|
127
|
+
pageRef: string;
|
|
128
|
+
parentRef?: string;
|
|
129
|
+
props?: Record<string, unknown>;
|
|
130
|
+
style: {
|
|
131
|
+
base: string[];
|
|
132
|
+
slots: Record<string, string[]>;
|
|
133
|
+
};
|
|
134
|
+
/** CSS of the definitions referenced by `style` (keyed by class ref), inlined so an edit needs no follow-up
|
|
135
|
+
* read of each definition. Present only for refs that resolve to a definition. */
|
|
136
|
+
resolvedStyle?: Record<string, AIDefinition>;
|
|
137
|
+
/** Global (type 'element') styles that also affect this element because they target its type — every element of
|
|
138
|
+
* the type inherits them. Read-only here (not editable as definitions); shown so the effective CSS is complete. */
|
|
139
|
+
globalStyles?: AIGlobalStyle[];
|
|
140
|
+
/** Id rule (type 'id') targeting this element by its DOM `id` attribute (`#id`). Present only when the element
|
|
141
|
+
* carries an `id` that a rule matches. Edit it with the id-style tools (never as a definition). */
|
|
142
|
+
idStyle?: AIIdStyle;
|
|
143
|
+
/** Variant names each attached class exposes (deduped across its selectors), so the agent knows a class HAS a
|
|
144
|
+
* variant (e.g. a button class with "primary") before applying it via `initialState.styleVariant`. */
|
|
145
|
+
availableVariants?: Record<string, string[]>;
|
|
146
|
+
/** Which variant/visibility this element applies today (element.definition.initialState). */
|
|
147
|
+
initialState?: AIInitialState;
|
|
148
|
+
/** Data bindings on this element, grouped by category. */
|
|
149
|
+
bindings?: AIBindings;
|
|
150
|
+
/** Interaction flows on this element (event → ordered callbacks). */
|
|
151
|
+
interactions?: AIInteractionFlow[];
|
|
152
|
+
childRefs?: string[];
|
|
153
|
+
}
|
|
154
|
+
/** A global element style (a type 'element' StyleItem): its CSS applies to every element whose type equals
|
|
155
|
+
* `appliesToType`. It is not an addressable class definition — editing it would change every such element. */
|
|
156
|
+
export interface AIGlobalStyle extends AIDefinition {
|
|
157
|
+
appliesToType: string;
|
|
158
|
+
}
|
|
159
|
+
/** An id rule (a type 'id' StyleItem): its CSS targets the single element whose DOM `id` equals `targetId`
|
|
160
|
+
* (the CSS equivalent of `#id { … }`). Style one element by giving it an `id` attribute and writing this rule;
|
|
161
|
+
* prefer a class definition when the styling could be reused. */
|
|
162
|
+
export interface AIIdStyle extends AIDefinition {
|
|
163
|
+
targetId: string;
|
|
164
|
+
}
|
|
165
|
+
export interface AIDefinitionSlot extends DisplayModeCss {
|
|
166
|
+
states?: Record<string, DisplayModeCss>;
|
|
167
|
+
variants?: Record<string, DisplayModeCss>;
|
|
168
|
+
}
|
|
169
|
+
export interface AIDefinition extends AIDefinitionSlot {
|
|
170
|
+
ref: string;
|
|
171
|
+
slots?: Record<string, AIDefinitionSlot>;
|
|
172
|
+
}
|
|
173
|
+
export type StyleVariableCategory = 'color' | 'spacing' | 'shadow' | 'custom';
|
|
174
|
+
export type StyleVariableValue = string | number | {
|
|
175
|
+
light?: string;
|
|
176
|
+
dark?: string;
|
|
177
|
+
default?: string;
|
|
178
|
+
};
|
|
179
|
+
export interface AIStyleVariable {
|
|
180
|
+
name: string;
|
|
181
|
+
reference: string;
|
|
182
|
+
value: StyleVariableValue;
|
|
183
|
+
}
|
|
184
|
+
export interface AISchemaVariable {
|
|
185
|
+
name: string;
|
|
186
|
+
reference: string;
|
|
187
|
+
category: string;
|
|
188
|
+
type: string;
|
|
189
|
+
value: string | number | boolean;
|
|
190
|
+
subValues?: Array<{
|
|
191
|
+
when: unknown;
|
|
192
|
+
value: string | number | boolean;
|
|
193
|
+
}>;
|
|
194
|
+
}
|
|
195
|
+
/** Space-level settings: the arbitrary global CSS (`customCss`), state persistence, and the user/auth provider
|
|
196
|
+
* configuration. Every field is optional — a patch changes only the keys it sends. */
|
|
197
|
+
export interface AISettings {
|
|
198
|
+
customCss?: string;
|
|
199
|
+
keepState?: boolean;
|
|
200
|
+
stateStorage?: 'localStorage' | 'sessionStorage';
|
|
201
|
+
userProvider?: 'auth0' | 'basic' | 'custom' | '';
|
|
202
|
+
auth0Domain?: string;
|
|
203
|
+
auth0ClientId?: string;
|
|
204
|
+
tokenStorage?: 'localStorage' | 'sessionStorage' | '';
|
|
205
|
+
loginUrl?: string;
|
|
206
|
+
userUrl?: string;
|
|
207
|
+
refreshUrl?: string;
|
|
208
|
+
logoutUrl?: string;
|
|
209
|
+
detailsPath?: string;
|
|
210
|
+
tokenPath?: string;
|
|
211
|
+
expirationTimePath?: string;
|
|
212
|
+
}
|
|
213
|
+
export interface ValidationError {
|
|
214
|
+
path: string;
|
|
215
|
+
message: string;
|
|
216
|
+
hint: string;
|
|
217
|
+
validValues?: unknown[];
|
|
218
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ValidationError } from './aiSchema';
|
|
2
|
+
import { Operation } from '../tools/operations';
|
|
3
|
+
export type PreviewRequestBody = {
|
|
4
|
+
spaceId: number;
|
|
5
|
+
env?: string;
|
|
6
|
+
pageRef?: string;
|
|
7
|
+
operations?: Operation[];
|
|
8
|
+
};
|
|
9
|
+
export type PreviewResult = {
|
|
10
|
+
ok: true;
|
|
11
|
+
token?: string;
|
|
12
|
+
pagePath: string;
|
|
13
|
+
html: string;
|
|
14
|
+
stateVersion: string;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
error: string;
|
|
18
|
+
message: string;
|
|
19
|
+
errors?: ValidationError[];
|
|
20
|
+
};
|
|
21
|
+
/** How the MCP tools reach the renderer. The consumer injects an implementation (an HTTP client to the SSR
|
|
22
|
+
* `/preview` endpoint, or an in-process call when co-located); absent means preview is not wired. */
|
|
23
|
+
export type PreviewClient = {
|
|
24
|
+
render: (body: PreviewRequestBody) => Promise<PreviewResult>;
|
|
25
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type Viewport = {
|
|
2
|
+
label: string;
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
};
|
|
6
|
+
export type ScreenshotImage = {
|
|
7
|
+
label: string;
|
|
8
|
+
mimeType: string;
|
|
9
|
+
data: string;
|
|
10
|
+
};
|
|
11
|
+
export type ScreenshotResult = {
|
|
12
|
+
ok: true;
|
|
13
|
+
images: ScreenshotImage[];
|
|
14
|
+
} | {
|
|
15
|
+
ok: false;
|
|
16
|
+
error: string;
|
|
17
|
+
message: string;
|
|
18
|
+
};
|
|
19
|
+
export type ScreenshotInput = {
|
|
20
|
+
pagePath: string;
|
|
21
|
+
token?: string;
|
|
22
|
+
viewports: Viewport[];
|
|
23
|
+
};
|
|
24
|
+
/** How plitzi_screenshot reaches the headless-browser service. The consumer injects an implementation (an HTTP
|
|
25
|
+
* client to the dedicated browser pod); absent → the tool is not registered. A capture that fails (pod down)
|
|
26
|
+
* returns `ok:false` rather than throwing, so the tool can degrade to the HTML preview. */
|
|
27
|
+
export type ScreenshotClient = {
|
|
28
|
+
capture: (input: ScreenshotInput) => Promise<ScreenshotResult>;
|
|
29
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { AIDefinition, AIElementDetail, ValidationError } from './aiSchema';
|
|
2
|
+
import { Operation } from '../tools/operations';
|
|
3
|
+
import { Schema, Style } from '@plitzi/sdk-shared';
|
|
4
|
+
/** The element schema and the style schema persist independently (Space model / Style model), so each has
|
|
5
|
+
* its own optional persister. When one is absent, that schema is applied in memory but reported unsaved. */
|
|
6
|
+
export interface Persisters {
|
|
7
|
+
schema?: (schema: Schema) => Promise<void>;
|
|
8
|
+
style?: (style: Style) => Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export interface Conflict {
|
|
11
|
+
resourceUri: string;
|
|
12
|
+
expectedVersion: string;
|
|
13
|
+
currentVersion: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ChangedResource {
|
|
16
|
+
uri: string;
|
|
17
|
+
stateVersion: string;
|
|
18
|
+
}
|
|
19
|
+
/** Full detail of a created/updated element, plus its own uri and stateVersion so a follow-up edit of the same
|
|
20
|
+
* element can guard with optimistic concurrency without an intermediate read. */
|
|
21
|
+
export type WriteElement = AIElementDetail & {
|
|
22
|
+
uri: string;
|
|
23
|
+
stateVersion: string;
|
|
24
|
+
};
|
|
25
|
+
/** Write result: what changed and the new versions, plus the full detail of every element created/updated (with
|
|
26
|
+
* its uri + stateVersion) so the caller has that context without a follow-up read. Other resources (pages,
|
|
27
|
+
* definitions, variables) still report only uri+version — re-read them if needed. */
|
|
28
|
+
export interface WriteResponse {
|
|
29
|
+
applied: boolean;
|
|
30
|
+
dryRun?: boolean;
|
|
31
|
+
persisted?: boolean;
|
|
32
|
+
summary: {
|
|
33
|
+
created: number;
|
|
34
|
+
updated: number;
|
|
35
|
+
deleted: number;
|
|
36
|
+
};
|
|
37
|
+
changed: ChangedResource[];
|
|
38
|
+
elements?: WriteElement[];
|
|
39
|
+
warnings?: string[];
|
|
40
|
+
errors?: ValidationError[];
|
|
41
|
+
conflict?: {
|
|
42
|
+
message: string;
|
|
43
|
+
conflicts: Conflict[];
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** The outcome of applying a batch to the space in memory: counts, which schema(s) changed (so the caller can
|
|
47
|
+
* persist each independently), the invalidated resource URIs and the refs of the elements it created/updated. */
|
|
48
|
+
export interface MutationOutcome {
|
|
49
|
+
created: number;
|
|
50
|
+
updated: number;
|
|
51
|
+
deleted: number;
|
|
52
|
+
staleResources: string[];
|
|
53
|
+
elementRefs: string[];
|
|
54
|
+
errors: ValidationError[];
|
|
55
|
+
changedSchema: boolean;
|
|
56
|
+
changedStyle: boolean;
|
|
57
|
+
}
|
|
58
|
+
export interface ApplyInput {
|
|
59
|
+
environment?: string;
|
|
60
|
+
dryRun?: boolean;
|
|
61
|
+
expectedResourceVersions?: Record<string, string>;
|
|
62
|
+
operations: Operation[];
|
|
63
|
+
}
|
|
64
|
+
export interface ValidateInput {
|
|
65
|
+
environment?: string;
|
|
66
|
+
operations: Operation[];
|
|
67
|
+
}
|
|
68
|
+
export interface ValidationResult {
|
|
69
|
+
valid: boolean;
|
|
70
|
+
errors: ValidationError[];
|
|
71
|
+
warnings: string[];
|
|
72
|
+
}
|
|
73
|
+
export interface SearchInput {
|
|
74
|
+
query: string;
|
|
75
|
+
filters?: {
|
|
76
|
+
type?: string;
|
|
77
|
+
pageRef?: string;
|
|
78
|
+
};
|
|
79
|
+
/** 'detail' inlines each hit's full props/style so an edit needs no follow-up read. */
|
|
80
|
+
include?: 'detail';
|
|
81
|
+
/** Max element hits to return in this page (default 50). */
|
|
82
|
+
limit?: number;
|
|
83
|
+
/** Element hits to skip before this page (default 0). */
|
|
84
|
+
offset?: number;
|
|
85
|
+
}
|
|
86
|
+
export interface SearchHit {
|
|
87
|
+
pageRef: string;
|
|
88
|
+
ref: string;
|
|
89
|
+
uri: string;
|
|
90
|
+
pageUri: string;
|
|
91
|
+
stateVersion: string;
|
|
92
|
+
parentRef?: string;
|
|
93
|
+
/** Ancestor labels from the page down to and including this element. */
|
|
94
|
+
path: string[];
|
|
95
|
+
label: string;
|
|
96
|
+
type: string;
|
|
97
|
+
matches: string[];
|
|
98
|
+
detail?: AIElementDetail;
|
|
99
|
+
}
|
|
100
|
+
export interface SearchPageHit {
|
|
101
|
+
ref: string;
|
|
102
|
+
uri: string;
|
|
103
|
+
stateVersion: string;
|
|
104
|
+
label: string;
|
|
105
|
+
slug: string;
|
|
106
|
+
matches: string[];
|
|
107
|
+
}
|
|
108
|
+
export interface SearchResponse {
|
|
109
|
+
results: SearchHit[];
|
|
110
|
+
/** Total element hits matching the query across all pages, before offset/limit. */
|
|
111
|
+
total: number;
|
|
112
|
+
/** Element hits skipped before this page (echoes the request's offset, defaulted). */
|
|
113
|
+
offset: number;
|
|
114
|
+
/** Page size applied to element hits (echoes the request's limit, defaulted). */
|
|
115
|
+
limit: number;
|
|
116
|
+
/** The offset to pass next to fetch the following page. Present only while more hits remain past this page. */
|
|
117
|
+
nextOffset?: number;
|
|
118
|
+
/** Style definitions whose ref matches the query, with their full CSS — so finding a class by name closes the
|
|
119
|
+
* loop to its style without a separate read. Present only when at least one definition matches. */
|
|
120
|
+
definitions?: AIDefinition[];
|
|
121
|
+
/** Pages whose name or slug matches the query (element hits never include pages). Each carries the page uri +
|
|
122
|
+
* stateVersion, ready to open or edit. Present only when at least one page matches. */
|
|
123
|
+
pages?: SearchPageHit[];
|
|
124
|
+
}
|
|
125
|
+
export interface ReadInput {
|
|
126
|
+
uris: string[];
|
|
127
|
+
}
|
|
128
|
+
export interface ReadHit {
|
|
129
|
+
uri: string;
|
|
130
|
+
stateVersion?: string;
|
|
131
|
+
data?: unknown;
|
|
132
|
+
error?: string;
|
|
133
|
+
message?: string;
|
|
134
|
+
hint?: string;
|
|
135
|
+
}
|
|
136
|
+
export interface ReadResponse {
|
|
137
|
+
results: ReadHit[];
|
|
138
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { TtlCache } from '../../helpers/cache';
|
|
2
2
|
import { RequestMetrics } from '../../helpers/metrics';
|
|
3
3
|
import { PluginManager } from '../../plugins/manager';
|
|
4
|
-
import { Environment, SSRRenderResult, SSRRequest, SSRServerConfig, SSRTemplateFn } from '@plitzi/sdk-shared';
|
|
4
|
+
import { Environment, OfflineDataRaw, SSRRenderResult, SSRRequest, SSRServerConfig, SSRTemplateFn } from '@plitzi/sdk-shared';
|
|
5
5
|
export type BuildBodyResult = {
|
|
6
6
|
body?: string;
|
|
7
7
|
result: SSRRenderResult;
|
|
8
8
|
};
|
|
9
|
-
export declare const buildBody: (req: SSRRequest, config: SSRServerConfig, spaceId: number, environment: Environment, revision: number, renderFn: SSRTemplateFn, pluginManager: PluginManager, offlineDataCache?: TtlCache<string>, metrics?: RequestMetrics) => Promise<BuildBodyResult>;
|
|
9
|
+
export declare const buildBody: (req: SSRRequest, config: SSRServerConfig, spaceId: number, environment: Environment, revision: number, renderFn: SSRTemplateFn, pluginManager: PluginManager, offlineDataCache?: TtlCache<string>, metrics?: RequestMetrics, offlineDataOverride?: OfflineDataRaw) => Promise<BuildBodyResult>;
|
|
@@ -2,7 +2,7 @@ import { ComponentProps } from './Component';
|
|
|
2
2
|
import { TtlCache } from '../../helpers/cache';
|
|
3
3
|
import { RequestMetrics } from '../../helpers/metrics';
|
|
4
4
|
import { PluginManager } from '../../plugins/manager';
|
|
5
|
-
import { Environment, PluginEntry, SSRRequest, SSRServerConfig, SSRTemplateProps } from '@plitzi/sdk-shared';
|
|
5
|
+
import { Environment, OfflineDataRaw, PluginEntry, SSRRequest, SSRServerConfig, SSRTemplateProps } from '@plitzi/sdk-shared';
|
|
6
6
|
export type RenderPrep = {
|
|
7
7
|
componentProps: ComponentProps;
|
|
8
8
|
entries: PluginEntry[];
|
|
@@ -10,4 +10,4 @@ export type RenderPrep = {
|
|
|
10
10
|
offlineData: string;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export declare const prepareRender: (req: SSRRequest, config: SSRServerConfig, spaceId: number, environment: Environment, revision: number, pluginManager: PluginManager, offlineDataCache?: TtlCache<string>, metrics?: RequestMetrics) => Promise<RenderPrep>;
|
|
13
|
+
export declare const prepareRender: (req: SSRRequest, config: SSRServerConfig, spaceId: number, environment: Environment, revision: number, pluginManager: PluginManager, offlineDataCache?: TtlCache<string>, metrics?: RequestMetrics, offlineDataOverride?: OfflineDataRaw) => Promise<RenderPrep>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PREVIEW_TOKEN_PARAM } from '../mcp/constants';
|
|
2
|
+
import { ServerCaches } from '../../helpers/cache';
|
|
3
|
+
import { PluginManager } from '../../plugins/manager';
|
|
4
|
+
import { PreviewRequestBody, PreviewResult } from '../mcp/types';
|
|
5
|
+
import { DraftStore, OfflineDataRaw, SSRRequest, SSRServerConfig, SSRTemplateFn } from '@plitzi/sdk-shared';
|
|
6
|
+
export { PREVIEW_TOKEN_PARAM };
|
|
7
|
+
/** In-memory one-shot draft store — the default when the consumer injects none. Fine for a single replica;
|
|
8
|
+
* a multi-replica deployment must inject a shared store so a preview URL resolves on any replica. */
|
|
9
|
+
export declare const createMemoryDraftStore: () => DraftStore;
|
|
10
|
+
/** Consume the draft override for a render, if the request carries a valid preview token. Returns undefined on
|
|
11
|
+
* a normal request (renders persisted state) or when the token is unknown/expired (one-shot / TTL). */
|
|
12
|
+
export declare const takeDraftOverride: (req: SSRRequest, config: SSRServerConfig) => Promise<OfflineDataRaw | undefined>;
|
|
13
|
+
/** Build a preview of a page: apply any unsaved `operations` to a clone (never persisted), render the resulting
|
|
14
|
+
* draft to full HTML via the SSR pipeline, and stash the draft under a one-shot token so a browser can fetch
|
|
15
|
+
* the exact same render at `?__pt=<token>` (for screenshots). With no operations it previews persisted state. */
|
|
16
|
+
export declare const createPreview: (body: PreviewRequestBody, config: SSRServerConfig, renderFn: SSRTemplateFn, pluginManager: PluginManager, caches: ServerCaches) => Promise<PreviewResult>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TtlCache } from '../../helpers/cache';
|
|
2
2
|
import { RequestMetrics } from '../../helpers/metrics';
|
|
3
3
|
import { PluginManager } from '../../plugins/manager';
|
|
4
|
-
import { Environment, SSRRequest, SSRResponseHelpers, SSRServerConfig, SSRTemplateFn } from '@plitzi/sdk-shared';
|
|
5
|
-
export declare const streamBody: (req: SSRRequest, res: SSRResponseHelpers, config: SSRServerConfig, spaceId: number, environment: Environment, revision: number, renderFn: SSRTemplateFn, pluginManager: PluginManager, offlineDataCache?: TtlCache<string>, htmlCache?: TtlCache<string>, cacheKey?: string, metrics?: RequestMetrics) => Promise<void>;
|
|
4
|
+
import { Environment, OfflineDataRaw, SSRRequest, SSRResponseHelpers, SSRServerConfig, SSRTemplateFn } from '@plitzi/sdk-shared';
|
|
5
|
+
export declare const streamBody: (req: SSRRequest, res: SSRResponseHelpers, config: SSRServerConfig, spaceId: number, environment: Environment, revision: number, renderFn: SSRTemplateFn, pluginManager: PluginManager, offlineDataCache?: TtlCache<string>, htmlCache?: TtlCache<string>, cacheKey?: string, metrics?: RequestMetrics, offlineDataOverride?: OfflineDataRaw) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-server",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.6",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
"sideEffects": false,
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
26
|
-
"@plitzi/plitzi-sdk": "0.32.
|
|
27
|
-
"@plitzi/sdk-
|
|
26
|
+
"@plitzi/plitzi-sdk": "0.32.6",
|
|
27
|
+
"@plitzi/sdk-schema": "0.32.6",
|
|
28
|
+
"@plitzi/sdk-shared": "0.32.6",
|
|
28
29
|
"ejs": "^6.0.1",
|
|
29
30
|
"esbuild": "^0.28.1",
|
|
30
31
|
"zod": "^4.4.3"
|
|
@@ -35,19 +36,19 @@
|
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@types/ejs": "^3.1.5",
|
|
38
|
-
"@types/node": "^26.
|
|
39
|
+
"@types/node": "^26.1.1",
|
|
39
40
|
"@types/react": "^19.2.17",
|
|
40
|
-
"@vitejs/plugin-react": "^6.0.
|
|
41
|
-
"@vitest/coverage-v8": "^4.1.
|
|
42
|
-
"eslint": "^9.39.
|
|
41
|
+
"@vitejs/plugin-react": "^6.0.4",
|
|
42
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
43
|
+
"eslint": "^9.39.5",
|
|
43
44
|
"eslint-plugin-import": "^2.32.0",
|
|
44
|
-
"react": "^19.2.
|
|
45
|
-
"react-dom": "^19.2.
|
|
46
|
-
"tsx": "^4.
|
|
45
|
+
"react": "^19.2.8",
|
|
46
|
+
"react-dom": "^19.2.8",
|
|
47
|
+
"tsx": "^4.23.1",
|
|
47
48
|
"typescript": "^6.0.3",
|
|
48
|
-
"vite": "^8.
|
|
49
|
-
"vite-plugin-dts": "^5.0.
|
|
50
|
-
"vitest": "^4.1.
|
|
49
|
+
"vite": "^8.1.5",
|
|
50
|
+
"vite-plugin-dts": "^5.0.3",
|
|
51
|
+
"vitest": "^4.1.10"
|
|
51
52
|
},
|
|
52
53
|
"scripts": {
|
|
53
54
|
"start:dev": "node --import ./src/standalone/register-alias.mjs --watch src/standalone/server.ts",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"lint": "TIMING=1 eslint ./src",
|
|
60
61
|
"typecheck": "tsc -p tsconfig.app.json --noEmit",
|
|
61
62
|
"test": "vitest run",
|
|
62
|
-
"test:coverage": "vitest run --coverage"
|
|
63
|
+
"test:coverage": "vitest run --coverage",
|
|
64
|
+
"bench": "vitest bench --run"
|
|
63
65
|
}
|
|
64
66
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __exportAll = (all, no_symbols) => {
|
|
4
|
-
let target = {};
|
|
5
|
-
for (var name in all) __defProp(target, name, {
|
|
6
|
-
get: all[name],
|
|
7
|
-
enumerable: true
|
|
8
|
-
});
|
|
9
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
-
return target;
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
13
|
-
export { __exportAll };
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { parseRequest, readRawBody } from "./requestParser.js";
|
|
2
|
-
import { serveStatic } from "./staticFiles.js";
|
|
3
|
-
import { buildResponseHelpers } from "../helpers/buildResponseHelpers.js";
|
|
4
|
-
import { runMiddlewares } from "../helpers/runMiddlewares.js";
|
|
5
|
-
import { authMiddleware } from "../middlewares/auth.js";
|
|
6
|
-
import { basicAuthMiddleware } from "../middlewares/basicAuth.js";
|
|
7
|
-
import { spaceDeploymentMiddleware } from "../middlewares/spaceDeployment.js";
|
|
8
|
-
import { handleMcp } from "../modules/mcp/handler.js";
|
|
9
|
-
import { handleRsc } from "../modules/rsc/handler.js";
|
|
10
|
-
import { renderSSR } from "../modules/ssr/handler.js";
|
|
11
|
-
import path from "node:path";
|
|
12
|
-
import { fileURLToPath } from "node:url";
|
|
13
|
-
//#region src/core/requestHandler.ts
|
|
14
|
-
var __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
-
var BUILTIN_PUBLIC_DIR = path.resolve(__dirname, "../public");
|
|
16
|
-
var safeRedirectTarget = (req) => {
|
|
17
|
-
const redirectParam = req.query["redirect"];
|
|
18
|
-
return redirectParam && redirectParam.startsWith("/") && !redirectParam.startsWith("//") ? redirectParam : "/";
|
|
19
|
-
};
|
|
20
|
-
var handleRequest = async (raw, rawRes, config, port, renderFn, caches, pluginManager) => {
|
|
21
|
-
const req = parseRequest(raw);
|
|
22
|
-
const res = buildResponseHelpers(rawRes, req.headers["accept-encoding"]);
|
|
23
|
-
if (req.path === "\0") {
|
|
24
|
-
res.setStatus(400);
|
|
25
|
-
res.end();
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
res.setHeader("X-Content-Type-Options", "nosniff");
|
|
29
|
-
res.setHeader("Referrer-Policy", "strict-origin-when-cross-origin");
|
|
30
|
-
res.setHeader("X-DNS-Prefetch-Control", "off");
|
|
31
|
-
const frameOptions = config.frameOptions === void 0 ? "DENY" : config.frameOptions;
|
|
32
|
-
if (frameOptions) if (Array.isArray(frameOptions)) res.setHeader("Content-Security-Policy", `frame-ancestors ${frameOptions.join(" ")}`);
|
|
33
|
-
else {
|
|
34
|
-
res.setHeader("X-Frame-Options", frameOptions);
|
|
35
|
-
res.setHeader("Content-Security-Policy", `frame-ancestors '${frameOptions === "DENY" ? "none" : "self"}'`);
|
|
36
|
-
}
|
|
37
|
-
if ((config.httpVersion ?? 2) >= 3) res.setHeader("Alt-Svc", `h3=":${port}"; ma=86400`);
|
|
38
|
-
if (serveStatic(req, res, BUILTIN_PUBLIC_DIR)) return;
|
|
39
|
-
if (config.publicDir && serveStatic(req, res, config.publicDir)) return;
|
|
40
|
-
if (req.path.startsWith("/.well-known/")) {
|
|
41
|
-
res.setStatus(404);
|
|
42
|
-
res.end();
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (req.path.startsWith(pluginManager.urlPrefix + "/")) {
|
|
46
|
-
const relative = req.path.slice(pluginManager.urlPrefix.length);
|
|
47
|
-
const pluginName = relative.split("/")[1];
|
|
48
|
-
if (pluginName && pluginManager.hasPlugin(pluginName)) {
|
|
49
|
-
await pluginManager.prepare(pluginName);
|
|
50
|
-
if (serveStatic({
|
|
51
|
-
...req,
|
|
52
|
-
path: relative
|
|
53
|
-
}, res, pluginManager.outputDir)) return;
|
|
54
|
-
}
|
|
55
|
-
res.setStatus(404);
|
|
56
|
-
res.send("Not found");
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const loginPath = config.loginPath === false ? null : config.loginPath ?? "/auth/login";
|
|
60
|
-
if (loginPath && req.method === "POST" && req.path === loginPath) {
|
|
61
|
-
req.body = await readRawBody(raw);
|
|
62
|
-
const isLoggedIn = await config.adapters.onLogin?.(req, res);
|
|
63
|
-
if (req.headers["sec-fetch-mode"] === "navigate") {
|
|
64
|
-
res.setStatus(303);
|
|
65
|
-
res.setHeader("Location", isLoggedIn ? safeRedirectTarget(req) : loginPath);
|
|
66
|
-
res.end();
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
res.setStatus(isLoggedIn ? 200 : 401);
|
|
70
|
-
res.end();
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const logoutPath = config.logoutPath === false ? null : config.logoutPath ?? "/auth/logout";
|
|
74
|
-
if (logoutPath && req.method === "POST" && req.path === logoutPath) {
|
|
75
|
-
req.body = await readRawBody(raw);
|
|
76
|
-
await config.adapters.onLogout?.(req, res);
|
|
77
|
-
if (req.headers["sec-fetch-mode"] === "navigate") {
|
|
78
|
-
res.setStatus(303);
|
|
79
|
-
res.setHeader("Location", safeRedirectTarget(req));
|
|
80
|
-
res.end();
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
res.setStatus(204);
|
|
84
|
-
res.end();
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (config.static) for (const [prefix, rootDir] of Object.entries(config.static)) {
|
|
88
|
-
const normalizedPrefix = prefix.endsWith("/") ? prefix : `${prefix}/`;
|
|
89
|
-
if (req.path === prefix || req.path.startsWith(normalizedPrefix)) {
|
|
90
|
-
if (serveStatic({
|
|
91
|
-
...req,
|
|
92
|
-
path: req.path.slice(prefix.length) || "/"
|
|
93
|
-
}, res, rootDir)) return;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const mcpPath = config.mcp?.path ?? "/mcp";
|
|
97
|
-
if (config.mcp && (config.mcp.enabled ?? true) && req.path.startsWith(mcpPath)) {
|
|
98
|
-
await handleMcp(raw, rawRes, config.mcp);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (await runMiddlewares([
|
|
102
|
-
spaceDeploymentMiddleware(config.adapters),
|
|
103
|
-
basicAuthMiddleware({ cacheTtlMs: config.cacheTtlMs }),
|
|
104
|
-
authMiddleware(config.adapters),
|
|
105
|
-
...config.middlewares || []
|
|
106
|
-
], req, res) || res.status !== 200) return;
|
|
107
|
-
const rscPath = config.rsc?.path ?? "/_rsc";
|
|
108
|
-
if ((config.rsc?.enabled ?? !!config.adapters.getRscData) && req.method === "GET" && req.path === rscPath) {
|
|
109
|
-
await handleRsc(req, res, config, pluginManager, caches.rsc);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
await renderSSR(req, res, config, renderFn, pluginManager, caches);
|
|
113
|
-
};
|
|
114
|
-
var makeHandler = (config, port, renderFn, caches, pluginManager) => {
|
|
115
|
-
return (raw, rawRes) => {
|
|
116
|
-
handleRequest(raw, rawRes, config, port, renderFn, caches, pluginManager).catch((err) => {
|
|
117
|
-
console.error("[SSR] Unhandled error:", err);
|
|
118
|
-
try {
|
|
119
|
-
if (!rawRes.headersSent) rawRes.writeHead(500, { "Content-Type": "text/plain" });
|
|
120
|
-
rawRes.end("Internal Server Error");
|
|
121
|
-
} catch {}
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
//#endregion
|
|
126
|
-
export { makeHandler };
|