@zapier/zapier-sdk-cli 0.38.1 → 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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Command, CommanderError } from 'commander';
2
+ import { Command, CommanderError, Option } from 'commander';
3
3
  import { z } from 'zod';
4
4
  import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, injectCliLogin, BaseSdkOptionsSchema, createZapierSdkWithoutRegistry, registryPlugin, ZapierError, ZapierValidationError, ZapierUnknownError, batch, toSnakeCase, buildApplicationLifecycleEvent, isCredentialsObject, isPositional, runWithTelemetryContext, buildCapabilityMessage, formatErrorMessage, getOsInfo, getPlatformVersions, getCiPlatform, isCi, getReleaseId, getCurrentTimestamp, generateEventId } from '@zapier/zapier-sdk';
5
5
  import inquirer from 'inquirer';
@@ -797,11 +797,11 @@ Optional fields${pathContext}:`));
797
797
  );
798
798
  this.startSpinner();
799
799
  const page = await context.sdk.listInputFieldChoices({
800
- appKey: context.resolvedParams.appKey,
801
- actionKey: context.resolvedParams.actionKey,
800
+ app: context.resolvedParams.app,
801
+ action: context.resolvedParams.action,
802
802
  actionType: context.resolvedParams.actionType,
803
- connectionId: context.resolvedParams.connectionId,
804
- inputFieldKey: fieldMeta.key,
803
+ connection: context.resolvedParams.connection,
804
+ inputField: fieldMeta.key,
805
805
  inputs,
806
806
  ...cursor && { cursor }
807
807
  });
@@ -1065,7 +1065,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
1065
1065
 
1066
1066
  // package.json
1067
1067
  var package_default = {
1068
- version: "0.38.1"};
1068
+ version: "0.39.0"};
1069
1069
 
1070
1070
  // src/telemetry/builders.ts
1071
1071
  function createCliBaseEvent(context = {}) {
@@ -1621,13 +1621,15 @@ function analyzeZodSchema(schema, functionInfo) {
1621
1621
  return parameters;
1622
1622
  }
1623
1623
  function analyzeZodField(name, schema, functionInfo) {
1624
- if (functionInfo?.deprecatedParameters?.includes(name)) {
1625
- return null;
1626
- }
1627
1624
  let baseSchema = schema;
1628
1625
  let required = true;
1629
1626
  let defaultValue = void 0;
1627
+ let isDeprecated = false;
1630
1628
  while (true) {
1629
+ const meta = baseSchema.meta?.();
1630
+ if (meta?.deprecated) {
1631
+ isDeprecated = true;
1632
+ }
1631
1633
  if (baseSchema instanceof z.ZodOptional) {
1632
1634
  required = false;
1633
1635
  baseSchema = baseSchema._zod.def.innerType;
@@ -1683,7 +1685,8 @@ function analyzeZodField(name, schema, functionInfo) {
1683
1685
  choices,
1684
1686
  hasResolver: paramHasResolver,
1685
1687
  isPositional: isPositional(schema),
1686
- elementType
1688
+ elementType,
1689
+ hidden: isDeprecated
1687
1690
  };
1688
1691
  }
1689
1692
  function analyzeInputParameters(inputParameters, functionInfo) {
@@ -1698,9 +1701,6 @@ function analyzeInputParameters(inputParameters, functionInfo) {
1698
1701
  if (schema instanceof z.ZodObject) {
1699
1702
  const shape = schema.shape;
1700
1703
  for (const [key, fieldSchema] of Object.entries(shape)) {
1701
- if (functionInfo?.deprecatedParameters?.includes(key)) {
1702
- continue;
1703
- }
1704
1704
  const analyzed = analyzeZodField(
1705
1705
  key,
1706
1706
  fieldSchema,
@@ -1863,6 +1863,15 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
1863
1863
  args.slice(0, -1),
1864
1864
  options2
1865
1865
  );
1866
+ const schemaAliases = schema?.meta?.()?.aliases;
1867
+ if (schemaAliases) {
1868
+ for (const [oldName, newName] of Object.entries(schemaAliases)) {
1869
+ if (oldName in rawParams && !(newName in rawParams)) {
1870
+ rawParams[newName] = rawParams[oldName];
1871
+ delete rawParams[oldName];
1872
+ }
1873
+ }
1874
+ }
1866
1875
  if (schema && !usesInputParameters) {
1867
1876
  const resolver = new SchemaParameterResolver();
1868
1877
  resolvedParams = await resolver.resolveParameters(
@@ -1980,7 +1989,7 @@ ${confirmMessageAfter}`));
1980
1989
  cli_arguments: sanitizeCliArguments(process.argv.slice(2))
1981
1990
  },
1982
1991
  context: {
1983
- selected_api: resolvedParams.appKey ?? null
1992
+ selected_api: resolvedParams.app ?? null
1984
1993
  }
1985
1994
  });
1986
1995
  sdk2.getContext().eventEmission.emit(CLI_COMMAND_EXECUTED_EVENT_SUBJECT, event);
@@ -2044,17 +2053,26 @@ function addCommand(program2, commandName, config) {
2044
2053
  }
2045
2054
  flags.push(`--${kebabName}`);
2046
2055
  if (param.type === "boolean") {
2047
- command.option(flags.join(", "), param.description);
2056
+ const opt = new Option(flags.join(", "), param.description);
2057
+ if (param.hidden) opt.hideHelp();
2058
+ command.addOption(opt);
2048
2059
  } else if (param.type === "array") {
2049
2060
  const flagSignature = flags.join(", ") + ` <value>`;
2050
- command.option(flagSignature, param.description || "", collect, []);
2061
+ const opt = new Option(flagSignature, param.description || "");
2062
+ opt.default([]);
2063
+ opt.argParser(
2064
+ (value, previous) => (previous || []).concat([value])
2065
+ );
2066
+ if (param.hidden) opt.hideHelp();
2067
+ command.addOption(opt);
2051
2068
  } else {
2052
2069
  const flagSignature = flags.join(", ") + ` <${param.type}>`;
2053
- command.option(
2054
- flagSignature,
2055
- param.description || "",
2056
- param.default
2057
- );
2070
+ const opt = new Option(flagSignature, param.description || "");
2071
+ if (param.default !== void 0) {
2072
+ opt.default(param.default);
2073
+ }
2074
+ if (param.hidden) opt.hideHelp();
2075
+ command.addOption(opt);
2058
2076
  }
2059
2077
  }
2060
2078
  });
@@ -2607,10 +2625,10 @@ var getLoginConfigPathPlugin = () => {
2607
2625
  };
2608
2626
  };
2609
2627
  var AddSchema = z.object({
2610
- appKeys: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
2628
+ apps: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
2611
2629
  "One or more app keys to add (e.g., 'slack', 'github', 'trello')"
2612
2630
  ),
2613
- connectionIds: z.array(z.string()).optional().describe(
2631
+ connections: z.array(z.string()).optional().describe(
2614
2632
  "Connection IDs to use for type generation (e.g., ['123', '456'])"
2615
2633
  ),
2616
2634
  configPath: z.string().optional().describe(
@@ -2636,8 +2654,8 @@ async function detectTypesOutputDirectory() {
2636
2654
  var addPlugin = ({ sdk: sdk2 }) => {
2637
2655
  const add = createFunction(async function add2(options) {
2638
2656
  const {
2639
- appKeys,
2640
- connectionIds,
2657
+ apps: appKeys,
2658
+ connections: connectionIds,
2641
2659
  configPath,
2642
2660
  typesOutput = await detectTypesOutputDirectory()
2643
2661
  } = options;
@@ -2659,17 +2677,17 @@ var addPlugin = ({ sdk: sdk2 }) => {
2659
2677
  }
2660
2678
  break;
2661
2679
  case "app_processing_start":
2662
- const appName = event.slug ? `${event.slug} (${event.appKey})` : event.appKey;
2680
+ const appName = event.slug ? `${event.slug} (${event.app})` : event.app;
2663
2681
  console.log(`\u{1F4E6} Adding ${appName}...`);
2664
2682
  break;
2665
2683
  case "manifest_updated":
2666
- const appDisplay = appSlugAndKeyMap.get(event.appKey) || event.appKey;
2684
+ const appDisplay = appSlugAndKeyMap.get(event.app) || event.app;
2667
2685
  console.log(
2668
- `\u{1F4DD} Locked ${appDisplay} to ${event.appKey}@${event.version} using key '${event.manifestKey}'`
2686
+ `\u{1F4DD} Locked ${appDisplay} to ${event.app}@${event.version} using key '${event.manifestKey}'`
2669
2687
  );
2670
2688
  break;
2671
2689
  case "app_processing_error":
2672
- const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
2690
+ const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
2673
2691
  console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
2674
2692
  break;
2675
2693
  }
@@ -2683,13 +2701,13 @@ var addPlugin = ({ sdk: sdk2 }) => {
2683
2701
  console.log(`\u{1F510} Found ${event.count} connection(s)`);
2684
2702
  break;
2685
2703
  case "connection_matched":
2686
- const appWithConnection = appSlugAndKeyMap.get(event.appKey) || event.appKey;
2704
+ const appWithConnection = appSlugAndKeyMap.get(event.app) || event.app;
2687
2705
  console.log(
2688
2706
  `\u{1F510} Using connection ${event.connectionId} (${event.connectionTitle}) for ${appWithConnection}`
2689
2707
  );
2690
2708
  break;
2691
2709
  case "connection_not_matched":
2692
- const appWithoutConnection = appSlugAndKeyMap.get(event.appKey) || event.appKey;
2710
+ const appWithoutConnection = appSlugAndKeyMap.get(event.app) || event.app;
2693
2711
  console.warn(
2694
2712
  `\u26A0\uFE0F No matching connection found for ${appWithoutConnection}`
2695
2713
  );
@@ -2700,20 +2718,20 @@ var addPlugin = ({ sdk: sdk2 }) => {
2700
2718
  );
2701
2719
  break;
2702
2720
  case "app_processing_error":
2703
- const errorApp = appSlugAndKeyMap.get(event.appKey) || event.appKey;
2721
+ const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
2704
2722
  console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
2705
2723
  break;
2706
2724
  }
2707
2725
  };
2708
2726
  const manifestResult = await sdk2.buildManifest({
2709
- appKeys,
2727
+ apps: appKeys,
2710
2728
  skipWrite: false,
2711
2729
  configPath,
2712
2730
  onProgress: handleManifestProgress
2713
2731
  });
2714
2732
  const typesResult = await sdk2.generateAppTypes({
2715
- appKeys,
2716
- connectionIds,
2733
+ apps: appKeys,
2734
+ connections: connectionIds,
2717
2735
  skipWrite: false,
2718
2736
  typesOutputDirectory: resolvedTypesOutput,
2719
2737
  onProgress: handleTypesProgress
@@ -2739,10 +2757,10 @@ var addPlugin = ({ sdk: sdk2 }) => {
2739
2757
  };
2740
2758
  };
2741
2759
  var GenerateAppTypesSchema = z.object({
2742
- appKeys: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
2760
+ apps: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
2743
2761
  "One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
2744
2762
  ),
2745
- connectionIds: z.array(z.string()).optional().describe(
2763
+ connections: z.array(z.string()).optional().describe(
2746
2764
  "Connection IDs to use for type generation (e.g., ['123', '456'])"
2747
2765
  ),
2748
2766
  skipWrite: z.boolean().optional().describe(
@@ -2844,10 +2862,10 @@ Usage:
2844
2862
 
2845
2863
  const zapier = createZapierSdk();
2846
2864
  // Types are automatically available:
2847
- await zapier.apps.${preferredKey}.search.user_by_email({ connectionId: 123, inputs: { email } })
2865
+ await zapier.apps.${preferredKey}.search.user_by_email({ connection: 123, inputs: { email } })
2848
2866
 
2849
2867
  // Factory usage (pinned connection):
2850
- const ${myVariableName} = zapier.apps.${preferredKey}({ connectionId: 123 })
2868
+ const ${myVariableName} = zapier.apps.${preferredKey}({ connection: 123 })
2851
2869
  await ${myVariableName}.search.user_by_email({ inputs: { email } })`;
2852
2870
  const statements = [
2853
2871
  // Import the SDK to activate module augmentation
@@ -2857,6 +2875,7 @@ Usage:
2857
2875
  [
2858
2876
  "ActionExecutionOptions",
2859
2877
  "ActionExecutionResult",
2878
+ "AppFactoryInput",
2860
2879
  "ZapierFetchInitOptions"
2861
2880
  ],
2862
2881
  "@zapier/zapier-sdk"
@@ -3182,17 +3201,7 @@ Usage:
3182
3201
  void 0,
3183
3202
  "options",
3184
3203
  void 0,
3185
- this.factory.createTypeLiteralNode([
3186
- this.factory.createPropertySignature(
3187
- void 0,
3188
- "connectionId",
3189
- void 0,
3190
- this.factory.createUnionTypeNode([
3191
- this.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
3192
- this.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword)
3193
- ])
3194
- )
3195
- ])
3204
+ this.factory.createTypeReferenceNode("AppFactoryInput")
3196
3205
  )
3197
3206
  ],
3198
3207
  this.factory.createTypeReferenceNode(`${appName}AppProxy`)
@@ -3356,8 +3365,8 @@ function createManifestEntry(app) {
3356
3365
  var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3357
3366
  const generateAppTypes = createFunction(async function generateAppTypes2(options) {
3358
3367
  const {
3359
- appKeys,
3360
- connectionIds,
3368
+ apps: appKeys,
3369
+ connections: connectionIds,
3361
3370
  skipWrite = false,
3362
3371
  typesOutputDirectory = await detectTypesOutputDirectory(),
3363
3372
  onProgress
@@ -3367,7 +3376,7 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3367
3376
  typeDefinitions: {}
3368
3377
  };
3369
3378
  onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
3370
- const appsIterable = sdk2.listApps({ appKeys }).items();
3379
+ const appsIterable = sdk2.listApps({ apps: appKeys }).items();
3371
3380
  const apps = [];
3372
3381
  for await (const app of appsIterable) {
3373
3382
  apps.push(app);
@@ -3383,7 +3392,7 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3383
3392
  type: "connections_lookup_start",
3384
3393
  count: connectionIds.length
3385
3394
  });
3386
- const connectionsIterable = sdk2.listConnections({ connectionIds }).items();
3395
+ const connectionsIterable = sdk2.listConnections({ connections: connectionIds }).items();
3387
3396
  for await (const connection of connectionsIterable) {
3388
3397
  connections.push(connection);
3389
3398
  }
@@ -3401,7 +3410,7 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3401
3410
  for (const app of apps) {
3402
3411
  onProgress?.({
3403
3412
  type: "app_processing_start",
3404
- appKey: app.key,
3413
+ app: app.key,
3405
3414
  slug: app.slug
3406
3415
  });
3407
3416
  try {
@@ -3409,7 +3418,7 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3409
3418
  const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
3410
3419
  onProgress?.({
3411
3420
  type: "app_processing_error",
3412
- appKey: app.key,
3421
+ app: app.key,
3413
3422
  error: errorMessage
3414
3423
  });
3415
3424
  throw new ZapierValidationError(errorMessage, {
@@ -3428,14 +3437,14 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3428
3437
  connectionId = matchingConnection.id;
3429
3438
  onProgress?.({
3430
3439
  type: "connection_matched",
3431
- appKey: app.key,
3440
+ app: app.key,
3432
3441
  connectionId: matchingConnection.id,
3433
3442
  connectionTitle: matchingConnection.title || ""
3434
3443
  });
3435
3444
  } else {
3436
3445
  onProgress?.({
3437
3446
  type: "connection_not_matched",
3438
- appKey: app.key
3447
+ app: app.key
3439
3448
  });
3440
3449
  }
3441
3450
  }
@@ -3464,13 +3473,13 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3464
3473
  }
3465
3474
  onProgress?.({
3466
3475
  type: "app_processing_complete",
3467
- appKey: app.key
3476
+ app: app.key
3468
3477
  });
3469
3478
  } catch (error) {
3470
3479
  const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
3471
3480
  onProgress?.({
3472
3481
  type: "app_processing_error",
3473
- appKey: app.key,
3482
+ app: app.key,
3474
3483
  error: errorMessage
3475
3484
  });
3476
3485
  if (error instanceof ZapierValidationError) {
@@ -3498,7 +3507,7 @@ var generateAppTypesPlugin = ({ sdk: sdk2 }) => {
3498
3507
  };
3499
3508
  };
3500
3509
  var BuildManifestSchema = z.object({
3501
- appKeys: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
3510
+ apps: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
3502
3511
  "One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello')"
3503
3512
  ),
3504
3513
  skipWrite: z.boolean().optional().describe(
@@ -3514,9 +3523,14 @@ var BuildManifestSchema = z.object({
3514
3523
  // src/plugins/buildManifest/index.ts
3515
3524
  var buildManifestPlugin = ({ sdk: sdk2, context }) => {
3516
3525
  const buildManifest = createFunction(async function buildManifest2(options) {
3517
- const { appKeys, skipWrite = false, configPath, onProgress } = options;
3526
+ const {
3527
+ apps: appKeys,
3528
+ skipWrite = false,
3529
+ configPath,
3530
+ onProgress
3531
+ } = options;
3518
3532
  onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
3519
- const appsIterable = sdk2.listApps({ appKeys }).items();
3533
+ const appsIterable = sdk2.listApps({ apps: appKeys }).items();
3520
3534
  const apps = [];
3521
3535
  for await (const app of appsIterable) {
3522
3536
  apps.push(app);
@@ -3530,14 +3544,14 @@ var buildManifestPlugin = ({ sdk: sdk2, context }) => {
3530
3544
  for (const app of apps) {
3531
3545
  onProgress?.({
3532
3546
  type: "app_processing_start",
3533
- appKey: app.key,
3547
+ app: app.key,
3534
3548
  slug: app.slug
3535
3549
  });
3536
3550
  try {
3537
3551
  const manifestEntry = createManifestEntry(app);
3538
3552
  onProgress?.({
3539
3553
  type: "manifest_entry_built",
3540
- appKey: app.key,
3554
+ app: app.key,
3541
3555
  manifestKey: manifestEntry.implementationName,
3542
3556
  version: manifestEntry.version || ""
3543
3557
  });
@@ -3551,16 +3565,16 @@ var buildManifestPlugin = ({ sdk: sdk2, context }) => {
3551
3565
  updatedManifest = manifest;
3552
3566
  onProgress?.({
3553
3567
  type: "manifest_updated",
3554
- appKey: app.key,
3568
+ app: app.key,
3555
3569
  manifestKey: updatedManifestKey,
3556
3570
  version: manifestEntry.version || ""
3557
3571
  });
3558
- onProgress?.({ type: "app_processing_complete", appKey: app.key });
3572
+ onProgress?.({ type: "app_processing_complete", app: app.key });
3559
3573
  } catch (error) {
3560
3574
  const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
3561
3575
  onProgress?.({
3562
3576
  type: "app_processing_error",
3563
- appKey: app.key,
3577
+ app: app.key,
3564
3578
  error: errorMessage
3565
3579
  });
3566
3580
  if (error instanceof ZapierValidationError) {
@@ -3680,7 +3694,9 @@ var CurlSchema = z.object({
3680
3694
  maxTime: z.number().optional().describe("Maximum time in seconds for the request"),
3681
3695
  user: z.string().optional().describe("Basic auth credentials as 'user:password'"),
3682
3696
  compressed: z.boolean().optional().describe("Request compressed response (sends Accept-Encoding header)"),
3683
- connectionId: z.union([z.string(), z.number()]).optional().describe("Zapier connection ID for authentication")
3697
+ connection: z.union([z.string(), z.number()]).optional().describe("Zapier connection ID or alias for authentication"),
3698
+ /** @deprecated Use `connection` instead. */
3699
+ connectionId: z.union([z.string(), z.number()]).optional().meta({ deprecated: true })
3684
3700
  }).describe("Make HTTP requests through Zapier Relay with curl-like options");
3685
3701
  var CurlExitError = class extends Error {
3686
3702
  constructor(message, exitCode) {
@@ -3855,8 +3871,10 @@ var curlPlugin = ({
3855
3871
  maxTime,
3856
3872
  user,
3857
3873
  compressed,
3874
+ connection: connectionParam,
3858
3875
  connectionId
3859
3876
  } = options;
3877
+ const connection = connectionParam ?? connectionId;
3860
3878
  const parsedUrl = new URL(rawUrl);
3861
3879
  const headers = {};
3862
3880
  for (const h of header) {
@@ -3964,7 +3982,7 @@ var curlPlugin = ({
3964
3982
  body,
3965
3983
  redirect,
3966
3984
  signal,
3967
- connectionId
3985
+ connection
3968
3986
  });
3969
3987
  const timeTotalSeconds = (performance.now() - start) / 1e3;
3970
3988
  if (verbose && !silent) {
@@ -4600,7 +4618,7 @@ function createZapierCliSdk(options = {}) {
4600
4618
  // package.json with { type: 'json' }
4601
4619
  var package_default2 = {
4602
4620
  name: "@zapier/zapier-sdk-cli",
4603
- version: "0.38.1"};
4621
+ version: "0.39.0"};
4604
4622
  var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
4605
4623
  var CACHE_RESET_INTERVAL_MS = (() => {
4606
4624
  const { ZAPIER_SDK_UPDATE_CHECK_INTERVAL_MS = `${ONE_DAY_MS}` } = process.env;