@salsita-ai/sdk 0.50.0-develop.10b1931917 → 0.50.0-develop.1162eef277

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 (279) hide show
  1. package/README.md +11 -11
  2. package/dist/application-spec/generate-application/code/common/index.d.ts +1 -0
  3. package/dist/application-spec/generate-application/code/common/index.js +1 -1
  4. package/dist/application-spec/generate-application/code/common/project-module-list.d.ts +8 -0
  5. package/dist/application-spec/generate-application/code/common/project-module-list.js +3 -0
  6. package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
  7. package/dist/application-spec/generate-application/code/project-scaffolding.js +2 -2
  8. package/dist/application-spec/generate-application/code/templates/admin-domain-code.d.ts +1 -2
  9. package/dist/application-spec/generate-application/code/templates/admin-domain-code.js +6 -14
  10. package/dist/application-spec/generate-application/code/templates/admin-frontend-code.d.ts +1 -2
  11. package/dist/application-spec/generate-application/code/templates/admin-frontend-code.js +4 -4
  12. package/dist/application-spec/generate-application/code/templates/configurator-domain-code.d.ts +1 -2
  13. package/dist/application-spec/generate-application/code/templates/configurator-domain-code.js +7 -16
  14. package/dist/application-spec/generate-application/code/templates/configurator-frontend-code.d.ts +1 -2
  15. package/dist/application-spec/generate-application/code/templates/configurator-frontend-code.js +7 -9
  16. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-assistant.d.ts +2 -2
  17. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-assistant.js +1 -1
  18. package/dist/application-spec/generate-application/code/templates/domain-spec.js +4 -4
  19. package/dist/application-spec/generate-application/code/templates/domain.js +3 -3
  20. package/dist/application-spec/generate-application/code/templates/index.d.ts +1 -0
  21. package/dist/application-spec/generate-application/code/templates/index.js +1 -1
  22. package/dist/application-spec/generate-application/code/templates/skills/agents-md.js +1 -1
  23. package/dist/application-spec/generate-application/code/templates/skills/phoenix-cli-skill.js +1 -1
  24. package/dist/application-spec/generate-application/code/templates/skills/phoenix-create-configurator-skill.js +43 -13
  25. package/dist/application-spec/generate-application/code/templates/skills/phoenix-feedback-skill.js +39 -16
  26. package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js +2 -2
  27. package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill.js +1 -1
  28. package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.d.ts +1 -0
  29. package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.js +6 -0
  30. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +30 -3
  31. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +19 -5
  32. package/dist/application-spec/generate-application/code/templates/webhook-builders.js +8 -4
  33. package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.d.ts +4 -3
  34. package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.js +1 -1
  35. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.d.ts +3 -8
  36. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.js +1 -1
  37. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +9 -43
  38. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
  39. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-server-settings.d.ts +2 -2
  40. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant.d.ts +5 -21
  41. package/dist/client/phoenix-api.d.ts +58 -30
  42. package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
  43. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +158 -13
  44. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
  45. package/dist/configurator/application-runtime/extensions/systems/assistant-system/change-recorder.d.ts +85 -0
  46. package/dist/configurator/application-runtime/extensions/systems/assistant-system/change-recorder.js +1 -0
  47. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +8 -3
  48. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -1
  49. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.d.ts +4 -0
  50. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.js +1 -1
  51. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +16 -1
  52. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
  53. package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.d.ts +9 -0
  54. package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.js +1 -0
  55. package/dist/configurator/application-runtime/extensions/systems/index.d.ts +1 -1
  56. package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.d.ts +2 -0
  57. package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.js +1 -1
  58. package/dist/configurator/common/frontend-analytics.d.ts +21 -21
  59. package/dist/configurator/index.d.ts +0 -1
  60. package/dist/configurator/index.js +1 -1
  61. package/dist/configurator/pages/LoadedConfiguratorDetailPage.js +1 -1
  62. package/dist/configurator/scene/scene-analytics/scene-analytics.d.ts +2 -2
  63. package/dist/configurator/ui/assistant/AssistantChips.d.ts +11 -0
  64. package/dist/configurator/ui/assistant/AssistantChips.js +1 -0
  65. package/dist/configurator/ui/assistant/AssistantComposer.d.ts +6 -0
  66. package/dist/configurator/ui/assistant/AssistantComposer.js +1 -0
  67. package/dist/configurator/ui/assistant/AssistantMarkdown.d.ts +7 -0
  68. package/dist/configurator/ui/assistant/AssistantMarkdown.js +1 -0
  69. package/dist/configurator/ui/assistant/AssistantPanel.d.ts +11 -0
  70. package/dist/configurator/ui/assistant/AssistantPanel.js +1 -0
  71. package/dist/configurator/ui/assistant/AssistantThread.d.ts +6 -0
  72. package/dist/configurator/ui/assistant/AssistantThread.js +1 -0
  73. package/dist/configurator/ui/assistant/assistant-failure.d.ts +18 -0
  74. package/dist/configurator/ui/assistant/assistant-failure.js +1 -0
  75. package/dist/configurator/ui/assistant/index.d.ts +2 -0
  76. package/dist/configurator/ui/assistant/index.js +1 -0
  77. package/dist/configurator/ui/assistant/streamed-markdown.d.ts +6 -0
  78. package/dist/configurator/ui/assistant/streamed-markdown.js +2 -0
  79. package/dist/configurator/ui/assistant/theme.d.ts +2 -0
  80. package/dist/configurator/ui/assistant/theme.js +1 -0
  81. package/dist/configurator/ui/assistant/thread-items.d.ts +37 -0
  82. package/dist/configurator/ui/assistant/thread-items.js +1 -0
  83. package/dist/configurator/ui/assistant/tool-chip.d.ts +44 -0
  84. package/dist/configurator/ui/assistant/tool-chip.js +1 -0
  85. package/dist/configurator/ui/assistant/use-follow-stream.d.ts +17 -0
  86. package/dist/configurator/ui/assistant/use-follow-stream.js +1 -0
  87. package/dist/configurator/ui/assistant/use-is-assistant-panel-open.d.ts +5 -0
  88. package/dist/configurator/ui/assistant/use-is-assistant-panel-open.js +1 -0
  89. package/dist/configurator/ui/configurator-layout/universal/DesktopLayout.js +5 -5
  90. package/dist/configurator/ui/configurator-layout/universal/MobileLayout.d.ts +2 -0
  91. package/dist/configurator/ui/configurator-layout/universal/MobileLayout.js +4 -4
  92. package/dist/configurator/ui/legacy/mobile-controls/MobileControls.d.ts +1 -1
  93. package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.d.ts +10 -0
  94. package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.js +1 -0
  95. package/dist/configurator/ui/phoenix-layout-elements/index.d.ts +1 -0
  96. package/dist/configurator/ui/phoenix-layout-elements/index.js +1 -1
  97. package/dist/docs/complex-use-cases/filtered-controls-with-fix-dialog.mdx +84 -98
  98. package/dist/docs/complex-use-cases/navigation-reset-selection.mdx +18 -12
  99. package/dist/docs/index.json +1 -1
  100. package/dist/docs/layouts/custom-price.mdx +14 -16
  101. package/dist/docs/layouts/sidebar/tabs.mdx +24 -21
  102. package/dist/docs/layouts/toolbar.mdx +6 -0
  103. package/dist/docs/other-features/domain-actions.mdx +1 -1
  104. package/dist/docs/other-features/side-effects.mdx +68 -34
  105. package/dist/docs/other-features/transformers.mdx +1 -1
  106. package/dist/docs/phoenix/admin.mdx +11 -26
  107. package/dist/docs/phoenix/finalization.mdx +1 -1
  108. package/dist/docs/phoenix/integration/headless-mode-external.mdx +5 -5
  109. package/dist/docs/phoenix/integration/widget-mode-external.mdx +5 -5
  110. package/dist/docs/phoenix/localization.mdx +3 -22
  111. package/dist/docs/phoenix/phoenix-cli.mdx +96 -13
  112. package/dist/docs/phoenix/project-structure.mdx +9 -2
  113. package/dist/docs/phoenix/sdk-builder-workflow.mdx +7 -5
  114. package/dist/docs/recipes-and-delete/recipe-hierarchy-selection.mdx +15 -13
  115. package/dist/docs/relations/hierarchy.mdx +13 -2
  116. package/dist/domain/actions/action-factory.d.ts +3 -2
  117. package/dist/domain/application/application-config.d.ts +25 -75
  118. package/dist/domain/application/assistant/assistant-manifest.d.ts +61 -0
  119. package/dist/domain/application/assistant/assistant-manifest.js +1 -0
  120. package/dist/domain/application/assistant/assistant-resolved-manifest.d.ts +95 -0
  121. package/dist/domain/application/assistant/assistant-resolved-manifest.js +1 -0
  122. package/dist/domain/application/assistant/assistant-value-type.d.ts +9 -0
  123. package/dist/domain/application/assistant/assistant-value-type.js +1 -0
  124. package/dist/domain/application/assistant/build-assistant-manifest.d.ts +4 -0
  125. package/dist/domain/application/assistant/build-assistant-manifest.js +1 -0
  126. package/dist/{phoenix/application-spec → domain/application/assistant}/generate-assistant-prompt.d.ts +6 -5
  127. package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -0
  128. package/dist/domain/application/assistant/index.d.ts +4 -0
  129. package/dist/domain/application/assistant/index.js +1 -0
  130. package/dist/domain/application/assistant-field-options.d.ts +1 -1
  131. package/dist/domain/application/assistant-mutations.d.ts +1 -1
  132. package/dist/domain/application/assistant-recipe-groups.d.ts +1 -1
  133. package/dist/domain/application/configurator-builder.d.ts +33 -18
  134. package/dist/domain/application/configurator-builder.js +1 -1
  135. package/dist/domain/application/element-registration.d.ts +5 -0
  136. package/dist/domain/application/element-registration.js +1 -1
  137. package/dist/domain/application/handler-registration.d.ts +5 -0
  138. package/dist/domain/application/handler-registration.js +1 -1
  139. package/dist/domain/application/index.d.ts +5 -4
  140. package/dist/domain/application/index.js +1 -1
  141. package/dist/domain/application/resolve-imported-transformers.d.ts +11 -1
  142. package/dist/domain/application/resolve-imported-transformers.js +1 -1
  143. package/dist/domain/components/domain-component-optic.d.ts +3 -0
  144. package/dist/domain/components/domain-component-optic.js +2 -2
  145. package/dist/domain/components/updates.d.ts +16 -0
  146. package/dist/domain/core/action.d.ts +1 -1
  147. package/dist/domain/domain-builder.d.ts +10 -1
  148. package/dist/domain/domain-builder.js +1 -1
  149. package/dist/domain/domain-context/index.d.ts +1 -1
  150. package/dist/domain/domain-context/store-system/store-system.js +1 -1
  151. package/dist/domain/domain-context/transformers/chain-builder.d.ts +1 -1
  152. package/dist/domain/domain-runtime/domain-runtime.d.ts +4 -4
  153. package/dist/domain/domain-runtime/spec/initialize.js +1 -1
  154. package/dist/domain/domain-runtime/spec/selectors.d.ts +2 -2
  155. package/dist/domain/domain-runtime/spec/selectors.js +1 -1
  156. package/dist/domain/domain-runtime/spec/types.d.ts +3 -3
  157. package/dist/domain/index.d.ts +3 -2
  158. package/dist/domain/index.js +1 -1
  159. package/dist/domain/invariants/invariants.d.ts +9 -0
  160. package/dist/domain/invariants/invariants.js +1 -1
  161. package/dist/domain/mocks/create-mock-domain-runtime.d.ts +3 -3
  162. package/dist/domain/mocks/create-mock-domain-runtime.js +1 -1
  163. package/dist/domain/project-modules/index.d.ts +1 -0
  164. package/dist/domain/project-modules/index.js +1 -0
  165. package/dist/domain/project-modules/project-modules.d.ts +41 -0
  166. package/dist/domain/project-modules/project-modules.js +1 -0
  167. package/dist/domain/system-components/common/dimension-indicator-schema.d.ts +1 -1
  168. package/dist/domain/system-components/common/dimension-indicator-schema.js +1 -1
  169. package/dist/domain/system-components/phoenix-layout-elements/assistant-toolbar-button.d.ts +44 -0
  170. package/dist/domain/system-components/phoenix-layout-elements/assistant-toolbar-button.js +1 -0
  171. package/dist/domain/system-components/phoenix-layout-elements/index.d.ts +1 -0
  172. package/dist/domain/system-components/phoenix-layout-elements/index.js +1 -1
  173. package/dist/domain/system-components/phoenix-layout-elements/phoenix-layout-element.d.ts +2 -1
  174. package/dist/domain/system-components/phoenix-layout-elements/phoenix-layout-element.js +1 -1
  175. package/dist/editor/Editor.js +1 -1
  176. package/dist/editor/domain-editors/use-implementation-files.d.ts +7 -6
  177. package/dist/editor/domain-editors/use-implementation-files.js +1 -1
  178. package/dist/editor/graphql/GraphQLPanel.js +1 -1
  179. package/dist/editor/variants/VariantAnswerFooter.d.ts +17 -0
  180. package/dist/editor/variants/VariantAnswerFooter.js +1 -0
  181. package/dist/editor/variants/VariantPreviewHandler.d.ts +6 -0
  182. package/dist/editor/variants/VariantPreviewHandler.js +1 -0
  183. package/dist/editor/variants/variant-preview-styles.d.ts +49 -0
  184. package/dist/editor/variants/variant-preview-styles.js +1 -0
  185. package/dist/i18n/locales/cs/messages.js +1 -1
  186. package/dist/i18n/locales/da/messages.js +1 -1
  187. package/dist/i18n/locales/de/messages.js +1 -1
  188. package/dist/i18n/locales/de-AT/messages.js +1 -1
  189. package/dist/i18n/locales/en/messages.js +1 -1
  190. package/dist/i18n/locales/en-AU/messages.js +1 -1
  191. package/dist/i18n/locales/en-GB/messages.js +1 -1
  192. package/dist/i18n/locales/es/messages.js +1 -1
  193. package/dist/i18n/locales/fr/messages.js +1 -1
  194. package/dist/i18n/locales/hu/messages.js +1 -1
  195. package/dist/i18n/locales/it/messages.js +1 -1
  196. package/dist/i18n/locales/nl/messages.js +1 -1
  197. package/dist/i18n/locales/pl/messages.js +1 -1
  198. package/dist/i18n/locales/pt/messages.js +1 -1
  199. package/dist/i18n/locales/ro/messages.js +1 -1
  200. package/dist/i18n/locales/sk/messages.js +1 -1
  201. package/dist/i18n/locales/tr/messages.js +1 -1
  202. package/dist/legacy/domain-cli/gen/configurator-builder.js +21 -8
  203. package/dist/legacy/domain-cli/utils/cache.d.ts +1 -1
  204. package/dist/legacy/domain-cli/utils/cache.js +1 -1
  205. package/dist/legacy/domain-spec/__generated/domain-schema.d.ts +6 -0
  206. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-admin.js +18 -19
  207. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-configurator.js +15 -16
  208. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-admin.js +22 -23
  209. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-configurator.js +15 -16
  210. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/generator-shared.d.ts +7 -2
  211. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/generator-shared.js +8 -12
  212. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/index.d.ts +1 -1
  213. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/index.js +1 -1
  214. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/webhook-builders.js +7 -7
  215. package/dist/phoenix/application-spec/application-spec-builder.js +1 -1
  216. package/dist/phoenix/application-spec/resolve-deployment-data.d.ts +4 -3
  217. package/dist/phoenix/application-spec/resolve-deployment-data.js +2 -2
  218. package/dist/phoenix/cli.js +1 -1
  219. package/dist/phoenix/commands/deploy.js +2 -2
  220. package/dist/phoenix/commands/dev.js +5 -5
  221. package/dist/phoenix/commands/feedback.d.ts +2 -1
  222. package/dist/phoenix/commands/feedback.js +1 -1
  223. package/dist/phoenix/commands/index.d.ts +1 -0
  224. package/dist/phoenix/commands/index.js +1 -1
  225. package/dist/phoenix/commands/prepare-deployment-command.js +2 -2
  226. package/dist/phoenix/commands/prepare-local-environment-command.js +1 -1
  227. package/dist/phoenix/commands/story-dev.js +2 -2
  228. package/dist/phoenix/commands/variants.d.ts +35 -0
  229. package/dist/phoenix/commands/variants.js +1 -0
  230. package/dist/phoenix/editor-server/commands-router.d.ts +68 -1
  231. package/dist/phoenix/editor-server/commands-router.js +1 -1
  232. package/dist/phoenix/editor-server/editor-router.d.ts +65 -0
  233. package/dist/phoenix/editor-server/editor-server.d.ts +3 -3
  234. package/dist/phoenix/editor-server/editor-server.js +1 -1
  235. package/dist/phoenix/editor-server/protocol.d.ts +1 -0
  236. package/dist/phoenix/editor-server/spec-router.js +1 -1
  237. package/dist/phoenix/editor-server/trpc.d.ts +3 -0
  238. package/dist/phoenix/services/application-spec-project-watcher.d.ts +13 -2
  239. package/dist/phoenix/services/application-spec-project-watcher.js +3 -3
  240. package/dist/phoenix/services/index.d.ts +4 -0
  241. package/dist/phoenix/services/index.js +1 -1
  242. package/dist/phoenix/services/phoenix-application.d.ts +21 -0
  243. package/dist/phoenix/services/phoenix-application.js +1 -0
  244. package/dist/phoenix/services/phoenix-store.d.ts +48 -0
  245. package/dist/phoenix/services/phoenix-store.js +1 -0
  246. package/dist/phoenix/services/phx-variant-previews-plugin.d.ts +9 -0
  247. package/dist/phoenix/services/phx-variant-previews-plugin.js +1 -0
  248. package/dist/phoenix/services/prepare-development-environment.js +1 -1
  249. package/dist/phoenix/services/variant-file-session.d.ts +36 -0
  250. package/dist/phoenix/services/variant-file-session.js +1 -0
  251. package/dist/phoenix/services/variant-preview-service.d.ts +80 -0
  252. package/dist/phoenix/services/variant-preview-service.js +1 -0
  253. package/dist/phoenix/services/vite-config.js +1 -1
  254. package/dist/react-sdk/application-runtime/common-services/analytics/analytics-service.d.ts +2 -2
  255. package/dist/react-sdk/application-runtime/common-services/analytics/domain-controls-analytics.d.ts +21 -21
  256. package/dist/react-sdk/application-runtime/hooks/data/use-published-data.d.ts +1 -1
  257. package/dist/react-sdk/application-runtime/hooks/use-domain-application-props.d.ts +5 -2
  258. package/dist/react-sdk/application-runtime/hooks/use-spec.d.ts +1 -1
  259. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.d.ts +1 -1
  260. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.js +1 -1
  261. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +4 -4
  262. package/dist/ui-sdk/common/use-viewport-size.d.ts +4 -1
  263. package/dist/ui-sdk/common/use-viewport-size.js +1 -1
  264. package/dist/ui-sdk/components/mobile-controls/index.d.ts +1 -1
  265. package/dist/ui-sdk/theme/types.d.ts +4 -0
  266. package/dist/webhook/builders/common.d.ts +3 -0
  267. package/dist/webhook/builders/webhook-builder.d.ts +1 -1
  268. package/dist/webhook/builders/webhook-builder.js +1 -1
  269. package/package.json +5 -8
  270. package/schema/domain-spec.json +24 -0
  271. package/dist/configurator/assistant/index.d.ts +0 -1
  272. package/dist/configurator/assistant/index.js +0 -1
  273. package/dist/configurator/assistant/use-assistant-chat.d.ts +0 -20
  274. package/dist/configurator/assistant/use-assistant-chat.js +0 -1
  275. package/dist/extras/assistant/AssistantChat.d.ts +0 -6
  276. package/dist/extras/assistant/AssistantChat.js +0 -1
  277. package/dist/extras/assistant/index.d.ts +0 -1
  278. package/dist/extras/assistant/index.js +0 -1
  279. package/dist/phoenix/application-spec/generate-assistant-prompt.js +0 -1
@@ -2,12 +2,10 @@ import type { I18n } from '@lingui/core';
2
2
  import type { ThemeOptions } from '@mui/material';
3
3
  import type { z } from 'zod';
4
4
  import type { FinalizeTaskResource } from '@salsita-ai/contracts/webhook';
5
- import type { DomainComponentOptic } from '../components/domain-component-optic.js';
6
- import type { $DomainEntity, DomainEntity, DomainFactory, EnumLike, ProductPreset, SchemaOfObject, SystemComponentTypeConstraint } from '../core/index.js';
7
- import type { DomainContextSystems, Transformers } from '../domain-context/index.js';
8
- import type { AclConfig, ApplicationConfig, AssistantManifest, DataSpec, DefaultEnvs, ImportedTransformer, ResourcesConfig, SpecTransformer, UserInterfaceConfig } from './application-config.js';
9
- import type { ElementRegistration } from './element-registration.js';
10
- import type { HandlerRegistration } from './handler-registration.js';
5
+ import type { $DomainEntity, DomainEntity, DomainFactory, EnumLike, ProductPreset, SchemaOfObject } from '../core/index.js';
6
+ import type { ProjectModule } from '../project-modules/index.js';
7
+ import type { AclConfig, ApplicationConfig, DataSpec, DefaultEnvs, ResourcesConfig, SpecTransformer, TransformersConfig, UserInterfaceConfig } from './application-config.js';
8
+ import type { AssistantResolvedManifest } from './assistant/index.js';
11
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> {
12
10
  version?: string;
13
11
  textLanguages?: string[];
@@ -18,13 +16,13 @@ interface ConfiguratorBuilderContext<ENTITIES extends DomainEntity<string> = nev
18
16
  viewState?: EnumLike<VIEW_STATES>;
19
17
  toolState?: EnumLike<TOOL_STATES>;
20
18
  exportState?: EnumLike<EXPORT_STATES>;
21
- componentOptics: ReadonlyArray<DomainComponentOptic<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITIES, SystemComponentTypeConstraint>>;
19
+ componentOptics: readonly ProjectModule[];
22
20
  i18n?: I18n;
23
21
  adminDomainFactory?: DomainFactory<ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
24
22
  adminPresets?: ReadonlyArray<ProductPreset<ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES>>;
25
23
  adminNavigationState?: EnumLike<ADMIN_NAVIGATION_STATES>;
26
24
  adminViewState?: EnumLike<ADMIN_VIEW_STATES>;
27
- adminComponentOptics: ReadonlyArray<DomainComponentOptic<ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, SystemComponentTypeConstraint>>;
25
+ adminComponentOptics: readonly ProjectModule[];
28
26
  publishedData?: z.ZodType<PUBLISHED_DATA>;
29
27
  finalizeData?: SchemaOfObject<FINALIZE_DATA>;
30
28
  prefetchedFinalizeData?: SchemaOfObject<PREFETCHED_FINALIZE_DATA>;
@@ -32,7 +30,7 @@ interface ConfiguratorBuilderContext<ENTITIES extends DomainEntity<string> = nev
32
30
  callbackData?: SchemaOfObject<CALLBACK_DATA>;
33
31
  resources?: ReadonlyArray<FinalizeTaskResource<RESOURCE>>;
34
32
  dataSpec?: DataSpec;
35
- createTransformers?: (ctx: DomainContextSystems<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>) => Transformers<ENTITIES>;
33
+ transformers?: TransformersConfig;
36
34
  acl?: AclConfig;
37
35
  enableAdminRelease?: boolean;
38
36
  ui?: Pick<UserInterfaceConfig, 'appLoader' | 'preview' | 'alwaysExpand'>;
@@ -41,11 +39,11 @@ interface ConfiguratorBuilderContext<ENTITIES extends DomainEntity<string> = nev
41
39
  readonly scope: string;
42
40
  }>>;
43
41
  publishedDataHash?: string;
44
- assistant?: AssistantManifest | null;
42
+ assistant?: AssistantResolvedManifest | null;
45
43
  theme?: ThemeOptions;
46
44
  tagName?: string;
47
- handlers?: ReadonlyArray<HandlerRegistration<any, any>>;
48
- elements?: readonly ElementRegistration[];
45
+ handlers?: readonly ProjectModule[];
46
+ elements?: readonly ProjectModule[];
49
47
  }
50
48
  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> {
51
49
  private readonly _context;
@@ -61,7 +59,7 @@ export declare class ConfiguratorBuilder<ENTITIES extends DomainEntity<string> =
61
59
  readonly scope: string;
62
60
  }>>): ConfiguratorBuilder<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>;
63
61
  withPublishedDataHash(publishedDataHash: string): ConfiguratorBuilder<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>;
64
- withAssistant(assistant: AssistantManifest | null): ConfiguratorBuilder<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>;
62
+ withAssistant(assistant: AssistantResolvedManifest | null): ConfiguratorBuilder<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>;
65
63
  withTheme(theme: ThemeOptions): ConfiguratorBuilder<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>;
66
64
  withDomainFactory<NEW_ENTITIES extends DomainEntity<string>, NEW_ALLOWED_ROOT_ENTITIES extends NEW_ENTITIES, NEW_MAP extends Record<NEW_ENTITIES['type'], $DomainEntity<NEW_ENTITIES>>, NEW_PUBLISHED_DATA extends Record<string, unknown>, NEW_SESSION_DATA extends Record<string, unknown>, NEW_FRONTEND_DATA extends Record<string, unknown>>(domainFactory: DomainFactory<NEW_ENTITIES, NEW_ALLOWED_ROOT_ENTITIES, NEW_MAP, NEW_PUBLISHED_DATA, NEW_SESSION_DATA, NEW_FRONTEND_DATA>): ConfiguratorBuilder<NEW_ENTITIES, NEW_ALLOWED_ROOT_ENTITIES, NEW_MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, NEW_PUBLISHED_DATA, NEW_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>;
67
65
  withAdminDomainFactory<NEW_ADMIN_ENTITIES extends DomainEntity<string>, NEW_ADMIN_ALLOWED_ROOT_ENTITIES extends NEW_ADMIN_ENTITIES, NEW_ADMIN_MAP extends Record<NEW_ADMIN_ENTITIES['type'], $DomainEntity<NEW_ADMIN_ENTITIES>>>(adminDomainFactory: DomainFactory<NEW_ADMIN_ENTITIES, NEW_ADMIN_ALLOWED_ROOT_ENTITIES, NEW_ADMIN_MAP, any, any, any>): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, NEW_ADMIN_ENTITIES, NEW_ADMIN_ALLOWED_ROOT_ENTITIES, NEW_ADMIN_MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
@@ -78,17 +76,34 @@ export declare class ConfiguratorBuilder<ENTITIES extends DomainEntity<string> =
78
76
  withAdminViewState<NEW_ADMIN_VIEW_STATES extends string>(adminViewState: EnumLike<NEW_ADMIN_VIEW_STATES>): ConfiguratorBuilder<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, NEW_ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
79
77
  withPresets(presets: ReadonlyArray<ProductPreset<ENTITIES, ALLOWED_ROOT_ENTITIES>>): ConfiguratorBuilder<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>;
80
78
  withAdminPresets(adminPresets: ReadonlyArray<ProductPreset<ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES>>): ConfiguratorBuilder<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>;
81
- withComponentOptics(componentOptics: ReadonlyArray<DomainComponentOptic<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITIES, SystemComponentTypeConstraint>>): ConfiguratorBuilder<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>;
82
- withAdminComponentOptics(componentOptics: ReadonlyArray<DomainComponentOptic<ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, SystemComponentTypeConstraint>>): ConfiguratorBuilder<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>;
83
- withHandlers(handlers: ReadonlyArray<HandlerRegistration<any, any>>): ConfiguratorBuilder<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>;
84
- withElements(elements: readonly ElementRegistration[]): ConfiguratorBuilder<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>;
79
+ /** Adds component optics as project modules: the `src/components/` files, or the optics a generated file lists. The runtime spec validates them. */
80
+ withComponentOptics(componentOptics: readonly ProjectModule[]): ConfiguratorBuilder<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>;
81
+ /** Adds admin component optics as project modules: the `src/admin/components/` files, or the optics a generated file lists. The runtime spec validates them. */
82
+ withAdminComponentOptics(componentOptics: readonly ProjectModule[]): ConfiguratorBuilder<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>;
83
+ /**
84
+ * Sets the handlers as project modules, one per `src/handlers/` file. They are stored unread: the
85
+ * runtime spec validates them, and `buildConfig` inspects them only afterwards.
86
+ */
87
+ withHandlers(handlers: readonly ProjectModule[]): ConfiguratorBuilder<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>;
88
+ /** Sets the elements as project modules, one per `src/elements/` file, for the runtime spec to validate. */
89
+ withElements(elements: readonly ProjectModule[]): ConfiguratorBuilder<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>;
85
90
  withResources<NEW_RESOURCE extends string>(resources: ReadonlyArray<FinalizeTaskResource<NEW_RESOURCE>>): ConfiguratorBuilder<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, NEW_RESOURCE>;
86
91
  withWebComponentTag(tagName: string): ConfiguratorBuilder<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>;
87
- withTransformers(importedTransformers: ReadonlyArray<ImportedTransformer<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>>, specTransformers: readonly SpecTransformer[]): ConfiguratorBuilder<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>;
92
+ /**
93
+ * Sets the transformers: the `src/transformers/` files as project modules, and the spec's `transformers`
94
+ * section that selects and orders them. The runtime spec validates the files and builds the factory.
95
+ */
96
+ withTransformers(importedTransformers: readonly ProjectModule[], specTransformers: readonly SpecTransformer[]): ConfiguratorBuilder<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>;
88
97
  withInterface(_interface: unknown): this;
89
98
  withDataSpec: (dataSpec: DataSpec) => ConfiguratorBuilder<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>;
90
99
  private _computeInitialPublishedData;
91
100
  buildConfig(): ApplicationConfig<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, Record<string, unknown>, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES>;
101
+ /**
102
+ * Builds the config together with the validated handlers. The handlers are read from the bootstrap
103
+ * runtime's spec rather than from the builder context, so nothing here touches a project file's
104
+ * export before the spec has checked it against its folder's contract.
105
+ */
106
+ private _buildConfigWithHandlers;
92
107
  buildWebhookContext(): {
93
108
  config: ApplicationConfig<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, Record<string, unknown>, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES>;
94
109
  parseFinalizeData: (data: unknown) => FINALIZE_DATA;
@@ -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/json-schema.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{createInitialPublishedData as s}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 u}from"./published-data/MapPublishedChunkedDataHandler.js";import{isMapPublishedRevisionDataHandler as c}from"./published-data/MapPublishedRevisionDataHandler.js";import{isSheetValidatorHandler as d}from"./published-data/SheetValidatorHandler.js";import{resolveImportedTransformers as m}from"./resolve-imported-transformers.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){if(t.filter(t=>l(t)).length>1)throw Error("Multiple createFilterPublishedChunksHandler handlers found. Only one handler is allowed.");if(t.filter(t=>h(t)).length>1)throw Error("Multiple createDataRowValidatorHandler handlers found. Only one handler is allowed.");if(t.filter(t=>d(t)).length>1)throw Error("Multiple createSheetValidatorHandler handlers found. Only one handler is allowed.");return new ConfiguratorBuilder({...this._context,handlers:t})}withElements(t){return new ConfiguratorBuilder({...this._context,elements: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,createTransformers:i=>m(t,e,i)})}withInterface(t){return this}withDataSpec=t=>new ConfiguratorBuilder({...this._context,dataSpec:t});_computeInitialPublishedData(t,e){if(!this._context.adminDomainFactory)throw Error("adminDomainFactory is required!");return s({adminDomainFactory:this._context.adminDomainFactory,domainRuntime:e,adminPresets:this._context.adminPresets??[],handlers:this._context.handlers,dataSpec:this._context.dataSpec,chunks:this._context.chunks,logger:t})}buildConfig(){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.handlers?.find(o)?.handler().handler,s=this._context.handlers?.find(a)?.handler().handler(void 0),h={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:this._context.tagName??"salsita-configurator",options:s??{},Application:i},handlers:this._context.handlers??[],elements:this._context.elements??[],createTransformers:this._context.createTransformers,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},l=t(),u=n({config:h,services:{analyticsService:new r,i18n:e,logger:l}}),c=this._computeInitialPublishedData(l,u);return{...h,initialPublishedData:c}}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 t=this.buildConfig(),e=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},r=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},n=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},o=this._context.handlers?.find(c)?.handler().handler,a=this._context.handlers?.find(u)?.handler().handler,s=this._context.handlers?.find(h)?.handler().handler,l=this._context.handlers?.find(d)?.handler().handler;return{config:t,parseFinalizeData:e,parseFinalizeResult:r,resources:this._context.resources??[],parseCallbackData:n,mapPublishedRevisionData:o,mapPublishedChunkedData:a,dataRowValidator:s,sheetValidator:l}}}
1
+ import{initConsoleLogger as t}from"@salsita-ai/common/utils";import{defaultI18n as e}from"#package/i18n";import{extendedSchemaValidator as i}from"../core/json-schema.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{createInitialPublishedData as s}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 u}from"./published-data/MapPublishedChunkedDataHandler.js";import{isMapPublishedRevisionDataHandler as c}from"./published-data/MapPublishedRevisionDataHandler.js";import{isSheetValidatorHandler as d}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})}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 s({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??[],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(),c=n({config:s,services:{analyticsService:new r,i18n:e,logger:u}}),m=c.getState().spec.configurator.handlers;if(m.filter(t=>l(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=>d(t)).length>1)throw Error("Multiple createSheetValidatorHandler handlers found. Only one handler is allowed.");let f=m.find(o)?.handler().handler,w=m.find(a)?.handler().handler(void 0),x=this._computeInitialPublishedData(u,c,m);return{config:{...s,mount:{tag:i,options:w??{},Application:f},initialPublishedData:x},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(u)?.handler().handler,l=e.find(h)?.handler().handler,m=e.find(d)?.handler().handler;return{config:t,parseFinalizeData:r,parseFinalizeResult:n,resources:this._context.resources??[],parseCallbackData:o,mapPublishedRevisionData:a,mapPublishedChunkedData:s,dataRowValidator:l,sheetValidator:m}}}
@@ -2,6 +2,7 @@ import type { SvgIconProps } from '@mui/material';
2
2
  import type { PropsWithChildren, ReactNode } from 'react';
3
3
  import type { ExtendedJsonSchema } from '@salsita-ai/common/utils';
4
4
  import type { DomainEntityId } from '../core/index.js';
5
+ import { type ProjectModule } from '../project-modules/index.js';
5
6
  export interface PhoenixEntityElementProps {
6
7
  entityId: DomainEntityId<string>;
7
8
  children?: ReactNode;
@@ -102,4 +103,8 @@ export declare const createPhoenixEntityElement: <SCHEMA extends {
102
103
  } = never>(element: PhoenixEntityElementDefinition<SCHEMA>) => import("react").FunctionComponent<SCHEMA["props"] & CustomPhoenixEntityElementProps>;
103
104
  export declare const createCustomPhoenixEntityElement: (name: string, element: (props: CustomPhoenixEntityElementProps) => JSX.Element) => PhoenixEntityElementRegistration;
104
105
  export type CreateCustomPhoenixEntityElement = (name: string, element: (props: CustomPhoenixEntityElementProps) => JSX.Element) => PhoenixEntityElementRegistration;
106
+ /** The element registrations of one `src/elements/` file; the editor keys its per-file reload cache on this. */
107
+ export declare const resolveElementModule: (module: ProjectModule) => readonly ElementRegistration[];
108
+ /** Validates the `src/elements/` files of an application config and flattens their registrations. */
109
+ export declare const resolveElementModules: (modules: readonly ProjectModule[]) => readonly ElementRegistration[];
105
110
  export {};
@@ -1 +1 @@
1
- export const systemElementRegistry={layoutElements:{},entityElements:{}};export const createPhoenixLayoutElement=e=>(systemElementRegistry.layoutElements[e.schema.properties.kind.enum[0]]=e.component,e.component);export const createCustomPhoenixLayoutElement=(e,t)=>({type:"layout",name:e,element:t});export const createPhoenixEntityElement=e=>(systemElementRegistry.entityElements[e.schema.properties.kind.enum[0]]=e.component,e.component);export const createCustomPhoenixEntityElement=(e,t)=>({type:"entity",name:e,element:t});
1
+ import{SHARED_FOLDER_HINT as e,isRecord as t,resolveListModule as n}from"../project-modules/index.js";export const systemElementRegistry={layoutElements:{},entityElements:{}};export const createPhoenixLayoutElement=e=>(systemElementRegistry.layoutElements[e.schema.properties.kind.enum[0]]=e.component,e.component);export const createCustomPhoenixLayoutElement=(e,t)=>({type:"layout",name:e,element:t});export const createPhoenixEntityElement=e=>(systemElementRegistry.entityElements[e.schema.properties.kind.enum[0]]=e.component,e.component);export const createCustomPhoenixEntityElement=(e,t)=>({type:"entity",name:e,element:t});let o={expected:"an element registration, or an array of them",fix:`Create it with phx.frontend.createCustomPhoenixLayoutElement(...) or phx.frontend.createCustomPhoenixEntityElement(...), ${e}.`},r=e=>!!t(e)&&("icon"===e.type?Array.isArray(e.elements):("entity"===e.type||"layout"===e.type)&&"string"==typeof e.name&&"function"==typeof e.element);export const resolveElementModule=e=>n(e,o,r);export const resolveElementModules=e=>e.flatMap(resolveElementModule);
@@ -1,3 +1,4 @@
1
+ import { type ProjectModule } from '../project-modules/index.js';
1
2
  export type PhoenixHandlerDefinition = {
2
3
  handler: () => Promise<void>;
3
4
  };
@@ -27,3 +28,7 @@ export declare const createPhoenixHandler: (name: string, handler: () => Phoenix
27
28
  export type CreatePhoenixHandler = (name: string, handler: () => PhoenixHandlerDefinition) => PhoenixHandlerRegistration;
28
29
  export declare const createSystemPhoenixHandler: <P, R>(name: string, handler: () => SystemPhoenixHandlerDefinition<P, R>) => SystemPhoenixHandlerRegistration<P, R>;
29
30
  export declare const createSystemPhoenixAsyncHandler: <P, R>(name: string, handler: () => SystemPhoenixAsyncHandlerDefinition<P, R>) => SystemPhoenixAsyncHandlerRegistration<P, R>;
31
+ /** The handler registrations of one `src/handlers/` file; the editor keys its per-file reload cache on this. */
32
+ export declare const resolveHandlerModule: (module: ProjectModule) => ReadonlyArray<HandlerRegistration<any, any>>;
33
+ /** Validates the `src/handlers/` files of an application config and flattens their registrations. */
34
+ export declare const resolveHandlerModules: (modules: readonly ProjectModule[]) => ReadonlyArray<HandlerRegistration<any, any>>;
@@ -1 +1 @@
1
- export const createPhoenixHandler=(e,t)=>({type:"phoenix",name:e,handler:t});export const createSystemPhoenixHandler=(e,t)=>({type:"system",name:e,handler:t});export const createSystemPhoenixAsyncHandler=(e,t)=>({type:"system-async",name:e,handler:t});
1
+ import{SHARED_FOLDER_HINT as e,isRecord as t,resolveListModule as o}from"../project-modules/index.js";export const createPhoenixHandler=(e,t)=>({type:"phoenix",name:e,handler:t});export const createSystemPhoenixHandler=(e,t)=>({type:"system",name:e,handler:t});export const createSystemPhoenixAsyncHandler=(e,t)=>({type:"system-async",name:e,handler:t});let r={expected:"a handler registration, or an array of them",fix:`Create it with phx.frontend.createPhoenixHandler(...) or one of the other phx.frontend.create…Handler(...) factories, ${e}.`},n=e=>t(e)&&("phoenix"===e.type||"system"===e.type||"system-async"===e.type)&&"string"==typeof e.name&&"function"==typeof e.handler;export const resolveHandlerModule=e=>o(e,r,n);export const resolveHandlerModules=e=>e.flatMap(resolveHandlerModule);
@@ -1,11 +1,11 @@
1
- export { type DomainConfig, type NavigationConfig, type ISessionService, type Session, type ResourcesConfig, type ApplicationConfig, type UserInterfaceConfig, type MountConfig, type WebComponentOptions, type SessionState, type AuthenticationErrorCode, type DataCellValue, type DataSchema, type DataSchemaArrayField, type DataSchemaField, type DataSchemaFieldObject, type DataSpec, type DataSpecEntry, type SwatchSpecEntry, type ChunksSpec, type AssistantFieldOptions, type AssistantFieldSource, type AssistantManifest, type AssistantRecipeGroup, type ImportedTransformer, type SpecTransformer, type AdminPagesSpec, type AnyApplicationConfig, type DefaultEnvs, } from './application-config.js';
1
+ export { type DomainConfig, type NavigationConfig, type ISessionService, type Session, type ResourcesConfig, type ApplicationConfig, type UserInterfaceConfig, type MountConfig, type WebComponentOptions, type SessionState, type AuthenticationErrorCode, type DataCellValue, type DataSchema, type DataSchemaArrayField, type DataSchemaField, type DataSchemaFieldObject, type DataSpec, type DataSpecEntry, type SwatchSpecEntry, type ChunksSpec, type ImportedTransformer, type SpecTransformer, type TransformersConfig, type AdminPagesSpec, type AnyApplicationConfig, type DefaultEnvs, } from './application-config.js';
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, assistantAddedEntityIds, findAssistantRecipeGroups, prepareAssistantRecipeUpdates, readAssistantRecipeGroup, } from './assistant-recipe-groups.js';
5
5
  export { ConfiguratorBuilder } 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
- export { resolveImportedTransformers } from './resolve-imported-transformers.js';
8
+ export { resolveImportedTransformers, resolveTransformerModule, resolveTransformerModules, } from './resolve-imported-transformers.js';
9
9
  export { webComponentAttributeParsers, createWebComponentPropertyDescriptor, type AttributeParser, type WebComponentPropertyDescriptor, } from './web-component-property.js';
10
10
  export { createWebComponentEventDescriptor, type WebComponentEventDescriptor } from './web-component-event.js';
11
11
  export { standardWebComponentProperties, type StandardConfiguratorElement } from './standard-properties.js';
@@ -26,5 +26,6 @@ export { createDataRowValidatorHandler, DataRowValidatorHandlerName, isDataRowVa
26
26
  export { createSheetValidatorHandler, SheetValidatorHandlerName, isSheetValidatorHandler, type CreateSheetValidatorHandler, type SheetValidatorResult, } from './published-data/SheetValidatorHandler.js';
27
27
  export { createMapPublishedRevisionDataHandler, createMapPublishedRevisionDataHandlerFactory, isMapPublishedRevisionDataHandler, type CreateMapPublishedRevisionDataHandler, type TypedCreateMapPublishedRevisionDataHandler, } from './published-data/MapPublishedRevisionDataHandler.js';
28
28
  export { createMapPublishedChunkedDataHandler, createMapPublishedChunkedDataHandlerFactory, isMapPublishedChunkedDataHandler, type CreateMapPublishedChunkedDataHandler, type MapPublishedChunkedDataHandlerProps, type MapPublishedChunkedDataResult, type TypedCreateMapPublishedChunkedDataHandler, } from './published-data/MapPublishedChunkedDataHandler.js';
29
- export { type PhoenixHandlerDefinition, type SystemPhoenixHandlerDefinition, type PhoenixHandlerRegistration, type SystemPhoenixHandlerRegistration, type SystemPhoenixAsyncHandlerDefinition, type SystemPhoenixAsyncHandlerRegistration, type HandlerRegistration, type CreatePhoenixHandler, createPhoenixHandler, createSystemPhoenixHandler, createSystemPhoenixAsyncHandler, } from './handler-registration.js';
30
- export { type PhoenixEntityElementProps, type PhoenixEntityElementRegistration, type PhoenixLayoutElementRegistration, type PhoenixIconRegistration, type ElementRegistration, type CustomPhoenixEntityElementProps, type PhoenixLayoutElementDefinition, type PhoenixEntityElementDefinition, type CreateCustomPhoenixLayoutElement, type CreateCustomPhoenixEntityElement, createPhoenixLayoutElement, createPhoenixEntityElement, createCustomPhoenixLayoutElement, createCustomPhoenixEntityElement, } from './element-registration.js';
29
+ export { type PhoenixHandlerDefinition, type SystemPhoenixHandlerDefinition, type PhoenixHandlerRegistration, type SystemPhoenixHandlerRegistration, type SystemPhoenixAsyncHandlerDefinition, type SystemPhoenixAsyncHandlerRegistration, type HandlerRegistration, type CreatePhoenixHandler, createPhoenixHandler, createSystemPhoenixHandler, createSystemPhoenixAsyncHandler, resolveHandlerModule, resolveHandlerModules, } from './handler-registration.js';
30
+ export { type PhoenixEntityElementProps, type PhoenixEntityElementRegistration, type PhoenixLayoutElementRegistration, type PhoenixIconRegistration, type ElementRegistration, type CustomPhoenixEntityElementProps, type PhoenixLayoutElementDefinition, type PhoenixEntityElementDefinition, type CreateCustomPhoenixLayoutElement, type CreateCustomPhoenixEntityElement, createPhoenixLayoutElement, createPhoenixEntityElement, createCustomPhoenixLayoutElement, createCustomPhoenixEntityElement, resolveElementModule, resolveElementModules, } from './element-registration.js';
31
+ export * from './assistant/index.js';
@@ -1 +1 @@
1
- export{findAssistantFieldOptions,readAssistantFieldOptions}from"./assistant-field-options.js";export{deleteEntityUpdateTag,findAssistantMutation,modifyEntityUpdateTag}from"./assistant-mutations.js";export{assistantAddedEntityIds,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{resolveImportedTransformers}from"./resolve-imported-transformers.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{ResourceBuilder}from"./resource-builder.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{createPhoenixHandler,createSystemPhoenixHandler,createSystemPhoenixAsyncHandler}from"./handler-registration.js";export{createPhoenixLayoutElement,createPhoenixEntityElement,createCustomPhoenixLayoutElement,createCustomPhoenixEntityElement}from"./element-registration.js";
1
+ export{findAssistantFieldOptions,readAssistantFieldOptions}from"./assistant-field-options.js";export{deleteEntityUpdateTag,findAssistantMutation,modifyEntityUpdateTag}from"./assistant-mutations.js";export{assistantAddedEntityIds,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{resolveImportedTransformers,resolveTransformerModule,resolveTransformerModules}from"./resolve-imported-transformers.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{ResourceBuilder}from"./resource-builder.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{createPhoenixHandler,createSystemPhoenixHandler,createSystemPhoenixAsyncHandler,resolveHandlerModule,resolveHandlerModules}from"./handler-registration.js";export{createPhoenixLayoutElement,createPhoenixEntityElement,createCustomPhoenixLayoutElement,createCustomPhoenixEntityElement,resolveElementModule,resolveElementModules}from"./element-registration.js";export*from"./assistant/index.js";
@@ -1,13 +1,23 @@
1
1
  import type { $DomainEntity, DomainEntity } from '../core/model.js';
2
2
  import type { DomainContextSystems } from '../domain-context/domain-context-systems.js';
3
3
  import type { Transformers } from '../domain-context/store-system/store-system.js';
4
+ import { type ProjectModule } from '../project-modules/index.js';
4
5
  import type { ImportedTransformer, SpecTransformer } from './application-config.js';
6
+ type AnyImportedTransformer = ImportedTransformer<any, any, any, any, any, any, any>;
7
+ /**
8
+ * The transformer of one `src/transformers/` file, named after the file. The spec's `transformers` section
9
+ * selects a plain-function export by that name; a transformer made with `build(name)` registers under its own.
10
+ */
11
+ export declare const resolveTransformerModule: (module: ProjectModule) => AnyImportedTransformer;
12
+ /** Validates the `src/transformers/` files of an application config and names each after its file. */
13
+ export declare const resolveTransformerModules: (modules: readonly ProjectModule[]) => readonly AnyImportedTransformer[];
5
14
  /**
6
15
  * Resolves imported transformer modules against spec transformer declarations.
7
16
  * Each imported transformer is registered/executed with the domain context,
8
17
  * then matched by name against spec entries to apply priority ordering.
9
18
  *
10
- * Used both at build time (via withTransformers) and at hot-reload time
19
+ * Used both when the runtime spec is initialized from the application config and at hot-reload time
11
20
  * (via domain-context subscription to registry changes).
12
21
  */
13
22
  export declare const resolveImportedTransformers: <ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string>(importedTransformers: ReadonlyArray<ImportedTransformer<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>>, specTransformers: readonly SpecTransformer[], ctx: DomainContextSystems<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>) => Transformers<ENTITIES>;
23
+ export {};
@@ -1 +1 @@
1
- export const resolveImportedTransformers=(r,e,t)=>{let o=r.flatMap(({name:r,transformer:e})=>{if(Array.isArray(e))return e.map((e,o)=>{if("register"in e)return e.register(t);if("function"==typeof e)return{priority:1/0,transformer:e(t),name:`${r}[${o}]`};throw Error(`Transformer '${r}[${o}]' must be either a RegistrableTransformer (with register method) or a TransformerFactory (function)`)});if("register"in e)return e.register(t);if("function"==typeof e)return{priority:1/0,transformer:e(t),name:r};throw Error(`Transformer '${r}' must be either a RegistrableTransformer (with register method) or a TransformerFactory (function)`)}),n=[];for(let r of e){let e=o.find(e=>e.name===r.name);if(!e){let e=o.map(r=>r.name).filter(Boolean).join(", ");throw Error(`Transformer '${r.name}' not found in imported transformer files. Available transformers: ${e||"none"}`)}n.push({priority:r.priority??1/0,transformer:e.transformer,name:r.name})}return n};
1
+ import{SHARED_FOLDER_HINT as r,createContractError as e,isRecord as t}from"../project-modules/index.js";let o={expected:"a transformer (a function of the domain context, or an object with a register method), or an array of them",fix:`Create it with phx.frontend.transformerBuilder, ${r}.`},n=r=>"function"==typeof r||t(r)&&"function"==typeof r.register;export const resolveTransformerModule=r=>{let t;if(!(Array.isArray(t=r.exports)?t.every(n):n(t)))throw e(r.origin,o,r.exports);return{name:r.origin.replace(/^.*\//,"").replace(/\.tsx?$/,""),transformer:r.exports}};export const resolveTransformerModules=r=>r.map(resolveTransformerModule);export const resolveImportedTransformers=(r,e,t)=>{let o=r.flatMap(({name:r,transformer:e})=>{if(Array.isArray(e))return e.map((e,o)=>{if("register"in e)return e.register(t);if("function"==typeof e)return{priority:1/0,transformer:e(t),name:`${r}[${o}]`};throw Error(`Transformer '${r}[${o}]' must be either a RegistrableTransformer (with register method) or a TransformerFactory (function)`)});if("register"in e)return e.register(t);if("function"==typeof e)return{priority:1/0,transformer:e(t),name:r};throw Error(`Transformer '${r}' must be either a RegistrableTransformer (with register method) or a TransformerFactory (function)`)}),n=[];for(let r of e){let e=o.find(e=>e.name===r.name);if(!e){let e=o.map(r=>r.name).filter(Boolean).join(", ");throw Error(`Transformer '${r.name}' not found in imported transformer files. Available transformers: ${e||"none"}`)}n.push({priority:r.priority??1/0,transformer:e.transformer,name:r.name})}return n};
@@ -5,6 +5,7 @@ import type { ExpressionContext } from '../core/expression.js';
5
5
  import type { $DomainEntity, DomainEntity, EntityByType } from '../core/model.js';
6
6
  import type { DomainState } from '../core/state.js';
7
7
  import type { CustomExpression } from '../expressions/custom-expression.js';
8
+ import { type ProjectModule } from '../project-modules/index.js';
8
9
  import { type ComponentSystemFilter, type NavigationFilterOptic } from './legacy-filter.js';
9
10
  import type { GradualComponentSystemFilter, IdOrWithId } from './system-component-filter.js';
10
11
  import type { Viewport } from './viewport-state-component.js';
@@ -33,6 +34,8 @@ export interface DomainComponentDynamicOptic<ENTITIES extends DomainEntity<strin
33
34
  }
34
35
  export type DomainComponentOptic<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, ENTITY extends ENTITIES, COMPONENT_TYPE extends SystemComponentTypeConstraint> = DomainComponentSimpleOptic<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITY, COMPONENT_TYPE> | DomainComponentDynamicOptic<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, COMPONENT_TYPE>;
35
36
  export type AnyDomainComponentOptic = DomainComponentOptic<any, any, any, any, any, any, any>;
37
+ /** Validates the `src/components/` files, or the optics a generated file lists, and flattens them. */
38
+ export declare const resolveComponentOpticModules: (modules: readonly ProjectModule[]) => readonly AnyDomainComponentOptic[];
36
39
  export declare class DomainComponentOpticBuilder<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, ALIASES extends Record<string, ENTITIES>, ENTITY extends ENTITIES, $ENTITY extends $DomainEntity<ENTITIES>, COMPONENT_TYPE extends SystemComponentTypeConstraint> {
37
40
  private readonly aliasMap;
38
41
  private readonly entityTypes;
@@ -1,4 +1,4 @@
1
- import{createCacheToken as t,getStickyCache as e}from"@salsita-ai/common/utils";import{createCustomExpression as i}from"../expressions/custom-expression.js";import{withProfilerLabel as n}from"../utils/profiler-label.js";export class DomainComponentOpticBuilder{aliasMap;entityTypes;componentType;instanceName;navigationFilters;generated;entityTypeOrAliasNames;constructor(t,e,i,n,s=[],a=!1,o=[]){this.aliasMap=t,this.entityTypes=e,this.componentType=i,this.instanceName=n,this.navigationFilters=s,this.generated=a,this.entityTypeOrAliasNames=o}static from(t){return new DomainComponentOpticBuilder(t,[])}withEntity(t){return new DomainComponentOpticBuilder(this.aliasMap,[...this.entityTypes,t],this.componentType,this.instanceName,this.navigationFilters,this.generated,[...this.entityTypeOrAliasNames,t])}withAlias(t){return new DomainComponentOpticBuilder(this.aliasMap,[...this.entityTypes,...this.aliasMap[t]],this.componentType,this.instanceName,this.navigationFilters,this.generated,[...this.entityTypeOrAliasNames,String(t)])}withComponent(t,e,i=!1){return new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,t,e,this.navigationFilters,i,this.entityTypeOrAliasNames)}withFilter(i){if(console.warn(`Component ${this.componentType?.name}#${this.instanceName} on entity ${this.entityTypes.join(", ")} uses a legacy filter with full filter evaluation. This is a suboptimal variant and is deprecated in favor of per-criterion evaluation.
1
+ import{createCacheToken as t,getStickyCache as e}from"@salsita-ai/common/utils";import{createCustomExpression as i}from"../expressions/custom-expression.js";import{SHARED_FOLDER_HINT as n,isRecord as s,resolveListModule as a}from"../project-modules/index.js";import{withProfilerLabel as o}from"../utils/profiler-label.js";let r={expected:"an attached component, or an array of them",fix:`Create it with phx.domain.attachComponent(...) (phx.domain.admin.attachComponent(...) under src/admin/), ${n}.`},d=t=>s(t)&&("simple"===t.kind||"dynamic"===t.kind)&&"string"==typeof t.instanceName&&"function"==typeof t.read;export const resolveComponentOpticModules=t=>t.flatMap(t=>a(t,r,d));export class DomainComponentOpticBuilder{aliasMap;entityTypes;componentType;instanceName;navigationFilters;generated;entityTypeOrAliasNames;constructor(t,e,i,n,s=[],a=!1,o=[]){this.aliasMap=t,this.entityTypes=e,this.componentType=i,this.instanceName=n,this.navigationFilters=s,this.generated=a,this.entityTypeOrAliasNames=o}static from(t){return new DomainComponentOpticBuilder(t,[])}withEntity(t){return new DomainComponentOpticBuilder(this.aliasMap,[...this.entityTypes,t],this.componentType,this.instanceName,this.navigationFilters,this.generated,[...this.entityTypeOrAliasNames,t])}withAlias(t){return new DomainComponentOpticBuilder(this.aliasMap,[...this.entityTypes,...this.aliasMap[t]],this.componentType,this.instanceName,this.navigationFilters,this.generated,[...this.entityTypeOrAliasNames,String(t)])}withComponent(t,e,i=!1){return new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,t,e,this.navigationFilters,i,this.entityTypeOrAliasNames)}withFilter(i){if(console.warn(`Component ${this.componentType?.name}#${this.instanceName} on entity ${this.entityTypes.join(", ")} uses a legacy filter with full filter evaluation. This is a suboptimal variant and is deprecated in favor of per-criterion evaluation.
2
2
 
3
3
  In your TS files, replace
4
4
  withFilter()
@@ -13,4 +13,4 @@ import{createCacheToken as t,getStickyCache as e}from"@salsita-ai/common/utils";
13
13
  active:
14
14
  $read: $trueOrFalseExpression
15
15
  # ... other eventual criteria
16
- `),"function"==typeof i){let n=t(),s=t=>({evaluate:(s,a,o)=>{let r=e(a,n),d=r.get(s);if(!d){if(void 0===(d=i(o.domain.get$Entity(s,a),a)))throw Error(`Dynamic filter on component ${this.componentType?.name}.${this.instanceName} on entity ${s} returned 'undefined'. This is likely a bug in the component definition, check whether you are referencing a correct expression or field!`);r.put(s,d)}return"boolean"==typeof d?"active"===t?d:void 0:d[t]},meta:{}});return new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,{navigationStates:s("navigationStates"),selectedEntityIds:s("selectedEntityIds"),hoveredEntityIds:s("hoveredEntityIds"),draggedEntityIds:s("draggedEntityIds"),viewStates:s("viewStates"),toolStates:s("toolStates"),modes:s("modes"),roles:s("roles"),active:s("active"),fullscreen:s("fullscreen"),debug:s("debug"),viewports:s("viewports"),exportedEntityIds:void 0,exportStates:void 0}],this.generated,this.entityTypeOrAliasNames)}return"boolean"==typeof i?new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,{active:i,navigationStates:void 0,selectedEntityIds:void 0,hoveredEntityIds:void 0,draggedEntityIds:void 0,viewStates:void 0,toolStates:void 0,modes:void 0,roles:void 0,fullscreen:void 0,debug:void 0,viewports:void 0,exportedEntityIds:void 0,exportStates:void 0}],this.generated,this.entityTypeOrAliasNames):new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,{navigationStates:void 0,selectedEntityIds:void 0,hoveredEntityIds:void 0,draggedEntityIds:void 0,viewStates:void 0,toolStates:void 0,modes:void 0,roles:void 0,active:void 0,fullscreen:void 0,debug:void 0,viewports:void 0,exportedEntityIds:void 0,exportStates:void 0,...i}],this.generated,this.entityTypeOrAliasNames)}withGradualFilter(t){let e=t=>"function"==typeof t?i(t,{}):t,n={navigationStates:e(t.navigationStates),selectedEntityIds:e(t.selectedEntityIds),hoveredEntityIds:e(t.hoveredEntityIds),draggedEntityIds:e(t.draggedEntityIds),exportedEntityIds:e(t.exportedEntityIds),viewStates:e(t.viewStates),toolStates:e(t.toolStates),exportStates:e(t.exportStates),modes:e(t.modes),roles:e(t.roles),active:e(t.active),fullscreen:e(t.fullscreen),debug:e(t.debug),viewports:e(t.viewports)};return new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,n],this.generated,this.entityTypeOrAliasNames)}validate(){if(!this.componentType||!this.instanceName)throw Error("Use withComponent before attaching");if(!this.entityTypes.length)throw Error("Use withEntity and/or withAlias before attaching")}_getProfilerLabel(){return[...this.entityTypeOrAliasNames,this.componentType.name,this.instanceName].join("_")}attach=(i,s)=>{var a,o;let r,d;return this.validate(),a={kind:"simple",entityTypes:new Set(this.entityTypes),componentType:this.componentType,instanceName:this.instanceName,navigationFilters:this.navigationFilters,read:(t,e,n)=>i(n.domain.get$Entity(t,e),e,n),write:s??(()=>({})),generated:this.generated},o=this._getProfilerLabel(),r=t(),d=n(o,a.read),{...a,read:(t,i,n)=>{let s=e(i,r),a=s.get(t);if(a)return a;let o=d(t,i,n);return s.put(t,o),o}}};attachMany=i=>{var s,a;let o,r;return this.validate(),s={kind:"dynamic",entityTypes:new Set(this.entityTypes),componentType:this.componentType,instanceName:this.instanceName,navigationFilters:this.navigationFilters,read:(t,e,n)=>i(n.domain.get$Entity(t,e),e,n)},a=this._getProfilerLabel(),o=t(),r=n(a,s.read),{...s,read:(t,i,n)=>{let s=e(i,o),a=s.get(t);if(a)return a;let d=r(t,i,n);return s.put(t,d),d}}}}
16
+ `),"function"==typeof i){let n=t(),s=t=>({evaluate:(s,a,o)=>{let r=e(a,n),d=r.get(s);if(!d){if(void 0===(d=i(o.domain.get$Entity(s,a),a)))throw Error(`Dynamic filter on component ${this.componentType?.name}.${this.instanceName} on entity ${s} returned 'undefined'. This is likely a bug in the component definition, check whether you are referencing a correct expression or field!`);r.put(s,d)}return"boolean"==typeof d?"active"===t?d:void 0:d[t]},meta:{}});return new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,{navigationStates:s("navigationStates"),selectedEntityIds:s("selectedEntityIds"),hoveredEntityIds:s("hoveredEntityIds"),draggedEntityIds:s("draggedEntityIds"),viewStates:s("viewStates"),toolStates:s("toolStates"),modes:s("modes"),roles:s("roles"),active:s("active"),fullscreen:s("fullscreen"),debug:s("debug"),viewports:s("viewports"),exportedEntityIds:void 0,exportStates:void 0}],this.generated,this.entityTypeOrAliasNames)}return"boolean"==typeof i?new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,{active:i,navigationStates:void 0,selectedEntityIds:void 0,hoveredEntityIds:void 0,draggedEntityIds:void 0,viewStates:void 0,toolStates:void 0,modes:void 0,roles:void 0,fullscreen:void 0,debug:void 0,viewports:void 0,exportedEntityIds:void 0,exportStates:void 0}],this.generated,this.entityTypeOrAliasNames):new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,{navigationStates:void 0,selectedEntityIds:void 0,hoveredEntityIds:void 0,draggedEntityIds:void 0,viewStates:void 0,toolStates:void 0,modes:void 0,roles:void 0,active:void 0,fullscreen:void 0,debug:void 0,viewports:void 0,exportedEntityIds:void 0,exportStates:void 0,...i}],this.generated,this.entityTypeOrAliasNames)}withGradualFilter(t){let e=t=>"function"==typeof t?i(t,{}):t,n={navigationStates:e(t.navigationStates),selectedEntityIds:e(t.selectedEntityIds),hoveredEntityIds:e(t.hoveredEntityIds),draggedEntityIds:e(t.draggedEntityIds),exportedEntityIds:e(t.exportedEntityIds),viewStates:e(t.viewStates),toolStates:e(t.toolStates),exportStates:e(t.exportStates),modes:e(t.modes),roles:e(t.roles),active:e(t.active),fullscreen:e(t.fullscreen),debug:e(t.debug),viewports:e(t.viewports)};return new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,n],this.generated,this.entityTypeOrAliasNames)}validate(){if(!this.componentType||!this.instanceName)throw Error("Use withComponent before attaching");if(!this.entityTypes.length)throw Error("Use withEntity and/or withAlias before attaching")}_getProfilerLabel(){return[...this.entityTypeOrAliasNames,this.componentType.name,this.instanceName].join("_")}attach=(i,n)=>{var s,a;let r,d;return this.validate(),s={kind:"simple",entityTypes:new Set(this.entityTypes),componentType:this.componentType,instanceName:this.instanceName,navigationFilters:this.navigationFilters,read:(t,e,n)=>i(n.domain.get$Entity(t,e),e,n),write:n??(()=>({})),generated:this.generated},a=this._getProfilerLabel(),r=t(),d=o(a,s.read),{...s,read:(t,i,n)=>{let s=e(i,r),a=s.get(t);if(a)return a;let o=d(t,i,n);return s.put(t,o),o}}};attachMany=i=>{var n,s;let a,r;return this.validate(),n={kind:"dynamic",entityTypes:new Set(this.entityTypes),componentType:this.componentType,instanceName:this.instanceName,navigationFilters:this.navigationFilters,read:(t,e,n)=>i(n.domain.get$Entity(t,e),e,n)},s=this._getProfilerLabel(),a=t(),r=o(s,n.read),{...n,read:(t,i,n)=>{let s=e(i,a),o=s.get(t);if(o)return o;let d=r(t,i,n);return s.put(t,d),d}}}}
@@ -7,6 +7,8 @@ export interface ComponentModification<COMPONENT_TYPE extends SystemComponentTyp
7
7
  entityId: EntityId;
8
8
  updateTag: string;
9
9
  hint?: Localizable;
10
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
11
+ agentHint?: string | null;
10
12
  componentInstance: ComponentInstance<COMPONENT_TYPE>;
11
13
  writableState: WritableStateOfComponent<COMPONENT_TYPE>;
12
14
  metadata?: Record<string, unknown>;
@@ -17,6 +19,8 @@ export interface EphemeralRecordModification<COMPONENT_TYPE extends SystemCompon
17
19
  entityId: EntityId;
18
20
  updateTag: string;
19
21
  hint?: Localizable;
22
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
23
+ agentHint?: string | null;
20
24
  componentInstance: ComponentInstance<COMPONENT_TYPE>;
21
25
  writableState: WritableStateOfComponent<COMPONENT_TYPE>;
22
26
  }
@@ -25,6 +29,8 @@ export interface EphemeralRecordCreation<COMPONENT_TYPE extends SystemComponentT
25
29
  entityId: EntityId;
26
30
  updateTag: string;
27
31
  hint?: Localizable;
32
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
33
+ agentHint?: string | null;
28
34
  componentInstance: ComponentInstance<COMPONENT_TYPE>;
29
35
  initialState: StateOfComponent<COMPONENT_TYPE>;
30
36
  }
@@ -34,6 +40,8 @@ export interface EphemeralRecordDeletion<COMPONENT_TYPE extends SystemComponentT
34
40
  componentInstance: ComponentInstance<COMPONENT_TYPE>;
35
41
  updateTag: string;
36
42
  hint?: Localizable;
43
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
44
+ agentHint?: string | null;
37
45
  }
38
46
  export type DomainEntityStateDelta<ENTITY extends DomainEntity<string>> = Partial<Omit<ENTITY, 'id' | 'type'>>;
39
47
  export interface DomainEntityModification<ENTITY extends DomainEntity<string> = DomainEntity<string>> {
@@ -41,6 +49,8 @@ export interface DomainEntityModification<ENTITY extends DomainEntity<string> =
41
49
  entityId: ENTITY['id'];
42
50
  updateTag: string;
43
51
  hint?: Localizable;
52
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
53
+ agentHint?: string | null;
44
54
  stateDelta: DomainEntityStateDelta<ENTITY>;
45
55
  origin?: ComponentModification<SystemComponentTypeConstraint>;
46
56
  }
@@ -55,6 +65,8 @@ export interface DomainEntityCreation<ENTITY extends DomainEntity<string>, PAREN
55
65
  collection?: string;
56
66
  parentId: PARENT['id'];
57
67
  hint?: Localizable;
68
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
69
+ agentHint?: string | null;
58
70
  }
59
71
  export interface DomainEntityReplacement<ENTITY extends DomainEntity<string>> {
60
72
  kind: 'replaceDomainEntity';
@@ -63,12 +75,16 @@ export interface DomainEntityReplacement<ENTITY extends DomainEntity<string>> {
63
75
  updateTag: string;
64
76
  keepChildren: boolean;
65
77
  hint?: Localizable;
78
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
79
+ agentHint?: string | null;
66
80
  }
67
81
  export interface EntityDeletion<ENTITY extends DomainEntity<string>> {
68
82
  kind: 'deleteEntity';
69
83
  entityId: EntityId<ENTITY>;
70
84
  updateTag: string;
71
85
  hint?: Localizable;
86
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
87
+ agentHint?: string | null;
72
88
  }
73
89
  export type DataUpdate<ENTITY extends DomainEntity<string>, PARENT extends DomainEntity<string>> = EphemeralRecordModification | EphemeralRecordCreation | EphemeralRecordDeletion | DomainEntityModification<ENTITY> | DomainEntityCreation<ENTITY, PARENT> | DomainEntityReplacement<ENTITY> | EntityDeletion<ENTITY>;
74
90
  export type StateUpdate<ENTITY extends DomainEntity<string>, PARENT extends DomainEntity<string>> = ComponentModification<SystemComponentTypeConstraint> | DataUpdate<ENTITY, PARENT>;
@@ -59,7 +59,7 @@ export type AnyActionContext = ActionContext<any, any, any, any, any, any, any,
59
59
  */
60
60
  export type ActionImplementation<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string, PARAMS, RESULT> = (params: PARAMS, state: DomainState<ENTITIES>, context: ActionContext<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>) => PreparedAction<ENTITIES, RESULT>;
61
61
  export type AnyActionImplementation = ActionImplementation<any, any, any, any, any, any, any, any, any, any, any, unknown>;
62
- /** The implementations of every declared action by name, as the generated barrel merges them from `src/actions/`. */
62
+ /** The implementations of every declared action by name, as `DomainBuilder.withActionModules` merges them from `src/actions/`. */
63
63
  export type ActionImplementations<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string, ACTION_TYPES extends ActionTypes> = {
64
64
  readonly [NAME in keyof ACTION_TYPES]: ActionImplementation<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, ACTION_TYPES[NAME]['params'], ACTION_TYPES[NAME]['result']>;
65
65
  };
@@ -6,6 +6,7 @@ import { DomainFactory } from './core/index.js';
6
6
  import { type MigrateFunction } from './core/migrations.js';
7
7
  import { type $DomainEntity, type DomainEntity, type EntityByType } from './core/model.js';
8
8
  import type { $DomainEntityReflection, EntityReflections, SchemaOfObject } from './core/reflection.js';
9
+ import { type ProjectModule } from './project-modules/index.js';
9
10
  export type AliasedExpressions<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, ALIASES extends Record<string, ENTITIES>> = {
10
11
  [K in TypeOrAlias<ENTITIES, ALIASES>]?: Record<string, AnonymousExpression<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ExpandAlias<ENTITIES, ALIASES, K>, unknown>>;
11
12
  };
@@ -31,9 +32,17 @@ export declare class DomainBuilder<ENTITIES extends DomainEntity<string>, ALLOWE
31
32
  static from<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, ALIASES extends Readonly<Record<string, ENTITIES>>>(entities: EntityReflections<ENTITIES>, aliasMap: AliasMap<ALIASES>, $entityReflections: $EntityReflections<ENTITIES>, allowedRootEntityTypes: ReadonlyArray<ALLOWED_ROOT_ENTITIES['type']>, modelVersion: number, publishedData: SchemaOfObject<PUBLISHED_DATA>, sessionData: SchemaOfObject<SESSION_DATA>, frontendData: SchemaOfObject<FRONTEND_DATA>, backendData: ExtendedJsonSchema | undefined, isAdminDomain: boolean): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
32
33
  withMigrate(migration: MigrateFunction<ENTITIES>): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
33
34
  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>;
35
+ /**
36
+ * Adds the expressions of the `src/expressions/` files, as the generated barrel lists them. Each file
37
+ * is checked against the folder's contract and added on its own, so an expression defined twice is
38
+ * reported with both files instead of being overwritten by file order.
39
+ */
40
+ withExpressionModules(modules: readonly ProjectModule[]): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
34
41
  /** Declares the actions of the domain, as the generated `domain-spec.ts` reads them from the spec's `actions` section. */
35
42
  withActions(actions: readonly ActionDefinition[]): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
36
- /** Adds the implementations of the declared actions, as the generated barrel merges them from `src/actions/`. */
43
+ /** Adds the action implementations of the `src/actions/` files, as the generated barrel lists them, after checking each file against the folder's contract. */
44
+ withActionModules(modules: readonly ProjectModule[]): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
45
+ /** Adds the implementations of the declared actions, already merged by action name. */
37
46
  withActionImplementations(implementations: AnyActionImplementations): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
38
47
  build: () => DomainFactory<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
39
48
  }
@@ -1 +1 @@
1
- import{expandAlias as t}from"./core/alias.js";import{DomainFactory as i}from"./core/index.js";import{MigrateFunctionBuilder as e}from"./core/migrations.js";import{withProfilerLabel as s}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,a,n,o,h,l,m,r,d,p,c){this.entities=t,this.aliasMap=i,this.$entityReflections=e,this.allowedRootEntityTypes=s,this.implemented=a,this.modelVersion=n,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,i,s,a,n,o,h,l,m,r){let d=e.fromVersions({1:t}).to(1).using({}).build();return new DomainBuilder(t,i,s,a,{},n,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(i){let e={...this.implemented};return Object.entries(i).forEach(([i,a])=>{t(this.aliasMap,i).forEach(t=>{let n={...e[t]};e[t]=n,Object.entries(a).forEach(([e,a])=>{let o=n[e];if(o)throw Error(`Duplicate expression ${t}.${e}: The expression is defined on both ${i} and ${o.origin.typeOrAlias}, which would lead to ambiguous usage. Please ensure that expressions are only defined once.`);n[e]={...a,evaluate:s(`${t}_${e}`,a.evaluate),origin:{name:e,typeOrAlias:i}}})})}),new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,e,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)}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 t=this.implemented,s=this.migrate??e.fromVersions({1:this.entities}).to(1).using({}).build();return new i({aliasMap:this.aliasMap,entityReflections:this.entities,$entityReflections:this.$entityReflections,expressions:t,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{expandAlias as t}from"./core/alias.js";import{DomainFactory as i}from"./core/index.js";import{MigrateFunctionBuilder as s}from"./core/migrations.js";import{resolveActionModules as e,resolveExpressionModules as n}from"./project-modules/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,s,e,n,a,o,h,l,r,m,d,p,c){this.entities=t,this.aliasMap=i,this.$entityReflections=s,this.allowedRootEntityTypes=e,this.implemented=n,this.modelVersion=a,this.publishedData=o,this.sessionData=h,this.frontendData=l,this.backendData=r,this.migrate=m,this.isAdminDomain=d,this.actions=p,this.actionImplementations=c}static from(t,i,e,n,a,o,h,l,r,m){let d=s.fromVersions({1:t}).to(1).using({}).build();return new DomainBuilder(t,i,e,n,{},a,o,h,l,r,d,m,{},{})}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(i){let s={...this.implemented};return Object.entries(i).forEach(([i,e])=>{t(this.aliasMap,i).forEach(t=>{let n={...s[t]};s[t]=n,Object.entries(e).forEach(([s,e])=>{let o=n[s];if(o)throw Error(`Duplicate expression ${t}.${s}: The expression is defined on both ${i} and ${o.origin.typeOrAlias}, which would lead to ambiguous usage. Please ensure that expressions are only defined once.`);n[s]={...e,evaluate:a(`${t}_${s}`,e.evaluate),origin:{name:s,typeOrAlias:i}}})})}),new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,s,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(e(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 t=this.implemented,e=this.migrate??s.fromVersions({1:this.entities}).to(1).using({}).build();return new i({aliasMap:this.aliasMap,entityReflections:this.entities,$entityReflections:this.$entityReflections,expressions:t,allowedRootEntityTypes:this.allowedRootEntityTypes,modelVersion:this.modelVersion,migrate:e,publishedData:this.publishedData,sessionData:this.sessionData,frontendData:this.frontendData,backendData:this.backendData,isAdminDomain:this.isAdminDomain,actions:this.actions,actionImplementations:this.actionImplementations})}}
@@ -1,5 +1,5 @@
1
1
  export { type AnalyticsSystem, NoopAnalyticsSystem } from './analytics-system/analytics-system.js';
2
- export { type AnalyticsEvent, AnalyticsEventFactory, AnalyticsEventType, } from './analytics-system/analytics-contracts.js';
2
+ export { type AnalyticsEvent, AnalyticsEventFactory, AnalyticsEventType, type DataLoadedEvent, type InitEvent, type NavigationEvent, type SessionAuthenticatedEvent, type SystemEvent, type UserActionEvent, } from './analytics-system/analytics-contracts.js';
3
3
  export { NavigationUpdateTag, isInitialNavigationUpdate, isNavigationUpdate, isInitialViewUpdate, isViewUpdate, isInitialSelectionUpdate, isSelectUpdate, isDeselectUpdate, isInitialFullscreenUpdate, isToggleFullscreenUpdate, isInitialDebugUpdate, isInitialViewportUpdate, isSetViewportUpdate, isInitialDragUpdate, isDragStartUpdate, isDragEndUpdate, isInitialToolUpdate, isToolUpdate, isExportUpdate, } from './navigation-system/navigation-updates.js';
4
4
  export { createAutoSelectionTransformer, NavigationSystem, type NavigationSystemContext, } from './navigation-system/navigation-system.js';
5
5
  export { createResetSelectionOnNavigationTransformer, createNavigationOnSelectionTransformer, createNavigationOnDeselectTransformer, createSelectParentOnDeselectionTransformer, createNavigationOnSelectionChangeTransformer, } from './navigation-system/selection-transformers.js';
@@ -1,2 +1,2 @@
1
- import{CompositeKeyMap as e,assertExistence as t,isEqualArray as i}from"@salsita-ai/common/utils";import{dragStateComponent as o}from"../../components/drag-state-component.js";import{hoverStateComponent as r}from"../../components/hover-state-component.js";import{selectionStateComponent as s}from"../../components/selection-state-component.js";import{getComponentSystemFilterState as n}from"../../components/system-component-filter.js";import{systemVirtualEntityId as a}from"../../components/system-virtual-entity.js";import{systemUpdateFactory as d}from"../../components/updates.js";import{isSystemViewportStateComponentSnapshot as m}from"../../components/viewport-state-component.js";import{isEqualComponentInstance as l}from"../../core/component.js";import{domainEntityTypeFromId as c,isVirtualEntityId as p}from"../../core/model.js";import{projectedEntitiesComponent as h}from"../../system-components/index.js";import{cloneEvalCache as f,createEvalCacheToken as v,getEvalCache as g,setEvalCache as u}from"../../utils/eval-cache.js";import{createCascadeDeletesTransformer as y}from"../relation-transformers/cascade-deletes.js";import{createCascadeRefPruningTransformer as S}from"../relation-transformers/cascade-ref-pruning.js";import{applyUpdates as I}from"./apply-updates.js";import{LifecycleStateSlice as _}from"./lifecycle-state-slice.js";import{mergeReconciliationsUpdates as x,reconcileProjectedEntities as T}from"./reconcile-projected-entities.js";let E={uninitializedError:"StoreSystem is not initialized."},k=v({clone:e=>e}),w=class InvalidInitialStateError extends Error{emission;childError;constructor(e,t,i){let o="";"uncaught"===e.validity.severity&&(o=`: ${e.validity.error.message}`),("fatal"===e.validity.severity||"fixable"===e.validity.severity)&&(o=`: ${e.validity.entityViolations.map(e=>{let i=e.violation.message;return null!=i?t(i):e.violation.type}).join(", ")}`),super(`Initial state is not valid! Severity: ${e.validity.severity}, Cause: ${o}`),this.emission=e,this.childError=i,this.name="InvalidInitialStateError"}},b=(e,t)=>{try{return e()}catch(e){throw t(e),e}};export class StoreSystem{_context;stateSlices;get isInitialized(){return this.committed.isInitialized}_onBeforeCommitHooks=[];committed=new _(E);potentiallyInvalid=new _(E);rendered=new _(E);stagedUpdates=void 0;transformToDataUpdates=(e,t)=>{let i=!1,o=e.map(e=>"modifyComponent"===e.kind?(i=!0,this.componentModificationToDataUpdate(e,t)):e);return i?o:e};createInitialTransformPipe=()=>[{transformer:this.transformToDataUpdates,priority:1/0,registrationToken:{},name:"TransformToDataUpdates"}];transformPipe=this.createInitialTransformPipe();_cascadeDeletesTransformer=(...e)=>(this._cascadeDeletesTransformerMemo??=y(this._context.selectors.getCompositionProjections()))(...e);_cascadeDeletesTransformerMemo;_refPruningTransformer=(...e)=>(this._refPruningTransformerMemo??=S(this._context.selectors.getComponentReader()))(...e);_refPruningTransformerMemo;_deselectOnDeleteTransformer=(e,t)=>{let i=new Set(e.filter(e=>"deleteEntity"===e.kind).map(e=>e.entityId));if(0===i.size)return e;let o=n(t).selectedEntityId;return o&&i.has(o)?[...e,d.EphemeralRecordModification({componentInstance:{entityId:a,componentType:s},updateTag:"AutoDeselectRemovedProjectedEntity",writableState:{selectedEntityId:t.rootEntityId}})]:e};constructor(e){this._context=e,this.stateSlices={committed:this.committed.observable,rendered:this.rendered.observable,potentiallyInvalid:this.potentiallyInvalid.observable}}_validateState=e=>this._context.selectors.getValidationProjections().validateState(e);initialize=()=>{let e=this._context.selectors.getInitialDomainState();this.stagedUpdates=void 0;let t=this._validateState(e),i={kind:"reset",state:e,validity:t,tag:void 0,transformationLog:void 0},o=i;if(!o.validity.valid&&"fatal"===o.validity.severity||"fixable"===o.validity.severity){this._context.domainServicesSelectors.getLogger().debug("Trying to fix initial emission:",o);let e=o.state,{transformedUpdates:t,transformationLog:i}=this.applyTransformers([],e,"committed"),r=I(this.transformToDataUpdates(t,e),e);f(e,r),o={kind:"reset",state:r,validity:this._validateState(r),tag:"fixed",transformationLog:i}}if(!o.validity.valid){if(this._context.domainServicesSelectors.getLogger().error("Invalid initial emission:",{initialEmission:i,fixedEmission:o}),"uncaught"===o.validity.severity)throw new w(o,this._context.domainServicesSelectors.getResolveLocalizable(),o.validity.error??void 0);throw new w(o,this._context.domainServicesSelectors.getResolveLocalizable())}this.committed.next(o),this.rendered.next(o),this.potentiallyInvalid.next(o)};registerTransformer(e,i,o){let r={};return((e,i,o)=>{let r=0;for(;r<e.length&&0>=o(t(e[r]),i);)r++;e.splice(r,0,i)})(this.transformPipe,{registrationToken:r,transformer:i,priority:e,name:o},(e,t)=>e.priority===t.priority?0:e.priority<t.priority?-1:1),()=>{let e=this.transformPipe.findIndex(e=>e.registrationToken===r);-1!==e&&this.transformPipe.splice(e,1)}}onBeforeCommit(e){return this._onBeforeCommitHooks.push(e),()=>{this._onBeforeCommitHooks=this._onBeforeCommitHooks.filter(t=>t!==e)}}componentModificationToDataUpdate=(e,t)=>{let i=e.entityId;if(!p(i)){let t=this._context.selectors.getComponentReaderIndexes().opticMap.get(c(i))?.get(e.componentInstance.componentType)?.get(e.componentInstance.instanceName);if(t?.kind==="simple"){let o=t.write(e.writableState);return{kind:"modifyDomainEntity",entityId:i,updateTag:e.updateTag,stateDelta:o,hint:e.hint,origin:e}}}let o=t.ephemeralRecords.find(t=>l(t.componentInstance,e.componentInstance));if(o)return{kind:"modifyEphemeralRecord",entityId:e.entityId,updateTag:e.updateTag,componentInstance:o.componentInstance,writableState:e.writableState,hint:e.hint};throw Error(`Component ${e.componentInstance.componentType.name} is not attached on entity #${e.entityId}`)};getNewState=(e,t)=>{let i=I(this.transformToDataUpdates(e,t),t);return f(this.rendered.isInitialized?this.rendered.value.state:t,i),i};applyTransformers(e,t,i){let o=this._context.environmentSelectors.getEnvironmentIsDev()?[]:void 0;return{transformedUpdates:this.transformPipe.reduce((e,{transformer:r,name:s})=>{let n,a=o?[]:void 0,d=a?(e,t,i)=>{n=e,a.push({phase:e,message:t,data:i})}:void 0,m=b(()=>r(e,t,i,d),r=>{this._context.domainServicesSelectors.getLogger().error("Error while applying transformer!",{name:s,updates:e,previousState:t,kind:i,transformationLog:o},r instanceof Error?r:Error(String(r)))});return a&&o&&o.push({name:s,status:n??(m===e?"no-event":"apply"),entries:a,updatesIn:e,updatesOut:m}),m},e),transformationLog:o}}_updateProjectedEntities(e,t,o){if(!e.validity.valid)return e;let r=this._context.selectors.getComponentReader().readManyComponents({componentTypes:[h]},e.state),s=g(e.previousState,k);if(s&&i(s,r))return e;let n=0,a=e,d=[];for(;a.validity.valid;){n++;let i=T(a.state.entities,r,t);if(0===i.length)break;if(n>10)throw Error(`Maximum number of reconciliation rounds reached: 10. Projected entities seem to be recursively depending on themselves.
1
+ import{CompositeKeyMap as e,assertExistence as t,isEqualArray as i}from"@salsita-ai/common/utils";import{dragStateComponent as o}from"../../components/drag-state-component.js";import{hoverStateComponent as r}from"../../components/hover-state-component.js";import{selectionStateComponent as s}from"../../components/selection-state-component.js";import{getComponentSystemFilterState as n}from"../../components/system-component-filter.js";import{systemVirtualEntityId as a}from"../../components/system-virtual-entity.js";import{systemUpdateFactory as d}from"../../components/updates.js";import{isSystemViewportStateComponentSnapshot as m}from"../../components/viewport-state-component.js";import{isEqualComponentInstance as l}from"../../core/component.js";import{domainEntityTypeFromId as c,isVirtualEntityId as p}from"../../core/model.js";import{projectedEntitiesComponent as h}from"../../system-components/index.js";import{cloneEvalCache as f,createEvalCacheToken as v,getEvalCache as g,setEvalCache as u}from"../../utils/eval-cache.js";import{createCascadeDeletesTransformer as y}from"../relation-transformers/cascade-deletes.js";import{createCascadeRefPruningTransformer as S}from"../relation-transformers/cascade-ref-pruning.js";import{applyUpdates as I}from"./apply-updates.js";import{LifecycleStateSlice as _}from"./lifecycle-state-slice.js";import{mergeReconciliationsUpdates as x,reconcileProjectedEntities as T}from"./reconcile-projected-entities.js";let E={uninitializedError:"StoreSystem is not initialized."},k=v({clone:e=>e}),w=class InvalidInitialStateError extends Error{emission;childError;constructor(e,t,i){let o="";"uncaught"===e.validity.severity&&(o=`: ${e.validity.error.message}`),("fatal"===e.validity.severity||"fixable"===e.validity.severity)&&(o=`: ${e.validity.entityViolations.map(e=>{let i=e.violation.message;return null!=i?t(i):e.violation.type}).join(", ")}`),super(`Initial state is not valid! Severity: ${e.validity.severity}, Cause: ${o}`),this.emission=e,this.childError=i,this.name="InvalidInitialStateError"}},b=(e,t)=>{try{return e()}catch(e){throw t(e),e}};export class StoreSystem{_context;stateSlices;get isInitialized(){return this.committed.isInitialized}_onBeforeCommitHooks=[];committed=new _(E);potentiallyInvalid=new _(E);rendered=new _(E);stagedUpdates=void 0;transformToDataUpdates=(e,t)=>{let i=!1,o=e.map(e=>"modifyComponent"===e.kind?(i=!0,this.componentModificationToDataUpdate(e,t)):e);return i?o:e};createInitialTransformPipe=()=>[{transformer:this.transformToDataUpdates,priority:1/0,registrationToken:{},name:"TransformToDataUpdates"}];transformPipe=this.createInitialTransformPipe();_cascadeDeletesTransformer=(...e)=>(this._cascadeDeletesTransformerMemo??=y(this._context.selectors.getCompositionProjections()))(...e);_cascadeDeletesTransformerMemo;_refPruningTransformer=(...e)=>(this._refPruningTransformerMemo??=S(this._context.selectors.getComponentReader()))(...e);_refPruningTransformerMemo;_deselectOnDeleteTransformer=(e,t)=>{let i=new Set(e.filter(e=>"deleteEntity"===e.kind).map(e=>e.entityId));if(0===i.size)return e;let o=n(t).selectedEntityId;return o&&i.has(o)?[...e,d.EphemeralRecordModification({componentInstance:{entityId:a,componentType:s},updateTag:"AutoDeselectRemovedProjectedEntity",writableState:{selectedEntityId:t.rootEntityId}})]:e};constructor(e){this._context=e,this.stateSlices={committed:this.committed.observable,rendered:this.rendered.observable,potentiallyInvalid:this.potentiallyInvalid.observable}}_validateState=e=>this._context.selectors.getValidationProjections().validateState(e);initialize=()=>{let e=this._context.selectors.getInitialDomainState();this.stagedUpdates=void 0;let t=this._validateState(e),i={kind:"reset",state:e,validity:t,tag:void 0,transformationLog:void 0},o=i;if(!o.validity.valid&&"fatal"===o.validity.severity||"fixable"===o.validity.severity){this._context.domainServicesSelectors.getLogger().debug("Trying to fix initial emission:",o);let e=o.state,{transformedUpdates:t,transformationLog:i}=this.applyTransformers([],e,"committed"),r=I(this.transformToDataUpdates(t,e),e);f(e,r),o={kind:"reset",state:r,validity:this._validateState(r),tag:"fixed",transformationLog:i}}if(!o.validity.valid){if(this._context.domainServicesSelectors.getLogger().error("Invalid initial emission:",{initialEmission:i,fixedEmission:o}),"uncaught"===o.validity.severity)throw new w(o,this._context.domainServicesSelectors.getResolveLocalizable(),o.validity.error??void 0);throw new w(o,this._context.domainServicesSelectors.getResolveLocalizable())}this.committed.next(o),this.rendered.next(o),this.potentiallyInvalid.next(o)};registerTransformer(e,i,o){let r={};return((e,i,o)=>{let r=0;for(;r<e.length&&0>=o(t(e[r]),i);)r++;e.splice(r,0,i)})(this.transformPipe,{registrationToken:r,transformer:i,priority:e,name:o},(e,t)=>e.priority===t.priority?0:e.priority<t.priority?-1:1),()=>{let e=this.transformPipe.findIndex(e=>e.registrationToken===r);-1!==e&&this.transformPipe.splice(e,1)}}onBeforeCommit(e){return this._onBeforeCommitHooks.push(e),()=>{this._onBeforeCommitHooks=this._onBeforeCommitHooks.filter(t=>t!==e)}}componentModificationToDataUpdate=(e,t)=>{let i=e.entityId;if(!p(i)){let t=this._context.selectors.getComponentReaderIndexes().opticMap.get(c(i))?.get(e.componentInstance.componentType)?.get(e.componentInstance.instanceName);if(t?.kind==="simple"){let o=t.write(e.writableState);return{kind:"modifyDomainEntity",entityId:i,updateTag:e.updateTag,stateDelta:o,hint:e.hint,agentHint:e.agentHint,origin:e}}}let o=t.ephemeralRecords.find(t=>l(t.componentInstance,e.componentInstance));if(o)return{kind:"modifyEphemeralRecord",entityId:e.entityId,updateTag:e.updateTag,componentInstance:o.componentInstance,writableState:e.writableState,hint:e.hint,agentHint:e.agentHint};throw Error(`Component ${e.componentInstance.componentType.name} is not attached on entity #${e.entityId}`)};getNewState=(e,t)=>{let i=I(this.transformToDataUpdates(e,t),t);return f(this.rendered.isInitialized?this.rendered.value.state:t,i),i};applyTransformers(e,t,i){let o=this._context.environmentSelectors.getEnvironmentIsDev()?[]:void 0;return{transformedUpdates:this.transformPipe.reduce((e,{transformer:r,name:s})=>{let n,a=o?[]:void 0,d=a?(e,t,i)=>{n=e,a.push({phase:e,message:t,data:i})}:void 0,m=b(()=>r(e,t,i,d),r=>{this._context.domainServicesSelectors.getLogger().error("Error while applying transformer!",{name:s,updates:e,previousState:t,kind:i,transformationLog:o},r instanceof Error?r:Error(String(r)))});return a&&o&&o.push({name:s,status:n??(m===e?"no-event":"apply"),entries:a,updatesIn:e,updatesOut:m}),m},e),transformationLog:o}}_updateProjectedEntities(e,t,o){if(!e.validity.valid)return e;let r=this._context.selectors.getComponentReader().readManyComponents({componentTypes:[h]},e.state),s=g(e.previousState,k);if(s&&i(s,r))return e;let n=0,a=e,d=[];for(;a.validity.valid;){n++;let i=T(a.state.entities,r,t);if(0===i.length)break;if(n>10)throw Error(`Maximum number of reconciliation rounds reached: 10. Projected entities seem to be recursively depending on themselves.
2
2
  If expressions populating 'projectedEntities' components rely on other projected entities, make sure that the dependencies do not have cycles.`);let s=(d=x(d,i)).map(e=>e.dataUpdate),m=this._cascadeDeletesTransformer(s,e.previousState,o,void 0,t),l=this._refPruningTransformer(m,e.previousState,o,void 0,t),c=this._deselectOnDeleteTransformer(l,e.previousState,o,void 0,t);if(!(a=this.prepareStateEmissionWithoutTransformation([...t,...c],e.previousState,o)).validity.valid)return this._context.domainServicesSelectors.getLogger().error("Reconciliation of projected entities led to an invalid state! Reconciliation skipped.",{emission:a}),e;r=this._context.selectors.getComponentReader().readManyComponents({componentTypes:[h]},a.state)}return u(a.state,k,r),a}prepareStateEmission(e,t,i){let{transformedUpdates:o,transformationLog:r}=this.applyTransformers(e,t,i),s=this.prepareStateEmissionWithoutTransformation(o,t,i);return{...this._updateProjectedEntities(s,o,i),transformationLog:r}}emissionCache=new e([Map,WeakMap,WeakMap,WeakMap,WeakMap]);getEmissionCacheKey=(e,t,i)=>[e,t,i,this._context.selectors.getStoreRuntimeDependencies(),this._context.selectors.getExpressionContext()];prepareStateEmissionWithoutTransformation=(e,t,i)=>{let o=this.getEmissionCacheKey(i,t,e),r=this.emissionCache.get(o);if(r)return r;let s=b(()=>this.transformToDataUpdates(e,t),o=>{this._context.domainServicesSelectors.getLogger().error("Error while transforming updates to data updates!",{updates:e,previousState:t,kind:i},o instanceof Error?o:Error(String(o)))}),n=b(()=>I(s,t),o=>{this._context.domainServicesSelectors.getLogger().error("Error while applying updates!",{updates:e,previousState:t,kind:i,dataUpdates:s},o instanceof Error?o:Error(String(o)))});f(this.rendered.isInitialized?this.rendered.value.state:t,n);let a=this._validateState(n);"uncaught"===a.severity&&this._context.domainServicesSelectors.getLogger().error("There was an uncaught validation error:",{updates:e,dataUpdates:s,previousState:t,newState:n,kind:i},a.error);let d={kind:i,previousState:t,state:n,updates:s,validity:a,transformationLog:void 0};return this.emissionCache.set(o,d),d};stage(e,t=!0){this.stagedUpdates=e;let i=this.prepareStateEmission(e,this.committed.value.state,"staged");return t&&this.emit(i),i}emit(e){"staged"===e.kind?e.validity.valid&&this.rendered.nextIfDifferent(e):(e.validity.valid?(this.committed.nextIfDifferent(e),this.rendered.nextIfDifferent(e)):this.rendered.nextIfDifferent(this.committed.value),this.potentiallyInvalid.nextIfDifferent(e))}commit=()=>{if(void 0===this.stagedUpdates)return;let e=this.prepareStateEmission(this.stagedUpdates,this.committed.value.state,"committed"),t=()=>{if(this._onBeforeCommitHooks.some(i=>!1===i(e,t))){this._context.domainServicesSelectors.getLogger().debug("Commit was canceled by one of the onBeforeCommit hooks! Resetting rendered state.",e),this.rollback();return}this.stagedUpdates=void 0,this._context.domainServicesSelectors.getLogger().debug("commit",e),this.emit(e)};t()};commitPrepared=e=>{if("committed"!==e.kind||!e.validity.valid)throw Error(`commitPrepared received a ${e.validity.valid?e.kind:"invalid"} emission, but only a valid committed emission can become the committed state. Prepare the emission with kind "committed" and check its validity before committing it.`);let t=()=>e.previousState===this.committed.value.state;if(!t())return"conflict";let i=()=>{t()?o():this._context.domainServicesSelectors.getLogger().warn("A held commit was dropped, because the committed state changed since it was prepared.",e)},o=()=>this._onBeforeCommitHooks.some(t=>!1===t(e,i))?(this._context.domainServicesSelectors.getLogger().debug("A prepared commit was held by one of the onBeforeCommit hooks.",e),!1):(this._context.domainServicesSelectors.getLogger().debug("commitPrepared",e),this.stagedUpdates=void 0,this.emit(e),!0);return o()?"committed":"held"};rollback=()=>{void 0!==this.stagedUpdates&&(this.stagedUpdates=void 0,this.emit(this.committed.value))};_resetInteractionState(e){return e.ephemeralRecords.some(e=>{let t;return(t=e.componentInstance.componentType)===r||t===o})?{...e,ephemeralRecords:e.ephemeralRecords.map(e=>e.componentInstance.componentType===r?{...e,state:{hoveredEntityId:null}}:e.componentInstance.componentType===o?{...e,state:{draggedEntityId:null}}:e)}:e}_preserveViewportState(e,t){let i=t.ephemeralRecords.find(m),o=e.ephemeralRecords.filter(e=>!m(e));return{...e,ephemeralRecords:i?[...o,i]:o}}reset(e,t){let i=this.committed.value.state,o=this._preserveViewportState(e,i),r=this._resetInteractionState(o),s=this._validateState(r);if(!s.valid)throw Error("Cannot reset to an invalid state");this.stagedUpdates=void 0,this.emit({kind:"reset",state:r,validity:s,tag:t,transformationLog:void 0})}stageAndCommit(e){if(0!==e.length){this.stagedUpdates=e;try{this.commit()}finally{this.stagedUpdates=void 0}}}}
@@ -4,7 +4,7 @@ import type { TransformerRegistration, UpdateTransformer } from '../store-system
4
4
  export type RegisterFunction<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string> = (domainContext: DomainContextSystems<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>, priority?: number) => TransformerRegistration<ENTITIES>;
5
5
  export type RegistrableTransformer<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string> = {
6
6
  /**
7
- * Creates a registration object consumed in `createTransformers` callback of the app config.
7
+ * Creates a registration object consumed by the runtime spec's `createTransformers` factory.
8
8
  */
9
9
  register: RegisterFunction<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>;
10
10
  };