@zapier/zapier-sdk-cli 0.38.2 → 0.39.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.cjs CHANGED
@@ -835,11 +835,11 @@ Optional fields${pathContext}:`));
835
835
  );
836
836
  this.startSpinner();
837
837
  const page = await context.sdk.listInputFieldChoices({
838
- appKey: context.resolvedParams.appKey,
839
- actionKey: context.resolvedParams.actionKey,
838
+ app: context.resolvedParams.app,
839
+ action: context.resolvedParams.action,
840
840
  actionType: context.resolvedParams.actionType,
841
- connectionId: context.resolvedParams.connectionId,
842
- inputFieldKey: fieldMeta.key,
841
+ connection: context.resolvedParams.connection,
842
+ inputField: fieldMeta.key,
843
843
  inputs,
844
844
  ...cursor && { cursor }
845
845
  });
@@ -1103,7 +1103,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
1103
1103
 
1104
1104
  // package.json
1105
1105
  var package_default = {
1106
- version: "0.38.2"};
1106
+ version: "0.39.0"};
1107
1107
 
1108
1108
  // src/telemetry/builders.ts
1109
1109
  function createCliBaseEvent(context = {}) {
@@ -1659,13 +1659,15 @@ function analyzeZodSchema(schema, functionInfo) {
1659
1659
  return parameters;
1660
1660
  }
1661
1661
  function analyzeZodField(name, schema, functionInfo) {
1662
- if (functionInfo?.deprecatedParameters?.includes(name)) {
1663
- return null;
1664
- }
1665
1662
  let baseSchema = schema;
1666
1663
  let required = true;
1667
1664
  let defaultValue = void 0;
1665
+ let isDeprecated = false;
1668
1666
  while (true) {
1667
+ const meta = baseSchema.meta?.();
1668
+ if (meta?.deprecated) {
1669
+ isDeprecated = true;
1670
+ }
1669
1671
  if (baseSchema instanceof zod.z.ZodOptional) {
1670
1672
  required = false;
1671
1673
  baseSchema = baseSchema._zod.def.innerType;
@@ -1721,7 +1723,8 @@ function analyzeZodField(name, schema, functionInfo) {
1721
1723
  choices,
1722
1724
  hasResolver: paramHasResolver,
1723
1725
  isPositional: zapierSdk.isPositional(schema),
1724
- elementType
1726
+ elementType,
1727
+ hidden: isDeprecated
1725
1728
  };
1726
1729
  }
1727
1730
  function analyzeInputParameters(inputParameters, functionInfo) {
@@ -1736,9 +1739,6 @@ function analyzeInputParameters(inputParameters, functionInfo) {
1736
1739
  if (schema instanceof zod.z.ZodObject) {
1737
1740
  const shape = schema.shape;
1738
1741
  for (const [key, fieldSchema] of Object.entries(shape)) {
1739
- if (functionInfo?.deprecatedParameters?.includes(key)) {
1740
- continue;
1741
- }
1742
1742
  const analyzed = analyzeZodField(
1743
1743
  key,
1744
1744
  fieldSchema,
@@ -1901,6 +1901,15 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
1901
1901
  args.slice(0, -1),
1902
1902
  options2
1903
1903
  );
1904
+ const schemaAliases = schema?.meta?.()?.aliases;
1905
+ if (schemaAliases) {
1906
+ for (const [oldName, newName] of Object.entries(schemaAliases)) {
1907
+ if (oldName in rawParams && !(newName in rawParams)) {
1908
+ rawParams[newName] = rawParams[oldName];
1909
+ delete rawParams[oldName];
1910
+ }
1911
+ }
1912
+ }
1904
1913
  if (schema && !usesInputParameters) {
1905
1914
  const resolver = new SchemaParameterResolver();
1906
1915
  resolvedParams = await resolver.resolveParameters(
@@ -2018,7 +2027,7 @@ ${confirmMessageAfter}`));
2018
2027
  cli_arguments: sanitizeCliArguments(process.argv.slice(2))
2019
2028
  },
2020
2029
  context: {
2021
- selected_api: resolvedParams.appKey ?? null
2030
+ selected_api: resolvedParams.app ?? null
2022
2031
  }
2023
2032
  });
2024
2033
  sdk2.getContext().eventEmission.emit(CLI_COMMAND_EXECUTED_EVENT_SUBJECT, event);
@@ -2082,17 +2091,26 @@ function addCommand(program2, commandName, config) {
2082
2091
  }
2083
2092
  flags.push(`--${kebabName}`);
2084
2093
  if (param.type === "boolean") {
2085
- command.option(flags.join(", "), param.description);
2094
+ const opt = new commander.Option(flags.join(", "), param.description);
2095
+ if (param.hidden) opt.hideHelp();
2096
+ command.addOption(opt);
2086
2097
  } else if (param.type === "array") {
2087
2098
  const flagSignature = flags.join(", ") + ` <value>`;
2088
- command.option(flagSignature, param.description || "", collect, []);
2099
+ const opt = new commander.Option(flagSignature, param.description || "");
2100
+ opt.default([]);
2101
+ opt.argParser(
2102
+ (value, previous) => (previous || []).concat([value])
2103
+ );
2104
+ if (param.hidden) opt.hideHelp();
2105
+ command.addOption(opt);
2089
2106
  } else {
2090
2107
  const flagSignature = flags.join(", ") + ` <${param.type}>`;
2091
- command.option(
2092
- flagSignature,
2093
- param.description || "",
2094
- param.default
2095
- );
2108
+ const opt = new commander.Option(flagSignature, param.description || "");
2109
+ if (param.default !== void 0) {
2110
+ opt.default(param.default);
2111
+ }
2112
+ if (param.hidden) opt.hideHelp();
2113
+ command.addOption(opt);
2096
2114
  }
2097
2115
  }
2098
2116
  });
@@ -2645,10 +2663,10 @@ var getLoginConfigPathPlugin = () => {
2645
2663
  };
2646
2664
  };
2647
2665
  var AddSchema = zod.z.object({
2648
- appKeys: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
2666
+ apps: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
2649
2667
  "One or more app keys to add (e.g., 'slack', 'github', 'trello')"
2650
2668
  ),
2651
- connectionIds: zod.z.array(zod.z.string()).optional().describe(
2669
+ connections: zod.z.array(zod.z.string()).optional().describe(
2652
2670
  "Connection IDs to use for type generation (e.g., ['123', '456'])"
2653
2671
  ),
2654
2672
  configPath: zod.z.string().optional().describe(
@@ -2674,8 +2692,8 @@ async function detectTypesOutputDirectory() {
2674
2692
  var addPlugin = ({ sdk: sdk2 }) => {
2675
2693
  const add = zapierSdk.createFunction(async function add2(options) {
2676
2694
  const {
2677
- appKeys,
2678
- connectionIds,
2695
+ apps: appKeys,
2696
+ connections: connectionIds,
2679
2697
  configPath,
2680
2698
  typesOutput = await detectTypesOutputDirectory()
2681
2699
  } = options;
@@ -2697,17 +2715,17 @@ var addPlugin = ({ sdk: sdk2 }) => {
2697
2715
  }
2698
2716
  break;
2699
2717
  case "app_processing_start":
2700
- const appName = event.slug ? `${event.slug} (${event.appKey})` : event.appKey;
2718
+ const appName = event.slug ? `${event.slug} (${event.app})` : event.app;
2701
2719
  console.log(`\u{1F4E6} Adding ${appName}...`);
2702
2720
  break;
2703
2721
  case "manifest_updated":
2704
- const appDisplay = appSlugAndKeyMap.get(event.appKey) || event.appKey;
2722
+ const appDisplay = appSlugAndKeyMap.get(event.app) || event.app;
2705
2723
  console.log(
2706
- `\u{1F4DD} Locked ${appDisplay} to ${event.appKey}@${event.version} using key '${event.manifestKey}'`
2724
+ `\u{1F4DD} Locked ${appDisplay} to ${event.app}@${event.version} using key '${event.manifestKey}'`
2707
2725
  );
2708
2726
  break;
2709
2727
  case "app_processing_error":
2710
- const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
2728
+ const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
2711
2729
  console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
2712
2730
  break;
2713
2731
  }
@@ -2721,13 +2739,13 @@ var addPlugin = ({ sdk: sdk2 }) => {
2721
2739
  console.log(`\u{1F510} Found ${event.count} connection(s)`);
2722
2740
  break;
2723
2741
  case "connection_matched":
2724
- const appWithConnection = appSlugAndKeyMap.get(event.appKey) || event.appKey;
2742
+ const appWithConnection = appSlugAndKeyMap.get(event.app) || event.app;
2725
2743
  console.log(
2726
2744
  `\u{1F510} Using connection ${event.connectionId} (${event.connectionTitle}) for ${appWithConnection}`
2727
2745
  );
2728
2746
  break;
2729
2747
  case "connection_not_matched":
2730
- const appWithoutConnection = appSlugAndKeyMap.get(event.appKey) || event.appKey;
2748
+ const appWithoutConnection = appSlugAndKeyMap.get(event.app) || event.app;
2731
2749
  console.warn(
2732
2750
  `\u26A0\uFE0F No matching connection found for ${appWithoutConnection}`
2733
2751
  );
@@ -2738,20 +2756,20 @@ var addPlugin = ({ sdk: sdk2 }) => {
2738
2756
  );
2739
2757
  break;
2740
2758
  case "app_processing_error":
2741
- const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
2759
+ const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
2742
2760
  console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
2743
2761
  break;
2744
2762
  }
2745
2763
  };
2746
2764
  const manifestResult = await sdk2.buildManifest({
2747
- appKeys,
2765
+ apps: appKeys,
2748
2766
  skipWrite: false,
2749
2767
  configPath,
2750
2768
  onProgress: handleManifestProgress
2751
2769
  });
2752
2770
  const typesResult = await sdk2.generateAppTypes({
2753
- appKeys,
2754
- connectionIds,
2771
+ apps: appKeys,
2772
+ connections: connectionIds,
2755
2773
  skipWrite: false,
2756
2774
  typesOutputDirectory: resolvedTypesOutput,
2757
2775
  onProgress: handleTypesProgress
@@ -2777,10 +2795,10 @@ var addPlugin = ({ sdk: sdk2 }) => {
2777
2795
  };
2778
2796
  };
2779
2797
  var GenerateAppTypesSchema = zod.z.object({
2780
- appKeys: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
2798
+ apps: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
2781
2799
  "One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
2782
2800
  ),
2783
- connectionIds: zod.z.array(zod.z.string()).optional().describe(
2801
+ connections: zod.z.array(zod.z.string()).optional().describe(
2784
2802
  "Connection IDs to use for type generation (e.g., ['123', '456'])"
2785
2803
  ),
2786
2804
  skipWrite: zod.z.boolean().optional().describe(
@@ -2882,10 +2900,10 @@ Usage:
2882
2900
 
2883
2901
  const zapier = createZapierSdk();
2884
2902
  // Types are automatically available:
2885
- await zapier.apps.${preferredKey}.search.user_by_email({ connectionId: 123, inputs: { email } })
2903
+ await zapier.apps.${preferredKey}.search.user_by_email({ connection: 123, inputs: { email } })
2886
2904
 
2887
2905
  // Factory usage (pinned connection):
2888
- const ${myVariableName} = zapier.apps.${preferredKey}({ connectionId: 123 })
2906
+ const ${myVariableName} = zapier.apps.${preferredKey}({ connection: 123 })
2889
2907
  await ${myVariableName}.search.user_by_email({ inputs: { email } })`;
2890
2908
  const statements = [
2891
2909
  // Import the SDK to activate module augmentation
@@ -2895,6 +2913,7 @@ Usage:
2895
2913
  [
2896
2914
  "ActionExecutionOptions",
2897
2915
  "ActionExecutionResult",
2916
+ "AppFactoryInput",
2898
2917
  "ZapierFetchInitOptions"
2899
2918
  ],
2900
2919
  "@zapier/zapier-sdk"
@@ -3220,17 +3239,7 @@ Usage:
3220
3239
  void 0,
3221
3240
  "options",
3222
3241
  void 0,
3223
- this.factory.createTypeLiteralNode([
3224
- this.factory.createPropertySignature(
3225
- void 0,
3226
- "connectionId",
3227
- void 0,
3228
- this.factory.createUnionTypeNode([
3229
- this.factory.createKeywordTypeNode(ts__namespace.SyntaxKind.StringKeyword),
3230
- this.factory.createKeywordTypeNode(ts__namespace.SyntaxKind.NumberKeyword)
3231
- ])
3232
- )
3233
- ])
3242
+ this.factory.createTypeReferenceNode("AppFactoryInput")
3234
3243
  )
3235
3244
  ],
3236
3245
  this.factory.createTypeReferenceNode(`${appName}AppProxy`)
@@ -3394,8 +3403,8 @@ function createManifestEntry(app) {
3394
3403
  var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3395
3404
  const generateAppTypes = zapierSdk.createFunction(async function generateAppTypes2(options) {
3396
3405
  const {
3397
- appKeys,
3398
- connectionIds,
3406
+ apps: appKeys,
3407
+ connections: connectionIds,
3399
3408
  skipWrite = false,
3400
3409
  typesOutputDirectory = await detectTypesOutputDirectory(),
3401
3410
  onProgress
@@ -3405,7 +3414,7 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3405
3414
  typeDefinitions: {}
3406
3415
  };
3407
3416
  onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
3408
- const appsIterable = sdk2.listApps({ appKeys }).items();
3417
+ const appsIterable = sdk2.listApps({ apps: appKeys }).items();
3409
3418
  const apps = [];
3410
3419
  for await (const app of appsIterable) {
3411
3420
  apps.push(app);
@@ -3421,7 +3430,7 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3421
3430
  type: "connections_lookup_start",
3422
3431
  count: connectionIds.length
3423
3432
  });
3424
- const connectionsIterable = sdk2.listConnections({ connectionIds }).items();
3433
+ const connectionsIterable = sdk2.listConnections({ connections: connectionIds }).items();
3425
3434
  for await (const connection of connectionsIterable) {
3426
3435
  connections.push(connection);
3427
3436
  }
@@ -3439,7 +3448,7 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3439
3448
  for (const app of apps) {
3440
3449
  onProgress?.({
3441
3450
  type: "app_processing_start",
3442
- appKey: app.key,
3451
+ app: app.key,
3443
3452
  slug: app.slug
3444
3453
  });
3445
3454
  try {
@@ -3447,7 +3456,7 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3447
3456
  const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
3448
3457
  onProgress?.({
3449
3458
  type: "app_processing_error",
3450
- appKey: app.key,
3459
+ app: app.key,
3451
3460
  error: errorMessage
3452
3461
  });
3453
3462
  throw new zapierSdk.ZapierValidationError(errorMessage, {
@@ -3466,14 +3475,14 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3466
3475
  connectionId = matchingConnection.id;
3467
3476
  onProgress?.({
3468
3477
  type: "connection_matched",
3469
- appKey: app.key,
3478
+ app: app.key,
3470
3479
  connectionId: matchingConnection.id,
3471
3480
  connectionTitle: matchingConnection.title || ""
3472
3481
  });
3473
3482
  } else {
3474
3483
  onProgress?.({
3475
3484
  type: "connection_not_matched",
3476
- appKey: app.key
3485
+ app: app.key
3477
3486
  });
3478
3487
  }
3479
3488
  }
@@ -3502,13 +3511,13 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3502
3511
  }
3503
3512
  onProgress?.({
3504
3513
  type: "app_processing_complete",
3505
- appKey: app.key
3514
+ app: app.key
3506
3515
  });
3507
3516
  } catch (error) {
3508
3517
  const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
3509
3518
  onProgress?.({
3510
3519
  type: "app_processing_error",
3511
- appKey: app.key,
3520
+ app: app.key,
3512
3521
  error: errorMessage
3513
3522
  });
3514
3523
  if (error instanceof zapierSdk.ZapierValidationError) {
@@ -3536,7 +3545,7 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3536
3545
  };
3537
3546
  };
3538
3547
  var BuildManifestSchema = zod.z.object({
3539
- appKeys: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
3548
+ apps: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
3540
3549
  "One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello')"
3541
3550
  ),
3542
3551
  skipWrite: zod.z.boolean().optional().describe(
@@ -3552,9 +3561,14 @@ var BuildManifestSchema = zod.z.object({
3552
3561
  // src/plugins/buildManifest/index.ts
3553
3562
  var buildManifestPlugin = ({ sdk: sdk2, context }) => {
3554
3563
  const buildManifest = zapierSdk.createFunction(async function buildManifest2(options) {
3555
- const { appKeys, skipWrite = false, configPath, onProgress } = options;
3564
+ const {
3565
+ apps: appKeys,
3566
+ skipWrite = false,
3567
+ configPath,
3568
+ onProgress
3569
+ } = options;
3556
3570
  onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
3557
- const appsIterable = sdk2.listApps({ appKeys }).items();
3571
+ const appsIterable = sdk2.listApps({ apps: appKeys }).items();
3558
3572
  const apps = [];
3559
3573
  for await (const app of appsIterable) {
3560
3574
  apps.push(app);
@@ -3568,14 +3582,14 @@ var buildManifestPlugin = ({ sdk: sdk2, context }) => {
3568
3582
  for (const app of apps) {
3569
3583
  onProgress?.({
3570
3584
  type: "app_processing_start",
3571
- appKey: app.key,
3585
+ app: app.key,
3572
3586
  slug: app.slug
3573
3587
  });
3574
3588
  try {
3575
3589
  const manifestEntry = createManifestEntry(app);
3576
3590
  onProgress?.({
3577
3591
  type: "manifest_entry_built",
3578
- appKey: app.key,
3592
+ app: app.key,
3579
3593
  manifestKey: manifestEntry.implementationName,
3580
3594
  version: manifestEntry.version || ""
3581
3595
  });
@@ -3589,16 +3603,16 @@ var buildManifestPlugin = ({ sdk: sdk2, context }) => {
3589
3603
  updatedManifest = manifest;
3590
3604
  onProgress?.({
3591
3605
  type: "manifest_updated",
3592
- appKey: app.key,
3606
+ app: app.key,
3593
3607
  manifestKey: updatedManifestKey,
3594
3608
  version: manifestEntry.version || ""
3595
3609
  });
3596
- onProgress?.({ type: "app_processing_complete", appKey: app.key });
3610
+ onProgress?.({ type: "app_processing_complete", app: app.key });
3597
3611
  } catch (error) {
3598
3612
  const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
3599
3613
  onProgress?.({
3600
3614
  type: "app_processing_error",
3601
- appKey: app.key,
3615
+ app: app.key,
3602
3616
  error: errorMessage
3603
3617
  });
3604
3618
  if (error instanceof zapierSdk.ZapierValidationError) {
@@ -3718,7 +3732,9 @@ var CurlSchema = zod.z.object({
3718
3732
  maxTime: zod.z.number().optional().describe("Maximum time in seconds for the request"),
3719
3733
  user: zod.z.string().optional().describe("Basic auth credentials as 'user:password'"),
3720
3734
  compressed: zod.z.boolean().optional().describe("Request compressed response (sends Accept-Encoding header)"),
3721
- connectionId: zod.z.union([zod.z.string(), zod.z.number()]).optional().describe("Zapier connection ID for authentication")
3735
+ connection: zod.z.union([zod.z.string(), zod.z.number()]).optional().describe("Zapier connection ID or alias for authentication"),
3736
+ /** @deprecated Use `connection` instead. */
3737
+ connectionId: zod.z.union([zod.z.string(), zod.z.number()]).optional().meta({ deprecated: true })
3722
3738
  }).describe("Make HTTP requests through Zapier Relay with curl-like options");
3723
3739
  var CurlExitError = class extends Error {
3724
3740
  constructor(message, exitCode) {
@@ -3893,8 +3909,10 @@ var curlPlugin = ({
3893
3909
  maxTime,
3894
3910
  user,
3895
3911
  compressed,
3912
+ connection: connectionParam,
3896
3913
  connectionId
3897
3914
  } = options;
3915
+ const connection = connectionParam ?? connectionId;
3898
3916
  const parsedUrl = new URL(rawUrl);
3899
3917
  const headers = {};
3900
3918
  for (const h of header) {
@@ -4002,7 +4020,7 @@ var curlPlugin = ({
4002
4020
  body,
4003
4021
  redirect,
4004
4022
  signal,
4005
- connectionId
4023
+ connection
4006
4024
  });
4007
4025
  const timeTotalSeconds = (performance.now() - start) / 1e3;
4008
4026
  if (verbose && !silent) {
@@ -4638,7 +4656,7 @@ function createZapierCliSdk(options = {}) {
4638
4656
  // package.json with { type: 'json' }
4639
4657
  var package_default2 = {
4640
4658
  name: "@zapier/zapier-sdk-cli",
4641
- version: "0.38.2"};
4659
+ version: "0.39.0"};
4642
4660
  var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
4643
4661
  var CACHE_RESET_INTERVAL_MS = (() => {
4644
4662
  const { ZAPIER_SDK_UPDATE_CHECK_INTERVAL_MS = `${ONE_DAY_MS}` } = process.env;