@zapier/zapier-sdk-cli 0.48.2 → 0.49.1
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 +25 -0
- package/README.md +10 -9
- package/dist/cli.cjs +543 -198
- package/dist/cli.mjs +541 -197
- package/dist/experimental.cjs +1 -1
- package/dist/experimental.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/package.json +2 -1
- package/dist/src/utils/parameter-resolver.d.ts +91 -1
- package/dist/src/utils/parameter-resolver.js +570 -129
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
package/dist/cli.cjs
CHANGED
|
@@ -5,7 +5,8 @@ var commander = require('commander');
|
|
|
5
5
|
var zod = require('zod');
|
|
6
6
|
var zapierSdk = require('@zapier/zapier-sdk');
|
|
7
7
|
var inquirer = require('inquirer');
|
|
8
|
-
var
|
|
8
|
+
var search = require('@inquirer/search');
|
|
9
|
+
var chalk = require('chalk');
|
|
9
10
|
var ora = require('ora');
|
|
10
11
|
var util = require('util');
|
|
11
12
|
var wrapAnsi = require('wrap-ansi');
|
|
@@ -54,7 +55,8 @@ function _interopNamespace(e) {
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
var inquirer__default = /*#__PURE__*/_interopDefault(inquirer);
|
|
57
|
-
var
|
|
58
|
+
var search__default = /*#__PURE__*/_interopDefault(search);
|
|
59
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
58
60
|
var ora__default = /*#__PURE__*/_interopDefault(ora);
|
|
59
61
|
var util__default = /*#__PURE__*/_interopDefault(util);
|
|
60
62
|
var wrapAnsi__default = /*#__PURE__*/_interopDefault(wrapAnsi);
|
|
@@ -184,7 +186,7 @@ var SchemaParameterResolver = class {
|
|
|
184
186
|
debugLog(message) {
|
|
185
187
|
if (this.debug) {
|
|
186
188
|
this.stopSpinner();
|
|
187
|
-
console.log(
|
|
189
|
+
console.log(chalk__default.default.gray(`[Zapier CLI] ${message}`));
|
|
188
190
|
}
|
|
189
191
|
}
|
|
190
192
|
startSpinner() {
|
|
@@ -211,14 +213,8 @@ var SchemaParameterResolver = class {
|
|
|
211
213
|
const hasValue = this.getNestedValue(providedParams, param.path) !== void 0;
|
|
212
214
|
return !hasValue;
|
|
213
215
|
});
|
|
214
|
-
const required = missingResolvable.filter((param) =>
|
|
215
|
-
|
|
216
|
-
if (param.name === "inputs") return interactiveMode;
|
|
217
|
-
return false;
|
|
218
|
-
});
|
|
219
|
-
const optional = missingResolvable.filter(
|
|
220
|
-
(param) => !required.includes(param)
|
|
221
|
-
);
|
|
216
|
+
const required = missingResolvable.filter((param) => param.isRequired);
|
|
217
|
+
const optional = missingResolvable.filter((param) => !param.isRequired);
|
|
222
218
|
if (parseResult.success && required.length === 0 && optional.length === 0) {
|
|
223
219
|
return parseResult.data;
|
|
224
220
|
}
|
|
@@ -275,7 +271,7 @@ var SchemaParameterResolver = class {
|
|
|
275
271
|
}
|
|
276
272
|
} catch (error) {
|
|
277
273
|
if (this.isUserCancellation(error)) {
|
|
278
|
-
console.log(
|
|
274
|
+
console.log(chalk__default.default.yellow("\n\nOperation cancelled by user"));
|
|
279
275
|
throw new ZapierCliUserCancellationError();
|
|
280
276
|
}
|
|
281
277
|
throw error;
|
|
@@ -312,7 +308,7 @@ var SchemaParameterResolver = class {
|
|
|
312
308
|
}
|
|
313
309
|
} catch (error) {
|
|
314
310
|
if (this.isUserCancellation(error)) {
|
|
315
|
-
console.log(
|
|
311
|
+
console.log(chalk__default.default.yellow("\n\nOperation cancelled by user"));
|
|
316
312
|
throw new ZapierCliUserCancellationError();
|
|
317
313
|
}
|
|
318
314
|
throw error;
|
|
@@ -423,6 +419,237 @@ var SchemaParameterResolver = class {
|
|
|
423
419
|
throw new ZapierCliMissingParametersError(missingParams);
|
|
424
420
|
}
|
|
425
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* Wrap a PromptConfig.validate so internal sentinels (Symbols) bypass
|
|
424
|
+
* it. The resolver's validator is intended for actual user values; our
|
|
425
|
+
* Skip / Custom / Load-more sentinels are internal control-flow and
|
|
426
|
+
* should pass through. Returns `undefined` when the resolver didn't
|
|
427
|
+
* supply a validator (so `await search({ ...rest })` doesn't get a
|
|
428
|
+
* pass-through identity function).
|
|
429
|
+
*/
|
|
430
|
+
wrapPromptValidate(validate) {
|
|
431
|
+
if (!validate) return void 0;
|
|
432
|
+
return (value) => typeof value === "symbol" ? true : validate(value);
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Apply a PromptConfig.filter to a selected value, but only when the
|
|
436
|
+
* value is a real data choice (not an internal sentinel). @inquirer/search
|
|
437
|
+
* has no built-in filter hook, so the search-backed paths call this
|
|
438
|
+
* explicitly before returning.
|
|
439
|
+
*/
|
|
440
|
+
applyPromptFilter(filter, value) {
|
|
441
|
+
if (!filter || typeof value === "symbol") return value;
|
|
442
|
+
return filter(value);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* If the resolver's PromptConfig sets a `default` value, move the
|
|
446
|
+
* matching choice to the front so it's the first selectable item in
|
|
447
|
+
* the rendered source. @inquirer/search has no built-in `default`
|
|
448
|
+
* option; first-selectable is what Enter picks, so reordering achieves
|
|
449
|
+
* the same semantics inquirer.prompt's list had natively.
|
|
450
|
+
*
|
|
451
|
+
* Returns the original array if no default is set or the default
|
|
452
|
+
* doesn't match any current choice.
|
|
453
|
+
*/
|
|
454
|
+
reorderForDefault(matches, defaultValue) {
|
|
455
|
+
if (defaultValue === void 0) return matches;
|
|
456
|
+
const idx = matches.findIndex((c) => c.value === defaultValue);
|
|
457
|
+
if (idx <= 0) return matches;
|
|
458
|
+
return [matches[idx], ...matches.slice(0, idx), ...matches.slice(idx + 1)];
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Build the disabled "if you had X capability, more results would show"
|
|
462
|
+
* hints for any unmet capabilities the resolver declared. Returns the
|
|
463
|
+
* raw hint strings — callers wrap them into choice objects with whatever
|
|
464
|
+
* sentinel value they prefer (disabled choices' values are inert).
|
|
465
|
+
*/
|
|
466
|
+
async computeCapabilityHints(resolver, context) {
|
|
467
|
+
if (!resolver.requireCapabilities) return [];
|
|
468
|
+
const capContext = context.sdk.context;
|
|
469
|
+
if (!capContext.hasCapability) return [];
|
|
470
|
+
const messages = [];
|
|
471
|
+
for (const cap of resolver.requireCapabilities) {
|
|
472
|
+
const enabled = await capContext.hasCapability(cap);
|
|
473
|
+
if (!enabled) messages.push(zapierSdk.buildCapabilityMessage(cap));
|
|
474
|
+
}
|
|
475
|
+
return messages;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Unpack a DynamicResolver.fetch result into the three shapes the caller
|
|
479
|
+
* cares about: a flat items array, an optional AsyncIterator for further
|
|
480
|
+
* pagination, and a hasMore flag. Centralizing keeps the AsyncIterable /
|
|
481
|
+
* `{data, nextCursor}` / `TItem[]` discrimination in one place — both
|
|
482
|
+
* the main dropdown loop and the search-mode flow consume it.
|
|
483
|
+
*
|
|
484
|
+
* The function is `async` for the AsyncIterable branch only (we eagerly
|
|
485
|
+
* consume the first page so callers don't have to discriminate). The
|
|
486
|
+
* other two branches return synchronously; an explicit Promise.resolve
|
|
487
|
+
* is unnecessary because async automatically wraps.
|
|
488
|
+
*
|
|
489
|
+
* Note: callers in search mode intentionally drop `pageIterator` /
|
|
490
|
+
* `hasMore` because each search() invocation re-prompts from scratch;
|
|
491
|
+
* pagination only matters when the prompt is the dropdown itself.
|
|
492
|
+
*/
|
|
493
|
+
async unpackFetchResult(fetchResult, promptLabel) {
|
|
494
|
+
if (fetchResult != null && typeof fetchResult === "object" && Symbol.asyncIterator in fetchResult) {
|
|
495
|
+
const pageIterator = fetchResult[Symbol.asyncIterator]();
|
|
496
|
+
const first = await pageIterator.next();
|
|
497
|
+
if (!first.done && first.value) {
|
|
498
|
+
return {
|
|
499
|
+
items: Array.isArray(first.value.data) ? first.value.data : [],
|
|
500
|
+
pageIterator,
|
|
501
|
+
hasMore: first.value.nextCursor != null
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
return { items: [], pageIterator, hasMore: false };
|
|
505
|
+
}
|
|
506
|
+
if (fetchResult != null && typeof fetchResult === "object" && "data" in fetchResult) {
|
|
507
|
+
const page = fetchResult;
|
|
508
|
+
const hasMore = page.nextCursor != null;
|
|
509
|
+
if (hasMore) {
|
|
510
|
+
this.debugLog(
|
|
511
|
+
`Resolver for ${promptLabel} has more pages but no iterator. Use toIterable() to enable "Load more..." support.`
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
return {
|
|
515
|
+
items: Array.isArray(page.data) ? page.data : [],
|
|
516
|
+
pageIterator: null,
|
|
517
|
+
hasMore
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
return {
|
|
521
|
+
items: Array.isArray(fetchResult) ? fetchResult : [],
|
|
522
|
+
pageIterator: null,
|
|
523
|
+
hasMore: false
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Search-mode dynamic resolver: prompts the user for free-form text, passes
|
|
528
|
+
* it to fetch via `search`, and either short-circuits on a primitive return
|
|
529
|
+
* (exact match) or renders the results as a search-filterable dropdown.
|
|
530
|
+
* Empty results still render the dropdown so the user can fall through to
|
|
531
|
+
* "(Use 'foo' as-is)" or "(Try a different search)" rather than being
|
|
532
|
+
* stuck.
|
|
533
|
+
*
|
|
534
|
+
* Known limitation: pagination beyond the first page is dropped. Each
|
|
535
|
+
* search() invocation re-prompts from scratch and the user is expected
|
|
536
|
+
* to refine their query if too many results came back. If a future
|
|
537
|
+
* high-cardinality search resolver needs Load-more here, the
|
|
538
|
+
* `pageIterator` / `hasMore` from `unpackFetchResult` is what to wire in.
|
|
539
|
+
*/
|
|
540
|
+
async resolveDynamicWithSearchInput({
|
|
541
|
+
resolver,
|
|
542
|
+
context,
|
|
543
|
+
promptLabel,
|
|
544
|
+
isOptional
|
|
545
|
+
}) {
|
|
546
|
+
const parenParts = [];
|
|
547
|
+
if (isOptional) parenParts.push("optional");
|
|
548
|
+
if (resolver.placeholder) parenParts.push(resolver.placeholder);
|
|
549
|
+
const parens = parenParts.length > 0 ? ` (${parenParts.join(", ")})` : "";
|
|
550
|
+
const message = `Enter or search ${promptLabel}${parens}:`;
|
|
551
|
+
const SKIP_SENTINEL = Symbol("SKIP");
|
|
552
|
+
const USE_AS_IS_SENTINEL = Symbol("USE_AS_IS");
|
|
553
|
+
const TRY_AGAIN_SENTINEL = Symbol("TRY_AGAIN");
|
|
554
|
+
let lastNote;
|
|
555
|
+
while (true) {
|
|
556
|
+
this.stopSpinner();
|
|
557
|
+
if (lastNote) {
|
|
558
|
+
console.log(chalk__default.default.yellow(lastNote));
|
|
559
|
+
lastNote = void 0;
|
|
560
|
+
}
|
|
561
|
+
const answers = await inquirer__default.default.prompt([
|
|
562
|
+
{ type: "input", name: "search", message }
|
|
563
|
+
]);
|
|
564
|
+
const rawInput = answers.search;
|
|
565
|
+
const searchInput = typeof rawInput === "string" ? rawInput.trim() : "";
|
|
566
|
+
if (!searchInput) {
|
|
567
|
+
if (isOptional) return void 0;
|
|
568
|
+
lastNote = `${promptLabel} is required.`;
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
571
|
+
const searchParams = {
|
|
572
|
+
...context.resolvedParams,
|
|
573
|
+
search: searchInput
|
|
574
|
+
};
|
|
575
|
+
this.startSpinner();
|
|
576
|
+
this.debugLog(`Searching ${promptLabel} for "${searchInput}"`);
|
|
577
|
+
let fetchResult;
|
|
578
|
+
try {
|
|
579
|
+
fetchResult = await resolver.fetch(context.sdk, searchParams);
|
|
580
|
+
} finally {
|
|
581
|
+
this.stopSpinner();
|
|
582
|
+
}
|
|
583
|
+
if (typeof fetchResult === "string" || typeof fetchResult === "number") {
|
|
584
|
+
return fetchResult;
|
|
585
|
+
}
|
|
586
|
+
const { items } = await this.unpackFetchResult(fetchResult, promptLabel);
|
|
587
|
+
const choicesConfig = resolver.prompt(items, searchParams);
|
|
588
|
+
const dataChoices = choicesConfig.choices ?? [];
|
|
589
|
+
const capabilityHintMessages = await this.computeCapabilityHints(
|
|
590
|
+
resolver,
|
|
591
|
+
context
|
|
592
|
+
);
|
|
593
|
+
const selected = await search__default.default({
|
|
594
|
+
message: choicesConfig.message,
|
|
595
|
+
validate: this.wrapPromptValidate(choicesConfig.validate),
|
|
596
|
+
// @inquirer/search passes an AbortSignal as the second arg for
|
|
597
|
+
// cancelling async sources. All three of our source callbacks are
|
|
598
|
+
// pure-local (filter an already-fetched array), so we intentionally
|
|
599
|
+
// ignore the signal. A future server-side filter implementation
|
|
600
|
+
// would need to honor it.
|
|
601
|
+
source: (term) => {
|
|
602
|
+
const trimmed = (term ?? "").trim();
|
|
603
|
+
const lower = trimmed.toLowerCase();
|
|
604
|
+
const matches = trimmed ? dataChoices.filter((c) => c.name.toLowerCase().includes(lower)) : dataChoices;
|
|
605
|
+
const orderedMatches = trimmed ? matches : this.reorderForDefault(matches, choicesConfig.default);
|
|
606
|
+
const skipChoice = isOptional ? [{ name: chalk__default.default.dim("(Skip)"), value: SKIP_SENTINEL }] : [];
|
|
607
|
+
const useAsIsChoice = {
|
|
608
|
+
name: chalk__default.default.dim(`(Use ${JSON.stringify(searchInput)} as-is)`),
|
|
609
|
+
value: USE_AS_IS_SENTINEL
|
|
610
|
+
};
|
|
611
|
+
const tryAgainChoice = {
|
|
612
|
+
name: chalk__default.default.dim("(Try a different search)"),
|
|
613
|
+
value: TRY_AGAIN_SENTINEL
|
|
614
|
+
};
|
|
615
|
+
const out = [];
|
|
616
|
+
if (orderedMatches.length === 0) {
|
|
617
|
+
out.push(useAsIsChoice);
|
|
618
|
+
out.push(tryAgainChoice);
|
|
619
|
+
out.push(...skipChoice);
|
|
620
|
+
} else {
|
|
621
|
+
out.push(...orderedMatches);
|
|
622
|
+
out.push(...skipChoice);
|
|
623
|
+
out.push(useAsIsChoice);
|
|
624
|
+
out.push(tryAgainChoice);
|
|
625
|
+
}
|
|
626
|
+
for (const message2 of capabilityHintMessages) {
|
|
627
|
+
out.push({
|
|
628
|
+
name: chalk__default.default.dim(message2),
|
|
629
|
+
value: SKIP_SENTINEL,
|
|
630
|
+
disabled: true
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
return out;
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
if (selected === SKIP_SENTINEL) return void 0;
|
|
637
|
+
if (selected === USE_AS_IS_SENTINEL) {
|
|
638
|
+
const validationResult = choicesConfig.validate?.(searchInput);
|
|
639
|
+
if (validationResult === false) {
|
|
640
|
+
lastNote = `${promptLabel}: invalid value.`;
|
|
641
|
+
continue;
|
|
642
|
+
}
|
|
643
|
+
if (typeof validationResult === "string") {
|
|
644
|
+
lastNote = validationResult;
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
return this.applyPromptFilter(choicesConfig.filter, searchInput);
|
|
648
|
+
}
|
|
649
|
+
if (selected === TRY_AGAIN_SENTINEL) continue;
|
|
650
|
+
return this.applyPromptFilter(choicesConfig.filter, selected);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
426
653
|
async resolveParameter(param, context, functionName, options) {
|
|
427
654
|
const resolver = this.getResolver(
|
|
428
655
|
param.name,
|
|
@@ -436,6 +663,27 @@ var SchemaParameterResolver = class {
|
|
|
436
663
|
isOptional: options?.isOptional
|
|
437
664
|
});
|
|
438
665
|
}
|
|
666
|
+
/**
|
|
667
|
+
* Run a resolver to obtain a value for one parameter, prompting the
|
|
668
|
+
* user when necessary. Routes to one of several prompt backends and
|
|
669
|
+
* has to keep the `PromptConfig` contract honest across each one.
|
|
670
|
+
*
|
|
671
|
+
* `PromptConfig` field × prompt-backend handling:
|
|
672
|
+
*
|
|
673
|
+
* | field | list (search()) | checkbox/confirm (inquirer.prompt) | search-mode dropdown (search()) |
|
|
674
|
+
* | -------- | --------------- | ---------------------------------- | ------------------------------- |
|
|
675
|
+
* | type | required | required | required |
|
|
676
|
+
* | name | (set internally)| forwarded | (set internally) |
|
|
677
|
+
* | message | forwarded | forwarded | forwarded |
|
|
678
|
+
* | choices | filtered in src | passed to inquirer | filtered in src |
|
|
679
|
+
* | default | reorder matches | passed (also internal cursor jump) | reorder matches |
|
|
680
|
+
* | validate | wrapped | passed (inquirer native) | wrapped + manual for (Use as-is)|
|
|
681
|
+
* | filter | manual once | inquirer native (do NOT double) | manual once |
|
|
682
|
+
*
|
|
683
|
+
* Escape-hatch sentinels (Skip / Custom value / Use as-is / Load more
|
|
684
|
+
* / Try again) bypass the resolver's validate/filter because they
|
|
685
|
+
* aren't real user values — they're CLI control-flow.
|
|
686
|
+
*/
|
|
439
687
|
async resolveWithResolver(resolver, param, context, options = {}) {
|
|
440
688
|
const { arrayIndex, isOptional } = options;
|
|
441
689
|
const inArrayContext = arrayIndex != null;
|
|
@@ -474,41 +722,52 @@ var SchemaParameterResolver = class {
|
|
|
474
722
|
this.stopSpinner();
|
|
475
723
|
return autoResolution.resolvedValue;
|
|
476
724
|
}
|
|
725
|
+
if (dynamicResolver.inputType === "search") {
|
|
726
|
+
this.stopSpinner();
|
|
727
|
+
return await this.resolveDynamicWithSearchInput({
|
|
728
|
+
resolver: dynamicResolver,
|
|
729
|
+
context,
|
|
730
|
+
promptLabel,
|
|
731
|
+
isOptional: isOptional ?? false
|
|
732
|
+
});
|
|
733
|
+
}
|
|
477
734
|
this.debugLog(`Fetching options for ${promptLabel}`);
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
735
|
+
let fetchResult;
|
|
736
|
+
try {
|
|
737
|
+
fetchResult = await dynamicResolver.fetch(
|
|
738
|
+
context.sdk,
|
|
739
|
+
context.resolvedParams
|
|
740
|
+
);
|
|
741
|
+
} finally {
|
|
742
|
+
this.stopSpinner();
|
|
743
|
+
}
|
|
744
|
+
if (typeof fetchResult === "string" || typeof fetchResult === "number") {
|
|
745
|
+
console.error(
|
|
746
|
+
chalk__default.default.yellow(
|
|
747
|
+
`Resolver for ${promptLabel} returned a primitive value but is not in search mode. Set inputType: "search" on the resolver if you want exact-match short-circuit. Falling back to manual entry.`
|
|
748
|
+
)
|
|
749
|
+
);
|
|
750
|
+
const fallbackAnswers = await inquirer__default.default.prompt([
|
|
751
|
+
{
|
|
752
|
+
type: "input",
|
|
753
|
+
name: promptName,
|
|
754
|
+
message: `Enter ${promptLabel}${isOptional ? " (optional)" : ""}:`
|
|
755
|
+
}
|
|
756
|
+
]);
|
|
757
|
+
const fallbackValue = fallbackAnswers[promptName];
|
|
758
|
+
if (isOptional && (fallbackValue === void 0 || fallbackValue === "")) {
|
|
759
|
+
return void 0;
|
|
502
760
|
}
|
|
503
|
-
|
|
504
|
-
items = fetchResult || [];
|
|
505
|
-
pageIterator = null;
|
|
761
|
+
return fallbackValue;
|
|
506
762
|
}
|
|
763
|
+
const unpacked = await this.unpackFetchResult(fetchResult, promptLabel);
|
|
764
|
+
let pageIterator = unpacked.pageIterator;
|
|
765
|
+
let items = unpacked.items;
|
|
766
|
+
let hasMore = unpacked.hasMore;
|
|
507
767
|
const LOAD_MORE_SENTINEL = Symbol("LOAD_MORE");
|
|
508
768
|
const SKIP_SENTINEL = Symbol("SKIP");
|
|
509
769
|
const CUSTOM_VALUE_SENTINEL = Symbol("CUSTOM_VALUE");
|
|
510
770
|
let newItemsStartIndex = -1;
|
|
511
|
-
this.stopSpinner();
|
|
512
771
|
while (true) {
|
|
513
772
|
const promptConfig = dynamicResolver.prompt(
|
|
514
773
|
items,
|
|
@@ -523,50 +782,97 @@ var SchemaParameterResolver = class {
|
|
|
523
782
|
`No ${promptLabel} available to select.`
|
|
524
783
|
);
|
|
525
784
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
if (hasMore && pageIterator && promptConfig.choices) {
|
|
540
|
-
promptConfig.choices.push({
|
|
541
|
-
name: chalk7__default.default.dim("(Load more...)"),
|
|
542
|
-
value: LOAD_MORE_SENTINEL
|
|
543
|
-
});
|
|
785
|
+
const capabilityHints = [];
|
|
786
|
+
if (!hasMore) {
|
|
787
|
+
const hintMessages = await this.computeCapabilityHints(
|
|
788
|
+
dynamicResolver,
|
|
789
|
+
context
|
|
790
|
+
);
|
|
791
|
+
for (const message of hintMessages) {
|
|
792
|
+
capabilityHints.push({
|
|
793
|
+
name: chalk__default.default.dim(message),
|
|
794
|
+
value: SKIP_SENTINEL,
|
|
795
|
+
disabled: true
|
|
796
|
+
});
|
|
797
|
+
}
|
|
544
798
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
799
|
+
let selected;
|
|
800
|
+
if (promptConfig.type === "list") {
|
|
801
|
+
const dataChoices = promptConfig.choices ?? [];
|
|
802
|
+
selected = await search__default.default({
|
|
803
|
+
message: promptConfig.message,
|
|
804
|
+
validate: this.wrapPromptValidate(promptConfig.validate),
|
|
805
|
+
source: (term) => {
|
|
806
|
+
const trimmed = (term ?? "").trim();
|
|
807
|
+
const lower = trimmed.toLowerCase();
|
|
808
|
+
const matches = trimmed ? dataChoices.filter(
|
|
809
|
+
(c) => c.name.toLowerCase().includes(lower)
|
|
810
|
+
) : dataChoices;
|
|
811
|
+
const out = [];
|
|
812
|
+
const skipChoice = isOptional ? [
|
|
813
|
+
{
|
|
814
|
+
name: chalk__default.default.dim("(Skip)"),
|
|
815
|
+
value: SKIP_SENTINEL
|
|
816
|
+
}
|
|
817
|
+
] : [];
|
|
818
|
+
const customValueChoice = {
|
|
819
|
+
name: chalk__default.default.dim("(Enter custom value)"),
|
|
820
|
+
value: CUSTOM_VALUE_SENTINEL
|
|
821
|
+
};
|
|
822
|
+
const orderedMatches = trimmed ? matches : this.reorderForDefault(matches, promptConfig.default);
|
|
823
|
+
const matchesFirst = trimmed || promptConfig.default !== void 0;
|
|
824
|
+
const loadMoreChoice = hasMore && pageIterator ? {
|
|
825
|
+
name: chalk__default.default.dim("(Load more...)"),
|
|
826
|
+
value: LOAD_MORE_SENTINEL
|
|
827
|
+
} : null;
|
|
828
|
+
if (matchesFirst && orderedMatches.length > 0) {
|
|
829
|
+
out.push(...orderedMatches);
|
|
830
|
+
out.push(...skipChoice);
|
|
831
|
+
out.push(customValueChoice);
|
|
832
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
833
|
+
} else if (matchesFirst) {
|
|
834
|
+
out.push(customValueChoice);
|
|
835
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
836
|
+
out.push(...skipChoice);
|
|
837
|
+
} else {
|
|
838
|
+
out.push(...skipChoice);
|
|
839
|
+
out.push(customValueChoice);
|
|
840
|
+
out.push(...orderedMatches);
|
|
841
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
556
842
|
}
|
|
843
|
+
if (capabilityHints.length > 0 && (!trimmed || matches.length > 0)) {
|
|
844
|
+
out.push(...capabilityHints);
|
|
845
|
+
}
|
|
846
|
+
return out;
|
|
557
847
|
}
|
|
848
|
+
});
|
|
849
|
+
} else {
|
|
850
|
+
if (isOptional && promptConfig.choices) {
|
|
851
|
+
promptConfig.choices.unshift({
|
|
852
|
+
name: chalk__default.default.dim("(Skip)"),
|
|
853
|
+
value: SKIP_SENTINEL
|
|
854
|
+
});
|
|
558
855
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
promptConfig.default = promptConfig.choices[adjustedIndex].value;
|
|
856
|
+
if (hasMore && pageIterator && promptConfig.choices) {
|
|
857
|
+
promptConfig.choices.push({
|
|
858
|
+
name: chalk__default.default.dim("(Load more...)"),
|
|
859
|
+
value: LOAD_MORE_SENTINEL
|
|
860
|
+
});
|
|
565
861
|
}
|
|
566
|
-
|
|
862
|
+
if (capabilityHints.length > 0 && promptConfig.choices) {
|
|
863
|
+
promptConfig.choices.push(...capabilityHints);
|
|
864
|
+
}
|
|
865
|
+
if (newItemsStartIndex >= 0 && promptConfig.choices) {
|
|
866
|
+
const injectedBefore = isOptional ? 1 : 0;
|
|
867
|
+
const adjustedIndex = newItemsStartIndex + injectedBefore;
|
|
868
|
+
if (promptConfig.choices[adjustedIndex]) {
|
|
869
|
+
promptConfig.default = promptConfig.choices[adjustedIndex].value;
|
|
870
|
+
}
|
|
871
|
+
newItemsStartIndex = -1;
|
|
872
|
+
}
|
|
873
|
+
const answers = await inquirer__default.default.prompt([promptConfig]);
|
|
874
|
+
selected = answers[promptName];
|
|
567
875
|
}
|
|
568
|
-
const answers = await inquirer__default.default.prompt([promptConfig]);
|
|
569
|
-
let selected = answers[promptName];
|
|
570
876
|
if (selected === SKIP_SENTINEL) {
|
|
571
877
|
return void 0;
|
|
572
878
|
}
|
|
@@ -605,7 +911,7 @@ var SchemaParameterResolver = class {
|
|
|
605
911
|
}
|
|
606
912
|
continue;
|
|
607
913
|
}
|
|
608
|
-
return selected;
|
|
914
|
+
return promptConfig.type === "list" ? this.applyPromptFilter(promptConfig.filter, selected) : selected;
|
|
609
915
|
}
|
|
610
916
|
} else if (resolver.type === "fields") {
|
|
611
917
|
if (isOptional && !inArrayContext) {
|
|
@@ -663,7 +969,7 @@ var SchemaParameterResolver = class {
|
|
|
663
969
|
if (!rootFieldItems || rootFieldItems.length === 0) {
|
|
664
970
|
if (iteration === 1) {
|
|
665
971
|
console.log(
|
|
666
|
-
|
|
972
|
+
chalk__default.default.yellow(`No input fields required for this action.`)
|
|
667
973
|
);
|
|
668
974
|
}
|
|
669
975
|
break;
|
|
@@ -686,7 +992,7 @@ var SchemaParameterResolver = class {
|
|
|
686
992
|
}
|
|
687
993
|
if (iteration >= maxIterations) {
|
|
688
994
|
console.log(
|
|
689
|
-
|
|
995
|
+
chalk__default.default.yellow(
|
|
690
996
|
`
|
|
691
997
|
\u26A0\uFE0F Maximum field resolution iterations reached. Some dynamic fields may not have been discovered.`
|
|
692
998
|
)
|
|
@@ -737,7 +1043,7 @@ var SchemaParameterResolver = class {
|
|
|
737
1043
|
};
|
|
738
1044
|
}
|
|
739
1045
|
if (items.length >= maxItems) {
|
|
740
|
-
console.log(
|
|
1046
|
+
console.log(chalk__default.default.gray(`Maximum of ${maxItems} items reached.`));
|
|
741
1047
|
}
|
|
742
1048
|
return items;
|
|
743
1049
|
}
|
|
@@ -755,7 +1061,7 @@ var SchemaParameterResolver = class {
|
|
|
755
1061
|
const fieldsetTitle = typedItem.title || typedItem.key;
|
|
756
1062
|
const pathDisplay = fieldsetPath.length > 0 ? ` (in ${fieldsetPath.join(" > ")})` : "";
|
|
757
1063
|
console.log(
|
|
758
|
-
|
|
1064
|
+
chalk__default.default.cyan(
|
|
759
1065
|
`
|
|
760
1066
|
\u{1F4C1} Processing fieldset: ${fieldsetTitle}${pathDisplay}`
|
|
761
1067
|
)
|
|
@@ -823,7 +1129,7 @@ var SchemaParameterResolver = class {
|
|
|
823
1129
|
}
|
|
824
1130
|
} else {
|
|
825
1131
|
console.log(
|
|
826
|
-
|
|
1132
|
+
chalk__default.default.gray(
|
|
827
1133
|
`
|
|
828
1134
|
There are ${optionalFields.length} ${iteration === 1 ? "" : "additional "}optional field(s) available${pathContext}.`
|
|
829
1135
|
)
|
|
@@ -838,7 +1144,7 @@ There are ${optionalFields.length} ${iteration === 1 ? "" : "additional "}option
|
|
|
838
1144
|
}
|
|
839
1145
|
]);
|
|
840
1146
|
if (shouldConfigureOptional.configure) {
|
|
841
|
-
console.log(
|
|
1147
|
+
console.log(chalk__default.default.cyan(`
|
|
842
1148
|
Optional fields${pathContext}:`));
|
|
843
1149
|
for (const field of optionalFields) {
|
|
844
1150
|
await this.promptForField(field, targetInputs, context);
|
|
@@ -854,7 +1160,7 @@ Optional fields${pathContext}:`));
|
|
|
854
1160
|
}
|
|
855
1161
|
} catch (error) {
|
|
856
1162
|
if (this.isUserCancellation(error)) {
|
|
857
|
-
console.log(
|
|
1163
|
+
console.log(chalk__default.default.yellow("\n\nOperation cancelled by user"));
|
|
858
1164
|
throw new ZapierCliUserCancellationError();
|
|
859
1165
|
}
|
|
860
1166
|
throw error;
|
|
@@ -930,7 +1236,7 @@ Optional fields${pathContext}:`));
|
|
|
930
1236
|
}));
|
|
931
1237
|
if (choices.length === 0 && !cursor) {
|
|
932
1238
|
console.log(
|
|
933
|
-
|
|
1239
|
+
chalk__default.default.yellow(`No choices available for ${fieldMeta.title}`)
|
|
934
1240
|
);
|
|
935
1241
|
}
|
|
936
1242
|
return {
|
|
@@ -940,14 +1246,17 @@ Optional fields${pathContext}:`));
|
|
|
940
1246
|
} catch (error) {
|
|
941
1247
|
this.stopSpinner();
|
|
942
1248
|
console.warn(
|
|
943
|
-
|
|
1249
|
+
chalk__default.default.yellow(`Failed to fetch choices for ${fieldMeta.title}:`),
|
|
944
1250
|
error
|
|
945
1251
|
);
|
|
946
1252
|
return { choices: [] };
|
|
947
1253
|
}
|
|
948
1254
|
}
|
|
949
1255
|
/**
|
|
950
|
-
* Prompt user with choices (handles both single and multi-select with pagination)
|
|
1256
|
+
* Prompt user with choices (handles both single and multi-select with pagination).
|
|
1257
|
+
* Single-select goes through @inquirer/search so users can type-to-filter long
|
|
1258
|
+
* dropdowns (SELECT fields); multi-select stays on inquirer.prompt since search
|
|
1259
|
+
* is single-select only.
|
|
951
1260
|
*/
|
|
952
1261
|
async promptWithChoices({
|
|
953
1262
|
fieldMeta,
|
|
@@ -960,45 +1269,81 @@ Optional fields${pathContext}:`));
|
|
|
960
1269
|
const choices = [...initialChoices];
|
|
961
1270
|
let nextCursor = initialCursor;
|
|
962
1271
|
const LOAD_MORE_SENTINEL = Symbol("LOAD_MORE");
|
|
1272
|
+
const SKIP_SENTINEL = Symbol("SKIP");
|
|
963
1273
|
const CUSTOM_VALUE_SENTINEL = Symbol("CUSTOM_VALUE");
|
|
1274
|
+
const message = `${fieldMeta.title}${fieldMeta.isRequired ? " (required)" : " (optional)"}:`;
|
|
964
1275
|
while (true) {
|
|
965
|
-
|
|
966
|
-
name: choice.label,
|
|
967
|
-
value: choice.value
|
|
968
|
-
}));
|
|
1276
|
+
let selectedValue;
|
|
969
1277
|
if (!fieldMeta.isMultiSelect) {
|
|
970
|
-
|
|
971
|
-
name:
|
|
972
|
-
value:
|
|
973
|
-
});
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1278
|
+
const dataChoices = choices.map((c) => ({
|
|
1279
|
+
name: c.label,
|
|
1280
|
+
value: c.value
|
|
1281
|
+
}));
|
|
1282
|
+
selectedValue = await search__default.default({
|
|
1283
|
+
message,
|
|
1284
|
+
source: (term) => {
|
|
1285
|
+
const trimmed = (term ?? "").trim();
|
|
1286
|
+
const lower = trimmed.toLowerCase();
|
|
1287
|
+
const matches = trimmed ? dataChoices.filter((c) => c.name.toLowerCase().includes(lower)) : dataChoices;
|
|
1288
|
+
const out = [];
|
|
1289
|
+
const skipChoice = !fieldMeta.isRequired ? [{ name: chalk__default.default.dim("(Skip)"), value: SKIP_SENTINEL }] : [];
|
|
1290
|
+
const customValueChoice = {
|
|
1291
|
+
name: chalk__default.default.dim("(Enter custom value)"),
|
|
1292
|
+
value: CUSTOM_VALUE_SENTINEL
|
|
1293
|
+
};
|
|
1294
|
+
const loadMoreChoice = nextCursor && context ? {
|
|
1295
|
+
name: chalk__default.default.dim("(Load more...)"),
|
|
1296
|
+
value: LOAD_MORE_SENTINEL
|
|
1297
|
+
} : null;
|
|
1298
|
+
if (trimmed && matches.length > 0) {
|
|
1299
|
+
out.push(...matches);
|
|
1300
|
+
out.push(...skipChoice);
|
|
1301
|
+
out.push(customValueChoice);
|
|
1302
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
1303
|
+
} else if (trimmed) {
|
|
1304
|
+
out.push(customValueChoice);
|
|
1305
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
1306
|
+
out.push(...skipChoice);
|
|
1307
|
+
} else {
|
|
1308
|
+
out.push(...skipChoice);
|
|
1309
|
+
out.push(customValueChoice);
|
|
1310
|
+
out.push(...matches);
|
|
1311
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
1312
|
+
}
|
|
1313
|
+
return out;
|
|
1314
|
+
}
|
|
979
1315
|
});
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
1316
|
+
if (selectedValue === SKIP_SENTINEL) {
|
|
1317
|
+
return void 0;
|
|
1318
|
+
}
|
|
1319
|
+
if (selectedValue === CUSTOM_VALUE_SENTINEL) {
|
|
1320
|
+
return await this.promptFreeForm(fieldMeta);
|
|
1321
|
+
}
|
|
1322
|
+
} else {
|
|
1323
|
+
const promptChoices = choices.map((c) => ({
|
|
1324
|
+
name: c.label,
|
|
1325
|
+
value: c.value
|
|
1326
|
+
}));
|
|
1327
|
+
if (nextCursor) {
|
|
1328
|
+
promptChoices.push({
|
|
1329
|
+
name: chalk__default.default.dim("(Load more...)"),
|
|
1330
|
+
value: LOAD_MORE_SENTINEL
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
const promptConfig = {
|
|
1334
|
+
type: "checkbox",
|
|
1335
|
+
name: fieldMeta.key,
|
|
1336
|
+
message,
|
|
1337
|
+
choices: promptChoices,
|
|
990
1338
|
validate: (input) => {
|
|
991
1339
|
if (fieldMeta.isRequired && (!input || input.length === 0)) {
|
|
992
1340
|
return "At least one selection is required";
|
|
993
1341
|
}
|
|
994
1342
|
return true;
|
|
995
1343
|
}
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
let selectedValue = answer[fieldMeta.key];
|
|
1000
|
-
if (selectedValue === CUSTOM_VALUE_SENTINEL) {
|
|
1001
|
-
return await this.promptFreeForm(fieldMeta);
|
|
1344
|
+
};
|
|
1345
|
+
const answer = await inquirer__default.default.prompt([promptConfig]);
|
|
1346
|
+
selectedValue = answer[fieldMeta.key];
|
|
1002
1347
|
}
|
|
1003
1348
|
const wantsMore = fieldMeta.isMultiSelect ? Array.isArray(selectedValue) && selectedValue.includes(LOAD_MORE_SENTINEL) : selectedValue === LOAD_MORE_SENTINEL;
|
|
1004
1349
|
if (wantsMore && nextCursor && context) {
|
|
@@ -1061,7 +1406,7 @@ Optional fields${pathContext}:`));
|
|
|
1061
1406
|
};
|
|
1062
1407
|
}
|
|
1063
1408
|
if (fieldMeta.description) {
|
|
1064
|
-
promptConfig.prefix =
|
|
1409
|
+
promptConfig.prefix = chalk__default.default.gray(`\u2139 ${fieldMeta.description}
|
|
1065
1410
|
`);
|
|
1066
1411
|
}
|
|
1067
1412
|
try {
|
|
@@ -1069,7 +1414,7 @@ Optional fields${pathContext}:`));
|
|
|
1069
1414
|
return answer[fieldMeta.key];
|
|
1070
1415
|
} catch (error) {
|
|
1071
1416
|
if (this.isUserCancellation(error)) {
|
|
1072
|
-
console.log(
|
|
1417
|
+
console.log(chalk__default.default.yellow("\n\nOperation cancelled by user"));
|
|
1073
1418
|
throw new ZapierCliUserCancellationError();
|
|
1074
1419
|
}
|
|
1075
1420
|
throw error;
|
|
@@ -1087,7 +1432,7 @@ Optional fields${pathContext}:`));
|
|
|
1087
1432
|
}
|
|
1088
1433
|
} catch (error) {
|
|
1089
1434
|
if (this.isUserCancellation(error)) {
|
|
1090
|
-
console.log(
|
|
1435
|
+
console.log(chalk__default.default.yellow("\n\nOperation cancelled by user"));
|
|
1091
1436
|
throw new ZapierCliUserCancellationError();
|
|
1092
1437
|
}
|
|
1093
1438
|
throw error;
|
|
@@ -1210,7 +1555,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
|
|
|
1210
1555
|
|
|
1211
1556
|
// package.json
|
|
1212
1557
|
var package_default = {
|
|
1213
|
-
version: "0.
|
|
1558
|
+
version: "0.49.1"};
|
|
1214
1559
|
|
|
1215
1560
|
// src/telemetry/builders.ts
|
|
1216
1561
|
function createCliBaseEvent(context = {}) {
|
|
@@ -1295,7 +1640,7 @@ async function formatItemsFromSchema(functionInfo, items, startingNumber = 0, op
|
|
|
1295
1640
|
});
|
|
1296
1641
|
}
|
|
1297
1642
|
function formatSingleItem(formatted, itemNumber) {
|
|
1298
|
-
let titleLine = `${
|
|
1643
|
+
let titleLine = `${chalk__default.default.gray(`${itemNumber + 1}.`)} ${chalk__default.default.cyan(formatted.title)}`;
|
|
1299
1644
|
const subtitleParts = [];
|
|
1300
1645
|
if (formatted.keys) {
|
|
1301
1646
|
subtitleParts.push(...formatted.keys);
|
|
@@ -1307,11 +1652,11 @@ function formatSingleItem(formatted, itemNumber) {
|
|
|
1307
1652
|
}
|
|
1308
1653
|
const uniqueParts = [...new Set(subtitleParts)];
|
|
1309
1654
|
if (uniqueParts.length > 0) {
|
|
1310
|
-
titleLine += ` ${
|
|
1655
|
+
titleLine += ` ${chalk__default.default.gray(`(${uniqueParts.join(", ")})`)}`;
|
|
1311
1656
|
}
|
|
1312
1657
|
console.log(titleLine);
|
|
1313
1658
|
if (formatted.description) {
|
|
1314
|
-
console.log(` ${
|
|
1659
|
+
console.log(` ${chalk__default.default.dim(formatted.description)}`);
|
|
1315
1660
|
}
|
|
1316
1661
|
if (formatted.data !== void 0) {
|
|
1317
1662
|
formatJsonOutput(formatted.data);
|
|
@@ -1322,7 +1667,7 @@ function formatSingleItem(formatted, itemNumber) {
|
|
|
1322
1667
|
if (detail.label) {
|
|
1323
1668
|
const isMultiline = detail.text.includes("\n");
|
|
1324
1669
|
if (isMultiline) {
|
|
1325
|
-
console.log(` ${
|
|
1670
|
+
console.log(` ${chalk__default.default.gray(detail.label + ":")}`);
|
|
1326
1671
|
const displayText = formatDetailText(
|
|
1327
1672
|
detail.text,
|
|
1328
1673
|
DETAIL_INDENT + " "
|
|
@@ -1331,7 +1676,7 @@ function formatSingleItem(formatted, itemNumber) {
|
|
|
1331
1676
|
console.log(`${DETAIL_INDENT} ${styledText}`);
|
|
1332
1677
|
} else {
|
|
1333
1678
|
const styledValue = applyStyle(detail.text, detail.style);
|
|
1334
|
-
console.log(` ${
|
|
1679
|
+
console.log(` ${chalk__default.default.gray(detail.label + ":")} ${styledValue}`);
|
|
1335
1680
|
}
|
|
1336
1681
|
} else {
|
|
1337
1682
|
const displayText = formatDetailText(detail.text, DETAIL_INDENT);
|
|
@@ -1355,16 +1700,16 @@ function formatDetailText(text, indent = DETAIL_INDENT) {
|
|
|
1355
1700
|
function applyStyle(value, style) {
|
|
1356
1701
|
switch (style) {
|
|
1357
1702
|
case "dim":
|
|
1358
|
-
return
|
|
1703
|
+
return chalk__default.default.dim(value);
|
|
1359
1704
|
case "accent":
|
|
1360
|
-
return
|
|
1705
|
+
return chalk__default.default.magenta(value);
|
|
1361
1706
|
case "warning":
|
|
1362
|
-
return
|
|
1707
|
+
return chalk__default.default.red(value);
|
|
1363
1708
|
case "success":
|
|
1364
|
-
return
|
|
1709
|
+
return chalk__default.default.green(value);
|
|
1365
1710
|
case "normal":
|
|
1366
1711
|
default:
|
|
1367
|
-
return
|
|
1712
|
+
return chalk__default.default.blue(value);
|
|
1368
1713
|
}
|
|
1369
1714
|
}
|
|
1370
1715
|
function convertGenericItemToFormattedItem(item) {
|
|
@@ -1496,10 +1841,10 @@ function renderItemsForDisplay(items, functionInfo, startingNumber = 0) {
|
|
|
1496
1841
|
const obj = item;
|
|
1497
1842
|
const name = obj?.name || obj?.key || obj?.id || "Item";
|
|
1498
1843
|
console.log(
|
|
1499
|
-
`${
|
|
1844
|
+
`${chalk__default.default.gray(`${startingNumber + index + 1}.`)} ${chalk__default.default.cyan(String(name))}`
|
|
1500
1845
|
);
|
|
1501
1846
|
if (obj?.description)
|
|
1502
|
-
console.log(` ${
|
|
1847
|
+
console.log(` ${chalk__default.default.dim(String(obj.description))}`);
|
|
1503
1848
|
console.log();
|
|
1504
1849
|
});
|
|
1505
1850
|
}
|
|
@@ -1511,35 +1856,35 @@ function createInteractiveRenderer() {
|
|
|
1511
1856
|
if (!(Symbol.asyncIterator in Object(source))) {
|
|
1512
1857
|
const items = source?.data;
|
|
1513
1858
|
if (!Array.isArray(items) || items.length === 0) {
|
|
1514
|
-
console.log(
|
|
1859
|
+
console.log(chalk__default.default.yellow(`No ${itemName} found.`));
|
|
1515
1860
|
return;
|
|
1516
1861
|
}
|
|
1517
1862
|
renderItemsForDisplay(items, functionInfo, 0);
|
|
1518
|
-
console.log(
|
|
1863
|
+
console.log(chalk__default.default.green(`
|
|
1519
1864
|
\u2705 Showing ${items.length} ${itemName}`));
|
|
1520
1865
|
return;
|
|
1521
1866
|
}
|
|
1522
1867
|
let totalShown = 0;
|
|
1523
1868
|
let pageCount = 0;
|
|
1524
|
-
console.log(
|
|
1869
|
+
console.log(chalk__default.default.blue(`\u{1F4CB} ${getListTitle(functionInfo)}
|
|
1525
1870
|
`));
|
|
1526
1871
|
for await (const page of source) {
|
|
1527
1872
|
const items = page.data ?? [];
|
|
1528
1873
|
pageCount++;
|
|
1529
1874
|
if (items.length === 0 && pageCount === 1) {
|
|
1530
|
-
console.log(
|
|
1875
|
+
console.log(chalk__default.default.yellow(`No ${itemName} found.`));
|
|
1531
1876
|
return;
|
|
1532
1877
|
}
|
|
1533
1878
|
if (items.length === 0) break;
|
|
1534
1879
|
if (pageCount > 1) {
|
|
1535
1880
|
console.clear();
|
|
1536
|
-
console.log(
|
|
1881
|
+
console.log(chalk__default.default.blue(`\u{1F4CB} ${getListTitle(functionInfo)}
|
|
1537
1882
|
`));
|
|
1538
1883
|
}
|
|
1539
1884
|
renderItemsForDisplay(items, functionInfo, totalShown);
|
|
1540
1885
|
totalShown += items.length;
|
|
1541
1886
|
console.log(
|
|
1542
|
-
|
|
1887
|
+
chalk__default.default.green(
|
|
1543
1888
|
`
|
|
1544
1889
|
\u2705 Showing ${totalShown} ${itemName} (page ${pageCount})`
|
|
1545
1890
|
)
|
|
@@ -1558,7 +1903,7 @@ function createInteractiveRenderer() {
|
|
|
1558
1903
|
break;
|
|
1559
1904
|
}
|
|
1560
1905
|
}
|
|
1561
|
-
console.log(
|
|
1906
|
+
console.log(chalk__default.default.gray(`
|
|
1562
1907
|
\u{1F4C4} Finished browsing ${itemName}`));
|
|
1563
1908
|
},
|
|
1564
1909
|
renderCollectedList(items, { maxItems, userSpecifiedMaxItems, functionInfo } = {}) {
|
|
@@ -1568,30 +1913,30 @@ function createInteractiveRenderer() {
|
|
|
1568
1913
|
}
|
|
1569
1914
|
const itemName = getItemName(functionInfo);
|
|
1570
1915
|
if (items.length === 0) {
|
|
1571
|
-
console.log(
|
|
1916
|
+
console.log(chalk__default.default.yellow(`No ${itemName} found.`));
|
|
1572
1917
|
return;
|
|
1573
1918
|
}
|
|
1574
|
-
console.log(
|
|
1919
|
+
console.log(chalk__default.default.green(`
|
|
1575
1920
|
\u2705 Found ${items.length} ${itemName}:
|
|
1576
1921
|
`));
|
|
1577
1922
|
renderItemsForDisplay(items, functionInfo);
|
|
1578
1923
|
if (userSpecifiedMaxItems && maxItems) {
|
|
1579
1924
|
console.log(
|
|
1580
|
-
|
|
1925
|
+
chalk__default.default.gray(
|
|
1581
1926
|
`
|
|
1582
1927
|
\u{1F4C4} Showing up to ${maxItems} ${itemName} (--max-items ${maxItems})`
|
|
1583
1928
|
)
|
|
1584
1929
|
);
|
|
1585
1930
|
} else {
|
|
1586
|
-
console.log(
|
|
1931
|
+
console.log(chalk__default.default.gray(`
|
|
1587
1932
|
\u{1F4C4} All available ${itemName} shown`));
|
|
1588
1933
|
}
|
|
1589
1934
|
},
|
|
1590
1935
|
renderItem(value, options) {
|
|
1591
1936
|
if (options?.outputFile) {
|
|
1592
1937
|
const label = options.commandName ? `\u2705 ${options.commandName} completed successfully!` : "\u2705 Done!";
|
|
1593
|
-
console.log(
|
|
1594
|
-
console.log(
|
|
1938
|
+
console.log(chalk__default.default.green(label));
|
|
1939
|
+
console.log(chalk__default.default.gray(`Output written to: ${options.outputFile}`));
|
|
1595
1940
|
} else {
|
|
1596
1941
|
formatJsonOutput(value);
|
|
1597
1942
|
}
|
|
@@ -1601,17 +1946,17 @@ function createInteractiveRenderer() {
|
|
|
1601
1946
|
},
|
|
1602
1947
|
renderError(error) {
|
|
1603
1948
|
if (error instanceof ZapierCliMissingParametersError) {
|
|
1604
|
-
console.error(
|
|
1605
|
-
console.error("\n" +
|
|
1949
|
+
console.error(chalk__default.default.red("\u274C " + formatMissingParamsError(error)));
|
|
1950
|
+
console.error("\n" + chalk__default.default.dim("Use --help to see available options"));
|
|
1606
1951
|
throw new ZapierCliExitError(error.message, 1);
|
|
1607
1952
|
}
|
|
1608
1953
|
if (error instanceof zapierSdk.ZapierError) {
|
|
1609
1954
|
const formattedMessage = zapierSdk.formatErrorMessage(error);
|
|
1610
|
-
console.error(
|
|
1955
|
+
console.error(chalk__default.default.red("\u274C Error:"), formattedMessage);
|
|
1611
1956
|
throw new ZapierCliExitError(formattedMessage, 1);
|
|
1612
1957
|
}
|
|
1613
1958
|
const msg = error instanceof Error ? error.message : "Unknown error";
|
|
1614
|
-
console.error(
|
|
1959
|
+
console.error(chalk__default.default.red("\u274C Error:"), msg);
|
|
1615
1960
|
throw new ZapierCliExitError(msg, 1);
|
|
1616
1961
|
}
|
|
1617
1962
|
};
|
|
@@ -1721,7 +2066,7 @@ async function promptConfirm(confirmType, itemType) {
|
|
|
1721
2066
|
}
|
|
1722
2067
|
const configOrFn = CONFIRM_MESSAGES[confirmType];
|
|
1723
2068
|
const { messageBefore, messageAfter } = typeof configOrFn === "function" ? configOrFn(itemType) : configOrFn;
|
|
1724
|
-
console.log(
|
|
2069
|
+
console.log(chalk__default.default.yellow(`
|
|
1725
2070
|
${messageBefore}
|
|
1726
2071
|
`));
|
|
1727
2072
|
const { confirmed } = await inquirer__default.default.prompt([
|
|
@@ -1743,9 +2088,9 @@ function emitDeprecationWarning({
|
|
|
1743
2088
|
}
|
|
1744
2089
|
console.warn();
|
|
1745
2090
|
console.warn(
|
|
1746
|
-
|
|
2091
|
+
chalk__default.default.yellow.bold("\u26A0\uFE0F DEPRECATION WARNING") + chalk__default.default.yellow(` - \`${cliCommandName}\` is deprecated.`)
|
|
1747
2092
|
);
|
|
1748
|
-
console.warn(
|
|
2093
|
+
console.warn(chalk__default.default.yellow(` ${deprecation.message}`));
|
|
1749
2094
|
console.warn();
|
|
1750
2095
|
}
|
|
1751
2096
|
function emitParamDeprecationWarnings({
|
|
@@ -1759,12 +2104,12 @@ function emitParamDeprecationWarnings({
|
|
|
1759
2104
|
if (Array.isArray(value) && value.length === 0) continue;
|
|
1760
2105
|
console.warn();
|
|
1761
2106
|
console.warn(
|
|
1762
|
-
|
|
2107
|
+
chalk__default.default.yellow.bold("\u26A0\uFE0F DEPRECATION WARNING") + chalk__default.default.yellow(
|
|
1763
2108
|
` - \`${toKebabCase(param.name)}\` is deprecated and may be removed in a future release.`
|
|
1764
2109
|
)
|
|
1765
2110
|
);
|
|
1766
2111
|
if (param.deprecationMessage) {
|
|
1767
|
-
console.warn(
|
|
2112
|
+
console.warn(chalk__default.default.yellow(` ${param.deprecationMessage}`));
|
|
1768
2113
|
}
|
|
1769
2114
|
console.warn();
|
|
1770
2115
|
}
|
|
@@ -2095,7 +2440,7 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
|
|
|
2095
2440
|
functionInfo.itemType
|
|
2096
2441
|
);
|
|
2097
2442
|
if (!confirmResult.confirmed) {
|
|
2098
|
-
console.log(
|
|
2443
|
+
console.log(chalk__default.default.yellow("Operation cancelled."));
|
|
2099
2444
|
return;
|
|
2100
2445
|
}
|
|
2101
2446
|
confirmMessageAfter = confirmResult.messageAfter;
|
|
@@ -2157,7 +2502,7 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
|
|
|
2157
2502
|
renderer.renderItem(normalizedResult.value);
|
|
2158
2503
|
}
|
|
2159
2504
|
if (confirmMessageAfter) {
|
|
2160
|
-
console.log(
|
|
2505
|
+
console.log(chalk__default.default.yellow(`
|
|
2161
2506
|
${confirmMessageAfter}`));
|
|
2162
2507
|
}
|
|
2163
2508
|
break;
|
|
@@ -3200,20 +3545,20 @@ var spinPromise = async (promise, text) => {
|
|
|
3200
3545
|
};
|
|
3201
3546
|
var log = {
|
|
3202
3547
|
info: (message, ...args) => {
|
|
3203
|
-
console.log(
|
|
3548
|
+
console.log(chalk__default.default.blue("\u2139"), message, ...args);
|
|
3204
3549
|
},
|
|
3205
3550
|
error: (message, ...args) => {
|
|
3206
|
-
console.error(
|
|
3551
|
+
console.error(chalk__default.default.red("\u2716"), message, ...args);
|
|
3207
3552
|
},
|
|
3208
3553
|
success: (message, ...args) => {
|
|
3209
|
-
console.log(
|
|
3554
|
+
console.log(chalk__default.default.green("\u2713"), message, ...args);
|
|
3210
3555
|
},
|
|
3211
3556
|
warn: (message, ...args) => {
|
|
3212
|
-
console.log(
|
|
3557
|
+
console.log(chalk__default.default.yellow("\u26A0"), message, ...args);
|
|
3213
3558
|
},
|
|
3214
3559
|
debug: (message, ...args) => {
|
|
3215
3560
|
if (process.env.DEBUG === "true" || process.argv.includes("--debug")) {
|
|
3216
|
-
console.log(
|
|
3561
|
+
console.log(chalk__default.default.gray("\u{1F41B}"), message, ...args);
|
|
3217
3562
|
}
|
|
3218
3563
|
}
|
|
3219
3564
|
};
|
|
@@ -5423,7 +5768,7 @@ function buildTemplateVariables({
|
|
|
5423
5768
|
};
|
|
5424
5769
|
}
|
|
5425
5770
|
function cleanupProject({ projectDir }) {
|
|
5426
|
-
console.log("\n" +
|
|
5771
|
+
console.log("\n" + chalk__default.default.yellow("!") + " Cleaning up...");
|
|
5427
5772
|
fs.rmSync(projectDir, { recursive: true, force: true });
|
|
5428
5773
|
}
|
|
5429
5774
|
async function withInterruptCleanup(cleanup, fn) {
|
|
@@ -5633,8 +5978,8 @@ function buildNextSteps({
|
|
|
5633
5978
|
}
|
|
5634
5979
|
function createConsoleDisplayHooks() {
|
|
5635
5980
|
return {
|
|
5636
|
-
onItemComplete: (message) => console.log(" " +
|
|
5637
|
-
onWarn: (message) => console.warn(
|
|
5981
|
+
onItemComplete: (message) => console.log(" " + chalk__default.default.green("\u2713") + " " + chalk__default.default.dim(message)),
|
|
5982
|
+
onWarn: (message) => console.warn(chalk__default.default.yellow("!") + " " + message),
|
|
5638
5983
|
onStepStart: ({
|
|
5639
5984
|
description,
|
|
5640
5985
|
stepNumber,
|
|
@@ -5643,31 +5988,31 @@ function createConsoleDisplayHooks() {
|
|
|
5643
5988
|
skipPrompts
|
|
5644
5989
|
}) => {
|
|
5645
5990
|
const progressMessage = `${description}...`;
|
|
5646
|
-
const stepCounter =
|
|
5991
|
+
const stepCounter = chalk__default.default.dim(`${stepNumber}/${totalSteps}`);
|
|
5647
5992
|
if (skipPrompts) {
|
|
5648
5993
|
console.log(
|
|
5649
|
-
"\n" +
|
|
5994
|
+
"\n" + chalk__default.default.bold(`\u276F ${progressMessage}`) + " " + stepCounter + "\n"
|
|
5650
5995
|
);
|
|
5651
5996
|
} else {
|
|
5652
5997
|
console.log(
|
|
5653
|
-
|
|
5998
|
+
chalk__default.default.dim("\u2192") + " " + progressMessage + " " + stepCounter
|
|
5654
5999
|
);
|
|
5655
6000
|
}
|
|
5656
6001
|
if (command) {
|
|
5657
|
-
console.log(" " +
|
|
6002
|
+
console.log(" " + chalk__default.default.cyan(`$ ${command}`));
|
|
5658
6003
|
}
|
|
5659
6004
|
},
|
|
5660
6005
|
onStepSuccess: ({ stepNumber, totalSteps }) => console.log(
|
|
5661
|
-
"\n" +
|
|
6006
|
+
"\n" + chalk__default.default.green("\u2713") + " " + chalk__default.default.dim(`Step ${stepNumber}/${totalSteps} complete`) + "\n"
|
|
5662
6007
|
),
|
|
5663
6008
|
onStepError: ({ description, command, err }) => {
|
|
5664
6009
|
const detail = err instanceof Error && err.message ? `
|
|
5665
|
-
${
|
|
6010
|
+
${chalk__default.default.dim(err.message)}` : "";
|
|
5666
6011
|
const hint = command ? `
|
|
5667
|
-
${
|
|
6012
|
+
${chalk__default.default.dim("run manually:")} ${chalk__default.default.cyan(`$ ${command}`)}` : "";
|
|
5668
6013
|
console.error(
|
|
5669
6014
|
`
|
|
5670
|
-
${
|
|
6015
|
+
${chalk__default.default.red("\u2716")} ${chalk__default.default.bold(description)}${chalk__default.default.dim(" failed")}${detail}${hint}`
|
|
5671
6016
|
);
|
|
5672
6017
|
}
|
|
5673
6018
|
};
|
|
@@ -5679,22 +6024,22 @@ function displaySummaryAndNextSteps({
|
|
|
5679
6024
|
packageManager
|
|
5680
6025
|
}) {
|
|
5681
6026
|
const formatStatus = (complete) => ({
|
|
5682
|
-
icon: complete ?
|
|
5683
|
-
text: complete ?
|
|
6027
|
+
icon: complete ? chalk__default.default.green("\u2713") : chalk__default.default.yellow("!"),
|
|
6028
|
+
text: complete ? chalk__default.default.green("Setup complete") : chalk__default.default.yellow("Setup interrupted")
|
|
5684
6029
|
});
|
|
5685
|
-
const formatNextStep = (step, i) => " " +
|
|
5686
|
-
const formatCommand = (cmd) => " " +
|
|
5687
|
-
const formatCompletedStep = (step) => " " +
|
|
6030
|
+
const formatNextStep = (step, i) => " " + chalk__default.default.dim(`${i + 1}.`) + " " + chalk__default.default.bold(step.description);
|
|
6031
|
+
const formatCommand = (cmd) => " " + chalk__default.default.cyan(`$ ${cmd}`);
|
|
6032
|
+
const formatCompletedStep = (step) => " " + chalk__default.default.green("\u2713") + " " + step.description;
|
|
5688
6033
|
const { execCmd } = getPackageManagerCommands({ packageManager });
|
|
5689
6034
|
const leftoverSteps = steps.filter(
|
|
5690
6035
|
(s) => !completedSetupStepIds.includes(s.id)
|
|
5691
6036
|
);
|
|
5692
6037
|
const isComplete = leftoverSteps.length === 0;
|
|
5693
6038
|
const status = formatStatus(isComplete);
|
|
5694
|
-
console.log("\n" +
|
|
5695
|
-
console.log(" " +
|
|
6039
|
+
console.log("\n" + chalk__default.default.bold("\u276F Summary") + "\n");
|
|
6040
|
+
console.log(" " + chalk__default.default.dim("Project") + " " + chalk__default.default.bold(projectName));
|
|
5696
6041
|
console.log(
|
|
5697
|
-
" " +
|
|
6042
|
+
" " + chalk__default.default.dim("Status") + " " + status.icon + " " + status.text
|
|
5698
6043
|
);
|
|
5699
6044
|
const completedSteps = steps.filter(
|
|
5700
6045
|
(s) => completedSetupStepIds.includes(s.id)
|
|
@@ -5704,7 +6049,7 @@ function displaySummaryAndNextSteps({
|
|
|
5704
6049
|
for (const step of completedSteps) console.log(formatCompletedStep(step));
|
|
5705
6050
|
}
|
|
5706
6051
|
const nextSteps = buildNextSteps({ projectName, leftoverSteps, execCmd });
|
|
5707
|
-
console.log("\n" +
|
|
6052
|
+
console.log("\n" + chalk__default.default.bold("\u276F Next Steps") + "\n");
|
|
5708
6053
|
nextSteps.forEach((step, i) => {
|
|
5709
6054
|
console.log(formatNextStep(step, i));
|
|
5710
6055
|
if (step.command) console.log(formatCommand(step.command));
|
|
@@ -5780,13 +6125,13 @@ function createInteractiveCallback() {
|
|
|
5780
6125
|
const attrs = message.message_attributes;
|
|
5781
6126
|
console.log(
|
|
5782
6127
|
`
|
|
5783
|
-
${
|
|
6128
|
+
${chalk__default.default.bold(`Message #${messageNumber}`)} ${chalk__default.default.dim(message.id)} ${chalk__default.default.dim(`(lease #${attrs.lease_count})`)}`
|
|
5784
6129
|
);
|
|
5785
6130
|
if (attrs.error_message) {
|
|
5786
|
-
console.log(
|
|
6131
|
+
console.log(chalk__default.default.yellow(` upstream error: ${attrs.error_message}`));
|
|
5787
6132
|
}
|
|
5788
6133
|
if (attrs.possible_duplicate_data) {
|
|
5789
|
-
console.log(
|
|
6134
|
+
console.log(chalk__default.default.yellow(" possible duplicate data"));
|
|
5790
6135
|
}
|
|
5791
6136
|
while (true) {
|
|
5792
6137
|
let action;
|
|
@@ -5816,7 +6161,7 @@ ${chalk7__default.default.bold(`Message #${messageNumber}`)} ${chalk7__default.d
|
|
|
5816
6161
|
throw error;
|
|
5817
6162
|
}
|
|
5818
6163
|
if (action === "view") {
|
|
5819
|
-
console.log(
|
|
6164
|
+
console.log(chalk__default.default.dim(JSON.stringify(message.payload, null, 2)));
|
|
5820
6165
|
continue;
|
|
5821
6166
|
}
|
|
5822
6167
|
if (action === "ack") {
|
|
@@ -5919,7 +6264,7 @@ function describeReason(reason) {
|
|
|
5919
6264
|
}
|
|
5920
6265
|
function printDrainError(reason, message) {
|
|
5921
6266
|
console.error(
|
|
5922
|
-
|
|
6267
|
+
chalk__default.default.red(`Error processing ${message.id}: ${describeReason(reason)}`)
|
|
5923
6268
|
);
|
|
5924
6269
|
}
|
|
5925
6270
|
function printDrainSummary(counts) {
|
|
@@ -5929,7 +6274,7 @@ function printDrainSummary(counts) {
|
|
|
5929
6274
|
if (skipped > 0) parts.push(`${skipped} skipped`);
|
|
5930
6275
|
parts.push(`${counts.rejected} rejected`);
|
|
5931
6276
|
console.log(
|
|
5932
|
-
|
|
6277
|
+
chalk__default.default.dim(
|
|
5933
6278
|
`
|
|
5934
6279
|
Processed ${total} message${total === 1 ? "" : "s"} (${parts.join(", ")}).`
|
|
5935
6280
|
)
|
|
@@ -5937,7 +6282,7 @@ Processed ${total} message${total === 1 ? "" : "s"} (${parts.join(", ")}).`
|
|
|
5937
6282
|
}
|
|
5938
6283
|
function warnInteractiveContinueOnErrorOverride() {
|
|
5939
6284
|
console.warn(
|
|
5940
|
-
|
|
6285
|
+
chalk__default.default.yellow(
|
|
5941
6286
|
'Note: continueOnError=false is overridden to true in interactive mode (the "Skip (let lease expire)" choice would otherwise terminate the drain).'
|
|
5942
6287
|
)
|
|
5943
6288
|
);
|
|
@@ -6241,7 +6586,7 @@ var watchTriggerInboxCliPlugin = zapierSdk.definePlugin(
|
|
|
6241
6586
|
// package.json with { type: 'json' }
|
|
6242
6587
|
var package_default2 = {
|
|
6243
6588
|
name: "@zapier/zapier-sdk-cli",
|
|
6244
|
-
version: "0.
|
|
6589
|
+
version: "0.49.1"};
|
|
6245
6590
|
|
|
6246
6591
|
// src/sdk.ts
|
|
6247
6592
|
zapierSdk.injectCliLogin(login_exports);
|
|
@@ -6448,26 +6793,26 @@ function displayUpdateNotification(versionInfo, packageName) {
|
|
|
6448
6793
|
if (versionInfo.isDeprecated) {
|
|
6449
6794
|
console.error();
|
|
6450
6795
|
console.error(
|
|
6451
|
-
|
|
6796
|
+
chalk__default.default.red.bold("\u26A0\uFE0F DEPRECATION WARNING") + chalk__default.default.red(
|
|
6452
6797
|
` - ${packageName} v${versionInfo.currentVersion} is deprecated.`
|
|
6453
6798
|
)
|
|
6454
6799
|
);
|
|
6455
6800
|
if (versionInfo.deprecationMessage) {
|
|
6456
|
-
console.error(
|
|
6801
|
+
console.error(chalk__default.default.red(` ${versionInfo.deprecationMessage}`));
|
|
6457
6802
|
}
|
|
6458
|
-
console.error(
|
|
6803
|
+
console.error(chalk__default.default.red(` Please update to the latest version.`));
|
|
6459
6804
|
console.error();
|
|
6460
6805
|
}
|
|
6461
6806
|
if (versionInfo.hasUpdate) {
|
|
6462
6807
|
console.error();
|
|
6463
6808
|
console.error(
|
|
6464
|
-
|
|
6809
|
+
chalk__default.default.yellow.bold("\u{1F4E6} Update available!") + chalk__default.default.yellow(
|
|
6465
6810
|
` ${packageName} v${versionInfo.currentVersion} \u2192 v${versionInfo.latestVersion}`
|
|
6466
6811
|
)
|
|
6467
6812
|
);
|
|
6468
6813
|
console.error(
|
|
6469
|
-
|
|
6470
|
-
` Run ${
|
|
6814
|
+
chalk__default.default.yellow(
|
|
6815
|
+
` Run ${chalk__default.default.bold(getUpdateCommand(packageName))} to update.`
|
|
6471
6816
|
)
|
|
6472
6817
|
);
|
|
6473
6818
|
console.error();
|