@zapier/zapier-sdk-cli 0.22.0 → 0.23.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.
Files changed (89) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +57 -0
  3. package/dist/cli.cjs +45 -3
  4. package/dist/cli.mjs +45 -3
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.mjs +1 -1
  7. package/dist/package.json +78 -0
  8. package/dist/src/cli.d.ts +2 -0
  9. package/dist/src/cli.js +105 -0
  10. package/dist/src/generators/ast-generator.d.ts +41 -0
  11. package/dist/src/generators/ast-generator.js +409 -0
  12. package/dist/src/index.d.ts +4 -0
  13. package/dist/src/index.js +4 -0
  14. package/dist/src/plugins/add/index.d.ts +15 -0
  15. package/dist/src/plugins/add/index.js +103 -0
  16. package/dist/src/plugins/add/schemas.d.ts +8 -0
  17. package/dist/src/plugins/add/schemas.js +22 -0
  18. package/dist/src/plugins/buildManifest/index.d.ts +13 -0
  19. package/dist/src/plugins/buildManifest/index.js +81 -0
  20. package/dist/src/plugins/buildManifest/schemas.d.ts +44 -0
  21. package/dist/src/plugins/buildManifest/schemas.js +17 -0
  22. package/dist/src/plugins/bundleCode/index.d.ts +15 -0
  23. package/dist/src/plugins/bundleCode/index.js +80 -0
  24. package/dist/src/plugins/bundleCode/schemas.d.ts +10 -0
  25. package/dist/src/plugins/bundleCode/schemas.js +19 -0
  26. package/dist/src/plugins/generateAppTypes/index.d.ts +13 -0
  27. package/dist/src/plugins/generateAppTypes/index.js +157 -0
  28. package/dist/src/plugins/generateAppTypes/schemas.d.ts +58 -0
  29. package/dist/src/plugins/generateAppTypes/schemas.js +21 -0
  30. package/dist/src/plugins/getLoginConfigPath/index.d.ts +15 -0
  31. package/dist/src/plugins/getLoginConfigPath/index.js +19 -0
  32. package/dist/src/plugins/getLoginConfigPath/schemas.d.ts +3 -0
  33. package/dist/src/plugins/getLoginConfigPath/schemas.js +5 -0
  34. package/dist/src/plugins/index.d.ts +8 -0
  35. package/dist/src/plugins/index.js +8 -0
  36. package/dist/src/plugins/login/index.d.ts +23 -0
  37. package/dist/src/plugins/login/index.js +95 -0
  38. package/dist/src/plugins/login/schemas.d.ts +5 -0
  39. package/dist/src/plugins/login/schemas.js +10 -0
  40. package/dist/src/plugins/logout/index.d.ts +15 -0
  41. package/dist/src/plugins/logout/index.js +18 -0
  42. package/dist/src/plugins/logout/schemas.d.ts +3 -0
  43. package/dist/src/plugins/logout/schemas.js +5 -0
  44. package/dist/src/plugins/mcp/index.d.ts +15 -0
  45. package/dist/src/plugins/mcp/index.js +24 -0
  46. package/dist/src/plugins/mcp/schemas.d.ts +5 -0
  47. package/dist/src/plugins/mcp/schemas.js +10 -0
  48. package/dist/src/sdk.d.ts +9 -0
  49. package/dist/src/sdk.js +24 -0
  50. package/dist/src/telemetry/builders.d.ts +42 -0
  51. package/dist/src/telemetry/builders.js +55 -0
  52. package/dist/src/telemetry/events.d.ts +37 -0
  53. package/dist/src/telemetry/events.js +4 -0
  54. package/dist/src/types/sdk.d.ts +5 -0
  55. package/dist/src/types/sdk.js +1 -0
  56. package/dist/src/utils/api/client.d.ts +15 -0
  57. package/dist/src/utils/api/client.js +27 -0
  58. package/dist/src/utils/auth/login.d.ts +7 -0
  59. package/dist/src/utils/auth/login.js +154 -0
  60. package/dist/src/utils/cli-generator-utils.d.ts +14 -0
  61. package/dist/src/utils/cli-generator-utils.js +122 -0
  62. package/dist/src/utils/cli-generator.d.ts +3 -0
  63. package/dist/src/utils/cli-generator.js +597 -0
  64. package/dist/src/utils/constants.d.ts +3 -0
  65. package/dist/src/utils/constants.js +5 -0
  66. package/dist/src/utils/directory-detection.d.ts +5 -0
  67. package/dist/src/utils/directory-detection.js +21 -0
  68. package/dist/src/utils/errors.d.ts +16 -0
  69. package/dist/src/utils/errors.js +19 -0
  70. package/dist/src/utils/getCallablePromise.d.ts +6 -0
  71. package/dist/src/utils/getCallablePromise.js +14 -0
  72. package/dist/src/utils/log.d.ts +8 -0
  73. package/dist/src/utils/log.js +21 -0
  74. package/dist/src/utils/manifest-helpers.d.ts +10 -0
  75. package/dist/src/utils/manifest-helpers.js +19 -0
  76. package/dist/src/utils/package-manager-detector.d.ts +16 -0
  77. package/dist/src/utils/package-manager-detector.js +77 -0
  78. package/dist/src/utils/parameter-resolver.d.ts +42 -0
  79. package/dist/src/utils/parameter-resolver.js +699 -0
  80. package/dist/src/utils/schema-formatter.d.ts +6 -0
  81. package/dist/src/utils/schema-formatter.js +115 -0
  82. package/dist/src/utils/serializeAsync.d.ts +2 -0
  83. package/dist/src/utils/serializeAsync.js +16 -0
  84. package/dist/src/utils/spinner.d.ts +1 -0
  85. package/dist/src/utils/spinner.js +21 -0
  86. package/dist/src/utils/version-checker.d.ts +17 -0
  87. package/dist/src/utils/version-checker.js +156 -0
  88. package/dist/tsconfig.tsbuildinfo +1 -0
  89. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @zapier/zapier-sdk-cli
2
2
 
3
+ ## 0.23.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 33e2a8f: Added methods/commands for creating/listing/deleting client credentials.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [33e2a8f]
12
+ - @zapier/zapier-sdk-cli-login@0.6.0
13
+ - @zapier/zapier-sdk-mcp@0.6.0
14
+ - @zapier/zapier-sdk@0.21.0
15
+
16
+ ## 0.22.1
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [7bd3c5c]
21
+ - @zapier/zapier-sdk@0.20.1
22
+ - @zapier/zapier-sdk-mcp@0.5.1
23
+
3
24
  ## 0.22.0
4
25
 
5
26
  - Fix 0.21.0 saying to update to 0.21.0.
package/README.md CHANGED
@@ -25,6 +25,10 @@
25
25
  - [`find-unique-authentication`](#find-unique-authentication)
26
26
  - [`get-authentication`](#get-authentication)
27
27
  - [`list-authentications`](#list-authentications)
28
+ - [Client Credentials](#client-credentials)
29
+ - [`create-client-credentials`](#create-client-credentials)
30
+ - [`delete-client-credentials`](#delete-client-credentials)
31
+ - [`list-client-credentials`](#list-client-credentials)
28
32
  - [HTTP Requests](#http-requests)
29
33
  - [`request`](#request)
30
34
  - [Utilities](#utilities)
@@ -364,6 +368,59 @@ List available authentications with optional filtering
364
368
  npx zapier-sdk list-authentications [--app-key] [--authentication-ids] [--search] [--title] [--account-id] [--owner] [--is-expired] [--page-size] [--max-items] [--cursor]
365
369
  ```
366
370
 
371
+ ### Client Credentials
372
+
373
+ #### `create-client-credentials`
374
+
375
+ Create new client credentials for the authenticated user
376
+
377
+ **Options:**
378
+
379
+ | Option | Type | Required | Default | Possible Values | Description |
380
+ | ------------------ | -------- | -------- | -------------- | --------------- | ---------------------------------------------- |
381
+ | `<name>` | `string` | ✅ | — | — | Human-readable name for the client credentials |
382
+ | `--allowed_scopes` | `array` | ❌ | `["external"]` | — | Scopes to allow for these credentials |
383
+
384
+ **Usage:**
385
+
386
+ ```bash
387
+ npx zapier-sdk create-client-credentials <name> [--allowed_scopes]
388
+ ```
389
+
390
+ #### `delete-client-credentials`
391
+
392
+ Delete client credentials by client ID
393
+
394
+ **Options:**
395
+
396
+ | Option | Type | Required | Default | Possible Values | Description |
397
+ | ------------- | -------- | -------- | ------- | --------------- | ------------------------------------------------- |
398
+ | `<client-id>` | `string` | ✅ | — | — | The client ID of the client credentials to delete |
399
+
400
+ **Usage:**
401
+
402
+ ```bash
403
+ npx zapier-sdk delete-client-credentials <client-id>
404
+ ```
405
+
406
+ #### `list-client-credentials`
407
+
408
+ List client credentials for the authenticated user
409
+
410
+ **Options:**
411
+
412
+ | Option | Type | Required | Default | Possible Values | Description |
413
+ | ------------- | -------- | -------- | ------- | --------------- | ---------------------------------------------- |
414
+ | `--page-size` | `number` | ❌ | — | — | Number of credentials per page |
415
+ | `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
416
+ | `--cursor` | `string` | ❌ | — | — | Cursor to start from |
417
+
418
+ **Usage:**
419
+
420
+ ```bash
421
+ npx zapier-sdk list-client-credentials [--page-size] [--max-items] [--cursor]
422
+ ```
423
+
367
424
  ### HTTP Requests
368
425
 
369
426
  #### `request`
package/dist/cli.cjs CHANGED
@@ -876,6 +876,33 @@ function formatItemsGeneric(items, startingNumber = 0) {
876
876
  formatSingleItem(formatted, startingNumber + index);
877
877
  });
878
878
  }
879
+ var CONFIRM_MESSAGES = {
880
+ "create-secret": {
881
+ messageBefore: "You are about to create a sensitive secret that will be displayed as plain text.\nOnce created, you cannot retrieve it again.",
882
+ messageAfter: "Please treat this secret like a password and store it securely!"
883
+ },
884
+ delete: {
885
+ messageBefore: "You are about to delete this record."
886
+ }
887
+ };
888
+ async function promptConfirm(confirmType) {
889
+ if (!confirmType || !CONFIRM_MESSAGES[confirmType]) {
890
+ return { confirmed: true };
891
+ }
892
+ const { messageBefore, messageAfter } = CONFIRM_MESSAGES[confirmType];
893
+ console.log(chalk3__default.default.yellow(`
894
+ ${messageBefore}
895
+ `));
896
+ const { confirmed } = await inquirer__default.default.prompt([
897
+ {
898
+ type: "confirm",
899
+ name: "confirmed",
900
+ message: "Continue?",
901
+ default: false
902
+ }
903
+ ]);
904
+ return { confirmed, messageAfter };
905
+ }
879
906
  function analyzeZodSchema(schema, functionInfo) {
880
907
  const parameters = [];
881
908
  const schemaDef = schema._zod?.def;
@@ -907,7 +934,8 @@ function analyzeZodField(name, schema, functionInfo) {
907
934
  baseSchema = baseSchema._zod.def.innerType;
908
935
  } else if (baseSchema instanceof zod.z.ZodDefault) {
909
936
  required = false;
910
- defaultValue = baseSchema._zod.def.defaultValue();
937
+ const defValue = baseSchema._zod.def.defaultValue;
938
+ defaultValue = typeof defValue === "function" ? defValue() : defValue;
911
939
  baseSchema = baseSchema._zod.def.innerType;
912
940
  } else {
913
941
  const zodDef = baseSchema._zod?.def;
@@ -1057,6 +1085,16 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
1057
1085
  sdk2,
1058
1086
  functionInfo.name
1059
1087
  );
1088
+ const confirm = functionInfo.confirm;
1089
+ let confirmMessageAfter;
1090
+ if (confirm && !shouldUseJson) {
1091
+ const confirmResult = await promptConfirm(confirm);
1092
+ if (!confirmResult.confirmed) {
1093
+ console.log(chalk3__default.default.yellow("Operation cancelled."));
1094
+ return;
1095
+ }
1096
+ confirmMessageAfter = confirmResult.messageAfter;
1097
+ }
1060
1098
  if (isListCommand && hasPaginationParams && !shouldUseJson && !hasUserSpecifiedMaxItems) {
1061
1099
  const sdkObj = sdk2;
1062
1100
  const sdkIterator = sdkObj[functionInfo.name](resolvedParams);
@@ -1109,6 +1147,10 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
1109
1147
  } else {
1110
1148
  formatJsonOutput(items);
1111
1149
  }
1150
+ if (confirmMessageAfter) {
1151
+ console.log(chalk3__default.default.yellow(`
1152
+ ${confirmMessageAfter}`));
1153
+ }
1112
1154
  }
1113
1155
  } catch (error) {
1114
1156
  if (error instanceof Error && error.message.includes('"code"')) {
@@ -1656,7 +1698,7 @@ var LoginSchema = zod.z.object({
1656
1698
 
1657
1699
  // package.json
1658
1700
  var package_default = {
1659
- version: "0.22.0"};
1701
+ version: "0.23.0"};
1660
1702
 
1661
1703
  // src/telemetry/builders.ts
1662
1704
  function createCliBaseEvent(context = {}) {
@@ -2937,7 +2979,7 @@ function createZapierCliSdk(options = {}) {
2937
2979
  // package.json with { type: 'json' }
2938
2980
  var package_default2 = {
2939
2981
  name: "@zapier/zapier-sdk-cli",
2940
- version: "0.22.0"};
2982
+ version: "0.23.0"};
2941
2983
  function detectPackageManager(cwd = process.cwd()) {
2942
2984
  const ua = process.env.npm_config_user_agent;
2943
2985
  if (ua) {
package/dist/cli.mjs CHANGED
@@ -840,6 +840,33 @@ function formatItemsGeneric(items, startingNumber = 0) {
840
840
  formatSingleItem(formatted, startingNumber + index);
841
841
  });
842
842
  }
843
+ var CONFIRM_MESSAGES = {
844
+ "create-secret": {
845
+ messageBefore: "You are about to create a sensitive secret that will be displayed as plain text.\nOnce created, you cannot retrieve it again.",
846
+ messageAfter: "Please treat this secret like a password and store it securely!"
847
+ },
848
+ delete: {
849
+ messageBefore: "You are about to delete this record."
850
+ }
851
+ };
852
+ async function promptConfirm(confirmType) {
853
+ if (!confirmType || !CONFIRM_MESSAGES[confirmType]) {
854
+ return { confirmed: true };
855
+ }
856
+ const { messageBefore, messageAfter } = CONFIRM_MESSAGES[confirmType];
857
+ console.log(chalk3.yellow(`
858
+ ${messageBefore}
859
+ `));
860
+ const { confirmed } = await inquirer.prompt([
861
+ {
862
+ type: "confirm",
863
+ name: "confirmed",
864
+ message: "Continue?",
865
+ default: false
866
+ }
867
+ ]);
868
+ return { confirmed, messageAfter };
869
+ }
843
870
  function analyzeZodSchema(schema, functionInfo) {
844
871
  const parameters = [];
845
872
  const schemaDef = schema._zod?.def;
@@ -871,7 +898,8 @@ function analyzeZodField(name, schema, functionInfo) {
871
898
  baseSchema = baseSchema._zod.def.innerType;
872
899
  } else if (baseSchema instanceof z.ZodDefault) {
873
900
  required = false;
874
- defaultValue = baseSchema._zod.def.defaultValue();
901
+ const defValue = baseSchema._zod.def.defaultValue;
902
+ defaultValue = typeof defValue === "function" ? defValue() : defValue;
875
903
  baseSchema = baseSchema._zod.def.innerType;
876
904
  } else {
877
905
  const zodDef = baseSchema._zod?.def;
@@ -1021,6 +1049,16 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
1021
1049
  sdk2,
1022
1050
  functionInfo.name
1023
1051
  );
1052
+ const confirm = functionInfo.confirm;
1053
+ let confirmMessageAfter;
1054
+ if (confirm && !shouldUseJson) {
1055
+ const confirmResult = await promptConfirm(confirm);
1056
+ if (!confirmResult.confirmed) {
1057
+ console.log(chalk3.yellow("Operation cancelled."));
1058
+ return;
1059
+ }
1060
+ confirmMessageAfter = confirmResult.messageAfter;
1061
+ }
1024
1062
  if (isListCommand && hasPaginationParams && !shouldUseJson && !hasUserSpecifiedMaxItems) {
1025
1063
  const sdkObj = sdk2;
1026
1064
  const sdkIterator = sdkObj[functionInfo.name](resolvedParams);
@@ -1073,6 +1111,10 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
1073
1111
  } else {
1074
1112
  formatJsonOutput(items);
1075
1113
  }
1114
+ if (confirmMessageAfter) {
1115
+ console.log(chalk3.yellow(`
1116
+ ${confirmMessageAfter}`));
1117
+ }
1076
1118
  }
1077
1119
  } catch (error) {
1078
1120
  if (error instanceof Error && error.message.includes('"code"')) {
@@ -1620,7 +1662,7 @@ var LoginSchema = z.object({
1620
1662
 
1621
1663
  // package.json
1622
1664
  var package_default = {
1623
- version: "0.22.0"};
1665
+ version: "0.23.0"};
1624
1666
 
1625
1667
  // src/telemetry/builders.ts
1626
1668
  function createCliBaseEvent(context = {}) {
@@ -2901,7 +2943,7 @@ function createZapierCliSdk(options = {}) {
2901
2943
  // package.json with { type: 'json' }
2902
2944
  var package_default2 = {
2903
2945
  name: "@zapier/zapier-sdk-cli",
2904
- version: "0.22.0"};
2946
+ version: "0.23.0"};
2905
2947
  function detectPackageManager(cwd = process.cwd()) {
2906
2948
  const ua = process.env.npm_config_user_agent;
2907
2949
  if (ua) {
package/dist/index.cjs CHANGED
@@ -302,7 +302,7 @@ var LoginSchema = zod.z.object({
302
302
 
303
303
  // package.json
304
304
  var package_default = {
305
- version: "0.22.0"};
305
+ version: "0.23.0"};
306
306
 
307
307
  // src/telemetry/builders.ts
308
308
  function createCliBaseEvent(context = {}) {
package/dist/index.mjs CHANGED
@@ -271,7 +271,7 @@ var LoginSchema = z.object({
271
271
 
272
272
  // package.json
273
273
  var package_default = {
274
- version: "0.22.0"};
274
+ version: "0.23.0"};
275
275
 
276
276
  // src/telemetry/builders.ts
277
277
  function createCliBaseEvent(context = {}) {
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@zapier/zapier-sdk-cli",
3
+ "version": "0.23.0",
4
+ "description": "Command line interface for Zapier SDK",
5
+ "main": "dist/index.cjs",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "require": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.cjs"
13
+ },
14
+ "import": {
15
+ "types": "./dist/index.d.mts",
16
+ "default": "./dist/index.mjs"
17
+ }
18
+ }
19
+ },
20
+ "bin": {
21
+ "zapier-sdk": "./bin/zapier-sdk.mjs"
22
+ },
23
+ "scripts": {
24
+ "test": "vitest",
25
+ "build": "tsup",
26
+ "clean": "rm -rf dist",
27
+ "rebuild": "pnpm clean && pnpm build",
28
+ "dev": "tsx src/cli.ts",
29
+ "typecheck": "tsc --project tsconfig.build.json --noEmit",
30
+ "prepublishOnly": "node ../../scripts/check-version.js"
31
+ },
32
+ "keywords": [
33
+ "zapier",
34
+ "cli",
35
+ "sdk"
36
+ ],
37
+ "author": "",
38
+ "license": "SEE LICENSE IN LICENSE",
39
+ "files": [
40
+ "dist",
41
+ "bin",
42
+ "README.md",
43
+ "CHANGELOG.md"
44
+ ],
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "dependencies": {
49
+ "@zapier/zapier-sdk": "workspace:*",
50
+ "@zapier/zapier-sdk-cli-login": "workspace:*",
51
+ "@zapier/zapier-sdk-mcp": "workspace:*",
52
+ "chalk": "^5.3.0",
53
+ "cli-table3": "^0.6.5",
54
+ "commander": "^12.0.0",
55
+ "conf": "^14.0.0",
56
+ "esbuild": "^0.25.5",
57
+ "express": "^5.1.0",
58
+ "inquirer": "^12.6.3",
59
+ "is-installed-globally": "^1.0.0",
60
+ "jsonwebtoken": "^9.0.2",
61
+ "open": "^10.2.0",
62
+ "ora": "^8.2.0",
63
+ "package-json": "^10.0.1",
64
+ "pkce-challenge": "^5.0.0",
65
+ "semver": "^7.7.3",
66
+ "typescript": "^5.8.3",
67
+ "zod": "4.2.1"
68
+ },
69
+ "devDependencies": {
70
+ "@types/express": "^5.0.3",
71
+ "@types/inquirer": "^9.0.8",
72
+ "@types/jsonwebtoken": "^9.0.10",
73
+ "@types/node": "^24.0.1",
74
+ "@types/semver": "^7.7.1",
75
+ "tsup": "^8.5.0",
76
+ "vitest": "^3.2.3"
77
+ }
78
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+ import { Command, CommanderError } from "commander";
3
+ import { generateCliCommands } from "./utils/cli-generator";
4
+ import { createZapierCliSdk } from "./sdk";
5
+ import packageJson from "../package.json" with { type: "json" };
6
+ import { ZapierCliError } from "./utils/errors";
7
+ import { checkAndNotifyUpdates } from "./utils/version-checker";
8
+ const program = new Command();
9
+ program
10
+ .name("zapier-sdk")
11
+ .description("CLI for Zapier SDK")
12
+ .version(packageJson.version, "-v, --version", "display version number")
13
+ .option("--debug", "Enable debug logging")
14
+ .option("--base-url <url>", "Base URL for Zapier API endpoints")
15
+ .option("--credentials <token>", "Authentication token")
16
+ .option("--credentials-client-id <id>", "OAuth client ID for authentication")
17
+ .option("--credentials-client-secret <secret>", "OAuth client secret for authentication")
18
+ .option("--credentials-base-url <url>", "Base URL for authentication endpoints")
19
+ .option("--tracking-base-url <url>", "Base URL for Zapier tracking endpoints");
20
+ // Check for debug flag early (support both flag and env var)
21
+ const isDebugMode = process.env.DEBUG === "true" || process.argv.includes("--debug");
22
+ // Helper to get flag value from argv
23
+ function getFlagValue(flagName) {
24
+ const index = process.argv.indexOf(flagName);
25
+ return index !== -1 ? process.argv[index + 1] : undefined;
26
+ }
27
+ // Extract options from process.argv for early SDK creation
28
+ // We need to create the SDK before parsing to generate commands from schemas
29
+ const baseUrl = getFlagValue("--base-url");
30
+ const credentialsToken = getFlagValue("--credentials");
31
+ const credentialsClientId = getFlagValue("--credentials-client-id");
32
+ const credentialsClientSecret = getFlagValue("--credentials-client-secret");
33
+ const credentialsBaseUrl = getFlagValue("--credentials-base-url");
34
+ const trackingBaseUrl = getFlagValue("--tracking-base-url");
35
+ // Build credentials object from flags
36
+ function buildCredentialsFromFlags() {
37
+ // If a direct token is provided, use it
38
+ if (credentialsToken) {
39
+ return credentialsToken;
40
+ }
41
+ // If client ID is provided, build a credentials object
42
+ if (credentialsClientId) {
43
+ if (credentialsClientSecret) {
44
+ // Client credentials flow
45
+ return {
46
+ type: "client_credentials",
47
+ clientId: credentialsClientId,
48
+ clientSecret: credentialsClientSecret,
49
+ baseUrl: credentialsBaseUrl,
50
+ };
51
+ }
52
+ else {
53
+ // PKCE flow (no secret)
54
+ return {
55
+ type: "pkce",
56
+ clientId: credentialsClientId,
57
+ baseUrl: credentialsBaseUrl,
58
+ };
59
+ }
60
+ }
61
+ // No credentials from flags - will fall back to env vars or stored login
62
+ return undefined;
63
+ }
64
+ const credentials = buildCredentialsFromFlags();
65
+ // Create CLI SDK instance with all plugins and URL options
66
+ const sdk = createZapierCliSdk({
67
+ debug: isDebugMode,
68
+ credentials,
69
+ baseUrl,
70
+ trackingBaseUrl,
71
+ });
72
+ // Auth commands now handled by plugins
73
+ // Generate CLI commands from SDK schemas (including CLI plugins)
74
+ generateCliCommands(program, sdk);
75
+ // MCP command now handled by plugin
76
+ // Override Commander's default exit behavior to handle our custom errors
77
+ program.exitOverride();
78
+ (async () => {
79
+ let exitCode = 0;
80
+ // Start version checking non-blocking
81
+ const versionCheckPromise = checkAndNotifyUpdates({
82
+ packageName: packageJson.name,
83
+ currentVersion: packageJson.version,
84
+ });
85
+ try {
86
+ await program.parseAsync();
87
+ }
88
+ catch (error) {
89
+ if (error instanceof ZapierCliError) {
90
+ exitCode = error.exitCode;
91
+ }
92
+ else if (error instanceof CommanderError) {
93
+ exitCode = error.exitCode;
94
+ }
95
+ else {
96
+ // For any other unexpected errors, exit with code 1
97
+ console.error("Unexpected error:", error);
98
+ exitCode = 1;
99
+ }
100
+ }
101
+ // Wait for version checking to complete
102
+ await versionCheckPromise;
103
+ // Use exitCode instead of exit() to allow stdout to flush when piped
104
+ process.exitCode = exitCode;
105
+ })();
@@ -0,0 +1,41 @@
1
+ import type { GetSdkType, ListActionsPluginProvides, ListInputFieldsPluginProvides, ManifestPluginProvides, AppItem } from "@zapier/zapier-sdk";
2
+ interface GenerateTypesOptions {
3
+ app: AppItem;
4
+ authenticationId?: string | number;
5
+ }
6
+ /**
7
+ * AST-based TypeScript type generator using the TypeScript Compiler API
8
+ */
9
+ export declare class AstTypeGenerator {
10
+ private readonly factory;
11
+ private readonly printer;
12
+ /**
13
+ * Generate TypeScript types using AST for a specific app
14
+ */
15
+ generateTypes(options: GenerateTypesOptions & {
16
+ sdk: GetSdkType<ListActionsPluginProvides & ListInputFieldsPluginProvides & ManifestPluginProvides>;
17
+ }): Promise<string>;
18
+ private createSourceFile;
19
+ private createImportStatement;
20
+ private createTypeImportStatement;
21
+ private groupActionsByType;
22
+ private createInputInterface;
23
+ private createActionInterface;
24
+ private createAppProxyInterface;
25
+ private createFetchMethodProperty;
26
+ private createAppFactoryInterface;
27
+ private createAppWithFactoryType;
28
+ private createModuleAugmentation;
29
+ private mapFieldTypeToTypeNode;
30
+ private capitalize;
31
+ private sanitizeActionName;
32
+ private sanitizeFieldName;
33
+ private escapeComment;
34
+ private createPropertyName;
35
+ private isValidIdentifier;
36
+ private getPreferredProgrammaticKey;
37
+ private getPreferredAppName;
38
+ private sanitizeToIdentifier;
39
+ private getAllKeys;
40
+ }
41
+ export {};