@zapier/zapier-sdk-cli 0.4.4 → 0.6.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/dist/cli.js CHANGED
@@ -205,29 +205,38 @@ var SchemaParameterResolver = class {
205
205
  }
206
206
  console.log(chalk.blue(`
207
207
  \u{1F50D} Resolving ${param.name}...`));
208
- if (resolver.type === "static") {
208
+ const typedResolver = resolver;
209
+ if (typedResolver.type === "static") {
209
210
  const promptConfig = {
210
- type: resolver.inputType === "password" ? "password" : "input",
211
+ type: typedResolver.inputType === "password" ? "password" : "input",
211
212
  name: param.name,
212
213
  message: `Enter ${param.name}:`,
213
- ...resolver.placeholder && { default: resolver.placeholder }
214
+ ...typedResolver.placeholder && {
215
+ default: typedResolver.placeholder
216
+ }
214
217
  };
215
218
  const answers = await inquirer.prompt([promptConfig]);
216
219
  return answers[param.name];
217
- } else if (resolver.type === "dynamic") {
220
+ } else if (typedResolver.type === "dynamic") {
218
221
  try {
219
222
  if (param.isRequired && param.name !== "authenticationId") {
220
223
  console.log(chalk.gray(`Fetching options for ${param.name}...`));
221
224
  }
222
- const items = await resolver.fetch(context.sdk, context.resolvedParams);
225
+ const items = await typedResolver.fetch(
226
+ context.sdk,
227
+ context.resolvedParams
228
+ );
223
229
  const safeItems = items || [];
224
- const promptConfig = resolver.prompt(safeItems, context.resolvedParams);
230
+ const promptConfig = typedResolver.prompt(
231
+ safeItems,
232
+ context.resolvedParams
233
+ );
225
234
  const answers = await inquirer.prompt([promptConfig]);
226
235
  return answers[param.name];
227
236
  } catch (error) {
228
237
  throw error;
229
238
  }
230
- } else if (resolver.type === "fields") {
239
+ } else if (typedResolver.type === "fields") {
231
240
  return await this.resolveFieldsRecursively(
232
241
  resolver,
233
242
  context,
@@ -237,6 +246,7 @@ var SchemaParameterResolver = class {
237
246
  throw new Error(`Unknown resolver type for ${param.name}`);
238
247
  }
239
248
  async resolveFieldsRecursively(resolver, context, param) {
249
+ const typedResolver = resolver;
240
250
  const inputs = {};
241
251
  let processedFieldKeys = /* @__PURE__ */ new Set();
242
252
  let iteration = 0;
@@ -255,7 +265,7 @@ var SchemaParameterResolver = class {
255
265
  `Fetching input fields for ${param.name}${iteration > 1 ? ` (iteration ${iteration})` : ""}...`
256
266
  )
257
267
  );
258
- const fields = await resolver.fetch(
268
+ const fields = await typedResolver.fetch(
259
269
  updatedContext.sdk,
260
270
  updatedContext.resolvedParams
261
271
  );
@@ -268,7 +278,7 @@ var SchemaParameterResolver = class {
268
278
  break;
269
279
  }
270
280
  const newFields = fields.filter(
271
- (field) => !processedFieldKeys.has(field.key)
281
+ (field) => !(field.key && processedFieldKeys.has(field.key))
272
282
  );
273
283
  if (newFields.length === 0) {
274
284
  break;
@@ -343,40 +353,54 @@ Optional fields:`));
343
353
  return inputs;
344
354
  }
345
355
  getNestedValue(obj, path3) {
346
- return path3.reduce((current, key) => current?.[key], obj);
356
+ return path3.reduce(
357
+ (current, key) => current?.[key],
358
+ obj
359
+ );
347
360
  }
348
361
  setNestedValue(obj, path3, value) {
349
362
  const lastKey = path3[path3.length - 1];
350
363
  const parent = path3.slice(0, -1).reduce((current, key) => {
351
- if (!(key in current)) {
352
- current[key] = {};
364
+ const currentObj = current;
365
+ if (!(key in currentObj)) {
366
+ currentObj[key] = {};
353
367
  }
354
- return current[key];
368
+ return currentObj[key];
355
369
  }, obj);
356
370
  parent[lastKey] = value;
357
371
  }
358
372
  async promptForField(field, inputs) {
373
+ const fieldObj = field;
359
374
  const fieldPrompt = {
360
- type: field.type === "boolean" ? "confirm" : "input",
361
- name: field.key,
362
- message: `${field.label || field.key}${field.required ? " (required)" : " (optional)"}:`,
363
- ...field.helpText && { prefix: chalk.gray(`\u2139 ${field.helpText}
364
- `) },
365
- ...field.default && { default: field.default }
375
+ type: fieldObj.type === "boolean" ? "confirm" : "input",
376
+ name: fieldObj.key,
377
+ message: `${fieldObj.label || fieldObj.key}${fieldObj.required ? " (required)" : " (optional)"}:`
366
378
  };
367
- if (field.choices && field.choices.length > 0) {
379
+ if (fieldObj.helpText) {
380
+ fieldPrompt.prefix = chalk.gray(`\u2139 ${fieldObj.helpText}
381
+ `);
382
+ }
383
+ if (fieldObj.default !== void 0) {
384
+ fieldPrompt.default = fieldObj.default;
385
+ }
386
+ if (fieldObj.choices && fieldObj.choices.length > 0) {
368
387
  fieldPrompt.type = "list";
369
- fieldPrompt.choices = field.choices.map((choice) => ({
370
- name: choice.label || choice.value,
371
- value: choice.value
372
- }));
388
+ fieldPrompt.choices = fieldObj.choices.map(
389
+ (choice) => {
390
+ const choiceObj = choice;
391
+ return {
392
+ name: choiceObj.label || choiceObj.value,
393
+ value: choiceObj.value
394
+ };
395
+ }
396
+ );
373
397
  }
374
398
  try {
375
399
  const answer = await inquirer.prompt([fieldPrompt]);
376
- if (answer[field.key] !== void 0 && answer[field.key] !== "") {
377
- inputs[field.key] = answer[field.key];
378
- } else if (field.required) {
379
- throw new Error(`Required field ${field.key} cannot be empty`);
400
+ if (answer[fieldObj.key] !== void 0 && answer[fieldObj.key] !== "") {
401
+ inputs[fieldObj.key] = answer[fieldObj.key];
402
+ } else if (fieldObj.required) {
403
+ throw new Error(`Required field ${fieldObj.key} cannot be empty`);
380
404
  }
381
405
  } catch (error) {
382
406
  if (this.isUserCancellation(error)) {
@@ -387,7 +411,8 @@ Optional fields:`));
387
411
  }
388
412
  }
389
413
  isUserCancellation(error) {
390
- return error?.name === "ExitPromptError" || error?.message?.includes("User force closed") || error?.isTTYError;
414
+ const errorObj = error;
415
+ return errorObj?.name === "ExitPromptError" || errorObj?.message?.includes("User force closed") || errorObj?.isTTYError === true;
391
416
  }
392
417
  };
393
418
 
@@ -444,10 +469,11 @@ function applyStyle(value, style) {
444
469
  }
445
470
  function formatItemsGeneric(items) {
446
471
  items.forEach((item, index) => {
447
- const name = item.title || item.name || item.key || item.id || "Item";
472
+ const itemObj = item;
473
+ const name = itemObj.title || itemObj.name || itemObj.key || itemObj.id || "Item";
448
474
  console.log(`${chalk2.gray(`${index + 1}.`)} ${chalk2.cyan(name)}`);
449
- if (item.description) {
450
- console.log(` ${chalk2.dim(item.description)}`);
475
+ if (itemObj.description) {
476
+ console.log(` ${chalk2.dim(itemObj.description)}`);
451
477
  }
452
478
  console.log();
453
479
  });
@@ -525,11 +551,12 @@ function methodNameToCliCommand(methodName) {
525
551
  return toKebabCase(methodName);
526
552
  }
527
553
  function generateCliCommands(program2, sdk2) {
528
- if (!sdk2.__registry) {
554
+ if (typeof sdk2.getRegistry !== "function") {
529
555
  console.error("SDK registry not available");
530
556
  return;
531
557
  }
532
- sdk2.__registry.forEach((fnInfo) => {
558
+ const registry = sdk2.getRegistry();
559
+ registry.functions.forEach((fnInfo) => {
533
560
  if (!fnInfo.inputSchema) {
534
561
  console.warn(`Schema not found for ${fnInfo.name}`);
535
562
  return;
@@ -543,6 +570,66 @@ function generateCliCommands(program2, sdk2) {
543
570
  );
544
571
  addCommand(program2, cliCommandName, config);
545
572
  });
573
+ program2.configureHelp({
574
+ formatHelp: (cmd, helper) => {
575
+ const helpWidth = helper.helpWidth || 80;
576
+ let output = helper.commandUsage(cmd) + "\n";
577
+ if (cmd.description()) {
578
+ output += helper.wrap(cmd.description(), helpWidth, 0) + "\n";
579
+ }
580
+ const options = helper.visibleOptions(cmd);
581
+ if (options.length > 0) {
582
+ output += "\nOptions:\n";
583
+ const longestOptionLength = Math.max(
584
+ ...options.map((opt) => helper.optionTerm(opt).length)
585
+ );
586
+ options.forEach((option) => {
587
+ const term = helper.optionTerm(option);
588
+ const padding = " ".repeat(
589
+ Math.max(2, longestOptionLength - term.length + 4)
590
+ );
591
+ output += ` ${term}${padding}${helper.optionDescription(option)}
592
+ `;
593
+ });
594
+ }
595
+ const commands = helper.visibleCommands(cmd);
596
+ if (commands.length > 0) {
597
+ output += "\nCommands:\n";
598
+ const categorizedCommands = /* @__PURE__ */ new Set();
599
+ registry.categories.forEach((category) => {
600
+ const categoryCommands = commands.filter(
601
+ (command) => category.functions.some((functionName) => {
602
+ const cliCommandName = methodNameToCliCommand(functionName);
603
+ return command.name() === cliCommandName;
604
+ })
605
+ );
606
+ if (categoryCommands.length > 0) {
607
+ output += `
608
+ ${category.titlePlural}:
609
+ `;
610
+ categoryCommands.forEach((command) => {
611
+ output += ` ${helper.subcommandTerm(command)}
612
+ `;
613
+ categorizedCommands.add(command.name());
614
+ });
615
+ }
616
+ });
617
+ const otherCommands = commands.filter(
618
+ (command) => !categorizedCommands.has(command.name())
619
+ );
620
+ if (otherCommands.length > 0) {
621
+ output += `
622
+ Other:
623
+ `;
624
+ otherCommands.forEach((command) => {
625
+ output += ` ${helper.subcommandTerm(command)}
626
+ `;
627
+ });
628
+ }
629
+ }
630
+ return output;
631
+ }
632
+ });
546
633
  }
547
634
  function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk2) {
548
635
  const parameters = analyzeZodSchema(schema);
@@ -568,24 +655,27 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk2) {
568
655
  rawParams,
569
656
  sdk2
570
657
  );
571
- const hasOutputFile = resolvedParams.output;
572
- if (hasOutputFile) {
573
- await sdk2[sdkMethodName](resolvedParams);
574
- console.log(
575
- chalk3.green(`\u2705 ${cliCommandName} completed successfully!`)
576
- );
577
- console.log(chalk3.gray(`Output written to: ${resolvedParams.output}`));
578
- return;
579
- }
580
658
  if (isListCommand && hasPaginationParams && !shouldUseJson && !hasUserSpecifiedMaxItems) {
581
- const sdkIterator = sdk2[sdkMethodName](resolvedParams);
659
+ const sdkObj = sdk2;
660
+ const sdkIterator = await sdkObj[sdkMethodName](resolvedParams);
582
661
  await handlePaginatedListWithAsyncIteration(
583
662
  sdkMethodName,
584
663
  sdkIterator,
585
664
  schema
586
665
  );
587
666
  } else {
588
- const result = await sdk2[sdkMethodName](resolvedParams);
667
+ const hasOutputFile = resolvedParams.output;
668
+ if (hasOutputFile) {
669
+ const sdkObj2 = sdk2;
670
+ await sdkObj2[sdkMethodName](resolvedParams);
671
+ console.log(
672
+ chalk3.green(`\u2705 ${cliCommandName} completed successfully!`)
673
+ );
674
+ console.log(chalk3.gray(`Output written to: ${hasOutputFile}`));
675
+ return;
676
+ }
677
+ const sdkObj = sdk2;
678
+ const result = await sdkObj[sdkMethodName](resolvedParams);
589
679
  const items = result?.data ? result.data : result;
590
680
  if (shouldUseJson) {
591
681
  console.log(JSON.stringify(items, null, 2));
@@ -608,8 +698,13 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk2) {
608
698
  const validationErrors = JSON.parse(error.message);
609
699
  console.error(chalk3.red("\u274C Validation Error:"));
610
700
  validationErrors.forEach((err) => {
611
- const field = err.path?.join(".") || "unknown";
612
- console.error(chalk3.yellow(` \u2022 ${field}: ${err.message}`));
701
+ const errorObj = err;
702
+ const field = errorObj?.path?.join(".") || "unknown";
703
+ console.error(
704
+ chalk3.yellow(
705
+ ` \u2022 ${field}: ${errorObj?.message || "Unknown error"}`
706
+ )
707
+ );
613
708
  });
614
709
  console.error(
615
710
  "\n" + chalk3.dim(`Use --help to see available options`)
@@ -658,10 +753,18 @@ function addCommand(program2, commandName, config) {
658
753
  command.option(flags.join(", "), param.description);
659
754
  } else if (param.type === "array") {
660
755
  const flagSignature = flags.join(", ") + ` <values...>`;
661
- command.option(flagSignature, param.description, param.default);
756
+ command.option(
757
+ flagSignature,
758
+ param.description,
759
+ param.default
760
+ );
662
761
  } else {
663
762
  const flagSignature = flags.join(", ") + ` <${param.type}>`;
664
- command.option(flagSignature, param.description, param.default);
763
+ command.option(
764
+ flagSignature,
765
+ param.description || "",
766
+ param.default
767
+ );
665
768
  }
666
769
  }
667
770
  });
@@ -826,10 +929,11 @@ function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxIt
826
929
  }
827
930
  function formatItemsGeneric2(items) {
828
931
  items.forEach((item, index) => {
829
- const name = item.title || item.name || item.key || item.id || "Item";
830
- console.log(`${chalk3.gray(`${index + 1}.`)} ${chalk3.cyan(name)}`);
831
- if (item.description) {
832
- console.log(` ${chalk3.dim(item.description)}`);
932
+ const itemObj = item;
933
+ const name = itemObj?.name || itemObj?.key || itemObj?.id || "Item";
934
+ console.log(`${chalk3.gray(`${index + 1}.`)} ${chalk3.cyan(String(name))}`);
935
+ if (itemObj?.description) {
936
+ console.log(` ${chalk3.dim(String(itemObj.description))}`);
833
937
  }
834
938
  console.log();
835
939
  });
@@ -1150,7 +1254,8 @@ var GenerateTypesSchema = z3.object({
1150
1254
  ),
1151
1255
  debug: DebugPropertySchema.describe(
1152
1256
  "Enable debug logging during generation"
1153
- )
1257
+ ),
1258
+ lockFilePath: z3.string().optional().describe("Path to the .zapierrc lock file (defaults to .zapierrc)")
1154
1259
  }).describe("Generate TypeScript SDK code for a specific app");
1155
1260
 
1156
1261
  // src/commands/generate-types/index.ts
@@ -1184,21 +1289,41 @@ async function generateTypes(options) {
1184
1289
  if (authenticationId) {
1185
1290
  for (const action of actions) {
1186
1291
  try {
1292
+ const manifestEntry = sdk2.getContext().getManifestEntry(appKey);
1187
1293
  const fieldsResult = await sdk2.listInputFields({
1188
- appKey: action.app_key,
1294
+ // If the appKey is in the manifest, use the appKey so that the types are consistent with the manifest's version, otherwise use the action.app_key
1295
+ appKey: manifestEntry ? appKey : action.app_key,
1189
1296
  actionKey: action.key,
1190
1297
  actionType: action.action_type,
1191
1298
  authenticationId
1192
1299
  });
1193
- const fields = fieldsResult.data;
1194
- actionsWithFields.push({ ...action, inputFields: fields });
1300
+ const fields = fieldsResult.data.map((field) => {
1301
+ const fieldObj = field;
1302
+ return {
1303
+ ...fieldObj,
1304
+ required: fieldObj.is_required || fieldObj.required || false
1305
+ };
1306
+ });
1307
+ actionsWithFields.push({
1308
+ ...action,
1309
+ inputFields: fields,
1310
+ name: action.title || action.key
1311
+ });
1195
1312
  } catch {
1196
- actionsWithFields.push({ ...action, inputFields: [] });
1313
+ actionsWithFields.push({
1314
+ ...action,
1315
+ inputFields: [],
1316
+ name: action.title || action.key
1317
+ });
1197
1318
  }
1198
1319
  }
1199
1320
  } else {
1200
1321
  actions.forEach((action) => {
1201
- actionsWithFields.push({ ...action, inputFields: [] });
1322
+ actionsWithFields.push({
1323
+ ...action,
1324
+ inputFields: [],
1325
+ name: action.title || action.key
1326
+ });
1202
1327
  });
1203
1328
  }
1204
1329
  const typeDefinitions = generateTypeDefinitions(
@@ -1556,7 +1681,11 @@ function createGenerateTypesCommand() {
1556
1681
  command.option(flags.join(", "), param.description);
1557
1682
  } else {
1558
1683
  const flagSignature = flags.join(", ") + ` <${param.type}>`;
1559
- command.option(flagSignature, param.description, param.default);
1684
+ command.option(
1685
+ flagSignature,
1686
+ param.description || "",
1687
+ param.default
1688
+ );
1560
1689
  }
1561
1690
  }
1562
1691
  });
@@ -1570,23 +1699,33 @@ function createGenerateTypesCommand() {
1570
1699
  args.slice(0, -1),
1571
1700
  options
1572
1701
  );
1573
- const sdk2 = createZapierSdk();
1702
+ const sdk2 = createZapierSdk({
1703
+ manifestPath: rawParams.lockFilePath
1704
+ });
1574
1705
  const resolver = new SchemaParameterResolver();
1575
1706
  const resolvedParams = await resolver.resolveParameters(
1576
1707
  GenerateTypesSchema,
1577
1708
  rawParams,
1578
1709
  sdk2
1579
1710
  );
1711
+ const params = resolvedParams;
1580
1712
  console.log(
1581
1713
  chalk5.blue(
1582
- `\u{1F527} Generating TypeScript types for ${resolvedParams.appKey}...`
1714
+ `\u{1F527} Generating TypeScript types for ${params.appKey}...`
1583
1715
  )
1584
1716
  );
1585
- const result = await generateTypes({ ...resolvedParams, sdk: sdk2 });
1717
+ const generateTypesParams = {
1718
+ appKey: params.appKey,
1719
+ debug: params.debug ?? false,
1720
+ authenticationId: params.authenticationId,
1721
+ output: params.output,
1722
+ sdk: sdk2
1723
+ };
1724
+ const result = await generateTypes(generateTypesParams);
1586
1725
  if (options.json) {
1587
1726
  console.log(JSON.stringify({ result }, null, 2));
1588
1727
  } else {
1589
- const output = resolvedParams.output || `./types/${resolvedParams.appKey}.d.ts`;
1728
+ const output = params.output || `./types/${params.appKey}.d.ts`;
1590
1729
  console.log(chalk5.green("\u2705 TypeScript types generated successfully!"));
1591
1730
  console.log(chalk5.gray(`Output written to: ${output}`));
1592
1731
  }
@@ -1717,7 +1856,11 @@ function createBundleCodeCommand() {
1717
1856
  command.option(flags.join(", "), param.description);
1718
1857
  } else {
1719
1858
  const flagSignature = flags.join(", ") + ` <${param.type}>`;
1720
- command.option(flagSignature, param.description, param.default);
1859
+ command.option(
1860
+ flagSignature,
1861
+ param.description || "",
1862
+ param.default
1863
+ );
1721
1864
  }
1722
1865
  }
1723
1866
  });
@@ -1735,7 +1878,9 @@ function createBundleCodeCommand() {
1735
1878
  throw new Error("Input file path is required");
1736
1879
  }
1737
1880
  console.log(chalk6.blue(`\u{1F4E6} Bundling ${rawParams.input}...`));
1738
- const result = await bundleCode(rawParams);
1881
+ const result = await bundleCode(
1882
+ rawParams
1883
+ );
1739
1884
  if (options.json) {
1740
1885
  console.log(JSON.stringify({ result }, null, 2));
1741
1886
  } else if (rawParams.output && !rawParams.string) {
@@ -1770,7 +1915,7 @@ function createMcpCommand() {
1770
1915
 
1771
1916
  // src/cli.ts
1772
1917
  var program = new Command7();
1773
- program.name("zapier-sdk").description("CLI for Zapier SDK - Commands auto-generated from SDK schemas").version("1.0.0").option("--debug", "Enable debug logging");
1918
+ program.name("zapier-sdk").description("CLI for Zapier SDK").version("1.0.0").option("--debug", "Enable debug logging");
1774
1919
  var isDebugMode = process.env.DEBUG === "true" || process.argv.includes("--debug");
1775
1920
  var sdk = createZapierSdk2({
1776
1921
  debug: isDebugMode
package/dist/src/cli.js CHANGED
@@ -6,7 +6,7 @@ import { createLoginCommand, createLogoutCommand, createConfigPathCommand, creat
6
6
  const program = new Command();
7
7
  program
8
8
  .name("zapier-sdk")
9
- .description("CLI for Zapier SDK - Commands auto-generated from SDK schemas")
9
+ .description("CLI for Zapier SDK")
10
10
  .version("1.0.0")
11
11
  .option("--debug", "Enable debug logging");
12
12
  // Check for debug flag early
@@ -32,7 +32,7 @@ export function createBundleCodeCommand() {
32
32
  }
33
33
  else {
34
34
  const flagSignature = flags.join(", ") + ` <${param.type}>`;
35
- command.option(flagSignature, param.description, param.default);
35
+ command.option(flagSignature, param.description || "", param.default);
36
36
  }
37
37
  }
38
38
  });
@@ -34,7 +34,7 @@ export function createGenerateTypesCommand() {
34
34
  }
35
35
  else {
36
36
  const flagSignature = flags.join(", ") + ` <${param.type}>`;
37
- command.option(flagSignature, param.description, param.default);
37
+ command.option(flagSignature, param.description || "", param.default);
38
38
  }
39
39
  }
40
40
  });
@@ -47,19 +47,30 @@ export function createGenerateTypesCommand() {
47
47
  const options = commandObj.opts();
48
48
  // Convert CLI args to SDK method parameters
49
49
  const rawParams = convertCliArgsToSdkParams(parameters, args.slice(0, -1), options);
50
- // Create SDK instance
51
- const sdk = createZapierSdk();
50
+ // Create SDK instance with manifest path if provided
51
+ const sdk = createZapierSdk({
52
+ manifestPath: rawParams.lockFilePath,
53
+ });
52
54
  // Resolve missing parameters interactively using schema metadata
53
55
  const resolver = new SchemaParameterResolver();
54
56
  const resolvedParams = await resolver.resolveParameters(GenerateTypesSchema, rawParams, sdk);
55
- console.log(chalk.blue(`🔧 Generating TypeScript types for ${resolvedParams.appKey}...`));
57
+ const params = resolvedParams;
58
+ console.log(chalk.blue(`🔧 Generating TypeScript types for ${params.appKey}...`));
56
59
  // Call our implementation
57
- const result = await generateTypes({ ...resolvedParams, sdk });
60
+ const generateTypesParams = {
61
+ appKey: params.appKey,
62
+ debug: params.debug ?? false,
63
+ authenticationId: params.authenticationId,
64
+ output: params.output,
65
+ sdk,
66
+ };
67
+ const result = await generateTypes(generateTypesParams);
58
68
  if (options.json) {
59
69
  console.log(JSON.stringify({ result }, null, 2));
60
70
  }
61
71
  else {
62
- const output = resolvedParams.output || `./types/${resolvedParams.appKey}.d.ts`;
72
+ const output = params.output ||
73
+ `./types/${params.appKey}.d.ts`;
63
74
  console.log(chalk.green("✅ TypeScript types generated successfully!"));
64
75
  console.log(chalk.gray(`Output written to: ${output}`));
65
76
  }
@@ -32,25 +32,46 @@ export async function generateTypes(options) {
32
32
  if (authenticationId) {
33
33
  for (const action of actions) {
34
34
  try {
35
+ // Check to see if the appKey is in the manifest
36
+ const manifestEntry = sdk.getContext().getManifestEntry(appKey);
35
37
  const fieldsResult = await sdk.listInputFields({
36
- appKey: action.app_key,
38
+ // If the appKey is in the manifest, use the appKey so that the types are consistent with the manifest's version, otherwise use the action.app_key
39
+ appKey: manifestEntry ? appKey : action.app_key,
37
40
  actionKey: action.key,
38
41
  actionType: action.action_type,
39
42
  authenticationId: authenticationId,
40
43
  });
41
- const fields = fieldsResult.data; // Direct array result
42
- actionsWithFields.push({ ...action, inputFields: fields });
44
+ const fields = fieldsResult.data.map((field) => {
45
+ const fieldObj = field;
46
+ return {
47
+ ...fieldObj,
48
+ required: fieldObj.is_required || fieldObj.required || false,
49
+ };
50
+ });
51
+ actionsWithFields.push({
52
+ ...action,
53
+ inputFields: fields,
54
+ name: action.title || action.key,
55
+ });
43
56
  }
44
57
  catch {
45
58
  // If we can't get fields for an action, include it without fields
46
- actionsWithFields.push({ ...action, inputFields: [] });
59
+ actionsWithFields.push({
60
+ ...action,
61
+ inputFields: [],
62
+ name: action.title || action.key,
63
+ });
47
64
  }
48
65
  }
49
66
  }
50
67
  else {
51
68
  // Convert actions to have empty input fields (will generate generic types)
52
69
  actions.forEach((action) => {
53
- actionsWithFields.push({ ...action, inputFields: [] });
70
+ actionsWithFields.push({
71
+ ...action,
72
+ inputFields: [],
73
+ name: action.title || action.key,
74
+ });
54
75
  });
55
76
  }
56
77
  // Generate TypeScript types
@@ -4,15 +4,18 @@ export declare const GenerateTypesSchema: z.ZodObject<{
4
4
  authenticationId: z.ZodOptional<z.ZodNumber>;
5
5
  output: z.ZodOptional<z.ZodString>;
6
6
  debug: z.ZodDefault<z.ZodBoolean>;
7
+ lockFilePath: z.ZodOptional<z.ZodString>;
7
8
  }, "strip", z.ZodTypeAny, {
8
9
  appKey: string;
9
10
  debug: boolean;
10
11
  authenticationId?: number | undefined;
11
12
  output?: string | undefined;
13
+ lockFilePath?: string | undefined;
12
14
  }, {
13
15
  appKey: string;
14
16
  authenticationId?: number | undefined;
15
17
  output?: string | undefined;
16
18
  debug?: boolean | undefined;
19
+ lockFilePath?: string | undefined;
17
20
  }>;
18
21
  export type GenerateTypesOptions = z.infer<typeof GenerateTypesSchema>;
@@ -7,5 +7,9 @@ export const GenerateTypesSchema = z
7
7
  authenticationId: AuthenticationIdPropertySchema.optional(),
8
8
  output: OutputPropertySchema.optional().describe("Output file path (defaults to generated/<appKey>.ts)"),
9
9
  debug: DebugPropertySchema.describe("Enable debug logging during generation"),
10
+ lockFilePath: z
11
+ .string()
12
+ .optional()
13
+ .describe("Path to the .zapierrc lock file (defaults to .zapierrc)"),
10
14
  })
11
15
  .describe("Generate TypeScript SDK code for a specific app");
@@ -1,14 +1,14 @@
1
- export interface ApiResponse<T = any> {
1
+ export interface ApiResponse<T = unknown> {
2
2
  data: T;
3
3
  status: number;
4
4
  }
5
5
  export declare const createApiClient: () => {
6
- post: <T = any>(url: string, data: any, options?: {
6
+ post: <T = unknown>(url: string, data: Record<string, string>, options?: {
7
7
  headers?: Record<string, string>;
8
8
  }) => Promise<ApiResponse<T>>;
9
9
  };
10
10
  declare const api: {
11
- post: <T = any>(url: string, data: any, options?: {
11
+ post: <T = unknown>(url: string, data: Record<string, string>, options?: {
12
12
  headers?: Record<string, string>;
13
13
  }) => Promise<ApiResponse<T>>;
14
14
  };
@@ -4,10 +4,10 @@ export interface CliParameter {
4
4
  type: "string" | "number" | "boolean" | "array";
5
5
  required: boolean;
6
6
  description?: string;
7
- default?: any;
7
+ default?: unknown;
8
8
  choices?: string[];
9
9
  hasResolver?: boolean;
10
10
  isPositional?: boolean;
11
11
  }
12
12
  export declare function analyzeZodSchema(schema: z.ZodSchema): CliParameter[];
13
- export declare function convertCliArgsToSdkParams(parameters: CliParameter[], positionalArgs: any[], options: Record<string, any>): Record<string, any>;
13
+ export declare function convertCliArgsToSdkParams(parameters: CliParameter[], positionalArgs: unknown[], options: Record<string, unknown>): Record<string, unknown>;