twenty-sdk 2.4.1 → 2.4.2
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/define/index.cjs.map +1 -1
- package/dist/define/index.mjs.map +1 -1
- package/dist/{get-function-input-schema-BZ7_XyUh-DA45tC6Z.js → get-function-input-schema-BZ7_XyUh-BkkT5sr_.js} +1 -1
- package/dist/{get-function-input-schema-BZ7_XyUh-KX7PWzdV.mjs → get-function-input-schema-BZ7_XyUh-Dd-bckv_.mjs} +1 -1
- package/dist/operations.cjs +1 -1
- package/dist/operations.mjs +2 -2
- package/dist/{uninstall-C6NJA8FL.js → uninstall-BL0Kw7KG.js} +2 -2
- package/dist/{uninstall-D_Xoz10Q.mjs → uninstall-xvZY2Uuc.mjs} +2 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("typescript"),o=require("./uninstall-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("typescript"),o=require("./uninstall-BL0Kw7KG.js"),c=n=>{switch(n.kind){case e.SyntaxKind.NumberKeyword:return{type:"number"};case e.SyntaxKind.StringKeyword:return{type:"string"};case e.SyntaxKind.BooleanKeyword:return{type:"boolean"};case e.SyntaxKind.ArrayType:return{type:"array",items:c(n.elementType)};case e.SyntaxKind.ObjectKeyword:return{type:"object"};case e.SyntaxKind.TypeLiteral:{const i={};return n.members.forEach(t=>{if(o.o(t.name)&&o.o(t.type)){const r=t.name.text;i[r]=c(t.type)}}),{type:"object",properties:i}}case e.SyntaxKind.UnionType:{const i=n,t=[];let r=!0;return i.types.forEach(a=>{if(a.kind===e.SyntaxKind.LiteralType){const y=a.literal;y.kind===e.SyntaxKind.StringLiteral?t.push(y.text):r=!1}else r=!1}),r?{type:"string",enum:t}:{}}default:return{}}},s=(n,i)=>n.parameters.reduce((t,r)=>{const a=r.type;return o.o(a)?[...t,c(a)]:[...t,{}]},i),d=n=>n.kind===e.SyntaxKind.FunctionDeclaration?[n]:n.kind===e.SyntaxKind.VariableStatement?n.declarationList.declarations.filter(i=>o.o(i.initializer)&&i.initializer.kind===e.SyntaxKind.ArrowFunction).map(i=>i.initializer):[],l=n=>{const i=e.createSourceFile("temp.ts",n,e.ScriptTarget.ESNext,!0);let t=[];return i.forEachChild(r=>{(r.kind===e.SyntaxKind.FunctionDeclaration||r.kind===e.SyntaxKind.VariableStatement)&&d(r).forEach(a=>{t=s(a,t)})}),t};exports.getFunctionInputSchema=l;
|
package/dist/operations.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./uninstall-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./uninstall-BL0Kw7KG.js"),i=async t=>(t?.remote&&e.ConfigService.setActiveRemote(t.remote),await new e.ConfigService().clearConfig(),{success:!0,data:void 0}),n=t=>e.runSafe(()=>i(t),e.AUTH_ERROR_CODES.AUTH_FAILED),o="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyMDIwMjAyMC0xYzI1LTRkMDItYmYyNS02YWVjY2Y3ZWE0MTkiLCJ0eXBlIjoiQVBJX0tFWSIsIndvcmtzcGFjZUlkIjoiMjAyMDIwMjAtMWMyNS00ZDAyLWJmMjUtNmFlY2NmN2VhNDE5IiwiaWF0IjoxNzM1Njg5NjAwLCJleHAiOjQ4OTE0NDk2MDAsImp0aSI6IjIwMjAyMDIwLWY0MDEtNGQ4YS1hNzMxLTY0ZDAwN2MyN2JhZCJ9.bfQjfyN0NEtTCLE_xPyNcwonDzlSXFoP8kdCQTdnuDc",a="http://localhost:2020";exports.APP_ERROR_CODES=e.APP_ERROR_CODES;exports.AUTH_ERROR_CODES=e.AUTH_ERROR_CODES;exports.ConfigService=e.ConfigService;exports.FUNCTION_ERROR_CODES=e.FUNCTION_ERROR_CODES;exports.SERVER_ERROR_CODES=e.SERVER_ERROR_CODES;exports.appBuild=e.appBuild;exports.appDeploy=e.appDeploy;exports.appDevOnce=e.appDevOnce;exports.appInstall=e.appInstall;exports.appPublish=e.appPublish;exports.appUninstall=e.appUninstall;exports.authLogin=e.authLogin;exports.authLoginOAuth=e.authLoginOAuth;exports.checkDockerRunning=e.checkDockerRunning;exports.containerExists=e.containerExists;exports.detectLocalServer=e.detectLocalServer;exports.functionExecute=e.functionExecute;exports.getContainerDigest=e.getContainerDigest;exports.getImageDigest=e.getImageDigest;exports.getImageForVersion=e.getImageForVersion;exports.serverStart=e.serverStart;exports.serverUpgrade=e.serverUpgrade;exports.DEV_API_KEY=o;exports.DEV_API_URL=a;exports.authLogout=n;
|
package/dist/operations.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as t, A as s, C as a } from "./uninstall-
|
|
2
|
-
import { a as p, F as N, S as g, b as A, c as R, d as M, e as S, f as l, g as u, h as C, i as j, j as m, k as O, l as h, m as y, n as L, p as _, q as f, s as Y, t as d } from "./uninstall-
|
|
1
|
+
import { r as t, A as s, C as a } from "./uninstall-xvZY2Uuc.mjs";
|
|
2
|
+
import { a as p, F as N, S as g, b as A, c as R, d as M, e as S, f as l, g as u, h as C, i as j, j as m, k as O, l as h, m as y, n as L, p as _, q as f, s as Y, t as d } from "./uninstall-xvZY2Uuc.mjs";
|
|
3
3
|
const i = async (e) => (e?.remote && a.setActiveRemote(e.remote), await new a().clearConfig(), { success: !0, data: void 0 }), c = (e) => t(() => i(e), s.AUTH_FAILED), r = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyMDIwMjAyMC0xYzI1LTRkMDItYmYyNS02YWVjY2Y3ZWE0MTkiLCJ0eXBlIjoiQVBJX0tFWSIsIndvcmtzcGFjZUlkIjoiMjAyMDIwMjAtMWMyNS00ZDAyLWJmMjUtNmFlY2NmN2VhNDE5IiwiaWF0IjoxNzM1Njg5NjAwLCJleHAiOjQ4OTE0NDk2MDAsImp0aSI6IjIwMjAyMDIwLWY0MDEtNGQ4YS1hNzMxLTY0ZDAwN2MyN2JhZCJ9.bfQjfyN0NEtTCLE_xPyNcwonDzlSXFoP8kdCQTdnuDc", I = "http://localhost:2020";
|
|
4
4
|
export {
|
|
5
5
|
p as APP_ERROR_CODES,
|
|
@@ -54,11 +54,11 @@ const __anyStub = new Proxy(() => undefined, __anyHandler);
|
|
|
54
54
|
${e.join(`
|
|
55
55
|
`)}
|
|
56
56
|
`},fi=()=>({name:"twenty-sdk-define-stub",setup(e){e.onResolve({filter:/^twenty-sdk\/define$/},()=>({path:Fd,namespace:Bt})),e.onLoad({filter:/.*/,namespace:Bt},()=>({contents:_d(),loader:"js"}))}}),Hd=/^(.+)\((\d+),(\d+)\): error TS\d+: (.+)$/,Qo=e=>{const a=e.match(Hd);if(!a)return null;const[,i,n,s,r]=a;return{text:r,file:i,line:Number(n),column:Number(s)-1}},Xd=e=>{const a=[];for(const i of e.split(`
|
|
57
|
-
`)){const n=Qo(i);n&&a.push(n)}return a},Li=e=>{const a=En.default.join(e,"tsconfig.json"),i=En.default.join(e,"node_modules",".bin","tsc");return new Promise(n=>{ne.execFile(i,["--noEmit","--pretty","false","-p",a],{cwd:e},(s,r,l)=>{n(Xd(l||r))})})},xd=e=>e.map(a=>({text:a.text,location:{file:a.file,line:a.line,column:a.column,lineText:"",length:0,namespace:"",suggestion:""}})),Wo=(e,a)=>({name:"typecheck",setup:i=>{i.onStart(async()=>{if(a())return;const n=await Li(e);return{errors:xd(n)}})}}),Ko=["twenty-client-sdk/core","twenty-client-sdk/metadata","path","fs","crypto","stream","util","os","url","http","https","events","buffer","querystring","assert","zlib","net","tls","child_process","worker_threads"];class Uo{constructor(a){this.esBuildContext=null,this.isRestarting=!1,this.lastChecksums=new Map,this.buildCompletePromise=Promise.resolve(),this.resolveBuildComplete=null,this.appPath=a.appPath,this.sourcePaths=a.sourcePaths,this.watchMode=a.watch??!0,this.onFileBuilt=a.handleFileBuilt,this.onBuildError=a.handleBuildError,this.config=a.config}shouldRestart(a){const i=this.sourcePaths.sort().join(","),n=[...a].sort().join(",");return i!==n}async start(){this.sourcePaths.length>0&&await this.createContext()}async close(){await this.esBuildContext?.dispose(),this.esBuildContext=null}async restart(a){if(!this.isRestarting){this.isRestarting=!0;try{await this.close();const i=J.default.join(this.appPath,me);await hd(i,this.sourcePaths,a),this.sourcePaths=a,this.lastChecksums.clear(),this.sourcePaths.length>0&&await this.createContext()}finally{this.isRestarting=!1}}}async createContext(){const a=J.default.join(this.appPath,me),i={};for(const r of this.sourcePaths){const l=r.replace(/\.tsx?$/,"");i[l]=J.default.join(this.appPath,r)}const n=this,s=[...this.config.extraPlugins??[],{name:"build-notifications",setup:r=>{r.onEnd(async l=>{try{if(l.errors.length>0){l.errors[0].text.includes("Could not resolve")||await this.onBuildError?.(l.errors.map(g=>({error:g.text,location:g.location})));return}await Ho({result:l,appPath:this.appPath,fileFolder:this.config.fileFolder,lastChecksums:n.lastChecksums,onFileBuilt:n.onFileBuilt})}finally{n.resolveBuildComplete?.()}})}}];this.esBuildContext=await on.context({entryPoints:i,bundle:!0,splitting:!1,format:"esm",platform:this.config.platform,outdir:a,outExtension:{".js":".mjs"},external:this.config.externalModules,tsconfig:J.default.join(this.appPath,"tsconfig.json"),jsx:this.config.jsx,sourcemap:!0,metafile:!0,logLevel:"silent",minify:this.config.minify,banner:this.config.banner,plugins:s}),this.buildCompletePromise=new Promise(r=>{this.resolveBuildComplete=r}),await this.esBuildContext.rebuild(),await this.buildCompletePromise,this.watchMode&&await this.esBuildContext.watch()}}const Bd=e=>new Uo({...e,config:{externalModules:Ko,fileFolder:be.BuiltLogicFunction,platform:"node",extraPlugins:[Wo(e.appPath,e.shouldSkipTypecheck),fi()],banner:io}}),Od=e=>new Uo({...e,config:{externalModules:Xo,fileFolder:be.BuiltFrontComponent,jsx:"automatic",extraPlugins:[Wo(e.appPath,e.shouldSkipTypecheck),...an.getFrontComponentBuildPlugins(),fi()]}}),Gd=()=>({bundle:!0,splitting:!1,format:"esm",outExtension:{".js":".mjs"},external:Xo,jsx:"automatic",sourcemap:!0,metafile:!0,logLevel:"silent",plugins:[...an.getFrontComponentBuildPlugins()]}),zo=async e=>{const a=Q.join(e.appPath,me);await ke(a),await Fo(a);const i=new Map,n=l=>{i.set(l.builtPath,{checksum:l.checksum,builtPath:l.builtPath,sourcePath:l.sourcePath,fileFolder:l.fileFolder,usesSdkClient:l.usesSdkClient})},{logicFunctions:s,frontComponents:r}=e.filePaths;return await Nt({appPath:e.appPath,sourcePaths:s,fileFolder:be.BuiltLogicFunction,buildOptions:{bundle:!0,splitting:!1,format:"esm",platform:"node",outdir:Q.join(e.appPath,me),outExtension:{".js":".mjs"},external:Ko,tsconfig:Q.join(e.appPath,"tsconfig.json"),sourcemap:!0,metafile:!0,logLevel:"silent",banner:io,plugins:[fi()]},onFileBuilt:n}),await Nt({appPath:e.appPath,sourcePaths:r,fileFolder:be.BuiltFrontComponent,buildOptions:{...Gd(),outdir:Q.join(e.appPath,me),tsconfig:Q.join(e.appPath,"tsconfig.json"),jsx:"automatic",sourcemap:!0,metafile:!0,logLevel:"silent",plugins:[...an.getFrontComponentBuildPlugins(),fi()]},onFileBuilt:n}),await Ot({appPath:e.appPath,fileFolder:be.PublicAsset,filePaths:e.filePaths.publicAssets,collectFileBuilt:n}),await Ot({appPath:e.appPath,fileFolder:be.Dependencies,filePaths:["package.json","yarn.lock"].filter(l=>rd(Q.join(e.appPath,l))),collectFileBuilt:n}),{builtFileInfos:i}},Ot=async({appPath:e,fileFolder:a,filePaths:i,collectFileBuilt:n})=>{for(const s of i){const r=Q.join(e,s);if(!await Ii(r))continue;const l=Q.join(me,s),g=Q.join(e,l);await ke(Q.dirname(g)),await Ro(r,g);const h=await B.readFile(g),c=eo.default.createHash("md5").update(h).digest("hex");n({fileFolder:a,builtPath:l,sourcePath:s,checksum:c})}};var $a=(e=>(e.DefineApplication="defineApplication",e.DefineApplicationRole="defineApplicationRole",e.DefineField="defineField",e.DefineLogicFunction="defineLogicFunction",e.DefinePostInstallLogicFunction="definePostInstallLogicFunction",e.DefinePreInstallLogicFunction="definePreInstallLogicFunction",e.DefineObject="defineObject",e.DefineRole="defineRole",e.DefineSkill="defineSkill",e.DefineAgent="defineAgent",e.DefineConnectionProvider="defineConnectionProvider",e.DefineFrontComponent="defineFrontComponent",e.DefineView="defineView",e.DefineNavigationMenuItem="defineNavigationMenuItem",e.DefinePageLayout="definePageLayout",e.DefinePageLayoutTab="definePageLayoutTab",e.DefineCommandMenuItem="defineCommandMenuItem",e))($a||{}),ie=(e=>(e.Application="application",e.Fields="fields",e.LogicFunctions="logicFunctions",e.Objects="objects",e.Roles="roles",e.Skills="skills",e.Agents="agents",e.ConnectionProviders="connectionProviders",e.FrontComponents="frontComponents",e.PublicAssets="publicAssets",e.Views="views",e.NavigationMenuItems="navigationMenuItems",e.PageLayouts="pageLayouts",e.PageLayoutTabs="pageLayoutTabs",e.CommandMenuItems="commandMenuItems",e))(ie||{});const Qd={defineApplication:"application",defineApplicationRole:"roles",defineField:"fields",defineLogicFunction:"logicFunctions",definePostInstallLogicFunction:"logicFunctions",definePreInstallLogicFunction:"logicFunctions",defineObject:"objects",defineRole:"roles",defineSkill:"skills",defineAgent:"agents",defineConnectionProvider:"connectionProviders",defineFrontComponent:"frontComponents",defineView:"views",defineNavigationMenuItem:"navigationMenuItems",definePageLayout:"pageLayouts",definePageLayoutTab:"pageLayoutTabs",defineCommandMenuItem:"commandMenuItems"},Wd=e=>{if(!ta.isCallExpression(e))return;const a=e.expression;if(ta.isIdentifier(a)&&Object.values($a).includes(a.text))return a.text},Kd=e=>{const a=ta.createSourceFile("temp.ts",e,ta.ScriptTarget.Latest,!0),i=[];ta.forEachChild(a,n=>{i.push(n)});for(const n of i)if(ta.isExportAssignment(n)){if(n.isExportEquals||!n.expression)return;const s=Wd(n.expression);if(s)return s}},Ud=[[/\bfavoriteRecordIds\.length\b/g,"arrayLength(favoriteRecordIds)"],[/\bselectedRecords\.length\b/g,"arrayLength(selectedRecords)"]],zd=e=>Ud.reduce((a,[i,n])=>a.replace(i,n),e.replace(/!==/g,"!=").replace(/===/g,"==").replace(/&&/g,"and").replace(/\|\|/g,"or").replace(/!(?!=)/g,"not ").replace(/,(\s*\))/g,"$1")),Vd=/(conditionalAvailabilityExpression\s*:\s*)(?!['"`])((?:[^,}()]|\([^()]*\))+)/g,qd=e=>e.replace(Vd,(a,i,n)=>i+JSON.stringify(zd(n.trim()))),el={name:"conditional-availability-transform",setup:e=>{e.onLoad({filter:/\.tsx?$/},async a=>{const i=await Wu.readFile(a.path,"utf8");if(!i.includes("conditionalAvailabilityExpression"))return null;const n=qd(i);return n===i?null:{contents:n,loader:a.path.endsWith(".tsx")?"tsx":"ts"}})}},al=["twenty-sdk/ui","twenty-client-sdk/core","twenty-client-sdk/metadata"],il={name:"manifest-mock",setup:e=>{const a=new RegExp(`^(${al.map(i=>i.replace("/","\\/")).join("|")})$`);e.onResolve({filter:a},({path:i})=>({path:i,namespace:"manifest-mock"})),e.onLoad({filter:/.*/,namespace:"manifest-mock"},()=>({contents:"module.exports = new Proxy({}, { get: () => () => {} });",loader:"js"}))}},de=async({filePath:e,appPath:a})=>{const i=await nl({filePath:e,appPath:a});return tl(i,e)},nl=async({filePath:e,appPath:a})=>{const i=J.default.join(a,"tsconfig.json"),n=await Ii(i),s=Gu.createRequire(J.default.join(a,"package.json"));let r,l;try{r=J.default.dirname(s.resolve("react/package.json")),l=J.default.dirname(s.resolve("react-dom/package.json"))}catch{}const h=(await on.build({entryPoints:[e],bundle:!0,write:!1,format:"cjs",platform:"node",target:"node18",jsx:"automatic",tsconfig:n?i:void 0,alias:{...r&&{react:r},...l&&{"react-dom":l}},plugins:[el,il],logLevel:"silent"})).outputFiles[0].text,c=await B.mkdtemp(J.default.join(tn.default.tmpdir(),"twenty-manifest-")),d=J.default.join(c,"module.cjs");try{return await B.writeFile(d,h),s(d)}finally{await hi(c)}},tl=(e,a)=>{if(Fe(e.default)&&bn(e.default))return e.default;throw new Error(`Config file ${a} must export a config object default export`)},ol="a80ff791-b940-4c47-a522-2bb478515415",Gt=e=>e.type!==I.SELECT&&e.type!==I.MULTI_SELECT||e.options===void 0||e.options===null?e:{...e,options:e.options.map(a=>({...a,id:a.id??xe.v5(`${a.label}-${e.universalIdentifier}`,ol)}))},xi="b403ec59-4d80-4f22-85e6-717a192dc9cb",ul=e=>({...e,objectPermissions:(e.objectPermissions??[]).map(a=>({...a,universalIdentifier:xe.v5(`${e.universalIdentifier}:${a.objectUniversalIdentifier}`,xi)})),fieldPermissions:(e.fieldPermissions??[]).map(a=>({...a,universalIdentifier:xe.v5(`${e.universalIdentifier}:${a.objectUniversalIdentifier}:${a.fieldUniversalIdentifier}`,xi)})),permissionFlags:(e.permissionFlags??[]).map(a=>({universalIdentifier:xe.v5(`${e.universalIdentifier}:${a}`,xi),flag:a}))}),sl=e=>{const a=e.universalIdentifier,i={name:"id",label:"Id",description:"Id",icon:"Icon123",isNullable:!1,defaultValue:"uuid",type:I.UUID,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"id"})},n={name:"name",label:"Name",description:"Name",icon:"IconAbc",isNullable:!0,defaultValue:null,type:I.TEXT,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"name"})},s={name:"createdAt",label:"Creation date",description:"Creation date",icon:"IconCalendar",isNullable:!1,defaultValue:"now",type:I.DATE_TIME,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"createdAt"})},r={name:"updatedAt",label:"Last update",description:"Last time the record was changed",icon:"IconCalendarClock",isNullable:!1,defaultValue:"now",type:I.DATE_TIME,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"updatedAt"})},l={name:"deletedAt",label:"Deleted at",description:"Deletion date",icon:"IconCalendarClock",isNullable:!0,defaultValue:null,type:I.DATE_TIME,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"deletedAt"})},g={name:"createdBy",label:"Created by",description:"The creator of the record",icon:"IconCreativeCommonsSa",isNullable:!1,defaultValue:{name:"''",source:"'MANUAL'"},type:I.ACTOR,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"createdBy"})},h={name:"updatedBy",label:"Updated by",description:"The workspace member who last updated the record",icon:"IconUserCircle",isNullable:!1,defaultValue:{name:"''",source:"'MANUAL'"},type:I.ACTOR,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"updatedBy"})},c={name:"position",label:"Position",description:"Position",icon:"IconHierarchy2",isNullable:!1,defaultValue:0,type:I.POSITION,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"position"})},d={name:"searchVector",label:"Search vector",icon:"IconSearch",description:"Search vector",isNullable:!0,defaultValue:null,type:I.TS_VECTOR,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"searchVector"})};return[i,n,s,r,l,g,h,c,d]},si={targetFieldName:e=>`target${gi(e.nameSingular)}`,targetLabel:e=>gi(e.nameSingular),icon:"IconBuildingSkyscraper",isNullable:!0},rl=[{...si,fieldName:"timelineActivities",label:"Timeline Activities",targetIcon:"IconTimelineEvent",targetFieldType:I.MORPH_RELATION,standardObjectKey:"timelineActivity",morphId:He.timelineActivity.morphIds.targetMorphId.morphId},{...si,fieldName:"attachments",label:"Attachments",icon:"IconBuildingSkyscraper",targetIcon:"IconFileImport",targetFieldType:I.MORPH_RELATION,standardObjectKey:"attachment",morphId:He.attachment.morphIds.targetMorphId.morphId},{...si,fieldName:"noteTargets",label:"Note Targets",icon:"IconBuildingSkyscraper",targetIcon:"IconCheckbox",targetFieldType:I.MORPH_RELATION,standardObjectKey:"noteTarget",morphId:He.noteTarget.morphIds.targetMorphId.morphId},{...si,fieldName:"taskTargets",label:"Task Targets",icon:"IconBuildingSkyscraper",targetIcon:"IconCheckbox",targetFieldType:I.MORPH_RELATION,standardObjectKey:"taskTarget",morphId:He.taskTarget.morphIds.targetMorphId.morphId}],dl=({config:e,forwardFieldUniversalIdentifier:a,objectConfig:i,universalIdentifier:n})=>{const s=He[e.standardObjectKey],r={name:e.targetFieldName(i),label:e.targetLabel(i),description:`${e.targetLabel(i)} ${i.labelSingular}`,icon:e.targetIcon,isNullable:!0,universalSettings:{relationType:Qe.MANY_TO_ONE,onDelete:un.SET_NULL,joinColumnName:`target${gi(i.nameSingular)}Id`},universalIdentifier:n,objectUniversalIdentifier:s.universalIdentifier,relationTargetFieldMetadataUniversalIdentifier:a,relationTargetObjectMetadataUniversalIdentifier:i.universalIdentifier};return e.targetFieldType===I.MORPH_RELATION?{...r,type:e.targetFieldType,morphId:e.morphId}:{...r,type:e.targetFieldType}},ll=e=>{const a=[],i=[];for(const n of rl){const s=He[n.standardObjectKey],r=fe({objectUniversalIdentifier:e.universalIdentifier,fieldName:n.fieldName}),l=fe({objectUniversalIdentifier:e.universalIdentifier,fieldName:`${n.fieldName}Inverse`}),g={name:n.fieldName,label:n.label,description:`${e.labelPlural} tied to the ${n.targetLabel(e)}`,icon:n.icon,isNullable:n.isNullable,type:I.RELATION,universalSettings:{relationType:Qe.ONE_TO_MANY},universalIdentifier:r,relationTargetFieldMetadataUniversalIdentifier:l,relationTargetObjectMetadataUniversalIdentifier:s.universalIdentifier},h=dl({config:n,objectConfig:e,universalIdentifier:l,forwardFieldUniversalIdentifier:r});a.push(g),i.push(h)}return{objectFields:a,fields:i}},gl=e=>{const a=sl(e),{objectFields:i,fields:n}=ll(e),s=(e.fields??[]).map(l=>l.name),r=[...e.fields];for(const l of a)s.includes(l.name)||r.push(l);for(const l of i)s.includes(l.name)||r.push(l);return{objectFields:r,fields:n}},hl={type:"object",properties:{}},cl=async e=>{const{getFunctionInputSchema:a}=await Promise.resolve().then(()=>require("./get-function-input-schema-BZ7_XyUh-DA45tC6Z.js")),i=a(e)[0];return i?.type==="object"&&Fe(i.properties)?{type:"object",properties:i.properties}:hl},qi=e=>{const a={type:"unknown"};switch(e.type){case"string":a.type="string";break;case"number":case"integer":a.type="number";break;case"boolean":a.type="boolean";break;case"array":a.type="array",e.items&&(a.items=qi(e.items));break;case"object":a.type="object",e.properties&&(a.properties=Object.fromEntries(Object.entries(e.properties).map(([i,n])=>[i,qi(n)])));break;default:a.type="unknown"}return Array.isArray(e.enum)&&(a.enum=e.enum.filter(i=>typeof i=="string")),e.multiline===!0&&(a.multiline=!0),ue.isNonEmptyString(e.label)&&(a.label=e.label),a},fl=e=>[qi(e)],pl=async e=>await qt.glob(["**/*.ts","**/*.tsx"],{cwd:e,absolute:!0,ignore:["**/node_modules/**","**/*.d.ts","**/dist/**","**/.twenty/**"],onlyFiles:!0}),bl=async e=>await qt.glob([`${ao}/**/*`],{cwd:e,absolute:!0,onlyFiles:!0}),Vo=async e=>{const a=await pl(e),i=[],n=[];let s;const r=[],l=[],g=[],h=[],c=[],d=[],p=[],o=[],u=[],t=[],f=[],b=[],y=[],m=[],j=[],v=[],w=[],C=[],S=[],Y=[],D=[],Z=[],k=[],L=[],$=[],M=[],X=[],O=[],te=[],_e=[],va=[],Za=[];for(const F of a){const Se=await B.readFile(F,"utf-8"),ee=Q.relative(e,F),Be=Kd(Se);if(!Be)continue;switch(Qd[Be]){case ie.Application:{const A=await de({appPath:e,filePath:F});s=A.config,i.push(...A.errors),n.push(...A.warnings??[]),C.push(ee);break}case ie.Objects:{const A=await de({appPath:e,filePath:F}),{objectFields:z,fields:K}=gl(A.config),$e=A.config.labelIdentifierFieldMetadataUniversalIdentifier??z.find(qe=>qe.name==="name")?.universalIdentifier;if(!$e){i.push(`No label identifier field found for object ${A.config.nameSingular}. Please add a field with name "name" to your object.`);break}const De={...A.config,fields:z.map(Gt),labelIdentifierFieldMetadataUniversalIdentifier:$e};r.push(De),l.push(...K),i.push(...A.errors),n.push(...A.warnings??[]),S.push(ee);break}case ie.Fields:{const A=await de({appPath:e,filePath:F}),z=Gt(A.config);l.push(z),i.push(...A.errors),n.push(...A.warnings??[]),Y.push(ee);break}case ie.Roles:{const A=await de({appPath:e,filePath:F}),z=ul(A.config);g.push(z),i.push(...A.errors),n.push(...A.warnings??[]),D.push(ee),Be===$a.DefineApplicationRole&&w.push(A.config.universalIdentifier);break}case ie.Skills:{const A=await de({appPath:e,filePath:F});h.push(A.config),i.push(...A.errors),n.push(...A.warnings??[]),Z.push(ee);break}case ie.Agents:{const A=await de({appPath:e,filePath:F});c.push(A.config),i.push(...A.errors),n.push(...A.warnings??[]),k.push(ee);break}case ie.ConnectionProviders:{const A=await de({appPath:e,filePath:F});d.push(A.config),i.push(...A.errors),n.push(...A.warnings??[]),L.push(ee);break}case ie.LogicFunctions:{const A=await de({appPath:e,filePath:F});i.push(...A.errors),n.push(...A.warnings??[]);const{handler:z,...K}=A.config,$e=Q.relative(e,F),De=K.toolTriggerSettings&&!K.toolTriggerSettings.inputSchema||K.workflowActionTriggerSettings&&!K.workflowActionTriggerSettings.inputSchema?await cl(Se):null,qe=K.toolTriggerSettings?{...K.toolTriggerSettings,inputSchema:K.toolTriggerSettings.inputSchema??De??void 0}:void 0,Sa=K.workflowActionTriggerSettings?{...K.workflowActionTriggerSettings,inputSchema:K.workflowActionTriggerSettings.inputSchema??(De?fl(De):void 0)}:void 0,Yi={...K,...qe?{toolTriggerSettings:qe}:{},...Sa?{workflowActionTriggerSettings:Sa}:{},handlerName:"default.config.handler",sourceHandlerPath:$e,builtHandlerPath:$e.replace(/\.tsx?$/,".mjs"),builtHandlerChecksum:"[default-checksum]"};if(p.push(Yi),$.push(ee),Be===$a.DefinePostInstallLogicFunction){const ea=A.config;j.push({universalIdentifier:A.config.universalIdentifier,shouldRunOnVersionUpgrade:ea.shouldRunOnVersionUpgrade??!1,shouldRunSynchronously:ea.shouldRunSynchronously??!1})}if(Be===$a.DefinePreInstallLogicFunction){const ea=A.config;v.push({universalIdentifier:A.config.universalIdentifier,shouldRunOnVersionUpgrade:ea.shouldRunOnVersionUpgrade??!1})}break}case ie.FrontComponents:{const A=await de({appPath:e,filePath:F});i.push(...A.errors),n.push(...A.warnings??[]);const{component:z,...K}=A.config,$e=Q.relative(e,F),De={...K,componentName:z.name,sourceComponentPath:$e,builtComponentPath:$e.replace(/\.tsx?$/,".mjs"),builtComponentChecksum:"",isHeadless:K.isHeadless??!1};o.push(De),M.push(ee);break}case ie.Views:{const A=await de({appPath:e,filePath:F}),z={...A.config};t.push(z),i.push(...A.errors),n.push(...A.warnings??[]),O.push(ee);break}case ie.NavigationMenuItems:{const A=await de({appPath:e,filePath:F});f.push(A.config),i.push(...A.errors),n.push(...A.warnings??[]),te.push(ee);break}case ie.PageLayouts:{const A=await de({appPath:e,filePath:F}),z={...A.config};b.push(z),i.push(...A.errors),n.push(...A.warnings??[]),_e.push(ee);break}case ie.PageLayoutTabs:{const A=await de({appPath:e,filePath:F}),z={...A.config};y.push(z),i.push(...A.errors),n.push(...A.warnings??[]),va.push(ee);break}case ie.CommandMenuItems:{const A=await de({appPath:e,filePath:F});m.push(A.config),i.push(...A.errors),n.push(...A.warnings??[]),Za.push(ee);break}case ie.PublicAssets:break;default:Jo()}}const Pa=await bl(e);for(const F of Pa){const Se=Q.relative(e,F);u.push({filePath:Se,fileName:Q.basename(F),fileType:Q.extname(F).replace(/^\./,""),checksum:null}),X.push(Se)}s||i.push("Cannot build application, please export default defineApplication() to define an application"),j.length>1&&i.push("Only one post install logic function is allowed per application"),v.length>1&&i.push("Only one pre install logic function is allowed per application"),w.length>1&&i.push("Only one defineApplicationRole is allowed per application");const ja=s?.defaultRoleUniversalIdentifier??(w.length===1?w[0]:void 0);s&&!ja&&i.push("Application must declare a default role: either pass `defaultRoleUniversalIdentifier` to defineApplication() or mark a role file with defineApplicationRole()");const Ma=s&&ja?{...s,defaultRoleUniversalIdentifier:ja,yarnLockChecksum:null,packageJsonChecksum:null,...j.length>=1?{postInstallLogicFunction:j[0]}:{},...v.length>=1?{preInstallLogicFunction:v[0]}:{}}:void 0,oe=(F,Se)=>F.universalIdentifier.localeCompare(Se.universalIdentifier),ki=(F,Se)=>F.filePath.localeCompare(Se.filePath);return{manifest:Ma?{application:Ma,objects:r.sort(oe),fields:l.sort(oe),roles:g.sort(oe),skills:h.sort(oe),agents:c.sort(oe),connectionProviders:d.sort(oe),logicFunctions:p.sort(oe),frontComponents:o.sort(oe),publicAssets:u.sort(ki),views:t.sort(oe),navigationMenuItems:f.sort(oe),pageLayouts:b.sort(oe),pageLayoutTabs:y.sort(oe),commandMenuItems:m.sort(oe)}:null,filePaths:{application:C,objects:S,fields:Y,roles:D,skills:Z,agents:k,connectionProviders:L,logicFunctions:$,frontComponents:M,publicAssets:X,views:O,navigationMenuItems:te,pageLayouts:_e,pageLayoutTabs:va,commandMenuItems:Za},errors:i,warnings:n}},Qt=4,yl=[I.RELATION,I.MORPH_RELATION],Bi=[Qe.MANY_TO_ONE,Qe.ONE_TO_MANY],ml=e=>{const a=new Set,i=new Set;for(const n of e)a.has(n)?i.add(n):a.add(n);return Array.from(i)},qo=e=>{const a=[];if(!e)return[];for(const[i,n]of Object.entries(e))i==="universalIdentifier"&&typeof n=="string"&&a.push(n),!(i==="postInstallLogicFunction"||i==="preInstallLogicFunction")&&typeof n=="object"&&a.push(...qo(n));return a},wl=e=>{const a=[];for(const i of e){if(!yl.includes(i.type))continue;const n=i.universalSettings;if(!n?.relationType){a.push(`Relation field "${i.name}" is missing relationType. ${i.type} fields must declare a relationType (${Bi.join(" or ")}) in universalSettings.`);continue}if(!Bi.includes(n.relationType)){a.push(`Relation field "${i.name}" has invalid relationType "${n.relationType}". Expected ${Bi.join(" or ")}.`);continue}n.relationType===Qe.MANY_TO_ONE&&!n.joinColumnName&&a.push(`MANY_TO_ONE relation field "${i.name}" is missing joinColumnName. MANY_TO_ONE relations must declare a joinColumnName in universalSettings.`)}return a},vl=e=>{const a=[],i=new Set;for(const n of e){if(i.has(n))continue;if(i.add(n),!xe.validate(n)){a.push(`Universal identifier "${n}" is not a valid UUID.`);continue}const s=xe.version(n);s<Qt&&a.push(`Universal identifier "${n}" is UUID version ${s}. Only UUID version ${Qt} or higher is allowed.`)}return a},jl=e=>{const a=[],i=[],n=qo(e),s=ml(n);s.length>0&&a.push(`Duplicate universal identifiers: ${s.join(", ")}`);const r=vl(n);r.length>0&&a.push(`Duplicate universal identifiers: ${r.join(", ")}`),Xi(e.objects)||i.push("No object defined"),Xi(e.logicFunctions)||i.push("No logic function defined"),Xi(e.frontComponents)||i.push("No front component defined");const l=[...e.fields,...e.objects.flatMap(g=>g.fields)];return a.push(...wl(l)),{errors:a,warnings:i,isValid:a.length===0}},wn=async e=>{const a=await Vo(e);if(a.errors.length>0||!a.manifest)return{success:!1,errors:a.errors.length>0?a.errors:["Failed to build manifest."]};const i=jl(a.manifest);return i.isValid?{success:!0,manifest:a.manifest,filePaths:a.filePaths,warnings:[...a.warnings,...i.warnings]}:{success:!1,errors:i.errors}},vn=({manifest:e,builtFileInfos:a})=>{let i=structuredClone(e);for(const[n,{fileFolder:s,checksum:r}]of a.entries()){const l=Q.relative(me,n);if(s===be.BuiltLogicFunction){const g=i.logicFunctions,h=g.findIndex(c=>c.builtHandlerPath===l);if(h===-1)continue;i={...i,logicFunctions:g.map((c,d)=>d===h?{...c,builtHandlerChecksum:r}:c)}}if(s===be.PublicAsset){const g=i.publicAssets,h=g.findIndex(c=>c.filePath===l);if(h===-1)continue;i={...i,publicAssets:g.map((c,d)=>d===h?{...c,checksum:r}:c)};continue}if(s===be.BuiltFrontComponent){const g=i.frontComponents,h=g.findIndex(d=>d.builtComponentPath===l)??-1;if(h===-1)continue;const c=a.get(n);i={...i,frontComponents:g.map((d,p)=>p===h?{...d,builtComponentChecksum:r,usesSdkClient:c?.usesSdkClient??!1}:d)}}s===be.Dependencies&&(l==="package.json"&&(i.application.packageJsonChecksum=r),l==="yarn.lock"&&(i.application.yarnLockChecksum=r))}return i},jn=async(e,a)=>{const i=J.default.join(e,me);await ke(i);const n=J.default.join(i,"manifest.json");return await ld(n,a),n},ve=async(e,a)=>{try{return await e()}catch(i){return{success:!1,error:{code:a,message:i instanceof Error?i.message:"Unexpected error"}}}},Xe={AUTH_FAILED:"AUTH_FAILED",NO_REMOTES:"NO_REMOTES",REMOTE_NOT_FOUND:"REMOTE_NOT_FOUND",OAUTH_NOT_SUPPORTED:"OAUTH_NOT_SUPPORTED"},x={MANIFEST_NOT_FOUND:"MANIFEST_NOT_FOUND",MANIFEST_BUILD_FAILED:"MANIFEST_BUILD_FAILED",BUILD_FAILED:"BUILD_FAILED",PUBLISH_FAILED:"PUBLISH_FAILED",INSTALL_FAILED:"INSTALL_FAILED",UNINSTALL_FAILED:"UNINSTALL_FAILED",SYNC_FAILED:"SYNC_FAILED",TYPECHECK_FAILED:"TYPECHECK_FAILED",DEPLOY_FAILED:"DEPLOY_FAILED"},Ye={DOCKER_NOT_INSTALLED:"DOCKER_NOT_INSTALLED",DOCKER_NOT_RUNNING:"DOCKER_NOT_RUNNING",CONTAINER_START_FAILED:"CONTAINER_START_FAILED",HEALTH_TIMEOUT:"HEALTH_TIMEOUT",IMAGE_UPGRADE_FAILED:"IMAGE_UPGRADE_FAILED"},ka={FETCH_FUNCTIONS_FAILED:"FETCH_FUNCTIONS_FAILED",FUNCTION_NOT_FOUND:"FUNCTION_NOT_FOUND",EXECUTION_FAILED:"EXECUTION_FAILED"},Sl=async e=>{const{appPath:a,onProgress:i}=e;i?.("Building manifest...");const n=await wn(a);if(!n.success)return{success:!1,error:{code:x.MANIFEST_BUILD_FAILED,message:n.errors.join(`
|
|
57
|
+
`)){const n=Qo(i);n&&a.push(n)}return a},Li=e=>{const a=En.default.join(e,"tsconfig.json"),i=En.default.join(e,"node_modules",".bin","tsc");return new Promise(n=>{ne.execFile(i,["--noEmit","--pretty","false","-p",a],{cwd:e},(s,r,l)=>{n(Xd(l||r))})})},xd=e=>e.map(a=>({text:a.text,location:{file:a.file,line:a.line,column:a.column,lineText:"",length:0,namespace:"",suggestion:""}})),Wo=(e,a)=>({name:"typecheck",setup:i=>{i.onStart(async()=>{if(a())return;const n=await Li(e);return{errors:xd(n)}})}}),Ko=["twenty-client-sdk/core","twenty-client-sdk/metadata","path","fs","crypto","stream","util","os","url","http","https","events","buffer","querystring","assert","zlib","net","tls","child_process","worker_threads"];class Uo{constructor(a){this.esBuildContext=null,this.isRestarting=!1,this.lastChecksums=new Map,this.buildCompletePromise=Promise.resolve(),this.resolveBuildComplete=null,this.appPath=a.appPath,this.sourcePaths=a.sourcePaths,this.watchMode=a.watch??!0,this.onFileBuilt=a.handleFileBuilt,this.onBuildError=a.handleBuildError,this.config=a.config}shouldRestart(a){const i=this.sourcePaths.sort().join(","),n=[...a].sort().join(",");return i!==n}async start(){this.sourcePaths.length>0&&await this.createContext()}async close(){await this.esBuildContext?.dispose(),this.esBuildContext=null}async restart(a){if(!this.isRestarting){this.isRestarting=!0;try{await this.close();const i=J.default.join(this.appPath,me);await hd(i,this.sourcePaths,a),this.sourcePaths=a,this.lastChecksums.clear(),this.sourcePaths.length>0&&await this.createContext()}finally{this.isRestarting=!1}}}async createContext(){const a=J.default.join(this.appPath,me),i={};for(const r of this.sourcePaths){const l=r.replace(/\.tsx?$/,"");i[l]=J.default.join(this.appPath,r)}const n=this,s=[...this.config.extraPlugins??[],{name:"build-notifications",setup:r=>{r.onEnd(async l=>{try{if(l.errors.length>0){l.errors[0].text.includes("Could not resolve")||await this.onBuildError?.(l.errors.map(g=>({error:g.text,location:g.location})));return}await Ho({result:l,appPath:this.appPath,fileFolder:this.config.fileFolder,lastChecksums:n.lastChecksums,onFileBuilt:n.onFileBuilt})}finally{n.resolveBuildComplete?.()}})}}];this.esBuildContext=await on.context({entryPoints:i,bundle:!0,splitting:!1,format:"esm",platform:this.config.platform,outdir:a,outExtension:{".js":".mjs"},external:this.config.externalModules,tsconfig:J.default.join(this.appPath,"tsconfig.json"),jsx:this.config.jsx,sourcemap:!0,metafile:!0,logLevel:"silent",minify:this.config.minify,banner:this.config.banner,plugins:s}),this.buildCompletePromise=new Promise(r=>{this.resolveBuildComplete=r}),await this.esBuildContext.rebuild(),await this.buildCompletePromise,this.watchMode&&await this.esBuildContext.watch()}}const Bd=e=>new Uo({...e,config:{externalModules:Ko,fileFolder:be.BuiltLogicFunction,platform:"node",extraPlugins:[Wo(e.appPath,e.shouldSkipTypecheck),fi()],banner:io}}),Od=e=>new Uo({...e,config:{externalModules:Xo,fileFolder:be.BuiltFrontComponent,jsx:"automatic",extraPlugins:[Wo(e.appPath,e.shouldSkipTypecheck),...an.getFrontComponentBuildPlugins(),fi()]}}),Gd=()=>({bundle:!0,splitting:!1,format:"esm",outExtension:{".js":".mjs"},external:Xo,jsx:"automatic",sourcemap:!0,metafile:!0,logLevel:"silent",plugins:[...an.getFrontComponentBuildPlugins()]}),zo=async e=>{const a=Q.join(e.appPath,me);await ke(a),await Fo(a);const i=new Map,n=l=>{i.set(l.builtPath,{checksum:l.checksum,builtPath:l.builtPath,sourcePath:l.sourcePath,fileFolder:l.fileFolder,usesSdkClient:l.usesSdkClient})},{logicFunctions:s,frontComponents:r}=e.filePaths;return await Nt({appPath:e.appPath,sourcePaths:s,fileFolder:be.BuiltLogicFunction,buildOptions:{bundle:!0,splitting:!1,format:"esm",platform:"node",outdir:Q.join(e.appPath,me),outExtension:{".js":".mjs"},external:Ko,tsconfig:Q.join(e.appPath,"tsconfig.json"),sourcemap:!0,metafile:!0,logLevel:"silent",banner:io,plugins:[fi()]},onFileBuilt:n}),await Nt({appPath:e.appPath,sourcePaths:r,fileFolder:be.BuiltFrontComponent,buildOptions:{...Gd(),outdir:Q.join(e.appPath,me),tsconfig:Q.join(e.appPath,"tsconfig.json"),jsx:"automatic",sourcemap:!0,metafile:!0,logLevel:"silent",plugins:[...an.getFrontComponentBuildPlugins(),fi()]},onFileBuilt:n}),await Ot({appPath:e.appPath,fileFolder:be.PublicAsset,filePaths:e.filePaths.publicAssets,collectFileBuilt:n}),await Ot({appPath:e.appPath,fileFolder:be.Dependencies,filePaths:["package.json","yarn.lock"].filter(l=>rd(Q.join(e.appPath,l))),collectFileBuilt:n}),{builtFileInfos:i}},Ot=async({appPath:e,fileFolder:a,filePaths:i,collectFileBuilt:n})=>{for(const s of i){const r=Q.join(e,s);if(!await Ii(r))continue;const l=Q.join(me,s),g=Q.join(e,l);await ke(Q.dirname(g)),await Ro(r,g);const h=await B.readFile(g),c=eo.default.createHash("md5").update(h).digest("hex");n({fileFolder:a,builtPath:l,sourcePath:s,checksum:c})}};var $a=(e=>(e.DefineApplication="defineApplication",e.DefineApplicationRole="defineApplicationRole",e.DefineField="defineField",e.DefineLogicFunction="defineLogicFunction",e.DefinePostInstallLogicFunction="definePostInstallLogicFunction",e.DefinePreInstallLogicFunction="definePreInstallLogicFunction",e.DefineObject="defineObject",e.DefineRole="defineRole",e.DefineSkill="defineSkill",e.DefineAgent="defineAgent",e.DefineConnectionProvider="defineConnectionProvider",e.DefineFrontComponent="defineFrontComponent",e.DefineView="defineView",e.DefineNavigationMenuItem="defineNavigationMenuItem",e.DefinePageLayout="definePageLayout",e.DefinePageLayoutTab="definePageLayoutTab",e.DefineCommandMenuItem="defineCommandMenuItem",e))($a||{}),ie=(e=>(e.Application="application",e.Fields="fields",e.LogicFunctions="logicFunctions",e.Objects="objects",e.Roles="roles",e.Skills="skills",e.Agents="agents",e.ConnectionProviders="connectionProviders",e.FrontComponents="frontComponents",e.PublicAssets="publicAssets",e.Views="views",e.NavigationMenuItems="navigationMenuItems",e.PageLayouts="pageLayouts",e.PageLayoutTabs="pageLayoutTabs",e.CommandMenuItems="commandMenuItems",e))(ie||{});const Qd={defineApplication:"application",defineApplicationRole:"roles",defineField:"fields",defineLogicFunction:"logicFunctions",definePostInstallLogicFunction:"logicFunctions",definePreInstallLogicFunction:"logicFunctions",defineObject:"objects",defineRole:"roles",defineSkill:"skills",defineAgent:"agents",defineConnectionProvider:"connectionProviders",defineFrontComponent:"frontComponents",defineView:"views",defineNavigationMenuItem:"navigationMenuItems",definePageLayout:"pageLayouts",definePageLayoutTab:"pageLayoutTabs",defineCommandMenuItem:"commandMenuItems"},Wd=e=>{if(!ta.isCallExpression(e))return;const a=e.expression;if(ta.isIdentifier(a)&&Object.values($a).includes(a.text))return a.text},Kd=e=>{const a=ta.createSourceFile("temp.ts",e,ta.ScriptTarget.Latest,!0),i=[];ta.forEachChild(a,n=>{i.push(n)});for(const n of i)if(ta.isExportAssignment(n)){if(n.isExportEquals||!n.expression)return;const s=Wd(n.expression);if(s)return s}},Ud=[[/\bfavoriteRecordIds\.length\b/g,"arrayLength(favoriteRecordIds)"],[/\bselectedRecords\.length\b/g,"arrayLength(selectedRecords)"]],zd=e=>Ud.reduce((a,[i,n])=>a.replace(i,n),e.replace(/!==/g,"!=").replace(/===/g,"==").replace(/&&/g,"and").replace(/\|\|/g,"or").replace(/!(?!=)/g,"not ").replace(/,(\s*\))/g,"$1")),Vd=/(conditionalAvailabilityExpression\s*:\s*)(?!['"`])((?:[^,}()]|\([^()]*\))+)/g,qd=e=>e.replace(Vd,(a,i,n)=>i+JSON.stringify(zd(n.trim()))),el={name:"conditional-availability-transform",setup:e=>{e.onLoad({filter:/\.tsx?$/},async a=>{const i=await Wu.readFile(a.path,"utf8");if(!i.includes("conditionalAvailabilityExpression"))return null;const n=qd(i);return n===i?null:{contents:n,loader:a.path.endsWith(".tsx")?"tsx":"ts"}})}},al=["twenty-sdk/ui","twenty-client-sdk/core","twenty-client-sdk/metadata"],il={name:"manifest-mock",setup:e=>{const a=new RegExp(`^(${al.map(i=>i.replace("/","\\/")).join("|")})$`);e.onResolve({filter:a},({path:i})=>({path:i,namespace:"manifest-mock"})),e.onLoad({filter:/.*/,namespace:"manifest-mock"},()=>({contents:"module.exports = new Proxy({}, { get: () => () => {} });",loader:"js"}))}},de=async({filePath:e,appPath:a})=>{const i=await nl({filePath:e,appPath:a});return tl(i,e)},nl=async({filePath:e,appPath:a})=>{const i=J.default.join(a,"tsconfig.json"),n=await Ii(i),s=Gu.createRequire(J.default.join(a,"package.json"));let r,l;try{r=J.default.dirname(s.resolve("react/package.json")),l=J.default.dirname(s.resolve("react-dom/package.json"))}catch{}const h=(await on.build({entryPoints:[e],bundle:!0,write:!1,format:"cjs",platform:"node",target:"node18",jsx:"automatic",tsconfig:n?i:void 0,alias:{...r&&{react:r},...l&&{"react-dom":l}},plugins:[el,il],logLevel:"silent"})).outputFiles[0].text,c=await B.mkdtemp(J.default.join(tn.default.tmpdir(),"twenty-manifest-")),d=J.default.join(c,"module.cjs");try{return await B.writeFile(d,h),s(d)}finally{await hi(c)}},tl=(e,a)=>{if(Fe(e.default)&&bn(e.default))return e.default;throw new Error(`Config file ${a} must export a config object default export`)},ol="a80ff791-b940-4c47-a522-2bb478515415",Gt=e=>e.type!==I.SELECT&&e.type!==I.MULTI_SELECT||e.options===void 0||e.options===null?e:{...e,options:e.options.map(a=>({...a,id:a.id??xe.v5(`${a.label}-${e.universalIdentifier}`,ol)}))},xi="b403ec59-4d80-4f22-85e6-717a192dc9cb",ul=e=>({...e,objectPermissions:(e.objectPermissions??[]).map(a=>({...a,universalIdentifier:xe.v5(`${e.universalIdentifier}:${a.objectUniversalIdentifier}`,xi)})),fieldPermissions:(e.fieldPermissions??[]).map(a=>({...a,universalIdentifier:xe.v5(`${e.universalIdentifier}:${a.objectUniversalIdentifier}:${a.fieldUniversalIdentifier}`,xi)})),permissionFlags:(e.permissionFlags??[]).map(a=>({universalIdentifier:xe.v5(`${e.universalIdentifier}:${a}`,xi),flag:a}))}),sl=e=>{const a=e.universalIdentifier,i={name:"id",label:"Id",description:"Id",icon:"Icon123",isNullable:!1,defaultValue:"uuid",type:I.UUID,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"id"})},n={name:"name",label:"Name",description:"Name",icon:"IconAbc",isNullable:!0,defaultValue:null,type:I.TEXT,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"name"})},s={name:"createdAt",label:"Creation date",description:"Creation date",icon:"IconCalendar",isNullable:!1,defaultValue:"now",type:I.DATE_TIME,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"createdAt"})},r={name:"updatedAt",label:"Last update",description:"Last time the record was changed",icon:"IconCalendarClock",isNullable:!1,defaultValue:"now",type:I.DATE_TIME,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"updatedAt"})},l={name:"deletedAt",label:"Deleted at",description:"Deletion date",icon:"IconCalendarClock",isNullable:!0,defaultValue:null,type:I.DATE_TIME,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"deletedAt"})},g={name:"createdBy",label:"Created by",description:"The creator of the record",icon:"IconCreativeCommonsSa",isNullable:!1,defaultValue:{name:"''",source:"'MANUAL'"},type:I.ACTOR,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"createdBy"})},h={name:"updatedBy",label:"Updated by",description:"The workspace member who last updated the record",icon:"IconUserCircle",isNullable:!1,defaultValue:{name:"''",source:"'MANUAL'"},type:I.ACTOR,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"updatedBy"})},c={name:"position",label:"Position",description:"Position",icon:"IconHierarchy2",isNullable:!1,defaultValue:0,type:I.POSITION,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"position"})},d={name:"searchVector",label:"Search vector",icon:"IconSearch",description:"Search vector",isNullable:!0,defaultValue:null,type:I.TS_VECTOR,universalIdentifier:fe({objectUniversalIdentifier:a,fieldName:"searchVector"})};return[i,n,s,r,l,g,h,c,d]},si={targetFieldName:e=>`target${gi(e.nameSingular)}`,targetLabel:e=>gi(e.nameSingular),icon:"IconBuildingSkyscraper",isNullable:!0},rl=[{...si,fieldName:"timelineActivities",label:"Timeline Activities",targetIcon:"IconTimelineEvent",targetFieldType:I.MORPH_RELATION,standardObjectKey:"timelineActivity",morphId:He.timelineActivity.morphIds.targetMorphId.morphId},{...si,fieldName:"attachments",label:"Attachments",icon:"IconBuildingSkyscraper",targetIcon:"IconFileImport",targetFieldType:I.MORPH_RELATION,standardObjectKey:"attachment",morphId:He.attachment.morphIds.targetMorphId.morphId},{...si,fieldName:"noteTargets",label:"Note Targets",icon:"IconBuildingSkyscraper",targetIcon:"IconCheckbox",targetFieldType:I.MORPH_RELATION,standardObjectKey:"noteTarget",morphId:He.noteTarget.morphIds.targetMorphId.morphId},{...si,fieldName:"taskTargets",label:"Task Targets",icon:"IconBuildingSkyscraper",targetIcon:"IconCheckbox",targetFieldType:I.MORPH_RELATION,standardObjectKey:"taskTarget",morphId:He.taskTarget.morphIds.targetMorphId.morphId}],dl=({config:e,forwardFieldUniversalIdentifier:a,objectConfig:i,universalIdentifier:n})=>{const s=He[e.standardObjectKey],r={name:e.targetFieldName(i),label:e.targetLabel(i),description:`${e.targetLabel(i)} ${i.labelSingular}`,icon:e.targetIcon,isNullable:!0,universalSettings:{relationType:Qe.MANY_TO_ONE,onDelete:un.SET_NULL,joinColumnName:`target${gi(i.nameSingular)}Id`},universalIdentifier:n,objectUniversalIdentifier:s.universalIdentifier,relationTargetFieldMetadataUniversalIdentifier:a,relationTargetObjectMetadataUniversalIdentifier:i.universalIdentifier};return e.targetFieldType===I.MORPH_RELATION?{...r,type:e.targetFieldType,morphId:e.morphId}:{...r,type:e.targetFieldType}},ll=e=>{const a=[],i=[];for(const n of rl){const s=He[n.standardObjectKey],r=fe({objectUniversalIdentifier:e.universalIdentifier,fieldName:n.fieldName}),l=fe({objectUniversalIdentifier:e.universalIdentifier,fieldName:`${n.fieldName}Inverse`}),g={name:n.fieldName,label:n.label,description:`${e.labelPlural} tied to the ${n.targetLabel(e)}`,icon:n.icon,isNullable:n.isNullable,type:I.RELATION,universalSettings:{relationType:Qe.ONE_TO_MANY},universalIdentifier:r,relationTargetFieldMetadataUniversalIdentifier:l,relationTargetObjectMetadataUniversalIdentifier:s.universalIdentifier},h=dl({config:n,objectConfig:e,universalIdentifier:l,forwardFieldUniversalIdentifier:r});a.push(g),i.push(h)}return{objectFields:a,fields:i}},gl=e=>{const a=sl(e),{objectFields:i,fields:n}=ll(e),s=(e.fields??[]).map(l=>l.name),r=[...e.fields];for(const l of a)s.includes(l.name)||r.push(l);for(const l of i)s.includes(l.name)||r.push(l);return{objectFields:r,fields:n}},hl={type:"object",properties:{}},cl=async e=>{const{getFunctionInputSchema:a}=await Promise.resolve().then(()=>require("./get-function-input-schema-BZ7_XyUh-BkkT5sr_.js")),i=a(e)[0];return i?.type==="object"&&Fe(i.properties)?{type:"object",properties:i.properties}:hl},qi=e=>{const a={type:"unknown"};switch(e.type){case"string":a.type="string";break;case"number":case"integer":a.type="number";break;case"boolean":a.type="boolean";break;case"array":a.type="array",e.items&&(a.items=qi(e.items));break;case"object":a.type="object",e.properties&&(a.properties=Object.fromEntries(Object.entries(e.properties).map(([i,n])=>[i,qi(n)])));break;default:a.type="unknown"}return Array.isArray(e.enum)&&(a.enum=e.enum.filter(i=>typeof i=="string")),e.multiline===!0&&(a.multiline=!0),ue.isNonEmptyString(e.label)&&(a.label=e.label),a},fl=e=>[qi(e)],pl=async e=>await qt.glob(["**/*.ts","**/*.tsx"],{cwd:e,absolute:!0,ignore:["**/node_modules/**","**/*.d.ts","**/dist/**","**/.twenty/**"],onlyFiles:!0}),bl=async e=>await qt.glob([`${ao}/**/*`],{cwd:e,absolute:!0,onlyFiles:!0}),Vo=async e=>{const a=await pl(e),i=[],n=[];let s;const r=[],l=[],g=[],h=[],c=[],d=[],p=[],o=[],u=[],t=[],f=[],b=[],y=[],m=[],j=[],v=[],w=[],C=[],S=[],Y=[],D=[],Z=[],k=[],L=[],$=[],M=[],X=[],O=[],te=[],_e=[],va=[],Za=[];for(const F of a){const Se=await B.readFile(F,"utf-8"),ee=Q.relative(e,F),Be=Kd(Se);if(!Be)continue;switch(Qd[Be]){case ie.Application:{const A=await de({appPath:e,filePath:F});s=A.config,i.push(...A.errors),n.push(...A.warnings??[]),C.push(ee);break}case ie.Objects:{const A=await de({appPath:e,filePath:F}),{objectFields:z,fields:K}=gl(A.config),$e=A.config.labelIdentifierFieldMetadataUniversalIdentifier??z.find(qe=>qe.name==="name")?.universalIdentifier;if(!$e){i.push(`No label identifier field found for object ${A.config.nameSingular}. Please add a field with name "name" to your object.`);break}const De={...A.config,fields:z.map(Gt),labelIdentifierFieldMetadataUniversalIdentifier:$e};r.push(De),l.push(...K),i.push(...A.errors),n.push(...A.warnings??[]),S.push(ee);break}case ie.Fields:{const A=await de({appPath:e,filePath:F}),z=Gt(A.config);l.push(z),i.push(...A.errors),n.push(...A.warnings??[]),Y.push(ee);break}case ie.Roles:{const A=await de({appPath:e,filePath:F}),z=ul(A.config);g.push(z),i.push(...A.errors),n.push(...A.warnings??[]),D.push(ee),Be===$a.DefineApplicationRole&&w.push(A.config.universalIdentifier);break}case ie.Skills:{const A=await de({appPath:e,filePath:F});h.push(A.config),i.push(...A.errors),n.push(...A.warnings??[]),Z.push(ee);break}case ie.Agents:{const A=await de({appPath:e,filePath:F});c.push(A.config),i.push(...A.errors),n.push(...A.warnings??[]),k.push(ee);break}case ie.ConnectionProviders:{const A=await de({appPath:e,filePath:F});d.push(A.config),i.push(...A.errors),n.push(...A.warnings??[]),L.push(ee);break}case ie.LogicFunctions:{const A=await de({appPath:e,filePath:F});i.push(...A.errors),n.push(...A.warnings??[]);const{handler:z,...K}=A.config,$e=Q.relative(e,F),De=K.toolTriggerSettings&&!K.toolTriggerSettings.inputSchema||K.workflowActionTriggerSettings&&!K.workflowActionTriggerSettings.inputSchema?await cl(Se):null,qe=K.toolTriggerSettings?{...K.toolTriggerSettings,inputSchema:K.toolTriggerSettings.inputSchema??De??void 0}:void 0,Sa=K.workflowActionTriggerSettings?{...K.workflowActionTriggerSettings,inputSchema:K.workflowActionTriggerSettings.inputSchema??(De?fl(De):void 0)}:void 0,Yi={...K,...qe?{toolTriggerSettings:qe}:{},...Sa?{workflowActionTriggerSettings:Sa}:{},handlerName:"default.config.handler",sourceHandlerPath:$e,builtHandlerPath:$e.replace(/\.tsx?$/,".mjs"),builtHandlerChecksum:"[default-checksum]"};if(p.push(Yi),$.push(ee),Be===$a.DefinePostInstallLogicFunction){const ea=A.config;j.push({universalIdentifier:A.config.universalIdentifier,shouldRunOnVersionUpgrade:ea.shouldRunOnVersionUpgrade??!1,shouldRunSynchronously:ea.shouldRunSynchronously??!1})}if(Be===$a.DefinePreInstallLogicFunction){const ea=A.config;v.push({universalIdentifier:A.config.universalIdentifier,shouldRunOnVersionUpgrade:ea.shouldRunOnVersionUpgrade??!1})}break}case ie.FrontComponents:{const A=await de({appPath:e,filePath:F});i.push(...A.errors),n.push(...A.warnings??[]);const{component:z,...K}=A.config,$e=Q.relative(e,F),De={...K,componentName:z.name,sourceComponentPath:$e,builtComponentPath:$e.replace(/\.tsx?$/,".mjs"),builtComponentChecksum:"",isHeadless:K.isHeadless??!1};o.push(De),M.push(ee);break}case ie.Views:{const A=await de({appPath:e,filePath:F}),z={...A.config};t.push(z),i.push(...A.errors),n.push(...A.warnings??[]),O.push(ee);break}case ie.NavigationMenuItems:{const A=await de({appPath:e,filePath:F});f.push(A.config),i.push(...A.errors),n.push(...A.warnings??[]),te.push(ee);break}case ie.PageLayouts:{const A=await de({appPath:e,filePath:F}),z={...A.config};b.push(z),i.push(...A.errors),n.push(...A.warnings??[]),_e.push(ee);break}case ie.PageLayoutTabs:{const A=await de({appPath:e,filePath:F}),z={...A.config};y.push(z),i.push(...A.errors),n.push(...A.warnings??[]),va.push(ee);break}case ie.CommandMenuItems:{const A=await de({appPath:e,filePath:F});m.push(A.config),i.push(...A.errors),n.push(...A.warnings??[]),Za.push(ee);break}case ie.PublicAssets:break;default:Jo()}}const Pa=await bl(e);for(const F of Pa){const Se=Q.relative(e,F);u.push({filePath:Se,fileName:Q.basename(F),fileType:Q.extname(F).replace(/^\./,""),checksum:null}),X.push(Se)}s||i.push("Cannot build application, please export default defineApplication() to define an application"),j.length>1&&i.push("Only one post install logic function is allowed per application"),v.length>1&&i.push("Only one pre install logic function is allowed per application"),w.length>1&&i.push("Only one defineApplicationRole is allowed per application");const ja=s?.defaultRoleUniversalIdentifier??(w.length===1?w[0]:void 0);s&&!ja&&i.push("Application must declare a default role: either pass `defaultRoleUniversalIdentifier` to defineApplication() or mark a role file with defineApplicationRole()");const Ma=s&&ja?{...s,defaultRoleUniversalIdentifier:ja,yarnLockChecksum:null,packageJsonChecksum:null,...j.length>=1?{postInstallLogicFunction:j[0]}:{},...v.length>=1?{preInstallLogicFunction:v[0]}:{}}:void 0,oe=(F,Se)=>F.universalIdentifier.localeCompare(Se.universalIdentifier),ki=(F,Se)=>F.filePath.localeCompare(Se.filePath);return{manifest:Ma?{application:Ma,objects:r.sort(oe),fields:l.sort(oe),roles:g.sort(oe),skills:h.sort(oe),agents:c.sort(oe),connectionProviders:d.sort(oe),logicFunctions:p.sort(oe),frontComponents:o.sort(oe),publicAssets:u.sort(ki),views:t.sort(oe),navigationMenuItems:f.sort(oe),pageLayouts:b.sort(oe),pageLayoutTabs:y.sort(oe),commandMenuItems:m.sort(oe)}:null,filePaths:{application:C,objects:S,fields:Y,roles:D,skills:Z,agents:k,connectionProviders:L,logicFunctions:$,frontComponents:M,publicAssets:X,views:O,navigationMenuItems:te,pageLayouts:_e,pageLayoutTabs:va,commandMenuItems:Za},errors:i,warnings:n}},Qt=4,yl=[I.RELATION,I.MORPH_RELATION],Bi=[Qe.MANY_TO_ONE,Qe.ONE_TO_MANY],ml=e=>{const a=new Set,i=new Set;for(const n of e)a.has(n)?i.add(n):a.add(n);return Array.from(i)},qo=e=>{const a=[];if(!e)return[];for(const[i,n]of Object.entries(e))i==="universalIdentifier"&&typeof n=="string"&&a.push(n),!(i==="postInstallLogicFunction"||i==="preInstallLogicFunction")&&typeof n=="object"&&a.push(...qo(n));return a},wl=e=>{const a=[];for(const i of e){if(!yl.includes(i.type))continue;const n=i.universalSettings;if(!n?.relationType){a.push(`Relation field "${i.name}" is missing relationType. ${i.type} fields must declare a relationType (${Bi.join(" or ")}) in universalSettings.`);continue}if(!Bi.includes(n.relationType)){a.push(`Relation field "${i.name}" has invalid relationType "${n.relationType}". Expected ${Bi.join(" or ")}.`);continue}n.relationType===Qe.MANY_TO_ONE&&!n.joinColumnName&&a.push(`MANY_TO_ONE relation field "${i.name}" is missing joinColumnName. MANY_TO_ONE relations must declare a joinColumnName in universalSettings.`)}return a},vl=e=>{const a=[],i=new Set;for(const n of e){if(i.has(n))continue;if(i.add(n),!xe.validate(n)){a.push(`Universal identifier "${n}" is not a valid UUID.`);continue}const s=xe.version(n);s<Qt&&a.push(`Universal identifier "${n}" is UUID version ${s}. Only UUID version ${Qt} or higher is allowed.`)}return a},jl=e=>{const a=[],i=[],n=qo(e),s=ml(n);s.length>0&&a.push(`Duplicate universal identifiers: ${s.join(", ")}`);const r=vl(n);r.length>0&&a.push(`Duplicate universal identifiers: ${r.join(", ")}`),Xi(e.objects)||i.push("No object defined"),Xi(e.logicFunctions)||i.push("No logic function defined"),Xi(e.frontComponents)||i.push("No front component defined");const l=[...e.fields,...e.objects.flatMap(g=>g.fields)];return a.push(...wl(l)),{errors:a,warnings:i,isValid:a.length===0}},wn=async e=>{const a=await Vo(e);if(a.errors.length>0||!a.manifest)return{success:!1,errors:a.errors.length>0?a.errors:["Failed to build manifest."]};const i=jl(a.manifest);return i.isValid?{success:!0,manifest:a.manifest,filePaths:a.filePaths,warnings:[...a.warnings,...i.warnings]}:{success:!1,errors:i.errors}},vn=({manifest:e,builtFileInfos:a})=>{let i=structuredClone(e);for(const[n,{fileFolder:s,checksum:r}]of a.entries()){const l=Q.relative(me,n);if(s===be.BuiltLogicFunction){const g=i.logicFunctions,h=g.findIndex(c=>c.builtHandlerPath===l);if(h===-1)continue;i={...i,logicFunctions:g.map((c,d)=>d===h?{...c,builtHandlerChecksum:r}:c)}}if(s===be.PublicAsset){const g=i.publicAssets,h=g.findIndex(c=>c.filePath===l);if(h===-1)continue;i={...i,publicAssets:g.map((c,d)=>d===h?{...c,checksum:r}:c)};continue}if(s===be.BuiltFrontComponent){const g=i.frontComponents,h=g.findIndex(d=>d.builtComponentPath===l)??-1;if(h===-1)continue;const c=a.get(n);i={...i,frontComponents:g.map((d,p)=>p===h?{...d,builtComponentChecksum:r,usesSdkClient:c?.usesSdkClient??!1}:d)}}s===be.Dependencies&&(l==="package.json"&&(i.application.packageJsonChecksum=r),l==="yarn.lock"&&(i.application.yarnLockChecksum=r))}return i},jn=async(e,a)=>{const i=J.default.join(e,me);await ke(i);const n=J.default.join(i,"manifest.json");return await ld(n,a),n},ve=async(e,a)=>{try{return await e()}catch(i){return{success:!1,error:{code:a,message:i instanceof Error?i.message:"Unexpected error"}}}},Xe={AUTH_FAILED:"AUTH_FAILED",NO_REMOTES:"NO_REMOTES",REMOTE_NOT_FOUND:"REMOTE_NOT_FOUND",OAUTH_NOT_SUPPORTED:"OAUTH_NOT_SUPPORTED"},x={MANIFEST_NOT_FOUND:"MANIFEST_NOT_FOUND",MANIFEST_BUILD_FAILED:"MANIFEST_BUILD_FAILED",BUILD_FAILED:"BUILD_FAILED",PUBLISH_FAILED:"PUBLISH_FAILED",INSTALL_FAILED:"INSTALL_FAILED",UNINSTALL_FAILED:"UNINSTALL_FAILED",SYNC_FAILED:"SYNC_FAILED",TYPECHECK_FAILED:"TYPECHECK_FAILED",DEPLOY_FAILED:"DEPLOY_FAILED"},Ye={DOCKER_NOT_INSTALLED:"DOCKER_NOT_INSTALLED",DOCKER_NOT_RUNNING:"DOCKER_NOT_RUNNING",CONTAINER_START_FAILED:"CONTAINER_START_FAILED",HEALTH_TIMEOUT:"HEALTH_TIMEOUT",IMAGE_UPGRADE_FAILED:"IMAGE_UPGRADE_FAILED"},ka={FETCH_FUNCTIONS_FAILED:"FETCH_FUNCTIONS_FAILED",FUNCTION_NOT_FOUND:"FUNCTION_NOT_FOUND",EXECUTION_FAILED:"EXECUTION_FAILED"},Sl=async e=>{const{appPath:a,onProgress:i}=e;i?.("Building manifest...");const n=await wn(a);if(!n.success)return{success:!1,error:{code:x.MANIFEST_BUILD_FAILED,message:n.errors.join(`
|
|
58
58
|
`)}};const{manifest:s,filePaths:r}=n;for(const p of n.warnings)i?.(`⚠ ${p}`);i?.("Building application files...");const l=await zo({appPath:a,filePaths:r});i?.("Running typecheck...");const g=await Li(a);if(g.length>0){const p=g.map(o=>`${o.file}(${o.line},${o.column+1}): ${o.text}`);return{success:!1,error:{code:x.TYPECHECK_FAILED,message:`Typecheck failed:
|
|
59
59
|
${p.join(`
|
|
60
60
|
`)}`}}}const h=vn({manifest:s,builtFileInfos:l.builtFileInfos});await jn(a,h);const c=J.default.join(a,".twenty","output"),d={outputDir:c,fileCount:l.builtFileInfos.size};if(e.tarball){i?.("Packing tarball...");const o=Vt.execSync("npm pack --pack-destination .",{cwd:c,encoding:"utf-8"}).trim().split(`
|
|
61
|
-
`).pop();d.tarballPath=J.default.join(c,o)}return{success:!0,data:d}},eu=e=>ve(()=>Sl(e),x.BUILD_FAILED),Cl="2.4.
|
|
61
|
+
`).pop();d.tarballPath=J.default.join(c,o)}return{success:!0,data:d}},eu=e=>ve(()=>Sl(e),x.BUILD_FAILED),Cl="2.4.2",au={version:Cl},Wt=J.join(tn.homedir(),".twenty"),Ya=(e=!1)=>e||process.env.NODE_ENV==="test"?J.join(Wt,"config.test.json"):J.join(Wt,"config.json"),Oi=1,Ie="local",bi=class bi{constructor(a){this.configPath=a?.configPath??Ya()}static setActiveRemote(a){this.activeRemote=a??Ie}static getActiveRemote(){return this.activeRemote}getActiveRemoteName(){return bi.getActiveRemote()}async readRawConfig(){await dd(this.configPath);const a=await B.readFile(this.configPath,"utf8"),i=JSON.parse(a||"{}");return this.migrateConfigIfNeeded(i)}async migrateConfigIfNeeded(a){if(a.version===Oi)return a;const i="profiles"in a,n="apiUrl"in a&&!("remotes"in a);if(!i&&!n)return a;const s={version:Oi},r=d=>typeof d=="string"?d:void 0,l=d=>({apiUrl:r(d.apiUrl)??"",apiKey:r(d.apiKey),twentyCLIRegistrationClientId:r(d.twentyCLIRegistrationClientId)??r(d.oauthClientId),twentyCLIAccessToken:r(d.twentyCLIAccessToken)??r(d.accessToken)??r(d.applicationAccessToken),twentyCLIRefreshToken:r(d.twentyCLIRefreshToken)??r(d.refreshToken)??r(d.applicationRefreshToken),appRegistrationId:r(d.appRegistrationId),appRegistrationClientId:r(d.appRegistrationClientId),appAccessToken:r(d.appAccessToken),appRefreshToken:r(d.appRefreshToken)}),g=a.profiles??{};s.remotes={};for(const[d,p]of Object.entries(g)){const o=d==="default"?Ie:d;s.remotes[o]=l(p)}const h=a.remotes??{};for(const[d,p]of Object.entries(h)){const o=d==="default"?Ie:d;s.remotes[o]=p}n&&!s.remotes[Ie]&&(s.remotes[Ie]=l(a));const c=a.defaultWorkspace;return c&&(s.defaultRemote=c==="default"?Ie:c),await ke(J.dirname(this.configPath)),await B.writeFile(this.configPath,JSON.stringify(s,null,2)),s}async getConfig(){return this.getConfigForRemote(this.getActiveRemoteName())}async getConfigForRemote(a){const i=this.getDefaultConfig();try{const s=(await this.readRawConfig()).remotes?.[a];return s?{apiUrl:s.apiUrl||i.apiUrl,apiKey:s.apiKey,twentyCLIRegistrationId:s.twentyCLIRegistrationId,twentyCLIRegistrationClientId:s.twentyCLIRegistrationClientId,twentyCLIAccessToken:s.twentyCLIAccessToken,twentyCLIRefreshToken:s.twentyCLIRefreshToken,appRegistrationId:s.appRegistrationId,appRegistrationClientId:s.appRegistrationClientId,appAccessToken:s.appAccessToken,appRefreshToken:s.appRefreshToken}:i}catch{return i}}async setConfig(a){const i=await this.readRawConfig(),n=this.getActiveRemoteName();i.version=Oi,i.remotes||(i.remotes={});const s=i.remotes[n]??this.getDefaultConfig();i.remotes[n]={...s,...a},await ke(J.dirname(this.configPath)),await B.writeFile(this.configPath,JSON.stringify(i,null,2))}async clearConfig(){const a=await this.readRawConfig(),i=this.getActiveRemoteName();a.remotes||(a.remotes={}),a.remotes[i]&&delete a.remotes[i],await ke(J.dirname(this.configPath)),await B.writeFile(this.configPath,JSON.stringify(a,null,2))}getDefaultConfig(){return{apiUrl:"http://localhost:2020"}}async getRemotes(){try{const a=await this.readRawConfig(),i=new Set;return i.add(Ie),a.remotes&&Object.keys(a.remotes).forEach(n=>i.add(n)),Array.from(i).sort()}catch{return[Ie]}}async getDefaultRemote(){try{return(await this.readRawConfig()).defaultRemote??Ie}catch{return Ie}}async setDefaultRemote(a){const i=await this.readRawConfig();i.defaultRemote=a,await ke(J.dirname(this.configPath)),await B.writeFile(this.configPath,JSON.stringify(i,null,2))}};bi.activeRemote=Ie;let W=bi;class Il{constructor(a){const{disableInterceptors:i=!1,serverUrl:n,token:s,skipAuth:r=!1}=a||{};this.configService=new W,this.tokenOverride=s,this.serverUrlOverride=n,this.client=ye.default.create(),this.client.interceptors.request.use(async l=>{const g=await this.configService.getConfig();if(l.baseURL=this.serverUrlOverride??g.apiUrl,!l.headers.Authorization&&!r){const h=await this.resolveAuthToken();h&&(l.headers.Authorization=`Bearer ${h}`)}return l}),!i&&this.client.interceptors.response.use(l=>l,async l=>{throw l.response?.status===401?console.error(la.default.red("Authentication failed. Run `yarn twenty remote add` to authenticate.")):l.response?.status===403?console.error(la.default.red("Access denied. Check your API key and workspace permissions.")):l.code==="ECONNREFUSED"&&console.error(la.default.red("Cannot connect to Twenty server. Is it running?")),l})}async validateAuth(){try{const i=await this.client.post("/metadata",{query:`
|
|
62
62
|
query CurrentWorkspace {
|
|
63
63
|
currentWorkspace {
|
|
64
64
|
id
|
|
@@ -10390,7 +10390,7 @@ const Kd = {
|
|
|
10390
10390
|
type: "object",
|
|
10391
10391
|
properties: {}
|
|
10392
10392
|
}, pl = async (e) => {
|
|
10393
|
-
const { getFunctionInputSchema: a } = await import("./get-function-input-schema-BZ7_XyUh-
|
|
10393
|
+
const { getFunctionInputSchema: a } = await import("./get-function-input-schema-BZ7_XyUh-Dd-bckv_.mjs"), i = a(e)[0];
|
|
10394
10394
|
return i?.type === "object" && He(i.properties) ? {
|
|
10395
10395
|
type: "object",
|
|
10396
10396
|
properties: i.properties
|
|
@@ -10925,7 +10925,7 @@ ${p.join(`
|
|
|
10925
10925
|
d.tarballPath = B.join(c, o);
|
|
10926
10926
|
}
|
|
10927
10927
|
return { success: !0, data: d };
|
|
10928
|
-
}, Ll = (e) => je(() => Il(e), X.BUILD_FAILED), $l = "2.4.
|
|
10928
|
+
}, Ll = (e) => je(() => Il(e), X.BUILD_FAILED), $l = "2.4.2", kl = {
|
|
10929
10929
|
version: $l
|
|
10930
10930
|
}, _t = he.join(Qt.homedir(), ".twenty"), li = (e = !1) => e || process.env.NODE_ENV === "test" ? he.join(_t, "config.test.json") : he.join(_t, "config.json"), _i = 1, ye = "local", fi = class fi {
|
|
10931
10931
|
constructor(a) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twenty-sdk",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"bin": {
|
|
6
6
|
"twenty": "dist/cli.cjs"
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"react": "^19.0.0",
|
|
84
84
|
"react-dom": "^19.0.0",
|
|
85
85
|
"tinyglobby": "^0.2.15",
|
|
86
|
-
"twenty-client-sdk": "2.4.
|
|
86
|
+
"twenty-client-sdk": "2.4.2",
|
|
87
87
|
"typescript": "^5.9.2",
|
|
88
88
|
"uuid": "^13.0.0",
|
|
89
89
|
"vite": "^7.0.0",
|