@salsita-ai/sdk 0.50.0-develop.da56a0c6c3 → 0.50.0-develop.dfac20c66b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +19 -11
  2. package/dist/application-spec/errors/diagnostic-codes.d.ts +6 -0
  3. package/dist/application-spec/errors/diagnostic-codes.js +1 -1
  4. package/dist/application-spec/errors/diagnostic-messages.d.ts +6 -0
  5. package/dist/application-spec/errors/diagnostic-messages.js +1 -1
  6. package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
  7. package/dist/application-spec/generate-application/code/templates/application-types.js +6 -6
  8. package/dist/application-spec/generate-application/code/templates/configurator-domain-code.d.ts +1 -0
  9. package/dist/application-spec/generate-application/code/templates/configurator-domain-code.js +11 -8
  10. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.d.ts +3 -1
  11. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.js +70 -66
  12. package/dist/application-spec/generate-application/code/templates/domain-spec/generate-phx-globals.js +3 -0
  13. package/dist/application-spec/generate-application/code/templates/domain-spec.js +5 -5
  14. package/dist/application-spec/generate-application/code/templates/domain.js +2 -2
  15. package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.d.ts +11 -0
  16. package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.js +8 -0
  17. package/dist/application-spec/generate-application/code/templates/global-definition/index.d.ts +1 -0
  18. package/dist/application-spec/generate-application/code/templates/global-definition/index.js +1 -1
  19. package/dist/application-spec/generate-application/code/templates/globals.js +1 -0
  20. package/dist/application-spec/generate-application/code/templates/skills/phoenix-create-configurator-skill.js +3 -1
  21. package/dist/application-spec/generate-application/code/templates/skills/phoenix-feedback-skill.js +39 -16
  22. package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js +4 -2
  23. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +3 -1
  24. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +2 -2
  25. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.d.ts +2 -0
  26. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.js +1 -1
  27. package/dist/application-spec/generate-application/runtime/sections/actions-runtime.d.ts +14 -0
  28. package/dist/application-spec/generate-application/runtime/sections/actions-runtime.js +1 -0
  29. package/dist/application-spec/generate-application/runtime/sections/index.d.ts +1 -0
  30. package/dist/application-spec/generate-application/runtime/sections/index.js +1 -1
  31. package/dist/application-spec/parse-application-files/categorize/categorize-files.d.ts +3 -1
  32. package/dist/application-spec/parse-application-files/categorize/categorize-files.js +1 -1
  33. package/dist/application-spec/parse-application-files/merge/index.d.ts +1 -0
  34. package/dist/application-spec/parse-application-files/merge/index.js +1 -1
  35. package/dist/application-spec/parse-application-files/merge/merged-actions.d.ts +11 -0
  36. package/dist/application-spec/parse-application-files/merge/merged-actions.js +1 -0
  37. package/dist/application-spec/parse-application-files/merge/merged-spec.d.ts +2 -0
  38. package/dist/application-spec/parse-application-files/merge/merged-spec.js +1 -1
  39. package/dist/application-spec/parse-application-files/raw-spec/index.d.ts +1 -0
  40. package/dist/application-spec/parse-application-files/raw-spec/index.js +1 -1
  41. package/dist/application-spec/parse-application-files/raw-spec/raw-actions.d.ts +18 -0
  42. package/dist/application-spec/parse-application-files/raw-spec/raw-actions.js +1 -0
  43. package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.d.ts +14 -2
  44. package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.js +1 -1
  45. package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.d.ts +2 -0
  46. package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.js +1 -1
  47. package/dist/application-spec/parse-application-files/resolve/resolve-import-modules.js +1 -1
  48. package/dist/application-spec/parse-application-files/spec/application/application-spec.js +1 -1
  49. package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.d.ts +4 -2
  50. package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.js +1 -1
  51. package/dist/application-spec/parse-application-files/spec/common/index.d.ts +1 -0
  52. package/dist/application-spec/parse-application-files/spec/common/index.js +1 -1
  53. package/dist/application-spec/parse-application-files/spec/common/schema-ref-resolver.d.ts +23 -0
  54. package/dist/application-spec/parse-application-files/spec/common/schema-ref-resolver.js +1 -0
  55. package/dist/application-spec/parse-application-files/spec/model/names/action-name.d.ts +10 -0
  56. package/dist/application-spec/parse-application-files/spec/model/names/action-name.js +1 -0
  57. package/dist/application-spec/parse-application-files/spec/model/names/index.d.ts +1 -0
  58. package/dist/application-spec/parse-application-files/spec/model/names/index.js +1 -1
  59. package/dist/application-spec/parse-application-files/spec/sections/actions.d.ts +35 -0
  60. package/dist/application-spec/parse-application-files/spec/sections/actions.js +1 -0
  61. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.d.ts +3 -14
  62. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.js +1 -1
  63. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +12 -3
  64. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
  65. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant.d.ts +5 -3
  66. package/dist/application-spec/parse-application-files/spec/sections/index.d.ts +1 -0
  67. package/dist/application-spec/parse-application-files/spec/sections/index.js +1 -1
  68. package/dist/configurator/application-runtime/extensions/configurator-extension-systems.d.ts +2 -1
  69. package/dist/configurator/application-runtime/extensions/configurator-extension-systems.js +1 -1
  70. package/dist/configurator/application-runtime/extensions/selectors.d.ts +2 -1
  71. package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
  72. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +35 -0
  73. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -0
  74. package/dist/configurator/{assistant → application-runtime/extensions/systems/assistant-system}/browser-details.d.ts +1 -1
  75. package/dist/configurator/application-runtime/extensions/systems/assistant-system/browser-details.js +1 -0
  76. package/dist/configurator/{assistant → application-runtime/extensions/systems/assistant-system}/graphql-tools.d.ts +13 -14
  77. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -0
  78. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
  79. package/dist/configurator/application-runtime/extensions/systems/index.d.ts +1 -0
  80. package/dist/configurator/application-runtime/extensions/systems/index.js +1 -1
  81. package/dist/configurator/assistant/use-assistant-chat.js +1 -1
  82. package/dist/docs/index.json +12 -2
  83. package/dist/docs/other-features/domain-actions.mdx +418 -0
  84. package/dist/docs/phoenix/admin.mdx +2 -2
  85. package/dist/docs/phoenix/best-practices.mdx +1 -0
  86. package/dist/docs/phoenix/finalization.mdx +1 -1
  87. package/dist/docs/phoenix/integration/headless-mode-external.mdx +5 -5
  88. package/dist/docs/phoenix/integration/widget-mode-external.mdx +5 -5
  89. package/dist/docs/phoenix/phoenix-cli.mdx +59 -19
  90. package/dist/docs/phoenix/project-structure.mdx +4 -1
  91. package/dist/docs/phoenix/sdk-builder-workflow.mdx +5 -4
  92. package/dist/domain/actions/action-factory.d.ts +10 -0
  93. package/dist/domain/actions/action-factory.js +1 -0
  94. package/dist/domain/actions/prepare-action-implementations.d.ts +15 -0
  95. package/dist/domain/actions/prepare-action-implementations.js +5 -0
  96. package/dist/domain/application/application-config.d.ts +3 -1
  97. package/dist/domain/application/assistant-mutations.d.ts +15 -14
  98. package/dist/domain/application/assistant-mutations.js +1 -1
  99. package/dist/domain/core/action.d.ts +67 -0
  100. package/dist/domain/core/action.js +1 -0
  101. package/dist/domain/core/domain-factory.d.ts +4 -0
  102. package/dist/domain/core/index.d.ts +1 -0
  103. package/dist/domain/domain-builder.d.ts +7 -0
  104. package/dist/domain/domain-builder.js +1 -1
  105. package/dist/domain/domain-context/action-system/action-system.d.ts +40 -0
  106. package/dist/domain/domain-context/action-system/action-system.js +1 -0
  107. package/dist/domain/domain-context/domain-context-systems.d.ts +5 -2
  108. package/dist/domain/domain-context/index.d.ts +1 -0
  109. package/dist/domain/domain-context/index.js +1 -1
  110. package/dist/domain/domain-runtime/domain-context/domain-context.js +1 -1
  111. package/dist/domain/domain-runtime/domain-context/selectors.d.ts +4 -0
  112. package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
  113. package/dist/domain/domain-runtime/domain-runtime.d.ts +12 -0
  114. package/dist/domain/domain-runtime/spec/initialize.js +1 -1
  115. package/dist/domain/domain-runtime/spec/types.d.ts +15 -1
  116. package/dist/domain/index.d.ts +2 -0
  117. package/dist/domain/index.js +1 -1
  118. package/dist/domain/mocks/create-mock-domain-runtime.d.ts +6 -0
  119. package/dist/editor/domain-editors/DomainSpecContext.js +1 -1
  120. package/dist/editor/domain-editors/apply-spec-update.js +1 -1
  121. package/dist/editor/domain-editors/use-implementation-files.d.ts +7 -3
  122. package/dist/editor/domain-editors/use-implementation-files.js +1 -1
  123. package/dist/phoenix/application-spec/generate-assistant-prompt.d.ts +2 -2
  124. package/dist/phoenix/application-spec/generate-assistant-prompt.js +1 -1
  125. package/dist/phoenix/cli.js +1 -1
  126. package/dist/phoenix/commands/build.d.ts +5 -0
  127. package/dist/phoenix/commands/build.js +1 -1
  128. package/dist/phoenix/commands/feedback.d.ts +2 -1
  129. package/dist/phoenix/commands/feedback.js +1 -1
  130. package/dist/phoenix/commands/login.d.ts +24 -6
  131. package/dist/phoenix/commands/login.js +2 -2
  132. package/dist/phoenix/services/index.d.ts +1 -0
  133. package/dist/phoenix/services/index.js +1 -1
  134. package/dist/phoenix/services/phx-banner-plugin.d.ts +32 -0
  135. package/dist/phoenix/services/phx-banner-plugin.js +1 -0
  136. package/dist/phoenix/services/phx-licenses-plugin.d.ts +55 -0
  137. package/dist/phoenix/services/phx-licenses-plugin.js +8 -0
  138. package/dist/phoenix/services/vite-config.d.ts +2 -0
  139. package/dist/phoenix/services/vite-config.js +1 -1
  140. package/dist/phoenix/utils/index.d.ts +1 -0
  141. package/dist/phoenix/utils/index.js +1 -1
  142. package/dist/phoenix/utils/read-git-commit.d.ts +14 -0
  143. package/dist/phoenix/utils/read-git-commit.js +1 -0
  144. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +12 -0
  145. package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +3 -0
  146. package/package.json +3 -3
  147. package/dist/configurator/assistant/browser-details.js +0 -1
  148. package/dist/configurator/assistant/graphql-tools.js +0 -1
@@ -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 i of e)if("entity"===i.type||"layout"===i.type)t[i.name]=a?.[i.name]??i.name;else{let e=`icon:${n}`;t[e]=a?.[e]??`${e}:${i.elements.length}`,n+=1}return t};export const initializeSpec=n=>{let i=n.adminDomain.presets[0];if(!i)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,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,allowedRootEntityTypes:n.adminDomain.domainFactory.context.allowedRootEntityTypes,migrate:n.adminDomain.domainFactory.context.migrate,preset:i,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)}}};
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;
@@ -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';
@@ -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 r from"lodash-es/debounce.js";import t from"promise-queue";import{createContext as o,useCallback as n,useContext as i,useEffect as s,useMemo as a,useRef as c,useState as l}from"react";import{match as m}from"ts-pattern";import{ApplicationRuntime as p,BinaryFile as u,RawProjectFiles as d,RuntimeReferenceStore as f,TextFile as g,buildPhoenixDefinitions as v,isConfiguratorModelSchemaCompatible as S,isTextFile as y,parseApplicationFiles as E}from"#package/application-spec";import{getAllPhxDefinitions as h}from"#package/domain";import{useApplicationRuntime as x,useMountGuard as D}from"#package/react-sdk";import{useEditorConnection as A}from"../services/EditorConnectionContext.js";import{trpc as C}from"../services/trpc.js";import{applyRuntimeReset as w,applySpecUpdate as N,prepareRuntimeRefresh as P,prepareRuntimeReset as R}from"./apply-spec-update.js";import{useDiagnostics as _}from"./use-diagnostics.js";import{useImplementationFiles as L}from"./use-implementation-files.js";import{getWasmSwcParsers as j}from"./wasm-swc-parsers.js";let k=o(null),I={debug:e=>console.debug(e)},b=e=>e instanceof Error?e.message:String(e);export const DomainSpecProvider=o=>{let{children:i,domainSpec:O,initialRawProjectFiles:T}=o,[M,$]=l(a(()=>O?[{fileName:"domain.yaml",content:O}]:T?T.files.filter(y).map(e=>({fileName:e.name,content:e.content})):[],[O,T])),[F,z]=l(null),H=a(()=>new f,[]),q=a(()=>v(h()),[]),U=c(null),G=x(),{getImplementationFiles:Q}=L(),{diagnostics:B,unreadDiagnosticCount:V,setDiagnostics:X,pushDiagnostic:Y,clearDiagnostics:Z,markDiagnosticsRead:J}=_(),K=a(()=>new t(1,1/0),[]),W=c(0),ee=c(null),{mutateAsync:er}=C.requestSpecFiles.useMutation(),{mutateAsync:et}=C.save.useMutation(),eo=D(),{localMode:en,connectionStatus:ei}=A(),{data:es}=C.getEditorConfig.useQuery(void 0,{enabled:!en&&"connected"===ei}),ea=en||es?.specSync===!0,ec=M.length>0?M:void 0,el=a(()=>M.map(e=>e.fileName),[M]),em=a(()=>r(async e=>{if(!en&&"connected"===ei&&0!==e.length)try{await et(e.map(e=>({fileName:e.fileName,content:e.content})))}catch(e){console.error("[DomainSpecContext] Failed to save files to disk:",e)}},1e3),[en,ei,et]);s(()=>()=>{em.cancel()},[em]);let ep=n(()=>{z(null)},[]),eu=n(async(e,r)=>{$(t=>{let o=t.find(r=>r.fileName===e)?t.map(t=>t.fileName===e?{...t,content:r}:t):[...t,{fileName:e,content:r}];return em(o),o})},[em]),ed=n(async(e,r)=>{let t,o,n=()=>eo()&&W.current===r;if(!n())return;let i=d(e.rawProjectFiles.files.map(e=>m(e).with({kind:"text"},e=>g(e.name,e.content)).with({kind:"binary"},e=>u(e.name)).exhaustive()));$(i.files.filter(y).map(e=>({fileName:e.name,content:e.content})));try{t=await j()}catch(e){if(!n())return;X([{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 s=E({rawProjectFiles:i,phxDefinitions:q},{analyzer:t.analyzer,evalExpressionParser:t.evalExpressionParser,referenceStore:H,logger:I});if(console.info(`[DomainSpecContext] Spec parsed: ${s.ok?"ok":"error"}, ${s.diagnostics.length} diagnostics`),!s.ok)return void X([...s.errors,...s.diagnostics].map(e=>({...e,source:"spec"})));Z();let{applicationSpec:a}=s.value,c=await Q({application:s.value,projectRoot:e.projectRoot});if(!n())return;if(c.errors.length>0)return void X(c.errors.map(e=>({code:e.code,message:e.message,severity:"error",source:"reload",path:[]})));let l=p(a,H,c.implementations,c.importedTransformers,c.invariantImplementations,c.adminImplementations);if(!l.ok){let e=`Missing expression implementations: ${l.missingExpressions.map(e=>`${e.entityType}.${e.exprName}`).join(", ")}`;console.error(`[DomainSpecContext] ${e}`),Y({code:"MISSING_EXPRESSION_IMPLEMENTATIONS",message:e,severity:"error",source:"runtime"});return}let{runtime:f}=l,v=null===U.current||S(U.current.configurator,a.configurator),h=G.selectors.environment.getPersistenceConfig();if(!v){let e;if("server"===h.type)return void Y({code:"HOT_RELOAD_MODEL_CHANGE_REQUIRES_RESTART",message:"Domain model changes require an application restart and were not applied.",severity:"error",source:"runtime"});if(!G.selectors.domainContext.configurator.getInitializationState().isCurrent)return void G.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=R({runtime:f,implementationFiles:c,previousSpec:G.getState().spec})}catch(e){Y({code:"HOT_RELOAD_PREPARE_FAILED",message:b(e),severity:"error",source:"runtime"});return}return G.selectors.domainServices.getLogger().debug("[DomainSpecContext] Reseeding the reset session directly from the spec preset; onPresetLoadedHandler and ProductSelected analytics are intentionally skipped."),w(G,e,G.selectors.domainApplicationContext.configurator.getConfigurationPersistSystem().revisionId$.value),void(U.current=a)}try{o=P({runtime:f,implementationFiles:c,previousSpec:G.getState().spec})}catch(e){Y({code:"HOT_RELOAD_PREPARE_FAILED",message:b(e),severity:"error",source:"runtime"});return}n()&&(N(G,o),U.current=a)},[G,Q,eo,q,Y,H,X,Z]),ef=c(null),eg=n(e=>{let r=W.current+1;W.current=r,ee.current={data:e,generation:r},K.add(async()=>{let e=ee.current;e&&e.data!==ef.current&&(ee.current=null,ef.current=e.data,await ed(e.data,e.generation))})},[ed,K]);C.onSpecChange.useSubscription(void 0,{enabled:!en&&ea,onData:eg}),s(()=>{!en&&ea&&er().catch(()=>{console.warn("[DomainSpecContext] Failed to request spec files")})},[er,en,ea]);let ev=a(()=>({files:ec,fileNames:el,updateFile:eu,parsing:!1,parseError:F,clearParseError:ep,diagnostics:B,clearDiagnostics:Z,unreadDiagnosticCount:V,markDiagnosticsRead:J}),[ec,el,eu,F,ep,B,Z,V,J]);return e(k.Provider,{value:ev,children:i})};export const useDomainSpecContext=()=>{let e=i(k);if(null===e)throw Error("useDomainSpecContext must be used within DomainSpecProvider");return e};
1
+ import{jsx as e}from"react/jsx-runtime";import t from"lodash-es/debounce.js";import r from"promise-queue";import{createContext as o,useCallback as n,useContext as i,useEffect as a,useMemo as s,useRef as c,useState as m}from"react";import{match as l}from"ts-pattern";import{ApplicationRuntime as p,BinaryFile as u,RawProjectFiles as d,RuntimeReferenceStore as g,TextFile as f,buildPhoenixDefinitions as S,isConfiguratorModelSchemaCompatible as v,isTextFile as h,parseApplicationFiles as y}from"#package/application-spec";import{findActionImplementationConflicts as E,getAllPhxDefinitions as x}from"#package/domain";import{useApplicationRuntime as A,useMountGuard as C}from"#package/react-sdk";import{useEditorConnection as D}from"../services/EditorConnectionContext.js";import{trpc as I}from"../services/trpc.js";import{applyRuntimeReset as N,applySpecUpdate as w,prepareRuntimeRefresh as P,prepareRuntimeReset as _}from"./apply-spec-update.js";import{useDiagnostics as R}from"./use-diagnostics.js";import{useImplementationFiles as j}from"./use-implementation-files.js";import{getWasmSwcParsers as L}from"./wasm-swc-parsers.js";let k=o(null),T={debug:e=>console.debug(e)},M=e=>e instanceof Error?e.message:String(e);export const DomainSpecProvider=o=>{let{children:i,domainSpec:O,initialRawProjectFiles:b}=o,[$,F]=m(s(()=>O?[{fileName:"domain.yaml",content:O}]:b?b.files.filter(h).map(e=>({fileName:e.name,content:e.content})):[],[O,b])),[z,H]=m(null),q=s(()=>new g,[]),G=s(()=>S(x()),[]),U=c(null),Q=A(),{getImplementationFiles:B}=j(),{diagnostics:V,unreadDiagnosticCount:X,setDiagnostics:Y,pushDiagnostic:Z,clearDiagnostics:J,markDiagnosticsRead:K}=R(),W=s(()=>new r(1,1/0),[]),ee=c(0),et=c(null),{mutateAsync:er}=I.requestSpecFiles.useMutation(),{mutateAsync:eo}=I.save.useMutation(),en=C(),{localMode:ei,connectionStatus:ea}=D(),{data:es}=I.getEditorConfig.useQuery(void 0,{enabled:!ei&&"connected"===ea}),ec=ei||es?.specSync===!0,em=$.length>0?$:void 0,el=s(()=>$.map(e=>e.fileName),[$]),ep=s(()=>t(async e=>{if(!ei&&"connected"===ea&&0!==e.length)try{await eo(e.map(e=>({fileName:e.fileName,content:e.content})))}catch(e){console.error("[DomainSpecContext] Failed to save files to disk:",e)}},1e3),[ei,ea,eo]);a(()=>()=>{ep.cancel()},[ep]);let eu=n(()=>{H(null)},[]),ed=n(async(e,t)=>{F(r=>{let o=r.find(t=>t.fileName===e)?r.map(r=>r.fileName===e?{...r,content:t}:r):[...r,{fileName:e,content:t}];return ep(o),o})},[ep]),eg=n(async(e,t)=>{let r,o,n=()=>en()&&ee.current===t;if(!n())return;let i=d(e.rawProjectFiles.files.map(e=>l(e).with({kind:"text"},e=>f(e.name,e.content)).with({kind:"binary"},e=>u(e.name)).exhaustive()));F(i.files.filter(h).map(e=>({fileName:e.name,content:e.content})));try{r=await L()}catch(e){if(!n())return;Y([{code:"MODULE_ANALYZER_UNAVAILABLE",message:`The editor's module analyzer failed to load: ${e instanceof Error?e.message:String(e)}`,severity:"error",source:"spec",path:[]}]);return}if(!n())return;let a=y({rawProjectFiles:i,phxDefinitions:G},{analyzer:r.analyzer,evalExpressionParser:r.evalExpressionParser,referenceStore:q,logger:T});if(console.info(`[DomainSpecContext] Spec parsed: ${a.ok?"ok":"error"}, ${a.diagnostics.length} diagnostics`),!a.ok)return void Y([...a.errors,...a.diagnostics].map(e=>({...e,source:"spec"})));J();let{applicationSpec:s}=a.value,c=await B({application:a.value,projectRoot:e.projectRoot});if(!n())return;if(c.errors.length>0)return void Y(c.errors.map(e=>({code:e.code,message:e.message,severity:"error",source:"reload",path:[]})));let m=E([...s.configurator.actions.values()].map(e=>String(e.name)),c.actionImplementations??Q.getState().spec.configurator.actionImplementations);if(m.extra.length>0&&console.error(`[DomainSpecContext] Action implementations without a declaration: ${m.extra.join(", ")}`),m.missing.length>0){let e=`Missing action implementations: ${m.missing.join(", ")}. Add each to a default export of phx.domain.implementActions({ ... }) in src/actions/.`;console.error(`[DomainSpecContext] ${e}`),Z({code:"MISSING_ACTION_IMPLEMENTATIONS",message:e,severity:"error",source:"runtime"});return}let g=p(s,q,c.implementations,c.importedTransformers,c.invariantImplementations,c.adminImplementations);if(!g.ok){let e=`Missing expression implementations: ${g.missingExpressions.map(e=>`${e.entityType}.${e.exprName}`).join(", ")}`;console.error(`[DomainSpecContext] ${e}`),Z({code:"MISSING_EXPRESSION_IMPLEMENTATIONS",message:e,severity:"error",source:"runtime"});return}let{runtime:S}=g,x=null===U.current||v(U.current.configurator,s.configurator),A=Q.selectors.environment.getPersistenceConfig();if(!x){let e;if("server"===A.type)return void Z({code:"HOT_RELOAD_MODEL_CHANGE_REQUIRES_RESTART",message:"Domain model changes require an application restart and were not applied.",severity:"error",source:"runtime"});if(!Q.selectors.domainContext.configurator.getInitializationState().isCurrent)return void Q.selectors.domainServices.getLogger().debug("[DomainSpecContext] Skipping the model reset because no configurator session is initialized; the change applies once a session loads under the new spec.");try{e=_({runtime:S,implementationFiles:c,previousSpec:Q.getState().spec})}catch(e){Z({code:"HOT_RELOAD_PREPARE_FAILED",message:M(e),severity:"error",source:"runtime"});return}return Q.selectors.domainServices.getLogger().debug("[DomainSpecContext] Reseeding the reset session directly from the spec preset; onPresetLoadedHandler and ProductSelected analytics are intentionally skipped."),N(Q,e,Q.selectors.domainApplicationContext.configurator.getConfigurationPersistSystem().revisionId$.value),void(U.current=s)}try{o=P({runtime:S,implementationFiles:c,previousSpec:Q.getState().spec})}catch(e){Z({code:"HOT_RELOAD_PREPARE_FAILED",message:M(e),severity:"error",source:"runtime"});return}n()&&(w(Q,o),U.current=s)},[Q,B,en,G,Z,q,Y,J]),ef=c(null),eS=n(e=>{let t=ee.current+1;ee.current=t,et.current={data:e,generation:t},W.add(async()=>{let e=et.current;e&&e.data!==ef.current&&(et.current=null,ef.current=e.data,await eg(e.data,e.generation))})},[eg,W]);I.onSpecChange.useSubscription(void 0,{enabled:!ei&&ec,onData:eS}),a(()=>{!ei&&ec&&er().catch(()=>{console.warn("[DomainSpecContext] Failed to request spec files")})},[er,ei,ec]);let ev=s(()=>({files:em,fileNames:el,updateFile:ed,parsing:!1,parseError:z,clearParseError:eu,diagnostics:V,clearDiagnostics:J,unreadDiagnosticCount:X,markDiagnosticsRead:K}),[em,el,ed,z,eu,V,J,X,K]);return e(k.Provider,{value:ev,children:i})};export const useDomainSpecContext=()=>{let e=i(k);if(null===e)throw Error("useDomainSpecContext must be used within DomainSpecProvider");return e};
@@ -1 +1 @@
1
- import{resolveImportedTransformers as e}from"#package/domain";import{getPhoenixThemes as t}from"#package/ui-sdk";import{getCustomComponentOptics as n}from"./use-implementation-files.js";let s=s=>{var o;let a,i,{runtime:r,implementationFiles:m,previousSpec:p}=s,c=r.configurator,l=p.configurator,u=m.handlers?.handlers??l.handlers,d=m.handlers?((e,t,n)=>{let s={};for(let o of e)s[o.name]=t?.[o.name]??n?.[o.name]??o.name;return s})(u,m.handlers.nameHashes,l.handlerHashes):l.handlerHashes,f=m.elements?.elements??l.elements,h=m.elements?((e,t,n)=>{let s={},o=0;for(let a of e)if("entity"===a.type||"layout"===a.type)s[a.name]=t?.[a.name]??n?.[a.name]??a.name;else{let e=`icon:${o}`;s[e]=t?.[e]??n?.[e]??`${e}:${a.elements.length}`,o+=1}return s})(f,m.elements.nameHashes,l.elementHashes):l.elementHashes,g=null!==m.customComponentOptics,R=c.componentOptics.changed||g?[...c.componentOptics.optics.map(e=>e.optic),...m.customComponentOptics??n(l.componentOptics)]:l.componentOptics,x=c.transformersRuntime.changed?t=>e(c.transformersRuntime.importedTransformers,c.transformersRuntime.specTransformers,t):l.createTransformers;return{presets:c.presetRuntime.changed?c.presetRuntime.presets:l.presets,theme:c.themeRuntime.changed?(o=c.themeRuntime,a=t(),i=Object.entries(a).find(([e])=>e===o.preset)?.[1]??{},Object.keys(o.options).length>0?{...i,...o.options}:i):l.theme,assistant:c.assistantRuntime.changed?c.assistantRuntime.assistant:l.assistant,navigationStates:c.statesRuntime.changed?c.statesRuntime.navigationStates:l.navigationStates,viewStates:c.statesRuntime.changed?c.statesRuntime.viewStates:l.viewStates,toolStates:c.statesRuntime.changed?c.statesRuntime.toolStates:l.toolStates,exportStates:c.statesRuntime.changed?c.statesRuntime.exportStates:l.exportStates,componentOptics:R,createTransformers:x,handlers:u,handlerHashes:d,elements:f,elementHashes:h}};export const prepareRuntimeRefresh=e=>{let{runtime:t,previousSpec:n}=e,o=n.configurator,a=s(e),i=t.configurator.expressionRuntime.changed?t.configurator.expressionRuntime.merged:o.expressions;return{nextSpec:{...n,configurator:{...o,...a,expressions:i}}}};export const prepareRuntimeReset=e=>{let{runtime:t,previousSpec:n}=e,o=n.configurator,a=s(e),i=t.configurator.expressionRuntime.merged,r=t.configurator.modelRuntime.domainBuilder.withExpressions(i).build(),m=a.presets[0];if(void 0===m)throw Error("Cannot reset the configurator after a model change because the application spec has no presets.");return{firstPreset:m,nextSpec:{...n,configurator:{...o,...a,modelVersion:r.context.modelVersion,factory:r,aliasMap:r.context.aliasMap,entityReflections:r.context.entityReflections,$entityReflections:r.context.$entityReflections,expressions:i,allowedRootEntityTypes:r.context.allowedRootEntityTypes,migrate:r.context.migrate}}}};let o=(e,t)=>{e.actions.spec.updateSpec(t)};export const applyRuntimeRefresh=(e,t)=>o(e,t.nextSpec);export const applyRuntimeReset=(e,t,n)=>{o(e,t.nextSpec),e.actions.loadedData.completeConfiguratorLoad({initialRevisionId:n,initialEntities:t.firstPreset.initialDomainEntities,modelVersion:t.nextSpec.configurator.modelVersion,rootEntityType:t.firstPreset.rootEntityType,schemaIdentity:t.nextSpec.configurator.factory})};export const applySpecUpdate=(e,t)=>o(e,t.nextSpec);
1
+ import{resolveImportedTransformers as e}from"#package/domain";import{getPhoenixThemes as t}from"#package/ui-sdk";import{getCustomComponentOptics as n}from"./use-implementation-files.js";let s=s=>{var o;let i,a,{runtime:r,implementationFiles:m,previousSpec:c}=s,p=r.configurator,l=c.configurator,u=m.handlers?.handlers??l.handlers,f=m.handlers?((e,t,n)=>{let s={};for(let o of e)s[o.name]=t?.[o.name]??n?.[o.name]??o.name;return s})(u,m.handlers.nameHashes,l.handlerHashes):l.handlerHashes,d=m.elements?.elements??l.elements,h=m.elements?((e,t,n)=>{let s={},o=0;for(let i of e)if("entity"===i.type||"layout"===i.type)s[i.name]=t?.[i.name]??n?.[i.name]??i.name;else{let e=`icon:${o}`;s[e]=t?.[e]??n?.[e]??`${e}:${i.elements.length}`,o+=1}return s})(d,m.elements.nameHashes,l.elementHashes):l.elementHashes,g=null!==m.customComponentOptics,R=p.componentOptics.changed||g?[...p.componentOptics.optics.map(e=>e.optic),...m.customComponentOptics??n(l.componentOptics)]:l.componentOptics,x=p.transformersRuntime.changed?t=>e(p.transformersRuntime.importedTransformers,p.transformersRuntime.specTransformers,t):l.createTransformers;return{presets:p.presetRuntime.changed?p.presetRuntime.presets:l.presets,theme:p.themeRuntime.changed?(o=p.themeRuntime,i=t(),a=Object.entries(i).find(([e])=>e===o.preset)?.[1]??{},Object.keys(o.options).length>0?{...a,...o.options}:a):l.theme,assistant:p.assistantRuntime.changed?p.assistantRuntime.assistant:l.assistant,navigationStates:p.statesRuntime.changed?p.statesRuntime.navigationStates:l.navigationStates,viewStates:p.statesRuntime.changed?p.statesRuntime.viewStates:l.viewStates,toolStates:p.statesRuntime.changed?p.statesRuntime.toolStates:l.toolStates,exportStates:p.statesRuntime.changed?p.statesRuntime.exportStates:l.exportStates,componentOptics:R,createTransformers:x,handlers:u,handlerHashes:f,elements:d,elementHashes:h}};export const prepareRuntimeRefresh=e=>{let{runtime:t,previousSpec:n}=e,o=n.configurator,i=s(e),a=t.configurator.expressionRuntime.changed?t.configurator.expressionRuntime.merged:o.expressions,r=t.configurator.actionsRuntime.changed?t.configurator.actionsRuntime.definitions:o.actions,m=e.implementationFiles.actionImplementations??o.actionImplementations;return{nextSpec:{...n,configurator:{...o,...i,expressions:a,actions:r,actionImplementations:m}}}};export const prepareRuntimeReset=e=>{let{runtime:t,previousSpec:n}=e,o=n.configurator,i=s(e),a=t.configurator.expressionRuntime.merged,r=t.configurator.actionsRuntime.definitions,m=e.implementationFiles.actionImplementations??o.actionImplementations,c=t.configurator.modelRuntime.domainBuilder.withExpressions(a).withActions(Object.values(r)).withActionImplementations(m).build(),p=i.presets[0];if(void 0===p)throw Error("Cannot reset the configurator after a model change because the application spec has no presets.");return{firstPreset:p,nextSpec:{...n,configurator:{...o,...i,modelVersion:c.context.modelVersion,factory:c,aliasMap:c.context.aliasMap,entityReflections:c.context.entityReflections,$entityReflections:c.context.$entityReflections,expressions:a,actions:r,actionImplementations:m,allowedRootEntityTypes:c.context.allowedRootEntityTypes,migrate:c.context.migrate}}}};let o=(e,t)=>{e.actions.spec.updateSpec(t)};export const applyRuntimeRefresh=(e,t)=>o(e,t.nextSpec);export const applyRuntimeReset=(e,t,n)=>{o(e,t.nextSpec),e.actions.loadedData.completeConfiguratorLoad({initialRevisionId:n,initialEntities:t.firstPreset.initialDomainEntities,modelVersion:t.nextSpec.configurator.modelVersion,rootEntityType:t.firstPreset.rootEntityType,schemaIdentity:t.nextSpec.configurator.factory})};export const applySpecUpdate=(e,t)=>o(e,t.nextSpec);
@@ -1,5 +1,5 @@
1
1
  import type { Application, ExpressionImplementations, InvariantImplementations } from '#package/application-spec';
2
- import { type DomainComponentOptic, type DomainEntity, type ElementRegistration, type HandlerRegistration, type ImportedTransformer, type SystemComponentTypeConstraint } from '#package/domain';
2
+ import { type AnyActionImplementations, type DomainComponentOptic, type DomainEntity, type ElementRegistration, type HandlerRegistration, type ImportedTransformer, type SystemComponentTypeConstraint } from '#package/domain';
3
3
  type AnyImportedTransformer = ImportedTransformer<any, any, any, any, any, any, any>;
4
4
  type RuntimeData = Record<string, unknown>;
5
5
  type RuntimeEntity = DomainEntity<string>;
@@ -23,11 +23,13 @@ export interface ReloadError {
23
23
  * The freshly reloaded (or cached) implementation files needed to build an `ApplicationRuntime`.
24
24
  *
25
25
  * `implementations`, `adminImplementations`, `invariantImplementations`, `importedTransformers` and `customComponentOptics` always contain the latest
26
- * successfully loaded values.
26
+ * successfully loaded values. So does `actionImplementations`, which is `null` only until the first successful load: a round
27
+ * that loaded them may be dropped before it is applied, and the next round must still carry them.
27
28
  * `handlers`/`elements` are `null` when their category did not change this round.
28
29
  */
29
30
  export interface ImplementationFiles {
30
31
  readonly implementations: ExpressionImplementations;
32
+ readonly actionImplementations: AnyActionImplementations | null;
31
33
  readonly adminImplementations?: ExpressionImplementations;
32
34
  readonly invariantImplementations: InvariantImplementations;
33
35
  readonly importedTransformers: readonly AnyImportedTransformer[];
@@ -40,6 +42,8 @@ export interface GetImplementationFilesProps {
40
42
  readonly application: Application;
41
43
  readonly projectRoot: string;
42
44
  }
45
+ /** Merges the default exports of the `src/actions/` modules by action name, as the generated barrel does. */
46
+ export declare const resolveActionModules: (modules: readonly AnyActionImplementations[]) => AnyActionImplementations;
43
47
  type ExpressionModules = ReadonlyArray<Record<string, Record<string, unknown>>>;
44
48
  type ResolvedExpressions = ExpressionImplementations;
45
49
  export declare const resolveExpressionModules: (modules: ExpressionModules, aliasMap: Record<string, readonly string[]>) => ResolvedExpressions;
@@ -50,7 +54,7 @@ export declare const getCustomComponentOptics: <ComponentOptic extends {
50
54
  }>(componentOptics: readonly ComponentOptic[]) => readonly ComponentOptic[];
51
55
  /**
52
56
  * Owns the should-reload gating and cross-update caching for project implementation files
53
- * (expressions, invariants, components, transformers, handlers, elements). Returns `getImplementationFiles`,
57
+ * (expressions, actions, invariants, components, transformers, handlers, elements). Returns `getImplementationFiles`,
54
58
  * which reloads changed categories and returns the merged set with per-category reload errors.
55
59
  * Invariants also retry failed imports and refresh when their generated declarations change.
56
60
  */
@@ -1 +1 @@
1
- import{useCallback as e,useRef as n}from"react";import{expandAlias as t}from"#package/domain";import{importImplementationFile as r}from"./import-implementation-file.js";let a=e=>e instanceof Error?e.message:String(e),o=async(e,n)=>{let t=Date.now();return Promise.all(e.map(async e=>{let a=await r(`/@fs/${n}/${e}?t=${t}`);return{filePath:e,module:a}}))};export const resolveExpressionModules=(e,n)=>{let r={};for(let n of e)for(let[e,t]of Object.entries(n))r[e]={...r[e],...t};let a={};for(let[e,o]of Object.entries(r))for(let r of t(n,e)){let n=a[r]??{};for(let[t,r]of Object.entries(o))n[t]={...r,origin:{name:t,typeOrAlias:e}};a[r]=n}return a};export const resolveComponentModules=e=>e.flatMap(e=>Array.isArray(e)?e:[e]);export const mergeComponentOptics=(e,n)=>e.concat(n);export const getCustomComponentOptics=e=>e.filter(e=>!0!==e.generated);let s=async(e,n,t)=>{let r=await o(e,t);return resolveExpressionModules(r.map(e=>e.module),n)},i=async(e,n)=>{let t=await o(e,n);return resolveComponentModules(t.map(e=>e.module))},l=async(e,n)=>{let t=await o(e,n),r={};for(let{module:e}of t)for(let[n,t]of Object.entries(e))r[n]=[...r[n]??[],...t];return r},m=async(e,n)=>(await o(e,n)).map(({filePath:e,module:n})=>({name:e.replace(/^.*\//,"").replace(/\.tsx?$/,""),transformer:n})),p=async(e,n)=>(await o(e,n)).map(({filePath:e,module:n})=>({filePath:e,registrations:Array.isArray(n)?n:[n]})),c=async(e,n)=>(await o(e,n)).map(({filePath:e,module:n})=>({filePath:e,registrations:Array.isArray(n)?n:[n]}));export const useImplementationFiles=()=>{let t=n({}),r=n({}),o=n(0),f=n(null),u=n({}),d=n(null),h=n(null),g=n(null),E=n([]),w=n(null),y=n(null),F=n(new Map),I=n(new Map);return{getImplementationFiles:e(async e=>{let{application:n,projectRoot:O}=e,A=++o.current,{applicationSpec:M,categorizedFiles:R}=n,x=[],C=t.current,v=r.current,D=u.current,S=g.current,L=E.current,$=R.expressionsChanged,_=R.componentsChanged,b=R.transformersChanged,N=R.handlersChanged,j=R.elementsChanged,P=Object.fromEntries(R.invariants.map(e=>[e.file.name,e.depHash])),H=d.current,k=JSON.stringify(M.configurator.invariants.entries),T=null===H||h.current!==k||Object.keys(H).length!==R.invariants.length||R.invariants.some(e=>H[e.file.name]!==e.depHash);if(console.info(`[useImplementationFiles] Changed: spec=${R.specChanged}, expressions=${R.expressionsChanged}, adminExpressions=${R.adminExpressionsChanged}, transformers=${R.transformersChanged}, handlers=${R.handlersChanged}, elements=${R.elementsChanged}`),$){console.info("[useImplementationFiles] Reloading expression implementations");try{let e=Object.fromEntries(M.configurator.latestModel.aliases);t.current=C=await s(R.expressions.map(e=>e.file.name),e,O)}catch(e){console.warn("[useImplementationFiles] Failed to reload expressions:",e),x.push({code:"RELOAD_EXPRESSIONS_FAILED",message:a(e)})}}let J=JSON.stringify({projectRoot:O,files:R.adminExpressions.map(e=>[e.file.name,e.depHash]),aliases:[...M.admin.latestModel.aliases]});if(A===o.current&&f.current!==J)try{v=await s(R.adminExpressions.map(e=>e.file.name),Object.fromEntries(M.admin.latestModel.aliases),O),A===o.current&&(r.current=v,f.current=J)}catch(e){x.push({code:"RELOAD_ADMIN_EXPRESSIONS_FAILED",message:a(e)})}if(_){console.info("[useImplementationFiles] Reloading component optics");try{g.current=S=await i(R.components.map(e=>e.file.name),O)}catch(e){console.warn("[useImplementationFiles] Failed to reload components:",e),x.push({code:"RELOAD_COMPONENTS_FAILED",message:a(e)})}}if(T){console.info("[useImplementationFiles] Reloading invariant implementations");try{u.current=D=await l(R.invariants.map(e=>e.file.name),O),d.current=P,h.current=k}catch(e){console.warn("[useImplementationFiles] Failed to reload invariants:",e),x.push({code:"RELOAD_INVARIANTS_FAILED",message:a(e)})}}if(b){console.info("[useImplementationFiles] Reloading transformer implementations");try{E.current=L=await m(R.transformers.map(e=>e.file.name),O)}catch(e){console.warn("[useImplementationFiles] Failed to reload transformers:",e),x.push({code:"RELOAD_TRANSFORMERS_FAILED",message:a(e)})}}let X=null;if(N){console.info("[useImplementationFiles] Reloading handler implementations");try{let e=Object.fromEntries(R.handlers.map(e=>[e.file.name,e.depHash])),n=w.current,t=t=>null===n||n[t]!==e[t],r=I.current,a=R.handlers.map(e=>e.file.name),o=a.filter(e=>t(e)||!r.has(e)),s=await p(o,O),i=new Map(s.map(e=>[e.filePath,e])),l=a.map(e=>{let n=i.get(e)??r.get(e);if(!n)throw Error(`Handler file "${e}" was neither re-imported nor cached from a previous round. This is a hot-reload bookkeeping bug — reload the editor page to recover.`);return n}),m=l.flatMap(e=>e.registrations),c={};for(let{filePath:n,registrations:r}of l){let a=t(n)?e[n]:void 0;if(a)for(let e of r)c[e.name]=a}console.info(`[useImplementationFiles] Staged handlers for registry (${m.length} total)`),X={handlers:m,nameHashes:c},I.current=new Map(l.map(e=>[e.filePath,e])),w.current=e}catch(e){console.warn("[useImplementationFiles] Failed to reload handlers:",e),x.push({code:"RELOAD_HANDLERS_FAILED",message:a(e)})}}let V=null;if(j){console.info("[useImplementationFiles] Reloading element implementations");try{let e=Object.fromEntries(R.elements.map(e=>[e.file.name,e.depHash])),n=y.current,t=t=>null===n||n[t]!==e[t],r=F.current,a=R.elements.map(e=>e.file.name),o=a.filter(e=>t(e)||!r.has(e)),s=await c(o,O),i=new Map(s.map(e=>[e.filePath,e])),l=a.map(e=>{let n=i.get(e)??r.get(e);if(!n)throw Error(`Element file "${e}" was neither re-imported nor cached from a previous round. This is a hot-reload bookkeeping bug — reload the editor page to recover.`);return n}),m=l.flatMap(e=>e.registrations),p={},f=0;for(let{filePath:n,registrations:r}of l){let a=t(n)?e[n]:void 0;for(let e of r){if("entity"===e.type||"layout"===e.type){a&&(p[e.name]=a);continue}a&&(p[`icon:${f}`]=a),f+=1}}console.info(`[useImplementationFiles] Staged elements for registry (${m.length} total)`),V={elements:m,nameHashes:p},F.current=new Map(l.map(e=>[e.filePath,e])),y.current=e}catch(e){console.warn("[useImplementationFiles] Failed to reload elements:",e),x.push({code:"RELOAD_ELEMENTS_FAILED",message:a(e)})}}return{implementations:C,adminImplementations:v,invariantImplementations:D,importedTransformers:L,customComponentOptics:S,handlers:X,elements:V,errors:x}},[])}};
1
+ import{useCallback as e,useRef as n}from"react";import{expandAlias as t}from"#package/domain";import{importImplementationFile as r}from"./import-implementation-file.js";let a=e=>e instanceof Error?e.message:String(e),o=async(e,n)=>{let t=Date.now();return Promise.all(e.map(async e=>{let a=await r(`/@fs/${n}/${e}?t=${t}`);return{filePath:e,module:a}}))};export const resolveActionModules=e=>e.reduce((e,n)=>({...e,...n}),{});let s=async(e,n)=>{let t=await o(e,n);return resolveActionModules(t.map(({module:e})=>e))};export const resolveExpressionModules=(e,n)=>{let r={};for(let n of e)for(let[e,t]of Object.entries(n))r[e]={...r[e],...t};let a={};for(let[e,o]of Object.entries(r))for(let r of t(n,e)){let n=a[r]??{};for(let[t,r]of Object.entries(o))n[t]={...r,origin:{name:t,typeOrAlias:e}};a[r]=n}return a};export const resolveComponentModules=e=>e.flatMap(e=>Array.isArray(e)?e:[e]);export const mergeComponentOptics=(e,n)=>e.concat(n);export const getCustomComponentOptics=e=>e.filter(e=>!0!==e.generated);let i=async(e,n,t)=>{let r=await o(e,t);return resolveExpressionModules(r.map(e=>e.module),n)},l=async(e,n)=>{let t=await o(e,n);return resolveComponentModules(t.map(e=>e.module))},m=async(e,n)=>{let t=await o(e,n),r={};for(let{module:e}of t)for(let[n,t]of Object.entries(e))r[n]=[...r[n]??[],...t];return r},c=async(e,n)=>(await o(e,n)).map(({filePath:e,module:n})=>({name:e.replace(/^.*\//,"").replace(/\.tsx?$/,""),transformer:n})),p=async(e,n)=>(await o(e,n)).map(({filePath:e,module:n})=>({filePath:e,registrations:Array.isArray(n)?n:[n]})),u=async(e,n)=>(await o(e,n)).map(({filePath:e,module:n})=>({filePath:e,registrations:Array.isArray(n)?n:[n]}));export const useImplementationFiles=()=>{let t=n({}),r=n(null),o=n({}),f=n(0),d=n(null),h=n({}),g=n(null),E=n(null),F=n(null),w=n([]),y=n(null),I=n(null),A=n(new Map),O=n(new Map);return{getImplementationFiles:e(async e=>{let{application:n,projectRoot:M}=e,R=++f.current,{applicationSpec:C,categorizedFiles:v}=n,x=[],D=t.current,L=o.current,S=h.current,_=F.current,$=w.current,b=v.expressionsChanged,N=v.actionsChanged,j=v.componentsChanged,P=v.transformersChanged,H=v.handlersChanged,T=v.elementsChanged,k=Object.fromEntries(v.invariants.map(e=>[e.file.name,e.depHash])),J=g.current,X=JSON.stringify(C.configurator.invariants.entries),V=null===J||E.current!==X||Object.keys(J).length!==v.invariants.length||v.invariants.some(e=>J[e.file.name]!==e.depHash);if(console.info(`[useImplementationFiles] Changed: spec=${v.specChanged}, expressions=${v.expressionsChanged}, actions=${v.actionsChanged}, adminExpressions=${v.adminExpressionsChanged}, transformers=${v.transformersChanged}, handlers=${v.handlersChanged}, elements=${v.elementsChanged}`),b){console.info("[useImplementationFiles] Reloading expression implementations");try{let e=Object.fromEntries(C.configurator.latestModel.aliases);t.current=D=await i(v.expressions.map(e=>e.file.name),e,M)}catch(e){console.warn("[useImplementationFiles] Failed to reload expressions:",e),x.push({code:"RELOAD_EXPRESSIONS_FAILED",message:a(e)})}}let q=r.current;if(N){console.info("[useImplementationFiles] Reloading action implementations");try{r.current=q=await s(v.actions.map(e=>e.file.name),M)}catch(e){console.warn("[useImplementationFiles] Failed to reload actions:",e),x.push({code:"RELOAD_ACTIONS_FAILED",message:a(e)})}}let z=JSON.stringify({projectRoot:M,files:v.adminExpressions.map(e=>[e.file.name,e.depHash]),aliases:[...C.admin.latestModel.aliases]});if(R===f.current&&d.current!==z)try{L=await i(v.adminExpressions.map(e=>e.file.name),Object.fromEntries(C.admin.latestModel.aliases),M),R===f.current&&(o.current=L,d.current=z)}catch(e){x.push({code:"RELOAD_ADMIN_EXPRESSIONS_FAILED",message:a(e)})}if(j){console.info("[useImplementationFiles] Reloading component optics");try{F.current=_=await l(v.components.map(e=>e.file.name),M)}catch(e){console.warn("[useImplementationFiles] Failed to reload components:",e),x.push({code:"RELOAD_COMPONENTS_FAILED",message:a(e)})}}if(V){console.info("[useImplementationFiles] Reloading invariant implementations");try{h.current=S=await m(v.invariants.map(e=>e.file.name),M),g.current=k,E.current=X}catch(e){console.warn("[useImplementationFiles] Failed to reload invariants:",e),x.push({code:"RELOAD_INVARIANTS_FAILED",message:a(e)})}}if(P){console.info("[useImplementationFiles] Reloading transformer implementations");try{w.current=$=await c(v.transformers.map(e=>e.file.name),M)}catch(e){console.warn("[useImplementationFiles] Failed to reload transformers:",e),x.push({code:"RELOAD_TRANSFORMERS_FAILED",message:a(e)})}}let B=null;if(H){console.info("[useImplementationFiles] Reloading handler implementations");try{let e=Object.fromEntries(v.handlers.map(e=>[e.file.name,e.depHash])),n=y.current,t=t=>null===n||n[t]!==e[t],r=O.current,a=v.handlers.map(e=>e.file.name),o=a.filter(e=>t(e)||!r.has(e)),s=await p(o,M),i=new Map(s.map(e=>[e.filePath,e])),l=a.map(e=>{let n=i.get(e)??r.get(e);if(!n)throw Error(`Handler file "${e}" was neither re-imported nor cached from a previous round. This is a hot-reload bookkeeping bug — reload the editor page to recover.`);return n}),m=l.flatMap(e=>e.registrations),c={};for(let{filePath:n,registrations:r}of l){let a=t(n)?e[n]:void 0;if(a)for(let e of r)c[e.name]=a}console.info(`[useImplementationFiles] Staged handlers for registry (${m.length} total)`),B={handlers:m,nameHashes:c},O.current=new Map(l.map(e=>[e.filePath,e])),y.current=e}catch(e){console.warn("[useImplementationFiles] Failed to reload handlers:",e),x.push({code:"RELOAD_HANDLERS_FAILED",message:a(e)})}}let G=null;if(T){console.info("[useImplementationFiles] Reloading element implementations");try{let e=Object.fromEntries(v.elements.map(e=>[e.file.name,e.depHash])),n=I.current,t=t=>null===n||n[t]!==e[t],r=A.current,a=v.elements.map(e=>e.file.name),o=a.filter(e=>t(e)||!r.has(e)),s=await u(o,M),i=new Map(s.map(e=>[e.filePath,e])),l=a.map(e=>{let n=i.get(e)??r.get(e);if(!n)throw Error(`Element file "${e}" was neither re-imported nor cached from a previous round. This is a hot-reload bookkeeping bug — reload the editor page to recover.`);return n}),m=l.flatMap(e=>e.registrations),c={},p=0;for(let{filePath:n,registrations:r}of l){let a=t(n)?e[n]:void 0;for(let e of r){if("entity"===e.type||"layout"===e.type){a&&(c[e.name]=a);continue}a&&(c[`icon:${p}`]=a),p+=1}}console.info(`[useImplementationFiles] Staged elements for registry (${m.length} total)`),G={elements:m,nameHashes:c},A.current=new Map(l.map(e=>[e.filePath,e])),I.current=e}catch(e){console.warn("[useImplementationFiles] Failed to reload elements:",e),x.push({code:"RELOAD_ELEMENTS_FAILED",message:a(e)})}}return{implementations:D,actionImplementations:q,adminImplementations:L,invariantImplementations:S,importedTransformers:$,customComponentOptics:_,handlers:B,elements:G,errors:x}},[])}};
@@ -5,8 +5,8 @@ import type { AssistantSpec } from '#package/application-spec';
5
5
  * because the conventions it describes belong to this SDK version and not to the server. The part
6
6
  * about changes is left out when the schema has no `Mutation` type, the part about adding
7
7
  * entities when it has no `addChild` mutation, the part about replacing them when it has no
8
- * `replaceEntity` mutation, and the part about the choices of a field when it has
9
- * no options edge. The last section explains the
8
+ * `replaceEntity` mutation, the part about the choices of a field when it has
9
+ * no options edge, and the part about custom changes when the manifest exposes no action. The last section explains the
10
10
  * `query` and `apply` tools, which every run registers whatever the schema holds.
11
11
  */
12
12
  export declare const generateAssistantPrompt: (assistant: NonNullable<AssistantSpec>) => string;
@@ -1 +1 @@
1
- let e=["How to read the GraphQL schema of this configurator:","- A configuration is a set of entities. `root` is the root entity, `entities` lists every entity or the ones with the given ids, and `selectedEntity` is the entity the user has selected, or the root entity when nothing is selected.","- Every entity has an `id` of the form `<Type>-<number>`, for example `Table-1`, and a `type` with its entity type name. Ids are assigned by the configurator: read them from the configuration and never make one up.","- A field whose name starts with `_` is computed by the configurator from other values. It can be read like any other field and never written.","- Numbers are in the units the configuration stores them in. A field description names the unit when the product defines one.",'- A text field that only takes fixed values lists them in its description as "One of: ...". Use exactly those values.',"- A field typed as another entity type or as a list of one is a relation: select fields on it to read the related entities.","- Field and type descriptions come from the team that built the configurator and say what a value means for the product."],t=["How changes work:","- Every field of the `Mutation` type is one change. Its description says what it changes and what it returns.","- The configurator checks the whole configuration after each change. A change that would leave it invalid fails with an error that names the entities at fault, and it is not applied. Later changes of the same request are then not run.","- The configurator may adjust other values in response to a change, so read what a mutation returns instead of assuming the values you sent."],n=["How to add entities:","- Entities are added from recipes, the same ones the configurator offers the user. An entity type that can take children has a `meta` field; `meta { childRecipes }` lists its recipe groups and their recipes.","- List the recipes of the group first, pick one by its `key`, then call `addChild` with the id of the parent, the `groupId` and the `key`. Keys change with the configuration and the language, so never reuse one from memory.","- `dryRun` on a recipe shows what adding it would do without adding it: whether it is `ok`, the `changedEntities` it would add or modify, the `deletedEntityIds` it would remove, and the `errors` when it cannot be added. An entity whose id the configuration does not have yet is new. It is costly, so select it only on the recipes you are deciding between.","- Put each `addChild` in its own operation. The recipes of a group and what they add depend on the configuration before them, so after adding something, list the group again before adding from it once more."],a=["How to replace entities:","- An entity is replaced from recipes, the same ones the configurator offers the user. An entity type that can be replaced has a `meta` field; `meta { replaceRecipes }` lists its replace recipe groups and what the entity can be replaced with.","- List the recipes of the group first, pick one by its `key`, then call `replaceEntity` with the id of the entity, the `groupId` and the `key`. `dryRun` on a replace recipe shows what replacing would do without doing it: the replacement and everything else that changes are under `changedEntities`, and the replaced entity is among the `deletedEntityIds`.","- The replacement is a new entity with a new id, and its field values come from the recipe, so they can differ from those of the entity it replaces. Read the ids and values `replaceEntity` returns, and never use the old id again.","- Put each `replaceEntity` in its own operation. The recipes of a group and what they do depend on the configuration before them, so after replacing something, list the group of the replacement again before replacing once more."],i=["How to find the values a field can take:","- Some fields store a key whose choices the configurator holds elsewhere. Such a field has an edge under `meta` named after it: `meta { <field>Options }` lists its choices, each with the `value` to write and the `name` the user sees.","- Read the choices before you write such a field or name a choice to the user, and write the `value`, not the `name`. A value outside the list is rejected unless the edge description says the field is not checked.","- `dryRun` on an option shows what writing its value would do without writing it: whether it is `ok`, the `changedEntities` it would add or modify, the `deletedEntityIds` it would remove, and the `errors` when the value cannot be written. It is costly, so select it only on the options you are deciding between. It is null when the edge description says the options cannot be dry-run.","- The choices can depend on the entity and on its current state. Read them again after a change, unless the edge description says they are the same for all instances or do not change."],o=["How to use the `query` and `apply` tools:","- Both take `operations`, a list of GraphQL documents that run in order. Each document holds exactly one operation. To do several things, send several items in one call instead of several calls.","- Write values into the document as literals. Use `variables` only for a value that cannot be written as a literal.","- Select only the fields you need: results are returned whole.","- The result has one GraphQL result per operation, in the order sent. When an operation fails, its `errors` say why and the operations after it are not run.","- `query` reads the configuration the user has open and never changes it. Call it before you say anything about the configuration."],s=["- This configurator exposes no changes, so there is nothing for `apply` to run. Say so when the user asks you to change the configuration."],r=['- Mutations inside `query` answer "what if" questions. Each operation sees the changes of the ones before it, so a mutation followed by a query shows the configuration as it would be. Nothing is kept and the user sees no change.',"- `apply` makes the changes the user asked for. It is all or nothing: when any operation fails, nothing is changed; when all succeed, the user gets them as one undo step.","- `committed` in the result says whether the changes were kept. When it is false although no operation failed, `message` says why: the changes may be waiting for the approval of the user, the user may have changed the configuration meanwhile, or this session may not change the configuration at all. Without a `message`, the operations changed nothing. Never tell the user a change was made unless `committed` is true."];export const generateAssistantPrompt=h=>{let d=/^type Mutation\b/m.test(h.sdl);return[e,...d?[t]:[],.../^\s+addChild\(/m.test(h.sdl)?[n]:[],.../^\s+replaceEntity\(/m.test(h.sdl)?[a]:[],.../^type FieldOption\b/m.test(h.sdl)?[i]:[],[...o,...d?r:s]].map(e=>e.join("\n")).join("\n\n")};
1
+ let e=["How to read the GraphQL schema of this configurator:","- A configuration is a set of entities. `root` is the root entity, `entities` lists every entity or the ones with the given ids, and `selectedEntity` is the entity the user has selected, or the root entity when nothing is selected.","- Every entity has an `id` of the form `<Type>-<number>`, for example `Table-1`, and a `type` with its entity type name. Ids are assigned by the configurator: read them from the configuration and never make one up.","- A field whose name starts with `_` is computed by the configurator from other values. It can be read like any other field and never written.","- Numbers are in the units the configuration stores them in. A field description names the unit when the product defines one.",'- A text field that only takes fixed values lists them in its description as "One of: ...". Use exactly those values.',"- A field typed as another entity type or as a list of one is a relation: select fields on it to read the related entities.","- Field and type descriptions come from the team that built the configurator and say what a value means for the product."],t=["How changes work:","- Every field of the `Mutation` type is one change. Its description says what it changes and what it returns.","- The configurator checks the whole configuration after each change. A change that would leave it invalid fails with an error that names the entities at fault, and it is not applied. Later changes of the same request are then not run.","- The configurator may adjust other values in response to a change, so read what a mutation returns instead of assuming the values you sent."],a=["How to add entities:","- Entities are added from recipes, the same ones the configurator offers the user. An entity type that can take children has a `meta` field; `meta { childRecipes }` lists its recipe groups and their recipes.","- List the recipes of the group first, pick one by its `key`, then call `addChild` with the id of the parent, the `groupId` and the `key`. Keys change with the configuration and the language, so never reuse one from memory.","- `dryRun` on a recipe shows what adding it would do without adding it: whether it is `ok`, the `changedEntities` it would add or modify, the `deletedEntityIds` it would remove, and the `errors` when it cannot be added. An entity whose id the configuration does not have yet is new. It is costly, so select it only on the recipes you are deciding between.","- Put each `addChild` in its own operation. The recipes of a group and what they add depend on the configuration before them, so after adding something, list the group again before adding from it once more."],n=["How to replace entities:","- An entity is replaced from recipes, the same ones the configurator offers the user. An entity type that can be replaced has a `meta` field; `meta { replaceRecipes }` lists its replace recipe groups and what the entity can be replaced with.","- List the recipes of the group first, pick one by its `key`, then call `replaceEntity` with the id of the entity, the `groupId` and the `key`. `dryRun` on a replace recipe shows what replacing would do without doing it: the replacement and everything else that changes are under `changedEntities`, and the replaced entity is among the `deletedEntityIds`.","- The replacement is a new entity with a new id, and its field values come from the recipe, so they can differ from those of the entity it replaces. Read the ids and values `replaceEntity` returns, and never use the old id again.","- Put each `replaceEntity` in its own operation. The recipes of a group and what they do depend on the configuration before them, so after replacing something, list the group of the replacement again before replacing once more."],i=["How to find the values a field can take:","- Some fields store a key whose choices the configurator holds elsewhere. Such a field has an edge under `meta` named after it: `meta { <field>Options }` lists its choices, each with the `value` to write and the `name` the user sees.","- Read the choices before you write such a field or name a choice to the user, and write the `value`, not the `name`. A value outside the list is rejected unless the edge description says the field is not checked.","- `dryRun` on an option shows what writing its value would do without writing it: whether it is `ok`, the `changedEntities` it would add or modify, the `deletedEntityIds` it would remove, and the `errors` when the value cannot be written. It is costly, so select it only on the options you are deciding between. It is null when the edge description says the options cannot be dry-run.","- The choices can depend on the entity and on its current state. Read them again after a change, unless the edge description says they are the same for all instances or do not change."],o=["How the custom changes of this configurator work:","- Besides the generic changes, the `Mutation` type has fields the team built for this product. Each runs one domain operation the configurator itself uses, so prefer it over composing the same change from generic mutations. Its description says what it does and what its arguments mean.","- Its arguments are checked against what the operation declares; an argument that does not fit, or a change the product does not allow, fails the field with a message that says what to send instead.","- It returns an object whose fields the description names; a field typed as an entity reads that entity after the change."],s=["How to use the `query` and `apply` tools:","- Both take `operations`, a list of GraphQL documents that run in order. Each document holds exactly one operation. To do several things, send several items in one call instead of several calls.","- Write values into the document as literals. Use `variables` only for a value that cannot be written as a literal.","- Select only the fields you need: results are returned whole.","- The result has one GraphQL result per operation, in the order sent. When an operation fails, its `errors` say why and the operations after it are not run.","- `query` reads the configuration the user has open and never changes it. Call it before you say anything about the configuration."],r=["- This configurator exposes no changes, so there is nothing for `apply` to run. Say so when the user asks you to change the configuration."],h=['- Mutations inside `query` answer "what if" questions. Each operation sees the changes of the ones before it, so a mutation followed by a query shows the configuration as it would be. Nothing is kept and the user sees no change.',"- `apply` makes the changes the user asked for. It is all or nothing: when any operation fails, nothing is changed; when all succeed, the user gets them as one undo step.","- `committed` in the result says whether the changes were kept. When it is false although no operation failed, `message` says why: the changes may be waiting for the approval of the user, the user may have changed the configuration meanwhile, or this session may not change the configuration at all. Without a `message`, the operations changed nothing. Never tell the user a change was made unless `committed` is true."];export const generateAssistantPrompt=d=>{let c=/^type Mutation\b/m.test(d.sdl);return[e,...c?[t]:[],.../^\s+addChild\(/m.test(d.sdl)?[a]:[],.../^\s+replaceEntity\(/m.test(d.sdl)?[n]:[],.../^type FieldOption\b/m.test(d.sdl)?[i]:[],...Object.keys(d.actions).length>0?[o]:[],[...s,...c?h:r]].map(e=>e.join("\n")).join("\n\n")};