@zapier/zapier-sdk-cli 0.35.1 → 0.36.1

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/dist/index.cjs CHANGED
@@ -2511,7 +2511,7 @@ function createZapierCliSdk(options = {}) {
2511
2511
 
2512
2512
  // package.json
2513
2513
  var package_default = {
2514
- version: "0.35.1"};
2514
+ version: "0.36.1"};
2515
2515
 
2516
2516
  // src/telemetry/builders.ts
2517
2517
  function createCliBaseEvent(context = {}) {
package/dist/index.mjs CHANGED
@@ -2478,7 +2478,7 @@ function createZapierCliSdk(options = {}) {
2478
2478
 
2479
2479
  // package.json
2480
2480
  var package_default = {
2481
- version: "0.35.1"};
2481
+ version: "0.36.1"};
2482
2482
 
2483
2483
  // src/telemetry/builders.ts
2484
2484
  function createCliBaseEvent(context = {}) {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk-cli",
3
- "version": "0.35.1",
3
+ "version": "0.36.1",
4
4
  "description": "Command line interface for Zapier SDK",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -56,6 +56,11 @@
56
56
  "CHANGELOG.md",
57
57
  "CLAUDE.md"
58
58
  ],
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "https://gitlab.com/zapier/zapier-sdk/zapier-sdk.git",
62
+ "directory": "packages/zapier-sdk-cli"
63
+ },
59
64
  "publishConfig": {
60
65
  "access": "public"
61
66
  },
@@ -78,6 +83,7 @@
78
83
  "pkce-challenge": "^5.0.0",
79
84
  "semver": "^7.7.3",
80
85
  "typescript": "^5.8.3",
86
+ "wrap-ansi": "^10.0.0",
81
87
  "zod": "4.2.1"
82
88
  },
83
89
  "devDependencies": {
@@ -103,15 +103,16 @@ const CONFIRM_MESSAGES = {
103
103
  "Once created, you cannot retrieve it again.",
104
104
  messageAfter: "Please treat this secret like a password and store it securely!",
105
105
  },
106
- delete: {
107
- messageBefore: "You are about to delete this record.",
108
- },
106
+ delete: (itemType) => ({
107
+ messageBefore: `You are about to delete the ${itemType || "item"}.`,
108
+ }),
109
109
  };
110
- async function promptConfirm(confirmType) {
110
+ async function promptConfirm(confirmType, itemType) {
111
111
  if (!confirmType || !CONFIRM_MESSAGES[confirmType]) {
112
112
  return { confirmed: true }; // No confirmation needed
113
113
  }
114
- const { messageBefore, messageAfter } = CONFIRM_MESSAGES[confirmType];
114
+ const configOrFn = CONFIRM_MESSAGES[confirmType];
115
+ const { messageBefore, messageAfter } = typeof configOrFn === "function" ? configOrFn(itemType) : configOrFn;
115
116
  console.log(chalk.yellow(`\n${messageBefore}\n`));
116
117
  const { confirmed } = await inquirer.prompt([
117
118
  {
@@ -196,6 +197,7 @@ function analyzeZodField(name, schema, functionInfo) {
196
197
  }
197
198
  // Determine parameter type
198
199
  let paramType = "string";
200
+ let elementType;
199
201
  let choices;
200
202
  if (baseSchema instanceof z.ZodString) {
201
203
  paramType = "string";
@@ -208,6 +210,17 @@ function analyzeZodField(name, schema, functionInfo) {
208
210
  }
209
211
  else if (baseSchema instanceof z.ZodArray) {
210
212
  paramType = "array";
213
+ const elementSchema = baseSchema._zod.def.element;
214
+ if (elementSchema instanceof z.ZodObject ||
215
+ elementSchema instanceof z.ZodRecord) {
216
+ elementType = "object";
217
+ }
218
+ else if (elementSchema instanceof z.ZodNumber) {
219
+ elementType = "number";
220
+ }
221
+ else if (elementSchema instanceof z.ZodBoolean) {
222
+ elementType = "boolean";
223
+ }
211
224
  }
212
225
  else if (baseSchema instanceof z.ZodEnum) {
213
226
  paramType = "string";
@@ -233,6 +246,7 @@ function analyzeZodField(name, schema, functionInfo) {
233
246
  choices,
234
247
  hasResolver: paramHasResolver,
235
248
  isPositional: isPositional(schema),
249
+ elementType,
236
250
  };
237
251
  }
238
252
  /**
@@ -431,7 +445,12 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
431
445
  const rawParams = convertCliArgsToSdkParams(parameters, args.slice(0, -1), options);
432
446
  if (schema && !usesInputParameters) {
433
447
  const resolver = new SchemaParameterResolver();
434
- resolvedParams = (await resolver.resolveParameters(schema, rawParams, sdk, functionInfo.name, { interactiveMode }));
448
+ resolvedParams = (await resolver.resolveParameters(schema, rawParams, sdk, functionInfo.name, {
449
+ interactiveMode,
450
+ debug: !!options.debug ||
451
+ process.env.DEBUG === "true" ||
452
+ process.argv.includes("--debug"),
453
+ }));
435
454
  }
436
455
  else {
437
456
  resolvedParams = rawParams;
@@ -439,7 +458,7 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
439
458
  const confirm = functionInfo.confirm;
440
459
  let confirmMessageAfter;
441
460
  if (confirm && interactiveMode) {
442
- const confirmResult = await promptConfirm(confirm);
461
+ const confirmResult = await promptConfirm(confirm, functionInfo.itemType);
443
462
  if (!confirmResult.confirmed) {
444
463
  console.log(chalk.yellow("Operation cancelled."));
445
464
  return;
@@ -643,7 +662,7 @@ function convertCliArgsToSdkParams(parameters, positionalArgs, options) {
643
662
  if ((param.required || param.isPositional) &&
644
663
  argIndex < positionalArgs.length) {
645
664
  // Use the original camelCase parameter name for the SDK
646
- sdkParams[param.name] = convertValue(positionalArgs[argIndex], param.type);
665
+ sdkParams[param.name] = convertValue(positionalArgs[argIndex], param.type, param.elementType);
647
666
  argIndex++;
648
667
  }
649
668
  });
@@ -661,12 +680,12 @@ function convertCliArgsToSdkParams(parameters, positionalArgs, options) {
661
680
  value.length === 0) {
662
681
  return;
663
682
  }
664
- sdkParams[camelKey] = convertValue(value, param.type);
683
+ sdkParams[camelKey] = convertValue(value, param.type, param.elementType);
665
684
  }
666
685
  });
667
686
  return sdkParams;
668
687
  }
669
- function convertValue(value, type) {
688
+ function convertValue(value, type, elementType) {
670
689
  // Don't convert undefined values - let the resolver system handle them
671
690
  if (value === undefined) {
672
691
  return undefined;
@@ -676,8 +695,23 @@ function convertValue(value, type) {
676
695
  return Number(value);
677
696
  case "boolean":
678
697
  return Boolean(value);
679
- case "array":
680
- return Array.isArray(value) ? value : [value];
698
+ case "array": {
699
+ const arr = Array.isArray(value) ? value : [value];
700
+ if (elementType !== "object")
701
+ return arr;
702
+ return arr.flatMap((item) => {
703
+ if (typeof item === "string" &&
704
+ (item.startsWith("{") || item.startsWith("["))) {
705
+ try {
706
+ return JSON.parse(item);
707
+ }
708
+ catch {
709
+ return item;
710
+ }
711
+ }
712
+ return item;
713
+ });
714
+ }
681
715
  case "string":
682
716
  return value;
683
717
  case "object":
@@ -1,8 +1,14 @@
1
1
  import { z } from "zod";
2
2
  import { type ZapierSdk } from "@zapier/zapier-sdk";
3
3
  export declare class SchemaParameterResolver {
4
+ private debug;
5
+ private spinner;
6
+ private debugLog;
7
+ private startSpinner;
8
+ private stopSpinner;
4
9
  resolveParameters(schema: z.ZodSchema, providedParams: unknown, sdk: ZapierSdk, functionName?: string, options?: {
5
10
  interactiveMode?: boolean;
11
+ debug?: boolean;
6
12
  }): Promise<unknown>;
7
13
  private extractParametersFromSchema;
8
14
  private analyzeFieldSchema;
@@ -20,7 +26,12 @@ export declare class SchemaParameterResolver {
20
26
  */
21
27
  private resolveRequiredParamsNonInteractive;
22
28
  private resolveParameter;
29
+ private resolveWithResolver;
23
30
  private resolveFieldsRecursively;
31
+ /**
32
+ * Resolves an array parameter by repeatedly prompting for items until user says no
33
+ */
34
+ private resolveArrayRecursively;
24
35
  /**
25
36
  * Recursively processes fieldsets and their fields, maintaining natural structure
26
37
  * and creating nested inputs as needed (e.g., fieldset "foo" becomes inputs.foo = [{}])