@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.
Files changed (476) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/adapters/jsonAdapters.js +6 -1
  3. package/dist/core/createServer.js +8 -44
  4. package/dist/core/health.js +15 -0
  5. package/dist/core/http/dispatcher.js +29 -0
  6. package/dist/core/http/securityHeaders.js +15 -0
  7. package/dist/core/http/stages/authRoutes.js +41 -0
  8. package/dist/core/http/stages/health.js +12 -0
  9. package/dist/core/http/stages/middlewares.js +16 -0
  10. package/dist/core/http/stages/pluginAssets.js +20 -0
  11. package/dist/core/http/stages/static.js +30 -0
  12. package/dist/core/server/baseServer.js +29 -0
  13. package/dist/core/server/mcpServer.js +29 -0
  14. package/dist/core/server/ssrServer.js +54 -0
  15. package/dist/core/services/mcp.js +22 -0
  16. package/dist/core/services/preview.js +37 -0
  17. package/dist/core/services/registry.js +30 -0
  18. package/dist/core/services/resolve.js +12 -0
  19. package/dist/core/services/rsc.js +11 -0
  20. package/dist/core/services/ssr.js +13 -0
  21. package/dist/core/transports.js +9 -9
  22. package/dist/helpers/buildServerInfo.js +3 -9
  23. package/dist/index.js +20 -6
  24. package/dist/modules/ai/AIEngine.js +4 -4
  25. package/dist/modules/ai/toolkit.js +58 -0
  26. package/dist/modules/mcp/catalogs/builtinCallbacks.js +204 -0
  27. package/dist/modules/mcp/catalogs/builtinComponents.js +170 -0
  28. package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +50 -0
  29. package/dist/modules/mcp/catalogs/builtinTransformers.js +148 -0
  30. package/dist/modules/mcp/catalogs/builtinUtilities.js +90 -0
  31. package/dist/modules/mcp/catalogs/cssCatalog.js +205 -0
  32. package/dist/modules/mcp/catalogs/observed.js +90 -0
  33. package/dist/modules/mcp/catalogs/paramSpec.js +69 -0
  34. package/dist/modules/mcp/catalogs/registry.js +89 -0
  35. package/dist/modules/mcp/constants.js +4 -0
  36. package/dist/modules/mcp/handler.js +24 -20
  37. package/dist/modules/mcp/helpers/agentPrompt.js +104 -0
  38. package/dist/modules/mcp/helpers/computeVersion.js +16 -0
  39. package/dist/modules/mcp/helpers/guide.js +449 -0
  40. package/dist/modules/mcp/helpers/interactions.js +123 -0
  41. package/dist/modules/mcp/helpers/log.js +54 -0
  42. package/dist/modules/mcp/helpers/opResult.js +18 -0
  43. package/dist/modules/mcp/helpers/space.js +262 -0
  44. package/dist/modules/mcp/helpers/uris.js +44 -0
  45. package/dist/modules/mcp/previewClient.js +31 -0
  46. package/dist/modules/mcp/resources/canonical.js +30 -0
  47. package/dist/modules/mcp/resources/core.js +15 -0
  48. package/dist/modules/mcp/resources/envelope.js +14 -0
  49. package/dist/modules/mcp/resources/primer.js +30 -0
  50. package/dist/modules/mcp/resources/register.js +174 -0
  51. package/dist/modules/mcp/resources/router.js +25 -0
  52. package/dist/modules/mcp/resources/schema.js +43 -0
  53. package/dist/modules/mcp/resources/style.js +34 -0
  54. package/dist/modules/mcp/screenshotClient.js +47 -0
  55. package/dist/modules/mcp/server.js +66 -20
  56. package/dist/modules/mcp/tools/apply/dispatch.js +103 -0
  57. package/dist/modules/mcp/tools/apply/index.js +136 -0
  58. package/dist/modules/mcp/tools/apply/writeResult.js +37 -0
  59. package/dist/modules/mcp/tools/index.js +20 -148
  60. package/dist/modules/mcp/tools/operations/index.js +41 -0
  61. package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +32 -0
  62. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +36 -0
  63. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +47 -0
  64. package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +29 -0
  65. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +41 -0
  66. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +58 -0
  67. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +65 -0
  68. package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +30 -0
  69. package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +49 -0
  70. package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +52 -0
  71. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +47 -0
  72. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +43 -0
  73. package/dist/modules/mcp/tools/operations/schema/operations.js +39 -0
  74. package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +25 -0
  75. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +75 -0
  76. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +45 -0
  77. package/dist/modules/mcp/tools/operations/schema/shared.js +119 -0
  78. package/dist/modules/mcp/tools/operations/schema/translator.js +215 -0
  79. package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +18 -0
  80. package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +42 -0
  81. package/dist/modules/mcp/tools/operations/schema/write.js +109 -0
  82. package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +21 -0
  83. package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +28 -0
  84. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +24 -0
  85. package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +21 -0
  86. package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +28 -0
  87. package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +24 -0
  88. package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +21 -0
  89. package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +28 -0
  90. package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +24 -0
  91. package/dist/modules/mcp/tools/operations/style/operations.js +27 -0
  92. package/dist/modules/mcp/tools/operations/style/shared.js +59 -0
  93. package/dist/modules/mcp/tools/operations/style/translator.js +101 -0
  94. package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +21 -0
  95. package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +22 -0
  96. package/dist/modules/mcp/tools/operations/style/write.js +108 -0
  97. package/dist/modules/mcp/tools/preview.js +37 -0
  98. package/dist/modules/mcp/tools/read.js +33 -0
  99. package/dist/modules/mcp/tools/screenshot.js +83 -0
  100. package/dist/modules/mcp/tools/search.js +115 -0
  101. package/dist/modules/mcp/tools/shared/tool.js +26 -0
  102. package/dist/modules/mcp/tools/shared/validator/audit.js +124 -0
  103. package/dist/modules/mcp/tools/shared/validator/batch.js +30 -0
  104. package/dist/modules/mcp/tools/shared/validator/bindings.js +70 -0
  105. package/dist/modules/mcp/tools/shared/validator/context.js +35 -0
  106. package/dist/modules/mcp/tools/shared/validator/css.js +47 -0
  107. package/dist/modules/mcp/tools/shared/validator/elements.js +55 -0
  108. package/dist/modules/mcp/tools/shared/validator/index.js +226 -0
  109. package/dist/modules/mcp/tools/shared/validator/interactions.js +106 -0
  110. package/dist/modules/mcp/tools/shared/validator/refs.js +28 -0
  111. package/dist/modules/mcp/tools/validate.js +39 -0
  112. package/dist/modules/ssr/buildBody.js +2 -2
  113. package/dist/modules/ssr/handler.js +6 -4
  114. package/dist/modules/ssr/prepareRender.js +5 -5
  115. package/dist/modules/ssr/preview.js +106 -0
  116. package/dist/modules/ssr/registerExternalPlugins.js +1 -1
  117. package/dist/modules/ssr/streamBody.js +3 -3
  118. package/dist/modules/ssr/template.js +1 -1
  119. package/dist/modules/ssr/views/template.ejs +2 -0
  120. package/dist/plugins/compile.js +1 -1
  121. package/dist/plugins/copy.js +1 -1
  122. package/dist/plugins/manager.js +1 -1
  123. package/dist/server.js +34 -9
  124. package/dist/src/core/createServer.d.ts +5 -1
  125. package/dist/src/core/health.d.ts +10 -0
  126. package/dist/src/core/http/dispatcher.d.ts +7 -0
  127. package/dist/src/core/http/securityHeaders.d.ts +2 -0
  128. package/dist/src/core/http/stages/authRoutes.d.ts +4 -0
  129. package/dist/src/core/http/stages/health.d.ts +2 -0
  130. package/dist/src/core/http/stages/middlewares.d.ts +2 -0
  131. package/dist/src/core/http/stages/pluginAssets.d.ts +2 -0
  132. package/dist/src/core/http/stages/static.d.ts +5 -0
  133. package/dist/src/core/http/types.d.ts +19 -0
  134. package/dist/src/core/server/baseServer.d.ts +9 -0
  135. package/dist/src/core/server/mcpServer.d.ts +2 -0
  136. package/dist/src/core/server/ssrServer.d.ts +2 -0
  137. package/dist/src/core/services/mcp.d.ts +3 -0
  138. package/dist/src/core/services/preview.d.ts +2 -0
  139. package/dist/src/core/services/registry.d.ts +4 -0
  140. package/dist/src/core/services/resolve.d.ts +3 -0
  141. package/dist/src/core/services/rsc.d.ts +2 -0
  142. package/dist/src/core/services/ssr.d.ts +3 -0
  143. package/dist/src/core/transports.d.ts +2 -2
  144. package/dist/src/index.d.ts +12 -3
  145. package/dist/src/modules/ai/index.d.ts +1 -0
  146. package/dist/src/modules/ai/toolkit.d.ts +17 -0
  147. package/dist/src/modules/mcp/catalogs/builtinCallbacks.d.ts +23 -0
  148. package/dist/src/modules/mcp/catalogs/builtinComponents.d.ts +4 -0
  149. package/dist/src/modules/mcp/catalogs/builtinElementCallbacks.d.ts +20 -0
  150. package/dist/src/modules/mcp/catalogs/builtinTransformers.d.ts +28 -0
  151. package/dist/src/modules/mcp/catalogs/builtinUtilities.d.ts +18 -0
  152. package/dist/src/modules/mcp/catalogs/cssCatalog.d.ts +14 -0
  153. package/dist/src/modules/mcp/catalogs/index.d.ts +9 -0
  154. package/dist/src/modules/mcp/catalogs/observed.d.ts +48 -0
  155. package/dist/src/modules/mcp/catalogs/paramSpec.d.ts +42 -0
  156. package/dist/src/modules/mcp/catalogs/registry.d.ts +35 -0
  157. package/dist/src/modules/mcp/constants.d.ts +1 -0
  158. package/dist/src/modules/mcp/handler.d.ts +6 -3
  159. package/dist/src/modules/mcp/helpers/agentPrompt.d.ts +4 -0
  160. package/dist/src/modules/mcp/helpers/computeVersion.d.ts +1 -0
  161. package/dist/src/modules/mcp/helpers/guide.d.ts +3 -0
  162. package/dist/src/modules/mcp/helpers/index.d.ts +8 -0
  163. package/dist/src/modules/mcp/helpers/interactions.d.ts +30 -0
  164. package/dist/src/modules/mcp/helpers/log.d.ts +8 -0
  165. package/dist/src/modules/mcp/helpers/opResult.d.ts +13 -0
  166. package/dist/src/modules/mcp/helpers/space.d.ts +105 -0
  167. package/dist/src/modules/mcp/helpers/uris.d.ts +28 -0
  168. package/dist/src/modules/mcp/index.d.ts +12 -5
  169. package/dist/src/modules/mcp/previewClient.d.ts +13 -0
  170. package/dist/src/modules/mcp/resources/canonical.d.ts +6 -0
  171. package/dist/src/modules/mcp/resources/core.d.ts +5 -0
  172. package/dist/src/modules/mcp/resources/envelope.d.ts +10 -0
  173. package/dist/src/modules/mcp/resources/index.d.ts +7 -10
  174. package/dist/src/modules/mcp/resources/primer.d.ts +7 -0
  175. package/dist/src/modules/mcp/resources/register.d.ts +6 -0
  176. package/dist/src/modules/mcp/resources/router.d.ts +6 -0
  177. package/dist/src/modules/mcp/resources/schema.d.ts +5 -0
  178. package/dist/src/modules/mcp/resources/style.d.ts +5 -0
  179. package/dist/src/modules/mcp/screenshotClient.d.ts +13 -0
  180. package/dist/src/modules/mcp/server.d.ts +21 -3
  181. package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +6 -0
  182. package/dist/src/modules/mcp/tools/apply/index.d.ts +420 -0
  183. package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +8 -0
  184. package/dist/src/modules/mcp/tools/index.d.ts +17 -6
  185. package/dist/src/modules/mcp/tools/operations/index.d.ts +828 -0
  186. package/dist/src/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +17 -0
  187. package/dist/src/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +25 -0
  188. package/dist/src/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +27 -0
  189. package/dist/src/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +10 -0
  190. package/dist/src/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +16 -0
  191. package/dist/src/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +22 -0
  192. package/dist/src/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +16 -0
  193. package/dist/src/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +9 -0
  194. package/dist/src/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +12 -0
  195. package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +20 -0
  196. package/dist/src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +12 -0
  197. package/dist/src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +18 -0
  198. package/dist/src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +27 -0
  199. package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +210 -0
  200. package/dist/src/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +9 -0
  201. package/dist/src/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +14 -0
  202. package/dist/src/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +34 -0
  203. package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +77 -0
  204. package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +12 -0
  205. package/dist/src/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +9 -0
  206. package/dist/src/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +16 -0
  207. package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +42 -0
  208. package/dist/src/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +9 -0
  209. package/dist/src/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +37 -0
  210. package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +37 -0
  211. package/dist/src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +9 -0
  212. package/dist/src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +37 -0
  213. package/dist/src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +37 -0
  214. package/dist/src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +9 -0
  215. package/dist/src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +37 -0
  216. package/dist/src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +37 -0
  217. package/dist/src/modules/mcp/tools/operations/style/index.d.ts +14 -0
  218. package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +231 -0
  219. package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +115 -0
  220. package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +12 -0
  221. package/dist/src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +15 -0
  222. package/dist/src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +20 -0
  223. package/dist/src/modules/mcp/tools/operations/style/write.d.ts +12 -0
  224. package/dist/src/modules/mcp/tools/preview.d.ts +415 -0
  225. package/dist/src/modules/mcp/tools/read.d.ts +8 -0
  226. package/dist/src/modules/mcp/tools/screenshot.d.ts +420 -0
  227. package/dist/src/modules/mcp/tools/search.d.ts +15 -0
  228. package/dist/src/modules/mcp/tools/shared/tool.d.ts +50 -0
  229. package/dist/src/modules/mcp/tools/shared/validator/audit.d.ts +4 -0
  230. package/dist/src/modules/mcp/tools/shared/validator/batch.d.ts +5 -0
  231. package/dist/src/modules/mcp/tools/shared/validator/bindings.d.ts +6 -0
  232. package/dist/src/modules/mcp/tools/shared/validator/context.d.ts +34 -0
  233. package/dist/src/modules/mcp/tools/shared/validator/css.d.ts +4 -0
  234. package/dist/src/modules/mcp/tools/shared/validator/elements.d.ts +6 -0
  235. package/dist/src/modules/mcp/tools/shared/validator/index.d.ts +8 -0
  236. package/dist/src/modules/mcp/tools/shared/validator/interactions.d.ts +3 -0
  237. package/dist/src/modules/mcp/tools/shared/validator/refs.d.ts +4 -0
  238. package/dist/src/modules/mcp/tools/validate.d.ts +417 -0
  239. package/dist/src/modules/mcp/types/aiSchema.d.ts +218 -0
  240. package/dist/src/modules/mcp/types/index.d.ts +4 -0
  241. package/dist/src/modules/mcp/types/previewTypes.d.ts +25 -0
  242. package/dist/src/modules/mcp/types/screenshotTypes.d.ts +29 -0
  243. package/dist/src/modules/mcp/types/toolTypes.d.ts +138 -0
  244. package/dist/src/modules/ssr/buildBody.d.ts +2 -2
  245. package/dist/src/modules/ssr/prepareRender.d.ts +2 -2
  246. package/dist/src/modules/ssr/preview.d.ts +16 -0
  247. package/dist/src/modules/ssr/streamBody.d.ts +2 -2
  248. package/package.json +16 -14
  249. package/dist/_virtual/_rolldown/runtime.js +0 -13
  250. package/dist/core/requestHandler.js +0 -126
  251. package/dist/modules/mcp/helpers.js +0 -75
  252. package/dist/modules/mcp/resources/glossary/binding.js +0 -73
  253. package/dist/modules/mcp/resources/glossary/collection.js +0 -76
  254. package/dist/modules/mcp/resources/glossary/displayMode.js +0 -50
  255. package/dist/modules/mcp/resources/glossary/element.js +0 -68
  256. package/dist/modules/mcp/resources/glossary/environment.js +0 -48
  257. package/dist/modules/mcp/resources/glossary/interaction.js +0 -62
  258. package/dist/modules/mcp/resources/glossary/page.js +0 -70
  259. package/dist/modules/mcp/resources/glossary/plugin.js +0 -96
  260. package/dist/modules/mcp/resources/glossary/resource.js +0 -75
  261. package/dist/modules/mcp/resources/glossary/schema.js +0 -69
  262. package/dist/modules/mcp/resources/glossary/schemaVariable.js +0 -60
  263. package/dist/modules/mcp/resources/glossary/segment.js +0 -59
  264. package/dist/modules/mcp/resources/glossary/space.js +0 -73
  265. package/dist/modules/mcp/resources/glossary/style.js +0 -81
  266. package/dist/modules/mcp/resources/glossary/styleSelector.js +0 -77
  267. package/dist/modules/mcp/resources/glossary/styleVariable.js +0 -72
  268. package/dist/modules/mcp/resources/index.js +0 -71
  269. package/dist/modules/mcp/resources/workflows/data.js +0 -49
  270. package/dist/modules/mcp/resources/workflows/elements.js +0 -53
  271. package/dist/modules/mcp/resources/workflows/segments.js +0 -55
  272. package/dist/modules/mcp/resources/workflows/styles.js +0 -91
  273. package/dist/modules/mcp/tools/collections/createCollection.js +0 -25
  274. package/dist/modules/mcp/tools/collections/createCollectionRecord.js +0 -27
  275. package/dist/modules/mcp/tools/collections/deleteCollection.js +0 -16
  276. package/dist/modules/mcp/tools/collections/deleteCollectionRecord.js +0 -16
  277. package/dist/modules/mcp/tools/collections/getCollection.js +0 -21
  278. package/dist/modules/mcp/tools/collections/getCollectionRecord.js +0 -25
  279. package/dist/modules/mcp/tools/collections/getCollectionRecords.js +0 -29
  280. package/dist/modules/mcp/tools/collections/getCollections.js +0 -19
  281. package/dist/modules/mcp/tools/collections/updateCollection.js +0 -28
  282. package/dist/modules/mcp/tools/collections/updateCollectionRecord.js +0 -31
  283. package/dist/modules/mcp/tools/docs/listResources.js +0 -16
  284. package/dist/modules/mcp/tools/docs/readResource.js +0 -23
  285. package/dist/modules/mcp/tools/plugins/addPlugin.js +0 -24
  286. package/dist/modules/mcp/tools/plugins/listPlugins.js +0 -20
  287. package/dist/modules/mcp/tools/plugins/removePlugin.js +0 -16
  288. package/dist/modules/mcp/tools/plugins/updatePlugin.js +0 -23
  289. package/dist/modules/mcp/tools/resources/addResource.js +0 -33
  290. package/dist/modules/mcp/tools/resources/getResource.js +0 -29
  291. package/dist/modules/mcp/tools/resources/getResources.js +0 -27
  292. package/dist/modules/mcp/tools/resources/moveResource.js +0 -30
  293. package/dist/modules/mcp/tools/resources/removeResource.js +0 -19
  294. package/dist/modules/mcp/tools/segment/createSegment.js +0 -27
  295. package/dist/modules/mcp/tools/segment/deleteSegment.js +0 -16
  296. package/dist/modules/mcp/tools/segment/getSegment.js +0 -19
  297. package/dist/modules/mcp/tools/segment/getSegments.js +0 -27
  298. package/dist/modules/mcp/tools/segment/schema/elements/createSegmentElement.js +0 -24
  299. package/dist/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.js +0 -19
  300. package/dist/modules/mcp/tools/segment/schema/elements/moveSegmentElement.js +0 -28
  301. package/dist/modules/mcp/tools/segment/schema/elements/updateSegmentElement.js +0 -23
  302. package/dist/modules/mcp/tools/segment/schema/variables/createSegmentVariable.js +0 -41
  303. package/dist/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.js +0 -19
  304. package/dist/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.js +0 -41
  305. package/dist/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.js +0 -34
  306. package/dist/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.js +0 -21
  307. package/dist/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.js +0 -34
  308. package/dist/modules/mcp/tools/segment/updateSegment.js +0 -30
  309. package/dist/modules/mcp/tools/space/schema/applyPreview.js +0 -33
  310. package/dist/modules/mcp/tools/space/schema/elements/cloneElement.js +0 -34
  311. package/dist/modules/mcp/tools/space/schema/elements/createElement.js +0 -50
  312. package/dist/modules/mcp/tools/space/schema/elements/deleteElement.js +0 -16
  313. package/dist/modules/mcp/tools/space/schema/elements/getElement.js +0 -17
  314. package/dist/modules/mcp/tools/space/schema/elements/getElements.js +0 -21
  315. package/dist/modules/mcp/tools/space/schema/elements/listElements.js +0 -28
  316. package/dist/modules/mcp/tools/space/schema/elements/moveElement.js +0 -27
  317. package/dist/modules/mcp/tools/space/schema/elements/updateElement.js +0 -49
  318. package/dist/modules/mcp/tools/space/schema/getSpaceSettings.js +0 -46
  319. package/dist/modules/mcp/tools/space/schema/pageFolders/createPageFolder.js +0 -24
  320. package/dist/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.js +0 -16
  321. package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolder.js +0 -17
  322. package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolders.js +0 -17
  323. package/dist/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.js +0 -28
  324. package/dist/modules/mcp/tools/space/schema/pages/createPage.js +0 -37
  325. package/dist/modules/mcp/tools/space/schema/pages/deletePage.js +0 -16
  326. package/dist/modules/mcp/tools/space/schema/pages/getPage.js +0 -28
  327. package/dist/modules/mcp/tools/space/schema/pages/getPageBySlug.js +0 -17
  328. package/dist/modules/mcp/tools/space/schema/pages/getPages.js +0 -17
  329. package/dist/modules/mcp/tools/space/schema/pages/updatePage.js +0 -25
  330. package/dist/modules/mcp/tools/space/schema/schemas.js +0 -53
  331. package/dist/modules/mcp/tools/space/schema/updateSpaceSettings.js +0 -23
  332. package/dist/modules/mcp/tools/space/schema/variables/createVariable.js +0 -38
  333. package/dist/modules/mcp/tools/space/schema/variables/deleteVariable.js +0 -16
  334. package/dist/modules/mcp/tools/space/schema/variables/getVariable.js +0 -17
  335. package/dist/modules/mcp/tools/space/schema/variables/getVariables.js +0 -17
  336. package/dist/modules/mcp/tools/space/schema/variables/updateVariable.js +0 -38
  337. package/dist/modules/mcp/tools/space/style/selectors/createStyleSelector.js +0 -37
  338. package/dist/modules/mcp/tools/space/style/selectors/deleteStyleSelector.js +0 -24
  339. package/dist/modules/mcp/tools/space/style/selectors/getStyleSelectors.js +0 -20
  340. package/dist/modules/mcp/tools/space/style/selectors/updateStyleSelector.js +0 -37
  341. package/dist/modules/mcp/tools/space/style/variables/createStyleVariable.js +0 -33
  342. package/dist/modules/mcp/tools/space/style/variables/deleteStyleVariable.js +0 -20
  343. package/dist/modules/mcp/tools/space/style/variables/getStyleVariable.js +0 -19
  344. package/dist/modules/mcp/tools/space/style/variables/getStyleVariables.js +0 -16
  345. package/dist/modules/mcp/tools/space/style/variables/updateStyleVariable.js +0 -33
  346. package/dist/package.js +0 -77
  347. package/dist/package.json.d.ts +0 -67
  348. package/dist/src/core/requestHandler.d.ts +0 -5
  349. package/dist/src/modules/mcp/helpers.d.ts +0 -9
  350. package/dist/src/modules/mcp/resources/glossary/binding.d.ts +0 -7
  351. package/dist/src/modules/mcp/resources/glossary/collection.d.ts +0 -7
  352. package/dist/src/modules/mcp/resources/glossary/displayMode.d.ts +0 -7
  353. package/dist/src/modules/mcp/resources/glossary/element.d.ts +0 -7
  354. package/dist/src/modules/mcp/resources/glossary/environment.d.ts +0 -7
  355. package/dist/src/modules/mcp/resources/glossary/interaction.d.ts +0 -7
  356. package/dist/src/modules/mcp/resources/glossary/page.d.ts +0 -7
  357. package/dist/src/modules/mcp/resources/glossary/plugin.d.ts +0 -7
  358. package/dist/src/modules/mcp/resources/glossary/resource.d.ts +0 -7
  359. package/dist/src/modules/mcp/resources/glossary/schema.d.ts +0 -7
  360. package/dist/src/modules/mcp/resources/glossary/schemaVariable.d.ts +0 -7
  361. package/dist/src/modules/mcp/resources/glossary/segment.d.ts +0 -7
  362. package/dist/src/modules/mcp/resources/glossary/space.d.ts +0 -7
  363. package/dist/src/modules/mcp/resources/glossary/style.d.ts +0 -7
  364. package/dist/src/modules/mcp/resources/glossary/styleSelector.d.ts +0 -7
  365. package/dist/src/modules/mcp/resources/glossary/styleVariable.d.ts +0 -7
  366. package/dist/src/modules/mcp/resources/workflows/data.d.ts +0 -7
  367. package/dist/src/modules/mcp/resources/workflows/elements.d.ts +0 -7
  368. package/dist/src/modules/mcp/resources/workflows/segments.d.ts +0 -7
  369. package/dist/src/modules/mcp/resources/workflows/styles.d.ts +0 -7
  370. package/dist/src/modules/mcp/tools/collections/createCollection.d.ts +0 -3
  371. package/dist/src/modules/mcp/tools/collections/createCollectionRecord.d.ts +0 -3
  372. package/dist/src/modules/mcp/tools/collections/deleteCollection.d.ts +0 -3
  373. package/dist/src/modules/mcp/tools/collections/deleteCollectionRecord.d.ts +0 -3
  374. package/dist/src/modules/mcp/tools/collections/getCollection.d.ts +0 -3
  375. package/dist/src/modules/mcp/tools/collections/getCollectionRecord.d.ts +0 -3
  376. package/dist/src/modules/mcp/tools/collections/getCollectionRecords.d.ts +0 -3
  377. package/dist/src/modules/mcp/tools/collections/getCollections.d.ts +0 -3
  378. package/dist/src/modules/mcp/tools/collections/index.d.ts +0 -10
  379. package/dist/src/modules/mcp/tools/collections/updateCollection.d.ts +0 -3
  380. package/dist/src/modules/mcp/tools/collections/updateCollectionRecord.d.ts +0 -3
  381. package/dist/src/modules/mcp/tools/docs/index.d.ts +0 -2
  382. package/dist/src/modules/mcp/tools/docs/listResources.d.ts +0 -3
  383. package/dist/src/modules/mcp/tools/docs/readResource.d.ts +0 -3
  384. package/dist/src/modules/mcp/tools/plugins/addPlugin.d.ts +0 -3
  385. package/dist/src/modules/mcp/tools/plugins/index.d.ts +0 -5
  386. package/dist/src/modules/mcp/tools/plugins/listPlugins.d.ts +0 -3
  387. package/dist/src/modules/mcp/tools/plugins/removePlugin.d.ts +0 -3
  388. package/dist/src/modules/mcp/tools/plugins/updatePlugin.d.ts +0 -3
  389. package/dist/src/modules/mcp/tools/resources/addResource.d.ts +0 -3
  390. package/dist/src/modules/mcp/tools/resources/getResource.d.ts +0 -3
  391. package/dist/src/modules/mcp/tools/resources/getResources.d.ts +0 -3
  392. package/dist/src/modules/mcp/tools/resources/index.d.ts +0 -6
  393. package/dist/src/modules/mcp/tools/resources/moveResource.d.ts +0 -3
  394. package/dist/src/modules/mcp/tools/resources/removeResource.d.ts +0 -3
  395. package/dist/src/modules/mcp/tools/segment/createSegment.d.ts +0 -3
  396. package/dist/src/modules/mcp/tools/segment/deleteSegment.d.ts +0 -3
  397. package/dist/src/modules/mcp/tools/segment/getSegment.d.ts +0 -3
  398. package/dist/src/modules/mcp/tools/segment/getSegments.d.ts +0 -3
  399. package/dist/src/modules/mcp/tools/segment/index.d.ts +0 -8
  400. package/dist/src/modules/mcp/tools/segment/schema/elements/createSegmentElement.d.ts +0 -3
  401. package/dist/src/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.d.ts +0 -3
  402. package/dist/src/modules/mcp/tools/segment/schema/elements/index.d.ts +0 -5
  403. package/dist/src/modules/mcp/tools/segment/schema/elements/moveSegmentElement.d.ts +0 -3
  404. package/dist/src/modules/mcp/tools/segment/schema/elements/updateSegmentElement.d.ts +0 -3
  405. package/dist/src/modules/mcp/tools/segment/schema/index.d.ts +0 -2
  406. package/dist/src/modules/mcp/tools/segment/schema/variables/createSegmentVariable.d.ts +0 -3
  407. package/dist/src/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.d.ts +0 -3
  408. package/dist/src/modules/mcp/tools/segment/schema/variables/index.d.ts +0 -4
  409. package/dist/src/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.d.ts +0 -3
  410. package/dist/src/modules/mcp/tools/segment/segment.test.d.ts +0 -1
  411. package/dist/src/modules/mcp/tools/segment/style/index.d.ts +0 -1
  412. package/dist/src/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.d.ts +0 -3
  413. package/dist/src/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.d.ts +0 -3
  414. package/dist/src/modules/mcp/tools/segment/style/variables/index.d.ts +0 -4
  415. package/dist/src/modules/mcp/tools/segment/style/variables/segmentStyleVariables.test.d.ts +0 -1
  416. package/dist/src/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.d.ts +0 -3
  417. package/dist/src/modules/mcp/tools/segment/updateSegment.d.ts +0 -3
  418. package/dist/src/modules/mcp/tools/space/index.d.ts +0 -2
  419. package/dist/src/modules/mcp/tools/space/schema/applyPreview.d.ts +0 -3
  420. package/dist/src/modules/mcp/tools/space/schema/elements/cloneElement.d.ts +0 -3
  421. package/dist/src/modules/mcp/tools/space/schema/elements/createElement.d.ts +0 -3
  422. package/dist/src/modules/mcp/tools/space/schema/elements/deleteElement.d.ts +0 -3
  423. package/dist/src/modules/mcp/tools/space/schema/elements/elements.test.d.ts +0 -1
  424. package/dist/src/modules/mcp/tools/space/schema/elements/getElement.d.ts +0 -3
  425. package/dist/src/modules/mcp/tools/space/schema/elements/getElements.d.ts +0 -3
  426. package/dist/src/modules/mcp/tools/space/schema/elements/index.d.ts +0 -9
  427. package/dist/src/modules/mcp/tools/space/schema/elements/listElements.d.ts +0 -3
  428. package/dist/src/modules/mcp/tools/space/schema/elements/moveElement.d.ts +0 -3
  429. package/dist/src/modules/mcp/tools/space/schema/elements/updateElement.d.ts +0 -3
  430. package/dist/src/modules/mcp/tools/space/schema/getSpaceSettings.d.ts +0 -3
  431. package/dist/src/modules/mcp/tools/space/schema/index.d.ts +0 -8
  432. package/dist/src/modules/mcp/tools/space/schema/pageFolders/createPageFolder.d.ts +0 -3
  433. package/dist/src/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.d.ts +0 -3
  434. package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolder.d.ts +0 -3
  435. package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolders.d.ts +0 -3
  436. package/dist/src/modules/mcp/tools/space/schema/pageFolders/index.d.ts +0 -6
  437. package/dist/src/modules/mcp/tools/space/schema/pageFolders/pageFolders.test.d.ts +0 -1
  438. package/dist/src/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.d.ts +0 -3
  439. package/dist/src/modules/mcp/tools/space/schema/pages/createPage.d.ts +0 -3
  440. package/dist/src/modules/mcp/tools/space/schema/pages/deletePage.d.ts +0 -3
  441. package/dist/src/modules/mcp/tools/space/schema/pages/getPage.d.ts +0 -3
  442. package/dist/src/modules/mcp/tools/space/schema/pages/getPageBySlug.d.ts +0 -3
  443. package/dist/src/modules/mcp/tools/space/schema/pages/getPages.d.ts +0 -3
  444. package/dist/src/modules/mcp/tools/space/schema/pages/index.d.ts +0 -7
  445. package/dist/src/modules/mcp/tools/space/schema/pages/pages.test.d.ts +0 -1
  446. package/dist/src/modules/mcp/tools/space/schema/pages/updatePage.d.ts +0 -3
  447. package/dist/src/modules/mcp/tools/space/schema/schemas.d.ts +0 -66
  448. package/dist/src/modules/mcp/tools/space/schema/updateSpaceSettings.d.ts +0 -3
  449. package/dist/src/modules/mcp/tools/space/schema/variables/createVariable.d.ts +0 -3
  450. package/dist/src/modules/mcp/tools/space/schema/variables/deleteVariable.d.ts +0 -3
  451. package/dist/src/modules/mcp/tools/space/schema/variables/getVariable.d.ts +0 -3
  452. package/dist/src/modules/mcp/tools/space/schema/variables/getVariables.d.ts +0 -3
  453. package/dist/src/modules/mcp/tools/space/schema/variables/index.d.ts +0 -6
  454. package/dist/src/modules/mcp/tools/space/schema/variables/updateVariable.d.ts +0 -3
  455. package/dist/src/modules/mcp/tools/space/schema/variables/variables.test.d.ts +0 -1
  456. package/dist/src/modules/mcp/tools/space/space.test.d.ts +0 -1
  457. package/dist/src/modules/mcp/tools/space/style/index.d.ts +0 -2
  458. package/dist/src/modules/mcp/tools/space/style/selectors/createStyleSelector.d.ts +0 -3
  459. package/dist/src/modules/mcp/tools/space/style/selectors/deleteStyleSelector.d.ts +0 -3
  460. package/dist/src/modules/mcp/tools/space/style/selectors/getStyleSelectors.d.ts +0 -3
  461. package/dist/src/modules/mcp/tools/space/style/selectors/index.d.ts +0 -5
  462. package/dist/src/modules/mcp/tools/space/style/selectors/styleSelectors.test.d.ts +0 -1
  463. package/dist/src/modules/mcp/tools/space/style/selectors/updateStyleSelector.d.ts +0 -3
  464. package/dist/src/modules/mcp/tools/space/style/variables/createStyleVariable.d.ts +0 -3
  465. package/dist/src/modules/mcp/tools/space/style/variables/deleteStyleVariable.d.ts +0 -3
  466. package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariable.d.ts +0 -3
  467. package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariables.d.ts +0 -3
  468. package/dist/src/modules/mcp/tools/space/style/variables/index.d.ts +0 -6
  469. package/dist/src/modules/mcp/tools/space/style/variables/styleVariables.test.d.ts +0 -1
  470. package/dist/src/modules/mcp/tools/space/style/variables/updateStyleVariable.d.ts +0 -3
  471. /package/dist/src/{modules/mcp/helpers.test.d.ts → core/server/mcpServer.test.d.ts} +0 -0
  472. /package/dist/src/modules/{mcp/tools/collections/collections.test.d.ts → ai/toolkit.test.d.ts} +0 -0
  473. /package/dist/src/modules/mcp/{tools/plugins/plugins.test.d.ts → catalogs/builtinTransformers.test.d.ts} +0 -0
  474. /package/dist/src/modules/mcp/{tools/resources/resources.test.d.ts → helpers/log.test.d.ts} +0 -0
  475. /package/dist/src/modules/mcp/{tools/segment/schema/elements/segmentElements.test.d.ts → mcp.bench.d.ts} +0 -0
  476. /package/dist/src/modules/mcp/{tools/segment/schema/variables/segmentVariables.test.d.ts → mcp.test.d.ts} +0 -0
@@ -0,0 +1,47 @@
1
+ import { compoundLonghands, expandShorthand, isCssProperty, suggestCssProperty } from "../../../catalogs/cssCatalog.js";
2
+ import { checkStyleVarRefs, checkVarRefs, warnOnce } from "./context.js";
3
+ //#region src/modules/mcp/tools/shared/validator/css.ts
4
+ var checkCss = (css, path, ctx) => {
5
+ if (!css) return;
6
+ const declared = {};
7
+ for (const [key, value] of Object.entries(css)) if (value !== null) declared[key] = value;
8
+ for (const [key, value] of Object.entries(expandShorthand(declared))) {
9
+ const longhands = compoundLonghands(key);
10
+ if (longhands) if (!isCssProperty(key)) ctx.errors.push({
11
+ path: `${path}.${key}`,
12
+ message: `Compound CSS shorthand "${key}" is not supported — write its atomic longhand properties`,
13
+ hint: `Use: ${longhands.join(", ")}. (Note: flex layout is display + flex-direction + flex-grow/shrink/basis, not "flex".)`,
14
+ validValues: longhands
15
+ });
16
+ else warnOnce(ctx, `CSS shorthand "${key}" at ${path}.${key} is accepted but stored as one compound value. Plitzi styling is atomic — prefer the longhands (${longhands.join(", ")}) so a breakpoint/state/variant can override each property independently.`);
17
+ else if (!isCssProperty(key)) {
18
+ const suggestion = suggestCssProperty(key);
19
+ ctx.errors.push({
20
+ path: `${path}.${key}`,
21
+ message: `Unknown CSS property "${key}"`,
22
+ hint: suggestion ? `Use the kebab-case key "${suggestion}"` : "Read plitzi://css-properties for the valid property keys"
23
+ });
24
+ }
25
+ if (typeof value === "string") {
26
+ checkStyleVarRefs(value, `${path}.${key}`, ctx);
27
+ checkVarRefs(value, `${path}.${key}`, ctx);
28
+ }
29
+ }
30
+ };
31
+ var checkSlotCss = (slot, path, ctx) => {
32
+ checkCss(slot.desktop, `${path}.desktop`, ctx);
33
+ checkCss(slot.tablet, `${path}.tablet`, ctx);
34
+ checkCss(slot.mobile, `${path}.mobile`, ctx);
35
+ for (const [state, dm] of Object.entries(slot.states ?? {})) {
36
+ checkCss(dm.desktop, `${path}.states.${state}.desktop`, ctx);
37
+ checkCss(dm.tablet, `${path}.states.${state}.tablet`, ctx);
38
+ checkCss(dm.mobile, `${path}.states.${state}.mobile`, ctx);
39
+ }
40
+ for (const [name, dm] of Object.entries(slot.variants ?? {})) {
41
+ checkCss(dm.desktop, `${path}.variants.${name}.desktop`, ctx);
42
+ checkCss(dm.tablet, `${path}.variants.${name}.tablet`, ctx);
43
+ checkCss(dm.mobile, `${path}.variants.${name}.mobile`, ctx);
44
+ }
45
+ };
46
+ //#endregion
47
+ export { checkCss, checkSlotCss };
@@ -0,0 +1,55 @@
1
+ import { definitionVariantNames } from "../../operations/style/translator.js";
2
+ import { RAW_CODE_TYPES, checkVarRefs, warnOnce } from "./context.js";
3
+ import { checkIdRef } from "./refs.js";
4
+ //#region src/modules/mcp/tools/shared/validator/elements.ts
5
+ var checkTypeProps = (type, props, path, ctx) => {
6
+ if (!props || RAW_CODE_TYPES.has(type)) return;
7
+ const meta = ctx.typeMeta.get(type);
8
+ const known = meta && meta.attributes.size > 0 ? meta.attributes : ctx.typeProps.get(type);
9
+ if (!known || known.size === 0) return;
10
+ const strict = meta?.custom === false;
11
+ for (const key of Object.keys(props)) {
12
+ if (key === "subType" || known.has(key)) continue;
13
+ if (strict) ctx.errors.push({
14
+ path,
15
+ message: `Type "${type}" has no attribute "${key}"`,
16
+ hint: `Valid attributes: ${[...known].sort().join(", ")}`,
17
+ validValues: [...known].sort()
18
+ });
19
+ else warnOnce(ctx, `Type "${type}" has no observed prop "${key}" at ${path} (known: ${[...known].sort().join(", ")}). It may still be valid — verify against plitzi://types.`);
20
+ }
21
+ };
22
+ var checkVariantApplication = (initialState, path, ctx) => {
23
+ for (const [cls, selectors] of Object.entries(initialState?.styleVariant ?? {})) {
24
+ const declared = definitionVariantNames(ctx.style, cls);
25
+ const batch = ctx.batchVariants.get(cls);
26
+ for (const [selector, variant] of Object.entries(selectors)) {
27
+ const names = Array.isArray(variant) ? variant : [variant];
28
+ for (const name of names) if (!((declared?.[selector]?.includes(name) ?? false) || (batch?.has(name) ?? false))) warnOnce(ctx, `Element applies variant "${name}" on class "${cls}" (${selector}) at ${path}, but that class defines no such variant${declared ? ` (declares: ${Object.entries(declared).map(([s, v]) => `${s}:${v.join("/")}`).join(", ")})` : ""}. Create it via upsertDefinition/patchDefinition "variants", or fix the name.`);
29
+ }
30
+ }
31
+ };
32
+ var checkElementProps = (element, path, ctx) => {
33
+ if (!element.props || RAW_CODE_TYPES.has(element.type)) return;
34
+ for (const [key, value] of Object.entries(element.props)) if (typeof value === "string") checkVarRefs(value, `${path}.props.${key}`, ctx);
35
+ checkTypeProps(element.type, element.props, path, ctx);
36
+ };
37
+ var checkElementInput = (element, path, ctx, seen) => {
38
+ checkIdRef(element.ref, `${path}.ref`, ctx);
39
+ if (seen.has(element.ref)) ctx.errors.push({
40
+ path: `${path}.ref`,
41
+ message: `Duplicate ref "${element.ref}" in this batch`,
42
+ hint: "Use a unique ref"
43
+ });
44
+ seen.add(element.ref);
45
+ if (!element.type) ctx.errors.push({
46
+ path: `${path}.type`,
47
+ message: "Element type is required",
48
+ hint: "Read plitzi://types for known types"
49
+ });
50
+ else if (!ctx.knownTypes.has(element.type)) ctx.warnings.push(`Type "${element.type}" was not seen in this space; ensure a plugin provides it (${path}.type).`);
51
+ checkElementProps(element, path, ctx);
52
+ element.children?.forEach((child, i) => checkElementInput(child, `${path}.children[${i}]`, ctx, seen));
53
+ };
54
+ //#endregion
55
+ export { checkElementInput, checkTypeProps, checkVariantApplication };
@@ -0,0 +1,226 @@
1
+ import { observedDataSources, observedInteractionActions } from "../../../catalogs/observed.js";
2
+ import { buildTypeRegistry } from "../../../catalogs/registry.js";
3
+ import { findElementByRef, findFolderByRef, findPageByRef, folderAncestorIds, getPageElements, pageFoldersOf, pageRefOf, resolveRef, routeParamNames } from "../../../helpers/space.js";
4
+ import { MAX_OPS } from "../../operations/index.js";
5
+ import { batchDeclaredFolders, batchDeclaredPages, batchDeclaredVariants, batchDeclaredVars } from "./batch.js";
6
+ import { checkObservedName, checkVarRefs, warnOnce } from "./context.js";
7
+ import { checkBindingSourceScope, checkBindingTarget, checkBindingTransformers } from "./bindings.js";
8
+ import { checkSlotCss } from "./css.js";
9
+ import { checkRef } from "./refs.js";
10
+ import { checkElementInput, checkTypeProps, checkVariantApplication } from "./elements.js";
11
+ import { checkInteractionNode } from "./interactions.js";
12
+ //#region src/modules/mcp/tools/shared/validator/index.ts
13
+ var STYLE_CATEGORIES = [
14
+ "color",
15
+ "spacing",
16
+ "shadow",
17
+ "custom"
18
+ ];
19
+ var buildTypeMeta = (catalog) => {
20
+ const meta = /* @__PURE__ */ new Map();
21
+ for (const [type, entry] of Object.entries(catalog ?? {})) {
22
+ const bindingsAllowed = entry.bindingsAllowed;
23
+ meta.set(type, {
24
+ attributes: new Set(entry.attributes ?? []),
25
+ styleSelectors: new Set(entry.styleSelectors ?? []),
26
+ custom: entry.custom ?? false,
27
+ ...bindingsAllowed ? { bindingTargets: {
28
+ attributes: new Set(bindingsAllowed.attributes ?? []),
29
+ initialState: new Set(bindingsAllowed.initialState ?? [])
30
+ } } : {}
31
+ });
32
+ }
33
+ return meta;
34
+ };
35
+ /** The shared validation context, derived from a space (+ the batch's ops, for batch-declared names). Extracted so
36
+ * the post-apply resource audit (auditResources) can run the same checks against the resulting draft. */
37
+ var buildValidationCtx = (space, ops) => {
38
+ const registry = buildTypeRegistry(space.schema, space.catalog);
39
+ return {
40
+ errors: [],
41
+ warnings: [],
42
+ warned: /* @__PURE__ */ new Set(),
43
+ knownTypes: new Set(Object.keys(registry.types)),
44
+ typeProps: new Map(Object.entries(registry.types).map(([type, info]) => [type, new Set(Object.keys(info.props))])),
45
+ typeMeta: buildTypeMeta(space.catalog),
46
+ elementType: (ref) => (findElementByRef(space.schema, ref) ?? findPageByRef(space.schema, ref))?.definition.type,
47
+ schemaVars: /* @__PURE__ */ new Set([
48
+ ...space.schema.variables.map((v) => v.name),
49
+ ...routeParamNames(space.schema),
50
+ ...batchDeclaredVars(ops)
51
+ ]),
52
+ styleVars: new Set(Object.values(space.style.variables).flatMap((group) => Object.keys(group))),
53
+ style: space.style,
54
+ batchVariants: batchDeclaredVariants(ops),
55
+ observedActions: observedInteractionActions(space.schema),
56
+ observedSources: observedDataSources(space.schema)
57
+ };
58
+ };
59
+ var validateOperations = (space, ops) => {
60
+ const batchPages = batchDeclaredPages(ops);
61
+ const batchFolders = batchDeclaredFolders(ops);
62
+ const folderRefs = () => pageFoldersOf(space.schema).map((f) => f.id);
63
+ const ctx = buildValidationCtx(space, ops);
64
+ if (ops.length > 1e3) ctx.errors.push({
65
+ path: "operations",
66
+ message: `Batch has ${ops.length} operations (max ${MAX_OPS})`,
67
+ hint: `Split into batches of at most ${MAX_OPS}`
68
+ });
69
+ ops.forEach((op, i) => {
70
+ const base = `operations[${i}]`;
71
+ if ((op.type === "upsertElement" || op.type === "patchElement" || op.type === "deleteElement" || op.type === "moveElement" || op.type === "upsertBinding" || op.type === "patchBinding" || op.type === "deleteBinding" || op.type === "upsertInteractionFlow" || op.type === "patchInteractionNode" || op.type === "deleteInteraction") && op.pageRef) {
72
+ if (!findPageByRef(space.schema, op.pageRef) && !batchPages.has(op.pageRef)) {
73
+ const validRefs = getPageElements(space.schema).map(pageRefOf);
74
+ ctx.errors.push({
75
+ path: `${base}.pageRef`,
76
+ message: `Page "${op.pageRef}" does not exist`,
77
+ hint: "Use an existing page ref, or create it with upsertPage earlier in the same batch",
78
+ validValues: validRefs
79
+ });
80
+ }
81
+ }
82
+ switch (op.type) {
83
+ case "upsertElement":
84
+ checkElementInput(op.element, `${base}.element`, ctx, /* @__PURE__ */ new Set());
85
+ checkVariantApplication(op.element.initialState, `${base}.element.initialState`, ctx);
86
+ break;
87
+ case "patchElement": {
88
+ checkRef(op.ref, `${base}.ref`, ctx);
89
+ const page = findPageByRef(space.schema, op.pageRef);
90
+ const target = page ? resolveRef(space.schema, page, op.ref) : void 0;
91
+ if (op.props) {
92
+ for (const [key, value] of Object.entries(op.props)) if (typeof value === "string") checkVarRefs(value, `${base}.props.${key}`, ctx);
93
+ if (target && target.id !== page?.id) checkTypeProps(target.definition.type, op.props, base, ctx);
94
+ }
95
+ checkVariantApplication(op.initialState, `${base}.initialState`, ctx);
96
+ break;
97
+ }
98
+ case "upsertDefinition":
99
+ case "patchDefinition": {
100
+ const { type, ref, slots, ...slot } = op;
101
+ checkRef(ref, `${base}.ref`, ctx);
102
+ checkSlotCss(slot, base, ctx);
103
+ for (const [slotName, slotDef] of Object.entries(slots ?? {})) checkSlotCss(slotDef, `${base}.slots.${slotName}`, ctx);
104
+ break;
105
+ }
106
+ case "upsertGlobalStyle":
107
+ case "patchGlobalStyle": {
108
+ const { type, componentType, slots, ...slot } = op;
109
+ checkRef(componentType, `${base}.componentType`, ctx);
110
+ checkSlotCss(slot, base, ctx);
111
+ for (const [slotName, slotDef] of Object.entries(slots ?? {})) checkSlotCss(slotDef, `${base}.slots.${slotName}`, ctx);
112
+ break;
113
+ }
114
+ case "deleteGlobalStyle":
115
+ checkRef(op.componentType, `${base}.componentType`, ctx);
116
+ break;
117
+ case "upsertPage":
118
+ checkRef(op.ref, `${base}.ref`, ctx);
119
+ if (op.slug === void 0 && !findPageByRef(space.schema, op.ref)) warnOnce(ctx, `Page "${op.ref}" is being created without a slug. Set a slug for a clean, stable URL (good practice); the page ref is used as a fallback.`);
120
+ if (typeof op.folder === "string" && op.folder !== "") {
121
+ if (!findFolderByRef(space.schema, op.folder) && !batchFolders.has(op.folder)) ctx.errors.push({
122
+ path: `${base}.folder`,
123
+ message: `Folder "${op.folder}" does not exist`,
124
+ hint: "Create it with upsertFolder earlier in the same batch, or read plitzi://folders for valid refs",
125
+ validValues: folderRefs()
126
+ });
127
+ }
128
+ break;
129
+ case "upsertFolder":
130
+ checkRef(op.ref, `${base}.ref`, ctx);
131
+ if (typeof op.parentId === "string") {
132
+ checkRef(op.parentId, `${base}.parentId`, ctx);
133
+ const parent = findFolderByRef(space.schema, op.parentId);
134
+ if (!parent && !batchFolders.has(op.parentId)) ctx.errors.push({
135
+ path: `${base}.parentId`,
136
+ message: `Parent folder "${op.parentId}" does not exist`,
137
+ hint: "Create the parent with upsertFolder first, or read plitzi://folders for valid refs",
138
+ validValues: folderRefs()
139
+ });
140
+ const selfId = findFolderByRef(space.schema, op.ref)?.id ?? op.ref;
141
+ if ((parent?.id ?? op.parentId) === selfId || parent && folderAncestorIds(pageFoldersOf(space.schema), parent.id).includes(selfId)) ctx.errors.push({
142
+ path: `${base}.parentId`,
143
+ message: `Folder "${op.ref}" cannot be nested under itself or one of its descendants`,
144
+ hint: "Choose a parent that is not this folder or below it"
145
+ });
146
+ }
147
+ break;
148
+ case "deleteDefinition":
149
+ case "deleteFolder":
150
+ case "deletePage":
151
+ case "upsertVariable":
152
+ case "deleteVariable":
153
+ checkRef("ref" in op ? op.ref : op.name, `${base}.${"ref" in op ? "ref" : "name"}`, ctx);
154
+ break;
155
+ case "upsertStyleVariable":
156
+ case "deleteStyleVariable":
157
+ if (!STYLE_CATEGORIES.includes(op.category)) ctx.errors.push({
158
+ path: `${base}.category`,
159
+ message: `Unknown style-variable category "${op.category}"`,
160
+ hint: "Use one of the valid categories",
161
+ validValues: STYLE_CATEGORIES
162
+ });
163
+ break;
164
+ case "upsertBinding":
165
+ checkRef(op.ref, `${base}.ref`, ctx);
166
+ checkObservedName(op.binding.source, ctx.observedSources, "Data source", "plitzi://data-sources", `${base}.binding.source`, ctx);
167
+ checkBindingTarget(op.ref, op.category, op.binding.to, `${base}.binding.to`, ctx);
168
+ checkBindingSourceScope(space, ctx, op.ref, op.binding.source, `${base}.binding.source`);
169
+ checkBindingTransformers(op.binding.transformers, `${base}.binding.transformers`, ctx);
170
+ break;
171
+ case "patchBinding":
172
+ checkRef(op.ref, `${base}.ref`, ctx);
173
+ checkObservedName(op.source, ctx.observedSources, "Data source", "plitzi://data-sources", `${base}.source`, ctx);
174
+ checkBindingTarget(op.ref, op.category, op.to, `${base}.to`, ctx);
175
+ if (op.source !== void 0) checkBindingSourceScope(space, ctx, op.ref, op.source, `${base}.source`);
176
+ checkBindingTransformers(op.transformers, `${base}.transformers`, ctx);
177
+ break;
178
+ case "deleteBinding":
179
+ checkRef(op.ref, `${base}.ref`, ctx);
180
+ break;
181
+ case "upsertInteractionFlow":
182
+ checkRef(op.ref, `${base}.ref`, ctx);
183
+ if (op.nodes[0] && op.nodes[0].nodeType !== "trigger") ctx.errors.push({
184
+ path: `${base}.nodes[0].nodeType`,
185
+ message: "The first node of a flow must be a trigger",
186
+ hint: "Put the trigger first; the callbacks/utilities that run after it follow in order"
187
+ });
188
+ op.nodes.forEach((node, n) => checkInteractionNode(node, `${base}.nodes[${n}]`, ctx, op.ref));
189
+ break;
190
+ case "patchInteractionNode": {
191
+ checkRef(op.ref, `${base}.ref`, ctx);
192
+ const existing = findElementByRef(space.schema, op.ref)?.definition.interactions?.[op.nodeId];
193
+ if (existing) checkInteractionNode({
194
+ id: existing.id,
195
+ title: op.title ?? existing.title,
196
+ nodeType: existing.type,
197
+ action: op.action ?? existing.action,
198
+ params: {
199
+ ...existing.params,
200
+ ...op.params ?? {}
201
+ },
202
+ enabled: op.enabled ?? existing.enabled,
203
+ elementId: op.elementId ?? existing.elementId ?? void 0
204
+ }, base, ctx, op.ref);
205
+ else checkObservedName(op.action, ctx.observedActions, "Interaction action", "plitzi://interactions", `${base}.action`, ctx);
206
+ break;
207
+ }
208
+ case "deleteInteraction":
209
+ checkRef(op.ref, `${base}.ref`, ctx);
210
+ if (Boolean(op.flowId) === Boolean(op.nodeId)) ctx.errors.push({
211
+ path: `${base}.nodeId`,
212
+ message: "Provide exactly one of flowId or nodeId",
213
+ hint: "flowId removes a whole flow; nodeId removes a single step"
214
+ });
215
+ break;
216
+ default: break;
217
+ }
218
+ });
219
+ return {
220
+ valid: ctx.errors.length === 0,
221
+ errors: ctx.errors,
222
+ warnings: ctx.warnings
223
+ };
224
+ };
225
+ //#endregion
226
+ export { buildValidationCtx, validateOperations };
@@ -0,0 +1,106 @@
1
+ import { hiddenParams, invalidParams, missingRequiredParams, reconcileParams } from "../../../catalogs/paramSpec.js";
2
+ import { getGlobalCallback } from "../../../catalogs/builtinCallbacks.js";
3
+ import { getElementCallback } from "../../../catalogs/builtinElementCallbacks.js";
4
+ import { getUtility } from "../../../catalogs/builtinUtilities.js";
5
+ import { NULLISH_ELEMENT_IDS } from "../../../helpers/interactions.js";
6
+ import { checkObservedName, warnOnce } from "./context.js";
7
+ //#region src/modules/mcp/tools/shared/validator/interactions.ts
8
+ var describeType = (type) => {
9
+ switch (type) {
10
+ case "boolean": return "a boolean";
11
+ case "number": return "a number";
12
+ case "select": return "one of its allowed values";
13
+ case "scalar": return "a string, number or boolean";
14
+ default: return "a string";
15
+ }
16
+ };
17
+ var checkParams = (label, action, params, spec, base, ctx) => {
18
+ const unknown = Object.keys(params).filter((key) => !(key in spec));
19
+ if (unknown.length > 0) warnOnce(ctx, `${label} "${action}" at ${base} got unknown param(s) ${unknown.map((k) => `"${k}"`).join(", ")} — these are dropped on apply. Valid params: ${Object.keys(spec).join(", ")}.`);
20
+ const effective = reconcileParams(params, spec, true);
21
+ const missing = missingRequiredParams(params, effective, spec);
22
+ if (missing.length > 0) warnOnce(ctx, `${label} "${action}" at ${base} is missing required param(s) ${missing.map((k) => `"${k}"`).join(", ")} — the step is malformed without them (see plitzi://interactions for what each does).`);
23
+ const hidden = hiddenParams(params, effective, spec);
24
+ if (hidden.length > 0) warnOnce(ctx, `${label} "${action}" at ${base}: param(s) ${hidden.map((k) => `"${k}"`).join(", ")} are ignored under the current params (they only apply when a companion param is set — see plitzi://interactions). Set the companion param or drop them.`);
25
+ for (const { key, expected, got, options } of invalidParams(params, effective, spec)) {
26
+ const detail = options ? ` Allowed values: ${options.join(", ")}.` : "";
27
+ ctx.errors.push({
28
+ path: `${base}.params.${key}`,
29
+ message: `${label} "${action}" at ${base}: param "${key}" must be ${describeType(expected)} but got ${got}.${detail}`,
30
+ hint: `Set "${key}" to ${describeType(expected)}.`,
31
+ ...options ? { validValues: options } : {}
32
+ });
33
+ }
34
+ };
35
+ var checkGlobalCallback = (node, base, ctx) => {
36
+ const builtin = getGlobalCallback(node.action);
37
+ if (!builtin) {
38
+ if (getUtility(node.action)) warnOnce(ctx, `"${node.action}" at ${base} is a utility, not a global callback — use nodeType "utility".`);
39
+ else if (getElementCallback(node.action)) warnOnce(ctx, `"${node.action}" at ${base} is an element callback, not a global callback — use nodeType "callback" and set elementId to the element it acts on.`);
40
+ return;
41
+ }
42
+ if (node.elementId !== void 0 && node.elementId !== builtin.source) warnOnce(ctx, `Global callback "${node.action}" at ${base} is registered on "${builtin.source}", not on "${node.elementId}". Omit elementId (the MCP sets "${builtin.source}") or set it to "${builtin.source}".`);
43
+ if (node.params && builtin.strictParams) checkParams("Global callback", node.action, node.params, builtin.params, base, ctx);
44
+ };
45
+ var checkSetStateKey = (node, base, ctx, hostRef) => {
46
+ const key = node.params?.key;
47
+ if (typeof key !== "string" || key === "") return;
48
+ const targetRef = typeof node.elementId === "string" && node.elementId !== "" ? node.elementId : hostRef;
49
+ const type = ctx.elementType(targetRef);
50
+ const meta = type ? ctx.typeMeta.get(type) : void 0;
51
+ if (!meta) return;
52
+ const state = node.params?.category === "state";
53
+ const validKeys = state ? /* @__PURE__ */ new Set(["visibility", ...[...meta.styleSelectors].map((selector) => `styleSelectors.${selector}`)]) : meta.attributes;
54
+ if (validKeys.size === 0 || validKeys.has(key)) return;
55
+ const kind = state ? "state" : "attribute";
56
+ const valid = [...validKeys].sort();
57
+ const detail = `Element setState at ${base} sets ${kind} "${key}" on type "${type}", which has no such ${kind} key`;
58
+ if (!meta.custom) ctx.errors.push({
59
+ path: base,
60
+ message: detail,
61
+ hint: `Use one of: ${valid.join(", ")}`,
62
+ validValues: valid
63
+ });
64
+ else warnOnce(ctx, `${detail} (${valid.join(", ")}). It may still be valid — verify against plitzi://types.`);
65
+ };
66
+ var checkElementCallback = (node, base, ctx, hostRef) => {
67
+ const builtin = getElementCallback(node.action);
68
+ if (!builtin) {
69
+ if (getUtility(node.action)) warnOnce(ctx, `"${node.action}" at ${base} is a utility, not an element callback — use nodeType "utility".`);
70
+ else {
71
+ const global = getGlobalCallback(node.action);
72
+ if (global) warnOnce(ctx, `"${node.action}" at ${base} is a global callback (source "${global.source}"), not an element callback — use nodeType "globalCallback" and omit elementId.`);
73
+ }
74
+ return;
75
+ }
76
+ if (node.params && builtin.strictParams) checkParams("Element callback", node.action, node.params, builtin.params, base, ctx);
77
+ if (node.action === "setState") checkSetStateKey(node, base, ctx, hostRef);
78
+ };
79
+ var checkUtility = (node, base, ctx) => {
80
+ if (node.elementId && !NULLISH_ELEMENT_IDS.has(node.elementId)) warnOnce(ctx, `Utility "${node.action}" at ${base} has elementId "${node.elementId}" — a utility takes NO element (it is resolved by its action alone). Omit elementId; the MCP stores null. Pointing it at an element is a no-op.`);
81
+ const utility = getUtility(node.action);
82
+ if (!utility) {
83
+ if (getGlobalCallback(node.action)) warnOnce(ctx, `"${node.action}" at ${base} is a global callback, not a utility — use nodeType "globalCallback".`);
84
+ else if (getElementCallback(node.action)) warnOnce(ctx, `"${node.action}" at ${base} is an element callback, not a utility — use nodeType "callback".`);
85
+ return;
86
+ }
87
+ if (node.params && utility.strictParams) checkParams("Utility", node.action, node.params, utility.params, base, ctx);
88
+ };
89
+ var checkInteractionNode = (node, base, ctx, hostRef) => {
90
+ checkObservedName(node.action, ctx.observedActions, "Interaction action", "plitzi://interactions", `${base}.action`, ctx);
91
+ if (node.elementId === "undefined" || node.elementId === "null") warnOnce(ctx, `Node "${node.action}" at ${base} has the literal string elementId "${node.elementId}" — a stringified nullish value. Re-save the step: elementId must be a real element ref, a source module, or empty for a utility.`);
92
+ switch (node.nodeType) {
93
+ case "globalCallback":
94
+ checkGlobalCallback(node, base, ctx);
95
+ break;
96
+ case "callback":
97
+ checkElementCallback(node, base, ctx, hostRef);
98
+ break;
99
+ case "utility":
100
+ checkUtility(node, base, ctx);
101
+ break;
102
+ default: break;
103
+ }
104
+ };
105
+ //#endregion
106
+ export { checkInteractionNode };
@@ -0,0 +1,28 @@
1
+ import { isValidIdRef } from "@plitzi/sdk-schema/helpers/idRef";
2
+ //#region src/modules/mcp/tools/shared/validator/refs.ts
3
+ var REF_RE = /^[a-zA-Z0-9._-]+$/;
4
+ var checkRef = (ref, path, ctx) => {
5
+ if (!ref || ref.trim().length === 0) {
6
+ ctx.errors.push({
7
+ path,
8
+ message: "Ref must not be empty",
9
+ hint: "Use a semantic name like \"hero.title\""
10
+ });
11
+ return;
12
+ }
13
+ if (!REF_RE.test(ref)) ctx.errors.push({
14
+ path,
15
+ message: `Ref "${ref}" has invalid characters`,
16
+ hint: "Allowed characters: letters, numbers, dot, hyphen, underscore"
17
+ });
18
+ };
19
+ var checkIdRef = (ref, path, ctx) => {
20
+ checkRef(ref, path, ctx);
21
+ if (ref && REF_RE.test(ref) && !isValidIdRef(ref)) ctx.errors.push({
22
+ path,
23
+ message: `Ref "${ref}" is not a valid idRef`,
24
+ hint: "Use only letters, numbers, hyphens and underscores (e.g. \"hero-cta\" or \"my_list_card\"). This ref becomes the element idRef, which the runtime embeds in source names like `apiContainer_<idRef>.field` and in interaction targets — a dot would break those paths."
25
+ });
26
+ };
27
+ //#endregion
28
+ export { REF_RE, checkIdRef, checkRef };
@@ -0,0 +1,39 @@
1
+ import { cloneSpace } from "../helpers/space.js";
2
+ import { environment, operations } from "./operations/index.js";
3
+ import { applyOperations } from "./apply/dispatch.js";
4
+ import { defineTool } from "./shared/tool.js";
5
+ import { validateOperations } from "./shared/validator/index.js";
6
+ import { auditResources } from "./shared/validator/audit.js";
7
+ //#region src/modules/mcp/tools/validate.ts
8
+ var validateShape = {
9
+ environment,
10
+ operations
11
+ };
12
+ var validate = (input, space) => {
13
+ const validation = validateOperations(space, input.operations);
14
+ if (!validation.valid) return validation;
15
+ const env = input.environment ?? "main";
16
+ const draft = cloneSpace(space);
17
+ const outcome = applyOperations(draft, env, input.operations);
18
+ if (outcome.errors.length > 0) return {
19
+ valid: false,
20
+ errors: outcome.errors,
21
+ warnings: validation.warnings
22
+ };
23
+ const audit = auditResources(draft, input.operations);
24
+ return {
25
+ valid: audit.errors.length === 0,
26
+ errors: audit.errors,
27
+ warnings: [...validation.warnings, ...audit.warnings]
28
+ };
29
+ };
30
+ var validateTool = defineTool({
31
+ name: "plitzi_validate",
32
+ title: "Validate",
33
+ description: "Check a batch of operations without executing them. Returns teachable errors and warnings — including any PRE-EXISTING malformation in a resource the batch touches (which blocks a save until fixed).",
34
+ inputShape: validateShape,
35
+ access: "read",
36
+ run: (input, ctx) => validate(input, ctx.space)
37
+ });
38
+ //#endregion
39
+ export { validate, validateShape, validateTool };
@@ -3,8 +3,8 @@ import { prepareRender } from "./prepareRender.js";
3
3
  import { renderToString } from "react-dom/server";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  //#region src/modules/ssr/buildBody.tsx
6
- var buildBody = async (req, config, spaceId, environment, revision, renderFn, pluginManager, offlineDataCache, metrics) => {
7
- const prep = await prepareRender(req, config, spaceId, environment, revision, pluginManager, offlineDataCache, metrics);
6
+ var buildBody = async (req, config, spaceId, environment, revision, renderFn, pluginManager, offlineDataCache, metrics, offlineDataOverride) => {
7
+ const prep = await prepareRender(req, config, spaceId, environment, revision, pluginManager, offlineDataCache, metrics, offlineDataOverride);
8
8
  const result = {};
9
9
  const reactStart = metrics ? performance.now() : 0;
10
10
  const html = renderToString(/* @__PURE__ */ jsx(Component, {
@@ -1,6 +1,7 @@
1
1
  import { buildHtmlCacheKey } from "../../helpers/cache/keys.js";
2
- import { applySSRResult } from "./applySSRResult.js";
3
2
  import { buildBody } from "./buildBody.js";
3
+ import { takeDraftOverride } from "./preview.js";
4
+ import { applySSRResult } from "./applySSRResult.js";
4
5
  import { streamBody } from "./streamBody.js";
5
6
  import { RequestMetrics } from "../../helpers/metrics.js";
6
7
  //#region src/modules/ssr/handler.tsx
@@ -8,7 +9,8 @@ var renderSSR = async (req, res, config, renderFn, pluginManager, caches) => {
8
9
  const { environment = "main", spaceId = 1, revision = 0 } = req.ctx.spaceDeployment || {};
9
10
  const devMode = config.devMode ?? false;
10
11
  res.setHeader("Content-Type", "text/html; charset=utf-8");
11
- const htmlCache = environment !== "main" ? caches.html : void 0;
12
+ const offlineDataOverride = await takeDraftOverride(req, config);
13
+ const htmlCache = environment !== "main" && !offlineDataOverride ? caches.html : void 0;
12
14
  const cacheKey = htmlCache ? buildHtmlCacheKey(req.ctx.user?.token, spaceId, environment, revision, req) : void 0;
13
15
  if (htmlCache && cacheKey) {
14
16
  const cached = htmlCache.get(cacheKey);
@@ -22,10 +24,10 @@ var renderSSR = async (req, res, config, renderFn, pluginManager, caches) => {
22
24
  const metrics = devMode ? new RequestMetrics() : void 0;
23
25
  if (cacheKey) res.setHeader("X-Cache", "MISS");
24
26
  if (config.streaming) {
25
- await streamBody(req, res, config, spaceId, environment, revision, renderFn, pluginManager, caches.offlineData, htmlCache, cacheKey, metrics);
27
+ await streamBody(req, res, config, spaceId, environment, revision, renderFn, pluginManager, caches.offlineData, htmlCache, cacheKey, metrics, offlineDataOverride);
26
28
  return;
27
29
  }
28
- const { body, result } = await buildBody(req, config, spaceId, environment, revision, renderFn, pluginManager, caches.offlineData, metrics);
30
+ const { body, result } = await buildBody(req, config, spaceId, environment, revision, renderFn, pluginManager, caches.offlineData, metrics, offlineDataOverride);
29
31
  if (metrics) {
30
32
  res.setHeader("Server-Timing", metrics.toServerTimingHeader());
31
33
  metrics.log(`${req.method} ${req.path}`);
@@ -1,16 +1,16 @@
1
- import { buildOfflineDataCacheKey } from "../../helpers/cache/keys.js";
2
1
  import { loadPluginComponents } from "./loadPluginComponents.js";
3
2
  import { registerExternalPlugins } from "./registerExternalPlugins.js";
4
3
  import { buildServerInfo } from "../../helpers/buildServerInfo.js";
4
+ import { buildOfflineDataCacheKey } from "../../helpers/cache/keys.js";
5
5
  import { escapeJson } from "../../helpers/escapeJson.js";
6
6
  import { readCookie } from "../../helpers/readCookie.js";
7
7
  //#region src/modules/ssr/prepareRender.tsx
8
- var prepareRender = async (req, config, spaceId, environment, revision, pluginManager, offlineDataCache, metrics) => {
8
+ var prepareRender = async (req, config, spaceId, environment, revision, pluginManager, offlineDataCache, metrics, offlineDataOverride) => {
9
9
  const m = (name, fn) => metrics ? metrics.measure(name, fn) : Promise.resolve(fn());
10
10
  const offlineCacheKey = environment !== "main" ? buildOfflineDataCacheKey(spaceId, environment, revision) : void 0;
11
- const cachedOfflineStr = offlineCacheKey ? offlineDataCache?.get(offlineCacheKey) : void 0;
12
- const [offlineData, server] = await Promise.all([cachedOfflineStr ? JSON.parse(cachedOfflineStr) : m("schema", () => config.adapters.getOfflineData(spaceId, environment, revision)), m("rsc", () => buildServerInfo(req, config))]);
13
- if (!cachedOfflineStr && offlineCacheKey && offlineData !== void 0) offlineDataCache?.set(offlineCacheKey, JSON.stringify(offlineData));
11
+ const cachedOfflineStr = offlineDataOverride === void 0 && offlineCacheKey ? offlineDataCache?.get(offlineCacheKey) : void 0;
12
+ const [offlineData, server] = await Promise.all([offlineDataOverride !== void 0 ? Promise.resolve(offlineDataOverride) : cachedOfflineStr ? JSON.parse(cachedOfflineStr) : m("schema", () => config.adapters.getOfflineData(spaceId, environment, revision)), m("rsc", () => buildServerInfo(req, config))]);
13
+ if (offlineDataOverride === void 0 && !cachedOfflineStr && offlineCacheKey && offlineData !== void 0) offlineDataCache?.set(offlineCacheKey, JSON.stringify(offlineData));
14
14
  const v = config.assetVersion ? `?v=${config.assetVersion}` : "";
15
15
  const sdkDevToolsStylePath = `/sdk-assets/plitzi-sdk-devtools.css${v}`;
16
16
  const debugCookie = readCookie(req.headers.cookie, "plitzi_debug");