@salsita-ai/sdk 0.50.0-develop.eb204e0da4 → 0.50.0-develop.f42416a4e6
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/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/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 +4 -2
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +3 -1
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +2 -2
- 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/configurator-extension-systems.d.ts +2 -1
- package/dist/configurator/application-runtime/extensions/configurator-extension-systems.js +1 -1
- package/dist/configurator/application-runtime/extensions/selectors.d.ts +2 -1
- package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +35 -0
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -0
- package/dist/configurator/{assistant → application-runtime/extensions/systems/assistant-system}/browser-details.d.ts +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/browser-details.js +1 -0
- package/dist/configurator/{assistant → application-runtime/extensions/systems/assistant-system}/graphql-tools.d.ts +13 -14
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -0
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/index.d.ts +1 -0
- package/dist/configurator/application-runtime/extensions/systems/index.js +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/assistant/use-assistant-chat.d.ts +15 -5
- package/dist/configurator/assistant/use-assistant-chat.js +1 -1
- 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 +11 -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/AssistantPanelProvider.d.ts +42 -0
- package/dist/configurator/ui/assistant/AssistantPanelProvider.js +1 -0
- package/dist/configurator/ui/assistant/AssistantThread.d.ts +11 -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/configurator-layout/universal/DesktopLayout.js +5 -5
- package/dist/configurator/ui/configurator-layout/universal/Layout.js +1 -1
- package/dist/configurator/ui/configurator-layout/universal/MobileLayout.d.ts +2 -0
- package/dist/configurator/ui/configurator-layout/universal/MobileLayout.js +3 -3
- 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 +4 -0
- package/dist/docs/other-features/domain-actions.mdx +418 -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 +60 -20
- package/dist/docs/phoenix/project-structure.mdx +4 -1
- package/dist/docs/phoenix/sdk-builder-workflow.mdx +5 -4
- 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/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 +1 -0
- package/dist/domain/domain-context/index.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/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/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/generate-assistant-prompt.d.ts +2 -2
- 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/feedback.d.ts +2 -1
- package/dist/phoenix/commands/feedback.js +1 -1
- package/dist/phoenix/commands/login.d.ts +24 -6
- package/dist/phoenix/commands/login.js +2 -2
- package/dist/phoenix/services/index.d.ts +1 -0
- package/dist/phoenix/services/index.js +1 -1
- 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/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/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/theme/types.d.ts +4 -0
- package/package.json +4 -7
- package/schema/domain-spec.json +24 -0
- package/dist/configurator/assistant/browser-details.js +0 -1
- package/dist/configurator/assistant/graphql-tools.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:
|
|
@@ -569,9 +603,11 @@ SDK-builder workspaces sign the CLI in with a personal API token instead of proj
|
|
|
569
603
|
|
|
570
604
|
Signs the CLI in to the SDK-builder workspace `<customer>`:
|
|
571
605
|
|
|
572
|
-
1. Opens Studio, where you approve the sign-in (use `--no-open` to only print the link).
|
|
606
|
+
1. Opens Studio, where you name the token and approve the sign-in (use `--no-open` to only print the link). The page shows the workspace, your account, the computer the CLI runs on and how long the link still works. The CLI suggests the name `phoenix CLI on <computer>`; change it so you can tell your machines and agents apart later.
|
|
573
607
|
2. Studio sends a one-time code back to the CLI on `127.0.0.1`.
|
|
574
|
-
3. The CLI exchanges the code for a token.
|
|
608
|
+
3. The CLI exchanges the code for a token with the name you approved, and sends the browser back to Studio, which confirms the sign-in.
|
|
609
|
+
|
|
610
|
+
**Deny** in Studio stops the CLI at once: it exits with `The sign-in was denied in Studio` and no token is created. The link works for five minutes and only for the CLI that printed it; after that, Studio shows that it no longer works and the CLI gives up.
|
|
575
611
|
|
|
576
612
|
The token is stored in `~/.phoenix/credentials.json`, readable only by you, per server, together with the Studio URL of the sign-in; `PHOENIX_CREDENTIALS_FILE` moves the file. The token works until you revoke it. Signing in again to the same server revokes the token it replaces; the CLI warns if the server could not revoke it.
|
|
577
613
|
|
|
@@ -592,28 +628,32 @@ Revokes the token on the server and removes it from the credentials file. `--reg
|
|
|
592
628
|
|
|
593
629
|
### `phoenix deploy`
|
|
594
630
|
|
|
595
|
-
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.
|
|
631
|
+
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.
|
|
596
632
|
|
|
597
|
-
### `phoenix feedback
|
|
633
|
+
### `phoenix feedback [message]`
|
|
598
634
|
|
|
599
635
|
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.
|
|
600
636
|
|
|
601
637
|
```bash
|
|
602
638
|
phoenix feedback "phoenix build reports a missing entity when a module file is empty" --type bug
|
|
639
|
+
phoenix feedback --file report.txt --type bug
|
|
603
640
|
```
|
|
604
641
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
|
608
|
-
|
|
|
609
|
-
| `--
|
|
610
|
-
| `--
|
|
611
|
-
| `--
|
|
612
|
-
| `--
|
|
642
|
+
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.
|
|
643
|
+
|
|
644
|
+
| Flag | Env | Default | Description |
|
|
645
|
+
| ---------------------- | -------------- | ----------------------------- | --------------------------------------------------------- |
|
|
646
|
+
| `--file` | — | — | Text file that holds the message, instead of the argument |
|
|
647
|
+
| `--type` | — | `other` | What the feedback is about: `bug`, `idea` or `other` |
|
|
648
|
+
| `--contact` | — | — | How to reach you, when you want a reply |
|
|
649
|
+
| `--agent` | — | — | Name of the coding agent that writes the feedback |
|
|
650
|
+
| `--projectSlug` / `-p` | `PROJECT_SLUG` | `project` of the spec, if any | Workspace project the feedback is about |
|
|
651
|
+
| `--region` | — | `eu` | Phoenix region of the workspace: `eu` or `us` |
|
|
652
|
+
| `--serverUrl` / `-su` | — | the region's server | Phoenix server URL, for a local or custom server |
|
|
613
653
|
|
|
614
|
-
A message holds at most
|
|
654
|
+
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.
|
|
615
655
|
|
|
616
|
-
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
|
|
656
|
+
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.
|
|
617
657
|
|
|
618
658
|
## Next Steps
|
|
619
659
|
|
|
@@ -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 |
|
|
@@ -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
|
|
@@ -362,6 +364,7 @@ Domain logic files define the business rules and computed properties of your con
|
|
|
362
364
|
| Purpose | Location | Example Files |
|
|
363
365
|
| ------------ | ------------------- | ---------------------------------------------- |
|
|
364
366
|
| Expressions | `src/expressions/` | `table.ts`, `legs.ts`, `module.ts` |
|
|
367
|
+
| Actions | `src/actions/` | `move-part.ts`, `swap-cabinets.ts` |
|
|
365
368
|
| Invariants | `src/invariants/` | `top.ts`, `legs.ts` |
|
|
366
369
|
| Transformers | `src/transformers/` | `fix-table-top-material-update-transformer.ts` |
|
|
367
370
|
| Migrations | `src/migrations/` | `v2.ts`, `v3.ts`, `v4.ts` |
|
|
@@ -510,7 +513,7 @@ The `application.yaml` file contains global application-level settings. These fi
|
|
|
510
513
|
| Field | Type | Description |
|
|
511
514
|
| -------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
512
515
|
| `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
|
|
516
|
+
| `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
517
|
| `webComponentTag` | `string` | Custom HTML web component tag name for embedding |
|
|
515
518
|
| `pageTitle` | `string` | Browser page title |
|
|
516
519
|
|
|
@@ -36,11 +36,11 @@ The starter `spec/application.yaml` begins with `project: default`, which means
|
|
|
36
36
|
pnpm phoenix login <workspace>
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
`phoenix login` opens Studio, where you approve the sign-in. Studio sends a one-time code back to the CLI on `127.0.0.1`,
|
|
39
|
+
`phoenix login` opens Studio, where you name the token and approve the sign-in. The CLI suggests `phoenix CLI on <computer>`; a name of your own, such as the agent and the machine, tells your tokens apart later. Studio sends a one-time code back to the CLI on `127.0.0.1`, the CLI exchanges it for a personal token and returns the browser to Studio, which confirms the sign-in. The code only works for the CLI that asked for it and expires after five minutes. **Deny** stops the waiting CLI at once and creates no token. Use `--no-open` to print the link instead of opening a browser.
|
|
40
40
|
|
|
41
41
|
The CLI stores the token in `~/.phoenix/credentials.json`, readable only by you, with one entry per server. `PHOENIX_CREDENTIALS_FILE` moves the file. The token acts for you in your workspace until you revoke it. It stops working when you are removed from the workspace or banned.
|
|
42
42
|
|
|
43
|
-
`pnpm phoenix logout` revokes the token and removes it from the file. Studio's **CLI tokens** page lists your tokens with when they were last used, and revokes any of them, for example one left on another computer.
|
|
43
|
+
`pnpm phoenix logout` revokes the token and removes it from the file. Studio's **CLI tokens** page lists your tokens by the names you gave them, with when they were last used, and revokes any of them, for example one left on another computer. A revoked token leaves the list.
|
|
44
44
|
|
|
45
45
|
`login`, `logout` and `deploy` follow the region, not the `SERVER_URL` in the project's `.env`. `dev` follows the region too when `.env` has no `SERVER_URL`:
|
|
46
46
|
|
|
@@ -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}}})};
|
|
@@ -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
|
|
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})}}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ActionContext, ActionTypes, PreparedAction } from '../../core/action.js';
|
|
2
|
+
import type { $DomainEntity, DomainEntity } from '../../core/model.js';
|
|
3
|
+
import type { DomainState } from '../../core/state.js';
|
|
4
|
+
import type { DomainContextSelectors } from '../../domain-runtime/domain-context/index.js';
|
|
5
|
+
export interface ActionSystemContext {
|
|
6
|
+
/**
|
|
7
|
+
* The action system's window into the runtime registry: the declared actions and their
|
|
8
|
+
* implementations are read per call, never snapshotted, so a hot-reloaded spec or action file is
|
|
9
|
+
* observed without rebuilding the system.
|
|
10
|
+
*/
|
|
11
|
+
readonly selectors: DomainContextSelectors;
|
|
12
|
+
}
|
|
13
|
+
/** ActionSystem with its types erased — how the runtime selectors expose the instance. */
|
|
14
|
+
export type AnyActionSystem = ActionSystem<any, any, any, any, any, any, any, any, any, any, any>;
|
|
15
|
+
/**
|
|
16
|
+
* Runs the actions an application declares under `actions` and implements in `src/actions/`. It
|
|
17
|
+
* only prepares: an action gets the state it is called on and returns the updates it wants applied
|
|
18
|
+
* with a reader for its result, and the caller stages, commits or dry-runs them. Every caller of an
|
|
19
|
+
* action goes through it, so all of them run the same domain logic.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ActionSystem<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> {
|
|
22
|
+
private readonly _context;
|
|
23
|
+
/** One compiled validator per declared action, rebuilt only when the declarations change. */
|
|
24
|
+
private readonly _selectValidators;
|
|
25
|
+
private readonly _updates;
|
|
26
|
+
constructor(_context: ActionSystemContext);
|
|
27
|
+
/**
|
|
28
|
+
* The context an implementation runs with on `state`. Code that prepares updates outside an
|
|
29
|
+
* action can run on the same context, so it can do everything an action can, the same way.
|
|
30
|
+
*/
|
|
31
|
+
readonly createContext: (state: DomainState<ENTITIES>) => ActionContext<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>;
|
|
32
|
+
/**
|
|
33
|
+
* Prepares the action `name` with `args` on `state`. The arguments are validated against the
|
|
34
|
+
* params schema the action declares, and the implementation is called with the validated
|
|
35
|
+
* parameters and the context of the state; nothing is staged or committed. Throws for an unknown
|
|
36
|
+
* action, arguments that do not fit the schema, or a declared action without an implementation.
|
|
37
|
+
* The result of `readResult` is not validated: the generated type is its contract.
|
|
38
|
+
*/
|
|
39
|
+
readonly prepareAction: <NAME extends keyof ACTION_TYPES & string>(name: NAME, args: unknown, state: DomainState<ENTITIES>) => PreparedAction<ENTITIES, ACTION_TYPES[NAME]['result']>;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSelector as t}from"@salsita-ai/common/utils";import{createUpdateFactory as e}from"../../components/updates.js";import{extendedSchemaValidator as s}from"../../core/json-schema.js";import{getIdSequence as o}from"../store-system/next-domain-entity-id.js";export class ActionSystem{_context;_selectValidators=t([t.leaf(t=>t)],t=>new Map(Object.values(t).map(t=>[t.name,s.compile(t.params)])));_updates=e();constructor(t){this._context=t}createContext=t=>({expressionContext:this._context.selectors.getExpressionContext(),systems:this._context.selectors.getDomainSystems(),getIdSequence:()=>o(t.entities,[]),updates:this._updates});prepareAction=(t,e,o)=>{let n=this._context.selectors.getActionDefinitions(),i=Object.values(n).find(e=>e.name===t);if(!i){let e=Object.values(n).map(t=>`"${t.name}"`);throw Error(`Unknown action "${t}". ${e.length>0?`The application declares these actions: ${e.join(", ")}.`:"The application declares no actions."} Declare it under "actions" in a spec file and implement it in src/actions/.`)}let a=this._selectValidators(n).get(i.name);if(a&&!a(e))throw Error(`The arguments of action "${t}" do not fit its params: ${s.errorsText(a.errors)}. Nothing was changed. Send arguments that fit the params the action declares.`);return(Object.entries(this._context.selectors.getActionImplementations()).find(([e])=>e===t)?.[1])(e,o,this.createContext(o))}}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { ActionTypes } from '../core/action.js';
|
|
1
2
|
import type { Domain } from '../core/domain.js';
|
|
2
3
|
import type { $DomainEntity, DomainEntity } from '../core/model.js';
|
|
3
4
|
import type { ComponentReader, DomainContextSelectors } from '../domain-runtime/domain-context/index.js';
|
|
4
5
|
import type { BlenderProjections, CollisionProjections, CompositionProjections, ConstraintProjections, PositionProjections, ProjectedEntitiesProjections, SnappingProjections, ValidationProjections } from '../projections/index.js';
|
|
5
6
|
import type { SketchingProjections } from '../sketching/sketching-projections.js';
|
|
7
|
+
import type { ActionSystem } from './action-system/action-system.js';
|
|
6
8
|
import type { DimensionSystem } from './dimension-system/dimension-system.js';
|
|
7
9
|
import type { NavigationSystem } from './navigation-system/navigation-system.js';
|
|
8
10
|
import type { RecipeCookerSystem } from './recipe-system/recipe-cooker-system.js';
|
|
@@ -14,7 +16,7 @@ import type { UndoSystem } from './undo-system.js';
|
|
|
14
16
|
* The `DomainContext` lifecycle orchestrates these systems but does not expose them.
|
|
15
17
|
* Consumers read this record through `DomainContextSelectors.getDomainSystems()`.
|
|
16
18
|
*/
|
|
17
|
-
export interface DomainContextSystems<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string> {
|
|
19
|
+
export interface DomainContextSystems<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string, ACTION_TYPES extends ActionTypes = ActionTypes> {
|
|
18
20
|
/**
|
|
19
21
|
* The system graph's window into the runtime registry. Consumers outside the domain systems use
|
|
20
22
|
* it to read spec-derived values live rather than through construction-time snapshots.
|
|
@@ -30,6 +32,7 @@ export interface DomainContextSystems<ENTITIES extends DomainEntity<string>, ALL
|
|
|
30
32
|
readonly dimensionSystem: DimensionSystem<ENTITIES>;
|
|
31
33
|
readonly undoSystem: UndoSystem<ENTITIES, $MAP>;
|
|
32
34
|
readonly recipeCooker: RecipeCookerSystem<ENTITIES>;
|
|
35
|
+
readonly actionSystem: ActionSystem<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, Record<string, unknown>, Record<string, unknown>, Record<string, unknown>, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, ACTION_TYPES>;
|
|
33
36
|
readonly sketchingProjections: SketchingProjections<ENTITIES>;
|
|
34
37
|
readonly collisionProjections: CollisionProjections<ENTITIES>;
|
|
35
38
|
readonly positionProjections: PositionProjections<ENTITIES>;
|
|
@@ -37,4 +40,4 @@ export interface DomainContextSystems<ENTITIES extends DomainEntity<string>, ALL
|
|
|
37
40
|
readonly projectedEntitiesProjections: ProjectedEntitiesProjections<ENTITIES>;
|
|
38
41
|
readonly constraintProjections: ConstraintProjections<ENTITIES>;
|
|
39
42
|
}
|
|
40
|
-
export type AnyDomainContextSystems = DomainContextSystems<any, any, any, any, any, any, any>;
|
|
43
|
+
export type AnyDomainContextSystems = DomainContextSystems<any, any, any, any, any, any, any, any>;
|
|
@@ -13,6 +13,7 @@ export { createCascadeRefPruningTransformer } from './relation-transformers/casc
|
|
|
13
13
|
export { createCreateEntityRefsTransformer } from './relation-transformers/create-entity-refs.js';
|
|
14
14
|
export { type CanBeUndonePredicate, type CanBeUndoneContext, type UndoCapabilities, UndoSystem, UNDO_REDO_RESET_TAG, isUndoRedoReset, } from './undo-system.js';
|
|
15
15
|
export { DimensionSystem, type AnyDimensionSystem, type DimensionSystemContext, type AngleDimensionViolation, type DistanceDimensionViolation, type GenericDimensionViolation, } from './dimension-system/dimension-system.js';
|
|
16
|
+
export { ActionSystem, type AnyActionSystem, type ActionSystemContext } from './action-system/action-system.js';
|
|
16
17
|
export { RecipeFactoryBuilder, type EntityRecipe } from './recipe-system/recipes.js';
|
|
17
18
|
export { RecipeCookerSystem, type AnyRecipeCookerSystem, type RecipeCookerSystemContext, ReplaceRecipeUpdateTag, isReplaceEntityUpdate, type IsReplaceRecipeUpdate, CreateRecipeUpdateTag, isCreateEntityUpdate, type IsCreateRecipeUpdate, } from './recipe-system/recipe-cooker-system.js';
|
|
18
19
|
export { type DomainContextSystems, type AnyDomainContextSystems } from './domain-context-systems.js';
|