@salsita-ai/sdk 0.50.0-develop.be40f0cee8 → 0.50.0-develop.d81d7591c5

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 (272) hide show
  1. package/dist/application-spec/generate-application/code/common/index.d.ts +1 -0
  2. package/dist/application-spec/generate-application/code/common/index.js +1 -1
  3. package/dist/application-spec/generate-application/code/common/project-module-list.d.ts +8 -0
  4. package/dist/application-spec/generate-application/code/common/project-module-list.js +3 -0
  5. package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
  6. package/dist/application-spec/generate-application/code/project-scaffolding.js +2 -2
  7. package/dist/application-spec/generate-application/code/templates/admin-domain-code.d.ts +1 -2
  8. package/dist/application-spec/generate-application/code/templates/admin-domain-code.js +6 -14
  9. package/dist/application-spec/generate-application/code/templates/admin-frontend-code.d.ts +1 -2
  10. package/dist/application-spec/generate-application/code/templates/admin-frontend-code.js +4 -4
  11. package/dist/application-spec/generate-application/code/templates/configurator-domain-code.d.ts +1 -2
  12. package/dist/application-spec/generate-application/code/templates/configurator-domain-code.js +7 -16
  13. package/dist/application-spec/generate-application/code/templates/configurator-frontend-code.d.ts +1 -2
  14. package/dist/application-spec/generate-application/code/templates/configurator-frontend-code.js +7 -9
  15. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-assistant.d.ts +2 -2
  16. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-assistant.js +1 -1
  17. package/dist/application-spec/generate-application/code/templates/domain-spec.js +4 -4
  18. package/dist/application-spec/generate-application/code/templates/domain.js +3 -3
  19. package/dist/application-spec/generate-application/code/templates/index.d.ts +1 -0
  20. package/dist/application-spec/generate-application/code/templates/index.js +1 -1
  21. package/dist/application-spec/generate-application/code/templates/skills/agents-md.js +1 -1
  22. package/dist/application-spec/generate-application/code/templates/skills/phoenix-cli-skill.js +1 -1
  23. package/dist/application-spec/generate-application/code/templates/skills/phoenix-create-configurator-skill.js +41 -13
  24. package/dist/application-spec/generate-application/code/templates/skills/phoenix-feedback-skill.js +1 -1
  25. package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js +2 -2
  26. package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill.js +1 -1
  27. package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.d.ts +1 -0
  28. package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.js +6 -0
  29. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +30 -3
  30. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +19 -5
  31. package/dist/application-spec/generate-application/code/templates/webhook-builders.js +8 -4
  32. package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.d.ts +4 -3
  33. package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.js +1 -1
  34. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.d.ts +3 -8
  35. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.js +1 -1
  36. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +9 -43
  37. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
  38. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-server-settings.d.ts +2 -2
  39. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant.d.ts +5 -21
  40. package/dist/client/phoenix-api.d.ts +58 -30
  41. package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
  42. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +158 -13
  43. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
  44. package/dist/configurator/application-runtime/extensions/systems/assistant-system/change-recorder.d.ts +85 -0
  45. package/dist/configurator/application-runtime/extensions/systems/assistant-system/change-recorder.js +1 -0
  46. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +8 -3
  47. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -1
  48. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.d.ts +4 -0
  49. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.js +1 -1
  50. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +16 -1
  51. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
  52. package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.d.ts +9 -0
  53. package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.js +1 -0
  54. package/dist/configurator/application-runtime/extensions/systems/index.d.ts +1 -1
  55. package/dist/configurator/common/frontend-analytics.d.ts +21 -21
  56. package/dist/configurator/index.d.ts +0 -1
  57. package/dist/configurator/index.js +1 -1
  58. package/dist/configurator/pages/LoadedConfiguratorDetailPage.js +1 -1
  59. package/dist/configurator/scene/scene-analytics/scene-analytics.d.ts +2 -2
  60. package/dist/configurator/ui/assistant/AssistantChips.js +1 -1
  61. package/dist/configurator/ui/assistant/AssistantComposer.d.ts +1 -6
  62. package/dist/configurator/ui/assistant/AssistantComposer.js +1 -1
  63. package/dist/configurator/ui/assistant/AssistantPanel.js +1 -1
  64. package/dist/configurator/ui/assistant/AssistantThread.d.ts +1 -6
  65. package/dist/configurator/ui/assistant/AssistantThread.js +1 -1
  66. package/dist/configurator/ui/assistant/index.d.ts +1 -1
  67. package/dist/configurator/ui/assistant/index.js +1 -1
  68. package/dist/configurator/ui/assistant/thread-items.d.ts +1 -1
  69. package/dist/configurator/ui/assistant/tool-chip.d.ts +8 -1
  70. package/dist/configurator/ui/assistant/tool-chip.js +1 -1
  71. package/dist/configurator/ui/assistant/use-is-assistant-panel-open.d.ts +5 -0
  72. package/dist/configurator/ui/assistant/use-is-assistant-panel-open.js +1 -0
  73. package/dist/configurator/ui/configurator-layout/universal/DesktopLayout.js +2 -2
  74. package/dist/configurator/ui/configurator-layout/universal/Layout.js +1 -1
  75. package/dist/configurator/ui/configurator-layout/universal/MobileLayout.js +4 -4
  76. package/dist/configurator/ui/legacy/mobile-controls/MobileControls.d.ts +1 -1
  77. package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.d.ts +2 -2
  78. package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.js +1 -1
  79. package/dist/docs/complex-use-cases/filtered-controls-with-fix-dialog.mdx +84 -98
  80. package/dist/docs/complex-use-cases/navigation-reset-selection.mdx +18 -12
  81. package/dist/docs/index.json +1 -1
  82. package/dist/docs/layouts/custom-price.mdx +14 -16
  83. package/dist/docs/layouts/sidebar/tabs.mdx +24 -21
  84. package/dist/docs/layouts/toolbar.mdx +3 -1
  85. package/dist/docs/other-features/domain-actions.mdx +1 -1
  86. package/dist/docs/other-features/side-effects.mdx +68 -34
  87. package/dist/docs/other-features/transformers.mdx +1 -1
  88. package/dist/docs/phoenix/admin.mdx +9 -24
  89. package/dist/docs/phoenix/localization.mdx +3 -22
  90. package/dist/docs/phoenix/phoenix-cli.mdx +81 -2
  91. package/dist/docs/phoenix/project-structure.mdx +9 -2
  92. package/dist/docs/phoenix/sdk-builder-workflow.mdx +4 -3
  93. package/dist/docs/recipes-and-delete/recipe-hierarchy-selection.mdx +15 -13
  94. package/dist/docs/relations/hierarchy.mdx +13 -2
  95. package/dist/domain/actions/action-factory.d.ts +3 -2
  96. package/dist/domain/application/application-config.d.ts +25 -75
  97. package/dist/domain/application/assistant/assistant-manifest.d.ts +61 -0
  98. package/dist/domain/application/assistant/assistant-resolved-manifest.d.ts +95 -0
  99. package/dist/domain/application/assistant/assistant-value-type.d.ts +9 -0
  100. package/dist/domain/application/assistant/assistant-value-type.js +1 -0
  101. package/dist/domain/application/assistant/build-assistant-manifest.d.ts +4 -0
  102. package/dist/domain/application/assistant/build-assistant-manifest.js +1 -0
  103. package/dist/{phoenix/application-spec → domain/application/assistant}/generate-assistant-prompt.d.ts +6 -5
  104. package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -0
  105. package/dist/domain/application/assistant/index.d.ts +4 -0
  106. package/dist/domain/application/assistant/index.js +1 -0
  107. package/dist/domain/application/assistant-field-options.d.ts +1 -1
  108. package/dist/domain/application/assistant-mutations.d.ts +1 -1
  109. package/dist/domain/application/assistant-recipe-groups.d.ts +1 -1
  110. package/dist/domain/application/configurator-builder.d.ts +33 -18
  111. package/dist/domain/application/configurator-builder.js +1 -1
  112. package/dist/domain/application/element-registration.d.ts +5 -0
  113. package/dist/domain/application/element-registration.js +1 -1
  114. package/dist/domain/application/handler-registration.d.ts +5 -0
  115. package/dist/domain/application/handler-registration.js +1 -1
  116. package/dist/domain/application/index.d.ts +5 -4
  117. package/dist/domain/application/index.js +1 -1
  118. package/dist/domain/application/resolve-imported-transformers.d.ts +11 -1
  119. package/dist/domain/application/resolve-imported-transformers.js +1 -1
  120. package/dist/domain/components/domain-component-optic.d.ts +3 -0
  121. package/dist/domain/components/domain-component-optic.js +2 -2
  122. package/dist/domain/components/system-component-builder.js +1 -1
  123. package/dist/domain/components/updates.d.ts +16 -0
  124. package/dist/domain/core/action.d.ts +1 -1
  125. package/dist/domain/core/component.d.ts +1 -1
  126. package/dist/domain/core/decoder/create-decoder.d.ts +6 -0
  127. package/dist/domain/core/decoder/create-decoder.js +1 -0
  128. package/dist/domain/core/decoder/decoder.d.ts +6 -0
  129. package/dist/domain/core/decoder/decoder.js +1 -0
  130. package/dist/domain/core/decoder/index.d.ts +2 -0
  131. package/dist/domain/core/decoder/index.js +1 -0
  132. package/dist/domain/core/domain-factory.js +1 -1
  133. package/dist/domain/core/index.d.ts +1 -3
  134. package/dist/domain/core/index.js +1 -1
  135. package/dist/domain/core/reflection.d.ts +1 -1
  136. package/dist/domain/core/reflection.js +1 -1
  137. package/dist/domain/core/schema/enhanced-json-schema.js +1 -0
  138. package/dist/domain/core/schema/extended-schema-validator.js +1 -0
  139. package/dist/domain/core/schema/index.d.ts +3 -0
  140. package/dist/domain/core/schema/index.js +1 -0
  141. package/dist/domain/core/schema/schema-validator.js +1 -0
  142. package/dist/domain/domain-builder.d.ts +10 -1
  143. package/dist/domain/domain-builder.js +1 -1
  144. package/dist/domain/domain-context/action-system/action-system.js +1 -1
  145. package/dist/domain/domain-context/index.d.ts +1 -1
  146. package/dist/domain/domain-context/store-system/store-system.js +1 -1
  147. package/dist/domain/domain-context/transformers/chain-builder.d.ts +1 -1
  148. package/dist/domain/domain-runtime/domain-runtime.d.ts +4 -4
  149. package/dist/domain/domain-runtime/spec/initialize.js +1 -1
  150. package/dist/domain/domain-runtime/spec/selectors.d.ts +2 -2
  151. package/dist/domain/domain-runtime/spec/selectors.js +1 -1
  152. package/dist/domain/domain-runtime/spec/types.d.ts +3 -3
  153. package/dist/domain/index.d.ts +3 -2
  154. package/dist/domain/index.js +1 -1
  155. package/dist/domain/invariants/invariants.d.ts +9 -0
  156. package/dist/domain/invariants/invariants.js +1 -1
  157. package/dist/domain/mocks/create-mock-domain-runtime.d.ts +3 -3
  158. package/dist/domain/mocks/create-mock-domain-runtime.js +1 -1
  159. package/dist/domain/project-modules/index.d.ts +1 -0
  160. package/dist/domain/project-modules/index.js +1 -0
  161. package/dist/domain/project-modules/project-modules.d.ts +41 -0
  162. package/dist/domain/project-modules/project-modules.js +1 -0
  163. package/dist/domain/system-components/common/dimension-indicator-schema.d.ts +1 -1
  164. package/dist/domain/system-components/common/dimension-indicator-schema.js +1 -1
  165. package/dist/editor/Editor.js +1 -1
  166. package/dist/editor/domain-editors/use-implementation-files.d.ts +7 -6
  167. package/dist/editor/domain-editors/use-implementation-files.js +1 -1
  168. package/dist/editor/graphql/GraphQLPanel.js +1 -1
  169. package/dist/editor/variants/VariantAnswerFooter.d.ts +17 -0
  170. package/dist/editor/variants/VariantAnswerFooter.js +1 -0
  171. package/dist/editor/variants/VariantPreviewHandler.d.ts +6 -0
  172. package/dist/editor/variants/VariantPreviewHandler.js +1 -0
  173. package/dist/editor/variants/variant-preview-styles.d.ts +49 -0
  174. package/dist/editor/variants/variant-preview-styles.js +1 -0
  175. package/dist/i18n/locales/cs/messages.js +1 -1
  176. package/dist/i18n/locales/da/messages.js +1 -1
  177. package/dist/i18n/locales/de/messages.js +1 -1
  178. package/dist/i18n/locales/de-AT/messages.js +1 -1
  179. package/dist/i18n/locales/en/messages.js +1 -1
  180. package/dist/i18n/locales/en-AU/messages.js +1 -1
  181. package/dist/i18n/locales/en-GB/messages.js +1 -1
  182. package/dist/i18n/locales/es/messages.js +1 -1
  183. package/dist/i18n/locales/fr/messages.js +1 -1
  184. package/dist/i18n/locales/hu/messages.js +1 -1
  185. package/dist/i18n/locales/it/messages.js +1 -1
  186. package/dist/i18n/locales/nl/messages.js +1 -1
  187. package/dist/i18n/locales/pl/messages.js +1 -1
  188. package/dist/i18n/locales/pt/messages.js +1 -1
  189. package/dist/i18n/locales/ro/messages.js +1 -1
  190. package/dist/i18n/locales/sk/messages.js +1 -1
  191. package/dist/i18n/locales/tr/messages.js +1 -1
  192. package/dist/legacy/domain-cli/gen/configurator-builder.js +21 -8
  193. package/dist/legacy/domain-cli/utils/cache.d.ts +1 -1
  194. package/dist/legacy/domain-cli/utils/cache.js +1 -1
  195. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-admin.js +18 -19
  196. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-configurator.js +15 -16
  197. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-admin.js +22 -23
  198. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-configurator.js +15 -16
  199. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/generator-shared.d.ts +7 -2
  200. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/generator-shared.js +8 -12
  201. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/index.d.ts +1 -1
  202. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/index.js +1 -1
  203. package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/webhook-builders.js +7 -7
  204. package/dist/phoenix/application-spec/application-spec-builder.js +1 -1
  205. package/dist/phoenix/application-spec/resolve-deployment-data.d.ts +4 -3
  206. package/dist/phoenix/application-spec/resolve-deployment-data.js +2 -2
  207. package/dist/phoenix/cli.js +1 -1
  208. package/dist/phoenix/commands/deploy.js +2 -2
  209. package/dist/phoenix/commands/dev.js +5 -5
  210. package/dist/phoenix/commands/index.d.ts +1 -0
  211. package/dist/phoenix/commands/index.js +1 -1
  212. package/dist/phoenix/commands/prepare-deployment-command.js +2 -2
  213. package/dist/phoenix/commands/prepare-local-environment-command.js +1 -1
  214. package/dist/phoenix/commands/story-dev.js +2 -2
  215. package/dist/phoenix/commands/variants.d.ts +35 -0
  216. package/dist/phoenix/commands/variants.js +1 -0
  217. package/dist/phoenix/editor-server/commands-router.d.ts +68 -1
  218. package/dist/phoenix/editor-server/commands-router.js +1 -1
  219. package/dist/phoenix/editor-server/editor-router.d.ts +65 -0
  220. package/dist/phoenix/editor-server/editor-server.d.ts +3 -3
  221. package/dist/phoenix/editor-server/editor-server.js +1 -1
  222. package/dist/phoenix/editor-server/protocol.d.ts +1 -0
  223. package/dist/phoenix/editor-server/spec-router.js +1 -1
  224. package/dist/phoenix/editor-server/trpc.d.ts +3 -0
  225. package/dist/phoenix/services/application-spec-project-watcher.d.ts +13 -2
  226. package/dist/phoenix/services/application-spec-project-watcher.js +3 -3
  227. package/dist/phoenix/services/index.d.ts +4 -0
  228. package/dist/phoenix/services/index.js +1 -1
  229. package/dist/phoenix/services/phoenix-application.d.ts +21 -0
  230. package/dist/phoenix/services/phoenix-application.js +1 -0
  231. package/dist/phoenix/services/phoenix-store.d.ts +48 -0
  232. package/dist/phoenix/services/phoenix-store.js +1 -0
  233. package/dist/phoenix/services/phx-variant-previews-plugin.d.ts +9 -0
  234. package/dist/phoenix/services/phx-variant-previews-plugin.js +1 -0
  235. package/dist/phoenix/services/prepare-development-environment.js +1 -1
  236. package/dist/phoenix/services/variant-file-session.d.ts +36 -0
  237. package/dist/phoenix/services/variant-file-session.js +1 -0
  238. package/dist/phoenix/services/variant-preview-service.d.ts +80 -0
  239. package/dist/phoenix/services/variant-preview-service.js +1 -0
  240. package/dist/phoenix/services/vite-config.js +1 -1
  241. package/dist/react-sdk/application-runtime/common-services/analytics/analytics-service.d.ts +2 -2
  242. package/dist/react-sdk/application-runtime/common-services/analytics/domain-controls-analytics.d.ts +21 -21
  243. package/dist/react-sdk/application-runtime/hooks/data/use-published-data.d.ts +1 -1
  244. package/dist/react-sdk/application-runtime/hooks/use-domain-application-props.d.ts +5 -2
  245. package/dist/react-sdk/application-runtime/hooks/use-spec.d.ts +1 -1
  246. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.d.ts +1 -1
  247. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.js +1 -1
  248. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +4 -4
  249. package/dist/ui-sdk/common/use-viewport-size.d.ts +4 -1
  250. package/dist/ui-sdk/common/use-viewport-size.js +1 -1
  251. package/dist/ui-sdk/components/mobile-controls/index.d.ts +1 -1
  252. package/dist/webhook/builders/common.d.ts +3 -0
  253. package/dist/webhook/builders/webhook-builder.d.ts +1 -1
  254. package/dist/webhook/builders/webhook-builder.js +1 -1
  255. package/package.json +4 -4
  256. package/dist/configurator/assistant/index.d.ts +0 -1
  257. package/dist/configurator/assistant/index.js +0 -1
  258. package/dist/configurator/assistant/use-assistant-chat.d.ts +0 -30
  259. package/dist/configurator/assistant/use-assistant-chat.js +0 -1
  260. package/dist/configurator/ui/assistant/AssistantPanelProvider.d.ts +0 -42
  261. package/dist/configurator/ui/assistant/AssistantPanelProvider.js +0 -1
  262. package/dist/domain/core/json-schema.js +0 -1
  263. package/dist/phoenix/application-spec/generate-assistant-prompt.js +0 -1
  264. /package/dist/domain/{core/enhanced-json-schema.js → application/assistant/assistant-manifest.js} +0 -0
  265. /package/dist/domain/{core/schema-validator.js → application/assistant/assistant-resolved-manifest.js} +0 -0
  266. /package/dist/domain/core/{schema-validator-ajv.d.ts → schema/create-ajv-schema-validator.d.ts} +0 -0
  267. /package/dist/domain/core/{schema-validator-ajv.js → schema/create-ajv-schema-validator.js} +0 -0
  268. /package/dist/domain/core/{schema-validator-csp.d.ts → schema/create-csp-schema-validator.d.ts} +0 -0
  269. /package/dist/domain/core/{schema-validator-csp.js → schema/create-csp-schema-validator.js} +0 -0
  270. /package/dist/domain/core/{enhanced-json-schema.d.ts → schema/enhanced-json-schema.d.ts} +0 -0
  271. /package/dist/domain/core/{json-schema.d.ts → schema/extended-schema-validator.d.ts} +0 -0
  272. /package/dist/domain/core/{schema-validator.d.ts → schema/schema-validator.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ let e=["How to read the GraphQL schema of this configurator:","- A configuration is a set of entities. `root` is the root entity, `entities` lists every entity or the ones with the given ids, and `selectedEntity` is the entity the user has selected, or the root entity when nothing is selected.","- Every entity has an `id` of the form `<Type>-<number>`, for example `Table-1`, and a `type` with its entity type name. Ids are assigned by the configurator: read them from the configuration and never make one up.","- A field whose name starts with `_` is computed by the configurator from other values. It can be read like any other field and never written.","- Numbers are in the units the configuration stores them in. A field description names the unit when the product defines one.",'- A text field that only takes fixed values lists them in its description as "One of: ...". Use exactly those values.',"- A field typed as another entity type or as a list of one is a relation: select fields on it to read the related entities.","- Field and type descriptions come from the team that built the configurator and say what a value means for the product."],t=["How changes work:","- Every field of the `Mutation` type is one change. Its description says what it changes and what it returns.","- The configurator checks the whole configuration after each change. A change that would leave it invalid fails with an error that names the entities at fault, and it is not applied. Later changes of the same request are then not run.","- The configurator may adjust other values in response to a change, so read what a mutation returns instead of assuming the values you sent."],a=["How to add entities:","- Entities are added from recipes, the same ones the configurator offers the user. An entity type that can take children has a `meta` field; `meta { childRecipes }` lists its recipe groups and their recipes.","- List the recipes of the group first, pick one by its `key`, then call `addChild` with the id of the parent, the `groupId` and the `key`. Keys change with the configuration and the language, so never reuse one from memory.","- `dryRun` on a recipe shows what adding it would do without adding it: whether it is `ok`, the `changedEntities` it would add or modify, the `deletedEntityIds` it would remove, the `sideEffects` the configurator says it would have, and the `errors` when it cannot be added. An entity whose id the configuration does not have yet is new. It is costly, so select it only on the recipes you are deciding between.","- Put each `addChild` in its own operation. The recipes of a group and what they add depend on the configuration before them, so after adding something, list the group again before adding from it once more."],n=["How to replace entities:","- An entity is replaced from recipes, the same ones the configurator offers the user. An entity type that can be replaced has a `meta` field; `meta { replaceRecipes }` lists its replace recipe groups and what the entity can be replaced with.","- List the recipes of the group first, pick one by its `key`, then call `replaceEntity` with the id of the entity, the `groupId` and the `key`. `dryRun` on a replace recipe shows what replacing would do without doing it: the replacement and everything else that changes are under `changedEntities`, and the replaced entity is among the `deletedEntityIds`.","- The replacement is a new entity with a new id, and its field values come from the recipe, so they can differ from those of the entity it replaces. Read the ids and values `replaceEntity` returns, and never use the old id again.","- Put each `replaceEntity` in its own operation. The recipes of a group and what they do depend on the configuration before them, so after replacing something, list the group of the replacement again before replacing once more."],o=["How to find the values a field can take:","- Some fields store a key whose choices the configurator holds elsewhere. Such a field has an edge under `meta` named after it: `meta { <field>Options }` lists its choices, each with the `value` to write and the `name` the user sees.","- Read the choices before you write such a field or name a choice to the user, and write the `value`, not the `name`. A value outside the list is rejected unless the edge description says the field is not checked.","- `dryRun` on an option shows what writing its value would do without writing it: whether it is `ok`, the `changedEntities` it would add or modify, the `deletedEntityIds` it would remove, the `sideEffects` the configurator says it would have, and the `errors` when the value cannot be written. It is costly, so select it only on the options you are deciding between. It is null when the edge description says the options cannot be dry-run.","- The choices can depend on the entity and on its current state. Read them again after a change, unless the edge description says they are the same for all instances or do not change."],i=["How the custom changes of this configurator work:","- Besides the generic changes, the `Mutation` type has fields the team built for this product. Each runs one domain operation the configurator itself uses, so prefer it over composing the same change from generic mutations. Its description says what it does and what its arguments mean.","- Its arguments are checked against what the operation declares; an argument that does not fit, or a change the product does not allow, fails the field with a message that says what to send instead.","- It returns an object whose fields the description names; a field typed as an entity reads that entity after the change."],s=["How to use the `query` and `apply` tools:","- Both take `operations`, a list of GraphQL documents that run in order. Each document holds exactly one operation. To do several things, send several items in one call instead of several calls.","- Write values into the document as literals. Use `variables` only for a value that cannot be written as a literal.","- Select only the fields you need: results are returned whole.","- The result has one GraphQL result per operation, in the order sent. When an operation fails, its `errors` say why and the operations after it are not run.","- `query` reads the configuration the user has open and never changes it. Call it before you say anything about the configuration."],h=["- This configurator exposes no changes, so there is nothing for `apply` to run. Say so when the user asks you to change the configuration."],r=['- Mutations inside `query` answer "what if" questions. Each operation sees the changes of the ones before it, so a mutation followed by a query shows the configuration as it would be. Nothing is kept and the user sees no change.',"- `apply` makes the changes the user asked for. It is all or nothing: when any operation fails, nothing is changed; when all succeed, the user gets them as one undo step.","- `committed` in the result says whether the changes were kept. When it is false although no operation failed, `message` says why: the changes may be waiting for the approval of the user, the user may have changed the configuration meanwhile, or this session may not change the configuration at all. Without a `message`, the operations changed nothing. Never tell the user a change was made unless `committed` is true.","- `sideEffects` in the result lists what the configurator did beyond what the operations asked for, such as parts it added or replaced to keep the configuration valid, in its own words. Tell the user about them when the changes were kept. When they were not, or in `query`, it lists what the mutations that succeeded would do. `dryRun` has the same list for a single recipe or option."],d=["How to read the change record:","- Every user message starts with a change record of the configuration since your previous action. It is the complete list of the entities that were added or deleted, of the stored fields of this schema that changed, and of the selection and navigation changes, so update your picture from it and do not query those again when it does not mention them.","- Fields whose name starts with `_` are computed and are never listed. Read them again when the record lists a change they may depend on.","- `[changes: none]`: nothing changed. Do not query again what you already know.","- `[changes]` is followed by one line per change. `selected`, `navigationState`, `viewState` and `toolState` lines show `<old> -> <new>` of what `selectedEntity` and `navigation` return, with `none` for an empty value. `A <id>` is an added entity and `D <id>` a deleted one. `M <id>` is a modified entity, followed by one `<field>: <old> -> <new>` line per changed field, under the name the field has in this schema. A `reset: undo/redo` line says the user undid or redid changes.","- The `#` comment at the end of a line names the control, the transformer or the explanation of the last change to that line.","- `[changes: unavailable]`: the page was loaded since your previous action, so earlier values may be stale. `[changes: too many (n)]`: n entities changed and are not listed. In both cases query what you need."],c=["- Changes you applied are not in the record, except those that were waiting for the approval of the user: they appear in it once approved."];export const generateAssistantPrompt=l=>{let u=/^type Mutation\b/m.test(l.sdl);return[e,...u?[t]:[],.../^\s+addChild\(/m.test(l.sdl)?[a]:[],.../^\s+replaceEntity\(/m.test(l.sdl)?[n]:[],.../^type FieldOption\b/m.test(l.sdl)?[o]:[],...Object.keys(l.actions??{}).length>0?[i]:[],[...s,...u?r:h],[...d,...u?c:[]]].map(e=>e.join("\n")).join("\n\n")};
@@ -0,0 +1,4 @@
1
+ export type { AssistantResolvedManifest, AssistantResolvedField, AssistantValueType, AssistantRelationType, AssistantStates, AssistantWritableType, AssistantWritableField, AssistantResolvedHint, AssistantResolvedRecipes, AssistantResolvedOptionsEdge, AssistantResolvedAction, AssistantResolvedActionResult, } from './assistant-resolved-manifest.js';
2
+ export { buildAssistantManifest } from './build-assistant-manifest.js';
3
+ export type { AssistantFieldSource, AssistantRecipeGroup, AssistantFieldOptions, AssistantManifest, } from './assistant-manifest.js';
4
+ export { generateAssistantPrompt } from './generate-assistant-prompt.js';
@@ -0,0 +1 @@
1
+ export{buildAssistantManifest}from"./build-assistant-manifest.js";export{generateAssistantPrompt}from"./generate-assistant-prompt.js";
@@ -1,7 +1,7 @@
1
1
  import type { DomainEntity, DomainEntityId } from '../core/model.js';
2
2
  import type { DomainState } from '../core/state.js';
3
- import type { AssistantFieldOptions, AssistantManifest } from './application-config.js';
4
3
  import type { AssistantRecipeContext } from './assistant-recipe-groups.js';
4
+ import type { AssistantFieldOptions, AssistantManifest } from './assistant/index.js';
5
5
  type AnyDomainState = DomainState<DomainEntity<string>>;
6
6
  /**
7
7
  * One choice of a writable field as the assistant reads it, whatever component holds it: the value
@@ -3,7 +3,7 @@ import { type StateUpdate } from '../components/updates.js';
3
3
  import type { AnyActionContext } from '../core/action.js';
4
4
  import { type DomainEntity } from '../core/model.js';
5
5
  import type { DomainState } from '../core/state.js';
6
- import type { AssistantManifest } from './application-config.js';
6
+ import type { AssistantManifest } from './assistant/index.js';
7
7
  type AnyDomainState = DomainState<DomainEntity<string>>;
8
8
  /**
9
9
  * Update tag of user-intended entity deletions, from the configurator's delete controls and the
@@ -11,7 +11,7 @@ import type { RecipeListItem } from '../system-components/common/recipes.js';
11
11
  import type { DistanceDimensionSelectComponent } from '../system-components/distance-dimension-select.js';
12
12
  import type { MaterialSwatchComponent } from '../system-components/material-swatch.js';
13
13
  import { type ReplaceEntityRecipesComponent } from '../system-components/replace-entity-recipes.js';
14
- import type { AssistantManifest, AssistantRecipeGroup } from './application-config.js';
14
+ import type { AssistantManifest, AssistantRecipeGroup } from './assistant/index.js';
15
15
  type AnyDomainState = DomainState<DomainEntity<string>>;
16
16
  /** An update a recipe cooks to: the creation of an entity, or the replacement of the entity a replace recipe is for. */
17
17
  type AnyRecipeUpdate = DomainEntityCreation<DomainEntity<string>, DomainEntity<string>> | DomainEntityReplacement<DomainEntity<string>>;
@@ -2,12 +2,10 @@ import type { I18n } from '@lingui/core';
2
2
  import type { ThemeOptions } from '@mui/material';
3
3
  import type { z } from 'zod';
4
4
  import type { FinalizeTaskResource } from '@salsita-ai/contracts/webhook';
5
- import type { DomainComponentOptic } from '../components/domain-component-optic.js';
6
- import type { $DomainEntity, DomainEntity, DomainFactory, EnumLike, ProductPreset, SchemaOfObject, SystemComponentTypeConstraint } from '../core/index.js';
7
- import type { DomainContextSystems, Transformers } from '../domain-context/index.js';
8
- import type { AclConfig, ApplicationConfig, AssistantManifest, DataSpec, DefaultEnvs, ImportedTransformer, ResourcesConfig, SpecTransformer, UserInterfaceConfig } from './application-config.js';
9
- import type { ElementRegistration } from './element-registration.js';
10
- import type { HandlerRegistration } from './handler-registration.js';
5
+ import type { $DomainEntity, DomainEntity, DomainFactory, EnumLike, ProductPreset, SchemaOfObject } from '../core/index.js';
6
+ import type { ProjectModule } from '../project-modules/index.js';
7
+ import type { AclConfig, ApplicationConfig, DataSpec, DefaultEnvs, ResourcesConfig, SpecTransformer, TransformersConfig, UserInterfaceConfig } from './application-config.js';
8
+ import type { AssistantResolvedManifest } from './assistant/index.js';
11
9
  interface ConfiguratorBuilderContext<ENTITIES extends DomainEntity<string> = never, ALLOWED_ROOT_ENTITIES extends ENTITIES = never, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>> = never, NAVIGATION_STATES extends string = never, VIEW_STATES extends string = never, TOOL_STATES extends string = never, EXPORT_STATES extends string = never, PUBLISHED_DATA extends Record<string, unknown> = never, SESSION_DATA extends Record<string, unknown> = never, FRONTEND_DATA extends Record<string, unknown> = never, ADMIN_ENTITIES extends DomainEntity<string> = never, ADMIN_ALLOWED_ROOT_ENTITIES extends ADMIN_ENTITIES = never, ADMIN_$MAP extends Record<ADMIN_ENTITIES['type'], $DomainEntity<ADMIN_ENTITIES>> = never, ADMIN_NAVIGATION_STATES extends string = never, ADMIN_VIEW_STATES extends string = never, FINALIZE_DATA extends Record<string, unknown> = never, PREFETCHED_FINALIZE_DATA extends Record<string, unknown> = never, FINALIZE_RESULT extends Record<string, unknown> = never, CALLBACK_DATA extends Record<string, unknown> = never, RESOURCE extends string = never> {
12
10
  version?: string;
13
11
  textLanguages?: string[];
@@ -18,13 +16,13 @@ interface ConfiguratorBuilderContext<ENTITIES extends DomainEntity<string> = nev
18
16
  viewState?: EnumLike<VIEW_STATES>;
19
17
  toolState?: EnumLike<TOOL_STATES>;
20
18
  exportState?: EnumLike<EXPORT_STATES>;
21
- componentOptics: ReadonlyArray<DomainComponentOptic<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITIES, SystemComponentTypeConstraint>>;
19
+ componentOptics: readonly ProjectModule[];
22
20
  i18n?: I18n;
23
21
  adminDomainFactory?: DomainFactory<ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
24
22
  adminPresets?: ReadonlyArray<ProductPreset<ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES>>;
25
23
  adminNavigationState?: EnumLike<ADMIN_NAVIGATION_STATES>;
26
24
  adminViewState?: EnumLike<ADMIN_VIEW_STATES>;
27
- adminComponentOptics: ReadonlyArray<DomainComponentOptic<ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, SystemComponentTypeConstraint>>;
25
+ adminComponentOptics: readonly ProjectModule[];
28
26
  publishedData?: z.ZodType<PUBLISHED_DATA>;
29
27
  finalizeData?: SchemaOfObject<FINALIZE_DATA>;
30
28
  prefetchedFinalizeData?: SchemaOfObject<PREFETCHED_FINALIZE_DATA>;
@@ -32,7 +30,7 @@ interface ConfiguratorBuilderContext<ENTITIES extends DomainEntity<string> = nev
32
30
  callbackData?: SchemaOfObject<CALLBACK_DATA>;
33
31
  resources?: ReadonlyArray<FinalizeTaskResource<RESOURCE>>;
34
32
  dataSpec?: DataSpec;
35
- createTransformers?: (ctx: DomainContextSystems<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>) => Transformers<ENTITIES>;
33
+ transformers?: TransformersConfig;
36
34
  acl?: AclConfig;
37
35
  enableAdminRelease?: boolean;
38
36
  ui?: Pick<UserInterfaceConfig, 'appLoader' | 'preview' | 'alwaysExpand'>;
@@ -41,11 +39,11 @@ interface ConfiguratorBuilderContext<ENTITIES extends DomainEntity<string> = nev
41
39
  readonly scope: string;
42
40
  }>>;
43
41
  publishedDataHash?: string;
44
- assistant?: AssistantManifest | null;
42
+ assistant?: AssistantResolvedManifest | null;
45
43
  theme?: ThemeOptions;
46
44
  tagName?: string;
47
- handlers?: ReadonlyArray<HandlerRegistration<any, any>>;
48
- elements?: readonly ElementRegistration[];
45
+ handlers?: readonly ProjectModule[];
46
+ elements?: readonly ProjectModule[];
49
47
  }
50
48
  export declare class ConfiguratorBuilder<ENTITIES extends DomainEntity<string> = never, ALLOWED_ROOT_ENTITIES extends ENTITIES = never, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>> = never, NAVIGATION_STATES extends string = never, VIEW_STATES extends string = never, TOOL_STATES extends string = never, EXPORT_STATES extends string = never, PUBLISHED_DATA extends Record<string, unknown> = never, SESSION_DATA extends Record<string, unknown> = never, FRONTEND_DATA extends Record<string, unknown> = never, ADMIN_ENTITIES extends DomainEntity<string> = never, ADMIN_ALLOWED_ROOT_ENTITIES extends ADMIN_ENTITIES = never, ADMIN_$MAP extends Record<ADMIN_ENTITIES['type'], $DomainEntity<ADMIN_ENTITIES>> = never, ADMIN_NAVIGATION_STATES extends string = never, ADMIN_VIEW_STATES extends string = never, FINALIZE_DATA extends Record<string, unknown> = never, PREFETCHED_FINALIZE_DATA extends Record<string, unknown> = never, FINALIZE_RESULT extends Record<string, unknown> = never, CALLBACK_DATA extends Record<string, unknown> = never, RESOURCE extends string = never> {
51
49
  private readonly _context;
@@ -61,7 +59,7 @@ export declare class ConfiguratorBuilder<ENTITIES extends DomainEntity<string> =
61
59
  readonly scope: string;
62
60
  }>>): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
63
61
  withPublishedDataHash(publishedDataHash: string): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
64
- withAssistant(assistant: AssistantManifest | null): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
62
+ withAssistant(assistant: AssistantResolvedManifest | null): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
65
63
  withTheme(theme: ThemeOptions): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
66
64
  withDomainFactory<NEW_ENTITIES extends DomainEntity<string>, NEW_ALLOWED_ROOT_ENTITIES extends NEW_ENTITIES, NEW_MAP extends Record<NEW_ENTITIES['type'], $DomainEntity<NEW_ENTITIES>>, NEW_PUBLISHED_DATA extends Record<string, unknown>, NEW_SESSION_DATA extends Record<string, unknown>, NEW_FRONTEND_DATA extends Record<string, unknown>>(domainFactory: DomainFactory<NEW_ENTITIES, NEW_ALLOWED_ROOT_ENTITIES, NEW_MAP, NEW_PUBLISHED_DATA, NEW_SESSION_DATA, NEW_FRONTEND_DATA>): ConfiguratorBuilder<NEW_ENTITIES, NEW_ALLOWED_ROOT_ENTITIES, NEW_MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, NEW_PUBLISHED_DATA, NEW_SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
67
65
  withAdminDomainFactory<NEW_ADMIN_ENTITIES extends DomainEntity<string>, NEW_ADMIN_ALLOWED_ROOT_ENTITIES extends NEW_ADMIN_ENTITIES, NEW_ADMIN_MAP extends Record<NEW_ADMIN_ENTITIES['type'], $DomainEntity<NEW_ADMIN_ENTITIES>>>(adminDomainFactory: DomainFactory<NEW_ADMIN_ENTITIES, NEW_ADMIN_ALLOWED_ROOT_ENTITIES, NEW_ADMIN_MAP, any, any, any>): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, NEW_ADMIN_ENTITIES, NEW_ADMIN_ALLOWED_ROOT_ENTITIES, NEW_ADMIN_MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
@@ -78,17 +76,34 @@ export declare class ConfiguratorBuilder<ENTITIES extends DomainEntity<string> =
78
76
  withAdminViewState<NEW_ADMIN_VIEW_STATES extends string>(adminViewState: EnumLike<NEW_ADMIN_VIEW_STATES>): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, NEW_ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
79
77
  withPresets(presets: ReadonlyArray<ProductPreset<ENTITIES, ALLOWED_ROOT_ENTITIES>>): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
80
78
  withAdminPresets(adminPresets: ReadonlyArray<ProductPreset<ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES>>): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
81
- withComponentOptics(componentOptics: ReadonlyArray<DomainComponentOptic<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITIES, SystemComponentTypeConstraint>>): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
82
- withAdminComponentOptics(componentOptics: ReadonlyArray<DomainComponentOptic<ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, SystemComponentTypeConstraint>>): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
83
- withHandlers(handlers: ReadonlyArray<HandlerRegistration<any, any>>): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
84
- withElements(elements: readonly ElementRegistration[]): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
79
+ /** Adds component optics as project modules: the `src/components/` files, or the optics a generated file lists. The runtime spec validates them. */
80
+ withComponentOptics(componentOptics: readonly ProjectModule[]): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
81
+ /** Adds admin component optics as project modules: the `src/admin/components/` files, or the optics a generated file lists. The runtime spec validates them. */
82
+ withAdminComponentOptics(componentOptics: readonly ProjectModule[]): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
83
+ /**
84
+ * Sets the handlers as project modules, one per `src/handlers/` file. They are stored unread: the
85
+ * runtime spec validates them, and `buildConfig` inspects them only afterwards.
86
+ */
87
+ withHandlers(handlers: readonly ProjectModule[]): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
88
+ /** Sets the elements as project modules, one per `src/elements/` file, for the runtime spec to validate. */
89
+ withElements(elements: readonly ProjectModule[]): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
85
90
  withResources<NEW_RESOURCE extends string>(resources: ReadonlyArray<FinalizeTaskResource<NEW_RESOURCE>>): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, NEW_RESOURCE>;
86
91
  withWebComponentTag(tagName: string): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
87
- withTransformers(importedTransformers: ReadonlyArray<ImportedTransformer<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>>, specTransformers: readonly SpecTransformer[]): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
92
+ /**
93
+ * Sets the transformers: the `src/transformers/` files as project modules, and the spec's `transformers`
94
+ * section that selects and orders them. The runtime spec validates the files and builds the factory.
95
+ */
96
+ withTransformers(importedTransformers: readonly ProjectModule[], specTransformers: readonly SpecTransformer[]): ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
88
97
  withInterface(_interface: unknown): this;
89
98
  withDataSpec: (dataSpec: DataSpec) => ConfiguratorBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>;
90
99
  private _computeInitialPublishedData;
91
100
  buildConfig(): ApplicationConfig<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, Record<string, unknown>, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES>;
101
+ /**
102
+ * Builds the config together with the validated handlers. The handlers are read from the bootstrap
103
+ * runtime's spec rather than from the builder context, so nothing here touches a project file's
104
+ * export before the spec has checked it against its folder's contract.
105
+ */
106
+ private _buildConfigWithHandlers;
92
107
  buildWebhookContext(): {
93
108
  config: ApplicationConfig<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, Record<string, unknown>, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES>;
94
109
  parseFinalizeData: (data: unknown) => FINALIZE_DATA;
@@ -1 +1 @@
1
- import{initConsoleLogger as t}from"@salsita-ai/common/utils";import{defaultI18n as e}from"#package/i18n";import{extendedSchemaValidator as i}from"../core/json-schema.js";import{NoopAnalyticsSystem as r}from"../domain-context/index.js";import{createDomainRuntime as n}from"../domain-runtime/index.js";import{isGetApplicationWrapperHandler as o}from"./GetApplicationWrapperHandler.js";import{isGetWebComponentOptionsHandler as a}from"./GetWebComponentOptions.js";import{createInitialPublishedData as s}from"./create-initial-published-data.js";import{isDataRowValidatorHandler as h}from"./published-data/DataRowValidatorHandler.js";import{isFilterPublishedChunksHandler as l}from"./published-data/FilterPublishedChunksHandler.js";import{isMapPublishedChunkedDataHandler as u}from"./published-data/MapPublishedChunkedDataHandler.js";import{isMapPublishedRevisionDataHandler as c}from"./published-data/MapPublishedRevisionDataHandler.js";import{isSheetValidatorHandler as d}from"./published-data/SheetValidatorHandler.js";import{resolveImportedTransformers as m}from"./resolve-imported-transformers.js";export class ConfiguratorBuilder{_context;constructor(t){this._context=t}withDefaultEnvs(t){return new ConfiguratorBuilder({...this._context,defaultEnvs:t})}withVersion(t){return new ConfiguratorBuilder({...this._context,version:t})}withTextLanguages(t){return new ConfiguratorBuilder({...this._context,textLanguages:t})}withAcl(t){return new ConfiguratorBuilder({...this._context,acl:t})}withAdminRelease(t){return new ConfiguratorBuilder({...this._context,enableAdminRelease:t})}withUi(t){return new ConfiguratorBuilder({...this._context,ui:t})}withResourcesConfig(t){return new ConfiguratorBuilder({...this._context,resourcesConfig:t})}withChunks(t){return new ConfiguratorBuilder({...this._context,chunks:t})}withPublishedDataHash(t){return new ConfiguratorBuilder({...this._context,publishedDataHash:t})}withAssistant(t){return new ConfiguratorBuilder({...this._context,assistant:t})}withTheme(t){return new ConfiguratorBuilder({...this._context,theme:t})}withDomainFactory(t){return new ConfiguratorBuilder({...this._context,domainFactory:t})}withAdminDomainFactory(t){return new ConfiguratorBuilder({...this._context,adminDomainFactory:t})}withI18n=t=>new ConfiguratorBuilder({...this._context,i18n:t});withPrefetchedFinalizeData(t){return new ConfiguratorBuilder({...this._context,prefetchedFinalizeData:t})}withFinalizeData(t){return new ConfiguratorBuilder({...this._context,finalizeData:t})}withFinalizeResult(t){return new ConfiguratorBuilder({...this._context,finalizeResult:t})}withCallbackData(t){return new ConfiguratorBuilder({...this._context,callbackData:t})}withNavigationState(t){return new ConfiguratorBuilder({...this._context,navigationState:t})}withViewState(t){return new ConfiguratorBuilder({...this._context,viewState:t})}withToolState(t){return new ConfiguratorBuilder({...this._context,toolState:t})}withExportState(t){return new ConfiguratorBuilder({...this._context,exportState:t})}withAdminNavigationState(t){return new ConfiguratorBuilder({...this._context,adminNavigationState:t})}withAdminViewState(t){return new ConfiguratorBuilder({...this._context,adminViewState:t})}withPresets(t){return new ConfiguratorBuilder({...this._context,presets:t})}withAdminPresets(t){return new ConfiguratorBuilder({...this._context,adminPresets:t})}withComponentOptics(t){return new ConfiguratorBuilder({...this._context,componentOptics:[...this._context.componentOptics,...t]})}withAdminComponentOptics(t){return new ConfiguratorBuilder({...this._context,adminComponentOptics:[...this._context.adminComponentOptics??[],...t]})}withHandlers(t){if(t.filter(t=>l(t)).length>1)throw Error("Multiple createFilterPublishedChunksHandler handlers found. Only one handler is allowed.");if(t.filter(t=>h(t)).length>1)throw Error("Multiple createDataRowValidatorHandler handlers found. Only one handler is allowed.");if(t.filter(t=>d(t)).length>1)throw Error("Multiple createSheetValidatorHandler handlers found. Only one handler is allowed.");return new ConfiguratorBuilder({...this._context,handlers:t})}withElements(t){return new ConfiguratorBuilder({...this._context,elements:t})}withResources(t){return new ConfiguratorBuilder({...this._context,resources:t})}withWebComponentTag(t){return new ConfiguratorBuilder({...this._context,tagName:t})}withTransformers(t,e){return new ConfiguratorBuilder({...this._context,createTransformers:i=>m(t,e,i)})}withInterface(t){return this}withDataSpec=t=>new ConfiguratorBuilder({...this._context,dataSpec:t});_computeInitialPublishedData(t,e){if(!this._context.adminDomainFactory)throw Error("adminDomainFactory is required!");return s({adminDomainFactory:this._context.adminDomainFactory,domainRuntime:e,adminPresets:this._context.adminPresets??[],handlers:this._context.handlers,dataSpec:this._context.dataSpec,chunks:this._context.chunks,logger:t})}buildConfig(){if(!this._context.domainFactory)throw Error("Can not create application config, domainFactory is required! Is it registered with the ConfiguratorBuilder?");if(!this._context.presets)throw Error("Can not create application config, presets are required! Is it registered with the ConfiguratorBuilder?");if(!this._context.adminDomainFactory)throw Error("Can not create application config, adminDomainFactory is required! Is it registered with the ConfiguratorBuilder?");if(!this._context.adminPresets)throw Error("Can not create application config, adminPresets are required! Is it registered with the ConfiguratorBuilder?");if(!this._context.version)throw Error("Can not create application config, version is required!");let i=this._context.handlers?.find(o)?.handler().handler,s=this._context.handlers?.find(a)?.handler().handler(void 0),h={defaultEnvs:this._context.defaultEnvs,services:{i18n:this._context.i18n},version:this._context.version,initialPublishedData:{},domain:{textLanguages:this._context.textLanguages,componentOptics:this._context.componentOptics,presets:this._context.presets,domainFactory:this._context.domainFactory},navigation:{navigationStates:this._context.navigationState?.values(),viewStates:this._context.viewState?.values(),toolStates:this._context.toolState?.values(),exportStates:this._context.exportState?.values()},adminNavigation:{navigationStates:this._context.adminNavigationState?.values(),viewStates:this._context.adminViewState?.values()},adminDomain:{textLanguages:this._context.textLanguages,componentOptics:this._context.adminComponentOptics??[],presets:this._context.adminPresets,domainFactory:this._context.adminDomainFactory},mount:{tag:this._context.tagName??"salsita-configurator",options:s??{},Application:i},handlers:this._context.handlers??[],elements:this._context.elements??[],createTransformers:this._context.createTransformers,features:{acl:this._context.acl,enableAdminRelease:this._context.enableAdminRelease},ui:{preview:this._context.ui?.preview,alwaysExpand:this._context.ui?.alwaysExpand,theme:this._context.theme},resources:this._context.resourcesConfig,chunks:this._context.chunks,publishedDataHash:this._context.publishedDataHash,assistant:this._context.assistant,dataSpec:this._context.dataSpec},l=t(),u=n({config:h,services:{analyticsService:new r,i18n:e,logger:l}}),c=this._computeInitialPublishedData(l,u);return{...h,initialPublishedData:c}}buildWebhookContext(){if(!this._context.domainFactory)throw Error("domainFactory is required!");if(!this._context.adminDomainFactory)throw Error("adminDomainFactory is required!");if(!this._context.adminPresets)throw Error("adminPresets are required!");let t=this.buildConfig(),e=t=>{if(null==this._context.finalizeData)return{};let e=i.compile(this._context.finalizeData);if(!e(t))throw console.error("Finalize data validation errors:",e.errors),Error("Invalid finalize data!");return t},r=t=>{if(null==this._context.finalizeResult)return{};let e=i.compile(this._context.finalizeResult);if(!e(t))throw console.error("Finalize result validation errors:",e.errors),Error("Invalid finalize result!");return t},n=t=>{if(null==this._context.callbackData)return{};let e=i.compile(this._context.callbackData);if(!e(t))throw console.error("Callback data validation errors:",e.errors),Error("Invalid callback data!");return t},o=this._context.handlers?.find(c)?.handler().handler,a=this._context.handlers?.find(u)?.handler().handler,s=this._context.handlers?.find(h)?.handler().handler,l=this._context.handlers?.find(d)?.handler().handler;return{config:t,parseFinalizeData:e,parseFinalizeResult:r,resources:this._context.resources??[],parseCallbackData:n,mapPublishedRevisionData:o,mapPublishedChunkedData:a,dataRowValidator:s,sheetValidator:l}}}
1
+ import{initConsoleLogger as t}from"@salsita-ai/common/utils";import{defaultI18n as e}from"#package/i18n";import{extendedSchemaValidator as i}from"../core/schema/index.js";import{NoopAnalyticsSystem as r}from"../domain-context/index.js";import{createDomainRuntime as n}from"../domain-runtime/index.js";import{isGetApplicationWrapperHandler as o}from"./GetApplicationWrapperHandler.js";import{isGetWebComponentOptionsHandler as a}from"./GetWebComponentOptions.js";import{createInitialPublishedData as s}from"./create-initial-published-data.js";import{isDataRowValidatorHandler as h}from"./published-data/DataRowValidatorHandler.js";import{isFilterPublishedChunksHandler as l}from"./published-data/FilterPublishedChunksHandler.js";import{isMapPublishedChunkedDataHandler as u}from"./published-data/MapPublishedChunkedDataHandler.js";import{isMapPublishedRevisionDataHandler as d}from"./published-data/MapPublishedRevisionDataHandler.js";import{isSheetValidatorHandler as c}from"./published-data/SheetValidatorHandler.js";export class ConfiguratorBuilder{_context;constructor(t){this._context=t}withDefaultEnvs(t){return new ConfiguratorBuilder({...this._context,defaultEnvs:t})}withVersion(t){return new ConfiguratorBuilder({...this._context,version:t})}withTextLanguages(t){return new ConfiguratorBuilder({...this._context,textLanguages:t})}withAcl(t){return new ConfiguratorBuilder({...this._context,acl:t})}withAdminRelease(t){return new ConfiguratorBuilder({...this._context,enableAdminRelease:t})}withUi(t){return new ConfiguratorBuilder({...this._context,ui:t})}withResourcesConfig(t){return new ConfiguratorBuilder({...this._context,resourcesConfig:t})}withChunks(t){return new ConfiguratorBuilder({...this._context,chunks:t})}withPublishedDataHash(t){return new ConfiguratorBuilder({...this._context,publishedDataHash:t})}withAssistant(t){return new ConfiguratorBuilder({...this._context,assistant:t})}withTheme(t){return new ConfiguratorBuilder({...this._context,theme:t})}withDomainFactory(t){return new ConfiguratorBuilder({...this._context,domainFactory:t})}withAdminDomainFactory(t){return new ConfiguratorBuilder({...this._context,adminDomainFactory:t})}withI18n=t=>new ConfiguratorBuilder({...this._context,i18n:t});withPrefetchedFinalizeData(t){return new ConfiguratorBuilder({...this._context,prefetchedFinalizeData:t})}withFinalizeData(t){return new ConfiguratorBuilder({...this._context,finalizeData:t})}withFinalizeResult(t){return new ConfiguratorBuilder({...this._context,finalizeResult:t})}withCallbackData(t){return new ConfiguratorBuilder({...this._context,callbackData:t})}withNavigationState(t){return new ConfiguratorBuilder({...this._context,navigationState:t})}withViewState(t){return new ConfiguratorBuilder({...this._context,viewState:t})}withToolState(t){return new ConfiguratorBuilder({...this._context,toolState:t})}withExportState(t){return new ConfiguratorBuilder({...this._context,exportState:t})}withAdminNavigationState(t){return new ConfiguratorBuilder({...this._context,adminNavigationState:t})}withAdminViewState(t){return new ConfiguratorBuilder({...this._context,adminViewState:t})}withPresets(t){return new ConfiguratorBuilder({...this._context,presets:t})}withAdminPresets(t){return new ConfiguratorBuilder({...this._context,adminPresets:t})}withComponentOptics(t){return new ConfiguratorBuilder({...this._context,componentOptics:[...this._context.componentOptics,...t]})}withAdminComponentOptics(t){return new ConfiguratorBuilder({...this._context,adminComponentOptics:[...this._context.adminComponentOptics??[],...t]})}withHandlers(t){return new ConfiguratorBuilder({...this._context,handlers:t})}withElements(t){return new ConfiguratorBuilder({...this._context,elements:t})}withResources(t){return new ConfiguratorBuilder({...this._context,resources:t})}withWebComponentTag(t){return new ConfiguratorBuilder({...this._context,tagName:t})}withTransformers(t,e){return new ConfiguratorBuilder({...this._context,transformers:{importedTransformers:t,specTransformers:e}})}withInterface(t){return this}withDataSpec=t=>new ConfiguratorBuilder({...this._context,dataSpec:t});_computeInitialPublishedData(t,e,i){if(!this._context.adminDomainFactory)throw Error("adminDomainFactory is required!");return s({adminDomainFactory:this._context.adminDomainFactory,domainRuntime:e,adminPresets:this._context.adminPresets??[],handlers:i,dataSpec:this._context.dataSpec,chunks:this._context.chunks,logger:t})}buildConfig(){return this._buildConfigWithHandlers().config}_buildConfigWithHandlers(){if(!this._context.domainFactory)throw Error("Can not create application config, domainFactory is required! Is it registered with the ConfiguratorBuilder?");if(!this._context.presets)throw Error("Can not create application config, presets are required! Is it registered with the ConfiguratorBuilder?");if(!this._context.adminDomainFactory)throw Error("Can not create application config, adminDomainFactory is required! Is it registered with the ConfiguratorBuilder?");if(!this._context.adminPresets)throw Error("Can not create application config, adminPresets are required! Is it registered with the ConfiguratorBuilder?");if(!this._context.version)throw Error("Can not create application config, version is required!");let i=this._context.tagName??"salsita-configurator",s={defaultEnvs:this._context.defaultEnvs,services:{i18n:this._context.i18n},version:this._context.version,initialPublishedData:{},domain:{textLanguages:this._context.textLanguages,componentOptics:this._context.componentOptics,presets:this._context.presets,domainFactory:this._context.domainFactory},navigation:{navigationStates:this._context.navigationState?.values(),viewStates:this._context.viewState?.values(),toolStates:this._context.toolState?.values(),exportStates:this._context.exportState?.values()},adminNavigation:{navigationStates:this._context.adminNavigationState?.values(),viewStates:this._context.adminViewState?.values()},adminDomain:{textLanguages:this._context.textLanguages,componentOptics:this._context.adminComponentOptics??[],presets:this._context.adminPresets,domainFactory:this._context.adminDomainFactory},mount:{tag:i,options:{}},handlers:this._context.handlers??[],elements:this._context.elements??[],transformers:this._context.transformers,features:{acl:this._context.acl,enableAdminRelease:this._context.enableAdminRelease},ui:{preview:this._context.ui?.preview,alwaysExpand:this._context.ui?.alwaysExpand,theme:this._context.theme},resources:this._context.resourcesConfig,chunks:this._context.chunks,publishedDataHash:this._context.publishedDataHash,assistant:this._context.assistant,dataSpec:this._context.dataSpec},u=t(),d=n({config:s,services:{analyticsService:new r,i18n:e,logger:u}}),m=d.getState().spec.configurator.handlers;if(m.filter(t=>l(t)).length>1)throw Error("Multiple createFilterPublishedChunksHandler handlers found. Only one handler is allowed.");if(m.filter(t=>h(t)).length>1)throw Error("Multiple createDataRowValidatorHandler handlers found. Only one handler is allowed.");if(m.filter(t=>c(t)).length>1)throw Error("Multiple createSheetValidatorHandler handlers found. Only one handler is allowed.");let f=m.find(o)?.handler().handler,x=m.find(a)?.handler().handler(void 0),w=this._computeInitialPublishedData(u,d,m);return{config:{...s,mount:{tag:i,options:x??{},Application:f},initialPublishedData:w},handlers:m}}buildWebhookContext(){if(!this._context.domainFactory)throw Error("domainFactory is required!");if(!this._context.adminDomainFactory)throw Error("adminDomainFactory is required!");if(!this._context.adminPresets)throw Error("adminPresets are required!");let{config:t,handlers:e}=this._buildConfigWithHandlers(),r=t=>{if(null==this._context.finalizeData)return{};let e=i.compile(this._context.finalizeData);if(!e(t))throw console.error("Finalize data validation errors:",e.errors),Error("Invalid finalize data!");return t},n=t=>{if(null==this._context.finalizeResult)return{};let e=i.compile(this._context.finalizeResult);if(!e(t))throw console.error("Finalize result validation errors:",e.errors),Error("Invalid finalize result!");return t},o=t=>{if(null==this._context.callbackData)return{};let e=i.compile(this._context.callbackData);if(!e(t))throw console.error("Callback data validation errors:",e.errors),Error("Invalid callback data!");return t},a=e.find(d)?.handler().handler,s=e.find(u)?.handler().handler,l=e.find(h)?.handler().handler,m=e.find(c)?.handler().handler;return{config:t,parseFinalizeData:r,parseFinalizeResult:n,resources:this._context.resources??[],parseCallbackData:o,mapPublishedRevisionData:a,mapPublishedChunkedData:s,dataRowValidator:l,sheetValidator:m}}}
@@ -2,6 +2,7 @@ import type { SvgIconProps } from '@mui/material';
2
2
  import type { PropsWithChildren, ReactNode } from 'react';
3
3
  import type { ExtendedJsonSchema } from '@salsita-ai/common/utils';
4
4
  import type { DomainEntityId } from '../core/index.js';
5
+ import { type ProjectModule } from '../project-modules/index.js';
5
6
  export interface PhoenixEntityElementProps {
6
7
  entityId: DomainEntityId<string>;
7
8
  children?: ReactNode;
@@ -102,4 +103,8 @@ export declare const createPhoenixEntityElement: <SCHEMA extends {
102
103
  } = never>(element: PhoenixEntityElementDefinition<SCHEMA>) => import("react").FunctionComponent<SCHEMA["props"] & CustomPhoenixEntityElementProps>;
103
104
  export declare const createCustomPhoenixEntityElement: (name: string, element: (props: CustomPhoenixEntityElementProps) => JSX.Element) => PhoenixEntityElementRegistration;
104
105
  export type CreateCustomPhoenixEntityElement = (name: string, element: (props: CustomPhoenixEntityElementProps) => JSX.Element) => PhoenixEntityElementRegistration;
106
+ /** The element registrations of one `src/elements/` file; the editor keys its per-file reload cache on this. */
107
+ export declare const resolveElementModule: (module: ProjectModule) => readonly ElementRegistration[];
108
+ /** Validates the `src/elements/` files of an application config and flattens their registrations. */
109
+ export declare const resolveElementModules: (modules: readonly ProjectModule[]) => readonly ElementRegistration[];
105
110
  export {};
@@ -1 +1 @@
1
- export const systemElementRegistry={layoutElements:{},entityElements:{}};export const createPhoenixLayoutElement=e=>(systemElementRegistry.layoutElements[e.schema.properties.kind.enum[0]]=e.component,e.component);export const createCustomPhoenixLayoutElement=(e,t)=>({type:"layout",name:e,element:t});export const createPhoenixEntityElement=e=>(systemElementRegistry.entityElements[e.schema.properties.kind.enum[0]]=e.component,e.component);export const createCustomPhoenixEntityElement=(e,t)=>({type:"entity",name:e,element:t});
1
+ import{SHARED_FOLDER_HINT as e,isRecord as t,resolveListModule as n}from"../project-modules/index.js";export const systemElementRegistry={layoutElements:{},entityElements:{}};export const createPhoenixLayoutElement=e=>(systemElementRegistry.layoutElements[e.schema.properties.kind.enum[0]]=e.component,e.component);export const createCustomPhoenixLayoutElement=(e,t)=>({type:"layout",name:e,element:t});export const createPhoenixEntityElement=e=>(systemElementRegistry.entityElements[e.schema.properties.kind.enum[0]]=e.component,e.component);export const createCustomPhoenixEntityElement=(e,t)=>({type:"entity",name:e,element:t});let o={expected:"an element registration, or an array of them",fix:`Create it with phx.frontend.createCustomPhoenixLayoutElement(...) or phx.frontend.createCustomPhoenixEntityElement(...), ${e}.`},r=e=>!!t(e)&&("icon"===e.type?Array.isArray(e.elements):("entity"===e.type||"layout"===e.type)&&"string"==typeof e.name&&"function"==typeof e.element);export const resolveElementModule=e=>n(e,o,r);export const resolveElementModules=e=>e.flatMap(resolveElementModule);
@@ -1,3 +1,4 @@
1
+ import { type ProjectModule } from '../project-modules/index.js';
1
2
  export type PhoenixHandlerDefinition = {
2
3
  handler: () => Promise<void>;
3
4
  };
@@ -27,3 +28,7 @@ export declare const createPhoenixHandler: (name: string, handler: () => Phoenix
27
28
  export type CreatePhoenixHandler = (name: string, handler: () => PhoenixHandlerDefinition) => PhoenixHandlerRegistration;
28
29
  export declare const createSystemPhoenixHandler: <P, R>(name: string, handler: () => SystemPhoenixHandlerDefinition<P, R>) => SystemPhoenixHandlerRegistration<P, R>;
29
30
  export declare const createSystemPhoenixAsyncHandler: <P, R>(name: string, handler: () => SystemPhoenixAsyncHandlerDefinition<P, R>) => SystemPhoenixAsyncHandlerRegistration<P, R>;
31
+ /** The handler registrations of one `src/handlers/` file; the editor keys its per-file reload cache on this. */
32
+ export declare const resolveHandlerModule: (module: ProjectModule) => ReadonlyArray<HandlerRegistration<any, any>>;
33
+ /** Validates the `src/handlers/` files of an application config and flattens their registrations. */
34
+ export declare const resolveHandlerModules: (modules: readonly ProjectModule[]) => ReadonlyArray<HandlerRegistration<any, any>>;
@@ -1 +1 @@
1
- export const createPhoenixHandler=(e,t)=>({type:"phoenix",name:e,handler:t});export const createSystemPhoenixHandler=(e,t)=>({type:"system",name:e,handler:t});export const createSystemPhoenixAsyncHandler=(e,t)=>({type:"system-async",name:e,handler:t});
1
+ import{SHARED_FOLDER_HINT as e,isRecord as t,resolveListModule as o}from"../project-modules/index.js";export const createPhoenixHandler=(e,t)=>({type:"phoenix",name:e,handler:t});export const createSystemPhoenixHandler=(e,t)=>({type:"system",name:e,handler:t});export const createSystemPhoenixAsyncHandler=(e,t)=>({type:"system-async",name:e,handler:t});let r={expected:"a handler registration, or an array of them",fix:`Create it with phx.frontend.createPhoenixHandler(...) or one of the other phx.frontend.create…Handler(...) factories, ${e}.`},n=e=>t(e)&&("phoenix"===e.type||"system"===e.type||"system-async"===e.type)&&"string"==typeof e.name&&"function"==typeof e.handler;export const resolveHandlerModule=e=>o(e,r,n);export const resolveHandlerModules=e=>e.flatMap(resolveHandlerModule);
@@ -1,11 +1,11 @@
1
- export { type DomainConfig, type NavigationConfig, type ISessionService, type Session, type ResourcesConfig, type ApplicationConfig, type UserInterfaceConfig, type MountConfig, type WebComponentOptions, type SessionState, type AuthenticationErrorCode, type DataCellValue, type DataSchema, type DataSchemaArrayField, type DataSchemaField, type DataSchemaFieldObject, type DataSpec, type DataSpecEntry, type SwatchSpecEntry, type ChunksSpec, type AssistantFieldOptions, type AssistantFieldSource, type AssistantManifest, type AssistantRecipeGroup, type ImportedTransformer, type SpecTransformer, type AdminPagesSpec, type AnyApplicationConfig, type DefaultEnvs, } from './application-config.js';
1
+ export { type DomainConfig, type NavigationConfig, type ISessionService, type Session, type ResourcesConfig, type ApplicationConfig, type UserInterfaceConfig, type MountConfig, type WebComponentOptions, type SessionState, type AuthenticationErrorCode, type DataCellValue, type DataSchema, type DataSchemaArrayField, type DataSchemaField, type DataSchemaFieldObject, type DataSpec, type DataSpecEntry, type SwatchSpecEntry, type ChunksSpec, type ImportedTransformer, type SpecTransformer, type TransformersConfig, type AdminPagesSpec, type AnyApplicationConfig, type DefaultEnvs, } from './application-config.js';
2
2
  export { type AssistantFieldOption, findAssistantFieldOptions, readAssistantFieldOptions, } from './assistant-field-options.js';
3
3
  export { deleteEntityUpdateTag, findAssistantMutation, modifyEntityUpdateTag } from './assistant-mutations.js';
4
4
  export { type AssistantRecipe, type AssistantRecipeContext, type AssistantRecipeGroupSnapshot, type AssistantRecipeKind, assistantAddedEntityIds, findAssistantRecipeGroups, prepareAssistantRecipeUpdates, readAssistantRecipeGroup, } from './assistant-recipe-groups.js';
5
5
  export { ConfiguratorBuilder } from './configurator-builder.js';
6
6
  export * from './admin-page-factories.js';
7
7
  export { createInitialPublishedData, type CreateInitialPublishedDataProps } from './create-initial-published-data.js';
8
- export { resolveImportedTransformers } from './resolve-imported-transformers.js';
8
+ export { resolveImportedTransformers, resolveTransformerModule, resolveTransformerModules, } from './resolve-imported-transformers.js';
9
9
  export { webComponentAttributeParsers, createWebComponentPropertyDescriptor, type AttributeParser, type WebComponentPropertyDescriptor, } from './web-component-property.js';
10
10
  export { createWebComponentEventDescriptor, type WebComponentEventDescriptor } from './web-component-event.js';
11
11
  export { standardWebComponentProperties, type StandardConfiguratorElement } from './standard-properties.js';
@@ -26,5 +26,6 @@ export { createDataRowValidatorHandler, DataRowValidatorHandlerName, isDataRowVa
26
26
  export { createSheetValidatorHandler, SheetValidatorHandlerName, isSheetValidatorHandler, type CreateSheetValidatorHandler, type SheetValidatorResult, } from './published-data/SheetValidatorHandler.js';
27
27
  export { createMapPublishedRevisionDataHandler, createMapPublishedRevisionDataHandlerFactory, isMapPublishedRevisionDataHandler, type CreateMapPublishedRevisionDataHandler, type TypedCreateMapPublishedRevisionDataHandler, } from './published-data/MapPublishedRevisionDataHandler.js';
28
28
  export { createMapPublishedChunkedDataHandler, createMapPublishedChunkedDataHandlerFactory, isMapPublishedChunkedDataHandler, type CreateMapPublishedChunkedDataHandler, type MapPublishedChunkedDataHandlerProps, type MapPublishedChunkedDataResult, type TypedCreateMapPublishedChunkedDataHandler, } from './published-data/MapPublishedChunkedDataHandler.js';
29
- export { type PhoenixHandlerDefinition, type SystemPhoenixHandlerDefinition, type PhoenixHandlerRegistration, type SystemPhoenixHandlerRegistration, type SystemPhoenixAsyncHandlerDefinition, type SystemPhoenixAsyncHandlerRegistration, type HandlerRegistration, type CreatePhoenixHandler, createPhoenixHandler, createSystemPhoenixHandler, createSystemPhoenixAsyncHandler, } from './handler-registration.js';
30
- export { type PhoenixEntityElementProps, type PhoenixEntityElementRegistration, type PhoenixLayoutElementRegistration, type PhoenixIconRegistration, type ElementRegistration, type CustomPhoenixEntityElementProps, type PhoenixLayoutElementDefinition, type PhoenixEntityElementDefinition, type CreateCustomPhoenixLayoutElement, type CreateCustomPhoenixEntityElement, createPhoenixLayoutElement, createPhoenixEntityElement, createCustomPhoenixLayoutElement, createCustomPhoenixEntityElement, } from './element-registration.js';
29
+ export { type PhoenixHandlerDefinition, type SystemPhoenixHandlerDefinition, type PhoenixHandlerRegistration, type SystemPhoenixHandlerRegistration, type SystemPhoenixAsyncHandlerDefinition, type SystemPhoenixAsyncHandlerRegistration, type HandlerRegistration, type CreatePhoenixHandler, createPhoenixHandler, createSystemPhoenixHandler, createSystemPhoenixAsyncHandler, resolveHandlerModule, resolveHandlerModules, } from './handler-registration.js';
30
+ export { type PhoenixEntityElementProps, type PhoenixEntityElementRegistration, type PhoenixLayoutElementRegistration, type PhoenixIconRegistration, type ElementRegistration, type CustomPhoenixEntityElementProps, type PhoenixLayoutElementDefinition, type PhoenixEntityElementDefinition, type CreateCustomPhoenixLayoutElement, type CreateCustomPhoenixEntityElement, createPhoenixLayoutElement, createPhoenixEntityElement, createCustomPhoenixLayoutElement, createCustomPhoenixEntityElement, resolveElementModule, resolveElementModules, } from './element-registration.js';
31
+ export * from './assistant/index.js';
@@ -1 +1 @@
1
- export{findAssistantFieldOptions,readAssistantFieldOptions}from"./assistant-field-options.js";export{deleteEntityUpdateTag,findAssistantMutation,modifyEntityUpdateTag}from"./assistant-mutations.js";export{assistantAddedEntityIds,findAssistantRecipeGroups,prepareAssistantRecipeUpdates,readAssistantRecipeGroup}from"./assistant-recipe-groups.js";export{ConfiguratorBuilder}from"./configurator-builder.js";export*from"./admin-page-factories.js";export{createInitialPublishedData}from"./create-initial-published-data.js";export{resolveImportedTransformers}from"./resolve-imported-transformers.js";export{webComponentAttributeParsers,createWebComponentPropertyDescriptor}from"./web-component-property.js";export{createWebComponentEventDescriptor}from"./web-component-event.js";export{standardWebComponentProperties}from"./standard-properties.js";export{standardWebComponentEvents}from"./standard-events.js";export{ResourceBuilder}from"./resource-builder.js";export{createGetApplicationWrapperHandler,isGetApplicationWrapperHandler}from"./GetApplicationWrapperHandler.js";export{createGetThemeHandler,GetThemeHandlerName,isGetThemeHandler}from"./GetThemeHandler.js";export{createGetWebComponentOptionsHandler,isGetWebComponentOptionsHandler}from"./GetWebComponentOptions.js";export{createFinalizeAdminDomain}from"./published-data/create-finalize-admin-domain.js";export{FilterPublishedChunksHandlerName,isFilterPublishedChunksHandler}from"./published-data/FilterPublishedChunksHandler.js";export{mapPublishedData}from"./published-data/map-published-data.js";export{flattenTabData,mapDefaultValuesToRecords,mapPublishedChunkedData,SYSTEM_CHUNK_KEY,SYSTEM_CHUNK_SCOPE,SWATCH_DEFINITION}from"./published-data/map-published-chunked-data.js";export{buildLegendRows}from"./published-data/build-legend-data.js";export{formatFieldType,getFieldDescription}from"./published-data/format-field-type.js";export{mapDataToSheet}from"./published-data/map-data-to-sheet.js";export{validateRows}from"./published-data/validate-sheet-data.js";export{createDataRowValidatorHandler,DataRowValidatorHandlerName,isDataRowValidatorHandler}from"./published-data/DataRowValidatorHandler.js";export{createSheetValidatorHandler,SheetValidatorHandlerName,isSheetValidatorHandler}from"./published-data/SheetValidatorHandler.js";export{createMapPublishedRevisionDataHandler,createMapPublishedRevisionDataHandlerFactory,isMapPublishedRevisionDataHandler}from"./published-data/MapPublishedRevisionDataHandler.js";export{createMapPublishedChunkedDataHandler,createMapPublishedChunkedDataHandlerFactory,isMapPublishedChunkedDataHandler}from"./published-data/MapPublishedChunkedDataHandler.js";export{createPhoenixHandler,createSystemPhoenixHandler,createSystemPhoenixAsyncHandler}from"./handler-registration.js";export{createPhoenixLayoutElement,createPhoenixEntityElement,createCustomPhoenixLayoutElement,createCustomPhoenixEntityElement}from"./element-registration.js";
1
+ export{findAssistantFieldOptions,readAssistantFieldOptions}from"./assistant-field-options.js";export{deleteEntityUpdateTag,findAssistantMutation,modifyEntityUpdateTag}from"./assistant-mutations.js";export{assistantAddedEntityIds,findAssistantRecipeGroups,prepareAssistantRecipeUpdates,readAssistantRecipeGroup}from"./assistant-recipe-groups.js";export{ConfiguratorBuilder}from"./configurator-builder.js";export*from"./admin-page-factories.js";export{createInitialPublishedData}from"./create-initial-published-data.js";export{resolveImportedTransformers,resolveTransformerModule,resolveTransformerModules}from"./resolve-imported-transformers.js";export{webComponentAttributeParsers,createWebComponentPropertyDescriptor}from"./web-component-property.js";export{createWebComponentEventDescriptor}from"./web-component-event.js";export{standardWebComponentProperties}from"./standard-properties.js";export{standardWebComponentEvents}from"./standard-events.js";export{ResourceBuilder}from"./resource-builder.js";export{createGetApplicationWrapperHandler,isGetApplicationWrapperHandler}from"./GetApplicationWrapperHandler.js";export{createGetThemeHandler,GetThemeHandlerName,isGetThemeHandler}from"./GetThemeHandler.js";export{createGetWebComponentOptionsHandler,isGetWebComponentOptionsHandler}from"./GetWebComponentOptions.js";export{createFinalizeAdminDomain}from"./published-data/create-finalize-admin-domain.js";export{FilterPublishedChunksHandlerName,isFilterPublishedChunksHandler}from"./published-data/FilterPublishedChunksHandler.js";export{mapPublishedData}from"./published-data/map-published-data.js";export{flattenTabData,mapDefaultValuesToRecords,mapPublishedChunkedData,SYSTEM_CHUNK_KEY,SYSTEM_CHUNK_SCOPE,SWATCH_DEFINITION}from"./published-data/map-published-chunked-data.js";export{buildLegendRows}from"./published-data/build-legend-data.js";export{formatFieldType,getFieldDescription}from"./published-data/format-field-type.js";export{mapDataToSheet}from"./published-data/map-data-to-sheet.js";export{validateRows}from"./published-data/validate-sheet-data.js";export{createDataRowValidatorHandler,DataRowValidatorHandlerName,isDataRowValidatorHandler}from"./published-data/DataRowValidatorHandler.js";export{createSheetValidatorHandler,SheetValidatorHandlerName,isSheetValidatorHandler}from"./published-data/SheetValidatorHandler.js";export{createMapPublishedRevisionDataHandler,createMapPublishedRevisionDataHandlerFactory,isMapPublishedRevisionDataHandler}from"./published-data/MapPublishedRevisionDataHandler.js";export{createMapPublishedChunkedDataHandler,createMapPublishedChunkedDataHandlerFactory,isMapPublishedChunkedDataHandler}from"./published-data/MapPublishedChunkedDataHandler.js";export{createPhoenixHandler,createSystemPhoenixHandler,createSystemPhoenixAsyncHandler,resolveHandlerModule,resolveHandlerModules}from"./handler-registration.js";export{createPhoenixLayoutElement,createPhoenixEntityElement,createCustomPhoenixLayoutElement,createCustomPhoenixEntityElement,resolveElementModule,resolveElementModules}from"./element-registration.js";export*from"./assistant/index.js";
@@ -1,13 +1,23 @@
1
1
  import type { $DomainEntity, DomainEntity } from '../core/model.js';
2
2
  import type { DomainContextSystems } from '../domain-context/domain-context-systems.js';
3
3
  import type { Transformers } from '../domain-context/store-system/store-system.js';
4
+ import { type ProjectModule } from '../project-modules/index.js';
4
5
  import type { ImportedTransformer, SpecTransformer } from './application-config.js';
6
+ type AnyImportedTransformer = ImportedTransformer<any, any, any, any, any, any, any>;
7
+ /**
8
+ * The transformer of one `src/transformers/` file, named after the file. The spec's `transformers` section
9
+ * selects a plain-function export by that name; a transformer made with `build(name)` registers under its own.
10
+ */
11
+ export declare const resolveTransformerModule: (module: ProjectModule) => AnyImportedTransformer;
12
+ /** Validates the `src/transformers/` files of an application config and names each after its file. */
13
+ export declare const resolveTransformerModules: (modules: readonly ProjectModule[]) => readonly AnyImportedTransformer[];
5
14
  /**
6
15
  * Resolves imported transformer modules against spec transformer declarations.
7
16
  * Each imported transformer is registered/executed with the domain context,
8
17
  * then matched by name against spec entries to apply priority ordering.
9
18
  *
10
- * Used both at build time (via withTransformers) and at hot-reload time
19
+ * Used both when the runtime spec is initialized from the application config and at hot-reload time
11
20
  * (via domain-context subscription to registry changes).
12
21
  */
13
22
  export declare const resolveImportedTransformers: <ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string>(importedTransformers: ReadonlyArray<ImportedTransformer<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>>, specTransformers: readonly SpecTransformer[], ctx: DomainContextSystems<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>) => Transformers<ENTITIES>;
23
+ export {};
@@ -1 +1 @@
1
- export const resolveImportedTransformers=(r,e,t)=>{let o=r.flatMap(({name:r,transformer:e})=>{if(Array.isArray(e))return e.map((e,o)=>{if("register"in e)return e.register(t);if("function"==typeof e)return{priority:1/0,transformer:e(t),name:`${r}[${o}]`};throw Error(`Transformer '${r}[${o}]' must be either a RegistrableTransformer (with register method) or a TransformerFactory (function)`)});if("register"in e)return e.register(t);if("function"==typeof e)return{priority:1/0,transformer:e(t),name:r};throw Error(`Transformer '${r}' must be either a RegistrableTransformer (with register method) or a TransformerFactory (function)`)}),n=[];for(let r of e){let e=o.find(e=>e.name===r.name);if(!e){let e=o.map(r=>r.name).filter(Boolean).join(", ");throw Error(`Transformer '${r.name}' not found in imported transformer files. Available transformers: ${e||"none"}`)}n.push({priority:r.priority??1/0,transformer:e.transformer,name:r.name})}return n};
1
+ import{SHARED_FOLDER_HINT as r,createContractError as e,isRecord as t}from"../project-modules/index.js";let o={expected:"a transformer (a function of the domain context, or an object with a register method), or an array of them",fix:`Create it with phx.frontend.transformerBuilder, ${r}.`},n=r=>"function"==typeof r||t(r)&&"function"==typeof r.register;export const resolveTransformerModule=r=>{let t;if(!(Array.isArray(t=r.exports)?t.every(n):n(t)))throw e(r.origin,o,r.exports);return{name:r.origin.replace(/^.*\//,"").replace(/\.tsx?$/,""),transformer:r.exports}};export const resolveTransformerModules=r=>r.map(resolveTransformerModule);export const resolveImportedTransformers=(r,e,t)=>{let o=r.flatMap(({name:r,transformer:e})=>{if(Array.isArray(e))return e.map((e,o)=>{if("register"in e)return e.register(t);if("function"==typeof e)return{priority:1/0,transformer:e(t),name:`${r}[${o}]`};throw Error(`Transformer '${r}[${o}]' must be either a RegistrableTransformer (with register method) or a TransformerFactory (function)`)});if("register"in e)return e.register(t);if("function"==typeof e)return{priority:1/0,transformer:e(t),name:r};throw Error(`Transformer '${r}' must be either a RegistrableTransformer (with register method) or a TransformerFactory (function)`)}),n=[];for(let r of e){let e=o.find(e=>e.name===r.name);if(!e){let e=o.map(r=>r.name).filter(Boolean).join(", ");throw Error(`Transformer '${r.name}' not found in imported transformer files. Available transformers: ${e||"none"}`)}n.push({priority:r.priority??1/0,transformer:e.transformer,name:r.name})}return n};
@@ -5,6 +5,7 @@ import type { ExpressionContext } from '../core/expression.js';
5
5
  import type { $DomainEntity, DomainEntity, EntityByType } from '../core/model.js';
6
6
  import type { DomainState } from '../core/state.js';
7
7
  import type { CustomExpression } from '../expressions/custom-expression.js';
8
+ import { type ProjectModule } from '../project-modules/index.js';
8
9
  import { type ComponentSystemFilter, type NavigationFilterOptic } from './legacy-filter.js';
9
10
  import type { GradualComponentSystemFilter, IdOrWithId } from './system-component-filter.js';
10
11
  import type { Viewport } from './viewport-state-component.js';
@@ -33,6 +34,8 @@ export interface DomainComponentDynamicOptic<ENTITIES extends DomainEntity<strin
33
34
  }
34
35
  export type DomainComponentOptic<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, ENTITY extends ENTITIES, COMPONENT_TYPE extends SystemComponentTypeConstraint> = DomainComponentSimpleOptic<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ENTITY, COMPONENT_TYPE> | DomainComponentDynamicOptic<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, COMPONENT_TYPE>;
35
36
  export type AnyDomainComponentOptic = DomainComponentOptic<any, any, any, any, any, any, any>;
37
+ /** Validates the `src/components/` files, or the optics a generated file lists, and flattens them. */
38
+ export declare const resolveComponentOpticModules: (modules: readonly ProjectModule[]) => readonly AnyDomainComponentOptic[];
36
39
  export declare class DomainComponentOpticBuilder<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, ALIASES extends Record<string, ENTITIES>, ENTITY extends ENTITIES, $ENTITY extends $DomainEntity<ENTITIES>, COMPONENT_TYPE extends SystemComponentTypeConstraint> {
37
40
  private readonly aliasMap;
38
41
  private readonly entityTypes;
@@ -1,4 +1,4 @@
1
- import{createCacheToken as t,getStickyCache as e}from"@salsita-ai/common/utils";import{createCustomExpression as i}from"../expressions/custom-expression.js";import{withProfilerLabel as n}from"../utils/profiler-label.js";export class DomainComponentOpticBuilder{aliasMap;entityTypes;componentType;instanceName;navigationFilters;generated;entityTypeOrAliasNames;constructor(t,e,i,n,s=[],a=!1,o=[]){this.aliasMap=t,this.entityTypes=e,this.componentType=i,this.instanceName=n,this.navigationFilters=s,this.generated=a,this.entityTypeOrAliasNames=o}static from(t){return new DomainComponentOpticBuilder(t,[])}withEntity(t){return new DomainComponentOpticBuilder(this.aliasMap,[...this.entityTypes,t],this.componentType,this.instanceName,this.navigationFilters,this.generated,[...this.entityTypeOrAliasNames,t])}withAlias(t){return new DomainComponentOpticBuilder(this.aliasMap,[...this.entityTypes,...this.aliasMap[t]],this.componentType,this.instanceName,this.navigationFilters,this.generated,[...this.entityTypeOrAliasNames,String(t)])}withComponent(t,e,i=!1){return new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,t,e,this.navigationFilters,i,this.entityTypeOrAliasNames)}withFilter(i){if(console.warn(`Component ${this.componentType?.name}#${this.instanceName} on entity ${this.entityTypes.join(", ")} uses a legacy filter with full filter evaluation. This is a suboptimal variant and is deprecated in favor of per-criterion evaluation.
1
+ import{createCacheToken as t,getStickyCache as e}from"@salsita-ai/common/utils";import{createCustomExpression as i}from"../expressions/custom-expression.js";import{SHARED_FOLDER_HINT as n,isRecord as s,resolveListModule as a}from"../project-modules/index.js";import{withProfilerLabel as o}from"../utils/profiler-label.js";let r={expected:"an attached component, or an array of them",fix:`Create it with phx.domain.attachComponent(...) (phx.domain.admin.attachComponent(...) under src/admin/), ${n}.`},d=t=>s(t)&&("simple"===t.kind||"dynamic"===t.kind)&&"string"==typeof t.instanceName&&"function"==typeof t.read;export const resolveComponentOpticModules=t=>t.flatMap(t=>a(t,r,d));export class DomainComponentOpticBuilder{aliasMap;entityTypes;componentType;instanceName;navigationFilters;generated;entityTypeOrAliasNames;constructor(t,e,i,n,s=[],a=!1,o=[]){this.aliasMap=t,this.entityTypes=e,this.componentType=i,this.instanceName=n,this.navigationFilters=s,this.generated=a,this.entityTypeOrAliasNames=o}static from(t){return new DomainComponentOpticBuilder(t,[])}withEntity(t){return new DomainComponentOpticBuilder(this.aliasMap,[...this.entityTypes,t],this.componentType,this.instanceName,this.navigationFilters,this.generated,[...this.entityTypeOrAliasNames,t])}withAlias(t){return new DomainComponentOpticBuilder(this.aliasMap,[...this.entityTypes,...this.aliasMap[t]],this.componentType,this.instanceName,this.navigationFilters,this.generated,[...this.entityTypeOrAliasNames,String(t)])}withComponent(t,e,i=!1){return new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,t,e,this.navigationFilters,i,this.entityTypeOrAliasNames)}withFilter(i){if(console.warn(`Component ${this.componentType?.name}#${this.instanceName} on entity ${this.entityTypes.join(", ")} uses a legacy filter with full filter evaluation. This is a suboptimal variant and is deprecated in favor of per-criterion evaluation.
2
2
 
3
3
  In your TS files, replace
4
4
  withFilter()
@@ -13,4 +13,4 @@ import{createCacheToken as t,getStickyCache as e}from"@salsita-ai/common/utils";
13
13
  active:
14
14
  $read: $trueOrFalseExpression
15
15
  # ... other eventual criteria
16
- `),"function"==typeof i){let n=t(),s=t=>({evaluate:(s,a,o)=>{let r=e(a,n),d=r.get(s);if(!d){if(void 0===(d=i(o.domain.get$Entity(s,a),a)))throw Error(`Dynamic filter on component ${this.componentType?.name}.${this.instanceName} on entity ${s} returned 'undefined'. This is likely a bug in the component definition, check whether you are referencing a correct expression or field!`);r.put(s,d)}return"boolean"==typeof d?"active"===t?d:void 0:d[t]},meta:{}});return new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,{navigationStates:s("navigationStates"),selectedEntityIds:s("selectedEntityIds"),hoveredEntityIds:s("hoveredEntityIds"),draggedEntityIds:s("draggedEntityIds"),viewStates:s("viewStates"),toolStates:s("toolStates"),modes:s("modes"),roles:s("roles"),active:s("active"),fullscreen:s("fullscreen"),debug:s("debug"),viewports:s("viewports"),exportedEntityIds:void 0,exportStates:void 0}],this.generated,this.entityTypeOrAliasNames)}return"boolean"==typeof i?new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,{active:i,navigationStates:void 0,selectedEntityIds:void 0,hoveredEntityIds:void 0,draggedEntityIds:void 0,viewStates:void 0,toolStates:void 0,modes:void 0,roles:void 0,fullscreen:void 0,debug:void 0,viewports:void 0,exportedEntityIds:void 0,exportStates:void 0}],this.generated,this.entityTypeOrAliasNames):new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,{navigationStates:void 0,selectedEntityIds:void 0,hoveredEntityIds:void 0,draggedEntityIds:void 0,viewStates:void 0,toolStates:void 0,modes:void 0,roles:void 0,active:void 0,fullscreen:void 0,debug:void 0,viewports:void 0,exportedEntityIds:void 0,exportStates:void 0,...i}],this.generated,this.entityTypeOrAliasNames)}withGradualFilter(t){let e=t=>"function"==typeof t?i(t,{}):t,n={navigationStates:e(t.navigationStates),selectedEntityIds:e(t.selectedEntityIds),hoveredEntityIds:e(t.hoveredEntityIds),draggedEntityIds:e(t.draggedEntityIds),exportedEntityIds:e(t.exportedEntityIds),viewStates:e(t.viewStates),toolStates:e(t.toolStates),exportStates:e(t.exportStates),modes:e(t.modes),roles:e(t.roles),active:e(t.active),fullscreen:e(t.fullscreen),debug:e(t.debug),viewports:e(t.viewports)};return new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,n],this.generated,this.entityTypeOrAliasNames)}validate(){if(!this.componentType||!this.instanceName)throw Error("Use withComponent before attaching");if(!this.entityTypes.length)throw Error("Use withEntity and/or withAlias before attaching")}_getProfilerLabel(){return[...this.entityTypeOrAliasNames,this.componentType.name,this.instanceName].join("_")}attach=(i,s)=>{var a,o;let r,d;return this.validate(),a={kind:"simple",entityTypes:new Set(this.entityTypes),componentType:this.componentType,instanceName:this.instanceName,navigationFilters:this.navigationFilters,read:(t,e,n)=>i(n.domain.get$Entity(t,e),e,n),write:s??(()=>({})),generated:this.generated},o=this._getProfilerLabel(),r=t(),d=n(o,a.read),{...a,read:(t,i,n)=>{let s=e(i,r),a=s.get(t);if(a)return a;let o=d(t,i,n);return s.put(t,o),o}}};attachMany=i=>{var s,a;let o,r;return this.validate(),s={kind:"dynamic",entityTypes:new Set(this.entityTypes),componentType:this.componentType,instanceName:this.instanceName,navigationFilters:this.navigationFilters,read:(t,e,n)=>i(n.domain.get$Entity(t,e),e,n)},a=this._getProfilerLabel(),o=t(),r=n(a,s.read),{...s,read:(t,i,n)=>{let s=e(i,o),a=s.get(t);if(a)return a;let d=r(t,i,n);return s.put(t,d),d}}}}
16
+ `),"function"==typeof i){let n=t(),s=t=>({evaluate:(s,a,o)=>{let r=e(a,n),d=r.get(s);if(!d){if(void 0===(d=i(o.domain.get$Entity(s,a),a)))throw Error(`Dynamic filter on component ${this.componentType?.name}.${this.instanceName} on entity ${s} returned 'undefined'. This is likely a bug in the component definition, check whether you are referencing a correct expression or field!`);r.put(s,d)}return"boolean"==typeof d?"active"===t?d:void 0:d[t]},meta:{}});return new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,{navigationStates:s("navigationStates"),selectedEntityIds:s("selectedEntityIds"),hoveredEntityIds:s("hoveredEntityIds"),draggedEntityIds:s("draggedEntityIds"),viewStates:s("viewStates"),toolStates:s("toolStates"),modes:s("modes"),roles:s("roles"),active:s("active"),fullscreen:s("fullscreen"),debug:s("debug"),viewports:s("viewports"),exportedEntityIds:void 0,exportStates:void 0}],this.generated,this.entityTypeOrAliasNames)}return"boolean"==typeof i?new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,{active:i,navigationStates:void 0,selectedEntityIds:void 0,hoveredEntityIds:void 0,draggedEntityIds:void 0,viewStates:void 0,toolStates:void 0,modes:void 0,roles:void 0,fullscreen:void 0,debug:void 0,viewports:void 0,exportedEntityIds:void 0,exportStates:void 0}],this.generated,this.entityTypeOrAliasNames):new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,{navigationStates:void 0,selectedEntityIds:void 0,hoveredEntityIds:void 0,draggedEntityIds:void 0,viewStates:void 0,toolStates:void 0,modes:void 0,roles:void 0,active:void 0,fullscreen:void 0,debug:void 0,viewports:void 0,exportedEntityIds:void 0,exportStates:void 0,...i}],this.generated,this.entityTypeOrAliasNames)}withGradualFilter(t){let e=t=>"function"==typeof t?i(t,{}):t,n={navigationStates:e(t.navigationStates),selectedEntityIds:e(t.selectedEntityIds),hoveredEntityIds:e(t.hoveredEntityIds),draggedEntityIds:e(t.draggedEntityIds),exportedEntityIds:e(t.exportedEntityIds),viewStates:e(t.viewStates),toolStates:e(t.toolStates),exportStates:e(t.exportStates),modes:e(t.modes),roles:e(t.roles),active:e(t.active),fullscreen:e(t.fullscreen),debug:e(t.debug),viewports:e(t.viewports)};return new DomainComponentOpticBuilder(this.aliasMap,this.entityTypes,this.componentType,this.instanceName,[...this.navigationFilters,n],this.generated,this.entityTypeOrAliasNames)}validate(){if(!this.componentType||!this.instanceName)throw Error("Use withComponent before attaching");if(!this.entityTypes.length)throw Error("Use withEntity and/or withAlias before attaching")}_getProfilerLabel(){return[...this.entityTypeOrAliasNames,this.componentType.name,this.instanceName].join("_")}attach=(i,n)=>{var s,a;let r,d;return this.validate(),s={kind:"simple",entityTypes:new Set(this.entityTypes),componentType:this.componentType,instanceName:this.instanceName,navigationFilters:this.navigationFilters,read:(t,e,n)=>i(n.domain.get$Entity(t,e),e,n),write:n??(()=>({})),generated:this.generated},a=this._getProfilerLabel(),r=t(),d=o(a,s.read),{...s,read:(t,i,n)=>{let s=e(i,r),a=s.get(t);if(a)return a;let o=d(t,i,n);return s.put(t,o),o}}};attachMany=i=>{var n,s;let a,r;return this.validate(),n={kind:"dynamic",entityTypes:new Set(this.entityTypes),componentType:this.componentType,instanceName:this.instanceName,navigationFilters:this.navigationFilters,read:(t,e,n)=>i(n.domain.get$Entity(t,e),e,n)},s=this._getProfilerLabel(),a=t(),r=o(s,n.read),{...n,read:(t,i,n)=>{let s=e(i,a),o=s.get(t);if(o)return o;let d=r(t,i,n);return s.put(t,d),d}}}}
@@ -1 +1 @@
1
- import e from"lodash-es/pick.js";import{getCommonPhxDefinitions as t}from"../core/index.js";import{extendedSchemaValidator as i}from"../core/json-schema.js";export class SystemComponentBuilder{name;writableKeys;jsonSchema;constructor(e,t,i){this.name=e,this.writableKeys=t,this.jsonSchema=i}static component(e){return new SystemComponentBuilder(e,[],{type:"object",properties:{},required:[],additionalProperties:!1})}withState(e){return new SystemComponentBuilder(this.name,[],e)}withWritableKeys(e){return new SystemComponentBuilder(this.name,e,this.jsonSchema)}build(){let s=t(),r={...this.jsonSchema,definitions:{...s,...this.jsonSchema.definitions}};return{name:this.name,writableKeys:this.writableKeys,schema:this.jsonSchema,validateState:i.compile(r),validateWritableState:i.compile({...r,properties:e(this.jsonSchema.properties,this.writableKeys),required:this.jsonSchema.required?.filter(e=>this.writableKeys.includes(e))})}}}
1
+ import e from"lodash-es/pick.js";import{getCommonPhxDefinitions as t}from"../core/index.js";import{extendedSchemaValidator as i}from"../core/schema/index.js";export class SystemComponentBuilder{name;writableKeys;jsonSchema;constructor(e,t,i){this.name=e,this.writableKeys=t,this.jsonSchema=i}static component(e){return new SystemComponentBuilder(e,[],{type:"object",properties:{},required:[],additionalProperties:!1})}withState(e){return new SystemComponentBuilder(this.name,[],e)}withWritableKeys(e){return new SystemComponentBuilder(this.name,e,this.jsonSchema)}build(){let s=t(),r={...this.jsonSchema,definitions:{...s,...this.jsonSchema.definitions}};return{name:this.name,writableKeys:this.writableKeys,schema:this.jsonSchema,validateState:i.compile(r),validateWritableState:i.compile({...r,properties:e(this.jsonSchema.properties,this.writableKeys),required:this.jsonSchema.required?.filter(e=>this.writableKeys.includes(e))})}}}
@@ -7,6 +7,8 @@ export interface ComponentModification<COMPONENT_TYPE extends SystemComponentTyp
7
7
  entityId: EntityId;
8
8
  updateTag: string;
9
9
  hint?: Localizable;
10
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
11
+ agentHint?: string | null;
10
12
  componentInstance: ComponentInstance<COMPONENT_TYPE>;
11
13
  writableState: WritableStateOfComponent<COMPONENT_TYPE>;
12
14
  metadata?: Record<string, unknown>;
@@ -17,6 +19,8 @@ export interface EphemeralRecordModification<COMPONENT_TYPE extends SystemCompon
17
19
  entityId: EntityId;
18
20
  updateTag: string;
19
21
  hint?: Localizable;
22
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
23
+ agentHint?: string | null;
20
24
  componentInstance: ComponentInstance<COMPONENT_TYPE>;
21
25
  writableState: WritableStateOfComponent<COMPONENT_TYPE>;
22
26
  }
@@ -25,6 +29,8 @@ export interface EphemeralRecordCreation<COMPONENT_TYPE extends SystemComponentT
25
29
  entityId: EntityId;
26
30
  updateTag: string;
27
31
  hint?: Localizable;
32
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
33
+ agentHint?: string | null;
28
34
  componentInstance: ComponentInstance<COMPONENT_TYPE>;
29
35
  initialState: StateOfComponent<COMPONENT_TYPE>;
30
36
  }
@@ -34,6 +40,8 @@ export interface EphemeralRecordDeletion<COMPONENT_TYPE extends SystemComponentT
34
40
  componentInstance: ComponentInstance<COMPONENT_TYPE>;
35
41
  updateTag: string;
36
42
  hint?: Localizable;
43
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
44
+ agentHint?: string | null;
37
45
  }
38
46
  export type DomainEntityStateDelta<ENTITY extends DomainEntity<string>> = Partial<Omit<ENTITY, 'id' | 'type'>>;
39
47
  export interface DomainEntityModification<ENTITY extends DomainEntity<string> = DomainEntity<string>> {
@@ -41,6 +49,8 @@ export interface DomainEntityModification<ENTITY extends DomainEntity<string> =
41
49
  entityId: ENTITY['id'];
42
50
  updateTag: string;
43
51
  hint?: Localizable;
52
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
53
+ agentHint?: string | null;
44
54
  stateDelta: DomainEntityStateDelta<ENTITY>;
45
55
  origin?: ComponentModification<SystemComponentTypeConstraint>;
46
56
  }
@@ -55,6 +65,8 @@ export interface DomainEntityCreation<ENTITY extends DomainEntity<string>, PAREN
55
65
  collection?: string;
56
66
  parentId: PARENT['id'];
57
67
  hint?: Localizable;
68
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
69
+ agentHint?: string | null;
58
70
  }
59
71
  export interface DomainEntityReplacement<ENTITY extends DomainEntity<string>> {
60
72
  kind: 'replaceDomainEntity';
@@ -63,12 +75,16 @@ export interface DomainEntityReplacement<ENTITY extends DomainEntity<string>> {
63
75
  updateTag: string;
64
76
  keepChildren: boolean;
65
77
  hint?: Localizable;
78
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
79
+ agentHint?: string | null;
66
80
  }
67
81
  export interface EntityDeletion<ENTITY extends DomainEntity<string>> {
68
82
  kind: 'deleteEntity';
69
83
  entityId: EntityId<ENTITY>;
70
84
  updateTag: string;
71
85
  hint?: Localizable;
86
+ /** What the assistant agent is told about this update instead of `hint`; `null` keeps the wording from it, and its change record then explains the change by `updateTag`. Never shown to the user. */
87
+ agentHint?: string | null;
72
88
  }
73
89
  export type DataUpdate<ENTITY extends DomainEntity<string>, PARENT extends DomainEntity<string>> = EphemeralRecordModification | EphemeralRecordCreation | EphemeralRecordDeletion | DomainEntityModification<ENTITY> | DomainEntityCreation<ENTITY, PARENT> | DomainEntityReplacement<ENTITY> | EntityDeletion<ENTITY>;
74
90
  export type StateUpdate<ENTITY extends DomainEntity<string>, PARENT extends DomainEntity<string>> = ComponentModification<SystemComponentTypeConstraint> | DataUpdate<ENTITY, PARENT>;
@@ -59,7 +59,7 @@ export type AnyActionContext = ActionContext<any, any, any, any, any, any, any,
59
59
  */
60
60
  export type ActionImplementation<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string, PARAMS, RESULT> = (params: PARAMS, state: DomainState<ENTITIES>, context: ActionContext<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>) => PreparedAction<ENTITIES, RESULT>;
61
61
  export type AnyActionImplementation = ActionImplementation<any, any, any, any, any, any, any, any, any, any, any, unknown>;
62
- /** The implementations of every declared action by name, as the generated barrel merges them from `src/actions/`. */
62
+ /** The implementations of every declared action by name, as `DomainBuilder.withActionModules` merges them from `src/actions/`. */
63
63
  export type ActionImplementations<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string, ACTION_TYPES extends ActionTypes> = {
64
64
  readonly [NAME in keyof ACTION_TYPES]: ActionImplementation<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, ACTION_TYPES[NAME]['params'], ACTION_TYPES[NAME]['result']>;
65
65
  };
@@ -1,6 +1,6 @@
1
1
  import { type ExtendedJsonSchema } from '@salsita-ai/common/utils';
2
2
  import type { EntityId } from './model.js';
3
- import type { PhxValidateFunction } from './schema-validator.js';
3
+ import type { PhxValidateFunction } from './schema/index.js';
4
4
  /**
5
5
  * Definition of how the component looks like, it's name, state and other properties. It is used to instantiate components.
6
6
  */
@@ -0,0 +1,6 @@
1
+ import type { Decoder } from './decoder.js';
2
+ /**
3
+ * Creates the decoder of data that must match a JSON schema. `subject` is what the data is, as the
4
+ * error names it, for example `Session data`.
5
+ */
6
+ export declare const createDecoder: <DATA>(schema: object, subject: string) => Decoder<DATA>;
@@ -0,0 +1 @@
1
+ import{extendedSchemaValidator as r}from"../schema/index.js";export const createDecoder=(e,o)=>t=>{let i=r.compile(e);if(!i(t))throw Error(`${o} is not valid: ${r.errorsText(i.errors)}`);return t};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Turns data of unknown shape into data of a known type, and throws when the data does not match.
3
+ * Everything that enters a domain from outside goes through one: published, session, frontend and
4
+ * backend data.
5
+ */
6
+ export type Decoder<DATA> = (data: unknown) => DATA;
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1,2 @@
1
+ export { createDecoder } from './create-decoder.js';
2
+ export type { Decoder } from './decoder.js';
@@ -0,0 +1 @@
1
+ export{createDecoder}from"./create-decoder.js";
@@ -1 +1 @@
1
- import{migrateCommonAdminDomain as t}from"../admin-domain/implementation/common-admin-migrations.js";import{extendedSchemaValidator as r}from"./json-schema.js";export class DomainFactory{context;modelVersion;hasBackendData;constructor(t){this.context=t,this.modelVersion=t.modelVersion,this.hasBackendData=void 0!==t.backendData}parsePublishedData=t=>{let e=r.compile(this.context.publishedData);if(!e(t))throw Error(`Admin data is not valid: ${r.errorsText(e.errors)}`);return t};parseSessionData=t=>{let e=r.compile(this.context.sessionData);if(!e(t))throw Error(`Session data is not valid: ${r.errorsText(e.errors)}`);return t};parseFrontendData=t=>{let e=r.compile(this.context.frontendData);if(!e(t))throw Error(`Frontend data is not valid: ${r.errorsText(e.errors)}`);return t};parseBackendData=t=>{if(void 0===this.context.backendData)throw Error("Backend data is not supported for this domain");let e=r.compile(this.context.backendData);if(!e(t))throw Error(`Backend data is not valid: ${r.errorsText(e.errors)}`);return t};validateAndMigrateState=(r,e)=>{let a=this.context.isAdminDomain?t(r):r;return this.context.migrate({state:a,version:e},{trimExtraProperties:!1})}}
1
+ import{migrateCommonAdminDomain as t}from"../admin-domain/implementation/common-admin-migrations.js";import{createDecoder as a}from"./decoder/index.js";export class DomainFactory{context;modelVersion;hasBackendData;constructor(t){this.context=t,this.modelVersion=t.modelVersion,this.hasBackendData=void 0!==t.backendData}parsePublishedData=t=>a(this.context.publishedData,"Admin data")(t);parseSessionData=t=>a(this.context.sessionData,"Session data")(t);parseFrontendData=t=>a(this.context.frontendData,"Frontend data")(t);parseBackendData=t=>{if(void 0===this.context.backendData)throw Error("Backend data is not supported for this domain");return a(this.context.backendData,"Backend data")(t)};validateAndMigrateState=(a,e)=>{let n=this.context.isAdminDomain?t(a):a;return this.context.migrate({state:n,version:e},{trimExtraProperties:!1})}}