@plitzi/sdk-server 0.32.25 → 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 (514) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +326 -162
  3. package/dist/adapters/authAdapters.d.ts +21 -0
  4. package/dist/adapters/authAdapters.js +12 -0
  5. package/dist/adapters/jsonAdapters.d.ts +15 -0
  6. package/dist/adapters/jsonAdapters.js +9 -4
  7. package/dist/core/auth/api.d.ts +148 -0
  8. package/dist/core/auth/api.js +286 -0
  9. package/dist/core/auth/authorize.d.ts +96 -0
  10. package/dist/core/auth/authorize.js +92 -0
  11. package/dist/core/auth/createAuth.d.ts +165 -0
  12. package/dist/core/auth/createAuth.js +105 -0
  13. package/dist/core/auth/credentials.d.ts +29 -0
  14. package/dist/core/auth/credentials.js +48 -0
  15. package/dist/core/auth/domains.d.ts +41 -0
  16. package/dist/core/auth/domains.js +78 -0
  17. package/dist/core/auth/identity.d.ts +108 -0
  18. package/dist/core/auth/identity.js +164 -0
  19. package/dist/core/auth/oauth/client.d.ts +5 -0
  20. package/dist/core/auth/oauth/client.js +47 -0
  21. package/dist/core/auth/oauth/index.d.ts +78 -0
  22. package/dist/core/auth/oauth/index.js +113 -0
  23. package/dist/core/auth/oauth/providers/github.d.ts +2 -0
  24. package/dist/core/auth/oauth/providers/github.js +48 -0
  25. package/dist/core/auth/oauth/providers/google.d.ts +2 -0
  26. package/dist/core/auth/oauth/providers/google.js +30 -0
  27. package/dist/core/auth/oauth/state.d.ts +23 -0
  28. package/dist/core/auth/oauth/state.js +55 -0
  29. package/dist/core/auth/oauth/types.d.ts +51 -0
  30. package/dist/core/auth/oauth/types.js +13 -0
  31. package/dist/core/auth/routes.d.ts +50 -0
  32. package/dist/core/auth/routes.js +129 -0
  33. package/dist/core/auth/session.d.ts +128 -0
  34. package/dist/core/auth/session.js +165 -0
  35. package/dist/core/auth/spaceTokens.d.ts +137 -0
  36. package/dist/core/auth/spaceTokens.js +212 -0
  37. package/dist/core/auth/tokens.d.ts +151 -0
  38. package/dist/core/auth/tokens.js +221 -0
  39. package/dist/core/createServer.d.ts +29 -0
  40. package/dist/core/createServer.js +28 -14
  41. package/dist/core/handlers/authMiddleware.d.ts +27 -0
  42. package/dist/core/handlers/authMiddleware.js +38 -0
  43. package/dist/core/handlers/authRouteHandlers.d.ts +46 -0
  44. package/dist/core/handlers/authRouteHandlers.js +75 -0
  45. package/dist/core/handlers/types.d.ts +37 -0
  46. package/dist/{src/core → core}/http/dispatcher.d.ts +2 -2
  47. package/dist/core/http/dispatcher.js +8 -6
  48. package/dist/core/http/navigation.d.ts +11 -0
  49. package/dist/core/http/navigation.js +16 -0
  50. package/dist/core/http/securityHeaders.js +6 -4
  51. package/dist/core/http/stages/authApi.d.ts +17 -0
  52. package/dist/core/http/stages/authApi.js +66 -0
  53. package/dist/core/http/stages/authRoutes.js +40 -11
  54. package/dist/core/http/stages/exchangeRoute.d.ts +15 -0
  55. package/dist/core/http/stages/exchangeRoute.js +67 -0
  56. package/dist/core/http/stages/health.d.ts +11 -0
  57. package/dist/core/http/stages/health.js +25 -3
  58. package/dist/core/http/stages/middlewares.d.ts +2 -0
  59. package/dist/core/http/stages/static.d.ts +13 -0
  60. package/dist/core/http/stages/static.js +21 -6
  61. package/dist/core/http/types.d.ts +35 -0
  62. package/dist/{modules/mcp/constants.js → core/previewToken.js} +1 -1
  63. package/dist/core/sdkAssets.d.ts +16 -0
  64. package/dist/core/sdkAssets.js +46 -0
  65. package/dist/core/server/baseServer.js +40 -5
  66. package/dist/core/server/pageServer.d.ts +7 -0
  67. package/dist/core/server/pageServer.js +13 -17
  68. package/dist/core/services/action.d.ts +9 -0
  69. package/dist/core/services/action.js +21 -0
  70. package/dist/core/services/registry.d.ts +3 -0
  71. package/dist/core/services/registry.js +9 -19
  72. package/dist/{src/core → core}/services/resolve.d.ts +1 -0
  73. package/dist/core/services/resolve.js +6 -4
  74. package/dist/core/services/rsc.js +3 -2
  75. package/dist/core/staticFiles.js +1 -1
  76. package/dist/{src/core → core}/transports.d.ts +3 -0
  77. package/dist/core/transports.js +7 -6
  78. package/dist/handlers.d.ts +58 -0
  79. package/dist/handlers.js +3 -0
  80. package/dist/{src/helpers → helpers}/buildResponseHelpers.d.ts +2 -1
  81. package/dist/helpers/buildResponseHelpers.js +13 -4
  82. package/dist/helpers/buildServerInfo.d.ts +3 -0
  83. package/dist/helpers/buildServerInfo.js +25 -3
  84. package/dist/{src/helpers → helpers}/cache/keys.d.ts +5 -1
  85. package/dist/helpers/cache/keys.js +1 -1
  86. package/dist/helpers/compress.d.ts +18 -0
  87. package/dist/helpers/compress.js +47 -11
  88. package/dist/helpers/offlineDataLoader.d.ts +11 -0
  89. package/dist/helpers/offlineDataLoader.js +15 -0
  90. package/dist/helpers/resolveDebugMode.d.ts +10 -0
  91. package/dist/helpers/resolveDebugMode.js +13 -0
  92. package/dist/index.d.ts +16 -2
  93. package/dist/index.js +9 -20
  94. package/dist/kernel.d.ts +41 -0
  95. package/dist/kernel.js +22 -0
  96. package/dist/middlewares/spaceDeployment.d.ts +2 -0
  97. package/dist/middlewares/spaceDeployment.js +2 -1
  98. package/dist/modules/actions/handler.d.ts +11 -0
  99. package/dist/modules/actions/handler.js +77 -0
  100. package/dist/modules/connectors/engine.d.ts +42 -0
  101. package/dist/modules/connectors/engine.js +221 -0
  102. package/dist/modules/connectors/getByPath.d.ts +8 -0
  103. package/dist/modules/connectors/getByPath.js +21 -0
  104. package/dist/modules/connectors/index.d.ts +7 -0
  105. package/dist/modules/connectors/projection.d.ts +18 -0
  106. package/dist/modules/connectors/projection.js +108 -0
  107. package/dist/modules/connectors/resolver.d.ts +18 -0
  108. package/dist/modules/connectors/resolver.js +68 -0
  109. package/dist/modules/connectors/types.d.ts +19 -0
  110. package/dist/{src/modules → modules}/rsc/handler.d.ts +2 -2
  111. package/dist/modules/rsc/handler.js +54 -2
  112. package/dist/modules/rsc/resolveRscData.d.ts +35 -0
  113. package/dist/modules/rsc/resolveRscData.js +74 -0
  114. package/dist/{src/modules → modules}/ssr/Component.d.ts +4 -1
  115. package/dist/modules/ssr/Component.js +10 -3
  116. package/dist/modules/ssr/buildBody.d.ts +9 -0
  117. package/dist/modules/ssr/handler.d.ts +4 -0
  118. package/dist/modules/ssr/handler.js +18 -1
  119. package/dist/{src/modules → modules}/ssr/loadPluginComponents.d.ts +5 -2
  120. package/dist/modules/ssr/loadPluginComponents.js +20 -2
  121. package/dist/{src/modules → modules}/ssr/prepareRender.d.ts +2 -2
  122. package/dist/modules/ssr/prepareRender.js +24 -7
  123. package/dist/modules/ssr/preview.d.ts +10 -0
  124. package/dist/modules/ssr/preview.js +5 -78
  125. package/dist/modules/ssr/registerExternalPlugins.js +1 -1
  126. package/dist/modules/ssr/streamBody.d.ts +5 -0
  127. package/dist/modules/ssr/streamBody.js +1 -1
  128. package/dist/modules/ssr/template.d.ts +2 -0
  129. package/dist/modules/ssr/template.js +1 -1
  130. package/dist/plugins/compile.js +1 -1
  131. package/dist/plugins/manager.js +12 -8
  132. package/dist/ssr.d.ts +15 -0
  133. package/dist/ssr.js +4 -0
  134. package/package.json +29 -25
  135. package/dist/.gitkeep +0 -0
  136. package/dist/core/server/mcpServer.js +0 -29
  137. package/dist/core/services/mcp.js +0 -27
  138. package/dist/core/services/oauth.js +0 -116
  139. package/dist/core/services/preview.js +0 -37
  140. package/dist/core/services/proxy.js +0 -12
  141. package/dist/mcp.d.ts +0 -2
  142. package/dist/mcp.js +0 -7
  143. package/dist/modules/ai/AIEngine.js +0 -120
  144. package/dist/modules/ai/toolkit.js +0 -59
  145. package/dist/modules/mcp/apps/example/view/index.tsx +0 -70
  146. package/dist/modules/mcp/apps/index.js +0 -16
  147. package/dist/modules/mcp/apps/render/index.js +0 -17
  148. package/dist/modules/mcp/apps/render/styles.js +0 -54
  149. package/dist/modules/mcp/apps/render/view/heldBatch.ts +0 -107
  150. package/dist/modules/mcp/apps/render/view/index.tsx +0 -314
  151. package/dist/modules/mcp/apps/render/view/streamProgress.ts +0 -137
  152. package/dist/modules/mcp/apps/shared/assets.js +0 -10
  153. package/dist/modules/mcp/apps/shared/bundle.js +0 -23
  154. package/dist/modules/mcp/apps/shared/page.js +0 -34
  155. package/dist/modules/mcp/apps/shared/registerApp.js +0 -43
  156. package/dist/modules/mcp/apps/shared/resolve.js +0 -5
  157. package/dist/modules/mcp/apps/shared/shell.ejs +0 -59
  158. package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +0 -23
  159. package/dist/modules/mcp/catalogs/builtinCallbacks.js +0 -204
  160. package/dist/modules/mcp/catalogs/builtinComponents.js +0 -170
  161. package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +0 -50
  162. package/dist/modules/mcp/catalogs/builtinTransformers.js +0 -148
  163. package/dist/modules/mcp/catalogs/builtinUtilities.js +0 -90
  164. package/dist/modules/mcp/catalogs/cssCatalog/border.js +0 -30
  165. package/dist/modules/mcp/catalogs/cssCatalog/box.js +0 -31
  166. package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +0 -185
  167. package/dist/modules/mcp/catalogs/cssCatalog/index.js +0 -131
  168. package/dist/modules/mcp/catalogs/cssCatalog/layout.js +0 -98
  169. package/dist/modules/mcp/catalogs/cssCatalog/visual.js +0 -144
  170. package/dist/modules/mcp/catalogs/observed.js +0 -90
  171. package/dist/modules/mcp/catalogs/paramSpec.js +0 -69
  172. package/dist/modules/mcp/catalogs/registry.js +0 -89
  173. package/dist/modules/mcp/handler.js +0 -83
  174. package/dist/modules/mcp/helpers/agentPrompt.js +0 -104
  175. package/dist/modules/mcp/helpers/computeVersion.js +0 -16
  176. package/dist/modules/mcp/helpers/guide.js +0 -467
  177. package/dist/modules/mcp/helpers/interactions.js +0 -123
  178. package/dist/modules/mcp/helpers/log.js +0 -64
  179. package/dist/modules/mcp/helpers/opResult.js +0 -18
  180. package/dist/modules/mcp/helpers/space.js +0 -300
  181. package/dist/modules/mcp/helpers/uris.js +0 -44
  182. package/dist/modules/mcp/previewClient.js +0 -31
  183. package/dist/modules/mcp/proxy/config.js +0 -63
  184. package/dist/modules/mcp/proxy/fetch.js +0 -91
  185. package/dist/modules/mcp/proxy/grant.js +0 -67
  186. package/dist/modules/mcp/proxy/guard.js +0 -38
  187. package/dist/modules/mcp/proxy/handler.js +0 -99
  188. package/dist/modules/mcp/proxy/payload.js +0 -29
  189. package/dist/modules/mcp/proxy/rewrite.js +0 -138
  190. package/dist/modules/mcp/proxy/sign.js +0 -15
  191. package/dist/modules/mcp/proxy/types.js +0 -9
  192. package/dist/modules/mcp/resources/canonical.js +0 -30
  193. package/dist/modules/mcp/resources/core.js +0 -18
  194. package/dist/modules/mcp/resources/envelope.js +0 -14
  195. package/dist/modules/mcp/resources/primer.js +0 -31
  196. package/dist/modules/mcp/resources/register.js +0 -190
  197. package/dist/modules/mcp/resources/renderGuide.js +0 -451
  198. package/dist/modules/mcp/resources/router.js +0 -37
  199. package/dist/modules/mcp/resources/schema.js +0 -43
  200. package/dist/modules/mcp/resources/style.js +0 -34
  201. package/dist/modules/mcp/screenshotClient.js +0 -47
  202. package/dist/modules/mcp/server.js +0 -113
  203. package/dist/modules/mcp/tools/apply/dispatch.js +0 -105
  204. package/dist/modules/mcp/tools/apply/index.js +0 -150
  205. package/dist/modules/mcp/tools/apply/writeResult.js +0 -37
  206. package/dist/modules/mcp/tools/index.js +0 -24
  207. package/dist/modules/mcp/tools/operations/index.js +0 -45
  208. package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +0 -32
  209. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +0 -36
  210. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +0 -47
  211. package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +0 -29
  212. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +0 -41
  213. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +0 -58
  214. package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +0 -148
  215. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +0 -65
  216. package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +0 -30
  217. package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +0 -49
  218. package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +0 -52
  219. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +0 -47
  220. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +0 -44
  221. package/dist/modules/mcp/tools/operations/schema/operations.js +0 -41
  222. package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +0 -25
  223. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +0 -75
  224. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +0 -45
  225. package/dist/modules/mcp/tools/operations/schema/shared.js +0 -122
  226. package/dist/modules/mcp/tools/operations/schema/translator.js +0 -215
  227. package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +0 -18
  228. package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +0 -42
  229. package/dist/modules/mcp/tools/operations/schema/write.js +0 -109
  230. package/dist/modules/mcp/tools/operations/schemaIds.js +0 -54
  231. package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +0 -21
  232. package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +0 -28
  233. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +0 -24
  234. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +0 -40
  235. package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +0 -21
  236. package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +0 -28
  237. package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +0 -24
  238. package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +0 -21
  239. package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +0 -28
  240. package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +0 -24
  241. package/dist/modules/mcp/tools/operations/style/operations.js +0 -29
  242. package/dist/modules/mcp/tools/operations/style/shared.js +0 -59
  243. package/dist/modules/mcp/tools/operations/style/translator.js +0 -101
  244. package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +0 -21
  245. package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +0 -22
  246. package/dist/modules/mcp/tools/operations/style/write.js +0 -108
  247. package/dist/modules/mcp/tools/preview.js +0 -37
  248. package/dist/modules/mcp/tools/read.js +0 -51
  249. package/dist/modules/mcp/tools/render.js +0 -184
  250. package/dist/modules/mcp/tools/screenshot.js +0 -83
  251. package/dist/modules/mcp/tools/search.js +0 -115
  252. package/dist/modules/mcp/tools/shared/expandOperations.js +0 -44
  253. package/dist/modules/mcp/tools/shared/tool.js +0 -33
  254. package/dist/modules/mcp/tools/shared/validator/audit.js +0 -124
  255. package/dist/modules/mcp/tools/shared/validator/batch.js +0 -39
  256. package/dist/modules/mcp/tools/shared/validator/bindings.js +0 -70
  257. package/dist/modules/mcp/tools/shared/validator/context.js +0 -35
  258. package/dist/modules/mcp/tools/shared/validator/css.js +0 -39
  259. package/dist/modules/mcp/tools/shared/validator/elements.js +0 -68
  260. package/dist/modules/mcp/tools/shared/validator/index.js +0 -246
  261. package/dist/modules/mcp/tools/shared/validator/interactions.js +0 -103
  262. package/dist/modules/mcp/tools/shared/validator/refs.js +0 -28
  263. package/dist/modules/mcp/tools/validate.js +0 -47
  264. package/dist/modules/oauth/authorize.js +0 -177
  265. package/dist/modules/oauth/challenge.js +0 -33
  266. package/dist/modules/oauth/consentPage.js +0 -118
  267. package/dist/modules/oauth/metadata.js +0 -69
  268. package/dist/modules/oauth/params.js +0 -5
  269. package/dist/modules/oauth/pkce.js +0 -15
  270. package/dist/modules/oauth/records.js +0 -46
  271. package/dist/modules/oauth/register.js +0 -55
  272. package/dist/modules/oauth/respond.js +0 -44
  273. package/dist/modules/oauth/token.js +0 -100
  274. package/dist/public/.gitkeep +0 -0
  275. package/dist/src/adapters/jsonAdapters.d.ts +0 -7
  276. package/dist/src/core/createServer.d.ts +0 -14
  277. package/dist/src/core/http/stages/health.d.ts +0 -2
  278. package/dist/src/core/http/stages/middlewares.d.ts +0 -2
  279. package/dist/src/core/http/stages/static.d.ts +0 -5
  280. package/dist/src/core/http/types.d.ts +0 -22
  281. package/dist/src/core/server/mcpServer.d.ts +0 -2
  282. package/dist/src/core/server/pageServer.d.ts +0 -10
  283. package/dist/src/core/services/mcp.d.ts +0 -3
  284. package/dist/src/core/services/oauth.d.ts +0 -18
  285. package/dist/src/core/services/preview.d.ts +0 -2
  286. package/dist/src/core/services/proxy.d.ts +0 -2
  287. package/dist/src/core/services/registry.d.ts +0 -4
  288. package/dist/src/helpers/buildServerInfo.d.ts +0 -2
  289. package/dist/src/helpers/compress.d.ts +0 -3
  290. package/dist/src/index.d.ts +0 -15
  291. package/dist/src/mcp.d.ts +0 -14
  292. package/dist/src/middlewares/spaceDeployment.d.ts +0 -2
  293. package/dist/src/modules/ai/AIEngine.d.ts +0 -20
  294. package/dist/src/modules/ai/index.d.ts +0 -4
  295. package/dist/src/modules/ai/toolkit.d.ts +0 -17
  296. package/dist/src/modules/mcp/apps/example/index.d.ts +0 -8
  297. package/dist/src/modules/mcp/apps/index.d.ts +0 -11
  298. package/dist/src/modules/mcp/apps/render/index.d.ts +0 -4
  299. package/dist/src/modules/mcp/apps/render/styles.d.ts +0 -10
  300. package/dist/src/modules/mcp/apps/shared/assets.d.ts +0 -10
  301. package/dist/src/modules/mcp/apps/shared/bundle.d.ts +0 -4
  302. package/dist/src/modules/mcp/apps/shared/index.d.ts +0 -3
  303. package/dist/src/modules/mcp/apps/shared/page.d.ts +0 -2
  304. package/dist/src/modules/mcp/apps/shared/registerApp.d.ts +0 -5
  305. package/dist/src/modules/mcp/apps/shared/resolve.d.ts +0 -1
  306. package/dist/src/modules/mcp/apps/shared/zodEnglishOnly.d.ts +0 -4
  307. package/dist/src/modules/mcp/catalogs/builtinCallbacks.d.ts +0 -23
  308. package/dist/src/modules/mcp/catalogs/builtinComponents.d.ts +0 -4
  309. package/dist/src/modules/mcp/catalogs/builtinElementCallbacks.d.ts +0 -20
  310. package/dist/src/modules/mcp/catalogs/builtinTransformers.d.ts +0 -28
  311. package/dist/src/modules/mcp/catalogs/builtinUtilities.d.ts +0 -18
  312. package/dist/src/modules/mcp/catalogs/cssCatalog/border.d.ts +0 -4
  313. package/dist/src/modules/mcp/catalogs/cssCatalog/box.d.ts +0 -4
  314. package/dist/src/modules/mcp/catalogs/cssCatalog/helpers.d.ts +0 -34
  315. package/dist/src/modules/mcp/catalogs/cssCatalog/index.d.ts +0 -19
  316. package/dist/src/modules/mcp/catalogs/cssCatalog/layout.d.ts +0 -9
  317. package/dist/src/modules/mcp/catalogs/cssCatalog/visual.d.ts +0 -8
  318. package/dist/src/modules/mcp/catalogs/index.d.ts +0 -9
  319. package/dist/src/modules/mcp/catalogs/observed.d.ts +0 -48
  320. package/dist/src/modules/mcp/catalogs/paramSpec.d.ts +0 -42
  321. package/dist/src/modules/mcp/catalogs/registry.d.ts +0 -35
  322. package/dist/src/modules/mcp/e2e/index.d.ts +0 -6
  323. package/dist/src/modules/mcp/e2e/mcpEndpoint.d.ts +0 -27
  324. package/dist/src/modules/mcp/e2e/postMessageChannel.d.ts +0 -22
  325. package/dist/src/modules/mcp/e2e/renderingHost.d.ts +0 -34
  326. package/dist/src/modules/mcp/handler.d.ts +0 -22
  327. package/dist/src/modules/mcp/helpers/agentPrompt.d.ts +0 -4
  328. package/dist/src/modules/mcp/helpers/computeVersion.d.ts +0 -1
  329. package/dist/src/modules/mcp/helpers/guide.d.ts +0 -4
  330. package/dist/src/modules/mcp/helpers/index.d.ts +0 -8
  331. package/dist/src/modules/mcp/helpers/interactions.d.ts +0 -30
  332. package/dist/src/modules/mcp/helpers/log.d.ts +0 -8
  333. package/dist/src/modules/mcp/helpers/opResult.d.ts +0 -13
  334. package/dist/src/modules/mcp/helpers/space.d.ts +0 -115
  335. package/dist/src/modules/mcp/helpers/uris.d.ts +0 -28
  336. package/dist/src/modules/mcp/index.d.ts +0 -13
  337. package/dist/src/modules/mcp/previewClient.d.ts +0 -13
  338. package/dist/src/modules/mcp/proxy/config.d.ts +0 -19
  339. package/dist/src/modules/mcp/proxy/fetch.d.ts +0 -18
  340. package/dist/src/modules/mcp/proxy/grant.d.ts +0 -25
  341. package/dist/src/modules/mcp/proxy/guard.d.ts +0 -6
  342. package/dist/src/modules/mcp/proxy/handler.d.ts +0 -8
  343. package/dist/src/modules/mcp/proxy/index.d.ts +0 -8
  344. package/dist/src/modules/mcp/proxy/payload.d.ts +0 -8
  345. package/dist/src/modules/mcp/proxy/rewrite.d.ts +0 -18
  346. package/dist/src/modules/mcp/proxy/sign.d.ts +0 -6
  347. package/dist/src/modules/mcp/proxy/types.d.ts +0 -45
  348. package/dist/src/modules/mcp/resources/canonical.d.ts +0 -6
  349. package/dist/src/modules/mcp/resources/core.d.ts +0 -5
  350. package/dist/src/modules/mcp/resources/envelope.d.ts +0 -10
  351. package/dist/src/modules/mcp/resources/index.d.ts +0 -8
  352. package/dist/src/modules/mcp/resources/primer.d.ts +0 -7
  353. package/dist/src/modules/mcp/resources/register.d.ts +0 -10
  354. package/dist/src/modules/mcp/resources/renderGuide.d.ts +0 -10
  355. package/dist/src/modules/mcp/resources/router.d.ts +0 -10
  356. package/dist/src/modules/mcp/resources/schema.d.ts +0 -5
  357. package/dist/src/modules/mcp/resources/style.d.ts +0 -5
  358. package/dist/src/modules/mcp/screenshotClient.d.ts +0 -13
  359. package/dist/src/modules/mcp/server.d.ts +0 -31
  360. package/dist/src/modules/mcp/tests/helpers.d.ts +0 -13
  361. package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +0 -6
  362. package/dist/src/modules/mcp/tools/apply/index.d.ts +0 -470
  363. package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +0 -8
  364. package/dist/src/modules/mcp/tools/index.d.ts +0 -18
  365. package/dist/src/modules/mcp/tools/operations/index.d.ts +0 -928
  366. package/dist/src/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +0 -17
  367. package/dist/src/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +0 -25
  368. package/dist/src/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +0 -27
  369. package/dist/src/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +0 -10
  370. package/dist/src/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +0 -16
  371. package/dist/src/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +0 -22
  372. package/dist/src/modules/mcp/tools/operations/schema/elements/repeatElement.d.ts +0 -55
  373. package/dist/src/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +0 -16
  374. package/dist/src/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +0 -9
  375. package/dist/src/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +0 -12
  376. package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +0 -21
  377. package/dist/src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +0 -12
  378. package/dist/src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +0 -18
  379. package/dist/src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +0 -27
  380. package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +0 -229
  381. package/dist/src/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +0 -9
  382. package/dist/src/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +0 -14
  383. package/dist/src/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +0 -34
  384. package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +0 -92
  385. package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +0 -12
  386. package/dist/src/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +0 -9
  387. package/dist/src/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +0 -16
  388. package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +0 -42
  389. package/dist/src/modules/mcp/tools/operations/schemaIds.d.ts +0 -6
  390. package/dist/src/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +0 -9
  391. package/dist/src/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +0 -37
  392. package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +0 -37
  393. package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinitions.d.ts +0 -41
  394. package/dist/src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +0 -9
  395. package/dist/src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +0 -37
  396. package/dist/src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +0 -37
  397. package/dist/src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +0 -9
  398. package/dist/src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +0 -37
  399. package/dist/src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +0 -37
  400. package/dist/src/modules/mcp/tools/operations/style/index.d.ts +0 -15
  401. package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +0 -264
  402. package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +0 -116
  403. package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +0 -12
  404. package/dist/src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +0 -15
  405. package/dist/src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +0 -20
  406. package/dist/src/modules/mcp/tools/operations/style/write.d.ts +0 -12
  407. package/dist/src/modules/mcp/tools/preview.d.ts +0 -465
  408. package/dist/src/modules/mcp/tools/read.d.ts +0 -9
  409. package/dist/src/modules/mcp/tools/render.d.ts +0 -499
  410. package/dist/src/modules/mcp/tools/render.test.d.ts +0 -1
  411. package/dist/src/modules/mcp/tools/screenshot.d.ts +0 -470
  412. package/dist/src/modules/mcp/tools/search.d.ts +0 -15
  413. package/dist/src/modules/mcp/tools/shared/expandOperations.d.ts +0 -13
  414. package/dist/src/modules/mcp/tools/shared/tool.d.ts +0 -72
  415. package/dist/src/modules/mcp/tools/shared/validator/audit.d.ts +0 -4
  416. package/dist/src/modules/mcp/tools/shared/validator/batch.d.ts +0 -5
  417. package/dist/src/modules/mcp/tools/shared/validator/bindings.d.ts +0 -6
  418. package/dist/src/modules/mcp/tools/shared/validator/context.d.ts +0 -38
  419. package/dist/src/modules/mcp/tools/shared/validator/css.d.ts +0 -4
  420. package/dist/src/modules/mcp/tools/shared/validator/elements.d.ts +0 -7
  421. package/dist/src/modules/mcp/tools/shared/validator/index.d.ts +0 -8
  422. package/dist/src/modules/mcp/tools/shared/validator/interactions.d.ts +0 -3
  423. package/dist/src/modules/mcp/tools/shared/validator/refs.d.ts +0 -4
  424. package/dist/src/modules/mcp/tools/validate.d.ts +0 -467
  425. package/dist/src/modules/mcp/types/aiSchema.d.ts +0 -218
  426. package/dist/src/modules/mcp/types/appTypes.d.ts +0 -26
  427. package/dist/src/modules/mcp/types/index.d.ts +0 -5
  428. package/dist/src/modules/mcp/types/previewTypes.d.ts +0 -25
  429. package/dist/src/modules/mcp/types/screenshotTypes.d.ts +0 -29
  430. package/dist/src/modules/mcp/types/toolTypes.d.ts +0 -138
  431. package/dist/src/modules/oauth/authorize.d.ts +0 -7
  432. package/dist/src/modules/oauth/challenge.d.ts +0 -11
  433. package/dist/src/modules/oauth/consentPage.d.ts +0 -7
  434. package/dist/src/modules/oauth/metadata.d.ts +0 -40
  435. package/dist/src/modules/oauth/params.d.ts +0 -5
  436. package/dist/src/modules/oauth/pkce.d.ts +0 -6
  437. package/dist/src/modules/oauth/records.d.ts +0 -71
  438. package/dist/src/modules/oauth/register.d.ts +0 -5
  439. package/dist/src/modules/oauth/respond.d.ts +0 -13
  440. package/dist/src/modules/oauth/token.d.ts +0 -5
  441. package/dist/src/modules/ssr/buildBody.d.ts +0 -9
  442. package/dist/src/modules/ssr/handler.d.ts +0 -4
  443. package/dist/src/modules/ssr/preview.d.ts +0 -16
  444. package/dist/src/modules/ssr/streamBody.d.ts +0 -5
  445. package/dist/src/modules/ssr/template.d.ts +0 -6
  446. package/dist/src/standalone/alias-loader.d.mts +0 -2
  447. package/dist/src/standalone/plugins/ClientInfo.d.ts +0 -2
  448. package/dist/src/standalone/plugins/ServerInfo.d.ts +0 -2
  449. package/dist/src/standalone/plugins/SharedInfo.d.ts +0 -2
  450. package/dist/src/standalone/plugins/styles.d.ts +0 -5
  451. package/dist/src/standalone/register-alias.d.mts +0 -1
  452. package/dist/src/standalone/server.d.ts +0 -1
  453. package/dist/src/standalone/stubs/react-syntax-highlighter.d.mts +0 -31
  454. package/skills/plitzi-render/SKILL.md +0 -174
  455. /package/dist/{src/core/http/dispatcher.test.d.ts → core/auth/api.test.d.ts} +0 -0
  456. /package/dist/{src/core/server/mcpServer.test.d.ts → core/auth/authorize.test.d.ts} +0 -0
  457. /package/dist/{src/modules/ai/toolkit.test.d.ts → core/auth/createAuth.test.d.ts} +0 -0
  458. /package/dist/{src/modules/mcp/apps/apps.test.d.ts → core/auth/domains.test.d.ts} +0 -0
  459. /package/dist/{src/modules/mcp/apps/render/styles.test.d.ts → core/auth/identity.test.d.ts} +0 -0
  460. /package/dist/{src/modules → core/auth}/oauth/oauth.test.d.ts +0 -0
  461. /package/dist/{src/modules/mcp/catalogs/builtinTransformers.test.d.ts → core/auth/routes.test.d.ts} +0 -0
  462. /package/dist/{src/modules/mcp/catalogs/cssCatalog/cssCatalog.test.d.ts → core/auth/session.test.d.ts} +0 -0
  463. /package/dist/{src/modules/mcp/e2e/connector.test.d.ts → core/auth/spaceTokens.test.d.ts} +0 -0
  464. /package/dist/{src/modules/mcp/e2e/host.test.d.ts → core/auth/tokens.test.d.ts} +0 -0
  465. /package/dist/{src/modules/mcp/e2e/oauthConnector.test.d.ts → core/createServer.test.d.ts} +0 -0
  466. /package/dist/{src/modules/mcp/helpers/log.test.d.ts → core/handlers/handlers.test.d.ts} +0 -0
  467. /package/dist/{src/core → core}/health.d.ts +0 -0
  468. /package/dist/{src/modules/mcp/mcp.bench.d.ts → core/http/dispatcher.test.d.ts} +0 -0
  469. /package/dist/{src/core → core}/http/securityHeaders.d.ts +0 -0
  470. /package/dist/{src/core → core}/http/stages/authRoutes.d.ts +0 -0
  471. /package/dist/{src/core → core}/http/stages/pluginAssets.d.ts +0 -0
  472. /package/dist/{src/core → core}/mimeTypes.d.ts +0 -0
  473. /package/dist/{src/modules/mcp/constants.d.ts → core/previewToken.d.ts} +0 -0
  474. /package/dist/{src/core → core}/requestParser.d.ts +0 -0
  475. /package/dist/{src/core → core}/server/baseServer.d.ts +0 -0
  476. /package/dist/{src/modules/mcp/proxy/endpoint.test.d.ts → core/server/baseServer.test.d.ts} +0 -0
  477. /package/dist/{src/modules/mcp/proxy/proxy.test.d.ts → core/services/resolve.test.d.ts} +0 -0
  478. /package/dist/{src/core → core}/services/rsc.d.ts +0 -0
  479. /package/dist/{src/core → core}/services/ssr.d.ts +0 -0
  480. /package/dist/{src/core → core}/staticFiles.d.ts +0 -0
  481. /package/dist/{src/modules/mcp/proxy/wiring.test.d.ts → helpers/buildResponseHelpers.test.d.ts} +0 -0
  482. /package/dist/{src/helpers → helpers}/cache/TtlCache.d.ts +0 -0
  483. /package/dist/{src/helpers → helpers}/cache/cacheManager.d.ts +0 -0
  484. /package/dist/{src/helpers → helpers}/cache/defaults.d.ts +0 -0
  485. /package/dist/{src/helpers → helpers}/cache/index.d.ts +0 -0
  486. /package/dist/{src/modules/mcp/tests/apply.test.d.ts → helpers/cache/keys.test.d.ts} +0 -0
  487. /package/dist/{src/helpers → helpers}/cache/serverCaches.d.ts +0 -0
  488. /package/dist/{src/modules/mcp/tests/bindings.test.d.ts → helpers/compress.test.d.ts} +0 -0
  489. /package/dist/{src/helpers → helpers}/escapeJson.d.ts +0 -0
  490. /package/dist/{src/helpers → helpers}/metrics.d.ts +0 -0
  491. /package/dist/{src/helpers → helpers}/normalizePlugins.d.ts +0 -0
  492. /package/dist/{src/modules/mcp/tests/css.test.d.ts → helpers/offlineDataLoader.test.d.ts} +0 -0
  493. /package/dist/{src/helpers → helpers}/readCookie.d.ts +0 -0
  494. /package/dist/{src/modules/mcp/tests/interactions.test.d.ts → helpers/resolveDebugMode.test.d.ts} +0 -0
  495. /package/dist/{src/helpers → helpers}/runMiddlewares.d.ts +0 -0
  496. /package/dist/{src/helpers → helpers}/serverLog.d.ts +0 -0
  497. /package/dist/{src/middlewares → middlewares}/auth.d.ts +0 -0
  498. /package/dist/{src/middlewares → middlewares}/basicAuth.d.ts +0 -0
  499. /package/dist/{src/modules/mcp/tests/pages.test.d.ts → middlewares/spaceDeployment.test.d.ts} +0 -0
  500. /package/dist/{src/modules/mcp/tests/reads.test.d.ts → modules/actions/handler.test.d.ts} +0 -0
  501. /package/dist/{src/modules/mcp/tests/schemaIds.test.d.ts → modules/connectors/engine.test.d.ts} +0 -0
  502. /package/dist/{src/modules/mcp/tests/search.test.d.ts → modules/connectors/projection.test.d.ts} +0 -0
  503. /package/dist/{src/modules/mcp/tests/skill.test.d.ts → modules/connectors/resolver.test.d.ts} +0 -0
  504. /package/dist/{src/modules/mcp/tests/styles.test.d.ts → modules/rsc/resolveRscData.test.d.ts} +0 -0
  505. /package/dist/{src/modules → modules}/ssr/applySSRResult.d.ts +0 -0
  506. /package/dist/{src/modules/mcp/tests/tools.test.d.ts → modules/ssr/loadPluginComponents.test.d.ts} +0 -0
  507. /package/dist/{src/modules/mcp/tests/validation.test.d.ts → modules/ssr/metering.test.d.ts} +0 -0
  508. /package/dist/{src/modules → modules}/ssr/registerExternalPlugins.d.ts +0 -0
  509. /package/dist/{src/plugins → plugins}/compile.d.ts +0 -0
  510. /package/dist/{src/plugins → plugins}/copy.d.ts +0 -0
  511. /package/dist/{src/plugins → plugins}/detect.d.ts +0 -0
  512. /package/dist/{src/plugins → plugins}/manager.d.ts +0 -0
  513. /package/dist/{src/plugins → plugins}/validate.d.ts +0 -0
  514. /package/dist/{src/plugins → plugins}/validate.test.d.ts +0 -0
@@ -0,0 +1,21 @@
1
+ //#region src/modules/connectors/getByPath.ts
2
+ /**
3
+ * Reads a dot path out of an arbitrary JSON response (`data.items`, `meta.pagination.total`). Kept local and
4
+ * dependency-free on purpose: the equivalent helper in plitzi-ui would drag the UI bundle into the request path.
5
+ *
6
+ * A path of `.` or an empty path returns the value itself, which is how a manifest says "the response *is* the
7
+ * array" or "the record *is* its own values".
8
+ */
9
+ var getByPath = (source, path) => {
10
+ if (!path || path === ".") return source;
11
+ return path.split(".").reduce((current, key) => {
12
+ if (current === null || current === void 0) return;
13
+ if (Array.isArray(current)) {
14
+ const index = Number(key);
15
+ return Number.isInteger(index) ? current[index] : void 0;
16
+ }
17
+ if (typeof current === "object") return current[key];
18
+ }, source);
19
+ };
20
+ //#endregion
21
+ export { getByPath };
@@ -0,0 +1,7 @@
1
+ export { fetchConnectorRecords, rebaseMedia, writeConnectorRecord } from './engine';
2
+ export { createConnectorResolver } from './resolver';
3
+ export { getByPath } from './getByPath';
4
+ export { collectBoundPaths, projectSlice } from './projection';
5
+ export type { FetchConnectorOptions, WriteConnectorOptions } from './engine';
6
+ export type { ConnectorLookups, ProviderPagination } from './resolver';
7
+ export type { ConnectorAuth, ConnectorCredential, ConnectorEndpoints, ConnectorFilter, ConnectorManifest, ConnectorManifestDraft, ConnectorPageInfo, ConnectorPagination, ConnectorQuery, ConnectorReadEndpoint, ConnectorRecord, ConnectorResponseMapping, ConnectorResult, ConnectorWriteEndpoint } from './types';
@@ -0,0 +1,18 @@
1
+ import { Element } from '@plitzi/sdk-shared';
2
+ /**
3
+ * Collects the paths a page actually reads out of one provider source.
4
+ *
5
+ * Bindings declare `<source>.<path>` directly; transformer params, `when` rules and attribute templates can carry
6
+ * the same reference inside a twig token, so both are scanned. Returning an empty set means nothing statically
7
+ * references the source — the caller must then keep the slice whole rather than serve an empty one.
8
+ */
9
+ export declare const collectBoundPaths: (flat: Record<string, Element>, rootId: string, sourceName: string) => string[];
10
+ /**
11
+ * Narrows a provider slice to what the page reads.
12
+ *
13
+ * A CMS entry routinely carries fields nobody bound — author emails, internal notes, unpublished translations.
14
+ * Those would otherwise land in the client store and in the HTML, so anything unreferenced is dropped here. With no
15
+ * declared paths the slice passes through untouched: an empty projection would blank the page, and shipping too
16
+ * much is a smaller failure than rendering nothing.
17
+ */
18
+ export declare const projectSlice: (slice: unknown, paths: string[]) => unknown;
@@ -0,0 +1,108 @@
1
+ //#region src/modules/connectors/projection.ts
2
+ /**
3
+ * Structural keys a page needs regardless of what it binds, so paging and empty states never depend on static
4
+ * analysis. A pager binds `pageInfo.*` and an empty state binds `isEmpty`; both would otherwise be projected away
5
+ * for any page that reads neither.
6
+ */
7
+ var ALWAYS_KEPT = [
8
+ "pageInfo",
9
+ "isEmpty",
10
+ "hasError",
11
+ "errorMessage"
12
+ ];
13
+ var createNode = () => ({
14
+ leaf: false,
15
+ children: /* @__PURE__ */ new Map()
16
+ });
17
+ var insert = (root, segments) => {
18
+ let node = root;
19
+ for (const segment of segments) {
20
+ const key = /^\d+$/.test(segment) ? "*" : segment;
21
+ let next = node.children.get(key);
22
+ if (!next) {
23
+ next = createNode();
24
+ node.children.set(key, next);
25
+ }
26
+ node = next;
27
+ }
28
+ node.leaf = true;
29
+ };
30
+ /** Pulls `<source>.<path>` references out of any string that may carry a twig token. */
31
+ var collectFromTemplate = (value, sourceName, found) => {
32
+ if (typeof value !== "string") return;
33
+ const pattern = new RegExp(`${sourceName}\\.([a-zA-Z0-9_\\-.]+)`, "g");
34
+ for (const match of value.matchAll(pattern)) found.add(match[1].replace(/\.$/, ""));
35
+ };
36
+ var walkUnknown = (value, sourceName, found) => {
37
+ if (typeof value === "string") {
38
+ collectFromTemplate(value, sourceName, found);
39
+ return;
40
+ }
41
+ if (Array.isArray(value)) {
42
+ value.forEach((entry) => walkUnknown(entry, sourceName, found));
43
+ return;
44
+ }
45
+ if (value !== null && typeof value === "object") Object.values(value).forEach((entry) => walkUnknown(entry, sourceName, found));
46
+ };
47
+ /**
48
+ * Collects the paths a page actually reads out of one provider source.
49
+ *
50
+ * Bindings declare `<source>.<path>` directly; transformer params, `when` rules and attribute templates can carry
51
+ * the same reference inside a twig token, so both are scanned. Returning an empty set means nothing statically
52
+ * references the source — the caller must then keep the slice whole rather than serve an empty one.
53
+ */
54
+ var collectBoundPaths = (flat, rootId, sourceName) => {
55
+ if (!sourceName) return [];
56
+ const found = /* @__PURE__ */ new Set();
57
+ const seen = /* @__PURE__ */ new Set();
58
+ const pending = [rootId];
59
+ const prefix = `${sourceName}.`;
60
+ while (pending.length > 0) {
61
+ const id = pending.pop();
62
+ if (id === void 0 || seen.has(id)) continue;
63
+ seen.add(id);
64
+ const element = flat[id];
65
+ if (!element) continue;
66
+ const { bindings, items } = element.definition;
67
+ Object.values(bindings ?? {}).forEach((categoryBindings) => {
68
+ categoryBindings.forEach((binding) => {
69
+ if (binding.source.startsWith(prefix)) found.add(binding.source.slice(prefix.length));
70
+ walkUnknown(binding.transformers, sourceName, found);
71
+ walkUnknown(binding.when, sourceName, found);
72
+ });
73
+ });
74
+ walkUnknown(element.attributes, sourceName, found);
75
+ if (items) pending.push(...items);
76
+ }
77
+ return [...found];
78
+ };
79
+ var projectNode = (value, node) => {
80
+ if (node.leaf || node.children.size === 0) return value;
81
+ if (Array.isArray(value)) {
82
+ const itemNode = node.children.get("*");
83
+ return value.map((item) => projectNode(item, itemNode ?? node));
84
+ }
85
+ if (value === null || typeof value !== "object") return value;
86
+ const source = value;
87
+ return [...node.children.entries()].reduce((acum, [key, child]) => {
88
+ if (key !== "*" && key in source) acum[key] = projectNode(source[key], child);
89
+ return acum;
90
+ }, {});
91
+ };
92
+ /**
93
+ * Narrows a provider slice to what the page reads.
94
+ *
95
+ * A CMS entry routinely carries fields nobody bound — author emails, internal notes, unpublished translations.
96
+ * Those would otherwise land in the client store and in the HTML, so anything unreferenced is dropped here. With no
97
+ * declared paths the slice passes through untouched: an empty projection would blank the page, and shipping too
98
+ * much is a smaller failure than rendering nothing.
99
+ */
100
+ var projectSlice = (slice, paths) => {
101
+ if (paths.length === 0 || slice === null || typeof slice !== "object") return slice;
102
+ const root = createNode();
103
+ paths.forEach((path) => insert(root, path.split(".")));
104
+ ALWAYS_KEPT.forEach((key) => insert(root, [key]));
105
+ return projectNode(slice, root);
106
+ };
107
+ //#endregion
108
+ export { collectBoundPaths, projectSlice };
@@ -0,0 +1,18 @@
1
+ import { ConnectorCredential, ConnectorManifest } from './types';
2
+ import { RscElementResolver } from '../rsc/resolveRscData';
3
+ export type ConnectorLookups = {
4
+ /** Reads a manifest by id. Server-side state: manifests name endpoints and must never reach the browser. */
5
+ getConnector: (spaceId: number, connectorId: string) => Promise<ConnectorManifest | undefined>;
6
+ /** Resolves the secret referenced by `manifest.credential`. */
7
+ getCredential?: (spaceId: number, identifier: string) => Promise<ConnectorCredential | undefined>;
8
+ fetchImpl?: typeof fetch;
9
+ };
10
+ export type ProviderPagination = 'none' | 'url' | 'append';
11
+ /**
12
+ * Bridges the connector engine into the RSC pipeline: reads the provider element's own configuration, resolves its
13
+ * manifest and credential server-side, and returns the slice the element will publish as a binding source.
14
+ *
15
+ * An element without a connector resolves to nothing rather than failing — an unconfigured provider on a page is a
16
+ * draft, not an error.
17
+ */
18
+ export declare const createConnectorResolver: ({ getConnector, getCredential, fetchImpl }: ConnectorLookups) => RscElementResolver;
@@ -0,0 +1,68 @@
1
+ import { fetchConnectorRecords } from "./engine.js";
2
+ import { collectBoundPaths, projectSlice } from "./projection.js";
3
+ import getSourceName from "@plitzi/sdk-shared/dataSource/helpers/getSourceName";
4
+ //#region src/modules/connectors/resolver.ts
5
+ var DEFAULT_PAGE_PARAM = "page";
6
+ var toLimit = (limit, singleRecord) => {
7
+ if (singleRecord) return 1;
8
+ const parsed = typeof limit === "string" ? parseInt(limit, 10) : limit;
9
+ return parsed !== void 0 && !Number.isNaN(parsed) ? parsed : void 0;
10
+ };
11
+ /**
12
+ * Reads the requested page out of the request's query string.
13
+ *
14
+ * Both pagination modes arrive here: URL paging puts the parameter in the visitor's address bar, and append mode
15
+ * puts the same parameter on its `/_rsc` refresh. One code path, so a "load more" window and a shared link of the
16
+ * same page resolve to the same records.
17
+ */
18
+ var toPage = (queryParams, attributes) => {
19
+ if (attributes.pagination === "none" || attributes.singleRecord) return 1;
20
+ const raw = queryParams[attributes.pageParam ?? DEFAULT_PAGE_PARAM];
21
+ const parsed = raw ? parseInt(raw, 10) : NaN;
22
+ return Number.isNaN(parsed) || parsed < 1 ? 1 : parsed;
23
+ };
24
+ /**
25
+ * Bridges the connector engine into the RSC pipeline: reads the provider element's own configuration, resolves its
26
+ * manifest and credential server-side, and returns the slice the element will publish as a binding source.
27
+ *
28
+ * An element without a connector resolves to nothing rather than failing — an unconfigured provider on a page is a
29
+ * draft, not an error.
30
+ */
31
+ var createConnectorResolver = ({ getConnector, getCredential, fetchImpl }) => async ({ element, flat, routeParams, queryParams, spaceId }) => {
32
+ const attributes = element.attributes;
33
+ const { connector: connectorId, endpoint, resource, limit, singleRecord = false, filters } = attributes;
34
+ if (!connectorId) return;
35
+ const manifest = await getConnector(spaceId, connectorId);
36
+ if (!manifest) throw new Error(`Connector "${connectorId}" is not configured for space ${spaceId}`);
37
+ const credential = manifest.credential && getCredential ? await getCredential(spaceId, manifest.credential) : void 0;
38
+ const pageSize = toLimit(limit, singleRecord);
39
+ const page = toPage(queryParams, attributes);
40
+ const pageParam = attributes.pageParam ?? DEFAULT_PAGE_PARAM;
41
+ const { records, pageInfo } = await fetchConnectorRecords({
42
+ manifest,
43
+ endpoint,
44
+ credential,
45
+ query: {
46
+ resource,
47
+ limit: pageSize,
48
+ offset: pageSize === void 0 ? void 0 : (page - 1) * pageSize,
49
+ page,
50
+ cursor: queryParams[`${pageParam}Cursor`],
51
+ filters,
52
+ routeParams,
53
+ queryParams
54
+ },
55
+ fetchImpl
56
+ });
57
+ const slice = {
58
+ ...singleRecord ? { record: records[0] } : { records },
59
+ pageInfo,
60
+ isEmpty: records.length === 0,
61
+ hasError: false,
62
+ errorMessage: ""
63
+ };
64
+ if (manifest.projection === "full") return slice;
65
+ return projectSlice(slice, collectBoundPaths(flat, element.id, getSourceName(element.definition.type, element)));
66
+ };
67
+ //#endregion
68
+ export { createConnectorResolver };
@@ -0,0 +1,19 @@
1
+ import { ConnectorRecord, PageInfo } from '@plitzi/sdk-shared';
2
+ /**
3
+ * The manifest vocabulary lives in `@plitzi/sdk-shared` because the builder authors the document the engine
4
+ * executes. Only the result shapes below are server-side: nothing outside this process ever sees them.
5
+ */
6
+ export type { ConnectorAuth, ConnectorCredential, ConnectorEndpoints, ConnectorFilter, ConnectorManifest, ConnectorManifestDraft, ConnectorPagination, ConnectorQuery, ConnectorReadEndpoint, ConnectorRecord, ConnectorResponseMapping, ConnectorWriteEndpoint } from '@plitzi/sdk-shared';
7
+ /**
8
+ * `PageInfo` is the cursor-shaped connection contract shared with GraphQL. A pager cannot be rendered from cursors
9
+ * alone, so a connector result also carries the ordinal window it just read.
10
+ */
11
+ export type ConnectorPageInfo = PageInfo & {
12
+ page: number;
13
+ /** Total pages when the provider reports a total; `0` when it does not and paging relies on page size. */
14
+ pageCount: number;
15
+ };
16
+ export type ConnectorResult = {
17
+ records: ConnectorRecord[];
18
+ pageInfo: ConnectorPageInfo;
19
+ };
@@ -1,6 +1,6 @@
1
1
  import { TtlCache } from '../../helpers/cache';
2
2
  import { PluginManager } from '../../plugins/manager';
3
- import { SSRRequest, SSRResponseHelpers, SSRServerConfig } from '@plitzi/sdk-shared';
3
+ import { SSRPageServerConfig, SSRRequest, SSRResponseHelpers } from '@plitzi/sdk-shared';
4
4
  /**
5
5
  * Handles GET /_rsc requests.
6
6
  *
@@ -14,4 +14,4 @@ import { SSRRequest, SSRResponseHelpers, SSRServerConfig } from '@plitzi/sdk-sha
14
14
  * - Authenticated requests: Cache-Control: private, max-age=<ttl>
15
15
  * - Unauthenticated requests: Cache-Control: public, max-age=<ttl>
16
16
  */
17
- export declare const handleRsc: (req: SSRRequest, res: SSRResponseHelpers, config: SSRServerConfig, _pluginManager: PluginManager, cache?: TtlCache<string>) => Promise<void>;
17
+ export declare const handleRsc: (req: SSRRequest, res: SSRResponseHelpers, config: SSRPageServerConfig, _pluginManager: PluginManager, cache?: TtlCache<string>) => Promise<void>;
@@ -1,6 +1,48 @@
1
1
  import { DEFAULT_TTL_MS } from "../../helpers/cache/defaults.js";
2
2
  import { buildRscCacheKey } from "../../helpers/cache/keys.js";
3
+ import { createOfflineDataLoader } from "../../helpers/offlineDataLoader.js";
3
4
  //#region src/modules/rsc/handler.ts
5
+ /** Bounds the reflected location: it only ever selects one of this space's own pages, but it is still input. */
6
+ var MAX_PAGE_LOCATION = 2048;
7
+ var meterRsc = async (req, config, spaceId, environment, revision, cached) => {
8
+ if (!config.adapters.meter) return;
9
+ try {
10
+ await config.adapters.meter({
11
+ kind: "rsc_query",
12
+ cached,
13
+ req,
14
+ spaceId,
15
+ environment,
16
+ revision
17
+ });
18
+ } catch {}
19
+ };
20
+ /**
21
+ * Rewrites the request to the page the browser is actually on.
22
+ *
23
+ * A refresh is issued against `/_rsc`, not against `/blog/my-post`, so resolving straight from `req.path` matches
24
+ * nothing in `schema.pages` and every client-side refresh silently returns no data. The SDK sends the visitor's
25
+ * location as `?location=`, and route params plus the page parameter are read from that instead.
26
+ *
27
+ * Reflecting it is safe by construction: it is matched against this space's own page list, so the worst a forged
28
+ * value can do is resolve a page the same visitor could have loaded directly.
29
+ */
30
+ var withPageLocation = (req) => {
31
+ const location = req.query.location;
32
+ if (!location || !location.startsWith("/") || location.length > MAX_PAGE_LOCATION) return req;
33
+ const url = new URL(location, `${req.protocol}://${req.hostname}`);
34
+ const query = [...url.searchParams.entries()].reduce((acum, [key, value]) => {
35
+ acum[key] = value;
36
+ return acum;
37
+ }, {});
38
+ return {
39
+ ...req,
40
+ path: url.pathname,
41
+ search: url.search,
42
+ url: `${url.pathname}${url.search}`,
43
+ query
44
+ };
45
+ };
4
46
  /**
5
47
  * Handles GET /_rsc requests.
6
48
  *
@@ -29,11 +71,13 @@ var handleRsc = async (req, res, config, _pluginManager, cache) => {
29
71
  const idsRaw = req.query.ids;
30
72
  const ids = idsRaw ? idsRaw.split(",").filter(Boolean).slice(0, 50).map((id) => id.slice(0, 128)) : void 0;
31
73
  const idsParam = ids?.join(",");
74
+ const pageRequest = withPageLocation(req);
32
75
  const ttlMs = config.rsc?.cacheTtlMs ?? DEFAULT_TTL_MS.rsc;
33
76
  const isAuthenticated = !!req.ctx.user;
34
77
  const cacheControl = environment === "main" ? "no-store" : isAuthenticated ? `private, max-age=${Math.floor(ttlMs / 1e3)}` : `public, max-age=${Math.floor(ttlMs / 1e3)}`;
35
- const cacheKey = environment !== "main" ? buildRscCacheKey(spaceId, environment, revision, req.ctx.user?.id, idsParam) : void 0;
78
+ const cacheKey = environment !== "main" ? buildRscCacheKey(spaceId, environment, revision, req.ctx.user?.id, idsParam, req) : void 0;
36
79
  const cached = cacheKey ? cache?.get(cacheKey) : void 0;
80
+ await meterRsc(req, config, spaceId, environment, revision, !!cached);
37
81
  if (cached) {
38
82
  res.setHeader("Content-Type", "application/json; charset=utf-8");
39
83
  res.setHeader("Cache-Control", cacheControl);
@@ -43,7 +87,15 @@ var handleRsc = async (req, res, config, _pluginManager, cache) => {
43
87
  }
44
88
  let rscData;
45
89
  try {
46
- rscData = await config.adapters.getRscData(req, spaceId, environment, revision, req.ctx.user, ids);
90
+ rscData = await config.adapters.getRscData({
91
+ req: pageRequest,
92
+ spaceId,
93
+ environment,
94
+ revision,
95
+ user: req.ctx.user,
96
+ ids,
97
+ loadOfflineData: createOfflineDataLoader(() => config.adapters.getOfflineData(spaceId, environment, revision))
98
+ });
47
99
  } catch (err) {
48
100
  console.error("[RSC] getRscData error:", err);
49
101
  res.setStatus(500);
@@ -0,0 +1,35 @@
1
+ import { Element, Environment, Schema, SSRRequest, SSRRscData, SSRUser } from '@plitzi/sdk-shared';
2
+ /** Everything an element resolver needs to turn one `runtime: 'server'` element into its data slice. */
3
+ export type RscResolveContext = {
4
+ element: Element;
5
+ /** The whole element map, so a resolver can inspect the subtree that consumes its data. */
6
+ flat: Record<string, Element>;
7
+ routeParams: Record<string, string | undefined>;
8
+ queryParams: Record<string, string>;
9
+ req: SSRRequest;
10
+ spaceId: number;
11
+ environment: Environment;
12
+ user: SSRUser | undefined;
13
+ };
14
+ /** Produces the data slice for a single server element. Returning undefined leaves the element out of the payload. */
15
+ export type RscElementResolver = (context: RscResolveContext) => Promise<unknown>;
16
+ export type ResolveRscDataOptions = {
17
+ schema: Schema;
18
+ req: SSRRequest;
19
+ spaceId: number;
20
+ environment: Environment;
21
+ user: SSRUser | undefined;
22
+ /** Restricts resolution to these element ids (partial refresh). Undefined resolves every server element. */
23
+ ids?: string[];
24
+ resolveElement: RscElementResolver;
25
+ /** Per-element budget. One slow provider must not hold the whole payload. */
26
+ timeoutMs?: number;
27
+ };
28
+ /**
29
+ * Resolves the server-side data slices for the page addressed by `req`.
30
+ *
31
+ * The URL is matched against the schema's pages with the same matcher the client router uses, so the element set
32
+ * and the route params are what the browser will see. Each `runtime: 'server'` element resolves independently:
33
+ * a provider that fails or hangs costs its own slice and nothing else.
34
+ */
35
+ export declare const resolveRscData: ({ schema, req, spaceId, environment, user, ids, resolveElement, timeoutMs }: ResolveRscDataOptions) => Promise<SSRRscData>;
@@ -0,0 +1,74 @@
1
+ import { getPaths, matchRoutePath } from "@plitzi/sdk-shared/navigation";
2
+ //#region src/modules/rsc/resolveRscData.ts
3
+ var DEFAULT_ELEMENT_TIMEOUT_MS = 5e3;
4
+ /** Depth-first walk of a page subtree. Iterative to stay safe on deeply nested schemas. */
5
+ var collectSubtree = (flat, rootId) => {
6
+ const collected = [];
7
+ const seen = /* @__PURE__ */ new Set();
8
+ const pending = [rootId];
9
+ while (pending.length > 0) {
10
+ const id = pending.pop();
11
+ if (id === void 0 || seen.has(id)) continue;
12
+ seen.add(id);
13
+ const element = flat[id];
14
+ if (!element) continue;
15
+ collected.push(element);
16
+ const { items } = element.definition;
17
+ if (items) pending.push(...items);
18
+ }
19
+ return collected;
20
+ };
21
+ var withTimeout = async (promise, timeoutMs, label) => {
22
+ let timer;
23
+ try {
24
+ return await Promise.race([promise, new Promise((_resolve, reject) => {
25
+ timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`RSC resolution timed out after ${timeoutMs}ms for ${label}`)), timeoutMs);
26
+ })]);
27
+ } finally {
28
+ if (timer) clearTimeout(timer);
29
+ }
30
+ };
31
+ /**
32
+ * Resolves the server-side data slices for the page addressed by `req`.
33
+ *
34
+ * The URL is matched against the schema's pages with the same matcher the client router uses, so the element set
35
+ * and the route params are what the browser will see. Each `runtime: 'server'` element resolves independently:
36
+ * a provider that fails or hangs costs its own slice and nothing else.
37
+ */
38
+ var resolveRscData = async ({ schema, req, spaceId, environment, user, ids, resolveElement, timeoutMs = DEFAULT_ELEMENT_TIMEOUT_MS }) => {
39
+ if (schema.rsc?.enabled === false) return {};
40
+ const pages = schema.pages.reduce((acum, pageId) => {
41
+ const page = schema.flat[pageId];
42
+ if (page) acum[pageId] = page;
43
+ return acum;
44
+ }, {});
45
+ const paths = getPaths(pages, schema.pageFolders, !!user);
46
+ const { pageId, pathMatch } = matchRoutePath(paths, req.path, !!user);
47
+ if (!pageId) return { serverData: {} };
48
+ const routeParams = pathMatch?.params ?? {};
49
+ const requested = ids ? new Set(ids) : void 0;
50
+ const targets = collectSubtree(schema.flat, pageId).filter((element) => element.definition.runtime === "server" && (!requested || requested.has(element.id)));
51
+ if (targets.length === 0) return { serverData: {} };
52
+ return { serverData: (await Promise.allSettled(targets.map(async (element) => ({
53
+ id: element.id,
54
+ data: await withTimeout(resolveElement({
55
+ element,
56
+ flat: schema.flat,
57
+ routeParams,
58
+ queryParams: req.query,
59
+ req,
60
+ spaceId,
61
+ environment,
62
+ user
63
+ }), timeoutMs, `element ${element.id}`)
64
+ })))).reduce((acum, result, index) => {
65
+ if (result.status === "rejected") {
66
+ console.error(`[RSC] element ${targets[index].id} failed to resolve:`, result.reason);
67
+ return acum;
68
+ }
69
+ if (result.value.data !== void 0) acum[result.value.id] = result.value.data;
70
+ return acum;
71
+ }, {}) };
72
+ };
73
+ //#endregion
74
+ export { resolveRscData };
@@ -9,6 +9,9 @@ export type ComponentProps = {
9
9
  ssrResult?: SSRRenderResult;
10
10
  sdkDevToolsStylePath?: string;
11
11
  debugMode?: boolean;
12
+ /** Forced on when the metering adapter degrades this render; otherwise left to the SDK's own default so the
13
+ * markup here matches what the browser hydrates with. */
14
+ branding?: boolean;
12
15
  };
13
- declare const Component: ({ server, renderMode, previewMode, offlineData, environment, plugins, ssrResult, sdkDevToolsStylePath, debugMode }: ComponentProps) => import("react").JSX.Element;
16
+ declare const Component: ({ server, renderMode, previewMode, offlineData, environment, plugins, ssrResult, sdkDevToolsStylePath, debugMode, branding }: ComponentProps) => import("react").JSX.Element;
14
17
  export default Component;
@@ -1,17 +1,24 @@
1
1
  import PlitziSdk from "@plitzi/plitzi-sdk";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  //#region src/modules/ssr/Component.tsx
4
- var Component = ({ server, renderMode = "raw", previewMode = true, offlineData, environment = "main", plugins, ssrResult, sdkDevToolsStylePath, debugMode = false }) => {
4
+ var Component = ({ server, renderMode = "raw", previewMode = true, offlineData, environment = "main", plugins, ssrResult, sdkDevToolsStylePath, debugMode = false, branding }) => {
5
+ const serverWithResult = {
6
+ ...server,
7
+ ssr: {
8
+ ...server.ssr,
9
+ renderResult: ssrResult
10
+ }
11
+ };
5
12
  return /* @__PURE__ */ jsx(PlitziSdk, {
6
13
  environment,
7
- server,
14
+ server: serverWithResult,
8
15
  previewMode,
9
16
  renderMode,
10
17
  offlineMode: !!offlineData && Object.keys(offlineData).length > 0,
11
18
  offlineData,
12
- ssrResult,
13
19
  sdkDevToolsStylePath,
14
20
  debugMode,
21
+ ...branding === void 0 ? {} : { branding },
15
22
  children: plugins && Object.keys(plugins).map((key) => /* @__PURE__ */ jsx(PlitziSdk.Plugin, {
16
23
  renderType: key,
17
24
  component: plugins[key].component,
@@ -0,0 +1,9 @@
1
+ import { TtlCache } from '../../helpers/cache';
2
+ import { RequestMetrics } from '../../helpers/metrics';
3
+ import { PluginManager } from '../../plugins/manager';
4
+ import { Environment, OfflineDataRaw, SSRPageServerConfig, SSRRenderResult, SSRRequest, SSRTemplateFn } from '@plitzi/sdk-shared';
5
+ export type BuildBodyResult = {
6
+ body?: string;
7
+ result: SSRRenderResult;
8
+ };
9
+ export declare const buildBody: (req: SSRRequest, config: SSRPageServerConfig, spaceId: number, environment: Environment, revision: number, renderFn: SSRTemplateFn, pluginManager: PluginManager, offlineDataCache?: TtlCache<string>, metrics?: RequestMetrics, offlineDataOverride?: OfflineDataRaw) => Promise<BuildBodyResult>;
@@ -0,0 +1,4 @@
1
+ import { ServerCaches } from '../../helpers/cache';
2
+ import { PluginManager } from '../../plugins/manager';
3
+ import { SSRPageServerConfig, SSRRequest, SSRResponseHelpers, SSRTemplateFn } from '@plitzi/sdk-shared';
4
+ export declare const renderSSR: (req: SSRRequest, res: SSRResponseHelpers, config: SSRPageServerConfig, renderFn: SSRTemplateFn, pluginManager: PluginManager, caches: ServerCaches) => Promise<void>;
@@ -1,10 +1,25 @@
1
1
  import { buildHtmlCacheKey } from "../../helpers/cache/keys.js";
2
- import { buildBody } from "./buildBody.js";
3
2
  import { takeDraftOverride } from "./preview.js";
4
3
  import { applySSRResult } from "./applySSRResult.js";
4
+ import { buildBody } from "./buildBody.js";
5
5
  import { streamBody } from "./streamBody.js";
6
6
  import { RequestMetrics } from "../../helpers/metrics.js";
7
7
  //#region src/modules/ssr/handler.tsx
8
+ var meterPage = async (req, config, spaceId, environment, revision, cached) => {
9
+ if (!config.adapters.meter) return;
10
+ try {
11
+ return await config.adapters.meter({
12
+ kind: "page_view",
13
+ cached,
14
+ req,
15
+ spaceId,
16
+ environment,
17
+ revision
18
+ });
19
+ } catch {
20
+ return;
21
+ }
22
+ };
8
23
  var renderSSR = async (req, res, config, renderFn, pluginManager, caches) => {
9
24
  const { environment = "main", spaceId = 1, revision = 0 } = req.ctx.spaceDeployment || {};
10
25
  const devMode = config.devMode ?? false;
@@ -17,10 +32,12 @@ var renderSSR = async (req, res, config, renderFn, pluginManager, caches) => {
17
32
  if (cached) {
18
33
  res.setHeader("X-Cache", "HIT");
19
34
  if (devMode) res.setHeader("Server-Timing", "html;desc=\"cache-hit\";dur=0");
35
+ await meterPage(req, config, spaceId, environment, revision, true);
20
36
  res.send(cached);
21
37
  return;
22
38
  }
23
39
  }
40
+ if (!offlineDataOverride) req.ctx.meter = await meterPage(req, config, spaceId, environment, revision, false);
24
41
  const metrics = devMode ? new RequestMetrics() : void 0;
25
42
  if (cacheKey) res.setHeader("X-Cache", "MISS");
26
43
  if (config.streaming) {
@@ -9,5 +9,8 @@ import { PluginEntry, SSRPlugin } from '@plitzi/sdk-shared';
9
9
  * Component-source plugins (already in memory via getComponents()) are merged in directly.
10
10
  */
11
11
  export declare const loadPluginComponents: (entries: PluginEntry[], inlineComponents?: Record<string, unknown>) => Promise<Record<string, SSRPlugin>>;
12
- /** Removes one or all entries from the component and failed-import caches. Call after plugin rebuild. */
13
- export declare const invalidatePluginComponentCache: (filePath?: string) => void;
12
+ /** Drop the loaded-component and failed-import caches and force the next import to re-read from disk. A plugin
13
+ * rebuilt at the SAME version lands back on the same path, so without this an invalidation refreshes the build
14
+ * on disk while every render keeps serving the component imported before it. The plugin manager owns its own
15
+ * caches and cannot reach these, which is why invalidation has to clear both sides. */
16
+ export declare const invalidatePluginComponentCache: () => void;
@@ -1,6 +1,15 @@
1
+ import { pathToFileURL } from "node:url";
1
2
  //#region src/modules/ssr/loadPluginComponents.ts
2
3
  /** Module-level cache: absolute filePath → loaded React component. */
3
4
  var componentCache = /* @__PURE__ */ new Map();
5
+ /** Bumped on invalidation and appended to the import URL. Node's ESM registry caches a module by URL for the
6
+ * life of the process — clearing the Map above is not enough, since a rebuilt plugin lands back on the same
7
+ * path and `import()` would hand back the module loaded before it. A changed URL is the only way to re-read.
8
+ * Stays at 0 until something actually invalidates, so a normal render imports the plain path and every
9
+ * subsequent one hits Node's cache. Superseded generations stay resident: the registry has no eviction, which
10
+ * is the price of reloading at all and why this is driven by explicit invalidation rather than per-request. */
11
+ var generation = 0;
12
+ var importUrl = (filePath) => generation === 0 ? filePath : `${pathToFileURL(filePath).href}?g=${generation}`;
4
13
  /**
5
14
  * Plugins that failed to import (e.g. browser-only code like `document`).
6
15
  * These are permanently skipped on the server and fall through to client-side rendering.
@@ -26,7 +35,7 @@ var loadPluginComponents = async (entries, inlineComponents) => {
26
35
  if (failedImports.has(filePath)) return;
27
36
  let component = componentCache.get(filePath);
28
37
  if (!component) try {
29
- const mod = await import(filePath);
38
+ const mod = await import(importUrl(filePath));
30
39
  component = mod.default ?? mod;
31
40
  componentCache.set(filePath, component);
32
41
  } catch (err) {
@@ -41,5 +50,14 @@ var loadPluginComponents = async (entries, inlineComponents) => {
41
50
  }));
42
51
  return result;
43
52
  };
53
+ /** Drop the loaded-component and failed-import caches and force the next import to re-read from disk. A plugin
54
+ * rebuilt at the SAME version lands back on the same path, so without this an invalidation refreshes the build
55
+ * on disk while every render keeps serving the component imported before it. The plugin manager owns its own
56
+ * caches and cannot reach these, which is why invalidation has to clear both sides. */
57
+ var invalidatePluginComponentCache = () => {
58
+ componentCache.clear();
59
+ failedImports.clear();
60
+ generation += 1;
61
+ };
44
62
  //#endregion
45
- export { loadPluginComponents };
63
+ export { invalidatePluginComponentCache, loadPluginComponents };
@@ -2,7 +2,7 @@ import { ComponentProps } from './Component';
2
2
  import { TtlCache } from '../../helpers/cache';
3
3
  import { RequestMetrics } from '../../helpers/metrics';
4
4
  import { PluginManager } from '../../plugins/manager';
5
- import { Environment, OfflineDataRaw, PluginEntry, SSRRequest, SSRServerConfig, SSRTemplateProps } from '@plitzi/sdk-shared';
5
+ import { Environment, OfflineDataRaw, PluginEntry, SSRPageServerConfig, SSRRequest, SSRTemplateProps } from '@plitzi/sdk-shared';
6
6
  export type RenderPrep = {
7
7
  componentProps: ComponentProps;
8
8
  entries: PluginEntry[];
@@ -10,4 +10,4 @@ export type RenderPrep = {
10
10
  offlineData: string;
11
11
  };
12
12
  };
13
- export declare const prepareRender: (req: SSRRequest, config: SSRServerConfig, spaceId: number, environment: Environment, revision: number, pluginManager: PluginManager, offlineDataCache?: TtlCache<string>, metrics?: RequestMetrics, offlineDataOverride?: OfflineDataRaw) => Promise<RenderPrep>;
13
+ export declare const prepareRender: (req: SSRRequest, config: SSRPageServerConfig, spaceId: number, environment: Environment, revision: number, pluginManager: PluginManager, offlineDataCache?: TtlCache<string>, metrics?: RequestMetrics, offlineDataOverride?: OfflineDataRaw) => Promise<RenderPrep>;