@salsita-ai/sdk 0.50.0-develop.da8d27f5d7 → 0.50.0-develop.dfac20c66b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -11
- package/dist/application-spec/errors/diagnostic-codes.d.ts +6 -0
- package/dist/application-spec/errors/diagnostic-codes.js +1 -1
- package/dist/application-spec/errors/diagnostic-messages.d.ts +6 -0
- package/dist/application-spec/errors/diagnostic-messages.js +1 -1
- package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
- package/dist/application-spec/generate-application/code/templates/application-types.js +6 -6
- package/dist/application-spec/generate-application/code/templates/configurator-domain-code.d.ts +1 -0
- package/dist/application-spec/generate-application/code/templates/configurator-domain-code.js +11 -8
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.d.ts +3 -1
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.js +70 -66
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-phx-globals.js +3 -0
- package/dist/application-spec/generate-application/code/templates/domain-spec.js +5 -5
- package/dist/application-spec/generate-application/code/templates/domain.js +2 -2
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.d.ts +11 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.js +8 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/index.d.ts +1 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/globals.js +1 -0
- package/dist/application-spec/generate-application/code/templates/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} +4 -2
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-feedback-skill.js +54 -0
- 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/admin.mdx +2 -2
- package/dist/docs/phoenix/best-practices.mdx +1 -0
- package/dist/docs/phoenix/finalization.mdx +1 -1
- package/dist/docs/phoenix/integration/headless-mode-external.mdx +5 -5
- package/dist/docs/phoenix/integration/widget-mode-external.mdx +5 -5
- package/dist/docs/phoenix/migrations.mdx +45 -5
- package/dist/docs/phoenix/phoenix-cli.mdx +60 -20
- package/dist/docs/phoenix/project-structure.mdx +4 -1
- package/dist/docs/phoenix/sdk-builder-workflow.mdx +9 -6
- 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/cli.js +1 -1
- package/dist/phoenix/commands/build.d.ts +5 -0
- package/dist/phoenix/commands/build.js +1 -1
- package/dist/phoenix/commands/deploy.js +2 -2
- package/dist/phoenix/commands/feedback.d.ts +2 -1
- package/dist/phoenix/commands/feedback.js +1 -1
- package/dist/phoenix/commands/login.d.ts +24 -6
- package/dist/phoenix/commands/login.js +2 -2
- package/dist/phoenix/services/index.d.ts +1 -0
- package/dist/phoenix/services/index.js +1 -1
- package/dist/phoenix/services/phx-banner-plugin.d.ts +32 -0
- package/dist/phoenix/services/phx-banner-plugin.js +1 -0
- package/dist/phoenix/services/phx-licenses-plugin.d.ts +55 -0
- package/dist/phoenix/services/phx-licenses-plugin.js +8 -0
- package/dist/phoenix/services/vite-config.d.ts +2 -0
- package/dist/phoenix/services/vite-config.js +1 -1
- package/dist/phoenix/utils/index.d.ts +1 -0
- package/dist/phoenix/utils/index.js +1 -1
- package/dist/phoenix/utils/read-git-commit.d.ts +14 -0
- package/dist/phoenix/utils/read-git-commit.js +1 -0
- package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +12 -0
- package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +3 -0
- package/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-feedback-skill.js +0 -31
- 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
|
@@ -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)}}};
|
|
@@ -2,7 +2,7 @@ import type { ThemeOptions } from '@mui/material';
|
|
|
2
2
|
import type { SessionRole } from '@salsita-ai/contracts/api';
|
|
3
3
|
import type { AssistantManifest, ChunksSpec, DataSpec, ElementRegistration, HandlerRegistration } from '../../application/index.js';
|
|
4
4
|
import type { AnyDomainComponentOptic } from '../../components/index.js';
|
|
5
|
-
import type { Any$EntityReflections, AnyAliasMap, AnyAllowedRootEntityTypes, AnyDomainFactory, AnyEntityReflections, AnyExpressions, AnyProductPreset, DomainEntity, MigrateFunction } from '../../core/index.js';
|
|
5
|
+
import type { ActionDefinitions, Any$EntityReflections, AnyActionImplementations, AnyAliasMap, AnyAllowedRootEntityTypes, AnyDomainFactory, AnyEntityReflections, AnyExpressions, AnyProductPreset, DomainEntity, MigrateFunction } from '../../core/index.js';
|
|
6
6
|
import type { AnyCreateTransformersFactory } from '../../domain-context/store-system/store-system.js';
|
|
7
7
|
export interface ApplicationConfiguratorSpec {
|
|
8
8
|
readonly modelVersion: number;
|
|
@@ -11,6 +11,13 @@ export interface ApplicationConfiguratorSpec {
|
|
|
11
11
|
readonly entityReflections: AnyEntityReflections;
|
|
12
12
|
readonly $entityReflections: Any$EntityReflections;
|
|
13
13
|
readonly expressions: AnyExpressions;
|
|
14
|
+
/**
|
|
15
|
+
* The actions the application declares and their implementations. Seeded from the domain factory
|
|
16
|
+
* during mount; editor hot reload replaces the declarations when the spec changes and the
|
|
17
|
+
* implementations when a file in `src/actions/` changes.
|
|
18
|
+
*/
|
|
19
|
+
readonly actions: ActionDefinitions;
|
|
20
|
+
readonly actionImplementations: AnyActionImplementations;
|
|
14
21
|
readonly allowedRootEntityTypes: AnyAllowedRootEntityTypes;
|
|
15
22
|
readonly migrate: MigrateFunction<DomainEntity<string>>;
|
|
16
23
|
readonly presets: readonly AnyProductPreset[];
|
|
@@ -60,6 +67,13 @@ export interface ApplicationAdminSpec {
|
|
|
60
67
|
readonly entityReflections: AnyEntityReflections;
|
|
61
68
|
readonly $entityReflections: Any$EntityReflections;
|
|
62
69
|
readonly expressions: AnyExpressions;
|
|
70
|
+
/**
|
|
71
|
+
* The actions the application declares and their implementations. Seeded from the domain factory
|
|
72
|
+
* during mount; editor hot reload replaces the declarations when the spec changes and the
|
|
73
|
+
* implementations when a file in `src/actions/` changes.
|
|
74
|
+
*/
|
|
75
|
+
readonly actions: ActionDefinitions;
|
|
76
|
+
readonly actionImplementations: AnyActionImplementations;
|
|
63
77
|
readonly allowedRootEntityTypes: AnyAllowedRootEntityTypes;
|
|
64
78
|
readonly migrate: MigrateFunction<DomainEntity<string>>;
|
|
65
79
|
readonly preset: AnyProductPreset;
|
package/dist/domain/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from './core/index.js';
|
|
2
|
+
export { createActionFactory } from './actions/action-factory.js';
|
|
3
|
+
export { type ActionImplementationConflicts, findActionImplementationConflicts, } from './actions/prepare-action-implementations.js';
|
|
2
4
|
export { createConstantExpressionFactory } from './expressions/constant-expressions.js';
|
|
3
5
|
export { createCustomExpressionFactory } from './expressions/custom-expression.js';
|
|
4
6
|
export { createCustomInvariantFactory, type StaticallyDefinedViolations } from './invariants/custom-invariants.js';
|
package/dist/domain/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./core/index.js";export{createConstantExpressionFactory}from"./expressions/constant-expressions.js";export{createCustomExpressionFactory}from"./expressions/custom-expression.js";export{createCustomInvariantFactory}from"./invariants/custom-invariants.js";export{InvariantBuilder}from"./invariants/invariants.js";export{compareSeverity}from"./invariants/violation.js";export{violationsComponent}from"./invariants/violation-component.js";export{createRelationFactory}from"./relations/relation-factory.js";export{attachMultipleReferenceComponent,attachSingleReferenceComponent,referenceComponent}from"./relations/reference-component.js";export{composedOfComponent}from"./relations/composed-of.js";export{createSingleReferenceRead,createSingleReferenceWrite,createMultipleReferenceRead,createMultipleReferenceWrite,createSingleCompositionRead,createMultipleCompositionRead,createEmptyWrite}from"./relations/component-factories.js";export{systemVirtualEntityId}from"./components/system-virtual-entity.js";export{navigationStateComponent,isNavigationComponentSnapshot,isSystemNavigationComponentSnapshot}from"./components/navigation-state-component.js";export{hoverStateComponent,isHoverStateComponentSnapshot,isSystemHoverStateComponentSnapshot}from"./components/hover-state-component.js";export{selectionStateComponent,isSelectionComponentSnapshot,isSystemSelectionComponentSnapshot}from"./components/selection-state-component.js";export{viewStateComponent,isViewComponentSnapshot,isSystemViewComponentSnapshot}from"./components/view-state-component.js";export{toolStateComponent,isToolStateComponentSnapshot,isSystemToolStateComponentSnapshot}from"./components/tool-state-component.js";export{debugStateComponent,isDebugStateComponentSnapshot,isSystemDebugStateComponentSnapshot}from"./components/debug-state-component.js";export{fullscreenStateComponent,isFullscreenStateComponentSnapshot,isSystemFullscreenStateComponentSnapshot}from"./components/fullscreen-state-component.js";export{dragStateComponent,isDragStateComponentSnapshot,isSystemDragStateComponentSnapshot}from"./components/drag-state-component.js";export{viewportStateComponent,isViewportStateComponentSnapshot,isSystemViewportStateComponentSnapshot,VIEWPORTS}from"./components/viewport-state-component.js";export{ComponentSystemFilterPropsSchema,getComponentSystemFilterState,CombinedComponentFilterSchema}from"./components/system-component-filter.js";export{ComponentSystemFilterSchema}from"./components/legacy-filter.js";export{DomainComponentOpticBuilder}from"./components/domain-component-optic.js";export{groupComponentsByEntityIdAndName,isEqualGroupedComponentSnapshots}from"./components/group-components-by-entity-id-and-name.js";export{SystemComponentBuilder}from"./components/system-component-builder.js";export{isComponentModificationOfType,systemUpdateFactory,createUpdateFactory}from"./components/updates.js";export{DomainBuilder}from"./domain-builder.js";export{memoEval,isMemoizedArray,isMemoizedObject}from"./utils/memo-eval.js";export{cloneEvalCache,getEvalCache,setEvalCache,createEvalCacheToken}from"./utils/eval-cache.js";export{areProfilerLabelsEnabled,setProfilerLabelsEnabled}from"./utils/profiler-label.js";export*from"./dimensions/index.js";export*from"./domain-context/index.js";export*from"./system-components/index.js";export*from"./sketching/index.js";export*from"./projections/index.js";export*from"./admin-domain/index.js";export*from"./application/index.js";export*from"./scene/index.js";export{getAllPhxDefinitions}from"./system-definitions.js";export{availableSystemComponents,componentsByName}from"./available-system-components.js";export*from"./mocks/index.js";export*from"./domain-runtime/index.js";
|
|
1
|
+
export*from"./core/index.js";export{createActionFactory}from"./actions/action-factory.js";export{findActionImplementationConflicts}from"./actions/prepare-action-implementations.js";export{createConstantExpressionFactory}from"./expressions/constant-expressions.js";export{createCustomExpressionFactory}from"./expressions/custom-expression.js";export{createCustomInvariantFactory}from"./invariants/custom-invariants.js";export{InvariantBuilder}from"./invariants/invariants.js";export{compareSeverity}from"./invariants/violation.js";export{violationsComponent}from"./invariants/violation-component.js";export{createRelationFactory}from"./relations/relation-factory.js";export{attachMultipleReferenceComponent,attachSingleReferenceComponent,referenceComponent}from"./relations/reference-component.js";export{composedOfComponent}from"./relations/composed-of.js";export{createSingleReferenceRead,createSingleReferenceWrite,createMultipleReferenceRead,createMultipleReferenceWrite,createSingleCompositionRead,createMultipleCompositionRead,createEmptyWrite}from"./relations/component-factories.js";export{systemVirtualEntityId}from"./components/system-virtual-entity.js";export{navigationStateComponent,isNavigationComponentSnapshot,isSystemNavigationComponentSnapshot}from"./components/navigation-state-component.js";export{hoverStateComponent,isHoverStateComponentSnapshot,isSystemHoverStateComponentSnapshot}from"./components/hover-state-component.js";export{selectionStateComponent,isSelectionComponentSnapshot,isSystemSelectionComponentSnapshot}from"./components/selection-state-component.js";export{viewStateComponent,isViewComponentSnapshot,isSystemViewComponentSnapshot}from"./components/view-state-component.js";export{toolStateComponent,isToolStateComponentSnapshot,isSystemToolStateComponentSnapshot}from"./components/tool-state-component.js";export{debugStateComponent,isDebugStateComponentSnapshot,isSystemDebugStateComponentSnapshot}from"./components/debug-state-component.js";export{fullscreenStateComponent,isFullscreenStateComponentSnapshot,isSystemFullscreenStateComponentSnapshot}from"./components/fullscreen-state-component.js";export{dragStateComponent,isDragStateComponentSnapshot,isSystemDragStateComponentSnapshot}from"./components/drag-state-component.js";export{viewportStateComponent,isViewportStateComponentSnapshot,isSystemViewportStateComponentSnapshot,VIEWPORTS}from"./components/viewport-state-component.js";export{ComponentSystemFilterPropsSchema,getComponentSystemFilterState,CombinedComponentFilterSchema}from"./components/system-component-filter.js";export{ComponentSystemFilterSchema}from"./components/legacy-filter.js";export{DomainComponentOpticBuilder}from"./components/domain-component-optic.js";export{groupComponentsByEntityIdAndName,isEqualGroupedComponentSnapshots}from"./components/group-components-by-entity-id-and-name.js";export{SystemComponentBuilder}from"./components/system-component-builder.js";export{isComponentModificationOfType,systemUpdateFactory,createUpdateFactory}from"./components/updates.js";export{DomainBuilder}from"./domain-builder.js";export{memoEval,isMemoizedArray,isMemoizedObject}from"./utils/memo-eval.js";export{cloneEvalCache,getEvalCache,setEvalCache,createEvalCacheToken}from"./utils/eval-cache.js";export{areProfilerLabelsEnabled,setProfilerLabelsEnabled}from"./utils/profiler-label.js";export*from"./dimensions/index.js";export*from"./domain-context/index.js";export*from"./system-components/index.js";export*from"./sketching/index.js";export*from"./projections/index.js";export*from"./admin-domain/index.js";export*from"./application/index.js";export*from"./scene/index.js";export{getAllPhxDefinitions}from"./system-definitions.js";export{availableSystemComponents,componentsByName}from"./available-system-components.js";export*from"./mocks/index.js";export*from"./domain-runtime/index.js";
|
|
@@ -394,6 +394,8 @@ export declare const createMockDomainRuntime: <ENTITIES extends DomainEntity<str
|
|
|
394
394
|
getActiveConfigurationId: () => string;
|
|
395
395
|
getFactory: () => import("../index.js").AnyDomainFactory;
|
|
396
396
|
getDomainExpressions: () => import("../index.js").AnyExpressions;
|
|
397
|
+
getActionDefinitions: () => Readonly<Record<string, import("../index.js").ActionDefinition>>;
|
|
398
|
+
getActionImplementations: () => Readonly<Record<string, import("../index.js").AnyActionImplementation>>;
|
|
397
399
|
getModelVersion: () => number;
|
|
398
400
|
getAliasMap: () => import("../index.js").AnyAliasMap;
|
|
399
401
|
getAllowedRootEntityTypes: () => import("../index.js").AnyAllowedRootEntityTypes;
|
|
@@ -434,6 +436,7 @@ export declare const createMockDomainRuntime: <ENTITIES extends DomainEntity<str
|
|
|
434
436
|
getNavigationSystem: () => import("../domain-context/navigation-system/navigation-system.js").AnyNavigationSystem;
|
|
435
437
|
getUndoSystem: () => import("../domain-context/undo-system.js").AnyUndoSystem;
|
|
436
438
|
getRecipeCookerSystem: () => import("../index.js").AnyRecipeCookerSystem;
|
|
439
|
+
getActionSystem: () => import("../index.js").AnyActionSystem;
|
|
437
440
|
getBlenderProjections: () => import("../index.js").AnyBlenderProjections;
|
|
438
441
|
getExpressionContext: () => import("../index.js").AnyExpressionContext;
|
|
439
442
|
getDomainSystems: () => import("../index.js").AnyDomainContextSystems;
|
|
@@ -500,6 +503,8 @@ export declare const createMockDomainRuntime: <ENTITIES extends DomainEntity<str
|
|
|
500
503
|
getActiveConfigurationId: () => string;
|
|
501
504
|
getFactory: () => import("../index.js").AnyDomainFactory;
|
|
502
505
|
getDomainExpressions: () => import("../index.js").AnyExpressions;
|
|
506
|
+
getActionDefinitions: () => Readonly<Record<string, import("../index.js").ActionDefinition>>;
|
|
507
|
+
getActionImplementations: () => Readonly<Record<string, import("../index.js").AnyActionImplementation>>;
|
|
503
508
|
getModelVersion: () => number;
|
|
504
509
|
getAliasMap: () => import("../index.js").AnyAliasMap;
|
|
505
510
|
getAllowedRootEntityTypes: () => import("../index.js").AnyAllowedRootEntityTypes;
|
|
@@ -540,6 +545,7 @@ export declare const createMockDomainRuntime: <ENTITIES extends DomainEntity<str
|
|
|
540
545
|
getNavigationSystem: () => import("../domain-context/navigation-system/navigation-system.js").AnyNavigationSystem;
|
|
541
546
|
getUndoSystem: () => import("../domain-context/undo-system.js").AnyUndoSystem;
|
|
542
547
|
getRecipeCookerSystem: () => import("../index.js").AnyRecipeCookerSystem;
|
|
548
|
+
getActionSystem: () => import("../index.js").AnyActionSystem;
|
|
543
549
|
getBlenderProjections: () => import("../index.js").AnyBlenderProjections;
|
|
544
550
|
getExpressionContext: () => import("../index.js").AnyExpressionContext;
|
|
545
551
|
getDomainSystems: () => import("../index.js").AnyDomainContextSystems;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import t from"lodash-es/debounce.js";import r from"promise-queue";import{createContext as o,useCallback as n,useContext as i,useEffect as a,useMemo as s,useRef as c,useState as m}from"react";import{match as l}from"ts-pattern";import{ApplicationRuntime as p,BinaryFile as u,RawProjectFiles as d,RuntimeReferenceStore as g,TextFile as f,buildPhoenixDefinitions as S,isConfiguratorModelSchemaCompatible as v,isTextFile as h,parseApplicationFiles as y}from"#package/application-spec";import{findActionImplementationConflicts as E,getAllPhxDefinitions as x}from"#package/domain";import{useApplicationRuntime as A,useMountGuard as C}from"#package/react-sdk";import{useEditorConnection as D}from"../services/EditorConnectionContext.js";import{trpc as I}from"../services/trpc.js";import{applyRuntimeReset as N,applySpecUpdate as w,prepareRuntimeRefresh as P,prepareRuntimeReset as _}from"./apply-spec-update.js";import{useDiagnostics as R}from"./use-diagnostics.js";import{useImplementationFiles as j}from"./use-implementation-files.js";import{getWasmSwcParsers as L}from"./wasm-swc-parsers.js";let k=o(null),T={debug:e=>console.debug(e)},M=e=>e instanceof Error?e.message:String(e);export const DomainSpecProvider=o=>{let{children:i,domainSpec:O,initialRawProjectFiles:b}=o,[$,F]=m(s(()=>O?[{fileName:"domain.yaml",content:O}]:b?b.files.filter(h).map(e=>({fileName:e.name,content:e.content})):[],[O,b])),[z,H]=m(null),q=s(()=>new g,[]),G=s(()=>S(x()),[]),U=c(null),Q=A(),{getImplementationFiles:B}=j(),{diagnostics:V,unreadDiagnosticCount:X,setDiagnostics:Y,pushDiagnostic:Z,clearDiagnostics:J,markDiagnosticsRead:K}=R(),W=s(()=>new r(1,1/0),[]),ee=c(0),et=c(null),{mutateAsync:er}=I.requestSpecFiles.useMutation(),{mutateAsync:eo}=I.save.useMutation(),en=C(),{localMode:ei,connectionStatus:ea}=D(),{data:es}=I.getEditorConfig.useQuery(void 0,{enabled:!ei&&"connected"===ea}),ec=ei||es?.specSync===!0,em=$.length>0?$:void 0,el=s(()=>$.map(e=>e.fileName),[$]),ep=s(()=>t(async e=>{if(!ei&&"connected"===ea&&0!==e.length)try{await eo(e.map(e=>({fileName:e.fileName,content:e.content})))}catch(e){console.error("[DomainSpecContext] Failed to save files to disk:",e)}},1e3),[ei,ea,eo]);a(()=>()=>{ep.cancel()},[ep]);let eu=n(()=>{H(null)},[]),ed=n(async(e,t)=>{F(r=>{let o=r.find(t=>t.fileName===e)?r.map(r=>r.fileName===e?{...r,content:t}:r):[...r,{fileName:e,content:t}];return ep(o),o})},[ep]),eg=n(async(e,t)=>{let r,o,n=()=>en()&&ee.current===t;if(!n())return;let i=d(e.rawProjectFiles.files.map(e=>l(e).with({kind:"text"},e=>f(e.name,e.content)).with({kind:"binary"},e=>u(e.name)).exhaustive()));F(i.files.filter(h).map(e=>({fileName:e.name,content:e.content})));try{r=await L()}catch(e){if(!n())return;Y([{code:"MODULE_ANALYZER_UNAVAILABLE",message:`The editor's module analyzer failed to load: ${e instanceof Error?e.message:String(e)}`,severity:"error",source:"spec",path:[]}]);return}if(!n())return;let a=y({rawProjectFiles:i,phxDefinitions:G},{analyzer:r.analyzer,evalExpressionParser:r.evalExpressionParser,referenceStore:q,logger:T});if(console.info(`[DomainSpecContext] Spec parsed: ${a.ok?"ok":"error"}, ${a.diagnostics.length} diagnostics`),!a.ok)return void Y([...a.errors,...a.diagnostics].map(e=>({...e,source:"spec"})));J();let{applicationSpec:s}=a.value,c=await B({application:a.value,projectRoot:e.projectRoot});if(!n())return;if(c.errors.length>0)return void Y(c.errors.map(e=>({code:e.code,message:e.message,severity:"error",source:"reload",path:[]})));let m=E([...s.configurator.actions.values()].map(e=>String(e.name)),c.actionImplementations??Q.getState().spec.configurator.actionImplementations);if(m.extra.length>0&&console.error(`[DomainSpecContext] Action implementations without a declaration: ${m.extra.join(", ")}`),m.missing.length>0){let e=`Missing action implementations: ${m.missing.join(", ")}. Add each to a default export of phx.domain.implementActions({ ... }) in src/actions/.`;console.error(`[DomainSpecContext] ${e}`),Z({code:"MISSING_ACTION_IMPLEMENTATIONS",message:e,severity:"error",source:"runtime"});return}let g=p(s,q,c.implementations,c.importedTransformers,c.invariantImplementations,c.adminImplementations);if(!g.ok){let e=`Missing expression implementations: ${g.missingExpressions.map(e=>`${e.entityType}.${e.exprName}`).join(", ")}`;console.error(`[DomainSpecContext] ${e}`),Z({code:"MISSING_EXPRESSION_IMPLEMENTATIONS",message:e,severity:"error",source:"runtime"});return}let{runtime:S}=g,x=null===U.current||v(U.current.configurator,s.configurator),A=Q.selectors.environment.getPersistenceConfig();if(!x){let e;if("server"===A.type)return void Z({code:"HOT_RELOAD_MODEL_CHANGE_REQUIRES_RESTART",message:"Domain model changes require an application restart and were not applied.",severity:"error",source:"runtime"});if(!Q.selectors.domainContext.configurator.getInitializationState().isCurrent)return void Q.selectors.domainServices.getLogger().debug("[DomainSpecContext] Skipping the model reset because no configurator session is initialized; the change applies once a session loads under the new spec.");try{e=_({runtime:S,implementationFiles:c,previousSpec:Q.getState().spec})}catch(e){Z({code:"HOT_RELOAD_PREPARE_FAILED",message:M(e),severity:"error",source:"runtime"});return}return Q.selectors.domainServices.getLogger().debug("[DomainSpecContext] Reseeding the reset session directly from the spec preset; onPresetLoadedHandler and ProductSelected analytics are intentionally skipped."),N(Q,e,Q.selectors.domainApplicationContext.configurator.getConfigurationPersistSystem().revisionId$.value),void(U.current=s)}try{o=P({runtime:S,implementationFiles:c,previousSpec:Q.getState().spec})}catch(e){Z({code:"HOT_RELOAD_PREPARE_FAILED",message:M(e),severity:"error",source:"runtime"});return}n()&&(w(Q,o),U.current=s)},[Q,B,en,G,Z,q,Y,J]),ef=c(null),eS=n(e=>{let t=ee.current+1;ee.current=t,et.current={data:e,generation:t},W.add(async()=>{let e=et.current;e&&e.data!==ef.current&&(et.current=null,ef.current=e.data,await eg(e.data,e.generation))})},[eg,W]);I.onSpecChange.useSubscription(void 0,{enabled:!ei&&ec,onData:eS}),a(()=>{!ei&&ec&&er().catch(()=>{console.warn("[DomainSpecContext] Failed to request spec files")})},[er,ei,ec]);let ev=s(()=>({files:em,fileNames:el,updateFile:ed,parsing:!1,parseError:z,clearParseError:eu,diagnostics:V,clearDiagnostics:J,unreadDiagnosticCount:X,markDiagnosticsRead:K}),[em,el,ed,z,eu,V,J,X,K]);return e(k.Provider,{value:ev,children:i})};export const useDomainSpecContext=()=>{let e=i(k);if(null===e)throw Error("useDomainSpecContext must be used within DomainSpecProvider");return e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveImportedTransformers as e}from"#package/domain";import{getPhoenixThemes as t}from"#package/ui-sdk";import{getCustomComponentOptics as n}from"./use-implementation-files.js";let s=s=>{var o;let a,
|
|
1
|
+
import{resolveImportedTransformers as e}from"#package/domain";import{getPhoenixThemes as t}from"#package/ui-sdk";import{getCustomComponentOptics as n}from"./use-implementation-files.js";let s=s=>{var o;let i,a,{runtime:r,implementationFiles:m,previousSpec:c}=s,p=r.configurator,l=c.configurator,u=m.handlers?.handlers??l.handlers,f=m.handlers?((e,t,n)=>{let s={};for(let o of e)s[o.name]=t?.[o.name]??n?.[o.name]??o.name;return s})(u,m.handlers.nameHashes,l.handlerHashes):l.handlerHashes,d=m.elements?.elements??l.elements,h=m.elements?((e,t,n)=>{let s={},o=0;for(let i of e)if("entity"===i.type||"layout"===i.type)s[i.name]=t?.[i.name]??n?.[i.name]??i.name;else{let e=`icon:${o}`;s[e]=t?.[e]??n?.[e]??`${e}:${i.elements.length}`,o+=1}return s})(d,m.elements.nameHashes,l.elementHashes):l.elementHashes,g=null!==m.customComponentOptics,R=p.componentOptics.changed||g?[...p.componentOptics.optics.map(e=>e.optic),...m.customComponentOptics??n(l.componentOptics)]:l.componentOptics,x=p.transformersRuntime.changed?t=>e(p.transformersRuntime.importedTransformers,p.transformersRuntime.specTransformers,t):l.createTransformers;return{presets:p.presetRuntime.changed?p.presetRuntime.presets:l.presets,theme:p.themeRuntime.changed?(o=p.themeRuntime,i=t(),a=Object.entries(i).find(([e])=>e===o.preset)?.[1]??{},Object.keys(o.options).length>0?{...a,...o.options}:a):l.theme,assistant:p.assistantRuntime.changed?p.assistantRuntime.assistant:l.assistant,navigationStates:p.statesRuntime.changed?p.statesRuntime.navigationStates:l.navigationStates,viewStates:p.statesRuntime.changed?p.statesRuntime.viewStates:l.viewStates,toolStates:p.statesRuntime.changed?p.statesRuntime.toolStates:l.toolStates,exportStates:p.statesRuntime.changed?p.statesRuntime.exportStates:l.exportStates,componentOptics:R,createTransformers:x,handlers:u,handlerHashes:f,elements:d,elementHashes:h}};export const prepareRuntimeRefresh=e=>{let{runtime:t,previousSpec:n}=e,o=n.configurator,i=s(e),a=t.configurator.expressionRuntime.changed?t.configurator.expressionRuntime.merged:o.expressions,r=t.configurator.actionsRuntime.changed?t.configurator.actionsRuntime.definitions:o.actions,m=e.implementationFiles.actionImplementations??o.actionImplementations;return{nextSpec:{...n,configurator:{...o,...i,expressions:a,actions:r,actionImplementations:m}}}};export const prepareRuntimeReset=e=>{let{runtime:t,previousSpec:n}=e,o=n.configurator,i=s(e),a=t.configurator.expressionRuntime.merged,r=t.configurator.actionsRuntime.definitions,m=e.implementationFiles.actionImplementations??o.actionImplementations,c=t.configurator.modelRuntime.domainBuilder.withExpressions(a).withActions(Object.values(r)).withActionImplementations(m).build(),p=i.presets[0];if(void 0===p)throw Error("Cannot reset the configurator after a model change because the application spec has no presets.");return{firstPreset:p,nextSpec:{...n,configurator:{...o,...i,modelVersion:c.context.modelVersion,factory:c,aliasMap:c.context.aliasMap,entityReflections:c.context.entityReflections,$entityReflections:c.context.$entityReflections,expressions:a,actions:r,actionImplementations:m,allowedRootEntityTypes:c.context.allowedRootEntityTypes,migrate:c.context.migrate}}}};let o=(e,t)=>{e.actions.spec.updateSpec(t)};export const applyRuntimeRefresh=(e,t)=>o(e,t.nextSpec);export const applyRuntimeReset=(e,t,n)=>{o(e,t.nextSpec),e.actions.loadedData.completeConfiguratorLoad({initialRevisionId:n,initialEntities:t.firstPreset.initialDomainEntities,modelVersion:t.nextSpec.configurator.modelVersion,rootEntityType:t.firstPreset.rootEntityType,schemaIdentity:t.nextSpec.configurator.factory})};export const applySpecUpdate=(e,t)=>o(e,t.nextSpec);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Application, ExpressionImplementations, InvariantImplementations } from '#package/application-spec';
|
|
2
|
-
import { type DomainComponentOptic, type DomainEntity, type ElementRegistration, type HandlerRegistration, type ImportedTransformer, type SystemComponentTypeConstraint } from '#package/domain';
|
|
2
|
+
import { type AnyActionImplementations, type DomainComponentOptic, type DomainEntity, type ElementRegistration, type HandlerRegistration, type ImportedTransformer, type SystemComponentTypeConstraint } from '#package/domain';
|
|
3
3
|
type AnyImportedTransformer = ImportedTransformer<any, any, any, any, any, any, any>;
|
|
4
4
|
type RuntimeData = Record<string, unknown>;
|
|
5
5
|
type RuntimeEntity = DomainEntity<string>;
|
|
@@ -23,11 +23,13 @@ export interface ReloadError {
|
|
|
23
23
|
* The freshly reloaded (or cached) implementation files needed to build an `ApplicationRuntime`.
|
|
24
24
|
*
|
|
25
25
|
* `implementations`, `adminImplementations`, `invariantImplementations`, `importedTransformers` and `customComponentOptics` always contain the latest
|
|
26
|
-
* successfully loaded values.
|
|
26
|
+
* successfully loaded values. So does `actionImplementations`, which is `null` only until the first successful load: a round
|
|
27
|
+
* that loaded them may be dropped before it is applied, and the next round must still carry them.
|
|
27
28
|
* `handlers`/`elements` are `null` when their category did not change this round.
|
|
28
29
|
*/
|
|
29
30
|
export interface ImplementationFiles {
|
|
30
31
|
readonly implementations: ExpressionImplementations;
|
|
32
|
+
readonly actionImplementations: AnyActionImplementations | null;
|
|
31
33
|
readonly adminImplementations?: ExpressionImplementations;
|
|
32
34
|
readonly invariantImplementations: InvariantImplementations;
|
|
33
35
|
readonly importedTransformers: readonly AnyImportedTransformer[];
|
|
@@ -40,6 +42,8 @@ export interface GetImplementationFilesProps {
|
|
|
40
42
|
readonly application: Application;
|
|
41
43
|
readonly projectRoot: string;
|
|
42
44
|
}
|
|
45
|
+
/** Merges the default exports of the `src/actions/` modules by action name, as the generated barrel does. */
|
|
46
|
+
export declare const resolveActionModules: (modules: readonly AnyActionImplementations[]) => AnyActionImplementations;
|
|
43
47
|
type ExpressionModules = ReadonlyArray<Record<string, Record<string, unknown>>>;
|
|
44
48
|
type ResolvedExpressions = ExpressionImplementations;
|
|
45
49
|
export declare const resolveExpressionModules: (modules: ExpressionModules, aliasMap: Record<string, readonly string[]>) => ResolvedExpressions;
|
|
@@ -50,7 +54,7 @@ export declare const getCustomComponentOptics: <ComponentOptic extends {
|
|
|
50
54
|
}>(componentOptics: readonly ComponentOptic[]) => readonly ComponentOptic[];
|
|
51
55
|
/**
|
|
52
56
|
* Owns the should-reload gating and cross-update caching for project implementation files
|
|
53
|
-
* (expressions, invariants, components, transformers, handlers, elements). Returns `getImplementationFiles`,
|
|
57
|
+
* (expressions, actions, invariants, components, transformers, handlers, elements). Returns `getImplementationFiles`,
|
|
54
58
|
* which reloads changed categories and returns the merged set with per-category reload errors.
|
|
55
59
|
* Invariants also retry failed imports and refresh when their generated declarations change.
|
|
56
60
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as e,useRef as n}from"react";import{expandAlias as t}from"#package/domain";import{importImplementationFile as r}from"./import-implementation-file.js";let a=e=>e instanceof Error?e.message:String(e),o=async(e,n)=>{let t=Date.now();return Promise.all(e.map(async e=>{let a=await r(`/@fs/${n}/${e}?t=${t}`);return{filePath:e,module:a}}))};export const resolveExpressionModules=(e,n)=>{let r={};for(let n of e)for(let[e,t]of Object.entries(n))r[e]={...r[e],...t};let a={};for(let[e,o]of Object.entries(r))for(let r of t(n,e)){let n=a[r]??{};for(let[t,r]of Object.entries(o))n[t]={...r,origin:{name:t,typeOrAlias:e}};a[r]=n}return a};export const resolveComponentModules=e=>e.flatMap(e=>Array.isArray(e)?e:[e]);export const mergeComponentOptics=(e,n)=>e.concat(n);export const getCustomComponentOptics=e=>e.filter(e=>!0!==e.generated);let
|
|
1
|
+
import{useCallback as e,useRef as n}from"react";import{expandAlias as t}from"#package/domain";import{importImplementationFile as r}from"./import-implementation-file.js";let a=e=>e instanceof Error?e.message:String(e),o=async(e,n)=>{let t=Date.now();return Promise.all(e.map(async e=>{let a=await r(`/@fs/${n}/${e}?t=${t}`);return{filePath:e,module:a}}))};export const resolveActionModules=e=>e.reduce((e,n)=>({...e,...n}),{});let s=async(e,n)=>{let t=await o(e,n);return resolveActionModules(t.map(({module:e})=>e))};export const resolveExpressionModules=(e,n)=>{let r={};for(let n of e)for(let[e,t]of Object.entries(n))r[e]={...r[e],...t};let a={};for(let[e,o]of Object.entries(r))for(let r of t(n,e)){let n=a[r]??{};for(let[t,r]of Object.entries(o))n[t]={...r,origin:{name:t,typeOrAlias:e}};a[r]=n}return a};export const resolveComponentModules=e=>e.flatMap(e=>Array.isArray(e)?e:[e]);export const mergeComponentOptics=(e,n)=>e.concat(n);export const getCustomComponentOptics=e=>e.filter(e=>!0!==e.generated);let i=async(e,n,t)=>{let r=await o(e,t);return resolveExpressionModules(r.map(e=>e.module),n)},l=async(e,n)=>{let t=await o(e,n);return resolveComponentModules(t.map(e=>e.module))},m=async(e,n)=>{let t=await o(e,n),r={};for(let{module:e}of t)for(let[n,t]of Object.entries(e))r[n]=[...r[n]??[],...t];return r},c=async(e,n)=>(await o(e,n)).map(({filePath:e,module:n})=>({name:e.replace(/^.*\//,"").replace(/\.tsx?$/,""),transformer:n})),p=async(e,n)=>(await o(e,n)).map(({filePath:e,module:n})=>({filePath:e,registrations:Array.isArray(n)?n:[n]})),u=async(e,n)=>(await o(e,n)).map(({filePath:e,module:n})=>({filePath:e,registrations:Array.isArray(n)?n:[n]}));export const useImplementationFiles=()=>{let t=n({}),r=n(null),o=n({}),f=n(0),d=n(null),h=n({}),g=n(null),E=n(null),F=n(null),w=n([]),y=n(null),I=n(null),A=n(new Map),O=n(new Map);return{getImplementationFiles:e(async e=>{let{application:n,projectRoot:M}=e,R=++f.current,{applicationSpec:C,categorizedFiles:v}=n,x=[],D=t.current,L=o.current,S=h.current,_=F.current,$=w.current,b=v.expressionsChanged,N=v.actionsChanged,j=v.componentsChanged,P=v.transformersChanged,H=v.handlersChanged,T=v.elementsChanged,k=Object.fromEntries(v.invariants.map(e=>[e.file.name,e.depHash])),J=g.current,X=JSON.stringify(C.configurator.invariants.entries),V=null===J||E.current!==X||Object.keys(J).length!==v.invariants.length||v.invariants.some(e=>J[e.file.name]!==e.depHash);if(console.info(`[useImplementationFiles] Changed: spec=${v.specChanged}, expressions=${v.expressionsChanged}, actions=${v.actionsChanged}, adminExpressions=${v.adminExpressionsChanged}, transformers=${v.transformersChanged}, handlers=${v.handlersChanged}, elements=${v.elementsChanged}`),b){console.info("[useImplementationFiles] Reloading expression implementations");try{let e=Object.fromEntries(C.configurator.latestModel.aliases);t.current=D=await i(v.expressions.map(e=>e.file.name),e,M)}catch(e){console.warn("[useImplementationFiles] Failed to reload expressions:",e),x.push({code:"RELOAD_EXPRESSIONS_FAILED",message:a(e)})}}let q=r.current;if(N){console.info("[useImplementationFiles] Reloading action implementations");try{r.current=q=await s(v.actions.map(e=>e.file.name),M)}catch(e){console.warn("[useImplementationFiles] Failed to reload actions:",e),x.push({code:"RELOAD_ACTIONS_FAILED",message:a(e)})}}let z=JSON.stringify({projectRoot:M,files:v.adminExpressions.map(e=>[e.file.name,e.depHash]),aliases:[...C.admin.latestModel.aliases]});if(R===f.current&&d.current!==z)try{L=await i(v.adminExpressions.map(e=>e.file.name),Object.fromEntries(C.admin.latestModel.aliases),M),R===f.current&&(o.current=L,d.current=z)}catch(e){x.push({code:"RELOAD_ADMIN_EXPRESSIONS_FAILED",message:a(e)})}if(j){console.info("[useImplementationFiles] Reloading component optics");try{F.current=_=await l(v.components.map(e=>e.file.name),M)}catch(e){console.warn("[useImplementationFiles] Failed to reload components:",e),x.push({code:"RELOAD_COMPONENTS_FAILED",message:a(e)})}}if(V){console.info("[useImplementationFiles] Reloading invariant implementations");try{h.current=S=await m(v.invariants.map(e=>e.file.name),M),g.current=k,E.current=X}catch(e){console.warn("[useImplementationFiles] Failed to reload invariants:",e),x.push({code:"RELOAD_INVARIANTS_FAILED",message:a(e)})}}if(P){console.info("[useImplementationFiles] Reloading transformer implementations");try{w.current=$=await c(v.transformers.map(e=>e.file.name),M)}catch(e){console.warn("[useImplementationFiles] Failed to reload transformers:",e),x.push({code:"RELOAD_TRANSFORMERS_FAILED",message:a(e)})}}let B=null;if(H){console.info("[useImplementationFiles] Reloading handler implementations");try{let e=Object.fromEntries(v.handlers.map(e=>[e.file.name,e.depHash])),n=y.current,t=t=>null===n||n[t]!==e[t],r=O.current,a=v.handlers.map(e=>e.file.name),o=a.filter(e=>t(e)||!r.has(e)),s=await p(o,M),i=new Map(s.map(e=>[e.filePath,e])),l=a.map(e=>{let n=i.get(e)??r.get(e);if(!n)throw Error(`Handler file "${e}" was neither re-imported nor cached from a previous round. This is a hot-reload bookkeeping bug — reload the editor page to recover.`);return n}),m=l.flatMap(e=>e.registrations),c={};for(let{filePath:n,registrations:r}of l){let a=t(n)?e[n]:void 0;if(a)for(let e of r)c[e.name]=a}console.info(`[useImplementationFiles] Staged handlers for registry (${m.length} total)`),B={handlers:m,nameHashes:c},O.current=new Map(l.map(e=>[e.filePath,e])),y.current=e}catch(e){console.warn("[useImplementationFiles] Failed to reload handlers:",e),x.push({code:"RELOAD_HANDLERS_FAILED",message:a(e)})}}let G=null;if(T){console.info("[useImplementationFiles] Reloading element implementations");try{let e=Object.fromEntries(v.elements.map(e=>[e.file.name,e.depHash])),n=I.current,t=t=>null===n||n[t]!==e[t],r=A.current,a=v.elements.map(e=>e.file.name),o=a.filter(e=>t(e)||!r.has(e)),s=await u(o,M),i=new Map(s.map(e=>[e.filePath,e])),l=a.map(e=>{let n=i.get(e)??r.get(e);if(!n)throw Error(`Element file "${e}" was neither re-imported nor cached from a previous round. This is a hot-reload bookkeeping bug — reload the editor page to recover.`);return n}),m=l.flatMap(e=>e.registrations),c={},p=0;for(let{filePath:n,registrations:r}of l){let a=t(n)?e[n]:void 0;for(let e of r){if("entity"===e.type||"layout"===e.type){a&&(c[e.name]=a);continue}a&&(c[`icon:${p}`]=a),p+=1}}console.info(`[useImplementationFiles] Staged elements for registry (${m.length} total)`),G={elements:m,nameHashes:c},A.current=new Map(l.map(e=>[e.filePath,e])),I.current=e}catch(e){console.warn("[useImplementationFiles] Failed to reload elements:",e),x.push({code:"RELOAD_ELEMENTS_FAILED",message:a(e)})}}return{implementations:D,actionImplementations:q,adminImplementations:L,invariantImplementations:S,importedTransformers:$,customComponentOptics:_,handlers:B,elements:G,errors:x}},[])}};
|
|
@@ -5,8 +5,8 @@ import type { AssistantSpec } from '#package/application-spec';
|
|
|
5
5
|
* because the conventions it describes belong to this SDK version and not to the server. The part
|
|
6
6
|
* about changes is left out when the schema has no `Mutation` type, the part about adding
|
|
7
7
|
* entities when it has no `addChild` mutation, the part about replacing them when it has no
|
|
8
|
-
* `replaceEntity` mutation,
|
|
9
|
-
* no options edge. The last section explains the
|
|
8
|
+
* `replaceEntity` mutation, the part about the choices of a field when it has
|
|
9
|
+
* no options edge, and the part about custom changes when the manifest exposes no action. The last section explains the
|
|
10
10
|
* `query` and `apply` tools, which every run registers whatever the schema holds.
|
|
11
11
|
*/
|
|
12
12
|
export declare const generateAssistantPrompt: (assistant: NonNullable<AssistantSpec>) => string;
|