@salsita-ai/sdk 0.50.0-develop.b7caacb493 → 0.50.0-develop.b956e273cc

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 (75) hide show
  1. package/dist/application/index.d.ts +1 -0
  2. package/dist/application/index.js +1 -1
  3. package/dist/application/mount-application.d.ts +1 -1
  4. package/dist/application/mount-application.js +1 -1
  5. package/dist/application/mount-configurator.d.ts +19 -0
  6. package/dist/application/mount-configurator.js +1 -0
  7. package/dist/application/mounted-application-runtime.d.ts +4 -0
  8. package/dist/application/mounted-application-runtime.js +1 -0
  9. package/dist/application/register-web-component.d.ts +2 -0
  10. package/dist/application/register-web-component.js +1 -0
  11. package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill.js +1 -1
  12. package/dist/application-spec/generate-application/index.d.ts +1 -0
  13. package/dist/application-spec/generate-application/index.js +1 -1
  14. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-runtime.d.ts +2 -0
  15. package/dist/application-spec/generate-application/runtime/admin-runtime/admin-runtime.js +1 -1
  16. package/dist/application-spec/generate-application/runtime/application-runtime.d.ts +5 -0
  17. package/dist/application-spec/generate-application/runtime/application-runtime.js +1 -1
  18. package/dist/application-spec/generate-application/runtime/application-spec-slice.d.ts +2 -1
  19. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.d.ts +2 -0
  20. package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.js +1 -1
  21. package/dist/application-spec/generate-application/runtime/create-application.d.ts +57 -0
  22. package/dist/application-spec/generate-application/runtime/create-application.js +1 -0
  23. package/dist/client/authorized-client.d.ts +3 -1
  24. package/dist/client/authorized-client.js +1 -1
  25. package/dist/client/contract.d.ts +17 -0
  26. package/dist/client/index.d.ts +1 -1
  27. package/dist/client/local-authorized-client.d.ts +3 -1
  28. package/dist/client/local-authorized-client.js +1 -1
  29. package/dist/client/memory-authorized-client.d.ts +4 -1
  30. package/dist/client/memory-authorized-client.js +1 -1
  31. package/dist/client/phoenix-api.d.ts +228 -0
  32. package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
  33. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +13 -0
  34. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
  35. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +2 -1
  36. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -1
  37. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +15 -9
  38. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
  39. package/dist/configurator/ui/assistant/screenshots/ScreenshotThumbnails.d.ts +1 -1
  40. package/dist/configurator/ui/assistant/screenshots/ScreenshotThumbnails.js +1 -1
  41. package/dist/configurator/ui/assistant/screenshots/tool-screenshots.d.ts +12 -4
  42. package/dist/configurator/ui/assistant/screenshots/tool-screenshots.js +1 -1
  43. package/dist/configurator/ui/assistant/screenshots/use-screenshot-src.d.ts +8 -0
  44. package/dist/configurator/ui/assistant/screenshots/use-screenshot-src.js +1 -0
  45. package/dist/docs/index.json +1 -1
  46. package/dist/docs/phoenix/domain-model.mdx +4 -1
  47. package/dist/docs/phoenix/phoenix-cli.mdx +8 -2
  48. package/dist/docs/phoenix/sdk-builder-workflow.mdx +4 -2
  49. package/dist/domain/application/assistant/build-assistant-manifest.js +1 -1
  50. package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -1
  51. package/dist/domain/application/configurator-builder.d.ts +7 -1
  52. package/dist/domain/application/configurator-builder.js +1 -1
  53. package/dist/domain/application/index.d.ts +1 -1
  54. package/dist/domain/application/index.js +1 -1
  55. package/dist/domain/domain-runtime/application.d.ts +39 -0
  56. package/dist/domain/domain-runtime/application.js +1 -0
  57. package/dist/domain/domain-runtime/domain-runtime.d.ts +18 -4
  58. package/dist/domain/domain-runtime/domain-runtime.js +1 -1
  59. package/dist/domain/domain-runtime/environment/initialize.d.ts +1 -1
  60. package/dist/domain/domain-runtime/index.d.ts +1 -0
  61. package/dist/domain/domain-runtime/index.js +1 -1
  62. package/dist/phoenix/application-spec/resolve-deployment-data.d.ts +11 -0
  63. package/dist/phoenix/application-spec/resolve-deployment-data.js +2 -2
  64. package/dist/phoenix/cli.js +1 -1
  65. package/dist/phoenix/commands/dev.js +5 -5
  66. package/dist/phoenix/commands/generated-env-markers.d.ts +1 -0
  67. package/dist/phoenix/commands/generated-env-markers.js +1 -1
  68. package/dist/phoenix/services/application-spec-project-watcher.d.ts +3 -1
  69. package/dist/phoenix/services/application-spec-project-watcher.js +2 -2
  70. package/dist/phoenix/services/prepare-development-environment.js +1 -1
  71. package/dist/react-sdk/application-runtime/common-services/analytics/analytics-service.d.ts +1 -1
  72. package/dist/react-sdk/application-runtime/common-services/initialize.d.ts +2 -2
  73. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +17 -6
  74. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.js +1 -1
  75. package/package.json +3 -3
@@ -85,7 +85,9 @@ On the server, the install runs pnpm. It follows your `pnpm-lock.yaml` and `pnpm
85
85
 
86
86
  If the build fails, is cancelled or takes too long, `phoenix deploy` prints the end of the build log and exits with an error. `--no-wait` returns as soon as the build starts.
87
87
 
88
- Studio's **Builds & deployments** page lists your builds and shows which one your configurator serves. Each build shows its progress, its error and the full build log while it runs.
88
+ Studio's **Builds & deployments** page lists your builds, 20 to a page, and shows which one your configurator serves. Filter it to the live build or to the builds that failed. Each build shows its progress, its error and the full build log while it runs, and who deployed it with which CLI token.
89
+
90
+ **Rebuild** on a build's page builds the files uploaded with that build again, with your environment variables as they are now, without a new `phoenix deploy`. Use it after changing a variable, or when a build failed for a reason on our side. If the rebuild succeeds it goes live, so rebuilding an older build rolls production back to it.
89
91
 
90
92
  `phoenix deploy` refuses symlinks, hard-linked files and other special files among the project files, because builds only accept regular files. Packing uses the system `tar`, which macOS, Linux and Windows 10 or later all include. The build runner checks the uploaded archive again and keeps only project files, so a file outside the list above never reaches the build.
91
93
 
@@ -107,5 +109,5 @@ Coding agents working in your project use the same command, guided by the genera
107
109
  - `phoenix deploy` always deploys to the workspace's default project; it doesn't read `project` from the spec yet.
108
110
  - Only `phoenix dev` works from the sign-in. `phoenix deployment:prepare-dev` still needs the `.env` block of a Studio development environment.
109
111
  - Every deploy uploads the whole project; there are no incremental uploads.
110
- - Your own environment variables are set in Studio under Environment, by a super admin of the workspace, and apply from the next deploy. `phoenix dev` doesn't receive them: your development environment has its own variables. A build reads them from `process.env`; a webhook reads the ones the spec declares under `env.webhook`, through `phx.webhooksEnv` (see [Webhooks](?path=/docs/phoenix-webhooks--docs)). They can't use platform names such as `LAMBDA_FUNCTION_NAME`, the `AWS_` prefix, the identity provider settings such as `CLERK_API_KEY`, or names the CLI and the deploy tooling read themselves, such as `SERVER_URL` or `NODE_OPTIONS`; Studio refuses those names.
112
+ - Your own environment variables are set in Studio under Environment, by a super admin of the workspace, and apply from the next deploy. After a change, **Redeploy #N now** there rebuilds your live build with the new values, without a new `phoenix deploy`; it appears once your own build is live. `phoenix dev` doesn't receive them: your development environment has its own variables. A build reads them from `process.env`; a webhook reads the ones the spec declares under `env.webhook`, through `phx.webhooksEnv` (see [Webhooks](?path=/docs/phoenix-webhooks--docs)). They can't use platform names such as `LAMBDA_FUNCTION_NAME`, the `AWS_` prefix, the identity provider settings such as `CLERK_API_KEY`, or names the CLI and the deploy tooling read themselves, such as `SERVER_URL` or `NODE_OPTIONS`; Studio refuses those names.
111
113
  - Only super admins of a workspace can open its Studio. Admins and users see a page that says so.
@@ -1 +1 @@
1
- import{GraphQLBoolean as e,GraphQLEnumType as t,GraphQLID as n,GraphQLInputObjectType as i,GraphQLInterfaceType as s,GraphQLList as r,GraphQLNonNull as o,GraphQLObjectType as a,GraphQLSchema as p,GraphQLString as c,printSchema as d,validateSchema as l}from"graphql";import{GraphQLJSON as h,createAssistantValueType as w}from"./assistant-value-type.js";import{buildAssistantLenses as y}from"./build-assistant-lenses.js";import{createAssistantExecutionSchema as u}from"./create-assistant-execution-schema.js";let m="AnyDomainEntity",f="RootEntity",g=[["navigationState","Active navigation state.","navigationStates"],["viewState","Active view state.","viewStates"],["toolState","Active tool state.","toolStates"]],b={section:"childRecipes",mutation:"addChild"},v={section:"replaceRecipes",mutation:"replaceEntity"},j=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],$=(e,t)=>{if(!t||0===t.length)return e;let n=`One of: ${t.map(e=>`"${e}"`).join(", ")}.`;return e?/[.!?]$/.test(e)?`${e} ${n}`:`${e}. ${n}`:n},O=({target:e,cardinality:t},n)=>{let i=n(e);switch(t){case"1-1":return new o(i);case"0-1":return i;case"0-N":case"1-N":return new o(new r(new o(i)))}},E=(e,t,i)=>{let s={id:{type:new o(n),description:i?`Unique id of the entity, assigned by the configurator, e.g. "${i}-1".`:void 0},type:{type:new o(c),description:i?`Entity type name, e.g. "${i}".`:void 0}};for(let n of e)s[n.name]={type:"edge"===n.type.kind?O(n.type,t):w(n.type.type),description:n.description};return s},R=e=>Object.fromEntries(e.map(({name:e,source:t,localized:n})=>[e,n?{source:t,localized:!0}:{source:t}])),k={sameForAllInstances:e=>`Same recipe groups and recipes for every ${e}.`,constantDuringSession:()=>"Fixed for the session."},T={sameForAllInstances:e=>`Same for every ${e}.`,constantDuringSession:()=>"Fixed for the session."},I=(e,t,n)=>e.map(e=>` ${t[e](n)}`).join(""),N=({section:e},{groups:t,hints:n},{entityType:i,purpose:s,recipeGroup:a})=>{let p=t.filter(({dryRuns:e})=>!e).map(({groupId:e})=>e);return 0===t.length?{}:{[e]:{type:new o(new r(new o(a))),description:`The recipe groups for ${s} this ${i}: ${t.map(({groupId:e})=>e).join(", ")}. A group is listed only while the configurator offers it on the entity.${p.length>0?` Recipes of these groups cannot be dry-run: ${p.join(", ")}.`:""}${I(n,k,i)}`}}},A=({entityType:e,childRecipes:n,replaceRecipes:i,optionsEdges:s,screenshots:p},{recipeGroup:c,fieldOption:d,screenshot:l})=>new a({name:`${e}Meta`,fields:Object.assign(N(b,n,{entityType:e,purpose:"adding children to",recipeGroup:c}),N(v,i,{entityType:e,purpose:"replacing",recipeGroup:c}),...s.map(({options:{edgeName:t,field:n,validate:i,dryRuns:s},hints:a})=>({[t]:{type:new r(new o(d)),description:`Values "${n}" accepts on this ${e}. Null when there is no choice to make.${i?"":" Not checked on write."}${s?"":" Cannot be dry-run."}${I(a,T,e)}`}})),0===p.length?{}:{screenshot:{type:l,args:{view:{type:new o(new t({name:`${e}ScreenshotView`,values:Object.fromEntries(p.map(({view:e,description:t})=>[e,{description:t}]))}))}},description:"Renders this entity from a predefined view. The picture follows the tool result as an image labelled with `image`. Each one costs tokens and blocks the user's configurator while it renders: ask only when seeing the design answers something the data cannot. The images of one call share a size budget; past it, further screenshots come back null. Null as well when the view does not apply to this entity right now."}})}),S=e=>Object.entries(e).map(([e,t])=>`${e} (${t.map(({groupId:e})=>e).join(", ")})`);export const buildAssistantManifest=t=>{var O,k,T,I,N;let M,D,F,W,{entityTypes:x,aliases:C,exampleType:q,fields:G,states:U,deletableTypes:K,writableTypes:V,actionFields:z,optionsEdges:P}=t,L=Object.fromEntries(Object.entries(t.childRecipes).map(([e,t])=>[e,t.groups])),Q=Object.fromEntries(Object.entries(t.replaceRecipes).map(([e,t])=>[e,t.groups])),B=new Map,H=new Map,J=new Map,X=e=>{let[t,...n]=Object.entries(C).find(([t])=>t===e)?.[1]??[];return(t&&0===n.length?H.get(t):void 0)??J.get(e)??Z},Y=e=>H.get(e)??X(e),Z=new s({name:m,description:"Every entity of the configuration.",fields:()=>E(G[m]??[],Y,q)});for(let e of(J.set(m,Z),Object.keys(C)))e!==m&&J.set(e,new s({name:e,interfaces:[Z],fields:()=>E(G[e]??[],Y)}));let _={};for(let e of x){let t=[m,...Object.entries(C).filter(([t,n])=>t!==m&&n.includes(e)).map(([e])=>e)],n=G[e]??[];_[e]=R(n),H.set(e,new a({name:e,interfaces:t.flatMap(e=>J.get(e)??[]),fields:()=>{let t=B.get(e);return{...E(n,Y),...t?{meta:{type:new o(t),description:"What can be done to this entity right now."}}:{}}}}))}let ee=(O=()=>X(J.has(f)?f:m),k=()=>X(m),M=new a({name:"DryRunError",description:"One reason a change cannot be made right now.",fields:{type:{type:new o(c),description:"Kind of the problem."},entityId:{type:n,description:"The entity the problem is on, when it is on one."},message:{type:c,description:"The problem as the user would be told it."}}}),new a({name:"DryRun",description:"What using a recipe or writing an option would do, tried out on the configuration the query reads. Nothing is changed.",fields:()=>({ok:{type:new o(e),description:"Whether the change would succeed on the configuration the query reads."},root:{type:O(),description:"The root entity of the configuration as it would be after the change; null when ok is false. Everything selected under it reads that configuration."},changedEntities:{type:new o(new r(new o(k()))),description:"Entities the change would add or modify; empty when ok is false. One whose id is not in the configuration would be added, and its real id may differ. An entity written to is listed even when its values stay the same."},deletedEntityIds:{type:new o(new r(new o(n))),description:"The ids of the entities the change would remove; empty when ok is false."},sideEffects:{type:new o(new r(new o(c))),description:"The major or unexpected things the configurator would change along with it; empty when ok is false."},errors:{type:new o(new r(new o(M))),description:"Why the change cannot be made; empty when ok is true."}})})),et={recipeGroup:(T=[...Object.keys(L).length>0?[b.mutation]:[],...Object.keys(Q).length>0?[v.mutation]:[]],D=T.join(" or "),F=new a({name:"Recipe",description:`${T.includes("addChild")?"One thing that can be added to the entity (under childRecipes)":"One thing the entity can be replaced with (under replaceRecipes)"}${T.length>1?" or that it can be replaced with (under replaceRecipes)":""}.`,fields:{key:{type:new o(c),description:`Pass to ${D} as recipeKey. Valid only for the listing it came from.`},name:{type:new o(c),description:"Name shown to the user."},description:{type:c},imageUrl:{type:c,description:"Thumbnail shown to the user."},dryRun:{type:ee,description:"What using this recipe would do. Null when it cannot be tried."}}}),new a({name:"RecipeGroup",description:"A group of recipes for this entity.",fields:{groupId:{type:new o(c),description:`Pass to ${D} as recipeGroupId.`},name:{type:new o(c),description:"Name shown to the user."},description:{type:c},recipes:{type:new o(new r(new o(F)))}}})),fieldOption:new a({name:"FieldOption",description:"One value a field accepts. Writing a value outside the list is rejected unless the field description says it is not checked.",fields:{value:{type:new o(h),description:"The value to write to the field."},name:{type:c,description:"Name shown to the user."},description:{type:c},imageUrl:{type:c,description:"Image shown to the user."},color:{type:c,description:'Color shown to the user, as "#rrggbb".'},dryRun:{type:ee,description:"What writing this value would do. Null when it cannot be tried."}}}),screenshot:new a({name:"Screenshot",description:"A screenshot of an entity. The picture itself follows the tool result.",fields:{image:{type:new o(n),description:"Label of the image that follows the tool result."}}})};for(let e of x){let n=j(t.childRecipes,e)??{groups:[],hints:[]},i=j(t.replaceRecipes,e)??{groups:[],hints:[]},s=j(P,e)??[],r=j(t.screenshots,e)??[];(n.groups.length>0||i.groups.length>0||s.length>0||r.length>0)&&B.set(e,A({entityType:e,childRecipes:n,replaceRecipes:i,optionsEdges:s.map(t=>({...t,hints:(C[f]??[]).includes(e)?t.hints.filter(e=>"sameForAllInstances"!==e):t.hints})),screenshots:r},et))}let en=new p({query:(I=X(J.has(f)?f:m),N=X(m),W=(e=>{let t={};for(let[n,i,s]of g){let r=e[s];r.length>1&&(t[n]={type:new o(c),description:$(i,r)})}if(0!==Object.keys(t).length)return new a({name:"Navigation",description:"The active UI states of the configurator.",fields:t})})(U),new a({name:"Query",fields:{root:{type:new o(I),description:"The root entity of the configuration."},entities:{type:new o(new r(N)),args:{ids:{type:new r(new o(n))}},description:"Every entity, or the given ids in order with null for an unknown id."},selectedEntity:{type:new o(N),description:"The selected entity, or the root entity when nothing is selected."},...W?{navigation:{type:new o(W)}}:{}}})),mutation:(({deletableTypes:e,writableTypes:t,childRecipes:s,replaceRecipes:p,actionFields:d,objectTypes:l,anyDomainEntity:h,targetOutputType:y})=>{let u,m;if(0!==e.length||0!==t.length||0!==Object.keys(s).length||0!==Object.keys(p).length||0!==d.length)return new a({name:"Mutation",fields:Object.assign(0===e.length?{}:{deleteEntity:{type:new o(new r(new o(n))),args:{id:{type:new o(n)}},description:`Deletes the entity and everything composed into it. Deletable types: ${e.join(", ")}. Returns the ids removed, the given one first.`}},0===(u=S(s)).length?{}:{addChild:{type:new o(new r(new o(h))),args:{parentId:{type:new o(n)},recipeGroupId:{type:new o(c)},recipeKey:{type:new o(c)}},description:`Adds a child to the entity parentId from a recipe listed under its meta { childRecipes }. Types with child recipes: ${u.join("; ")}. Returns the entities added, the recipe's own first; empty when they were removed again.`}},0===(m=S(p)).length?{}:{replaceEntity:{type:new o(new r(new o(h))),args:{entityId:{type:new o(n)},recipeGroupId:{type:new o(c)},recipeKey:{type:new o(c)}},description:`Replaces the entity entityId from a recipe listed under its meta { replaceRecipes }. Types with replace recipes: ${m.join("; ")}. The replacement is a new entity: it has a new id and the field values of its recipe, and entityId no longer exists. Returns the entities added, the replacement first; empty when they were removed again.`}},...t.flatMap(e=>{let t=l.get(e.entityType);return t?[(({entityType:e,fields:t},s)=>{let r=Object.fromEntries(t.map(({name:e,type:t,description:n})=>[e,{type:w(t),description:n}]));return{[`modify${e}`]:{type:s,args:{id:{type:new o(n)},delta:{type:new o(new i({name:`${e}Delta`,fields:r}))}},description:`Sets the fields named in delta on one ${e}. Returns the entity after the change, or null when the change removed it.`}}})(e,t)]:[]}),Object.fromEntries(d.map(e=>{var t;return[e.fieldName,{type:new o(new a({name:(t=e.fieldName,`${t.charAt(0).toUpperCase()+t.slice(1)}Result`),description:`What ${e.fieldName} returns, read from the configuration after the change.`,fields:()=>Object.fromEntries(Object.entries(e.result).map(([e,t])=>[e,{type:"edge"===t.kind?(({target:e,list:t,nullable:n},i)=>{let s=t?new r(new o(i(e))):i(e);return n?s:new o(s)})(t,y):w(t.type),description:t.description}]))})),args:Object.fromEntries(Object.entries(e.args).map(([e,t])=>[e,{type:w(t.type),description:t.description}])),description:e.description}]})))})})({deletableTypes:K,writableTypes:V,childRecipes:L,replaceRecipes:Q,actionFields:z,objectTypes:H,anyDomainEntity:X(m),targetOutputType:Y}),types:[...J.values(),...H.values()]}),ei=l(en);if(ei.length>0)throw Error(ei.map(e=>e.message).join(" "));let es=d(en);return{sdl:es,navigationFields:g.filter(([,,e])=>U[e].length>1).map(([e])=>e),fields:_,deletableTypes:K,writableFields:Object.fromEntries(V.map(({entityType:e,fields:t})=>[e,Object.fromEntries(t.map(({name:e,property:t})=>[e,t]))])),childRecipes:L,replaceRecipes:Q,fieldOptions:Object.fromEntries(x.flatMap(e=>{let t=j(P,e);return t?[[e,t.map(({options:e})=>e)]]:[]})),screenshots:Object.fromEntries(x.flatMap(e=>{let n=j(t.screenshots,e);return n?[[e,n]]:[]})),actions:Object.fromEntries(z.map(({fieldName:e,actionName:t})=>[e,t])),lenses:y(t,u(es)),formElements:t.formElements}};
1
+ import{GraphQLBoolean as e,GraphQLEnumType as t,GraphQLID as n,GraphQLInputObjectType as i,GraphQLInterfaceType as s,GraphQLList as r,GraphQLNonNull as o,GraphQLObjectType as a,GraphQLSchema as p,GraphQLString as d,printSchema as c,validateSchema as l}from"graphql";import{GraphQLJSON as h,createAssistantValueType as w}from"./assistant-value-type.js";import{buildAssistantLenses as y}from"./build-assistant-lenses.js";import{createAssistantExecutionSchema as u}from"./create-assistant-execution-schema.js";let m="AnyDomainEntity",f="RootEntity",g=[["navigationState","Active navigation state.","navigationStates"],["viewState","Active view state.","viewStates"],["toolState","Active tool state.","toolStates"]],b={section:"childRecipes",mutation:"addChild"},v={section:"replaceRecipes",mutation:"replaceEntity"},j=(e,t)=>Object.entries(e).find(([e])=>e===t)?.[1],$=(e,t)=>{if(!t||0===t.length)return e;let n=`One of: ${t.map(e=>`"${e}"`).join(", ")}.`;return e?/[.!?]$/.test(e)?`${e} ${n}`:`${e}. ${n}`:n},O=({target:e,cardinality:t},n)=>{let i=n(e);switch(t){case"1-1":return new o(i);case"0-1":return i;case"0-N":case"1-N":return new o(new r(new o(i)))}},E=(e,t,i)=>{let s={id:{type:new o(n),description:i?`Unique id of the entity, assigned by the configurator, e.g. "${i}-1".`:void 0},type:{type:new o(d),description:i?`Entity type name, e.g. "${i}".`:void 0}};for(let n of e)s[n.name]={type:"edge"===n.type.kind?O(n.type,t):w(n.type.type),description:n.description};return s},R=e=>Object.fromEntries(e.map(({name:e,source:t,localized:n})=>[e,n?{source:t,localized:!0}:{source:t}])),k={sameForAllInstances:e=>`Same recipe groups and recipes for every ${e}.`,constantDuringSession:()=>"Fixed for the session."},T={sameForAllInstances:e=>`Same for every ${e}.`,constantDuringSession:()=>"Fixed for the session."},I=(e,t,n)=>e.map(e=>` ${t[e](n)}`).join(""),N=({section:e},{groups:t,hints:n},{entityType:i,purpose:s,recipeGroup:a})=>{let p=t.filter(({dryRuns:e})=>!e).map(({groupId:e})=>e);return 0===t.length?{}:{[e]:{type:new o(new r(new o(a))),description:`The recipe groups for ${s} this ${i}: ${t.map(({groupId:e})=>e).join(", ")}. A group is listed only while the configurator offers it on the entity.${p.length>0?` Recipes of these groups cannot be dry-run: ${p.join(", ")}.`:""}${I(n,k,i)}`}}},A=({entityType:e,childRecipes:n,replaceRecipes:i,optionsEdges:s,screenshots:p},{recipeGroup:d,fieldOption:c,screenshot:l})=>new a({name:`${e}Meta`,fields:Object.assign(N(b,n,{entityType:e,purpose:"adding children to",recipeGroup:d}),N(v,i,{entityType:e,purpose:"replacing",recipeGroup:d}),...s.map(({options:{edgeName:t,field:n,validate:i,dryRuns:s},hints:a})=>({[t]:{type:new r(new o(c)),description:`Values "${n}" accepts on this ${e}. Null when there is no choice to make.${i?"":" Not checked on write."}${s?"":" Cannot be dry-run."}${I(a,T,e)}`}})),0===p.length?{}:{screenshot:{type:l,args:{view:{type:new o(new t({name:`${e}ScreenshotView`,values:Object.fromEntries(p.map(({view:e,description:t})=>[e,{description:t}]))}))}},description:"Renders this entity from a predefined view. The picture follows the tool result as an image labelled with `image`. Null when the view does not apply to this entity right now."}})}),S=e=>Object.entries(e).map(([e,t])=>`${e} (${t.map(({groupId:e})=>e).join(", ")})`);export const buildAssistantManifest=t=>{var O,k,T,I,N;let M,D,F,W,{entityTypes:x,aliases:C,exampleType:q,fields:G,states:U,deletableTypes:K,writableTypes:V,actionFields:P,optionsEdges:z}=t,L=Object.fromEntries(Object.entries(t.childRecipes).map(([e,t])=>[e,t.groups])),Q=Object.fromEntries(Object.entries(t.replaceRecipes).map(([e,t])=>[e,t.groups])),B=new Map,H=new Map,J=new Map,X=e=>{let[t,...n]=Object.entries(C).find(([t])=>t===e)?.[1]??[];return(t&&0===n.length?H.get(t):void 0)??J.get(e)??Z},Y=e=>H.get(e)??X(e),Z=new s({name:m,description:"Every entity of the configuration.",fields:()=>E(G[m]??[],Y,q)});for(let e of(J.set(m,Z),Object.keys(C)))e!==m&&J.set(e,new s({name:e,interfaces:[Z],fields:()=>E(G[e]??[],Y)}));let _={};for(let e of x){let t=[m,...Object.entries(C).filter(([t,n])=>t!==m&&n.includes(e)).map(([e])=>e)],n=G[e]??[];_[e]=R(n),H.set(e,new a({name:e,interfaces:t.flatMap(e=>J.get(e)??[]),fields:()=>{let t=B.get(e);return{...E(n,Y),...t?{meta:{type:new o(t),description:"What can be done to this entity right now."}}:{}}}}))}let ee=(O=()=>X(J.has(f)?f:m),k=()=>X(m),M=new a({name:"DryRunError",description:"One reason a change cannot be made right now.",fields:{type:{type:new o(d),description:"Kind of the problem."},entityId:{type:n,description:"The entity the problem is on, when it is on one."},message:{type:d,description:"The problem as the user would be told it."}}}),new a({name:"DryRun",description:"What using a recipe or writing an option would do, tried out on the configuration the query reads. Nothing is changed.",fields:()=>({ok:{type:new o(e),description:"Whether the change would succeed on the configuration the query reads."},root:{type:O(),description:"The root entity of the configuration as it would be after the change; null when ok is false. Everything selected under it reads that configuration."},changedEntities:{type:new o(new r(new o(k()))),description:"Entities the change would add or modify; empty when ok is false. One whose id is not in the configuration would be added, and its real id may differ. An entity written to is listed even when its values stay the same."},deletedEntityIds:{type:new o(new r(new o(n))),description:"The ids of the entities the change would remove; empty when ok is false."},sideEffects:{type:new o(new r(new o(d))),description:"The major or unexpected things the configurator would change along with it; empty when ok is false."},errors:{type:new o(new r(new o(M))),description:"Why the change cannot be made; empty when ok is true."}})})),et={recipeGroup:(T=[...Object.keys(L).length>0?[b.mutation]:[],...Object.keys(Q).length>0?[v.mutation]:[]],D=T.join(" or "),F=new a({name:"Recipe",description:`${T.includes("addChild")?"One thing that can be added to the entity (under childRecipes)":"One thing the entity can be replaced with (under replaceRecipes)"}${T.length>1?" or that it can be replaced with (under replaceRecipes)":""}.`,fields:{key:{type:new o(d),description:`Pass to ${D} as recipeKey. Valid only for the listing it came from.`},name:{type:new o(d),description:"Name shown to the user."},description:{type:d},imageUrl:{type:d,description:"Thumbnail shown to the user."},dryRun:{type:ee,description:"What using this recipe would do. Null when it cannot be tried."}}}),new a({name:"RecipeGroup",description:"A group of recipes for this entity.",fields:{groupId:{type:new o(d),description:`Pass to ${D} as recipeGroupId.`},name:{type:new o(d),description:"Name shown to the user."},description:{type:d},recipes:{type:new o(new r(new o(F)))}}})),fieldOption:new a({name:"FieldOption",description:"One value a field accepts. Writing a value outside the list is rejected unless the field description says it is not checked.",fields:{value:{type:new o(h),description:"The value to write to the field."},name:{type:d,description:"Name shown to the user."},description:{type:d},imageUrl:{type:d,description:"Image shown to the user."},color:{type:d,description:'Color shown to the user, as "#rrggbb".'},dryRun:{type:ee,description:"What writing this value would do. Null when it cannot be tried."}}}),screenshot:new a({name:"Screenshot",description:"A screenshot of an entity. The picture itself follows the tool result.",fields:{image:{type:new o(n),description:"Label of the image that follows the tool result."}}})};for(let e of x){let n=j(t.childRecipes,e)??{groups:[],hints:[]},i=j(t.replaceRecipes,e)??{groups:[],hints:[]},s=j(z,e)??[],r=j(t.screenshots,e)??[];(n.groups.length>0||i.groups.length>0||s.length>0||r.length>0)&&B.set(e,A({entityType:e,childRecipes:n,replaceRecipes:i,optionsEdges:s.map(t=>({...t,hints:(C[f]??[]).includes(e)?t.hints.filter(e=>"sameForAllInstances"!==e):t.hints})),screenshots:r},et))}let en=new p({query:(I=X(J.has(f)?f:m),N=X(m),W=(e=>{let t={};for(let[n,i,s]of g){let r=e[s];r.length>1&&(t[n]={type:new o(d),description:$(i,r)})}if(0!==Object.keys(t).length)return new a({name:"Navigation",description:"The active UI states of the configurator.",fields:t})})(U),new a({name:"Query",fields:{root:{type:new o(I),description:"The root entity of the configuration."},entities:{type:new o(new r(N)),args:{ids:{type:new r(new o(n))}},description:"Every entity, or the given ids in order with null for an unknown id."},selectedEntity:{type:new o(N),description:"The selected entity, or the root entity when nothing is selected."},...W?{navigation:{type:new o(W)}}:{}}})),mutation:(({deletableTypes:e,writableTypes:t,childRecipes:s,replaceRecipes:p,actionFields:c,objectTypes:l,anyDomainEntity:h,targetOutputType:y})=>{let u,m;if(0!==e.length||0!==t.length||0!==Object.keys(s).length||0!==Object.keys(p).length||0!==c.length)return new a({name:"Mutation",fields:Object.assign(0===e.length?{}:{deleteEntity:{type:new o(new r(new o(n))),args:{id:{type:new o(n)}},description:`Deletes the entity and everything composed into it. Deletable types: ${e.join(", ")}. Returns the ids removed, the given one first.`}},0===(u=S(s)).length?{}:{addChild:{type:new o(new r(new o(h))),args:{parentId:{type:new o(n)},recipeGroupId:{type:new o(d)},recipeKey:{type:new o(d)}},description:`Adds a child to the entity parentId from a recipe listed under its meta { childRecipes }. Types with child recipes: ${u.join("; ")}. Returns the entities added, the recipe's own first; empty when they were removed again.`}},0===(m=S(p)).length?{}:{replaceEntity:{type:new o(new r(new o(h))),args:{entityId:{type:new o(n)},recipeGroupId:{type:new o(d)},recipeKey:{type:new o(d)}},description:`Replaces the entity entityId from a recipe listed under its meta { replaceRecipes }. Types with replace recipes: ${m.join("; ")}. The replacement is a new entity: it has a new id and the field values of its recipe, and entityId no longer exists. Returns the entities added, the replacement first; empty when they were removed again.`}},...t.flatMap(e=>{let t=l.get(e.entityType);return t?[(({entityType:e,fields:t},s)=>{let r=Object.fromEntries(t.map(({name:e,type:t,description:n})=>[e,{type:w(t),description:n}]));return{[`modify${e}`]:{type:s,args:{id:{type:new o(n)},delta:{type:new o(new i({name:`${e}Delta`,fields:r}))}},description:`Sets the fields named in delta on one ${e}. Returns the entity after the change, or null when the change removed it.`}}})(e,t)]:[]}),Object.fromEntries(c.map(e=>{var t;return[e.fieldName,{type:new o(new a({name:(t=e.fieldName,`${t.charAt(0).toUpperCase()+t.slice(1)}Result`),description:`What ${e.fieldName} returns, read from the configuration after the change.`,fields:()=>Object.fromEntries(Object.entries(e.result).map(([e,t])=>[e,{type:"edge"===t.kind?(({target:e,list:t,nullable:n},i)=>{let s=t?new r(new o(i(e))):i(e);return n?s:new o(s)})(t,y):w(t.type),description:t.description}]))})),args:Object.fromEntries(Object.entries(e.args).map(([e,t])=>[e,{type:w(t.type),description:t.description}])),description:e.description}]})))})})({deletableTypes:K,writableTypes:V,childRecipes:L,replaceRecipes:Q,actionFields:P,objectTypes:H,anyDomainEntity:X(m),targetOutputType:Y}),types:[...J.values(),...H.values()]}),ei=l(en);if(ei.length>0)throw Error(ei.map(e=>e.message).join(" "));let es=c(en);return{sdl:es,navigationFields:g.filter(([,,e])=>U[e].length>1).map(([e])=>e),fields:_,deletableTypes:K,writableFields:Object.fromEntries(V.map(({entityType:e,fields:t})=>[e,Object.fromEntries(t.map(({name:e,property:t})=>[e,t]))])),childRecipes:L,replaceRecipes:Q,fieldOptions:Object.fromEntries(x.flatMap(e=>{let t=j(z,e);return t?[[e,t.map(({options:e})=>e)]]:[]})),screenshots:Object.fromEntries(x.flatMap(e=>{let n=j(t.screenshots,e);return n?[[e,n]]:[]})),actions:Object.fromEntries(P.map(({fieldName:e,actionName:t})=>[e,t])),lenses:y(t,u(es)),formElements:t.formElements}};
@@ -1 +1 @@
1
- import{ASSISTANT_BUILT_IN_FORM_ELEMENTS as e}from"./form/index.js";let t=[["Containers",["group","choice","choices"]],["Options",["option"]],["Inputs",["input"]]];export const formElementSignature=({name:e,role:t,attributes:a})=>{let n=["label",...Object.entries(a).map(([e,t])=>((e,{type:t,enum:a})=>a?`${e}="${a.join("|")}"`:"string"===t?e:`${e}="<${t}>"`)(e,t))];return"option"===t||"input"===t?`<${e} ${n.join(" ")} />`:`<${e} ${n.join(" ")}>…</${e}>`};export const generateAssistantPrompt=a=>{let n,s=Object.values(a.childRecipes??{}).some(e=>e.length>0),i=Object.values(a.replaceRecipes??{}).some(e=>e.length>0),o=Object.values(a.fieldOptions??{}).some(e=>e.length>0),r=Object.keys(a.actions??{}).length>0,h=(a.deletableTypes?.length??0)>0||Object.values(a.writableFields??{}).some(e=>Object.keys(e).length>0)||s||i||r,l=s||i||o,d=[...s?["`childRecipes` is what can be added to it"]:[],...i?["`replaceRecipes` what it can be replaced with"]:[],...o?["`<field>Options` the values a field accepts"]:[]],c=["`selected`",...(a.navigationFields??[]).map(e=>`\`${e}\``)].join(", ");return[["Tools","- Put related operations in one call and select only the fields you need.",...h?[`- Use a mutation inside \`query\` to answer a what-if about a change ${l?"the lists under `meta` do not show":"before making it"}.`,"- Use `apply` only for what the user asked for."]:["- Nothing in this configurator can be changed through you. Say so when the user asks for a change."],"- When an operation fails, its `errors` say why and what to send instead."],...h?[["After a change","- A change is made only when the `apply` result has `committed: true`. Otherwise `errors` or `message` says what happened; without either, nothing changed. Never say a change was made when it was not.","- `sideEffects` names the major or unexpected things the configurator changed along with your change. Tell the user about them when committed; otherwise they describe what would happen. Smaller adjustments are not listed.","- A mutation returns the state after the change: use the ids and values it returned, not the ones you sent.",...r?["- When one mutation does the whole of what the user asked, use it instead of building the same change from several others."]:[]]]:[],...l?[["What can be done to an entity",`- \`meta\` lists what is possible right now: ${d.join(", ")}. Read the list before such a change and before telling the user what is available.`,`- You can select \`dryRun\` on ${[...s||i?["recipes"]:[],...o?["options"]:[]].join(" or ")} to look ahead and pick one that meets what the user asked for. It is optional before a change.`,"- Read the lists again after a change, unless their descriptions say they stay the same."]]:[],["The `[changes]` block","- Every user message starts with it: a glimpse of what the user did in the configurator since your last turn.",`- \`[changes: none]\`, or only ${c} lines: what you know still holds. Do not query it again.`,"- Other lines are a hint at what to read again: `A` added, `D` deleted, `M` modified with the fields. Text after `#` says what caused the line; `reset: undo/redo` says the user undid or redid changes.","- Read computed fields again when a listed change may affect them.","- `[changes: unavailable]` and `[changes: too many (n)]`: read again before relying on anything you read earlier.",...h?["- Your applied changes are not listed, except those waiting for user approval: they appear once approved."]:[]],["Reading the schema","- Take ids from results.",...(a.deletableTypes?.length??0)>0||i?["- The id of a deleted or replaced entity is gone and may later be given to another entity."]:[],`- A field whose name starts with \`_\` is computed: read it${h?", never write it":""}.`,"- Numbers are in the unit the field description names. Convert when the user uses another unit."],["Links","- You may link an entity of the current configuration when you speak about that very entity: `[the left burner](entity:CookingTop-1)`. It helps the user find it in the configurator.",...l?["- Whenever you name recipes or options you read from `meta`, in a list, a table or a sentence, link each one: `[Single gas burner](recipe:KitchenRange-1/top/gas_single)` or `[Oak](option:Cabinet-2/finishOptions/oak)`. The link shows the user its picture or color and its description, so never draw previews yourself. The target is the entity id, the recipe group id or the options field you read, and the key or value, each encoded as in a URL."]:[]],["Replies","- Write Markdown only, never HTML: the panel does not render it.","- An image, `![alt](path)`, is shown only when its path is relative.","- To make a warning or a key note stand out, write a GitHub alert: a blockquote whose first line is only `[!WARNING]` or `[!NOTE]`. Use it sparingly."],["Forms","- To ask the user something they answer by picking or typing, end your reply with a form: a fenced code block with the language `form`. It holds only elements, written as lowercase tags with string attributes, without Markdown or text.","- Every element takes `label`, the text the user sees; on a container or an input it also names the answer. An option or an input whose signature lists `value` takes it: an option sends it instead of its label, and an input starts with it.",'- A bare attribute in a signature takes any text, `name="<type>"` takes a value of that type written as text, such as `min="<number>"`, and `name="a|b"` takes one of the words listed.',"- Options can also stand on their own, outside a `choice` or `choices`.","- An element or attribute not listed here, or an element other than an option inside a `choice` or `choices`, makes the whole form fail.","- The answer is the user's next message. Each container or input gives a line `Label: value`, or the bare value without a label; the lines of a labelled container are indented by two spaces under it, a `choices` lists each picked option on its own line, and `—` marks what was left unanswered.",'- Example: `<choice label="Plinth"><reply label="Black" /><reply label="Oak" /></choice>` is answered with `Plinth: Oak`.',"- The chat shows the answer as the user's own message, so a `value` reads as natural words, never as an id, key or code. Give `value` only when the label alone would be unclear as an answer, and map the answer's labels back to ids yourself.",...(n=[...e,...a.formElements??[]],t.flatMap(([e,t])=>{let a=n.filter(({role:e})=>t.includes(e));return 0===a.length?[]:[`- ${e}:`,...a.map(e=>` - \`${formElementSignature(e)}\`: ${(({description:e,required:t=[]})=>0===t.length?e:`${e} Requires ${t.map(e=>`\`${e}\``).join(", ")}.`)(e)}`)]}))],...a.lenses?.declarations?[["Built-in fragments","- These fragments are already defined for every operation. Spread one by name on a field of its type, as in `field { ...FragmentName }`, instead of listing its fields.","- A fragment is a starting selection: add the other fields you need next to the spread, by name from the schema.","- Never define a fragment with one of these names.","",a.lenses.declarations]]:[]].map(e=>e.join("\n")).join("\n\n")};
1
+ import{ASSISTANT_BUILT_IN_FORM_ELEMENTS as e}from"./form/index.js";let t=[["Containers",["group","choice","choices"]],["Options",["option"]],["Inputs",["input"]]];export const formElementSignature=({name:e,role:t,attributes:a})=>{let n=["label",...Object.entries(a).map(([e,t])=>((e,{type:t,enum:a})=>a?`${e}="${a.join("|")}"`:"string"===t?e:`${e}="<${t}>"`)(e,t))];return"option"===t||"input"===t?`<${e} ${n.join(" ")} />`:`<${e} ${n.join(" ")}>…</${e}>`};export const generateAssistantPrompt=a=>{let n,s=Object.values(a.childRecipes??{}).some(e=>e.length>0),o=Object.values(a.replaceRecipes??{}).some(e=>e.length>0),i=Object.values(a.fieldOptions??{}).some(e=>e.length>0),r=Object.keys(a.actions??{}).length>0,h=Object.values(a.screenshots??{}).some(e=>e.length>0),l=(a.deletableTypes?.length??0)>0||Object.values(a.writableFields??{}).some(e=>Object.keys(e).length>0)||s||o||r,d=s||o||i,u=[...s?["`childRecipes` is what can be added to it"]:[],...o?["`replaceRecipes` what it can be replaced with"]:[],...i?["`<field>Options` the values a field accepts"]:[]],c=["`selected`",...(a.navigationFields??[]).map(e=>`\`${e}\``)].join(", ");return[["Tools","- Put related operations in one call and select only the fields you need.",...l?[`- Use a mutation inside \`query\` to answer a what-if about a change ${d?"the lists under `meta` do not show":"before making it"}.`,"- Use `apply` only for what the user asked for."]:["- Nothing in this configurator can be changed through you. Say so when the user asks for a change."],"- When an operation fails, its `errors` say why and what to send instead."],...l?[["After a change","- A change is made only when the `apply` result has `committed: true`. Otherwise `errors` or `message` says what happened; without either, nothing changed. Never say a change was made when it was not.","- `sideEffects` names the major or unexpected things the configurator changed along with your change. Tell the user about them when committed; otherwise they describe what would happen. Smaller adjustments are not listed.","- A mutation returns the state after the change: use the ids and values it returned, not the ones you sent.",...r?["- When one mutation does the whole of what the user asked, use it instead of building the same change from several others."]:[]]]:[],...d?[["What can be done to an entity",`- \`meta\` lists what is possible right now: ${u.join(", ")}. Read the list before such a change and before telling the user what is available.`,`- You can select \`dryRun\` on ${[...s||o?["recipes"]:[],...i?["options"]:[]].join(" or ")} to look ahead and pick one that meets what the user asked for. It is optional before a change.`,"- Read the lists again after a change, unless their descriptions say they stay the same."]]:[],...h?[["Seeing the design","- `meta { screenshot(view: …) { image } }` renders an entity from one of the views its `<Type>ScreenshotView` lists. The picture follows the tool result.","- Take one when the user asks how the design looks, or when you are not sure something is laid out right: what sits where, what overlaps or lines up. Otherwise rely on the data.","- Each one costs tokens and blocks the user's configurator while it renders."]]:[],["The `[changes]` block","- Every user message starts with it: a glimpse of what the user did in the configurator since your last turn.",`- \`[changes: none]\`, or only ${c} lines: what you know still holds. Do not query it again.`,"- Other lines are a hint at what to read again: `A` added, `D` deleted, `M` modified with the fields. Text after `#` says what caused the line; `reset: undo/redo` says the user undid or redid changes.","- Read computed fields again when a listed change may affect them.","- `[changes: unavailable]` and `[changes: too many (n)]`: read again before relying on anything you read earlier.",...l?["- Your applied changes are not listed, except those waiting for user approval: they appear once approved."]:[]],["Reading the schema","- Take ids from results.",...(a.deletableTypes?.length??0)>0||o?["- The id of a deleted or replaced entity is gone and may later be given to another entity."]:[],`- A field whose name starts with \`_\` is computed: read it${l?", never write it":""}.`,"- Numbers are in the unit the field description names. Convert when the user uses another unit."],["Links","- You may link an entity of the current configuration when you speak about that very entity: `[the left burner](entity:CookingTop-1)`. It helps the user find it in the configurator.",...d?["- Whenever you name recipes or options you read from `meta`, in a list, a table or a sentence, link each one: `[Single gas burner](recipe:KitchenRange-1/top/gas_single)` or `[Oak](option:Cabinet-2/finishOptions/oak)`. The link shows the user its picture or color and its description, so never draw previews yourself. The target is the entity id, the recipe group id or the options field you read, and the key or value, each encoded as in a URL."]:[]],["Replies","- Write Markdown only, never HTML: the panel does not render it.","- An image, `![alt](path)`, is shown only when its path is relative.","- To make a warning or a key note stand out, write a GitHub alert: a blockquote whose first line is only `[!WARNING]` or `[!NOTE]`. Use it sparingly."],["Forms","- To ask the user something they answer by picking or typing, end your reply with a form: a fenced code block with the language `form`. It holds only elements, written as lowercase tags with string attributes, without Markdown or text.","- Every element takes `label`, the text the user sees; on a container or an input it also names the answer. An option or an input whose signature lists `value` takes it: an option sends it instead of its label, and an input starts with it.",'- A bare attribute in a signature takes any text, `name="<type>"` takes a value of that type written as text, such as `min="<number>"`, and `name="a|b"` takes one of the words listed.',"- Options can also stand on their own, outside a `choice` or `choices`.","- An element or attribute not listed here, or an element other than an option inside a `choice` or `choices`, makes the whole form fail.","- The answer is the user's next message. Each container or input gives a line `Label: value`, or the bare value without a label; the lines of a labelled container are indented by two spaces under it, a `choices` lists each picked option on its own line, and `—` marks what was left unanswered.",'- Example: `<choice label="Plinth"><reply label="Black" /><reply label="Oak" /></choice>` is answered with `Plinth: Oak`.',"- The chat shows the answer as the user's own message, so a `value` reads as natural words, never as an id, key or code. Give `value` only when the label alone would be unclear as an answer, and map the answer's labels back to ids yourself.",...(n=[...e,...a.formElements??[]],t.flatMap(([e,t])=>{let a=n.filter(({role:e})=>t.includes(e));return 0===a.length?[]:[`- ${e}:`,...a.map(e=>` - \`${formElementSignature(e)}\`: ${(({description:e,required:t=[]})=>0===t.length?e:`${e} Requires ${t.map(e=>`\`${e}\``).join(", ")}.`)(e)}`)]}))],...a.lenses?.declarations?[["Built-in fragments","- These fragments are already defined for every operation. Spread one by name on a field of its type, as in `field { ...FragmentName }`, instead of listing its fields.","- A fragment is a starting selection: add the other fields you need next to the spread, by name from the schema.","- Never define a fragment with one of these names.","",a.lenses.declarations]]:[]].map(e=>e.join("\n")).join("\n\n")};
@@ -3,7 +3,7 @@ import type { ThemeOptions } from '@mui/material';
3
3
  import type { z } from 'zod';
4
4
  import type { FinalizeTaskResource } from '@salsita-ai/contracts/webhook';
5
5
  import { type $DomainEntity, type DomainEntity, type DomainFactory, type EnumLike, type ProductPreset, type SchemaOfObject } from '../core/index.js';
6
- import { type ElementRegistration, type ProjectModule } from '../domain-runtime/index.js';
6
+ import { type ElementRegistration, type HandlerRegistration, type ProjectModule } from '../domain-runtime/index.js';
7
7
  import type { AclConfig, ApplicationConfig, DataSpec, DefaultEnvs, ResourcesConfig, SpecTransformer, TransformersConfig, UserInterfaceConfig } from './application-config.js';
8
8
  import { type AssistantResolvedManifest } from './assistant/index.js';
9
9
  interface ConfiguratorBuilderContext<ENTITIES extends DomainEntity<string> = never, ALLOWED_ROOT_ENTITIES extends ENTITIES = never, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>> = never, NAVIGATION_STATES extends string = never, VIEW_STATES extends string = never, TOOL_STATES extends string = never, EXPORT_STATES extends string = never, PUBLISHED_DATA extends Record<string, unknown> = never, SESSION_DATA extends Record<string, unknown> = never, FRONTEND_DATA extends Record<string, unknown> = never, ADMIN_ENTITIES extends DomainEntity<string> = never, ADMIN_ALLOWED_ROOT_ENTITIES extends ADMIN_ENTITIES = never, ADMIN_$MAP extends Record<ADMIN_ENTITIES['type'], $DomainEntity<ADMIN_ENTITIES>> = never, ADMIN_NAVIGATION_STATES extends string = never, ADMIN_VIEW_STATES extends string = never, FINALIZE_DATA extends Record<string, unknown> = never, PREFETCHED_FINALIZE_DATA extends Record<string, unknown> = never, FINALIZE_RESULT extends Record<string, unknown> = never, CALLBACK_DATA extends Record<string, unknown> = never, RESOURCE extends string = never> {
@@ -46,6 +46,12 @@ interface ConfiguratorBuilderContext<ENTITIES extends DomainEntity<string> = nev
46
46
  elements?: readonly ProjectModule[];
47
47
  defaultElements?: readonly ElementRegistration[];
48
48
  }
49
+ /**
50
+ * Rejects a second registration of a handler kind the application runs at most once: the assistant
51
+ * setup, the published-chunks filter, the data-row validator and the sheet validator. Both ways of
52
+ * building an application call it, `ConfiguratorBuilder.buildConfig` and `createApplication`.
53
+ */
54
+ export declare const checkSingleInstanceHandlers: (handlers: ReadonlyArray<HandlerRegistration<any, any>>) => void;
49
55
  export declare class ConfiguratorBuilder<ENTITIES extends DomainEntity<string> = never, ALLOWED_ROOT_ENTITIES extends ENTITIES = never, $MAP extends Record<ENTITIES['type'], $DomainEntity<ENTITIES>> = never, NAVIGATION_STATES extends string = never, VIEW_STATES extends string = never, TOOL_STATES extends string = never, EXPORT_STATES extends string = never, PUBLISHED_DATA extends Record<string, unknown> = never, SESSION_DATA extends Record<string, unknown> = never, FRONTEND_DATA extends Record<string, unknown> = never, ADMIN_ENTITIES extends DomainEntity<string> = never, ADMIN_ALLOWED_ROOT_ENTITIES extends ADMIN_ENTITIES = never, ADMIN_$MAP extends Record<ADMIN_ENTITIES['type'], $DomainEntity<ADMIN_ENTITIES>> = never, ADMIN_NAVIGATION_STATES extends string = never, ADMIN_VIEW_STATES extends string = never, FINALIZE_DATA extends Record<string, unknown> = never, PREFETCHED_FINALIZE_DATA extends Record<string, unknown> = never, FINALIZE_RESULT extends Record<string, unknown> = never, CALLBACK_DATA extends Record<string, unknown> = never, RESOURCE extends string = never> {
50
56
  private readonly _context;
51
57
  constructor(_context: ConfiguratorBuilderContext<ENTITIES, ALLOWED_ROOT_ENTITIES, $MAP, NAVIGATION_STATES, VIEW_STATES, TOOL_STATES, EXPORT_STATES, PUBLISHED_DATA, SESSION_DATA, FRONTEND_DATA, ADMIN_ENTITIES, ADMIN_ALLOWED_ROOT_ENTITIES, ADMIN_$MAP, ADMIN_NAVIGATION_STATES, ADMIN_VIEW_STATES, FINALIZE_DATA, PREFETCHED_FINALIZE_DATA, FINALIZE_RESULT, CALLBACK_DATA, RESOURCE>);
@@ -1 +1 @@
1
- import{initConsoleLogger as t}from"@salsita-ai/common/utils";import{defaultI18n as e}from"#package/i18n";import{extendedSchemaValidator as i}from"../core/index.js";import{NoopAnalyticsSystem as r}from"../domain-context/index.js";import{createDomainRuntime as n}from"../domain-runtime/index.js";import{isGetApplicationWrapperHandler as o}from"./GetApplicationWrapperHandler.js";import{isGetWebComponentOptionsHandler as a}from"./GetWebComponentOptions.js";import{isAssistantSetupHandler as s}from"./assistant/index.js";import{createInitialPublishedData as l}from"./create-initial-published-data.js";import{isDataRowValidatorHandler as h}from"./published-data/DataRowValidatorHandler.js";import{isFilterPublishedChunksHandler as u}from"./published-data/FilterPublishedChunksHandler.js";import{isMapPublishedChunkedDataHandler as d}from"./published-data/MapPublishedChunkedDataHandler.js";import{isMapPublishedRevisionDataHandler as c}from"./published-data/MapPublishedRevisionDataHandler.js";import{isSheetValidatorHandler as f}from"./published-data/SheetValidatorHandler.js";export class ConfiguratorBuilder{_context;constructor(t){this._context=t}withDefaultEnvs(t){return new ConfiguratorBuilder({...this._context,defaultEnvs:t})}withVersion(t){return new ConfiguratorBuilder({...this._context,version:t})}withTextLanguages(t){return new ConfiguratorBuilder({...this._context,textLanguages:t})}withAcl(t){return new ConfiguratorBuilder({...this._context,acl:t})}withAdminRelease(t){return new ConfiguratorBuilder({...this._context,enableAdminRelease:t})}withUi(t){return new ConfiguratorBuilder({...this._context,ui:t})}withResourcesConfig(t){return new ConfiguratorBuilder({...this._context,resourcesConfig:t})}withChunks(t){return new ConfiguratorBuilder({...this._context,chunks:t})}withPublishedDataHash(t){return new ConfiguratorBuilder({...this._context,publishedDataHash:t})}withAssistant(t){return new ConfiguratorBuilder({...this._context,assistant:t})}withTheme(t){return new ConfiguratorBuilder({...this._context,theme:t})}withDomainFactory(t){return new ConfiguratorBuilder({...this._context,domainFactory:t})}withAdminDomainFactory(t){return new ConfiguratorBuilder({...this._context,adminDomainFactory:t})}withI18n=t=>new ConfiguratorBuilder({...this._context,i18n:t});withPrefetchedFinalizeData(t){return new ConfiguratorBuilder({...this._context,prefetchedFinalizeData:t})}withFinalizeData(t){return new ConfiguratorBuilder({...this._context,finalizeData:t})}withFinalizeResult(t){return new ConfiguratorBuilder({...this._context,finalizeResult:t})}withCallbackData(t){return new ConfiguratorBuilder({...this._context,callbackData:t})}withNavigationState(t){return new ConfiguratorBuilder({...this._context,navigationState:t})}withViewState(t){return new ConfiguratorBuilder({...this._context,viewState:t})}withToolState(t){return new ConfiguratorBuilder({...this._context,toolState:t})}withExportState(t){return new ConfiguratorBuilder({...this._context,exportState:t})}withAdminNavigationState(t){return new ConfiguratorBuilder({...this._context,adminNavigationState:t})}withAdminViewState(t){return new ConfiguratorBuilder({...this._context,adminViewState:t})}withPresets(t){return new ConfiguratorBuilder({...this._context,presets:t})}withAdminPresets(t){return new ConfiguratorBuilder({...this._context,adminPresets:t})}withComponentOptics(t){return new ConfiguratorBuilder({...this._context,componentOptics:[...this._context.componentOptics,...t]})}withAdminComponentOptics(t){return new ConfiguratorBuilder({...this._context,adminComponentOptics:[...this._context.adminComponentOptics??[],...t]})}withHandlers(t){return new ConfiguratorBuilder({...this._context,handlers:t})}withElements(t){return new ConfiguratorBuilder({...this._context,elements:t})}withDefaultElements(t){return new ConfiguratorBuilder({...this._context,defaultElements:t})}withResources(t){return new ConfiguratorBuilder({...this._context,resources:t})}withWebComponentTag(t){return new ConfiguratorBuilder({...this._context,tagName:t})}withTransformers(t,e){return new ConfiguratorBuilder({...this._context,transformers:{importedTransformers:t,specTransformers:e}})}withInterface(t){return this}withDataSpec=t=>new ConfiguratorBuilder({...this._context,dataSpec:t});_computeInitialPublishedData(t,e,i){if(!this._context.adminDomainFactory)throw Error("adminDomainFactory is required!");return l({adminDomainFactory:this._context.adminDomainFactory,domainRuntime:e,adminPresets:this._context.adminPresets??[],handlers:i,dataSpec:this._context.dataSpec,chunks:this._context.chunks,logger:t})}buildConfig(){return this._buildConfigWithHandlers().config}_buildConfigWithHandlers(){if(!this._context.domainFactory)throw Error("Can not create application config, domainFactory is required! Is it registered with the ConfiguratorBuilder?");if(!this._context.presets)throw Error("Can not create application config, presets are required! Is it registered with the ConfiguratorBuilder?");if(!this._context.adminDomainFactory)throw Error("Can not create application config, adminDomainFactory is required! Is it registered with the ConfiguratorBuilder?");if(!this._context.adminPresets)throw Error("Can not create application config, adminPresets are required! Is it registered with the ConfiguratorBuilder?");if(!this._context.version)throw Error("Can not create application config, version is required!");let i=this._context.tagName??"salsita-configurator",l={defaultEnvs:this._context.defaultEnvs,services:{i18n:this._context.i18n},version:this._context.version,initialPublishedData:{},domain:{textLanguages:this._context.textLanguages,componentOptics:this._context.componentOptics,presets:this._context.presets,domainFactory:this._context.domainFactory},navigation:{navigationStates:this._context.navigationState?.values(),viewStates:this._context.viewState?.values(),toolStates:this._context.toolState?.values(),exportStates:this._context.exportState?.values()},adminNavigation:{navigationStates:this._context.adminNavigationState?.values(),viewStates:this._context.adminViewState?.values()},adminDomain:{textLanguages:this._context.textLanguages,componentOptics:this._context.adminComponentOptics??[],presets:this._context.adminPresets,domainFactory:this._context.adminDomainFactory},mount:{tag:i,options:{}},handlers:this._context.handlers??[],elements:this._context.elements??[],defaultElements:this._context.defaultElements??[],transformers:this._context.transformers,features:{acl:this._context.acl,enableAdminRelease:this._context.enableAdminRelease},ui:{preview:this._context.ui?.preview,alwaysExpand:this._context.ui?.alwaysExpand,theme:this._context.theme},resources:this._context.resourcesConfig,chunks:this._context.chunks,publishedDataHash:this._context.publishedDataHash,assistant:this._context.assistant,dataSpec:this._context.dataSpec},d=t(),c=n({config:l,services:{analyticsService:new r,i18n:e,logger:d}}),m=c.getState().spec.configurator.handlers;if(m.filter(s).length>1)throw Error("Multiple createAssistantSetupHandler handlers found. Only one handler is allowed.");if(m.filter(t=>u(t)).length>1)throw Error("Multiple createFilterPublishedChunksHandler handlers found. Only one handler is allowed.");if(m.filter(t=>h(t)).length>1)throw Error("Multiple createDataRowValidatorHandler handlers found. Only one handler is allowed.");if(m.filter(t=>f(t)).length>1)throw Error("Multiple createSheetValidatorHandler handlers found. Only one handler is allowed.");let w=m.find(o)?.handler().handler,x=m.find(a)?.handler().handler(void 0),_=this._computeInitialPublishedData(d,c,m);return{config:{...l,mount:{tag:i,options:x??{},Application:w},initialPublishedData:_},handlers:m}}buildWebhookContext(){if(!this._context.domainFactory)throw Error("domainFactory is required!");if(!this._context.adminDomainFactory)throw Error("adminDomainFactory is required!");if(!this._context.adminPresets)throw Error("adminPresets are required!");let{config:t,handlers:e}=this._buildConfigWithHandlers(),r=t=>{if(null==this._context.finalizeData)return{};let e=i.compile(this._context.finalizeData);if(!e(t))throw console.error("Finalize data validation errors:",e.errors),Error("Invalid finalize data!");return t},n=t=>{if(null==this._context.finalizeResult)return{};let e=i.compile(this._context.finalizeResult);if(!e(t))throw console.error("Finalize result validation errors:",e.errors),Error("Invalid finalize result!");return t},o=t=>{if(null==this._context.callbackData)return{};let e=i.compile(this._context.callbackData);if(!e(t))throw console.error("Callback data validation errors:",e.errors),Error("Invalid callback data!");return t},a=e.find(c)?.handler().handler,s=e.find(d)?.handler().handler,l=e.find(h)?.handler().handler,u=e.find(f)?.handler().handler;return{config:t,parseFinalizeData:r,parseFinalizeResult:n,resources:this._context.resources??[],parseCallbackData:o,mapPublishedRevisionData:a,mapPublishedChunkedData:s,dataRowValidator:l,sheetValidator:u}}}
1
+ import{initConsoleLogger as t}from"@salsita-ai/common/utils";import{defaultI18n as e}from"#package/i18n";import{extendedSchemaValidator as i}from"../core/index.js";import{NoopAnalyticsSystem as r}from"../domain-context/index.js";import{createDomainRuntime as n}from"../domain-runtime/index.js";import{isGetApplicationWrapperHandler as o}from"./GetApplicationWrapperHandler.js";import{isGetWebComponentOptionsHandler as a}from"./GetWebComponentOptions.js";import{isAssistantSetupHandler as s}from"./assistant/index.js";import{createInitialPublishedData as u}from"./create-initial-published-data.js";import{isDataRowValidatorHandler as h}from"./published-data/DataRowValidatorHandler.js";import{isFilterPublishedChunksHandler as l}from"./published-data/FilterPublishedChunksHandler.js";import{isMapPublishedChunkedDataHandler as c}from"./published-data/MapPublishedChunkedDataHandler.js";import{isMapPublishedRevisionDataHandler as d}from"./published-data/MapPublishedRevisionDataHandler.js";import{isSheetValidatorHandler as m}from"./published-data/SheetValidatorHandler.js";let f=[[s,"createAssistantSetupHandler"],[l,"createFilterPublishedChunksHandler"],[h,"createDataRowValidatorHandler"],[m,"createSheetValidatorHandler"]];export const checkSingleInstanceHandlers=t=>{for(let[e,i]of f)if(t.filter(t=>e(t)).length>1)throw Error(`Multiple ${i} handlers found. Only one handler is allowed.`)};export class ConfiguratorBuilder{_context;constructor(t){this._context=t}withDefaultEnvs(t){return new ConfiguratorBuilder({...this._context,defaultEnvs:t})}withVersion(t){return new ConfiguratorBuilder({...this._context,version:t})}withTextLanguages(t){return new ConfiguratorBuilder({...this._context,textLanguages:t})}withAcl(t){return new ConfiguratorBuilder({...this._context,acl:t})}withAdminRelease(t){return new ConfiguratorBuilder({...this._context,enableAdminRelease:t})}withUi(t){return new ConfiguratorBuilder({...this._context,ui:t})}withResourcesConfig(t){return new ConfiguratorBuilder({...this._context,resourcesConfig:t})}withChunks(t){return new ConfiguratorBuilder({...this._context,chunks:t})}withPublishedDataHash(t){return new ConfiguratorBuilder({...this._context,publishedDataHash:t})}withAssistant(t){return new ConfiguratorBuilder({...this._context,assistant:t})}withTheme(t){return new ConfiguratorBuilder({...this._context,theme:t})}withDomainFactory(t){return new ConfiguratorBuilder({...this._context,domainFactory:t})}withAdminDomainFactory(t){return new ConfiguratorBuilder({...this._context,adminDomainFactory:t})}withI18n=t=>new ConfiguratorBuilder({...this._context,i18n:t});withPrefetchedFinalizeData(t){return new ConfiguratorBuilder({...this._context,prefetchedFinalizeData:t})}withFinalizeData(t){return new ConfiguratorBuilder({...this._context,finalizeData:t})}withFinalizeResult(t){return new ConfiguratorBuilder({...this._context,finalizeResult:t})}withCallbackData(t){return new ConfiguratorBuilder({...this._context,callbackData:t})}withNavigationState(t){return new ConfiguratorBuilder({...this._context,navigationState:t})}withViewState(t){return new ConfiguratorBuilder({...this._context,viewState:t})}withToolState(t){return new ConfiguratorBuilder({...this._context,toolState:t})}withExportState(t){return new ConfiguratorBuilder({...this._context,exportState:t})}withAdminNavigationState(t){return new ConfiguratorBuilder({...this._context,adminNavigationState:t})}withAdminViewState(t){return new ConfiguratorBuilder({...this._context,adminViewState:t})}withPresets(t){return new ConfiguratorBuilder({...this._context,presets:t})}withAdminPresets(t){return new ConfiguratorBuilder({...this._context,adminPresets:t})}withComponentOptics(t){return new ConfiguratorBuilder({...this._context,componentOptics:[...this._context.componentOptics,...t]})}withAdminComponentOptics(t){return new ConfiguratorBuilder({...this._context,adminComponentOptics:[...this._context.adminComponentOptics??[],...t]})}withHandlers(t){return new ConfiguratorBuilder({...this._context,handlers:t})}withElements(t){return new ConfiguratorBuilder({...this._context,elements:t})}withDefaultElements(t){return new ConfiguratorBuilder({...this._context,defaultElements:t})}withResources(t){return new ConfiguratorBuilder({...this._context,resources:t})}withWebComponentTag(t){return new ConfiguratorBuilder({...this._context,tagName:t})}withTransformers(t,e){return new ConfiguratorBuilder({...this._context,transformers:{importedTransformers:t,specTransformers:e}})}withInterface(t){return this}withDataSpec=t=>new ConfiguratorBuilder({...this._context,dataSpec:t});_computeInitialPublishedData(t,e,i){if(!this._context.adminDomainFactory)throw Error("adminDomainFactory is required!");return u({adminDomainFactory:this._context.adminDomainFactory,domainRuntime:e,adminPresets:this._context.adminPresets??[],handlers:i,dataSpec:this._context.dataSpec,chunks:this._context.chunks,logger:t})}buildConfig(){return this._buildConfigWithHandlers().config}_buildConfigWithHandlers(){if(!this._context.domainFactory)throw Error("Can not create application config, domainFactory is required! Is it registered with the ConfiguratorBuilder?");if(!this._context.presets)throw Error("Can not create application config, presets are required! Is it registered with the ConfiguratorBuilder?");if(!this._context.adminDomainFactory)throw Error("Can not create application config, adminDomainFactory is required! Is it registered with the ConfiguratorBuilder?");if(!this._context.adminPresets)throw Error("Can not create application config, adminPresets are required! Is it registered with the ConfiguratorBuilder?");if(!this._context.version)throw Error("Can not create application config, version is required!");let i=this._context.tagName??"salsita-configurator",s={defaultEnvs:this._context.defaultEnvs,services:{i18n:this._context.i18n},version:this._context.version,initialPublishedData:{},domain:{textLanguages:this._context.textLanguages,componentOptics:this._context.componentOptics,presets:this._context.presets,domainFactory:this._context.domainFactory},navigation:{navigationStates:this._context.navigationState?.values(),viewStates:this._context.viewState?.values(),toolStates:this._context.toolState?.values(),exportStates:this._context.exportState?.values()},adminNavigation:{navigationStates:this._context.adminNavigationState?.values(),viewStates:this._context.adminViewState?.values()},adminDomain:{textLanguages:this._context.textLanguages,componentOptics:this._context.adminComponentOptics??[],presets:this._context.adminPresets,domainFactory:this._context.adminDomainFactory},mount:{tag:i,options:{}},handlers:this._context.handlers??[],elements:this._context.elements??[],defaultElements:this._context.defaultElements??[],transformers:this._context.transformers,features:{acl:this._context.acl,enableAdminRelease:this._context.enableAdminRelease},ui:{preview:this._context.ui?.preview,alwaysExpand:this._context.ui?.alwaysExpand,theme:this._context.theme},resources:this._context.resourcesConfig,chunks:this._context.chunks,publishedDataHash:this._context.publishedDataHash,assistant:this._context.assistant,dataSpec:this._context.dataSpec},u=t(),h=n({config:s,services:{analyticsService:new r,i18n:e,logger:u}}),l=h.getState().spec.configurator.handlers;checkSingleInstanceHandlers(l);let c=l.find(o)?.handler().handler,d=l.find(a)?.handler().handler(void 0),m=this._computeInitialPublishedData(u,h,l);return{config:{...s,mount:{tag:i,options:d??{},Application:c},initialPublishedData:m},handlers:l}}buildWebhookContext(){if(!this._context.domainFactory)throw Error("domainFactory is required!");if(!this._context.adminDomainFactory)throw Error("adminDomainFactory is required!");if(!this._context.adminPresets)throw Error("adminPresets are required!");let{config:t,handlers:e}=this._buildConfigWithHandlers(),r=t=>{if(null==this._context.finalizeData)return{};let e=i.compile(this._context.finalizeData);if(!e(t))throw console.error("Finalize data validation errors:",e.errors),Error("Invalid finalize data!");return t},n=t=>{if(null==this._context.finalizeResult)return{};let e=i.compile(this._context.finalizeResult);if(!e(t))throw console.error("Finalize result validation errors:",e.errors),Error("Invalid finalize result!");return t},o=t=>{if(null==this._context.callbackData)return{};let e=i.compile(this._context.callbackData);if(!e(t))throw console.error("Callback data validation errors:",e.errors),Error("Invalid callback data!");return t},a=e.find(d)?.handler().handler,s=e.find(c)?.handler().handler,u=e.find(h)?.handler().handler,l=e.find(m)?.handler().handler;return{config:t,parseFinalizeData:r,parseFinalizeResult:n,resources:this._context.resources??[],parseCallbackData:o,mapPublishedRevisionData:a,mapPublishedChunkedData:s,dataRowValidator:u,sheetValidator:l}}}
@@ -2,7 +2,7 @@ export { type DomainConfig, type NavigationConfig, type ISessionService, type Se
2
2
  export { type AssistantFieldOption, findAssistantFieldOptions, readAssistantFieldOptions, } from './assistant-field-options.js';
3
3
  export { deleteEntityUpdateTag, findAssistantMutation, modifyEntityUpdateTag } from './assistant-mutations.js';
4
4
  export { type AssistantRecipe, type AssistantRecipeContext, type AssistantRecipeGroupSnapshot, type AssistantRecipeKind, findAssistantRecipeGroups, prepareAssistantRecipeUpdates, readAssistantRecipeGroup, } from './assistant-recipe-groups.js';
5
- export { ConfiguratorBuilder } from './configurator-builder.js';
5
+ export { ConfiguratorBuilder, checkSingleInstanceHandlers } from './configurator-builder.js';
6
6
  export * from './admin-page-factories.js';
7
7
  export { createInitialPublishedData, type CreateInitialPublishedDataProps } from './create-initial-published-data.js';
8
8
  export { webComponentAttributeParsers, createWebComponentPropertyDescriptor, type AttributeParser, type WebComponentPropertyDescriptor, } from './web-component-property.js';
@@ -1 +1 @@
1
- export{findAssistantFieldOptions,readAssistantFieldOptions}from"./assistant-field-options.js";export{deleteEntityUpdateTag,findAssistantMutation,modifyEntityUpdateTag}from"./assistant-mutations.js";export{findAssistantRecipeGroups,prepareAssistantRecipeUpdates,readAssistantRecipeGroup}from"./assistant-recipe-groups.js";export{ConfiguratorBuilder}from"./configurator-builder.js";export*from"./admin-page-factories.js";export{createInitialPublishedData}from"./create-initial-published-data.js";export{webComponentAttributeParsers,createWebComponentPropertyDescriptor}from"./web-component-property.js";export{createWebComponentEventDescriptor}from"./web-component-event.js";export{standardWebComponentProperties}from"./standard-properties.js";export{standardWebComponentEvents}from"./standard-events.js";export{createGetApplicationWrapperHandler,isGetApplicationWrapperHandler}from"./GetApplicationWrapperHandler.js";export{createGetThemeHandler,GetThemeHandlerName,isGetThemeHandler}from"./GetThemeHandler.js";export{createGetWebComponentOptionsHandler,isGetWebComponentOptionsHandler}from"./GetWebComponentOptions.js";export{createFinalizeAdminDomain}from"./published-data/create-finalize-admin-domain.js";export{FilterPublishedChunksHandlerName,isFilterPublishedChunksHandler}from"./published-data/FilterPublishedChunksHandler.js";export{mapPublishedData}from"./published-data/map-published-data.js";export{flattenTabData,mapDefaultValuesToRecords,mapPublishedChunkedData,SYSTEM_CHUNK_KEY,SYSTEM_CHUNK_SCOPE,SWATCH_DEFINITION}from"./published-data/map-published-chunked-data.js";export{buildLegendRows}from"./published-data/build-legend-data.js";export{formatFieldType,getFieldDescription}from"./published-data/format-field-type.js";export{mapDataToSheet}from"./published-data/map-data-to-sheet.js";export{validateRows}from"./published-data/validate-sheet-data.js";export{createDataRowValidatorHandler,DataRowValidatorHandlerName,isDataRowValidatorHandler}from"./published-data/DataRowValidatorHandler.js";export{createSheetValidatorHandler,SheetValidatorHandlerName,isSheetValidatorHandler}from"./published-data/SheetValidatorHandler.js";export{createMapPublishedRevisionDataHandler,createMapPublishedRevisionDataHandlerFactory,isMapPublishedRevisionDataHandler}from"./published-data/MapPublishedRevisionDataHandler.js";export{createMapPublishedChunkedDataHandler,createMapPublishedChunkedDataHandlerFactory,isMapPublishedChunkedDataHandler}from"./published-data/MapPublishedChunkedDataHandler.js";export*from"./assistant/index.js";
1
+ export{findAssistantFieldOptions,readAssistantFieldOptions}from"./assistant-field-options.js";export{deleteEntityUpdateTag,findAssistantMutation,modifyEntityUpdateTag}from"./assistant-mutations.js";export{findAssistantRecipeGroups,prepareAssistantRecipeUpdates,readAssistantRecipeGroup}from"./assistant-recipe-groups.js";export{ConfiguratorBuilder,checkSingleInstanceHandlers}from"./configurator-builder.js";export*from"./admin-page-factories.js";export{createInitialPublishedData}from"./create-initial-published-data.js";export{webComponentAttributeParsers,createWebComponentPropertyDescriptor}from"./web-component-property.js";export{createWebComponentEventDescriptor}from"./web-component-event.js";export{standardWebComponentProperties}from"./standard-properties.js";export{standardWebComponentEvents}from"./standard-events.js";export{createGetApplicationWrapperHandler,isGetApplicationWrapperHandler}from"./GetApplicationWrapperHandler.js";export{createGetThemeHandler,GetThemeHandlerName,isGetThemeHandler}from"./GetThemeHandler.js";export{createGetWebComponentOptionsHandler,isGetWebComponentOptionsHandler}from"./GetWebComponentOptions.js";export{createFinalizeAdminDomain}from"./published-data/create-finalize-admin-domain.js";export{FilterPublishedChunksHandlerName,isFilterPublishedChunksHandler}from"./published-data/FilterPublishedChunksHandler.js";export{mapPublishedData}from"./published-data/map-published-data.js";export{flattenTabData,mapDefaultValuesToRecords,mapPublishedChunkedData,SYSTEM_CHUNK_KEY,SYSTEM_CHUNK_SCOPE,SWATCH_DEFINITION}from"./published-data/map-published-chunked-data.js";export{buildLegendRows}from"./published-data/build-legend-data.js";export{formatFieldType,getFieldDescription}from"./published-data/format-field-type.js";export{mapDataToSheet}from"./published-data/map-data-to-sheet.js";export{validateRows}from"./published-data/validate-sheet-data.js";export{createDataRowValidatorHandler,DataRowValidatorHandlerName,isDataRowValidatorHandler}from"./published-data/DataRowValidatorHandler.js";export{createSheetValidatorHandler,SheetValidatorHandlerName,isSheetValidatorHandler}from"./published-data/SheetValidatorHandler.js";export{createMapPublishedRevisionDataHandler,createMapPublishedRevisionDataHandlerFactory,isMapPublishedRevisionDataHandler}from"./published-data/MapPublishedRevisionDataHandler.js";export{createMapPublishedChunkedDataHandler,createMapPublishedChunkedDataHandlerFactory,isMapPublishedChunkedDataHandler}from"./published-data/MapPublishedChunkedDataHandler.js";export*from"./assistant/index.js";
@@ -0,0 +1,39 @@
1
+ import type { AnyApplicationConfig, DefaultEnvs } from '../application/index.js';
2
+ import type { PersistenceConfig } from './environment/index.js';
3
+ import { type ApplicationSpec } from './spec/index.js';
4
+ /**
5
+ * The environment an application runs in, before the runtime resolves it: the values of the
6
+ * phoenix runtime config (`defaultEnvs`), and the deployment id, the development flag and the
7
+ * persistence when the host sets them explicitly.
8
+ */
9
+ interface ApplicationEnvironmentInput {
10
+ readonly defaultEnvs?: DefaultEnvs | undefined;
11
+ readonly deploymentId?: string | undefined;
12
+ readonly isDev?: boolean | undefined;
13
+ readonly persistence?: PersistenceConfig | undefined;
14
+ }
15
+ /**
16
+ * An application ready to run: the spec slice of the domain runtime, the environment it runs in,
17
+ * the services it uses (i18n, and a logger, analytics or admin integration a host provides) and the
18
+ * tag of the web component it mounts as.
19
+ *
20
+ * `createApplication` of `@salsita-ai/sdk/application-spec` builds one from an
21
+ * application's runtime spec and its project modules, without a builder or an `ApplicationConfig`.
22
+ * `TYPES` is the project's types; no value carries it at run time.
23
+ */
24
+ export interface Application<TYPES = unknown> {
25
+ readonly spec: ApplicationSpec;
26
+ readonly environment: ApplicationEnvironmentInput;
27
+ readonly services: NonNullable<AnyApplicationConfig['services']>;
28
+ readonly tag: string;
29
+ /** Never set: it carries `TYPES` to the functions that take the application. */
30
+ readonly '~types'?: TYPES;
31
+ }
32
+ /**
33
+ * Converts the config of a project built with `ConfiguratorBuilder` to the application a runtime
34
+ * starts from. It checks the project's files (`initializeSpec`) and throws every mistake together,
35
+ * so a host converts it where it shows a failed start: a mount when an element starts, the domain
36
+ * runtime when it initializes.
37
+ */
38
+ export declare const applicationFromConfig: (config: AnyApplicationConfig) => Application;
39
+ export {};
@@ -0,0 +1 @@
1
+ import{initializeSpec as e}from"./spec/index.js";export const applicationFromConfig=s=>({spec:e(s),environment:{defaultEnvs:s.defaultEnvs,deploymentId:s.deploymentId,isDev:s.isDev,persistence:s.persistence},services:s.services??{},tag:s.mount.tag});
@@ -1,6 +1,7 @@
1
1
  import { BehaviorSubject } from 'rxjs';
2
2
  import type { AnyApplicationConfig } from '../application/index.js';
3
3
  import { type ApplicationAccessInfo } from './access/index.js';
4
+ import { type Application } from './application.js';
4
5
  import { type ApplicationDomainContextState, type DomainApplicationType, type InitializableSystem } from './domain-context/index.js';
5
6
  import { type ApplicationDomainData } from './domain-data/index.js';
6
7
  import { type DomainRuntimeServices } from './domain-services/index.js';
@@ -21,17 +22,30 @@ export interface DomainRuntimeState {
21
22
  readonly webComponent: ApplicationWebComponentState;
22
23
  readonly domainContext: ApplicationDomainContextState;
23
24
  }
24
- interface Props<State extends DomainRuntimeState> {
25
+ /**
26
+ * What a domain runtime starts from: the spec slice and the environment of an application, or the
27
+ * config of a project built with `ConfiguratorBuilder`, which is converted to them when the runtime
28
+ * initializes.
29
+ */
30
+ type DomainRuntimeSource = {
31
+ readonly application: Pick<Application, 'spec' | 'environment'>;
32
+ readonly config?: undefined;
33
+ } | {
25
34
  readonly config: AnyApplicationConfig;
35
+ readonly application?: undefined;
36
+ };
37
+ type DomainRuntimeProps = DomainRuntimeSource & {
26
38
  readonly services: DomainRuntimeServices;
27
- readonly getSubject: () => BehaviorSubject<State>;
28
39
  /**
29
40
  * Systems a host layers onto a slot's domain initialization. Webhook and finalize hosts run the
30
41
  * domain alone and pass nothing; the application runtime contributes its domain-application
31
42
  * systems here.
32
43
  */
33
44
  readonly getExtensionSystems?: (applicationType: DomainApplicationType) => readonly InitializableSystem[];
34
- }
45
+ };
46
+ type Props<State extends DomainRuntimeState> = DomainRuntimeProps & {
47
+ readonly getSubject: () => BehaviorSubject<State>;
48
+ };
35
49
  export declare function createDomainRuntimeSlices<State extends DomainRuntimeState>(props: Props<State>): {
36
50
  initialize: () => {
37
51
  spec: ApplicationSpec;
@@ -643,7 +657,7 @@ export declare function createDomainRuntimeSlices<State extends DomainRuntimeSta
643
657
  };
644
658
  };
645
659
  export type DomainRuntimeSlices = ReturnType<typeof createDomainRuntimeSlices>;
646
- export declare const createDomainRuntime: (props: Omit<Props<DomainRuntimeState>, 'getSubject'>) => {
660
+ export declare const createDomainRuntime: (props: DomainRuntimeProps) => {
647
661
  initialize: () => {
648
662
  spec: ApplicationSpec;
649
663
  overrides: ApplicationOverrides;
@@ -1 +1 @@
1
- import{BehaviorSubject as e}from"rxjs";import{createAccessInfoActions as t,createAccessInfoSelectors as n,initializeAccessInfo as a}from"./access/index.js";import{createDomainContextActions as o,createDomainContextSelectors as i,initializeDomainContext as s}from"./domain-context/index.js";import{createDomainDataActions as r,createDomainDataSelectors as m,initializeDomainData as l}from"./domain-data/index.js";import{createDomainServicesSelectors as d}from"./domain-services/index.js";import{createEnvironmentActions as c,createEnvironmentSelectors as u,initializeEnvironment as v}from"./environment/index.js";import{createLoadedDataActions as x,createLoadedDataSelectors as p,initializeLoadedData as S}from"./loaded-data/index.js";import{createOverridesActions as f,createOverridesSelectors as g,initializeOverrides as C}from"./overrides/index.js";import{createSessionContextActions as D,createSessionContextSelectors as b,initializeSessionContext as j}from"./session-context/index.js";import{createSpecActions as w,createSpecSelectors as y,initializeSpec as E}from"./spec/index.js";import{createWebComponentActions as z,createWebComponentSelectors as R,initializeWebComponent as h}from"./web-component/index.js";export function createDomainRuntimeSlices(e){let{config:A,getSubject:T,services:I,getExtensionSystems:L}=e,M=w({setSpec:e=>{let t=T(),n=e(t.value.spec);t.next({...t.value,spec:n})}}),O=y({getState:()=>T().value}),W=d({services:I,specSelectors:O}),k=f({setOverrides:e=>{let t=T(),n=e(t.value.overrides);t.next({...t.value,overrides:n})}}),q=g({getState:()=>T().value}),B=u({getState:()=>T().value,overridesSelectors:q}),F=c({setEnvironment:e=>{let t=T(),n=e(t.value.environment);t.next({...t.value,environment:n})}}),G=x({setLoadedData:e=>{let t=T(),n=e(t.value.loadedData);t.next({...t.value,loadedData:n})}}),H=p({getState:()=>T().value}),J=r({setDomainDataState:e=>{let t=T(),n=e(t.value.domainData);t.next({...t.value,domainData:n})}}),K=m({getState:()=>T().value,overridesSelectors:q}),N=D({setSessionContextState:e=>{let t=T(),n=e(t.value.sessionContext);t.next({...t.value,sessionContext:n})}}),P=b({getState:()=>T().value,overridesSelectors:q}),Q=t({setAccessInfoState:e=>{let t=T(),n=e(t.value.access);t.next({...t.value,access:n})}}),U=n({getState:()=>T().value,overridesSelectors:q}),{setLocale:V,...X}=z({setWebComponentState:e=>{let t=T(),n=e(t.value.webComponent);t.next({...t.value,webComponent:n})}}),Y=R({getState:()=>T().value}),Z=o({setDomainContextState:e=>{let t=T(),n=e(t.value.domainContext);t.next({...t.value,domainContext:n})}}),$={configurator:i({applicationType:"configurator",getState:()=>T().value,actions:Z.configurator,getExtensionSystems:()=>L?.("configurator")??[],specSelectors:O,accessSelectors:U,webComponentSelectors:Y,domainDataSelectors:K,sessionContextSelectors:P,domainServicesSelectors:W,environmentSelectors:B}),admin:i({applicationType:"admin",getState:()=>T().value,actions:Z.admin,getExtensionSystems:()=>L?.("admin")??[],specSelectors:O,accessSelectors:U,webComponentSelectors:Y,domainDataSelectors:K,sessionContextSelectors:P,domainServicesSelectors:W,environmentSelectors:B})};return{initialize:()=>({spec:E(A),overrides:C(),environment:v(A),loadedData:S(),domainData:l(),sessionContext:j(),access:a(),webComponent:h(),domainContext:s()}),selectors:{domainServices:W,spec:O,overrides:q,environment:B,loadedData:H,domainData:K,sessionContext:P,access:U,webComponent:Y,domainContext:$},actions:{spec:M,overrides:k,environment:F,loadedData:G,domainData:J,sessionContext:N,access:Q,webComponent:X,domainContext:Z},hostMirrorActions:{setLocale:V}}}export const createDomainRuntime=t=>{let{config:n,services:a,getExtensionSystems:o}=t,i=null,s=createDomainRuntimeSlices({config:n,getSubject:()=>{if(!i)throw Error("Subject not yet initialized!");return i},services:a,getExtensionSystems:o});return i=new e(s.initialize()),{...s,getState:()=>i.value,subscribe:e=>{let t=i.subscribe(()=>e());return()=>t.unsubscribe()}}};
1
+ import{BehaviorSubject as e}from"rxjs";import{createAccessInfoActions as t,createAccessInfoSelectors as n,initializeAccessInfo as a}from"./access/index.js";import{applicationFromConfig as o}from"./application.js";import{createDomainContextActions as i,createDomainContextSelectors as s,initializeDomainContext as r}from"./domain-context/index.js";import{createDomainDataActions as m,createDomainDataSelectors as l,initializeDomainData as c}from"./domain-data/index.js";import{createDomainServicesSelectors as d}from"./domain-services/index.js";import{createEnvironmentActions as u,createEnvironmentSelectors as v,initializeEnvironment as p}from"./environment/index.js";import{createLoadedDataActions as x,createLoadedDataSelectors as S,initializeLoadedData as f}from"./loaded-data/index.js";import{createOverridesActions as g,createOverridesSelectors as C,initializeOverrides as D}from"./overrides/index.js";import{createSessionContextActions as b,createSessionContextSelectors as j,initializeSessionContext as w}from"./session-context/index.js";import{createSpecActions as y,createSpecSelectors as E}from"./spec/index.js";import{createWebComponentActions as z,createWebComponentSelectors as R,initializeWebComponent as h}from"./web-component/index.js";export function createDomainRuntimeSlices(e){let{getSubject:A,services:T,getExtensionSystems:I}=e,L=y({setSpec:e=>{let t=A(),n=e(t.value.spec);t.next({...t.value,spec:n})}}),M=E({getState:()=>A().value}),O=d({services:T,specSelectors:M}),W=g({setOverrides:e=>{let t=A(),n=e(t.value.overrides);t.next({...t.value,overrides:n})}}),k=C({getState:()=>A().value}),q=v({getState:()=>A().value,overridesSelectors:k}),B=u({setEnvironment:e=>{let t=A(),n=e(t.value.environment);t.next({...t.value,environment:n})}}),F=x({setLoadedData:e=>{let t=A(),n=e(t.value.loadedData);t.next({...t.value,loadedData:n})}}),G=S({getState:()=>A().value}),H=m({setDomainDataState:e=>{let t=A(),n=e(t.value.domainData);t.next({...t.value,domainData:n})}}),J=l({getState:()=>A().value,overridesSelectors:k}),K=b({setSessionContextState:e=>{let t=A(),n=e(t.value.sessionContext);t.next({...t.value,sessionContext:n})}}),N=j({getState:()=>A().value,overridesSelectors:k}),P=t({setAccessInfoState:e=>{let t=A(),n=e(t.value.access);t.next({...t.value,access:n})}}),Q=n({getState:()=>A().value,overridesSelectors:k}),{setLocale:U,...V}=z({setWebComponentState:e=>{let t=A(),n=e(t.value.webComponent);t.next({...t.value,webComponent:n})}}),X=R({getState:()=>A().value}),Y=i({setDomainContextState:e=>{let t=A(),n=e(t.value.domainContext);t.next({...t.value,domainContext:n})}}),Z={configurator:s({applicationType:"configurator",getState:()=>A().value,actions:Y.configurator,getExtensionSystems:()=>I?.("configurator")??[],specSelectors:M,accessSelectors:Q,webComponentSelectors:X,domainDataSelectors:J,sessionContextSelectors:N,domainServicesSelectors:O,environmentSelectors:q}),admin:s({applicationType:"admin",getState:()=>A().value,actions:Y.admin,getExtensionSystems:()=>I?.("admin")??[],specSelectors:M,accessSelectors:Q,webComponentSelectors:X,domainDataSelectors:J,sessionContextSelectors:N,domainServicesSelectors:O,environmentSelectors:q})};return{initialize:()=>{let t=e.application??o(e.config);return{spec:t.spec,overrides:D(),environment:p(t.environment),loadedData:f(),domainData:c(),sessionContext:w(),access:a(),webComponent:h(),domainContext:r()}},selectors:{domainServices:O,spec:M,overrides:k,environment:q,loadedData:G,domainData:J,sessionContext:N,access:Q,webComponent:X,domainContext:Z},actions:{spec:L,overrides:W,environment:B,loadedData:F,domainData:H,sessionContext:K,access:P,webComponent:V,domainContext:Y},hostMirrorActions:{setLocale:U}}}export const createDomainRuntime=t=>{let n=null,a=createDomainRuntimeSlices({...t,getSubject:()=>{if(!n)throw Error("Subject not yet initialized!");return n}});return n=new e(a.initialize()),{...a,getState:()=>n.value,subscribe:e=>{let t=n.subscribe(()=>e());return()=>t.unsubscribe()}}};
@@ -2,4 +2,4 @@ import type { AnyApplicationConfig } from '../../application/index.js';
2
2
  import type { ApplicationEnvironmentConfig } from './types.js';
3
3
  export declare const GOD_MODE_SESSION_STORAGE_KEY = "salsita-god-mode";
4
4
  export declare const isNotRegisteredDeploymentId: (deploymentId: string) => boolean;
5
- export declare const initializeEnvironment: (config: AnyApplicationConfig) => ApplicationEnvironmentConfig;
5
+ export declare const initializeEnvironment: (config: Pick<AnyApplicationConfig, 'defaultEnvs' | 'deploymentId' | 'isDev' | 'persistence'>) => ApplicationEnvironmentConfig;
@@ -1,4 +1,5 @@
1
1
  export * from './domain-runtime.js';
2
+ export { type Application, applicationFromConfig } from './application.js';
2
3
  export * from './domain-context/index.js';
3
4
  export * from './domain-services/index.js';
4
5
  export { type ImplementationErrorCode, type ImplementationErrorCollector, type ImplementationErrorProps, type StartupStage, ImplementationError, ImplementationErrors, createImplementationErrorCollector, isImplementationError, isImplementationErrors, toImplementationErrors, } from './errors/index.js';
@@ -1 +1 @@
1
- export*from"./domain-runtime.js";export*from"./domain-context/index.js";export*from"./domain-services/index.js";export{ImplementationError,ImplementationErrors,createImplementationErrorCollector,isImplementationError,isImplementationErrors,toImplementationErrors}from"./errors/index.js";export*from"./spec/index.js";export*from"./environment/index.js";export*from"./access/index.js";export*from"./overrides/index.js";export*from"./loaded-data/index.js";export*from"./domain-data/index.js";export*from"./session-context/index.js";export*from"./web-component/index.js";
1
+ export*from"./domain-runtime.js";export{applicationFromConfig}from"./application.js";export*from"./domain-context/index.js";export*from"./domain-services/index.js";export{ImplementationError,ImplementationErrors,createImplementationErrorCollector,isImplementationError,isImplementationErrors,toImplementationErrors}from"./errors/index.js";export*from"./spec/index.js";export*from"./environment/index.js";export*from"./access/index.js";export*from"./overrides/index.js";export*from"./loaded-data/index.js";export*from"./domain-data/index.js";export*from"./session-context/index.js";export*from"./web-component/index.js";
@@ -1,4 +1,5 @@
1
1
  import type { DeploymentAssistant } from '@salsita-ai/contracts/assistant';
2
+ import { type ApplicationSpec } from '#package/application-spec';
2
3
  import type { Logger } from '../utils/index.js';
3
4
  interface ResolveOptions {
4
5
  readonly skipUpload: boolean;
@@ -22,6 +23,8 @@ interface DeploymentData {
22
23
  readonly assistant: boolean;
23
24
  /** Generated locally for prepare-command diagnostics; never sent to the server. */
24
25
  readonly assistantSetup: DeploymentAssistant | undefined;
26
+ /** {@link getDeploymentFingerprint} of the spec the data was resolved from; never sent to the server. */
27
+ readonly fingerprint: string;
25
28
  readonly assets: {
26
29
  readonly privateFilePaths: readonly string[];
27
30
  readonly publicFilePaths: readonly string[];
@@ -29,6 +32,14 @@ interface DeploymentData {
29
32
  readonly publicFilesFullPaths: readonly string[];
30
33
  };
31
34
  }
35
+ /**
36
+ * Fingerprint of what the server applies to the requests of a deployment prepared from the spec: the configurator and
37
+ * admin configuration schemas with their versions, the published data schema, the auth hook, the roles that may
38
+ * create configurations and the assistant. Preparing a development deployment records it in the generated env file,
39
+ * and `phoenix dev` prepares again when the spec's fingerprint differs from the recorded one, such as after a domain
40
+ * model change.
41
+ */
42
+ export declare const getDeploymentFingerprint: (applicationSpec: ApplicationSpec) => string;
32
43
  /** Resolves deployment data using the new application-spec pipeline (parse only, no codegen/write). */
33
44
  export declare const resolveApplicationSpecDeploymentData: (options: ResolveOptions) => Promise<DeploymentData>;
34
45
  export {};
@@ -1,2 +1,2 @@
1
- import{RuntimeReferenceStore as e,buildPhoenixDefinitions as a,parseApplicationFiles as s}from"#package/application-spec";import{generateAssistantPrompt as i,getAllPhxDefinitions as t}from"#package/domain";import{readApplicationFiles as o}from"./application-spec-file-reader.js";import{readProjectAssets as r}from"./read-project-assets.js";import{swcEvalExpressionParser as n,swcModuleAnalyzer as l}from"./swc-module-analyzer.js";export const resolveApplicationSpecDeploymentData=async p=>{let{skipUpload:c,logger:m}=p,u=s({rawProjectFiles:await o({envs:{}}),phxDefinitions:a(t())},{analyzer:l,evalExpressionParser:n,referenceStore:new e,logger:m});if(!u.ok)throw Error(`Failed to parse application spec:
2
- ${u.errors.map(e=>` [${e.code}] ${e.message}`).join("\n")}`);let{configurator:d,admin:h}=u.value.applicationSpec,{configurationSchema:v}=d,f=h.configurationSchema,S=await r(),g=[],F=[],b=[],A=[];c||(g=S.privateAssetFiles,F=S.publicAssetFiles,b=S.privateAssetFilesFullPaths,A=S.publicAssetFilesFullPaths,m.debug(`Scanned assets: ${g.length} private files, ${F.length} public files`));let{appMetadata:j,infra:w}=u.value.applicationSpec,{assistant:k,assistantServerSettings:D}=d;return{schema:{...v.schema},schemaVersion:v.version,adminSchema:{...f.schema},adminSchemaVersion:f.version,applicationVersion:j.applicationVersion,publishedDataHash:d.dataSchemas.publishedDataHash,useAuthHook:j.useAuthHook,aclCanCreate:w.acl.canCreate,embeddings:void 0,chat:void 0,assistant:null!==k&&null!==D,assistantSetup:k&&D?{sdl:k.sdl,prompt:i(k),instructions:D.instructions??void 0,ai:D.ai}:void 0,assets:{privateFilePaths:g,publicFilePaths:F,privateFilesFullPaths:b,publicFilesFullPaths:A}}};
1
+ import{createHash as e}from"node:crypto";import{RuntimeReferenceStore as a,buildPhoenixDefinitions as s,parseApplicationFiles as t}from"#package/application-spec";import{generateAssistantPrompt as i,getAllPhxDefinitions as n}from"#package/domain";import{readApplicationFiles as o}from"./application-spec-file-reader.js";import{readProjectAssets as r}from"./read-project-assets.js";import{swcEvalExpressionParser as c,swcModuleAnalyzer as l}from"./swc-module-analyzer.js";let p=e=>null!==e.assistant&&null!==e.assistantServerSettings;export const getDeploymentFingerprint=a=>{let{configurator:s,admin:t,appMetadata:i,infra:n}=a,o={configurationSchema:[s.configurationSchema.version,s.configurationSchema.hash],adminConfigurationSchema:[t.configurationSchema.version,t.configurationSchema.hash],publishedDataHash:s.dataSchemas.publishedDataHash,useAuthHook:i.useAuthHook,aclCanCreate:n.acl.canCreate,assistant:p(s)};return e("sha256").update(JSON.stringify(o)).digest("hex")};export const resolveApplicationSpecDeploymentData=async e=>{let{skipUpload:h,logger:m}=e,u=t({rawProjectFiles:await o({envs:{}}),phxDefinitions:s(n())},{analyzer:l,evalExpressionParser:c,referenceStore:new a,logger:m});if(!u.ok)throw Error(`Failed to parse application spec:
2
+ ${u.errors.map(e=>` [${e.code}] ${e.message}`).join("\n")}`);let{applicationSpec:d}=u.value,{configurator:g,admin:f}=d,{configurationSchema:S}=g,v=f.configurationSchema,F=await r(),b=[],A=[],D=[],y=[];h||(b=F.privateAssetFiles,A=F.publicAssetFiles,D=F.privateAssetFilesFullPaths,y=F.publicAssetFilesFullPaths,m.debug(`Scanned assets: ${b.length} private files, ${A.length} public files`));let{appMetadata:H,infra:k}=d,{assistant:C,assistantServerSettings:j}=g;return{schema:{...S.schema},schemaVersion:S.version,adminSchema:{...v.schema},adminSchemaVersion:v.version,applicationVersion:H.applicationVersion,publishedDataHash:g.dataSchemas.publishedDataHash,useAuthHook:H.useAuthHook,aclCanCreate:k.acl.canCreate,embeddings:void 0,chat:void 0,assistant:p(g),assistantSetup:C&&j?{sdl:C.sdl,prompt:i(C),instructions:j.instructions??void 0,ai:j.ai}:void 0,fingerprint:getDeploymentFingerprint(d),assets:{privateFilePaths:b,publicFilePaths:A,privateFilesFullPaths:D,publicFilesFullPaths:y}}};