@zapier/zapier-sdk 0.0.3 → 0.1.1
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/dist/api/auth.d.ts +8 -0
- package/dist/api/auth.js +29 -0
- package/dist/api/client.d.ts +8 -0
- package/dist/api/client.js +102 -0
- package/dist/api/debug.d.ts +12 -0
- package/dist/api/debug.js +50 -0
- package/dist/api/index.d.ts +26 -0
- package/dist/api/index.js +51 -0
- package/dist/api/polling.d.ts +17 -0
- package/dist/api/polling.js +34 -0
- package/dist/{types.d.ts → api/types.d.ts} +37 -88
- package/dist/api/types.js +9 -0
- package/dist/functions/{bundleCode.d.ts → bundleCode/index.d.ts} +1 -8
- package/dist/functions/bundleCode/info.d.ts +27 -0
- package/dist/functions/bundleCode/info.js +11 -0
- package/dist/functions/bundleCode/schemas.d.ts +27 -0
- package/dist/functions/bundleCode/schemas.js +22 -0
- package/dist/functions/findFirstAuthentication/index.d.ts +12 -0
- package/dist/functions/findFirstAuthentication/index.js +21 -0
- package/dist/functions/findFirstAuthentication/info.d.ts +30 -0
- package/dist/functions/findFirstAuthentication/info.js +11 -0
- package/dist/functions/findFirstAuthentication/schemas.d.ts +42 -0
- package/dist/functions/findFirstAuthentication/schemas.js +25 -0
- package/dist/functions/findUniqueAuthentication/index.d.ts +13 -0
- package/dist/functions/findUniqueAuthentication/index.js +28 -0
- package/dist/functions/findUniqueAuthentication/info.d.ts +30 -0
- package/dist/functions/findUniqueAuthentication/info.js +11 -0
- package/dist/functions/findUniqueAuthentication/schemas.d.ts +42 -0
- package/dist/functions/findUniqueAuthentication/schemas.js +25 -0
- package/dist/functions/{generateTypes.d.ts → generateTypes/index.d.ts} +2 -7
- package/dist/functions/{generateTypes.js → generateTypes/index.js} +58 -24
- package/dist/functions/generateTypes/info.d.ts +21 -0
- package/dist/functions/generateTypes/info.js +11 -0
- package/dist/functions/generateTypes/schemas.d.ts +30 -0
- package/dist/functions/generateTypes/schemas.js +14 -0
- package/dist/functions/{getAction.d.ts → getAction/index.d.ts} +2 -6
- package/dist/functions/{getAction.js → getAction/index.js} +6 -5
- package/dist/functions/getAction/info.d.ts +18 -0
- package/dist/functions/getAction/info.js +11 -0
- package/dist/functions/getAction/schemas.d.ts +30 -0
- package/dist/functions/getAction/schemas.js +13 -0
- package/dist/functions/{getApp.d.ts → getApp/index.d.ts} +2 -4
- package/dist/functions/{getApp.js → getApp/index.js} +6 -10
- package/dist/functions/getApp/info.d.ts +12 -0
- package/dist/functions/getApp/info.js +11 -0
- package/dist/functions/getApp/schemas.d.ts +24 -0
- package/dist/functions/getApp/schemas.js +11 -0
- package/dist/functions/{listActions.d.ts → listActions/index.d.ts} +3 -6
- package/dist/functions/{listActions.js → listActions/index.js} +4 -3
- package/dist/functions/listActions/info.d.ts +15 -0
- package/dist/functions/listActions/info.js +11 -0
- package/dist/functions/listActions/schemas.d.ts +27 -0
- package/dist/functions/listActions/schemas.js +14 -0
- package/dist/functions/{listApps.d.ts → listApps/index.d.ts} +2 -6
- package/dist/functions/{listApps.js → listApps/index.js} +1 -1
- package/dist/functions/listApps/info.d.ts +18 -0
- package/dist/functions/listApps/info.js +11 -0
- package/dist/functions/listApps/schemas.d.ts +30 -0
- package/dist/functions/listApps/schemas.js +15 -0
- package/dist/functions/{listAuths.d.ts → listAuthentications/index.d.ts} +3 -9
- package/dist/functions/{listAuths.js → listAuthentications/index.js} +28 -12
- package/dist/functions/listAuthentications/info.d.ts +30 -0
- package/dist/functions/listAuthentications/info.js +11 -0
- package/dist/functions/listAuthentications/schemas.d.ts +42 -0
- package/dist/functions/listAuthentications/schemas.js +25 -0
- package/dist/functions/{listFields.d.ts → listFields/index.d.ts} +3 -9
- package/dist/functions/{listFields.js → listFields/index.js} +8 -10
- package/dist/functions/listFields/info.d.ts +24 -0
- package/dist/functions/listFields/info.js +11 -0
- package/dist/functions/listFields/schemas.d.ts +36 -0
- package/dist/functions/listFields/schemas.js +17 -0
- package/dist/functions/{runAction.d.ts → runAction/index.d.ts} +2 -8
- package/dist/functions/{runAction.js → runAction/index.js} +15 -14
- package/dist/functions/runAction/info.d.ts +24 -0
- package/dist/functions/runAction/info.js +11 -0
- package/dist/functions/runAction/schemas.d.ts +36 -0
- package/dist/functions/runAction/schemas.js +15 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +17 -6
- package/dist/plugins/apps/index.d.ts +8 -0
- package/dist/plugins/apps/index.js +77 -0
- package/dist/plugins/apps/info.d.ts +6 -0
- package/dist/plugins/apps/info.js +13 -0
- package/dist/plugins/apps/types.d.ts +21 -0
- package/dist/plugins/apps/types.js +2 -0
- package/dist/resolvers/actionKey.d.ts +8 -0
- package/dist/resolvers/actionKey.js +20 -0
- package/dist/resolvers/actionType.d.ts +8 -0
- package/dist/resolvers/actionType.js +21 -0
- package/dist/resolvers/appKey.d.ts +6 -0
- package/dist/resolvers/appKey.js +8 -0
- package/dist/resolvers/authenticationId.d.ts +8 -0
- package/dist/resolvers/authenticationId.js +29 -0
- package/dist/resolvers/index.d.ts +39 -0
- package/dist/resolvers/index.js +105 -0
- package/dist/resolvers/inputs.d.ts +7 -0
- package/dist/resolvers/inputs.js +15 -0
- package/dist/schema-utils.d.ts +44 -0
- package/dist/schema-utils.js +76 -0
- package/dist/schemas/Action.d.ts +21 -0
- package/dist/schemas/Action.js +31 -0
- package/dist/schemas/App.d.ts +19 -0
- package/dist/schemas/App.js +32 -0
- package/dist/schemas/Auth.d.ts +27 -0
- package/dist/schemas/Auth.js +42 -0
- package/dist/schemas/Field.d.ts +15 -0
- package/dist/schemas/Field.js +25 -0
- package/dist/sdk.d.ts +3 -4
- package/dist/sdk.js +104 -11
- package/dist/types/domain.d.ts +22 -0
- package/dist/types/domain.js +21 -0
- package/dist/types/properties.d.ts +21 -0
- package/dist/types/properties.js +43 -0
- package/dist/types/sdk.d.ts +23 -0
- package/dist/types/sdk.js +2 -0
- package/package.json +4 -2
- package/src/api/auth.ts +28 -0
- package/src/api/client.ts +148 -0
- package/src/api/debug.ts +58 -0
- package/src/api/index.ts +83 -0
- package/src/api/polling.ts +56 -0
- package/src/api/types.ts +177 -0
- package/src/functions/{bundleCode.ts → bundleCode/index.ts} +1 -8
- package/src/functions/bundleCode/info.ts +9 -0
- package/src/functions/bundleCode/schemas.ts +30 -0
- package/src/functions/findFirstAuthentication/index.ts +24 -0
- package/src/functions/findFirstAuthentication/info.ts +9 -0
- package/src/functions/findFirstAuthentication/schemas.ts +60 -0
- package/src/functions/findUniqueAuthentication/index.ts +35 -0
- package/src/functions/findUniqueAuthentication/info.ts +9 -0
- package/src/functions/findUniqueAuthentication/schemas.ts +60 -0
- package/src/functions/{generateTypes.ts → generateTypes/index.ts} +70 -31
- package/src/functions/generateTypes/info.ts +9 -0
- package/src/functions/generateTypes/schemas.ts +38 -0
- package/src/functions/{getAction.ts → getAction/index.ts} +11 -12
- package/src/functions/getAction/info.ts +9 -0
- package/src/functions/getAction/schemas.ts +35 -0
- package/src/functions/{getApp.ts → getApp/index.ts} +9 -15
- package/src/functions/getApp/info.ts +9 -0
- package/src/functions/getApp/schemas.ts +31 -0
- package/src/functions/{listActions.ts → listActions/index.ts} +8 -10
- package/src/functions/listActions/info.ts +9 -0
- package/src/functions/listActions/schemas.ts +40 -0
- package/src/functions/{listApps.ts → listApps/index.ts} +3 -8
- package/src/functions/listApps/info.ts +9 -0
- package/src/functions/listApps/schemas.ts +43 -0
- package/src/functions/{listAuths.ts → listAuthentications/index.ts} +32 -23
- package/src/functions/listAuthentications/info.ts +9 -0
- package/src/functions/listAuthentications/schemas.ts +60 -0
- package/src/functions/{listFields.ts → listFields/index.ts} +11 -20
- package/src/functions/listFields/info.ts +9 -0
- package/src/functions/listFields/schemas.ts +46 -0
- package/src/functions/{runAction.ts → runAction/index.ts} +25 -23
- package/src/functions/runAction/info.ts +9 -0
- package/src/functions/runAction/schemas.ts +41 -0
- package/src/index.ts +19 -5
- package/src/plugins/apps/index.ts +144 -0
- package/src/plugins/apps/info.ts +12 -0
- package/src/plugins/apps/types.ts +34 -0
- package/src/resolvers/actionKey.ts +33 -0
- package/src/resolvers/actionType.ts +30 -0
- package/src/resolvers/appKey.ts +11 -0
- package/src/resolvers/authenticationId.ts +38 -0
- package/src/resolvers/index.ts +117 -0
- package/src/resolvers/inputs.ts +23 -0
- package/src/schema-utils.ts +154 -0
- package/src/schemas/Action.ts +40 -0
- package/src/schemas/App.ts +43 -0
- package/src/schemas/Auth.ts +54 -0
- package/src/schemas/Field.ts +34 -0
- package/src/sdk.ts +165 -19
- package/src/types/domain.ts +54 -0
- package/src/types/properties.ts +67 -0
- package/src/types/sdk.ts +46 -0
- package/dist/actions-sdk.d.ts +0 -47
- package/dist/actions-sdk.js +0 -208
- package/dist/api.d.ts +0 -62
- package/dist/api.js +0 -227
- package/dist/output-schemas.d.ts +0 -95
- package/dist/output-schemas.js +0 -138
- package/dist/schemas.d.ts +0 -338
- package/dist/schemas.js +0 -336
- package/dist/types.js +0 -41
- package/src/actions-sdk.ts +0 -356
- package/src/api.ts +0 -361
- package/src/output-schemas.ts +0 -196
- package/src/schemas.ts +0 -467
- package/src/types.ts +0 -257
- /package/dist/functions/{bundleCode.js → bundleCode/index.js} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
AppKeyPropertySchema,
|
|
4
|
+
ActionTypePropertySchema,
|
|
5
|
+
} from "../../types/properties";
|
|
6
|
+
import { withOutputSchema } from "../../schema-utils";
|
|
7
|
+
import { ActionItemSchema } from "../../schemas/Action";
|
|
8
|
+
import type { Action } from "../../types/domain";
|
|
9
|
+
|
|
10
|
+
// Pure Zod schema - no resolver metadata!
|
|
11
|
+
export const ListActionsSchema = withOutputSchema(
|
|
12
|
+
z
|
|
13
|
+
.object({
|
|
14
|
+
appKey: AppKeyPropertySchema.optional(),
|
|
15
|
+
type: ActionTypePropertySchema.optional().describe(
|
|
16
|
+
"Filter actions by type",
|
|
17
|
+
),
|
|
18
|
+
})
|
|
19
|
+
.describe("List all actions for a specific app"),
|
|
20
|
+
ActionItemSchema,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
// Type inferred from schema + function config
|
|
24
|
+
export type ListActionsOptions = z.infer<typeof ListActionsSchema> & {
|
|
25
|
+
/** Base URL for Zapier API */
|
|
26
|
+
baseUrl?: string;
|
|
27
|
+
/** Authentication token */
|
|
28
|
+
token?: string;
|
|
29
|
+
/** Optional pre-instantiated API client */
|
|
30
|
+
api?: any;
|
|
31
|
+
/** Enable debug logging */
|
|
32
|
+
debug?: boolean;
|
|
33
|
+
/** Custom fetch implementation */
|
|
34
|
+
fetch?: typeof globalThis.fetch;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// SDK function interface - ready to be mixed into main SDK interface
|
|
38
|
+
export interface ListActionsSdkFunction {
|
|
39
|
+
listActions: (options?: Partial<ListActionsOptions>) => Promise<Action[]>;
|
|
40
|
+
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { getOrCreateApiClient } from "
|
|
2
|
-
import type { Integration
|
|
3
|
-
|
|
4
|
-
export interface ListAppsOptions extends FunctionConfig {
|
|
5
|
-
category?: string;
|
|
6
|
-
limit?: number;
|
|
7
|
-
offset?: number;
|
|
8
|
-
}
|
|
1
|
+
import { getOrCreateApiClient } from "../../api";
|
|
2
|
+
import type { Integration } from "../../types/domain";
|
|
3
|
+
import type { ListAppsOptions } from "./schemas";
|
|
9
4
|
|
|
10
5
|
/**
|
|
11
6
|
* List available apps with optional filtering
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { listApps } from "./index";
|
|
2
|
+
import { ListAppsSchema } from "./schemas";
|
|
3
|
+
|
|
4
|
+
// Function registry info - imports both function and schema
|
|
5
|
+
export const listAppsInfo = {
|
|
6
|
+
name: listApps.name,
|
|
7
|
+
inputSchema: ListAppsSchema,
|
|
8
|
+
implementation: listApps,
|
|
9
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
LimitPropertySchema,
|
|
4
|
+
OffsetPropertySchema,
|
|
5
|
+
} from "../../types/properties";
|
|
6
|
+
import { withOutputSchema } from "../../schema-utils";
|
|
7
|
+
import { AppItemSchema } from "../../schemas/App";
|
|
8
|
+
import type { Integration } from "../../types/domain";
|
|
9
|
+
|
|
10
|
+
// Pure Zod schema - no resolver metadata!
|
|
11
|
+
export const ListAppsSchema = withOutputSchema(
|
|
12
|
+
z
|
|
13
|
+
.object({
|
|
14
|
+
category: z.string().optional().describe("Filter apps by category"),
|
|
15
|
+
limit: LimitPropertySchema.optional().describe(
|
|
16
|
+
"Maximum number of items to return (1-200)",
|
|
17
|
+
),
|
|
18
|
+
offset: OffsetPropertySchema.optional().describe(
|
|
19
|
+
"Number of items to skip for pagination",
|
|
20
|
+
),
|
|
21
|
+
})
|
|
22
|
+
.describe("List all available apps with optional filtering"),
|
|
23
|
+
AppItemSchema,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// Type inferred from schema + function config
|
|
27
|
+
export type ListAppsOptions = z.infer<typeof ListAppsSchema> & {
|
|
28
|
+
/** Base URL for Zapier API */
|
|
29
|
+
baseUrl?: string;
|
|
30
|
+
/** Authentication token */
|
|
31
|
+
token?: string;
|
|
32
|
+
/** Optional pre-instantiated API client */
|
|
33
|
+
api?: any;
|
|
34
|
+
/** Enable debug logging */
|
|
35
|
+
debug?: boolean;
|
|
36
|
+
/** Custom fetch implementation */
|
|
37
|
+
fetch?: typeof globalThis.fetch;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// SDK function interface - ready to be mixed into main SDK interface
|
|
41
|
+
export interface ListAppsSdkFunction {
|
|
42
|
+
listApps: (options?: Partial<ListAppsOptions>) => Promise<Integration[]>;
|
|
43
|
+
}
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
import { getOrCreateApiClient } from "
|
|
1
|
+
import { getOrCreateApiClient } from "../../api";
|
|
2
2
|
import type {
|
|
3
3
|
Authentication,
|
|
4
4
|
AuthenticationsResponse,
|
|
5
|
-
|
|
6
|
-
} from "../
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
export interface ListAuthsOptions extends FunctionConfig {
|
|
10
|
-
appKey?: string;
|
|
11
|
-
account_id?: string;
|
|
12
|
-
owner?: string;
|
|
13
|
-
limit?: number;
|
|
14
|
-
offset?: number;
|
|
15
|
-
}
|
|
5
|
+
} from "../../types/domain";
|
|
6
|
+
import { getApp } from "../getApp";
|
|
7
|
+
import type { ListAuthenticationsOptions } from "./schemas";
|
|
16
8
|
|
|
17
9
|
/**
|
|
18
10
|
* List available authentications with optional filtering
|
|
@@ -23,8 +15,8 @@ export interface ListAuthsOptions extends FunctionConfig {
|
|
|
23
15
|
* @param options - Filtering, pagination, and API configuration options
|
|
24
16
|
* @returns Promise<Authentication[]> with pagination metadata
|
|
25
17
|
*/
|
|
26
|
-
export async function
|
|
27
|
-
options:
|
|
18
|
+
export async function listAuthentications(
|
|
19
|
+
options: Partial<ListAuthenticationsOptions> = {},
|
|
28
20
|
): Promise<Authentication[]> {
|
|
29
21
|
const { token } = options;
|
|
30
22
|
|
|
@@ -37,8 +29,8 @@ export async function listAuths(
|
|
|
37
29
|
const api = getOrCreateApiClient(options);
|
|
38
30
|
|
|
39
31
|
// Local function to handle the actual API fetching
|
|
40
|
-
const
|
|
41
|
-
options:
|
|
32
|
+
const listAuthenticationsInternal = async (
|
|
33
|
+
options: ListAuthenticationsOptions = {},
|
|
42
34
|
): Promise<Authentication[]> => {
|
|
43
35
|
// Build search parameters
|
|
44
36
|
const searchParams: Record<string, string> = {};
|
|
@@ -48,7 +40,7 @@ export async function listAuths(
|
|
|
48
40
|
try {
|
|
49
41
|
// Use the standalone getApp function
|
|
50
42
|
const app = await getApp({
|
|
51
|
-
|
|
43
|
+
appKey: options.appKey,
|
|
52
44
|
api,
|
|
53
45
|
token: options.token,
|
|
54
46
|
baseUrl: options.baseUrl,
|
|
@@ -76,6 +68,12 @@ export async function listAuths(
|
|
|
76
68
|
}
|
|
77
69
|
|
|
78
70
|
// Add other query parameters if provided
|
|
71
|
+
// Use title as search if no explicit search provided
|
|
72
|
+
if (options.search) {
|
|
73
|
+
searchParams.search = options.search;
|
|
74
|
+
} else if (options.title) {
|
|
75
|
+
searchParams.search = options.title;
|
|
76
|
+
}
|
|
79
77
|
if (options.account_id) {
|
|
80
78
|
searchParams.account_id = options.account_id;
|
|
81
79
|
}
|
|
@@ -110,7 +108,18 @@ export async function listAuths(
|
|
|
110
108
|
);
|
|
111
109
|
|
|
112
110
|
// Transform API response
|
|
113
|
-
|
|
111
|
+
let auths = data.results || [];
|
|
112
|
+
|
|
113
|
+
// Coerce title from label if title is missing (API cleanup)
|
|
114
|
+
auths = auths.map((auth) => ({
|
|
115
|
+
...auth,
|
|
116
|
+
title: auth.title || (auth as any).label || undefined,
|
|
117
|
+
}));
|
|
118
|
+
|
|
119
|
+
// Filter by exact title match if specified
|
|
120
|
+
if (options.title) {
|
|
121
|
+
auths = auths.filter((auth) => auth.title === options.title);
|
|
122
|
+
}
|
|
114
123
|
|
|
115
124
|
// Add pagination metadata to the response
|
|
116
125
|
if (auths.length > 0) {
|
|
@@ -129,7 +138,7 @@ export async function listAuths(
|
|
|
129
138
|
// If a limit is provided and no specific owner filter, prioritize owned auths
|
|
130
139
|
if (options.limit && options.owner === undefined) {
|
|
131
140
|
// First get owned auths
|
|
132
|
-
const ownedAuths = await
|
|
141
|
+
const ownedAuths = await listAuthenticationsInternal({
|
|
133
142
|
...options,
|
|
134
143
|
owner: "me",
|
|
135
144
|
});
|
|
@@ -140,15 +149,15 @@ export async function listAuths(
|
|
|
140
149
|
}
|
|
141
150
|
|
|
142
151
|
// Get all auths up to the original limit to fill remaining slots
|
|
143
|
-
const allAuths = await
|
|
152
|
+
const allAuths = await listAuthenticationsInternal({
|
|
144
153
|
...options,
|
|
145
154
|
owner: undefined,
|
|
146
155
|
});
|
|
147
156
|
|
|
148
157
|
// Filter out auths the user already owns to avoid duplicates
|
|
149
|
-
const
|
|
158
|
+
const ownedAuthenticationIds = new Set(ownedAuths.map((auth) => auth.id));
|
|
150
159
|
const additionalAuths = allAuths.filter(
|
|
151
|
-
(auth) => !
|
|
160
|
+
(auth) => !ownedAuthenticationIds.has(auth.id),
|
|
152
161
|
);
|
|
153
162
|
|
|
154
163
|
// Combine and slice to the requested limit
|
|
@@ -157,5 +166,5 @@ export async function listAuths(
|
|
|
157
166
|
}
|
|
158
167
|
|
|
159
168
|
// Standard implementation for non-prioritized requests
|
|
160
|
-
return
|
|
169
|
+
return listAuthenticationsInternal(options);
|
|
161
170
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { listAuthentications } from "./index";
|
|
2
|
+
import { ListAuthenticationsSchema } from "./schemas";
|
|
3
|
+
|
|
4
|
+
// Function registry info - imports both function and schema
|
|
5
|
+
export const listAuthenticationsInfo = {
|
|
6
|
+
name: listAuthentications.name,
|
|
7
|
+
inputSchema: ListAuthenticationsSchema,
|
|
8
|
+
implementation: listAuthentications,
|
|
9
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
AppKeyPropertySchema,
|
|
4
|
+
LimitPropertySchema,
|
|
5
|
+
OffsetPropertySchema,
|
|
6
|
+
} from "../../types/properties";
|
|
7
|
+
import { withOutputSchema } from "../../schema-utils";
|
|
8
|
+
import { AuthItemSchema } from "../../schemas/Auth";
|
|
9
|
+
import type { Authentication } from "../../types/domain";
|
|
10
|
+
|
|
11
|
+
// Pure Zod schema - no resolver metadata!
|
|
12
|
+
export const ListAuthenticationsSchema = withOutputSchema(
|
|
13
|
+
z
|
|
14
|
+
.object({
|
|
15
|
+
appKey: AppKeyPropertySchema.optional().describe(
|
|
16
|
+
"App slug to get authentications for (e.g., 'slack', 'github')",
|
|
17
|
+
),
|
|
18
|
+
search: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Search term to filter authentications by title"),
|
|
22
|
+
title: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Filter authentications by exact title match"),
|
|
26
|
+
account_id: z.string().optional().describe("Filter by account ID"),
|
|
27
|
+
owner: z.string().optional().describe("Filter by owner"),
|
|
28
|
+
limit: LimitPropertySchema.optional().describe(
|
|
29
|
+
"Maximum number of items to return (1-200)",
|
|
30
|
+
),
|
|
31
|
+
offset: OffsetPropertySchema.optional().describe(
|
|
32
|
+
"Number of items to skip for pagination",
|
|
33
|
+
),
|
|
34
|
+
})
|
|
35
|
+
.describe("List available authentications with optional filtering"),
|
|
36
|
+
AuthItemSchema,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// Type inferred from schema + function config
|
|
40
|
+
export type ListAuthenticationsOptions = z.infer<
|
|
41
|
+
typeof ListAuthenticationsSchema
|
|
42
|
+
> & {
|
|
43
|
+
/** Base URL for Zapier API */
|
|
44
|
+
baseUrl?: string;
|
|
45
|
+
/** Authentication token */
|
|
46
|
+
token?: string;
|
|
47
|
+
/** Optional pre-instantiated API client */
|
|
48
|
+
api?: any;
|
|
49
|
+
/** Enable debug logging */
|
|
50
|
+
debug?: boolean;
|
|
51
|
+
/** Custom fetch implementation */
|
|
52
|
+
fetch?: typeof globalThis.fetch;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// SDK function interface - ready to be mixed into main SDK interface
|
|
56
|
+
export interface ListAuthenticationsSdkFunction {
|
|
57
|
+
listAuthentications: (
|
|
58
|
+
options?: Partial<ListAuthenticationsOptions>,
|
|
59
|
+
) => Promise<Authentication[]>;
|
|
60
|
+
}
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import { getOrCreateApiClient } from "
|
|
1
|
+
import { getOrCreateApiClient } from "../../api";
|
|
2
2
|
import type {
|
|
3
3
|
ActionField,
|
|
4
4
|
NeedsRequest,
|
|
5
5
|
NeedsResponse,
|
|
6
|
-
|
|
7
|
-
} from "../
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
export interface ListFieldsOptions extends FunctionConfig {
|
|
11
|
-
app: string;
|
|
12
|
-
action: string;
|
|
13
|
-
type: string;
|
|
14
|
-
authId?: number;
|
|
15
|
-
params?: Record<string, any>;
|
|
16
|
-
}
|
|
6
|
+
} from "../../types/domain";
|
|
7
|
+
import { getApp } from "../getApp";
|
|
8
|
+
import type { ListFieldsOptions } from "./schemas";
|
|
17
9
|
|
|
18
10
|
/**
|
|
19
11
|
* List available fields for an action
|
|
@@ -21,7 +13,7 @@ export interface ListFieldsOptions extends FunctionConfig {
|
|
|
21
13
|
* This function can be used standalone without instantiating a full SDK,
|
|
22
14
|
* which enables better tree-shaking in applications that only need this functionality.
|
|
23
15
|
*
|
|
24
|
-
* @param options - Action details,
|
|
16
|
+
* @param options - Action details, authentication ID, params, and API configuration options
|
|
25
17
|
* @returns Promise<ActionField[]>
|
|
26
18
|
*/
|
|
27
19
|
export async function listFields(
|
|
@@ -29,15 +21,12 @@ export async function listFields(
|
|
|
29
21
|
): Promise<ActionField[]> {
|
|
30
22
|
const api = getOrCreateApiClient(options);
|
|
31
23
|
|
|
32
|
-
//
|
|
33
|
-
const {
|
|
34
|
-
const appKey = app;
|
|
35
|
-
const actionKey = action;
|
|
36
|
-
const actionType = type;
|
|
24
|
+
// Extract parameters
|
|
25
|
+
const { appKey, actionKey, actionType, authenticationId, params } = options;
|
|
37
26
|
|
|
38
27
|
// Use the standalone getApp function
|
|
39
28
|
const appData = await getApp({
|
|
40
|
-
|
|
29
|
+
appKey,
|
|
41
30
|
api,
|
|
42
31
|
token: options.token,
|
|
43
32
|
baseUrl: options.baseUrl,
|
|
@@ -55,7 +44,7 @@ export async function listFields(
|
|
|
55
44
|
selected_api: selectedApi,
|
|
56
45
|
action: actionKey,
|
|
57
46
|
type_of: actionType,
|
|
58
|
-
authentication_id:
|
|
47
|
+
authentication_id: authenticationId,
|
|
59
48
|
params: params || {},
|
|
60
49
|
};
|
|
61
50
|
|
|
@@ -93,3 +82,5 @@ export async function listFields(
|
|
|
93
82
|
inputFormat: need.input_format,
|
|
94
83
|
}));
|
|
95
84
|
}
|
|
85
|
+
|
|
86
|
+
// No registry info here - moved to info.ts for proper tree-shaking
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { listFields } from "./index";
|
|
2
|
+
import { ListFieldsSchema } from "./schemas";
|
|
3
|
+
|
|
4
|
+
// Function registry info - imports both function and schema
|
|
5
|
+
export const listFieldsInfo = {
|
|
6
|
+
name: listFields.name,
|
|
7
|
+
inputSchema: ListFieldsSchema,
|
|
8
|
+
implementation: listFields,
|
|
9
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
AppKeyPropertySchema,
|
|
4
|
+
ActionTypePropertySchema,
|
|
5
|
+
ActionKeyPropertySchema,
|
|
6
|
+
AuthenticationIdPropertySchema,
|
|
7
|
+
ParamsPropertySchema,
|
|
8
|
+
} from "../../types/properties";
|
|
9
|
+
import { withOutputSchema } from "../../schema-utils";
|
|
10
|
+
import { FieldItemSchema } from "../../schemas/Field";
|
|
11
|
+
import type { ActionField } from "../../types/domain";
|
|
12
|
+
|
|
13
|
+
// Pure Zod schema - no resolver metadata!
|
|
14
|
+
export const ListFieldsSchema = withOutputSchema(
|
|
15
|
+
z
|
|
16
|
+
.object({
|
|
17
|
+
appKey: AppKeyPropertySchema,
|
|
18
|
+
actionType: ActionTypePropertySchema,
|
|
19
|
+
actionKey: ActionKeyPropertySchema,
|
|
20
|
+
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
21
|
+
params: ParamsPropertySchema.optional().describe(
|
|
22
|
+
"Additional parameters that may affect available fields",
|
|
23
|
+
),
|
|
24
|
+
})
|
|
25
|
+
.describe("Get the input fields required for a specific action"),
|
|
26
|
+
FieldItemSchema,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// Type inferred from schema + function config
|
|
30
|
+
export type ListFieldsOptions = z.infer<typeof ListFieldsSchema> & {
|
|
31
|
+
/** Base URL for Zapier API */
|
|
32
|
+
baseUrl?: string;
|
|
33
|
+
/** Authentication token */
|
|
34
|
+
token?: string;
|
|
35
|
+
/** Optional pre-instantiated API client */
|
|
36
|
+
api?: any;
|
|
37
|
+
/** Enable debug logging */
|
|
38
|
+
debug?: boolean;
|
|
39
|
+
/** Custom fetch implementation */
|
|
40
|
+
fetch?: typeof globalThis.fetch;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// SDK function interface - ready to be mixed into main SDK interface
|
|
44
|
+
export interface ListFieldsSdkFunction {
|
|
45
|
+
listFields: (options: ListFieldsOptions) => Promise<ActionField[]>;
|
|
46
|
+
}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import { getOrCreateApiClient, generateRequestId } from "
|
|
2
|
-
import type { ActionExecutionResult
|
|
3
|
-
import { getAction } from "
|
|
4
|
-
import { getApp } from "
|
|
5
|
-
|
|
6
|
-
export interface RunActionOptions extends FunctionConfig {
|
|
7
|
-
app: string;
|
|
8
|
-
type: string;
|
|
9
|
-
action: string;
|
|
10
|
-
inputs?: Record<string, any>;
|
|
11
|
-
authId?: number;
|
|
12
|
-
}
|
|
1
|
+
import { getOrCreateApiClient, generateRequestId } from "../../api";
|
|
2
|
+
import type { ActionExecutionResult } from "../../types/domain";
|
|
3
|
+
import { getAction } from "../getAction";
|
|
4
|
+
import { getApp } from "../getApp";
|
|
5
|
+
import type { RunActionOptions } from "./schemas";
|
|
13
6
|
|
|
14
7
|
/**
|
|
15
8
|
* Execute an action
|
|
@@ -23,7 +16,14 @@ export interface RunActionOptions extends FunctionConfig {
|
|
|
23
16
|
export async function runAction(
|
|
24
17
|
options: RunActionOptions,
|
|
25
18
|
): Promise<ActionExecutionResult> {
|
|
26
|
-
const {
|
|
19
|
+
const {
|
|
20
|
+
appKey,
|
|
21
|
+
actionType,
|
|
22
|
+
actionKey,
|
|
23
|
+
inputs,
|
|
24
|
+
authenticationId: providedAuthenticationId,
|
|
25
|
+
token,
|
|
26
|
+
} = options;
|
|
27
27
|
|
|
28
28
|
if (!token && !process.env.ZAPIER_TOKEN) {
|
|
29
29
|
throw new Error(
|
|
@@ -36,15 +36,15 @@ export async function runAction(
|
|
|
36
36
|
// Validate that the action exists
|
|
37
37
|
const actionData = await getAction({
|
|
38
38
|
...options,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
appKey: appKey,
|
|
40
|
+
actionKey: actionKey,
|
|
41
|
+
actionType: actionType,
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
// Validate action type matches
|
|
45
|
-
if (actionData.type !==
|
|
45
|
+
if (actionData.type !== actionType) {
|
|
46
46
|
throw new Error(
|
|
47
|
-
`Action type mismatch: expected ${
|
|
47
|
+
`Action type mismatch: expected ${actionType}, got ${actionData.type}`,
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -52,12 +52,12 @@ export async function runAction(
|
|
|
52
52
|
const startTime = Date.now();
|
|
53
53
|
const result = await executeActionWithStrategy({
|
|
54
54
|
api,
|
|
55
|
-
appSlug:
|
|
56
|
-
actionKey:
|
|
55
|
+
appSlug: appKey,
|
|
56
|
+
actionKey: actionKey,
|
|
57
57
|
actionType: actionData.type,
|
|
58
58
|
executionOptions: { inputs: inputs || {} },
|
|
59
59
|
auth: token
|
|
60
|
-
? { token: token, authentication_id:
|
|
60
|
+
? { token: token, authentication_id: providedAuthenticationId }
|
|
61
61
|
: undefined,
|
|
62
62
|
options,
|
|
63
63
|
});
|
|
@@ -150,7 +150,7 @@ async function executeActionViaActionsApi(
|
|
|
150
150
|
|
|
151
151
|
// Use the standalone getApp function
|
|
152
152
|
const appData = await getApp({
|
|
153
|
-
|
|
153
|
+
appKey: appSlug,
|
|
154
154
|
api,
|
|
155
155
|
token: options.token,
|
|
156
156
|
baseUrl: options.baseUrl,
|
|
@@ -216,7 +216,7 @@ async function executeActionViaInvokeApi(
|
|
|
216
216
|
|
|
217
217
|
// Use the standalone getApp function
|
|
218
218
|
const appData = await getApp({
|
|
219
|
-
|
|
219
|
+
appKey: appSlug,
|
|
220
220
|
api,
|
|
221
221
|
token: options.token,
|
|
222
222
|
baseUrl: options.baseUrl,
|
|
@@ -254,3 +254,5 @@ async function executeActionViaInvokeApi(
|
|
|
254
254
|
resultExtractor: (result: any) => result.results || result,
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
|
+
|
|
258
|
+
// No registry info here - moved to info.ts for proper tree-shaking
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { runAction } from "./index";
|
|
2
|
+
import { RunActionSchema } from "./schemas";
|
|
3
|
+
|
|
4
|
+
// Function registry info - imports both function and schema
|
|
5
|
+
export const runActionInfo = {
|
|
6
|
+
name: runAction.name,
|
|
7
|
+
inputSchema: RunActionSchema,
|
|
8
|
+
implementation: runAction,
|
|
9
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
AppKeyPropertySchema,
|
|
4
|
+
ActionTypePropertySchema,
|
|
5
|
+
ActionKeyPropertySchema,
|
|
6
|
+
AuthenticationIdPropertySchema,
|
|
7
|
+
InputsPropertySchema,
|
|
8
|
+
} from "../../types/properties";
|
|
9
|
+
import type { ActionExecutionResult } from "../../types/domain";
|
|
10
|
+
|
|
11
|
+
// Pure Zod schema - no resolver metadata!
|
|
12
|
+
export const RunActionSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
appKey: AppKeyPropertySchema,
|
|
15
|
+
actionType: ActionTypePropertySchema,
|
|
16
|
+
actionKey: ActionKeyPropertySchema,
|
|
17
|
+
inputs: InputsPropertySchema.optional().describe(
|
|
18
|
+
"Input parameters for the action",
|
|
19
|
+
),
|
|
20
|
+
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
21
|
+
})
|
|
22
|
+
.describe("Execute an action with the given inputs");
|
|
23
|
+
|
|
24
|
+
// Type inferred from schema + function config
|
|
25
|
+
export type RunActionOptions = z.infer<typeof RunActionSchema> & {
|
|
26
|
+
/** Base URL for Zapier API */
|
|
27
|
+
baseUrl?: string;
|
|
28
|
+
/** Authentication token */
|
|
29
|
+
token?: string;
|
|
30
|
+
/** Optional pre-instantiated API client */
|
|
31
|
+
api?: any;
|
|
32
|
+
/** Enable debug logging */
|
|
33
|
+
debug?: boolean;
|
|
34
|
+
/** Custom fetch implementation */
|
|
35
|
+
fetch?: typeof globalThis.fetch;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// SDK function interface - ready to be mixed into main SDK interface
|
|
39
|
+
export interface RunActionSdkFunction {
|
|
40
|
+
runAction: (options: RunActionOptions) => Promise<ActionExecutionResult>;
|
|
41
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
// Export everything from types and
|
|
2
|
-
export * from "./types";
|
|
3
|
-
export * from "./
|
|
1
|
+
// Export everything from types and plugins
|
|
2
|
+
export * from "./types/domain";
|
|
3
|
+
export * from "./types/properties";
|
|
4
|
+
export * from "./plugins/apps";
|
|
5
|
+
|
|
6
|
+
// Export schema utilities for CLI
|
|
7
|
+
export { isPositional } from "./schema-utils";
|
|
8
|
+
|
|
9
|
+
// Export resolvers for CLI use
|
|
10
|
+
export * from "./resolvers";
|
|
11
|
+
|
|
12
|
+
// Note: SdkSchemas is now available via SDK.__registry
|
|
4
13
|
|
|
5
14
|
// Export individual functions for tree-shaking
|
|
6
|
-
export {
|
|
15
|
+
export { listAuthentications } from "./functions/listAuthentications";
|
|
16
|
+
export { findFirstAuthentication } from "./functions/findFirstAuthentication";
|
|
17
|
+
export { findUniqueAuthentication } from "./functions/findUniqueAuthentication";
|
|
7
18
|
export { listApps } from "./functions/listApps";
|
|
8
19
|
export { getApp } from "./functions/getApp";
|
|
9
20
|
export { listActions } from "./functions/listActions";
|
|
@@ -14,4 +25,7 @@ export { generateTypes } from "./functions/generateTypes";
|
|
|
14
25
|
export { bundleCode } from "./functions/bundleCode";
|
|
15
26
|
|
|
16
27
|
// Export the main combined SDK
|
|
17
|
-
export { createZapierSdk,
|
|
28
|
+
export { createZapierSdk, ZapierSdkOptions } from "./sdk";
|
|
29
|
+
|
|
30
|
+
// Export SDK type from types (not sdk.ts to avoid circular imports)
|
|
31
|
+
export type { ZapierSdk } from "./types/sdk";
|