@salsita-ai/sdk 0.50.0-develop.8f6deac646 → 0.50.0-develop.9267bdc12e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/application-spec/errors/diagnostic-codes.d.ts +5 -0
- package/dist/application-spec/errors/diagnostic-codes.js +1 -1
- package/dist/application-spec/errors/diagnostic-messages.d.ts +5 -0
- package/dist/application-spec/errors/diagnostic-messages.js +1 -1
- package/dist/application-spec/generate-application/code/project-scaffolding.d.ts +8 -1
- package/dist/application-spec/generate-application/code/project-scaffolding.js +2 -2
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-defaults.d.ts +4 -2
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.js +48 -48
- 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/generate-relation-expressions.js +1 -1
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-resources.d.ts +6 -8
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-resources.js +11 -11
- package/dist/application-spec/generate-application/code/templates/domain-spec/index.d.ts +1 -1
- package/dist/application-spec/generate-application/code/templates/domain-spec/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/domain-spec.js +12 -12
- package/dist/application-spec/generate-application/code/templates/domain.js +3 -3
- package/dist/application-spec/generate-application/code/templates/globals.js +5 -4
- package/dist/application-spec/generate-application/code/templates/index.d.ts +0 -7
- package/dist/application-spec/generate-application/code/templates/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/package-json.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js +8 -2
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +9 -10
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +2 -4
- package/dist/application-spec/generate-application/runtime/application-runtime.d.ts +1 -3
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.d.ts +1 -3
- package/dist/application-spec/generate-application/runtime/sections/component-optic.d.ts +2 -1
- package/dist/application-spec/generate-application/runtime/sections/expression-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/sections/transformers-runtime.d.ts +2 -4
- package/dist/application-spec/parse-application-files/categorize/module-analysis.d.ts +1 -1
- package/dist/application-spec/parse-application-files/categorize/module-analysis.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.d.ts +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.js +1 -1
- package/dist/application-spec/parse-application-files/spec/application/admin-spec/admin-spec.js +1 -1
- package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.js +1 -1
- package/dist/application-spec/parse-application-files/spec/model/defaults.d.ts +7 -2
- package/dist/application-spec/parse-application-files/spec/model/defaults.js +1 -1
- package/dist/application-spec/parse-application-files/spec/relations/reference-field-type.d.ts +25 -0
- package/dist/application-spec/parse-application-files/spec/relations/reference-field-type.js +1 -0
- package/dist/application-spec/parse-application-files/spec/relations/relation-field-mismatch.d.ts +46 -0
- package/dist/application-spec/parse-application-files/spec/relations/relation-field-mismatch.js +1 -0
- package/dist/application-spec/parse-application-files/spec/relations/relations.d.ts +4 -3
- package/dist/application-spec/parse-application-files/spec/relations/relations.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/infra.d.ts +2 -0
- package/dist/application-spec/parse-application-files/spec/sections/infra.js +1 -1
- package/dist/configurator/application-runtime/extensions/create-configurator-extensions.js +1 -1
- package/dist/configurator/application-runtime/extensions/selectors.d.ts +3 -1
- package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +3 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +3 -1
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.js +1 -1
- package/dist/configurator/common/configurator-interface.d.ts +5 -1
- package/dist/configurator/common/configurator-interface.js +1 -1
- package/dist/configurator/pages/DefaultConfiguratorLayout.d.ts +6 -0
- package/dist/configurator/pages/DefaultConfiguratorLayout.js +1 -0
- package/dist/configurator/pages/LoadedConfiguratorDetailPage.js +1 -1
- package/dist/configurator/ui/configurator-layout/universal/DesktopLayout.d.ts +1 -75
- package/dist/configurator/ui/configurator-layout/universal/DesktopLayout.js +5 -20
- package/dist/configurator/ui/configurator-layout/universal/DesktopPreview.js +1 -1
- package/dist/configurator/ui/configurator-layout/universal/DesktopSidebar.d.ts +92 -0
- package/dist/configurator/ui/configurator-layout/universal/DesktopSidebar.js +16 -0
- package/dist/configurator/ui/configurator-layout/universal/MobileLayout.js +4 -4
- package/dist/configurator/ui/configurator-layout/universal/MobilePreview.js +1 -1
- package/dist/configurator/ui/configurator-layout/universal/use-layout-scene-safe-area.d.ts +47 -0
- package/dist/configurator/ui/configurator-layout/universal/use-layout-scene-safe-area.js +1 -0
- package/dist/configurator/ui/configurator-layout/universal/use-scene-safe-area.d.ts +11 -26
- package/dist/configurator/ui/configurator-layout/universal/use-scene-safe-area.js +1 -1
- package/dist/docs/complex-use-cases/filtered-controls-with-fix-dialog.mdx +16 -19
- package/dist/docs/complex-use-cases/sketching.mdx +0 -38
- package/dist/docs/controls/select-attribute/cardselect.mdx +9 -13
- package/dist/docs/index.json +11 -1
- package/dist/docs/integrations/woocommerce/local-development.mdx +1 -1
- package/dist/docs/layouts/custom-layout.mdx +981 -0
- package/dist/docs/other-features/side-effects.mdx +8 -11
- package/dist/docs/other-features/violation-messages.mdx +52 -56
- package/dist/docs/phoenix/configurator-interface.mdx +105 -65
- package/dist/docs/phoenix/domain-model.mdx +4 -0
- package/dist/docs/phoenix/getting-started.mdx +1 -1
- package/dist/docs/phoenix/phoenix-cli.mdx +19 -26
- package/dist/docs/phoenix/project-structure.mdx +16 -10
- package/dist/docs/phoenix/quickstart.mdx +2 -2
- package/dist/docs/phoenix/sdk-builder-workflow.mdx +2 -2
- package/dist/docs/phoenix/webhook-membership.mdx +10 -9
- package/dist/docs/phoenix/webhooks.mdx +2 -2
- package/dist/domain/admin-domain/implementation/common-admin-expressions.d.ts +26 -11
- package/dist/domain/admin-domain/implementation/common-admin-publish.d.ts +1 -2
- package/dist/domain/admin-domain/index.js +1 -1
- package/dist/domain/application/GetApplicationWrapperHandler.d.ts +2 -2
- package/dist/domain/application/GetThemeHandler.d.ts +1 -1
- package/dist/domain/application/GetWebComponentOptions.d.ts +1 -1
- package/dist/domain/application/application-config.d.ts +5 -3
- package/dist/domain/application/assistant/assistant-fields.d.ts +5 -0
- package/dist/domain/application/assistant/assistant-fields.js +1 -0
- package/dist/domain/application/assistant/assistant-resolved-manifest.d.ts +27 -1
- package/dist/domain/application/assistant/assistant-resolved-manifest.js +1 -1
- package/dist/domain/application/assistant/index.d.ts +4 -1
- package/dist/domain/application/assistant/index.js +1 -1
- package/dist/domain/application/assistant/session-setup/AssistantSetupHandler.d.ts +20 -0
- package/dist/domain/application/assistant/session-setup/AssistantSetupHandler.js +1 -0
- package/dist/domain/application/assistant/session-setup/apply-assistant-setup.d.ts +10 -0
- package/dist/domain/application/assistant/session-setup/apply-assistant-setup.js +1 -0
- package/dist/domain/application/assistant/session-setup/assistant-setup-manifest.d.ts +48 -0
- package/dist/domain/application/assistant/session-setup/assistant-setup-manifest.js +1 -0
- package/dist/domain/application/assistant/session-setup/create-session-assistant.d.ts +15 -0
- package/dist/domain/application/assistant/session-setup/create-session-assistant.js +1 -0
- package/dist/domain/application/assistant/session-setup/index.d.ts +4 -0
- package/dist/domain/application/assistant/session-setup/index.js +1 -0
- package/dist/domain/application/configurator-builder.d.ts +2 -2
- package/dist/domain/application/configurator-builder.js +1 -1
- package/dist/domain/application/create-initial-published-data.d.ts +6 -7
- package/dist/domain/application/index.d.ts +0 -4
- package/dist/domain/application/index.js +1 -1
- package/dist/domain/application/published-data/DataRowValidatorHandler.d.ts +1 -1
- package/dist/domain/application/published-data/FilterPublishedChunksHandler.d.ts +1 -1
- package/dist/domain/application/published-data/MapPublishedChunkedDataHandler.d.ts +1 -1
- package/dist/domain/application/published-data/MapPublishedRevisionDataHandler.d.ts +1 -1
- package/dist/domain/application/published-data/SheetValidatorHandler.d.ts +1 -1
- package/dist/domain/application/published-data/map-published-chunked-data.d.ts +1 -1
- package/dist/domain/application/published-data/map-published-data.d.ts +7 -3
- package/dist/domain/core/component/domain-component-optic.d.ts +11 -19
- package/dist/domain/core/component/domain-component-optic.js +2 -2
- package/dist/domain/core/component/legacy-filter.d.ts +2 -17
- package/dist/domain/core/component/system-component-filter.d.ts +36 -18
- package/dist/domain/core/expression/constant-expressions.d.ts +16 -8
- package/dist/domain/core/expression/constant-expressions.js +1 -1
- package/dist/domain/core/expression/custom-expression.d.ts +17 -4
- package/dist/domain/core/expression/custom-expression.js +1 -1
- package/dist/domain/core/expression/expression.d.ts +1 -2
- package/dist/domain/core/invariant/custom-invariants.d.ts +6 -14
- package/dist/domain/core/invariant/invariants.d.ts +1 -4
- package/dist/domain/core/recipe/recipes.d.ts +18 -50
- package/dist/domain/core/recipe/recipes.js +1 -1
- package/dist/domain/core/relation/all-of-type-relation.d.ts +8 -21
- package/dist/domain/core/relation/all-of-type-relation.js +1 -1
- package/dist/domain/core/relation/direct-relation.d.ts +13 -24
- package/dist/domain/core/relation/index.d.ts +0 -1
- package/dist/domain/core/relation/indirect-relation.d.ts +12 -67
- package/dist/domain/core/relation/indirect-relation.js +1 -1
- package/dist/domain/core/relation/relation-factory.d.ts +19 -15
- package/dist/domain/core/relation/relation-factory.js +1 -1
- package/dist/domain/core/state/migrations.d.ts +14 -45
- package/dist/domain/core/state/migrations.js +1 -1
- package/dist/domain/core/state/state.d.ts +1 -1
- package/dist/domain/domain-builder.d.ts +1 -1
- package/dist/domain/domain-builder.js +1 -1
- package/dist/domain/domain-runtime/access/selectors.d.ts +9 -0
- package/dist/domain/domain-runtime/access/selectors.js +1 -1
- package/dist/domain/domain-runtime/access/types.d.ts +2 -0
- package/dist/domain/domain-runtime/access/types.js +1 -1
- package/dist/domain/domain-runtime/domain-context/selectors.d.ts +14 -13
- package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
- package/dist/domain/domain-runtime/domain-context/types.d.ts +4 -1
- package/dist/domain/domain-runtime/domain-runtime.d.ts +56 -40
- package/dist/domain/domain-runtime/errors/implementation-error-collector.d.ts +19 -0
- package/dist/domain/domain-runtime/errors/implementation-error-collector.js +1 -0
- package/dist/domain/domain-runtime/errors/implementation-error.d.ts +46 -0
- package/dist/domain/domain-runtime/errors/implementation-error.js +1 -0
- package/dist/domain/domain-runtime/errors/implementation-errors.d.ts +13 -0
- package/dist/domain/domain-runtime/errors/implementation-errors.js +1 -0
- package/dist/domain/domain-runtime/errors/index.d.ts +4 -0
- package/dist/domain/domain-runtime/errors/index.js +1 -0
- package/dist/domain/domain-runtime/errors/to-implementation-errors.d.ts +10 -0
- package/dist/domain/domain-runtime/errors/to-implementation-errors.js +1 -0
- package/dist/domain/domain-runtime/index.d.ts +1 -0
- package/dist/domain/domain-runtime/index.js +1 -1
- package/dist/domain/domain-runtime/spec/create-violation-expressions.d.ts +24 -0
- package/dist/domain/domain-runtime/spec/create-violation-expressions.js +1 -0
- package/dist/domain/domain-runtime/spec/index.d.ts +2 -5
- package/dist/domain/domain-runtime/spec/index.js +1 -1
- package/dist/domain/domain-runtime/spec/initialize.js +1 -1
- package/dist/domain/{application → domain-runtime/spec/module-checks}/element-registration.d.ts +2 -2
- package/dist/domain/domain-runtime/spec/module-checks/element-registration.js +1 -0
- package/dist/domain/{application → domain-runtime/spec/module-checks}/handler-registration.d.ts +1 -1
- package/dist/domain/domain-runtime/spec/module-checks/handler-registration.js +1 -0
- package/dist/domain/domain-runtime/spec/module-checks/index.d.ts +8 -0
- package/dist/domain/domain-runtime/spec/module-checks/index.js +1 -0
- package/dist/domain/{project-modules → domain-runtime/spec/module-checks}/project-modules.d.ts +8 -1
- package/dist/domain/domain-runtime/spec/module-checks/project-modules.js +1 -0
- package/dist/domain/domain-runtime/spec/{resolve-action-modules.d.ts → module-checks/resolve-action-modules.d.ts} +2 -2
- package/dist/domain/domain-runtime/spec/module-checks/resolve-action-modules.js +1 -0
- package/dist/domain/domain-runtime/spec/{resolve-component-optic-modules.d.ts → module-checks/resolve-component-optic-modules.d.ts} +2 -2
- package/dist/domain/domain-runtime/spec/module-checks/resolve-component-optic-modules.js +1 -0
- package/dist/domain/domain-runtime/spec/{resolve-expression-modules.d.ts → module-checks/resolve-expression-modules.d.ts} +2 -2
- package/dist/domain/domain-runtime/spec/module-checks/resolve-expression-modules.js +1 -0
- package/dist/domain/domain-runtime/spec/module-checks/resolve-imported-transformers.d.ts +22 -0
- package/dist/domain/domain-runtime/spec/module-checks/resolve-imported-transformers.js +1 -0
- package/dist/domain/domain-runtime/spec/module-checks/resolve-invariant-modules.d.ts +6 -0
- package/dist/domain/domain-runtime/spec/module-checks/resolve-invariant-modules.js +1 -0
- package/dist/domain/domain-runtime/spec/selectors.d.ts +5 -6
- package/dist/domain/domain-runtime/spec/selectors.js +1 -1
- package/dist/domain/domain-runtime/spec/types.d.ts +2 -1
- package/dist/domain/index.d.ts +0 -1
- package/dist/domain/mocks/create-mock-domain-context.d.ts +1 -1
- package/dist/domain/mocks/create-mock-domain-runtime.d.ts +18 -9
- package/dist/domain/mocks/create-mock-domain-runtime.js +1 -1
- package/dist/domain/mocks/create-mock-domain.d.ts +1 -1
- package/dist/domain/mocks/create-mock-domain.js +1 -1
- package/dist/domain/mocks/create-mock-state.d.ts +2 -2
- package/dist/domain/projections/blender-projections/camera.d.ts +1 -1
- package/dist/domain/utils/eval-cache.d.ts +1 -1
- package/dist/domain/utils/map-nested-object.d.ts +1 -1
- package/dist/editor/domain-editors/use-implementation-files.d.ts +1 -2
- package/dist/editor/mocks/EditorMockContext.js +1 -1
- package/dist/legacy/domain-cli/gen/configurator-builder.js +13 -12
- package/dist/legacy/domain-cli/gen/constant-expressions.js +1 -3
- package/dist/legacy/domain-cli/gen/defaults.js +1 -7
- package/dist/legacy/domain-cli/gen/implementation.js +7 -11
- package/dist/legacy/domain-cli/gen/invariants.js +3 -4
- package/dist/legacy/domain-cli/gen/relations.js +1 -1
- package/dist/legacy/domain-cli/utils/cache.d.ts +1 -1
- package/dist/legacy/domain-cli/utils/cache.js +1 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/claude-md.d.ts +1 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/cursor-rules.d.ts +1 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.d.ts +1 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.js +1 -0
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/domain-index.js +17 -15
- package/dist/phoenix/application-spec/application-spec-builder.js +1 -1
- package/dist/phoenix/commands/init.d.ts +4 -4
- package/dist/phoenix/commands/init.js +1 -1
- package/dist/phoenix/commands/prettier.js +1 -1
- package/dist/phoenix/utils/git/index.d.ts +1 -0
- package/dist/phoenix/utils/git/index.js +1 -0
- package/dist/phoenix/utils/git/is-inside-git-repository.d.ts +6 -0
- package/dist/phoenix/utils/git/is-inside-git-repository.js +1 -0
- package/dist/phoenix/utils/index.d.ts +1 -0
- package/dist/phoenix/utils/index.js +1 -1
- package/dist/react-sdk/application-runtime/hooks/use-access-service.d.ts +2 -0
- package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.js +1 -1
- package/dist/react-sdk/application-runtime/routing/access-service.d.ts +1 -0
- package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +33 -16
- package/dist/react-sdk/application-runtime/runtime/create-application-runtime.js +1 -1
- package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +4 -4
- package/dist/react-sdk/domain-context/index.d.ts +1 -1
- package/dist/react-sdk/domain-context/index.js +1 -1
- package/dist/react-sdk/domain-context/system-hooks/navigation-hooks.d.ts +6 -0
- package/dist/react-sdk/domain-context/system-hooks/navigation-hooks.js +1 -1
- package/dist/webhook/builders/webhook-builder.js +1 -1
- package/package.json +3 -3
- package/dist/application-spec/generate-application/code/templates/env-ci.d.ts +0 -1
- package/dist/application-spec/generate-application/code/templates/env-ci.js +0 -25
- package/dist/application-spec/generate-application/code/templates/env-example.d.ts +0 -1
- package/dist/application-spec/generate-application/code/templates/env-example.js +0 -94
- package/dist/application-spec/generate-application/code/templates/prettier-ignore.d.ts +0 -1
- package/dist/application-spec/generate-application/code/templates/prettier-ignore.js +0 -6
- package/dist/application-spec/generate-application/code/templates/private-assets-readme.d.ts +0 -1
- package/dist/application-spec/generate-application/code/templates/private-assets-readme.js +0 -24
- package/dist/application-spec/generate-application/code/templates/public-assets-readme.d.ts +0 -1
- package/dist/application-spec/generate-application/code/templates/public-assets-readme.js +0 -24
- package/dist/application-spec/generate-application/code/templates/readme.d.ts +0 -1
- package/dist/application-spec/generate-application/code/templates/readme.js +0 -23
- package/dist/application-spec/generate-application/code/templates/skills/agents-md.d.ts +0 -1
- package/dist/application-spec/generate-application/code/templates/skills/agents-md.js +0 -2
- package/dist/domain/application/element-registration.js +0 -1
- package/dist/domain/application/handler-registration.js +0 -1
- package/dist/domain/application/resolve-imported-transformers.d.ts +0 -22
- package/dist/domain/application/resolve-imported-transformers.js +0 -1
- package/dist/domain/application/resource-builder.d.ts +0 -13
- package/dist/domain/application/resource-builder.js +0 -1
- package/dist/domain/core/relation/relation-implementation.d.ts +0 -7
- package/dist/domain/core/relation/relation-implementation.js +0 -1
- package/dist/domain/domain-runtime/spec/invariant-builder.d.ts +0 -26
- package/dist/domain/domain-runtime/spec/invariant-builder.js +0 -1
- package/dist/domain/domain-runtime/spec/resolve-action-modules.js +0 -1
- package/dist/domain/domain-runtime/spec/resolve-component-optic-modules.js +0 -1
- package/dist/domain/domain-runtime/spec/resolve-expression-modules.js +0 -1
- package/dist/domain/domain-runtime/spec/resolve-invariant-modules.d.ts +0 -6
- package/dist/domain/domain-runtime/spec/resolve-invariant-modules.js +0 -1
- package/dist/domain/project-modules/index.d.ts +0 -1
- package/dist/domain/project-modules/index.js +0 -1
- package/dist/domain/project-modules/project-modules.js +0 -1
|
@@ -1,28 +1,17 @@
|
|
|
1
|
+
import type { AnyDomain } from '../domain.js';
|
|
1
2
|
import type { ExpressionMeta } from '../expression/index.js';
|
|
2
|
-
import type { DomainEntity,
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import type { DomainEntity, DomainEntityId } from '../model/index.js';
|
|
4
|
+
import type { DomainState } from '../state/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* A relation whose related entities are the ones a field of the entity itself references. The
|
|
7
|
+
* application-spec parser checks that `field` is a reference field of the entity that fits the
|
|
8
|
+
* target and the cardinality.
|
|
9
|
+
*/
|
|
10
|
+
export interface DirectRelation {
|
|
6
11
|
kind: 'direct';
|
|
7
|
-
target:
|
|
8
|
-
field:
|
|
9
|
-
cardinality: '0-N' | '1-N';
|
|
12
|
+
target: string;
|
|
13
|
+
field: string;
|
|
14
|
+
cardinality: '0-1' | '1-1' | '0-N' | '1-N';
|
|
10
15
|
meta?: ExpressionMeta;
|
|
11
16
|
}
|
|
12
|
-
|
|
13
|
-
kind: 'direct';
|
|
14
|
-
target: TARGET;
|
|
15
|
-
field: SingleReferenceField<ExpandAlias<ENTITIES, ALIASES, SELF>, ExpandAlias<ENTITIES, ALIASES, TARGET>, never>;
|
|
16
|
-
cardinality: '1-1';
|
|
17
|
-
meta?: ExpressionMeta;
|
|
18
|
-
}
|
|
19
|
-
interface DirectSingle0Relation<ENTITIES extends DomainEntity<string>, ALIASES extends Record<string, ENTITIES>, SELF extends TypeOrAlias<ENTITIES, ALIASES>, TARGET extends TypeOrAlias<ENTITIES, ALIASES>> {
|
|
20
|
-
kind: 'direct';
|
|
21
|
-
target: TARGET;
|
|
22
|
-
field: SingleReferenceField<ExpandAlias<ENTITIES, ALIASES, SELF>, ExpandAlias<ENTITIES, ALIASES, TARGET>, null>;
|
|
23
|
-
cardinality: '0-1';
|
|
24
|
-
meta?: ExpressionMeta;
|
|
25
|
-
}
|
|
26
|
-
export type DirectRelation<ENTITIES extends DomainEntity<string>, ALIASES extends Record<string, ENTITIES>, SELF extends TypeOrAlias<ENTITIES, ALIASES>, TARGET extends TypeOrAlias<ENTITIES, ALIASES>> = DirectArrayRelation<ENTITIES, ALIASES, SELF, TARGET> | DirectSingle1Relation<ENTITIES, ALIASES, SELF, TARGET> | DirectSingle0Relation<ENTITIES, ALIASES, SELF, TARGET>;
|
|
27
|
-
export declare const directRelation: RelationImplementation<'direct'>;
|
|
28
|
-
export {};
|
|
17
|
+
export declare const directRelation: (relation: DirectRelation) => (selfId: DomainEntityId<string>, state: DomainState<DomainEntity<string>>, domain: AnyDomain) => Array<DomainEntityId<string>>;
|
|
@@ -1,71 +1,17 @@
|
|
|
1
1
|
import type { ExpressionMeta } from '../expression/index.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type AnyAliasMap, type DomainEntity, type DomainEntityId } from '../model/index.js';
|
|
3
3
|
import type { DomainState } from '../state/index.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
cardinality: '0-1';
|
|
10
|
-
meta?: ExpressionMeta;
|
|
11
|
-
}
|
|
12
|
-
interface IndirectNonNullableSingle0Relation<ENTITIES extends DomainEntity<string>, ALIASES extends Record<string, ENTITIES>, SELF extends TypeOrAlias<ENTITIES, ALIASES>, TARGET extends TypeOrAlias<ENTITIES, ALIASES>> {
|
|
13
|
-
kind: 'indirect';
|
|
14
|
-
target: TARGET;
|
|
15
|
-
field: SingleReferenceField<ExpandAlias<ENTITIES, ALIASES, TARGET>, ExpandAlias<ENTITIES, ALIASES, SELF>, never>;
|
|
16
|
-
cardinality: '0-1';
|
|
17
|
-
meta?: ExpressionMeta;
|
|
18
|
-
}
|
|
19
|
-
interface IndirectNullableSingle1Relation<ENTITIES extends DomainEntity<string>, ALIASES extends Record<string, ENTITIES>, SELF extends TypeOrAlias<ENTITIES, ALIASES>, TARGET extends TypeOrAlias<ENTITIES, ALIASES>> {
|
|
20
|
-
kind: 'indirect';
|
|
21
|
-
target: TARGET;
|
|
22
|
-
field: SingleReferenceField<ExpandAlias<ENTITIES, ALIASES, TARGET>, ExpandAlias<ENTITIES, ALIASES, SELF>, null>;
|
|
23
|
-
cardinality: '1-1';
|
|
24
|
-
meta?: ExpressionMeta;
|
|
25
|
-
}
|
|
26
|
-
interface IndirectNonNullableSingle1Relation<ENTITIES extends DomainEntity<string>, ALIASES extends Record<string, ENTITIES>, SELF extends TypeOrAlias<ENTITIES, ALIASES>, TARGET extends TypeOrAlias<ENTITIES, ALIASES>> {
|
|
27
|
-
kind: 'indirect';
|
|
28
|
-
target: TARGET;
|
|
29
|
-
field: SingleReferenceField<ExpandAlias<ENTITIES, ALIASES, TARGET>, ExpandAlias<ENTITIES, ALIASES, SELF>, never>;
|
|
30
|
-
cardinality: '1-1';
|
|
31
|
-
meta?: ExpressionMeta;
|
|
32
|
-
}
|
|
33
|
-
interface IndirectSingleNRelation<ENTITIES extends DomainEntity<string>, ALIASES extends Record<string, ENTITIES>, SELF extends TypeOrAlias<ENTITIES, ALIASES>, TARGET extends TypeOrAlias<ENTITIES, ALIASES>> {
|
|
34
|
-
kind: 'indirect';
|
|
35
|
-
target: TARGET;
|
|
36
|
-
field: SingleReferenceField<ExpandAlias<ENTITIES, ALIASES, TARGET>, ExpandAlias<ENTITIES, ALIASES, SELF>, never>;
|
|
37
|
-
cardinality: '0-N' | '1-N';
|
|
38
|
-
meta?: ExpressionMeta;
|
|
39
|
-
}
|
|
40
|
-
interface IndirectNullableSingleNRelation<ENTITIES extends DomainEntity<string>, ALIASES extends Record<string, ENTITIES>, SELF extends TypeOrAlias<ENTITIES, ALIASES>, TARGET extends TypeOrAlias<ENTITIES, ALIASES>> {
|
|
41
|
-
kind: 'indirect';
|
|
42
|
-
target: TARGET;
|
|
43
|
-
field: SingleReferenceField<ExpandAlias<ENTITIES, ALIASES, TARGET>, ExpandAlias<ENTITIES, ALIASES, SELF>, null>;
|
|
44
|
-
cardinality: '0-N' | '1-N';
|
|
45
|
-
meta?: ExpressionMeta;
|
|
46
|
-
}
|
|
47
|
-
interface IndirectArray0Relation<ENTITIES extends DomainEntity<string>, ALIASES extends Record<string, ENTITIES>, SELF extends TypeOrAlias<ENTITIES, ALIASES>, TARGET extends TypeOrAlias<ENTITIES, ALIASES>> {
|
|
48
|
-
kind: 'indirect';
|
|
49
|
-
target: TARGET;
|
|
50
|
-
field: ArrayReferenceField<ExpandAlias<ENTITIES, ALIASES, TARGET>, ExpandAlias<ENTITIES, ALIASES, SELF>>;
|
|
51
|
-
cardinality: '0-1';
|
|
52
|
-
meta?: ExpressionMeta;
|
|
53
|
-
}
|
|
54
|
-
interface IndirectArray1Relation<ENTITIES extends DomainEntity<string>, ALIASES extends Record<string, ENTITIES>, SELF extends TypeOrAlias<ENTITIES, ALIASES>, TARGET extends TypeOrAlias<ENTITIES, ALIASES>> {
|
|
55
|
-
kind: 'indirect';
|
|
56
|
-
target: TARGET;
|
|
57
|
-
field: ArrayReferenceField<ExpandAlias<ENTITIES, ALIASES, TARGET>, ExpandAlias<ENTITIES, ALIASES, SELF>>;
|
|
58
|
-
cardinality: '1-1';
|
|
59
|
-
meta?: ExpressionMeta;
|
|
60
|
-
}
|
|
61
|
-
interface IndirectArrayNRelation<ENTITIES extends DomainEntity<string>, ALIASES extends Record<string, ENTITIES>, SELF extends TypeOrAlias<ENTITIES, ALIASES>, TARGET extends TypeOrAlias<ENTITIES, ALIASES>> {
|
|
4
|
+
/**
|
|
5
|
+
* A relation whose related entities are the ones that reference the entity in their `field`. The
|
|
6
|
+
* application-spec parser checks that `field` is a reference field of the target that points back.
|
|
7
|
+
*/
|
|
8
|
+
export interface IndirectRelation {
|
|
62
9
|
kind: 'indirect';
|
|
63
|
-
target:
|
|
64
|
-
field:
|
|
65
|
-
cardinality: '0-N' | '1-N';
|
|
10
|
+
target: string;
|
|
11
|
+
field: string;
|
|
12
|
+
cardinality: '0-1' | '1-1' | '0-N' | '1-N';
|
|
66
13
|
meta?: ExpressionMeta;
|
|
67
14
|
}
|
|
68
|
-
export type IndirectRelation<ENTITIES extends DomainEntity<string>, ALIASES extends Record<string, ENTITIES>, SELF extends TypeOrAlias<ENTITIES, ALIASES>, TARGET extends TypeOrAlias<ENTITIES, ALIASES>> = IndirectArray1Relation<ENTITIES, ALIASES, SELF, TARGET> | IndirectArray0Relation<ENTITIES, ALIASES, SELF, TARGET> | IndirectArrayNRelation<ENTITIES, ALIASES, SELF, TARGET> | IndirectNullableSingle0Relation<ENTITIES, ALIASES, SELF, TARGET> | IndirectNonNullableSingle0Relation<ENTITIES, ALIASES, SELF, TARGET> | IndirectNullableSingle1Relation<ENTITIES, ALIASES, SELF, TARGET> | IndirectNonNullableSingle1Relation<ENTITIES, ALIASES, SELF, TARGET> | IndirectSingleNRelation<ENTITIES, ALIASES, SELF, TARGET> | IndirectNullableSingleNRelation<ENTITIES, ALIASES, SELF, TARGET>;
|
|
69
15
|
/**
|
|
70
16
|
* Resolves `indirect` relations from a per-state reverse-reference index. Relations reading the
|
|
71
17
|
* same field on the same set of target types share one index mapping each referenced id to the
|
|
@@ -73,8 +19,7 @@ export type IndirectRelation<ENTITIES extends DomainEntity<string>, ALIASES exte
|
|
|
73
19
|
* every index, and every later resolution on that state is a lookup. Registration closes once the
|
|
74
20
|
* first state has been indexed, so an index can never be missing from a state already walked.
|
|
75
21
|
*/
|
|
76
|
-
export declare const createIndirectRelation:
|
|
77
|
-
readonly target:
|
|
22
|
+
export declare const createIndirectRelation: (aliasMap: AnyAliasMap) => (relation: {
|
|
23
|
+
readonly target: string;
|
|
78
24
|
readonly field: string;
|
|
79
|
-
}) => (sourceId: DomainEntityId<string>, state: DomainState<
|
|
80
|
-
export {};
|
|
25
|
+
}) => (sourceId: DomainEntityId<string>, state: DomainState<DomainEntity<string>>) => DomainEntityId<string>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isArray as e}from"@salsita-ai/common/utils";import{expandAlias as t}from"../model/index.js";let r=e=>"string"==typeof e;export const createIndirectRelation=i=>{let n=new Map,o=new WeakMap,a=!1;return l=>{if(a)throw Error(`Cannot register indirect relation ${
|
|
1
|
+
import{isArray as e}from"@salsita-ai/common/utils";import{expandAlias as t}from"../model/index.js";let r=e=>"string"==typeof e;export const createIndirectRelation=i=>{let n=new Map,o=new WeakMap,a=!1;return l=>{if(a)throw Error(`Cannot register indirect relation ${l.target}#${l.field} after evaluation started. Create all relation expressions before evaluating the domain state.`);let s=new Set(t(i,l.target)),f=`${l.field}|${[...s].sort().join("|")}`;return n.set(f,{field:l.field,targetTypes:s}),(t,i)=>(t=>{let i=o.get(t);if(i)return i;a=!0;let l=new Map([...n.keys()].map(e=>[e,new Map]));for(let i of t.entities)for(let[t,{field:o,targetTypes:a}]of n){if(!a.has(i.type))continue;let n=i[o],s=e(n)?new Set(n.filter(r)):r(n)?[n]:[],f=l.get(t);for(let e of s){let t=f.get(e);t||(t=[],f.set(e,t)),t.push(i.id)}}return o.set(t,l),l})(i).get(f).get(t)??[]}};
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import type { AnonymousExpression } from '../expression/index.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type $DomainEntity, type AnyAliasMap, type DomainEntity } from '../model/index.js';
|
|
3
3
|
import { type AllOfTypeRelation } from './all-of-type-relation.js';
|
|
4
|
-
import type
|
|
4
|
+
import { type DirectRelation } from './direct-relation.js';
|
|
5
5
|
import { type IndirectRelation } from './indirect-relation.js';
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
/** A relation as a spec declares it: where the related entities are found and how many there may be. */
|
|
7
|
+
export type Relation = DirectRelation | AllOfTypeRelation | IndirectRelation;
|
|
8
|
+
type RelatedEntity = $DomainEntity<DomainEntity<string>>;
|
|
9
|
+
/**
|
|
10
|
+
* The expression of a relation as a domain takes it. The entity and data types are erased, so that
|
|
11
|
+
* the domain of any project accepts it: an expression typed with the base entity type is not
|
|
12
|
+
* assignable to one typed with a project's entities. The type a project reads from a relation is
|
|
13
|
+
* the one its generated model declares for the relation's property.
|
|
14
|
+
*/
|
|
15
|
+
type RelationExpression = AnonymousExpression<any, any, any, any, any, any, RelatedEntity | null | ReadonlyArray<RelatedEntity>>;
|
|
16
|
+
/**
|
|
17
|
+
* Makes the expression of one relation: it collects the related entities of an entity and returns
|
|
18
|
+
* them as the cardinality says, one entity, one entity or `null`, or an array.
|
|
19
|
+
*/
|
|
20
|
+
export type RelationFactory = (relation: Relation) => RelationExpression;
|
|
21
|
+
export declare const createRelationFactory: (aliasMap: AnyAliasMap) => RelationFactory;
|
|
22
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{match as t}from"ts-pattern";import{
|
|
1
|
+
import{match as t}from"ts-pattern";import{expandAlias as e}from"../model/index.js";import{createAllOfTypeRelation as r}from"./all-of-type-relation.js";import{directRelation as i}from"./direct-relation.js";import{createIndirectRelation as n}from"./indirect-relation.js";export const createRelationFactory=o=>{let a=r(o),l=n(o);return r=>{let n=t(r).with({kind:"direct"},t=>i(t)).with({kind:"indirect"},t=>l(t)).with({kind:"allOfType"},t=>a(t)).exhaustive(),d=t(r).with({cardinality:"0-1"},()=>t=>{if(t.length>1)throw Error(`Expected at most one entity, but got ${t.length}`);return t[0]??null}).with({cardinality:"1-1"},()=>t=>{let[e,...r]=t;if(void 0===e||r.length>0)throw Error(`Expected exactly one entity, but got ${t.length}`);return e}).with({cardinality:"0-N"},()=>t=>t).with({cardinality:"1-N"},()=>t=>{if(0===t.length)throw Error("Expected at least one entity, but got none");return t}).exhaustive(),c=e(o,r.target);return{meta:{alwaysEvaluate:!0,...r.meta},evaluate:(t,e,i)=>{let o=n(t,e,i.domain),a=i.domain.get$Entities(o,e);if(!a.every(t=>c.includes(t.type))){let t=a.map(t=>t.type).filter(t=>!c.includes(t));throw Error(`Expected ${r.target} entities, but got ${t.join(", ")}`)}return d(a)}}}};
|
|
@@ -48,51 +48,20 @@ export type MigrateFunction<LATEST_ENTITIES extends DomainEntity<string>> = (ver
|
|
|
48
48
|
state: ReadonlyArray<DomainEntity<string>>;
|
|
49
49
|
}, options: MigrateFunctionOptions) => readonly LATEST_ENTITIES[];
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* Creates the function that migrates a state of any registered version of the model to the latest
|
|
52
|
+
* one. The state is validated against the reflections of its own version, and again after every
|
|
53
|
+
* migration against the reflections of the version that migration yields.
|
|
54
|
+
*
|
|
55
|
+
* @param modelVersions the entity reflections of every version of the model, keyed by version
|
|
56
|
+
* @param latestVersion the version the state is migrated to
|
|
57
|
+
* @param migrations the migration to each version above the first: the one under key `n` takes a
|
|
58
|
+
* state of version `n - 1` to version `n`
|
|
52
59
|
* @example
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
1: v1Reflections,
|
|
59
|
-
2: v2Reflections,
|
|
60
|
-
3: v3Reflections,
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
// the latest version of the model
|
|
64
|
-
.to(2)
|
|
65
|
-
|
|
66
|
-
// the migrations between the versions
|
|
67
|
-
.using({
|
|
68
|
-
2: migrationToV2,
|
|
69
|
-
3: migrationToV3,
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
.build()
|
|
73
|
-
|
|
60
|
+
* export const migrate = createMigrateFunction(
|
|
61
|
+
* { 1: v1Reflections, 2: v2Reflections, 3: v3Reflections },
|
|
62
|
+
* 3,
|
|
63
|
+
* { 2: migrationToV2, 3: migrationToV3 }
|
|
64
|
+
* )
|
|
74
65
|
*/
|
|
75
|
-
export declare const
|
|
76
|
-
/**
|
|
77
|
-
* Provide the entity reflections for all versions of the model.
|
|
78
|
-
*/
|
|
79
|
-
fromVersions: <VERSIONS extends Record<number, EntityReflections<any>>>(modelVersions: VERSIONS) => {
|
|
80
|
-
/**
|
|
81
|
-
* Specify the latest version of the model. I.e. the version to which the state will be migrated.
|
|
82
|
-
*/
|
|
83
|
-
to: <LATEST extends keyof VERSIONS & number>(latestVersion: LATEST) => {
|
|
84
|
-
/**
|
|
85
|
-
* Provide the migrations between each consecutive version of the model.
|
|
86
|
-
*
|
|
87
|
-
* Migration with index `i` should migrate the state from version `i - 1` to version `i`.
|
|
88
|
-
*/
|
|
89
|
-
using: (migrations: Record<Exclude<keyof VERSIONS, 1>, Migration<any, any>>) => {
|
|
90
|
-
/**
|
|
91
|
-
* Finally, build the migration function.
|
|
92
|
-
*/
|
|
93
|
-
build: () => MigrateFunction<EntitiesOfReflections<VERSIONS[LATEST]>>;
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
};
|
|
66
|
+
export declare const createMigrateFunction: <VERSIONS extends Record<number, EntityReflections<any>>, LATEST extends keyof VERSIONS & number>(modelVersions: VERSIONS, latestVersion: LATEST, migrations: Record<Exclude<keyof VERSIONS, 1>, Migration<any, any>>) => MigrateFunction<EntitiesOfReflections<VERSIONS[LATEST]>>;
|
|
98
67
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from"lodash-es/pick.js";export class StateMigrationError extends Error{constructor(t){super(t),this.name="StateMigrationError"}}export const isStateMigrationError=t=>t instanceof StateMigrationError;let e=(e,r,i,o)=>e.map(e=>{let n=r[e.type];if(!n)throw new StateMigrationError(`Unknown entity type "${e.type}". The state contains an entity whose type is not registered in the domain model for this version. Fix: register the entity type in the domain spec, or remove/migrate the stale entity from the preset or configuration data.`);if(n._meta.validator(e))return e;if(i){let r=t(e,Object.keys(n._meta.schema.properties));if(n._meta.validator(e))return o?.error(`Entity ${e.type}#${e.id} had extra fields that had to be trimmed: ${Object.keys(r)}`),r}throw new StateMigrationError(`Entity "${e.type}#${e.id}" does not match its schema in the current domain model. Validation errors: ${JSON.stringify(n._meta.validator.errors)}. Fix: update the entity data to match the schema, add a migration that transforms older data into the current shape, or re-register the schema if it changed.`)});export const createMigrateFunction=(t,r,i)=>(o,{logger:n,trimExtraProperties:a})=>{let s=t[o.version];if(!s)throw new StateMigrationError(`Unknown model version ${o.version}. The state declares a version that has no registered reflections. Fix: register the version in the model versions passed to createMigrateFunction, or correct the version stored on the state.`);let d=e(o.state,s,a,n);o.version===r?n?.debug(`State is already in the latest version ${r}`):n?.debug(`Migrating state from version ${o.version} to ${r}`);for(let s=o.version;s<r;s++){n?.debug(`Applying intermediate migration to version ${s+1}`);let h=t[s+1];if(!h)throw new StateMigrationError(`Unknown model version ${s+1} while migrating from ${o.version} to ${r}. An intermediate version has no registered reflections. Fix: register version ${s+1} in the model versions passed to createMigrateFunction.`);let g=i[s+1];if(!g)throw new StateMigrationError(`Missing migration from version ${s} to ${s+1}. No migration is registered for this step while migrating to ${r}. Fix: add the migration under key ${s+1} in the migrations passed to createMigrateFunction.`);d=e(g(d),h,a,n)}return d};
|
|
@@ -6,4 +6,4 @@ export interface DomainState<ENTITIES extends DomainEntity<string>> {
|
|
|
6
6
|
readonly ephemeralRecords: ReadonlyArray<ComponentSnapshot<SystemComponentTypeConstraint>>;
|
|
7
7
|
}
|
|
8
8
|
export type DomainStateFactory<ENTITIES extends DomainEntity<string>> = (entities: readonly ENTITIES[], ephemeralRecords: ReadonlyArray<ComponentSnapshot<SystemComponentTypeConstraint>>, rootEntityType: ENTITIES['type']) => DomainState<ENTITIES>;
|
|
9
|
-
export declare const createInitialDomainState: <ENTITIES extends DomainEntity<string
|
|
9
|
+
export declare const createInitialDomainState: <ENTITIES extends DomainEntity<string>>(entities: readonly ENTITIES[], rootEntityType: ENTITIES['type']) => DomainState<ENTITIES>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ExtendedJsonSchema } from '@salsita-ai/common/utils';
|
|
2
2
|
import { type $DomainEntity, type $DomainEntityReflection, type ActionDefinition, type AliasMap, type AliasedExpressions, type AnyActionImplementations, type DomainEntity, DomainFactory, type EntityByType, type EntityReflections, type MigrateFunction, type SchemaOfObject } from './core/index.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type ProjectModule } from './domain-runtime/index.js';
|
|
4
4
|
type $EntityReflections<ENTITIES extends DomainEntity<string>> = {
|
|
5
5
|
[TYPE in ENTITIES['type']]: $DomainEntityReflection<$DomainEntity<EntityByType<ENTITIES, TYPE>>>;
|
|
6
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DomainFactory as t,
|
|
1
|
+
import{DomainFactory as t,createMigrateFunction as i,expandAlias as e}from"./core/index.js";import{resolveActionModules as s,resolveExpressionModules as n}from"./domain-runtime/index.js";import{withProfilerLabel as a}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,n,a,o,h,l,m,r,d,p,c){this.entities=t,this.aliasMap=i,this.$entityReflections=e,this.allowedRootEntityTypes=s,this.implemented=n,this.modelVersion=a,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,e,s,n,a,o,h,l,m,r){let d=i({1:t},1,{});return new DomainBuilder(t,e,s,n,{},a,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(t){let i={...this.implemented};return Object.entries(t).forEach(([t,s])=>{e(this.aliasMap,t).forEach(e=>{let n={...i[e]};i[e]=n,Object.entries(s).forEach(([i,s])=>{let o=n[i];if(o)throw Error(`Duplicate expression ${e}.${i}: The expression is defined on both ${t} and ${o.origin.typeOrAlias}, which would lead to ambiguous usage. Please ensure that expressions are only defined once.`);n[i]={...s,evaluate:a(`${e}_${i}`,s.evaluate),origin:{name:i,typeOrAlias:t}}})})}),new DomainBuilder(this.entities,this.aliasMap,this.$entityReflections,this.allowedRootEntityTypes,i,this.modelVersion,this.publishedData,this.sessionData,this.frontendData,this.backendData,this.migrate,this.isAdminDomain,this.actions,this.actionImplementations)}withExpressionModules(t){return n(t,this.aliasMap).reduce((t,i)=>t.withExpressions(i.expressions),this)}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)}withActionModules(t){return this.withActionImplementations(s(t))}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 e=this.implemented,s=this.migrate??i({1:this.entities},1,{});return new t({aliasMap:this.aliasMap,entityReflections:this.entities,$entityReflections:this.$entityReflections,expressions:e,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})}}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AccessLevel } from '@salsita-ai/contracts/api';
|
|
1
2
|
import type { OverridesSelectorState, OverridesSelectors } from '../overrides/index.js';
|
|
2
3
|
import type { AccessService, ApplicationAccessInfo } from './types.js';
|
|
3
4
|
/**
|
|
@@ -17,24 +18,28 @@ export declare const requireAccessService: (applicationName: 'configurator' | 'a
|
|
|
17
18
|
export declare const createAccessInfoSelectors: (context: Context) => {
|
|
18
19
|
selectConfiguratorRawAccessInfo: import("@salsita-ai/common/utils").Selector<AccessSelectorState, {
|
|
19
20
|
raw: string;
|
|
21
|
+
access: AccessLevel;
|
|
20
22
|
viewMode: boolean;
|
|
21
23
|
revisionId: string | undefined;
|
|
22
24
|
configurationId: string;
|
|
23
25
|
} | null>;
|
|
24
26
|
selectAdminRawAccessInfo: import("@salsita-ai/common/utils").Selector<AccessSelectorState, {
|
|
25
27
|
raw: string;
|
|
28
|
+
access: AccessLevel;
|
|
26
29
|
viewMode: boolean;
|
|
27
30
|
revisionId: string | undefined;
|
|
28
31
|
configurationId: string;
|
|
29
32
|
} | null>;
|
|
30
33
|
selectConfiguratorAccessInfo: import("@salsita-ai/common/utils").Selector<AccessSelectorState, {
|
|
31
34
|
raw: string;
|
|
35
|
+
access: AccessLevel;
|
|
32
36
|
viewMode: boolean;
|
|
33
37
|
revisionId: string | undefined;
|
|
34
38
|
configurationId: string;
|
|
35
39
|
}>;
|
|
36
40
|
selectAdminAccessInfo: import("@salsita-ai/common/utils").Selector<AccessSelectorState, {
|
|
37
41
|
raw: string;
|
|
42
|
+
access: AccessLevel;
|
|
38
43
|
viewMode: boolean;
|
|
39
44
|
revisionId: string | undefined;
|
|
40
45
|
configurationId: string;
|
|
@@ -47,24 +52,28 @@ export declare const createAccessInfoSelectors: (context: Context) => {
|
|
|
47
52
|
selectAdminConfigurationId: import("@salsita-ai/common/utils").Selector<AccessSelectorState, string>;
|
|
48
53
|
getConfiguratorRawAccessInfo: () => {
|
|
49
54
|
raw: string;
|
|
55
|
+
access: AccessLevel;
|
|
50
56
|
viewMode: boolean;
|
|
51
57
|
revisionId: string | undefined;
|
|
52
58
|
configurationId: string;
|
|
53
59
|
} | null;
|
|
54
60
|
getAdminRawAccessInfo: () => {
|
|
55
61
|
raw: string;
|
|
62
|
+
access: AccessLevel;
|
|
56
63
|
viewMode: boolean;
|
|
57
64
|
revisionId: string | undefined;
|
|
58
65
|
configurationId: string;
|
|
59
66
|
} | null;
|
|
60
67
|
getConfiguratorAccessInfo: () => {
|
|
61
68
|
raw: string;
|
|
69
|
+
access: AccessLevel;
|
|
62
70
|
viewMode: boolean;
|
|
63
71
|
revisionId: string | undefined;
|
|
64
72
|
configurationId: string;
|
|
65
73
|
};
|
|
66
74
|
getAdminAccessInfo: () => {
|
|
67
75
|
raw: string;
|
|
76
|
+
access: AccessLevel;
|
|
68
77
|
viewMode: boolean;
|
|
69
78
|
revisionId: string | undefined;
|
|
70
79
|
configurationId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSelector as e}from"@salsita-ai/common/utils";let
|
|
1
|
+
import{createSelector as e}from"@salsita-ai/common/utils";import{AccessLevel as c}from"@salsita-ai/contracts/api";let i=e=>Error(`Cannot read ${e} access info because valid access is not loaded. Access info is written by the ${e} lifecycle after token validation. Move this read into the loaded ${e} lifecycle.`),n=e=>({accessInfo:e,configurationId:e.configurationId});export const requireAccessService=(e,c)=>{if(null===c)throw i(e);return c};export const createAccessInfoSelectors=o=>{let{getState:r,overridesSelectors:s}=o,t=e.withTypes(),a=t([t.leaf(e=>e.access.configuratorAccessInfo)],e=>e),l=t([t.leaf(e=>e.access.adminAccessInfo)],e=>e),f=t([a],e=>{if(null===e)throw i("configurator");return e}),u=t([l],e=>{if(null===e)throw i("admin");return e}),d=t([a,s.selectAccessService,s.selectAccessLevel],(e,i,o)=>{var r;let s,t,a=i??(null===e?null:n(e));return null===a||null===o?a:(r={configurationId:a.configurationId,...void 0===a.accessInfo.revisionId?{}:{revisionId:a.accessInfo.revisionId},access:o},s=e=>btoa(JSON.stringify(e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),t=`${s({alg:"none",typ:"JWT"})}.${s(r)}.`,{configurationId:a.configurationId,accessInfo:{raw:t,access:"owner"===o?c.Owner:"read-revision"===o?c.ReadRevision:c.Read,viewMode:"read-revision"===o,revisionId:a.accessInfo.revisionId,configurationId:a.configurationId}})}),g=t([l,s.selectAccessService],(e,c)=>null!==c?c:null===e?null:n(e)),I=t([d],e=>requireAccessService("configurator",e)),v=t([g],e=>requireAccessService("admin",e)),A=t([I],e=>e.configurationId),m=t([v],e=>e.configurationId);return{selectConfiguratorRawAccessInfo:a,selectAdminRawAccessInfo:l,selectConfiguratorAccessInfo:f,selectAdminAccessInfo:u,selectConfiguratorRawAccessService:d,selectAdminRawAccessService:g,selectConfiguratorAccessService:I,selectAdminAccessService:v,selectConfiguratorConfigurationId:A,selectAdminConfigurationId:m,getConfiguratorRawAccessInfo:()=>a(r()),getAdminRawAccessInfo:()=>l(r()),getConfiguratorAccessInfo:()=>f(r()),getAdminAccessInfo:()=>u(r()),getConfiguratorRawAccessService:()=>d(r()),getAdminRawAccessService:()=>g(r()),getConfiguratorAccessService:()=>I(r()),getAdminAccessService:()=>v(r()),getConfiguratorConfigurationId:()=>A(r()),getAdminConfigurationId:()=>m(r())}};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { AccessLevel } from '@salsita-ai/contracts/api';
|
|
1
2
|
export declare const decodeAccessInfo: (accessToken: string, configurationId: string) => {
|
|
2
3
|
raw: string;
|
|
4
|
+
access: AccessLevel;
|
|
3
5
|
viewMode: boolean;
|
|
4
6
|
revisionId: string | undefined;
|
|
5
7
|
configurationId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jwtDecode as
|
|
1
|
+
import{jwtDecode as e}from"jwt-decode";import{AccessLevel as o}from"@salsita-ai/contracts/api";export const decodeAccessInfo=(i,r)=>{try{let c=e(i),n=c.exp;if(void 0!==n&&n<Date.now()/1e3||c.configurationId!==r)return null;return{raw:i,access:c.access,viewMode:c.access===o.ReadRevision,revisionId:c.revisionId,configurationId:c.configurationId}}catch(e){return null}};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AnyDomain, type AnyDomainFactory, type DomainComponentOptic, type
|
|
1
|
+
import { type AnyDomain, type AnyDomainFactory, type DomainComponentOptic, type DomainMode, type SystemComponentTypeConstraint } from '../../core/index.js';
|
|
2
2
|
import { type AnyActionSystem, type AnyDimensionSystem, type AnyDomainContextSystems, type AnyNavigationSystem, type AnyRecipeCookerSystem, type AnyStoreSystem, type AnyUndoSystem } from '../../domain-context/index.js';
|
|
3
3
|
import { type AnyBlenderProjections, type AnyCollisionProjections, type AnyCompositionProjections, type AnyConstraintProjections, type AnyPositionProjections, type AnyProjectedEntitiesProjections, type AnySnappingProjections, type AnyValidationProjections } from '../../projections/index.js';
|
|
4
4
|
import { type AnySketchingProjections } from '../../sketching/sketching-projections.js';
|
|
@@ -15,17 +15,18 @@ import { type AnyComponentReader } from './component-reader.js';
|
|
|
15
15
|
import { DomainContext } from './domain-context.js';
|
|
16
16
|
import type { AnyExpressionContext } from './expression-context.js';
|
|
17
17
|
import type { ApplicationDomainContextState, DomainApplicationType, DomainContextInitializationContext, DomainContextInitializationIdentity, DomainContextInitializationState, InitializableSystem, SchemaCoherence } from './types.js';
|
|
18
|
-
|
|
18
|
+
/** A component optic of any project, for any component type. */
|
|
19
|
+
type ComponentOptic = DomainComponentOptic<any, any, any, any, any, any, SystemComponentTypeConstraint>;
|
|
19
20
|
/**
|
|
20
21
|
* Lookup indexes derived from the current component optics. The component reader and the
|
|
21
22
|
* component write systems share this representation so a runtime optic update is observed
|
|
22
23
|
* consistently across reads and writes.
|
|
23
24
|
*/
|
|
24
|
-
export interface ComponentReaderIndexes
|
|
25
|
-
readonly opticMap: ReadonlyMap<
|
|
26
|
-
readonly allComponentTypes: ReadonlyMap<
|
|
27
|
-
readonly allComponentInstanceNames: ReadonlyMap<
|
|
28
|
-
readonly dynamicInstanceNames: ReadonlyMap<
|
|
25
|
+
export interface ComponentReaderIndexes {
|
|
26
|
+
readonly opticMap: ReadonlyMap<string, ReadonlyMap<SystemComponentTypeConstraint, ReadonlyMap<string, ComponentOptic>>>;
|
|
27
|
+
readonly allComponentTypes: ReadonlyMap<string, ReadonlySet<SystemComponentTypeConstraint>>;
|
|
28
|
+
readonly allComponentInstanceNames: ReadonlyMap<string, ReadonlyMap<SystemComponentTypeConstraint, ReadonlySet<string>>>;
|
|
29
|
+
readonly dynamicInstanceNames: ReadonlyMap<string, ReadonlyMap<SystemComponentTypeConstraint, readonly string[]>>;
|
|
29
30
|
}
|
|
30
31
|
interface Context {
|
|
31
32
|
readonly applicationType: DomainApplicationType;
|
|
@@ -69,7 +70,7 @@ export declare const createDomainContextSelectors: (context: Context) => {
|
|
|
69
70
|
selectAliasMap: import("@salsita-ai/common/utils").Selector<DomainContextSelectorState, import("../../index.js").AnyAliasMap>;
|
|
70
71
|
selectAllowedRootEntityTypes: import("@salsita-ai/common/utils").Selector<DomainContextSelectorState, import("../../index.js").AnyAllowedRootEntityTypes>;
|
|
71
72
|
selectEntityReflections: import("@salsita-ai/common/utils").Selector<DomainContextSelectorState, import("../../index.js").AnyEntityReflections>;
|
|
72
|
-
selectMigrate: import("@salsita-ai/common/utils").Selector<DomainContextSelectorState, import("../../index.js").MigrateFunction<DomainEntity<string>>>;
|
|
73
|
+
selectMigrate: import("@salsita-ai/common/utils").Selector<DomainContextSelectorState, import("../../index.js").MigrateFunction<import("../../index.js").DomainEntity<string>>>;
|
|
73
74
|
selectLatestMode: import("@salsita-ai/common/utils").Selector<DomainContextSelectorState, DomainMode>;
|
|
74
75
|
selectLatestConfigurationId: import("@salsita-ai/common/utils").Selector<DomainContextSelectorState, string | null>;
|
|
75
76
|
selectLatestSessionContext: import("@salsita-ai/common/utils").Selector<DomainContextSelectorState, DomainSessionContext> | import("@salsita-ai/common/utils").Selector<SessionContextSelectorState, DomainSessionContext | null>;
|
|
@@ -81,9 +82,9 @@ export declare const createDomainContextSelectors: (context: Context) => {
|
|
|
81
82
|
selectIsViewMode: import("@salsita-ai/common/utils").Selector<DomainContextSelectorState, boolean>;
|
|
82
83
|
selectInitializationState: import("@salsita-ai/common/utils").Selector<DomainContextSelectorState, DomainContextInitializationState>;
|
|
83
84
|
selectComponentOptics: import("@salsita-ai/common/utils").Selector<DomainContextSelectorState, readonly import("../../index.js").AnyDomainComponentOptic[]>;
|
|
84
|
-
selectComponentReaderIndexes: import("@salsita-ai/common/utils").Selector<DomainContextSelectorState, ComponentReaderIndexes
|
|
85
|
+
selectComponentReaderIndexes: import("@salsita-ai/common/utils").Selector<DomainContextSelectorState, ComponentReaderIndexes>;
|
|
85
86
|
selectStoreRuntimeDependencies: import("@salsita-ai/common/utils").Selector<DomainContextSelectorState, {
|
|
86
|
-
componentReaderIndexes: ComponentReaderIndexes
|
|
87
|
+
componentReaderIndexes: ComponentReaderIndexes;
|
|
87
88
|
domainExpressions: import("../../index.js").AnyExpressions;
|
|
88
89
|
allowedRootEntityTypes: import("../../index.js").AnyAllowedRootEntityTypes;
|
|
89
90
|
}>;
|
|
@@ -120,12 +121,12 @@ export declare const createDomainContextSelectors: (context: Context) => {
|
|
|
120
121
|
getAliasMap: () => import("../../index.js").AnyAliasMap;
|
|
121
122
|
getAllowedRootEntityTypes: () => import("../../index.js").AnyAllowedRootEntityTypes;
|
|
122
123
|
getEntityReflections: () => import("../../index.js").AnyEntityReflections;
|
|
123
|
-
getMigrate: () => import("../../index.js").MigrateFunction<DomainEntity<string>>;
|
|
124
|
+
getMigrate: () => import("../../index.js").MigrateFunction<import("../../index.js").DomainEntity<string>>;
|
|
124
125
|
getActiveMode: () => DomainMode;
|
|
125
126
|
getIsInitialized: () => boolean;
|
|
126
|
-
getComponentReaderIndexes: () => ComponentReaderIndexes
|
|
127
|
+
getComponentReaderIndexes: () => ComponentReaderIndexes;
|
|
127
128
|
getStoreRuntimeDependencies: () => {
|
|
128
|
-
componentReaderIndexes: ComponentReaderIndexes
|
|
129
|
+
componentReaderIndexes: ComponentReaderIndexes;
|
|
129
130
|
domainExpressions: import("../../index.js").AnyExpressions;
|
|
130
131
|
allowedRootEntityTypes: import("../../index.js").AnyAllowedRootEntityTypes;
|
|
131
132
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSelector as e}from"@salsita-ai/common/utils";import{Domain as t,createInitialDomainState as n}from"../../core/index.js";import{ActionSystem as o,DimensionSystem as i,NavigationSystem as a,RecipeCookerSystem as s,StoreSystem as r,UndoSystem as c}from"../../domain-context/index.js";import{BlenderProjections as l,CollisionProjections as m,CompositionProjections as d,ConstraintProjections as g,PositionProjections as f,ProjectedEntitiesProjections as u,SnappingProjections as p,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{prepareActionImplementations as S,prepareDomainExpressions as x}from"../spec/index.js";import{ComponentReader as C}from"./component-reader.js";import{DomainContext as D}from"./domain-context.js";let j=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:$,domainDataSelectors:k,sessionContextSelectors:N,domainServicesSelectors:z,environmentSelectors:L,getExtensionSystems:V}=e,B="configurator"===A?T.selectConfiguratorSpec:T.selectAdminSpec,F="configurator"===A?b.selectConfiguratorRawAccessService:b.selectAdminRawAccessService,W=j.leaf(e=>e.domainContext[A]),_=j([W],e=>e.initializationContext),q=j([_],e=>{if(null===e)throw Error(`Domain lifecycle context is not available for ${A}! Read it from an active domain lifecycle.`);return e}),O=j([W],e=>e.executionMode),U=j([W],e=>e.isInitialized),G=j([B],e=>e.factory),H=j([B],e=>e.expressions),J=j([B],e=>e.actions),K=j([B],e=>e.actionImplementations),Q=j([J,K],S),X=j([B],e=>e.$entityReflections),Y=j([H,X],(e,t)=>x({expressions:e,$entityReflections:t})),Z=j([B],e=>e.modelVersion),ee=j([B],e=>e.aliasMap),et=j([B],e=>e.allowedRootEntityTypes),en=j([B],e=>e.entityReflections),eo=j([B],e=>e.migrate),ei=j([O,$.selectReadonly,F],(e,t,n)=>"finalize"===e?"finalize":h(A,n).accessInfo.viewMode||t?"read":"owner"),ea=j([F],e=>e?.configurationId??null),es="configurator"===A?N.selectSessionContext:j([],()=>P),er=j([es],e=>e?.role??null),ec=j([es],e=>e?.data??null),el=j([j.leaf(e=>e.loadedData)],e=>"configurator"===A?e.configuratorLoadedData:e.adminLoadedData),em=j([el],e=>e?.schemaIdentity??null),ed=j([el,G],(e,t)=>{if(null===e)return"coherent";let n=e.schemaIdentity;return void 0===n?"missing-stamp":n===t?"coherent":"schema-mismatch"}),eg=j([ea,er,ec,em,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=j([F,$.selectReadonly],(e,t)=>e?.accessInfo.viewMode===!0||t),eu=j([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}}),ep=j([B],e=>e.componentOptics),ey=j([ep],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=j([ey,Y,et],(e,t,n)=>({componentReaderIndexes:e,domainExpressions:t,allowedRootEntityTypes:n})),eh=j([B],e=>e.navigationStates),eS=j([B],e=>e.viewStates),ex="configurator"===A?j([T.selectConfiguratorSpec],e=>e.toolStates):j([],()=>v),eC="configurator"===A?j([T.selectConfiguratorSpec],e=>e.exportStates):j([],()=>v),eD="configurator"===A?j([T.selectConfiguratorSpec],e=>e.createTransformers):j([],()=>void 0),ej=j([el],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=j([ej,G],(e,t)=>n(t.validateAndMigrateState(e.initialEntities,e.modelVersion),e.rootEntityType)),eI="configurator"===A?k.selectConfiguratorFrontendData:k.selectAdminFrontendData,eP="configurator"===A?k.selectConfiguratorBackendData:k.selectAdminBackendData,eM="configurator"===A?k.selectConfiguratorPublishedData:k.selectAdminPublishedData,eA="configurator"===A?j([N.selectSessionContext],e=>M(e).role):j([],()=>"admin"),eR="configurator"===A?j([N.selectSessionContext],e=>M(e).data):j([],()=>I),eE=j([ea,ei,eA,eR,ej],(e,t,n,o,i)=>({configurationId:e,mode:t,role:n,schemaIdentity:i.schemaIdentity,sessionData:o})),eT=j([q],e=>e.mode),eb=j([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}),e$=j([q],e=>e.role),ek=j([q],e=>e.sessionData),eN=j([eT,e$,ek,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:em,selectSchemaCoherence:ed,selectInitializationIdentity:eg,selectIsViewMode:ef,selectInitializationState:eu,selectComponentOptics:ep,selectComponentReaderIndexes:ey,selectStoreRuntimeDependencies:ew,selectNavigationStates:eh,selectViewStates:eS,selectToolStates:ex,selectExportStates:eC,selectCreateTransformers:eD,selectLatestLoadedData:el,selectLoadedData:ej,selectInitialDomainState:ev,selectFrontendData:eI,selectBackendData:eP,selectPublishedData:eM,selectLatestRole:eA,selectLatestSessionData:eR,selectNextInitializationContext:eE,selectActiveMode:eT,selectActiveConfigurationId:eb,selectActiveRole:e$,selectActiveSessionData:ek,selectExpressionContext:eN,getInitializationContext:()=>_(R()),getInitializationState:()=>eu(R()),getNextInitializationContext:()=>eE(R()),getLatestLoadedData:()=>el(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:()=>eC(R()),getCreateTransformers:()=>eD(R()),getLoadedData:()=>ej(R()),getInitialDomainState:()=>ev(R()),getFrontendData:()=>eI(R()),getBackendData:()=>eP(R()),getPublishedData:()=>eM(R()),getActiveRole:()=>e$(R()),getActiveSessionData:()=>ek(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 t({selectors:ez}),eV=new C({selectors:ez}),eB=new d({selectors:ez}),eF=new i({selectors:ez}),eW=new y({selectors:ez}),e_=new w({selectors:ez}),eq=new f({selectors:ez}),eO=new m({selectors:ez}),eU=new p({selectors:ez}),eG=new g({selectors:ez}),eH=new u({selectors:ez}),eJ=new r({selectors:ez,domainServicesSelectors:z,environmentSelectors:L}),eK=new a({selectors:ez,domainServicesSelectors:z}),eQ=new c({selectors:ez}),eX=new s({selectors:ez}),eY=new o({selectors:ez}),eZ=new l({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 D({selectors:ez,actions:E,getExtensionSystems:V});return ez};
|
|
1
|
+
import{createSelector as e}from"@salsita-ai/common/utils";import{Domain as t,createInitialDomainState as n}from"../../core/index.js";import{ActionSystem as o,DimensionSystem as i,NavigationSystem as a,RecipeCookerSystem as s,StoreSystem as r,UndoSystem as c}from"../../domain-context/index.js";import{BlenderProjections as l,CollisionProjections as m,CompositionProjections as d,ConstraintProjections as g,PositionProjections as f,ProjectedEntitiesProjections as u,SnappingProjections as p,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{prepareActionImplementations as S,prepareDomainExpressions as x}from"../spec/index.js";import{ComponentReader as C}from"./component-reader.js";import{DomainContext as D}from"./domain-context.js";let j=e.withTypes(),I=[],v={},P={role:"admin",data:v},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:$,domainDataSelectors:k,sessionContextSelectors:N,domainServicesSelectors:z,environmentSelectors:L,getExtensionSystems:V}=e,B="configurator"===A?T.selectConfiguratorSpec:T.selectAdminSpec,F="configurator"===A?b.selectConfiguratorRawAccessService:b.selectAdminRawAccessService,W=j.leaf(e=>e.domainContext[A]),_=j([W],e=>e.initializationContext),q=j([_],e=>{if(null===e)throw Error(`Domain lifecycle context is not available for ${A}! Read it from an active domain lifecycle.`);return e}),O=j([W],e=>e.executionMode),U=j([W],e=>e.isInitialized),G=j([B],e=>e.factory),H=j([B],e=>e.expressions),J=j([B],e=>e.actions),K=j([B],e=>e.actionImplementations),Q=j([J,K],S),X=j([B],e=>e.$entityReflections),Y=j([H,X],(e,t)=>x({expressions:e,$entityReflections:t})),Z=j([B],e=>e.modelVersion),ee=j([B],e=>e.aliasMap),et=j([B],e=>e.allowedRootEntityTypes),en=j([B],e=>e.entityReflections),eo=j([B],e=>e.migrate),ei=j([O,$.selectReadonly,F],(e,t,n)=>"finalize"===e?"finalize":h(A,n).accessInfo.viewMode||t?"read":"owner"),ea=j([F],e=>e?.configurationId??null),es="configurator"===A?N.selectSessionContext:j([],()=>P),er=j([es],e=>e?.role??null),ec=j([es],e=>e?.data??null),el=j([j.leaf(e=>e.loadedData)],e=>"configurator"===A?e.configuratorLoadedData:e.adminLoadedData),em=j([el],e=>e?.schemaIdentity??null),ed=j([el,G],(e,t)=>{if(null===e)return"coherent";let n=e.schemaIdentity;return void 0===n?"missing-stamp":n===t?"coherent":"schema-mismatch"}),eg=j([ea,er,ec,em,ed,F],(e,t,n,o,i,a)=>null===e||null===a||null===t||null===n||null===o||"coherent"!==i?null:{access:a.accessInfo.access,configurationId:e,role:t,schemaIdentity:o,sessionData:n}),ef=j([F,$.selectReadonly],(e,t)=>e?.accessInfo.viewMode===!0||t),eu=j([eg,_,U,ef],(e,t,n,o)=>{let i=null!==e&&null!==t&&n&&t.access===e.access&&t.configurationId===e.configurationId&&t.role===e.role&&t.schemaIdentity===e.schemaIdentity&&t.sessionData===e.sessionData;return{identity:e,isCurrent:i,isViewMode:o}}),ep=j([B],e=>e.componentOptics),ey=j([ep],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=j([ey,Y,et],(e,t,n)=>({componentReaderIndexes:e,domainExpressions:t,allowedRootEntityTypes:n})),eh=j([B],e=>e.navigationStates),eS=j([B],e=>e.viewStates),ex="configurator"===A?j([T.selectConfiguratorSpec],e=>e.toolStates):j([],()=>I),eC="configurator"===A?j([T.selectConfiguratorSpec],e=>e.exportStates):j([],()=>I),eD="configurator"===A?j([T.selectConfiguratorSpec],e=>e.createTransformers):j([],()=>void 0),ej=j([el],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}),eI=j([ej,G],(e,t)=>n(t.validateAndMigrateState(e.initialEntities,e.modelVersion),e.rootEntityType)),ev="configurator"===A?k.selectConfiguratorFrontendData:k.selectAdminFrontendData,eP="configurator"===A?k.selectConfiguratorBackendData:k.selectAdminBackendData,eM="configurator"===A?k.selectConfiguratorPublishedData:k.selectAdminPublishedData,eA="configurator"===A?j([N.selectSessionContext],e=>M(e).role):j([],()=>"admin"),eR="configurator"===A?j([N.selectSessionContext],e=>M(e).data):j([],()=>v),eE=j([ea,ei,eA,eR,ej,F],(e,t,n,o,i,a)=>({access:a?.accessInfo.access??null,configurationId:e,mode:t,role:n,schemaIdentity:i.schemaIdentity,sessionData:o})),eT=j([q],e=>e.mode),eb=j([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}),e$=j([q],e=>e.role),ek=j([q],e=>e.sessionData),eN=j([eT,e$,ek,ev,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:em,selectSchemaCoherence:ed,selectInitializationIdentity:eg,selectIsViewMode:ef,selectInitializationState:eu,selectComponentOptics:ep,selectComponentReaderIndexes:ey,selectStoreRuntimeDependencies:ew,selectNavigationStates:eh,selectViewStates:eS,selectToolStates:ex,selectExportStates:eC,selectCreateTransformers:eD,selectLatestLoadedData:el,selectLoadedData:ej,selectInitialDomainState:eI,selectFrontendData:ev,selectBackendData:eP,selectPublishedData:eM,selectLatestRole:eA,selectLatestSessionData:eR,selectNextInitializationContext:eE,selectActiveMode:eT,selectActiveConfigurationId:eb,selectActiveRole:e$,selectActiveSessionData:ek,selectExpressionContext:eN,getInitializationContext:()=>_(R()),getInitializationState:()=>eu(R()),getNextInitializationContext:()=>eE(R()),getLatestLoadedData:()=>el(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:()=>eC(R()),getCreateTransformers:()=>eD(R()),getLoadedData:()=>ej(R()),getInitialDomainState:()=>eI(R()),getFrontendData:()=>ev(R()),getBackendData:()=>eP(R()),getPublishedData:()=>eM(R()),getActiveRole:()=>e$(R()),getActiveSessionData:()=>ek(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 t({selectors:ez}),eV=new C({selectors:ez}),eB=new d({selectors:ez}),eF=new i({selectors:ez}),eW=new y({selectors:ez}),e_=new w({selectors:ez}),eq=new f({selectors:ez}),eO=new m({selectors:ez}),eU=new p({selectors:ez}),eG=new g({selectors:ez}),eH=new u({selectors:ez}),eJ=new r({selectors:ez,domainServicesSelectors:z,environmentSelectors:L}),eK=new a({selectors:ez,domainServicesSelectors:z}),eQ=new c({selectors:ez}),eX=new s({selectors:ez}),eY=new o({selectors:ez}),eZ=new l({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 D({selectors:ez,actions:E,getExtensionSystems:V});return ez};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SessionRole } from '@salsita-ai/contracts/api';
|
|
1
|
+
import type { AccessLevel, SessionRole } from '@salsita-ai/contracts/api';
|
|
2
2
|
import type { AnyDomainFactory, DomainMode } from '../../core/index.js';
|
|
3
3
|
/** A retained system that refreshes its configuration-owned state on every initialization. */
|
|
4
4
|
export interface InitializableSystem {
|
|
@@ -26,6 +26,7 @@ export type DomainExecutionMode = 'interactive' | 'finalize';
|
|
|
26
26
|
export type SchemaCoherence = 'coherent' | 'schema-mismatch' | 'missing-stamp';
|
|
27
27
|
/** Runtime inputs that identify the interactive configuration rendered by a lifecycle host. */
|
|
28
28
|
export interface DomainContextInitializationIdentity {
|
|
29
|
+
readonly access: AccessLevel;
|
|
29
30
|
readonly configurationId: string;
|
|
30
31
|
readonly role: SessionRole;
|
|
31
32
|
readonly schemaIdentity: AnyDomainFactory;
|
|
@@ -33,6 +34,8 @@ export interface DomainContextInitializationIdentity {
|
|
|
33
34
|
}
|
|
34
35
|
/** Inputs captured by the latest successful domain-context initialization. */
|
|
35
36
|
export interface DomainContextInitializationContext {
|
|
37
|
+
/** Token access captured with the session inputs; finalization has no interactive access. */
|
|
38
|
+
readonly access: AccessLevel | null;
|
|
36
39
|
/** Finalization has no interactive access and therefore no configuration id. */
|
|
37
40
|
readonly configurationId: string | null;
|
|
38
41
|
readonly mode: DomainMode;
|