@salsita-ai/sdk 0.50.0-develop.da56a0c6c3 → 0.50.0-develop.ea458ea381
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application-spec/errors/diagnostic-codes.d.ts +6 -0
- package/dist/application-spec/errors/diagnostic-codes.js +1 -1
- package/dist/application-spec/errors/diagnostic-messages.d.ts +6 -0
- package/dist/application-spec/errors/diagnostic-messages.js +1 -1
- package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
- package/dist/application-spec/generate-application/code/templates/application-types.js +6 -6
- package/dist/application-spec/generate-application/code/templates/configurator-domain-code.d.ts +1 -0
- package/dist/application-spec/generate-application/code/templates/configurator-domain-code.js +11 -8
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.d.ts +3 -1
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.js +70 -66
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-phx-globals.js +3 -0
- package/dist/application-spec/generate-application/code/templates/domain-spec.js +5 -5
- package/dist/application-spec/generate-application/code/templates/domain.js +2 -2
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.d.ts +11 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.js +8 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/index.d.ts +1 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/globals.js +1 -0
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js +4 -2
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +3 -1
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +2 -2
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.d.ts +2 -0
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/sections/actions-runtime.d.ts +14 -0
- package/dist/application-spec/generate-application/runtime/sections/actions-runtime.js +1 -0
- package/dist/application-spec/generate-application/runtime/sections/index.d.ts +1 -0
- package/dist/application-spec/generate-application/runtime/sections/index.js +1 -1
- package/dist/application-spec/parse-application-files/categorize/categorize-files.d.ts +3 -1
- package/dist/application-spec/parse-application-files/categorize/categorize-files.js +1 -1
- package/dist/application-spec/parse-application-files/merge/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/merge/index.js +1 -1
- package/dist/application-spec/parse-application-files/merge/merged-actions.d.ts +11 -0
- package/dist/application-spec/parse-application-files/merge/merged-actions.js +1 -0
- package/dist/application-spec/parse-application-files/merge/merged-spec.d.ts +2 -0
- package/dist/application-spec/parse-application-files/merge/merged-spec.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/raw-spec/index.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-actions.d.ts +18 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-actions.js +1 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.d.ts +14 -2
- package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.d.ts +2 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.js +1 -1
- package/dist/application-spec/parse-application-files/resolve/resolve-import-modules.js +1 -1
- package/dist/application-spec/parse-application-files/spec/application/application-spec.js +1 -1
- package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.d.ts +4 -2
- package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.js +1 -1
- package/dist/application-spec/parse-application-files/spec/common/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/spec/common/index.js +1 -1
- package/dist/application-spec/parse-application-files/spec/common/schema-ref-resolver.d.ts +23 -0
- package/dist/application-spec/parse-application-files/spec/common/schema-ref-resolver.js +1 -0
- package/dist/application-spec/parse-application-files/spec/model/names/action-name.d.ts +10 -0
- package/dist/application-spec/parse-application-files/spec/model/names/action-name.js +1 -0
- package/dist/application-spec/parse-application-files/spec/model/names/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/spec/model/names/index.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/actions.d.ts +35 -0
- package/dist/application-spec/parse-application-files/spec/sections/actions.js +1 -0
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.d.ts +3 -14
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +12 -3
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant.d.ts +5 -3
- package/dist/application-spec/parse-application-files/spec/sections/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/spec/sections/index.js +1 -1
- package/dist/configurator/application-runtime/extensions/configurator-extension-systems.d.ts +2 -1
- package/dist/configurator/application-runtime/extensions/configurator-extension-systems.js +1 -1
- package/dist/configurator/application-runtime/extensions/selectors.d.ts +2 -1
- package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +35 -0
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -0
- package/dist/configurator/{assistant → application-runtime/extensions/systems/assistant-system}/browser-details.d.ts +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/browser-details.js +1 -0
- package/dist/configurator/{assistant → application-runtime/extensions/systems/assistant-system}/graphql-tools.d.ts +13 -14
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -0
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/index.d.ts +1 -0
- package/dist/configurator/application-runtime/extensions/systems/index.js +1 -1
- package/dist/configurator/assistant/use-assistant-chat.js +1 -1
- package/dist/docs/index.json +12 -2
- package/dist/docs/other-features/domain-actions.mdx +418 -0
- package/dist/docs/phoenix/best-practices.mdx +1 -0
- package/dist/docs/phoenix/phoenix-cli.mdx +4 -2
- package/dist/docs/phoenix/project-structure.mdx +3 -0
- package/dist/docs/phoenix/sdk-builder-workflow.mdx +2 -2
- package/dist/domain/actions/action-factory.d.ts +10 -0
- package/dist/domain/actions/action-factory.js +1 -0
- package/dist/domain/actions/prepare-action-implementations.d.ts +15 -0
- package/dist/domain/actions/prepare-action-implementations.js +5 -0
- package/dist/domain/application/application-config.d.ts +3 -1
- package/dist/domain/application/assistant-mutations.d.ts +15 -14
- package/dist/domain/application/assistant-mutations.js +1 -1
- package/dist/domain/core/action.d.ts +67 -0
- package/dist/domain/core/action.js +1 -0
- package/dist/domain/core/domain-factory.d.ts +4 -0
- package/dist/domain/core/index.d.ts +1 -0
- package/dist/domain/domain-builder.d.ts +7 -0
- package/dist/domain/domain-builder.js +1 -1
- package/dist/domain/domain-context/action-system/action-system.d.ts +40 -0
- package/dist/domain/domain-context/action-system/action-system.js +1 -0
- package/dist/domain/domain-context/domain-context-systems.d.ts +5 -2
- package/dist/domain/domain-context/index.d.ts +1 -0
- package/dist/domain/domain-context/index.js +1 -1
- package/dist/domain/domain-runtime/domain-context/domain-context.js +1 -1
- package/dist/domain/domain-runtime/domain-context/selectors.d.ts +4 -0
- package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
- package/dist/domain/domain-runtime/domain-runtime.d.ts +12 -0
- package/dist/domain/domain-runtime/spec/initialize.js +1 -1
- package/dist/domain/domain-runtime/spec/types.d.ts +15 -1
- package/dist/domain/index.d.ts +2 -0
- package/dist/domain/index.js +1 -1
- package/dist/domain/mocks/create-mock-domain-runtime.d.ts +6 -0
- package/dist/editor/domain-editors/DomainSpecContext.js +1 -1
- package/dist/editor/domain-editors/apply-spec-update.js +1 -1
- package/dist/editor/domain-editors/use-implementation-files.d.ts +7 -3
- package/dist/editor/domain-editors/use-implementation-files.js +1 -1
- package/dist/phoenix/application-spec/generate-assistant-prompt.d.ts +2 -2
- package/dist/phoenix/application-spec/generate-assistant-prompt.js +1 -1
- package/dist/phoenix/commands/login.d.ts +24 -6
- package/dist/phoenix/commands/login.js +2 -2
- package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +12 -0
- package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +3 -0
- package/package.json +3 -3
- package/dist/configurator/assistant/browser-details.js +0 -1
- package/dist/configurator/assistant/graphql-tools.js +0 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ExtendedJsonSchema } from '@salsita-ai/common/utils';
|
|
2
|
+
import type { StateUpdate, UpdateFactory } from '../components/updates.js';
|
|
3
|
+
import type { DomainContextSystems } from '../domain-context/domain-context-systems.js';
|
|
4
|
+
import type { IdSequence } from '../domain-context/store-system/next-domain-entity-id.js';
|
|
5
|
+
import type { ExpressionContext } from './expression.js';
|
|
6
|
+
import type { $DomainEntity, DomainEntity } from './model.js';
|
|
7
|
+
import type { DomainState } from './state.js';
|
|
8
|
+
/**
|
|
9
|
+
* The parameter and result types of the actions an application declares under `actions`, keyed by
|
|
10
|
+
* action name. Codegen derives it from the spec; `ActionSystem.prepareAction` and the
|
|
11
|
+
* `implementActions` factory are typed against it.
|
|
12
|
+
*/
|
|
13
|
+
export type ActionTypes = Record<string, {
|
|
14
|
+
readonly params: unknown;
|
|
15
|
+
readonly result: unknown;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* One action as the spec declares it, carried into the domain factory by the generated code:
|
|
19
|
+
* `params` is the AJV-ready object schema of its parameters, which `prepareAction` validates the
|
|
20
|
+
* arguments against before the implementation runs, and `description` says what the action does.
|
|
21
|
+
*/
|
|
22
|
+
export interface ActionDefinition {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly description?: string;
|
|
25
|
+
readonly params: ExtendedJsonSchema;
|
|
26
|
+
}
|
|
27
|
+
/** The declared actions of an application by name; empty when the spec declares none. */
|
|
28
|
+
export type ActionDefinitions = Readonly<Record<string, ActionDefinition>>;
|
|
29
|
+
/** The working state an action ran against and the state its applied updates produced. */
|
|
30
|
+
export interface ActionStateChange<ENTITIES extends DomainEntity<string>> {
|
|
31
|
+
readonly previousState: DomainState<ENTITIES>;
|
|
32
|
+
readonly state: DomainState<ENTITIES>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* What one action prepares: the updates it wants applied, computed from the state it ran against,
|
|
36
|
+
* and how to read its result from the change they made, including whatever the transformers added.
|
|
37
|
+
* Nothing is staged or committed; the caller decides what to do with the updates.
|
|
38
|
+
*/
|
|
39
|
+
export interface PreparedAction<ENTITIES extends DomainEntity<string>, RESULT> {
|
|
40
|
+
readonly updates: ReadonlyArray<StateUpdate<ENTITIES, ENTITIES>>;
|
|
41
|
+
readonly readResult: (change: ActionStateChange<ENTITIES>) => RESULT;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* What an action implementation reads besides its parameters and the state: the expression context
|
|
45
|
+
* (domain, data, projections), the domain systems, an id sequence for entities it creates, and the
|
|
46
|
+
* update factory typed for the application's entities.
|
|
47
|
+
*/
|
|
48
|
+
export interface ActionContext<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string> {
|
|
49
|
+
readonly expressionContext: ExpressionContext<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
|
|
50
|
+
readonly systems: DomainContextSystems<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>;
|
|
51
|
+
readonly getIdSequence: () => IdSequence<ENTITIES>;
|
|
52
|
+
readonly updates: UpdateFactory<ENTITIES>;
|
|
53
|
+
}
|
|
54
|
+
export type AnyActionContext = ActionContext<any, any, any, any, any, any, any, any, any, any>;
|
|
55
|
+
/**
|
|
56
|
+
* The implementation of one declared action. It must not change anything itself; a thrown error
|
|
57
|
+
* fails the call, and its message reaches whoever asked for the action, so it says what went wrong
|
|
58
|
+
* and how to fix the request.
|
|
59
|
+
*/
|
|
60
|
+
export type ActionImplementation<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string, PARAMS, RESULT> = (params: PARAMS, state: DomainState<ENTITIES>, context: ActionContext<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>) => PreparedAction<ENTITIES, RESULT>;
|
|
61
|
+
export type AnyActionImplementation = ActionImplementation<any, any, any, any, any, any, any, any, any, any, any, unknown>;
|
|
62
|
+
/** The implementations of every declared action by name, as the generated barrel merges them from `src/actions/`. */
|
|
63
|
+
export type ActionImplementations<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string, ACTION_TYPES extends ActionTypes> = {
|
|
64
|
+
readonly [NAME in keyof ACTION_TYPES]: ActionImplementation<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, ACTION_TYPES[NAME]['params'], ACTION_TYPES[NAME]['result']>;
|
|
65
|
+
};
|
|
66
|
+
/** The action implementations of an application with their types erased, as the runtime spec slice holds them. */
|
|
67
|
+
export type AnyActionImplementations = Readonly<Record<string, AnyActionImplementation>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ExtendedJsonSchema } from '@salsita-ai/common/utils';
|
|
2
|
+
import type { ActionDefinitions, AnyActionImplementations } from './action.js';
|
|
2
3
|
import type { Expression } from './expression.js';
|
|
3
4
|
import type { MigrateFunction } from './migrations.js';
|
|
4
5
|
import type { $DomainEntity, DomainEntity, EntityByType } from './model.js';
|
|
@@ -25,6 +26,9 @@ export interface DomainFactoryContext<ENTITIES extends DomainEntity<string>, ALL
|
|
|
25
26
|
frontendData: SchemaOfObject<FRONTEND_DATA>;
|
|
26
27
|
backendData: ExtendedJsonSchema | undefined;
|
|
27
28
|
isAdminDomain: boolean;
|
|
29
|
+
/** The actions the spec declares, and their implementations from `src/actions/`; both empty for a domain without actions. */
|
|
30
|
+
actions: ActionDefinitions;
|
|
31
|
+
actionImplementations: AnyActionImplementations;
|
|
28
32
|
}
|
|
29
33
|
export type AnyDomainFactory = DomainFactory<any, any, any, any, any, any>;
|
|
30
34
|
export declare class DomainFactory<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, _$MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>> {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { EnhancedJsonObjectSchemaType, EnhancedJsonSchemaType, JsonSchemaType, MemberImport, } from './enhanced-json-schema.js';
|
|
2
|
+
export type { ActionContext, ActionDefinition, ActionDefinitions, ActionImplementation, ActionImplementations, ActionStateChange, ActionTypes, AnyActionContext, AnyActionImplementation, AnyActionImplementations, PreparedAction, } from './action.js';
|
|
2
3
|
export { extendedSchemaValidator, getExtendedSchemaValidator } from './json-schema.js';
|
|
3
4
|
export { _unsafeBuildDomainEntityId, domainEntityTypeFromId, createVirtualEntityId, isDomainEntityId, isVirtualEntityId, VirtualEntityIdSchema, isEqualEntityTypeAndId, parseDomainEntityId, DomainEntityIdSchema, DomainEntitySchema, $DomainEntitySchema, } from './model.js';
|
|
4
5
|
export type { $DomainEntity, DomainEntity, VirtualEntityId, DomainEntityId, EntityIdSchema, EntityByType, EntityId, } from './model.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ExtendedJsonSchema } from '@salsita-ai/common/utils';
|
|
2
|
+
import type { ActionDefinition, AnyActionImplementations } from './core/action.js';
|
|
2
3
|
import { type AliasMap, type ExpandAlias, type TypeOrAlias } from './core/alias.js';
|
|
3
4
|
import type { AnonymousExpression } from './core/expression.js';
|
|
4
5
|
import { DomainFactory } from './core/index.js';
|
|
@@ -24,10 +25,16 @@ export declare class DomainBuilder<ENTITIES extends DomainEntity<string>, ALLOWE
|
|
|
24
25
|
private readonly backendData;
|
|
25
26
|
private readonly migrate;
|
|
26
27
|
private readonly isAdminDomain;
|
|
28
|
+
private readonly actions;
|
|
29
|
+
private readonly actionImplementations;
|
|
27
30
|
private constructor();
|
|
28
31
|
static from<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, ALIASES extends Readonly<Record<string, ENTITIES>>>(entities: EntityReflections<ENTITIES>, aliasMap: AliasMap<ALIASES>, $entityReflections: $EntityReflections<ENTITIES>, allowedRootEntityTypes: ReadonlyArray<ALLOWED_ROOT_ENTITIES['type']>, modelVersion: number, publishedData: SchemaOfObject<PUBLISHED_DATA>, sessionData: SchemaOfObject<SESSION_DATA>, frontendData: SchemaOfObject<FRONTEND_DATA>, backendData: ExtendedJsonSchema | undefined, isAdminDomain: boolean): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
|
|
29
32
|
withMigrate(migration: MigrateFunction<ENTITIES>): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
|
|
30
33
|
withExpressions(implementation: AliasedExpressions<ENTITIES, ALLOWED_ROOT_ENTITIES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ALIASES>): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
|
|
34
|
+
/** Declares the actions of the domain, as the generated `domain-spec.ts` reads them from the spec's `actions` section. */
|
|
35
|
+
withActions(actions: readonly ActionDefinition[]): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
|
|
36
|
+
/** Adds the implementations of the declared actions, as the generated barrel merges them from `src/actions/`. */
|
|
37
|
+
withActionImplementations(implementations: AnyActionImplementations): DomainBuilder<ENTITIES, ALLOWED_ROOT_ENTITIES, ALIASES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
|
|
31
38
|
build: () => DomainFactory<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA>;
|
|
32
39
|
}
|
|
33
40
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{expandAlias as
|
|
1
|
+
import{expandAlias as t}from"./core/alias.js";import{DomainFactory as i}from"./core/index.js";import{MigrateFunctionBuilder as e}from"./core/migrations.js";import{withProfilerLabel as s}from"./utils/profiler-label.js";export class DomainBuilder{entities;aliasMap;$entityReflections;allowedRootEntityTypes;implemented;modelVersion;publishedData;sessionData;frontendData;backendData;migrate;isAdminDomain;actions;actionImplementations;constructor(t,i,e,s,a,n,o,h,l,m,r,d,p,c){this.entities=t,this.aliasMap=i,this.$entityReflections=e,this.allowedRootEntityTypes=s,this.implemented=a,this.modelVersion=n,this.publishedData=o,this.sessionData=h,this.frontendData=l,this.backendData=m,this.migrate=r,this.isAdminDomain=d,this.actions=p,this.actionImplementations=c}static from(t,i,s,a,n,o,h,l,m,r){let d=e.fromVersions({1:t}).to(1).using({}).build();return new DomainBuilder(t,i,s,a,{},n,o,h,l,m,d,r,{},{})}withMigrate(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,t,this.isAdminDomain,this.actions,this.actionImplementations)}withExpressions(i){let e={...this.implemented};return Object.entries(i).forEach(([i,a])=>{t(this.aliasMap,i).forEach(t=>{let n={...e[t]};e[t]=n,Object.entries(a).forEach(([e,a])=>{let o=n[e];if(o)throw Error(`Duplicate expression ${t}.${e}: The expression is defined on both ${i} and ${o.origin.typeOrAlias}, which would lead to ambiguous usage. Please ensure that expressions are only defined once.`);n[e]={...a,evaluate:s(`${t}_${e}`,a.evaluate),origin:{name:e,typeOrAlias:i}}})})}),new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,e,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,this.actions,this.actionImplementations)}withActions(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,Object.fromEntries(t.map(t=>[t.name,t])),this.actionImplementations)}withActionImplementations(t){return new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,this.implemented,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,this.actions,{...this.actionImplementations,...t})}build=()=>{let t=this.implemented,s=this.migrate??e.fromVersions({1:this.entities}).to(1).using({}).build();return new i({aliasMap:this.aliasMap,entityReflections:this.entities,$entityReflections:this.$entityReflections,expressions:t,allowedRootEntityTypes:this.allowedRootEntityTypes,modelVersion:this.modelVersion,migrate:s,publishedData:this.publishedData,sessionData:this.sessionData,frontendData:this.frontendData,backendData:this.backendData,isAdminDomain:this.isAdminDomain,actions:this.actions,actionImplementations:this.actionImplementations})}}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ActionContext, ActionTypes, PreparedAction } from '../../core/action.js';
|
|
2
|
+
import type { $DomainEntity, DomainEntity } from '../../core/model.js';
|
|
3
|
+
import type { DomainState } from '../../core/state.js';
|
|
4
|
+
import type { DomainContextSelectors } from '../../domain-runtime/domain-context/index.js';
|
|
5
|
+
export interface ActionSystemContext {
|
|
6
|
+
/**
|
|
7
|
+
* The action system's window into the runtime registry: the declared actions and their
|
|
8
|
+
* implementations are read per call, never snapshotted, so a hot-reloaded spec or action file is
|
|
9
|
+
* observed without rebuilding the system.
|
|
10
|
+
*/
|
|
11
|
+
readonly selectors: DomainContextSelectors;
|
|
12
|
+
}
|
|
13
|
+
/** ActionSystem with its types erased — how the runtime selectors expose the instance. */
|
|
14
|
+
export type AnyActionSystem = ActionSystem<any, any, any, any, any, any, any, any, any, any, any>;
|
|
15
|
+
/**
|
|
16
|
+
* Runs the actions an application declares under `actions` and implements in `src/actions/`. It
|
|
17
|
+
* only prepares: an action gets the state it is called on and returns the updates it wants applied
|
|
18
|
+
* with a reader for its result, and the caller stages, commits or dry-runs them. Every caller of an
|
|
19
|
+
* action goes through it, so all of them run the same domain logic.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ActionSystem<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, PUBLISHED_DATA extends Record<string, unknown>, SESSION_DATA extends Record<string, unknown>, FRONTEND_DATA extends Record<string, unknown>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string, ACTION_TYPES extends ActionTypes> {
|
|
22
|
+
private readonly _context;
|
|
23
|
+
/** One compiled validator per declared action, rebuilt only when the declarations change. */
|
|
24
|
+
private readonly _selectValidators;
|
|
25
|
+
private readonly _updates;
|
|
26
|
+
constructor(_context: ActionSystemContext);
|
|
27
|
+
/**
|
|
28
|
+
* The context an implementation runs with on `state`. Code that prepares updates outside an
|
|
29
|
+
* action can run on the same context, so it can do everything an action can, the same way.
|
|
30
|
+
*/
|
|
31
|
+
readonly createContext: (state: DomainState<ENTITIES>) => ActionContext<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES>;
|
|
32
|
+
/**
|
|
33
|
+
* Prepares the action `name` with `args` on `state`. The arguments are validated against the
|
|
34
|
+
* params schema the action declares, and the implementation is called with the validated
|
|
35
|
+
* parameters and the context of the state; nothing is staged or committed. Throws for an unknown
|
|
36
|
+
* action, arguments that do not fit the schema, or a declared action without an implementation.
|
|
37
|
+
* The result of `readResult` is not validated: the generated type is its contract.
|
|
38
|
+
*/
|
|
39
|
+
readonly prepareAction: <NAME extends keyof ACTION_TYPES & string>(name: NAME, args: unknown, state: DomainState<ENTITIES>) => PreparedAction<ENTITIES, ACTION_TYPES[NAME]['result']>;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createSelector as t}from"@salsita-ai/common/utils";import{createUpdateFactory as e}from"../../components/updates.js";import{extendedSchemaValidator as s}from"../../core/json-schema.js";import{getIdSequence as o}from"../store-system/next-domain-entity-id.js";export class ActionSystem{_context;_selectValidators=t([t.leaf(t=>t)],t=>new Map(Object.values(t).map(t=>[t.name,s.compile(t.params)])));_updates=e();constructor(t){this._context=t}createContext=t=>({expressionContext:this._context.selectors.getExpressionContext(),systems:this._context.selectors.getDomainSystems(),getIdSequence:()=>o(t.entities,[]),updates:this._updates});prepareAction=(t,e,o)=>{let n=this._context.selectors.getActionDefinitions(),i=Object.values(n).find(e=>e.name===t);if(!i){let e=Object.values(n).map(t=>`"${t.name}"`);throw Error(`Unknown action "${t}". ${e.length>0?`The application declares these actions: ${e.join(", ")}.`:"The application declares no actions."} Declare it under "actions" in a spec file and implement it in src/actions/.`)}let a=this._selectValidators(n).get(i.name);if(a&&!a(e))throw Error(`The arguments of action "${t}" do not fit its params: ${s.errorsText(a.errors)}. Nothing was changed. Send arguments that fit the params the action declares.`);return(Object.entries(this._context.selectors.getActionImplementations()).find(([e])=>e===t)?.[1])(e,o,this.createContext(o))}}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { ActionTypes } from '../core/action.js';
|
|
1
2
|
import type { Domain } from '../core/domain.js';
|
|
2
3
|
import type { $DomainEntity, DomainEntity } from '../core/model.js';
|
|
3
4
|
import type { ComponentReader, DomainContextSelectors } from '../domain-runtime/domain-context/index.js';
|
|
4
5
|
import type { BlenderProjections, CollisionProjections, CompositionProjections, ConstraintProjections, PositionProjections, ProjectedEntitiesProjections, SnappingProjections, ValidationProjections } from '../projections/index.js';
|
|
5
6
|
import type { SketchingProjections } from '../sketching/sketching-projections.js';
|
|
7
|
+
import type { ActionSystem } from './action-system/action-system.js';
|
|
6
8
|
import type { DimensionSystem } from './dimension-system/dimension-system.js';
|
|
7
9
|
import type { NavigationSystem } from './navigation-system/navigation-system.js';
|
|
8
10
|
import type { RecipeCookerSystem } from './recipe-system/recipe-cooker-system.js';
|
|
@@ -14,7 +16,7 @@ import type { UndoSystem } from './undo-system.js';
|
|
|
14
16
|
* The `DomainContext` lifecycle orchestrates these systems but does not expose them.
|
|
15
17
|
* Consumers read this record through `DomainContextSelectors.getDomainSystems()`.
|
|
16
18
|
*/
|
|
17
|
-
export interface DomainContextSystems<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string> {
|
|
19
|
+
export interface DomainContextSystems<ENTITIES extends DomainEntity<string>, ALLOWED_ROOT_ENTITIES extends ENTITIES, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>>, NAVIGATION_STATES extends string, VIEW_STATES extends string, TOOL_STATES extends string, EXPORT_STATES extends string, ACTION_TYPES extends ActionTypes = ActionTypes> {
|
|
18
20
|
/**
|
|
19
21
|
* The system graph's window into the runtime registry. Consumers outside the domain systems use
|
|
20
22
|
* it to read spec-derived values live rather than through construction-time snapshots.
|
|
@@ -30,6 +32,7 @@ export interface DomainContextSystems<ENTITIES extends DomainEntity<string>, ALL
|
|
|
30
32
|
readonly dimensionSystem: DimensionSystem<ENTITIES>;
|
|
31
33
|
readonly undoSystem: UndoSystem<ENTITIES, $MAP>;
|
|
32
34
|
readonly recipeCooker: RecipeCookerSystem<ENTITIES>;
|
|
35
|
+
readonly actionSystem: ActionSystem<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, Record<string, unknown>, Record<string, unknown>, Record<string, unknown>, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, ACTION_TYPES>;
|
|
33
36
|
readonly sketchingProjections: SketchingProjections<ENTITIES>;
|
|
34
37
|
readonly collisionProjections: CollisionProjections<ENTITIES>;
|
|
35
38
|
readonly positionProjections: PositionProjections<ENTITIES>;
|
|
@@ -37,4 +40,4 @@ export interface DomainContextSystems<ENTITIES extends DomainEntity<string>, ALL
|
|
|
37
40
|
readonly projectedEntitiesProjections: ProjectedEntitiesProjections<ENTITIES>;
|
|
38
41
|
readonly constraintProjections: ConstraintProjections<ENTITIES>;
|
|
39
42
|
}
|
|
40
|
-
export type AnyDomainContextSystems = DomainContextSystems<any, any, any, any, any, any, any>;
|
|
43
|
+
export type AnyDomainContextSystems = DomainContextSystems<any, any, any, any, any, any, any, any>;
|
|
@@ -13,6 +13,7 @@ export { createCascadeRefPruningTransformer } from './relation-transformers/casc
|
|
|
13
13
|
export { createCreateEntityRefsTransformer } from './relation-transformers/create-entity-refs.js';
|
|
14
14
|
export { type CanBeUndonePredicate, type CanBeUndoneContext, type UndoCapabilities, UndoSystem, UNDO_REDO_RESET_TAG, isUndoRedoReset, } from './undo-system.js';
|
|
15
15
|
export { DimensionSystem, type AnyDimensionSystem, type DimensionSystemContext, type AngleDimensionViolation, type DistanceDimensionViolation, type GenericDimensionViolation, } from './dimension-system/dimension-system.js';
|
|
16
|
+
export { ActionSystem, type AnyActionSystem, type ActionSystemContext } from './action-system/action-system.js';
|
|
16
17
|
export { RecipeFactoryBuilder, type EntityRecipe } from './recipe-system/recipes.js';
|
|
17
18
|
export { RecipeCookerSystem, type AnyRecipeCookerSystem, type RecipeCookerSystemContext, ReplaceRecipeUpdateTag, isReplaceEntityUpdate, type IsReplaceRecipeUpdate, CreateRecipeUpdateTag, isCreateEntityUpdate, type IsCreateRecipeUpdate, } from './recipe-system/recipe-cooker-system.js';
|
|
18
19
|
export { type DomainContextSystems, type AnyDomainContextSystems } from './domain-context-systems.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{NoopAnalyticsSystem}from"./analytics-system/analytics-system.js";export{AnalyticsEventFactory,AnalyticsEventType}from"./analytics-system/analytics-contracts.js";export{NavigationUpdateTag,isInitialNavigationUpdate,isNavigationUpdate,isInitialViewUpdate,isViewUpdate,isInitialSelectionUpdate,isSelectUpdate,isDeselectUpdate,isInitialFullscreenUpdate,isToggleFullscreenUpdate,isInitialDebugUpdate,isInitialViewportUpdate,isSetViewportUpdate,isInitialDragUpdate,isDragStartUpdate,isDragEndUpdate,isInitialToolUpdate,isToolUpdate,isExportUpdate}from"./navigation-system/navigation-updates.js";export{createAutoSelectionTransformer,NavigationSystem}from"./navigation-system/navigation-system.js";export{createResetSelectionOnNavigationTransformer,createNavigationOnSelectionTransformer,createNavigationOnDeselectTransformer,createSelectParentOnDeselectionTransformer,createNavigationOnSelectionChangeTransformer}from"./navigation-system/selection-transformers.js";export{StoreSystem}from"./store-system/store-system.js";export{nextDomainEntityId,getIdSequence}from"./store-system/next-domain-entity-id.js";export{applyUpdates}from"./store-system/apply-updates.js";export{SystemState,SystemStateInitialUpdateTag,SystemStateUpdateTag}from"./store-system/system-state.js";export{createRefReplaceTransformer}from"./relation-transformers/replace-refs.js";export{createCascadeDeletesTransformer}from"./relation-transformers/cascade-deletes.js";export{createCascadeRefPruningTransformer}from"./relation-transformers/cascade-ref-pruning.js";export{createCreateEntityRefsTransformer}from"./relation-transformers/create-entity-refs.js";export{UndoSystem,UNDO_REDO_RESET_TAG,isUndoRedoReset}from"./undo-system.js";export{DimensionSystem}from"./dimension-system/dimension-system.js";export{RecipeFactoryBuilder}from"./recipe-system/recipes.js";export{RecipeCookerSystem,ReplaceRecipeUpdateTag,isReplaceEntityUpdate,CreateRecipeUpdateTag,isCreateEntityUpdate}from"./recipe-system/recipe-cooker-system.js";export{createTransformer}from"./create-transformer.js";export*from"./transformers/index.js";
|
|
1
|
+
export{NoopAnalyticsSystem}from"./analytics-system/analytics-system.js";export{AnalyticsEventFactory,AnalyticsEventType}from"./analytics-system/analytics-contracts.js";export{NavigationUpdateTag,isInitialNavigationUpdate,isNavigationUpdate,isInitialViewUpdate,isViewUpdate,isInitialSelectionUpdate,isSelectUpdate,isDeselectUpdate,isInitialFullscreenUpdate,isToggleFullscreenUpdate,isInitialDebugUpdate,isInitialViewportUpdate,isSetViewportUpdate,isInitialDragUpdate,isDragStartUpdate,isDragEndUpdate,isInitialToolUpdate,isToolUpdate,isExportUpdate}from"./navigation-system/navigation-updates.js";export{createAutoSelectionTransformer,NavigationSystem}from"./navigation-system/navigation-system.js";export{createResetSelectionOnNavigationTransformer,createNavigationOnSelectionTransformer,createNavigationOnDeselectTransformer,createSelectParentOnDeselectionTransformer,createNavigationOnSelectionChangeTransformer}from"./navigation-system/selection-transformers.js";export{StoreSystem}from"./store-system/store-system.js";export{nextDomainEntityId,getIdSequence}from"./store-system/next-domain-entity-id.js";export{applyUpdates}from"./store-system/apply-updates.js";export{SystemState,SystemStateInitialUpdateTag,SystemStateUpdateTag}from"./store-system/system-state.js";export{createRefReplaceTransformer}from"./relation-transformers/replace-refs.js";export{createCascadeDeletesTransformer}from"./relation-transformers/cascade-deletes.js";export{createCascadeRefPruningTransformer}from"./relation-transformers/cascade-ref-pruning.js";export{createCreateEntityRefsTransformer}from"./relation-transformers/create-entity-refs.js";export{UndoSystem,UNDO_REDO_RESET_TAG,isUndoRedoReset}from"./undo-system.js";export{DimensionSystem}from"./dimension-system/dimension-system.js";export{ActionSystem}from"./action-system/action-system.js";export{RecipeFactoryBuilder}from"./recipe-system/recipes.js";export{RecipeCookerSystem,ReplaceRecipeUpdateTag,isReplaceEntityUpdate,CreateRecipeUpdateTag,isCreateEntityUpdate}from"./recipe-system/recipe-cooker-system.js";export{createTransformer}from"./create-transformer.js";export*from"./transformers/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createCascadeDeletesTransformer as e}from"../../domain-context/relation-transformers/cascade-deletes.js";import{createCascadeRefPruningTransformer as t}from"../../domain-context/relation-transformers/cascade-ref-pruning.js";import{createCreateEntityRefsTransformer as s}from"../../domain-context/relation-transformers/create-entity-refs.js";import{createRefReplaceTransformer as r}from"../../domain-context/relation-transformers/replace-refs.js";import{createAutoSnapTransformer as n}from"../../domain-context/transformers/auto-snap-transformer.js";export class DomainContext{_context;_connected=!1;_activeCreateTransformers=void 0;_userTransformerUnregisters=[];_lastExpressionContext=null;_lastDomainExpressions=null;_lastComponentReaderIndexes=null;_lastLoadedData=null;constructor(e){this._context=e}initialize(){let{selectors:o,actions:a,getExtensionSystems:i}=this._context;this._assertSchemaCoherence();let m=o.getStoreSystem();try{for(let i of(a.setInitializationContext(o.getNextInitializationContext()),this._connected||(m.registerTransformer(10,e(o.getCompositionProjections()),"CascadeDeletes"),m.registerTransformer(20,t(o.getComponentReader()),"CascadeRefPruning"),m.registerTransformer(25,s(o.getComponentReader()),"CreateEntityRefs"),m.registerTransformer(30,r(o.getComponentReader()),"RefReplace"),m.registerTransformer(40,n(o.getComponentReader(),o.getSnappingProjections(),o.getDimensionSystem(),o.getPositionProjections(),m),"AutoSnap"),this._connected=!0),this._reconcileUserTransformers(),[m,o.getUndoSystem()]))i.initialize();for(let e of(m.stageAndCommit(o.getDimensionSystem().initialize(m.stateSlices.committed.value.state)),[o.getNavigationSystem(),...i()]))e.initialize();this._lastExpressionContext=o.getExpressionContext(),this._lastDomainExpressions=o.getDomainExpressions(),this._lastComponentReaderIndexes=o.getComponentReaderIndexes(),this._lastLoadedData=o.getLoadedData(),a.completeInitialization()}catch(e){throw a.failInitialization(),e}}reconcile=()=>{this._context.selectors.getInitializationState().isCurrent&&(this._reconcileUserTransformers(),this._refreshIfLoadedDataChanged(),this._refreshIfExpressionContextChanged())};_assertSchemaCoherence(){switch(this._context.selectors.getSchemaCoherence()){case"coherent":return;case"missing-stamp":throw Error("Cannot initialize the domain context: the loaded data carries no schema identity.");case"schema-mismatch":throw Error("Cannot initialize the domain context: the loaded data belongs to a different schema identity than the active spec.")}}_registerUserTransformers(e){let t=this._context.selectors.getStoreSystem();for(let s of e)this._userTransformerUnregisters.push(t.registerTransformer(s.priority,s.transformer,s.name??"Anonymous"))}_unregisterUserTransformers(){for(let e of this._userTransformerUnregisters)e();this._userTransformerUnregisters=[]}_reconcileUserTransformers(){let e=this._context.selectors.getCreateTransformers();if(this._activeCreateTransformers===e)return;let t=e?.(this._context.selectors.getDomainSystems())??[];this._unregisterUserTransformers(),this._activeCreateTransformers=e,this._registerUserTransformers(t)}_refreshIfExpressionContextChanged(){let{selectors:e}=this._context,t=e.getExpressionContext(),s=e.getDomainExpressions(),r=e.getComponentReaderIndexes();if(this._lastExpressionContext===t&&this._lastDomainExpressions===s&&this._lastComponentReaderIndexes===r)return;let n=e.getStoreSystem();n.reset(n.stateSlices.committed.value.state,"expressionContextRefreshed"),this._lastExpressionContext=t,this._lastDomainExpressions=s,this._lastComponentReaderIndexes=r}_refreshIfLoadedDataChanged(){let{selectors:e}=this._context,t=e.getLatestLoadedData();null!==t&&this._lastLoadedData!==t&&(e.getStoreSystem().reset(e.getInitialDomainState(),"loadedDataRefreshed"),this._lastLoadedData=t)}}
|
|
1
|
+
import{createCascadeDeletesTransformer as e}from"../../domain-context/relation-transformers/cascade-deletes.js";import{createCascadeRefPruningTransformer as t}from"../../domain-context/relation-transformers/cascade-ref-pruning.js";import{createCreateEntityRefsTransformer as s}from"../../domain-context/relation-transformers/create-entity-refs.js";import{createRefReplaceTransformer as r}from"../../domain-context/relation-transformers/replace-refs.js";import{createAutoSnapTransformer as n}from"../../domain-context/transformers/auto-snap-transformer.js";export class DomainContext{_context;_connected=!1;_activeCreateTransformers=void 0;_userTransformerUnregisters=[];_lastExpressionContext=null;_lastDomainExpressions=null;_lastComponentReaderIndexes=null;_lastLoadedData=null;constructor(e){this._context=e}initialize(){let{selectors:o,actions:a,getExtensionSystems:i}=this._context;this._assertSchemaCoherence();let m=o.getStoreSystem();try{for(let i of(a.setInitializationContext(o.getNextInitializationContext()),this._connected||(m.registerTransformer(10,e(o.getCompositionProjections()),"CascadeDeletes"),m.registerTransformer(20,t(o.getComponentReader()),"CascadeRefPruning"),m.registerTransformer(25,s(o.getComponentReader()),"CreateEntityRefs"),m.registerTransformer(30,r(o.getComponentReader()),"RefReplace"),m.registerTransformer(40,n(o.getComponentReader(),o.getSnappingProjections(),o.getDimensionSystem(),o.getPositionProjections(),m),"AutoSnap"),this._connected=!0),this._reconcileUserTransformers(),[m,o.getUndoSystem()]))i.initialize();for(let e of(m.stageAndCommit(o.getDimensionSystem().initialize(m.stateSlices.committed.value.state)),[o.getNavigationSystem(),...i()]))e.initialize();o.getActionImplementations(),this._lastExpressionContext=o.getExpressionContext(),this._lastDomainExpressions=o.getDomainExpressions(),this._lastComponentReaderIndexes=o.getComponentReaderIndexes(),this._lastLoadedData=o.getLoadedData(),a.completeInitialization()}catch(e){throw a.failInitialization(),e}}reconcile=()=>{this._context.selectors.getInitializationState().isCurrent&&(this._reconcileUserTransformers(),this._refreshIfLoadedDataChanged(),this._refreshIfExpressionContextChanged())};_assertSchemaCoherence(){switch(this._context.selectors.getSchemaCoherence()){case"coherent":return;case"missing-stamp":throw Error("Cannot initialize the domain context: the loaded data carries no schema identity.");case"schema-mismatch":throw Error("Cannot initialize the domain context: the loaded data belongs to a different schema identity than the active spec.")}}_registerUserTransformers(e){let t=this._context.selectors.getStoreSystem();for(let s of e)this._userTransformerUnregisters.push(t.registerTransformer(s.priority,s.transformer,s.name??"Anonymous"))}_unregisterUserTransformers(){for(let e of this._userTransformerUnregisters)e();this._userTransformerUnregisters=[]}_reconcileUserTransformers(){let e=this._context.selectors.getCreateTransformers();if(this._activeCreateTransformers===e)return;let t=e?.(this._context.selectors.getDomainSystems())??[];this._unregisterUserTransformers(),this._activeCreateTransformers=e,this._registerUserTransformers(t)}_refreshIfExpressionContextChanged(){let{selectors:e}=this._context,t=e.getExpressionContext(),s=e.getDomainExpressions(),r=e.getComponentReaderIndexes();if(this._lastExpressionContext===t&&this._lastDomainExpressions===s&&this._lastComponentReaderIndexes===r)return;let n=e.getStoreSystem();n.reset(n.stateSlices.committed.value.state,"expressionContextRefreshed"),this._lastExpressionContext=t,this._lastDomainExpressions=s,this._lastComponentReaderIndexes=r}_refreshIfLoadedDataChanged(){let{selectors:e}=this._context,t=e.getLatestLoadedData();null!==t&&this._lastLoadedData!==t&&(e.getStoreSystem().reset(e.getInitialDomainState(),"loadedDataRefreshed"),this._lastLoadedData=t)}}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DomainComponentOptic } from '../../components/index.js';
|
|
2
2
|
import { type AnyDomain } from '../../core/domain.js';
|
|
3
3
|
import type { AnyDomainFactory, AnyExpressionContext, DomainEntity, DomainMode, SystemComponentTypeConstraint } from '../../core/index.js';
|
|
4
|
+
import { type AnyActionSystem } from '../../domain-context/action-system/action-system.js';
|
|
4
5
|
import { type AnyDimensionSystem } from '../../domain-context/dimension-system/dimension-system.js';
|
|
5
6
|
import type { AnyDomainContextSystems } from '../../domain-context/domain-context-systems.js';
|
|
6
7
|
import { type AnyNavigationSystem } from '../../domain-context/navigation-system/navigation-system.js';
|
|
@@ -120,6 +121,8 @@ export declare const createDomainContextSelectors: (context: Context) => {
|
|
|
120
121
|
getActiveConfigurationId: () => string;
|
|
121
122
|
getFactory: () => AnyDomainFactory;
|
|
122
123
|
getDomainExpressions: () => import("../../index.js").AnyExpressions;
|
|
124
|
+
getActionDefinitions: () => Readonly<Record<string, import("../../index.js").ActionDefinition>>;
|
|
125
|
+
getActionImplementations: () => Readonly<Record<string, import("../../index.js").AnyActionImplementation>>;
|
|
123
126
|
getModelVersion: () => number;
|
|
124
127
|
getAliasMap: () => import("../../index.js").AnyAliasMap;
|
|
125
128
|
getAllowedRootEntityTypes: () => import("../../index.js").AnyAllowedRootEntityTypes;
|
|
@@ -160,6 +163,7 @@ export declare const createDomainContextSelectors: (context: Context) => {
|
|
|
160
163
|
getNavigationSystem: () => AnyNavigationSystem;
|
|
161
164
|
getUndoSystem: () => AnyUndoSystem;
|
|
162
165
|
getRecipeCookerSystem: () => AnyRecipeCookerSystem;
|
|
166
|
+
getActionSystem: () => AnyActionSystem;
|
|
163
167
|
getBlenderProjections: () => AnyBlenderProjections;
|
|
164
168
|
getExpressionContext: () => AnyExpressionContext;
|
|
165
169
|
getDomainSystems: () => AnyDomainContextSystems;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSelector as e}from"@salsita-ai/common/utils";import{Domain as t}from"../../core/domain.js";import{createInitialDomainState as n}from"../../core/state.js";import{DimensionSystem as o}from"../../domain-context/dimension-system/dimension-system.js";import{NavigationSystem as i}from"../../domain-context/navigation-system/navigation-system.js";import{RecipeCookerSystem as a}from"../../domain-context/recipe-system/recipe-cooker-system.js";import{StoreSystem as s}from"../../domain-context/store-system/store-system.js";import{UndoSystem as r}from"../../domain-context/undo-system.js";import{prepareDomainExpressions as c}from"../../expressions/index.js";import{BlenderProjections as l,CollisionProjections as m,CompositionProjections as d,ConstraintProjections as g,PositionProjections as f,ProjectedEntitiesProjections as p,SnappingProjections as u,ValidationProjections as y}from"../../projections/index.js";import{SketchingProjections as w}from"../../sketching/sketching-projections.js";import{requireAccessService as h}from"../access/index.js";import{ComponentReader as S}from"./component-reader.js";import{DomainContext as x}from"./domain-context.js";let j=e.withTypes(),C=[],D={},v={role:"admin",data:D},I=e=>{if(null!==e)return e;throw Error("Cannot read the session role and data because the domain session context is not set. The session context is written into the domain runtime by the session lifecycle after authentication. Move this read into the loaded session lifecycle.")};export const createDomainContextSelectors=e=>{let{applicationType:P,getState:M,actions:R,specSelectors:E,accessSelectors:T,webComponentSelectors:b,domainDataSelectors:A,sessionContextSelectors:k,domainServicesSelectors:$,environmentSelectors:N,getExtensionSystems:z}=e,L="configurator"===P?E.selectConfiguratorSpec:E.selectAdminSpec,V="configurator"===P?T.selectConfiguratorRawAccessService:T.selectAdminRawAccessService,B=j.leaf(e=>e.domainContext[P]),F=j([B],e=>e.initializationContext),W=j([F],e=>{if(null===e)throw Error(`Domain lifecycle context is not available for ${P}! Read it from an active domain lifecycle.`);return e}),_=j([B],e=>e.executionMode),q=j([B],e=>e.isInitialized),O=j([L],e=>e.factory),U=j([L],e=>e.expressions),G=j([L],e=>e.$entityReflections),H=j([U,G],(e,t)=>c({expressions:e,$entityReflections:t})),J=j([L],e=>e.modelVersion),K=j([L],e=>e.aliasMap),Q=j([L],e=>e.allowedRootEntityTypes),X=j([L],e=>e.entityReflections),Y=j([L],e=>e.migrate),Z=j([_,b.selectReadonly,V],(e,t,n)=>"finalize"===e?"finalize":h(P,n).accessInfo.viewMode||t?"read":"owner"),ee=j([V],e=>e?.configurationId??null),et="configurator"===P?k.selectSessionContext:j([],()=>v),en=j([et],e=>e?.role??null),eo=j([et],e=>e?.data??null),ei=j([j.leaf(e=>e.loadedData)],e=>"configurator"===P?e.configuratorLoadedData:e.adminLoadedData),ea=j([ei],e=>e?.schemaIdentity??null),es=j([ei,O],(e,t)=>{if(null===e)return"coherent";let n=e.schemaIdentity;return void 0===n?"missing-stamp":n===t?"coherent":"schema-mismatch"}),er=j([ee,en,eo,ea,es],(e,t,n,o,i)=>null===e||null===t||null===n||null===o||"coherent"!==i?null:{configurationId:e,role:t,schemaIdentity:o,sessionData:n}),ec=j([V,b.selectReadonly],(e,t)=>e?.accessInfo.viewMode===!0||t),el=j([er,F,q,ec],(e,t,n,o)=>{let i=null!==e&&null!==t&&n&&t.configurationId===e.configurationId&&t.role===e.role&&t.schemaIdentity===e.schemaIdentity&&t.sessionData===e.sessionData;return{identity:e,isCurrent:i,isViewMode:o}}),em=j([L],e=>e.componentOptics),ed=j([em],e=>(e=>{let t=new Map,n=new Map,o=new Map,i=new Map;for(let n of e)for(let e of n.entityTypes){let o=t.get(e);o||(o=new Map,t.set(e,o));let a=o.get(n.componentType);if(a||(a=new Map,o.set(n.componentType,a)),a.has(n.instanceName))throw Error(`Component instance ${n.instanceName} already exists for type ${n.componentType.name} in entity ${e}. This is likely a bug in the component definition! InstanceNames must be unique within an entity and component.`);if(a.set(n.instanceName,n),"dynamic"===n.kind){let t=i.get(e);t||(t=new Map,i.set(e,t));let o=t.get(n.componentType)??[],a=o.find(e=>{var t;return t=n.instanceName,e.startsWith(`${t}_`)||t.startsWith(`${e}_`)});if(a)throw Error(`Cannot register dynamic component instance ${n.instanceName} for component ${n.componentType.name} on entity ${e} because it overlaps with dynamic instance ${a}. Rename one dynamic instance so compound names cannot be ambiguous.`);t.set(n.componentType,[...o,n.instanceName])}}for(let[e,i]of t.entries()){n.set(e,new Set(i.keys()));let t=new Map;for(let[n,a]of(o.set(e,t),i.entries()))t.set(n,new Set(a.keys()))}return{opticMap:t,allComponentTypes:n,allComponentInstanceNames:o,dynamicInstanceNames:i}})(e)),eg=j([ed,H,Q],(e,t,n)=>({componentReaderIndexes:e,domainExpressions:t,allowedRootEntityTypes:n})),ef=j([L],e=>e.navigationStates),ep=j([L],e=>e.viewStates),eu="configurator"===P?j([E.selectConfiguratorSpec],e=>e.toolStates):j([],()=>C),ey="configurator"===P?j([E.selectConfiguratorSpec],e=>e.exportStates):j([],()=>C),ew="configurator"===P?j([E.selectConfiguratorSpec],e=>e.createTransformers):j([],()=>void 0),eh=j([ei],e=>{if(null===e)throw Error(`Loaded data is not available for ${P}! Loaded data is written after the configuration fetch succeeds and before the domain context initialization starts.`);return e}),eS=j([eh,O],(e,t)=>n(t.validateAndMigrateState(e.initialEntities,e.modelVersion),e.rootEntityType)),ex="configurator"===P?A.selectConfiguratorFrontendData:A.selectAdminFrontendData,ej="configurator"===P?A.selectConfiguratorBackendData:A.selectAdminBackendData,eC="configurator"===P?A.selectConfiguratorPublishedData:A.selectAdminPublishedData,eD="configurator"===P?j([k.selectSessionContext],e=>I(e).role):j([],()=>"admin"),ev="configurator"===P?j([k.selectSessionContext],e=>I(e).data):j([],()=>D),eI=j([ee,Z,eD,ev,eh],(e,t,n,o,i)=>({configurationId:e,mode:t,role:n,schemaIdentity:i.schemaIdentity,sessionData:o})),eP=j([W],e=>e.mode),eM=j([W],e=>{let t=e.configurationId;if(null===t)throw Error(`Configuration id is not available for ${P}! Read it from an active interactive domain lifecycle.`);return t}),eR=j([W],e=>e.role),eE=j([W],e=>e.sessionData),eT=j([eP,eR,eE,ex,ej,eC,Y],(e,t,n,o,i,a,s)=>({mode:e,role:t,sessionData:n,frontendData:o,backendData:i,publishedData:a,migrate:s,domain:eA,componentReader:ek,positionProjections:eV,sketchingProjections:eL,collisionProjections:eB,constraintProjections:eW,snappingProjections:eF,projectedEntitiesProjections:e_})),eb={selectApplicationSpec:L,selectRawAccessService:V,selectDomainContextState:B,selectInitializationContext:F,selectActiveInitializationContext:W,selectExecutionMode:_,selectIsInitialized:q,selectFactory:O,selectSpecExpressions:U,select$SpecEntityReflections:G,selectDomainExpressions:H,selectModelVersion:J,selectAliasMap:K,selectAllowedRootEntityTypes:Q,selectEntityReflections:X,selectMigrate:Y,selectLatestMode:Z,selectLatestConfigurationId:ee,selectLatestSessionContext:et,selectLatestRoleOrNull:en,selectLatestSessionDataOrNull:eo,selectLatestSchemaIdentity:ea,selectSchemaCoherence:es,selectInitializationIdentity:er,selectIsViewMode:ec,selectInitializationState:el,selectComponentOptics:em,selectComponentReaderIndexes:ed,selectStoreRuntimeDependencies:eg,selectNavigationStates:ef,selectViewStates:ep,selectToolStates:eu,selectExportStates:ey,selectCreateTransformers:ew,selectLatestLoadedData:ei,selectLoadedData:eh,selectInitialDomainState:eS,selectFrontendData:ex,selectBackendData:ej,selectPublishedData:eC,selectLatestRole:eD,selectLatestSessionData:ev,selectNextInitializationContext:eI,selectActiveMode:eP,selectActiveConfigurationId:eM,selectActiveRole:eR,selectActiveSessionData:eE,selectExpressionContext:eT,getInitializationContext:()=>F(M()),getInitializationState:()=>el(M()),getNextInitializationContext:()=>eI(M()),getLatestLoadedData:()=>ei(M()),getSchemaCoherence:()=>es(M()),getActiveConfigurationId:()=>eM(M()),getFactory:()=>O(M()),getDomainExpressions:()=>H(M()),getModelVersion:()=>J(M()),getAliasMap:()=>K(M()),getAllowedRootEntityTypes:()=>Q(M()),getEntityReflections:()=>X(M()),getMigrate:()=>Y(M()),getActiveMode:()=>eP(M()),getIsInitialized:()=>q(M()),getComponentReaderIndexes:()=>ed(M()),getStoreRuntimeDependencies:()=>eg(M()),getNavigationStates:()=>ef(M()),getViewStates:()=>ep(M()),getToolStates:()=>eu(M()),getExportStates:()=>ey(M()),getCreateTransformers:()=>ew(M()),getLoadedData:()=>eh(M()),getInitialDomainState:()=>eS(M()),getFrontendData:()=>ex(M()),getBackendData:()=>ej(M()),getPublishedData:()=>eC(M()),getActiveRole:()=>eR(M()),getActiveSessionData:()=>eE(M()),getDomain:()=>eA,getComponentReader:()=>ek,getCompositionProjections:()=>e$,getDimensionSystem:()=>eN,getValidationProjections:()=>ez,getSketchingProjections:()=>eL,getPositionProjections:()=>eV,getCollisionProjections:()=>eB,getSnappingProjections:()=>eF,getConstraintProjections:()=>eW,getProjectedEntitiesProjections:()=>e_,getStoreSystem:()=>eq,getNavigationSystem:()=>eO,getUndoSystem:()=>eU,getRecipeCookerSystem:()=>eG,getBlenderProjections:()=>eH,getExpressionContext:()=>eT(M()),getDomainSystems:function(){return eJ},getDomainContext:function(){return eK}},eA=new t({selectors:eb}),ek=new S({selectors:eb}),e$=new d({selectors:eb}),eN=new o({selectors:eb}),ez=new y({selectors:eb}),eL=new w({selectors:eb}),eV=new f({selectors:eb}),eB=new m({selectors:eb}),eF=new u({selectors:eb}),eW=new g({selectors:eb}),e_=new p({selectors:eb}),eq=new s({selectors:eb,domainServicesSelectors:$,environmentSelectors:N}),eO=new i({selectors:eb,domainServicesSelectors:$}),eU=new r({selectors:eb}),eG=new a({selectors:eb}),eH=new l({selectors:eb,domainServicesSelectors:$}),eJ={domainContextSelectors:eb,domain:eA,componentReader:ek,compositionProjections:e$,blenderProjections:eH,validationProjections:ez,storeSystem:eq,navigationSystem:eO,dimensionSystem:eN,undoSystem:eU,recipeCooker:eG,sketchingProjections:eL,collisionProjections:eB,positionProjections:eV,snappingProjections:eF,projectedEntitiesProjections:e_,constraintProjections:eW},eK=new x({selectors:eb,actions:R,getExtensionSystems:z});return eb};
|
|
1
|
+
import{createSelector as e}from"@salsita-ai/common/utils";import{prepareActionImplementations as t}from"../../actions/prepare-action-implementations.js";import{Domain as n}from"../../core/domain.js";import{createInitialDomainState as o}from"../../core/state.js";import{ActionSystem as i}from"../../domain-context/action-system/action-system.js";import{DimensionSystem as a}from"../../domain-context/dimension-system/dimension-system.js";import{NavigationSystem as s}from"../../domain-context/navigation-system/navigation-system.js";import{RecipeCookerSystem as r}from"../../domain-context/recipe-system/recipe-cooker-system.js";import{StoreSystem as c}from"../../domain-context/store-system/store-system.js";import{UndoSystem as m}from"../../domain-context/undo-system.js";import{prepareDomainExpressions as l}from"../../expressions/index.js";import{BlenderProjections as d,CollisionProjections as g,CompositionProjections as f,ConstraintProjections as p,PositionProjections as u,ProjectedEntitiesProjections as y,SnappingProjections as w,ValidationProjections as h}from"../../projections/index.js";import{SketchingProjections as S}from"../../sketching/sketching-projections.js";import{requireAccessService as x}from"../access/index.js";import{ComponentReader as j}from"./component-reader.js";import{DomainContext as C}from"./domain-context.js";let D=e.withTypes(),v=[],I={},P={role:"admin",data:I},M=e=>{if(null!==e)return e;throw Error("Cannot read the session role and data because the domain session context is not set. The session context is written into the domain runtime by the session lifecycle after authentication. Move this read into the loaded session lifecycle.")};export const createDomainContextSelectors=e=>{let{applicationType:A,getState:R,actions:E,specSelectors:T,accessSelectors:b,webComponentSelectors:k,domainDataSelectors:$,sessionContextSelectors:N,domainServicesSelectors:z,environmentSelectors:L,getExtensionSystems:V}=e,B="configurator"===A?T.selectConfiguratorSpec:T.selectAdminSpec,F="configurator"===A?b.selectConfiguratorRawAccessService:b.selectAdminRawAccessService,W=D.leaf(e=>e.domainContext[A]),_=D([W],e=>e.initializationContext),q=D([_],e=>{if(null===e)throw Error(`Domain lifecycle context is not available for ${A}! Read it from an active domain lifecycle.`);return e}),O=D([W],e=>e.executionMode),U=D([W],e=>e.isInitialized),G=D([B],e=>e.factory),H=D([B],e=>e.expressions),J=D([B],e=>e.actions),K=D([B],e=>e.actionImplementations),Q=D([J,K],t),X=D([B],e=>e.$entityReflections),Y=D([H,X],(e,t)=>l({expressions:e,$entityReflections:t})),Z=D([B],e=>e.modelVersion),ee=D([B],e=>e.aliasMap),et=D([B],e=>e.allowedRootEntityTypes),en=D([B],e=>e.entityReflections),eo=D([B],e=>e.migrate),ei=D([O,k.selectReadonly,F],(e,t,n)=>"finalize"===e?"finalize":x(A,n).accessInfo.viewMode||t?"read":"owner"),ea=D([F],e=>e?.configurationId??null),es="configurator"===A?N.selectSessionContext:D([],()=>P),er=D([es],e=>e?.role??null),ec=D([es],e=>e?.data??null),em=D([D.leaf(e=>e.loadedData)],e=>"configurator"===A?e.configuratorLoadedData:e.adminLoadedData),el=D([em],e=>e?.schemaIdentity??null),ed=D([em,G],(e,t)=>{if(null===e)return"coherent";let n=e.schemaIdentity;return void 0===n?"missing-stamp":n===t?"coherent":"schema-mismatch"}),eg=D([ea,er,ec,el,ed],(e,t,n,o,i)=>null===e||null===t||null===n||null===o||"coherent"!==i?null:{configurationId:e,role:t,schemaIdentity:o,sessionData:n}),ef=D([F,k.selectReadonly],(e,t)=>e?.accessInfo.viewMode===!0||t),ep=D([eg,_,U,ef],(e,t,n,o)=>{let i=null!==e&&null!==t&&n&&t.configurationId===e.configurationId&&t.role===e.role&&t.schemaIdentity===e.schemaIdentity&&t.sessionData===e.sessionData;return{identity:e,isCurrent:i,isViewMode:o}}),eu=D([B],e=>e.componentOptics),ey=D([eu],e=>(e=>{let t=new Map,n=new Map,o=new Map,i=new Map;for(let n of e)for(let e of n.entityTypes){let o=t.get(e);o||(o=new Map,t.set(e,o));let a=o.get(n.componentType);if(a||(a=new Map,o.set(n.componentType,a)),a.has(n.instanceName))throw Error(`Component instance ${n.instanceName} already exists for type ${n.componentType.name} in entity ${e}. This is likely a bug in the component definition! InstanceNames must be unique within an entity and component.`);if(a.set(n.instanceName,n),"dynamic"===n.kind){let t=i.get(e);t||(t=new Map,i.set(e,t));let o=t.get(n.componentType)??[],a=o.find(e=>{var t;return t=n.instanceName,e.startsWith(`${t}_`)||t.startsWith(`${e}_`)});if(a)throw Error(`Cannot register dynamic component instance ${n.instanceName} for component ${n.componentType.name} on entity ${e} because it overlaps with dynamic instance ${a}. Rename one dynamic instance so compound names cannot be ambiguous.`);t.set(n.componentType,[...o,n.instanceName])}}for(let[e,i]of t.entries()){n.set(e,new Set(i.keys()));let t=new Map;for(let[n,a]of(o.set(e,t),i.entries()))t.set(n,new Set(a.keys()))}return{opticMap:t,allComponentTypes:n,allComponentInstanceNames:o,dynamicInstanceNames:i}})(e)),ew=D([ey,Y,et],(e,t,n)=>({componentReaderIndexes:e,domainExpressions:t,allowedRootEntityTypes:n})),eh=D([B],e=>e.navigationStates),eS=D([B],e=>e.viewStates),ex="configurator"===A?D([T.selectConfiguratorSpec],e=>e.toolStates):D([],()=>v),ej="configurator"===A?D([T.selectConfiguratorSpec],e=>e.exportStates):D([],()=>v),eC="configurator"===A?D([T.selectConfiguratorSpec],e=>e.createTransformers):D([],()=>void 0),eD=D([em],e=>{if(null===e)throw Error(`Loaded data is not available for ${A}! Loaded data is written after the configuration fetch succeeds and before the domain context initialization starts.`);return e}),ev=D([eD,G],(e,t)=>o(t.validateAndMigrateState(e.initialEntities,e.modelVersion),e.rootEntityType)),eI="configurator"===A?$.selectConfiguratorFrontendData:$.selectAdminFrontendData,eP="configurator"===A?$.selectConfiguratorBackendData:$.selectAdminBackendData,eM="configurator"===A?$.selectConfiguratorPublishedData:$.selectAdminPublishedData,eA="configurator"===A?D([N.selectSessionContext],e=>M(e).role):D([],()=>"admin"),eR="configurator"===A?D([N.selectSessionContext],e=>M(e).data):D([],()=>I),eE=D([ea,ei,eA,eR,eD],(e,t,n,o,i)=>({configurationId:e,mode:t,role:n,schemaIdentity:i.schemaIdentity,sessionData:o})),eT=D([q],e=>e.mode),eb=D([q],e=>{let t=e.configurationId;if(null===t)throw Error(`Configuration id is not available for ${A}! Read it from an active interactive domain lifecycle.`);return t}),ek=D([q],e=>e.role),e$=D([q],e=>e.sessionData),eN=D([eT,ek,e$,eI,eP,eM,eo],(e,t,n,o,i,a,s)=>({mode:e,role:t,sessionData:n,frontendData:o,backendData:i,publishedData:a,migrate:s,domain:eL,componentReader:eV,positionProjections:eq,sketchingProjections:e_,collisionProjections:eO,constraintProjections:eG,snappingProjections:eU,projectedEntitiesProjections:eH})),ez={selectApplicationSpec:B,selectRawAccessService:F,selectDomainContextState:W,selectInitializationContext:_,selectActiveInitializationContext:q,selectExecutionMode:O,selectIsInitialized:U,selectFactory:G,selectSpecExpressions:H,select$SpecEntityReflections:X,selectDomainExpressions:Y,selectModelVersion:Z,selectAliasMap:ee,selectAllowedRootEntityTypes:et,selectEntityReflections:en,selectMigrate:eo,selectLatestMode:ei,selectLatestConfigurationId:ea,selectLatestSessionContext:es,selectLatestRoleOrNull:er,selectLatestSessionDataOrNull:ec,selectLatestSchemaIdentity:el,selectSchemaCoherence:ed,selectInitializationIdentity:eg,selectIsViewMode:ef,selectInitializationState:ep,selectComponentOptics:eu,selectComponentReaderIndexes:ey,selectStoreRuntimeDependencies:ew,selectNavigationStates:eh,selectViewStates:eS,selectToolStates:ex,selectExportStates:ej,selectCreateTransformers:eC,selectLatestLoadedData:em,selectLoadedData:eD,selectInitialDomainState:ev,selectFrontendData:eI,selectBackendData:eP,selectPublishedData:eM,selectLatestRole:eA,selectLatestSessionData:eR,selectNextInitializationContext:eE,selectActiveMode:eT,selectActiveConfigurationId:eb,selectActiveRole:ek,selectActiveSessionData:e$,selectExpressionContext:eN,getInitializationContext:()=>_(R()),getInitializationState:()=>ep(R()),getNextInitializationContext:()=>eE(R()),getLatestLoadedData:()=>em(R()),getSchemaCoherence:()=>ed(R()),getActiveConfigurationId:()=>eb(R()),getFactory:()=>G(R()),getDomainExpressions:()=>Y(R()),getActionDefinitions:()=>J(R()),getActionImplementations:()=>Q(R()),getModelVersion:()=>Z(R()),getAliasMap:()=>ee(R()),getAllowedRootEntityTypes:()=>et(R()),getEntityReflections:()=>en(R()),getMigrate:()=>eo(R()),getActiveMode:()=>eT(R()),getIsInitialized:()=>U(R()),getComponentReaderIndexes:()=>ey(R()),getStoreRuntimeDependencies:()=>ew(R()),getNavigationStates:()=>eh(R()),getViewStates:()=>eS(R()),getToolStates:()=>ex(R()),getExportStates:()=>ej(R()),getCreateTransformers:()=>eC(R()),getLoadedData:()=>eD(R()),getInitialDomainState:()=>ev(R()),getFrontendData:()=>eI(R()),getBackendData:()=>eP(R()),getPublishedData:()=>eM(R()),getActiveRole:()=>ek(R()),getActiveSessionData:()=>e$(R()),getDomain:()=>eL,getComponentReader:()=>eV,getCompositionProjections:()=>eB,getDimensionSystem:()=>eF,getValidationProjections:()=>eW,getSketchingProjections:()=>e_,getPositionProjections:()=>eq,getCollisionProjections:()=>eO,getSnappingProjections:()=>eU,getConstraintProjections:()=>eG,getProjectedEntitiesProjections:()=>eH,getStoreSystem:()=>eJ,getNavigationSystem:()=>eK,getUndoSystem:()=>eQ,getRecipeCookerSystem:()=>eX,getActionSystem:()=>eY,getBlenderProjections:()=>eZ,getExpressionContext:()=>eN(R()),getDomainSystems:function(){return e0},getDomainContext:function(){return e1}},eL=new n({selectors:ez}),eV=new j({selectors:ez}),eB=new f({selectors:ez}),eF=new a({selectors:ez}),eW=new h({selectors:ez}),e_=new S({selectors:ez}),eq=new u({selectors:ez}),eO=new g({selectors:ez}),eU=new w({selectors:ez}),eG=new p({selectors:ez}),eH=new y({selectors:ez}),eJ=new c({selectors:ez,domainServicesSelectors:z,environmentSelectors:L}),eK=new s({selectors:ez,domainServicesSelectors:z}),eQ=new m({selectors:ez}),eX=new r({selectors:ez}),eY=new i({selectors:ez}),eZ=new d({selectors:ez,domainServicesSelectors:z}),e0={domainContextSelectors:ez,domain:eL,componentReader:eV,compositionProjections:eB,blenderProjections:eZ,validationProjections:eW,storeSystem:eJ,navigationSystem:eK,dimensionSystem:eF,undoSystem:eQ,recipeCooker:eX,actionSystem:eY,sketchingProjections:e_,collisionProjections:eO,positionProjections:eq,snappingProjections:eU,projectedEntitiesProjections:eH,constraintProjections:eG},e1=new C({selectors:ez,actions:E,getExtensionSystems:V});return ez};
|
|
@@ -398,6 +398,8 @@ export declare function createDomainRuntimeSlices<State extends DomainRuntimeSta
|
|
|
398
398
|
getActiveConfigurationId: () => string;
|
|
399
399
|
getFactory: () => import("../index.js").AnyDomainFactory;
|
|
400
400
|
getDomainExpressions: () => import("../index.js").AnyExpressions;
|
|
401
|
+
getActionDefinitions: () => Readonly<Record<string, import("../index.js").ActionDefinition>>;
|
|
402
|
+
getActionImplementations: () => Readonly<Record<string, import("../index.js").AnyActionImplementation>>;
|
|
401
403
|
getModelVersion: () => number;
|
|
402
404
|
getAliasMap: () => import("../index.js").AnyAliasMap;
|
|
403
405
|
getAllowedRootEntityTypes: () => import("../index.js").AnyAllowedRootEntityTypes;
|
|
@@ -438,6 +440,7 @@ export declare function createDomainRuntimeSlices<State extends DomainRuntimeSta
|
|
|
438
440
|
getNavigationSystem: () => import("../domain-context/navigation-system/navigation-system.js").AnyNavigationSystem;
|
|
439
441
|
getUndoSystem: () => import("../domain-context/undo-system.js").AnyUndoSystem;
|
|
440
442
|
getRecipeCookerSystem: () => import("../index.js").AnyRecipeCookerSystem;
|
|
443
|
+
getActionSystem: () => import("../index.js").AnyActionSystem;
|
|
441
444
|
getBlenderProjections: () => import("../index.js").AnyBlenderProjections;
|
|
442
445
|
getExpressionContext: () => import("../index.js").AnyExpressionContext;
|
|
443
446
|
getDomainSystems: () => import("../index.js").AnyDomainContextSystems;
|
|
@@ -504,6 +507,8 @@ export declare function createDomainRuntimeSlices<State extends DomainRuntimeSta
|
|
|
504
507
|
getActiveConfigurationId: () => string;
|
|
505
508
|
getFactory: () => import("../index.js").AnyDomainFactory;
|
|
506
509
|
getDomainExpressions: () => import("../index.js").AnyExpressions;
|
|
510
|
+
getActionDefinitions: () => Readonly<Record<string, import("../index.js").ActionDefinition>>;
|
|
511
|
+
getActionImplementations: () => Readonly<Record<string, import("../index.js").AnyActionImplementation>>;
|
|
507
512
|
getModelVersion: () => number;
|
|
508
513
|
getAliasMap: () => import("../index.js").AnyAliasMap;
|
|
509
514
|
getAllowedRootEntityTypes: () => import("../index.js").AnyAllowedRootEntityTypes;
|
|
@@ -544,6 +549,7 @@ export declare function createDomainRuntimeSlices<State extends DomainRuntimeSta
|
|
|
544
549
|
getNavigationSystem: () => import("../domain-context/navigation-system/navigation-system.js").AnyNavigationSystem;
|
|
545
550
|
getUndoSystem: () => import("../domain-context/undo-system.js").AnyUndoSystem;
|
|
546
551
|
getRecipeCookerSystem: () => import("../index.js").AnyRecipeCookerSystem;
|
|
552
|
+
getActionSystem: () => import("../index.js").AnyActionSystem;
|
|
547
553
|
getBlenderProjections: () => import("../index.js").AnyBlenderProjections;
|
|
548
554
|
getExpressionContext: () => import("../index.js").AnyExpressionContext;
|
|
549
555
|
getDomainSystems: () => import("../index.js").AnyDomainContextSystems;
|
|
@@ -982,6 +988,8 @@ export declare const createDomainRuntime: (props: Omit<Props<DomainRuntimeState>
|
|
|
982
988
|
getActiveConfigurationId: () => string;
|
|
983
989
|
getFactory: () => import("../index.js").AnyDomainFactory;
|
|
984
990
|
getDomainExpressions: () => import("../index.js").AnyExpressions;
|
|
991
|
+
getActionDefinitions: () => Readonly<Record<string, import("../index.js").ActionDefinition>>;
|
|
992
|
+
getActionImplementations: () => Readonly<Record<string, import("../index.js").AnyActionImplementation>>;
|
|
985
993
|
getModelVersion: () => number;
|
|
986
994
|
getAliasMap: () => import("../index.js").AnyAliasMap;
|
|
987
995
|
getAllowedRootEntityTypes: () => import("../index.js").AnyAllowedRootEntityTypes;
|
|
@@ -1022,6 +1030,7 @@ export declare const createDomainRuntime: (props: Omit<Props<DomainRuntimeState>
|
|
|
1022
1030
|
getNavigationSystem: () => import("../domain-context/navigation-system/navigation-system.js").AnyNavigationSystem;
|
|
1023
1031
|
getUndoSystem: () => import("../domain-context/undo-system.js").AnyUndoSystem;
|
|
1024
1032
|
getRecipeCookerSystem: () => import("../index.js").AnyRecipeCookerSystem;
|
|
1033
|
+
getActionSystem: () => import("../index.js").AnyActionSystem;
|
|
1025
1034
|
getBlenderProjections: () => import("../index.js").AnyBlenderProjections;
|
|
1026
1035
|
getExpressionContext: () => import("../index.js").AnyExpressionContext;
|
|
1027
1036
|
getDomainSystems: () => import("../index.js").AnyDomainContextSystems;
|
|
@@ -1088,6 +1097,8 @@ export declare const createDomainRuntime: (props: Omit<Props<DomainRuntimeState>
|
|
|
1088
1097
|
getActiveConfigurationId: () => string;
|
|
1089
1098
|
getFactory: () => import("../index.js").AnyDomainFactory;
|
|
1090
1099
|
getDomainExpressions: () => import("../index.js").AnyExpressions;
|
|
1100
|
+
getActionDefinitions: () => Readonly<Record<string, import("../index.js").ActionDefinition>>;
|
|
1101
|
+
getActionImplementations: () => Readonly<Record<string, import("../index.js").AnyActionImplementation>>;
|
|
1091
1102
|
getModelVersion: () => number;
|
|
1092
1103
|
getAliasMap: () => import("../index.js").AnyAliasMap;
|
|
1093
1104
|
getAllowedRootEntityTypes: () => import("../index.js").AnyAllowedRootEntityTypes;
|
|
@@ -1128,6 +1139,7 @@ export declare const createDomainRuntime: (props: Omit<Props<DomainRuntimeState>
|
|
|
1128
1139
|
getNavigationSystem: () => import("../domain-context/navigation-system/navigation-system.js").AnyNavigationSystem;
|
|
1129
1140
|
getUndoSystem: () => import("../domain-context/undo-system.js").AnyUndoSystem;
|
|
1130
1141
|
getRecipeCookerSystem: () => import("../index.js").AnyRecipeCookerSystem;
|
|
1142
|
+
getActionSystem: () => import("../index.js").AnyActionSystem;
|
|
1131
1143
|
getBlenderProjections: () => import("../index.js").AnyBlenderProjections;
|
|
1132
1144
|
getExpressionContext: () => import("../index.js").AnyExpressionContext;
|
|
1133
1145
|
getDomainSystems: () => import("../index.js").AnyDomainContextSystems;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SessionRole as e}from"@salsita-ai/contracts/api";let a=(e,a)=>{let t={};for(let n of e)t[n.name]=a?.[n.name]??n.name;return t},t=(e,a)=>{let t={},n=0;for(let
|
|
1
|
+
import{SessionRole as e}from"@salsita-ai/contracts/api";let a=(e,a)=>{let t={};for(let n of e)t[n.name]=a?.[n.name]??n.name;return t},t=(e,a)=>{let t={},n=0;for(let o of e)if("entity"===o.type||"layout"===o.type)t[o.name]=a?.[o.name]??o.name;else{let e=`icon:${n}`;t[e]=a?.[e]??`${e}:${o.elements.length}`,n+=1}return t};export const initializeSpec=n=>{let o=n.adminDomain.presets[0];if(!o)throw Error("Cannot register application spec because admin preset is required.");return{version:n.version,dataConfig:n.dataSpec??null,chunks:n.chunks,publishedDataHash:n.publishedDataHash,initialPublishedData:n.initialPublishedData,canCreate:n.features?.acl?.canCreate??Object.values(e),enableAdminRelease:n.features?.enableAdminRelease??!1,textLanguages:n.domain.textLanguages??n.adminDomain.textLanguages??["en"],baseResourcesUrl:n.resources?.baseResourcesUrl??n.defaultEnvs?.resourcesUrl??"",configurator:{factory:n.domain.domainFactory,presets:n.domain.presets,aliasMap:n.domain.domainFactory.context.aliasMap,entityReflections:n.domain.domainFactory.context.entityReflections,$entityReflections:n.domain.domainFactory.context.$entityReflections,expressions:n.domain.domainFactory.context.expressions,actions:n.domain.domainFactory.context.actions,actionImplementations:n.domain.domainFactory.context.actionImplementations,allowedRootEntityTypes:n.domain.domainFactory.context.allowedRootEntityTypes,migrate:n.domain.domainFactory.context.migrate,componentOptics:n.domain.componentOptics,createTransformers:n.createTransformers??(()=>[]),navigationStates:n.navigation?.navigationStates??[],viewStates:n.navigation?.viewStates??[],toolStates:n.navigation?.toolStates??[],exportStates:n.navigation?.exportStates??[],handlers:n.handlers,handlerHashes:a(n.handlers),elements:n.elements,elementHashes:t(n.elements),appLoader:n.ui?.appLoader??"universal",preview:n.ui?.preview??"auto",alwaysExpand:n.ui?.alwaysExpand??!1,theme:n.ui?.theme??{},assistant:n.assistant??null,deploymentQueryDisabled:n.resources?.deploymentQueryDisabled??!1,prefetchTextureUrls:n.resources?.prefetchTextureUrls??[],modelVersion:n.domain.domainFactory.modelVersion},admin:{factory:n.adminDomain.domainFactory,modelVersion:n.adminDomain.domainFactory.modelVersion,aliasMap:n.adminDomain.domainFactory.context.aliasMap,entityReflections:n.adminDomain.domainFactory.context.entityReflections,$entityReflections:n.adminDomain.domainFactory.context.$entityReflections,expressions:n.adminDomain.domainFactory.context.expressions,actions:n.adminDomain.domainFactory.context.actions,actionImplementations:n.adminDomain.domainFactory.context.actionImplementations,allowedRootEntityTypes:n.adminDomain.domainFactory.context.allowedRootEntityTypes,migrate:n.adminDomain.domainFactory.context.migrate,preset:o,componentOptics:n.adminDomain.componentOptics,navigationStates:n.adminNavigation?.navigationStates??[],viewStates:n.adminNavigation?.viewStates??[],handlers:n.handlers,handlerHashes:a(n.handlers),elements:n.elements,elementHashes:t(n.elements)}}};
|
|
@@ -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};
|