@salsita-ai/sdk 0.50.0-develop.da56a0c6c3 → 0.50.0-develop.ea458ea381
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application-spec/errors/diagnostic-codes.d.ts +6 -0
- package/dist/application-spec/errors/diagnostic-codes.js +1 -1
- package/dist/application-spec/errors/diagnostic-messages.d.ts +6 -0
- package/dist/application-spec/errors/diagnostic-messages.js +1 -1
- package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
- package/dist/application-spec/generate-application/code/templates/application-types.js +6 -6
- package/dist/application-spec/generate-application/code/templates/configurator-domain-code.d.ts +1 -0
- package/dist/application-spec/generate-application/code/templates/configurator-domain-code.js +11 -8
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.d.ts +3 -1
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-domain-block.js +70 -66
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-phx-globals.js +3 -0
- package/dist/application-spec/generate-application/code/templates/domain-spec.js +5 -5
- package/dist/application-spec/generate-application/code/templates/domain.js +2 -2
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.d.ts +11 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.js +8 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/index.d.ts +1 -0
- package/dist/application-spec/generate-application/code/templates/global-definition/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/globals.js +1 -0
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js +4 -2
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +3 -1
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +2 -2
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.d.ts +2 -0
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/sections/actions-runtime.d.ts +14 -0
- package/dist/application-spec/generate-application/runtime/sections/actions-runtime.js +1 -0
- package/dist/application-spec/generate-application/runtime/sections/index.d.ts +1 -0
- package/dist/application-spec/generate-application/runtime/sections/index.js +1 -1
- package/dist/application-spec/parse-application-files/categorize/categorize-files.d.ts +3 -1
- package/dist/application-spec/parse-application-files/categorize/categorize-files.js +1 -1
- package/dist/application-spec/parse-application-files/merge/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/merge/index.js +1 -1
- package/dist/application-spec/parse-application-files/merge/merged-actions.d.ts +11 -0
- package/dist/application-spec/parse-application-files/merge/merged-actions.js +1 -0
- package/dist/application-spec/parse-application-files/merge/merged-spec.d.ts +2 -0
- package/dist/application-spec/parse-application-files/merge/merged-spec.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/raw-spec/index.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-actions.d.ts +18 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-actions.js +1 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.d.ts +14 -2
- package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.js +1 -1
- package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.d.ts +2 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.js +1 -1
- package/dist/application-spec/parse-application-files/resolve/resolve-import-modules.js +1 -1
- package/dist/application-spec/parse-application-files/spec/application/application-spec.js +1 -1
- package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.d.ts +4 -2
- package/dist/application-spec/parse-application-files/spec/application/configurator-spec/configurator-spec.js +1 -1
- package/dist/application-spec/parse-application-files/spec/common/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/spec/common/index.js +1 -1
- package/dist/application-spec/parse-application-files/spec/common/schema-ref-resolver.d.ts +23 -0
- package/dist/application-spec/parse-application-files/spec/common/schema-ref-resolver.js +1 -0
- package/dist/application-spec/parse-application-files/spec/model/names/action-name.d.ts +10 -0
- package/dist/application-spec/parse-application-files/spec/model/names/action-name.js +1 -0
- package/dist/application-spec/parse-application-files/spec/model/names/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/spec/model/names/index.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/actions.d.ts +35 -0
- package/dist/application-spec/parse-application-files/spec/sections/actions.js +1 -0
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.d.ts +3 -14
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-field-type.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +12 -3
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
- package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant.d.ts +5 -3
- package/dist/application-spec/parse-application-files/spec/sections/index.d.ts +1 -0
- package/dist/application-spec/parse-application-files/spec/sections/index.js +1 -1
- package/dist/configurator/application-runtime/extensions/configurator-extension-systems.d.ts +2 -1
- package/dist/configurator/application-runtime/extensions/configurator-extension-systems.js +1 -1
- package/dist/configurator/application-runtime/extensions/selectors.d.ts +2 -1
- package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +35 -0
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -0
- package/dist/configurator/{assistant → application-runtime/extensions/systems/assistant-system}/browser-details.d.ts +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/browser-details.js +1 -0
- package/dist/configurator/{assistant → application-runtime/extensions/systems/assistant-system}/graphql-tools.d.ts +13 -14
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -0
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/index.d.ts +1 -0
- package/dist/configurator/application-runtime/extensions/systems/index.js +1 -1
- package/dist/configurator/assistant/use-assistant-chat.js +1 -1
- package/dist/docs/index.json +12 -2
- package/dist/docs/other-features/domain-actions.mdx +418 -0
- package/dist/docs/phoenix/best-practices.mdx +1 -0
- package/dist/docs/phoenix/phoenix-cli.mdx +4 -2
- package/dist/docs/phoenix/project-structure.mdx +3 -0
- package/dist/docs/phoenix/sdk-builder-workflow.mdx +2 -2
- package/dist/domain/actions/action-factory.d.ts +10 -0
- package/dist/domain/actions/action-factory.js +1 -0
- package/dist/domain/actions/prepare-action-implementations.d.ts +15 -0
- package/dist/domain/actions/prepare-action-implementations.js +5 -0
- package/dist/domain/application/application-config.d.ts +3 -1
- package/dist/domain/application/assistant-mutations.d.ts +15 -14
- package/dist/domain/application/assistant-mutations.js +1 -1
- package/dist/domain/core/action.d.ts +67 -0
- package/dist/domain/core/action.js +1 -0
- package/dist/domain/core/domain-factory.d.ts +4 -0
- package/dist/domain/core/index.d.ts +1 -0
- package/dist/domain/domain-builder.d.ts +7 -0
- package/dist/domain/domain-builder.js +1 -1
- package/dist/domain/domain-context/action-system/action-system.d.ts +40 -0
- package/dist/domain/domain-context/action-system/action-system.js +1 -0
- package/dist/domain/domain-context/domain-context-systems.d.ts +5 -2
- package/dist/domain/domain-context/index.d.ts +1 -0
- package/dist/domain/domain-context/index.js +1 -1
- package/dist/domain/domain-runtime/domain-context/domain-context.js +1 -1
- package/dist/domain/domain-runtime/domain-context/selectors.d.ts +4 -0
- package/dist/domain/domain-runtime/domain-context/selectors.js +1 -1
- package/dist/domain/domain-runtime/domain-runtime.d.ts +12 -0
- package/dist/domain/domain-runtime/spec/initialize.js +1 -1
- package/dist/domain/domain-runtime/spec/types.d.ts +15 -1
- package/dist/domain/index.d.ts +2 -0
- package/dist/domain/index.js +1 -1
- package/dist/domain/mocks/create-mock-domain-runtime.d.ts +6 -0
- package/dist/editor/domain-editors/DomainSpecContext.js +1 -1
- package/dist/editor/domain-editors/apply-spec-update.js +1 -1
- package/dist/editor/domain-editors/use-implementation-files.d.ts +7 -3
- package/dist/editor/domain-editors/use-implementation-files.js +1 -1
- package/dist/phoenix/application-spec/generate-assistant-prompt.d.ts +2 -2
- package/dist/phoenix/application-spec/generate-assistant-prompt.js +1 -1
- package/dist/phoenix/commands/login.d.ts +24 -6
- package/dist/phoenix/commands/login.js +2 -2
- package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +12 -0
- package/dist/react-sdk/domain-context/common-hooks/use-domain-context.d.ts +3 -0
- package/package.json +3 -3
- package/dist/configurator/assistant/browser-details.js +0 -1
- package/dist/configurator/assistant/graphql-tools.js +0 -1
|
@@ -1,87 +1,90 @@
|
|
|
1
|
-
import{skipApplicationTypeImports as e}from"../../common/index.js";import{generateComponentOpticsCode as n}from"./generate-component-optics.js";import{generateDefaultsBlock as t}from"./generate-defaults.js";import{generateInvariantsBlock as
|
|
1
|
+
import{skipApplicationTypeImports as e}from"../../common/index.js";import{generateComponentOpticsCode as n}from"./generate-component-optics.js";import{generateDefaultsBlock as t}from"./generate-defaults.js";import{generateInvariantsBlock as i}from"./generate-invariants.js";import{generateRelationExpressionsCode as a}from"./generate-relation-expressions.js";import{generateStaticValueCode as o}from"./generate-static-value-code.js";import{generateValueExpressionsCode as s}from"./generate-value-expressions.js";let r="@salsita-ai/sdk/domain",m=(e,n,t)=>{let i=[],a=[];for(let o of e.modelVersion.entitySchemas){let e=JSON.stringify(o.shapeSchema,null,2);i.push(`${t}const ${o.entityType} = new DomainEntityReflection<${n}${o.entityType}>('${o.entityType}', [${e}])`),a.push(String(o.entityType))}return{entityDecls:i.join("\n"),entityNames:a}};export const generateDomainBlock=l=>{let{domainSpec:$,invariants:p,actions:c,typePrefix:d,versionNsPrefix:u,isAdmin:y,modelVersionsExportName:h,relationExpressionsExportName:f,componentOpticsExportName:D,valueExpressionsExportName:E,createRecipeExportName:S,imports:R,registerApplicationTypeImports:g=e}=l;R.addImport(r,"$DomainEntityReflection"),R.addImport(r,"DomainBuilder"),R.addImport(r,"DomainComponentOpticBuilder"),R.addImport(r,"DomainEntityReflection"),R.addImport(r,"EnhancedAliasReflection"),R.addImport(r,"InvariantBuilder"),R.addImport(r,"RawAliasReflection"),R.addImport(r,"SchemaReflection"),R.addImport(r,"createCustomExpressionFactory"),R.addImport(r,"createCustomInvariantFactory"),y&&(R.addImport(r,"commonAdminCustomExpressions"),R.addImport(r,"commonAdminViolationExpressions"),R.addImport(r,"createMapPublishedRevisionDataHandlerFactory"),R.addImport(r,"createMapPublishedChunkedDataHandlerFactory"),R.addImport(r,"createDataRowValidatorHandler"),R.addImport(r,"createSheetValidatorHandler")),R.addTypeImport(r,"SchemaOfObject"),c&&(R.addImport(r,"createActionFactory"),R.addTypeImport(r,"ActionDefinition"));let{entityTypes:v,entitySchemas:x}=$.latestModel,A=[...$.latestModel.aliases],j=A.map(([e])=>String(e)),C=j.includes("RootEntity")?"RootEntity":"AnyDomainEntity",{resolvedVersions:I}=$,M=I.latestVersion,w=d?`${d}.`:"",B=new Map([...$.expressions.constants].map(([e,n])=>[String(e),n])),b=(e,n)=>{let t=[...B.get(n)?.keys()??[]],i=t.length>0?`, ${t.map(e=>`'${e}'`).join(" | ")}`:"";return`${e}<${w}$${n}${i}>`},P=e=>{let n=B.get(e);if(!n)return"{}";let t=[...n].map(([e,n])=>{let t=o(n,R).replaceAll("\n","\n ");return` ${e}: ${t},`});return`{
|
|
2
2
|
${t.join("\n")}
|
|
3
|
-
}`},
|
|
4
|
-
${
|
|
5
|
-
}`);else{let n=`${
|
|
3
|
+
}`},k=x.map(e=>{let n=JSON.stringify(e.shapeSchema,null,2);return` const ${e.entityType} = new DomainEntityReflection<${w}${e.entityType}>('${e.entityType}', [${n}])`}),F=A.map(([e,n])=>{let t=n.map(String).join(", ");return` const ${e} = new RawAliasReflection<${w}${e}>('${e}', [${t}])`}),H=[...$.latestModel.commonTypes],V=H.map(([e])=>String(e)),O=I.versionedModels.filter(e=>!e.isLatest).map(e=>`${u}${e.version}`);g(R,[...y?["Admin",...O]:[...v.map(String),...j,...V,...v.map(e=>`$${String(e)}`),...j.map(e=>`$${e}`),"Aliases","$Map",...O,...c?["ActionTypes","NavigationState","ViewState","ToolState","ExportState"]:[]],"PublishedData","SessionData","FrontendData",...y?[]:["BackendData"]]);let T=H.map(([e,n])=>{let t=JSON.stringify(n.runtimeSchema,null,2);return n.schema.enum?.length&&n.schema.enum.every(e=>"string"==typeof e)?` const ${e}: EnumLike<${w}${e}> = new EnumReflection('${e}', ${t}) as EnumLike<${w}${e}>`:` const ${e}: SchemaReflection<${w}${e}> = new SchemaReflection('${e}', ${t})`}),N=[...$.latestModel.shapes],J=N.map(([e,n])=>{let t=JSON.stringify(n.runtimeSchema,null,2);return` const ${e}Shape = new SchemaReflection('${e}Shape', ${t})`}),L=N.map(([e])=>`${e}Shape`),_=j.map(e=>` ${e}: ${e}.types,`).join("\n"),z=j.map(e=>` ${e},`).join("\n"),G=V.map(e=>` ${e},`).join("\n"),q=L.map(e=>` ${e},`).join("\n"),K=v.map(e=>` ${e},`).join("\n"),Q=[];for(let[e,n]of $.expressions.expressions)n.size>0&&Q.push(` const ${e}Expressions = ${JSON.stringify([...n.keys()])}`);let U=v.map(e=>{let n=$.expressions.entityExpressions.get(e),t=(n?.shapeGroups??[]).map(e=>`${e}Expressions`),i=t.length>0?t.map(e=>`...${e}`).join(", "):"",a=b("$DomainEntityReflection",String(e));return` const $${e}: ${a} = new ${a}('${e}', [${i}], ${P(String(e))})`}).join("\n"),W=v.map(e=>` ${e}: $${e},`).join("\n"),X=A.map(([e,n])=>{let t=n.map(e=>JSON.stringify(String(e))).join(", "),i=b("EnhancedAliasReflection",String(e));return` const $${e}: ${i} = new ${i}('$${e}', [${t}], ${P(String(e))})`}).join("\n"),Y=[...v.map(String),...j].map(e=>` $${e},`).join("\n"),Z=[],ee=[];for(let e of I.versionedModels)if(e.isLatest)Z.push(` ${e.version}: entities,`),ee.push(` readonly ${e.version}: {
|
|
4
|
+
${v.map(e=>` readonly ${String(e)}: DomainEntityReflection<${w}${String(e)}>`).join("\n")}
|
|
5
|
+
}`);else{let n=`${u}${e.version}.`,{entityDecls:t,entityNames:i}=m(e,n," "),a=i.map(e=>` ${e},`).join("\n");Z.push(` ${e.version}: (() => {
|
|
6
6
|
${t}
|
|
7
7
|
return {
|
|
8
|
-
${
|
|
8
|
+
${a}
|
|
9
9
|
} as const
|
|
10
|
-
})(),`),
|
|
11
|
-
${
|
|
12
|
-
}`)}let
|
|
13
|
-
const ${
|
|
14
|
-
|
|
15
|
-
const relationExpressions = ${
|
|
16
|
-
const componentOptics = ${n($.components,R)}`,
|
|
17
|
-
const valueExpressions = ${s($.expressions,R,"implementCustomExpressions",
|
|
18
|
-
const
|
|
10
|
+
})(),`),ee.push(` readonly ${e.version}: {
|
|
11
|
+
${i.map(e=>` readonly ${e}: DomainEntityReflection<${n}${e}>`).join("\n")}
|
|
12
|
+
}`)}let en=y?"adminDomainBuilder":"domainBuilder",et=y?"attachAdminComponent":"attachComponent",ei=y?"implementAdminCustomExpressions":"implementCustomExpressions",ea=y?"implementCustomAdminInvariants":"implementCustomInvariants",eo=y?"adminInvariantBuilder":"invariantBuilder",es=y?"adminModel":"model",er=y?"adminEnhancedModel":"enhancedModel",em=y?"implementAdminRelation":"implementRelation",el=y?"__adminDomain":"__configuratorDomain",e$="PublishedData, SessionData, FrontendData",ep=`${w}AnyDomainEntity, ${w}RootEntity, ${w}$Map, ${e$}, ${w}Aliases`,ec=`<${ep}>`,ed=i(p,ep,R),eu=(e,n)=>e===n?e:`${e}: ${n}`,ey=[...$.expressions.expressions.values()].some(e=>[...e.values()].some(e=>"relation"===e.implementation.kind));ey&&R.addImport(r,"createRelationFactory");let eh=ey?`
|
|
13
|
+
const ${em} = createRelationFactory${ec}(aliases)
|
|
14
|
+
|
|
15
|
+
const relationExpressions = ${a($.expressions,em)}`:"\n const relationExpressions = {} as const",ef=`
|
|
16
|
+
const componentOptics = ${n($.components,R)}`,eD=`
|
|
17
|
+
const valueExpressions = ${s($.expressions,R,"implementCustomExpressions",y?{PresetCategory:"commonAdminCustomExpressions.PresetCategory"}:{})}`;R.addImport(r,"RecipeFactoryBuilder");let eE=t($.defaults,R),eS=[...c?.values()??[]].map(e=>({name:String(e.name),...void 0===e.description?{}:{description:e.description},params:e.paramsSchema})),eR=c?`
|
|
18
|
+
const actionDefinitions: readonly ActionDefinition[] = ${JSON.stringify(eS,null,2).replaceAll("\n","\n ")}
|
|
19
|
+
|
|
20
|
+
const implementActions = createActionFactory<${w}AnyDomainEntity, ${w}RootEntity, ${w}$Map, ${e$}, NavigationState, ViewState, ToolState, ExportState, ActionTypes>()`:"",eg=`
|
|
21
|
+
const createRecipe = RecipeFactoryBuilder.forAliases<${w}AnyDomainEntity, ${w}Aliases>(aliases)
|
|
19
22
|
.forEntities(AnyDomainEntity.reflections)
|
|
20
23
|
.withDefaults(defaults)
|
|
21
|
-
.build()`,
|
|
22
|
-
${
|
|
23
|
-
}`,
|
|
24
|
-
${
|
|
25
|
-
}`,
|
|
26
|
-
${
|
|
24
|
+
.build()`,ev=[...v.map(e=>` readonly ${String(e)}: DomainEntityReflection<${w}${String(e)}>`),...j.map(e=>` readonly ${e}: RawAliasReflection<${w}${e}>`),...H.map(([e,n])=>{let t=n.schema.enum?.length&&n.schema.enum.every(e=>"string"==typeof e)?"EnumLike":"SchemaReflection";return` readonly ${e}: ${t}<${w}${e}>`}),...L.map(e=>` readonly ${e}: SchemaReflection<unknown>`)].join("\n"),ex=`{
|
|
25
|
+
${ev}
|
|
26
|
+
}`,eA=[...v.map(e=>` readonly $${String(e)}: ${b("$DomainEntityReflection",String(e))}`),...j.map(e=>` readonly $${e}: ${b("EnhancedAliasReflection",e)}`)].join("\n"),ej=`{
|
|
27
|
+
${eA}
|
|
28
|
+
}`,eC=`{
|
|
29
|
+
${ee.join("\n")}
|
|
27
30
|
}`;return`const ${el} = (() => {
|
|
28
31
|
const modelVersion = ${M}
|
|
29
32
|
|
|
30
|
-
${
|
|
31
|
-
|
|
32
|
-
${P.join("\n")}
|
|
33
|
+
${eE}
|
|
33
34
|
|
|
34
35
|
${k.join("\n")}
|
|
35
36
|
|
|
36
|
-
${
|
|
37
|
+
${F.join("\n")}
|
|
38
|
+
|
|
39
|
+
${T.join("\n")}
|
|
37
40
|
|
|
38
41
|
${J.join("\n")}
|
|
39
42
|
|
|
40
43
|
const aliases = {
|
|
41
|
-
${
|
|
44
|
+
${_}
|
|
42
45
|
} as const
|
|
43
46
|
|
|
44
47
|
const entities = {
|
|
45
|
-
${
|
|
48
|
+
${K}
|
|
46
49
|
} as const
|
|
47
50
|
|
|
48
51
|
const model = {
|
|
49
|
-
${
|
|
50
|
-
${_}
|
|
52
|
+
${K}
|
|
51
53
|
${z}
|
|
52
54
|
${G}
|
|
55
|
+
${q}
|
|
53
56
|
} as const
|
|
54
57
|
|
|
55
|
-
${
|
|
56
|
-
${Q}
|
|
57
|
-
${W}
|
|
58
|
-
const $entityReflections = {
|
|
58
|
+
${Q.length>0?Q.join("\n")+"\n":""}
|
|
59
59
|
${U}
|
|
60
|
+
${X}
|
|
61
|
+
const $entityReflections = {
|
|
62
|
+
${W}
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
const enhancedModel = {
|
|
63
|
-
${
|
|
66
|
+
${Y}
|
|
64
67
|
} as const
|
|
65
68
|
|
|
66
|
-
const implementCustomExpressions = createCustomExpressionFactory${
|
|
67
|
-
${
|
|
68
|
-
${
|
|
69
|
+
const implementCustomExpressions = createCustomExpressionFactory${ec}({})
|
|
70
|
+
${eR}${eh}
|
|
71
|
+
${eD}
|
|
69
72
|
|
|
70
73
|
const modelVersions = {
|
|
71
|
-
${
|
|
74
|
+
${Z.join("\n")}
|
|
72
75
|
} as const
|
|
73
|
-
const attachComponent = DomainComponentOpticBuilder.from${
|
|
74
|
-
|
|
75
|
-
${
|
|
76
|
-
const invariantBuilder = new InvariantBuilder${
|
|
77
|
-
${
|
|
78
|
-
const createMapPublishedRevisionDataHandler = createMapPublishedRevisionDataHandlerFactory<${
|
|
79
|
-
const createMapPublishedChunkedDataHandler = createMapPublishedChunkedDataHandlerFactory<${
|
|
80
|
-
`:""}${
|
|
81
|
-
${
|
|
76
|
+
const attachComponent = DomainComponentOpticBuilder.from${ec}(aliases)
|
|
77
|
+
|
|
78
|
+
${ed}
|
|
79
|
+
const invariantBuilder = new InvariantBuilder${ec}(aliases)${y?"\n .withInvariants(implementCustomInvariants(commonAdminViolationExpressions))":""}
|
|
80
|
+
${y?`
|
|
81
|
+
const createMapPublishedRevisionDataHandler = createMapPublishedRevisionDataHandlerFactory<${w}AnyDomainEntity, ${w}RootEntity, ${w}$Map, PublishedData>()
|
|
82
|
+
const createMapPublishedChunkedDataHandler = createMapPublishedChunkedDataHandlerFactory<${w}AnyDomainEntity, ${w}RootEntity, ${w}$Map>()
|
|
83
|
+
`:""}${ef}
|
|
84
|
+
${eg}
|
|
82
85
|
|
|
83
86
|
return {
|
|
84
|
-
domainBuilder: DomainBuilder.from${
|
|
87
|
+
domainBuilder: DomainBuilder.from${ec}(
|
|
85
88
|
entities,
|
|
86
89
|
aliases,
|
|
87
90
|
$entityReflections,
|
|
@@ -90,13 +93,13 @@ ${eE}
|
|
|
90
93
|
PublishedData,
|
|
91
94
|
SessionData,
|
|
92
95
|
FrontendData,
|
|
93
|
-
${
|
|
94
|
-
${
|
|
95
|
-
).withExpressions(valueExpressions),
|
|
96
|
-
attachComponent,
|
|
96
|
+
${y?"undefined":"BackendData"},
|
|
97
|
+
${y}
|
|
98
|
+
).withExpressions(valueExpressions)${c?".withActions(actionDefinitions)":""},
|
|
99
|
+
attachComponent,${c?"\n implementActions,":""}
|
|
97
100
|
implementCustomExpressions,
|
|
98
101
|
implementCustomInvariants,
|
|
99
|
-
invariantBuilder,${
|
|
102
|
+
invariantBuilder,${y?`
|
|
100
103
|
createMapPublishedRevisionDataHandler,
|
|
101
104
|
createMapPublishedChunkedDataHandler,`:""}
|
|
102
105
|
model,
|
|
@@ -110,20 +113,21 @@ ${eE}
|
|
|
110
113
|
})()
|
|
111
114
|
|
|
112
115
|
const {
|
|
113
|
-
${
|
|
114
|
-
${
|
|
115
|
-
${
|
|
116
|
-
${
|
|
117
|
-
${
|
|
116
|
+
${eu("domainBuilder",en)},
|
|
117
|
+
${eu("attachComponent",et)},
|
|
118
|
+
${eu("implementCustomExpressions",ei)},
|
|
119
|
+
${eu("implementCustomInvariants",ea)},
|
|
120
|
+
${eu("invariantBuilder",eo)},${y?`
|
|
118
121
|
createMapPublishedRevisionDataHandler,
|
|
119
|
-
createMapPublishedChunkedDataHandler
|
|
120
|
-
|
|
121
|
-
${
|
|
122
|
-
${
|
|
123
|
-
${
|
|
122
|
+
createMapPublishedChunkedDataHandler,`:`
|
|
123
|
+
implementActions,`}
|
|
124
|
+
${eu("relationExpressions",f)},
|
|
125
|
+
${eu("valueExpressions",E)},
|
|
126
|
+
${eu("componentOptics",D)},
|
|
127
|
+
${eu("createRecipe",S)},
|
|
124
128
|
} = ${el}
|
|
125
129
|
|
|
126
|
-
const ${
|
|
127
|
-
const ${
|
|
128
|
-
const ${
|
|
129
|
-
export { ${
|
|
130
|
+
const ${es}: ${ex} = ${el}.model
|
|
131
|
+
const ${er}: ${ej} = ${el}.enhancedModel
|
|
132
|
+
const ${h}: ${eC} = ${el}.modelVersions
|
|
133
|
+
export { ${en}, ${et}, ${ei}, ${ea}, ${eo}, ${es}, ${er}, ${f}, ${E}, ${D}, ${h}, ${S}${y?", createMapPublishedRevisionDataHandler, createMapPublishedChunkedDataHandler, createDataRowValidatorHandler, createSheetValidatorHandler":", implementActions"} }`};
|
|
@@ -10,6 +10,7 @@ globalThis.phx.domain = {
|
|
|
10
10
|
enhancedModel,
|
|
11
11
|
implementCustomExpressions,
|
|
12
12
|
implementCustomInvariants,
|
|
13
|
+
implementActions,
|
|
13
14
|
attachComponent,
|
|
14
15
|
createRecipe,
|
|
15
16
|
|
|
@@ -50,6 +51,7 @@ globalThis.phx.applicationTypes = {
|
|
|
50
51
|
readonly enhancedModel: typeof enhancedModel
|
|
51
52
|
readonly implementCustomExpressions: typeof implementCustomExpressions
|
|
52
53
|
readonly implementCustomInvariants: typeof implementCustomInvariants
|
|
54
|
+
readonly implementActions: typeof implementActions
|
|
53
55
|
readonly attachComponent: typeof attachComponent
|
|
54
56
|
readonly createRecipe: typeof createRecipe
|
|
55
57
|
readonly admin: {
|
|
@@ -69,6 +71,7 @@ globalThis.phx.applicationTypes = {
|
|
|
69
71
|
enhancedModel,
|
|
70
72
|
implementCustomExpressions,
|
|
71
73
|
implementCustomInvariants,
|
|
74
|
+
implementActions,
|
|
72
75
|
attachComponent,
|
|
73
76
|
createRecipe,
|
|
74
77
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{CodeImports as e,autoHeader as a,skipApplicationTypeImports as i}from"../common/index.js";import{generateApplicationMetadataBlock as o,generateAssistantBlock as n,generateBaseConfiguratorBuilder as t,generateChunksSpec as s,generateDataSchemaConstants as r,generateDataSpec as p,generateDomainBlock as m,generateLocaleCodegen as d,generatePhxGlobalsBlock as c,generateResourcesCodegen as l,generateStateConstants as
|
|
2
|
-
${
|
|
1
|
+
import{CodeImports as e,autoHeader as a,skipApplicationTypeImports as i}from"../common/index.js";import{generateApplicationMetadataBlock as o,generateAssistantBlock as n,generateBaseConfiguratorBuilder as t,generateChunksSpec as s,generateDataSchemaConstants as r,generateDataSpec as p,generateDomainBlock as m,generateLocaleCodegen as d,generatePhxGlobalsBlock as c,generateResourcesCodegen as l,generateStateConstants as u}from"./domain-spec/index.js";let x="@salsita-ai/sdk/domain",g="@salsita-ai/sdk/i18n";export const globalDomainSpecPhxBinding={generateBindingBlock:c,generateStateConstants:u,registerApplicationTypeImports:i};export const generateApplicationSpecDomainSpecFile=(i,c=globalDomainSpecPhxBinding)=>{let u=new e,{registerApplicationTypeImports:f}=c,E=m({domainSpec:i.configurator,invariants:i.configurator.invariants,actions:i.configurator.actions,typePrefix:"",versionNsPrefix:"ModelV",isAdmin:!1,modelVersionsExportName:"modelVersions",relationExpressionsExportName:"relationExpressions",componentOpticsExportName:"componentOptics",valueExpressionsExportName:"valueExpressions",createRecipeExportName:"createRecipe",imports:u,registerApplicationTypeImports:f}),S=m({domainSpec:i.admin,invariants:i.admin.invariants,actions:void 0,typePrefix:"Admin",versionNsPrefix:"AdminV",isAdmin:!0,modelVersionsExportName:"adminModelVersions",relationExpressionsExportName:"adminRelationExpressions",componentOpticsExportName:"adminComponentOptics",valueExpressionsExportName:"adminValueExpressions",createRecipeExportName:"createAdminRecipe",imports:u,registerApplicationTypeImports:f}),{hasResources:$}=l(i);u.addImport(x,"ConfiguratorBuilder"),u.addImport(x,"EnumReflection"),u.addTypeImport(x,"AssistantManifest"),u.addTypeImport(x,"ChunksSpec"),u.addTypeImport(x,"DataSpec"),u.addTypeImport(x,"EnumLike"),$&&u.addImport(x,"ResourceBuilder"),u.addImport(g,"mergeCatalogs"),u.addImport(g,"sdkCatalog"),u.addImport("@lingui/core","setupI18n");let k=r(i.configurator.dataSchemas,u,f),v=c.generateStateConstants({configuratorStates:i.configurator.states,adminStates:i.admin.states},u,f),I=o(i),{importBlock:N,catalogBlock:h,createI18nExport:A}=d(i.configurator.ui.availableLocales),{preBlock:B,builderBlock:C}=t(i,u,f),y=c.generateBindingBlock();return`${a("domain-spec.ts","Domain builders, model schemas, component optics and expression definitions derived from the spec.")}
|
|
2
|
+
${u.toString()}${N}
|
|
3
3
|
|
|
4
4
|
// ---- Data schemas ----
|
|
5
5
|
|
|
@@ -11,7 +11,7 @@ ${S}
|
|
|
11
11
|
|
|
12
12
|
// ---- Configurator domain ----
|
|
13
13
|
|
|
14
|
-
${
|
|
14
|
+
${E}
|
|
15
15
|
|
|
16
16
|
// ---- i18n ----
|
|
17
17
|
|
|
@@ -21,11 +21,11 @@ ${A}
|
|
|
21
21
|
|
|
22
22
|
// ---- Application metadata ----
|
|
23
23
|
|
|
24
|
-
${
|
|
24
|
+
${I}
|
|
25
25
|
|
|
26
26
|
// ---- State enums ----
|
|
27
27
|
|
|
28
|
-
${
|
|
28
|
+
${v}
|
|
29
29
|
|
|
30
30
|
const $dataSpec: DataSpec = ${p(i.dataSpec.entries)}
|
|
31
31
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{CodeImports as i}from"../common/code-imports.js";import{autoHeader as n}from"../common/file-headers.js";let o=/v(\d+)\.ts$/,t=(i,n)=>i.versionedModels.filter(i=>void 0!==i.migrationFile).map(i=>({version:i.version,file:i.migrationFile,importName:n?`${n}MigrateToV${i.version}`:`migrateToV${i.version}`})),s=i=>i.map(i=>{let n=i.file.replace(o,`v${i.version}.js`),t=`migrateToV${i.version}`,s=i.importName!==t?` as ${i.importName}`:"";return`import { ${t}${s} } from '../${n}'`}).join("\n"),e=(i,n,o,t)=>[`const ${t}Migrations = {`,...i.map(i=>` ${i.version}: ${i.importName},`),"}","",`const ${t} = MigrateFunctionBuilder`,` .fromVersions(${n})`,` .to(${o})`,` .using(${t}Migrations)`," .build()"].join("\n");export const generateApplicationSpecDomainFile=o=>{let r=new i,a="./domain-spec.js",m="./configurator-domain-code.js",d="./admin-domain-code.js",p=i=>[...i.expressions.values()].some(i=>[...i.values()].some(i=>"relation"===i.implementation.kind)),l=p(o.configurator.expressions),c=p(o.admin.expressions),u=t(o.configurator.resolvedVersions,""),I=t(o.admin.resolvedVersions,"admin"),g=u.length>0,h=I.length>0;r.addImport(a,"baseConfiguratorBuilder"),r.addImport(a,"domainBuilder"),r.addImport(a,"adminDomainBuilder"),r.addImport(a,"attachComponent"),r.addImport(a,"attachAdminComponent"),r.addImport(a,"implementCustomExpressions"),r.addImport(a,"implementAdminCustomExpressions"),r.addImport(a,"createI18n"),r.addImport(a,"componentOptics"),r.addImport(a,"adminComponentOptics"),r.addImport(a,"invariantBuilder"),r.addImport(a,"adminInvariantBuilder"),r.addImport(m,"customExpressions"),r.addImport(m,"customInvariants"),r.addImport(d,"customAdminExpressions"),r.addImport(d,"customAdminInvariants"),l&&r.addImport(a,"relationExpressions"),c&&r.addImport(a,"adminRelationExpressions"),(g||h)&&r.addImport("@salsita-ai/sdk/domain","MigrateFunctionBuilder"),g&&r.addImport(a,"modelVersions"),h&&r.addImport(a,"adminModelVersions");let x=[];g&&x.push(s(u)),h&&x.push(s(I));let v=x.length>0?"\n"+x.join("\n")+"\n":"",$=[];g&&$.push(e(u,"modelVersions",o.configurator.schemaVersion,"migrate")),h&&$.push(e(I,"adminModelVersions",o.admin.schemaVersion,"migrateAdmin"));let E=$.length>0?"\n"+$.join("\n\n")+"\n":"",f=["const domainFactory = domainBuilder",l?" .withExpressions(relationExpressions)":null," .withExpressions(invariantBuilder.withInvariants(customInvariants).buildViolationExpressions())"," .withExpressions(customExpressions)",g?" .withMigrate(migrate)":null," .build()"].filter(Boolean).join("\n"),
|
|
1
|
+
import{CodeImports as i}from"../common/code-imports.js";import{autoHeader as n}from"../common/file-headers.js";let o=/v(\d+)\.ts$/,t=(i,n)=>i.versionedModels.filter(i=>void 0!==i.migrationFile).map(i=>({version:i.version,file:i.migrationFile,importName:n?`${n}MigrateToV${i.version}`:`migrateToV${i.version}`})),s=i=>i.map(i=>{let n=i.file.replace(o,`v${i.version}.js`),t=`migrateToV${i.version}`,s=i.importName!==t?` as ${i.importName}`:"";return`import { ${t}${s} } from '../${n}'`}).join("\n"),e=(i,n,o,t)=>[`const ${t}Migrations = {`,...i.map(i=>` ${i.version}: ${i.importName},`),"}","",`const ${t} = MigrateFunctionBuilder`,` .fromVersions(${n})`,` .to(${o})`,` .using(${t}Migrations)`," .build()"].join("\n");export const generateApplicationSpecDomainFile=o=>{let r=new i,a="./domain-spec.js",m="./configurator-domain-code.js",d="./admin-domain-code.js",p=i=>[...i.expressions.values()].some(i=>[...i.values()].some(i=>"relation"===i.implementation.kind)),l=p(o.configurator.expressions),c=p(o.admin.expressions),u=t(o.configurator.resolvedVersions,""),I=t(o.admin.resolvedVersions,"admin"),g=u.length>0,h=I.length>0;r.addImport(a,"baseConfiguratorBuilder"),r.addImport(a,"domainBuilder"),r.addImport(a,"adminDomainBuilder"),r.addImport(a,"attachComponent"),r.addImport(a,"attachAdminComponent"),r.addImport(a,"implementCustomExpressions"),r.addImport(a,"implementAdminCustomExpressions"),r.addImport(a,"createI18n"),r.addImport(a,"componentOptics"),r.addImport(a,"adminComponentOptics"),r.addImport(a,"invariantBuilder"),r.addImport(a,"adminInvariantBuilder"),r.addImport(m,"customExpressions"),r.addImport(m,"customInvariants"),r.addImport(m,"customActions"),r.addImport(d,"customAdminExpressions"),r.addImport(d,"customAdminInvariants"),l&&r.addImport(a,"relationExpressions"),c&&r.addImport(a,"adminRelationExpressions"),(g||h)&&r.addImport("@salsita-ai/sdk/domain","MigrateFunctionBuilder"),g&&r.addImport(a,"modelVersions"),h&&r.addImport(a,"adminModelVersions");let x=[];g&&x.push(s(u)),h&&x.push(s(I));let v=x.length>0?"\n"+x.join("\n")+"\n":"",$=[];g&&$.push(e(u,"modelVersions",o.configurator.schemaVersion,"migrate")),h&&$.push(e(I,"adminModelVersions",o.admin.schemaVersion,"migrateAdmin"));let E=$.length>0?"\n"+$.join("\n\n")+"\n":"",f=["const domainFactory = domainBuilder",l?" .withExpressions(relationExpressions)":null," .withExpressions(invariantBuilder.withInvariants(customInvariants).buildViolationExpressions())"," .withExpressions(customExpressions)"," .withActionImplementations(customActions)",g?" .withMigrate(migrate)":null," .build()"].filter(Boolean).join("\n"),A=["const adminDomainFactory = adminDomainBuilder",c?" .withExpressions(adminRelationExpressions)":null," .withExpressions(adminInvariantBuilder.withInvariants(customAdminInvariants).buildViolationExpressions())"," .withExpressions(customAdminExpressions)",h?" .withMigrate(migrateAdmin)":null," .build()"].filter(Boolean).join("\n");return`${n("domain.ts","Assembles domain and admin domain factories from builders, migrations, expressions and invariants.")}
|
|
2
2
|
${r.toString()}
|
|
3
3
|
${v}export { attachComponent, attachAdminComponent, implementCustomExpressions, implementAdminCustomExpressions, createI18n }
|
|
4
4
|
${E}
|
|
5
5
|
${f}
|
|
6
|
-
${
|
|
6
|
+
${A}
|
|
7
7
|
|
|
8
8
|
export const configuratorBuilder = baseConfiguratorBuilder
|
|
9
9
|
.withDomainFactory(domainFactory)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PhoenixDefinitions } from '../../../../core/phoenix-definitions.js';
|
|
2
|
+
import type { Actions, ModelVersion } from '../../../../parse-application-files/index.js';
|
|
3
|
+
import type { CodeImports } from '../../common/code-imports.js';
|
|
4
|
+
/**
|
|
5
|
+
* Generates the `ActionTypes` map of the declared actions (name → `{ params, result }`) and the
|
|
6
|
+
* `ActionName`, `ActionParams<NAME>` and `ActionResult<NAME>` types derived from it. A nullable
|
|
7
|
+
* param is optional. The `description` of an action, a param and a result member becomes the doc
|
|
8
|
+
* comment of its property, so it shows wherever the types are used. Without actions the map is
|
|
9
|
+
* empty, so `ActionName` is `never`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const generateActionTypeDecls: (actions: Actions, model: ModelVersion, phxDefinitions: PhoenixDefinitions, imports: CodeImports, indent: number, typeOnlyImports?: boolean) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{schemaToTypeString as e}from"../common/schema-to-type-string.js";let t=(e,t)=>{let n=(e??"").trim().replaceAll("*/","*\\/").split("\n").map(e=>e.trim());return""===n[0]||void 0===n[0]?[]:1===n.length?[`${t}/** ${n[0]} */`]:[`${t}/**`,...n.map(e=>`${t} * ${e}`.trimEnd()),`${t} */`]};export const generateActionTypeDecls=(n,r,o,a,p,s=!1)=>{let i=" ".repeat(p),$=" ".repeat(p+2),c=" ".repeat(p+4),l=" ".repeat(p+6),m={phxDefinitions:o,commonTypeNames:new Set(r.commonTypes.keys()),imports:a,typeOnlyImports:s},y=[...n.values()].map(n=>{let r=Object.entries(n.params).flatMap(([n,{schema:r,required:o}])=>[...t(r.description,l),`${l}readonly ${n}${o?"":"?"}: ${e(r,m)}`]),o=Object.entries(n.result).flatMap(([n,r])=>[...t(r.description,l),`${l}readonly ${n}: ${e(r,m)}`]),a=e=>e.length>0?`{
|
|
2
|
+
${e.join("\n")}
|
|
3
|
+
${c}}`:"Record<string, never>";return[...t(n.description,$),`${$}readonly ${n.name}: {`,`${c}readonly params: ${a(r)}`,`${c}readonly result: ${a(o)}`,`${$}}`].join("\n")}),A=y.length>0?`{
|
|
4
|
+
${y.join("\n")}
|
|
5
|
+
${i}}`:"Record<never, never>";return`${i}type ActionTypes = ${A}
|
|
6
|
+
${i}type ActionName = keyof ActionTypes
|
|
7
|
+
${i}type ActionParams<NAME extends ActionName> = ActionTypes[NAME]['params']
|
|
8
|
+
${i}type ActionResult<NAME extends ActionName> = ActionTypes[NAME]['result']`};
|
package/dist/application-spec/generate-application/code/templates/global-definition/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { generateActionTypeDecls } from './generate-action-types.js';
|
|
1
2
|
export { generateModelTypeDecls } from './generate-model-types.js';
|
|
2
3
|
export { generateExpressionTypeDecls, generateEntityExpressionComposites } from './generate-expression-types.js';
|
|
3
4
|
export { generateDataSchemaTypeDecls } from './generate-data-schema-types.js';
|
package/dist/application-spec/generate-application/code/templates/global-definition/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{generateModelTypeDecls}from"./generate-model-types.js";export{generateExpressionTypeDecls,generateEntityExpressionComposites}from"./generate-expression-types.js";export{generateDataSchemaTypeDecls}from"./generate-data-schema-types.js";
|
|
1
|
+
export{generateActionTypeDecls}from"./generate-action-types.js";export{generateModelTypeDecls}from"./generate-model-types.js";export{generateExpressionTypeDecls,generateEntityExpressionComposites}from"./generate-expression-types.js";export{generateDataSchemaTypeDecls}from"./generate-data-schema-types.js";
|
|
@@ -73,6 +73,7 @@ ${h}
|
|
|
73
73
|
readonly enhancedModel: typeof import('./domain-spec.js').enhancedModel
|
|
74
74
|
readonly implementCustomExpressions: typeof import('./domain-spec.js').implementCustomExpressions
|
|
75
75
|
readonly implementCustomInvariants: typeof import('./domain-spec.js').implementCustomInvariants
|
|
76
|
+
readonly implementActions: typeof import('./domain-spec.js').implementActions
|
|
76
77
|
readonly attachComponent: typeof import('./domain-spec.js').attachComponent
|
|
77
78
|
readonly createRecipe: typeof import('./domain-spec.js').createRecipe
|
|
78
79
|
|
package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js
CHANGED
|
@@ -7,13 +7,15 @@ import{renderAgentSkill as e}from"./agent-skill.js";let i=`Review all current gi
|
|
|
7
7
|
- [ ] Relations properly define parent-child ownership (1-N, 0-1)
|
|
8
8
|
- [ ] Expressions have matching implementations in src/expressions/
|
|
9
9
|
- [ ] Invariants have matching implementations in src/invariants/
|
|
10
|
+
- [ ] Actions declared under actions: have matching implementations in src/actions/ (a missing one fails the type check of the generated barrel)
|
|
10
11
|
- [ ] Component bindings use correct entity types or aliases
|
|
11
12
|
- [ ] $read/$write/$bind reference valid properties or expressions
|
|
12
13
|
- [ ] A model that has been deployed is unchanged under its version: the change is in \`model.latest\`, the deployed model is kept as \`model.v<N>\`, and \`src/migrations/v<N+1>.ts\` migrates saved configurations
|
|
13
14
|
|
|
14
|
-
### Expressions & Invariants (src/expressions/, src/invariants/)
|
|
15
|
+
### Expressions, Actions & Invariants (src/expressions/, src/actions/, src/invariants/)
|
|
15
16
|
|
|
16
|
-
- [ ] Use phx.domain.implementCustomExpressions() / implementCustomInvariants()
|
|
17
|
+
- [ ] Use phx.domain.implementCustomExpressions() / implementActions() / implementCustomInvariants()
|
|
18
|
+
- [ ] Actions only prepare: they return updates and a readResult reader, never stage or commit, and throw messages that say what to send instead
|
|
17
19
|
- [ ] Expression names prefixed with $ in YAML match implementation
|
|
18
20
|
- [ ] No side effects in expressions (pure computed values only)
|
|
19
21
|
- [ ] Invariant violations return proper severity and messages
|
|
@@ -25,6 +25,7 @@ Declarative 3D product configurator built with Phoenix SDK. Domain model defined
|
|
|
25
25
|
readonly projectStructure: `## Project Structure
|
|
26
26
|
- \`spec/\` — Domain YAML specs (entities, relations, expressions, invariants, components, application config)
|
|
27
27
|
- \`src/expressions/\` — Computed/derived entity properties (\`phx.domain.implementCustomExpressions()\`)
|
|
28
|
+
- \`src/actions/\` — Domain operations declared under \`actions:\` in the spec (\`phx.domain.implementActions()\`), run by controls and exposed to the assistant
|
|
28
29
|
- \`src/invariants/\` — Business rule constraints (\`phx.domain.implementCustomInvariants()\`)
|
|
29
30
|
- \`src/transformers/\` — Automatic state fixers (\`phx.frontend.transformerBuilder\`)
|
|
30
31
|
- \`src/components/\` — ECS system components (\`phx.domain.attachComponent.withEntity()\`)
|
|
@@ -48,6 +49,7 @@ Declarative 3D product configurator built with Phoenix SDK. Domain model defined
|
|
|
48
49
|
/** Expressions, invariants, transformers, components, webhooks, and filters at a glance. */
|
|
49
50
|
readonly keyPatterns: `## Key Patterns
|
|
50
51
|
- Expressions = computed properties on entities (prefix: \`$\`), implemented per-entity in src/expressions/
|
|
52
|
+
- Actions = named domain operations (\`actions:\` in YAML with \`params\` and \`result\` schemas), implemented in src/actions/, prepared through \`actionSystem.prepareAction()\` and exposed as assistant mutations through \`assistant.actions\`
|
|
51
53
|
- Invariants = validation rules returning violations, static or dynamic
|
|
52
54
|
- Transformers = auto-fixers maintaining consistency after state changes
|
|
53
55
|
- Components defined in YAML with \`$read\`/\`$bind\` bindings, or custom in src/components/ using attachComponent builder
|
|
@@ -63,7 +65,7 @@ Declarative 3D product configurator built with Phoenix SDK. Domain model defined
|
|
|
63
65
|
- Underscore folders (_shared/, _utils/) are NOT auto-imported`;
|
|
64
66
|
/** The default-export rule of the SDK auto-import system. */
|
|
65
67
|
readonly exportRules: `## Export Rules
|
|
66
|
-
All files in src/expressions/, src/invariants/, src/transformers/, src/components/, src/handlers/, src/webhooks/ MUST use default exports. Can be a single item or an array. Named exports are ignored by the SDK auto-import system.`;
|
|
68
|
+
All files in src/expressions/, src/actions/, src/invariants/, src/transformers/, src/components/, src/handlers/, src/webhooks/ MUST use default exports. Can be a single item or an array. Named exports are ignored by the SDK auto-import system.`;
|
|
67
69
|
/** Which components and handlers are bundled into the webhook. */
|
|
68
70
|
readonly webhookMembership: `## Webhook Membership
|
|
69
71
|
- User-authored components, admin components, and handlers are frontend-only by default.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export const sdkGuidanceSections={projectIntro:`## Phoenix Configurator Project
|
|
2
2
|
|
|
3
|
-
Declarative 3D product configurator built with Phoenix SDK. Domain model defined in YAML, custom logic in TypeScript.`,buildCommands:"## Build Commands\n- `pnpm phoenix build` — Full production build\n- `pnpm phoenix dev` — Development mode with hot reload\n- `pnpm phoenix sync` — Sync generated files without full build",devLogs:"## Dev Logs\n- `pnpm phoenix dev` writes all logs to `.phoenix/phoenix-dev.log`\n- Contains: spec parse errors, build errors, browser runtime errors, file watcher events\n- After making changes, always check the log for errors: `tail -50 .phoenix/phoenix-dev.log` or `grep ERROR .phoenix/phoenix-dev.log`\n- Rotated automatically at 10MB (`.log.1`, `.log.2` are older rotations)",projectStructure:"## Project Structure\n- `spec/` — Domain YAML specs (entities, relations, expressions, invariants, components, application config)\n- `src/expressions/` — Computed/derived entity properties (`phx.domain.implementCustomExpressions()`)\n- `src/invariants/` — Business rule constraints (`phx.domain.implementCustomInvariants()`)\n- `src/transformers/` — Automatic state fixers (`phx.frontend.transformerBuilder`)\n- `src/components/` — ECS system components (`phx.domain.attachComponent.withEntity()`)\n- `src/elements/` — Page-level React components (`phx.frontend.createCustomPhoenixLayoutElement()`)\n- `src/handlers/` — Event & lifecycle handlers\n- `src/webhooks/` — Server-side webhook handlers (`phx.webhooks.*Builder`)\n- `src/migrations/` — Schema version migrations (v*.ts)\n- `src/locales/` — Locale catalogs (authored .po sources; compiled .ts, do not edit)\n- `src/admin/` — Admin interface (mirrors main src/ structure)\n- `src/_shared/` — Shared utilities (NOT auto-imported, requires explicit imports)\n- `.phoenix/` — Auto-generated files (DO NOT EDIT)\n- `public/` — Static assets (3D models, textures, images, HDRI maps, fonts)\n- `assets/` — Uploadable resources (PDF templates, email assets)",architecturePrinciples:"## Architecture Principles\n- YAML-first: 99% of configuration in spec/*.yaml, custom code is last resort\n- ECS pattern: entities (domain objects) + components (behavior/UI) + systems (SDK runtime)\n- Reactive state: immutable domain state flows through RxJS pipelines\n- Data binding: `$read` (read-only), `$write` (write-only), `$bind` (bidirectional) connect components to domain\n- memoEval: all component implementations must use memoEval for stable object references",keyPatterns:"## Key Patterns\n- Expressions = computed properties on entities (prefix: `$`), implemented per-entity in src/expressions/\n- Invariants = validation rules returning violations, static or dynamic\n- Transformers = auto-fixers maintaining consistency after state changes\n- Components defined in YAML with `$read`/`$bind` bindings, or custom in src/components/ using attachComponent builder\n- Webhooks = server-side finalization tasks (PDF, email, CSV, image rendering)\n- Filters = contextual component activation via navigationStates, viewStates, modes, selectedEntityIds",fileConventions:`## File Conventions
|
|
3
|
+
Declarative 3D product configurator built with Phoenix SDK. Domain model defined in YAML, custom logic in TypeScript.`,buildCommands:"## Build Commands\n- `pnpm phoenix build` — Full production build\n- `pnpm phoenix dev` — Development mode with hot reload\n- `pnpm phoenix sync` — Sync generated files without full build",devLogs:"## Dev Logs\n- `pnpm phoenix dev` writes all logs to `.phoenix/phoenix-dev.log`\n- Contains: spec parse errors, build errors, browser runtime errors, file watcher events\n- After making changes, always check the log for errors: `tail -50 .phoenix/phoenix-dev.log` or `grep ERROR .phoenix/phoenix-dev.log`\n- Rotated automatically at 10MB (`.log.1`, `.log.2` are older rotations)",projectStructure:"## Project Structure\n- `spec/` — Domain YAML specs (entities, relations, expressions, invariants, components, application config)\n- `src/expressions/` — Computed/derived entity properties (`phx.domain.implementCustomExpressions()`)\n- `src/actions/` — Domain operations declared under `actions:` in the spec (`phx.domain.implementActions()`), run by controls and exposed to the assistant\n- `src/invariants/` — Business rule constraints (`phx.domain.implementCustomInvariants()`)\n- `src/transformers/` — Automatic state fixers (`phx.frontend.transformerBuilder`)\n- `src/components/` — ECS system components (`phx.domain.attachComponent.withEntity()`)\n- `src/elements/` — Page-level React components (`phx.frontend.createCustomPhoenixLayoutElement()`)\n- `src/handlers/` — Event & lifecycle handlers\n- `src/webhooks/` — Server-side webhook handlers (`phx.webhooks.*Builder`)\n- `src/migrations/` — Schema version migrations (v*.ts)\n- `src/locales/` — Locale catalogs (authored .po sources; compiled .ts, do not edit)\n- `src/admin/` — Admin interface (mirrors main src/ structure)\n- `src/_shared/` — Shared utilities (NOT auto-imported, requires explicit imports)\n- `.phoenix/` — Auto-generated files (DO NOT EDIT)\n- `public/` — Static assets (3D models, textures, images, HDRI maps, fonts)\n- `assets/` — Uploadable resources (PDF templates, email assets)",architecturePrinciples:"## Architecture Principles\n- YAML-first: 99% of configuration in spec/*.yaml, custom code is last resort\n- ECS pattern: entities (domain objects) + components (behavior/UI) + systems (SDK runtime)\n- Reactive state: immutable domain state flows through RxJS pipelines\n- Data binding: `$read` (read-only), `$write` (write-only), `$bind` (bidirectional) connect components to domain\n- memoEval: all component implementations must use memoEval for stable object references",keyPatterns:"## Key Patterns\n- Expressions = computed properties on entities (prefix: `$`), implemented per-entity in src/expressions/\n- Actions = named domain operations (`actions:` in YAML with `params` and `result` schemas), implemented in src/actions/, prepared through `actionSystem.prepareAction()` and exposed as assistant mutations through `assistant.actions`\n- Invariants = validation rules returning violations, static or dynamic\n- Transformers = auto-fixers maintaining consistency after state changes\n- Components defined in YAML with `$read`/`$bind` bindings, or custom in src/components/ using attachComponent builder\n- Webhooks = server-side finalization tasks (PDF, email, CSV, image rendering)\n- Filters = contextual component activation via navigationStates, viewStates, modes, selectedEntityIds",fileConventions:`## File Conventions
|
|
4
4
|
- Components: PascalCase (.tsx)
|
|
5
5
|
- Utilities: kebab-case (.ts)
|
|
6
6
|
- Expressions: entity-name.ts
|
|
7
7
|
- Migrations: v*.ts (sequential)
|
|
8
8
|
- Specs: kebab-case.yaml
|
|
9
9
|
- Underscore folders (_shared/, _utils/) are NOT auto-imported`,exportRules:`## Export Rules
|
|
10
|
-
All files in src/expressions/, src/invariants/, src/transformers/, src/components/, src/handlers/, src/webhooks/ MUST use default exports. Can be a single item or an array. Named exports are ignored by the SDK auto-import system.`,webhookMembership:"## Webhook Membership\n- User-authored components, admin components, and handlers are frontend-only by default.\n- A handler that registers `createMapPublishedRevisionDataHandler`, `createMapPublishedChunkedDataHandler`, `createDataRowValidatorHandler`, or `createSheetValidatorHandler` is included in the webhook automatically.\n- To include another component or handler in the webhook, put `'use webhook'` as its first statement (leading comments are allowed).\n- A webhook-included file and its runtime local-import closure must not import browser SDK entrypoints (`application`, `admin`, `configurator`, `editor`, `react`, `ui`) or style/font/image assets. Spec parsing reports the unsafe import and inclusion reason as a diagnostic.\n- Keep browser rendering in an unpinned file. Move shared server-safe logic into a separate module when both frontend and webhook code need it.",doNotEdit:"## Do Not Edit\n- `.phoenix/` directory — completely regenerated on each build\n- `tsconfig.json`, `eslint.config.js`, `prettier.config.js`, `.prettierignore`, `.linguirc`, `.nvmrc`\n- `src/locales/` .ts files — compiled from .po files",modelVersioning:"## Version the Domain Model Once It Is Deployed\nA deployed model version cannot change, because saved configurations depend on it. `pnpm phoenix deploy` is refused, before anything is uploaded, when the model differs from the one already deployed under the same version. The version is not written anywhere: `model.latest` is always the highest numbered version plus one, so a spec with only `latest` is v1, and `applicationVersion` plays no part. `pnpm phoenix dev` accepts every model change, so a working preview does not show that the deploy will pass.\n\nTo change a model that has been deployed as v<N>:\n1. Keep the deployed model, unchanged, as `model.v<N>` in the spec. A file of its own, such as `spec/model-v<N>.yaml`, keeps `latest` readable.\n2. Make the change in `model.latest`, which is now v<N+1>.\n3. Add `src/migrations/v<N+1>.ts` exporting `migrateToV<N+1>`. It receives the saved entities of v<N> and returns entities that are valid in v<N+1>; `ModelV<N>` and `ModelV<N+1>` are generated global namespaces.\n\nThe admin model is versioned on its own, under `src/admin/migrations/`, with its types in `AdminV<N>`.\n\n**Replacing the starter.** When the first deployment of the workspace was the starter, its `Box` model is v1 in production. When the real model replaces it, keep the starter's model as `model.v1` and define the real model in `latest`. Configurations saved from the starter are not worth converting, so the migration returns the starting state of the new model, the `initialDomainEntities` of its preset, and drops the boxes:\n```typescript\n// src/migrations/v2.ts\nimport type { Migration } from '@salsita-ai/sdk/domain'\n\nexport const migrateToV2: Migration<ModelV1.AnyDomainEntity, ModelV2.AnyDomainEntity> = () => [\n // the entities of the new model's preset\n]\n```\nAn entity of a type the new version no longer has must not stay in the returned state. An entity id starts with its type (`Box-1`), so an entity that keeps its data under a new type name needs a new id and every relation pointing at it rewritten. Read `docs/phoenix/migrations.mdx` before writing any other migration.",sdkDocumentation:'## SDK Documentation\n\nAlways search SDK docs for relevant examples before implementing Phoenix features.\n\n### Commands\n- `pnpm phoenix docs` — Full documentation index with descriptions\n- `pnpm phoenix docs -s <term>` — Search all doc content and metadata (case-insensitive)\n- `pnpm phoenix docs --dir` — Print the absolute docs directory for grep or ripgrep\n- `pnpm phoenix docs -r <path>` — Read specific doc (raw text to stdout)\n- `pnpm phoenix docs -c <category>` — List docs in a category\n- `pnpm phoenix docs -l` — List all doc paths with titles\n\n### Key Docs\n- `docs/phoenix/getting-started.mdx` — Setup, prerequisites, first project\n- `docs/phoenix/quickstart.mdx` — End-to-end tutorial building a configurator\n- `docs/phoenix/domain-model.mdx` — Entities, attributes, relations, specs\n- `docs/phoenix/components.mdx` — ECS pattern, YAML components, custom components\n- `docs/phoenix/project-structure.mdx` — Files, folders, conventions\n- `docs/phoenix/best-practices.mdx` — YAML-first, code patterns, common pitfalls\n- `docs/phoenix/state-management.mdx` — Reactive state, RxJS pipelines, data flow\n- `docs/phoenix/expression-context.mdx` — Expression API, context object, helpers\n- `docs/phoenix/webhooks.mdx` — Server-side finalization workflows\n- `docs/phoenix/finalization.mdx` — Finalization system, PDF/email/CSV generation\n- `docs/phoenix/migrations.mdx` — Schema versioning, migration files\n\n### Agent Workflow\n1. Find relevant docs by content: `pnpm phoenix docs -s \'camera\'`\n2. Read matching doc: `pnpm phoenix docs -r docs/3d-scene/cameras/transitions.mdx`\n3. Search within a doc: `pnpm phoenix docs -r <path> | grep "example"`\n4. Search titles only as a fallback: `pnpm phoenix docs -l | grep "camera"`\n5. Search generated files directly when needed: `grep -rn "camera" "$(pnpm phoenix docs --dir)"`\n6. Browse a topic area: `pnpm phoenix docs -c "Layouts"`',assetInspection:"## 3D Asset Inspection\n\nRun `pnpm phoenix inspect:assets` to discover all glTF/GLB files in `public/` and get a summary table. Use `--file <path>` for detailed single-file inspection.\n\n**When to use:** before writing YAML/code that references objectName, materialsToOverride, morphTargetInfluences, or object positioning.\n\n**What it shows per node:**\n- Name, type (Mesh/Light/Camera/Empty), children\n- Transform: `pos=`, `rot=`, `scale=` (only non-default values shown)\n- Per-node morph targets: `morphs=Width,Height`\n- Bounding box: `bounds=WxHxD` (width x height x depth in meters)\n- Origin placement: `origin=center`, `bottom-center`, `top-center`, `bottom-corner`, etc. with numerical offset\n\n**Use cases:**\n- Find exact node names for `objectName` in scene entity components\n- Find material names for `materialsToOverride`\n- Find morph target names for `morphTargetInfluences`\n- Check model dimensions (bounds) for positioning, dimension indicators, or invariants\n- Check origin placement to understand how models anchor (center vs bottom-center)\n- Use `--json` for programmatic access to all data\n\n**Flags:** `--objects`, `--materials`, `--morphs`, `--animations`, `--json`",screenshotCli:"## Screenshot CLI\n\nCapture 3D canvas screenshots from a running dev server via `pnpm phoenix screenshot`.\n\n**Prerequisites:**\n1. `phoenix dev` must be running (starts the WebSocket server on port 3020)\n2. Configurator must be open in a browser (the browser does the actual rendering)\n\n**Options:**\n- `--output, -o` — Output file path (default: `./screenshot.png`)\n- `--width, -w` — Width in pixels (default: 1920)\n- `--height` — Height in pixels (default: 1080)\n- `--format, -f` — Image format: PNG or JPEG (default: PNG)\n- `--port` — WebSocket server port (default: 3020)\n\n**Example workflow:**\n1. Start dev server: `pnpm phoenix dev`\n2. Open configurator in browser (or via Playwright MCP)\n3. Take screenshot: `pnpm phoenix screenshot -o ./render.png -w 2560 --height 1440`\n\n**Use cases:** visual regression testing, generating product images, debugging 3D renders",inspectState:"## Inspect: State\n\nGet the current editor runtime state as JSON via `pnpm phoenix inspect:state`.\n\n**Prerequisites:** same as screenshot (dev server running + browser open)\n\n**Options:**\n- `--output, -o` — Output file path (prints to stdout if omitted)\n- `--sections, -s` — Comma-separated: entities, navigation, validation (default: all)\n- `--pretty` — Pretty-print JSON (default: true)\n- `--port` — WebSocket server port (default: 3020)\n\n**Example:** `pnpm phoenix inspect:state -o ./state.json -s entities,navigation`\n\n**Lifecycle status:** Always included in response. Shows which systems are ready:\n- `domainLoaded` — domain data loaded\n- `domainContextReady` — domain context initialized (entities available)\n- `configuratorReady` — 3D configurator initialized\n- `sessionAuthenticated` — session service active\n- `editorMode` — editor mode enabled\n\n**Tips:** Use `--sections` to limit payload size. Pipe through `head`/`tail` for partial output (e.g., `pnpm phoenix inspect:state | head -50`).\n\n**Use cases:** AI agent context, debugging entity state, inspecting navigation/validation",inspectData:`## Inspect: Data
|
|
10
|
+
All files in src/expressions/, src/actions/, src/invariants/, src/transformers/, src/components/, src/handlers/, src/webhooks/ MUST use default exports. Can be a single item or an array. Named exports are ignored by the SDK auto-import system.`,webhookMembership:"## Webhook Membership\n- User-authored components, admin components, and handlers are frontend-only by default.\n- A handler that registers `createMapPublishedRevisionDataHandler`, `createMapPublishedChunkedDataHandler`, `createDataRowValidatorHandler`, or `createSheetValidatorHandler` is included in the webhook automatically.\n- To include another component or handler in the webhook, put `'use webhook'` as its first statement (leading comments are allowed).\n- A webhook-included file and its runtime local-import closure must not import browser SDK entrypoints (`application`, `admin`, `configurator`, `editor`, `react`, `ui`) or style/font/image assets. Spec parsing reports the unsafe import and inclusion reason as a diagnostic.\n- Keep browser rendering in an unpinned file. Move shared server-safe logic into a separate module when both frontend and webhook code need it.",doNotEdit:"## Do Not Edit\n- `.phoenix/` directory — completely regenerated on each build\n- `tsconfig.json`, `eslint.config.js`, `prettier.config.js`, `.prettierignore`, `.linguirc`, `.nvmrc`\n- `src/locales/` .ts files — compiled from .po files",modelVersioning:"## Version the Domain Model Once It Is Deployed\nA deployed model version cannot change, because saved configurations depend on it. `pnpm phoenix deploy` is refused, before anything is uploaded, when the model differs from the one already deployed under the same version. The version is not written anywhere: `model.latest` is always the highest numbered version plus one, so a spec with only `latest` is v1, and `applicationVersion` plays no part. `pnpm phoenix dev` accepts every model change, so a working preview does not show that the deploy will pass.\n\nTo change a model that has been deployed as v<N>:\n1. Keep the deployed model, unchanged, as `model.v<N>` in the spec. A file of its own, such as `spec/model-v<N>.yaml`, keeps `latest` readable.\n2. Make the change in `model.latest`, which is now v<N+1>.\n3. Add `src/migrations/v<N+1>.ts` exporting `migrateToV<N+1>`. It receives the saved entities of v<N> and returns entities that are valid in v<N+1>; `ModelV<N>` and `ModelV<N+1>` are generated global namespaces.\n\nThe admin model is versioned on its own, under `src/admin/migrations/`, with its types in `AdminV<N>`.\n\n**Replacing the starter.** When the first deployment of the workspace was the starter, its `Box` model is v1 in production. When the real model replaces it, keep the starter's model as `model.v1` and define the real model in `latest`. Configurations saved from the starter are not worth converting, so the migration returns the starting state of the new model, the `initialDomainEntities` of its preset, and drops the boxes:\n```typescript\n// src/migrations/v2.ts\nimport type { Migration } from '@salsita-ai/sdk/domain'\n\nexport const migrateToV2: Migration<ModelV1.AnyDomainEntity, ModelV2.AnyDomainEntity> = () => [\n // the entities of the new model's preset\n]\n```\nAn entity of a type the new version no longer has must not stay in the returned state. An entity id starts with its type (`Box-1`), so an entity that keeps its data under a new type name needs a new id and every relation pointing at it rewritten. Read `docs/phoenix/migrations.mdx` before writing any other migration.",sdkDocumentation:'## SDK Documentation\n\nAlways search SDK docs for relevant examples before implementing Phoenix features.\n\n### Commands\n- `pnpm phoenix docs` — Full documentation index with descriptions\n- `pnpm phoenix docs -s <term>` — Search all doc content and metadata (case-insensitive)\n- `pnpm phoenix docs --dir` — Print the absolute docs directory for grep or ripgrep\n- `pnpm phoenix docs -r <path>` — Read specific doc (raw text to stdout)\n- `pnpm phoenix docs -c <category>` — List docs in a category\n- `pnpm phoenix docs -l` — List all doc paths with titles\n\n### Key Docs\n- `docs/phoenix/getting-started.mdx` — Setup, prerequisites, first project\n- `docs/phoenix/quickstart.mdx` — End-to-end tutorial building a configurator\n- `docs/phoenix/domain-model.mdx` — Entities, attributes, relations, specs\n- `docs/phoenix/components.mdx` — ECS pattern, YAML components, custom components\n- `docs/phoenix/project-structure.mdx` — Files, folders, conventions\n- `docs/phoenix/best-practices.mdx` — YAML-first, code patterns, common pitfalls\n- `docs/phoenix/state-management.mdx` — Reactive state, RxJS pipelines, data flow\n- `docs/phoenix/expression-context.mdx` — Expression API, context object, helpers\n- `docs/phoenix/webhooks.mdx` — Server-side finalization workflows\n- `docs/phoenix/finalization.mdx` — Finalization system, PDF/email/CSV generation\n- `docs/phoenix/migrations.mdx` — Schema versioning, migration files\n\n### Agent Workflow\n1. Find relevant docs by content: `pnpm phoenix docs -s \'camera\'`\n2. Read matching doc: `pnpm phoenix docs -r docs/3d-scene/cameras/transitions.mdx`\n3. Search within a doc: `pnpm phoenix docs -r <path> | grep "example"`\n4. Search titles only as a fallback: `pnpm phoenix docs -l | grep "camera"`\n5. Search generated files directly when needed: `grep -rn "camera" "$(pnpm phoenix docs --dir)"`\n6. Browse a topic area: `pnpm phoenix docs -c "Layouts"`',assetInspection:"## 3D Asset Inspection\n\nRun `pnpm phoenix inspect:assets` to discover all glTF/GLB files in `public/` and get a summary table. Use `--file <path>` for detailed single-file inspection.\n\n**When to use:** before writing YAML/code that references objectName, materialsToOverride, morphTargetInfluences, or object positioning.\n\n**What it shows per node:**\n- Name, type (Mesh/Light/Camera/Empty), children\n- Transform: `pos=`, `rot=`, `scale=` (only non-default values shown)\n- Per-node morph targets: `morphs=Width,Height`\n- Bounding box: `bounds=WxHxD` (width x height x depth in meters)\n- Origin placement: `origin=center`, `bottom-center`, `top-center`, `bottom-corner`, etc. with numerical offset\n\n**Use cases:**\n- Find exact node names for `objectName` in scene entity components\n- Find material names for `materialsToOverride`\n- Find morph target names for `morphTargetInfluences`\n- Check model dimensions (bounds) for positioning, dimension indicators, or invariants\n- Check origin placement to understand how models anchor (center vs bottom-center)\n- Use `--json` for programmatic access to all data\n\n**Flags:** `--objects`, `--materials`, `--morphs`, `--animations`, `--json`",screenshotCli:"## Screenshot CLI\n\nCapture 3D canvas screenshots from a running dev server via `pnpm phoenix screenshot`.\n\n**Prerequisites:**\n1. `phoenix dev` must be running (starts the WebSocket server on port 3020)\n2. Configurator must be open in a browser (the browser does the actual rendering)\n\n**Options:**\n- `--output, -o` — Output file path (default: `./screenshot.png`)\n- `--width, -w` — Width in pixels (default: 1920)\n- `--height` — Height in pixels (default: 1080)\n- `--format, -f` — Image format: PNG or JPEG (default: PNG)\n- `--port` — WebSocket server port (default: 3020)\n\n**Example workflow:**\n1. Start dev server: `pnpm phoenix dev`\n2. Open configurator in browser (or via Playwright MCP)\n3. Take screenshot: `pnpm phoenix screenshot -o ./render.png -w 2560 --height 1440`\n\n**Use cases:** visual regression testing, generating product images, debugging 3D renders",inspectState:"## Inspect: State\n\nGet the current editor runtime state as JSON via `pnpm phoenix inspect:state`.\n\n**Prerequisites:** same as screenshot (dev server running + browser open)\n\n**Options:**\n- `--output, -o` — Output file path (prints to stdout if omitted)\n- `--sections, -s` — Comma-separated: entities, navigation, validation (default: all)\n- `--pretty` — Pretty-print JSON (default: true)\n- `--port` — WebSocket server port (default: 3020)\n\n**Example:** `pnpm phoenix inspect:state -o ./state.json -s entities,navigation`\n\n**Lifecycle status:** Always included in response. Shows which systems are ready:\n- `domainLoaded` — domain data loaded\n- `domainContextReady` — domain context initialized (entities available)\n- `configuratorReady` — 3D configurator initialized\n- `sessionAuthenticated` — session service active\n- `editorMode` — editor mode enabled\n\n**Tips:** Use `--sections` to limit payload size. Pipe through `head`/`tail` for partial output (e.g., `pnpm phoenix inspect:state | head -50`).\n\n**Use cases:** AI agent context, debugging entity state, inspecting navigation/validation",inspectData:`## Inspect: Data
|
|
11
11
|
|
|
12
12
|
Get the current editor context data as JSON via \`pnpm phoenix inspect:data\`.
|
|
13
13
|
|
|
@@ -2,6 +2,7 @@ import { Branded } from '@salsita-ai/common/utils';
|
|
|
2
2
|
import type { ImportedTransformer } from '#package/domain';
|
|
3
3
|
import type { RuntimeReferenceStore } from '../../../caching/index.js';
|
|
4
4
|
import type { ApplicationSpec } from '../../../parse-application-files/index.js';
|
|
5
|
+
import { ActionsRuntime } from '../sections/actions-runtime.js';
|
|
5
6
|
import { AssistantRuntime } from '../sections/assistant-runtime.js';
|
|
6
7
|
import { ComponentOptics } from '../sections/component-optic.js';
|
|
7
8
|
import { type ExpressionImplementations, ExpressionRuntime, type InvariantImplementations, type MissingExpression } from '../sections/expression-runtime.js';
|
|
@@ -20,6 +21,7 @@ export type ConfiguratorRuntime = Branded<'ConfiguratorRuntime', {
|
|
|
20
21
|
readonly themeRuntime: ThemeRuntime;
|
|
21
22
|
readonly transformersRuntime: TransformersRuntime;
|
|
22
23
|
readonly assistantRuntime: AssistantRuntime;
|
|
24
|
+
readonly actionsRuntime: ActionsRuntime;
|
|
23
25
|
}>;
|
|
24
26
|
export type ConfiguratorRuntimeResult = {
|
|
25
27
|
readonly ok: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Branded as t}from"@salsita-ai/common/utils";import{AssistantRuntime as e}from"../sections/assistant-runtime.js";import{ComponentOptics as
|
|
1
|
+
import{Branded as t}from"@salsita-ai/common/utils";import{ActionsRuntime as o}from"../sections/actions-runtime.js";import{AssistantRuntime as e}from"../sections/assistant-runtime.js";import{ComponentOptics as r}from"../sections/component-optic.js";import{ExpressionRuntime as s}from"../sections/expression-runtime.js";import{PresetRuntime as i}from"../sections/preset-runtime.js";import{ThemeRuntime as n}from"../sections/theme-runtime.js";import{TransformersRuntime as m}from"../sections/transformers-runtime.js";import{ConfiguratorModelRuntime as u}from"./configurator-model-runtime.js";import{ConfiguratorStatesRuntime as c}from"./states-runtime.js";export const ConfiguratorRuntime=(p,a,f,g,R)=>{let j=u(p.configurator,a),x=s(p.configurator,a,f,"configuratorExpressionRuntime",R);return x.ok?{ok:!0,runtime:t({modelRuntime:j,componentOptics:r(a,{components:p.configurator.components,referenceScope:"configuratorRuntime/componentOptics",modelRuntime:j}),presetRuntime:i(a,{referenceScope:"configuratorRuntime/presetRuntime",presets:p.configurator.presets.presets}),statesRuntime:c(p,a),expressionRuntime:x.runtime,themeRuntime:n(p,a),transformersRuntime:m(p,a,g),assistantRuntime:e(p,a),actionsRuntime:o(p.configurator.actions,a)})}:{ok:!1,missingExpressions:x.missing}};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Branded } from '@salsita-ai/common/utils';
|
|
2
|
+
import type { ActionDefinitions } from '#package/domain';
|
|
3
|
+
import type { RuntimeReferenceStore } from '../../../caching/index.js';
|
|
4
|
+
import type { Actions } from '../../../parse-application-files/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* The declared actions as the runtime spec slice holds them, with change tracking: the definitions
|
|
7
|
+
* are rebuilt only when their declaration changes, so a hot reload of an unrelated section keeps
|
|
8
|
+
* the action system's compiled validators.
|
|
9
|
+
*/
|
|
10
|
+
export type ActionsRuntime = Branded<'ActionsRuntime', {
|
|
11
|
+
readonly definitions: ActionDefinitions;
|
|
12
|
+
readonly changed: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const ActionsRuntime: (actions: Actions, referenceStore: RuntimeReferenceStore) => ActionsRuntime;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import i from"lodash-es/isEqual.js";import{Branded as e}from"@salsita-ai/common/utils";export const ActionsRuntime=(t,n)=>{let o=n.createBuilder("configuratorRuntime/actions",{build:i=>i.definition,getKey:i=>i.definition.name,compare:(e,t)=>i(e.definition,t.definition)}),a=!1,r=new Set,d={};for(let i of t.values()){let e={definition:{name:String(i.name),...void 0===i.description?{}:{description:i.description},params:i.paramsSchema}},t=o.build(e);t.changed&&(a=!0),r.add(o.getKey(e)),d[t.output.name]=t.output}return o.cleanup(r)&&(a=!0),e({definitions:d,changed:a})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{AssistantRuntime}from"./assistant-runtime.js";export{ComponentOptics}from"./component-optic.js";export{DataRuntime}from"./data-runtime.js";export{ExpressionRuntime}from"./expression-runtime.js";export{PresetRuntime}from"./preset-runtime.js";export{ThemeRuntime}from"./theme-runtime.js";export{TransformersRuntime}from"./transformers-runtime.js";export{evaluateStaticMemoEvalPlan,generateMemoEvalPlanRuntime}from"./generate-memo-eval-plan-runtime.js";export{evaluateReflectionConstants,findReflectionConstants}from"./reflection-constants-runtime.js";
|
|
1
|
+
export{ActionsRuntime}from"./actions-runtime.js";export{AssistantRuntime}from"./assistant-runtime.js";export{ComponentOptics}from"./component-optic.js";export{DataRuntime}from"./data-runtime.js";export{ExpressionRuntime}from"./expression-runtime.js";export{PresetRuntime}from"./preset-runtime.js";export{ThemeRuntime}from"./theme-runtime.js";export{TransformersRuntime}from"./transformers-runtime.js";export{evaluateStaticMemoEvalPlan,generateMemoEvalPlanRuntime}from"./generate-memo-eval-plan-runtime.js";export{evaluateReflectionConstants,findReflectionConstants}from"./reflection-constants-runtime.js";
|
|
@@ -3,7 +3,7 @@ import { type RuntimeReferenceStore } from '../../caching/index.js';
|
|
|
3
3
|
import type { ParseContext, RawProjectFiles, TextFile } from '../../core/index.js';
|
|
4
4
|
import { type ModuleAnalysis, type ModuleAnalyzer, type WebhookMembership } from './module-analysis.js';
|
|
5
5
|
/** Known file categories used for path-based sorting. */
|
|
6
|
-
export type FileCategory = 'spec' | 'expressions' | 'handlers' | 'elements' | 'transformers' | 'components' | 'invariants' | 'migrations' | 'adminMigrations' | 'adminExpressions' | 'adminInvariants' | 'adminComponents' | 'adminElements' | 'webhooks' | 'locales' | 'mockTemplates' | 'projectFiles' | 'customCode';
|
|
6
|
+
export type FileCategory = 'spec' | 'expressions' | 'actions' | 'handlers' | 'elements' | 'transformers' | 'components' | 'invariants' | 'migrations' | 'adminMigrations' | 'adminExpressions' | 'adminInvariants' | 'adminComponents' | 'adminElements' | 'webhooks' | 'locales' | 'mockTemplates' | 'projectFiles' | 'customCode';
|
|
7
7
|
/**
|
|
8
8
|
* A text file categorized by path pattern, with dep-aware change tracking.
|
|
9
9
|
*
|
|
@@ -32,6 +32,8 @@ export type CategorizedFiles = Branded<'CategorizedFiles', {
|
|
|
32
32
|
readonly specChanged: boolean;
|
|
33
33
|
readonly expressions: readonly CategorizedFile[];
|
|
34
34
|
readonly expressionsChanged: boolean;
|
|
35
|
+
readonly actions: readonly CategorizedFile[];
|
|
36
|
+
readonly actionsChanged: boolean;
|
|
35
37
|
readonly handlers: readonly CategorizedFile[];
|
|
36
38
|
readonly handlersChanged: boolean;
|
|
37
39
|
readonly elements: readonly CategorizedFile[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"lodash-es/isEqual.js";import{Branded as n}from"@salsita-ai/common/utils";import{computeFileDepHashes as s}from"../../caching/index.js";import{DiagnosticCode as o,diagnosticMessages as a}from"../../errors/index.js";import{findWebhookHandlerRegistration as i}from"./module-analysis.js";import{findWebhookSafetyViolation as t}from"./webhook-safety.js";export const buildProjectFileIndex=e=>new Map([...e.spec,...e.expressions,...e.handlers,...e.elements,...e.transformers,...e.components,...e.invariants,...e.migrations,...e.adminMigrations,...e.adminExpressions,...e.adminInvariants,...e.adminComponents,...e.adminElements,...e.webhooks,...e.locales,...e.mockTemplates,...e.projectFiles,...e.customCode].map(e=>[e.file.name,e]));let r=e=>/\/_[^/]+\//.test(e),m=[{path:"spec/",key:"spec"},{path:"src/admin/expressions/",key:"adminExpressions"},{path:"src/admin/invariants/",key:"adminInvariants"},{path:"src/admin/components/",key:"adminComponents"},{path:"src/admin/elements/",key:"adminElements"},{path:"src/admin/migrations/",key:"adminMigrations"},{path:"src/expressions/",key:"expressions"},{path:"src/handlers/",key:"handlers"},{path:"src/elements/",key:"elements"},{path:"src/transformers/",key:"transformers"},{path:"src/components/",key:"components"},{path:"src/invariants/",key:"invariants"},{path:"src/migrations/",key:"migrations"},{path:"src/webhooks/",key:"webhooks"},{path:"src/locales/",key:"locales"},{path:"mocks/",key:"mockTemplates"}],l=new Set(["package.json",".gitignore","CLAUDE.md",".cursor/rules/phoenix.mdc"]),d=new Set(["migrations","adminMigrations"]),
|
|
1
|
+
import e from"lodash-es/isEqual.js";import{Branded as n}from"@salsita-ai/common/utils";import{computeFileDepHashes as s}from"../../caching/index.js";import{DiagnosticCode as o,diagnosticMessages as a}from"../../errors/index.js";import{findWebhookHandlerRegistration as i}from"./module-analysis.js";import{findWebhookSafetyViolation as t}from"./webhook-safety.js";export const buildProjectFileIndex=e=>new Map([...e.spec,...e.expressions,...e.actions,...e.handlers,...e.elements,...e.transformers,...e.components,...e.invariants,...e.migrations,...e.adminMigrations,...e.adminExpressions,...e.adminInvariants,...e.adminComponents,...e.adminElements,...e.webhooks,...e.locales,...e.mockTemplates,...e.projectFiles,...e.customCode].map(e=>[e.file.name,e]));let r=e=>/\/_[^/]+\//.test(e),m=[{path:"spec/",key:"spec"},{path:"src/admin/expressions/",key:"adminExpressions"},{path:"src/admin/invariants/",key:"adminInvariants"},{path:"src/admin/components/",key:"adminComponents"},{path:"src/admin/elements/",key:"adminElements"},{path:"src/admin/migrations/",key:"adminMigrations"},{path:"src/expressions/",key:"expressions"},{path:"src/actions/",key:"actions"},{path:"src/handlers/",key:"handlers"},{path:"src/elements/",key:"elements"},{path:"src/transformers/",key:"transformers"},{path:"src/components/",key:"components"},{path:"src/invariants/",key:"invariants"},{path:"src/migrations/",key:"migrations"},{path:"src/webhooks/",key:"webhooks"},{path:"src/locales/",key:"locales"},{path:"mocks/",key:"mockTemplates"}],l=new Set(["package.json",".gitignore","CLAUDE.md",".cursor/rules/phoenix.mdc"]),d=new Set(["migrations","adminMigrations"]),c=m.filter(({path:e,key:n})=>e.startsWith("src/")&&d.has(n)),p=(e,n)=>{let s=e.slice(n.length).split("/");return!(s.length<=1)&&s.slice(0,-1).some(e=>!e.startsWith("_"))},h=/\.(ts|tsx|js|jsx)$/,f=(e,n)=>{if("components"===e||"adminComponents"===e)return n.hasUseWebhookDirective?{membership:"pinned",logSuffix:"webhook ('use webhook' directive)"}:{membership:"frontend",logSuffix:"frontend only (no 'use webhook' directive)"};if("handlers"===e){let e=i(n);return void 0!==e?{membership:"named-handler",logSuffix:`webhook (the ${e} registration)`}:n.hasUseWebhookDirective?{membership:"pinned",logSuffix:"webhook ('use webhook' directive)"}:{membership:"frontend",logSuffix:"frontend only (not a named handler or pin)"}}};export const CategorizedFiles=(i,d,g,u)=>{let k={spec:[],expressions:[],actions:[],handlers:[],elements:[],transformers:[],components:[],invariants:[],migrations:[],adminMigrations:[],adminExpressions:[],adminInvariants:[],adminComponents:[],adminElements:[],webhooks:[],locales:[],mockTemplates:[],projectFiles:[],customCode:[]},b=[];for(let e of i.files){if("text"!==e.kind)continue;if(r(e.name)){k.customCode.push({file:e,category:"customCode"});continue}if(l.has(e.name)){k.projectFiles.push({file:e,category:"projectFiles"});continue}let n=!1;for(let{path:s,key:o}of m)if(e.name.startsWith(s)){k[o].push({file:e,category:o}),n=!0;break}n||b.push(e.name)}for(let e of b)e.startsWith("src/")&&g.error(o.UNKNOWN_SRC_PATH,a.UNKNOWN_SRC_PATH(e));for(let{path:e,key:n}of c)for(let s of k[n])p(s.file.name,e)&&g.error(o.INVALID_SUBDIRECTORY,a.INVALID_SUBDIRECTORY(s.file.name,e));if(k.webhooks.length>0&&!k.webhooks.some(e=>"src/webhooks/index.ts"===e.file.name)&&g.error(o.MISSING_WEBHOOK_INDEX,a.MISSING_WEBHOOK_INDEX()),g.hasErrors)return;let C=[];for(let e of Object.values(k))for(let n of e)C.push(n.file.name);let v=s(i,C),{analyzer:x,logger:y}=u,E=d.createBuilder("categorizedFiles/moduleAnalysis",{build:e=>{try{return{analysis:x(e.name,e.content)}}catch(e){return{error:e instanceof Error?e.message:String(e)}}},getKey:e=>e.name,compare:(e,n)=>e.content===n.content}),I=new Set,w=e=>{if(!h.test(e.name))return;I.add(e.name);let n=E.build({name:e.name,content:e.content}).output;return void 0!==n.error?void g.error(o.MODULE_ANALYSIS_FAILED,a[o.MODULE_ANALYSIS_FAILED](e.name,n.error)):n.analysis},S={},j={};for(let[e,s]of Object.entries(k)){let o=d.createBuilder(`categorizedFiles/${e}`,{build:e=>e,getKey:e=>e.name,compare:(e,n)=>e.depHash===n.depHash}),a=new Set;S[e]=s.map(e=>{let s=v[e.file.name]??{deps:[],hash:""},{changed:i}=o.build({name:e.file.name,depHash:s.hash});a.add(e.file.name);let t=w(e.file),r=void 0===t?void 0:f(e.category,t);return void 0!==r&&y.debug(`Webhook membership: ${e.file.name} -> ${r.logSuffix}`),n({file:e.file,category:e.category,deps:s.deps,depHash:s.hash,changed:i,analysis:t,webhookMembership:r?.membership})}),j[e]=o.cleanup(a)}E.cleanup(I);let _=(e,n)=>n.some(e=>e.changed)||!0===j[e],F=d.createBuilder("categorizedFiles/envs",{build:e=>e.envs,getKey:()=>"singleton",compare:(n,s)=>e(n.envs,s.envs)}).build({envs:i.envs}),M=n({spec:S.spec,specChanged:_("spec",S.spec),expressions:S.expressions,expressionsChanged:_("expressions",S.expressions),actions:S.actions,actionsChanged:_("actions",S.actions),handlers:S.handlers,handlersChanged:_("handlers",S.handlers),elements:S.elements,elementsChanged:_("elements",S.elements),transformers:S.transformers,transformersChanged:_("transformers",S.transformers),components:S.components,componentsChanged:_("components",S.components),invariants:S.invariants,invariantsChanged:_("invariants",S.invariants),migrations:S.migrations,migrationsChanged:_("migrations",S.migrations),adminMigrations:S.adminMigrations,adminMigrationsChanged:_("adminMigrations",S.adminMigrations),adminExpressions:S.adminExpressions,adminExpressionsChanged:_("adminExpressions",S.adminExpressions),adminInvariants:S.adminInvariants,adminInvariantsChanged:_("adminInvariants",S.adminInvariants),adminComponents:S.adminComponents,adminComponentsChanged:_("adminComponents",S.adminComponents),adminElements:S.adminElements,adminElementsChanged:_("adminElements",S.adminElements),webhooks:S.webhooks,webhooksChanged:_("webhooks",S.webhooks),locales:S.locales,localesChanged:_("locales",S.locales),mockTemplates:S.mockTemplates,mockTemplatesChanged:_("mockTemplates",S.mockTemplates),projectFiles:S.projectFiles,projectFilesChanged:_("projectFiles",S.projectFiles),customCode:S.customCode,customCodeChanged:_("customCode",S.customCode),envs:F.output,envsChanged:F.changed}),O=buildProjectFileIndex(M);for(let e of O.values()){if("pinned"!==e.webhookMembership&&"named-handler"!==e.webhookMembership)continue;let n=t(e,O);void 0!==n&&g.error(o.WEBHOOK_UNSAFE_IMPORT,a[o.WEBHOOK_UNSAFE_IMPORT](n.fileName,n.inclusionReason,n.importer,n.specifier))}return M};
|