@salsita-ai/sdk 0.50.0-develop.da8d27f5d7 → 0.50.0-develop.ea458ea381
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/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/index.d.ts +6 -6
- package/dist/application-spec/generate-application/code/templates/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/agents-md.js +2 -0
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-cli-skill.js +1 -0
- package/dist/application-spec/generate-application/code/templates/{phoenix-create-configurator-skill.d.ts → skills/phoenix-create-configurator-skill.d.ts} +1 -1
- package/dist/application-spec/generate-application/code/templates/{phoenix-create-configurator-skill.js → skills/phoenix-create-configurator-skill.js} +1 -1
- package/dist/application-spec/generate-application/code/templates/{phoenix-feedback-skill.js → skills/phoenix-feedback-skill.js} +1 -1
- package/dist/application-spec/generate-application/code/templates/{phoenix-review-skill.js → skills/phoenix-review-skill.js} +6 -4
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill.js +1 -0
- package/dist/application-spec/generate-application/code/templates/{common → skills}/sdk-content.d.ts +24 -1
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +67 -0
- 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/client/phoenix-api.d.ts +5 -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/assistant/use-assistant-chat.js +1 -1
- package/dist/docs/index.json +12 -2
- package/dist/docs/other-features/domain-actions.mdx +418 -0
- package/dist/docs/phoenix/best-practices.mdx +1 -0
- package/dist/docs/phoenix/migrations.mdx +45 -5
- package/dist/docs/phoenix/phoenix-cli.mdx +5 -3
- package/dist/docs/phoenix/project-structure.mdx +3 -0
- package/dist/docs/phoenix/sdk-builder-workflow.mdx +6 -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/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/phoenix/application-spec/generate-assistant-prompt.d.ts +2 -2
- package/dist/phoenix/application-spec/generate-assistant-prompt.js +1 -1
- package/dist/phoenix/commands/deploy.js +2 -2
- package/dist/phoenix/commands/login.d.ts +24 -6
- package/dist/phoenix/commands/login.js +2 -2
- 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/package.json +3 -3
- package/dist/application-spec/generate-application/code/templates/agents-md.js +0 -2
- package/dist/application-spec/generate-application/code/templates/common/sdk-content.js +0 -67
- package/dist/application-spec/generate-application/code/templates/phoenix-cli-skill.js +0 -1
- package/dist/application-spec/generate-application/code/templates/phoenix-skill.js +0 -1
- package/dist/configurator/assistant/browser-details.js +0 -1
- package/dist/configurator/assistant/graphql-tools.js +0 -1
- /package/dist/application-spec/generate-application/code/templates/{common → skills}/agent-skill.d.ts +0 -0
- /package/dist/application-spec/generate-application/code/templates/{common → skills}/agent-skill.js +0 -0
- /package/dist/application-spec/generate-application/code/templates/{agents-md.d.ts → skills/agents-md.d.ts} +0 -0
- /package/dist/application-spec/generate-application/code/templates/{phoenix-cli-skill.d.ts → skills/phoenix-cli-skill.d.ts} +0 -0
- /package/dist/application-spec/generate-application/code/templates/{phoenix-feedback-skill.d.ts → skills/phoenix-feedback-skill.d.ts} +0 -0
- /package/dist/application-spec/generate-application/code/templates/{phoenix-review-skill.d.ts → skills/phoenix-review-skill.d.ts} +0 -0
- /package/dist/application-spec/generate-application/code/templates/{phoenix-skill.d.ts → skills/phoenix-skill.d.ts} +0 -0
|
@@ -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';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{NoopAnalyticsSystem}from"./analytics-system/analytics-system.js";export{AnalyticsEventFactory,AnalyticsEventType}from"./analytics-system/analytics-contracts.js";export{NavigationUpdateTag,isInitialNavigationUpdate,isNavigationUpdate,isInitialViewUpdate,isViewUpdate,isInitialSelectionUpdate,isSelectUpdate,isDeselectUpdate,isInitialFullscreenUpdate,isToggleFullscreenUpdate,isInitialDebugUpdate,isInitialViewportUpdate,isSetViewportUpdate,isInitialDragUpdate,isDragStartUpdate,isDragEndUpdate,isInitialToolUpdate,isToolUpdate,isExportUpdate}from"./navigation-system/navigation-updates.js";export{createAutoSelectionTransformer,NavigationSystem}from"./navigation-system/navigation-system.js";export{createResetSelectionOnNavigationTransformer,createNavigationOnSelectionTransformer,createNavigationOnDeselectTransformer,createSelectParentOnDeselectionTransformer,createNavigationOnSelectionChangeTransformer}from"./navigation-system/selection-transformers.js";export{StoreSystem}from"./store-system/store-system.js";export{nextDomainEntityId,getIdSequence}from"./store-system/next-domain-entity-id.js";export{applyUpdates}from"./store-system/apply-updates.js";export{SystemState,SystemStateInitialUpdateTag,SystemStateUpdateTag}from"./store-system/system-state.js";export{createRefReplaceTransformer}from"./relation-transformers/replace-refs.js";export{createCascadeDeletesTransformer}from"./relation-transformers/cascade-deletes.js";export{createCascadeRefPruningTransformer}from"./relation-transformers/cascade-ref-pruning.js";export{createCreateEntityRefsTransformer}from"./relation-transformers/create-entity-refs.js";export{UndoSystem,UNDO_REDO_RESET_TAG,isUndoRedoReset}from"./undo-system.js";export{DimensionSystem}from"./dimension-system/dimension-system.js";export{RecipeFactoryBuilder}from"./recipe-system/recipes.js";export{RecipeCookerSystem,ReplaceRecipeUpdateTag,isReplaceEntityUpdate,CreateRecipeUpdateTag,isCreateEntityUpdate}from"./recipe-system/recipe-cooker-system.js";export{createTransformer}from"./create-transformer.js";export*from"./transformers/index.js";
|
|
1
|
+
export{NoopAnalyticsSystem}from"./analytics-system/analytics-system.js";export{AnalyticsEventFactory,AnalyticsEventType}from"./analytics-system/analytics-contracts.js";export{NavigationUpdateTag,isInitialNavigationUpdate,isNavigationUpdate,isInitialViewUpdate,isViewUpdate,isInitialSelectionUpdate,isSelectUpdate,isDeselectUpdate,isInitialFullscreenUpdate,isToggleFullscreenUpdate,isInitialDebugUpdate,isInitialViewportUpdate,isSetViewportUpdate,isInitialDragUpdate,isDragStartUpdate,isDragEndUpdate,isInitialToolUpdate,isToolUpdate,isExportUpdate}from"./navigation-system/navigation-updates.js";export{createAutoSelectionTransformer,NavigationSystem}from"./navigation-system/navigation-system.js";export{createResetSelectionOnNavigationTransformer,createNavigationOnSelectionTransformer,createNavigationOnDeselectTransformer,createSelectParentOnDeselectionTransformer,createNavigationOnSelectionChangeTransformer}from"./navigation-system/selection-transformers.js";export{StoreSystem}from"./store-system/store-system.js";export{nextDomainEntityId,getIdSequence}from"./store-system/next-domain-entity-id.js";export{applyUpdates}from"./store-system/apply-updates.js";export{SystemState,SystemStateInitialUpdateTag,SystemStateUpdateTag}from"./store-system/system-state.js";export{createRefReplaceTransformer}from"./relation-transformers/replace-refs.js";export{createCascadeDeletesTransformer}from"./relation-transformers/cascade-deletes.js";export{createCascadeRefPruningTransformer}from"./relation-transformers/cascade-ref-pruning.js";export{createCreateEntityRefsTransformer}from"./relation-transformers/create-entity-refs.js";export{UndoSystem,UNDO_REDO_RESET_TAG,isUndoRedoReset}from"./undo-system.js";export{DimensionSystem}from"./dimension-system/dimension-system.js";export{ActionSystem}from"./action-system/action-system.js";export{RecipeFactoryBuilder}from"./recipe-system/recipes.js";export{RecipeCookerSystem,ReplaceRecipeUpdateTag,isReplaceEntityUpdate,CreateRecipeUpdateTag,isCreateEntityUpdate}from"./recipe-system/recipe-cooker-system.js";export{createTransformer}from"./create-transformer.js";export*from"./transformers/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createCascadeDeletesTransformer as e}from"../../domain-context/relation-transformers/cascade-deletes.js";import{createCascadeRefPruningTransformer as t}from"../../domain-context/relation-transformers/cascade-ref-pruning.js";import{createCreateEntityRefsTransformer as s}from"../../domain-context/relation-transformers/create-entity-refs.js";import{createRefReplaceTransformer as r}from"../../domain-context/relation-transformers/replace-refs.js";import{createAutoSnapTransformer as n}from"../../domain-context/transformers/auto-snap-transformer.js";export class DomainContext{_context;_connected=!1;_activeCreateTransformers=void 0;_userTransformerUnregisters=[];_lastExpressionContext=null;_lastDomainExpressions=null;_lastComponentReaderIndexes=null;_lastLoadedData=null;constructor(e){this._context=e}initialize(){let{selectors:o,actions:a,getExtensionSystems:i}=this._context;this._assertSchemaCoherence();let m=o.getStoreSystem();try{for(let i of(a.setInitializationContext(o.getNextInitializationContext()),this._connected||(m.registerTransformer(10,e(o.getCompositionProjections()),"CascadeDeletes"),m.registerTransformer(20,t(o.getComponentReader()),"CascadeRefPruning"),m.registerTransformer(25,s(o.getComponentReader()),"CreateEntityRefs"),m.registerTransformer(30,r(o.getComponentReader()),"RefReplace"),m.registerTransformer(40,n(o.getComponentReader(),o.getSnappingProjections(),o.getDimensionSystem(),o.getPositionProjections(),m),"AutoSnap"),this._connected=!0),this._reconcileUserTransformers(),[m,o.getUndoSystem()]))i.initialize();for(let e of(m.stageAndCommit(o.getDimensionSystem().initialize(m.stateSlices.committed.value.state)),[o.getNavigationSystem(),...i()]))e.initialize();this._lastExpressionContext=o.getExpressionContext(),this._lastDomainExpressions=o.getDomainExpressions(),this._lastComponentReaderIndexes=o.getComponentReaderIndexes(),this._lastLoadedData=o.getLoadedData(),a.completeInitialization()}catch(e){throw a.failInitialization(),e}}reconcile=()=>{this._context.selectors.getInitializationState().isCurrent&&(this._reconcileUserTransformers(),this._refreshIfLoadedDataChanged(),this._refreshIfExpressionContextChanged())};_assertSchemaCoherence(){switch(this._context.selectors.getSchemaCoherence()){case"coherent":return;case"missing-stamp":throw Error("Cannot initialize the domain context: the loaded data carries no schema identity.");case"schema-mismatch":throw Error("Cannot initialize the domain context: the loaded data belongs to a different schema identity than the active spec.")}}_registerUserTransformers(e){let t=this._context.selectors.getStoreSystem();for(let s of e)this._userTransformerUnregisters.push(t.registerTransformer(s.priority,s.transformer,s.name??"Anonymous"))}_unregisterUserTransformers(){for(let e of this._userTransformerUnregisters)e();this._userTransformerUnregisters=[]}_reconcileUserTransformers(){let e=this._context.selectors.getCreateTransformers();if(this._activeCreateTransformers===e)return;let t=e?.(this._context.selectors.getDomainSystems())??[];this._unregisterUserTransformers(),this._activeCreateTransformers=e,this._registerUserTransformers(t)}_refreshIfExpressionContextChanged(){let{selectors:e}=this._context,t=e.getExpressionContext(),s=e.getDomainExpressions(),r=e.getComponentReaderIndexes();if(this._lastExpressionContext===t&&this._lastDomainExpressions===s&&this._lastComponentReaderIndexes===r)return;let n=e.getStoreSystem();n.reset(n.stateSlices.committed.value.state,"expressionContextRefreshed"),this._lastExpressionContext=t,this._lastDomainExpressions=s,this._lastComponentReaderIndexes=r}_refreshIfLoadedDataChanged(){let{selectors:e}=this._context,t=e.getLatestLoadedData();null!==t&&this._lastLoadedData!==t&&(e.getStoreSystem().reset(e.getInitialDomainState(),"loadedDataRefreshed"),this._lastLoadedData=t)}}
|
|
1
|
+
import{createCascadeDeletesTransformer as e}from"../../domain-context/relation-transformers/cascade-deletes.js";import{createCascadeRefPruningTransformer as t}from"../../domain-context/relation-transformers/cascade-ref-pruning.js";import{createCreateEntityRefsTransformer as s}from"../../domain-context/relation-transformers/create-entity-refs.js";import{createRefReplaceTransformer as r}from"../../domain-context/relation-transformers/replace-refs.js";import{createAutoSnapTransformer as n}from"../../domain-context/transformers/auto-snap-transformer.js";export class DomainContext{_context;_connected=!1;_activeCreateTransformers=void 0;_userTransformerUnregisters=[];_lastExpressionContext=null;_lastDomainExpressions=null;_lastComponentReaderIndexes=null;_lastLoadedData=null;constructor(e){this._context=e}initialize(){let{selectors:o,actions:a,getExtensionSystems:i}=this._context;this._assertSchemaCoherence();let m=o.getStoreSystem();try{for(let i of(a.setInitializationContext(o.getNextInitializationContext()),this._connected||(m.registerTransformer(10,e(o.getCompositionProjections()),"CascadeDeletes"),m.registerTransformer(20,t(o.getComponentReader()),"CascadeRefPruning"),m.registerTransformer(25,s(o.getComponentReader()),"CreateEntityRefs"),m.registerTransformer(30,r(o.getComponentReader()),"RefReplace"),m.registerTransformer(40,n(o.getComponentReader(),o.getSnappingProjections(),o.getDimensionSystem(),o.getPositionProjections(),m),"AutoSnap"),this._connected=!0),this._reconcileUserTransformers(),[m,o.getUndoSystem()]))i.initialize();for(let e of(m.stageAndCommit(o.getDimensionSystem().initialize(m.stateSlices.committed.value.state)),[o.getNavigationSystem(),...i()]))e.initialize();o.getActionImplementations(),this._lastExpressionContext=o.getExpressionContext(),this._lastDomainExpressions=o.getDomainExpressions(),this._lastComponentReaderIndexes=o.getComponentReaderIndexes(),this._lastLoadedData=o.getLoadedData(),a.completeInitialization()}catch(e){throw a.failInitialization(),e}}reconcile=()=>{this._context.selectors.getInitializationState().isCurrent&&(this._reconcileUserTransformers(),this._refreshIfLoadedDataChanged(),this._refreshIfExpressionContextChanged())};_assertSchemaCoherence(){switch(this._context.selectors.getSchemaCoherence()){case"coherent":return;case"missing-stamp":throw Error("Cannot initialize the domain context: the loaded data carries no schema identity.");case"schema-mismatch":throw Error("Cannot initialize the domain context: the loaded data belongs to a different schema identity than the active spec.")}}_registerUserTransformers(e){let t=this._context.selectors.getStoreSystem();for(let s of e)this._userTransformerUnregisters.push(t.registerTransformer(s.priority,s.transformer,s.name??"Anonymous"))}_unregisterUserTransformers(){for(let e of this._userTransformerUnregisters)e();this._userTransformerUnregisters=[]}_reconcileUserTransformers(){let e=this._context.selectors.getCreateTransformers();if(this._activeCreateTransformers===e)return;let t=e?.(this._context.selectors.getDomainSystems())??[];this._unregisterUserTransformers(),this._activeCreateTransformers=e,this._registerUserTransformers(t)}_refreshIfExpressionContextChanged(){let{selectors:e}=this._context,t=e.getExpressionContext(),s=e.getDomainExpressions(),r=e.getComponentReaderIndexes();if(this._lastExpressionContext===t&&this._lastDomainExpressions===s&&this._lastComponentReaderIndexes===r)return;let n=e.getStoreSystem();n.reset(n.stateSlices.committed.value.state,"expressionContextRefreshed"),this._lastExpressionContext=t,this._lastDomainExpressions=s,this._lastComponentReaderIndexes=r}_refreshIfLoadedDataChanged(){let{selectors:e}=this._context,t=e.getLatestLoadedData();null!==t&&this._lastLoadedData!==t&&(e.getStoreSystem().reset(e.getInitialDomainState(),"loadedDataRefreshed"),this._lastLoadedData=t)}}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DomainComponentOptic } from '../../components/index.js';
|
|
2
2
|
import { type AnyDomain } from '../../core/domain.js';
|
|
3
3
|
import type { AnyDomainFactory, AnyExpressionContext, DomainEntity, DomainMode, SystemComponentTypeConstraint } from '../../core/index.js';
|
|
4
|
+
import { type AnyActionSystem } from '../../domain-context/action-system/action-system.js';
|
|
4
5
|
import { type AnyDimensionSystem } from '../../domain-context/dimension-system/dimension-system.js';
|
|
5
6
|
import type { AnyDomainContextSystems } from '../../domain-context/domain-context-systems.js';
|
|
6
7
|
import { type AnyNavigationSystem } from '../../domain-context/navigation-system/navigation-system.js';
|
|
@@ -120,6 +121,8 @@ export declare const createDomainContextSelectors: (context: Context) => {
|
|
|
120
121
|
getActiveConfigurationId: () => string;
|
|
121
122
|
getFactory: () => AnyDomainFactory;
|
|
122
123
|
getDomainExpressions: () => import("../../index.js").AnyExpressions;
|
|
124
|
+
getActionDefinitions: () => Readonly<Record<string, import("../../index.js").ActionDefinition>>;
|
|
125
|
+
getActionImplementations: () => Readonly<Record<string, import("../../index.js").AnyActionImplementation>>;
|
|
123
126
|
getModelVersion: () => number;
|
|
124
127
|
getAliasMap: () => import("../../index.js").AnyAliasMap;
|
|
125
128
|
getAllowedRootEntityTypes: () => import("../../index.js").AnyAllowedRootEntityTypes;
|
|
@@ -160,6 +163,7 @@ export declare const createDomainContextSelectors: (context: Context) => {
|
|
|
160
163
|
getNavigationSystem: () => AnyNavigationSystem;
|
|
161
164
|
getUndoSystem: () => AnyUndoSystem;
|
|
162
165
|
getRecipeCookerSystem: () => AnyRecipeCookerSystem;
|
|
166
|
+
getActionSystem: () => AnyActionSystem;
|
|
163
167
|
getBlenderProjections: () => AnyBlenderProjections;
|
|
164
168
|
getExpressionContext: () => AnyExpressionContext;
|
|
165
169
|
getDomainSystems: () => AnyDomainContextSystems;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSelector as e}from"@salsita-ai/common/utils";import{Domain as t}from"../../core/domain.js";import{createInitialDomainState as n}from"../../core/state.js";import{DimensionSystem as o}from"../../domain-context/dimension-system/dimension-system.js";import{NavigationSystem as i}from"../../domain-context/navigation-system/navigation-system.js";import{RecipeCookerSystem as a}from"../../domain-context/recipe-system/recipe-cooker-system.js";import{StoreSystem as s}from"../../domain-context/store-system/store-system.js";import{UndoSystem as r}from"../../domain-context/undo-system.js";import{prepareDomainExpressions as c}from"../../expressions/index.js";import{BlenderProjections as l,CollisionProjections as m,CompositionProjections as d,ConstraintProjections as g,PositionProjections as f,ProjectedEntitiesProjections as p,SnappingProjections as u,ValidationProjections as y}from"../../projections/index.js";import{SketchingProjections as w}from"../../sketching/sketching-projections.js";import{requireAccessService as h}from"../access/index.js";import{ComponentReader as S}from"./component-reader.js";import{DomainContext as x}from"./domain-context.js";let j=e.withTypes(),C=[],D={},v={role:"admin",data:D},I=e=>{if(null!==e)return e;throw Error("Cannot read the session role and data because the domain session context is not set. The session context is written into the domain runtime by the session lifecycle after authentication. Move this read into the loaded session lifecycle.")};export const createDomainContextSelectors=e=>{let{applicationType:P,getState:M,actions:R,specSelectors:E,accessSelectors:T,webComponentSelectors:b,domainDataSelectors:A,sessionContextSelectors:k,domainServicesSelectors:$,environmentSelectors:N,getExtensionSystems:z}=e,L="configurator"===P?E.selectConfiguratorSpec:E.selectAdminSpec,V="configurator"===P?T.selectConfiguratorRawAccessService:T.selectAdminRawAccessService,B=j.leaf(e=>e.domainContext[P]),F=j([B],e=>e.initializationContext),W=j([F],e=>{if(null===e)throw Error(`Domain lifecycle context is not available for ${P}! Read it from an active domain lifecycle.`);return e}),_=j([B],e=>e.executionMode),q=j([B],e=>e.isInitialized),O=j([L],e=>e.factory),U=j([L],e=>e.expressions),G=j([L],e=>e.$entityReflections),H=j([U,G],(e,t)=>c({expressions:e,$entityReflections:t})),J=j([L],e=>e.modelVersion),K=j([L],e=>e.aliasMap),Q=j([L],e=>e.allowedRootEntityTypes),X=j([L],e=>e.entityReflections),Y=j([L],e=>e.migrate),Z=j([_,b.selectReadonly,V],(e,t,n)=>"finalize"===e?"finalize":h(P,n).accessInfo.viewMode||t?"read":"owner"),ee=j([V],e=>e?.configurationId??null),et="configurator"===P?k.selectSessionContext:j([],()=>v),en=j([et],e=>e?.role??null),eo=j([et],e=>e?.data??null),ei=j([j.leaf(e=>e.loadedData)],e=>"configurator"===P?e.configuratorLoadedData:e.adminLoadedData),ea=j([ei],e=>e?.schemaIdentity??null),es=j([ei,O],(e,t)=>{if(null===e)return"coherent";let n=e.schemaIdentity;return void 0===n?"missing-stamp":n===t?"coherent":"schema-mismatch"}),er=j([ee,en,eo,ea,es],(e,t,n,o,i)=>null===e||null===t||null===n||null===o||"coherent"!==i?null:{configurationId:e,role:t,schemaIdentity:o,sessionData:n}),ec=j([V,b.selectReadonly],(e,t)=>e?.accessInfo.viewMode===!0||t),el=j([er,F,q,ec],(e,t,n,o)=>{let i=null!==e&&null!==t&&n&&t.configurationId===e.configurationId&&t.role===e.role&&t.schemaIdentity===e.schemaIdentity&&t.sessionData===e.sessionData;return{identity:e,isCurrent:i,isViewMode:o}}),em=j([L],e=>e.componentOptics),ed=j([em],e=>(e=>{let t=new Map,n=new Map,o=new Map,i=new Map;for(let n of e)for(let e of n.entityTypes){let o=t.get(e);o||(o=new Map,t.set(e,o));let a=o.get(n.componentType);if(a||(a=new Map,o.set(n.componentType,a)),a.has(n.instanceName))throw Error(`Component instance ${n.instanceName} already exists for type ${n.componentType.name} in entity ${e}. This is likely a bug in the component definition! InstanceNames must be unique within an entity and component.`);if(a.set(n.instanceName,n),"dynamic"===n.kind){let t=i.get(e);t||(t=new Map,i.set(e,t));let o=t.get(n.componentType)??[],a=o.find(e=>{var t;return t=n.instanceName,e.startsWith(`${t}_`)||t.startsWith(`${e}_`)});if(a)throw Error(`Cannot register dynamic component instance ${n.instanceName} for component ${n.componentType.name} on entity ${e} because it overlaps with dynamic instance ${a}. Rename one dynamic instance so compound names cannot be ambiguous.`);t.set(n.componentType,[...o,n.instanceName])}}for(let[e,i]of t.entries()){n.set(e,new Set(i.keys()));let t=new Map;for(let[n,a]of(o.set(e,t),i.entries()))t.set(n,new Set(a.keys()))}return{opticMap:t,allComponentTypes:n,allComponentInstanceNames:o,dynamicInstanceNames:i}})(e)),eg=j([ed,H,Q],(e,t,n)=>({componentReaderIndexes:e,domainExpressions:t,allowedRootEntityTypes:n})),ef=j([L],e=>e.navigationStates),ep=j([L],e=>e.viewStates),eu="configurator"===P?j([E.selectConfiguratorSpec],e=>e.toolStates):j([],()=>C),ey="configurator"===P?j([E.selectConfiguratorSpec],e=>e.exportStates):j([],()=>C),ew="configurator"===P?j([E.selectConfiguratorSpec],e=>e.createTransformers):j([],()=>void 0),eh=j([ei],e=>{if(null===e)throw Error(`Loaded data is not available for ${P}! Loaded data is written after the configuration fetch succeeds and before the domain context initialization starts.`);return e}),eS=j([eh,O],(e,t)=>n(t.validateAndMigrateState(e.initialEntities,e.modelVersion),e.rootEntityType)),ex="configurator"===P?A.selectConfiguratorFrontendData:A.selectAdminFrontendData,ej="configurator"===P?A.selectConfiguratorBackendData:A.selectAdminBackendData,eC="configurator"===P?A.selectConfiguratorPublishedData:A.selectAdminPublishedData,eD="configurator"===P?j([k.selectSessionContext],e=>I(e).role):j([],()=>"admin"),ev="configurator"===P?j([k.selectSessionContext],e=>I(e).data):j([],()=>D),eI=j([ee,Z,eD,ev,eh],(e,t,n,o,i)=>({configurationId:e,mode:t,role:n,schemaIdentity:i.schemaIdentity,sessionData:o})),eP=j([W],e=>e.mode),eM=j([W],e=>{let t=e.configurationId;if(null===t)throw Error(`Configuration id is not available for ${P}! Read it from an active interactive domain lifecycle.`);return t}),eR=j([W],e=>e.role),eE=j([W],e=>e.sessionData),eT=j([eP,eR,eE,ex,ej,eC,Y],(e,t,n,o,i,a,s)=>({mode:e,role:t,sessionData:n,frontendData:o,backendData:i,publishedData:a,migrate:s,domain:eA,componentReader:ek,positionProjections:eV,sketchingProjections:eL,collisionProjections:eB,constraintProjections:eW,snappingProjections:eF,projectedEntitiesProjections:e_})),eb={selectApplicationSpec:L,selectRawAccessService:V,selectDomainContextState:B,selectInitializationContext:F,selectActiveInitializationContext:W,selectExecutionMode:_,selectIsInitialized:q,selectFactory:O,selectSpecExpressions:U,select$SpecEntityReflections:G,selectDomainExpressions:H,selectModelVersion:J,selectAliasMap:K,selectAllowedRootEntityTypes:Q,selectEntityReflections:X,selectMigrate:Y,selectLatestMode:Z,selectLatestConfigurationId:ee,selectLatestSessionContext:et,selectLatestRoleOrNull:en,selectLatestSessionDataOrNull:eo,selectLatestSchemaIdentity:ea,selectSchemaCoherence:es,selectInitializationIdentity:er,selectIsViewMode:ec,selectInitializationState:el,selectComponentOptics:em,selectComponentReaderIndexes:ed,selectStoreRuntimeDependencies:eg,selectNavigationStates:ef,selectViewStates:ep,selectToolStates:eu,selectExportStates:ey,selectCreateTransformers:ew,selectLatestLoadedData:ei,selectLoadedData:eh,selectInitialDomainState:eS,selectFrontendData:ex,selectBackendData:ej,selectPublishedData:eC,selectLatestRole:eD,selectLatestSessionData:ev,selectNextInitializationContext:eI,selectActiveMode:eP,selectActiveConfigurationId:eM,selectActiveRole:eR,selectActiveSessionData:eE,selectExpressionContext:eT,getInitializationContext:()=>F(M()),getInitializationState:()=>el(M()),getNextInitializationContext:()=>eI(M()),getLatestLoadedData:()=>ei(M()),getSchemaCoherence:()=>es(M()),getActiveConfigurationId:()=>eM(M()),getFactory:()=>O(M()),getDomainExpressions:()=>H(M()),getModelVersion:()=>J(M()),getAliasMap:()=>K(M()),getAllowedRootEntityTypes:()=>Q(M()),getEntityReflections:()=>X(M()),getMigrate:()=>Y(M()),getActiveMode:()=>eP(M()),getIsInitialized:()=>q(M()),getComponentReaderIndexes:()=>ed(M()),getStoreRuntimeDependencies:()=>eg(M()),getNavigationStates:()=>ef(M()),getViewStates:()=>ep(M()),getToolStates:()=>eu(M()),getExportStates:()=>ey(M()),getCreateTransformers:()=>ew(M()),getLoadedData:()=>eh(M()),getInitialDomainState:()=>eS(M()),getFrontendData:()=>ex(M()),getBackendData:()=>ej(M()),getPublishedData:()=>eC(M()),getActiveRole:()=>eR(M()),getActiveSessionData:()=>eE(M()),getDomain:()=>eA,getComponentReader:()=>ek,getCompositionProjections:()=>e$,getDimensionSystem:()=>eN,getValidationProjections:()=>ez,getSketchingProjections:()=>eL,getPositionProjections:()=>eV,getCollisionProjections:()=>eB,getSnappingProjections:()=>eF,getConstraintProjections:()=>eW,getProjectedEntitiesProjections:()=>e_,getStoreSystem:()=>eq,getNavigationSystem:()=>eO,getUndoSystem:()=>eU,getRecipeCookerSystem:()=>eG,getBlenderProjections:()=>eH,getExpressionContext:()=>eT(M()),getDomainSystems:function(){return eJ},getDomainContext:function(){return eK}},eA=new t({selectors:eb}),ek=new S({selectors:eb}),e$=new d({selectors:eb}),eN=new o({selectors:eb}),ez=new y({selectors:eb}),eL=new w({selectors:eb}),eV=new f({selectors:eb}),eB=new m({selectors:eb}),eF=new u({selectors:eb}),eW=new g({selectors:eb}),e_=new p({selectors:eb}),eq=new s({selectors:eb,domainServicesSelectors:$,environmentSelectors:N}),eO=new i({selectors:eb,domainServicesSelectors:$}),eU=new r({selectors:eb}),eG=new a({selectors:eb}),eH=new l({selectors:eb,domainServicesSelectors:$}),eJ={domainContextSelectors:eb,domain:eA,componentReader:ek,compositionProjections:e$,blenderProjections:eH,validationProjections:ez,storeSystem:eq,navigationSystem:eO,dimensionSystem:eN,undoSystem:eU,recipeCooker:eG,sketchingProjections:eL,collisionProjections:eB,positionProjections:eV,snappingProjections:eF,projectedEntitiesProjections:e_,constraintProjections:eW},eK=new x({selectors:eb,actions:R,getExtensionSystems:z});return eb};
|
|
1
|
+
import{createSelector as e}from"@salsita-ai/common/utils";import{prepareActionImplementations as t}from"../../actions/prepare-action-implementations.js";import{Domain as n}from"../../core/domain.js";import{createInitialDomainState as o}from"../../core/state.js";import{ActionSystem as i}from"../../domain-context/action-system/action-system.js";import{DimensionSystem as a}from"../../domain-context/dimension-system/dimension-system.js";import{NavigationSystem as s}from"../../domain-context/navigation-system/navigation-system.js";import{RecipeCookerSystem as r}from"../../domain-context/recipe-system/recipe-cooker-system.js";import{StoreSystem as c}from"../../domain-context/store-system/store-system.js";import{UndoSystem as m}from"../../domain-context/undo-system.js";import{prepareDomainExpressions as l}from"../../expressions/index.js";import{BlenderProjections as d,CollisionProjections as g,CompositionProjections as f,ConstraintProjections as p,PositionProjections as u,ProjectedEntitiesProjections as y,SnappingProjections as w,ValidationProjections as h}from"../../projections/index.js";import{SketchingProjections as S}from"../../sketching/sketching-projections.js";import{requireAccessService as x}from"../access/index.js";import{ComponentReader as j}from"./component-reader.js";import{DomainContext as C}from"./domain-context.js";let D=e.withTypes(),v=[],I={},P={role:"admin",data:I},M=e=>{if(null!==e)return e;throw Error("Cannot read the session role and data because the domain session context is not set. The session context is written into the domain runtime by the session lifecycle after authentication. Move this read into the loaded session lifecycle.")};export const createDomainContextSelectors=e=>{let{applicationType:A,getState:R,actions:E,specSelectors:T,accessSelectors:b,webComponentSelectors:k,domainDataSelectors:$,sessionContextSelectors:N,domainServicesSelectors:z,environmentSelectors:L,getExtensionSystems:V}=e,B="configurator"===A?T.selectConfiguratorSpec:T.selectAdminSpec,F="configurator"===A?b.selectConfiguratorRawAccessService:b.selectAdminRawAccessService,W=D.leaf(e=>e.domainContext[A]),_=D([W],e=>e.initializationContext),q=D([_],e=>{if(null===e)throw Error(`Domain lifecycle context is not available for ${A}! Read it from an active domain lifecycle.`);return e}),O=D([W],e=>e.executionMode),U=D([W],e=>e.isInitialized),G=D([B],e=>e.factory),H=D([B],e=>e.expressions),J=D([B],e=>e.actions),K=D([B],e=>e.actionImplementations),Q=D([J,K],t),X=D([B],e=>e.$entityReflections),Y=D([H,X],(e,t)=>l({expressions:e,$entityReflections:t})),Z=D([B],e=>e.modelVersion),ee=D([B],e=>e.aliasMap),et=D([B],e=>e.allowedRootEntityTypes),en=D([B],e=>e.entityReflections),eo=D([B],e=>e.migrate),ei=D([O,k.selectReadonly,F],(e,t,n)=>"finalize"===e?"finalize":x(A,n).accessInfo.viewMode||t?"read":"owner"),ea=D([F],e=>e?.configurationId??null),es="configurator"===A?N.selectSessionContext:D([],()=>P),er=D([es],e=>e?.role??null),ec=D([es],e=>e?.data??null),em=D([D.leaf(e=>e.loadedData)],e=>"configurator"===A?e.configuratorLoadedData:e.adminLoadedData),el=D([em],e=>e?.schemaIdentity??null),ed=D([em,G],(e,t)=>{if(null===e)return"coherent";let n=e.schemaIdentity;return void 0===n?"missing-stamp":n===t?"coherent":"schema-mismatch"}),eg=D([ea,er,ec,el,ed],(e,t,n,o,i)=>null===e||null===t||null===n||null===o||"coherent"!==i?null:{configurationId:e,role:t,schemaIdentity:o,sessionData:n}),ef=D([F,k.selectReadonly],(e,t)=>e?.accessInfo.viewMode===!0||t),ep=D([eg,_,U,ef],(e,t,n,o)=>{let i=null!==e&&null!==t&&n&&t.configurationId===e.configurationId&&t.role===e.role&&t.schemaIdentity===e.schemaIdentity&&t.sessionData===e.sessionData;return{identity:e,isCurrent:i,isViewMode:o}}),eu=D([B],e=>e.componentOptics),ey=D([eu],e=>(e=>{let t=new Map,n=new Map,o=new Map,i=new Map;for(let n of e)for(let e of n.entityTypes){let o=t.get(e);o||(o=new Map,t.set(e,o));let a=o.get(n.componentType);if(a||(a=new Map,o.set(n.componentType,a)),a.has(n.instanceName))throw Error(`Component instance ${n.instanceName} already exists for type ${n.componentType.name} in entity ${e}. This is likely a bug in the component definition! InstanceNames must be unique within an entity and component.`);if(a.set(n.instanceName,n),"dynamic"===n.kind){let t=i.get(e);t||(t=new Map,i.set(e,t));let o=t.get(n.componentType)??[],a=o.find(e=>{var t;return t=n.instanceName,e.startsWith(`${t}_`)||t.startsWith(`${e}_`)});if(a)throw Error(`Cannot register dynamic component instance ${n.instanceName} for component ${n.componentType.name} on entity ${e} because it overlaps with dynamic instance ${a}. Rename one dynamic instance so compound names cannot be ambiguous.`);t.set(n.componentType,[...o,n.instanceName])}}for(let[e,i]of t.entries()){n.set(e,new Set(i.keys()));let t=new Map;for(let[n,a]of(o.set(e,t),i.entries()))t.set(n,new Set(a.keys()))}return{opticMap:t,allComponentTypes:n,allComponentInstanceNames:o,dynamicInstanceNames:i}})(e)),ew=D([ey,Y,et],(e,t,n)=>({componentReaderIndexes:e,domainExpressions:t,allowedRootEntityTypes:n})),eh=D([B],e=>e.navigationStates),eS=D([B],e=>e.viewStates),ex="configurator"===A?D([T.selectConfiguratorSpec],e=>e.toolStates):D([],()=>v),ej="configurator"===A?D([T.selectConfiguratorSpec],e=>e.exportStates):D([],()=>v),eC="configurator"===A?D([T.selectConfiguratorSpec],e=>e.createTransformers):D([],()=>void 0),eD=D([em],e=>{if(null===e)throw Error(`Loaded data is not available for ${A}! Loaded data is written after the configuration fetch succeeds and before the domain context initialization starts.`);return e}),ev=D([eD,G],(e,t)=>o(t.validateAndMigrateState(e.initialEntities,e.modelVersion),e.rootEntityType)),eI="configurator"===A?$.selectConfiguratorFrontendData:$.selectAdminFrontendData,eP="configurator"===A?$.selectConfiguratorBackendData:$.selectAdminBackendData,eM="configurator"===A?$.selectConfiguratorPublishedData:$.selectAdminPublishedData,eA="configurator"===A?D([N.selectSessionContext],e=>M(e).role):D([],()=>"admin"),eR="configurator"===A?D([N.selectSessionContext],e=>M(e).data):D([],()=>I),eE=D([ea,ei,eA,eR,eD],(e,t,n,o,i)=>({configurationId:e,mode:t,role:n,schemaIdentity:i.schemaIdentity,sessionData:o})),eT=D([q],e=>e.mode),eb=D([q],e=>{let t=e.configurationId;if(null===t)throw Error(`Configuration id is not available for ${A}! Read it from an active interactive domain lifecycle.`);return t}),ek=D([q],e=>e.role),e$=D([q],e=>e.sessionData),eN=D([eT,ek,e$,eI,eP,eM,eo],(e,t,n,o,i,a,s)=>({mode:e,role:t,sessionData:n,frontendData:o,backendData:i,publishedData:a,migrate:s,domain:eL,componentReader:eV,positionProjections:eq,sketchingProjections:e_,collisionProjections:eO,constraintProjections:eG,snappingProjections:eU,projectedEntitiesProjections:eH})),ez={selectApplicationSpec:B,selectRawAccessService:F,selectDomainContextState:W,selectInitializationContext:_,selectActiveInitializationContext:q,selectExecutionMode:O,selectIsInitialized:U,selectFactory:G,selectSpecExpressions:H,select$SpecEntityReflections:X,selectDomainExpressions:Y,selectModelVersion:Z,selectAliasMap:ee,selectAllowedRootEntityTypes:et,selectEntityReflections:en,selectMigrate:eo,selectLatestMode:ei,selectLatestConfigurationId:ea,selectLatestSessionContext:es,selectLatestRoleOrNull:er,selectLatestSessionDataOrNull:ec,selectLatestSchemaIdentity:el,selectSchemaCoherence:ed,selectInitializationIdentity:eg,selectIsViewMode:ef,selectInitializationState:ep,selectComponentOptics:eu,selectComponentReaderIndexes:ey,selectStoreRuntimeDependencies:ew,selectNavigationStates:eh,selectViewStates:eS,selectToolStates:ex,selectExportStates:ej,selectCreateTransformers:eC,selectLatestLoadedData:em,selectLoadedData:eD,selectInitialDomainState:ev,selectFrontendData:eI,selectBackendData:eP,selectPublishedData:eM,selectLatestRole:eA,selectLatestSessionData:eR,selectNextInitializationContext:eE,selectActiveMode:eT,selectActiveConfigurationId:eb,selectActiveRole:ek,selectActiveSessionData:e$,selectExpressionContext:eN,getInitializationContext:()=>_(R()),getInitializationState:()=>ep(R()),getNextInitializationContext:()=>eE(R()),getLatestLoadedData:()=>em(R()),getSchemaCoherence:()=>ed(R()),getActiveConfigurationId:()=>eb(R()),getFactory:()=>G(R()),getDomainExpressions:()=>Y(R()),getActionDefinitions:()=>J(R()),getActionImplementations:()=>Q(R()),getModelVersion:()=>Z(R()),getAliasMap:()=>ee(R()),getAllowedRootEntityTypes:()=>et(R()),getEntityReflections:()=>en(R()),getMigrate:()=>eo(R()),getActiveMode:()=>eT(R()),getIsInitialized:()=>U(R()),getComponentReaderIndexes:()=>ey(R()),getStoreRuntimeDependencies:()=>ew(R()),getNavigationStates:()=>eh(R()),getViewStates:()=>eS(R()),getToolStates:()=>ex(R()),getExportStates:()=>ej(R()),getCreateTransformers:()=>eC(R()),getLoadedData:()=>eD(R()),getInitialDomainState:()=>ev(R()),getFrontendData:()=>eI(R()),getBackendData:()=>eP(R()),getPublishedData:()=>eM(R()),getActiveRole:()=>ek(R()),getActiveSessionData:()=>e$(R()),getDomain:()=>eL,getComponentReader:()=>eV,getCompositionProjections:()=>eB,getDimensionSystem:()=>eF,getValidationProjections:()=>eW,getSketchingProjections:()=>e_,getPositionProjections:()=>eq,getCollisionProjections:()=>eO,getSnappingProjections:()=>eU,getConstraintProjections:()=>eG,getProjectedEntitiesProjections:()=>eH,getStoreSystem:()=>eJ,getNavigationSystem:()=>eK,getUndoSystem:()=>eQ,getRecipeCookerSystem:()=>eX,getActionSystem:()=>eY,getBlenderProjections:()=>eZ,getExpressionContext:()=>eN(R()),getDomainSystems:function(){return e0},getDomainContext:function(){return e1}},eL=new n({selectors:ez}),eV=new j({selectors:ez}),eB=new f({selectors:ez}),eF=new a({selectors:ez}),eW=new h({selectors:ez}),e_=new S({selectors:ez}),eq=new u({selectors:ez}),eO=new g({selectors:ez}),eU=new w({selectors:ez}),eG=new p({selectors:ez}),eH=new y({selectors:ez}),eJ=new c({selectors:ez,domainServicesSelectors:z,environmentSelectors:L}),eK=new s({selectors:ez,domainServicesSelectors:z}),eQ=new m({selectors:ez}),eX=new r({selectors:ez}),eY=new i({selectors:ez}),eZ=new d({selectors:ez,domainServicesSelectors:z}),e0={domainContextSelectors:ez,domain:eL,componentReader:eV,compositionProjections:eB,blenderProjections:eZ,validationProjections:eW,storeSystem:eJ,navigationSystem:eK,dimensionSystem:eF,undoSystem:eQ,recipeCooker:eX,actionSystem:eY,sketchingProjections:e_,collisionProjections:eO,positionProjections:eq,snappingProjections:eU,projectedEntitiesProjections:eH,constraintProjections:eG},e1=new C({selectors:ez,actions:E,getExtensionSystems:V});return ez};
|
|
@@ -398,6 +398,8 @@ export declare function createDomainRuntimeSlices<State extends DomainRuntimeSta
|
|
|
398
398
|
getActiveConfigurationId: () => string;
|
|
399
399
|
getFactory: () => import("../index.js").AnyDomainFactory;
|
|
400
400
|
getDomainExpressions: () => import("../index.js").AnyExpressions;
|
|
401
|
+
getActionDefinitions: () => Readonly<Record<string, import("../index.js").ActionDefinition>>;
|
|
402
|
+
getActionImplementations: () => Readonly<Record<string, import("../index.js").AnyActionImplementation>>;
|
|
401
403
|
getModelVersion: () => number;
|
|
402
404
|
getAliasMap: () => import("../index.js").AnyAliasMap;
|
|
403
405
|
getAllowedRootEntityTypes: () => import("../index.js").AnyAllowedRootEntityTypes;
|
|
@@ -438,6 +440,7 @@ export declare function createDomainRuntimeSlices<State extends DomainRuntimeSta
|
|
|
438
440
|
getNavigationSystem: () => import("../domain-context/navigation-system/navigation-system.js").AnyNavigationSystem;
|
|
439
441
|
getUndoSystem: () => import("../domain-context/undo-system.js").AnyUndoSystem;
|
|
440
442
|
getRecipeCookerSystem: () => import("../index.js").AnyRecipeCookerSystem;
|
|
443
|
+
getActionSystem: () => import("../index.js").AnyActionSystem;
|
|
441
444
|
getBlenderProjections: () => import("../index.js").AnyBlenderProjections;
|
|
442
445
|
getExpressionContext: () => import("../index.js").AnyExpressionContext;
|
|
443
446
|
getDomainSystems: () => import("../index.js").AnyDomainContextSystems;
|
|
@@ -504,6 +507,8 @@ export declare function createDomainRuntimeSlices<State extends DomainRuntimeSta
|
|
|
504
507
|
getActiveConfigurationId: () => string;
|
|
505
508
|
getFactory: () => import("../index.js").AnyDomainFactory;
|
|
506
509
|
getDomainExpressions: () => import("../index.js").AnyExpressions;
|
|
510
|
+
getActionDefinitions: () => Readonly<Record<string, import("../index.js").ActionDefinition>>;
|
|
511
|
+
getActionImplementations: () => Readonly<Record<string, import("../index.js").AnyActionImplementation>>;
|
|
507
512
|
getModelVersion: () => number;
|
|
508
513
|
getAliasMap: () => import("../index.js").AnyAliasMap;
|
|
509
514
|
getAllowedRootEntityTypes: () => import("../index.js").AnyAllowedRootEntityTypes;
|
|
@@ -544,6 +549,7 @@ export declare function createDomainRuntimeSlices<State extends DomainRuntimeSta
|
|
|
544
549
|
getNavigationSystem: () => import("../domain-context/navigation-system/navigation-system.js").AnyNavigationSystem;
|
|
545
550
|
getUndoSystem: () => import("../domain-context/undo-system.js").AnyUndoSystem;
|
|
546
551
|
getRecipeCookerSystem: () => import("../index.js").AnyRecipeCookerSystem;
|
|
552
|
+
getActionSystem: () => import("../index.js").AnyActionSystem;
|
|
547
553
|
getBlenderProjections: () => import("../index.js").AnyBlenderProjections;
|
|
548
554
|
getExpressionContext: () => import("../index.js").AnyExpressionContext;
|
|
549
555
|
getDomainSystems: () => import("../index.js").AnyDomainContextSystems;
|
|
@@ -982,6 +988,8 @@ export declare const createDomainRuntime: (props: Omit<Props<DomainRuntimeState>
|
|
|
982
988
|
getActiveConfigurationId: () => string;
|
|
983
989
|
getFactory: () => import("../index.js").AnyDomainFactory;
|
|
984
990
|
getDomainExpressions: () => import("../index.js").AnyExpressions;
|
|
991
|
+
getActionDefinitions: () => Readonly<Record<string, import("../index.js").ActionDefinition>>;
|
|
992
|
+
getActionImplementations: () => Readonly<Record<string, import("../index.js").AnyActionImplementation>>;
|
|
985
993
|
getModelVersion: () => number;
|
|
986
994
|
getAliasMap: () => import("../index.js").AnyAliasMap;
|
|
987
995
|
getAllowedRootEntityTypes: () => import("../index.js").AnyAllowedRootEntityTypes;
|
|
@@ -1022,6 +1030,7 @@ export declare const createDomainRuntime: (props: Omit<Props<DomainRuntimeState>
|
|
|
1022
1030
|
getNavigationSystem: () => import("../domain-context/navigation-system/navigation-system.js").AnyNavigationSystem;
|
|
1023
1031
|
getUndoSystem: () => import("../domain-context/undo-system.js").AnyUndoSystem;
|
|
1024
1032
|
getRecipeCookerSystem: () => import("../index.js").AnyRecipeCookerSystem;
|
|
1033
|
+
getActionSystem: () => import("../index.js").AnyActionSystem;
|
|
1025
1034
|
getBlenderProjections: () => import("../index.js").AnyBlenderProjections;
|
|
1026
1035
|
getExpressionContext: () => import("../index.js").AnyExpressionContext;
|
|
1027
1036
|
getDomainSystems: () => import("../index.js").AnyDomainContextSystems;
|
|
@@ -1088,6 +1097,8 @@ export declare const createDomainRuntime: (props: Omit<Props<DomainRuntimeState>
|
|
|
1088
1097
|
getActiveConfigurationId: () => string;
|
|
1089
1098
|
getFactory: () => import("../index.js").AnyDomainFactory;
|
|
1090
1099
|
getDomainExpressions: () => import("../index.js").AnyExpressions;
|
|
1100
|
+
getActionDefinitions: () => Readonly<Record<string, import("../index.js").ActionDefinition>>;
|
|
1101
|
+
getActionImplementations: () => Readonly<Record<string, import("../index.js").AnyActionImplementation>>;
|
|
1091
1102
|
getModelVersion: () => number;
|
|
1092
1103
|
getAliasMap: () => import("../index.js").AnyAliasMap;
|
|
1093
1104
|
getAllowedRootEntityTypes: () => import("../index.js").AnyAllowedRootEntityTypes;
|
|
@@ -1128,6 +1139,7 @@ export declare const createDomainRuntime: (props: Omit<Props<DomainRuntimeState>
|
|
|
1128
1139
|
getNavigationSystem: () => import("../domain-context/navigation-system/navigation-system.js").AnyNavigationSystem;
|
|
1129
1140
|
getUndoSystem: () => import("../domain-context/undo-system.js").AnyUndoSystem;
|
|
1130
1141
|
getRecipeCookerSystem: () => import("../index.js").AnyRecipeCookerSystem;
|
|
1142
|
+
getActionSystem: () => import("../index.js").AnyActionSystem;
|
|
1131
1143
|
getBlenderProjections: () => import("../index.js").AnyBlenderProjections;
|
|
1132
1144
|
getExpressionContext: () => import("../index.js").AnyExpressionContext;
|
|
1133
1145
|
getDomainSystems: () => import("../index.js").AnyDomainContextSystems;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SessionRole as e}from"@salsita-ai/contracts/api";let a=(e,a)=>{let t={};for(let n of e)t[n.name]=a?.[n.name]??n.name;return t},t=(e,a)=>{let t={},n=0;for(let
|
|
1
|
+
import{SessionRole as e}from"@salsita-ai/contracts/api";let a=(e,a)=>{let t={};for(let n of e)t[n.name]=a?.[n.name]??n.name;return t},t=(e,a)=>{let t={},n=0;for(let o of e)if("entity"===o.type||"layout"===o.type)t[o.name]=a?.[o.name]??o.name;else{let e=`icon:${n}`;t[e]=a?.[e]??`${e}:${o.elements.length}`,n+=1}return t};export const initializeSpec=n=>{let o=n.adminDomain.presets[0];if(!o)throw Error("Cannot register application spec because admin preset is required.");return{version:n.version,dataConfig:n.dataSpec??null,chunks:n.chunks,publishedDataHash:n.publishedDataHash,initialPublishedData:n.initialPublishedData,canCreate:n.features?.acl?.canCreate??Object.values(e),enableAdminRelease:n.features?.enableAdminRelease??!1,textLanguages:n.domain.textLanguages??n.adminDomain.textLanguages??["en"],baseResourcesUrl:n.resources?.baseResourcesUrl??n.defaultEnvs?.resourcesUrl??"",configurator:{factory:n.domain.domainFactory,presets:n.domain.presets,aliasMap:n.domain.domainFactory.context.aliasMap,entityReflections:n.domain.domainFactory.context.entityReflections,$entityReflections:n.domain.domainFactory.context.$entityReflections,expressions:n.domain.domainFactory.context.expressions,actions:n.domain.domainFactory.context.actions,actionImplementations:n.domain.domainFactory.context.actionImplementations,allowedRootEntityTypes:n.domain.domainFactory.context.allowedRootEntityTypes,migrate:n.domain.domainFactory.context.migrate,componentOptics:n.domain.componentOptics,createTransformers:n.createTransformers??(()=>[]),navigationStates:n.navigation?.navigationStates??[],viewStates:n.navigation?.viewStates??[],toolStates:n.navigation?.toolStates??[],exportStates:n.navigation?.exportStates??[],handlers:n.handlers,handlerHashes:a(n.handlers),elements:n.elements,elementHashes:t(n.elements),appLoader:n.ui?.appLoader??"universal",preview:n.ui?.preview??"auto",alwaysExpand:n.ui?.alwaysExpand??!1,theme:n.ui?.theme??{},assistant:n.assistant??null,deploymentQueryDisabled:n.resources?.deploymentQueryDisabled??!1,prefetchTextureUrls:n.resources?.prefetchTextureUrls??[],modelVersion:n.domain.domainFactory.modelVersion},admin:{factory:n.adminDomain.domainFactory,modelVersion:n.adminDomain.domainFactory.modelVersion,aliasMap:n.adminDomain.domainFactory.context.aliasMap,entityReflections:n.adminDomain.domainFactory.context.entityReflections,$entityReflections:n.adminDomain.domainFactory.context.$entityReflections,expressions:n.adminDomain.domainFactory.context.expressions,actions:n.adminDomain.domainFactory.context.actions,actionImplementations:n.adminDomain.domainFactory.context.actionImplementations,allowedRootEntityTypes:n.adminDomain.domainFactory.context.allowedRootEntityTypes,migrate:n.adminDomain.domainFactory.context.migrate,preset:o,componentOptics:n.adminDomain.componentOptics,navigationStates:n.adminNavigation?.navigationStates??[],viewStates:n.adminNavigation?.viewStates??[],handlers:n.handlers,handlerHashes:a(n.handlers),elements:n.elements,elementHashes:t(n.elements)}}};
|