@salsita-ai/sdk 0.50.0-develop.2331d4a6b7 → 0.50.0-develop.2be7811d51
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.
- package/README.md +19 -11
- package/dist/application-spec/errors/diagnostic-codes.d.ts +6 -0
- package/dist/application-spec/errors/diagnostic-codes.js +1 -1
- package/dist/application-spec/errors/diagnostic-messages.d.ts +6 -0
- package/dist/application-spec/errors/diagnostic-messages.js +1 -1
- package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
- package/dist/application-spec/generate-application/code/project-scaffolding.js +2 -2
- package/dist/application-spec/generate-application/code/templates/application-types.js +6 -6
- package/dist/application-spec/generate-application/code/templates/configurator-domain-code.d.ts +1 -0
- package/dist/application-spec/generate-application/code/templates/configurator-domain-code.js +11 -8
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.d.ts +3 -1
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.js +70 -66
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-phx-globals.js +3 -0
- package/dist/application-spec/generate-application/code/templates/domain-spec.js +5 -5
- package/dist/application-spec/generate-application/code/templates/domain.js +2 -2
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.d.ts +11 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.js +8 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/index.d.ts +1 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/globals.js +1 -0
- package/dist/application-spec/generate-application/code/templates/index.d.ts +1 -0
- package/dist/application-spec/generate-application/code/templates/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/agents-md.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-cli-skill.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-create-configurator-skill.js +3 -1
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-feedback-skill.js +39 -16
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js +5 -3
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.d.ts +1 -0
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-variants-skill.js +6 -0
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +15 -3
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +3 -3
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.d.ts +2 -0
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/sections/actions-runtime.d.ts +14 -0
- package/dist/application-spec/generate-application/runtime/sections/actions-runtime.js +1 -0
- package/dist/application-spec/generate-application/runtime/sections/index.d.ts +1 -0
- package/dist/application-spec/generate-application/runtime/sections/index.js +1 -1
- package/dist/application-spec/parse-application-files/categorize/categorize-files.d.ts +3 -1
- package/dist/application-spec/parse-application-files/categorize/categorize-files.js +1 -1
- package/dist/application-spec/parse-application-files/merge/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/merge/index.js +1 -1
- package/dist/application-spec/parse-application-files/merge/merged-actions.d.ts +11 -0
- package/dist/application-spec/parse-application-files/merge/merged-actions.js +1 -0
- package/dist/application-spec/parse-application-files/merge/merged-spec.d.ts +2 -0
- package/dist/application-spec/parse-application-files/merge/merged-spec.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/raw-spec/index.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-actions.d.ts +18 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-actions.js +1 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.d.ts +14 -2
- package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.d.ts +2 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.js +1 -1
- package/dist/application-spec/parse-application-files/resolve/resolve-import-modules.js +1 -1
- package/dist/application-spec/parse-application-files/spec/application/application-spec.js +1 -1
- package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.d.ts +4 -2
- package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.js +1 -1
- package/dist/application-spec/parse-application-files/spec/common/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/spec/common/index.js +1 -1
- package/dist/application-spec/parse-application-files/spec/common/schema-ref-resolver.d.ts +23 -0
- package/dist/application-spec/parse-application-files/spec/common/schema-ref-resolver.js +1 -0
- package/dist/application-spec/parse-application-files/spec/model/names/action-name.d.ts +10 -0
- package/dist/application-spec/parse-application-files/spec/model/names/action-name.js +1 -0
- package/dist/application-spec/parse-application-files/spec/model/names/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/spec/model/names/index.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/actions.d.ts +35 -0
- package/dist/application-spec/parse-application-files/spec/sections/actions.js +1 -0
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.d.ts +3 -14
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +12 -3
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant.d.ts +5 -3
- package/dist/application-spec/parse-application-files/spec/sections/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/spec/sections/index.js +1 -1
- package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +146 -13
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/change-recorder.d.ts +85 -0
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/change-recorder.js +1 -0
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +8 -3
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.d.ts +4 -0
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +16 -1
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.d.ts +9 -0
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/side-effects.js +1 -0
- package/dist/configurator/application-runtime/extensions/systems/index.d.ts +1 -1
- package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.d.ts +2 -0
- package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.js +1 -1
- package/dist/configurator/common/frontend-analytics.d.ts +21 -21
- package/dist/configurator/index.d.ts +0 -1
- package/dist/configurator/index.js +1 -1
- package/dist/configurator/pages/LoadedConfiguratorDetailPage.js +1 -1
- package/dist/configurator/scene/scene-analytics/scene-analytics.d.ts +2 -2
- package/dist/configurator/ui/assistant/AssistantChips.d.ts +11 -0
- package/dist/configurator/ui/assistant/AssistantChips.js +1 -0
- package/dist/configurator/ui/assistant/AssistantComposer.d.ts +6 -0
- package/dist/configurator/ui/assistant/AssistantComposer.js +1 -0
- package/dist/configurator/ui/assistant/AssistantMarkdown.d.ts +7 -0
- package/dist/configurator/ui/assistant/AssistantMarkdown.js +1 -0
- package/dist/configurator/ui/assistant/AssistantPanel.d.ts +11 -0
- package/dist/configurator/ui/assistant/AssistantPanel.js +1 -0
- package/dist/configurator/ui/assistant/AssistantThread.d.ts +6 -0
- package/dist/configurator/ui/assistant/AssistantThread.js +1 -0
- package/dist/configurator/ui/assistant/assistant-failure.d.ts +18 -0
- package/dist/configurator/ui/assistant/assistant-failure.js +1 -0
- package/dist/configurator/ui/assistant/index.d.ts +2 -0
- package/dist/configurator/ui/assistant/index.js +1 -0
- package/dist/configurator/ui/assistant/streamed-markdown.d.ts +6 -0
- package/dist/configurator/ui/assistant/streamed-markdown.js +2 -0
- package/dist/configurator/ui/assistant/theme.d.ts +2 -0
- package/dist/configurator/ui/assistant/theme.js +1 -0
- package/dist/configurator/ui/assistant/thread-items.d.ts +37 -0
- package/dist/configurator/ui/assistant/thread-items.js +1 -0
- package/dist/configurator/ui/assistant/tool-chip.d.ts +37 -0
- package/dist/configurator/ui/assistant/tool-chip.js +1 -0
- package/dist/configurator/ui/assistant/use-follow-stream.d.ts +17 -0
- package/dist/configurator/ui/assistant/use-follow-stream.js +1 -0
- package/dist/configurator/ui/assistant/use-is-assistant-panel-open.d.ts +5 -0
- package/dist/configurator/ui/assistant/use-is-assistant-panel-open.js +1 -0
- package/dist/configurator/ui/configurator-layout/universal/DesktopLayout.js +5 -5
- package/dist/configurator/ui/configurator-layout/universal/MobileLayout.d.ts +2 -0
- package/dist/configurator/ui/configurator-layout/universal/MobileLayout.js +4 -4
- package/dist/configurator/ui/legacy/mobile-controls/MobileControls.d.ts +1 -1
- package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.d.ts +10 -0
- package/dist/configurator/ui/phoenix-layout-elements/AssistantToolbarButton.js +1 -0
- package/dist/configurator/ui/phoenix-layout-elements/index.d.ts +1 -0
- package/dist/configurator/ui/phoenix-layout-elements/index.js +1 -1
- package/dist/docs/index.json +12 -2
- package/dist/docs/layouts/toolbar.mdx +6 -0
- package/dist/docs/other-features/domain-actions.mdx +418 -0
- package/dist/docs/other-features/side-effects.mdx +26 -0
- package/dist/docs/phoenix/admin.mdx +2 -2
- package/dist/docs/phoenix/best-practices.mdx +1 -0
- package/dist/docs/phoenix/finalization.mdx +1 -1
- package/dist/docs/phoenix/integration/headless-mode-external.mdx +5 -5
- package/dist/docs/phoenix/integration/widget-mode-external.mdx +5 -5
- package/dist/docs/phoenix/phoenix-cli.mdx +135 -18
- package/dist/docs/phoenix/project-structure.mdx +7 -3
- package/dist/docs/phoenix/sdk-builder-workflow.mdx +3 -2
- package/dist/domain/actions/action-factory.d.ts +10 -0
- package/dist/domain/actions/action-factory.js +1 -0
- package/dist/domain/actions/prepare-action-implementations.d.ts +15 -0
- package/dist/domain/actions/prepare-action-implementations.js +5 -0
- package/dist/domain/application/application-config.d.ts +3 -1
- package/dist/domain/application/assistant-mutations.d.ts +15 -14
- package/dist/domain/application/assistant-mutations.js +1 -1
- package/dist/domain/components/updates.d.ts +16 -0
- package/dist/domain/core/action.d.ts +67 -0
- package/dist/domain/core/action.js +1 -0
- package/dist/domain/core/domain-factory.d.ts +4 -0
- package/dist/domain/core/index.d.ts +1 -0
- package/dist/domain/domain-builder.d.ts +7 -0
- package/dist/domain/domain-builder.js +1 -1
- package/dist/domain/domain-context/action-system/action-system.d.ts +40 -0
- package/dist/domain/domain-context/action-system/action-system.js +1 -0
- package/dist/domain/domain-context/domain-context-systems.d.ts +5 -2
- package/dist/domain/domain-context/index.d.ts +2 -1
- package/dist/domain/domain-context/index.js +1 -1
- package/dist/domain/domain-context/store-system/store-system.js +1 -1
- package/dist/domain/domain-runtime/domain-context/domain-context.js +1 -1
- package/dist/domain/domain-runtime/domain-context/selectors.d.ts +4 -0
- package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
- package/dist/domain/domain-runtime/domain-runtime.d.ts +12 -0
- package/dist/domain/domain-runtime/spec/initialize.js +1 -1
- package/dist/domain/domain-runtime/spec/types.d.ts +15 -1
- package/dist/domain/index.d.ts +2 -0
- package/dist/domain/index.js +1 -1
- package/dist/domain/mocks/create-mock-domain-runtime.d.ts +6 -0
- package/dist/domain/system-components/phoenix-layout-elements/assistant-toolbar-button.d.ts +44 -0
- package/dist/domain/system-components/phoenix-layout-elements/assistant-toolbar-button.js +1 -0
- package/dist/domain/system-components/phoenix-layout-elements/index.d.ts +1 -0
- package/dist/domain/system-components/phoenix-layout-elements/index.js +1 -1
- package/dist/domain/system-components/phoenix-layout-elements/phoenix-layout-element.d.ts +2 -1
- package/dist/domain/system-components/phoenix-layout-elements/phoenix-layout-element.js +1 -1
- package/dist/editor/Editor.js +1 -1
- package/dist/editor/domain-editors/DomainSpecContext.js +1 -1
- package/dist/editor/domain-editors/apply-spec-update.js +1 -1
- package/dist/editor/domain-editors/use-implementation-files.d.ts +7 -3
- package/dist/editor/domain-editors/use-implementation-files.js +1 -1
- package/dist/editor/graphql/GraphQLPanel.js +1 -1
- package/dist/editor/variants/VariantAnswerFooter.d.ts +17 -0
- package/dist/editor/variants/VariantAnswerFooter.js +1 -0
- package/dist/editor/variants/VariantPreviewHandler.d.ts +6 -0
- package/dist/editor/variants/VariantPreviewHandler.js +1 -0
- package/dist/editor/variants/variant-preview-styles.d.ts +49 -0
- package/dist/editor/variants/variant-preview-styles.js +1 -0
- package/dist/i18n/locales/cs/messages.js +1 -1
- package/dist/i18n/locales/da/messages.js +1 -1
- package/dist/i18n/locales/de/messages.js +1 -1
- package/dist/i18n/locales/de-AT/messages.js +1 -1
- package/dist/i18n/locales/en/messages.js +1 -1
- package/dist/i18n/locales/en-AU/messages.js +1 -1
- package/dist/i18n/locales/en-GB/messages.js +1 -1
- package/dist/i18n/locales/es/messages.js +1 -1
- package/dist/i18n/locales/fr/messages.js +1 -1
- package/dist/i18n/locales/hu/messages.js +1 -1
- package/dist/i18n/locales/it/messages.js +1 -1
- package/dist/i18n/locales/nl/messages.js +1 -1
- package/dist/i18n/locales/pl/messages.js +1 -1
- package/dist/i18n/locales/pt/messages.js +1 -1
- package/dist/i18n/locales/ro/messages.js +1 -1
- package/dist/i18n/locales/sk/messages.js +1 -1
- package/dist/i18n/locales/tr/messages.js +1 -1
- package/dist/legacy/domain-spec/__generated/domain-schema.d.ts +6 -0
- package/dist/phoenix/application-spec/application-spec-builder.js +1 -1
- package/dist/phoenix/application-spec/generate-assistant-prompt.d.ts +4 -3
- package/dist/phoenix/application-spec/generate-assistant-prompt.js +1 -1
- package/dist/phoenix/cli.js +1 -1
- package/dist/phoenix/commands/build.d.ts +5 -0
- package/dist/phoenix/commands/build.js +1 -1
- package/dist/phoenix/commands/deploy.js +2 -2
- package/dist/phoenix/commands/dev.js +5 -5
- package/dist/phoenix/commands/feedback.d.ts +2 -1
- package/dist/phoenix/commands/feedback.js +1 -1
- package/dist/phoenix/commands/index.d.ts +1 -0
- package/dist/phoenix/commands/index.js +1 -1
- package/dist/phoenix/commands/story-dev.js +2 -2
- package/dist/phoenix/commands/variants.d.ts +35 -0
- package/dist/phoenix/commands/variants.js +1 -0
- package/dist/phoenix/editor-server/commands-router.d.ts +68 -1
- package/dist/phoenix/editor-server/commands-router.js +1 -1
- package/dist/phoenix/editor-server/editor-router.d.ts +65 -0
- package/dist/phoenix/editor-server/editor-server.d.ts +3 -3
- package/dist/phoenix/editor-server/editor-server.js +1 -1
- package/dist/phoenix/editor-server/protocol.d.ts +1 -0
- package/dist/phoenix/editor-server/spec-router.js +1 -1
- package/dist/phoenix/editor-server/trpc.d.ts +3 -0
- package/dist/phoenix/services/application-spec-project-watcher.d.ts +13 -2
- package/dist/phoenix/services/application-spec-project-watcher.js +3 -3
- package/dist/phoenix/services/index.d.ts +5 -0
- package/dist/phoenix/services/index.js +1 -1
- package/dist/phoenix/services/phoenix-application.d.ts +21 -0
- package/dist/phoenix/services/phoenix-application.js +1 -0
- package/dist/phoenix/services/phoenix-store.d.ts +48 -0
- package/dist/phoenix/services/phoenix-store.js +1 -0
- package/dist/phoenix/services/phx-banner-plugin.d.ts +32 -0
- package/dist/phoenix/services/phx-banner-plugin.js +1 -0
- package/dist/phoenix/services/phx-licenses-plugin.d.ts +55 -0
- package/dist/phoenix/services/phx-licenses-plugin.js +8 -0
- package/dist/phoenix/services/phx-variant-previews-plugin.d.ts +9 -0
- package/dist/phoenix/services/phx-variant-previews-plugin.js +1 -0
- package/dist/phoenix/services/variant-file-session.d.ts +36 -0
- package/dist/phoenix/services/variant-file-session.js +1 -0
- package/dist/phoenix/services/variant-preview-service.d.ts +80 -0
- package/dist/phoenix/services/variant-preview-service.js +1 -0
- package/dist/phoenix/services/vite-config.d.ts +2 -0
- package/dist/phoenix/services/vite-config.js +1 -1
- package/dist/phoenix/utils/index.d.ts +1 -0
- package/dist/phoenix/utils/index.js +1 -1
- package/dist/phoenix/utils/read-git-commit.d.ts +14 -0
- package/dist/phoenix/utils/read-git-commit.js +1 -0
- package/dist/react-sdk/application-runtime/common-services/analytics/analytics-service.d.ts +2 -2
- package/dist/react-sdk/application-runtime/common-services/analytics/domain-controls-analytics.d.ts +21 -21
- package/dist/react-sdk/application-runtime/hooks/data/use-published-data.d.ts +1 -1
- package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +12 -0
- package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +3 -0
- package/dist/ui-sdk/common/use-viewport-size.d.ts +4 -1
- package/dist/ui-sdk/common/use-viewport-size.js +1 -1
- package/dist/ui-sdk/components/mobile-controls/index.d.ts +1 -1
- package/dist/ui-sdk/theme/types.d.ts +4 -0
- package/package.json +5 -8
- package/schema/domain-spec.json +24 -0
- package/dist/configurator/assistant/index.d.ts +0 -1
- package/dist/configurator/assistant/index.js +0 -1
- package/dist/configurator/assistant/use-assistant-chat.d.ts +0 -20
- package/dist/configurator/assistant/use-assistant-chat.js +0 -1
- package/dist/extras/assistant/AssistantChat.d.ts +0 -6
- package/dist/extras/assistant/AssistantChat.js +0 -1
- package/dist/extras/assistant/index.d.ts +0 -1
- package/dist/extras/assistant/index.js +0 -1
|
@@ -327,15 +327,49 @@ as restart-required unless their feature documentation explicitly states live-up
|
|
|
327
327
|
|
|
328
328
|
Builds the project for production deployment.
|
|
329
329
|
|
|
330
|
-
| Flag
|
|
331
|
-
|
|
|
332
|
-
| `--onlyFrontend`
|
|
333
|
-
| `--onlyWebhook`
|
|
334
|
-
| `--force` / `-f`
|
|
335
|
-
| `--
|
|
330
|
+
| Flag | Env Variable | Default | Description |
|
|
331
|
+
| ----------------- | --------------- | ------- | --------------------------------------------------- |
|
|
332
|
+
| `--onlyFrontend` | — | — | Build only the frontend bundle |
|
|
333
|
+
| `--onlyWebhook` | — | — | Build only webhooks |
|
|
334
|
+
| `--force` / `-f` | `FORCE_REBUILD` | `false` | Force full rebuild, skip cache |
|
|
335
|
+
| `--banner <text>` | — | — | Replaces the application line of the banner comment |
|
|
336
|
+
| `--debug` | `DEBUG` | `false` | Verbose logging |
|
|
336
337
|
|
|
337
338
|
The build target can also be controlled via `BUILD_TARGET` env (`frontend`, `webhook`, or `both`).
|
|
338
339
|
|
|
340
|
+
#### Banner comment
|
|
341
|
+
|
|
342
|
+
Every JavaScript file the frontend build emits (the configurator, admin and embedded bundles, and the editor's entry and lazy chunks) starts with a comment that identifies the build, so `head -n 5 <bundle.js>` tells two deployed bundles of nearly the same size apart:
|
|
343
|
+
|
|
344
|
+
```js
|
|
345
|
+
/*!
|
|
346
|
+
* App version: 1.2.3; Commit: 9fd79ce0f4c1a2b3d4e5f60718293a4b5c6d7e8f
|
|
347
|
+
* Built with Salsita SDK 3.4.0. Copyright (c) Salsita s.r.o. All rights reserved.
|
|
348
|
+
* Third-party licences: THIRD-PARTY-LICENSES.txt
|
|
349
|
+
*/
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
The first line is the application's. By default it holds `applicationVersion` from `spec/application.yaml` and the commit checked out in the project, read with `git rev-parse HEAD`. Where git cannot read a commit for the project (no checkout, git missing or refusing the repository, or the project's `package.json` is not tracked by the repository around it), the line holds the version only and `--debug` logs it; this is the case for a platform build from uploaded sources.
|
|
353
|
+
|
|
354
|
+
`--banner <text>` replaces that line with your own text, for example when CI knows a release name the spec does not:
|
|
355
|
+
|
|
356
|
+
```sh
|
|
357
|
+
pnpm phoenix build --banner "Release: ${RELEASE_NAME}; Commit: ${COMMIT_SHA}"
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
The line is **public**: it ships in every bundle. The default publishes the application version and the commit SHA; pass `--banner ""` to leave the line out, and never put a secret or internal detail in your own text. The text is written as comment text only. Each line of a multi-line value (or each repeated `--banner`) becomes its own comment line and `*/` is written as `*\/`. There is no environment-variable fallback, and the option has no effect on webhook output or with `--onlyWebhook`. Lazy chunks keep their hashed file name when only the banner text changes.
|
|
361
|
+
|
|
362
|
+
The banner and the licences file below are produced by the application-spec pipeline; the legacy pipeline's build ignores `--banner`.
|
|
363
|
+
|
|
364
|
+
#### Third-party licences
|
|
365
|
+
|
|
366
|
+
The frontend build writes `.phoenix/dist/frontend/THIRD-PARTY-LICENSES.txt` next to the bundles and the banner comment points to it. It lists every third-party package whose code or styles are in any of the frontend bundles, once each, sorted by name and version, with the package's version, the licence declared in its `package.json` and the text of its licence file (`LICENSE*`, `LICENCE*` or `COPYING*`). A package that ships no licence file is listed without the text. Your project's own source is not listed.
|
|
367
|
+
|
|
368
|
+
Deploy the file together with the bundles, so the notices those licences ask for travel with every copy. The build lists licences; it does not judge whether a licence suits your product. Two kinds of package are not in the list, so add their notices yourself when you use them:
|
|
369
|
+
|
|
370
|
+
- packages used only inside a web worker, which are bundled separately;
|
|
371
|
+
- packages a stylesheet reaches on its own, through CSS `@import`, Sass `@use` or `url()`. A stylesheet imported from JavaScript or TypeScript (`import 'some-font/index.css'`) is listed.
|
|
372
|
+
|
|
339
373
|
#### Bundle-size budgets
|
|
340
374
|
|
|
341
375
|
Application-spec projects can set gzip-size limits for the standalone configurator and webhook bundles. Add the optional `budgets` section to a spec YAML file:
|
|
@@ -457,6 +491,85 @@ phoenix screenshot -o preview.png -w 1920 --height 1080
|
|
|
457
491
|
| `--height` | `1080` | Image height in pixels |
|
|
458
492
|
| `--format` / `-f` | `png` | Image format (`png` or `jpeg`) |
|
|
459
493
|
|
|
494
|
+
### `phoenix variants`
|
|
495
|
+
|
|
496
|
+
Show several options over the configurator and wait for your pick. It is built for coding agents: when a decision is a matter of taste, such as the edge of a table top, how glossy a finish is or where a control sits, the agent writes one file per option, you choose in the browser, and the command hands your answer back to the agent.
|
|
497
|
+
|
|
498
|
+
```bash
|
|
499
|
+
phoenix variants .phoenix/variants/table-edge --title 'Which edge suits the table?' --description 'Only the edge of the top differs.'
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
Every `<id>.variant.js` script or `<id>.html` page in the folder is one option, shown in file-name order. Each script edits frontend project files on top of the same captured baseline. Original is always the first choice and restores that baseline. Switching options removes the previous option's edits and applies the selected script; the editor dialog has any number of choices on the left and your already loaded configurator on the right.
|
|
503
|
+
|
|
504
|
+
```js
|
|
505
|
+
// .phoenix/variants/brand/blue.variant.js
|
|
506
|
+
export const title = 'Blue brand'
|
|
507
|
+
export const description = 'A blue primary colour with the current layout.'
|
|
508
|
+
|
|
509
|
+
export default ({ read, write, remove }) => {
|
|
510
|
+
const file = 'src/handlers/theme.ts'
|
|
511
|
+
write(file, read(file).replace("main: '#E93335'", "main: '#2364aa'"))
|
|
512
|
+
}
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
`read(path)` always reads the baseline. `write(path, contents)` replaces or creates a file; `remove(path)` deletes it. Scripts run in the browser and collect edits; Phoenix validates and writes the batch locally. Supported files are YAML under `spec/` outside `spec/admin/`, and TypeScript under `src/components`, `transformers`, `handlers`, `elements` and `_`-prefixed shared folders. Expressions, actions and invariants also run on the server, so a script cannot edit them.
|
|
516
|
+
|
|
517
|
+
For standalone UI or branding proposals, write self-contained HTML files. Each page renders in its own iframe when selected; its `<title>` names the option and `<meta name="description" content="...">` describes it. HTML and scripts may share a set if their file names give distinct option ids.
|
|
518
|
+
|
|
519
|
+
```html
|
|
520
|
+
<!-- .phoenix/variants/brand/blue.html -->
|
|
521
|
+
<!doctype html>
|
|
522
|
+
<title>Blue studio</title>
|
|
523
|
+
<meta name="description" content="A calm blue identity with generous spacing." />
|
|
524
|
+
<style>
|
|
525
|
+
body {
|
|
526
|
+
margin: 0;
|
|
527
|
+
padding: 40px;
|
|
528
|
+
background: #f0f5fa;
|
|
529
|
+
color: #163b66;
|
|
530
|
+
font-family: sans-serif;
|
|
531
|
+
}
|
|
532
|
+
</style>
|
|
533
|
+
<h1>Made for your everyday.</h1>
|
|
534
|
+
<button>Design your table</button>
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
Scripts run once per selection. The completed file batch calls the existing rebuild queue directly, without a separate file-change event stream or a watcher that reapplies the option.
|
|
538
|
+
|
|
539
|
+
Use script options for controls, layout, brand, lights, visual effects, materials, positions, components, elements and transformers. Changes to the model, schemas, data or deployment settings are rejected before any files are written. Environment files, webhooks, their shared implementation dependencies, dependencies and uploaded assets cannot be overridden. Files connected through symbolic links are also excluded, so restoring the baseline preserves the original files. No server preparation or webhook rebuild runs for a variant transaction.
|
|
540
|
+
|
|
541
|
+
Picking a script keeps its exact implementation in the project. Picking an HTML page returns the selected proposal for the agent to implement; the page itself changes no project source files. Choosing Original keeps the captured baseline. Users finish by confirming Original or another option. Escape stays available to the configurator, and clicking the backdrop leaves the comparison open. The agent can use `--close` to restore the baseline source files without giving an answer. Phoenix records recovery information on disk and restores interrupted previews at the next `phoenix dev` start. It never overwrites a file edited outside the preview: switching options over such an edit is refused, and when the comparison ends, or is restored at the next start, that file is left as it is with a warning in the dev log while the others are restored. Other source changes made while a comparison is open are rebuilt once it ends.
|
|
542
|
+
|
|
543
|
+
Answers are held for four seconds with Undo and Send now.
|
|
544
|
+
|
|
545
|
+
The command prints the outcome as JSON. After `chosen` it removes the folder:
|
|
546
|
+
|
|
547
|
+
| `status` | Meaning |
|
|
548
|
+
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
549
|
+
| `chosen` | An option was picked: `choice` is its id, or `null` for Original; `label` is its name. |
|
|
550
|
+
| `waiting` | The wait ran out. The preview stays open: the same command attaches to it again, and an answer given in between is returned by the next run. |
|
|
551
|
+
| `closed` | The preview was closed without an answer, by `--close` or by another set of options taking its place. The folder is kept. |
|
|
552
|
+
|
|
553
|
+
| Flag | Default | Description |
|
|
554
|
+
| ---------------------- | ----------------------------- | --------------------------------------------------------- |
|
|
555
|
+
| `--title` / `-t` | `Which option do you prefer?` | Question shown above the options |
|
|
556
|
+
| `--description` / `-d` | — | A line saying what differs between the options |
|
|
557
|
+
| `--timeout` | `540` | Seconds to wait for the answer |
|
|
558
|
+
| `--keep` | `false` | Keep the folder after the answer |
|
|
559
|
+
| `--close` | `false` | Close the open preview without an answer; needs no folder |
|
|
560
|
+
| `--port` / `-p` | `3020` | Editor WebSocket port |
|
|
561
|
+
|
|
562
|
+
Known limits:
|
|
563
|
+
|
|
564
|
+
- Variant transactions start rebuilding immediately, bypassing the normal file-watcher debounce. Hot reload still needs to parse and apply the updated implementation. There is no wait for UI or scene loading to settle; allow a visible transition to finish before judging or choosing.
|
|
565
|
+
- Only one option is displayed at a time; simultaneous comparison is not supported.
|
|
566
|
+
- For script options and Original, the dialog moves the existing configurator into the preview and returns it on close, preserving the loaded scene, camera and UI state. Opening the dialog starts no second application or initial loading screen. Configuration interactions still change the current configuration; restoring source files does not undo them.
|
|
567
|
+
- Custom scripts are trusted project code. Their file API stages edits; scripts must not make network requests or other side effects.
|
|
568
|
+
- Binary assets, CSS files, locale catalog changes, dependency changes and edits requiring a full application restart are unsupported.
|
|
569
|
+
- Storybook `story-dev` has no variant previews. A project on the legacy pipeline has no variant previews; the command says so and exits.
|
|
570
|
+
|
|
571
|
+
Generated projects carry the `phoenix-variants` agent skill, which tells coding agents when to offer options, how to write each kind and what to do with your answer.
|
|
572
|
+
|
|
460
573
|
## SDK Development
|
|
461
574
|
|
|
462
575
|
### `phoenix link`
|
|
@@ -594,28 +707,32 @@ Revokes the token on the server and removes it from the credentials file. `--reg
|
|
|
594
707
|
|
|
595
708
|
### `phoenix deploy`
|
|
596
709
|
|
|
597
|
-
Validates the spec, adds the pnpm settings `phoenix init` writes to `pnpm-workspace.yaml` when they are missing, packs and uploads the project, starts its build on the server and follows it until the configurator is live. Before the upload the server compares the domain model with the deployed one: a model that changed under an already deployed model version is refused with the reason, and needs a new model version and a [migration](?path=/docs/phoenix-migrations--docs). Once the build starts it prints `Follow the build in Studio: <url>`, the build's page in the Studio you signed in through; a sign-in stored by an older CLI has no Studio URL, so sign in again to get the link. `--region` or `--serverUrl` selects the server, as for `login`; `--no-wait` returns as soon as the build starts.
|
|
710
|
+
Validates the spec, adds the pnpm settings `phoenix init` writes to `pnpm-workspace.yaml` when they are missing, packs and uploads the project, starts its build on the server and follows it until the configurator is live. Before the upload the server compares the domain model with the deployed one: a model that changed under an already deployed model version is refused with the reason, and needs a new model version and a [migration](?path=/docs/phoenix-migrations--docs). Once the build starts it prints `Follow the build in Studio: <url>`, the build's page in the Studio you signed in through; a sign-in stored by an older CLI has no Studio URL, so sign in again to get the link. After `Your configurator is live at <url>` it prints one line for coding agents, which tells them to offer the run evaluation of the `phoenix-feedback` skill once you have nothing more to build; you can ignore it when you run the command yourself. `--region` or `--serverUrl` selects the server, as for `login`; `--no-wait` returns as soon as the build starts.
|
|
598
711
|
|
|
599
|
-
### `phoenix feedback
|
|
712
|
+
### `phoenix feedback [message]`
|
|
600
713
|
|
|
601
714
|
Sends feedback about the SDK, the CLI, the documentation or Studio to the Phoenix team. It needs `phoenix login`: the server records the workspace, user and API token of the sign-in, so the message itself needs no introduction.
|
|
602
715
|
|
|
603
716
|
```bash
|
|
604
717
|
phoenix feedback "phoenix build reports a missing entity when a module file is empty" --type bug
|
|
718
|
+
phoenix feedback --file report.txt --type bug
|
|
605
719
|
```
|
|
606
720
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
|
610
|
-
|
|
|
611
|
-
| `--
|
|
612
|
-
| `--
|
|
613
|
-
| `--
|
|
614
|
-
| `--
|
|
721
|
+
Pass the message as the argument for a short note, or `--file` for a longer report: the content of the file is the message, read as UTF-8, so quotes, backticks and new lines arrive unchanged. Giving both, or neither, is an error.
|
|
722
|
+
|
|
723
|
+
| Flag | Env | Default | Description |
|
|
724
|
+
| ---------------------- | -------------- | ----------------------------- | --------------------------------------------------------- |
|
|
725
|
+
| `--file` | — | — | Text file that holds the message, instead of the argument |
|
|
726
|
+
| `--type` | — | `other` | What the feedback is about: `bug`, `idea` or `other` |
|
|
727
|
+
| `--contact` | — | — | How to reach you, when you want a reply |
|
|
728
|
+
| `--agent` | — | — | Name of the coding agent that writes the feedback |
|
|
729
|
+
| `--projectSlug` / `-p` | `PROJECT_SLUG` | `project` of the spec, if any | Workspace project the feedback is about |
|
|
730
|
+
| `--region` | — | `eu` | Phoenix region of the workspace: `eu` or `us` |
|
|
731
|
+
| `--serverUrl` / `-su` | — | the region's server | Phoenix server URL, for a local or custom server |
|
|
615
732
|
|
|
616
|
-
A message holds at most
|
|
733
|
+
A message holds at most 100,000 characters, from the argument or from the file. Besides the message and the flags, the CLI sends only the SDK version, the operating system and the Node.js version; no file of the project is attached, and the Phoenix team reads a build's sources through the build's page in Studio. The project must belong to the signed-in workspace, otherwise the server refuses the feedback; without a project, the feedback is sent on its own.
|
|
617
734
|
|
|
618
|
-
Generated projects carry the `phoenix-feedback` agent skill. It tells coding agents when to draft feedback, to show you the draft and send it only after you approve it, and what
|
|
735
|
+
Generated projects carry the `phoenix-feedback` agent skill. It tells coding agents when to draft feedback, to show you the draft and send it only after you approve it, and how to write a report: the build id with its Studio page link, the live configurator link, what the agent was doing, what happened and what was expected, the exact error or output, the workaround and a condensed conversation log. When you say you are done, or a deploy went live and you confirm the run is finished, the agent asks you to evaluate the run, one question at a time: minutes spent, then a score from 0 to 10 for the agent's guidance, the configurator's functionality, its UX, the quality of the 3D, the UI visuals and the overall result, then your comments. It never picks a score for you and sends nothing when you decline. Secrets, credentials and personal data never go into a message; file paths, spec and code snippets and your own words may, once you approved the draft that contains them. The command needs a server with API 1.40.0 or newer; a message over 5000 characters needs API 1.43.0 or newer.
|
|
619
736
|
|
|
620
737
|
## Next Steps
|
|
621
738
|
|
|
@@ -40,6 +40,7 @@ project-root/
|
|
|
40
40
|
| `components/` | Phoenix system components (ECS) |
|
|
41
41
|
| `elements/` | Page elements (pages, providers) |
|
|
42
42
|
| `expressions/` | Domain logic expressions |
|
|
43
|
+
| `actions/` | Implementations of the domain actions declared under `actions:` |
|
|
43
44
|
| `invariants/` | Domain constraints |
|
|
44
45
|
| `transformers/` | Data transformation logic |
|
|
45
46
|
| `handlers/` | Event & lifecycle handlers |
|
|
@@ -188,7 +189,7 @@ type CustomMaterial = Phx['AdminModel']['CustomMaterial']
|
|
|
188
189
|
|
|
189
190
|
### DO NOT EDIT (Fully Auto-Generated)
|
|
190
191
|
|
|
191
|
-
- **Everything in `.phoenix/`** - Completely regenerated on each build
|
|
192
|
+
- **Everything in `.phoenix/`** - Completely regenerated on each build. The one exception is `.phoenix/variants/`, where a coding agent writes the option files for `phoenix variants`; a rebuild keeps it
|
|
192
193
|
- `tsconfig.json`, `eslint.config.js`, `prettier.config.js`, `.prettierignore`
|
|
193
194
|
- `.linguirc`, `.nvmrc`
|
|
194
195
|
- `src/locales/**/*.ts` - Compiled from `.po` catalogs
|
|
@@ -197,7 +198,7 @@ type CustomMaterial = Phx['AdminModel']['CustomMaterial']
|
|
|
197
198
|
|
|
198
199
|
### Agent Guidance
|
|
199
200
|
|
|
200
|
-
Coding agents (Claude Code, Codex, Cursor) read `AGENTS.md` and the Phoenix agent skills. `AGENTS.md` is written once with the build commands, the do-not-edit list and a pointer to the skills; after that it is yours. The `phoenix`, `phoenix-cli`, `phoenix-feedback` and `phoenix-review` skills carry the SDK conventions, CLI tooling and review checklist, and the `phoenix-create-configurator` skill walks the agent from your product documents and assets to a reviewed configurator in five stages. Phoenix keeps them in step with the installed SDK, including the reference files inside a skill folder. During the internal beta, a project created from a canary build of the SDK gets one more section in the `phoenix` skill: once per conversation the agent checks for a newer canary and, after telling you, updates the project's SDK and runs `phoenix sync`. Other skill folders are never touched.
|
|
201
|
+
Coding agents (Claude Code, Codex, Cursor) read `AGENTS.md` and the Phoenix agent skills. `AGENTS.md` is written once with the build commands, the do-not-edit list and a pointer to the skills; after that it is yours. The `phoenix`, `phoenix-cli`, `phoenix-feedback` and `phoenix-review` skills carry the SDK conventions, CLI tooling and review checklist, and the `phoenix-create-configurator` skill walks the agent from your product documents and assets to a reviewed configurator in five stages. The `phoenix-variants` skill has the agent show you several options over the dev preview when a decision is a matter of taste, and build the one you pick. Phoenix keeps them in step with the installed SDK, including the reference files inside a skill folder. During the internal beta, a project created from a canary build of the SDK gets one more section in the `phoenix` skill: once per conversation the agent checks for a newer canary and, after telling you, updates the project's SDK and runs `phoenix sync`. Other skill folders are never touched.
|
|
201
202
|
|
|
202
203
|
Projects created by earlier SDK versions had this guidance in `CLAUDE.md`, `.cursor/rules/phoenix.mdc` and `commands/review.md`. Sync removes the SDK block from the first two, keeps your own text around it, deletes a file that held nothing else, and deletes the review commands; use the `phoenix-review` skill instead of `/review`.
|
|
203
204
|
|
|
@@ -249,6 +250,7 @@ project-root/
|
|
|
249
250
|
│ ├── components/ # Phoenix system components (ECS)
|
|
250
251
|
│ ├── elements/ # UI elements (pages, providers)
|
|
251
252
|
│ ├── expressions/ # Domain logic expressions
|
|
253
|
+
│ ├── actions/ # Domain action implementations
|
|
252
254
|
│ ├── invariants/ # Domain constraints
|
|
253
255
|
│ ├── transformers/ # Data transformation logic
|
|
254
256
|
│ ├── handlers/ # Event & lifecycle handlers
|
|
@@ -314,6 +316,7 @@ project-root/
|
|
|
314
316
|
│ │ └── builders.ts
|
|
315
317
|
│ ├── .swc/ # SWC transpiled sources
|
|
316
318
|
│ ├── .lingui/ # Compiled i18n catalogs
|
|
319
|
+
│ ├── variants/ # Option files of `phoenix variants`, written by coding agents
|
|
317
320
|
│ ├── dist/ # Build output
|
|
318
321
|
│ │ ├── frontend/ # Frontend bundles
|
|
319
322
|
│ │ └── webhooks/ # Webhook bundles
|
|
@@ -362,6 +365,7 @@ Domain logic files define the business rules and computed properties of your con
|
|
|
362
365
|
| Purpose | Location | Example Files |
|
|
363
366
|
| ------------ | ------------------- | ---------------------------------------------- |
|
|
364
367
|
| Expressions | `src/expressions/` | `table.ts`, `legs.ts`, `module.ts` |
|
|
368
|
+
| Actions | `src/actions/` | `move-part.ts`, `swap-cabinets.ts` |
|
|
365
369
|
| Invariants | `src/invariants/` | `top.ts`, `legs.ts` |
|
|
366
370
|
| Transformers | `src/transformers/` | `fix-table-top-material-update-transformer.ts` |
|
|
367
371
|
| Migrations | `src/migrations/` | `v2.ts`, `v3.ts`, `v4.ts` |
|
|
@@ -510,7 +514,7 @@ The `application.yaml` file contains global application-level settings. These fi
|
|
|
510
514
|
| Field | Type | Description |
|
|
511
515
|
| -------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
512
516
|
| `project` | `string` | Server project `phoenix dev` develops in: a project slug, or `default` for the default project of the signed-in workspace. Read only by the CLI; overridden by `--projectSlug` and `PROJECT_SLUG` |
|
|
513
|
-
| `applicationVersion` | `string` | Semantic version (`x.y.z`) exported as `ApplicationVersion` constant
|
|
517
|
+
| `applicationVersion` | `string` | Semantic version (`x.y.z`) exported as `ApplicationVersion` constant, stored on the deployment record and named in the banner comment of built bundles |
|
|
514
518
|
| `webComponentTag` | `string` | Custom HTML web component tag name for embedding |
|
|
515
519
|
| `pageTitle` | `string` | Browser page title |
|
|
516
520
|
|
|
@@ -94,9 +94,10 @@ Studio's **Builds & deployments** page lists your builds and shows which one you
|
|
|
94
94
|
Tell us what is broken, confusing or missing, from wherever you are:
|
|
95
95
|
|
|
96
96
|
- In Studio, **Send beta feedback** in the sidebar opens a short form.
|
|
97
|
-
- In the terminal, `pnpm phoenix feedback "<message>" --type bug|idea|other` sends it with your sign-in. See the [CLI reference](?path=/docs/phoenix-phoenix-cli--docs).
|
|
97
|
+
- In the terminal, `pnpm phoenix feedback "<message>" --type bug|idea|other` sends it with your sign-in, and `--file <path>` sends a text file instead of the argument. See the [CLI reference](?path=/docs/phoenix-phoenix-cli--docs).
|
|
98
|
+
- On a build's page in Studio, **Download sources** downloads the archive `phoenix deploy` uploaded for that build, so a report only needs to name the build.
|
|
98
99
|
|
|
99
|
-
Coding agents working in your project use the same command, guided by the generated `phoenix-feedback` skill. They never send on their own: an agent shows you a draft, right away when the problem is crucial and otherwise at the end of the task, and sends it only after you approve it.
|
|
100
|
+
Coding agents working in your project use the same command, guided by the generated `phoenix-feedback` skill. They never send on their own: an agent shows you a draft, right away when the problem is crucial and otherwise at the end of the task, and sends it only after you approve it. A report names the build with its Studio page link and the live configurator, says what the agent was doing, what happened and what it expected, quotes the exact error and ends with a condensed conversation log. Agents are told never to include secrets, credentials or personal data; parts of your project and your own words go in only through a draft you approved. When you are done with the configurator, the agent also asks you, once per conversation, to evaluate the run: minutes spent, then scores from 0 to 10 for the agent's guidance, functionality, UX, 3D quality, UI visuals and the overall result, and your comments. It asks one question at a time, never picks a score for you, tells you the answers go to the Phoenix team, shows the message and sends it only after you approve it.
|
|
100
101
|
|
|
101
102
|
## Known limits
|
|
102
103
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ActionImplementations, ActionTypes } from '../core/action.js';
|
|
2
|
+
import type { $DomainEntity, DomainEntity } from '../core/model.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates the `implementActions` factory the generated `domain-spec.ts` exposes as
|
|
5
|
+
* `phx.domain.implementActions`. A module in `src/actions/` implements any subset of the declared
|
|
6
|
+
* actions and gets each parameter and result typed from the spec; a name the spec does not declare
|
|
7
|
+
* is a type error, since its implementation would have to be `never`. The generated barrel merges
|
|
8
|
+
* the modules and checks that every declared action is implemented.
|
|
9
|
+
*/
|
|
10
|
+
export declare const createActionFactory: <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>() => <IMPLEMENTATIONS extends Partial<ActionImplementations<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, ACTION_TYPES>>>(implementations: IMPLEMENTATIONS & Readonly<Record<Exclude<keyof IMPLEMENTATIONS, keyof ACTION_TYPES>, never>>) => IMPLEMENTATIONS;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const createActionFactory=()=>t=>t;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ActionDefinitions, AnyActionImplementations } from '../core/index.js';
|
|
2
|
+
/** The declared actions that have no implementation, and the implementations of undeclared names. */
|
|
3
|
+
export interface ActionImplementationConflicts {
|
|
4
|
+
readonly missing: readonly string[];
|
|
5
|
+
readonly extra: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/** Compares the names of the declared actions with the implemented ones. */
|
|
8
|
+
export declare const findActionImplementationConflicts: (declared: readonly string[], implementations: AnyActionImplementations) => ActionImplementationConflicts;
|
|
9
|
+
/**
|
|
10
|
+
* Validates the implemented actions against the declared ones, as `prepareDomainExpressions` does
|
|
11
|
+
* for expressions: a declared action without an implementation throws, so the domain is not
|
|
12
|
+
* instantiated with an action that can only fail when it is called; an implementation of an
|
|
13
|
+
* undeclared name is logged. Returns the implementations unchanged.
|
|
14
|
+
*/
|
|
15
|
+
export declare const prepareActionImplementations: (definitions: ActionDefinitions, implementations: AnyActionImplementations) => AnyActionImplementations;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const findActionImplementationConflicts=(e,n)=>{let t=Object.keys(n);return{missing:e.filter(e=>!t.includes(e)),extra:t.filter(n=>!e.includes(n))}};export const prepareActionImplementations=(e,n)=>{let{missing:t,extra:i}=findActionImplementationConflicts(Object.values(e).map(e=>e.name),n);if(0===t.length&&0===i.length)return n;let o=Error("Domain cannot be instantiated because there are conflicts between declared and implemented actions."+(t.length>0?`
|
|
2
|
+
|
|
3
|
+
Missing actions: ${t.join(", ")}. Add each to a default export of phx.domain.implementActions({ ... }) in src/actions/.`:"")+(i.length>0?`
|
|
4
|
+
|
|
5
|
+
Extra actions: ${i.join(", ")}. Declare each under "actions" in a spec file or remove its implementation.`:"")+"\n");if(t.length>0)throw o;return console.error(o),n};
|
|
@@ -112,7 +112,8 @@ export interface AssistantFieldOptions {
|
|
|
112
112
|
* the recipe groups `meta { childRecipes }` and `addChild` expose, in manifest order, and absent
|
|
113
113
|
* means none; `replaceRecipes` lists the same for `meta { replaceRecipes }` and `replaceEntity`;
|
|
114
114
|
* `fieldOptions` lists, per entity type, the options edges `meta` exposes for its
|
|
115
|
-
* writable fields, and absent means none
|
|
115
|
+
* writable fields, and absent means none; `actions` maps each custom `Mutation` field to the
|
|
116
|
+
* declared action it runs, and absent means none. Consumed by the configurator GraphQL system.
|
|
116
117
|
*/
|
|
117
118
|
export interface AssistantManifest {
|
|
118
119
|
readonly sdl: string;
|
|
@@ -122,6 +123,7 @@ export interface AssistantManifest {
|
|
|
122
123
|
readonly childRecipes?: Readonly<Record<string, readonly AssistantRecipeGroup[]>>;
|
|
123
124
|
readonly replaceRecipes?: Readonly<Record<string, readonly AssistantRecipeGroup[]>>;
|
|
124
125
|
readonly fieldOptions?: Readonly<Record<string, readonly AssistantFieldOptions[]>>;
|
|
126
|
+
readonly actions?: Readonly<Record<string, string>>;
|
|
125
127
|
}
|
|
126
128
|
export type AdminPagesSpec = {
|
|
127
129
|
readonly presets?: boolean | {
|
|
@@ -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 {
|
|
3
|
-
import { type
|
|
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
6
|
import type { AssistantManifest } from './application-config.js';
|
|
6
|
-
import { type AssistantRecipeContext } from './assistant-recipe-groups.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
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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
|
|
23
|
+
export interface AssistantMutationContext {
|
|
25
24
|
readonly manifest: AssistantManifest;
|
|
26
|
-
|
|
27
|
-
|
|
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,
|
|
60
|
-
* implementation when the name is `modify` followed by an
|
|
61
|
-
* fields for. `undefined` when the configurator has no
|
|
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
|
|
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}}})};
|
|
@@ -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>> {
|