@salsita-ai/sdk 0.50.0-develop.9feae4851f → 0.50.0-develop.a4dde5f252

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 (252) hide show
  1. package/README.md +2 -2
  2. package/dist/admin/create-admin-pages-from-spec.d.ts +1 -1
  3. package/dist/application-spec/generate-application/code/project-scaffolding.d.ts +1 -1
  4. package/dist/application-spec/generate-application/code/project-scaffolding.js +2 -2
  5. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.js +36 -36
  6. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-invariants.d.ts +1 -1
  7. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-invariants.js +1 -1
  8. package/dist/application-spec/generate-application/code/templates/domain.js +1 -1
  9. package/dist/application-spec/generate-application/code/templates/index.d.ts +0 -6
  10. package/dist/application-spec/generate-application/code/templates/index.js +1 -1
  11. package/dist/application-spec/generate-application/code/templates/package-json.js +1 -1
  12. package/dist/application-spec/generate-application/code/templates/skills/phoenix-create-configurator-skill.js +66 -42
  13. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +10 -12
  14. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +6 -8
  15. package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.js +1 -1
  16. package/dist/client/phoenix-api.d.ts +5 -3
  17. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +34 -1
  18. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
  19. package/dist/configurator/pages/DefaultConfiguratorLayout.d.ts +6 -0
  20. package/dist/configurator/pages/DefaultConfiguratorLayout.js +1 -0
  21. package/dist/configurator/pages/LoadedConfiguratorDetailPage.js +1 -1
  22. package/dist/docs/index.json +1 -1
  23. package/dist/docs/integrations/woocommerce/local-development.mdx +1 -1
  24. package/dist/docs/phoenix/configurator-interface.mdx +33 -6
  25. package/dist/docs/phoenix/expression-context.mdx +11 -3
  26. package/dist/docs/phoenix/getting-started.mdx +1 -1
  27. package/dist/docs/phoenix/phoenix-cli.mdx +17 -26
  28. package/dist/docs/phoenix/project-structure.mdx +5 -3
  29. package/dist/docs/phoenix/quickstart.mdx +2 -2
  30. package/dist/docs/phoenix/sdk-builder-workflow.mdx +2 -2
  31. package/dist/docs/phoenix/webhooks.mdx +1 -1
  32. package/dist/docs/ux-guidelines/choosing-a-control.mdx +11 -0
  33. package/dist/domain/admin-domain/implementation/common-admin-expressions.d.ts +10 -10
  34. package/dist/domain/admin-domain/index.d.ts +7 -2
  35. package/dist/domain/application/GetApplicationWrapperHandler.d.ts +1 -1
  36. package/dist/domain/application/GetThemeHandler.d.ts +1 -1
  37. package/dist/domain/application/GetWebComponentOptions.d.ts +1 -1
  38. package/dist/domain/application/admin-page-factories.d.ts +1 -2
  39. package/dist/domain/application/application-config.d.ts +3 -24
  40. package/dist/domain/application/assistant-mutations.d.ts +2 -1
  41. package/dist/domain/application/assistant-recipe-groups.d.ts +1 -1
  42. package/dist/domain/application/configurator-builder.d.ts +1 -1
  43. package/dist/domain/application/create-initial-published-data.d.ts +1 -2
  44. package/dist/domain/application/index.d.ts +1 -4
  45. package/dist/domain/application/index.js +1 -1
  46. package/dist/domain/application/published-data/DataRowValidatorHandler.d.ts +1 -1
  47. package/dist/domain/application/published-data/FilterPublishedChunksHandler.d.ts +1 -1
  48. package/dist/domain/application/published-data/MapPublishedChunkedDataHandler.d.ts +1 -1
  49. package/dist/domain/application/published-data/MapPublishedRevisionDataHandler.d.ts +1 -1
  50. package/dist/domain/application/published-data/SheetValidatorHandler.d.ts +1 -1
  51. package/dist/domain/application/published-data/build-legend-data.d.ts +1 -1
  52. package/dist/domain/application/published-data/format-field-type.d.ts +1 -1
  53. package/dist/domain/application/published-data/map-data-to-sheet.d.ts +1 -1
  54. package/dist/domain/application/published-data/map-published-chunked-data.d.ts +2 -2
  55. package/dist/domain/application/published-data/validate-sheet-data.d.ts +1 -1
  56. package/dist/domain/core/action/action-factory.d.ts +2 -2
  57. package/dist/domain/core/action/action.d.ts +19 -14
  58. package/dist/domain/core/component/domain-component-optic.d.ts +30 -40
  59. package/dist/domain/core/component/domain-component-optic.js +2 -2
  60. package/dist/domain/core/component/legacy-filter.d.ts +2 -17
  61. package/dist/domain/core/component/system-component-filter.d.ts +23 -18
  62. package/dist/domain/core/data-schema/data-cell-value.d.ts +4 -0
  63. package/dist/domain/core/data-schema/data-cell-value.js +1 -0
  64. package/dist/domain/core/data-schema/data-schema-array-field.d.ts +5 -0
  65. package/dist/domain/core/data-schema/data-schema-array-field.js +1 -0
  66. package/dist/domain/core/data-schema/data-schema-field-object.d.ts +4 -0
  67. package/dist/domain/core/data-schema/data-schema-field-object.js +1 -0
  68. package/dist/domain/core/data-schema/data-schema-field.d.ts +2 -0
  69. package/dist/domain/core/data-schema/data-schema-field.js +1 -0
  70. package/dist/domain/core/data-schema/data-schema-localized-field.d.ts +4 -0
  71. package/dist/domain/core/data-schema/data-schema-localized-field.js +1 -0
  72. package/dist/domain/core/data-schema/data-schema-primitive-field.d.ts +5 -0
  73. package/dist/domain/core/data-schema/data-schema-primitive-field.js +1 -0
  74. package/dist/domain/core/data-schema/data-schema.d.ts +2 -0
  75. package/dist/domain/core/data-schema/data-schema.js +1 -0
  76. package/dist/domain/core/data-schema/index.d.ts +7 -0
  77. package/dist/domain/core/data-schema/index.js +1 -0
  78. package/dist/domain/core/domain.d.ts +2 -2
  79. package/dist/domain/core/emission/index.d.ts +8 -0
  80. package/dist/domain/core/emission/index.js +1 -0
  81. package/dist/domain/core/emission/reset-state-emission.d.ts +12 -0
  82. package/dist/domain/core/emission/reset-state-emission.js +1 -0
  83. package/dist/domain/core/emission/state-emission.d.ts +4 -0
  84. package/dist/domain/core/emission/state-emission.js +1 -0
  85. package/dist/domain/core/emission/state-update-emission.d.ts +14 -0
  86. package/dist/domain/core/emission/state-update-emission.js +1 -0
  87. package/dist/domain/core/emission/state-validation-result.d.ts +18 -0
  88. package/dist/domain/core/emission/state-validation-result.js +1 -0
  89. package/dist/domain/core/emission/transformation-log.d.ts +2 -0
  90. package/dist/domain/core/emission/transformation-log.js +1 -0
  91. package/dist/domain/core/emission/transformer-log-entry.d.ts +6 -0
  92. package/dist/domain/core/emission/transformer-log-entry.js +1 -0
  93. package/dist/domain/core/emission/transformer-log.d.ts +11 -0
  94. package/dist/domain/core/emission/transformer-log.js +1 -0
  95. package/dist/domain/core/emission/transformer-phase.d.ts +1 -0
  96. package/dist/domain/core/emission/transformer-phase.js +1 -0
  97. package/dist/domain/core/expression/aliased-expressions.d.ts +2 -2
  98. package/dist/domain/core/expression/constant-expressions.d.ts +2 -2
  99. package/dist/domain/core/expression/constant-expressions.js +1 -1
  100. package/dist/domain/core/expression/custom-expression.d.ts +6 -6
  101. package/dist/domain/core/expression/custom-expression.js +1 -1
  102. package/dist/domain/core/expression/expression.d.ts +15 -17
  103. package/dist/domain/core/index.d.ts +2 -0
  104. package/dist/domain/core/invariant/custom-invariants.d.ts +5 -5
  105. package/dist/domain/core/invariant/index.d.ts +1 -1
  106. package/dist/domain/core/invariant/index.js +1 -1
  107. package/dist/domain/core/invariant/invariants.d.ts +4 -67
  108. package/dist/domain/core/invariant/invariants.js +1 -1
  109. package/dist/domain/core/invariant/violation.d.ts +1 -1
  110. package/dist/domain/core/relation/reference-component.d.ts +2 -2
  111. package/dist/domain/core/state/migrations.d.ts +14 -45
  112. package/dist/domain/core/state/migrations.js +1 -1
  113. package/dist/domain/domain-builder.d.ts +1 -1
  114. package/dist/domain/domain-builder.js +1 -1
  115. package/dist/domain/domain-context/action-system/action-system.d.ts +2 -2
  116. package/dist/domain/domain-context/action-system/action-system.js +1 -1
  117. package/dist/domain/domain-context/action-system/index.d.ts +1 -0
  118. package/dist/domain/domain-context/action-system/index.js +1 -0
  119. package/dist/domain/domain-context/analytics-system/index.d.ts +2 -0
  120. package/dist/domain/domain-context/analytics-system/index.js +1 -0
  121. package/dist/domain/domain-context/create-transformer.d.ts +1 -1
  122. package/dist/domain/domain-context/dimension-system/dimension-system.d.ts +2 -2
  123. package/dist/domain/domain-context/dimension-system/dimension-system.js +1 -1
  124. package/dist/domain/domain-context/dimension-system/index.d.ts +1 -0
  125. package/dist/domain/domain-context/dimension-system/index.js +1 -0
  126. package/dist/domain/domain-context/domain-context-systems.d.ts +7 -7
  127. package/dist/domain/domain-context/index.d.ts +8 -17
  128. package/dist/domain/domain-context/index.js +1 -1
  129. package/dist/domain/domain-context/navigation-system/index.d.ts +3 -0
  130. package/dist/domain/domain-context/navigation-system/index.js +1 -0
  131. package/dist/domain/domain-context/navigation-system/navigation-system.d.ts +2 -3
  132. package/dist/domain/domain-context/navigation-system/navigation-system.js +1 -1
  133. package/dist/domain/domain-context/navigation-system/selection-transformers.d.ts +1 -1
  134. package/dist/domain/domain-context/recipe-system/index.d.ts +1 -0
  135. package/dist/domain/domain-context/recipe-system/index.js +1 -0
  136. package/dist/domain/domain-context/recipe-system/recipe-cooker-system.d.ts +1 -1
  137. package/dist/domain/domain-context/recipe-system/recipe-cooker-system.js +1 -1
  138. package/dist/domain/domain-context/relation-transformers/cascade-deletes.d.ts +2 -2
  139. package/dist/domain/domain-context/relation-transformers/cascade-ref-pruning.d.ts +2 -2
  140. package/dist/domain/domain-context/relation-transformers/create-entity-refs.d.ts +2 -2
  141. package/dist/domain/domain-context/relation-transformers/index.d.ts +4 -0
  142. package/dist/domain/domain-context/relation-transformers/index.js +1 -0
  143. package/dist/domain/domain-context/relation-transformers/replace-refs.d.ts +2 -2
  144. package/dist/domain/domain-context/store-system/index.d.ts +4 -0
  145. package/dist/domain/domain-context/store-system/index.js +1 -0
  146. package/dist/domain/domain-context/store-system/reconcile-projected-entities.js +1 -1
  147. package/dist/domain/domain-context/store-system/store-system.d.ts +2 -35
  148. package/dist/domain/domain-context/store-system/store-system.js +2 -2
  149. package/dist/domain/domain-context/store-system/system-state.d.ts +1 -1
  150. package/dist/domain/domain-context/transformers/actions-builder.js +1 -1
  151. package/dist/domain/domain-context/transformers/auto-snap-transformer.d.ts +5 -7
  152. package/dist/domain/domain-context/transformers/auto-snap-transformer.js +1 -1
  153. package/dist/domain/domain-context/transformers/chain-builder.d.ts +1 -1
  154. package/dist/domain/domain-context/transformers/context.d.ts +2 -3
  155. package/dist/domain/domain-context/transformers/context.js +1 -1
  156. package/dist/domain/domain-context/transformers/entity-builder.js +1 -1
  157. package/dist/domain/domain-context/transformers/index.d.ts +1 -1
  158. package/dist/domain/domain-context/transformers/index.js +1 -1
  159. package/dist/domain/domain-context/transformers/when-builder.d.ts +2 -3
  160. package/dist/domain/domain-context/transformers/when-builder.js +1 -1
  161. package/dist/domain/domain-context/undo-system.d.ts +2 -3
  162. package/dist/domain/domain-runtime/domain-context/action-context.d.ts +11 -0
  163. package/dist/domain/domain-runtime/domain-context/action-context.js +1 -0
  164. package/dist/domain/domain-runtime/domain-context/domain-context.js +1 -1
  165. package/dist/domain/domain-runtime/domain-context/expression-context.d.ts +8 -0
  166. package/dist/domain/domain-runtime/domain-context/expression-context.js +1 -0
  167. package/dist/domain/domain-runtime/domain-context/index.d.ts +3 -0
  168. package/dist/domain/domain-runtime/domain-context/runtime-expression-context.d.ts +18 -0
  169. package/dist/domain/domain-runtime/domain-context/runtime-expression-context.js +1 -0
  170. package/dist/domain/domain-runtime/domain-context/selectors.d.ts +5 -10
  171. package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
  172. package/dist/domain/domain-runtime/domain-runtime.d.ts +52 -52
  173. package/dist/domain/domain-runtime/spec/index.d.ts +2 -0
  174. package/dist/domain/domain-runtime/spec/index.js +1 -1
  175. package/dist/domain/domain-runtime/spec/initialize.js +1 -1
  176. package/dist/domain/domain-runtime/spec/invariant-builder.d.ts +26 -0
  177. package/dist/domain/domain-runtime/spec/invariant-builder.js +1 -0
  178. package/dist/domain/{application → domain-runtime/spec/module-checks}/element-registration.d.ts +2 -2
  179. package/dist/domain/domain-runtime/spec/module-checks/element-registration.js +1 -0
  180. package/dist/domain/{application → domain-runtime/spec/module-checks}/handler-registration.d.ts +1 -1
  181. package/dist/domain/domain-runtime/spec/module-checks/handler-registration.js +1 -0
  182. package/dist/domain/domain-runtime/spec/module-checks/index.d.ts +8 -0
  183. package/dist/domain/domain-runtime/spec/module-checks/index.js +1 -0
  184. package/dist/domain/{project-modules → domain-runtime/spec/module-checks}/project-modules.d.ts +0 -16
  185. package/dist/domain/domain-runtime/spec/module-checks/project-modules.js +1 -0
  186. package/dist/domain/domain-runtime/spec/module-checks/resolve-action-modules.d.ts +4 -0
  187. package/dist/domain/domain-runtime/spec/module-checks/resolve-action-modules.js +1 -0
  188. package/dist/domain/domain-runtime/spec/module-checks/resolve-component-optic-modules.d.ts +4 -0
  189. package/dist/domain/domain-runtime/spec/module-checks/resolve-component-optic-modules.js +1 -0
  190. package/dist/domain/domain-runtime/spec/module-checks/resolve-expression-modules.d.ts +15 -0
  191. package/dist/domain/domain-runtime/spec/module-checks/resolve-expression-modules.js +1 -0
  192. package/dist/domain/{application → domain-runtime/spec/module-checks}/resolve-imported-transformers.d.ts +4 -5
  193. package/dist/domain/domain-runtime/spec/module-checks/resolve-imported-transformers.js +1 -0
  194. package/dist/domain/domain-runtime/spec/module-checks/resolve-invariant-modules.d.ts +6 -0
  195. package/dist/domain/domain-runtime/spec/module-checks/resolve-invariant-modules.js +1 -0
  196. package/dist/domain/domain-runtime/spec/selectors.d.ts +5 -6
  197. package/dist/domain/domain-runtime/spec/selectors.js +1 -1
  198. package/dist/domain/domain-runtime/spec/types.d.ts +3 -2
  199. package/dist/domain/index.d.ts +0 -1
  200. package/dist/domain/index.js +1 -1
  201. package/dist/domain/mocks/create-mock-domain-runtime-services.d.ts +1 -1
  202. package/dist/domain/mocks/create-mock-domain-runtime.d.ts +10 -10
  203. package/dist/domain/projections/blender-projections/blender-projections.d.ts +1 -2
  204. package/dist/domain/projections/blender-projections/camera.d.ts +1 -1
  205. package/dist/domain/projections/collision-projections.d.ts +1 -1
  206. package/dist/domain/projections/composition-projections.d.ts +1 -1
  207. package/dist/domain/projections/constraint-projections.d.ts +1 -1
  208. package/dist/domain/projections/index.d.ts +1 -1
  209. package/dist/domain/projections/position-projections.d.ts +1 -1
  210. package/dist/domain/projections/projected-entities-projections.d.ts +1 -1
  211. package/dist/domain/projections/snapping-projections.d.ts +1 -1
  212. package/dist/domain/projections/validation-projections.d.ts +3 -19
  213. package/dist/domain/sketching/sketching-projections.d.ts +1 -1
  214. package/dist/domain/system-components/phoenix-entity-elements/admin-data-table-sidebar.d.ts +1 -1
  215. package/dist/domain/system-components/phoenix-layout-elements/admin-connected-resource-page.d.ts +1 -1
  216. package/dist/domain/system-components/phoenix-layout-elements/admin-data-table-actions.d.ts +1 -1
  217. package/dist/domain/system-components/phoenix-layout-elements/admin-data-table-page.d.ts +1 -1
  218. package/dist/domain/utils/memo-eval.d.ts +2 -2
  219. package/dist/legacy/domain-cli/gen/constant-expressions.js +1 -3
  220. package/dist/legacy/domain-cli/gen/implementation.js +7 -11
  221. package/dist/legacy/domain-cli/gen/invariants.js +5 -3
  222. package/dist/legacy/domain-cli/utils/cache.d.ts +1 -1
  223. package/dist/legacy/domain-cli/utils/cache.js +1 -1
  224. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/claude-md.d.ts +1 -1
  225. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/cursor-rules.d.ts +1 -1
  226. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.d.ts +1 -1
  227. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.js +1 -0
  228. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/domain-index.js +4 -4
  229. package/dist/phoenix/commands/init.d.ts +4 -4
  230. package/dist/phoenix/commands/init.js +1 -1
  231. package/dist/phoenix/commands/prettier.js +1 -1
  232. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +20 -20
  233. package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +5 -5
  234. package/package.json +3 -3
  235. package/dist/application-spec/generate-application/code/templates/env-ci.d.ts +0 -1
  236. package/dist/application-spec/generate-application/code/templates/env-ci.js +0 -25
  237. package/dist/application-spec/generate-application/code/templates/env-example.d.ts +0 -1
  238. package/dist/application-spec/generate-application/code/templates/env-example.js +0 -94
  239. package/dist/application-spec/generate-application/code/templates/private-assets-readme.d.ts +0 -1
  240. package/dist/application-spec/generate-application/code/templates/private-assets-readme.js +0 -24
  241. package/dist/application-spec/generate-application/code/templates/public-assets-readme.d.ts +0 -1
  242. package/dist/application-spec/generate-application/code/templates/public-assets-readme.js +0 -24
  243. package/dist/application-spec/generate-application/code/templates/readme.d.ts +0 -1
  244. package/dist/application-spec/generate-application/code/templates/readme.js +0 -23
  245. package/dist/application-spec/generate-application/code/templates/skills/agents-md.d.ts +0 -1
  246. package/dist/application-spec/generate-application/code/templates/skills/agents-md.js +0 -2
  247. package/dist/domain/application/element-registration.js +0 -1
  248. package/dist/domain/application/handler-registration.js +0 -1
  249. package/dist/domain/application/resolve-imported-transformers.js +0 -1
  250. package/dist/domain/project-modules/index.d.ts +0 -1
  251. package/dist/domain/project-modules/index.js +0 -1
  252. package/dist/domain/project-modules/project-modules.js +0 -1
@@ -1,11 +1,12 @@
1
1
  import type { SessionRole } from '@salsita-ai/contracts/api';
2
- import type { ComponentReader } from '../../domain-runtime/domain-context/index.js';
3
- import type { CollisionProjections, ConstraintProjections, PositionProjections, ProjectedEntitiesProjections, SnappingProjections } from '../../projections/index.js';
4
- import type { SketchingProjections } from '../../sketching/index.js';
5
2
  import type { Domain } from '../domain.js';
6
- import type { $DomainEntity, DomainEntity, TypeOrAlias } from '../model/index.js';
3
+ import type { $DomainEntity, DomainEntity } from '../model/index.js';
7
4
  import type { DomainState, MigrateFunction } from '../state/index.js';
8
- export interface ExpressionContext<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>> {
5
+ /**
6
+ * The part of the expression context that core declares: the mode and role of the session, the data
7
+ * of the application, the entity view and the migration of the model.
8
+ */
9
+ export interface CoreExpressionContext<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>> {
9
10
  readonly mode: 'owner' | 'read' | 'finalize';
10
11
  readonly role: SessionRole;
11
12
  readonly publishedData: PUBLISHED_DATA;
@@ -13,23 +14,20 @@ export interface ExpressionContext<ENTITIES extends DomainEntity<string>, ALLOWE
13
14
  readonly backendData: Record<string, unknown> | undefined;
14
15
  readonly sessionData: SESSION_DATA;
15
16
  readonly domain: Domain<ENTITIES, ALLOWED_ROOT_ENTITIES, Record<ENTITIES['type'], $DomainEntity<ENTITIES>>>;
16
- readonly componentReader: ComponentReader<ENTITIES>;
17
17
  readonly migrate: MigrateFunction<ENTITIES>;
18
- readonly positionProjections: PositionProjections<ENTITIES>;
19
- readonly sketchingProjections: SketchingProjections<ENTITIES>;
20
- readonly collisionProjections: CollisionProjections<ENTITIES>;
21
- readonly constraintProjections: ConstraintProjections<ENTITIES>;
22
- readonly snappingProjections: SnappingProjections<ENTITIES>;
23
- readonly projectedEntitiesProjections: ProjectedEntitiesProjections<ENTITIES>;
24
18
  }
25
- export type AnyExpressionContext = ExpressionContext<any, any, any, any, any>;
19
+ /**
20
+ * The context an expression is evaluated in. Core declares its own part; `CONTEXT_EXTENSION` is
21
+ * what whoever evaluates the expression adds to it, such as the component reader and the
22
+ * projections of the domain runtime. An expression that reads only core's part leaves it out.
23
+ */
24
+ export type OpenExpressionContext<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>, CONTEXT_EXTENSION = unknown> = CoreExpressionContext<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA> & CONTEXT_EXTENSION;
26
25
  export interface ExpressionMeta {
27
26
  /**
28
27
  * By enabling this flag, expression will be run during validation. It is primarily used to check validity of relations.
29
28
  */
30
29
  readonly alwaysEvaluate?: boolean;
31
30
  }
32
- export type ExpressionMetas<ENTITIES extends DomainEntity<string>, ALIASES extends Record<string, ENTITIES>> = Partial<Record<TypeOrAlias<ENTITIES, ALIASES>, Record<string, ExpressionMeta>>>;
33
31
  /**
34
32
  * Metadata used for debugging of expression exceptions.
35
33
  */
@@ -37,11 +35,11 @@ export interface ExpressionOrigin {
37
35
  readonly typeOrAlias: string;
38
36
  readonly name: string;
39
37
  }
40
- export interface AnonymousExpression<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>, SELF extends ENTITIES, T> {
41
- evaluate(selfId: SELF['id'], state: DomainState<ENTITIES>, ctx: ExpressionContext<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>): T;
38
+ export interface AnonymousExpression<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>, SELF extends ENTITIES, T, CONTEXT_EXTENSION = unknown> {
39
+ evaluate(selfId: SELF['id'], state: DomainState<ENTITIES>, ctx: OpenExpressionContext<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, CONTEXT_EXTENSION>): T;
42
40
  readonly meta: ExpressionMeta;
43
41
  }
44
- export interface Expression<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>, SELF extends ENTITIES, T> extends AnonymousExpression<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, SELF, T> {
42
+ export interface Expression<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>, SELF extends ENTITIES, T, CONTEXT_EXTENSION = unknown> extends AnonymousExpression<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, SELF, T, CONTEXT_EXTENSION> {
45
43
  readonly origin: ExpressionOrigin;
46
44
  }
47
45
  export type AnyExpression = Expression<any, any, any, any, any, any, any>;
@@ -1,8 +1,10 @@
1
1
  export * from './action/index.js';
2
2
  export * from './component/index.js';
3
+ export type * from './data-schema/index.js';
3
4
  export * from './decoder/index.js';
4
5
  export * from './domain-factory.js';
5
6
  export * from './domain.js';
7
+ export type * from './emission/index.js';
6
8
  export * from './expression/index.js';
7
9
  export * from './invariant/index.js';
8
10
  export * from './model/index.js';
@@ -3,9 +3,9 @@ import type { CustomExpression } from '../expression/index.js';
3
3
  import type { $DomainEntity, DomainEntity, ExpandAlias, TypeOrAlias } from '../model/index.js';
4
4
  import type { Invariant } from './invariants.js';
5
5
  import type { Violation } from './violation.js';
6
- export type CustomInvariantsFromBlueprints<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>, BLUEPRINTS extends Partial<Record<keyof $MAP & string, Record<string, boolean | string>>>> = {
6
+ export type CustomInvariantsFromBlueprints<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>, BLUEPRINTS extends Partial<Record<keyof $MAP & string, Record<string, boolean | string>>>, CONTEXT_EXTENSION = unknown> = {
7
7
  [TYPE_OR_ALIAS in keyof BLUEPRINTS]: {
8
- [NAME in keyof BLUEPRINTS[TYPE_OR_ALIAS]]: TYPE_OR_ALIAS extends keyof $MAP ? CustomExpression<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, $MAP[TYPE_OR_ALIAS], BLUEPRINTS[TYPE_OR_ALIAS][NAME] extends string ? ReadonlyArray<Violation<BLUEPRINTS[TYPE_OR_ALIAS][NAME]>> : BLUEPRINTS[TYPE_OR_ALIAS][NAME]> : never;
8
+ [NAME in keyof BLUEPRINTS[TYPE_OR_ALIAS]]: TYPE_OR_ALIAS extends keyof $MAP ? CustomExpression<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, $MAP[TYPE_OR_ALIAS], BLUEPRINTS[TYPE_OR_ALIAS][NAME] extends string ? ReadonlyArray<Violation<BLUEPRINTS[TYPE_OR_ALIAS][NAME]>> : BLUEPRINTS[TYPE_OR_ALIAS][NAME], CONTEXT_EXTENSION> : never;
9
9
  };
10
10
  };
11
11
  export type StaticallyDefinedViolations<ENTITIES extends DomainEntity<string>, ALIASES extends Record<string, ENTITIES>, BLUEPRINTS extends Partial<Record<TypeOrAlias<ENTITIES, ALIASES>, Record<string, boolean | string>>>> = OmitEmpty<{
@@ -13,9 +13,9 @@ export type StaticallyDefinedViolations<ENTITIES extends DomainEntity<string>, A
13
13
  [NAME in keyof BLUEPRINTS[TYPE_OR_ALIAS]]: BLUEPRINTS[TYPE_OR_ALIAS][NAME] extends boolean ? Violation<string> : never;
14
14
  }>;
15
15
  }>;
16
- export type InvariantsFromBlueprints<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>, BLUEPRINTS extends Partial<Record<TypeOrAlias<ENTITIES, ALIASES>, Record<string, boolean | string>>>, STATIC_VIOLATIONS extends StaticallyDefinedViolations<ENTITIES, ALIASES, BLUEPRINTS>, PICK extends keyof BLUEPRINTS = keyof BLUEPRINTS> = {
16
+ export type InvariantsFromBlueprints<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>, BLUEPRINTS extends Partial<Record<TypeOrAlias<ENTITIES, ALIASES>, Record<string, boolean | string>>>, STATIC_VIOLATIONS extends StaticallyDefinedViolations<ENTITIES, ALIASES, BLUEPRINTS>, PICK extends keyof BLUEPRINTS = keyof BLUEPRINTS, CONTEXT_EXTENSION = unknown> = {
17
17
  readonly [TYPE_OR_ALIAS in keyof BLUEPRINTS & string & PICK]: ReadonlyArray<{
18
- [NAME in keyof BLUEPRINTS[TYPE_OR_ALIAS]]: Invariant<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ExpandAlias<ENTITIES, ALIASES, TYPE_OR_ALIAS>, BLUEPRINTS[TYPE_OR_ALIAS][NAME] extends boolean ? TYPE_OR_ALIAS extends keyof STATIC_VIOLATIONS ? NAME extends keyof STATIC_VIOLATIONS[TYPE_OR_ALIAS] ? STATIC_VIOLATIONS[TYPE_OR_ALIAS][NAME]['type'] : never : never : BLUEPRINTS[TYPE_OR_ALIAS][NAME] extends string ? BLUEPRINTS[TYPE_OR_ALIAS][NAME] : never>;
18
+ [NAME in keyof BLUEPRINTS[TYPE_OR_ALIAS]]: Invariant<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ExpandAlias<ENTITIES, ALIASES, TYPE_OR_ALIAS>, BLUEPRINTS[TYPE_OR_ALIAS][NAME] extends boolean ? TYPE_OR_ALIAS extends keyof STATIC_VIOLATIONS ? NAME extends keyof STATIC_VIOLATIONS[TYPE_OR_ALIAS] ? STATIC_VIOLATIONS[TYPE_OR_ALIAS][NAME]['type'] : never : never : BLUEPRINTS[TYPE_OR_ALIAS][NAME] extends string ? BLUEPRINTS[TYPE_OR_ALIAS][NAME] : never, CONTEXT_EXTENSION>;
19
19
  }[keyof BLUEPRINTS[TYPE_OR_ALIAS]]>;
20
20
  };
21
- export declare const createCustomInvariantFactory: <ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<TypeOrAlias<ENTITIES, ALIASES>, $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>, BLUEPRINTS extends Partial<Record<TypeOrAlias<ENTITIES, ALIASES>, Record<string, boolean | string>>>>() => <STATIC_VIOLATIONS extends StaticallyDefinedViolations<ENTITIES, ALIASES, BLUEPRINTS>>(staticViolations: STATIC_VIOLATIONS) => <TYPES_OR_ALIASES extends keyof BLUEPRINTS & string>(implementations: Pick<CustomInvariantsFromBlueprints<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, BLUEPRINTS>, TYPES_OR_ALIASES>) => InvariantsFromBlueprints<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES, BLUEPRINTS, STATIC_VIOLATIONS, TYPES_OR_ALIASES>;
21
+ export declare const createCustomInvariantFactory: <ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<TypeOrAlias<ENTITIES, ALIASES>, $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>, BLUEPRINTS extends Partial<Record<TypeOrAlias<ENTITIES, ALIASES>, Record<string, boolean | string>>>, CONTEXT_EXTENSION = unknown>() => <STATIC_VIOLATIONS extends StaticallyDefinedViolations<ENTITIES, ALIASES, BLUEPRINTS>>(staticViolations: STATIC_VIOLATIONS) => <TYPES_OR_ALIASES extends keyof BLUEPRINTS & string>(implementations: Pick<CustomInvariantsFromBlueprints<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, BLUEPRINTS, CONTEXT_EXTENSION>, TYPES_OR_ALIASES>) => InvariantsFromBlueprints<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES, BLUEPRINTS, STATIC_VIOLATIONS, TYPES_OR_ALIASES, CONTEXT_EXTENSION>;
@@ -1,5 +1,5 @@
1
1
  export * from './builtin-invariant.js';
2
2
  export * from './custom-invariants.js';
3
- export * from './invariants.js';
3
+ export type * from './invariants.js';
4
4
  export * from './violation-component.js';
5
5
  export * from './violation.js';
@@ -1 +1 @@
1
- export*from"./builtin-invariant.js";export*from"./custom-invariants.js";export*from"./invariants.js";export*from"./violation-component.js";export*from"./violation.js";
1
+ export*from"./builtin-invariant.js";export*from"./custom-invariants.js";export*from"./violation-component.js";export*from"./violation.js";
@@ -1,11 +1,9 @@
1
- import type { OmitNever } from '@salsita-ai/common/utils';
2
- import { type ProjectModule } from '../../project-modules/index.js';
3
- import type { AnonymousExpression, ExpressionContext } from '../expression/index.js';
4
- import { type $DomainEntity, type AliasMap, type DomainEntity, type EntityByType, type EventualAlias, type ExpandAlias, type ExtractFromAliasedRecord, type TypeOrAlias } from '../model/index.js';
1
+ import type { OpenExpressionContext } from '../expression/index.js';
2
+ import type { $DomainEntity, DomainEntity, ExpandAlias, TypeOrAlias } from '../model/index.js';
5
3
  import type { DomainState } from '../state/index.js';
6
4
  import { type Violation } from './violation.js';
7
- export interface Invariant<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, VIOLATION_TYPE extends string> {
8
- evaluate(selfId: ENTITY['id'], state: DomainState<ENTITIES>, ctx: ExpressionContext<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>): ReadonlyArray<Violation<VIOLATION_TYPE>>;
5
+ export interface Invariant<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, VIOLATION_TYPE extends string, CONTEXT_EXTENSION = unknown> {
6
+ evaluate(selfId: ENTITY['id'], state: DomainState<ENTITIES>, ctx: OpenExpressionContext<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, CONTEXT_EXTENSION>): ReadonlyArray<Violation<VIOLATION_TYPE>>;
9
7
  }
10
8
  export type AliasedInvariants<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>, VIOLATION_TYPES extends string> = {
11
9
  [K in TypeOrAlias<ENTITIES, ALIASES>]?: ReadonlyArray<Invariant<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ExpandAlias<ENTITIES, ALIASES, K>, VIOLATION_TYPES>>;
@@ -13,64 +11,3 @@ export type AliasedInvariants<ENTITIES extends DomainEntity<string>, ALLOWED_ROO
13
11
  export type DeclaredInvariants<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>> = {
14
12
  readonly [TYPE in ENTITIES['type']]: '$violations' extends keyof $MAP[TYPE] ? $MAP[TYPE]['$violations'] extends () => ReadonlyArray<Violation<infer VIOLATION_TYPE>> ? ReadonlyArray<Invariant<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITIES, VIOLATION_TYPE>> : never : never;
15
13
  };
16
- type ConflictingInvariants<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>, EXPECTED extends Partial<Record<ENTITIES['type'], ReadonlyArray<Invariant<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITIES, string>>>>, IMPLEMENTED extends Partial<Record<ENTITIES['type'], ReadonlyArray<Invariant<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITIES, string>>>>> = OmitNever<{
17
- [K in keyof EXPECTED]: EXPECTED[K] extends [never] ? never : K extends keyof IMPLEMENTED ? ViolationTypeOfInvariants<EXPECTED[K]> extends ViolationTypeOfInvariants<IMPLEMENTED[K]> ? ViolationTypeOfInvariants<IMPLEMENTED[K]> extends ViolationTypeOfInvariants<EXPECTED[K]> ? never : {
18
- missing: Exclude<ViolationTypeOfInvariants<EXPECTED[K]>, ViolationTypeOfInvariants<IMPLEMENTED[K]>>;
19
- extra: Exclude<ViolationTypeOfInvariants<IMPLEMENTED[K]>, ViolationTypeOfInvariants<EXPECTED[K]>>;
20
- } : {
21
- missing: Exclude<ViolationTypeOfInvariants<EXPECTED[K]>, ViolationTypeOfInvariants<IMPLEMENTED[K]>>;
22
- extra: Exclude<ViolationTypeOfInvariants<IMPLEMENTED[K]>, ViolationTypeOfInvariants<EXPECTED[K]>>;
23
- } : {
24
- missing: ViolationTypeOfInvariants<EXPECTED[K]>;
25
- extra: never;
26
- };
27
- }>;
28
- type ViolationOfInvariants<INVARIANTS> = INVARIANTS extends ReadonlyArray<infer INVARIANT> ? INVARIANT : never;
29
- type ViolationTypeOfInvariants<INVARIANTS> = ViolationOfInvariants<INVARIANTS> extends Invariant<any, any, any, any, any, any, infer VIOLATION_TYPE> ? VIOLATION_TYPE : never;
30
- type ExpandAndMergeInvariants<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 Readonly<Record<string, ENTITIES>>, EXPANDED extends Partial<Record<ENTITIES['type'], ReadonlyArray<Invariant<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITIES, string>>>>, ALIASED extends Partial<Record<TypeOrAlias<ENTITIES, ALIASES>, ReadonlyArray<Invariant<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITIES, string>>>>> = {
31
- [K in keyof EXPANDED | ExpandAlias<ENTITIES, ALIASES, keyof ALIASED & string>['type']]: K extends ENTITIES['type'] ? ExtractFromAliasedRecord<ENTITIES, ALIASES, ALIASED, EventualAlias<ENTITIES, ALIASES, K> | K> extends infer INVARIANTS_FROM_ALIAS ? [
32
- INVARIANTS_FROM_ALIAS
33
- ] extends [never] ? K extends keyof EXPANDED ? EXPANDED[K] : never : K extends keyof EXPANDED ? ReadonlyArray<ViolationOfInvariants<EXPANDED[K]> | ViolationOfInvariants<INVARIANTS_FROM_ALIAS>> : ReadonlyArray<ViolationOfInvariants<INVARIANTS_FROM_ALIAS>> : never : never;
34
- };
35
- type ExpressionsFromInvariants<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>, INVARIANTS extends Partial<Record<ENTITIES['type'], ReadonlyArray<Invariant<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITIES, string>>>>> = {
36
- [K in keyof INVARIANTS & ENTITIES['type']]: {
37
- $violations: AnonymousExpression<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, EntityByType<ENTITIES, K>, ReadonlyArray<Violation<INVARIANTS[K] extends ReadonlyArray<infer ELEMENT> ? ELEMENT extends Invariant<any, any, any, any, any, any, infer VIOLATION_TYPE> ? VIOLATION_TYPE : never : never>>>;
38
- };
39
- };
40
- type BuildViolationExpressions<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>, INVARIANTS extends Partial<Record<ENTITIES['type'], ReadonlyArray<Invariant<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITIES, string>>>>> = Record<never, never> extends ConflictingInvariants<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, DeclaredInvariants<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>, INVARIANTS> ? () => ExpressionsFromInvariants<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, INVARIANTS> : never;
41
- type AnyInvariant = Invariant<any, any, any, any, any, any, string>;
42
- /** Validates the `src/invariants/` files and concatenates their invariants per entity type or alias. */
43
- export declare const resolveInvariantModules: (modules: readonly ProjectModule[]) => Readonly<Record<string, readonly AnyInvariant[]>>;
44
- export declare class InvariantBuilder<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>, INVARIANTS extends Partial<Record<ENTITIES['type'], ReadonlyArray<Invariant<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITIES, string>>>> = Record<never, never>> {
45
- private readonly aliasMap;
46
- private readonly invariants;
47
- constructor(aliasMap: AliasMap<ALIASES>, invariants?: INVARIANTS);
48
- /**
49
- * Adds the invariants of the `src/invariants/` files, as the generated barrel lists them, after
50
- * checking each file against the folder's contract.
51
- */
52
- withInvariantModules(modules: readonly ProjectModule[]): InvariantBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES, ExpandAndMergeInvariants<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES, INVARIANTS, AliasedInvariants<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES, string>>>;
53
- withInvariants<ALIASED_INVARIANTS extends AliasedInvariants<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES, string>>(aliasedInvariants: ALIASED_INVARIANTS): InvariantBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES, ExpandAndMergeInvariants<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES, INVARIANTS, ALIASED_INVARIANTS>>;
54
- /**
55
- * DO NOT USE in runtime!
56
- *
57
- * This is just a dev-time to review conflicts in declared and actually reportable violations.
58
- * Use your IDEs code-completion to see which entities have conflicts and which violations are the conflicting ones.
59
- *
60
- * Use the helper when you see the following error on the `.buildViolationExpressions()` method call:
61
- * ```
62
- * TS2349: This expression is not callable.
63
- * Type never has no call signatures.
64
- * ```
65
- * simply
66
- * ```ts
67
- * const violationExpressions = invariantBuilder
68
- * .withInvariants(createBuiltinInvariants(domainComponentReader))
69
- * .withInvariants(kitchenRangeInvariants)
70
- * ._conflicts.Oven. // <- trigger code-completion here
71
- * ```
72
- */
73
- _conflicts: ConflictingInvariants<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, DeclaredInvariants<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>, INVARIANTS>;
74
- buildViolationExpressions: BuildViolationExpressions<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, INVARIANTS>;
75
- }
76
- export {};
@@ -1 +1 @@
1
- import{SHARED_FOLDER_HINT as t,createContractError as e,isRecord as a}from"../../project-modules/index.js";import{expandAlias as i}from"../model/index.js";let r={expected:"an object of invariant lists keyed by entity type or alias",fix:`Create it with phx.domain.implementCustomInvariants({ ... }) (phx.domain.admin.implementCustomInvariants({ ... }) under src/admin/), ${t}.`},n=t=>a(t)&&"function"==typeof t.evaluate,s=t=>a(t)&&Object.values(t).every(t=>Array.isArray(t)&&t.every(n));export const resolveInvariantModules=t=>{let a={};for(let i of t){if(!s(i.exports))throw e(i.origin,r,i.exports);for(let[t,e]of Object.entries(i.exports))a[t]=[...a[t]??[],...e]}return a};export class InvariantBuilder{aliasMap;invariants;constructor(t,e={}){this.aliasMap=t,this.invariants=e}withInvariantModules(t){return this.withInvariants(resolveInvariantModules(t))}withInvariants(t){let e={...this.invariants};return Object.entries(t).forEach(([t,a])=>{i(this.aliasMap,t).forEach(t=>{e[t]=[...e[t]??[],...a]})}),new InvariantBuilder(this.aliasMap,e)}_conflicts={};buildViolationExpressions=()=>{let t={};return Object.entries(this.invariants).forEach(([e,a])=>{t[e]={$violations:{evaluate:(t,e,i)=>a.flatMap(a=>a.evaluate(t,e,i)),meta:{}}}}),t}}
1
+ export{};
@@ -1,6 +1,6 @@
1
1
  import type { I18n } from '@lingui/core';
2
2
  import type { Localizable } from '@salsita-ai/common/utils';
3
- import type { StateEmission } from '../../domain-context/store-system/store-system.js';
3
+ import type { StateEmission } from '../emission/index.js';
4
4
  import type { $DomainEntity, DomainEntity, EntityId } from '../model/index.js';
5
5
  /**
6
6
  * An **ORDERED** list of violation severities.
@@ -13,5 +13,5 @@ export type ReferenceComponentState = {
13
13
  */
14
14
  export declare const referenceComponent: import("../index.js").SystemComponentType<"reference", ReferenceComponentState, "referencedEntityIds">;
15
15
  export type ReferenceComponent = typeof referenceComponent;
16
- export declare const attachSingleReferenceComponent: <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<ENTITY>, TARGET_ENTITY extends ENTITIES>(attachComponent: DomainComponentOpticBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES, ENTITY, $ENTITY, typeof referenceComponent>, targetReflection: DomainEntityReflection<TARGET_ENTITY> | RawAliasReflection<TARGET_ENTITY>, field: SingleReferenceField<ENTITY, TARGET_ENTITY, any>) => import("../index.js").DomainComponentSimpleOptic<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITY, import("../index.js").SystemComponentType<"reference", ReferenceComponentState, "referencedEntityIds">>;
17
- export declare const attachMultipleReferenceComponent: <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<ENTITY>, TARGET_ENTITY extends ENTITIES>(attachComponent: DomainComponentOpticBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES, ENTITY, $ENTITY, typeof referenceComponent>, targetReflection: DomainEntityReflection<TARGET_ENTITY> | RawAliasReflection<TARGET_ENTITY>, field: ArrayReferenceField<ENTITY, TARGET_ENTITY>) => import("../index.js").DomainComponentSimpleOptic<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITY, import("../index.js").SystemComponentType<"reference", ReferenceComponentState, "referencedEntityIds">>;
16
+ export declare const attachSingleReferenceComponent: <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<ENTITY>, TARGET_ENTITY extends ENTITIES, CONTEXT_EXTENSION = unknown>(attachComponent: DomainComponentOpticBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES, ENTITY, $ENTITY, typeof referenceComponent, CONTEXT_EXTENSION>, targetReflection: DomainEntityReflection<TARGET_ENTITY> | RawAliasReflection<TARGET_ENTITY>, field: SingleReferenceField<ENTITY, TARGET_ENTITY, any>) => import("../index.js").DomainComponentSimpleOptic<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITY, import("../index.js").SystemComponentType<"reference", ReferenceComponentState, "referencedEntityIds">, CONTEXT_EXTENSION>;
17
+ export declare const attachMultipleReferenceComponent: <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<ENTITY>, TARGET_ENTITY extends ENTITIES, CONTEXT_EXTENSION = unknown>(attachComponent: DomainComponentOpticBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES, ENTITY, $ENTITY, typeof referenceComponent, CONTEXT_EXTENSION>, targetReflection: DomainEntityReflection<TARGET_ENTITY> | RawAliasReflection<TARGET_ENTITY>, field: ArrayReferenceField<ENTITY, TARGET_ENTITY>) => import("../index.js").DomainComponentSimpleOptic<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITY, import("../index.js").SystemComponentType<"reference", ReferenceComponentState, "referencedEntityIds">, CONTEXT_EXTENSION>;
@@ -48,51 +48,20 @@ export type MigrateFunction<LATEST_ENTITIES extends DomainEntity<string>> = (ver
48
48
  state: ReadonlyArray<DomainEntity<string>>;
49
49
  }, options: MigrateFunctionOptions) => readonly LATEST_ENTITIES[];
50
50
  /**
51
- * Builder for the state migration function.
51
+ * Creates the function that migrates a state of any registered version of the model to the latest
52
+ * one. The state is validated against the reflections of its own version, and again after every
53
+ * migration against the reflections of the version that migration yields.
54
+ *
55
+ * @param modelVersions the entity reflections of every version of the model, keyed by version
56
+ * @param latestVersion the version the state is migrated to
57
+ * @param migrations the migration to each version above the first: the one under key `n` takes a
58
+ * state of version `n - 1` to version `n`
52
59
  * @example
53
-
54
- export const migrateState = MigrateFunctionBuilder
55
-
56
- // the reflections are used for validation and sanitization
57
- .fromVersions({
58
- 1: v1Reflections,
59
- 2: v2Reflections,
60
- 3: v3Reflections,
61
- })
62
-
63
- // the latest version of the model
64
- .to(2)
65
-
66
- // the migrations between the versions
67
- .using({
68
- 2: migrationToV2,
69
- 3: migrationToV3,
70
- })
71
-
72
- .build()
73
-
60
+ * export const migrate = createMigrateFunction(
61
+ * { 1: v1Reflections, 2: v2Reflections, 3: v3Reflections },
62
+ * 3,
63
+ * { 2: migrationToV2, 3: migrationToV3 }
64
+ * )
74
65
  */
75
- export declare const MigrateFunctionBuilder: {
76
- /**
77
- * Provide the entity reflections for all versions of the model.
78
- */
79
- fromVersions: <VERSIONS extends Record<number, EntityReflections<any>>>(modelVersions: VERSIONS) => {
80
- /**
81
- * Specify the latest version of the model. I.e. the version to which the state will be migrated.
82
- */
83
- to: <LATEST extends keyof VERSIONS & number>(latestVersion: LATEST) => {
84
- /**
85
- * Provide the migrations between each consecutive version of the model.
86
- *
87
- * Migration with index `i` should migrate the state from version `i - 1` to version `i`.
88
- */
89
- using: (migrations: Record<Exclude<keyof VERSIONS, 1>, Migration<any, any>>) => {
90
- /**
91
- * Finally, build the migration function.
92
- */
93
- build: () => MigrateFunction<EntitiesOfReflections<VERSIONS[LATEST]>>;
94
- };
95
- };
96
- };
97
- };
66
+ export declare const createMigrateFunction: <VERSIONS extends Record<number, EntityReflections<any>>, LATEST extends keyof VERSIONS & number>(modelVersions: VERSIONS, latestVersion: LATEST, migrations: Record<Exclude<keyof VERSIONS, 1>, Migration<any, any>>) => MigrateFunction<EntitiesOfReflections<VERSIONS[LATEST]>>;
98
67
  export {};
@@ -1 +1 @@
1
- import e from"lodash-es/pick.js";export class StateMigrationError extends Error{constructor(e){super(e),this.name="StateMigrationError"}}export const isStateMigrationError=e=>e instanceof StateMigrationError;let t=(t,r,i,o)=>t.map(t=>{let n=r[t.type];if(!n)throw new StateMigrationError(`Unknown entity type "${t.type}". The state contains an entity whose type is not registered in the domain model for this version. Fix: register the entity type in the domain spec, or remove/migrate the stale entity from the preset or configuration data.`);if(n._meta.validator(t))return t;if(i){let r=e(t,Object.keys(n._meta.schema.properties));if(n._meta.validator(t))return o?.error(`Entity ${t.type}#${t.id} had extra fields that had to be trimmed: ${Object.keys(r)}`),r}throw new StateMigrationError(`Entity "${t.type}#${t.id}" does not match its schema in the current domain model. Validation errors: ${JSON.stringify(n._meta.validator.errors)}. Fix: update the entity data to match the schema, add a migration that transforms older data into the current shape, or re-register the schema if it changed.`)});export const MigrateFunctionBuilder={fromVersions:e=>({to:r=>({using:i=>({build:()=>(o,{logger:n,trimExtraProperties:a})=>{let s=e[o.version];if(!s)throw new StateMigrationError(`Unknown model version ${o.version}. The state declares a version that has no registered reflections. Fix: register the version in MigrateFunctionBuilder.fromVersions({ ... }), or correct the version stored on the state.`);let d=t(o.state,s,a,n);o.version===r?n?.debug(`State is already in the latest version ${r}`):n?.debug(`Migrating state from version ${o.version} to ${r}`);for(let s=o.version;s<r;s++){n?.debug(`Applying intermediate migration to version ${s+1}`);let h=e[s+1];if(!h)throw new StateMigrationError(`Unknown model version ${s+1} while migrating from ${o.version} to ${r}. An intermediate version has no registered reflections. Fix: register version ${s+1} in MigrateFunctionBuilder.fromVersions({ ... }).`);let g=i[s+1];if(!g)throw new StateMigrationError(`Missing migration from version ${s} to ${s+1}. No migration is registered for this step while migrating to ${r}. Fix: add the migration in MigrateFunctionBuilder.using({ ${s+1}: ... }).`);d=t(g(d),h,a,n)}if(!e[o.version])throw new StateMigrationError(`Unknown model version ${o.version}. The state declares a version that has no registered reflections. Fix: register the version in MigrateFunctionBuilder.fromVersions({ ... }), or correct the version stored on the state.`);return d}})})})};
1
+ import t from"lodash-es/pick.js";export class StateMigrationError extends Error{constructor(t){super(t),this.name="StateMigrationError"}}export const isStateMigrationError=t=>t instanceof StateMigrationError;let e=(e,r,i,o)=>e.map(e=>{let n=r[e.type];if(!n)throw new StateMigrationError(`Unknown entity type "${e.type}". The state contains an entity whose type is not registered in the domain model for this version. Fix: register the entity type in the domain spec, or remove/migrate the stale entity from the preset or configuration data.`);if(n._meta.validator(e))return e;if(i){let r=t(e,Object.keys(n._meta.schema.properties));if(n._meta.validator(e))return o?.error(`Entity ${e.type}#${e.id} had extra fields that had to be trimmed: ${Object.keys(r)}`),r}throw new StateMigrationError(`Entity "${e.type}#${e.id}" does not match its schema in the current domain model. Validation errors: ${JSON.stringify(n._meta.validator.errors)}. Fix: update the entity data to match the schema, add a migration that transforms older data into the current shape, or re-register the schema if it changed.`)});export const createMigrateFunction=(t,r,i)=>(o,{logger:n,trimExtraProperties:a})=>{let s=t[o.version];if(!s)throw new StateMigrationError(`Unknown model version ${o.version}. The state declares a version that has no registered reflections. Fix: register the version in the model versions passed to createMigrateFunction, or correct the version stored on the state.`);let d=e(o.state,s,a,n);o.version===r?n?.debug(`State is already in the latest version ${r}`):n?.debug(`Migrating state from version ${o.version} to ${r}`);for(let s=o.version;s<r;s++){n?.debug(`Applying intermediate migration to version ${s+1}`);let h=t[s+1];if(!h)throw new StateMigrationError(`Unknown model version ${s+1} while migrating from ${o.version} to ${r}. An intermediate version has no registered reflections. Fix: register version ${s+1} in the model versions passed to createMigrateFunction.`);let g=i[s+1];if(!g)throw new StateMigrationError(`Missing migration from version ${s} to ${s+1}. No migration is registered for this step while migrating to ${r}. Fix: add the migration under key ${s+1} in the migrations passed to createMigrateFunction.`);d=e(g(d),h,a,n)}return d};
@@ -1,6 +1,6 @@
1
1
  import { type ExtendedJsonSchema } from '@salsita-ai/common/utils';
2
2
  import { type $DomainEntity, type $DomainEntityReflection, type ActionDefinition, type AliasMap, type AliasedExpressions, type AnyActionImplementations, type DomainEntity, DomainFactory, type EntityByType, type EntityReflections, type MigrateFunction, type SchemaOfObject } from './core/index.js';
3
- import { type ProjectModule } from './project-modules/index.js';
3
+ import { type ProjectModule } from './domain-runtime/index.js';
4
4
  type $EntityReflections<ENTITIES extends DomainEntity<string>> = {
5
5
  [TYPE in ENTITIES['type']]: $DomainEntityReflection<$DomainEntity<EntityByType<ENTITIES, TYPE>>>;
6
6
  };
@@ -1 +1 @@
1
- import{DomainFactory as t,MigrateFunctionBuilder as i,expandAlias as e}from"./core/index.js";import{resolveActionModules as s,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,e,s,n,a,o,h,l,r,m,d,p,c){this.entities=t,this.aliasMap=i,this.$entityReflections=e,this.allowedRootEntityTypes=s,this.implemented=n,this.modelVersion=a,this.publishedData=o,this.sessionData=h,this.frontendData=l,this.backendData=r,this.migrate=m,this.isAdminDomain=d,this.actions=p,this.actionImplementations=c}static from(t,e,s,n,a,o,h,l,r,m){let d=i.fromVersions({1:t}).to(1).using({}).build();return new DomainBuilder(t,e,s,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(t){let i={...this.implemented};return Object.entries(t).forEach(([t,s])=>{e(this.aliasMap,t).forEach(e=>{let n={...i[e]};i[e]=n,Object.entries(s).forEach(([i,s])=>{let o=n[i];if(o)throw Error(`Duplicate expression ${e}.${i}: The expression is defined on both ${t} and ${o.origin.typeOrAlias}, which would lead to ambiguous usage. Please ensure that expressions are only defined once.`);n[i]={...s,evaluate:a(`${e}_${i}`,s.evaluate),origin:{name:i,typeOrAlias:t}}})})}),new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,i,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,this.actions,this.actionImplementations)}withExpressionModules(t){return n(t,this.aliasMap).reduce((t,i)=>t.withExpressions(i.expressions),this)}withActions(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,Object.fromEntries(t.map(t=>[t.name,t])),this.actionImplementations)}withActionModules(t){return this.withActionImplementations(s(t))}withActionImplementations(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,this.actions,{...this.actionImplementations,...t})}build=()=>{let e=this.implemented,s=this.migrate??i.fromVersions({1:this.entities}).to(1).using({}).build();return new t({aliasMap:this.aliasMap,entityReflections:this.entities,$entityReflections:this.$entityReflections,expressions:e,allowedRootEntityTypes:this.allowedRootEntityTypes,modelVersion:this.modelVersion,migrate:s,publishedData:this.publishedData,sessionData:this.sessionData,frontendData:this.frontendData,backendData:this.backendData,isAdminDomain:this.isAdminDomain,actions:this.actions,actionImplementations:this.actionImplementations})}}
1
+ import{DomainFactory as t,createMigrateFunction as i,expandAlias as e}from"./core/index.js";import{resolveActionModules as s,resolveExpressionModules as n}from"./domain-runtime/index.js";import{withProfilerLabel as a}from"./utils/profiler-label.js";export class DomainBuilder{entities;aliasMap;$entityReflections;allowedRootEntityTypes;implemented;modelVersion;publishedData;sessionData;frontendData;backendData;migrate;isAdminDomain;actions;actionImplementations;constructor(t,i,e,s,n,a,o,h,l,m,r,d,p,c){this.entities=t,this.aliasMap=i,this.$entityReflections=e,this.allowedRootEntityTypes=s,this.implemented=n,this.modelVersion=a,this.publishedData=o,this.sessionData=h,this.frontendData=l,this.backendData=m,this.migrate=r,this.isAdminDomain=d,this.actions=p,this.actionImplementations=c}static from(t,e,s,n,a,o,h,l,m,r){let d=i({1:t},1,{});return new DomainBuilder(t,e,s,n,{},a,o,h,l,m,d,r,{},{})}withMigrate(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,t,this.isAdminDomain,this.actions,this.actionImplementations)}withExpressions(t){let i={...this.implemented};return Object.entries(t).forEach(([t,s])=>{e(this.aliasMap,t).forEach(e=>{let n={...i[e]};i[e]=n,Object.entries(s).forEach(([i,s])=>{let o=n[i];if(o)throw Error(`Duplicate expression ${e}.${i}: The expression is defined on both ${t} and ${o.origin.typeOrAlias}, which would lead to ambiguous usage. Please ensure that expressions are only defined once.`);n[i]={...s,evaluate:a(`${e}_${i}`,s.evaluate),origin:{name:i,typeOrAlias:t}}})})}),new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,i,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,this.actions,this.actionImplementations)}withExpressionModules(t){return n(t,this.aliasMap).reduce((t,i)=>t.withExpressions(i.expressions),this)}withActions(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,Object.fromEntries(t.map(t=>[t.name,t])),this.actionImplementations)}withActionModules(t){return this.withActionImplementations(s(t))}withActionImplementations(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,this.actions,{...this.actionImplementations,...t})}build=()=>{let e=this.implemented,s=this.migrate??i({1:this.entities},1,{});return new t({aliasMap:this.aliasMap,entityReflections:this.entities,$entityReflections:this.$entityReflections,expressions:e,allowedRootEntityTypes:this.allowedRootEntityTypes,modelVersion:this.modelVersion,migrate:s,publishedData:this.publishedData,sessionData:this.sessionData,frontendData:this.frontendData,backendData:this.backendData,isAdminDomain:this.isAdminDomain,actions:this.actions,actionImplementations:this.actionImplementations})}}
@@ -1,5 +1,5 @@
1
- import { type $DomainEntity, type ActionContext, type ActionTypes, type DomainEntity, type DomainState, type PreparedAction } from '../../core/index.js';
2
- import type { DomainContextSelectors } from '../../domain-runtime/domain-context/index.js';
1
+ import { type $DomainEntity, type ActionTypes, type DomainEntity, type DomainState, type PreparedAction } from '../../core/index.js';
2
+ import type { ActionContext, DomainContextSelectors } from '../../domain-runtime/index.js';
3
3
  export interface ActionSystemContext {
4
4
  /**
5
5
  * The action system's window into the runtime registry: the declared actions and their
@@ -1 +1 @@
1
- import{createSelector as t}from"@salsita-ai/common/utils";import{createUpdateFactory as e,extendedSchemaValidator as s}from"../../core/index.js";import{getIdSequence as n}from"../store-system/next-domain-entity-id.js";export class ActionSystem{_context;_selectValidators=t([t.leaf(t=>t)],t=>new Map(Object.values(t).map(t=>[t.name,s.compile(t.params)])));_updates=e();constructor(t){this._context=t}createContext=t=>({expressionContext:this._context.selectors.getExpressionContext(),systems:this._context.selectors.getDomainSystems(),getIdSequence:()=>n(t.entities,[]),updates:this._updates});prepareAction=(t,e,n)=>{let o=this._context.selectors.getActionDefinitions(),i=Object.values(o).find(e=>e.name===t);if(!i){let e=Object.values(o).map(t=>`"${t.name}"`);throw Error(`Unknown action "${t}". ${e.length>0?`The application declares these actions: ${e.join(", ")}.`:"The application declares no actions."} Declare it under "actions" in a spec file and implement it in src/actions/.`)}let a=this._selectValidators(o).get(i.name);if(a&&!a(e))throw Error(`The arguments of action "${t}" do not fit its params: ${s.errorsText(a.errors)}. Nothing was changed. Send arguments that fit the params the action declares.`);return(Object.entries(this._context.selectors.getActionImplementations()).find(([e])=>e===t)?.[1])(e,n,this.createContext(n))}}
1
+ import{createSelector as t}from"@salsita-ai/common/utils";import{createUpdateFactory as e,extendedSchemaValidator as s}from"../../core/index.js";import{getIdSequence as n}from"../store-system/index.js";export class ActionSystem{_context;_selectValidators=t([t.leaf(t=>t)],t=>new Map(Object.values(t).map(t=>[t.name,s.compile(t.params)])));_updates=e();constructor(t){this._context=t}createContext=t=>({expressionContext:this._context.selectors.getExpressionContext(),systems:this._context.selectors.getDomainSystems(),getIdSequence:()=>n(t.entities,[]),updates:this._updates});prepareAction=(t,e,n)=>{let o=this._context.selectors.getActionDefinitions(),i=Object.values(o).find(e=>e.name===t);if(!i){let e=Object.values(o).map(t=>`"${t.name}"`);throw Error(`Unknown action "${t}". ${e.length>0?`The application declares these actions: ${e.join(", ")}.`:"The application declares no actions."} Declare it under "actions" in a spec file and implement it in src/actions/.`)}let a=this._selectValidators(o).get(i.name);if(a&&!a(e))throw Error(`The arguments of action "${t}" do not fit its params: ${s.errorsText(a.errors)}. Nothing was changed. Send arguments that fit the params the action declares.`);return(Object.entries(this._context.selectors.getActionImplementations()).find(([e])=>e===t)?.[1])(e,n,this.createContext(n))}}
@@ -0,0 +1 @@
1
+ export { ActionSystem, type ActionSystemContext, type AnyActionSystem } from './action-system.js';
@@ -0,0 +1 @@
1
+ export{ActionSystem}from"./action-system.js";
@@ -0,0 +1,2 @@
1
+ export { type AnalyticsEvent, AnalyticsEventFactory, AnalyticsEventType, type DataLoadedEvent, type InitEvent, type NavigationEvent, type SessionAuthenticatedEvent, type SystemEvent, type UserActionEvent, } from './analytics-contracts.js';
2
+ export { type AnalyticsSystem, NoopAnalyticsSystem } from './analytics-system.js';
@@ -0,0 +1 @@
1
+ export{AnalyticsEventFactory,AnalyticsEventType}from"./analytics-contracts.js";export{NoopAnalyticsSystem}from"./analytics-system.js";
@@ -1,5 +1,5 @@
1
1
  import type { $DomainEntity, DomainEntity } from '../core/index.js';
2
2
  import type { DomainContextSystems } from './domain-context-systems.js';
3
- import type { UpdateTransformer } from './store-system/store-system.js';
3
+ import type { UpdateTransformer } from './store-system/index.js';
4
4
  export declare const createTransformer: <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>(transformer: (ctx: DomainContextSystems<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>) => UpdateTransformer<ENTITIES>) => (ctx: DomainContextSystems<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>) => UpdateTransformer<ENTITIES>;
5
5
  export type TransformerFactory<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> = (transformer: (ctx: DomainContextSystems<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>) => UpdateTransformer<ENTITIES>) => (ctx: DomainContextSystems<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>) => UpdateTransformer<ENTITIES>;
@@ -1,7 +1,7 @@
1
1
  import type { DomainEntity, DomainState, EntityViolation } from '../../core/index.js';
2
2
  import { DimensionUnit, type UnitsConfig } from '../../dimensions/index.js';
3
- import type { DomainContextSelectors } from '../../domain-runtime/domain-context/index.js';
4
- import { SystemState } from '../store-system/system-state.js';
3
+ import type { DomainContextSelectors } from '../../domain-runtime/index.js';
4
+ import { SystemState } from '../store-system/index.js';
5
5
  import { type DimensionStateComponent } from './dimension-state.js';
6
6
  export type DistanceDimensionViolation = `${string}.distanceDimension.tooLarge` | `${string}.distanceDimension.tooSmall`;
7
7
  export type GenericDimensionViolation = `${string}.genericDimension.tooLarge` | `${string}.genericDimension.tooSmall`;
@@ -1 +1 @@
1
- import{AngleUnit as t,DEFAULT_DECIMAL_PLACES as e,DimensionUnit as i,defaultAngleToUnit as n,formatDistanceValue as a,isDimensionGreaterThanMax as o,isDimensionLowerThanMin as s}from"../../dimensions/index.js";import{angleDimensionComponent as l,applicationConfigComponent as m,distanceDimensionComponent as r,genericDimensionComponent as c}from"../../system-components/index.js";import{SystemState as u}from"../store-system/system-state.js";import{dimensionStateComponent as g}from"./dimension-state.js";let d={[t.degree]:"\xb0",[t.radian]:"rad"},p={mm:{strategy:"decimal",decimalPlaces:0},cm:{strategy:"decimal",decimalPlaces:1},m:{strategy:"decimal",decimalPlaces:2},inch:{strategy:"fraction",fractionBasis:[3,4]},feet:{strategy:"fraction-inch",fractionBasis:[3,4]}},h=["mm","cm","m","inch","feet"];function f(t,e){let i={sourceUnit:t.sourceUnit,displayUnit:t.displayUnit,unitDisplayConfig:t.unitDisplayConfig,locale:t.locale,omitLeadingZeroUnits:!0},n=a(t.limitValue,i),o=a(t.currentValue,i);return"tooLarge"===e?{id:"sdk.distanceDimension.hintMessageTooLarge",message:"Current value is {0}, which is larger than allowed maximum of {1}.",values:{0:o.valueWithUnit,1:n.valueWithUnit}}:{id:"sdk.distanceDimension.hintMessageTooSmall",message:"Current value is {0}, which is smaller than allowed minimum of {1}.",values:{0:o.valueWithUnit,1:n.valueWithUnit}}}function y(t,e){let i=`${t.currentValue.toFixed(t.decimalPlaces)}\u00A0${t.unit}`,n=`${t.limitValue}\u00A0${t.unit}`;return"tooLarge"===e?{id:"sdk.genericDimension.hintMessageTooLarge",message:"Current value is {currentWithUnit}, which is larger than allowed maximum of {limitWithUnit}.",values:{currentWithUnit:i,limitWithUnit:n}}:{id:"sdk.genericDimension.hintMessageTooSmall",message:"Current value is {currentWithUnit}, which is smaller than allowed minimum of {limitWithUnit}.",values:{currentWithUnit:i,limitWithUnit:n}}}function v(t,e){let i=`${n(t.currentValue,t.unit).toFixed(t.decimalPlaces)}\u00A0${t.unitLabel}`,a=`${n(t.limitValue,t.unit).toFixed(t.decimalPlaces)}\u00A0${t.unitLabel}`;return"tooLarge"===e?{id:"sdk.angleDimension.hintMessageTooLarge",message:"Current value is {currentWithUnit}, which is larger than allowed maximum of {limitWithUnit}.",values:{currentWithUnit:i,limitWithUnit:a}}:{id:"sdk.angleDimension.hintMessageTooSmall",message:"Current value is {currentWithUnit}, which is smaller than allowed minimum of {limitWithUnit}.",values:{currentWithUnit:i,limitWithUnit:a}}}export class DimensionSystem{_context;state;constructor(t){this._context=t,this.state=new u({selectors:this._context.selectors,componentType:g,getInitialState:t=>{let e=this._context.selectors.getComponentReader().readFirstRootComponent({componentTypes:[m]},t);return{unit:e?.state.initialGlobalUnit??e?.state.distanceDataUnit??i.mm}}})}initialize=t=>this.state.getInitialUpdates(t);getDimensionConfig=t=>{let e=this._context.selectors.getComponentReader().readFirstRootComponent({componentTypes:[m]},t);return{distanceDataUnit:e?.state.distanceDataUnit??i.mm,unitDisplayConfig:e?.state.unitDisplayConfig??p,availableDimensions:e?.state.availableDimensions??h}};getDataDistanceUnit=t=>this.getDimensionConfig(t).distanceDataUnit;getGlobalUnit=t=>this.state.get(t).unit;getSetGlobalUnitUpdates=(t,e)=>this.state.getUpdates(e=>({...e,unit:t}),e);_getDistanceComponentViolations=t=>{let e=this.getDimensionConfig(t),i=this.state.get(t),n=this._context.selectors.getComponentReader().readManyComponents({componentTypes:[r]},t),a=[];for(let t of n){let n=t.state.displayUnit??i.unit,l=t.state.unitDisplayConfig?.[n]??e.unitDisplayConfig[n];if(!l)throw Error(`Unit config for ${n} not found!`);let m=t.state.max;if(void 0!==m&&o(t.state.value,m)){let i={currentValue:t.state.value,limitValue:m,sourceUnit:e.distanceDataUnit,displayUnit:n,unitDisplayConfig:l};a.push({entityId:t.componentInstance.entityId,violation:{type:`${t.componentInstance.instanceName}.distanceDimension.tooLarge`,severity:"fatal",message:f({...i,locale:"en-US"},"tooLarge"),formatControlViolationMessage:(t,e)=>f({...i,locale:e.i18n.locale},"tooLarge")}})}let r=t.state.min;if(void 0!==r&&s(t.state.value,r)){let i={currentValue:t.state.value,limitValue:r,sourceUnit:e.distanceDataUnit,displayUnit:n,unitDisplayConfig:l};a.push({entityId:t.componentInstance.entityId,violation:{type:`${t.componentInstance.instanceName}.distanceDimension.tooSmall`,severity:"fatal",message:f({...i,locale:"en-US"},"tooSmall"),formatControlViolationMessage:(t,e)=>f({...i,locale:e.i18n.locale},"tooSmall")}})}}return a};_getGenericComponentViolations=t=>{let i=this._context.selectors.getComponentReader().readManyComponents({componentTypes:[c]},t),n=[];for(let t of i){if(void 0!==t.state.max&&o(t.state.value,t.state.max)){let i={currentValue:t.state.value,limitValue:t.state.max,decimalPlaces:t.state.decimalPlaces??e,unit:t.state.unit};n.push({entityId:t.componentInstance.entityId,violation:{type:`${t.componentInstance.instanceName}.genericDimension.tooLarge`,severity:"fatal",message:y(i,"tooLarge"),formatControlViolationMessage:()=>y(i,"tooLarge")}})}if(void 0!==t.state.min&&s(t.state.value,t.state.min)){let i={currentValue:t.state.value,limitValue:t.state.min,decimalPlaces:t.state.decimalPlaces??e,unit:t.state.unit};n.push({entityId:t.componentInstance.entityId,violation:{type:`${t.componentInstance.instanceName}.genericDimension.tooSmall`,severity:"fatal",message:y(i,"tooSmall"),formatControlViolationMessage:()=>y(i,"tooSmall")}})}}return n};_getAngleComponentViolations=t=>{let i=this._context.selectors.getComponentReader().readManyComponents({componentTypes:[l]},t),n=[];for(let t of i){let i=t.state.unit??"degree",a=d[i],l=t.state.decimalPlaces??e;if(void 0!==t.state.max&&o(t.state.value,t.state.max)){let e={currentValue:t.state.value,limitValue:t.state.max,unit:i,unitLabel:a,decimalPlaces:l};n.push({entityId:t.componentInstance.entityId,violation:{type:`${t.componentInstance.instanceName}.angleDimension.tooLarge`,severity:"fatal",message:v(e,"tooLarge"),formatControlViolationMessage:()=>v(e,"tooLarge")}})}if(void 0!==t.state.min&&s(t.state.value,t.state.min)){let e={currentValue:t.state.value,limitValue:t.state.min,unit:i,unitLabel:a,decimalPlaces:l};n.push({entityId:t.componentInstance.entityId,violation:{type:`${t.componentInstance.instanceName}.angleDimension.tooSmall`,severity:"fatal",message:v(e,"tooSmall"),formatControlViolationMessage:()=>v(e,"tooSmall")}})}}return n};validateState=t=>[...this._getDistanceComponentViolations(t),...this._getGenericComponentViolations(t),...this._getAngleComponentViolations(t)]}
1
+ import{AngleUnit as t,DEFAULT_DECIMAL_PLACES as e,DimensionUnit as i,defaultAngleToUnit as n,formatDistanceValue as a,isDimensionGreaterThanMax as o,isDimensionLowerThanMin as s}from"../../dimensions/index.js";import{angleDimensionComponent as l,applicationConfigComponent as m,distanceDimensionComponent as r,genericDimensionComponent as c}from"../../system-components/index.js";import{SystemState as u}from"../store-system/index.js";import{dimensionStateComponent as g}from"./dimension-state.js";let d={[t.degree]:"\xb0",[t.radian]:"rad"},p={mm:{strategy:"decimal",decimalPlaces:0},cm:{strategy:"decimal",decimalPlaces:1},m:{strategy:"decimal",decimalPlaces:2},inch:{strategy:"fraction",fractionBasis:[3,4]},feet:{strategy:"fraction-inch",fractionBasis:[3,4]}},h=["mm","cm","m","inch","feet"];function f(t,e){let i={sourceUnit:t.sourceUnit,displayUnit:t.displayUnit,unitDisplayConfig:t.unitDisplayConfig,locale:t.locale,omitLeadingZeroUnits:!0},n=a(t.limitValue,i),o=a(t.currentValue,i);return"tooLarge"===e?{id:"sdk.distanceDimension.hintMessageTooLarge",message:"Current value is {0}, which is larger than allowed maximum of {1}.",values:{0:o.valueWithUnit,1:n.valueWithUnit}}:{id:"sdk.distanceDimension.hintMessageTooSmall",message:"Current value is {0}, which is smaller than allowed minimum of {1}.",values:{0:o.valueWithUnit,1:n.valueWithUnit}}}function y(t,e){let i=`${t.currentValue.toFixed(t.decimalPlaces)}\u00A0${t.unit}`,n=`${t.limitValue}\u00A0${t.unit}`;return"tooLarge"===e?{id:"sdk.genericDimension.hintMessageTooLarge",message:"Current value is {currentWithUnit}, which is larger than allowed maximum of {limitWithUnit}.",values:{currentWithUnit:i,limitWithUnit:n}}:{id:"sdk.genericDimension.hintMessageTooSmall",message:"Current value is {currentWithUnit}, which is smaller than allowed minimum of {limitWithUnit}.",values:{currentWithUnit:i,limitWithUnit:n}}}function v(t,e){let i=`${n(t.currentValue,t.unit).toFixed(t.decimalPlaces)}\u00A0${t.unitLabel}`,a=`${n(t.limitValue,t.unit).toFixed(t.decimalPlaces)}\u00A0${t.unitLabel}`;return"tooLarge"===e?{id:"sdk.angleDimension.hintMessageTooLarge",message:"Current value is {currentWithUnit}, which is larger than allowed maximum of {limitWithUnit}.",values:{currentWithUnit:i,limitWithUnit:a}}:{id:"sdk.angleDimension.hintMessageTooSmall",message:"Current value is {currentWithUnit}, which is smaller than allowed minimum of {limitWithUnit}.",values:{currentWithUnit:i,limitWithUnit:a}}}export class DimensionSystem{_context;state;constructor(t){this._context=t,this.state=new u({selectors:this._context.selectors,componentType:g,getInitialState:t=>{let e=this._context.selectors.getComponentReader().readFirstRootComponent({componentTypes:[m]},t);return{unit:e?.state.initialGlobalUnit??e?.state.distanceDataUnit??i.mm}}})}initialize=t=>this.state.getInitialUpdates(t);getDimensionConfig=t=>{let e=this._context.selectors.getComponentReader().readFirstRootComponent({componentTypes:[m]},t);return{distanceDataUnit:e?.state.distanceDataUnit??i.mm,unitDisplayConfig:e?.state.unitDisplayConfig??p,availableDimensions:e?.state.availableDimensions??h}};getDataDistanceUnit=t=>this.getDimensionConfig(t).distanceDataUnit;getGlobalUnit=t=>this.state.get(t).unit;getSetGlobalUnitUpdates=(t,e)=>this.state.getUpdates(e=>({...e,unit:t}),e);_getDistanceComponentViolations=t=>{let e=this.getDimensionConfig(t),i=this.state.get(t),n=this._context.selectors.getComponentReader().readManyComponents({componentTypes:[r]},t),a=[];for(let t of n){let n=t.state.displayUnit??i.unit,l=t.state.unitDisplayConfig?.[n]??e.unitDisplayConfig[n];if(!l)throw Error(`Unit config for ${n} not found!`);let m=t.state.max;if(void 0!==m&&o(t.state.value,m)){let i={currentValue:t.state.value,limitValue:m,sourceUnit:e.distanceDataUnit,displayUnit:n,unitDisplayConfig:l};a.push({entityId:t.componentInstance.entityId,violation:{type:`${t.componentInstance.instanceName}.distanceDimension.tooLarge`,severity:"fatal",message:f({...i,locale:"en-US"},"tooLarge"),formatControlViolationMessage:(t,e)=>f({...i,locale:e.i18n.locale},"tooLarge")}})}let r=t.state.min;if(void 0!==r&&s(t.state.value,r)){let i={currentValue:t.state.value,limitValue:r,sourceUnit:e.distanceDataUnit,displayUnit:n,unitDisplayConfig:l};a.push({entityId:t.componentInstance.entityId,violation:{type:`${t.componentInstance.instanceName}.distanceDimension.tooSmall`,severity:"fatal",message:f({...i,locale:"en-US"},"tooSmall"),formatControlViolationMessage:(t,e)=>f({...i,locale:e.i18n.locale},"tooSmall")}})}}return a};_getGenericComponentViolations=t=>{let i=this._context.selectors.getComponentReader().readManyComponents({componentTypes:[c]},t),n=[];for(let t of i){if(void 0!==t.state.max&&o(t.state.value,t.state.max)){let i={currentValue:t.state.value,limitValue:t.state.max,decimalPlaces:t.state.decimalPlaces??e,unit:t.state.unit};n.push({entityId:t.componentInstance.entityId,violation:{type:`${t.componentInstance.instanceName}.genericDimension.tooLarge`,severity:"fatal",message:y(i,"tooLarge"),formatControlViolationMessage:()=>y(i,"tooLarge")}})}if(void 0!==t.state.min&&s(t.state.value,t.state.min)){let i={currentValue:t.state.value,limitValue:t.state.min,decimalPlaces:t.state.decimalPlaces??e,unit:t.state.unit};n.push({entityId:t.componentInstance.entityId,violation:{type:`${t.componentInstance.instanceName}.genericDimension.tooSmall`,severity:"fatal",message:y(i,"tooSmall"),formatControlViolationMessage:()=>y(i,"tooSmall")}})}}return n};_getAngleComponentViolations=t=>{let i=this._context.selectors.getComponentReader().readManyComponents({componentTypes:[l]},t),n=[];for(let t of i){let i=t.state.unit??"degree",a=d[i],l=t.state.decimalPlaces??e;if(void 0!==t.state.max&&o(t.state.value,t.state.max)){let e={currentValue:t.state.value,limitValue:t.state.max,unit:i,unitLabel:a,decimalPlaces:l};n.push({entityId:t.componentInstance.entityId,violation:{type:`${t.componentInstance.instanceName}.angleDimension.tooLarge`,severity:"fatal",message:v(e,"tooLarge"),formatControlViolationMessage:()=>v(e,"tooLarge")}})}if(void 0!==t.state.min&&s(t.state.value,t.state.min)){let e={currentValue:t.state.value,limitValue:t.state.min,unit:i,unitLabel:a,decimalPlaces:l};n.push({entityId:t.componentInstance.entityId,violation:{type:`${t.componentInstance.instanceName}.angleDimension.tooSmall`,severity:"fatal",message:v(e,"tooSmall"),formatControlViolationMessage:()=>v(e,"tooSmall")}})}}return n};validateState=t=>[...this._getDistanceComponentViolations(t),...this._getGenericComponentViolations(t),...this._getAngleComponentViolations(t)]}
@@ -0,0 +1 @@
1
+ export { type AngleDimensionViolation, type AnyDimensionSystem, DimensionSystem, type DimensionSystemContext, type DistanceDimensionViolation, type GenericDimensionViolation, } from './dimension-system.js';
@@ -0,0 +1 @@
1
+ export{DimensionSystem}from"./dimension-system.js";
@@ -1,12 +1,12 @@
1
1
  import type { $DomainEntity, ActionTypes, Domain, DomainEntity } from '../core/index.js';
2
- import type { ComponentReader, DomainContextSelectors } from '../domain-runtime/domain-context/index.js';
2
+ import type { ComponentReader, DomainContextSelectors } from '../domain-runtime/index.js';
3
3
  import type { BlenderProjections, CollisionProjections, CompositionProjections, ConstraintProjections, PositionProjections, ProjectedEntitiesProjections, SnappingProjections, ValidationProjections } from '../projections/index.js';
4
- import type { SketchingProjections } from '../sketching/sketching-projections.js';
5
- import type { ActionSystem } from './action-system/action-system.js';
6
- import type { DimensionSystem } from './dimension-system/dimension-system.js';
7
- import type { NavigationSystem } from './navigation-system/navigation-system.js';
8
- import type { RecipeCookerSystem } from './recipe-system/recipe-cooker-system.js';
9
- import type { StoreSystem } from './store-system/store-system.js';
4
+ import type { SketchingProjections } from '../sketching/index.js';
5
+ import type { ActionSystem } from './action-system/index.js';
6
+ import type { DimensionSystem } from './dimension-system/index.js';
7
+ import type { NavigationSystem } from './navigation-system/index.js';
8
+ import type { RecipeCookerSystem } from './recipe-system/index.js';
9
+ import type { StoreSystem } from './store-system/index.js';
10
10
  import type { UndoSystem } from './undo-system.js';
11
11
  /**
12
12
  * Stable domain system graph owned by one application slot in the domain runtime.
@@ -1,20 +1,11 @@
1
- export { type AnalyticsSystem, NoopAnalyticsSystem } from './analytics-system/analytics-system.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
- 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
- export { createAutoSelectionTransformer, NavigationSystem, type NavigationSystemContext, } from './navigation-system/navigation-system.js';
5
- export { createResetSelectionOnNavigationTransformer, createNavigationOnSelectionTransformer, createNavigationOnDeselectTransformer, createSelectParentOnDeselectionTransformer, createNavigationOnSelectionChangeTransformer, } from './navigation-system/selection-transformers.js';
6
- export { StoreSystem, type TransformerRegistration, type StateEmission, type UpdateTransformer, type TransformerLogFunction, type Transformers, type StateSliceName, type StateUpdateEmission, type StateEmissionKind, type CommitPreparedOutcome, } from './store-system/store-system.js';
7
- export { nextDomainEntityId, getIdSequence } from './store-system/next-domain-entity-id.js';
8
- export { applyUpdates } from './store-system/apply-updates.js';
9
- export { SystemState, SystemStateInitialUpdateTag, SystemStateUpdateTag, type SystemStateContext, } from './store-system/system-state.js';
10
- export { createRefReplaceTransformer } from './relation-transformers/replace-refs.js';
11
- export { createCascadeDeletesTransformer } from './relation-transformers/cascade-deletes.js';
12
- export { createCascadeRefPruningTransformer } from './relation-transformers/cascade-ref-pruning.js';
13
- export { createCreateEntityRefsTransformer } from './relation-transformers/create-entity-refs.js';
14
- export { type CanBeUndonePredicate, type CanBeUndoneContext, type UndoCapabilities, UndoSystem, UNDO_REDO_RESET_TAG, isUndoRedoReset, } from './undo-system.js';
15
- export { DimensionSystem, type AnyDimensionSystem, type DimensionSystemContext, type AngleDimensionViolation, type DistanceDimensionViolation, type GenericDimensionViolation, } from './dimension-system/dimension-system.js';
16
- export { ActionSystem, type AnyActionSystem, type ActionSystemContext } from './action-system/action-system.js';
17
- export { RecipeCookerSystem, type AnyRecipeCookerSystem, type RecipeCookerSystemContext, ReplaceRecipeUpdateTag, isReplaceEntityUpdate, type IsReplaceRecipeUpdate, CreateRecipeUpdateTag, isCreateEntityUpdate, type IsCreateRecipeUpdate, } from './recipe-system/recipe-cooker-system.js';
1
+ export { type AnalyticsSystem, NoopAnalyticsSystem, type AnalyticsEvent, AnalyticsEventFactory, AnalyticsEventType, type DataLoadedEvent, type InitEvent, type NavigationEvent, type SessionAuthenticatedEvent, type SystemEvent, type UserActionEvent, } from './analytics-system/index.js';
2
+ export { NavigationUpdateTag, isInitialNavigationUpdate, isNavigationUpdate, isInitialViewUpdate, isViewUpdate, isInitialSelectionUpdate, isSelectUpdate, isDeselectUpdate, isInitialFullscreenUpdate, isToggleFullscreenUpdate, isInitialDebugUpdate, isInitialViewportUpdate, isSetViewportUpdate, isInitialDragUpdate, isDragStartUpdate, isDragEndUpdate, isInitialToolUpdate, isToolUpdate, isExportUpdate, createAutoSelectionTransformer, NavigationSystem, type NavigationSystemContext, createResetSelectionOnNavigationTransformer, createNavigationOnSelectionTransformer, createNavigationOnDeselectTransformer, createSelectParentOnDeselectionTransformer, createNavigationOnSelectionChangeTransformer, type AnyNavigationSystem, } from './navigation-system/index.js';
3
+ export { StoreSystem, type TransformerRegistration, type UpdateTransformer, type TransformerLogFunction, type Transformers, type StateSliceName, type StateEmissionKind, type CommitPreparedOutcome, nextDomainEntityId, getIdSequence, applyUpdates, SystemState, SystemStateInitialUpdateTag, SystemStateUpdateTag, type SystemStateContext, type AnyCreateTransformersFactory, type AnyStoreSystem, type Unregister, } from './store-system/index.js';
4
+ export { createRefReplaceTransformer, createCascadeDeletesTransformer, createCascadeRefPruningTransformer, createCreateEntityRefsTransformer, } from './relation-transformers/index.js';
5
+ export { type CanBeUndonePredicate, type CanBeUndoneContext, type UndoCapabilities, UndoSystem, UNDO_REDO_RESET_TAG, isUndoRedoReset, type AnyUndoSystem, } from './undo-system.js';
6
+ export { DimensionSystem, type AnyDimensionSystem, type DimensionSystemContext, type AngleDimensionViolation, type DistanceDimensionViolation, type GenericDimensionViolation, } from './dimension-system/index.js';
7
+ export { ActionSystem, type AnyActionSystem, type ActionSystemContext } from './action-system/index.js';
8
+ export { RecipeCookerSystem, type AnyRecipeCookerSystem, type RecipeCookerSystemContext, ReplaceRecipeUpdateTag, isReplaceEntityUpdate, type IsReplaceRecipeUpdate, CreateRecipeUpdateTag, isCreateEntityUpdate, type IsCreateRecipeUpdate, } from './recipe-system/index.js';
18
9
  export { type DomainContextSystems, type AnyDomainContextSystems } from './domain-context-systems.js';
19
10
  export { createTransformer, type TransformerFactory } from './create-transformer.js';
20
11
  export * from './transformers/index.js';
@@ -1 +1 @@
1
- export{NoopAnalyticsSystem}from"./analytics-system/analytics-system.js";export{AnalyticsEventFactory,AnalyticsEventType}from"./analytics-system/analytics-contracts.js";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";export{createAutoSelectionTransformer,NavigationSystem}from"./navigation-system/navigation-system.js";export{createResetSelectionOnNavigationTransformer,createNavigationOnSelectionTransformer,createNavigationOnDeselectTransformer,createSelectParentOnDeselectionTransformer,createNavigationOnSelectionChangeTransformer}from"./navigation-system/selection-transformers.js";export{StoreSystem}from"./store-system/store-system.js";export{nextDomainEntityId,getIdSequence}from"./store-system/next-domain-entity-id.js";export{applyUpdates}from"./store-system/apply-updates.js";export{SystemState,SystemStateInitialUpdateTag,SystemStateUpdateTag}from"./store-system/system-state.js";export{createRefReplaceTransformer}from"./relation-transformers/replace-refs.js";export{createCascadeDeletesTransformer}from"./relation-transformers/cascade-deletes.js";export{createCascadeRefPruningTransformer}from"./relation-transformers/cascade-ref-pruning.js";export{createCreateEntityRefsTransformer}from"./relation-transformers/create-entity-refs.js";export{UndoSystem,UNDO_REDO_RESET_TAG,isUndoRedoReset}from"./undo-system.js";export{DimensionSystem}from"./dimension-system/dimension-system.js";export{ActionSystem}from"./action-system/action-system.js";export{RecipeCookerSystem,ReplaceRecipeUpdateTag,isReplaceEntityUpdate,CreateRecipeUpdateTag,isCreateEntityUpdate}from"./recipe-system/recipe-cooker-system.js";export{createTransformer}from"./create-transformer.js";export*from"./transformers/index.js";
1
+ export{NoopAnalyticsSystem,AnalyticsEventFactory,AnalyticsEventType}from"./analytics-system/index.js";export{NavigationUpdateTag,isInitialNavigationUpdate,isNavigationUpdate,isInitialViewUpdate,isViewUpdate,isInitialSelectionUpdate,isSelectUpdate,isDeselectUpdate,isInitialFullscreenUpdate,isToggleFullscreenUpdate,isInitialDebugUpdate,isInitialViewportUpdate,isSetViewportUpdate,isInitialDragUpdate,isDragStartUpdate,isDragEndUpdate,isInitialToolUpdate,isToolUpdate,isExportUpdate,createAutoSelectionTransformer,NavigationSystem,createResetSelectionOnNavigationTransformer,createNavigationOnSelectionTransformer,createNavigationOnDeselectTransformer,createSelectParentOnDeselectionTransformer,createNavigationOnSelectionChangeTransformer}from"./navigation-system/index.js";export{StoreSystem,nextDomainEntityId,getIdSequence,applyUpdates,SystemState,SystemStateInitialUpdateTag,SystemStateUpdateTag}from"./store-system/index.js";export{createRefReplaceTransformer,createCascadeDeletesTransformer,createCascadeRefPruningTransformer,createCreateEntityRefsTransformer}from"./relation-transformers/index.js";export{UndoSystem,UNDO_REDO_RESET_TAG,isUndoRedoReset}from"./undo-system.js";export{DimensionSystem}from"./dimension-system/index.js";export{ActionSystem}from"./action-system/index.js";export{RecipeCookerSystem,ReplaceRecipeUpdateTag,isReplaceEntityUpdate,CreateRecipeUpdateTag,isCreateEntityUpdate}from"./recipe-system/index.js";export{createTransformer}from"./create-transformer.js";export*from"./transformers/index.js";
@@ -0,0 +1,3 @@
1
+ export { type AnyNavigationSystem, NavigationSystem, type NavigationSystemContext, createAutoSelectionTransformer, } from './navigation-system.js';
2
+ export { NavigationUpdateTag, isDeselectUpdate, isDragEndUpdate, isDragStartUpdate, isExportUpdate, isInitialDebugUpdate, isInitialDragUpdate, isInitialFullscreenUpdate, isInitialNavigationUpdate, isInitialSelectionUpdate, isInitialToolUpdate, isInitialViewUpdate, isInitialViewportUpdate, isNavigationUpdate, isSelectUpdate, isSetViewportUpdate, isToggleFullscreenUpdate, isToolUpdate, isViewUpdate, } from './navigation-updates.js';
3
+ export { createNavigationOnDeselectTransformer, createNavigationOnSelectionChangeTransformer, createNavigationOnSelectionTransformer, createResetSelectionOnNavigationTransformer, createSelectParentOnDeselectionTransformer, } from './selection-transformers.js';
@@ -0,0 +1 @@
1
+ export{NavigationSystem,createAutoSelectionTransformer}from"./navigation-system.js";export{NavigationUpdateTag,isDeselectUpdate,isDragEndUpdate,isDragStartUpdate,isExportUpdate,isInitialDebugUpdate,isInitialDragUpdate,isInitialFullscreenUpdate,isInitialNavigationUpdate,isInitialSelectionUpdate,isInitialToolUpdate,isInitialViewUpdate,isInitialViewportUpdate,isNavigationUpdate,isSelectUpdate,isSetViewportUpdate,isToggleFullscreenUpdate,isToolUpdate,isViewUpdate}from"./navigation-updates.js";export{createNavigationOnDeselectTransformer,createNavigationOnSelectionChangeTransformer,createNavigationOnSelectionTransformer,createResetSelectionOnNavigationTransformer,createSelectParentOnDeselectionTransformer}from"./selection-transformers.js";
@@ -1,7 +1,6 @@
1
1
  import { type DomainEntity, type DomainState, type Viewport } from '../../core/index.js';
2
- import type { DomainContextSelectors } from '../../domain-runtime/domain-context/index.js';
3
- import type { DomainServicesSelectors } from '../../domain-runtime/domain-services/index.js';
4
- import type { UpdateTransformer } from '../store-system/store-system.js';
2
+ import type { DomainContextSelectors, DomainServicesSelectors } from '../../domain-runtime/index.js';
3
+ import type { UpdateTransformer } from '../store-system/index.js';
5
4
  /**
6
5
  * Automatically selects new/replaced entities and deselects deleted entities.
7
6
  * This transformers runs automatically with priority 100.