twenty-sdk 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/cli/commands/dev-once.d.ts +7 -0
  2. package/dist/cli/commands/exec.d.ts +2 -2
  3. package/dist/cli/operations/dev-once.d.ts +13 -0
  4. package/dist/cli/operations/execute.d.ts +2 -2
  5. package/dist/cli/operations/index.d.ts +2 -0
  6. package/dist/cli/operations/server-start.d.ts +1 -0
  7. package/dist/cli/utilities/build/manifest/manifest-extract-config.d.ts +1 -1
  8. package/dist/cli/utilities/build/manifest/utils/add-missing-field-option-ids.d.ts +2 -0
  9. package/dist/cli/utilities/build/manifest/utils/from-role-config-to-role-manifest.d.ts +3 -0
  10. package/dist/cli/utilities/config/config-service.d.ts +3 -1
  11. package/dist/cli/utilities/config/get-config-path.d.ts +1 -1
  12. package/dist/cli/utilities/server/docker-container.d.ts +5 -3
  13. package/dist/cli.cjs +46 -44
  14. package/dist/cli.mjs +2035 -2089
  15. package/dist/{frontComponentHostCommunicationApi-op3Q7sYg.mjs → frontComponentHostCommunicationApi-Bz03t3FY.mjs} +66 -74
  16. package/dist/{frontComponentHostCommunicationApi-DvdpnfNz.js → frontComponentHostCommunicationApi-DyOxvANW.js} +3 -3
  17. package/dist/{get-function-input-schema-BZ7_XyUh-xI83N7kX.mjs → get-function-input-schema-BZ7_XyUh-CtECetlr.mjs} +1 -1
  18. package/dist/{get-function-input-schema-BZ7_XyUh-Bf_NiyDR.js → get-function-input-schema-BZ7_XyUh-D2ypJxjI.js} +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.mjs +9 -9
  21. package/dist/operations.cjs +1 -1
  22. package/dist/operations.mjs +14 -13
  23. package/dist/sdk/application/application-config.d.ts +1 -1
  24. package/dist/sdk/common/types/define-entity.type.d.ts +5 -2
  25. package/dist/sdk/index.d.ts +1 -1
  26. package/dist/sdk/logic-functions/define-post-install-logic-function.d.ts +2 -5
  27. package/dist/sdk/logic-functions/define-post-install-logic-function.js.map +1 -1
  28. package/dist/sdk/logic-functions/define-pre-install-logic-function.d.ts +2 -5
  29. package/dist/sdk/logic-functions/define-pre-install-logic-function.js.map +1 -1
  30. package/dist/sdk/logic-functions/install-payload-type.d.ts +5 -0
  31. package/dist/sdk/logic-functions/post-install-logic-function-config.d.ts +4 -0
  32. package/dist/sdk/logic-functions/pre-install-logic-function-config.d.ts +5 -0
  33. package/dist/sdk/roles/define-role.d.ts +2 -2
  34. package/dist/sdk/roles/define-role.js.map +1 -1
  35. package/dist/sdk/roles/role-config.d.ts +7 -0
  36. package/dist/ui/index.cjs +413 -398
  37. package/dist/ui/index.mjs +2164 -2134
  38. package/dist/uninstall-CXlUxs8p.js +189 -0
  39. package/dist/{uninstall-9yB-e13_.mjs → uninstall-CrGYRb-Z.mjs} +993 -663
  40. package/package.json +2 -2
  41. package/dist/sdk/logic-functions/install-logic-function-payload-type.d.ts +0 -4
  42. package/dist/uninstall-BCUbP_Bn.js +0 -178
@@ -1,67 +1,68 @@
1
- import * as Ce from "fs";
2
- import it from "fs";
3
- import { execSync as Ue } from "child_process";
4
- import * as C from "path";
5
- import h, { join as P, dirname as at, relative as W, extname as rt, basename as ot } from "path";
6
- import je from "crypto";
7
- import { mkdir as fe, access as Me, writeFile as j, readFile as Q, readdir as ct, rm as $e, cp as lt, mkdtemp as ut } from "node:fs/promises";
8
- import { T as Be, B as O, E as R, o as He, u as pt, R as g, y as V, b as ue, z as X, Z as dt, c as ft, d as mt, e as oe, g as ht } from "./frontComponentHostCommunicationApi-op3Q7sYg.mjs";
9
- import * as me from "esbuild";
10
- import { g as he } from "./get-front-component-build-plugins-BGeVpUW3.mjs";
11
- import { execFile as Ve, execSync as Z, spawnSync as gt, spawn as yt } from "node:child_process";
12
- import Oe, { dirname as It, join as vt } from "node:path";
13
- import At from "node:http";
14
- import _e from "node:crypto";
15
- import N from "axios";
16
- import te from "chalk";
17
- import { existsSync as wt } from "node:fs";
18
- import * as qe from "os";
19
- import Tt from "os";
20
- import { createClient as Ft } from "graphql-sse";
21
- import { getIntrospectionQuery as bt, buildClientSchema as Et, printSchema as Nt } from "graphql";
22
- import * as q from "typescript";
23
- import * as kt from "fs/promises";
24
- import { createRequire as Ct } from "module";
25
- import { v5 as Ot } from "uuid";
1
+ import * as Re from "fs";
2
+ import yt from "fs";
3
+ import { execSync as qe } from "child_process";
4
+ import * as x from "path";
5
+ import I, { join as R, dirname as It, relative as J, extname as vt, basename as At } from "path";
6
+ import wt from "node:http";
7
+ import { execFile as ze, execSync as te, spawnSync as Ft, spawn as Tt } from "node:child_process";
8
+ import xe from "node:crypto";
9
+ import S from "axios";
10
+ import oe from "chalk";
11
+ import { T as Je, B as D, E as O, o as Ge, u as Et, R as A, w as G, s as ye, z as ee, Z as bt, y as Nt, d as St, g as fe, h as Ct } from "./frontComponentHostCommunicationApi-Bz03t3FY.mjs";
12
+ import We from "crypto";
13
+ import { mkdir as ve, access as Ke, writeFile as H, readFile as se, readdir as kt, rm as Xe, cp as Pt, mkdtemp as Lt } from "node:fs/promises";
14
+ import * as Ae from "esbuild";
15
+ import { g as we } from "./get-front-component-build-plugins-BGeVpUW3.mjs";
16
+ import De, { dirname as Ot, join as _t } from "node:path";
17
+ import { replaceCoreClient as Rt } from "twenty-client-sdk/generate";
18
+ import { existsSync as xt } from "node:fs";
19
+ import * as Dt from "os";
20
+ import Ut from "os";
21
+ import { createClient as $t } from "graphql-sse";
22
+ import { getIntrospectionQuery as jt, buildClientSchema as Mt, printSchema as Bt } from "graphql";
23
+ import * as W from "typescript";
24
+ import * as Ht from "fs/promises";
25
+ import { createRequire as Vt } from "module";
26
+ import { v5 as Z } from "uuid";
26
27
  import "@sniptt/guards";
27
28
  import "react";
28
- import { glob as Ye } from "tinyglobby";
29
- const ge = async (e) => {
29
+ import { glob as Qe } from "tinyglobby";
30
+ const Fe = async (e) => {
30
31
  try {
31
- return await Me(e), !0;
32
+ return await Ke(e), !0;
32
33
  } catch {
33
34
  return !1;
34
35
  }
35
- }, _t = (e) => wt(e), U = (e) => fe(e, { recursive: !0 }), Lt = async (e) => {
36
- await fe(It(e), { recursive: !0 });
36
+ }, Yt = (e) => xt(e), B = (e) => ve(e, { recursive: !0 }), qt = async (e) => {
37
+ await ve(Ot(e), { recursive: !0 });
37
38
  try {
38
- await Me(e);
39
+ await Ke(e);
39
40
  } catch {
40
- await j(e, "");
41
+ await H(e, "");
41
42
  }
42
- }, St = async (e) => {
43
+ }, zt = async (e) => {
43
44
  let t;
44
45
  try {
45
- t = await ct(e);
46
+ t = await kt(e);
46
47
  } catch (s) {
47
48
  if (s instanceof Error && "code" in s && s.code === "ENOENT") {
48
- await fe(e, { recursive: !0 });
49
+ await ve(e, { recursive: !0 });
49
50
  return;
50
51
  }
51
52
  throw s;
52
53
  }
53
54
  await Promise.all(
54
55
  t.map(
55
- (s) => $e(vt(e, s), { recursive: !0, force: !0 })
56
+ (s) => Xe(_t(e, s), { recursive: !0, force: !0 })
56
57
  )
57
58
  );
58
- }, Pt = (e, t) => lt(e, t, { recursive: !0 }), pe = (e) => $e(e, { recursive: !0, force: !0 }), Rt = async (e) => {
59
- const t = await Q(e, "utf-8");
59
+ }, Jt = (e, t) => Pt(e, t, { recursive: !0 }), Ie = (e) => Xe(e, { recursive: !0, force: !0 }), Gt = async (e) => {
60
+ const t = await se(e, "utf-8");
60
61
  return JSON.parse(t);
61
- }, xt = async (e, t) => {
62
- await j(e, JSON.stringify(t, null, 2) + `
62
+ }, Wt = async (e, t) => {
63
+ await H(e, JSON.stringify(t, null, 2) + `
63
64
  `);
64
- }, Dt = "twenty-client-sdk", ze = async ({
65
+ }, Kt = "twenty-client-sdk", Ze = async ({
65
66
  result: e,
66
67
  appPath: t,
67
68
  fileFolder: s,
@@ -72,22 +73,22 @@ const ge = async (e) => {
72
73
  (r) => r.endsWith(".mjs")
73
74
  );
74
75
  for (const r of a) {
75
- const o = h.resolve(r), l = h.relative(t, o), c = e.metafile?.outputs?.[r]?.entryPoint || "", u = h.relative(t, c), d = await Q(o), f = je.createHash("md5").update(d).digest("hex");
76
- if (n.get(l) === f)
76
+ const o = I.resolve(r), l = I.relative(t, o), c = e.metafile?.outputs?.[r]?.entryPoint || "", u = I.relative(t, c), d = await se(o), p = We.createHash("md5").update(d).digest("hex");
77
+ if (n.get(l) === p)
77
78
  continue;
78
- n.set(l, f);
79
- const _ = e.metafile?.outputs?.[r]?.imports?.some(
80
- (L) => L.external === !0 && L.path.startsWith(Dt)
79
+ n.set(l, p);
80
+ const T = e.metafile?.outputs?.[r]?.imports?.some(
81
+ (E) => E.external === !0 && E.path.startsWith(Kt)
81
82
  ) ?? !1;
82
83
  i && await i({
83
84
  fileFolder: s,
84
85
  builtPath: l,
85
86
  sourcePath: u,
86
- checksum: f,
87
- usesSdkClient: _
87
+ checksum: p,
88
+ usesSdkClient: T
88
89
  });
89
90
  }
90
- }, Le = async ({
91
+ }, Ue = async ({
91
92
  appPath: e,
92
93
  sourcePaths: t,
93
94
  fileFolder: s,
@@ -99,30 +100,30 @@ const ge = async (e) => {
99
100
  const a = {};
100
101
  for (const o of t) {
101
102
  const l = o.replace(/\.tsx?$/, "");
102
- a[l] = h.join(e, o);
103
+ a[l] = I.join(e, o);
103
104
  }
104
- const r = await me.build({
105
+ const r = await Ae.build({
105
106
  ...n,
106
107
  entryPoints: a
107
108
  });
108
- await ze({
109
+ await Ze({
109
110
  result: r,
110
111
  appPath: e,
111
112
  fileFolder: s,
112
113
  lastChecksums: /* @__PURE__ */ new Map(),
113
114
  onFileBuilt: i
114
115
  });
115
- }, Ut = async (e, t, s) => {
116
+ }, Xt = async (e, t, s) => {
116
117
  const n = new Set(s), i = t.filter((a) => !n.has(a));
117
118
  for (const a of i) {
118
- const r = a.replace(/\.tsx?$/, ".mjs"), o = h.join(e, r), l = `${o}.map`;
119
- await pe(o), await pe(l);
119
+ const r = a.replace(/\.tsx?$/, ".mjs"), o = I.join(e, r), l = `${o}.map`;
120
+ await Ie(o), await Ie(l);
120
121
  }
121
- }, Je = [
122
+ }, et = [
122
123
  "twenty-client-sdk/core",
123
124
  "twenty-client-sdk/metadata"
124
- ], jt = /^(.+)\((\d+),(\d+)\): error TS\d+: (.+)$/, Mt = (e) => {
125
- const t = e.match(jt);
125
+ ], Qt = /^(.+)\((\d+),(\d+)\): error TS\d+: (.+)$/, Zt = (e) => {
126
+ const t = e.match(Qt);
126
127
  if (!t)
127
128
  return null;
128
129
  const [, s, n, i, a] = t;
@@ -132,27 +133,27 @@ const ge = async (e) => {
132
133
  line: Number(n),
133
134
  column: Number(i) - 1
134
135
  };
135
- }, $t = (e) => {
136
+ }, es = (e) => {
136
137
  const t = [];
137
138
  for (const s of e.split(`
138
139
  `)) {
139
- const n = Mt(s);
140
+ const n = Zt(s);
140
141
  n && t.push(n);
141
142
  }
142
143
  return t;
143
- }, Ge = (e) => {
144
- const t = Oe.join(e, "tsconfig.json"), s = Oe.join(e, "node_modules", ".bin", "tsc");
144
+ }, Te = (e) => {
145
+ const t = De.join(e, "tsconfig.json"), s = De.join(e, "node_modules", ".bin", "tsc");
145
146
  return new Promise((n) => {
146
- Ve(
147
+ ze(
147
148
  s,
148
149
  ["--noEmit", "--pretty", "false", "-p", t],
149
150
  { cwd: e },
150
151
  (i, a, r) => {
151
- n($t(r || a));
152
+ n(es(r || a));
152
153
  }
153
154
  );
154
155
  });
155
- }, Bt = (e) => e.map((t) => ({
156
+ }, ts = (e) => e.map((t) => ({
156
157
  text: t.text,
157
158
  location: {
158
159
  file: t.file,
@@ -163,17 +164,17 @@ const ge = async (e) => {
163
164
  namespace: "",
164
165
  suggestion: ""
165
166
  }
166
- })), We = (e, t) => ({
167
+ })), tt = (e, t) => ({
167
168
  name: "typecheck",
168
169
  setup: (s) => {
169
170
  s.onStart(async () => {
170
171
  if (t())
171
172
  return;
172
- const n = await Ge(e);
173
- return { errors: Bt(n) };
173
+ const n = await Te(e);
174
+ return { errors: ts(n) };
174
175
  });
175
176
  }
176
- }), Ke = [
177
+ }), st = [
177
178
  "twenty-client-sdk/core",
178
179
  "twenty-client-sdk/metadata",
179
180
  "path",
@@ -195,7 +196,7 @@ const ge = async (e) => {
195
196
  "child_process",
196
197
  "worker_threads"
197
198
  ];
198
- class Xe {
199
+ class nt {
199
200
  constructor(t) {
200
201
  this.esBuildContext = null, this.isRestarting = !1, this.lastChecksums = /* @__PURE__ */ new Map(), this.buildCompletePromise = Promise.resolve(), this.resolveBuildComplete = null, this.appPath = t.appPath, this.sourcePaths = t.sourcePaths, this.watchMode = t.watch ?? !0, this.onFileBuilt = t.handleFileBuilt, this.onBuildError = t.handleBuildError, this.config = t.config;
201
202
  }
@@ -214,18 +215,18 @@ class Xe {
214
215
  this.isRestarting = !0;
215
216
  try {
216
217
  await this.close();
217
- const s = h.join(this.appPath, R);
218
- await Ut(s, this.sourcePaths, t), this.sourcePaths = t, this.lastChecksums.clear(), this.sourcePaths.length > 0 && await this.createContext();
218
+ const s = I.join(this.appPath, O);
219
+ await Xt(s, this.sourcePaths, t), this.sourcePaths = t, this.lastChecksums.clear(), this.sourcePaths.length > 0 && await this.createContext();
219
220
  } finally {
220
221
  this.isRestarting = !1;
221
222
  }
222
223
  }
223
224
  }
224
225
  async createContext() {
225
- const t = h.join(this.appPath, R), s = {};
226
+ const t = I.join(this.appPath, O), s = {};
226
227
  for (const a of this.sourcePaths) {
227
228
  const r = a.replace(/\.tsx?$/, "");
228
- s[r] = h.join(this.appPath, a);
229
+ s[r] = I.join(this.appPath, a);
229
230
  }
230
231
  const n = this, i = [
231
232
  ...this.config.extraPlugins ?? [],
@@ -243,7 +244,7 @@ class Xe {
243
244
  );
244
245
  return;
245
246
  }
246
- await ze({
247
+ await Ze({
247
248
  result: r,
248
249
  appPath: this.appPath,
249
250
  fileFolder: this.config.fileFolder,
@@ -257,7 +258,7 @@ class Xe {
257
258
  }
258
259
  }
259
260
  ];
260
- this.esBuildContext = await me.context({
261
+ this.esBuildContext = await Ae.context({
261
262
  entryPoints: s,
262
263
  bundle: !0,
263
264
  splitting: !1,
@@ -266,7 +267,7 @@ class Xe {
266
267
  outdir: t,
267
268
  outExtension: { ".js": ".mjs" },
268
269
  external: this.config.externalModules,
269
- tsconfig: h.join(this.appPath, "tsconfig.json"),
270
+ tsconfig: I.join(this.appPath, "tsconfig.json"),
270
271
  jsx: this.config.jsx,
271
272
  sourcemap: !0,
272
273
  metafile: !0,
@@ -279,42 +280,42 @@ class Xe {
279
280
  }), await this.esBuildContext.rebuild(), await this.buildCompletePromise, this.watchMode && await this.esBuildContext.watch();
280
281
  }
281
282
  }
282
- const kn = (e) => new Xe({
283
+ const Hn = (e) => new nt({
283
284
  ...e,
284
285
  config: {
285
- externalModules: Ke,
286
- fileFolder: O.BuiltLogicFunction,
286
+ externalModules: st,
287
+ fileFolder: D.BuiltLogicFunction,
287
288
  platform: "node",
288
289
  extraPlugins: [
289
- We(e.appPath, e.shouldSkipTypecheck)
290
+ tt(e.appPath, e.shouldSkipTypecheck)
290
291
  ],
291
- banner: Be
292
+ banner: Je
292
293
  }
293
- }), Cn = (e) => new Xe({
294
+ }), Vn = (e) => new nt({
294
295
  ...e,
295
296
  config: {
296
- externalModules: Je,
297
- fileFolder: O.BuiltFrontComponent,
297
+ externalModules: et,
298
+ fileFolder: D.BuiltFrontComponent,
298
299
  jsx: "automatic",
299
300
  extraPlugins: [
300
- We(e.appPath, e.shouldSkipTypecheck),
301
- ...he()
301
+ tt(e.appPath, e.shouldSkipTypecheck),
302
+ ...we()
302
303
  ]
303
304
  }
304
- }), Ht = () => ({
305
+ }), ss = () => ({
305
306
  bundle: !0,
306
307
  splitting: !1,
307
308
  format: "esm",
308
309
  outExtension: { ".js": ".mjs" },
309
- external: Je,
310
+ external: et,
310
311
  jsx: "automatic",
311
312
  sourcemap: !0,
312
313
  metafile: !0,
313
314
  logLevel: "silent",
314
- plugins: [...he()]
315
- }), Vt = async (e) => {
316
- const t = P(e.appPath, R);
317
- await U(t), await St(t);
315
+ plugins: [...we()]
316
+ }), it = async (e) => {
317
+ const t = R(e.appPath, O);
318
+ await B(t), await zt(t);
318
319
  const s = /* @__PURE__ */ new Map(), n = (r) => {
319
320
  s.set(r.builtPath, {
320
321
  checksum: r.checksum,
@@ -324,66 +325,66 @@ const kn = (e) => new Xe({
324
325
  usesSdkClient: r.usesSdkClient
325
326
  });
326
327
  }, { logicFunctions: i, frontComponents: a } = e.filePaths;
327
- return await Le({
328
+ return await Ue({
328
329
  appPath: e.appPath,
329
330
  sourcePaths: i,
330
- fileFolder: O.BuiltLogicFunction,
331
+ fileFolder: D.BuiltLogicFunction,
331
332
  buildOptions: {
332
333
  bundle: !0,
333
334
  splitting: !1,
334
335
  format: "esm",
335
336
  platform: "node",
336
- outdir: P(e.appPath, R),
337
+ outdir: R(e.appPath, O),
337
338
  outExtension: { ".js": ".mjs" },
338
- external: Ke,
339
- tsconfig: P(e.appPath, "tsconfig.json"),
339
+ external: st,
340
+ tsconfig: R(e.appPath, "tsconfig.json"),
340
341
  sourcemap: !0,
341
342
  metafile: !0,
342
343
  logLevel: "silent",
343
- banner: Be
344
+ banner: Je
344
345
  },
345
346
  onFileBuilt: n
346
- }), await Le({
347
+ }), await Ue({
347
348
  appPath: e.appPath,
348
349
  sourcePaths: a,
349
- fileFolder: O.BuiltFrontComponent,
350
+ fileFolder: D.BuiltFrontComponent,
350
351
  buildOptions: {
351
- ...Ht(),
352
- outdir: P(e.appPath, R),
353
- tsconfig: P(e.appPath, "tsconfig.json"),
352
+ ...ss(),
353
+ outdir: R(e.appPath, O),
354
+ tsconfig: R(e.appPath, "tsconfig.json"),
354
355
  jsx: "automatic",
355
356
  sourcemap: !0,
356
357
  metafile: !0,
357
358
  logLevel: "silent",
358
- plugins: [...he()]
359
+ plugins: [...we()]
359
360
  },
360
361
  onFileBuilt: n
361
- }), await Se({
362
+ }), await $e({
362
363
  appPath: e.appPath,
363
- fileFolder: O.PublicAsset,
364
+ fileFolder: D.PublicAsset,
364
365
  filePaths: e.filePaths.publicAssets,
365
366
  collectFileBuilt: n
366
- }), await Se({
367
+ }), await $e({
367
368
  appPath: e.appPath,
368
- fileFolder: O.Dependencies,
369
+ fileFolder: D.Dependencies,
369
370
  filePaths: ["package.json", "yarn.lock"].filter(
370
- (r) => _t(P(e.appPath, r))
371
+ (r) => Yt(R(e.appPath, r))
371
372
  ),
372
373
  collectFileBuilt: n
373
374
  }), { builtFileInfos: s };
374
- }, Se = async ({
375
+ }, $e = async ({
375
376
  appPath: e,
376
377
  fileFolder: t,
377
378
  filePaths: s,
378
379
  collectFileBuilt: n
379
380
  }) => {
380
381
  for (const i of s) {
381
- const a = P(e, i);
382
- if (!await ge(a))
382
+ const a = R(e, i);
383
+ if (!await Fe(a))
383
384
  continue;
384
- const r = P(R, i), o = P(e, r);
385
- await U(at(o)), await Pt(a, o);
386
- const l = await Q(o), c = je.createHash("md5").update(l).digest("hex");
385
+ const r = R(O, i), o = R(e, r);
386
+ await B(It(o)), await Jt(a, o);
387
+ const l = await se(o), c = We.createHash("md5").update(l).digest("hex");
387
388
  n({
388
389
  fileFolder: t,
389
390
  builtPath: r,
@@ -392,13 +393,13 @@ const kn = (e) => new Xe({
392
393
  });
393
394
  }
394
395
  };
395
- var ne = /* @__PURE__ */ ((e) => (e.DefineApplication = "defineApplication", e.DefineField = "defineField", e.DefineLogicFunction = "defineLogicFunction", e.DefinePreInstallLogicFunction = "definePreInstallLogicFunction", e.DefinePostInstallLogicFunction = "definePostInstallLogicFunction", e.DefineObject = "defineObject", e.DefineRole = "defineRole", e.DefineSkill = "defineSkill", e.DefineAgent = "defineAgent", e.DefineFrontComponent = "defineFrontComponent", e.DefineView = "defineView", e.DefineNavigationMenuItem = "defineNavigationMenuItem", e.DefinePageLayout = "definePageLayout", e))(ne || {}), A = /* @__PURE__ */ ((e) => (e.Application = "application", e.Fields = "fields", e.LogicFunctions = "logicFunctions", e.Objects = "objects", e.Roles = "roles", e.Skills = "skills", e.Agents = "agents", e.FrontComponents = "frontComponents", e.PublicAssets = "publicAssets", e.Views = "views", e.NavigationMenuItems = "navigationMenuItems", e.PageLayouts = "pageLayouts", e))(A || {});
396
- const qt = {
396
+ var ue = /* @__PURE__ */ ((e) => (e.DefineApplication = "defineApplication", 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.DefineFrontComponent = "defineFrontComponent", e.DefineView = "defineView", e.DefineNavigationMenuItem = "defineNavigationMenuItem", e.DefinePageLayout = "definePageLayout", e))(ue || {}), N = /* @__PURE__ */ ((e) => (e.Application = "application", e.Fields = "fields", e.LogicFunctions = "logicFunctions", e.Objects = "objects", e.Roles = "roles", e.Skills = "skills", e.Agents = "agents", e.FrontComponents = "frontComponents", e.PublicAssets = "publicAssets", e.Views = "views", e.NavigationMenuItems = "navigationMenuItems", e.PageLayouts = "pageLayouts", e))(N || {});
397
+ const ns = {
397
398
  defineApplication: "application",
398
399
  defineField: "fields",
399
400
  defineLogicFunction: "logicFunctions",
400
- definePreInstallLogicFunction: "logicFunctions",
401
401
  definePostInstallLogicFunction: "logicFunctions",
402
+ definePreInstallLogicFunction: "logicFunctions",
402
403
  defineObject: "objects",
403
404
  defineRole: "roles",
404
405
  defineSkill: "skills",
@@ -408,62 +409,62 @@ const qt = {
408
409
  defineNavigationMenuItem: "navigationMenuItems",
409
410
  definePageLayout: "pageLayouts"
410
411
  /* PageLayouts */
411
- }, Yt = (e) => {
412
- if (!q.isCallExpression(e))
412
+ }, is = (e) => {
413
+ if (!W.isCallExpression(e))
413
414
  return;
414
415
  const t = e.expression;
415
- if (q.isIdentifier(t) && Object.values(ne).includes(t.text))
416
+ if (W.isIdentifier(t) && Object.values(ue).includes(t.text))
416
417
  return t.text;
417
- }, zt = (e) => {
418
- const t = q.createSourceFile(
418
+ }, as = (e) => {
419
+ const t = W.createSourceFile(
419
420
  "temp.ts",
420
421
  e,
421
- q.ScriptTarget.Latest,
422
+ W.ScriptTarget.Latest,
422
423
  !0
423
424
  ), s = [];
424
- q.forEachChild(t, (n) => {
425
+ W.forEachChild(t, (n) => {
425
426
  s.push(n);
426
427
  });
427
428
  for (const n of s)
428
- if (q.isExportAssignment(n)) {
429
+ if (W.isExportAssignment(n)) {
429
430
  if (n.isExportEquals || !n.expression)
430
431
  return;
431
- const i = Yt(n.expression);
432
+ const i = is(n.expression);
432
433
  if (i)
433
434
  return i;
434
435
  }
435
- }, Jt = [
436
+ }, rs = [
436
437
  [/\bfavoriteRecordIds\.length\b/g, "arrayLength(favoriteRecordIds)"],
437
438
  [/\bselectedRecords\.length\b/g, "arrayLength(selectedRecords)"]
438
- ], Gt = (e) => Jt.reduce(
439
+ ], os = (e) => rs.reduce(
439
440
  (t, [s, n]) => t.replace(s, n),
440
441
  e.replace(/!==/g, "!=").replace(/===/g, "==").replace(/&&/g, "and").replace(/\|\|/g, "or").replace(/!(?!=)/g, "not ").replace(/,(\s*\))/g, "$1")
441
- ), Wt = /(conditionalAvailabilityExpression\s*:\s*)(?!['"`])((?:[^,}()]|\([^()]*\))+)/g, Kt = (e) => e.replace(
442
- Wt,
443
- (t, s, n) => s + JSON.stringify(Gt(n.trim()))
444
- ), Xt = {
442
+ ), cs = /(conditionalAvailabilityExpression\s*:\s*)(?!['"`])((?:[^,}()]|\([^()]*\))+)/g, ls = (e) => e.replace(
443
+ cs,
444
+ (t, s, n) => s + JSON.stringify(os(n.trim()))
445
+ ), us = {
445
446
  name: "conditional-availability-transform",
446
447
  setup: (e) => {
447
448
  e.onLoad({ filter: /\.tsx?$/ }, async (t) => {
448
- const s = await kt.readFile(t.path, "utf8");
449
+ const s = await Ht.readFile(t.path, "utf8");
449
450
  if (!s.includes("conditionalAvailabilityExpression"))
450
451
  return null;
451
- const n = Kt(s);
452
+ const n = ls(s);
452
453
  return n === s ? null : {
453
454
  contents: n,
454
455
  loader: t.path.endsWith(".tsx") ? "tsx" : "ts"
455
456
  };
456
457
  });
457
458
  }
458
- }, Qt = [
459
+ }, ps = [
459
460
  "twenty-sdk/ui",
460
461
  "twenty-client-sdk/core",
461
462
  "twenty-client-sdk/metadata"
462
- ], Zt = {
463
+ ], ds = {
463
464
  name: "manifest-mock",
464
465
  setup: (e) => {
465
466
  const t = new RegExp(
466
- `^(${Qt.map((s) => s.replace("/", "\\/")).join("|")})$`
467
+ `^(${ps.map((s) => s.replace("/", "\\/")).join("|")})$`
467
468
  );
468
469
  e.onResolve({ filter: t }, ({ path: s }) => ({
469
470
  path: s,
@@ -473,23 +474,23 @@ const qt = {
473
474
  loader: "js"
474
475
  }));
475
476
  }
476
- }, F = async ({
477
+ }, k = async ({
477
478
  filePath: e,
478
479
  appPath: t
479
480
  }) => {
480
- const s = await es({ filePath: e, appPath: t });
481
- return ts(s, e);
482
- }, es = async ({
481
+ const s = await fs({ filePath: e, appPath: t });
482
+ return ms(s, e);
483
+ }, fs = async ({
483
484
  filePath: e,
484
485
  appPath: t
485
486
  }) => {
486
- const s = h.join(t, "tsconfig.json"), n = await ge(s), i = Ct(h.join(t, "package.json"));
487
+ const s = I.join(t, "tsconfig.json"), n = await Fe(s), i = Vt(I.join(t, "package.json"));
487
488
  let a, r;
488
489
  try {
489
- a = h.dirname(i.resolve("react/package.json")), r = h.dirname(i.resolve("react-dom/package.json"));
490
+ a = I.dirname(i.resolve("react/package.json")), r = I.dirname(i.resolve("react-dom/package.json"));
490
491
  } catch {
491
492
  }
492
- const l = (await me.build({
493
+ const l = (await Ae.build({
493
494
  entryPoints: [e],
494
495
  bundle: !0,
495
496
  write: !1,
@@ -502,27 +503,27 @@ const qt = {
502
503
  ...a && { react: a },
503
504
  ...r && { "react-dom": r }
504
505
  },
505
- plugins: [Xt, Zt],
506
+ plugins: [us, ds],
506
507
  logLevel: "silent"
507
- })).outputFiles[0].text, c = await ut(h.join(Tt.tmpdir(), "twenty-manifest-")), u = h.join(c, "module.cjs");
508
+ })).outputFiles[0].text, c = await Lt(I.join(Ut.tmpdir(), "twenty-manifest-")), u = I.join(c, "module.cjs");
508
509
  try {
509
- return await j(u, l), i(u);
510
+ return await H(u, l), i(u);
510
511
  } finally {
511
- await pe(c);
512
+ await Ie(c);
512
513
  }
513
- }, ts = (e, t) => {
514
- if (He(e.default) && pt(e.default))
514
+ }, ms = (e, t) => {
515
+ if (Ge(e.default) && Et(e.default))
515
516
  return e.default;
516
517
  throw new Error(
517
518
  `Config file ${t} must export a config object default export`
518
519
  );
519
- }, ss = "142046f0-4d80-48b5-ad56-26ad410e895c", E = ({
520
+ }, hs = "142046f0-4d80-48b5-ad56-26ad410e895c", L = ({
520
521
  objectConfig: e,
521
522
  fieldName: t
522
523
  }) => {
523
524
  const s = `${e.universalIdentifier}-${t}`;
524
- return Ot(s, ss);
525
- }, ns = (e) => {
525
+ return Z(s, hs);
526
+ }, gs = (e) => {
526
527
  const t = {
527
528
  name: "id",
528
529
  label: "Id",
@@ -530,8 +531,8 @@ const qt = {
530
531
  icon: "Icon123",
531
532
  isNullable: !1,
532
533
  defaultValue: "uuid",
533
- type: g.UUID,
534
- universalIdentifier: E({
534
+ type: A.UUID,
535
+ universalIdentifier: L({
535
536
  objectConfig: e,
536
537
  fieldName: "id"
537
538
  })
@@ -542,8 +543,8 @@ const qt = {
542
543
  icon: "IconAbc",
543
544
  isNullable: !0,
544
545
  defaultValue: null,
545
- type: g.TEXT,
546
- universalIdentifier: E({
546
+ type: A.TEXT,
547
+ universalIdentifier: L({
547
548
  objectConfig: e,
548
549
  fieldName: "name"
549
550
  })
@@ -554,8 +555,8 @@ const qt = {
554
555
  icon: "IconCalendar",
555
556
  isNullable: !1,
556
557
  defaultValue: "now",
557
- type: g.DATE_TIME,
558
- universalIdentifier: E({
558
+ type: A.DATE_TIME,
559
+ universalIdentifier: L({
559
560
  objectConfig: e,
560
561
  fieldName: "createdAt"
561
562
  })
@@ -566,8 +567,8 @@ const qt = {
566
567
  icon: "IconCalendarClock",
567
568
  isNullable: !1,
568
569
  defaultValue: "now",
569
- type: g.DATE_TIME,
570
- universalIdentifier: E({
570
+ type: A.DATE_TIME,
571
+ universalIdentifier: L({
571
572
  objectConfig: e,
572
573
  fieldName: "updatedAt"
573
574
  })
@@ -578,8 +579,8 @@ const qt = {
578
579
  icon: "IconCalendarClock",
579
580
  isNullable: !0,
580
581
  defaultValue: null,
581
- type: g.DATE_TIME,
582
- universalIdentifier: E({
582
+ type: A.DATE_TIME,
583
+ universalIdentifier: L({
583
584
  objectConfig: e,
584
585
  fieldName: "deletedAt"
585
586
  })
@@ -590,8 +591,8 @@ const qt = {
590
591
  icon: "IconCreativeCommonsSa",
591
592
  isNullable: !1,
592
593
  defaultValue: { name: "''", source: "'MANUAL'" },
593
- type: g.ACTOR,
594
- universalIdentifier: E({
594
+ type: A.ACTOR,
595
+ universalIdentifier: L({
595
596
  objectConfig: e,
596
597
  fieldName: "createdBy"
597
598
  })
@@ -602,8 +603,8 @@ const qt = {
602
603
  icon: "IconUserCircle",
603
604
  isNullable: !1,
604
605
  defaultValue: { name: "''", source: "'MANUAL'" },
605
- type: g.ACTOR,
606
- universalIdentifier: E({
606
+ type: A.ACTOR,
607
+ universalIdentifier: L({
607
608
  objectConfig: e,
608
609
  fieldName: "updatedBy"
609
610
  })
@@ -614,8 +615,8 @@ const qt = {
614
615
  icon: "IconHierarchy2",
615
616
  isNullable: !1,
616
617
  defaultValue: 0,
617
- type: g.POSITION,
618
- universalIdentifier: E({
618
+ type: A.POSITION,
619
+ universalIdentifier: L({
619
620
  objectConfig: e,
620
621
  fieldName: "position"
621
622
  })
@@ -626,8 +627,8 @@ const qt = {
626
627
  description: "Search vector",
627
628
  isNullable: !0,
628
629
  defaultValue: null,
629
- type: g.TS_VECTOR,
630
- universalIdentifier: E({
630
+ type: A.TS_VECTOR,
631
+ universalIdentifier: L({
631
632
  objectConfig: e,
632
633
  fieldName: "searchVector"
633
634
  })
@@ -643,83 +644,83 @@ const qt = {
643
644
  l,
644
645
  c
645
646
  ];
646
- }, G = {
647
- targetFieldName: (e) => `target${ue(e.nameSingular)}`,
648
- targetLabel: (e) => ue(e.nameSingular),
647
+ }, X = {
648
+ targetFieldName: (e) => `target${ye(e.nameSingular)}`,
649
+ targetLabel: (e) => ye(e.nameSingular),
649
650
  icon: "IconBuildingSkyscraper",
650
651
  isNullable: !0
651
- }, is = [
652
+ }, ys = [
652
653
  {
653
- ...G,
654
+ ...X,
654
655
  fieldName: "timelineActivities",
655
656
  label: "Timeline Activities",
656
657
  targetIcon: "IconTimelineEvent",
657
- targetFieldType: g.MORPH_RELATION,
658
+ targetFieldType: A.MORPH_RELATION,
658
659
  standardObjectKey: "timelineActivity",
659
- morphId: V.timelineActivity.morphIds.targetMorphId.morphId
660
+ morphId: G.timelineActivity.morphIds.targetMorphId.morphId
660
661
  },
661
662
  {
662
- ...G,
663
+ ...X,
663
664
  fieldName: "favorites",
664
665
  label: "Favorites",
665
666
  icon: "IconBuildingSkyscraper",
666
667
  targetIcon: "IconHeart",
667
- targetFieldType: g.RELATION,
668
+ targetFieldType: A.RELATION,
668
669
  standardObjectKey: "favorite"
669
670
  },
670
671
  {
671
- ...G,
672
+ ...X,
672
673
  fieldName: "attachments",
673
674
  label: "Attachments",
674
675
  icon: "IconBuildingSkyscraper",
675
676
  targetIcon: "IconFileImport",
676
- targetFieldType: g.MORPH_RELATION,
677
+ targetFieldType: A.MORPH_RELATION,
677
678
  standardObjectKey: "attachment",
678
- morphId: V.attachment.morphIds.targetMorphId.morphId
679
+ morphId: G.attachment.morphIds.targetMorphId.morphId
679
680
  },
680
681
  {
681
- ...G,
682
+ ...X,
682
683
  fieldName: "noteTargets",
683
684
  label: "Note Targets",
684
685
  icon: "IconBuildingSkyscraper",
685
686
  targetIcon: "IconCheckbox",
686
- targetFieldType: g.MORPH_RELATION,
687
+ targetFieldType: A.MORPH_RELATION,
687
688
  standardObjectKey: "noteTarget",
688
- morphId: V.noteTarget.morphIds.targetMorphId.morphId
689
+ morphId: G.noteTarget.morphIds.targetMorphId.morphId
689
690
  },
690
691
  {
691
- ...G,
692
+ ...X,
692
693
  fieldName: "taskTargets",
693
694
  label: "Task Targets",
694
695
  icon: "IconBuildingSkyscraper",
695
696
  targetIcon: "IconCheckbox",
696
- targetFieldType: g.MORPH_RELATION,
697
+ targetFieldType: A.MORPH_RELATION,
697
698
  standardObjectKey: "taskTarget",
698
- morphId: V.taskTarget.morphIds.targetMorphId.morphId
699
+ morphId: G.taskTarget.morphIds.targetMorphId.morphId
699
700
  }
700
- ], as = ({
701
+ ], Is = ({
701
702
  config: e,
702
703
  forwardFieldUniversalIdentifier: t,
703
704
  objectConfig: s,
704
705
  universalIdentifier: n
705
706
  }) => {
706
- const i = V[e.standardObjectKey], a = {
707
+ const i = G[e.standardObjectKey], a = {
707
708
  name: e.targetFieldName(s),
708
709
  label: e.targetLabel(s),
709
710
  description: `${e.targetLabel(s)} ${s.labelSingular}`,
710
711
  icon: e.targetIcon,
711
712
  isNullable: !0,
712
713
  universalSettings: {
713
- relationType: X.MANY_TO_ONE,
714
- onDelete: dt.SET_NULL,
715
- joinColumnName: `target${ue(s.nameSingular)}Id`
714
+ relationType: ee.MANY_TO_ONE,
715
+ onDelete: bt.SET_NULL,
716
+ joinColumnName: `target${ye(s.nameSingular)}Id`
716
717
  },
717
718
  universalIdentifier: n,
718
719
  objectUniversalIdentifier: i.universalIdentifier,
719
720
  relationTargetFieldMetadataUniversalIdentifier: t,
720
721
  relationTargetObjectMetadataUniversalIdentifier: s.universalIdentifier
721
722
  };
722
- return e.targetFieldType === g.MORPH_RELATION ? {
723
+ return e.targetFieldType === A.MORPH_RELATION ? {
723
724
  ...a,
724
725
  type: e.targetFieldType,
725
726
  morphId: e.morphId
@@ -727,13 +728,13 @@ const qt = {
727
728
  ...a,
728
729
  type: e.targetFieldType
729
730
  };
730
- }, rs = (e) => {
731
+ }, vs = (e) => {
731
732
  const t = [], s = [];
732
- for (const n of is) {
733
- const i = V[n.standardObjectKey], a = E({
733
+ for (const n of ys) {
734
+ const i = G[n.standardObjectKey], a = L({
734
735
  objectConfig: e,
735
736
  fieldName: n.fieldName
736
- }), r = E({
737
+ }), r = L({
737
738
  objectConfig: e,
738
739
  fieldName: `${n.fieldName}Inverse`
739
740
  }), o = {
@@ -742,12 +743,12 @@ const qt = {
742
743
  description: `${e.labelPlural} tied to the ${n.targetLabel(e)}`,
743
744
  icon: n.icon,
744
745
  isNullable: n.isNullable,
745
- type: g.RELATION,
746
- universalSettings: { relationType: X.ONE_TO_MANY },
746
+ type: A.RELATION,
747
+ universalSettings: { relationType: ee.ONE_TO_MANY },
747
748
  universalIdentifier: a,
748
749
  relationTargetFieldMetadataUniversalIdentifier: r,
749
750
  relationTargetObjectMetadataUniversalIdentifier: i.universalIdentifier
750
- }, l = as({
751
+ }, l = Is({
751
752
  config: n,
752
753
  objectConfig: e,
753
754
  universalIdentifier: r,
@@ -756,285 +757,336 @@ const qt = {
756
757
  t.push(o), s.push(l);
757
758
  }
758
759
  return { objectFields: t, fields: s };
759
- }, os = (e) => {
760
- const t = ns(e), { objectFields: s, fields: n } = rs(e), i = (e.fields ?? []).map((r) => r.name), a = [...e.fields];
760
+ }, As = (e) => {
761
+ const t = gs(e), { objectFields: s, fields: n } = vs(e), i = (e.fields ?? []).map((r) => r.name), a = [...e.fields];
761
762
  for (const r of t)
762
763
  i.includes(r.name) || a.push(r);
763
764
  for (const r of s)
764
765
  i.includes(r.name) || a.push(r);
765
766
  return { objectFields: a, fields: n };
766
- }, cs = {
767
+ }, ws = {
767
768
  type: "object",
768
769
  properties: {}
769
- }, ls = async (e) => {
770
- const { getFunctionInputSchema: t } = await import("./get-function-input-schema-BZ7_XyUh-xI83N7kX.mjs"), s = t(e)[0];
771
- return s?.type === "object" && He(s.properties) ? {
770
+ }, Fs = async (e) => {
771
+ const { getFunctionInputSchema: t } = await import("./get-function-input-schema-BZ7_XyUh-CtECetlr.mjs"), s = t(e)[0];
772
+ return s?.type === "object" && Ge(s.properties) ? {
772
773
  type: "object",
773
774
  properties: s.properties
774
- } : cs;
775
- }, us = async (e) => await Ye(["**/*.ts", "**/*.tsx"], {
775
+ } : ws;
776
+ }, Ts = "a80ff791-b940-4c47-a522-2bb478515415", je = (e) => e.type !== A.SELECT && e.type !== A.MULTI_SELECT || e.options === void 0 || e.options === null ? e : {
777
+ ...e,
778
+ options: e.options.map((t) => ({
779
+ ...t,
780
+ id: t.id ?? Z(
781
+ `${t.label}-${e.universalIdentifier}`,
782
+ Ts
783
+ )
784
+ }))
785
+ }, me = "b403ec59-4d80-4f22-85e6-717a192dc9cb", Es = (e) => ({
786
+ ...e,
787
+ objectPermissions: (e.objectPermissions ?? []).map(
788
+ (t) => ({
789
+ ...t,
790
+ universalIdentifier: Z(
791
+ `${e.universalIdentifier}:${t.objectUniversalIdentifier}`,
792
+ me
793
+ )
794
+ })
795
+ ),
796
+ fieldPermissions: (e.fieldPermissions ?? []).map(
797
+ (t) => ({
798
+ ...t,
799
+ universalIdentifier: Z(
800
+ `${e.universalIdentifier}:${t.objectUniversalIdentifier}:${t.fieldUniversalIdentifier}`,
801
+ me
802
+ )
803
+ })
804
+ ),
805
+ permissionFlags: (e.permissionFlags ?? []).map(
806
+ (t) => ({
807
+ universalIdentifier: Z(
808
+ `${e.universalIdentifier}:${t}`,
809
+ me
810
+ ),
811
+ flag: t
812
+ })
813
+ )
814
+ }), bs = async (e) => await Qe(["**/*.ts", "**/*.tsx"], {
776
815
  cwd: e,
777
816
  absolute: !0,
778
817
  ignore: ["**/node_modules/**", "**/*.d.ts", "**/dist/**", "**/.twenty/**"],
779
818
  onlyFiles: !0
780
- }), ps = async (e) => await Ye([`${mt}/**/*`], {
819
+ }), Ns = async (e) => await Qe([`${St}/**/*`], {
781
820
  cwd: e,
821
+ absolute: !0,
782
822
  onlyFiles: !0
783
- }), Qe = async (e) => {
784
- const t = await us(e), s = [];
823
+ }), at = async (e) => {
824
+ const t = await bs(e), s = [];
785
825
  let n;
786
- const i = [], a = [], r = [], o = [], l = [], c = [], u = [], d = [], f = [], I = [], w = [], _ = [], L = [], ae = [], re = [], Ie = [], ve = [], Ae = [], we = [], Te = [], Fe = [], be = [], Ee = [], Ne = [], ke = [];
787
- for (const m of t) {
788
- const $ = await Q(m, "utf-8"), T = W(e, m), ee = zt($);
789
- if (!ee)
826
+ const i = [], a = [], r = [], o = [], l = [], c = [], u = [], d = [], p = [], h = [], v = [], T = [], E = [], g = [], F = [], ne = [], be = [], Ne = [], Se = [], Ce = [], ke = [], Pe = [], Le = [], Oe = [], _e = [];
827
+ for (const y of t) {
828
+ const $ = await se(y, "utf-8"), C = J(e, y), ie = as($);
829
+ if (!ie)
790
830
  continue;
791
- switch (qt[ee]) {
792
- case A.Application: {
793
- const p = await F({
831
+ switch (ns[ie]) {
832
+ case N.Application: {
833
+ const f = await k({
794
834
  appPath: e,
795
- filePath: m
835
+ filePath: y
796
836
  });
797
837
  n = {
798
- ...p.config,
838
+ ...f.config,
799
839
  yarnLockChecksum: null,
800
840
  packageJsonChecksum: null
801
- }, s.push(...p.errors), ae.push(T);
841
+ }, s.push(...f.errors), g.push(C);
802
842
  break;
803
843
  }
804
- case A.Objects: {
805
- const p = await F({
844
+ case N.Objects: {
845
+ const f = await k({
806
846
  appPath: e,
807
- filePath: m
847
+ filePath: y
808
848
  }), {
809
- objectFields: S,
810
- fields: B
811
- } = os(p.config), D = p.config.labelIdentifierFieldMetadataUniversalIdentifier ?? S.find((J) => J.name === "name")?.universalIdentifier;
812
- if (!D) {
849
+ objectFields: b,
850
+ fields: Y
851
+ } = As(f.config), M = f.config.labelIdentifierFieldMetadataUniversalIdentifier ?? b.find((K) => K.name === "name")?.universalIdentifier;
852
+ if (!M) {
813
853
  s.push(
814
- `No label identifier field found for object ${p.config.nameSingular}. Please add a field with name "name" to your object.`
854
+ `No label identifier field found for object ${f.config.nameSingular}. Please add a field with name "name" to your object.`
815
855
  );
816
856
  break;
817
857
  }
818
- const H = {
819
- ...p.config,
820
- fields: S,
821
- labelIdentifierFieldMetadataUniversalIdentifier: D
858
+ const q = {
859
+ ...f.config,
860
+ fields: b.map(je),
861
+ labelIdentifierFieldMetadataUniversalIdentifier: M
822
862
  };
823
- i.push(H), a.push(...B), s.push(...p.errors), re.push(T);
863
+ i.push(q), a.push(...Y), s.push(...f.errors), F.push(C);
824
864
  break;
825
865
  }
826
- case A.Fields: {
827
- const p = await F({
866
+ case N.Fields: {
867
+ const f = await k({
828
868
  appPath: e,
829
- filePath: m
830
- });
831
- a.push(p.config), s.push(...p.errors), Ie.push(T);
869
+ filePath: y
870
+ }), b = je(f.config);
871
+ a.push(b), s.push(...f.errors), ne.push(C);
832
872
  break;
833
873
  }
834
- case A.Roles: {
835
- const p = await F({
874
+ case N.Roles: {
875
+ const f = await k({
836
876
  appPath: e,
837
- filePath: m
838
- });
839
- r.push(p.config), s.push(...p.errors), ve.push(T);
877
+ filePath: y
878
+ }), b = Es(f.config);
879
+ r.push(b), s.push(...f.errors), be.push(C);
840
880
  break;
841
881
  }
842
- case A.Skills: {
843
- const p = await F({
882
+ case N.Skills: {
883
+ const f = await k({
844
884
  appPath: e,
845
- filePath: m
885
+ filePath: y
846
886
  });
847
- o.push(p.config), s.push(...p.errors), Ae.push(T);
887
+ o.push(f.config), s.push(...f.errors), Ne.push(C);
848
888
  break;
849
889
  }
850
- case A.Agents: {
851
- const p = await F({
890
+ case N.Agents: {
891
+ const f = await k({
852
892
  appPath: e,
853
- filePath: m
893
+ filePath: y
854
894
  });
855
- l.push(p.config), s.push(...p.errors), we.push(T);
895
+ l.push(f.config), s.push(...f.errors), Se.push(C);
856
896
  break;
857
897
  }
858
- case A.LogicFunctions: {
859
- const p = await F({
898
+ case N.LogicFunctions: {
899
+ const f = await k({
860
900
  appPath: e,
861
- filePath: m
901
+ filePath: y
862
902
  });
863
- s.push(...p.errors);
864
- const { handler: S, ...B } = p.config, D = W(e, m), H = B.toolInputSchema ?? await ls($), J = {
865
- ...B,
866
- toolInputSchema: H,
903
+ s.push(...f.errors);
904
+ const { handler: b, ...Y } = f.config, M = J(e, y), q = Y.toolInputSchema ?? await Fs($), K = {
905
+ ...Y,
906
+ toolInputSchema: q,
867
907
  handlerName: "default.config.handler",
868
- sourceHandlerPath: D,
869
- builtHandlerPath: D.replace(/\.tsx?$/, ".mjs"),
908
+ sourceHandlerPath: M,
909
+ builtHandlerPath: M.replace(/\.tsx?$/, ".mjs"),
870
910
  builtHandlerChecksum: "[default-checksum]"
871
911
  };
872
- c.push(J), Te.push(T), ee === ne.DefinePreInstallLogicFunction && _.push(
873
- p.config.universalIdentifier
874
- ), ee === ne.DefinePostInstallLogicFunction && L.push(
875
- p.config.universalIdentifier
876
- );
912
+ if (c.push(K), Ce.push(C), ie === ue.DefinePostInstallLogicFunction) {
913
+ const ae = f.config;
914
+ T.push({
915
+ universalIdentifier: f.config.universalIdentifier,
916
+ shouldRunOnVersionUpgrade: ae.shouldRunOnVersionUpgrade ?? !1,
917
+ shouldRunSynchronously: ae.shouldRunSynchronously ?? !1
918
+ });
919
+ }
920
+ if (ie === ue.DefinePreInstallLogicFunction) {
921
+ const ae = f.config;
922
+ E.push({
923
+ universalIdentifier: f.config.universalIdentifier,
924
+ shouldRunOnVersionUpgrade: ae.shouldRunOnVersionUpgrade ?? !1
925
+ });
926
+ }
877
927
  break;
878
928
  }
879
- case A.FrontComponents: {
880
- const p = await F({
929
+ case N.FrontComponents: {
930
+ const f = await k({
881
931
  appPath: e,
882
- filePath: m
932
+ filePath: y
883
933
  });
884
- s.push(...p.errors);
885
- const { component: S, command: B, ...D } = p.config, H = W(e, m), J = {
886
- ...D,
887
- componentName: S.name,
888
- sourceComponentPath: H,
889
- builtComponentPath: H.replace(/\.tsx?$/, ".mjs"),
934
+ s.push(...f.errors);
935
+ const { component: b, command: Y, ...M } = f.config, q = J(e, y), K = {
936
+ ...M,
937
+ componentName: b.name,
938
+ sourceComponentPath: q,
939
+ builtComponentPath: q.replace(/\.tsx?$/, ".mjs"),
890
940
  builtComponentChecksum: "",
891
- isHeadless: D.isHeadless ?? !1,
941
+ isHeadless: M.isHeadless ?? !1,
892
942
  // transformed by conditionalAvailabilityTransformPlugin
893
- command: B
943
+ command: Y
894
944
  };
895
- u.push(J), Fe.push(T);
945
+ u.push(K), ke.push(C);
896
946
  break;
897
947
  }
898
- case A.Views: {
899
- const p = await F({
948
+ case N.Views: {
949
+ const f = await k({
900
950
  appPath: e,
901
- filePath: m
902
- }), S = {
903
- ...p.config
951
+ filePath: y
952
+ }), b = {
953
+ ...f.config
904
954
  };
905
- f.push(S), s.push(...p.errors), Ee.push(T);
955
+ p.push(b), s.push(...f.errors), Le.push(C);
906
956
  break;
907
957
  }
908
- case A.NavigationMenuItems: {
909
- const p = await F({
958
+ case N.NavigationMenuItems: {
959
+ const f = await k({
910
960
  appPath: e,
911
- filePath: m
961
+ filePath: y
912
962
  });
913
- I.push(p.config), s.push(...p.errors), Ne.push(T);
963
+ h.push(f.config), s.push(...f.errors), Oe.push(C);
914
964
  break;
915
965
  }
916
- case A.PageLayouts: {
917
- const p = await F({
966
+ case N.PageLayouts: {
967
+ const f = await k({
918
968
  appPath: e,
919
- filePath: m
920
- }), S = {
921
- ...p.config
969
+ filePath: y
970
+ }), b = {
971
+ ...f.config
922
972
  };
923
- w.push(S), s.push(...p.errors), ke.push(T);
973
+ v.push(b), s.push(...f.errors), _e.push(C);
924
974
  break;
925
975
  }
926
- case A.PublicAssets:
976
+ case N.PublicAssets:
927
977
  break;
928
978
  default:
929
- ft();
979
+ Nt();
930
980
  }
931
981
  }
932
- const st = await ps(e);
933
- for (const m of st)
982
+ const ht = await Ns(e);
983
+ for (const y of ht) {
984
+ const $ = J(e, y);
934
985
  d.push({
935
- filePath: m,
936
- fileName: ot(m),
937
- fileType: rt(m).replace(/^\./, ""),
986
+ filePath: $,
987
+ fileName: At(y),
988
+ fileType: vt(y).replace(/^\./, ""),
938
989
  checksum: null
939
- }), be.push(W(e, m));
990
+ }), Pe.push($);
991
+ }
940
992
  n || s.push(
941
993
  "Cannot build application, please export default defineApplication() to define an application"
942
- ), _.length > 1 && s.push(
943
- "Only one pre install logic function is allowed per application"
944
- ), L.length > 1 && s.push(
994
+ ), T.length > 1 && s.push(
945
995
  "Only one post install logic function is allowed per application"
946
- ), n && _.length >= 1 && (n = {
996
+ ), E.length > 1 && s.push(
997
+ "Only one pre install logic function is allowed per application"
998
+ ), n && T.length >= 1 && (n = {
947
999
  ...n,
948
- preInstallLogicFunctionUniversalIdentifier: _[0]
949
- }), n && L.length >= 1 && (n = {
1000
+ postInstallLogicFunction: T[0]
1001
+ }), n && E.length >= 1 && (n = {
950
1002
  ...n,
951
- postInstallLogicFunctionUniversalIdentifier: L[0]
1003
+ preInstallLogicFunction: E[0]
952
1004
  });
953
- const k = (m, $) => m.universalIdentifier.localeCompare($.universalIdentifier), nt = (m, $) => m.filePath.localeCompare($.filePath);
1005
+ const _ = (y, $) => y.universalIdentifier.localeCompare($.universalIdentifier), gt = (y, $) => y.filePath.localeCompare($.filePath);
954
1006
  return { manifest: n ? {
955
1007
  application: n,
956
- objects: i.sort(k),
957
- fields: a.sort(k),
958
- roles: r.sort(k),
959
- skills: o.sort(k),
960
- agents: l.sort(k),
961
- logicFunctions: c.sort(k),
962
- frontComponents: u.sort(k),
963
- publicAssets: d.sort(nt),
964
- views: f.sort(k),
965
- navigationMenuItems: I.sort(k),
966
- pageLayouts: w.sort(k)
1008
+ objects: i.sort(_),
1009
+ fields: a.sort(_),
1010
+ roles: r.sort(_),
1011
+ skills: o.sort(_),
1012
+ agents: l.sort(_),
1013
+ logicFunctions: c.sort(_),
1014
+ frontComponents: u.sort(_),
1015
+ publicAssets: d.sort(gt),
1016
+ views: p.sort(_),
1017
+ navigationMenuItems: h.sort(_),
1018
+ pageLayouts: v.sort(_)
967
1019
  } : null, filePaths: {
968
- application: ae,
969
- objects: re,
970
- fields: Ie,
971
- roles: ve,
972
- skills: Ae,
973
- agents: we,
974
- logicFunctions: Te,
975
- frontComponents: Fe,
976
- publicAssets: be,
977
- views: Ee,
978
- navigationMenuItems: Ne,
979
- pageLayouts: ke
1020
+ application: g,
1021
+ objects: F,
1022
+ fields: ne,
1023
+ roles: be,
1024
+ skills: Ne,
1025
+ agents: Se,
1026
+ logicFunctions: Ce,
1027
+ frontComponents: ke,
1028
+ publicAssets: Pe,
1029
+ views: Le,
1030
+ navigationMenuItems: Oe,
1031
+ pageLayouts: _e
980
1032
  }, errors: s };
981
- }, ds = [
982
- g.RELATION,
983
- g.MORPH_RELATION
984
- ], ce = [
985
- X.MANY_TO_ONE,
986
- X.ONE_TO_MANY
987
- ], fs = (e) => {
1033
+ }, Ss = [
1034
+ A.RELATION,
1035
+ A.MORPH_RELATION
1036
+ ], he = [
1037
+ ee.MANY_TO_ONE,
1038
+ ee.ONE_TO_MANY
1039
+ ], Cs = (e) => {
988
1040
  const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
989
1041
  for (const n of e)
990
1042
  t.has(n) ? s.add(n) : t.add(n);
991
1043
  return Array.from(s);
992
- }, Ze = (e) => {
1044
+ }, rt = (e) => {
993
1045
  const t = [];
994
1046
  if (!e)
995
1047
  return [];
996
1048
  for (const [s, n] of Object.entries(e))
997
- s === "universalIdentifier" && typeof n == "string" && t.push(n), typeof n == "object" && t.push(...Ze(n));
1049
+ s === "universalIdentifier" && typeof n == "string" && t.push(n), !(s === "postInstallLogicFunction" || s === "preInstallLogicFunction") && typeof n == "object" && t.push(...rt(n));
998
1050
  return t;
999
- }, ms = (e) => {
1051
+ }, ks = (e) => {
1000
1052
  const t = [];
1001
1053
  for (const s of e) {
1002
- if (!ds.includes(s.type))
1054
+ if (!Ss.includes(s.type))
1003
1055
  continue;
1004
1056
  const n = s.universalSettings;
1005
1057
  if (!n?.relationType) {
1006
1058
  t.push(
1007
- `Relation field "${s.name}" is missing relationType. ${s.type} fields must declare a relationType (${ce.join(" or ")}) in universalSettings.`
1059
+ `Relation field "${s.name}" is missing relationType. ${s.type} fields must declare a relationType (${he.join(" or ")}) in universalSettings.`
1008
1060
  );
1009
1061
  continue;
1010
1062
  }
1011
- if (!ce.includes(n.relationType)) {
1063
+ if (!he.includes(n.relationType)) {
1012
1064
  t.push(
1013
- `Relation field "${s.name}" has invalid relationType "${n.relationType}". Expected ${ce.join(" or ")}.`
1065
+ `Relation field "${s.name}" has invalid relationType "${n.relationType}". Expected ${he.join(" or ")}.`
1014
1066
  );
1015
1067
  continue;
1016
1068
  }
1017
- n.relationType === X.MANY_TO_ONE && !n.joinColumnName && t.push(
1069
+ n.relationType === ee.MANY_TO_ONE && !n.joinColumnName && t.push(
1018
1070
  `MANY_TO_ONE relation field "${s.name}" is missing joinColumnName. MANY_TO_ONE relations must declare a joinColumnName in universalSettings.`
1019
1071
  );
1020
1072
  }
1021
1073
  return t;
1022
- }, hs = (e) => {
1023
- const t = [], s = [], n = fs(Ze(e));
1024
- n.length > 0 && t.push(`Duplicate universal identifiers: ${n.join(", ")}`), oe(e.objects) || s.push("No object defined"), oe(e.logicFunctions) || s.push("No logic function defined"), oe(e.frontComponents) || s.push("No front component defined");
1074
+ }, Ps = (e) => {
1075
+ const t = [], s = [], n = Cs(rt(e));
1076
+ n.length > 0 && t.push(`Duplicate universal identifiers: ${n.join(", ")}`), fe(e.objects) || s.push("No object defined"), fe(e.logicFunctions) || s.push("No logic function defined"), fe(e.frontComponents) || s.push("No front component defined");
1025
1077
  const i = [
1026
1078
  ...e.fields,
1027
1079
  ...e.objects.flatMap((a) => a.fields)
1028
1080
  ];
1029
- return t.push(...ms(i)), { errors: t, warnings: s, isValid: t.length === 0 };
1030
- }, gs = async (e) => {
1031
- const t = await Qe(e);
1081
+ return t.push(...ks(i)), { errors: t, warnings: s, isValid: t.length === 0 };
1082
+ }, ot = async (e) => {
1083
+ const t = await at(e);
1032
1084
  if (t.errors.length > 0 || !t.manifest)
1033
1085
  return {
1034
1086
  success: !1,
1035
1087
  errors: t.errors.length > 0 ? t.errors : ["Failed to build manifest."]
1036
1088
  };
1037
- const s = hs(t.manifest);
1089
+ const s = Ps(t.manifest);
1038
1090
  return s.isValid ? {
1039
1091
  success: !0,
1040
1092
  manifest: t.manifest,
@@ -1044,7 +1096,7 @@ const qt = {
1044
1096
  success: !1,
1045
1097
  errors: s.errors
1046
1098
  };
1047
- }, ys = ({
1099
+ }, ct = ({
1048
1100
  manifest: e,
1049
1101
  builtFileInfos: t
1050
1102
  }) => {
@@ -1053,8 +1105,8 @@ const qt = {
1053
1105
  n,
1054
1106
  { fileFolder: i, checksum: a }
1055
1107
  ] of t.entries()) {
1056
- const r = W(R, n);
1057
- if (i === O.BuiltLogicFunction) {
1108
+ const r = J(O, n);
1109
+ if (i === D.BuiltLogicFunction) {
1058
1110
  const o = s.logicFunctions, l = o.findIndex(
1059
1111
  (c) => c.builtHandlerPath === r
1060
1112
  );
@@ -1067,7 +1119,7 @@ const qt = {
1067
1119
  )
1068
1120
  };
1069
1121
  }
1070
- if (i === O.PublicAsset) {
1122
+ if (i === D.PublicAsset) {
1071
1123
  const o = s.publicAssets, l = o.findIndex((c) => c.filePath === r);
1072
1124
  if (l === -1)
1073
1125
  continue;
@@ -1079,7 +1131,7 @@ const qt = {
1079
1131
  };
1080
1132
  continue;
1081
1133
  }
1082
- if (i === O.BuiltFrontComponent) {
1134
+ if (i === D.BuiltFrontComponent) {
1083
1135
  const o = s.frontComponents, l = o.findIndex(
1084
1136
  (u) => u.builtComponentPath === r
1085
1137
  ) ?? -1;
@@ -1097,15 +1149,15 @@ const qt = {
1097
1149
  )
1098
1150
  };
1099
1151
  }
1100
- i === O.Dependencies && (r === "package.json" && (s.application.packageJsonChecksum = a), r === "yarn.lock" && (s.application.yarnLockChecksum = a));
1152
+ i === D.Dependencies && (r === "package.json" && (s.application.packageJsonChecksum = a), r === "yarn.lock" && (s.application.yarnLockChecksum = a));
1101
1153
  }
1102
1154
  return s;
1103
- }, Is = async (e, t) => {
1104
- const s = h.join(e, R);
1105
- await U(s);
1106
- const n = h.join(s, "manifest.json");
1107
- return await xt(n, t), n;
1108
- }, x = async (e, t) => {
1155
+ }, lt = async (e, t) => {
1156
+ const s = I.join(e, O);
1157
+ await B(s);
1158
+ const n = I.join(s, "manifest.json");
1159
+ return await Wt(n, t), n;
1160
+ }, U = async (e, t) => {
1109
1161
  try {
1110
1162
  return await e();
1111
1163
  } catch (s) {
@@ -1117,12 +1169,12 @@ const qt = {
1117
1169
  }
1118
1170
  };
1119
1171
  }
1120
- }, M = {
1172
+ }, V = {
1121
1173
  AUTH_FAILED: "AUTH_FAILED",
1122
1174
  NO_REMOTES: "NO_REMOTES",
1123
1175
  REMOTE_NOT_FOUND: "REMOTE_NOT_FOUND",
1124
1176
  OAUTH_NOT_SUPPORTED: "OAUTH_NOT_SUPPORTED"
1125
- }, v = {
1177
+ }, m = {
1126
1178
  MANIFEST_NOT_FOUND: "MANIFEST_NOT_FOUND",
1127
1179
  MANIFEST_BUILD_FAILED: "MANIFEST_BUILD_FAILED",
1128
1180
  BUILD_FAILED: "BUILD_FAILED",
@@ -1132,23 +1184,23 @@ const qt = {
1132
1184
  SYNC_FAILED: "SYNC_FAILED",
1133
1185
  TYPECHECK_FAILED: "TYPECHECK_FAILED",
1134
1186
  DEPLOY_FAILED: "DEPLOY_FAILED"
1135
- }, K = {
1187
+ }, Q = {
1136
1188
  DOCKER_NOT_RUNNING: "DOCKER_NOT_RUNNING",
1137
1189
  CONTAINER_START_FAILED: "CONTAINER_START_FAILED",
1138
1190
  HEALTH_TIMEOUT: "HEALTH_TIMEOUT"
1139
- }, se = {
1191
+ }, ce = {
1140
1192
  FETCH_FUNCTIONS_FAILED: "FETCH_FUNCTIONS_FAILED",
1141
1193
  FUNCTION_NOT_FOUND: "FUNCTION_NOT_FOUND",
1142
1194
  EXECUTION_FAILED: "EXECUTION_FAILED"
1143
- }, vs = async (e) => {
1195
+ }, Ls = async (e) => {
1144
1196
  const { appPath: t, onProgress: s } = e;
1145
1197
  s?.("Building manifest...");
1146
- const n = await gs(t);
1198
+ const n = await ot(t);
1147
1199
  if (!n.success)
1148
1200
  return {
1149
1201
  success: !1,
1150
1202
  error: {
1151
- code: v.MANIFEST_BUILD_FAILED,
1203
+ code: m.MANIFEST_BUILD_FAILED,
1152
1204
  message: n.errors.join(`
1153
1205
  `)
1154
1206
  }
@@ -1157,73 +1209,73 @@ const qt = {
1157
1209
  for (const d of n.warnings)
1158
1210
  s?.(`⚠ ${d}`);
1159
1211
  s?.("Building application files...");
1160
- const r = await Vt({
1212
+ const r = await it({
1161
1213
  appPath: t,
1162
1214
  filePaths: a
1163
1215
  });
1164
1216
  s?.("Running typecheck...");
1165
- const o = await Ge(t);
1217
+ const o = await Te(t);
1166
1218
  if (o.length > 0) {
1167
1219
  const d = o.map(
1168
- (f) => `${f.file}(${f.line},${f.column + 1}): ${f.text}`
1220
+ (p) => `${p.file}(${p.line},${p.column + 1}): ${p.text}`
1169
1221
  );
1170
1222
  return {
1171
1223
  success: !1,
1172
1224
  error: {
1173
- code: v.TYPECHECK_FAILED,
1225
+ code: m.TYPECHECK_FAILED,
1174
1226
  message: `Typecheck failed:
1175
1227
  ${d.join(`
1176
1228
  `)}`
1177
1229
  }
1178
1230
  };
1179
1231
  }
1180
- const l = ys({
1232
+ const l = ct({
1181
1233
  manifest: i,
1182
1234
  builtFileInfos: r.builtFileInfos
1183
1235
  });
1184
- await Is(t, l);
1185
- const c = h.join(t, ".twenty", "output"), u = {
1236
+ await lt(t, l);
1237
+ const c = I.join(t, ".twenty", "output"), u = {
1186
1238
  outputDir: c,
1187
1239
  fileCount: r.builtFileInfos.size
1188
1240
  };
1189
1241
  if (e.tarball) {
1190
1242
  s?.("Packing tarball...");
1191
- const f = Ue("npm pack --pack-destination .", {
1243
+ const p = qe("npm pack --pack-destination .", {
1192
1244
  cwd: c,
1193
1245
  encoding: "utf-8"
1194
1246
  }).trim().split(`
1195
1247
  `).pop();
1196
- u.tarballPath = h.join(c, f);
1248
+ u.tarballPath = I.join(c, p);
1197
1249
  }
1198
1250
  return { success: !0, data: u };
1199
- }, As = (e) => x(() => vs(e), v.BUILD_FAILED), ws = C.join(qe.tmpdir(), ".twenty-sdk-test"), Ts = () => process.env.NODE_ENV === "test" ? C.join(ws, "config.json") : C.join(qe.homedir(), ".twenty", "config.json"), le = 1, b = "local", ie = class ie {
1200
- constructor() {
1201
- this.configPath = Ts();
1251
+ }, Os = (e) => U(() => Ls(e), m.BUILD_FAILED), Me = x.join(Dt.homedir(), ".twenty"), le = (e = !1) => e || process.env.NODE_ENV === "test" ? x.join(Me, "config.test.json") : x.join(Me, "config.json"), ge = 1, P = "local", pe = class pe {
1252
+ constructor(t) {
1253
+ this.configPath = t?.configPath ?? le();
1202
1254
  }
1203
1255
  static setActiveRemote(t) {
1204
- this.activeRemote = t ?? b;
1256
+ this.activeRemote = t ?? P;
1205
1257
  }
1206
1258
  static getActiveRemote() {
1207
1259
  return this.activeRemote;
1208
1260
  }
1209
1261
  getActiveRemoteName() {
1210
- return ie.getActiveRemote();
1262
+ return pe.getActiveRemote();
1211
1263
  }
1212
1264
  async readRawConfig() {
1213
- await Lt(this.configPath);
1214
- const t = await Q(this.configPath, "utf8"), s = JSON.parse(t || "{}");
1265
+ await qt(this.configPath);
1266
+ const t = await se(this.configPath, "utf8"), s = JSON.parse(t || "{}");
1215
1267
  return this.migrateConfigIfNeeded(s);
1216
1268
  }
1217
1269
  // TODO: Remove after 2026-04-30 — migrates legacy config format
1218
1270
  // (profiles, top-level keys, applicationAccessToken/applicationRefreshToken)
1219
1271
  // to the current format (remotes, accessToken/refreshToken)
1220
1272
  async migrateConfigIfNeeded(t) {
1221
- if (t.version === le)
1273
+ if (t.version === ge)
1222
1274
  return t;
1223
1275
  const s = "profiles" in t, n = "apiUrl" in t && !("remotes" in t);
1224
1276
  if (!s && !n)
1225
1277
  return t;
1226
- const i = { version: le }, a = (u) => typeof u == "string" ? u : void 0, r = (u) => ({
1278
+ const i = { version: ge }, a = (u) => typeof u == "string" ? u : void 0, r = (u) => ({
1227
1279
  apiUrl: a(u.apiUrl) ?? "",
1228
1280
  apiKey: a(u.apiKey),
1229
1281
  accessToken: a(u.accessToken) ?? a(u.applicationAccessToken),
@@ -1232,25 +1284,22 @@ ${d.join(`
1232
1284
  }), o = t.profiles ?? {};
1233
1285
  i.remotes = {};
1234
1286
  for (const [u, d] of Object.entries(o)) {
1235
- const f = u === "default" ? b : u;
1236
- i.remotes[f] = r(d);
1287
+ const p = u === "default" ? P : u;
1288
+ i.remotes[p] = r(d);
1237
1289
  }
1238
1290
  const l = t.remotes ?? {};
1239
1291
  for (const [u, d] of Object.entries(l)) {
1240
- const f = u === "default" ? b : u;
1241
- i.remotes[f] = d;
1292
+ const p = u === "default" ? P : u;
1293
+ i.remotes[p] = d;
1242
1294
  }
1243
- n && !i.remotes[b] && (i.remotes[b] = r(
1295
+ n && !i.remotes[P] && (i.remotes[P] = r(
1244
1296
  t
1245
1297
  ));
1246
1298
  const c = t.defaultWorkspace;
1247
- return c && (i.defaultRemote = c === "default" ? b : c), await U(C.dirname(this.configPath)), await j(this.configPath, JSON.stringify(i, null, 2)), i;
1299
+ return c && (i.defaultRemote = c === "default" ? P : c), await B(x.dirname(this.configPath)), await H(this.configPath, JSON.stringify(i, null, 2)), i;
1248
1300
  }
1249
1301
  async getConfig() {
1250
- return process.env.TWENTY_TOKEN && process.env.TWENTY_API_URL ? {
1251
- apiUrl: process.env.TWENTY_API_URL,
1252
- accessToken: process.env.TWENTY_TOKEN
1253
- } : this.getConfigForRemote(this.getActiveRemoteName());
1302
+ return this.getConfigForRemote(this.getActiveRemoteName());
1254
1303
  }
1255
1304
  async getConfigForRemote(t) {
1256
1305
  const s = this.getDefaultConfig();
@@ -1269,13 +1318,13 @@ ${d.join(`
1269
1318
  }
1270
1319
  async setConfig(t) {
1271
1320
  const s = await this.readRawConfig(), n = this.getActiveRemoteName();
1272
- s.version = le, s.remotes || (s.remotes = {});
1321
+ s.version = ge, s.remotes || (s.remotes = {});
1273
1322
  const i = s.remotes[n] || { apiUrl: "" };
1274
- s.remotes[n] = { ...i, ...t }, await U(C.dirname(this.configPath)), await j(this.configPath, JSON.stringify(s, null, 2));
1323
+ s.remotes[n] = { ...i, ...t }, await B(x.dirname(this.configPath)), await H(this.configPath, JSON.stringify(s, null, 2));
1275
1324
  }
1276
1325
  async clearConfig() {
1277
1326
  const t = await this.readRawConfig(), s = this.getActiveRemoteName();
1278
- t.remotes || (t.remotes = {}), t.remotes[s] && delete t.remotes[s], await U(C.dirname(this.configPath)), await j(this.configPath, JSON.stringify(t, null, 2));
1327
+ t.remotes || (t.remotes = {}), t.remotes[s] && delete t.remotes[s], await B(x.dirname(this.configPath)), await H(this.configPath, JSON.stringify(t, null, 2));
1279
1328
  }
1280
1329
  getDefaultConfig() {
1281
1330
  return {
@@ -1285,26 +1334,26 @@ ${d.join(`
1285
1334
  async getRemotes() {
1286
1335
  try {
1287
1336
  const t = await this.readRawConfig(), s = /* @__PURE__ */ new Set();
1288
- return s.add(b), t.remotes && Object.keys(t.remotes).forEach((n) => s.add(n)), Array.from(s).sort();
1337
+ return s.add(P), t.remotes && Object.keys(t.remotes).forEach((n) => s.add(n)), Array.from(s).sort();
1289
1338
  } catch {
1290
- return [b];
1339
+ return [P];
1291
1340
  }
1292
1341
  }
1293
1342
  async getDefaultRemote() {
1294
1343
  try {
1295
- return (await this.readRawConfig()).defaultRemote ?? b;
1344
+ return (await this.readRawConfig()).defaultRemote ?? P;
1296
1345
  } catch {
1297
- return b;
1346
+ return P;
1298
1347
  }
1299
1348
  }
1300
1349
  async setDefaultRemote(t) {
1301
1350
  const s = await this.readRawConfig();
1302
- s.defaultRemote = t, await U(C.dirname(this.configPath)), await j(this.configPath, JSON.stringify(s, null, 2));
1351
+ s.defaultRemote = t, await B(x.dirname(this.configPath)), await H(this.configPath, JSON.stringify(s, null, 2));
1303
1352
  }
1304
1353
  };
1305
- ie.activeRemote = b;
1306
- let y = ie;
1307
- class Fs {
1354
+ pe.activeRemote = P;
1355
+ let w = pe;
1356
+ class _s {
1308
1357
  constructor(t) {
1309
1358
  const {
1310
1359
  disableInterceptors: s = !1,
@@ -1312,7 +1361,7 @@ class Fs {
1312
1361
  token: i,
1313
1362
  skipAuth: a = !1
1314
1363
  } = t || {};
1315
- this.configService = new y(), this.tokenOverride = i, this.serverUrlOverride = n, this.client = N.create(), this.client.interceptors.request.use(async (r) => {
1364
+ this.configService = new w(), this.tokenOverride = i, this.serverUrlOverride = n, this.client = S.create(), this.client.interceptors.request.use(async (r) => {
1316
1365
  const o = await this.configService.getConfig();
1317
1366
  if (r.baseURL = this.serverUrlOverride ?? o.apiUrl, !r.headers.Authorization && !a) {
1318
1367
  const l = await this.resolveAuthToken();
@@ -1323,15 +1372,15 @@ class Fs {
1323
1372
  (r) => r,
1324
1373
  async (r) => {
1325
1374
  throw r.response?.status === 401 ? console.error(
1326
- te.red(
1375
+ oe.red(
1327
1376
  "Authentication failed. Run `yarn twenty remote add` to authenticate."
1328
1377
  )
1329
1378
  ) : r.response?.status === 403 ? console.error(
1330
- te.red(
1379
+ oe.red(
1331
1380
  "Access denied. Check your API key and workspace permissions."
1332
1381
  )
1333
1382
  ) : r.code === "ECONNREFUSED" && console.error(
1334
- te.red("Cannot connect to Twenty server. Is it running?")
1383
+ oe.red("Cannot connect to Twenty server. Is it running?")
1335
1384
  ), r;
1336
1385
  }
1337
1386
  );
@@ -1361,7 +1410,7 @@ class Fs {
1361
1410
  serverUp: s.status === 200
1362
1411
  };
1363
1412
  } catch (t) {
1364
- return N.isAxiosError(t) && t.response ? {
1413
+ return S.isAxiosError(t) && t.response ? {
1365
1414
  authValid: !1,
1366
1415
  serverUp: !0
1367
1416
  } : {
@@ -1375,7 +1424,7 @@ class Fs {
1375
1424
  if (!t.refreshToken || !t.oauthClientId)
1376
1425
  return null;
1377
1426
  try {
1378
- const s = await N.post(`${t.apiUrl}/oauth/token`, {
1427
+ const s = await S.post(`${t.apiUrl}/oauth/token`, {
1379
1428
  grant_type: "refresh_token",
1380
1429
  refresh_token: t.refreshToken,
1381
1430
  client_id: t.oauthClientId
@@ -1391,16 +1440,13 @@ class Fs {
1391
1440
  async resolveAuthToken() {
1392
1441
  if (this.tokenOverride)
1393
1442
  return this.tokenOverride;
1394
- const t = process.env.TWENTY_TOKEN;
1395
- if (t)
1396
- return t;
1397
- const s = await this.configService.getConfig(), n = s.accessToken;
1398
- if (n && this.isTokenExpired(n)) {
1399
- const i = await this.refreshToken();
1400
- if (i)
1401
- return i;
1443
+ const t = await this.configService.getConfig(), s = t.accessToken;
1444
+ if (s && this.isTokenExpired(s)) {
1445
+ const n = await this.refreshToken();
1446
+ if (n)
1447
+ return n;
1402
1448
  }
1403
- return n ?? s.apiKey;
1449
+ return s ?? t.apiKey;
1404
1450
  }
1405
1451
  isTokenExpired(t) {
1406
1452
  try {
@@ -1412,7 +1458,7 @@ class Fs {
1412
1458
  }
1413
1459
  }
1414
1460
  }
1415
- class bs {
1461
+ class Rs {
1416
1462
  constructor(t) {
1417
1463
  this.client = t;
1418
1464
  }
@@ -1591,7 +1637,7 @@ class bs {
1591
1637
  message: `Successfully synced application: ${t.application.displayName}`
1592
1638
  };
1593
1639
  } catch (s) {
1594
- if (N.isAxiosError(s) && s.response) {
1640
+ if (S.isAxiosError(s) && s.response) {
1595
1641
  const n = s.response.data?.errors;
1596
1642
  return Array.isArray(n) && n.length > 0 ? {
1597
1643
  success: !1,
@@ -1635,7 +1681,7 @@ class bs {
1635
1681
  message: "Successfully uninstalled application"
1636
1682
  };
1637
1683
  } catch (s) {
1638
- if (N.isAxiosError(s) && s.response)
1684
+ if (S.isAxiosError(s) && s.response)
1639
1685
  return {
1640
1686
  success: !1,
1641
1687
  error: s.response.data?.errors?.[0]?.message || s.message
@@ -1644,7 +1690,7 @@ class bs {
1644
1690
  }
1645
1691
  }
1646
1692
  }
1647
- const Es = {
1693
+ const xs = {
1648
1694
  ".jpg": "image/jpeg",
1649
1695
  ".jpeg": "image/jpeg",
1650
1696
  ".png": "image/png",
@@ -1677,11 +1723,11 @@ const Es = {
1677
1723
  ".tsx": "application/typescript",
1678
1724
  ".html": "text/html",
1679
1725
  ".css": "text/css"
1680
- }, Ns = (e) => {
1681
- const t = C.extname(e).toLowerCase();
1682
- return Es[t] || "application/octet-stream";
1726
+ }, Ds = (e) => {
1727
+ const t = x.extname(e).toLowerCase();
1728
+ return xs[t] || "application/octet-stream";
1683
1729
  };
1684
- class ks {
1730
+ class Us {
1685
1731
  constructor(t) {
1686
1732
  this.client = t;
1687
1733
  }
@@ -1728,7 +1774,7 @@ class ks {
1728
1774
  data: o.data.data.uploadAppTarball
1729
1775
  };
1730
1776
  } catch (n) {
1731
- return N.isAxiosError(n) && n.response ? {
1777
+ return S.isAxiosError(n) && n.response ? {
1732
1778
  success: !1,
1733
1779
  error: n.response.data?.errors?.[0]?.message || n.message
1734
1780
  } : {
@@ -1766,7 +1812,7 @@ class ks {
1766
1812
  data: n.data.data.installMarketplaceApp
1767
1813
  };
1768
1814
  } catch (s) {
1769
- return N.isAxiosError(s) && s.response ? {
1815
+ return S.isAxiosError(s) && s.response ? {
1770
1816
  success: !1,
1771
1817
  error: s.response.data?.errors?.[0]?.message || s.message
1772
1818
  } : {
@@ -1782,18 +1828,18 @@ class ks {
1782
1828
  applicationUniversalIdentifier: i
1783
1829
  }) {
1784
1830
  try {
1785
- const a = C.resolve(t);
1786
- if (!Ce.existsSync(a))
1831
+ const a = x.resolve(t);
1832
+ if (!Re.existsSync(a))
1787
1833
  return {
1788
1834
  success: !1,
1789
1835
  error: `File not found: ${a}`
1790
1836
  };
1791
- const r = C.basename(a), o = Ce.readFileSync(a), l = Ns(r), c = `
1837
+ const r = x.basename(a), o = Re.readFileSync(a), l = Ds(r), c = `
1792
1838
  mutation UploadApplicationFile($file: Upload!, $applicationUniversalIdentifier: String!, $fileFolder: FileFolder!, $filePath: String!) {
1793
1839
  uploadApplicationFile(file: $file, applicationUniversalIdentifier: $applicationUniversalIdentifier, fileFolder: $fileFolder, filePath: $filePath)
1794
1840
  { path }
1795
1841
  }
1796
- `, u = ht(n), d = JSON.stringify({
1842
+ `, u = Ct(n), d = JSON.stringify({
1797
1843
  query: c,
1798
1844
  variables: {
1799
1845
  file: null,
@@ -1801,28 +1847,28 @@ class ks {
1801
1847
  filePath: s,
1802
1848
  fileFolder: u
1803
1849
  }
1804
- }), f = JSON.stringify({
1850
+ }), p = JSON.stringify({
1805
1851
  0: ["variables.file"]
1806
- }), I = new FormData();
1807
- I.append("operations", d), I.append("map", f), I.append(
1852
+ }), h = new FormData();
1853
+ h.append("operations", d), h.append("map", p), h.append(
1808
1854
  "0",
1809
1855
  new Blob([new Uint8Array(o)], { type: l }),
1810
1856
  r
1811
1857
  );
1812
- const w = await this.client.post(
1858
+ const v = await this.client.post(
1813
1859
  "/metadata",
1814
- I
1860
+ h
1815
1861
  );
1816
- return w.data.errors ? {
1862
+ return v.data.errors ? {
1817
1863
  success: !1,
1818
- error: w.data.errors[0]?.message || "Failed to upload file"
1864
+ error: v.data.errors[0]?.message || "Failed to upload file"
1819
1865
  } : {
1820
1866
  success: !0,
1821
- data: w.data.data.uploadApplicationFile,
1867
+ data: v.data.data.uploadApplicationFile,
1822
1868
  message: `Successfully uploaded ${r}`
1823
1869
  };
1824
1870
  } catch (a) {
1825
- return N.isAxiosError(a) && a.response ? {
1871
+ return S.isAxiosError(a) && a.response ? {
1826
1872
  success: !1,
1827
1873
  error: a.response.data?.errors?.[0]?.message || a.message
1828
1874
  } : {
@@ -1832,7 +1878,7 @@ class ks {
1832
1878
  }
1833
1879
  }
1834
1880
  }
1835
- class Cs {
1881
+ class $s {
1836
1882
  constructor(t) {
1837
1883
  this.apiClient = t;
1838
1884
  }
@@ -1923,7 +1969,7 @@ class Cs {
1923
1969
  functionUniversalIdentifier: s,
1924
1970
  functionName: n
1925
1971
  }) {
1926
- const i = await this.apiClient.configService.getConfig(), a = this.apiClient.serverUrlOverride ?? i.apiUrl, r = Ft({
1972
+ const i = await this.apiClient.configService.getConfig(), a = this.apiClient.serverUrlOverride ?? i.apiUrl, r = $t({
1927
1973
  url: a + "/metadata",
1928
1974
  headers: async () => {
1929
1975
  const c = await this.apiClient.resolveAuthToken();
@@ -1959,7 +2005,7 @@ class Cs {
1959
2005
  );
1960
2006
  }
1961
2007
  }
1962
- class Os {
2008
+ class js {
1963
2009
  constructor(t) {
1964
2010
  this.client = t;
1965
2011
  }
@@ -1971,7 +2017,7 @@ class Os {
1971
2017
  }
1972
2018
  async introspectEndpoint(t, s) {
1973
2019
  try {
1974
- const n = bt(), i = {
2020
+ const n = jt(), i = {
1975
2021
  "Content-Type": "application/json",
1976
2022
  Accept: "*/*"
1977
2023
  };
@@ -1988,14 +2034,14 @@ class Os {
1988
2034
  success: !1,
1989
2035
  error: `GraphQL introspection errors: ${JSON.stringify(a.data.errors)}`
1990
2036
  };
1991
- const r = Et(a.data.data);
2037
+ const r = Mt(a.data.data);
1992
2038
  return {
1993
2039
  success: !0,
1994
- data: Nt(r),
2040
+ data: Bt(r),
1995
2041
  message: `Successfully loaded schema from ${t}`
1996
2042
  };
1997
2043
  } catch (n) {
1998
- if (N.isAxiosError(n) && n.response)
2044
+ if (S.isAxiosError(n) && n.response)
1999
2045
  return {
2000
2046
  success: !1,
2001
2047
  error: n.response.data?.errors?.[0]?.message || `Failed to load schema from ${t}`
@@ -2004,9 +2050,9 @@ class Os {
2004
2050
  }
2005
2051
  }
2006
2052
  }
2007
- class z {
2053
+ class j {
2008
2054
  constructor(t) {
2009
- this.apiClient = new Fs(t), this.applicationApi = new bs(this.apiClient.client), this.schemaApi = new Os(this.apiClient.client), this.logicFunctionApi = new Cs(this.apiClient), this.fileApi = new ks(this.apiClient.client);
2055
+ this.apiClient = new _s(t), this.applicationApi = new Rs(this.apiClient.client), this.schemaApi = new js(this.apiClient.client), this.logicFunctionApi = new $s(this.apiClient), this.fileApi = new Us(this.apiClient.client);
2010
2056
  }
2011
2057
  validateAuth() {
2012
2058
  return this.apiClient.validateAuth();
@@ -2059,10 +2105,10 @@ class z {
2059
2105
  return this.fileApi.uploadFile(...t);
2060
2106
  }
2061
2107
  }
2062
- const _s = async (e) => {
2108
+ const Ms = async (e) => {
2063
2109
  const { tarballPath: t, onProgress: s } = e;
2064
- e.remote && y.setActiveRemote(e.remote), s?.(`Uploading ${t}...`);
2065
- const n = it.readFileSync(t), a = await new z({
2110
+ e.remote && w.setActiveRemote(e.remote), s?.(`Uploading ${t}...`);
2111
+ const n = yt.readFileSync(t), a = await new j({
2066
2112
  serverUrl: e.serverUrl,
2067
2113
  token: e.token
2068
2114
  }).uploadAppTarball({ tarballBuffer: n });
@@ -2074,11 +2120,36 @@ const _s = async (e) => {
2074
2120
  } : {
2075
2121
  success: !1,
2076
2122
  error: {
2077
- code: v.DEPLOY_FAILED,
2123
+ code: m.DEPLOY_FAILED,
2078
2124
  message: `Upload failed: ${a.error}`
2079
2125
  }
2080
2126
  };
2081
- }, On = (e) => x(() => _s(e), v.DEPLOY_FAILED), Ls = [2020, 3e3], et = async (e) => {
2127
+ }, Yn = (e) => U(() => Ms(e), m.DEPLOY_FAILED);
2128
+ class Bs {
2129
+ constructor(t) {
2130
+ this.apiService = new j({
2131
+ disableInterceptors: !0,
2132
+ serverUrl: t?.serverUrl,
2133
+ skipAuth: !0,
2134
+ token: t?.token
2135
+ });
2136
+ }
2137
+ async generateCoreClient({
2138
+ appPath: t,
2139
+ authToken: s
2140
+ }) {
2141
+ const n = await this.apiService.getSchema({ authToken: s });
2142
+ if (!n.success)
2143
+ throw new Error(
2144
+ `Failed to introspect core schema: ${JSON.stringify(n.error)}`
2145
+ );
2146
+ await Rt({
2147
+ packageRoot: R(t, "node_modules", "twenty-client-sdk"),
2148
+ schema: n.data
2149
+ });
2150
+ }
2151
+ }
2152
+ const Hs = [2020, 3e3], ut = async (e) => {
2082
2153
  const t = new AbortController(), s = setTimeout(() => t.abort(), 2e3);
2083
2154
  try {
2084
2155
  return (await (await fetch(`http://localhost:${e}/healthz`, {
@@ -2089,31 +2160,104 @@ const _s = async (e) => {
2089
2160
  } finally {
2090
2161
  clearTimeout(s);
2091
2162
  }
2092
- }, Ss = async (e) => {
2093
- const t = e ? [e] : Ls;
2163
+ }, Vs = async (e) => {
2164
+ const t = e ? [e] : Hs;
2094
2165
  for (const s of t)
2095
- if (await et(s))
2166
+ if (await ut(s))
2096
2167
  return `http://localhost:${s}`;
2097
2168
  return null;
2098
- }, ye = async (e) => {
2099
- const t = h.join(e, R);
2100
- await U(t);
2101
- const s = h.join(t, "manifest.json");
2102
- if (!await ge(s)) {
2103
- const { manifest: n } = await Qe(e);
2169
+ }, Ys = (e) => {
2170
+ if (!e || typeof e != "object")
2171
+ return null;
2172
+ const s = e.extensions;
2173
+ if (!s?.errors || !s?.summary)
2174
+ return null;
2175
+ const n = [], i = s.summary.totalErrors;
2176
+ n.push({
2177
+ message: `Sync failed with ${i} error${i !== 1 ? "s" : ""}`,
2178
+ status: "error"
2179
+ });
2180
+ for (const [a, r] of Object.entries(s.errors)) {
2181
+ const o = s.summary[a] ?? r.length;
2182
+ n.push({
2183
+ message: `${a}: ${o} error${o !== 1 ? "s" : ""}`,
2184
+ status: "error"
2185
+ });
2186
+ let l = 1;
2187
+ for (const c of r) {
2188
+ const u = c.flatEntityMinimalInformation?.universalIdentifier;
2189
+ for (const d of c.errors) {
2190
+ const p = [];
2191
+ d.value && p.push(`value: ${d.value}`), u && p.push(`universalIdentifier: ${u}`);
2192
+ const h = p.length > 0 ? ` (${p.join(", ")})` : "";
2193
+ n.push({
2194
+ message: ` ${l}. ${d.code}: ${d.message}${h}`,
2195
+ status: "error"
2196
+ }), l++;
2197
+ }
2198
+ }
2199
+ }
2200
+ return n;
2201
+ }, re = (e) => {
2202
+ try {
2203
+ const t = JSON.stringify(e, null, 2);
2204
+ return t === "{}" || t === void 0 ? String(e) : t;
2205
+ } catch {
2206
+ return String(e);
2207
+ }
2208
+ }, z = (e) => {
2209
+ if (typeof e == "string")
2210
+ return e;
2211
+ if (S.isAxiosError(e)) {
2212
+ const t = [], s = e.response?.status, n = e.response?.statusText;
2213
+ s && t.push(`HTTP ${s}${n ? ` ${n}` : ""}`);
2214
+ const i = e.response?.data, a = i?.errors;
2215
+ if (Array.isArray(a) && a.length > 0) {
2216
+ const r = a.map((o) => typeof o.message == "string" ? o.message : re(o)).join("; ");
2217
+ t.push(r);
2218
+ } else i?.message ? t.push(
2219
+ typeof i.message == "string" ? i.message : re(i.message)
2220
+ ) : i ? t.push(re(i)) : e.message && t.push(e.message);
2221
+ return e.code && t.push(`(${e.code})`), t.join(" - ") || "Unknown Axios error";
2222
+ }
2223
+ return e instanceof Error ? e.message || e.toString() : re(e);
2224
+ };
2225
+ class qs {
2226
+ constructor(t) {
2227
+ this.apiService = new j(), this.applicationUniversalIdentifier = t.applicationUniversalIdentifier, this.appPath = t.appPath;
2228
+ }
2229
+ async uploadFile({
2230
+ builtPath: t,
2231
+ fileFolder: s
2232
+ }) {
2233
+ const n = J(O, t);
2234
+ return await this.apiService.uploadFile({
2235
+ filePath: I.join(this.appPath, t),
2236
+ builtHandlerPath: n,
2237
+ fileFolder: s,
2238
+ applicationUniversalIdentifier: this.applicationUniversalIdentifier
2239
+ });
2240
+ }
2241
+ }
2242
+ const Ee = async (e) => {
2243
+ const t = I.join(e, O);
2244
+ await B(t);
2245
+ const s = I.join(t, "manifest.json");
2246
+ if (!await Fe(s)) {
2247
+ const { manifest: n } = await at(e);
2104
2248
  return n;
2105
2249
  }
2106
- return await Rt(s);
2107
- }, Ps = (e, t) => t.logicFunctions.some(
2250
+ return await Gt(s);
2251
+ }, zs = (e, t) => t.logicFunctions.some(
2108
2252
  (s) => s.universalIdentifier === e.universalIdentifier
2109
- ), Pe = (e) => "preInstall" in e ? "pre install" : "postInstall" in e ? "post install" : "functionUniversalIdentifier" in e ? e.functionUniversalIdentifier : "functionName" in e ? e.functionName : "unknown", Rs = async (e) => {
2110
- e.remote && y.setActiveRemote(e.remote);
2111
- const t = new z(), s = await ye(e.appPath);
2253
+ ), Be = (e) => "postInstall" in e ? "post install" : "preInstall" in e ? "pre install" : "functionUniversalIdentifier" in e ? e.functionUniversalIdentifier : "functionName" in e ? e.functionName : "unknown", Js = async (e) => {
2254
+ e.remote && w.setActiveRemote(e.remote);
2255
+ const t = new j(), s = await Ee(e.appPath);
2112
2256
  if (!s)
2113
2257
  return {
2114
2258
  success: !1,
2115
2259
  error: {
2116
- code: v.MANIFEST_NOT_FOUND,
2260
+ code: m.MANIFEST_NOT_FOUND,
2117
2261
  message: "Manifest not found. Run `build` or `dev` first."
2118
2262
  }
2119
2263
  };
@@ -2123,22 +2267,22 @@ const _s = async (e) => {
2123
2267
  return {
2124
2268
  success: !1,
2125
2269
  error: {
2126
- code: se.FETCH_FUNCTIONS_FAILED,
2270
+ code: ce.FETCH_FUNCTIONS_FAILED,
2127
2271
  message: o
2128
2272
  }
2129
2273
  };
2130
2274
  }
2131
2275
  const i = n.data.filter(
2132
- (o) => o.universalIdentifier && Ps(o, s)
2133
- ), a = i.find((o) => "preInstall" in e && e.preInstall ? o.universalIdentifier === s.application.preInstallLogicFunctionUniversalIdentifier : "postInstall" in e && e.postInstall ? o.universalIdentifier === s.application.postInstallLogicFunctionUniversalIdentifier : "functionUniversalIdentifier" in e ? o.universalIdentifier === e.functionUniversalIdentifier : "functionName" in e ? o.name === e.functionName : !1);
2276
+ (o) => o.universalIdentifier && zs(o, s)
2277
+ ), a = i.find((o) => "postInstall" in e && e.postInstall ? o.universalIdentifier === s.application.postInstallLogicFunction?.universalIdentifier : "preInstall" in e && e.preInstall ? o.universalIdentifier === s.application.preInstallLogicFunction?.universalIdentifier : "functionUniversalIdentifier" in e ? o.universalIdentifier === e.functionUniversalIdentifier : "functionName" in e ? o.name === e.functionName : !1);
2134
2278
  if (!a)
2135
2279
  return {
2136
2280
  success: !1,
2137
2281
  error: {
2138
- code: se.FUNCTION_NOT_FOUND,
2139
- message: `Function "${Pe(e)}" not found in application.`,
2282
+ code: ce.FUNCTION_NOT_FOUND,
2283
+ message: `Function "${Be(e)}" not found in application.`,
2140
2284
  details: {
2141
- identifier: Pe(e),
2285
+ identifier: Be(e),
2142
2286
  availableFunctions: i.map((o) => ({
2143
2287
  name: o.name,
2144
2288
  universalIdentifier: o.universalIdentifier
@@ -2155,7 +2299,7 @@ const _s = async (e) => {
2155
2299
  return {
2156
2300
  success: !1,
2157
2301
  error: {
2158
- code: se.EXECUTION_FAILED,
2302
+ code: ce.EXECUTION_FAILED,
2159
2303
  message: o
2160
2304
  }
2161
2305
  };
@@ -2167,17 +2311,17 @@ const _s = async (e) => {
2167
2311
  ...r.data
2168
2312
  }
2169
2313
  };
2170
- }, _n = (e) => x(
2171
- () => Rs(e),
2172
- se.EXECUTION_FAILED
2173
- ), xs = async (e) => {
2174
- e.remote && y.setActiveRemote(e.remote);
2175
- const t = new z(), s = await ye(e.appPath);
2314
+ }, qn = (e) => U(
2315
+ () => Js(e),
2316
+ ce.EXECUTION_FAILED
2317
+ ), Gs = async (e) => {
2318
+ e.remote && w.setActiveRemote(e.remote);
2319
+ const t = new j(), s = await Ee(e.appPath);
2176
2320
  if (!s)
2177
2321
  return {
2178
2322
  success: !1,
2179
2323
  error: {
2180
- code: v.MANIFEST_NOT_FOUND,
2324
+ code: m.MANIFEST_NOT_FOUND,
2181
2325
  message: "Manifest not found. Run `build` or `dev` first."
2182
2326
  }
2183
2327
  };
@@ -2189,14 +2333,14 @@ const _s = async (e) => {
2189
2333
  return {
2190
2334
  success: !1,
2191
2335
  error: {
2192
- code: v.INSTALL_FAILED,
2336
+ code: m.INSTALL_FAILED,
2193
2337
  message: i
2194
2338
  }
2195
2339
  };
2196
2340
  }
2197
2341
  return { success: !0, data: void 0 };
2198
- }, Ln = (e) => x(() => xs(e), v.INSTALL_FAILED), Ds = async (e) => {
2199
- const { appPath: t, onProgress: s } = e, n = await As({
2342
+ }, zn = (e) => U(() => Gs(e), m.INSTALL_FAILED), Ws = async (e) => {
2343
+ const { appPath: t, onProgress: s } = e, n = await Os({
2200
2344
  appPath: t,
2201
2345
  onProgress: s
2202
2346
  });
@@ -2205,7 +2349,7 @@ const _s = async (e) => {
2205
2349
  s?.("Publishing to npm...");
2206
2350
  const i = e.npmTag ? ` --tag ${e.npmTag}` : "";
2207
2351
  try {
2208
- Ue(`npm publish${i}`, {
2352
+ qe(`npm publish${i}`, {
2209
2353
  cwd: n.data.outputDir,
2210
2354
  stdio: "inherit"
2211
2355
  });
@@ -2213,34 +2357,34 @@ const _s = async (e) => {
2213
2357
  return {
2214
2358
  success: !1,
2215
2359
  error: {
2216
- code: v.PUBLISH_FAILED,
2360
+ code: m.PUBLISH_FAILED,
2217
2361
  message: "npm publish failed"
2218
2362
  }
2219
2363
  };
2220
2364
  }
2221
2365
  return { success: !0, data: { target: "npm" } };
2222
- }, Sn = (e) => x(() => Ds(e), v.PUBLISH_FAILED), Us = async (e) => {
2366
+ }, Jn = (e) => U(() => Ws(e), m.PUBLISH_FAILED), Ks = async (e) => {
2223
2367
  const { apiKey: t, apiUrl: s, remote: n } = e;
2224
- n && y.setActiveRemote(n);
2225
- const i = new y();
2368
+ n && w.setActiveRemote(n);
2369
+ const i = new w();
2226
2370
  return await i.setConfig({
2227
2371
  apiUrl: s,
2228
2372
  apiKey: t,
2229
2373
  accessToken: void 0,
2230
2374
  refreshToken: void 0,
2231
2375
  oauthClientId: void 0
2232
- }), (await new z().validateAuth()).authValid ? { success: !0, data: void 0 } : (await i.clearConfig(), {
2376
+ }), (await new j().validateAuth()).authValid ? { success: !0, data: void 0 } : (await i.clearConfig(), {
2233
2377
  success: !1,
2234
2378
  error: {
2235
- code: M.AUTH_FAILED,
2379
+ code: V.AUTH_FAILED,
2236
2380
  message: "Authentication failed. Please check your credentials."
2237
2381
  }
2238
2382
  });
2239
- }, Pn = (e) => x(() => Us(e), M.AUTH_FAILED), js = `<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 96 96">
2383
+ }, Gn = (e) => U(() => Ks(e), V.AUTH_FAILED), Xs = `<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 96 96">
2240
2384
  <rect width="96" height="96" rx="11.3" fill="#000"/>
2241
2385
  <path fill="#fff" d="M19.25 35.75c0-5.25 4.26-9.5 9.5-9.5h18.29c.27 0 .51.16.63.4.11.25.06.54-.12.75l-4.01 4.35c-.7.76-1.68 1.2-2.71 1.2H28.8c-1.57 0-2.85 1.27-2.85 2.85v7.18c0 .93-.75 1.67-1.68 1.67h-3.34c-.93 0-1.67-.75-1.67-1.67v-7.23z"/>
2242
2386
  <path fill="#fff" d="M76.15 60.25c0 5.25-4.26 9.5-9.5 9.5h-7.77c-5.25 0-9.5-4.25-9.5-9.5V46.65c0-.93.35-1.82.98-2.5l4.53-4.92c.19-.2.49-.27.75-.17.26.11.44.36.44.64v20.52c0 1.57 1.28 2.85 2.85 2.85h7.68c1.57 0 2.85-1.28 2.85-2.85V35.8c0-1.57-1.28-2.85-2.85-2.85h-8.93c-1.02 0-2 .43-2.7 1.18L28.35 63.06h16c.92 0 1.67.75 1.67 1.68v3.34c0 .93-.75 1.67-1.67 1.67H22.79c-1.95 0-3.55-1.59-3.55-3.54v-1.77c0-.89.33-1.75.94-2.4l29.86-32.43c1.98-2.15 4.75-3.36 7.67-3.36h8.93c5.25 0 9.5 4.25 9.5 9.5v24.5z"/>
2243
- </svg>`, tt = ({
2387
+ </svg>`, pt = ({
2244
2388
  title: e,
2245
2389
  message: t,
2246
2390
  isSuccess: s
@@ -2303,7 +2447,7 @@ const _s = async (e) => {
2303
2447
  </head>
2304
2448
  <body>
2305
2449
  <div class="card">
2306
- <div class="logo">${js}</div>
2450
+ <div class="logo">${Xs}</div>
2307
2451
  <div class="icon ${s ? "icon-success" : "icon-error"}">
2308
2452
  ${s ? '<svg viewBox="0 0 24 24" fill="none" stroke="#22c55e" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>' : '<svg viewBox="0 0 24 24" fill="none" stroke="#ef4444" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>'}
2309
2453
  </div>
@@ -2311,35 +2455,35 @@ const _s = async (e) => {
2311
2455
  <p>${t}</p>
2312
2456
  </div>
2313
2457
  </body>
2314
- </html>`, Ms = tt({
2458
+ </html>`, Qs = pt({
2315
2459
  title: "Authentication successful",
2316
2460
  message: "You can close this window and return to the terminal.",
2317
2461
  isSuccess: !0
2318
- }), $s = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;"), Bs = (e) => tt({
2462
+ }), Zs = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;"), en = (e) => pt({
2319
2463
  title: "Authentication failed",
2320
- message: `${$s(e)}<br>Please return to the terminal and try again.`,
2464
+ message: `${Zs(e)}<br>Please return to the terminal and try again.`,
2321
2465
  isSuccess: !1
2322
- }), Hs = (e) => {
2466
+ }), tn = (e) => {
2323
2467
  const t = e?.timeoutMs ?? 12e4;
2324
2468
  return new Promise((s, n) => {
2325
2469
  let i, a;
2326
2470
  const r = new Promise((l) => {
2327
2471
  i = l;
2328
- }), o = At.createServer((l, c) => {
2472
+ }), o = wt.createServer((l, c) => {
2329
2473
  const u = new URL(l.url ?? "/", "http://127.0.0.1");
2330
2474
  if (u.pathname !== "/callback") {
2331
2475
  c.writeHead(404), c.end("Not found");
2332
2476
  return;
2333
2477
  }
2334
- const d = u.searchParams.get("code"), f = u.searchParams.get("error"), I = {
2478
+ const d = u.searchParams.get("code"), p = u.searchParams.get("error"), h = {
2335
2479
  "Content-Type": "text/html",
2336
2480
  Connection: "close"
2337
2481
  };
2338
2482
  if (d)
2339
- c.writeHead(200, I), c.end(Ms), i({ success: !0, code: d });
2483
+ c.writeHead(200, h), c.end(Qs), i({ success: !0, code: d });
2340
2484
  else {
2341
- const w = f ?? u.searchParams.get("error_description") ?? "Unknown error";
2342
- c.writeHead(200, I), c.end(Bs(w)), i({ success: !1, error: w });
2485
+ const v = p ?? u.searchParams.get("error_description") ?? "Unknown error";
2486
+ c.writeHead(200, h), c.end(en(v)), i({ success: !1, error: v });
2343
2487
  }
2344
2488
  });
2345
2489
  o.listen(0, "127.0.0.1", () => {
@@ -2366,7 +2510,7 @@ const _s = async (e) => {
2366
2510
  });
2367
2511
  }), o.on("error", n);
2368
2512
  });
2369
- }, Vs = (e) => {
2513
+ }, sn = (e) => {
2370
2514
  try {
2371
2515
  new URL(e);
2372
2516
  } catch {
@@ -2374,25 +2518,25 @@ const _s = async (e) => {
2374
2518
  }
2375
2519
  const [t, s] = process.platform === "darwin" ? ["open", [e]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", e]] : ["xdg-open", [e]];
2376
2520
  return new Promise((n) => {
2377
- Ve(t, s, (i) => {
2521
+ ze(t, s, (i) => {
2378
2522
  n(!i);
2379
2523
  });
2380
2524
  });
2381
- }, qs = () => {
2382
- const e = _e.randomBytes(32).toString("base64url"), t = _e.createHash("sha256").update(e).digest("base64url");
2525
+ }, nn = () => {
2526
+ const e = xe.randomBytes(32).toString("base64url"), t = xe.createHash("sha256").update(e).digest("base64url");
2383
2527
  return { codeVerifier: e, codeChallenge: t };
2384
- }, Ys = async (e) => {
2528
+ }, an = async (e) => {
2385
2529
  const { apiUrl: t, remote: s, timeoutMs: n } = e;
2386
- s && y.setActiveRemote(s);
2387
- const i = new y(), a = `${t}/.well-known/oauth-authorization-server`;
2530
+ s && w.setActiveRemote(s);
2531
+ const i = new w(), a = `${t}/.well-known/oauth-authorization-server`;
2388
2532
  let r;
2389
2533
  try {
2390
- r = (await N.get(a)).data;
2534
+ r = (await S.get(a)).data;
2391
2535
  } catch {
2392
2536
  return {
2393
2537
  success: !1,
2394
2538
  error: {
2395
- code: M.OAUTH_NOT_SUPPORTED,
2539
+ code: V.OAUTH_NOT_SUPPORTED,
2396
2540
  message: `Could not reach the OAuth discovery endpoint at ${a}. Ensure the server is running. Use --api-key instead.`
2397
2541
  }
2398
2542
  };
@@ -2401,216 +2545,394 @@ const _s = async (e) => {
2401
2545
  return {
2402
2546
  success: !1,
2403
2547
  error: {
2404
- code: M.OAUTH_NOT_SUPPORTED,
2548
+ code: V.OAUTH_NOT_SUPPORTED,
2405
2549
  message: "Server does not expose a CLI client ID. Ensure the server is up to date. Use --api-key instead."
2406
2550
  }
2407
2551
  };
2408
- const o = r.cli_client_id, { codeVerifier: l, codeChallenge: c } = qs(), u = await Hs({ timeoutMs: n });
2552
+ const o = r.cli_client_id, { codeVerifier: l, codeChallenge: c } = nn(), u = await tn({ timeoutMs: n });
2409
2553
  try {
2410
2554
  const d = new URL(r.authorization_endpoint);
2411
- d.searchParams.set("clientId", o), d.searchParams.set("codeChallenge", c), d.searchParams.set("redirectUrl", u.callbackUrl), await Vs(d.toString()) || console.log(
2555
+ d.searchParams.set("clientId", o), d.searchParams.set("codeChallenge", c), d.searchParams.set("redirectUrl", u.callbackUrl), await sn(d.toString()) || console.log(
2412
2556
  `
2413
2557
  Open this URL in your browser to authenticate:
2414
2558
  ${d.toString()}
2415
2559
  `
2416
2560
  );
2417
- const I = await u.waitForCallback();
2418
- if (!I.success)
2561
+ const h = await u.waitForCallback();
2562
+ if (!h.success)
2419
2563
  return {
2420
2564
  success: !1,
2421
2565
  error: {
2422
- code: M.AUTH_FAILED,
2423
- message: I.error
2566
+ code: V.AUTH_FAILED,
2567
+ message: h.error
2424
2568
  }
2425
2569
  };
2426
- const w = await N.post(r.token_endpoint, {
2570
+ const v = await S.post(r.token_endpoint, {
2427
2571
  grant_type: "authorization_code",
2428
- code: I.code,
2572
+ code: h.code,
2429
2573
  code_verifier: l,
2430
2574
  redirect_uri: u.callbackUrl,
2431
2575
  client_id: o
2432
- }), { access_token: _, refresh_token: L } = w.data;
2576
+ }), { access_token: T, refresh_token: E } = v.data;
2433
2577
  return await i.setConfig({
2434
2578
  apiUrl: t,
2435
- accessToken: _,
2436
- refreshToken: L,
2579
+ accessToken: T,
2580
+ refreshToken: E,
2437
2581
  oauthClientId: o
2438
- }), (await new z({
2582
+ }), (await new j({
2439
2583
  serverUrl: t,
2440
- token: _
2584
+ token: T
2441
2585
  }).validateAuth()).authValid ? { success: !0, data: void 0 } : (await i.clearConfig(), {
2442
2586
  success: !1,
2443
2587
  error: {
2444
- code: M.AUTH_FAILED,
2588
+ code: V.AUTH_FAILED,
2445
2589
  message: "OAuth tokens received but authentication validation failed."
2446
2590
  }
2447
2591
  });
2448
2592
  } finally {
2449
2593
  u.close();
2450
2594
  }
2451
- }, Rn = (e) => x(() => Ys(e), M.AUTH_FAILED), Y = "twenty-app-dev", zs = "twentycrm/twenty-app-dev:latest", de = 2020, Js = () => {
2595
+ }, Wn = (e) => U(() => an(e), V.AUTH_FAILED), de = "twenty-app-dev", dt = "twenty-app-dev-test", rn = "twentycrm/twenty-app-dev:latest", ft = 2020, mt = 2021, on = (e = de) => {
2452
2596
  try {
2453
- return Z(
2454
- `docker inspect -f '{{.State.Running}}' ${Y}`,
2597
+ return te(
2598
+ `docker inspect -f '{{.State.Running}}' ${e}`,
2455
2599
  { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] }
2456
2600
  ).trim() === "true";
2457
2601
  } catch {
2458
2602
  return !1;
2459
2603
  }
2460
- }, Re = () => {
2604
+ }, He = (e = de) => {
2605
+ const t = e === dt ? mt : ft;
2461
2606
  try {
2462
- const t = Z(
2463
- `docker inspect -f '{{range .Config.Env}}{{println .}}{{end}}' ${Y}`,
2607
+ const n = te(
2608
+ `docker inspect -f '{{range .Config.Env}}{{println .}}{{end}}' ${e}`,
2464
2609
  { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] }
2465
2610
  ).match(/^NODE_PORT=(\d+)$/m);
2466
- return t ? parseInt(t[1], 10) : de;
2611
+ return n ? parseInt(n[1], 10) : t;
2467
2612
  } catch {
2468
- return de;
2613
+ return t;
2469
2614
  }
2470
- }, Gs = () => {
2615
+ }, cn = (e = de) => {
2471
2616
  try {
2472
- return Z(`docker inspect ${Y}`, {
2617
+ return te(`docker inspect ${e}`, {
2473
2618
  stdio: ["pipe", "pipe", "ignore"]
2474
2619
  }), !0;
2475
2620
  } catch {
2476
2621
  return !1;
2477
2622
  }
2478
- }, Ws = () => {
2623
+ }, ln = () => {
2479
2624
  try {
2480
- return Z("docker info", { stdio: "ignore" }), !0;
2625
+ return te("docker info", { stdio: "ignore" }), !0;
2481
2626
  } catch {
2482
2627
  return !1;
2483
2628
  }
2484
- }, Ks = 2e3, Xs = 180 * 1e3, xe = "==> START ", Qs = "==> DONE", De = async (e) => {
2485
- const t = Date.now(), s = (l) => process.stdout.write(te.gray(l)), n = yt(
2629
+ }, un = 2e3, pn = 180 * 1e3, Ve = "==> START ", dn = "==> DONE", Ye = async (e, t) => {
2630
+ const s = Date.now(), n = (c) => process.stdout.write(oe.gray(c)), i = Tt(
2486
2631
  "docker",
2487
- ["logs", "-f", "--since", "1s", Y],
2632
+ ["logs", "-f", "--since", "1s", t],
2488
2633
  { stdio: ["ignore", "pipe", "pipe"] }
2489
2634
  );
2490
- n.on("error", () => {
2635
+ i.on("error", () => {
2491
2636
  });
2492
- let i = !1;
2493
- const a = (l) => {
2494
- const c = l.trim(), u = c.indexOf(xe), d = c.indexOf(Qs);
2495
- if (u !== -1) {
2496
- i && s(`Done
2637
+ let a = !1;
2638
+ const r = (c) => {
2639
+ const u = c.trim(), d = u.indexOf(Ve), p = u.indexOf(dn);
2640
+ if (d !== -1) {
2641
+ a && n(`Done
2497
2642
  `);
2498
- const f = c.slice(u + xe.length);
2499
- s(`==> ${f}... `), i = !0;
2500
- } else d !== -1 && i && (s(`Done
2501
- `), i = !1);
2643
+ const h = u.slice(d + Ve.length);
2644
+ n(`==> ${h}... `), a = !0;
2645
+ } else p !== -1 && a && (n(`Done
2646
+ `), a = !1);
2502
2647
  };
2503
- let r = "";
2504
- const o = (l) => {
2505
- r += l.toString();
2506
- const c = r.split(`
2648
+ let o = "";
2649
+ const l = (c) => {
2650
+ o += c.toString();
2651
+ const u = o.split(`
2507
2652
  `);
2508
- r = c.pop() ?? "", c.forEach(a);
2653
+ o = u.pop() ?? "", u.forEach(r);
2509
2654
  };
2510
- n.stdout?.on("data", o), n.stderr?.on("data", o);
2655
+ i.stdout?.on("data", l), i.stderr?.on("data", l);
2511
2656
  try {
2512
- for (; Date.now() - t < Xs; ) {
2513
- if (await et(e))
2514
- return i && s(`Done
2657
+ for (; Date.now() - s < pn; ) {
2658
+ if (await ut(e))
2659
+ return a && n(`Done
2515
2660
  `), !0;
2516
2661
  await new Promise(
2517
- (l) => setTimeout(l, Ks)
2662
+ (c) => setTimeout(c, un)
2518
2663
  );
2519
2664
  }
2520
- return i && s(`Failed
2665
+ return a && n(`Failed
2521
2666
  `), !1;
2522
2667
  } finally {
2523
- n.kill();
2524
- }
2525
- }, Zs = async (e = {}) => {
2526
- const { onProgress: t } = e, s = await Ss(e.port);
2527
- if (s) {
2528
- const o = new y();
2529
- y.setActiveRemote("local"), await o.setConfig({ apiUrl: s });
2530
- const l = new URL(s).port;
2531
- return t?.(`Twenty server detected on ${s}`), {
2668
+ i.kill();
2669
+ }
2670
+ }, fn = async (e = {}) => {
2671
+ const { onProgress: t, test: s } = e, n = s ? dt : de, i = s ? mt : ft, a = s ? "twenty-app-dev-test-data" : "twenty-app-dev-data", r = s ? "twenty-app-dev-test-storage" : "twenty-app-dev-storage", o = await Vs(e.port ?? i);
2672
+ if (o) {
2673
+ const p = new w(
2674
+ s ? { configPath: le(!0) } : void 0
2675
+ );
2676
+ w.setActiveRemote("local"), await p.setConfig({ apiUrl: o });
2677
+ const h = new URL(o).port;
2678
+ return t?.(`Twenty server detected on ${o}`), {
2532
2679
  success: !0,
2533
- data: { port: parseInt(l, 10), url: s }
2680
+ data: { port: parseInt(h, 10), url: o }
2534
2681
  };
2535
2682
  }
2536
- if (!Ws())
2683
+ if (!ln())
2537
2684
  return {
2538
2685
  success: !1,
2539
2686
  error: {
2540
- code: K.DOCKER_NOT_RUNNING,
2687
+ code: Q.DOCKER_NOT_RUNNING,
2541
2688
  message: "Docker is not running. Please start Docker and try again."
2542
2689
  }
2543
2690
  };
2544
- if (Js()) {
2545
- const o = Re();
2546
- if (t?.("Container is running, waiting for it to become healthy..."), !await De(o))
2691
+ if (on(n)) {
2692
+ const p = He(n);
2693
+ if (t?.("Container is running, waiting for it to become healthy..."), !await Ye(p, n))
2547
2694
  return {
2548
2695
  success: !1,
2549
2696
  error: {
2550
- code: K.HEALTH_TIMEOUT,
2697
+ code: Q.HEALTH_TIMEOUT,
2551
2698
  message: `Twenty server did not become healthy in time.
2552
2699
  Check: 'yarn twenty server logs'`
2553
2700
  }
2554
2701
  };
2555
- const c = `http://localhost:${o}`, u = new y();
2556
- return y.setActiveRemote("local"), await u.setConfig({ apiUrl: c }), t?.(`Server running on ${c}`), { success: !0, data: { port: o, url: c } };
2557
- }
2558
- let n = e.port ?? de;
2559
- if (Gs()) {
2560
- const o = Re();
2561
- o !== n && t?.(
2562
- `Existing container uses port ${o}. Run 'yarn twenty server reset' first to change ports.`
2563
- ), n = o, t?.("Starting existing container..."), Z(`docker start ${Y}`, { stdio: "ignore" });
2564
- } else if (t?.("Starting Twenty container..."), gt(
2702
+ const v = `http://localhost:${p}`, T = new w(
2703
+ s ? { configPath: le(!0) } : void 0
2704
+ );
2705
+ return w.setActiveRemote("local"), await T.setConfig({ apiUrl: v }), t?.(`Server running on ${v}`), { success: !0, data: { port: p, url: v } };
2706
+ }
2707
+ let l = e.port ?? i;
2708
+ if (cn(n)) {
2709
+ const p = He(n);
2710
+ p !== l && t?.(
2711
+ `Existing container uses port ${p}. Run 'yarn twenty server reset${s ? " --test" : ""}' first to change ports.`
2712
+ ), l = p, t?.("Starting existing container..."), te(`docker start ${n}`, { stdio: "ignore" });
2713
+ } else if (t?.("Starting Twenty container..."), Ft(
2565
2714
  "docker",
2566
2715
  [
2567
2716
  "run",
2568
2717
  "-d",
2569
2718
  "--name",
2570
- Y,
2719
+ n,
2571
2720
  "-p",
2572
- `${n}:${n}`,
2721
+ `${l}:${l}`,
2573
2722
  "-e",
2574
- `NODE_PORT=${n}`,
2723
+ `NODE_PORT=${l}`,
2575
2724
  "-e",
2576
- `SERVER_URL=http://localhost:${n}`,
2725
+ `SERVER_URL=http://localhost:${l}`,
2577
2726
  "-v",
2578
- "twenty-app-dev-data:/data/postgres",
2727
+ `${a}:/data/postgres`,
2579
2728
  "-v",
2580
- "twenty-app-dev-storage:/app/packages/twenty-server/.local-storage",
2581
- zs
2729
+ `${r}:/app/packages/twenty-server/.local-storage`,
2730
+ rn
2582
2731
  ],
2583
2732
  { stdio: "inherit" }
2584
2733
  ).status !== 0)
2585
2734
  return {
2586
2735
  success: !1,
2587
2736
  error: {
2588
- code: K.CONTAINER_START_FAILED,
2737
+ code: Q.CONTAINER_START_FAILED,
2589
2738
  message: "Failed to start Twenty container."
2590
2739
  }
2591
2740
  };
2592
- if (t?.("Waiting for Twenty to be ready..."), !await De(n))
2741
+ if (t?.("Waiting for Twenty to be ready..."), !await Ye(l, n))
2593
2742
  return {
2594
2743
  success: !1,
2595
2744
  error: {
2596
- code: K.HEALTH_TIMEOUT,
2745
+ code: Q.HEALTH_TIMEOUT,
2597
2746
  message: `Twenty server did not become healthy in time.
2598
2747
  Check: 'yarn twenty server logs'`
2599
2748
  }
2600
2749
  };
2601
- const a = `http://localhost:${n}`, r = new y();
2602
- return y.setActiveRemote("local"), await r.setConfig({ apiUrl: a }), t?.(`Server running on ${a}`), { success: !0, data: { port: n, url: a } };
2603
- }, xn = (e) => x(
2604
- () => Zs(e),
2605
- K.CONTAINER_START_FAILED
2606
- ), en = async (e) => {
2607
- e.remote && y.setActiveRemote(e.remote);
2608
- const t = new z(), s = await ye(e.appPath);
2750
+ const u = `http://localhost:${l}`, d = new w(
2751
+ s ? { configPath: le(!0) } : void 0
2752
+ );
2753
+ return w.setActiveRemote("local"), await d.setConfig({ apiUrl: u }), t?.(`Server running on ${u}`), { success: !0, data: { port: l, url: u } };
2754
+ }, Kn = (e) => U(
2755
+ () => fn(e),
2756
+ Q.CONTAINER_START_FAILED
2757
+ ), mn = async (e) => {
2758
+ const { appPath: t, onProgress: s, verbose: n } = e;
2759
+ s?.("Checking server...");
2760
+ const i = new j({ disableInterceptors: !0 }), a = await i.validateAuth();
2761
+ if (!a.serverUp)
2762
+ return {
2763
+ success: !1,
2764
+ error: {
2765
+ code: m.SYNC_FAILED,
2766
+ message: `Cannot reach Twenty server.
2767
+
2768
+ Start a local server:
2769
+ yarn twenty server start
2770
+
2771
+ Check server status:
2772
+ yarn twenty server status`
2773
+ }
2774
+ };
2775
+ if (!a.authValid)
2776
+ return {
2777
+ success: !1,
2778
+ error: {
2779
+ code: m.SYNC_FAILED,
2780
+ message: "Authentication failed. Run `yarn twenty remote add --local` to authenticate."
2781
+ }
2782
+ };
2783
+ s?.("Building manifest...");
2784
+ const r = await ot(t);
2785
+ if (!r.success)
2786
+ return {
2787
+ success: !1,
2788
+ error: {
2789
+ code: m.MANIFEST_BUILD_FAILED,
2790
+ message: r.errors.join(`
2791
+ `)
2792
+ }
2793
+ };
2794
+ for (const g of r.warnings)
2795
+ s?.(`⚠ ${g}`);
2796
+ s?.("Building application files...");
2797
+ const o = await it({
2798
+ appPath: t,
2799
+ manifest: r.manifest,
2800
+ filePaths: r.filePaths
2801
+ });
2802
+ s?.("Running typecheck...");
2803
+ const l = await Te(t);
2804
+ if (l.length > 0) {
2805
+ const g = l.map(
2806
+ (F) => `${F.file}(${F.line},${F.column + 1}): ${F.text}`
2807
+ );
2808
+ return {
2809
+ success: !1,
2810
+ error: {
2811
+ code: m.TYPECHECK_FAILED,
2812
+ message: `Typecheck failed:
2813
+ ${g.join(`
2814
+ `)}`
2815
+ }
2816
+ };
2817
+ }
2818
+ const c = ct({
2819
+ manifest: r.manifest,
2820
+ builtFileInfos: o.builtFileInfos
2821
+ });
2822
+ await lt(t, c), s?.("Registering application...");
2823
+ const u = new w(), d = await i.findApplicationRegistrationByUniversalIdentifier(
2824
+ c.application.universalIdentifier
2825
+ );
2826
+ if (!d.success)
2827
+ return {
2828
+ success: !1,
2829
+ error: {
2830
+ code: m.SYNC_FAILED,
2831
+ message: `Failed to check app registration: ${z(d.error)}`
2832
+ }
2833
+ };
2834
+ if (!d.data) {
2835
+ const g = await i.createApplicationRegistration({
2836
+ name: c.application.displayName,
2837
+ universalIdentifier: c.application.universalIdentifier
2838
+ });
2839
+ if (!g.success)
2840
+ return {
2841
+ success: !1,
2842
+ error: {
2843
+ code: m.SYNC_FAILED,
2844
+ message: `Failed to create app registration: ${z(g.error)}`
2845
+ }
2846
+ };
2847
+ await u.setConfig({
2848
+ oauthClientId: g.data.applicationRegistration.oAuthClientId
2849
+ });
2850
+ }
2851
+ const p = await i.createDevelopmentApplication({
2852
+ universalIdentifier: c.application.universalIdentifier,
2853
+ name: c.application.displayName
2854
+ });
2855
+ if (!p.success)
2856
+ return {
2857
+ success: !1,
2858
+ error: {
2859
+ code: m.SYNC_FAILED,
2860
+ message: `Failed to create development application: ${z(p.error)}`
2861
+ }
2862
+ };
2863
+ s?.(
2864
+ `Uploading ${o.builtFileInfos.size} file${o.builtFileInfos.size === 1 ? "" : "s"}...`
2865
+ );
2866
+ const h = new qs({
2867
+ appPath: t,
2868
+ applicationUniversalIdentifier: c.application.universalIdentifier
2869
+ }), v = [], T = Array.from(o.builtFileInfos.values()).map(
2870
+ async (g) => {
2871
+ n && s?.(`Uploading ${g.builtPath}`);
2872
+ const F = await h.uploadFile({
2873
+ builtPath: g.builtPath,
2874
+ fileFolder: g.fileFolder
2875
+ });
2876
+ F.success || v.push(
2877
+ `Failed to upload ${g.builtPath}: ${z(F.error)}`
2878
+ );
2879
+ }
2880
+ );
2881
+ if (await Promise.all(T), v.length > 0)
2882
+ return {
2883
+ success: !1,
2884
+ error: {
2885
+ code: m.SYNC_FAILED,
2886
+ message: v.join(`
2887
+ `)
2888
+ }
2889
+ };
2890
+ s?.("Syncing manifest...");
2891
+ const E = await i.syncApplication(c);
2892
+ if (!E.success) {
2893
+ const g = n ? null : Ys(E.error), F = g ? g.map((ne) => ne.message).join(`
2894
+ `) : `Sync failed with error: ${z(E.error)}`;
2895
+ return {
2896
+ success: !1,
2897
+ error: {
2898
+ code: m.SYNC_FAILED,
2899
+ message: F
2900
+ }
2901
+ };
2902
+ }
2903
+ s?.("Generating API client...");
2904
+ try {
2905
+ const g = await u.getConfig();
2906
+ await new Bs().generateCoreClient({
2907
+ appPath: t,
2908
+ authToken: g.accessToken
2909
+ });
2910
+ } catch (g) {
2911
+ return {
2912
+ success: !1,
2913
+ error: {
2914
+ code: m.SYNC_FAILED,
2915
+ message: `Failed to generate API client: ${z(g)}`
2916
+ }
2917
+ };
2918
+ }
2919
+ return {
2920
+ success: !0,
2921
+ data: {
2922
+ outputDir: I.join(t, O),
2923
+ fileCount: o.builtFileInfos.size,
2924
+ applicationDisplayName: c.application.displayName,
2925
+ applicationUniversalIdentifier: c.application.universalIdentifier
2926
+ }
2927
+ };
2928
+ }, Xn = (e) => U(() => mn(e), m.SYNC_FAILED), hn = async (e) => {
2929
+ e.remote && w.setActiveRemote(e.remote);
2930
+ const t = new j(), s = await Ee(e.appPath);
2609
2931
  if (!s)
2610
2932
  return {
2611
2933
  success: !1,
2612
2934
  error: {
2613
- code: v.MANIFEST_NOT_FOUND,
2935
+ code: m.MANIFEST_NOT_FOUND,
2614
2936
  message: "Manifest not found. Run `build` or `dev` first."
2615
2937
  }
2616
2938
  };
@@ -2622,48 +2944,56 @@ Check: 'yarn twenty server logs'`
2622
2944
  return {
2623
2945
  success: !1,
2624
2946
  error: {
2625
- code: v.UNINSTALL_FAILED,
2947
+ code: m.UNINSTALL_FAILED,
2626
2948
  message: i
2627
2949
  }
2628
2950
  };
2629
2951
  }
2630
2952
  return { success: !0, data: void 0 };
2631
- }, Dn = (e) => x(() => en(e), v.UNINSTALL_FAILED);
2953
+ }, Qn = (e) => U(() => hn(e), m.UNINSTALL_FAILED);
2632
2954
  export {
2633
- M as A,
2634
- Y as B,
2635
- y as C,
2636
- de as D,
2637
- Js as E,
2638
- se as F,
2639
- Re as G,
2640
- et as H,
2641
- Ge as I,
2642
- K as S,
2643
- v as a,
2644
- As as b,
2645
- On as c,
2646
- Ln as d,
2647
- Sn as e,
2648
- Dn as f,
2649
- Pn as g,
2650
- Rn as h,
2651
- Ss as i,
2652
- _n as j,
2653
- U as k,
2654
- z as l,
2655
- gs as m,
2656
- Pt as n,
2657
- pe as o,
2658
- ge as p,
2659
- Mt as q,
2660
- x as r,
2661
- xn as s,
2662
- kn as t,
2663
- Cn as u,
2664
- ys as v,
2665
- Is as w,
2666
- St as x,
2667
- ye as y,
2668
- Gs as z
2955
+ V as A,
2956
+ qs as B,
2957
+ w as C,
2958
+ Bs as D,
2959
+ zt as E,
2960
+ ce as F,
2961
+ Ee as G,
2962
+ le as H,
2963
+ mt as I,
2964
+ ft as J,
2965
+ de as K,
2966
+ cn as L,
2967
+ on as M,
2968
+ He as N,
2969
+ ut as O,
2970
+ Te as P,
2971
+ Q as S,
2972
+ dt as T,
2973
+ m as a,
2974
+ Os as b,
2975
+ Yn as c,
2976
+ Xn as d,
2977
+ zn as e,
2978
+ Jn as f,
2979
+ Qn as g,
2980
+ Gn as h,
2981
+ Wn as i,
2982
+ Vs as j,
2983
+ qn as k,
2984
+ B as l,
2985
+ j as m,
2986
+ ot as n,
2987
+ Jt as o,
2988
+ Fe as p,
2989
+ Ie as q,
2990
+ U as r,
2991
+ Kn as s,
2992
+ Zt as t,
2993
+ Hn as u,
2994
+ Vn as v,
2995
+ ct as w,
2996
+ lt as x,
2997
+ Ys as y,
2998
+ z
2669
2999
  };