@zapier/zapier-sdk 0.0.1 → 0.0.3

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.
Files changed (49) hide show
  1. package/dist/actions-sdk.d.ts +47 -0
  2. package/dist/actions-sdk.js +208 -0
  3. package/dist/api.d.ts +62 -0
  4. package/dist/api.js +227 -0
  5. package/dist/functions/bundleCode.d.ts +18 -0
  6. package/dist/functions/bundleCode.js +91 -0
  7. package/dist/functions/generateTypes.d.ts +16 -0
  8. package/dist/functions/generateTypes.js +271 -0
  9. package/dist/functions/getAction.d.ts +16 -0
  10. package/dist/functions/getAction.js +25 -0
  11. package/dist/functions/getApp.d.ts +14 -0
  12. package/dist/functions/getApp.js +41 -0
  13. package/dist/functions/listActions.d.ts +15 -0
  14. package/dist/functions/listActions.js +127 -0
  15. package/dist/functions/listApps.d.ts +16 -0
  16. package/dist/functions/listApps.js +50 -0
  17. package/dist/functions/listAuths.d.ts +18 -0
  18. package/dist/functions/listAuths.js +118 -0
  19. package/dist/functions/listFields.d.ts +18 -0
  20. package/dist/functions/listFields.js +67 -0
  21. package/dist/functions/runAction.d.ts +18 -0
  22. package/dist/functions/runAction.js +156 -0
  23. package/dist/index.d.ts +12 -3
  24. package/dist/index.js +24 -5
  25. package/dist/output-schemas.d.ts +95 -0
  26. package/dist/output-schemas.js +138 -0
  27. package/dist/schemas.d.ts +338 -0
  28. package/dist/schemas.js +336 -0
  29. package/dist/sdk.d.ts +5 -5
  30. package/dist/sdk.js +8 -8
  31. package/dist/types.d.ts +196 -0
  32. package/dist/types.js +41 -0
  33. package/package.json +5 -3
  34. package/src/actions-sdk.ts +356 -0
  35. package/src/api.ts +361 -0
  36. package/src/functions/bundleCode.ts +85 -0
  37. package/src/functions/generateTypes.ts +309 -0
  38. package/src/functions/getAction.ts +34 -0
  39. package/src/functions/getApp.ts +47 -0
  40. package/src/functions/listActions.ts +151 -0
  41. package/src/functions/listApps.ts +65 -0
  42. package/src/functions/listAuths.ts +161 -0
  43. package/src/functions/listFields.ts +95 -0
  44. package/src/functions/runAction.ts +256 -0
  45. package/src/index.ts +15 -4
  46. package/src/output-schemas.ts +196 -0
  47. package/src/schemas.ts +467 -0
  48. package/src/sdk.ts +13 -13
  49. package/src/types.ts +257 -0
@@ -0,0 +1,338 @@
1
+ import { z } from "zod";
2
+ export interface StaticResolver {
3
+ type: "static";
4
+ inputType?: "input" | "password" | "editor";
5
+ placeholder?: string;
6
+ }
7
+ export interface DynamicResolver {
8
+ type: "dynamic";
9
+ fetch: (sdk: any, resolvedParams: any) => Promise<any[]>;
10
+ prompt: (items: any[], params: any) => any;
11
+ depends?: string[];
12
+ }
13
+ export interface FieldsResolver {
14
+ type: "fields";
15
+ fetch: (sdk: any, resolvedParams: any) => Promise<any[]>;
16
+ depends?: string[];
17
+ }
18
+ export interface ResolverMetadata {
19
+ resolver?: StaticResolver | DynamicResolver | FieldsResolver;
20
+ }
21
+ export declare const AppsListSchema: z.ZodObject<{
22
+ limit: z.ZodOptional<z.ZodNumber>;
23
+ offset: z.ZodOptional<z.ZodNumber>;
24
+ category: z.ZodOptional<z.ZodString>;
25
+ }, "strip", z.ZodTypeAny, {
26
+ category?: string | undefined;
27
+ limit?: number | undefined;
28
+ offset?: number | undefined;
29
+ }, {
30
+ category?: string | undefined;
31
+ limit?: number | undefined;
32
+ offset?: number | undefined;
33
+ }>;
34
+ export declare const AppsGetSchema: z.ZodObject<{
35
+ key: z.ZodString;
36
+ }, "strip", z.ZodTypeAny, {
37
+ key: string;
38
+ }, {
39
+ key: string;
40
+ }>;
41
+ export declare const FieldsListSchema: z.ZodObject<{
42
+ app: z.ZodString;
43
+ type: z.ZodEnum<["read", "write", "search", "create", "update", "delete"]>;
44
+ action: z.ZodString;
45
+ authId: z.ZodOptional<z.ZodNumber>;
46
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
47
+ }, "strip", z.ZodTypeAny, {
48
+ action: string;
49
+ type: "create" | "update" | "search" | "delete" | "read" | "write";
50
+ app: string;
51
+ authId?: number | undefined;
52
+ params?: Record<string, any> | undefined;
53
+ }, {
54
+ action: string;
55
+ type: "create" | "update" | "search" | "delete" | "read" | "write";
56
+ app: string;
57
+ authId?: number | undefined;
58
+ params?: Record<string, any> | undefined;
59
+ }>;
60
+ export declare const ActionsListSchema: z.ZodObject<{
61
+ appKey: z.ZodString;
62
+ type: z.ZodOptional<z.ZodEnum<["read", "write", "search", "create", "update", "delete"]>>;
63
+ }, "strip", z.ZodTypeAny, {
64
+ appKey: string;
65
+ type?: "create" | "update" | "search" | "delete" | "read" | "write" | undefined;
66
+ }, {
67
+ appKey: string;
68
+ type?: "create" | "update" | "search" | "delete" | "read" | "write" | undefined;
69
+ }>;
70
+ export declare const ActionsGetSchema: z.ZodObject<{
71
+ app: z.ZodString;
72
+ type: z.ZodEnum<["read", "write", "search", "create", "update", "delete"]>;
73
+ action: z.ZodString;
74
+ }, "strip", z.ZodTypeAny, {
75
+ action: string;
76
+ type: "create" | "update" | "search" | "delete" | "read" | "write";
77
+ app: string;
78
+ }, {
79
+ action: string;
80
+ type: "create" | "update" | "search" | "delete" | "read" | "write";
81
+ app: string;
82
+ }>;
83
+ export declare const ActionsRunSchema: z.ZodObject<{
84
+ app: z.ZodString;
85
+ type: z.ZodEnum<["read", "write", "search", "create", "update", "delete"]>;
86
+ action: z.ZodString;
87
+ inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
88
+ authId: z.ZodOptional<z.ZodNumber>;
89
+ }, "strip", z.ZodTypeAny, {
90
+ action: string;
91
+ type: "create" | "update" | "search" | "delete" | "read" | "write";
92
+ app: string;
93
+ inputs?: Record<string, any> | undefined;
94
+ authId?: number | undefined;
95
+ }, {
96
+ action: string;
97
+ type: "create" | "update" | "search" | "delete" | "read" | "write";
98
+ app: string;
99
+ inputs?: Record<string, any> | undefined;
100
+ authId?: number | undefined;
101
+ }>;
102
+ export declare const AuthsListSchema: z.ZodObject<{
103
+ limit: z.ZodOptional<z.ZodNumber>;
104
+ offset: z.ZodOptional<z.ZodNumber>;
105
+ appKey: z.ZodString;
106
+ account_id: z.ZodOptional<z.ZodString>;
107
+ owner: z.ZodOptional<z.ZodString>;
108
+ }, "strip", z.ZodTypeAny, {
109
+ appKey: string;
110
+ account_id?: string | undefined;
111
+ owner?: string | undefined;
112
+ limit?: number | undefined;
113
+ offset?: number | undefined;
114
+ }, {
115
+ appKey: string;
116
+ account_id?: string | undefined;
117
+ owner?: string | undefined;
118
+ limit?: number | undefined;
119
+ offset?: number | undefined;
120
+ }>;
121
+ export declare const AuthsFindSchema: z.ZodObject<{
122
+ appKey: z.ZodString;
123
+ }, "strip", z.ZodTypeAny, {
124
+ appKey: string;
125
+ }, {
126
+ appKey: string;
127
+ }>;
128
+ export declare const GenerateSchema: z.ZodObject<{
129
+ appKey: z.ZodString;
130
+ token: z.ZodOptional<z.ZodString>;
131
+ authId: z.ZodOptional<z.ZodNumber>;
132
+ output: z.ZodOptional<z.ZodString>;
133
+ debug: z.ZodDefault<z.ZodBoolean>;
134
+ }, "strip", z.ZodTypeAny, {
135
+ debug: boolean;
136
+ appKey: string;
137
+ token?: string | undefined;
138
+ authId?: number | undefined;
139
+ output?: string | undefined;
140
+ }, {
141
+ appKey: string;
142
+ token?: string | undefined;
143
+ debug?: boolean | undefined;
144
+ authId?: number | undefined;
145
+ output?: string | undefined;
146
+ }>;
147
+ export declare const BundleSchema: z.ZodObject<{
148
+ input: z.ZodString;
149
+ output: z.ZodOptional<z.ZodString>;
150
+ string: z.ZodDefault<z.ZodBoolean>;
151
+ minify: z.ZodDefault<z.ZodBoolean>;
152
+ target: z.ZodDefault<z.ZodString>;
153
+ cjs: z.ZodDefault<z.ZodBoolean>;
154
+ }, "strip", z.ZodTypeAny, {
155
+ string: boolean;
156
+ input: string;
157
+ target: string;
158
+ cjs: boolean;
159
+ minify: boolean;
160
+ output?: string | undefined;
161
+ }, {
162
+ input: string;
163
+ string?: boolean | undefined;
164
+ output?: string | undefined;
165
+ target?: string | undefined;
166
+ cjs?: boolean | undefined;
167
+ minify?: boolean | undefined;
168
+ }>;
169
+ export declare const SdkSchemas: {
170
+ readonly apps: {
171
+ readonly list: z.ZodObject<{
172
+ limit: z.ZodOptional<z.ZodNumber>;
173
+ offset: z.ZodOptional<z.ZodNumber>;
174
+ category: z.ZodOptional<z.ZodString>;
175
+ }, "strip", z.ZodTypeAny, {
176
+ category?: string | undefined;
177
+ limit?: number | undefined;
178
+ offset?: number | undefined;
179
+ }, {
180
+ category?: string | undefined;
181
+ limit?: number | undefined;
182
+ offset?: number | undefined;
183
+ }>;
184
+ readonly get: z.ZodObject<{
185
+ key: z.ZodString;
186
+ }, "strip", z.ZodTypeAny, {
187
+ key: string;
188
+ }, {
189
+ key: string;
190
+ }>;
191
+ };
192
+ readonly actions: {
193
+ readonly list: z.ZodObject<{
194
+ appKey: z.ZodString;
195
+ type: z.ZodOptional<z.ZodEnum<["read", "write", "search", "create", "update", "delete"]>>;
196
+ }, "strip", z.ZodTypeAny, {
197
+ appKey: string;
198
+ type?: "create" | "update" | "search" | "delete" | "read" | "write" | undefined;
199
+ }, {
200
+ appKey: string;
201
+ type?: "create" | "update" | "search" | "delete" | "read" | "write" | undefined;
202
+ }>;
203
+ readonly get: z.ZodObject<{
204
+ app: z.ZodString;
205
+ type: z.ZodEnum<["read", "write", "search", "create", "update", "delete"]>;
206
+ action: z.ZodString;
207
+ }, "strip", z.ZodTypeAny, {
208
+ action: string;
209
+ type: "create" | "update" | "search" | "delete" | "read" | "write";
210
+ app: string;
211
+ }, {
212
+ action: string;
213
+ type: "create" | "update" | "search" | "delete" | "read" | "write";
214
+ app: string;
215
+ }>;
216
+ readonly run: z.ZodObject<{
217
+ app: z.ZodString;
218
+ type: z.ZodEnum<["read", "write", "search", "create", "update", "delete"]>;
219
+ action: z.ZodString;
220
+ inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
221
+ authId: z.ZodOptional<z.ZodNumber>;
222
+ }, "strip", z.ZodTypeAny, {
223
+ action: string;
224
+ type: "create" | "update" | "search" | "delete" | "read" | "write";
225
+ app: string;
226
+ inputs?: Record<string, any> | undefined;
227
+ authId?: number | undefined;
228
+ }, {
229
+ action: string;
230
+ type: "create" | "update" | "search" | "delete" | "read" | "write";
231
+ app: string;
232
+ inputs?: Record<string, any> | undefined;
233
+ authId?: number | undefined;
234
+ }>;
235
+ };
236
+ readonly auths: {
237
+ readonly list: z.ZodObject<{
238
+ limit: z.ZodOptional<z.ZodNumber>;
239
+ offset: z.ZodOptional<z.ZodNumber>;
240
+ appKey: z.ZodString;
241
+ account_id: z.ZodOptional<z.ZodString>;
242
+ owner: z.ZodOptional<z.ZodString>;
243
+ }, "strip", z.ZodTypeAny, {
244
+ appKey: string;
245
+ account_id?: string | undefined;
246
+ owner?: string | undefined;
247
+ limit?: number | undefined;
248
+ offset?: number | undefined;
249
+ }, {
250
+ appKey: string;
251
+ account_id?: string | undefined;
252
+ owner?: string | undefined;
253
+ limit?: number | undefined;
254
+ offset?: number | undefined;
255
+ }>;
256
+ readonly find: z.ZodObject<{
257
+ appKey: z.ZodString;
258
+ }, "strip", z.ZodTypeAny, {
259
+ appKey: string;
260
+ }, {
261
+ appKey: string;
262
+ }>;
263
+ };
264
+ readonly fields: {
265
+ readonly list: z.ZodObject<{
266
+ app: z.ZodString;
267
+ type: z.ZodEnum<["read", "write", "search", "create", "update", "delete"]>;
268
+ action: z.ZodString;
269
+ authId: z.ZodOptional<z.ZodNumber>;
270
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
271
+ }, "strip", z.ZodTypeAny, {
272
+ action: string;
273
+ type: "create" | "update" | "search" | "delete" | "read" | "write";
274
+ app: string;
275
+ authId?: number | undefined;
276
+ params?: Record<string, any> | undefined;
277
+ }, {
278
+ action: string;
279
+ type: "create" | "update" | "search" | "delete" | "read" | "write";
280
+ app: string;
281
+ authId?: number | undefined;
282
+ params?: Record<string, any> | undefined;
283
+ }>;
284
+ };
285
+ readonly generate: z.ZodObject<{
286
+ appKey: z.ZodString;
287
+ token: z.ZodOptional<z.ZodString>;
288
+ authId: z.ZodOptional<z.ZodNumber>;
289
+ output: z.ZodOptional<z.ZodString>;
290
+ debug: z.ZodDefault<z.ZodBoolean>;
291
+ }, "strip", z.ZodTypeAny, {
292
+ debug: boolean;
293
+ appKey: string;
294
+ token?: string | undefined;
295
+ authId?: number | undefined;
296
+ output?: string | undefined;
297
+ }, {
298
+ appKey: string;
299
+ token?: string | undefined;
300
+ debug?: boolean | undefined;
301
+ authId?: number | undefined;
302
+ output?: string | undefined;
303
+ }>;
304
+ readonly bundle: z.ZodObject<{
305
+ input: z.ZodString;
306
+ output: z.ZodOptional<z.ZodString>;
307
+ string: z.ZodDefault<z.ZodBoolean>;
308
+ minify: z.ZodDefault<z.ZodBoolean>;
309
+ target: z.ZodDefault<z.ZodString>;
310
+ cjs: z.ZodDefault<z.ZodBoolean>;
311
+ }, "strip", z.ZodTypeAny, {
312
+ string: boolean;
313
+ input: string;
314
+ target: string;
315
+ cjs: boolean;
316
+ minify: boolean;
317
+ output?: string | undefined;
318
+ }, {
319
+ input: string;
320
+ string?: boolean | undefined;
321
+ output?: string | undefined;
322
+ target?: string | undefined;
323
+ cjs?: boolean | undefined;
324
+ minify?: boolean | undefined;
325
+ }>;
326
+ };
327
+ export type AppsListOptions = z.infer<typeof AppsListSchema>;
328
+ export type AppsGetOptions = z.infer<typeof AppsGetSchema>;
329
+ export type ActionsListOptions = z.infer<typeof ActionsListSchema>;
330
+ export type ActionsGetOptions = z.infer<typeof ActionsGetSchema>;
331
+ export type ActionsRunOptions = z.infer<typeof ActionsRunSchema>;
332
+ export type AuthsListOptions = z.infer<typeof AuthsListSchema>;
333
+ export type AuthsFindOptions = z.infer<typeof AuthsFindSchema>;
334
+ export type FieldsListOptions = z.infer<typeof FieldsListSchema>;
335
+ export type GenerateOptions = z.infer<typeof GenerateSchema>;
336
+ export type BundleOptions = z.infer<typeof BundleSchema>;
337
+ export declare function getSchemaDescription(schema: z.ZodSchema): string | undefined;
338
+ export declare function getFieldDescriptions(schema: z.ZodObject<any>): Record<string, string>;
@@ -0,0 +1,336 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SdkSchemas = exports.BundleSchema = exports.GenerateSchema = exports.AuthsFindSchema = exports.AuthsListSchema = exports.ActionsRunSchema = exports.ActionsGetSchema = exports.ActionsListSchema = exports.FieldsListSchema = exports.AppsGetSchema = exports.AppsListSchema = void 0;
4
+ exports.getSchemaDescription = getSchemaDescription;
5
+ exports.getFieldDescriptions = getFieldDescriptions;
6
+ const zod_1 = require("zod");
7
+ const output_schemas_1 = require("./output-schemas");
8
+ // Helper function to add resolver metadata to schemas
9
+ function withResolver(schema, meta) {
10
+ // Store resolver metadata on the schema definition
11
+ schema._def.resolverMeta = meta;
12
+ return schema;
13
+ }
14
+ // ============================================================================
15
+ // Base Schemas
16
+ // ============================================================================
17
+ const PaginationSchema = zod_1.z.object({
18
+ limit: zod_1.z
19
+ .number()
20
+ .int()
21
+ .min(1)
22
+ .max(200)
23
+ .optional()
24
+ .describe("Maximum number of items to return (1-200)"),
25
+ offset: zod_1.z
26
+ .number()
27
+ .int()
28
+ .min(0)
29
+ .optional()
30
+ .describe("Number of items to skip for pagination"),
31
+ });
32
+ // ============================================================================
33
+ // Apps Service Schemas
34
+ // ============================================================================
35
+ exports.AppsListSchema = (0, output_schemas_1.withOutputSchema)(zod_1.z
36
+ .object({
37
+ category: zod_1.z
38
+ .string()
39
+ .optional()
40
+ .describe("Filter apps by category (e.g., 'productivity', 'crm', 'hr')"),
41
+ ...PaginationSchema.shape,
42
+ })
43
+ .describe("List available apps with optional filtering"), output_schemas_1.AppItemSchema);
44
+ exports.AppsGetSchema = zod_1.z
45
+ .object({
46
+ key: zod_1.z
47
+ .string()
48
+ .min(1)
49
+ .describe("The unique app key/slug (e.g., 'slack', 'github', '100hires-ats')"),
50
+ })
51
+ .describe("Get detailed information about a specific app");
52
+ // ============================================================================
53
+ // Shared Parameter Schemas
54
+ // ============================================================================
55
+ // Shared app parameter with resolver
56
+ const AppParameterSchema = withResolver(zod_1.z.string().min(1).describe("App slug (e.g., 'slack', 'github')"), {
57
+ resolver: {
58
+ type: "static",
59
+ },
60
+ });
61
+ // Shared type parameter with resolver that depends on app
62
+ const ActionTypeParameterSchema = withResolver(zod_1.z
63
+ .enum(["read", "write", "search", "create", "update", "delete"])
64
+ .describe("Action type that matches the action's defined type"), {
65
+ resolver: {
66
+ type: "dynamic",
67
+ depends: ["app"],
68
+ fetch: async (sdk, resolvedParams) => {
69
+ const actions = await sdk.actions.list({ appKey: resolvedParams.app });
70
+ const types = [...new Set(actions.map((action) => action.type))];
71
+ return types.map((type) => ({ key: type, name: type }));
72
+ },
73
+ prompt: (types) => ({
74
+ type: "list",
75
+ name: "type",
76
+ message: "Select action type:",
77
+ choices: types.map((type) => ({
78
+ name: type.name,
79
+ value: type.key,
80
+ })),
81
+ }),
82
+ },
83
+ });
84
+ // Shared action parameter with resolver that depends on app and type
85
+ const ActionParameterSchema = withResolver(zod_1.z.string().min(1).describe("Action key to execute"), {
86
+ resolver: {
87
+ type: "dynamic",
88
+ depends: ["app", "type"],
89
+ fetch: async (sdk, resolvedParams) => {
90
+ const actions = await sdk.actions.list({ appKey: resolvedParams.app });
91
+ return actions.filter((action) => action.type === resolvedParams.type);
92
+ },
93
+ prompt: (actions) => ({
94
+ type: "list",
95
+ name: "action",
96
+ message: "Select action:",
97
+ choices: actions.map((action) => ({
98
+ name: `${action.name || action.key} - ${action.description || "No description"}`,
99
+ value: action.key,
100
+ })),
101
+ }),
102
+ },
103
+ });
104
+ // Shared authId parameter with resolver that depends on app
105
+ const AuthIdParameterSchema = withResolver(zod_1.z
106
+ .number()
107
+ .int()
108
+ .optional()
109
+ .describe("Authentication ID to use for this action"), {
110
+ resolver: {
111
+ type: "dynamic",
112
+ depends: ["app"],
113
+ fetch: async (sdk, resolvedParams) => {
114
+ // Get auths for the specific app (owned auths will be prioritized automatically)
115
+ return await sdk.auths.list({
116
+ appKey: resolvedParams.app,
117
+ limit: 1000,
118
+ });
119
+ },
120
+ prompt: (auths, params) => ({
121
+ type: "list",
122
+ name: "authId",
123
+ message: `Select authentication for ${params.app}:`,
124
+ choices: [
125
+ ...auths.map((auth) => ({
126
+ name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
127
+ value: auth.id,
128
+ })),
129
+ {
130
+ name: "↗ Skip authentication (may fail)",
131
+ value: null,
132
+ },
133
+ ],
134
+ }),
135
+ },
136
+ });
137
+ // ============================================================================
138
+ // Fields Service Schemas
139
+ // ============================================================================
140
+ exports.FieldsListSchema = (0, output_schemas_1.withOutputSchema)(zod_1.z
141
+ .object({
142
+ app: AppParameterSchema,
143
+ type: ActionTypeParameterSchema,
144
+ action: ActionParameterSchema,
145
+ authId: AuthIdParameterSchema,
146
+ params: zod_1.z
147
+ .record(zod_1.z.any())
148
+ .optional()
149
+ .describe("Additional parameters that may affect available fields"),
150
+ })
151
+ .describe("Get the input fields required for a specific action"), output_schemas_1.FieldItemSchema);
152
+ // ============================================================================
153
+ // Actions Service Schemas
154
+ // ============================================================================
155
+ exports.ActionsListSchema = (0, output_schemas_1.withOutputSchema)(zod_1.z
156
+ .object({
157
+ appKey: withResolver(zod_1.z
158
+ .string()
159
+ .min(1)
160
+ .describe("App slug to get actions for (e.g., 'slack', 'github')"), {
161
+ resolver: {
162
+ type: "static",
163
+ },
164
+ }),
165
+ type: zod_1.z
166
+ .enum(["read", "write", "search", "create", "update", "delete"])
167
+ .optional()
168
+ .describe("Filter actions by type"),
169
+ })
170
+ .describe("List all actions for a specific app"), output_schemas_1.ActionItemSchema);
171
+ exports.ActionsGetSchema = zod_1.z
172
+ .object({
173
+ app: AppParameterSchema,
174
+ type: ActionTypeParameterSchema,
175
+ action: ActionParameterSchema,
176
+ })
177
+ .describe("Get detailed information about a specific action");
178
+ exports.ActionsRunSchema = zod_1.z
179
+ .object({
180
+ app: AppParameterSchema,
181
+ type: ActionTypeParameterSchema,
182
+ action: ActionParameterSchema,
183
+ inputs: withResolver(zod_1.z
184
+ .record(zod_1.z.any())
185
+ .optional()
186
+ .describe("Input parameters for the action as key-value pairs"), {
187
+ resolver: {
188
+ type: "fields",
189
+ depends: ["app", "action", "type", "authId"],
190
+ fetch: async (sdk, resolvedParams) => {
191
+ return await sdk.fields.list({
192
+ app: resolvedParams.app,
193
+ action: resolvedParams.action,
194
+ type: resolvedParams.type,
195
+ authId: resolvedParams.authId,
196
+ });
197
+ },
198
+ },
199
+ }),
200
+ authId: AuthIdParameterSchema,
201
+ })
202
+ .describe("Execute an action on a specific app");
203
+ // ============================================================================
204
+ // Auths Service Schemas
205
+ // ============================================================================
206
+ exports.AuthsListSchema = (0, output_schemas_1.withOutputSchema)(zod_1.z
207
+ .object({
208
+ appKey: withResolver(zod_1.z
209
+ .string()
210
+ .min(1)
211
+ .describe("App slug to get authentications for (e.g., 'slack', 'github')"), {
212
+ resolver: {
213
+ type: "static",
214
+ },
215
+ }),
216
+ account_id: zod_1.z.string().optional().describe("Filter by account ID"),
217
+ owner: zod_1.z.string().optional().describe("Filter by owner"),
218
+ ...PaginationSchema.shape,
219
+ })
220
+ .describe("List available authentications with optional filtering"), output_schemas_1.AuthItemSchema);
221
+ exports.AuthsFindSchema = zod_1.z
222
+ .object({
223
+ appKey: zod_1.z.string().min(1).describe("App key to find authentication for"),
224
+ })
225
+ .describe("Find the authentication ID for a specific app");
226
+ // ============================================================================
227
+ // Root Tools Schemas
228
+ // ============================================================================
229
+ exports.GenerateSchema = zod_1.z
230
+ .object({
231
+ appKey: withResolver(zod_1.z.string().min(1).describe("App key to generate SDK code for"), {
232
+ resolver: {
233
+ type: "static",
234
+ },
235
+ }),
236
+ token: zod_1.z
237
+ .string()
238
+ .optional()
239
+ .describe("Zapier API token (defaults to ZAPIER_TOKEN env var)"),
240
+ authId: withResolver(zod_1.z.number().int().optional().describe("Authentication ID to use"), {
241
+ resolver: {
242
+ type: "dynamic",
243
+ depends: ["appKey"],
244
+ fetch: async (sdk, resolvedParams) => {
245
+ // Get auths for the specific app (owned auths will be prioritized automatically)
246
+ return await sdk.auths.list({
247
+ appKey: resolvedParams.appKey,
248
+ limit: 1000,
249
+ });
250
+ },
251
+ prompt: (auths, params) => ({
252
+ type: "list",
253
+ name: "authId",
254
+ message: `Select authentication for ${params.appKey}:`,
255
+ choices: [
256
+ ...auths.map((auth) => ({
257
+ name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
258
+ value: auth.id,
259
+ })),
260
+ {
261
+ name: "↗ Skip authentication (may fail)",
262
+ value: null,
263
+ },
264
+ ],
265
+ }),
266
+ },
267
+ }),
268
+ output: zod_1.z
269
+ .string()
270
+ .optional()
271
+ .describe("Output file path (defaults to generated/<appKey>.ts)"),
272
+ debug: zod_1.z
273
+ .boolean()
274
+ .default(false)
275
+ .describe("Enable debug logging during generation"),
276
+ })
277
+ .describe("Generate TypeScript SDK code for a specific app");
278
+ exports.BundleSchema = zod_1.z
279
+ .object({
280
+ input: zod_1.z.string().min(1).describe("Input TypeScript file path to bundle"),
281
+ output: zod_1.z
282
+ .string()
283
+ .optional()
284
+ .describe("Output file path (defaults to input with .js extension)"),
285
+ string: zod_1.z
286
+ .boolean()
287
+ .default(false)
288
+ .describe("Return bundled code as string instead of writing to file"),
289
+ minify: zod_1.z.boolean().default(false).describe("Minify the bundled output"),
290
+ target: zod_1.z.string().default("es2020").describe("ECMAScript target version"),
291
+ cjs: zod_1.z
292
+ .boolean()
293
+ .default(false)
294
+ .describe("Output CommonJS format instead of ESM"),
295
+ })
296
+ .describe("Bundle TypeScript code into executable JavaScript");
297
+ // ============================================================================
298
+ // SDK Schema Collection
299
+ // ============================================================================
300
+ exports.SdkSchemas = {
301
+ apps: {
302
+ list: exports.AppsListSchema,
303
+ get: exports.AppsGetSchema,
304
+ },
305
+ actions: {
306
+ list: exports.ActionsListSchema,
307
+ get: exports.ActionsGetSchema,
308
+ run: exports.ActionsRunSchema,
309
+ },
310
+ auths: {
311
+ list: exports.AuthsListSchema,
312
+ find: exports.AuthsFindSchema,
313
+ },
314
+ fields: {
315
+ list: exports.FieldsListSchema,
316
+ },
317
+ // Root namespace tools
318
+ generate: exports.GenerateSchema,
319
+ bundle: exports.BundleSchema,
320
+ };
321
+ // ============================================================================
322
+ // Schema Utilities
323
+ // ============================================================================
324
+ function getSchemaDescription(schema) {
325
+ return schema.description;
326
+ }
327
+ function getFieldDescriptions(schema) {
328
+ const descriptions = {};
329
+ const shape = schema.shape;
330
+ for (const [key, fieldSchema] of Object.entries(shape)) {
331
+ if (fieldSchema instanceof zod_1.z.ZodType && fieldSchema.description) {
332
+ descriptions[key] = fieldSchema.description;
333
+ }
334
+ }
335
+ return descriptions;
336
+ }
package/dist/sdk.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ActionsSDK } from "../../actions-sdk/dist";
2
- import { BaseSDKOptions } from "../../shared-sdk/dist";
3
- export interface ZapierSDK extends ActionsSDK {
1
+ import { ActionsSdk } from "./actions-sdk";
2
+ import { BaseSdkOptions } from "./types";
3
+ export interface ZapierSdk extends ActionsSdk {
4
4
  }
5
- export interface ZapierSDKOptions extends BaseSDKOptions {
5
+ export interface ZapierSdkOptions extends BaseSdkOptions {
6
6
  }
7
- export declare function createZapierSDK(options?: ZapierSDKOptions): ZapierSDK;
7
+ export declare function createZapierSdk(options?: ZapierSdkOptions): ZapierSdk;