@salsita-ai/sdk 0.50.0-develop.da8d27f5d7 → 0.50.0-develop.dbf0122072

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 (327) hide show
  1. package/README.md +19 -11
  2. package/dist/{phoenix/application-spec → application-spec/assistant}/generate-assistant-prompt.d.ts +6 -5
  3. package/dist/application-spec/assistant/generate-assistant-prompt.js +1 -0
  4. package/dist/application-spec/assistant/index.d.ts +1 -0
  5. package/dist/application-spec/assistant/index.js +1 -0
  6. package/dist/application-spec/errors/diagnostic-codes.d.ts +6 -0
  7. package/dist/application-spec/errors/diagnostic-codes.js +1 -1
  8. package/dist/application-spec/errors/diagnostic-messages.d.ts +6 -0
  9. package/dist/application-spec/errors/diagnostic-messages.js +1 -1
  10. package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
  11. package/dist/application-spec/generate-application/code/project-scaffolding.js +2 -2
  12. package/dist/application-spec/generate-application/code/templates/application-types.js +6 -6
  13. package/dist/application-spec/generate-application/code/templates/configurator-domain-code.d.ts +1 -0
  14. package/dist/application-spec/generate-application/code/templates/configurator-domain-code.js +11 -8
  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/generate-domain-block.d.ts +3 -1
  18. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.js +70 -66
  19. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-phx-globals.js +3 -0
  20. package/dist/application-spec/generate-application/code/templates/domain-spec.js +7 -7
  21. package/dist/application-spec/generate-application/code/templates/domain.js +2 -2
  22. package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.d.ts +11 -0
  23. package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.js +8 -0
  24. package/dist/application-spec/generate-application/code/templates/global-definition/index.d.ts +1 -0
  25. package/dist/application-spec/generate-application/code/templates/global-definition/index.js +1 -1
  26. package/dist/application-spec/generate-application/code/templates/globals.js +1 -0
  27. package/dist/application-spec/generate-application/code/templates/index.d.ts +7 -6
  28. package/dist/application-spec/generate-application/code/templates/index.js +1 -1
  29. package/dist/application-spec/generate-application/code/templates/skills/agents-md.js +2 -0
  30. package/dist/application-spec/generate-application/code/templates/skills/phoenix-cli-skill.js +1 -0
  31. package/dist/application-spec/generate-application/code/templates/{phoenix-create-configurator-skill.d.ts → skills/phoenix-create-configurator-skill.d.ts} +1 -1
  32. package/dist/application-spec/generate-application/code/templates/{phoenix-create-configurator-skill.js → skills/phoenix-create-configurator-skill.js} +43 -13
  33. package/dist/application-spec/generate-application/code/templates/skills/phoenix-feedback-skill.js +54 -0
  34. package/dist/application-spec/generate-application/code/templates/{phoenix-review-skill.js → skills/phoenix-review-skill.js} +7 -5
  35. package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill.js +1 -0
  36. package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.d.ts +1 -0
  37. package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.js +6 -0
  38. package/dist/application-spec/generate-application/code/templates/{common → skills}/sdk-content.d.ts +52 -3
  39. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +82 -0
  40. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.d.ts +2 -0
  41. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.js +1 -1
  42. package/dist/application-spec/generate-application/runtime/sections/actions-runtime.d.ts +14 -0
  43. package/dist/application-spec/generate-application/runtime/sections/actions-runtime.js +1 -0
  44. package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.d.ts +4 -3
  45. package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.js +1 -1
  46. package/dist/application-spec/generate-application/runtime/sections/index.d.ts +1 -0
  47. package/dist/application-spec/generate-application/runtime/sections/index.js +1 -1
  48. package/dist/application-spec/index.d.ts +1 -0
  49. package/dist/application-spec/index.js +1 -1
  50. package/dist/application-spec/parse-application-files/categorize/categorize-files.d.ts +3 -1
  51. package/dist/application-spec/parse-application-files/categorize/categorize-files.js +1 -1
  52. package/dist/application-spec/parse-application-files/merge/index.d.ts +1 -0
  53. package/dist/application-spec/parse-application-files/merge/index.js +1 -1
  54. package/dist/application-spec/parse-application-files/merge/merged-actions.d.ts +11 -0
  55. package/dist/application-spec/parse-application-files/merge/merged-actions.js +1 -0
  56. package/dist/application-spec/parse-application-files/merge/merged-spec.d.ts +2 -0
  57. package/dist/application-spec/parse-application-files/merge/merged-spec.js +1 -1
  58. package/dist/application-spec/parse-application-files/raw-spec/index.d.ts +1 -0
  59. package/dist/application-spec/parse-application-files/raw-spec/index.js +1 -1
  60. package/dist/application-spec/parse-application-files/raw-spec/raw-actions.d.ts +18 -0
  61. package/dist/application-spec/parse-application-files/raw-spec/raw-actions.js +1 -0
  62. package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.d.ts +14 -2
  63. package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.js +1 -1
  64. package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.d.ts +2 -0
  65. package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.js +1 -1
  66. package/dist/application-spec/parse-application-files/resolve/resolve-import-modules.js +1 -1
  67. package/dist/application-spec/parse-application-files/spec/application/application-spec.js +1 -1
  68. package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.d.ts +4 -2
  69. package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.js +1 -1
  70. package/dist/application-spec/parse-application-files/spec/common/index.d.ts +1 -0
  71. package/dist/application-spec/parse-application-files/spec/common/index.js +1 -1
  72. package/dist/application-spec/parse-application-files/spec/common/schema-ref-resolver.d.ts +23 -0
  73. package/dist/application-spec/parse-application-files/spec/common/schema-ref-resolver.js +1 -0
  74. package/dist/application-spec/parse-application-files/spec/model/names/action-name.d.ts +10 -0
  75. package/dist/application-spec/parse-application-files/spec/model/names/action-name.js +1 -0
  76. package/dist/application-spec/parse-application-files/spec/model/names/index.d.ts +1 -0
  77. package/dist/application-spec/parse-application-files/spec/model/names/index.js +1 -1
  78. package/dist/application-spec/parse-application-files/spec/sections/actions.d.ts +35 -0
  79. package/dist/application-spec/parse-application-files/spec/sections/actions.js +1 -0
  80. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.d.ts +5 -21
  81. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.js +1 -1
  82. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +14 -39
  83. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
  84. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-server-settings.d.ts +1 -1
  85. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant.d.ts +5 -19
  86. package/dist/application-spec/parse-application-files/spec/sections/index.d.ts +1 -0
  87. package/dist/application-spec/parse-application-files/spec/sections/index.js +1 -1
  88. package/dist/client/phoenix-api.d.ts +5 -1
  89. package/dist/configurator/application-runtime/extensions/configurator-extension-systems.d.ts +2 -1
  90. package/dist/configurator/application-runtime/extensions/configurator-extension-systems.js +1 -1
  91. package/dist/configurator/application-runtime/extensions/selectors.d.ts +2 -1
  92. package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
  93. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +180 -0
  94. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -0
  95. package/dist/configurator/{assistant → application-runtime/extensions/systems/assistant-system}/browser-details.d.ts +1 -1
  96. package/dist/configurator/application-runtime/extensions/systems/assistant-system/browser-details.js +1 -0
  97. package/dist/configurator/application-runtime/extensions/systems/assistant-system/change-recorder.d.ts +85 -0
  98. package/dist/configurator/application-runtime/extensions/systems/assistant-system/change-recorder.js +1 -0
  99. package/dist/configurator/{assistant → application-runtime/extensions/systems/assistant-system}/graphql-tools.d.ts +20 -16
  100. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -0
  101. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.d.ts +4 -0
  102. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.js +1 -1
  103. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +16 -1
  104. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
  105. package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.d.ts +9 -0
  106. package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.js +1 -0
  107. package/dist/configurator/application-runtime/extensions/systems/index.d.ts +1 -0
  108. package/dist/configurator/application-runtime/extensions/systems/index.js +1 -1
  109. package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.d.ts +2 -0
  110. package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.js +1 -1
  111. package/dist/configurator/common/frontend-analytics.d.ts +21 -21
  112. package/dist/configurator/index.d.ts +0 -1
  113. package/dist/configurator/index.js +1 -1
  114. package/dist/configurator/pages/LoadedConfiguratorDetailPage.js +1 -1
  115. package/dist/configurator/scene/scene-analytics/scene-analytics.d.ts +2 -2
  116. package/dist/configurator/ui/assistant/AssistantChips.d.ts +11 -0
  117. package/dist/configurator/ui/assistant/AssistantChips.js +1 -0
  118. package/dist/configurator/ui/assistant/AssistantComposer.d.ts +6 -0
  119. package/dist/configurator/ui/assistant/AssistantComposer.js +1 -0
  120. package/dist/configurator/ui/assistant/AssistantMarkdown.d.ts +7 -0
  121. package/dist/configurator/ui/assistant/AssistantMarkdown.js +1 -0
  122. package/dist/configurator/ui/assistant/AssistantPanel.d.ts +11 -0
  123. package/dist/configurator/ui/assistant/AssistantPanel.js +1 -0
  124. package/dist/configurator/ui/assistant/AssistantThread.d.ts +6 -0
  125. package/dist/configurator/ui/assistant/AssistantThread.js +1 -0
  126. package/dist/configurator/ui/assistant/assistant-failure.d.ts +18 -0
  127. package/dist/configurator/ui/assistant/assistant-failure.js +1 -0
  128. package/dist/configurator/ui/assistant/index.d.ts +2 -0
  129. package/dist/configurator/ui/assistant/index.js +1 -0
  130. package/dist/configurator/ui/assistant/streamed-markdown.d.ts +6 -0
  131. package/dist/configurator/ui/assistant/streamed-markdown.js +2 -0
  132. package/dist/configurator/ui/assistant/theme.d.ts +2 -0
  133. package/dist/configurator/ui/assistant/theme.js +1 -0
  134. package/dist/configurator/ui/assistant/thread-items.d.ts +37 -0
  135. package/dist/configurator/ui/assistant/thread-items.js +1 -0
  136. package/dist/configurator/ui/assistant/tool-chip.d.ts +44 -0
  137. package/dist/configurator/ui/assistant/tool-chip.js +1 -0
  138. package/dist/configurator/ui/assistant/use-follow-stream.d.ts +17 -0
  139. package/dist/configurator/ui/assistant/use-follow-stream.js +1 -0
  140. package/dist/configurator/ui/assistant/use-is-assistant-panel-open.d.ts +5 -0
  141. package/dist/configurator/ui/assistant/use-is-assistant-panel-open.js +1 -0
  142. package/dist/configurator/ui/configurator-layout/universal/DesktopLayout.js +5 -5
  143. package/dist/configurator/ui/configurator-layout/universal/MobileLayout.d.ts +2 -0
  144. package/dist/configurator/ui/configurator-layout/universal/MobileLayout.js +4 -4
  145. package/dist/configurator/ui/legacy/mobile-controls/MobileControls.d.ts +1 -1
  146. package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.d.ts +10 -0
  147. package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.js +1 -0
  148. package/dist/configurator/ui/phoenix-layout-elements/index.d.ts +1 -0
  149. package/dist/configurator/ui/phoenix-layout-elements/index.js +1 -1
  150. package/dist/docs/index.json +12 -2
  151. package/dist/docs/layouts/toolbar.mdx +6 -0
  152. package/dist/docs/other-features/domain-actions.mdx +418 -0
  153. package/dist/docs/other-features/side-effects.mdx +26 -0
  154. package/dist/docs/phoenix/admin.mdx +2 -2
  155. package/dist/docs/phoenix/best-practices.mdx +1 -0
  156. package/dist/docs/phoenix/finalization.mdx +1 -1
  157. package/dist/docs/phoenix/integration/headless-mode-external.mdx +5 -5
  158. package/dist/docs/phoenix/integration/widget-mode-external.mdx +5 -5
  159. package/dist/docs/phoenix/migrations.mdx +45 -5
  160. package/dist/docs/phoenix/phoenix-cli.mdx +139 -20
  161. package/dist/docs/phoenix/project-structure.mdx +7 -3
  162. package/dist/docs/phoenix/sdk-builder-workflow.mdx +12 -8
  163. package/dist/domain/actions/action-factory.d.ts +10 -0
  164. package/dist/domain/actions/action-factory.js +1 -0
  165. package/dist/domain/actions/prepare-action-implementations.d.ts +15 -0
  166. package/dist/domain/actions/prepare-action-implementations.js +5 -0
  167. package/dist/domain/application/application-config.d.ts +2 -60
  168. package/dist/domain/application/assistant/assistant-manifest.d.ts +61 -0
  169. package/dist/domain/application/assistant/assistant-manifest.js +1 -0
  170. package/dist/domain/application/assistant/assistant-resolved-manifest.d.ts +95 -0
  171. package/dist/domain/application/assistant/assistant-resolved-manifest.js +1 -0
  172. package/dist/domain/application/assistant/assistant-value-type.d.ts +9 -0
  173. package/dist/domain/application/assistant/assistant-value-type.js +1 -0
  174. package/dist/domain/application/assistant/build-assistant-manifest.d.ts +4 -0
  175. package/dist/domain/application/assistant/build-assistant-manifest.js +1 -0
  176. package/dist/domain/application/assistant/index.d.ts +3 -0
  177. package/dist/domain/application/assistant/index.js +1 -0
  178. package/dist/domain/application/assistant-field-options.d.ts +1 -1
  179. package/dist/domain/application/assistant-mutations.d.ts +16 -15
  180. package/dist/domain/application/assistant-mutations.js +1 -1
  181. package/dist/domain/application/assistant-recipe-groups.d.ts +1 -1
  182. package/dist/domain/application/configurator-builder.d.ts +4 -3
  183. package/dist/domain/application/index.d.ts +2 -1
  184. package/dist/domain/application/index.js +1 -1
  185. package/dist/domain/components/updates.d.ts +16 -0
  186. package/dist/domain/core/action.d.ts +67 -0
  187. package/dist/domain/core/action.js +1 -0
  188. package/dist/domain/core/domain-factory.d.ts +4 -0
  189. package/dist/domain/core/index.d.ts +1 -0
  190. package/dist/domain/domain-builder.d.ts +7 -0
  191. package/dist/domain/domain-builder.js +1 -1
  192. package/dist/domain/domain-context/action-system/action-system.d.ts +40 -0
  193. package/dist/domain/domain-context/action-system/action-system.js +1 -0
  194. package/dist/domain/domain-context/domain-context-systems.d.ts +5 -2
  195. package/dist/domain/domain-context/index.d.ts +2 -1
  196. package/dist/domain/domain-context/index.js +1 -1
  197. package/dist/domain/domain-context/store-system/store-system.js +1 -1
  198. package/dist/domain/domain-runtime/domain-context/domain-context.js +1 -1
  199. package/dist/domain/domain-runtime/domain-context/selectors.d.ts +4 -0
  200. package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
  201. package/dist/domain/domain-runtime/domain-runtime.d.ts +16 -4
  202. package/dist/domain/domain-runtime/spec/initialize.js +1 -1
  203. package/dist/domain/domain-runtime/spec/selectors.d.ts +2 -2
  204. package/dist/domain/domain-runtime/spec/selectors.js +1 -1
  205. package/dist/domain/domain-runtime/spec/types.d.ts +18 -4
  206. package/dist/domain/index.d.ts +2 -0
  207. package/dist/domain/index.js +1 -1
  208. package/dist/domain/mocks/create-mock-domain-runtime.d.ts +8 -2
  209. package/dist/domain/system-components/phoenix-layout-elements/assistant-toolbar-button.d.ts +44 -0
  210. package/dist/domain/system-components/phoenix-layout-elements/assistant-toolbar-button.js +1 -0
  211. package/dist/domain/system-components/phoenix-layout-elements/index.d.ts +1 -0
  212. package/dist/domain/system-components/phoenix-layout-elements/index.js +1 -1
  213. package/dist/domain/system-components/phoenix-layout-elements/phoenix-layout-element.d.ts +2 -1
  214. package/dist/domain/system-components/phoenix-layout-elements/phoenix-layout-element.js +1 -1
  215. package/dist/editor/Editor.js +1 -1
  216. package/dist/editor/domain-editors/DomainSpecContext.js +1 -1
  217. package/dist/editor/domain-editors/apply-spec-update.js +1 -1
  218. package/dist/editor/domain-editors/use-implementation-files.d.ts +7 -3
  219. package/dist/editor/domain-editors/use-implementation-files.js +1 -1
  220. package/dist/editor/graphql/GraphQLPanel.js +1 -1
  221. package/dist/editor/variants/VariantAnswerFooter.d.ts +17 -0
  222. package/dist/editor/variants/VariantAnswerFooter.js +1 -0
  223. package/dist/editor/variants/VariantPreviewHandler.d.ts +6 -0
  224. package/dist/editor/variants/VariantPreviewHandler.js +1 -0
  225. package/dist/editor/variants/variant-preview-styles.d.ts +49 -0
  226. package/dist/editor/variants/variant-preview-styles.js +1 -0
  227. package/dist/i18n/locales/cs/messages.js +1 -1
  228. package/dist/i18n/locales/da/messages.js +1 -1
  229. package/dist/i18n/locales/de/messages.js +1 -1
  230. package/dist/i18n/locales/de-AT/messages.js +1 -1
  231. package/dist/i18n/locales/en/messages.js +1 -1
  232. package/dist/i18n/locales/en-AU/messages.js +1 -1
  233. package/dist/i18n/locales/en-GB/messages.js +1 -1
  234. package/dist/i18n/locales/es/messages.js +1 -1
  235. package/dist/i18n/locales/fr/messages.js +1 -1
  236. package/dist/i18n/locales/hu/messages.js +1 -1
  237. package/dist/i18n/locales/it/messages.js +1 -1
  238. package/dist/i18n/locales/nl/messages.js +1 -1
  239. package/dist/i18n/locales/pl/messages.js +1 -1
  240. package/dist/i18n/locales/pt/messages.js +1 -1
  241. package/dist/i18n/locales/ro/messages.js +1 -1
  242. package/dist/i18n/locales/sk/messages.js +1 -1
  243. package/dist/i18n/locales/tr/messages.js +1 -1
  244. package/dist/legacy/domain-spec/__generated/domain-schema.d.ts +6 -0
  245. package/dist/phoenix/application-spec/application-spec-builder.js +1 -1
  246. package/dist/phoenix/application-spec/resolve-deployment-data.js +2 -2
  247. package/dist/phoenix/cli.js +1 -1
  248. package/dist/phoenix/commands/build.d.ts +5 -0
  249. package/dist/phoenix/commands/build.js +1 -1
  250. package/dist/phoenix/commands/deploy.js +2 -2
  251. package/dist/phoenix/commands/dev.js +5 -5
  252. package/dist/phoenix/commands/feedback.d.ts +2 -1
  253. package/dist/phoenix/commands/feedback.js +1 -1
  254. package/dist/phoenix/commands/index.d.ts +1 -0
  255. package/dist/phoenix/commands/index.js +1 -1
  256. package/dist/phoenix/commands/login.d.ts +24 -6
  257. package/dist/phoenix/commands/login.js +2 -2
  258. package/dist/phoenix/commands/story-dev.js +2 -2
  259. package/dist/phoenix/commands/variants.d.ts +35 -0
  260. package/dist/phoenix/commands/variants.js +1 -0
  261. package/dist/phoenix/editor-server/commands-router.d.ts +68 -1
  262. package/dist/phoenix/editor-server/commands-router.js +1 -1
  263. package/dist/phoenix/editor-server/editor-router.d.ts +65 -0
  264. package/dist/phoenix/editor-server/editor-server.d.ts +3 -3
  265. package/dist/phoenix/editor-server/editor-server.js +1 -1
  266. package/dist/phoenix/editor-server/protocol.d.ts +1 -0
  267. package/dist/phoenix/editor-server/spec-router.js +1 -1
  268. package/dist/phoenix/editor-server/trpc.d.ts +3 -0
  269. package/dist/phoenix/services/application-spec-project-watcher.d.ts +13 -2
  270. package/dist/phoenix/services/application-spec-project-watcher.js +3 -3
  271. package/dist/phoenix/services/index.d.ts +5 -0
  272. package/dist/phoenix/services/index.js +1 -1
  273. package/dist/phoenix/services/phoenix-application.d.ts +21 -0
  274. package/dist/phoenix/services/phoenix-application.js +1 -0
  275. package/dist/phoenix/services/phoenix-store.d.ts +48 -0
  276. package/dist/phoenix/services/phoenix-store.js +1 -0
  277. package/dist/phoenix/services/phx-banner-plugin.d.ts +32 -0
  278. package/dist/phoenix/services/phx-banner-plugin.js +1 -0
  279. package/dist/phoenix/services/phx-licenses-plugin.d.ts +55 -0
  280. package/dist/phoenix/services/phx-licenses-plugin.js +8 -0
  281. package/dist/phoenix/services/phx-variant-previews-plugin.d.ts +9 -0
  282. package/dist/phoenix/services/phx-variant-previews-plugin.js +1 -0
  283. package/dist/phoenix/services/variant-file-session.d.ts +36 -0
  284. package/dist/phoenix/services/variant-file-session.js +1 -0
  285. package/dist/phoenix/services/variant-preview-service.d.ts +80 -0
  286. package/dist/phoenix/services/variant-preview-service.js +1 -0
  287. package/dist/phoenix/services/vite-config.d.ts +2 -0
  288. package/dist/phoenix/services/vite-config.js +1 -1
  289. package/dist/phoenix/utils/index.d.ts +1 -0
  290. package/dist/phoenix/utils/index.js +1 -1
  291. package/dist/phoenix/utils/read-git-commit.d.ts +14 -0
  292. package/dist/phoenix/utils/read-git-commit.js +1 -0
  293. package/dist/react-sdk/application-runtime/common-services/analytics/analytics-service.d.ts +2 -2
  294. package/dist/react-sdk/application-runtime/common-services/analytics/domain-controls-analytics.d.ts +21 -21
  295. package/dist/react-sdk/application-runtime/hooks/data/use-published-data.d.ts +1 -1
  296. package/dist/react-sdk/application-runtime/hooks/use-spec.d.ts +1 -1
  297. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +16 -4
  298. package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +3 -0
  299. package/dist/ui-sdk/common/use-viewport-size.d.ts +4 -1
  300. package/dist/ui-sdk/common/use-viewport-size.js +1 -1
  301. package/dist/ui-sdk/components/mobile-controls/index.d.ts +1 -1
  302. package/dist/ui-sdk/theme/types.d.ts +4 -0
  303. package/package.json +5 -8
  304. package/schema/domain-spec.json +24 -0
  305. package/dist/application-spec/generate-application/code/templates/agents-md.js +0 -2
  306. package/dist/application-spec/generate-application/code/templates/common/sdk-content.js +0 -67
  307. package/dist/application-spec/generate-application/code/templates/phoenix-cli-skill.js +0 -1
  308. package/dist/application-spec/generate-application/code/templates/phoenix-feedback-skill.js +0 -31
  309. package/dist/application-spec/generate-application/code/templates/phoenix-skill.js +0 -1
  310. package/dist/configurator/assistant/browser-details.js +0 -1
  311. package/dist/configurator/assistant/graphql-tools.js +0 -1
  312. package/dist/configurator/assistant/index.d.ts +0 -1
  313. package/dist/configurator/assistant/index.js +0 -1
  314. package/dist/configurator/assistant/use-assistant-chat.d.ts +0 -20
  315. package/dist/configurator/assistant/use-assistant-chat.js +0 -1
  316. package/dist/extras/assistant/AssistantChat.d.ts +0 -6
  317. package/dist/extras/assistant/AssistantChat.js +0 -1
  318. package/dist/extras/assistant/index.d.ts +0 -1
  319. package/dist/extras/assistant/index.js +0 -1
  320. package/dist/phoenix/application-spec/generate-assistant-prompt.js +0 -1
  321. /package/dist/application-spec/generate-application/code/templates/{common → skills}/agent-skill.d.ts +0 -0
  322. /package/dist/application-spec/generate-application/code/templates/{common → skills}/agent-skill.js +0 -0
  323. /package/dist/application-spec/generate-application/code/templates/{agents-md.d.ts → skills/agents-md.d.ts} +0 -0
  324. /package/dist/application-spec/generate-application/code/templates/{phoenix-cli-skill.d.ts → skills/phoenix-cli-skill.d.ts} +0 -0
  325. /package/dist/application-spec/generate-application/code/templates/{phoenix-feedback-skill.d.ts → skills/phoenix-feedback-skill.d.ts} +0 -0
  326. /package/dist/application-spec/generate-application/code/templates/{phoenix-review-skill.d.ts → skills/phoenix-review-skill.d.ts} +0 -0
  327. /package/dist/application-spec/generate-application/code/templates/{phoenix-skill.d.ts → skills/phoenix-skill.d.ts} +0 -0
@@ -0,0 +1,95 @@
1
+ import type { AssistantFieldOptions, AssistantRecipeGroup } from './assistant-manifest.js';
2
+ /** JSON description of a scalar or recursively nested list, including nullability at each level. */
3
+ export type AssistantValueType = {
4
+ readonly kind: 'scalar';
5
+ readonly name: 'Int' | 'Float' | 'String' | 'Boolean' | 'ID' | 'JSON';
6
+ readonly nonNull: boolean;
7
+ } | {
8
+ readonly kind: 'list';
9
+ readonly item: AssistantValueType;
10
+ readonly nonNull: boolean;
11
+ };
12
+ /** A relation edge resolved against the model at parse time, linked to GraphQL types only during building. */
13
+ export interface AssistantRelationType {
14
+ readonly kind: 'edge';
15
+ readonly target: string;
16
+ readonly cardinality: '1-1' | '0-1' | '0-N' | '1-N';
17
+ }
18
+ /** A field's source and resolved type, carried in the application bundle without GraphQL instances. */
19
+ export interface AssistantResolvedField {
20
+ readonly name: string;
21
+ readonly source: string;
22
+ readonly type: {
23
+ readonly kind: 'value';
24
+ readonly type: AssistantValueType;
25
+ } | AssistantRelationType;
26
+ readonly localized: boolean;
27
+ readonly description?: string;
28
+ }
29
+ /** Declared UI state values used to describe the navigation query. */
30
+ export interface AssistantStates {
31
+ readonly navigationStates: readonly string[];
32
+ readonly viewStates: readonly string[];
33
+ readonly toolStates: readonly string[];
34
+ }
35
+ /** Serializable resolved whitelist from which the browser or backend constructs the assistant schema. */
36
+ export interface AssistantResolvedManifest {
37
+ readonly entityTypes: readonly string[];
38
+ readonly aliases: Readonly<Record<string, readonly string[]>>;
39
+ readonly exampleType?: string;
40
+ readonly fields: Readonly<Record<string, readonly AssistantResolvedField[]>>;
41
+ readonly states: AssistantStates;
42
+ readonly deletableTypes: readonly string[];
43
+ readonly writableTypes: readonly AssistantWritableType[];
44
+ readonly childRecipes: Readonly<Record<string, AssistantResolvedRecipes>>;
45
+ readonly replaceRecipes: Readonly<Record<string, AssistantResolvedRecipes>>;
46
+ readonly optionsEdges: Readonly<Record<string, readonly AssistantResolvedOptionsEdge[]>>;
47
+ readonly actionFields: readonly AssistantResolvedAction[];
48
+ }
49
+ /** Optional mutation input for one stored field, using its exposed name. */
50
+ export interface AssistantWritableField {
51
+ readonly name: string;
52
+ readonly property: string;
53
+ readonly type: AssistantValueType;
54
+ readonly description?: string;
55
+ }
56
+ /** One entity type's writable fields, in manifest order. */
57
+ export interface AssistantWritableType {
58
+ readonly entityType: string;
59
+ readonly fields: readonly AssistantWritableField[];
60
+ }
61
+ /** Description hints resolved from recipe/option entries; no parse context is retained. */
62
+ export type AssistantResolvedHint = 'sameForAllInstances' | 'constantDuringSession';
63
+ /** Recipe groups and their description hints for one entity type. */
64
+ export interface AssistantResolvedRecipes {
65
+ readonly groups: readonly AssistantRecipeGroup[];
66
+ readonly hints: readonly AssistantResolvedHint[];
67
+ }
68
+ /** One options edge, carrying the write-validation contract and schema description hints. */
69
+ export interface AssistantResolvedOptionsEdge {
70
+ readonly options: AssistantFieldOptions;
71
+ readonly hints: readonly AssistantResolvedHint[];
72
+ }
73
+ /** An action result field, either an entity edge or a plain JSON-described value. */
74
+ export type AssistantResolvedActionResult = {
75
+ readonly kind: 'edge';
76
+ readonly target: string;
77
+ readonly list: boolean;
78
+ readonly nullable: boolean;
79
+ readonly description?: string;
80
+ } | {
81
+ readonly kind: 'value';
82
+ readonly type: AssistantValueType;
83
+ readonly description?: string;
84
+ };
85
+ /** A custom mutation resolved against the declared action, independent of its implementation. */
86
+ export interface AssistantResolvedAction {
87
+ readonly fieldName: string;
88
+ readonly actionName: string;
89
+ readonly description?: string;
90
+ readonly args: Readonly<Record<string, {
91
+ readonly type: AssistantValueType;
92
+ readonly description?: string;
93
+ }>>;
94
+ readonly result: Readonly<Record<string, AssistantResolvedActionResult>>;
95
+ }
@@ -0,0 +1,9 @@
1
+ import { type GraphQLInputType, type GraphQLOutputType, GraphQLScalarType } from 'graphql';
2
+ import type { AssistantValueType } from './assistant-resolved-manifest.js';
3
+ /**
4
+ * Opaque scalar for values the assistant schema does not type: objects, custom TypeScript types and
5
+ * loose unions. A value is plain serializable data and passes through unchanged.
6
+ */
7
+ export declare const GraphQLJSON: GraphQLScalarType<unknown, unknown>;
8
+ /** Recreates a GraphQL value type from the JSON descriptor, preserving every list and nullability layer. */
9
+ export declare const createAssistantValueType: (descriptor: AssistantValueType) => GraphQLInputType & GraphQLOutputType;
@@ -0,0 +1 @@
1
+ import{GraphQLBoolean as e,GraphQLFloat as t,GraphQLID as a,GraphQLInt as n,GraphQLList as r,GraphQLNonNull as l,GraphQLScalarType as s,GraphQLString as i}from"graphql";export const GraphQLJSON=new s({name:"JSON",description:"Any JSON value, returned as stored. Always plain serializable data."});let o={Int:n,Float:t,String:i,Boolean:e,ID:a,JSON:GraphQLJSON};export const createAssistantValueType=e=>{let t="list"===e.kind?new r(createAssistantValueType(e.item)):o[e.name];return e.nonNull?new l(t):t};
@@ -0,0 +1,4 @@
1
+ import type { AssistantManifest } from './assistant-manifest.js';
2
+ import type { AssistantResolvedManifest } from './assistant-resolved-manifest.js';
3
+ /** Constructs the schema and runtime sources exclusively from serializable resolved data. */
4
+ export declare const buildAssistantManifest: (resolved: AssistantResolvedManifest) => Required<AssistantManifest>;
@@ -0,0 +1 @@
1
+ import{GraphQLBoolean as e,GraphQLID as t,GraphQLInputObjectType as n,GraphQLInterfaceType as i,GraphQLList as o,GraphQLNonNull as r,GraphQLObjectType as s,GraphQLSchema as a,GraphQLString as p,printSchema as d,validateSchema as h}from"graphql";import{GraphQLJSON as c,createAssistantValueType as l}from"./assistant-value-type.js";let y="AnyDomainEntity",u="RootEntity",f={section:"childRecipes",mutation:"addChild"},g={section:"replaceRecipes",mutation:"replaceEntity"},w=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],m=(e,t)=>{if(!t||0===t.length)return e;let n=`One of: ${t.map(e=>`"${e}"`).join(", ")}.`;return e?/[.!?]$/.test(e)?`${e} ${n}`:`${e}. ${n}`:n},b=({target:e,cardinality:t},n)=>{let i=n(e);switch(t){case"1-1":return new r(i);case"0-1":return i;case"0-N":case"1-N":return new r(new o(new r(i)))}},v=(e,n,i)=>{let o={id:{type:new r(t),description:i?`Unique id of the entity, e.g. "${i}-1".`:void 0},type:{type:new r(p),description:i?`Entity type name, e.g. "${i}".`:void 0}};for(let t of e)o[t.name]={type:"edge"===t.type.kind?b(t.type,n):l(t.type.type),description:t.description};return o},$=e=>Object.fromEntries(e.map(({name:e,source:t,localized:n})=>[e,n?{source:t,localized:!0}:{source:t}])),j={sameForAllInstances:e=>`All ${e} instances have the same recipe groups and recipes.`,constantDuringSession:()=>"They do not change during the session."},O={sameForAllInstances:e=>`All ${e} instances have the same options.`,constantDuringSession:()=>"The options do not change during the session."},E=(e,t,n)=>e.map(e=>` ${t[e](n)}`).join(""),R=({section:e},{groups:t,hints:n},{entityType:i,purpose:s,recipeGroup:a})=>{let p=t.filter(({dryRuns:e})=>!e).map(({groupId:e})=>e);return 0===t.length?{}:{[e]:{type:new r(new o(new r(a))),description:`The recipe groups for ${s} this ${i}: ${t.map(({groupId:e})=>e).join(", ")}. A group is listed only while the configurator offers it on the entity.${p.length>0?` Recipes of these groups cannot be dry-run: ${p.join(", ")}.`:""}${E(n,j,i)}`}}},k=({entityType:e,childRecipes:t,replaceRecipes:n,optionsEdges:i},{recipeGroup:a,fieldOption:p})=>new s({name:`${e}Meta`,fields:Object.assign(R(f,t,{entityType:e,purpose:"adding children to",recipeGroup:a}),R(g,n,{entityType:e,purpose:"replacing",recipeGroup:a}),...i.map(({options:{edgeName:t,field:n,validate:i,dryRuns:s},hints:a})=>({[t]:{type:new o(new r(p)),description:`The values "${n}" of this ${e} can take, as the configurator offers them in the current state of the entity. Null when the configurator does not offer a choice on this entity. ${i?`modify${e} rejects a "${n}" value that is not in the list.`:`modify${e} does not check "${n}" against the list.`}${s?"":" Its options cannot be dry-run."}${E(a,O,e)}`}})))}),I=e=>Object.entries(e).map(([e,t])=>`${e} (${t.map(({groupId:e})=>e).join(", ")})`);export const buildAssistantManifest=b=>{var j,O,E,R,T;let A,N,D,M,{entityTypes:S,aliases:q,exampleType:W,fields:C,states:G,deletableTypes:K,writableTypes:U,actionFields:F,optionsEdges:x}=b,z=Object.fromEntries(Object.entries(b.childRecipes).map(([e,t])=>[e,t.groups])),Q=Object.fromEntries(Object.entries(b.replaceRecipes).map(([e,t])=>[e,t.groups])),B=new Map,H=new Map,J=new Map,L=e=>{let[t,...n]=Object.entries(q).find(([t])=>t===e)?.[1]??[];return(t&&0===n.length?H.get(t):void 0)??J.get(e)??V},P=e=>H.get(e)??L(e),V=new i({name:y,description:"Every domain entity.",fields:()=>v(C[y]??[],P,W)});for(let e of(J.set(y,V),Object.keys(q)))e!==y&&J.set(e,new i({name:e,interfaces:[V],fields:()=>v(C[e]??[],P)}));let X={};for(let e of S){let t=[y,...Object.entries(q).filter(([t,n])=>t!==y&&n.includes(e)).map(([e])=>e)],n=C[e]??[];X[e]=$(n),H.set(e,new s({name:e,interfaces:t.flatMap(e=>J.get(e)??[]),fields:()=>{let t=B.get(e);return{...v(n,P),...t?{meta:{type:new r(t),description:"What the configurator offers on this entity besides its fields."}}:{}}}}))}let Y=(j=()=>L(J.has(u)?u:y),O=()=>L(y),A=new s({name:"DryRunError",description:"One reason a change cannot be made right now.",fields:{type:{type:new r(p),description:'Kind of the problem, or "uncaught".'},entityId:{type:t,description:"The entity the problem is on, when it is on one."},message:{type:p,description:"The problem as the configurator words it for the user."}}}),new s({name:"DryRun",description:"What using a recipe or writing an option would do, tried out on the configuration the query reads. Nothing is changed.",fields:()=>({ok:{type:new r(e),description:"Whether the change would succeed on the configuration the query reads."},root:{type:j(),description:"The root entity of the configuration as it would be after the change; null when ok is false. Everything selected under it reads that configuration."},changedEntities:{type:new r(new o(new r(O()))),description:"Every entity the change would add or modify, read from that configuration; empty when ok is false. An entity whose id the configuration does not have yet would be added, and its id may differ in the real mutation. An entity that is written to is listed even when it gets the values it already has."},deletedEntityIds:{type:new r(new o(new r(t))),description:"The ids of the entities the change would remove; empty when ok is false."},sideEffects:{type:new r(new o(new r(p))),description:"What the configurator would do beyond the change itself, such as parts it would add or replace, in its own words; empty when ok is false."},errors:{type:new r(new o(new r(A))),description:"Why the change cannot be made; empty when ok is true."}})})),Z={recipeGroup:(E=[...Object.keys(z).length>0?[f.mutation]:[],...Object.keys(Q).length>0?[g.mutation]:[]],N=E.join(" or "),D=new s({name:"Recipe",description:"One recipe of a recipe group: something that can be added to the entity, or something the entity can be replaced with, depending on the edge the group is listed under.",fields:{key:{type:new r(p),description:`Identifies the recipe within its group; pass it to ${N} as recipeKey. Keys can change with the configuration and with the language, so read them from the listing rather than remembering them.`},name:{type:new r(p),description:"Name shown to the user."},description:{type:p},imageUrl:{type:p,description:"Thumbnail shown to the user."},dryRun:{type:Y,description:"Tries the recipe out. Each selected dry-run costs a full recalculation, so select it only on the recipes you are deciding between. Null for a group whose recipes cannot be dry-run."}}}),new s({name:"RecipeGroup",description:"A group of recipes of an entity, as the configurator offers them to the user.",fields:{groupId:{type:new r(p),description:`Identifies the group on its entity; pass it to ${N} as recipeGroupId.`},name:{type:new r(p),description:"Name shown to the user."},description:{type:p},recipes:{type:new r(new o(new r(D)))}}})),fieldOption:new s({name:"FieldOption",description:"One choice of a field, as the configurator offers it to the user.",fields:{value:{type:new r(c),description:"The value to write to the field."},name:{type:p,description:"Name shown to the user."},description:{type:p},imageUrl:{type:p,description:"Image shown to the user."},color:{type:p,description:'Color shown to the user, as "#rrggbb".'},dryRun:{type:Y,description:"Tries writing the value to the field. Each selected dry-run costs a full recalculation, so select it only on the options you are deciding between. Null for a field whose options cannot be dry-run."}}})};for(let e of S){let t=w(b.childRecipes,e)??{groups:[],hints:[]},n=w(b.replaceRecipes,e)??{groups:[],hints:[]},i=w(x,e)??[];(t.groups.length>0||n.groups.length>0||i.length>0)&&B.set(e,k({entityType:e,childRecipes:t,replaceRecipes:n,optionsEdges:i},Z))}let _=new a({query:(R=L(J.has(u)?u:y),T=L(y),M=(e=>{let t={};for(let[n,i,o]of[["navigationState","Active navigation state.",e.navigationStates],["viewState","Active view state.",e.viewStates],["toolState","Active tool state.",e.toolStates]])o.length>1&&(t[n]={type:new r(p),description:m(i,o)});if(0!==Object.keys(t).length)return new s({name:"Navigation",description:"The active UI states of the configurator.",fields:t})})(G),new s({name:"Query",fields:{root:{type:new r(R),description:"The root entity of the configuration."},entities:{type:new r(new o(T)),args:{ids:{type:new o(new r(t))}},description:`Every entity of the configuration, or, when ids are given, those entities in the same order with null for an unknown id. Ids have the form "<Type>-<number>"${W?`, e.g. "${W}-1"`:""}; any other id is an error.`},selectedEntity:{type:new r(T),description:"The selected entity, or the root entity when nothing is selected."},...M?{navigation:{type:new r(M)}}:{}}})),mutation:(({deletableTypes:e,writableTypes:i,childRecipes:a,replaceRecipes:d,actionFields:h,objectTypes:c,anyDomainEntity:y,targetOutputType:u})=>{let f,g;if(0!==e.length||0!==i.length||0!==Object.keys(a).length||0!==Object.keys(d).length||0!==h.length)return new s({name:"Mutation",fields:Object.assign(0===e.length?{}:{deleteEntity:{type:new r(new o(new r(t))),args:{id:{type:new r(t)}},description:`Deletes the entity with the given id, together with the entities composed into it, and returns the ids of every entity the deletion removed, the given one first. Deletable entity types: ${e.join(", ")}. Nothing can be read from removed entities afterwards, so query what you need from them before deleting.`}},0===(f=I(a)).length?{}:{addChild:{type:new r(new o(new r(y))),args:{parentId:{type:new r(t)},recipeGroupId:{type:new r(p)},recipeKey:{type:new r(p)}},description:`Adds a child to the entity with the id parentId by one recipe of one of its recipe groups. Entity types with recipe groups: ${f.join("; ")}. Read the groupId and the recipe key from "meta { childRecipes }" of the parent. Returns every entity the change added, the recipe's own first and then whatever the configurator added in response, such as a part the new child needs; the list is empty when the configurator removed them again.`}},0===(g=I(d)).length?{}:{replaceEntity:{type:new r(new o(new r(y))),args:{entityId:{type:new r(t)},recipeGroupId:{type:new r(p)},recipeKey:{type:new r(p)}},description:`Replaces the entity with the id entityId by one recipe of one of its replace recipe groups. Entity types with replace recipe groups: ${g.join("; ")}. Read the groupId and the recipe key from "meta { replaceRecipes }" of the entity. The replacement is a new entity with a new id: the id passed in no longer exists afterwards, and the replacement has the field values of its recipe, not those of the entity it replaces. Returns every entity the change added, the replacement first and then whatever the configurator added in response, such as a part the replacement needs; the list is empty when the configurator removed them again.`}},...i.flatMap(e=>{let i=c.get(e.entityType);return i?[(({entityType:e,fields:i},o)=>{let s=Object.fromEntries(i.map(({name:e,type:t,description:n})=>[e,{type:l(t),description:n}]));return{[`modify${e}`]:{type:o,args:{id:{type:new r(t)},delta:{type:new r(new n({name:`${e}Delta`,fields:s}))}},description:`Changes writable fields of the one ${e} with the given id: ${i.map(({name:e})=>e).join(", ")}. The delta sets only the fields it names and needs at least one; values are in stored units, as the field descriptions say. Returns the entity as it is after the change, including what the configurator adjusted in response, or null when the change caused the entity to be removed.`}}})(e,i)]:[]}),Object.fromEntries(h.map(e=>{var t;return[e.fieldName,{type:new r(new s({name:(t=e.fieldName,`${t.charAt(0).toUpperCase()+t.slice(1)}Result`),description:`What ${e.fieldName} returns, read from the configuration after the change.`,fields:()=>Object.fromEntries(Object.entries(e.result).map(([e,t])=>[e,{type:"edge"===t.kind?(({target:e,list:t,nullable:n},i)=>{let s=t?new o(new r(i(e))):i(e);return n?s:new r(s)})(t,u):l(t.type),description:t.description}]))})),args:Object.fromEntries(Object.entries(e.args).map(([e,t])=>[e,{type:l(t.type),description:t.description}])),description:e.description}]})))})})({deletableTypes:K,writableTypes:U,childRecipes:z,replaceRecipes:Q,actionFields:F,objectTypes:H,anyDomainEntity:L(y),targetOutputType:P}),types:[...J.values(),...H.values()]}),ee=h(_);if(ee.length>0)throw Error(ee.map(e=>e.message).join(" "));return{sdl:d(_),fields:X,deletableTypes:K,writableFields:Object.fromEntries(U.map(({entityType:e,fields:t})=>[e,Object.fromEntries(t.map(({name:e,property:t})=>[e,t]))])),childRecipes:z,replaceRecipes:Q,fieldOptions:Object.fromEntries(S.flatMap(e=>{let t=w(x,e);return t?[[e,t.map(({options:e})=>e)]]:[]})),actions:Object.fromEntries(F.map(({fieldName:e,actionName:t})=>[e,t]))}};
@@ -0,0 +1,3 @@
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';
@@ -0,0 +1 @@
1
+ export{buildAssistantManifest}from"./build-assistant-manifest.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
@@ -1,9 +1,9 @@
1
+ import type { Localizable } from '@salsita-ai/common/utils';
1
2
  import { type StateUpdate } from '../components/updates.js';
2
- import type { Domain } from '../core/domain.js';
3
- import { type $DomainEntity, type DomainEntity } from '../core/model.js';
3
+ import type { AnyActionContext } from '../core/action.js';
4
+ import { type DomainEntity } from '../core/model.js';
4
5
  import type { DomainState } from '../core/state.js';
5
- import type { AssistantManifest } from './application-config.js';
6
- import { type AssistantRecipeContext } from './assistant-recipe-groups.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
@@ -12,19 +12,19 @@ type AnyDomainState = DomainState<DomainEntity<string>>;
12
12
  export declare const deleteEntityUpdateTag = "deleteEntity";
13
13
  /** Update tag of the entity modifications the assistant's `modify<Type>` mutations make. */
14
14
  export declare const modifyEntityUpdateTag = "modifyEntity";
15
- /** The domain of any application, as far as a mutation implementation reads it. */
16
- type AnyDomain = Domain<DomainEntity<string>, DomainEntity<string>, Record<string, $DomainEntity<DomainEntity<string>>>>;
17
15
  /** The arguments of one mutation field, as the GraphQL executor coerced them against the field's schema. */
18
16
  export type AssistantMutationArgs = Readonly<Record<string, unknown>>;
19
17
  /**
20
- * What a mutation implementation reads besides its arguments and the state it runs against. The
21
- * recipe context is what `addChild` and `replaceEntity` read their recipe groups and cook their recipes with, and what
22
- * `modify<Type>` reads the choices of a field with.
18
+ * What a mutation implementation reads besides its arguments and the state it runs against: the
19
+ * manifest, and the context the application's actions run with on that state. The built-ins and the
20
+ * custom mutations share it, so a built-in reads the domain, the component reader and the recipe
21
+ * cooker through `action.systems`, the way an action implementation does.
23
22
  */
24
- export interface AssistantMutationContext extends AssistantRecipeContext {
23
+ export interface AssistantMutationContext {
25
24
  readonly manifest: AssistantManifest;
26
- /** Validates a changed entity against its shape, and reads entities for the result of a field. */
27
- readonly domain: Pick<AnyDomain, 'validateEntity' | 'getEntity' | 'get$Entity'>;
25
+ readonly action: AnyActionContext;
26
+ /** Resolves a title in the current language, for recipe keys and option names. */
27
+ readonly resolveLocalizable: (message: Localizable) => string;
28
28
  }
29
29
  /** The working state a mutation field ran against and the state its applied updates produced. */
30
30
  export interface AssistantMutationStateChange {
@@ -56,9 +56,10 @@ export interface AssistantMutationDeclaration {
56
56
  readonly implementation: AssistantMutationImplementation;
57
57
  }
58
58
  /**
59
- * The declaration resolving a `Mutation` field: a built-in by its name, or the shared modify
60
- * implementation when the name is `modify` followed by an entity type the manifest declares writable
61
- * fields for. `undefined` when the configurator has no implementation for the field.
59
+ * The declaration resolving a `Mutation` field: a built-in by its name, the action a custom mutation
60
+ * of that name runs, or the shared modify implementation when the name is `modify` followed by an
61
+ * entity type the manifest declares writable fields for. `undefined` when the configurator has no
62
+ * implementation for the field.
62
63
  */
63
64
  export declare const findAssistantMutation: (fieldName: string, manifest: AssistantManifest) => AssistantMutationDeclaration | undefined;
64
65
  export {};
@@ -1 +1 @@
1
- import{z as e}from"zod";import{systemUpdateFactory as t}from"../components/updates.js";import{DomainEntityIdSchema as i}from"../core/model.js";import{findAssistantFieldOptions as r,readAssistantFieldOptions as n}from"./assistant-field-options.js";import{assistantAddedEntityIds as o,findAssistantRecipeGroups as a,prepareAssistantRecipeUpdates as s,readAssistantRecipeGroup as d}from"./assistant-recipe-groups.js";export const deleteEntityUpdateTag="deleteEntity";export const modifyEntityUpdateTag="modifyEntity";let l=e.string().regex(new RegExp(i.pattern),'An entity id is the type name, a dash and a number, e.g. "Root-1". Query the current entities and use an id they return.'),p=e.object({id:l}),h=e.object({id:l,delta:e.record(e.unknown())}),u="modify",f=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],y=e=>Array.isArray(e)?e.map(y):"object"!=typeof e||null===e||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,y(t)])),c=e.object({parentId:l,recipeGroupId:e.string(),recipeKey:e.string()}),g=e.object({entityId:l,recipeGroupId:e.string(),recipeKey:e.string()}),m=e=>e.map(e=>`"${e}"`).join(", "),$=[{name:"deleteEntity",implementation:(e,i,{manifest:r})=>{let{id:n}=p.parse(e),o=i.entities.find(e=>e.id===n);if(!o)throw Error(`Entity "${n}" does not exist, so it cannot be deleted. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);let a=r.deletableTypes??[];if(!a.includes(o.type))throw Error(`Entity "${n}" is a ${o.type}, which is not deletable. ${a.length>0?`Only entities of these types can be deleted: ${a.join(", ")}.`:"No entity type is deletable."} Delete an entity of a deletable type instead.`);return{updates:[t.EntityDeletion({entityId:o.id,updateTag:"deleteEntity"})],readResult:({previousState:e,state:t})=>{var i;let r;return[o.id,...(i=o.id,r=new Set(t.entities.map(e=>e.id)),e.entities.map(e=>e.id).filter(e=>e!==i&&!r.has(e)))]}}}},{name:"addChild",implementation:(e,t,i)=>{let{parentId:r,recipeGroupId:n,recipeKey:l}=c.parse(e),p=t.entities.find(e=>e.id===r);if(!p)throw Error(`Entity "${r}" does not exist, so nothing can be added to it. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);let h=a(i.manifest,"child",p.type),u=h.find(e=>e.groupId===n);if(!u)throw Error(`Entity "${r}" is a ${p.type}, which has no recipe group "${n}". ${h.length>0?`Its recipe groups are: ${m(h.map(({groupId:e})=>e))}.`:`Nothing can be added to a ${p.type}.`} Query "meta { childRecipes { groupId } }" on the entity you want to add to and use a groupId it returns.`);let f=d("child",u,p.id,t,i);if(!f)throw Error(`The recipe group "${n}" is not available on "${r}" right now, so nothing can be added from it. The configurator offers a group only in some states of the configuration. Query "meta { childRecipes { groupId } }" on "${r}" to see the groups it offers now.`);let y=f.recipes.find(e=>e.key===l);if(!y)throw Error(`The recipe group "${n}" on "${r}" has no recipe with the key "${l}". Recipes and their keys change with the configuration and with the language. List the recipes of the group again and use a key it returns.`);let g=s(y,f,p.id,t,i);return{updates:g,readResult:e=>o(g,p.id,e).map(t=>i.domain.get$Entity(t,e.state))}}},{name:"replaceEntity",implementation:(e,t,i)=>{let{entityId:r,recipeGroupId:n,recipeKey:l}=g.parse(e),p=t.entities.find(e=>e.id===r);if(!p)throw Error(`Entity "${r}" does not exist, so it cannot be replaced. It may have been deleted or replaced by an earlier operation or field; a replaced entity gets a new id. Query the current entities and use an id they return.`);let h=a(i.manifest,"replace",p.type),u=h.find(e=>e.groupId===n);if(!u)throw Error(`Entity "${r}" is a ${p.type}, which has no replace recipe group "${n}". ${h.length>0?`Its replace recipe groups are: ${m(h.map(({groupId:e})=>e))}.`:`A ${p.type} cannot be replaced.`} Query "meta { replaceRecipes { groupId } }" on the entity you want to replace and use a groupId it returns.`);let f=d("replace",u,p.id,t,i);if(!f)throw Error(`The recipe group "${n}" is not available on "${r}" right now, so it cannot be replaced from it. The configurator offers a group only in some states of the configuration. Query "meta { replaceRecipes { groupId } }" on "${r}" to see the groups it offers now.`);let y=f.recipes.find(e=>e.key===l);if(!y)throw Error(`The recipe group "${n}" on "${r}" has no recipe with the key "${l}". Recipes and their keys change with the configuration and with the language. List the recipes of the group again and use a key it returns.`);let c=s(y,f,p.id,t,i);return{updates:c,readResult:e=>o(c,p.id,e).map(t=>i.domain.get$Entity(t,e.state))}}}];export const findAssistantMutation=(e,i)=>{let o,a,s=$.find(t=>t.name===e);if(s||!e.startsWith(u))return s;let d=e.slice(u.length),l=f(i.writableFields??{},d);return l&&(o=`${u}${d}`,a=Object.keys(l).join(", "),{name:o,implementation:(e,i,s)=>{let{manifest:p,domain:c}=s,{id:g,delta:m}=h.parse(e),$=i.entities.find(e=>e.id===g);if(!$)throw Error(`Entity "${g}" does not exist, so it cannot be modified. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);if($.type!==d)throw Error(`Entity "${g}" is a ${$.type}, but ${o} modifies only ${d} entities. ${f(p.writableFields??{},$.type)?`Use ${u}${$.type} for it instead.`:`${$.type} has no writable fields, so it cannot be modified; pass the id of a ${d}.`}`);let w=Object.entries(m).flatMap(([e,t])=>{let i=f(l,e);return void 0===i?[]:[{field:e,property:i,value:y(t)}]}),b=Object.fromEntries(w.map(({property:e,value:t})=>[e,t]));if(0===Object.keys(b).length)throw Error(`The delta of ${o} is empty, so there is nothing to change on "${g}". Set at least one of its fields: ${a}.`);let E=c.validateEntity({...$,...b});if(!E.success){let e=w.filter(({field:e,property:t})=>e!==t).map(({field:e,property:t})=>`${e} is stored as ${t}`);throw Error(`The delta would make "${g}" an invalid ${d}: ${E.errors.join("; ")}. ${e.length>0?`The messages name stored properties: ${e.join(", ")}. `:""}Nothing was changed. Send values that fit the types and the allowed values the schema describes for these fields.`)}let j=r(p,d);for(let{field:e,value:t}of w){let r=j.find(t=>t.field===e);if(!r?.validate||null===t)continue;let o=n(r,$.id,i,s);if(o&&!o.some(e=>e.value===t))throw Error(`${JSON.stringify(t)} is not a value "${e}" of "${g}" can take right now. ${o.length>0?`The configurator offers these values: ${o.map(e=>JSON.stringify(e.value)).join(", ")}.`:"The configurator offers no value for it in this state."} Nothing was changed. Send one of the offered values; "meta { ${r.edgeName} }" on the entity lists them with their names. When the values depend on another field of this delta, change that field in an earlier mutation field of the same operation.`)}return{updates:[t.DomainEntityModification({entityId:$.id,stateDelta:b,updateTag:"modifyEntity"})],readResult:({state:e})=>c.getEntity($.id,e)?c.get$Entity($.id,e):null}}})};
1
+ import{z as e}from"zod";import{systemUpdateFactory as t}from"../components/updates.js";import{DomainEntityIdSchema as i}from"../core/model.js";import{findAssistantFieldOptions as n,readAssistantFieldOptions as r}from"./assistant-field-options.js";import{assistantAddedEntityIds as o,findAssistantRecipeGroups as a,prepareAssistantRecipeUpdates as s,readAssistantRecipeGroup as d}from"./assistant-recipe-groups.js";export const deleteEntityUpdateTag="deleteEntity";export const modifyEntityUpdateTag="modifyEntity";let l=({action:e,resolveLocalizable:t})=>({componentReader:e.systems.componentReader,recipeCooker:e.systems.recipeCooker,resolveLocalizable:t}),p=e.string().regex(new RegExp(i.pattern),'An entity id is the type name, a dash and a number, e.g. "Root-1". Query the current entities and use an id they return.'),h=e.object({id:p}),c=e.object({id:p,delta:e.record(e.unknown())}),y="modify",u=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],f=e=>Array.isArray(e)?e.map(f):"object"!=typeof e||null===e||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,f(t)])),m=e.object({parentId:p,recipeGroupId:e.string(),recipeKey:e.string()}),g=e.object({entityId:p,recipeGroupId:e.string(),recipeKey:e.string()}),$=e=>e.map(e=>`"${e}"`).join(", "),w=[{name:"deleteEntity",implementation:(e,i,{manifest:n})=>{let{id:r}=h.parse(e),o=i.entities.find(e=>e.id===r);if(!o)throw Error(`Entity "${r}" does not exist, so it cannot be deleted. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);let a=n.deletableTypes??[];if(!a.includes(o.type))throw Error(`Entity "${r}" is a ${o.type}, which is not deletable. ${a.length>0?`Only entities of these types can be deleted: ${a.join(", ")}.`:"No entity type is deletable."} Delete an entity of a deletable type instead.`);return{updates:[t.EntityDeletion({entityId:o.id,updateTag:"deleteEntity"})],readResult:({previousState:e,state:t})=>{var i;let n;return[o.id,...(i=o.id,n=new Set(t.entities.map(e=>e.id)),e.entities.map(e=>e.id).filter(e=>e!==i&&!n.has(e)))]}}}},{name:"addChild",implementation:(e,t,i)=>{let{parentId:n,recipeGroupId:r,recipeKey:p}=m.parse(e),h=t.entities.find(e=>e.id===n);if(!h)throw Error(`Entity "${n}" does not exist, so nothing can be added to it. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);let c=a(i.manifest,"child",h.type),y=c.find(e=>e.groupId===r);if(!y)throw Error(`Entity "${n}" is a ${h.type}, which has no recipe group "${r}". ${c.length>0?`Its recipe groups are: ${$(c.map(({groupId:e})=>e))}.`:`Nothing can be added to a ${h.type}.`} Query "meta { childRecipes { groupId } }" on the entity you want to add to and use a groupId it returns.`);let u=l(i),f=d("child",y,h.id,t,u);if(!f)throw Error(`The recipe group "${r}" is not available on "${n}" right now, so nothing can be added from it. The configurator offers a group only in some states of the configuration. Query "meta { childRecipes { groupId } }" on "${n}" to see the groups it offers now.`);let g=f.recipes.find(e=>e.key===p);if(!g)throw Error(`The recipe group "${r}" on "${n}" has no recipe with the key "${p}". Recipes and their keys change with the configuration and with the language. List the recipes of the group again and use a key it returns.`);let w=s(g,f,h.id,t,u);return{updates:w,readResult:e=>o(w,h.id,e).map(t=>i.action.systems.domain.get$Entity(t,e.state))}}},{name:"replaceEntity",implementation:(e,t,i)=>{let{entityId:n,recipeGroupId:r,recipeKey:p}=g.parse(e),h=t.entities.find(e=>e.id===n);if(!h)throw Error(`Entity "${n}" does not exist, so it cannot be replaced. It may have been deleted or replaced by an earlier operation or field; a replaced entity gets a new id. Query the current entities and use an id they return.`);let c=a(i.manifest,"replace",h.type),y=c.find(e=>e.groupId===r);if(!y)throw Error(`Entity "${n}" is a ${h.type}, which has no replace recipe group "${r}". ${c.length>0?`Its replace recipe groups are: ${$(c.map(({groupId:e})=>e))}.`:`A ${h.type} cannot be replaced.`} Query "meta { replaceRecipes { groupId } }" on the entity you want to replace and use a groupId it returns.`);let u=l(i),f=d("replace",y,h.id,t,u);if(!f)throw Error(`The recipe group "${r}" is not available on "${n}" right now, so it cannot be replaced from it. The configurator offers a group only in some states of the configuration. Query "meta { replaceRecipes { groupId } }" on "${n}" to see the groups it offers now.`);let m=f.recipes.find(e=>e.key===p);if(!m)throw Error(`The recipe group "${r}" on "${n}" has no recipe with the key "${p}". Recipes and their keys change with the configuration and with the language. List the recipes of the group again and use a key it returns.`);let w=s(m,f,h.id,t,u);return{updates:w,readResult:e=>o(w,h.id,e).map(t=>i.action.systems.domain.get$Entity(t,e.state))}}}];export const findAssistantMutation=(e,i)=>{let o,a,s=w.find(t=>t.name===e),d=u(i.actions??{},e);if(s)return s;if(void 0!==d)return{name:e,implementation:(e,t,{action:i})=>i.systems.actionSystem.prepareAction(d,f(e),t)};if(!e.startsWith(y))return;let p=e.slice(y.length),h=u(i.writableFields??{},p);return h&&(o=`${y}${p}`,a=Object.keys(h).join(", "),{name:o,implementation:(e,i,s)=>{let{manifest:d}=s,{domain:m}=s.action.systems,{id:g,delta:$}=c.parse(e),w=i.entities.find(e=>e.id===g);if(!w)throw Error(`Entity "${g}" does not exist, so it cannot be modified. It may have been deleted by an earlier operation or field. Query the current entities and use an id they return.`);if(w.type!==p)throw Error(`Entity "${g}" is a ${w.type}, but ${o} modifies only ${p} entities. ${u(d.writableFields??{},w.type)?`Use ${y}${w.type} for it instead.`:`${w.type} has no writable fields, so it cannot be modified; pass the id of a ${p}.`}`);let b=Object.entries($).flatMap(([e,t])=>{let i=u(h,e);return void 0===i?[]:[{field:e,property:i,value:f(t)}]}),E=Object.fromEntries(b.map(({property:e,value:t})=>[e,t]));if(0===Object.keys(E).length)throw Error(`The delta of ${o} is empty, so there is nothing to change on "${g}". Set at least one of its fields: ${a}.`);let j=m.validateEntity({...w,...E});if(!j.success){let e=b.filter(({field:e,property:t})=>e!==t).map(({field:e,property:t})=>`${e} is stored as ${t}`);throw Error(`The delta would make "${g}" an invalid ${p}: ${j.errors.join("; ")}. ${e.length>0?`The messages name stored properties: ${e.join(", ")}. `:""}Nothing was changed. Send values that fit the types and the allowed values the schema describes for these fields.`)}let v=n(d,p);for(let{field:e,value:t}of b){let n=v.find(t=>t.field===e);if(!n?.validate||null===t)continue;let o=r(n,w.id,i,l(s));if(o&&!o.some(e=>e.value===t))throw Error(`${JSON.stringify(t)} is not a value "${e}" of "${g}" can take right now. ${o.length>0?`The configurator offers these values: ${o.map(e=>JSON.stringify(e.value)).join(", ")}.`:"The configurator offers no value for it in this state."} Nothing was changed. Send one of the offered values; "meta { ${n.edgeName} }" on the entity lists them with their names. When the values depend on another field of this delta, change that field in an earlier mutation field of the same operation.`)}return{updates:[t.DomainEntityModification({entityId:w.id,stateDelta:E,updateTag:"modifyEntity"})],readResult:({state:e})=>m.getEntity(w.id,e)?m.get$Entity(w.id,e):null}}})};
@@ -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>>;
@@ -5,7 +5,8 @@ import type { FinalizeTaskResource } from '@salsita-ai/contracts/webhook';
5
5
  import type { DomainComponentOptic } from '../components/domain-component-optic.js';
6
6
  import type { $DomainEntity, DomainEntity, DomainFactory, EnumLike, ProductPreset, SchemaOfObject, SystemComponentTypeConstraint } from '../core/index.js';
7
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';
8
+ import type { AclConfig, ApplicationConfig, DataSpec, DefaultEnvs, ImportedTransformer, ResourcesConfig, SpecTransformer, UserInterfaceConfig } from './application-config.js';
9
+ import type { AssistantResolvedManifest } from './assistant/index.js';
9
10
  import type { ElementRegistration } from './element-registration.js';
10
11
  import type { HandlerRegistration } from './handler-registration.js';
11
12
  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> {
@@ -41,7 +42,7 @@ interface ConfiguratorBuilderContext<ENTITIES extends DomainEntity<string> = nev
41
42
  readonly scope: string;
42
43
  }>>;
43
44
  publishedDataHash?: string;
44
- assistant?: AssistantManifest | null;
45
+ assistant?: AssistantResolvedManifest | null;
45
46
  theme?: ThemeOptions;
46
47
  tagName?: string;
47
48
  handlers?: ReadonlyArray<HandlerRegistration<any, any>>;
@@ -61,7 +62,7 @@ export declare class ConfiguratorBuilder<ENTITIES extends DomainEntity<string> =
61
62
  readonly scope: string;
62
63
  }>>): 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
64
  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>;
65
+ 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
66
  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
67
  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
68
  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>;
@@ -1,4 +1,4 @@
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 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';
@@ -28,3 +28,4 @@ export { createMapPublishedRevisionDataHandler, createMapPublishedRevisionDataHa
28
28
  export { createMapPublishedChunkedDataHandler, createMapPublishedChunkedDataHandlerFactory, isMapPublishedChunkedDataHandler, type CreateMapPublishedChunkedDataHandler, type MapPublishedChunkedDataHandlerProps, type MapPublishedChunkedDataResult, type TypedCreateMapPublishedChunkedDataHandler, } from './published-data/MapPublishedChunkedDataHandler.js';
29
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
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';
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}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";export*from"./assistant/index.js";
@@ -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>;
@@ -0,0 +1,67 @@
1
+ import type { ExtendedJsonSchema } from '@salsita-ai/common/utils';
2
+ import type { StateUpdate, UpdateFactory } from '../components/updates.js';
3
+ import type { DomainContextSystems } from '../domain-context/domain-context-systems.js';
4
+ import type { IdSequence } from '../domain-context/store-system/next-domain-entity-id.js';
5
+ import type { ExpressionContext } from './expression.js';
6
+ import type { $DomainEntity, DomainEntity } from './model.js';
7
+ import type { DomainState } from './state.js';
8
+ /**
9
+ * The parameter and result types of the actions an application declares under `actions`, keyed by
10
+ * action name. Codegen derives it from the spec; `ActionSystem.prepareAction` and the
11
+ * `implementActions` factory are typed against it.
12
+ */
13
+ export type ActionTypes = Record<string, {
14
+ readonly params: unknown;
15
+ readonly result: unknown;
16
+ }>;
17
+ /**
18
+ * One action as the spec declares it, carried into the domain factory by the generated code:
19
+ * `params` is the AJV-ready object schema of its parameters, which `prepareAction` validates the
20
+ * arguments against before the implementation runs, and `description` says what the action does.
21
+ */
22
+ export interface ActionDefinition {
23
+ readonly name: string;
24
+ readonly description?: string;
25
+ readonly params: ExtendedJsonSchema;
26
+ }
27
+ /** The declared actions of an application by name; empty when the spec declares none. */
28
+ export type ActionDefinitions = Readonly<Record<string, ActionDefinition>>;
29
+ /** The working state an action ran against and the state its applied updates produced. */
30
+ export interface ActionStateChange<ENTITIES extends DomainEntity<string>> {
31
+ readonly previousState: DomainState<ENTITIES>;
32
+ readonly state: DomainState<ENTITIES>;
33
+ }
34
+ /**
35
+ * What one action prepares: the updates it wants applied, computed from the state it ran against,
36
+ * and how to read its result from the change they made, including whatever the transformers added.
37
+ * Nothing is staged or committed; the caller decides what to do with the updates.
38
+ */
39
+ export interface PreparedAction<ENTITIES extends DomainEntity<string>, RESULT> {
40
+ readonly updates: ReadonlyArray<StateUpdate<ENTITIES, ENTITIES>>;
41
+ readonly readResult: (change: ActionStateChange<ENTITIES>) => RESULT;
42
+ }
43
+ /**
44
+ * What an action implementation reads besides its parameters and the state: the expression context
45
+ * (domain, data, projections), the domain systems, an id sequence for entities it creates, and the
46
+ * update factory typed for the application's entities.
47
+ */
48
+ export interface ActionContext<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> {
49
+ readonly expressionContext: ExpressionContext<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
50
+ readonly systems: DomainContextSystems<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>;
51
+ readonly getIdSequence: () => IdSequence<ENTITIES>;
52
+ readonly updates: UpdateFactory<ENTITIES>;
53
+ }
54
+ export type AnyActionContext = ActionContext<any, any, any, any, any, any, any, any, any, any>;
55
+ /**
56
+ * The implementation of one declared action. It must not change anything itself; a thrown error
57
+ * fails the call, and its message reaches whoever asked for the action, so it says what went wrong
58
+ * and how to fix the request.
59
+ */
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
+ 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/`. */
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
+ 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
+ };
66
+ /** The action implementations of an application with their types erased, as the runtime spec slice holds them. */
67
+ export type AnyActionImplementations = Readonly<Record<string, AnyActionImplementation>>;
@@ -0,0 +1 @@
1
+ export{};
@@ -1,4 +1,5 @@
1
1
  import type { ExtendedJsonSchema } from '@salsita-ai/common/utils';
2
+ import type { ActionDefinitions, AnyActionImplementations } from './action.js';
2
3
  import type { Expression } from './expression.js';
3
4
  import type { MigrateFunction } from './migrations.js';
4
5
  import type { $DomainEntity, DomainEntity, EntityByType } from './model.js';
@@ -25,6 +26,9 @@ export interface DomainFactoryContext<ENTITIES extends DomainEntity<string>, ALL
25
26
  frontendData: SchemaOfObject<FRONTEND_DATA>;
26
27
  backendData: ExtendedJsonSchema | undefined;
27
28
  isAdminDomain: boolean;
29
+ /** The actions the spec declares, and their implementations from `src/actions/`; both empty for a domain without actions. */
30
+ actions: ActionDefinitions;
31
+ actionImplementations: AnyActionImplementations;
28
32
  }
29
33
  export type AnyDomainFactory = DomainFactory<any, any, any, any, any, any>;
30
34
  export declare class DomainFactory<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>> {
@@ -1,4 +1,5 @@
1
1
  export type { EnhancedJsonObjectSchemaType, EnhancedJsonSchemaType, JsonSchemaType, MemberImport, } from './enhanced-json-schema.js';
2
+ export type { ActionContext, ActionDefinition, ActionDefinitions, ActionImplementation, ActionImplementations, ActionStateChange, ActionTypes, AnyActionContext, AnyActionImplementation, AnyActionImplementations, PreparedAction, } from './action.js';
2
3
  export { extendedSchemaValidator, getExtendedSchemaValidator } from './json-schema.js';
3
4
  export { _unsafeBuildDomainEntityId, domainEntityTypeFromId, createVirtualEntityId, isDomainEntityId, isVirtualEntityId, VirtualEntityIdSchema, isEqualEntityTypeAndId, parseDomainEntityId, DomainEntityIdSchema, DomainEntitySchema, $DomainEntitySchema, } from './model.js';
4
5
  export type { $DomainEntity, DomainEntity, VirtualEntityId, DomainEntityId, EntityIdSchema, EntityByType, EntityId, } from './model.js';
@@ -1,4 +1,5 @@
1
1
  import { type ExtendedJsonSchema } from '@salsita-ai/common/utils';
2
+ import type { ActionDefinition, AnyActionImplementations } from './core/action.js';
2
3
  import { type AliasMap, type ExpandAlias, type TypeOrAlias } from './core/alias.js';
3
4
  import type { AnonymousExpression } from './core/expression.js';
4
5
  import { DomainFactory } from './core/index.js';
@@ -24,10 +25,16 @@ export declare class DomainBuilder<ENTITIES extends DomainEntity<string>, ALLOWE
24
25
  private readonly backendData;
25
26
  private readonly migrate;
26
27
  private readonly isAdminDomain;
28
+ private readonly actions;
29
+ private readonly actionImplementations;
27
30
  private constructor();
28
31
  static from<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, ALIASES extends Readonly<Record<string, ENTITIES>>>(entities: EntityReflections<ENTITIES>, aliasMap: AliasMap<ALIASES>, $entityReflections: $EntityReflections<ENTITIES>, allowedRootEntityTypes: ReadonlyArray<ALLOWED_ROOT_ENTITIES['type']>, modelVersion: number, publishedData: SchemaOfObject<PUBLISHED_DATA>, sessionData: SchemaOfObject<SESSION_DATA>, frontendData: SchemaOfObject<FRONTEND_DATA>, backendData: ExtendedJsonSchema | undefined, isAdminDomain: boolean): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
29
32
  withMigrate(migration: MigrateFunction<ENTITIES>): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
30
33
  withExpressions(implementation: AliasedExpressions<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES>): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
34
+ /** Declares the actions of the domain, as the generated `domain-spec.ts` reads them from the spec's `actions` section. */
35
+ withActions(actions: readonly ActionDefinition[]): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
36
+ /** Adds the implementations of the declared actions, as the generated barrel merges them from `src/actions/`. */
37
+ withActionImplementations(implementations: AnyActionImplementations): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
31
38
  build: () => DomainFactory<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
32
39
  }
33
40
  export {};
@@ -1 +1 @@
1
- import{expandAlias as i}from"./core/alias.js";import{DomainFactory as t}from"./core/index.js";import{MigrateFunctionBuilder as e}from"./core/migrations.js";import{withProfilerLabel as s}from"./utils/profiler-label.js";export class DomainBuilder{entities;aliasMap;$entityReflections;allowedRootEntityTypes;implemented;modelVersion;publishedData;sessionData;frontendData;backendData;migrate;isAdminDomain;constructor(i,t,e,s,a,n,o,l,r,h,d,m){this.entities=i,this.aliasMap=t,this.$entityReflections=e,this.allowedRootEntityTypes=s,this.implemented=a,this.modelVersion=n,this.publishedData=o,this.sessionData=l,this.frontendData=r,this.backendData=h,this.migrate=d,this.isAdminDomain=m}static from(i,t,s,a,n,o,l,r,h,d){let m=e.fromVersions({1:i}).to(1).using({}).build();return new DomainBuilder(i,t,s,a,{},n,o,l,r,h,m,d)}withMigrate(i){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,i,this.isAdminDomain)}withExpressions(t){let e={...this.implemented};return Object.entries(t).forEach(([t,a])=>{i(this.aliasMap,t).forEach(i=>{let n={...e[i]};e[i]=n,Object.entries(a).forEach(([e,a])=>{let o=n[e];if(o)throw Error(`Duplicate expression ${i}.${e}: The expression is defined on both ${t} and ${o.origin.typeOrAlias}, which would lead to ambiguous usage. Please ensure that expressions are only defined once.`);n[e]={...a,evaluate:s(`${i}_${e}`,a.evaluate),origin:{name:e,typeOrAlias:t}}})})}),new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,e,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain)}build=()=>{let i=this.implemented,s=this.migrate??e.fromVersions({1:this.entities}).to(1).using({}).build();return new t({aliasMap:this.aliasMap,entityReflections:this.entities,$entityReflections:this.$entityReflections,expressions:i,allowedRootEntityTypes:this.allowedRootEntityTypes,modelVersion:this.modelVersion,migrate:s,publishedData:this.publishedData,sessionData:this.sessionData,frontendData:this.frontendData,backendData:this.backendData,isAdminDomain:this.isAdminDomain})}}
1
+ import{expandAlias as t}from"./core/alias.js";import{DomainFactory as i}from"./core/index.js";import{MigrateFunctionBuilder as e}from"./core/migrations.js";import{withProfilerLabel as s}from"./utils/profiler-label.js";export class DomainBuilder{entities;aliasMap;$entityReflections;allowedRootEntityTypes;implemented;modelVersion;publishedData;sessionData;frontendData;backendData;migrate;isAdminDomain;actions;actionImplementations;constructor(t,i,e,s,a,n,o,h,l,m,r,d,p,c){this.entities=t,this.aliasMap=i,this.$entityReflections=e,this.allowedRootEntityTypes=s,this.implemented=a,this.modelVersion=n,this.publishedData=o,this.sessionData=h,this.frontendData=l,this.backendData=m,this.migrate=r,this.isAdminDomain=d,this.actions=p,this.actionImplementations=c}static from(t,i,s,a,n,o,h,l,m,r){let d=e.fromVersions({1:t}).to(1).using({}).build();return new DomainBuilder(t,i,s,a,{},n,o,h,l,m,d,r,{},{})}withMigrate(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,t,this.isAdminDomain,this.actions,this.actionImplementations)}withExpressions(i){let e={...this.implemented};return Object.entries(i).forEach(([i,a])=>{t(this.aliasMap,i).forEach(t=>{let n={...e[t]};e[t]=n,Object.entries(a).forEach(([e,a])=>{let o=n[e];if(o)throw Error(`Duplicate expression ${t}.${e}: The expression is defined on both ${i} and ${o.origin.typeOrAlias}, which would lead to ambiguous usage. Please ensure that expressions are only defined once.`);n[e]={...a,evaluate:s(`${t}_${e}`,a.evaluate),origin:{name:e,typeOrAlias:i}}})})}),new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,e,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,this.actions,this.actionImplementations)}withActions(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,Object.fromEntries(t.map(t=>[t.name,t])),this.actionImplementations)}withActionImplementations(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,this.actions,{...this.actionImplementations,...t})}build=()=>{let t=this.implemented,s=this.migrate??e.fromVersions({1:this.entities}).to(1).using({}).build();return new i({aliasMap:this.aliasMap,entityReflections:this.entities,$entityReflections:this.$entityReflections,expressions:t,allowedRootEntityTypes:this.allowedRootEntityTypes,modelVersion:this.modelVersion,migrate:s,publishedData:this.publishedData,sessionData:this.sessionData,frontendData:this.frontendData,backendData:this.backendData,isAdminDomain:this.isAdminDomain,actions:this.actions,actionImplementations:this.actionImplementations})}}