@salsita-ai/sdk 0.50.0-develop.bfba230ad7 → 0.50.0-develop.d81d7591c5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application-spec/generate-application/code/common/index.d.ts +1 -0
- package/dist/application-spec/generate-application/code/common/index.js +1 -1
- package/dist/application-spec/generate-application/code/common/project-module-list.d.ts +8 -0
- package/dist/application-spec/generate-application/code/common/project-module-list.js +3 -0
- package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
- package/dist/application-spec/generate-application/code/templates/admin-domain-code.d.ts +1 -2
- package/dist/application-spec/generate-application/code/templates/admin-domain-code.js +6 -14
- package/dist/application-spec/generate-application/code/templates/admin-frontend-code.d.ts +1 -2
- package/dist/application-spec/generate-application/code/templates/admin-frontend-code.js +4 -4
- package/dist/application-spec/generate-application/code/templates/configurator-domain-code.d.ts +1 -2
- package/dist/application-spec/generate-application/code/templates/configurator-domain-code.js +7 -16
- package/dist/application-spec/generate-application/code/templates/configurator-frontend-code.d.ts +1 -2
- package/dist/application-spec/generate-application/code/templates/configurator-frontend-code.js +7 -9
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-assistant.d.ts +2 -2
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-assistant.js +1 -1
- package/dist/application-spec/generate-application/code/templates/domain-spec.js +4 -4
- package/dist/application-spec/generate-application/code/templates/domain.js +3 -3
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +2 -1
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +1 -2
- package/dist/application-spec/generate-application/code/templates/webhook-builders.js +8 -4
- package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.d.ts +4 -3
- package/dist/application-spec/generate-application/runtime/sections/assistant-runtime.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.d.ts +3 -8
- 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 +9 -43
- 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-server-settings.d.ts +2 -2
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant.d.ts +5 -21
- package/dist/client/phoenix-api.d.ts +58 -30
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +15 -3
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
- package/dist/configurator/ui/assistant/AssistantChips.js +1 -1
- package/dist/configurator/ui/assistant/tool-chip.d.ts +8 -1
- package/dist/configurator/ui/assistant/tool-chip.js +1 -1
- package/dist/docs/complex-use-cases/filtered-controls-with-fix-dialog.mdx +84 -98
- package/dist/docs/complex-use-cases/navigation-reset-selection.mdx +18 -12
- package/dist/docs/index.json +1 -1
- package/dist/docs/layouts/custom-price.mdx +14 -16
- package/dist/docs/layouts/sidebar/tabs.mdx +24 -21
- package/dist/docs/other-features/domain-actions.mdx +1 -1
- package/dist/docs/other-features/side-effects.mdx +42 -34
- package/dist/docs/other-features/transformers.mdx +1 -1
- package/dist/docs/phoenix/admin.mdx +9 -24
- package/dist/docs/phoenix/localization.mdx +3 -22
- package/dist/docs/phoenix/project-structure.mdx +6 -0
- package/dist/docs/recipes-and-delete/recipe-hierarchy-selection.mdx +15 -13
- package/dist/docs/relations/hierarchy.mdx +13 -2
- package/dist/domain/actions/action-factory.d.ts +3 -2
- package/dist/domain/application/application-config.d.ts +25 -75
- package/dist/domain/application/assistant/assistant-manifest.d.ts +61 -0
- package/dist/domain/application/assistant/assistant-resolved-manifest.d.ts +95 -0
- package/dist/domain/application/assistant/assistant-value-type.d.ts +9 -0
- package/dist/domain/application/assistant/assistant-value-type.js +1 -0
- package/dist/domain/application/assistant/build-assistant-manifest.d.ts +4 -0
- package/dist/domain/application/assistant/build-assistant-manifest.js +1 -0
- package/dist/{phoenix/application-spec → domain/application/assistant}/generate-assistant-prompt.d.ts +3 -3
- package/dist/{phoenix/application-spec → domain/application/assistant}/generate-assistant-prompt.js +1 -1
- package/dist/domain/application/assistant/index.d.ts +4 -0
- package/dist/domain/application/assistant/index.js +1 -0
- package/dist/domain/application/assistant-field-options.d.ts +1 -1
- package/dist/domain/application/assistant-mutations.d.ts +1 -1
- package/dist/domain/application/assistant-recipe-groups.d.ts +1 -1
- package/dist/domain/application/configurator-builder.d.ts +33 -18
- package/dist/domain/application/configurator-builder.js +1 -1
- package/dist/domain/application/element-registration.d.ts +5 -0
- package/dist/domain/application/element-registration.js +1 -1
- package/dist/domain/application/handler-registration.d.ts +5 -0
- package/dist/domain/application/handler-registration.js +1 -1
- package/dist/domain/application/index.d.ts +5 -4
- package/dist/domain/application/index.js +1 -1
- package/dist/domain/application/resolve-imported-transformers.d.ts +11 -1
- package/dist/domain/application/resolve-imported-transformers.js +1 -1
- package/dist/domain/components/domain-component-optic.d.ts +3 -0
- package/dist/domain/components/domain-component-optic.js +2 -2
- package/dist/domain/components/system-component-builder.js +1 -1
- package/dist/domain/core/action.d.ts +1 -1
- package/dist/domain/core/component.d.ts +1 -1
- package/dist/domain/core/decoder/create-decoder.d.ts +6 -0
- package/dist/domain/core/decoder/create-decoder.js +1 -0
- package/dist/domain/core/decoder/decoder.d.ts +6 -0
- package/dist/domain/core/decoder/decoder.js +1 -0
- package/dist/domain/core/decoder/index.d.ts +2 -0
- package/dist/domain/core/decoder/index.js +1 -0
- package/dist/domain/core/domain-factory.js +1 -1
- package/dist/domain/core/index.d.ts +1 -3
- package/dist/domain/core/index.js +1 -1
- package/dist/domain/core/reflection.d.ts +1 -1
- package/dist/domain/core/reflection.js +1 -1
- package/dist/domain/core/schema/enhanced-json-schema.js +1 -0
- package/dist/domain/core/schema/extended-schema-validator.js +1 -0
- package/dist/domain/core/schema/index.d.ts +3 -0
- package/dist/domain/core/schema/index.js +1 -0
- package/dist/domain/core/schema/schema-validator.js +1 -0
- package/dist/domain/domain-builder.d.ts +10 -1
- package/dist/domain/domain-builder.js +1 -1
- package/dist/domain/domain-context/action-system/action-system.js +1 -1
- package/dist/domain/domain-context/transformers/chain-builder.d.ts +1 -1
- package/dist/domain/domain-runtime/domain-runtime.d.ts +4 -4
- package/dist/domain/domain-runtime/spec/initialize.js +1 -1
- package/dist/domain/domain-runtime/spec/selectors.d.ts +2 -2
- package/dist/domain/domain-runtime/spec/selectors.js +1 -1
- package/dist/domain/domain-runtime/spec/types.d.ts +3 -3
- package/dist/domain/index.d.ts +3 -2
- package/dist/domain/index.js +1 -1
- package/dist/domain/invariants/invariants.d.ts +9 -0
- package/dist/domain/invariants/invariants.js +1 -1
- package/dist/domain/mocks/create-mock-domain-runtime.d.ts +3 -3
- package/dist/domain/mocks/create-mock-domain-runtime.js +1 -1
- package/dist/domain/project-modules/index.d.ts +1 -0
- package/dist/domain/project-modules/index.js +1 -0
- package/dist/domain/project-modules/project-modules.d.ts +41 -0
- package/dist/domain/project-modules/project-modules.js +1 -0
- package/dist/domain/system-components/common/dimension-indicator-schema.d.ts +1 -1
- package/dist/domain/system-components/common/dimension-indicator-schema.js +1 -1
- package/dist/editor/domain-editors/use-implementation-files.d.ts +7 -6
- 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-cli/gen/configurator-builder.js +21 -8
- package/dist/legacy/domain-cli/utils/cache.d.ts +1 -1
- package/dist/legacy/domain-cli/utils/cache.js +1 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-admin.js +18 -19
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-configurator.js +15 -16
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-admin.js +22 -23
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-configurator.js +15 -16
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/generator-shared.d.ts +7 -2
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/generator-shared.js +8 -12
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/index.d.ts +1 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/index.js +1 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/webhook-builders.js +7 -7
- package/dist/phoenix/application-spec/resolve-deployment-data.d.ts +4 -3
- package/dist/phoenix/application-spec/resolve-deployment-data.js +2 -2
- package/dist/phoenix/commands/prepare-deployment-command.js +2 -2
- package/dist/phoenix/commands/prepare-local-environment-command.js +1 -1
- package/dist/phoenix/services/prepare-development-environment.js +1 -1
- package/dist/phoenix/services/variant-file-session.js +1 -1
- package/dist/react-sdk/application-runtime/hooks/use-domain-application-props.d.ts +5 -2
- package/dist/react-sdk/application-runtime/hooks/use-spec.d.ts +1 -1
- package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.d.ts +1 -1
- package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.js +1 -1
- package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +4 -4
- package/dist/webhook/builders/common.d.ts +3 -0
- package/dist/webhook/builders/webhook-builder.d.ts +1 -1
- package/dist/webhook/builders/webhook-builder.js +1 -1
- package/package.json +3 -3
- package/dist/domain/core/json-schema.js +0 -1
- /package/dist/domain/{core/enhanced-json-schema.js → application/assistant/assistant-manifest.js} +0 -0
- /package/dist/domain/{core/schema-validator.js → application/assistant/assistant-resolved-manifest.js} +0 -0
- /package/dist/domain/core/{schema-validator-ajv.d.ts → schema/create-ajv-schema-validator.d.ts} +0 -0
- /package/dist/domain/core/{schema-validator-ajv.js → schema/create-ajv-schema-validator.js} +0 -0
- /package/dist/domain/core/{schema-validator-csp.d.ts → schema/create-csp-schema-validator.d.ts} +0 -0
- /package/dist/domain/core/{schema-validator-csp.js → schema/create-csp-schema-validator.js} +0 -0
- /package/dist/domain/core/{enhanced-json-schema.d.ts → schema/enhanced-json-schema.d.ts} +0 -0
- /package/dist/domain/core/{json-schema.d.ts → schema/extended-schema-validator.d.ts} +0 -0
- /package/dist/domain/core/{schema-validator.d.ts → schema/schema-validator.d.ts} +0 -0
|
@@ -18,7 +18,7 @@ The `createResetSelectionOnNavigationTransformer` automatically deselects entiti
|
|
|
18
18
|
|
|
19
19
|
## Guide
|
|
20
20
|
|
|
21
|
-
The `createResetSelectionOnNavigationTransformer` is added
|
|
21
|
+
The `createResetSelectionOnNavigationTransformer` is added as a file in `src/transformers/`. It automatically injects a deselect update when navigating to specified states.
|
|
22
22
|
|
|
23
23
|
### Step 1: Import the transformer
|
|
24
24
|
|
|
@@ -28,19 +28,25 @@ Import the transformer function from the domain package:
|
|
|
28
28
|
import { createResetSelectionOnNavigationTransformer } from '@salsita-ai/sdk/domain'
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
### Step 2: Add the transformer to your
|
|
31
|
+
### Step 2: Add the transformer to your project
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Create the transformer in a file under `src/transformers/`:
|
|
34
34
|
|
|
35
35
|
```typescript
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
// src/transformers/reset-selection.ts
|
|
37
|
+
import { createResetSelectionOnNavigationTransformer } from '@salsita-ai/sdk/domain'
|
|
38
|
+
|
|
39
|
+
export default phx.frontend.createTransformer(ctx =>
|
|
40
|
+
createResetSelectionOnNavigationTransformer([phx.applicationTypes.NavigationState.SecondStep], ctx)
|
|
41
|
+
)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Each file in `src/transformers/` default-exports one transformer and is picked up by its location. The `transformers` section of the spec turns it on by name. For a transformer made with `build(name)` that is the name passed to `build(...)`, which must match the file name with case and dashes ignored (`fix-finish.ts` and `fixFinish` match). For a plain-function export it is the file name:
|
|
45
|
+
|
|
46
|
+
```yaml
|
|
47
|
+
# spec/application.yaml
|
|
48
|
+
transformers:
|
|
49
|
+
- name: reset-selection
|
|
44
50
|
```
|
|
45
51
|
|
|
46
52
|
The transformer takes two arguments:
|
|
@@ -97,7 +103,7 @@ When the transformer triggers, any selected entity is deselected automatically.
|
|
|
97
103
|
*
|
|
98
104
|
* @param navigationStates - Array of navigation state names that trigger deselection
|
|
99
105
|
* @param ctx - Domain context providing access to the navigation system
|
|
100
|
-
* @returns Update transformer
|
|
106
|
+
* @returns Update transformer to return from a transformer file in src/transformers/
|
|
101
107
|
*
|
|
102
108
|
* @example
|
|
103
109
|
* // Deselect when entering the summary step
|
package/dist/docs/index.json
CHANGED
|
@@ -78,24 +78,22 @@ Your custom component has full access to the Material-UI theme and SDK utilities
|
|
|
78
78
|
|
|
79
79
|
### Step 3: Attach the component to your entity
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
Attach your custom price component to the root entity in a file under `src/components/`. The generated code picks the
|
|
82
|
+
file up by its location and registers its default export:
|
|
82
83
|
|
|
83
84
|
```typescript
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
),
|
|
97
|
-
])
|
|
98
|
-
.buildConfig()
|
|
85
|
+
// src/components/custom-price.tsx
|
|
86
|
+
export default phx.domain.attachComponent
|
|
87
|
+
.withEntity('Scene')
|
|
88
|
+
.withComponent(customPriceFooterComponent, 'default')
|
|
89
|
+
.attach(
|
|
90
|
+
memoEval(
|
|
91
|
+
(s) => [s.$price],
|
|
92
|
+
(price) => ({
|
|
93
|
+
node: <AppPrice price={price} />,
|
|
94
|
+
})
|
|
95
|
+
)
|
|
96
|
+
)
|
|
99
97
|
```
|
|
100
98
|
|
|
101
99
|
The `memoEval` function takes two arguments:
|
|
@@ -179,27 +179,30 @@ When a selected entity has no `sidebarTabs`, its property pages replace the root
|
|
|
179
179
|
You can use transformers to automatically navigate to specific tabs when entities are selected or deselected:
|
|
180
180
|
|
|
181
181
|
```typescript
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
182
|
+
// src/transformers/bucky-ball-tab.ts
|
|
183
|
+
export default phx.frontend.transformerBuilder.when
|
|
184
|
+
.entity(['BuckyBall'])
|
|
185
|
+
.selected()
|
|
186
|
+
.then.navigateTo('BuckyBallTab1')
|
|
187
|
+
.build('buckyBallTab')
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
// src/transformers/tab.ts
|
|
192
|
+
export default phx.frontend.transformerBuilder.when
|
|
193
|
+
.entity(['BuckyBall'])
|
|
194
|
+
.deselected()
|
|
195
|
+
.then.navigateTo('tab1')
|
|
196
|
+
.build('tab')
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Each file in `src/transformers/` default-exports one transformer and is picked up by its location. The `transformers` section of the spec turns it on by name. For a transformer made with `build(name)` that is the name passed to `build(...)`, which must match the file name with case and dashes ignored (`fix-finish.ts` and `fixFinish` match). For a plain-function export it is the file name:
|
|
200
|
+
|
|
201
|
+
```yaml
|
|
202
|
+
# spec/application.yaml
|
|
203
|
+
transformers:
|
|
204
|
+
- name: buckyBallTab
|
|
205
|
+
- name: tab
|
|
203
206
|
```
|
|
204
207
|
|
|
205
208
|
This creates smooth navigation flows where selecting specific entities automatically switches to their relevant tabs, and deselecting returns to a default tab state.
|
|
@@ -83,7 +83,7 @@ export default phx.domain.implementActions({
|
|
|
83
83
|
})
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
Throw to reject a call: the message reaches the user through the control's hint and the assistant through the failed mutation, so say what went wrong and what to send instead. An
|
|
86
|
+
Throw to reject a call: the message reaches the user through the control's hint and the assistant through the failed mutation, so say what went wrong and what to send instead. An implementation of a name the spec does not declare is a type error. A declared action without an implementation is not: it stops the domain from initializing, and under `phoenix dev` the editor reports it as a `MISSING_ACTION_IMPLEMENTATIONS` diagnostic and does not apply the change; an implementation of an undeclared name is logged.
|
|
87
87
|
|
|
88
88
|
## Run it from the UI
|
|
89
89
|
|
|
@@ -66,40 +66,48 @@ With following control structure. The top input selects the material, the bottom
|
|
|
66
66
|
The transformer is used to change the finish if necessary and show the notification.
|
|
67
67
|
|
|
68
68
|
```typescript
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
.
|
|
69
|
+
// src/transformers/fix-finish.ts
|
|
70
|
+
import { msg } from '@lingui/core/macro'
|
|
71
|
+
|
|
72
|
+
import { availableMaterials } from '../_shared/materials.js'
|
|
73
|
+
|
|
74
|
+
export default phx.frontend.transformerBuilder.when
|
|
75
|
+
.entity(['Plate'])
|
|
76
|
+
.modified({ atFields: ['material'] })
|
|
77
|
+
.causes.self.violation(['finishNotAvailable'])
|
|
78
|
+
.then.applySideEffect(({ update, getOld$Entity }) => {
|
|
79
|
+
const oldPlate = getOld$Entity()
|
|
80
|
+
const newMaterial = update.stateDelta.material
|
|
81
|
+
|
|
82
|
+
const validMaterial =
|
|
83
|
+
availableMaterials.find(m => m.material === newMaterial && m.finish === oldPlate.finish) ??
|
|
84
|
+
availableMaterials.find(m => m.material === newMaterial)
|
|
85
|
+
|
|
86
|
+
if (!validMaterial || validMaterial.finish === oldPlate.finish) {
|
|
87
|
+
return []
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// create an additional update that will fix the material finish
|
|
91
|
+
const fixUpdate = phx.frontend.updates.DomainEntityModification({
|
|
92
|
+
entityId: oldPlate.id,
|
|
93
|
+
stateDelta: {
|
|
94
|
+
finish: validMaterial.finish,
|
|
95
|
+
},
|
|
96
|
+
updateTag: 'fix.finish',
|
|
97
|
+
hint: msg`Material finish was adjusted`, // specify a hint for the user (side effect)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
return [fixUpdate]
|
|
101
|
+
})
|
|
102
|
+
.build('fix-finish')
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Each file in `src/transformers/` default-exports one transformer and is picked up by its location. The `transformers` section of the spec turns it on by name. For a transformer made with `build(name)` that is the name passed to `build(...)`, which must match the file name with case and dashes ignored (`fix-finish.ts` and `fixFinish` match). For a plain-function export it is the file name:
|
|
106
|
+
|
|
107
|
+
```yaml
|
|
108
|
+
# spec/application.yaml
|
|
109
|
+
transformers:
|
|
110
|
+
- name: fix-finish
|
|
103
111
|
```
|
|
104
112
|
|
|
105
113
|
### Hints and the AI assistant
|
|
@@ -102,7 +102,7 @@ export const removeExtraneousBranchesAndLeavesWhenShortened = phx.frontend.trans
|
|
|
102
102
|
- With `overrideMatchinUpdates(ctx => /* side effect updates */)` the updates returned by the provided callback will replace the original **matched update**. This will be triggered for every matching update. Note that this action is not available in events which are not bound to a specific update - such as a violation check without a defined cause.
|
|
103
103
|
- With `overrideAllUpdates(ctx => /* side effect updates */)` the updates returned by the provided callback will replace all original updates. This will be triggered only once for a single run of the transformer. This allows for implementation of transformers that behave similarly as the raw `UpdateTransformer`
|
|
104
104
|
- High-level actions: `select`, `deselect`, `navigate`, `changeView` - more on these in the other examples.
|
|
105
|
-
- `build(name)` is the final step to create the transformer.
|
|
105
|
+
- `build(name)` is the final step to create the transformer. The name identifies the transformer while tracing, and it is the name the `transformers` section of the spec refers to, so it must match the file name with case and dashes ignored (`fix-finish.ts` and `fixFinish` match). Note that this returns a `RegistrableTransformer`. Default-export it from a file in `src/transformers/` and list the name passed to `build(...)` in the `transformers` section of the spec; the generated code registers it. The shorter snippets on this page use descriptive names for readability; the complete implementation below uses names that match its files.
|
|
106
106
|
|
|
107
107
|
### Side-Effect on Update Causing Another Entity's Violation
|
|
108
108
|
|
|
@@ -427,43 +427,28 @@ For technical details about data transformation and storage, see [Data Sources -
|
|
|
427
427
|
|
|
428
428
|
## Web Component Integration
|
|
429
429
|
|
|
430
|
-
Admin functionality
|
|
430
|
+
Admin functionality is part of the same application as the configurator and needs no separate web component setup.
|
|
431
431
|
|
|
432
|
-
###
|
|
432
|
+
### Registering Admin Components
|
|
433
433
|
|
|
434
|
-
|
|
434
|
+
The frontend entry is generated into `.phoenix/`, so a project never calls the configurator builder itself. Every file
|
|
435
|
+
in `src/admin/components/` is picked up by its location and its default export is registered as admin components:
|
|
435
436
|
|
|
436
437
|
```typescript
|
|
437
438
|
// src/admin/components/admin-components.tsx
|
|
438
|
-
|
|
439
|
-
import { customAdminOptics } from './optics.js'
|
|
440
|
-
import { NotAuthenticatedPage } from '../pages/NotAuthenticatedPage.js'
|
|
441
|
-
|
|
442
|
-
const config = configuratorBuilder
|
|
443
|
-
.withComponentOptics(customConfiguratorComponents)
|
|
444
|
-
.withAdminComponentOptics(customAdminOptics) // Register admin components
|
|
445
|
-
.buildConfig({
|
|
446
|
-
deploymentId: phx.runtimeConfig.DEPLOYMENT_ID,
|
|
447
|
-
persistence: {
|
|
448
|
-
type: 'server',
|
|
449
|
-
serverUrl: phx.runtimeConfig.SERVER_URL,
|
|
450
|
-
},
|
|
451
|
-
ui: {
|
|
452
|
-
notAuthenticatedPage: <NotAuthenticatedPage />, // Show when user not authenticated
|
|
453
|
-
},
|
|
454
|
-
// ... other config
|
|
455
|
-
})
|
|
439
|
+
// ... customAdminOptics as defined in the example above
|
|
456
440
|
|
|
457
|
-
|
|
441
|
+
export default customAdminOptics
|
|
458
442
|
```
|
|
459
443
|
|
|
460
|
-
|
|
444
|
+
The page shown to a user who is not authenticated is an element. Create it with
|
|
445
|
+
`phx.frontend.createNotAuthenticatedPage(...)` in a file under `src/elements/`.
|
|
461
446
|
|
|
462
447
|
### Built-in Admin Integration
|
|
463
448
|
|
|
464
449
|
Phoenix automatically provides admin functionality when:
|
|
465
450
|
|
|
466
|
-
1. Admin components are
|
|
451
|
+
1. Admin components are default-exported from files in `src/admin/components/`
|
|
467
452
|
2. Admin configuration exists in `phoenix.config.ts`
|
|
468
453
|
3. User has admin session token
|
|
469
454
|
|
|
@@ -116,28 +116,9 @@ After running `pnpm lingui:compile`, your custom translations will override the
|
|
|
116
116
|
- Adapt translations for your target audience
|
|
117
117
|
- Maintain consistency with your existing product language
|
|
118
118
|
|
|
119
|
-
**Frontend integration**:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
import { configuratorBuilder } from 'project-domain'
|
|
123
|
-
import { createI18n } from 'project-i18n'
|
|
124
|
-
|
|
125
|
-
const i18n = createI18n()
|
|
126
|
-
|
|
127
|
-
export const config = configuratorBuilder
|
|
128
|
-
.withComponentOptics(customComponents)
|
|
129
|
-
.withPresets(presets)
|
|
130
|
-
.withI18n(i18n) // Register i18n service with configurator
|
|
131
|
-
.buildConfig({
|
|
132
|
-
features: {
|
|
133
|
-
availableLocales: ['en', 'de', 'cs'],
|
|
134
|
-
},
|
|
135
|
-
services: {
|
|
136
|
-
logger,
|
|
137
|
-
},
|
|
138
|
-
// ... other configuration
|
|
139
|
-
})
|
|
140
|
-
```
|
|
119
|
+
**Frontend integration**: the generated `.phoenix` code creates the i18n service from `.phoenix/i18n.ts` and registers
|
|
120
|
+
it with the application, so there is nothing to wire by hand. The languages come from `availableLocales` in
|
|
121
|
+
`spec/application.yaml`.
|
|
141
122
|
|
|
142
123
|
## Working with YAML Domain Specifications
|
|
143
124
|
|
|
@@ -49,6 +49,12 @@ project-root/
|
|
|
49
49
|
| `locales/` | Locale catalogs (`.po` sources; compiled `.ts`, do not edit) |
|
|
50
50
|
| `_*` | Shared code folders at any depth (not auto-imported) |
|
|
51
51
|
|
|
52
|
+
Every file in `components/`, `elements/`, `expressions/`, `actions/`, `invariants/`, `transformers/` and `handlers/`
|
|
53
|
+
(and their `admin/` counterparts) is imported by its location, so its default export must be what that folder's `phx`
|
|
54
|
+
factory returns, or an array of those. A file that exports anything else, such as a plain React component in
|
|
55
|
+
`elements/`, stops the application at start with an `Invalid default export in <file>` error that names the expected
|
|
56
|
+
shape. Keep plain components and helpers in a `_*` folder.
|
|
57
|
+
|
|
52
58
|
### Admin Folders (src/admin/)
|
|
53
59
|
|
|
54
60
|
The `admin/` folder supports these admin-specific categories:
|
|
@@ -160,21 +160,23 @@ Room: {
|
|
|
160
160
|
|
|
161
161
|
### Entity Replacement Transformer
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
Add a transformer to handle entity deselection when replacement occurs. This ensures clean state transitions:
|
|
164
164
|
|
|
165
165
|
```typescript
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
166
|
+
// src/transformers/deselect-special.ts
|
|
167
|
+
export default phx.frontend.transformerBuilder.when
|
|
168
|
+
.entity(['RedSpecialConsole', 'BlueSpecialConsole'])
|
|
169
|
+
.replacedWith(['RedSpecialConsole', 'BlueSpecialConsole'])
|
|
170
|
+
.then.deselect()
|
|
171
|
+
.build('deselect-special')
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Each file in `src/transformers/` default-exports one transformer and is picked up by its location. The `transformers` section of the spec turns it on by name. For a transformer made with `build(name)` that is the name passed to `build(...)`, which must match the file name with case and dashes ignored (`fix-finish.ts` and `fixFinish` match). For a plain-function export it is the file name:
|
|
175
|
+
|
|
176
|
+
```yaml
|
|
177
|
+
# spec/application.yaml
|
|
178
|
+
transformers:
|
|
179
|
+
- name: deselect-special
|
|
178
180
|
```
|
|
179
181
|
|
|
180
182
|
### Initial Configuration
|
|
@@ -69,8 +69,19 @@ relations:
|
|
|
69
69
|
|
|
70
70
|
Consider enabling select-parent-on-deselection to keep selection stable:
|
|
71
71
|
|
|
72
|
-
```
|
|
73
|
-
.
|
|
72
|
+
```typescript
|
|
73
|
+
// src/transformers/select-parent.ts
|
|
74
|
+
import { createSelectParentOnDeselectionTransformer } from '@salsita-ai/sdk/domain'
|
|
75
|
+
|
|
76
|
+
export default createSelectParentOnDeselectionTransformer
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Each file in `src/transformers/` default-exports one transformer and is picked up by its location. The `transformers` section of the spec turns it on by name. For a transformer made with `build(name)` that is the name passed to `build(...)`, which must match the file name with case and dashes ignored (`fix-finish.ts` and `fixFinish` match). For a plain-function export it is the file name:
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
# spec/application.yaml
|
|
83
|
+
transformers:
|
|
84
|
+
- name: select-parent
|
|
74
85
|
```
|
|
75
86
|
|
|
76
87
|
## Example
|
|
@@ -4,7 +4,8 @@ import type { $DomainEntity, DomainEntity } from '../core/model.js';
|
|
|
4
4
|
* Creates the `implementActions` factory the generated `domain-spec.ts` exposes as
|
|
5
5
|
* `phx.domain.implementActions`. A module in `src/actions/` implements any subset of the declared
|
|
6
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
|
|
8
|
-
* the modules
|
|
7
|
+
* is a type error, since its implementation would have to be `never`. The generated barrel lists
|
|
8
|
+
* the modules; `DomainBuilder.withActionModules` merges them, and domain initialization checks that
|
|
9
|
+
* every declared action is implemented.
|
|
9
10
|
*/
|
|
10
11
|
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;
|
|
@@ -6,12 +6,11 @@ import type { Logger } from '@salsita-ai/common/utils';
|
|
|
6
6
|
import type { SessionRole, SessionTokenPayload } from '@salsita-ai/contracts/api';
|
|
7
7
|
import type { CellValue } from '@salsita-ai/contracts/webhook';
|
|
8
8
|
import type { AdminIntegrationService } from '#package/react-sdk';
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type { AnalyticsSystem, DomainContextSystems, TransformerFactory, Transformers } from '../domain-context/index.js';
|
|
9
|
+
import type { $DomainEntity, DomainEntity, DomainFactory, ProductPreset } from '../core/index.js';
|
|
10
|
+
import type { AnalyticsSystem, TransformerFactory } from '../domain-context/index.js';
|
|
12
11
|
import type { RegistrableTransformer } from '../domain-context/transformers/index.js';
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
12
|
+
import type { ProjectModule } from '../project-modules/index.js';
|
|
13
|
+
import type { AssistantResolvedManifest } from './assistant/index.js';
|
|
15
14
|
import type { WebComponentEventDescriptor } from './web-component-event.js';
|
|
16
15
|
import type { WebComponentPropertyDescriptor } from './web-component-property.js';
|
|
17
16
|
export type ImportedTransformer<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> = {
|
|
@@ -22,6 +21,17 @@ export type SpecTransformer = {
|
|
|
22
21
|
name: string;
|
|
23
22
|
priority?: number;
|
|
24
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* The transformers of an application: the `src/transformers/` files as project modules, and the spec's
|
|
26
|
+
* `transformers` section, which selects them by name and orders them by priority. A plain-function
|
|
27
|
+
* export is selected by its file name; a transformer made with `build(name)` by that name, which the spec
|
|
28
|
+
* parser requires to match the file name with case and dashes ignored. The runtime spec resolves the two
|
|
29
|
+
* into the factory the store system calls on every update.
|
|
30
|
+
*/
|
|
31
|
+
export interface TransformersConfig {
|
|
32
|
+
readonly importedTransformers: readonly ProjectModule[];
|
|
33
|
+
readonly specTransformers: readonly SpecTransformer[];
|
|
34
|
+
}
|
|
25
35
|
export interface DataSchemaPrimitiveField {
|
|
26
36
|
readonly type: 'string' | 'number' | 'integer' | 'boolean';
|
|
27
37
|
readonly enum?: ReadonlyArray<string | number>;
|
|
@@ -64,67 +74,6 @@ export type DataSpec = {
|
|
|
64
74
|
export type ChunksSpec = Readonly<Record<string, {
|
|
65
75
|
readonly scope: string;
|
|
66
76
|
}>>;
|
|
67
|
-
/**
|
|
68
|
-
* Where one exposed assistant GraphQL field reads its value on the `$` entity: a stored field name,
|
|
69
|
-
* or an expression name including its `$`. `localized` marks a localizable value that resolves to a
|
|
70
|
-
* string in the current locale.
|
|
71
|
-
*/
|
|
72
|
-
export interface AssistantFieldSource {
|
|
73
|
-
readonly source: string;
|
|
74
|
-
readonly localized?: true;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* One recipe group the assistant manifest exposes on an entity type: a `childEntityRecipes` instance
|
|
78
|
-
* under `childRecipes`, a `replaceEntityRecipes` instance under `replaceRecipes`. `groupId` is the
|
|
79
|
-
* name the agent addresses the group by, `instanceName` the component instance it reads,
|
|
80
|
-
* `description` the manifest's text replacing the component's group description, and `dryRuns`
|
|
81
|
-
* whether the recipes of the group can be dry-run.
|
|
82
|
-
*/
|
|
83
|
-
export interface AssistantRecipeGroup {
|
|
84
|
-
readonly groupId: string;
|
|
85
|
-
readonly instanceName: string;
|
|
86
|
-
readonly description?: string;
|
|
87
|
-
readonly dryRuns: boolean;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* The options edge of one writable field the assistant manifest links to its component. `field` is
|
|
91
|
-
* the delta field of `modify<Type>` the choices are for, `edgeName` the field of `<Type>Meta` that
|
|
92
|
-
* lists them, `componentType` and `instanceName` the component instance they are read from, and
|
|
93
|
-
* `validate` whether `modify<Type>` rejects a value that is not among them, and `dryRuns` whether
|
|
94
|
-
* the choices can be dry-run.
|
|
95
|
-
*/
|
|
96
|
-
export interface AssistantFieldOptions {
|
|
97
|
-
readonly field: string;
|
|
98
|
-
readonly edgeName: string;
|
|
99
|
-
readonly componentType: 'materialSwatch' | 'attributeSelection' | 'distanceDimensionSelect';
|
|
100
|
-
readonly instanceName: string;
|
|
101
|
-
readonly validate: boolean;
|
|
102
|
-
readonly dryRuns: boolean;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Experimental assistant manifest generated from the application spec `assistant` section. `sdl` is
|
|
106
|
-
* the GraphQL schema text prepared at parse time; `fields` maps each GraphQL object type's exposed
|
|
107
|
-
* fields (type name → GraphQL field name) to the stored field or expression its resolvers read;
|
|
108
|
-
* `deletableTypes` lists the entity types the `deleteEntity` mutation may delete, with aliases
|
|
109
|
-
* already expanded, and absent means none; `writableFields` maps, per entity type with a
|
|
110
|
-
* `modify<Type>` mutation, each field of its delta input to the stored property it writes, and
|
|
111
|
-
* absent means no entity type is writable; `childRecipes` lists, per entity type with a `meta` field,
|
|
112
|
-
* the recipe groups `meta { childRecipes }` and `addChild` expose, in manifest order, and absent
|
|
113
|
-
* means none; `replaceRecipes` lists the same for `meta { replaceRecipes }` and `replaceEntity`;
|
|
114
|
-
* `fieldOptions` lists, per entity type, the options edges `meta` exposes for its
|
|
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.
|
|
117
|
-
*/
|
|
118
|
-
export interface AssistantManifest {
|
|
119
|
-
readonly sdl: string;
|
|
120
|
-
readonly fields: Readonly<Record<string, Readonly<Record<string, AssistantFieldSource>>>>;
|
|
121
|
-
readonly deletableTypes?: readonly string[];
|
|
122
|
-
readonly writableFields?: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
123
|
-
readonly childRecipes?: Readonly<Record<string, readonly AssistantRecipeGroup[]>>;
|
|
124
|
-
readonly replaceRecipes?: Readonly<Record<string, readonly AssistantRecipeGroup[]>>;
|
|
125
|
-
readonly fieldOptions?: Readonly<Record<string, readonly AssistantFieldOptions[]>>;
|
|
126
|
-
readonly actions?: Readonly<Record<string, string>>;
|
|
127
|
-
}
|
|
128
77
|
export type AdminPagesSpec = {
|
|
129
78
|
readonly presets?: boolean | {
|
|
130
79
|
readonly categoryNavigationState?: string;
|
|
@@ -171,9 +120,11 @@ export interface DomainConfig<ENTITIES extends DomainEntity<string>, ALLOWED_ROO
|
|
|
171
120
|
*/
|
|
172
121
|
readonly domainFactory: DomainFactory<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
|
|
173
122
|
/**
|
|
174
|
-
* Components attached to the domain used for the Application to work
|
|
123
|
+
* Components attached to the domain used for the Application to work, as project modules: the
|
|
124
|
+
* `src/components/` files and the optics a generated file lists. The runtime spec validates and
|
|
125
|
+
* flattens them.
|
|
175
126
|
*/
|
|
176
|
-
readonly componentOptics:
|
|
127
|
+
readonly componentOptics: readonly ProjectModule[];
|
|
177
128
|
/**
|
|
178
129
|
* List of languages that the user will be able to provide in multi-lingual text fields in the Admin UI
|
|
179
130
|
*/
|
|
@@ -352,15 +303,14 @@ export interface ApplicationConfig<ENTITIES extends DomainEntity<string>, ALLOWE
|
|
|
352
303
|
readonly chunks?: ChunksSpec;
|
|
353
304
|
readonly dataSpec?: DataSpec;
|
|
354
305
|
readonly publishedDataHash?: string;
|
|
355
|
-
readonly assistant?:
|
|
356
|
-
/**
|
|
357
|
-
|
|
358
|
-
*/
|
|
359
|
-
readonly createTransformers?: (ctx: DomainContextSystems<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>) => Transformers<ENTITIES>;
|
|
306
|
+
readonly assistant?: AssistantResolvedManifest | null;
|
|
307
|
+
/** The project's transformers; the runtime spec validates the files and builds the store's transformer factory from them. */
|
|
308
|
+
readonly transformers?: TransformersConfig;
|
|
360
309
|
readonly adminNavigation?: AdminNavigationConfig<ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES> | undefined;
|
|
361
310
|
readonly adminDomain: DomainConfig<ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
|
|
362
|
-
|
|
363
|
-
readonly
|
|
311
|
+
/** The `src/handlers/` and `src/elements/` files as project modules; the runtime spec validates and flattens both. */
|
|
312
|
+
readonly handlers: readonly ProjectModule[];
|
|
313
|
+
readonly elements: readonly ProjectModule[];
|
|
364
314
|
readonly mount: MountConfig<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, CHAT_CONTEXT, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES>;
|
|
365
315
|
}
|
|
366
316
|
export {};
|