attio 0.0.1-experimental.20241011.4 → 0.0.1-experimental.20241011.5
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.
|
@@ -7,11 +7,10 @@ const addConnectionSchema = z.object({
|
|
|
7
7
|
app_id: z.string(),
|
|
8
8
|
connection_definition_id: z.string(),
|
|
9
9
|
});
|
|
10
|
-
export async function addConnectionDefinition({ token, devSlug, appId,
|
|
10
|
+
export async function addConnectionDefinition({ token, devSlug, appId, label, description, global, connectionType, clientId, clientSecret, authorizeUrl, accessTokenUrl, major, scopes, }) {
|
|
11
11
|
const connectionDefinitionId = uuid();
|
|
12
12
|
const body = {
|
|
13
13
|
connection_type: connectionType,
|
|
14
|
-
slug: key,
|
|
15
14
|
label,
|
|
16
15
|
description,
|
|
17
16
|
global,
|
|
@@ -11,10 +11,6 @@ import { Select } from "../../components/Select.js";
|
|
|
11
11
|
import { addConnectionMachine, connectionTypes } from "../../machines/add-connection-machine.js";
|
|
12
12
|
export const description = "Create a new connection for your Attio app";
|
|
13
13
|
export const options = z.object({
|
|
14
|
-
key: z
|
|
15
|
-
.string()
|
|
16
|
-
.optional()
|
|
17
|
-
.describe(option({ description: "A unique key for your connection" })),
|
|
18
14
|
label: z
|
|
19
15
|
.string()
|
|
20
16
|
.optional()
|
|
@@ -61,10 +57,9 @@ export const options = z.object({
|
|
|
61
57
|
.default(false)
|
|
62
58
|
.describe(option({ description: "Run in development mode (additional debugging info)" })),
|
|
63
59
|
});
|
|
64
|
-
export default function AddConnection({ options: {
|
|
60
|
+
export default function AddConnection({ options: { label, description, type: connectionType, authorizeUrl, accessTokenUrl, scopes, clientId, clientSecret, dev, }, }) {
|
|
65
61
|
const [snapshot, send] = useMachine(addConnectionMachine, {
|
|
66
62
|
input: {
|
|
67
|
-
key,
|
|
68
63
|
label,
|
|
69
64
|
description,
|
|
70
65
|
connectionType,
|
|
@@ -90,9 +85,6 @@ export default function AddConnection({ options: { key, label, description, type
|
|
|
90
85
|
snapshot.context.label && !snapshot.matches("Ask for label") && (React.createElement(Box, null,
|
|
91
86
|
React.createElement(Text, null, "Label: "),
|
|
92
87
|
React.createElement(Text, { color: "green" }, snapshot.context.label))),
|
|
93
|
-
snapshot.context.key && !snapshot.matches("Ask for key") && (React.createElement(Box, null,
|
|
94
|
-
React.createElement(Text, null, "Connection Key: "),
|
|
95
|
-
React.createElement(Text, { color: "green" }, snapshot.context.key))),
|
|
96
88
|
snapshot.context.description && !snapshot.matches("Ask for description") && (React.createElement(Box, null,
|
|
97
89
|
React.createElement(Text, null, "Description: "),
|
|
98
90
|
React.createElement(Text, { color: "green" }, snapshot.context.description))),
|
|
@@ -124,51 +116,6 @@ export default function AddConnection({ options: { key, label, description, type
|
|
|
124
116
|
!snapshot.matches("Ask for Client ID") && (React.createElement(Box, null,
|
|
125
117
|
React.createElement(Text, null, "Client ID: "),
|
|
126
118
|
React.createElement(Text, { color: "green" }, snapshot.context.clientId)))))),
|
|
127
|
-
snapshot.matches("Ask for key") && (React.createElement(React.Fragment, null,
|
|
128
|
-
React.createElement(Box, { flexDirection: "column" },
|
|
129
|
-
React.createElement(Box, { flexDirection: "column", margin: 1, borderStyle: "round", padding: 1 },
|
|
130
|
-
React.createElement(Text, null,
|
|
131
|
-
"import ",
|
|
132
|
-
"{",
|
|
133
|
-
" connections ",
|
|
134
|
-
"}",
|
|
135
|
-
" from \"attio/server\""),
|
|
136
|
-
React.createElement(Box, { marginY: 1 },
|
|
137
|
-
React.createElement(Text, null, "...")),
|
|
138
|
-
React.createElement(Text, null,
|
|
139
|
-
"const response = await fetch(\"https://api.yourdomain.com/your-endpoint\", ",
|
|
140
|
-
"{"),
|
|
141
|
-
React.createElement(Text, null,
|
|
142
|
-
" ",
|
|
143
|
-
"method: \"GET\","),
|
|
144
|
-
React.createElement(Text, null,
|
|
145
|
-
" ",
|
|
146
|
-
"headers: ",
|
|
147
|
-
"{"),
|
|
148
|
-
React.createElement(Text, null,
|
|
149
|
-
" ",
|
|
150
|
-
"\"Content-Type\": \"application/json\","),
|
|
151
|
-
React.createElement(Box, { flexWrap: "wrap" },
|
|
152
|
-
React.createElement(Text, null,
|
|
153
|
-
" ",
|
|
154
|
-
"Authorization: `Bearer $",
|
|
155
|
-
"{",
|
|
156
|
-
"connections"),
|
|
157
|
-
React.createElement(Text, null, snapshot.context.key?.includes("-") ? '["' : "."),
|
|
158
|
-
React.createElement(Text, { color: "yellowBright" }, snapshot.context.key),
|
|
159
|
-
snapshot.context.key?.includes("-") && React.createElement(Text, null, "\"]"),
|
|
160
|
-
React.createElement(Text, null,
|
|
161
|
-
"}",
|
|
162
|
-
"`,")),
|
|
163
|
-
React.createElement(Box, { marginLeft: 41 + (snapshot.context.key?.includes("-") ? 1 : 0) },
|
|
164
|
-
React.createElement(Text, { color: "cyan" }, "^".repeat(snapshot.context.key?.length ?? 0))),
|
|
165
|
-
React.createElement(Text, null, " }"),
|
|
166
|
-
React.createElement(Text, null,
|
|
167
|
-
"}",
|
|
168
|
-
");")),
|
|
169
|
-
React.createElement(Box, null,
|
|
170
|
-
React.createElement(Text, null, "Unique Connection Key: "),
|
|
171
|
-
React.createElement(TextInput, { value: snapshot.context.key ?? "", onChange: (key) => send({ type: "Update Key", key }), onSubmit: () => send({ type: "Submit" }) }))))),
|
|
172
119
|
snapshot.matches("Ask for label") && (React.createElement(React.Fragment, null,
|
|
173
120
|
React.createElement(Box, null,
|
|
174
121
|
React.createElement(Text, null, "Provide a label for your connection. This is what your users will see.")),
|
|
@@ -3,7 +3,6 @@ import { assign, setup, fromCallback } from "xstate";
|
|
|
3
3
|
import { addConnectionDefinition } from "../api/add-connection-definition.js";
|
|
4
4
|
import { fetchConnections } from "../api/fetch-connections.js";
|
|
5
5
|
import { options } from "../commands/connection/add.js";
|
|
6
|
-
import { slugifyExtension } from "../util/slugify-extension.js";
|
|
7
6
|
import { loadAppConfig, loadDeveloperConfig } from "./actors.js";
|
|
8
7
|
export const connectionTypes = [
|
|
9
8
|
{ value: "secret", label: "Secret" },
|
|
@@ -16,7 +15,7 @@ export const addConnectionMachine = setup({
|
|
|
16
15
|
input: {},
|
|
17
16
|
},
|
|
18
17
|
actors: {
|
|
19
|
-
"createConnectionDefinition": fromCallback(({ sendBack, input: { developer: { token, slug: devSlug }, config, connectionType: connection_type,
|
|
18
|
+
"createConnectionDefinition": fromCallback(({ sendBack, input: { developer: { token, slug: devSlug }, config, connectionType: connection_type, label, description, global, authorizeUrl, accessTokenUrl, clientId, clientSecret, scopes, }, }) => {
|
|
20
19
|
const add = async () => {
|
|
21
20
|
try {
|
|
22
21
|
await addConnectionDefinition({
|
|
@@ -25,7 +24,6 @@ export const addConnectionMachine = setup({
|
|
|
25
24
|
appId: config.id,
|
|
26
25
|
major: config.major,
|
|
27
26
|
connectionType: connection_type,
|
|
28
|
-
key,
|
|
29
27
|
label,
|
|
30
28
|
description,
|
|
31
29
|
global,
|
|
@@ -131,9 +129,6 @@ export const addConnectionMachine = setup({
|
|
|
131
129
|
setDeveloperConfig: assign({
|
|
132
130
|
developer: (_, params) => params,
|
|
133
131
|
}),
|
|
134
|
-
setKey: assign({
|
|
135
|
-
key: (_, params) => slugifyExtension(params.key, false),
|
|
136
|
-
}),
|
|
137
132
|
setInvalidAuthorizeUrl: assign({
|
|
138
133
|
error: (_, params) => {
|
|
139
134
|
const result = options.shape.authorizeUrl
|
|
@@ -188,13 +183,9 @@ export const addConnectionMachine = setup({
|
|
|
188
183
|
setGlobalTaken: assign({
|
|
189
184
|
error: () => "Global taken",
|
|
190
185
|
}),
|
|
191
|
-
slugifyLabel: assign({
|
|
192
|
-
key: (_, params) => slugifyExtension(params.label, true),
|
|
193
|
-
}),
|
|
194
186
|
},
|
|
195
187
|
guards: {
|
|
196
188
|
"have connection type": (_, params) => Boolean(params.connectionType),
|
|
197
|
-
"have key": (_, params) => Boolean(params.key),
|
|
198
189
|
"have label": (_, params) => Boolean(params.label),
|
|
199
190
|
"have description": (_, params) => Boolean(params.description),
|
|
200
191
|
"have authorize url": (_, params) => params.connectionType === "secret" ||
|
|
@@ -269,7 +260,6 @@ export const addConnectionMachine = setup({
|
|
|
269
260
|
global: context.global,
|
|
270
261
|
label: context.label,
|
|
271
262
|
description: context.description,
|
|
272
|
-
key: context.key,
|
|
273
263
|
}),
|
|
274
264
|
},
|
|
275
265
|
on: {
|
|
@@ -449,33 +439,6 @@ export const addConnectionMachine = setup({
|
|
|
449
439
|
},
|
|
450
440
|
],
|
|
451
441
|
},
|
|
452
|
-
"Do we have a key?": {
|
|
453
|
-
always: [
|
|
454
|
-
{
|
|
455
|
-
target: "Do we have a description?",
|
|
456
|
-
reenter: true,
|
|
457
|
-
actions: "clearError",
|
|
458
|
-
guard: { type: "have key", params: ({ context }) => context },
|
|
459
|
-
},
|
|
460
|
-
{
|
|
461
|
-
target: "Ask for key",
|
|
462
|
-
actions: {
|
|
463
|
-
type: "slugifyLabel",
|
|
464
|
-
params: ({ context }) => ({ label: context.label }),
|
|
465
|
-
},
|
|
466
|
-
},
|
|
467
|
-
],
|
|
468
|
-
},
|
|
469
|
-
"Ask for key": {
|
|
470
|
-
on: {
|
|
471
|
-
"Update Key": {
|
|
472
|
-
actions: { type: "setKey", params: ({ event }) => event },
|
|
473
|
-
},
|
|
474
|
-
"Submit": "Do we have a description?",
|
|
475
|
-
"Previous": "Ask for label",
|
|
476
|
-
"Next": "Do we have a description?",
|
|
477
|
-
},
|
|
478
|
-
},
|
|
479
442
|
"Do we have a connection type?": {
|
|
480
443
|
always: [
|
|
481
444
|
{
|
|
@@ -513,7 +476,7 @@ export const addConnectionMachine = setup({
|
|
|
513
476
|
"Do we have a label?": {
|
|
514
477
|
always: [
|
|
515
478
|
{
|
|
516
|
-
target: "Do we have a
|
|
479
|
+
target: "Do we have a description?",
|
|
517
480
|
guard: { type: "have label", params: ({ context }) => context },
|
|
518
481
|
reenter: true,
|
|
519
482
|
},
|
|
@@ -548,7 +511,7 @@ export const addConnectionMachine = setup({
|
|
|
548
511
|
"Ask for label": {
|
|
549
512
|
on: {
|
|
550
513
|
"Submit": {
|
|
551
|
-
target: "Do we have a
|
|
514
|
+
target: "Do we have a description?",
|
|
552
515
|
guard: { type: "have label", params: ({ context }) => context },
|
|
553
516
|
reenter: true,
|
|
554
517
|
},
|
|
@@ -557,7 +520,7 @@ export const addConnectionMachine = setup({
|
|
|
557
520
|
},
|
|
558
521
|
"Previous": "Ask for connection type",
|
|
559
522
|
"Next": {
|
|
560
|
-
target: "Ask for
|
|
523
|
+
target: "Ask for description",
|
|
561
524
|
guard: { type: "have label", params: ({ context }) => context },
|
|
562
525
|
},
|
|
563
526
|
},
|
|
@@ -578,7 +541,7 @@ export const addConnectionMachine = setup({
|
|
|
578
541
|
guard: { type: "have description", params: ({ context }) => context },
|
|
579
542
|
actions: "clearError",
|
|
580
543
|
},
|
|
581
|
-
"Previous": "Ask for
|
|
544
|
+
"Previous": "Ask for label",
|
|
582
545
|
"Next": {
|
|
583
546
|
target: "Ask for global",
|
|
584
547
|
guard: { type: "have description", params: ({ context }) => context },
|