@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,55 @@
1
+ import { connectorOps } from "./connectors/index.js";
2
+ import { elementOps } from "./schema/operations.js";
3
+ import { registerSharedSchemaIds } from "./schemaIds.js";
4
+ import { styleOps } from "./style/operations.js";
5
+ import { z } from "zod";
6
+ //#region src/modules/mcp/tools/operations/index.ts
7
+ registerSharedSchemaIds();
8
+ var documentOps = [
9
+ elementOps.upsertElement,
10
+ elementOps.repeatElement,
11
+ elementOps.patchElement,
12
+ elementOps.deleteElement,
13
+ elementOps.moveElement,
14
+ elementOps.upsertPage,
15
+ elementOps.deletePage,
16
+ elementOps.upsertFolder,
17
+ elementOps.deleteFolder,
18
+ elementOps.upsertVariable,
19
+ elementOps.deleteVariable,
20
+ elementOps.upsertBinding,
21
+ elementOps.patchBinding,
22
+ elementOps.deleteBinding,
23
+ elementOps.upsertInteractionFlow,
24
+ elementOps.patchInteractionNode,
25
+ elementOps.deleteInteraction,
26
+ elementOps.patchSettings,
27
+ styleOps.upsertDefinition,
28
+ styleOps.upsertDefinitions,
29
+ styleOps.patchDefinition,
30
+ styleOps.deleteDefinition,
31
+ styleOps.upsertGlobalStyle,
32
+ styleOps.patchGlobalStyle,
33
+ styleOps.deleteGlobalStyle,
34
+ styleOps.upsertIdStyle,
35
+ styleOps.patchIdStyle,
36
+ styleOps.deleteIdStyle,
37
+ styleOps.upsertStyleVariable,
38
+ styleOps.deleteStyleVariable
39
+ ];
40
+ var documentOperation = z.discriminatedUnion("type", documentOps);
41
+ var operation = z.discriminatedUnion("type", [
42
+ ...documentOps,
43
+ connectorOps.upsertConnector,
44
+ connectorOps.patchConnector,
45
+ connectorOps.deleteConnector
46
+ ]);
47
+ var STYLE_OP_TYPES = new Set(Object.keys(styleOps));
48
+ new Set(Object.keys(connectorOps));
49
+ var isStyleOp = (type) => STYLE_OP_TYPES.has(type);
50
+ var MAX_OPS = 1e3;
51
+ var environment = z.string().optional().describe("Environment; default main");
52
+ var operations = z.array(operation).max(MAX_OPS).describe(`Operations applied atomically, in order (max ${MAX_OPS})`);
53
+ var documentOperations = z.array(documentOperation).max(MAX_OPS).describe(`Operations applied atomically, in order (max ${MAX_OPS})`);
54
+ //#endregion
55
+ export { MAX_OPS, documentOperation, documentOperations, environment, isStyleOp, operation, operations };
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ import { OpResult, Space } from '../../../../helpers';
3
+ import { Env } from '../../../../types';
4
+ export declare const deleteBindingOp: z.ZodObject<{
5
+ type: z.ZodLiteral<"deleteBinding">;
6
+ pageRef: z.ZodString;
7
+ ref: z.ZodString;
8
+ category: z.ZodEnum<{
9
+ attributes: "attributes";
10
+ style: "style";
11
+ initialState: "initialState";
12
+ }>;
13
+ to: z.ZodString;
14
+ id: z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strip>;
16
+ export type DeleteBinding = z.infer<typeof deleteBindingOp>;
17
+ export declare const deleteBinding: (space: Space, env: Env, op: DeleteBinding) => OpResult;
@@ -0,0 +1,32 @@
1
+ import { pageUri } from "../../../../helpers/uris.js";
2
+ import { empty, fail } from "../../../../helpers/opResult.js";
3
+ import { bindingCategory } from "../shared.js";
4
+ import { resolveElement } from "../write.js";
5
+ import { z } from "zod";
6
+ //#region src/modules/mcp/tools/operations/schema/bindings/deleteBinding.ts
7
+ var deleteBindingOp = z.object({
8
+ type: z.literal("deleteBinding"),
9
+ pageRef: z.string().describe("Page ref or id"),
10
+ ref: z.string().describe("Element ref or id"),
11
+ category: bindingCategory,
12
+ to: z.string().describe("Target of the binding to remove"),
13
+ id: z.string().optional().describe("Match by id instead of to")
14
+ }).describe("Remove a data binding from an element (matched by id when given, else by to). Fails if none matches.");
15
+ var deleteBinding = (space, env, op) => {
16
+ const found = resolveElement(space, env, op.pageRef, op.ref);
17
+ if ("error" in found) return found.error;
18
+ const bindings = found.el.definition.bindings;
19
+ const list = bindings?.[op.category];
20
+ const index = list ? list.findIndex((b) => op.id ? b.id === op.id : b.to === op.to) : -1;
21
+ if (!bindings || !list || index < 0) return fail("to", `No ${op.category} binding matching "${op.id ?? op.to}" on "${op.ref}"`, "Nothing to delete");
22
+ list.splice(index, 1);
23
+ if (list.length === 0) Reflect.deleteProperty(bindings, op.category);
24
+ return {
25
+ ...empty(),
26
+ deleted: 1,
27
+ staleResources: [pageUri(env, op.pageRef)],
28
+ elementRefs: [op.ref]
29
+ };
30
+ };
31
+ //#endregion
32
+ export { deleteBinding, deleteBindingOp };
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+ import { OpResult, Space } from '../../../../helpers';
3
+ import { Env } from '../../../../types';
4
+ export declare const patchBindingOp: z.ZodObject<{
5
+ type: z.ZodLiteral<"patchBinding">;
6
+ pageRef: z.ZodString;
7
+ ref: z.ZodString;
8
+ category: z.ZodEnum<{
9
+ attributes: "attributes";
10
+ style: "style";
11
+ initialState: "initialState";
12
+ }>;
13
+ to: z.ZodString;
14
+ id: z.ZodOptional<z.ZodString>;
15
+ source: z.ZodOptional<z.ZodString>;
16
+ transformers: z.ZodOptional<z.ZodArray<z.ZodObject<{
17
+ action: z.ZodString;
18
+ params: z.ZodRecord<z.ZodString, z.ZodString>;
19
+ enabled: z.ZodOptional<z.ZodBoolean>;
20
+ }, z.core.$strip>>>;
21
+ when: z.ZodOptional<z.ZodType<import('@plitzi/plitzi-ui/components/QueryBuilder').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/plitzi-ui/components/QueryBuilder').RuleGroup, unknown>>>;
22
+ enabled: z.ZodOptional<z.ZodBoolean>;
23
+ }, z.core.$strip>;
24
+ export type PatchBinding = z.infer<typeof patchBindingOp>;
25
+ export declare const patchBinding: (space: Space, env: Env, op: PatchBinding) => OpResult;
@@ -0,0 +1,36 @@
1
+ import { pageUri } from "../../../../helpers/uris.js";
2
+ import { empty, fail } from "../../../../helpers/opResult.js";
3
+ import { bindingCategory, bindingInput } from "../shared.js";
4
+ import { resolveElement } from "../write.js";
5
+ import { z } from "zod";
6
+ //#region src/modules/mcp/tools/operations/schema/bindings/patchBinding.ts
7
+ var patchBindingOp = z.object({
8
+ type: z.literal("patchBinding"),
9
+ pageRef: z.string().describe("Page ref or id"),
10
+ ref: z.string().describe("Element ref or id"),
11
+ category: bindingCategory,
12
+ to: z.string().describe("Target of the binding to patch"),
13
+ id: z.string().optional().describe("Match by id instead of to"),
14
+ source: bindingInput.shape.source.optional(),
15
+ transformers: bindingInput.shape.transformers,
16
+ when: bindingInput.shape.when,
17
+ enabled: bindingInput.shape.enabled
18
+ }).describe("Partially update an EXISTING binding (matched by id when given, else by to): only the fields you pass change. Never creates — fails if no binding matches.");
19
+ var patchBinding = (space, env, op) => {
20
+ const found = resolveElement(space, env, op.pageRef, op.ref);
21
+ if ("error" in found) return found.error;
22
+ const binding = (found.el.definition.bindings?.[op.category])?.find((b) => op.id ? b.id === op.id : b.to === op.to);
23
+ if (!binding) return fail("to", `No ${op.category} binding matching "${op.id ?? op.to}" on "${op.ref}"`, "Use upsertBinding to add it");
24
+ if (op.source !== void 0) binding.source = op.source;
25
+ if (op.transformers !== void 0) binding.transformers = op.transformers;
26
+ if (op.when !== void 0) binding.when = op.when;
27
+ if (op.enabled !== void 0) binding.enabled = op.enabled;
28
+ return {
29
+ ...empty(),
30
+ updated: 1,
31
+ staleResources: [pageUri(env, op.pageRef)],
32
+ elementRefs: [op.ref]
33
+ };
34
+ };
35
+ //#endregion
36
+ export { patchBinding, patchBindingOp };
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import { OpResult, Space } from '../../../../helpers';
3
+ import { Env } from '../../../../types';
4
+ export declare const upsertBindingOp: z.ZodObject<{
5
+ type: z.ZodLiteral<"upsertBinding">;
6
+ pageRef: z.ZodString;
7
+ ref: z.ZodString;
8
+ category: z.ZodEnum<{
9
+ attributes: "attributes";
10
+ style: "style";
11
+ initialState: "initialState";
12
+ }>;
13
+ binding: z.ZodObject<{
14
+ to: z.ZodString;
15
+ source: z.ZodString;
16
+ id: z.ZodOptional<z.ZodString>;
17
+ transformers: z.ZodOptional<z.ZodArray<z.ZodObject<{
18
+ action: z.ZodString;
19
+ params: z.ZodRecord<z.ZodString, z.ZodString>;
20
+ enabled: z.ZodOptional<z.ZodBoolean>;
21
+ }, z.core.$strip>>>;
22
+ when: z.ZodOptional<z.ZodType<import('@plitzi/plitzi-ui/components/QueryBuilder').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/plitzi-ui/components/QueryBuilder').RuleGroup, unknown>>>;
23
+ enabled: z.ZodOptional<z.ZodBoolean>;
24
+ }, z.core.$strip>;
25
+ }, z.core.$strip>;
26
+ export type UpsertBinding = z.infer<typeof upsertBindingOp>;
27
+ export declare const upsertBinding: (space: Space, env: Env, op: UpsertBinding) => OpResult;
@@ -0,0 +1,47 @@
1
+ import { generateObjectId } from "../../../../helpers/space.js";
2
+ import { pageUri } from "../../../../helpers/uris.js";
3
+ import { empty } from "../../../../helpers/opResult.js";
4
+ import { bindingCategory, bindingInput } from "../shared.js";
5
+ import { resolveElement } from "../write.js";
6
+ import { z } from "zod";
7
+ //#region src/modules/mcp/tools/operations/schema/bindings/upsertBinding.ts
8
+ var upsertBindingOp = z.object({
9
+ type: z.literal("upsertBinding"),
10
+ pageRef: z.string().describe("Page ref or id"),
11
+ ref: z.string().describe("Element ref or id"),
12
+ category: bindingCategory,
13
+ binding: bindingInput
14
+ }).describe("Add a data binding to an element, or replace the one already feeding the same target (matched by binding.id when given, else by binding.to). Connects a data source to a prop, style value, or initialState key.");
15
+ var upsertBinding = (space, env, op) => {
16
+ const found = resolveElement(space, env, op.pageRef, op.ref);
17
+ if ("error" in found) return found.error;
18
+ const bindings = found.el.definition.bindings ??= {};
19
+ const list = bindings[op.category] ??= [];
20
+ const index = list.findIndex((b) => op.binding.id ? b.id === op.binding.id : b.to === op.binding.to);
21
+ const binding = {
22
+ id: op.binding.id ?? (index >= 0 ? list[index].id : generateObjectId()),
23
+ to: op.binding.to,
24
+ source: op.binding.source
25
+ };
26
+ if (op.binding.transformers) binding.transformers = op.binding.transformers;
27
+ if (op.binding.when !== void 0) binding.when = op.binding.when;
28
+ if (op.binding.enabled !== void 0) binding.enabled = op.binding.enabled;
29
+ if (index >= 0) {
30
+ list[index] = binding;
31
+ return {
32
+ ...empty(),
33
+ updated: 1,
34
+ staleResources: [pageUri(env, op.pageRef)],
35
+ elementRefs: [op.ref]
36
+ };
37
+ }
38
+ list.push(binding);
39
+ return {
40
+ ...empty(),
41
+ created: 1,
42
+ staleResources: [pageUri(env, op.pageRef)],
43
+ elementRefs: [op.ref]
44
+ };
45
+ };
46
+ //#endregion
47
+ export { upsertBinding, upsertBindingOp };
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ import { Space, OpResult } from '../../../../helpers';
3
+ import { Env } from '../../../../types';
4
+ export declare const deleteElementOp: z.ZodObject<{
5
+ type: z.ZodLiteral<"deleteElement">;
6
+ pageRef: z.ZodString;
7
+ ref: z.ZodString;
8
+ }, z.core.$strip>;
9
+ export type DeleteElement = z.infer<typeof deleteElementOp>;
10
+ export declare const deleteElement: (space: Space, env: Env, op: DeleteElement) => OpResult;
@@ -0,0 +1,29 @@
1
+ import { descendantIds, findPageByRef, indexRemoveElements, resolveRef } from "../../../../helpers/space.js";
2
+ import { pageUri } from "../../../../helpers/uris.js";
3
+ import { empty, fail } from "../../../../helpers/opResult.js";
4
+ import { removeFromParent } from "../write.js";
5
+ import { z } from "zod";
6
+ //#region src/modules/mcp/tools/operations/schema/elements/deleteElement.ts
7
+ var deleteElementOp = z.object({
8
+ type: z.literal("deleteElement"),
9
+ pageRef: z.string().describe("Page ref or id"),
10
+ ref: z.string().describe("Ref or id of the element to delete")
11
+ }).describe("Delete an element and all of its descendants from a page.");
12
+ var deleteElement = (space, env, op) => {
13
+ const page = findPageByRef(space.schema, op.pageRef);
14
+ if (!page) return fail("pageRef", `Page "${op.pageRef}" not found`, "Read the pages resource for valid refs");
15
+ const el = resolveRef(space.schema, page, op.ref);
16
+ if (!el || el.id === page.id) return fail("ref", `Element "${op.ref}" not found in page "${op.pageRef}"`, "Read the page resource for valid refs");
17
+ const ids = [...descendantIds(space.schema, el.id), el.id];
18
+ const removed = ids.map((id) => space.schema.flat[id]);
19
+ for (const id of ids) Reflect.deleteProperty(space.schema.flat, id);
20
+ removeFromParent(space, el);
21
+ indexRemoveElements(space.schema, removed);
22
+ return {
23
+ ...empty(),
24
+ deleted: 1,
25
+ staleResources: [pageUri(env, op.pageRef)]
26
+ };
27
+ };
28
+ //#endregion
29
+ export { deleteElement, deleteElementOp };
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ import { Space, OpResult } from '../../../../helpers';
3
+ import { Env } from '../../../../types';
4
+ export declare const moveElementOp: z.ZodObject<{
5
+ type: z.ZodLiteral<"moveElement">;
6
+ pageRef: z.ZodString;
7
+ ref: z.ZodString;
8
+ toParentRef: z.ZodString;
9
+ position: z.ZodEnum<{
10
+ inside: "inside";
11
+ before: "before";
12
+ after: "after";
13
+ }>;
14
+ }, z.core.$strip>;
15
+ export type MoveElement = z.infer<typeof moveElementOp>;
16
+ export declare const moveElement: (space: Space, env: Env, op: MoveElement) => OpResult;
@@ -0,0 +1,41 @@
1
+ import { findPageByRef, indexInvalidateDetails, resolveRef } from "../../../../helpers/space.js";
2
+ import { pageUri } from "../../../../helpers/uris.js";
3
+ import { empty, fail } from "../../../../helpers/opResult.js";
4
+ import { position } from "../shared.js";
5
+ import { placeChild, removeFromParent } from "../write.js";
6
+ import { z } from "zod";
7
+ //#region src/modules/mcp/tools/operations/schema/elements/moveElement.ts
8
+ var moveElementOp = z.object({
9
+ type: z.literal("moveElement"),
10
+ pageRef: z.string().describe("Page ref or id"),
11
+ ref: z.string().describe("Ref or id of the element to move"),
12
+ toParentRef: z.string().describe("Ref or id of the anchor the element moves relative to (see position)"),
13
+ position
14
+ }).describe("Move an existing element to a new parent, or reorder it — its placement is set by position.");
15
+ var moveElement = (space, env, op) => {
16
+ const page = findPageByRef(space.schema, op.pageRef);
17
+ if (!page) return fail("pageRef", `Page "${op.pageRef}" not found`, "Read the pages resource for valid refs");
18
+ const el = resolveRef(space.schema, page, op.ref);
19
+ const anchor = resolveRef(space.schema, page, op.toParentRef);
20
+ if (!el || el.id === page.id) return fail("ref", `Element "${op.ref}" not found`, "Read the page resource for valid refs");
21
+ if (!anchor) return fail("toParentRef", `Target "${op.toParentRef}" not found`, "Read the page resource for valid refs");
22
+ removeFromParent(space, el);
23
+ let parent = anchor;
24
+ let index;
25
+ if (op.position === "before" || op.position === "after") {
26
+ parent = anchor.definition.parentId ? space.schema.flat[anchor.definition.parentId] ?? page : page;
27
+ const at = (parent.definition.items ?? []).indexOf(anchor.id);
28
+ index = at < 0 ? void 0 : op.position === "after" ? at + 1 : at;
29
+ }
30
+ el.definition.parentId = parent.id;
31
+ placeChild(parent, el.id, index);
32
+ indexInvalidateDetails(space.schema);
33
+ return {
34
+ ...empty(),
35
+ updated: 1,
36
+ staleResources: [pageUri(env, op.pageRef)],
37
+ elementRefs: [op.ref]
38
+ };
39
+ };
40
+ //#endregion
41
+ export { moveElement, moveElementOp };
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import { Space, OpResult } from '../../../../helpers';
3
+ import { Env } from '../../../../types';
4
+ export declare const patchElementOp: z.ZodObject<{
5
+ type: z.ZodLiteral<"patchElement">;
6
+ pageRef: z.ZodString;
7
+ ref: z.ZodString;
8
+ idRef: z.ZodOptional<z.ZodString>;
9
+ label: z.ZodOptional<z.ZodString>;
10
+ subType: z.ZodOptional<z.ZodString>;
11
+ props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
12
+ style: z.ZodOptional<z.ZodObject<{
13
+ base: z.ZodOptional<z.ZodArray<z.ZodString>>;
14
+ slots: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
15
+ }, z.core.$strip>>;
16
+ initialState: z.ZodOptional<z.ZodObject<{
17
+ styleVariant: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>>;
18
+ visibility: z.ZodOptional<z.ZodBoolean>;
19
+ }, z.core.$strip>>;
20
+ runtime: z.ZodOptional<z.ZodEnum<{
21
+ server: "server";
22
+ client: "client";
23
+ shared: "shared";
24
+ }>>;
25
+ }, z.core.$strip>;
26
+ export type PatchElement = z.infer<typeof patchElementOp>;
27
+ export declare const patchElement: (space: Space, env: Env, op: PatchElement) => OpResult;
@@ -0,0 +1,60 @@
1
+ import { findPageByRef, resolveRef } from "../../../../helpers/space.js";
2
+ import { pageUri } from "../../../../helpers/uris.js";
3
+ import { empty, fail } from "../../../../helpers/opResult.js";
4
+ import { elementRuntime, initialStateInput, styleRefs } from "../shared.js";
5
+ import { guardNewRef, writeInitialState } from "../write.js";
6
+ import { z } from "zod";
7
+ import { repointIdRefs } from "@plitzi/sdk-schema/helpers/idRef";
8
+ //#region src/modules/mcp/tools/operations/schema/elements/patchElement.ts
9
+ var patchElementOp = z.object({
10
+ type: z.literal("patchElement"),
11
+ pageRef: z.string().describe("Page ref or id"),
12
+ ref: z.string().describe("Existing element ref or id"),
13
+ idRef: z.string().optional().describe("Assign or rename this element idRef ([A-Za-z0-9_-], starting with a letter, unique in the space). Without one an element publishes no data source, so it is not bindable. A rename moves the source name with it: every binding and interaction that targeted the old one is repointed for you."),
14
+ label: z.string().optional(),
15
+ subType: z.string().optional(),
16
+ props: z.record(z.string(), z.unknown()).optional().describe("Merged onto existing props: listed keys change, null unsets a key, others are preserved"),
17
+ style: styleRefs.optional().describe("Merged onto existing style: base replaces base, listed slots replace slots"),
18
+ initialState: initialStateInput.optional().describe("Merged onto existing initialState: styleVariant overlays per class/selector, visibility overrides"),
19
+ runtime: elementRuntime.optional()
20
+ }).describe("Partially update an EXISTING element: only the fields you pass change (props/style/initialState are merged, not replaced). Never creates — fails if ref does not resolve. Use upsertElement to create or fully replace.");
21
+ var patchElement = (space, env, op) => {
22
+ const page = findPageByRef(space.schema, op.pageRef);
23
+ if (!page) return fail("pageRef", `Page "${op.pageRef}" not found`, "Read plitzi://schema/" + env + "/pages for valid refs");
24
+ const el = resolveRef(space.schema, page, op.ref);
25
+ if (!el || el.id === page.id) return fail("ref", `Element "${op.ref}" not found in page "${op.pageRef}"`, "patchElement only updates an existing element; use upsertElement to create one");
26
+ if (op.idRef !== void 0 && op.idRef !== el.idRef) {
27
+ const guard = guardNewRef(space, op.idRef, "idRef");
28
+ if (guard) return guard;
29
+ const previous = el.idRef;
30
+ el.idRef = op.idRef;
31
+ if (previous) repointIdRefs(space.schema.flat, { [previous]: op.idRef });
32
+ }
33
+ if (op.label !== void 0) el.definition.label = op.label;
34
+ if (op.subType !== void 0) el.attributes = {
35
+ ...el.attributes,
36
+ subType: op.subType
37
+ };
38
+ if (op.props !== void 0) {
39
+ const merged = { ...el.attributes };
40
+ for (const [key, value] of Object.entries(op.props)) if (value === null) Reflect.deleteProperty(merged, key);
41
+ else merged[key] = value;
42
+ el.attributes = merged;
43
+ }
44
+ if (op.style !== void 0) {
45
+ const selectors = { ...el.definition.styleSelectors };
46
+ if (op.style.base !== void 0) selectors.base = op.style.base.join(" ");
47
+ for (const [slot, classes] of Object.entries(op.style.slots ?? {})) selectors[slot] = classes.join(" ");
48
+ el.definition.styleSelectors = selectors;
49
+ }
50
+ if (op.initialState !== void 0) writeInitialState(el, op.initialState, true);
51
+ if (op.runtime !== void 0) el.definition.runtime = op.runtime;
52
+ return {
53
+ ...empty(),
54
+ updated: 1,
55
+ staleResources: [pageUri(env, op.pageRef)],
56
+ elementRefs: [op.ref]
57
+ };
58
+ };
59
+ //#endregion
60
+ export { patchElement, patchElementOp };
@@ -0,0 +1,55 @@
1
+ import { z } from 'zod';
2
+ import { ValidationError } from '../../../../types';
3
+ import { ElementInput } from '../shared';
4
+ /** An element of the template. Same shape as any element, plus the one thing only a template may carry: `repeat`,
5
+ * which turns the node into a wrapper whose children are a sub-template rendered once per entry of a list living
6
+ * in the current row. */
7
+ export interface TemplateElement {
8
+ ref: string;
9
+ type: string;
10
+ label?: string;
11
+ subType?: string;
12
+ props?: Record<string, unknown>;
13
+ style?: {
14
+ base?: string[];
15
+ slots?: Record<string, string[]>;
16
+ };
17
+ initialState?: {
18
+ styleVariant?: Record<string, Record<string, string | string[]>>;
19
+ visibility?: boolean;
20
+ };
21
+ children?: TemplateElement[];
22
+ /** The sub-template is a PLAIN element tree: one level of nesting, no repeat inside a repeat inside a repeat.
23
+ * That is also what keeps the op expressible as JSON Schema — a template that could nest itself without limit
24
+ * makes the tool schema infinitely recursive, and a host that reads it blows its stack. */
25
+ repeat?: {
26
+ items: string;
27
+ template: ElementInput;
28
+ };
29
+ }
30
+ export declare const repeatElementOp: z.ZodObject<{
31
+ type: z.ZodLiteral<"repeatElement">;
32
+ pageRef: z.ZodString;
33
+ ref: z.ZodString;
34
+ elementType: z.ZodOptional<z.ZodString>;
35
+ label: z.ZodOptional<z.ZodString>;
36
+ style: z.ZodOptional<z.ZodObject<{
37
+ base: z.ZodOptional<z.ZodArray<z.ZodString>>;
38
+ slots: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
39
+ }, z.core.$strip>>;
40
+ parentRef: z.ZodOptional<z.ZodString>;
41
+ position: z.ZodOptional<z.ZodEnum<{
42
+ inside: "inside";
43
+ before: "before";
44
+ after: "after";
45
+ }>>;
46
+ template: z.ZodType<TemplateElement, unknown, z.core.$ZodTypeInternals<TemplateElement, unknown>>;
47
+ items: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
48
+ }, z.core.$strip>;
49
+ export type RepeatElement = z.infer<typeof repeatElementOp>;
50
+ /** Expand one repeat into the single upsertElement it stands for: the wrapper, with the template rendered once per
51
+ * row as its children. Returns the errors instead of throwing, so a bad row reads like every other op error. */
52
+ export declare const expandRepeat: (op: RepeatElement) => {
53
+ element?: ElementInput;
54
+ errors: ValidationError[];
55
+ };
@@ -0,0 +1,148 @@
1
+ import { elementInput, elementShape, position, styleRefs } from "../shared.js";
2
+ import { z } from "zod";
3
+ //#region src/modules/mcp/tools/operations/schema/elements/repeatElement.ts
4
+ var item = z.record(z.string(), z.unknown());
5
+ var MAX_ITEMS = 100;
6
+ var MAX_ROWS = 500;
7
+ var templateElement = z.lazy(() => z.object({
8
+ ...elementShape,
9
+ children: z.array(templateElement).optional(),
10
+ repeat: z.object({
11
+ items: z.string().describe("The row field holding the sub-list, as \"{{item.<field>}}\" (or just the field path)"),
12
+ template: elementInput.describe("Rendered once per entry of that sub-list (a plain element tree)")
13
+ }).optional().describe("Makes THIS element the wrapper of a nested list — a list inside each row")
14
+ }));
15
+ var repeatElementOp = z.object({
16
+ type: z.literal("repeatElement"),
17
+ pageRef: z.string().describe("Page ref or id"),
18
+ ref: z.string().describe("Ref of the WRAPPER element this creates; the rows become its children"),
19
+ elementType: z.string().optional().describe("Type of the wrapper; defaults to container"),
20
+ label: z.string().optional(),
21
+ style: styleRefs.optional().describe("Classes for the wrapper — this is where the row/grid layout goes"),
22
+ parentRef: z.string().optional().describe("Anchor ref/id; defaults to page root"),
23
+ position: position.optional(),
24
+ template: templateElement.describe("The subtree ONE row renders, with {{item.field}} placeholders"),
25
+ items: z.array(item).min(1).max(MAX_ITEMS).describe("One object per row; its fields fill the {{item.field}} placeholders of the template")
26
+ }).describe("Build a LIST from one template plus its `items` data, instead of repeating near-identical elements. Creates a wrapper whose children are the template rendered once per row. `{{item.<field>}}` is replaced by that row field — alone as the whole value it keeps the field type, mixed with text it interpolates. Every ref gets the row number appended (\"day\" → \"day-1\"), which is how you address a row later. A template node may carry `repeat: { items: \"{{item.<list>}}\", template: … }` to nest a list inside each row: it becomes the sub-list wrapper, refs number both levels (\"step-2-3\"), and `{{item.…}}` there reads the SUB-row. Other {{…}} names are untouched, so schema variables still work.");
27
+ var PLACEHOLDER = /\{\{\s*item\.([A-Za-z0-9_.-]+)\s*\}\}/g;
28
+ var WHOLE_PLACEHOLDER = /^\{\{\s*item\.([A-Za-z0-9_.-]+)\s*\}\}$/;
29
+ var lookup = (row, path) => path.split(".").reduce((value, key) => {
30
+ if (value === null || typeof value !== "object") return;
31
+ return value[key];
32
+ }, row);
33
+ /** One string of the template, with its placeholders resolved. A placeholder that IS the whole string yields the
34
+ * field's own value (a number stays a number, an array stays an array); mixed text interpolates. */
35
+ var fillString = (text, row) => {
36
+ const whole = WHOLE_PLACEHOLDER.exec(text);
37
+ if (whole) {
38
+ const value = lookup(row, whole[1]);
39
+ return value === void 0 ? {
40
+ value: text,
41
+ missing: whole[1]
42
+ } : { value };
43
+ }
44
+ let missing;
45
+ const value = text.replace(PLACEHOLDER, (match, path) => {
46
+ const found = lookup(row, path);
47
+ if (found === void 0) {
48
+ missing ??= path;
49
+ return match;
50
+ }
51
+ if (typeof found === "string") return found;
52
+ return typeof found === "number" || typeof found === "boolean" ? found.toString() : JSON.stringify(found);
53
+ });
54
+ return missing === void 0 ? { value } : {
55
+ value,
56
+ missing
57
+ };
58
+ };
59
+ var fillValue = (value, row, missing) => {
60
+ if (typeof value === "string") {
61
+ const filled = fillString(value, row);
62
+ if (filled.missing) missing.add(filled.missing);
63
+ return filled.value;
64
+ }
65
+ if (Array.isArray(value)) return value.map((entry) => fillValue(entry, row, missing));
66
+ if (value !== null && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, fillValue(entry, row, missing)]));
67
+ return value;
68
+ };
69
+ var listOf = (row, spec) => {
70
+ const whole = WHOLE_PLACEHOLDER.exec(spec);
71
+ const value = lookup(row, whole ? whole[1] : spec);
72
+ if (!Array.isArray(value)) return;
73
+ return value.map((entry) => entry !== null && typeof entry === "object" ? entry : { value: entry });
74
+ };
75
+ /** One template node against one row. `suffix` is the row numbering accumulated from the OUTSIDE in, so a nested
76
+ * row reads "step-2-3" (row 2, sub-row 3) rather than the other way round. */
77
+ var expandNode = (node, row, suffix, state) => {
78
+ const { children, repeat, ...own } = node;
79
+ const filled = fillValue(own, row, state.missing);
80
+ const element = {
81
+ ...filled,
82
+ ref: `${filled.ref}${suffix}`
83
+ };
84
+ if (repeat) {
85
+ const rows = listOf(row, repeat.items);
86
+ if (!rows) {
87
+ state.notAList.add(repeat.items);
88
+ return element;
89
+ }
90
+ const capped = rows.slice(0, MAX_ITEMS);
91
+ state.rows += capped.length;
92
+ element.children = capped.map((subRow, index) => expandNode(repeat.template, subRow, `${suffix}-${index + 1}`, state));
93
+ return element;
94
+ }
95
+ if (children) element.children = children.map((child) => expandNode(child, row, suffix, state));
96
+ return element;
97
+ };
98
+ var rowError = (index, message, hint) => ({
99
+ path: `items[${index}]`,
100
+ message,
101
+ hint
102
+ });
103
+ var keysOf = (row) => Object.keys(row).join(", ") || "(nothing)";
104
+ /** Expand one repeat into the single upsertElement it stands for: the wrapper, with the template rendered once per
105
+ * row as its children. Returns the errors instead of throwing, so a bad row reads like every other op error. */
106
+ var expandRepeat = (op) => {
107
+ const errors = [];
108
+ const children = [];
109
+ let total = op.items.length;
110
+ for (const [index, row] of op.items.entries()) {
111
+ const state = {
112
+ missing: /* @__PURE__ */ new Set(),
113
+ notAList: /* @__PURE__ */ new Set(),
114
+ rows: 0
115
+ };
116
+ const expanded = expandNode(op.template, row, `-${index + 1}`, state);
117
+ total += state.rows;
118
+ if (state.missing.size > 0) {
119
+ const fields = [...state.missing];
120
+ errors.push(rowError(index, `Row ${index + 1} has no ${fields.map((field) => `"${field}"`).join(", ")}`, `The template reads it as {{item.${fields[0]}}}. This row carries: ${keysOf(row)}`));
121
+ continue;
122
+ }
123
+ if (state.notAList.size > 0) {
124
+ const [spec] = [...state.notAList];
125
+ errors.push(rowError(index, `Row ${index + 1} has no list at ${spec}`, `A nested repeat needs an ARRAY in that field. This row carries: ${keysOf(row)}`));
126
+ continue;
127
+ }
128
+ children.push(expanded);
129
+ }
130
+ if (errors.length > 0) return { errors };
131
+ if (total > MAX_ROWS) return { errors: [{
132
+ path: "items",
133
+ message: `This repeat expands to ${total} rows (max ${MAX_ROWS})`,
134
+ hint: "Shorten the lists, or split the widget into several repeats."
135
+ }] };
136
+ return {
137
+ element: {
138
+ ref: op.ref,
139
+ type: op.elementType ?? "container",
140
+ ...op.label === void 0 ? {} : { label: op.label },
141
+ ...op.style === void 0 ? {} : { style: op.style },
142
+ children
143
+ },
144
+ errors
145
+ };
146
+ };
147
+ //#endregion
148
+ export { expandRepeat, repeatElementOp };
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ import { Space, OpResult } from '../../../../helpers';
3
+ import { Env } from '../../../../types';
4
+ export declare const upsertElementOp: z.ZodObject<{
5
+ type: z.ZodLiteral<"upsertElement">;
6
+ pageRef: z.ZodString;
7
+ element: z.ZodType<import('..').ElementInput, unknown, z.core.$ZodTypeInternals<import('..').ElementInput, unknown>>;
8
+ parentRef: z.ZodOptional<z.ZodString>;
9
+ position: z.ZodOptional<z.ZodEnum<{
10
+ inside: "inside";
11
+ before: "before";
12
+ after: "after";
13
+ }>>;
14
+ }, z.core.$strip>;
15
+ export type UpsertElement = z.infer<typeof upsertElementOp>;
16
+ export declare const upsertElement: (space: Space, env: Env, op: UpsertElement) => OpResult;