@plitzi/sdk-mcp 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +175 -0
  3. package/dist/createServer.d.ts +11 -0
  4. package/dist/createServer.js +36 -0
  5. package/dist/createServer.test.d.ts +1 -0
  6. package/dist/index.d.ts +20 -0
  7. package/dist/index.js +21 -0
  8. package/dist/modules/ai/AIEngine.d.ts +20 -0
  9. package/dist/modules/ai/AIEngine.js +120 -0
  10. package/dist/modules/ai/index.d.ts +4 -0
  11. package/dist/modules/ai/toolkit.d.ts +17 -0
  12. package/dist/modules/ai/toolkit.js +59 -0
  13. package/dist/modules/ai/toolkit.test.d.ts +1 -0
  14. package/dist/modules/mcp/apps/apps.test.d.ts +1 -0
  15. package/dist/modules/mcp/apps/example/index.d.ts +8 -0
  16. package/dist/modules/mcp/apps/example/view/index.tsx +70 -0
  17. package/dist/modules/mcp/apps/index.d.ts +11 -0
  18. package/dist/modules/mcp/apps/index.js +16 -0
  19. package/dist/modules/mcp/apps/render/index.d.ts +4 -0
  20. package/dist/modules/mcp/apps/render/index.js +17 -0
  21. package/dist/modules/mcp/apps/render/styles.d.ts +10 -0
  22. package/dist/modules/mcp/apps/render/styles.js +54 -0
  23. package/dist/modules/mcp/apps/render/styles.test.d.ts +1 -0
  24. package/dist/modules/mcp/apps/render/view/heldBatch.ts +107 -0
  25. package/dist/modules/mcp/apps/render/view/index.tsx +314 -0
  26. package/dist/modules/mcp/apps/render/view/streamProgress.ts +137 -0
  27. package/dist/modules/mcp/apps/shared/assets.d.ts +10 -0
  28. package/dist/modules/mcp/apps/shared/assets.js +10 -0
  29. package/dist/modules/mcp/apps/shared/bundle.d.ts +4 -0
  30. package/dist/modules/mcp/apps/shared/bundle.js +23 -0
  31. package/dist/modules/mcp/apps/shared/index.d.ts +3 -0
  32. package/dist/modules/mcp/apps/shared/page.d.ts +2 -0
  33. package/dist/modules/mcp/apps/shared/page.js +34 -0
  34. package/dist/modules/mcp/apps/shared/registerApp.d.ts +5 -0
  35. package/dist/modules/mcp/apps/shared/registerApp.js +43 -0
  36. package/dist/modules/mcp/apps/shared/resolve.d.ts +1 -0
  37. package/dist/modules/mcp/apps/shared/resolve.js +5 -0
  38. package/dist/modules/mcp/apps/shared/shell.ejs +59 -0
  39. package/dist/modules/mcp/apps/shared/zodEnglishOnly.d.ts +4 -0
  40. package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +23 -0
  41. package/dist/modules/mcp/catalogs/builtinCallbacks.d.ts +19 -0
  42. package/dist/modules/mcp/catalogs/builtinCallbacks.js +139 -0
  43. package/dist/modules/mcp/catalogs/builtinComponents.d.ts +4 -0
  44. package/dist/modules/mcp/catalogs/builtinComponents.js +165 -0
  45. package/dist/modules/mcp/catalogs/builtinElementCallbacks.d.ts +17 -0
  46. package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +50 -0
  47. package/dist/modules/mcp/catalogs/builtinTransformers.d.ts +28 -0
  48. package/dist/modules/mcp/catalogs/builtinTransformers.js +148 -0
  49. package/dist/modules/mcp/catalogs/builtinTransformers.test.d.ts +1 -0
  50. package/dist/modules/mcp/catalogs/builtinUtilities.d.ts +15 -0
  51. package/dist/modules/mcp/catalogs/builtinUtilities.js +90 -0
  52. package/dist/modules/mcp/catalogs/cssCatalog/border.d.ts +4 -0
  53. package/dist/modules/mcp/catalogs/cssCatalog/border.js +30 -0
  54. package/dist/modules/mcp/catalogs/cssCatalog/box.d.ts +4 -0
  55. package/dist/modules/mcp/catalogs/cssCatalog/box.js +31 -0
  56. package/dist/modules/mcp/catalogs/cssCatalog/cssCatalog.test.d.ts +1 -0
  57. package/dist/modules/mcp/catalogs/cssCatalog/helpers.d.ts +34 -0
  58. package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +185 -0
  59. package/dist/modules/mcp/catalogs/cssCatalog/index.d.ts +18 -0
  60. package/dist/modules/mcp/catalogs/cssCatalog/index.js +131 -0
  61. package/dist/modules/mcp/catalogs/cssCatalog/layout.d.ts +9 -0
  62. package/dist/modules/mcp/catalogs/cssCatalog/layout.js +99 -0
  63. package/dist/modules/mcp/catalogs/cssCatalog/visual.d.ts +8 -0
  64. package/dist/modules/mcp/catalogs/cssCatalog/visual.js +147 -0
  65. package/dist/modules/mcp/catalogs/index.d.ts +9 -0
  66. package/dist/modules/mcp/catalogs/observed.d.ts +46 -0
  67. package/dist/modules/mcp/catalogs/observed.js +90 -0
  68. package/dist/modules/mcp/catalogs/paramSpec.d.ts +39 -0
  69. package/dist/modules/mcp/catalogs/paramSpec.js +69 -0
  70. package/dist/modules/mcp/catalogs/registry.d.ts +35 -0
  71. package/dist/modules/mcp/catalogs/registry.js +89 -0
  72. package/dist/modules/mcp/e2e/connector.test.d.ts +1 -0
  73. package/dist/modules/mcp/e2e/host.test.d.ts +1 -0
  74. package/dist/modules/mcp/e2e/index.d.ts +6 -0
  75. package/dist/modules/mcp/e2e/mcpEndpoint.d.ts +27 -0
  76. package/dist/modules/mcp/e2e/oauthConnector.test.d.ts +1 -0
  77. package/dist/modules/mcp/e2e/postMessageChannel.d.ts +22 -0
  78. package/dist/modules/mcp/e2e/renderingHost.d.ts +39 -0
  79. package/dist/modules/mcp/handler.d.ts +22 -0
  80. package/dist/modules/mcp/handler.js +83 -0
  81. package/dist/modules/mcp/helpers/agentPrompt.d.ts +4 -0
  82. package/dist/modules/mcp/helpers/agentPrompt.js +104 -0
  83. package/dist/modules/mcp/helpers/computeVersion.d.ts +1 -0
  84. package/dist/modules/mcp/helpers/computeVersion.js +16 -0
  85. package/dist/modules/mcp/helpers/guide.d.ts +4 -0
  86. package/dist/modules/mcp/helpers/guide.js +608 -0
  87. package/dist/modules/mcp/helpers/index.d.ts +8 -0
  88. package/dist/modules/mcp/helpers/interactions.d.ts +30 -0
  89. package/dist/modules/mcp/helpers/interactions.js +123 -0
  90. package/dist/modules/mcp/helpers/log.d.ts +8 -0
  91. package/dist/modules/mcp/helpers/log.js +64 -0
  92. package/dist/modules/mcp/helpers/log.test.d.ts +1 -0
  93. package/dist/modules/mcp/helpers/opResult.d.ts +13 -0
  94. package/dist/modules/mcp/helpers/opResult.js +18 -0
  95. package/dist/modules/mcp/helpers/space.d.ts +126 -0
  96. package/dist/modules/mcp/helpers/space.js +314 -0
  97. package/dist/modules/mcp/helpers/uris.d.ts +33 -0
  98. package/dist/modules/mcp/helpers/uris.js +50 -0
  99. package/dist/modules/mcp/index.d.ts +13 -0
  100. package/dist/modules/mcp/mcp.bench.d.ts +1 -0
  101. package/dist/modules/mcp/previewClient.d.ts +13 -0
  102. package/dist/modules/mcp/previewClient.js +31 -0
  103. package/dist/modules/mcp/proxy/config.d.ts +20 -0
  104. package/dist/modules/mcp/proxy/config.js +62 -0
  105. package/dist/modules/mcp/proxy/endpoint.test.d.ts +1 -0
  106. package/dist/modules/mcp/proxy/fetch.d.ts +18 -0
  107. package/dist/modules/mcp/proxy/fetch.js +91 -0
  108. package/dist/modules/mcp/proxy/grant.d.ts +25 -0
  109. package/dist/modules/mcp/proxy/grant.js +67 -0
  110. package/dist/modules/mcp/proxy/guard.d.ts +6 -0
  111. package/dist/modules/mcp/proxy/guard.js +38 -0
  112. package/dist/modules/mcp/proxy/handler.d.ts +8 -0
  113. package/dist/modules/mcp/proxy/handler.js +99 -0
  114. package/dist/modules/mcp/proxy/index.d.ts +8 -0
  115. package/dist/modules/mcp/proxy/payload.d.ts +8 -0
  116. package/dist/modules/mcp/proxy/payload.js +29 -0
  117. package/dist/modules/mcp/proxy/proxy.test.d.ts +1 -0
  118. package/dist/modules/mcp/proxy/rewrite.d.ts +18 -0
  119. package/dist/modules/mcp/proxy/rewrite.js +138 -0
  120. package/dist/modules/mcp/proxy/sign.d.ts +6 -0
  121. package/dist/modules/mcp/proxy/sign.js +15 -0
  122. package/dist/modules/mcp/proxy/types.d.ts +45 -0
  123. package/dist/modules/mcp/proxy/types.js +9 -0
  124. package/dist/modules/mcp/proxy/wiring.test.d.ts +1 -0
  125. package/dist/modules/mcp/resources/canonical.d.ts +6 -0
  126. package/dist/modules/mcp/resources/canonical.js +30 -0
  127. package/dist/modules/mcp/resources/connectors.d.ts +22 -0
  128. package/dist/modules/mcp/resources/connectors.js +46 -0
  129. package/dist/modules/mcp/resources/core.d.ts +5 -0
  130. package/dist/modules/mcp/resources/core.js +18 -0
  131. package/dist/modules/mcp/resources/envelope.d.ts +10 -0
  132. package/dist/modules/mcp/resources/envelope.js +14 -0
  133. package/dist/modules/mcp/resources/index.d.ts +9 -0
  134. package/dist/modules/mcp/resources/primer.d.ts +7 -0
  135. package/dist/modules/mcp/resources/primer.js +33 -0
  136. package/dist/modules/mcp/resources/register.d.ts +10 -0
  137. package/dist/modules/mcp/resources/register.js +205 -0
  138. package/dist/modules/mcp/resources/renderGuide.d.ts +10 -0
  139. package/dist/modules/mcp/resources/renderGuide.js +451 -0
  140. package/dist/modules/mcp/resources/router.d.ts +10 -0
  141. package/dist/modules/mcp/resources/router.js +39 -0
  142. package/dist/modules/mcp/resources/schema.d.ts +5 -0
  143. package/dist/modules/mcp/resources/schema.js +43 -0
  144. package/dist/modules/mcp/resources/style.d.ts +5 -0
  145. package/dist/modules/mcp/resources/style.js +34 -0
  146. package/dist/modules/mcp/screenshotClient.d.ts +13 -0
  147. package/dist/modules/mcp/screenshotClient.js +47 -0
  148. package/dist/modules/mcp/server.d.ts +31 -0
  149. package/dist/modules/mcp/server.js +127 -0
  150. package/dist/modules/mcp/tests/apply.test.d.ts +1 -0
  151. package/dist/modules/mcp/tests/bindings.test.d.ts +1 -0
  152. package/dist/modules/mcp/tests/connectors.test.d.ts +1 -0
  153. package/dist/modules/mcp/tests/css.test.d.ts +1 -0
  154. package/dist/modules/mcp/tests/helpers.d.ts +13 -0
  155. package/dist/modules/mcp/tests/interactions.test.d.ts +1 -0
  156. package/dist/modules/mcp/tests/pages.test.d.ts +1 -0
  157. package/dist/modules/mcp/tests/reads.test.d.ts +1 -0
  158. package/dist/modules/mcp/tests/schemaIds.test.d.ts +1 -0
  159. package/dist/modules/mcp/tests/search.test.d.ts +1 -0
  160. package/dist/modules/mcp/tests/skill.test.d.ts +1 -0
  161. package/dist/modules/mcp/tests/styles.test.d.ts +1 -0
  162. package/dist/modules/mcp/tests/tools.test.d.ts +1 -0
  163. package/dist/modules/mcp/tests/validation.test.d.ts +1 -0
  164. package/dist/modules/mcp/tools/apply/dispatch.d.ts +6 -0
  165. package/dist/modules/mcp/tools/apply/dispatch.js +128 -0
  166. package/dist/modules/mcp/tools/apply/index.d.ts +656 -0
  167. package/dist/modules/mcp/tools/apply/index.js +161 -0
  168. package/dist/modules/mcp/tools/apply/writeResult.d.ts +8 -0
  169. package/dist/modules/mcp/tools/apply/writeResult.js +37 -0
  170. package/dist/modules/mcp/tools/index.d.ts +18 -0
  171. package/dist/modules/mcp/tools/index.js +24 -0
  172. package/dist/modules/mcp/tools/operations/connectors/deleteConnector.d.ts +9 -0
  173. package/dist/modules/mcp/tools/operations/connectors/deleteConnector.js +20 -0
  174. package/dist/modules/mcp/tools/operations/connectors/index.d.ts +188 -0
  175. package/dist/modules/mcp/tools/operations/connectors/index.js +12 -0
  176. package/dist/modules/mcp/tools/operations/connectors/manifest.d.ts +89 -0
  177. package/dist/modules/mcp/tools/operations/connectors/manifest.js +70 -0
  178. package/dist/modules/mcp/tools/operations/connectors/patchConnector.d.ts +94 -0
  179. package/dist/modules/mcp/tools/operations/connectors/patchConnector.js +58 -0
  180. package/dist/modules/mcp/tools/operations/connectors/upsertConnector.d.ts +98 -0
  181. package/dist/modules/mcp/tools/operations/connectors/upsertConnector.js +64 -0
  182. package/dist/modules/mcp/tools/operations/index.d.ts +2235 -0
  183. package/dist/modules/mcp/tools/operations/index.js +55 -0
  184. package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +17 -0
  185. package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +32 -0
  186. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +25 -0
  187. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +36 -0
  188. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +27 -0
  189. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +47 -0
  190. package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +10 -0
  191. package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +29 -0
  192. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +16 -0
  193. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +41 -0
  194. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +27 -0
  195. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +60 -0
  196. package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.d.ts +55 -0
  197. package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +148 -0
  198. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +16 -0
  199. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +66 -0
  200. package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +9 -0
  201. package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +32 -0
  202. package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +12 -0
  203. package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +49 -0
  204. package/dist/modules/mcp/tools/operations/schema/index.d.ts +21 -0
  205. package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +12 -0
  206. package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +52 -0
  207. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +18 -0
  208. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +47 -0
  209. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +27 -0
  210. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +44 -0
  211. package/dist/modules/mcp/tools/operations/schema/operations.d.ts +236 -0
  212. package/dist/modules/mcp/tools/operations/schema/operations.js +41 -0
  213. package/dist/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +9 -0
  214. package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +25 -0
  215. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +14 -0
  216. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +77 -0
  217. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +36 -0
  218. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +44 -0
  219. package/dist/modules/mcp/tools/operations/schema/shared.d.ts +106 -0
  220. package/dist/modules/mcp/tools/operations/schema/shared.js +131 -0
  221. package/dist/modules/mcp/tools/operations/schema/translator.d.ts +12 -0
  222. package/dist/modules/mcp/tools/operations/schema/translator.js +216 -0
  223. package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +9 -0
  224. package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +18 -0
  225. package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +16 -0
  226. package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +42 -0
  227. package/dist/modules/mcp/tools/operations/schema/write.d.ts +42 -0
  228. package/dist/modules/mcp/tools/operations/schema/write.js +112 -0
  229. package/dist/modules/mcp/tools/operations/schemaIds.d.ts +6 -0
  230. package/dist/modules/mcp/tools/operations/schemaIds.js +58 -0
  231. package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +9 -0
  232. package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +21 -0
  233. package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +37 -0
  234. package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +28 -0
  235. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +37 -0
  236. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +24 -0
  237. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.d.ts +41 -0
  238. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +40 -0
  239. package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +9 -0
  240. package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +21 -0
  241. package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +37 -0
  242. package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +28 -0
  243. package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +37 -0
  244. package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +24 -0
  245. package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +9 -0
  246. package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +21 -0
  247. package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +37 -0
  248. package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +28 -0
  249. package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +37 -0
  250. package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +24 -0
  251. package/dist/modules/mcp/tools/operations/style/index.d.ts +15 -0
  252. package/dist/modules/mcp/tools/operations/style/operations.d.ts +264 -0
  253. package/dist/modules/mcp/tools/operations/style/operations.js +29 -0
  254. package/dist/modules/mcp/tools/operations/style/shared.d.ts +116 -0
  255. package/dist/modules/mcp/tools/operations/style/shared.js +59 -0
  256. package/dist/modules/mcp/tools/operations/style/translator.d.ts +12 -0
  257. package/dist/modules/mcp/tools/operations/style/translator.js +101 -0
  258. package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +15 -0
  259. package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +21 -0
  260. package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +20 -0
  261. package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +22 -0
  262. package/dist/modules/mcp/tools/operations/style/write.d.ts +12 -0
  263. package/dist/modules/mcp/tools/operations/style/write.js +108 -0
  264. package/dist/modules/mcp/tools/preview.d.ts +472 -0
  265. package/dist/modules/mcp/tools/preview.js +37 -0
  266. package/dist/modules/mcp/tools/read.d.ts +9 -0
  267. package/dist/modules/mcp/tools/read.js +51 -0
  268. package/dist/modules/mcp/tools/render.d.ts +506 -0
  269. package/dist/modules/mcp/tools/render.js +184 -0
  270. package/dist/modules/mcp/tools/render.test.d.ts +1 -0
  271. package/dist/modules/mcp/tools/screenshot.d.ts +656 -0
  272. package/dist/modules/mcp/tools/screenshot.js +83 -0
  273. package/dist/modules/mcp/tools/search.d.ts +15 -0
  274. package/dist/modules/mcp/tools/search.js +115 -0
  275. package/dist/modules/mcp/tools/shared/expandOperations.d.ts +13 -0
  276. package/dist/modules/mcp/tools/shared/expandOperations.js +44 -0
  277. package/dist/modules/mcp/tools/shared/tool.d.ts +72 -0
  278. package/dist/modules/mcp/tools/shared/tool.js +33 -0
  279. package/dist/modules/mcp/tools/shared/validator/audit.d.ts +4 -0
  280. package/dist/modules/mcp/tools/shared/validator/audit.js +124 -0
  281. package/dist/modules/mcp/tools/shared/validator/batch.d.ts +5 -0
  282. package/dist/modules/mcp/tools/shared/validator/batch.js +39 -0
  283. package/dist/modules/mcp/tools/shared/validator/bindings.d.ts +6 -0
  284. package/dist/modules/mcp/tools/shared/validator/bindings.js +70 -0
  285. package/dist/modules/mcp/tools/shared/validator/connectors.d.ts +19 -0
  286. package/dist/modules/mcp/tools/shared/validator/connectors.js +76 -0
  287. package/dist/modules/mcp/tools/shared/validator/context.d.ts +38 -0
  288. package/dist/modules/mcp/tools/shared/validator/context.js +35 -0
  289. package/dist/modules/mcp/tools/shared/validator/css.d.ts +4 -0
  290. package/dist/modules/mcp/tools/shared/validator/css.js +39 -0
  291. package/dist/modules/mcp/tools/shared/validator/elements.d.ts +7 -0
  292. package/dist/modules/mcp/tools/shared/validator/elements.js +68 -0
  293. package/dist/modules/mcp/tools/shared/validator/index.d.ts +8 -0
  294. package/dist/modules/mcp/tools/shared/validator/index.js +268 -0
  295. package/dist/modules/mcp/tools/shared/validator/interactions.d.ts +3 -0
  296. package/dist/modules/mcp/tools/shared/validator/interactions.js +103 -0
  297. package/dist/modules/mcp/tools/shared/validator/refs.d.ts +4 -0
  298. package/dist/modules/mcp/tools/shared/validator/refs.js +28 -0
  299. package/dist/modules/mcp/tools/validate.d.ts +653 -0
  300. package/dist/modules/mcp/tools/validate.js +47 -0
  301. package/dist/modules/mcp/types/aiSchema.d.ts +226 -0
  302. package/dist/modules/mcp/types/appTypes.d.ts +26 -0
  303. package/dist/modules/mcp/types/index.d.ts +5 -0
  304. package/dist/modules/mcp/types/previewTypes.d.ts +25 -0
  305. package/dist/modules/mcp/types/screenshotTypes.d.ts +29 -0
  306. package/dist/modules/mcp/types/toolTypes.d.ts +145 -0
  307. package/dist/modules/oauth/authorize.d.ts +7 -0
  308. package/dist/modules/oauth/authorize.js +177 -0
  309. package/dist/modules/oauth/challenge.d.ts +11 -0
  310. package/dist/modules/oauth/challenge.js +33 -0
  311. package/dist/modules/oauth/consentPage.d.ts +7 -0
  312. package/dist/modules/oauth/consentPage.js +118 -0
  313. package/dist/modules/oauth/metadata.d.ts +40 -0
  314. package/dist/modules/oauth/metadata.js +69 -0
  315. package/dist/modules/oauth/oauth.test.d.ts +1 -0
  316. package/dist/modules/oauth/params.d.ts +5 -0
  317. package/dist/modules/oauth/params.js +5 -0
  318. package/dist/modules/oauth/pkce.d.ts +6 -0
  319. package/dist/modules/oauth/pkce.js +15 -0
  320. package/dist/modules/oauth/records.d.ts +71 -0
  321. package/dist/modules/oauth/records.js +46 -0
  322. package/dist/modules/oauth/register.d.ts +5 -0
  323. package/dist/modules/oauth/register.js +55 -0
  324. package/dist/modules/oauth/respond.d.ts +13 -0
  325. package/dist/modules/oauth/respond.js +44 -0
  326. package/dist/modules/oauth/token.d.ts +5 -0
  327. package/dist/modules/oauth/token.js +100 -0
  328. package/dist/options.d.ts +73 -0
  329. package/dist/packageBoundary.test.d.ts +1 -0
  330. package/dist/pipeline.d.ts +12 -0
  331. package/dist/pipeline.js +29 -0
  332. package/dist/pipeline.test.d.ts +1 -0
  333. package/dist/preview/createPreview.d.ts +10 -0
  334. package/dist/preview/createPreview.js +83 -0
  335. package/dist/server.d.ts +15 -0
  336. package/dist/server.js +7 -0
  337. package/dist/stages/mcp.d.ts +4 -0
  338. package/dist/stages/mcp.js +30 -0
  339. package/dist/stages/oauth.d.ts +19 -0
  340. package/dist/stages/oauth.js +114 -0
  341. package/dist/stages/preview.d.ts +2 -0
  342. package/dist/stages/preview.js +37 -0
  343. package/dist/stages/proxy.d.ts +3 -0
  344. package/dist/stages/proxy.js +14 -0
  345. package/dist/tests/httpRequest.d.ts +14 -0
  346. package/package.json +77 -0
  347. package/skills/plitzi-render/SKILL.md +174 -0
@@ -0,0 +1,76 @@
1
+ import { findConnectorEntry } from "../../../helpers/space.js";
2
+ import { toManifest } from "../../operations/connectors/upsertConnector.js";
3
+ import { warnOnce } from "./context.js";
4
+ import { validateConnectorManifest } from "@plitzi/sdk-shared/connectors";
5
+ //#region src/modules/mcp/tools/shared/validator/connectors.ts
6
+ /** Run the one shared manifest validator and fold its report into the batch result. Errors reject the batch;
7
+ * warnings ride along — notably "reads {{credential.…}} but names no credential", which is expected here: the
8
+ * agent authors the manifest and the space owner attaches the secret afterwards. */
9
+ var checkManifest = (manifest, base, ctx) => {
10
+ const report = validateConnectorManifest(manifest);
11
+ for (const issue of report.errors) ctx.errors.push({
12
+ path: issue.path ? `${base}.${issue.path}` : base,
13
+ message: issue.message,
14
+ hint: issue.hint ?? "Read plitzi://guide (Connectors) for the manifest shape"
15
+ });
16
+ for (const issue of report.warnings) warnOnce(ctx, `${base}.${issue.path}: ${issue.message}${issue.hint ? ` — ${issue.hint}` : ""}`);
17
+ };
18
+ /** Connectors this batch creates, so an element wired to one earlier in the same batch is not reported missing. */
19
+ var batchDeclaredConnectors = (ops) => {
20
+ const refs = /* @__PURE__ */ new Set();
21
+ for (const op of ops) if (op.type === "upsertConnector") refs.add(op.ref);
22
+ return refs;
23
+ };
24
+ var checkConnectorOp = (space, op, base, ctx) => {
25
+ if (op.type === "upsertConnector") {
26
+ checkManifest(toManifest(op), base, ctx);
27
+ return;
28
+ }
29
+ if (op.type !== "deleteConnector") return;
30
+ const inUse = Object.values(space.schema.flat).filter((el) => el.attributes.connector === op.ref).map((el) => el.idRef ?? el.id);
31
+ if (inUse.length > 0) warnOnce(ctx, `Connector "${op.ref}" still feeds ${inUse.length} element(s) (${inUse.join(", ")}). Deleting it leaves them resolving to no data. Confirm with the user, and repoint or remove those elements too.`);
32
+ };
33
+ var asString = (value) => typeof value === "string" && value ? value : void 0;
34
+ /**
35
+ * A provider element checked against the connector it names.
36
+ *
37
+ * These are warnings, not errors, and deliberately: the connector store is a different document from the schema,
38
+ * so an element may legitimately be authored before (or after) the connector it points at — and a batch that
39
+ * refuses the page because the connector is not there yet would make the two impossible to write in either order.
40
+ * What the agent must not do is walk away believing a page is wired when it resolves to nothing.
41
+ */
42
+ var checkProviderElement = (space, ctx, ref, runtime, props, batchConnectors, base) => {
43
+ const connectorId = asString(props?.connector);
44
+ if (!connectorId) {
45
+ if (runtime === "server") warnOnce(ctx, `"${ref}" at ${base} renders on the server but names no connector, so it resolves to no data. Set its \`connector\` prop to one the space has (read plitzi://connectors).`);
46
+ return;
47
+ }
48
+ if (runtime !== "server") warnOnce(ctx, `"${ref}" at ${base} names connector "${connectorId}" but is not server-rendered, so the connector is IGNORED and the element fetches its own \`query\` from the browser instead. Set runtime: "server" on it.`);
49
+ const entry = findConnectorEntry(space, connectorId);
50
+ if (!entry) {
51
+ if (!batchConnectors.has(connectorId)) warnOnce(ctx, `Connector "${connectorId}" at ${base} is not configured in this space, so "${ref}" resolves to no data. Read plitzi://connectors, or create it with upsertConnector.`);
52
+ return;
53
+ }
54
+ const endpoint = asString(props?.endpoint);
55
+ const reads = Object.keys(entry.manifest.endpoints.read);
56
+ if (endpoint !== void 0 && !reads.includes(endpoint)) ctx.errors.push({
57
+ path: `${base}.props.endpoint`,
58
+ message: `Connector "${connectorId}" has no read endpoint named "${endpoint}"`,
59
+ hint: "Name one the connector declares, or add it with patchConnector",
60
+ validValues: reads
61
+ });
62
+ const operators = Object.keys(entry.manifest.operators ?? {});
63
+ if (!Array.isArray(props?.filters)) return;
64
+ props.filters.forEach((filter, i) => {
65
+ if (filter === null || typeof filter !== "object") return;
66
+ const operator = asString(filter.operator);
67
+ if (operator !== void 0 && !operators.includes(operator)) ctx.errors.push({
68
+ path: `${base}.props.filters[${i}].operator`,
69
+ message: `Connector "${connectorId}" declares no operator "${operator}", so this filter is dropped and the query returns unfiltered records`,
70
+ hint: "Use an operator the connector declares, or add it with patchConnector",
71
+ validValues: operators
72
+ });
73
+ });
74
+ };
75
+ //#endregion
76
+ export { batchDeclaredConnectors, checkConnectorOp, checkProviderElement };
@@ -0,0 +1,38 @@
1
+ import { ValidationError } from '../../../types';
2
+ import { Style } from '@plitzi/sdk-shared';
3
+ export declare const RAW_CODE_TYPES: Set<string>;
4
+ /** What the batch is authoring. A `widget` (plitzi_render) is embedded in a host's chat UI we do not own, so its
5
+ * raw markup is held to a stricter rule than a space the account owns. */
6
+ export type ValidationMode = 'space' | 'widget';
7
+ /** Authoritative per-type metadata from the component catalog (default sdk-elements ∪ this space's plugins).
8
+ * `custom` drives strict-vs-lenient validation: a default type (custom:false) owns its full attribute set, so an
9
+ * unknown attribute/setState key on it is an error; a plugin type (custom:true) is best-effort (warnings). */
10
+ export interface TypeMeta {
11
+ attributes: Set<string>;
12
+ styleSelectors: Set<string>;
13
+ custom: boolean;
14
+ bindingTargets?: {
15
+ attributes: Set<string>;
16
+ initialState: Set<string>;
17
+ };
18
+ }
19
+ export interface ValidationCtx {
20
+ mode: ValidationMode;
21
+ errors: ValidationError[];
22
+ warnings: string[];
23
+ warned: Set<string>;
24
+ knownTypes: Set<string>;
25
+ typeProps: Map<string, Set<string>>;
26
+ typeMeta: Map<string, TypeMeta>;
27
+ elementType: (ref: string) => string | undefined;
28
+ schemaVars: Set<string>;
29
+ styleVars: Set<string>;
30
+ style: Style;
31
+ batchVariants: Map<string, Set<string>>;
32
+ observedActions: Set<string>;
33
+ observedSources: Set<string>;
34
+ }
35
+ export declare const warnOnce: (ctx: ValidationCtx, message: string) => void;
36
+ export declare const checkVarRefs: (text: string, path: string, ctx: ValidationCtx) => void;
37
+ export declare const checkStyleVarRefs: (text: string, path: string, ctx: ValidationCtx) => void;
38
+ export declare const checkObservedName: (value: string | undefined, observed: Set<string>, kind: string, resource: string, path: string, ctx: ValidationCtx) => void;
@@ -0,0 +1,35 @@
1
+ //#region src/modules/mcp/tools/shared/validator/context.ts
2
+ var VAR_REF = /\{\{\s*([A-Za-z_][\w.-]*)\s*\}\}/g;
3
+ var CSS_VAR = /var\(\s*--([A-Za-z_][\w-]*)\s*\)/g;
4
+ var RAW_CODE_TYPES = /* @__PURE__ */ new Set([
5
+ "blockJsx",
6
+ "blockHtml",
7
+ "custom"
8
+ ]);
9
+ var warnOnce = (ctx, message) => {
10
+ if (!ctx.warned.has(message)) {
11
+ ctx.warned.add(message);
12
+ ctx.warnings.push(message);
13
+ }
14
+ };
15
+ var checkVarRefs = (text, path, ctx) => {
16
+ for (const match of text.matchAll(VAR_REF)) {
17
+ const name = match[1];
18
+ if (!ctx.schemaVars.has(name)) warnOnce(ctx, `Unknown variable {{${name}}} at ${path}: not a space schema variable or a page route param. Read plitzi://schema-variables, or use a route param from the page skeleton (routeParams).`);
19
+ }
20
+ };
21
+ var checkStyleVarRefs = (text, path, ctx) => {
22
+ for (const match of text.matchAll(CSS_VAR)) {
23
+ const name = match[1];
24
+ if (!ctx.styleVars.has(name)) {
25
+ const tokens = [...ctx.styleVars];
26
+ warnOnce(ctx, `Unknown style variable var(--${name}) at ${path}: not a design token in this space. ${tokens.length > 0 ? `Available tokens: ${tokens.slice(0, 30).join(", ")}${tokens.length > 30 ? ", …" : ""}.` : "Read plitzi://style-variables for the valid token names."}`);
27
+ }
28
+ }
29
+ };
30
+ var checkObservedName = (value, observed, kind, resource, path, ctx) => {
31
+ if (!value || observed.size === 0 || observed.has(value)) return;
32
+ warnOnce(ctx, `${kind} "${value}" at ${path} was not seen in this space. Verify against ${resource}; it may still be valid.`);
33
+ };
34
+ //#endregion
35
+ export { RAW_CODE_TYPES, checkObservedName, checkStyleVarRefs, checkVarRefs, warnOnce };
@@ -0,0 +1,4 @@
1
+ import { ValidationCtx } from './context';
2
+ import { DefinitionSlotPatch } from '../../operations';
3
+ export declare const checkCss: (css: Record<string, string | number | null> | undefined, path: string, ctx: ValidationCtx) => void;
4
+ export declare const checkSlotCss: (slot: DefinitionSlotPatch, path: string, ctx: ValidationCtx) => void;
@@ -0,0 +1,39 @@
1
+ import { expandShorthand, isCssProperty, suggestCssProperty } from "../../../catalogs/cssCatalog/index.js";
2
+ import { checkStyleVarRefs, checkVarRefs } 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
+ if (!isCssProperty(key)) {
10
+ const suggestion = suggestCssProperty(key);
11
+ ctx.errors.push({
12
+ path: `${path}.${key}`,
13
+ message: `Unknown CSS property "${key}"`,
14
+ hint: suggestion ? `Use the kebab-case key "${suggestion}"` : "Read plitzi://css-properties for the valid property keys"
15
+ });
16
+ }
17
+ if (typeof value === "string") {
18
+ checkStyleVarRefs(value, `${path}.${key}`, ctx);
19
+ checkVarRefs(value, `${path}.${key}`, ctx);
20
+ }
21
+ }
22
+ };
23
+ var checkSlotCss = (slot, path, ctx) => {
24
+ checkCss(slot.desktop, `${path}.desktop`, ctx);
25
+ checkCss(slot.tablet, `${path}.tablet`, ctx);
26
+ checkCss(slot.mobile, `${path}.mobile`, ctx);
27
+ for (const [state, dm] of Object.entries(slot.states ?? {})) {
28
+ checkCss(dm.desktop, `${path}.states.${state}.desktop`, ctx);
29
+ checkCss(dm.tablet, `${path}.states.${state}.tablet`, ctx);
30
+ checkCss(dm.mobile, `${path}.states.${state}.mobile`, ctx);
31
+ }
32
+ for (const [name, dm] of Object.entries(slot.variants ?? {})) {
33
+ checkCss(dm.desktop, `${path}.variants.${name}.desktop`, ctx);
34
+ checkCss(dm.tablet, `${path}.variants.${name}.tablet`, ctx);
35
+ checkCss(dm.mobile, `${path}.variants.${name}.mobile`, ctx);
36
+ }
37
+ };
38
+ //#endregion
39
+ export { checkCss, checkSlotCss };
@@ -0,0 +1,7 @@
1
+ import { ValidationCtx } from './context';
2
+ import { ElementInput } from '../../operations';
3
+ import { InitialStateInput } from '../../operations/schema/shared';
4
+ export declare const checkTypeProps: (type: string, props: Record<string, unknown> | undefined, path: string, ctx: ValidationCtx) => void;
5
+ export declare const checkVariantApplication: (initialState: InitialStateInput | undefined, path: string, ctx: ValidationCtx) => void;
6
+ export declare const checkRawMarkup: (type: string, props: Record<string, unknown> | undefined, path: string, ctx: ValidationCtx) => void;
7
+ export declare const checkElementInput: (element: ElementInput, path: string, ctx: ValidationCtx, seen: Set<string>) => void;
@@ -0,0 +1,68 @@
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))) {
29
+ const avail = declared ? ` (declares: ${Object.entries(declared).map(([s, v]) => `${s}:${v.join("/")}`).join(", ")})` : "";
30
+ warnOnce(ctx, `Element applies variant "${name}" on class "${cls}" (${selector}) at ${path}, but that class defines no such variant${avail}. Create it via upsertDefinition/patchDefinition "variants", or fix the name.`);
31
+ }
32
+ }
33
+ }
34
+ };
35
+ var EXECUTABLE_MARKUP = /<script\b|\son[a-z]+\s*=|javascript:/i;
36
+ var checkRawMarkup = (type, props, path, ctx) => {
37
+ if (ctx.mode !== "widget" || !props || !RAW_CODE_TYPES.has(type)) return;
38
+ for (const [key, value] of Object.entries(props)) if (typeof value === "string" && EXECUTABLE_MARKUP.test(value)) ctx.errors.push({
39
+ path: `${path}.props.${key}`,
40
+ message: `Executable markup in a "${type}" prop is not allowed in a widget`,
41
+ hint: "A widget renders inside the host UI, so <script>, javascript: URLs and inline on* handlers are rejected. Keep the markup inert (an inline <svg> is what this type is for) and wire behaviour with upsertInteractionFlow."
42
+ });
43
+ };
44
+ var checkElementProps = (element, path, ctx) => {
45
+ checkRawMarkup(element.type, element.props, path, ctx);
46
+ if (!element.props || RAW_CODE_TYPES.has(element.type)) return;
47
+ for (const [key, value] of Object.entries(element.props)) if (typeof value === "string") checkVarRefs(value, `${path}.props.${key}`, ctx);
48
+ checkTypeProps(element.type, element.props, path, ctx);
49
+ };
50
+ var checkElementInput = (element, path, ctx, seen) => {
51
+ checkIdRef(element.ref, `${path}.ref`, ctx);
52
+ if (seen.has(element.ref)) ctx.errors.push({
53
+ path: `${path}.ref`,
54
+ message: `Duplicate ref "${element.ref}" in this batch`,
55
+ hint: "Use a unique ref"
56
+ });
57
+ seen.add(element.ref);
58
+ if (!element.type) ctx.errors.push({
59
+ path: `${path}.type`,
60
+ message: "Element type is required",
61
+ hint: "Read plitzi://types for known types"
62
+ });
63
+ 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).`);
64
+ checkElementProps(element, path, ctx);
65
+ element.children?.forEach((child, i) => checkElementInput(child, `${path}.children[${i}]`, ctx, seen));
66
+ };
67
+ //#endregion
68
+ export { checkElementInput, checkRawMarkup, checkTypeProps, checkVariantApplication };
@@ -0,0 +1,8 @@
1
+ import { ValidationCtx, ValidationMode } from './context';
2
+ import { Space } from '../../../helpers';
3
+ import { ValidationResult } from '../../../types';
4
+ import { Operation } from '../../operations';
5
+ /** The shared validation context, derived from a space (+ the batch's ops, for batch-declared names). Extracted so
6
+ * the post-apply resource audit (auditResources) can run the same checks against the resulting draft. */
7
+ export declare const buildValidationCtx: (space: Space, ops: Operation[], mode?: ValidationMode) => ValidationCtx;
8
+ export declare const validateOperations: (space: Space, ops: Operation[], mode?: ValidationMode) => ValidationResult;
@@ -0,0 +1,268 @@
1
+ import { BUILTIN_COMPONENTS } from "../../../catalogs/builtinComponents.js";
2
+ import { observedDataSources, observedInteractionActions } from "../../../catalogs/observed.js";
3
+ import { buildTypeRegistry } from "../../../catalogs/registry.js";
4
+ import { findElementByRef, findFolderByRef, findPageByRef, folderAncestorIds, getPageElements, pageFoldersOf, pageRefOf, resolveRef, routeParamNames } from "../../../helpers/space.js";
5
+ import { MAX_OPS } from "../../operations/index.js";
6
+ import { batchDeclaredFolders, batchDeclaredPages, batchDeclaredVariants, batchDeclaredVars } from "./batch.js";
7
+ import { checkObservedName, checkVarRefs, warnOnce } from "./context.js";
8
+ import { checkBindingSourceScope, checkBindingTarget, checkBindingTransformers } from "./bindings.js";
9
+ import { batchDeclaredConnectors, checkConnectorOp, checkProviderElement } from "./connectors.js";
10
+ import { checkSlotCss } from "./css.js";
11
+ import { checkRef } from "./refs.js";
12
+ import { checkElementInput, checkRawMarkup, checkTypeProps, checkVariantApplication } from "./elements.js";
13
+ import { checkInteractionNode } from "./interactions.js";
14
+ //#region src/modules/mcp/tools/shared/validator/index.ts
15
+ var STYLE_CATEGORIES = [
16
+ "color",
17
+ "spacing",
18
+ "shadow",
19
+ "custom"
20
+ ];
21
+ /** The element type that reads through a connector. Only this one carries the connector attributes, so only it is
22
+ * worth cross-checking against the connector store. */
23
+ var PROVIDER_TYPE = "apiContainer";
24
+ var buildTypeMeta = (catalog) => {
25
+ const meta = /* @__PURE__ */ new Map();
26
+ for (const [type, entry] of Object.entries(catalog ?? {})) {
27
+ const bindingsAllowed = entry.bindingsAllowed;
28
+ meta.set(type, {
29
+ attributes: new Set(entry.attributes ?? []),
30
+ styleSelectors: new Set(entry.styleSelectors ?? []),
31
+ custom: entry.custom ?? false,
32
+ ...bindingsAllowed ? { bindingTargets: {
33
+ attributes: new Set(bindingsAllowed.attributes ?? []),
34
+ initialState: new Set(bindingsAllowed.initialState ?? [])
35
+ } } : {}
36
+ });
37
+ }
38
+ return meta;
39
+ };
40
+ /** The shared validation context, derived from a space (+ the batch's ops, for batch-declared names). Extracted so
41
+ * the post-apply resource audit (auditResources) can run the same checks against the resulting draft. */
42
+ var buildValidationCtx = (space, ops, mode = "space") => {
43
+ const registry = buildTypeRegistry(space.schema, space.catalog);
44
+ return {
45
+ mode,
46
+ errors: [],
47
+ warnings: [],
48
+ warned: /* @__PURE__ */ new Set(),
49
+ knownTypes: /* @__PURE__ */ new Set([...Object.keys(registry.types), ...Object.keys(BUILTIN_COMPONENTS)]),
50
+ typeProps: new Map(Object.entries(registry.types).map(([type, info]) => [type, new Set(Object.keys(info.props))])),
51
+ typeMeta: buildTypeMeta(space.catalog),
52
+ elementType: (ref) => (findElementByRef(space.schema, ref) ?? findPageByRef(space.schema, ref))?.definition.type,
53
+ schemaVars: /* @__PURE__ */ new Set([
54
+ ...space.schema.variables.map((v) => v.name),
55
+ ...routeParamNames(space.schema),
56
+ ...batchDeclaredVars(ops)
57
+ ]),
58
+ styleVars: new Set(Object.values(space.style.variables).flatMap((group) => Object.keys(group))),
59
+ style: space.style,
60
+ batchVariants: batchDeclaredVariants(ops),
61
+ observedActions: observedInteractionActions(space.schema),
62
+ observedSources: observedDataSources(space.schema)
63
+ };
64
+ };
65
+ var validateOperations = (space, ops, mode = "space") => {
66
+ const batchPages = batchDeclaredPages(ops);
67
+ const batchFolders = batchDeclaredFolders(ops);
68
+ const batchConnectors = batchDeclaredConnectors(ops);
69
+ const folderRefs = () => pageFoldersOf(space.schema).map((f) => f.id);
70
+ const ctx = buildValidationCtx(space, ops, mode);
71
+ const checkProviders = (input, base) => {
72
+ if (input.type === PROVIDER_TYPE) checkProviderElement(space, ctx, input.ref, input.runtime, input.props, batchConnectors, base);
73
+ (input.children ?? []).forEach((child, i) => checkProviders(child, `${base}.children[${i}]`));
74
+ };
75
+ if (ops.length > 1e3) ctx.errors.push({
76
+ path: "operations",
77
+ message: `Batch has ${ops.length} operations (max ${MAX_OPS})`,
78
+ hint: `Split into batches of at most ${MAX_OPS}`
79
+ });
80
+ ops.forEach((op, i) => {
81
+ const base = `operations[${i}]`;
82
+ 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) {
83
+ if (!findPageByRef(space.schema, op.pageRef) && !batchPages.has(op.pageRef)) {
84
+ const validRefs = getPageElements(space.schema).map(pageRefOf);
85
+ ctx.errors.push({
86
+ path: `${base}.pageRef`,
87
+ message: `Page "${op.pageRef}" does not exist`,
88
+ hint: "Use an existing page ref, or create it with upsertPage earlier in the same batch",
89
+ validValues: validRefs
90
+ });
91
+ }
92
+ }
93
+ switch (op.type) {
94
+ case "upsertElement":
95
+ checkElementInput(op.element, `${base}.element`, ctx, /* @__PURE__ */ new Set());
96
+ checkVariantApplication(op.element.initialState, `${base}.element.initialState`, ctx);
97
+ checkProviders(op.element, `${base}.element`);
98
+ break;
99
+ case "patchElement": {
100
+ checkRef(op.ref, `${base}.ref`, ctx);
101
+ const page = findPageByRef(space.schema, op.pageRef);
102
+ const target = page ? resolveRef(space.schema, page, op.ref) : void 0;
103
+ if (op.props) {
104
+ for (const [key, value] of Object.entries(op.props)) if (typeof value === "string") checkVarRefs(value, `${base}.props.${key}`, ctx);
105
+ if (target && target.id !== page?.id) {
106
+ checkRawMarkup(target.definition.type, op.props, base, ctx);
107
+ checkTypeProps(target.definition.type, op.props, base, ctx);
108
+ }
109
+ }
110
+ checkVariantApplication(op.initialState, `${base}.initialState`, ctx);
111
+ if (target && target.definition.type === PROVIDER_TYPE) checkProviderElement(space, ctx, op.ref, op.runtime ?? target.definition.runtime, {
112
+ ...target.attributes,
113
+ ...op.props
114
+ }, batchConnectors, base);
115
+ break;
116
+ }
117
+ case "upsertDefinitions": {
118
+ const entries = Object.entries(op.definitions);
119
+ if (entries.length === 0) ctx.errors.push({
120
+ path: `${base}.definitions`,
121
+ message: "This operation declares no classes",
122
+ hint: "Key each class by its name: { \"definitions\": { \"card\": { \"desktop\": { … } } } }"
123
+ });
124
+ for (const [ref, { slots, ...slot }] of entries) {
125
+ const entry = `${base}.definitions.${ref}`;
126
+ checkRef(ref, entry, ctx);
127
+ checkSlotCss(slot, entry, ctx);
128
+ for (const [slotName, slotDef] of Object.entries(slots ?? {})) checkSlotCss(slotDef, `${entry}.slots.${slotName}`, ctx);
129
+ }
130
+ break;
131
+ }
132
+ case "upsertDefinition":
133
+ case "patchDefinition": {
134
+ const { type, ref, slots, ...slot } = op;
135
+ checkRef(ref, `${base}.ref`, ctx);
136
+ checkSlotCss(slot, base, ctx);
137
+ for (const [slotName, slotDef] of Object.entries(slots ?? {})) checkSlotCss(slotDef, `${base}.slots.${slotName}`, ctx);
138
+ break;
139
+ }
140
+ case "upsertGlobalStyle":
141
+ case "patchGlobalStyle": {
142
+ const { type, componentType, slots, ...slot } = op;
143
+ checkRef(componentType, `${base}.componentType`, ctx);
144
+ checkSlotCss(slot, base, ctx);
145
+ for (const [slotName, slotDef] of Object.entries(slots ?? {})) checkSlotCss(slotDef, `${base}.slots.${slotName}`, ctx);
146
+ break;
147
+ }
148
+ case "deleteGlobalStyle":
149
+ checkRef(op.componentType, `${base}.componentType`, ctx);
150
+ break;
151
+ case "upsertPage":
152
+ checkRef(op.ref, `${base}.ref`, ctx);
153
+ 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.`);
154
+ if (typeof op.folder === "string" && op.folder !== "") {
155
+ if (!findFolderByRef(space.schema, op.folder) && !batchFolders.has(op.folder)) ctx.errors.push({
156
+ path: `${base}.folder`,
157
+ message: `Folder "${op.folder}" does not exist`,
158
+ hint: "Create it with upsertFolder earlier in the same batch, or read plitzi://folders for valid refs",
159
+ validValues: folderRefs()
160
+ });
161
+ }
162
+ break;
163
+ case "upsertFolder":
164
+ checkRef(op.ref, `${base}.ref`, ctx);
165
+ if (typeof op.parentId === "string") {
166
+ checkRef(op.parentId, `${base}.parentId`, ctx);
167
+ const parent = findFolderByRef(space.schema, op.parentId);
168
+ if (!parent && !batchFolders.has(op.parentId)) ctx.errors.push({
169
+ path: `${base}.parentId`,
170
+ message: `Parent folder "${op.parentId}" does not exist`,
171
+ hint: "Create the parent with upsertFolder first, or read plitzi://folders for valid refs",
172
+ validValues: folderRefs()
173
+ });
174
+ const selfId = findFolderByRef(space.schema, op.ref)?.id ?? op.ref;
175
+ if ((parent?.id ?? op.parentId) === selfId || parent && folderAncestorIds(pageFoldersOf(space.schema), parent.id).includes(selfId)) ctx.errors.push({
176
+ path: `${base}.parentId`,
177
+ message: `Folder "${op.ref}" cannot be nested under itself or one of its descendants`,
178
+ hint: "Choose a parent that is not this folder or below it"
179
+ });
180
+ }
181
+ break;
182
+ case "deleteDefinition":
183
+ case "deleteFolder":
184
+ case "deletePage":
185
+ case "upsertVariable":
186
+ case "deleteVariable":
187
+ checkRef("ref" in op ? op.ref : op.name, `${base}.${"ref" in op ? "ref" : "name"}`, ctx);
188
+ break;
189
+ case "upsertStyleVariable":
190
+ case "deleteStyleVariable":
191
+ if (!STYLE_CATEGORIES.includes(op.category)) ctx.errors.push({
192
+ path: `${base}.category`,
193
+ message: `Unknown style-variable category "${op.category}"`,
194
+ hint: "Use one of the valid categories",
195
+ validValues: STYLE_CATEGORIES
196
+ });
197
+ break;
198
+ case "upsertBinding":
199
+ checkRef(op.ref, `${base}.ref`, ctx);
200
+ checkObservedName(op.binding.source, ctx.observedSources, "Data source", "plitzi://data-sources", `${base}.binding.source`, ctx);
201
+ checkBindingTarget(op.ref, op.category, op.binding.to, `${base}.binding.to`, ctx);
202
+ checkBindingSourceScope(space, ctx, op.ref, op.binding.source, `${base}.binding.source`);
203
+ checkBindingTransformers(op.binding.transformers, `${base}.binding.transformers`, ctx);
204
+ break;
205
+ case "patchBinding":
206
+ checkRef(op.ref, `${base}.ref`, ctx);
207
+ checkObservedName(op.source, ctx.observedSources, "Data source", "plitzi://data-sources", `${base}.source`, ctx);
208
+ checkBindingTarget(op.ref, op.category, op.to, `${base}.to`, ctx);
209
+ if (op.source !== void 0) checkBindingSourceScope(space, ctx, op.ref, op.source, `${base}.source`);
210
+ checkBindingTransformers(op.transformers, `${base}.transformers`, ctx);
211
+ break;
212
+ case "deleteBinding":
213
+ checkRef(op.ref, `${base}.ref`, ctx);
214
+ break;
215
+ case "upsertInteractionFlow":
216
+ checkRef(op.ref, `${base}.ref`, ctx);
217
+ if (op.nodes[0] && op.nodes[0].nodeType !== "trigger") ctx.errors.push({
218
+ path: `${base}.nodes[0].nodeType`,
219
+ message: "The first node of a flow must be a trigger",
220
+ hint: "Put the trigger first; the callbacks/utilities that run after it follow in order"
221
+ });
222
+ op.nodes.forEach((node, n) => checkInteractionNode(node, `${base}.nodes[${n}]`, ctx, op.ref));
223
+ break;
224
+ case "patchInteractionNode": {
225
+ checkRef(op.ref, `${base}.ref`, ctx);
226
+ const existing = findElementByRef(space.schema, op.ref)?.definition.interactions?.[op.nodeId];
227
+ if (existing) {
228
+ const merged = {
229
+ id: existing.id,
230
+ title: op.title ?? existing.title,
231
+ nodeType: existing.type,
232
+ action: op.action ?? existing.action,
233
+ params: {
234
+ ...existing.params,
235
+ ...op.params ?? {}
236
+ },
237
+ enabled: op.enabled ?? existing.enabled,
238
+ elementId: op.elementId ?? existing.elementId ?? void 0
239
+ };
240
+ checkInteractionNode(merged, base, ctx, op.ref);
241
+ } else checkObservedName(op.action, ctx.observedActions, "Interaction action", "plitzi://interactions", `${base}.action`, ctx);
242
+ break;
243
+ }
244
+ case "upsertConnector":
245
+ case "deleteConnector":
246
+ checkRef(op.ref, `${base}.ref`, ctx);
247
+ checkConnectorOp(space, op, base, ctx);
248
+ break;
249
+ case "patchConnector":
250
+ checkRef(op.ref, `${base}.ref`, ctx);
251
+ break;
252
+ case "deleteInteraction":
253
+ checkRef(op.ref, `${base}.ref`, ctx);
254
+ if (Boolean(op.flowId) === Boolean(op.nodeId)) ctx.errors.push({
255
+ path: `${base}.nodeId`,
256
+ message: "Provide exactly one of flowId or nodeId",
257
+ hint: "flowId removes a whole flow; nodeId removes a single step"
258
+ });
259
+ }
260
+ });
261
+ return {
262
+ valid: ctx.errors.length === 0,
263
+ errors: ctx.errors,
264
+ warnings: ctx.warnings
265
+ };
266
+ };
267
+ //#endregion
268
+ export { buildValidationCtx, validateOperations };
@@ -0,0 +1,3 @@
1
+ import { ValidationCtx } from './context';
2
+ import { InteractionNodeInput } from '../../operations/schema/shared';
3
+ export declare const checkInteractionNode: (node: InteractionNodeInput, base: string, ctx: ValidationCtx, hostRef: string) => void;