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.
- package/dist/cli/commands/dev-once.d.ts +7 -0
- package/dist/cli/commands/exec.d.ts +2 -2
- package/dist/cli/operations/dev-once.d.ts +13 -0
- package/dist/cli/operations/execute.d.ts +2 -2
- package/dist/cli/operations/index.d.ts +2 -0
- package/dist/cli/operations/server-start.d.ts +1 -0
- package/dist/cli/utilities/build/manifest/manifest-extract-config.d.ts +1 -1
- package/dist/cli/utilities/build/manifest/utils/add-missing-field-option-ids.d.ts +2 -0
- package/dist/cli/utilities/build/manifest/utils/from-role-config-to-role-manifest.d.ts +3 -0
- package/dist/cli/utilities/config/config-service.d.ts +3 -1
- package/dist/cli/utilities/config/get-config-path.d.ts +1 -1
- package/dist/cli/utilities/server/docker-container.d.ts +5 -3
- package/dist/cli.cjs +46 -44
- package/dist/cli.mjs +2035 -2089
- package/dist/{frontComponentHostCommunicationApi-op3Q7sYg.mjs → frontComponentHostCommunicationApi-Bz03t3FY.mjs} +66 -74
- package/dist/{frontComponentHostCommunicationApi-DvdpnfNz.js → frontComponentHostCommunicationApi-DyOxvANW.js} +3 -3
- package/dist/{get-function-input-schema-BZ7_XyUh-xI83N7kX.mjs → get-function-input-schema-BZ7_XyUh-CtECetlr.mjs} +1 -1
- package/dist/{get-function-input-schema-BZ7_XyUh-Bf_NiyDR.js → get-function-input-schema-BZ7_XyUh-D2ypJxjI.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +9 -9
- package/dist/operations.cjs +1 -1
- package/dist/operations.mjs +14 -13
- package/dist/sdk/application/application-config.d.ts +1 -1
- package/dist/sdk/common/types/define-entity.type.d.ts +5 -2
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/logic-functions/define-post-install-logic-function.d.ts +2 -5
- package/dist/sdk/logic-functions/define-post-install-logic-function.js.map +1 -1
- package/dist/sdk/logic-functions/define-pre-install-logic-function.d.ts +2 -5
- package/dist/sdk/logic-functions/define-pre-install-logic-function.js.map +1 -1
- package/dist/sdk/logic-functions/install-payload-type.d.ts +5 -0
- package/dist/sdk/logic-functions/post-install-logic-function-config.d.ts +4 -0
- package/dist/sdk/logic-functions/pre-install-logic-function-config.d.ts +5 -0
- package/dist/sdk/roles/define-role.d.ts +2 -2
- package/dist/sdk/roles/define-role.js.map +1 -1
- package/dist/sdk/roles/role-config.d.ts +7 -0
- package/dist/ui/index.cjs +413 -398
- package/dist/ui/index.mjs +2164 -2134
- package/dist/uninstall-CXlUxs8p.js +189 -0
- package/dist/{uninstall-9yB-e13_.mjs → uninstall-CrGYRb-Z.mjs} +993 -663
- package/package.json +2 -2
- package/dist/sdk/logic-functions/install-logic-function-payload-type.d.ts +0 -4
- package/dist/uninstall-BCUbP_Bn.js +0 -178
|
@@ -1,67 +1,68 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import { execSync as
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import * as
|
|
24
|
-
import
|
|
25
|
-
import {
|
|
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
|
|
29
|
-
const
|
|
29
|
+
import { glob as Qe } from "tinyglobby";
|
|
30
|
+
const Fe = async (e) => {
|
|
30
31
|
try {
|
|
31
|
-
return await
|
|
32
|
+
return await Ke(e), !0;
|
|
32
33
|
} catch {
|
|
33
34
|
return !1;
|
|
34
35
|
}
|
|
35
|
-
},
|
|
36
|
-
await
|
|
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
|
|
39
|
+
await Ke(e);
|
|
39
40
|
} catch {
|
|
40
|
-
await
|
|
41
|
+
await H(e, "");
|
|
41
42
|
}
|
|
42
|
-
},
|
|
43
|
+
}, zt = async (e) => {
|
|
43
44
|
let t;
|
|
44
45
|
try {
|
|
45
|
-
t = await
|
|
46
|
+
t = await kt(e);
|
|
46
47
|
} catch (s) {
|
|
47
48
|
if (s instanceof Error && "code" in s && s.code === "ENOENT") {
|
|
48
|
-
await
|
|
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) =>
|
|
56
|
+
(s) => Xe(_t(e, s), { recursive: !0, force: !0 })
|
|
56
57
|
)
|
|
57
58
|
);
|
|
58
|
-
},
|
|
59
|
-
const t = await
|
|
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
|
-
},
|
|
62
|
-
await
|
|
62
|
+
}, Wt = async (e, t) => {
|
|
63
|
+
await H(e, JSON.stringify(t, null, 2) + `
|
|
63
64
|
`);
|
|
64
|
-
},
|
|
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 =
|
|
76
|
-
if (n.get(l) ===
|
|
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,
|
|
79
|
-
const
|
|
80
|
-
(
|
|
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:
|
|
87
|
-
usesSdkClient:
|
|
87
|
+
checksum: p,
|
|
88
|
+
usesSdkClient: T
|
|
88
89
|
});
|
|
89
90
|
}
|
|
90
|
-
},
|
|
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] =
|
|
103
|
+
a[l] = I.join(e, o);
|
|
103
104
|
}
|
|
104
|
-
const r = await
|
|
105
|
+
const r = await Ae.build({
|
|
105
106
|
...n,
|
|
106
107
|
entryPoints: a
|
|
107
108
|
});
|
|
108
|
-
await
|
|
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
|
-
},
|
|
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 =
|
|
119
|
-
await
|
|
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
|
-
},
|
|
122
|
+
}, et = [
|
|
122
123
|
"twenty-client-sdk/core",
|
|
123
124
|
"twenty-client-sdk/metadata"
|
|
124
|
-
],
|
|
125
|
-
const t = e.match(
|
|
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
|
-
},
|
|
136
|
+
}, es = (e) => {
|
|
136
137
|
const t = [];
|
|
137
138
|
for (const s of e.split(`
|
|
138
139
|
`)) {
|
|
139
|
-
const n =
|
|
140
|
+
const n = Zt(s);
|
|
140
141
|
n && t.push(n);
|
|
141
142
|
}
|
|
142
143
|
return t;
|
|
143
|
-
},
|
|
144
|
-
const t =
|
|
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
|
-
|
|
147
|
+
ze(
|
|
147
148
|
s,
|
|
148
149
|
["--noEmit", "--pretty", "false", "-p", t],
|
|
149
150
|
{ cwd: e },
|
|
150
151
|
(i, a, r) => {
|
|
151
|
-
n(
|
|
152
|
+
n(es(r || a));
|
|
152
153
|
}
|
|
153
154
|
);
|
|
154
155
|
});
|
|
155
|
-
},
|
|
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
|
-
})),
|
|
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
|
|
173
|
-
return { errors:
|
|
173
|
+
const n = await Te(e);
|
|
174
|
+
return { errors: ts(n) };
|
|
174
175
|
});
|
|
175
176
|
}
|
|
176
|
-
}),
|
|
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
|
|
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 =
|
|
218
|
-
await
|
|
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 =
|
|
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] =
|
|
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
|
|
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
|
|
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:
|
|
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
|
|
283
|
+
const Hn = (e) => new nt({
|
|
283
284
|
...e,
|
|
284
285
|
config: {
|
|
285
|
-
externalModules:
|
|
286
|
-
fileFolder:
|
|
286
|
+
externalModules: st,
|
|
287
|
+
fileFolder: D.BuiltLogicFunction,
|
|
287
288
|
platform: "node",
|
|
288
289
|
extraPlugins: [
|
|
289
|
-
|
|
290
|
+
tt(e.appPath, e.shouldSkipTypecheck)
|
|
290
291
|
],
|
|
291
|
-
banner:
|
|
292
|
+
banner: Je
|
|
292
293
|
}
|
|
293
|
-
}),
|
|
294
|
+
}), Vn = (e) => new nt({
|
|
294
295
|
...e,
|
|
295
296
|
config: {
|
|
296
|
-
externalModules:
|
|
297
|
-
fileFolder:
|
|
297
|
+
externalModules: et,
|
|
298
|
+
fileFolder: D.BuiltFrontComponent,
|
|
298
299
|
jsx: "automatic",
|
|
299
300
|
extraPlugins: [
|
|
300
|
-
|
|
301
|
-
...
|
|
301
|
+
tt(e.appPath, e.shouldSkipTypecheck),
|
|
302
|
+
...we()
|
|
302
303
|
]
|
|
303
304
|
}
|
|
304
|
-
}),
|
|
305
|
+
}), ss = () => ({
|
|
305
306
|
bundle: !0,
|
|
306
307
|
splitting: !1,
|
|
307
308
|
format: "esm",
|
|
308
309
|
outExtension: { ".js": ".mjs" },
|
|
309
|
-
external:
|
|
310
|
+
external: et,
|
|
310
311
|
jsx: "automatic",
|
|
311
312
|
sourcemap: !0,
|
|
312
313
|
metafile: !0,
|
|
313
314
|
logLevel: "silent",
|
|
314
|
-
plugins: [...
|
|
315
|
-
}),
|
|
316
|
-
const t =
|
|
317
|
-
await
|
|
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
|
|
328
|
+
return await Ue({
|
|
328
329
|
appPath: e.appPath,
|
|
329
330
|
sourcePaths: i,
|
|
330
|
-
fileFolder:
|
|
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:
|
|
337
|
+
outdir: R(e.appPath, O),
|
|
337
338
|
outExtension: { ".js": ".mjs" },
|
|
338
|
-
external:
|
|
339
|
-
tsconfig:
|
|
339
|
+
external: st,
|
|
340
|
+
tsconfig: R(e.appPath, "tsconfig.json"),
|
|
340
341
|
sourcemap: !0,
|
|
341
342
|
metafile: !0,
|
|
342
343
|
logLevel: "silent",
|
|
343
|
-
banner:
|
|
344
|
+
banner: Je
|
|
344
345
|
},
|
|
345
346
|
onFileBuilt: n
|
|
346
|
-
}), await
|
|
347
|
+
}), await Ue({
|
|
347
348
|
appPath: e.appPath,
|
|
348
349
|
sourcePaths: a,
|
|
349
|
-
fileFolder:
|
|
350
|
+
fileFolder: D.BuiltFrontComponent,
|
|
350
351
|
buildOptions: {
|
|
351
|
-
...
|
|
352
|
-
outdir:
|
|
353
|
-
tsconfig:
|
|
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: [...
|
|
359
|
+
plugins: [...we()]
|
|
359
360
|
},
|
|
360
361
|
onFileBuilt: n
|
|
361
|
-
}), await
|
|
362
|
+
}), await $e({
|
|
362
363
|
appPath: e.appPath,
|
|
363
|
-
fileFolder:
|
|
364
|
+
fileFolder: D.PublicAsset,
|
|
364
365
|
filePaths: e.filePaths.publicAssets,
|
|
365
366
|
collectFileBuilt: n
|
|
366
|
-
}), await
|
|
367
|
+
}), await $e({
|
|
367
368
|
appPath: e.appPath,
|
|
368
|
-
fileFolder:
|
|
369
|
+
fileFolder: D.Dependencies,
|
|
369
370
|
filePaths: ["package.json", "yarn.lock"].filter(
|
|
370
|
-
(r) =>
|
|
371
|
+
(r) => Yt(R(e.appPath, r))
|
|
371
372
|
),
|
|
372
373
|
collectFileBuilt: n
|
|
373
374
|
}), { builtFileInfos: s };
|
|
374
|
-
},
|
|
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 =
|
|
382
|
-
if (!await
|
|
382
|
+
const a = R(e, i);
|
|
383
|
+
if (!await Fe(a))
|
|
383
384
|
continue;
|
|
384
|
-
const r =
|
|
385
|
-
await
|
|
386
|
-
const l = await
|
|
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
|
|
396
|
-
const
|
|
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
|
-
},
|
|
412
|
-
if (!
|
|
412
|
+
}, is = (e) => {
|
|
413
|
+
if (!W.isCallExpression(e))
|
|
413
414
|
return;
|
|
414
415
|
const t = e.expression;
|
|
415
|
-
if (
|
|
416
|
+
if (W.isIdentifier(t) && Object.values(ue).includes(t.text))
|
|
416
417
|
return t.text;
|
|
417
|
-
},
|
|
418
|
-
const t =
|
|
418
|
+
}, as = (e) => {
|
|
419
|
+
const t = W.createSourceFile(
|
|
419
420
|
"temp.ts",
|
|
420
421
|
e,
|
|
421
|
-
|
|
422
|
+
W.ScriptTarget.Latest,
|
|
422
423
|
!0
|
|
423
424
|
), s = [];
|
|
424
|
-
|
|
425
|
+
W.forEachChild(t, (n) => {
|
|
425
426
|
s.push(n);
|
|
426
427
|
});
|
|
427
428
|
for (const n of s)
|
|
428
|
-
if (
|
|
429
|
+
if (W.isExportAssignment(n)) {
|
|
429
430
|
if (n.isExportEquals || !n.expression)
|
|
430
431
|
return;
|
|
431
|
-
const i =
|
|
432
|
+
const i = is(n.expression);
|
|
432
433
|
if (i)
|
|
433
434
|
return i;
|
|
434
435
|
}
|
|
435
|
-
},
|
|
436
|
+
}, rs = [
|
|
436
437
|
[/\bfavoriteRecordIds\.length\b/g, "arrayLength(favoriteRecordIds)"],
|
|
437
438
|
[/\bselectedRecords\.length\b/g, "arrayLength(selectedRecords)"]
|
|
438
|
-
],
|
|
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
|
-
),
|
|
442
|
-
|
|
443
|
-
(t, s, n) => s + JSON.stringify(
|
|
444
|
-
),
|
|
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
|
|
449
|
+
const s = await Ht.readFile(t.path, "utf8");
|
|
449
450
|
if (!s.includes("conditionalAvailabilityExpression"))
|
|
450
451
|
return null;
|
|
451
|
-
const n =
|
|
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
|
-
},
|
|
459
|
+
}, ps = [
|
|
459
460
|
"twenty-sdk/ui",
|
|
460
461
|
"twenty-client-sdk/core",
|
|
461
462
|
"twenty-client-sdk/metadata"
|
|
462
|
-
],
|
|
463
|
+
], ds = {
|
|
463
464
|
name: "manifest-mock",
|
|
464
465
|
setup: (e) => {
|
|
465
466
|
const t = new RegExp(
|
|
466
|
-
`^(${
|
|
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
|
-
},
|
|
477
|
+
}, k = async ({
|
|
477
478
|
filePath: e,
|
|
478
479
|
appPath: t
|
|
479
480
|
}) => {
|
|
480
|
-
const s = await
|
|
481
|
-
return
|
|
482
|
-
},
|
|
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 =
|
|
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 =
|
|
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
|
|
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: [
|
|
506
|
+
plugins: [us, ds],
|
|
506
507
|
logLevel: "silent"
|
|
507
|
-
})).outputFiles[0].text, c = await
|
|
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
|
|
510
|
+
return await H(u, l), i(u);
|
|
510
511
|
} finally {
|
|
511
|
-
await
|
|
512
|
+
await Ie(c);
|
|
512
513
|
}
|
|
513
|
-
},
|
|
514
|
-
if (
|
|
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
|
-
},
|
|
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
|
|
525
|
-
},
|
|
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:
|
|
534
|
-
universalIdentifier:
|
|
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:
|
|
546
|
-
universalIdentifier:
|
|
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:
|
|
558
|
-
universalIdentifier:
|
|
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:
|
|
570
|
-
universalIdentifier:
|
|
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:
|
|
582
|
-
universalIdentifier:
|
|
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:
|
|
594
|
-
universalIdentifier:
|
|
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:
|
|
606
|
-
universalIdentifier:
|
|
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:
|
|
618
|
-
universalIdentifier:
|
|
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:
|
|
630
|
-
universalIdentifier:
|
|
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
|
-
},
|
|
647
|
-
targetFieldName: (e) => `target${
|
|
648
|
-
targetLabel: (e) =>
|
|
647
|
+
}, X = {
|
|
648
|
+
targetFieldName: (e) => `target${ye(e.nameSingular)}`,
|
|
649
|
+
targetLabel: (e) => ye(e.nameSingular),
|
|
649
650
|
icon: "IconBuildingSkyscraper",
|
|
650
651
|
isNullable: !0
|
|
651
|
-
},
|
|
652
|
+
}, ys = [
|
|
652
653
|
{
|
|
653
|
-
...
|
|
654
|
+
...X,
|
|
654
655
|
fieldName: "timelineActivities",
|
|
655
656
|
label: "Timeline Activities",
|
|
656
657
|
targetIcon: "IconTimelineEvent",
|
|
657
|
-
targetFieldType:
|
|
658
|
+
targetFieldType: A.MORPH_RELATION,
|
|
658
659
|
standardObjectKey: "timelineActivity",
|
|
659
|
-
morphId:
|
|
660
|
+
morphId: G.timelineActivity.morphIds.targetMorphId.morphId
|
|
660
661
|
},
|
|
661
662
|
{
|
|
662
|
-
...
|
|
663
|
+
...X,
|
|
663
664
|
fieldName: "favorites",
|
|
664
665
|
label: "Favorites",
|
|
665
666
|
icon: "IconBuildingSkyscraper",
|
|
666
667
|
targetIcon: "IconHeart",
|
|
667
|
-
targetFieldType:
|
|
668
|
+
targetFieldType: A.RELATION,
|
|
668
669
|
standardObjectKey: "favorite"
|
|
669
670
|
},
|
|
670
671
|
{
|
|
671
|
-
...
|
|
672
|
+
...X,
|
|
672
673
|
fieldName: "attachments",
|
|
673
674
|
label: "Attachments",
|
|
674
675
|
icon: "IconBuildingSkyscraper",
|
|
675
676
|
targetIcon: "IconFileImport",
|
|
676
|
-
targetFieldType:
|
|
677
|
+
targetFieldType: A.MORPH_RELATION,
|
|
677
678
|
standardObjectKey: "attachment",
|
|
678
|
-
morphId:
|
|
679
|
+
morphId: G.attachment.morphIds.targetMorphId.morphId
|
|
679
680
|
},
|
|
680
681
|
{
|
|
681
|
-
...
|
|
682
|
+
...X,
|
|
682
683
|
fieldName: "noteTargets",
|
|
683
684
|
label: "Note Targets",
|
|
684
685
|
icon: "IconBuildingSkyscraper",
|
|
685
686
|
targetIcon: "IconCheckbox",
|
|
686
|
-
targetFieldType:
|
|
687
|
+
targetFieldType: A.MORPH_RELATION,
|
|
687
688
|
standardObjectKey: "noteTarget",
|
|
688
|
-
morphId:
|
|
689
|
+
morphId: G.noteTarget.morphIds.targetMorphId.morphId
|
|
689
690
|
},
|
|
690
691
|
{
|
|
691
|
-
...
|
|
692
|
+
...X,
|
|
692
693
|
fieldName: "taskTargets",
|
|
693
694
|
label: "Task Targets",
|
|
694
695
|
icon: "IconBuildingSkyscraper",
|
|
695
696
|
targetIcon: "IconCheckbox",
|
|
696
|
-
targetFieldType:
|
|
697
|
+
targetFieldType: A.MORPH_RELATION,
|
|
697
698
|
standardObjectKey: "taskTarget",
|
|
698
|
-
morphId:
|
|
699
|
+
morphId: G.taskTarget.morphIds.targetMorphId.morphId
|
|
699
700
|
}
|
|
700
|
-
],
|
|
701
|
+
], Is = ({
|
|
701
702
|
config: e,
|
|
702
703
|
forwardFieldUniversalIdentifier: t,
|
|
703
704
|
objectConfig: s,
|
|
704
705
|
universalIdentifier: n
|
|
705
706
|
}) => {
|
|
706
|
-
const i =
|
|
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:
|
|
714
|
-
onDelete:
|
|
715
|
-
joinColumnName: `target${
|
|
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 ===
|
|
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
|
-
},
|
|
731
|
+
}, vs = (e) => {
|
|
731
732
|
const t = [], s = [];
|
|
732
|
-
for (const n of
|
|
733
|
-
const i =
|
|
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 =
|
|
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:
|
|
746
|
-
universalSettings: { relationType:
|
|
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 =
|
|
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
|
-
},
|
|
760
|
-
const t =
|
|
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
|
-
},
|
|
767
|
+
}, ws = {
|
|
767
768
|
type: "object",
|
|
768
769
|
properties: {}
|
|
769
|
-
},
|
|
770
|
-
const { getFunctionInputSchema: t } = await import("./get-function-input-schema-BZ7_XyUh-
|
|
771
|
-
return s?.type === "object" &&
|
|
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
|
-
} :
|
|
775
|
-
},
|
|
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
|
-
}),
|
|
819
|
+
}), Ns = async (e) => await Qe([`${St}/**/*`], {
|
|
781
820
|
cwd: e,
|
|
821
|
+
absolute: !0,
|
|
782
822
|
onlyFiles: !0
|
|
783
|
-
}),
|
|
784
|
-
const t = await
|
|
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 = [],
|
|
787
|
-
for (const
|
|
788
|
-
const $ = await
|
|
789
|
-
if (!
|
|
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 (
|
|
792
|
-
case
|
|
793
|
-
const
|
|
831
|
+
switch (ns[ie]) {
|
|
832
|
+
case N.Application: {
|
|
833
|
+
const f = await k({
|
|
794
834
|
appPath: e,
|
|
795
|
-
filePath:
|
|
835
|
+
filePath: y
|
|
796
836
|
});
|
|
797
837
|
n = {
|
|
798
|
-
...
|
|
838
|
+
...f.config,
|
|
799
839
|
yarnLockChecksum: null,
|
|
800
840
|
packageJsonChecksum: null
|
|
801
|
-
}, s.push(...
|
|
841
|
+
}, s.push(...f.errors), g.push(C);
|
|
802
842
|
break;
|
|
803
843
|
}
|
|
804
|
-
case
|
|
805
|
-
const
|
|
844
|
+
case N.Objects: {
|
|
845
|
+
const f = await k({
|
|
806
846
|
appPath: e,
|
|
807
|
-
filePath:
|
|
847
|
+
filePath: y
|
|
808
848
|
}), {
|
|
809
|
-
objectFields:
|
|
810
|
-
fields:
|
|
811
|
-
} =
|
|
812
|
-
if (!
|
|
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 ${
|
|
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
|
|
819
|
-
...
|
|
820
|
-
fields:
|
|
821
|
-
labelIdentifierFieldMetadataUniversalIdentifier:
|
|
858
|
+
const q = {
|
|
859
|
+
...f.config,
|
|
860
|
+
fields: b.map(je),
|
|
861
|
+
labelIdentifierFieldMetadataUniversalIdentifier: M
|
|
822
862
|
};
|
|
823
|
-
i.push(
|
|
863
|
+
i.push(q), a.push(...Y), s.push(...f.errors), F.push(C);
|
|
824
864
|
break;
|
|
825
865
|
}
|
|
826
|
-
case
|
|
827
|
-
const
|
|
866
|
+
case N.Fields: {
|
|
867
|
+
const f = await k({
|
|
828
868
|
appPath: e,
|
|
829
|
-
filePath:
|
|
830
|
-
});
|
|
831
|
-
a.push(
|
|
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
|
|
835
|
-
const
|
|
874
|
+
case N.Roles: {
|
|
875
|
+
const f = await k({
|
|
836
876
|
appPath: e,
|
|
837
|
-
filePath:
|
|
838
|
-
});
|
|
839
|
-
r.push(
|
|
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
|
|
843
|
-
const
|
|
882
|
+
case N.Skills: {
|
|
883
|
+
const f = await k({
|
|
844
884
|
appPath: e,
|
|
845
|
-
filePath:
|
|
885
|
+
filePath: y
|
|
846
886
|
});
|
|
847
|
-
o.push(
|
|
887
|
+
o.push(f.config), s.push(...f.errors), Ne.push(C);
|
|
848
888
|
break;
|
|
849
889
|
}
|
|
850
|
-
case
|
|
851
|
-
const
|
|
890
|
+
case N.Agents: {
|
|
891
|
+
const f = await k({
|
|
852
892
|
appPath: e,
|
|
853
|
-
filePath:
|
|
893
|
+
filePath: y
|
|
854
894
|
});
|
|
855
|
-
l.push(
|
|
895
|
+
l.push(f.config), s.push(...f.errors), Se.push(C);
|
|
856
896
|
break;
|
|
857
897
|
}
|
|
858
|
-
case
|
|
859
|
-
const
|
|
898
|
+
case N.LogicFunctions: {
|
|
899
|
+
const f = await k({
|
|
860
900
|
appPath: e,
|
|
861
|
-
filePath:
|
|
901
|
+
filePath: y
|
|
862
902
|
});
|
|
863
|
-
s.push(...
|
|
864
|
-
const { handler:
|
|
865
|
-
...
|
|
866
|
-
toolInputSchema:
|
|
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:
|
|
869
|
-
builtHandlerPath:
|
|
908
|
+
sourceHandlerPath: M,
|
|
909
|
+
builtHandlerPath: M.replace(/\.tsx?$/, ".mjs"),
|
|
870
910
|
builtHandlerChecksum: "[default-checksum]"
|
|
871
911
|
};
|
|
872
|
-
c.push(
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
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
|
|
880
|
-
const
|
|
929
|
+
case N.FrontComponents: {
|
|
930
|
+
const f = await k({
|
|
881
931
|
appPath: e,
|
|
882
|
-
filePath:
|
|
932
|
+
filePath: y
|
|
883
933
|
});
|
|
884
|
-
s.push(...
|
|
885
|
-
const { component:
|
|
886
|
-
...
|
|
887
|
-
componentName:
|
|
888
|
-
sourceComponentPath:
|
|
889
|
-
builtComponentPath:
|
|
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:
|
|
941
|
+
isHeadless: M.isHeadless ?? !1,
|
|
892
942
|
// transformed by conditionalAvailabilityTransformPlugin
|
|
893
|
-
command:
|
|
943
|
+
command: Y
|
|
894
944
|
};
|
|
895
|
-
u.push(
|
|
945
|
+
u.push(K), ke.push(C);
|
|
896
946
|
break;
|
|
897
947
|
}
|
|
898
|
-
case
|
|
899
|
-
const
|
|
948
|
+
case N.Views: {
|
|
949
|
+
const f = await k({
|
|
900
950
|
appPath: e,
|
|
901
|
-
filePath:
|
|
902
|
-
}),
|
|
903
|
-
...
|
|
951
|
+
filePath: y
|
|
952
|
+
}), b = {
|
|
953
|
+
...f.config
|
|
904
954
|
};
|
|
905
|
-
|
|
955
|
+
p.push(b), s.push(...f.errors), Le.push(C);
|
|
906
956
|
break;
|
|
907
957
|
}
|
|
908
|
-
case
|
|
909
|
-
const
|
|
958
|
+
case N.NavigationMenuItems: {
|
|
959
|
+
const f = await k({
|
|
910
960
|
appPath: e,
|
|
911
|
-
filePath:
|
|
961
|
+
filePath: y
|
|
912
962
|
});
|
|
913
|
-
|
|
963
|
+
h.push(f.config), s.push(...f.errors), Oe.push(C);
|
|
914
964
|
break;
|
|
915
965
|
}
|
|
916
|
-
case
|
|
917
|
-
const
|
|
966
|
+
case N.PageLayouts: {
|
|
967
|
+
const f = await k({
|
|
918
968
|
appPath: e,
|
|
919
|
-
filePath:
|
|
920
|
-
}),
|
|
921
|
-
...
|
|
969
|
+
filePath: y
|
|
970
|
+
}), b = {
|
|
971
|
+
...f.config
|
|
922
972
|
};
|
|
923
|
-
|
|
973
|
+
v.push(b), s.push(...f.errors), _e.push(C);
|
|
924
974
|
break;
|
|
925
975
|
}
|
|
926
|
-
case
|
|
976
|
+
case N.PublicAssets:
|
|
927
977
|
break;
|
|
928
978
|
default:
|
|
929
|
-
|
|
979
|
+
Nt();
|
|
930
980
|
}
|
|
931
981
|
}
|
|
932
|
-
const
|
|
933
|
-
for (const
|
|
982
|
+
const ht = await Ns(e);
|
|
983
|
+
for (const y of ht) {
|
|
984
|
+
const $ = J(e, y);
|
|
934
985
|
d.push({
|
|
935
|
-
filePath:
|
|
936
|
-
fileName:
|
|
937
|
-
fileType:
|
|
986
|
+
filePath: $,
|
|
987
|
+
fileName: At(y),
|
|
988
|
+
fileType: vt(y).replace(/^\./, ""),
|
|
938
989
|
checksum: null
|
|
939
|
-
}),
|
|
990
|
+
}), Pe.push($);
|
|
991
|
+
}
|
|
940
992
|
n || s.push(
|
|
941
993
|
"Cannot build application, please export default defineApplication() to define an application"
|
|
942
|
-
),
|
|
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
|
-
),
|
|
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
|
-
|
|
949
|
-
}), n &&
|
|
1000
|
+
postInstallLogicFunction: T[0]
|
|
1001
|
+
}), n && E.length >= 1 && (n = {
|
|
950
1002
|
...n,
|
|
951
|
-
|
|
1003
|
+
preInstallLogicFunction: E[0]
|
|
952
1004
|
});
|
|
953
|
-
const
|
|
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(
|
|
957
|
-
fields: a.sort(
|
|
958
|
-
roles: r.sort(
|
|
959
|
-
skills: o.sort(
|
|
960
|
-
agents: l.sort(
|
|
961
|
-
logicFunctions: c.sort(
|
|
962
|
-
frontComponents: u.sort(
|
|
963
|
-
publicAssets: d.sort(
|
|
964
|
-
views:
|
|
965
|
-
navigationMenuItems:
|
|
966
|
-
pageLayouts:
|
|
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:
|
|
969
|
-
objects:
|
|
970
|
-
fields:
|
|
971
|
-
roles:
|
|
972
|
-
skills:
|
|
973
|
-
agents:
|
|
974
|
-
logicFunctions:
|
|
975
|
-
frontComponents:
|
|
976
|
-
publicAssets:
|
|
977
|
-
views:
|
|
978
|
-
navigationMenuItems:
|
|
979
|
-
pageLayouts:
|
|
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
|
-
},
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
],
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
],
|
|
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
|
-
},
|
|
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(...
|
|
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
|
-
},
|
|
1051
|
+
}, ks = (e) => {
|
|
1000
1052
|
const t = [];
|
|
1001
1053
|
for (const s of e) {
|
|
1002
|
-
if (!
|
|
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 (${
|
|
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 (!
|
|
1063
|
+
if (!he.includes(n.relationType)) {
|
|
1012
1064
|
t.push(
|
|
1013
|
-
`Relation field "${s.name}" has invalid relationType "${n.relationType}". Expected ${
|
|
1065
|
+
`Relation field "${s.name}" has invalid relationType "${n.relationType}". Expected ${he.join(" or ")}.`
|
|
1014
1066
|
);
|
|
1015
1067
|
continue;
|
|
1016
1068
|
}
|
|
1017
|
-
n.relationType ===
|
|
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
|
-
},
|
|
1023
|
-
const t = [], s = [], n =
|
|
1024
|
-
n.length > 0 && t.push(`Duplicate universal identifiers: ${n.join(", ")}`),
|
|
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(...
|
|
1030
|
-
},
|
|
1031
|
-
const t = await
|
|
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 =
|
|
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
|
-
},
|
|
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 =
|
|
1057
|
-
if (i ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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
|
-
},
|
|
1104
|
-
const s =
|
|
1105
|
-
await
|
|
1106
|
-
const n =
|
|
1107
|
-
return await
|
|
1108
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
1195
|
+
}, Ls = async (e) => {
|
|
1144
1196
|
const { appPath: t, onProgress: s } = e;
|
|
1145
1197
|
s?.("Building manifest...");
|
|
1146
|
-
const n = await
|
|
1198
|
+
const n = await ot(t);
|
|
1147
1199
|
if (!n.success)
|
|
1148
1200
|
return {
|
|
1149
1201
|
success: !1,
|
|
1150
1202
|
error: {
|
|
1151
|
-
code:
|
|
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
|
|
1212
|
+
const r = await it({
|
|
1161
1213
|
appPath: t,
|
|
1162
1214
|
filePaths: a
|
|
1163
1215
|
});
|
|
1164
1216
|
s?.("Running typecheck...");
|
|
1165
|
-
const o = await
|
|
1217
|
+
const o = await Te(t);
|
|
1166
1218
|
if (o.length > 0) {
|
|
1167
1219
|
const d = o.map(
|
|
1168
|
-
(
|
|
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:
|
|
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 =
|
|
1232
|
+
const l = ct({
|
|
1181
1233
|
manifest: i,
|
|
1182
1234
|
builtFileInfos: r.builtFileInfos
|
|
1183
1235
|
});
|
|
1184
|
-
await
|
|
1185
|
-
const c =
|
|
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
|
|
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 =
|
|
1248
|
+
u.tarballPath = I.join(c, p);
|
|
1197
1249
|
}
|
|
1198
1250
|
return { success: !0, data: u };
|
|
1199
|
-
},
|
|
1200
|
-
constructor() {
|
|
1201
|
-
this.configPath =
|
|
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 ??
|
|
1256
|
+
this.activeRemote = t ?? P;
|
|
1205
1257
|
}
|
|
1206
1258
|
static getActiveRemote() {
|
|
1207
1259
|
return this.activeRemote;
|
|
1208
1260
|
}
|
|
1209
1261
|
getActiveRemoteName() {
|
|
1210
|
-
return
|
|
1262
|
+
return pe.getActiveRemote();
|
|
1211
1263
|
}
|
|
1212
1264
|
async readRawConfig() {
|
|
1213
|
-
await
|
|
1214
|
-
const t = await
|
|
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 ===
|
|
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:
|
|
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
|
|
1236
|
-
i.remotes[
|
|
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
|
|
1241
|
-
i.remotes[
|
|
1292
|
+
const p = u === "default" ? P : u;
|
|
1293
|
+
i.remotes[p] = d;
|
|
1242
1294
|
}
|
|
1243
|
-
n && !i.remotes[
|
|
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" ?
|
|
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
|
|
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 =
|
|
1321
|
+
s.version = ge, s.remotes || (s.remotes = {});
|
|
1273
1322
|
const i = s.remotes[n] || { apiUrl: "" };
|
|
1274
|
-
s.remotes[n] = { ...i, ...t }, await
|
|
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
|
|
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(
|
|
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 [
|
|
1339
|
+
return [P];
|
|
1291
1340
|
}
|
|
1292
1341
|
}
|
|
1293
1342
|
async getDefaultRemote() {
|
|
1294
1343
|
try {
|
|
1295
|
-
return (await this.readRawConfig()).defaultRemote ??
|
|
1344
|
+
return (await this.readRawConfig()).defaultRemote ?? P;
|
|
1296
1345
|
} catch {
|
|
1297
|
-
return
|
|
1346
|
+
return P;
|
|
1298
1347
|
}
|
|
1299
1348
|
}
|
|
1300
1349
|
async setDefaultRemote(t) {
|
|
1301
1350
|
const s = await this.readRawConfig();
|
|
1302
|
-
s.defaultRemote = t, await
|
|
1351
|
+
s.defaultRemote = t, await B(x.dirname(this.configPath)), await H(this.configPath, JSON.stringify(s, null, 2));
|
|
1303
1352
|
}
|
|
1304
1353
|
};
|
|
1305
|
-
|
|
1306
|
-
let
|
|
1307
|
-
class
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
1379
|
+
oe.red(
|
|
1331
1380
|
"Access denied. Check your API key and workspace permissions."
|
|
1332
1381
|
)
|
|
1333
1382
|
) : r.code === "ECONNREFUSED" && console.error(
|
|
1334
|
-
|
|
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
|
|
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
|
|
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 =
|
|
1395
|
-
if (
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
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
|
|
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
|
|
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 (
|
|
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 (
|
|
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
|
|
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
|
-
},
|
|
1681
|
-
const t =
|
|
1682
|
-
return
|
|
1726
|
+
}, Ds = (e) => {
|
|
1727
|
+
const t = x.extname(e).toLowerCase();
|
|
1728
|
+
return xs[t] || "application/octet-stream";
|
|
1683
1729
|
};
|
|
1684
|
-
class
|
|
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
|
|
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
|
|
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 =
|
|
1786
|
-
if (!
|
|
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 =
|
|
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 =
|
|
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
|
-
}),
|
|
1850
|
+
}), p = JSON.stringify({
|
|
1805
1851
|
0: ["variables.file"]
|
|
1806
|
-
}),
|
|
1807
|
-
|
|
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
|
|
1858
|
+
const v = await this.client.post(
|
|
1813
1859
|
"/metadata",
|
|
1814
|
-
|
|
1860
|
+
h
|
|
1815
1861
|
);
|
|
1816
|
-
return
|
|
1862
|
+
return v.data.errors ? {
|
|
1817
1863
|
success: !1,
|
|
1818
|
-
error:
|
|
1864
|
+
error: v.data.errors[0]?.message || "Failed to upload file"
|
|
1819
1865
|
} : {
|
|
1820
1866
|
success: !0,
|
|
1821
|
-
data:
|
|
1867
|
+
data: v.data.data.uploadApplicationFile,
|
|
1822
1868
|
message: `Successfully uploaded ${r}`
|
|
1823
1869
|
};
|
|
1824
1870
|
} catch (a) {
|
|
1825
|
-
return
|
|
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
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
2037
|
+
const r = Mt(a.data.data);
|
|
1992
2038
|
return {
|
|
1993
2039
|
success: !0,
|
|
1994
|
-
data:
|
|
2040
|
+
data: Bt(r),
|
|
1995
2041
|
message: `Successfully loaded schema from ${t}`
|
|
1996
2042
|
};
|
|
1997
2043
|
} catch (n) {
|
|
1998
|
-
if (
|
|
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
|
|
2053
|
+
class j {
|
|
2008
2054
|
constructor(t) {
|
|
2009
|
-
this.apiClient = new
|
|
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
|
|
2108
|
+
const Ms = async (e) => {
|
|
2063
2109
|
const { tarballPath: t, onProgress: s } = e;
|
|
2064
|
-
e.remote &&
|
|
2065
|
-
const n =
|
|
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:
|
|
2123
|
+
code: m.DEPLOY_FAILED,
|
|
2078
2124
|
message: `Upload failed: ${a.error}`
|
|
2079
2125
|
}
|
|
2080
2126
|
};
|
|
2081
|
-
},
|
|
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
|
-
},
|
|
2093
|
-
const t = e ? [e] :
|
|
2163
|
+
}, Vs = async (e) => {
|
|
2164
|
+
const t = e ? [e] : Hs;
|
|
2094
2165
|
for (const s of t)
|
|
2095
|
-
if (await
|
|
2166
|
+
if (await ut(s))
|
|
2096
2167
|
return `http://localhost:${s}`;
|
|
2097
2168
|
return null;
|
|
2098
|
-
},
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
const s =
|
|
2102
|
-
if (!
|
|
2103
|
-
|
|
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
|
|
2107
|
-
},
|
|
2250
|
+
return await Gt(s);
|
|
2251
|
+
}, zs = (e, t) => t.logicFunctions.some(
|
|
2108
2252
|
(s) => s.universalIdentifier === e.universalIdentifier
|
|
2109
|
-
),
|
|
2110
|
-
e.remote &&
|
|
2111
|
-
const t = new
|
|
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:
|
|
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:
|
|
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 &&
|
|
2133
|
-
), a = i.find((o) => "
|
|
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:
|
|
2139
|
-
message: `Function "${
|
|
2282
|
+
code: ce.FUNCTION_NOT_FOUND,
|
|
2283
|
+
message: `Function "${Be(e)}" not found in application.`,
|
|
2140
2284
|
details: {
|
|
2141
|
-
identifier:
|
|
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:
|
|
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
|
-
},
|
|
2171
|
-
() =>
|
|
2172
|
-
|
|
2173
|
-
),
|
|
2174
|
-
e.remote &&
|
|
2175
|
-
const t = new
|
|
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:
|
|
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:
|
|
2336
|
+
code: m.INSTALL_FAILED,
|
|
2193
2337
|
message: i
|
|
2194
2338
|
}
|
|
2195
2339
|
};
|
|
2196
2340
|
}
|
|
2197
2341
|
return { success: !0, data: void 0 };
|
|
2198
|
-
},
|
|
2199
|
-
const { appPath: t, onProgress: s } = e, n = await
|
|
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
|
-
|
|
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:
|
|
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
|
-
},
|
|
2366
|
+
}, Jn = (e) => U(() => Ws(e), m.PUBLISH_FAILED), Ks = async (e) => {
|
|
2223
2367
|
const { apiKey: t, apiUrl: s, remote: n } = e;
|
|
2224
|
-
n &&
|
|
2225
|
-
const i = new
|
|
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
|
|
2376
|
+
}), (await new j().validateAuth()).authValid ? { success: !0, data: void 0 } : (await i.clearConfig(), {
|
|
2233
2377
|
success: !1,
|
|
2234
2378
|
error: {
|
|
2235
|
-
code:
|
|
2379
|
+
code: V.AUTH_FAILED,
|
|
2236
2380
|
message: "Authentication failed. Please check your credentials."
|
|
2237
2381
|
}
|
|
2238
2382
|
});
|
|
2239
|
-
},
|
|
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>`,
|
|
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">${
|
|
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>`,
|
|
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
|
-
}),
|
|
2462
|
+
}), Zs = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), en = (e) => pt({
|
|
2319
2463
|
title: "Authentication failed",
|
|
2320
|
-
message: `${
|
|
2464
|
+
message: `${Zs(e)}<br>Please return to the terminal and try again.`,
|
|
2321
2465
|
isSuccess: !1
|
|
2322
|
-
}),
|
|
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 =
|
|
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"),
|
|
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,
|
|
2483
|
+
c.writeHead(200, h), c.end(Qs), i({ success: !0, code: d });
|
|
2340
2484
|
else {
|
|
2341
|
-
const
|
|
2342
|
-
c.writeHead(200,
|
|
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
|
-
},
|
|
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
|
-
|
|
2521
|
+
ze(t, s, (i) => {
|
|
2378
2522
|
n(!i);
|
|
2379
2523
|
});
|
|
2380
2524
|
});
|
|
2381
|
-
},
|
|
2382
|
-
const e =
|
|
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
|
-
},
|
|
2528
|
+
}, an = async (e) => {
|
|
2385
2529
|
const { apiUrl: t, remote: s, timeoutMs: n } = e;
|
|
2386
|
-
s &&
|
|
2387
|
-
const i = new
|
|
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
|
|
2534
|
+
r = (await S.get(a)).data;
|
|
2391
2535
|
} catch {
|
|
2392
2536
|
return {
|
|
2393
2537
|
success: !1,
|
|
2394
2538
|
error: {
|
|
2395
|
-
code:
|
|
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:
|
|
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 } =
|
|
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
|
|
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
|
|
2418
|
-
if (!
|
|
2561
|
+
const h = await u.waitForCallback();
|
|
2562
|
+
if (!h.success)
|
|
2419
2563
|
return {
|
|
2420
2564
|
success: !1,
|
|
2421
2565
|
error: {
|
|
2422
|
-
code:
|
|
2423
|
-
message:
|
|
2566
|
+
code: V.AUTH_FAILED,
|
|
2567
|
+
message: h.error
|
|
2424
2568
|
}
|
|
2425
2569
|
};
|
|
2426
|
-
const
|
|
2570
|
+
const v = await S.post(r.token_endpoint, {
|
|
2427
2571
|
grant_type: "authorization_code",
|
|
2428
|
-
code:
|
|
2572
|
+
code: h.code,
|
|
2429
2573
|
code_verifier: l,
|
|
2430
2574
|
redirect_uri: u.callbackUrl,
|
|
2431
2575
|
client_id: o
|
|
2432
|
-
}), { access_token:
|
|
2576
|
+
}), { access_token: T, refresh_token: E } = v.data;
|
|
2433
2577
|
return await i.setConfig({
|
|
2434
2578
|
apiUrl: t,
|
|
2435
|
-
accessToken:
|
|
2436
|
-
refreshToken:
|
|
2579
|
+
accessToken: T,
|
|
2580
|
+
refreshToken: E,
|
|
2437
2581
|
oauthClientId: o
|
|
2438
|
-
}), (await new
|
|
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:
|
|
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
|
-
},
|
|
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
|
|
2454
|
-
`docker inspect -f '{{.State.Running}}' ${
|
|
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
|
-
},
|
|
2604
|
+
}, He = (e = de) => {
|
|
2605
|
+
const t = e === dt ? mt : ft;
|
|
2461
2606
|
try {
|
|
2462
|
-
const
|
|
2463
|
-
`docker inspect -f '{{range .Config.Env}}{{println .}}{{end}}' ${
|
|
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
|
|
2611
|
+
return n ? parseInt(n[1], 10) : t;
|
|
2467
2612
|
} catch {
|
|
2468
|
-
return
|
|
2613
|
+
return t;
|
|
2469
2614
|
}
|
|
2470
|
-
},
|
|
2615
|
+
}, cn = (e = de) => {
|
|
2471
2616
|
try {
|
|
2472
|
-
return
|
|
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
|
-
},
|
|
2623
|
+
}, ln = () => {
|
|
2479
2624
|
try {
|
|
2480
|
-
return
|
|
2625
|
+
return te("docker info", { stdio: "ignore" }), !0;
|
|
2481
2626
|
} catch {
|
|
2482
2627
|
return !1;
|
|
2483
2628
|
}
|
|
2484
|
-
},
|
|
2485
|
-
const
|
|
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",
|
|
2632
|
+
["logs", "-f", "--since", "1s", t],
|
|
2488
2633
|
{ stdio: ["ignore", "pipe", "pipe"] }
|
|
2489
2634
|
);
|
|
2490
|
-
|
|
2635
|
+
i.on("error", () => {
|
|
2491
2636
|
});
|
|
2492
|
-
let
|
|
2493
|
-
const
|
|
2494
|
-
const
|
|
2495
|
-
if (
|
|
2496
|
-
|
|
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
|
|
2499
|
-
|
|
2500
|
-
} else
|
|
2501
|
-
`),
|
|
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
|
|
2504
|
-
const
|
|
2505
|
-
|
|
2506
|
-
const
|
|
2648
|
+
let o = "";
|
|
2649
|
+
const l = (c) => {
|
|
2650
|
+
o += c.toString();
|
|
2651
|
+
const u = o.split(`
|
|
2507
2652
|
`);
|
|
2508
|
-
|
|
2653
|
+
o = u.pop() ?? "", u.forEach(r);
|
|
2509
2654
|
};
|
|
2510
|
-
|
|
2655
|
+
i.stdout?.on("data", l), i.stderr?.on("data", l);
|
|
2511
2656
|
try {
|
|
2512
|
-
for (; Date.now() -
|
|
2513
|
-
if (await
|
|
2514
|
-
return
|
|
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
|
-
(
|
|
2662
|
+
(c) => setTimeout(c, un)
|
|
2518
2663
|
);
|
|
2519
2664
|
}
|
|
2520
|
-
return
|
|
2665
|
+
return a && n(`Failed
|
|
2521
2666
|
`), !1;
|
|
2522
2667
|
} finally {
|
|
2523
|
-
|
|
2524
|
-
}
|
|
2525
|
-
},
|
|
2526
|
-
const { onProgress: t } = e, s = await
|
|
2527
|
-
if (
|
|
2528
|
-
const
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
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(
|
|
2680
|
+
data: { port: parseInt(h, 10), url: o }
|
|
2534
2681
|
};
|
|
2535
2682
|
}
|
|
2536
|
-
if (!
|
|
2683
|
+
if (!ln())
|
|
2537
2684
|
return {
|
|
2538
2685
|
success: !1,
|
|
2539
2686
|
error: {
|
|
2540
|
-
code:
|
|
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 (
|
|
2545
|
-
const
|
|
2546
|
-
if (t?.("Container is running, waiting for it to become healthy..."), !await
|
|
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:
|
|
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
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
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
|
-
|
|
2719
|
+
n,
|
|
2571
2720
|
"-p",
|
|
2572
|
-
`${
|
|
2721
|
+
`${l}:${l}`,
|
|
2573
2722
|
"-e",
|
|
2574
|
-
`NODE_PORT=${
|
|
2723
|
+
`NODE_PORT=${l}`,
|
|
2575
2724
|
"-e",
|
|
2576
|
-
`SERVER_URL=http://localhost:${
|
|
2725
|
+
`SERVER_URL=http://localhost:${l}`,
|
|
2577
2726
|
"-v",
|
|
2578
|
-
|
|
2727
|
+
`${a}:/data/postgres`,
|
|
2579
2728
|
"-v",
|
|
2580
|
-
|
|
2581
|
-
|
|
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:
|
|
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
|
|
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:
|
|
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
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
()
|
|
2605
|
-
|
|
2606
|
-
)
|
|
2607
|
-
|
|
2608
|
-
|
|
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:
|
|
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:
|
|
2947
|
+
code: m.UNINSTALL_FAILED,
|
|
2626
2948
|
message: i
|
|
2627
2949
|
}
|
|
2628
2950
|
};
|
|
2629
2951
|
}
|
|
2630
2952
|
return { success: !0, data: void 0 };
|
|
2631
|
-
},
|
|
2953
|
+
}, Qn = (e) => U(() => hn(e), m.UNINSTALL_FAILED);
|
|
2632
2954
|
export {
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
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
|
};
|