@zapier/zapier-sdk-cli 0.22.1 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
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
+
3
16
  ## 0.22.1
4
17
 
5
18
  ### Patch Changes
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.1"};
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.1"};
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.1"};
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.1"};
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.1"};
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.1"};
274
+ version: "0.23.0"};
275
275
 
276
276
  // src/telemetry/builders.ts
277
277
  function createCliBaseEvent(context = {}) {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk-cli",
3
- "version": "0.22.1",
3
+ "version": "0.23.0",
4
4
  "description": "Command line interface for Zapier SDK",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -5,6 +5,32 @@ import { formatItemsFromSchema, formatJsonOutput } from "./schema-formatter";
5
5
  import chalk from "chalk";
6
6
  import inquirer from "inquirer";
7
7
  import { ZapierCliError, ZapierCliExitError } from "./errors";
8
+ const CONFIRM_MESSAGES = {
9
+ "create-secret": {
10
+ messageBefore: "You are about to create a sensitive secret that will be displayed as plain text.\n" +
11
+ "Once created, you cannot retrieve it again.",
12
+ messageAfter: "Please treat this secret like a password and store it securely!",
13
+ },
14
+ delete: {
15
+ messageBefore: "You are about to delete this record.",
16
+ },
17
+ };
18
+ async function promptConfirm(confirmType) {
19
+ if (!confirmType || !CONFIRM_MESSAGES[confirmType]) {
20
+ return { confirmed: true }; // No confirmation needed
21
+ }
22
+ const { messageBefore, messageAfter } = CONFIRM_MESSAGES[confirmType];
23
+ console.log(chalk.yellow(`\n${messageBefore}\n`));
24
+ const { confirmed } = await inquirer.prompt([
25
+ {
26
+ type: "confirm",
27
+ name: "confirmed",
28
+ message: "Continue?",
29
+ default: false,
30
+ },
31
+ ]);
32
+ return { confirmed, messageAfter };
33
+ }
8
34
  // ============================================================================
9
35
  // Schema Analysis
10
36
  // ============================================================================
@@ -39,7 +65,8 @@ function analyzeZodField(name, schema, functionInfo) {
39
65
  }
40
66
  else if (baseSchema instanceof z.ZodDefault) {
41
67
  required = false;
42
- defaultValue = baseSchema._zod.def.defaultValue();
68
+ const defValue = baseSchema._zod.def.defaultValue;
69
+ defaultValue = typeof defValue === "function" ? defValue() : defValue;
43
70
  baseSchema = baseSchema._zod.def.innerType;
44
71
  }
45
72
  else {
@@ -204,6 +231,17 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
204
231
  // Resolve missing parameters interactively using schema metadata
205
232
  const resolver = new SchemaParameterResolver();
206
233
  const resolvedParams = await resolver.resolveParameters(schema, rawParams, sdk, functionInfo.name);
234
+ // Check for confirmation before executing (skip for --json mode)
235
+ const confirm = functionInfo.confirm;
236
+ let confirmMessageAfter;
237
+ if (confirm && !shouldUseJson) {
238
+ const confirmResult = await promptConfirm(confirm);
239
+ if (!confirmResult.confirmed) {
240
+ console.log(chalk.yellow("Operation cancelled."));
241
+ return;
242
+ }
243
+ confirmMessageAfter = confirmResult.messageAfter;
244
+ }
207
245
  // Handle paginated list commands with async iteration
208
246
  if (isListCommand &&
209
247
  hasPaginationParams &&
@@ -260,6 +298,10 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
260
298
  else {
261
299
  formatJsonOutput(items);
262
300
  }
301
+ // Show message after operation completes
302
+ if (confirmMessageAfter) {
303
+ console.log(chalk.yellow(`\n${confirmMessageAfter}`));
304
+ }
263
305
  }
264
306
  }
265
307
  catch (error) {