@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,608 @@
1
+ //#region src/modules/mcp/helpers/guide.ts
2
+ var serverInstructions = "Plitzi AI server: read-then-write editing of a Plitzi space. Reads follow a filesystem model — list cheap, read one item in detail on demand; never fetch a whole tree you do not need. Workflow: (1) read plitzi://primer/{env} once — it bundles the guide, types, css-properties and page/definition/variable summaries in a single call; (2) plitzi_search with include:\"detail\" to jump to elements — each hit then carries its uri, stateVersion AND full style/resolvedStyle, so an edit needs no per-element read; open a page skeleton or element only when you need its tree/detail (the skeleton already lists the style classes of each node, and plitzi_read fetches many uris at once); (3) plitzi_apply with dryRun to preview a batch; (4) plitzi_apply to persist, passing expectedResourceVersions to guard against concurrent edits — apply and search both hand back the versions you need for the next edit. Use patchElement / patchDefinition to change only some props / CSS (the upsert variants replace them all). An element read (and search include:\"detail\") inlines the CSS of the definitions it attaches under resolvedStyle, so you rarely need a separate definition read. Refs accept a semantic idRef ([A-Za-z0-9_-] starting with a letter, unique, chosen by you) or the raw id — the idRef is ALSO the runtime wiring key, so a provider source is `<type>_<idRef>.<field>`, visible to the provider’s DESCENDANTS only (bind inside its subtree). CSS is plain kebab-case — write shorthands freely (`border: 1px solid red`, `padding: 8px 16px`, `font: bold 16px/1.5 Arial`), they are expanded to longhands for you and STORED that way, so read-back shows the longhands; style vars are var(--name), schema vars are {{name}}. READERS — do not confuse them: MCP *resources* are the browsable catalog (list them, or open one by URI); plitzi_search FINDS refs by label/type/attribute; plitzi_read BATCH-fetches URIs you already hold. Reach for search/read to work; browse resources to discover. CMS / API integrations (Strapi, WordPress, Contentful, any REST service) go through a CONNECTOR: a manifest you author declaring the base URL, endpoints and auth template, which the SERVER executes — read plitzi://connector-presets for working ones and plitzi://connectors/{env} for this space’s. You never see or create the credential; the space owner attaches it, and the connector saves without one. An apiContainer reads through it only with runtime:\"server\". Elements also carry applied style variants + visibility (initialState), data bindings and interaction flows: edit them with patchElement (initialState), upsertBinding/patchBinding/deleteBinding, and upsertInteractionFlow/patchInteractionNode/deleteInteraction. An element read shows all three plus availableVariants (which variant each of its classes offers). Separately, to SHOW the user a small self-contained widget (offline, no space or backend) instead of editing the space — a card, hero, pricing table, a visual answer — use plitzi_render; read plitzi://render/guide for it.";
3
+ var widgetsOnlyInstructions = "Plitzi widget server (widgets-only connection). This connection carries NO Plitzi space: nothing can be read or edited in one, and the space tools are not offered here — do not look for them. What it does do is build self-contained UI widgets fully offline, with no backend, account or setup: call plitzi_render to SHOW the user a real rendered layout (card, hero, pricing table, checklist, form, gallery) instead of describing one. Read plitzi://render/guide first — the element/prop table, the style model and a worked example; plitzi://render/types lists every element type you can author (plitzi_read fetches both). To change a widget you already rendered, call plitzi_render again with patch:true and its renderId. If the user wants to edit their real Plitzi space from here, that is a reconnection they make: the integration must be re-authorized and granted a space (the consent screen lists theirs) — you cannot do it from this connection, and no retry will change it.";
4
+ var guideQuickstart = `# Plitzi AI MCP — quickstart
5
+ This is the condensed guide; read \`plitzi://guide\` for the full reference (every resource, op and example).
6
+
7
+ A space is **two schemas you edit together in one atomic \`plitzi_apply\` batch**: the **element schema** (tree of
8
+ pages/elements) and the **style schema** (definitions = CSS classes, tokens, theme). To style an element: write a
9
+ **definition** and attach it via the element's \`style.base\` in the same batch.
10
+
11
+ **Workflow:** (1) you already have this primer (guide + types + css + page/style summaries). (2) \`plitzi_search\`
12
+ with \`include:"detail"\` to find elements — each hit carries its \`uri\`, \`stateVersion\` and full style, so no
13
+ per-element read. (3) \`plitzi_apply\` with \`dryRun:true\` to preview. (4) \`plitzi_apply\` to persist, passing
14
+ \`expectedResourceVersions\` (uri → the stateVersion you read) for every resource you change — omitting it lets a
15
+ concurrent edit be lost. Use \`patchElement\`/\`patchDefinition\` to change only some props/CSS (upsert replaces all).
16
+
17
+ **Refs & wiring:** a ref is the semantic \`idRef\` (letters, numbers, hyphens and underscores, **starting with a
18
+ letter — no dots**) or the raw id. The idRef is the runtime wiring key: a provider's source is \`<type>_<idRef>\`, and
19
+ interactions target by it. A dot would split that path; an **underscore is fine** — the first \`_\` separates the type
20
+ from the idRef (element types have none), so \`list_food_item\` reads unambiguously as type \`list\`, idRef \`food_item\`.
21
+
22
+ **Styling:** CSS keys are **kebab-case** (\`background-color\`); \`var(--token)\` for style vars, \`{{name}}\` for schema
23
+ vars. **Write plain CSS** — shorthands (\`border\`, \`padding\`, \`margin\`, \`gap\`, \`overflow\`, \`flex\`, \`background\`,
24
+ \`font\`, \`transition\`, \`animation\`, \`grid\`, \`grid-row\`/\`grid-column\`, \`place-*\`, \`outline\`, \`columns\`,
25
+ \`list-style\`, \`text-decoration\`) are expanded to their longhands for you, so \`border: 1px solid red\` is stored as
26
+ \`border-top-color\`/\`border-top-width\`/\`border-top-style\`/… That is also how you read them back. Flex layout is
27
+ still \`display: flex\` + \`flex-direction\`/\`align-items\`/…, not a \`flex\` value. Mind a type's \`defaultStyle\`
28
+ (\`text\` is \`display: inline\`). Global styles (\`button {…}\`) and id styles (\`#id\`) have their own ops.
29
+
30
+ **Data bindings** (\`upsertBinding\`, category attributes|style|initialState): connect a \`source\` to a \`to\` field.
31
+ A source \`<type>_<idRef>\` is scoped to the provider's **DESCENDANTS only** — bind inside the provider's subtree
32
+ (module sources state/space/navigation/auth/collection are global). \`apiContainer.mockData\` is builder-only; set a
33
+ real \`query\` for production. \`transformers: [{action, params}]\` post-process the value — use exact action names
34
+ from \`plitzi://data-sources\`; \`twigTemplate\` formats it (the value is \`{{source}}\`, not \`{{value}}\`). \`when\` is
35
+ a QueryBuilder RuleGroup gating the binding.
36
+
37
+ **Interactions** (\`upsertInteractionFlow\`): a \`trigger\` node first, then callbacks/utilities **in order** (links
38
+ computed for you). Node types: \`callback\` (an element's own callback — \`elementId\` is that element), \`globalCallback\`
39
+ (a source module — omit \`elementId\`, the MCP sets it), \`utility\` (no element). Element \`setState\`
40
+ (category/key/value/revertOnFinish) ≠ global \`setState\` (source \`state\`, key/type/value). To turn a step off use
41
+ \`patchInteractionNode {enabled:false}\` — \`deleteInteraction\` removes it (destructive; confirm first). Any param
42
+ **value** can be a binding token \`{{ source }}\` (e.g. notification \`content: "{{ list_<idRef>.item.name }}"\`).
43
+
44
+ **CMS / API integrations** (\`upsertConnector\`): a **connector** is a manifest declaring a provider's base URL,
45
+ endpoints, auth template and filter operators, executed by the **server** — so integrating Strapi, WordPress,
46
+ Contentful or any REST API is configuration, not code. Read \`plitzi://connector-presets\` (working manifests + every
47
+ template token) and \`plitzi://connectors/{env}\` (this space's). **You never create or see credentials** — write the
48
+ manifest with \`{{credential.token}}\` and no \`connection.credential\`; it saves, and the space owner attaches the
49
+ secret in the builder. To consume one, an \`apiContainer\` needs **\`runtime: "server"\`** plus \`connector\`,
50
+ \`resource\`, optional \`endpoint\`/\`filters\`/\`limit\`/\`singleRecord\`/\`pagination\`; it then publishes
51
+ \`apiContainer_<idRef>.records\` (or \`.record\`) \`.pageInfo .isEmpty .hasError\` to its **descendants**. Full worked
52
+ flow — list page, detail page, paging, writes — in \`plitzi://guide\`.
53
+
54
+ **Pages & navigation:** \`upsertPage\` — always set a **relative** \`slug\` (no leading \`/\`; the runtime and folder
55
+ slugs prepend the path). A \`:name\` segment (\`"posts/:postId"\`) is a route param, readable as \`{{name}}\` and as the
56
+ source \`navigation.routeParams.name\` → build dynamic pages this way. To move between pages **prefer the \`Link\`
57
+ element** (a container: \`mode\` "page"/"internal"/"external") over a \`navigate\` interaction.
58
+
59
+ **Touched resources must be malformation-free.** Editing an element/definition also checks its CURRENT stored content
60
+ and BLOCKS the save on any \`Pre-existing malformation in <resource>\` error (a broken transformer, malformed node,
61
+ invalid CSS) — even parts you did not touch. These are NOT from your change (the message says so); fix them in the
62
+ SAME batch and re-apply (the check runs on the result, so the fix unblocks it). \`Pre-existing issue\` warnings advise
63
+ but do not block.
64
+
65
+ Read \`plitzi://guide\` before anything above is unclear.
66
+ `;
67
+ var guideText = `# Plitzi AI MCP — usage guide
68
+
69
+ A Plitzi space is **two separate schemas** you edit together:
70
+ - **Element schema** — the tree of pages and elements (their type, label, props, and which style classes they use).
71
+ - **Style schema** — reusable **definitions** (CSS classes), design tokens (variables), theme.
72
+
73
+ They are stored and persisted independently, but a single \`plitzi_apply\` batch may touch **both atomically**.
74
+ To style a specific element you do two things in one batch: write a **definition** (style schema) and **attach**
75
+ it via the element's \`style.base\` (element schema). Example — "rename button X to PEPE and make it red":
76
+ \`\`\`json
77
+ { "operations": [
78
+ { "type": "upsertDefinition", "ref": "btn-x", "desktop": { "color": "red" } },
79
+ { "type": "upsertElement", "pageRef": "home",
80
+ "element": { "ref": "X", "type": "button", "label": "PEPE", "style": { "base": ["btn-x"] } } }
81
+ ] }
82
+ \`\`\`
83
+
84
+ Reads are cheap by design — treat them like a filesystem: **list** to navigate, **read one item** for detail.
85
+ Never download a whole tree you do not need.
86
+
87
+ ## Resources (read)
88
+ - \`plitzi://primer/{env}\` — **cold-start bundle**: guide + types + css-properties + page/definition/variable
89
+ **summaries** in one read. Fetch this first instead of the individual resources below. Summaries only — open a
90
+ page skeleton or element for its tree/detail.
91
+ - \`plitzi://guide\` — this guide.
92
+ - \`plitzi://types\` — element types **observed in this space** (ground truth): props, slots, subTypes, plus each
93
+ type's \`label\`, \`description\` (what it is FOR) and \`category\`, and a \`source\` (\`builtin\` | \`plugin\` | \`unknown\`).
94
+ Read the descriptions to pick the right type — e.g. \`apiContainer\` fetches backend data into the frontend,
95
+ \`link\` navigates between pages, \`list\` repeats a template over a data array. \`plugin\` types are custom elements.
96
+ - \`plitzi://css-properties\` — valid kebab-case CSS property keys.
97
+ - \`plitzi://schema/{env}/pages\` — page **summaries** (ref, label, elementCount, folder). No element trees.
98
+ - \`plitzi://folders/{env}\` — page **folders** (the sidebar tree): ref, name, slug, parentId. \`/{ref}\` for one.
99
+ - \`plitzi://schema/{env}/pages/{ref}\` — one page as a **skeleton tree**: each node is \`ref/type/label\` **plus the
100
+ style classes it attaches** (\`base\`, and \`slots\` for non-base slots) — names only, no CSS. So you can map every
101
+ element to its class in a single page read, without opening each element just to learn which class it uses.
102
+ - \`plitzi://schema/{env}/pages/{ref}/styles\` — **every style the page uses in one read**: the class definitions its
103
+ elements attach (deduplicated, **with full CSS**) plus the global styles affecting any element type on the page.
104
+ Reach for this to recolor/restyle a whole page — it needs no shared class-name prefix and no per-element reads.
105
+ - \`plitzi://schema/{env}/elements/{ref}\` — one element in **full detail** (props, style, parentRef, childRefs).
106
+ Its \`resolvedStyle\` inlines the **CSS of every definition** the element attaches (keyed by class ref), so you
107
+ can see and edit its style without a separate definition read. Its \`globalStyles\` lists the **global element
108
+ selectors** that also affect it (the CSS equivalent of \`button { … }\`, keyed by the type they target) — every
109
+ element of that type inherits them. Edit a global only through the global-style tools (never per element). If the
110
+ element carries a DOM \`id\` that an id rule matches, its \`idStyle\` (\`#id\`) is inlined too.
111
+ - \`plitzi://definitions/{env}\` — the **names** of every style definition.
112
+ - \`plitzi://definitions/{env}/{ref}\` — one definition's CSS.
113
+ - \`plitzi://global-styles/{env}\` — element **types** that have a site-wide global style. \`/{componentType}\` for one.
114
+ - \`plitzi://id-styles/{env}\` — DOM **ids** that have an id rule (\`#id\`) targeting a single element. \`/{targetId}\` for one.
115
+ - \`plitzi://style-variables/{env}\` — design tokens by category. \`/{category}\` for one.
116
+ - \`plitzi://schema-variables/{env}\` — space-level values referenced in props as \`{{name}}\`.
117
+ - \`plitzi://settings/{env}\` — space-level settings: the global \`customCss\` and the state/auth (user-provider) config.
118
+ - \`plitzi://interactions/{env}\` — interaction **actions** observed in this space (grouped by node type): the
119
+ vocabulary for interaction flows.
120
+ - \`plitzi://data-sources/{env}\` — data-source **paths** and binding targets observed in this space: the
121
+ vocabulary for data bindings.
122
+ - \`plitzi://connector-presets\` — working starting **manifests** (Strapi, WordPress, Directus, Contentful, plain
123
+ REST) with the credential keys each provider needs, plus every **template token** the connector engine binds.
124
+ Space-independent. Read it before writing a connector by hand.
125
+ - \`plitzi://connectors/{env}\` — the **connectors this space has**: for each, its read/write endpoint names, its
126
+ filter operators and its published fields. \`/{ref}\` opens one manifest in full. See *Connectors* below.
127
+
128
+ The style resources also answer under the \`plitzi://schema/{env}/…\` root as aliases — \`plitzi://schema/{env}/definitions/{ref}\`, \`plitzi://schema/{env}/style-variables/{category}\`, \`plitzi://schema/{env}/schema-variables\` — but prefer the ready-made \`uri\` from search / a write response over hand-building either form.
129
+
130
+ Data resources return \`{ stateVersion, data }\`. Keep \`stateVersion\` for optimistic concurrency.
131
+
132
+ **Reuse what you already know — don't re-scan an unchanged page.** A page read (\`plitzi://schema/{env}/pages/{ref}\`)
133
+ returns a \`stateVersion\` that is an **aggregate of the whole page**: it changes if and only if some element on the
134
+ page changed. Its skeleton \`tree\` also carries a \`stateVersion\` **per node**, identical to the one a direct element
135
+ read or search hit returns for that element. So when you come back to a page you already inspected:
136
+ 1. Re-read just the page skeleton and compare its top-level \`stateVersion\` to the one you held. **Same → nothing
137
+ changed since your read; skip re-reading and re-searching the tree** and act on what you already know.
138
+ 2. If it differs, diff the per-node \`stateVersion\`s against the ones you cached and \`plitzi_read\` **only the nodes
139
+ that changed** — never re-search or re-read the whole tree.
140
+
141
+ This is a **read-time** shortcut, not a safety guarantee. **Other agents/sub-agents may edit the same space
142
+ concurrently**, so a version you cached can go stale between your read and your write. Never skip the write-time
143
+ check below on the strength of a cached hash — the guarantee that no concurrent edit is lost comes only from
144
+ \`expectedResourceVersions\` on \`plitzi_apply\`, which re-validates against the live data at write time.
145
+
146
+ ## Navigating (files analogy)
147
+ Pages and containers are folders; elements are files. **Prefer \`plitzi_search\` (especially with \`include: "detail"\`)
148
+ over reading elements one by one** — it jumps straight to elements by label/type/attribute and each hit already
149
+ carries the element's \`uri\`, \`stateVersion\`, \`pageUri\`, \`parentRef\` and tree \`path\`, so you can edit it (with
150
+ optimistic concurrency) **without a follow-up read**. \`include: "detail"\` additionally inlines each hit's props/style
151
+ **and** its \`resolvedStyle\` (the CSS behind its classes) — so a search-then-edit is the efficient path and a manual
152
+ element read is the exception. Search also matches **pages** by name/slug (returned under \`pages\`, each with its uri +
153
+ stateVersion) and returns any **style definitions** whose name matches the query, with full CSS, under \`definitions\`.
154
+ When you do hold several refs to open (e.g. from a skeleton), read them together with \`plitzi_read\` rather than one at a time.
155
+
156
+ ## Tools (write)
157
+ - \`plitzi_validate\` — check a batch, returns teachable errors/warnings. Writes nothing. Also reports **pre-existing
158
+ malformations** in any resource the batch touches (see below).
159
+ - \`plitzi_apply\` — validate → apply → persist atomically. Rejects the whole batch on any error or conflict. Pass
160
+ \`dryRun: true\` to apply in memory only and get the same result back (changed versions + full element detail)
161
+ without persisting — inspect it, then re-run without \`dryRun\` to commit.
162
+ - \`plitzi_search\` — find elements (and pages/definitions) across the space.
163
+ - \`plitzi_read\` — read many resource **uris in one batch** (pages, elements, definitions, variables). Pass the
164
+ ready-made uris from search / a write response; each result is \`{ uri, stateVersion, data }\` or a teachable error,
165
+ so one bad uri never fails the batch. Use it instead of N single reads whenever you already hold several refs.
166
+
167
+ ## Readers: resources vs plitzi_search vs plitzi_read (do not confuse them)
168
+ Three ways to read, each for a different moment — pick by what you have in hand:
169
+ - **MCP resources** (the \`plitzi://…\` catalog above) — the **browsable index**. List them to discover what exists, or
170
+ open one by URI when you are exploring. This is the passive catalog, not a tool.
171
+ - **\`plitzi_search\`** — you know *what* you want but not its **ref/uri** ("the hero button"). Search finds it by
172
+ label/type/attribute and hands back the uri + stateVersion (and, with \`include:"detail"\`, the full element).
173
+ - **\`plitzi_read\`** — you **already hold one or more uris** (from search or a write response) and want their
174
+ content in one batch. It is the tool form of opening resources, for when you have the addresses.
175
+ Rule of thumb: **discover → resources**, **find a ref → plitzi_search**, **fetch known uris → plitzi_read**. Never
176
+ hand-build a URI to guess your way to an element — search for it instead.
177
+
178
+ Write tools return what **changed** (\`{ uri, stateVersion }\`) plus counts, and the **full detail of every element
179
+ they created or updated** — each with its own \`uri\` and \`stateVersion\` (\`elements: [...]\`) so a follow-up edit of
180
+ the same element needs **no intermediate read**. Other resources (pages, definitions, variables) still report only
181
+ uri+stateVersion — re-read them if you need their new content. The operation shapes are in each tool's input
182
+ schema (discriminated by \`type\`).
183
+
184
+ ## Addressing
185
+ Refs are the semantic \`idRef\` (e.g. \`"hero-cta"\`) or the element's **raw id** — both resolve. Creating an element
186
+ stores the \`ref\` you chose as its **idRef**.
187
+
188
+ The idRef is not just an alias — it is the **wiring key the runtime uses**. A provider registers its data source as
189
+ \`<type>_<idRef>\`, so a \`source\` you write against a ref resolves to that element at runtime with no id translation.
190
+ Rules for a **new** ref (both are enforced; a violation fails the batch):
191
+ - Charset \`[A-Za-z0-9_-]\`, **starting with a letter** (e.g. \`"products-api"\`, \`"food_item"\`). A \`.\` would split the
192
+ \`<type>_<idRef>.<field>\` source path and the interaction target lookup, so **no dots**. An **underscore is
193
+ allowed**: the FIRST \`_\` separates \`<type>\` from \`<idRef>\` and element types are camelCase with none, so
194
+ underscores inside the idRef are unambiguous (\`list_food_item\` → type \`list\`, idRef \`food_item\`).
195
+ - **Unique across the space**; creating a ref that is taken is rejected (address the existing element instead).
196
+
197
+ **Where an element renders** is its \`runtime\`, settable on \`upsertElement\`/\`patchElement\`: \`"shared"\` (the
198
+ default, both sides), \`"client"\` (browser only) or \`"server"\` (SSR only). It matters for one thing above all — an
199
+ \`apiContainer\` reads through a **connector** only when it is \`"server"\` (see *Connectors*). An element read
200
+ reports it only when it is set.
201
+
202
+ An idRef is **optional** on an element — one built in the builder may not have it. The consequence is specific: an
203
+ element without an idRef **publishes no data source** and **holds no interactions**, because the runtime keys
204
+ everything by idRef and the raw id is never a fallback. You do not have to fix this by hand: writing an
205
+ interaction **mints an idRef for you** — the element that hosts the flow, and any element a node targets, is given
206
+ a free \`<type>-<n>\` ref if it lacks one, and the flow is wired to it. A node target you write may be a raw id; it
207
+ is normalised to that element's idRef. (To make an element a data-source **provider** to bind against, give it an
208
+ idRef explicitly with \`patchElement\`, or create it with the \`ref\` you want — a created element stores its ref as
209
+ its idRef.)
210
+
211
+ **Renaming** an idRef moves the wiring key: every binding source and interaction target across the space that
212
+ pointed at the old name is repointed with it, so the element stays wired. You do not have to rewrite them.
213
+
214
+ ## Styling (crosses both schemas)
215
+ - **Mind the type's intrinsic default style.** A type renders with a base CSS *before* any class is attached — read
216
+ it from \`defaultStyle\` on the type in \`plitzi://types\` (the primer includes it). Do not assume \`display: block\`:
217
+ \`text\`, for one, defaults to \`display: inline\`, so margins/width/vertical padding behave differently. If you need
218
+ block/flex layout on such an element, set \`display\` explicitly in your definition rather than relying on a default.
219
+ - **Images: preserve aspect ratio.** Setting only \`width\` and \`height\` (or forcing both) distorts an image. Change
220
+ one dimension and let the other be \`auto\`, or set \`aspect-ratio\` with \`object-fit: cover\`/\`contain\`, so the
221
+ image scales without stretching.
222
+ - **Font size and line height move together.** When you change \`font-size\`, set \`line-height\` in the same edit
223
+ (prefer a unitless ratio like \`1.5\`, which tracks the font size). Changing one without the other leaves cramped or
224
+ loosely-spaced text — they are a joint change, not two separate ones.
225
+ - A definition lives in the **style schema**; an element's \`style.base\` (element schema) is the link that applies
226
+ it. Styling an element = upsertDefinitions + upsertElement with that ref in \`style.base\`, in one batch.
227
+ - **Repeating siblings**: when a set of siblings shares a shape and differs only in data (a list, cards, rows,
228
+ steps), use \`repeatElement\` — the template once with \`{{item.field}}\` placeholders plus \`items\`, which
229
+ creates the wrapper and numbers each row's refs (\`step-1\`, \`step-2\`…). A list inside each row is the same op:
230
+ the wrapping node carries \`repeat: { items: "{{item.<list>}}", template: … }\` and its refs number both levels
231
+ (\`blk-2-3\`). Copy-pasting the subtree N times costs N times the tokens and drifts.
232
+ - CSS keys are **kebab-case** (\`background-color\`). camelCase is rejected — read \`plitzi://css-properties\`.
233
+ - **Write normal CSS — shorthands are accepted and expanded for you.** \`border\`, \`border-{side}\`,
234
+ \`border-width\`/\`-color\`/\`-style\`, \`border-radius\`, \`padding\`, \`margin\`, \`inset\`, \`gap\`, \`overflow\`,
235
+ \`flex\`, \`flex-flow\`, \`background\`, \`font\`, \`transition\`, \`animation\`, \`grid\`, \`grid-template\`,
236
+ \`grid-area\`, \`grid-row\`, \`grid-column\`, \`place-content\`, \`place-items\`, \`place-self\`, \`outline\`,
237
+ \`columns\`, \`list-style\`, \`text-decoration\` — the full list is in \`plitzi://css-properties\` under
238
+ \`shorthands\`. They **persist as longhand keys** (that is what a read gives back), so a breakpoint/state/variant
239
+ can still override one property at a time.
240
+ - \`border: 1px solid red\` → \`border-top-width: 1px\`, \`border-top-style: solid\`, \`border-top-color: red\`, …
241
+ for all four sides. A shorthand also RESETS what it omits, so \`border: none\` clears a width a previous
242
+ definition set.
243
+ - Comma-separated layers are kept per longhand: \`transition: opacity 200ms, transform 300ms\` →
244
+ \`transition-property: opacity, transform\` + \`transition-duration: 200ms, 300ms\`.
245
+ - In a **patch**, a shorthand replaces the longhands it controls (\`padding: 8px\` overwrites a previous
246
+ \`padding-left\`), and \`"border": null\` removes all twelve border longhands.
247
+ - **Flex layout is not a \`flex\` value**: set \`display: flex\` **plus** \`flex-direction\`, \`align-items\`,
248
+ \`justify-content\` as separate properties.
249
+ - CSS is grouped by breakpoint: \`desktop\`, \`tablet\`, \`mobile\`.
250
+ - Reference a style variable in CSS as \`var(--name)\`; a schema variable in a prop as \`{{name}}\`.
251
+ - \`element.style.base\` is a **list** of definition refs; other slots go under \`element.style.slots\`.
252
+ - **An element can attach SEVERAL classes at once, and they all apply.** \`style.base\` holds a list, and each
253
+ non-base slot holds its own — every attached definition contributes CSS, and they **cascade** (a later class, then a
254
+ global/id rule, overrides an earlier one on the same property). So when a style looks wrong, the culprit may be
255
+ ANY attached class, not the one you just edited: read the element's \`resolvedStyle\` (it inlines the CSS of every
256
+ class it attaches, keyed by ref) together with its \`globalStyles\`/\`idStyle\` and the type's \`defaultStyle\`, and
257
+ fix the class that actually sets the property — do not just pile another class on top.
258
+ - **Three kinds of style live in the style schema — do not confuse them:**
259
+ - **Definitions** = reusable CSS **classes** (\`upsertDefinition\`/\`patchDefinition\`/\`deleteDefinition\`, keyed by a
260
+ class \`ref\`). Attach one to an element via \`style.base\` to style **that** element (and anything else that opts in).
261
+ This is the **default** way to style one element. Declaring MORE than one class in a batch? Use
262
+ \`upsertDefinitions\` — one op carrying \`{ "<class>": { desktop: … }, … }\`, same result as the run of
263
+ \`upsertDefinition\` it replaces, without repeating the envelope once per class.
264
+ - **Global styles** = the CSS equivalent of a bare element selector like \`button { … }\`
265
+ (\`upsertGlobalStyle\`/\`patchGlobalStyle\`/\`deleteGlobalStyle\`, keyed by \`componentType\`). They style **every**
266
+ element of that type at once. Use these for site-wide intent — e.g. "all buttons rounded":
267
+ \`{ "type": "upsertGlobalStyle", "componentType": "button", "desktop": { "border-radius": "9999px" } }\`.
268
+ - **Id styles** = the CSS equivalent of an id selector like \`#hero { … }\`
269
+ (\`upsertIdStyle\`/\`patchIdStyle\`/\`deleteIdStyle\`, keyed by \`targetId\`). They style the **single** element whose
270
+ DOM \`id\` attribute equals \`targetId\` — so the element must carry that \`id\` (set it in its props). Prefer a
271
+ **definition** for one element; reach for an id style only when a specific, uniquely-identified node must be
272
+ targeted by id: \`{ "type": "upsertIdStyle", "targetId": "hero", "desktop": { "min-height": "100vh" } }\`.
273
+ - The three share one name space, so an op refuses a name held by another kind (guards against a typo silently
274
+ rewriting every element of a type, or converting a class into an id rule). If refused, you targeted the wrong
275
+ kind — switch tools or rename.
276
+
277
+ ## Style variants & element state
278
+ A **variant** is a named CSS override on a definition (e.g. a button class with a \`primary\` variant). It takes two
279
+ steps across the two schemas:
280
+ - **Declare** the variant CSS on the class (style schema): \`upsertDefinition\`/\`patchDefinition\` with
281
+ \`variants: { "primary": { "desktop": { "background-color": "#111" } } }\` (per slot under \`slots.<slot>.variants\`).
282
+ - **Apply** it to an element (element schema): \`initialState.styleVariant\` =
283
+ \`{ "<class-ref>": { "base": "primary" } }\` — a slot name instead of \`base\` targets that slot; an array applies
284
+ several. Set it via \`upsertElement\`/\`patchElement\`.
285
+ An element read reports \`availableVariants\` (which variant each attached class offers) and the element's current
286
+ \`initialState\`, so you can see a button **has** a \`primary\` variant and whether it uses it. If the user asks for a
287
+ variant that does not exist yet, **create it (upsertDefinition variants) and apply it in the same batch**.
288
+ - \`initialState.visibility\` (boolean) sets whether the element starts shown or hidden.
289
+
290
+ ## Data bindings
291
+ Connect a data **source** to an element field. A binding is \`{ to, source, transformers?, when?, enabled? }\` grouped
292
+ by **category**: \`attributes\` (a prop), \`style\` (a style value), \`initialState\` (an initial-state key).
293
+ - \`upsertBinding\` adds one, or replaces the binding already feeding the same \`to\` (or \`id\`).
294
+ - \`patchBinding\` edits an existing one (matched by \`to\`/\`id\`); \`deleteBinding\` removes it.
295
+ Discover valid source paths **and the transformer catalog** in \`plitzi://data-sources/{env}\`. Example — feed an API
296
+ list into a list element:
297
+ \`{ "type": "upsertBinding", "pageRef": "home", "ref": "myList", "category": "attributes",
298
+ "binding": { "to": "items", "source": "apiContainer_x.data" } }\`.
299
+
300
+ **Source scope — a source is visible to the provider's DESCENDANTS only.** An element source named
301
+ \`<type>_<idRef>\` (e.g. \`apiContainer_products\`, \`list_food-list\`) is published by that element into the scope of
302
+ its **subtree**, so **only elements INSIDE the provider can bind to it**. Binding a sibling or an unrelated element
303
+ to it resolves to nothing at runtime. So to consume \`apiContainer_products.data\`, the bound element must live under
304
+ that apiContainer; inside a \`list\`, the repeated \`listItem\` and its children read the per-row source
305
+ (\`list_<idRef>.item.<field>\`). Module sources (no \`<type>_<idRef>\` head — \`state\`, \`space\`, \`navigation\`,
306
+ \`auth\`, \`collection\`) are global and bindable anywhere. Binding an element to an element source outside its
307
+ provider's subtree is schema-valid but **broken at runtime** (the source is not in scope), so
308
+ \`plitzi_validate\`/\`plitzi_apply\` treat it as an **error and reject the batch** — move the element under the
309
+ provider, or bind a source that is in scope.
310
+
311
+ **mockData is builder-only.** An \`apiContainer\`'s \`mockData\` prop feeds sample data **while editing in the
312
+ builder**; the published runtime fetches real data instead. Never rely on mockData as the production source — give
313
+ the provider a real source: a **connector** with \`runtime: "server"\` (see *Connectors*, the right answer whenever
314
+ the API needs a token or the content should be in the HTML), or a browser-side \`query\`/\`method\` for a public URL.
315
+
316
+ **\`transformers\` — post-process the value before it reaches the field** (\`source → t₁ → t₂ → field\`). An array of
317
+ \`{ action, params }\`; the runtime runs them in order and resolves each by its \`action\` alone, so an **unknown
318
+ action is silently skipped** and the raw value passes through. Use the **exact** action names from
319
+ \`plitzi://data-sources\` (\`transformers\`). The most common is **\`twigTemplate\`** to format a value — the incoming
320
+ value is the **\`{{source}}\`** token (NOT \`{{value}}\`); \`{{sourceTo}}\` is the field's previous value. Example —
321
+ show a number with units:
322
+ \`{ "type": "upsertBinding", "pageRef": "home", "ref": "food-item-time", "category": "attributes",
323
+ "binding": { "to": "content", "source": "list_food-list.item.cookTimeMinutes",
324
+ "transformers": [ { "action": "twigTemplate", "params": { "template": "{{source}} min de cocción" } } ] } }\`.
325
+ Other transformers: \`dateConverter\` (format a date/timestamp), \`capitalize\`, \`stringToArray\` (split on a
326
+ separator), \`arrayMap\` (remap the keys of each object in an array), \`staticValue\`. Transformer \`params\` values are
327
+ strings. Each transformer also takes an optional \`enabled\` flag: set \`"enabled": false\` to keep it in the chain but
328
+ skip it at runtime (defaults to true) — the value passes through untouched, and a disabled transformer is not
329
+ validated.
330
+
331
+ **\`when\` — gate the binding** with a QueryBuilder RuleGroup: the binding only applies when the guard passes against
332
+ the data source. Shape: \`{ "combinator": "and", "rules": [ { "field": "<path>", "operator": "=", "value": "x" } ] }\`
333
+ (operators: \`=\`, \`!=\`, \`<\`, \`>\`, \`contains\`, \`beginsWith\`, \`empty\`, \`in\`, \`between\`, …; nest RuleGroups for
334
+ and/or). The guard is validated structurally. Example — only bind when a flag is set:
335
+ \`"when": { "combinator": "and", "rules": [ { "field": "status", "operator": "=", "value": "published" } ] }\`.
336
+
337
+ ## Interactions
338
+ An interaction **flow** is a **trigger** (an event like \`onClick\`, \`onPageLoad\`) followed by the callbacks/utilities
339
+ it runs, in order. You pass the steps **in order** and the stored beforeNode/afterNode/flowId links are computed for
340
+ you — never wire them by hand. Each step also has an \`enabled\` flag (see disable vs delete below).
341
+
342
+ **Node types & \`elementId\`** — a step names which element (or module) provides the callback it runs. Picking the
343
+ **wrong node type for an action** makes the runtime resolve it against nothing, so the step **silently does nothing**:
344
+ - \`trigger\` — the event; belongs to the host element. \`elementId\` defaults to the host.
345
+ - \`callback\` — a callback provided by a **specific element**. \`elementId\` is that element's ref (the flow host by
346
+ default, or another element to act on); give its ref or raw id and it is normalised to the idRef. Every element
347
+ registers a built-in **\`setState\`** callback that changes **its own attribute or state**: params
348
+ \`category\` (\`"attribute"\` — set a prop like \`content\`/\`disabled\` — or \`"state"\` — \`visibility\` or a style
349
+ selector), \`key\`, \`value\` (a **scalar** whose type follows the target attribute — a real boolean \`true\`/\`false\`
350
+ for a boolean attribute, a number for a numeric one, otherwise a string), and **\`revertOnFinish\`**. Set
351
+ \`revertOnFinish: true\` for a **temporary** change (a "loading…" label, disabling a button while it works): it is
352
+ **undone automatically when the flow finishes**, so you do **NOT** add manual restore steps at the end. This element
353
+ \`setState\` has **no** \`type\` param (that belongs to the global one below). An element type may also register its
354
+ own extra callbacks.
355
+ - \`globalCallback\` — a callback provided by a **source module**, NOT by any element: \`addNotification\` (source
356
+ \`space\`), \`setState\`/\`clearState\` (\`state\`), \`navigate\` (\`navigation\`), \`authLogin\`/\`authLogout\`/
357
+ \`authRefreshDetails\` (\`auth\`), \`addCollectionRecord\`/\`updateCollectionRecord\`/\`removeCollectionRecord\`
358
+ (\`collection\`). Its \`elementId\` is the **source module id**, never the host element — a node that stored the host
359
+ idRef here would resolve to nothing at runtime. **Omit \`elementId\`**: the MCP sets the correct source and fills the
360
+ builder's **param defaults** (e.g. \`addNotification\` gets \`autoDismiss:true\`, \`autoDismissTimeout:5000\`,
361
+ \`placement:"top-right"\`, \`appeareance:"success"\`) for any params you leave out. Use **only** the params each
362
+ callback declares (exact spelling) — for \`addNotification\` the visible text goes in \`content\`; there is **no**
363
+ \`title\`/\`message\`/\`type\` param, and any unknown key is dropped. See the full param schema for each callback under
364
+ \`globalCallbacks\` in \`plitzi://interactions/{env}\`.
365
+ - **Two \`setState\`s — do not mix them:** the **element** \`setState\` (nodeType \`callback\`, on an element,
366
+ category/key/value/revertOnFinish) changes THAT element's attribute/state and is what you want to change a button's
367
+ label or disabled flag. The **global** \`setState\` (nodeType \`globalCallback\`, source \`state\`, key/type/value)
368
+ writes \`runtime.state.<key>\`. They share a name but have different node types AND different params.
369
+ - \`utility\` — a built-in utility action (no element/source module); nodeType \`utility\`. Use the **exact** param
370
+ names: \`delayTime\` waits \`time\` milliseconds (**not** \`delay\`), \`twigTemplate\` (\`returnMode\`, \`template\`),
371
+ \`webHook\` (\`url\`, \`method\`, …). See \`utilities\` in \`plitzi://interactions/{env}\`.
372
+
373
+ **A param value can be a data binding.** Any interaction param may hold a \`{{ source }}\` token instead of a literal —
374
+ it resolves at runtime exactly like a prop binding, using the same source grammar (\`<type>_<idRef>.<path>\`, or a
375
+ module source like \`navigation\`/\`state\`). This is how a step reacts to *the data in context*: inside a \`listItem\`,
376
+ a click on a row can show \`addNotification\` with \`content: "{{ list_<idRef>.item.name }}"\` — the clicked row's field.
377
+ The value follows the source's type, so a token is valid even where a param expects a boolean/number. Copy/paste of an
378
+ element repoints these tokens to the new idRefs automatically, along with the element's bindings.
379
+
380
+ **Navigating between pages — prefer the \`Link\` element over an interaction.** For a plain "go to page X" the right
381
+ tool is a \`link\` element (a container, see *Pages & folders*), not a \`navigate\` interaction step. Use the
382
+ \`navigate\` globalCallback only when the navigation is one step of a larger flow (e.g. submit a form, then go).
383
+
384
+ Tools:
385
+ - \`upsertInteractionFlow\` — create or replace one flow. The FIRST node must be a \`trigger\`. Pass \`flowId\` (the
386
+ trigger's node id) to replace an existing flow. Example (elementId omitted — the MCP wires it to \`space\` and fills
387
+ the notification defaults):
388
+ \`{ "type": "upsertInteractionFlow", "pageRef": "home", "ref": "cta", "nodes": [
389
+ { "nodeType": "trigger", "action": "onClick", "title": "Click" },
390
+ { "nodeType": "globalCallback", "action": "addNotification", "title": "Notify",
391
+ "params": { "content": "Saved!" } } ] }\`.
392
+ - \`patchInteractionNode\` — change one step in place (by \`nodeId\`); \`params\` merge onto the node.
393
+
394
+ **Disable vs delete a step — do not confuse them (three different intents):**
395
+ - **Disable / deactivate / turn off a step** (keep it in the flow, just stop it running): \`patchInteractionNode\`
396
+ with \`{ "enabled": false }\`. Re-enable with \`{ "enabled": true }\`. This is NOT a deletion — the step stays.
397
+ - **Remove one step** from a flow: \`deleteInteraction\` with \`nodeId\` (its neighbors are re-linked).
398
+ - **Remove the whole flow**: \`deleteInteraction\` with \`flowId\` (the trigger node id).
399
+
400
+ So "deactivate the addNotification step" means \`patchInteractionNode { enabled: false }\` — never delete the step, and
401
+ never delete the flow. \`deleteInteraction\` is **destructive and not undoable**: only use it when the user asked to
402
+ *remove* something, and **confirm with the user before deleting** a step or a flow.
403
+
404
+ Discover valid actions in \`plitzi://interactions/{env}\`: \`actions\` = observed, \`globalCallbacks\` /
405
+ \`elementCallbacks\` / \`utilities\` = the built-in vocabularies with their full param schema, so you know the exact
406
+ node type and valid params per action. An element read lists its flows as ordered nodes (each with its \`id\` and
407
+ \`enabled\`), so a follow-up patch/delete needs no extra read.
408
+
409
+ ## Connectors — CMS and API integrations
410
+ A **connector** is how a space reads real content from Strapi, WordPress, Contentful, Directus or any REST service.
411
+ It is **a manifest, not code**: you declare the base URL, the endpoints, the auth template and the filter operators,
412
+ and the **server** executes it during the render. Integrating a new CMS never means shipping an adapter — it means
413
+ writing one document, which you can do here with \`upsertConnector\`.
414
+
415
+ Why the server and not the browser: the request (and the token behind it) never reaches the visitor, and the content
416
+ is in the HTML search engines see. That is also the one hard rule below — a provider element that is not
417
+ server-rendered ignores its connector entirely.
418
+
419
+ **Read these two first:**
420
+ - \`plitzi://connector-presets\` — **working manifests** for Strapi v5, WordPress, Directus, Contentful and a plain
421
+ REST API, each with the \`credentialKeys\` that provider needs, **plus every template token** the engine binds.
422
+ Start from the preset for the user's provider and edit it; do not invent a shape from memory.
423
+ - \`plitzi://connectors/{env}\` — the connectors **this space already has**, each with its read/write endpoint names,
424
+ its filter operators and its published fields. \`plitzi://connectors/{env}/{ref}\` opens one manifest in full.
425
+
426
+ ### Credentials are NOT yours to write
427
+ You never create, see or transmit a secret. Author the manifest with the token in place
428
+ (\`"value": "Bearer {{credential.token}}"\`) and **leave \`connection.credential\` unset** unless the user hands you an
429
+ identifier. The connector **saves fine that way** — validation reports it as a *warning*, not an error — and its
430
+ requests go unauthenticated until the space owner creates the credential in the builder and attaches it. Say that to
431
+ the user as the last step of any integration you build, naming the keys the preset lists (e.g. Strapi needs \`token\`).
432
+
433
+ ### The manifest
434
+ Every string is a template the server renders per request. \`{{resource}}\` is the collection the element asked for;
435
+ \`{{limit}}\`/\`{{offset}}\`/\`{{page}}\`/\`{{cursor}}\` the window; \`{{routeParams.x}}\`/\`{{queryParams.x}}\` the
436
+ visitor's URL; \`{{credential.x}}\` the secret; \`{{field}}\`/\`{{value}}\` inside an operator; \`{{id}}\`/\`{{values}}\`
437
+ inside a write. The op splits it in two, exactly as the engine does:
438
+ - **\`connection\`** — what applies to every call: \`credential\`, \`auth\`, \`headers\`, \`pagination\`, \`operators\`,
439
+ \`mediaBaseUrl\`, \`fields\`, \`projection\`.
440
+ - **\`endpoints\`** — the individual calls: \`read\` (named; **\`list\` is the one an element addresses when it names
441
+ none**) and \`write\` (named; **omit for read-only** — an undeclared write can never be executed).
442
+
443
+ A read endpoint says where things live in *that* provider's response: \`itemsPath\` (the array), \`totalPath\` (the
444
+ count), \`idPath\` (the record's id), \`valuesPath\` (its fields). Strapi's \`data\` + \`meta.pagination.total\` and
445
+ Contentful's \`items\` + \`fields\` are the same manifest with different paths.
446
+
447
+ Two traps the validator will catch for you, both silent at runtime otherwise:
448
+ - An **operator template must render a whole \`key=value\` entry** (\`"eq": "filters[{{field}}][$eq]={{value}}"\`). A
449
+ filter naming an operator the manifest does not declare is **dropped** — the query then returns *unfiltered*
450
+ records, not none.
451
+ - **Paging must appear in the request.** Declaring \`pagination: "page"\` without \`{{page}}\` in the query makes every
452
+ page resolve to the first one.
453
+
454
+ Example — Strapi, from the preset:
455
+ \`\`\`json
456
+ { "type": "upsertConnector", "ref": "strapi-blog", "name": "Blog CMS",
457
+ "baseUrl": "https://cms.example.com",
458
+ "connection": {
459
+ "auth": { "in": "header", "name": "Authorization", "value": "Bearer {{credential.token}}" },
460
+ "pagination": "offset",
461
+ "operators": { "eq": "filters[{{field}}][$eq]={{value}}", "contains": "filters[{{field}}][$containsi]={{value}}" },
462
+ "mediaBaseUrl": "https://cms.example.com" },
463
+ "endpoints": { "read": { "list": {
464
+ "path": "/api/{{resource}}",
465
+ "query": { "pagination[start]": "{{offset}}", "pagination[limit]": "{{limit}}", "populate": "*" },
466
+ "itemsPath": "data", "totalPath": "meta.pagination.total", "idPath": "documentId" } } } }
467
+ \`\`\`
468
+ \`patchConnector\` changes part of one (endpoints merge **by name**; \`null\` removes one) — that is how you add a
469
+ \`detail\` read to a large manifest without resending it. \`deleteConnector\` is destructive: every element pointing
470
+ at it stops resolving, so confirm first.
471
+
472
+ ### Using a connector on a page
473
+ The provider element is \`apiContainer\`, and it needs **both halves**:
474
+ 1. \`runtime: "server"\` — set it on \`upsertElement\`/\`patchElement\`. **Without it the connector is ignored** and the
475
+ element falls back to fetching its own \`query\` URL from the browser. This is the single most common mistake; the
476
+ validator warns when it sees one half without the other.
477
+ 2. props: \`connector\` (the ref), \`resource\` (the collection → \`{{resource}}\`), and optionally \`endpoint\` (a read
478
+ other than \`list\`), \`filters\`, \`limit\`, \`singleRecord\`, \`pagination\`, \`pageParam\`.
479
+
480
+ It then publishes one source **to its descendants only** (like any provider — bind *inside* its subtree):
481
+ \`apiContainer_<idRef>.records\` (an array), \`.pageInfo\` (\`page\`, \`pageCount\`, \`total\`, \`hasNextPage\`…),
482
+ \`.isEmpty\`, \`.hasError\`, \`.errorMessage\`, \`.isLoading\`. With \`singleRecord: true\` it publishes \`.record\`
483
+ instead of \`.records\` — that is what a **detail page** uses. Bind an empty-state block's visibility to \`.isEmpty\`
484
+ and an error block's to \`.hasError\`; they are ordinary bindings, no special mechanism.
485
+
486
+ **A list page** — provider, then a \`list\` inside it bound to the records, then the row template reading the item:
487
+ \`\`\`json
488
+ { "operations": [
489
+ { "type": "upsertElement", "pageRef": "blog", "element": {
490
+ "ref": "posts-api", "type": "apiContainer", "runtime": "server",
491
+ "props": { "connector": "strapi-blog", "resource": "articles", "limit": "9", "pagination": "url" },
492
+ "children": [ { "ref": "posts", "type": "list", "children": [
493
+ { "ref": "post-row", "type": "listItem", "children": [
494
+ { "ref": "post-title", "type": "text" } ] } ] } ] } },
495
+ { "type": "upsertBinding", "pageRef": "blog", "ref": "posts", "category": "attributes",
496
+ "binding": { "to": "items", "source": "apiContainer_posts-api.records" } },
497
+ { "type": "upsertBinding", "pageRef": "blog", "ref": "post-title", "category": "attributes",
498
+ "binding": { "to": "content", "source": "list_posts.item.title" } } ] }
499
+ \`\`\`
500
+
501
+ **A detail page** is the same provider with \`singleRecord\` and a filter resolved from the URL. Create the page with a
502
+ route param (\`"slug": "blog/:postSlug"\`), then filter on it — the filter \`value\` is a template the server resolves:
503
+ \`\`\`json
504
+ { "type": "upsertElement", "pageRef": "post-detail", "element": {
505
+ "ref": "post-api", "type": "apiContainer", "runtime": "server",
506
+ "props": { "connector": "strapi-blog", "resource": "articles", "singleRecord": true,
507
+ "filters": [ { "field": "slug", "operator": "eq", "value": "{{routeParams.postSlug}}" } ] } } }
508
+ \`\`\`
509
+ Its children then bind to \`apiContainer_post-api.record.<field>\`. A filter whose template resolves to nothing
510
+ returns **no records** rather than the whole collection — a URL that addressed one post never renders a different one.
511
+
512
+ **Paging** is the \`pagination\` prop: \`"none"\`, \`"url"\` (the page number rides the query string, so pages are
513
+ shareable and indexable — prefer it) or \`"append"\` (a "load more" list). Give each list on a page its own
514
+ \`pageParam\` so two lists page independently. The provider also offers the \`loadMore\` and \`goToPage\` callbacks to
515
+ interaction flows, and \`performQuery\` to refetch.
516
+
517
+ **Writing back** (a form, a "delete" button): declare the endpoint under \`endpoints.write\`, then call the provider's
518
+ **\`writeRecord\`** callback from an interaction flow — nodeType \`callback\`, \`elementId\` the apiContainer's ref,
519
+ params \`action\` (the write endpoint's name) and \`recordId\`. The write goes through the server, which owns the
520
+ credential and refuses any action the manifest does not declare. Writes exist **only** on a server-rendered provider.
521
+
522
+ **Connectors need a server.** A space published without server rendering has nowhere to resolve one: it works in the
523
+ builder and renders empty when published. If the user has no SSR deployment, say so rather than leaving them to
524
+ discover it — the alternative is a browser-side \`query\`, which cannot keep a secret.
525
+
526
+ ## Pages & folders
527
+ - **Always set a \`slug\` when creating a page** (\`upsertPage\`) — it is the page's URL path and good practice for a
528
+ clean, stable route (e.g. \`"pricing"\` or \`"posts/:postId"\`). Omit it and the page ref is used as the slug,
529
+ and \`plitzi_validate\`/\`plitzi_apply\` warn so you remember to set a meaningful one.
530
+ - **A page slug is RELATIVE — do NOT start it with \`/\`.** The runtime prepends the leading slash (and any folder
531
+ path) itself, so a leading slash doubles it. Write \`"pricing"\`, not \`"/pricing"\`. (upsertPage strips a leading
532
+ slash for you, but write it relative.)
533
+ - **Dynamic pages — route params.** A slug segment written \`:name\` (e.g. \`"posts/:postId"\`) is a **route param**,
534
+ exactly like React Router. On that page it is readable **two ways**: as \`{{name}}\` inside a prop, and as the
535
+ data-binding source **\`navigation.routeParams.name\`** (the \`navigation\` module source, global — bindable
536
+ anywhere). So a blog is a \`"posts"\` list page plus a \`"posts/:postId"\` detail page whose \`apiContainer\` query
537
+ binds \`navigation.routeParams.postId\` to fetch that one post. (\`navigation.queryParams.<name>\` exposes \`?query=\`
538
+ string params the same way.)
539
+ - **Navigate with the \`Link\` element, not an interaction.** \`link\` is a **container** — it wraps any children and
540
+ navigates on click, so it is the default way to move between pages. Its \`mode\`: \`"page"\` links to another space
541
+ page (set \`href\` to the target page, folder path resolved for you); \`"internal"\` takes a path inside the space and
542
+ resolves \`{{token}}\` templates in it, so a row's "view" link is \`mode:"internal", href:"posts/{{postId}}"\`;
543
+ \`"external"\` is a full URL. \`target\` is \`self\`/\`blank\`/\`parent\`/\`top\`. Reach for the \`navigate\` globalCallback
544
+ only when navigation must be **one step inside a larger interaction flow** (e.g. save, then go) — for a plain link,
545
+ use \`link\`.
546
+
547
+ Pages can be grouped into **folders** (the sidebar tree). A folder is \`{ ref, name, slug, parentId? }\`; its \`ref\`
548
+ **is its id** (there is no separate idRef), and that id is what a page and a nested folder reference.
549
+ - **Folder slugs PREPEND to the page URL — this is how nested URLs are built.** The full path is each ancestor
550
+ folder's slug plus the page slug, joined by \`/\`: a page at slug \`"1-1-1"\` inside \`folder-1\` > \`folder-1-1\`
551
+ resolves to \`/folder-1/folder-1-1/1-1-1\`. So a folder slug is part of the route; keep folder slugs relative too.
552
+ - Create/rename/move a folder with \`upsertFolder\` (the \`ref\` you pass on create becomes its id — pick a stable one
553
+ like \`"blog"\`). Nest it under another with \`parentId\` (a folder ref); \`parentId: null\` moves it back to the root.
554
+ - Put a page in a folder with \`upsertPage\`'s \`folder\` (a folder ref). A page's \`folder\` is always either **empty
555
+ (root)** or an **existing folder id**: \`folder: null\` or \`folder: ""\` moves it to the root, and any other value
556
+ must resolve to a folder that already exists or is created earlier in the same batch — an unknown folder is
557
+ rejected, never stored.
558
+ - \`deleteFolder\` removes a folder and **promotes its contents up one level** — its child folders and its pages move
559
+ to its parent (or the root). A folder cannot be nested under itself or one of its descendants.
560
+ - **Disable a page** with \`upsertPage\`'s \`enabled: false\`; \`enabled: true\` re-enables it (defaults to enabled, and
561
+ a page read reports its current \`enabled\`). Disabling only affects the **published SDK runtime** — the page stops
562
+ being routable/accessible to end users. It stays fully **editable here**: you can still read it and apply any op to
563
+ a disabled page. This does not delete it — \`deletePage\` does.
564
+
565
+ ## Settings
566
+ Space-level configuration lives in \`plitzi://settings/{env}\` and is edited with a single **\`patchSettings\`** op
567
+ (merge — only the fields you pass change):
568
+ - \`customCss\` — **raw global CSS** injected for the whole space. Use it only for genuinely site-wide rules
569
+ (\`@keyframes\`, \`@font-face\`, resets). To style an element, write a **definition** and attach it — never customCss.
570
+ - \`keepState\` / \`stateStorage\` — persist element state across reloads (\`localStorage\`/\`sessionStorage\`).
571
+ - **User provider / auth**: \`userProvider\` — \`basic\` for any HTTP+JSON backend, the name of a provider registered
572
+ in the page, or \`""\` to disable auth — plus \`tokenStorage\`, the \`loginUrl\`/\`userUrl\`/\`refreshUrl\`/\`logoutUrl\`
573
+ endpoints and the \`detailsPath\`/\`tokenPath\`/\`refreshTokenPath\`/\`expirationTimePath\` mapping that says where the
574
+ values sit in their responses. \`sessionHintCookie\` is worth setting whenever the backend can: it names a readable
575
+ cookie carrying only expiries, which is what lets a page answer "nobody is signed in" without a request.
576
+ Example — inject a keyframe globally:
577
+ \`{ "type": "patchSettings", "customCss": "@keyframes spin { to { transform: rotate(360deg); } }" }\`.
578
+
579
+ ## Semantics
580
+ - **props are fully replaced** on \`upsertElement\`: send every prop you want to keep. To change only some props,
581
+ use **\`patchElement\`** — it merges \`props\`/\`style\` onto the existing element (listed keys change, \`null\` unsets
582
+ a key, everything else is preserved) and never creates. Combined with \`plitzi_search\` (which returns the ref +
583
+ stateVersion), a targeted edit is two calls with no read.
584
+ - **definition CSS is fully replaced** on \`upsertDefinition\`: send every property you want to keep. To change only
585
+ some declarations, use **\`patchDefinition\`** — it merges CSS per breakpoint/state/variant/slot onto the existing
586
+ definition (listed keys change, \`null\` removes a property, everything else is preserved) and never creates.
587
+ Example — recolor one definition without resending it: \`{ "type": "patchDefinition", "ref": "btn-x",
588
+ "desktop": { "background-color": "#111" } }\`.
589
+ - **Atomic batches**: if any operation fails, \`plitzi_apply\` persists nothing.
590
+ - **Every resource you touch must be malformation-free — pre-existing errors block the save.** When your batch edits
591
+ an element (or a definition/global/id style), the validator also checks the resource's **current stored content**
592
+ for malformations — a broken transformer action, a malformed interaction node, invalid CSS — even in parts your
593
+ edit does not touch. Such a finding is reported as a \`Pre-existing malformation in <resource>: …\` **error**, and
594
+ \`plitzi_apply\` rejects the batch until it is fixed. These are **not caused by your change** (the message says so)
595
+ — do not be confused; fix them **in the same batch** and re-apply. Because the check runs on the resulting state,
596
+ including the fix in your batch is exactly what unblocks the save. (Advisory issues — an unobserved source/action
597
+ name that may still be a valid plugin, a binding target a plugin manifest does not list — come back as
598
+ \`Pre-existing issue …\` **warnings** and do not block.)
599
+ - **Optimistic concurrency — read before you write, and prove your read is current.** Editing a resource means you
600
+ read it first, so you hold its \`stateVersion\`. **Always pass \`expectedResourceVersions\`** (URI → the stateVersion
601
+ you read) for every resource your batch changes. If another agent edited it in the meantime, the live version no
602
+ longer matches and apply is **rejected with a conflict** — nothing persists. Then re-read the reported resources
603
+ (their new content + version) and retry on top of the fresh state. This is exactly how a file editor forces a
604
+ re-read after a stale write: it is what keeps concurrent agents from silently overwriting each other's changes, so
605
+ never omit it "to save a call".
606
+ `;
607
+ //#endregion
608
+ export { guideQuickstart, guideText, serverInstructions, widgetsOnlyInstructions };