attio 0.0.1-experimental.20250324 → 0.0.1-experimental.20250325
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/lib/api/fetch-versions.js +0 -24
- package/lib/api/get-app-info.js +2 -2
- package/lib/commands/dev.js +7 -1
- package/lib/commands/version/list.js +4 -5
- package/lib/machines/actions.js +1 -0
- package/lib/machines/actors.js +94 -34
- package/lib/machines/create-version-machine.js +116 -123
- package/lib/machines/dev-machine.js +146 -358
- package/lib/machines/init-machine.js +57 -134
- package/package.json +1 -1
- package/lib/api/add-connection-definition.js +0 -32
- package/lib/api/load-app-id.js +0 -9
- package/lib/api/load-dev-slug.js +0 -9
- package/lib/schema.js +0 -33
- package/lib/templates/common/attio.json +0 -4
- package/lib/util/app-config.js +0 -51
- package/lib/util/load-developer-config.js +0 -92
- package/lib/util/print-install-instructions.js +0 -32
|
@@ -6,8 +6,6 @@ import { completeBundleUpload } from "../api/complete-bundle-upload.js";
|
|
|
6
6
|
import { createDevVersion } from "../api/create-dev-version.js";
|
|
7
7
|
import { startGraphqlServer } from "../api/start-graphql-server.js";
|
|
8
8
|
import { startUpload } from "../api/start-upload.js";
|
|
9
|
-
import { loadAppConfigFile } from "../util/app-config.js";
|
|
10
|
-
import { loadDeveloperConfig, loadInitialDeveloperConfig, saveTargetWorkspaceToConfig, } from "../util/load-developer-config.js";
|
|
11
9
|
import notifier from "node-notifier";
|
|
12
10
|
import { loadEnv } from "../util/load-env.js";
|
|
13
11
|
import { loadAttioCliPackageJson } from "../util/load-attio-cli-package-json.js";
|
|
@@ -21,10 +19,8 @@ import { printMessage } from "../util/print-message.js";
|
|
|
21
19
|
import { printJsError, printTsError } from "../util/typescript.js";
|
|
22
20
|
import { clearTerminal } from "../util/clear-terminal.js";
|
|
23
21
|
import { setTerminalTitle } from "../util/set-terminal-title.js";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import { askWithTypedChoices, fromCallbackWithErrorHandling } from "./actors.js";
|
|
27
|
-
import { fetchWorkspaces } from "../api/fetch-workspaces.js";
|
|
22
|
+
import { printLogo, showActorError } from "./actions.js";
|
|
23
|
+
import { askWithTypedChoices, authenticate, determineWorkspace, fromCallbackWithErrorHandling, loadAppInfo, loadAppSlug, } from "./actors.js";
|
|
28
24
|
import { ensureAuthed } from "../api/ensure-authed.js";
|
|
29
25
|
process.on("SIGINT", () => {
|
|
30
26
|
process.stdout.write("\x1B[?25h");
|
|
@@ -37,33 +33,18 @@ export const devMachine = setup({
|
|
|
37
33
|
types: {
|
|
38
34
|
context: {},
|
|
39
35
|
events: {},
|
|
36
|
+
input: {},
|
|
40
37
|
children: {},
|
|
41
38
|
},
|
|
42
|
-
guards: {
|
|
43
|
-
"have dev version": ({ context }) => Boolean(context.devVersion),
|
|
44
|
-
"have typescript errors": (_, params) => Boolean(params.typeScriptErrors?.length),
|
|
45
|
-
"have target workspace": (_, params) => Boolean(params.config?.target_workspace_id),
|
|
46
|
-
"have workspaces": (_, params) => Boolean(params.output?.length),
|
|
47
|
-
"is workspace admin": (_, params) => params.output.access_level === "admin",
|
|
48
|
-
"only one workspace and admin": (_, params) => params.output.length === 1 && params.output[0].access_level === "admin",
|
|
49
|
-
"only one workspace and not admin": (_, params) => params.output.length === 1 && params.output[0].access_level !== "admin",
|
|
50
|
-
},
|
|
51
39
|
actors: {
|
|
52
40
|
"javascript": jsMachine,
|
|
53
41
|
"typescript": tsMachine,
|
|
54
42
|
"env": envMachine,
|
|
55
43
|
"code-gen": codeGenMachine,
|
|
56
44
|
"askForWorkspace": askWithTypedChoices(),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
sendBack({ type: "Initialization Error", error: config });
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
ensureAuthed().then((token) => {
|
|
64
|
-
sendBack({ type: "Initialized", config: { ...config, token } });
|
|
65
|
-
});
|
|
66
|
-
}),
|
|
45
|
+
authenticate,
|
|
46
|
+
loadAppSlug,
|
|
47
|
+
loadAppInfo,
|
|
67
48
|
"keyboard": fromCallbackWithErrorHandling(({ sendBack }) => {
|
|
68
49
|
if (!process.stdin.isTTY)
|
|
69
50
|
return;
|
|
@@ -108,64 +89,29 @@ export const devMachine = setup({
|
|
|
108
89
|
}
|
|
109
90
|
};
|
|
110
91
|
}),
|
|
111
|
-
|
|
112
|
-
"
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const app = loadAppConfigFile();
|
|
126
|
-
if (typeof app === "string")
|
|
127
|
-
throw app;
|
|
128
|
-
const environmentVariables = await loadEnv();
|
|
129
|
-
if (typeof environmentVariables === "string")
|
|
130
|
-
throw environmentVariables;
|
|
131
|
-
const packageJson = loadAttioCliPackageJson();
|
|
132
|
-
if (typeof packageJson === "string")
|
|
133
|
-
throw packageJson;
|
|
134
|
-
const devVersion = await createDevVersion({
|
|
135
|
-
token: await ensureAuthed(),
|
|
136
|
-
devSlug: config.developer_slug,
|
|
137
|
-
appId: app.id,
|
|
138
|
-
targetWorkspaceId: config.target_workspace_id,
|
|
139
|
-
environmentVariables,
|
|
140
|
-
cliVersion: packageJson.version,
|
|
141
|
-
});
|
|
142
|
-
sendBack({
|
|
143
|
-
type: "Upload Prepared",
|
|
144
|
-
devVersion: { ...devVersion, app_slug: app.slug },
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
prepareUpload().catch((error) => {
|
|
148
|
-
if (error instanceof Error &&
|
|
149
|
-
error.message.includes("invalid authentication token")) {
|
|
150
|
-
sendBack({
|
|
151
|
-
type: "Auth Error",
|
|
152
|
-
error,
|
|
153
|
-
});
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
sendBack({
|
|
157
|
-
type: "Upload Error",
|
|
158
|
-
error: typeof error === "string" ? new Error(error) : error,
|
|
159
|
-
});
|
|
92
|
+
determineWorkspace,
|
|
93
|
+
"prepareUpload": fromPromise(async ({ input: { appInfo, workspace } }) => {
|
|
94
|
+
const environmentVariables = await loadEnv();
|
|
95
|
+
if (typeof environmentVariables === "string")
|
|
96
|
+
throw environmentVariables;
|
|
97
|
+
const packageJson = loadAttioCliPackageJson();
|
|
98
|
+
if (typeof packageJson === "string")
|
|
99
|
+
throw packageJson;
|
|
100
|
+
const devVersion = await createDevVersion({
|
|
101
|
+
token: await ensureAuthed(),
|
|
102
|
+
appId: appInfo.app_id,
|
|
103
|
+
targetWorkspaceId: workspace.id,
|
|
104
|
+
environmentVariables,
|
|
105
|
+
cliVersion: packageJson.version,
|
|
160
106
|
});
|
|
107
|
+
return devVersion;
|
|
161
108
|
}),
|
|
162
|
-
"upload":
|
|
109
|
+
"upload": fromPromise(async ({ input: { token, contents, devVersion: { app_dev_version_id: devVersionId }, appInfo: { app_id: appId }, }, }) => {
|
|
163
110
|
const spinner = new Spinner();
|
|
164
|
-
|
|
111
|
+
try {
|
|
165
112
|
spinner.start("Uploading...");
|
|
166
113
|
const { client_bundle_upload_url, server_bundle_upload_url, app_dev_version_bundle_id: bundleId, } = await startUpload({
|
|
167
114
|
token,
|
|
168
|
-
developerSlug,
|
|
169
115
|
appId,
|
|
170
116
|
devVersionId,
|
|
171
117
|
});
|
|
@@ -192,26 +138,29 @@ export const devMachine = setup({
|
|
|
192
138
|
});
|
|
193
139
|
await completeBundleUpload({
|
|
194
140
|
token,
|
|
195
|
-
developerSlug,
|
|
196
141
|
appId,
|
|
197
142
|
devVersionId,
|
|
198
143
|
bundleId,
|
|
199
144
|
});
|
|
200
145
|
spinner.success(`Upload completed at ${new Date().toLocaleString()}.`);
|
|
201
|
-
sendBack({ type: "Upload Complete" });
|
|
202
146
|
notifier.notify({
|
|
203
147
|
title: "Upload Complete",
|
|
204
148
|
message: "New bundle uploaded to Attio",
|
|
205
149
|
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
if (error instanceof Error) {
|
|
153
|
+
spinner.error(`Upload failed: ${error.message}`);
|
|
154
|
+
notifier.notify({
|
|
155
|
+
title: "Upload Failed",
|
|
156
|
+
message: "Bundle upload to Attio failed",
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
finally {
|
|
162
|
+
spinner.stop();
|
|
163
|
+
}
|
|
215
164
|
}),
|
|
216
165
|
"watch": fromCallbackWithErrorHandling(({ sendBack }) => {
|
|
217
166
|
const watcher = chokidar.watch(["src", ".env"], {
|
|
@@ -225,12 +174,11 @@ export const devMachine = setup({
|
|
|
225
174
|
};
|
|
226
175
|
}),
|
|
227
176
|
"graphql": fromCallbackWithErrorHandling(({ sendBack }) => startGraphqlServer(sendBack)),
|
|
228
|
-
"loadInstallation": fromCallbackWithErrorHandling(({ sendBack, input }) => {
|
|
177
|
+
"loadInstallation": fromCallbackWithErrorHandling(({ sendBack, input: { token, appInfo, workspace } }) => {
|
|
229
178
|
fetchInstallation({
|
|
230
|
-
token
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
workspaceId: input.config.target_workspace_id,
|
|
179
|
+
token,
|
|
180
|
+
appId: appInfo.app_id,
|
|
181
|
+
workspaceId: workspace.id,
|
|
234
182
|
}).then((installation) => {
|
|
235
183
|
if (installation) {
|
|
236
184
|
sendBack({ type: "Found Installation" });
|
|
@@ -240,13 +188,12 @@ export const devMachine = setup({
|
|
|
240
188
|
}
|
|
241
189
|
});
|
|
242
190
|
}),
|
|
243
|
-
"pollForInstallation": fromCallbackWithErrorHandling(({ sendBack, input }) => {
|
|
191
|
+
"pollForInstallation": fromCallbackWithErrorHandling(({ sendBack, input: { token, appInfo, workspace } }) => {
|
|
244
192
|
const interval = setInterval(() => {
|
|
245
193
|
fetchInstallation({
|
|
246
|
-
token
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
workspaceId: input.config.target_workspace_id,
|
|
194
|
+
token,
|
|
195
|
+
appId: appInfo.app_id,
|
|
196
|
+
workspaceId: workspace.id,
|
|
250
197
|
}).then((installation) => {
|
|
251
198
|
if (installation) {
|
|
252
199
|
sendBack({ type: "Found Installation" });
|
|
@@ -258,15 +205,10 @@ export const devMachine = setup({
|
|
|
258
205
|
},
|
|
259
206
|
actions: {
|
|
260
207
|
clearUploadError: assign({ uploadError: undefined }),
|
|
261
|
-
|
|
262
|
-
printInstallInstructions(context.configError);
|
|
263
|
-
},
|
|
208
|
+
showActorError,
|
|
264
209
|
printAuthError: (_, params) => {
|
|
265
210
|
process.stderr.write(`${params.error.message}\n\n`);
|
|
266
211
|
},
|
|
267
|
-
printUploadError: (_, params) => {
|
|
268
|
-
printMessage(params.uploadError.message);
|
|
269
|
-
},
|
|
270
212
|
printError: (_, params) => {
|
|
271
213
|
printMessage(params.error);
|
|
272
214
|
},
|
|
@@ -308,7 +250,7 @@ export const devMachine = setup({
|
|
|
308
250
|
open(`http://localhost:${context.graphqlPort}/graphql`);
|
|
309
251
|
},
|
|
310
252
|
openInstallPage: ({ context }) => {
|
|
311
|
-
open(`${APP}/${context.workspace.slug}/settings/apps/${context.
|
|
253
|
+
open(`${APP}/${context.workspace.slug}/settings/apps/${context.appSlug}`);
|
|
312
254
|
},
|
|
313
255
|
saveTypeScriptErrors: assign({
|
|
314
256
|
typeScriptErrors: (_, params) => params.errors,
|
|
@@ -331,37 +273,26 @@ export const devMachine = setup({
|
|
|
331
273
|
sendCodeGenerationDone: enqueueActions(({ enqueue }) => {
|
|
332
274
|
enqueue.sendTo("typescript", { type: "Change" });
|
|
333
275
|
}),
|
|
334
|
-
|
|
335
|
-
|
|
276
|
+
setToken: assign({
|
|
277
|
+
token: (_, params) => params.output,
|
|
336
278
|
}),
|
|
337
|
-
|
|
338
|
-
|
|
279
|
+
setAppInfo: assign({
|
|
280
|
+
appInfo: (_, params) => params.output,
|
|
339
281
|
}),
|
|
340
|
-
|
|
341
|
-
|
|
282
|
+
setAppSlug: assign({
|
|
283
|
+
appSlug: (_, params) => params.output,
|
|
284
|
+
}),
|
|
285
|
+
setWorkspace: assign({
|
|
286
|
+
workspace: (_, params) => params.output,
|
|
342
287
|
}),
|
|
343
288
|
setGraphqlPort: assign({
|
|
344
289
|
graphqlPort: (_, params) => params.port,
|
|
345
290
|
}),
|
|
346
|
-
setTerminalTitle: (
|
|
347
|
-
setTerminalTitle(
|
|
348
|
-
? `attio dev – ${context.devVersion.app_id}`
|
|
349
|
-
: `attio dev`);
|
|
350
|
-
},
|
|
351
|
-
setTargetWorkspace: assign({
|
|
352
|
-
config: (_, params) => ({
|
|
353
|
-
...params.config,
|
|
354
|
-
target_workspace_id: params.workspace.id,
|
|
355
|
-
}),
|
|
356
|
-
}),
|
|
357
|
-
saveTargetWorkspaceToConfig: (_, params) => {
|
|
358
|
-
saveTargetWorkspaceToConfig(params.workspace.id);
|
|
291
|
+
setTerminalTitle: (_, params) => {
|
|
292
|
+
setTerminalTitle(params.devVersion?.app_id ? `attio dev – ${params.devVersion.app_id}` : `attio dev`);
|
|
359
293
|
},
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}),
|
|
363
|
-
setWorkspace: assign({
|
|
364
|
-
workspace: (_, params) => params.output,
|
|
294
|
+
setDevVersion: assign({
|
|
295
|
+
devVersion: (_, params) => params.output,
|
|
365
296
|
}),
|
|
366
297
|
setSuccess: assign({
|
|
367
298
|
jsContents: (_, params) => params.contents,
|
|
@@ -372,9 +303,15 @@ export const devMachine = setup({
|
|
|
372
303
|
}),
|
|
373
304
|
},
|
|
374
305
|
}).createMachine({
|
|
375
|
-
context: {
|
|
306
|
+
context: ({ input }) => ({
|
|
307
|
+
jsContents: ["", ""],
|
|
308
|
+
appSlug: "",
|
|
309
|
+
token: "",
|
|
310
|
+
appInfo: { app_id: "", title: "" },
|
|
311
|
+
...input,
|
|
312
|
+
}),
|
|
376
313
|
id: "Dev Machine",
|
|
377
|
-
initial: "
|
|
314
|
+
initial: "Authenticate",
|
|
378
315
|
states: {
|
|
379
316
|
"Watching": {
|
|
380
317
|
invoke: [
|
|
@@ -438,91 +375,63 @@ export const devMachine = setup({
|
|
|
438
375
|
entry: "printWatching",
|
|
439
376
|
},
|
|
440
377
|
"Uploading": {
|
|
441
|
-
on: {
|
|
442
|
-
"Upload Complete": "Watching",
|
|
443
|
-
},
|
|
444
378
|
invoke: {
|
|
445
379
|
src: "upload",
|
|
446
380
|
input: ({ context }) => {
|
|
447
|
-
if (!context.devVersion)
|
|
448
|
-
throw new Error("No devVersion");
|
|
449
|
-
if (!context.config)
|
|
450
|
-
throw new Error("No config");
|
|
451
381
|
return {
|
|
452
382
|
devVersion: context.devVersion,
|
|
453
|
-
|
|
383
|
+
appInfo: context.appInfo,
|
|
384
|
+
token: context.token,
|
|
454
385
|
contents: context.jsContents,
|
|
455
386
|
};
|
|
456
387
|
},
|
|
388
|
+
onDone: "Watching",
|
|
389
|
+
onError: {
|
|
390
|
+
target: "#Dev Machine.Error",
|
|
391
|
+
actions: { type: "showActorError", params: ({ event }) => event },
|
|
392
|
+
},
|
|
457
393
|
},
|
|
458
394
|
},
|
|
459
395
|
"Upload When Ready": {
|
|
460
396
|
always: {
|
|
461
|
-
target: "
|
|
462
|
-
guard:
|
|
397
|
+
target: "Uploading",
|
|
398
|
+
guard: ({ context }) => Boolean(context.devVersion),
|
|
463
399
|
reenter: true,
|
|
464
400
|
},
|
|
465
|
-
on: {
|
|
466
|
-
"Upload Prepared": {
|
|
467
|
-
target: "Can Upload?",
|
|
468
|
-
actions: { type: "setDevVersion", params: ({ event }) => event },
|
|
469
|
-
reenter: true,
|
|
470
|
-
},
|
|
471
|
-
},
|
|
472
|
-
},
|
|
473
|
-
"Upload Error": {
|
|
474
|
-
exit: "clearUploadError",
|
|
475
|
-
on: {
|
|
476
|
-
Change: {
|
|
477
|
-
target: "#Dev Machine.Watching.JavaScript",
|
|
478
|
-
reenter: true,
|
|
479
|
-
actions: "sendChange",
|
|
480
|
-
description: `Re-enter to invoke prepareUpload again`,
|
|
481
|
-
},
|
|
482
|
-
},
|
|
483
|
-
entry: {
|
|
484
|
-
type: "printUploadError",
|
|
485
|
-
params: ({ context }) => ({ uploadError: context.uploadError }),
|
|
486
|
-
},
|
|
487
|
-
},
|
|
488
|
-
"Can Upload?": {
|
|
489
|
-
always: [
|
|
490
|
-
{
|
|
491
|
-
target: "Watching",
|
|
492
|
-
guard: {
|
|
493
|
-
type: "have typescript errors",
|
|
494
|
-
params: ({ context }) => context,
|
|
495
|
-
},
|
|
496
|
-
reenter: true,
|
|
497
|
-
},
|
|
498
|
-
"Uploading",
|
|
499
|
-
],
|
|
500
401
|
},
|
|
501
402
|
},
|
|
502
403
|
initial: "Building",
|
|
503
404
|
on: {
|
|
504
|
-
"Upload Prepared": {
|
|
505
|
-
target: "JavaScript",
|
|
506
|
-
actions: [
|
|
507
|
-
{ type: "setDevVersion", params: ({ event }) => event },
|
|
508
|
-
"setTerminalTitle",
|
|
509
|
-
],
|
|
510
|
-
},
|
|
511
405
|
"Change": {
|
|
512
406
|
target: "JavaScript",
|
|
513
407
|
actions: "sendChange",
|
|
514
408
|
},
|
|
515
|
-
"Upload Error": {
|
|
516
|
-
target: ".Upload Error",
|
|
517
|
-
actions: { type: "setUploadError", params: ({ event }) => event },
|
|
518
|
-
},
|
|
519
409
|
"Auth Error": {
|
|
520
410
|
target: "#Dev Machine.Auth Error",
|
|
521
|
-
actions: {
|
|
411
|
+
actions: {
|
|
412
|
+
type: "printAuthError",
|
|
413
|
+
params: ({ event }) => event,
|
|
414
|
+
},
|
|
522
415
|
},
|
|
523
416
|
},
|
|
524
417
|
invoke: {
|
|
525
418
|
src: "prepareUpload",
|
|
419
|
+
input: ({ context }) => ({
|
|
420
|
+
appInfo: context.appInfo,
|
|
421
|
+
workspace: context.workspace,
|
|
422
|
+
}),
|
|
423
|
+
onDone: {
|
|
424
|
+
target: "JavaScript",
|
|
425
|
+
actions: [
|
|
426
|
+
{ type: "setDevVersion", params: ({ event }) => event },
|
|
427
|
+
{ type: "setTerminalTitle", params: ({ event }) => event },
|
|
428
|
+
],
|
|
429
|
+
reenter: true,
|
|
430
|
+
},
|
|
431
|
+
onError: {
|
|
432
|
+
target: "#Dev Machine.Error",
|
|
433
|
+
actions: { type: "showActorError", params: ({ event }) => event },
|
|
434
|
+
},
|
|
526
435
|
},
|
|
527
436
|
},
|
|
528
437
|
TypeScript: {
|
|
@@ -593,8 +502,10 @@ export const devMachine = setup({
|
|
|
593
502
|
invoke: {
|
|
594
503
|
src: "loadInstallation",
|
|
595
504
|
input: ({ context }) => ({
|
|
596
|
-
|
|
505
|
+
appInfo: context.appInfo,
|
|
506
|
+
token: context.token,
|
|
597
507
|
devVersion: context.devVersion,
|
|
508
|
+
workspace: context.workspace,
|
|
598
509
|
}),
|
|
599
510
|
},
|
|
600
511
|
on: {
|
|
@@ -612,8 +523,10 @@ export const devMachine = setup({
|
|
|
612
523
|
invoke: {
|
|
613
524
|
src: "pollForInstallation",
|
|
614
525
|
input: ({ context }) => ({
|
|
615
|
-
|
|
526
|
+
appInfo: context.appInfo,
|
|
527
|
+
token: context.token,
|
|
616
528
|
devVersion: context.devVersion,
|
|
529
|
+
workspace: context.workspace,
|
|
617
530
|
}),
|
|
618
531
|
},
|
|
619
532
|
on: {
|
|
@@ -641,201 +554,76 @@ export const devMachine = setup({
|
|
|
641
554
|
type: "parallel",
|
|
642
555
|
entry: "promptToOpenGraphQLExplorer",
|
|
643
556
|
},
|
|
644
|
-
"
|
|
645
|
-
|
|
646
|
-
"
|
|
647
|
-
|
|
648
|
-
|
|
557
|
+
"Authenticate": {
|
|
558
|
+
invoke: {
|
|
559
|
+
src: "authenticate",
|
|
560
|
+
onDone: {
|
|
561
|
+
target: "Loading App Slug",
|
|
649
562
|
reenter: true,
|
|
563
|
+
actions: { type: "setToken", params: ({ event }) => event },
|
|
650
564
|
},
|
|
651
|
-
|
|
652
|
-
target: "
|
|
565
|
+
onError: {
|
|
566
|
+
target: "Error",
|
|
653
567
|
actions: {
|
|
654
|
-
type: "
|
|
568
|
+
type: "showActorError",
|
|
655
569
|
params: ({ event }) => event,
|
|
656
570
|
},
|
|
657
571
|
},
|
|
658
572
|
},
|
|
659
|
-
invoke: {
|
|
660
|
-
src: "loadConfig",
|
|
661
|
-
},
|
|
662
|
-
},
|
|
663
|
-
"No Config": {
|
|
664
|
-
type: "final",
|
|
665
|
-
entry: "showConfigInstructions",
|
|
666
573
|
},
|
|
667
574
|
"Auth Error": {
|
|
668
575
|
type: "final",
|
|
669
576
|
},
|
|
670
|
-
"
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
},
|
|
679
|
-
"Loading Workspaces",
|
|
680
|
-
],
|
|
681
|
-
},
|
|
682
|
-
"Loading Workspaces": {
|
|
683
|
-
invoke: {
|
|
684
|
-
src: "loadWorkspaces",
|
|
685
|
-
input: ({ context }) => ({ token: context.config.token }),
|
|
686
|
-
onDone: [
|
|
687
|
-
{
|
|
688
|
-
target: "#Dev Machine.Loading Workspace Details",
|
|
689
|
-
guard: {
|
|
690
|
-
type: "only one workspace and admin",
|
|
691
|
-
params: ({ event }) => event,
|
|
692
|
-
},
|
|
693
|
-
reenter: true,
|
|
694
|
-
actions: [
|
|
695
|
-
{
|
|
696
|
-
type: "setTargetWorkspace",
|
|
697
|
-
params: ({ context, event }) => ({
|
|
698
|
-
config: context.config,
|
|
699
|
-
workspace: event.output[0],
|
|
700
|
-
}),
|
|
701
|
-
},
|
|
702
|
-
{
|
|
703
|
-
type: "saveTargetWorkspaceToConfig",
|
|
704
|
-
params: ({ event }) => ({ workspace: event.output[0] }),
|
|
705
|
-
},
|
|
706
|
-
],
|
|
707
|
-
},
|
|
708
|
-
{
|
|
709
|
-
target: "#Dev Machine.Not admin of only workspace",
|
|
710
|
-
guard: {
|
|
711
|
-
type: "only one workspace and not admin",
|
|
712
|
-
params: ({ event }) => event,
|
|
713
|
-
},
|
|
714
|
-
reenter: true,
|
|
715
|
-
actions: {
|
|
716
|
-
type: "printError",
|
|
717
|
-
params: ({ event }) => ({
|
|
718
|
-
error: `You are not the admin of the workspace ${event.output[0].name}. Please ask an admin to make you an admin of the workspace or create your own workspace.
|
|
719
|
-
|
|
720
|
-
${APP}/welcome/workspace-details
|
|
721
|
-
`,
|
|
722
|
-
}),
|
|
723
|
-
},
|
|
724
|
-
},
|
|
725
|
-
{
|
|
726
|
-
target: "Ask for Workspace",
|
|
727
|
-
guard: { type: "have workspaces", params: ({ event }) => event },
|
|
728
|
-
actions: { type: "setWorkspaces", params: ({ event }) => event },
|
|
729
|
-
},
|
|
730
|
-
{
|
|
731
|
-
target: "No Workspaces",
|
|
732
|
-
reenter: true,
|
|
733
|
-
actions: {
|
|
734
|
-
type: "printError",
|
|
735
|
-
params: () => ({
|
|
736
|
-
error: `You are not the admin of any workspaces. Either request permission from an existing workspace or create your own.
|
|
737
|
-
|
|
738
|
-
${APP}/welcome/workspace-details
|
|
739
|
-
`,
|
|
740
|
-
}),
|
|
741
|
-
},
|
|
742
|
-
},
|
|
743
|
-
],
|
|
744
|
-
onError: {
|
|
745
|
-
target: "Failed to load workspaces",
|
|
746
|
-
actions: {
|
|
747
|
-
type: "printError",
|
|
748
|
-
params: ({ event }) => ({
|
|
749
|
-
error: `Failed to load workspaces: ${event.error}`,
|
|
750
|
-
}),
|
|
751
|
-
},
|
|
752
|
-
},
|
|
753
|
-
},
|
|
577
|
+
"Loading App Info": {
|
|
578
|
+
invoke: {
|
|
579
|
+
src: "loadAppInfo",
|
|
580
|
+
input: ({ context }) => context,
|
|
581
|
+
onDone: {
|
|
582
|
+
target: "Determine Workspace",
|
|
583
|
+
actions: { type: "setAppInfo", params: ({ event }) => event },
|
|
584
|
+
reenter: true,
|
|
754
585
|
},
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
input: ({ context }) => ({
|
|
759
|
-
message: "Choose a workspace",
|
|
760
|
-
choices: context.workspaces.map((workspace) => ({
|
|
761
|
-
name: workspace.name,
|
|
762
|
-
value: workspace,
|
|
763
|
-
})),
|
|
764
|
-
}),
|
|
765
|
-
onDone: [
|
|
766
|
-
{
|
|
767
|
-
target: "#Dev Machine.Loading Workspace Details",
|
|
768
|
-
actions: [
|
|
769
|
-
{
|
|
770
|
-
type: "setTargetWorkspace",
|
|
771
|
-
params: ({ context, event }) => ({
|
|
772
|
-
config: context.config,
|
|
773
|
-
workspace: event.output,
|
|
774
|
-
}),
|
|
775
|
-
},
|
|
776
|
-
{
|
|
777
|
-
type: "saveTargetWorkspaceToConfig",
|
|
778
|
-
params: ({ event }) => ({ workspace: event.output }),
|
|
779
|
-
},
|
|
780
|
-
],
|
|
781
|
-
guard: { type: "is workspace admin", params: ({ event }) => event },
|
|
782
|
-
reenter: true,
|
|
783
|
-
},
|
|
784
|
-
{
|
|
785
|
-
target: "#Dev Machine.Require Admin Workspace",
|
|
786
|
-
reenter: true,
|
|
787
|
-
actions: {
|
|
788
|
-
type: "printError",
|
|
789
|
-
params: ({ event }) => ({
|
|
790
|
-
error: `You are not the admin of the workspace ${event.output.name}. Please ask an admin to make you an admin of the workspace or create your own workspace.
|
|
791
|
-
|
|
792
|
-
${APP}/welcome/workspace-details
|
|
793
|
-
`,
|
|
794
|
-
}),
|
|
795
|
-
},
|
|
796
|
-
},
|
|
797
|
-
],
|
|
798
|
-
},
|
|
586
|
+
onError: {
|
|
587
|
+
target: "Error",
|
|
588
|
+
actions: { type: "showActorError", params: ({ event }) => event },
|
|
799
589
|
},
|
|
800
|
-
|
|
801
|
-
|
|
590
|
+
},
|
|
591
|
+
},
|
|
592
|
+
"Loading App Slug": {
|
|
593
|
+
invoke: {
|
|
594
|
+
src: "loadAppSlug",
|
|
595
|
+
onDone: {
|
|
596
|
+
target: "Loading App Info",
|
|
597
|
+
actions: { type: "setAppSlug", params: ({ event }) => event },
|
|
802
598
|
},
|
|
803
|
-
|
|
804
|
-
|
|
599
|
+
onError: {
|
|
600
|
+
target: "Error",
|
|
601
|
+
actions: { type: "showActorError", params: ({ event }) => event },
|
|
805
602
|
},
|
|
806
603
|
},
|
|
807
|
-
initial: "Need Target Workspace?",
|
|
808
|
-
},
|
|
809
|
-
"Require Admin Workspace": {
|
|
810
|
-
type: "final",
|
|
811
604
|
},
|
|
812
|
-
"
|
|
605
|
+
"Error": {
|
|
813
606
|
type: "final",
|
|
814
607
|
},
|
|
815
|
-
"
|
|
608
|
+
"Determine Workspace": {
|
|
816
609
|
invoke: {
|
|
817
|
-
src: "
|
|
818
|
-
input: ({ context }) =>
|
|
819
|
-
config: context.config,
|
|
820
|
-
}),
|
|
610
|
+
src: "determineWorkspace",
|
|
611
|
+
input: ({ context }) => context,
|
|
821
612
|
onDone: {
|
|
822
613
|
target: "Watching",
|
|
823
|
-
actions:
|
|
614
|
+
actions: [
|
|
615
|
+
{
|
|
616
|
+
type: "setWorkspace",
|
|
617
|
+
params: ({ event }) => event,
|
|
618
|
+
},
|
|
619
|
+
],
|
|
824
620
|
},
|
|
825
621
|
onError: {
|
|
826
|
-
target: "
|
|
827
|
-
actions: {
|
|
828
|
-
type: "printError",
|
|
829
|
-
params: () => ({
|
|
830
|
-
error: "Failed to load workspace details",
|
|
831
|
-
}),
|
|
832
|
-
},
|
|
622
|
+
target: "Error",
|
|
623
|
+
actions: { type: "showActorError", params: ({ event }) => event },
|
|
833
624
|
},
|
|
834
625
|
},
|
|
835
626
|
},
|
|
836
|
-
"Failed to load workspaces": {
|
|
837
|
-
type: "final",
|
|
838
|
-
},
|
|
839
627
|
},
|
|
840
628
|
entry: "printLogo",
|
|
841
629
|
});
|