@zapier/zapier-sdk 0.70.3 → 0.71.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/CHANGELOG.md +35 -0
- package/README.md +248 -95
- package/dist/api/approval-review-stream.d.ts +25 -0
- package/dist/api/approval-review-stream.d.ts.map +1 -0
- package/dist/api/approval-review-stream.js +104 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +215 -27
- package/dist/api/types.d.ts +13 -3
- package/dist/api/types.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -0
- package/dist/experimental.cjs +702 -67
- package/dist/experimental.d.mts +242 -2
- package/dist/experimental.d.ts +240 -0
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +10 -0
- package/dist/experimental.mjs +702 -68
- package/dist/{index-rIzBEINC.d.mts → index-B43uST61.d.mts} +248 -10
- package/dist/{index-rIzBEINC.d.ts → index-B43uST61.d.ts} +248 -10
- package/dist/index.cjs +592 -32
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +592 -33
- package/dist/plugins/api/index.d.ts.map +1 -1
- package/dist/plugins/api/index.js +2 -1
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts +9 -0
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts +9 -0
- package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts +9 -0
- package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts +5 -5
- package/dist/plugins/codeSubstrate/getTriggerRun/schemas.d.ts +1 -1
- package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts +31 -0
- package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getWorkflow/schemas.d.ts +42 -0
- package/dist/plugins/codeSubstrate/getWorkflow/schemas.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getWorkflow/schemas.js +20 -0
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts +9 -0
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowRun/schemas.d.ts +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts +35 -0
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.d.ts +13 -0
- package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.js +10 -0
- package/dist/plugins/codeSubstrate/listDurableRuns/schemas.d.ts +3 -3
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts +9 -0
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowRuns/schemas.d.ts +3 -3
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts +22 -0
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.d.ts +26 -0
- package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.js +10 -0
- package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts +9 -0
- package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listWorkflows/schemas.d.ts +32 -0
- package/dist/plugins/codeSubstrate/listWorkflows/schemas.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/listWorkflows/schemas.js +11 -0
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts +22 -0
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.d.ts +14 -1
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.js +11 -44
- package/dist/plugins/codeSubstrate/runDurable/index.d.ts +6 -0
- package/dist/plugins/codeSubstrate/runDurable/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/runDurable/index.js +3 -0
- package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts +12 -0
- package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/runDurable/schemas.js +33 -0
- package/dist/plugins/codeSubstrate/shared-schemas.d.ts +37 -0
- package/dist/plugins/codeSubstrate/shared-schemas.d.ts.map +1 -0
- package/dist/plugins/codeSubstrate/shared-schemas.js +69 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts +9 -0
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts +11 -0
- package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/updateWorkflow/schemas.d.ts +2 -0
- package/dist/plugins/codeSubstrate/updateWorkflow/schemas.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/updateWorkflow/schemas.js +7 -0
- package/dist/plugins/createConnection/index.d.ts +189 -0
- package/dist/plugins/createConnection/index.d.ts.map +1 -0
- package/dist/plugins/createConnection/index.js +71 -0
- package/dist/plugins/createConnection/schemas.d.ts +21 -0
- package/dist/plugins/createConnection/schemas.d.ts.map +1 -0
- package/dist/plugins/createConnection/schemas.js +38 -0
- package/dist/plugins/getConnectionStartUrl/index.d.ts +206 -0
- package/dist/plugins/getConnectionStartUrl/index.d.ts.map +1 -0
- package/dist/plugins/getConnectionStartUrl/index.js +39 -0
- package/dist/plugins/getConnectionStartUrl/schemas.d.ts +15 -0
- package/dist/plugins/getConnectionStartUrl/schemas.d.ts.map +1 -0
- package/dist/plugins/getConnectionStartUrl/schemas.js +23 -0
- package/dist/plugins/waitForNewConnection/index.d.ts +209 -0
- package/dist/plugins/waitForNewConnection/index.d.ts.map +1 -0
- package/dist/plugins/waitForNewConnection/index.js +75 -0
- package/dist/plugins/waitForNewConnection/schemas.d.ts +17 -0
- package/dist/plugins/waitForNewConnection/schemas.d.ts.map +1 -0
- package/dist/plugins/waitForNewConnection/schemas.js +39 -0
- package/dist/sdk.d.ts +126 -0
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +8 -0
- package/dist/types/errors.d.ts +13 -4
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +2 -0
- package/dist/types/sdk.d.ts +1 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/types/sdk.js +5 -1
- package/dist/utils/open-url.d.ts.map +1 -1
- package/dist/utils/open-url.js +7 -0
- package/dist/utils/should-open-browser.d.ts +24 -0
- package/dist/utils/should-open-browser.d.ts.map +1 -0
- package/dist/utils/should-open-browser.js +55 -0
- package/package.json +1 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { type CreateConnectionItem } from "./schemas";
|
|
2
|
+
export declare const createConnectionPlugin: (sdk: {
|
|
3
|
+
getConnectionStartUrl: (options?: {
|
|
4
|
+
app: string;
|
|
5
|
+
} | undefined) => Promise<{
|
|
6
|
+
data: import("../getConnectionStartUrl/schemas").GetConnectionStartUrlItem;
|
|
7
|
+
}>;
|
|
8
|
+
} & {
|
|
9
|
+
context: {
|
|
10
|
+
meta: {
|
|
11
|
+
getConnectionStartUrl: import("kitcore").PluginMeta<unknown>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
} & {
|
|
15
|
+
waitForNewConnection: (options?: {
|
|
16
|
+
app: string;
|
|
17
|
+
startedAt: number;
|
|
18
|
+
timeoutMs?: number | undefined;
|
|
19
|
+
pollIntervalMs?: number | undefined;
|
|
20
|
+
} | undefined) => Promise<{
|
|
21
|
+
data: import("../waitForNewConnection/schemas").WaitForNewConnectionItem;
|
|
22
|
+
}>;
|
|
23
|
+
} & {
|
|
24
|
+
context: {
|
|
25
|
+
meta: {
|
|
26
|
+
waitForNewConnection: import("kitcore").PluginMeta<unknown>;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
} & {
|
|
30
|
+
getApp: (options?: {
|
|
31
|
+
app: string;
|
|
32
|
+
} | {
|
|
33
|
+
appKey: string;
|
|
34
|
+
} | undefined) => Promise<{
|
|
35
|
+
data: {
|
|
36
|
+
slug: string;
|
|
37
|
+
title: string;
|
|
38
|
+
key: string;
|
|
39
|
+
implementation_id: string;
|
|
40
|
+
description?: string | undefined;
|
|
41
|
+
is_hidden?: boolean | undefined;
|
|
42
|
+
auth_type?: string | undefined;
|
|
43
|
+
actions?: {
|
|
44
|
+
read?: number | undefined;
|
|
45
|
+
read_bulk?: number | undefined;
|
|
46
|
+
write?: number | undefined;
|
|
47
|
+
search?: number | undefined;
|
|
48
|
+
search_or_write?: number | undefined;
|
|
49
|
+
search_and_write?: number | undefined;
|
|
50
|
+
filter?: number | undefined;
|
|
51
|
+
} | undefined;
|
|
52
|
+
is_deprecated?: boolean | undefined;
|
|
53
|
+
is_beta?: boolean | undefined;
|
|
54
|
+
is_premium?: boolean | undefined;
|
|
55
|
+
age_in_days?: number | undefined;
|
|
56
|
+
banner?: string | undefined;
|
|
57
|
+
categories?: {
|
|
58
|
+
id: number;
|
|
59
|
+
name: string;
|
|
60
|
+
slug: string;
|
|
61
|
+
}[] | undefined;
|
|
62
|
+
images?: {
|
|
63
|
+
url_16x16?: string | undefined;
|
|
64
|
+
url_32x32?: string | undefined;
|
|
65
|
+
url_64x64?: string | undefined;
|
|
66
|
+
url_128x128?: string | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
popularity?: number | undefined;
|
|
69
|
+
has_filters?: boolean | undefined;
|
|
70
|
+
has_reads?: boolean | undefined;
|
|
71
|
+
has_searches?: boolean | undefined;
|
|
72
|
+
has_searches_or_writes?: boolean | undefined;
|
|
73
|
+
has_upfront_fields?: boolean | undefined;
|
|
74
|
+
has_writes?: boolean | undefined;
|
|
75
|
+
is_built_in?: boolean | undefined;
|
|
76
|
+
is_featured?: boolean | undefined;
|
|
77
|
+
is_invite?: boolean | undefined;
|
|
78
|
+
is_public?: boolean | undefined;
|
|
79
|
+
is_upcoming?: boolean | undefined;
|
|
80
|
+
visibility?: string | undefined;
|
|
81
|
+
primary_color?: string | undefined;
|
|
82
|
+
secondary_color?: string | undefined;
|
|
83
|
+
classification?: string | undefined;
|
|
84
|
+
api_docs_url?: string | undefined;
|
|
85
|
+
image?: string | undefined;
|
|
86
|
+
version?: string | undefined;
|
|
87
|
+
};
|
|
88
|
+
}>;
|
|
89
|
+
} & {
|
|
90
|
+
context: {
|
|
91
|
+
meta: {
|
|
92
|
+
getApp: import("kitcore").PluginMeta<unknown>;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
} & {
|
|
96
|
+
listApps: (options?: ({
|
|
97
|
+
search?: string | undefined;
|
|
98
|
+
apps?: string[] | undefined;
|
|
99
|
+
appKeys?: string[] | undefined;
|
|
100
|
+
pageSize?: number | undefined;
|
|
101
|
+
maxItems?: number | undefined;
|
|
102
|
+
cursor?: string | undefined;
|
|
103
|
+
} & {
|
|
104
|
+
cursor?: string;
|
|
105
|
+
pageSize?: number;
|
|
106
|
+
maxItems?: number;
|
|
107
|
+
}) | undefined) => import("kitcore").PaginatedSdkResult<{
|
|
108
|
+
slug: string;
|
|
109
|
+
title: string;
|
|
110
|
+
key: string;
|
|
111
|
+
implementation_id: string;
|
|
112
|
+
description?: string | undefined;
|
|
113
|
+
is_hidden?: boolean | undefined;
|
|
114
|
+
auth_type?: string | undefined;
|
|
115
|
+
actions?: {
|
|
116
|
+
read?: number | undefined;
|
|
117
|
+
read_bulk?: number | undefined;
|
|
118
|
+
write?: number | undefined;
|
|
119
|
+
search?: number | undefined;
|
|
120
|
+
search_or_write?: number | undefined;
|
|
121
|
+
search_and_write?: number | undefined;
|
|
122
|
+
filter?: number | undefined;
|
|
123
|
+
} | undefined;
|
|
124
|
+
is_deprecated?: boolean | undefined;
|
|
125
|
+
is_beta?: boolean | undefined;
|
|
126
|
+
is_premium?: boolean | undefined;
|
|
127
|
+
age_in_days?: number | undefined;
|
|
128
|
+
banner?: string | undefined;
|
|
129
|
+
categories?: {
|
|
130
|
+
id: number;
|
|
131
|
+
name: string;
|
|
132
|
+
slug: string;
|
|
133
|
+
}[] | undefined;
|
|
134
|
+
images?: {
|
|
135
|
+
url_16x16?: string | undefined;
|
|
136
|
+
url_32x32?: string | undefined;
|
|
137
|
+
url_64x64?: string | undefined;
|
|
138
|
+
url_128x128?: string | undefined;
|
|
139
|
+
} | undefined;
|
|
140
|
+
popularity?: number | undefined;
|
|
141
|
+
has_filters?: boolean | undefined;
|
|
142
|
+
has_reads?: boolean | undefined;
|
|
143
|
+
has_searches?: boolean | undefined;
|
|
144
|
+
has_searches_or_writes?: boolean | undefined;
|
|
145
|
+
has_upfront_fields?: boolean | undefined;
|
|
146
|
+
has_writes?: boolean | undefined;
|
|
147
|
+
is_built_in?: boolean | undefined;
|
|
148
|
+
is_featured?: boolean | undefined;
|
|
149
|
+
is_invite?: boolean | undefined;
|
|
150
|
+
is_public?: boolean | undefined;
|
|
151
|
+
is_upcoming?: boolean | undefined;
|
|
152
|
+
visibility?: string | undefined;
|
|
153
|
+
primary_color?: string | undefined;
|
|
154
|
+
secondary_color?: string | undefined;
|
|
155
|
+
classification?: string | undefined;
|
|
156
|
+
api_docs_url?: string | undefined;
|
|
157
|
+
image?: string | undefined;
|
|
158
|
+
version?: string | undefined;
|
|
159
|
+
}>;
|
|
160
|
+
} & {
|
|
161
|
+
context: {
|
|
162
|
+
meta: {
|
|
163
|
+
listApps: import("kitcore").PluginMeta<unknown>;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
} & {
|
|
167
|
+
context: import("../eventEmission").EventEmissionContext;
|
|
168
|
+
} & {
|
|
169
|
+
context: {
|
|
170
|
+
meta: Record<string, import("kitcore").PluginMeta>;
|
|
171
|
+
};
|
|
172
|
+
}) => {
|
|
173
|
+
createConnection: (options?: {
|
|
174
|
+
app: string;
|
|
175
|
+
browser: "never" | "auto" | "always";
|
|
176
|
+
timeoutMs?: number | undefined;
|
|
177
|
+
pollIntervalMs?: number | undefined;
|
|
178
|
+
} | undefined) => Promise<{
|
|
179
|
+
data: CreateConnectionItem;
|
|
180
|
+
}>;
|
|
181
|
+
} & {
|
|
182
|
+
context: {
|
|
183
|
+
meta: {
|
|
184
|
+
createConnection: import("kitcore").PluginMeta<unknown>;
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
export type CreateConnectionPluginProvides = ReturnType<typeof createConnectionPlugin>;
|
|
189
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/createConnection/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,WAAW,CAAC;AAWnB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAyBX,oBAAoB;;;;;;;;CAqD3C,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,UAAU,CACrD,OAAO,sBAAsB,CAC9B,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { definePlugin, createPluginMethod } from "kitcore";
|
|
2
|
+
import { setMethodMetadata } from "../eventEmission/method-metadata";
|
|
3
|
+
import { appKeyResolver } from "../../resolvers";
|
|
4
|
+
import openUrl from "../../utils/open-url";
|
|
5
|
+
import { shouldOpenBrowser } from "../../utils/should-open-browser";
|
|
6
|
+
import { CreateConnectionSchema, CreateConnectionItemSchema, } from "./schemas";
|
|
7
|
+
export const createConnectionPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
8
|
+
name: "createConnection",
|
|
9
|
+
categories: ["connection"],
|
|
10
|
+
type: "create",
|
|
11
|
+
itemType: "Connection",
|
|
12
|
+
inputSchema: CreateConnectionSchema,
|
|
13
|
+
outputSchema: CreateConnectionItemSchema,
|
|
14
|
+
resolvers: { app: appKeyResolver },
|
|
15
|
+
formatter: {
|
|
16
|
+
format: (item) => ({
|
|
17
|
+
title: `Connection created: ${item.title || item.id}`,
|
|
18
|
+
id: item.id,
|
|
19
|
+
details: [
|
|
20
|
+
{ text: `App: ${item.app}`, style: "normal" },
|
|
21
|
+
{ text: `ID: ${item.id}`, style: "accent" },
|
|
22
|
+
],
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
handler: async ({ sdk: inner, options, }) => {
|
|
26
|
+
const { data: start } = await inner.getConnectionStartUrl({
|
|
27
|
+
app: options.app,
|
|
28
|
+
});
|
|
29
|
+
// Tag this method's scope so eventEmission's onMethodEnd hook
|
|
30
|
+
// emits the MethodCalled event with `selected_api` set. The inner
|
|
31
|
+
// call sets metadata in its own scope, so we set it again here for
|
|
32
|
+
// createConnection's outer scope.
|
|
33
|
+
setMethodMetadata({ selectedApi: start.app });
|
|
34
|
+
// console.error (stderr) so JSON output on stdout (CLI --json flag)
|
|
35
|
+
// stays parseable, and so this works without bare `process` access in
|
|
36
|
+
// browser bundles — matching open-approval.ts. Always printed: a
|
|
37
|
+
// failed / skipped browser-open falls back to user copy-paste, so this
|
|
38
|
+
// is the load-bearing contract.
|
|
39
|
+
console.error(`\nOpen this URL to complete the connection:\n ${start.url}\n`);
|
|
40
|
+
const shouldOpen = options.browser === "always" ||
|
|
41
|
+
(options.browser === "auto" && shouldOpenBrowser());
|
|
42
|
+
if (shouldOpen) {
|
|
43
|
+
try {
|
|
44
|
+
// Resolves once the OS handler is launched, not when the user
|
|
45
|
+
// finishes auth — that's waitForNewConnection's job.
|
|
46
|
+
await openUrl(start.url);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// openUrl can throw on unsupported platforms or when no handler is
|
|
50
|
+
// available. The URL is already printed to stderr, so the user can
|
|
51
|
+
// copy it.
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const { data: fresh } = await inner.waitForNewConnection({
|
|
55
|
+
app: start.app,
|
|
56
|
+
// Server-stamped mint time: measured on the same clock as a
|
|
57
|
+
// connection's `date`, so the freshness check is immune to
|
|
58
|
+
// client/server clock skew.
|
|
59
|
+
startedAt: start.startedAt,
|
|
60
|
+
timeoutMs: options.timeoutMs,
|
|
61
|
+
pollIntervalMs: options.pollIntervalMs,
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
data: CreateConnectionItemSchema.parse({
|
|
65
|
+
id: fresh.id,
|
|
66
|
+
app: start.app,
|
|
67
|
+
title: fresh.title ?? null,
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const CreateConnectionSchema: z.ZodObject<{
|
|
3
|
+
app: z.ZodString & {
|
|
4
|
+
_def: z.core.$ZodStringDef & import("kitcore").PositionalMetadata;
|
|
5
|
+
};
|
|
6
|
+
browser: z.ZodDefault<z.ZodEnum<{
|
|
7
|
+
never: "never";
|
|
8
|
+
auto: "auto";
|
|
9
|
+
always: "always";
|
|
10
|
+
}>>;
|
|
11
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
pollIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type CreateConnectionOptions = z.infer<typeof CreateConnectionSchema>;
|
|
15
|
+
export declare const CreateConnectionItemSchema: z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
app: z.ZodString;
|
|
18
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export type CreateConnectionItem = z.infer<typeof CreateConnectionItemSchema>;
|
|
21
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/createConnection/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,sBAAsB;;;;;;;;;;;iBA4BhC,CAAC;AAEJ,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE7E,eAAO,MAAM,0BAA0B;;;;iBAoBK,CAAC;AAE7C,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AppPropertySchema } from "../../types/properties";
|
|
3
|
+
export const CreateConnectionSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
app: AppPropertySchema,
|
|
6
|
+
browser: z
|
|
7
|
+
.enum(["auto", "always", "never"])
|
|
8
|
+
.default("auto")
|
|
9
|
+
.describe("When to auto-open the URL in a browser. `auto` (default) opens in local sessions and skips opening in CI / SSH / headless-Linux. `always` forces the open attempt. `never` skips it. The URL is always printed to stderr regardless — a failed or skipped open degrades gracefully to copy-paste."),
|
|
10
|
+
timeoutMs: z
|
|
11
|
+
.number()
|
|
12
|
+
.int()
|
|
13
|
+
.positive()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe("How long to wait for the user to complete the connection flow before giving up. Default 5 minutes (300_000)."),
|
|
16
|
+
pollIntervalMs: z
|
|
17
|
+
.number()
|
|
18
|
+
.int()
|
|
19
|
+
.positive()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Delay before the first poll request, in ms. Default 3 seconds (3_000). Subsequent polling cadence is managed by the SDK's polling primitive (backoff with sane defaults)."),
|
|
22
|
+
})
|
|
23
|
+
.describe("Create a new app connection, end-to-end. Mints the start URL via `get-connection-start-url`, prints it to stderr, opportunistically opens it in a browser when it looks safe to do so (skipping CI / SSH / headless-Linux by default — pass `--browser always` to force, `--browser never` to suppress), then polls via `wait-for-new-connection` until the user completes OAuth and the new connection appears. Returns the connection.\n\nThis is the right command for most callers. Reach for the lower-level building blocks when you want either of: (a) hand off the URL and *not* block on completion — call `get-connection-start-url` alone, no `wait-for-new-connection` needed, or (b) do something custom between minting the URL and waiting — call `get-connection-start-url`, do your work (email or DM the URL, render a QR code, etc.), then `wait-for-new-connection`.");
|
|
24
|
+
export const CreateConnectionItemSchema = z
|
|
25
|
+
.object({
|
|
26
|
+
id: z
|
|
27
|
+
.string()
|
|
28
|
+
.describe("The new connection's ID. Public UUID when available, falling back to the numeric ID."),
|
|
29
|
+
app: z
|
|
30
|
+
.string()
|
|
31
|
+
.describe("Versionless app key the connection was created for (e.g., 'SlackCLIAPI')."),
|
|
32
|
+
title: z
|
|
33
|
+
.string()
|
|
34
|
+
.nullable()
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Human-readable connection title set by the auth flow, when available."),
|
|
37
|
+
})
|
|
38
|
+
.describe("The newly created connection.");
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { type GetConnectionStartUrlItem } from "./schemas";
|
|
2
|
+
export declare const getConnectionStartUrlPlugin: (sdk: {
|
|
3
|
+
context: {
|
|
4
|
+
api: import("../..").ApiClient;
|
|
5
|
+
resolveCredentials: () => Promise<string | {
|
|
6
|
+
clientId: string;
|
|
7
|
+
clientSecret: string;
|
|
8
|
+
type?: "client_credentials" | undefined;
|
|
9
|
+
baseUrl?: string | undefined;
|
|
10
|
+
scope?: string | undefined;
|
|
11
|
+
} | {
|
|
12
|
+
clientId: string;
|
|
13
|
+
type?: "pkce" | undefined;
|
|
14
|
+
baseUrl?: string | undefined;
|
|
15
|
+
scope?: string | undefined;
|
|
16
|
+
} | undefined>;
|
|
17
|
+
};
|
|
18
|
+
} & {
|
|
19
|
+
context: {
|
|
20
|
+
getResolvedManifest: () => Promise<import("../manifest").Manifest | null>;
|
|
21
|
+
getVersionedImplementationId: (appKey: string) => Promise<string | null>;
|
|
22
|
+
resolveAppKeys: ({ appKeys }: {
|
|
23
|
+
appKeys: string[];
|
|
24
|
+
}) => Promise<import("../..").ResolvedAppLocator[]>;
|
|
25
|
+
updateManifestEntry: (options: import("../manifest").UpdateManifestEntryOptions) => Promise<import("../manifest").UpdateManifestEntryResult>;
|
|
26
|
+
addActionEntry: (options: import("../manifest").AddActionEntryOptions) => Promise<import("../manifest").AddActionEntryResult>;
|
|
27
|
+
findActionEntry: ({ name, manifest, }: {
|
|
28
|
+
name: string;
|
|
29
|
+
manifest: import("../manifest").Manifest;
|
|
30
|
+
}) => import("../manifest").ActionEntry | null;
|
|
31
|
+
listActionEntries: ({ configPath, }?: {
|
|
32
|
+
configPath?: string;
|
|
33
|
+
}) => Promise<Array<[string, import("../manifest").ActionEntry]>>;
|
|
34
|
+
deleteActionEntry: ({ name, configPath, skipWrite, }: {
|
|
35
|
+
name: string;
|
|
36
|
+
configPath?: string;
|
|
37
|
+
skipWrite?: boolean;
|
|
38
|
+
}) => Promise<import("../manifest").Manifest>;
|
|
39
|
+
hasActionEntry: ({ name, manifest, }: {
|
|
40
|
+
name: string;
|
|
41
|
+
manifest: import("../manifest").Manifest;
|
|
42
|
+
}) => boolean;
|
|
43
|
+
findManifestEntry: typeof import("../manifest").findManifestEntry;
|
|
44
|
+
readManifestFromFile: typeof import("../manifest").readManifestFromFile;
|
|
45
|
+
getManifestConnections: () => Promise<Record<string, {
|
|
46
|
+
connectionId: string | number;
|
|
47
|
+
}> | null>;
|
|
48
|
+
};
|
|
49
|
+
} & {
|
|
50
|
+
getApp: (options?: {
|
|
51
|
+
app: string;
|
|
52
|
+
} | {
|
|
53
|
+
appKey: string;
|
|
54
|
+
} | undefined) => Promise<{
|
|
55
|
+
data: {
|
|
56
|
+
slug: string;
|
|
57
|
+
title: string;
|
|
58
|
+
key: string;
|
|
59
|
+
implementation_id: string;
|
|
60
|
+
description?: string | undefined;
|
|
61
|
+
is_hidden?: boolean | undefined;
|
|
62
|
+
auth_type?: string | undefined;
|
|
63
|
+
actions?: {
|
|
64
|
+
read?: number | undefined;
|
|
65
|
+
read_bulk?: number | undefined;
|
|
66
|
+
write?: number | undefined;
|
|
67
|
+
search?: number | undefined;
|
|
68
|
+
search_or_write?: number | undefined;
|
|
69
|
+
search_and_write?: number | undefined;
|
|
70
|
+
filter?: number | undefined;
|
|
71
|
+
} | undefined;
|
|
72
|
+
is_deprecated?: boolean | undefined;
|
|
73
|
+
is_beta?: boolean | undefined;
|
|
74
|
+
is_premium?: boolean | undefined;
|
|
75
|
+
age_in_days?: number | undefined;
|
|
76
|
+
banner?: string | undefined;
|
|
77
|
+
categories?: {
|
|
78
|
+
id: number;
|
|
79
|
+
name: string;
|
|
80
|
+
slug: string;
|
|
81
|
+
}[] | undefined;
|
|
82
|
+
images?: {
|
|
83
|
+
url_16x16?: string | undefined;
|
|
84
|
+
url_32x32?: string | undefined;
|
|
85
|
+
url_64x64?: string | undefined;
|
|
86
|
+
url_128x128?: string | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
popularity?: number | undefined;
|
|
89
|
+
has_filters?: boolean | undefined;
|
|
90
|
+
has_reads?: boolean | undefined;
|
|
91
|
+
has_searches?: boolean | undefined;
|
|
92
|
+
has_searches_or_writes?: boolean | undefined;
|
|
93
|
+
has_upfront_fields?: boolean | undefined;
|
|
94
|
+
has_writes?: boolean | undefined;
|
|
95
|
+
is_built_in?: boolean | undefined;
|
|
96
|
+
is_featured?: boolean | undefined;
|
|
97
|
+
is_invite?: boolean | undefined;
|
|
98
|
+
is_public?: boolean | undefined;
|
|
99
|
+
is_upcoming?: boolean | undefined;
|
|
100
|
+
visibility?: string | undefined;
|
|
101
|
+
primary_color?: string | undefined;
|
|
102
|
+
secondary_color?: string | undefined;
|
|
103
|
+
classification?: string | undefined;
|
|
104
|
+
api_docs_url?: string | undefined;
|
|
105
|
+
image?: string | undefined;
|
|
106
|
+
version?: string | undefined;
|
|
107
|
+
};
|
|
108
|
+
}>;
|
|
109
|
+
} & {
|
|
110
|
+
context: {
|
|
111
|
+
meta: {
|
|
112
|
+
getApp: import("kitcore").PluginMeta<unknown>;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
} & {
|
|
116
|
+
listApps: (options?: ({
|
|
117
|
+
search?: string | undefined;
|
|
118
|
+
apps?: string[] | undefined;
|
|
119
|
+
appKeys?: string[] | undefined;
|
|
120
|
+
pageSize?: number | undefined;
|
|
121
|
+
maxItems?: number | undefined;
|
|
122
|
+
cursor?: string | undefined;
|
|
123
|
+
} & {
|
|
124
|
+
cursor?: string;
|
|
125
|
+
pageSize?: number;
|
|
126
|
+
maxItems?: number;
|
|
127
|
+
}) | undefined) => import("kitcore").PaginatedSdkResult<{
|
|
128
|
+
slug: string;
|
|
129
|
+
title: string;
|
|
130
|
+
key: string;
|
|
131
|
+
implementation_id: string;
|
|
132
|
+
description?: string | undefined;
|
|
133
|
+
is_hidden?: boolean | undefined;
|
|
134
|
+
auth_type?: string | undefined;
|
|
135
|
+
actions?: {
|
|
136
|
+
read?: number | undefined;
|
|
137
|
+
read_bulk?: number | undefined;
|
|
138
|
+
write?: number | undefined;
|
|
139
|
+
search?: number | undefined;
|
|
140
|
+
search_or_write?: number | undefined;
|
|
141
|
+
search_and_write?: number | undefined;
|
|
142
|
+
filter?: number | undefined;
|
|
143
|
+
} | undefined;
|
|
144
|
+
is_deprecated?: boolean | undefined;
|
|
145
|
+
is_beta?: boolean | undefined;
|
|
146
|
+
is_premium?: boolean | undefined;
|
|
147
|
+
age_in_days?: number | undefined;
|
|
148
|
+
banner?: string | undefined;
|
|
149
|
+
categories?: {
|
|
150
|
+
id: number;
|
|
151
|
+
name: string;
|
|
152
|
+
slug: string;
|
|
153
|
+
}[] | undefined;
|
|
154
|
+
images?: {
|
|
155
|
+
url_16x16?: string | undefined;
|
|
156
|
+
url_32x32?: string | undefined;
|
|
157
|
+
url_64x64?: string | undefined;
|
|
158
|
+
url_128x128?: string | undefined;
|
|
159
|
+
} | undefined;
|
|
160
|
+
popularity?: number | undefined;
|
|
161
|
+
has_filters?: boolean | undefined;
|
|
162
|
+
has_reads?: boolean | undefined;
|
|
163
|
+
has_searches?: boolean | undefined;
|
|
164
|
+
has_searches_or_writes?: boolean | undefined;
|
|
165
|
+
has_upfront_fields?: boolean | undefined;
|
|
166
|
+
has_writes?: boolean | undefined;
|
|
167
|
+
is_built_in?: boolean | undefined;
|
|
168
|
+
is_featured?: boolean | undefined;
|
|
169
|
+
is_invite?: boolean | undefined;
|
|
170
|
+
is_public?: boolean | undefined;
|
|
171
|
+
is_upcoming?: boolean | undefined;
|
|
172
|
+
visibility?: string | undefined;
|
|
173
|
+
primary_color?: string | undefined;
|
|
174
|
+
secondary_color?: string | undefined;
|
|
175
|
+
classification?: string | undefined;
|
|
176
|
+
api_docs_url?: string | undefined;
|
|
177
|
+
image?: string | undefined;
|
|
178
|
+
version?: string | undefined;
|
|
179
|
+
}>;
|
|
180
|
+
} & {
|
|
181
|
+
context: {
|
|
182
|
+
meta: {
|
|
183
|
+
listApps: import("kitcore").PluginMeta<unknown>;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
} & {
|
|
187
|
+
context: import("../eventEmission").EventEmissionContext;
|
|
188
|
+
} & {
|
|
189
|
+
context: {
|
|
190
|
+
meta: Record<string, import("kitcore").PluginMeta>;
|
|
191
|
+
};
|
|
192
|
+
}) => {
|
|
193
|
+
getConnectionStartUrl: (options?: {
|
|
194
|
+
app: string;
|
|
195
|
+
} | undefined) => Promise<{
|
|
196
|
+
data: GetConnectionStartUrlItem;
|
|
197
|
+
}>;
|
|
198
|
+
} & {
|
|
199
|
+
context: {
|
|
200
|
+
meta: {
|
|
201
|
+
getConnectionStartUrl: import("kitcore").PluginMeta<unknown>;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
export type GetConnectionStartUrlPluginProvides = ReturnType<typeof getConnectionStartUrlPlugin>;
|
|
206
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getConnectionStartUrl/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAGL,KAAK,yBAAyB,EAC/B,MAAM,WAAW,CAAC;AAoBnB,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAmDuhX,CAAC;;;;sBAAiX,CAAC;qBAAyB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cApCp7X,yBAAyB;;;;;;;;CA+BhD,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,UAAU,CAC1D,OAAO,2BAA2B,CACnC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { definePlugin, createPluginMethod } from "kitcore";
|
|
2
|
+
import { setMethodMetadata } from "../eventEmission/method-metadata";
|
|
3
|
+
import { appKeyResolver } from "../../resolvers";
|
|
4
|
+
import { GetConnectionStartUrlSchema, GetConnectionStartUrlItemSchema, } from "./schemas";
|
|
5
|
+
// Server endpoint that mints a signed, single-use connection start URL.
|
|
6
|
+
const START_PATH = "/zapier/api/authentications/v1/sdk/connections/start";
|
|
7
|
+
export const getConnectionStartUrlPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
8
|
+
name: "getConnectionStartUrl",
|
|
9
|
+
categories: ["connection"],
|
|
10
|
+
type: "create",
|
|
11
|
+
itemType: "ConnectionStartUrl",
|
|
12
|
+
inputSchema: GetConnectionStartUrlSchema,
|
|
13
|
+
outputSchema: GetConnectionStartUrlItemSchema,
|
|
14
|
+
resolvers: { app: appKeyResolver },
|
|
15
|
+
handler: async ({ sdk: inner, options, }) => {
|
|
16
|
+
// Send the versionless app key: the server resolves it to the freshest
|
|
17
|
+
// production version when the user opens the URL, which can be minutes
|
|
18
|
+
// after this call.
|
|
19
|
+
const versionedKey = await inner.context.getVersionedImplementationId(options.app);
|
|
20
|
+
const selectedApi = versionedKey
|
|
21
|
+
? versionedKey.split("@")[0]
|
|
22
|
+
: options.app;
|
|
23
|
+
// Tag this method's scope so eventEmission's onMethodEnd hook
|
|
24
|
+
// emits the MethodCalled event with `selected_api` set.
|
|
25
|
+
setMethodMetadata({ selectedApi });
|
|
26
|
+
const response = await inner.context.api.post(START_PATH, { selected_api: selectedApi }, { authRequired: true });
|
|
27
|
+
// Parse the mapped shape against the output schema so a server-side
|
|
28
|
+
// response change surfaces as a validation error here rather than
|
|
29
|
+
// silently producing a malformed item.
|
|
30
|
+
return {
|
|
31
|
+
data: GetConnectionStartUrlItemSchema.parse({
|
|
32
|
+
url: response.url,
|
|
33
|
+
expiresAt: response.expires_at,
|
|
34
|
+
startedAt: response.started_at,
|
|
35
|
+
app: selectedApi,
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const GetConnectionStartUrlSchema: z.ZodObject<{
|
|
3
|
+
app: z.ZodString & {
|
|
4
|
+
_def: z.core.$ZodStringDef & import("kitcore").PositionalMetadata;
|
|
5
|
+
};
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export type GetConnectionStartUrlOptions = z.infer<typeof GetConnectionStartUrlSchema>;
|
|
8
|
+
export declare const GetConnectionStartUrlItemSchema: z.ZodObject<{
|
|
9
|
+
url: z.ZodString;
|
|
10
|
+
expiresAt: z.ZodNumber;
|
|
11
|
+
startedAt: z.ZodNumber;
|
|
12
|
+
app: z.ZodString;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type GetConnectionStartUrlItem = z.infer<typeof GetConnectionStartUrlItemSchema>;
|
|
15
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/getConnectionStartUrl/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,2BAA2B;;;;iBAMrC,CAAC;AAEJ,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,2BAA2B,CACnC,CAAC;AAEF,eAAO,MAAM,+BAA+B;;;;;iBAyBzC,CAAC;AAEJ,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AppPropertySchema } from "../../types/properties";
|
|
3
|
+
export const GetConnectionStartUrlSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
app: AppPropertySchema,
|
|
6
|
+
})
|
|
7
|
+
.describe("Mint a short-lived URL that begins an SDK-initiated connection flow. The URL is signed by zapier.com and bound to the current user/account — opening it in a different browser session will fail the binding check. Returns the URL as data so the caller decides what to do with it.\n\nUse this directly (rather than the higher-level `create-connection`) when you want either of: (a) hand off the URL and *not* block waiting for completion — call this alone, skip `wait-for-new-connection` entirely, or (b) do something custom between minting the URL and waiting for the connection — call this, then email or DM the URL, render it as a QR code for mobile sign-in, etc., then call `wait-for-new-connection`. For the common case where you'd just print and poll back-to-back, `create-connection` is one call.\n\nPair with `wait-for-new-connection` to detect completion: pass the `startedAt` returned here straight through (it's the server's mint time, so polling isn't affected by client clock skew). Example (JS):\n\n```ts\nconst { data: { url, app, startedAt } } = await zapier.getConnectionStartUrl({ app: 'slack' });\n// hand `url` off — print it, DM it, email it, render a button, whatever\nconst { data: conn } = await zapier.waitForNewConnection({ app, startedAt });\n```");
|
|
8
|
+
export const GetConnectionStartUrlItemSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
url: z
|
|
11
|
+
.string()
|
|
12
|
+
.describe("URL the user should open in their browser to complete the auth flow. Single-use, time-limited."),
|
|
13
|
+
expiresAt: z
|
|
14
|
+
.number()
|
|
15
|
+
.describe("Unix timestamp (seconds) after which the URL's signature is rejected by zapier.com."),
|
|
16
|
+
startedAt: z
|
|
17
|
+
.number()
|
|
18
|
+
.describe("Unix timestamp (seconds) when the server minted the URL. Use it as the `startedAt` for `wait-for-new-connection` so polling is anchored to server time rather than a possibly-skewed client clock."),
|
|
19
|
+
app: z
|
|
20
|
+
.string()
|
|
21
|
+
.describe("Versionless app key the URL was minted for (e.g., 'SlackCLIAPI'). Useful for downstream filtering."),
|
|
22
|
+
})
|
|
23
|
+
.describe("The signed start-URL plus metadata needed to poll for completion.");
|