@zapier/zapier-sdk-cli 0.6.4 → 0.6.5

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,11 @@
1
1
  # @zapier/zapier-sdk-cli
2
2
 
3
+ ## 0.6.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 8b2b6b6: Fix pagination numbering regression and async iteration
8
+
3
9
  ## 0.6.4
4
10
 
5
11
  ### Patch Changes
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
  }
@@ -679,7 +681,7 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk2) {
679
681
  );
680
682
  if (isListCommand && hasPaginationParams && !shouldUseJson && !hasUserSpecifiedMaxItems) {
681
683
  const sdkObj = sdk2;
682
- const sdkIterator = await sdkObj[sdkMethodName](resolvedParams);
684
+ const sdkIterator = sdkObj[sdkMethodName](resolvedParams);
683
685
  await handlePaginatedListWithAsyncIteration(
684
686
  sdkMethodName,
685
687
  sdkIterator,
@@ -863,9 +865,9 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
863
865
  );
864
866
  }
865
867
  if (schema) {
866
- formatItemsFromSchema(schema, items);
868
+ formatItemsFromSchema(schema, items, totalShown);
867
869
  } else {
868
- formatItemsGeneric2(items);
870
+ formatItemsGeneric2(items, totalShown);
869
871
  }
870
872
  totalShown += items.length;
871
873
  console.log(
@@ -900,9 +902,9 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
900
902
  return;
901
903
  }
902
904
  if (schema) {
903
- formatItemsFromSchema(schema, items);
905
+ formatItemsFromSchema(schema, items, 0);
904
906
  } else {
905
- formatItemsGeneric2(items);
907
+ formatItemsGeneric2(items, 0);
906
908
  }
907
909
  console.log(chalk3__default.default.green(`
908
910
  \u2705 Showing ${items.length} ${itemName}`));
@@ -949,11 +951,13 @@ function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxIt
949
951
  \u{1F4C4} All available ${itemName} shown`));
950
952
  }
951
953
  }
952
- function formatItemsGeneric2(items) {
954
+ function formatItemsGeneric2(items, startingNumber = 0) {
953
955
  items.forEach((item, index) => {
954
956
  const itemObj = item;
955
957
  const name = itemObj?.name || itemObj?.key || itemObj?.id || "Item";
956
- console.log(`${chalk3__default.default.gray(`${index + 1}.`)} ${chalk3__default.default.cyan(String(name))}`);
958
+ console.log(
959
+ `${chalk3__default.default.gray(`${startingNumber + index + 1}.`)} ${chalk3__default.default.cyan(String(name))}`
960
+ );
957
961
  if (itemObj?.description) {
958
962
  console.log(` ${chalk3__default.default.dim(String(itemObj.description))}`);
959
963
  }
@@ -1698,7 +1702,7 @@ function createZapierCliSdk(options = {}) {
1698
1702
 
1699
1703
  // package.json
1700
1704
  var package_default = {
1701
- version: "0.6.4"};
1705
+ version: "0.6.5"};
1702
1706
 
1703
1707
  // src/cli.ts
1704
1708
  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
  }
@@ -646,7 +648,7 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk2) {
646
648
  );
647
649
  if (isListCommand && hasPaginationParams && !shouldUseJson && !hasUserSpecifiedMaxItems) {
648
650
  const sdkObj = sdk2;
649
- const sdkIterator = await sdkObj[sdkMethodName](resolvedParams);
651
+ const sdkIterator = sdkObj[sdkMethodName](resolvedParams);
650
652
  await handlePaginatedListWithAsyncIteration(
651
653
  sdkMethodName,
652
654
  sdkIterator,
@@ -830,9 +832,9 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
830
832
  );
831
833
  }
832
834
  if (schema) {
833
- formatItemsFromSchema(schema, items);
835
+ formatItemsFromSchema(schema, items, totalShown);
834
836
  } else {
835
- formatItemsGeneric2(items);
837
+ formatItemsGeneric2(items, totalShown);
836
838
  }
837
839
  totalShown += items.length;
838
840
  console.log(
@@ -867,9 +869,9 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
867
869
  return;
868
870
  }
869
871
  if (schema) {
870
- formatItemsFromSchema(schema, items);
872
+ formatItemsFromSchema(schema, items, 0);
871
873
  } else {
872
- formatItemsGeneric2(items);
874
+ formatItemsGeneric2(items, 0);
873
875
  }
874
876
  console.log(chalk3.green(`
875
877
  \u2705 Showing ${items.length} ${itemName}`));
@@ -916,11 +918,13 @@ function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxIt
916
918
  \u{1F4C4} All available ${itemName} shown`));
917
919
  }
918
920
  }
919
- function formatItemsGeneric2(items) {
921
+ function formatItemsGeneric2(items, startingNumber = 0) {
920
922
  items.forEach((item, index) => {
921
923
  const itemObj = item;
922
924
  const name = itemObj?.name || itemObj?.key || itemObj?.id || "Item";
923
- console.log(`${chalk3.gray(`${index + 1}.`)} ${chalk3.cyan(String(name))}`);
925
+ console.log(
926
+ `${chalk3.gray(`${startingNumber + index + 1}.`)} ${chalk3.cyan(String(name))}`
927
+ );
924
928
  if (itemObj?.description) {
925
929
  console.log(` ${chalk3.dim(String(itemObj.description))}`);
926
930
  }
@@ -1665,7 +1669,7 @@ function createZapierCliSdk(options = {}) {
1665
1669
 
1666
1670
  // package.json
1667
1671
  var package_default = {
1668
- version: "0.6.4"};
1672
+ version: "0.6.5"};
1669
1673
 
1670
1674
  // src/cli.ts
1671
1675
  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.6.5",
4
4
  "description": "Command line interface for Zapier SDK",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -203,9 +203,9 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk) {
203
203
  hasPaginationParams &&
204
204
  !shouldUseJson &&
205
205
  !hasUserSpecifiedMaxItems) {
206
- // Get the async iterator directly from the SDK method call
206
+ // Get the async iterable directly from the SDK method call (don't await it! that breaks the next page behavior)
207
207
  const sdkObj = sdk;
208
- const sdkIterator = await sdkObj[sdkMethodName](resolvedParams);
208
+ const sdkIterator = sdkObj[sdkMethodName](resolvedParams);
209
209
  await handlePaginatedListWithAsyncIteration(sdkMethodName, sdkIterator, schema);
210
210
  }
211
211
  else {
@@ -391,10 +391,10 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
391
391
  }
392
392
  // Format and display items using schema
393
393
  if (schema) {
394
- formatItemsFromSchema(schema, items);
394
+ formatItemsFromSchema(schema, items, totalShown);
395
395
  }
396
396
  else {
397
- formatItemsGeneric(items);
397
+ formatItemsGeneric(items, totalShown);
398
398
  }
399
399
  totalShown += items.length;
400
400
  console.log(chalk.green(`\n✅ Showing ${totalShown} ${itemName} (page ${pageCount})`));
@@ -428,10 +428,10 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
428
428
  return;
429
429
  }
430
430
  if (schema) {
431
- formatItemsFromSchema(schema, items);
431
+ formatItemsFromSchema(schema, items, 0);
432
432
  }
433
433
  else {
434
- formatItemsGeneric(items);
434
+ formatItemsGeneric(items, 0);
435
435
  }
436
436
  console.log(chalk.green(`\n✅ Showing ${items.length} ${itemName}`));
437
437
  }
@@ -476,12 +476,12 @@ function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxIt
476
476
  console.log(chalk.gray(`\n📄 All available ${itemName} shown`));
477
477
  }
478
478
  }
479
- function formatItemsGeneric(items) {
479
+ function formatItemsGeneric(items, startingNumber = 0) {
480
480
  // Fallback formatting for items without schema metadata
481
481
  items.forEach((item, index) => {
482
482
  const itemObj = item;
483
483
  const name = itemObj?.name || itemObj?.key || itemObj?.id || "Item";
484
- console.log(`${chalk.gray(`${index + 1}.`)} ${chalk.cyan(String(name))}`);
484
+ console.log(`${chalk.gray(`${startingNumber + index + 1}.`)} ${chalk.cyan(String(name))}`);
485
485
  if (itemObj?.description) {
486
486
  console.log(` ${chalk.dim(String(itemObj.description))}`);
487
487
  }
@@ -1,2 +1,2 @@
1
1
  import { z } from "zod";
2
- export declare function formatItemsFromSchema(inputSchema: z.ZodType, items: unknown[]): void;
2
+ export declare function formatItemsFromSchema(inputSchema: z.ZodType, items: unknown[], startingNumber?: number): void;
@@ -9,30 +9,30 @@ function getOutputSchema(schema) {
9
9
  // ============================================================================
10
10
  // Generic Schema-Driven Formatter
11
11
  // ============================================================================
12
- export function formatItemsFromSchema(inputSchema, items) {
12
+ export function formatItemsFromSchema(inputSchema, items, startingNumber = 0) {
13
13
  // Get the output schema and its format metadata
14
14
  const outputSchema = getOutputSchema(inputSchema);
15
15
  if (!outputSchema) {
16
16
  // Fallback to generic formatting if no output schema
17
- formatItemsGeneric(items);
17
+ formatItemsGeneric(items, startingNumber);
18
18
  return;
19
19
  }
20
20
  const formatMeta = getFormatMetadata(outputSchema);
21
21
  if (!formatMeta) {
22
22
  // Fallback to generic formatting if no format metadata
23
- formatItemsGeneric(items);
23
+ formatItemsGeneric(items, startingNumber);
24
24
  return;
25
25
  }
26
26
  // Format each item using the schema metadata
27
27
  items.forEach((item, index) => {
28
- formatSingleItem(item, index, formatMeta);
28
+ formatSingleItem(item, startingNumber + index, formatMeta);
29
29
  });
30
30
  }
31
- function formatSingleItem(item, index, formatMeta) {
31
+ function formatSingleItem(item, itemNumber, formatMeta) {
32
32
  // Get the formatted item from the format function
33
33
  const formatted = formatMeta.format(item);
34
34
  // Build the main title line
35
- let titleLine = `${chalk.gray(`${index + 1}.`)} ${chalk.cyan(formatted.title)}`;
35
+ let titleLine = `${chalk.gray(`${itemNumber + 1}.`)} ${chalk.cyan(formatted.title)}`;
36
36
  if (formatted.subtitle) {
37
37
  titleLine += ` ${chalk.gray(formatted.subtitle)}`;
38
38
  }
@@ -59,12 +59,12 @@ function applyStyle(value, style) {
59
59
  return chalk.blue(value);
60
60
  }
61
61
  }
62
- function formatItemsGeneric(items) {
62
+ function formatItemsGeneric(items, startingNumber = 0) {
63
63
  // Fallback formatting for items without schema metadata
64
64
  items.forEach((item, index) => {
65
65
  const itemObj = item;
66
66
  const name = itemObj.title || itemObj.name || itemObj.key || itemObj.id || "Item";
67
- console.log(`${chalk.gray(`${index + 1}.`)} ${chalk.cyan(name)}`);
67
+ console.log(`${chalk.gray(`${startingNumber + index + 1}.`)} ${chalk.cyan(name)}`);
68
68
  if (itemObj.description) {
69
69
  console.log(` ${chalk.dim(itemObj.description)}`);
70
70
  }