@zapier/zapier-sdk 0.70.4 → 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 +15 -0
- package/README.md +133 -15
- 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 +593 -33
- package/dist/experimental.d.mts +86 -2
- package/dist/experimental.d.ts +88 -4
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +10 -0
- package/dist/experimental.mjs +593 -34
- package/dist/{index-BNaiNmM-.d.mts → index-B43uST61.d.mts} +181 -12
- package/dist/{index-BNaiNmM-.d.ts → index-B43uST61.d.ts} +181 -12
- 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 +1 -1
- package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts +4 -4
- package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts +2 -2
- package/dist/plugins/codeSubstrate/getWorkflow/schemas.d.ts +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/listWorkflows/schemas.d.ts +2 -2
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/shared-schemas.d.ts +2 -2
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts +1 -1
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAUtD,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAE3D,eAAO,MAAM,SAAS;aACH;QAAE,OAAO,EAAE,cAAc,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAUtD,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAE3D,eAAO,MAAM,SAAS;aACH;QAAE,OAAO,EAAE,cAAc,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;CAiD7C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { resolveCredentials } from "../../credentials";
|
|
|
4
4
|
import { ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, } from "../../constants";
|
|
5
5
|
export const apiPlugin = definePlugin((sdk) => {
|
|
6
6
|
// Extract all options - everything passed to the plugin
|
|
7
|
-
const { fetch: customFetch = globalThis.fetch, baseUrl = ZAPIER_BASE_URL, credentials, token, onEvent, debug = false, maxNetworkRetries = ZAPIER_MAX_NETWORK_RETRIES, maxNetworkRetryDelayMs = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, maxConcurrentRequests = ZAPIER_MAX_CONCURRENT_REQUESTS, approvalTimeoutMs, maxApprovalRetries, approvalMode, callerPackage, } = sdk.context.options;
|
|
7
|
+
const { fetch: customFetch = globalThis.fetch, baseUrl = ZAPIER_BASE_URL, credentials, token, onEvent, debug = false, maxNetworkRetries = ZAPIER_MAX_NETWORK_RETRIES, maxNetworkRetryDelayMs = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, maxConcurrentRequests = ZAPIER_MAX_CONCURRENT_REQUESTS, approvalTimeoutMs, maxApprovalRetries, approvalMode, openAutoModeApprovalsInBrowser, callerPackage, } = sdk.context.options;
|
|
8
8
|
// Create the API client - it will handle token resolution internally
|
|
9
9
|
const api = createZapierApi({
|
|
10
10
|
baseUrl,
|
|
@@ -19,6 +19,7 @@ export const apiPlugin = definePlugin((sdk) => {
|
|
|
19
19
|
approvalTimeoutMs,
|
|
20
20
|
maxApprovalRetries,
|
|
21
21
|
approvalMode,
|
|
22
|
+
openAutoModeApprovalsInBrowser,
|
|
22
23
|
callerPackage,
|
|
23
24
|
});
|
|
24
25
|
return {
|
|
@@ -37,7 +37,7 @@ export declare const deleteWorkflowPlugin: (sdk: {
|
|
|
37
37
|
triggers: {
|
|
38
38
|
selected_api: string;
|
|
39
39
|
action: string;
|
|
40
|
-
status: "pending" | "active" | "unclaimed" | "releasing" | "released"
|
|
40
|
+
status: "failed" | "pending" | "active" | "unclaimed" | "releasing" | "released";
|
|
41
41
|
authentication_id?: string | null | undefined;
|
|
42
42
|
params?: Record<string, unknown> | undefined;
|
|
43
43
|
}[];
|
|
@@ -37,7 +37,7 @@ export declare const disableWorkflowPlugin: (sdk: {
|
|
|
37
37
|
triggers: {
|
|
38
38
|
selected_api: string;
|
|
39
39
|
action: string;
|
|
40
|
-
status: "pending" | "active" | "unclaimed" | "releasing" | "released"
|
|
40
|
+
status: "failed" | "pending" | "active" | "unclaimed" | "releasing" | "released";
|
|
41
41
|
authentication_id?: string | null | undefined;
|
|
42
42
|
params?: Record<string, unknown> | undefined;
|
|
43
43
|
}[];
|
|
@@ -37,7 +37,7 @@ export declare const enableWorkflowPlugin: (sdk: {
|
|
|
37
37
|
triggers: {
|
|
38
38
|
selected_api: string;
|
|
39
39
|
action: string;
|
|
40
|
-
status: "pending" | "active" | "unclaimed" | "releasing" | "released"
|
|
40
|
+
status: "failed" | "pending" | "active" | "unclaimed" | "releasing" | "released";
|
|
41
41
|
authentication_id?: string | null | undefined;
|
|
42
42
|
params?: Record<string, unknown> | undefined;
|
|
43
43
|
}[];
|
|
@@ -6,8 +6,8 @@ export declare const OperationTypeSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
|
6
6
|
}>, z.ZodString]>;
|
|
7
7
|
export type OperationType = z.infer<typeof OperationTypeSchema>;
|
|
8
8
|
export declare const OperationStatusSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
9
|
-
pending: "pending";
|
|
10
9
|
failed: "failed";
|
|
10
|
+
pending: "pending";
|
|
11
11
|
exhausted: "exhausted";
|
|
12
12
|
completed: "completed";
|
|
13
13
|
}>, z.ZodString]>;
|
|
@@ -22,8 +22,8 @@ export declare const OperationSchema: z.ZodObject<{
|
|
|
22
22
|
callback: "callback";
|
|
23
23
|
}>, z.ZodString]>;
|
|
24
24
|
status: z.ZodUnion<readonly [z.ZodEnum<{
|
|
25
|
-
pending: "pending";
|
|
26
25
|
failed: "failed";
|
|
26
|
+
pending: "pending";
|
|
27
27
|
exhausted: "exhausted";
|
|
28
28
|
completed: "completed";
|
|
29
29
|
}>, z.ZodString]>;
|
|
@@ -80,8 +80,8 @@ export declare const ExecutionSummarySchema: z.ZodObject<{
|
|
|
80
80
|
callback: "callback";
|
|
81
81
|
}>, z.ZodString]>;
|
|
82
82
|
status: z.ZodUnion<readonly [z.ZodEnum<{
|
|
83
|
-
pending: "pending";
|
|
84
83
|
failed: "failed";
|
|
84
|
+
pending: "pending";
|
|
85
85
|
exhausted: "exhausted";
|
|
86
86
|
completed: "completed";
|
|
87
87
|
}>, z.ZodString]>;
|
|
@@ -151,8 +151,8 @@ export declare const GetDurableRunResponseSchema: z.ZodObject<{
|
|
|
151
151
|
callback: "callback";
|
|
152
152
|
}>, z.ZodString]>;
|
|
153
153
|
status: z.ZodUnion<readonly [z.ZodEnum<{
|
|
154
|
-
pending: "pending";
|
|
155
154
|
failed: "failed";
|
|
155
|
+
pending: "pending";
|
|
156
156
|
exhausted: "exhausted";
|
|
157
157
|
completed: "completed";
|
|
158
158
|
}>, z.ZodString]>;
|
|
@@ -37,7 +37,7 @@ export declare const getWorkflowPlugin: (sdk: {
|
|
|
37
37
|
triggers: {
|
|
38
38
|
selected_api: string;
|
|
39
39
|
action: string;
|
|
40
|
-
status: "pending" | "active" | "unclaimed" | "releasing" | "released"
|
|
40
|
+
status: "failed" | "pending" | "active" | "unclaimed" | "releasing" | "released";
|
|
41
41
|
authentication_id?: string | null | undefined;
|
|
42
42
|
params?: Record<string, unknown> | undefined;
|
|
43
43
|
}[];
|
|
@@ -69,7 +69,7 @@ export declare const getWorkflowPlugin: (sdk: {
|
|
|
69
69
|
triggers: {
|
|
70
70
|
selected_api: string;
|
|
71
71
|
action: string;
|
|
72
|
-
status: "pending" | "active" | "unclaimed" | "releasing" | "released"
|
|
72
|
+
status: "failed" | "pending" | "active" | "unclaimed" | "releasing" | "released";
|
|
73
73
|
authentication_id?: string | null | undefined;
|
|
74
74
|
params?: Record<string, unknown> | undefined;
|
|
75
75
|
}[];
|
|
@@ -62,12 +62,12 @@ export declare const GetWorkflowResponseSchema: z.ZodObject<{
|
|
|
62
62
|
authentication_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
63
63
|
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
64
64
|
status: z.ZodEnum<{
|
|
65
|
+
failed: "failed";
|
|
65
66
|
pending: "pending";
|
|
66
67
|
active: "active";
|
|
67
68
|
unclaimed: "unclaimed";
|
|
68
69
|
releasing: "releasing";
|
|
69
70
|
released: "released";
|
|
70
|
-
failed: "failed";
|
|
71
71
|
}>;
|
|
72
72
|
}, z.core.$strip>>;
|
|
73
73
|
created_at: z.ZodString;
|
|
@@ -37,7 +37,7 @@ export declare const getWorkflowRunPlugin: (sdk: {
|
|
|
37
37
|
triggers: {
|
|
38
38
|
selected_api: string;
|
|
39
39
|
action: string;
|
|
40
|
-
status: "pending" | "active" | "unclaimed" | "releasing" | "released"
|
|
40
|
+
status: "failed" | "pending" | "active" | "unclaimed" | "releasing" | "released";
|
|
41
41
|
authentication_id?: string | null | undefined;
|
|
42
42
|
params?: Record<string, unknown> | undefined;
|
|
43
43
|
}[];
|
|
@@ -37,7 +37,7 @@ export declare const getWorkflowVersionPlugin: (sdk: {
|
|
|
37
37
|
triggers: {
|
|
38
38
|
selected_api: string;
|
|
39
39
|
action: string;
|
|
40
|
-
status: "pending" | "active" | "unclaimed" | "releasing" | "released"
|
|
40
|
+
status: "failed" | "pending" | "active" | "unclaimed" | "releasing" | "released";
|
|
41
41
|
authentication_id?: string | null | undefined;
|
|
42
42
|
params?: Record<string, unknown> | undefined;
|
|
43
43
|
}[];
|
|
@@ -37,7 +37,7 @@ export declare const listWorkflowRunsPlugin: (sdk: {
|
|
|
37
37
|
triggers: {
|
|
38
38
|
selected_api: string;
|
|
39
39
|
action: string;
|
|
40
|
-
status: "pending" | "active" | "unclaimed" | "releasing" | "released"
|
|
40
|
+
status: "failed" | "pending" | "active" | "unclaimed" | "releasing" | "released";
|
|
41
41
|
authentication_id?: string | null | undefined;
|
|
42
42
|
params?: Record<string, unknown> | undefined;
|
|
43
43
|
}[];
|
|
@@ -37,7 +37,7 @@ export declare const listWorkflowVersionsPlugin: (sdk: {
|
|
|
37
37
|
triggers: {
|
|
38
38
|
selected_api: string;
|
|
39
39
|
action: string;
|
|
40
|
-
status: "pending" | "active" | "unclaimed" | "releasing" | "released"
|
|
40
|
+
status: "failed" | "pending" | "active" | "unclaimed" | "releasing" | "released";
|
|
41
41
|
authentication_id?: string | null | undefined;
|
|
42
42
|
params?: Record<string, unknown> | undefined;
|
|
43
43
|
}[];
|
|
@@ -41,7 +41,7 @@ export declare const listWorkflowsPlugin: (sdk: {
|
|
|
41
41
|
triggers: {
|
|
42
42
|
selected_api: string;
|
|
43
43
|
action: string;
|
|
44
|
-
status: "pending" | "active" | "unclaimed" | "releasing" | "released"
|
|
44
|
+
status: "failed" | "pending" | "active" | "unclaimed" | "releasing" | "released";
|
|
45
45
|
authentication_id?: string | null | undefined;
|
|
46
46
|
params?: Record<string, unknown> | undefined;
|
|
47
47
|
}[];
|
|
@@ -14,12 +14,12 @@ export declare const WorkflowItemSchema: z.ZodObject<{
|
|
|
14
14
|
authentication_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
15
15
|
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
16
16
|
status: z.ZodEnum<{
|
|
17
|
+
failed: "failed";
|
|
17
18
|
pending: "pending";
|
|
18
19
|
active: "active";
|
|
19
20
|
unclaimed: "unclaimed";
|
|
20
21
|
releasing: "releasing";
|
|
21
22
|
released: "released";
|
|
22
|
-
failed: "failed";
|
|
23
23
|
}>;
|
|
24
24
|
}, z.core.$strip>>;
|
|
25
25
|
created_at: z.ZodString;
|
|
@@ -55,12 +55,12 @@ export declare const ListWorkflowsApiResponseSchema: z.ZodObject<{
|
|
|
55
55
|
authentication_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
56
56
|
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
57
57
|
status: z.ZodEnum<{
|
|
58
|
+
failed: "failed";
|
|
58
59
|
pending: "pending";
|
|
59
60
|
active: "active";
|
|
60
61
|
unclaimed: "unclaimed";
|
|
61
62
|
releasing: "releasing";
|
|
62
63
|
released: "released";
|
|
63
|
-
failed: "failed";
|
|
64
64
|
}>;
|
|
65
65
|
}, z.core.$strip>>;
|
|
66
66
|
created_at: z.ZodString;
|
|
@@ -37,7 +37,7 @@ export declare const publishWorkflowVersionPlugin: (sdk: {
|
|
|
37
37
|
triggers: {
|
|
38
38
|
selected_api: string;
|
|
39
39
|
action: string;
|
|
40
|
-
status: "pending" | "active" | "unclaimed" | "releasing" | "released"
|
|
40
|
+
status: "failed" | "pending" | "active" | "unclaimed" | "releasing" | "released";
|
|
41
41
|
authentication_id?: string | null | undefined;
|
|
42
42
|
params?: Record<string, unknown> | undefined;
|
|
43
43
|
}[];
|
|
@@ -13,12 +13,12 @@ export declare const WorkflowVersionTriggerConfigSchema: z.ZodObject<{
|
|
|
13
13
|
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
14
14
|
}, z.core.$strip>;
|
|
15
15
|
export declare const WorkflowTriggerStatusSchema: z.ZodEnum<{
|
|
16
|
+
failed: "failed";
|
|
16
17
|
pending: "pending";
|
|
17
18
|
active: "active";
|
|
18
19
|
unclaimed: "unclaimed";
|
|
19
20
|
releasing: "releasing";
|
|
20
21
|
released: "released";
|
|
21
|
-
failed: "failed";
|
|
22
22
|
}>;
|
|
23
23
|
export declare const WorkflowTriggerSchema: z.ZodObject<{
|
|
24
24
|
selected_api: z.ZodString;
|
|
@@ -26,12 +26,12 @@ export declare const WorkflowTriggerSchema: z.ZodObject<{
|
|
|
26
26
|
authentication_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
27
|
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
28
28
|
status: z.ZodEnum<{
|
|
29
|
+
failed: "failed";
|
|
29
30
|
pending: "pending";
|
|
30
31
|
active: "active";
|
|
31
32
|
unclaimed: "unclaimed";
|
|
32
33
|
releasing: "releasing";
|
|
33
34
|
released: "released";
|
|
34
|
-
failed: "failed";
|
|
35
35
|
}>;
|
|
36
36
|
}, z.core.$strip>;
|
|
37
37
|
//# sourceMappingURL=shared-schemas.d.ts.map
|
|
@@ -37,7 +37,7 @@ export declare const triggerWorkflowPlugin: (sdk: {
|
|
|
37
37
|
triggers: {
|
|
38
38
|
selected_api: string;
|
|
39
39
|
action: string;
|
|
40
|
-
status: "pending" | "active" | "unclaimed" | "releasing" | "released"
|
|
40
|
+
status: "failed" | "pending" | "active" | "unclaimed" | "releasing" | "released";
|
|
41
41
|
authentication_id?: string | null | undefined;
|
|
42
42
|
params?: Record<string, unknown> | undefined;
|
|
43
43
|
}[];
|
|
@@ -37,7 +37,7 @@ export declare const updateWorkflowPlugin: (sdk: {
|
|
|
37
37
|
triggers: {
|
|
38
38
|
selected_api: string;
|
|
39
39
|
action: string;
|
|
40
|
-
status: "pending" | "active" | "unclaimed" | "releasing" | "released"
|
|
40
|
+
status: "failed" | "pending" | "active" | "unclaimed" | "releasing" | "released";
|
|
41
41
|
authentication_id?: string | null | undefined;
|
|
42
42
|
params?: Record<string, unknown> | undefined;
|
|
43
43
|
}[];
|
|
@@ -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.");
|