twenty-sdk 0.4.4 → 0.4.6-alpha
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/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/ui/index.cjs +398 -398
- package/dist/ui/index.mjs +52 -53
- package/package.json +25 -5
package/dist/cli.cjs
CHANGED
|
@@ -441,4 +441,4 @@ export default defineField({
|
|
|
441
441
|
type: FieldMetadataType.${n.type},
|
|
442
442
|
objectUniversalIdentifier: '${n.objectUniversalIdentifier}',${i}
|
|
443
443
|
});
|
|
444
|
-
`},bx="src";class Nx{async execute(r,i){try{const o=r??await this.getEntity(),u=this.getFolderName(o),f=i?ge.join(Xt,i):ge.join(Xt,bx,u);await de.ensureDir(f);const{name:g,file:v}=await this.getEntityData(o),w=ge.join(f,this.getFileName(g,o));if(await de.pathExists(w)){const{overwrite:b}=await this.handleFileExist();if(!b)return}await de.writeFile(w,v),console.log(R.default.green(`✓ Created ${u}:`),R.default.cyan(ge.relative(Xt,w)))}catch(o){console.error(R.default.red("Add new entity failed:"),o instanceof Error?o.message:o),process.exit(1)}}async getEntityData(r){switch(r){case De.Object:{const i=await this.getObjectData(),o=i.nameSingular,u=Sx({data:i});return{name:o,file:u}}case De.Field:{const i=await this.getFieldData(),o=i.name,u=Ix({data:i});return{name:o,file:u}}case De.LogicFunction:{const i=await this.getEntityName(r),o=xx({name:i});return{name:i,file:o}}case De.FrontComponent:{const i=await this.getEntityName(r),o=_x({name:i});return{name:i,file:o}}case De.Role:{const i=await this.getEntityName(r),o=Ax({name:i});return{name:i,file:o}}default:Ut.ln()}}async getEntity(){const{entity:r}=await Ht.default.prompt([{type:"select",name:"entity",message:"What entity do you want to create?",default:"",choices:Object.values(De)}]);return r}async handleFileExist(){return await Ht.default.prompt([{type:"confirm",name:"overwrite",message:"File already exists. Do you want to overwrite it?",default:!1}])}async getEntityName(r){const{name:i}=await Ht.default.prompt([{type:"input",name:"name",message:`Enter a name for your new ${r}:`,default:"",validate:o=>o.length===0?`${r} name is required`:!0}]);return i}async getFieldData(){return Ht.default.prompt([{type:"input",name:"name",message:"Enter a name for your field:",default:"",validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"label",message:"Enter a label for your field:",default:r=>Ia(r.name),validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"select",name:"type",message:"Select the field type:",choices:Object.values(mc.s),default:mc.s.TEXT},{type:"input",name:"objectUniversalIdentifier",message:"Enter the universalIdentifier of the object this field belongs to:",default:"fill-later",validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"description",message:"Enter a description for your field (optional):",default:""}])}async getObjectData(){return Ht.default.prompt([{type:"input",name:"nameSingular",message:"Enter a name singular for your object (eg: company):",default:"",validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"namePlural",message:"Enter a name plural for your object (eg: companies):",default:"",validate:(r,i)=>r.trim()===i?.nameSingular.trim()?"Name plural must be different from name singular":!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelSingular",message:"Enter a label singular for your object:",default:r=>Ia(r.nameSingular),validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelPlural",message:"Enter a label plural for your object:",default:r=>Ia(r.namePlural),validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0}])}getFolderName(r){return`${fi(r)}s`}getFileName(r,i){switch(i){case De.FrontComponent:return`${fi(r)}.tsx`;default:return`${fi(r)}.ts`}}}const Ox=n=>{const r=new lx,i=new fx,o=new px,u=new dx,f=new mx;n.command("auth:login").description("Authenticate with Twenty").option("--api-key <key>","API key for authentication").option("--api-url <url>","Twenty API URL").action(async P=>{await i.execute(P)}),n.command("auth:logout").description("Remove authentication credentials").action(async()=>{await o.execute()}),n.command("auth:status").description("Check authentication status").action(async()=>{await u.execute()}),n.command("auth:switch [workspace]").description("Switch the default workspace for authentication").action(async P=>{await f.execute({workspace:P})}),n.command("auth:list").description("List all configured workspaces").action(async()=>{await r.execute()});const g=new sx,v=new cx,w=new Nx,b=new ux,O=new gx,D=new hx;n.command("app:dev [appPath]").description("Watch and sync local application changes").action(async P=>{await g.execute({appPath:Pi(P)})}),n.command("app:uninstall [appPath]").description("Uninstall application from Twenty").action(async P=>{try{const M=await v.execute({appPath:Pi(P),askForConfirmation:!0});process.exit(M.success?0:1)}catch{process.exit(1)}}),n.command("entity:add [entityType]").option("--path <path>","Path in which the entity should be created.").description(`Add a new entity to your application (${Object.values(De).join("|")})`).action(async(P,M)=>{await w.execute(P,M?.path)}),n.command("app:generate [appPath]").description("Generate Twenty client").action(async P=>{await b.execute(Pi(P))}),n.command("function:logs [appPath]").option("-u, --functionUniversalIdentifier <functionUniversalIdentifier>","Only show logs for the function with this universal ID").option("-n, --functionName <functionName>","Only show logs for the function with this name").description("Watch application function logs").action(async(P,M)=>{await O.execute({...M,appPath:Pi(P)})}),n.command("function:execute [appPath]").option("-p, --payload <payload>","JSON payload to send to the function","{}").option("-u, --functionUniversalIdentifier <functionUniversalIdentifier>","Universal ID of the function to execute").option("-n, --functionName <functionName>","Name of the function to execute").description("Execute a logic function with a JSON payload").action(async(P,M)=>{!M?.functionUniversalIdentifier&&!M?.functionName&&(console.error(R.default.red("Error: Either --functionName (-n) or --functionUniversalIdentifier (-u) is required.")),process.exit(1)),await D.execute({...M,payload:M?.payload??"{}",appPath:Pi(P)})})},Rx="0.4.
|
|
444
|
+
`},bx="src";class Nx{async execute(r,i){try{const o=r??await this.getEntity(),u=this.getFolderName(o),f=i?ge.join(Xt,i):ge.join(Xt,bx,u);await de.ensureDir(f);const{name:g,file:v}=await this.getEntityData(o),w=ge.join(f,this.getFileName(g,o));if(await de.pathExists(w)){const{overwrite:b}=await this.handleFileExist();if(!b)return}await de.writeFile(w,v),console.log(R.default.green(`✓ Created ${u}:`),R.default.cyan(ge.relative(Xt,w)))}catch(o){console.error(R.default.red("Add new entity failed:"),o instanceof Error?o.message:o),process.exit(1)}}async getEntityData(r){switch(r){case De.Object:{const i=await this.getObjectData(),o=i.nameSingular,u=Sx({data:i});return{name:o,file:u}}case De.Field:{const i=await this.getFieldData(),o=i.name,u=Ix({data:i});return{name:o,file:u}}case De.LogicFunction:{const i=await this.getEntityName(r),o=xx({name:i});return{name:i,file:o}}case De.FrontComponent:{const i=await this.getEntityName(r),o=_x({name:i});return{name:i,file:o}}case De.Role:{const i=await this.getEntityName(r),o=Ax({name:i});return{name:i,file:o}}default:Ut.ln()}}async getEntity(){const{entity:r}=await Ht.default.prompt([{type:"select",name:"entity",message:"What entity do you want to create?",default:"",choices:Object.values(De)}]);return r}async handleFileExist(){return await Ht.default.prompt([{type:"confirm",name:"overwrite",message:"File already exists. Do you want to overwrite it?",default:!1}])}async getEntityName(r){const{name:i}=await Ht.default.prompt([{type:"input",name:"name",message:`Enter a name for your new ${r}:`,default:"",validate:o=>o.length===0?`${r} name is required`:!0}]);return i}async getFieldData(){return Ht.default.prompt([{type:"input",name:"name",message:"Enter a name for your field:",default:"",validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"label",message:"Enter a label for your field:",default:r=>Ia(r.name),validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"select",name:"type",message:"Select the field type:",choices:Object.values(mc.s),default:mc.s.TEXT},{type:"input",name:"objectUniversalIdentifier",message:"Enter the universalIdentifier of the object this field belongs to:",default:"fill-later",validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"description",message:"Enter a description for your field (optional):",default:""}])}async getObjectData(){return Ht.default.prompt([{type:"input",name:"nameSingular",message:"Enter a name singular for your object (eg: company):",default:"",validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"namePlural",message:"Enter a name plural for your object (eg: companies):",default:"",validate:(r,i)=>r.trim()===i?.nameSingular.trim()?"Name plural must be different from name singular":!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelSingular",message:"Enter a label singular for your object:",default:r=>Ia(r.nameSingular),validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0},{type:"input",name:"labelPlural",message:"Enter a label plural for your object:",default:r=>Ia(r.namePlural),validate:r=>!r||r.trim().length===0?"Please enter a non empty string":!0}])}getFolderName(r){return`${fi(r)}s`}getFileName(r,i){switch(i){case De.FrontComponent:return`${fi(r)}.tsx`;default:return`${fi(r)}.ts`}}}const Ox=n=>{const r=new lx,i=new fx,o=new px,u=new dx,f=new mx;n.command("auth:login").description("Authenticate with Twenty").option("--api-key <key>","API key for authentication").option("--api-url <url>","Twenty API URL").action(async P=>{await i.execute(P)}),n.command("auth:logout").description("Remove authentication credentials").action(async()=>{await o.execute()}),n.command("auth:status").description("Check authentication status").action(async()=>{await u.execute()}),n.command("auth:switch [workspace]").description("Switch the default workspace for authentication").action(async P=>{await f.execute({workspace:P})}),n.command("auth:list").description("List all configured workspaces").action(async()=>{await r.execute()});const g=new sx,v=new cx,w=new Nx,b=new ux,O=new gx,D=new hx;n.command("app:dev [appPath]").description("Watch and sync local application changes").action(async P=>{await g.execute({appPath:Pi(P)})}),n.command("app:uninstall [appPath]").description("Uninstall application from Twenty").action(async P=>{try{const M=await v.execute({appPath:Pi(P),askForConfirmation:!0});process.exit(M.success?0:1)}catch{process.exit(1)}}),n.command("entity:add [entityType]").option("--path <path>","Path in which the entity should be created.").description(`Add a new entity to your application (${Object.values(De).join("|")})`).action(async(P,M)=>{await w.execute(P,M?.path)}),n.command("app:generate [appPath]").description("Generate Twenty client").action(async P=>{await b.execute(Pi(P))}),n.command("function:logs [appPath]").option("-u, --functionUniversalIdentifier <functionUniversalIdentifier>","Only show logs for the function with this universal ID").option("-n, --functionName <functionName>","Only show logs for the function with this name").description("Watch application function logs").action(async(P,M)=>{await O.execute({...M,appPath:Pi(P)})}),n.command("function:execute [appPath]").option("-p, --payload <payload>","JSON payload to send to the function","{}").option("-u, --functionUniversalIdentifier <functionUniversalIdentifier>","Universal ID of the function to execute").option("-n, --functionName <functionName>","Name of the function to execute").description("Execute a logic function with a JSON payload").action(async(P,M)=>{!M?.functionUniversalIdentifier&&!M?.functionName&&(console.error(R.default.red("Error: Either --functionName (-n) or --functionUniversalIdentifier (-u) is required.")),process.exit(1)),await D.execute({...M,payload:M?.payload??"{}",appPath:Pi(P)})})},Rx="0.4.6-alpha",Cx={version:Rx};Ly.inspect.defaultOptions.depth=10;const yi=new Pc.Command;yi.name("twenty").description("CLI for Twenty application development").version(Cx.version);yi.option("--workspace <name>","Use a specific workspace configuration (overrides the default set by auth:switch)");yi.hook("preAction",async n=>{let i=(n.optsWithGlobals?n.optsWithGlobals():n.opts()).workspace;i||(i=await new je().getDefaultWorkspace()),je.setActiveWorkspace(i),console.log(R.default.gray(`👩💻 Workspace - ${je.getActiveWorkspace()}`))});Ox(yi);yi.exitOverride();try{yi.parse()}catch(n){n instanceof Pc.CommanderError&&process.exit(n.exitCode),n instanceof Error&&(console.error(R.default.red("Error:"),n.message),process.exit(1))}
|
package/dist/cli.mjs
CHANGED
|
@@ -11418,7 +11418,7 @@ const Tx = (n) => {
|
|
|
11418
11418
|
});
|
|
11419
11419
|
}
|
|
11420
11420
|
);
|
|
11421
|
-
}, wx = "0.4.
|
|
11421
|
+
}, wx = "0.4.6-alpha", Ex = {
|
|
11422
11422
|
version: wx
|
|
11423
11423
|
};
|
|
11424
11424
|
by.defaultOptions.depth = 10;
|