twenty-sdk 2.4.0 → 2.4.1
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/commands/dev.d.ts +1 -0
- package/dist/cli/constants/dev-api-key.d.ts +2 -0
- package/dist/cli/operations/index.d.ts +1 -0
- package/dist/cli/types.d.ts +1 -0
- package/dist/cli.cjs +11 -11
- package/dist/cli.mjs +372 -376
- package/dist/define/index.cjs +1 -1
- package/dist/define/index.cjs.map +1 -1
- package/dist/define/index.mjs +4 -2
- package/dist/define/index.mjs.map +1 -1
- package/dist/front-component/index.cjs +1 -1
- package/dist/front-component/index.cjs.map +1 -1
- package/dist/front-component/index.d.ts +3 -1
- package/dist/front-component/index.mjs +23 -17
- package/dist/front-component/index.mjs.map +1 -1
- package/dist/{get-function-input-schema-BZ7_XyUh-DT3stfoz.js → get-function-input-schema-BZ7_XyUh-DA45tC6Z.js} +1 -1
- package/dist/{get-function-input-schema-BZ7_XyUh-OrMskPPC.mjs → get-function-input-schema-BZ7_XyUh-KX7PWzdV.mjs} +1 -1
- package/dist/operations.cjs +1 -1
- package/dist/operations.mjs +24 -22
- package/dist/{uninstall-BIllVz44.js → uninstall-C6NJA8FL.js} +5 -5
- package/dist/{uninstall-XLw7db6v.mjs → uninstall-D_Xoz10Q.mjs} +28 -25
- 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-C6NJA8FL.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-C6NJA8FL.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,28 +1,30 @@
|
|
|
1
|
-
import { r as
|
|
2
|
-
import { a as p, F as
|
|
3
|
-
const
|
|
1
|
+
import { r as t, A as s, C as a } from "./uninstall-D_Xoz10Q.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-D_Xoz10Q.mjs";
|
|
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,
|
|
6
|
-
|
|
6
|
+
s as AUTH_ERROR_CODES,
|
|
7
7
|
a as ConfigService,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
r as DEV_API_KEY,
|
|
9
|
+
I as DEV_API_URL,
|
|
10
|
+
N as FUNCTION_ERROR_CODES,
|
|
11
|
+
g as SERVER_ERROR_CODES,
|
|
12
|
+
A as appBuild,
|
|
13
|
+
R as appDeploy,
|
|
14
|
+
M as appDevOnce,
|
|
15
|
+
S as appInstall,
|
|
14
16
|
l as appPublish,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
u as appUninstall,
|
|
18
|
+
C as authLogin,
|
|
19
|
+
j as authLoginOAuth,
|
|
20
|
+
c as authLogout,
|
|
21
|
+
m as checkDockerRunning,
|
|
22
|
+
O as containerExists,
|
|
21
23
|
h as detectLocalServer,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
y as functionExecute,
|
|
25
|
+
L as getContainerDigest,
|
|
26
|
+
_ as getImageDigest,
|
|
27
|
+
f as getImageForVersion,
|
|
28
|
+
Y as serverStart,
|
|
29
|
+
d as serverUpgrade
|
|
28
30
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";const Zu=require("fs"),Vt=require("child_process"),Q=require("path"),Pu=require("node:http"),ne=require("node:child_process"),Mu=require("node:crypto"),Eu=require("axios"),Ju=require("chalk"),Nu=require("node:util"),B=require("node:fs/promises"),Fu=require("os"),Ru=require("crypto"),_u=require("esbuild"),an=require("./get-front-component-build-plugins-Ce_mghCA.js"),ue=require("@sniptt/guards"),nn=require("node:path"),xe=require("uuid"),Hu=require("twenty-client-sdk/generate"),Xu=require("node:fs"),U=require("zod"),xu=require("graphql-sse"),Ti=require("graphql"),Bu=require("typescript"),Ou=require("fs/promises"),Gu=require("module"),qt=require("tinyglobby"),Ke=e=>e&&e.__esModule?e:{default:e};function pa(e){if(e&&e.__esModule)return e;const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const n=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(a,i,n.get?n:{enumerable:!0,get:()=>e[i]})}}return a.default=e,Object.freeze(a)}const Gi=pa(Zu),J=pa(Q),Qu=Ke(Pu),Mn=Ke(Mu),ye=Ke(Eu),la=Ke(Ju),tn=pa(Fu),eo=Ke(Ru),on=pa(_u),En=Ke(nn),Te=Ke(U),ta=pa(Bu),Wu=pa(Ou),ao="public",Ku="TWENTY_API_URL",Uu="TWENTY_APP_ACCESS_TOKEN",io={js:`import { createRequire as __createRequire } from 'module';
|
|
2
|
-
const require = __createRequire(import.meta.url);`},me=".twenty/output";var no=(e=>(e.Object="object",e.Field="field",e.LogicFunction="logicFunction",e.FrontComponent="frontComponent",e.Role="role",e.Skill="skill",e.Agent="agent",e.ConnectionProvider="connectionProvider",e.View="view",e.NavigationMenuItem="navigationMenuItem",e.PageLayout="pageLayout",e.PageLayoutTab="pageLayoutTab",e.CommandMenuItem="commandMenuItem",e))(no||{}),I=(e=>(e.ACTOR="ACTOR",e.ADDRESS="ADDRESS",e.ARRAY="ARRAY",e.BOOLEAN="BOOLEAN",e.CURRENCY="CURRENCY",e.DATE="DATE",e.DATE_TIME="DATE_TIME",e.EMAILS="EMAILS",e.FILES="FILES",e.FULL_NAME="FULL_NAME",e.LINKS="LINKS",e.MORPH_RELATION="MORPH_RELATION",e.MULTI_SELECT="MULTI_SELECT",e.NUMBER="NUMBER",e.NUMERIC="NUMERIC",e.PHONES="PHONES",e.POSITION="POSITION",e.RATING="RATING",e.RAW_JSON="RAW_JSON",e.RELATION="RELATION",e.RICH_TEXT="RICH_TEXT",e.SELECT="SELECT",e.TEXT="TEXT",e.TS_VECTOR="TS_VECTOR",e.UUID="UUID",e))(I||{}),Qi=(e=>(e.EMAIL="EMAIL",e.CALENDAR="CALENDAR",e.WORKFLOW="WORKFLOW",e.AGENT="AGENT",e.API="API",e.IMPORT="IMPORT",e.MANUAL="MANUAL",e.SYSTEM="SYSTEM",e.WEBHOOK="WEBHOOK",e.APPLICATION="APPLICATION",e))(Qi||{});const zu={type:I.ACTOR,properties:[{name:"source",type:I.SELECT,hidden:!1,isRequired:!0,options:Object.keys(Qi).map((e,a)=>({id:xe.v4(),label:`${Qi[e].toLowerCase()}`,value:e,position:a}))},{name:"workspaceMemberId",type:I.UUID,hidden:"input",isRequired:!1},{name:"name",type:I.TEXT,hidden:"input",isRequired:!0},{name:"context",type:I.RAW_JSON,hidden:!1,isRequired:!1}]};var di=(e=>(e.MONDAY="MONDAY",e.SUNDAY="SUNDAY",e.SATURDAY="SATURDAY",e))(di||{}),Oe=(e=>(e.DAY="DAY",e.MONTH="MONTH",e.QUARTER="QUARTER",e.YEAR="YEAR",e.WEEK="WEEK",e.DAY_OF_THE_WEEK="DAY_OF_THE_WEEK",e.MONTH_OF_THE_YEAR="MONTH_OF_THE_YEAR",e.QUARTER_OF_THE_YEAR="QUARTER_OF_THE_YEAR",e.NONE="NONE",e))(Oe||{}),Ee=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var P=(e=>(e.IS="IS",e.IS_NOT_NULL="IS_NOT_NULL",e.IS_NOT="IS_NOT",e.LESS_THAN_OR_EQUAL="LESS_THAN_OR_EQUAL",e.GREATER_THAN_OR_EQUAL="GREATER_THAN_OR_EQUAL",e.IS_BEFORE="IS_BEFORE",e.IS_AFTER="IS_AFTER",e.CONTAINS="CONTAINS",e.DOES_NOT_CONTAIN="DOES_NOT_CONTAIN",e.IS_EMPTY="IS_EMPTY",e.IS_NOT_EMPTY="IS_NOT_EMPTY",e.IS_RELATIVE="IS_RELATIVE",e.IS_IN_PAST="IS_IN_PAST",e.IS_IN_FUTURE="IS_IN_FUTURE",e.IS_TODAY="IS_TODAY",e.VECTOR_SEARCH="VECTOR_SEARCH",e))(P||{}),ae=(e=>(e.Is="is",e.IsNotNull="isNotNull",e.IsNot="isNot",e.LessThanOrEqual="lessThan",e.GreaterThanOrEqual="greaterThan",e.IsBefore="isBefore",e.IsAfter="isAfter",e.Contains="contains",e.DoesNotContain="doesNotContain",e.IsEmpty="isEmpty",e.IsNotEmpty="isNotEmpty",e.IsRelative="isRelative",e.IsInPast="isInPast",e.IsInFuture="isInFuture",e.IsToday="isToday",e))(ae||{}),to=(e=>(e.MIN="MIN",e.MAX="MAX",e.AVG="AVG",e.SUM="SUM",e.COUNT="COUNT",e.COUNT_UNIQUE_VALUES="COUNT_UNIQUE_VALUES",e.COUNT_EMPTY="COUNT_EMPTY",e.COUNT_NOT_EMPTY="COUNT_NOT_EMPTY",e.COUNT_TRUE="COUNT_TRUE",e.COUNT_FALSE="COUNT_FALSE",e.PERCENTAGE_EMPTY="PERCENTAGE_EMPTY",e.PERCENTAGE_NOT_EMPTY="PERCENTAGE_NOT_EMPTY",e))(to||{});const qu={type:I.ADDRESS,properties:[{name:"addressStreet1",type:I.TEXT,hidden:!1,isRequired:!1},{name:"addressStreet2",type:I.TEXT,hidden:!1,isRequired:!1},{name:"addressCity",type:I.TEXT,hidden:!1,isRequired:!1},{name:"addressPostcode",type:I.TEXT,hidden:!1,isRequired:!1},{name:"addressState",type:I.TEXT,hidden:!1,isRequired:!1},{name:"addressCountry",type:I.TEXT,hidden:!1,isRequired:!1},{name:"addressLat",type:I.NUMERIC,hidden:!1,isRequired:!1},{name:"addressLng",type:I.NUMERIC,hidden:!1,isRequired:!1}]},es={type:I.CURRENCY,properties:[{name:"amountMicros",type:I.NUMERIC,hidden:!1,isRequired:!1},{name:"currencyCode",type:I.TEXT,hidden:!1,isRequired:!1}]},as={type:I.EMAILS,properties:[{name:"primaryEmail",type:I.TEXT,hidden:!1,isRequired:!1,isIncludedInUniqueConstraint:!0},{name:"additionalEmails",type:I.RAW_JSON,hidden:!1,isRequired:!1}]},is={type:I.FULL_NAME,properties:[{name:"firstName",type:I.TEXT,hidden:!1,isRequired:!1,isIncludedInUniqueConstraint:!1},{name:"lastName",type:I.TEXT,hidden:!1,isRequired:!1,isIncludedInUniqueConstraint:!1}]},ns={type:I.LINKS,properties:[{name:"primaryLinkLabel",type:I.TEXT,hidden:!1,isRequired:!1},{name:"primaryLinkUrl",type:I.TEXT,hidden:!1,isRequired:!1,isIncludedInUniqueConstraint:!0},{name:"secondaryLinks",type:I.RAW_JSON,hidden:!1,isRequired:!1}]},ts={type:I.PHONES,properties:[{name:"primaryPhoneNumber",type:I.TEXT,hidden:!1,isRequired:!1,isIncludedInUniqueConstraint:!0},{name:"primaryPhoneCountryCode",type:I.TEXT,hidden:!1,isRequired:!1},{name:"primaryPhoneCallingCode",type:I.TEXT,hidden:!1,isRequired:!1},{name:"additionalPhones",type:I.RAW_JSON,hidden:!1,isRequired:!1}]},os={type:I.RICH_TEXT,properties:[{name:"blocknote",type:I.TEXT,hidden:!1,isRequired:!1},{name:"markdown",type:I.TEXT,hidden:!1,isRequired:!1}]};U.z.object({blocknote:U.z.string().nullable().optional(),markdown:U.z.string().nullable()});I.LINKS,I.CURRENCY,I.FULL_NAME,I.ADDRESS,I.ACTOR,I.EMAILS,I.PHONES,I.RICH_TEXT;var oo=(e=>(e.COPY="COPY",e.OPEN_LINK="OPEN_LINK",e.OPEN_IN_APP="OPEN_IN_APP",e))(oo||{}),uo=(e=>(e.FLOAT="float",e.INT="int",e.BIGINT="bigint",e))(uo||{}),so=(e=>(e.RELATIVE="RELATIVE",e.USER_SETTINGS="USER_SETTINGS",e.CUSTOM="CUSTOM",e))(so||{}),be=(e=>(e.ProfilePicture="profile-picture",e.WorkspaceLogo="workspace-logo",e.Attachment="attachment",e.PersonPicture="person-picture",e.CorePicture="core-picture",e.File="file",e.AgentChat="agent-chat",e.BuiltLogicFunction="built-logic-function",e.BuiltFrontComponent="built-front-component",e.PublicAsset="public-asset",e.Source="source",e.FilesField="files-field",e.Dependencies="dependencies",e.Workflow="workflow",e.EmailAttachment="email-attachment",e.AppTarball="app-tarball",e.GeneratedSdkClient="generated-sdk-client",e))(be||{}),ro=(e=>(e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE",e))(ro||{}),lo=(e=>(e.VIEW="VIEW",e.FOLDER="FOLDER",e.LINK="LINK",e.OBJECT="OBJECT",e.RECORD="RECORD",e.PAGE_LAYOUT="PAGE_LAYOUT",e))(lo||{}),go=(e=>(e.GRID="GRID",e.VERTICAL_LIST="VERTICAL_LIST",e.CANVAS="CANVAS",e))(go||{}),un=(e=>(e.CASCADE="CASCADE",e.RESTRICT="RESTRICT",e.SET_NULL="SET_NULL",e.NO_ACTION="NO_ACTION",e))(un||{}),Qe=(e=>(e.MANY_TO_ONE="MANY_TO_ONE",e.ONE_TO_MANY="ONE_TO_MANY",e))(Qe||{}),ho=(e=>(e.DAY="DAY",e.WEEK="WEEK",e.MONTH="MONTH",e))(ho||{}),co=(e=>(e.AND="AND",e.OR="OR",e.NOT="NOT",e))(co||{}),fo=(e=>(e.INDEX="INDEX",e))(fo||{}),po=(e=>(e.SIDE_PANEL="SIDE_PANEL",e.RECORD_PAGE="RECORD_PAGE",e))(po||{}),oa=(e=>(e.ASC="ASC",e.DESC="DESC",e))(oa||{}),sn=(e=>(e.TABLE="TABLE",e.KANBAN="KANBAN",e.CALENDAR="CALENDAR",e.FIELDS_WIDGET="FIELDS_WIDGET",e.TABLE_WIDGET="TABLE_WIDGET",e))(sn||{}),bo=(e=>(e.WORKSPACE="WORKSPACE",e.UNLISTED="UNLISTED",e))(bo||{});const Fe=e=>!ue.isUndefined(e)&&!ue.isNull(e);var pe="INUMBER",ba="IOP1",ya="IOP2",ma="IOP3",Je="IVAR",We="IVARNAME",ha="IFUNCALL",yi="IFUNDEF",ge="IEXPR",rn="IEXPREVAL",Ue="IMEMBER",mi="IENDSTATEMENT",ca="IARRAY";function N(e,a){this.type=e,this.value=a??0}N.prototype.toString=function(){switch(this.type){case pe:case ba:case ya:case ma:case Je:case We:case mi:return this.value;case ha:return"CALL "+this.value;case yi:return"DEF "+this.value;case ca:return"ARRAY "+this.value;case Ue:return"."+this.value;default:return"Invalid Instruction"}};function wi(e){return new N(ba,e)}function Re(e){return new N(ya,e)}function yo(e){return new N(ma,e)}function Wi(e,a,i,n,s){for(var r=[],l=[],g,h,c,d,p=0;p<e.length;p++){var o=e[p],u=o.type;if(u===pe||u===We)Array.isArray(o.value)?r.push.apply(r,Wi(o.value.map(function(t){return new N(pe,t)}).concat(new N(ca,o.value.length)),a,i,n,s)):r.push(o);else if(u===Je&&Object.hasOwn(s,o.value))o=new N(pe,s[o.value]),r.push(o);else if(u===ya&&r.length>1)h=r.pop(),g=r.pop(),d=i[o.value],o=new N(pe,d(g.value,h.value)),r.push(o);else if(u===ma&&r.length>2)c=r.pop(),h=r.pop(),g=r.pop(),o.value==="?"?r.push(g.value?h.value:c.value):(d=n[o.value],o=new N(pe,d(g.value,h.value,c.value)),r.push(o));else if(u===ba&&r.length>0)g=r.pop(),d=a[o.value],o=new N(pe,d(g.value)),r.push(o);else if(u===ge){for(;r.length>0;)l.push(r.shift());l.push(new N(ge,Wi(o.value,a,i,n,s)))}else if(u===Ue&&r.length>0)g=r.pop(),r.push(new N(pe,g.value[o.value]));else{for(;r.length>0;)l.push(r.shift());l.push(o)}}for(;r.length>0;)l.push(r.shift());return l}function mo(e,a,i){for(var n=[],s=0;s<e.length;s++){var r=e[s],l=r.type;if(l===Je&&r.value===a)for(var g=0;g<i.tokens.length;g++){var h=i.tokens[g],c;h.type===ba?c=wi(h.value):h.type===ya?c=Re(h.value):h.type===ma?c=yo(h.value):c=new N(h.type,h.value),n.push(c)}else l===ge?n.push(new N(ge,mo(r.value,a,i))):n.push(r)}return n}function Ai(e,a,i){if(Object.values(a.functions).includes(e))return!0;for(const s of Object.values(i))if(typeof s=="object"&&s!==null){for(const r of Object.values(s))if(r===e){const l=Object.freeze({abs:Math.abs,acos:Math.acos,asin:Math.asin,atan:Math.atan,atan2:Math.atan2,ceil:Math.ceil,clz32:Math.clz32,cos:Math.cos,exp:Math.exp,floor:Math.floor,imul:Math.imul,fround:Math.fround,f16round:Math.f16round,log:Math.log,max:Math.max,min:Math.min,pow:Math.pow,random:Math.random,round:Math.round,sin:Math.sin,sqrt:Math.sqrt,tan:Math.tan,log10:Math.log10,log2:Math.log2,log1p:Math.log1p,expm1:Math.expm1,cosh:Math.cosh,sinh:Math.sinh,tanh:Math.tanh,acosh:Math.acosh,asinh:Math.asinh,atanh:Math.atanh,hypot:Math.hypot,trunc:Math.trunc,sign:Math.sign,cbrt:Math.cbrt});for(var n of Object.getOwnPropertyNames(l))if(l[n]===r)return!0;return Object.values(a.functions).includes(r)}}return!1}function Ge(e,a,i){var n=[],s,r,l,g,h,c;if(dn(e))return Pe(e,i);for(var d=e.length,p=0;p<d;p++){var o=e[p],u=o.type;if(u===pe||u===We)n.push(o.value);else if(u===ya)r=n.pop(),s=n.pop(),o.value==="and"?n.push(s?!!Ge(r,a,i):!1):o.value==="or"?n.push(s?!0:!!Ge(r,a,i)):o.value==="="?(g=a.binaryOps[o.value],n.push(g(s,Ge(r,a,i),i))):(g=a.binaryOps[o.value],n.push(g(Pe(s,i),Pe(r,i))));else if(u===ma)l=n.pop(),r=n.pop(),s=n.pop(),o.value==="?"?n.push(Ge(s?r:l,a,i)):(g=a.ternaryOps[o.value],n.push(g(Pe(s,i),Pe(r,i),Pe(l,i))));else if(u===Je){if(/^__proto__|prototype|constructor$/.test(o.value))throw new Error("prototype access detected");if(o.value in a.functions)n.push(a.functions[o.value]);else if(o.value in a.unaryOps&&a.parser.isOperatorEnabled(o.value))n.push(a.unaryOps[o.value]);else{var t=i[o.value];if(t!==void 0){if(typeof t=="function"&&!Ai(t,a,i))throw new Error("Variable references an unallowed function: "+o.value);n.push(t)}else throw new Error("undefined variable: "+o.value)}}else if(u===ba)s=n.pop(),g=a.unaryOps[o.value],n.push(g(Pe(s,i)));else if(u===ha){for(c=o.value,h=[];c-- >0;)h.unshift(Pe(n.pop(),i));if(g=n.pop(),!Ai(g,a,i))throw new Error("Is not an allowed function.");if(g.apply&&g.call)n.push(g.apply(void 0,h));else throw new Error(g+" is not a function")}else if(u===yi)n.push((function(){for(var f=n.pop(),b=[],y=o.value;y-- >0;)b.unshift(n.pop());var m=n.pop(),j=function(){for(var v=Object.assign({},i),w=0,C=b.length;w<C;w++)v[b[w]]=arguments[w];return Ge(f,a,v)};return a.functions["lambda_"+a.functions.__counter++]=j,i[m]=j,j})());else if(u===ge)n.push(us(o,a));else if(u===rn)n.push(o);else if(u===Ue){if(s=n.pop(),/^__proto__|prototype|constructor$/.test(o.value))throw new Error("prototype access detected in MEMBER");if(typeof s=="object"&&typeof s[o.value]=="function"&&!Ai(s[o.value],a,i))throw new Error("Is not an allowed function in MEMBER.");n.push(s[o.value])}else if(u===mi)n.pop();else if(u===ca){for(c=o.value,h=[];c-- >0;)h.unshift(n.pop());n.push(h)}else throw new Error("invalid Expression")}if(n.length>1)throw new Error("invalid Expression (parity)");return n[0]===0?0:Pe(n[0],i)}function us(e,a,i){return dn(e)?e:{type:rn,value:function(n){return Ge(e.value,a,n)}}}function dn(e){return e&&e.type===rn}function Pe(e,a){return dn(e)?e.value(a):e}function ln(e,a){for(var i=[],n,s,r,l,g,h,c=0;c<e.length;c++){var d=e[c],p=d.type;if(p===pe)typeof d.value=="number"&&d.value<0?i.push("("+d.value+")"):Array.isArray(d.value)?i.push("["+d.value.map(Jn).join(", ")+"]"):i.push(Jn(d.value));else if(p===ya)s=i.pop(),n=i.pop(),l=d.value,a?l==="^"?i.push("Math.pow("+n+", "+s+")"):l==="and"?i.push("(!!"+n+" && !!"+s+")"):l==="or"?i.push("(!!"+n+" || !!"+s+")"):l==="||"?i.push("(function(a,b){ return Array.isArray(a) && Array.isArray(b) ? a.concat(b) : String(a) + String(b); }(("+n+"),("+s+")))"):l==="=="?i.push("("+n+" === "+s+")"):l==="!="?i.push("("+n+" !== "+s+")"):l==="["?i.push(n+"[("+s+") | 0]"):i.push("("+n+" "+l+" "+s+")"):l==="["?i.push(n+"["+s+"]"):i.push("("+n+" "+l+" "+s+")");else if(p===ma)if(r=i.pop(),s=i.pop(),n=i.pop(),l=d.value,l==="?")i.push("("+n+" ? "+s+" : "+r+")");else throw new Error("invalid Expression");else if(p===Je||p===We)i.push(d.value);else if(p===ba)n=i.pop(),l=d.value,l==="-"||l==="+"?i.push("("+l+n+")"):a?l==="not"?i.push("(!"+n+")"):l==="!"?i.push("fac("+n+")"):i.push(l+"("+n+")"):l==="!"?i.push("("+n+"!)"):i.push("("+l+" "+n+")");else if(p===ha){for(h=d.value,g=[];h-- >0;)g.unshift(i.pop());l=i.pop(),i.push(l+"("+g.join(", ")+")")}else if(p===yi){for(s=i.pop(),h=d.value,g=[];h-- >0;)g.unshift(i.pop());n=i.pop(),a?i.push("("+n+" = function("+g.join(", ")+") { return "+s+" })"):i.push("("+n+"("+g.join(", ")+") = "+s+")")}else if(p===Ue)n=i.pop(),i.push(n+"."+d.value);else if(p===ca){for(h=d.value,g=[];h-- >0;)g.unshift(i.pop());i.push("["+g.join(", ")+"]")}else if(p===ge)i.push("("+ln(d.value,a)+")");else if(p!==mi)throw new Error("invalid Expression")}return i.length>1&&(a?i=[i.join(",")]:i=[i.join(";")]),String(i[0])}function Jn(e){return typeof e=="string"?JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"):e}function ua(e,a){for(var i=0;i<e.length;i++)if(e[i]===a)return!0;return!1}function gn(e,a,i){i=i||{};for(var n=!!i.withMembers,s=null,r=0;r<e.length;r++){var l=e[r];l.type===Je||l.type===We?!n&&!ua(a,l.value)?a.push(l.value):(s!==null&&(ua(a,s)||a.push(s)),s=l.value):l.type===Ue&&n&&s!==null?s+="."+l.value:l.type===ge?gn(l.value,a,i):s!==null&&(ua(a,s)||a.push(s),s=null)}s!==null&&!ua(a,s)&&a.push(s)}function Le(e,a){this.tokens=e,this.parser=a,this.unaryOps=a.unaryOps,this.binaryOps=a.binaryOps,this.ternaryOps=a.ternaryOps,this.functions=a.functions}Le.prototype.simplify=function(e){return e=e||{},new Le(Wi(this.tokens,this.unaryOps,this.binaryOps,this.ternaryOps,e),this.parser)};Le.prototype.substitute=function(e,a){return a instanceof Le||(a=this.parser.parse(String(a))),new Le(mo(this.tokens,e,a),this.parser)};Le.prototype.evaluate=function(e){return e=e||{},Ge(this.tokens,this,e)};Le.prototype.toString=function(){return ln(this.tokens,!1)};Le.prototype.symbols=function(e){e=e||{};var a=[];return gn(this.tokens,a,e),a};Le.prototype.variables=function(e){e=e||{};var a=[];gn(this.tokens,a,e);var i=this.functions;return a.filter(function(n){return!(n in i)})};Le.prototype.toJSFunction=function(e,a){var i=this,n=new Function(e,"with(this.functions) with (this.ternaryOps) with (this.binaryOps) with (this.unaryOps) { return "+ln(this.simplify(a).tokens,!0)+"; }");return function(){return n.apply(i,arguments)}};var Ta="TEOF",R="TOP",vi="TNUMBER",wo="TSTRING",Ne="TPAREN",fa="TBRACKET",ji="TCOMMA",hn="TNAME",cn="TSEMICOLON";function vo(e,a,i){this.type=e,this.value=a,this.index=i}vo.prototype.toString=function(){return this.type+": "+this.value};function G(e,a){this.pos=0,this.current=null,this.unaryOps=e.unaryOps,this.binaryOps=e.binaryOps,this.ternaryOps=e.ternaryOps,this.consts=e.consts,this.expression=a,this.savedPosition=0,this.savedCurrent=null,this.options=e.options,this.parser=e}G.prototype.newToken=function(e,a,i){return new vo(e,a,i??this.pos)};G.prototype.save=function(){this.savedPosition=this.pos,this.savedCurrent=this.current};G.prototype.restore=function(){this.pos=this.savedPosition,this.current=this.savedCurrent};G.prototype.next=function(){if(this.pos>=this.expression.length)return this.newToken(Ta,"EOF");if(this.isWhitespace()||this.isComment())return this.next();if(this.isRadixInteger()||this.isNumber()||this.isOperator()||this.isString()||this.isParen()||this.isBracket()||this.isComma()||this.isSemicolon()||this.isNamedOp()||this.isConst()||this.isName())return this.current;this.parseError('Unknown character "'+this.expression.charAt(this.pos)+'"')};G.prototype.isString=function(){var e=!1,a=this.pos,i=this.expression.charAt(a);if(i==="'"||i==='"')for(var n=this.expression.indexOf(i,a+1);n>=0&&this.pos<this.expression.length;){if(this.pos=n+1,this.expression.charAt(n-1)!=="\\"){var s=this.expression.substring(a+1,n);this.current=this.newToken(wo,this.unescape(s),a),e=!0;break}n=this.expression.indexOf(i,n+1)}return e};G.prototype.isParen=function(){var e=this.expression.charAt(this.pos);return e==="("||e===")"?(this.current=this.newToken(Ne,e),this.pos++,!0):!1};G.prototype.isBracket=function(){var e=this.expression.charAt(this.pos);return(e==="["||e==="]")&&this.isOperatorEnabled("[")?(this.current=this.newToken(fa,e),this.pos++,!0):!1};G.prototype.isComma=function(){var e=this.expression.charAt(this.pos);return e===","?(this.current=this.newToken(ji,","),this.pos++,!0):!1};G.prototype.isSemicolon=function(){var e=this.expression.charAt(this.pos);return e===";"?(this.current=this.newToken(cn,";"),this.pos++,!0):!1};G.prototype.isConst=function(){for(var e=this.pos,a=e;a<this.expression.length;a++){var i=this.expression.charAt(a);if(i.toUpperCase()===i.toLowerCase()&&(a===this.pos||i!=="_"&&i!=="."&&(i<"0"||i>"9")))break}if(a>e){var n=this.expression.substring(e,a);if(n in this.consts)return this.current=this.newToken(vi,this.consts[n]),this.pos+=n.length,!0}return!1};G.prototype.isNamedOp=function(){for(var e=this.pos,a=e;a<this.expression.length;a++){var i=this.expression.charAt(a);if(i.toUpperCase()===i.toLowerCase()&&(a===this.pos||i!=="_"&&(i<"0"||i>"9")))break}if(a>e){var n=this.expression.substring(e,a);if(this.isOperatorEnabled(n)&&(n in this.binaryOps||n in this.unaryOps||n in this.ternaryOps))return this.current=this.newToken(R,n),this.pos+=n.length,!0}return!1};G.prototype.isName=function(){for(var e=this.pos,a=e,i=!1;a<this.expression.length;a++){var n=this.expression.charAt(a);if(n.toUpperCase()===n.toLowerCase()){if(a===this.pos&&(n==="$"||n==="_")){n==="_"&&(i=!0);continue}else if(a===this.pos||!i||n!=="_"&&(n<"0"||n>"9"))break}else i=!0}if(i){var s=this.expression.substring(e,a);return this.current=this.newToken(hn,s),this.pos+=s.length,!0}return!1};G.prototype.isWhitespace=function(){for(var e=!1,a=this.expression.charAt(this.pos);(a===" "||a===" "||a===`
|
|
2
|
+
const require = __createRequire(import.meta.url);`},me=".twenty/output";var no=(e=>(e.Object="object",e.Field="field",e.LogicFunction="logicFunction",e.FrontComponent="frontComponent",e.Role="role",e.Skill="skill",e.Agent="agent",e.ConnectionProvider="connectionProvider",e.View="view",e.NavigationMenuItem="navigationMenuItem",e.PageLayout="pageLayout",e.PageLayoutTab="pageLayoutTab",e.CommandMenuItem="commandMenuItem",e))(no||{}),I=(e=>(e.ACTOR="ACTOR",e.ADDRESS="ADDRESS",e.ARRAY="ARRAY",e.BOOLEAN="BOOLEAN",e.CURRENCY="CURRENCY",e.DATE="DATE",e.DATE_TIME="DATE_TIME",e.EMAILS="EMAILS",e.FILES="FILES",e.FULL_NAME="FULL_NAME",e.LINKS="LINKS",e.MORPH_RELATION="MORPH_RELATION",e.MULTI_SELECT="MULTI_SELECT",e.NUMBER="NUMBER",e.NUMERIC="NUMERIC",e.PHONES="PHONES",e.POSITION="POSITION",e.RATING="RATING",e.RAW_JSON="RAW_JSON",e.RELATION="RELATION",e.RICH_TEXT="RICH_TEXT",e.SELECT="SELECT",e.TEXT="TEXT",e.TS_VECTOR="TS_VECTOR",e.UUID="UUID",e))(I||{}),Qi=(e=>(e.EMAIL="EMAIL",e.CALENDAR="CALENDAR",e.WORKFLOW="WORKFLOW",e.AGENT="AGENT",e.API="API",e.IMPORT="IMPORT",e.MANUAL="MANUAL",e.SYSTEM="SYSTEM",e.WEBHOOK="WEBHOOK",e.APPLICATION="APPLICATION",e))(Qi||{});const zu={type:I.ACTOR,properties:[{name:"source",type:I.SELECT,hidden:!1,isRequired:!0,options:Object.keys(Qi).map((e,a)=>({id:xe.v4(),label:`${Qi[e].toLowerCase()}`,value:e,position:a}))},{name:"workspaceMemberId",type:I.UUID,hidden:"input",isRequired:!1},{name:"name",type:I.TEXT,hidden:"input",isRequired:!0},{name:"context",type:I.RAW_JSON,hidden:!1,isRequired:!1}]};var di=(e=>(e.MONDAY="MONDAY",e.SUNDAY="SUNDAY",e.SATURDAY="SATURDAY",e))(di||{}),Oe=(e=>(e.DAY="DAY",e.MONTH="MONTH",e.QUARTER="QUARTER",e.YEAR="YEAR",e.WEEK="WEEK",e.DAY_OF_THE_WEEK="DAY_OF_THE_WEEK",e.MONTH_OF_THE_YEAR="MONTH_OF_THE_YEAR",e.QUARTER_OF_THE_YEAR="QUARTER_OF_THE_YEAR",e.NONE="NONE",e))(Oe||{}),Ee=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var P=(e=>(e.IS="IS",e.IS_NOT_NULL="IS_NOT_NULL",e.IS_NOT="IS_NOT",e.LESS_THAN_OR_EQUAL="LESS_THAN_OR_EQUAL",e.GREATER_THAN_OR_EQUAL="GREATER_THAN_OR_EQUAL",e.IS_BEFORE="IS_BEFORE",e.IS_AFTER="IS_AFTER",e.CONTAINS="CONTAINS",e.DOES_NOT_CONTAIN="DOES_NOT_CONTAIN",e.IS_EMPTY="IS_EMPTY",e.IS_NOT_EMPTY="IS_NOT_EMPTY",e.IS_RELATIVE="IS_RELATIVE",e.IS_IN_PAST="IS_IN_PAST",e.IS_IN_FUTURE="IS_IN_FUTURE",e.IS_TODAY="IS_TODAY",e.VECTOR_SEARCH="VECTOR_SEARCH",e))(P||{}),ae=(e=>(e.Is="is",e.IsNotNull="isNotNull",e.IsNot="isNot",e.LessThanOrEqual="lessThan",e.GreaterThanOrEqual="greaterThan",e.IsBefore="isBefore",e.IsAfter="isAfter",e.Contains="contains",e.DoesNotContain="doesNotContain",e.IsEmpty="isEmpty",e.IsNotEmpty="isNotEmpty",e.IsRelative="isRelative",e.IsInPast="isInPast",e.IsInFuture="isInFuture",e.IsToday="isToday",e))(ae||{}),to=(e=>(e.MIN="MIN",e.MAX="MAX",e.AVG="AVG",e.SUM="SUM",e.COUNT="COUNT",e.COUNT_UNIQUE_VALUES="COUNT_UNIQUE_VALUES",e.COUNT_EMPTY="COUNT_EMPTY",e.COUNT_NOT_EMPTY="COUNT_NOT_EMPTY",e.COUNT_TRUE="COUNT_TRUE",e.COUNT_FALSE="COUNT_FALSE",e.PERCENTAGE_EMPTY="PERCENTAGE_EMPTY",e.PERCENTAGE_NOT_EMPTY="PERCENTAGE_NOT_EMPTY",e))(to||{});const qu={type:I.ADDRESS,properties:[{name:"addressStreet1",type:I.TEXT,hidden:!1,isRequired:!1},{name:"addressStreet2",type:I.TEXT,hidden:!1,isRequired:!1},{name:"addressCity",type:I.TEXT,hidden:!1,isRequired:!1},{name:"addressPostcode",type:I.TEXT,hidden:!1,isRequired:!1},{name:"addressState",type:I.TEXT,hidden:!1,isRequired:!1},{name:"addressCountry",type:I.TEXT,hidden:!1,isRequired:!1},{name:"addressLat",type:I.NUMERIC,hidden:!1,isRequired:!1},{name:"addressLng",type:I.NUMERIC,hidden:!1,isRequired:!1}]},es={type:I.CURRENCY,properties:[{name:"amountMicros",type:I.NUMERIC,hidden:!1,isRequired:!1},{name:"currencyCode",type:I.TEXT,hidden:!1,isRequired:!1}]},as={type:I.EMAILS,properties:[{name:"primaryEmail",type:I.TEXT,hidden:!1,isRequired:!1,isIncludedInUniqueConstraint:!0},{name:"additionalEmails",type:I.RAW_JSON,hidden:!1,isRequired:!1}]},is={type:I.FULL_NAME,properties:[{name:"firstName",type:I.TEXT,hidden:!1,isRequired:!1,isIncludedInUniqueConstraint:!1},{name:"lastName",type:I.TEXT,hidden:!1,isRequired:!1,isIncludedInUniqueConstraint:!1}]},ns={type:I.LINKS,properties:[{name:"primaryLinkLabel",type:I.TEXT,hidden:!1,isRequired:!1},{name:"primaryLinkUrl",type:I.TEXT,hidden:!1,isRequired:!1,isIncludedInUniqueConstraint:!0},{name:"secondaryLinks",type:I.RAW_JSON,hidden:!1,isRequired:!1}]},ts={type:I.PHONES,properties:[{name:"primaryPhoneNumber",type:I.TEXT,hidden:!1,isRequired:!1,isIncludedInUniqueConstraint:!0},{name:"primaryPhoneCountryCode",type:I.TEXT,hidden:!1,isRequired:!1,isIncludedInUniqueConstraint:!0},{name:"primaryPhoneCallingCode",type:I.TEXT,hidden:!1,isRequired:!1,isIncludedInUniqueConstraint:!0},{name:"additionalPhones",type:I.RAW_JSON,hidden:!1,isRequired:!1}]},os={type:I.RICH_TEXT,properties:[{name:"blocknote",type:I.TEXT,hidden:!1,isRequired:!1},{name:"markdown",type:I.TEXT,hidden:!1,isRequired:!1}]};U.z.object({blocknote:U.z.string().nullable().optional(),markdown:U.z.string().nullable()});I.LINKS,I.CURRENCY,I.FULL_NAME,I.ADDRESS,I.ACTOR,I.EMAILS,I.PHONES,I.RICH_TEXT;var oo=(e=>(e.COPY="COPY",e.OPEN_LINK="OPEN_LINK",e.OPEN_IN_APP="OPEN_IN_APP",e))(oo||{}),uo=(e=>(e.FLOAT="float",e.INT="int",e.BIGINT="bigint",e))(uo||{}),so=(e=>(e.RELATIVE="RELATIVE",e.USER_SETTINGS="USER_SETTINGS",e.CUSTOM="CUSTOM",e))(so||{}),be=(e=>(e.ProfilePicture="profile-picture",e.WorkspaceLogo="workspace-logo",e.Attachment="attachment",e.PersonPicture="person-picture",e.CorePicture="core-picture",e.File="file",e.AgentChat="agent-chat",e.BuiltLogicFunction="built-logic-function",e.BuiltFrontComponent="built-front-component",e.PublicAsset="public-asset",e.Source="source",e.FilesField="files-field",e.Dependencies="dependencies",e.Workflow="workflow",e.EmailAttachment="email-attachment",e.AppTarball="app-tarball",e.GeneratedSdkClient="generated-sdk-client",e))(be||{}),ro=(e=>(e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE",e))(ro||{}),lo=(e=>(e.VIEW="VIEW",e.FOLDER="FOLDER",e.LINK="LINK",e.OBJECT="OBJECT",e.RECORD="RECORD",e.PAGE_LAYOUT="PAGE_LAYOUT",e))(lo||{}),go=(e=>(e.GRID="GRID",e.VERTICAL_LIST="VERTICAL_LIST",e.CANVAS="CANVAS",e))(go||{}),un=(e=>(e.CASCADE="CASCADE",e.RESTRICT="RESTRICT",e.SET_NULL="SET_NULL",e.NO_ACTION="NO_ACTION",e))(un||{}),Qe=(e=>(e.MANY_TO_ONE="MANY_TO_ONE",e.ONE_TO_MANY="ONE_TO_MANY",e))(Qe||{}),ho=(e=>(e.DAY="DAY",e.WEEK="WEEK",e.MONTH="MONTH",e))(ho||{}),co=(e=>(e.AND="AND",e.OR="OR",e.NOT="NOT",e))(co||{}),fo=(e=>(e.INDEX="INDEX",e))(fo||{}),po=(e=>(e.SIDE_PANEL="SIDE_PANEL",e.RECORD_PAGE="RECORD_PAGE",e))(po||{}),oa=(e=>(e.ASC="ASC",e.DESC="DESC",e))(oa||{}),sn=(e=>(e.TABLE="TABLE",e.KANBAN="KANBAN",e.CALENDAR="CALENDAR",e.FIELDS_WIDGET="FIELDS_WIDGET",e.TABLE_WIDGET="TABLE_WIDGET",e))(sn||{}),bo=(e=>(e.WORKSPACE="WORKSPACE",e.UNLISTED="UNLISTED",e))(bo||{});const Fe=e=>!ue.isUndefined(e)&&!ue.isNull(e);var pe="INUMBER",ba="IOP1",ya="IOP2",ma="IOP3",Je="IVAR",We="IVARNAME",ha="IFUNCALL",yi="IFUNDEF",ge="IEXPR",rn="IEXPREVAL",Ue="IMEMBER",mi="IENDSTATEMENT",ca="IARRAY";function N(e,a){this.type=e,this.value=a??0}N.prototype.toString=function(){switch(this.type){case pe:case ba:case ya:case ma:case Je:case We:case mi:return this.value;case ha:return"CALL "+this.value;case yi:return"DEF "+this.value;case ca:return"ARRAY "+this.value;case Ue:return"."+this.value;default:return"Invalid Instruction"}};function wi(e){return new N(ba,e)}function Re(e){return new N(ya,e)}function yo(e){return new N(ma,e)}function Wi(e,a,i,n,s){for(var r=[],l=[],g,h,c,d,p=0;p<e.length;p++){var o=e[p],u=o.type;if(u===pe||u===We)Array.isArray(o.value)?r.push.apply(r,Wi(o.value.map(function(t){return new N(pe,t)}).concat(new N(ca,o.value.length)),a,i,n,s)):r.push(o);else if(u===Je&&Object.hasOwn(s,o.value))o=new N(pe,s[o.value]),r.push(o);else if(u===ya&&r.length>1)h=r.pop(),g=r.pop(),d=i[o.value],o=new N(pe,d(g.value,h.value)),r.push(o);else if(u===ma&&r.length>2)c=r.pop(),h=r.pop(),g=r.pop(),o.value==="?"?r.push(g.value?h.value:c.value):(d=n[o.value],o=new N(pe,d(g.value,h.value,c.value)),r.push(o));else if(u===ba&&r.length>0)g=r.pop(),d=a[o.value],o=new N(pe,d(g.value)),r.push(o);else if(u===ge){for(;r.length>0;)l.push(r.shift());l.push(new N(ge,Wi(o.value,a,i,n,s)))}else if(u===Ue&&r.length>0)g=r.pop(),r.push(new N(pe,g.value[o.value]));else{for(;r.length>0;)l.push(r.shift());l.push(o)}}for(;r.length>0;)l.push(r.shift());return l}function mo(e,a,i){for(var n=[],s=0;s<e.length;s++){var r=e[s],l=r.type;if(l===Je&&r.value===a)for(var g=0;g<i.tokens.length;g++){var h=i.tokens[g],c;h.type===ba?c=wi(h.value):h.type===ya?c=Re(h.value):h.type===ma?c=yo(h.value):c=new N(h.type,h.value),n.push(c)}else l===ge?n.push(new N(ge,mo(r.value,a,i))):n.push(r)}return n}function Ai(e,a,i){if(Object.values(a.functions).includes(e))return!0;for(const s of Object.values(i))if(typeof s=="object"&&s!==null){for(const r of Object.values(s))if(r===e){const l=Object.freeze({abs:Math.abs,acos:Math.acos,asin:Math.asin,atan:Math.atan,atan2:Math.atan2,ceil:Math.ceil,clz32:Math.clz32,cos:Math.cos,exp:Math.exp,floor:Math.floor,imul:Math.imul,fround:Math.fround,f16round:Math.f16round,log:Math.log,max:Math.max,min:Math.min,pow:Math.pow,random:Math.random,round:Math.round,sin:Math.sin,sqrt:Math.sqrt,tan:Math.tan,log10:Math.log10,log2:Math.log2,log1p:Math.log1p,expm1:Math.expm1,cosh:Math.cosh,sinh:Math.sinh,tanh:Math.tanh,acosh:Math.acosh,asinh:Math.asinh,atanh:Math.atanh,hypot:Math.hypot,trunc:Math.trunc,sign:Math.sign,cbrt:Math.cbrt});for(var n of Object.getOwnPropertyNames(l))if(l[n]===r)return!0;return Object.values(a.functions).includes(r)}}return!1}function Ge(e,a,i){var n=[],s,r,l,g,h,c;if(dn(e))return Pe(e,i);for(var d=e.length,p=0;p<d;p++){var o=e[p],u=o.type;if(u===pe||u===We)n.push(o.value);else if(u===ya)r=n.pop(),s=n.pop(),o.value==="and"?n.push(s?!!Ge(r,a,i):!1):o.value==="or"?n.push(s?!0:!!Ge(r,a,i)):o.value==="="?(g=a.binaryOps[o.value],n.push(g(s,Ge(r,a,i),i))):(g=a.binaryOps[o.value],n.push(g(Pe(s,i),Pe(r,i))));else if(u===ma)l=n.pop(),r=n.pop(),s=n.pop(),o.value==="?"?n.push(Ge(s?r:l,a,i)):(g=a.ternaryOps[o.value],n.push(g(Pe(s,i),Pe(r,i),Pe(l,i))));else if(u===Je){if(/^__proto__|prototype|constructor$/.test(o.value))throw new Error("prototype access detected");if(o.value in a.functions)n.push(a.functions[o.value]);else if(o.value in a.unaryOps&&a.parser.isOperatorEnabled(o.value))n.push(a.unaryOps[o.value]);else{var t=i[o.value];if(t!==void 0){if(typeof t=="function"&&!Ai(t,a,i))throw new Error("Variable references an unallowed function: "+o.value);n.push(t)}else throw new Error("undefined variable: "+o.value)}}else if(u===ba)s=n.pop(),g=a.unaryOps[o.value],n.push(g(Pe(s,i)));else if(u===ha){for(c=o.value,h=[];c-- >0;)h.unshift(Pe(n.pop(),i));if(g=n.pop(),!Ai(g,a,i))throw new Error("Is not an allowed function.");if(g.apply&&g.call)n.push(g.apply(void 0,h));else throw new Error(g+" is not a function")}else if(u===yi)n.push((function(){for(var f=n.pop(),b=[],y=o.value;y-- >0;)b.unshift(n.pop());var m=n.pop(),j=function(){for(var v=Object.assign({},i),w=0,C=b.length;w<C;w++)v[b[w]]=arguments[w];return Ge(f,a,v)};return a.functions["lambda_"+a.functions.__counter++]=j,i[m]=j,j})());else if(u===ge)n.push(us(o,a));else if(u===rn)n.push(o);else if(u===Ue){if(s=n.pop(),/^__proto__|prototype|constructor$/.test(o.value))throw new Error("prototype access detected in MEMBER");if(typeof s=="object"&&typeof s[o.value]=="function"&&!Ai(s[o.value],a,i))throw new Error("Is not an allowed function in MEMBER.");n.push(s[o.value])}else if(u===mi)n.pop();else if(u===ca){for(c=o.value,h=[];c-- >0;)h.unshift(n.pop());n.push(h)}else throw new Error("invalid Expression")}if(n.length>1)throw new Error("invalid Expression (parity)");return n[0]===0?0:Pe(n[0],i)}function us(e,a,i){return dn(e)?e:{type:rn,value:function(n){return Ge(e.value,a,n)}}}function dn(e){return e&&e.type===rn}function Pe(e,a){return dn(e)?e.value(a):e}function ln(e,a){for(var i=[],n,s,r,l,g,h,c=0;c<e.length;c++){var d=e[c],p=d.type;if(p===pe)typeof d.value=="number"&&d.value<0?i.push("("+d.value+")"):Array.isArray(d.value)?i.push("["+d.value.map(Jn).join(", ")+"]"):i.push(Jn(d.value));else if(p===ya)s=i.pop(),n=i.pop(),l=d.value,a?l==="^"?i.push("Math.pow("+n+", "+s+")"):l==="and"?i.push("(!!"+n+" && !!"+s+")"):l==="or"?i.push("(!!"+n+" || !!"+s+")"):l==="||"?i.push("(function(a,b){ return Array.isArray(a) && Array.isArray(b) ? a.concat(b) : String(a) + String(b); }(("+n+"),("+s+")))"):l==="=="?i.push("("+n+" === "+s+")"):l==="!="?i.push("("+n+" !== "+s+")"):l==="["?i.push(n+"[("+s+") | 0]"):i.push("("+n+" "+l+" "+s+")"):l==="["?i.push(n+"["+s+"]"):i.push("("+n+" "+l+" "+s+")");else if(p===ma)if(r=i.pop(),s=i.pop(),n=i.pop(),l=d.value,l==="?")i.push("("+n+" ? "+s+" : "+r+")");else throw new Error("invalid Expression");else if(p===Je||p===We)i.push(d.value);else if(p===ba)n=i.pop(),l=d.value,l==="-"||l==="+"?i.push("("+l+n+")"):a?l==="not"?i.push("(!"+n+")"):l==="!"?i.push("fac("+n+")"):i.push(l+"("+n+")"):l==="!"?i.push("("+n+"!)"):i.push("("+l+" "+n+")");else if(p===ha){for(h=d.value,g=[];h-- >0;)g.unshift(i.pop());l=i.pop(),i.push(l+"("+g.join(", ")+")")}else if(p===yi){for(s=i.pop(),h=d.value,g=[];h-- >0;)g.unshift(i.pop());n=i.pop(),a?i.push("("+n+" = function("+g.join(", ")+") { return "+s+" })"):i.push("("+n+"("+g.join(", ")+") = "+s+")")}else if(p===Ue)n=i.pop(),i.push(n+"."+d.value);else if(p===ca){for(h=d.value,g=[];h-- >0;)g.unshift(i.pop());i.push("["+g.join(", ")+"]")}else if(p===ge)i.push("("+ln(d.value,a)+")");else if(p!==mi)throw new Error("invalid Expression")}return i.length>1&&(a?i=[i.join(",")]:i=[i.join(";")]),String(i[0])}function Jn(e){return typeof e=="string"?JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"):e}function ua(e,a){for(var i=0;i<e.length;i++)if(e[i]===a)return!0;return!1}function gn(e,a,i){i=i||{};for(var n=!!i.withMembers,s=null,r=0;r<e.length;r++){var l=e[r];l.type===Je||l.type===We?!n&&!ua(a,l.value)?a.push(l.value):(s!==null&&(ua(a,s)||a.push(s)),s=l.value):l.type===Ue&&n&&s!==null?s+="."+l.value:l.type===ge?gn(l.value,a,i):s!==null&&(ua(a,s)||a.push(s),s=null)}s!==null&&!ua(a,s)&&a.push(s)}function Le(e,a){this.tokens=e,this.parser=a,this.unaryOps=a.unaryOps,this.binaryOps=a.binaryOps,this.ternaryOps=a.ternaryOps,this.functions=a.functions}Le.prototype.simplify=function(e){return e=e||{},new Le(Wi(this.tokens,this.unaryOps,this.binaryOps,this.ternaryOps,e),this.parser)};Le.prototype.substitute=function(e,a){return a instanceof Le||(a=this.parser.parse(String(a))),new Le(mo(this.tokens,e,a),this.parser)};Le.prototype.evaluate=function(e){return e=e||{},Ge(this.tokens,this,e)};Le.prototype.toString=function(){return ln(this.tokens,!1)};Le.prototype.symbols=function(e){e=e||{};var a=[];return gn(this.tokens,a,e),a};Le.prototype.variables=function(e){e=e||{};var a=[];gn(this.tokens,a,e);var i=this.functions;return a.filter(function(n){return!(n in i)})};Le.prototype.toJSFunction=function(e,a){var i=this,n=new Function(e,"with(this.functions) with (this.ternaryOps) with (this.binaryOps) with (this.unaryOps) { return "+ln(this.simplify(a).tokens,!0)+"; }");return function(){return n.apply(i,arguments)}};var Ta="TEOF",R="TOP",vi="TNUMBER",wo="TSTRING",Ne="TPAREN",fa="TBRACKET",ji="TCOMMA",hn="TNAME",cn="TSEMICOLON";function vo(e,a,i){this.type=e,this.value=a,this.index=i}vo.prototype.toString=function(){return this.type+": "+this.value};function G(e,a){this.pos=0,this.current=null,this.unaryOps=e.unaryOps,this.binaryOps=e.binaryOps,this.ternaryOps=e.ternaryOps,this.consts=e.consts,this.expression=a,this.savedPosition=0,this.savedCurrent=null,this.options=e.options,this.parser=e}G.prototype.newToken=function(e,a,i){return new vo(e,a,i??this.pos)};G.prototype.save=function(){this.savedPosition=this.pos,this.savedCurrent=this.current};G.prototype.restore=function(){this.pos=this.savedPosition,this.current=this.savedCurrent};G.prototype.next=function(){if(this.pos>=this.expression.length)return this.newToken(Ta,"EOF");if(this.isWhitespace()||this.isComment())return this.next();if(this.isRadixInteger()||this.isNumber()||this.isOperator()||this.isString()||this.isParen()||this.isBracket()||this.isComma()||this.isSemicolon()||this.isNamedOp()||this.isConst()||this.isName())return this.current;this.parseError('Unknown character "'+this.expression.charAt(this.pos)+'"')};G.prototype.isString=function(){var e=!1,a=this.pos,i=this.expression.charAt(a);if(i==="'"||i==='"')for(var n=this.expression.indexOf(i,a+1);n>=0&&this.pos<this.expression.length;){if(this.pos=n+1,this.expression.charAt(n-1)!=="\\"){var s=this.expression.substring(a+1,n);this.current=this.newToken(wo,this.unescape(s),a),e=!0;break}n=this.expression.indexOf(i,n+1)}return e};G.prototype.isParen=function(){var e=this.expression.charAt(this.pos);return e==="("||e===")"?(this.current=this.newToken(Ne,e),this.pos++,!0):!1};G.prototype.isBracket=function(){var e=this.expression.charAt(this.pos);return(e==="["||e==="]")&&this.isOperatorEnabled("[")?(this.current=this.newToken(fa,e),this.pos++,!0):!1};G.prototype.isComma=function(){var e=this.expression.charAt(this.pos);return e===","?(this.current=this.newToken(ji,","),this.pos++,!0):!1};G.prototype.isSemicolon=function(){var e=this.expression.charAt(this.pos);return e===";"?(this.current=this.newToken(cn,";"),this.pos++,!0):!1};G.prototype.isConst=function(){for(var e=this.pos,a=e;a<this.expression.length;a++){var i=this.expression.charAt(a);if(i.toUpperCase()===i.toLowerCase()&&(a===this.pos||i!=="_"&&i!=="."&&(i<"0"||i>"9")))break}if(a>e){var n=this.expression.substring(e,a);if(n in this.consts)return this.current=this.newToken(vi,this.consts[n]),this.pos+=n.length,!0}return!1};G.prototype.isNamedOp=function(){for(var e=this.pos,a=e;a<this.expression.length;a++){var i=this.expression.charAt(a);if(i.toUpperCase()===i.toLowerCase()&&(a===this.pos||i!=="_"&&(i<"0"||i>"9")))break}if(a>e){var n=this.expression.substring(e,a);if(this.isOperatorEnabled(n)&&(n in this.binaryOps||n in this.unaryOps||n in this.ternaryOps))return this.current=this.newToken(R,n),this.pos+=n.length,!0}return!1};G.prototype.isName=function(){for(var e=this.pos,a=e,i=!1;a<this.expression.length;a++){var n=this.expression.charAt(a);if(n.toUpperCase()===n.toLowerCase()){if(a===this.pos&&(n==="$"||n==="_")){n==="_"&&(i=!0);continue}else if(a===this.pos||!i||n!=="_"&&(n<"0"||n>"9"))break}else i=!0}if(i){var s=this.expression.substring(e,a);return this.current=this.newToken(hn,s),this.pos+=s.length,!0}return!1};G.prototype.isWhitespace=function(){for(var e=!1,a=this.expression.charAt(this.pos);(a===" "||a===" "||a===`
|
|
3
3
|
`||a==="\r")&&(e=!0,this.pos++,!(this.pos>=this.expression.length));)a=this.expression.charAt(this.pos);return e};var ss=/^[0-9a-f]{4}$/i;G.prototype.unescape=function(e){var a=e.indexOf("\\");if(a<0)return e;for(var i=e.substring(0,a);a>=0;){var n=e.charAt(++a);switch(n){case"'":i+="'";break;case'"':i+='"';break;case"\\":i+="\\";break;case"/":i+="/";break;case"b":i+="\b";break;case"f":i+="\f";break;case"n":i+=`
|
|
4
4
|
`;break;case"r":i+="\r";break;case"t":i+=" ";break;case"u":var s=e.substring(a+1,a+5);ss.test(s)||this.parseError("Illegal escape sequence: \\u"+s),i+=String.fromCharCode(parseInt(s,16)),a+=4;break;default:throw this.parseError('Illegal escape sequence: "\\'+n+'"')}++a;var r=e.indexOf("\\",a);i+=e.substring(a,r<0?e.length:r),a=r}return i};G.prototype.isComment=function(){var e=this.expression.charAt(this.pos);return e==="/"&&this.expression.charAt(this.pos+1)==="*"?(this.pos=this.expression.indexOf("*/",this.pos)+2,this.pos===1&&(this.pos=this.expression.length),!0):!1};G.prototype.isRadixInteger=function(){var e=this.pos;if(e>=this.expression.length-2||this.expression.charAt(e)!=="0")return!1;++e;var a,i;if(this.expression.charAt(e)==="x")a=16,i=/^[0-9a-f]$/i,++e;else if(this.expression.charAt(e)==="b")a=2,i=/^[01]$/i,++e;else return!1;for(var n=!1,s=e;e<this.expression.length;){var r=this.expression.charAt(e);if(i.test(r))e++,n=!0;else break}return n&&(this.current=this.newToken(vi,parseInt(this.expression.substring(s,e),a)),this.pos=e),n};G.prototype.isNumber=function(){for(var e=!1,a=this.pos,i=a,n=a,s=!1,r=!1,l;a<this.expression.length&&(l=this.expression.charAt(a),l>="0"&&l<="9"||!s&&l===".");)l==="."?s=!0:r=!0,a++,e=r;if(e&&(n=a),l==="e"||l==="E"){a++;for(var g=!0,h=!1;a<this.expression.length;){if(l=this.expression.charAt(a),g&&(l==="+"||l==="-"))g=!1;else if(l>="0"&&l<="9")h=!0,g=!1;else break;a++}h||(a=n)}return e?(this.current=this.newToken(vi,parseFloat(this.expression.substring(i,a))),this.pos=a):this.pos=n,e};G.prototype.isOperator=function(){var e=this.pos,a=this.expression.charAt(this.pos);if(a==="+"||a==="-"||a==="*"||a==="/"||a==="%"||a==="^"||a==="?"||a===":"||a===".")this.current=this.newToken(R,a);else if(a==="∙"||a==="•")this.current=this.newToken(R,"*");else if(a===">")this.expression.charAt(this.pos+1)==="="?(this.current=this.newToken(R,">="),this.pos++):this.current=this.newToken(R,">");else if(a==="<")this.expression.charAt(this.pos+1)==="="?(this.current=this.newToken(R,"<="),this.pos++):this.current=this.newToken(R,"<");else if(a==="|")if(this.expression.charAt(this.pos+1)==="|")this.current=this.newToken(R,"||"),this.pos++;else return!1;else if(a==="=")this.expression.charAt(this.pos+1)==="="?(this.current=this.newToken(R,"=="),this.pos++):this.current=this.newToken(R,a);else if(a==="!")this.expression.charAt(this.pos+1)==="="?(this.current=this.newToken(R,"!="),this.pos++):this.current=this.newToken(R,a);else return!1;return this.pos++,this.isOperatorEnabled(this.current.value)?!0:(this.pos=e,!1)};G.prototype.isOperatorEnabled=function(e){return this.parser.isOperatorEnabled(e)};G.prototype.getCoordinates=function(){var e=0,a,i=-1;do e++,a=this.pos-i,i=this.expression.indexOf(`
|
|
5
5
|
`,i+1);while(i>=0&&i<this.pos);return{line:e,column:a}};G.prototype.parseError=function(e){var a=this.getCoordinates();throw new Error("parse error ["+a.line+":"+a.column+"]: "+e)};function H(e,a,i){this.parser=e,this.tokens=a,this.current=null,this.nextToken=null,this.next(),this.savedCurrent=null,this.savedNextToken=null,this.allowMemberAccess=i.allowMemberAccess!==!1}H.prototype.next=function(){return this.current=this.nextToken,this.nextToken=this.tokens.next()};H.prototype.tokenMatches=function(e,a){return typeof a>"u"?!0:Array.isArray(a)?ua(a,e.value):typeof a=="function"?a(e):e.value===a};H.prototype.save=function(){this.savedCurrent=this.current,this.savedNextToken=this.nextToken,this.tokens.save()};H.prototype.restore=function(){this.tokens.restore(),this.current=this.savedCurrent,this.nextToken=this.savedNextToken};H.prototype.accept=function(e,a){return this.nextToken.type===e&&this.tokenMatches(this.nextToken,a)?(this.next(),!0):!1};H.prototype.expect=function(e,a){if(!this.accept(e,a)){var i=this.tokens.getCoordinates();throw new Error("parse error ["+i.line+":"+i.column+"]: Expected "+(a||e))}};H.prototype.parseAtom=function(e){var a=this.tokens.unaryOps;function i(s){return s.value in a}if(this.accept(hn)||this.accept(R,i))e.push(new N(Je,this.current.value));else if(this.accept(vi))e.push(new N(pe,this.current.value));else if(this.accept(wo))e.push(new N(pe,this.current.value));else if(this.accept(Ne,"("))this.parseExpression(e),this.expect(Ne,")");else if(this.accept(fa,"["))if(this.accept(fa,"]"))e.push(new N(ca,0));else{var n=this.parseArrayList(e);e.push(new N(ca,n))}else throw new Error("unexpected "+this.nextToken)};H.prototype.parseExpression=function(e){var a=[];this.parseUntilEndStatement(e,a)||(this.parseVariableAssignmentExpression(a),!this.parseUntilEndStatement(e,a)&&this.pushExpression(e,a))};H.prototype.pushExpression=function(e,a){for(var i=0,n=a.length;i<n;i++)e.push(a[i])};H.prototype.parseUntilEndStatement=function(e,a){return this.accept(cn)?(this.nextToken&&this.nextToken.type!==Ta&&!(this.nextToken.type===Ne&&this.nextToken.value===")")&&a.push(new N(mi)),this.nextToken.type!==Ta&&this.parseExpression(a),e.push(new N(ge,a)),!0):!1};H.prototype.parseArrayList=function(e){for(var a=0;!this.accept(fa,"]");)for(this.parseExpression(e),++a;this.accept(ji);)this.parseExpression(e),++a;return a};H.prototype.parseVariableAssignmentExpression=function(e){for(this.parseConditionalExpression(e);this.accept(R,"=");){var a=e.pop(),i=[],n=e.length-1;if(a.type===ha){if(!this.tokens.isOperatorEnabled("()="))throw new Error("function definition is not permitted");for(var s=0,r=a.value+1;s<r;s++){var l=n-s;e[l].type===Je&&(e[l]=new N(We,e[l].value))}this.parseVariableAssignmentExpression(i),e.push(new N(ge,i)),e.push(new N(yi,a.value));continue}if(a.type!==Je&&a.type!==Ue)throw new Error("expected variable for assignment");this.parseVariableAssignmentExpression(i),e.push(new N(We,a.value)),e.push(new N(ge,i)),e.push(Re("="))}};H.prototype.parseConditionalExpression=function(e){for(this.parseOrExpression(e);this.accept(R,"?");){var a=[],i=[];this.parseConditionalExpression(a),this.expect(R,":"),this.parseConditionalExpression(i),e.push(new N(ge,a)),e.push(new N(ge,i)),e.push(yo("?"))}};H.prototype.parseOrExpression=function(e){for(this.parseAndExpression(e);this.accept(R,"or");){var a=[];this.parseAndExpression(a),e.push(new N(ge,a)),e.push(Re("or"))}};H.prototype.parseAndExpression=function(e){for(this.parseComparison(e);this.accept(R,"and");){var a=[];this.parseComparison(a),e.push(new N(ge,a)),e.push(Re("and"))}};var rs=["==","!=","<","<=",">=",">","in"];H.prototype.parseComparison=function(e){for(this.parseAddSub(e);this.accept(R,rs);){var a=this.current;this.parseAddSub(e),e.push(Re(a.value))}};var ds=["+","-","||"];H.prototype.parseAddSub=function(e){for(this.parseTerm(e);this.accept(R,ds);){var a=this.current;this.parseTerm(e),e.push(Re(a.value))}};var ls=["*","/","%"];H.prototype.parseTerm=function(e){for(this.parseFactor(e);this.accept(R,ls);){var a=this.current;this.parseFactor(e),e.push(Re(a.value))}};H.prototype.parseFactor=function(e){var a=this.tokens.unaryOps;function i(s){return s.value in a}if(this.save(),this.accept(R,i)){if(this.current.value!=="-"&&this.current.value!=="+"){if(this.nextToken.type===Ne&&this.nextToken.value==="("){this.restore(),this.parseExponential(e);return}else if(this.nextToken.type===cn||this.nextToken.type===ji||this.nextToken.type===Ta||this.nextToken.type===Ne&&this.nextToken.value===")"){this.restore(),this.parseAtom(e);return}}var n=this.current;this.parseFactor(e),e.push(wi(n.value))}else this.parseExponential(e)};H.prototype.parseExponential=function(e){for(this.parsePostfixExpression(e);this.accept(R,"^");)this.parseFactor(e),e.push(Re("^"))};H.prototype.parsePostfixExpression=function(e){for(this.parseFunctionCall(e);this.accept(R,"!");)e.push(wi("!"))};H.prototype.parseFunctionCall=function(e){var a=this.tokens.unaryOps;function i(r){return r.value in a}if(this.accept(R,i)){var n=this.current;this.parseAtom(e),e.push(wi(n.value))}else for(this.parseMemberExpression(e);this.accept(Ne,"(");)if(this.accept(Ne,")"))e.push(new N(ha,0));else{var s=this.parseArgumentList(e);e.push(new N(ha,s))}};H.prototype.parseArgumentList=function(e){for(var a=0;!this.accept(Ne,")");)for(this.parseExpression(e),++a;this.accept(ji);)this.parseExpression(e),++a;return a};H.prototype.parseMemberExpression=function(e){for(this.parseAtom(e);this.accept(R,".")||this.accept(fa,"[");){var a=this.current;if(a.value==="."){if(!this.allowMemberAccess)throw new Error('unexpected ".", member access is not permitted');this.expect(hn),e.push(new N(Ue,this.current.value))}else if(a.value==="["){if(!this.tokens.isOperatorEnabled("["))throw new Error('unexpected "[]", arrays are disabled');this.parseExpression(e),this.expect(fa,"]"),e.push(Re("["))}else throw new Error("unexpected symbol: "+a.value)}};function gs(e,a){return Number(e)+Number(a)}function hs(e,a){return e-a}function cs(e,a){return e*a}function fs(e,a){return e/a}function ps(e,a){return e%a}function bs(e,a){return Array.isArray(e)&&Array.isArray(a)?e.concat(a):""+e+a}function ys(e,a){return e===a}function ms(e,a){return e!==a}function ws(e,a){return e>a}function vs(e,a){return e<a}function js(e,a){return e>=a}function Ss(e,a){return e<=a}function Cs(e,a){return!!(e&&a)}function Is(e,a){return!!(e||a)}function Ls(e,a){return ua(a,e)}function $s(e){return(Math.exp(e)-Math.exp(-e))/2}function ks(e){return(Math.exp(e)+Math.exp(-e))/2}function Ys(e){return e===1/0?1:e===-1/0?-1:(Math.exp(e)-Math.exp(-e))/(Math.exp(e)+Math.exp(-e))}function Ts(e){return e===-1/0?e:Math.log(e+Math.sqrt(e*e+1))}function As(e){return Math.log(e+Math.sqrt(e*e-1))}function Ds(e){return Math.log((1+e)/(1-e))/2}function Nn(e){return Math.log(e)*Math.LOG10E}function Zs(e){return-e}function Ps(e){return!e}function Ms(e){return e<0?Math.ceil(e):Math.floor(e)}function Es(e){return Math.random()*(e||1)}function Fn(e){return fn(e+1)}function Js(e){return isFinite(e)&&e===Math.round(e)}var Ns=4.7421875,Di=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function fn(e){var a,i;if(Js(e)){if(e<=0)return isFinite(e)?1/0:NaN;if(e>171)return 1/0;for(var n=e-2,s=e-1;n>1;)s*=n,n--;return s===0&&(s=1),s}if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*fn(1-e));if(e>=171.35)return 1/0;if(e>85){var r=e*e,l=r*e,g=l*e,h=g*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*r)-139/(51840*l)-571/(2488320*g)+163879/(209018880*h)+5246819/(75246796800*h*e))}--e,i=Di[0];for(var c=1;c<Di.length;++c)i+=Di[c]/(e+c);return a=e+Ns+.5,Math.sqrt(2*Math.PI)*Math.pow(a,e+.5)*Math.exp(-a)*i}function Fs(e){return Array.isArray(e)?e.length:String(e).length}function Rn(){for(var e=0,a=0,i=0;i<arguments.length;i++){var n=Math.abs(arguments[i]),s;a<n?(s=a/n,e=e*s*s+1,a=n):n>0?(s=n/a,e+=s*s):e+=n}return a===1/0?1/0:a*Math.sqrt(e)}function _n(e,a,i){return e?a:i}function Rs(e,a){return typeof a>"u"||+a==0?Math.round(e):(e=+e,a=-+a,isNaN(e)||!(typeof a=="number"&&a%1===0)?NaN:(e=e.toString().split("e"),e=Math.round(+(e[0]+"e"+(e[1]?+e[1]-a:-a))),e=e.toString().split("e"),+(e[0]+"e"+(e[1]?+e[1]+a:a))))}function _s(e,a,i){return i&&(i[e]=a),a}function Hs(e,a){return e[a|0]}function Xs(e){return arguments.length===1&&Array.isArray(e)?Math.max.apply(Math,e):Math.max.apply(Math,arguments)}function xs(e){return arguments.length===1&&Array.isArray(e)?Math.min.apply(Math,e):Math.min.apply(Math,arguments)}function Bs(e,a){if(typeof e!="function")throw new Error("First argument to map is not a function");if(!Array.isArray(a))throw new Error("Second argument to map is not an array");return a.map(function(i,n){return e(i,n)})}function Os(e,a,i){if(typeof e!="function")throw new Error("First argument to fold is not a function");if(!Array.isArray(i))throw new Error("Second argument to fold is not an array");return i.reduce(function(n,s,r){return e(n,s,r)},a)}function Gs(e,a){if(typeof e!="function")throw new Error("First argument to filter is not a function");if(!Array.isArray(a))throw new Error("Second argument to filter is not an array");return a.filter(function(i,n){return e(i,n)})}function Qs(e,a){if(!(Array.isArray(a)||typeof a=="string"))throw new Error("Second argument to indexOf is not a string or array");return a.indexOf(e)}function Ws(e,a){if(!Array.isArray(a))throw new Error("Second argument to join is not an array");return a.join(e)}function Ks(e){return(e>0)-(e<0)||+e}var Hn=1/3;function Us(e){return e<0?-Math.pow(-e,Hn):Math.pow(e,Hn)}function zs(e){return Math.exp(e)-1}function Vs(e){return Math.log(1+e)}function qs(e){return Math.log(e)/Math.LN2}function er(e){if(!Array.isArray(e))throw new Error("Sum argument is not an array");return e.reduce(function(a,i){return a+Number(i)},0)}function ze(e){this.options=e||{},this.unaryOps={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,sinh:Math.sinh||$s,cosh:Math.cosh||ks,tanh:Math.tanh||Ys,asinh:Math.asinh||Ts,acosh:Math.acosh||As,atanh:Math.atanh||Ds,sqrt:Math.sqrt,cbrt:Math.cbrt||Us,log:Math.log,log2:Math.log2||qs,ln:Math.log,lg:Math.log10||Nn,log10:Math.log10||Nn,expm1:Math.expm1||zs,log1p:Math.log1p||Vs,abs:Math.abs,ceil:Math.ceil,floor:Math.floor,round:Math.round,trunc:Math.trunc||Ms,"-":Zs,"+":Number,exp:Math.exp,not:Ps,length:Fs,"!":Fn,sign:Math.sign||Ks},this.binaryOps={"+":gs,"-":hs,"*":cs,"/":fs,"%":ps,"^":Math.pow,"||":bs,"==":ys,"!=":ms,">":ws,"<":vs,">=":js,"<=":Ss,and:Cs,or:Is,in:Ls,"=":_s,"[":Hs},this.ternaryOps={"?":_n},this.functions={random:Es,fac:Fn,min:xs,max:Xs,hypot:Math.hypot||Rn,pyt:Math.hypot||Rn,pow:Math.pow,atan2:Math.atan2,if:_n,gamma:fn,roundTo:Rs,map:Bs,fold:Os,filter:Gs,indexOf:Qs,join:Ws,sum:er},this.consts={E:Math.E,PI:Math.PI,true:!0,false:!1}}ze.prototype.parse=function(e){var a=[],i=new H(this,new G(this,e),{allowMemberAccess:this.options.allowMemberAccess});return i.parseExpression(a),i.expect(Ta,"EOF"),new Le(a,this)};ze.prototype.evaluate=function(e,a){return this.parse(e).evaluate(a)};var jo=new ze;ze.parse=function(e){return jo.parse(e)};ze.evaluate=function(e,a){return jo.parse(e).evaluate(a)};var Xn={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"remainder","^":"power","!":"factorial","<":"comparison",">":"comparison","<=":"comparison",">=":"comparison","==":"comparison","!=":"comparison","||":"concatenate",and:"logical",or:"logical",not:"logical","?":"conditional",":":"conditional","=":"assignment","[":"array","()=":"fndef"};function ar(e){return Object.hasOwn(Xn,e)?Xn[e]:e}ze.prototype.isOperatorEnabled=function(e){var a=ar(e),i=this.options.operators||{};return!(a in i)||!!i[a]};var Na={exports:{}},Fa={exports:{}},Ce={},re={},xn;function he(){if(xn)return re;xn=1,re.__esModule=!0,re.extend=s,re.indexOf=h,re.escapeExpression=c,re.isEmpty=d,re.createFrame=p,re.blockParams=o,re.appendContextPath=u;var e={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`","=":"="},a=/[&<>"'`=]/g,i=/[&<>"'`=]/;function n(t){return e[t]}function s(t){for(var f=1;f<arguments.length;f++)for(var b in arguments[f])Object.prototype.hasOwnProperty.call(arguments[f],b)&&(t[b]=arguments[f][b]);return t}var r=Object.prototype.toString;re.toString=r;var l=function(f){return typeof f=="function"};l(/x/)&&(re.isFunction=l=function(t){return typeof t=="function"&&r.call(t)==="[object Function]"}),re.isFunction=l;var g=Array.isArray||function(t){return t&&typeof t=="object"?r.call(t)==="[object Array]":!1};re.isArray=g;function h(t,f){for(var b=0,y=t.length;b<y;b++)if(t[b]===f)return b;return-1}function c(t){if(typeof t!="string"){if(t&&t.toHTML)return t.toHTML();if(t==null)return"";if(!t)return t+"";t=""+t}return i.test(t)?t.replace(a,n):t}function d(t){return!t&&t!==0?!0:!!(g(t)&&t.length===0)}function p(t){var f=s({},t);return f._parent=t,f}function o(t,f){return t.path=f,t}function u(t,f){return(t?t+".":"")+f}return re}var Ra={exports:{}},Bn;function we(){return Bn||(Bn=1,(function(e,a){a.__esModule=!0;var i=["description","fileName","lineNumber","endLineNumber","message","name","number","stack"];function n(s,r){var l=r&&r.loc,g=void 0,h=void 0,c=void 0,d=void 0;l&&(g=l.start.line,h=l.end.line,c=l.start.column,d=l.end.column,s+=" - "+g+":"+c);for(var p=Error.prototype.constructor.call(this,s),o=0;o<i.length;o++)this[i[o]]=p[i[o]];Error.captureStackTrace&&Error.captureStackTrace(this,n);try{l&&(this.lineNumber=g,this.endLineNumber=h,Object.defineProperty?(Object.defineProperty(this,"column",{value:c,enumerable:!0}),Object.defineProperty(this,"endColumn",{value:d,enumerable:!0})):(this.column=c,this.endColumn=d))}catch{}}n.prototype=new Error,a.default=n,e.exports=a.default})(Ra,Ra.exports)),Ra.exports}var Ca={},_a={exports:{}},On;function ir(){return On||(On=1,(function(e,a){a.__esModule=!0;var i=he();a.default=function(n){n.registerHelper("blockHelperMissing",function(s,r){var l=r.inverse,g=r.fn;if(s===!0)return g(this);if(s===!1||s==null)return l(this);if(i.isArray(s))return s.length>0?(r.ids&&(r.ids=[r.name]),n.helpers.each(s,r)):l(this);if(r.data&&r.ids){var h=i.createFrame(r.data);h.contextPath=i.appendContextPath(r.data.contextPath,r.name),r={data:h}}return g(s,r)})},e.exports=a.default})(_a,_a.exports)),_a.exports}var Ha={exports:{}},Gn;function nr(){return Gn||(Gn=1,(function(e,a){a.__esModule=!0;function i(l){return l&&l.__esModule?l:{default:l}}var n=he(),s=we(),r=i(s);a.default=function(l){l.registerHelper("each",function(g,h){if(!h)throw new r.default("Must pass iterator to #each");var c=h.fn,d=h.inverse,p=0,o="",u=void 0,t=void 0;h.data&&h.ids&&(t=n.appendContextPath(h.data.contextPath,h.ids[0])+"."),n.isFunction(g)&&(g=g.call(this)),h.data&&(u=n.createFrame(h.data));function f(v,w,C){u&&(u.key=v,u.index=w,u.first=w===0,u.last=!!C,t&&(u.contextPath=t+v)),o=o+c(g[v],{data:u,blockParams:n.blockParams([g[v],v],[t+v,null])})}if(g&&typeof g=="object")if(n.isArray(g))for(var b=g.length;p<b;p++)p in g&&f(p,p,p===g.length-1);else if(typeof Symbol=="function"&&g[Symbol.iterator]){for(var y=[],m=g[Symbol.iterator](),j=m.next();!j.done;j=m.next())y.push(j.value);g=y;for(var b=g.length;p<b;p++)f(p,p,p===g.length-1)}else(function(){var v=void 0;Object.keys(g).forEach(function(w){v!==void 0&&f(v,p-1),v=w,p++}),v!==void 0&&f(v,p-1,!0)})();return p===0&&(o=d(this)),o})},e.exports=a.default})(Ha,Ha.exports)),Ha.exports}var Xa={exports:{}},Qn;function tr(){return Qn||(Qn=1,(function(e,a){a.__esModule=!0;function i(r){return r&&r.__esModule?r:{default:r}}var n=we(),s=i(n);a.default=function(r){r.registerHelper("helperMissing",function(){if(arguments.length!==1)throw new s.default('Missing helper: "'+arguments[arguments.length-1].name+'"')})},e.exports=a.default})(Xa,Xa.exports)),Xa.exports}var xa={exports:{}},Wn;function or(){return Wn||(Wn=1,(function(e,a){a.__esModule=!0;function i(l){return l&&l.__esModule?l:{default:l}}var n=he(),s=we(),r=i(s);a.default=function(l){l.registerHelper("if",function(g,h){if(arguments.length!=2)throw new r.default("#if requires exactly one argument");return n.isFunction(g)&&(g=g.call(this)),!h.hash.includeZero&&!g||n.isEmpty(g)?h.inverse(this):h.fn(this)}),l.registerHelper("unless",function(g,h){if(arguments.length!=2)throw new r.default("#unless requires exactly one argument");return l.helpers.if.call(this,g,{fn:h.inverse,inverse:h.fn,hash:h.hash})})},e.exports=a.default})(xa,xa.exports)),xa.exports}var Ba={exports:{}},Kn;function ur(){return Kn||(Kn=1,(function(e,a){a.__esModule=!0,a.default=function(i){i.registerHelper("log",function(){for(var n=[void 0],s=arguments[arguments.length-1],r=0;r<arguments.length-1;r++)n.push(arguments[r]);var l=1;s.hash.level!=null?l=s.hash.level:s.data&&s.data.level!=null&&(l=s.data.level),n[0]=l,i.log.apply(i,n)})},e.exports=a.default})(Ba,Ba.exports)),Ba.exports}var Oa={exports:{}},Un;function sr(){return Un||(Un=1,(function(e,a){a.__esModule=!0,a.default=function(i){i.registerHelper("lookup",function(n,s,r){return n&&r.lookupProperty(n,s)})},e.exports=a.default})(Oa,Oa.exports)),Oa.exports}var Ga={exports:{}},zn;function rr(){return zn||(zn=1,(function(e,a){a.__esModule=!0;function i(l){return l&&l.__esModule?l:{default:l}}var n=he(),s=we(),r=i(s);a.default=function(l){l.registerHelper("with",function(g,h){if(arguments.length!=2)throw new r.default("#with requires exactly one argument");n.isFunction(g)&&(g=g.call(this));var c=h.fn;if(n.isEmpty(g))return h.inverse(this);var d=h.data;return h.data&&h.ids&&(d=n.createFrame(h.data),d.contextPath=n.appendContextPath(h.data.contextPath,h.ids[0])),c(g,{data:d,blockParams:n.blockParams([g],[d&&d.contextPath])})})},e.exports=a.default})(Ga,Ga.exports)),Ga.exports}var Vn;function So(){if(Vn)return Ca;Vn=1,Ca.__esModule=!0,Ca.registerDefaultHelpers=f,Ca.moveHelperToHooks=b;function e(y){return y&&y.__esModule?y:{default:y}}var a=ir(),i=e(a),n=nr(),s=e(n),r=tr(),l=e(r),g=or(),h=e(g),c=ur(),d=e(c),p=sr(),o=e(p),u=rr(),t=e(u);function f(y){i.default(y),s.default(y),l.default(y),h.default(y),d.default(y),o.default(y),t.default(y)}function b(y,m,j){y.helpers[m]&&(y.hooks[m]=y.helpers[m],j||(y.helpers[m]=void 0))}return Ca}var Qa={},Wa={exports:{}},qn;function dr(){return qn||(qn=1,(function(e,a){a.__esModule=!0;var i=he();a.default=function(n){n.registerDecorator("inline",function(s,r,l,g){var h=s;return r.partials||(r.partials={},h=function(c,d){var p=l.partials;l.partials=i.extend({},p,r.partials);var o=s(c,d);return l.partials=p,o}),r.partials[g.args[0]]=g.fn,h})},e.exports=a.default})(Wa,Wa.exports)),Wa.exports}var et;function lr(){if(et)return Qa;et=1,Qa.__esModule=!0,Qa.registerDefaultDecorators=n;function e(s){return s&&s.__esModule?s:{default:s}}var a=dr(),i=e(a);function n(s){i.default(s)}return Qa}var Ka={exports:{}},at;function Co(){return at||(at=1,(function(e,a){a.__esModule=!0;var i=he(),n={methodMap:["debug","info","warn","error"],level:"info",lookupLevel:function(r){if(typeof r=="string"){var l=i.indexOf(n.methodMap,r.toLowerCase());l>=0?r=l:r=parseInt(r,10)}return r},log:function(r){if(r=n.lookupLevel(r),typeof console<"u"&&n.lookupLevel(n.level)<=r){var l=n.methodMap[r];console[l]||(l="log");for(var g=arguments.length,h=Array(g>1?g-1:0),c=1;c<g;c++)h[c-1]=arguments[c];console[l].apply(console,h)}}};a.default=n,e.exports=a.default})(Ka,Ka.exports)),Ka.exports}var aa={},it;function Io(){if(it)return aa;it=1,aa.__esModule=!0,aa.createProtoAccessControl=r,aa.resultIsAllowed=l,aa.resetLoggedProperties=c;function e(d){return d&&d.__esModule?d:{default:d}}var a=he(),i=Co(),n=e(i),s=Object.create(null);function r(d){var p=Object.create(null);p.__proto__=!1,a.extend(p,d.allowedProtoProperties);var o=Object.create(null);return o.constructor=!1,o.__defineGetter__=!1,o.__defineSetter__=!1,o.__lookupGetter__=!1,o.__lookupSetter__=!1,a.extend(o,d.allowedProtoMethods),{properties:{whitelist:p,defaultValue:d.allowProtoPropertiesByDefault},methods:{whitelist:o,defaultValue:d.allowProtoMethodsByDefault}}}function l(d,p,o){return g(typeof d=="function"?p.methods:p.properties,o)}function g(d,p){return d.whitelist[p]!==void 0?d.whitelist[p]===!0:d.defaultValue!==void 0?d.defaultValue:(h(p),!1)}function h(d){s[d]!==!0&&(s[d]=!0,n.default.log("error",'Handlebars: Access has been denied to resolve the property "'+d+`" because it is not an "own property" of its parent.
|
|
@@ -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-DT3stfoz.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_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-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(`
|
|
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.1",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
|
|
@@ -154,7 +154,7 @@ ${p.join(`
|
|
|
154
154
|
logs
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
`,h={input:{applicationUniversalIdentifier:a,universalIdentifier:i,name:n}};l.subscribe({query:g,variables:h},{next:({data:c})=>console.log(c?.logicFunctionLogs.logs),error:c=>console.error(c),complete:()=>console.log("Completed")})}}class Al{constructor(a){this.client=a}async getSchema(a){return this.introspectEndpoint("/graphql",a)}async getMetadataSchema(a){return this.introspectEndpoint("/metadata",a)}async introspectEndpoint(a,i){try{const n=Ti.getIntrospectionQuery(),s={"Content-Type":"application/json",Accept:"*/*"};i?.appAccessToken&&(s.Authorization=`Bearer ${i.appAccessToken}`);const r=await this.client.post(a,{query:n},{headers:s});if(r.data.errors)return{success:!1,error:`GraphQL introspection errors: ${JSON.stringify(r.data.errors)}`};const l=Ti.buildClientSchema(r.data.data);return{success:!0,data:Ti.printSchema(l),message:`Successfully loaded schema from ${a}`}}catch(n){if(ye.default.isAxiosError(n)&&n.response)return{success:!1,error:n.response.data?.errors?.[0]?.message||`Failed to load schema from ${a}`};throw n}}}class Ae{constructor(a){this.apiClient=new Il(a),this.applicationApi=new Ll(this.apiClient.client),this.schemaApi=new Al(this.apiClient.client),this.logicFunctionApi=new Tl(this.apiClient),this.fileApi=new Yl(this.apiClient.client)}validateAuth(){return this.apiClient.validateAuth()}refreshToken(){return this.apiClient.refreshToken()}findApplicationRegistrationByUniversalIdentifier(...a){return this.applicationApi.findApplicationRegistrationByUniversalIdentifier(...a)}createApplicationRegistration(...a){return this.applicationApi.createApplicationRegistration(...a)}rotateApplicationRegistrationClientSecret(...a){return this.applicationApi.rotateApplicationRegistrationClientSecret(...a)}createDevelopmentApplication(...a){return this.applicationApi.createDevelopmentApplication(...a)}syncApplication(a){return this.applicationApi.syncApplication(a)}uninstallApplication(a){return this.applicationApi.uninstallApplication(a)}syncMarketplaceCatalog(){return this.applicationApi.syncMarketplaceCatalog()}getSchema(a){return this.schemaApi.getSchema(a)}getMetadataSchema(a){return this.schemaApi.getMetadataSchema(a)}findLogicFunctions(...a){return this.logicFunctionApi.findLogicFunctions(...a)}executeLogicFunction(...a){return this.logicFunctionApi.executeLogicFunction(...a)}subscribeToLogs(...a){return this.logicFunctionApi.subscribeToLogs(...a)}uploadAppTarball(...a){return this.fileApi.uploadAppTarball(...a)}installTarballApp(...a){return this.fileApi.installTarballApp(...a)}uploadFile(...a){return this.fileApi.uploadFile(...a)}}const Dl=async e=>{const{tarballPath:a,onProgress:i}=e;e.remote&&W.setActiveRemote(e.remote),i?.(`Uploading ${a}...`);const n=Gi.default.readFileSync(a),r=await new Ae({serverUrl:e.serverUrl,token:e.token}).uploadAppTarball({tarballBuffer:n});return r.success?{success:!0,data:r.data}:{success:!1,error:{code:x.DEPLOY_FAILED,message:`Upload failed: ${r.error}`}}},Zl=e=>ve(()=>Dl(e),x.DEPLOY_FAILED);class iu{constructor(a){this.apiService=new Ae({disableInterceptors:!0,serverUrl:a?.serverUrl,skipAuth:!0,token:a?.token})}async generateCoreClient({appPath:a,appAccessToken:i}){const n=await this.apiService.getSchema({appAccessToken:i});if(!n.success)throw new Error(`Failed to introspect core schema: ${JSON.stringify(n.error)}`);await Hu.replaceCoreClient({packageRoot:Q.join(a,"node_modules","twenty-client-sdk"),schema:n.data})}}const Pl=[2020
|
|
157
|
+
`,h={input:{applicationUniversalIdentifier:a,universalIdentifier:i,name:n}};l.subscribe({query:g,variables:h},{next:({data:c})=>console.log(c?.logicFunctionLogs.logs),error:c=>console.error(c),complete:()=>console.log("Completed")})}}class Al{constructor(a){this.client=a}async getSchema(a){return this.introspectEndpoint("/graphql",a)}async getMetadataSchema(a){return this.introspectEndpoint("/metadata",a)}async introspectEndpoint(a,i){try{const n=Ti.getIntrospectionQuery(),s={"Content-Type":"application/json",Accept:"*/*"};i?.appAccessToken&&(s.Authorization=`Bearer ${i.appAccessToken}`);const r=await this.client.post(a,{query:n},{headers:s});if(r.data.errors)return{success:!1,error:`GraphQL introspection errors: ${JSON.stringify(r.data.errors)}`};const l=Ti.buildClientSchema(r.data.data);return{success:!0,data:Ti.printSchema(l),message:`Successfully loaded schema from ${a}`}}catch(n){if(ye.default.isAxiosError(n)&&n.response)return{success:!1,error:n.response.data?.errors?.[0]?.message||`Failed to load schema from ${a}`};throw n}}}class Ae{constructor(a){this.apiClient=new Il(a),this.applicationApi=new Ll(this.apiClient.client),this.schemaApi=new Al(this.apiClient.client),this.logicFunctionApi=new Tl(this.apiClient),this.fileApi=new Yl(this.apiClient.client)}validateAuth(){return this.apiClient.validateAuth()}refreshToken(){return this.apiClient.refreshToken()}findApplicationRegistrationByUniversalIdentifier(...a){return this.applicationApi.findApplicationRegistrationByUniversalIdentifier(...a)}createApplicationRegistration(...a){return this.applicationApi.createApplicationRegistration(...a)}rotateApplicationRegistrationClientSecret(...a){return this.applicationApi.rotateApplicationRegistrationClientSecret(...a)}createDevelopmentApplication(...a){return this.applicationApi.createDevelopmentApplication(...a)}syncApplication(a){return this.applicationApi.syncApplication(a)}uninstallApplication(a){return this.applicationApi.uninstallApplication(a)}syncMarketplaceCatalog(){return this.applicationApi.syncMarketplaceCatalog()}getSchema(a){return this.schemaApi.getSchema(a)}getMetadataSchema(a){return this.schemaApi.getMetadataSchema(a)}findLogicFunctions(...a){return this.logicFunctionApi.findLogicFunctions(...a)}executeLogicFunction(...a){return this.logicFunctionApi.executeLogicFunction(...a)}subscribeToLogs(...a){return this.logicFunctionApi.subscribeToLogs(...a)}uploadAppTarball(...a){return this.fileApi.uploadAppTarball(...a)}installTarballApp(...a){return this.fileApi.installTarballApp(...a)}uploadFile(...a){return this.fileApi.uploadFile(...a)}}const Dl=async e=>{const{tarballPath:a,onProgress:i}=e;e.remote&&W.setActiveRemote(e.remote),i?.(`Uploading ${a}...`);const n=Gi.default.readFileSync(a),r=await new Ae({serverUrl:e.serverUrl,token:e.token}).uploadAppTarball({tarballBuffer:n});return r.success?{success:!0,data:r.data}:{success:!1,error:{code:x.DEPLOY_FAILED,message:`Upload failed: ${r.error}`}}},Zl=e=>ve(()=>Dl(e),x.DEPLOY_FAILED);class iu{constructor(a){this.apiService=new Ae({disableInterceptors:!0,serverUrl:a?.serverUrl,skipAuth:!0,token:a?.token})}async generateCoreClient({appPath:a,appAccessToken:i}){const n=await this.apiService.getSchema({appAccessToken:i});if(!n.success)throw new Error(`Failed to introspect core schema: ${JSON.stringify(n.error)}`);await Hu.replaceCoreClient({packageRoot:Q.join(a,"node_modules","twenty-client-sdk"),schema:n.data})}}const Pl=[2020],Sn=async e=>{const a=new AbortController,i=setTimeout(()=>a.abort(),2e3);try{return(await(await fetch(`http://localhost:${e}/healthz`,{signal:a.signal})).json()).status==="ok"}catch{return!1}finally{clearTimeout(i)}},nu=async e=>{const a=e?[e]:Pl;for(const i of a)if(await Sn(i))return`http://localhost:${i}`;return null},Ml=e=>{if(bn(e))return e},El=e=>Ml(e)?.extensions?.subCode,Jl=(e,a)=>El(e)===a,Nl=e=>{if(!bn(e))return;const{error:a}=e;return typeof a=="string"?a:void 0},Fl=e=>Nl(e)==="invalid_client",Rl=async(e,a)=>{const i=await e.getConfig(),n=await fetch(`${i.apiUrl}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"client_credentials",client_id:a.clientId,client_secret:a.clientSecret})});if(!n.ok)throw new Error(`Token exchange failed: ${n.status} ${n.statusText}`);const s=await n.json();return await e.setConfig({appAccessToken:s.access_token,...s.refresh_token?{appRefreshToken:s.refresh_token}:{}}),{accessToken:s.access_token,refreshToken:s.refresh_token}},_l=3e4,Hl=e=>{try{return JSON.parse(Buffer.from(e.split(".")[1],"base64").toString()).exp*1e3<Date.now()+_l}catch{return!1}},tu=async(e,a)=>{const i=await e.getConfig();if(i.appAccessToken&&!Hl(i.appAccessToken))return i.appAccessToken;if(i.appRefreshToken&&i.appRegistrationClientId){const n=await fetch(`${i.apiUrl}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:i.appRefreshToken,client_id:i.appRegistrationClientId})});if(n.ok){const s=await n.json();return await e.setConfig({appAccessToken:s.access_token,...s.refresh_token?{appRefreshToken:s.refresh_token}:{}}),s.access_token}try{const s=await n.json();if(Fl(s)){await e.setConfig({appRegistrationId:void 0,appRegistrationClientId:void 0,appAccessToken:void 0,appRefreshToken:void 0});return}}catch{}}if(a)return(await Rl(e,a)).accessToken},ou=async(e,a,i)=>{const n=await e.createApplicationRegistration({name:i.name,universalIdentifier:i.universalIdentifier});if(n.success){const{applicationRegistration:h,clientSecret:c}=n.data;return await a.setConfig({appRegistrationId:h.id,appRegistrationClientId:h.oAuthClientId,appAccessToken:void 0,appRefreshToken:void 0}),{clientId:h.oAuthClientId,clientSecret:c,isNewRegistration:!0}}if(!Jl(n.error,"UNIVERSAL_IDENTIFIER_ALREADY_CLAIMED")){const h=n.error instanceof Error?n.error.message:n.error?.message??String(n.error);throw new Error(`Failed to create app registration: ${h}`)}const r=await e.findApplicationRegistrationByUniversalIdentifier(i.universalIdentifier);if(!r.success||!r.data)throw new Error(`App registration exists but could not be found: ${i.universalIdentifier}`);const l=r.data;await a.setConfig({appRegistrationId:l.id,appRegistrationClientId:l.oAuthClientId,appAccessToken:void 0,appRefreshToken:void 0});const g=await e.rotateApplicationRegistrationClientSecret(l.id);if(!g.success||!g.data)throw new Error(`Failed to rotate client secret for registration ${l.id}`);return{clientId:l.oAuthClientId,clientSecret:g.data.clientSecret,isNewRegistration:!1}},Cn=e=>{if(!e||typeof e!="object")return null;const i=e.extensions;if(!i?.errors||!i?.summary)return null;const n=[],s=i.summary.totalErrors;n.push({message:`Sync failed with ${s} error${s!==1?"s":""}`,status:"error"});for(const[r,l]of Object.entries(i.errors)){const g=i.summary[r]??l.length;n.push({message:`${r}: ${g} error${g!==1?"s":""}`,status:"error"});let h=1;for(const c of l){const d=c.flatEntityMinimalInformation?.universalIdentifier;for(const p of c.errors){const o=[];p.value&&o.push(`value: ${p.value}`),d&&o.push(`universalIdentifier: ${d}`);const u=o.length>0?` (${o.join(", ")})`:"";n.push({message:` ${h}. ${p.code}: ${p.message}${u}`,status:"error"}),h++}}}return n},ri=e=>{try{const a=JSON.stringify(e,null,2);return a==="{}"||a===void 0?String(e):a}catch{return String(e)}},da=e=>{if(typeof e=="string")return e;if(ye.default.isAxiosError(e)){const a=[],i=e.response?.status,n=e.response?.statusText;i&&a.push(`HTTP ${i}${n?` ${n}`:""}`);const s=e.response?.data,r=s?.errors;if(Array.isArray(r)&&r.length>0){const l=r.map(g=>typeof g.message=="string"?g.message:ri(g)).join("; ");a.push(l)}else s?.message?a.push(typeof s.message=="string"?s.message:ri(s.message)):s?a.push(ri(s)):e.message&&a.push(e.message);return e.code&&a.push(`(${e.code})`),a.join(" - ")||"Unknown Axios error"}return e instanceof Error?e.message||e.toString():ri(e)};class uu{constructor(a){this.apiService=new Ae,this.applicationUniversalIdentifier=a.applicationUniversalIdentifier,this.appPath=a.appPath}async uploadFile({builtPath:a,fileFolder:i}){const n=Q.relative(me,a);return await this.apiService.uploadFile({filePath:J.default.join(this.appPath,a),builtHandlerPath:n,fileFolder:i,applicationUniversalIdentifier:this.applicationUniversalIdentifier})}}const je="twenty-app-dev",Da="twenty-app-dev-test",Xl="twentycrm/twenty-app-dev:latest",In=2020,Ln=2021,su=(e=je)=>{try{return ne.execSync(`docker inspect -f '{{.State.Running}}' ${e}`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim()==="true"}catch{return!1}},pi=(e=je)=>{const a=e===Da?Ln:In;try{const n=ne.execSync(`docker inspect -f '{{range .Config.Env}}{{println .}}{{end}}' ${e}`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).match(/^NODE_PORT=(\d+)$/m);return n?parseInt(n[1],10):a}catch{return a}},$n=(e=je)=>{try{return ne.execSync(`docker inspect ${e}`,{stdio:["pipe","pipe","ignore"]}),!0}catch{return!1}},ru=(e="latest")=>`twentycrm/twenty-app-dev:${e}`,du=(e=je)=>{try{return ne.execSync(`docker inspect -f '{{.Image}}' ${e}`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim()}catch{return null}},lu=e=>{try{return ne.execSync(`docker inspect -f '{{.Id}}' ${e}`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim()}catch{return null}},xl=(e,a=je)=>{try{const n=ne.execSync(`docker inspect -f '{{range .Config.Env}}{{println .}}{{end}}' ${a}`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).match(new RegExp(`^${e}=(.+)$`,"m"));return n?n[1]:null}catch{return null}},kn=()=>{try{return ne.execSync("docker info",{stdio:"ignore"}),!0}catch{return!1}},Bl=()=>{switch(process.platform){case"darwin":return` Run: open -a Docker
|
|
158
158
|
(or launch Docker Desktop from Applications)`;case"linux":return` Run: sudo systemctl start docker
|
|
159
159
|
(or launch Docker Desktop if installed)`;case"win32":return" Launch Docker Desktop from the Start menu";default:return" See https://docs.docker.com/engine/install/ for installation"}},gu=e=>["Docker is not running.","","Start Docker:",Bl(),"","Then retry:",` ${e}`,"","Don't have Docker? Install from https://docs.docker.com/get-docker/"].join(`
|
|
160
160
|
`),hu=(e,a)=>e[0]!==a[0]?e[0]-a[0]:e[1]!==a[1]?e[1]-a[1]:e[2]-a[2],Ol=Nu.promisify(ne.execFile),Gl=async(e=je)=>{try{const{stdout:a}=await Ol("docker",["inspect","-f","{{range .Config.Env}}{{println .}}{{end}}",e],{encoding:"utf-8"}),i=a.match(/^APP_VERSION=(.+)$/m);return!i||i[1]==="0.0.0"||i[1]===""?null:i[1].trim().replace(/^v/,"")}catch{return null}},ga=e=>{const i=e.replace(/^v/,"").trim().match(/^(\d+)\.(\d+)\.(\d+)$/);return i?[parseInt(i[1],10),parseInt(i[2],10),parseInt(i[3],10)]:null},en=J.join(tn.homedir(),".twenty","version-check-cache.json"),Ql=1440*60*1e3,Wl=3e3,Kl="https://hub.docker.com/v2/repositories/twentycrm/twenty-app-dev/tags?page_size=100",Ul=async()=>{try{const e=await B.readFile(en,"utf-8"),a=JSON.parse(e);return typeof a.fetchedAt!="number"||!Array.isArray(a.versions)||Date.now()-a.fetchedAt>Ql?null:a.versions.map(i=>({name:i.name,lastUpdatedAt:new Date(i.lastUpdatedAt)}))}catch{return null}},zl=async e=>{try{await ke(J.dirname(en)),await B.writeFile(en,JSON.stringify({fetchedAt:Date.now(),versions:e.map(({name:a,lastUpdatedAt:i})=>({name:a,lastUpdatedAt:i.toISOString()}))}))}catch{}},Vl=async()=>{const e=new AbortController,a=setTimeout(()=>e.abort(),Wl);try{const i=await fetch(Kl,{signal:e.signal});if(!i.ok)return null;const n=await i.json();if(!Array.isArray(n.results))return null;const s=[];for(const r of n.results){if(typeof r.name!="string"||typeof r.last_updated!="string"||r.name==="latest"||ga(r.name)===null)continue;const l=new Date(r.last_updated);Number.isNaN(l.getTime())||s.push({name:r.name.replace(/^v/,""),lastUpdatedAt:l})}return s.sort((r,l)=>{const g=ga(r.name),h=ga(l.name);return g===null||h===null?0:hu(h,g)}),s}catch{return null}finally{clearTimeout(a)}},ql=async()=>{const e=await Ul();if(e!==null)return e;const a=await Vl();return a===null?[]:(await zl(a),a)},eg=1440*60*1e3,ag=365,cu=async(e=je)=>{const a=au.version,[i,n]=await Promise.all([Gl(e),ql()]),s=n[0]?.name??null,r=i?ga(i):null,l=s?ga(s):null,g=r!==null&&l!==null&&(r[0]<l[0]||r[0]===l[0]&&r[1]<l[1]),h=r===null?void 0:n.find(p=>{const o=ga(p.name);return o!==null&&hu(o,r)===0})?.lastUpdatedAt,c=n[0]?.lastUpdatedAt;let d=null;return c&&h?d=Math.floor((c.getTime()-h.getTime())/eg):c&&g&&(d=ag),{cliVersion:a,localServerVersion:i,latestServerVersion:s,isMinorOrMajorBehind:g,daysBehind:d}},ig=7,fu=async(e=je)=>{const a=await cu(e);a.localServerVersion===null||a.latestServerVersion===null||!a.isMinorOrMajorBehind||a.daysBehind===null||a.daysBehind<=ig||(console.warn(la.default.yellow(`⚠ Local Twenty server is v${a.localServerVersion} (${a.daysBehind} days behind v${a.latestServerVersion}).`)),console.warn(la.default.dim(" Update with: yarn twenty server upgrade")),console.warn(""))},$i=async e=>{const a=J.default.join(e,me);await ke(a);const i=J.default.join(a,"manifest.json");if(!await Ii(i)){const{manifest:n}=await Vo(e);return n}return await _o(i)},ng=(e,a)=>a.logicFunctions.some(i=>i.universalIdentifier===e.universalIdentifier),Kt=e=>"postInstall"in e?"post install":"preInstall"in e?"pre install":"functionUniversalIdentifier"in e?e.functionUniversalIdentifier:"functionName"in e?e.functionName:"unknown",tg=async e=>{e.remote&&W.setActiveRemote(e.remote);const a=new Ae,i=await $i(e.appPath);if(!i)return{success:!1,error:{code:x.MANIFEST_NOT_FOUND,message:"Manifest not found. Run `build` or `dev` first."}};const n=await a.findLogicFunctions();if(!n.success){const g=n.error instanceof Error?n.error.message:String(n.error??"Failed to fetch functions");return{success:!1,error:{code:ka.FETCH_FUNCTIONS_FAILED,message:g}}}const s=n.data.filter(g=>g.universalIdentifier&&ng(g,i)),r=s.find(g=>"postInstall"in e&&e.postInstall?g.universalIdentifier===i.application.postInstallLogicFunction?.universalIdentifier:"preInstall"in e&&e.preInstall?g.universalIdentifier===i.application.preInstallLogicFunction?.universalIdentifier:"functionUniversalIdentifier"in e?g.universalIdentifier===e.functionUniversalIdentifier:"functionName"in e?g.name===e.functionName:!1);if(!r)return{success:!1,error:{code:ka.FUNCTION_NOT_FOUND,message:`Function "${Kt(e)}" not found in application.`,details:{identifier:Kt(e),availableFunctions:s.map(g=>({name:g.name,universalIdentifier:g.universalIdentifier}))}}};const l=await a.executeLogicFunction({functionId:r.id,payload:e.payload??{}});if(!l.success){const g=l.error instanceof Error?l.error.message:String(l.error??"Execution failed");return{success:!1,error:{code:ka.EXECUTION_FAILED,message:g}}}return{success:!0,data:{functionName:r.name,...l.data}}},og=e=>ve(()=>tg(e),ka.EXECUTION_FAILED),ug=async e=>{e.remote&&W.setActiveRemote(e.remote);const a=new Ae,i=await $i(e.appPath);if(!i)return{success:!1,error:{code:x.MANIFEST_NOT_FOUND,message:"Manifest not found. Run `build` or `dev` first."}};const n=await a.installTarballApp({universalIdentifier:i.application.universalIdentifier});if(!n.success){const s=Cn(n.error),r=s?s.map(l=>l.message).join(`
|
|
@@ -250,4 +250,4 @@ Check: 'yarn twenty server logs'`}};const d=`http://localhost:${h}`,p=new W(i?{c
|
|
|
250
250
|
${m.join(`
|
|
251
251
|
`)}`}}}const c=vn({manifest:l.manifest,builtFileInfos:g.builtFileInfos});await jn(a,c),i?.("Registering application...");const d=new W,{clientId:p,clientSecret:o}=await ou(s,d,{name:c.application.displayName,universalIdentifier:c.application.universalIdentifier}),u=await s.createDevelopmentApplication({universalIdentifier:c.application.universalIdentifier,name:c.application.displayName});if(!u.success)return{success:!1,error:{code:x.SYNC_FAILED,message:`Failed to install development application: ${da(u.error)}`}};i?.(`Uploading ${g.builtFileInfos.size} file${g.builtFileInfos.size===1?"":"s"}...`);const t=new uu({appPath:a,applicationUniversalIdentifier:c.application.universalIdentifier}),f=[],b=Array.from(g.builtFileInfos.values()).map(async m=>{n&&i?.(`Uploading ${m.builtPath}`);const j=await t.uploadFile({builtPath:m.builtPath,fileFolder:m.fileFolder});j.success||f.push(`Failed to upload ${m.builtPath}: ${da(j.error)}`)});if(await Promise.all(b),f.length>0)return{success:!1,error:{code:x.SYNC_FAILED,message:f.join(`
|
|
252
252
|
`)}};i?.("Syncing manifest...");const y=await s.syncApplication(c);if(!y.success){const m=n?null:Cn(y.error),j=m?m.map(v=>v.message).join(`
|
|
253
|
-
`):`Sync failed with error: ${da(y.error)}`;return{success:!1,error:{code:x.SYNC_FAILED,message:j}}}i?.("Generating API client...");try{const m=await tu(d,{clientId:p,clientSecret:o});await new iu().generateCoreClient({appPath:a,appAccessToken:m})}catch(m){return{success:!1,error:{code:x.SYNC_FAILED,message:`Failed to generate API client: ${da(m)}`}}}return{success:!0,data:{outputDir:J.default.join(a,me),fileCount:g.builtFileInfos.size,applicationDisplayName:c.application.displayName,applicationUniversalIdentifier:c.application.universalIdentifier}}},Tg=e=>ve(()=>Yg(e),x.SYNC_FAILED),Ag=async e=>{e.remote&&W.setActiveRemote(e.remote);const a=new W,i=new Ae,n=await $i(e.appPath);if(!n)return{success:!1,error:{code:x.MANIFEST_NOT_FOUND,message:"Manifest not found. Run `build` or `dev` first."}};const s=await i.uninstallApplication(n.application.universalIdentifier);if(!s.success){const r=s.error instanceof Error?s.error.message:String(s.error??"Unknown error");return{success:!1,error:{code:x.UNINSTALL_FAILED,message:r}}}return await a.setConfig({appRegistrationId:void 0,appRegistrationClientId:void 0,appAccessToken:void 0,appRefreshToken:void 0}),{success:!0,data:void 0}},Dg=e=>ve(()=>Ag(e),x.UNINSTALL_FAILED);exports.APP_ERROR_CODES=x;exports.AUTH_ERROR_CODES=Xe;exports.ApiService=Ae;exports.CONTAINER_NAME=je;exports.ClientService=iu;exports.ConfigService=W;exports.DEFAULT_PORT=In;exports.DEFAULT_TEST_PORT=Ln;exports.FUNCTION_ERROR_CODES=ka;exports.FileUploader=uu;exports.R=I;exports.SERVER_ERROR_CODES=Ye;exports.
|
|
253
|
+
`):`Sync failed with error: ${da(y.error)}`;return{success:!1,error:{code:x.SYNC_FAILED,message:j}}}i?.("Generating API client...");try{const m=await tu(d,{clientId:p,clientSecret:o});await new iu().generateCoreClient({appPath:a,appAccessToken:m})}catch(m){return{success:!1,error:{code:x.SYNC_FAILED,message:`Failed to generate API client: ${da(m)}`}}}return{success:!0,data:{outputDir:J.default.join(a,me),fileCount:g.builtFileInfos.size,applicationDisplayName:c.application.displayName,applicationUniversalIdentifier:c.application.universalIdentifier}}},Tg=e=>ve(()=>Yg(e),x.SYNC_FAILED),Ag=async e=>{e.remote&&W.setActiveRemote(e.remote);const a=new W,i=new Ae,n=await $i(e.appPath);if(!n)return{success:!1,error:{code:x.MANIFEST_NOT_FOUND,message:"Manifest not found. Run `build` or `dev` first."}};const s=await i.uninstallApplication(n.application.universalIdentifier);if(!s.success){const r=s.error instanceof Error?s.error.message:String(s.error??"Unknown error");return{success:!1,error:{code:x.UNINSTALL_FAILED,message:r}}}return await a.setConfig({appRegistrationId:void 0,appRegistrationClientId:void 0,appAccessToken:void 0,appRefreshToken:void 0}),{success:!0,data:void 0}},Dg=e=>ve(()=>Ag(e),x.UNINSTALL_FAILED);exports.APP_ERROR_CODES=x;exports.AUTH_ERROR_CODES=Xe;exports.ApiService=Ae;exports.CONTAINER_NAME=je;exports.ClientService=iu;exports.ConfigService=W;exports.DEFAULT_PORT=In;exports.DEFAULT_TEST_PORT=Ln;exports.FUNCTION_ERROR_CODES=ka;exports.FileUploader=uu;exports.R=I;exports.SERVER_ERROR_CODES=Ye;exports.TEST_CONTAINER_NAME=Da;exports._=ao;exports.appBuild=eu;exports.appDeploy=Zl;exports.appDevOnce=Tg;exports.appInstall=sg;exports.appPublish=dg;exports.appUninstall=Dg;exports.authLogin=gg;exports.authLoginOAuth=vg;exports.b=be;exports.buildAndValidateManifest=wn;exports.checkDockerRunning=kn;exports.checkServerHealth=Sn;exports.checkServerVersionCompatibility=fu;exports.commonjsGlobal=Ee;exports.containerExists=$n;exports.copy=Ro;exports.createFrontComponentsWatcher=Od;exports.createLogicFunctionsWatcher=Bd;exports.detectLocalServer=nu;exports.e=no;exports.emptyDir=Fo;exports.ensureAppAccessTokenIsValidOrRefresh=tu;exports.ensureAppRegistration=ou;exports.ensureDir=ke;exports.formatManifestValidationErrors=Cn;exports.functionExecute=og;exports.getConfigPath=Ya;exports.getContainerDigest=du;exports.getContainerEnvVar=xl;exports.getContainerPort=pi;exports.getImageDigest=lu;exports.getImageForVersion=ru;exports.getVersionInfo=cu;exports.isContainerRunning=su;exports.manifestUpdateChecksums=vn;exports.o=Fe;exports.packageJson=au;exports.parseTscOutputLine=Qo;exports.pathExists=Ii;exports.rE=sn;exports.readJson=_o;exports.readManifestFromFile=$i;exports.remove=hi;exports.runSafe=ve;exports.runTypecheck=Li;exports.serializeError=da;exports.serverStart=Lg;exports.serverUpgrade=kg;exports.u=me;exports.v=Jo;exports.writeManifestToOutput=jn;
|