@zapier/zapier-sdk-cli 0.36.3 → 0.37.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 +12 -0
- package/README.md +48 -41
- package/dist/cli.cjs +128 -27
- package/dist/cli.mjs +129 -28
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/package.json +1 -1
- package/dist/src/cli.js +28 -2
- package/dist/src/utils/parameter-resolver.js +111 -21
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @zapier/zapier-sdk-cli
|
|
2
2
|
|
|
3
|
+
## 0.37.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2906101: Default `listConnections` and `listTables` to only return your own items. Gate shared access and table deletion behind boolean flags: `canIncludeSharedConnections`, `canIncludeSharedTables`, `canDeleteTables`. Set via SDK options, `.zapierrc`, CLI flags (`--can-delete-tables`), or env vars (`ZAPIER_CAN_DELETE_TABLES=true`).
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [2906101]
|
|
12
|
+
- @zapier/zapier-sdk@0.38.0
|
|
13
|
+
- @zapier/zapier-sdk-mcp@0.10.3
|
|
14
|
+
|
|
3
15
|
## 0.36.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -129,6 +129,9 @@ These options are available for all commands:
|
|
|
129
129
|
| `--tracking-base-url <url>` | | Base URL for Zapier tracking endpoints. |
|
|
130
130
|
| `--max-network-retries <count>` | | Max retries for rate-limited requests (default: 3). |
|
|
131
131
|
| `--max-network-retry-delay-ms <ms>` | | Max delay in ms to wait for retry (default: 60000). |
|
|
132
|
+
| `--can-include-shared-connections` | | Allow listing shared connections. |
|
|
133
|
+
| `--can-include-shared-tables` | | Allow listing shared tables. |
|
|
134
|
+
| `--can-delete-tables` | | Allow deleting tables. |
|
|
132
135
|
| `--json` | | Output raw JSON instead of formatted results |
|
|
133
136
|
|
|
134
137
|
## Available Commands
|
|
@@ -405,19 +408,20 @@ Find the first connection matching the criteria
|
|
|
405
408
|
|
|
406
409
|
**Options:**
|
|
407
410
|
|
|
408
|
-
| Option
|
|
409
|
-
|
|
|
410
|
-
| `--search`
|
|
411
|
-
| `--title`
|
|
412
|
-
| `--owner`
|
|
413
|
-
| `--app-key`
|
|
414
|
-
| `--account-id`
|
|
415
|
-
| `--
|
|
411
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
412
|
+
| ------------------ | --------- | -------- | ------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
413
|
+
| `--search` | `string` | ❌ | — | — | Search term to filter connections by title |
|
|
414
|
+
| `--title` | `string` | ❌ | — | — | Filter connections by exact title match (searches first, then filters locally) |
|
|
415
|
+
| `--owner` | `string` | ❌ | — | — | Filter by owner, 'me' for your own connections or a specific user ID |
|
|
416
|
+
| `--app-key` | `string` | ❌ | — | — | App key of connections to list (e.g., 'SlackCLIAPI' or slug like 'github') |
|
|
417
|
+
| `--account-id` | `string` | ❌ | — | — | Account ID to filter by |
|
|
418
|
+
| `--include-shared` | `boolean` | ❌ | — | — | Include connections shared with you. By default, only your own connections are returned (owner=me). Set to true to also include shared connections. |
|
|
419
|
+
| `--is-expired` | `boolean` | ❌ | — | — | Filter by expired status |
|
|
416
420
|
|
|
417
421
|
**Usage:**
|
|
418
422
|
|
|
419
423
|
```bash
|
|
420
|
-
npx zapier-sdk find-first-connection [--search] [--title] [--owner] [--app-key] [--account-id] [--is-expired]
|
|
424
|
+
npx zapier-sdk find-first-connection [--search] [--title] [--owner] [--app-key] [--account-id] [--include-shared] [--is-expired]
|
|
421
425
|
```
|
|
422
426
|
|
|
423
427
|
#### `find-unique-connection`
|
|
@@ -426,19 +430,20 @@ Find a unique connection matching the criteria
|
|
|
426
430
|
|
|
427
431
|
**Options:**
|
|
428
432
|
|
|
429
|
-
| Option
|
|
430
|
-
|
|
|
431
|
-
| `--search`
|
|
432
|
-
| `--title`
|
|
433
|
-
| `--owner`
|
|
434
|
-
| `--app-key`
|
|
435
|
-
| `--account-id`
|
|
436
|
-
| `--
|
|
433
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
434
|
+
| ------------------ | --------- | -------- | ------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
435
|
+
| `--search` | `string` | ❌ | — | — | Search term to filter connections by title |
|
|
436
|
+
| `--title` | `string` | ❌ | — | — | Filter connections by exact title match (searches first, then filters locally) |
|
|
437
|
+
| `--owner` | `string` | ❌ | — | — | Filter by owner, 'me' for your own connections or a specific user ID |
|
|
438
|
+
| `--app-key` | `string` | ❌ | — | — | App key of connections to list (e.g., 'SlackCLIAPI' or slug like 'github') |
|
|
439
|
+
| `--account-id` | `string` | ❌ | — | — | Account ID to filter by |
|
|
440
|
+
| `--include-shared` | `boolean` | ❌ | — | — | Include connections shared with you. By default, only your own connections are returned (owner=me). Set to true to also include shared connections. |
|
|
441
|
+
| `--is-expired` | `boolean` | ❌ | — | — | Filter by expired status |
|
|
437
442
|
|
|
438
443
|
**Usage:**
|
|
439
444
|
|
|
440
445
|
```bash
|
|
441
|
-
npx zapier-sdk find-unique-connection [--search] [--title] [--owner] [--app-key] [--account-id] [--is-expired]
|
|
446
|
+
npx zapier-sdk find-unique-connection [--search] [--title] [--owner] [--app-key] [--account-id] [--include-shared] [--is-expired]
|
|
442
447
|
```
|
|
443
448
|
|
|
444
449
|
#### `get-connection`
|
|
@@ -463,23 +468,24 @@ List available connections with optional filtering
|
|
|
463
468
|
|
|
464
469
|
**Options:**
|
|
465
470
|
|
|
466
|
-
| Option | Type | Required | Default | Possible Values | Description
|
|
467
|
-
| ------------------ | --------- | -------- | ------- | --------------- |
|
|
468
|
-
| `--search` | `string` | ❌ | — | — | Search term to filter connections by title
|
|
469
|
-
| `--title` | `string` | ❌ | — | — | Filter connections by exact title match (searches first, then filters locally)
|
|
470
|
-
| `--owner` | `string` | ❌ | — | — | Filter by owner, 'me' for your own connections or a specific user ID
|
|
471
|
-
| `--app-key` | `string` | ❌ | — | — | App key of connections to list (e.g., 'SlackCLIAPI' or slug like 'github')
|
|
472
|
-
| `--connection-ids` | `array` | ❌ | — | — | List of connection IDs to filter by
|
|
473
|
-
| `--account-id` | `string` | ❌ | — | — | Account ID to filter by
|
|
474
|
-
| `--
|
|
475
|
-
| `--
|
|
476
|
-
| `--
|
|
477
|
-
| `--
|
|
471
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
472
|
+
| ------------------ | --------- | -------- | ------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
473
|
+
| `--search` | `string` | ❌ | — | — | Search term to filter connections by title |
|
|
474
|
+
| `--title` | `string` | ❌ | — | — | Filter connections by exact title match (searches first, then filters locally) |
|
|
475
|
+
| `--owner` | `string` | ❌ | — | — | Filter by owner, 'me' for your own connections or a specific user ID |
|
|
476
|
+
| `--app-key` | `string` | ❌ | — | — | App key of connections to list (e.g., 'SlackCLIAPI' or slug like 'github') |
|
|
477
|
+
| `--connection-ids` | `array` | ❌ | — | — | List of connection IDs to filter by |
|
|
478
|
+
| `--account-id` | `string` | ❌ | — | — | Account ID to filter by |
|
|
479
|
+
| `--include-shared` | `boolean` | ❌ | — | — | Include connections shared with you. By default, only your own connections are returned (owner=me). Set to true to also include shared connections. |
|
|
480
|
+
| `--is-expired` | `boolean` | ❌ | — | — | Filter by expired status |
|
|
481
|
+
| `--page-size` | `number` | ❌ | — | — | Number of connections per page |
|
|
482
|
+
| `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
483
|
+
| `--cursor` | `string` | ❌ | — | — | Cursor to start from |
|
|
478
484
|
|
|
479
485
|
**Usage:**
|
|
480
486
|
|
|
481
487
|
```bash
|
|
482
|
-
npx zapier-sdk list-connections [--search] [--title] [--owner] [--app-key] [--connection-ids] [--account-id] [--is-expired] [--page-size] [--max-items] [--cursor]
|
|
488
|
+
npx zapier-sdk list-connections [--search] [--title] [--owner] [--app-key] [--connection-ids] [--account-id] [--include-shared] [--is-expired] [--page-size] [--max-items] [--cursor]
|
|
483
489
|
```
|
|
484
490
|
|
|
485
491
|
### HTTP Requests
|
|
@@ -711,20 +717,21 @@ List tables available to the authenticated user
|
|
|
711
717
|
|
|
712
718
|
**Options:**
|
|
713
719
|
|
|
714
|
-
| Option
|
|
715
|
-
|
|
|
716
|
-
| `--table-ids`
|
|
717
|
-
| `--kind`
|
|
718
|
-
| `--search`
|
|
719
|
-
| `--owner`
|
|
720
|
-
| `--
|
|
721
|
-
| `--
|
|
722
|
-
| `--
|
|
720
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
721
|
+
| ------------------ | --------- | -------- | ------- | -------------------------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
722
|
+
| `--table-ids` | `array` | ❌ | — | — | Filter by specific table IDs |
|
|
723
|
+
| `--kind` | `string` | ❌ | — | `table`, `virtual_table`, `both` | Filter by table type |
|
|
724
|
+
| `--search` | `string` | ❌ | — | — | Search term to filter tables by name |
|
|
725
|
+
| `--owner` | `string` | ❌ | — | — | Filter by table owner. Use "me" for the current user, or a numeric user ID. Requires includeShared to be true. |
|
|
726
|
+
| `--include-shared` | `boolean` | ❌ | — | — | Include tables shared with you. Without this, only your own tables are returned. |
|
|
727
|
+
| `--page-size` | `number` | ❌ | — | — | Number of tables per page |
|
|
728
|
+
| `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
729
|
+
| `--cursor` | `string` | ❌ | — | — | Cursor to start from |
|
|
723
730
|
|
|
724
731
|
**Usage:**
|
|
725
732
|
|
|
726
733
|
```bash
|
|
727
|
-
npx zapier-sdk list-tables [--table-ids] [--kind] [--search] [--owner] [--page-size] [--max-items] [--cursor]
|
|
734
|
+
npx zapier-sdk list-tables [--table-ids] [--kind] [--search] [--owner] [--include-shared] [--page-size] [--max-items] [--cursor]
|
|
728
735
|
```
|
|
729
736
|
|
|
730
737
|
#### `update-table-records`
|
package/dist/cli.cjs
CHANGED
|
@@ -230,10 +230,13 @@ var SchemaParameterResolver = class {
|
|
|
230
230
|
const value = await this.resolveParameter(
|
|
231
231
|
param,
|
|
232
232
|
context,
|
|
233
|
-
functionName
|
|
233
|
+
functionName,
|
|
234
|
+
{ isOptional: !param.isRequired }
|
|
234
235
|
);
|
|
235
|
-
|
|
236
|
-
|
|
236
|
+
if (param.isRequired || value !== void 0) {
|
|
237
|
+
this.setNestedValue(resolvedParams, param.path, value);
|
|
238
|
+
context.resolvedParams = resolvedParams;
|
|
239
|
+
}
|
|
237
240
|
} catch (error) {
|
|
238
241
|
if (this.isUserCancellation(error)) {
|
|
239
242
|
console.log(chalk7__default.default.yellow("\n\nOperation cancelled by user"));
|
|
@@ -426,28 +429,104 @@ var SchemaParameterResolver = class {
|
|
|
426
429
|
context.sdk,
|
|
427
430
|
context.resolvedParams
|
|
428
431
|
);
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
432
|
+
let pageIterator = null;
|
|
433
|
+
let items;
|
|
434
|
+
let hasMore = false;
|
|
435
|
+
if (fetchResult != null && typeof fetchResult === "object" && Symbol.asyncIterator in fetchResult) {
|
|
436
|
+
pageIterator = fetchResult[Symbol.asyncIterator]();
|
|
437
|
+
const first = await pageIterator.next();
|
|
438
|
+
if (!first.done && first.value) {
|
|
439
|
+
items = first.value.data;
|
|
440
|
+
hasMore = first.value.nextCursor != null;
|
|
441
|
+
} else {
|
|
442
|
+
items = [];
|
|
443
|
+
}
|
|
444
|
+
} else if (fetchResult != null && typeof fetchResult === "object" && "data" in fetchResult) {
|
|
445
|
+
const page = fetchResult;
|
|
446
|
+
items = page.data;
|
|
447
|
+
hasMore = page.nextCursor != null;
|
|
448
|
+
if (hasMore) {
|
|
449
|
+
this.debugLog(
|
|
450
|
+
`Resolver for ${promptLabel} has more pages but no iterator. Use toIterable() to enable "Load more..." support.`
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
} else {
|
|
454
|
+
items = fetchResult || [];
|
|
455
|
+
pageIterator = null;
|
|
456
|
+
}
|
|
457
|
+
const LOAD_MORE_SENTINEL = Symbol("LOAD_MORE");
|
|
458
|
+
const SKIP_SENTINEL = Symbol("SKIP");
|
|
459
|
+
let newItemsStartIndex = -1;
|
|
435
460
|
this.stopSpinner();
|
|
436
|
-
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
461
|
+
while (true) {
|
|
462
|
+
const promptConfig = dynamicResolver.prompt(
|
|
463
|
+
items,
|
|
464
|
+
context.resolvedParams
|
|
465
|
+
);
|
|
466
|
+
promptConfig.name = promptName;
|
|
467
|
+
if (isOptional && promptConfig.choices) {
|
|
468
|
+
promptConfig.choices.unshift({
|
|
469
|
+
name: chalk7__default.default.dim("(Skip)"),
|
|
470
|
+
value: SKIP_SENTINEL
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
if (hasMore && pageIterator && promptConfig.choices) {
|
|
474
|
+
promptConfig.choices.push({
|
|
475
|
+
name: chalk7__default.default.dim("(Load more...)"),
|
|
476
|
+
value: LOAD_MORE_SENTINEL
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
if (!hasMore && promptConfig.choices && dynamicResolver.requireCapabilities) {
|
|
480
|
+
const capContext = context.sdk.getContext();
|
|
481
|
+
if (capContext.hasCapability) {
|
|
482
|
+
for (const cap of dynamicResolver.requireCapabilities) {
|
|
483
|
+
const enabled = await capContext.hasCapability(cap);
|
|
484
|
+
if (!enabled) {
|
|
485
|
+
promptConfig.choices.push({
|
|
486
|
+
name: chalk7__default.default.dim(zapierSdk.buildCapabilityMessage(cap)),
|
|
487
|
+
value: SKIP_SENTINEL,
|
|
488
|
+
disabled: true
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
if (newItemsStartIndex >= 0 && promptConfig.choices) {
|
|
495
|
+
const injectedBefore = isOptional ? 1 : 0;
|
|
496
|
+
const adjustedIndex = newItemsStartIndex + injectedBefore;
|
|
497
|
+
if (promptConfig.choices[adjustedIndex]) {
|
|
498
|
+
promptConfig.default = promptConfig.choices[adjustedIndex].value;
|
|
499
|
+
}
|
|
500
|
+
newItemsStartIndex = -1;
|
|
501
|
+
}
|
|
502
|
+
const answers = await inquirer__default.default.prompt([promptConfig]);
|
|
503
|
+
let selected = answers[promptName];
|
|
504
|
+
if (selected === SKIP_SENTINEL) {
|
|
445
505
|
return void 0;
|
|
446
506
|
}
|
|
447
|
-
|
|
507
|
+
const wantsMore = Array.isArray(selected) ? selected.includes(LOAD_MORE_SENTINEL) : selected === LOAD_MORE_SENTINEL;
|
|
508
|
+
if (wantsMore && pageIterator) {
|
|
509
|
+
if (Array.isArray(selected)) {
|
|
510
|
+
selected = selected.filter(
|
|
511
|
+
(v) => v !== LOAD_MORE_SENTINEL
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
const prevLength = items.length;
|
|
515
|
+
this.startSpinner();
|
|
516
|
+
this.debugLog("Fetching more options...");
|
|
517
|
+
const next = await pageIterator.next();
|
|
518
|
+
this.stopSpinner();
|
|
519
|
+
if (!next.done && next.value) {
|
|
520
|
+
items = [...items, ...next.value.data];
|
|
521
|
+
hasMore = next.value.nextCursor != null;
|
|
522
|
+
newItemsStartIndex = prevLength;
|
|
523
|
+
} else {
|
|
524
|
+
hasMore = false;
|
|
525
|
+
}
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
return selected;
|
|
448
529
|
}
|
|
449
|
-
const answers = await inquirer__default.default.prompt([promptConfig]);
|
|
450
|
-
return answers[promptName];
|
|
451
530
|
} else if (resolver.type === "fields") {
|
|
452
531
|
if (isOptional && !inArrayContext) {
|
|
453
532
|
this.stopSpinner();
|
|
@@ -1024,7 +1103,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
|
|
|
1024
1103
|
|
|
1025
1104
|
// package.json
|
|
1026
1105
|
var package_default = {
|
|
1027
|
-
version: "0.
|
|
1106
|
+
version: "0.37.0"};
|
|
1028
1107
|
|
|
1029
1108
|
// src/telemetry/builders.ts
|
|
1030
1109
|
function createCliBaseEvent(context = {}) {
|
|
@@ -4559,7 +4638,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
4559
4638
|
// package.json with { type: 'json' }
|
|
4560
4639
|
var package_default2 = {
|
|
4561
4640
|
name: "@zapier/zapier-sdk-cli",
|
|
4562
|
-
version: "0.
|
|
4641
|
+
version: "0.37.0"};
|
|
4563
4642
|
var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
|
|
4564
4643
|
var CACHE_RESET_INTERVAL_MS = (() => {
|
|
4565
4644
|
const { ZAPIER_SDK_UPDATE_CHECK_INTERVAL_MS = `${ONE_DAY_MS}` } = process.env;
|
|
@@ -4704,8 +4783,6 @@ async function checkAndNotifyUpdates({
|
|
|
4704
4783
|
const versionInfo = await checkForUpdates({ packageName, currentVersion });
|
|
4705
4784
|
displayUpdateNotification(versionInfo, packageName);
|
|
4706
4785
|
}
|
|
4707
|
-
|
|
4708
|
-
// src/cli.ts
|
|
4709
4786
|
var EXIT_GRACE_PERIOD_MS = 500;
|
|
4710
4787
|
var program = new commander.Command();
|
|
4711
4788
|
var versionOption = getReservedCliOption("version" /* Version */);
|
|
@@ -4726,7 +4803,24 @@ program.name("zapier-sdk").description("CLI for Zapier SDK").version(
|
|
|
4726
4803
|
).option(
|
|
4727
4804
|
"--max-network-retry-delay-ms <ms>",
|
|
4728
4805
|
"Max delay in ms to wait for rate limit retry (default: 60000)"
|
|
4729
|
-
)
|
|
4806
|
+
);
|
|
4807
|
+
var booleanFlags = [];
|
|
4808
|
+
for (const [key, fieldSchema] of Object.entries(
|
|
4809
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4810
|
+
zapierSdk.BaseSdkOptionsSchema.shape
|
|
4811
|
+
)) {
|
|
4812
|
+
let inner = fieldSchema;
|
|
4813
|
+
if (inner instanceof zod.z.ZodOptional) {
|
|
4814
|
+
inner = inner._zod.def.innerType;
|
|
4815
|
+
}
|
|
4816
|
+
if (inner instanceof zod.z.ZodBoolean && key !== "debug") {
|
|
4817
|
+
const kebab = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
4818
|
+
const description = fieldSchema._zod?.def?.description ?? "";
|
|
4819
|
+
booleanFlags.push({ camelName: key, kebabFlag: `--${kebab}` });
|
|
4820
|
+
program.option(`--${kebab}`, description);
|
|
4821
|
+
}
|
|
4822
|
+
}
|
|
4823
|
+
program.helpOption(
|
|
4730
4824
|
`${helpOption.short}, ${helpOption.flag}`,
|
|
4731
4825
|
helpOption.description
|
|
4732
4826
|
);
|
|
@@ -4768,13 +4862,20 @@ function buildCredentialsFromFlags() {
|
|
|
4768
4862
|
return void 0;
|
|
4769
4863
|
}
|
|
4770
4864
|
var credentials = buildCredentialsFromFlags();
|
|
4865
|
+
var flagOverrides = {};
|
|
4866
|
+
for (const { camelName, kebabFlag } of booleanFlags) {
|
|
4867
|
+
if (process.argv.includes(kebabFlag)) {
|
|
4868
|
+
flagOverrides[camelName] = true;
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4771
4871
|
var sdk = createZapierCliSdk({
|
|
4772
4872
|
debug: isDebugMode,
|
|
4773
4873
|
credentials,
|
|
4774
4874
|
baseUrl,
|
|
4775
4875
|
trackingBaseUrl,
|
|
4776
4876
|
maxNetworkRetries,
|
|
4777
|
-
maxNetworkRetryDelayMs
|
|
4877
|
+
maxNetworkRetryDelayMs,
|
|
4878
|
+
...flagOverrides
|
|
4778
4879
|
});
|
|
4779
4880
|
generateCliCommands(program, sdk);
|
|
4780
4881
|
program.exitOverride();
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command, CommanderError } from 'commander';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, injectCliLogin, createZapierSdkWithoutRegistry, registryPlugin, ZapierError, ZapierValidationError, ZapierUnknownError, batch, toSnakeCase, buildApplicationLifecycleEvent, isCredentialsObject, isPositional, runWithTelemetryContext, formatErrorMessage, getOsInfo, getPlatformVersions, getCiPlatform, isCi, getReleaseId, getCurrentTimestamp, generateEventId } from '@zapier/zapier-sdk';
|
|
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';
|
|
6
6
|
import chalk7 from 'chalk';
|
|
7
7
|
import ora from 'ora';
|
|
@@ -192,10 +192,13 @@ var SchemaParameterResolver = class {
|
|
|
192
192
|
const value = await this.resolveParameter(
|
|
193
193
|
param,
|
|
194
194
|
context,
|
|
195
|
-
functionName
|
|
195
|
+
functionName,
|
|
196
|
+
{ isOptional: !param.isRequired }
|
|
196
197
|
);
|
|
197
|
-
|
|
198
|
-
|
|
198
|
+
if (param.isRequired || value !== void 0) {
|
|
199
|
+
this.setNestedValue(resolvedParams, param.path, value);
|
|
200
|
+
context.resolvedParams = resolvedParams;
|
|
201
|
+
}
|
|
199
202
|
} catch (error) {
|
|
200
203
|
if (this.isUserCancellation(error)) {
|
|
201
204
|
console.log(chalk7.yellow("\n\nOperation cancelled by user"));
|
|
@@ -388,28 +391,104 @@ var SchemaParameterResolver = class {
|
|
|
388
391
|
context.sdk,
|
|
389
392
|
context.resolvedParams
|
|
390
393
|
);
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
394
|
+
let pageIterator = null;
|
|
395
|
+
let items;
|
|
396
|
+
let hasMore = false;
|
|
397
|
+
if (fetchResult != null && typeof fetchResult === "object" && Symbol.asyncIterator in fetchResult) {
|
|
398
|
+
pageIterator = fetchResult[Symbol.asyncIterator]();
|
|
399
|
+
const first = await pageIterator.next();
|
|
400
|
+
if (!first.done && first.value) {
|
|
401
|
+
items = first.value.data;
|
|
402
|
+
hasMore = first.value.nextCursor != null;
|
|
403
|
+
} else {
|
|
404
|
+
items = [];
|
|
405
|
+
}
|
|
406
|
+
} else if (fetchResult != null && typeof fetchResult === "object" && "data" in fetchResult) {
|
|
407
|
+
const page = fetchResult;
|
|
408
|
+
items = page.data;
|
|
409
|
+
hasMore = page.nextCursor != null;
|
|
410
|
+
if (hasMore) {
|
|
411
|
+
this.debugLog(
|
|
412
|
+
`Resolver for ${promptLabel} has more pages but no iterator. Use toIterable() to enable "Load more..." support.`
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
} else {
|
|
416
|
+
items = fetchResult || [];
|
|
417
|
+
pageIterator = null;
|
|
418
|
+
}
|
|
419
|
+
const LOAD_MORE_SENTINEL = Symbol("LOAD_MORE");
|
|
420
|
+
const SKIP_SENTINEL = Symbol("SKIP");
|
|
421
|
+
let newItemsStartIndex = -1;
|
|
397
422
|
this.stopSpinner();
|
|
398
|
-
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
423
|
+
while (true) {
|
|
424
|
+
const promptConfig = dynamicResolver.prompt(
|
|
425
|
+
items,
|
|
426
|
+
context.resolvedParams
|
|
427
|
+
);
|
|
428
|
+
promptConfig.name = promptName;
|
|
429
|
+
if (isOptional && promptConfig.choices) {
|
|
430
|
+
promptConfig.choices.unshift({
|
|
431
|
+
name: chalk7.dim("(Skip)"),
|
|
432
|
+
value: SKIP_SENTINEL
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
if (hasMore && pageIterator && promptConfig.choices) {
|
|
436
|
+
promptConfig.choices.push({
|
|
437
|
+
name: chalk7.dim("(Load more...)"),
|
|
438
|
+
value: LOAD_MORE_SENTINEL
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
if (!hasMore && promptConfig.choices && dynamicResolver.requireCapabilities) {
|
|
442
|
+
const capContext = context.sdk.getContext();
|
|
443
|
+
if (capContext.hasCapability) {
|
|
444
|
+
for (const cap of dynamicResolver.requireCapabilities) {
|
|
445
|
+
const enabled = await capContext.hasCapability(cap);
|
|
446
|
+
if (!enabled) {
|
|
447
|
+
promptConfig.choices.push({
|
|
448
|
+
name: chalk7.dim(buildCapabilityMessage(cap)),
|
|
449
|
+
value: SKIP_SENTINEL,
|
|
450
|
+
disabled: true
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
if (newItemsStartIndex >= 0 && promptConfig.choices) {
|
|
457
|
+
const injectedBefore = isOptional ? 1 : 0;
|
|
458
|
+
const adjustedIndex = newItemsStartIndex + injectedBefore;
|
|
459
|
+
if (promptConfig.choices[adjustedIndex]) {
|
|
460
|
+
promptConfig.default = promptConfig.choices[adjustedIndex].value;
|
|
461
|
+
}
|
|
462
|
+
newItemsStartIndex = -1;
|
|
463
|
+
}
|
|
464
|
+
const answers = await inquirer.prompt([promptConfig]);
|
|
465
|
+
let selected = answers[promptName];
|
|
466
|
+
if (selected === SKIP_SENTINEL) {
|
|
407
467
|
return void 0;
|
|
408
468
|
}
|
|
409
|
-
|
|
469
|
+
const wantsMore = Array.isArray(selected) ? selected.includes(LOAD_MORE_SENTINEL) : selected === LOAD_MORE_SENTINEL;
|
|
470
|
+
if (wantsMore && pageIterator) {
|
|
471
|
+
if (Array.isArray(selected)) {
|
|
472
|
+
selected = selected.filter(
|
|
473
|
+
(v) => v !== LOAD_MORE_SENTINEL
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
const prevLength = items.length;
|
|
477
|
+
this.startSpinner();
|
|
478
|
+
this.debugLog("Fetching more options...");
|
|
479
|
+
const next = await pageIterator.next();
|
|
480
|
+
this.stopSpinner();
|
|
481
|
+
if (!next.done && next.value) {
|
|
482
|
+
items = [...items, ...next.value.data];
|
|
483
|
+
hasMore = next.value.nextCursor != null;
|
|
484
|
+
newItemsStartIndex = prevLength;
|
|
485
|
+
} else {
|
|
486
|
+
hasMore = false;
|
|
487
|
+
}
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
return selected;
|
|
410
491
|
}
|
|
411
|
-
const answers = await inquirer.prompt([promptConfig]);
|
|
412
|
-
return answers[promptName];
|
|
413
492
|
} else if (resolver.type === "fields") {
|
|
414
493
|
if (isOptional && !inArrayContext) {
|
|
415
494
|
this.stopSpinner();
|
|
@@ -986,7 +1065,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
|
|
|
986
1065
|
|
|
987
1066
|
// package.json
|
|
988
1067
|
var package_default = {
|
|
989
|
-
version: "0.
|
|
1068
|
+
version: "0.37.0"};
|
|
990
1069
|
|
|
991
1070
|
// src/telemetry/builders.ts
|
|
992
1071
|
function createCliBaseEvent(context = {}) {
|
|
@@ -4521,7 +4600,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
4521
4600
|
// package.json with { type: 'json' }
|
|
4522
4601
|
var package_default2 = {
|
|
4523
4602
|
name: "@zapier/zapier-sdk-cli",
|
|
4524
|
-
version: "0.
|
|
4603
|
+
version: "0.37.0"};
|
|
4525
4604
|
var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
|
|
4526
4605
|
var CACHE_RESET_INTERVAL_MS = (() => {
|
|
4527
4606
|
const { ZAPIER_SDK_UPDATE_CHECK_INTERVAL_MS = `${ONE_DAY_MS}` } = process.env;
|
|
@@ -4666,8 +4745,6 @@ async function checkAndNotifyUpdates({
|
|
|
4666
4745
|
const versionInfo = await checkForUpdates({ packageName, currentVersion });
|
|
4667
4746
|
displayUpdateNotification(versionInfo, packageName);
|
|
4668
4747
|
}
|
|
4669
|
-
|
|
4670
|
-
// src/cli.ts
|
|
4671
4748
|
var EXIT_GRACE_PERIOD_MS = 500;
|
|
4672
4749
|
var program = new Command();
|
|
4673
4750
|
var versionOption = getReservedCliOption("version" /* Version */);
|
|
@@ -4688,7 +4765,24 @@ program.name("zapier-sdk").description("CLI for Zapier SDK").version(
|
|
|
4688
4765
|
).option(
|
|
4689
4766
|
"--max-network-retry-delay-ms <ms>",
|
|
4690
4767
|
"Max delay in ms to wait for rate limit retry (default: 60000)"
|
|
4691
|
-
)
|
|
4768
|
+
);
|
|
4769
|
+
var booleanFlags = [];
|
|
4770
|
+
for (const [key, fieldSchema] of Object.entries(
|
|
4771
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4772
|
+
BaseSdkOptionsSchema.shape
|
|
4773
|
+
)) {
|
|
4774
|
+
let inner = fieldSchema;
|
|
4775
|
+
if (inner instanceof z.ZodOptional) {
|
|
4776
|
+
inner = inner._zod.def.innerType;
|
|
4777
|
+
}
|
|
4778
|
+
if (inner instanceof z.ZodBoolean && key !== "debug") {
|
|
4779
|
+
const kebab = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
4780
|
+
const description = fieldSchema._zod?.def?.description ?? "";
|
|
4781
|
+
booleanFlags.push({ camelName: key, kebabFlag: `--${kebab}` });
|
|
4782
|
+
program.option(`--${kebab}`, description);
|
|
4783
|
+
}
|
|
4784
|
+
}
|
|
4785
|
+
program.helpOption(
|
|
4692
4786
|
`${helpOption.short}, ${helpOption.flag}`,
|
|
4693
4787
|
helpOption.description
|
|
4694
4788
|
);
|
|
@@ -4730,13 +4824,20 @@ function buildCredentialsFromFlags() {
|
|
|
4730
4824
|
return void 0;
|
|
4731
4825
|
}
|
|
4732
4826
|
var credentials = buildCredentialsFromFlags();
|
|
4827
|
+
var flagOverrides = {};
|
|
4828
|
+
for (const { camelName, kebabFlag } of booleanFlags) {
|
|
4829
|
+
if (process.argv.includes(kebabFlag)) {
|
|
4830
|
+
flagOverrides[camelName] = true;
|
|
4831
|
+
}
|
|
4832
|
+
}
|
|
4733
4833
|
var sdk = createZapierCliSdk({
|
|
4734
4834
|
debug: isDebugMode,
|
|
4735
4835
|
credentials,
|
|
4736
4836
|
baseUrl,
|
|
4737
4837
|
trackingBaseUrl,
|
|
4738
4838
|
maxNetworkRetries,
|
|
4739
|
-
maxNetworkRetryDelayMs
|
|
4839
|
+
maxNetworkRetryDelayMs,
|
|
4840
|
+
...flagOverrides
|
|
4740
4841
|
});
|
|
4741
4842
|
generateCliCommands(program, sdk);
|
|
4742
4843
|
program.exitOverride();
|
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED