@salsita-ai/sdk 0.50.0-develop.fbe43b9a2d → 0.50.0-develop.fda84314a5

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 (306) 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/client/authorized-client.d.ts +3 -1
  49. package/dist/client/authorized-client.js +1 -1
  50. package/dist/client/contract.d.ts +17 -0
  51. package/dist/client/index.d.ts +1 -1
  52. package/dist/client/local-authorized-client.d.ts +3 -1
  53. package/dist/client/local-authorized-client.js +1 -1
  54. package/dist/client/memory-authorized-client.d.ts +4 -1
  55. package/dist/client/memory-authorized-client.js +1 -1
  56. package/dist/client/phoenix-api.d.ts +228 -0
  57. package/dist/configurator/ConfiguratorApp.js +1 -1
  58. package/dist/configurator/app-loader-content/index.d.ts +0 -1
  59. package/dist/configurator/app-loader-content/index.js +1 -1
  60. package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
  61. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +17 -3
  62. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
  63. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +23 -6
  64. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -1
  65. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +15 -9
  66. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
  67. package/dist/configurator/common/configurator-interface.d.ts +8 -5
  68. package/dist/configurator/common/configurator-interface.js +1 -1
  69. package/dist/configurator/configuration-not-found-page/BuiltInConfigurationNotFoundPage.d.ts +5 -0
  70. package/dist/configurator/configuration-not-found-page/BuiltInConfigurationNotFoundPage.js +1 -0
  71. package/dist/configurator/configuration-not-found-page/ConfigurationNotFoundPageElement.d.ts +0 -6
  72. package/dist/configurator/configuration-not-found-page/ConfigurationNotFoundPageElement.js +1 -1
  73. package/dist/configurator/configuration-not-found-page/index.d.ts +2 -2
  74. package/dist/configurator/configuration-not-found-page/index.js +1 -1
  75. package/dist/configurator/configurator-context/ConfiguratorResponsiveProvider.d.ts +3 -3
  76. package/dist/configurator/configurator-context/ConfiguratorResponsiveProvider.js +1 -1
  77. package/dist/configurator/configurator-context/PreviewContextProvider.js +1 -1
  78. package/dist/configurator/configurator-error-page/BuiltInConfiguratorErrorPage.d.ts +3 -3
  79. package/dist/configurator/configurator-error-page/BuiltInConfiguratorErrorPage.js +1 -1
  80. package/dist/configurator/configurator-error-page/ConfiguratorErrorPageElement.d.ts +0 -5
  81. package/dist/configurator/configurator-error-page/ConfiguratorErrorPageElement.js +1 -1
  82. package/dist/configurator/configurator-error-page/index.d.ts +1 -2
  83. package/dist/configurator/configurator-error-page/index.js +1 -1
  84. package/dist/configurator/index.d.ts +9 -2
  85. package/dist/configurator/index.js +1 -1
  86. package/dist/configurator/pages/default-configurator-elements.js +1 -1
  87. package/dist/configurator/pages/error-boundaries/LoadingErrorBoundary.js +1 -1
  88. package/dist/configurator/ui/assistant/screenshots/ScreenshotThumbnails.d.ts +1 -1
  89. package/dist/configurator/ui/assistant/screenshots/ScreenshotThumbnails.js +1 -1
  90. package/dist/configurator/ui/assistant/screenshots/tool-screenshots.d.ts +12 -4
  91. package/dist/configurator/ui/assistant/screenshots/tool-screenshots.js +1 -1
  92. package/dist/configurator/ui/assistant/screenshots/use-screenshot-src.d.ts +8 -0
  93. package/dist/configurator/ui/assistant/screenshots/use-screenshot-src.js +1 -0
  94. package/dist/configurator/ui/configurator-layout/slots/canvas/LayoutCanvas.js +1 -1
  95. package/dist/configurator/ui/configurator-layout/slots/canvas/SharedCanvas.js +1 -1
  96. package/dist/configurator/ui/configurator-layout/universal/use-layout-scene-safe-area.js +1 -1
  97. package/dist/configurator/ui/legacy/layout/common/ReactiveInterfaceLayout.js +1 -1
  98. package/dist/configurator/ui/phoenix-layout-elements/AppLoader.d.ts +0 -7
  99. package/dist/configurator/ui/phoenix-layout-elements/AppLoader.js +2 -2
  100. package/dist/configurator/ui/phoenix-layout-elements/index.d.ts +8 -1
  101. package/dist/configurator/ui/phoenix-layout-elements/index.js +1 -1
  102. package/dist/configurator/ui/preset-layout/PresetUi.d.ts +0 -2
  103. package/dist/configurator/ui/preset-layout/PresetUi.js +1 -1
  104. package/dist/configurator/ui/preset-layout/index.d.ts +6 -1
  105. package/dist/configurator/ui/preset-layout/index.js +1 -1
  106. package/dist/configurator/ui/save-message-snackbars/SaveMessageSnackbars.js +1 -1
  107. package/dist/docs/index.json +34 -1
  108. package/dist/docs/integrations/webcomponent-api/basics.mdx +2 -0
  109. package/dist/docs/layouts/custom-layout.mdx +318 -158
  110. package/dist/docs/layouts/gallery/ardent-compressor.mdx +1 -0
  111. package/dist/docs/layouts/gallery/corvid-drone.mdx +3428 -0
  112. package/dist/docs/layouts/gallery/fenwick-window.mdx +198 -127
  113. package/dist/docs/layouts/gallery/nightjar-guitar.mdx +3698 -0
  114. package/dist/docs/layouts/gallery/sunfold-solar.mdx +16 -4
  115. package/dist/docs/layouts/gallery/tidepool-aquascape.mdx +5203 -0
  116. package/dist/docs/phoenix/configurator-interface.mdx +8 -6
  117. package/dist/docs/phoenix/sdk-builder-workflow.mdx +4 -2
  118. package/dist/docs/phoenix/sessions-and-access.mdx +2 -0
  119. package/dist/domain/application/assistant/build-assistant-manifest.js +1 -1
  120. package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -1
  121. package/dist/domain/application/configurator-builder.d.ts +7 -1
  122. package/dist/domain/application/configurator-builder.js +1 -1
  123. package/dist/domain/application/index.d.ts +1 -1
  124. package/dist/domain/application/index.js +1 -1
  125. package/dist/domain/application/standard-properties.js +1 -1
  126. package/dist/domain/application/web-component-property.d.ts +3 -1
  127. package/dist/domain/application/web-component-property.js +1 -1
  128. package/dist/domain/domain-builder.d.ts +9 -3
  129. package/dist/domain/domain-builder.js +1 -1
  130. package/dist/domain/domain-runtime/application.d.ts +39 -0
  131. package/dist/domain/domain-runtime/application.js +1 -0
  132. package/dist/domain/domain-runtime/domain-context/selectors.d.ts +1 -0
  133. package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
  134. package/dist/domain/domain-runtime/domain-runtime.d.ts +40 -4
  135. package/dist/domain/domain-runtime/domain-runtime.js +1 -1
  136. package/dist/domain/domain-runtime/environment/initialize.d.ts +1 -1
  137. package/dist/domain/domain-runtime/errors/implementation-error-collector.d.ts +2 -0
  138. package/dist/domain/domain-runtime/errors/implementation-error-collector.js +1 -1
  139. package/dist/domain/domain-runtime/index.d.ts +2 -1
  140. package/dist/domain/domain-runtime/index.js +1 -1
  141. package/dist/domain/domain-runtime/spec/index.d.ts +1 -1
  142. package/dist/domain/domain-runtime/spec/index.js +1 -1
  143. package/dist/domain/domain-runtime/spec/module-checks/index.d.ts +1 -0
  144. package/dist/domain/domain-runtime/spec/module-checks/index.js +1 -1
  145. package/dist/domain/domain-runtime/spec/module-checks/merge-expression-modules.d.ts +23 -0
  146. package/dist/domain/domain-runtime/spec/module-checks/merge-expression-modules.js +1 -0
  147. package/dist/domain/domain-runtime/spec/module-checks/resolve-expression-modules.d.ts +3 -4
  148. package/dist/domain/domain-runtime/spec/module-checks/resolve-expression-modules.js +1 -1
  149. package/dist/domain/domain-runtime/web-component/actions.d.ts +3 -0
  150. package/dist/domain/domain-runtime/web-component/actions.js +1 -1
  151. package/dist/domain/domain-runtime/web-component/initialize.d.ts +1 -0
  152. package/dist/domain/domain-runtime/web-component/initialize.js +1 -1
  153. package/dist/domain/domain-runtime/web-component/selectors.d.ts +2 -0
  154. package/dist/domain/domain-runtime/web-component/selectors.js +1 -1
  155. package/dist/domain/domain-runtime/web-component/types.d.ts +6 -3
  156. package/dist/domain/mocks/create-mock-domain-runtime.d.ts +7 -0
  157. package/dist/editor/domain-editors/DomainSpecContext.js +1 -1
  158. package/dist/editor/domain-editors/apply-spec-update.d.ts +2 -1
  159. package/dist/editor/domain-editors/apply-spec-update.js +1 -1
  160. package/dist/editor/domain-editors/use-implementation-files.d.ts +6 -14
  161. package/dist/editor/domain-editors/use-implementation-files.js +1 -1
  162. package/dist/legacy/domain-cli/utils/cache.d.ts +1 -1
  163. package/dist/legacy/domain-cli/utils/cache.js +1 -1
  164. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/claude-md.d.ts +1 -1
  165. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/cursor-rules.d.ts +1 -1
  166. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.d.ts +1 -1
  167. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.js +11 -5
  168. package/dist/react-sdk/application-runtime/common-services/analytics/analytics-service.d.ts +1 -1
  169. package/dist/react-sdk/application-runtime/common-services/initialize.d.ts +2 -2
  170. package/dist/react-sdk/application-runtime/hooks/index.d.ts +2 -0
  171. package/dist/react-sdk/application-runtime/hooks/index.js +1 -1
  172. package/dist/react-sdk/application-runtime/hooks/loading/index.d.ts +5 -0
  173. package/dist/react-sdk/application-runtime/hooks/loading/index.js +1 -0
  174. package/dist/react-sdk/application-runtime/hooks/loading/loader-host-context.d.ts +11 -0
  175. package/dist/react-sdk/application-runtime/hooks/loading/loader-host-context.js +1 -0
  176. package/dist/react-sdk/application-runtime/hooks/loading/use-is-awaiting-loading-phase.d.ts +8 -0
  177. package/dist/react-sdk/application-runtime/hooks/loading/use-is-awaiting-loading-phase.js +1 -0
  178. package/dist/react-sdk/application-runtime/hooks/loading/use-is-loader-hosted.d.ts +7 -0
  179. package/dist/react-sdk/application-runtime/hooks/loading/use-is-loader-hosted.js +1 -0
  180. package/dist/react-sdk/application-runtime/hooks/loading/use-loading-actions.d.ts +9 -0
  181. package/dist/react-sdk/application-runtime/hooks/loading/use-loading-actions.js +1 -0
  182. package/dist/react-sdk/application-runtime/hooks/loading/use-loading-application.d.ts +24 -0
  183. package/dist/react-sdk/application-runtime/hooks/loading/use-loading-application.js +1 -0
  184. package/dist/react-sdk/application-runtime/hooks/responsive/index.d.ts +3 -0
  185. package/dist/react-sdk/application-runtime/hooks/responsive/index.js +1 -0
  186. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-actions.d.ts +9 -0
  187. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-actions.js +1 -0
  188. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-application.d.ts +26 -0
  189. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-application.js +1 -0
  190. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-state.d.ts +10 -0
  191. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-state.js +1 -0
  192. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-store.d.ts +24 -0
  193. package/dist/react-sdk/application-runtime/hooks/responsive/use-responsive-store.js +1 -0
  194. package/dist/react-sdk/application-runtime/hooks/use-access-service.d.ts +5 -0
  195. package/dist/react-sdk/application-runtime/hooks/use-access-service.js +1 -1
  196. package/dist/react-sdk/application-runtime/hooks/use-web-component-readonly-sync.d.ts +4 -11
  197. package/dist/react-sdk/application-runtime/hooks/use-web-component-readonly-sync.js +1 -1
  198. package/dist/react-sdk/application-runtime/hooks/use-web-component.d.ts +5 -0
  199. package/dist/react-sdk/application-runtime/hooks/use-web-component.js +1 -1
  200. package/dist/react-sdk/application-runtime/host-properties/actions.d.ts +15 -0
  201. package/dist/react-sdk/application-runtime/host-properties/actions.js +1 -0
  202. package/dist/react-sdk/application-runtime/host-properties/connect-host-properties.d.ts +30 -0
  203. package/dist/react-sdk/application-runtime/host-properties/connect-host-properties.js +1 -0
  204. package/dist/react-sdk/application-runtime/host-properties/domain-host-properties.d.ts +7 -0
  205. package/dist/react-sdk/application-runtime/host-properties/domain-host-properties.js +1 -0
  206. package/dist/react-sdk/application-runtime/host-properties/host-property-descriptors.d.ts +21 -0
  207. package/dist/react-sdk/application-runtime/host-properties/host-property-descriptors.js +1 -0
  208. package/dist/react-sdk/application-runtime/host-properties/host-property-scopes.d.ts +42 -0
  209. package/dist/react-sdk/application-runtime/host-properties/host-property-scopes.js +1 -0
  210. package/dist/react-sdk/application-runtime/host-properties/index.d.ts +8 -0
  211. package/dist/react-sdk/application-runtime/host-properties/index.js +1 -0
  212. package/dist/react-sdk/application-runtime/host-properties/initialize.d.ts +7 -0
  213. package/dist/react-sdk/application-runtime/host-properties/initialize.js +1 -0
  214. package/dist/react-sdk/application-runtime/host-properties/selectors.d.ts +54 -0
  215. package/dist/react-sdk/application-runtime/host-properties/selectors.js +1 -0
  216. package/dist/react-sdk/application-runtime/host-properties/types.d.ts +18 -0
  217. package/dist/react-sdk/application-runtime/index.d.ts +3 -0
  218. package/dist/react-sdk/application-runtime/loading/actions.d.ts +45 -0
  219. package/dist/react-sdk/application-runtime/loading/actions.js +1 -0
  220. package/dist/react-sdk/application-runtime/loading/index.d.ts +4 -0
  221. package/dist/react-sdk/application-runtime/loading/index.js +1 -0
  222. package/dist/react-sdk/application-runtime/loading/initialize.d.ts +3 -0
  223. package/dist/react-sdk/application-runtime/loading/initialize.js +1 -0
  224. package/dist/react-sdk/application-runtime/loading/selectors.d.ts +18 -0
  225. package/dist/react-sdk/application-runtime/loading/selectors.js +1 -0
  226. package/dist/react-sdk/application-runtime/loading/types.d.ts +59 -0
  227. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.js +1 -1
  228. package/dist/react-sdk/application-runtime/provider/ApplicationRuntime.d.ts +6 -0
  229. package/dist/react-sdk/application-runtime/provider/ApplicationRuntime.js +1 -1
  230. package/dist/react-sdk/application-runtime/provider/ApplicationType.d.ts +7 -0
  231. package/dist/react-sdk/application-runtime/provider/ApplicationType.js +1 -1
  232. package/dist/react-sdk/application-runtime/responsive/actions.d.ts +47 -0
  233. package/dist/react-sdk/application-runtime/responsive/actions.js +1 -0
  234. package/dist/react-sdk/application-runtime/responsive/index.d.ts +4 -0
  235. package/dist/react-sdk/application-runtime/responsive/index.js +1 -0
  236. package/dist/react-sdk/application-runtime/responsive/initialize.d.ts +3 -0
  237. package/dist/react-sdk/application-runtime/responsive/initialize.js +1 -0
  238. package/dist/react-sdk/application-runtime/responsive/selectors.d.ts +20 -0
  239. package/dist/react-sdk/application-runtime/responsive/selectors.js +1 -0
  240. package/dist/react-sdk/application-runtime/responsive/types.d.ts +104 -0
  241. package/dist/react-sdk/application-runtime/responsive/types.js +1 -0
  242. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +309 -8
  243. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.js +1 -1
  244. package/dist/react-sdk/domain-application-context/BackendDataProvider.js +1 -1
  245. package/dist/react-sdk/domain-application-context/FrontendDataProvider.js +1 -1
  246. package/dist/react-sdk/domain-application-context/PublishedDataProvider.js +1 -1
  247. package/dist/react-sdk/domain-context/common-hooks/index.d.ts +1 -0
  248. package/dist/react-sdk/domain-context/common-hooks/index.js +1 -1
  249. package/dist/react-sdk/domain-context/common-hooks/use-configuration-save-state.d.ts +23 -0
  250. package/dist/react-sdk/domain-context/common-hooks/use-configuration-save-state.js +1 -0
  251. package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +1 -0
  252. package/dist/react-sdk/domain-context/index.d.ts +1 -0
  253. package/dist/react-sdk/domain-context/index.js +1 -1
  254. package/dist/react-sdk/elements/index.d.ts +0 -1
  255. package/dist/react-sdk/index.d.ts +1 -1
  256. package/dist/react-sdk/index.js +1 -1
  257. package/dist/react-sdk/loading-state/LoaderHost.d.ts +20 -0
  258. package/dist/react-sdk/loading-state/LoaderHost.js +1 -0
  259. package/dist/react-sdk/loading-state/built-in-loading-phase.d.ts +9 -0
  260. package/dist/react-sdk/loading-state/built-in-loading-phase.js +1 -0
  261. package/dist/react-sdk/loading-state/create-app-loader.d.ts +18 -0
  262. package/dist/react-sdk/loading-state/create-app-loader.js +1 -0
  263. package/dist/react-sdk/loading-state/index.d.ts +4 -2
  264. package/dist/react-sdk/loading-state/index.js +1 -1
  265. package/dist/react-sdk/loading-state/{LoadingStateProvider.d.ts → loading-state-hooks.d.ts} +3 -12
  266. package/dist/react-sdk/loading-state/loading-state-hooks.js +1 -0
  267. package/dist/react-sdk/page-elements/ConfigurationNotFoundPagePropsProvider.d.ts +17 -0
  268. package/dist/react-sdk/page-elements/ConfigurationNotFoundPagePropsProvider.js +1 -0
  269. package/dist/react-sdk/page-elements/ConfiguratorErrorPagePropsProvider.d.ts +17 -0
  270. package/dist/react-sdk/page-elements/ConfiguratorErrorPagePropsProvider.js +1 -0
  271. package/dist/react-sdk/page-elements/configurator-error-page-props.js +1 -0
  272. package/dist/{configurator/configuration-not-found-page → react-sdk/page-elements}/create-configuration-not-found-page.d.ts +7 -1
  273. package/dist/react-sdk/page-elements/create-configuration-not-found-page.js +1 -0
  274. package/dist/{configurator/configurator-error-page → react-sdk/page-elements}/create-configurator-error-page.d.ts +6 -1
  275. package/dist/react-sdk/page-elements/create-configurator-error-page.js +1 -0
  276. package/dist/react-sdk/page-elements/create-preset-ui.d.ts +9 -0
  277. package/dist/react-sdk/page-elements/create-preset-ui.js +1 -0
  278. package/dist/react-sdk/page-elements/index.d.ts +6 -0
  279. package/dist/react-sdk/page-elements/index.js +1 -0
  280. package/dist/react-sdk/session/SessionServiceProvider.js +1 -1
  281. package/dist/react-sdk/web-component/create-web-component.js +1 -1
  282. package/dist/ui-sdk/responsive-application/ResponsiveApplicationProvider.d.ts +2 -2
  283. package/dist/ui-sdk/responsive-application/responsive-state-store.d.ts +11 -9
  284. package/dist/ui-sdk/responsive-application/use-store-responsive-info.js +1 -1
  285. package/package.json +3 -3
  286. package/dist/configurator/app-loader-content/app-loader-content-name.d.ts +0 -5
  287. package/dist/configurator/app-loader-content/app-loader-content-name.js +0 -1
  288. package/dist/configurator/configuration-not-found-page/create-configuration-not-found-page.js +0 -1
  289. package/dist/configurator/configurator-error-page/create-configurator-error-page.js +0 -1
  290. package/dist/react-sdk/loading-state/LoadingStateProvider.js +0 -1
  291. package/dist/react-sdk/loading-state/loading-state-manager.d.ts +0 -37
  292. package/dist/react-sdk/loading-state/loading-state-manager.js +0 -1
  293. package/dist/react-sdk/responsive-state/ResponsiveStateProvider.d.ts +0 -25
  294. package/dist/react-sdk/responsive-state/ResponsiveStateProvider.js +0 -1
  295. package/dist/react-sdk/responsive-state/canvas-padding.d.ts +0 -14
  296. package/dist/react-sdk/responsive-state/index.d.ts +0 -5
  297. package/dist/react-sdk/responsive-state/index.js +0 -1
  298. package/dist/react-sdk/responsive-state/responsive-state-manager.d.ts +0 -111
  299. package/dist/react-sdk/responsive-state/responsive-state-manager.js +0 -1
  300. package/dist/react-sdk/responsive-state/use-responsive-state-manager.d.ts +0 -10
  301. package/dist/react-sdk/responsive-state/use-responsive-state-manager.js +0 -1
  302. package/dist/react-sdk/responsive-state/use-responsive-state.d.ts +0 -11
  303. package/dist/react-sdk/responsive-state/use-responsive-state.js +0 -1
  304. /package/dist/react-sdk/{elements/configurator-error-page-props.js → application-runtime/host-properties/types.js} +0 -0
  305. /package/dist/react-sdk/{responsive-state/canvas-padding.js → application-runtime/loading/types.js} +0 -0
  306. /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 = () => {
@@ -647,6 +648,7 @@ A layout builds its toolbar from `phx.frontend.useToolbarActions()`, which retur
647
648
  | `phx.frontend.useStateValidity()` | The validity of the last committed state: `{ valid: true, severity: null }`, or `{ valid: true, severity: 'notice' \| 'warning', entityViolations }`. A change that leaves a `fixable` or `fatal` violation is rejected and never committed, and neither is a change during which an error was thrown, so neither is seen here. |
648
649
  | `phx.frontend.useFinalizeViolations()` | `{ disabled, hints, violations }`. `disabled` is `true` while a `warning`, `fixable` or `fatal` violation holds or the configuration failed to save; `hints` is the violations' text, or `undefined`. |
649
650
  | `phx.frontend.useConfiguratorMessages(onMessage)` | Nothing. It calls `onMessage(message)` once per message: `{ kind: 'violation', entityId, violation, text }` for each violation of the rejected state, including notices and warnings already present, so `violation.severity` tells the reason for the rejection (`fixable` or `fatal`) from them, `{ kind: 'sideEffect', text }` for each hint of a committed update, `{ kind: 'error', error, text }` when an error is thrown while a change is validated, with `text` the generic "Oops, something went wrong", `{ kind: 'saveError', error, text }` each time saving the configuration fails, with `error` what the save rejected with and `text` a generic message, and `{ kind: 'saveRecovery', text }` when a save succeeds after a failed one, with `text` "Configuration updated". `text` is resolved to the current language; a violation's is its `message`, or its `type` without one, and the built-in snackbar prefixes it with `entityId`. Hints committed before the layout mounted are not delivered, nor is a save that failed before it mounted; when the most recent change was rejected or threw, its messages are delivered again when the hook mounts. `onMessage` may be a new function on every render. On `phx.frontend` the message is typed by the project, so `violation.type` narrows to its violation types; from `@salsita-ai/sdk/react` the type is `ConfiguratorMessage`. |
651
+ | `phx.frontend.useConfigurationSaveState()` | `{ revisionId, isSaving, failure }`, the save status of the configuration. An editable configuration saves every committed change on its own, three seconds after the last one, and a read-only one never saves. `revisionId` is the revision the configuration is at: the loaded one, then the one the latest save created. `isSaving` is `true` while a save runs. `failure` is `{ error, timestamp }` of the latest failed save, with `timestamp` in milliseconds since the epoch, and `null` once a later save succeeds or another configuration loads. A layout shows a save indicator with it; the messages of a failed save and of its recovery come from `useConfiguratorMessages`. Besides `phx.frontend`, `@salsita-ai/sdk/react` exports it. |
650
652
  | `phx.frontend.useFinalizeAction(handler)` | `{ run, isPending, error, disabled, hints }` for the `finalizeAction` whose `handler` it is given; see the Finalize paragraph below for how to call it. `run()` records the finalize-button click for analytics and runs the project's handler, does nothing while `disabled` or `isPending`, and returns a promise that resolves once the handler has settled and never rejects; `error` is what the handler's last run rejected with, or `null`; `disabled` and `hints` are those of `useFinalizeViolations()`. The type of the result is `UseFinalizeActionResult` from `@salsita-ai/sdk/configurator`, which also exports the hook. |
651
653
  | `phx.frontend.useFinalizeActions()` | `{ actions, primary, secondary, disabled, hints }`: every active `finalizeAction` of the spec in spec order, `primary` the first `'primary'` one, or else the first, or `null`, and `secondary` the others; see the Finalize paragraph below. Each action is `{ key, handler, variant, label, title, icon, run, isPending, error, disabled }`, with `label` and `title` resolved; `run()` records the finalize-button click for analytics and runs the action's handler, does nothing while `disabled` or `isPending`, and returns a promise that never rejects. `disabled` and `hints` are those of `useFinalizeViolations()`. Besides `phx.frontend`, `@salsita-ai/sdk/react` exports it. |
652
654
 
@@ -654,7 +656,7 @@ A layout builds its toolbar from `phx.frontend.useToolbarActions()`, which retur
654
656
 
655
657
  **Finalize**
656
658
 
657
- A project layout finalizes over the spec's `finalizeAction` components, each `{ variant, label, title, icon, handler }`, where `variant` is `'primary'` or `'secondary'` and `handler` names the project's handler registered with `phx.frontend.createPhoenixHandler`. `phx.frontend.useFinalizeActions()` is the convenient way: it lists them with what a button needs, runs their handlers itself, and can be called anywhere in the layout, including a dialog the layout opens with `useModal`, as often as it likes. It returns:
659
+ A project layout finalizes over the spec's `finalizeAction` components, each `{ variant, label, title, icon, handler }`, where `variant` is `'primary'` or `'secondary'` and `handler` names the project's handler registered with `phx.frontend.createPhoenixHandler`. `phx.frontend.useFinalizeActions()` is the convenient way: it lists them with what a button needs, runs their handlers itself, and can be called anywhere in the layout, including a dialog the layout opens with `useModal`, as often as it likes; [Custom Layout](?path=/docs/layouts-custom-layout--docs#request-a-quote) offers its primary action this way in its review step. It returns:
658
660
 
659
661
  - `actions`, every active `finalizeAction` in spec order, and `primary` and `secondary`, the same actions split as the built-in footer splits them: `primary` is the first `'primary'` action, or else the first action, or `null` without any, and `secondary` the others in spec order.
660
662
  - `disabled` and `hints`, those of `useFinalizeViolations()`: finalizing is not possible while a `warning`, `fixable` or `fatal` violation holds or the configuration failed to save, and `hints` says why.
@@ -698,7 +700,7 @@ export const Finalize = () => {
698
700
 
699
701
  The configurator runs the handlers outside the layout, beside it, whenever a configuration is open, also in read mode and on every step. A handler can use what the configurator provides, such as `useModal`, but not a provider the layout itself adds; such a handler fails to load and shows as that action's `error`. An action's `isPending` and `error` are kept while the layout re-renders and while its components unmount and mount again.
700
702
 
701
- To run a single action the layout already knows, `phx.frontend.useFinalizeAction(handler)` runs it in the layout itself and returns `{ run, isPending, error, disabled, hints }`, with the same meaning. It runs the project's handler factory, which calls hooks, so the layout calls it once per component, never in a loop or conditionally, and wraps that component in `<PhoenixHandlerBoundary name={handler}>` from `@salsita-ai/sdk/react`, so an edited handler takes effect without a reload. Its `isPending` and `error` belong to the mounted component: when it unmounts during a run, the handler keeps running, and a component mounted afterwards starts with `isPending` false and no `error`. [Custom Layout](?path=/docs/layouts-custom-layout--docs#request-a-quote) runs a finalize action this way from its review step.
703
+ To run a single action the layout already knows, `phx.frontend.useFinalizeAction(handler)` runs it in the layout itself and returns `{ run, isPending, error, disabled, hints }`, with the same meaning. It runs the project's handler factory, which calls hooks, so the layout calls it once per component, never in a loop or conditionally, and wraps that component in `<PhoenixHandlerBoundary name={handler}>` from `@salsita-ai/sdk/react`, so an edited handler takes effect without a reload. Its `isPending` and `error` belong to the mounted component: when it unmounts during a run, the handler keeps running, and a component mounted afterwards starts with `isPending` false and no `error`.
702
704
 
703
705
  Neither hook checks read mode, so the layout hides finalizing while `accessInfo.viewMode` is `true`, as above.
704
706
 
@@ -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.
@@ -427,6 +427,8 @@ The `readonly` web component property lets the host force view mode without chan
427
427
 
428
428
  Because an owner-token session can be forced read-only client-side while the server still accepts writes from that owner token, Phoenix skips persistence and logs a warning instead of updating the configuration. This guards against the configuration being silently overwritten by code paths that mutate state in read-only mode. UI that triggers significant changes (anything that produces a new revision) should still be disabled when `accessInfo.viewMode` is true — the warning is a backstop, not a substitute.
429
429
 
430
+ The assistant follows the same read-only rule as the UI: its `apply` tool refuses changes while `accessInfo.viewMode` is true, that is with a read-revision token or while `readonly` is set, and makes them again once it is false. A switch of `readonly` takes effect at once, in both directions, and the configurator loads the configuration again. A change applied after `readonly` is cleared and before the configuration has loaded again is not saved; saving resumes once it has loaded. The `query` tool keeps working, including its dry-run mutations.
431
+
430
432
  ```html
431
433
  <salsita-configurator readonly></salsita-configurator>
432
434
  ```
@@ -1 +1 @@
1
- import{GraphQLBoolean as e,GraphQLEnumType as t,GraphQLID as n,GraphQLInputObjectType as i,GraphQLInterfaceType as s,GraphQLList as r,GraphQLNonNull as o,GraphQLObjectType as a,GraphQLSchema as p,GraphQLString as c,printSchema as d,validateSchema as l}from"graphql";import{GraphQLJSON as h,createAssistantValueType as w}from"./assistant-value-type.js";import{buildAssistantLenses as y}from"./build-assistant-lenses.js";import{createAssistantExecutionSchema as u}from"./create-assistant-execution-schema.js";let m="AnyDomainEntity",f="RootEntity",g=[["navigationState","Active navigation state.","navigationStates"],["viewState","Active view state.","viewStates"],["toolState","Active tool state.","toolStates"]],b={section:"childRecipes",mutation:"addChild"},v={section:"replaceRecipes",mutation:"replaceEntity"},j=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],$=(e,t)=>{if(!t||0===t.length)return e;let n=`One of: ${t.map(e=>`"${e}"`).join(", ")}.`;return e?/[.!?]$/.test(e)?`${e} ${n}`:`${e}. ${n}`:n},O=({target:e,cardinality:t},n)=>{let i=n(e);switch(t){case"1-1":return new o(i);case"0-1":return i;case"0-N":case"1-N":return new o(new r(new o(i)))}},E=(e,t,i)=>{let s={id:{type:new o(n),description:i?`Unique id of the entity, assigned by the configurator, e.g. "${i}-1".`:void 0},type:{type:new o(c),description:i?`Entity type name, e.g. "${i}".`:void 0}};for(let n of e)s[n.name]={type:"edge"===n.type.kind?O(n.type,t):w(n.type.type),description:n.description};return s},R=e=>Object.fromEntries(e.map(({name:e,source:t,localized:n})=>[e,n?{source:t,localized:!0}:{source:t}])),k={sameForAllInstances:e=>`Same recipe groups and recipes for every ${e}.`,constantDuringSession:()=>"Fixed for the session."},T={sameForAllInstances:e=>`Same for every ${e}.`,constantDuringSession:()=>"Fixed for the session."},I=(e,t,n)=>e.map(e=>` ${t[e](n)}`).join(""),N=({section:e},{groups:t,hints:n},{entityType:i,purpose:s,recipeGroup:a})=>{let p=t.filter(({dryRuns:e})=>!e).map(({groupId:e})=>e);return 0===t.length?{}:{[e]:{type:new o(new r(new o(a))),description:`The recipe groups for ${s} this ${i}: ${t.map(({groupId:e})=>e).join(", ")}. A group is listed only while the configurator offers it on the entity.${p.length>0?` Recipes of these groups cannot be dry-run: ${p.join(", ")}.`:""}${I(n,k,i)}`}}},A=({entityType:e,childRecipes:n,replaceRecipes:i,optionsEdges:s,screenshots:p},{recipeGroup:c,fieldOption:d,screenshot:l})=>new a({name:`${e}Meta`,fields:Object.assign(N(b,n,{entityType:e,purpose:"adding children to",recipeGroup:c}),N(v,i,{entityType:e,purpose:"replacing",recipeGroup:c}),...s.map(({options:{edgeName:t,field:n,validate:i,dryRuns:s},hints:a})=>({[t]:{type:new r(new o(d)),description:`Values "${n}" accepts on this ${e}. Null when there is no choice to make.${i?"":" Not checked on write."}${s?"":" Cannot be dry-run."}${I(a,T,e)}`}})),0===p.length?{}:{screenshot:{type:l,args:{view:{type:new o(new t({name:`${e}ScreenshotView`,values:Object.fromEntries(p.map(({view:e,description:t})=>[e,{description:t}]))}))}},description:"Renders this entity from a predefined view. The picture follows the tool result as an image labelled with `image`. Each one costs tokens and blocks the user's configurator while it renders: ask only when seeing the design answers something the data cannot. The images of one call share a size budget; past it, further screenshots come back null. Null as well when the view does not apply to this entity right now."}})}),S=e=>Object.entries(e).map(([e,t])=>`${e} (${t.map(({groupId:e})=>e).join(", ")})`);export const buildAssistantManifest=t=>{var O,k,T,I,N;let M,D,F,W,{entityTypes:x,aliases:C,exampleType:q,fields:G,states:U,deletableTypes:K,writableTypes:V,actionFields:z,optionsEdges:P}=t,L=Object.fromEntries(Object.entries(t.childRecipes).map(([e,t])=>[e,t.groups])),Q=Object.fromEntries(Object.entries(t.replaceRecipes).map(([e,t])=>[e,t.groups])),B=new Map,H=new Map,J=new Map,X=e=>{let[t,...n]=Object.entries(C).find(([t])=>t===e)?.[1]??[];return(t&&0===n.length?H.get(t):void 0)??J.get(e)??Z},Y=e=>H.get(e)??X(e),Z=new s({name:m,description:"Every entity of the configuration.",fields:()=>E(G[m]??[],Y,q)});for(let e of(J.set(m,Z),Object.keys(C)))e!==m&&J.set(e,new s({name:e,interfaces:[Z],fields:()=>E(G[e]??[],Y)}));let _={};for(let e of x){let t=[m,...Object.entries(C).filter(([t,n])=>t!==m&&n.includes(e)).map(([e])=>e)],n=G[e]??[];_[e]=R(n),H.set(e,new a({name:e,interfaces:t.flatMap(e=>J.get(e)??[]),fields:()=>{let t=B.get(e);return{...E(n,Y),...t?{meta:{type:new o(t),description:"What can be done to this entity right now."}}:{}}}}))}let ee=(O=()=>X(J.has(f)?f:m),k=()=>X(m),M=new a({name:"DryRunError",description:"One reason a change cannot be made right now.",fields:{type:{type:new o(c),description:"Kind of the problem."},entityId:{type:n,description:"The entity the problem is on, when it is on one."},message:{type:c,description:"The problem as the user would be told it."}}}),new a({name:"DryRun",description:"What using a recipe or writing an option would do, tried out on the configuration the query reads. Nothing is changed.",fields:()=>({ok:{type:new o(e),description:"Whether the change would succeed on the configuration the query reads."},root:{type:O(),description:"The root entity of the configuration as it would be after the change; null when ok is false. Everything selected under it reads that configuration."},changedEntities:{type:new o(new r(new o(k()))),description:"Entities the change would add or modify; empty when ok is false. One whose id is not in the configuration would be added, and its real id may differ. An entity written to is listed even when its values stay the same."},deletedEntityIds:{type:new o(new r(new o(n))),description:"The ids of the entities the change would remove; empty when ok is false."},sideEffects:{type:new o(new r(new o(c))),description:"The major or unexpected things the configurator would change along with it; empty when ok is false."},errors:{type:new o(new r(new o(M))),description:"Why the change cannot be made; empty when ok is true."}})})),et={recipeGroup:(T=[...Object.keys(L).length>0?[b.mutation]:[],...Object.keys(Q).length>0?[v.mutation]:[]],D=T.join(" or "),F=new a({name:"Recipe",description:`${T.includes("addChild")?"One thing that can be added to the entity (under childRecipes)":"One thing the entity can be replaced with (under replaceRecipes)"}${T.length>1?" or that it can be replaced with (under replaceRecipes)":""}.`,fields:{key:{type:new o(c),description:`Pass to ${D} as recipeKey. Valid only for the listing it came from.`},name:{type:new o(c),description:"Name shown to the user."},description:{type:c},imageUrl:{type:c,description:"Thumbnail shown to the user."},dryRun:{type:ee,description:"What using this recipe would do. Null when it cannot be tried."}}}),new a({name:"RecipeGroup",description:"A group of recipes for this entity.",fields:{groupId:{type:new o(c),description:`Pass to ${D} as recipeGroupId.`},name:{type:new o(c),description:"Name shown to the user."},description:{type:c},recipes:{type:new o(new r(new o(F)))}}})),fieldOption:new a({name:"FieldOption",description:"One value a field accepts. Writing a value outside the list is rejected unless the field description says it is not checked.",fields:{value:{type:new o(h),description:"The value to write to the field."},name:{type:c,description:"Name shown to the user."},description:{type:c},imageUrl:{type:c,description:"Image shown to the user."},color:{type:c,description:'Color shown to the user, as "#rrggbb".'},dryRun:{type:ee,description:"What writing this value would do. Null when it cannot be tried."}}}),screenshot:new a({name:"Screenshot",description:"A screenshot of an entity. The picture itself follows the tool result.",fields:{image:{type:new o(n),description:"Label of the image that follows the tool result."}}})};for(let e of x){let n=j(t.childRecipes,e)??{groups:[],hints:[]},i=j(t.replaceRecipes,e)??{groups:[],hints:[]},s=j(P,e)??[],r=j(t.screenshots,e)??[];(n.groups.length>0||i.groups.length>0||s.length>0||r.length>0)&&B.set(e,A({entityType:e,childRecipes:n,replaceRecipes:i,optionsEdges:s.map(t=>({...t,hints:(C[f]??[]).includes(e)?t.hints.filter(e=>"sameForAllInstances"!==e):t.hints})),screenshots:r},et))}let en=new p({query:(I=X(J.has(f)?f:m),N=X(m),W=(e=>{let t={};for(let[n,i,s]of g){let r=e[s];r.length>1&&(t[n]={type:new o(c),description:$(i,r)})}if(0!==Object.keys(t).length)return new a({name:"Navigation",description:"The active UI states of the configurator.",fields:t})})(U),new a({name:"Query",fields:{root:{type:new o(I),description:"The root entity of the configuration."},entities:{type:new o(new r(N)),args:{ids:{type:new r(new o(n))}},description:"Every entity, or the given ids in order with null for an unknown id."},selectedEntity:{type:new o(N),description:"The selected entity, or the root entity when nothing is selected."},...W?{navigation:{type:new o(W)}}:{}}})),mutation:(({deletableTypes:e,writableTypes:t,childRecipes:s,replaceRecipes:p,actionFields:d,objectTypes:l,anyDomainEntity:h,targetOutputType:y})=>{let u,m;if(0!==e.length||0!==t.length||0!==Object.keys(s).length||0!==Object.keys(p).length||0!==d.length)return new a({name:"Mutation",fields:Object.assign(0===e.length?{}:{deleteEntity:{type:new o(new r(new o(n))),args:{id:{type:new o(n)}},description:`Deletes the entity and everything composed into it. Deletable types: ${e.join(", ")}. Returns the ids removed, the given one first.`}},0===(u=S(s)).length?{}:{addChild:{type:new o(new r(new o(h))),args:{parentId:{type:new o(n)},recipeGroupId:{type:new o(c)},recipeKey:{type:new o(c)}},description:`Adds a child to the entity parentId from a recipe listed under its meta { childRecipes }. Types with child recipes: ${u.join("; ")}. Returns the entities added, the recipe's own first; empty when they were removed again.`}},0===(m=S(p)).length?{}:{replaceEntity:{type:new o(new r(new o(h))),args:{entityId:{type:new o(n)},recipeGroupId:{type:new o(c)},recipeKey:{type:new o(c)}},description:`Replaces the entity entityId from a recipe listed under its meta { replaceRecipes }. Types with replace recipes: ${m.join("; ")}. The replacement is a new entity: it has a new id and the field values of its recipe, and entityId no longer exists. Returns the entities added, the replacement first; empty when they were removed again.`}},...t.flatMap(e=>{let t=l.get(e.entityType);return t?[(({entityType:e,fields:t},s)=>{let r=Object.fromEntries(t.map(({name:e,type:t,description:n})=>[e,{type:w(t),description:n}]));return{[`modify${e}`]:{type:s,args:{id:{type:new o(n)},delta:{type:new o(new i({name:`${e}Delta`,fields:r}))}},description:`Sets the fields named in delta on one ${e}. Returns the entity after the change, or null when the change removed it.`}}})(e,t)]:[]}),Object.fromEntries(d.map(e=>{var t;return[e.fieldName,{type:new o(new a({name:(t=e.fieldName,`${t.charAt(0).toUpperCase()+t.slice(1)}Result`),description:`What ${e.fieldName} returns, read from the configuration after the change.`,fields:()=>Object.fromEntries(Object.entries(e.result).map(([e,t])=>[e,{type:"edge"===t.kind?(({target:e,list:t,nullable:n},i)=>{let s=t?new r(new o(i(e))):i(e);return n?s:new o(s)})(t,y):w(t.type),description:t.description}]))})),args:Object.fromEntries(Object.entries(e.args).map(([e,t])=>[e,{type:w(t.type),description:t.description}])),description:e.description}]})))})})({deletableTypes:K,writableTypes:V,childRecipes:L,replaceRecipes:Q,actionFields:z,objectTypes:H,anyDomainEntity:X(m),targetOutputType:Y}),types:[...J.values(),...H.values()]}),ei=l(en);if(ei.length>0)throw Error(ei.map(e=>e.message).join(" "));let es=d(en);return{sdl:es,navigationFields:g.filter(([,,e])=>U[e].length>1).map(([e])=>e),fields:_,deletableTypes:K,writableFields:Object.fromEntries(V.map(({entityType:e,fields:t})=>[e,Object.fromEntries(t.map(({name:e,property:t})=>[e,t]))])),childRecipes:L,replaceRecipes:Q,fieldOptions:Object.fromEntries(x.flatMap(e=>{let t=j(P,e);return t?[[e,t.map(({options:e})=>e)]]:[]})),screenshots:Object.fromEntries(x.flatMap(e=>{let n=j(t.screenshots,e);return n?[[e,n]]:[]})),actions:Object.fromEntries(z.map(({fieldName:e,actionName:t})=>[e,t])),lenses:y(t,u(es)),formElements:t.formElements}};
1
+ import{GraphQLBoolean as e,GraphQLEnumType as t,GraphQLID as n,GraphQLInputObjectType as i,GraphQLInterfaceType as s,GraphQLList as r,GraphQLNonNull as o,GraphQLObjectType as a,GraphQLSchema as p,GraphQLString as d,printSchema as c,validateSchema as l}from"graphql";import{GraphQLJSON as h,createAssistantValueType as w}from"./assistant-value-type.js";import{buildAssistantLenses as y}from"./build-assistant-lenses.js";import{createAssistantExecutionSchema as u}from"./create-assistant-execution-schema.js";let m="AnyDomainEntity",f="RootEntity",g=[["navigationState","Active navigation state.","navigationStates"],["viewState","Active view state.","viewStates"],["toolState","Active tool state.","toolStates"]],b={section:"childRecipes",mutation:"addChild"},v={section:"replaceRecipes",mutation:"replaceEntity"},j=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],$=(e,t)=>{if(!t||0===t.length)return e;let n=`One of: ${t.map(e=>`"${e}"`).join(", ")}.`;return e?/[.!?]$/.test(e)?`${e} ${n}`:`${e}. ${n}`:n},O=({target:e,cardinality:t},n)=>{let i=n(e);switch(t){case"1-1":return new o(i);case"0-1":return i;case"0-N":case"1-N":return new o(new r(new o(i)))}},E=(e,t,i)=>{let s={id:{type:new o(n),description:i?`Unique id of the entity, assigned by the configurator, e.g. "${i}-1".`:void 0},type:{type:new o(d),description:i?`Entity type name, e.g. "${i}".`:void 0}};for(let n of e)s[n.name]={type:"edge"===n.type.kind?O(n.type,t):w(n.type.type),description:n.description};return s},R=e=>Object.fromEntries(e.map(({name:e,source:t,localized:n})=>[e,n?{source:t,localized:!0}:{source:t}])),k={sameForAllInstances:e=>`Same recipe groups and recipes for every ${e}.`,constantDuringSession:()=>"Fixed for the session."},T={sameForAllInstances:e=>`Same for every ${e}.`,constantDuringSession:()=>"Fixed for the session."},I=(e,t,n)=>e.map(e=>` ${t[e](n)}`).join(""),N=({section:e},{groups:t,hints:n},{entityType:i,purpose:s,recipeGroup:a})=>{let p=t.filter(({dryRuns:e})=>!e).map(({groupId:e})=>e);return 0===t.length?{}:{[e]:{type:new o(new r(new o(a))),description:`The recipe groups for ${s} this ${i}: ${t.map(({groupId:e})=>e).join(", ")}. A group is listed only while the configurator offers it on the entity.${p.length>0?` Recipes of these groups cannot be dry-run: ${p.join(", ")}.`:""}${I(n,k,i)}`}}},A=({entityType:e,childRecipes:n,replaceRecipes:i,optionsEdges:s,screenshots:p},{recipeGroup:d,fieldOption:c,screenshot:l})=>new a({name:`${e}Meta`,fields:Object.assign(N(b,n,{entityType:e,purpose:"adding children to",recipeGroup:d}),N(v,i,{entityType:e,purpose:"replacing",recipeGroup:d}),...s.map(({options:{edgeName:t,field:n,validate:i,dryRuns:s},hints:a})=>({[t]:{type:new r(new o(c)),description:`Values "${n}" accepts on this ${e}. Null when there is no choice to make.${i?"":" Not checked on write."}${s?"":" Cannot be dry-run."}${I(a,T,e)}`}})),0===p.length?{}:{screenshot:{type:l,args:{view:{type:new o(new t({name:`${e}ScreenshotView`,values:Object.fromEntries(p.map(({view:e,description:t})=>[e,{description:t}]))}))}},description:"Renders this entity from a predefined view. The picture follows the tool result as an image labelled with `image`. Null when the view does not apply to this entity right now."}})}),S=e=>Object.entries(e).map(([e,t])=>`${e} (${t.map(({groupId:e})=>e).join(", ")})`);export const buildAssistantManifest=t=>{var O,k,T,I,N;let M,D,F,W,{entityTypes:x,aliases:C,exampleType:q,fields:G,states:U,deletableTypes:K,writableTypes:V,actionFields:P,optionsEdges:z}=t,L=Object.fromEntries(Object.entries(t.childRecipes).map(([e,t])=>[e,t.groups])),Q=Object.fromEntries(Object.entries(t.replaceRecipes).map(([e,t])=>[e,t.groups])),B=new Map,H=new Map,J=new Map,X=e=>{let[t,...n]=Object.entries(C).find(([t])=>t===e)?.[1]??[];return(t&&0===n.length?H.get(t):void 0)??J.get(e)??Z},Y=e=>H.get(e)??X(e),Z=new s({name:m,description:"Every entity of the configuration.",fields:()=>E(G[m]??[],Y,q)});for(let e of(J.set(m,Z),Object.keys(C)))e!==m&&J.set(e,new s({name:e,interfaces:[Z],fields:()=>E(G[e]??[],Y)}));let _={};for(let e of x){let t=[m,...Object.entries(C).filter(([t,n])=>t!==m&&n.includes(e)).map(([e])=>e)],n=G[e]??[];_[e]=R(n),H.set(e,new a({name:e,interfaces:t.flatMap(e=>J.get(e)??[]),fields:()=>{let t=B.get(e);return{...E(n,Y),...t?{meta:{type:new o(t),description:"What can be done to this entity right now."}}:{}}}}))}let ee=(O=()=>X(J.has(f)?f:m),k=()=>X(m),M=new a({name:"DryRunError",description:"One reason a change cannot be made right now.",fields:{type:{type:new o(d),description:"Kind of the problem."},entityId:{type:n,description:"The entity the problem is on, when it is on one."},message:{type:d,description:"The problem as the user would be told it."}}}),new a({name:"DryRun",description:"What using a recipe or writing an option would do, tried out on the configuration the query reads. Nothing is changed.",fields:()=>({ok:{type:new o(e),description:"Whether the change would succeed on the configuration the query reads."},root:{type:O(),description:"The root entity of the configuration as it would be after the change; null when ok is false. Everything selected under it reads that configuration."},changedEntities:{type:new o(new r(new o(k()))),description:"Entities the change would add or modify; empty when ok is false. One whose id is not in the configuration would be added, and its real id may differ. An entity written to is listed even when its values stay the same."},deletedEntityIds:{type:new o(new r(new o(n))),description:"The ids of the entities the change would remove; empty when ok is false."},sideEffects:{type:new o(new r(new o(d))),description:"The major or unexpected things the configurator would change along with it; empty when ok is false."},errors:{type:new o(new r(new o(M))),description:"Why the change cannot be made; empty when ok is true."}})})),et={recipeGroup:(T=[...Object.keys(L).length>0?[b.mutation]:[],...Object.keys(Q).length>0?[v.mutation]:[]],D=T.join(" or "),F=new a({name:"Recipe",description:`${T.includes("addChild")?"One thing that can be added to the entity (under childRecipes)":"One thing the entity can be replaced with (under replaceRecipes)"}${T.length>1?" or that it can be replaced with (under replaceRecipes)":""}.`,fields:{key:{type:new o(d),description:`Pass to ${D} as recipeKey. Valid only for the listing it came from.`},name:{type:new o(d),description:"Name shown to the user."},description:{type:d},imageUrl:{type:d,description:"Thumbnail shown to the user."},dryRun:{type:ee,description:"What using this recipe would do. Null when it cannot be tried."}}}),new a({name:"RecipeGroup",description:"A group of recipes for this entity.",fields:{groupId:{type:new o(d),description:`Pass to ${D} as recipeGroupId.`},name:{type:new o(d),description:"Name shown to the user."},description:{type:d},recipes:{type:new o(new r(new o(F)))}}})),fieldOption:new a({name:"FieldOption",description:"One value a field accepts. Writing a value outside the list is rejected unless the field description says it is not checked.",fields:{value:{type:new o(h),description:"The value to write to the field."},name:{type:d,description:"Name shown to the user."},description:{type:d},imageUrl:{type:d,description:"Image shown to the user."},color:{type:d,description:'Color shown to the user, as "#rrggbb".'},dryRun:{type:ee,description:"What writing this value would do. Null when it cannot be tried."}}}),screenshot:new a({name:"Screenshot",description:"A screenshot of an entity. The picture itself follows the tool result.",fields:{image:{type:new o(n),description:"Label of the image that follows the tool result."}}})};for(let e of x){let n=j(t.childRecipes,e)??{groups:[],hints:[]},i=j(t.replaceRecipes,e)??{groups:[],hints:[]},s=j(z,e)??[],r=j(t.screenshots,e)??[];(n.groups.length>0||i.groups.length>0||s.length>0||r.length>0)&&B.set(e,A({entityType:e,childRecipes:n,replaceRecipes:i,optionsEdges:s.map(t=>({...t,hints:(C[f]??[]).includes(e)?t.hints.filter(e=>"sameForAllInstances"!==e):t.hints})),screenshots:r},et))}let en=new p({query:(I=X(J.has(f)?f:m),N=X(m),W=(e=>{let t={};for(let[n,i,s]of g){let r=e[s];r.length>1&&(t[n]={type:new o(d),description:$(i,r)})}if(0!==Object.keys(t).length)return new a({name:"Navigation",description:"The active UI states of the configurator.",fields:t})})(U),new a({name:"Query",fields:{root:{type:new o(I),description:"The root entity of the configuration."},entities:{type:new o(new r(N)),args:{ids:{type:new r(new o(n))}},description:"Every entity, or the given ids in order with null for an unknown id."},selectedEntity:{type:new o(N),description:"The selected entity, or the root entity when nothing is selected."},...W?{navigation:{type:new o(W)}}:{}}})),mutation:(({deletableTypes:e,writableTypes:t,childRecipes:s,replaceRecipes:p,actionFields:c,objectTypes:l,anyDomainEntity:h,targetOutputType:y})=>{let u,m;if(0!==e.length||0!==t.length||0!==Object.keys(s).length||0!==Object.keys(p).length||0!==c.length)return new a({name:"Mutation",fields:Object.assign(0===e.length?{}:{deleteEntity:{type:new o(new r(new o(n))),args:{id:{type:new o(n)}},description:`Deletes the entity and everything composed into it. Deletable types: ${e.join(", ")}. Returns the ids removed, the given one first.`}},0===(u=S(s)).length?{}:{addChild:{type:new o(new r(new o(h))),args:{parentId:{type:new o(n)},recipeGroupId:{type:new o(d)},recipeKey:{type:new o(d)}},description:`Adds a child to the entity parentId from a recipe listed under its meta { childRecipes }. Types with child recipes: ${u.join("; ")}. Returns the entities added, the recipe's own first; empty when they were removed again.`}},0===(m=S(p)).length?{}:{replaceEntity:{type:new o(new r(new o(h))),args:{entityId:{type:new o(n)},recipeGroupId:{type:new o(d)},recipeKey:{type:new o(d)}},description:`Replaces the entity entityId from a recipe listed under its meta { replaceRecipes }. Types with replace recipes: ${m.join("; ")}. The replacement is a new entity: it has a new id and the field values of its recipe, and entityId no longer exists. Returns the entities added, the replacement first; empty when they were removed again.`}},...t.flatMap(e=>{let t=l.get(e.entityType);return t?[(({entityType:e,fields:t},s)=>{let r=Object.fromEntries(t.map(({name:e,type:t,description:n})=>[e,{type:w(t),description:n}]));return{[`modify${e}`]:{type:s,args:{id:{type:new o(n)},delta:{type:new o(new i({name:`${e}Delta`,fields:r}))}},description:`Sets the fields named in delta on one ${e}. Returns the entity after the change, or null when the change removed it.`}}})(e,t)]:[]}),Object.fromEntries(c.map(e=>{var t;return[e.fieldName,{type:new o(new a({name:(t=e.fieldName,`${t.charAt(0).toUpperCase()+t.slice(1)}Result`),description:`What ${e.fieldName} returns, read from the configuration after the change.`,fields:()=>Object.fromEntries(Object.entries(e.result).map(([e,t])=>[e,{type:"edge"===t.kind?(({target:e,list:t,nullable:n},i)=>{let s=t?new r(new o(i(e))):i(e);return n?s:new o(s)})(t,y):w(t.type),description:t.description}]))})),args:Object.fromEntries(Object.entries(e.args).map(([e,t])=>[e,{type:w(t.type),description:t.description}])),description:e.description}]})))})})({deletableTypes:K,writableTypes:V,childRecipes:L,replaceRecipes:Q,actionFields:P,objectTypes:H,anyDomainEntity:X(m),targetOutputType:Y}),types:[...J.values(),...H.values()]}),ei=l(en);if(ei.length>0)throw Error(ei.map(e=>e.message).join(" "));let es=c(en);return{sdl:es,navigationFields:g.filter(([,,e])=>U[e].length>1).map(([e])=>e),fields:_,deletableTypes:K,writableFields:Object.fromEntries(V.map(({entityType:e,fields:t})=>[e,Object.fromEntries(t.map(({name:e,property:t})=>[e,t]))])),childRecipes:L,replaceRecipes:Q,fieldOptions:Object.fromEntries(x.flatMap(e=>{let t=j(z,e);return t?[[e,t.map(({options:e})=>e)]]:[]})),screenshots:Object.fromEntries(x.flatMap(e=>{let n=j(t.screenshots,e);return n?[[e,n]]:[]})),actions:Object.fromEntries(P.map(({fieldName:e,actionName:t})=>[e,t])),lenses:y(t,u(es)),formElements:t.formElements}};
@@ -1 +1 @@
1
- import{ASSISTANT_BUILT_IN_FORM_ELEMENTS as e}from"./form/index.js";let t=[["Containers",["group","choice","choices"]],["Options",["option"]],["Inputs",["input"]]];export const formElementSignature=({name:e,role:t,attributes:a})=>{let n=["label",...Object.entries(a).map(([e,t])=>((e,{type:t,enum:a})=>a?`${e}="${a.join("|")}"`:"string"===t?e:`${e}="<${t}>"`)(e,t))];return"option"===t||"input"===t?`<${e} ${n.join(" ")} />`:`<${e} ${n.join(" ")}>…</${e}>`};export const generateAssistantPrompt=a=>{let n,s=Object.values(a.childRecipes??{}).some(e=>e.length>0),i=Object.values(a.replaceRecipes??{}).some(e=>e.length>0),o=Object.values(a.fieldOptions??{}).some(e=>e.length>0),r=Object.keys(a.actions??{}).length>0,h=(a.deletableTypes?.length??0)>0||Object.values(a.writableFields??{}).some(e=>Object.keys(e).length>0)||s||i||r,l=s||i||o,d=[...s?["`childRecipes` is what can be added to it"]:[],...i?["`replaceRecipes` what it can be replaced with"]:[],...o?["`<field>Options` the values a field accepts"]:[]],c=["`selected`",...(a.navigationFields??[]).map(e=>`\`${e}\``)].join(", ");return[["Tools","- Put related operations in one call and select only the fields you need.",...h?[`- Use a mutation inside \`query\` to answer a what-if about a change ${l?"the lists under `meta` do not show":"before making it"}.`,"- Use `apply` only for what the user asked for."]:["- Nothing in this configurator can be changed through you. Say so when the user asks for a change."],"- When an operation fails, its `errors` say why and what to send instead."],...h?[["After a change","- A change is made only when the `apply` result has `committed: true`. Otherwise `errors` or `message` says what happened; without either, nothing changed. Never say a change was made when it was not.","- `sideEffects` names the major or unexpected things the configurator changed along with your change. Tell the user about them when committed; otherwise they describe what would happen. Smaller adjustments are not listed.","- A mutation returns the state after the change: use the ids and values it returned, not the ones you sent.",...r?["- When one mutation does the whole of what the user asked, use it instead of building the same change from several others."]:[]]]:[],...l?[["What can be done to an entity",`- \`meta\` lists what is possible right now: ${d.join(", ")}. Read the list before such a change and before telling the user what is available.`,`- You can select \`dryRun\` on ${[...s||i?["recipes"]:[],...o?["options"]:[]].join(" or ")} to look ahead and pick one that meets what the user asked for. It is optional before a change.`,"- Read the lists again after a change, unless their descriptions say they stay the same."]]:[],["The `[changes]` block","- Every user message starts with it: a glimpse of what the user did in the configurator since your last turn.",`- \`[changes: none]\`, or only ${c} lines: what you know still holds. Do not query it again.`,"- Other lines are a hint at what to read again: `A` added, `D` deleted, `M` modified with the fields. Text after `#` says what caused the line; `reset: undo/redo` says the user undid or redid changes.","- Read computed fields again when a listed change may affect them.","- `[changes: unavailable]` and `[changes: too many (n)]`: read again before relying on anything you read earlier.",...h?["- Your applied changes are not listed, except those waiting for user approval: they appear once approved."]:[]],["Reading the schema","- Take ids from results.",...(a.deletableTypes?.length??0)>0||i?["- The id of a deleted or replaced entity is gone and may later be given to another entity."]:[],`- A field whose name starts with \`_\` is computed: read it${h?", never write it":""}.`,"- Numbers are in the unit the field description names. Convert when the user uses another unit."],["Links","- You may link an entity of the current configuration when you speak about that very entity: `[the left burner](entity:CookingTop-1)`. It helps the user find it in the configurator.",...l?["- Whenever you name recipes or options you read from `meta`, in a list, a table or a sentence, link each one: `[Single gas burner](recipe:KitchenRange-1/top/gas_single)` or `[Oak](option:Cabinet-2/finishOptions/oak)`. The link shows the user its picture or color and its description, so never draw previews yourself. The target is the entity id, the recipe group id or the options field you read, and the key or value, each encoded as in a URL."]:[]],["Replies","- Write Markdown only, never HTML: the panel does not render it.","- An image, `![alt](path)`, is shown only when its path is relative.","- To make a warning or a key note stand out, write a GitHub alert: a blockquote whose first line is only `[!WARNING]` or `[!NOTE]`. Use it sparingly."],["Forms","- To ask the user something they answer by picking or typing, end your reply with a form: a fenced code block with the language `form`. It holds only elements, written as lowercase tags with string attributes, without Markdown or text.","- Every element takes `label`, the text the user sees; on a container or an input it also names the answer. An option or an input whose signature lists `value` takes it: an option sends it instead of its label, and an input starts with it.",'- A bare attribute in a signature takes any text, `name="<type>"` takes a value of that type written as text, such as `min="<number>"`, and `name="a|b"` takes one of the words listed.',"- Options can also stand on their own, outside a `choice` or `choices`.","- An element or attribute not listed here, or an element other than an option inside a `choice` or `choices`, makes the whole form fail.","- The answer is the user's next message. Each container or input gives a line `Label: value`, or the bare value without a label; the lines of a labelled container are indented by two spaces under it, a `choices` lists each picked option on its own line, and `—` marks what was left unanswered.",'- Example: `<choice label="Plinth"><reply label="Black" /><reply label="Oak" /></choice>` is answered with `Plinth: Oak`.',"- The chat shows the answer as the user's own message, so a `value` reads as natural words, never as an id, key or code. Give `value` only when the label alone would be unclear as an answer, and map the answer's labels back to ids yourself.",...(n=[...e,...a.formElements??[]],t.flatMap(([e,t])=>{let a=n.filter(({role:e})=>t.includes(e));return 0===a.length?[]:[`- ${e}:`,...a.map(e=>` - \`${formElementSignature(e)}\`: ${(({description:e,required:t=[]})=>0===t.length?e:`${e} Requires ${t.map(e=>`\`${e}\``).join(", ")}.`)(e)}`)]}))],...a.lenses?.declarations?[["Built-in fragments","- These fragments are already defined for every operation. Spread one by name on a field of its type, as in `field { ...FragmentName }`, instead of listing its fields.","- A fragment is a starting selection: add the other fields you need next to the spread, by name from the schema.","- Never define a fragment with one of these names.","",a.lenses.declarations]]:[]].map(e=>e.join("\n")).join("\n\n")};
1
+ import{ASSISTANT_BUILT_IN_FORM_ELEMENTS as e}from"./form/index.js";let t=[["Containers",["group","choice","choices"]],["Options",["option"]],["Inputs",["input"]]];export const formElementSignature=({name:e,role:t,attributes:a})=>{let n=["label",...Object.entries(a).map(([e,t])=>((e,{type:t,enum:a})=>a?`${e}="${a.join("|")}"`:"string"===t?e:`${e}="<${t}>"`)(e,t))];return"option"===t||"input"===t?`<${e} ${n.join(" ")} />`:`<${e} ${n.join(" ")}>…</${e}>`};export const generateAssistantPrompt=a=>{let n,s=Object.values(a.childRecipes??{}).some(e=>e.length>0),o=Object.values(a.replaceRecipes??{}).some(e=>e.length>0),i=Object.values(a.fieldOptions??{}).some(e=>e.length>0),r=Object.keys(a.actions??{}).length>0,h=Object.values(a.screenshots??{}).some(e=>e.length>0),l=(a.deletableTypes?.length??0)>0||Object.values(a.writableFields??{}).some(e=>Object.keys(e).length>0)||s||o||r,d=s||o||i,u=[...s?["`childRecipes` is what can be added to it"]:[],...o?["`replaceRecipes` what it can be replaced with"]:[],...i?["`<field>Options` the values a field accepts"]:[]],c=["`selected`",...(a.navigationFields??[]).map(e=>`\`${e}\``)].join(", ");return[["Tools","- Put related operations in one call and select only the fields you need.",...l?[`- Use a mutation inside \`query\` to answer a what-if about a change ${d?"the lists under `meta` do not show":"before making it"}.`,"- Use `apply` only for what the user asked for."]:["- Nothing in this configurator can be changed through you. Say so when the user asks for a change."],"- When an operation fails, its `errors` say why and what to send instead."],...l?[["After a change","- A change is made only when the `apply` result has `committed: true`. Otherwise `errors` or `message` says what happened; without either, nothing changed. Never say a change was made when it was not.","- `sideEffects` names the major or unexpected things the configurator changed along with your change. Tell the user about them when committed; otherwise they describe what would happen. Smaller adjustments are not listed.","- A mutation returns the state after the change: use the ids and values it returned, not the ones you sent.",...r?["- When one mutation does the whole of what the user asked, use it instead of building the same change from several others."]:[]]]:[],...d?[["What can be done to an entity",`- \`meta\` lists what is possible right now: ${u.join(", ")}. Read the list before such a change and before telling the user what is available.`,`- You can select \`dryRun\` on ${[...s||o?["recipes"]:[],...i?["options"]:[]].join(" or ")} to look ahead and pick one that meets what the user asked for. It is optional before a change.`,"- Read the lists again after a change, unless their descriptions say they stay the same."]]:[],...h?[["Seeing the design","- `meta { screenshot(view: …) { image } }` renders an entity from one of the views its `<Type>ScreenshotView` lists. The picture follows the tool result.","- Take one when the user asks how the design looks, or when you are not sure something is laid out right: what sits where, what overlaps or lines up. Otherwise rely on the data.","- Each one costs tokens and blocks the user's configurator while it renders."]]:[],["The `[changes]` block","- Every user message starts with it: a glimpse of what the user did in the configurator since your last turn.",`- \`[changes: none]\`, or only ${c} lines: what you know still holds. Do not query it again.`,"- Other lines are a hint at what to read again: `A` added, `D` deleted, `M` modified with the fields. Text after `#` says what caused the line; `reset: undo/redo` says the user undid or redid changes.","- Read computed fields again when a listed change may affect them.","- `[changes: unavailable]` and `[changes: too many (n)]`: read again before relying on anything you read earlier.",...l?["- Your applied changes are not listed, except those waiting for user approval: they appear once approved."]:[]],["Reading the schema","- Take ids from results.",...(a.deletableTypes?.length??0)>0||o?["- The id of a deleted or replaced entity is gone and may later be given to another entity."]:[],`- A field whose name starts with \`_\` is computed: read it${l?", never write it":""}.`,"- Numbers are in the unit the field description names. Convert when the user uses another unit."],["Links","- You may link an entity of the current configuration when you speak about that very entity: `[the left burner](entity:CookingTop-1)`. It helps the user find it in the configurator.",...d?["- Whenever you name recipes or options you read from `meta`, in a list, a table or a sentence, link each one: `[Single gas burner](recipe:KitchenRange-1/top/gas_single)` or `[Oak](option:Cabinet-2/finishOptions/oak)`. The link shows the user its picture or color and its description, so never draw previews yourself. The target is the entity id, the recipe group id or the options field you read, and the key or value, each encoded as in a URL."]:[]],["Replies","- Write Markdown only, never HTML: the panel does not render it.","- An image, `![alt](path)`, is shown only when its path is relative.","- To make a warning or a key note stand out, write a GitHub alert: a blockquote whose first line is only `[!WARNING]` or `[!NOTE]`. Use it sparingly."],["Forms","- To ask the user something they answer by picking or typing, end your reply with a form: a fenced code block with the language `form`. It holds only elements, written as lowercase tags with string attributes, without Markdown or text.","- Every element takes `label`, the text the user sees; on a container or an input it also names the answer. An option or an input whose signature lists `value` takes it: an option sends it instead of its label, and an input starts with it.",'- A bare attribute in a signature takes any text, `name="<type>"` takes a value of that type written as text, such as `min="<number>"`, and `name="a|b"` takes one of the words listed.',"- Options can also stand on their own, outside a `choice` or `choices`.","- An element or attribute not listed here, or an element other than an option inside a `choice` or `choices`, makes the whole form fail.","- The answer is the user's next message. Each container or input gives a line `Label: value`, or the bare value without a label; the lines of a labelled container are indented by two spaces under it, a `choices` lists each picked option on its own line, and `—` marks what was left unanswered.",'- Example: `<choice label="Plinth"><reply label="Black" /><reply label="Oak" /></choice>` is answered with `Plinth: Oak`.',"- The chat shows the answer as the user's own message, so a `value` reads as natural words, never as an id, key or code. Give `value` only when the label alone would be unclear as an answer, and map the answer's labels back to ids yourself.",...(n=[...e,...a.formElements??[]],t.flatMap(([e,t])=>{let a=n.filter(({role:e})=>t.includes(e));return 0===a.length?[]:[`- ${e}:`,...a.map(e=>` - \`${formElementSignature(e)}\`: ${(({description:e,required:t=[]})=>0===t.length?e:`${e} Requires ${t.map(e=>`\`${e}\``).join(", ")}.`)(e)}`)]}))],...a.lenses?.declarations?[["Built-in fragments","- These fragments are already defined for every operation. Spread one by name on a field of its type, as in `field { ...FragmentName }`, instead of listing its fields.","- A fragment is a starting selection: add the other fields you need next to the spread, by name from the schema.","- Never define a fragment with one of these names.","",a.lenses.declarations]]:[]].map(e=>e.join("\n")).join("\n\n")};
@@ -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});
@@ -124,6 +124,7 @@ export declare const createDomainContextSelectors: (context: Context) => {
124
124
  getMigrate: () => import("../../index.js").MigrateFunction<import("../../index.js").DomainEntity<string>>;
125
125
  getActiveMode: () => DomainMode;
126
126
  getIsInitialized: () => boolean;
127
+ getIsViewMode: () => boolean;
127
128
  getComponentReaderIndexes: () => ComponentReaderIndexes;
128
129
  getStoreRuntimeDependencies: () => {
129
130
  componentReaderIndexes: ComponentReaderIndexes;
@@ -1 +1 @@
1
- import{createSelector as e}from"@salsita-ai/common/utils";import{Domain as t,createInitialDomainState as n}from"../../core/index.js";import{ActionSystem as o,DimensionSystem as i,NavigationSystem as a,RecipeCookerSystem as s,StoreSystem as r,UndoSystem as c}from"../../domain-context/index.js";import{BlenderProjections as l,CollisionProjections as m,CompositionProjections as d,ConstraintProjections as g,PositionProjections as f,ProjectedEntitiesProjections as u,SnappingProjections as p,ValidationProjections as y}from"../../projections/index.js";import{SketchingProjections as w}from"../../sketching/sketching-projections.js";import{requireAccessService as h}from"../access/index.js";import{prepareActionImplementations as S,prepareDomainExpressions as x}from"../spec/index.js";import{ComponentReader as C}from"./component-reader.js";import{DomainContext as D}from"./domain-context.js";let j=e.withTypes(),I=[],v={},P={role:"admin",data:v},M=e=>{if(null!==e)return e;throw Error("Cannot read the session role and data because the domain session context is not set. The session context is written into the domain runtime by the session lifecycle after authentication. Move this read into the loaded session lifecycle.")};export const createDomainContextSelectors=e=>{let{applicationType:A,getState:R,actions:E,specSelectors:T,accessSelectors:b,webComponentSelectors:$,domainDataSelectors:k,sessionContextSelectors:N,domainServicesSelectors:z,environmentSelectors:L,getExtensionSystems:V}=e,B="configurator"===A?T.selectConfiguratorSpec:T.selectAdminSpec,F="configurator"===A?b.selectConfiguratorRawAccessService:b.selectAdminRawAccessService,W=j.leaf(e=>e.domainContext[A]),_=j([W],e=>e.initializationContext),q=j([_],e=>{if(null===e)throw Error(`Domain lifecycle context is not available for ${A}! Read it from an active domain lifecycle.`);return e}),O=j([W],e=>e.executionMode),U=j([W],e=>e.isInitialized),G=j([B],e=>e.factory),H=j([B],e=>e.expressions),J=j([B],e=>e.actions),K=j([B],e=>e.actionImplementations),Q=j([J,K],S),X=j([B],e=>e.$entityReflections),Y=j([H,X],(e,t)=>x({expressions:e,$entityReflections:t})),Z=j([B],e=>e.modelVersion),ee=j([B],e=>e.aliasMap),et=j([B],e=>e.allowedRootEntityTypes),en=j([B],e=>e.entityReflections),eo=j([B],e=>e.migrate),ei=j([O,$.selectReadonly,F],(e,t,n)=>"finalize"===e?"finalize":h(A,n).accessInfo.viewMode||t?"read":"owner"),ea=j([F],e=>e?.configurationId??null),es="configurator"===A?N.selectSessionContext:j([],()=>P),er=j([es],e=>e?.role??null),ec=j([es],e=>e?.data??null),el=j([j.leaf(e=>e.loadedData)],e=>"configurator"===A?e.configuratorLoadedData:e.adminLoadedData),em=j([el],e=>e?.schemaIdentity??null),ed=j([el,G],(e,t)=>{if(null===e)return"coherent";let n=e.schemaIdentity;return void 0===n?"missing-stamp":n===t?"coherent":"schema-mismatch"}),eg=j([ea,er,ec,em,ed,F],(e,t,n,o,i,a)=>null===e||null===a||null===t||null===n||null===o||"coherent"!==i?null:{access:a.accessInfo.access,configurationId:e,role:t,schemaIdentity:o,sessionData:n}),ef=j([F,$.selectReadonly],(e,t)=>e?.accessInfo.viewMode===!0||t),eu=j([eg,_,U,ef],(e,t,n,o)=>{let i=null!==e&&null!==t&&n&&t.access===e.access&&t.configurationId===e.configurationId&&t.role===e.role&&t.schemaIdentity===e.schemaIdentity&&t.sessionData===e.sessionData;return{identity:e,isCurrent:i,isViewMode:o}}),ep=j([B],e=>e.componentOptics),ey=j([ep],e=>(e=>{let t=new Map,n=new Map,o=new Map,i=new Map;for(let n of e)for(let e of n.entityTypes){let o=t.get(e);o||(o=new Map,t.set(e,o));let a=o.get(n.componentType);if(a||(a=new Map,o.set(n.componentType,a)),a.has(n.instanceName))throw Error(`Component instance ${n.instanceName} already exists for type ${n.componentType.name} in entity ${e}. This is likely a bug in the component definition! InstanceNames must be unique within an entity and component.`);if(a.set(n.instanceName,n),"dynamic"===n.kind){let t=i.get(e);t||(t=new Map,i.set(e,t));let o=t.get(n.componentType)??[],a=o.find(e=>{var t;return t=n.instanceName,e.startsWith(`${t}_`)||t.startsWith(`${e}_`)});if(a)throw Error(`Cannot register dynamic component instance ${n.instanceName} for component ${n.componentType.name} on entity ${e} because it overlaps with dynamic instance ${a}. Rename one dynamic instance so compound names cannot be ambiguous.`);t.set(n.componentType,[...o,n.instanceName])}}for(let[e,i]of t.entries()){n.set(e,new Set(i.keys()));let t=new Map;for(let[n,a]of(o.set(e,t),i.entries()))t.set(n,new Set(a.keys()))}return{opticMap:t,allComponentTypes:n,allComponentInstanceNames:o,dynamicInstanceNames:i}})(e)),ew=j([ey,Y,et],(e,t,n)=>({componentReaderIndexes:e,domainExpressions:t,allowedRootEntityTypes:n})),eh=j([B],e=>e.navigationStates),eS=j([B],e=>e.viewStates),ex="configurator"===A?j([T.selectConfiguratorSpec],e=>e.toolStates):j([],()=>I),eC="configurator"===A?j([T.selectConfiguratorSpec],e=>e.exportStates):j([],()=>I),eD="configurator"===A?j([T.selectConfiguratorSpec],e=>e.createTransformers):j([],()=>void 0),ej=j([el],e=>{if(null===e)throw Error(`Loaded data is not available for ${A}! Loaded data is written after the configuration fetch succeeds and before the domain context initialization starts.`);return e}),eI=j([ej,G],(e,t)=>n(t.validateAndMigrateState(e.initialEntities,e.modelVersion),e.rootEntityType)),ev="configurator"===A?k.selectConfiguratorFrontendData:k.selectAdminFrontendData,eP="configurator"===A?k.selectConfiguratorBackendData:k.selectAdminBackendData,eM="configurator"===A?k.selectConfiguratorPublishedData:k.selectAdminPublishedData,eA="configurator"===A?j([N.selectSessionContext],e=>M(e).role):j([],()=>"admin"),eR="configurator"===A?j([N.selectSessionContext],e=>M(e).data):j([],()=>v),eE=j([ea,ei,eA,eR,ej,F],(e,t,n,o,i,a)=>({access:a?.accessInfo.access??null,configurationId:e,mode:t,role:n,schemaIdentity:i.schemaIdentity,sessionData:o})),eT=j([q],e=>e.mode),eb=j([q],e=>{let t=e.configurationId;if(null===t)throw Error(`Configuration id is not available for ${A}! Read it from an active interactive domain lifecycle.`);return t}),e$=j([q],e=>e.role),ek=j([q],e=>e.sessionData),eN=j([eT,e$,ek,ev,eP,eM,eo],(e,t,n,o,i,a,s)=>({mode:e,role:t,sessionData:n,frontendData:o,backendData:i,publishedData:a,migrate:s,domain:eL,componentReader:eV,positionProjections:eq,sketchingProjections:e_,collisionProjections:eO,constraintProjections:eG,snappingProjections:eU,projectedEntitiesProjections:eH})),ez={selectApplicationSpec:B,selectRawAccessService:F,selectDomainContextState:W,selectInitializationContext:_,selectActiveInitializationContext:q,selectExecutionMode:O,selectIsInitialized:U,selectFactory:G,selectSpecExpressions:H,select$SpecEntityReflections:X,selectDomainExpressions:Y,selectModelVersion:Z,selectAliasMap:ee,selectAllowedRootEntityTypes:et,selectEntityReflections:en,selectMigrate:eo,selectLatestMode:ei,selectLatestConfigurationId:ea,selectLatestSessionContext:es,selectLatestRoleOrNull:er,selectLatestSessionDataOrNull:ec,selectLatestSchemaIdentity:em,selectSchemaCoherence:ed,selectInitializationIdentity:eg,selectIsViewMode:ef,selectInitializationState:eu,selectComponentOptics:ep,selectComponentReaderIndexes:ey,selectStoreRuntimeDependencies:ew,selectNavigationStates:eh,selectViewStates:eS,selectToolStates:ex,selectExportStates:eC,selectCreateTransformers:eD,selectLatestLoadedData:el,selectLoadedData:ej,selectInitialDomainState:eI,selectFrontendData:ev,selectBackendData:eP,selectPublishedData:eM,selectLatestRole:eA,selectLatestSessionData:eR,selectNextInitializationContext:eE,selectActiveMode:eT,selectActiveConfigurationId:eb,selectActiveRole:e$,selectActiveSessionData:ek,selectExpressionContext:eN,getInitializationContext:()=>_(R()),getInitializationState:()=>eu(R()),getNextInitializationContext:()=>eE(R()),getLatestLoadedData:()=>el(R()),getSchemaCoherence:()=>ed(R()),getActiveConfigurationId:()=>eb(R()),getFactory:()=>G(R()),getDomainExpressions:()=>Y(R()),getActionDefinitions:()=>J(R()),getActionImplementations:()=>Q(R()),getModelVersion:()=>Z(R()),getAliasMap:()=>ee(R()),getAllowedRootEntityTypes:()=>et(R()),getEntityReflections:()=>en(R()),getMigrate:()=>eo(R()),getActiveMode:()=>eT(R()),getIsInitialized:()=>U(R()),getComponentReaderIndexes:()=>ey(R()),getStoreRuntimeDependencies:()=>ew(R()),getNavigationStates:()=>eh(R()),getViewStates:()=>eS(R()),getToolStates:()=>ex(R()),getExportStates:()=>eC(R()),getCreateTransformers:()=>eD(R()),getLoadedData:()=>ej(R()),getInitialDomainState:()=>eI(R()),getFrontendData:()=>ev(R()),getBackendData:()=>eP(R()),getPublishedData:()=>eM(R()),getActiveRole:()=>e$(R()),getActiveSessionData:()=>ek(R()),getDomain:()=>eL,getComponentReader:()=>eV,getCompositionProjections:()=>eB,getDimensionSystem:()=>eF,getValidationProjections:()=>eW,getSketchingProjections:()=>e_,getPositionProjections:()=>eq,getCollisionProjections:()=>eO,getSnappingProjections:()=>eU,getConstraintProjections:()=>eG,getProjectedEntitiesProjections:()=>eH,getStoreSystem:()=>eJ,getNavigationSystem:()=>eK,getUndoSystem:()=>eQ,getRecipeCookerSystem:()=>eX,getActionSystem:()=>eY,getBlenderProjections:()=>eZ,getExpressionContext:()=>eN(R()),getDomainSystems:function(){return e0},getDomainContext:function(){return e1}},eL=new t({selectors:ez}),eV=new C({selectors:ez}),eB=new d({selectors:ez}),eF=new i({selectors:ez}),eW=new y({selectors:ez}),e_=new w({selectors:ez}),eq=new f({selectors:ez}),eO=new m({selectors:ez}),eU=new p({selectors:ez}),eG=new g({selectors:ez}),eH=new u({selectors:ez}),eJ=new r({selectors:ez,domainServicesSelectors:z,environmentSelectors:L}),eK=new a({selectors:ez,domainServicesSelectors:z}),eQ=new c({selectors:ez}),eX=new s({selectors:ez}),eY=new o({selectors:ez}),eZ=new l({selectors:ez,domainServicesSelectors:z}),e0={domainContextSelectors:ez,domain:eL,componentReader:eV,compositionProjections:eB,blenderProjections:eZ,validationProjections:eW,storeSystem:eJ,navigationSystem:eK,dimensionSystem:eF,undoSystem:eQ,recipeCooker:eX,actionSystem:eY,sketchingProjections:e_,collisionProjections:eO,positionProjections:eq,snappingProjections:eU,projectedEntitiesProjections:eH,constraintProjections:eG},e1=new D({selectors:ez,actions:E,getExtensionSystems:V});return ez};
1
+ import{createSelector as e}from"@salsita-ai/common/utils";import{Domain as t,createInitialDomainState as n}from"../../core/index.js";import{ActionSystem as o,DimensionSystem as i,NavigationSystem as a,RecipeCookerSystem as s,StoreSystem as r,UndoSystem as c}from"../../domain-context/index.js";import{BlenderProjections as l,CollisionProjections as d,CompositionProjections as m,ConstraintProjections as g,PositionProjections as f,ProjectedEntitiesProjections as u,SnappingProjections as p,ValidationProjections as y}from"../../projections/index.js";import{SketchingProjections as w}from"../../sketching/sketching-projections.js";import{requireAccessService as h}from"../access/index.js";import{prepareActionImplementations as S,prepareDomainExpressions as x}from"../spec/index.js";import{ComponentReader as C}from"./component-reader.js";import{DomainContext as D}from"./domain-context.js";let j=e.withTypes(),I=[],v={},P={role:"admin",data:v},M=e=>{if(null!==e)return e;throw Error("Cannot read the session role and data because the domain session context is not set. The session context is written into the domain runtime by the session lifecycle after authentication. Move this read into the loaded session lifecycle.")};export const createDomainContextSelectors=e=>{let{applicationType:A,getState:R,actions:E,specSelectors:T,accessSelectors:b,webComponentSelectors:$,domainDataSelectors:k,sessionContextSelectors:N,domainServicesSelectors:z,environmentSelectors:L,getExtensionSystems:V}=e,B="configurator"===A?T.selectConfiguratorSpec:T.selectAdminSpec,F="configurator"===A?b.selectConfiguratorRawAccessService:b.selectAdminRawAccessService,W=j.leaf(e=>e.domainContext[A]),_=j([W],e=>e.initializationContext),q=j([_],e=>{if(null===e)throw Error(`Domain lifecycle context is not available for ${A}! Read it from an active domain lifecycle.`);return e}),O=j([W],e=>e.executionMode),U=j([W],e=>e.isInitialized),G=j([B],e=>e.factory),H=j([B],e=>e.expressions),J=j([B],e=>e.actions),K=j([B],e=>e.actionImplementations),Q=j([J,K],S),X=j([B],e=>e.$entityReflections),Y=j([H,X],(e,t)=>x({expressions:e,$entityReflections:t})),Z=j([B],e=>e.modelVersion),ee=j([B],e=>e.aliasMap),et=j([B],e=>e.allowedRootEntityTypes),en=j([B],e=>e.entityReflections),eo=j([B],e=>e.migrate),ei=j([O,$.selectReadonly,F],(e,t,n)=>"finalize"===e?"finalize":h(A,n).accessInfo.viewMode||t?"read":"owner"),ea=j([F],e=>e?.configurationId??null),es="configurator"===A?N.selectSessionContext:j([],()=>P),er=j([es],e=>e?.role??null),ec=j([es],e=>e?.data??null),el=j([j.leaf(e=>e.loadedData)],e=>"configurator"===A?e.configuratorLoadedData:e.adminLoadedData),ed=j([el],e=>e?.schemaIdentity??null),em=j([el,G],(e,t)=>{if(null===e)return"coherent";let n=e.schemaIdentity;return void 0===n?"missing-stamp":n===t?"coherent":"schema-mismatch"}),eg=j([ea,er,ec,ed,em,F],(e,t,n,o,i,a)=>null===e||null===a||null===t||null===n||null===o||"coherent"!==i?null:{access:a.accessInfo.access,configurationId:e,role:t,schemaIdentity:o,sessionData:n}),ef=j([F,$.selectReadonly],(e,t)=>e?.accessInfo.viewMode===!0||t),eu=j([eg,_,U,ef],(e,t,n,o)=>{let i=null!==e&&null!==t&&n&&t.access===e.access&&t.configurationId===e.configurationId&&t.role===e.role&&t.schemaIdentity===e.schemaIdentity&&t.sessionData===e.sessionData;return{identity:e,isCurrent:i,isViewMode:o}}),ep=j([B],e=>e.componentOptics),ey=j([ep],e=>(e=>{let t=new Map,n=new Map,o=new Map,i=new Map;for(let n of e)for(let e of n.entityTypes){let o=t.get(e);o||(o=new Map,t.set(e,o));let a=o.get(n.componentType);if(a||(a=new Map,o.set(n.componentType,a)),a.has(n.instanceName))throw Error(`Component instance ${n.instanceName} already exists for type ${n.componentType.name} in entity ${e}. This is likely a bug in the component definition! InstanceNames must be unique within an entity and component.`);if(a.set(n.instanceName,n),"dynamic"===n.kind){let t=i.get(e);t||(t=new Map,i.set(e,t));let o=t.get(n.componentType)??[],a=o.find(e=>{var t;return t=n.instanceName,e.startsWith(`${t}_`)||t.startsWith(`${e}_`)});if(a)throw Error(`Cannot register dynamic component instance ${n.instanceName} for component ${n.componentType.name} on entity ${e} because it overlaps with dynamic instance ${a}. Rename one dynamic instance so compound names cannot be ambiguous.`);t.set(n.componentType,[...o,n.instanceName])}}for(let[e,i]of t.entries()){n.set(e,new Set(i.keys()));let t=new Map;for(let[n,a]of(o.set(e,t),i.entries()))t.set(n,new Set(a.keys()))}return{opticMap:t,allComponentTypes:n,allComponentInstanceNames:o,dynamicInstanceNames:i}})(e)),ew=j([ey,Y,et],(e,t,n)=>({componentReaderIndexes:e,domainExpressions:t,allowedRootEntityTypes:n})),eh=j([B],e=>e.navigationStates),eS=j([B],e=>e.viewStates),ex="configurator"===A?j([T.selectConfiguratorSpec],e=>e.toolStates):j([],()=>I),eC="configurator"===A?j([T.selectConfiguratorSpec],e=>e.exportStates):j([],()=>I),eD="configurator"===A?j([T.selectConfiguratorSpec],e=>e.createTransformers):j([],()=>void 0),ej=j([el],e=>{if(null===e)throw Error(`Loaded data is not available for ${A}! Loaded data is written after the configuration fetch succeeds and before the domain context initialization starts.`);return e}),eI=j([ej,G],(e,t)=>n(t.validateAndMigrateState(e.initialEntities,e.modelVersion),e.rootEntityType)),ev="configurator"===A?k.selectConfiguratorFrontendData:k.selectAdminFrontendData,eP="configurator"===A?k.selectConfiguratorBackendData:k.selectAdminBackendData,eM="configurator"===A?k.selectConfiguratorPublishedData:k.selectAdminPublishedData,eA="configurator"===A?j([N.selectSessionContext],e=>M(e).role):j([],()=>"admin"),eR="configurator"===A?j([N.selectSessionContext],e=>M(e).data):j([],()=>v),eE=j([ea,ei,eA,eR,ej,F],(e,t,n,o,i,a)=>({access:a?.accessInfo.access??null,configurationId:e,mode:t,role:n,schemaIdentity:i.schemaIdentity,sessionData:o})),eT=j([q],e=>e.mode),eb=j([q],e=>{let t=e.configurationId;if(null===t)throw Error(`Configuration id is not available for ${A}! Read it from an active interactive domain lifecycle.`);return t}),e$=j([q],e=>e.role),ek=j([q],e=>e.sessionData),eN=j([eT,e$,ek,ev,eP,eM,eo],(e,t,n,o,i,a,s)=>({mode:e,role:t,sessionData:n,frontendData:o,backendData:i,publishedData:a,migrate:s,domain:eL,componentReader:eV,positionProjections:eq,sketchingProjections:e_,collisionProjections:eO,constraintProjections:eG,snappingProjections:eU,projectedEntitiesProjections:eH})),ez={selectApplicationSpec:B,selectRawAccessService:F,selectDomainContextState:W,selectInitializationContext:_,selectActiveInitializationContext:q,selectExecutionMode:O,selectIsInitialized:U,selectFactory:G,selectSpecExpressions:H,select$SpecEntityReflections:X,selectDomainExpressions:Y,selectModelVersion:Z,selectAliasMap:ee,selectAllowedRootEntityTypes:et,selectEntityReflections:en,selectMigrate:eo,selectLatestMode:ei,selectLatestConfigurationId:ea,selectLatestSessionContext:es,selectLatestRoleOrNull:er,selectLatestSessionDataOrNull:ec,selectLatestSchemaIdentity:ed,selectSchemaCoherence:em,selectInitializationIdentity:eg,selectIsViewMode:ef,selectInitializationState:eu,selectComponentOptics:ep,selectComponentReaderIndexes:ey,selectStoreRuntimeDependencies:ew,selectNavigationStates:eh,selectViewStates:eS,selectToolStates:ex,selectExportStates:eC,selectCreateTransformers:eD,selectLatestLoadedData:el,selectLoadedData:ej,selectInitialDomainState:eI,selectFrontendData:ev,selectBackendData:eP,selectPublishedData:eM,selectLatestRole:eA,selectLatestSessionData:eR,selectNextInitializationContext:eE,selectActiveMode:eT,selectActiveConfigurationId:eb,selectActiveRole:e$,selectActiveSessionData:ek,selectExpressionContext:eN,getInitializationContext:()=>_(R()),getInitializationState:()=>eu(R()),getNextInitializationContext:()=>eE(R()),getLatestLoadedData:()=>el(R()),getSchemaCoherence:()=>em(R()),getActiveConfigurationId:()=>eb(R()),getFactory:()=>G(R()),getDomainExpressions:()=>Y(R()),getActionDefinitions:()=>J(R()),getActionImplementations:()=>Q(R()),getModelVersion:()=>Z(R()),getAliasMap:()=>ee(R()),getAllowedRootEntityTypes:()=>et(R()),getEntityReflections:()=>en(R()),getMigrate:()=>eo(R()),getActiveMode:()=>eT(R()),getIsInitialized:()=>U(R()),getIsViewMode:()=>ef(R()),getComponentReaderIndexes:()=>ey(R()),getStoreRuntimeDependencies:()=>ew(R()),getNavigationStates:()=>eh(R()),getViewStates:()=>eS(R()),getToolStates:()=>ex(R()),getExportStates:()=>eC(R()),getCreateTransformers:()=>eD(R()),getLoadedData:()=>ej(R()),getInitialDomainState:()=>eI(R()),getFrontendData:()=>ev(R()),getBackendData:()=>eP(R()),getPublishedData:()=>eM(R()),getActiveRole:()=>e$(R()),getActiveSessionData:()=>ek(R()),getDomain:()=>eL,getComponentReader:()=>eV,getCompositionProjections:()=>eB,getDimensionSystem:()=>eF,getValidationProjections:()=>eW,getSketchingProjections:()=>e_,getPositionProjections:()=>eq,getCollisionProjections:()=>eO,getSnappingProjections:()=>eU,getConstraintProjections:()=>eG,getProjectedEntitiesProjections:()=>eH,getStoreSystem:()=>eJ,getNavigationSystem:()=>eK,getUndoSystem:()=>eQ,getRecipeCookerSystem:()=>eX,getActionSystem:()=>eY,getBlenderProjections:()=>eZ,getExpressionContext:()=>eN(R()),getDomainSystems:function(){return e0},getDomainContext:function(){return e1}},eL=new t({selectors:ez}),eV=new C({selectors:ez}),eB=new m({selectors:ez}),eF=new i({selectors:ez}),eW=new y({selectors:ez}),e_=new w({selectors:ez}),eq=new f({selectors:ez}),eO=new d({selectors:ez}),eU=new p({selectors:ez}),eG=new g({selectors:ez}),eH=new u({selectors:ez}),eJ=new r({selectors:ez,domainServicesSelectors:z,environmentSelectors:L}),eK=new a({selectors:ez,domainServicesSelectors:z}),eQ=new c({selectors:ez}),eX=new s({selectors:ez}),eY=new o({selectors:ez}),eZ=new l({selectors:ez,domainServicesSelectors:z}),e0={domainContextSelectors:ez,domain:eL,componentReader:eV,compositionProjections:eB,blenderProjections:eZ,validationProjections:eW,storeSystem:eJ,navigationSystem:eK,dimensionSystem:eF,undoSystem:eQ,recipeCooker:eX,actionSystem:eY,sketchingProjections:e_,collisionProjections:eO,positionProjections:eq,snappingProjections:eU,projectedEntitiesProjections:eH,constraintProjections:eG},e1=new D({selectors:ez,actions:E,getExtensionSystems:V});return ez};