@zapier/zapier-sdk-cli 0.6.4 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @zapier/zapier-sdk-cli
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 3a39eee: Add listInputFieldChoices method
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [3a39eee]
12
+ - @zapier/zapier-sdk-mcp@0.3.0
13
+ - @zapier/zapier-sdk@0.8.0
14
+
15
+ ## 0.7.0
16
+
17
+ ### Minor Changes
18
+
19
+ - 096d674: Changed incorrect account_id parameter to accountId. Also made sure all CLI parameters are documented as kebab-case.
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [096d674]
24
+ - @zapier/zapier-sdk@0.7.0
25
+ - @zapier/zapier-sdk-mcp@0.2.5
26
+
27
+ ## 0.6.5
28
+
29
+ ### Patch Changes
30
+
31
+ - 8b2b6b6: Fix pagination numbering regression and async iteration
32
+
3
33
  ## 0.6.4
4
34
 
5
35
  ### Patch Changes
package/README.md CHANGED
@@ -15,6 +15,7 @@
15
15
  - [Actions](#actions)
16
16
  - [`getAction`](#getaction)
17
17
  - [`listActions`](#listactions)
18
+ - [`listInputFieldChoices`](#listinputfieldchoices)
18
19
  - [`listInputFields`](#listinputfields)
19
20
  - [`runAction`](#runaction)
20
21
  - [Apps](#apps)
@@ -117,16 +118,16 @@ Get detailed information about a specific action
117
118
 
118
119
  **Options:**
119
120
 
120
- | Option | Type | Required | Default | Possible Values | Description |
121
- | -------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------- |
122
- | `<appKey>` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
123
- | `<actionType>` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
124
- | `<actionKey>` | `string` | ✅ | — | — | Action key to execute |
121
+ | Option | Type | Required | Default | Possible Values | Description |
122
+ | --------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------- |
123
+ | `<app-key>` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
124
+ | `<action-type>` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
125
+ | `<action-key>` | `string` | ✅ | — | — | Action key to execute |
125
126
 
126
127
  **Usage:**
127
128
 
128
129
  ```bash
129
- npx zapier-sdk get-action <appKey> <actionType> <actionKey>
130
+ npx zapier-sdk get-action <app-key> <action-type> <action-key>
130
131
  ```
131
132
 
132
133
  #### `list-actions`
@@ -137,7 +138,7 @@ List all actions for a specific app
137
138
 
138
139
  | Option | Type | Required | Default | Possible Values | Description |
139
140
  | --------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------ |
140
- | `<appKey>` | `string` | ✅ | — | — | App key of actions to list (e.g., 'SlackCLIAPI') |
141
+ | `<app-key>` | `string` | ✅ | — | — | App key of actions to list (e.g., 'SlackCLIAPI') |
141
142
  | `--action-type` | `string` | ❌ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Filter actions by type |
142
143
  | `--page-size` | `number` | ❌ | — | — | Number of actions per page |
143
144
  | `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
@@ -145,7 +146,31 @@ List all actions for a specific app
145
146
  **Usage:**
146
147
 
147
148
  ```bash
148
- npx zapier-sdk list-actions <appKey> [--action-type] [--page-size] [--max-items]
149
+ npx zapier-sdk list-actions <app-key> [--action-type] [--page-size] [--max-items]
150
+ ```
151
+
152
+ #### `list-input-field-choices`
153
+
154
+ Get the available choices for a dynamic dropdown input field
155
+
156
+ **Options:**
157
+
158
+ | Option | Type | Required | Default | Possible Values | Description |
159
+ | --------------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
160
+ | `<app-key>` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
161
+ | `<action-type>` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
162
+ | `<action-key>` | `string` | ✅ | — | — | Action key to execute |
163
+ | `<input-field-key>` | `string` | ✅ | — | — | Input field key to get choices for. |
164
+ | `--authentication-id` | `string` | ❌ | — | — | Authentication ID to use for this action |
165
+ | `--inputs` | `object` | ❌ | — | — | Current input values that may affect available choices |
166
+ | `--page` | `number` | ❌ | — | — | Page number for paginated results |
167
+ | `--page-size` | `number` | ❌ | — | — | Number of choices per page |
168
+ | `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
169
+
170
+ **Usage:**
171
+
172
+ ```bash
173
+ npx zapier-sdk list-input-field-choices <app-key> <action-type> <action-key> <input-field-key> [--authentication-id] [--inputs] [--page] [--page-size] [--max-items]
149
174
  ```
150
175
 
151
176
  #### `list-input-fields`
@@ -156,9 +181,9 @@ Get the input fields required for a specific action
156
181
 
157
182
  | Option | Type | Required | Default | Possible Values | Description |
158
183
  | --------------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
159
- | `<appKey>` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
160
- | `<actionType>` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
161
- | `<actionKey>` | `string` | ✅ | — | — | Action key to execute |
184
+ | `<app-key>` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
185
+ | `<action-type>` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
186
+ | `<action-key>` | `string` | ✅ | — | — | Action key to execute |
162
187
  | `--authentication-id` | `string` | ❌ | — | — | Authentication ID to use for this action |
163
188
  | `--inputs` | `object` | ❌ | — | — | Current input values that may affect available fields |
164
189
  | `--page-size` | `number` | ❌ | — | — | Number of input fields per page |
@@ -167,7 +192,7 @@ Get the input fields required for a specific action
167
192
  **Usage:**
168
193
 
169
194
  ```bash
170
- npx zapier-sdk list-input-fields <appKey> <actionType> <actionKey> [--authentication-id] [--inputs] [--page-size] [--max-items]
195
+ npx zapier-sdk list-input-fields <app-key> <action-type> <action-key> [--authentication-id] [--inputs] [--page-size] [--max-items]
171
196
  ```
172
197
 
173
198
  #### `run-action`
@@ -178,9 +203,9 @@ Execute an action with the given inputs
178
203
 
179
204
  | Option | Type | Required | Default | Possible Values | Description |
180
205
  | --------------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------- |
181
- | `<appKey>` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
182
- | `<actionType>` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
183
- | `<actionKey>` | `string` | ✅ | — | — | Action key to execute |
206
+ | `<app-key>` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
207
+ | `<action-type>` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
208
+ | `<action-key>` | `string` | ✅ | — | — | Action key to execute |
184
209
  | `--authentication-id` | `string` | ❌ | — | — | Authentication ID to use for this action |
185
210
  | `--inputs` | `object` | ❌ | — | — | Input parameters for the action |
186
211
  | `--page-size` | `number` | ❌ | — | — | Number of results per page |
@@ -189,7 +214,7 @@ Execute an action with the given inputs
189
214
  **Usage:**
190
215
 
191
216
  ```bash
192
- npx zapier-sdk run-action <appKey> <actionType> <actionKey> [--authentication-id] [--inputs] [--page-size] [--max-items]
217
+ npx zapier-sdk run-action <app-key> <action-type> <action-key> [--authentication-id] [--inputs] [--page-size] [--max-items]
193
218
  ```
194
219
 
195
220
  ### Apps
@@ -200,14 +225,14 @@ Get detailed information about a specific app
200
225
 
201
226
  **Options:**
202
227
 
203
- | Option | Type | Required | Default | Possible Values | Description |
204
- | ---------- | -------- | -------- | ------- | --------------- | --------------------------------------------- |
205
- | `<appKey>` | `string` | ✅ | — | — | App key of app to fetch (e.g., 'SlackCLIAPI') |
228
+ | Option | Type | Required | Default | Possible Values | Description |
229
+ | ----------- | -------- | -------- | ------- | --------------- | --------------------------------------------- |
230
+ | `<app-key>` | `string` | ✅ | — | — | App key of app to fetch (e.g., 'SlackCLIAPI') |
206
231
 
207
232
  **Usage:**
208
233
 
209
234
  ```bash
210
- npx zapier-sdk get-app <appKey>
235
+ npx zapier-sdk get-app <app-key>
211
236
  ```
212
237
 
213
238
  #### `list-apps`
@@ -242,13 +267,13 @@ Find the first authentication matching the criteria
242
267
  | `--app-key` | `string` | ❌ | — | — | App key of authentication to find (e.g., 'SlackCLIAPI') |
243
268
  | `--search` | `string` | ❌ | — | — | Search term to filter authentications by title |
244
269
  | `--title` | `string` | ❌ | — | — | Filter authentications by exact title match |
245
- | `--account_id` | `string` | ❌ | — | — | Filter by account ID |
270
+ | `--account-id` | `string` | ❌ | — | — | Filter by account ID |
246
271
  | `--owner` | `string` | ❌ | — | — | Filter by owner |
247
272
 
248
273
  **Usage:**
249
274
 
250
275
  ```bash
251
- npx zapier-sdk find-first-authentication [--app-key] [--search] [--title] [--account_id] [--owner]
276
+ npx zapier-sdk find-first-authentication [--app-key] [--search] [--title] [--account-id] [--owner]
252
277
  ```
253
278
 
254
279
  #### `find-unique-authentication`
@@ -262,13 +287,13 @@ Find a unique authentication matching the criteria
262
287
  | `--app-key` | `string` | ❌ | — | — | App key of authentication to find (e.g., 'SlackCLIAPI') |
263
288
  | `--search` | `string` | ❌ | — | — | Search term to filter authentications by title |
264
289
  | `--title` | `string` | ❌ | — | — | Filter authentications by exact title match |
265
- | `--account_id` | `string` | ❌ | — | — | Filter by account ID |
290
+ | `--account-id` | `string` | ❌ | — | — | Filter by account ID |
266
291
  | `--owner` | `string` | ❌ | — | — | Filter by owner |
267
292
 
268
293
  **Usage:**
269
294
 
270
295
  ```bash
271
- npx zapier-sdk find-unique-authentication [--app-key] [--search] [--title] [--account_id] [--owner]
296
+ npx zapier-sdk find-unique-authentication [--app-key] [--search] [--title] [--account-id] [--owner]
272
297
  ```
273
298
 
274
299
  #### `get-authentication`
@@ -277,14 +302,14 @@ Get a specific authentication by ID
277
302
 
278
303
  **Options:**
279
304
 
280
- | Option | Type | Required | Default | Possible Values | Description |
281
- | -------------------- | -------- | -------- | ------- | --------------- | ----------------------------- |
282
- | `<authenticationId>` | `number` | ✅ | — | — | Authentication ID to retrieve |
305
+ | Option | Type | Required | Default | Possible Values | Description |
306
+ | --------------------- | -------- | -------- | ------- | --------------- | ----------------------------- |
307
+ | `<authentication-id>` | `number` | ✅ | — | — | Authentication ID to retrieve |
283
308
 
284
309
  **Usage:**
285
310
 
286
311
  ```bash
287
- npx zapier-sdk get-authentication <authenticationId>
312
+ npx zapier-sdk get-authentication <authentication-id>
288
313
  ```
289
314
 
290
315
  #### `list-authentications`
@@ -298,7 +323,7 @@ List available authentications with optional filtering
298
323
  | `--app-key` | `string` | ❌ | — | — | App key of authentications to list (e.g., 'SlackCLIAPI') |
299
324
  | `--search` | `string` | ❌ | — | — | Search term to filter authentications by title |
300
325
  | `--title` | `string` | ❌ | — | — | Filter authentications by exact title match |
301
- | `--account_id` | `string` | ❌ | — | — | Filter by account ID |
326
+ | `--account-id` | `string` | ❌ | — | — | Filter by account ID |
302
327
  | `--owner` | `string` | ❌ | — | — | Filter by owner |
303
328
  | `--page-size` | `number` | ❌ | — | — | Number of authentications per page |
304
329
  | `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
@@ -306,7 +331,7 @@ List available authentications with optional filtering
306
331
  **Usage:**
307
332
 
308
333
  ```bash
309
- npx zapier-sdk list-authentications [--app-key] [--search] [--title] [--account_id] [--owner] [--page-size] [--max-items]
334
+ npx zapier-sdk list-authentications [--app-key] [--search] [--title] [--account-id] [--owner] [--page-size] [--max-items]
310
335
  ```
311
336
 
312
337
  ### HTTP Requests
@@ -365,7 +390,7 @@ Generate TypeScript SDK code for a specific app
365
390
 
366
391
  | Option | Type | Required | Default | Possible Values | Description |
367
392
  | --------------------- | -------- | -------- | ------- | --------------- | ------------------------------------------------------- |
368
- | `<appKey>` | `string` | ✅ | — | — | App key to generate SDK code for |
393
+ | `<app-key>` | `string` | ✅ | — | — | App key to generate SDK code for |
369
394
  | `--authentication-id` | `number` | ❌ | — | — | Authentication ID to use for this action |
370
395
  | `--output` | `string` | ❌ | — | — | Output file path (defaults to generated/<appKey>.ts) |
371
396
  | `--lock-file-path` | `string` | ❌ | — | — | Path to the .zapierrc lock file (defaults to .zapierrc) |
@@ -373,7 +398,7 @@ Generate TypeScript SDK code for a specific app
373
398
  **Usage:**
374
399
 
375
400
  ```bash
376
- npx zapier-sdk generate-types <appKey> [--authentication-id] [--output] [--lock-file-path]
401
+ npx zapier-sdk generate-types <app-key> [--authentication-id] [--output] [--lock-file-path]
377
402
  ```
378
403
 
379
404
  #### `get-config-path`
@@ -392,14 +417,14 @@ Execute lockVersion
392
417
 
393
418
  **Options:**
394
419
 
395
- | Option | Type | Required | Default | Possible Values | Description |
396
- | ---------- | -------- | -------- | ------- | --------------- | -------------------------------------------------------- |
397
- | `<appKey>` | `string` | ✅ | — | — | The app key to lock version for (e.g., 'slack', 'gmail') |
420
+ | Option | Type | Required | Default | Possible Values | Description |
421
+ | ----------- | -------- | -------- | ------- | --------------- | -------------------------------------------------------- |
422
+ | `<app-key>` | `string` | ✅ | — | — | The app key to lock version for (e.g., 'slack', 'gmail') |
398
423
 
399
424
  **Usage:**
400
425
 
401
426
  ```bash
402
- npx zapier-sdk lock-version <appKey>
427
+ npx zapier-sdk lock-version <app-key>
403
428
  ```
404
429
 
405
430
  #### `mcp`
package/dist/cli.cjs CHANGED
@@ -448,24 +448,24 @@ function getFormatMetadata(schema) {
448
448
  function getOutputSchema(schema) {
449
449
  return schema?._def?.outputSchema;
450
450
  }
451
- function formatItemsFromSchema(inputSchema, items) {
451
+ function formatItemsFromSchema(inputSchema, items, startingNumber = 0) {
452
452
  const outputSchema = getOutputSchema(inputSchema);
453
453
  if (!outputSchema) {
454
- formatItemsGeneric(items);
454
+ formatItemsGeneric(items, startingNumber);
455
455
  return;
456
456
  }
457
457
  const formatMeta = getFormatMetadata(outputSchema);
458
458
  if (!formatMeta) {
459
- formatItemsGeneric(items);
459
+ formatItemsGeneric(items, startingNumber);
460
460
  return;
461
461
  }
462
462
  items.forEach((item, index) => {
463
- formatSingleItem(item, index, formatMeta);
463
+ formatSingleItem(item, startingNumber + index, formatMeta);
464
464
  });
465
465
  }
466
- function formatSingleItem(item, index, formatMeta) {
466
+ function formatSingleItem(item, itemNumber, formatMeta) {
467
467
  const formatted = formatMeta.format(item);
468
- let titleLine = `${chalk3__default.default.gray(`${index + 1}.`)} ${chalk3__default.default.cyan(formatted.title)}`;
468
+ let titleLine = `${chalk3__default.default.gray(`${itemNumber + 1}.`)} ${chalk3__default.default.cyan(formatted.title)}`;
469
469
  if (formatted.subtitle) {
470
470
  titleLine += ` ${chalk3__default.default.gray(formatted.subtitle)}`;
471
471
  }
@@ -491,11 +491,13 @@ function applyStyle(value, style) {
491
491
  return chalk3__default.default.blue(value);
492
492
  }
493
493
  }
494
- function formatItemsGeneric(items) {
494
+ function formatItemsGeneric(items, startingNumber = 0) {
495
495
  items.forEach((item, index) => {
496
496
  const itemObj = item;
497
497
  const name = itemObj.title || itemObj.name || itemObj.key || itemObj.id || "Item";
498
- console.log(`${chalk3__default.default.gray(`${index + 1}.`)} ${chalk3__default.default.cyan(name)}`);
498
+ console.log(
499
+ `${chalk3__default.default.gray(`${startingNumber + index + 1}.`)} ${chalk3__default.default.cyan(name)}`
500
+ );
499
501
  if (itemObj.description) {
500
502
  console.log(` ${chalk3__default.default.dim(itemObj.description)}`);
501
503
  }
@@ -515,6 +517,10 @@ function formatJsonOutput(data) {
515
517
  }
516
518
  function analyzeZodSchema(schema) {
517
519
  const parameters = [];
520
+ if (schema._def && schema._def.typeName === "ZodEffects") {
521
+ const innerSchema = schema._def.schema;
522
+ return analyzeZodSchema(innerSchema);
523
+ }
518
524
  if (schema instanceof zod.z.ZodObject) {
519
525
  const shape = schema.shape;
520
526
  for (const [key, fieldSchema] of Object.entries(shape)) {
@@ -530,14 +536,19 @@ function analyzeZodField(name, schema) {
530
536
  let baseSchema = schema;
531
537
  let required = true;
532
538
  let defaultValue = void 0;
533
- if (baseSchema instanceof zod.z.ZodOptional) {
534
- required = false;
535
- baseSchema = baseSchema._def.innerType;
536
- }
537
- if (baseSchema instanceof zod.z.ZodDefault) {
538
- required = false;
539
- defaultValue = baseSchema._def.defaultValue();
540
- baseSchema = baseSchema._def.innerType;
539
+ while (true) {
540
+ if (baseSchema instanceof zod.z.ZodOptional) {
541
+ required = false;
542
+ baseSchema = baseSchema._def.innerType;
543
+ } else if (baseSchema instanceof zod.z.ZodDefault) {
544
+ required = false;
545
+ defaultValue = baseSchema._def.defaultValue();
546
+ baseSchema = baseSchema._def.innerType;
547
+ } else if (baseSchema._def && baseSchema._def.typeName === "ZodNullable") {
548
+ baseSchema = baseSchema._def.innerType;
549
+ } else {
550
+ break;
551
+ }
541
552
  }
542
553
  let paramType = "string";
543
554
  let choices;
@@ -679,7 +690,7 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk2) {
679
690
  );
680
691
  if (isListCommand && hasPaginationParams && !shouldUseJson && !hasUserSpecifiedMaxItems) {
681
692
  const sdkObj = sdk2;
682
- const sdkIterator = await sdkObj[sdkMethodName](resolvedParams);
693
+ const sdkIterator = sdkObj[sdkMethodName](resolvedParams);
683
694
  await handlePaginatedListWithAsyncIteration(
684
695
  sdkMethodName,
685
696
  sdkIterator,
@@ -863,9 +874,9 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
863
874
  );
864
875
  }
865
876
  if (schema) {
866
- formatItemsFromSchema(schema, items);
877
+ formatItemsFromSchema(schema, items, totalShown);
867
878
  } else {
868
- formatItemsGeneric2(items);
879
+ formatItemsGeneric2(items, totalShown);
869
880
  }
870
881
  totalShown += items.length;
871
882
  console.log(
@@ -900,9 +911,9 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
900
911
  return;
901
912
  }
902
913
  if (schema) {
903
- formatItemsFromSchema(schema, items);
914
+ formatItemsFromSchema(schema, items, 0);
904
915
  } else {
905
- formatItemsGeneric2(items);
916
+ formatItemsGeneric2(items, 0);
906
917
  }
907
918
  console.log(chalk3__default.default.green(`
908
919
  \u2705 Showing ${items.length} ${itemName}`));
@@ -949,11 +960,13 @@ function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxIt
949
960
  \u{1F4C4} All available ${itemName} shown`));
950
961
  }
951
962
  }
952
- function formatItemsGeneric2(items) {
963
+ function formatItemsGeneric2(items, startingNumber = 0) {
953
964
  items.forEach((item, index) => {
954
965
  const itemObj = item;
955
966
  const name = itemObj?.name || itemObj?.key || itemObj?.id || "Item";
956
- console.log(`${chalk3__default.default.gray(`${index + 1}.`)} ${chalk3__default.default.cyan(String(name))}`);
967
+ console.log(
968
+ `${chalk3__default.default.gray(`${startingNumber + index + 1}.`)} ${chalk3__default.default.cyan(String(name))}`
969
+ );
957
970
  if (itemObj?.description) {
958
971
  console.log(` ${chalk3__default.default.dim(String(itemObj.description))}`);
959
972
  }
@@ -1698,7 +1711,7 @@ function createZapierCliSdk(options = {}) {
1698
1711
 
1699
1712
  // package.json
1700
1713
  var package_default = {
1701
- version: "0.6.4"};
1714
+ version: "0.8.0"};
1702
1715
 
1703
1716
  // src/cli.ts
1704
1717
  var program = new commander.Command();
package/dist/cli.mjs CHANGED
@@ -415,24 +415,24 @@ function getFormatMetadata(schema) {
415
415
  function getOutputSchema(schema) {
416
416
  return schema?._def?.outputSchema;
417
417
  }
418
- function formatItemsFromSchema(inputSchema, items) {
418
+ function formatItemsFromSchema(inputSchema, items, startingNumber = 0) {
419
419
  const outputSchema = getOutputSchema(inputSchema);
420
420
  if (!outputSchema) {
421
- formatItemsGeneric(items);
421
+ formatItemsGeneric(items, startingNumber);
422
422
  return;
423
423
  }
424
424
  const formatMeta = getFormatMetadata(outputSchema);
425
425
  if (!formatMeta) {
426
- formatItemsGeneric(items);
426
+ formatItemsGeneric(items, startingNumber);
427
427
  return;
428
428
  }
429
429
  items.forEach((item, index) => {
430
- formatSingleItem(item, index, formatMeta);
430
+ formatSingleItem(item, startingNumber + index, formatMeta);
431
431
  });
432
432
  }
433
- function formatSingleItem(item, index, formatMeta) {
433
+ function formatSingleItem(item, itemNumber, formatMeta) {
434
434
  const formatted = formatMeta.format(item);
435
- let titleLine = `${chalk3.gray(`${index + 1}.`)} ${chalk3.cyan(formatted.title)}`;
435
+ let titleLine = `${chalk3.gray(`${itemNumber + 1}.`)} ${chalk3.cyan(formatted.title)}`;
436
436
  if (formatted.subtitle) {
437
437
  titleLine += ` ${chalk3.gray(formatted.subtitle)}`;
438
438
  }
@@ -458,11 +458,13 @@ function applyStyle(value, style) {
458
458
  return chalk3.blue(value);
459
459
  }
460
460
  }
461
- function formatItemsGeneric(items) {
461
+ function formatItemsGeneric(items, startingNumber = 0) {
462
462
  items.forEach((item, index) => {
463
463
  const itemObj = item;
464
464
  const name = itemObj.title || itemObj.name || itemObj.key || itemObj.id || "Item";
465
- console.log(`${chalk3.gray(`${index + 1}.`)} ${chalk3.cyan(name)}`);
465
+ console.log(
466
+ `${chalk3.gray(`${startingNumber + index + 1}.`)} ${chalk3.cyan(name)}`
467
+ );
466
468
  if (itemObj.description) {
467
469
  console.log(` ${chalk3.dim(itemObj.description)}`);
468
470
  }
@@ -482,6 +484,10 @@ function formatJsonOutput(data) {
482
484
  }
483
485
  function analyzeZodSchema(schema) {
484
486
  const parameters = [];
487
+ if (schema._def && schema._def.typeName === "ZodEffects") {
488
+ const innerSchema = schema._def.schema;
489
+ return analyzeZodSchema(innerSchema);
490
+ }
485
491
  if (schema instanceof z.ZodObject) {
486
492
  const shape = schema.shape;
487
493
  for (const [key, fieldSchema] of Object.entries(shape)) {
@@ -497,14 +503,19 @@ function analyzeZodField(name, schema) {
497
503
  let baseSchema = schema;
498
504
  let required = true;
499
505
  let defaultValue = void 0;
500
- if (baseSchema instanceof z.ZodOptional) {
501
- required = false;
502
- baseSchema = baseSchema._def.innerType;
503
- }
504
- if (baseSchema instanceof z.ZodDefault) {
505
- required = false;
506
- defaultValue = baseSchema._def.defaultValue();
507
- baseSchema = baseSchema._def.innerType;
506
+ while (true) {
507
+ if (baseSchema instanceof z.ZodOptional) {
508
+ required = false;
509
+ baseSchema = baseSchema._def.innerType;
510
+ } else if (baseSchema instanceof z.ZodDefault) {
511
+ required = false;
512
+ defaultValue = baseSchema._def.defaultValue();
513
+ baseSchema = baseSchema._def.innerType;
514
+ } else if (baseSchema._def && baseSchema._def.typeName === "ZodNullable") {
515
+ baseSchema = baseSchema._def.innerType;
516
+ } else {
517
+ break;
518
+ }
508
519
  }
509
520
  let paramType = "string";
510
521
  let choices;
@@ -646,7 +657,7 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk2) {
646
657
  );
647
658
  if (isListCommand && hasPaginationParams && !shouldUseJson && !hasUserSpecifiedMaxItems) {
648
659
  const sdkObj = sdk2;
649
- const sdkIterator = await sdkObj[sdkMethodName](resolvedParams);
660
+ const sdkIterator = sdkObj[sdkMethodName](resolvedParams);
650
661
  await handlePaginatedListWithAsyncIteration(
651
662
  sdkMethodName,
652
663
  sdkIterator,
@@ -830,9 +841,9 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
830
841
  );
831
842
  }
832
843
  if (schema) {
833
- formatItemsFromSchema(schema, items);
844
+ formatItemsFromSchema(schema, items, totalShown);
834
845
  } else {
835
- formatItemsGeneric2(items);
846
+ formatItemsGeneric2(items, totalShown);
836
847
  }
837
848
  totalShown += items.length;
838
849
  console.log(
@@ -867,9 +878,9 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
867
878
  return;
868
879
  }
869
880
  if (schema) {
870
- formatItemsFromSchema(schema, items);
881
+ formatItemsFromSchema(schema, items, 0);
871
882
  } else {
872
- formatItemsGeneric2(items);
883
+ formatItemsGeneric2(items, 0);
873
884
  }
874
885
  console.log(chalk3.green(`
875
886
  \u2705 Showing ${items.length} ${itemName}`));
@@ -916,11 +927,13 @@ function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxIt
916
927
  \u{1F4C4} All available ${itemName} shown`));
917
928
  }
918
929
  }
919
- function formatItemsGeneric2(items) {
930
+ function formatItemsGeneric2(items, startingNumber = 0) {
920
931
  items.forEach((item, index) => {
921
932
  const itemObj = item;
922
933
  const name = itemObj?.name || itemObj?.key || itemObj?.id || "Item";
923
- console.log(`${chalk3.gray(`${index + 1}.`)} ${chalk3.cyan(String(name))}`);
934
+ console.log(
935
+ `${chalk3.gray(`${startingNumber + index + 1}.`)} ${chalk3.cyan(String(name))}`
936
+ );
924
937
  if (itemObj?.description) {
925
938
  console.log(` ${chalk3.dim(String(itemObj.description))}`);
926
939
  }
@@ -1665,7 +1678,7 @@ function createZapierCliSdk(options = {}) {
1665
1678
 
1666
1679
  // package.json
1667
1680
  var package_default = {
1668
- version: "0.6.4"};
1681
+ version: "0.8.0"};
1669
1682
 
1670
1683
  // src/cli.ts
1671
1684
  var program = new Command();
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk-cli",
3
- "version": "0.6.4",
3
+ "version": "0.8.0",
4
4
  "description": "Command line interface for Zapier SDK",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",