attio 0.0.1-experimental.20250311 → 0.0.1-experimental.20250324
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/add-connection-definition.js +2 -2
- package/lib/api/auth.js +114 -0
- package/lib/api/complete-bundle-upload.js +2 -2
- package/lib/api/complete-prod-bundle-upload.js +2 -2
- package/lib/api/create-dev-version.js +2 -2
- package/lib/api/create-version.js +2 -2
- package/lib/api/ensure-authed.js +24 -0
- package/lib/api/fetch-connections.js +2 -2
- package/lib/api/fetch-installation.js +2 -2
- package/lib/api/fetch-versions.js +2 -2
- package/lib/api/keychain.js +30 -0
- package/lib/api/load-app-id.js +9 -0
- package/lib/api/load-dev-slug.js +9 -0
- package/lib/api/make-headers.js +1 -1
- package/lib/api/remove-connection-definition.js +2 -2
- package/lib/api/start-upload.js +2 -2
- package/lib/api/whoami.js +21 -0
- package/lib/attio.js +6 -2
- package/lib/commands/login.js +11 -0
- package/lib/commands/logout.js +11 -0
- package/lib/commands/version/index.js +1 -3
- package/lib/commands/version/list.js +31 -17
- package/lib/commands/whoami.js +19 -0
- package/lib/graphql/graphql-error.js +3 -0
- package/lib/machines/actors.js +3 -1
- package/lib/machines/dev-machine.js +5 -2
- package/lib/machines/init-machine.js +14 -7
- package/lib/templates/javascript/src/cat-fact.jsx +16 -0
- package/lib/templates/javascript/src/get-cat-fact.server.js +6 -0
- package/lib/templates/javascript/src/hello-world-dialog.jsx +6 -5
- package/lib/templates/typescript/src/cat-fact.tsx +16 -0
- package/lib/templates/typescript/src/get-cat-fact.server.ts +6 -0
- package/lib/templates/typescript/src/hello-world-dialog.tsx +5 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/util/load-developer-config.js +1 -0
- package/package.json +2 -1
- package/lib/api/publish-version.js +0 -15
- package/lib/commands/connection/add.js +0 -67
- package/lib/commands/connection/index.js +0 -9
- package/lib/commands/connection/list.js +0 -20
- package/lib/commands/connection/remove.js +0 -20
- package/lib/commands/version/publish.js +0 -48
- package/lib/machines/add-connection-machine.js +0 -559
- package/lib/machines/list-connections-machine.js +0 -174
- package/lib/machines/list-versions-machine.js +0 -151
- package/lib/machines/publish-version-machine.js +0 -230
- package/lib/machines/remove-connection-machine.js +0 -253
- package/lib/templates/javascript/src/advice.jsx +0 -16
- package/lib/templates/javascript/src/get-advice.server.js +0 -6
- package/lib/templates/typescript/src/advice.tsx +0 -16
- package/lib/templates/typescript/src/get-advice.server.ts +0 -6
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { assign, setup, fromCallback } from "xstate";
|
|
2
|
-
import { fetchConnections } from "../api/fetch-connections.js";
|
|
3
|
-
import { removeConnectionDefinition } from "../api/remove-connection-definition.js";
|
|
4
|
-
import { emptyConfig } from "../schema.js";
|
|
5
|
-
import { askWithChoices, loadAppConfig, loadDeveloperConfig, confirm } from "./actors.js";
|
|
6
|
-
import { printInstallInstructions } from "../util/print-install-instructions.js";
|
|
7
|
-
import { showError, printLogo } from "./actions.js";
|
|
8
|
-
import Spinner from "tiny-spinner";
|
|
9
|
-
export const removeConnectionMachine = setup({
|
|
10
|
-
types: {
|
|
11
|
-
context: {},
|
|
12
|
-
events: {},
|
|
13
|
-
},
|
|
14
|
-
actors: {
|
|
15
|
-
askWithChoices,
|
|
16
|
-
confirm,
|
|
17
|
-
removeConnectionDefinition: fromCallback(({ sendBack, input }) => {
|
|
18
|
-
const add = async () => {
|
|
19
|
-
const spinner = new Spinner();
|
|
20
|
-
try {
|
|
21
|
-
spinner.start("Removing connection...");
|
|
22
|
-
await removeConnectionDefinition({
|
|
23
|
-
token: input.developer.token,
|
|
24
|
-
devSlug: input.developer.slug,
|
|
25
|
-
appId: input.config.id,
|
|
26
|
-
global: input.global,
|
|
27
|
-
major: input.config.major,
|
|
28
|
-
});
|
|
29
|
-
spinner.success("Connection removed");
|
|
30
|
-
sendBack({ type: "Success" });
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
spinner.error("Error removing connection");
|
|
34
|
-
sendBack({ type: "Error", error: error.message });
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
add();
|
|
38
|
-
}),
|
|
39
|
-
loadDeveloperConfig,
|
|
40
|
-
loadAppConfig,
|
|
41
|
-
loadConnections: fromCallback(({ sendBack, input }) => {
|
|
42
|
-
const spinner = new Spinner();
|
|
43
|
-
spinner.start("Loading connections...");
|
|
44
|
-
fetchConnections({
|
|
45
|
-
token: input.developer.token,
|
|
46
|
-
devSlug: input.developer.slug,
|
|
47
|
-
appId: input.config.id,
|
|
48
|
-
major: input.config.major,
|
|
49
|
-
})
|
|
50
|
-
.then((connections) => {
|
|
51
|
-
spinner.success("Connections loaded");
|
|
52
|
-
sendBack({ type: "Connections Loaded", connections });
|
|
53
|
-
})
|
|
54
|
-
.catch((error) => {
|
|
55
|
-
spinner.error("Error loading connections");
|
|
56
|
-
sendBack({ type: "Error", error: error.message });
|
|
57
|
-
});
|
|
58
|
-
}),
|
|
59
|
-
},
|
|
60
|
-
actions: {
|
|
61
|
-
printLogo,
|
|
62
|
-
showError,
|
|
63
|
-
showConfigInstructions: ({ context }) => printInstallInstructions(context.configError),
|
|
64
|
-
showCanceled: () => {
|
|
65
|
-
process.stdout.write("No connection removed.\n\n");
|
|
66
|
-
},
|
|
67
|
-
showNoConnections: () => {
|
|
68
|
-
process.stdout.write("This app has no connections to remove.\n\n");
|
|
69
|
-
},
|
|
70
|
-
clearError: assign({
|
|
71
|
-
error: () => undefined,
|
|
72
|
-
}),
|
|
73
|
-
setError: assign({
|
|
74
|
-
error: (_, params) => params.error,
|
|
75
|
-
}),
|
|
76
|
-
setDeveloperConfig: assign({
|
|
77
|
-
developer: (_, params) => params,
|
|
78
|
-
}),
|
|
79
|
-
setConfigError: assign({
|
|
80
|
-
configError: (_, params) => params.configError,
|
|
81
|
-
}),
|
|
82
|
-
setConfig: assign({
|
|
83
|
-
config: (_, params) => params.config,
|
|
84
|
-
}),
|
|
85
|
-
setConnections: assign({
|
|
86
|
-
connections: (_, params) => params.connections,
|
|
87
|
-
}),
|
|
88
|
-
setGlobal: assign({
|
|
89
|
-
global: (_, params) => params.output === "true",
|
|
90
|
-
}),
|
|
91
|
-
setOnlyConnection: assign({
|
|
92
|
-
global: (_, params) => params.connections[0].global,
|
|
93
|
-
}),
|
|
94
|
-
},
|
|
95
|
-
guards: {
|
|
96
|
-
"have more than one connection": (_, params) => Boolean(params.connections && params.connections.length > 1),
|
|
97
|
-
"have only one connection": (_, params) => Boolean(params.connections && params.connections.length === 1),
|
|
98
|
-
"confirmed": (_, params) => params.output,
|
|
99
|
-
},
|
|
100
|
-
}).createMachine({
|
|
101
|
-
context: ({ input }) => ({
|
|
102
|
-
developer: { slug: "", token: "" },
|
|
103
|
-
config: emptyConfig,
|
|
104
|
-
...input,
|
|
105
|
-
}),
|
|
106
|
-
id: "Remove Connection Machine",
|
|
107
|
-
states: {
|
|
108
|
-
"Loading Developer Config": {
|
|
109
|
-
invoke: {
|
|
110
|
-
src: "loadDeveloperConfig",
|
|
111
|
-
},
|
|
112
|
-
on: {
|
|
113
|
-
"Developer Config Loaded": {
|
|
114
|
-
target: "Loading App Config",
|
|
115
|
-
actions: { type: "setDeveloperConfig", params: ({ event }) => event },
|
|
116
|
-
},
|
|
117
|
-
"No Developer Config": {
|
|
118
|
-
target: "Show config instructions",
|
|
119
|
-
actions: { type: "setConfigError", params: ({ event }) => event },
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
"Show config instructions": {
|
|
124
|
-
type: "final",
|
|
125
|
-
entry: "showConfigInstructions",
|
|
126
|
-
},
|
|
127
|
-
"Loading App Config": {
|
|
128
|
-
invoke: {
|
|
129
|
-
src: "loadAppConfig",
|
|
130
|
-
},
|
|
131
|
-
on: {
|
|
132
|
-
"Error": {
|
|
133
|
-
target: "Error",
|
|
134
|
-
actions: { type: "setError", params: ({ event }) => event },
|
|
135
|
-
},
|
|
136
|
-
"App Config Loaded": {
|
|
137
|
-
target: "Loading Connections",
|
|
138
|
-
actions: { type: "setConfig", params: ({ event }) => event },
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
"Error": {
|
|
143
|
-
type: "final",
|
|
144
|
-
entry: { type: "showError", params: ({ context }) => ({ error: context.error }) },
|
|
145
|
-
},
|
|
146
|
-
"Removing connection definition": {
|
|
147
|
-
invoke: {
|
|
148
|
-
src: "removeConnectionDefinition",
|
|
149
|
-
input: ({ context }) => ({
|
|
150
|
-
developer: context.developer,
|
|
151
|
-
config: context.config,
|
|
152
|
-
global: context.global,
|
|
153
|
-
}),
|
|
154
|
-
},
|
|
155
|
-
on: {
|
|
156
|
-
Success: "Success",
|
|
157
|
-
Error: {
|
|
158
|
-
target: "Error",
|
|
159
|
-
actions: { type: "setError", params: ({ event }) => event },
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
"Success": {
|
|
164
|
-
type: "final",
|
|
165
|
-
},
|
|
166
|
-
"Loading Connections": {
|
|
167
|
-
invoke: {
|
|
168
|
-
src: "loadConnections",
|
|
169
|
-
input: ({ context }) => context,
|
|
170
|
-
},
|
|
171
|
-
on: {
|
|
172
|
-
"Connections Loaded": [
|
|
173
|
-
{
|
|
174
|
-
target: "Choosing a Connection",
|
|
175
|
-
actions: { type: "setConnections", params: ({ event }) => event },
|
|
176
|
-
guard: {
|
|
177
|
-
type: "have more than one connection",
|
|
178
|
-
params: ({ event }) => event,
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
target: "Confirm Removal",
|
|
183
|
-
guard: {
|
|
184
|
-
type: "have only one connection",
|
|
185
|
-
params: ({ event }) => event,
|
|
186
|
-
},
|
|
187
|
-
reenter: true,
|
|
188
|
-
actions: [
|
|
189
|
-
{
|
|
190
|
-
type: "setConnections",
|
|
191
|
-
params: ({ event }) => event,
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
type: "setOnlyConnection",
|
|
195
|
-
params: ({ event }) => event,
|
|
196
|
-
},
|
|
197
|
-
],
|
|
198
|
-
},
|
|
199
|
-
"No Connections",
|
|
200
|
-
],
|
|
201
|
-
"Error": {
|
|
202
|
-
target: "Error",
|
|
203
|
-
actions: { type: "setError", params: ({ event }) => event },
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
"No Connections": {
|
|
208
|
-
type: "final",
|
|
209
|
-
entry: "showNoConnections",
|
|
210
|
-
},
|
|
211
|
-
"Choosing a Connection": {
|
|
212
|
-
invoke: {
|
|
213
|
-
src: "askWithChoices",
|
|
214
|
-
input: ({ context }) => ({
|
|
215
|
-
message: "Which connection would you like to remove?",
|
|
216
|
-
choices: context.connections.map((connection) => ({
|
|
217
|
-
name: `${connection.label} (${connection.global ? "workspace" : "user"})`,
|
|
218
|
-
value: connection.global ? "true" : "false",
|
|
219
|
-
})),
|
|
220
|
-
required: true,
|
|
221
|
-
}),
|
|
222
|
-
onDone: {
|
|
223
|
-
target: "Confirm Removal",
|
|
224
|
-
actions: { type: "setGlobal", params: ({ event }) => event },
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
"Confirm Removal": {
|
|
229
|
-
invoke: {
|
|
230
|
-
src: "confirm",
|
|
231
|
-
input: ({ context }) => ({
|
|
232
|
-
message: `Are you sure you want to remove "${context.connections[0].label}"?`,
|
|
233
|
-
}),
|
|
234
|
-
onDone: [
|
|
235
|
-
{
|
|
236
|
-
target: "Removing connection definition",
|
|
237
|
-
guard: { type: "confirmed", params: ({ event }) => event },
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
target: "Canceled",
|
|
241
|
-
reenter: true,
|
|
242
|
-
},
|
|
243
|
-
],
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
"Canceled": {
|
|
247
|
-
type: "final",
|
|
248
|
-
entry: "showCanceled",
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
initial: "Loading Developer Config",
|
|
252
|
-
entry: "printLogo",
|
|
253
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import {TextBlock, useAsyncCache} from "attio/client"
|
|
3
|
-
import getAdvice from "./get-advice.server"
|
|
4
|
-
|
|
5
|
-
export const Advice = ({recordId}) => {
|
|
6
|
-
// By passing in the recordId, the result will be cached for each recordId
|
|
7
|
-
const {
|
|
8
|
-
values: {advice},
|
|
9
|
-
// ^^^^^^– this key matches
|
|
10
|
-
// vvvvvv– this key
|
|
11
|
-
} = useAsyncCache({advice: [getAdvice, recordId]})
|
|
12
|
-
// ^^^^^^^^^ ^^^^^^^^
|
|
13
|
-
// async fn parameter(s)
|
|
14
|
-
|
|
15
|
-
return <TextBlock align="center">{`"${advice}"`}</TextBlock>
|
|
16
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export default async function getAdvice(recordId) {
|
|
2
|
-
// We don't really need the recordId for this API, but this is how we could use a parameter
|
|
3
|
-
const response = await fetch(`https://api.adviceslip.com/advice?${recordId}`)
|
|
4
|
-
const data = await response.json()
|
|
5
|
-
return data.slip.advice
|
|
6
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import {TextBlock, useAsyncCache} from "attio/client"
|
|
3
|
-
import getAdvice from "./get-advice.server"
|
|
4
|
-
|
|
5
|
-
export function Advice({recordId}: {recordId: string}) {
|
|
6
|
-
// By passing in the recordId, the result will be cached for each recordId
|
|
7
|
-
const {
|
|
8
|
-
values: {advice},
|
|
9
|
-
// ^^^^^^– this key matches
|
|
10
|
-
// vvvvvv– this key
|
|
11
|
-
} = useAsyncCache({advice: [getAdvice, recordId]})
|
|
12
|
-
// ^^^^^^^^^ ^^^^^^^^
|
|
13
|
-
// async fn parameter(s)
|
|
14
|
-
|
|
15
|
-
return <TextBlock align="center">{`"${advice}"`}</TextBlock>
|
|
16
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export default async function getAdvice(recordId: string): Promise<string> {
|
|
2
|
-
// We don't really need the recordId for this API, but this is how we could use a parameter
|
|
3
|
-
const response = await fetch(`https://api.adviceslip.com/advice?${recordId}`)
|
|
4
|
-
const data = await response.json()
|
|
5
|
-
return data.slip.advice
|
|
6
|
-
}
|