attio 0.0.1-experimental.20250325.1 → 0.0.1-experimental.20250326
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-workspaces.js +13 -15
- package/lib/machines/actors.js +2 -3
- package/lib/machines/dev-machine.js +4 -14
- package/package.json +1 -1
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { API } from "../env.js";
|
|
3
3
|
import { handleError } from "./handle-error.js";
|
|
4
4
|
import { makeHeaders } from "./make-headers.js";
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
})
|
|
5
|
+
const workspaceResponseSchema = z.object({
|
|
6
|
+
workspace_id: z.string().uuid(),
|
|
7
|
+
slug: z.string(),
|
|
8
|
+
name: z.string(),
|
|
9
|
+
logo_url: z.string().nullable(),
|
|
10
|
+
});
|
|
11
|
+
const listDevWorkspacesResponseSchema = z.object({
|
|
12
|
+
workspaces: z.array(workspaceResponseSchema),
|
|
13
|
+
accurate_at: z.string().datetime(),
|
|
14
|
+
});
|
|
15
15
|
export async function fetchWorkspaces({ token }) {
|
|
16
|
-
const response = await fetch(`${
|
|
16
|
+
const response = await fetch(`${API}/dev-workspaces`, {
|
|
17
17
|
method: "GET",
|
|
18
18
|
headers: makeHeaders(token),
|
|
19
19
|
});
|
|
20
20
|
await handleError(response);
|
|
21
|
-
return
|
|
22
|
-
.parse(await response.json())
|
|
23
|
-
.map(({ workspace, membership }) => ({ ...workspace, ...membership }));
|
|
21
|
+
return listDevWorkspacesResponseSchema.parse(await response.json()).workspaces;
|
|
24
22
|
}
|
package/lib/machines/actors.js
CHANGED
|
@@ -77,7 +77,7 @@ export const askWithTypedChoices = () => fromPromise(async ({ input, }) => await
|
|
|
77
77
|
export const confirm = fromPromise(async ({ input }) => await confirmPrompt(input));
|
|
78
78
|
export const fromCallbackWithErrorHandling = (callback) => fromCallback((...args) => {
|
|
79
79
|
try {
|
|
80
|
-
callback(...args);
|
|
80
|
+
return callback(...args);
|
|
81
81
|
}
|
|
82
82
|
catch (error) {
|
|
83
83
|
args[0].sendBack({
|
|
@@ -97,8 +97,7 @@ export const determineWorkspace = fromPromise(async ({ input: { token, workspace
|
|
|
97
97
|
spinner.success(`Using workspace: ${workspace.name}`);
|
|
98
98
|
return workspace;
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
if (!hasAdmin) {
|
|
100
|
+
if (workspaces.length === 0) {
|
|
102
101
|
throw new Error(`You are not the admin of any workspaces. Either request permission from an existing workspace or create your own.
|
|
103
102
|
|
|
104
103
|
${APP}/welcome/workspace-details
|
|
@@ -100,7 +100,7 @@ export const devMachine = setup({
|
|
|
100
100
|
const devVersion = await createDevVersion({
|
|
101
101
|
token: await ensureAuthed(),
|
|
102
102
|
appId: appInfo.app_id,
|
|
103
|
-
targetWorkspaceId: workspace.
|
|
103
|
+
targetWorkspaceId: workspace.workspace_id,
|
|
104
104
|
environmentVariables,
|
|
105
105
|
cliVersion: packageJson.version,
|
|
106
106
|
});
|
|
@@ -178,7 +178,7 @@ export const devMachine = setup({
|
|
|
178
178
|
fetchInstallation({
|
|
179
179
|
token,
|
|
180
180
|
appId: appInfo.app_id,
|
|
181
|
-
workspaceId: workspace.
|
|
181
|
+
workspaceId: workspace.workspace_id,
|
|
182
182
|
}).then((installation) => {
|
|
183
183
|
if (installation) {
|
|
184
184
|
sendBack({ type: "Found Installation" });
|
|
@@ -193,7 +193,7 @@ export const devMachine = setup({
|
|
|
193
193
|
fetchInstallation({
|
|
194
194
|
token,
|
|
195
195
|
appId: appInfo.app_id,
|
|
196
|
-
workspaceId: workspace.
|
|
196
|
+
workspaceId: workspace.workspace_id,
|
|
197
197
|
}).then((installation) => {
|
|
198
198
|
if (installation) {
|
|
199
199
|
sendBack({ type: "Found Installation" });
|
|
@@ -354,7 +354,6 @@ export const devMachine = setup({
|
|
|
354
354
|
},
|
|
355
355
|
"clearJavaScriptErrors",
|
|
356
356
|
],
|
|
357
|
-
reenter: true,
|
|
358
357
|
},
|
|
359
358
|
"JavaScript Error": {
|
|
360
359
|
target: "Watching",
|
|
@@ -396,7 +395,6 @@ export const devMachine = setup({
|
|
|
396
395
|
always: {
|
|
397
396
|
target: "Uploading",
|
|
398
397
|
guard: ({ context }) => Boolean(context.devVersion),
|
|
399
|
-
reenter: true,
|
|
400
398
|
},
|
|
401
399
|
},
|
|
402
400
|
},
|
|
@@ -426,7 +424,6 @@ export const devMachine = setup({
|
|
|
426
424
|
{ type: "setDevVersion", params: ({ event }) => event },
|
|
427
425
|
{ type: "setTerminalTitle", params: ({ event }) => event },
|
|
428
426
|
],
|
|
429
|
-
reenter: true,
|
|
430
427
|
},
|
|
431
428
|
onError: {
|
|
432
429
|
target: "#Dev Machine.Error",
|
|
@@ -536,13 +533,8 @@ export const devMachine = setup({
|
|
|
536
533
|
"60000": "Prompt to Install",
|
|
537
534
|
},
|
|
538
535
|
},
|
|
539
|
-
"Waiting for App ID": {
|
|
540
|
-
on: {
|
|
541
|
-
"Upload Prepared": "Looking for Installations",
|
|
542
|
-
},
|
|
543
|
-
},
|
|
544
536
|
},
|
|
545
|
-
initial: "
|
|
537
|
+
initial: "Looking for Installations",
|
|
546
538
|
on: {
|
|
547
539
|
"Install Opened": {
|
|
548
540
|
target: ".Poll For Installation",
|
|
@@ -559,7 +551,6 @@ export const devMachine = setup({
|
|
|
559
551
|
src: "authenticate",
|
|
560
552
|
onDone: {
|
|
561
553
|
target: "Loading App Slug",
|
|
562
|
-
reenter: true,
|
|
563
554
|
actions: { type: "setToken", params: ({ event }) => event },
|
|
564
555
|
},
|
|
565
556
|
onError: {
|
|
@@ -581,7 +572,6 @@ export const devMachine = setup({
|
|
|
581
572
|
onDone: {
|
|
582
573
|
target: "Determine Workspace",
|
|
583
574
|
actions: { type: "setAppInfo", params: ({ event }) => event },
|
|
584
|
-
reenter: true,
|
|
585
575
|
},
|
|
586
576
|
onError: {
|
|
587
577
|
target: "Error",
|