@zapier/zapier-sdk-cli 0.9.0 → 0.10.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.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from 'commander';
3
3
  import { z } from 'zod';
4
- import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, createZapierSdkWithoutRegistry, registryPlugin, ZapierError, formatErrorMessage, isPositional, hasResolver, getResolutionOrderForParams, getResolver } from '@zapier/zapier-sdk';
4
+ import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, createZapierSdkWithoutRegistry, registryPlugin, ZapierError, formatErrorMessage, isPositional } from '@zapier/zapier-sdk';
5
5
  import inquirer from 'inquirer';
6
6
  import chalk3 from 'chalk';
7
7
  import util from 'util';
@@ -19,12 +19,45 @@ import { resolve, join } from 'path';
19
19
  import * as ts from 'typescript';
20
20
  import { mkdir, writeFile, access } from 'fs/promises';
21
21
 
22
+ function getLocalResolutionOrder(paramName, resolvers, resolved = /* @__PURE__ */ new Set()) {
23
+ const resolver = resolvers[paramName];
24
+ if (!resolver || resolver.type === "static") {
25
+ return [paramName];
26
+ }
27
+ const order = [];
28
+ if ("depends" in resolver && resolver.depends) {
29
+ for (const dependency of resolver.depends) {
30
+ if (!resolved.has(dependency)) {
31
+ order.push(...getLocalResolutionOrder(dependency, resolvers, resolved));
32
+ resolved.add(dependency);
33
+ }
34
+ }
35
+ }
36
+ if (!resolved.has(paramName)) {
37
+ order.push(paramName);
38
+ resolved.add(paramName);
39
+ }
40
+ return order;
41
+ }
42
+ function getLocalResolutionOrderForParams(paramNames, resolvers) {
43
+ const resolved = /* @__PURE__ */ new Set();
44
+ const order = [];
45
+ for (const paramName of paramNames) {
46
+ const paramOrder = getLocalResolutionOrder(paramName, resolvers, resolved);
47
+ for (const param of paramOrder) {
48
+ if (!order.includes(param)) {
49
+ order.push(param);
50
+ }
51
+ }
52
+ }
53
+ return order;
54
+ }
22
55
  var SchemaParameterResolver = class {
23
- async resolveParameters(schema, providedParams, sdk2) {
56
+ async resolveParameters(schema, providedParams, sdk2, functionName) {
24
57
  const parseResult = schema.safeParse(providedParams);
25
58
  const allParams = this.extractParametersFromSchema(schema);
26
59
  const resolvableParams = allParams.filter(
27
- (param) => hasResolver(param.name)
60
+ (param) => this.hasResolver(param.name, sdk2, functionName)
28
61
  );
29
62
  const missingResolvable = resolvableParams.filter((param) => {
30
63
  const hasValue = this.getNestedValue(providedParams, param.path) !== void 0;
@@ -60,11 +93,16 @@ var SchemaParameterResolver = class {
60
93
  const context = {
61
94
  sdk: sdk2,
62
95
  currentParams: providedParams,
63
- resolvedParams
96
+ resolvedParams,
97
+ functionName
64
98
  };
99
+ const localResolvers = this.getLocalResolvers(sdk2, functionName);
65
100
  if (functionallyRequired.length > 0) {
66
101
  const requiredParamNames = functionallyRequired.map((p) => p.name);
67
- const requiredResolutionOrder = getResolutionOrderForParams(requiredParamNames);
102
+ const requiredResolutionOrder = getLocalResolutionOrderForParams(
103
+ requiredParamNames,
104
+ localResolvers
105
+ );
68
106
  const orderedRequiredParams = requiredResolutionOrder.map((paramName) => {
69
107
  let param = functionallyRequired.find((p) => p.name === paramName);
70
108
  if (!param) {
@@ -77,7 +115,11 @@ var SchemaParameterResolver = class {
77
115
  }).filter((param) => param !== void 0);
78
116
  for (const param of orderedRequiredParams) {
79
117
  try {
80
- const value = await this.resolveParameter(param, context);
118
+ const value = await this.resolveParameter(
119
+ param,
120
+ context,
121
+ functionName
122
+ );
81
123
  this.setNestedValue(resolvedParams, param.path, value);
82
124
  context.resolvedParams = resolvedParams;
83
125
  } catch (error) {
@@ -104,11 +146,18 @@ var SchemaParameterResolver = class {
104
146
  }
105
147
  if (alwaysPrompt.length > 0) {
106
148
  const alwaysPromptNames = alwaysPrompt.map((p) => p.name);
107
- const alwaysPromptResolutionOrder = getResolutionOrderForParams(alwaysPromptNames);
149
+ const alwaysPromptResolutionOrder = getLocalResolutionOrderForParams(
150
+ alwaysPromptNames,
151
+ localResolvers
152
+ );
108
153
  const orderedAlwaysPromptParams = alwaysPromptResolutionOrder.map((paramName) => alwaysPrompt.find((p) => p.name === paramName)).filter((param) => param !== void 0);
109
154
  for (const param of orderedAlwaysPromptParams) {
110
155
  try {
111
- const value = await this.resolveParameter(param, context);
156
+ const value = await this.resolveParameter(
157
+ param,
158
+ context,
159
+ functionName
160
+ );
112
161
  this.setNestedValue(resolvedParams, param.path, value);
113
162
  context.resolvedParams = resolvedParams;
114
163
  } catch (error) {
@@ -132,11 +181,18 @@ var SchemaParameterResolver = class {
132
181
  ]);
133
182
  if (shouldResolveOptional.resolveOptional) {
134
183
  const optionalParamNames = trulyOptional.map((p) => p.name);
135
- const optionalResolutionOrder = getResolutionOrderForParams(optionalParamNames);
184
+ const optionalResolutionOrder = getLocalResolutionOrderForParams(
185
+ optionalParamNames,
186
+ localResolvers
187
+ );
136
188
  const orderedOptionalParams = optionalResolutionOrder.map((paramName) => trulyOptional.find((p) => p.name === paramName)).filter((param) => param !== void 0);
137
189
  for (const param of orderedOptionalParams) {
138
190
  try {
139
- const value = await this.resolveParameter(param, context);
191
+ const value = await this.resolveParameter(
192
+ param,
193
+ context,
194
+ functionName
195
+ );
140
196
  this.setNestedValue(resolvedParams, param.path, value);
141
197
  context.resolvedParams = resolvedParams;
142
198
  } catch (error) {
@@ -195,8 +251,8 @@ var SchemaParameterResolver = class {
195
251
  isRequired
196
252
  };
197
253
  }
198
- async resolveParameter(param, context) {
199
- const resolver = getResolver(param.name);
254
+ async resolveParameter(param, context, functionName) {
255
+ const resolver = this.getResolver(param.name, context.sdk, functionName);
200
256
  if (!resolver) {
201
257
  throw new Error(`No resolver found for parameter: ${param.name}`);
202
258
  }
@@ -281,10 +337,10 @@ var SchemaParameterResolver = class {
281
337
  break;
282
338
  }
283
339
  const newRequiredFields = newFields.filter(
284
- (field) => field.required
340
+ (field) => field.is_required
285
341
  );
286
342
  const newOptionalFields = newFields.filter(
287
- (field) => !field.required
343
+ (field) => !field.is_required
288
344
  );
289
345
  if (newRequiredFields.length > 0) {
290
346
  console.log(
@@ -371,7 +427,7 @@ Optional fields:`));
371
427
  const fieldPrompt = {
372
428
  type: fieldObj.type === "boolean" ? "confirm" : "input",
373
429
  name: fieldObj.key,
374
- message: `${fieldObj.label || fieldObj.key}${fieldObj.required ? " (required)" : " (optional)"}:`
430
+ message: `${fieldObj.label || fieldObj.key}${fieldObj.is_required ? " (required)" : " (optional)"}:`
375
431
  };
376
432
  if (fieldObj.helpText) {
377
433
  fieldPrompt.prefix = chalk3.gray(`\u2139 ${fieldObj.helpText}
@@ -396,7 +452,7 @@ Optional fields:`));
396
452
  const answer = await inquirer.prompt([fieldPrompt]);
397
453
  if (answer[fieldObj.key] !== void 0 && answer[fieldObj.key] !== "") {
398
454
  inputs[fieldObj.key] = answer[fieldObj.key];
399
- } else if (fieldObj.required) {
455
+ } else if (fieldObj.is_required) {
400
456
  throw new Error(`Required field ${fieldObj.key} cannot be empty`);
401
457
  }
402
458
  } catch (error) {
@@ -411,6 +467,40 @@ Optional fields:`));
411
467
  const errorObj = error;
412
468
  return errorObj?.name === "ExitPromptError" || errorObj?.message?.includes("User force closed") || errorObj?.isTTYError === true;
413
469
  }
470
+ hasResolver(paramName, sdk2, functionName) {
471
+ if (functionName && typeof sdk2.getRegistry === "function") {
472
+ const registry = sdk2.getRegistry();
473
+ const functionInfo = registry.functions.find(
474
+ (f) => f.name === functionName
475
+ );
476
+ if (functionInfo && functionInfo.resolvers?.[paramName]) {
477
+ return true;
478
+ }
479
+ }
480
+ return false;
481
+ }
482
+ getResolver(paramName, sdk2, functionName) {
483
+ if (functionName && typeof sdk2.getRegistry === "function") {
484
+ const registry = sdk2.getRegistry();
485
+ const functionInfo = registry.functions.find(
486
+ (f) => f.name === functionName
487
+ );
488
+ if (functionInfo && functionInfo.resolvers?.[paramName]) {
489
+ return functionInfo.resolvers[paramName];
490
+ }
491
+ }
492
+ return null;
493
+ }
494
+ getLocalResolvers(sdk2, functionName) {
495
+ if (!functionName || typeof sdk2.getRegistry !== "function") {
496
+ return {};
497
+ }
498
+ const registry = sdk2.getRegistry();
499
+ const functionInfo = registry.functions.find(
500
+ (f) => f.name === functionName
501
+ );
502
+ return functionInfo?.resolvers || {};
503
+ }
414
504
  };
415
505
  function getFormatMetadata(schema) {
416
506
  return schema?._def?.formatMeta;
@@ -418,8 +508,16 @@ function getFormatMetadata(schema) {
418
508
  function getOutputSchema(schema) {
419
509
  return schema?._def?.outputSchema;
420
510
  }
421
- function formatItemsFromSchema(inputSchema, items, startingNumber = 0) {
422
- const outputSchema = getOutputSchema(inputSchema);
511
+ function formatJsonOutput(data) {
512
+ if (data === void 0) {
513
+ return;
514
+ }
515
+ console.log(
516
+ util.inspect(data, { colors: true, depth: null, breakLength: 80 })
517
+ );
518
+ }
519
+ function formatItemsFromSchema(functionInfo, items, startingNumber = 0) {
520
+ const outputSchema = functionInfo.outputSchema || getOutputSchema(functionInfo.inputSchema);
423
521
  if (!outputSchema) {
424
522
  formatItemsGeneric(items, startingNumber);
425
523
  return;
@@ -430,16 +528,26 @@ function formatItemsFromSchema(inputSchema, items, startingNumber = 0) {
430
528
  return;
431
529
  }
432
530
  items.forEach((item, index) => {
433
- formatSingleItem(item, startingNumber + index, formatMeta);
531
+ const formatted = formatMeta.format(item);
532
+ formatSingleItem(formatted, startingNumber + index);
434
533
  });
435
534
  }
436
- function formatSingleItem(item, itemNumber, formatMeta) {
437
- const formatted = formatMeta.format(item);
535
+ function formatSingleItem(formatted, itemNumber) {
438
536
  let titleLine = `${chalk3.gray(`${itemNumber + 1}.`)} ${chalk3.cyan(formatted.title)}`;
439
- if (formatted.subtitle) {
440
- titleLine += ` ${chalk3.gray(formatted.subtitle)}`;
537
+ if (formatted.id) {
538
+ titleLine += ` ${chalk3.gray(`(ID: ${formatted.id})`)}`;
539
+ } else if (formatted.key) {
540
+ titleLine += ` ${chalk3.gray(`(${formatted.key})`)}`;
441
541
  }
442
542
  console.log(titleLine);
543
+ if (formatted.description) {
544
+ console.log(` ${chalk3.dim(formatted.description)}`);
545
+ }
546
+ if (formatted.data !== void 0) {
547
+ formatJsonOutput(formatted.data);
548
+ console.log();
549
+ return;
550
+ }
443
551
  for (const detail of formatted.details) {
444
552
  const styledText = applyStyle(detail.text, detail.style);
445
553
  console.log(` ${styledText}`);
@@ -461,40 +569,36 @@ function applyStyle(value, style) {
461
569
  return chalk3.blue(value);
462
570
  }
463
571
  }
572
+ function convertGenericItemToFormattedItem(item) {
573
+ const itemObj = item;
574
+ return {
575
+ title: itemObj.title || itemObj.name || itemObj.key || itemObj.id || "Item",
576
+ id: itemObj.id,
577
+ key: itemObj.key,
578
+ description: itemObj.description,
579
+ details: []
580
+ };
581
+ }
464
582
  function formatItemsGeneric(items, startingNumber = 0) {
465
583
  items.forEach((item, index) => {
466
- const itemObj = item;
467
- const name = itemObj.title || itemObj.name || itemObj.key || itemObj.id || "Item";
468
- console.log(
469
- `${chalk3.gray(`${startingNumber + index + 1}.`)} ${chalk3.cyan(name)}`
470
- );
471
- if (itemObj.description) {
472
- console.log(` ${chalk3.dim(itemObj.description)}`);
473
- }
474
- console.log();
584
+ const formatted = convertGenericItemToFormattedItem(item);
585
+ formatSingleItem(formatted, startingNumber + index);
475
586
  });
476
587
  }
477
- function formatJsonOutput(data) {
478
- if (data === void 0) {
479
- return;
480
- }
481
- if (data && typeof data === "object" && !Array.isArray(data) && (data.success !== void 0 || data.id || data.status)) {
482
- console.log(chalk3.green("\u2705 Action completed successfully!\n"));
483
- }
484
- console.log(
485
- util.inspect(data, { colors: true, depth: null, breakLength: 80 })
486
- );
487
- }
488
- function analyzeZodSchema(schema) {
588
+ function analyzeZodSchema(schema, functionInfo) {
489
589
  const parameters = [];
490
590
  if (schema._def && schema._def.typeName === "ZodEffects") {
491
591
  const innerSchema = schema._def.schema;
492
- return analyzeZodSchema(innerSchema);
592
+ return analyzeZodSchema(innerSchema, functionInfo);
493
593
  }
494
594
  if (schema instanceof z.ZodObject) {
495
595
  const shape = schema.shape;
496
596
  for (const [key, fieldSchema] of Object.entries(shape)) {
497
- const param = analyzeZodField(key, fieldSchema);
597
+ const param = analyzeZodField(
598
+ key,
599
+ fieldSchema,
600
+ functionInfo
601
+ );
498
602
  if (param) {
499
603
  parameters.push(param);
500
604
  }
@@ -502,7 +606,7 @@ function analyzeZodSchema(schema) {
502
606
  }
503
607
  return parameters;
504
608
  }
505
- function analyzeZodField(name, schema) {
609
+ function analyzeZodField(name, schema, functionInfo) {
506
610
  let baseSchema = schema;
507
611
  let required = true;
508
612
  let defaultValue = void 0;
@@ -536,6 +640,10 @@ function analyzeZodField(name, schema) {
536
640
  } else if (baseSchema instanceof z.ZodRecord) {
537
641
  paramType = "string";
538
642
  }
643
+ let paramHasResolver = false;
644
+ if (functionInfo?.resolvers?.[name]) {
645
+ paramHasResolver = true;
646
+ }
539
647
  return {
540
648
  name,
541
649
  type: paramType,
@@ -543,7 +651,7 @@ function analyzeZodField(name, schema) {
543
651
  description: schema.description,
544
652
  default: defaultValue,
545
653
  choices,
546
- hasResolver: hasResolver(name),
654
+ hasResolver: paramHasResolver,
547
655
  isPositional: isPositional(schema)
548
656
  };
549
657
  }
@@ -565,12 +673,7 @@ function generateCliCommands(program2, sdk2) {
565
673
  return;
566
674
  }
567
675
  const cliCommandName = methodNameToCliCommand(fnInfo.name);
568
- const config = createCommandConfig(
569
- cliCommandName,
570
- fnInfo.name,
571
- fnInfo.inputSchema,
572
- sdk2
573
- );
676
+ const config = createCommandConfig(cliCommandName, fnInfo, sdk2);
574
677
  addCommand(program2, cliCommandName, config);
575
678
  });
576
679
  program2.configureHelp({
@@ -634,14 +737,15 @@ function generateCliCommands(program2, sdk2) {
634
737
  }
635
738
  });
636
739
  }
637
- function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk2) {
638
- const parameters = analyzeZodSchema(schema);
740
+ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
741
+ const schema = functionInfo.inputSchema;
742
+ const parameters = analyzeZodSchema(schema, functionInfo);
639
743
  const description = schema.description || `${cliCommandName} command`;
640
744
  const handler = async (...args) => {
641
745
  try {
642
746
  const commandObj = args[args.length - 1];
643
747
  const options = commandObj.opts();
644
- const isListCommand = cliCommandName.startsWith("list-");
748
+ const isListCommand = functionInfo.type === "list";
645
749
  const hasPaginationParams = parameters.some(
646
750
  (p) => p.name === "maxItems" || p.name === "pageSize"
647
751
  );
@@ -656,21 +760,22 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk2) {
656
760
  const resolvedParams = await resolver.resolveParameters(
657
761
  schema,
658
762
  rawParams,
659
- sdk2
763
+ sdk2,
764
+ functionInfo.name
660
765
  );
661
766
  if (isListCommand && hasPaginationParams && !shouldUseJson && !hasUserSpecifiedMaxItems) {
662
767
  const sdkObj = sdk2;
663
- const sdkIterator = sdkObj[sdkMethodName](resolvedParams);
768
+ const sdkIterator = sdkObj[functionInfo.name](resolvedParams);
664
769
  await handlePaginatedListWithAsyncIteration(
665
- sdkMethodName,
770
+ functionInfo.name,
666
771
  sdkIterator,
667
- schema
772
+ functionInfo
668
773
  );
669
774
  } else {
670
775
  const hasOutputFile = resolvedParams.output;
671
776
  if (hasOutputFile) {
672
777
  const sdkObj2 = sdk2;
673
- await sdkObj2[sdkMethodName](resolvedParams);
778
+ await sdkObj2[functionInfo.name](resolvedParams);
674
779
  console.log(
675
780
  chalk3.green(`\u2705 ${cliCommandName} completed successfully!`)
676
781
  );
@@ -678,7 +783,7 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk2) {
678
783
  return;
679
784
  }
680
785
  const sdkObj = sdk2;
681
- const result = await sdkObj[sdkMethodName](resolvedParams);
786
+ const result = await sdkObj[functionInfo.name](resolvedParams);
682
787
  const items = result?.data ? result.data : result;
683
788
  if (shouldUseJson) {
684
789
  console.log(JSON.stringify(items, null, 2));
@@ -688,8 +793,7 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk2) {
688
793
  resolvedParams.maxItems,
689
794
  hasUserSpecifiedMaxItems,
690
795
  shouldUseJson,
691
- schema,
692
- sdkMethodName
796
+ functionInfo
693
797
  );
694
798
  } else {
695
799
  formatJsonOutput(items);
@@ -810,6 +914,9 @@ function convertCliArgsToSdkParams(parameters, positionalArgs, options) {
810
914
  return sdkParams;
811
915
  }
812
916
  function convertValue(value, type) {
917
+ if (value === void 0) {
918
+ return void 0;
919
+ }
813
920
  switch (type) {
814
921
  case "number":
815
922
  return Number(value);
@@ -829,12 +936,14 @@ function convertValue(value, type) {
829
936
  return value;
830
937
  }
831
938
  }
832
- async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, schema) {
833
- const itemName = getItemNameFromMethod(sdkMethodName);
939
+ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, functionInfo) {
940
+ const itemName = getItemNameFromMethod(functionInfo);
834
941
  let totalShown = 0;
835
942
  let pageCount = 0;
836
- console.log(chalk3.blue(`\u{1F4CB} ${getListTitleFromMethod(sdkMethodName)}
837
- `));
943
+ console.log(
944
+ chalk3.blue(`\u{1F4CB} ${getListTitleFromMethod(sdkMethodName, functionInfo)}
945
+ `)
946
+ );
838
947
  try {
839
948
  for await (const page of sdkResult) {
840
949
  const items = page.data || page;
@@ -853,12 +962,14 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
853
962
  if (pageCount > 1) {
854
963
  console.clear();
855
964
  console.log(
856
- chalk3.blue(`\u{1F4CB} ${getListTitleFromMethod(sdkMethodName)}
857
- `)
965
+ chalk3.blue(
966
+ `\u{1F4CB} ${getListTitleFromMethod(sdkMethodName, functionInfo)}
967
+ `
968
+ )
858
969
  );
859
970
  }
860
- if (schema) {
861
- formatItemsFromSchema(schema, items, totalShown);
971
+ if (functionInfo) {
972
+ formatItemsFromSchema(functionInfo, items, totalShown);
862
973
  } else {
863
974
  formatItemsGeneric2(items, totalShown);
864
975
  }
@@ -894,8 +1005,8 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
894
1005
  console.log(chalk3.yellow(`No ${itemName} found.`));
895
1006
  return;
896
1007
  }
897
- if (schema) {
898
- formatItemsFromSchema(schema, items, 0);
1008
+ if (functionInfo) {
1009
+ formatItemsFromSchema(functionInfo, items, 0);
899
1010
  } else {
900
1011
  formatItemsGeneric2(items, 0);
901
1012
  }
@@ -906,7 +1017,7 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
906
1017
  }
907
1018
  }
908
1019
  }
909
- function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxItems, useRawJson, schema, methodName) {
1020
+ function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxItems, useRawJson, functionInfo) {
910
1021
  if (!Array.isArray(result)) {
911
1022
  if (useRawJson) {
912
1023
  console.log(JSON.stringify(result, null, 2));
@@ -919,7 +1030,7 @@ function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxIt
919
1030
  console.log(JSON.stringify(result, null, 2));
920
1031
  return;
921
1032
  }
922
- const itemName = methodName ? getItemNameFromMethod(methodName) : "items";
1033
+ const itemName = functionInfo ? getItemNameFromMethod(functionInfo) : "items";
923
1034
  if (result.length === 0) {
924
1035
  console.log(chalk3.yellow(`No ${itemName} found.`));
925
1036
  return;
@@ -927,8 +1038,8 @@ function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxIt
927
1038
  console.log(chalk3.green(`
928
1039
  \u2705 Found ${result.length} ${itemName}:
929
1040
  `));
930
- if (schema) {
931
- formatItemsFromSchema(schema, result);
1041
+ if (functionInfo) {
1042
+ formatItemsFromSchema(functionInfo, result);
932
1043
  } else {
933
1044
  formatItemsGeneric2(result);
934
1045
  }
@@ -957,18 +1068,17 @@ function formatItemsGeneric2(items, startingNumber = 0) {
957
1068
  console.log();
958
1069
  });
959
1070
  }
960
- function getItemNameFromMethod(methodName) {
961
- const listMatch = methodName.match(/^list(.+)$/);
962
- if (listMatch) {
963
- return listMatch[1].toLowerCase();
1071
+ function getItemNameFromMethod(functionInfo) {
1072
+ if (functionInfo.itemType) {
1073
+ return `${functionInfo.itemType} items`;
964
1074
  }
965
1075
  return "items";
966
1076
  }
967
- function getListTitleFromMethod(methodName) {
968
- const itemName = getItemNameFromMethod(methodName);
969
- if (itemName === "items") return "Available Items";
970
- const capitalized = itemName.charAt(0).toUpperCase() + itemName.slice(1);
971
- return `Available ${capitalized}`;
1077
+ function getListTitleFromMethod(methodName, functionInfo) {
1078
+ if (functionInfo.itemType) {
1079
+ return `Available ${functionInfo.itemType} items`;
1080
+ }
1081
+ return `${methodName} items`;
972
1082
  }
973
1083
 
974
1084
  // src/utils/constants.ts
@@ -1998,26 +2108,25 @@ var addPlugin = ({ sdk: sdk2, context }) => {
1998
2108
  console.log(`\u{1F510} Found ${authentications.length} authentication(s)`);
1999
2109
  }
2000
2110
  for (const app of apps) {
2001
- console.log(`\u{1F4E6} Adding ${app.key}...`);
2111
+ const appSlugAndKey = app.slug ? `${app.slug} (${app.key})` : app.key;
2112
+ console.log(`\u{1F4E6} Adding ${appSlugAndKey}...`);
2002
2113
  try {
2003
- const currentImplementationId = app.current_implementation_id;
2004
- const [implementationName, version] = currentImplementationId.split("@");
2005
- if (!implementationName || !version) {
2114
+ if (!app.version) {
2006
2115
  console.warn(
2007
- `\u26A0\uFE0F Invalid implementation ID format for '${app.key}': ${currentImplementationId}. Expected format: <implementationName>@<version>. Skipping...`
2116
+ `\u26A0\uFE0F Invalid implementation ID format for '${appSlugAndKey}': ${app.implementation_id}. Expected format: <implementationName>@<version>. Skipping...`
2008
2117
  );
2009
2118
  continue;
2010
2119
  }
2011
2120
  const [manifestKey] = await context.updateManifestEntry(
2012
2121
  app.key,
2013
2122
  {
2014
- implementationName,
2015
- version
2123
+ implementationName: app.key,
2124
+ version: app.version
2016
2125
  },
2017
2126
  configPath
2018
2127
  );
2019
2128
  console.log(
2020
- `\u{1F4DD} Locked ${app.key} to ${implementationName}@${version} using key '${manifestKey}'`
2129
+ `\u{1F4DD} Locked ${appSlugAndKey} to ${app.key}@${app.version} using key '${manifestKey}'`
2021
2130
  );
2022
2131
  let authenticationId;
2023
2132
  if (authentications.length > 0) {
@@ -2027,10 +2136,12 @@ var addPlugin = ({ sdk: sdk2, context }) => {
2027
2136
  if (matchingAuth) {
2028
2137
  authenticationId = matchingAuth.id;
2029
2138
  console.log(
2030
- `\u{1F510} Using authentication ${authenticationId} (${matchingAuth.title}) for ${app.key}`
2139
+ `\u{1F510} Using authentication ${authenticationId} (${matchingAuth.title}) for ${appSlugAndKey}`
2031
2140
  );
2032
2141
  } else {
2033
- console.warn(`\u26A0\uFE0F No matching authentication found for ${app.key}`);
2142
+ console.warn(
2143
+ `\u26A0\uFE0F No matching authentication found for ${appSlugAndKey}`
2144
+ );
2034
2145
  }
2035
2146
  }
2036
2147
  const typesPath = join(resolvedTypesOutput, `${manifestKey}.d.ts`);
@@ -2044,10 +2155,12 @@ var addPlugin = ({ sdk: sdk2, context }) => {
2044
2155
  await writeFile(typesPath, typeDefinitions, "utf8");
2045
2156
  console.log(`\u{1F527} Generated types for ${manifestKey} at ${typesPath}`);
2046
2157
  } catch (error) {
2047
- console.warn(`\u26A0\uFE0F Failed to generate types for ${app.key}: ${error}`);
2158
+ console.warn(
2159
+ `\u26A0\uFE0F Failed to generate types for ${appSlugAndKey}: ${error}`
2160
+ );
2048
2161
  }
2049
2162
  } catch (error) {
2050
- console.warn(`\u26A0\uFE0F Failed to process ${app.key}: ${error}`);
2163
+ console.warn(`\u26A0\uFE0F Failed to process ${appSlugAndKey}: ${error}`);
2051
2164
  }
2052
2165
  }
2053
2166
  console.log(`\u2705 Added ${apps.length} app(s) to manifest`);
@@ -2082,7 +2195,7 @@ function createZapierCliSdk(options = {}) {
2082
2195
 
2083
2196
  // package.json
2084
2197
  var package_default = {
2085
- version: "0.9.0"};
2198
+ version: "0.10.0"};
2086
2199
 
2087
2200
  // src/cli.ts
2088
2201
  var program = new Command();
package/dist/index.cjs CHANGED
@@ -1075,26 +1075,25 @@ var addPlugin = ({ sdk, context }) => {
1075
1075
  console.log(`\u{1F510} Found ${authentications.length} authentication(s)`);
1076
1076
  }
1077
1077
  for (const app of apps) {
1078
- console.log(`\u{1F4E6} Adding ${app.key}...`);
1078
+ const appSlugAndKey = app.slug ? `${app.slug} (${app.key})` : app.key;
1079
+ console.log(`\u{1F4E6} Adding ${appSlugAndKey}...`);
1079
1080
  try {
1080
- const currentImplementationId = app.current_implementation_id;
1081
- const [implementationName, version] = currentImplementationId.split("@");
1082
- if (!implementationName || !version) {
1081
+ if (!app.version) {
1083
1082
  console.warn(
1084
- `\u26A0\uFE0F Invalid implementation ID format for '${app.key}': ${currentImplementationId}. Expected format: <implementationName>@<version>. Skipping...`
1083
+ `\u26A0\uFE0F Invalid implementation ID format for '${appSlugAndKey}': ${app.implementation_id}. Expected format: <implementationName>@<version>. Skipping...`
1085
1084
  );
1086
1085
  continue;
1087
1086
  }
1088
1087
  const [manifestKey] = await context.updateManifestEntry(
1089
1088
  app.key,
1090
1089
  {
1091
- implementationName,
1092
- version
1090
+ implementationName: app.key,
1091
+ version: app.version
1093
1092
  },
1094
1093
  configPath
1095
1094
  );
1096
1095
  console.log(
1097
- `\u{1F4DD} Locked ${app.key} to ${implementationName}@${version} using key '${manifestKey}'`
1096
+ `\u{1F4DD} Locked ${appSlugAndKey} to ${app.key}@${app.version} using key '${manifestKey}'`
1098
1097
  );
1099
1098
  let authenticationId;
1100
1099
  if (authentications.length > 0) {
@@ -1104,10 +1103,12 @@ var addPlugin = ({ sdk, context }) => {
1104
1103
  if (matchingAuth) {
1105
1104
  authenticationId = matchingAuth.id;
1106
1105
  console.log(
1107
- `\u{1F510} Using authentication ${authenticationId} (${matchingAuth.title}) for ${app.key}`
1106
+ `\u{1F510} Using authentication ${authenticationId} (${matchingAuth.title}) for ${appSlugAndKey}`
1108
1107
  );
1109
1108
  } else {
1110
- console.warn(`\u26A0\uFE0F No matching authentication found for ${app.key}`);
1109
+ console.warn(
1110
+ `\u26A0\uFE0F No matching authentication found for ${appSlugAndKey}`
1111
+ );
1111
1112
  }
1112
1113
  }
1113
1114
  const typesPath = path.join(resolvedTypesOutput, `${manifestKey}.d.ts`);
@@ -1121,10 +1122,12 @@ var addPlugin = ({ sdk, context }) => {
1121
1122
  await promises.writeFile(typesPath, typeDefinitions, "utf8");
1122
1123
  console.log(`\u{1F527} Generated types for ${manifestKey} at ${typesPath}`);
1123
1124
  } catch (error) {
1124
- console.warn(`\u26A0\uFE0F Failed to generate types for ${app.key}: ${error}`);
1125
+ console.warn(
1126
+ `\u26A0\uFE0F Failed to generate types for ${appSlugAndKey}: ${error}`
1127
+ );
1125
1128
  }
1126
1129
  } catch (error) {
1127
- console.warn(`\u26A0\uFE0F Failed to process ${app.key}: ${error}`);
1130
+ console.warn(`\u26A0\uFE0F Failed to process ${appSlugAndKey}: ${error}`);
1128
1131
  }
1129
1132
  }
1130
1133
  console.log(`\u2705 Added ${apps.length} app(s) to manifest`);