twenty 2.59.0 → 2.61.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.
- package/dist/app-template/yarn.lock +39 -39
- package/dist/app-worker.cjs +1 -1
- package/dist/chunks/application-source-globs-FUknjGdt.cjs +1 -0
- package/dist/chunks/{build-source-manifest-Ddwa8ath.cjs → build-source-manifest-DQ5YF5PV.cjs} +1 -1
- package/dist/chunks/{build-source-snapshot-CUsEVNsQ.cjs → build-source-snapshot-DIjGWX_5.cjs} +19 -19
- package/dist/chunks/{cli-version.constant-y_3mZ4gx.cjs → cli-version.constant-Dn-WFWf8.cjs} +1 -1
- package/dist/chunks/collect-watch-inputs-Cj9epSJw.cjs +1 -0
- package/dist/chunks/compile-application-translations-CDykMbFf.cjs +58 -0
- package/dist/chunks/create-metadata-client-CrOsu4u3.cjs +6 -0
- package/dist/chunks/{create-rest-client-HbzXSfhZ.cjs → create-rest-client-D3ZXtAxc.cjs} +1 -1
- package/dist/chunks/extract-manifest-from-file-B3pazFD1.cjs +1 -0
- package/dist/chunks/{extract-source-translations-B-XmoSt7.cjs → extract-source-translations-b9c2CH4w.cjs} +1 -1
- package/dist/chunks/{fetch-metadata-inspection-ooyNi2DN.cjs → fetch-metadata-inspection-DN8am1j0.cjs} +1 -1
- package/dist/chunks/{fetch-signed-in-identity-nCzWXunB.cjs → fetch-signed-in-identity-kgzejZg2.cjs} +1 -1
- package/dist/chunks/fetch-workspace-or-throw-BIu0K3A-.cjs +1 -0
- package/dist/chunks/fs-utils-BcNux7fF.cjs +2 -0
- package/dist/chunks/{get-client-generation-skip-reason-BZiAtHwa.cjs → get-client-generation-skip-reason-C_oaO89K.cjs} +1 -1
- package/dist/chunks/get-mismatched-remote-url-D5jFYvVx.cjs +1 -0
- package/dist/chunks/global-flags.constant-JcdNC5G1.cjs +1 -0
- package/dist/chunks/is-exported-manifest-BHA_mGa6.cjs +1 -0
- package/dist/chunks/{is-valid-package-name-Ds0DY5qP.cjs → is-valid-package-name-o_jWsuUX.cjs} +1 -1
- package/dist/chunks/isRestorableApplicationSourcePath-Du_zM55R.cjs +1 -0
- package/dist/chunks/parse-app-export-B9Ocghe1.cjs +1 -0
- package/dist/chunks/pull-minimum-sdk-version.constant-DOAFtDDD.cjs +6 -0
- package/dist/chunks/pull-source-B5Hot5CI.cjs +1 -0
- package/dist/chunks/{read-app-identity-Cny6sAGs.cjs → read-app-identity-M47izSWp.cjs} +1 -1
- package/dist/chunks/{read-application-identifier-C4U2JsfD.cjs → read-application-identifier-BlEwa2gR.cjs} +1 -1
- package/dist/chunks/read-application-identity-CYKNL1g5.cjs +1 -0
- package/dist/chunks/{read-infer-deletion-option-Hv5V-A47.cjs → read-infer-deletion-option-DeyWsiCS.cjs} +1 -1
- package/dist/chunks/{read-source-identity-CG9W0pSt.cjs → read-source-identity-bo4jC2Dh.cjs} +1 -1
- package/dist/chunks/read-watch-input-stamp-DKJ-Plk2.cjs +1 -0
- package/dist/chunks/record-pull-base-DKrQDDmc.cjs +1 -0
- package/dist/chunks/{record-typecheck-config-inputs-U2RUjjp9.cjs → record-typecheck-config-inputs-BMV55iFx.cjs} +1 -1
- package/dist/chunks/{resolve-command-target-CLqjjxCT.cjs → resolve-command-target-B9QG8OZs.cjs} +1 -1
- package/dist/chunks/{resolve-project-typescript-DO4LrLr-.cjs → resolve-project-typescript-DjMUr6ks.cjs} +1 -1
- package/dist/chunks/{resolve-source-sdk-C4Hu045V.cjs → resolve-source-sdk-BDwffWHb.cjs} +1 -1
- package/dist/chunks/{run-app-add-command-b9sm20rn.cjs → run-app-add-command-De3cIhU0.cjs} +1 -1
- package/dist/chunks/{run-app-apply-command-CD7NOdiR.cjs → run-app-apply-command-BXVHKrW3.cjs} +2 -2
- package/dist/chunks/{run-app-build-command-C8ubC2GH.cjs → run-app-build-command-BMwzOOov.cjs} +1 -1
- package/dist/chunks/run-app-dev-command-Bg4zIJnX.cjs +3 -0
- package/dist/chunks/{run-app-exec-command-cw4vPVHE.cjs → run-app-exec-command-BOhA0aZN.cjs} +1 -1
- package/dist/chunks/{run-app-generate-client-command-BVRFtPni.cjs → run-app-generate-client-command-B7p5M_hN.cjs} +1 -1
- package/dist/chunks/{run-app-init-command-DuxE1JhM.cjs → run-app-init-command-DJ0UipFh.cjs} +1 -1
- package/dist/chunks/{run-app-install-command-DlcUupwk.cjs → run-app-install-command-CsK8l0Ou.cjs} +1 -1
- package/dist/chunks/{run-app-logs-command-CaLIVesh.cjs → run-app-logs-command-COAdNMuL.cjs} +1 -1
- package/dist/chunks/{run-app-operation-DKPh4r7b.cjs → run-app-operation-B4JecUV7.cjs} +1 -1
- package/dist/chunks/{run-app-plan-command-BGQ7vJZT.cjs → run-app-plan-command-hASkfDaJ.cjs} +1 -1
- package/dist/chunks/{run-app-publish-command-BGNJVIBl.cjs → run-app-publish-command-ClsjL5OP.cjs} +1 -1
- package/dist/chunks/{run-app-pull-command-NbZ8fjhE.cjs → run-app-pull-command-BfHIuJ1m.cjs} +2 -2
- package/dist/chunks/{run-app-translations-extract-command-CGIFvpC1.cjs → run-app-translations-extract-command-DHIEEFXs.cjs} +1 -1
- package/dist/chunks/{run-app-typecheck-command-D0KV3hFS.cjs → run-app-typecheck-command--4NoTac-.cjs} +1 -1
- package/dist/chunks/{run-app-uninstall-command-CepQk4_4.cjs → run-app-uninstall-command-ClRoCRjv.cjs} +1 -1
- package/dist/chunks/run-auth-login-command-p9VHNoqZ.cjs +1 -0
- package/dist/chunks/{run-auth-status-command-Dr4YQuLn.cjs → run-auth-status-command-CdqOc2-Q.cjs} +1 -1
- package/dist/chunks/{run-cli-oUabLHNz.cjs → run-cli-CgBPkP_r.cjs} +3 -3
- package/dist/chunks/{run-commands-command-DYm9TuAx.cjs → run-commands-command-BF3y7Dz2.cjs} +1 -1
- package/dist/chunks/{run-data-export-command-C4_7rc0v.cjs → run-data-export-command-ca_JYOnT.cjs} +1 -1
- package/dist/chunks/{run-data-get-command-CcEYQ4xO.cjs → run-data-get-command-BZTsbTvb.cjs} +1 -1
- package/dist/chunks/{run-data-list-command-D0K7HFD-.cjs → run-data-list-command-UI5hngdt.cjs} +1 -1
- package/dist/chunks/{run-doctor-command-fHf5vCGl.cjs → run-doctor-command-B_bcpjAT.cjs} +2 -2
- package/dist/chunks/run-local-start-command-B8N5Jgjd.cjs +1 -0
- package/dist/chunks/{run-metadata-field-describe-command-nfKhj-m_.cjs → run-metadata-field-describe-command-CH7Yob_y.cjs} +1 -1
- package/dist/chunks/{run-metadata-field-list-command-CW2I6hmh.cjs → run-metadata-field-list-command-BzxIj9tX.cjs} +1 -1
- package/dist/chunks/{run-metadata-object-describe-command-WLxcOe4T.cjs → run-metadata-object-describe-command-BF9FzF06.cjs} +1 -1
- package/dist/chunks/{run-metadata-object-list-command-Q4pwAEwO.cjs → run-metadata-object-list-command-Tk_Fjfc5.cjs} +1 -1
- package/dist/chunks/{run-open-command-DPrz3N1e.cjs → run-open-command-BldBUk02.cjs} +1 -1
- package/dist/chunks/{run-version-command-BWTSv9_Y.cjs → run-version-command-B_6F7XYT.cjs} +1 -1
- package/dist/chunks/{sign-in-to-remote-again-DFQr-xvw.cjs → sign-in-to-remote-again-BqU_-38L.cjs} +1 -1
- package/dist/chunks/standard-object-fields.constant-CA16BdJ2.cjs +1 -0
- package/dist/chunks/{typecheck-application-8A504oUF.cjs → typecheck-application-CiGxmS69.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/docs/commands.md +45 -17
- package/package.json +2 -2
- package/src/app/bundles/README.md +6 -0
- package/src/app/dev/README.md +13 -1
- package/src/app/pull/README.md +51 -18
- package/dist/chunks/FileFolder-BmCXp_bX.cjs +0 -1
- package/dist/chunks/collect-watch-inputs-DfWAkX1r.cjs +0 -1
- package/dist/chunks/compile-application-translations-C9UZQCAb.cjs +0 -58
- package/dist/chunks/create-metadata-client-FopHnDj0.cjs +0 -6
- package/dist/chunks/extract-manifest-from-file-DPDIhnyg.cjs +0 -1
- package/dist/chunks/fetch-workspace-or-throw-DHoa_BYF.cjs +0 -1
- package/dist/chunks/fs-utils-DoSmCBu8.cjs +0 -2
- package/dist/chunks/global-flags.constant-DMHyA_PD.cjs +0 -1
- package/dist/chunks/is-exported-manifest-C4lO285q.cjs +0 -1
- package/dist/chunks/list-application-source-files-DcyU-HrX.cjs +0 -1
- package/dist/chunks/parse-app-export-BC81wdmc.cjs +0 -1
- package/dist/chunks/pull-minimum-sdk-version.constant-DUMi_IUD.cjs +0 -6
- package/dist/chunks/pull-source-CXQQf8Lw.cjs +0 -1
- package/dist/chunks/read-application-identity-5sO-Mqb1.cjs +0 -1
- package/dist/chunks/read-watch-input-stamp-BxeOb0vI.cjs +0 -1
- package/dist/chunks/record-pull-base-8bIoAoiB.cjs +0 -1
- package/dist/chunks/run-app-dev-command-D1JOfJv6.cjs +0 -2
- package/dist/chunks/run-auth-login-command-DpS1bUdL.cjs +0 -1
- package/dist/chunks/run-local-start-command-DsFS9_ew.cjs +0 -1
- package/dist/chunks/standard-object-fields.constant-C4AVX0t2.cjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./isDefined-CJctgvfE.cjs"),t=require("./get-field-universal-identifier.util-d1401qKf.cjs"),n=require("./isValidUniversalIdentifier-DymFerYs.cjs"),r=require("./kebab-case-B3kq7ANN.cjs"),i=require("./has-error-code-DsJeqbZq.cjs"),a=require("./cli-error-CrUD8uMp.cjs"),o=require("./assert-pull-paths-TFGZvzZO.cjs"),s=require("./print-typescript-value-BjYn0ZFT.cjs"),c=require("./read-command-values-l5T9Lba4.cjs"),l=require("./convert-to-label-CI8cZyg_.cjs"),u=require("./confirm-in-terminal-D2e1lKUY.cjs"),d=require("./is-interaction-allowed-BQLOG8RG.cjs"),f=require("./style-BR52fK4V.cjs"),p=require("./to-worker-output-diagnostics-w1hZPfn0.cjs"),m=require("./read-app-identity-
|
|
1
|
+
const e=require("./isDefined-CJctgvfE.cjs"),t=require("./get-field-universal-identifier.util-d1401qKf.cjs"),n=require("./isValidUniversalIdentifier-DymFerYs.cjs"),r=require("./kebab-case-B3kq7ANN.cjs"),i=require("./has-error-code-DsJeqbZq.cjs"),a=require("./cli-error-CrUD8uMp.cjs"),o=require("./assert-pull-paths-TFGZvzZO.cjs"),s=require("./print-typescript-value-BjYn0ZFT.cjs"),c=require("./read-command-values-l5T9Lba4.cjs"),l=require("./convert-to-label-CI8cZyg_.cjs"),u=require("./confirm-in-terminal-D2e1lKUY.cjs"),d=require("./is-interaction-allowed-BQLOG8RG.cjs"),f=require("./style-BR52fK4V.cjs"),p=require("./to-worker-output-diagnostics-w1hZPfn0.cjs"),m=require("./read-app-identity-M47izSWp.cjs"),h=require("./resolve-app-project-B4IjfcM-.cjs");let g=require("node:crypto"),_=require("node:fs/promises"),v=require("node:path");var y={[r.r.TABLE]:`IconTable`,[r.r.KANBAN]:`IconLayoutKanban`,[r.r.CALENDAR]:`IconCalendar`,[r.r.LIST]:`IconList`,[r.r.FIELDS_WIDGET]:`IconListDetails`,[r.r.TABLE_WIDGET]:`IconTable`,[r.r.KANBAN_WIDGET]:`IconLayoutKanban`,[r.r.LIST_WIDGET]:`IconList`,[r.r.CALENDAR_WIDGET]:`IconCalendar`},b=[`object`,`field`,`logic-function`,`front-component`,`validation-rule`],x=({name:e,objectUniversalIdentifier:t})=>`import { defineNavigationMenuItem, NavigationMenuItemType } from 'twenty-sdk/define';
|
|
2
2
|
|
|
3
3
|
export default defineNavigationMenuItem({
|
|
4
4
|
universalIdentifier: '${(0,g.randomUUID)()}',
|
package/dist/chunks/{run-app-apply-command-CD7NOdiR.cjs → run-app-apply-command-BXVHKrW3.cjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./formatBytes-CUW21d2t.cjs"),r=require("./cli-error-CrUD8uMp.cjs"),i=require("./read-command-values-l5T9Lba4.cjs"),a=require("./style-BR52fK4V.cjs"),o=require("./resolve-app-project-B4IjfcM-.cjs"),s=require("./record-pull-base-
|
|
2
|
-
`)},g=async e=>{let n=performance.now(),a=c.t(e),l,u=await s.n((await o.t({explicitPath:i.i(e.options,`path`),workingDirectory:process.cwd()})).path).catch(()=>void 0),{project:p,sdk:m,data:g,diagnostics:_}=await f.t({context:e,useHeldBuild:async t=>{l=await s.i({build:t.data,appPath:t.project.path,context:e,inferDeletionFromMissingEntities:a,isCreationApproved:i.t(e.options,`create`),isDeletionApproved:i.t(e.options,`yes`)})}});if(!t.t(l))throw new r.t({code:`TOOLING_UNSUPPORTED`,message:`The app worker did not keep its build snapshot for upload, so nothing was applied.`});let v=t.t(l.appliedActions)?c.n(l.appliedActions):void 0;t.t(v)||e.output.warn({code:`SYNC_REPORT_UNAVAILABLE`,message:`The sync succeeded, but the server did not return a readable list of its changes.`});let y;try{y=await s.t({appPath:p.path,universalIdentifier:l.acknowledgedUniversalIdentifier,sourceFingerprints:u,context:e}),y===`recorded`&&l.completedPhases.push(`pullBase`)}catch(t){throw s.r({error:t,phase:`pullBase`,applicationName:g.application.displayName,apiUrl:e.target.apiUrl,completedPhases:l.completedPhases,signal:e.signal})}let b=await d.t({appPath:p.path}),x=`skipped`;if(t.t(b))e.output.warn({code:`CLIENT_NOT_GENERATED`,message:`The app's typed API client was not regenerated: ${b}`});else try{_.push(...await d.r({appPath:p.path,applicationUniversalIdentifier:l.acknowledgedUniversalIdentifier,sdk:m,context:e})),x=`generated`,l.completedPhases.push(`clientGeneration`)}catch(t){throw s.r({error:t,phase:`clientGeneration`,applicationName:g.application.displayName,apiUrl:e.target.apiUrl,completedPhases:l.completedPhases,signal:e.signal})}let S=Math.round(performance.now()-n);return{data:{app:{path:p.path,name:p.name},sdk:{version:m.version},application:g.application,contentHash:g.contentHash,inferDeletionFromMissingEntities:a??null,registrationCreated:l.isRegistrationCreated,completedPhases:l.completedPhases,actions:l.appliedActions??null,summary:v??null,upload:{fileCount:l.upload.fileCount,byteCount:l.upload.byteCount},clientGeneration:x,pullBase:y,diagnostics:_,durationMilliseconds:S},human:h({applicationName:g.application.displayName,apiUrl:e.target.apiUrl,summary:v,upload:l.upload,isRegistrationCreated:l.isRegistrationCreated,clientGeneration:x,durationMilliseconds:S})}};exports.runAppApplyCommand=g;
|
|
1
|
+
const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./formatBytes-CUW21d2t.cjs"),r=require("./cli-error-CrUD8uMp.cjs"),i=require("./read-command-values-l5T9Lba4.cjs"),a=require("./style-BR52fK4V.cjs"),o=require("./resolve-app-project-B4IjfcM-.cjs"),s=require("./record-pull-base-DKrQDDmc.cjs"),c=require("./read-infer-deletion-option-DeyWsiCS.cjs"),l=require("./format-data-value-D_1TNU-r.cjs"),u=require("./format-app-duration-gu2oRLB4.cjs"),d=require("./get-client-generation-skip-reason-C_oaO89K.cjs"),f=require("./run-app-operation-B4JecUV7.cjs");var p=e.t(),m=({count:e,label:t,color:n})=>{let r=`${e} ${t}`;return e===0?a.i(r):a.n(n,r)},h=({applicationName:e,apiUrl:r,summary:i,upload:o,isRegistrationCreated:s,clientGeneration:c,durationMilliseconds:d})=>{let f=t.t(i)?[m({count:i.create,label:`added`,color:`green`}),m({count:i.update,label:`changed`,color:`yellow`}),m({count:i.delete,label:`deleted`,color:`red`})].join(a.i(` · `)):a.i(`changes not reported`),h=o.fileCount===1?`file`:`files`;return[a.o(`Applied ${l.r(e)} to ${r} ${a.i(`in ${u.t(d)}`)}`),` ${f}${a.i(` · ${o.fileCount} ${h} uploaded (${n.t(o.byteCount)})`)}`,s?a.i(` Registered the app and installed it in this workspace.`):``,c===`generated`?a.i(` Regenerated the typed API client.`):``].filter(p.isNonEmptyString).join(`
|
|
2
|
+
`)},g=async e=>{let n=performance.now(),a=c.t(e),l,u=await s.n((await o.t({explicitPath:i.i(e.options,`path`),workingDirectory:process.cwd()})).path).catch(()=>void 0),{project:p,sdk:m,data:g,diagnostics:_}=await f.t({context:e,useHeldBuild:async t=>{l=await s.i({build:t.data,appPath:t.project.path,context:e,inferDeletionFromMissingEntities:a,isCreationApproved:i.t(e.options,`create`),isDeletionApproved:i.t(e.options,`yes`)})}});if(!t.t(l))throw new r.t({code:`TOOLING_UNSUPPORTED`,message:`The app worker did not keep its build snapshot for upload, so nothing was applied.`});let v=t.t(l.appliedActions)?c.n(l.appliedActions):void 0;t.t(v)||e.output.warn({code:`SYNC_REPORT_UNAVAILABLE`,message:`The sync succeeded, but the server did not return a readable list of its changes.`});let y;try{y=await s.t({appPath:p.path,universalIdentifier:l.acknowledgedUniversalIdentifier,sourceFingerprints:u,appliedManifest:{frontComponents:g.manifest.frontComponents,logicFunctions:g.manifest.logicFunctions},context:e}),y===`recorded`&&l.completedPhases.push(`pullBase`)}catch(t){throw s.r({error:t,phase:`pullBase`,applicationName:g.application.displayName,apiUrl:e.target.apiUrl,completedPhases:l.completedPhases,signal:e.signal})}let b=await d.t({appPath:p.path}),x=`skipped`;if(t.t(b))e.output.warn({code:`CLIENT_NOT_GENERATED`,message:`The app's typed API client was not regenerated: ${b}`});else try{_.push(...await d.r({appPath:p.path,applicationUniversalIdentifier:l.acknowledgedUniversalIdentifier,sdk:m,context:e})),x=`generated`,l.completedPhases.push(`clientGeneration`)}catch(t){throw s.r({error:t,phase:`clientGeneration`,applicationName:g.application.displayName,apiUrl:e.target.apiUrl,completedPhases:l.completedPhases,signal:e.signal})}let S=Math.round(performance.now()-n);return{data:{app:{path:p.path,name:p.name},sdk:{version:m.version},application:g.application,contentHash:g.contentHash,inferDeletionFromMissingEntities:a??null,registrationCreated:l.isRegistrationCreated,completedPhases:l.completedPhases,actions:l.appliedActions??null,summary:v??null,upload:{fileCount:l.upload.fileCount,byteCount:l.upload.byteCount},clientGeneration:x,pullBase:y,diagnostics:_,durationMilliseconds:S},human:h({applicationName:g.application.displayName,apiUrl:e.target.apiUrl,summary:v,upload:l.upload,isRegistrationCreated:l.isRegistrationCreated,clientGeneration:x,durationMilliseconds:S})}};exports.runAppApplyCommand=g;
|
package/dist/chunks/{run-app-build-command-C8ubC2GH.cjs → run-app-build-command-BMwzOOov.cjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./formatBytes-CUW21d2t.cjs"),t=require("./style-BR52fK4V.cjs"),n=require("./format-app-duration-gu2oRLB4.cjs"),r=require("./cli-version.constant-
|
|
1
|
+
const e=require("./formatBytes-CUW21d2t.cjs"),t=require("./style-BR52fK4V.cjs"),n=require("./format-app-duration-gu2oRLB4.cjs"),r=require("./cli-version.constant-Dn-WFWf8.cjs"),i=require("./run-app-operation-B4JecUV7.cjs");var a={"built-logic-function":[`logic function`,`logic functions`],"built-front-component":[`front component`,`front components`],source:[`source file`,`source files`],dependencies:[`dependency file`,`dependency files`],"public-asset":[`asset`,`assets`]},o=Object.keys(a),s=e=>{let t=o.indexOf(e);return t===-1?o.length:t},c=e=>{let t=new Map;for(let n of e.files)t.set(n.role,(t.get(n.role)??0)+1);return[...t].sort(([e],[t])=>s(e)-s(t)).map(([e,t])=>`${t} ${(a[e]??[e,e])[t===1?0:1]}`).join(` · `)},l=({build:i,durationMilliseconds:a})=>{let o=i.files.reduce((e,t)=>e+t.size,0);return[t.o(`Built ${i.application.displayName} with twenty ${r.t} ${t.i(`in ${n.t(a)}`)}`),t.i(` ${i.files.length} files · ${e.t(o)} · content hash ${i.contentHash.slice(0,12)}`),t.i(` ${c(i)}`),t.i(` Nothing was uploaded.`)].join(`
|
|
2
2
|
`)},u=async e=>{let{project:t,sdk:n,data:r,diagnostics:a,durationMilliseconds:o}=await i.t({context:e});return{data:{app:{path:t.path,name:t.name},sdk:{version:n.version},application:r.application,contentHash:r.contentHash,files:r.files,manifestFormat:r.manifestFormat,manifest:r.manifest,diagnostics:a,durationMilliseconds:o},human:l({build:r,durationMilliseconds:o})}};exports.runAppBuildCommand=u;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./get-client-sdk-package-path-2U3kDCRq.cjs"),r=require("./is-inside-directory-CymDrDJC.cjs"),i=require("./resolve-inside-sdk-DA7EQpf0.cjs"),a=require("./read-watch-input-stamp-DKJ-Plk2.cjs"),o=require("./has-error-code-DsJeqbZq.cjs"),s=require("./cli-error-CrUD8uMp.cjs"),c=require("./resolve-source-sdk-BDwffWHb.cjs"),l=require("./create-pull-base-write-CX8xZhMz.cjs"),u=require("./read-command-values-l5T9Lba4.cjs"),d=require("./style-BR52fK4V.cjs"),f=require("./to-worker-output-diagnostics-w1hZPfn0.cjs"),p=require("./resolve-app-project-B4IjfcM-.cjs"),m=require("./with-phase-details-CRqY0f3c.cjs"),h=require("./to-cli-error-4pSpVaW9.cjs"),g=require("./record-pull-base-DKrQDDmc.cjs"),_=require("./read-infer-deletion-option-DeyWsiCS.cjs"),v=require("./read-snapshot-file-Dxla2ete.cjs"),y=require("./create-tooling-failure-0Foyei1R.cjs"),b=require("./get-client-generation-skip-reason-C_oaO89K.cjs"),x=require("./format-progress-line-BoU0vHbc.cjs");let S=require("node:events"),C=require("node:crypto"),w=require("node:fs/promises"),T=require("node:path"),E=require("node:timers"),D=require("node:module"),O=require("node:fs"),k=require("node:timers/promises"),A=require("chokidar");var j=async({build:e,appPath:t,signal:n})=>{n.throwIfAborted();let r=v.a({build:e,appPath:t}),i=(0,T.join)(t,`.twenty`,`cli`,`snapshots`);await(0,w.mkdir)(i,{recursive:!0});let a=await(0,w.mkdtemp)((0,T.join)(i,`dev-`)),o=()=>(0,w.rm)(a,{recursive:!0,force:!0});try{for(let t of e.files){n.throwIfAborted();let e=await v.t({snapshotDirectory:r,artifact:t}),i=(0,T.join)(a,t.path);await(0,w.mkdir)((0,T.dirname)(i),{recursive:!0}),await(0,w.writeFile)(i,v.n(e),{flag:`wx`,signal:n})}return n.throwIfAborted(),{build:{...e,directory:a},release:o}}catch(e){throw await o(),e}},M=async({appPath:e,signal:n,updateWatchInputs:r,warn:i})=>{let a=await c.t({appPath:e,warn:i}),o=await g.n(e).catch(()=>void 0),l;try{let i=await f.n({request:{type:`bundleSnapshot`,appPath:e,holdSnapshot:!0,collectWatchInputs:!0},signal:n,useHeldSnapshot:async({result:t})=>{let r=f.s({value:t,parseData:f.a});r.success&&(l=await j({build:r.data,appPath:e,signal:n}))}});n.throwIfAborted();let c=f.s({value:i.result,parseData:f.a}),u=[...c.diagnostics,...f.t(i.output)];if(await r(i.watchInputs??[],c.success),!c.success)throw y.t({error:c.error,diagnostics:u,sdkVersion:a.version});if(!t.t(l))throw new s.t({code:`WORKER_FAILED`,message:`The build worker did not retain its dev snapshot.`});let d=i.release;if(!t.t(d)||!f.s({value:d,parseData:e=>e===null?{data:null}:void 0}).success)throw new s.t({code:`WORKER_FAILED`,message:`The build worker could not release its source snapshot. Stop and clean up .twenty/cli/snapshots before restarting dev.`});return{...l,contentHash:l.build.contentHash,tooling:a,diagnostics:u,sourceFingerprints:o}}catch(e){throw await l?.release(),e}},N=async e=>{let t=async e=>{try{return l.i(await(0,w.readFile)(e))}catch(e){if(o.t(e,`ENOENT`))return null;throw e}},n=[`dist/core.mjs`,`dist/core.cjs`],r=(0,T.join)(e,`dist/core/generated`);try{let t=await(0,w.readdir)(r,{recursive:!0,withFileTypes:!0});for(let r of t)(r.isFile()||r.isSymbolicLink())&&n.push((0,T.relative)(e,(0,T.join)(r.parentPath,r.name)))}catch(e){if(!o.t(e,`ENOENT`))throw e}return JSON.stringify(await Promise.all(n.sort().map(async n=>[n,await t((0,T.join)(e,n))])))},P=({appPath:e})=>{let r,a,o=()=>N(n.t({appPath:e}));return async({snapshot:s,applied:c,context:l,withBuildsPaused:u,invalidate:d})=>{let f=await b.t({appPath:e});if(t.t(f))return l.output.warn({code:`CLIENT_NOT_GENERATED`,message:f}),`skipped`;let p,_,v;try{p=await b.n({applicationUniversalIdentifier:c.acknowledgedUniversalIdentifier,context:l});let r=await(0,w.realpath)(n.t({appPath:e})),a=await(0,w.readFile)((0,T.join)(r,`package.json`)),s=i.t({resolveFromApp:(0,D.createRequire)((0,T.join)(r,`package.json`)).resolve,specifier:`twenty-client-sdk/generate`,sdkPath:r});if(!t.t(s))throw Error(`The installed twenty-client-sdk has no compatible generate entry point.`);_=(0,C.createHash)(`sha256`).update(p).update(r).update(a).update(await(0,w.readFile)(s)).digest(`hex`),v=await o()}catch(e){if(l.signal.aborted)throw m.t({error:h.t(e,l.signal),phase:`clientGeneration`,outcome:`applied`,completedPhases:c.completedPhases,hint:`The app was synced. Client generation had not started, so the previous typed API client was kept.`});return l.output.warn({code:`CLIENT_NOT_GENERATED`,message:`The app was synced, but its client inputs could not be fetched: ${h.t(e).message} The previous client was kept.`}),`skipped`}if(_===r&&v===a)return`unchanged`;let y=!1;try{await u(async()=>{l.signal.throwIfAborted(),y=!0,await b.i({appPath:e,schema:p,sdk:s.tooling,context:l}),r=_,a=await o(),c.completedPhases.push(`clientGeneration`),d()})}catch(e){throw y?g.r({error:e,phase:`clientGeneration`,applicationName:s.build.application.displayName,apiUrl:l.target.apiUrl,completedPhases:c.completedPhases,signal:l.signal}):m.t({error:h.t(e,l.signal),phase:`clientGeneration`,outcome:`applied`,completedPhases:c.completedPhases,hint:`The app was synced. Client generation had not started, so the previous typed API client was kept.`})}return`generated`}},F=e.t(),I=({message:e,code:t,percentage:n})=>(0,F.isNonEmptyString)(t)?d.s(e):x.t({message:e,percentage:n}),L=e=>{let t=[],n=Promise.resolve(),r=0;return{output:{...e.output,progress:e=>{t.length<32?t.push(e):r+=1},warn:e=>{t.length<32?t.push(e):r+=1}},emit:(i,a)=>{let o=t.splice(0);r>0&&(o.push({message:`${r} additional progress messages omitted.`}),r=0);let s=n.then(async()=>{if(a.throwIfAborted(),e.outputMode===`ndjson`)await e.output.event(`progress`,{...i,messages:o},a);else{let e=[...o.map(I),i.message].filter(e=>e.length>0).join(`
|
|
2
|
+
`);process.stderr.write(`${e}\n`)||await(0,S.once)(process.stderr,`drain`,{signal:a})}});return n=s.catch(()=>void 0),s}}},R=async({signal:e,subscribe:n,build:r,apply:i,onSkipped:a,debounceMilliseconds:o=100})=>{let s=new AbortController,c,l=e=>{s.abort(e),f()},u=()=>l(e.reason),d=new Set,f=()=>{for(let e of d)e()},p=async e=>{for(;!e();)s.signal.throwIfAborted(),await new Promise(e=>{let t=()=>{d.delete(t),e()};d.add(t)});s.signal.throwIfAborted()},m=1,h=0,g,_=!1,v=!1,y=new AbortController,b,x=()=>{m+=1,y.abort(Error(`App changed while awaiting approval.`)),f()},S=async()=>{for(;!s.signal.aborted;){await p(()=>!v&&m!==h);let n=m;if(await(0,k.setTimeout)(o,void 0,{signal:s.signal}),n!==m||v)continue;h=n,_=!0;let i;try{t.t(g)&&(await g.snapshot.release(),g=void 0),i=await r(n,AbortSignal.any([e,s.signal])),t.t(i)&&(n!==m||s.signal.aborted?(await i.release(),await a(n,`superseded`)):g={snapshot:i,revision:n})}finally{_=!1,f()}}},C=async()=>{for(;!s.signal.aborted;){await p(()=>t.t(g)&&g.revision===m);let n=g;if(t.t(n)){g=void 0,y=new AbortController;try{if(n.snapshot.contentHash===b){await a(n.revision,`unchanged`);continue}b=await i(n.snapshot,{revision:n.revision,signal:AbortSignal.any([e,s.signal]),revisionSignal:AbortSignal.any([e,s.signal,y.signal]),invalidate:x,withBuildsPaused:async e=>{v=!0;try{return await p(()=>!_),await e()}finally{v=!1,f()}}})?n.snapshot.contentHash:void 0}finally{await n.snapshot.release()}}}};e.addEventListener(`abort`,u,{once:!0});let w;try{e.throwIfAborted(),w=await n(x,l);let r=[S().catch(n=>{!e.aborted&&!t.t(c)&&(c=n),l(n)}),C().catch(e=>{c=e,l(e)})];if(await Promise.all(r),t.t(c))throw c;s.signal.throwIfAborted()}finally{l(e.reason),e.removeEventListener(`abort`,u);try{await w?.()}finally{await g?.snapshot.release()}}},z=1e3,B=100,V=({input:e,onChange:n,onError:r})=>{let i,s,c,l=!1,u=a.t(e),d=()=>{(0,E.clearInterval)(c),c=void 0},f=()=>{l=!0,clearTimeout(s),i?.close(),i=void 0,d()},p=()=>{if(l)return;i?.close(),i=void 0,clearTimeout(s);try{if(e.kind===`directory`&&a.n(e.path)){f(),n();return}let t=a.t(e),c=(0,O.watch)(e.path,{persistent:!1},()=>{l||i!==c||p()});i=c,c.on(`error`,e=>{l||i!==c||(o.t(e,`EPERM`)||o.t(e,`ENOENT`)?p():(f(),r(e)))}),d(),s=setTimeout(()=>{!l&&i===c&&a.t(e)!==t&&p()},B),s.unref()}catch(e){if(o.t(e,`ENOENT`)||o.t(e,`ENOTDIR`))t.t(c)||(c=(0,E.setInterval)(p,z),c.unref());else{f(),r(h.t(e));return}}let m=a.t(e);m!==u&&(u=m,n())};return p(),f},H=(e,t)=>new Promise((n,r)=>{let i=()=>{e.off(`ready`,a),e.off(`error`,o),t.removeEventListener(`abort`,s)},a=()=>{i(),n()},o=e=>{i(),r(e)},s=()=>{i(),r(t.reason)};e.once(`ready`,a),e.once(`error`,o),t.addEventListener(`abort`,s,{once:!0}),t.aborted&&s()}),U=async({appPath:e,signal:n,onChange:i,onError:o,onWarning:s,onScopeChange:c})=>{e=await(0,w.realpath)(e);let l=(0,A.watch)(e,{ignoreInitial:!0,followSymlinks:!1,ignored:t=>(0,T.relative)(e,t).split(T.sep)[0]===`dist`||a.r((0,T.relative)(e,t)),atomic:!0}).on(`all`,i).on(`error`,o),u=[],d=new Set,f=[],p,m=async e=>{if(!t.t(c))return;let n={filePaths:e.filter(e=>e.kind===`file`).map(e=>e.path).sort(),directoryPaths:e.filter(e=>e.kind===`directory`).map(e=>e.path).sort(),excludedDirectoryPaths:[...d].sort()},r=JSON.stringify(n);r!==p&&(await c(n),p=r)},h=async()=>{for(let e of u)e();u=[],await l.close()};try{await H(l,n)}catch(e){throw await h(),e}return{close:h,update:async(t,n)=>{n&&(f=t);let c=[...f,...t].filter(t=>!a.r(t.path)&&t.path!==e&&!r.t({filePath:t.path,directory:e})),l=new Set(c.filter(e=>e.kind===`directory`&&a.n(e.path)).map(e=>e.path));for(let e of l)d.has(e)||s?.({code:`WATCH_SCOPE_LIMITED`,message:`Not watching directory ${e}. Known files there are still watched. After fixing an unresolved import there, edit an app file or restart twenty app dev.`});d=l;let p=u;u=[];let h=[...new Map(c.map(e=>[`${e.kind}:${e.path}`,e])).values()].filter(e=>e.kind!==`directory`||!d.has(e.path));for(let e of h)u.push(V({input:e,onChange:i,onError:o}));for(let e of p)e();await m(h),t.some(e=>a.t(e)!==e.stamp)&&i()}}},W=({appPath:e,scope:t})=>[`Watch scope:`,` App folder (recursive): ${e}`,...[{label:`External files`,paths:t.filePaths},{label:`External directories (shallow)`,paths:t.directoryPaths},{label:`Excluded directories`,paths:t.excludedDirectoryPaths}].flatMap(({label:e,paths:t})=>t.length>0?[` ${e}:`,...t.map(e=>` ${e}`)]:[])].join(`
|
|
3
|
+
`),G=async e=>{let n=_.t(e),r=await p.t({explicitPath:u.i(e.options,`path`),workingDirectory:process.cwd()}),{output:i,emit:a}=L(e),o=P({appPath:r.path}),c,l=!1,d=t=>a({kind:`watch-scope`,message:W({appPath:r.path,scope:t}),appPath:r.path,...t},e.signal);throw await R({signal:e.signal,subscribe:async(t,n)=>{c=await U({appPath:r.path,signal:e.signal,onChange:t,onError:n,onWarning:i.warn,onScopeChange:u.t(e.options,`verbose`)?d:void 0});try{await a({kind:`watch-ready`,message:`Watching ${r.path}. Syncing to ${e.target.apiUrl}. Press Ctrl+C to stop.`,appPath:r.path},e.signal)}catch(e){throw await c.close(),e}return c.close},build:async(t,n)=>{await a({kind:`build-start`,message:`Building app…`,revision:t},n);try{let e=await M({appPath:r.path,signal:n,updateWatchInputs:c.update,warn:e=>{l||(l=!0,i.warn(e))}});try{return await a({kind:`build-success`,message:`Built ${e.build.application.displayName}.`,revision:t,buildId:e.build.buildId,contentHash:e.contentHash,diagnostics:e.diagnostics},n),e}catch(t){throw await e.release(),t}}catch(r){n.throwIfAborted();let o=h.t(r);if(o.code===`WORKER_FAILED`)throw new s.t({code:o.code,message:o.message,details:o.details,hint:`Fix the worker failure, then restart twenty app dev. A worker killed while building may leave folders in .twenty/cli/snapshots; remove abandoned snapshots only after stopping all dev/apply sessions for this app.`});if(![`TYPECHECK_FAILED`,`BUILD_FAILED`,`SDK_NOT_INSTALLED`,`SDK_SOURCE_UNSUPPORTED`,`TYPESCRIPT_NOT_INSTALLED`].includes(o.code))throw r;let c=o.details?.diagnostics;if(e.outputMode===`human`&&Array.isArray(c))for(let e of c.filter(f.i))i.progress({message:f.c(e)});await a({kind:`build-failure`,message:`${o.message} Waiting for source changes.`,revision:t,error:{code:o.code,message:o.message,details:o.details}},n);return}},apply:async(s,c)=>{let{revision:l,signal:d}=c,f={...e,output:i,signal:d},p=!1;await a({kind:`sync-start`,message:`Planning changes…`,revision:l,buildId:s.build.buildId},d);let m;try{m=await g.i({build:s.build,appPath:r.path,context:f,inferDeletionFromMissingEntities:n,isCreationApproved:u.t(e.options,`create`),isDeletionApproved:u.t(e.options,`yes`),approvalSignal:c.revisionSignal,flushProgress:()=>a({kind:`sync-progress`,message:``,revision:l},d),beforeWrite:()=>{p||c.revisionSignal.throwIfAborted(),p=!0}})}catch(e){if(d.aborted)throw e;let t=h.t(e);if(c.revisionSignal.aborted&&t.details?.phase===`confirmation`)return await a({kind:`sync-superseded`,message:`Source changed; a fresh plan is queued.`,revision:l,details:t.details},d),!1;if([`AUTH_REQUIRED`,`PERMISSION_DENIED`].includes(t.code))throw e;return await a({kind:`sync-failure`,message:`${t.message} A new source edit will request a fresh plan.`,revision:l,error:{code:t.code,message:t.message,hint:t.hint,details:t.details}},d),!1}try{await g.t({appPath:r.path,universalIdentifier:m.acknowledgedUniversalIdentifier,sourceFingerprints:s.sourceFingerprints,appliedManifest:{frontComponents:s.build.manifest.frontComponents,logicFunctions:s.build.manifest.logicFunctions},context:f})===`recorded`&&m.completedPhases.push(`pullBase`)}catch(t){throw g.r({error:t,phase:`pullBase`,applicationName:s.build.application.displayName,apiUrl:e.target.apiUrl,completedPhases:m.completedPhases,signal:d})}let _=await o({snapshot:s,applied:m,context:f,withBuildsPaused:c.withBuildsPaused,invalidate:c.invalidate});return t.t(m.appliedActions)||i.warn({code:`SYNC_REPORT_UNAVAILABLE`,message:`The sync succeeded, but the server did not return a readable list of changes.`}),await a({kind:`sync-success`,message:`Synced ${s.build.application.displayName}. Watching for changes…`,revision:l,buildId:s.build.buildId,contentHash:s.contentHash,completedPhases:m.completedPhases,clientGeneration:_,actions:m.appliedActions??null},d),!0},onSkipped:(t,n)=>a({kind:`build-skipped`,message:n===`unchanged`?`Build unchanged since the last acknowledged sync.`:`Source changed during the build; rebuilding…`,revision:t,reason:n},e.signal)}),new s.t({code:`INTERNAL_ERROR`,message:`The dev session stopped unexpectedly.`})};exports.runAppDevCommand=G;
|
|
@@ -1,3 +1,3 @@
|
|
|
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("./resolve-source-sdk-
|
|
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("./resolve-source-sdk-BDwffWHb.cjs"),o=require("./is-same-universal-identifier-Bm_wb6Ez.cjs"),s=require("./is-exported-manifest-BHA_mGa6.cjs"),c=require("./read-command-values-l5T9Lba4.cjs"),l=require("./read-input-value-CzJsE62r.cjs"),u=require("./parse-json-input-DxGKbeED.cjs"),d=require("./request-timeout-milliseconds.constant-BkZTOtpY.cjs"),f=require("./style-BR52fK4V.cjs"),p=require("./to-worker-output-diagnostics-w1hZPfn0.cjs"),m=require("./resolve-app-project-B4IjfcM-.cjs"),h=require("./to-cli-error-4pSpVaW9.cjs"),g=require("./is-application-not-found-error-CQ7k4hGU.cjs"),_=require("./create-metadata-client-CrOsu4u3.cjs"),v=require("./format-data-value-D_1TNU-r.cjs"),y=require("./create-tooling-failure-0Foyei1R.cjs"),b=require("./create-app-not-installed-error-sN4TzjlV.cjs"),x=require("./format-details-COEwKz_M.cjs");var S=e.t(),C=e=>n.t(e)&&(0,S.isString)(e.id)&&(0,S.isString)(e.name)&&((0,S.isString)(e.universalIdentifier)||e.universalIdentifier===null)&&((0,S.isString)(e.applicationId)||e.applicationId===null)&&(0,S.isNumber)(e.timeoutSeconds)&&Number.isFinite(e.timeoutSeconds)&&e.timeoutSeconds>=0&&Math.ceil(e.timeoutSeconds*1e3)+6e4<2**31,w=()=>new i.t({code:`INVALID_RESPONSE`,message:`The server returned an invalid logic-function response.`}),T=e=>{if([`AUTH_REQUIRED`,`PERMISSION_DENIED`].includes(e.code))return!0;let t=e.details?.errors;return e.code===`GRAPHQL_ERROR`&&(0,S.isArray)(t)&&t.length>0&&t.every(e=>n.t(e)&&(0,S.isString)(e.code)&&[`NOT_FOUND`,`BAD_USER_INPUT`,`GRAPHQL_VALIDATION_FAILED`].includes(e.code))},E=async({manifest:e,selector:r,payload:a,target:s,signal:c,onExecuting:l})=>{let u=_.t({target:s,signal:c}),{applicationUniversalIdentifier:f}=e,{findOneApplication:p,findManyLogicFunctions:m}=await u.query({findOneApplication:{__args:{universalIdentifier:f},id:!0,universalIdentifier:!0},findManyLogicFunctions:{id:!0,name:!0,universalIdentifier:!0,applicationId:!0,timeoutSeconds:!0}}).catch(e=>{throw g.t({error:e,field:`findOneApplication`})?b.t({universalIdentifier:f,apiUrl:s.apiUrl}):e});if(!n.t(p)||!(0,S.isString)(p.id)||!o.t({value:p.universalIdentifier,universalIdentifier:f})||!(0,S.isArray)(m)||!m.every(C))throw w();let v=m.filter(n=>n.applicationId===p.id&&t.t(n.universalIdentifier)&&e.universalIdentifiers.includes(n.universalIdentifier.toLowerCase())),y=r.kind===`hook`?e.hooks[r.value]:r.value,x=v.filter(e=>t.t(y)&&(r.kind===`name`?e.name===y:e.universalIdentifier?.toLowerCase()===y));if(x.length===0)throw new i.t({code:`NOT_FOUND`,exitCode:i.n.NOT_FOUND,message:`Function "${r.value}" was not found in the deployed app.`,hint:`Check the selected workspace and function. Run twenty app apply or twenty app dev to sync local changes first.`,details:{identifier:r.value,availableFunctions:v.map(({name:e,universalIdentifier:t})=>({name:e,universalIdentifier:t}))}});if(x.length>1)throw new i.t({code:`AMBIGUOUS_RESOURCE`,exitCode:i.n.CONFLICT,message:`More than one app function matches "${r.value}".`,hint:`Select a function with --universal-identifier.`});let E=x[0],D={applicationUniversalIdentifier:f,functionName:E.name,functionUniversalIdentifier:E.universalIdentifier};l(E.name),c.throwIfAborted();let O=_.t({target:s,signal:c,timeoutMilliseconds:Math.ceil(E.timeoutSeconds*1e3)+d.t});try{let{executeOneLogicFunction:e}=await O.mutation({executeOneLogicFunction:{__args:{input:{id:E.id,payload:a}},data:!0,logs:!0,duration:!0,status:!0,error:!0}});if(!n.t(e)||!(0,S.isString)(e.status)||!(0,S.isString)(e.logs)||!(0,S.isNumber)(e.duration)||!Number.isFinite(e.duration)||e.duration<0)throw w();return{...D,status:e.status,durationMilliseconds:e.duration,data:e.data??null,logs:e.logs,error:e.error??null}}catch(e){let t=h.t(e,c),n=T(t);throw new i.t({code:t.code,exitCode:t.exitCode,message:t.message,hint:n?t.hint:`Execution may have started and may still be running. Check its effects before retrying; this command does not retry or stop server-side execution.`,details:{...t.details,...D,outcome:n?`not-started`:`unknown`}})}},D=e=>JSON.stringify(e,null,2).replace(/[\x7f-\x9f]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`),O=(e,t=process.stdout)=>[x.t([[`Function`,v.r(e.functionName)],[`Status`,f.n(e.status===`SUCCESS`?`green`:`red`,v.r(e.status),t)],[`Duration`,f.i(`${e.durationMilliseconds}ms`,t)]],t),...e.data===null?[]:[``,f.t(`Data:`,t),D(e.data)],...e.error===null?[]:[``,f.t(`Error:`,t),D(e.error)],...e.logs.length>0?[``,f.t(`Logs:`,t),...e.logs.split(`
|
|
2
2
|
`).map(v.r)]:[]].join(`
|
|
3
3
|
`),k=async({options:e,output:r,outputMode:i,signal:o})=>{let l=await m.t({explicitPath:c.i(e,`path`),workingDirectory:process.cwd()}),u=await a.t({appPath:l.path,warn:r.warn});r.progress({message:`Reading app definitions in ${l.path}…`});let d=await p.n({request:{type:`buildManifest`,appPath:l.path},signal:o});o.throwIfAborted();let f=p.s({value:d.result,parseData:e=>{if(!n.t(e)||!s.t(e.manifest))return;let{manifest:r}=e;if(!(0,S.isArray)(r.logicFunctions))return;let i=[];for(let e of r.logicFunctions){if(!n.t(e)||!(0,S.isString)(e.universalIdentifier))return;i.push(e.universalIdentifier.toLowerCase())}let a={};for(let e of[`postInstallLogicFunction`,`preInstallLogicFunction`,`uninstallLogicFunction`]){let i=r.application[e];if(t.t(i)){if(!n.t(i)||!(0,S.isString)(i.universalIdentifier))return;a[e]=i.universalIdentifier.toLowerCase()}}return{data:{applicationUniversalIdentifier:r.application.universalIdentifier.toLowerCase(),universalIdentifiers:i,hooks:a}}}}),h=[...f.diagnostics,...p.t(d.output)];if(i===`human`)for(let e of h)r.progress({message:p.c(e)});if(!f.success)throw y.t({error:f.error,diagnostics:h,sdkVersion:u.version});return{...f.data,diagnostics:h}},A=e=>{let n=[],a=c.i(e,`name`),o=c.i(e,`universalIdentifier`);if(t.t(a)&&n.push({kind:`name`,value:a}),t.t(o)&&n.push({kind:`universalIdentifier`,value:o.toLowerCase()}),c.t(e,`postInstall`)&&n.push({kind:`hook`,value:`postInstallLogicFunction`}),c.t(e,`preInstall`)&&n.push({kind:`hook`,value:`preInstallLogicFunction`}),c.t(e,`uninstallHook`)&&n.push({kind:`hook`,value:`uninstallLogicFunction`}),n.length!==1)throw new i.t({code:`INVALID_INPUT`,exitCode:i.n.USAGE,message:`Choose exactly one of --name, --universal-identifier, --post-install, --pre-install or --uninstall-hook.`});let s=n[0];if(s.value.trim().length===0||s.kind===`universalIdentifier`&&!r.t(s.value))throw new i.t({code:`INVALID_INPUT`,exitCode:i.n.USAGE,message:s.kind===`name`?`--name cannot be empty.`:`--universal-identifier must be a UUID of version 4 or later.`});return s},j=async e=>{let{options:t,target:n,signal:r,output:a,outputMode:o}=e,s=A(t);if(n.credentialKind!==`oauth`)throw new i.t({code:`AUTH_REQUIRED`,exitCode:i.n.AUTHENTICATION,message:`Running logic functions requires a signed-in user. API keys cannot execute them.`,hint:`Sign in with twenty auth login --url ${n.apiUrl} --name dev, then use --remote dev.`,details:{credentialKind:n.credentialKind}});let d=u.n({text:await l.t({value:c.i(t,`payload`)??`{}`,optionName:`--payload`,signal:r}),optionName:`--payload`}),f=await k(e);s.kind===`hook`&&a.progress({message:`Executing the hook only; this does not install or uninstall the app.`});let p=await E({manifest:f,selector:s,payload:d,target:n,signal:r,onExecuting:e=>a.progress({message:`Executing ${v.r(e)} on ${n.apiUrl}…`})}),m=O(p,p.status===`SUCCESS`?process.stdout:process.stderr);if(p.status!==`SUCCESS`)throw o===`human`&&a.progress({message:m}),new i.t({code:`EXECUTION_FAILED`,message:`Function ${v.r(p.functionName)} returned ${v.r(p.status)}.`,details:{...p,outcome:`completed`,diagnostics:f.diagnostics}});return{data:{...p,diagnostics:f.diagnostics},human:m}};exports.runAppExecCommand=j;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./isDefined-CJctgvfE.cjs"),t=require("./get-client-sdk-package-path-2U3kDCRq.cjs"),n=require("./cli-error-CrUD8uMp.cjs"),r=require("./resolve-source-sdk-
|
|
1
|
+
const e=require("./isDefined-CJctgvfE.cjs"),t=require("./get-client-sdk-package-path-2U3kDCRq.cjs"),n=require("./cli-error-CrUD8uMp.cjs"),r=require("./resolve-source-sdk-BDwffWHb.cjs"),i=require("./read-command-values-l5T9Lba4.cjs"),a=require("./style-BR52fK4V.cjs"),o=require("./to-worker-output-diagnostics-w1hZPfn0.cjs"),s=require("./read-app-identity-M47izSWp.cjs"),c=require("./resolve-app-project-B4IjfcM-.cjs"),l=require("./is-application-not-found-error-CQ7k4hGU.cjs"),u=require("./get-client-generation-skip-reason-C_oaO89K.cjs"),d=require("./create-app-not-installed-error-sN4TzjlV.cjs"),f=require("./format-display-path-CZLIKwPT.cjs");var p=async p=>{let{options:m,output:h,outputMode:g,signal:_,target:v}=p,y=performance.now(),b=process.cwd(),x=await c.t({explicitPath:i.i(m,`path`),workingDirectory:b}),S=await u.t({appPath:x.path});if(e.t(S))throw new n.t({code:`CLIENT_SDK_NOT_INSTALLED`,message:`The typed API client cannot be generated: ${S}`,hint:`Install twenty-client-sdk in the app, for example with yarn add twenty-client-sdk, then try again.`,details:{appPath:x.path}});let C=await s.t({appPath:x.path,signal:_});if(!e.t(C.application))throw new n.t({code:`INVALID_INPUT`,exitCode:n.n.USAGE,message:`This project has no application definition.`});let w=C.application.universalIdentifier.toLowerCase();if(g===`human`)for(let e of C.diagnostics)h.progress({message:o.c(e)});let T=await r.t({appPath:x.path}),E=await u.r({appPath:x.path,applicationUniversalIdentifier:w,sdk:T,context:p}).catch(e=>{throw l.t({error:e,field:`applicationCoreGraphqlSchema`})?d.t({universalIdentifier:w,apiUrl:v.apiUrl,hint:`Install it with twenty app apply, which also generates the client.`}):e}),D=t.t({appPath:x.path}),O=f.t({workingDirectory:b,targetPath:D});return{data:{app:{path:x.path,name:x.name},sdk:{version:T.version},client:{path:D},application:C.application,diagnostics:[...C.diagnostics,...E],durationMilliseconds:Math.round(performance.now()-y)},human:[a.o(`Generated the typed API client for ${C.application.displayName??x.name} from ${v.apiUrl}`),` Saved in ${a.n(`cyan`,O)}`].join(`
|
|
2
2
|
`)}};exports.runAppGenerateClientCommand=p;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./cli-error-CrUD8uMp.cjs"),r=require("./read-command-values-l5T9Lba4.cjs"),i=require("./convert-to-label-CI8cZyg_.cjs"),a=require("./style-BR52fK4V.cjs"),o=require("./format-display-path-CZLIKwPT.cjs"),s=require("./is-valid-package-name-
|
|
1
|
+
const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./cli-error-CrUD8uMp.cjs"),r=require("./read-command-values-l5T9Lba4.cjs"),i=require("./convert-to-label-CI8cZyg_.cjs"),a=require("./style-BR52fK4V.cjs"),o=require("./format-display-path-CZLIKwPT.cjs"),s=require("./is-valid-package-name-o_jWsuUX.cjs"),c=require("./select-target-Ck9mdMLQ.cjs"),l=require("./get-config-path-C-D-QHuX.cjs"),u=require("./read-config-6GnzcpJm.cjs");let d=require("node:path");var f=e.t(),p=({appName:e,location:t,packageNames:n,packageVersion:r,nextSteps:i})=>{let o=Math.max(...i.map(({command:e})=>e.length));return[a.o(`Created ${e} in ${t}`),a.i(` ${c.n(n)} pinned to ${r}. Nothing was installed.`),``,a.t(`Next steps`),...i.map(({command:e,description:t})=>` ${a.r(e.padEnd(o))} ${a.i(`# ${t}`)}`)].join(`
|
|
2
2
|
`)},m=/^[\w./-]+$/,h=e=>m.test(e)?e:process.platform===`win32`?`'${e.replace(/'/g,`''`)}'`:`'${e.replace(/'/g,`'\\''`)}'`,g=({displayPath:e,isTargetConfigured:n,remoteName:r})=>{let i=t.t(r)?` --remote ${h(r)}`:``;return[...e===`.`?[]:[{command:`cd ${h(e.startsWith(`-`)?`./${e}`:e)}`,description:`Enter the new app`}],{command:`yarn install`,description:`Install the pinned dependencies`},...n?[]:[{command:`twenty auth login --url <url>${t.t(r)?` --name ${h(r)}`:``}`,description:`Connect a workspace`}],{command:`twenty app apply --create${i}`,description:`Build the app and install it in your workspace`}].map(e=>({...e,description:process.platform===`win32`?`${e.description} (PowerShell)`:e.description}))},_=({environment:e,remoteFlag:t})=>c.t({environment:e,remoteFlag:t,loadConfig:()=>u.t(l.t()),warn:()=>void 0}).then(()=>!0,()=>!1),v=async({arguments:e,options:t,output:a,signal:c})=>{let l=r.n(e,0)?.trim()??``;if(!s.t(l))throw new n.t({code:`INVALID_APP_NAME`,exitCode:n.n.USAGE,message:`"${l}" is not a valid package name.`,hint:`Use lowercase letters, digits, hyphens, dots or underscores, for example my-app.`});let u=process.cwd(),m=(0,d.resolve)(u,r.i(t,`path`)??(0,d.basename)(l)),h=r.i(t,`displayName`)?.trim(),v=(0,f.isNonEmptyString)(h)?h:i.t(l),y=r.i(t,`description`)?.trim()??``,b=o.t({workingDirectory:u,targetPath:m}),x=b===`.`?`the current directory`:b;a.progress({message:`Creating ${l} in ${x}…`}),await s.n({appDirectory:m,appName:l,appDisplayName:v,appDescription:y,signal:c});let S=r.i(t,`remote`),C=g({displayPath:b,isTargetConfigured:await _({environment:process.env,remoteFlag:S}),remoteName:S}),w=[...s.r];return process.platform===`win32`&&a.warn({code:`PLATFORM_UNSUPPORTED`,message:`Building apps is only supported on macOS and Linux. On Windows, work inside WSL 2.`}),{data:{app:{name:l,displayName:v,description:y,path:m},packages:w.map(e=>({name:e,version:s.i})),nextSteps:C},human:p({appName:l,location:x,packageNames:w,packageVersion:s.i,nextSteps:C})}};exports.runAppInitCommand=v;
|
package/dist/chunks/{run-app-install-command-DlcUupwk.cjs → run-app-install-command-CsK8l0Ou.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
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("./style-BR52fK4V.cjs"),a=require("./with-phase-details-CRqY0f3c.cjs"),o=require("./to-cli-error-4pSpVaW9.cjs"),s=require("./create-metadata-client-
|
|
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("./style-BR52fK4V.cjs"),a=require("./with-phase-details-CRqY0f3c.cjs"),o=require("./to-cli-error-4pSpVaW9.cjs"),s=require("./create-metadata-client-CrOsu4u3.cjs"),c=require("./format-data-value-D_1TNU-r.cjs"),l=require("./read-application-identifier-BlEwa2gR.cjs");let u=require("node:timers/promises");var d=new Set([`AUTH_REQUIRED`,`PERMISSION_DENIED`,`NOT_FOUND`]),f=({phase:e,code:t})=>e===`identity`||e===`start`&&d.has(t)?`not-started`:t===`INSTALL_FAILED`?`failed`:`unknown`,p=({outcome:e,phase:t})=>t===`identity`?`Fix the app source or identifier, then retry. No installation was started.`:e===`not-started`?`Check the target workspace, registration and APPLICATIONS permission before retrying.`:`Run twenty app install again to retry or resume waiting for the current installation. Stopping the CLI does not cancel the server job.`,m=({error:e,phase:n,completedPhases:i,universalIdentifier:s,jobId:c,signal:l})=>{let u=o.t(e,l),d=f({phase:n,code:u.code});return a.t({error:new r.t({cause:u,code:u.code,exitCode:u.exitCode,message:u.message,hint:u.hint,details:{...u.details,...t.t(s)?{universalIdentifier:s}:{},...t.t(c)?{jobId:c}:{}}}),phase:n,outcome:d,completedPhases:i,hint:p({outcome:d,phase:n})})},h=e.t(),g={POLL_INTERVAL_MILLISECONDS:1e3,TIMEOUT_MILLISECONDS:6e5},_=e=>(0,h.isNumber)(e)&&Number.isInteger(e)&&e>=0&&e<=100,v=async({universalIdentifier:e,jobId:i,target:a,signal:o,onProgress:c})=>{let l=s.t({target:a,signal:o}),d=0;for(;;){o.throwIfAborted();let a=(await l.query({__name:`FindInstallApplicationJobStatus`,findInstallApplicationJobStatus:{__args:{universalIdentifier:e,jobId:i},jobId:!0,state:!0,failedReason:!0,progress:!0}}))?.findInstallApplicationJobStatus;if(!n.t(a)||a.jobId!==i||!Object.values(s.n.enumJobState).includes(a.state)||t.t(a.progress)&&!_(a.progress))throw new r.t({code:`INVALID_RESPONSE`,message:`The server did not return the status of the requested installation job.`});if(a.state===`FAILED`)throw new r.t({code:`INSTALL_FAILED`,message:(0,h.isNonEmptyString)(a.failedReason)?a.failedReason:`The app installation job failed.`});let f=a.state===`COMPLETED`?100:a.progress??d;if(f!==d&&(d=f,c(f)),a.state===`COMPLETED`)break;await(0,u.setTimeout)(g.POLL_INTERVAL_MILLISECONDS,void 0,{signal:o})}},y=async({universalIdentifier:e,completedPhases:t,target:i,signal:a,onProgress:o})=>{let c=AbortSignal.timeout(g.TIMEOUT_MILLISECONDS),u=AbortSignal.any([a,c]),d=s.t({target:i,signal:u}),f=(n,i,o)=>m({error:c.aborted&&!a.aborted?new r.t({code:`TIMEOUT`,message:`Timed out waiting for the app installation after ${g.TIMEOUT_MILLISECONDS/1e3}s.`}):n,phase:i,completedPhases:t,universalIdentifier:e,jobId:o,signal:a}),p=await d.mutation({__name:`TriggerInstallApplication`,triggerInstallApplication:{__args:{input:{universalIdentifier:e}},jobId:!0}}).then(e=>{let t=e?.triggerInstallApplication;if(!n.t(t)||!(0,h.isNonEmptyString)(t.jobId))throw new r.t({code:`INVALID_RESPONSE`,message:`The server did not return an installation job identifier.`});return t.jobId}).catch(e=>{throw f(e,`start`)});return t.push(`start`),await v({universalIdentifier:e,jobId:p,target:i,signal:u,onProgress:o}).catch(e=>{throw f(e,`wait`,p)}),t.push(`wait`),{application:{universalIdentifier:e,name:(await l.n({universalIdentifier:e,target:i,signal:u}).catch(e=>{throw f(e,`check`,p)})).name},installed:!0,jobId:p}},b=async e=>{let{target:t,signal:n,output:r}=e,a=[],o=await l.t({context:e,onIdentityRead:()=>a.push(`identity`)}).catch(e=>{throw m({error:e,phase:`identity`,completedPhases:a,signal:n})}),s=`Installing the registered app on ${t.apiUrl}…`;r.progress({message:s,percentage:0});let u=await y({universalIdentifier:o,completedPhases:a,target:t,signal:n,onProgress:e=>r.progress({message:s,percentage:e})});return{data:u,human:i.o(`Installed ${c.r(u.application.name)} on ${t.apiUrl}`)}};exports.runAppInstallCommand=b;
|
|
@@ -1,4 +1,4 @@
|
|
|
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("./read-command-values-l5T9Lba4.cjs"),o=require("./style-BR52fK4V.cjs"),s=require("./to-worker-output-diagnostics-w1hZPfn0.cjs"),c=require("./read-app-identity-
|
|
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("./read-command-values-l5T9Lba4.cjs"),o=require("./style-BR52fK4V.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("./to-cli-error-4pSpVaW9.cjs"),d=require("./format-data-value-D_1TNU-r.cjs"),f=require("./subscribe-graphql-w-Ar4hCj.cjs"),p=require("./to-public-target-BltDNpJN.cjs");let m=require("node:events");var h=e=>{let n=a.i(e,`name`),o=a.i(e,`universalIdentifier`);if(t.t(n)&&t.t(o)||t.t(n)&&n.trim().length===0||t.t(o)&&!r.t(o))throw new i.t({code:`INVALID_INPUT`,exitCode:i.n.USAGE,message:`Use either a nonempty --name or a UUID of version 4 or later for --universal-identifier, or neither to watch every function in the app.`});return{...t.t(n)?{name:n}:{},...t.t(o)?{universalIdentifier:o.toLowerCase()}:{}}},g=e.t(),_=e=>{if(!(e instanceof i.t)||e.code!==`GRAPHQL_ERROR`)return!1;let r=e.details?.errors;return(0,g.isArray)(r)&&r.length>0&&r.every(e=>n.t(e)&&(!t.t(e.code)||e.code===`GRAPHQL_VALIDATION_FAILED`)&&(0,g.isString)(e.message)&&/Cannot query field "(?:name|universalIdentifier)" on type "LogicFunctionLogs"/.test(e.message))},v=async({applicationUniversalIdentifier:e,filter:r,target:a,signal:o,onConnected:s,onIdentityUnavailable:c,onRecord:l})=>{let u=0,d=c=>f.t({interruptionHint:`Restart twenty app logs to resume watching. Logs produced while disconnected cannot be replayed.`,target:a,signal:o,query:`subscription SubscribeToLogs($input: LogicFunctionLogsInput!) {
|
|
2
2
|
logicFunctionLogs(input: $input) {
|
|
3
3
|
logs
|
|
4
4
|
${c?`name universalIdentifier`:``}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./isDefined-CJctgvfE.cjs"),t=require("./isPlainObject-fJEJm71P.cjs"),n=require("./resolve-source-sdk-
|
|
1
|
+
const e=require("./isDefined-CJctgvfE.cjs"),t=require("./isPlainObject-fJEJm71P.cjs"),n=require("./resolve-source-sdk-BDwffWHb.cjs"),r=require("./read-command-values-l5T9Lba4.cjs"),i=require("./to-worker-output-diagnostics-w1hZPfn0.cjs"),a=require("./resolve-app-project-B4IjfcM-.cjs"),o=require("./create-tooling-failure-0Foyei1R.cjs"),s=require("./cli-version.constant-Dn-WFWf8.cjs");var c={build:`Building`,typecheck:`Typechecking`},l=({release:e,isSnapshotHeld:n})=>n?!t.t(e)||e.success!==!0:t.t(e)&&e.success===!1,u=async({operation:t,parseData:u,context:{options:d,output:f,outputMode:p,signal:m},useHeldBuild:h})=>{let g=await a.t({explicitPath:r.i(d,`path`),workingDirectory:process.cwd()}),_=await n.t({appPath:g.path,warn:f.warn});f.progress({message:`${c[t]} ${g.name} with twenty ${s.t}…`});let v=performance.now(),y=({result:e,output:t})=>{let n=i.s({value:e,parseData:u}),r=[...n.diagnostics,...i.t(t)];if(p===`human`)for(let e of r)f.progress({message:i.c(e)});if(!n.success)throw o.t({error:n.error,diagnostics:r,sdkVersion:_.version});return{data:n.data,diagnostics:r}},b,x=await i.n({request:t===`build`?{type:`bundleSnapshot`,appPath:g.path,holdSnapshot:e.t(h)}:{type:`typecheckSource`,appPath:g.path},signal:m,...e.t(h)?{useHeldSnapshot:async e=>{b=y(e),await h({project:g,sdk:_,...b})}}:{}});e.t(b)||m.throwIfAborted();let{data:S,diagnostics:C}=b??y(x);return l(x)&&f.warn({code:`SNAPSHOT_RELEASE_FAILED`,message:`The temporary build snapshot could not be removed. You can delete .twenty/cli/snapshots once no build is running.`}),{project:g,sdk:_,data:S,diagnostics:C,durationMilliseconds:Math.round(performance.now()-v)}},d=({context:e,useHeldBuild:t})=>u({operation:`build`,parseData:i.a,context:e,useHeldBuild:t}),f=({context:e})=>u({operation:`typecheck`,parseData:i.o,context:e});Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./read-infer-deletion-option-
|
|
1
|
+
const e=require("./read-infer-deletion-option-DeyWsiCS.cjs"),t=require("./run-app-operation-B4JecUV7.cjs");var n=async n=>{let r=performance.now(),i=e.t(n),{project:a,sdk:o,data:s,diagnostics:c}=await t.t({context:n});n.output.progress({message:`Computing metadata plan (read-only, nothing will be applied)…`});let l=await e.a({build:s,inferDeletionFromMissingEntities:i,target:n.target,signal:n.signal}),u=e.n(l);return{data:{app:{path:a.path,name:a.name},sdk:{version:o.version},application:s.application,contentHash:s.contentHash,plan:!0,inferDeletionFromMissingEntities:i??null,actions:l,summary:u,diagnostics:c,durationMilliseconds:Math.round(performance.now()-r)},human:e.r({applicationName:s.application.displayName,apiUrl:n.target.apiUrl,actions:l,summary:u,inferDeletionFromMissingEntities:i})}};exports.runAppPlanCommand=n;
|
package/dist/chunks/{run-app-publish-command-BGNJVIBl.cjs → run-app-publish-command-ClsjL5OP.cjs}
RENAMED
|
@@ -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("./cli-error-CrUD8uMp.cjs"),a=require("./read-command-values-l5T9Lba4.cjs"),o=require("./create-cancelled-error-BBhAY8fS.cjs"),s=require("./is-interaction-allowed-BQLOG8RG.cjs"),c=require("./style-BR52fK4V.cjs"),l=require("./with-phase-details-CRqY0f3c.cjs"),u=require("./to-cli-error-4pSpVaW9.cjs"),d=require("./create-metadata-client-
|
|
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("./cli-error-CrUD8uMp.cjs"),a=require("./read-command-values-l5T9Lba4.cjs"),o=require("./create-cancelled-error-BBhAY8fS.cjs"),s=require("./is-interaction-allowed-BQLOG8RG.cjs"),c=require("./style-BR52fK4V.cjs"),l=require("./with-phase-details-CRqY0f3c.cjs"),u=require("./to-cli-error-4pSpVaW9.cjs"),d=require("./create-metadata-client-CrOsu4u3.cjs"),f=require("./read-snapshot-file-Dxla2ete.cjs"),p=require("./run-app-operation-B4JecUV7.cjs"),m=require("./to-public-target-BltDNpJN.cjs"),h=require("./resolve-command-target-B9QG8OZs.cjs"),g=require("./execa-CAd0sJ7f.cjs");let _=require("node:fs/promises"),v=require("node:path"),y=require("node:fs");var b=`dependencies/yarn.lock`,x=t.t(),S=async({packedApp:e,context:{target:t,signal:a,output:o}})=>{let s=`prepare-upload`,c=[],p;try{a.throwIfAborted();let{size:n}=await(0,_.stat)(e.path),l=d.t({target:t,signal:a}),u=(await l.mutation({__name:`CreateAppTarballUpload`,createFileUpload:{__args:{filename:(0,v.basename)(e.path),size:n,fileFolder:`AppTarball`},fileId:!0,uploadUrl:!0,contentType:!0}})).createFileUpload;if(!r.t(u)||!(0,x.isNonEmptyString)(u.fileId)||!(0,x.isNonEmptyString)(u.uploadUrl)||!(0,x.isNonEmptyString)(u.contentType))throw new i.t({code:`INVALID_RESPONSE`,message:`The server returned an invalid tarball upload target.`});p=u.fileId,c.push(s),s=`upload`,o.progress({message:`Uploading ${e.name}@${e.version} to ${t.apiUrl}…`});let h=await f.r({target:t,uploadUrl:u.uploadUrl,contentType:u.contentType,bytes:await(0,y.openAsBlob)(e.path),signal:a});if(h<200||h>=300)throw new i.t({code:`UPLOAD_FAILED`,message:`File storage answered ${h}.`});c.push(s),a.throwIfAborted(),o.progress({message:`Registering the uploaded app…`}),s=`register`;let g=(await l.mutation({__name:`CompleteAppTarballUpload`,completeAppTarballUpload:{__args:{fileId:p},id:!0,name:!0,universalIdentifier:!0}})).completeAppTarballUpload;if(!r.t(g)||!(0,x.isNonEmptyString)(g.id)||!(0,x.isNonEmptyString)(g.name)||!(0,x.isNonEmptyString)(g.universalIdentifier))throw new i.t({code:`INVALID_RESPONSE`,message:`The server did not return the published app registration.`});return c.push(s),{target:`private`,registry:m.t(t),name:e.name,version:e.version,registration:g,fileId:p,installed:!1}}catch(e){let r=l.t({error:u.t(e,a),phase:s,completedPhases:c,outcome:s===`register`?`unknown`:`not-published`,hint:s===`register`?`The app may already be registered. Check the server registry before retrying; publishing does not install the app.`:`Fix the problem, then run twenty app publish --private again to create a fresh upload.`});throw new i.t({cause:r,code:r.code,exitCode:r.exitCode,message:r.message,hint:r.hint,details:{...r.details,...n.t(p)?{fileId:p}:{},registry:m.t(t)}})}},C=e.r(g.t()),w=async({args:e,appPath:t,signal:r,canInteract:a=!1,onOutput:s})=>{r.throwIfAborted();let c=(0,C.default)(`npm`,e,{cwd:t,stdio:a?`inherit`:[`ignore`,`pipe`,`pipe`],reject:!1,maxBuffer:4*1024*1024}),l=()=>c.kill(`SIGTERM`,{forceKillAfterTimeout:1e3});r.addEventListener(`abort`,l,{once:!0}),r.aborted&&l();try{let t=await c;if(r.aborted)throw o.t();if(!a&&n.t(s)&&((0,x.isNonEmptyString)(t.stdout)&&s(t.stdout),(0,x.isNonEmptyString)(t.stderr)&&s(t.stderr)),t.failed)throw new i.t({code:`PUBLISH_FAILED`,message:`npm ${e[0]} failed.`,hint:`Check that npm is installed and your npm registry credentials and package version are valid.`,details:{exitCode:t.exitCode,stdout:t.stdout?.slice(-16384)??``,stderr:t.stderr?.slice(-16384)??``}});return t.stdout??``}finally{r.removeEventListener(`abort`,l)}},T=async({packedApp:e,appPath:t,tag:r,context:i})=>{let a=n.t(process.env.ACTIONS_ID_TOKEN_REQUEST_URL)&&process.env.TWENTY_APP_PUBLISH_DISABLE_PROVENANCE!==`true`;return i.output.progress({message:`Publishing ${e.name}@${e.version} to npm…`}),await w({args:[`publish`,e.path,`--access`,`public`,`--ignore-scripts`,`--workspaces=false`,...a?[`--provenance`]:[],...n.t(r)?[`--tag`,r]:[]],appPath:t,signal:i.signal,canInteract:s.t(i),...i.outputMode===`human`?{onOutput:e=>i.output.progress({message:e})}:{}}),{target:`npm`,name:e.name,version:e.version,...n.t(r)?{tag:r}:{}}},E=async e=>{let t=(0,v.join)(e,b);await(0,_.mkdir)((0,v.dirname)(t),{recursive:!0}),await(0,_.copyFile)((0,v.join)(e,`yarn.lock`),t)},D=e=>{let t=r.t(e)?Object.values(e):e;return(0,x.isArray)(t)&&t.length===1?t[0]:void 0},O=e=>{let t;try{t=JSON.parse(e)}catch(e){throw new i.t({code:`PUBLISH_FAILED`,message:`npm pack returned invalid JSON.`,cause:e})}let n=D(t);if(!r.t(n)||!(0,x.isNonEmptyString)(n.name)||!(0,x.isNonEmptyString)(n.version)||!(0,x.isNonEmptyString)(n.filename)||(0,v.basename)(n.filename)!==n.filename||n.filename.includes(`\\`)||!n.filename.endsWith(`.tgz`)||!(0,x.isArray)(n.files))throw new i.t({code:`PUBLISH_FAILED`,message:`npm pack returned an invalid package description.`});let a=n.files.map(e=>{if(!r.t(e)||!(0,x.isNonEmptyString)(e.path))throw new i.t({code:`PUBLISH_FAILED`,message:`npm pack returned an invalid package file.`});return{path:e.path}});return{name:n.name,version:n.version,filename:n.filename,files:a}},k=async({appPath:e,build:t,signal:n,output:r,usePackage:a})=>{let o=f.a({build:t,appPath:e});for(let e of t.files)n.throwIfAborted(),await f.t({snapshotDirectory:o,artifact:e});await E(o);let s=await(0,_.mkdtemp)((0,v.join)((0,v.dirname)(o),`package-`));try{r.progress({message:`Packing the built app…`});let c=O(await w({args:[`pack`,o,`--json`,`--ignore-scripts`,`--workspaces=false`,`--pack-destination`,s],appPath:e,signal:n})),l=new Set(c.files.map(e=>e.path)),u=[`manifest.json`,`package.json`,...t.files.map(e=>e.path).filter(e=>e!==`yarn.lock`),b],d=[...new Set(u)].filter(e=>!l.has(e));if(d.length>0)throw new i.t({code:`PUBLISH_FAILED`,message:`The npm package is missing files required by the built app.`,hint:`Update the files field in package.json to include the manifest and built files.`,details:{missingPaths:d}});return n.throwIfAborted(),await a({path:(0,v.join)(s,c.filename),name:c.name,version:c.version})}finally{await(0,_.rm)(s,{recursive:!0,force:!0}).catch(()=>{r.warn({code:`PACKAGE_CLEANUP_FAILED`,message:`Could not remove temporary package folder ${s}.`})})}},A=async e=>{let t=a.i(e.options,`tag`),r=a.t(e.options,`private`);if(r&&n.t(t))throw new i.t({code:`INVALID_INPUT`,exitCode:i.n.USAGE,message:`--tag only applies to npm publishing.`});if(n.t(t)&&!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(t))throw new i.t({code:`INVALID_INPUT`,exitCode:i.n.USAGE,message:`Invalid npm tag: ${t}.`});if(!r&&n.t(a.i(e.options,`remote`)))throw new i.t({code:`INVALID_INPUT`,exitCode:i.n.USAGE,message:`npm publishing does not use a Twenty remote.`});let o=r?await h.t(e):void 0,s,{project:l,diagnostics:u}=await p.t({context:e,useHeldBuild:async({project:r,data:i})=>{s=await k({appPath:r.path,build:i,signal:e.signal,output:e.output,usePackage:async i=>n.t(o)?S({packedApp:i,context:{target:o,signal:e.signal,output:e.output}}):T({packedApp:i,appPath:r.path,tag:t,context:e})})}});if(!n.t(s))throw new i.t({code:`PUBLISH_FAILED`,message:`The build did not provide a package to publish.`});return{data:{app:{path:l.path,name:l.name},...s,diagnostics:u},human:c.o(`Published ${s.name}@${s.version} to ${o?.apiUrl??`npm`}${r?`. Existing installations may upgrade automatically.`:``}`)}};exports.runAppPublishCommand=A;
|
|
@@ -1,6 +1,6 @@
|
|
|
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("./pull-minimum-sdk-version.constant-
|
|
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("./pull-minimum-sdk-version.constant-DOAFtDDD.cjs"),a=require("./fetch-workspace-or-throw-BIu0K3A-.cjs"),o=require("./kebab-case-B3kq7ANN.cjs"),s=require("./cli-error-CrUD8uMp.cjs");require("./code-step-file-suffix.constant-B6vqrfcU.cjs");const c=require("./read-command-values-l5T9Lba4.cjs"),l=require("./create-cancelled-error-BBhAY8fS.cjs"),u=require("./confirm-in-terminal-D2e1lKUY.cjs"),d=require("./is-interaction-allowed-BQLOG8RG.cjs"),f=require("./style-BR52fK4V.cjs"),p=require("./to-worker-output-diagnostics-w1hZPfn0.cjs"),m=require("./read-app-identity-M47izSWp.cjs"),h=require("./resolve-app-project-B4IjfcM-.cjs"),g=require("./format-data-value-D_1TNU-r.cjs"),_=require("./require-approval-BIgPOy_r.cjs"),v=require("./is-valid-package-name-o_jWsuUX.cjs"),y=require("./execa-CAd0sJ7f.cjs");let b=require("node:path");var x=e.r(y.t()),S=async({appPath:e,signal:t,output:n})=>{t.throwIfAborted(),n.progress({message:`Installing app dependencies with yarn install…`});let r=(0,x.default)(`yarn`,[`install`],{cwd:e,env:{...p.r(process.env),YARN_ENABLE_IMMUTABLE_INSTALLS:`false`,COREPACK_ENABLE_DOWNLOAD_PROMPT:`0`},extendEnv:!1,stdio:[`ignore`,`pipe`,`pipe`],reject:!1,maxBuffer:4*1024*1024}),i=()=>r.kill(`SIGTERM`,{forceKillAfterTimeout:1e3});t.addEventListener(`abort`,i,{once:!0}),t.aborted&&i();try{let n=await r;if(t.aborted)throw l.t();if(n.failed)throw new s.t({code:`APP_INIT_FAILED`,message:`Could not install dependencies for the new app.`,hint:[(n.stderr?.trim()||n.stdout?.trim()||``).slice(-4e3).split(`
|
|
2
2
|
`).map(g.r).join(`
|
|
3
3
|
`),`The project was created at ${g.r(e)}. Fix the installation error, run yarn install there, then run twenty app pull again.`].filter(Boolean).join(`
|
|
4
4
|
`),details:{path:e,exitCode:n.exitCode,stdout:n.stdout?.slice(-16384)??``,stderr:n.stderr?.slice(-16384)??``}})}finally{t.removeEventListener(`abort`,i)}},C=async({context:e,displayName:t})=>{let{options:r,signal:i,output:a}=e,l=d.t(e),f=o.t(t)||`workspace-app`,p=c.i(r,`path`);if(!n.t(p)&&l&&(p=(await u.n({question:`No Twenty app found. Directory for the workspace custom app [./${g.r(f)}]: `,signal:i})).trim()||f),!n.t(p))throw new s.t({code:`APP_PATH_REQUIRED`,exitCode:s.n.USAGE,message:`Choose a directory for the workspace custom application.`,hint:`Pass --path <new-or-empty-directory> --yes to create the project, install its dependencies and pull.`});let m=(0,b.resolve)(process.cwd(),p),h=o.t((0,b.basename)(m));if(!v.t(h))throw new s.t({code:`INVALID_APP_NAME`,exitCode:s.n.USAGE,message:`The directory name cannot be used as an app package name.`,hint:`Choose a directory such as workspace-app.`});return await _.t({isApproved:c.t(r,`yes`),canPrompt:l,question:`Create ${g.r(t)} in ${g.r(m)}, install its dependencies and pull?`,code:`CONFIRMATION_REQUIRED`,message:`Pull needs to create a local project and install its dependencies.`,hint:`Pass --yes to create the project and install its dependencies.`,declinedMessage:`Pull stopped before creating the project.`,signal:i}),a.progress({message:`Creating ${h} in ${g.r(m)}…`}),await v.n({appDirectory:m,appName:h,appDisplayName:t,appDescription:``,shouldIncludeExample:!1,signal:i}),await S({appPath:m,signal:i,output:a}),{path:m,name:h}},w=20,T=[{status:`UNSUPPORTED`,title:`Not written, unsupported by this version`},{status:`FOREIGN_OWNED`,title:`Owned by another application, not written`},{status:`EXCLUDED`,title:`Excluded as workspace runtime state`},{status:`ENGINE_DERIVED`,title:`Derived by the engine, rebuilt on apply`}],E=({title:e,relativePaths:t})=>t.length===0?[]:t.slice().sort().map(t=>` ${e.padEnd(13)}${t}`),D=e=>{let t=new Map;for(let n of e){let e=JSON.stringify([n.metadataName,n.reason]),r=t.get(e)??{metadataName:n.metadataName,reason:n.reason,identifiers:[]};r.identifiers.push(n.universalIdentifier),t.set(e,r)}return[...t.values()].sort((e,t)=>e.metadataName.localeCompare(t.metadataName)||(e.reason??``).localeCompare(t.reason??``))},O=({writes:e,deletions:t,unchangedCount:r,skipped:i,coverage:a,localOnlyRelativePaths:o,unreadableRelativePaths:s=[],compiledTranslationEntryCountByLocale:c={},entityLabelByUniversalIdentifier:l={},verbose:u=!1})=>{let d=[...E({title:`written`,relativePaths:e.filter(e=>!e.isRegeneration).map(e=>e.relativePath)}),...E({title:`regenerated`,relativePaths:e.filter(e=>e.isRegeneration).map(e=>e.relativePath)}),...E({title:`deleted`,relativePaths:t.map(e=>e.relativePath)})];if(r>0&&d.push(` unchanged ${r} file(s)`),e.some(e=>e.relativePath.endsWith(`.code.ts`))&&d.push(``,`Workflow Code-step files contain workspace-authored code, read as text during pull and build.`),i.length>0){d.push(``,`Not written by the writer:`);for(let e of i)d.push(` ${e.kind} ${e.reason}`)}s.length>0&&d.push(``,`Could not be read, so a second file may now define the same entity (check their diagnostics and SDK dependencies before pulling again):`,...s.slice().sort().map(e=>` ${e}`)),o.length>0&&d.push(``,`Local entities the workspace does not have (left untouched):`,...o.slice().sort().map(e=>` ${e}`));let f=a.filter(e=>e.status===`EXPORTED`&&n.t(e.reason)).map(e=>` ${e.metadataName} ${l[e.universalIdentifier]??e.universalIdentifier}: ${e.reason}`).sort();if(f.length>0){let e=u?f:f.slice(0,w);d.push(``,`Written without their workspace-local state (${f.length} row(s)):`,...e),f.length>e.length&&d.push(` …and ${f.length-e.length} more, listed with --verbose`)}for(let e of T){let t=a.filter(t=>t.status===e.status);if(t.length!==0){d.push(``,`${e.title} (${t.length} row(s)):`);for(let{metadataName:e,reason:n,identifiers:r}of D(t))if(d.push(` ${e.padEnd(34)}${String(r.length).padEnd(6)}${n??``}`.trimEnd()),u){for(let e of r.slice(0,w))d.push(` ${e}`);r.length>w&&d.push(` …and ${r.length-w} more`)}}}let p=Object.entries(c).filter(([,e])=>e>0).sort(([e],[t])=>e.localeCompare(t));return p.length>0&&d.push(``,`Translations kept in compiled form until their source strings are in this tree (see locales/compiled/):`,...p.map(([e,t])=>` ${e.padEnd(13)}${t} ${t===1?`entry`:`entries`}`)),d.join(`
|
|
5
|
-
`)},k=t.t(),A=e=>(0,k.isString)(e)&&i.n.some(t=>t===e),j=e=>r.t(e)&&(0,k.isString)(e.universalIdentifier)&&(0,k.isString)(e.relativePath),M=e=>r.t(e)&&(A(e.kind)||e.kind===`translation`||e.kind===`dependency`||e.kind===`publicAsset`)&&(0,k.isBoolean)(e.isRegeneration)&&j(e),N=e=>r.t(e)&&A(e.kind)&&(0,k.isString)(e.universalIdentifier)&&(0,k.isString)(e.reason),P=e=>r.t(e)&&Object.values(e).every(k.isString),F=e=>r.t(e)&&Object.values(e).every(k.isNumber),I=e=>{if(!r.t(e)||!r.t(e.application)||!(0,k.isString)(e.application.universalIdentifier)||!(0,k.isString)(e.application.displayName)||!r.t(e.base)||!(0,k.isArray)(e.writes)||!e.writes.every(M)||!(0,k.isArray)(e.deletions)||!e.deletions.every(j)||!(0,k.isArray)(e.overwrittenLocalChanges)||!e.overwrittenLocalChanges.every(j)||!(0,k.isNumber)(e.unchangedCount)||!(0,k.isArray)(e.localOnlyRelativePaths)||!e.localOnlyRelativePaths.every(k.isString)||!(0,k.isArray)(e.unreadableRelativePaths)||!e.unreadableRelativePaths.every(k.isString)||!(0,k.isArray)(e.skipped)||!e.skipped.every(N)||!F(e.compiledTranslationEntryCountByLocale)||!P(e.entityLabelByUniversalIdentifier))return;let t=e.base.status;if(!(t!==`used`&&t!==`missing`&&t!==`other-target`&&t!==`unbound`&&t!==`unreadable`))return{data:{application:{universalIdentifier:e.application.universalIdentifier,displayName:e.application.displayName},base:{status:t},writes:e.writes,deletions:e.deletions,overwrittenLocalChanges:e.overwrittenLocalChanges,unchangedCount:e.unchangedCount,localOnlyRelativePaths:e.localOnlyRelativePaths,unreadableRelativePaths:e.unreadableRelativePaths,skipped:e.skipped,compiledTranslationEntryCountByLocale:e.compiledTranslationEntryCountByLocale,entityLabelByUniversalIdentifier:e.entityLabelByUniversalIdentifier}}},L=async e=>{let{options:t,target:r,signal:i,output:o,outputMode:l}=e,u=await h.t({explicitPath:c.i(t,`path`),workingDirectory:process.cwd()}).catch(e=>{if(!(e instanceof s.t&&[`APP_NOT_FOUND`,`APP_PATH_REQUIRED`].includes(e.code)))throw e}),d=n.t(u)?await m.t({appPath:u.path,signal:i,warn:o.warn}):{application:null,diagnostics:[]},_=await a.t({target:r,signal:i,shouldIncludeCustomApplication:!n.t(d.application)}),v=(d.application?.universalIdentifier??_.workspaceCustomApplication?.universalIdentifier)?.toLowerCase();if(!n.t(v))throw new s.t({code:`APP_NOT_FOUND`,message:`This workspace has no custom application to pull.`});o.progress({message:`Exporting the app from ${r.apiUrl}…`});let y=await a.n({universalIdentifier:v,target:r,signal:i,shouldIncludeDependencies:!0,shouldIncludeSourceFiles:!0,shouldIncludePublicAssets:!0});n.t(u)||(u=await C({context:e,displayName:y.application.displayName})),o.progress({message:`Reconciling local definitions. Changed workspace entities replace local edits…`});let b=await p.n({request:{type:`pull`,appPath:u.path,target:{apiUrl:r.apiUrl,workspaceId:_.id},applicationExport:y},signal:i}).catch(e=>{throw new s.t({code:e instanceof s.t?e.code:`PULL_FAILED`,exitCode:e instanceof s.t?e.exitCode:s.n.FAILURE,message:e instanceof Error?e.message:String(e),hint:`The worker did not acknowledge completion. Inspect local changes and any backups in .twenty/cli/pull-backup-* before retrying.`,details:{...e instanceof s.t?e.details:{},outcome:`unknown`}})}),x=p.s({value:b.result,parseData:I}),S=[...d.diagnostics,...x.diagnostics,...p.t(b.output)];if(l===`human`)for(let e of S)o.progress({message:p.c(e)});if(!x.success)throw new s.t({code:x.error.code===`CANCELLED`?`CANCELLED`:x.error.code===`SDK_SOURCE_UNSUPPORTED`?`SDK_SOURCE_UNSUPPORTED`:`PULL_FAILED`,exitCode:x.error.code===`CANCELLED`?s.n.CANCELLED:s.n.FAILURE,message:x.error.message,hint:x.error.hint??(x.error.code===`SDK_SOURCE_UNSUPPORTED`?`Upgrade the app to a compatible twenty-sdk version (2.50.0 or later).`:void 0),details:{...x.error.details,diagnostics:S}});let w=x.data;(w.skipped.length>0||w.unreadableRelativePaths.length>0||y.coverage.some(e=>![`EXPORTED`,`ENGINE_DERIVED`].includes(e.status)))&&o.warn({code:`PULL_INCOMPLETE`,message:`Some entities could not be written. See coverage, skipped entities and unreadable files in the pull report.`});let T=O({...w,writes:w.writes.map(e=>({...e,relativePath:g.r(e.relativePath)})),deletions:w.deletions.map(e=>({...e,relativePath:g.r(e.relativePath)})),skipped:w.skipped.map(e=>({...e,reason:g.r(e.reason)})),localOnlyRelativePaths:w.localOnlyRelativePaths.map(g.r),unreadableRelativePaths:w.unreadableRelativePaths.map(g.r),entityLabelByUniversalIdentifier:Object.fromEntries(Object.entries(w.entityLabelByUniversalIdentifier).map(([e,t])=>[e,g.r(t)])),coverage:y.coverage.map(e=>({...e,metadataName:g.r(e.metadataName),universalIdentifier:g.r(e.universalIdentifier),reason:e.reason===null?null:g.r(e.reason)})),verbose:c.t(t,`verbose`)}),E=y.coverage.filter(e=>![`EXPORTED`,`UNSUPPORTED`,`FOREIGN_OWNED`,`EXCLUDED`,`ENGINE_DERIVED`].includes(e.status));return{data:{app:{path:u.path,name:u.name},...w,pulled:!0,coverage:y.coverage,diagnostics:S},human:[f.o(`Pulled ${g.r(w.application.displayName)} into ${g.r(u.path)}`),T,...w.base.status===`used`?[]:[`No matching pull base (${w.base.status}); local-only definitions were kept.`],...w.overwrittenLocalChanges.length>0?[`Local edits replaced by workspace changes:`,...w.overwrittenLocalChanges.map(e=>` ${g.r(e.relativePath)}`)]:[],...E.length>0?[`Unrecognized coverage, not written:`,...E.map(e=>` ${g.r(e.metadataName)} ${g.r(e.status)}: ${g.r(e.reason)}`)]:[],...w.writes.some(e=>e.kind===`dependency`)?[`Run ${f.r(`yarn install`)} to install the pulled dependencies.`]:[],`Run ${f.r(`twenty app typecheck`)} to check the generated definitions.`].filter(Boolean).join(`
|
|
5
|
+
`)},k=t.t(),A=e=>(0,k.isString)(e)&&i.n.some(t=>t===e),j=e=>r.t(e)&&(0,k.isString)(e.universalIdentifier)&&(0,k.isString)(e.relativePath),M=e=>r.t(e)&&(A(e.kind)||e.kind===`translation`||e.kind===`dependency`||e.kind===`publicAsset`||e.kind===`source`)&&(0,k.isBoolean)(e.isRegeneration)&&j(e),N=e=>r.t(e)&&A(e.kind)&&(0,k.isString)(e.universalIdentifier)&&(0,k.isString)(e.reason),P=e=>r.t(e)&&Object.values(e).every(k.isString),F=e=>r.t(e)&&Object.values(e).every(k.isNumber),I=e=>{if(!r.t(e)||!r.t(e.application)||!(0,k.isString)(e.application.universalIdentifier)||!(0,k.isString)(e.application.displayName)||!r.t(e.base)||!(0,k.isArray)(e.writes)||!e.writes.every(M)||!(0,k.isArray)(e.deletions)||!e.deletions.every(j)||!(0,k.isArray)(e.overwrittenLocalChanges)||!e.overwrittenLocalChanges.every(j)||!(0,k.isNumber)(e.unchangedCount)||!(0,k.isArray)(e.localOnlyRelativePaths)||!e.localOnlyRelativePaths.every(k.isString)||!(0,k.isArray)(e.unreadableRelativePaths)||!e.unreadableRelativePaths.every(k.isString)||!(0,k.isArray)(e.skipped)||!e.skipped.every(N)||!F(e.compiledTranslationEntryCountByLocale)||!P(e.entityLabelByUniversalIdentifier))return;let t=e.base.status;if(!(t!==`used`&&t!==`missing`&&t!==`other-target`&&t!==`unbound`&&t!==`unreadable`))return{data:{application:{universalIdentifier:e.application.universalIdentifier,displayName:e.application.displayName},base:{status:t},writes:e.writes,deletions:e.deletions,overwrittenLocalChanges:e.overwrittenLocalChanges,unchangedCount:e.unchangedCount,localOnlyRelativePaths:e.localOnlyRelativePaths,unreadableRelativePaths:e.unreadableRelativePaths,skipped:e.skipped,compiledTranslationEntryCountByLocale:e.compiledTranslationEntryCountByLocale,entityLabelByUniversalIdentifier:e.entityLabelByUniversalIdentifier}}},L=async e=>{let{options:t,target:r,signal:i,output:o,outputMode:l}=e,u=await h.t({explicitPath:c.i(t,`path`),workingDirectory:process.cwd()}).catch(e=>{if(!(e instanceof s.t&&[`APP_NOT_FOUND`,`APP_PATH_REQUIRED`].includes(e.code)))throw e}),d=n.t(u)?await m.t({appPath:u.path,signal:i,warn:o.warn}):{application:null,diagnostics:[]},_=await a.t({target:r,signal:i,shouldIncludeCustomApplication:!n.t(d.application)}),v=(d.application?.universalIdentifier??_.workspaceCustomApplication?.universalIdentifier)?.toLowerCase();if(!n.t(v))throw new s.t({code:`APP_NOT_FOUND`,message:`This workspace has no custom application to pull.`});o.progress({message:`Exporting the app from ${r.apiUrl}…`});let y=await a.n({universalIdentifier:v,target:r,signal:i,shouldIncludeDependencies:!0,shouldIncludeSourceFiles:!0,shouldIncludePublicAssets:!0});n.t(u)||(u=await C({context:e,displayName:y.application.displayName})),o.progress({message:`Reconciling local definitions. Changed workspace entities replace local edits…`});let b=await p.n({request:{type:`pull`,appPath:u.path,target:{apiUrl:r.apiUrl,workspaceId:_.id},applicationExport:y},signal:i}).catch(e=>{throw new s.t({code:e instanceof s.t?e.code:`PULL_FAILED`,exitCode:e instanceof s.t?e.exitCode:s.n.FAILURE,message:e instanceof Error?e.message:String(e),hint:`The worker did not acknowledge completion. Inspect local changes and any backups in .twenty/cli/pull-backup-* before retrying.`,details:{...e instanceof s.t?e.details:{},outcome:`unknown`}})}),x=p.s({value:b.result,parseData:I}),S=[...d.diagnostics,...x.diagnostics,...p.t(b.output)];if(l===`human`)for(let e of S)o.progress({message:p.c(e)});if(!x.success)throw new s.t({code:x.error.code===`CANCELLED`?`CANCELLED`:x.error.code===`SDK_SOURCE_UNSUPPORTED`?`SDK_SOURCE_UNSUPPORTED`:`PULL_FAILED`,exitCode:x.error.code===`CANCELLED`?s.n.CANCELLED:s.n.FAILURE,message:x.error.message,hint:x.error.hint??(x.error.code===`SDK_SOURCE_UNSUPPORTED`?`Upgrade the app to a compatible twenty-sdk version (2.50.0 or later).`:void 0),details:{...x.error.details,diagnostics:S}});let w=x.data;(w.skipped.length>0||w.unreadableRelativePaths.length>0||y.coverage.some(e=>![`EXPORTED`,`ENGINE_DERIVED`].includes(e.status)))&&o.warn({code:`PULL_INCOMPLETE`,message:`Some entities could not be written. See coverage, skipped entities and unreadable files in the pull report.`});let T=O({...w,writes:w.writes.map(e=>({...e,relativePath:g.r(e.relativePath)})),deletions:w.deletions.map(e=>({...e,relativePath:g.r(e.relativePath)})),skipped:w.skipped.map(e=>({...e,reason:g.r(e.reason)})),localOnlyRelativePaths:w.localOnlyRelativePaths.map(g.r),unreadableRelativePaths:w.unreadableRelativePaths.map(g.r),entityLabelByUniversalIdentifier:Object.fromEntries(Object.entries(w.entityLabelByUniversalIdentifier).map(([e,t])=>[e,g.r(t)])),coverage:y.coverage.map(e=>({...e,metadataName:g.r(e.metadataName),universalIdentifier:g.r(e.universalIdentifier),reason:e.reason===null?null:g.r(e.reason)})),verbose:c.t(t,`verbose`)}),E=y.coverage.filter(e=>![`EXPORTED`,`UNSUPPORTED`,`FOREIGN_OWNED`,`EXCLUDED`,`ENGINE_DERIVED`].includes(e.status));return{data:{app:{path:u.path,name:u.name},...w,pulled:!0,coverage:y.coverage,diagnostics:S},human:[f.o(`Pulled ${g.r(w.application.displayName)} into ${g.r(u.path)}`),T,...w.base.status===`used`?[]:[`No matching pull base (${w.base.status}); local-only definitions were kept.`],...w.overwrittenLocalChanges.length>0?[`Local edits replaced by workspace changes:`,...w.overwrittenLocalChanges.map(e=>` ${g.r(e.relativePath)}`)]:[],...E.length>0?[`Unrecognized coverage, not written:`,...E.map(e=>` ${g.r(e.metadataName)} ${g.r(e.status)}: ${g.r(e.reason)}`)]:[],...w.writes.some(e=>e.kind===`dependency`)?[`Run ${f.r(`yarn install`)} to install the pulled dependencies.`]:[],`Run ${f.r(`twenty app typecheck`)} to check the generated definitions.`].filter(Boolean).join(`
|
|
6
6
|
`)}};exports.runAppPullCommand=L;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./build--4zYt4wd.cjs"),t=require("./isPlainObject-fJEJm71P.cjs"),n=require("./resolve-source-sdk-
|
|
1
|
+
const e=require("./build--4zYt4wd.cjs"),t=require("./isPlainObject-fJEJm71P.cjs"),n=require("./resolve-source-sdk-BDwffWHb.cjs"),r=require("./parse-extraction-locale-B0apfizg.cjs"),i=require("./read-command-values-l5T9Lba4.cjs"),a=require("./style-BR52fK4V.cjs"),o=require("./to-worker-output-diagnostics-w1hZPfn0.cjs"),s=require("./resolve-app-project-B4IjfcM-.cjs"),c=require("./create-tooling-failure-0Foyei1R.cjs");var l=e.t(),u=async e=>{let{options:u,output:d,outputMode:f,signal:p}=e,m=r.t(i.i(u,`locale`)),h=await s.t({explicitPath:i.i(u,`path`),workingDirectory:process.cwd()}),g=await n.t({appPath:h.path});d.progress({message:`Extracting translatable strings from ${h.name}…`});let _=await o.n({request:{type:`extractTranslations`,appPath:h.path,locale:m},signal:p}),v=o.s({value:_.result,parseData:e=>{if(!(!t.t(e)||!(0,l.isNumber)(e.sourceCount)||!(0,l.isArray)(e.updatedLocaleFiles)||!e.updatedLocaleFiles.every(l.isString)))return{data:{sourceCount:e.sourceCount,updatedLocaleFiles:e.updatedLocaleFiles}}}}),y=[...v.diagnostics,...o.t(_.output)];if(f===`human`)for(let e of y)d.progress({message:o.c(e)});if(!v.success)throw c.t({error:v.error,diagnostics:y,sdkVersion:g.version});return{data:{app:h,...v.data,diagnostics:y},human:[a.o(`Extracted ${v.data.sourceCount} ${v.data.sourceCount===1?`string`:`strings`} to locales/`),`Updated: ${v.data.updatedLocaleFiles.join(`, `)}`].join(`
|
|
2
2
|
`)}};exports.runAppTranslationsExtractCommand=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./style-BR52fK4V.cjs"),t=require("./format-app-duration-gu2oRLB4.cjs"),n=require("./run-app-operation-
|
|
1
|
+
const e=require("./style-BR52fK4V.cjs"),t=require("./format-app-duration-gu2oRLB4.cjs"),n=require("./run-app-operation-B4JecUV7.cjs");var r=async r=>{let{project:i,sdk:a,diagnostics:o,durationMilliseconds:s}=await n.n({context:r});return{data:{app:{path:i.path,name:i.name},sdk:{version:a.version},diagnostics:o,durationMilliseconds:s},human:e.o(`No type errors in ${i.name} ${e.i(`· project TypeScript · ${t.t(s)}`)}`)}};exports.runAppTypecheckCommand=r;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./cli-error-CrUD8uMp.cjs"),t=require("./read-command-values-l5T9Lba4.cjs"),n=require("./is-interaction-allowed-BQLOG8RG.cjs"),r=require("./style-BR52fK4V.cjs"),i=require("./with-phase-details-CRqY0f3c.cjs"),a=require("./to-cli-error-4pSpVaW9.cjs"),o=require("./is-application-not-found-error-CQ7k4hGU.cjs"),s=require("./create-metadata-client-
|
|
1
|
+
const e=require("./cli-error-CrUD8uMp.cjs"),t=require("./read-command-values-l5T9Lba4.cjs"),n=require("./is-interaction-allowed-BQLOG8RG.cjs"),r=require("./style-BR52fK4V.cjs"),i=require("./with-phase-details-CRqY0f3c.cjs"),a=require("./to-cli-error-4pSpVaW9.cjs"),o=require("./is-application-not-found-error-CQ7k4hGU.cjs"),s=require("./create-metadata-client-CrOsu4u3.cjs"),c=require("./format-data-value-D_1TNU-r.cjs"),l=require("./require-approval-BIgPOy_r.cjs"),u=require("./create-app-not-installed-error-sN4TzjlV.cjs"),d=require("./read-application-identifier-BlEwa2gR.cjs");var f=new Set([`AUTH_REQUIRED`,`PERMISSION_DENIED`]),p=({code:e,outcome:t})=>t===`unknown`?`The uninstall may have partly run. Run twenty app uninstall again: it reports APP_NOT_INSTALLED once the app is gone.`:e===`APP_NOT_INSTALLED`?`Nothing was uninstalled. Check the target workspace and the universal identifier.`:`Fix the problem, then run twenty app uninstall again.`,m=({error:e,phase:t,completedPhases:n,signal:r})=>{let o=a.t(e,r),s=t!==`uninstall`||f.has(o.code)?`not-started`:`unknown`;return i.t({error:o,phase:t,outcome:s,completedPhases:n,hint:p({code:o.code,outcome:s})})},h=async({universalIdentifier:t,target:n,signal:r})=>{if((await s.t({target:n,signal:r}).mutation({__name:`UninstallApplication`,uninstallApplication:{__args:{universalIdentifier:t}}}).catch(e=>{throw o.t({error:e,field:`uninstallApplication`})?u.t({universalIdentifier:t,apiUrl:n.apiUrl}):e}))?.uninstallApplication!==!0)throw new e.t({code:`INVALID_RESPONSE`,message:`The server did not confirm the uninstall of ${t}.`})},g=async i=>{let{options:a,target:o,signal:s,output:u,outputMode:f}=i,p=[],g=(e,t)=>m({error:e,phase:t,completedPhases:p,signal:s}),_=await d.t({context:i,onIdentityRead:()=>p.push(`identity`)}).catch(e=>{throw g(e,`identity`)});u.progress({message:`Checking the app on ${o.apiUrl}…`});let v=await d.n({universalIdentifier:_,target:o,signal:s}).catch(e=>{throw g(e,`check`)}),y=c.r(v.name);if(!v.canBeUninstalled)throw g(new e.t({code:`APP_NOT_UNINSTALLABLE`,exitCode:e.n.CONFLICT,message:`${y} cannot be uninstalled from ${o.apiUrl}.`}),`check`);return p.push(`check`),await l.t({isApproved:t.t(a,`yes`),canPrompt:n.t({options:a,outputMode:f}),question:`Uninstall ${y} from ${o.apiUrl}? Its objects, fields and their data are permanently deleted.`,code:`CONFIRMATION_REQUIRED`,message:`Uninstalling ${y} permanently deletes its objects, fields and their data.`,hint:`Pass --yes to uninstall it.`,declinedMessage:`Uninstall stopped at the confirmation prompt.`,signal:s}).catch(e=>{throw g(e,`confirmation`)}),u.progress({message:`Uninstalling ${y}…`}),await h({universalIdentifier:_,target:o,signal:s}).catch(e=>{throw g(e,`uninstall`)}),p.push(`uninstall`),{data:{application:{universalIdentifier:_,name:v.name},uninstalled:!0,completedPhases:p},human:[r.o(`Uninstalled ${y} from ${o.apiUrl}`),r.i(` Its registration is kept, so twenty app apply can install it again.`)].join(`
|
|
2
2
|
`)}};exports.runAppUninstallCommand=g;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./cli-error-CrUD8uMp.cjs"),r=require("./parse-api-url-B5c0Gh_n.cjs"),i=require("./read-command-values-l5T9Lba4.cjs"),a=require("./read-input-value-CzJsE62r.cjs"),o=require("./is-interaction-allowed-BQLOG8RG.cjs"),s=require("./style-BR52fK4V.cjs"),c=require("./get-config-path-C-D-QHuX.cjs"),l=require("./read-config-6GnzcpJm.cjs"),u=require("./resolve-proxy-headers-DipR9jft.cjs"),d=require("./api-key-stdin-hint.constant-BTPNgm3m.cjs"),f=require("./get-mismatched-remote-url-D5jFYvVx.cjs"),p=require("./sign-in-with-browser-TQANmPyb.cjs"),m=require("./update-config-Bk0qgzgZ.cjs"),h=require("./validate-remote-name-ZWOgVe80.cjs"),g=require("./fetch-signed-in-identity-kgzejZg2.cjs");var _=async e=>{if(process.stdin.isTTY===!0)throw new n.t({code:`USAGE`,exitCode:n.n.USAGE,message:`The API key must come from standard input.`,hint:d.t});let t=(await a.t({value:`-`,optionName:`the API key`,signal:e})).trim();if(t===``||/\s/.test(t))throw new n.t({code:`USAGE`,exitCode:n.n.USAGE,message:t===``?`Standard input is empty.`:`Standard input must contain only the API key.`,hint:d.t});return t},v=e.t(),y=({savedApiUrl:e,remoteName:t,apiUrl:n})=>{try{return r.t({rawUrl:e,sourceName:t})===n}catch{return!1}},b=({existingRemote:e,remoteName:n,apiUrl:r})=>!t.t(e)||!y({savedApiUrl:e.apiUrl,remoteName:n,apiUrl:r})?{headers:{}}:u.r({remote:e,remoteName:n}),x=({options:e,existingRemote:n,remoteName:r,apiUrl:a})=>{let o=i.r(e,`proxyHeader`),s=i.i(e,`proxyHeaderCommand`),c=t.t(o)&&t.t(s)?{headers:{}}:b({existingRemote:n,remoteName:r,apiUrl:a}),l=t.t(o)?u.n({lines:o,sourceName:`--proxy-header`}):c.headers,d=t.t(s)?s.trim():c.headerCommand;return{headers:l,...(0,v.isNonEmptyString)(d)?{headerCommand:d}:{}}},S=({headers:e,headerCommand:n})=>({...Object.keys(e).length>0?{proxyHeaders:e}:{},...t.t(n)?{proxyHeaderCommand:n}:{}}),C=({proxyHeaders:e,proxyHeaderCommand:t,...n})=>n,w=(e,t)=>Object.hasOwn(e.remotes,t)?e.remotes[t]:void 0,T=({config:e,remoteName:r,apiUrl:i,replace:a})=>{if(a)return;let o=f.t({config:e,remoteName:r,apiUrl:i});if(t.t(o))throw new n.t({code:`CONFIRMATION_REQUIRED`,exitCode:n.n.USAGE,message:`Saved remote "${r}" points to ${o}.`,hint:`Pass --replace to point it at ${i}.`})},E=async({options:e,apiUrl:t,proxyHeaders:r,output:a,outputMode:s,signal:c})=>{if(i.t(e,`withToken`))return{kind:`apiKey`,apiKey:await _(c)};if(!o.t({options:e,outputMode:s}))throw new n.t({code:`USAGE`,exitCode:n.n.USAGE,message:`Browser sign-in only runs in an interactive terminal, not with --no-input, JSON output, redirected stdin or in CI.`,hint:`In scripts and CI, retry this command with --with-token and pipe an API key on standard input.`});return{kind:`oauth`,...await p.t({apiUrl:t,proxyHeaders:r,output:a,signal:c})}},D=({remoteName:e,apiUrl:n,credentials:r,identity:i})=>{let a=t.t(i.workspaceName)?` · workspace ${i.workspaceName}`:``;return r.kind===`apiKey`?`Saved remote "${e}" ${s.i(`(${n}) · API key${a}`)}`:`Signed in to "${e}"${t.t(i.email)?` as ${i.email}`:``}${s.i(a)}`},O=async({options:e,output:a,outputMode:o,signal:d})=>{let f=i.i(e,`name`)??i.i(e,`remote`),_=h.t(f??`default`),v=i.t(e,`replace`),y=c.t(),b=await l.t(y),O=w(b,_),k=i.i(e,`url`);if(!t.t(k)&&!t.t(O))throw new n.t({code:`USAGE`,exitCode:n.n.USAGE,message:Object.keys(b.remotes).length===0?`No saved connections yet.`:`There is no remote named "${_}" yet.`,hint:t.t(f)?`Pass --url to create it.`:`Run twenty auth login --url <url> to save a connection.`});let A=t.t(k)?r.t({rawUrl:k,sourceName:`--url`}):r.t({rawUrl:O?.apiUrl??``,sourceName:`The URL of remote ${_}`});T({config:b,remoteName:_,apiUrl:A,replace:v});let j=x({options:e,existingRemote:O,remoteName:_,apiUrl:A}),M=u.t({environment:process.env,savedSettings:j}),N=await E({options:e,apiUrl:A,proxyHeaders:M,output:a,outputMode:o,signal:d}),P=await g.t({target:{apiUrl:A,bearerToken:N.kind===`apiKey`?N.apiKey:N.accessToken,credentialKind:N.kind,source:`remote`,remoteName:_,proxyHeaders:M},signal:d}).catch(e=>{throw e instanceof n.t&&e.code===`AUTH_REQUIRED`?new n.t({code:`AUTH_REQUIRED`,exitCode:n.n.AUTHENTICATION,message:`${A} rejected ${N.kind===`apiKey`?`this API key`:`the new session`}. Nothing was saved.`,hint:N.kind===`apiKey`?`Check the key and that it belongs to a workspace on this server.`:`Run twenty auth login again.`,details:e.details}):e}),F=await m.t({configPath:y,signal:d,update:n=>{let r=w(n,_);T({config:n,remoteName:_,apiUrl:A,replace:v});let a=t.t(n.defaultRemote)&&Object.hasOwn(n.remotes,n.defaultRemote),o=i.t(e,`use`)||!a?_:n.defaultRemote;return{result:o===_,config:{...n,defaultRemote:o,remotes:{...n.remotes,[_]:{...C(p.n({remote:r??{apiUrl:A},credentials:N})),...S(j),apiUrl:A,...t.t(P.workspaceName)?{workspaceName:P.workspaceName}:{}}}}}}});return{data:{remote:_,apiUrl:A,credentials:N.kind,workspaceName:P.workspaceName,email:P.email,isDefault:F},human:s.o(D({remoteName:_,apiUrl:A,credentials:N,identity:P}))}};exports.runAuthLoginCommand=O;
|
package/dist/chunks/{run-auth-status-command-Dr4YQuLn.cjs → run-auth-status-command-CdqOc2-Q.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./isDefined-CJctgvfE.cjs"),t=require("./target-environment-variable.constant-D7z8AihP.cjs"),n=require("./style-BR52fK4V.cjs"),r=require("./format-details-COEwKz_M.cjs"),i=require("./get-config-path-C-D-QHuX.cjs"),a=require("./read-config-6GnzcpJm.cjs"),o=require("./is-access-token-expiring-BvJhEqtV.cjs"),s=require("./fetch-signed-in-identity-
|
|
1
|
+
const e=require("./isDefined-CJctgvfE.cjs"),t=require("./target-environment-variable.constant-D7z8AihP.cjs"),n=require("./style-BR52fK4V.cjs"),r=require("./format-details-COEwKz_M.cjs"),i=require("./get-config-path-C-D-QHuX.cjs"),a=require("./read-config-6GnzcpJm.cjs"),o=require("./is-access-token-expiring-BvJhEqtV.cjs"),s=require("./fetch-signed-in-identity-kgzejZg2.cjs"),c=require("./credential-kind-labels.constant-CKdoQF8o.cjs");var l=6e4,u=e=>{let t=Math.max(0,Math.round((e-Date.now())/l));return t<120?`${t} minutes`:`${Math.round(t/60)} hours`},d=async({target:l,signal:d})=>{let f=await s.t({target:l,signal:d}),p=e.t(l.remoteName)&&(await a.t(i.t())).defaultRemote===l.remoteName,m=l.credentialKind===`oauth`?o.t(l.bearerToken):void 0,h=e.t(l.remoteName)?`${l.remoteName}${p?n.i(` (default)`):``}`:n.i(`none, using ${t.t.API_URL} and ${t.t.API_KEY}`),g=e.t(f.email)?`${f.email} ${n.i(`via ${c.t[l.credentialKind]}`)}`:c.t[l.credentialKind],_=n.n(`green`,`valid`);return{data:{remote:l.remoteName??null,isDefaultRemote:p,apiUrl:l.apiUrl,source:l.source,credentials:l.credentialKind,email:f.email,workspaceName:f.workspaceName,sessionExpiresAt:e.t(m)?new Date(m).toISOString():null},human:r.t([[`Remote`,h],[`Server`,l.apiUrl],[`Workspace`,f.workspaceName??n.i(`unnamed`)],[`Signed in`,g],[`Status`,e.t(m)?`${_} ${n.i(`· renews itself, current token expires in ${u(m)}`)}`:_]])}};exports.runAuthStatusCommand=d;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-mLOUI7ql.cjs"),t=require("./build--4zYt4wd.cjs"),n=require("./isDefined-CJctgvfE.cjs"),r=require("./
|
|
1
|
+
const e=require("./rolldown-runtime-mLOUI7ql.cjs"),t=require("./build--4zYt4wd.cjs"),n=require("./isDefined-CJctgvfE.cjs"),r=require("./isNonEmptyArray-v52xg4Xj.cjs"),i=require("./isPlainObject-fJEJm71P.cjs"),a=require("./capitalize-CF4z3TZK.cjs"),o=require("./cli-error-CrUD8uMp.cjs"),s=require("./read-command-values-l5T9Lba4.cjs"),c=require("./is-interaction-allowed-BQLOG8RG.cjs"),l=require("./style-BR52fK4V.cjs"),u=require("./to-cli-error-4pSpVaW9.cjs"),d=require("./cli-version.constant-Dn-WFWf8.cjs"),f=require("./format-progress-line-BoU0vHbc.cjs"),p=require("./to-public-target-BltDNpJN.cjs"),m=require("./resolve-command-target-B9QG8OZs.cjs"),h=require("./api-key-stdin-hint.constant-BTPNgm3m.cjs"),g=require("./global-flags.constant-JcdNC5G1.cjs");let ee=require("node:events"),_=require("node:readline");var v=t.t();function te({onlyFirst:e=!1}={}){return RegExp(`(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`,e?void 0:`g`)}var ne=te();function re(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes(`\x1B`)&&!e.includes(``)?e:e.replace(ne,``)}var y=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],b=[12288,12288,65281,65376,65504,65510],x=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],S=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],C=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],w=(e,t)=>{let n=0,r=Math.floor(e.length/2)-1;for(;n<=r;){let i=Math.floor((n+r)/2),a=i*2;if(t<e[a])r=i-1;else if(t>e[a+1])n=i+1;else return!0}return!1},ie=y[0],ae=y.at(-1),oe=b[0],se=b.at(-1);x[0],x.at(-1),S[0],S.at(-1);var ce=C[0],le=C.at(-1),T=19968,[ue,de]=fe(C);function fe(e){let t=e[0],n=e[1];for(let r=0;r<e.length;r+=2){let i=e[r],a=e[r+1];if(T>=i&&T<=a)return[i,a];a-i>n-t&&(t=i,n=a)}return[t,n]}var pe=e=>e<ie||e>ae?!1:w(y,e),me=e=>e<oe||e>se?!1:w(b,e),he=e=>e>=ue&&e<=de?!0:e<ce||e>le?!1:w(C,e);function ge(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function E(e,{ambiguousAsWide:t=!1}={}){return ge(e),me(e)||he(e)||t&&pe(e)?2:1}var _e=new Intl.Segmenter,ve=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Mark}|\p{Surrogate})+$/v,ye=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}\p{Surrogate}]+/v,D=/^\p{RGI_Emoji}$/v,O=/^[\d#*]\u20E3$/,k=/\p{Extended_Pictographic}/gu;function A(e){if(e.length>50)return!1;if(O.test(e))return!0;if(e.includes(``)){let t=e.match(k);return t!==null&&t.length>=2}return!1}function j(e){return e.replace(ye,``)}function M(e){return ve.test(e)}function N(e,t){let n=0;if(e.length>1)for(let r of e.slice(1))r>=``&&r<=``&&(n+=E(r.codePointAt(0),t));return n}function P(e,t={}){if(typeof e!=`string`||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t,i=e;if(!r&&(i.includes(`\x1B`)||i.includes(``))&&(i=re(i)),i.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let a=0,o={ambiguousAsWide:!n};for(let{segment:e}of _e.segment(i)){if(M(e))continue;if(D.test(e)||A(e)){a+=2;continue}let t=j(e).codePointAt(0);a+=E(t,o),a+=N(e,o)}return a}var F=({stream:e,text:t})=>{e.write(t.endsWith(`
|
|
2
2
|
`)?t:`${t}\n`)},be=({mode:e})=>{let t=!1,r=()=>{t&&=((0,_.cursorTo)(process.stderr,0),(0,_.clearLine)(process.stderr,0),!1)};return{write:({message:i,percentage:a})=>{let o=n.t(a)?`${a}%`:``,s=Math.min(20,(process.stderr.columns??80)-P(i)-o.length-5);if(r(),e!==`human`||!process.stderr.isTTY||c.n()||process.env.TERM===`dumb`||!n.t(a)||!Number.isFinite(a)||s<4){F({stream:process.stderr,text:f.t({message:i,percentage:a})});return}let l=Math.round(Math.min(100,Math.max(0,a))/100*s),u=`█`.repeat(l)+`░`.repeat(s-l);process.stderr.write(`${i} ${u} ${o}`),t=!0},clear:r}},xe=e=>e.map(({metadataName:e,entityLabel:t,message:r,userFriendlyMessage:i})=>{let a=(0,v.isNonEmptyString)(i)&&i!==r?`${i} (${r})`:r;return`• ${e}${n.t(t)?` ${t}`:``}: ${a}`}).join(`
|
|
3
|
-
`),Se=e=>!n.t(e)||!(0,v.isArray)(e.validationErrors)?[]:e.validationErrors.filter(e=>
|
|
3
|
+
`),Se=e=>!n.t(e)||!(0,v.isArray)(e.validationErrors)?[]:e.validationErrors.filter(e=>i.t(e)&&(0,v.isString)(e.metadataName)&&(0,v.isString)(e.message)),Ce=async(e,t)=>{t.throwIfAborted(),process.stdout.write(`${JSON.stringify(e)}\n`)||await(0,ee.once)(process.stdout,`drain`,{signal:t}),t.throwIfAborted()},I=e=>{F({stream:process.stdout,text:JSON.stringify(e)})},L=e=>e.split(`
|
|
4
4
|
`).map(e=>(0,v.isNonEmptyString)(e)?` ${e}`:e).join(`
|
|
5
5
|
`),R=e=>n.t(e)?{target:e}:{},z=({mode:e,command:t})=>{let r=[],i=be({mode:e}),a=0,o=(e,n)=>{a+=1,I({schemaVersion:1,command:t,type:e,sequence:a,data:n})},s=()=>{for(let e of r)F({stream:process.stderr,text:l.s(e.message)})};return{event:async(n,r,i)=>{e===`ndjson`&&(a+=1,await Ce({schemaVersion:1,command:t,type:n,sequence:a,data:r},i))},progress:({message:t,percentage:n})=>{if(e===`ndjson`){o(`progress`,{message:t,percentage:n});return}i.write({message:t,percentage:n})},warn:t=>{if(i.clear(),e===`ndjson`){o(`warning`,t);return}r.push(t)},succeed:({data:n,human:a},c)=>{if(i.clear(),e===`json`){I({schemaVersion:1,ok:!0,command:t,...R(c),data:n,warnings:r});return}if(e===`ndjson`){o(`result`,n);return}let l=a??JSON.stringify(n,null,2);(0,v.isNonEmptyString)(l)&&F({stream:process.stdout,text:l}),s()},fail:(a,c)=>{i.clear(),process.exitCode=a.exitCode;let u={code:a.code,message:a.message,...n.t(a.hint)?{hint:a.hint}:{},...n.t(a.details)?{details:a.details}:{}};if(e===`json`){I({schemaVersion:1,ok:!1,command:t,...R(c),error:u,warnings:r});return}if(e===`ndjson`){o(`error`,u);return}F({stream:process.stderr,text:l.a(a.message)});let d=Se(a.details);d.length>0&&F({stream:process.stderr,text:L(xe(d))}),n.t(a.hint)&&F({stream:process.stderr,text:L(a.hint)}),s()}}},B=`--format`,we=e=>e.reduce((t,n,r)=>n.startsWith(`${B}=`)?n.slice(9):n===B?e[r+1]:t,void 0),Te=e=>{let t=e.indexOf(`--`),n=t===-1?e:e.slice(0,t),r=we(n);return n.includes(`--json`)||r===`json`?`json`:r===`ndjson`?`ndjson`:`human`},V=class extends Error{commanderError;commandName;operands;options;constructor({commanderError:e,commandName:t,operands:n,options:r}){super(e.message),this.name=`CommandParseError`,this.commanderError=e,this.commandName=t,this.operands=n,this.options=r}},H=`twenty`,Ee=()=>{let e={standardOutput:``,standardError:``};return{captured:e,configuration:{writeOut:t=>{e.standardOutput+=t},writeErr:t=>{e.standardError+=t},outputError:t=>{e.standardError+=t}}}},U=e.t((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),W=e.t((e=>{var{InvalidArgumentError:t}=U(),n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),G=e.t((e=>{var{humanReadableArgName:t}=W(),n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
|
|
6
6
|
`)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
|
|
@@ -21,4 +21,4 @@ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._life
|
|
|
21
21
|
- ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let o=!1,s=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function l(e,t){let n=r.resolve(e,t);if(i.existsSync(n))return n;if(s.includes(r.extname(t)))return;let a=s.find(e=>i.existsSync(`${n}${e}`));if(a)return`${n}${a}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||``;if(this._scriptPath){let e;try{e=i.realpathSync(this._scriptPath)}catch{e=this._scriptPath}d=r.resolve(r.dirname(e),d)}if(d){let t=l(d,u);if(!t&&!e._executableFile&&this._scriptPath){let n=r.basename(this._scriptPath,r.extname(this._scriptPath));n!==this._name&&(t=l(d,`${n}-${e._name}`))}u=t||u}o=s.includes(r.extname(u));let f;a.platform===`win32`?(this._checkForMissingExecutable(u,d,e._name),t.unshift(u),t=h(a.execArgv).concat(t),f=n.spawn(a.execPath,t,{stdio:`inherit`})):o?(t.unshift(u),t=h(a.execArgv).concat(t),f=n.spawn(a.argv[0],t,{stdio:`inherit`})):f=n.spawn(u,t,{stdio:`inherit`}),f.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{a.on(e,()=>{f.killed===!1&&f.exitCode===null&&f.kill(e)})});let p=this._exitCallback;f.on(`close`,e=>{e??=1,p?p(new c(e,`commander.executeSubCommandAsync`,`(close)`)):a.exit(e)}),f.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(u,d,e._name);else if(t.code===`EACCES`)throw Error(`'${u}' not executable`);if(!p)a.exit(1);else{let e=new c(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,p(e)}}),this.runningCommand=f}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)!==void 0&&this.getOptionValueSource(t)!=="default"});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l))){this.emit(`option:${o.name()}`,l);continue}if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
22
22
|
`),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in a.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,a.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new f(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=p(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=p(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>s(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=r.basename(e,r.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(a.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
|
|
23
23
|
Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function h(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function g(){if(a.env.NO_COLOR||a.env.FORCE_COLOR===`0`||a.env.FORCE_COLOR===`false`)return!1;if(a.env.FORCE_COLOR||a.env.CLICOLOR_FORCE!==void 0)return!0}e.Command=m,e.useColor=g})),ke=e.t((e=>{var{Argument:t}=W(),{Command:n}=Oe(),{CommanderError:r,InvalidArgumentError:i}=U(),{Help:a}=G(),{Option:o}=K();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i})),{program:Ae,createCommand:je,createArgument:Me,createOption:Ne,CommanderError:Pe,InvalidArgumentError:Fe,InvalidOptionArgumentError:Ie,Command:Le,Argument:Re,Option:q,Help:ze}=e.r(ke(),1).default,Be=[{path:[`local`],description:`Run a local Twenty development environment`,helpGroup:g.a.APP,helpHint:`Runs Twenty, including its web UI, worker and databases. Requires a local Docker installation. Sign in afterward with twenty auth login.`},{path:[`app`],description:`Create, develop and manage applications`,helpGroup:g.a.APP},{path:[`app`,`translations`],description:`Manage app translation catalogs`},{path:[`data`],description:`Read workspace records`,helpGroup:g.a.WORKSPACE},{path:[`auth`],description:`Sign in and manage credentials`,helpGroup:g.a.WORKSPACE},{path:[`remote`],description:`Manage saved workspace connections`,helpGroup:g.a.WORKSPACE,helpHint:`Add a remote using browser sign-in or an API key. See: twenty auth login --help`,examples:g.o.examples},{path:[`metadata`],description:`Inspect the data model`,helpGroup:g.a.WORKSPACE},{path:[`metadata`,`object`],description:`Objects`},{path:[`metadata`,`field`],description:`Fields`},{path:[`api`],description:`Send raw REST and GraphQL requests`,helpGroup:g.a.WORKSPACE}],Ve=[`human`,`json`,`ndjson`],He=(e,t)=>t.reduce((e,t)=>e?.commands.find(e=>e.name()===t),e),J=(e,t)=>{let r=He(e,t);if(!n.t(r))throw Error(`Topic "${t.join(` `)}" is not registered.`);return r},Y=e=>`\nExamples:\n${e.map(e=>` ${e}`).join(`
|
|
24
|
-
`)}\n`,Ue=(e,t)=>{if(!e.outputModes.includes(t))throw new o.t({code:`USAGE`,exitCode:o.n.USAGE,message:`twenty ${g.n(e)} does not support ${t} output.`,hint:`Supported: ${e.outputModes.join(`, `)}`})},X=async({definition:e,outputMode:t,commandArguments:r,options:i})=>{let a=g.n(e),o=z({mode:t,command:a}),s=new AbortController,c=()=>s.abort(),l;process.on(`SIGINT`,c);try{Ue(e,t);let n={command:a,arguments:r,options:i,output:o,outputMode:t,signal:s.signal};if(!e.needsTarget){let t=await e.load();o.succeed(await t(n));return}let c=await m.t({options:i,outputMode:t,output:o,signal:s.signal});l=c;let u=await e.load();o.succeed(await u({...n,target:c}),p.t(c))}catch(e){o.fail(u.t(e,s.signal),n.t(l)?p.t(l):void 0)}finally{process.off(`SIGINT`,c),s.abort()}},Z=(e,t)=>e.exitOverride(n=>{throw new V({commanderError:n,commandName:t,operands:e.args,options:e.optsWithGlobals()})}),We=({flags:e,description:t,choices:r,required:i,hidden:a})=>{let o=new q(e,t);return a===!0&&o.hideHelp(),n.t(r)&&o.choices(r),i===!0&&o.makeOptionMandatory(),o},Q=({program:e,definition:t,outputMode:
|
|
24
|
+
`)}\n`,Ue=(e,t)=>{if(!e.outputModes.includes(t))throw new o.t({code:`USAGE`,exitCode:o.n.USAGE,message:`twenty ${g.n(e)} does not support ${t} output.`,hint:`Supported: ${e.outputModes.join(`, `)}`})},X=async({definition:e,outputMode:t,commandArguments:r,options:i})=>{let a=g.n(e),o=z({mode:t,command:a}),s=new AbortController,c=()=>s.abort(),l;process.on(`SIGINT`,c);try{Ue(e,t);let n={command:a,arguments:r,options:i,output:o,outputMode:t,signal:s.signal};if(!e.needsTarget){let t=await e.load();o.succeed(await t(n));return}let c=await m.t({options:i,outputMode:t,output:o,signal:s.signal});l=c;let u=await e.load();o.succeed(await u({...n,target:c}),p.t(c))}catch(e){o.fail(u.t(e,s.signal),n.t(l)?p.t(l):void 0)}finally{process.off(`SIGINT`,c),s.abort()}},Z=(e,t)=>e.exitOverride(n=>{throw new V({commanderError:n,commandName:t,operands:e.args,options:e.optsWithGlobals()})}),We=({flags:e,description:t,choices:r,required:i,hidden:a})=>{let o=new q(e,t);return a===!0&&o.hideHelp(),n.t(r)&&o.choices(r),i===!0&&o.makeOptionMandatory(),o},Q=({program:e,definition:t,outputMode:i})=>{let a=J(e,t.path.slice(0,-1)).command(t.path[t.path.length-1]).description(t.description);n.t(t.helpGroup)&&a.helpGroup(t.helpGroup);for(let e of t.arguments??[])a.argument(e.required?`<${e.name}>`:`[${e.name}]`,e.description);for(let e of t.options??[])a.addOption(We(e));r.t(t.examples)&&a.addHelpText(`after`,Y(t.examples)),Z(a,g.n(t)),a.action(()=>X({definition:t,outputMode:i,commandArguments:a.processedArgs,options:a.optsWithGlobals()}))},Ge=({program:e,topic:t})=>{let i=J(e,t.path.slice(0,-1)).command(t.path[t.path.length-1]).description(t.description);n.t(t.helpGroup)&&i.helpGroup(t.helpGroup),n.t(t.helpHint)&&i.addHelpText(`after`,`\n${t.helpHint}`),r.t(t.examples)&&i.addHelpText(`after`,Y(t.examples)),Z(i,t.path.join(` `))},Ke=({outputMode:e,outputConfiguration:t})=>{let n=new Le(H).description(`The Twenty command line`).version(d.t,g.t.VERSION,`Print the version`).addOption(new q(g.t.JSON,`Print one JSON document on stdout`).conflicts(`format`)).addOption(new q(g.t.FORMAT,`Output format`).choices(Ve)).option(g.t.REMOTE,`Saved remote to use for this command`).option(g.t.NO_INPUT,`Never prompt or open a browser`).helpOption(g.t.HELP,`Show help`).commandsGroup(g.a.TOOLS).helpCommand(`help [command]`,`Show help for a command`).configureHelp({showGlobalOptions:!0}).configureOutput(t);Z(n,H);for(let e of Be)Ge({program:n,topic:e});for(let t of g.r)Q({program:n,definition:t,outputMode:e});return n},qe=`help`,Je=e=>a.t(e.replace(/^error: /,``).replace(/\s*\n\s*/g,` `).trim()),Ye=e=>e===`twenty`?H:`${H} ${e}`,$=({message:e,commandName:t})=>new o.t({code:`USAGE`,exitCode:o.n.USAGE,message:e,hint:`See: ${Ye(t)} --help`}),Xe=(e,t)=>e.code===`commander.helpDisplayed`||e.code===`commander.help`&&(e.exitCode===0||!r.t(t)),Ze=e=>(e[0]===qe?e.slice(1):e).join(` `),Qe=async({error:e,outputMode:t,capturedOutput:n})=>{let{commanderError:r,commandName:i,operands:a,options:c}=e;if(r.code===`commander.version`){await X({definition:g.i,outputMode:t,commandArguments:[],options:{}});return}let l=z({mode:t,command:i});if(Xe(r,a)){let e=(0,v.isNonEmptyString)(n.standardOutput)?n.standardOutput:n.standardError;l.succeed({data:{help:e},human:e});return}if(r.code===`commander.help`){l.fail($({message:`Unknown command '${Ze(a)}'`,commandName:i}));return}if(r.code===`commander.excessArguments`&&i===g.n(g.o)&&s.t(c,`withToken`)){l.fail(new o.t({code:`USAGE`,exitCode:o.n.USAGE,message:`--with-token reads the API key from standard input, not as an argument.`,hint:h.t}));return}l.fail($({message:Je(r.message),commandName:i}))},$e=async e=>{let t=Te(e),n=Ee(),r=Ke({outputMode:t,outputConfiguration:n.configuration});try{await r.parseAsync(e,{from:`user`})}catch(e){if(e instanceof V){await Qe({error:e,outputMode:t,capturedOutput:n.captured});return}z({mode:t,command:H}).fail(u.t(e))}};exports.runCli=$e;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./isDefined-CJctgvfE.cjs"),t=require("./style-BR52fK4V.cjs"),n=require("./global-flags.constant-
|
|
1
|
+
const e=require("./isDefined-CJctgvfE.cjs"),t=require("./style-BR52fK4V.cjs"),n=require("./global-flags.constant-JcdNC5G1.cjs"),r=require("./format-table-4drtI5sP.cjs");var i=async()=>{let i=n.r.map(t=>({name:n.n(t),description:t.description,arguments:(t.arguments??[]).map(({name:e,required:t})=>({name:e,required:t})),flags:(t.options??[]).filter(({hidden:e})=>e!==!0).map(({flags:e})=>e),outputs:t.outputModes,writes:t.writes,needsProject:t.needsProject,needsTarget:t.needsTarget,...e.t(t.requiredPermissions)?{requiredPermissions:t.requiredPermissions}:{}})).sort((e,t)=>e.name.localeCompare(t.name));return{data:{commands:i,globalFlags:Object.values(n.t)},human:[r.t({rows:i,columns:[{header:`COMMAND`,value:e=>e.name},{header:`DESCRIPTION`,value:e=>e.description}]}),`${t.i(`${i.length} commands · details: `)}${t.r(`twenty <command> --help`)}`].join(`
|
|
2
2
|
`)}};exports.runCommandsCommand=i;
|
package/dist/chunks/{run-data-export-command-C4_7rc0v.cjs → run-data-export-command-ca_JYOnT.cjs}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./isPlainObject-fJEJm71P.cjs"),r=require("./isValidUuid-D3NV1xmO.cjs"),i=require("./has-error-code-DsJeqbZq.cjs"),a=require("./cli-error-CrUD8uMp.cjs"),o=require("./read-command-values-l5T9Lba4.cjs"),s=require("./resolve-request-url-CfvGDGkw.cjs"),c=require("./read-bounded-body-BekYzK8S.cjs"),l=require("./create-http-status-error-1VM7PoVZ.cjs"),u=require("./style-BR52fK4V.cjs"),d=require("./create-metadata-client-
|
|
1
|
+
const e=require("./build--4zYt4wd.cjs"),t=require("./isDefined-CJctgvfE.cjs"),n=require("./isPlainObject-fJEJm71P.cjs"),r=require("./isValidUuid-D3NV1xmO.cjs"),i=require("./has-error-code-DsJeqbZq.cjs"),a=require("./cli-error-CrUD8uMp.cjs"),o=require("./read-command-values-l5T9Lba4.cjs"),s=require("./resolve-request-url-CfvGDGkw.cjs"),c=require("./read-bounded-body-BekYzK8S.cjs"),l=require("./create-http-status-error-1VM7PoVZ.cjs"),u=require("./style-BR52fK4V.cjs"),d=require("./create-metadata-client-CrOsu4u3.cjs"),f=require("./subscribe-graphql-w-Ar4hCj.cjs"),p=require("./to-public-target-BltDNpJN.cjs"),m=require("./metadata-page.constant-D4-pGQWp.cjs"),h=require("./resolve-metadata-object-7DhvIcEm.cjs");let g=require("node:crypto"),_=require("node:fs/promises"),v=require("node:path");var y=[`:`,`[`,`,`],b=({character:e,previousCharacter:n,openQuote:r})=>t.t(r)?e===r?null:r:(e===`"`||e===`'`)&&t.t(n)&&y.includes(n)?e:null,x=e=>{let n=[],r=``,i=null,a=`[`;for(let o of e){if(i=b({character:o,previousCharacter:a,openQuote:i}),a=o,o===`,`&&!t.t(i)){n.push(r),r=``;continue}r+=o}return n.push(r),n},S=function(e){return e.AscNullsFirst=`AscNullsFirst`,e.AscNullsLast=`AscNullsLast`,e.DescNullsFirst=`DescNullsFirst`,e.DescNullsLast=`DescNullsLast`,e}({}),C=e.t(),w=1024*1024*1024,T=async({path:e,shouldOverwrite:n,signal:r})=>{let o=(0,v.resolve)(e),s=()=>new a.t({code:`CONFLICT`,exitCode:a.n.CONFLICT,message:`${o} already exists.`,hint:`Choose another output path or use --force to replace a file.`}),c=async e=>{try{return await e()}catch(e){throw i.t(e,`EEXIST`)?s():new a.t({code:`FILE_WRITE_FAILED`,message:`Could not save the CSV file to ${o}.`,hint:`Check that the output directory exists, is writable, and has enough free space.`,cause:e})}},l=await c(()=>(0,_.lstat)(o).catch(e=>{if(!i.t(e,`ENOENT`))throw e}));if(t.t(l)&&(!n||!l.isFile()))throw s();let u=`${o}.${(0,g.randomUUID)()}.tmp`,d=await c(()=>(0,_.open)(u,`wx`,384)),f=async()=>{await d.close().catch(()=>void 0),await(0,_.rm)(u,{force:!0}).catch(()=>void 0)};if(!n){let e=`${u}.probe`;try{await(0,_.link)(u,e)}catch(e){throw await f(),new a.t({code:`FILE_WRITE_FAILED`,message:`Could not prepare a non-overwriting export to ${o}.`,hint:`The output directory must support hard links. Choose a writable directory on a filesystem that supports them, or use --force to allow replacing the destination file.`,cause:e})}try{await c(()=>(0,_.unlink)(e))}catch(t){throw await(0,_.rm)(e,{force:!0}).catch(()=>void 0),await f(),t}}return{outputPath:o,save:async e=>{let t=0,i=e.getReader();try{for(let e=await i.read();!e.done;e=await i.read()){if(r.throwIfAborted(),t+=e.value.byteLength,t>w)throw new a.t({code:`RESPONSE_LIMIT_EXCEEDED`,message:`The CSV export exceeds the 1 GiB download limit.`});await c(()=>d.writeFile(e.value))}}finally{await i.cancel().catch(()=>void 0),i.releaseLock()}return await c(()=>d.sync()),await c(()=>d.close()),r.throwIfAborted(),n?await c(()=>(0,_.rename)(u,o)):await c(()=>(0,_.link)(u,o)),t},cleanup:f}},E=900*1e3,D=async({id:e,downloadPath:n,target:r,signal:i,save:o})=>{if(!n.startsWith(`/file/record-export/${e}?token=`)||!/^\/file\/record-export\/[0-9a-f-]+\?token=[A-Za-z0-9._-]+$/i.test(n))throw new a.t({code:`INVALID_RESPONSE`,message:`The server returned an invalid export download path.`});let u=s.t({apiUrl:r.apiUrl,path:n}),d=AbortSignal.any([i,AbortSignal.timeout(E)]),f;try{if(f=await s.s({proxyHeaders:r.proxyHeaders,requestUrl:u,canReplay:!0,signal:d,send:e=>c.n(u,{headers:s.c({initHeaders:{Accept:`text/csv`},bearerToken:r.bearerToken,proxyHeaderValues:e}),redirect:`manual`,signal:d},E)}),f.status>=300&&f.status<400)throw s.i({response:f,url:u,proxyHeaders:r.proxyHeaders});if(!f.ok)throw l.t({status:f.status,headers:f.headers,body:void 0,target:r});if(!t.t(f.body)||f.headers.get(`content-type`)?.split(`;`)[0].trim().toLowerCase()!==`text/csv`)throw new a.t({code:`INVALID_RESPONSE`,message:`The server did not return a CSV file.`});return await o(f.body)}catch(e){if(e instanceof a.t||i.aborted)throw e;let t=s.o({error:e,signal:i,url:u,timeoutMilliseconds:E});throw t instanceof a.t?new a.t({code:t.code,message:t.message,hint:`Run the export again. Interrupted downloads cannot be resumed.`}):t}finally{await f?.body?.cancel().catch(()=>void 0)}},O=async({client:e,objectMetadataId:t})=>m.n(async n=>{let{fields:r}=await e.query({fields:{__args:{paging:{first:m.t,after:n},filter:{objectMetadataId:{eq:t}}},pageInfo:{hasNextPage:!0,endCursor:!0},edges:{node:{id:!0,name:!0,isActive:!0,isSystem:!0}}}});return r}),k=[`eq`,`neq`,`in`,`containsAny`,`is`,`gt`,`gte`,`lt`,`lte`,`startsWith`,`endsWith`,`like`,`ilike`],A=()=>new a.t({code:`USAGE`,exitCode:a.n.USAGE,message:`Invalid REST filter expression.`,hint:`Use field[operator]:value, for example employees[gte]:5000 or and(tier[eq]:GOLD,employees[gte]:5000).`}),j=e=>{let t=[],n=0,r=0,i=0,a=``,o=!1,s=!1;for(let c=0;c<e.length;c++){let l=e[c];if((0,C.isNonEmptyString)(a)){l===a&&(a=``);continue}if((l===`"`||l===`'`)&&(c===0||[`:`,`[`,`,`].includes(e[c-1]))){a=l;continue}if(l===`(`&&(r++,o=!1),l===`)`&&(r--,o=!1),l===`:`&&e[c-1]===`]`&&(o=!0,s=/\[(in|containsAny)\]$/.test(e.slice(0,c))),l===`[`&&(!o||s&&e[c-1]===`:`)&&i++,l===`]`&&(!o||i>0)&&i--,l===`,`&&i===0&&(o=!1),r<0||i<0)throw A();l===`,`&&r===0&&i===0&&(t.push(e.slice(n,c)),n=c+1)}if(r!==0||i!==0||(0,C.isNonEmptyString)(a))throw A();return t.push(e.slice(n)),t},M=e=>(e.startsWith(`"`)||e.startsWith(`'`))&&(e.endsWith(`"`)||e.endsWith(`'`))?e.slice(1,-1):e,N=({comparator:e,text:t})=>{if(e!==`in`&&e!==`containsAny`)return e===`is`?t:M(t);if(!t.startsWith(`[`)||!t.endsWith(`]`))throw A();return x(t.slice(1,-1)).map(M)},P=({expression:e,depth:n})=>{if(n>50)throw A();let r=/^(and|or|not)\((.+)\)$/.exec(e);if(t.t(r)){let e=j(r[2]).map(e=>P({expression:e,depth:n+1}));if(r[1]===`not`){if(e.length!==1)throw A();return{not:e[0]}}return{[r[1]]:e}}let i=/^([^\[\]]+)\[([^\[\]]+)\]:(.+)$/.exec(e);if(!t.t(i)||!k.includes(i[2]))throw A();let[,a,o,s]=i,c=N({comparator:o,text:s});return a.split(`.`).reverse().reduce((e,t)=>{if(!(0,C.isNonEmptyString)(t))throw A();return{[t]:e}},{[o]:c})},F=e=>{let t=j(e);return t.length===1&&/^(and|or|not)\(/.test(e)?P({expression:e,depth:0}):{and:t.map(e=>P({expression:e,depth:0}))}},I=Object.values(S),L=e=>{let n=e.split(`,`).map(e=>{let n=/^([^\[\]]+)(?:\[([^\[\]]+)\])?$/.exec(e),r=I.find(e=>e===(n?.[2]??S.AscNullsFirst));if(!t.t(n)||!t.t(r))throw new a.t({code:`USAGE`,exitCode:a.n.USAGE,message:`Invalid REST order_by expression.`,hint:`Use field[direction], for example employees[DescNullsLast].`});let[i,...o]=n[1].split(`.`).reverse();return o.reduce((e,t)=>({[t]:e}),{[i]:r})});return n.some(e=>Object.hasOwn(e,`id`))?n:[...n,{id:S.AscNullsLast}]},R=e=>new a.t({code:`USAGE`,exitCode:a.n.USAGE,message:e}),z=()=>new a.t({code:`INVALID_RESPONSE`,message:`The server returned invalid export progress.`}),B=async({arguments:e,options:i,target:s,signal:c,output:l,outputMode:m})=>{let g=o.i(i,`output`);if(!t.t(g)||!(0,C.isNonEmptyString)(g.trim())||g===`-`)throw R(`--output must name a destination CSV file.`);let _=o.i(i,`fields`)?.split(`,`).map(e=>e.trim());if(_?.some(e=>!(0,C.isNonEmptyString)(e)))throw R(`--fields cannot contain empty names.`);let v=o.i(i,`filter`),y=o.i(i,`orderBy`),b=t.t(v)?F(v):void 0,x=t.t(y)?L(y):void 0,S=await T({path:g,shouldOverwrite:o.t(i,`force`),signal:c}),w=Date.now();try{let i=d.t({target:s,signal:c}),v=await h.t({client:i,name:o.n(e,0)??``}),y=await O({client:i,objectMetadataId:v.id}),T=t.t(_)?[...new Set(_)]:y.filter(e=>e.isActive&&!e.isSystem).map(e=>e.name).sort();if(T.length===0||T.length>500)throw R(`Select between 1 and 500 active fields with --fields.`);let E=T.map(e=>{let n=y.find(t=>t.name===e&&t.isActive);if(!t.t(n))throw R(`No active field named ${e} on ${v.namePlural}. Use twenty metadata field list ${v.namePlural}.`);return n.id});await l.event(`start`,{object:v.namePlural,outputPath:S.outputPath,target:p.t(s)},c),m===`human`&&(l.progress({message:`Target: ${s.remoteName??s.source} (${s.apiUrl})`}),l.progress({message:`Exporting ${v.namePlural}…`,percentage:0}));let k,A,j=-1;if(await f.t({target:s,signal:c,interruptionHint:`Run the export again. Interrupted exports cannot be resumed.`,query:`subscription ExportRecords($input: CreateRecordExportInput!) {
|
|
2
2
|
exportRecords(input: $input) { id filename progress downloadPath errorMessage }
|
|
3
3
|
}`,variables:{input:{objectMetadataId:v.id,fieldMetadataIds:E,filter:b,orderBy:x}},onConnected:async()=>void 0,onData:async e=>{if(!n.t(e)||!n.t(e.exportRecords))throw z();let i=e.exportRecords;if(!(0,C.isString)(i.id)||!r.t(i.id)||!Number.isInteger(i.progress)||typeof i.progress!=`number`||i.progress<0||i.progress>100||t.t(A)&&i.id!==A||t.t(i.errorMessage)&&!(0,C.isString)(i.errorMessage)||t.t(i.downloadPath)&&!(0,C.isString)(i.downloadPath))throw z();if(A=i.id,(0,C.isString)(i.errorMessage))throw new a.t({code:`EXPORT_FAILED`,message:i.errorMessage,hint:`Run the export again after resolving the server error.`});if(i.progress!==j&&(await l.event(`progress`,{id:i.id,progress:i.progress},c),m===`human`&&l.progress({message:`Exporting ${v.namePlural}…`,percentage:i.progress}),j=i.progress),(0,C.isString)(i.downloadPath)){if(i.progress!==100)throw z();m===`human`&&l.progress({message:`Downloading CSV…`});let e=await D({id:i.id,downloadPath:i.downloadPath,target:s,signal:c,save:S.save});return k={id:i.id,bytes:e},!1}}}),!t.t(k))throw new a.t({code:`EXPORT_INTERRUPTED`,message:`The export ended before a download was ready.`,hint:`Run the export again.`});let M=Date.now()-w;return{data:{...k,object:v.namePlural,outputPath:S.outputPath,durationMilliseconds:M},human:u.o(`Exported ${v.namePlural} to ${g} (${k.bytes.toLocaleString(`en-US`)} bytes) in ${(M/1e3).toFixed(1)}s`)}}finally{await S.cleanup()}};exports.runDataExportCommand=B;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./cli-error-CrUD8uMp.cjs"),t=require("./read-command-values-l5T9Lba4.cjs"),n=require("./create-metadata-client-
|
|
1
|
+
const e=require("./cli-error-CrUD8uMp.cjs"),t=require("./read-command-values-l5T9Lba4.cjs"),n=require("./create-metadata-client-CrOsu4u3.cjs"),r=require("./format-data-value-D_1TNU-r.cjs"),i=require("./format-details-COEwKz_M.cjs"),a=require("./resolve-metadata-object-7DhvIcEm.cjs"),o=require("./create-rest-client-D3ZXtAxc.cjs");var s=async({arguments:s,target:c,signal:l,outputMode:u})=>{let d=t.n(s,1)??``;if(d.length===0||d===`.`||d===`..`)throw new e.t({code:`USAGE`,exitCode:e.n.USAGE,message:`A record id is required.`});let f=await a.t({client:n.t({target:c,signal:l}),name:t.n(s,0)??``}),p=o.r(await o.t({target:c,signal:l}).get(`/rest/${encodeURIComponent(f.namePlural)}/${encodeURIComponent(d)}`,{query:{depth:1}}),f.nameSingular);return{data:p,...u===`human`?{human:i.t(Object.entries(p).map(([e,t])=>[r.t(e),r.n(t)]))}:{}}};exports.runDataGetCommand=s;
|