twenty 2.63.0 → 2.65.0

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 (68) hide show
  1. package/dist/app-template/yarn.lock +18 -238
  2. package/dist/app-worker.cjs +1 -1
  3. package/dist/chunks/assert-app-roles-allowed-C4syxo2P.cjs +2 -0
  4. package/dist/chunks/{build-source-manifest-CxHynmsg.cjs → build-source-manifest-BXSPu3cN.cjs} +1 -1
  5. package/dist/chunks/{build-source-snapshot-CNYcI3lA.cjs → build-source-snapshot-DXDxwxMF.cjs} +1 -1
  6. package/dist/chunks/{cli-version.constant-ol3Ctp_7.cjs → cli-version.constant-DHNpJ_rq.cjs} +1 -1
  7. package/dist/chunks/compile-application-translations-Dkf_xJ-1.cjs +58 -0
  8. package/dist/chunks/compute-deterministic-uuid.util-BHojBHTU.cjs +1 -0
  9. package/dist/chunks/create-metadata-client-DOQK3gKE.cjs +6 -0
  10. package/dist/chunks/{extract-source-translations-DMxAPQGT.cjs → extract-source-translations-CdX9bsGE.cjs} +1 -1
  11. package/dist/chunks/fetch-app-export-kiQnE1Vi.cjs +1 -0
  12. package/dist/chunks/{fetch-metadata-inspection-BitnLMsU.cjs → fetch-metadata-inspection-9UIOxMWz.cjs} +1 -1
  13. package/dist/chunks/{fetch-signed-in-identity-Chv2DXkd.cjs → fetch-signed-in-identity-DS7llq6p.cjs} +1 -1
  14. package/dist/chunks/fetch-workspace-or-throw-DsxaW4lw.cjs +1 -0
  15. package/dist/chunks/{get-client-generation-skip-reason-cLYKdg9t.cjs → get-client-generation-skip-reason-BG0kMvEP.cjs} +1 -1
  16. package/dist/chunks/get-field-universal-identifier.util-4kQ5e4Tv.cjs +1 -0
  17. package/dist/chunks/getApplicationManifestRoleViolations-B1uo1G5p.cjs +1 -0
  18. package/dist/chunks/{global-flags.constant-jbTPGUzd.cjs → global-flags.constant-Cz9Pu1gw.cjs} +1 -1
  19. package/dist/chunks/{is-valid-package-name-Dsoc-rVq.cjs → is-valid-package-name-DOBkurja.cjs} +1 -1
  20. package/dist/chunks/pull-minimum-sdk-version.constant-C6NC1Jf_.cjs +6 -0
  21. package/dist/chunks/{pull-source-BR9wkaXA.cjs → pull-source-DKof1UA8.cjs} +1 -1
  22. package/dist/chunks/{read-application-identifier-BFC_sHg4.cjs → read-application-identifier-BB0WRzMY.cjs} +1 -1
  23. package/dist/chunks/{read-infer-deletion-option-CvBiu59G.cjs → read-infer-deletion-option-BiBJJH9Z.cjs} +1 -1
  24. package/dist/chunks/record-pull-base-D9koU6CG.cjs +1 -0
  25. package/dist/chunks/{resolve-command-target-BcuWptbH.cjs → resolve-command-target-BVgM2_NY.cjs} +1 -1
  26. package/dist/chunks/{run-app-add-command-BuoyG82_.cjs → run-app-add-command-D9UvSCRi.cjs} +3 -3
  27. package/dist/chunks/{run-app-apply-command-BFIPn04H.cjs → run-app-apply-command-BEF7BFvH.cjs} +1 -1
  28. package/dist/chunks/{run-app-build-command-BL5z2pAy.cjs → run-app-build-command-O25lkSwj.cjs} +1 -1
  29. package/dist/chunks/{run-app-dev-command-BcfV3DE-.cjs → run-app-dev-command-Boqdovo0.cjs} +1 -1
  30. package/dist/chunks/{run-app-exec-command-C17xcKow.cjs → run-app-exec-command-AejFDwrF.cjs} +1 -1
  31. package/dist/chunks/{run-app-generate-client-command-BV5PTy_i.cjs → run-app-generate-client-command-HQnRfPSd.cjs} +1 -1
  32. package/dist/chunks/{run-app-init-command-S9bUinGS.cjs → run-app-init-command-BiWlxuhq.cjs} +1 -1
  33. package/dist/chunks/{run-app-install-command-Cq9Jobbj.cjs → run-app-install-command-D6Iog7YY.cjs} +1 -1
  34. package/dist/chunks/{run-app-operation-CuZ4m1fm.cjs → run-app-operation-ya6yEswL.cjs} +1 -1
  35. package/dist/chunks/run-app-plan-command-C9teUXwT.cjs +1 -0
  36. package/dist/chunks/run-app-publish-command-TTp1zvc2.cjs +1 -0
  37. package/dist/chunks/run-app-pull-command-CB5ulUDP.cjs +6 -0
  38. package/dist/chunks/{run-app-typecheck-command-CIFFgU2u.cjs → run-app-typecheck-command-CwNuLuVW.cjs} +1 -1
  39. package/dist/chunks/{run-app-uninstall-command-Dhfci1zL.cjs → run-app-uninstall-command-BTxmy7EA.cjs} +1 -1
  40. package/dist/chunks/{run-auth-login-command-sYroS-oN.cjs → run-auth-login-command-GTYHkqks.cjs} +1 -1
  41. package/dist/chunks/{run-auth-status-command-DTOLTpcS.cjs → run-auth-status-command-D-RJkyHP.cjs} +1 -1
  42. package/dist/chunks/{run-cli-CtNeoYdv.cjs → run-cli-ChTwbHN0.cjs} +1 -1
  43. package/dist/chunks/{run-commands-command-Df3vekbG.cjs → run-commands-command-Dc2s4CLF.cjs} +1 -1
  44. package/dist/chunks/{run-data-export-command-D8bi-_eQ.cjs → run-data-export-command-Uona_veE.cjs} +1 -1
  45. package/dist/chunks/{run-data-get-command-AoCO8VBs.cjs → run-data-get-command-CsSFwlvd.cjs} +1 -1
  46. package/dist/chunks/{run-data-list-command-CMi1OeBV.cjs → run-data-list-command-DsUi50ev.cjs} +1 -1
  47. package/dist/chunks/{run-doctor-command-VaRt9-ya.cjs → run-doctor-command-BWUIB09t.cjs} +1 -1
  48. package/dist/chunks/{run-metadata-field-describe-command-vgmY2Cjn.cjs → run-metadata-field-describe-command-CO5xw_pA.cjs} +1 -1
  49. package/dist/chunks/{run-metadata-field-list-command-CVlFGJBc.cjs → run-metadata-field-list-command-BVQqm-C4.cjs} +1 -1
  50. package/dist/chunks/{run-metadata-object-describe-command-CjC9TIBb.cjs → run-metadata-object-describe-command-WqdWjHKk.cjs} +1 -1
  51. package/dist/chunks/{run-metadata-object-list-command-BkffcdhV.cjs → run-metadata-object-list-command-B9FNZf1p.cjs} +1 -1
  52. package/dist/chunks/{run-open-command-DFlEdJCd.cjs → run-open-command-CJdT-RJo.cjs} +1 -1
  53. package/dist/chunks/{run-version-command-CCBLrCKu.cjs → run-version-command-CVPmLMkq.cjs} +1 -1
  54. package/dist/chunks/{sign-in-to-remote-again-BhnOemXJ.cjs → sign-in-to-remote-again-BQY4nrqe.cjs} +1 -1
  55. package/dist/chunks/standard-object-fields.constant-5mGzYzj4.cjs +1 -0
  56. package/dist/chunks/typed-object-entries-1_YZ6pWb.cjs +1 -0
  57. package/dist/cli.cjs +1 -1
  58. package/package.json +2 -2
  59. package/dist/chunks/compile-application-translations-H-I23n4l.cjs +0 -58
  60. package/dist/chunks/create-metadata-client-BITefgbL.cjs +0 -6
  61. package/dist/chunks/fetch-workspace-or-throw-DI5HKKWN.cjs +0 -1
  62. package/dist/chunks/get-field-universal-identifier.util-d1401qKf.cjs +0 -1
  63. package/dist/chunks/pull-minimum-sdk-version.constant-DJS72Nbz.cjs +0 -6
  64. package/dist/chunks/record-pull-base-C97pZrKE.cjs +0 -1
  65. package/dist/chunks/run-app-plan-command-DaSA-Hil.cjs +0 -1
  66. package/dist/chunks/run-app-publish-command-2AWr5rt6.cjs +0 -1
  67. package/dist/chunks/run-app-pull-command-BESAEuyX.cjs +0 -6
  68. package/dist/chunks/standard-object-fields.constant-BxrNzIwQ.cjs +0 -1
@@ -1 +1 @@
1
- const e=require("./rolldown-runtime-mLOUI7ql.cjs"),t=require("./create-metadata-client-BITefgbL.cjs");var n=e.n({fetchSignedInIdentity:()=>r}),r=async({target:e,signal:n})=>{let r=t.t({target:e,signal:n});if(e.credentialKind===`apiKey`){let{currentWorkspace:e}=await r.query({currentWorkspace:{displayName:!0}});return{workspaceName:e.displayName??null,email:null}}let{currentWorkspace:i,currentUser:a}=await r.query({currentWorkspace:{displayName:!0},currentUser:{email:!0}});return{workspaceName:i.displayName??null,email:a.email}};Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
1
+ const e=require("./rolldown-runtime-mLOUI7ql.cjs"),t=require("./create-metadata-client-DOQK3gKE.cjs");var n=e.n({fetchSignedInIdentity:()=>r}),r=async({target:e,signal:n})=>{let r=t.t({target:e,signal:n});if(e.credentialKind===`apiKey`){let{currentWorkspace:e}=await r.query({currentWorkspace:{displayName:!0}});return{workspaceName:e.displayName??null,email:null}}let{currentWorkspace:i,currentUser:a}=await r.query({currentWorkspace:{displayName:!0},currentUser:{email:!0}});return{workspaceName:i.displayName??null,email:a.email}};Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
@@ -0,0 +1 @@
1
+ const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./isPlainObject-fJEJm71P.cjs"),r=require("./isValidUuid-D3NV1xmO.cjs"),i=require("./isValidUniversalIdentifier-DymFerYs.cjs"),a=require("./cli-error-CrUD8uMp.cjs"),o=require("./create-metadata-client-DOQK3gKE.cjs");var s=e.t(),c=async({target:e,signal:c,shouldIncludeCustomApplication:l=!1})=>{let u=(await o.t({target:e,signal:c}).query({currentWorkspace:{id:!0,...l?{workspaceCustomApplication:{universalIdentifier:!0}}:{}}}))?.currentWorkspace;if(!n.t(u)||!(0,s.isNonEmptyString)(u.id)||!r.t(u.id))throw new a.t({code:`INVALID_RESPONSE`,message:`${e.apiUrl} did not say which workspace these credentials belong to.`});if(l&&t.t(u.workspaceCustomApplication)&&(!n.t(u.workspaceCustomApplication)||!(0,s.isNonEmptyString)(u.workspaceCustomApplication.universalIdentifier)||!i.t(u.workspaceCustomApplication.universalIdentifier)))throw new a.t({code:`INVALID_RESPONSE`,message:`${e.apiUrl} returned an invalid workspace custom application identifier.`});return u};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
@@ -1 +1 @@
1
- const e=require("./build--4zYt4wd.cjs"),t=require("./get-client-sdk-package-path-2U3kDCRq.cjs"),n=require("./has-error-code-DsJeqbZq.cjs"),r=require("./cli-error-CrUD8uMp.cjs"),i=require("./to-worker-output-diagnostics-w1hZPfn0.cjs"),a=require("./create-metadata-client-BITefgbL.cjs"),o=require("./create-tooling-failure-0Foyei1R.cjs");let s=require("node:fs/promises");var c=e.t(),l=async({applicationUniversalIdentifier:e,context:{target:t,signal:n,output:i}})=>{i.progress({message:`Fetching the application schema…`});let o=(await a.t({target:t,signal:n}).query({__name:`ApplicationCoreGraphqlSchema`,applicationCoreGraphqlSchema:{__args:{applicationUniversalIdentifier:e}}}))?.applicationCoreGraphqlSchema;if(!(0,c.isNonEmptyString)(o)||o.trim().length===0)throw new r.t({code:`INVALID_RESPONSE`,message:`The server did not return an application GraphQL schema.`});return o},u=async({appPath:e,schema:t,sdk:n,context:{signal:r,output:a,outputMode:s}})=>{a.progress({message:`Generating the typed API client…`});let c=await i.n({request:{type:`generateSourceClient`,appPath:e,schema:t},signal:r}),l=i.s({value:c.result,parseData:i.o}),u=[...l.diagnostics,...i.t(c.output)];if(s===`human`)for(let e of u)a.progress({message:i.c(e)});if(!l.success)throw o.t({error:l.error,diagnostics:u,sdkVersion:n.version,operation:`generateClient`});return r.throwIfAborted(),u},d=async e=>u({...e,schema:await l(e)}),f=async({appPath:e})=>{if(await(0,s.lstat)(t.t({appPath:e})).then(()=>!1,e=>n.t(e,`ENOENT`)))return`twenty-client-sdk is not installed in the app's own node_modules.`};Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return f}});
1
+ const e=require("./build--4zYt4wd.cjs"),t=require("./get-client-sdk-package-path-2U3kDCRq.cjs"),n=require("./has-error-code-DsJeqbZq.cjs"),r=require("./cli-error-CrUD8uMp.cjs"),i=require("./to-worker-output-diagnostics-w1hZPfn0.cjs"),a=require("./create-metadata-client-DOQK3gKE.cjs"),o=require("./create-tooling-failure-0Foyei1R.cjs");let s=require("node:fs/promises");var c=e.t(),l=async({applicationUniversalIdentifier:e,context:{target:t,signal:n,output:i}})=>{i.progress({message:`Fetching the application schema…`});let o=(await a.t({target:t,signal:n}).query({__name:`ApplicationCoreGraphqlSchema`,applicationCoreGraphqlSchema:{__args:{applicationUniversalIdentifier:e}}}))?.applicationCoreGraphqlSchema;if(!(0,c.isNonEmptyString)(o)||o.trim().length===0)throw new r.t({code:`INVALID_RESPONSE`,message:`The server did not return an application GraphQL schema.`});return o},u=async({appPath:e,schema:t,sdk:n,context:{signal:r,output:a,outputMode:s}})=>{a.progress({message:`Generating the typed API client…`});let c=await i.n({request:{type:`generateSourceClient`,appPath:e,schema:t},signal:r}),l=i.s({value:c.result,parseData:i.o}),u=[...l.diagnostics,...i.t(c.output)];if(s===`human`)for(let e of u)a.progress({message:i.c(e)});if(!l.success)throw o.t({error:l.error,diagnostics:u,sdkVersion:n.version,operation:`generateClient`});return r.throwIfAborted(),u},d=async e=>u({...e,schema:await l(e)}),f=async({appPath:e})=>{if(await(0,s.lstat)(t.t({appPath:e})).then(()=>!1,e=>n.t(e,`ENOENT`)))return`twenty-client-sdk is not installed in the app's own node_modules.`};Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return f}});
@@ -0,0 +1 @@
1
+ const e=require("./compute-deterministic-uuid.util-BHojBHTU.cjs");var t=function(e){return e.ACTOR=`ACTOR`,e.ADDRESS=`ADDRESS`,e.ARRAY=`ARRAY`,e.BOOLEAN=`BOOLEAN`,e.CURRENCY=`CURRENCY`,e.DATE=`DATE`,e.DATE_TIME=`DATE_TIME`,e.EMAILS=`EMAILS`,e.FILES=`FILES`,e.FULL_NAME=`FULL_NAME`,e.LINKS=`LINKS`,e.MORPH_RELATION=`MORPH_RELATION`,e.MULTI_SELECT=`MULTI_SELECT`,e.NUMBER=`NUMBER`,e.NUMERIC=`NUMERIC`,e.PHONES=`PHONES`,e.POSITION=`POSITION`,e.RATING=`RATING`,e.RAW_JSON=`RAW_JSON`,e.RELATION=`RELATION`,e.RICH_TEXT=`RICH_TEXT`,e.SELECT=`SELECT`,e.TEXT=`TEXT`,e.TS_VECTOR=`TS_VECTOR`,e.UUID=`UUID`,e}({}),n=function(e){return e.MANY_TO_ONE=`MANY_TO_ONE`,e.ONE_TO_MANY=`ONE_TO_MANY`,e}({}),r=({applicationUniversalIdentifier:t,objectUniversalIdentifier:n,name:r})=>e.t({entityNamespace:`fieldMetadata`,value:`${n}:${r}`,applicationUniversalIdentifier:t});Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
@@ -0,0 +1 @@
1
+ const e=require("./isDefined-CJctgvfE.cjs"),t=require("./isNonEmptyArray-v52xg4Xj.cjs"),n=require("./compute-deterministic-uuid.util-BHojBHTU.cjs");var r=e=>e,i=({applicationUniversalIdentifier:e,roleUniversalIdentifier:t,objectMetadataUniversalIdentifier:r,rootRowLevelPermissionPredicateGroupUniversalIdentifier:i})=>n.t({entityNamespace:`rowLevelPermissionRule`,value:[t,r,i??`ungrouped`].join(`:`),applicationUniversalIdentifier:e}),a=({manifest:t})=>{let n=new Set(t.agents.map(e=>e.roleUniversalIdentifier).filter(e.t)),r=new Map,i=new Set;for(let{universalIdentifier:e}of t.roles){let a=[...e===t.application.defaultRoleUniversalIdentifier?[`requested`]:[],...n.has(e)?[`agent`]:[]];a.length===0?i.add(e):r.set(e,a)}return{roleKindsByUniversalIdentifier:r,standaloneRoleUniversalIdentifiers:i}},o=({rowLevelPermissionRuleUniversalIdentifier:e,...t})=>t,s=({rules:t,predicateGroups:n,predicates:r})=>{let i=new Set(t.map(({universalIdentifier:e})=>e)),a=({rowLevelPermissionRuleUniversalIdentifier:t})=>e.t(t)&&i.has(t),s=n.filter(a),c=r.filter(a),l=new Set(s.map(({universalIdentifier:e})=>e)),u=t=>e.t(t)&&l.has(t)?t:null,d=({ruleUniversalIdentifier:e,parentPredicateGroupUniversalIdentifier:t})=>{let n=c.filter(n=>n.rowLevelPermissionRuleUniversalIdentifier===e&&u(n.predicateGroupUniversalIdentifier)===t).map(({objectUniversalIdentifier:e,predicateGroupUniversalIdentifier:t,rowLevelPermissionRuleUniversalIdentifier:n,...r})=>r),r=s.filter(n=>n.rowLevelPermissionRuleUniversalIdentifier===e&&u(n.parentPredicateGroupUniversalIdentifier)===t).map(({objectUniversalIdentifier:t,parentPredicateGroupUniversalIdentifier:n,rowLevelPermissionRuleUniversalIdentifier:r,...i})=>({...i,...d({ruleUniversalIdentifier:e,parentPredicateGroupUniversalIdentifier:i.universalIdentifier})}));return{...n.length>0?{predicates:n}:{},...r.length>0?{predicateGroups:r}:{}}};return{rules:t.map(e=>({...e,...d({ruleUniversalIdentifier:e.universalIdentifier,parentPredicateGroupUniversalIdentifier:null})})),predicateGroups:n.filter(e=>!a(e)).map(o),predicates:r.filter(e=>!a(e)).map(o)}},c={canReadAllRecords:!1,canCreateAllRecords:!1,canUpdateAllRecords:!1,canSoftDeleteAllRecords:!1,canDestroyAllRecords:!1},l=({canReadAllRecords:t,canCreateAllRecords:n,canUpdateAllRecords:r,canSoftDeleteAllRecords:i,canDestroyAllRecords:a})=>({...e.t(t)?{canReadAllRecords:t}:{},...e.t(n)?{canCreateAllRecords:n}:{},...e.t(r)?{canUpdateAllRecords:r}:{},...e.t(i)?{canSoftDeleteAllRecords:i}:{},...e.t(a)?{canDestroyAllRecords:a}:{}}),u=({predicateGroupUniversalIdentifier:t,predicateGroupByUniversalIdentifier:n})=>{let r=new Set,i=t;for(;!r.has(i);){r.add(i);let t=n.get(i)?.parentPredicateGroupUniversalIdentifier;if(!e.t(t))break;i=t}return i},d=({object:t,fieldPermission:n})=>{let{fieldUniversalIdentifier:r,universalIdentifier:i}=n,a=n.canReadFieldValue===!1?[...t.unreadableFields??[],r]:t.unreadableFields,o=n.canUpdateFieldValue===!1?[...t.uneditableFields??[],r]:t.uneditableFields,s=e.t(i)?[...t.fieldPermissionIdentifiers??[],{fieldUniversalIdentifier:r,universalIdentifier:i}]:t.fieldPermissionIdentifiers;return{...t,...e.t(a)?{unreadableFields:a}:{},...e.t(o)?{uneditableFields:o}:{},...e.t(s)?{fieldPermissionIdentifiers:s}:{}}},f=({role:t,applicationUniversalIdentifier:n,objectDefaultsByUniversalIdentifier:r={}})=>{let{recordsPermissions:a={},canReadAllObjectRecords:o,canUpdateAllObjectRecords:f,canSoftDeleteAllObjectRecords:p,canDestroyAllObjectRecords:m,objectPermissions:h=[],fieldPermissions:g=[],rowLevelPermissionPredicateGroups:_=[],rowLevelPermissionPredicates:v=[],...y}=t,b=l({canReadAllRecords:a.canReadAllRecords??o,canCreateAllRecords:a.canCreateAllRecords,canUpdateAllRecords:a.canUpdateAllRecords??f,canSoftDeleteAllRecords:a.canSoftDeleteAllRecords??p,canDestroyAllRecords:a.canDestroyAllRecords??m}),x=new Map([...a.objects??[],...h.map(({universalIdentifier:t,objectUniversalIdentifier:n,canReadObjectRecords:r,canUpdateObjectRecords:i,canSoftDeleteObjectRecords:a,canDestroyObjectRecords:o})=>({...e.t(t)?{universalIdentifier:t}:{},objectUniversalIdentifier:n,...l({canReadAllRecords:r,canUpdateAllRecords:i,canSoftDeleteAllRecords:a,canDestroyAllRecords:o})}))].map(e=>[e.objectUniversalIdentifier,e])),S=e=>{let t=x.get(e)??{objectUniversalIdentifier:e};return x.set(e,t),t};for(let e of g){let t=S(e.objectUniversalIdentifier);x.set(t.objectUniversalIdentifier,d({object:t,fieldPermission:e}))}let C=new Map(_.map(e=>[e.universalIdentifier,e])),w=new Map,T=({objectUniversalIdentifier:a,predicateGroupUniversalIdentifier:o})=>{let s=e.t(o)?u({predicateGroupUniversalIdentifier:o,predicateGroupByUniversalIdentifier:C}):null,c=i({applicationUniversalIdentifier:n,roleUniversalIdentifier:t.universalIdentifier,objectMetadataUniversalIdentifier:a,rootRowLevelPermissionPredicateGroupUniversalIdentifier:s});if(!w.has(c)){let e=S(a),t=r[a],n=({declaredOnObject:e,declaredOnAllObjects:n,action:r})=>e??(((t?.isSystem??!1)||(n??!1))&&!(t?.disabledObjectPermissionActions??[]).includes(r)),i=n({declaredOnObject:e.canUpdateAllRecords,declaredOnAllObjects:b.canUpdateAllRecords,action:`canUpdateObjectRecords`});w.set(c,{universalIdentifier:c,objectUniversalIdentifier:a,canReadRecords:n({declaredOnObject:e.canReadAllRecords,declaredOnAllObjects:b.canReadAllRecords,action:`canReadObjectRecords`}),canCreateRecords:e.canCreateAllRecords??e.canUpdateAllRecords??b.canCreateAllRecords??i,canUpdateRecords:i,canSoftDeleteRecords:n({declaredOnObject:e.canSoftDeleteAllRecords,declaredOnAllObjects:b.canSoftDeleteAllRecords,action:`canSoftDeleteObjectRecords`}),canDestroyRecords:n({declaredOnObject:e.canDestroyAllRecords,declaredOnAllObjects:b.canDestroyAllRecords,action:`canDestroyObjectRecords`})})}return c},{rules:E}=s({predicateGroups:_.map(e=>({...e,rowLevelPermissionRuleUniversalIdentifier:T({objectUniversalIdentifier:e.objectUniversalIdentifier,predicateGroupUniversalIdentifier:e.universalIdentifier})})),predicates:v.map(e=>({...e,rowLevelPermissionRuleUniversalIdentifier:T({objectUniversalIdentifier:e.objectUniversalIdentifier,predicateGroupUniversalIdentifier:e.predicateGroupUniversalIdentifier})})),rules:[...w.values()]});for(let{objectUniversalIdentifier:e,...t}of E){let n=S(e);x.set(e,{...n,...c,rowLevelRecordsPermissions:[...n.rowLevelRecordsPermissions??[],t]})}return{...y,recordsPermissions:{...b,objects:[...x.values()]}}},p=e=>t.t(e.rowLevelRecordsPermissions),m=e=>[e,...e.rowLevelRecordsPermissions??[]].some(({unreadableFields:e,uneditableFields:n,fieldPermissionIdentifiers:r})=>t.t(e)||t.t(n)||t.t(r)),h=({canBeAssignedToUsers:e,canBeAssignedToApiKeys:t})=>e!==!1||t!==!1,g=({manifest:e})=>{let{roleKindsByUniversalIdentifier:n}=a({manifest:e});return e.roles.flatMap(r=>{let i={roleUniversalIdentifier:r.universalIdentifier,roleLabel:r.label},a=n.get(r.universalIdentifier)??[],o=!t.t(a)&&h(r)?[{...i,kind:`standaloneRole`}]:[],{objects:s}=f({role:r,applicationUniversalIdentifier:e.application.universalIdentifier}).recordsPermissions;return[...o,...[[`rowLevelRules`,p],[`fieldPermissions`,m]].flatMap(([e,n])=>{let r=s.filter(n).map(e=>e.objectUniversalIdentifier);return t.t(r)?[{...i,kind:e,roleKinds:a,objectUniversalIdentifiers:r}]:[]})]})},_=e=>{let n=r(`Role "${e.roleLabel}" (${e.roleUniversalIdentifier})`);if(e.kind===`standaloneRole`)return r(`${n} is neither the application role nor an agent role, and can be assigned to members or API keys. Set canBeAssignedToUsers and canBeAssignedToApiKeys to false so that only agents can hold it.`);let i=e.kind===`rowLevelRules`?`row-level rules`:`field permissions`;return r(`${n}, the ${t.t(e.roleKinds)?e.roleKinds.map(e=>e===`requested`?`application`:`agent`).join(` and `):`standalone`} role, declares ${i} on objects ${e.objectUniversalIdentifiers.join(`, `)}. Marketplace applications cannot declare ${i}: the workspace configures them.`)};Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return _}});
@@ -1 +1 @@
1
- var e={path:[`data`,`export`],description:`Export records to a CSV file with server-side permissions`,arguments:[{name:`object`,description:`Exact singular or plural API name`,required:!0}],options:[{flags:`--output <file>`,description:`Destination CSV file (required)`},{flags:`--fields <names>`,description:`Comma-separated field API names, in CSV order (default: active non-system fields)`},{flags:`--filter <expression>`,description:`REST filter expression, as in data list`},{flags:`--order-by <expression>`,description:`REST order_by expression, as in data list`},{flags:`--force`,description:`Replace an existing output file after a successful download`}],examples:[`twenty data export companies --output companies.csv`,`twenty data export companies --fields name,domainName,employees --filter 'employees[gte]:5000' --output large-companies.csv`,`twenty data export people --output people.csv --format ndjson`],outputModes:[`human`,`json`,`ndjson`],writes:!0,needsProject:!1,needsTarget:!0,requiredPermissions:[`EXPORT_CSV`],load:async()=>(await Promise.resolve().then(()=>require("./run-data-export-command-D8bi-_eQ.cjs"))).runDataExportCommand},t={path:[`local`,`start`],description:`Start the local Twenty development environment`,options:[{flags:`-p, --port <port>`,description:`HTTP port for a new instance (default: 2020, or 2021 with --test)`},{flags:`--test`,description:`Use the separate local test instance`}],arguments:[{name:`version`,description:`Twenty version or image tag (new instances: engines.twenty, then latest)`,required:!1}],examples:[`twenty local start`,`twenty local start 2.53.1 --test`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-local-start-command-B8N5Jgjd.cjs"))).runLocalStartCommand},n={path:[`local`,`stop`],description:`Stop the local environment, preserving its data`,options:[{flags:`--test`,description:`Use the separate local test instance`}],examples:[`twenty local stop`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-local-stop-command-D66F73fW.cjs"))).runLocalStopCommand},r={path:[`local`,`status`],description:`Show local environment status, URL and image`,options:[{flags:`--test`,description:`Use the separate local test instance`}],examples:[`twenty local status --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-local-status-command-BYxy0R9I.cjs"))).runLocalStatusCommand},i={path:[`local`,`logs`],description:`Stream local environment logs`,options:[{flags:`-n, --lines <lines>`,description:`Number of recent log lines (default: 50, maximum: 10000)`},{flags:`--no-follow`,description:`Print recent logs and exit`},{flags:`--test`,description:`Use the separate local test instance`}],examples:[`twenty local logs`,`twenty local logs --test --no-follow`],outputModes:[`human`,`ndjson`],writes:!1,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-local-logs-command-COsSRk3f.cjs"))).runLocalLogsCommand},a={path:[`local`,`reset`],description:`Delete the local environment and all its data`,options:[{flags:`--yes`,description:`Delete the local environment and its data without asking`},{flags:`--test`,description:`Use the separate local test instance`}],examples:[`twenty local reset`,`twenty local reset --test --yes`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-local-reset-command-m0x-EiA6.cjs"))).runLocalResetCommand},o={path:[`local`,`upgrade`],description:`Upgrade the local environment, preserving its data volumes`,options:[{flags:`--test`,description:`Use the separate local test instance`}],arguments:[{name:`version`,description:`Twenty version or image tag (default: engines.twenty, then latest)`,required:!1}],examples:[`twenty local upgrade`,`twenty local upgrade 2.53.1 --test`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-local-upgrade-command-6P71bQw6.cjs"))).runLocalUpgradeCommand},s={path:[`app`,`install`],description:`Install a registered app package in the target workspace`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--universal-identifier <id>`,description:`Registered app universal identifier, works without a local project`}],examples:[`twenty app install --remote dev`,`twenty app install --path ./apps/billing --json`,`twenty app install --universal-identifier <id> --remote staging --json`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!0,requiredPermissions:[`APPLICATIONS`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-install-command-Cq9Jobbj.cjs"))).runAppInstallCommand},c={path:[`app`,`publish`],description:`Build and publish the app to npm or a private Twenty registry`,options:[{flags:`--private`,description:`Publish to a Twenty server registry using --remote or the active target`},{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--tag <tag>`,description:`npm dist-tag, for example beta or next`}],examples:[`twenty app publish`,`twenty app publish --private --remote dev`,`twenty app publish --path ./apps/billing --tag beta --json`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-app-publish-command-2AWr5rt6.cjs"))).runAppPublishCommand},l={path:[`app`,`dev`],description:`Watch app source, build complete snapshots and sync changes to the workspace`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--prune`,description:`Delete remote entities missing from the app source (the default, except for the workspace custom application)`},{flags:`--no-prune`,description:`Keep remote entities missing from the app source`},{flags:`--no-delete`,description:`Deprecated alias of --no-prune`,hidden:!0},{flags:`--create`,description:`Allow registering and installing an app with no registration`},{flags:`--yes`,description:`Allow object and field deletions without asking`},{flags:`--verbose`,description:`Show watched and excluded external paths when scope changes`}],examples:[`twenty app dev --remote dev`,`twenty app dev --create --no-prune`,`twenty app dev --format ndjson --no-prune`,`twenty app dev --verbose`],outputModes:[`human`,`ndjson`],writes:!0,needsProject:!0,needsTarget:!0,requiredPermissions:[`APPLICATIONS`,`UPLOAD_FILE`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-dev-command-BcfV3DE-.cjs"))).runAppDevCommand},u={path:[`app`,`add`],description:`Add an object, field, logic function, front component or validation rule to an app`,arguments:[{name:`entity`,description:`object, field, logic-function, front-component or validation-rule (prompted when omitted)`,required:!1}],options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--name <name>`,description:`Definition name; also determines the generated filename`},{flags:`--create-view`,description:`Create a table view for the new object`},{flags:`--create-navigation-menu-item`,description:`Create a navigation menu item for the new object`},{flags:`--create-page-layout`,description:`Create a record page layout and its fields view for the new object`},{flags:`--name-plural <name>`,description:`Plural API name (object)`},{flags:`--label <label>`,description:`Display label (object or field; default: derived from name)`},{flags:`--label-plural <label>`,description:`Plural display label (object; default: derived from plural name)`},{flags:`--type <type>`,description:`Field type, for example TEXT, NUMBER or RELATION (default: TEXT)`},{flags:`--object <uuid>`,description:`Parent object universal identifier (field or validation rule)`},{flags:`--description <text>`,description:`Field description`},{flags:`--target-object <uuid>`,description:`Target object universal identifier (relation field)`},{flags:`--target-field <uuid>`,description:`Target field universal identifier (relation field)`},{flags:`--relation-type <type>`,description:`ONE_TO_MANY or MANY_TO_ONE (relation field; default: ONE_TO_MANY)`},{flags:`--on-delete <action>`,description:`CASCADE, RESTRICT, SET_NULL, NO_ACTION or None (relation field; default: CASCADE)`}],examples:[`twenty app add`,`twenty app add object --name invoice --name-plural invoices --no-input`,`twenty app add object --name invoice --name-plural invoices --create-view --create-navigation-menu-item --create-page-layout --no-input`,`twenty app add field --name amount --type NUMBER --object <object-universal-identifier> --json`,`twenty app add logic-function --name send-invoice --no-input`,`twenty app add front-component --name invoice-panel --no-input`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-app-add-command-BuoyG82_.cjs"))).runAppAddCommand},d={path:[`app`,`exec`],description:`Execute a deployed app logic function as the signed-in user`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--name <name>`,description:`Exact deployed function name`},{flags:`--universal-identifier <id>`,description:`Function universal identifier`},{flags:`--post-install`,description:`Execute the post-install hook without installing the app`},{flags:`--pre-install`,description:`Execute the pre-install hook without installing the app`},{flags:`--uninstall-hook`,description:`Execute the uninstall hook without uninstalling the app`},{flags:`--payload <json>`,description:`JSON object, @file or - for stdin (default: {})`}],examples:[`twenty app exec --name add-numbers --remote dev`,`twenty app exec --name add-numbers --payload @payload.json --json`,`twenty app exec --post-install --payload '{}'`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!0,requiredPermissions:[`APPLICATIONS`,`WORKFLOWS`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-exec-command-C17xcKow.cjs"))).runAppExecCommand},f={path:[`app`,`generate-client`],description:`Regenerate the app's typed API client from the workspace schema, without building or syncing`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`}],examples:[`twenty app generate-client --remote dev`,`twenty app generate-client --path ./apps/billing --json`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-app-generate-client-command-BV5PTy_i.cjs"))).runAppGenerateClientCommand},p={path:[`app`,`logs`],description:`Watch new logic-function logs from this app`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--name <name>`,description:`Filter all functions with this exact name within the app`},{flags:`--universal-identifier <id>`,description:`Filter one function by universal identifier`}],examples:[`twenty app logs --remote dev`,`twenty app logs --name add-numbers --remote dev`,`twenty app logs --format ndjson`],outputModes:[`human`,`ndjson`],writes:!1,needsProject:!0,needsTarget:!0,requiredPermissions:[`WORKFLOWS`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-logs-command-COAdNMuL.cjs"))).runAppLogsCommand},m={path:[`app`,`apply`],description:`Build the app, preview the changes, then upload and sync it to the workspace`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--prune`,description:`Delete remote entities missing from the app source (the default, except for the workspace custom application)`},{flags:`--no-prune`,description:`Keep remote entities missing from the app source`},{flags:`--no-delete`,description:`Deprecated alias of --no-prune`,hidden:!0},{flags:`--create`,description:`Register the app and install it in the workspace if it has no registration yet`},{flags:`--yes`,description:`Apply object and field deletions without asking; does not change which entities are deleted`}],examples:[`twenty app apply --remote dev`,`twenty app apply --create --json`,`twenty app apply --no-prune`,`twenty app apply --prune`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!0,requiredPermissions:[`APPLICATIONS`,`UPLOAD_FILE`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-apply-command-BFIPn04H.cjs"))).runAppApplyCommand},h={path:[`app`,`build`],description:`Build the app with the CLI and report the artifacts`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`}],examples:[`twenty app build`,`twenty app build --path ./apps/billing --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!0,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-app-build-command-BL5z2pAy.cjs"))).runAppBuildCommand},g={path:[`app`,`init`],description:`Create an app from the template bundled with this CLI, without installing anything`,arguments:[{name:`name`,description:`Package name of the app, for example my-app`,required:!0}],options:[{flags:`--path <directory>`,description:`Directory to create (default: ./<name>)`},{flags:`--display-name <name>`,description:`Name shown in Twenty (default: derived from the package name)`},{flags:`--description <text>`,description:`Description shown in Twenty`}],examples:[`twenty app init my-app`,`twenty app init billing --path ./apps/billing --display-name Billing --json`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-app-init-command-S9bUinGS.cjs"))).runAppInitCommand},_={path:[`app`,`pull`],description:`Pull an app, or create a local project for the workspace custom app`,options:[{flags:`--path <directory>`,description:`App directory, or a new or empty directory for the workspace custom app`},{flags:`--yes`,description:`Create a missing project and install its dependencies without prompting`},{flags:`--verbose`,description:`List coverage details`}],examples:[`twenty app pull --remote dev`,`twenty app pull --path ./apps/billing`,`twenty app pull --path ./workspace-app --yes --json`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!0,requiredPermissions:[`APPLICATIONS`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-pull-command-BESAEuyX.cjs"))).runAppPullCommand},v={path:[`app`,`plan`],description:`Build the app and preview metadata changes without applying them`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--prune`,description:`Delete remote entities missing from the app source (the default, except for the workspace custom application)`},{flags:`--no-prune`,description:`Keep remote entities missing from the app source`},{flags:`--no-delete`,description:`Deprecated alias of --no-prune`,hidden:!0}],examples:[`twenty app plan --remote dev`,`twenty app plan --path ./apps/billing --no-prune --json`,`twenty app plan --prune`],outputModes:[`human`,`json`],writes:!1,needsProject:!0,needsTarget:!0,requiredPermissions:[`APPLICATIONS`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-plan-command-DaSA-Hil.cjs"))).runAppPlanCommand},y={path:[`app`,`translations`,`extract`],description:`Extract app strings and update translation catalogs`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--locale <locale>`,description:`Create a target locale catalog if missing, for example fr-FR`}],examples:[`twenty app translations extract`,`twenty app translations extract --locale fr-FR`,`twenty app translations extract --path ./apps/billing --json`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-app-translations-extract-command-DHIEEFXs.cjs"))).runAppTranslationsExtractCommand},b={path:[`app`,`typecheck`],description:`Typecheck the app with its project TypeScript, without building`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`}],examples:[`twenty app typecheck`,`twenty app typecheck --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!0,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-app-typecheck-command-CIFFgU2u.cjs"))).runAppTypecheckCommand},x={path:[`app`,`uninstall`],description:`Uninstall the app from the workspace, deleting its objects, fields and their data`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--universal-identifier <id>`,description:`Uninstall the app with this universal identifier, works without a local project`},{flags:`--yes`,description:`Uninstall without asking`}],examples:[`twenty app uninstall --remote dev`,`twenty app uninstall --yes --json`,`twenty app uninstall --universal-identifier <id> --yes`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!0,requiredPermissions:[`APPLICATIONS`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-uninstall-command-Dhfci1zL.cjs"))).runAppUninstallCommand},S={path:[`auth`,`login`],description:`Sign in with your browser or an API key, and save the remote`,options:[{flags:`--with-token`,description:`Read an API key from standard input`},{flags:`--url <url>`,description:`Twenty server URL, for example https://acme.twenty.com`},{flags:`--name <name>`,description:`Name of the remote to save (defaults to "default")`},{flags:`--use`,description:`Make this remote the default`},{flags:`--replace`,description:`Point an existing remote at a different URL`},{flags:`--proxy-header <header...>`,description:`Header for an authenticating proxy in front of the server, as "Name: value". Repeatable; saved on the remote`},{flags:`--proxy-header-command <command>`,description:`Shell command that prints proxy headers as "Name: value" lines, run when a request needs them; saved on the remote`}],examples:[`twenty auth login --url https://acme.twenty.com`,`twenty auth login --url https://acme.twenty.com --name prod --use`,`printf '%s' "$TWENTY_API_KEY" | twenty auth login --with-token --url https://acme.twenty.com --name prod --use`,`twenty auth login --with-token --remote prod < api-key.txt`,`twenty auth login --url https://twenty.example.com --proxy-header-command 'echo "cf-access-token: $(cloudflared access token -app=https://twenty.example.com)"'`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-auth-login-command-sYroS-oN.cjs"))).runAuthLoginCommand},C={path:[`auth`,`logout`],description:`Forget the credentials of a saved remote, keeping the remote`,examples:[`twenty auth logout --remote staging`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-auth-logout-command-hvi_HvpQ.cjs"))).runAuthLogoutCommand},w={path:[`auth`,`status`],description:`Show which workspace commands use and check its credentials`,outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-auth-status-command-DTOLTpcS.cjs"))).runAuthStatusCommand},T={path:[`auth`,`token`],description:`Print the credential commands send, for scripts`,examples:[`curl -H "Authorization: Bearer $(twenty auth token)" https://acme.twenty.com/rest/companies`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-auth-token-command-D4geJ-rx.cjs"))).runAuthTokenCommand},E={path:[`api`,`graphql`],description:`Send a GraphQL query or mutation`,options:[{flags:`--query <query>`,description:`GraphQL document: inline, @file.graphql, or - for standard input`,required:!0},{flags:`--variables <json>`,description:`Variables as a JSON object: inline, @file.json, or - for standard input`},{flags:`--metadata`,description:`Send to the metadata API instead of the core API`}],examples:[`twenty api graphql --query '{ companies(first: 2) { edges { node { name } } } }'`,`twenty api graphql --metadata --query '{ currentWorkspace { displayName } }'`,`twenty api graphql --query @create-company.graphql --variables @variables.json`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-api-graphql-command-ELrIPdM5.cjs"))).runApiGraphqlCommand},D={path:[`api`,`rest`],description:`Send a request to the REST API`,arguments:[{name:`path`,description:`Path under the API URL, for example /rest/companies`,required:!0}],options:[{flags:`-X, --method <method>`,description:`HTTP method, defaults to GET; required with --body`,choices:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`]},{flags:`--body <json>`,description:`Request body: JSON, @file.json, or - for standard input`}],examples:[`twenty api rest '/rest/companies?limit=5'`,`twenty api rest /rest/companies --method POST --body '{"name":"Linear"}'`,`twenty api rest /rest/companies/<id> --method PATCH --body @changes.json`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-api-rest-command-COVnszcN.cjs"))).runApiRestCommand},O={WORKSPACE:`Workspace:`,APP:`App development:`,TOOLS:`Tools:`},k={path:[`commands`],description:`List the available commands`,helpGroup:O.TOOLS,outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-commands-command-Df3vekbG.cjs"))).runCommandsCommand},A={path:[`data`,`get`],description:`Inspect a record by id`,arguments:[{name:`object`,description:`Exact singular or plural API name`,required:!0},{name:`id`,description:`Record id`,required:!0}],examples:[`twenty data get companies <id>`,`twenty data get people <id> --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-data-get-command-AoCO8VBs.cjs"))).runDataGetCommand},j={path:[`data`,`list`],description:`List records with REST filters and pagination`,arguments:[{name:`object`,description:`Exact singular or plural API name`,required:!0}],options:[{flags:`--filter <expression>`,description:`REST filter expression, passed through unchanged`},{flags:`--order-by <expression>`,description:`REST order_by expression, passed through unchanged`},{flags:`--fields <names>`,description:`Comma-separated human table columns; JSON and NDJSON retain full records`},{flags:`--limit <count>`,description:`Records per page, 1–200 (default: 50)`},{flags:`--cursor <cursor>`,description:`Start after this opaque REST cursor`},{flags:`--all`,description:`Read every remaining page, bounded unless --format ndjson is used`}],examples:[`twenty data list companies --limit 20`,`twenty data list companies --filter 'employees[gte]:5000' --order-by 'employees[DescNullsLast]'`,`twenty data list people --all --format ndjson`],outputModes:[`human`,`json`,`ndjson`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-data-list-command-CMi1OeBV.cjs"))).runDataListCommand},M={path:[`doctor`],description:`Diagnose CLI, app SDK and workspace connection problems`,helpGroup:O.TOOLS,options:[{flags:`--path <directory>`,description:`App directory to inspect`},{flags:`--offline`,description:`Skip network checks`}],examples:[`twenty doctor`,`twenty doctor --remote staging --path ./my-app --json`,`twenty doctor --offline`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-doctor-command-VaRt9-ya.cjs"))).runDoctorCommand},N={path:[`metadata`,`object`,`describe`],description:`Describe an object`,arguments:[{name:`object`,description:`Exact singular or plural API name`,required:!0}],examples:[`twenty metadata object describe companies`,`twenty metadata object describe person --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-metadata-object-describe-command-CjC9TIBb.cjs"))).runMetadataObjectDescribeCommand},P={path:[`metadata`,`field`,`list`],description:`List fields and who owns each one`,arguments:[{name:`object`,description:`Exact singular or plural API name`,required:!0}],options:[{flags:`--all`,description:`Include system fields`}],examples:[`twenty metadata field list companies`,`twenty metadata field list companies --all --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-metadata-field-list-command-CVlFGJBc.cjs"))).runMetadataFieldListCommand},F={path:[`metadata`,`field`,`describe`],description:`Describe a field, its constraints, options and relations`,arguments:[{name:`object`,description:`Exact singular or plural object API name`,required:!0},{name:`field`,description:`Exact field API name, including system fields`,required:!0}],examples:[`twenty metadata field describe companies tier`,`twenty metadata field describe people company --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-metadata-field-describe-command-vgmY2Cjn.cjs"))).runMetadataFieldDescribeCommand},I={path:[`metadata`,`object`,`list`],description:`List objects and who owns each one`,options:[{flags:`--all`,description:`Include system objects`}],examples:[`twenty metadata object list`,`twenty metadata object list --all --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-metadata-object-list-command-BkffcdhV.cjs"))).runMetadataObjectListCommand},L={path:[`open`],description:`Open the workspace in your browser`,helpGroup:O.WORKSPACE,arguments:[{name:`page`,description:`Page to open, for example settings/applications`,required:!1}],options:[{flags:`--url-only`,description:`Print the address instead of opening a browser`}],examples:[`twenty open`,`twenty open settings/applications`,`twenty open --remote staging --url-only --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-open-command-DFlEdJCd.cjs"))).runOpenCommand},R={path:[`remote`,`list`],description:`List saved remotes`,outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-remote-list-command-C2tZHRAT.cjs"))).runRemoteListCommand},z={path:[`remote`,`remove`],description:`Remove a saved remote and its credentials`,arguments:[{name:`name`,description:`Saved remote`,required:!0}],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-remote-remove-command-DgSQvjeN.cjs"))).runRemoteRemoveCommand},B={path:[`remote`,`rename`],description:`Rename a saved remote`,arguments:[{name:`current`,description:`Current name`,required:!0},{name:`new`,description:`New name`,required:!0}],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-remote-rename-command--37-GTRY.cjs"))).runRemoteRenameCommand},V={path:[`remote`,`use`],description:`Make a saved remote the default`,arguments:[{name:`name`,description:`Saved remote`,required:!0}],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-remote-use-command-B6obKSPB.cjs"))).runRemoteUseCommand},H={path:[`version`],description:`Print version information`,helpGroup:O.TOOLS,outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-version-command-CCBLrCKu.cjs"))).runVersionCommand},U=[t,n,r,i,a,o,u,m,l,d,p,h,f,g,v,_,c,y,b,s,x,S,C,w,T,R,V,B,z,E,D,k,j,e,A,M,I,N,P,F,L,H],W=e=>e.path.join(` `),G={JSON:`--json`,FORMAT:`--format <format>`,REMOTE:`-r, --remote <name>`,NO_INPUT:`--no-input`,HELP:`-h, --help`,VERSION:`-v, --version`};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return G}});
1
+ var e={path:[`data`,`export`],description:`Export records to a CSV file with server-side permissions`,arguments:[{name:`object`,description:`Exact singular or plural API name`,required:!0}],options:[{flags:`--output <file>`,description:`Destination CSV file (required)`},{flags:`--fields <names>`,description:`Comma-separated field API names, in CSV order (default: active non-system fields)`},{flags:`--filter <expression>`,description:`REST filter expression, as in data list`},{flags:`--order-by <expression>`,description:`REST order_by expression, as in data list`},{flags:`--force`,description:`Replace an existing output file after a successful download`}],examples:[`twenty data export companies --output companies.csv`,`twenty data export companies --fields name,domainName,employees --filter 'employees[gte]:5000' --output large-companies.csv`,`twenty data export people --output people.csv --format ndjson`],outputModes:[`human`,`json`,`ndjson`],writes:!0,needsProject:!1,needsTarget:!0,requiredPermissions:[`EXPORT_CSV`],load:async()=>(await Promise.resolve().then(()=>require("./run-data-export-command-Uona_veE.cjs"))).runDataExportCommand},t={path:[`local`,`start`],description:`Start the local Twenty development environment`,options:[{flags:`-p, --port <port>`,description:`HTTP port for a new instance (default: 2020, or 2021 with --test)`},{flags:`--test`,description:`Use the separate local test instance`}],arguments:[{name:`version`,description:`Twenty version or image tag (new instances: engines.twenty, then latest)`,required:!1}],examples:[`twenty local start`,`twenty local start 2.53.1 --test`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-local-start-command-B8N5Jgjd.cjs"))).runLocalStartCommand},n={path:[`local`,`stop`],description:`Stop the local environment, preserving its data`,options:[{flags:`--test`,description:`Use the separate local test instance`}],examples:[`twenty local stop`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-local-stop-command-D66F73fW.cjs"))).runLocalStopCommand},r={path:[`local`,`status`],description:`Show local environment status, URL and image`,options:[{flags:`--test`,description:`Use the separate local test instance`}],examples:[`twenty local status --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-local-status-command-BYxy0R9I.cjs"))).runLocalStatusCommand},i={path:[`local`,`logs`],description:`Stream local environment logs`,options:[{flags:`-n, --lines <lines>`,description:`Number of recent log lines (default: 50, maximum: 10000)`},{flags:`--no-follow`,description:`Print recent logs and exit`},{flags:`--test`,description:`Use the separate local test instance`}],examples:[`twenty local logs`,`twenty local logs --test --no-follow`],outputModes:[`human`,`ndjson`],writes:!1,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-local-logs-command-COsSRk3f.cjs"))).runLocalLogsCommand},a={path:[`local`,`reset`],description:`Delete the local environment and all its data`,options:[{flags:`--yes`,description:`Delete the local environment and its data without asking`},{flags:`--test`,description:`Use the separate local test instance`}],examples:[`twenty local reset`,`twenty local reset --test --yes`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-local-reset-command-m0x-EiA6.cjs"))).runLocalResetCommand},o={path:[`local`,`upgrade`],description:`Upgrade the local environment, preserving its data volumes`,options:[{flags:`--test`,description:`Use the separate local test instance`}],arguments:[{name:`version`,description:`Twenty version or image tag (default: engines.twenty, then latest)`,required:!1}],examples:[`twenty local upgrade`,`twenty local upgrade 2.53.1 --test`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-local-upgrade-command-6P71bQw6.cjs"))).runLocalUpgradeCommand},s={path:[`app`,`install`],description:`Install a registered app package in the target workspace`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--universal-identifier <id>`,description:`Registered app universal identifier, works without a local project`}],examples:[`twenty app install --remote dev`,`twenty app install --path ./apps/billing --json`,`twenty app install --universal-identifier <id> --remote staging --json`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!0,requiredPermissions:[`APPLICATIONS`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-install-command-D6Iog7YY.cjs"))).runAppInstallCommand},c={path:[`app`,`publish`],description:`Build and publish the app to npm or a private Twenty registry`,options:[{flags:`--private`,description:`Publish to a Twenty server registry using --remote or the active target`},{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--tag <tag>`,description:`npm dist-tag, for example beta or next`}],examples:[`twenty app publish`,`twenty app publish --private --remote dev`,`twenty app publish --path ./apps/billing --tag beta --json`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-app-publish-command-TTp1zvc2.cjs"))).runAppPublishCommand},l={path:[`app`,`dev`],description:`Watch app source, build complete snapshots and sync changes to the workspace`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--prune`,description:`Delete remote entities missing from the app source (the default, except for the workspace custom application)`},{flags:`--no-prune`,description:`Keep remote entities missing from the app source`},{flags:`--no-delete`,description:`Deprecated alias of --no-prune`,hidden:!0},{flags:`--create`,description:`Allow registering and installing an app with no registration`},{flags:`--yes`,description:`Allow object and field deletions without asking`},{flags:`--verbose`,description:`Show watched and excluded external paths when scope changes`}],examples:[`twenty app dev --remote dev`,`twenty app dev --create --no-prune`,`twenty app dev --format ndjson --no-prune`,`twenty app dev --verbose`],outputModes:[`human`,`ndjson`],writes:!0,needsProject:!0,needsTarget:!0,requiredPermissions:[`APPLICATIONS`,`UPLOAD_FILE`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-dev-command-Boqdovo0.cjs"))).runAppDevCommand},u={path:[`app`,`add`],description:`Add an object, field, logic function, front component or validation rule to an app`,arguments:[{name:`entity`,description:`object, field, logic-function, front-component or validation-rule (prompted when omitted)`,required:!1}],options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--name <name>`,description:`Definition name; also determines the generated filename`},{flags:`--create-view`,description:`Create a table view for the new object`},{flags:`--create-navigation-menu-item`,description:`Create a navigation menu item for the new object`},{flags:`--create-page-layout`,description:`Create a record page layout and its fields view for the new object`},{flags:`--name-plural <name>`,description:`Plural API name (object)`},{flags:`--label <label>`,description:`Display label (object or field; default: derived from name)`},{flags:`--label-plural <label>`,description:`Plural display label (object; default: derived from plural name)`},{flags:`--type <type>`,description:`Field type, for example TEXT, NUMBER or RELATION (default: TEXT)`},{flags:`--object <uuid>`,description:`Parent object universal identifier (field or validation rule)`},{flags:`--description <text>`,description:`Field description`},{flags:`--target-object <uuid>`,description:`Target object universal identifier (relation field)`},{flags:`--target-field <uuid>`,description:`Target field universal identifier (relation field)`},{flags:`--relation-type <type>`,description:`ONE_TO_MANY or MANY_TO_ONE (relation field; default: ONE_TO_MANY)`},{flags:`--on-delete <action>`,description:`CASCADE, RESTRICT, SET_NULL, NO_ACTION or None (relation field; default: CASCADE)`}],examples:[`twenty app add`,`twenty app add object --name invoice --name-plural invoices --no-input`,`twenty app add object --name invoice --name-plural invoices --create-view --create-navigation-menu-item --create-page-layout --no-input`,`twenty app add field --name amount --type NUMBER --object <object-universal-identifier> --json`,`twenty app add logic-function --name send-invoice --no-input`,`twenty app add front-component --name invoice-panel --no-input`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-app-add-command-D9UvSCRi.cjs"))).runAppAddCommand},d={path:[`app`,`exec`],description:`Execute a deployed app logic function as the signed-in user`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--name <name>`,description:`Exact deployed function name`},{flags:`--universal-identifier <id>`,description:`Function universal identifier`},{flags:`--post-install`,description:`Execute the post-install hook without installing the app`},{flags:`--pre-install`,description:`Execute the pre-install hook without installing the app`},{flags:`--uninstall-hook`,description:`Execute the uninstall hook without uninstalling the app`},{flags:`--payload <json>`,description:`JSON object, @file or - for stdin (default: {})`}],examples:[`twenty app exec --name add-numbers --remote dev`,`twenty app exec --name add-numbers --payload @payload.json --json`,`twenty app exec --post-install --payload '{}'`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!0,requiredPermissions:[`APPLICATIONS`,`WORKFLOWS`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-exec-command-AejFDwrF.cjs"))).runAppExecCommand},f={path:[`app`,`generate-client`],description:`Regenerate the app's typed API client from the workspace schema, without building or syncing`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`}],examples:[`twenty app generate-client --remote dev`,`twenty app generate-client --path ./apps/billing --json`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-app-generate-client-command-HQnRfPSd.cjs"))).runAppGenerateClientCommand},p={path:[`app`,`logs`],description:`Watch new logic-function logs from this app`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--name <name>`,description:`Filter all functions with this exact name within the app`},{flags:`--universal-identifier <id>`,description:`Filter one function by universal identifier`}],examples:[`twenty app logs --remote dev`,`twenty app logs --name add-numbers --remote dev`,`twenty app logs --format ndjson`],outputModes:[`human`,`ndjson`],writes:!1,needsProject:!0,needsTarget:!0,requiredPermissions:[`WORKFLOWS`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-logs-command-COAdNMuL.cjs"))).runAppLogsCommand},m={path:[`app`,`apply`],description:`Build the app, preview the changes, then upload and sync it to the workspace`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--prune`,description:`Delete remote entities missing from the app source (the default, except for the workspace custom application)`},{flags:`--no-prune`,description:`Keep remote entities missing from the app source`},{flags:`--no-delete`,description:`Deprecated alias of --no-prune`,hidden:!0},{flags:`--create`,description:`Register the app and install it in the workspace if it has no registration yet`},{flags:`--yes`,description:`Apply object and field deletions without asking; does not change which entities are deleted`}],examples:[`twenty app apply --remote dev`,`twenty app apply --create --json`,`twenty app apply --no-prune`,`twenty app apply --prune`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!0,requiredPermissions:[`APPLICATIONS`,`UPLOAD_FILE`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-apply-command-BEF7BFvH.cjs"))).runAppApplyCommand},h={path:[`app`,`build`],description:`Build the app with the CLI and report the artifacts`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`}],examples:[`twenty app build`,`twenty app build --path ./apps/billing --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!0,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-app-build-command-O25lkSwj.cjs"))).runAppBuildCommand},g={path:[`app`,`init`],description:`Create an app from the template bundled with this CLI, without installing anything`,arguments:[{name:`name`,description:`Package name of the app, for example my-app`,required:!0}],options:[{flags:`--path <directory>`,description:`Directory to create (default: ./<name>)`},{flags:`--display-name <name>`,description:`Name shown in Twenty (default: derived from the package name)`},{flags:`--description <text>`,description:`Description shown in Twenty`}],examples:[`twenty app init my-app`,`twenty app init billing --path ./apps/billing --display-name Billing --json`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-app-init-command-BiWlxuhq.cjs"))).runAppInitCommand},_={path:[`app`,`pull`],description:`Pull an app, or create a local project for the workspace custom app`,options:[{flags:`--path <directory>`,description:`App directory, or a new or empty directory for the workspace custom app`},{flags:`--yes`,description:`Create a missing project and install its dependencies without prompting`},{flags:`--verbose`,description:`List coverage details`}],examples:[`twenty app pull --remote dev`,`twenty app pull --path ./apps/billing`,`twenty app pull --path ./workspace-app --yes --json`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!0,requiredPermissions:[`APPLICATIONS`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-pull-command-CB5ulUDP.cjs"))).runAppPullCommand},v={path:[`app`,`plan`],description:`Build the app and preview metadata changes without applying them`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--prune`,description:`Delete remote entities missing from the app source (the default, except for the workspace custom application)`},{flags:`--no-prune`,description:`Keep remote entities missing from the app source`},{flags:`--no-delete`,description:`Deprecated alias of --no-prune`,hidden:!0}],examples:[`twenty app plan --remote dev`,`twenty app plan --path ./apps/billing --no-prune --json`,`twenty app plan --prune`],outputModes:[`human`,`json`],writes:!1,needsProject:!0,needsTarget:!0,requiredPermissions:[`APPLICATIONS`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-plan-command-C9teUXwT.cjs"))).runAppPlanCommand},y={path:[`app`,`translations`,`extract`],description:`Extract app strings and update translation catalogs`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--locale <locale>`,description:`Create a target locale catalog if missing, for example fr-FR`}],examples:[`twenty app translations extract`,`twenty app translations extract --locale fr-FR`,`twenty app translations extract --path ./apps/billing --json`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-app-translations-extract-command-DHIEEFXs.cjs"))).runAppTranslationsExtractCommand},b={path:[`app`,`typecheck`],description:`Typecheck the app with its project TypeScript, without building`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`}],examples:[`twenty app typecheck`,`twenty app typecheck --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!0,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-app-typecheck-command-CwNuLuVW.cjs"))).runAppTypecheckCommand},x={path:[`app`,`uninstall`],description:`Uninstall the app from the workspace, deleting its objects, fields and their data`,options:[{flags:`--path <directory>`,description:`App directory (default: the app containing the current folder)`},{flags:`--universal-identifier <id>`,description:`Uninstall the app with this universal identifier, works without a local project`},{flags:`--yes`,description:`Uninstall without asking`}],examples:[`twenty app uninstall --remote dev`,`twenty app uninstall --yes --json`,`twenty app uninstall --universal-identifier <id> --yes`],outputModes:[`human`,`json`],writes:!0,needsProject:!0,needsTarget:!0,requiredPermissions:[`APPLICATIONS`],load:async()=>(await Promise.resolve().then(()=>require("./run-app-uninstall-command-BTxmy7EA.cjs"))).runAppUninstallCommand},S={path:[`auth`,`login`],description:`Sign in with your browser or an API key, and save the remote`,options:[{flags:`--with-token`,description:`Read an API key from standard input`},{flags:`--url <url>`,description:`Twenty server URL, for example https://acme.twenty.com`},{flags:`--name <name>`,description:`Name of the remote to save (defaults to "default")`},{flags:`--use`,description:`Make this remote the default`},{flags:`--replace`,description:`Point an existing remote at a different URL`},{flags:`--proxy-header <header...>`,description:`Header for an authenticating proxy in front of the server, as "Name: value". Repeatable; saved on the remote`},{flags:`--proxy-header-command <command>`,description:`Shell command that prints proxy headers as "Name: value" lines, run when a request needs them; saved on the remote`}],examples:[`twenty auth login --url https://acme.twenty.com`,`twenty auth login --url https://acme.twenty.com --name prod --use`,`printf '%s' "$TWENTY_API_KEY" | twenty auth login --with-token --url https://acme.twenty.com --name prod --use`,`twenty auth login --with-token --remote prod < api-key.txt`,`twenty auth login --url https://twenty.example.com --proxy-header-command 'echo "cf-access-token: $(cloudflared access token -app=https://twenty.example.com)"'`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-auth-login-command-GTYHkqks.cjs"))).runAuthLoginCommand},C={path:[`auth`,`logout`],description:`Forget the credentials of a saved remote, keeping the remote`,examples:[`twenty auth logout --remote staging`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-auth-logout-command-hvi_HvpQ.cjs"))).runAuthLogoutCommand},w={path:[`auth`,`status`],description:`Show which workspace commands use and check its credentials`,outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-auth-status-command-D-RJkyHP.cjs"))).runAuthStatusCommand},T={path:[`auth`,`token`],description:`Print the credential commands send, for scripts`,examples:[`curl -H "Authorization: Bearer $(twenty auth token)" https://acme.twenty.com/rest/companies`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-auth-token-command-D4geJ-rx.cjs"))).runAuthTokenCommand},E={path:[`api`,`graphql`],description:`Send a GraphQL query or mutation`,options:[{flags:`--query <query>`,description:`GraphQL document: inline, @file.graphql, or - for standard input`,required:!0},{flags:`--variables <json>`,description:`Variables as a JSON object: inline, @file.json, or - for standard input`},{flags:`--metadata`,description:`Send to the metadata API instead of the core API`}],examples:[`twenty api graphql --query '{ companies(first: 2) { edges { node { name } } } }'`,`twenty api graphql --metadata --query '{ currentWorkspace { displayName } }'`,`twenty api graphql --query @create-company.graphql --variables @variables.json`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-api-graphql-command-ELrIPdM5.cjs"))).runApiGraphqlCommand},D={path:[`api`,`rest`],description:`Send a request to the REST API`,arguments:[{name:`path`,description:`Path under the API URL, for example /rest/companies`,required:!0}],options:[{flags:`-X, --method <method>`,description:`HTTP method, defaults to GET; required with --body`,choices:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`]},{flags:`--body <json>`,description:`Request body: JSON, @file.json, or - for standard input`}],examples:[`twenty api rest '/rest/companies?limit=5'`,`twenty api rest /rest/companies --method POST --body '{"name":"Linear"}'`,`twenty api rest /rest/companies/<id> --method PATCH --body @changes.json`],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-api-rest-command-COVnszcN.cjs"))).runApiRestCommand},O={WORKSPACE:`Workspace:`,APP:`App development:`,TOOLS:`Tools:`},k={path:[`commands`],description:`List the available commands`,helpGroup:O.TOOLS,outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-commands-command-Dc2s4CLF.cjs"))).runCommandsCommand},A={path:[`data`,`get`],description:`Inspect a record by id`,arguments:[{name:`object`,description:`Exact singular or plural API name`,required:!0},{name:`id`,description:`Record id`,required:!0}],examples:[`twenty data get companies <id>`,`twenty data get people <id> --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-data-get-command-CsSFwlvd.cjs"))).runDataGetCommand},j={path:[`data`,`list`],description:`List records with REST filters and pagination`,arguments:[{name:`object`,description:`Exact singular or plural API name`,required:!0}],options:[{flags:`--filter <expression>`,description:`REST filter expression, passed through unchanged`},{flags:`--order-by <expression>`,description:`REST order_by expression, passed through unchanged`},{flags:`--fields <names>`,description:`Comma-separated human table columns; JSON and NDJSON retain full records`},{flags:`--limit <count>`,description:`Records per page, 1–200 (default: 50)`},{flags:`--cursor <cursor>`,description:`Start after this opaque REST cursor`},{flags:`--all`,description:`Read every remaining page, bounded unless --format ndjson is used`}],examples:[`twenty data list companies --limit 20`,`twenty data list companies --filter 'employees[gte]:5000' --order-by 'employees[DescNullsLast]'`,`twenty data list people --all --format ndjson`],outputModes:[`human`,`json`,`ndjson`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-data-list-command-DsUi50ev.cjs"))).runDataListCommand},M={path:[`doctor`],description:`Diagnose CLI, app SDK and workspace connection problems`,helpGroup:O.TOOLS,options:[{flags:`--path <directory>`,description:`App directory to inspect`},{flags:`--offline`,description:`Skip network checks`}],examples:[`twenty doctor`,`twenty doctor --remote staging --path ./my-app --json`,`twenty doctor --offline`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-doctor-command-BWUIB09t.cjs"))).runDoctorCommand},N={path:[`metadata`,`object`,`describe`],description:`Describe an object`,arguments:[{name:`object`,description:`Exact singular or plural API name`,required:!0}],examples:[`twenty metadata object describe companies`,`twenty metadata object describe person --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-metadata-object-describe-command-WqdWjHKk.cjs"))).runMetadataObjectDescribeCommand},P={path:[`metadata`,`field`,`list`],description:`List fields and who owns each one`,arguments:[{name:`object`,description:`Exact singular or plural API name`,required:!0}],options:[{flags:`--all`,description:`Include system fields`}],examples:[`twenty metadata field list companies`,`twenty metadata field list companies --all --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-metadata-field-list-command-BVQqm-C4.cjs"))).runMetadataFieldListCommand},F={path:[`metadata`,`field`,`describe`],description:`Describe a field, its constraints, options and relations`,arguments:[{name:`object`,description:`Exact singular or plural object API name`,required:!0},{name:`field`,description:`Exact field API name, including system fields`,required:!0}],examples:[`twenty metadata field describe companies tier`,`twenty metadata field describe people company --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-metadata-field-describe-command-CO5xw_pA.cjs"))).runMetadataFieldDescribeCommand},I={path:[`metadata`,`object`,`list`],description:`List objects and who owns each one`,options:[{flags:`--all`,description:`Include system objects`}],examples:[`twenty metadata object list`,`twenty metadata object list --all --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-metadata-object-list-command-B9FNZf1p.cjs"))).runMetadataObjectListCommand},L={path:[`open`],description:`Open the workspace in your browser`,helpGroup:O.WORKSPACE,arguments:[{name:`page`,description:`Page to open, for example settings/applications`,required:!1}],options:[{flags:`--url-only`,description:`Print the address instead of opening a browser`}],examples:[`twenty open`,`twenty open settings/applications`,`twenty open --remote staging --url-only --json`],outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!0,load:async()=>(await Promise.resolve().then(()=>require("./run-open-command-CJdT-RJo.cjs"))).runOpenCommand},R={path:[`remote`,`list`],description:`List saved remotes`,outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-remote-list-command-C2tZHRAT.cjs"))).runRemoteListCommand},z={path:[`remote`,`remove`],description:`Remove a saved remote and its credentials`,arguments:[{name:`name`,description:`Saved remote`,required:!0}],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-remote-remove-command-DgSQvjeN.cjs"))).runRemoteRemoveCommand},B={path:[`remote`,`rename`],description:`Rename a saved remote`,arguments:[{name:`current`,description:`Current name`,required:!0},{name:`new`,description:`New name`,required:!0}],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-remote-rename-command--37-GTRY.cjs"))).runRemoteRenameCommand},V={path:[`remote`,`use`],description:`Make a saved remote the default`,arguments:[{name:`name`,description:`Saved remote`,required:!0}],outputModes:[`human`,`json`],writes:!0,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-remote-use-command-B6obKSPB.cjs"))).runRemoteUseCommand},H={path:[`version`],description:`Print version information`,helpGroup:O.TOOLS,outputModes:[`human`,`json`],writes:!1,needsProject:!1,needsTarget:!1,load:async()=>(await Promise.resolve().then(()=>require("./run-version-command-CVPmLMkq.cjs"))).runVersionCommand},U=[t,n,r,i,a,o,u,m,l,d,p,h,f,g,v,_,c,y,b,s,x,S,C,w,T,R,V,B,z,E,D,k,j,e,A,M,I,N,P,F,L,H],W=e=>e.path.join(` `),G={JSON:`--json`,FORMAT:`--format <format>`,REMOTE:`-r, --remote <name>`,NO_INPUT:`--no-input`,HELP:`-h, --help`,VERSION:`-v, --version`};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return G}});
@@ -1 +1 @@
1
- const e=require("./rolldown-runtime-mLOUI7ql.cjs"),t=require("./valid-BPaM0XRk.cjs"),n=require("./satisfies-Jm-ashRt.cjs"),r=require("./ltr-BS5BTFWS.cjs"),i=require("./isDefined-CJctgvfE.cjs"),a=require("./isNonEmptyArray-v52xg4Xj.cjs"),o=require("./has-error-code-DsJeqbZq.cjs"),s=require("./cli-error-CrUD8uMp.cjs"),c=require("./print-typescript-value-BjYn0ZFT.cjs"),l=require("./cli-version.constant-ol3Ctp_7.cjs"),u=require("./max-satisfying-BNYDQrne.cjs");let d=require("node:crypto"),f=require("node:fs/promises"),p=require("node:path"),m=require("node:fs");var h=`2.63.0`,g=[`twenty-client-sdk`,`twenty-sdk`,`twenty-ui`],_=e.t(((e,t)=>{var n=u.r();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),v=e.t(((e,n)=>{var r=t.f();n.exports=(e,t,n,i,a)=>{typeof n==`string`&&(a=i,i=n,n=void 0);try{return new r(e instanceof r?e.version:e,n).inc(t,i,a).version}catch{return null}}})),y=e.t(((e,t)=>{var n=u.r();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l)return!c.patch&&!c.minor?`major`:s.patch?`patch`:s.minor?`minor`:`major`;let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),b=e.t(((e,n)=>{var r=t.f();n.exports=(e,t)=>new r(e,t).major})),x=e.t(((e,n)=>{var r=t.f();n.exports=(e,t)=>new r(e,t).minor})),S=e.t(((e,n)=>{var r=t.f();n.exports=(e,t)=>new r(e,t).patch})),C=e.t(((e,t)=>{var n=u.r();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),w=e.t(((e,n)=>{var r=t.d();n.exports=(e,t,n)=>r(t,e,n)})),T=e.t(((e,n)=>{var r=t.d();n.exports=(e,t)=>r(e,t,!0)})),E=e.t(((e,n)=>{var r=t.f();n.exports=(e,t,n)=>{let i=new r(e,n),a=new r(t,n);return i.compare(a)||i.compareBuild(a)}})),D=e.t(((e,t)=>{var n=E();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),O=e.t(((e,t)=>{var n=E();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),k=e.t(((e,n)=>{var r=t.f(),i=u.r(),{safeRe:a,t:o}=t.m();n.exports=(e,t)=>{if(e instanceof r)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let n=null;if(!t.rtl)n=e.match(t.includePrerelease?a[o.COERCEFULL]:a[o.COERCE]);else{let r=t.includePrerelease?a[o.COERCERTLFULL]:a[o.COERCERTL],i;for(;(i=r.exec(e))&&(!n||n.index+n[0].length!==e.length);)(!n||i.index+i[0].length!==n.index+n[0].length)&&(n=i),r.lastIndex=i.index+i[1].length+i[2].length;r.lastIndex=-1}if(n===null)return null;let s=n[2];return i(`${s}.${n[3]||`0`}.${n[4]||`0`}${t.includePrerelease&&n[5]?`-${n[5]}`:``}${t.includePrerelease&&n[6]?`+${n[6]}`:``}`,t)}})),A=e.t(((e,n)=>{var r=t.n();n.exports=(e,t)=>new r(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),j=e.t(((e,n)=>{var r=t.f(),i=t.n();n.exports=(e,t,n)=>{let a=null,o=null,s=null;try{s=new i(t,n)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new r(a,n))}),a}})),M=e.t(((e,n)=>{var r=t.f(),i=t.n(),a=t.c();n.exports=(e,t)=>{e=new i(e,t);let n=new r(`0.0.0`);if(e.test(n)||(n=new r(`0.0.0-0`),e.test(n)))return n;n=null;for(let t=0;t<e.set.length;++t){let i=e.set[t],o=null;i.forEach(e=>{let t=new r(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||a(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!n||a(n,o))&&(n=o)}return n&&e.test(n)?n:null}})),N=e.t(((e,t)=>{var n=r.n();t.exports=(e,t,r)=>n(e,t,`>`,r)})),P=e.t(((e,n)=>{var r=t.n();n.exports=(e,t,n)=>(e=new r(e,n),t=new r(t,n),e.intersects(t,n))})),F=e.t(((e,r)=>{var i=n.t(),a=t.d();r.exports=(e,t,n)=>{let r=[],o=null,s=null,c=e.sort((e,t)=>a(e,t,n));for(let e of c)i(e,t,n)?(s=e,o||=e):(s&&r.push([o,s]),s=null,o=null);o&&r.push([o,null]);let l=[];for(let[e,t]of r)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),I=e.t(((e,r)=>{var i=t.n(),a=t.r(),{ANY:o}=a,s=n.t(),c=t.d(),l=(e,t,n={})=>{if(e===t)return!0;e=new i(e,n),t=new i(t,n);let r=!1;OUTER:for(let i of e.set){for(let e of t.set){let t=f(i,e,n);if(r||=t!==null,t)continue OUTER}if(r)return!1}return!0},u=[new a(`>=0.0.0-0`)],d=[new a(`>=0.0.0`)],f=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===o){if(t.length===1&&t[0].semver===o)return!0;e=n.includePrerelease?u:d}if(t.length===1&&t[0].semver===o){if(n.includePrerelease)return!0;t=d}let r=new Set,i,a;for(let t of e)t.operator===`>`||t.operator===`>=`?i=p(i,t,n):t.operator===`<`||t.operator===`<=`?a=m(a,t,n):r.add(t.semver);if(r.size>1)return null;let l;if(i&&a&&(l=c(i.semver,a.semver,n),l>0||l===0&&(i.operator!==`>=`||a.operator!==`<=`)))return null;for(let e of r){if(i&&!s(e,String(i),n)||a&&!s(e,String(a),n))return null;for(let r of t)if(!s(e,String(r),n))return!1;return!0}let f,h,g,_,v=a&&!n.includePrerelease&&a.semver.prerelease.length?a.semver:!1,y=i&&!n.includePrerelease&&i.semver.prerelease.length?i.semver:!1;v&&v.prerelease.length===1&&a.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,i){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(f=p(i,e,n),f===e&&f!==i)return!1}else if(i.operator===`>=`&&!s(i.semver,String(e),n))return!1}if(a){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=m(a,e,n),h===e&&h!==a)return!1}else if(a.operator===`<=`&&!s(a.semver,String(e),n))return!1}if(!e.operator&&(a||i)&&l!==0)return!1}return!(i&&g&&!a&&l!==0||a&&_&&!i&&l!==0||y||v)},p=(e,t,n)=>{if(!e)return t;let r=c(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},m=(e,t,n)=>{if(!e)return t;let r=c(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};r.exports=l})),L=e.t(((e,i)=>{var a=t.m(),o=t.h(),s=t.f(),c=t.p();i.exports={parse:u.r(),valid:u.n(),clean:_(),inc:v(),diff:y(),major:b(),minor:x(),patch:S(),prerelease:C(),compare:t.d(),rcompare:w(),compareLoose:T(),compareBuild:E(),sort:D(),rsort:O(),gt:t.c(),lt:t.o(),eq:t.u(),neq:t.l(),gte:t.s(),lte:t.a(),cmp:t.i(),coerce:k(),Comparator:t.r(),Range:t.n(),satisfies:n.t(),toComparators:A(),maxSatisfying:u.t(),minSatisfying:j(),minVersion:M(),validRange:t.t(),outside:r.n(),gtr:N(),ltr:r.t(),intersects:P(),simplifyRange:F(),subset:I(),SemVer:s,re:a.re,src:a.src,tokens:a.t,SEMVER_SPEC_VERSION:o.SEMVER_SPEC_VERSION,RELEASE_TYPES:o.RELEASE_TYPES,compareIdentifiers:c.compareIdentifiers,rcompareIdentifiers:c.rcompareIdentifiers}})),R=e.r(L()),z=()=>(0,p.join)((0,p.dirname)((0,m.realpathSync)(process.argv[1]??``)),`app-template`),B=async({appDirectory:e,appName:t,appDisplayName:n,appDescription:r,shouldIncludeExample:i=!0})=>{let a=z(),o=(0,p.join)(a,`example`);await(0,f.cp)(a,e,{recursive:!0,filter:e=>e!==o}),i&&await(0,f.cp)((0,p.join)(o,`files`),e,{recursive:!0}),await(0,f.writeFile)((0,p.join)(e,`yarn.lock`),``,{flag:`a`});for(let[t,n]of[[`gitignore`,`.gitignore`],[`yarnrc.yml`,`.yarnrc.yml`]])await(0,f.rename)((0,p.join)(e,t),(0,p.join)(e,n));if(i){await(0,f.rename)((0,p.join)(e,`github`),(0,p.join)(e,`.github`)),await(0,f.cp)((0,p.join)(e,`AGENTS.md`),(0,p.join)(e,`CLAUDE.md`));for(let t of[`ci.yml`,`cd.yml`,`publish.yml`]){let n=(0,p.join)(e,`.github`,`workflows`,t);await(0,f.writeFile)(n,(await(0,f.readFile)(n,`utf8`)).replaceAll(`CLI-VERSION-TO-BE-GENERATED`,l.t))}let t=(0,p.join)(e,`src/constants/universal-identifiers.ts`);await(0,f.writeFile)(t,(await(0,f.readFile)(t,`utf8`)).replace(/'DISPLAY-NAME-TO-BE-GENERATED'/g,()=>c.n({value:n})).replace(/'DESCRIPTION-TO-BE-GENERATED'/g,()=>c.n({value:r})).replace(/UUID-TO-BE-GENERATED/g,()=>(0,d.randomUUID)()))}let s=(0,p.join)(e,`package.json`),u=JSON.parse(await(0,f.readFile)(s,`utf8`));u.name=t,u.engines.twenty=`>=${R.default.major(h)}.${R.default.minor(h)}.0`;for(let e of g)u.devDependencies[e]=h;if(i){let e=JSON.parse(await(0,f.readFile)((0,p.join)(o,`scripts.json`),`utf8`));u.scripts={...u.scripts,...e}}await(0,f.writeFile)(s,JSON.stringify(u,null,2))},V=`TO-BE-GENERATED`,H=`yarn.lock`,U=({appDirectory:e,reason:t})=>new s.t({code:`APP_PATH_UNAVAILABLE`,exitCode:s.n.CONFLICT,message:`${e} already exists and ${t}.`,hint:`Choose another app name, or pass --path with a new or empty directory.`,details:{path:e}}),W=async e=>{let t=await(0,f.stat)(e).catch(e=>{if(!o.t(e,`ENOENT`))throw e});if(!i.t(t))return`missing`;if(!t.isDirectory())throw U({appDirectory:e,reason:`is not a directory`});if(a.t(await(0,f.readdir)(e)))throw U({appDirectory:e,reason:`is not empty`});return`empty`},G=async e=>{let t=await(0,f.readdir)(e,{recursive:!0,withFileTypes:!0}),n=[];for(let r of t){let t=(0,p.join)(r.parentPath,r.name),i=(0,p.relative)(e,t);r.isFile()&&i!==H&&(await(0,f.readFile)(t,`utf8`)).includes(V)&&n.push(i)}return n},K=async({stagingDirectory:e,appDirectory:t})=>{let n=[];try{for(let r of await(0,f.readdir)(e,{recursive:!0,withFileTypes:!0})){let i=(0,p.join)(r.parentPath,r.name),a=(0,p.join)(t,(0,p.relative)(e,i));r.isDirectory()?await(0,f.mkdir)(a):await(0,f.copyFile)(i,a,m.constants.COPYFILE_EXCL),n.push({createdPath:a,isDirectory:r.isDirectory()})}}catch(e){for(let{createdPath:e,isDirectory:t}of n.reverse())await(t?(0,f.rmdir)(e):(0,f.unlink)(e)).catch(()=>void 0);throw e}await(0,f.rm)(e,{recursive:!0,force:!0})},q=async({appDirectory:e,appName:t,appDisplayName:n,appDescription:r,shouldIncludeExample:i=!0,signal:o})=>{await W(e);let c=(0,p.dirname)(e);await(0,f.mkdir)(c,{recursive:!0});let l=await(0,f.mkdtemp)((0,p.join)(c,`.${(0,p.basename)(e)}-`));try{await B({appName:t,appDisplayName:n,appDescription:r,shouldIncludeExample:i,appDirectory:l}),o.throwIfAborted();let c=await G(l);if(a.t(c))throw new s.t({code:`APP_INIT_FAILED`,message:`The app template still has placeholders in ${c.join(`, `)}.`,hint:`This CLI ships an app template it cannot render. Upgrade the twenty CLI.`,details:{unrenderedFiles:c}});o.throwIfAborted(),await W(e)===`empty`?await K({stagingDirectory:l,appDirectory:e}):await(0,f.rename)(l,e)}catch(t){throw await(0,f.rm)(l,{recursive:!0,force:!0}),t instanceof s.t||o.aborted?t:new s.t({code:`APP_INIT_FAILED`,message:`Could not create ${e}: ${t instanceof Error?t.message:String(t)}`,hint:`Files this command had written there were removed. Fix the cause, then run the command again.`,details:{path:e}})}},J=/^(?:@[a-z0-9~-][a-z0-9._~-]*\/)?[a-z0-9~-][a-z0-9._~-]*$/,Y=214,X=e=>e.length<=Y&&![`node_modules`,`favicon.ico`].includes(e)&&J.test(e);Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return X}});
1
+ const e=require("./rolldown-runtime-mLOUI7ql.cjs"),t=require("./valid-BPaM0XRk.cjs"),n=require("./satisfies-Jm-ashRt.cjs"),r=require("./ltr-BS5BTFWS.cjs"),i=require("./isDefined-CJctgvfE.cjs"),a=require("./isNonEmptyArray-v52xg4Xj.cjs"),o=require("./has-error-code-DsJeqbZq.cjs"),s=require("./cli-error-CrUD8uMp.cjs"),c=require("./print-typescript-value-BjYn0ZFT.cjs"),l=require("./cli-version.constant-DHNpJ_rq.cjs"),u=require("./max-satisfying-BNYDQrne.cjs");let d=require("node:crypto"),f=require("node:fs/promises"),p=require("node:path"),m=require("node:fs");var h=`2.65.0`,g=[`twenty-client-sdk`,`twenty-sdk`,`twenty-ui`],_=e.t(((e,t)=>{var n=u.r();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),v=e.t(((e,n)=>{var r=t.f();n.exports=(e,t,n,i,a)=>{typeof n==`string`&&(a=i,i=n,n=void 0);try{return new r(e instanceof r?e.version:e,n).inc(t,i,a).version}catch{return null}}})),y=e.t(((e,t)=>{var n=u.r();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l)return!c.patch&&!c.minor?`major`:s.patch?`patch`:s.minor?`minor`:`major`;let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),b=e.t(((e,n)=>{var r=t.f();n.exports=(e,t)=>new r(e,t).major})),x=e.t(((e,n)=>{var r=t.f();n.exports=(e,t)=>new r(e,t).minor})),S=e.t(((e,n)=>{var r=t.f();n.exports=(e,t)=>new r(e,t).patch})),C=e.t(((e,t)=>{var n=u.r();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),w=e.t(((e,n)=>{var r=t.d();n.exports=(e,t,n)=>r(t,e,n)})),T=e.t(((e,n)=>{var r=t.d();n.exports=(e,t)=>r(e,t,!0)})),E=e.t(((e,n)=>{var r=t.f();n.exports=(e,t,n)=>{let i=new r(e,n),a=new r(t,n);return i.compare(a)||i.compareBuild(a)}})),D=e.t(((e,t)=>{var n=E();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),O=e.t(((e,t)=>{var n=E();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),k=e.t(((e,n)=>{var r=t.f(),i=u.r(),{safeRe:a,t:o}=t.m();n.exports=(e,t)=>{if(e instanceof r)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let n=null;if(!t.rtl)n=e.match(t.includePrerelease?a[o.COERCEFULL]:a[o.COERCE]);else{let r=t.includePrerelease?a[o.COERCERTLFULL]:a[o.COERCERTL],i;for(;(i=r.exec(e))&&(!n||n.index+n[0].length!==e.length);)(!n||i.index+i[0].length!==n.index+n[0].length)&&(n=i),r.lastIndex=i.index+i[1].length+i[2].length;r.lastIndex=-1}if(n===null)return null;let s=n[2];return i(`${s}.${n[3]||`0`}.${n[4]||`0`}${t.includePrerelease&&n[5]?`-${n[5]}`:``}${t.includePrerelease&&n[6]?`+${n[6]}`:``}`,t)}})),A=e.t(((e,n)=>{var r=t.n();n.exports=(e,t)=>new r(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),j=e.t(((e,n)=>{var r=t.f(),i=t.n();n.exports=(e,t,n)=>{let a=null,o=null,s=null;try{s=new i(t,n)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new r(a,n))}),a}})),M=e.t(((e,n)=>{var r=t.f(),i=t.n(),a=t.c();n.exports=(e,t)=>{e=new i(e,t);let n=new r(`0.0.0`);if(e.test(n)||(n=new r(`0.0.0-0`),e.test(n)))return n;n=null;for(let t=0;t<e.set.length;++t){let i=e.set[t],o=null;i.forEach(e=>{let t=new r(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||a(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!n||a(n,o))&&(n=o)}return n&&e.test(n)?n:null}})),N=e.t(((e,t)=>{var n=r.n();t.exports=(e,t,r)=>n(e,t,`>`,r)})),P=e.t(((e,n)=>{var r=t.n();n.exports=(e,t,n)=>(e=new r(e,n),t=new r(t,n),e.intersects(t,n))})),F=e.t(((e,r)=>{var i=n.t(),a=t.d();r.exports=(e,t,n)=>{let r=[],o=null,s=null,c=e.sort((e,t)=>a(e,t,n));for(let e of c)i(e,t,n)?(s=e,o||=e):(s&&r.push([o,s]),s=null,o=null);o&&r.push([o,null]);let l=[];for(let[e,t]of r)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),I=e.t(((e,r)=>{var i=t.n(),a=t.r(),{ANY:o}=a,s=n.t(),c=t.d(),l=(e,t,n={})=>{if(e===t)return!0;e=new i(e,n),t=new i(t,n);let r=!1;OUTER:for(let i of e.set){for(let e of t.set){let t=f(i,e,n);if(r||=t!==null,t)continue OUTER}if(r)return!1}return!0},u=[new a(`>=0.0.0-0`)],d=[new a(`>=0.0.0`)],f=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===o){if(t.length===1&&t[0].semver===o)return!0;e=n.includePrerelease?u:d}if(t.length===1&&t[0].semver===o){if(n.includePrerelease)return!0;t=d}let r=new Set,i,a;for(let t of e)t.operator===`>`||t.operator===`>=`?i=p(i,t,n):t.operator===`<`||t.operator===`<=`?a=m(a,t,n):r.add(t.semver);if(r.size>1)return null;let l;if(i&&a&&(l=c(i.semver,a.semver,n),l>0||l===0&&(i.operator!==`>=`||a.operator!==`<=`)))return null;for(let e of r){if(i&&!s(e,String(i),n)||a&&!s(e,String(a),n))return null;for(let r of t)if(!s(e,String(r),n))return!1;return!0}let f,h,g,_,v=a&&!n.includePrerelease&&a.semver.prerelease.length?a.semver:!1,y=i&&!n.includePrerelease&&i.semver.prerelease.length?i.semver:!1;v&&v.prerelease.length===1&&a.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,i){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(f=p(i,e,n),f===e&&f!==i)return!1}else if(i.operator===`>=`&&!s(i.semver,String(e),n))return!1}if(a){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=m(a,e,n),h===e&&h!==a)return!1}else if(a.operator===`<=`&&!s(a.semver,String(e),n))return!1}if(!e.operator&&(a||i)&&l!==0)return!1}return!(i&&g&&!a&&l!==0||a&&_&&!i&&l!==0||y||v)},p=(e,t,n)=>{if(!e)return t;let r=c(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},m=(e,t,n)=>{if(!e)return t;let r=c(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};r.exports=l})),L=e.t(((e,i)=>{var a=t.m(),o=t.h(),s=t.f(),c=t.p();i.exports={parse:u.r(),valid:u.n(),clean:_(),inc:v(),diff:y(),major:b(),minor:x(),patch:S(),prerelease:C(),compare:t.d(),rcompare:w(),compareLoose:T(),compareBuild:E(),sort:D(),rsort:O(),gt:t.c(),lt:t.o(),eq:t.u(),neq:t.l(),gte:t.s(),lte:t.a(),cmp:t.i(),coerce:k(),Comparator:t.r(),Range:t.n(),satisfies:n.t(),toComparators:A(),maxSatisfying:u.t(),minSatisfying:j(),minVersion:M(),validRange:t.t(),outside:r.n(),gtr:N(),ltr:r.t(),intersects:P(),simplifyRange:F(),subset:I(),SemVer:s,re:a.re,src:a.src,tokens:a.t,SEMVER_SPEC_VERSION:o.SEMVER_SPEC_VERSION,RELEASE_TYPES:o.RELEASE_TYPES,compareIdentifiers:c.compareIdentifiers,rcompareIdentifiers:c.rcompareIdentifiers}})),R=e.r(L()),z=()=>(0,p.join)((0,p.dirname)((0,m.realpathSync)(process.argv[1]??``)),`app-template`),B=async({appDirectory:e,appName:t,appDisplayName:n,appDescription:r,shouldIncludeExample:i=!0})=>{let a=z(),o=(0,p.join)(a,`example`);await(0,f.cp)(a,e,{recursive:!0,filter:e=>e!==o}),i&&await(0,f.cp)((0,p.join)(o,`files`),e,{recursive:!0}),await(0,f.writeFile)((0,p.join)(e,`yarn.lock`),``,{flag:`a`});for(let[t,n]of[[`gitignore`,`.gitignore`],[`yarnrc.yml`,`.yarnrc.yml`]])await(0,f.rename)((0,p.join)(e,t),(0,p.join)(e,n));if(i){await(0,f.rename)((0,p.join)(e,`github`),(0,p.join)(e,`.github`)),await(0,f.cp)((0,p.join)(e,`AGENTS.md`),(0,p.join)(e,`CLAUDE.md`));for(let t of[`ci.yml`,`cd.yml`,`publish.yml`]){let n=(0,p.join)(e,`.github`,`workflows`,t);await(0,f.writeFile)(n,(await(0,f.readFile)(n,`utf8`)).replaceAll(`CLI-VERSION-TO-BE-GENERATED`,l.t))}let t=(0,p.join)(e,`src/constants/universal-identifiers.ts`);await(0,f.writeFile)(t,(await(0,f.readFile)(t,`utf8`)).replace(/'DISPLAY-NAME-TO-BE-GENERATED'/g,()=>c.n({value:n})).replace(/'DESCRIPTION-TO-BE-GENERATED'/g,()=>c.n({value:r})).replace(/UUID-TO-BE-GENERATED/g,()=>(0,d.randomUUID)()))}let s=(0,p.join)(e,`package.json`),u=JSON.parse(await(0,f.readFile)(s,`utf8`));u.name=t,u.engines.twenty=`>=${R.default.major(h)}.${R.default.minor(h)}.0`;for(let e of g)u.devDependencies[e]=h;if(i){let e=JSON.parse(await(0,f.readFile)((0,p.join)(o,`scripts.json`),`utf8`));u.scripts={...u.scripts,...e}}await(0,f.writeFile)(s,JSON.stringify(u,null,2))},V=`TO-BE-GENERATED`,H=`yarn.lock`,U=({appDirectory:e,reason:t})=>new s.t({code:`APP_PATH_UNAVAILABLE`,exitCode:s.n.CONFLICT,message:`${e} already exists and ${t}.`,hint:`Choose another app name, or pass --path with a new or empty directory.`,details:{path:e}}),W=async e=>{let t=await(0,f.stat)(e).catch(e=>{if(!o.t(e,`ENOENT`))throw e});if(!i.t(t))return`missing`;if(!t.isDirectory())throw U({appDirectory:e,reason:`is not a directory`});if(a.t(await(0,f.readdir)(e)))throw U({appDirectory:e,reason:`is not empty`});return`empty`},G=async e=>{let t=await(0,f.readdir)(e,{recursive:!0,withFileTypes:!0}),n=[];for(let r of t){let t=(0,p.join)(r.parentPath,r.name),i=(0,p.relative)(e,t);r.isFile()&&i!==H&&(await(0,f.readFile)(t,`utf8`)).includes(V)&&n.push(i)}return n},K=async({stagingDirectory:e,appDirectory:t})=>{let n=[];try{for(let r of await(0,f.readdir)(e,{recursive:!0,withFileTypes:!0})){let i=(0,p.join)(r.parentPath,r.name),a=(0,p.join)(t,(0,p.relative)(e,i));r.isDirectory()?await(0,f.mkdir)(a):await(0,f.copyFile)(i,a,m.constants.COPYFILE_EXCL),n.push({createdPath:a,isDirectory:r.isDirectory()})}}catch(e){for(let{createdPath:e,isDirectory:t}of n.reverse())await(t?(0,f.rmdir)(e):(0,f.unlink)(e)).catch(()=>void 0);throw e}await(0,f.rm)(e,{recursive:!0,force:!0})},q=async({appDirectory:e,appName:t,appDisplayName:n,appDescription:r,shouldIncludeExample:i=!0,signal:o})=>{await W(e);let c=(0,p.dirname)(e);await(0,f.mkdir)(c,{recursive:!0});let l=await(0,f.mkdtemp)((0,p.join)(c,`.${(0,p.basename)(e)}-`));try{await B({appName:t,appDisplayName:n,appDescription:r,shouldIncludeExample:i,appDirectory:l}),o.throwIfAborted();let c=await G(l);if(a.t(c))throw new s.t({code:`APP_INIT_FAILED`,message:`The app template still has placeholders in ${c.join(`, `)}.`,hint:`This CLI ships an app template it cannot render. Upgrade the twenty CLI.`,details:{unrenderedFiles:c}});o.throwIfAborted(),await W(e)===`empty`?await K({stagingDirectory:l,appDirectory:e}):await(0,f.rename)(l,e)}catch(t){throw await(0,f.rm)(l,{recursive:!0,force:!0}),t instanceof s.t||o.aborted?t:new s.t({code:`APP_INIT_FAILED`,message:`Could not create ${e}: ${t instanceof Error?t.message:String(t)}`,hint:`Files this command had written there were removed. Fix the cause, then run the command again.`,details:{path:e}})}},J=/^(?:@[a-z0-9~-][a-z0-9._~-]*\/)?[a-z0-9~-][a-z0-9._~-]*$/,Y=214,X=e=>e.length<=Y&&![`node_modules`,`favicon.ico`].includes(e)&&J.test(e);Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return X}});
@@ -0,0 +1,6 @@
1
+ const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./get-field-universal-identifier.util-4kQ5e4Tv.cjs"),r=require("./standard-object-fields.constant-5mGzYzj4.cjs"),i=require("./compute-deterministic-uuid.util-BHojBHTU.cjs"),a=require("./kebab-case-tmo--p0I.cjs"),o=require("./TwentyStandardApplicationUniversalIdentifier-Cm4vo0D3.cjs"),s=require("./print-typescript-value-BjYn0ZFT.cjs");var c=function(e){return e.IS=`IS`,e.IS_NOT_NULL=`IS_NOT_NULL`,e.IS_NOT=`IS_NOT`,e.LESS_THAN_OR_EQUAL=`LESS_THAN_OR_EQUAL`,e.GREATER_THAN_OR_EQUAL=`GREATER_THAN_OR_EQUAL`,e.IS_BEFORE=`IS_BEFORE`,e.IS_AFTER=`IS_AFTER`,e.CONTAINS=`CONTAINS`,e.DOES_NOT_CONTAIN=`DOES_NOT_CONTAIN`,e.IS_EMPTY=`IS_EMPTY`,e.IS_NOT_EMPTY=`IS_NOT_EMPTY`,e.IS_RELATIVE=`IS_RELATIVE`,e.IS_IN_PAST=`IS_IN_PAST`,e.IS_IN_FUTURE=`IS_IN_FUTURE`,e.IS_TODAY=`IS_TODAY`,e.VECTOR_SEARCH=`VECTOR_SEARCH`,e}({}),l=function(e){return e.MIN=`MIN`,e.MAX=`MAX`,e.AVG=`AVG`,e.SUM=`SUM`,e.COUNT=`COUNT`,e.COUNT_UNIQUE_VALUES=`COUNT_UNIQUE_VALUES`,e.COUNT_EMPTY=`COUNT_EMPTY`,e.COUNT_NOT_EMPTY=`COUNT_NOT_EMPTY`,e.COUNT_TRUE=`COUNT_TRUE`,e.COUNT_FALSE=`COUNT_FALSE`,e.PERCENTAGE_EMPTY=`PERCENTAGE_EMPTY`,e.PERCENTAGE_NOT_EMPTY=`PERCENTAGE_NOT_EMPTY`,e}({}),u=function(e){return e.FLOAT=`float`,e.INT=`int`,e.BIGINT=`bigint`,e}({}),d=function(e){return e.RELATIVE=`RELATIVE`,e.USER_SETTINGS=`USER_SETTINGS`,e.CUSTOM=`CUSTOM`,e}({}),ee=function(e){return e.BTREE=`BTREE`,e.GIN=`GIN`,e}({}),f=function(e){return e.VIEW=`VIEW`,e.FOLDER=`FOLDER`,e.LINK=`LINK`,e.OBJECT=`OBJECT`,e.RECORD=`RECORD`,e.PAGE_LAYOUT=`PAGE_LAYOUT`,e.AGENT_CHAT_CHANNEL=`AGENT_CHAT_CHANNEL`,e.NATIVE_PAGE=`NATIVE_PAGE`,e.WORKFLOW=`WORKFLOW`,e.AGENT=`AGENT`,e.TAB=`TAB`,e.SECTION=`SECTION`,e}({}),p=function(e){return e.SIDE_PANEL=`SIDE_PANEL`,e.RECORD_PAGE=`RECORD_PAGE`,e.USER_CHOICE=`USER_CHOICE`,e}({}),te=function(e){return e.DAY=`DAY`,e.MONTH=`MONTH`,e.QUARTER=`QUARTER`,e.YEAR=`YEAR`,e.WEEK=`WEEK`,e.DAY_OF_THE_WEEK=`DAY_OF_THE_WEEK`,e.MONTH_OF_THE_YEAR=`MONTH_OF_THE_YEAR`,e.QUARTER_OF_THE_YEAR=`QUARTER_OF_THE_YEAR`,e.NONE=`NONE`,e}({}),m=function(e){return e.AND=`AND`,e.OR=`OR`,e}({}),h=function(e){return e.DAY=`DAY`,e.WEEK=`WEEK`,e.MONTH=`MONTH`,e}({}),g=function(e){return e.AND=`AND`,e.OR=`OR`,e.NOT=`NOT`,e}({}),_=function(e){return e.SIDE_PANEL=`SIDE_PANEL`,e.RECORD_PAGE=`RECORD_PAGE`,e}({}),v=function(e){return e.ASC=`ASC`,e.DESC=`DESC`,e}({}),y=({applicationUniversalIdentifier:e,objectUniversalIdentifier:t,name:n})=>i.t({entityNamespace:`pageLayout`,value:t?`${t}:${n}`:n,applicationUniversalIdentifier:e}),ne=({objectMetadataApplicationUniversalIdentifier:e,pageLayoutUniversalIdentifier:t,title:n})=>i.t({entityNamespace:`pageLayoutTab`,value:`${t}:${n}`,applicationUniversalIdentifier:e}),b=({objectMetadataApplicationUniversalIdentifier:e,pageLayoutTabUniversalIdentifier:t,title:n})=>i.t({entityNamespace:`pageLayoutWidget`,value:`${t}:${n}`,applicationUniversalIdentifier:e}),x=({objectMetadataApplicationUniversalIdentifier:e,objectUniversalIdentifier:t})=>y({applicationUniversalIdentifier:e,objectUniversalIdentifier:t,name:r.c.RECORD_FORM}),S=({objectMetadataApplicationUniversalIdentifier:e,objectUniversalIdentifier:t})=>y({applicationUniversalIdentifier:e,objectUniversalIdentifier:t,name:r.c.RECORD_PAGE}),C=e=>{let{folderUniversalIdentifier:n,...r}=e,i=e.parentUniversalIdentifier??n;return t.t(i)?{...r,parentUniversalIdentifier:i}:r},w=({objectUniversalIdentifier:e,tabs:t})=>{let n=S({objectMetadataApplicationUniversalIdentifier:o.t,objectUniversalIdentifier:e});return{universalIdentifier:n,tabs:Object.fromEntries(Object.entries(t).map(([e,{title:t,widgets:r}])=>{let i=ne({objectMetadataApplicationUniversalIdentifier:o.t,pageLayoutUniversalIdentifier:n,title:t});return[e,{universalIdentifier:i,widgets:Object.fromEntries(Object.entries(r).map(([e,t])=>[e,{universalIdentifier:b({objectMetadataApplicationUniversalIdentifier:o.t,pageLayoutTabUniversalIdentifier:i,title:t})}]))}]}))}},T={myFirstDashboard:{universalIdentifier:`20202020-d001-4d01-8d01-da5ab0a00001`,tabs:{tab1:{universalIdentifier:`20202020-d011-4d11-8d11-da5ab0a01001`,widgets:{welcomeRichText:{universalIdentifier:`20202020-d111-4d11-8d11-da5ab0a11001`},dealsByCompany:{universalIdentifier:`20202020-d111-4d11-8d11-da5ab0a11002`},pipelineValueByStage:{universalIdentifier:`20202020-d111-4d11-8d11-da5ab0a11003`},revenueTimeline:{universalIdentifier:`20202020-d111-4d11-8d11-da5ab0a11004`},opportunitiesByOwner:{universalIdentifier:`20202020-d111-4d11-8d11-da5ab0a11005`},stockMarketIframe:{universalIdentifier:`20202020-d111-4d11-8d11-da5ab0a11006`},dealsCreatedThisMonth:{universalIdentifier:`20202020-d111-4d11-8d11-da5ab0a11007`},dealValueCreatedThisMonth:{universalIdentifier:`20202020-d111-4d11-8d11-da5ab0a11008`}}}}},workspaceMemberRecordPage:w({objectUniversalIdentifier:r.n.workspaceMember,tabs:{home:{title:`Home`,widgets:{fields:`Fields`}}}}),attachmentRecordPage:w({objectUniversalIdentifier:r.n.attachment,tabs:{home:{title:`Home`,widgets:{preview:`Preview`,fields:`Fields`,attachedTo:`Attached to`}}}}),companyRecordPage:w({objectUniversalIdentifier:r.n.company,tabs:{home:{title:`Home`,widgets:{fields:`Fields`,people:`People`,opportunities:`Opportunities`}},timeline:{title:`Timeline`,widgets:{timeline:`Timeline`}},tasks:{title:`Tasks`,widgets:{tasks:`Tasks`}},notes:{title:`Notes`,widgets:{notes:`Notes`}},files:{title:`Files`,widgets:{files:`Files`}},emails:{title:`Emails`,widgets:{emails:`Emails`}},conversations:{title:`Conversations`,widgets:{conversations:`Conversations`}},calendar:{title:`Calendar`,widgets:{calendar:`Calendar`}}}}),personRecordPage:w({objectUniversalIdentifier:r.n.person,tabs:{home:{title:`Home`,widgets:{fields:`Fields`,company:`Company`,pointOfContactForOpportunities:`Opportunities`,listMemberships:`Lists`}},timeline:{title:`Timeline`,widgets:{timeline:`Timeline`}},tasks:{title:`Tasks`,widgets:{tasks:`Tasks`}},notes:{title:`Notes`,widgets:{notes:`Notes`}},files:{title:`Files`,widgets:{files:`Files`}},emails:{title:`Emails`,widgets:{emails:`Emails`}},conversations:{title:`Conversations`,widgets:{conversations:`Conversations`}},calendar:{title:`Calendar`,widgets:{calendar:`Calendar`}}}}),opportunityRecordPage:w({objectUniversalIdentifier:r.n.opportunity,tabs:{home:{title:`Home`,widgets:{fields:`Fields`,pointOfContact:`Point of Contact`,company:`Company`,owner:`Owner`}},timeline:{title:`Timeline`,widgets:{timeline:`Timeline`}},tasks:{title:`Tasks`,widgets:{tasks:`Tasks`}},notes:{title:`Notes`,widgets:{notes:`Notes`}},files:{title:`Files`,widgets:{files:`Files`}},emails:{title:`Emails`,widgets:{emails:`Emails`}},conversations:{title:`Conversations`,widgets:{conversations:`Conversations`}},calendar:{title:`Calendar`,widgets:{calendar:`Calendar`}}}}),noteRecordPage:w({objectUniversalIdentifier:r.n.note,tabs:{home:{title:`Home`,widgets:{fields:`Fields`,noteRichText:`Note`}},note:{title:`Note`,widgets:{noteRichText:`Note`}},timeline:{title:`Timeline`,widgets:{timeline:`Timeline`}},files:{title:`Files`,widgets:{files:`Files`}}}}),taskRecordPage:w({objectUniversalIdentifier:r.n.task,tabs:{home:{title:`Home`,widgets:{fields:`Fields`,taskRichText:`Task`}},note:{title:`Note`,widgets:{taskRichText:`Task`}},timeline:{title:`Timeline`,widgets:{timeline:`Timeline`}},files:{title:`Files`,widgets:{files:`Files`}}}}),workflowRunRecordPage:w({objectUniversalIdentifier:r.n.workflowRun,tabs:{home:{title:`Home`,widgets:{fields:`Fields`}},flow:{title:`Flow`,widgets:{workflowRun:`Flow`}}}}),agentChatThreadRecordPage:w({objectUniversalIdentifier:r.n.agentChatThread,tabs:{chat:{title:`Chat`,widgets:{chat:`Chat`}}}}),blocklistRecordPage:w({objectUniversalIdentifier:r.n.blocklist,tabs:{home:{title:`Home`,widgets:{fields:`Fields`}},timeline:{title:`Timeline`,widgets:{timeline:`Timeline`}}}}),calendarChannelEventAssociationRecordPage:w({objectUniversalIdentifier:r.n.calendarChannelEventAssociation,tabs:{home:{title:`Home`,widgets:{fields:`Fields`}},timeline:{title:`Timeline`,widgets:{timeline:`Timeline`}}}}),calendarEventRecordPage:w({objectUniversalIdentifier:r.n.calendarEvent,tabs:{home:{title:`Home`,widgets:{fields:`Fields`,participants:`Participants`,callRecordings:`Call Recordings`}},timeline:{title:`Timeline`,widgets:{timeline:`Timeline`}},summary:{title:`Summary`,widgets:{summary:`Summary`}},callRecording:{title:`Call Recording`,widgets:{transcript:`Transcript`}}}}),calendarEventParticipantRecordPage:w({objectUniversalIdentifier:r.n.calendarEventParticipant,tabs:{home:{title:`Home`,widgets:{fields:`Fields`}},timeline:{title:`Timeline`,widgets:{timeline:`Timeline`}}}}),callRecordingRecordPage:w({objectUniversalIdentifier:r.n.callRecording,tabs:{home:{title:`Home`,widgets:{fields:`Fields`}},timeline:{title:`Timeline`,widgets:{timeline:`Timeline`}},summary:{title:`Summary`,widgets:{summary:`Summary`}},callRecording:{title:`Call Recording`,widgets:{transcript:`Transcript`}}}}),messageChannelMessageAssociationRecordPage:w({objectUniversalIdentifier:r.n.messageChannelMessageAssociation,tabs:{home:{title:`Home`,widgets:{fields:`Fields`}},timeline:{title:`Timeline`,widgets:{timeline:`Timeline`}}}}),messageChannelMessageAssociationMessageFolderRecordPage:w({objectUniversalIdentifier:r.n.messageChannelMessageAssociationMessageFolder,tabs:{home:{title:`Home`,widgets:{fields:`Fields`}},timeline:{title:`Timeline`,widgets:{timeline:`Timeline`}}}}),messageParticipantRecordPage:w({objectUniversalIdentifier:r.n.messageParticipant,tabs:{home:{title:`Home`,widgets:{fields:`Fields`}},timeline:{title:`Timeline`,widgets:{timeline:`Timeline`}}}}),messageRecordPage:w({objectUniversalIdentifier:r.n.message,tabs:{home:{title:`Home`,widgets:{fields:`Fields`}}}}),messageThreadRecordPage:w({objectUniversalIdentifier:r.n.messageThread,tabs:{home:{title:`Home`,widgets:{emailThread:`Thread`}}}}),messageListRecordPage:w({objectUniversalIdentifier:r.n.messageList,tabs:{home:{title:`Home`,widgets:{fields:`Fields`,members:`Members`}},members:{title:`Members`,widgets:{members:`Members`}}}}),messageCampaignRecordPage:w({objectUniversalIdentifier:r.n.messageCampaign,tabs:{home:{title:`Home`,widgets:{details:`Details`,list:`List`,recipients:`Recipients`,fields:`Fields`}},composer:{title:`Email`,widgets:{messageCampaign:`Email`}}}})},E=e.t(),re=80,ie=new Map(Object.entries(r.t).flatMap(([e,t])=>Object.entries(t).map(([t,{universalIdentifier:n}])=>[n,{objectName:e,fieldName:t}]))),D=e=>(0,E.isNonEmptyString)(e)&&(0,E.isNonEmptyString)(a.t(e).replace(/-+/g,``)),O=e=>e.slice(0,re).replace(/-+$/g,``),k=({segments:e,universalIdentifier:n})=>{let r=O(e.filter(t.t).map(a.t).join(`-`).replace(/-{2,}/g,`-`).replace(/^-+|-+$/g,``));return(0,E.isNonEmptyString)(r)?r:n.slice(0,8)},ae=({indexManifest:e,objectName:t,fieldLocationByUniversalIdentifier:n})=>k({segments:[t,...e.fields.map(({fieldUniversalIdentifier:e})=>n.get(e)?.fieldName??null)],universalIdentifier:e.universalIdentifier}),oe=({viewFieldManifest:e,fieldLocationByUniversalIdentifier:n})=>{let r=n.get(e.fieldMetadataUniversalIdentifier)??ie.get(e.fieldMetadataUniversalIdentifier);return k({segments:t.t(r)?[r.objectName,r.fieldName]:[],universalIdentifier:e.universalIdentifier})},se=80,A=e=>[{path:[...e,`type`],symbol:`FieldType`,members:n.r},{path:[...e,`universalSettings`,`relationType`],symbol:`RelationType`,members:n.n},{path:[...e,`universalSettings`,`onDelete`],symbol:`OnDeleteAction`,members:a.n},{path:[...e,`universalSettings`,`dataType`],symbol:`NumberDataType`,members:u},{path:[...e,`universalSettings`,`displayFormat`],symbol:`DateDisplayFormat`,members:d}],j=A([]),M=[{path:[`openRecordIn`],symbol:`ObjectOpenRecordIn`,members:p},...A([`fields`,`[]`])],N=[{path:[`indexType`],symbol:`IndexType`,members:ee}],P=5,F=e=>[`recordsPermissions`,`objects`,`[]`,`rowLevelRecordsPermissions`,`[]`,...Array.from({length:e},()=>[`predicateGroups`,`[]`]).flat()],I=()=>[...Array.from({length:6},(e,t)=>({path:[...F(t),`predicates`,`[]`,`operand`],symbol:`RowLevelPermissionPredicateOperand`,members:c})),...Array.from({length:P},(e,t)=>({path:[...F(t+1),`logicalOperator`],symbol:`RowLevelPermissionPredicateGroupLogicalOperator`,members:m}))],L=e=>[...I(),{path:[`rowLevelPermissionPredicateGroups`,`[]`,`logicalOperator`],symbol:`RowLevelPermissionPredicateGroupLogicalOperator`,members:m},{path:[`rowLevelPermissionPredicates`,`[]`,`operand`],symbol:`RowLevelPermissionPredicateOperand`,members:c},{path:[`permissionFlagUniversalIdentifiers`,`[]`],symbol:`SystemPermissionFlag`,members:e}];L(r.r);var R=e=>({path:e,symbol:`AggregateOperations`,members:l}),z=e=>[{path:[...e,`filters`,`[]`,`operand`],symbol:`ViewFilterOperand`,members:r.u},{path:[...e,`filterGroups`,`[]`,`logicalOperator`],symbol:`ViewFilterGroupLogicalOperator`,members:g},{path:[...e,`sorts`,`[]`,`direction`],symbol:`ViewSortDirection`,members:v},R([...e,`aggregateOperation`])],B=[R([`aggregateOperation`]),...z([`relationScope`])],V=[{path:[`type`],symbol:`ViewType`,members:a.r},{path:[`openRecordIn`],symbol:`ViewOpenRecordIn`,members:_},R([`kanbanAggregateOperation`]),{path:[`calendarLayout`],symbol:`ViewCalendarLayout`,members:h},R([`fields`,`[]`,`aggregateOperation`]),...z([`fields`,`[]`,`relationScope`]),{path:[`filters`,`[]`,`operand`],symbol:`ViewFilterOperand`,members:r.u},{path:[`filterGroups`,`[]`,`logicalOperator`],symbol:`ViewFilterGroupLogicalOperator`,members:g},{path:[`sorts`,`[]`,`direction`],symbol:`ViewSortDirection`,members:v}],H=e=>[{path:[...e,`type`],symbol:`WidgetType`,members:r.d},{path:[...e,`position`,`layoutMode`],symbol:`PageLayoutTabLayoutMode`,members:r.l},R([...e,`configuration`,`aggregateOperation`]),...[`dateGranularity`,`primaryAxisDateGranularity`,`secondaryAxisGroupByDateGranularity`].map(t=>({path:[...e,`configuration`,t],symbol:`ObjectRecordGroupByDateGranularity`,members:te}))],U=e=>[{path:[...e,`layoutMode`],symbol:`PageLayoutTabLayoutMode`,members:r.l},...H([...e,`widgets`,`[]`])],W=H([]),G=U([]),K=[{path:[`type`],symbol:`NavigationMenuItemType`,members:f}],ce=[{path:[`type`],symbol:`PageLayoutType`,members:r.c},...U([`tabs`,`[]`])],q=[`version`,`steps`,`[]`],J=e=>({path:e,symbol:`ViewFilterOperand`,members:r.u}),le=[J([`version`,`trigger`,`settings`,`filter`,`stepFilters`,`[]`,`operand`]),J([...q,`input`,`stepFilters`,`[]`,`operand`]),J([...q,`input`,`filter`,`recordFilters`,`[]`,`operand`]),{path:[...q,`input`,`[]`,`type`],symbol:`FieldType`,members:n.r}],ue=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),de=({definer:e,config:n,enumBindings:r=[],importStatements:i=[]})=>{let a=new Set,o=s.n({value:n,resolveEnumSymbol:({path:e,value:n})=>{let i=r.find(t=>ue(t.path,e));if(!t.t(i))return;let o=Object.keys(i.members).find(e=>i.members[e]===n);if(t.t(o))return a.add(i.symbol),`${i.symbol}.${o}`}}),c=[e,...[...a].sort()],l=`import { ${c.join(`, `)} } from 'twenty-sdk/define';`,u=l.length<=se?l:`import {\n${c.map(e=>` ${e},`).join(`
2
+ `)}\n} from 'twenty-sdk/define';`;return{content:`${[...i,u].join(`
3
+ `)}
4
+
5
+ export default ${e}(${o});
6
+ `,requiredSdkExports:c}},fe=`__typename`,Y=e=>Array.isArray(e)?e.map(Y):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).filter(([e])=>e!==fe).map(([e,t])=>[e,Y(t)])),pe=new Set([`packageJsonChecksum`,`yarnLockChecksum`,`requiredServerVersionRange`,`aboutDescription`,`postInstallLogicFunction`,`preInstallLogicFunction`,`uninstallLogicFunction`,`healthCheckLogicFunction`,`settingsFrontComponent`,`settingsCustomTabFrontComponentUniversalIdentifier`,`frontComponentSharedDependencies`,`logoUrl`,`screenshots`]),me=`public/cover.generated.png`,he=e=>(e.roles??[]).some(({universalIdentifier:t})=>t===e.application.defaultRoleUniversalIdentifier),ge=e=>{let t=Object.fromEntries(Object.entries(e.application).filter(([t])=>!pe.has(t)&&!(t===`defaultRoleUniversalIdentifier`&&he(e)))),{galleryImages:n}=t;if(!Array.isArray(n)||n.length===0||n.every(e=>e===me)){let{galleryImages:e,...n}=t;return n}return t},X=({permissions:e,getDerivedUniversalIdentifier:t})=>e.map(({universalIdentifier:e,...n})=>e===t(n)?n:{universalIdentifier:e,...n}),_e=({roleManifest:e,applicationUniversalIdentifier:n})=>{let{universalIdentifier:i,objectPermissions:a,recordsPermissions:o,fieldPermissions:s}=e;return{...e,...t.t(a)?{objectPermissions:X({permissions:a,getDerivedUniversalIdentifier:({objectUniversalIdentifier:e})=>r.o({applicationUniversalIdentifier:n,roleUniversalIdentifier:i,objectUniversalIdentifier:e})})}:{},...t.t(o?.objects)?{recordsPermissions:{...o,objects:X({permissions:o.objects,getDerivedUniversalIdentifier:({objectUniversalIdentifier:e})=>r.o({applicationUniversalIdentifier:n,roleUniversalIdentifier:i,objectUniversalIdentifier:e})})}}:{},...t.t(s)?{fieldPermissions:X({permissions:s,getDerivedUniversalIdentifier:({fieldUniversalIdentifier:e})=>r.s({applicationUniversalIdentifier:n,roleUniversalIdentifier:i,fieldUniversalIdentifier:e})})}:{}}},ve=({objectName:e,fieldName:t,fieldUniversalIdentifier:n})=>k({segments:[e,t],universalIdentifier:n}),ye=new Map(Object.entries(r.n).map(([e,t])=>[t,e])),Z=({objectUniversalIdentifier:e,manifest:t})=>(t.objects??[]).find(t=>t.universalIdentifier===e)?.nameSingular??ye.get(e)??null,be=new Map(Object.entries(T).map(([e,{universalIdentifier:t}])=>[t,e])),Q=({pageLayoutUniversalIdentifier:e,manifest:n})=>{let r=n.pageLayouts?.find(t=>t.universalIdentifier===e);if(t.t(r))return r.name;let i=be.get(e);if(t.t(i))return i;let a=n.application.universalIdentifier;for(let t of n.objects??[]){let n={objectMetadataApplicationUniversalIdentifier:a,objectUniversalIdentifier:t.universalIdentifier};if(S(n)===e)return`${t.nameSingular}RecordPage`;if(x(n)===e)return`${t.nameSingular}RecordForm`}return null},$=({viewUniversalIdentifier:e,manifest:n})=>{let i=n.views?.find(t=>t.universalIdentifier===e);if(t.t(i))return i.name;let a=n.application.universalIdentifier;for(let t of n.objects??[])if(r.i({objectMetadataApplicationUniversalIdentifier:a,objectUniversalIdentifier:t.universalIdentifier,viewKey:r.a.INDEX})===e)return`${t.nameSingular}IndexView`;return null},xe=({navigationMenuItemManifest:e,manifest:n})=>{let{type:r,name:i,targetObjectUniversalIdentifier:a,viewUniversalIdentifier:o,pageLayoutUniversalIdentifier:s}=e;return D(i)?i:r===f.OBJECT&&t.t(a)?Z({objectUniversalIdentifier:a,manifest:n}):r===f.VIEW&&t.t(o)?$({viewUniversalIdentifier:o,manifest:n}):r===f.PAGE_LAYOUT&&t.t(s)?Q({pageLayoutUniversalIdentifier:s,manifest:n}):null},Se=({navigationMenuItemManifest:e,manifest:t})=>k({segments:[xe({navigationMenuItemManifest:e,manifest:t})],universalIdentifier:e.universalIdentifier}),Ce=({parentUniversalIdentifier:e,manifest:t})=>{let n=t.navigationMenuItems?.find(t=>t.universalIdentifier===e)?.name;return D(n)?n:null},we=[`application`,`frontComponent`,`logicFunction`,`object`,`field`,`index`,`permissionFlag`,`role`,`view`,`viewField`,`pageLayout`,`pageLayoutTab`,`navigationMenuItem`,`pageLayoutWidget`,`workflow`,`skill`,`agent`,`validationRule`,`relatedRecordPath`],Te=({manifest:e,sourceFileByUniversalIdentifier:n=new Map,systemPermissionFlag:i=r.r})=>{let o=e.application.universalIdentifier,s=[],c=[];s.push({kind:`application`,universalIdentifier:o,definer:`defineApplication`,config:ge(e),enumBindings:[],defaultFolder:`src`,fileSuffix:`.config.ts`,fileBaseName:`application`,parentName:null});let l=new Set,u=new Map,d=[...e.fields??[]];for(let t of e.objects??[]){let e=[];for(let r of t.fields??[])u.set(r.universalIdentifier,{objectName:t.nameSingular,fieldName:r.name}),n.get(r.universalIdentifier.toLowerCase())?.entityKey===`fields`?d.push({...r,objectUniversalIdentifier:t.universalIdentifier}):e.push(r);l.add(t.universalIdentifier),s.push({kind:`object`,universalIdentifier:t.universalIdentifier,definer:`defineObject`,config:{...t,fields:e},enumBindings:M,defaultFolder:`src/objects`,fileSuffix:`.object.ts`,fileBaseName:a.t(t.nameSingular),parentName:null})}for(let t of d){let n=Z({objectUniversalIdentifier:t.objectUniversalIdentifier,manifest:e});u.set(t.universalIdentifier,{objectName:n,fieldName:t.name}),s.push({kind:`field`,universalIdentifier:t.universalIdentifier,definer:`defineField`,config:t,enumBindings:j,defaultFolder:`src/fields`,fileSuffix:`.field.ts`,fileBaseName:ve({objectName:n,fieldName:t.name,fieldUniversalIdentifier:t.universalIdentifier}),parentName:n})}for(let t of e.indexes??[]){if(!l.has(t.objectUniversalIdentifier)){c.push({kind:`index`,universalIdentifier:t.universalIdentifier,reason:`its object is not part of the written source`});continue}let n=Z({objectUniversalIdentifier:t.objectUniversalIdentifier,manifest:e});s.push({kind:`index`,universalIdentifier:t.universalIdentifier,definer:`defineIndex`,config:t,enumBindings:N,defaultFolder:`src/indexes`,fileSuffix:`.index.ts`,fileBaseName:ae({indexManifest:t,objectName:n,fieldLocationByUniversalIdentifier:u}),parentName:n})}for(let t of e.validationRules??[])s.push({kind:`validationRule`,universalIdentifier:t.universalIdentifier,definer:`defineValidationRule`,config:t,enumBindings:[],defaultFolder:`src/validation-rules`,fileSuffix:`.validation-rule.ts`,fileBaseName:k({segments:[t.name],universalIdentifier:t.universalIdentifier}),parentName:Z({objectUniversalIdentifier:t.objectUniversalIdentifier,manifest:e})});for(let t of e.permissionFlags??[])s.push({kind:`permissionFlag`,universalIdentifier:t.universalIdentifier,definer:`definePermissionFlag`,config:t,enumBindings:[],defaultFolder:`src/permission-flags`,fileSuffix:`.permission-flag.ts`,fileBaseName:k({segments:[t.key],universalIdentifier:t.universalIdentifier}),parentName:null});for(let t of e.roles??[])s.push({kind:`role`,universalIdentifier:t.universalIdentifier,definer:t.universalIdentifier===e.application.defaultRoleUniversalIdentifier?`defineApplicationRole`:`defineRole`,config:_e({roleManifest:t,applicationUniversalIdentifier:o}),enumBindings:L(i),defaultFolder:`src/roles`,fileSuffix:`.role.ts`,fileBaseName:k({segments:[t.label],universalIdentifier:t.universalIdentifier}),parentName:null});for(let t of e.views??[])s.push({kind:`view`,universalIdentifier:t.universalIdentifier,definer:`defineView`,config:t,enumBindings:V,defaultFolder:`src/views`,fileSuffix:`.view.ts`,fileBaseName:k({segments:[t.name],universalIdentifier:t.universalIdentifier}),parentName:Z({objectUniversalIdentifier:t.objectUniversalIdentifier,manifest:e})});for(let t of e.viewFields??[])s.push({kind:`viewField`,universalIdentifier:t.universalIdentifier,definer:`defineViewField`,config:t,enumBindings:B,defaultFolder:`src/view-fields`,fileSuffix:`.view-field.ts`,fileBaseName:oe({viewFieldManifest:t,fieldLocationByUniversalIdentifier:u}),parentName:null});for(let n of e.pageLayouts??[])s.push({kind:`pageLayout`,universalIdentifier:n.universalIdentifier,definer:`definePageLayout`,config:Y(n),enumBindings:ce,defaultFolder:`src/page-layouts`,fileSuffix:`.page-layout.ts`,fileBaseName:k({segments:[n.name],universalIdentifier:n.universalIdentifier}),parentName:t.t(n.objectUniversalIdentifier)?Z({objectUniversalIdentifier:n.objectUniversalIdentifier,manifest:e}):null});for(let n of e.pageLayoutTabs??[]){let{pageLayoutUniversalIdentifier:r}=n;if(!t.t(r)){c.push({kind:`pageLayoutTab`,universalIdentifier:n.universalIdentifier,reason:`it does not name the page layout it belongs to`});continue}s.push({kind:`pageLayoutTab`,universalIdentifier:n.universalIdentifier,definer:`definePageLayoutTab`,config:Y(n),enumBindings:G,defaultFolder:`src/page-layout-tabs`,fileSuffix:`.page-layout-tab.ts`,fileBaseName:k({segments:[n.title],universalIdentifier:n.universalIdentifier}),parentName:Q({pageLayoutUniversalIdentifier:r,manifest:e})})}for(let n of e.navigationMenuItems??[]){let r=C(n).parentUniversalIdentifier;s.push({kind:`navigationMenuItem`,universalIdentifier:n.universalIdentifier,definer:`defineNavigationMenuItem`,config:n,enumBindings:K,defaultFolder:`src/navigation-menu-items`,fileSuffix:`.navigation-menu-item.ts`,fileBaseName:Se({navigationMenuItemManifest:n,manifest:e}),parentName:t.t(r)?Ce({parentUniversalIdentifier:r,manifest:e}):null})}for(let n of e.pageLayoutWidgets??[]){let{objectUniversalIdentifier:r}=n;s.push({kind:`pageLayoutWidget`,universalIdentifier:n.universalIdentifier,definer:`definePageLayoutWidget`,config:Y(n),enumBindings:W,defaultFolder:`src/page-layout-widgets`,fileSuffix:`.page-layout-widget.ts`,fileBaseName:k({segments:[n.title],universalIdentifier:n.universalIdentifier}),parentName:t.t(r)?Z({objectUniversalIdentifier:r,manifest:e}):null})}for(let t of e.workflows??[])s.push({kind:`workflow`,universalIdentifier:t.universalIdentifier,definer:`defineWorkflow`,config:t,enumBindings:le,defaultFolder:`src/workflows`,fileSuffix:`.workflow.ts`,fileBaseName:k({segments:[t.name],universalIdentifier:t.universalIdentifier}),parentName:null});for(let t of e.skills??[])s.push({kind:`skill`,universalIdentifier:t.universalIdentifier,definer:`defineSkill`,config:t,enumBindings:[],defaultFolder:`src/skills`,fileSuffix:`.skill.ts`,fileBaseName:k({segments:[t.name],universalIdentifier:t.universalIdentifier}),parentName:null});for(let t of e.relatedRecordPaths??[])s.push({kind:`relatedRecordPath`,universalIdentifier:t.universalIdentifier,definer:`defineRelatedRecordPath`,config:t,enumBindings:[],defaultFolder:`src/related-record-paths`,fileSuffix:`.related-record-path.ts`,fileBaseName:k({segments:[],universalIdentifier:t.universalIdentifier}),parentName:null});for(let t of e.agents??[])s.push({kind:`agent`,universalIdentifier:t.universalIdentifier,definer:`defineAgent`,config:t,enumBindings:[],defaultFolder:`src/agents`,fileSuffix:`.agent.ts`,fileBaseName:k({segments:[t.name],universalIdentifier:t.universalIdentifier}),parentName:null});return{entities:s,skipped:c}},Ee=`2.50.0`;Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return Ee}});
@@ -1 +1 @@
1
- const e=require("./rolldown-runtime-mLOUI7ql.cjs"),t=require("./build--4zYt4wd.cjs"),n=require("./isDefined-CJctgvfE.cjs"),r=require("./isPlainObject-fJEJm71P.cjs"),i=require("./is-supported-locale-DUMI9QQ2.cjs"),a=require("./pull-minimum-sdk-version.constant-DJS72Nbz.cjs"),o=require("./isValidUniversalIdentifier-DymFerYs.cjs"),s=require("./locale-catalog-format-BD4XDEnl.cjs"),c=require("./kebab-case-tmo--p0I.cjs"),l=require("./has-error-code-DsJeqbZq.cjs"),u=require("./fs-utils-BcNux7fF.cjs"),d=require("./cli-error-CrUD8uMp.cjs"),f=require("./get-tooling-error-context-CZKTM7Q6.cjs"),p=require("./isRestorableApplicationSourcePath-Du_zM55R.cjs"),m=require("./parse-app-export-B9Ocghe1.cjs"),h=require("./extract-manifest-from-file-KLaAvTnC.cjs"),g=require("./code-step-file-suffix.constant-B6vqrfcU.cjs"),_=require("./collect-translatable-strings-AWv41yIv.cjs"),v=require("./constants-Cf5-CwMu.cjs"),y=require("./assert-pull-paths-TFGZvzZO.cjs"),b=require("./is-locale-catalog-T4W5NhnW.cjs"),x=require("./is-exported-manifest-BHA_mGa6.cjs"),S=require("./create-pull-base-write-CX8xZhMz.cjs"),C=require("./print-typescript-value-BjYn0ZFT.cjs"),w=require("./read-application-identity-CxmrWgYf.cjs");let T=require("node:fs/promises"),E=require("node:path"),D=require("node:module"),O=require("esbuild"),k=require("typescript");k=e.r(k);var A=t.t(),ee=async({appPath:e,manifest:t,files:r,reservedPaths:i,remoteSourceFingerprints:a={},sourceFingerprints:o={}})=>{let s=new Set(m.i(t).map(e=>e.sourcePath)),c=[],l={},f={},h=0;for(let t of r.filter(e=>e.folder===p.r.Source&&!s.has(e.path))){let r=Buffer.from(t.content,t.encoding===`base64`?`base64`:`utf8`),s=S.i(r),p=await u.i((0,E.join)(e,t.path))?await(0,T.readFile)((0,E.join)(e,t.path)):void 0;if(i.has(t.path.toLowerCase())||n.t(p)&&!p.equals(r)&&!n.t(a[t.path]??o[t.path])&&t.path!==`tsconfig.json`)throw new d.t({code:`CONFLICT`,message:`Cannot restore source ${t.path}: it is occupied by another local file or definition. No local files were changed.`});if(l[t.path]=s,p?.equals(r)){f[t.path]=s,h++;continue}if(n.t(p)&&(a[t.path]??o[t.path])===s){h++;continue}c.push({kind:`source`,universalIdentifier:`source/${t.path}`,relativePath:t.path,content:r,requiredSdkExports:[],isRegeneration:n.t(p)})}return{writes:c,fingerprints:l,unchangedSourceFingerprints:f,unchangedCount:h}},te=async({appPath:e,files:t,sourceFingerprints:r={},publicAssetFingerprints:i={}})=>{await y.t({appPath:e,relativePaths:t.map(({path:e})=>e)});let a=[],o={},s={};for(let{path:c,content:l}of t){let t=Buffer.from(l,`base64`),d=S.i(t);o[c]=d;let f=(0,E.join)(e,c),p=await u.i(f)?await(0,T.readFile)(f):void 0;if(!(n.t(p)&&(i[c]??r[c])===d)){if(p?.equals(t)){s[c]=d;continue}a.push({kind:`publicAsset`,universalIdentifier:`public-asset/${c}`,relativePath:c,content:t,requiredSdkExports:[],isRegeneration:n.t(p)})}}return{writes:a,fingerprints:o,unchangedSourceFingerprints:s,unchangedCount:t.length-a.length}},ne=async({appPath:e,manifest:t,baseManifest:r,files:i,scannedFiles:a,protectedIdentifiers:o,reservedPaths:s,remoteSourceFingerprints:c={},sourceFingerprints:l={}})=>{let f=[],h=[],g=0,_={},v={},y=new Set(s),b=m.i(t),x=m.i(r);for(let t of b){let{sourcePath:r}=t,{universalIdentifier:o}=t.definition,s=i.find(e=>e.folder===p.r.Source&&e.path===r),m=a.find(e=>e.entityKey===t.entityKey&&e.universalIdentifier?.toLowerCase()===o.toLowerCase());if(n.t(t.sourceFiles)&&n.t(m)&&m.relativePath.split(`\\`).join(`/`)!==r)throw new d.t({code:`CONFLICT`,message:`${t.label} ${o} moved locally. Restore it to ${r} before pulling its imported files.`});let h=(m?.relativePath??r).split(`\\`).join(`/`),b=h.toLowerCase(),C=await u.i((0,E.join)(e,h))?await(0,T.readFile)((0,E.join)(e,h),`utf8`):void 0;if(!n.t(s)||y.has(b)||n.t(C)&&!n.t(m))throw new d.t({code:`CONFLICT`,message:n.t(s)?`Cannot restore ${t.label.toLowerCase()} ${o}: ${h} is occupied by another local file or definition. No local files were changed.`:`Source for ${t.label.toLowerCase()} ${o} was not exported. No local files were changed.`});y.add(b);let w=Buffer.from(s.content,s.encoding===`base64`?`base64`:`utf8`).toString(`utf8`),D=S.i(w);_[r]=D,C===w&&(v[h]=D);let O=x.find(e=>e.definition.universalIdentifier.toLowerCase()===o.toLowerCase()),k=(n.t(O)?c[O.sourcePath]:void 0)??l[h];if(C===w||n.t(C)&&n.t(O)&&(n.t(k)?k===D:JSON.stringify(O.definition)===JSON.stringify(t.definition))){g++;continue}f.push({kind:t.kind,universalIdentifier:o,relativePath:h,content:w,requiredSdkExports:t.requiredSdkExports,isRegeneration:n.t(C)})}for(let e of x){if(o.has(e.definition.universalIdentifier.toLowerCase())){let t=c[e.sourcePath];if(!n.t(t)||b.some(t=>t.definition.universalIdentifier.toLowerCase()===e.definition.universalIdentifier.toLowerCase()))continue;_[e.sourcePath]=t;continue}let t=a.find(t=>t.entityKey===e.entityKey&&t.universalIdentifier?.toLowerCase()===e.definition.universalIdentifier.toLowerCase())?.relativePath.split(`\\`).join(`/`);n.t(t)&&!y.has(t.toLowerCase())&&h.push({universalIdentifier:e.definition.universalIdentifier,relativePath:t})}return{writes:f,deletions:h,unchangedCount:g,fingerprints:_,unchangedSourceFingerprints:v}},j=({value:e,identifiers:t})=>{(0,A.isArray)(e)?e.forEach(e=>j({value:e,identifiers:t})):r.t(e)&&((0,A.isString)(e.universalIdentifier)&&t.add(e.universalIdentifier.toLowerCase()),Object.values(e).forEach(e=>j({value:e,identifiers:t})))},M=[`import { readFileSync } from 'node:fs';`,`import { join } from 'node:path';`],N=e=>E.posix.basename(e).replace(/(\.workflow)?\.tsx?$/,``),P=e=>E.posix.join(E.posix.dirname(e),N(e)),F=({folderPath:e,fileBaseName:t,universalIdentifier:r,localFileName:i,takenFileNames:a,isCodeStepPathAvailable:o})=>{let s=r.slice(0,8),c=t=>!a.has(t)&&o({relativePath:E.posix.join(e,t),stepUniversalIdentifier:r}),l=[`${t}${g.t}`,`${s}-${t}${g.t}`],u=`${s}-${t}-`,d=e=>l.includes(e)||e.startsWith(u)&&e.endsWith(`.code.ts`)&&/^([2-9]|[1-9]\d+)$/.test(e.slice(u.length,-8)),f=e=>(a.add(e),e);if(n.t(i)&&d(i)&&c(i))return f(i);let[p]=l;c(p)||(p=l[1]);for(let e=2;!c(p);e++)p=`${u}${e}${g.t}`;return f(p)},I=({config:e,workflowRelativePath:t,isCodeStepPathAvailable:i=()=>!0,localCodeStepPathByStepIdentifier:o})=>{if(!r.t(e)||!r.t(e.version)||!Array.isArray(e.version.steps))return{config:e,importStatements:[],codeStepFiles:[]};let s=N(t),c=P(t),l=new Set,u=[],d=e.version.steps.map(e=>{if(!r.t(e)||e.type!==`CODE`||!(0,A.isString)(e.universalIdentifier)||!r.t(e.input)||!(0,A.isString)(e.input.code))return e;let t=o?.get(e.universalIdentifier.toLowerCase()),d=F({folderPath:c,fileBaseName:a.o({segments:[(0,A.isString)(e.name)?e.name:null],universalIdentifier:e.universalIdentifier}),universalIdentifier:e.universalIdentifier,localFileName:n.t(t)&&E.posix.dirname(t)===c?E.posix.basename(t):void 0,takenFileNames:l,isCodeStepPathAvailable:i});return u.push({universalIdentifier:e.universalIdentifier,relativePath:E.posix.join(c,d),content:e.input.code}),{...e,input:{...e.input,code:C.r(`readFileSync(join(__dirname, ${C.t(s)}, ${C.t(d)}), 'utf8')`)}}});return u.length===0?{config:e,importStatements:[],codeStepFiles:u}:{config:{...e,version:{...e.version,steps:d}},importStatements:M,codeStepFiles:u}},L=async({manifest:e,frontComponentSourcePaths:t})=>{let r=[..._.t(e),...await _.n(t)],a=new Map(r.map(e=>[s.r(e.message,e.context),e]));return Object.entries(e.translations??{}).filter(e=>i.t(e[0])&&b.t(e[1])).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>{let r=[],i={};for(let[e,o]of Object.entries(t)){let t=a.get(e);n.t(t)?r.push({message:t.message,context:t.context,translation:o}):i[e]=o}return{locale:e,authored:s.t(r),compiled:i}})},R=e=>n.t(e)&&typeof e==`object`&&!Array.isArray(e),z=e=>`${JSON.stringify(e,null,2)}\n`,B=e=>{if(!n.t(e))return{};try{let t=JSON.parse(e);return n.t(t)&&typeof t==`object`?t:{}}catch{return{}}},V=({message:e,context:t})=>JSON.stringify([t??null,e]),re=({catalog:e,existingAuthoredContent:t,existingCompiledContent:n})=>{let r=new Set(s.n(e.authored).map(e=>s.r(e.message,e.context))),i=new Set(Object.keys(B(n)).filter(t=>!(t in e.compiled)&&r.has(t)));if(i.size===0)return null;let a=s.n(B(t)),o=new Set(a.map(V)),c=s.n(e.authored).filter(e=>i.has(s.r(e.message,e.context))&&!o.has(V(e)));return s.t([...a,...c])},H=e=>`${v.n}/${e}.json`,U=e=>`${v.t}/${e}.json`,W=async e=>await u.i(e)?await(0,T.readFile)(e,`utf8`):null,G=async({appPath:e,manifest:t,baseManifest:r,frontComponentSourcePaths:a})=>{let o=[],s=[],c={},l=t.translations;if(!R(l))return{writes:o,deletions:s,compiledEntryCountByLocale:c};let d=await L({manifest:t,frontComponentSourcePaths:a}),f=new Set(Object.keys(l)),p=R(r?.translations)?r.translations:{},m=l;for(let t of d){let{locale:r,authored:i,compiled:a}=t,l=Object.keys(a).length;l>0&&(c[r]=l);let u=H(r),d=U(r),f=await W((0,E.join)(e,u)),h=await W((0,E.join)(e,d)),g=r in p&&JSON.stringify(p[r])===JSON.stringify(m[r]),_=(Object.keys(i).length===0||n.t(f))&&(l===0||n.t(h)),v=g&&_?re({catalog:t,existingAuthoredContent:f,existingCompiledContent:h}):null;if(g&&_&&!n.t(v))continue;let y=[{relativePath:u,content:z(v??i),isWanted:Object.keys(v??i).length>0,existingContent:f},{relativePath:d,content:z(a),isWanted:l>0,existingContent:h}];for(let{relativePath:e,content:t,isWanted:i,existingContent:a}of y){let c=n.t(a);if(!i){c&&e===d&&s.push({universalIdentifier:r,relativePath:e});continue}a!==t&&o.push({kind:`translation`,requiredSdkExports:[],universalIdentifier:r,relativePath:e,content:t,isRegeneration:c})}}for(let[t,n]of Object.entries(p))if(!(f.has(t)||!i.t(t)||!b.t(n)))for(let n of[H(t),U(t)])await u.i((0,E.join)(e,n))&&s.push({universalIdentifier:t,relativePath:n});return{writes:o,deletions:s,compiledEntryCountByLocale:c}},K=({entity:e,relativePath:t,isCodeStepPathAvailable:n,localCodeStepPathByStepIdentifier:r})=>{if(e.kind!==`workflow`)return{...a.i({definer:e.definer,config:e.config,enumBindings:e.enumBindings}),codeStepFiles:[]};let{config:i,importStatements:o,codeStepFiles:s}=I({config:e.config,workflowRelativePath:t,isCodeStepPathAvailable:n,localCodeStepPathByStepIdentifier:r});return{...a.i({definer:e.definer,config:i,enumBindings:e.enumBindings,importStatements:o}),codeStepFiles:s}},ie=async({appPath:e,baseManifest:t,writes:r,deletions:i,frontComponentSourcePaths:o,sourceFingerprints:s,baseEntities:c,localCodeStepFilesByWorkflowPath:l})=>{if(!n.t(t))return[];let u=new Map(c.map(e=>[e.universalIdentifier,e])),d=await G({appPath:e,manifest:t,baseManifest:null,frontComponentSourcePaths:o}),f=new Map(d.writes.map(e=>[e.relativePath,e.content])),p=new Set(d.deletions.map(({relativePath:e})=>e)),m=new Map(c.flatMap(e=>e.kind===`workflow`?I({config:e.config,workflowRelativePath:``}).codeStepFiles.map(({universalIdentifier:e,content:t})=>[e.toLowerCase(),t]):[])),h=[...l.values()].flat(),g=new Map(h.map(({universalIdentifier:e,relativePath:t})=>[e.toLowerCase(),t])),_=new Map(h.flatMap(({universalIdentifier:e,relativePath:t})=>{let r=m.get(e.toLowerCase());return n.t(r)?[[t,r]]:[]})),v=({universalIdentifier:e,relativePath:t})=>{let r=u.get(e);if(n.t(r))return[K({entity:r,relativePath:t,localCodeStepPathByStepIdentifier:g}).content,a.i({definer:r.definer,config:r.config,enumBindings:r.enumBindings}).content];let i=_.get(t)??f.get(t);return n.t(i)?[i]:[]},y=[];for(let{universalIdentifier:t,relativePath:a}of[...r.filter(e=>e.isRegeneration),...i]){let r=s?.[a];if(n.t(r)){S.i(await(0,T.readFile)((0,E.join)(e,a)))!==r&&y.push({universalIdentifier:t,relativePath:a});continue}let i=v({universalIdentifier:t,relativePath:a});(p.has(a)||i.length>0&&!i.includes(await(0,T.readFile)((0,E.join)(e,a),`utf8`)))&&y.push({universalIdentifier:t,relativePath:a})}return y},q=e=>e.split(`\\`).join(`/`),J=({node:e,name:t})=>n.t(e)&&k.isIdentifier(e)&&e.text===t,Y=({objectLiteral:e,propertyName:t})=>e.properties.find(e=>k.isPropertyAssignment(e)&&!k.isComputedPropertyName(e.name)&&e.name.text===t)?.initializer,ae=e=>{if(!n.t(e)||!k.isCallExpression(e)||!J({node:e.expression,name:`readFileSync`}))return;let[t]=e.arguments;if(!n.t(t)||!k.isCallExpression(t)||!J({node:t.expression,name:`join`}))return;let[r,...i]=t.arguments;return J({node:r,name:`__dirname`})&&i.every(k.isStringLiteralLike)?i.map(e=>e.text):void 0},oe=({workflowPath:e,source:t})=>{let r=new Map,i=t=>{if(k.isObjectLiteralExpression(t)){let i=Y({objectLiteral:t,propertyName:`universalIdentifier`}),a=Y({objectLiteral:t,propertyName:`input`}),o=n.t(a)&&k.isObjectLiteralExpression(a)?ae(Y({objectLiteral:a,propertyName:`code`})):void 0;n.t(i)&&k.isStringLiteralLike(i)&&n.t(o)&&r.set(i.text.toLowerCase(),E.posix.join(E.posix.dirname(e),...o))}k.forEachChild(t,i)};return i(k.createSourceFile(e,t,k.ScriptTarget.Latest,!1)),r},se=async({appPath:e,scannedFiles:t,baseEntities:r})=>{let i=new Set(t.filter(e=>e.isReadable).map(e=>q(e.relativePath))),a=new Map(r.filter(e=>e.kind===`workflow`).map(e=>[e.universalIdentifier.toLowerCase(),e.config])),o=new Map;for(let r of t){if(r.entityKey!==`workflows`)continue;let t=q(r.relativePath),s=`${P(t)}/`,c=new Map,l=new Set,u=e=>e.startsWith(s)&&e.endsWith(`.code.ts`)&&i.has(e)&&!l.has(e),d=({stepIdentifier:e,relativePath:t})=>{c.set(e,t),l.add(t)};for(let[n,r]of oe({workflowPath:t,source:await(0,T.readFile)((0,E.join)(e,t),`utf8`)}))u(r)&&d({stepIdentifier:n,relativePath:r});let f=I({config:n.t(r.universalIdentifier)?a.get(r.universalIdentifier.toLowerCase()):void 0,workflowRelativePath:t,localCodeStepPathByStepIdentifier:c}).codeStepFiles;for(let{universalIdentifier:t,relativePath:n,content:r}of f){let i=t.toLowerCase();!c.has(i)&&u(n)&&await(0,T.readFile)((0,E.join)(e,n),`utf8`)===r&&d({stepIdentifier:i,relativePath:n})}o.set(t,[...c].map(([e,t])=>({universalIdentifier:e,relativePath:t})))}return o},ce=async({appPath:e,applicationExport:t,target:i,signal:a})=>{a.throwIfAborted();let o=S.n(i),s=m.n(t.manifest),c=m.r({value:t.files,logicFunctions:s.logicFunctions??[],frontComponents:s.frontComponents??[]});if(await y.t({appPath:e,relativePaths:[S.r,...c.map(e=>e.path)]}),!r.t(JSON.parse(await(0,T.readFile)((0,E.join)(e,`package.json`),`utf8`))))throw Error(`Pull requires a project with a package.json object.`);let l=await w.t({appPath:e,signal:a});if(n.t(l.application)&&l.application.universalIdentifier.toLowerCase()!==t.application.universalIdentifier.toLowerCase())throw Error(`This project declares application ${l.application.universalIdentifier}, but the export belongs to ${t.application.universalIdentifier}. Pull it into a different directory.`);return a.throwIfAborted(),{applicationExport:{...t,files:c},target:o}},le=({entities:e,unreconciledUniversalIdentifiers:t})=>e.map(e=>{if(e.kind!==`application`||!r.t(e.config)||!(0,A.isString)(e.config.defaultRoleUniversalIdentifier)||!t?.has(e.config.defaultRoleUniversalIdentifier.toLowerCase()))return e;let{defaultRoleUniversalIdentifier:n,...i}=e.config;return{...e,config:i}}),ue=({manifest:e,baseManifest:t,scannedFiles:r,unreconciledUniversalIdentifiers:i,systemPermissionFlag:o})=>{let s=new Map;for(let e of r)e.isReadable&&n.t(e.universalIdentifier)&&s.set(e.universalIdentifier.toLowerCase(),e);let{entities:c,skipped:l}=a.r({manifest:e,sourceFileByUniversalIdentifier:s,systemPermissionFlag:o});return{entities:c,baseEntities:le({entities:n.t(t)?a.r({manifest:t,sourceFileByUniversalIdentifier:s}).entities:[],unreconciledUniversalIdentifiers:i}),skipped:l}},de=({entities:e,baseEntities:t,protectedIdentifiers:r,writes:i,deletions:a,scannedFiles:o})=>{let s=new Set;j({value:t,identifiers:s});let c=new Map(o.map(e=>{let t=new Set;return j({value:e.config,identifiers:t}),[e.relativePath.split(`\\`).join(`/`),t]})),l=new Map(e.map(e=>[e.universalIdentifier.toLowerCase(),e.config])),u=new Map(t.map(e=>[e.universalIdentifier.toLowerCase(),e])),d=[...i.filter(e=>e.kind!==`translation`&&e.isRegeneration),...a.flatMap(e=>{let t=u.get(e.universalIdentifier.toLowerCase());return n.t(t)?[{...e,kind:t.kind}]:[]})],f=[],p=new Set,m=[],h;do{h=p.size;let e=new Map(c);for(let t of i){if(t.kind===`translation`||p.has(t.relativePath))continue;let n=new Set;j({value:l.get(t.universalIdentifier.toLowerCase()),identifiers:n}),e.set(t.relativePath,n)}for(let t of a)p.has(t.relativePath)||e.delete(t.relativePath);let t=new Set([...e.values()].flatMap(e=>[...e]));for(let e of d){if(p.has(e.relativePath)||e.kind===`translation`||e.kind===`dependency`||e.kind===`publicAsset`||e.kind===`source`)continue;let i=[...c.get(e.relativePath)??[]].find(e=>!t.has(e)&&(r.has(e)||!s.has(e)));if(n.t(i)){if(p.add(e.relativePath),e.kind===`workflow`){let t=new Set(c.get(e.relativePath));j({value:l.get(e.universalIdentifier.toLowerCase()),identifiers:t}),m.push({codeStepFolderPath:`${P(e.relativePath)}/`,identifiers:t})}f.push({kind:e.kind,universalIdentifier:e.universalIdentifier,reason:`preserving ${e.relativePath}, replacement would remove nested local definition ${i} without a confirmed remote deletion`})}}}while(p.size!==h);let g=({relativePath:e,universalIdentifier:t})=>p.has(e)||m.some(({codeStepFolderPath:n,identifiers:r})=>e.startsWith(n)&&r.has(t.toLowerCase()));return{writes:i.filter(e=>!g(e)),deletions:a.filter(e=>!g(e)),skipped:f}},fe=({manifest:e,baseManifest:t,unreconciledUniversalIdentifiers:i,protectedIdentifiers:a})=>{let o=e=>r.t(e)&&(0,A.isString)(e.universalIdentifier)?e.universalIdentifier.toLowerCase():void 0,s=(e,t)=>{let s=new Map(t.map(e=>[o(e),e])),l=e.filter(e=>{let t=o(e);return!n.t(t)||!i.has(t)}).map(e=>{let t=o(e),i=s.get(t);return!n.t(t)||!r.t(e)||!r.t(i)?e:c(e,i)}),u=new Set(l.map(o)),d=t.filter(e=>{let t=o(e);return n.t(t)&&!u.has(t)&&(i.has(t)||a.has(t))});return[...l,...d]},c=(e,t)=>{let n={...e};for(let r of new Set([...Object.keys(e),...Object.keys(t??{})])){let i=e[r],a=t?.[r];if(!(0,A.isArray)(i)&&!(0,A.isArray)(a))continue;let o=s((0,A.isArray)(i)?i:[],(0,A.isArray)(a)?a:[]);((0,A.isArray)(i)||o.length>0)&&(n[r]=o)}return n},l={...e,...c(e,t)};return n.t(t)&&i.has(e.application.universalIdentifier.toLowerCase())&&(l.application=t.application),l},pe=/^[0-9a-f]{64}$/,X=e=>r.t(e)&&Object.values(e).every(e=>(0,A.isString)(e)&&pe.test(e)),me=async({appPath:e,target:t,applicationUniversalIdentifier:i})=>{await y.t({appPath:e,relativePaths:[S.r]});let a=S.n(t);try{let t=JSON.parse(await(0,T.readFile)((0,E.join)(e,S.r),`utf8`));if(r.t(t)&&t.version===1)return{status:`unbound`,manifest:null};if(!r.t(t)||t.version!==2||!r.t(t.target)||!(0,A.isString)(t.target.apiUrl)||!(0,A.isString)(t.target.workspaceId)||!(0,A.isString)(t.applicationUniversalIdentifier)||!x.t(t.manifest)||t.applicationUniversalIdentifier.toLowerCase()!==t.manifest.application.universalIdentifier.toLowerCase()||n.t(t.unreconciledUniversalIdentifiers)&&(!(0,A.isArray)(t.unreconciledUniversalIdentifiers)||!t.unreconciledUniversalIdentifiers.every(e=>(0,A.isString)(e)&&o.t(e)))||n.t(t.sourceFingerprints)&&!X(t.sourceFingerprints)||n.t(t.publicAssetFingerprints)&&!X(t.publicAssetFingerprints)||n.t(t.remoteSourceFingerprints)&&!X(t.remoteSourceFingerprints)||n.t(t.dependencyFingerprints)&&!X(t.dependencyFingerprints))return{status:`unreadable`,manifest:null};let s=S.n({apiUrl:t.target.apiUrl,workspaceId:t.target.workspaceId});return s.apiUrl!==a.apiUrl||s.workspaceId!==a.workspaceId||t.applicationUniversalIdentifier.toLowerCase()!==i.toLowerCase()?{status:`other-target`,manifest:null}:{status:`used`,manifest:t.manifest,unreconciledUniversalIdentifiers:t.unreconciledUniversalIdentifiers?.filter(A.isString).map(e=>e.toLowerCase()),dependencyFingerprints:X(t.dependencyFingerprints)?t.dependencyFingerprints:void 0,publicAssetFingerprints:X(t.publicAssetFingerprints)?t.publicAssetFingerprints:void 0,remoteSourceFingerprints:X(t.remoteSourceFingerprints)?t.remoteSourceFingerprints:void 0,sourceFingerprints:X(t.sourceFingerprints)?t.sourceFingerprints:void 0}}catch(e){return{status:l.t(e,`ENOENT`)?`missing`:`unreadable`,manifest:null}}},he=({appPath:e,writes:t})=>{let r=new Set(t.flatMap(e=>e.requiredSdkExports));if(r.size===0)return;let i=(0,D.createRequire)((0,E.join)(e,`package.json`))(`twenty-sdk/define`),o=[...r].filter(e=>!n.t(i[e])).sort();if(o.length>0)throw new d.t({code:`SDK_SOURCE_UNSUPPORTED`,message:`The app's twenty-sdk cannot read the generated definitions. Missing exports: ${o.join(`, `)}.`,hint:`Upgrade the app to a compatible twenty-sdk version (${a.t} or later).`,details:{missingNames:o}})},ge=`.twenty/cli`,_e=async({appPath:e,writes:t,deletions:n})=>{let r=t.map(e=>e.relativePath);if(new Set(r).size!==r.length)throw Error(`Refusing to write: two entities resolved to the same file path`);let i=(0,E.resolve)(e);for(let t of[...r,...n.map(e=>e.relativePath)]){let n=(0,E.relative)(i,(0,E.resolve)(i,t));if(n.length===0||n===`..`||n.startsWith(`..${E.sep}`)||(0,E.isAbsolute)(n))throw Error(`Refusing to write: ${t} leaves the application directory`);let r=(0,E.join)(e,t);if(await u.i(r)&&(await(0,T.lstat)(r)).isDirectory())throw Error(`Refusing to write: ${t} is a directory, and pull never deletes a folder`)}},ve=async({appPath:e,backupDirectory:t,relativePath:n})=>{let r=(0,E.join)(e,n);if(!await u.i(r))return!1;let i=(0,E.join)(t,n);return await u.r((0,E.dirname)(i)),await u.t(r,i),!0},ye=async({appPath:e,backupDirectory:t,backedUpRelativePaths:n,writtenRelativePaths:r})=>{for(let t of r)await(0,T.rm)((0,E.join)(e,t),{force:!0});for(let r of n){let n=(0,E.join)(e,r);await u.r((0,E.dirname)(n)),await(0,T.rm)(n,{force:!0}),await u.t((0,E.join)(t,r),n)}},be=async({appPath:e,writes:t,deletions:n,finalWrite:r,signal:i})=>{let a=r?[...t,r]:t;i?.throwIfAborted(),await _e({appPath:e,writes:a,deletions:n});let o=(0,E.join)(e,ge);await u.r(o);let s=await(0,T.mkdtemp)((0,E.join)(o,`pull-staging-`)),c=await(0,T.mkdtemp)((0,E.join)(o,`pull-backup-`)),l=[],f=[];try{for(let e of a){let t=(0,E.join)(s,e.relativePath);await u.r((0,E.dirname)(t)),await(0,T.writeFile)(t,e.content,e===r?{mode:384}:void 0)}for(let t of[...a.map(e=>e.relativePath),...n.map(e=>e.relativePath)])await ve({appPath:e,backupDirectory:c,relativePath:t})&&l.push(t);i?.throwIfAborted();for(let n of t){let t=(0,E.join)(e,n.relativePath);await u.r((0,E.dirname)(t)),f.push(n.relativePath),await u.t((0,E.join)(s,n.relativePath),t)}for(let t of n)await(0,T.rm)((0,E.join)(e,t.relativePath),{force:!0});if(r){let t=(0,E.join)(e,r.relativePath);await u.r((0,E.dirname)(t)),f.push(r.relativePath),await u.t((0,E.join)(s,r.relativePath),t)}}catch(t){try{await ye({appPath:e,backupDirectory:c,backedUpRelativePaths:l,writtenRelativePaths:f.filter(e=>!l.includes(e))})}catch(e){throw await u.o(s).catch(()=>void 0),new d.t({code:`PULL_FAILED`,details:{outcome:`unknown`,backupDirectory:c},message:`Pull failed and could not restore every file it had replaced. The originals are kept in ${c}.\nOriginal failure: ${t instanceof Error?t.message:String(t)}\nRestore failure: ${e instanceof Error?e.message:String(e)}`})}throw await u.o(s),await u.o(c),i?.aborted&&Object.is(t,i.reason)?t:new d.t({code:`PULL_FAILED`,message:t instanceof Error?t.message:String(t),details:{outcome:`unchanged`}})}try{await u.o(s),await u.o(c)}catch(e){throw new d.t({code:`PULL_FAILED`,message:`Pull completed, but temporary files could not be removed: ${e instanceof Error?e.message:String(e)}`,details:{outcome:`pulled`,backupDirectory:c,stagingDirectory:s}})}},xe=[`nameSingular`,`name`,`label`,`title`],Se=e=>{let t={},i=[{value:e}];for(;i.length>0;){let e=i.pop();if(!n.t(e))break;let{value:a,parentLabel:o}=e;if(Array.isArray(a)){for(let e of[...a].reverse())i.push({value:e,parentLabel:o});continue}if(!r.t(a))continue;let s=xe.map(e=>a[e]).find(A.isNonEmptyString),c=n.t(s)&&n.t(o)?`${o}.${s}`:s??o;n.t(s)&&n.t(c)&&(0,A.isNonEmptyString)(a.universalIdentifier)&&(t[a.universalIdentifier]=c);for(let e of Object.values(a).reverse())i.push({value:e,parentLabel:c})}return t},Ce=e=>{let t=new Map;for(let n of e){let e=`${n.defaultFolder}/${n.fileBaseName}${n.fileSuffix}`,r=t.get(e)??[];r.push(n),t.set(e,r)}let r=new Map;for(let e of t.values()){if(e.length===1){r.set(e[0].universalIdentifier,e[0].fileBaseName);continue}let t=e.map(e=>n.t(e.parentName)?a.a(`${c.t(e.parentName)}-${e.fileBaseName}`):e.fileBaseName),i=new Map;for(let e of t)i.set(e,(i.get(e)??0)+1);e.forEach((e,n)=>{let o=t[n],s=i.get(o)===1;r.set(e.universalIdentifier,s?o:a.a(`${e.universalIdentifier.slice(0,8)}-${o}`))})}return r},Z=e=>e.toLowerCase(),Q=e=>e.split(`\\`).join(`/`),we=({scannedFiles:e,entityKey:t})=>{let n=new Map;for(let r of e){if(r.entityKey!==t)continue;let e=Q((0,E.dirname)(r.relativePath));n.set(e,(n.get(e)??0)+1)}return[...n.entries()].sort(([e,t],[n,r])=>r-t||e.localeCompare(n))[0]?.[0]??null},Te=({folder:e,fileBaseName:t,fileSuffix:n,universalIdentifier:r,takenRelativePaths:i})=>{let a=r.slice(0,8),o=[t,`${a}-${t}`,...Array.from({length:100},(e,n)=>`${a}-${t}-${n+2}`)];for(let t of o){let r=E.posix.join(e,`${t}${n}`);if(!i.has(Z(r)))return r}throw Error(`Could not find a free file name for ${r} in ${e}`)},Ee=({entity:e,applicationFile:t,scannedFileByUniversalIdentifier:n})=>e.kind===`application`?t:n.get(e.universalIdentifier.toLowerCase()),De=({entities:e,baseEntities:t,scannedFiles:r,workspaceUniversalIdentifiers:i,unreconciledUniversalIdentifiers:a,localCodeStepFilesByWorkflowPath:o})=>{let s=new Set(e.map(e=>e.universalIdentifier.toLowerCase())),c=new Map(t.map(e=>[e.universalIdentifier,JSON.stringify(e.config)])),l=Ce(e),u=new Map,d=r.find(e=>e.entityKey===`application`);for(let e of r)n.t(e.universalIdentifier)&&u.set(e.universalIdentifier.toLowerCase(),e);let f=[],p=[],m=new Set,h=new Set(r.map(e=>Z(Q(e.relativePath)))),g=new Set(h),_=[],v=new Set,y=e=>o?.get(e)??[];for(let t of e){let e=Ee({entity:t,applicationFile:d,scannedFileByUniversalIdentifier:u}),i=n.t(e)?Q(e.relativePath):void 0,o=we({scannedFiles:r,entityKey:x.n[t.kind]})??t.defaultFolder,b=l.get(t.universalIdentifier)??t.fileBaseName,S=i??Te({folder:o,fileBaseName:b,fileSuffix:t.fileSuffix,universalIdentifier:t.universalIdentifier,takenRelativePaths:g});m.add(S),g.add(Z(S)),v.add(Z(S));let C=c.get(t.universalIdentifier),w=new Set,T=new Set;j({value:e?.config,identifiers:w}),j({value:t.config,identifiers:T});let E=[...w].some(e=>!T.has(e)&&s.has(e));if(n.t(e)&&e.targetFunctionName===t.definer&&!E&&!a?.has(t.universalIdentifier.toLowerCase())&&n.t(C)&&C===JSON.stringify(t.config)){p.push(t);continue}let D=n.t(i)?y(i):[],O=new Map(D.map(e=>[e.universalIdentifier.toLowerCase(),Z(e.relativePath)])),{codeStepFiles:k,...A}=K({entity:t,relativePath:S,isCodeStepPathAvailable:({relativePath:e,stepUniversalIdentifier:t})=>{let n=Z(e);return!g.has(n)||!v.has(n)&&O.get(t.toLowerCase())===n}});f.push({kind:t.kind,universalIdentifier:t.universalIdentifier,relativePath:S,...A,isRegeneration:n.t(i)});for(let e of k){let n=Z(e.relativePath);f.push({kind:t.kind,...e,requiredSdkExports:[],isRegeneration:h.has(n)}),m.add(e.relativePath),g.add(n),v.add(n)}_.push(...D)}let b=[];for(let e of c.keys()){if(s.has(e.toLowerCase()))continue;let t=u.get(e.toLowerCase()),r=n.t(t)?Q(t.relativePath):void 0;!n.t(r)||m.has(r)||(b.push({universalIdentifier:e,relativePath:r}),i.has(e)||_.push(...y(r)))}let S=r.filter(e=>n.t(e.universalIdentifier)&&!s.has(e.universalIdentifier.toLowerCase())&&!c.has(e.universalIdentifier)&&!i.has(e.universalIdentifier)&&!m.has(Q(e.relativePath))).map(e=>Q(e.relativePath));return{writes:f,unchanged:p,deletions:b,codeStepFileDeletions:_.filter(e=>!m.has(e.relativePath)),localOnlyRelativePaths:S}},$=[`dependencies`,`devDependencies`,`peerDependencies`],Oe=({content:e,existingContent:t})=>{let n=JSON.parse(e),i=JSON.parse(t);if($.some(e=>{let t=n[e];return r.t(t)&&Object.hasOwn(t,`twenty-sdk`)}))return e;for(let e of $){let t=i[e];if(!r.t(t)||!(0,A.isString)(t[`twenty-sdk`]))continue;let a=n[e];return n[e]={...r.t(a)?a:{},"twenty-sdk":t[`twenty-sdk`]},`${JSON.stringify(n,null,2)}\n`}return e},ke=async({appPath:e,files:t,sourceFingerprints:r={},dependencyFingerprints:i={}})=>{let a=[],o={},s={};for(let{path:c,content:l}of t){let t=(0,E.join)(e,c),d=await u.i(t)?await(0,T.readFile)(t,`utf8`):void 0,f=S.i(l);if(o[c]=f,n.t(d)&&(i[c]??r[c])===f)continue;let p=c===`package.json`&&n.t(d)?Oe({content:l,existingContent:d}):l;if(d===p){s[c]=S.i(p);continue}a.push({kind:`dependency`,universalIdentifier:`dependencies/${c}`,relativePath:c,content:p,requiredSdkExports:[],isRegeneration:n.t(d)})}return{writes:a,fingerprints:o,unchangedSourceFingerprints:s,unchangedCount:t.length-a.length}},Ae=async({appPath:e,includeConfig:t=!1,signal:r})=>{r.throwIfAborted();let i=await h.i(e),a=[];for(let o of i){r.throwIfAborted();let i=(0,E.relative)(e,o),s;try{s=await(0,T.readFile)(o,`utf-8`)}catch{a.push({relativePath:i,entityKey:null,targetFunctionName:null,universalIdentifier:null,isReadable:!1});continue}let c=h.r({fileContent:s,filePath:o});if(!n.t(c)){a.push({relativePath:i,entityKey:null,targetFunctionName:null,universalIdentifier:null,isReadable:!0});continue}let l=h.n[c],u={},f=!0;try{u=(await h.t({appPath:e,filePath:o})).config}catch(e){if(e instanceof d.t&&e.code===`SDK_SOURCE_UNSUPPORTED`)throw e;u={},f=!1}a.push({relativePath:i,entityKey:l,targetFunctionName:c,universalIdentifier:(0,A.isString)(u.universalIdentifier)?u.universalIdentifier:null,isReadable:f,...t?{config:u}:{}})}return r.throwIfAborted(),a},je=({sourceFingerprints:e={},writes:t,deletions:n})=>{let r=new Set(n.map(e=>e.relativePath));return{...Object.fromEntries(Object.entries(e).filter(([e])=>!r.has(e))),...Object.fromEntries(t.map(e=>[e.relativePath,S.i(e.content)]))}},Me=async e=>{let{appPath:t,signal:r}=e;try{let{applicationExport:i,target:a}=await ce(e),o=m.n(i.manifest),c=await me({appPath:t,target:a,applicationUniversalIdentifier:i.application.universalIdentifier}),l=n.t(c.manifest)?m.n(c.manifest):null,u=await Ae({appPath:t,includeConfig:!0,signal:r}),d=new Set(c.unreconciledUniversalIdentifiers),{entities:f,baseEntities:h,skipped:g}=ue({manifest:o,baseManifest:l,scannedFiles:u,unreconciledUniversalIdentifiers:d,systemPermissionFlag:s.i(t)});r?.throwIfAborted();let _=new Set(i.coverage.map(e=>e.universalIdentifier)),v=await se({appPath:t,scannedFiles:u,baseEntities:h}),b=De({entities:f,baseEntities:h,scannedFiles:u,workspaceUniversalIdentifiers:_,unreconciledUniversalIdentifiers:d,localCodeStepFilesByWorkflowPath:v}),x=new Set;j({value:o,identifiers:x}),j({value:i.coverage,identifiers:x});let C=u.filter(e=>e.entityKey===`frontComponents`).map(e=>(0,E.join)(t,e.relativePath)),w=await G({appPath:t,manifest:o,baseManifest:l,frontComponentSourcePaths:C}),T=de({entities:f,baseEntities:h,protectedIdentifiers:x,writes:b.writes,deletions:[...b.deletions.filter(e=>!x.has(e.universalIdentifier.toLowerCase())),...b.codeStepFileDeletions],scannedFiles:u}),D=await ke({appPath:t,files:i.files.filter(e=>e.folder===p.r.Dependencies),sourceFingerprints:c.sourceFingerprints,dependencyFingerprints:c.dependencyFingerprints}),O=await te({appPath:t,files:i.files.filter(({folder:e})=>e===p.r.PublicAsset),sourceFingerprints:c.sourceFingerprints,publicAssetFingerprints:c.publicAssetFingerprints}),k=await ne({appPath:t,manifest:o,baseManifest:l,files:i.files,scannedFiles:u,protectedIdentifiers:x,remoteSourceFingerprints:c.remoteSourceFingerprints,sourceFingerprints:c.sourceFingerprints,reservedPaths:new Set([...T.writes,...w.writes,...D.writes,...O.writes].map(e=>e.relativePath.toLowerCase()))}),A=await ee({appPath:t,manifest:o,files:i.files,remoteSourceFingerprints:c.remoteSourceFingerprints,sourceFingerprints:c.sourceFingerprints,reservedPaths:new Set([...T.writes,...w.writes,...D.writes,...O.writes,...k.writes,...k.deletions,...T.deletions].map(e=>e.relativePath.toLowerCase()))}),M=[...T.writes,...w.writes,...D.writes,...O.writes,...k.writes,...A.writes],N=[...T.deletions,...k.deletions,...w.deletions.filter(e=>n.t(l?.translations)&&e.universalIdentifier in l.translations)],P=[...g,...T.skipped],F=new Set(P.map(e=>e.universalIdentifier.toLowerCase())),I=S.t({target:a,manifest:fe({manifest:i.manifest,baseManifest:c.manifest,unreconciledUniversalIdentifiers:F,protectedIdentifiers:x}),unreconciledUniversalIdentifiers:[...F],remoteSourceFingerprints:{...k.fingerprints,...A.fingerprints},publicAssetFingerprints:{...c.publicAssetFingerprints,...O.fingerprints},dependencyFingerprints:{...c.dependencyFingerprints,...D.fingerprints},sourceFingerprints:je({sourceFingerprints:{...c.sourceFingerprints,...D.unchangedSourceFingerprints,...O.unchangedSourceFingerprints,...k.unchangedSourceFingerprints,...A.unchangedSourceFingerprints},writes:M,deletions:N})});await y.t({appPath:t,relativePaths:[...M.map(e=>e.relativePath),...N.map(e=>e.relativePath),I.relativePath]});let L=await ie({appPath:t,baseManifest:l,writes:M,deletions:N,frontComponentSourcePaths:C,baseEntities:h,localCodeStepFilesByWorkflowPath:v,sourceFingerprints:c.sourceFingerprints}),R=Se(o);return he({appPath:t,writes:M}),r?.throwIfAborted(),await be({appPath:t,writes:M,deletions:N,finalWrite:I,signal:r}),{success:!0,data:{application:{universalIdentifier:i.application.universalIdentifier,displayName:i.application.displayName},base:{status:c.status},writes:M.map(({content:e,requiredSdkExports:t,...n})=>n),deletions:N,overwrittenLocalChanges:L,unchangedCount:b.unchanged.length+D.unchangedCount+O.unchangedCount+k.unchangedCount+A.unchangedCount,localOnlyRelativePaths:b.localOnlyRelativePaths,unreadableRelativePaths:u.filter(e=>!e.isReadable).map(e=>e.relativePath),skipped:P,compiledTranslationEntryCountByLocale:w.compiledEntryCountByLocale,entityLabelByUniversalIdentifier:R},diagnostics:[]}}catch(e){return{success:!1,error:{code:r?.aborted&&Object.is(e,r.reason)?`CANCELLED`:e instanceof d.t?e.code:`PULL_FAILED`,message:e instanceof Error?e.message:String(e),...f.t(e),details:{outcome:`unchanged`,...e instanceof d.t?e.details:{}}},diagnostics:[]}}},Ne=async e=>{try{let t=e.applicationExport,n=r.t(t)&&r.t(t.application)&&(0,A.isString)(t.application.universalIdentifier)?t.application.universalIdentifier:``;return await Me({...e,applicationExport:m.t({value:t,universalIdentifier:n})})}finally{await(0,O.stop)()}};exports.pullSource=Ne;
1
+ const e=require("./rolldown-runtime-mLOUI7ql.cjs"),t=require("./build--4zYt4wd.cjs"),n=require("./isDefined-CJctgvfE.cjs"),r=require("./isPlainObject-fJEJm71P.cjs"),i=require("./is-supported-locale-DUMI9QQ2.cjs"),a=require("./isValidUniversalIdentifier-DymFerYs.cjs"),o=require("./pull-minimum-sdk-version.constant-C6NC1Jf_.cjs"),s=require("./locale-catalog-format-BD4XDEnl.cjs"),c=require("./kebab-case-tmo--p0I.cjs"),l=require("./has-error-code-DsJeqbZq.cjs"),u=require("./fs-utils-BcNux7fF.cjs"),d=require("./cli-error-CrUD8uMp.cjs"),f=require("./get-tooling-error-context-CZKTM7Q6.cjs"),p=require("./isRestorableApplicationSourcePath-Du_zM55R.cjs"),m=require("./parse-app-export-B9Ocghe1.cjs"),h=require("./extract-manifest-from-file-KLaAvTnC.cjs"),g=require("./code-step-file-suffix.constant-B6vqrfcU.cjs"),_=require("./collect-translatable-strings-AWv41yIv.cjs"),v=require("./constants-Cf5-CwMu.cjs"),y=require("./assert-pull-paths-TFGZvzZO.cjs"),b=require("./is-locale-catalog-T4W5NhnW.cjs"),x=require("./is-exported-manifest-BHA_mGa6.cjs"),S=require("./create-pull-base-write-CX8xZhMz.cjs"),C=require("./print-typescript-value-BjYn0ZFT.cjs"),w=require("./read-application-identity-CxmrWgYf.cjs");let T=require("node:fs/promises"),E=require("node:path"),D=require("node:module"),O=require("esbuild"),k=require("typescript");k=e.r(k);var A=t.t(),ee=async({appPath:e,manifest:t,files:r,reservedPaths:i,remoteSourceFingerprints:a={},sourceFingerprints:o={}})=>{let s=new Set(m.i(t).map(e=>e.sourcePath)),c=[],l={},f={},h=0;for(let t of r.filter(e=>e.folder===p.r.Source&&!s.has(e.path))){let r=Buffer.from(t.content,t.encoding===`base64`?`base64`:`utf8`),s=S.i(r),p=await u.i((0,E.join)(e,t.path))?await(0,T.readFile)((0,E.join)(e,t.path)):void 0;if(i.has(t.path.toLowerCase())||n.t(p)&&!p.equals(r)&&!n.t(a[t.path]??o[t.path])&&t.path!==`tsconfig.json`)throw new d.t({code:`CONFLICT`,message:`Cannot restore source ${t.path}: it is occupied by another local file or definition. No local files were changed.`});if(l[t.path]=s,p?.equals(r)){f[t.path]=s,h++;continue}if(n.t(p)&&(a[t.path]??o[t.path])===s){h++;continue}c.push({kind:`source`,universalIdentifier:`source/${t.path}`,relativePath:t.path,content:r,requiredSdkExports:[],isRegeneration:n.t(p)})}return{writes:c,fingerprints:l,unchangedSourceFingerprints:f,unchangedCount:h}},te=async({appPath:e,files:t,sourceFingerprints:r={},publicAssetFingerprints:i={}})=>{await y.t({appPath:e,relativePaths:t.map(({path:e})=>e)});let a=[],o={},s={};for(let{path:c,content:l}of t){let t=Buffer.from(l,`base64`),d=S.i(t);o[c]=d;let f=(0,E.join)(e,c),p=await u.i(f)?await(0,T.readFile)(f):void 0;if(!(n.t(p)&&(i[c]??r[c])===d)){if(p?.equals(t)){s[c]=d;continue}a.push({kind:`publicAsset`,universalIdentifier:`public-asset/${c}`,relativePath:c,content:t,requiredSdkExports:[],isRegeneration:n.t(p)})}}return{writes:a,fingerprints:o,unchangedSourceFingerprints:s,unchangedCount:t.length-a.length}},ne=async({appPath:e,manifest:t,baseManifest:r,files:i,scannedFiles:a,protectedIdentifiers:o,reservedPaths:s,remoteSourceFingerprints:c={},sourceFingerprints:l={}})=>{let f=[],h=[],g=0,_={},v={},y=new Set(s),b=m.i(t),x=m.i(r);for(let t of b){let{sourcePath:r}=t,{universalIdentifier:o}=t.definition,s=i.find(e=>e.folder===p.r.Source&&e.path===r),m=a.find(e=>e.entityKey===t.entityKey&&e.universalIdentifier?.toLowerCase()===o.toLowerCase());if(n.t(t.sourceFiles)&&n.t(m)&&m.relativePath.split(`\\`).join(`/`)!==r)throw new d.t({code:`CONFLICT`,message:`${t.label} ${o} moved locally. Restore it to ${r} before pulling its imported files.`});let h=(m?.relativePath??r).split(`\\`).join(`/`),b=h.toLowerCase(),C=await u.i((0,E.join)(e,h))?await(0,T.readFile)((0,E.join)(e,h),`utf8`):void 0;if(!n.t(s)||y.has(b)||n.t(C)&&!n.t(m))throw new d.t({code:`CONFLICT`,message:n.t(s)?`Cannot restore ${t.label.toLowerCase()} ${o}: ${h} is occupied by another local file or definition. No local files were changed.`:`Source for ${t.label.toLowerCase()} ${o} was not exported. No local files were changed.`});y.add(b);let w=Buffer.from(s.content,s.encoding===`base64`?`base64`:`utf8`).toString(`utf8`),D=S.i(w);_[r]=D,C===w&&(v[h]=D);let O=x.find(e=>e.definition.universalIdentifier.toLowerCase()===o.toLowerCase()),k=(n.t(O)?c[O.sourcePath]:void 0)??l[h];if(C===w||n.t(C)&&n.t(O)&&(n.t(k)?k===D:JSON.stringify(O.definition)===JSON.stringify(t.definition))){g++;continue}f.push({kind:t.kind,universalIdentifier:o,relativePath:h,content:w,requiredSdkExports:t.requiredSdkExports,isRegeneration:n.t(C)})}for(let e of x){if(o.has(e.definition.universalIdentifier.toLowerCase())){let t=c[e.sourcePath];if(!n.t(t)||b.some(t=>t.definition.universalIdentifier.toLowerCase()===e.definition.universalIdentifier.toLowerCase()))continue;_[e.sourcePath]=t;continue}let t=a.find(t=>t.entityKey===e.entityKey&&t.universalIdentifier?.toLowerCase()===e.definition.universalIdentifier.toLowerCase())?.relativePath.split(`\\`).join(`/`);n.t(t)&&!y.has(t.toLowerCase())&&h.push({universalIdentifier:e.definition.universalIdentifier,relativePath:t})}return{writes:f,deletions:h,unchangedCount:g,fingerprints:_,unchangedSourceFingerprints:v}},j=({value:e,identifiers:t})=>{(0,A.isArray)(e)?e.forEach(e=>j({value:e,identifiers:t})):r.t(e)&&((0,A.isString)(e.universalIdentifier)&&t.add(e.universalIdentifier.toLowerCase()),Object.values(e).forEach(e=>j({value:e,identifiers:t})))},M=[`import { readFileSync } from 'node:fs';`,`import { join } from 'node:path';`],N=e=>E.posix.basename(e).replace(/(\.workflow)?\.tsx?$/,``),P=e=>E.posix.join(E.posix.dirname(e),N(e)),F=({folderPath:e,fileBaseName:t,universalIdentifier:r,localFileName:i,takenFileNames:a,isCodeStepPathAvailable:o})=>{let s=r.slice(0,8),c=t=>!a.has(t)&&o({relativePath:E.posix.join(e,t),stepUniversalIdentifier:r}),l=[`${t}${g.t}`,`${s}-${t}${g.t}`],u=`${s}-${t}-`,d=e=>l.includes(e)||e.startsWith(u)&&e.endsWith(`.code.ts`)&&/^([2-9]|[1-9]\d+)$/.test(e.slice(u.length,-8)),f=e=>(a.add(e),e);if(n.t(i)&&d(i)&&c(i))return f(i);let[p]=l;c(p)||(p=l[1]);for(let e=2;!c(p);e++)p=`${u}${e}${g.t}`;return f(p)},I=({config:e,workflowRelativePath:t,isCodeStepPathAvailable:i=()=>!0,localCodeStepPathByStepIdentifier:a})=>{if(!r.t(e)||!r.t(e.version)||!Array.isArray(e.version.steps))return{config:e,importStatements:[],codeStepFiles:[]};let s=N(t),c=P(t),l=new Set,u=[],d=e.version.steps.map(e=>{if(!r.t(e)||e.type!==`CODE`||!(0,A.isString)(e.universalIdentifier)||!r.t(e.input)||!(0,A.isString)(e.input.code))return e;let t=a?.get(e.universalIdentifier.toLowerCase()),d=F({folderPath:c,fileBaseName:o.o({segments:[(0,A.isString)(e.name)?e.name:null],universalIdentifier:e.universalIdentifier}),universalIdentifier:e.universalIdentifier,localFileName:n.t(t)&&E.posix.dirname(t)===c?E.posix.basename(t):void 0,takenFileNames:l,isCodeStepPathAvailable:i});return u.push({universalIdentifier:e.universalIdentifier,relativePath:E.posix.join(c,d),content:e.input.code}),{...e,input:{...e.input,code:C.r(`readFileSync(join(__dirname, ${C.t(s)}, ${C.t(d)}), 'utf8')`)}}});return u.length===0?{config:e,importStatements:[],codeStepFiles:u}:{config:{...e,version:{...e.version,steps:d}},importStatements:M,codeStepFiles:u}},L=async({manifest:e,frontComponentSourcePaths:t})=>{let r=[..._.t(e),...await _.n(t)],a=new Map(r.map(e=>[s.r(e.message,e.context),e]));return Object.entries(e.translations??{}).filter(e=>i.t(e[0])&&b.t(e[1])).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>{let r=[],i={};for(let[e,o]of Object.entries(t)){let t=a.get(e);n.t(t)?r.push({message:t.message,context:t.context,translation:o}):i[e]=o}return{locale:e,authored:s.t(r),compiled:i}})},R=e=>n.t(e)&&typeof e==`object`&&!Array.isArray(e),z=e=>`${JSON.stringify(e,null,2)}\n`,B=e=>{if(!n.t(e))return{};try{let t=JSON.parse(e);return n.t(t)&&typeof t==`object`?t:{}}catch{return{}}},V=({message:e,context:t})=>JSON.stringify([t??null,e]),re=({catalog:e,existingAuthoredContent:t,existingCompiledContent:n})=>{let r=new Set(s.n(e.authored).map(e=>s.r(e.message,e.context))),i=new Set(Object.keys(B(n)).filter(t=>!(t in e.compiled)&&r.has(t)));if(i.size===0)return null;let a=s.n(B(t)),o=new Set(a.map(V)),c=s.n(e.authored).filter(e=>i.has(s.r(e.message,e.context))&&!o.has(V(e)));return s.t([...a,...c])},H=e=>`${v.n}/${e}.json`,U=e=>`${v.t}/${e}.json`,W=async e=>await u.i(e)?await(0,T.readFile)(e,`utf8`):null,G=async({appPath:e,manifest:t,baseManifest:r,frontComponentSourcePaths:a})=>{let o=[],s=[],c={},l=t.translations;if(!R(l))return{writes:o,deletions:s,compiledEntryCountByLocale:c};let d=await L({manifest:t,frontComponentSourcePaths:a}),f=new Set(Object.keys(l)),p=R(r?.translations)?r.translations:{},m=l;for(let t of d){let{locale:r,authored:i,compiled:a}=t,l=Object.keys(a).length;l>0&&(c[r]=l);let u=H(r),d=U(r),f=await W((0,E.join)(e,u)),h=await W((0,E.join)(e,d)),g=r in p&&JSON.stringify(p[r])===JSON.stringify(m[r]),_=(Object.keys(i).length===0||n.t(f))&&(l===0||n.t(h)),v=g&&_?re({catalog:t,existingAuthoredContent:f,existingCompiledContent:h}):null;if(g&&_&&!n.t(v))continue;let y=[{relativePath:u,content:z(v??i),isWanted:Object.keys(v??i).length>0,existingContent:f},{relativePath:d,content:z(a),isWanted:l>0,existingContent:h}];for(let{relativePath:e,content:t,isWanted:i,existingContent:a}of y){let c=n.t(a);if(!i){c&&e===d&&s.push({universalIdentifier:r,relativePath:e});continue}a!==t&&o.push({kind:`translation`,requiredSdkExports:[],universalIdentifier:r,relativePath:e,content:t,isRegeneration:c})}}for(let[t,n]of Object.entries(p))if(!(f.has(t)||!i.t(t)||!b.t(n)))for(let n of[H(t),U(t)])await u.i((0,E.join)(e,n))&&s.push({universalIdentifier:t,relativePath:n});return{writes:o,deletions:s,compiledEntryCountByLocale:c}},K=({entity:e,relativePath:t,isCodeStepPathAvailable:n,localCodeStepPathByStepIdentifier:r})=>{if(e.kind!==`workflow`)return{...o.i({definer:e.definer,config:e.config,enumBindings:e.enumBindings}),codeStepFiles:[]};let{config:i,importStatements:a,codeStepFiles:s}=I({config:e.config,workflowRelativePath:t,isCodeStepPathAvailable:n,localCodeStepPathByStepIdentifier:r});return{...o.i({definer:e.definer,config:i,enumBindings:e.enumBindings,importStatements:a}),codeStepFiles:s}},ie=async({appPath:e,baseManifest:t,writes:r,deletions:i,frontComponentSourcePaths:a,sourceFingerprints:s,baseEntities:c,localCodeStepFilesByWorkflowPath:l})=>{if(!n.t(t))return[];let u=new Map(c.map(e=>[e.universalIdentifier,e])),d=await G({appPath:e,manifest:t,baseManifest:null,frontComponentSourcePaths:a}),f=new Map(d.writes.map(e=>[e.relativePath,e.content])),p=new Set(d.deletions.map(({relativePath:e})=>e)),m=new Map(c.flatMap(e=>e.kind===`workflow`?I({config:e.config,workflowRelativePath:``}).codeStepFiles.map(({universalIdentifier:e,content:t})=>[e.toLowerCase(),t]):[])),h=[...l.values()].flat(),g=new Map(h.map(({universalIdentifier:e,relativePath:t})=>[e.toLowerCase(),t])),_=new Map(h.flatMap(({universalIdentifier:e,relativePath:t})=>{let r=m.get(e.toLowerCase());return n.t(r)?[[t,r]]:[]})),v=({universalIdentifier:e,relativePath:t})=>{let r=u.get(e);if(n.t(r))return[K({entity:r,relativePath:t,localCodeStepPathByStepIdentifier:g}).content,o.i({definer:r.definer,config:r.config,enumBindings:r.enumBindings}).content];let i=_.get(t)??f.get(t);return n.t(i)?[i]:[]},y=[];for(let{universalIdentifier:t,relativePath:a}of[...r.filter(e=>e.isRegeneration),...i]){let r=s?.[a];if(n.t(r)){S.i(await(0,T.readFile)((0,E.join)(e,a)))!==r&&y.push({universalIdentifier:t,relativePath:a});continue}let i=v({universalIdentifier:t,relativePath:a});(p.has(a)||i.length>0&&!i.includes(await(0,T.readFile)((0,E.join)(e,a),`utf8`)))&&y.push({universalIdentifier:t,relativePath:a})}return y},q=e=>e.split(`\\`).join(`/`),J=({node:e,name:t})=>n.t(e)&&k.isIdentifier(e)&&e.text===t,Y=({objectLiteral:e,propertyName:t})=>e.properties.find(e=>k.isPropertyAssignment(e)&&!k.isComputedPropertyName(e.name)&&e.name.text===t)?.initializer,ae=e=>{if(!n.t(e)||!k.isCallExpression(e)||!J({node:e.expression,name:`readFileSync`}))return;let[t]=e.arguments;if(!n.t(t)||!k.isCallExpression(t)||!J({node:t.expression,name:`join`}))return;let[r,...i]=t.arguments;return J({node:r,name:`__dirname`})&&i.every(k.isStringLiteralLike)?i.map(e=>e.text):void 0},oe=({workflowPath:e,source:t})=>{let r=new Map,i=t=>{if(k.isObjectLiteralExpression(t)){let i=Y({objectLiteral:t,propertyName:`universalIdentifier`}),a=Y({objectLiteral:t,propertyName:`input`}),o=n.t(a)&&k.isObjectLiteralExpression(a)?ae(Y({objectLiteral:a,propertyName:`code`})):void 0;n.t(i)&&k.isStringLiteralLike(i)&&n.t(o)&&r.set(i.text.toLowerCase(),E.posix.join(E.posix.dirname(e),...o))}k.forEachChild(t,i)};return i(k.createSourceFile(e,t,k.ScriptTarget.Latest,!1)),r},se=async({appPath:e,scannedFiles:t,baseEntities:r})=>{let i=new Set(t.filter(e=>e.isReadable).map(e=>q(e.relativePath))),a=new Map(r.filter(e=>e.kind===`workflow`).map(e=>[e.universalIdentifier.toLowerCase(),e.config])),o=new Map;for(let r of t){if(r.entityKey!==`workflows`)continue;let t=q(r.relativePath),s=`${P(t)}/`,c=new Map,l=new Set,u=e=>e.startsWith(s)&&e.endsWith(`.code.ts`)&&i.has(e)&&!l.has(e),d=({stepIdentifier:e,relativePath:t})=>{c.set(e,t),l.add(t)};for(let[n,r]of oe({workflowPath:t,source:await(0,T.readFile)((0,E.join)(e,t),`utf8`)}))u(r)&&d({stepIdentifier:n,relativePath:r});let f=I({config:n.t(r.universalIdentifier)?a.get(r.universalIdentifier.toLowerCase()):void 0,workflowRelativePath:t,localCodeStepPathByStepIdentifier:c}).codeStepFiles;for(let{universalIdentifier:t,relativePath:n,content:r}of f){let i=t.toLowerCase();!c.has(i)&&u(n)&&await(0,T.readFile)((0,E.join)(e,n),`utf8`)===r&&d({stepIdentifier:i,relativePath:n})}o.set(t,[...c].map(([e,t])=>({universalIdentifier:e,relativePath:t})))}return o},ce=async({appPath:e,applicationExport:t,target:i,signal:a})=>{a.throwIfAborted();let o=S.n(i),s=m.n(t.manifest),c=m.r({value:t.files,logicFunctions:s.logicFunctions??[],frontComponents:s.frontComponents??[]});if(await y.t({appPath:e,relativePaths:[S.r,...c.map(e=>e.path)]}),!r.t(JSON.parse(await(0,T.readFile)((0,E.join)(e,`package.json`),`utf8`))))throw Error(`Pull requires a project with a package.json object.`);let l=await w.t({appPath:e,signal:a});if(n.t(l.application)&&l.application.universalIdentifier.toLowerCase()!==t.application.universalIdentifier.toLowerCase())throw Error(`This project declares application ${l.application.universalIdentifier}, but the export belongs to ${t.application.universalIdentifier}. Pull it into a different directory.`);return a.throwIfAborted(),{applicationExport:{...t,files:c},target:o}},le=({entities:e,unreconciledUniversalIdentifiers:t})=>e.map(e=>{if(e.kind!==`application`||!r.t(e.config)||!(0,A.isString)(e.config.defaultRoleUniversalIdentifier)||!t?.has(e.config.defaultRoleUniversalIdentifier.toLowerCase()))return e;let{defaultRoleUniversalIdentifier:n,...i}=e.config;return{...e,config:i}}),ue=({manifest:e,baseManifest:t,scannedFiles:r,unreconciledUniversalIdentifiers:i,systemPermissionFlag:a})=>{let s=new Map;for(let e of r)e.isReadable&&n.t(e.universalIdentifier)&&s.set(e.universalIdentifier.toLowerCase(),e);let{entities:c,skipped:l}=o.r({manifest:e,sourceFileByUniversalIdentifier:s,systemPermissionFlag:a});return{entities:c,baseEntities:le({entities:n.t(t)?o.r({manifest:t,sourceFileByUniversalIdentifier:s}).entities:[],unreconciledUniversalIdentifiers:i}),skipped:l}},de=({entities:e,baseEntities:t,protectedIdentifiers:r,writes:i,deletions:a,scannedFiles:o})=>{let s=new Set;j({value:t,identifiers:s});let c=new Map(o.map(e=>{let t=new Set;return j({value:e.config,identifiers:t}),[e.relativePath.split(`\\`).join(`/`),t]})),l=new Map(e.map(e=>[e.universalIdentifier.toLowerCase(),e.config])),u=new Map(t.map(e=>[e.universalIdentifier.toLowerCase(),e])),d=[...i.filter(e=>e.kind!==`translation`&&e.isRegeneration),...a.flatMap(e=>{let t=u.get(e.universalIdentifier.toLowerCase());return n.t(t)?[{...e,kind:t.kind}]:[]})],f=[],p=new Set,m=[],h;do{h=p.size;let e=new Map(c);for(let t of i){if(t.kind===`translation`||p.has(t.relativePath))continue;let n=new Set;j({value:l.get(t.universalIdentifier.toLowerCase()),identifiers:n}),e.set(t.relativePath,n)}for(let t of a)p.has(t.relativePath)||e.delete(t.relativePath);let t=new Set([...e.values()].flatMap(e=>[...e]));for(let e of d){if(p.has(e.relativePath)||e.kind===`translation`||e.kind===`dependency`||e.kind===`publicAsset`||e.kind===`source`)continue;let i=[...c.get(e.relativePath)??[]].find(e=>!t.has(e)&&(r.has(e)||!s.has(e)));if(n.t(i)){if(p.add(e.relativePath),e.kind===`workflow`){let t=new Set(c.get(e.relativePath));j({value:l.get(e.universalIdentifier.toLowerCase()),identifiers:t}),m.push({codeStepFolderPath:`${P(e.relativePath)}/`,identifiers:t})}f.push({kind:e.kind,universalIdentifier:e.universalIdentifier,reason:`preserving ${e.relativePath}, replacement would remove nested local definition ${i} without a confirmed remote deletion`})}}}while(p.size!==h);let g=({relativePath:e,universalIdentifier:t})=>p.has(e)||m.some(({codeStepFolderPath:n,identifiers:r})=>e.startsWith(n)&&r.has(t.toLowerCase()));return{writes:i.filter(e=>!g(e)),deletions:a.filter(e=>!g(e)),skipped:f}},fe=({manifest:e,baseManifest:t,unreconciledUniversalIdentifiers:i,protectedIdentifiers:a})=>{let o=e=>r.t(e)&&(0,A.isString)(e.universalIdentifier)?e.universalIdentifier.toLowerCase():void 0,s=(e,t)=>{let s=new Map(t.map(e=>[o(e),e])),l=e.filter(e=>{let t=o(e);return!n.t(t)||!i.has(t)}).map(e=>{let t=o(e),i=s.get(t);return!n.t(t)||!r.t(e)||!r.t(i)?e:c(e,i)}),u=new Set(l.map(o)),d=t.filter(e=>{let t=o(e);return n.t(t)&&!u.has(t)&&(i.has(t)||a.has(t))});return[...l,...d]},c=(e,t)=>{let n={...e};for(let r of new Set([...Object.keys(e),...Object.keys(t??{})])){let i=e[r],a=t?.[r];if(!(0,A.isArray)(i)&&!(0,A.isArray)(a))continue;let o=s((0,A.isArray)(i)?i:[],(0,A.isArray)(a)?a:[]);((0,A.isArray)(i)||o.length>0)&&(n[r]=o)}return n},l={...e,...c(e,t)};return n.t(t)&&i.has(e.application.universalIdentifier.toLowerCase())&&(l.application=t.application),l},pe=/^[0-9a-f]{64}$/,X=e=>r.t(e)&&Object.values(e).every(e=>(0,A.isString)(e)&&pe.test(e)),me=async({appPath:e,target:t,applicationUniversalIdentifier:i})=>{await y.t({appPath:e,relativePaths:[S.r]});let o=S.n(t);try{let t=JSON.parse(await(0,T.readFile)((0,E.join)(e,S.r),`utf8`));if(r.t(t)&&t.version===1)return{status:`unbound`,manifest:null};if(!r.t(t)||t.version!==2||!r.t(t.target)||!(0,A.isString)(t.target.apiUrl)||!(0,A.isString)(t.target.workspaceId)||!(0,A.isString)(t.applicationUniversalIdentifier)||!x.t(t.manifest)||t.applicationUniversalIdentifier.toLowerCase()!==t.manifest.application.universalIdentifier.toLowerCase()||n.t(t.unreconciledUniversalIdentifiers)&&(!(0,A.isArray)(t.unreconciledUniversalIdentifiers)||!t.unreconciledUniversalIdentifiers.every(e=>(0,A.isString)(e)&&a.t(e)))||n.t(t.sourceFingerprints)&&!X(t.sourceFingerprints)||n.t(t.publicAssetFingerprints)&&!X(t.publicAssetFingerprints)||n.t(t.remoteSourceFingerprints)&&!X(t.remoteSourceFingerprints)||n.t(t.dependencyFingerprints)&&!X(t.dependencyFingerprints))return{status:`unreadable`,manifest:null};let s=S.n({apiUrl:t.target.apiUrl,workspaceId:t.target.workspaceId});return s.apiUrl!==o.apiUrl||s.workspaceId!==o.workspaceId||t.applicationUniversalIdentifier.toLowerCase()!==i.toLowerCase()?{status:`other-target`,manifest:null}:{status:`used`,manifest:t.manifest,unreconciledUniversalIdentifiers:t.unreconciledUniversalIdentifiers?.filter(A.isString).map(e=>e.toLowerCase()),dependencyFingerprints:X(t.dependencyFingerprints)?t.dependencyFingerprints:void 0,publicAssetFingerprints:X(t.publicAssetFingerprints)?t.publicAssetFingerprints:void 0,remoteSourceFingerprints:X(t.remoteSourceFingerprints)?t.remoteSourceFingerprints:void 0,sourceFingerprints:X(t.sourceFingerprints)?t.sourceFingerprints:void 0}}catch(e){return{status:l.t(e,`ENOENT`)?`missing`:`unreadable`,manifest:null}}},he=({appPath:e,writes:t})=>{let r=new Set(t.flatMap(e=>e.requiredSdkExports));if(r.size===0)return;let i=(0,D.createRequire)((0,E.join)(e,`package.json`))(`twenty-sdk/define`),a=[...r].filter(e=>!n.t(i[e])).sort();if(a.length>0)throw new d.t({code:`SDK_SOURCE_UNSUPPORTED`,message:`The app's twenty-sdk cannot read the generated definitions. Missing exports: ${a.join(`, `)}.`,hint:`Upgrade the app to a compatible twenty-sdk version (${o.t} or later).`,details:{missingNames:a}})},ge=`.twenty/cli`,_e=async({appPath:e,writes:t,deletions:n})=>{let r=t.map(e=>e.relativePath);if(new Set(r).size!==r.length)throw Error(`Refusing to write: two entities resolved to the same file path`);let i=(0,E.resolve)(e);for(let t of[...r,...n.map(e=>e.relativePath)]){let n=(0,E.relative)(i,(0,E.resolve)(i,t));if(n.length===0||n===`..`||n.startsWith(`..${E.sep}`)||(0,E.isAbsolute)(n))throw Error(`Refusing to write: ${t} leaves the application directory`);let r=(0,E.join)(e,t);if(await u.i(r)&&(await(0,T.lstat)(r)).isDirectory())throw Error(`Refusing to write: ${t} is a directory, and pull never deletes a folder`)}},ve=async({appPath:e,backupDirectory:t,relativePath:n})=>{let r=(0,E.join)(e,n);if(!await u.i(r))return!1;let i=(0,E.join)(t,n);return await u.r((0,E.dirname)(i)),await u.t(r,i),!0},ye=async({appPath:e,backupDirectory:t,backedUpRelativePaths:n,writtenRelativePaths:r})=>{for(let t of r)await(0,T.rm)((0,E.join)(e,t),{force:!0});for(let r of n){let n=(0,E.join)(e,r);await u.r((0,E.dirname)(n)),await(0,T.rm)(n,{force:!0}),await u.t((0,E.join)(t,r),n)}},be=async({appPath:e,writes:t,deletions:n,finalWrite:r,signal:i})=>{let a=r?[...t,r]:t;i?.throwIfAborted(),await _e({appPath:e,writes:a,deletions:n});let o=(0,E.join)(e,ge);await u.r(o);let s=await(0,T.mkdtemp)((0,E.join)(o,`pull-staging-`)),c=await(0,T.mkdtemp)((0,E.join)(o,`pull-backup-`)),l=[],f=[];try{for(let e of a){let t=(0,E.join)(s,e.relativePath);await u.r((0,E.dirname)(t)),await(0,T.writeFile)(t,e.content,e===r?{mode:384}:void 0)}for(let t of[...a.map(e=>e.relativePath),...n.map(e=>e.relativePath)])await ve({appPath:e,backupDirectory:c,relativePath:t})&&l.push(t);i?.throwIfAborted();for(let n of t){let t=(0,E.join)(e,n.relativePath);await u.r((0,E.dirname)(t)),f.push(n.relativePath),await u.t((0,E.join)(s,n.relativePath),t)}for(let t of n)await(0,T.rm)((0,E.join)(e,t.relativePath),{force:!0});if(r){let t=(0,E.join)(e,r.relativePath);await u.r((0,E.dirname)(t)),f.push(r.relativePath),await u.t((0,E.join)(s,r.relativePath),t)}}catch(t){try{await ye({appPath:e,backupDirectory:c,backedUpRelativePaths:l,writtenRelativePaths:f.filter(e=>!l.includes(e))})}catch(e){throw await u.o(s).catch(()=>void 0),new d.t({code:`PULL_FAILED`,details:{outcome:`unknown`,backupDirectory:c},message:`Pull failed and could not restore every file it had replaced. The originals are kept in ${c}.\nOriginal failure: ${t instanceof Error?t.message:String(t)}\nRestore failure: ${e instanceof Error?e.message:String(e)}`})}throw await u.o(s),await u.o(c),i?.aborted&&Object.is(t,i.reason)?t:new d.t({code:`PULL_FAILED`,message:t instanceof Error?t.message:String(t),details:{outcome:`unchanged`}})}try{await u.o(s),await u.o(c)}catch(e){throw new d.t({code:`PULL_FAILED`,message:`Pull completed, but temporary files could not be removed: ${e instanceof Error?e.message:String(e)}`,details:{outcome:`pulled`,backupDirectory:c,stagingDirectory:s}})}},xe=[`nameSingular`,`name`,`label`,`title`],Se=e=>{let t={},i=[{value:e}];for(;i.length>0;){let e=i.pop();if(!n.t(e))break;let{value:a,parentLabel:o}=e;if(Array.isArray(a)){for(let e of[...a].reverse())i.push({value:e,parentLabel:o});continue}if(!r.t(a))continue;let s=xe.map(e=>a[e]).find(A.isNonEmptyString),c=n.t(s)&&n.t(o)?`${o}.${s}`:s??o;n.t(s)&&n.t(c)&&(0,A.isNonEmptyString)(a.universalIdentifier)&&(t[a.universalIdentifier]=c);for(let e of Object.values(a).reverse())i.push({value:e,parentLabel:c})}return t},Ce=e=>{let t=new Map;for(let n of e){let e=`${n.defaultFolder}/${n.fileBaseName}${n.fileSuffix}`,r=t.get(e)??[];r.push(n),t.set(e,r)}let r=new Map;for(let e of t.values()){if(e.length===1){r.set(e[0].universalIdentifier,e[0].fileBaseName);continue}let t=e.map(e=>n.t(e.parentName)?o.a(`${c.t(e.parentName)}-${e.fileBaseName}`):e.fileBaseName),i=new Map;for(let e of t)i.set(e,(i.get(e)??0)+1);e.forEach((e,n)=>{let a=t[n],s=i.get(a)===1;r.set(e.universalIdentifier,s?a:o.a(`${e.universalIdentifier.slice(0,8)}-${a}`))})}return r},Z=e=>e.toLowerCase(),Q=e=>e.split(`\\`).join(`/`),we=({scannedFiles:e,entityKey:t})=>{let n=new Map;for(let r of e){if(r.entityKey!==t)continue;let e=Q((0,E.dirname)(r.relativePath));n.set(e,(n.get(e)??0)+1)}return[...n.entries()].sort(([e,t],[n,r])=>r-t||e.localeCompare(n))[0]?.[0]??null},Te=({folder:e,fileBaseName:t,fileSuffix:n,universalIdentifier:r,takenRelativePaths:i})=>{let a=r.slice(0,8),o=[t,`${a}-${t}`,...Array.from({length:100},(e,n)=>`${a}-${t}-${n+2}`)];for(let t of o){let r=E.posix.join(e,`${t}${n}`);if(!i.has(Z(r)))return r}throw Error(`Could not find a free file name for ${r} in ${e}`)},Ee=({entity:e,applicationFile:t,scannedFileByUniversalIdentifier:n})=>e.kind===`application`?t:n.get(e.universalIdentifier.toLowerCase()),De=({entities:e,baseEntities:t,scannedFiles:r,workspaceUniversalIdentifiers:i,unreconciledUniversalIdentifiers:a,localCodeStepFilesByWorkflowPath:o})=>{let s=new Set(e.map(e=>e.universalIdentifier.toLowerCase())),c=new Map(t.map(e=>[e.universalIdentifier,JSON.stringify(e.config)])),l=Ce(e),u=new Map,d=r.find(e=>e.entityKey===`application`);for(let e of r)n.t(e.universalIdentifier)&&u.set(e.universalIdentifier.toLowerCase(),e);let f=[],p=[],m=new Set,h=new Set(r.map(e=>Z(Q(e.relativePath)))),g=new Set(h),_=[],v=new Set,y=e=>o?.get(e)??[];for(let t of e){let e=Ee({entity:t,applicationFile:d,scannedFileByUniversalIdentifier:u}),i=n.t(e)?Q(e.relativePath):void 0,o=we({scannedFiles:r,entityKey:x.n[t.kind]})??t.defaultFolder,b=l.get(t.universalIdentifier)??t.fileBaseName,S=i??Te({folder:o,fileBaseName:b,fileSuffix:t.fileSuffix,universalIdentifier:t.universalIdentifier,takenRelativePaths:g});m.add(S),g.add(Z(S)),v.add(Z(S));let C=c.get(t.universalIdentifier),w=new Set,T=new Set;j({value:e?.config,identifiers:w}),j({value:t.config,identifiers:T});let E=[...w].some(e=>!T.has(e)&&s.has(e));if(n.t(e)&&e.targetFunctionName===t.definer&&!E&&!a?.has(t.universalIdentifier.toLowerCase())&&n.t(C)&&C===JSON.stringify(t.config)){p.push(t);continue}let D=n.t(i)?y(i):[],O=new Map(D.map(e=>[e.universalIdentifier.toLowerCase(),Z(e.relativePath)])),{codeStepFiles:k,...A}=K({entity:t,relativePath:S,isCodeStepPathAvailable:({relativePath:e,stepUniversalIdentifier:t})=>{let n=Z(e);return!g.has(n)||!v.has(n)&&O.get(t.toLowerCase())===n}});f.push({kind:t.kind,universalIdentifier:t.universalIdentifier,relativePath:S,...A,isRegeneration:n.t(i)});for(let e of k){let n=Z(e.relativePath);f.push({kind:t.kind,...e,requiredSdkExports:[],isRegeneration:h.has(n)}),m.add(e.relativePath),g.add(n),v.add(n)}_.push(...D)}let b=[];for(let e of c.keys()){if(s.has(e.toLowerCase()))continue;let t=u.get(e.toLowerCase()),r=n.t(t)?Q(t.relativePath):void 0;!n.t(r)||m.has(r)||(b.push({universalIdentifier:e,relativePath:r}),i.has(e)||_.push(...y(r)))}let S=r.filter(e=>n.t(e.universalIdentifier)&&!s.has(e.universalIdentifier.toLowerCase())&&!c.has(e.universalIdentifier)&&!i.has(e.universalIdentifier)&&!m.has(Q(e.relativePath))).map(e=>Q(e.relativePath));return{writes:f,unchanged:p,deletions:b,codeStepFileDeletions:_.filter(e=>!m.has(e.relativePath)),localOnlyRelativePaths:S}},$=[`dependencies`,`devDependencies`,`peerDependencies`],Oe=({content:e,existingContent:t})=>{let n=JSON.parse(e),i=JSON.parse(t);if($.some(e=>{let t=n[e];return r.t(t)&&Object.hasOwn(t,`twenty-sdk`)}))return e;for(let e of $){let t=i[e];if(!r.t(t)||!(0,A.isString)(t[`twenty-sdk`]))continue;let a=n[e];return n[e]={...r.t(a)?a:{},"twenty-sdk":t[`twenty-sdk`]},`${JSON.stringify(n,null,2)}\n`}return e},ke=async({appPath:e,files:t,sourceFingerprints:r={},dependencyFingerprints:i={}})=>{let a=[],o={},s={};for(let{path:c,content:l}of t){let t=(0,E.join)(e,c),d=await u.i(t)?await(0,T.readFile)(t,`utf8`):void 0,f=S.i(l);if(o[c]=f,n.t(d)&&(i[c]??r[c])===f)continue;let p=c===`package.json`&&n.t(d)?Oe({content:l,existingContent:d}):l;if(d===p){s[c]=S.i(p);continue}a.push({kind:`dependency`,universalIdentifier:`dependencies/${c}`,relativePath:c,content:p,requiredSdkExports:[],isRegeneration:n.t(d)})}return{writes:a,fingerprints:o,unchangedSourceFingerprints:s,unchangedCount:t.length-a.length}},Ae=async({appPath:e,includeConfig:t=!1,signal:r})=>{r.throwIfAborted();let i=await h.i(e),a=[];for(let o of i){r.throwIfAborted();let i=(0,E.relative)(e,o),s;try{s=await(0,T.readFile)(o,`utf-8`)}catch{a.push({relativePath:i,entityKey:null,targetFunctionName:null,universalIdentifier:null,isReadable:!1});continue}let c=h.r({fileContent:s,filePath:o});if(!n.t(c)){a.push({relativePath:i,entityKey:null,targetFunctionName:null,universalIdentifier:null,isReadable:!0});continue}let l=h.n[c],u={},f=!0;try{u=(await h.t({appPath:e,filePath:o})).config}catch(e){if(e instanceof d.t&&e.code===`SDK_SOURCE_UNSUPPORTED`)throw e;u={},f=!1}a.push({relativePath:i,entityKey:l,targetFunctionName:c,universalIdentifier:(0,A.isString)(u.universalIdentifier)?u.universalIdentifier:null,isReadable:f,...t?{config:u}:{}})}return r.throwIfAborted(),a},je=({sourceFingerprints:e={},writes:t,deletions:n})=>{let r=new Set(n.map(e=>e.relativePath));return{...Object.fromEntries(Object.entries(e).filter(([e])=>!r.has(e))),...Object.fromEntries(t.map(e=>[e.relativePath,S.i(e.content)]))}},Me=async e=>{let{appPath:t,signal:r}=e;try{let{applicationExport:i,target:a}=await ce(e),o=m.n(i.manifest),c=await me({appPath:t,target:a,applicationUniversalIdentifier:i.application.universalIdentifier}),l=n.t(c.manifest)?m.n(c.manifest):null,u=await Ae({appPath:t,includeConfig:!0,signal:r}),d=new Set(c.unreconciledUniversalIdentifiers),{entities:f,baseEntities:h,skipped:g}=ue({manifest:o,baseManifest:l,scannedFiles:u,unreconciledUniversalIdentifiers:d,systemPermissionFlag:s.i(t)});r?.throwIfAborted();let _=new Set(i.coverage.map(e=>e.universalIdentifier)),v=await se({appPath:t,scannedFiles:u,baseEntities:h}),b=De({entities:f,baseEntities:h,scannedFiles:u,workspaceUniversalIdentifiers:_,unreconciledUniversalIdentifiers:d,localCodeStepFilesByWorkflowPath:v}),x=new Set;j({value:o,identifiers:x}),j({value:i.coverage,identifiers:x});let C=u.filter(e=>e.entityKey===`frontComponents`).map(e=>(0,E.join)(t,e.relativePath)),w=await G({appPath:t,manifest:o,baseManifest:l,frontComponentSourcePaths:C}),T=de({entities:f,baseEntities:h,protectedIdentifiers:x,writes:b.writes,deletions:[...b.deletions.filter(e=>!x.has(e.universalIdentifier.toLowerCase())),...b.codeStepFileDeletions],scannedFiles:u}),D=await ke({appPath:t,files:i.files.filter(e=>e.folder===p.r.Dependencies),sourceFingerprints:c.sourceFingerprints,dependencyFingerprints:c.dependencyFingerprints}),O=await te({appPath:t,files:i.files.filter(({folder:e})=>e===p.r.PublicAsset),sourceFingerprints:c.sourceFingerprints,publicAssetFingerprints:c.publicAssetFingerprints}),k=await ne({appPath:t,manifest:o,baseManifest:l,files:i.files,scannedFiles:u,protectedIdentifiers:x,remoteSourceFingerprints:c.remoteSourceFingerprints,sourceFingerprints:c.sourceFingerprints,reservedPaths:new Set([...T.writes,...w.writes,...D.writes,...O.writes].map(e=>e.relativePath.toLowerCase()))}),A=await ee({appPath:t,manifest:o,files:i.files,remoteSourceFingerprints:c.remoteSourceFingerprints,sourceFingerprints:c.sourceFingerprints,reservedPaths:new Set([...T.writes,...w.writes,...D.writes,...O.writes,...k.writes,...k.deletions,...T.deletions].map(e=>e.relativePath.toLowerCase()))}),M=[...T.writes,...w.writes,...D.writes,...O.writes,...k.writes,...A.writes],N=[...T.deletions,...k.deletions,...w.deletions.filter(e=>n.t(l?.translations)&&e.universalIdentifier in l.translations)],P=[...g,...T.skipped],F=new Set(P.map(e=>e.universalIdentifier.toLowerCase())),I=S.t({target:a,manifest:fe({manifest:i.manifest,baseManifest:c.manifest,unreconciledUniversalIdentifiers:F,protectedIdentifiers:x}),unreconciledUniversalIdentifiers:[...F],remoteSourceFingerprints:{...k.fingerprints,...A.fingerprints},publicAssetFingerprints:{...c.publicAssetFingerprints,...O.fingerprints},dependencyFingerprints:{...c.dependencyFingerprints,...D.fingerprints},sourceFingerprints:je({sourceFingerprints:{...c.sourceFingerprints,...D.unchangedSourceFingerprints,...O.unchangedSourceFingerprints,...k.unchangedSourceFingerprints,...A.unchangedSourceFingerprints},writes:M,deletions:N})});await y.t({appPath:t,relativePaths:[...M.map(e=>e.relativePath),...N.map(e=>e.relativePath),I.relativePath]});let L=await ie({appPath:t,baseManifest:l,writes:M,deletions:N,frontComponentSourcePaths:C,baseEntities:h,localCodeStepFilesByWorkflowPath:v,sourceFingerprints:c.sourceFingerprints}),R=Se(o);return he({appPath:t,writes:M}),r?.throwIfAborted(),await be({appPath:t,writes:M,deletions:N,finalWrite:I,signal:r}),{success:!0,data:{application:{universalIdentifier:i.application.universalIdentifier,displayName:i.application.displayName},base:{status:c.status},writes:M.map(({content:e,requiredSdkExports:t,...n})=>n),deletions:N,overwrittenLocalChanges:L,unchangedCount:b.unchanged.length+D.unchangedCount+O.unchangedCount+k.unchangedCount+A.unchangedCount,localOnlyRelativePaths:b.localOnlyRelativePaths,unreadableRelativePaths:u.filter(e=>!e.isReadable).map(e=>e.relativePath),skipped:P,compiledTranslationEntryCountByLocale:w.compiledEntryCountByLocale,entityLabelByUniversalIdentifier:R},diagnostics:[]}}catch(e){return{success:!1,error:{code:r?.aborted&&Object.is(e,r.reason)?`CANCELLED`:e instanceof d.t?e.code:`PULL_FAILED`,message:e instanceof Error?e.message:String(e),...f.t(e),details:{outcome:`unchanged`,...e instanceof d.t?e.details:{}}},diagnostics:[]}}},Ne=async e=>{try{let t=e.applicationExport,n=r.t(t)&&r.t(t.application)&&(0,A.isString)(t.application.universalIdentifier)?t.application.universalIdentifier:``;return await Me({...e,applicationExport:m.t({value:t,universalIdentifier:n})})}finally{await(0,O.stop)()}};exports.pullSource=Ne;
@@ -1 +1 @@
1
- const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./isPlainObject-fJEJm71P.cjs"),r=require("./isValidUniversalIdentifier-DymFerYs.cjs"),i=require("./cli-error-CrUD8uMp.cjs"),a=require("./is-same-universal-identifier-Bm_wb6Ez.cjs"),o=require("./read-command-values-l5T9Lba4.cjs"),s=require("./to-worker-output-diagnostics-w1hZPfn0.cjs"),c=require("./read-app-identity-M47izSWp.cjs"),l=require("./resolve-app-project-B4IjfcM-.cjs"),u=require("./is-application-not-found-error-CQ7k4hGU.cjs"),d=require("./create-metadata-client-BITefgbL.cjs"),f=require("./create-app-not-installed-error-sN4TzjlV.cjs");var p=e.t(),m=async({universalIdentifier:e,target:t,signal:r})=>{let o=(await d.t({target:t,signal:r}).query({__name:`FindInstalledApplication`,findOneApplication:{__args:{universalIdentifier:e},name:!0,universalIdentifier:!0,canBeUninstalled:!0}}).catch(n=>{throw u.t({error:n,field:`findOneApplication`})?f.t({universalIdentifier:e,apiUrl:t.apiUrl}):n}))?.findOneApplication;if(!n.t(o)||!(0,p.isNonEmptyString)(o.name)||!a.t({value:o.universalIdentifier,universalIdentifier:e})||!(0,p.isBoolean)(o.canBeUninstalled))throw new i.t({code:`INVALID_RESPONSE`,message:`The server returned an invalid installed application.`});return{name:o.name,canBeUninstalled:o.canBeUninstalled}},h=async({context:e,onIdentityRead:n})=>{let a=o.i(e.options,`universalIdentifier`);if(t.t(a)){if(!r.t(a))throw new i.t({code:`INVALID_INPUT`,exitCode:i.n.USAGE,message:`--universal-identifier must be a UUID of version 4 or later, not ${a}.`});return a.toLowerCase()}let{options:u,output:d,outputMode:f,signal:p}=e,m=await c.t({appPath:(await l.t({explicitPath:o.i(u,`path`),workingDirectory:process.cwd()})).path,signal:p,warn:d.warn});if(!t.t(m.application))throw new i.t({code:`INVALID_INPUT`,exitCode:i.n.USAGE,message:`This project has no application definition.`});if(f===`human`)for(let e of m.diagnostics)d.progress({message:s.c(e)});return n(),m.application.universalIdentifier.toLowerCase()};Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return h}});
1
+ const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./isPlainObject-fJEJm71P.cjs"),r=require("./isValidUniversalIdentifier-DymFerYs.cjs"),i=require("./cli-error-CrUD8uMp.cjs"),a=require("./is-same-universal-identifier-Bm_wb6Ez.cjs"),o=require("./read-command-values-l5T9Lba4.cjs"),s=require("./to-worker-output-diagnostics-w1hZPfn0.cjs"),c=require("./read-app-identity-M47izSWp.cjs"),l=require("./resolve-app-project-B4IjfcM-.cjs"),u=require("./create-metadata-client-DOQK3gKE.cjs"),d=require("./is-application-not-found-error-CQ7k4hGU.cjs"),f=require("./create-app-not-installed-error-sN4TzjlV.cjs");var p=e.t(),m=async({universalIdentifier:e,target:t,signal:r})=>{let o=(await u.t({target:t,signal:r}).query({__name:`FindInstalledApplication`,findOneApplication:{__args:{universalIdentifier:e},name:!0,universalIdentifier:!0,canBeUninstalled:!0}}).catch(n=>{throw d.t({error:n,field:`findOneApplication`})?f.t({universalIdentifier:e,apiUrl:t.apiUrl}):n}))?.findOneApplication;if(!n.t(o)||!(0,p.isNonEmptyString)(o.name)||!a.t({value:o.universalIdentifier,universalIdentifier:e})||!(0,p.isBoolean)(o.canBeUninstalled))throw new i.t({code:`INVALID_RESPONSE`,message:`The server returned an invalid installed application.`});return{name:o.name,canBeUninstalled:o.canBeUninstalled}},h=async({context:e,onIdentityRead:n})=>{let a=o.i(e.options,`universalIdentifier`);if(t.t(a)){if(!r.t(a))throw new i.t({code:`INVALID_INPUT`,exitCode:i.n.USAGE,message:`--universal-identifier must be a UUID of version 4 or later, not ${a}.`});return a.toLowerCase()}let{options:u,output:d,outputMode:f,signal:p}=e,m=await c.t({appPath:(await l.t({explicitPath:o.i(u,`path`),workingDirectory:process.cwd()})).path,signal:p,warn:d.warn});if(!t.t(m.application))throw new i.t({code:`INVALID_INPUT`,exitCode:i.n.USAGE,message:`This project has no application definition.`});if(f===`human`)for(let e of m.diagnostics)d.progress({message:s.c(e)});return n(),m.application.universalIdentifier.toLowerCase()};Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return h}});
@@ -1,4 +1,4 @@
1
- const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./isPlainObject-fJEJm71P.cjs"),r=require("./cli-error-CrUD8uMp.cjs"),i=require("./is-same-universal-identifier-Bm_wb6Ez.cjs"),a=require("./style-BR52fK4V.cjs"),o=require("./is-application-not-found-error-CQ7k4hGU.cjs"),s=require("./result-item-limit.constant-QX3teiuy.cjs"),c=require("./create-metadata-client-BITefgbL.cjs"),l=require("./format-data-value-D_1TNU-r.cjs");var u=e.t(),d=e=>n.t(e)&&(e.type===`create`||e.type===`update`||e.type===`delete`)&&(0,u.isNonEmptyString)(e.metadataName)&&(e.type===`create`&&(0,u.isUndefined)(e.universalIdentifier)||(0,u.isNonEmptyString)(e.universalIdentifier))&&((0,u.isUndefined)(e.flatEntity)||n.t(e.flatEntity))&&((0,u.isUndefined)(e.cascadedFromUniversalIdentifier)||(0,u.isNonEmptyString)(e.cascadedFromUniversalIdentifier))&&((0,u.isUndefined)(e.diff)||n.t(e.diff)&&Object.values(e.diff).every(n.t)),f=e=>e.metadataName===`applicationVariable`?{...e,...t.t(e.flatEntity)&&`value`in e.flatEntity?{flatEntity:{...e.flatEntity,value:`(redacted)`}}:{},...t.t(e.diff)&&`value`in e.diff?{diff:{...e.diff,value:{before:`(redacted)`,after:`(redacted)`}}}:{}}:e,p=({value:e,applicationUniversalIdentifier:t})=>{if(!n.t(e)||!i.t({value:e.applicationUniversalIdentifier,universalIdentifier:t})||!(0,u.isArray)(e.actions)||!e.actions.every(d))throw new r.t({code:`INVALID_RESPONSE`,message:`The server returned an invalid application plan.`});if(e.actions.length>1e4)throw new r.t({code:`RESPONSE_LIMIT_EXCEEDED`,message:`The application plan exceeds ${s.t} actions.`,hint:`Reduce the app changes before requesting another plan.`});return e.actions.map(f)},m=async({build:e,inferDeletionFromMissingEntities:i,target:a,signal:s})=>{if(e.manifestFormat!==`twenty-application`||!n.t(e.manifest.application)||e.manifest.application.universalIdentifier!==e.application.universalIdentifier)throw new r.t({code:`TOOLING_UNSUPPORTED`,message:`The app build produced a manifest that this CLI cannot plan.`});try{return p({value:(await c.t({target:a,signal:s}).mutation({__name:`PreviewApplication`,syncApplication:{__args:{manifest:e.manifest,dryRun:!0,...t.t(i)&&{inferDeletionFromMissingEntities:i}},applicationUniversalIdentifier:!0,actions:!0}}))?.syncApplication,applicationUniversalIdentifier:e.application.universalIdentifier})}catch(t){throw t instanceof r.t&&o.t({error:t,field:`syncApplication`})?new r.t({code:`PLAN_UNAVAILABLE`,message:`This app must be registered in this workspace before its changes can be planned. Nothing was registered, uploaded or synchronized.`,hint:`Run twenty app apply --create to register it and install it in this workspace.`,details:{...t.details,body:void 0,data:null,applicationUniversalIdentifier:e.application.universalIdentifier,plan:!0}}):t instanceof r.t&&n.t(t.details)?new r.t({code:t.code,exitCode:t.exitCode,message:t.message,hint:t.hint,details:{...t.details,body:void 0,data:null}}):t}},h=e=>e.type===`delete`&&(e.metadataName===`objectMetadata`||e.metadataName===`fieldMetadata`),g=({action:e,root:t})=>e.type===`delete`&&t!==e&&(!h(e)||h(t)),_=e=>{let n=new Map(e.filter(e=>e.type===`delete`).map(e=>[e.universalIdentifier,e])),r=new Map,i=[];for(let a of e){let e=t.t(a.cascadedFromUniversalIdentifier)?n.get(a.cascadedFromUniversalIdentifier):void 0;if(!t.t(e)||!g({action:a,root:e})){i.push(a);continue}r.set(e,[...r.get(e)??[],a])}return{primaryActions:i,cascadesByRoot:r}},v=80,y=`(secret)`,b=`Entities missing from your source are destroyed by default. Re-run with --no-prune to keep them.`,x=new Set([`id`,`createdAt`,`updatedAt`,`deletedAt`,`universalIdentifier`,`__typename`]),S={create:0,update:1,delete:2},C={create:`+`,update:`~`,delete:`-`},w={create:`green`,update:`yellow`,delete:`red`},T={create:`will be created`,update:`will be updated in-place`,delete:`will be destroyed`},E=e=>{if(!t.t(e))return`null`;if((0,u.isBoolean)(e)||(0,u.isNumber)(e))return String(e);let n=(JSON.stringify(e)??String(e)).replace(/[\x7f-\x9f]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`);return n.length>v?`${n.slice(0,v-1)}…`:n},D=e=>{let t=e.flatEntity?.isSecret;if((0,u.isBoolean)(t))return t;let n=e.diff?.isSecret?.after;return(0,u.isBoolean)(n)?n:void 0},O=(e,t)=>e.metadataName===`applicationVariable`&&t===`value`&&D(e)!==!1,k=e=>Object.entries(e??{}).filter(([e,n])=>!x.has(e)&&!e.endsWith(`Id`)&&t.t(n)).sort(([e],[t])=>e.localeCompare(t)),A=e=>[e.flatEntity?.name,e.flatEntity?.nameSingular,e.flatEntity?.universalIdentifier].find(u.isString)??(e.type===`create`?`unknown`:e.universalIdentifier??`unknown`),j=e=>{let t=new Map;return e.forEach((e,n)=>{t.has(e.metadataName)||t.set(e.metadataName,n)}),[...e].sort((e,n)=>(t.get(e.metadataName)??0)-(t.get(n.metadataName)??0)||S[e.type]-S[n.type]||A(e).localeCompare(A(n)))},M=(e,t)=>a.t(` # ${l.r(e.metadataName)} ${E(A(e))} ${T[e.type]}`,t),N=(e,t)=>{let n=k(e.flatEntity),r=w[e.type];if(n.length===0)return[e.type===`delete`?a.n(r,` - name = ${E(A(e))}`,t):a.n(r,` + (no attributes to display)`,t)];let i=Math.max(...n.map(([e])=>e.length));return n.map(([n,o])=>a.n(r,` ${C[e.type]} ${n.padEnd(i)} = ${O(e,n)?y:E(o)}`,t))},P=(e,t)=>{let n=Object.keys(e.diff??{}).sort((e,t)=>e.localeCompare(t));if(n.length===0)return[];let r=Math.max(...n.map(e=>e.length));return n.map(n=>{let i=e.diff?.[n],o=O(e,n),s=o?y:E(i?.before),c=o?y:E(i?.after);return` ${a.n(`yellow`,`~`,t)} ${a.n(`yellow`,n.padEnd(r),t)} = ${a.n(`red`,s,t)} ${a.i(`->`,t)} ${a.n(`green`,c,t)}`})},F=({cascades:e,stream:t})=>{let n=new Map;for(let t of e)n.set(t.metadataName,(n.get(t.metadataName)??0)+1);let r=[...n.entries()].sort(([e,t],[n,r])=>r-t||e.localeCompare(n)).map(([e,t])=>`${t} ${e}`).join(`, `);return a.n(`red`,` - also destroys ${e.length} dependent ${e.length===1?`entity`:`entities`}: ${r}`,t)},I=({action:e,cascades:t,stream:n})=>{let r=e.type===`update`?P(e,n):N(e,n);return e.type===`update`&&r.length===0?void 0:[M(e,n),...r,...t.length>0?[F({cascades:t,stream:n})]:[]].join(`
1
+ const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./isPlainObject-fJEJm71P.cjs"),r=require("./cli-error-CrUD8uMp.cjs"),i=require("./is-same-universal-identifier-Bm_wb6Ez.cjs"),a=require("./style-BR52fK4V.cjs"),o=require("./create-metadata-client-DOQK3gKE.cjs"),s=require("./is-application-not-found-error-CQ7k4hGU.cjs"),c=require("./result-item-limit.constant-QX3teiuy.cjs"),l=require("./format-data-value-D_1TNU-r.cjs");var u=e.t(),d=e=>n.t(e)&&(e.type===`create`||e.type===`update`||e.type===`delete`)&&(0,u.isNonEmptyString)(e.metadataName)&&(e.type===`create`&&(0,u.isUndefined)(e.universalIdentifier)||(0,u.isNonEmptyString)(e.universalIdentifier))&&((0,u.isUndefined)(e.flatEntity)||n.t(e.flatEntity))&&((0,u.isUndefined)(e.cascadedFromUniversalIdentifier)||(0,u.isNonEmptyString)(e.cascadedFromUniversalIdentifier))&&((0,u.isUndefined)(e.diff)||n.t(e.diff)&&Object.values(e.diff).every(n.t)),f=e=>e.metadataName===`applicationVariable`?{...e,...t.t(e.flatEntity)&&`value`in e.flatEntity?{flatEntity:{...e.flatEntity,value:`(redacted)`}}:{},...t.t(e.diff)&&`value`in e.diff?{diff:{...e.diff,value:{before:`(redacted)`,after:`(redacted)`}}}:{}}:e,p=({value:e,applicationUniversalIdentifier:t})=>{if(!n.t(e)||!i.t({value:e.applicationUniversalIdentifier,universalIdentifier:t})||!(0,u.isArray)(e.actions)||!e.actions.every(d))throw new r.t({code:`INVALID_RESPONSE`,message:`The server returned an invalid application plan.`});if(e.actions.length>1e4)throw new r.t({code:`RESPONSE_LIMIT_EXCEEDED`,message:`The application plan exceeds ${c.t} actions.`,hint:`Reduce the app changes before requesting another plan.`});return e.actions.map(f)},m=async({build:e,inferDeletionFromMissingEntities:i,target:a,signal:c})=>{if(e.manifestFormat!==`twenty-application`||!n.t(e.manifest.application)||e.manifest.application.universalIdentifier!==e.application.universalIdentifier)throw new r.t({code:`TOOLING_UNSUPPORTED`,message:`The app build produced a manifest that this CLI cannot plan.`});try{return p({value:(await o.t({target:a,signal:c}).mutation({__name:`PreviewApplication`,syncApplication:{__args:{manifest:e.manifest,dryRun:!0,...t.t(i)&&{inferDeletionFromMissingEntities:i}},applicationUniversalIdentifier:!0,actions:!0}}))?.syncApplication,applicationUniversalIdentifier:e.application.universalIdentifier})}catch(t){throw t instanceof r.t&&s.t({error:t,field:`syncApplication`})?new r.t({code:`PLAN_UNAVAILABLE`,message:`This app must be registered in this workspace before its changes can be planned. Nothing was registered, uploaded or synchronized.`,hint:`Run twenty app apply --create to register it and install it in this workspace.`,details:{...t.details,body:void 0,data:null,applicationUniversalIdentifier:e.application.universalIdentifier,plan:!0}}):t instanceof r.t&&n.t(t.details)?new r.t({code:t.code,exitCode:t.exitCode,message:t.message,hint:t.hint,details:{...t.details,body:void 0,data:null}}):t}},h=e=>e.type===`delete`&&(e.metadataName===`objectMetadata`||e.metadataName===`fieldMetadata`),g=({action:e,root:t})=>e.type===`delete`&&t!==e&&(!h(e)||h(t)),_=e=>{let n=new Map(e.filter(e=>e.type===`delete`).map(e=>[e.universalIdentifier,e])),r=new Map,i=[];for(let a of e){let e=t.t(a.cascadedFromUniversalIdentifier)?n.get(a.cascadedFromUniversalIdentifier):void 0;if(!t.t(e)||!g({action:a,root:e})){i.push(a);continue}r.set(e,[...r.get(e)??[],a])}return{primaryActions:i,cascadesByRoot:r}},v=80,y=`(secret)`,b=`Entities missing from your source are destroyed by default. Re-run with --no-prune to keep them.`,x=new Set([`id`,`createdAt`,`updatedAt`,`deletedAt`,`universalIdentifier`,`__typename`]),S={create:0,update:1,delete:2},C={create:`+`,update:`~`,delete:`-`},w={create:`green`,update:`yellow`,delete:`red`},T={create:`will be created`,update:`will be updated in-place`,delete:`will be destroyed`},E=e=>{if(!t.t(e))return`null`;if((0,u.isBoolean)(e)||(0,u.isNumber)(e))return String(e);let n=(JSON.stringify(e)??String(e)).replace(/[\x7f-\x9f]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`);return n.length>v?`${n.slice(0,v-1)}…`:n},D=e=>{let t=e.flatEntity?.isSecret;if((0,u.isBoolean)(t))return t;let n=e.diff?.isSecret?.after;return(0,u.isBoolean)(n)?n:void 0},O=(e,t)=>e.metadataName===`applicationVariable`&&t===`value`&&D(e)!==!1,k=e=>Object.entries(e??{}).filter(([e,n])=>!x.has(e)&&!e.endsWith(`Id`)&&t.t(n)).sort(([e],[t])=>e.localeCompare(t)),A=e=>[e.flatEntity?.name,e.flatEntity?.nameSingular,e.flatEntity?.universalIdentifier].find(u.isString)??(e.type===`create`?`unknown`:e.universalIdentifier??`unknown`),j=e=>{let t=new Map;return e.forEach((e,n)=>{t.has(e.metadataName)||t.set(e.metadataName,n)}),[...e].sort((e,n)=>(t.get(e.metadataName)??0)-(t.get(n.metadataName)??0)||S[e.type]-S[n.type]||A(e).localeCompare(A(n)))},M=(e,t)=>a.t(` # ${l.r(e.metadataName)} ${E(A(e))} ${T[e.type]}`,t),N=(e,t)=>{let n=k(e.flatEntity),r=w[e.type];if(n.length===0)return[e.type===`delete`?a.n(r,` - name = ${E(A(e))}`,t):a.n(r,` + (no attributes to display)`,t)];let i=Math.max(...n.map(([e])=>e.length));return n.map(([n,o])=>a.n(r,` ${C[e.type]} ${n.padEnd(i)} = ${O(e,n)?y:E(o)}`,t))},P=(e,t)=>{let n=Object.keys(e.diff??{}).sort((e,t)=>e.localeCompare(t));if(n.length===0)return[];let r=Math.max(...n.map(e=>e.length));return n.map(n=>{let i=e.diff?.[n],o=O(e,n),s=o?y:E(i?.before),c=o?y:E(i?.after);return` ${a.n(`yellow`,`~`,t)} ${a.n(`yellow`,n.padEnd(r),t)} = ${a.n(`red`,s,t)} ${a.i(`->`,t)} ${a.n(`green`,c,t)}`})},F=({cascades:e,stream:t})=>{let n=new Map;for(let t of e)n.set(t.metadataName,(n.get(t.metadataName)??0)+1);let r=[...n.entries()].sort(([e,t],[n,r])=>r-t||e.localeCompare(n)).map(([e,t])=>`${t} ${e}`).join(`, `);return a.n(`red`,` - also destroys ${e.length} dependent ${e.length===1?`entity`:`entities`}: ${r}`,t)},I=({action:e,cascades:t,stream:n})=>{let r=e.type===`update`?P(e,n):N(e,n);return e.type===`update`&&r.length===0?void 0:[M(e,n),...r,...t.length>0?[F({cascades:t,stream:n})]:[]].join(`
2
2
  `)},L=({action:e,cascades:t})=>{let n=e.metadataName===`objectMetadata`?e.universalIdentifier:e.flatEntity?.objectMetadataUniversalIdentifier;return t.filter(e=>e.metadataName===`fieldMetadata`&&e.flatEntity?.objectMetadataUniversalIdentifier!==n).length},R=({action:e,cascades:t})=>{let n=e.metadataName===`objectMetadata`?`drops the table and all its rows`:`drops the column and its data`,r=L({action:e,cascades:t});return r===0?n:`${n}, and ${r} ${r===1?`field`:`fields`} on other objects`},z=({primaryActions:e,cascadesByRoot:t,stream:n})=>{let r=e.filter(h);return[a.t(a.n(`red`,`Warning: ${r.length} destructive change(s) will permanently delete data.`,n),n),...r.map(e=>a.n(`red`,` - ${l.r(e.metadataName)} ${E(A(e))}: ${R({action:e,cascades:t.get(e)??[]})}`,n)),a.n(`red`,`Destroys are irreversible. Review carefully before applying.`,n)].join(`
3
3
  `)},B=({actions:e,summary:n,inferDeletionFromMissingEntities:r,stream:i=process.stdout})=>{if(e.length===0)return`No changes. Twenty metadata matches your manifest.`;let{primaryActions:o,cascadesByRoot:s}=_(e),c=j(o).map(e=>I({action:e,cascades:s.get(e)??[],stream:i})).filter(t.t);return[a.t(`Twenty will perform the following actions:`,i),``,c.join(`
4
4
 
@@ -0,0 +1 @@
1
+ const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./isNonEmptyArray-v52xg4Xj.cjs"),r=require("./isPlainObject-fJEJm71P.cjs"),i=require("./cli-error-CrUD8uMp.cjs"),a=require("./isRestorableApplicationSourcePath-Du_zM55R.cjs"),o=require("./AssetDirectory-c_JEwMr2.cjs"),s=require("./application-source-globs-FUknjGdt.cjs"),c=require("./constants-Cf5-CwMu.cjs"),l=require("./assert-pull-paths-TFGZvzZO.cjs"),u=require("./is-same-universal-identifier-Bm_wb6Ez.cjs"),d=require("./create-pull-base-write-CX8xZhMz.cjs"),f=require("./create-cancelled-error-BBhAY8fS.cjs"),p=require("./is-interaction-allowed-BQLOG8RG.cjs"),m=require("./create-metadata-client-DOQK3gKE.cjs"),h=require("./fetch-workspace-or-throw-DsxaW4lw.cjs"),g=require("./assert-app-roles-allowed-C4syxo2P.cjs"),_=require("./with-phase-details-CRqY0f3c.cjs"),v=require("./to-cli-error-4pSpVaW9.cjs"),y=require("./read-infer-deletion-option-BiBJJH9Z.cjs"),b=require("./require-approval-BIgPOy_r.cjs"),x=require("./read-snapshot-file-Dxla2ete.cjs"),S=require("./fetch-app-export-kiQnE1Vi.cjs");let C=require("node:crypto"),w=require("node:fs/promises"),T=require("node:path"),E=require("tinyglobby");var D=new Set([`AUTH_REQUIRED`,`PERMISSION_DENIED`]),O=new Set([`SNAPSHOT_INVALID`,`TOOLING_UNSUPPORTED`]),k=({phase:e,code:t,upload:n})=>e===`build`||e===`preview`||e===`confirmation`?`not-started`:e===`upload`&&n.fileCount>0?`partial`:e===`upload`&&n.hasCreatedTargets?`unknown`:D.has(t)||O.has(t)?`not-started`:`unknown`,A=({phase:e,outcome:t})=>t===`not-started`?`Fix the problem, then run twenty app apply again. It rebuilds the app and requests a fresh plan.`:`The ${e} step may have changed the workspace. Run twenty app plan to see where it stands before applying again.`,j=({error:e,phase:t,completedPhases:n,upload:r,signal:i})=>{let a=v.t(e,i),o=k({phase:t,code:a.code,upload:r});return _.t({error:a,phase:t,outcome:o,completedPhases:n,hint:A({phase:t,outcome:o})})},M=e.t(),N=async({application:e,target:t,signal:n})=>{let a=(await m.t({target:t,signal:n}).mutation({__name:`InstallDevelopmentApplication`,createDevelopmentApplication:{__args:{universalIdentifier:e.universalIdentifier,name:e.displayName},id:!0,universalIdentifier:!0}}))?.createDevelopmentApplication;if(!r.t(a)||!(0,M.isNonEmptyString)(a.id)||!u.t({value:a.universalIdentifier,universalIdentifier:e.universalIdentifier}))throw new i.t({code:`INVALID_RESPONSE`,message:`The server returned an invalid development installation.`});return{applicationId:a.id}},P=async({application:e,target:t,signal:n})=>{let a=(await m.t({target:t,signal:n}).mutation({__name:`RegisterApplication`,createApplicationRegistration:{__args:{input:{name:e.displayName,universalIdentifier:e.universalIdentifier}},applicationRegistration:{id:!0,universalIdentifier:!0}}}))?.createApplicationRegistration,o=r.t(a)?a.applicationRegistration:void 0;if(!r.t(o)||!(0,M.isNonEmptyString)(o.id)||!u.t({value:o.universalIdentifier,universalIdentifier:e.universalIdentifier}))throw new i.t({code:`INVALID_RESPONSE`,message:`The server returned an invalid application registration.`});return{registrationId:o.id}},F=e=>{if(!(e instanceof i.t)||!r.t(e.details))return e;let{body:t,...n}=e.details;return new i.t({code:e.code,exitCode:e.exitCode,message:e.message,hint:e.hint,details:{...n,data:null}})},I=({value:e,applicationUniversalIdentifier:t})=>{try{return y.o({value:e,applicationUniversalIdentifier:t})}catch(e){if(e instanceof i.t)return;throw e}},L=async({build:e,inferDeletionFromMissingEntities:n,target:a,signal:o})=>{let s=e.application.universalIdentifier,c=(await m.t({target:a,signal:o}).mutation({__name:`SyncApplication`,syncApplication:{__args:{manifest:e.manifest,...t.t(n)&&{inferDeletionFromMissingEntities:n}},applicationUniversalIdentifier:!0,actions:!0}}).catch(e=>{throw F(e)}))?.syncApplication;if(!r.t(c)||!(0,M.isString)(c.applicationUniversalIdentifier)||!u.t({value:c.applicationUniversalIdentifier,universalIdentifier:s}))throw new i.t({code:`INVALID_RESPONSE`,message:`The server did not confirm the sync of ${s}.`});return{actions:I({value:c,applicationUniversalIdentifier:s}),acknowledgedUniversalIdentifier:c.applicationUniversalIdentifier}},R={"built-logic-function":`BuiltLogicFunction`,"built-front-component":`BuiltFrontComponent`,source:`Source`,dependencies:`Dependencies`,"public-asset":`PublicAsset`},z=()=>new i.t({code:`INVALID_RESPONSE`,message:`The server returned an invalid file upload response.`}),B=e=>r.t(e)&&(0,M.isNonEmptyString)(e.fileId)&&(0,M.isNonEmptyString)(e.filePath)&&(0,M.isNonEmptyString)(e.uploadUrl)&&(0,M.isNonEmptyString)(e.contentType),V=({value:e,idKey:t})=>{if(!(0,M.isArray)(e))throw z();return e.map(e=>{let n=r.t(e)?e[t]:void 0;if(!r.t(e)||!(0,M.isNonEmptyString)(n))throw z();return{id:n,message:(0,M.isNonEmptyString)(e.message)?e.message:`The server refused this file.`}})},H=e=>{let n=R[e.role];if(!t.t(n))throw new i.t({code:`TOOLING_UNSUPPORTED`,message:`The build contains a ${e.role} file, which the CLI cannot upload.`,details:{path:e.path,role:e.role}});return{fileFolder:n,filePath:e.path,size:e.size}},U=async({items:e,run:n})=>{let r=0,i,a=async()=>{if(r>=e.length||t.t(i))return;let o=e[r];r+=1;try{await n(o)}catch(e){i??={error:e}}await a()};if(await Promise.all(Array.from({length:Math.min(x.i.UPLOAD_CONCURRENCY,e.length)},a)),t.t(i))throw i.error},W=async({artifacts:e,context:t})=>{let n=(await m.t({target:t.target,signal:t.signal}).mutation({__name:`CreateApplicationFileUploads`,createApplicationFileUploads:{__args:{applicationUniversalIdentifier:t.applicationUniversalIdentifier,files:e.map(H)},targets:{fileId:!0,filePath:!0,uploadUrl:!0,contentType:!0},errors:{filePath:!0,message:!0}}}))?.createApplicationFileUploads;if(!r.t(n)||!(0,M.isArray)(n.targets)||!n.targets.every(B))throw z();t.progress.hasCreatedTargets=!0;let i=V({value:n.errors,idKey:`filePath`}),a=new Set([...n.targets.map(e=>e.filePath),...i.map(({id:e})=>e)]);return{uploadTargets:n.targets,failures:[...i.map(({id:e,message:t})=>({path:e,message:t})),...e.filter(e=>!a.has(e.path)).map(e=>({path:e.path,message:`The server did not accept this file.`}))]}},G=async({uploadTargets:e,artifactByPath:n,context:r,failures:a})=>{let o=[];return await U({items:e,run:async e=>{let s=n.get(e.filePath);if(!t.t(s)){a.push({path:e.filePath,message:`The server asked for a file this build does not have.`});return}let c=await x.t({snapshotDirectory:r.snapshotDirectory,artifact:s});try{let t=await x.r({target:r.target,uploadUrl:e.uploadUrl,contentType:e.contentType,bytes:c,signal:r.signal});if(t<200||t>=300){a.push({path:s.path,message:`File storage answered ${t}.`});return}o.push(e)}catch(e){if(r.signal.aborted||e instanceof i.t)throw e;a.push({path:s.path,message:e instanceof Error?e.message:String(e)})}}}),o},K=async({sentTargets:e,artifactByPath:t,context:i,failures:a})=>{if(!n.t(e))return;let o=(await m.t({target:i.target,signal:i.signal}).mutation({__name:`CompleteApplicationFileUploads`,completeApplicationFileUploads:{__args:{applicationUniversalIdentifier:i.applicationUniversalIdentifier,fileIds:e.map(e=>e.fileId)},errors:{fileId:!0,message:!0}}}))?.completeApplicationFileUploads;if(!r.t(o))throw z();let s=V({value:o.errors,idKey:`fileId`}),c=new Set(s.map(({id:e})=>e)),l=new Map(e.map(e=>[e.fileId,e.filePath]));a.push(...s.map(({id:e,message:t})=>({path:l.get(e)??e,message:t})));for(let n of e)c.has(n.fileId)||(i.progress.fileCount+=1,i.progress.byteCount+=t.get(n.filePath)?.size??0)},q=async({build:e,snapshotDirectory:t,target:r,signal:a,progress:o})=>{e.files.forEach(H);for(let n of e.files)await x.t({snapshotDirectory:t,artifact:n});let s={applicationUniversalIdentifier:e.application.universalIdentifier,snapshotDirectory:t,target:r,signal:a,progress:o},c=new Map(e.files.map(e=>[e.path,e])),l=[];for(let t=0;t<e.files.length;t+=100){let{uploadTargets:n,failures:r}=await W({artifacts:e.files.slice(t,t+100),context:s});l.push(...r),await K({sentTargets:await G({uploadTargets:n,artifactByPath:c,context:s,failures:l}),artifactByPath:c,context:s,failures:l})}if(n.t(l))throw new i.t({code:`UPLOAD_FAILED`,message:`${l.length} of ${e.files.length} files could not be uploaded.`,details:{failures:l}})},J=e=>e instanceof i.t&&e.code===`PLAN_UNAVAILABLE`,Y=async({build:e,appPath:t,context:{target:n,signal:r,output:i,outputMode:a,options:o},inferDeletionFromMissingEntities:s,isCreationApproved:c,isDeletionApproved:l,approvalSignal:u,beforeWrite:d,flushProgress:f})=>{let m=[`build`],h={fileCount:0,byteCount:0,hasCreatedTargets:!1},_=p.t({options:o,outputMode:a}),v=e.application,S=(e,t)=>j({error:e,phase:t,completedPhases:m,upload:h,signal:r}),C=async(e,t)=>{if(await f?.().catch(e=>{throw S(e,`confirmation`)}),[`registration`,`installation`,`upload`,`sync`].includes(e))try{d?.()}catch(e){throw S(e,`confirmation`)}try{let n=await t();return m.push(e),n}catch(t){throw S(t,e)}},w=async e=>(await f?.().catch(e=>{throw S(e,`confirmation`)}),b.t({...e,canPrompt:_,declinedMessage:`Apply stopped at the confirmation prompt.`,signal:u??r}).then(()=>u?.throwIfAborted()).catch(e=>{throw S(e,`confirmation`)})),T=()=>y.a({build:e,inferDeletionFromMissingEntities:s,target:n,signal:r}),E=async()=>{try{let e=await T();return m.push(`preview`),{actions:e,isRegistrationCreated:!1}}catch(e){if(!J(e))throw S(e,`preview`)}return await w({isApproved:c,question:`${v.displayName} is not registered. Register it and install it on ${n.apiUrl}?`,code:`CREATE_REQUIRED`,message:`${v.displayName} has no registration yet. Applying it would create one.`,hint:`Run twenty app apply --create to register it and install it in this workspace.`}),i.progress({message:`Registering the app…`}),await C(`registration`,()=>P({application:v,target:n,signal:r})),i.progress({message:`Installing the development app…`}),await C(`installation`,()=>N({application:v,target:n,signal:r})),i.progress({message:`Computing metadata plan…`}),{actions:await C(`preview`,T),isRegistrationCreated:!0}},D=x.a({build:e,appPath:t});i.progress({message:`Computing metadata plan on ${n.apiUrl}…`}),await g.t({build:e,target:n,signal:r}).catch(e=>{throw S(e,`preview`)});let{actions:O,isRegistrationCreated:k}=await E(),A=y.n(O);if(a===`human`&&i.progress({message:y.i({actions:O,summary:A,inferDeletionFromMissingEntities:s,stream:process.stderr})}),A.destructive>0){let e=A.destructive===1?`object or field deletion that permanently deletes`:`object or field deletions that permanently delete`;await w({isApproved:l,question:`Apply ${A.destructive} ${e} stored data on ${n.apiUrl}?`,code:`CONFIRMATION_REQUIRED`,message:`The plan includes ${A.destructive} ${e} stored data.`,hint:`Review it with twenty app plan, then pass --yes to apply it, or --no-prune to keep entities missing from source.`})}k||await C(`installation`,()=>N({application:v,target:n,signal:r})),i.progress({message:`Uploading ${e.files.length} ${e.files.length===1?`file`:`files`}…`}),await C(`upload`,()=>q({build:e,snapshotDirectory:D,target:n,signal:r,progress:h})),i.progress({message:`Synchronizing the app…`});let{actions:M,acknowledgedUniversalIdentifier:F}=await C(`sync`,()=>L({build:e,inferDeletionFromMissingEntities:s,target:n,signal:r}));return{completedPhases:m,isRegistrationCreated:k,appliedActions:M,acknowledgedUniversalIdentifier:F,upload:h}},X={pullBase:{cancelledMessage:`recording its pull base was cancelled`,failedMessage:`its pull base was not recorded`,hint:`The workspace already has this version of the app. Any previous pull base was kept. The typed API client was not regenerated. Review twenty app plan before retrying twenty app apply, which repeats the sync before recording the base and regenerating the client.`},clientGeneration:{cancelledMessage:`generating its typed API client was cancelled`,failedMessage:`its typed API client was not regenerated`,hint:`The workspace already has this version of the app, but the client files in node_modules/twenty-client-sdk may be incomplete. Fix the problem, then run twenty app generate-client to regenerate the client without syncing again.`}},Z=({error:e,phase:t,applicationName:n,apiUrl:r,completedPhases:a,signal:o})=>{let s=v.t(e,o),c=X[t],l=s.code===`CANCELLED`?`${n} was applied to ${r}, but ${c.cancelledMessage}.`:`${n} was applied to ${r}, but ${c.failedMessage}: ${s.message}`;return _.t({error:new i.t({code:s.code,exitCode:s.exitCode,message:l,hint:[c.hint,s.hint].filter(M.isNonEmptyString).join(` `),details:s.details}),phase:t,outcome:`applied`,completedPhases:a,hint:c.hint})},Q=async e=>{let t=await(0,E.glob)([...a.n.map(e=>`**/*${e}`),`${c.n}/*.json`,`${c.t}/*.json`,`package.json`,`yarn.lock`,`${o.t}/**/*`],{cwd:e,absolute:!0,onlyFiles:!0,ignore:s.n.filter(e=>e!==`**/*.d.ts`&&e!==`public/**`)}),n={};for(let r of t.sort())n[(0,T.relative)(e,r).split(T.sep).join(`/`)]=d.i(await(0,w.readFile)(r));return n},$=async({appPath:e,manifest:t,target:n,sourceFingerprints:r,signal:a})=>{let o=(0,T.join)(e,d.r),s=`${o}.${(0,C.randomUUID)()}.tmp`,c;try{a.throwIfAborted(),await l.t({appPath:e,relativePaths:[d.r]}),await(0,w.mkdir)((0,T.dirname)(o),{recursive:!0}),c=await(0,w.open)(s,`wx`,384),await c.writeFile(d.t({manifest:t,target:n,sourceFingerprints:r}).content),await c.sync(),await c.close(),await l.t({appPath:e,relativePaths:[d.r]}),a.throwIfAborted(),await(0,w.rename)(s,o)}catch(e){throw await c?.close().catch(()=>void 0),await(0,w.rm)(s,{force:!0}).catch(()=>void 0),a.aborted&&Object.is(e,a.reason)?e:new i.t({code:`PULL_BASE_RECORD_FAILED`,message:e instanceof Error?e.message:String(e)})}},ee=async({appPath:e,universalIdentifier:t,sourceFingerprints:n,appliedManifest:r,context:{target:a,signal:o,output:s}})=>{s.progress({message:`Recording the pull base…`});try{if(!(0,M.isArray)(r.frontComponents)||!(0,M.isArray)(r.logicFunctions))throw new i.t({code:`INVALID_RESPONSE`,message:`The applied snapshot is missing its frontend component or logic function collection.`});let{id:s}=await h.t({target:a,signal:o});return await $({appPath:e,manifest:{...(await S.t({universalIdentifier:t,target:a,signal:o})).manifest,frontComponents:r.frontComponents,logicFunctions:r.logicFunctions},target:{apiUrl:a.apiUrl,workspaceId:s},sourceFingerprints:n,signal:o}),`recorded`}catch(e){if(o.aborted)throw f.t();let t=v.t(e);return t.code===`APP_EXPORT_UNSUPPORTED`?`unsupported`:(s.warn({code:`PULL_BASE_NOT_RECORDED`,message:`The app was applied, but its pull base was not updated: ${t.message} Any previous base was kept. A later pull may report changes from this apply as remote changes.`}),`failed`)}};Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return ee}});