@zapier/zapier-sdk 0.3.0 → 0.4.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.
Files changed (158) hide show
  1. package/dist/index.cjs +2001 -0
  2. package/dist/index.d.mts +840 -0
  3. package/dist/index.d.ts +840 -20
  4. package/dist/index.mjs +1955 -0
  5. package/package.json +19 -7
  6. package/src/api/client.ts +84 -16
  7. package/src/api/types.ts +9 -1
  8. package/src/auth.ts +19 -287
  9. package/src/functions/fetch/index.ts +180 -0
  10. package/src/functions/fetch/info.ts +8 -0
  11. package/src/functions/fetch/schemas.ts +46 -0
  12. package/src/functions/findFirstAuthentication/schemas.ts +3 -13
  13. package/src/functions/findUniqueAuthentication/schemas.ts +3 -13
  14. package/src/functions/generateTypes/index.ts +15 -0
  15. package/src/functions/generateTypes/schemas.ts +3 -10
  16. package/src/functions/getAction/schemas.ts +3 -13
  17. package/src/functions/getApp/schemas.ts +2 -13
  18. package/src/functions/getAuthentication/index.ts +0 -1
  19. package/src/functions/getAuthentication/schemas.ts +3 -17
  20. package/src/functions/listActions/schemas.ts +3 -13
  21. package/src/functions/listApps/schemas.ts +2 -13
  22. package/src/functions/listAuthentications/index.ts +0 -1
  23. package/src/functions/listAuthentications/schemas.ts +3 -15
  24. package/src/functions/listFields/schemas.ts +3 -13
  25. package/src/functions/runAction/index.ts +0 -1
  26. package/src/functions/runAction/schemas.ts +6 -15
  27. package/src/index.ts +4 -2
  28. package/src/plugins/apps/index.ts +35 -9
  29. package/src/sdk.ts +20 -22
  30. package/src/types/domain.ts +16 -0
  31. package/src/types/sdk.ts +13 -1
  32. package/tsconfig.json +2 -2
  33. package/tsup.config.ts +21 -0
  34. package/dist/api/auth.d.ts +0 -8
  35. package/dist/api/auth.js +0 -29
  36. package/dist/api/client.d.ts +0 -8
  37. package/dist/api/client.js +0 -119
  38. package/dist/api/debug.d.ts +0 -12
  39. package/dist/api/debug.js +0 -50
  40. package/dist/api/index.d.ts +0 -28
  41. package/dist/api/index.js +0 -52
  42. package/dist/api/polling.d.ts +0 -17
  43. package/dist/api/polling.js +0 -34
  44. package/dist/api/types.d.ts +0 -147
  45. package/dist/api/types.js +0 -9
  46. package/dist/auth.d.ts +0 -59
  47. package/dist/auth.js +0 -261
  48. package/dist/functions/bundleCode/index.d.ts +0 -11
  49. package/dist/functions/bundleCode/index.js +0 -91
  50. package/dist/functions/bundleCode/info.d.ts +0 -27
  51. package/dist/functions/bundleCode/info.js +0 -11
  52. package/dist/functions/bundleCode/schemas.d.ts +0 -27
  53. package/dist/functions/bundleCode/schemas.js +0 -22
  54. package/dist/functions/findFirstAuthentication/index.d.ts +0 -12
  55. package/dist/functions/findFirstAuthentication/index.js +0 -21
  56. package/dist/functions/findFirstAuthentication/info.d.ts +0 -30
  57. package/dist/functions/findFirstAuthentication/info.js +0 -11
  58. package/dist/functions/findFirstAuthentication/schemas.d.ts +0 -42
  59. package/dist/functions/findFirstAuthentication/schemas.js +0 -25
  60. package/dist/functions/findUniqueAuthentication/index.d.ts +0 -13
  61. package/dist/functions/findUniqueAuthentication/index.js +0 -28
  62. package/dist/functions/findUniqueAuthentication/info.d.ts +0 -30
  63. package/dist/functions/findUniqueAuthentication/info.js +0 -11
  64. package/dist/functions/findUniqueAuthentication/schemas.d.ts +0 -42
  65. package/dist/functions/findUniqueAuthentication/schemas.js +0 -25
  66. package/dist/functions/generateTypes/index.d.ts +0 -11
  67. package/dist/functions/generateTypes/index.js +0 -305
  68. package/dist/functions/generateTypes/info.d.ts +0 -21
  69. package/dist/functions/generateTypes/info.js +0 -11
  70. package/dist/functions/generateTypes/schemas.d.ts +0 -30
  71. package/dist/functions/generateTypes/schemas.js +0 -14
  72. package/dist/functions/getAction/index.d.ts +0 -12
  73. package/dist/functions/getAction/index.js +0 -26
  74. package/dist/functions/getAction/info.d.ts +0 -18
  75. package/dist/functions/getAction/info.js +0 -11
  76. package/dist/functions/getAction/schemas.d.ts +0 -30
  77. package/dist/functions/getAction/schemas.js +0 -13
  78. package/dist/functions/getApp/index.d.ts +0 -12
  79. package/dist/functions/getApp/index.js +0 -37
  80. package/dist/functions/getApp/info.d.ts +0 -12
  81. package/dist/functions/getApp/info.js +0 -11
  82. package/dist/functions/getApp/schemas.d.ts +0 -24
  83. package/dist/functions/getApp/schemas.js +0 -11
  84. package/dist/functions/getAuthentication/index.d.ts +0 -13
  85. package/dist/functions/getAuthentication/index.js +0 -38
  86. package/dist/functions/getAuthentication/info.d.ts +0 -12
  87. package/dist/functions/getAuthentication/info.js +0 -11
  88. package/dist/functions/getAuthentication/schemas.d.ts +0 -26
  89. package/dist/functions/getAuthentication/schemas.js +0 -16
  90. package/dist/functions/listActions/index.d.ts +0 -12
  91. package/dist/functions/listActions/index.js +0 -128
  92. package/dist/functions/listActions/info.d.ts +0 -15
  93. package/dist/functions/listActions/info.js +0 -11
  94. package/dist/functions/listActions/schemas.d.ts +0 -27
  95. package/dist/functions/listActions/schemas.js +0 -14
  96. package/dist/functions/listApps/index.d.ts +0 -12
  97. package/dist/functions/listApps/index.js +0 -50
  98. package/dist/functions/listApps/info.d.ts +0 -18
  99. package/dist/functions/listApps/info.js +0 -11
  100. package/dist/functions/listApps/schemas.d.ts +0 -30
  101. package/dist/functions/listApps/schemas.js +0 -15
  102. package/dist/functions/listAuthentications/index.d.ts +0 -12
  103. package/dist/functions/listAuthentications/index.js +0 -131
  104. package/dist/functions/listAuthentications/info.d.ts +0 -30
  105. package/dist/functions/listAuthentications/info.js +0 -11
  106. package/dist/functions/listAuthentications/schemas.d.ts +0 -44
  107. package/dist/functions/listAuthentications/schemas.js +0 -25
  108. package/dist/functions/listFields/index.d.ts +0 -12
  109. package/dist/functions/listFields/index.js +0 -65
  110. package/dist/functions/listFields/info.d.ts +0 -24
  111. package/dist/functions/listFields/info.js +0 -11
  112. package/dist/functions/listFields/schemas.d.ts +0 -36
  113. package/dist/functions/listFields/schemas.js +0 -17
  114. package/dist/functions/runAction/index.d.ts +0 -12
  115. package/dist/functions/runAction/index.js +0 -86
  116. package/dist/functions/runAction/info.d.ts +0 -24
  117. package/dist/functions/runAction/info.js +0 -11
  118. package/dist/functions/runAction/schemas.d.ts +0 -38
  119. package/dist/functions/runAction/schemas.js +0 -15
  120. package/dist/index.js +0 -57
  121. package/dist/plugins/apps/index.d.ts +0 -8
  122. package/dist/plugins/apps/index.js +0 -77
  123. package/dist/plugins/apps/info.d.ts +0 -6
  124. package/dist/plugins/apps/info.js +0 -13
  125. package/dist/plugins/apps/types.d.ts +0 -21
  126. package/dist/plugins/apps/types.js +0 -2
  127. package/dist/resolvers/actionKey.d.ts +0 -8
  128. package/dist/resolvers/actionKey.js +0 -20
  129. package/dist/resolvers/actionType.d.ts +0 -8
  130. package/dist/resolvers/actionType.js +0 -21
  131. package/dist/resolvers/appKey.d.ts +0 -6
  132. package/dist/resolvers/appKey.js +0 -8
  133. package/dist/resolvers/authenticationId.d.ts +0 -8
  134. package/dist/resolvers/authenticationId.js +0 -29
  135. package/dist/resolvers/index.d.ts +0 -39
  136. package/dist/resolvers/index.js +0 -105
  137. package/dist/resolvers/inputs.d.ts +0 -7
  138. package/dist/resolvers/inputs.js +0 -15
  139. package/dist/schema-utils.d.ts +0 -44
  140. package/dist/schema-utils.js +0 -76
  141. package/dist/schemas/Action.d.ts +0 -21
  142. package/dist/schemas/Action.js +0 -31
  143. package/dist/schemas/App.d.ts +0 -19
  144. package/dist/schemas/App.js +0 -32
  145. package/dist/schemas/Auth.d.ts +0 -27
  146. package/dist/schemas/Auth.js +0 -42
  147. package/dist/schemas/Field.d.ts +0 -15
  148. package/dist/schemas/Field.js +0 -25
  149. package/dist/sdk.d.ts +0 -6
  150. package/dist/sdk.js +0 -90
  151. package/dist/types/domain.d.ts +0 -25
  152. package/dist/types/domain.js +0 -21
  153. package/dist/types/events.d.ts +0 -37
  154. package/dist/types/events.js +0 -8
  155. package/dist/types/properties.d.ts +0 -21
  156. package/dist/types/properties.js +0 -52
  157. package/dist/types/sdk.d.ts +0 -24
  158. package/dist/types/sdk.js +0 -2
package/dist/index.d.ts CHANGED
@@ -1,20 +1,840 @@
1
- export * from "./types/domain";
2
- export * from "./types/properties";
3
- export * from "./plugins/apps";
4
- export { isPositional } from "./schema-utils";
5
- export * from "./auth";
6
- export * from "./resolvers";
7
- export { listAuthentications } from "./functions/listAuthentications";
8
- export { getAuthentication } from "./functions/getAuthentication";
9
- export { findFirstAuthentication } from "./functions/findFirstAuthentication";
10
- export { findUniqueAuthentication } from "./functions/findUniqueAuthentication";
11
- export { listApps } from "./functions/listApps";
12
- export { getApp } from "./functions/getApp";
13
- export { listActions } from "./functions/listActions";
14
- export { getAction } from "./functions/getAction";
15
- export { runAction } from "./functions/runAction";
16
- export { listFields } from "./functions/listFields";
17
- export { generateTypes } from "./functions/generateTypes";
18
- export { bundleCode } from "./functions/bundleCode";
19
- export { createZapierSdk, ZapierSdkOptions } from "./sdk";
20
- export type { ZapierSdk } from "./types/sdk";
1
+ import { z } from 'zod';
2
+
3
+ interface Integration {
4
+ key: string;
5
+ name: string;
6
+ description: string;
7
+ version: string;
8
+ category?: string;
9
+ actions: Action[];
10
+ triggers: Trigger[];
11
+ current_implementation_id?: string;
12
+ }
13
+ interface Action {
14
+ key: string;
15
+ name: string;
16
+ description: string;
17
+ appKey: string;
18
+ type: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
19
+ inputFields: Field[];
20
+ outputFields: Field[];
21
+ }
22
+ interface Trigger {
23
+ key: string;
24
+ name: string;
25
+ description: string;
26
+ appKey: string;
27
+ type: "instant" | "polling" | "webhook";
28
+ outputFields: Field[];
29
+ }
30
+ interface Field {
31
+ key: string;
32
+ label: string;
33
+ type: "string" | "number" | "boolean" | "datetime" | "file" | "object" | "array";
34
+ required: boolean;
35
+ description?: string;
36
+ choices?: Choice[];
37
+ }
38
+ interface Choice {
39
+ value: string | number;
40
+ label: string;
41
+ }
42
+ interface ActionExecutionResult {
43
+ success: boolean;
44
+ data?: any;
45
+ error?: string;
46
+ metadata?: {
47
+ executionTime?: number;
48
+ requestId?: string;
49
+ };
50
+ }
51
+ interface ActionField {
52
+ key: string;
53
+ label?: string;
54
+ required: boolean;
55
+ type?: string;
56
+ helpText?: string;
57
+ helpTextHtml?: string;
58
+ choices?: ActionFieldChoice[];
59
+ default?: string;
60
+ placeholder?: string;
61
+ computed?: boolean;
62
+ customField?: boolean;
63
+ dependsOn?: string[];
64
+ format?: string;
65
+ inputFormat?: string[];
66
+ }
67
+ interface ActionFieldChoice {
68
+ value: string | number;
69
+ label: string;
70
+ }
71
+ interface NeedsRequest {
72
+ selected_api: string;
73
+ action: string;
74
+ type_of: string;
75
+ authentication_id?: number;
76
+ params?: Record<string, any>;
77
+ }
78
+ interface NeedsResponse {
79
+ success: boolean;
80
+ needs?: ActionField[];
81
+ errors?: string[];
82
+ }
83
+ interface Authentication {
84
+ id: number;
85
+ date: string;
86
+ lastchanged?: string;
87
+ account_id: number;
88
+ customuser_id?: number;
89
+ selected_api: string;
90
+ destination_selected_api?: string | null;
91
+ is_invite_only: boolean;
92
+ is_private: boolean;
93
+ shared_with_all: boolean;
94
+ is_stale?: string;
95
+ is_shared?: string;
96
+ marked_stale_at?: string | null;
97
+ label?: string | null;
98
+ identifier?: string | null;
99
+ title?: string | null;
100
+ url?: string;
101
+ groups?: string;
102
+ members?: string;
103
+ permissions?: Record<string, boolean>;
104
+ }
105
+ interface AuthenticationsResponse {
106
+ count: number;
107
+ next?: string | null;
108
+ previous?: string | null;
109
+ results: Authentication[];
110
+ }
111
+
112
+ /**
113
+ * SDK Event System
114
+ *
115
+ * This module provides common event type definitions for the SDK's
116
+ * event system, including authentication, API, and loading events.
117
+ */
118
+ interface SdkEvent {
119
+ type: string;
120
+ payload?: Record<string, any>;
121
+ timestamp?: number;
122
+ }
123
+ interface AuthEvent extends SdkEvent {
124
+ type: "auth_refreshing" | "auth_success" | "auth_error" | "auth_logout";
125
+ payload?: {
126
+ message?: string;
127
+ error?: string;
128
+ operation?: string;
129
+ };
130
+ }
131
+ interface ApiEvent extends SdkEvent {
132
+ type: "api_request" | "api_response" | "api_error";
133
+ payload?: {
134
+ url?: string;
135
+ method?: string;
136
+ status?: number;
137
+ duration?: number;
138
+ error?: string;
139
+ };
140
+ }
141
+ interface LoadingEvent extends SdkEvent {
142
+ type: "loading_start" | "loading_end";
143
+ payload?: {
144
+ operation?: string;
145
+ resource?: string;
146
+ };
147
+ }
148
+ type EventCallback = (event: SdkEvent) => void;
149
+
150
+ interface ActionExecutionOptions {
151
+ inputs?: Record<string, any>;
152
+ authenticationId?: number;
153
+ }
154
+ interface AuthObject {
155
+ id: number;
156
+ }
157
+ interface BaseSdkOptions {
158
+ token?: string;
159
+ getToken?: () => Promise<string | undefined>;
160
+ onEvent?: EventCallback;
161
+ fetch?: typeof fetch;
162
+ baseUrl?: string;
163
+ debug?: boolean;
164
+ }
165
+ interface FunctionOptions {
166
+ /** Base URL for Zapier API */
167
+ baseUrl?: string;
168
+ /** Authentication token */
169
+ token?: string;
170
+ /** Function to dynamically resolve authentication token */
171
+ getToken?: () => Promise<string | undefined>;
172
+ /** Optional pre-instantiated API client */
173
+ api?: any;
174
+ /** Enable debug logging */
175
+ debug?: boolean;
176
+ /** Custom fetch implementation */
177
+ fetch?: typeof globalThis.fetch;
178
+ }
179
+ declare class ZapierSdkError extends Error {
180
+ code?: string | undefined;
181
+ constructor(message: string, code?: string | undefined);
182
+ }
183
+ declare class AppNotFoundError extends ZapierSdkError {
184
+ appKey: string;
185
+ constructor(appKey: string);
186
+ }
187
+
188
+ declare const AppKeyPropertySchema: z.ZodString;
189
+ declare const ActionTypePropertySchema: z.ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>;
190
+ declare const ActionKeyPropertySchema: z.ZodString;
191
+ declare const AuthenticationIdPropertySchema: z.ZodNumber;
192
+ declare const InputsPropertySchema: z.ZodRecord<z.ZodString, z.ZodAny>;
193
+ declare const LimitPropertySchema: z.ZodDefault<z.ZodNumber>;
194
+ declare const OffsetPropertySchema: z.ZodDefault<z.ZodNumber>;
195
+ declare const OutputPropertySchema: z.ZodString;
196
+ declare const DebugPropertySchema: z.ZodDefault<z.ZodBoolean>;
197
+ declare const ParamsPropertySchema: z.ZodRecord<z.ZodString, z.ZodAny>;
198
+ type AppKeyProperty = z.infer<typeof AppKeyPropertySchema>;
199
+ type ActionTypeProperty = z.infer<typeof ActionTypePropertySchema>;
200
+ type ActionKeyProperty = z.infer<typeof ActionKeyPropertySchema>;
201
+ type AuthenticationIdProperty = z.infer<typeof AuthenticationIdPropertySchema>;
202
+ type InputsProperty = z.infer<typeof InputsPropertySchema>;
203
+ type LimitProperty = z.infer<typeof LimitPropertySchema>;
204
+ type OffsetProperty = z.infer<typeof OffsetPropertySchema>;
205
+ type OutputProperty = z.infer<typeof OutputPropertySchema>;
206
+ type DebugProperty = z.infer<typeof DebugPropertySchema>;
207
+ type ParamsProperty = z.infer<typeof ParamsPropertySchema>;
208
+
209
+ interface AppFactoryOptions {
210
+ authenticationId: number;
211
+ }
212
+ interface ActionTypeProxy {
213
+ [action: string]: (options?: ActionExecutionOptions) => Promise<ActionExecutionResult>;
214
+ }
215
+ interface AppProxy {
216
+ [type: string]: ActionTypeProxy;
217
+ }
218
+ interface AppFactory {
219
+ (options: AppFactoryOptions): AppProxy;
220
+ }
221
+ type AppProxyWithFactory = AppFactory & AppProxy;
222
+ interface ActionProxy {
223
+ [app: string]: AppProxyWithFactory;
224
+ }
225
+ interface AppsPluginSdkExtension {
226
+ apps: ActionProxy;
227
+ }
228
+
229
+ declare const ListActionsSchema: z.ZodObject<{
230
+ appKey: z.ZodOptional<z.ZodString>;
231
+ type: z.ZodOptional<z.ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>>;
232
+ }, "strip", z.ZodTypeAny, {
233
+ type?: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter" | undefined;
234
+ appKey?: string | undefined;
235
+ }, {
236
+ type?: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter" | undefined;
237
+ appKey?: string | undefined;
238
+ }>;
239
+ type ListActionsOptions = z.infer<typeof ListActionsSchema> & FunctionOptions;
240
+ interface ListActionsSdkFunction {
241
+ listActions: (options?: Partial<ListActionsOptions>) => Promise<Action[]>;
242
+ }
243
+
244
+ declare const GetActionSchema: z.ZodObject<{
245
+ appKey: z.ZodString;
246
+ actionType: z.ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>;
247
+ actionKey: z.ZodString;
248
+ }, "strip", z.ZodTypeAny, {
249
+ appKey: string;
250
+ actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
251
+ actionKey: string;
252
+ }, {
253
+ appKey: string;
254
+ actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
255
+ actionKey: string;
256
+ }>;
257
+ type GetActionOptions = z.infer<typeof GetActionSchema> & FunctionOptions;
258
+ interface GetActionSdkFunction {
259
+ getAction: (options: GetActionOptions) => Promise<Action>;
260
+ }
261
+
262
+ declare const GetAppSchema: z.ZodObject<{
263
+ appKey: z.ZodString;
264
+ }, "strip", z.ZodTypeAny, {
265
+ appKey: string;
266
+ }, {
267
+ appKey: string;
268
+ }>;
269
+ type GetAppOptions = z.infer<typeof GetAppSchema> & FunctionOptions;
270
+ interface GetAppSdkFunction {
271
+ getApp: (options: GetAppOptions) => Promise<Integration>;
272
+ }
273
+
274
+ declare const RunActionSchema: z.ZodObject<{
275
+ appKey: z.ZodString;
276
+ actionType: z.ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>;
277
+ actionKey: z.ZodString;
278
+ inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
279
+ authenticationId: z.ZodOptional<z.ZodNumber>;
280
+ }, "strip", z.ZodTypeAny, {
281
+ appKey: string;
282
+ actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
283
+ actionKey: string;
284
+ inputs?: Record<string, any> | undefined;
285
+ authenticationId?: number | undefined;
286
+ }, {
287
+ appKey: string;
288
+ actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
289
+ actionKey: string;
290
+ inputs?: Record<string, any> | undefined;
291
+ authenticationId?: number | undefined;
292
+ }>;
293
+ type RunActionOptions = z.infer<typeof RunActionSchema> & FunctionOptions;
294
+ interface RunActionSdkFunction {
295
+ runAction: (options: RunActionOptions) => Promise<ActionExecutionResult>;
296
+ }
297
+
298
+ declare const ListFieldsSchema: z.ZodObject<{
299
+ appKey: z.ZodString;
300
+ actionType: z.ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>;
301
+ actionKey: z.ZodString;
302
+ authenticationId: z.ZodOptional<z.ZodNumber>;
303
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
304
+ }, "strip", z.ZodTypeAny, {
305
+ appKey: string;
306
+ actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
307
+ actionKey: string;
308
+ params?: Record<string, any> | undefined;
309
+ authenticationId?: number | undefined;
310
+ }, {
311
+ appKey: string;
312
+ actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
313
+ actionKey: string;
314
+ params?: Record<string, any> | undefined;
315
+ authenticationId?: number | undefined;
316
+ }>;
317
+ type ListFieldsOptions = z.infer<typeof ListFieldsSchema> & FunctionOptions;
318
+ interface ListFieldsSdkFunction {
319
+ listFields: (options: ListFieldsOptions) => Promise<ActionField[]>;
320
+ }
321
+
322
+ declare const ListAuthenticationsSchema: z.ZodObject<{
323
+ appKey: z.ZodOptional<z.ZodString>;
324
+ search: z.ZodOptional<z.ZodString>;
325
+ title: z.ZodOptional<z.ZodString>;
326
+ account_id: z.ZodOptional<z.ZodString>;
327
+ owner: z.ZodOptional<z.ZodString>;
328
+ limit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
329
+ offset: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
330
+ }, "strip", z.ZodTypeAny, {
331
+ search?: string | undefined;
332
+ appKey?: string | undefined;
333
+ title?: string | undefined;
334
+ account_id?: string | undefined;
335
+ owner?: string | undefined;
336
+ limit?: number | undefined;
337
+ offset?: number | undefined;
338
+ }, {
339
+ search?: string | undefined;
340
+ appKey?: string | undefined;
341
+ title?: string | undefined;
342
+ account_id?: string | undefined;
343
+ owner?: string | undefined;
344
+ limit?: number | undefined;
345
+ offset?: number | undefined;
346
+ }>;
347
+ type ListAuthenticationsOptions = z.infer<typeof ListAuthenticationsSchema> & FunctionOptions;
348
+ interface ListAuthenticationsSdkFunction {
349
+ listAuthentications: (options?: Partial<ListAuthenticationsOptions>) => Promise<Authentication[]>;
350
+ }
351
+
352
+ declare const GetAuthenticationSchema: z.ZodObject<{
353
+ authenticationId: z.ZodNumber;
354
+ }, "strip", z.ZodTypeAny, {
355
+ authenticationId: number;
356
+ }, {
357
+ authenticationId: number;
358
+ }>;
359
+ type GetAuthenticationOptions = z.infer<typeof GetAuthenticationSchema> & FunctionOptions;
360
+ interface GetAuthenticationSdkFunction {
361
+ getAuthentication: (options: GetAuthenticationOptions) => Promise<Authentication>;
362
+ }
363
+
364
+ declare const FindFirstAuthenticationSchema: z.ZodObject<{
365
+ appKey: z.ZodOptional<z.ZodString>;
366
+ search: z.ZodOptional<z.ZodString>;
367
+ title: z.ZodOptional<z.ZodString>;
368
+ account_id: z.ZodOptional<z.ZodString>;
369
+ owner: z.ZodOptional<z.ZodString>;
370
+ limit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
371
+ offset: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
372
+ }, "strip", z.ZodTypeAny, {
373
+ search?: string | undefined;
374
+ appKey?: string | undefined;
375
+ title?: string | undefined;
376
+ account_id?: string | undefined;
377
+ owner?: string | undefined;
378
+ limit?: number | undefined;
379
+ offset?: number | undefined;
380
+ }, {
381
+ search?: string | undefined;
382
+ appKey?: string | undefined;
383
+ title?: string | undefined;
384
+ account_id?: string | undefined;
385
+ owner?: string | undefined;
386
+ limit?: number | undefined;
387
+ offset?: number | undefined;
388
+ }>;
389
+ type FindFirstAuthenticationOptions = z.infer<typeof FindFirstAuthenticationSchema> & FunctionOptions;
390
+ interface FindFirstAuthenticationSdkFunction {
391
+ findFirstAuthentication: (options?: Partial<FindFirstAuthenticationOptions>) => Promise<Authentication | null>;
392
+ }
393
+
394
+ declare const FindUniqueAuthenticationSchema: z.ZodObject<{
395
+ appKey: z.ZodOptional<z.ZodString>;
396
+ search: z.ZodOptional<z.ZodString>;
397
+ title: z.ZodOptional<z.ZodString>;
398
+ account_id: z.ZodOptional<z.ZodString>;
399
+ owner: z.ZodOptional<z.ZodString>;
400
+ limit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
401
+ offset: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
402
+ }, "strip", z.ZodTypeAny, {
403
+ search?: string | undefined;
404
+ appKey?: string | undefined;
405
+ title?: string | undefined;
406
+ account_id?: string | undefined;
407
+ owner?: string | undefined;
408
+ limit?: number | undefined;
409
+ offset?: number | undefined;
410
+ }, {
411
+ search?: string | undefined;
412
+ appKey?: string | undefined;
413
+ title?: string | undefined;
414
+ account_id?: string | undefined;
415
+ owner?: string | undefined;
416
+ limit?: number | undefined;
417
+ offset?: number | undefined;
418
+ }>;
419
+ type FindUniqueAuthenticationOptions = z.infer<typeof FindUniqueAuthenticationSchema> & FunctionOptions;
420
+ interface FindUniqueAuthenticationSdkFunction {
421
+ findUniqueAuthentication: (options?: Partial<FindUniqueAuthenticationOptions>) => Promise<Authentication>;
422
+ }
423
+
424
+ declare const GenerateTypesSchema: z.ZodObject<{
425
+ appKey: z.ZodString;
426
+ authenticationId: z.ZodOptional<z.ZodNumber>;
427
+ output: z.ZodOptional<z.ZodString>;
428
+ debug: z.ZodDefault<z.ZodBoolean>;
429
+ }, "strip", z.ZodTypeAny, {
430
+ appKey: string;
431
+ debug: boolean;
432
+ authenticationId?: number | undefined;
433
+ output?: string | undefined;
434
+ }, {
435
+ appKey: string;
436
+ authenticationId?: number | undefined;
437
+ output?: string | undefined;
438
+ debug?: boolean | undefined;
439
+ }>;
440
+ type GenerateTypesOptions = z.infer<typeof GenerateTypesSchema> & FunctionOptions;
441
+ interface GenerateTypesSdkFunction {
442
+ generateTypes: (options: GenerateTypesOptions) => Promise<string>;
443
+ }
444
+
445
+ declare const ListAppsSchema: z.ZodObject<{
446
+ category: z.ZodOptional<z.ZodString>;
447
+ limit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
448
+ offset: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
449
+ }, "strip", z.ZodTypeAny, {
450
+ limit?: number | undefined;
451
+ offset?: number | undefined;
452
+ category?: string | undefined;
453
+ }, {
454
+ limit?: number | undefined;
455
+ offset?: number | undefined;
456
+ category?: string | undefined;
457
+ }>;
458
+ type ListAppsOptions = z.infer<typeof ListAppsSchema> & FunctionOptions;
459
+ interface ListAppsSdkFunction {
460
+ listApps: (options?: Partial<ListAppsOptions>) => Promise<Integration[]>;
461
+ }
462
+
463
+ declare const BundleCodeSchema: z.ZodObject<{
464
+ input: z.ZodString;
465
+ output: z.ZodOptional<z.ZodString>;
466
+ string: z.ZodDefault<z.ZodBoolean>;
467
+ minify: z.ZodDefault<z.ZodBoolean>;
468
+ target: z.ZodDefault<z.ZodString>;
469
+ cjs: z.ZodDefault<z.ZodBoolean>;
470
+ }, "strip", z.ZodTypeAny, {
471
+ string: boolean;
472
+ input: string;
473
+ minify: boolean;
474
+ target: string;
475
+ cjs: boolean;
476
+ output?: string | undefined;
477
+ }, {
478
+ input: string;
479
+ string?: boolean | undefined;
480
+ output?: string | undefined;
481
+ minify?: boolean | undefined;
482
+ target?: string | undefined;
483
+ cjs?: boolean | undefined;
484
+ }>;
485
+ type BundleCodeOptions = z.infer<typeof BundleCodeSchema>;
486
+ interface BundleCodeSdkFunction {
487
+ bundleCode: (options: BundleCodeOptions) => Promise<string>;
488
+ }
489
+
490
+ declare const RelayFetchSchema: z.ZodObject<{
491
+ url: z.ZodString;
492
+ method: z.ZodOptional<z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]>>;
493
+ body: z.ZodOptional<z.ZodString>;
494
+ authenticationId: z.ZodOptional<z.ZodNumber>;
495
+ callbackUrl: z.ZodOptional<z.ZodString>;
496
+ authenticationTemplate: z.ZodOptional<z.ZodString>;
497
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
498
+ }, "strip", z.ZodTypeAny, {
499
+ url: string;
500
+ authenticationId?: number | undefined;
501
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | undefined;
502
+ body?: string | undefined;
503
+ callbackUrl?: string | undefined;
504
+ authenticationTemplate?: string | undefined;
505
+ headers?: Record<string, string> | undefined;
506
+ }, {
507
+ url: string;
508
+ authenticationId?: number | undefined;
509
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | undefined;
510
+ body?: string | undefined;
511
+ callbackUrl?: string | undefined;
512
+ authenticationTemplate?: string | undefined;
513
+ headers?: Record<string, string> | undefined;
514
+ }>;
515
+ type RelayFetchOptions$1 = z.infer<typeof RelayFetchSchema> & FunctionOptions & {
516
+ /** Base URL for Relay service */
517
+ relayBaseUrl?: string;
518
+ };
519
+ interface RelayFetchSdkFunction {
520
+ fetch: (options: RelayFetchOptions$1) => Promise<Response>;
521
+ }
522
+
523
+ interface ZapierSdkFunctions extends ListActionsSdkFunction, GetActionSdkFunction, GetAppSdkFunction, RunActionSdkFunction, ListFieldsSdkFunction, ListAuthenticationsSdkFunction, GetAuthenticationSdkFunction, FindFirstAuthenticationSdkFunction, FindUniqueAuthenticationSdkFunction, GenerateTypesSdkFunction, ListAppsSdkFunction, BundleCodeSdkFunction, RelayFetchSdkFunction {
524
+ }
525
+ interface ZapierSdkPlugins extends AppsPluginSdkExtension {
526
+ }
527
+ interface BaseZapierSdk extends ZapierSdkFunctions {
528
+ __registry: Array<{
529
+ name: string;
530
+ inputSchema: any;
531
+ implementation: Function;
532
+ }>;
533
+ }
534
+ interface ZapierSdk extends ZapierSdkFunctions, ZapierSdkPlugins {
535
+ __registry: Array<{
536
+ name: string;
537
+ inputSchema: any;
538
+ implementation: Function;
539
+ }>;
540
+ }
541
+
542
+ interface AppsPluginOptions {
543
+ sdk: ZapierSdk;
544
+ }
545
+ declare function createAppsPlugin(options: AppsPluginOptions): ActionProxy;
546
+
547
+ declare function isPositional(schema: z.ZodType): boolean;
548
+
549
+ /**
550
+ * SDK Authentication Utilities
551
+ *
552
+ * This module provides SDK-level authentication utilities focused
553
+ * solely on token acquisition. CLI-specific functionality like login/logout
554
+ * is handled by the @zapier/zapier-sdk-cli-login package.
555
+ */
556
+
557
+ interface AuthOptions {
558
+ onEvent?: EventCallback;
559
+ fetch?: typeof globalThis.fetch;
560
+ }
561
+ /**
562
+ * Gets the ZAPIER_TOKEN from environment variables.
563
+ * Returns undefined if not set.
564
+ */
565
+ declare function getTokenFromEnv(): string | undefined;
566
+ /**
567
+ * Attempts to get a token by optionally importing from CLI login package.
568
+ * This provides a graceful fallback when the CLI login package is not available.
569
+ *
570
+ * Returns undefined if no valid token is found or CLI package is not available.
571
+ */
572
+ declare function getTokenFromCliLogin(options?: AuthOptions): Promise<string | undefined>;
573
+ /**
574
+ * Attempts to get a token with the following precedence:
575
+ * 1. ZAPIER_TOKEN environment variable
576
+ * 2. CLI login package (if available) with auto-refresh
577
+ *
578
+ * Returns undefined if no valid token is found.
579
+ */
580
+ declare function getTokenFromEnvOrConfig(options?: AuthOptions): Promise<string | undefined>;
581
+
582
+ interface InputsResolver {
583
+ type: "fields";
584
+ depends: readonly string[];
585
+ fetch: (sdk: ZapierSdk, resolvedParams: Record<string, any>) => Promise<any[]>;
586
+ }
587
+ declare const inputsResolver: InputsResolver;
588
+
589
+ interface AuthenticationIdResolver {
590
+ type: "dynamic";
591
+ depends: readonly string[];
592
+ fetch: (sdk: ZapierSdk, resolvedParams: Record<string, any>) => Promise<any[]>;
593
+ prompt: (items: any[], params: Record<string, any>) => any;
594
+ }
595
+ declare const authenticationIdResolver: AuthenticationIdResolver;
596
+
597
+ interface ActionKeyResolver {
598
+ type: "dynamic";
599
+ depends: readonly string[];
600
+ fetch: (sdk: ZapierSdk, resolvedParams: Record<string, any>) => Promise<any[]>;
601
+ prompt: (items: any[], params: Record<string, any>) => any;
602
+ }
603
+ declare const actionKeyResolver: ActionKeyResolver;
604
+
605
+ interface ActionTypeResolver {
606
+ type: "dynamic";
607
+ depends: readonly string[];
608
+ fetch: (sdk: ZapierSdk, resolvedParams: Record<string, any>) => Promise<any[]>;
609
+ prompt: (items: any[], params: Record<string, any>) => any;
610
+ }
611
+ declare const actionTypeResolver: ActionTypeResolver;
612
+
613
+ interface AppKeyResolver {
614
+ type: "static";
615
+ inputType?: "text" | "password" | "email";
616
+ placeholder?: string;
617
+ }
618
+ declare const appKeyResolver: AppKeyResolver;
619
+
620
+ declare const resolverRegistry: {
621
+ readonly appKey: AppKeyResolver;
622
+ readonly actionType: ActionTypeResolver;
623
+ readonly actionKey: ActionKeyResolver;
624
+ readonly authenticationId: AuthenticationIdResolver;
625
+ readonly inputs: InputsResolver;
626
+ };
627
+ type ResolverName = keyof typeof resolverRegistry;
628
+ type ResolverType = (typeof resolverRegistry)[ResolverName];
629
+ /**
630
+ * Get a resolver by name
631
+ */
632
+ declare function getResolver(name: string): ResolverType | undefined;
633
+ /**
634
+ * Get all resolvers for a list of missing parameters
635
+ */
636
+ declare function getResolversForMissingParams(missingParams: string[]): Record<string, ResolverType>;
637
+ /**
638
+ * Check if a parameter has a resolver
639
+ */
640
+ declare function hasResolver(paramName: string): boolean;
641
+ /**
642
+ * Get all parameter names that have resolvers
643
+ */
644
+ declare function getResolvableParams(): string[];
645
+ /**
646
+ * Resolve dependency chain for a parameter
647
+ * Returns parameters in the order they need to be resolved
648
+ */
649
+ declare function getResolutionOrder(paramName: string, resolved?: Set<string>): string[];
650
+ /**
651
+ * Get resolution order for multiple parameters
652
+ */
653
+ declare function getResolutionOrderForParams(paramNames: string[]): string[];
654
+
655
+ /**
656
+ * List available authentications with optional filtering
657
+ *
658
+ * This function can be used standalone without instantiating a full SDK,
659
+ * which enables better tree-shaking in applications that only need this functionality.
660
+ *
661
+ * @param options - Filtering, pagination, and API configuration options
662
+ * @returns Promise<Authentication[]> with pagination metadata
663
+ */
664
+ declare function listAuthentications(options?: Partial<ListAuthenticationsOptions>): Promise<Authentication[]>;
665
+
666
+ /**
667
+ * Get a specific authentication by ID
668
+ *
669
+ * This function can be used standalone without instantiating a full SDK,
670
+ * which enables better tree-shaking in applications that only need this functionality.
671
+ *
672
+ * @param options - Authentication ID and API configuration options
673
+ * @returns Promise<Authentication> - The authentication details
674
+ * @throws Error if authentication not found or access denied
675
+ */
676
+ declare function getAuthentication(options: GetAuthenticationOptions): Promise<Authentication>;
677
+
678
+ /**
679
+ * Find the first authentication matching the given criteria
680
+ *
681
+ * This function can be used standalone without instantiating a full SDK,
682
+ * which enables better tree-shaking in applications that only need this functionality.
683
+ *
684
+ * @param options - Filtering and API configuration options
685
+ * @returns Promise<Authentication | null> - First matching authentication or null if not found
686
+ */
687
+ declare function findFirstAuthentication(options?: Partial<FindFirstAuthenticationOptions>): Promise<Authentication | null>;
688
+
689
+ /**
690
+ * Find a unique authentication matching the given criteria
691
+ *
692
+ * This function can be used standalone without instantiating a full SDK,
693
+ * which enables better tree-shaking in applications that only need this functionality.
694
+ *
695
+ * @param options - Filtering and API configuration options
696
+ * @returns Promise<Authentication> - The unique matching authentication
697
+ * @throws Error if no authentication found or multiple authentications found
698
+ */
699
+ declare function findUniqueAuthentication(options?: Partial<FindUniqueAuthenticationOptions>): Promise<Authentication>;
700
+
701
+ /**
702
+ * List available apps with optional filtering
703
+ *
704
+ * This function can be used standalone without instantiating a full SDK,
705
+ * which enables better tree-shaking in applications that only need this functionality.
706
+ *
707
+ * @param options - Filtering, pagination, and API configuration options
708
+ * @returns Promise<Integration[]> with pagination metadata
709
+ */
710
+ declare function listApps(options?: ListAppsOptions): Promise<Integration[]>;
711
+
712
+ /**
713
+ * Get a specific app by key
714
+ *
715
+ * This function can be used standalone without instantiating a full SDK,
716
+ * which enables better tree-shaking in applications that only need this functionality.
717
+ *
718
+ * @param options - App key and API configuration options
719
+ * @returns Promise<Integration>
720
+ */
721
+ declare function getApp(options: GetAppOptions): Promise<Integration>;
722
+
723
+ /**
724
+ * List available actions with optional filtering
725
+ *
726
+ * This function can be used standalone without instantiating a full SDK,
727
+ * which enables better tree-shaking in applications that only need this functionality.
728
+ *
729
+ * @param options - Filtering and API configuration options
730
+ * @returns Promise<Action[]> with pagination metadata
731
+ */
732
+ declare function listActions(options?: Partial<ListActionsOptions>): Promise<Action[]>;
733
+
734
+ /**
735
+ * Get a specific action by app, action key, and type
736
+ *
737
+ * This function can be used standalone without instantiating a full SDK,
738
+ * which enables better tree-shaking in applications that only need this functionality.
739
+ *
740
+ * @param options - App key, action key, type, and API configuration options
741
+ * @returns Promise<Action>
742
+ */
743
+ declare function getAction(options: GetActionOptions): Promise<Action>;
744
+
745
+ /**
746
+ * Execute an action
747
+ *
748
+ * This function can be used standalone without instantiating a full SDK,
749
+ * which enables better tree-shaking in applications that only need this functionality.
750
+ *
751
+ * @param options - Action execution parameters and API configuration options
752
+ * @returns Promise<ActionExecutionResult>
753
+ */
754
+ declare function runAction(options: RunActionOptions): Promise<ActionExecutionResult>;
755
+
756
+ /**
757
+ * List available fields for an action
758
+ *
759
+ * This function can be used standalone without instantiating a full SDK,
760
+ * which enables better tree-shaking in applications that only need this functionality.
761
+ *
762
+ * @param options - Action details, authentication ID, params, and API configuration options
763
+ * @returns Promise<ActionField[]>
764
+ */
765
+ declare function listFields(options: ListFieldsOptions): Promise<ActionField[]>;
766
+
767
+ /**
768
+ * Generate TypeScript types for a specific app
769
+ *
770
+ * This function can be used standalone without instantiating a full SDK,
771
+ * which enables better tree-shaking in applications that only need this functionality.
772
+ *
773
+ * @param options - App key, authentication ID, output path, and API configuration options
774
+ * @returns Promise<string> - Generated TypeScript code
775
+ */
776
+ declare function generateTypes(options: GenerateTypesOptions): Promise<string>;
777
+
778
+ /**
779
+ * Bundle TypeScript code into executable JavaScript
780
+ *
781
+ * This function can be used standalone without instantiating a full SDK,
782
+ * which enables better tree-shaking in applications that only need this functionality.
783
+ *
784
+ * @param options - Bundling configuration options
785
+ * @returns Promise<string> - Bundled JavaScript code
786
+ */
787
+ declare function bundleCode(options: BundleCodeOptions): Promise<string>;
788
+
789
+ interface RelayFetchOptions {
790
+ /** HTTP method */
791
+ method?: string;
792
+ /** Request body as a string */
793
+ body?: string;
794
+ /** Request headers */
795
+ headers?: HeadersInit;
796
+ /** Zapier authentication ID to use for the request */
797
+ authenticationId?: number;
798
+ /** URL to send async response to (makes request async) */
799
+ callbackUrl?: string;
800
+ /** Optional JSON string authentication template to bypass Notary lookup */
801
+ authenticationTemplate?: string;
802
+ }
803
+ interface RelayFetchConfig extends FunctionOptions {
804
+ /** Event callback function */
805
+ onEvent?: (event: any) => void;
806
+ }
807
+ /**
808
+ * Fetch function that can make requests to external APIs through Zapier's Relay service
809
+ *
810
+ * This function takes full URLs (like https://api.github.com/user) and transforms them
811
+ * into the relay format (/relay/api.github.com/user) for the API client to route
812
+ * to relay.zapier.com.
813
+ *
814
+ * @param url - The full URL to fetch
815
+ * @param options - Fetch options with additional Relay-specific parameters
816
+ * @param config - SDK configuration options
817
+ * @returns Promise<Response> - The response from the request
818
+ */
819
+ /**
820
+ * Schema-compatible wrapper function for the fetch functionality
821
+ */
822
+ declare function fetch$1(options: {
823
+ url: string;
824
+ method?: string;
825
+ body?: string;
826
+ headers?: Record<string, string>;
827
+ authenticationId?: number;
828
+ callbackUrl?: string;
829
+ authenticationTemplate?: string;
830
+ } & FunctionOptions): Promise<Response>;
831
+ /**
832
+ * Internal fetch implementation
833
+ */
834
+ declare function relayFetch(url: string | URL, options?: RelayFetchOptions, config?: RelayFetchConfig): Promise<Response>;
835
+
836
+ interface ZapierSdkOptions extends BaseSdkOptions {
837
+ }
838
+ declare function createZapierSdk(options?: ZapierSdkOptions): ZapierSdk;
839
+
840
+ export { type Action, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionKeyProperty, ActionKeyPropertySchema, type ActionProxy, type ActionTypeProperty, ActionTypePropertySchema, type ApiEvent, type AppKeyProperty, AppKeyPropertySchema, AppNotFoundError, type AppsPluginOptions, type AppsPluginSdkExtension, type AuthEvent, type AuthObject, type AuthOptions, type Authentication, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type AuthenticationsResponse, type BaseSdkOptions, type BaseZapierSdk, type Choice, type DebugProperty, DebugPropertySchema, type EventCallback, type Field, type FunctionOptions, type InputsProperty, InputsPropertySchema, type Integration, type LimitProperty, LimitPropertySchema, type LoadingEvent, type NeedsRequest, type NeedsResponse, type OffsetProperty, OffsetPropertySchema, type OutputProperty, OutputPropertySchema, type ParamsProperty, ParamsPropertySchema, RelayFetchSchema, type ResolverName, type ResolverType, type SdkEvent, type Trigger, type ZapierSdk, ZapierSdkError, type ZapierSdkOptions, actionKeyResolver, actionTypeResolver, appKeyResolver, authenticationIdResolver, bundleCode, createAppsPlugin, createZapierSdk, fetch$1 as fetch, findFirstAuthentication, findUniqueAuthentication, generateTypes, getAction, getApp, getAuthentication, getResolutionOrder, getResolutionOrderForParams, getResolvableParams, getResolver, getResolversForMissingParams, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, hasResolver, inputsResolver, isPositional, listActions, listApps, listAuthentications, listFields, relayFetch, resolverRegistry, runAction };