@salsita-ai/sdk 0.50.0-develop.3ca14b02a8 → 0.50.0-develop.3f44338ee8

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 (228) hide show
  1. package/dist/application/index.d.ts +1 -0
  2. package/dist/application/index.js +1 -1
  3. package/dist/application/mount-application.d.ts +1 -1
  4. package/dist/application/mount-application.js +1 -1
  5. package/dist/application/mount-configurator.d.ts +19 -0
  6. package/dist/application/mount-configurator.js +1 -0
  7. package/dist/application/mounted-application-runtime.d.ts +4 -0
  8. package/dist/application/mounted-application-runtime.js +1 -0
  9. package/dist/application/register-web-component.d.ts +2 -0
  10. package/dist/application/register-web-component.js +1 -0
  11. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +11 -5
  12. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +1 -1
  13. package/dist/application-spec/generate-application/implementations/phx-application-types.d.ts +25 -0
  14. package/dist/application-spec/generate-application/implementations/phx-application-types.js +1 -0
  15. package/dist/application-spec/generate-application/implementations/phx-domain.d.ts +36 -0
  16. package/dist/application-spec/generate-application/implementations/phx-domain.js +1 -0
  17. package/dist/application-spec/generate-application/implementations/phx-model.d.ts +24 -0
  18. package/dist/application-spec/generate-application/implementations/phx-model.js +1 -0
  19. package/dist/application-spec/generate-application/implementations/phx.d.ts +22 -0
  20. package/dist/application-spec/generate-application/implementations/phx.js +1 -0
  21. package/dist/application-spec/generate-application/index.d.ts +2 -0
  22. package/dist/application-spec/generate-application/index.js +1 -1
  23. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-model-runtime.d.ts +3 -3
  24. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-runtime.d.ts +7 -4
  25. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-runtime.js +1 -1
  26. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-spec-runtime.d.ts +16 -0
  27. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-spec-runtime.js +1 -0
  28. package/dist/application-spec/generate-application/runtime/application-runtime.d.ts +17 -4
  29. package/dist/application-spec/generate-application/runtime/application-runtime.js +1 -1
  30. package/dist/application-spec/generate-application/runtime/application-spec-slice.d.ts +71 -0
  31. package/dist/application-spec/generate-application/runtime/application-spec-slice.js +1 -0
  32. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-model-runtime.d.ts +3 -3
  33. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.d.ts +7 -5
  34. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.js +1 -1
  35. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-spec-runtime.d.ts +16 -0
  36. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-spec-runtime.js +1 -0
  37. package/dist/application-spec/generate-application/runtime/create-application.d.ts +57 -0
  38. package/dist/application-spec/generate-application/runtime/create-application.js +1 -0
  39. package/dist/application-spec/generate-application/runtime/index.d.ts +8 -0
  40. package/dist/application-spec/generate-application/runtime/index.js +1 -0
  41. package/dist/application-spec/generate-application/runtime/sections/expression-runtime.d.ts +9 -3
  42. package/dist/application-spec/generate-application/runtime/sections/expression-runtime.js +1 -1
  43. package/dist/application-spec/generate-application/runtime/spec-runtime.d.ts +21 -0
  44. package/dist/application-spec/generate-application/runtime/spec-runtime.js +1 -0
  45. package/dist/application-spec/generate-application/runtime-spec/encoded-runtime-spec.d.ts +3 -2
  46. package/dist/application-spec/generate-application/runtime-spec/runtime-spec.d.ts +44 -9
  47. package/dist/application-spec/generate-application/runtime-spec/runtime-spec.js +1 -1
  48. package/dist/configurator/ConfiguratorApp.js +1 -1
  49. package/dist/configurator/app-loader-content/index.d.ts +0 -1
  50. package/dist/configurator/app-loader-content/index.js +1 -1
  51. package/dist/configurator/common/configurator-interface.d.ts +3 -5
  52. package/dist/configurator/common/configurator-interface.js +1 -1
  53. package/dist/configurator/configuration-not-found-page/BuiltInConfigurationNotFoundPage.d.ts +5 -0
  54. package/dist/configurator/configuration-not-found-page/BuiltInConfigurationNotFoundPage.js +1 -0
  55. package/dist/configurator/configuration-not-found-page/ConfigurationNotFoundPageElement.d.ts +0 -6
  56. package/dist/configurator/configuration-not-found-page/ConfigurationNotFoundPageElement.js +1 -1
  57. package/dist/configurator/configuration-not-found-page/index.d.ts +2 -2
  58. package/dist/configurator/configuration-not-found-page/index.js +1 -1
  59. package/dist/configurator/configurator-error-page/BuiltInConfiguratorErrorPage.d.ts +3 -3
  60. package/dist/configurator/configurator-error-page/BuiltInConfiguratorErrorPage.js +1 -1
  61. package/dist/configurator/configurator-error-page/ConfiguratorErrorPageElement.d.ts +0 -5
  62. package/dist/configurator/configurator-error-page/ConfiguratorErrorPageElement.js +1 -1
  63. package/dist/configurator/configurator-error-page/index.d.ts +1 -2
  64. package/dist/configurator/configurator-error-page/index.js +1 -1
  65. package/dist/configurator/index.d.ts +9 -2
  66. package/dist/configurator/index.js +1 -1
  67. package/dist/configurator/pages/default-configurator-elements.js +1 -1
  68. package/dist/configurator/pages/error-boundaries/LoadingErrorBoundary.js +1 -1
  69. package/dist/configurator/ui/configurator-layout/slots/canvas/LayoutCanvas.js +1 -1
  70. package/dist/configurator/ui/configurator-layout/slots/canvas/SharedCanvas.js +1 -1
  71. package/dist/configurator/ui/legacy/layout/common/ReactiveInterfaceLayout.js +1 -1
  72. package/dist/configurator/ui/phoenix-layout-elements/AppLoader.d.ts +0 -7
  73. package/dist/configurator/ui/phoenix-layout-elements/AppLoader.js +2 -2
  74. package/dist/configurator/ui/phoenix-layout-elements/index.d.ts +8 -1
  75. package/dist/configurator/ui/phoenix-layout-elements/index.js +1 -1
  76. package/dist/configurator/ui/preset-layout/PresetUi.d.ts +0 -2
  77. package/dist/configurator/ui/preset-layout/PresetUi.js +1 -1
  78. package/dist/configurator/ui/preset-layout/index.d.ts +6 -1
  79. package/dist/configurator/ui/preset-layout/index.js +1 -1
  80. package/dist/docs/index.json +34 -1
  81. package/dist/docs/integrations/webcomponent-api/basics.mdx +2 -0
  82. package/dist/docs/layouts/gallery/corvid-drone.mdx +3428 -0
  83. package/dist/docs/layouts/gallery/nightjar-guitar.mdx +3698 -0
  84. package/dist/docs/layouts/gallery/tidepool-aquascape.mdx +5203 -0
  85. package/dist/docs/phoenix/configurator-interface.mdx +5 -4
  86. package/dist/docs/phoenix/sdk-builder-workflow.mdx +4 -2
  87. package/dist/domain/application/configurator-builder.d.ts +7 -1
  88. package/dist/domain/application/configurator-builder.js +1 -1
  89. package/dist/domain/application/index.d.ts +1 -1
  90. package/dist/domain/application/index.js +1 -1
  91. package/dist/domain/application/standard-properties.js +1 -1
  92. package/dist/domain/application/web-component-property.d.ts +3 -1
  93. package/dist/domain/application/web-component-property.js +1 -1
  94. package/dist/domain/domain-builder.d.ts +9 -3
  95. package/dist/domain/domain-builder.js +1 -1
  96. package/dist/domain/domain-runtime/application.d.ts +39 -0
  97. package/dist/domain/domain-runtime/application.js +1 -0
  98. package/dist/domain/domain-runtime/domain-runtime.d.ts +36 -4
  99. package/dist/domain/domain-runtime/domain-runtime.js +1 -1
  100. package/dist/domain/domain-runtime/environment/initialize.d.ts +1 -1
  101. package/dist/domain/domain-runtime/errors/implementation-error-collector.d.ts +2 -0
  102. package/dist/domain/domain-runtime/errors/implementation-error-collector.js +1 -1
  103. package/dist/domain/domain-runtime/index.d.ts +2 -1
  104. package/dist/domain/domain-runtime/index.js +1 -1
  105. package/dist/domain/domain-runtime/spec/index.d.ts +1 -1
  106. package/dist/domain/domain-runtime/spec/index.js +1 -1
  107. package/dist/domain/domain-runtime/spec/module-checks/index.d.ts +1 -0
  108. package/dist/domain/domain-runtime/spec/module-checks/index.js +1 -1
  109. package/dist/domain/domain-runtime/spec/module-checks/merge-expression-modules.d.ts +23 -0
  110. package/dist/domain/domain-runtime/spec/module-checks/merge-expression-modules.js +1 -0
  111. package/dist/domain/domain-runtime/spec/module-checks/resolve-expression-modules.d.ts +3 -4
  112. package/dist/domain/domain-runtime/spec/module-checks/resolve-expression-modules.js +1 -1
  113. package/dist/domain/domain-runtime/web-component/actions.d.ts +3 -0
  114. package/dist/domain/domain-runtime/web-component/actions.js +1 -1
  115. package/dist/domain/domain-runtime/web-component/initialize.d.ts +1 -0
  116. package/dist/domain/domain-runtime/web-component/initialize.js +1 -1
  117. package/dist/domain/domain-runtime/web-component/selectors.d.ts +2 -0
  118. package/dist/domain/domain-runtime/web-component/selectors.js +1 -1
  119. package/dist/domain/domain-runtime/web-component/types.d.ts +6 -3
  120. package/dist/domain/mocks/create-mock-domain-runtime.d.ts +5 -0
  121. package/dist/editor/domain-editors/DomainSpecContext.js +1 -1
  122. package/dist/editor/domain-editors/apply-spec-update.d.ts +2 -1
  123. package/dist/editor/domain-editors/apply-spec-update.js +1 -1
  124. package/dist/editor/domain-editors/use-implementation-files.d.ts +6 -14
  125. package/dist/editor/domain-editors/use-implementation-files.js +1 -1
  126. package/dist/legacy/domain-cli/utils/cache.d.ts +1 -1
  127. package/dist/legacy/domain-cli/utils/cache.js +1 -1
  128. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/claude-md.d.ts +1 -1
  129. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/cursor-rules.d.ts +1 -1
  130. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.d.ts +1 -1
  131. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.js +11 -5
  132. package/dist/react-sdk/application-runtime/common-services/analytics/analytics-service.d.ts +1 -1
  133. package/dist/react-sdk/application-runtime/common-services/initialize.d.ts +2 -2
  134. package/dist/react-sdk/application-runtime/hooks/index.d.ts +1 -0
  135. package/dist/react-sdk/application-runtime/hooks/index.js +1 -1
  136. package/dist/react-sdk/application-runtime/hooks/loading/index.d.ts +5 -0
  137. package/dist/react-sdk/application-runtime/hooks/loading/index.js +1 -0
  138. package/dist/react-sdk/application-runtime/hooks/loading/loader-host-context.d.ts +11 -0
  139. package/dist/react-sdk/application-runtime/hooks/loading/loader-host-context.js +1 -0
  140. package/dist/react-sdk/application-runtime/hooks/loading/use-is-awaiting-loading-phase.d.ts +8 -0
  141. package/dist/react-sdk/application-runtime/hooks/loading/use-is-awaiting-loading-phase.js +1 -0
  142. package/dist/react-sdk/application-runtime/hooks/loading/use-is-loader-hosted.d.ts +7 -0
  143. package/dist/react-sdk/application-runtime/hooks/loading/use-is-loader-hosted.js +1 -0
  144. package/dist/react-sdk/application-runtime/hooks/loading/use-loading-actions.d.ts +9 -0
  145. package/dist/react-sdk/application-runtime/hooks/loading/use-loading-actions.js +1 -0
  146. package/dist/react-sdk/application-runtime/hooks/loading/use-loading-application.d.ts +24 -0
  147. package/dist/react-sdk/application-runtime/hooks/loading/use-loading-application.js +1 -0
  148. package/dist/react-sdk/application-runtime/hooks/use-access-service.js +1 -1
  149. package/dist/react-sdk/application-runtime/hooks/use-web-component-readonly-sync.d.ts +4 -11
  150. package/dist/react-sdk/application-runtime/hooks/use-web-component-readonly-sync.js +1 -1
  151. package/dist/react-sdk/application-runtime/hooks/use-web-component.d.ts +5 -0
  152. package/dist/react-sdk/application-runtime/hooks/use-web-component.js +1 -1
  153. package/dist/react-sdk/application-runtime/host-properties/actions.d.ts +15 -0
  154. package/dist/react-sdk/application-runtime/host-properties/actions.js +1 -0
  155. package/dist/react-sdk/application-runtime/host-properties/connect-host-properties.d.ts +30 -0
  156. package/dist/react-sdk/application-runtime/host-properties/connect-host-properties.js +1 -0
  157. package/dist/react-sdk/application-runtime/host-properties/domain-host-properties.d.ts +7 -0
  158. package/dist/react-sdk/application-runtime/host-properties/domain-host-properties.js +1 -0
  159. package/dist/react-sdk/application-runtime/host-properties/host-property-descriptors.d.ts +21 -0
  160. package/dist/react-sdk/application-runtime/host-properties/host-property-descriptors.js +1 -0
  161. package/dist/react-sdk/application-runtime/host-properties/host-property-scopes.d.ts +42 -0
  162. package/dist/react-sdk/application-runtime/host-properties/host-property-scopes.js +1 -0
  163. package/dist/react-sdk/application-runtime/host-properties/index.d.ts +8 -0
  164. package/dist/react-sdk/application-runtime/host-properties/index.js +1 -0
  165. package/dist/react-sdk/application-runtime/host-properties/initialize.d.ts +7 -0
  166. package/dist/react-sdk/application-runtime/host-properties/initialize.js +1 -0
  167. package/dist/react-sdk/application-runtime/host-properties/selectors.d.ts +54 -0
  168. package/dist/react-sdk/application-runtime/host-properties/selectors.js +1 -0
  169. package/dist/react-sdk/application-runtime/host-properties/types.d.ts +18 -0
  170. package/dist/react-sdk/application-runtime/index.d.ts +2 -0
  171. package/dist/react-sdk/application-runtime/loading/actions.d.ts +45 -0
  172. package/dist/react-sdk/application-runtime/loading/actions.js +1 -0
  173. package/dist/react-sdk/application-runtime/loading/index.d.ts +4 -0
  174. package/dist/react-sdk/application-runtime/loading/index.js +1 -0
  175. package/dist/react-sdk/application-runtime/loading/initialize.d.ts +3 -0
  176. package/dist/react-sdk/application-runtime/loading/initialize.js +1 -0
  177. package/dist/react-sdk/application-runtime/loading/selectors.d.ts +18 -0
  178. package/dist/react-sdk/application-runtime/loading/selectors.js +1 -0
  179. package/dist/react-sdk/application-runtime/loading/types.d.ts +59 -0
  180. package/dist/react-sdk/application-runtime/loading/types.js +1 -0
  181. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.js +1 -1
  182. package/dist/react-sdk/application-runtime/provider/ApplicationRuntime.d.ts +6 -0
  183. package/dist/react-sdk/application-runtime/provider/ApplicationRuntime.js +1 -1
  184. package/dist/react-sdk/application-runtime/provider/ApplicationType.d.ts +7 -0
  185. package/dist/react-sdk/application-runtime/provider/ApplicationType.js +1 -1
  186. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +218 -8
  187. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.js +1 -1
  188. package/dist/react-sdk/domain-application-context/BackendDataProvider.js +1 -1
  189. package/dist/react-sdk/domain-application-context/FrontendDataProvider.js +1 -1
  190. package/dist/react-sdk/domain-application-context/PublishedDataProvider.js +1 -1
  191. package/dist/react-sdk/elements/index.d.ts +0 -1
  192. package/dist/react-sdk/index.d.ts +1 -0
  193. package/dist/react-sdk/index.js +1 -1
  194. package/dist/react-sdk/loading-state/LoaderHost.d.ts +20 -0
  195. package/dist/react-sdk/loading-state/LoaderHost.js +1 -0
  196. package/dist/react-sdk/loading-state/built-in-loading-phase.d.ts +9 -0
  197. package/dist/react-sdk/loading-state/built-in-loading-phase.js +1 -0
  198. package/dist/react-sdk/loading-state/create-app-loader.d.ts +18 -0
  199. package/dist/react-sdk/loading-state/create-app-loader.js +1 -0
  200. package/dist/react-sdk/loading-state/index.d.ts +4 -2
  201. package/dist/react-sdk/loading-state/index.js +1 -1
  202. package/dist/react-sdk/loading-state/{LoadingStateProvider.d.ts → loading-state-hooks.d.ts} +3 -12
  203. package/dist/react-sdk/loading-state/loading-state-hooks.js +1 -0
  204. package/dist/react-sdk/page-elements/ConfigurationNotFoundPagePropsProvider.d.ts +17 -0
  205. package/dist/react-sdk/page-elements/ConfigurationNotFoundPagePropsProvider.js +1 -0
  206. package/dist/react-sdk/page-elements/ConfiguratorErrorPagePropsProvider.d.ts +17 -0
  207. package/dist/react-sdk/page-elements/ConfiguratorErrorPagePropsProvider.js +1 -0
  208. package/dist/react-sdk/page-elements/configurator-error-page-props.js +1 -0
  209. package/dist/{configurator/configuration-not-found-page → react-sdk/page-elements}/create-configuration-not-found-page.d.ts +7 -1
  210. package/dist/react-sdk/page-elements/create-configuration-not-found-page.js +1 -0
  211. package/dist/{configurator/configurator-error-page → react-sdk/page-elements}/create-configurator-error-page.d.ts +6 -1
  212. package/dist/react-sdk/page-elements/create-configurator-error-page.js +1 -0
  213. package/dist/react-sdk/page-elements/create-preset-ui.d.ts +9 -0
  214. package/dist/react-sdk/page-elements/create-preset-ui.js +1 -0
  215. package/dist/react-sdk/page-elements/index.d.ts +6 -0
  216. package/dist/react-sdk/page-elements/index.js +1 -0
  217. package/dist/react-sdk/session/SessionServiceProvider.js +1 -1
  218. package/dist/react-sdk/web-component/create-web-component.js +1 -1
  219. package/package.json +3 -3
  220. package/dist/configurator/app-loader-content/app-loader-content-name.d.ts +0 -5
  221. package/dist/configurator/app-loader-content/app-loader-content-name.js +0 -1
  222. package/dist/configurator/configuration-not-found-page/create-configuration-not-found-page.js +0 -1
  223. package/dist/configurator/configurator-error-page/create-configurator-error-page.js +0 -1
  224. package/dist/react-sdk/loading-state/LoadingStateProvider.js +0 -1
  225. package/dist/react-sdk/loading-state/loading-state-manager.d.ts +0 -37
  226. package/dist/react-sdk/loading-state/loading-state-manager.js +0 -1
  227. /package/dist/react-sdk/{elements/configurator-error-page-props.js → application-runtime/host-properties/types.js} +0 -0
  228. /package/dist/react-sdk/{elements → page-elements}/configurator-error-page-props.d.ts +0 -0
@@ -391,7 +391,7 @@ Use these factories to customize the preset-selection screen without changing ho
391
391
  - `createPresetPageAction` adds project-specific content below the default preset cards.
392
392
  - `createPresetDeviceNotSupported` adds project-specific overlay content above the default preset cards.
393
393
 
394
- Without `createPresetUi`, Phoenix renders its built-in preset screen, which is the default `PresetUi` registration in `defaultConfiguratorElements`. The action and the overlay are parts of that built-in screen and render nothing until the project registers them.
394
+ Without `createPresetUi`, Phoenix renders its built-in preset screen, which is the default `PresetUi` registration in `defaultConfiguratorElements`. The action and the overlay are parts of that built-in screen and render nothing until the project registers them. `createPresetUi` and the element's name, `PresetUiName`, are also exported from `@salsita-ai/sdk/react`.
395
395
 
396
396
  ```typescript
397
397
  const PresetScreen = phx.frontend.createPresetUi(CustomPresetScreen)
@@ -413,7 +413,7 @@ export default phx.frontend.createConfigurationNotFoundPage(({ onBack }) => (
413
413
  ))
414
414
  ```
415
415
 
416
- The helper types the page's props as `ConfigurationNotFoundPageProps` from `@salsita-ai/sdk/react`. A layout element registered under the name `ConfigurationNotFoundPage` with `createCustomPhoenixLayoutElement` replaces the page too, but its component is typed as taking only `children`.
416
+ The helper types the page's props as `ConfigurationNotFoundPageProps` from `@salsita-ai/sdk/react`, which also exports the helper and the element's name, `ConfigurationNotFoundPageName`. A layout element registered under the name `ConfigurationNotFoundPage` with `createCustomPhoenixLayoutElement` replaces the page too, but its component is typed as taking only `children`.
417
417
 
418
418
  - The page receives one optional prop, `onBack`, which returns to the start of the configurator. It is set when a configuration fails to load or is opened without a valid access key. It is not set on the start page itself, so a page that offers a way back shows it only when `onBack` is set.
419
419
  - The configurator renders the element in four cases: a configuration fails to load, for example because its ID does not exist or the server rejects its access key; a configuration is opened without an access key for it; a signed-in user whose role may not create configurations (`acl.canCreate`) opens the start page; the preset screen has no preset category to show, for example because the host's `presetTags` match no preset. The last case happens inside the built-in preset screen, so a project that replaces it with `createPresetUi` decides what to show itself.
@@ -434,7 +434,7 @@ export default phx.frontend.createConfiguratorErrorPage(({ reason, onRetry }) =>
434
434
  ))
435
435
  ```
436
436
 
437
- The helper types the page's props as `ConfiguratorErrorPageProps` from `@salsita-ai/sdk/react`. A layout element registered under the name `ConfiguratorErrorPage` with `createCustomPhoenixLayoutElement` replaces the page too, but its component is typed as taking only `children`.
437
+ The helper types the page's props as `ConfiguratorErrorPageProps` from `@salsita-ai/sdk/react`, which also exports the helper and the element's name, `ConfiguratorErrorPageName`. A layout element registered under the name `ConfiguratorErrorPage` with `createCustomPhoenixLayoutElement` replaces the page too, but its component is typed as taking only `children`.
438
438
 
439
439
  - The page receives two props. `reason` says what failed: `uncaughtError` when rendering the configurator failed with an error nothing else handled, `presetCreationFailed` when starting a configuration from the only preset failed. `onRetry` tries again: after `uncaughtError` it renders the configurator again, after `presetCreationFailed` it reloads the page. The error itself is not passed; it is logged to the console.
440
440
  - The configurator renders the element in two cases: an error reaches the configurator's error boundary, which wraps everything from the scene resources and the session down to the pages, including a failure while the application starts; and creating a configuration fails on a start screen with a single preset. The element is available in both, because the spec and its elements are part of the application before the configurator renders.
@@ -451,6 +451,7 @@ export default phx.frontend.createAppLoader(({ phases }) => <span>{phases[0]?.la
451
451
  ```
452
452
 
453
453
  - Phoenix keeps the overlay, its place over the safe area and its fade-in; the element is only what it shows.
454
+ - `createAppLoader`, the props type `AppLoaderContentProps` and the element's name, `AppLoaderContentName`, are also exported from `@salsita-ai/sdk/react`.
454
455
  - The overlay stays up while a loading phase runs: the session, the project's data, the configuration and the 3D scene. It waits for the scene only when the loaded configuration's layout mounts a canvas, as the built-in layouts and `LayoutSlots.SharedCanvas` do. A `ConfiguratorLayout` without a canvas is not held by the loader: the overlay leaves once the configuration is up.
455
456
  - The top-level `appLoader: legacy` key in the spec turns the overlay off.
456
457
  - The built-in content is the default `AppLoaderContent` registration in `defaultConfiguratorElements`, see below.
@@ -598,7 +599,7 @@ Texts from the spec, such as option titles and the `detail` fields, are `Localiz
598
599
 
599
600
  **Steps and tabs**
600
601
 
601
- A project layout builds its steps and tabs from the spec, so the structure stays in `navigationSteps`, `sidebarTabs` and `horizontalTabs`, where `$filter` switches it, and the layout decides how it looks. `phx.frontend.useStepNavigation()` gives a wizard its steps with a `status` each, and `next`, `previous` and `goTo`; `phx.frontend.useTabNavigation()` gives tabs with `isActive` each, and `select`. Both enter a navigation state, so controls, cameras and components filtered by `navigationStates` follow. Neither hides anything in read mode or blocks a step on violations: a layout that should not move on while the configuration is invalid combines `canGoNext` with `useStateValidity()`, and a stepper that offers only earlier steps enables the steps whose `status` is `'complete'`.
602
+ A project layout builds its steps and tabs from the spec, so the structure stays in `navigationSteps`, `sidebarTabs` and `horizontalTabs`, where `$filter` switches it, and the layout decides how it looks. `phx.frontend.useStepNavigation()` gives a wizard its steps with a `status` each, and `next`, `previous` and `goTo`; `phx.frontend.useTabNavigation()` gives tabs with `isActive` each, and `select`. Both enter a navigation state, so controls, cameras and components filtered by `navigationStates` follow. Neither hides anything in read mode or blocks a step on violations: a layout that should not move on while the configuration has a problem requires `phx.frontend.useStateValidity().severity !== 'warning'` besides `canGoNext`, because a change with a `fixable` or `fatal` violation is rejected and the committed configuration is never invalid, while a `warning` stays and blocks finalizing. A stepper that offers only earlier steps enables the steps whose `status` is `'complete'`.
602
603
 
603
604
  ```tsx
604
605
  export const Wizard = () => {
@@ -85,7 +85,9 @@ On the server, the install runs pnpm. It follows your `pnpm-lock.yaml` and `pnpm
85
85
 
86
86
  If the build fails, is cancelled or takes too long, `phoenix deploy` prints the end of the build log and exits with an error. `--no-wait` returns as soon as the build starts.
87
87
 
88
- Studio's **Builds & deployments** page lists your builds and shows which one your configurator serves. Each build shows its progress, its error and the full build log while it runs.
88
+ Studio's **Builds & deployments** page lists your builds, 20 to a page, and shows which one your configurator serves. Filter it to the live build or to the builds that failed. Each build shows its progress, its error and the full build log while it runs, and who deployed it with which CLI token.
89
+
90
+ **Rebuild** on a build's page builds the files uploaded with that build again, with your environment variables as they are now, without a new `phoenix deploy`. Use it after changing a variable, or when a build failed for a reason on our side. If the rebuild succeeds it goes live, so rebuilding an older build rolls production back to it.
89
91
 
90
92
  `phoenix deploy` refuses symlinks, hard-linked files and other special files among the project files, because builds only accept regular files. Packing uses the system `tar`, which macOS, Linux and Windows 10 or later all include. The build runner checks the uploaded archive again and keeps only project files, so a file outside the list above never reaches the build.
91
93
 
@@ -107,5 +109,5 @@ Coding agents working in your project use the same command, guided by the genera
107
109
  - `phoenix deploy` always deploys to the workspace's default project; it doesn't read `project` from the spec yet.
108
110
  - Only `phoenix dev` works from the sign-in. `phoenix deployment:prepare-dev` still needs the `.env` block of a Studio development environment.
109
111
  - Every deploy uploads the whole project; there are no incremental uploads.
110
- - Your own environment variables are set in Studio under Environment, by a super admin of the workspace, and apply from the next deploy. `phoenix dev` doesn't receive them: your development environment has its own variables. A build reads them from `process.env`; a webhook reads the ones the spec declares under `env.webhook`, through `phx.webhooksEnv` (see [Webhooks](?path=/docs/phoenix-webhooks--docs)). They can't use platform names such as `LAMBDA_FUNCTION_NAME`, the `AWS_` prefix, the identity provider settings such as `CLERK_API_KEY`, or names the CLI and the deploy tooling read themselves, such as `SERVER_URL` or `NODE_OPTIONS`; Studio refuses those names.
112
+ - Your own environment variables are set in Studio under Environment, by a super admin of the workspace, and apply from the next deploy. After a change, **Redeploy #N now** there rebuilds your live build with the new values, without a new `phoenix deploy`; it appears once your own build is live. `phoenix dev` doesn't receive them: your development environment has its own variables. A build reads them from `process.env`; a webhook reads the ones the spec declares under `env.webhook`, through `phx.webhooksEnv` (see [Webhooks](?path=/docs/phoenix-webhooks--docs)). They can't use platform names such as `LAMBDA_FUNCTION_NAME`, the `AWS_` prefix, the identity provider settings such as `CLERK_API_KEY`, or names the CLI and the deploy tooling read themselves, such as `SERVER_URL` or `NODE_OPTIONS`; Studio refuses those names.
111
113
  - Only super admins of a workspace can open its Studio. Admins and users see a page that says so.
@@ -3,7 +3,7 @@ import type { ThemeOptions } from '@mui/material';
3
3
  import type { z } from 'zod';
4
4
  import type { FinalizeTaskResource } from '@salsita-ai/contracts/webhook';
5
5
  import { type $DomainEntity, type DomainEntity, type DomainFactory, type EnumLike, type ProductPreset, type SchemaOfObject } from '../core/index.js';
6
- import { type ElementRegistration, type ProjectModule } from '../domain-runtime/index.js';
6
+ import { type ElementRegistration, type HandlerRegistration, type ProjectModule } from '../domain-runtime/index.js';
7
7
  import type { AclConfig, ApplicationConfig, DataSpec, DefaultEnvs, ResourcesConfig, SpecTransformer, TransformersConfig, UserInterfaceConfig } from './application-config.js';
8
8
  import { type AssistantResolvedManifest } from './assistant/index.js';
9
9
  interface ConfiguratorBuilderContext<ENTITIES extends DomainEntity<string> = never, ALLOWED_ROOT_ENTITIES extends ENTITIES = never, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>> = never, NAVIGATION_STATES extends string = never, VIEW_STATES extends string = never, TOOL_STATES extends string = never, EXPORT_STATES extends string = never, PUBLISHED_DATA extends Record<string, unknown> = never, SESSION_DATA extends Record<string, unknown> = never, FRONTEND_DATA extends Record<string, unknown> = never, ADMIN_ENTITIES extends DomainEntity<string> = never, ADMIN_ALLOWED_ROOT_ENTITIES extends ADMIN_ENTITIES = never, ADMIN_$MAP extends Record<ADMIN_ENTITIES['type'], $DomainEntity<ADMIN_ENTITIES>> = never, ADMIN_NAVIGATION_STATES extends string = never, ADMIN_VIEW_STATES extends string = never, FINALIZE_DATA extends Record<string, unknown> = never, PREFETCHED_FINALIZE_DATA extends Record<string, unknown> = never, FINALIZE_RESULT extends Record<string, unknown> = never, CALLBACK_DATA extends Record<string, unknown> = never, RESOURCE extends string = never> {
@@ -46,6 +46,12 @@ interface ConfiguratorBuilderContext<ENTITIES extends DomainEntity<string> = nev
46
46
  elements?: readonly ProjectModule[];
47
47
  defaultElements?: readonly ElementRegistration[];
48
48
  }
49
+ /**
50
+ * Rejects a second registration of a handler kind the application runs at most once: the assistant
51
+ * setup, the published-chunks filter, the data-row validator and the sheet validator. Both ways of
52
+ * building an application call it, `ConfiguratorBuilder.buildConfig` and `createApplication`.
53
+ */
54
+ export declare const checkSingleInstanceHandlers: (handlers: ReadonlyArray<HandlerRegistration<any, any>>) => void;
49
55
  export declare class ConfiguratorBuilder<ENTITIES extends DomainEntity<string> = never, ALLOWED_ROOT_ENTITIES extends ENTITIES = never, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>> = never, NAVIGATION_STATES extends string = never, VIEW_STATES extends string = never, TOOL_STATES extends string = never, EXPORT_STATES extends string = never, PUBLISHED_DATA extends Record<string, unknown> = never, SESSION_DATA extends Record<string, unknown> = never, FRONTEND_DATA extends Record<string, unknown> = never, ADMIN_ENTITIES extends DomainEntity<string> = never, ADMIN_ALLOWED_ROOT_ENTITIES extends ADMIN_ENTITIES = never, ADMIN_$MAP extends Record<ADMIN_ENTITIES['type'], $DomainEntity<ADMIN_ENTITIES>> = never, ADMIN_NAVIGATION_STATES extends string = never, ADMIN_VIEW_STATES extends string = never, FINALIZE_DATA extends Record<string, unknown> = never, PREFETCHED_FINALIZE_DATA extends Record<string, unknown> = never, FINALIZE_RESULT extends Record<string, unknown> = never, CALLBACK_DATA extends Record<string, unknown> = never, RESOURCE extends string = never> {
50
56
  private readonly _context;
51
57
  constructor(_context: ConfiguratorBuilderContext<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>);
@@ -1 +1 @@
1
- import{initConsoleLogger as t}from"@salsita-ai/common/utils";import{defaultI18n as e}from"#package/i18n";import{extendedSchemaValidator as i}from"../core/index.js";import{NoopAnalyticsSystem as r}from"../domain-context/index.js";import{createDomainRuntime as n}from"../domain-runtime/index.js";import{isGetApplicationWrapperHandler as o}from"./GetApplicationWrapperHandler.js";import{isGetWebComponentOptionsHandler as a}from"./GetWebComponentOptions.js";import{isAssistantSetupHandler as s}from"./assistant/index.js";import{createInitialPublishedData as l}from"./create-initial-published-data.js";import{isDataRowValidatorHandler as h}from"./published-data/DataRowValidatorHandler.js";import{isFilterPublishedChunksHandler as u}from"./published-data/FilterPublishedChunksHandler.js";import{isMapPublishedChunkedDataHandler as d}from"./published-data/MapPublishedChunkedDataHandler.js";import{isMapPublishedRevisionDataHandler as c}from"./published-data/MapPublishedRevisionDataHandler.js";import{isSheetValidatorHandler as f}from"./published-data/SheetValidatorHandler.js";export class ConfiguratorBuilder{_context;constructor(t){this._context=t}withDefaultEnvs(t){return new ConfiguratorBuilder({...this._context,defaultEnvs:t})}withVersion(t){return new ConfiguratorBuilder({...this._context,version:t})}withTextLanguages(t){return new ConfiguratorBuilder({...this._context,textLanguages:t})}withAcl(t){return new ConfiguratorBuilder({...this._context,acl:t})}withAdminRelease(t){return new ConfiguratorBuilder({...this._context,enableAdminRelease:t})}withUi(t){return new ConfiguratorBuilder({...this._context,ui:t})}withResourcesConfig(t){return new ConfiguratorBuilder({...this._context,resourcesConfig:t})}withChunks(t){return new ConfiguratorBuilder({...this._context,chunks:t})}withPublishedDataHash(t){return new ConfiguratorBuilder({...this._context,publishedDataHash:t})}withAssistant(t){return new ConfiguratorBuilder({...this._context,assistant:t})}withTheme(t){return new ConfiguratorBuilder({...this._context,theme:t})}withDomainFactory(t){return new ConfiguratorBuilder({...this._context,domainFactory:t})}withAdminDomainFactory(t){return new ConfiguratorBuilder({...this._context,adminDomainFactory:t})}withI18n=t=>new ConfiguratorBuilder({...this._context,i18n:t});withPrefetchedFinalizeData(t){return new ConfiguratorBuilder({...this._context,prefetchedFinalizeData:t})}withFinalizeData(t){return new ConfiguratorBuilder({...this._context,finalizeData:t})}withFinalizeResult(t){return new ConfiguratorBuilder({...this._context,finalizeResult:t})}withCallbackData(t){return new ConfiguratorBuilder({...this._context,callbackData:t})}withNavigationState(t){return new ConfiguratorBuilder({...this._context,navigationState:t})}withViewState(t){return new ConfiguratorBuilder({...this._context,viewState:t})}withToolState(t){return new ConfiguratorBuilder({...this._context,toolState:t})}withExportState(t){return new ConfiguratorBuilder({...this._context,exportState:t})}withAdminNavigationState(t){return new ConfiguratorBuilder({...this._context,adminNavigationState:t})}withAdminViewState(t){return new ConfiguratorBuilder({...this._context,adminViewState:t})}withPresets(t){return new ConfiguratorBuilder({...this._context,presets:t})}withAdminPresets(t){return new ConfiguratorBuilder({...this._context,adminPresets:t})}withComponentOptics(t){return new ConfiguratorBuilder({...this._context,componentOptics:[...this._context.componentOptics,...t]})}withAdminComponentOptics(t){return new ConfiguratorBuilder({...this._context,adminComponentOptics:[...this._context.adminComponentOptics??[],...t]})}withHandlers(t){return new ConfiguratorBuilder({...this._context,handlers:t})}withElements(t){return new ConfiguratorBuilder({...this._context,elements:t})}withDefaultElements(t){return new ConfiguratorBuilder({...this._context,defaultElements:t})}withResources(t){return new ConfiguratorBuilder({...this._context,resources:t})}withWebComponentTag(t){return new ConfiguratorBuilder({...this._context,tagName:t})}withTransformers(t,e){return new ConfiguratorBuilder({...this._context,transformers:{importedTransformers:t,specTransformers:e}})}withInterface(t){return this}withDataSpec=t=>new ConfiguratorBuilder({...this._context,dataSpec:t});_computeInitialPublishedData(t,e,i){if(!this._context.adminDomainFactory)throw Error("adminDomainFactory is required!");return l({adminDomainFactory:this._context.adminDomainFactory,domainRuntime:e,adminPresets:this._context.adminPresets??[],handlers:i,dataSpec:this._context.dataSpec,chunks:this._context.chunks,logger:t})}buildConfig(){return this._buildConfigWithHandlers().config}_buildConfigWithHandlers(){if(!this._context.domainFactory)throw Error("Can not create application config, domainFactory is required! Is it registered with the ConfiguratorBuilder?");if(!this._context.presets)throw Error("Can not create application config, presets are required! Is it registered with the ConfiguratorBuilder?");if(!this._context.adminDomainFactory)throw Error("Can not create application config, adminDomainFactory is required! Is it registered with the ConfiguratorBuilder?");if(!this._context.adminPresets)throw Error("Can not create application config, adminPresets are required! Is it registered with the ConfiguratorBuilder?");if(!this._context.version)throw Error("Can not create application config, version is required!");let i=this._context.tagName??"salsita-configurator",l={defaultEnvs:this._context.defaultEnvs,services:{i18n:this._context.i18n},version:this._context.version,initialPublishedData:{},domain:{textLanguages:this._context.textLanguages,componentOptics:this._context.componentOptics,presets:this._context.presets,domainFactory:this._context.domainFactory},navigation:{navigationStates:this._context.navigationState?.values(),viewStates:this._context.viewState?.values(),toolStates:this._context.toolState?.values(),exportStates:this._context.exportState?.values()},adminNavigation:{navigationStates:this._context.adminNavigationState?.values(),viewStates:this._context.adminViewState?.values()},adminDomain:{textLanguages:this._context.textLanguages,componentOptics:this._context.adminComponentOptics??[],presets:this._context.adminPresets,domainFactory:this._context.adminDomainFactory},mount:{tag:i,options:{}},handlers:this._context.handlers??[],elements:this._context.elements??[],defaultElements:this._context.defaultElements??[],transformers:this._context.transformers,features:{acl:this._context.acl,enableAdminRelease:this._context.enableAdminRelease},ui:{preview:this._context.ui?.preview,alwaysExpand:this._context.ui?.alwaysExpand,theme:this._context.theme},resources:this._context.resourcesConfig,chunks:this._context.chunks,publishedDataHash:this._context.publishedDataHash,assistant:this._context.assistant,dataSpec:this._context.dataSpec},d=t(),c=n({config:l,services:{analyticsService:new r,i18n:e,logger:d}}),m=c.getState().spec.configurator.handlers;if(m.filter(s).length>1)throw Error("Multiple createAssistantSetupHandler handlers found. Only one handler is allowed.");if(m.filter(t=>u(t)).length>1)throw Error("Multiple createFilterPublishedChunksHandler handlers found. Only one handler is allowed.");if(m.filter(t=>h(t)).length>1)throw Error("Multiple createDataRowValidatorHandler handlers found. Only one handler is allowed.");if(m.filter(t=>f(t)).length>1)throw Error("Multiple createSheetValidatorHandler handlers found. Only one handler is allowed.");let w=m.find(o)?.handler().handler,x=m.find(a)?.handler().handler(void 0),_=this._computeInitialPublishedData(d,c,m);return{config:{...l,mount:{tag:i,options:x??{},Application:w},initialPublishedData:_},handlers:m}}buildWebhookContext(){if(!this._context.domainFactory)throw Error("domainFactory is required!");if(!this._context.adminDomainFactory)throw Error("adminDomainFactory is required!");if(!this._context.adminPresets)throw Error("adminPresets are required!");let{config:t,handlers:e}=this._buildConfigWithHandlers(),r=t=>{if(null==this._context.finalizeData)return{};let e=i.compile(this._context.finalizeData);if(!e(t))throw console.error("Finalize data validation errors:",e.errors),Error("Invalid finalize data!");return t},n=t=>{if(null==this._context.finalizeResult)return{};let e=i.compile(this._context.finalizeResult);if(!e(t))throw console.error("Finalize result validation errors:",e.errors),Error("Invalid finalize result!");return t},o=t=>{if(null==this._context.callbackData)return{};let e=i.compile(this._context.callbackData);if(!e(t))throw console.error("Callback data validation errors:",e.errors),Error("Invalid callback data!");return t},a=e.find(c)?.handler().handler,s=e.find(d)?.handler().handler,l=e.find(h)?.handler().handler,u=e.find(f)?.handler().handler;return{config:t,parseFinalizeData:r,parseFinalizeResult:n,resources:this._context.resources??[],parseCallbackData:o,mapPublishedRevisionData:a,mapPublishedChunkedData:s,dataRowValidator:l,sheetValidator:u}}}
1
+ import{initConsoleLogger as t}from"@salsita-ai/common/utils";import{defaultI18n as e}from"#package/i18n";import{extendedSchemaValidator as i}from"../core/index.js";import{NoopAnalyticsSystem as r}from"../domain-context/index.js";import{createDomainRuntime as n}from"../domain-runtime/index.js";import{isGetApplicationWrapperHandler as o}from"./GetApplicationWrapperHandler.js";import{isGetWebComponentOptionsHandler as a}from"./GetWebComponentOptions.js";import{isAssistantSetupHandler as s}from"./assistant/index.js";import{createInitialPublishedData as u}from"./create-initial-published-data.js";import{isDataRowValidatorHandler as h}from"./published-data/DataRowValidatorHandler.js";import{isFilterPublishedChunksHandler as l}from"./published-data/FilterPublishedChunksHandler.js";import{isMapPublishedChunkedDataHandler as c}from"./published-data/MapPublishedChunkedDataHandler.js";import{isMapPublishedRevisionDataHandler as d}from"./published-data/MapPublishedRevisionDataHandler.js";import{isSheetValidatorHandler as m}from"./published-data/SheetValidatorHandler.js";let f=[[s,"createAssistantSetupHandler"],[l,"createFilterPublishedChunksHandler"],[h,"createDataRowValidatorHandler"],[m,"createSheetValidatorHandler"]];export const checkSingleInstanceHandlers=t=>{for(let[e,i]of f)if(t.filter(t=>e(t)).length>1)throw Error(`Multiple ${i} handlers found. Only one handler is allowed.`)};export class ConfiguratorBuilder{_context;constructor(t){this._context=t}withDefaultEnvs(t){return new ConfiguratorBuilder({...this._context,defaultEnvs:t})}withVersion(t){return new ConfiguratorBuilder({...this._context,version:t})}withTextLanguages(t){return new ConfiguratorBuilder({...this._context,textLanguages:t})}withAcl(t){return new ConfiguratorBuilder({...this._context,acl:t})}withAdminRelease(t){return new ConfiguratorBuilder({...this._context,enableAdminRelease:t})}withUi(t){return new ConfiguratorBuilder({...this._context,ui:t})}withResourcesConfig(t){return new ConfiguratorBuilder({...this._context,resourcesConfig:t})}withChunks(t){return new ConfiguratorBuilder({...this._context,chunks:t})}withPublishedDataHash(t){return new ConfiguratorBuilder({...this._context,publishedDataHash:t})}withAssistant(t){return new ConfiguratorBuilder({...this._context,assistant:t})}withTheme(t){return new ConfiguratorBuilder({...this._context,theme:t})}withDomainFactory(t){return new ConfiguratorBuilder({...this._context,domainFactory:t})}withAdminDomainFactory(t){return new ConfiguratorBuilder({...this._context,adminDomainFactory:t})}withI18n=t=>new ConfiguratorBuilder({...this._context,i18n:t});withPrefetchedFinalizeData(t){return new ConfiguratorBuilder({...this._context,prefetchedFinalizeData:t})}withFinalizeData(t){return new ConfiguratorBuilder({...this._context,finalizeData:t})}withFinalizeResult(t){return new ConfiguratorBuilder({...this._context,finalizeResult:t})}withCallbackData(t){return new ConfiguratorBuilder({...this._context,callbackData:t})}withNavigationState(t){return new ConfiguratorBuilder({...this._context,navigationState:t})}withViewState(t){return new ConfiguratorBuilder({...this._context,viewState:t})}withToolState(t){return new ConfiguratorBuilder({...this._context,toolState:t})}withExportState(t){return new ConfiguratorBuilder({...this._context,exportState:t})}withAdminNavigationState(t){return new ConfiguratorBuilder({...this._context,adminNavigationState:t})}withAdminViewState(t){return new ConfiguratorBuilder({...this._context,adminViewState:t})}withPresets(t){return new ConfiguratorBuilder({...this._context,presets:t})}withAdminPresets(t){return new ConfiguratorBuilder({...this._context,adminPresets:t})}withComponentOptics(t){return new ConfiguratorBuilder({...this._context,componentOptics:[...this._context.componentOptics,...t]})}withAdminComponentOptics(t){return new ConfiguratorBuilder({...this._context,adminComponentOptics:[...this._context.adminComponentOptics??[],...t]})}withHandlers(t){return new ConfiguratorBuilder({...this._context,handlers:t})}withElements(t){return new ConfiguratorBuilder({...this._context,elements:t})}withDefaultElements(t){return new ConfiguratorBuilder({...this._context,defaultElements:t})}withResources(t){return new ConfiguratorBuilder({...this._context,resources:t})}withWebComponentTag(t){return new ConfiguratorBuilder({...this._context,tagName:t})}withTransformers(t,e){return new ConfiguratorBuilder({...this._context,transformers:{importedTransformers:t,specTransformers:e}})}withInterface(t){return this}withDataSpec=t=>new ConfiguratorBuilder({...this._context,dataSpec:t});_computeInitialPublishedData(t,e,i){if(!this._context.adminDomainFactory)throw Error("adminDomainFactory is required!");return u({adminDomainFactory:this._context.adminDomainFactory,domainRuntime:e,adminPresets:this._context.adminPresets??[],handlers:i,dataSpec:this._context.dataSpec,chunks:this._context.chunks,logger:t})}buildConfig(){return this._buildConfigWithHandlers().config}_buildConfigWithHandlers(){if(!this._context.domainFactory)throw Error("Can not create application config, domainFactory is required! Is it registered with the ConfiguratorBuilder?");if(!this._context.presets)throw Error("Can not create application config, presets are required! Is it registered with the ConfiguratorBuilder?");if(!this._context.adminDomainFactory)throw Error("Can not create application config, adminDomainFactory is required! Is it registered with the ConfiguratorBuilder?");if(!this._context.adminPresets)throw Error("Can not create application config, adminPresets are required! Is it registered with the ConfiguratorBuilder?");if(!this._context.version)throw Error("Can not create application config, version is required!");let i=this._context.tagName??"salsita-configurator",s={defaultEnvs:this._context.defaultEnvs,services:{i18n:this._context.i18n},version:this._context.version,initialPublishedData:{},domain:{textLanguages:this._context.textLanguages,componentOptics:this._context.componentOptics,presets:this._context.presets,domainFactory:this._context.domainFactory},navigation:{navigationStates:this._context.navigationState?.values(),viewStates:this._context.viewState?.values(),toolStates:this._context.toolState?.values(),exportStates:this._context.exportState?.values()},adminNavigation:{navigationStates:this._context.adminNavigationState?.values(),viewStates:this._context.adminViewState?.values()},adminDomain:{textLanguages:this._context.textLanguages,componentOptics:this._context.adminComponentOptics??[],presets:this._context.adminPresets,domainFactory:this._context.adminDomainFactory},mount:{tag:i,options:{}},handlers:this._context.handlers??[],elements:this._context.elements??[],defaultElements:this._context.defaultElements??[],transformers:this._context.transformers,features:{acl:this._context.acl,enableAdminRelease:this._context.enableAdminRelease},ui:{preview:this._context.ui?.preview,alwaysExpand:this._context.ui?.alwaysExpand,theme:this._context.theme},resources:this._context.resourcesConfig,chunks:this._context.chunks,publishedDataHash:this._context.publishedDataHash,assistant:this._context.assistant,dataSpec:this._context.dataSpec},u=t(),h=n({config:s,services:{analyticsService:new r,i18n:e,logger:u}}),l=h.getState().spec.configurator.handlers;checkSingleInstanceHandlers(l);let c=l.find(o)?.handler().handler,d=l.find(a)?.handler().handler(void 0),m=this._computeInitialPublishedData(u,h,l);return{config:{...s,mount:{tag:i,options:d??{},Application:c},initialPublishedData:m},handlers:l}}buildWebhookContext(){if(!this._context.domainFactory)throw Error("domainFactory is required!");if(!this._context.adminDomainFactory)throw Error("adminDomainFactory is required!");if(!this._context.adminPresets)throw Error("adminPresets are required!");let{config:t,handlers:e}=this._buildConfigWithHandlers(),r=t=>{if(null==this._context.finalizeData)return{};let e=i.compile(this._context.finalizeData);if(!e(t))throw console.error("Finalize data validation errors:",e.errors),Error("Invalid finalize data!");return t},n=t=>{if(null==this._context.finalizeResult)return{};let e=i.compile(this._context.finalizeResult);if(!e(t))throw console.error("Finalize result validation errors:",e.errors),Error("Invalid finalize result!");return t},o=t=>{if(null==this._context.callbackData)return{};let e=i.compile(this._context.callbackData);if(!e(t))throw console.error("Callback data validation errors:",e.errors),Error("Invalid callback data!");return t},a=e.find(d)?.handler().handler,s=e.find(c)?.handler().handler,u=e.find(h)?.handler().handler,l=e.find(m)?.handler().handler;return{config:t,parseFinalizeData:r,parseFinalizeResult:n,resources:this._context.resources??[],parseCallbackData:o,mapPublishedRevisionData:a,mapPublishedChunkedData:s,dataRowValidator:u,sheetValidator:l}}}
@@ -2,7 +2,7 @@ export { type DomainConfig, type NavigationConfig, type ISessionService, type Se
2
2
  export { type AssistantFieldOption, findAssistantFieldOptions, readAssistantFieldOptions, } from './assistant-field-options.js';
3
3
  export { deleteEntityUpdateTag, findAssistantMutation, modifyEntityUpdateTag } from './assistant-mutations.js';
4
4
  export { type AssistantRecipe, type AssistantRecipeContext, type AssistantRecipeGroupSnapshot, type AssistantRecipeKind, findAssistantRecipeGroups, prepareAssistantRecipeUpdates, readAssistantRecipeGroup, } from './assistant-recipe-groups.js';
5
- export { ConfiguratorBuilder } from './configurator-builder.js';
5
+ export { ConfiguratorBuilder, checkSingleInstanceHandlers } from './configurator-builder.js';
6
6
  export * from './admin-page-factories.js';
7
7
  export { createInitialPublishedData, type CreateInitialPublishedDataProps } from './create-initial-published-data.js';
8
8
  export { webComponentAttributeParsers, createWebComponentPropertyDescriptor, type AttributeParser, type WebComponentPropertyDescriptor, } from './web-component-property.js';
@@ -1 +1 @@
1
- export{findAssistantFieldOptions,readAssistantFieldOptions}from"./assistant-field-options.js";export{deleteEntityUpdateTag,findAssistantMutation,modifyEntityUpdateTag}from"./assistant-mutations.js";export{findAssistantRecipeGroups,prepareAssistantRecipeUpdates,readAssistantRecipeGroup}from"./assistant-recipe-groups.js";export{ConfiguratorBuilder}from"./configurator-builder.js";export*from"./admin-page-factories.js";export{createInitialPublishedData}from"./create-initial-published-data.js";export{webComponentAttributeParsers,createWebComponentPropertyDescriptor}from"./web-component-property.js";export{createWebComponentEventDescriptor}from"./web-component-event.js";export{standardWebComponentProperties}from"./standard-properties.js";export{standardWebComponentEvents}from"./standard-events.js";export{createGetApplicationWrapperHandler,isGetApplicationWrapperHandler}from"./GetApplicationWrapperHandler.js";export{createGetThemeHandler,GetThemeHandlerName,isGetThemeHandler}from"./GetThemeHandler.js";export{createGetWebComponentOptionsHandler,isGetWebComponentOptionsHandler}from"./GetWebComponentOptions.js";export{createFinalizeAdminDomain}from"./published-data/create-finalize-admin-domain.js";export{FilterPublishedChunksHandlerName,isFilterPublishedChunksHandler}from"./published-data/FilterPublishedChunksHandler.js";export{mapPublishedData}from"./published-data/map-published-data.js";export{flattenTabData,mapDefaultValuesToRecords,mapPublishedChunkedData,SYSTEM_CHUNK_KEY,SYSTEM_CHUNK_SCOPE,SWATCH_DEFINITION}from"./published-data/map-published-chunked-data.js";export{buildLegendRows}from"./published-data/build-legend-data.js";export{formatFieldType,getFieldDescription}from"./published-data/format-field-type.js";export{mapDataToSheet}from"./published-data/map-data-to-sheet.js";export{validateRows}from"./published-data/validate-sheet-data.js";export{createDataRowValidatorHandler,DataRowValidatorHandlerName,isDataRowValidatorHandler}from"./published-data/DataRowValidatorHandler.js";export{createSheetValidatorHandler,SheetValidatorHandlerName,isSheetValidatorHandler}from"./published-data/SheetValidatorHandler.js";export{createMapPublishedRevisionDataHandler,createMapPublishedRevisionDataHandlerFactory,isMapPublishedRevisionDataHandler}from"./published-data/MapPublishedRevisionDataHandler.js";export{createMapPublishedChunkedDataHandler,createMapPublishedChunkedDataHandlerFactory,isMapPublishedChunkedDataHandler}from"./published-data/MapPublishedChunkedDataHandler.js";export*from"./assistant/index.js";
1
+ export{findAssistantFieldOptions,readAssistantFieldOptions}from"./assistant-field-options.js";export{deleteEntityUpdateTag,findAssistantMutation,modifyEntityUpdateTag}from"./assistant-mutations.js";export{findAssistantRecipeGroups,prepareAssistantRecipeUpdates,readAssistantRecipeGroup}from"./assistant-recipe-groups.js";export{ConfiguratorBuilder,checkSingleInstanceHandlers}from"./configurator-builder.js";export*from"./admin-page-factories.js";export{createInitialPublishedData}from"./create-initial-published-data.js";export{webComponentAttributeParsers,createWebComponentPropertyDescriptor}from"./web-component-property.js";export{createWebComponentEventDescriptor}from"./web-component-event.js";export{standardWebComponentProperties}from"./standard-properties.js";export{standardWebComponentEvents}from"./standard-events.js";export{createGetApplicationWrapperHandler,isGetApplicationWrapperHandler}from"./GetApplicationWrapperHandler.js";export{createGetThemeHandler,GetThemeHandlerName,isGetThemeHandler}from"./GetThemeHandler.js";export{createGetWebComponentOptionsHandler,isGetWebComponentOptionsHandler}from"./GetWebComponentOptions.js";export{createFinalizeAdminDomain}from"./published-data/create-finalize-admin-domain.js";export{FilterPublishedChunksHandlerName,isFilterPublishedChunksHandler}from"./published-data/FilterPublishedChunksHandler.js";export{mapPublishedData}from"./published-data/map-published-data.js";export{flattenTabData,mapDefaultValuesToRecords,mapPublishedChunkedData,SYSTEM_CHUNK_KEY,SYSTEM_CHUNK_SCOPE,SWATCH_DEFINITION}from"./published-data/map-published-chunked-data.js";export{buildLegendRows}from"./published-data/build-legend-data.js";export{formatFieldType,getFieldDescription}from"./published-data/format-field-type.js";export{mapDataToSheet}from"./published-data/map-data-to-sheet.js";export{validateRows}from"./published-data/validate-sheet-data.js";export{createDataRowValidatorHandler,DataRowValidatorHandlerName,isDataRowValidatorHandler}from"./published-data/DataRowValidatorHandler.js";export{createSheetValidatorHandler,SheetValidatorHandlerName,isSheetValidatorHandler}from"./published-data/SheetValidatorHandler.js";export{createMapPublishedRevisionDataHandler,createMapPublishedRevisionDataHandlerFactory,isMapPublishedRevisionDataHandler}from"./published-data/MapPublishedRevisionDataHandler.js";export{createMapPublishedChunkedDataHandler,createMapPublishedChunkedDataHandlerFactory,isMapPublishedChunkedDataHandler}from"./published-data/MapPublishedChunkedDataHandler.js";export*from"./assistant/index.js";
@@ -1 +1 @@
1
- import{z as e}from"zod";import{RoutingStateSchema as t,parseRouteAttribute as a}from"./route-property.js";import{createWebComponentPropertyDescriptor as r,webComponentAttributeParsers as n}from"./web-component-property.js";export const standardWebComponentProperties={onEvent:r({schema:e.function().args(e.object({type:e.string(),payload:e.unknown()})).returns(e.unknown()),defaultValue:void 0,attributeParser:n.globalVariable,attributeNames:["on-event","onevent"]}),onAttached:r({schema:e.function().args(e.unknown().describe("The web component instance")).returns(e.unknown().describe("Nothing should be returned, but validation will not fail if something is (important for async handlers)")),defaultValue:void 0,attributeParser:n.globalVariable,attributeNames:["on-attached","onattached"]}),locale:r({schema:e.string(),defaultValue:"en",attributeParser:n.string,attributeNames:["locale"]}),nonce:r({schema:e.string(),defaultValue:void 0,attributeParser:n.string,attributeNames:["nonce"]}),modalZIndex:r({schema:e.number().int(),defaultValue:9910,attributeParser:n.number,attributeNames:["modal-zindex","modalzindex","modal-z-index"]}),expanded:r({schema:e.boolean(),defaultValue:!1,attributeParser:n.boolean,attributeNames:["expanded"]}),mode:r({schema:e.enum(["configurator","admin","standalone-admin"]),defaultValue:"configurator",attributeParser:n.string,attributeNames:["mode"]}),presetTags:r({schema:e.array(e.string()).nullable(),defaultValue:null,attributeParser:n.commaSeparatedStrings,attributeNames:["preset-tags"]}),route:r({schema:t,defaultValue:{route:"Index"},attributeParser:a,attributeNames:["route"]}),sessionToken:r({schema:e.string(),defaultValue:void 0,attributeParser:n.string,attributeNames:["session-token","sessiontoken"]}),adminSessionToken:r({schema:e.string(),defaultValue:void 0,attributeParser:n.string,attributeNames:["admin-session-token","adminsessiontoken"]}),refreshToken:r({schema:e.string(),defaultValue:void 0,attributeParser:n.string,attributeNames:["refresh-token","refreshtoken"]}),authorizationCode:r({schema:e.string(),defaultValue:void 0,attributeParser:n.string,attributeNames:["authorization-code","authorizationcode"]}),containerZIndex:r({schema:e.number().int(),defaultValue:9900,attributeParser:n.number,attributeNames:["container-zindex","containerzindex","container-z-index"]}),htmlFontSize:r({schema:e.number().int(),defaultValue:16,attributeParser:n.number,attributeNames:["html-font-size","htmlfontsize"]}),integrationMode:r({schema:e.enum(["page","handoff","widget","headless"]),defaultValue:"page",attributeParser:n.string,attributeNames:["integration-mode","integrationmode"]}),power:r({schema:e.enum(["on","standby","off"]),defaultValue:"on",attributeParser:n.string,attributeNames:["power"]}),readonly:r({schema:e.boolean(),defaultValue:!1,attributeParser:n.boolean,attributeNames:["readonly"]})};
1
+ import{z as e}from"zod";import{DEFAULT_FALLBACK_LOCALE as t}from"#package/i18n";import{RoutingStateSchema as a,parseRouteAttribute as r}from"./route-property.js";import{createWebComponentPropertyDescriptor as n,webComponentAttributeParsers as i}from"./web-component-property.js";export const standardWebComponentProperties={onEvent:n({schema:e.function().args(e.object({type:e.string(),payload:e.unknown()})).returns(e.unknown()),defaultValue:void 0,attributeParser:i.globalVariable,attributeNames:["on-event","onevent"]}),onAttached:n({schema:e.function().args(e.unknown().describe("The web component instance")).returns(e.unknown().describe("Nothing should be returned, but validation will not fail if something is (important for async handlers)")),defaultValue:void 0,attributeParser:i.globalVariable,attributeNames:["on-attached","onattached"]}),locale:n({schema:e.string(),defaultValue:t,attributeParser:i.string,attributeNames:["locale"]}),nonce:n({schema:e.string(),defaultValue:void 0,attributeParser:i.string,attributeNames:["nonce"]}),modalZIndex:n({schema:e.number().int(),defaultValue:9910,attributeParser:i.number,attributeNames:["modal-zindex","modalzindex","modal-z-index"]}),expanded:n({schema:e.boolean(),defaultValue:!1,attributeParser:i.boolean,attributeNames:["expanded"]}),mode:n({schema:e.enum(["configurator","admin","standalone-admin"]),defaultValue:"configurator",attributeParser:i.string,attributeNames:["mode"]}),presetTags:n({schema:e.array(e.string()).nullable(),defaultValue:null,attributeParser:i.commaSeparatedStrings,attributeNames:["preset-tags"]}),route:n({schema:a,defaultValue:{route:"Index"},attributeParser:r,attributeNames:["route"]}),sessionToken:n({schema:e.string(),defaultValue:void 0,attributeParser:i.string,attributeNames:["session-token","sessiontoken"]}),adminSessionToken:n({schema:e.string(),defaultValue:void 0,attributeParser:i.string,attributeNames:["admin-session-token","adminsessiontoken"]}),refreshToken:n({schema:e.string(),defaultValue:void 0,attributeParser:i.string,attributeNames:["refresh-token","refreshtoken"]}),authorizationCode:n({schema:e.string(),defaultValue:void 0,attributeParser:i.string,attributeNames:["authorization-code","authorizationcode"]}),containerZIndex:n({schema:e.number().int(),defaultValue:9900,attributeParser:i.number,attributeNames:["container-zindex","containerzindex","container-z-index"]}),htmlFontSize:n({schema:e.number().int(),defaultValue:16,attributeParser:i.number,attributeNames:["html-font-size","htmlfontsize"]}),integrationMode:n({schema:e.enum(["page","handoff","widget","headless"]),defaultValue:"page",attributeParser:i.string,attributeNames:["integration-mode","integrationmode"]}),power:n({schema:e.enum(["on","standby","off"]),defaultValue:"on",attributeParser:i.string,attributeNames:["power"]}),readonly:n({schema:e.boolean(),defaultValue:!1,attributeParser:i.boolean,attributeNames:["readonly"]})};
@@ -23,10 +23,12 @@ export declare const webComponentAttributeParsers: {
23
23
  readonly commaSeparatedStrings: (value: string) => string[];
24
24
  /**
25
25
  * Parses a string into a boolean.
26
+ * - `""`, a bare attribute such as `<salsita-configurator readonly>` -> `true`
26
27
  * - `"true"` -> `true`
27
28
  * - `"false"` -> `false`
28
29
  *
29
- * All other values are considered invalid.
30
+ * The web component also reads the attribute's own name as its value (`readonly="readonly"`) as `true`,
31
+ * as HTML does for boolean attributes. All other values are considered invalid.
30
32
  */
31
33
  readonly boolean: (value: string) => boolean;
32
34
  /**
@@ -1,2 +1,2 @@
1
- import{match as r}from"ts-pattern";export const EmptyProperty=Symbol("emptyProperty");export const webComponentAttributeParsers={globalVariable:r=>{if(!Object.hasOwn(window,r))throw Error(`Global variable ${r} not found`);return window[r]},string:String,number:r=>{let t=Number(r);if(isNaN(t))throw Error(`Invalid number: ${r}`);return t},commaSeparatedStrings:r=>r.split(",").map(r=>r.trim()).filter(r=>""!==r),boolean:t=>r(t).with("true",()=>!0).with("false",()=>!1).otherwise(()=>{throw Error(`Invalid boolean: ${t}`)}),json:r=>{try{return JSON.parse(r)}catch(t){throw Error(`Invalid JSON: ${r}`)}},shareUrl:r=>{let t=new URL(r);return{ca:t.searchParams.get("ca"),cid:t.searchParams.get("cid")}}};export function createWebComponentPropertyDescriptor(r){if(void 0!==r.attributeParser&&void 0!==r.attributeNames&&(void 0===r.attributeParser||void 0===r.attributeNames))throw Error(`When exposing WebComponent properties as attributes, both 'attributeParser' and 'attributeNames' must be specified.
1
+ import{match as r}from"ts-pattern";export const EmptyProperty=Symbol("emptyProperty");export const webComponentAttributeParsers={globalVariable:r=>{if(!Object.hasOwn(window,r))throw Error(`Global variable ${r} not found`);return window[r]},string:String,number:r=>{let t=Number(r);if(isNaN(t))throw Error(`Invalid number: ${r}`);return t},commaSeparatedStrings:r=>r.split(",").map(r=>r.trim()).filter(r=>""!==r),boolean:t=>r(t).with("","true",()=>!0).with("false",()=>!1).otherwise(()=>{throw Error(`Invalid boolean: ${t}`)}),json:r=>{try{return JSON.parse(r)}catch(t){throw Error(`Invalid JSON: ${r}`)}},shareUrl:r=>{let t=new URL(r);return{ca:t.searchParams.get("ca"),cid:t.searchParams.get("cid")}}};export function createWebComponentPropertyDescriptor(r){if(void 0!==r.attributeParser&&void 0!==r.attributeNames&&(void 0===r.attributeParser||void 0===r.attributeNames))throw Error(`When exposing WebComponent properties as attributes, both 'attributeParser' and 'attributeNames' must be specified.
2
2
  To migrate from previous versions of the SDK, add 'attributeNames: [<property-name-in-lowercase>]'.`);return"required"in r?{attributeParser:void 0,attributeNames:void 0,defaultValue:r.mockValue,...r}:{attributeNames:void 0,attributeParser:void 0,required:!1,...r}}
@@ -24,11 +24,17 @@ export declare class DomainBuilder<ENTITIES extends DomainEntity<string>, ALLOWE
24
24
  withMigrate(migration: MigrateFunction<ENTITIES>): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
25
25
  withExpressions(implementation: AliasedExpressions<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES>): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
26
26
  /**
27
- * Adds the expressions of the `src/expressions/` files, as the generated barrel lists them. Each file
28
- * is checked against the folder's contract and added on its own, so an expression defined twice is
29
- * reported with both files instead of being overwritten by file order.
27
+ * Adds the expressions of the `src/expressions/` files, as the generated barrel lists them. The
28
+ * files are merged by `mergeExpressionModules`, which checks each one and throws every wrong file,
29
+ * every expression defined twice and every expression the domain already has, such as a generated
30
+ * one, together as one `ImplementationErrors` of `DUPLICATE_DEFINITION`s.
30
31
  */
31
32
  withExpressionModules(modules: readonly ProjectModule[]): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
33
+ /**
34
+ * Adds expressions already expanded to entity types, each with its origin. An expression that the
35
+ * domain, or an earlier one of the list, defines for the same entity type is an error.
36
+ */
37
+ private withEntityExpressions;
32
38
  /** Declares the actions of the domain, as the generated `domain-spec.ts` reads them from the spec's `actions` section. */
33
39
  withActions(actions: readonly ActionDefinition[]): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
34
40
  /** Adds the action implementations of the `src/actions/` files, as the generated barrel lists them, after checking each file against the folder's contract. */
@@ -1 +1 @@
1
- import{DomainFactory as t,createMigrateFunction as i,expandAlias as e}from"./core/index.js";import{resolveActionModules as s,resolveExpressionModules as n}from"./domain-runtime/index.js";import{withProfilerLabel as a}from"./utils/profiler-label.js";export class DomainBuilder{entities;aliasMap;$entityReflections;allowedRootEntityTypes;implemented;modelVersion;publishedData;sessionData;frontendData;backendData;migrate;isAdminDomain;actions;actionImplementations;constructor(t,i,e,s,n,a,o,h,l,m,r,d,p,c){this.entities=t,this.aliasMap=i,this.$entityReflections=e,this.allowedRootEntityTypes=s,this.implemented=n,this.modelVersion=a,this.publishedData=o,this.sessionData=h,this.frontendData=l,this.backendData=m,this.migrate=r,this.isAdminDomain=d,this.actions=p,this.actionImplementations=c}static from(t,e,s,n,a,o,h,l,m,r){let d=i({1:t},1,{});return new DomainBuilder(t,e,s,n,{},a,o,h,l,m,d,r,{},{})}withMigrate(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,t,this.isAdminDomain,this.actions,this.actionImplementations)}withExpressions(t){let i={...this.implemented};return Object.entries(t).forEach(([t,s])=>{e(this.aliasMap,t).forEach(e=>{let n={...i[e]};i[e]=n,Object.entries(s).forEach(([i,s])=>{let o=n[i];if(o)throw Error(`Duplicate expression ${e}.${i}: The expression is defined on both ${t} and ${o.origin.typeOrAlias}, which would lead to ambiguous usage. Please ensure that expressions are only defined once.`);n[i]={...s,evaluate:a(`${e}_${i}`,s.evaluate),origin:{name:i,typeOrAlias:t}}})})}),new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,i,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,this.actions,this.actionImplementations)}withExpressionModules(t){return n(t,this.aliasMap).reduce((t,i)=>t.withExpressions(i.expressions),this)}withActions(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,Object.fromEntries(t.map(t=>[t.name,t])),this.actionImplementations)}withActionModules(t){return this.withActionImplementations(s(t))}withActionImplementations(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,this.actions,{...this.actionImplementations,...t})}build=()=>{let e=this.implemented,s=this.migrate??i({1:this.entities},1,{});return new t({aliasMap:this.aliasMap,entityReflections:this.entities,$entityReflections:this.$entityReflections,expressions:e,allowedRootEntityTypes:this.allowedRootEntityTypes,modelVersion:this.modelVersion,migrate:s,publishedData:this.publishedData,sessionData:this.sessionData,frontendData:this.frontendData,backendData:this.backendData,isAdminDomain:this.isAdminDomain,actions:this.actions,actionImplementations:this.actionImplementations})}}
1
+ import{DomainFactory as t,createMigrateFunction as i,expandAlias as e}from"./core/index.js";import{mergeExpressionModules as s,resolveActionModules as n}from"./domain-runtime/index.js";import{withProfilerLabel as a}from"./utils/profiler-label.js";export class DomainBuilder{entities;aliasMap;$entityReflections;allowedRootEntityTypes;implemented;modelVersion;publishedData;sessionData;frontendData;backendData;migrate;isAdminDomain;actions;actionImplementations;constructor(t,i,e,s,n,a,o,h,l,m,r,d,p,c){this.entities=t,this.aliasMap=i,this.$entityReflections=e,this.allowedRootEntityTypes=s,this.implemented=n,this.modelVersion=a,this.publishedData=o,this.sessionData=h,this.frontendData=l,this.backendData=m,this.migrate=r,this.isAdminDomain=d,this.actions=p,this.actionImplementations=c}static from(t,e,s,n,a,o,h,l,m,r){let d=i({1:t},1,{});return new DomainBuilder(t,e,s,n,{},a,o,h,l,m,d,r,{},{})}withMigrate(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,t,this.isAdminDomain,this.actions,this.actionImplementations)}withExpressions(t){let i=Object.entries(t);return this.withEntityExpressions(i.flatMap(([t,i])=>e(this.aliasMap,t).flatMap(e=>Object.entries(i).map(([i,s])=>({type:e,expression:{...s,origin:{name:i,typeOrAlias:t}}})))))}withExpressionModules(t){let i=new Map(Object.entries(this.implemented).map(([t,i])=>[t,new Set(Object.keys(i))]));return this.withEntityExpressions(Object.entries(s(t,this.aliasMap,void 0,i)).flatMap(([t,i])=>Object.values(i).map(i=>({type:t,expression:i}))))}withEntityExpressions(t){let i={...this.implemented};return t.forEach(({type:t,expression:e})=>{let{name:s,typeOrAlias:n}=e.origin,o={...i[t]},h=o[s];if(h)throw Error(`Duplicate expression ${t}.${s}: The expression is defined on both ${n} and ${h.origin.typeOrAlias}, which would lead to ambiguous usage. Please ensure that expressions are only defined once.`);o[s]={...e,evaluate:a(`${t}_${s}`,e.evaluate)},i[t]=o}),new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,i,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,this.actions,this.actionImplementations)}withActions(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,Object.fromEntries(t.map(t=>[t.name,t])),this.actionImplementations)}withActionModules(t){return this.withActionImplementations(n(t))}withActionImplementations(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,this.actions,{...this.actionImplementations,...t})}build=()=>{let e=this.implemented,s=this.migrate??i({1:this.entities},1,{});return new t({aliasMap:this.aliasMap,entityReflections:this.entities,$entityReflections:this.$entityReflections,expressions:e,allowedRootEntityTypes:this.allowedRootEntityTypes,modelVersion:this.modelVersion,migrate:s,publishedData:this.publishedData,sessionData:this.sessionData,frontendData:this.frontendData,backendData:this.backendData,isAdminDomain:this.isAdminDomain,actions:this.actions,actionImplementations:this.actionImplementations})}}
@@ -0,0 +1,39 @@
1
+ import type { AnyApplicationConfig, DefaultEnvs } from '../application/index.js';
2
+ import type { PersistenceConfig } from './environment/index.js';
3
+ import { type ApplicationSpec } from './spec/index.js';
4
+ /**
5
+ * The environment an application runs in, before the runtime resolves it: the values of the
6
+ * phoenix runtime config (`defaultEnvs`), and the deployment id, the development flag and the
7
+ * persistence when the host sets them explicitly.
8
+ */
9
+ interface ApplicationEnvironmentInput {
10
+ readonly defaultEnvs?: DefaultEnvs | undefined;
11
+ readonly deploymentId?: string | undefined;
12
+ readonly isDev?: boolean | undefined;
13
+ readonly persistence?: PersistenceConfig | undefined;
14
+ }
15
+ /**
16
+ * An application ready to run: the spec slice of the domain runtime, the environment it runs in,
17
+ * the services it uses (i18n, and a logger, analytics or admin integration a host provides) and the
18
+ * tag of the web component it mounts as.
19
+ *
20
+ * `createApplication` of `@salsita-ai/sdk/application-spec` builds one from an
21
+ * application's runtime spec and its project modules, without a builder or an `ApplicationConfig`.
22
+ * `TYPES` is the project's types; no value carries it at run time.
23
+ */
24
+ export interface Application<TYPES = unknown> {
25
+ readonly spec: ApplicationSpec;
26
+ readonly environment: ApplicationEnvironmentInput;
27
+ readonly services: NonNullable<AnyApplicationConfig['services']>;
28
+ readonly tag: string;
29
+ /** Never set: it carries `TYPES` to the functions that take the application. */
30
+ readonly '~types'?: TYPES;
31
+ }
32
+ /**
33
+ * Converts the config of a project built with `ConfiguratorBuilder` to the application a runtime
34
+ * starts from. It checks the project's files (`initializeSpec`) and throws every mistake together,
35
+ * so a host converts it where it shows a failed start: a mount when an element starts, the domain
36
+ * runtime when it initializes.
37
+ */
38
+ export declare const applicationFromConfig: (config: AnyApplicationConfig) => Application;
39
+ export {};
@@ -0,0 +1 @@
1
+ import{initializeSpec as e}from"./spec/index.js";export const applicationFromConfig=s=>({spec:e(s),environment:{defaultEnvs:s.defaultEnvs,deploymentId:s.deploymentId,isDev:s.isDev,persistence:s.persistence},services:s.services??{},tag:s.mount.tag});
@@ -1,6 +1,7 @@
1
1
  import { BehaviorSubject } from 'rxjs';
2
2
  import type { AnyApplicationConfig } from '../application/index.js';
3
3
  import { type ApplicationAccessInfo } from './access/index.js';
4
+ import { type Application } from './application.js';
4
5
  import { type ApplicationDomainContextState, type DomainApplicationType, type InitializableSystem } from './domain-context/index.js';
5
6
  import { type ApplicationDomainData } from './domain-data/index.js';
6
7
  import { type DomainRuntimeServices } from './domain-services/index.js';
@@ -21,17 +22,30 @@ export interface DomainRuntimeState {
21
22
  readonly webComponent: ApplicationWebComponentState;
22
23
  readonly domainContext: ApplicationDomainContextState;
23
24
  }
24
- interface Props<State extends DomainRuntimeState> {
25
+ /**
26
+ * What a domain runtime starts from: the spec slice and the environment of an application, or the
27
+ * config of a project built with `ConfiguratorBuilder`, which is converted to them when the runtime
28
+ * initializes.
29
+ */
30
+ type DomainRuntimeSource = {
31
+ readonly application: Pick<Application, 'spec' | 'environment'>;
32
+ readonly config?: undefined;
33
+ } | {
25
34
  readonly config: AnyApplicationConfig;
35
+ readonly application?: undefined;
36
+ };
37
+ type DomainRuntimeProps = DomainRuntimeSource & {
26
38
  readonly services: DomainRuntimeServices;
27
- readonly getSubject: () => BehaviorSubject<State>;
28
39
  /**
29
40
  * Systems a host layers onto a slot's domain initialization. Webhook and finalize hosts run the
30
41
  * domain alone and pass nothing; the application runtime contributes its domain-application
31
42
  * systems here.
32
43
  */
33
44
  readonly getExtensionSystems?: (applicationType: DomainApplicationType) => readonly InitializableSystem[];
34
- }
45
+ };
46
+ type Props<State extends DomainRuntimeState> = DomainRuntimeProps & {
47
+ readonly getSubject: () => BehaviorSubject<State>;
48
+ };
35
49
  export declare function createDomainRuntimeSlices<State extends DomainRuntimeState>(props: Props<State>): {
36
50
  initialize: () => {
37
51
  spec: ApplicationSpec;
@@ -344,6 +358,8 @@ export declare function createDomainRuntimeSlices<State extends DomainRuntimeSta
344
358
  webComponent: {
345
359
  selectReadonly: import("@salsita-ai/common/utils").Selector<import("./index.js").WebComponentSelectorState, boolean>;
346
360
  getReadonly: () => boolean;
361
+ selectLocale: import("@salsita-ai/common/utils").Selector<import("./index.js").WebComponentSelectorState, string>;
362
+ getLocale: () => string;
347
363
  getWebcomponentGeneration: () => number;
348
364
  };
349
365
  domainContext: {
@@ -632,9 +648,16 @@ export declare function createDomainRuntimeSlices<State extends DomainRuntimeSta
632
648
  };
633
649
  };
634
650
  };
651
+ /**
652
+ * Writers only the runtime that owns the host-property mirror may call, kept off the public
653
+ * `actions`: the host sets `locale` on the element, and the mirror copies it here.
654
+ */
655
+ hostMirrorActions: {
656
+ setLocale: (locale: string) => void;
657
+ };
635
658
  };
636
659
  export type DomainRuntimeSlices = ReturnType<typeof createDomainRuntimeSlices>;
637
- export declare const createDomainRuntime: (props: Omit<Props<DomainRuntimeState>, 'getSubject'>) => {
660
+ export declare const createDomainRuntime: (props: DomainRuntimeProps) => {
638
661
  initialize: () => {
639
662
  spec: ApplicationSpec;
640
663
  overrides: ApplicationOverrides;
@@ -946,6 +969,8 @@ export declare const createDomainRuntime: (props: Omit<Props<DomainRuntimeState>
946
969
  webComponent: {
947
970
  selectReadonly: import("@salsita-ai/common/utils").Selector<import("./index.js").WebComponentSelectorState, boolean>;
948
971
  getReadonly: () => boolean;
972
+ selectLocale: import("@salsita-ai/common/utils").Selector<import("./index.js").WebComponentSelectorState, string>;
973
+ getLocale: () => string;
949
974
  getWebcomponentGeneration: () => number;
950
975
  };
951
976
  domainContext: {
@@ -1234,6 +1259,13 @@ export declare const createDomainRuntime: (props: Omit<Props<DomainRuntimeState>
1234
1259
  };
1235
1260
  };
1236
1261
  };
1262
+ /**
1263
+ * Writers only the runtime that owns the host-property mirror may call, kept off the public
1264
+ * `actions`: the host sets `locale` on the element, and the mirror copies it here.
1265
+ */
1266
+ hostMirrorActions: {
1267
+ setLocale: (locale: string) => void;
1268
+ };
1237
1269
  getState: () => DomainRuntimeState;
1238
1270
  subscribe: (callback: () => void) => () => void;
1239
1271
  };
@@ -1 +1 @@
1
- import{BehaviorSubject as e}from"rxjs";import{createAccessInfoActions as t,createAccessInfoSelectors as n,initializeAccessInfo as a}from"./access/index.js";import{createDomainContextActions as o,createDomainContextSelectors as i,initializeDomainContext as s}from"./domain-context/index.js";import{createDomainDataActions as r,createDomainDataSelectors as m,initializeDomainData as l}from"./domain-data/index.js";import{createDomainServicesSelectors as d}from"./domain-services/index.js";import{createEnvironmentActions as c,createEnvironmentSelectors as u,initializeEnvironment as v}from"./environment/index.js";import{createLoadedDataActions as x,createLoadedDataSelectors as p,initializeLoadedData as S}from"./loaded-data/index.js";import{createOverridesActions as f,createOverridesSelectors as g,initializeOverrides as C}from"./overrides/index.js";import{createSessionContextActions as D,createSessionContextSelectors as b,initializeSessionContext as j}from"./session-context/index.js";import{createSpecActions as w,createSpecSelectors as y,initializeSpec as E}from"./spec/index.js";import{createWebComponentActions as z,createWebComponentSelectors as R,initializeWebComponent as T}from"./web-component/index.js";export function createDomainRuntimeSlices(e){let{config:h,getSubject:A,services:I,getExtensionSystems:L}=e,O=w({setSpec:e=>{let t=A(),n=e(t.value.spec);t.next({...t.value,spec:n})}}),W=y({getState:()=>A().value}),k=d({services:I,specSelectors:W}),q=f({setOverrides:e=>{let t=A(),n=e(t.value.overrides);t.next({...t.value,overrides:n})}}),B=g({getState:()=>A().value}),F=u({getState:()=>A().value,overridesSelectors:B}),G=c({setEnvironment:e=>{let t=A(),n=e(t.value.environment);t.next({...t.value,environment:n})}}),H=x({setLoadedData:e=>{let t=A(),n=e(t.value.loadedData);t.next({...t.value,loadedData:n})}}),J=p({getState:()=>A().value}),K=r({setDomainDataState:e=>{let t=A(),n=e(t.value.domainData);t.next({...t.value,domainData:n})}}),M=m({getState:()=>A().value,overridesSelectors:B}),N=D({setSessionContextState:e=>{let t=A(),n=e(t.value.sessionContext);t.next({...t.value,sessionContext:n})}}),P=b({getState:()=>A().value,overridesSelectors:B}),Q=t({setAccessInfoState:e=>{let t=A(),n=e(t.value.access);t.next({...t.value,access:n})}}),U=n({getState:()=>A().value,overridesSelectors:B}),V=z({setWebComponentState:e=>{let t=A(),n=e(t.value.webComponent);t.next({...t.value,webComponent:n})}}),X=R({getState:()=>A().value}),Y=o({setDomainContextState:e=>{let t=A(),n=e(t.value.domainContext);t.next({...t.value,domainContext:n})}}),Z={configurator:i({applicationType:"configurator",getState:()=>A().value,actions:Y.configurator,getExtensionSystems:()=>L?.("configurator")??[],specSelectors:W,accessSelectors:U,webComponentSelectors:X,domainDataSelectors:M,sessionContextSelectors:P,domainServicesSelectors:k,environmentSelectors:F}),admin:i({applicationType:"admin",getState:()=>A().value,actions:Y.admin,getExtensionSystems:()=>L?.("admin")??[],specSelectors:W,accessSelectors:U,webComponentSelectors:X,domainDataSelectors:M,sessionContextSelectors:P,domainServicesSelectors:k,environmentSelectors:F})};return{initialize:()=>({spec:E(h),overrides:C(),environment:v(h),loadedData:S(),domainData:l(),sessionContext:j(),access:a(),webComponent:T(),domainContext:s()}),selectors:{domainServices:k,spec:W,overrides:B,environment:F,loadedData:J,domainData:M,sessionContext:P,access:U,webComponent:X,domainContext:Z},actions:{spec:O,overrides:q,environment:G,loadedData:H,domainData:K,sessionContext:N,access:Q,webComponent:V,domainContext:Y}}}export const createDomainRuntime=t=>{let{config:n,services:a,getExtensionSystems:o}=t,i=null,s=createDomainRuntimeSlices({config:n,getSubject:()=>{if(!i)throw Error("Subject not yet initialized!");return i},services:a,getExtensionSystems:o});return i=new e(s.initialize()),{...s,getState:()=>i.value,subscribe:e=>{let t=i.subscribe(()=>e());return()=>t.unsubscribe()}}};
1
+ import{BehaviorSubject as e}from"rxjs";import{createAccessInfoActions as t,createAccessInfoSelectors as n,initializeAccessInfo as a}from"./access/index.js";import{applicationFromConfig as o}from"./application.js";import{createDomainContextActions as i,createDomainContextSelectors as s,initializeDomainContext as r}from"./domain-context/index.js";import{createDomainDataActions as m,createDomainDataSelectors as l,initializeDomainData as c}from"./domain-data/index.js";import{createDomainServicesSelectors as d}from"./domain-services/index.js";import{createEnvironmentActions as u,createEnvironmentSelectors as v,initializeEnvironment as p}from"./environment/index.js";import{createLoadedDataActions as x,createLoadedDataSelectors as S,initializeLoadedData as f}from"./loaded-data/index.js";import{createOverridesActions as g,createOverridesSelectors as C,initializeOverrides as D}from"./overrides/index.js";import{createSessionContextActions as b,createSessionContextSelectors as j,initializeSessionContext as w}from"./session-context/index.js";import{createSpecActions as y,createSpecSelectors as E}from"./spec/index.js";import{createWebComponentActions as z,createWebComponentSelectors as R,initializeWebComponent as h}from"./web-component/index.js";export function createDomainRuntimeSlices(e){let{getSubject:A,services:T,getExtensionSystems:I}=e,L=y({setSpec:e=>{let t=A(),n=e(t.value.spec);t.next({...t.value,spec:n})}}),M=E({getState:()=>A().value}),O=d({services:T,specSelectors:M}),W=g({setOverrides:e=>{let t=A(),n=e(t.value.overrides);t.next({...t.value,overrides:n})}}),k=C({getState:()=>A().value}),q=v({getState:()=>A().value,overridesSelectors:k}),B=u({setEnvironment:e=>{let t=A(),n=e(t.value.environment);t.next({...t.value,environment:n})}}),F=x({setLoadedData:e=>{let t=A(),n=e(t.value.loadedData);t.next({...t.value,loadedData:n})}}),G=S({getState:()=>A().value}),H=m({setDomainDataState:e=>{let t=A(),n=e(t.value.domainData);t.next({...t.value,domainData:n})}}),J=l({getState:()=>A().value,overridesSelectors:k}),K=b({setSessionContextState:e=>{let t=A(),n=e(t.value.sessionContext);t.next({...t.value,sessionContext:n})}}),N=j({getState:()=>A().value,overridesSelectors:k}),P=t({setAccessInfoState:e=>{let t=A(),n=e(t.value.access);t.next({...t.value,access:n})}}),Q=n({getState:()=>A().value,overridesSelectors:k}),{setLocale:U,...V}=z({setWebComponentState:e=>{let t=A(),n=e(t.value.webComponent);t.next({...t.value,webComponent:n})}}),X=R({getState:()=>A().value}),Y=i({setDomainContextState:e=>{let t=A(),n=e(t.value.domainContext);t.next({...t.value,domainContext:n})}}),Z={configurator:s({applicationType:"configurator",getState:()=>A().value,actions:Y.configurator,getExtensionSystems:()=>I?.("configurator")??[],specSelectors:M,accessSelectors:Q,webComponentSelectors:X,domainDataSelectors:J,sessionContextSelectors:N,domainServicesSelectors:O,environmentSelectors:q}),admin:s({applicationType:"admin",getState:()=>A().value,actions:Y.admin,getExtensionSystems:()=>I?.("admin")??[],specSelectors:M,accessSelectors:Q,webComponentSelectors:X,domainDataSelectors:J,sessionContextSelectors:N,domainServicesSelectors:O,environmentSelectors:q})};return{initialize:()=>{let t=e.application??o(e.config);return{spec:t.spec,overrides:D(),environment:p(t.environment),loadedData:f(),domainData:c(),sessionContext:w(),access:a(),webComponent:h(),domainContext:r()}},selectors:{domainServices:O,spec:M,overrides:k,environment:q,loadedData:G,domainData:J,sessionContext:N,access:Q,webComponent:X,domainContext:Z},actions:{spec:L,overrides:W,environment:B,loadedData:F,domainData:H,sessionContext:K,access:P,webComponent:V,domainContext:Y},hostMirrorActions:{setLocale:U}}}export const createDomainRuntime=t=>{let n=null,a=createDomainRuntimeSlices({...t,getSubject:()=>{if(!n)throw Error("Subject not yet initialized!");return n}});return n=new e(a.initialize()),{...a,getState:()=>n.value,subscribe:e=>{let t=n.subscribe(()=>e());return()=>t.unsubscribe()}}};
@@ -2,4 +2,4 @@ import type { AnyApplicationConfig } from '../../application/index.js';
2
2
  import type { ApplicationEnvironmentConfig } from './types.js';
3
3
  export declare const GOD_MODE_SESSION_STORAGE_KEY = "salsita-god-mode";
4
4
  export declare const isNotRegisteredDeploymentId: (deploymentId: string) => boolean;
5
- export declare const initializeEnvironment: (config: AnyApplicationConfig) => ApplicationEnvironmentConfig;
5
+ export declare const initializeEnvironment: (config: Pick<AnyApplicationConfig, 'defaultEnvs' | 'deploymentId' | 'isDev' | 'persistence'>) => ApplicationEnvironmentConfig;
@@ -10,6 +10,8 @@ export interface ImplementationErrorCollector {
10
10
  */
11
11
  readonly attempt: <T>(check: () => T, fallback: T) => T;
12
12
  readonly add: (error: ImplementationError) => void;
13
+ /** The errors recorded so far, in the order they were recorded. A host that reports them itself, such as the editor, reads them here instead of throwing them. */
14
+ readonly recorded: () => readonly ImplementationError[];
13
15
  /**
14
16
  * Throws the recorded errors as one {@link ImplementationErrors}, in the order they were
15
17
  * recorded. Does nothing when there are none.
@@ -1 +1 @@
1
- import{isImplementationError as r}from"./implementation-error.js";import{ImplementationErrors as t,isImplementationErrors as e}from"./implementation-errors.js";export const createImplementationErrorCollector=()=>{let o=[],n=r=>{o.push(r)};return{add:n,attempt:(t,o)=>{try{return t()}catch(t){if(e(t))return t.errors.forEach(n),o;if(r(t))return n(t),o;throw t}},throwIfAny:()=>{if(o.length>0)throw new t(o)}}};
1
+ import{isImplementationError as r}from"./implementation-error.js";import{ImplementationErrors as t,isImplementationErrors as e}from"./implementation-errors.js";export const createImplementationErrorCollector=()=>{let o=[],n=r=>{o.push(r)};return{add:n,attempt:(t,o)=>{try{return t()}catch(t){if(e(t))return t.errors.forEach(n),o;if(r(t))return n(t),o;throw t}},recorded:()=>[...o],throwIfAny:()=>{if(o.length>0)throw new t(o)}}};
@@ -1,7 +1,8 @@
1
1
  export * from './domain-runtime.js';
2
+ export { type Application, applicationFromConfig } from './application.js';
2
3
  export * from './domain-context/index.js';
3
4
  export * from './domain-services/index.js';
4
- export { type ImplementationErrorCode, type ImplementationErrorProps, type StartupStage, ImplementationError, ImplementationErrors, isImplementationError, isImplementationErrors, toImplementationErrors, } from './errors/index.js';
5
+ export { type ImplementationErrorCode, type ImplementationErrorCollector, type ImplementationErrorProps, type StartupStage, ImplementationError, ImplementationErrors, createImplementationErrorCollector, isImplementationError, isImplementationErrors, toImplementationErrors, } from './errors/index.js';
5
6
  export * from './spec/index.js';
6
7
  export * from './environment/index.js';
7
8
  export * from './access/index.js';
@@ -1 +1 @@
1
- export*from"./domain-runtime.js";export*from"./domain-context/index.js";export*from"./domain-services/index.js";export{ImplementationError,ImplementationErrors,isImplementationError,isImplementationErrors,toImplementationErrors}from"./errors/index.js";export*from"./spec/index.js";export*from"./environment/index.js";export*from"./access/index.js";export*from"./overrides/index.js";export*from"./loaded-data/index.js";export*from"./domain-data/index.js";export*from"./session-context/index.js";export*from"./web-component/index.js";
1
+ export*from"./domain-runtime.js";export{applicationFromConfig}from"./application.js";export*from"./domain-context/index.js";export*from"./domain-services/index.js";export{ImplementationError,ImplementationErrors,createImplementationErrorCollector,isImplementationError,isImplementationErrors,toImplementationErrors}from"./errors/index.js";export*from"./spec/index.js";export*from"./environment/index.js";export*from"./access/index.js";export*from"./overrides/index.js";export*from"./loaded-data/index.js";export*from"./domain-data/index.js";export*from"./session-context/index.js";export*from"./web-component/index.js";
@@ -4,6 +4,6 @@ export * from './actions.js';
4
4
  export * from './create-violation-expressions.js';
5
5
  export * from './initialize.js';
6
6
  export * from './memoize-expression.js';
7
- export { type PhoenixEntityElementProps, type PhoenixEntityElementRegistration, type PhoenixLayoutElementRegistration, type PhoenixIconRegistration, type AssistantFormElementRegistration, type ElementRegistration, type CustomPhoenixEntityElementProps, type PhoenixLayoutElementDefinition, type PhoenixEntityElementDefinition, type CreateCustomPhoenixLayoutElement, type CreateCustomPhoenixEntityElement, createPhoenixLayoutElement, createPhoenixEntityElement, createCustomPhoenixLayoutElement, createCustomPhoenixEntityElement, createAssistantFormElement, findAssistantFormElementErrors, resolveElementModule, resolveElementModules, type PhoenixHandlerDefinition, type SystemPhoenixHandlerDefinition, type PhoenixHandlerRegistration, type SystemPhoenixHandlerRegistration, type SystemPhoenixAsyncHandlerDefinition, type SystemPhoenixAsyncHandlerRegistration, type HandlerRegistration, type CreatePhoenixHandler, createPhoenixHandler, createSystemPhoenixHandler, createSystemPhoenixAsyncHandler, resolveHandlerModule, resolveHandlerModules, type ProjectModule, resolveActionModules, resolveComponentOpticModules, type ExpressionModule, resolveExpressionModules, resolveImportedTransformers, resolveTransformerModule, resolveTransformerModules, resolveInvariantModules, } from './module-checks/index.js';
7
+ export { type PhoenixEntityElementProps, type PhoenixEntityElementRegistration, type PhoenixLayoutElementRegistration, type PhoenixIconRegistration, type AssistantFormElementRegistration, type ElementRegistration, type CustomPhoenixEntityElementProps, type PhoenixLayoutElementDefinition, type PhoenixEntityElementDefinition, type CreateCustomPhoenixLayoutElement, type CreateCustomPhoenixEntityElement, createPhoenixLayoutElement, createPhoenixEntityElement, createCustomPhoenixLayoutElement, createCustomPhoenixEntityElement, createAssistantFormElement, findAssistantFormElementErrors, resolveElementModule, resolveElementModules, type PhoenixHandlerDefinition, type SystemPhoenixHandlerDefinition, type PhoenixHandlerRegistration, type SystemPhoenixHandlerRegistration, type SystemPhoenixAsyncHandlerDefinition, type SystemPhoenixAsyncHandlerRegistration, type HandlerRegistration, type CreatePhoenixHandler, createPhoenixHandler, createSystemPhoenixHandler, createSystemPhoenixAsyncHandler, resolveHandlerModule, resolveHandlerModules, type ProjectModule, resolveActionModules, resolveComponentOpticModules, type ExpressionModule, resolveExpressionModules, type ValuedExpressions, mergeExpressionModules, resolveImportedTransformers, resolveTransformerModule, resolveTransformerModules, resolveInvariantModules, } from './module-checks/index.js';
8
8
  export * from './prepare-action-implementations.js';
9
9
  export * from './prepare-domain-expressions.js';
@@ -1 +1 @@
1
- export*from"./selectors.js";export*from"./actions.js";export*from"./create-violation-expressions.js";export*from"./initialize.js";export*from"./memoize-expression.js";export{createPhoenixLayoutElement,createPhoenixEntityElement,createCustomPhoenixLayoutElement,createCustomPhoenixEntityElement,createAssistantFormElement,findAssistantFormElementErrors,resolveElementModule,resolveElementModules,createPhoenixHandler,createSystemPhoenixHandler,createSystemPhoenixAsyncHandler,resolveHandlerModule,resolveHandlerModules,resolveActionModules,resolveComponentOpticModules,resolveExpressionModules,resolveImportedTransformers,resolveTransformerModule,resolveTransformerModules,resolveInvariantModules}from"./module-checks/index.js";export*from"./prepare-action-implementations.js";export*from"./prepare-domain-expressions.js";
1
+ export*from"./selectors.js";export*from"./actions.js";export*from"./create-violation-expressions.js";export*from"./initialize.js";export*from"./memoize-expression.js";export{createPhoenixLayoutElement,createPhoenixEntityElement,createCustomPhoenixLayoutElement,createCustomPhoenixEntityElement,createAssistantFormElement,findAssistantFormElementErrors,resolveElementModule,resolveElementModules,createPhoenixHandler,createSystemPhoenixHandler,createSystemPhoenixAsyncHandler,resolveHandlerModule,resolveHandlerModules,resolveActionModules,resolveComponentOpticModules,resolveExpressionModules,mergeExpressionModules,resolveImportedTransformers,resolveTransformerModule,resolveTransformerModules,resolveInvariantModules}from"./module-checks/index.js";export*from"./prepare-action-implementations.js";export*from"./prepare-domain-expressions.js";
@@ -4,6 +4,7 @@ export { findAssistantFormElementErrors } from './find-assistant-form-element-er
4
4
  export { type ProjectModule } from './project-modules.js';
5
5
  export { resolveActionModules } from './resolve-action-modules.js';
6
6
  export { resolveComponentOpticModules } from './resolve-component-optic-modules.js';
7
+ export { type ValuedExpressions, mergeExpressionModules } from './merge-expression-modules.js';
7
8
  export { type ExpressionModule, resolveExpressionModules } from './resolve-expression-modules.js';
8
9
  export { resolveImportedTransformers, resolveTransformerModule, resolveTransformerModules, } from './resolve-imported-transformers.js';
9
10
  export { type AnyInvariant, resolveInvariantModules } from './resolve-invariant-modules.js';
@@ -1 +1 @@
1
- export{createPhoenixLayoutElement,createPhoenixEntityElement,createCustomPhoenixLayoutElement,createCustomPhoenixEntityElement,createAssistantFormElement,resolveElementModule,resolveElementModules}from"./element-registration.js";export{createPhoenixHandler,createSystemPhoenixHandler,createSystemPhoenixAsyncHandler,resolveHandlerModule,resolveHandlerModules}from"./handler-registration.js";export{findAssistantFormElementErrors}from"./find-assistant-form-element-errors.js";export{resolveActionModules}from"./resolve-action-modules.js";export{resolveComponentOpticModules}from"./resolve-component-optic-modules.js";export{resolveExpressionModules}from"./resolve-expression-modules.js";export{resolveImportedTransformers,resolveTransformerModule,resolveTransformerModules}from"./resolve-imported-transformers.js";export{resolveInvariantModules}from"./resolve-invariant-modules.js";
1
+ export{createPhoenixLayoutElement,createPhoenixEntityElement,createCustomPhoenixLayoutElement,createCustomPhoenixEntityElement,createAssistantFormElement,resolveElementModule,resolveElementModules}from"./element-registration.js";export{createPhoenixHandler,createSystemPhoenixHandler,createSystemPhoenixAsyncHandler,resolveHandlerModule,resolveHandlerModules}from"./handler-registration.js";export{findAssistantFormElementErrors}from"./find-assistant-form-element-errors.js";export{resolveActionModules}from"./resolve-action-modules.js";export{resolveComponentOpticModules}from"./resolve-component-optic-modules.js";export{mergeExpressionModules}from"./merge-expression-modules.js";export{resolveExpressionModules}from"./resolve-expression-modules.js";export{resolveImportedTransformers,resolveTransformerModule,resolveTransformerModules}from"./resolve-imported-transformers.js";export{resolveInvariantModules}from"./resolve-invariant-modules.js";
@@ -0,0 +1,23 @@
1
+ import type { AnonymousExpression, AnyExpressions } from '../../../core/index.js';
2
+ import { type ImplementationErrorCollector } from '../../errors/index.js';
3
+ import { type ProjectModule } from './project-modules.js';
4
+ type AnyAnonymousExpression = AnonymousExpression<any, any, any, any, any, any, unknown>;
5
+ type AliasMap = Readonly<Record<string, readonly string[]>>;
6
+ /** The expression names that already have a value, by entity type, so no project file may define them. */
7
+ export type ValuedExpressions = ReadonlyMap<string, ReadonlySet<string>>;
8
+ /** Whether a file's default export has the shape of the expressions folder contract. */
9
+ export declare const isExpressionExport: (value: unknown) => value is Record<string, Record<string, AnyAnonymousExpression>>;
10
+ /**
11
+ * Merges the `src/expressions/` files (or `src/admin/expressions/`) into the expressions of each
12
+ * entity type. It checks each file against the folder contract, rejects an expression that two
13
+ * files, or two keys of one file, define for one entity type after the aliases of `aliasMap` are
14
+ * expanded, and rejects an expression listed in `valued`, which the application gives a value
15
+ * already. Each accepted expression gets its `origin`: its name and the entity type or alias the
16
+ * file keys it by.
17
+ *
18
+ * Each file is checked on its own: a wrong file is recorded in `errors` with all its conflicts and
19
+ * left out, and the files after it still merge. Without `errors`, everything recorded is thrown at
20
+ * the end as one `ImplementationErrors`.
21
+ */
22
+ export declare const mergeExpressionModules: (modules: readonly ProjectModule[], aliasMap: AliasMap, errors?: ImplementationErrorCollector, valued?: ValuedExpressions) => AnyExpressions;
23
+ export {};
@@ -0,0 +1 @@
1
+ import{ImplementationError as e,ImplementationErrors as o,createImplementationErrorCollector as t}from"../../errors/index.js";import{SHARED_FOLDER_HINT as i,createContractError as n,isRecord as r}from"./project-modules.js";let s={expected:"an object of expressions keyed by entity type or alias, then by expression name",fix:`Create it with phx.domain.implementCustomExpressions({ ... }) (phx.domain.admin.implementCustomExpressions({ ... }) under src/admin/), ${i}.`},a=e=>r(e)&&"function"==typeof e.evaluate,p=e=>r(e)&&Object.values(e).every(a);export const isExpressionExport=e=>r(e)&&Object.values(e).every(p);let l=(o,t,i)=>new e({code:"DUPLICATE_DEFINITION",origin:o,problem:`Duplicate expression ${t}`,fix:i}),d=(e,t,i,r)=>{if(!isExpressionExport(e.exports))throw n(e,s,e.exports);let a=[],p=new Map,d=[];for(let[o,n]of Object.entries(e.exports))for(let s of t[o]??[o])for(let[t,f]of Object.entries(n)){let n=`${s}.${t}`,h=p.get(n),m=i.get(n);r.get(s)?.has(t)?d.push(l(e.origin,n,"The application already gives it a value (an $eval, $msg or read in the spec, a relation, the $violations of its invariants, or a built-in expression of the SDK), so this implementation would be ignored. Remove it from the file, or declare the expression in the spec with a type and no value.")):void 0!==h?d.push(l(e.origin,n,`The file defines it on both ${h} and ${o}, so its value would depend on the order the definitions are merged in. Define it once, on the alias or on the entity type.`)):void 0!==m&&d.push(l(e.origin,n,`It is also defined in ${m}, so its value would depend on file order. Keep one definition and remove the other.`)),p.set(n,o),a.push({key:n,entityType:s,typeOrAlias:o,name:t,expression:f})}if(d.length>0)throw new o(d);return a};export const mergeExpressionModules=(e,o,i,n=new Map)=>{let r=i??t(),s=new Map,a={};for(let t of e)for(let{key:e,entityType:i,typeOrAlias:p,name:l,expression:f}of r.attempt(()=>d(t,o,s,n),[]))s.set(e,t.origin),a[i]={...a[i],[l]:{...f,origin:{name:l,typeOrAlias:p}}};return void 0===i&&r.throwIfAny(),a};
@@ -1,5 +1,5 @@
1
1
  import type { AnonymousExpression } from '../../../core/index.js';
2
- import { type ProjectModule } from './project-modules.js';
2
+ import type { ProjectModule } from './project-modules.js';
3
3
  /** The expressions of one validated expression file, keyed by entity type or alias, then by expression name. */
4
4
  export interface ExpressionModule {
5
5
  readonly origin: string;
@@ -7,9 +7,8 @@ export interface ExpressionModule {
7
7
  }
8
8
  type AnyAnonymousExpression = AnonymousExpression<any, any, any, any, any, any, unknown>;
9
9
  /**
10
- * Validates the `src/expressions/` files and rejects an expression that two files define for the
11
- * same entity type. Merging stays with the caller, because the domain builder and the editor expand
12
- * aliases at different points; within one file the builder's own duplicate check applies.
10
+ * Validates the `src/expressions/` files with the checks of {@link mergeExpressionModules}, throws
11
+ * everything they find as one `ImplementationErrors`, and returns each file on its own, unmerged.
13
12
  */
14
13
  export declare const resolveExpressionModules: (modules: readonly ProjectModule[], aliasMap: Readonly<Record<string, readonly string[]>>) => readonly ExpressionModule[];
15
14
  export {};
@@ -1 +1 @@
1
- import{SHARED_FOLDER_HINT as e,createContractError as o,isRecord as t}from"./project-modules.js";let i={expected:"an object of expressions keyed by entity type or alias, then by expression name",fix:`Create it with phx.domain.implementCustomExpressions({ ... }) (phx.domain.admin.implementCustomExpressions({ ... }) under src/admin/), ${e}.`},r=e=>t(e)&&"function"==typeof e.evaluate,n=e=>t(e)&&Object.values(e).every(r);export const resolveExpressionModules=(e,r)=>{let s=new Map;return e.map(e=>{let p;if(!(t(p=e.exports)&&Object.values(p).every(n)))throw o(e,i,e.exports);for(let[o,t]of Object.entries(e.exports))for(let i of r[o]??[o])for(let o of Object.keys(t)){let t=`${i}.${o}`,r=s.get(t);if(void 0!==r&&r!==e.origin)throw Error(`Duplicate expression ${t}: it is defined in both ${r} and ${e.origin}, which would make its value depend on file order. Keep one definition and remove the other.`);s.set(t,e.origin)}return{origin:e.origin,expressions:e.exports}})};
1
+ import{isExpressionExport as e,mergeExpressionModules as o}from"./merge-expression-modules.js";export const resolveExpressionModules=(s,r)=>(o(s,r),s.flatMap(o=>e(o.exports)?[{origin:o.origin,expressions:o.exports}]:[]));
@@ -4,7 +4,10 @@ interface Context {
4
4
  }
5
5
  export declare const createWebComponentActions: (context: Context) => {
6
6
  setReadonly: (readonlyValue: boolean) => void;
7
+ setLocale: (locale: string) => void;
7
8
  startNewGeneration: () => void;
8
9
  };
9
10
  export type WebComponentActions = ReturnType<typeof createWebComponentActions>;
11
+ /** The writers the host-property mirror needs: the public `setReadonly` and the internal `setLocale`. */
12
+ export type WebComponentHostActions = Pick<WebComponentActions, 'setReadonly' | 'setLocale'>;
10
13
  export {};
@@ -1 +1 @@
1
- export const createWebComponentActions=e=>({setReadonly:t=>{e.setWebComponentState(e=>({...e,readonly:t}))},startNewGeneration:()=>{e.setWebComponentState(e=>({...e,webcomponentGeneration:e.webcomponentGeneration+1}))}});
1
+ export const createWebComponentActions=e=>({setReadonly:t=>{e.setWebComponentState(e=>({...e,readonly:t}))},setLocale:t=>{e.setWebComponentState(e=>({...e,locale:t}))},startNewGeneration:()=>{e.setWebComponentState(e=>({...e,webcomponentGeneration:e.webcomponentGeneration+1}))}});
@@ -1,2 +1,3 @@
1
1
  import type { ApplicationWebComponentState } from './types.js';
2
+ /** The initial state: `locale` is the host's property default, not resolved against the available locales. */
2
3
  export declare const initializeWebComponent: () => ApplicationWebComponentState;