@zapier/zapier-sdk-cli 0.44.0 → 0.45.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 (45) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +392 -40
  3. package/bin/zapier-sdk-experimental.mjs +14 -0
  4. package/dist/cli.cjs +585 -37
  5. package/dist/cli.mjs +584 -36
  6. package/dist/experimental.cjs +3519 -0
  7. package/dist/experimental.d.mts +39 -0
  8. package/dist/experimental.d.ts +39 -0
  9. package/dist/experimental.mjs +3483 -0
  10. package/dist/index.cjs +507 -26
  11. package/dist/index.d.mts +3 -514
  12. package/dist/index.d.ts +3 -514
  13. package/dist/index.mjs +505 -24
  14. package/dist/package.json +14 -2
  15. package/dist/sdk-B3nKAZdN.d.mts +516 -0
  16. package/dist/sdk-B3nKAZdN.d.ts +516 -0
  17. package/dist/src/cli.js +26 -2
  18. package/dist/src/experimental.d.ts +33 -0
  19. package/dist/src/experimental.js +83 -0
  20. package/dist/src/generators/ast-generator.d.ts +2 -2
  21. package/dist/src/generators/ast-generator.js +1 -1
  22. package/dist/src/plugins/add/index.d.ts +2 -2
  23. package/dist/src/plugins/bundleCode/index.js +3 -12
  24. package/dist/src/plugins/curl/index.js +2 -2
  25. package/dist/src/plugins/curl/utils.d.ts +11 -1
  26. package/dist/src/plugins/curl/utils.js +14 -5
  27. package/dist/src/plugins/drainTriggerInbox/index.d.ts +46 -0
  28. package/dist/src/plugins/drainTriggerInbox/index.js +178 -0
  29. package/dist/src/plugins/generateAppTypes/index.d.ts +2 -2
  30. package/dist/src/plugins/index.d.ts +2 -0
  31. package/dist/src/plugins/index.js +2 -0
  32. package/dist/src/plugins/mcp/index.d.ts +1 -0
  33. package/dist/src/plugins/mcp/index.js +5 -1
  34. package/dist/src/plugins/watchTriggerInbox/index.d.ts +45 -0
  35. package/dist/src/plugins/watchTriggerInbox/index.js +157 -0
  36. package/dist/src/sdk.js +5 -1
  37. package/dist/src/utils/cli-generator.js +18 -1
  38. package/dist/src/utils/cli-renderer.d.ts +12 -0
  39. package/dist/src/utils/cli-renderer.js +22 -1
  40. package/dist/src/utils/parameter-resolver.d.ts +1 -0
  41. package/dist/src/utils/parameter-resolver.js +55 -9
  42. package/dist/src/utils/triggerDrain.d.ts +144 -0
  43. package/dist/src/utils/triggerDrain.js +351 -0
  44. package/dist/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +16 -4
@@ -0,0 +1,516 @@
1
+ import * as _zapier_zapier_sdk from '@zapier/zapier-sdk';
2
+ import { AppItem, Manifest, ZapierSdk } from '@zapier/zapier-sdk';
3
+ import { z } from 'zod';
4
+
5
+ declare const BuildManifestSchema: z.ZodObject<{
6
+ apps: z.ZodArray<z.ZodString>;
7
+ skipWrite: z.ZodOptional<z.ZodBoolean>;
8
+ configPath: z.ZodOptional<z.ZodString>;
9
+ }, z.core.$strip>;
10
+ type BuildManifestOptions = z.infer<typeof BuildManifestSchema> & {
11
+ onProgress?: (event: ManifestBuildProgressEvent) => void;
12
+ };
13
+ type ManifestBuildProgressEvent = {
14
+ type: "apps_lookup_start";
15
+ count: number;
16
+ } | {
17
+ type: "app_found";
18
+ app: AppItem;
19
+ } | {
20
+ type: "apps_lookup_complete";
21
+ count: number;
22
+ } | {
23
+ type: "app_processing_start";
24
+ app: string;
25
+ slug?: string;
26
+ } | {
27
+ type: "manifest_entry_built";
28
+ app: string;
29
+ manifestKey: string;
30
+ version: string;
31
+ } | {
32
+ type: "manifest_updated";
33
+ app: string;
34
+ manifestKey: string;
35
+ version: string;
36
+ } | {
37
+ type: "app_processing_complete";
38
+ app: string;
39
+ } | {
40
+ type: "app_processing_error";
41
+ app: string;
42
+ error: string;
43
+ };
44
+ interface BuildManifestResult {
45
+ manifest?: Manifest;
46
+ }
47
+
48
+ declare const buildManifestPlugin: (sdk: {
49
+ listApps: (options?: ({
50
+ search?: string | undefined;
51
+ apps?: string[] | undefined;
52
+ appKeys?: string[] | undefined;
53
+ pageSize?: number | undefined;
54
+ maxItems?: number | undefined;
55
+ cursor?: string | undefined;
56
+ } & {
57
+ cursor?: string;
58
+ pageSize?: number;
59
+ maxItems?: number;
60
+ }) | undefined) => _zapier_zapier_sdk.PaginatedSdkResult<{
61
+ slug: string;
62
+ title: string;
63
+ key: string;
64
+ implementation_id: string;
65
+ description?: string | undefined;
66
+ is_hidden?: boolean | undefined;
67
+ auth_type?: string | undefined;
68
+ actions?: {
69
+ read?: number | undefined;
70
+ read_bulk?: number | undefined;
71
+ write?: number | undefined;
72
+ search?: number | undefined;
73
+ search_or_write?: number | undefined;
74
+ search_and_write?: number | undefined;
75
+ filter?: number | undefined;
76
+ } | undefined;
77
+ is_deprecated?: boolean | undefined;
78
+ is_beta?: boolean | undefined;
79
+ is_premium?: boolean | undefined;
80
+ age_in_days?: number | undefined;
81
+ banner?: string | undefined;
82
+ categories?: {
83
+ id: number;
84
+ name: string;
85
+ slug: string;
86
+ }[] | undefined;
87
+ images?: {
88
+ url_16x16?: string | undefined;
89
+ url_32x32?: string | undefined;
90
+ url_64x64?: string | undefined;
91
+ url_128x128?: string | undefined;
92
+ } | undefined;
93
+ popularity?: number | undefined;
94
+ has_filters?: boolean | undefined;
95
+ has_reads?: boolean | undefined;
96
+ has_searches?: boolean | undefined;
97
+ has_searches_or_writes?: boolean | undefined;
98
+ has_upfront_fields?: boolean | undefined;
99
+ has_writes?: boolean | undefined;
100
+ is_built_in?: boolean | undefined;
101
+ is_featured?: boolean | undefined;
102
+ is_invite?: boolean | undefined;
103
+ is_public?: boolean | undefined;
104
+ is_upcoming?: boolean | undefined;
105
+ visibility?: string | undefined;
106
+ primary_color?: string | undefined;
107
+ secondary_color?: string | undefined;
108
+ classification?: string | undefined;
109
+ api_docs_url?: string | undefined;
110
+ image?: string | undefined;
111
+ version?: string | undefined;
112
+ }>;
113
+ } & {
114
+ context: {
115
+ meta: {
116
+ listApps: _zapier_zapier_sdk.PluginMeta;
117
+ };
118
+ };
119
+ } & {
120
+ context: {
121
+ getResolvedManifest: () => Promise<Manifest | null>;
122
+ getVersionedImplementationId: (appKey: string) => Promise<string | null>;
123
+ resolveAppKeys: ({ appKeys }: {
124
+ appKeys: string[];
125
+ }) => Promise<_zapier_zapier_sdk.ResolvedAppLocator[]>;
126
+ updateManifestEntry: (options: _zapier_zapier_sdk.UpdateManifestEntryOptions) => Promise<_zapier_zapier_sdk.UpdateManifestEntryResult>;
127
+ addActionEntry: (options: _zapier_zapier_sdk.AddActionEntryOptions) => Promise<_zapier_zapier_sdk.AddActionEntryResult>;
128
+ findActionEntry: ({ name, manifest, }: {
129
+ name: string;
130
+ manifest: Manifest;
131
+ }) => _zapier_zapier_sdk.ActionEntry | null;
132
+ listActionEntries: ({ configPath, }?: {
133
+ configPath?: string;
134
+ }) => Promise<Array<[string, _zapier_zapier_sdk.ActionEntry]>>;
135
+ deleteActionEntry: ({ name, configPath, skipWrite, }: {
136
+ name: string;
137
+ configPath?: string;
138
+ skipWrite?: boolean;
139
+ }) => Promise<Manifest>;
140
+ hasActionEntry: ({ name, manifest, }: {
141
+ name: string;
142
+ manifest: Manifest;
143
+ }) => boolean;
144
+ findManifestEntry: typeof _zapier_zapier_sdk.findManifestEntry;
145
+ readManifestFromFile: typeof _zapier_zapier_sdk.readManifestFromFile;
146
+ getManifestConnections: () => Promise<Record<string, {
147
+ connectionId: string | number;
148
+ }> | null>;
149
+ };
150
+ } & {
151
+ context: _zapier_zapier_sdk.EventEmissionContext;
152
+ } & {
153
+ context: {
154
+ meta: Record<string, _zapier_zapier_sdk.PluginMeta>;
155
+ };
156
+ }) => {
157
+ buildManifest: (options?: BuildManifestOptions | undefined) => Promise<BuildManifestResult>;
158
+ } & {
159
+ context: {
160
+ meta: {
161
+ buildManifest: _zapier_zapier_sdk.PluginMeta;
162
+ };
163
+ };
164
+ };
165
+ type BuildManifestPluginProvides = ReturnType<typeof buildManifestPlugin>;
166
+
167
+ declare const feedbackPlugin: (sdk: {
168
+ context: {
169
+ options?: {
170
+ debug?: boolean;
171
+ };
172
+ };
173
+ } & {
174
+ context: _zapier_zapier_sdk.EventEmissionContext;
175
+ } & {
176
+ context: {
177
+ meta: Record<string, _zapier_zapier_sdk.PluginMeta>;
178
+ };
179
+ }) => {
180
+ feedback: (options?: {
181
+ feedback: string;
182
+ } | undefined) => Promise<string>;
183
+ } & {
184
+ context: {
185
+ meta: {
186
+ feedback: _zapier_zapier_sdk.PluginMeta;
187
+ };
188
+ };
189
+ };
190
+ type FeedbackPluginProvides = ReturnType<typeof feedbackPlugin>;
191
+
192
+ declare const GenerateAppTypesSchema: z.ZodObject<{
193
+ apps: z.ZodArray<z.ZodString>;
194
+ connections: z.ZodOptional<z.ZodArray<z.ZodString>>;
195
+ skipWrite: z.ZodOptional<z.ZodBoolean>;
196
+ typesOutputDirectory: z.ZodOptional<z.ZodString>;
197
+ }, z.core.$strip>;
198
+ type GenerateAppTypesOptions = z.infer<typeof GenerateAppTypesSchema> & {
199
+ onProgress?: (event: AppTypesProgressEvent) => void;
200
+ };
201
+ type AppTypesProgressEvent = {
202
+ type: "apps_lookup_start";
203
+ count: number;
204
+ } | {
205
+ type: "app_found";
206
+ app: AppItem;
207
+ } | {
208
+ type: "apps_lookup_complete";
209
+ count: number;
210
+ } | {
211
+ type: "connections_lookup_start";
212
+ count: number;
213
+ } | {
214
+ type: "connections_lookup_complete";
215
+ count: number;
216
+ } | {
217
+ type: "app_processing_start";
218
+ app: string;
219
+ slug?: string;
220
+ } | {
221
+ type: "connection_matched";
222
+ app: string;
223
+ connectionId: string;
224
+ connectionTitle: string;
225
+ } | {
226
+ type: "connection_not_matched";
227
+ app: string;
228
+ } | {
229
+ type: "type_generated";
230
+ manifestKey: string;
231
+ sizeBytes: number;
232
+ } | {
233
+ type: "file_written";
234
+ manifestKey: string;
235
+ filePath: string;
236
+ } | {
237
+ type: "app_processing_complete";
238
+ app: string;
239
+ } | {
240
+ type: "app_processing_error";
241
+ app: string;
242
+ error: string;
243
+ };
244
+ interface GenerateAppTypesResult {
245
+ typeDefinitions: Record<string, string>;
246
+ writtenFiles?: Record<string, string>;
247
+ }
248
+
249
+ declare const generateAppTypesPlugin: (sdk: {
250
+ listApps: (options?: ({
251
+ search?: string | undefined;
252
+ apps?: string[] | undefined;
253
+ appKeys?: string[] | undefined;
254
+ pageSize?: number | undefined;
255
+ maxItems?: number | undefined;
256
+ cursor?: string | undefined;
257
+ } & {
258
+ cursor?: string;
259
+ pageSize?: number;
260
+ maxItems?: number;
261
+ }) | undefined) => _zapier_zapier_sdk.PaginatedSdkResult<{
262
+ slug: string;
263
+ title: string;
264
+ key: string;
265
+ implementation_id: string;
266
+ description?: string | undefined;
267
+ is_hidden?: boolean | undefined;
268
+ auth_type?: string | undefined;
269
+ actions?: {
270
+ read?: number | undefined;
271
+ read_bulk?: number | undefined;
272
+ write?: number | undefined;
273
+ search?: number | undefined;
274
+ search_or_write?: number | undefined;
275
+ search_and_write?: number | undefined;
276
+ filter?: number | undefined;
277
+ } | undefined;
278
+ is_deprecated?: boolean | undefined;
279
+ is_beta?: boolean | undefined;
280
+ is_premium?: boolean | undefined;
281
+ age_in_days?: number | undefined;
282
+ banner?: string | undefined;
283
+ categories?: {
284
+ id: number;
285
+ name: string;
286
+ slug: string;
287
+ }[] | undefined;
288
+ images?: {
289
+ url_16x16?: string | undefined;
290
+ url_32x32?: string | undefined;
291
+ url_64x64?: string | undefined;
292
+ url_128x128?: string | undefined;
293
+ } | undefined;
294
+ popularity?: number | undefined;
295
+ has_filters?: boolean | undefined;
296
+ has_reads?: boolean | undefined;
297
+ has_searches?: boolean | undefined;
298
+ has_searches_or_writes?: boolean | undefined;
299
+ has_upfront_fields?: boolean | undefined;
300
+ has_writes?: boolean | undefined;
301
+ is_built_in?: boolean | undefined;
302
+ is_featured?: boolean | undefined;
303
+ is_invite?: boolean | undefined;
304
+ is_public?: boolean | undefined;
305
+ is_upcoming?: boolean | undefined;
306
+ visibility?: string | undefined;
307
+ primary_color?: string | undefined;
308
+ secondary_color?: string | undefined;
309
+ classification?: string | undefined;
310
+ api_docs_url?: string | undefined;
311
+ image?: string | undefined;
312
+ version?: string | undefined;
313
+ }>;
314
+ } & {
315
+ context: {
316
+ meta: {
317
+ listApps: _zapier_zapier_sdk.PluginMeta;
318
+ };
319
+ };
320
+ } & {
321
+ listActions: (options?: (({
322
+ app: string;
323
+ actionType?: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write" | undefined;
324
+ pageSize?: number | undefined;
325
+ maxItems?: number | undefined;
326
+ cursor?: string | undefined;
327
+ } | {
328
+ appKey: string;
329
+ actionType?: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write" | undefined;
330
+ pageSize?: number | undefined;
331
+ maxItems?: number | undefined;
332
+ cursor?: string | undefined;
333
+ }) & {
334
+ cursor?: string;
335
+ pageSize?: number;
336
+ maxItems?: number;
337
+ }) | undefined) => _zapier_zapier_sdk.PaginatedSdkResult<{
338
+ description: string;
339
+ key: string;
340
+ app_key: string;
341
+ action_type: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
342
+ title: string;
343
+ type: "action";
344
+ id?: string | undefined;
345
+ is_important?: boolean | undefined;
346
+ is_hidden?: boolean | undefined;
347
+ app_version?: string | undefined;
348
+ }>;
349
+ } & {
350
+ context: {
351
+ meta: {
352
+ listActions: _zapier_zapier_sdk.PluginMeta;
353
+ };
354
+ };
355
+ } & {
356
+ listActionInputFields: (options?: (({
357
+ app: string;
358
+ actionType: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
359
+ action: string;
360
+ connection?: string | number | undefined;
361
+ connectionId?: string | number | null | undefined;
362
+ authenticationId?: string | number | null | undefined;
363
+ inputs?: Record<string, unknown> | undefined;
364
+ pageSize?: number | undefined;
365
+ maxItems?: number | undefined;
366
+ cursor?: string | undefined;
367
+ } | {
368
+ appKey: string;
369
+ actionType: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
370
+ actionKey: string;
371
+ connection?: string | number | undefined;
372
+ connectionId?: string | number | null | undefined;
373
+ authenticationId?: string | number | null | undefined;
374
+ inputs?: Record<string, unknown> | undefined;
375
+ pageSize?: number | undefined;
376
+ maxItems?: number | undefined;
377
+ cursor?: string | undefined;
378
+ }) & {
379
+ cursor?: string;
380
+ pageSize?: number;
381
+ maxItems?: number;
382
+ }) | undefined) => _zapier_zapier_sdk.PaginatedSdkResult<{
383
+ key: string;
384
+ type: "input_field";
385
+ default_value: string;
386
+ depends_on: string[];
387
+ description: string;
388
+ invalidates_input_fields: boolean;
389
+ is_required: boolean;
390
+ placeholder: string;
391
+ title: string;
392
+ value_type: string;
393
+ format?: string | undefined;
394
+ items?: {
395
+ type: string;
396
+ } | undefined;
397
+ } | {
398
+ key: string;
399
+ type: "info_field";
400
+ description: string;
401
+ title?: string | undefined;
402
+ } | _zapier_zapier_sdk.FieldsetItem>;
403
+ } & {
404
+ context: {
405
+ meta: {
406
+ listActionInputFields: _zapier_zapier_sdk.PluginMeta;
407
+ };
408
+ };
409
+ } & {
410
+ listConnections: (options?: ({
411
+ title?: string | undefined;
412
+ search?: string | undefined;
413
+ owner?: string | undefined;
414
+ app?: string | undefined;
415
+ appKey?: string | undefined;
416
+ connections?: string[] | undefined;
417
+ connectionIds?: string[] | undefined;
418
+ authenticationIds?: string[] | undefined;
419
+ account?: string | undefined;
420
+ accountId?: string | undefined;
421
+ includeShared?: boolean | undefined;
422
+ isExpired?: boolean | undefined;
423
+ expired?: boolean | undefined;
424
+ pageSize?: number | undefined;
425
+ maxItems?: number | undefined;
426
+ cursor?: string | undefined;
427
+ } & {
428
+ cursor?: string;
429
+ pageSize?: number;
430
+ maxItems?: number;
431
+ }) | undefined) => _zapier_zapier_sdk.PaginatedSdkResult<{
432
+ date: string;
433
+ is_invite_only: boolean;
434
+ is_private: boolean;
435
+ shared_with_all: boolean;
436
+ id: string;
437
+ account_id: string;
438
+ title?: string | null | undefined;
439
+ lastchanged?: string | undefined;
440
+ destination_selected_api?: string | null | undefined;
441
+ is_stale?: string | undefined;
442
+ is_shared?: string | undefined;
443
+ marked_stale_at?: string | null | undefined;
444
+ label?: string | null | undefined;
445
+ identifier?: string | null | undefined;
446
+ url?: string | undefined;
447
+ groups?: Record<string, unknown>[] | undefined;
448
+ members?: string | undefined;
449
+ permissions?: Record<string, boolean> | undefined;
450
+ public_id?: string | undefined;
451
+ account_public_id?: string | undefined;
452
+ customuser_public_id?: string | undefined;
453
+ implementation_id?: string | undefined;
454
+ profile_id?: string | undefined;
455
+ is_expired?: string | undefined;
456
+ expired_at?: string | null | undefined;
457
+ app_key?: string | undefined;
458
+ app_version?: string | undefined;
459
+ }>;
460
+ } & {
461
+ context: {
462
+ meta: {
463
+ listConnections: _zapier_zapier_sdk.PluginMeta;
464
+ };
465
+ };
466
+ } & {
467
+ context: {
468
+ getResolvedManifest: () => Promise<_zapier_zapier_sdk.Manifest | null>;
469
+ getVersionedImplementationId: (appKey: string) => Promise<string | null>;
470
+ resolveAppKeys: ({ appKeys }: {
471
+ appKeys: string[];
472
+ }) => Promise<_zapier_zapier_sdk.ResolvedAppLocator[]>;
473
+ updateManifestEntry: (options: _zapier_zapier_sdk.UpdateManifestEntryOptions) => Promise<_zapier_zapier_sdk.UpdateManifestEntryResult>;
474
+ addActionEntry: (options: _zapier_zapier_sdk.AddActionEntryOptions) => Promise<_zapier_zapier_sdk.AddActionEntryResult>;
475
+ findActionEntry: ({ name, manifest, }: {
476
+ name: string;
477
+ manifest: _zapier_zapier_sdk.Manifest;
478
+ }) => _zapier_zapier_sdk.ActionEntry | null;
479
+ listActionEntries: ({ configPath, }?: {
480
+ configPath?: string;
481
+ }) => Promise<Array<[string, _zapier_zapier_sdk.ActionEntry]>>;
482
+ deleteActionEntry: ({ name, configPath, skipWrite, }: {
483
+ name: string;
484
+ configPath?: string;
485
+ skipWrite?: boolean;
486
+ }) => Promise<_zapier_zapier_sdk.Manifest>;
487
+ hasActionEntry: ({ name, manifest, }: {
488
+ name: string;
489
+ manifest: _zapier_zapier_sdk.Manifest;
490
+ }) => boolean;
491
+ findManifestEntry: typeof _zapier_zapier_sdk.findManifestEntry;
492
+ readManifestFromFile: typeof _zapier_zapier_sdk.readManifestFromFile;
493
+ getManifestConnections: () => Promise<Record<string, {
494
+ connectionId: string | number;
495
+ }> | null>;
496
+ };
497
+ } & {
498
+ context: _zapier_zapier_sdk.EventEmissionContext;
499
+ } & {
500
+ context: {
501
+ meta: Record<string, _zapier_zapier_sdk.PluginMeta>;
502
+ };
503
+ }) => {
504
+ generateAppTypes: (options?: GenerateAppTypesOptions | undefined) => Promise<GenerateAppTypesResult>;
505
+ } & {
506
+ context: {
507
+ meta: {
508
+ generateAppTypes: _zapier_zapier_sdk.PluginMeta;
509
+ };
510
+ };
511
+ };
512
+ type GenerateAppTypesPluginProvides = ReturnType<typeof generateAppTypesPlugin>;
513
+
514
+ type ZapierSdkCli = ZapierSdk & BuildManifestPluginProvides & FeedbackPluginProvides & GenerateAppTypesPluginProvides;
515
+
516
+ export type { ZapierSdkCli as Z };
package/dist/src/cli.js CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command, CommanderError } from "commander";
3
3
  import { generateCliCommands } from "./utils/cli-generator";
4
- import { createZapierCliSdk } from "./sdk";
4
+ import { createZapierCliSdk as createStableCliSdk } from "./sdk";
5
+ import { createZapierCliSdk as createExperimentalCliSdk } from "./experimental";
5
6
  import { resolveExtensions } from "./utils/extensions";
6
7
  import packageJson from "../package.json" with { type: "json" };
7
8
  import { ZapierCliError } from "./utils/errors";
@@ -25,7 +26,12 @@ program
25
26
  .option("--credentials-base-url <url>", "Base URL for authentication endpoints")
26
27
  .option("--tracking-base-url <url>", "Base URL for Zapier tracking endpoints")
27
28
  .option("--max-network-retries <count>", "Max retries for rate-limited requests (default: 3)")
28
- .option("--max-network-retry-delay-ms <ms>", "Max delay in ms to wait for rate limit retry (default: 60000)");
29
+ .option("--max-network-retry-delay-ms <ms>", "Max delay in ms to wait for rate limit retry (default: 60000)")
30
+ // Registered so Commander accepts --experimental without rejecting it as
31
+ // unknown. The actual factory selection happens before Commander parses,
32
+ // by peeking at argv directly. Equivalent to using the
33
+ // `zapier-sdk-experimental` bin or setting `ZAPIER_EXPERIMENTAL=1`.
34
+ .option("--experimental", "Use the experimental SDK / CLI surface");
29
35
  // Dynamically register boolean flags from BaseSdkOptionsSchema
30
36
  const booleanFlags = [];
31
37
  for (const [key, fieldSchema] of Object.entries(
@@ -103,6 +109,24 @@ for (const { camelName, kebabFlag } of booleanFlags) {
103
109
  flagOverrides[camelName] = true;
104
110
  }
105
111
  }
112
+ // Pick which CLI SDK factory to use BEFORE Commander parses anything,
113
+ // because the registry of available commands differs by factory:
114
+ // experimental commands literally don't exist in the stable factory's
115
+ // registry. Two equivalent triggers, either of which selects experimental:
116
+ //
117
+ // - `--experimental` appears in argv (passed by the user, or pushed by
118
+ // the `zapier-sdk-experimental` bin shim)
119
+ // - `ZAPIER_EXPERIMENTAL=1` is set in the environment
120
+ //
121
+ // The bin shim works by pushing `--experimental` onto argv before
122
+ // importing this file, so this single argv check covers both `zapier-sdk
123
+ // --experimental` and the dedicated `zapier-sdk-experimental` bin.
124
+ const useExperimental = process.argv.includes("--experimental") ||
125
+ process.env.ZAPIER_EXPERIMENTAL === "1" ||
126
+ process.env.ZAPIER_EXPERIMENTAL === "true";
127
+ const createZapierCliSdk = useExperimental
128
+ ? createExperimentalCliSdk
129
+ : createStableCliSdk;
106
130
  // Override Commander's default exit behavior to handle our custom errors
107
131
  program.exitOverride();
108
132
  (async () => {
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Experimental CLI SDK factory.
3
+ *
4
+ * Mirror of `./sdk.ts`, but built on top of
5
+ * `@zapier/zapier-sdk/experimental` so the underlying SDK has every
6
+ * `meta.experimental: true` plugin registered. The CLI's runtime
7
+ * entry point (`cli.ts`) chooses between this and the stable factory
8
+ * based on three equivalent triggers detected before Commander parses:
9
+ * the `zapier-sdk-experimental` bin name (via `argv[1]`), the
10
+ * `--experimental` flag, or the `ZAPIER_EXPERIMENTAL=1` env var.
11
+ *
12
+ * Plugin chain matches `./sdk.ts` literally, with future CLI-only
13
+ * experimental plugins inserted at appropriate positions. Both
14
+ * factories are kept in sync by shape tests.
15
+ */
16
+ import { type Plugin, type PluginProvides, type ZapierSdkOptions } from "@zapier/zapier-sdk/experimental";
17
+ import type { ZapierSdkCli } from "./types/sdk";
18
+ export interface ZapierCliSdkOptions extends ZapierSdkOptions {
19
+ /**
20
+ * Extra plugins discovered from `@zapier/zapier-sdk` extension packages.
21
+ * Pre-resolved by `cli.ts` (`utils/extensions.ts`) so this factory stays
22
+ * synchronous. Each plugin is layered onto the chain after all built-in
23
+ * CLI plugins, so its functions appear in `getRegistry({ package: "cli" })`
24
+ * automatically.
25
+ */
26
+ extensions?: Plugin<unknown, PluginProvides>[];
27
+ }
28
+ /**
29
+ * Create a Zapier CLI SDK with experimental plugins registered. The
30
+ * returned shape is a superset of the stable CLI SDK — same plugins
31
+ * plus any marked experimental.
32
+ */
33
+ export declare function createZapierCliSdk(options?: ZapierCliSdkOptions): ZapierSdkCli;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Experimental CLI SDK factory.
3
+ *
4
+ * Mirror of `./sdk.ts`, but built on top of
5
+ * `@zapier/zapier-sdk/experimental` so the underlying SDK has every
6
+ * `meta.experimental: true` plugin registered. The CLI's runtime
7
+ * entry point (`cli.ts`) chooses between this and the stable factory
8
+ * based on three equivalent triggers detected before Commander parses:
9
+ * the `zapier-sdk-experimental` bin name (via `argv[1]`), the
10
+ * `--experimental` flag, or the `ZAPIER_EXPERIMENTAL=1` env var.
11
+ *
12
+ * Plugin chain matches `./sdk.ts` literally, with future CLI-only
13
+ * experimental plugins inserted at appropriate positions. Both
14
+ * factories are kept in sync by shape tests.
15
+ */
16
+ import * as cliLogin from "./login";
17
+ import { createZapierSdk, injectCliLogin, } from "@zapier/zapier-sdk/experimental";
18
+ import { loginPlugin, logoutPlugin, mcpPlugin, bundleCodePlugin, getLoginConfigPathPlugin, addPlugin, generateAppTypesPlugin, buildManifestPlugin, feedbackPlugin, curlPlugin, cliOverridesPlugin, initPlugin, drainTriggerInboxCliPlugin, watchTriggerInboxCliPlugin, } from "./plugins/index";
19
+ import packageJson from "../package.json" with { type: "json" };
20
+ injectCliLogin(cliLogin);
21
+ /**
22
+ * Create a Zapier CLI SDK with experimental plugins registered. The
23
+ * returned shape is a superset of the stable CLI SDK — same plugins
24
+ * plus any marked experimental.
25
+ */
26
+ export function createZapierCliSdk(options = {}) {
27
+ const { extensions = [], ...sdkOptions } = options;
28
+ // Stash the resolved extensions on context so `mcpPlugin` can forward
29
+ // them to `startMcpServer`. Without this, MCP would build a vanilla SDK
30
+ // with no extensions and the CLI/MCP surfaces would diverge.
31
+ const extensionsContextPlugin = () => ({
32
+ context: { extensions },
33
+ });
34
+ // Tell the MCP plugin the CLI is in experimental mode so `mcp`
35
+ // launches a server built against `@zapier/zapier-sdk/experimental`.
36
+ // Without this, `zapier-sdk-experimental mcp` would silently expose
37
+ // only the stable surface — the README claim wouldn't match reality.
38
+ const experimentalContextPlugin = () => ({
39
+ context: { experimental: true },
40
+ });
41
+ let chain = createZapierSdk({
42
+ ...sdkOptions,
43
+ eventEmission: { ...sdkOptions.eventEmission, callContext: "cli" },
44
+ callerPackage: { name: packageJson.name, version: packageJson.version },
45
+ })
46
+ .addPlugin(extensionsContextPlugin)
47
+ .addPlugin(experimentalContextPlugin)
48
+ .addPlugin(generateAppTypesPlugin)
49
+ .addPlugin(buildManifestPlugin)
50
+ .addPlugin(bundleCodePlugin)
51
+ .addPlugin(getLoginConfigPathPlugin)
52
+ .addPlugin(addPlugin)
53
+ .addPlugin(feedbackPlugin)
54
+ .addPlugin(curlPlugin)
55
+ .addPlugin(initPlugin)
56
+ // Trigger inbox commands: the SDK's `drainTriggerInbox` and
57
+ // `watchTriggerInbox` are eager, callback-driven methods. Both CLI
58
+ // plugins override them to layer presentation flags (`--json`,
59
+ // interactive prompt, `--exec-shell` wrapping) around the same
60
+ // `onMessage` callback. `override: true` is the documented opt-in
61
+ // for intentional same-name replacement.
62
+ .addPlugin(drainTriggerInboxCliPlugin, { override: true })
63
+ .addPlugin(watchTriggerInboxCliPlugin, { override: true })
64
+ .addPlugin(mcpPlugin)
65
+ .addPlugin(loginPlugin)
66
+ .addPlugin(logoutPlugin)
67
+ .addPlugin(cliOverridesPlugin);
68
+ // Construct extensions defensively. The loader (`utils/extensions.ts`)
69
+ // already isolates *load*-time failures (failed dynamic imports);
70
+ // here we cover the second failure mode — a successfully-imported
71
+ // plugin that throws during construction (bad context lookup, schema
72
+ // build error, composePlugins collision, etc.). Honors the
73
+ // design-doc promise that "a broken extension does not kill the CLI."
74
+ for (const ext of extensions) {
75
+ try {
76
+ chain = chain.addPlugin(ext);
77
+ }
78
+ catch (err) {
79
+ console.warn(`Extension plugin failed to construct: ${err.message}; skipping.`);
80
+ }
81
+ }
82
+ return chain;
83
+ }
@@ -1,4 +1,4 @@
1
- import type { ListActionsPluginProvides, ListInputFieldsPluginProvides, ManifestPluginProvides, AppItem } from "@zapier/zapier-sdk";
1
+ import type { ListActionsPluginProvides, ListActionInputFieldsPluginProvides, ManifestPluginProvides, AppItem } from "@zapier/zapier-sdk";
2
2
  interface GenerateTypesOptions {
3
3
  app: AppItem;
4
4
  connectionId?: string | number;
@@ -13,7 +13,7 @@ export declare class AstTypeGenerator {
13
13
  * Generate TypeScript types using AST for a specific app
14
14
  */
15
15
  generateTypes(options: GenerateTypesOptions & {
16
- sdk: ListActionsPluginProvides & ListInputFieldsPluginProvides & ManifestPluginProvides;
16
+ sdk: ListActionsPluginProvides & ListActionInputFieldsPluginProvides & ManifestPluginProvides;
17
17
  }): Promise<string>;
18
18
  private createSourceFile;
19
19
  private createImportStatement;