@zapier/zapier-sdk-cli 0.48.2 → 0.49.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 +16 -0
- package/dist/cli.cjs +541 -190
- package/dist/cli.mjs +539 -189
- 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 +564 -119
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
package/dist/cli.mjs
CHANGED
|
@@ -3,7 +3,8 @@ import { Command, CommanderError, Option } from 'commander';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { definePlugin, createPluginMethod, getOrCreateApiClient, OutputPropertySchema, ZapierBundleError, DEFAULT_CONFIG_PATH, ZapierValidationError, ZapierUnknownError, ZapierReleaseTriggerMessageSignal, injectCliLogin, BaseSdkOptionsSchema, isCredentialsObject, invalidateCachedToken, buildApplicationLifecycleEvent, batch, toSnakeCase, ZapierAbortDrainSignal, createZapierSdk as createZapierSdk$1, ZapierError, isPositional, runWithTelemetryContext, buildCapabilityMessage, formatErrorMessage, getOsInfo, getPlatformVersions, getCiPlatform, isCi, getReleaseId, getCurrentTimestamp, generateEventId } from '@zapier/zapier-sdk';
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
|
-
import
|
|
6
|
+
import search from '@inquirer/search';
|
|
7
|
+
import chalk from 'chalk';
|
|
7
8
|
import ora from 'ora';
|
|
8
9
|
import util from 'util';
|
|
9
10
|
import wrapAnsi from 'wrap-ansi';
|
|
@@ -143,7 +144,7 @@ var SchemaParameterResolver = class {
|
|
|
143
144
|
debugLog(message) {
|
|
144
145
|
if (this.debug) {
|
|
145
146
|
this.stopSpinner();
|
|
146
|
-
console.log(
|
|
147
|
+
console.log(chalk.gray(`[Zapier CLI] ${message}`));
|
|
147
148
|
}
|
|
148
149
|
}
|
|
149
150
|
startSpinner() {
|
|
@@ -234,7 +235,7 @@ var SchemaParameterResolver = class {
|
|
|
234
235
|
}
|
|
235
236
|
} catch (error) {
|
|
236
237
|
if (this.isUserCancellation(error)) {
|
|
237
|
-
console.log(
|
|
238
|
+
console.log(chalk.yellow("\n\nOperation cancelled by user"));
|
|
238
239
|
throw new ZapierCliUserCancellationError();
|
|
239
240
|
}
|
|
240
241
|
throw error;
|
|
@@ -271,7 +272,7 @@ var SchemaParameterResolver = class {
|
|
|
271
272
|
}
|
|
272
273
|
} catch (error) {
|
|
273
274
|
if (this.isUserCancellation(error)) {
|
|
274
|
-
console.log(
|
|
275
|
+
console.log(chalk.yellow("\n\nOperation cancelled by user"));
|
|
275
276
|
throw new ZapierCliUserCancellationError();
|
|
276
277
|
}
|
|
277
278
|
throw error;
|
|
@@ -382,6 +383,237 @@ var SchemaParameterResolver = class {
|
|
|
382
383
|
throw new ZapierCliMissingParametersError(missingParams);
|
|
383
384
|
}
|
|
384
385
|
}
|
|
386
|
+
/**
|
|
387
|
+
* Wrap a PromptConfig.validate so internal sentinels (Symbols) bypass
|
|
388
|
+
* it. The resolver's validator is intended for actual user values; our
|
|
389
|
+
* Skip / Custom / Load-more sentinels are internal control-flow and
|
|
390
|
+
* should pass through. Returns `undefined` when the resolver didn't
|
|
391
|
+
* supply a validator (so `await search({ ...rest })` doesn't get a
|
|
392
|
+
* pass-through identity function).
|
|
393
|
+
*/
|
|
394
|
+
wrapPromptValidate(validate) {
|
|
395
|
+
if (!validate) return void 0;
|
|
396
|
+
return (value) => typeof value === "symbol" ? true : validate(value);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Apply a PromptConfig.filter to a selected value, but only when the
|
|
400
|
+
* value is a real data choice (not an internal sentinel). @inquirer/search
|
|
401
|
+
* has no built-in filter hook, so the search-backed paths call this
|
|
402
|
+
* explicitly before returning.
|
|
403
|
+
*/
|
|
404
|
+
applyPromptFilter(filter, value) {
|
|
405
|
+
if (!filter || typeof value === "symbol") return value;
|
|
406
|
+
return filter(value);
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* If the resolver's PromptConfig sets a `default` value, move the
|
|
410
|
+
* matching choice to the front so it's the first selectable item in
|
|
411
|
+
* the rendered source. @inquirer/search has no built-in `default`
|
|
412
|
+
* option; first-selectable is what Enter picks, so reordering achieves
|
|
413
|
+
* the same semantics inquirer.prompt's list had natively.
|
|
414
|
+
*
|
|
415
|
+
* Returns the original array if no default is set or the default
|
|
416
|
+
* doesn't match any current choice.
|
|
417
|
+
*/
|
|
418
|
+
reorderForDefault(matches, defaultValue) {
|
|
419
|
+
if (defaultValue === void 0) return matches;
|
|
420
|
+
const idx = matches.findIndex((c) => c.value === defaultValue);
|
|
421
|
+
if (idx <= 0) return matches;
|
|
422
|
+
return [matches[idx], ...matches.slice(0, idx), ...matches.slice(idx + 1)];
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Build the disabled "if you had X capability, more results would show"
|
|
426
|
+
* hints for any unmet capabilities the resolver declared. Returns the
|
|
427
|
+
* raw hint strings — callers wrap them into choice objects with whatever
|
|
428
|
+
* sentinel value they prefer (disabled choices' values are inert).
|
|
429
|
+
*/
|
|
430
|
+
async computeCapabilityHints(resolver, context) {
|
|
431
|
+
if (!resolver.requireCapabilities) return [];
|
|
432
|
+
const capContext = context.sdk.context;
|
|
433
|
+
if (!capContext.hasCapability) return [];
|
|
434
|
+
const messages = [];
|
|
435
|
+
for (const cap of resolver.requireCapabilities) {
|
|
436
|
+
const enabled = await capContext.hasCapability(cap);
|
|
437
|
+
if (!enabled) messages.push(buildCapabilityMessage(cap));
|
|
438
|
+
}
|
|
439
|
+
return messages;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Unpack a DynamicResolver.fetch result into the three shapes the caller
|
|
443
|
+
* cares about: a flat items array, an optional AsyncIterator for further
|
|
444
|
+
* pagination, and a hasMore flag. Centralizing keeps the AsyncIterable /
|
|
445
|
+
* `{data, nextCursor}` / `TItem[]` discrimination in one place — both
|
|
446
|
+
* the main dropdown loop and the search-mode flow consume it.
|
|
447
|
+
*
|
|
448
|
+
* The function is `async` for the AsyncIterable branch only (we eagerly
|
|
449
|
+
* consume the first page so callers don't have to discriminate). The
|
|
450
|
+
* other two branches return synchronously; an explicit Promise.resolve
|
|
451
|
+
* is unnecessary because async automatically wraps.
|
|
452
|
+
*
|
|
453
|
+
* Note: callers in search mode intentionally drop `pageIterator` /
|
|
454
|
+
* `hasMore` because each search() invocation re-prompts from scratch;
|
|
455
|
+
* pagination only matters when the prompt is the dropdown itself.
|
|
456
|
+
*/
|
|
457
|
+
async unpackFetchResult(fetchResult, promptLabel) {
|
|
458
|
+
if (fetchResult != null && typeof fetchResult === "object" && Symbol.asyncIterator in fetchResult) {
|
|
459
|
+
const pageIterator = fetchResult[Symbol.asyncIterator]();
|
|
460
|
+
const first = await pageIterator.next();
|
|
461
|
+
if (!first.done && first.value) {
|
|
462
|
+
return {
|
|
463
|
+
items: Array.isArray(first.value.data) ? first.value.data : [],
|
|
464
|
+
pageIterator,
|
|
465
|
+
hasMore: first.value.nextCursor != null
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
return { items: [], pageIterator, hasMore: false };
|
|
469
|
+
}
|
|
470
|
+
if (fetchResult != null && typeof fetchResult === "object" && "data" in fetchResult) {
|
|
471
|
+
const page = fetchResult;
|
|
472
|
+
const hasMore = page.nextCursor != null;
|
|
473
|
+
if (hasMore) {
|
|
474
|
+
this.debugLog(
|
|
475
|
+
`Resolver for ${promptLabel} has more pages but no iterator. Use toIterable() to enable "Load more..." support.`
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
return {
|
|
479
|
+
items: Array.isArray(page.data) ? page.data : [],
|
|
480
|
+
pageIterator: null,
|
|
481
|
+
hasMore
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
return {
|
|
485
|
+
items: Array.isArray(fetchResult) ? fetchResult : [],
|
|
486
|
+
pageIterator: null,
|
|
487
|
+
hasMore: false
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Search-mode dynamic resolver: prompts the user for free-form text, passes
|
|
492
|
+
* it to fetch via `search`, and either short-circuits on a primitive return
|
|
493
|
+
* (exact match) or renders the results as a search-filterable dropdown.
|
|
494
|
+
* Empty results still render the dropdown so the user can fall through to
|
|
495
|
+
* "(Use 'foo' as-is)" or "(Try a different search)" rather than being
|
|
496
|
+
* stuck.
|
|
497
|
+
*
|
|
498
|
+
* Known limitation: pagination beyond the first page is dropped. Each
|
|
499
|
+
* search() invocation re-prompts from scratch and the user is expected
|
|
500
|
+
* to refine their query if too many results came back. If a future
|
|
501
|
+
* high-cardinality search resolver needs Load-more here, the
|
|
502
|
+
* `pageIterator` / `hasMore` from `unpackFetchResult` is what to wire in.
|
|
503
|
+
*/
|
|
504
|
+
async resolveDynamicWithSearchInput({
|
|
505
|
+
resolver,
|
|
506
|
+
context,
|
|
507
|
+
promptLabel,
|
|
508
|
+
isOptional
|
|
509
|
+
}) {
|
|
510
|
+
const parenParts = [];
|
|
511
|
+
if (isOptional) parenParts.push("optional");
|
|
512
|
+
if (resolver.placeholder) parenParts.push(resolver.placeholder);
|
|
513
|
+
const parens = parenParts.length > 0 ? ` (${parenParts.join(", ")})` : "";
|
|
514
|
+
const message = `Enter or search ${promptLabel}${parens}:`;
|
|
515
|
+
const SKIP_SENTINEL = Symbol("SKIP");
|
|
516
|
+
const USE_AS_IS_SENTINEL = Symbol("USE_AS_IS");
|
|
517
|
+
const TRY_AGAIN_SENTINEL = Symbol("TRY_AGAIN");
|
|
518
|
+
let lastNote;
|
|
519
|
+
while (true) {
|
|
520
|
+
this.stopSpinner();
|
|
521
|
+
if (lastNote) {
|
|
522
|
+
console.log(chalk.yellow(lastNote));
|
|
523
|
+
lastNote = void 0;
|
|
524
|
+
}
|
|
525
|
+
const answers = await inquirer.prompt([
|
|
526
|
+
{ type: "input", name: "search", message }
|
|
527
|
+
]);
|
|
528
|
+
const rawInput = answers.search;
|
|
529
|
+
const searchInput = typeof rawInput === "string" ? rawInput.trim() : "";
|
|
530
|
+
if (!searchInput) {
|
|
531
|
+
if (isOptional) return void 0;
|
|
532
|
+
lastNote = `${promptLabel} is required.`;
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
const searchParams = {
|
|
536
|
+
...context.resolvedParams,
|
|
537
|
+
search: searchInput
|
|
538
|
+
};
|
|
539
|
+
this.startSpinner();
|
|
540
|
+
this.debugLog(`Searching ${promptLabel} for "${searchInput}"`);
|
|
541
|
+
let fetchResult;
|
|
542
|
+
try {
|
|
543
|
+
fetchResult = await resolver.fetch(context.sdk, searchParams);
|
|
544
|
+
} finally {
|
|
545
|
+
this.stopSpinner();
|
|
546
|
+
}
|
|
547
|
+
if (typeof fetchResult === "string" || typeof fetchResult === "number") {
|
|
548
|
+
return fetchResult;
|
|
549
|
+
}
|
|
550
|
+
const { items } = await this.unpackFetchResult(fetchResult, promptLabel);
|
|
551
|
+
const choicesConfig = resolver.prompt(items, searchParams);
|
|
552
|
+
const dataChoices = choicesConfig.choices ?? [];
|
|
553
|
+
const capabilityHintMessages = await this.computeCapabilityHints(
|
|
554
|
+
resolver,
|
|
555
|
+
context
|
|
556
|
+
);
|
|
557
|
+
const selected = await search({
|
|
558
|
+
message: choicesConfig.message,
|
|
559
|
+
validate: this.wrapPromptValidate(choicesConfig.validate),
|
|
560
|
+
// @inquirer/search passes an AbortSignal as the second arg for
|
|
561
|
+
// cancelling async sources. All three of our source callbacks are
|
|
562
|
+
// pure-local (filter an already-fetched array), so we intentionally
|
|
563
|
+
// ignore the signal. A future server-side filter implementation
|
|
564
|
+
// would need to honor it.
|
|
565
|
+
source: (term) => {
|
|
566
|
+
const trimmed = (term ?? "").trim();
|
|
567
|
+
const lower = trimmed.toLowerCase();
|
|
568
|
+
const matches = trimmed ? dataChoices.filter((c) => c.name.toLowerCase().includes(lower)) : dataChoices;
|
|
569
|
+
const orderedMatches = trimmed ? matches : this.reorderForDefault(matches, choicesConfig.default);
|
|
570
|
+
const skipChoice = isOptional ? [{ name: chalk.dim("(Skip)"), value: SKIP_SENTINEL }] : [];
|
|
571
|
+
const useAsIsChoice = {
|
|
572
|
+
name: chalk.dim(`(Use ${JSON.stringify(searchInput)} as-is)`),
|
|
573
|
+
value: USE_AS_IS_SENTINEL
|
|
574
|
+
};
|
|
575
|
+
const tryAgainChoice = {
|
|
576
|
+
name: chalk.dim("(Try a different search)"),
|
|
577
|
+
value: TRY_AGAIN_SENTINEL
|
|
578
|
+
};
|
|
579
|
+
const out = [];
|
|
580
|
+
if (orderedMatches.length === 0) {
|
|
581
|
+
out.push(useAsIsChoice);
|
|
582
|
+
out.push(tryAgainChoice);
|
|
583
|
+
out.push(...skipChoice);
|
|
584
|
+
} else {
|
|
585
|
+
out.push(...orderedMatches);
|
|
586
|
+
out.push(...skipChoice);
|
|
587
|
+
out.push(useAsIsChoice);
|
|
588
|
+
out.push(tryAgainChoice);
|
|
589
|
+
}
|
|
590
|
+
for (const message2 of capabilityHintMessages) {
|
|
591
|
+
out.push({
|
|
592
|
+
name: chalk.dim(message2),
|
|
593
|
+
value: SKIP_SENTINEL,
|
|
594
|
+
disabled: true
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
return out;
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
if (selected === SKIP_SENTINEL) return void 0;
|
|
601
|
+
if (selected === USE_AS_IS_SENTINEL) {
|
|
602
|
+
const validationResult = choicesConfig.validate?.(searchInput);
|
|
603
|
+
if (validationResult === false) {
|
|
604
|
+
lastNote = `${promptLabel}: invalid value.`;
|
|
605
|
+
continue;
|
|
606
|
+
}
|
|
607
|
+
if (typeof validationResult === "string") {
|
|
608
|
+
lastNote = validationResult;
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
return this.applyPromptFilter(choicesConfig.filter, searchInput);
|
|
612
|
+
}
|
|
613
|
+
if (selected === TRY_AGAIN_SENTINEL) continue;
|
|
614
|
+
return this.applyPromptFilter(choicesConfig.filter, selected);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
385
617
|
async resolveParameter(param, context, functionName, options) {
|
|
386
618
|
const resolver = this.getResolver(
|
|
387
619
|
param.name,
|
|
@@ -395,6 +627,27 @@ var SchemaParameterResolver = class {
|
|
|
395
627
|
isOptional: options?.isOptional
|
|
396
628
|
});
|
|
397
629
|
}
|
|
630
|
+
/**
|
|
631
|
+
* Run a resolver to obtain a value for one parameter, prompting the
|
|
632
|
+
* user when necessary. Routes to one of several prompt backends and
|
|
633
|
+
* has to keep the `PromptConfig` contract honest across each one.
|
|
634
|
+
*
|
|
635
|
+
* `PromptConfig` field × prompt-backend handling:
|
|
636
|
+
*
|
|
637
|
+
* | field | list (search()) | checkbox/confirm (inquirer.prompt) | search-mode dropdown (search()) |
|
|
638
|
+
* | -------- | --------------- | ---------------------------------- | ------------------------------- |
|
|
639
|
+
* | type | required | required | required |
|
|
640
|
+
* | name | (set internally)| forwarded | (set internally) |
|
|
641
|
+
* | message | forwarded | forwarded | forwarded |
|
|
642
|
+
* | choices | filtered in src | passed to inquirer | filtered in src |
|
|
643
|
+
* | default | reorder matches | passed (also internal cursor jump) | reorder matches |
|
|
644
|
+
* | validate | wrapped | passed (inquirer native) | wrapped + manual for (Use as-is)|
|
|
645
|
+
* | filter | manual once | inquirer native (do NOT double) | manual once |
|
|
646
|
+
*
|
|
647
|
+
* Escape-hatch sentinels (Skip / Custom value / Use as-is / Load more
|
|
648
|
+
* / Try again) bypass the resolver's validate/filter because they
|
|
649
|
+
* aren't real user values — they're CLI control-flow.
|
|
650
|
+
*/
|
|
398
651
|
async resolveWithResolver(resolver, param, context, options = {}) {
|
|
399
652
|
const { arrayIndex, isOptional } = options;
|
|
400
653
|
const inArrayContext = arrayIndex != null;
|
|
@@ -433,41 +686,52 @@ var SchemaParameterResolver = class {
|
|
|
433
686
|
this.stopSpinner();
|
|
434
687
|
return autoResolution.resolvedValue;
|
|
435
688
|
}
|
|
689
|
+
if (dynamicResolver.inputType === "search") {
|
|
690
|
+
this.stopSpinner();
|
|
691
|
+
return await this.resolveDynamicWithSearchInput({
|
|
692
|
+
resolver: dynamicResolver,
|
|
693
|
+
context,
|
|
694
|
+
promptLabel,
|
|
695
|
+
isOptional: isOptional ?? false
|
|
696
|
+
});
|
|
697
|
+
}
|
|
436
698
|
this.debugLog(`Fetching options for ${promptLabel}`);
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
699
|
+
let fetchResult;
|
|
700
|
+
try {
|
|
701
|
+
fetchResult = await dynamicResolver.fetch(
|
|
702
|
+
context.sdk,
|
|
703
|
+
context.resolvedParams
|
|
704
|
+
);
|
|
705
|
+
} finally {
|
|
706
|
+
this.stopSpinner();
|
|
707
|
+
}
|
|
708
|
+
if (typeof fetchResult === "string" || typeof fetchResult === "number") {
|
|
709
|
+
console.error(
|
|
710
|
+
chalk.yellow(
|
|
711
|
+
`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.`
|
|
712
|
+
)
|
|
713
|
+
);
|
|
714
|
+
const fallbackAnswers = await inquirer.prompt([
|
|
715
|
+
{
|
|
716
|
+
type: "input",
|
|
717
|
+
name: promptName,
|
|
718
|
+
message: `Enter ${promptLabel}${isOptional ? " (optional)" : ""}:`
|
|
719
|
+
}
|
|
720
|
+
]);
|
|
721
|
+
const fallbackValue = fallbackAnswers[promptName];
|
|
722
|
+
if (isOptional && (fallbackValue === void 0 || fallbackValue === "")) {
|
|
723
|
+
return void 0;
|
|
461
724
|
}
|
|
462
|
-
|
|
463
|
-
items = fetchResult || [];
|
|
464
|
-
pageIterator = null;
|
|
725
|
+
return fallbackValue;
|
|
465
726
|
}
|
|
727
|
+
const unpacked = await this.unpackFetchResult(fetchResult, promptLabel);
|
|
728
|
+
let pageIterator = unpacked.pageIterator;
|
|
729
|
+
let items = unpacked.items;
|
|
730
|
+
let hasMore = unpacked.hasMore;
|
|
466
731
|
const LOAD_MORE_SENTINEL = Symbol("LOAD_MORE");
|
|
467
732
|
const SKIP_SENTINEL = Symbol("SKIP");
|
|
468
733
|
const CUSTOM_VALUE_SENTINEL = Symbol("CUSTOM_VALUE");
|
|
469
734
|
let newItemsStartIndex = -1;
|
|
470
|
-
this.stopSpinner();
|
|
471
735
|
while (true) {
|
|
472
736
|
const promptConfig = dynamicResolver.prompt(
|
|
473
737
|
items,
|
|
@@ -482,50 +746,97 @@ var SchemaParameterResolver = class {
|
|
|
482
746
|
`No ${promptLabel} available to select.`
|
|
483
747
|
);
|
|
484
748
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
if (hasMore && pageIterator && promptConfig.choices) {
|
|
499
|
-
promptConfig.choices.push({
|
|
500
|
-
name: chalk7.dim("(Load more...)"),
|
|
501
|
-
value: LOAD_MORE_SENTINEL
|
|
502
|
-
});
|
|
749
|
+
const capabilityHints = [];
|
|
750
|
+
if (!hasMore) {
|
|
751
|
+
const hintMessages = await this.computeCapabilityHints(
|
|
752
|
+
dynamicResolver,
|
|
753
|
+
context
|
|
754
|
+
);
|
|
755
|
+
for (const message of hintMessages) {
|
|
756
|
+
capabilityHints.push({
|
|
757
|
+
name: chalk.dim(message),
|
|
758
|
+
value: SKIP_SENTINEL,
|
|
759
|
+
disabled: true
|
|
760
|
+
});
|
|
761
|
+
}
|
|
503
762
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
763
|
+
let selected;
|
|
764
|
+
if (promptConfig.type === "list") {
|
|
765
|
+
const dataChoices = promptConfig.choices ?? [];
|
|
766
|
+
selected = await search({
|
|
767
|
+
message: promptConfig.message,
|
|
768
|
+
validate: this.wrapPromptValidate(promptConfig.validate),
|
|
769
|
+
source: (term) => {
|
|
770
|
+
const trimmed = (term ?? "").trim();
|
|
771
|
+
const lower = trimmed.toLowerCase();
|
|
772
|
+
const matches = trimmed ? dataChoices.filter(
|
|
773
|
+
(c) => c.name.toLowerCase().includes(lower)
|
|
774
|
+
) : dataChoices;
|
|
775
|
+
const out = [];
|
|
776
|
+
const skipChoice = isOptional ? [
|
|
777
|
+
{
|
|
778
|
+
name: chalk.dim("(Skip)"),
|
|
779
|
+
value: SKIP_SENTINEL
|
|
780
|
+
}
|
|
781
|
+
] : [];
|
|
782
|
+
const customValueChoice = {
|
|
783
|
+
name: chalk.dim("(Enter custom value)"),
|
|
784
|
+
value: CUSTOM_VALUE_SENTINEL
|
|
785
|
+
};
|
|
786
|
+
const orderedMatches = trimmed ? matches : this.reorderForDefault(matches, promptConfig.default);
|
|
787
|
+
const matchesFirst = trimmed || promptConfig.default !== void 0;
|
|
788
|
+
const loadMoreChoice = hasMore && pageIterator ? {
|
|
789
|
+
name: chalk.dim("(Load more...)"),
|
|
790
|
+
value: LOAD_MORE_SENTINEL
|
|
791
|
+
} : null;
|
|
792
|
+
if (matchesFirst && orderedMatches.length > 0) {
|
|
793
|
+
out.push(...orderedMatches);
|
|
794
|
+
out.push(...skipChoice);
|
|
795
|
+
out.push(customValueChoice);
|
|
796
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
797
|
+
} else if (matchesFirst) {
|
|
798
|
+
out.push(customValueChoice);
|
|
799
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
800
|
+
out.push(...skipChoice);
|
|
801
|
+
} else {
|
|
802
|
+
out.push(...skipChoice);
|
|
803
|
+
out.push(customValueChoice);
|
|
804
|
+
out.push(...orderedMatches);
|
|
805
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
806
|
+
}
|
|
807
|
+
if (capabilityHints.length > 0 && (!trimmed || matches.length > 0)) {
|
|
808
|
+
out.push(...capabilityHints);
|
|
515
809
|
}
|
|
810
|
+
return out;
|
|
516
811
|
}
|
|
812
|
+
});
|
|
813
|
+
} else {
|
|
814
|
+
if (isOptional && promptConfig.choices) {
|
|
815
|
+
promptConfig.choices.unshift({
|
|
816
|
+
name: chalk.dim("(Skip)"),
|
|
817
|
+
value: SKIP_SENTINEL
|
|
818
|
+
});
|
|
517
819
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
820
|
+
if (hasMore && pageIterator && promptConfig.choices) {
|
|
821
|
+
promptConfig.choices.push({
|
|
822
|
+
name: chalk.dim("(Load more...)"),
|
|
823
|
+
value: LOAD_MORE_SENTINEL
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
if (capabilityHints.length > 0 && promptConfig.choices) {
|
|
827
|
+
promptConfig.choices.push(...capabilityHints);
|
|
524
828
|
}
|
|
525
|
-
newItemsStartIndex
|
|
829
|
+
if (newItemsStartIndex >= 0 && promptConfig.choices) {
|
|
830
|
+
const injectedBefore = isOptional ? 1 : 0;
|
|
831
|
+
const adjustedIndex = newItemsStartIndex + injectedBefore;
|
|
832
|
+
if (promptConfig.choices[adjustedIndex]) {
|
|
833
|
+
promptConfig.default = promptConfig.choices[adjustedIndex].value;
|
|
834
|
+
}
|
|
835
|
+
newItemsStartIndex = -1;
|
|
836
|
+
}
|
|
837
|
+
const answers = await inquirer.prompt([promptConfig]);
|
|
838
|
+
selected = answers[promptName];
|
|
526
839
|
}
|
|
527
|
-
const answers = await inquirer.prompt([promptConfig]);
|
|
528
|
-
let selected = answers[promptName];
|
|
529
840
|
if (selected === SKIP_SENTINEL) {
|
|
530
841
|
return void 0;
|
|
531
842
|
}
|
|
@@ -564,7 +875,7 @@ var SchemaParameterResolver = class {
|
|
|
564
875
|
}
|
|
565
876
|
continue;
|
|
566
877
|
}
|
|
567
|
-
return selected;
|
|
878
|
+
return promptConfig.type === "list" ? this.applyPromptFilter(promptConfig.filter, selected) : selected;
|
|
568
879
|
}
|
|
569
880
|
} else if (resolver.type === "fields") {
|
|
570
881
|
if (isOptional && !inArrayContext) {
|
|
@@ -622,7 +933,7 @@ var SchemaParameterResolver = class {
|
|
|
622
933
|
if (!rootFieldItems || rootFieldItems.length === 0) {
|
|
623
934
|
if (iteration === 1) {
|
|
624
935
|
console.log(
|
|
625
|
-
|
|
936
|
+
chalk.yellow(`No input fields required for this action.`)
|
|
626
937
|
);
|
|
627
938
|
}
|
|
628
939
|
break;
|
|
@@ -645,7 +956,7 @@ var SchemaParameterResolver = class {
|
|
|
645
956
|
}
|
|
646
957
|
if (iteration >= maxIterations) {
|
|
647
958
|
console.log(
|
|
648
|
-
|
|
959
|
+
chalk.yellow(
|
|
649
960
|
`
|
|
650
961
|
\u26A0\uFE0F Maximum field resolution iterations reached. Some dynamic fields may not have been discovered.`
|
|
651
962
|
)
|
|
@@ -696,7 +1007,7 @@ var SchemaParameterResolver = class {
|
|
|
696
1007
|
};
|
|
697
1008
|
}
|
|
698
1009
|
if (items.length >= maxItems) {
|
|
699
|
-
console.log(
|
|
1010
|
+
console.log(chalk.gray(`Maximum of ${maxItems} items reached.`));
|
|
700
1011
|
}
|
|
701
1012
|
return items;
|
|
702
1013
|
}
|
|
@@ -714,7 +1025,7 @@ var SchemaParameterResolver = class {
|
|
|
714
1025
|
const fieldsetTitle = typedItem.title || typedItem.key;
|
|
715
1026
|
const pathDisplay = fieldsetPath.length > 0 ? ` (in ${fieldsetPath.join(" > ")})` : "";
|
|
716
1027
|
console.log(
|
|
717
|
-
|
|
1028
|
+
chalk.cyan(
|
|
718
1029
|
`
|
|
719
1030
|
\u{1F4C1} Processing fieldset: ${fieldsetTitle}${pathDisplay}`
|
|
720
1031
|
)
|
|
@@ -782,7 +1093,7 @@ var SchemaParameterResolver = class {
|
|
|
782
1093
|
}
|
|
783
1094
|
} else {
|
|
784
1095
|
console.log(
|
|
785
|
-
|
|
1096
|
+
chalk.gray(
|
|
786
1097
|
`
|
|
787
1098
|
There are ${optionalFields.length} ${iteration === 1 ? "" : "additional "}optional field(s) available${pathContext}.`
|
|
788
1099
|
)
|
|
@@ -797,7 +1108,7 @@ There are ${optionalFields.length} ${iteration === 1 ? "" : "additional "}option
|
|
|
797
1108
|
}
|
|
798
1109
|
]);
|
|
799
1110
|
if (shouldConfigureOptional.configure) {
|
|
800
|
-
console.log(
|
|
1111
|
+
console.log(chalk.cyan(`
|
|
801
1112
|
Optional fields${pathContext}:`));
|
|
802
1113
|
for (const field of optionalFields) {
|
|
803
1114
|
await this.promptForField(field, targetInputs, context);
|
|
@@ -813,7 +1124,7 @@ Optional fields${pathContext}:`));
|
|
|
813
1124
|
}
|
|
814
1125
|
} catch (error) {
|
|
815
1126
|
if (this.isUserCancellation(error)) {
|
|
816
|
-
console.log(
|
|
1127
|
+
console.log(chalk.yellow("\n\nOperation cancelled by user"));
|
|
817
1128
|
throw new ZapierCliUserCancellationError();
|
|
818
1129
|
}
|
|
819
1130
|
throw error;
|
|
@@ -889,7 +1200,7 @@ Optional fields${pathContext}:`));
|
|
|
889
1200
|
}));
|
|
890
1201
|
if (choices.length === 0 && !cursor) {
|
|
891
1202
|
console.log(
|
|
892
|
-
|
|
1203
|
+
chalk.yellow(`No choices available for ${fieldMeta.title}`)
|
|
893
1204
|
);
|
|
894
1205
|
}
|
|
895
1206
|
return {
|
|
@@ -899,14 +1210,17 @@ Optional fields${pathContext}:`));
|
|
|
899
1210
|
} catch (error) {
|
|
900
1211
|
this.stopSpinner();
|
|
901
1212
|
console.warn(
|
|
902
|
-
|
|
1213
|
+
chalk.yellow(`Failed to fetch choices for ${fieldMeta.title}:`),
|
|
903
1214
|
error
|
|
904
1215
|
);
|
|
905
1216
|
return { choices: [] };
|
|
906
1217
|
}
|
|
907
1218
|
}
|
|
908
1219
|
/**
|
|
909
|
-
* Prompt user with choices (handles both single and multi-select with pagination)
|
|
1220
|
+
* Prompt user with choices (handles both single and multi-select with pagination).
|
|
1221
|
+
* Single-select goes through @inquirer/search so users can type-to-filter long
|
|
1222
|
+
* dropdowns (SELECT fields); multi-select stays on inquirer.prompt since search
|
|
1223
|
+
* is single-select only.
|
|
910
1224
|
*/
|
|
911
1225
|
async promptWithChoices({
|
|
912
1226
|
fieldMeta,
|
|
@@ -919,45 +1233,81 @@ Optional fields${pathContext}:`));
|
|
|
919
1233
|
const choices = [...initialChoices];
|
|
920
1234
|
let nextCursor = initialCursor;
|
|
921
1235
|
const LOAD_MORE_SENTINEL = Symbol("LOAD_MORE");
|
|
1236
|
+
const SKIP_SENTINEL = Symbol("SKIP");
|
|
922
1237
|
const CUSTOM_VALUE_SENTINEL = Symbol("CUSTOM_VALUE");
|
|
1238
|
+
const message = `${fieldMeta.title}${fieldMeta.isRequired ? " (required)" : " (optional)"}:`;
|
|
923
1239
|
while (true) {
|
|
924
|
-
|
|
925
|
-
name: choice.label,
|
|
926
|
-
value: choice.value
|
|
927
|
-
}));
|
|
1240
|
+
let selectedValue;
|
|
928
1241
|
if (!fieldMeta.isMultiSelect) {
|
|
929
|
-
|
|
930
|
-
name:
|
|
931
|
-
value:
|
|
932
|
-
});
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
1242
|
+
const dataChoices = choices.map((c) => ({
|
|
1243
|
+
name: c.label,
|
|
1244
|
+
value: c.value
|
|
1245
|
+
}));
|
|
1246
|
+
selectedValue = await search({
|
|
1247
|
+
message,
|
|
1248
|
+
source: (term) => {
|
|
1249
|
+
const trimmed = (term ?? "").trim();
|
|
1250
|
+
const lower = trimmed.toLowerCase();
|
|
1251
|
+
const matches = trimmed ? dataChoices.filter((c) => c.name.toLowerCase().includes(lower)) : dataChoices;
|
|
1252
|
+
const out = [];
|
|
1253
|
+
const skipChoice = !fieldMeta.isRequired ? [{ name: chalk.dim("(Skip)"), value: SKIP_SENTINEL }] : [];
|
|
1254
|
+
const customValueChoice = {
|
|
1255
|
+
name: chalk.dim("(Enter custom value)"),
|
|
1256
|
+
value: CUSTOM_VALUE_SENTINEL
|
|
1257
|
+
};
|
|
1258
|
+
const loadMoreChoice = nextCursor && context ? {
|
|
1259
|
+
name: chalk.dim("(Load more...)"),
|
|
1260
|
+
value: LOAD_MORE_SENTINEL
|
|
1261
|
+
} : null;
|
|
1262
|
+
if (trimmed && matches.length > 0) {
|
|
1263
|
+
out.push(...matches);
|
|
1264
|
+
out.push(...skipChoice);
|
|
1265
|
+
out.push(customValueChoice);
|
|
1266
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
1267
|
+
} else if (trimmed) {
|
|
1268
|
+
out.push(customValueChoice);
|
|
1269
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
1270
|
+
out.push(...skipChoice);
|
|
1271
|
+
} else {
|
|
1272
|
+
out.push(...skipChoice);
|
|
1273
|
+
out.push(customValueChoice);
|
|
1274
|
+
out.push(...matches);
|
|
1275
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
1276
|
+
}
|
|
1277
|
+
return out;
|
|
1278
|
+
}
|
|
938
1279
|
});
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1280
|
+
if (selectedValue === SKIP_SENTINEL) {
|
|
1281
|
+
return void 0;
|
|
1282
|
+
}
|
|
1283
|
+
if (selectedValue === CUSTOM_VALUE_SENTINEL) {
|
|
1284
|
+
return await this.promptFreeForm(fieldMeta);
|
|
1285
|
+
}
|
|
1286
|
+
} else {
|
|
1287
|
+
const promptChoices = choices.map((c) => ({
|
|
1288
|
+
name: c.label,
|
|
1289
|
+
value: c.value
|
|
1290
|
+
}));
|
|
1291
|
+
if (nextCursor) {
|
|
1292
|
+
promptChoices.push({
|
|
1293
|
+
name: chalk.dim("(Load more...)"),
|
|
1294
|
+
value: LOAD_MORE_SENTINEL
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
const promptConfig = {
|
|
1298
|
+
type: "checkbox",
|
|
1299
|
+
name: fieldMeta.key,
|
|
1300
|
+
message,
|
|
1301
|
+
choices: promptChoices,
|
|
949
1302
|
validate: (input) => {
|
|
950
1303
|
if (fieldMeta.isRequired && (!input || input.length === 0)) {
|
|
951
1304
|
return "At least one selection is required";
|
|
952
1305
|
}
|
|
953
1306
|
return true;
|
|
954
1307
|
}
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
let selectedValue = answer[fieldMeta.key];
|
|
959
|
-
if (selectedValue === CUSTOM_VALUE_SENTINEL) {
|
|
960
|
-
return await this.promptFreeForm(fieldMeta);
|
|
1308
|
+
};
|
|
1309
|
+
const answer = await inquirer.prompt([promptConfig]);
|
|
1310
|
+
selectedValue = answer[fieldMeta.key];
|
|
961
1311
|
}
|
|
962
1312
|
const wantsMore = fieldMeta.isMultiSelect ? Array.isArray(selectedValue) && selectedValue.includes(LOAD_MORE_SENTINEL) : selectedValue === LOAD_MORE_SENTINEL;
|
|
963
1313
|
if (wantsMore && nextCursor && context) {
|
|
@@ -1020,7 +1370,7 @@ Optional fields${pathContext}:`));
|
|
|
1020
1370
|
};
|
|
1021
1371
|
}
|
|
1022
1372
|
if (fieldMeta.description) {
|
|
1023
|
-
promptConfig.prefix =
|
|
1373
|
+
promptConfig.prefix = chalk.gray(`\u2139 ${fieldMeta.description}
|
|
1024
1374
|
`);
|
|
1025
1375
|
}
|
|
1026
1376
|
try {
|
|
@@ -1028,7 +1378,7 @@ Optional fields${pathContext}:`));
|
|
|
1028
1378
|
return answer[fieldMeta.key];
|
|
1029
1379
|
} catch (error) {
|
|
1030
1380
|
if (this.isUserCancellation(error)) {
|
|
1031
|
-
console.log(
|
|
1381
|
+
console.log(chalk.yellow("\n\nOperation cancelled by user"));
|
|
1032
1382
|
throw new ZapierCliUserCancellationError();
|
|
1033
1383
|
}
|
|
1034
1384
|
throw error;
|
|
@@ -1046,7 +1396,7 @@ Optional fields${pathContext}:`));
|
|
|
1046
1396
|
}
|
|
1047
1397
|
} catch (error) {
|
|
1048
1398
|
if (this.isUserCancellation(error)) {
|
|
1049
|
-
console.log(
|
|
1399
|
+
console.log(chalk.yellow("\n\nOperation cancelled by user"));
|
|
1050
1400
|
throw new ZapierCliUserCancellationError();
|
|
1051
1401
|
}
|
|
1052
1402
|
throw error;
|
|
@@ -1169,7 +1519,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
|
|
|
1169
1519
|
|
|
1170
1520
|
// package.json
|
|
1171
1521
|
var package_default = {
|
|
1172
|
-
version: "0.
|
|
1522
|
+
version: "0.49.0"};
|
|
1173
1523
|
|
|
1174
1524
|
// src/telemetry/builders.ts
|
|
1175
1525
|
function createCliBaseEvent(context = {}) {
|
|
@@ -1254,7 +1604,7 @@ async function formatItemsFromSchema(functionInfo, items, startingNumber = 0, op
|
|
|
1254
1604
|
});
|
|
1255
1605
|
}
|
|
1256
1606
|
function formatSingleItem(formatted, itemNumber) {
|
|
1257
|
-
let titleLine = `${
|
|
1607
|
+
let titleLine = `${chalk.gray(`${itemNumber + 1}.`)} ${chalk.cyan(formatted.title)}`;
|
|
1258
1608
|
const subtitleParts = [];
|
|
1259
1609
|
if (formatted.keys) {
|
|
1260
1610
|
subtitleParts.push(...formatted.keys);
|
|
@@ -1266,11 +1616,11 @@ function formatSingleItem(formatted, itemNumber) {
|
|
|
1266
1616
|
}
|
|
1267
1617
|
const uniqueParts = [...new Set(subtitleParts)];
|
|
1268
1618
|
if (uniqueParts.length > 0) {
|
|
1269
|
-
titleLine += ` ${
|
|
1619
|
+
titleLine += ` ${chalk.gray(`(${uniqueParts.join(", ")})`)}`;
|
|
1270
1620
|
}
|
|
1271
1621
|
console.log(titleLine);
|
|
1272
1622
|
if (formatted.description) {
|
|
1273
|
-
console.log(` ${
|
|
1623
|
+
console.log(` ${chalk.dim(formatted.description)}`);
|
|
1274
1624
|
}
|
|
1275
1625
|
if (formatted.data !== void 0) {
|
|
1276
1626
|
formatJsonOutput(formatted.data);
|
|
@@ -1281,7 +1631,7 @@ function formatSingleItem(formatted, itemNumber) {
|
|
|
1281
1631
|
if (detail.label) {
|
|
1282
1632
|
const isMultiline = detail.text.includes("\n");
|
|
1283
1633
|
if (isMultiline) {
|
|
1284
|
-
console.log(` ${
|
|
1634
|
+
console.log(` ${chalk.gray(detail.label + ":")}`);
|
|
1285
1635
|
const displayText = formatDetailText(
|
|
1286
1636
|
detail.text,
|
|
1287
1637
|
DETAIL_INDENT + " "
|
|
@@ -1290,7 +1640,7 @@ function formatSingleItem(formatted, itemNumber) {
|
|
|
1290
1640
|
console.log(`${DETAIL_INDENT} ${styledText}`);
|
|
1291
1641
|
} else {
|
|
1292
1642
|
const styledValue = applyStyle(detail.text, detail.style);
|
|
1293
|
-
console.log(` ${
|
|
1643
|
+
console.log(` ${chalk.gray(detail.label + ":")} ${styledValue}`);
|
|
1294
1644
|
}
|
|
1295
1645
|
} else {
|
|
1296
1646
|
const displayText = formatDetailText(detail.text, DETAIL_INDENT);
|
|
@@ -1314,16 +1664,16 @@ function formatDetailText(text, indent = DETAIL_INDENT) {
|
|
|
1314
1664
|
function applyStyle(value, style) {
|
|
1315
1665
|
switch (style) {
|
|
1316
1666
|
case "dim":
|
|
1317
|
-
return
|
|
1667
|
+
return chalk.dim(value);
|
|
1318
1668
|
case "accent":
|
|
1319
|
-
return
|
|
1669
|
+
return chalk.magenta(value);
|
|
1320
1670
|
case "warning":
|
|
1321
|
-
return
|
|
1671
|
+
return chalk.red(value);
|
|
1322
1672
|
case "success":
|
|
1323
|
-
return
|
|
1673
|
+
return chalk.green(value);
|
|
1324
1674
|
case "normal":
|
|
1325
1675
|
default:
|
|
1326
|
-
return
|
|
1676
|
+
return chalk.blue(value);
|
|
1327
1677
|
}
|
|
1328
1678
|
}
|
|
1329
1679
|
function convertGenericItemToFormattedItem(item) {
|
|
@@ -1455,10 +1805,10 @@ function renderItemsForDisplay(items, functionInfo, startingNumber = 0) {
|
|
|
1455
1805
|
const obj = item;
|
|
1456
1806
|
const name = obj?.name || obj?.key || obj?.id || "Item";
|
|
1457
1807
|
console.log(
|
|
1458
|
-
`${
|
|
1808
|
+
`${chalk.gray(`${startingNumber + index + 1}.`)} ${chalk.cyan(String(name))}`
|
|
1459
1809
|
);
|
|
1460
1810
|
if (obj?.description)
|
|
1461
|
-
console.log(` ${
|
|
1811
|
+
console.log(` ${chalk.dim(String(obj.description))}`);
|
|
1462
1812
|
console.log();
|
|
1463
1813
|
});
|
|
1464
1814
|
}
|
|
@@ -1470,35 +1820,35 @@ function createInteractiveRenderer() {
|
|
|
1470
1820
|
if (!(Symbol.asyncIterator in Object(source))) {
|
|
1471
1821
|
const items = source?.data;
|
|
1472
1822
|
if (!Array.isArray(items) || items.length === 0) {
|
|
1473
|
-
console.log(
|
|
1823
|
+
console.log(chalk.yellow(`No ${itemName} found.`));
|
|
1474
1824
|
return;
|
|
1475
1825
|
}
|
|
1476
1826
|
renderItemsForDisplay(items, functionInfo, 0);
|
|
1477
|
-
console.log(
|
|
1827
|
+
console.log(chalk.green(`
|
|
1478
1828
|
\u2705 Showing ${items.length} ${itemName}`));
|
|
1479
1829
|
return;
|
|
1480
1830
|
}
|
|
1481
1831
|
let totalShown = 0;
|
|
1482
1832
|
let pageCount = 0;
|
|
1483
|
-
console.log(
|
|
1833
|
+
console.log(chalk.blue(`\u{1F4CB} ${getListTitle(functionInfo)}
|
|
1484
1834
|
`));
|
|
1485
1835
|
for await (const page of source) {
|
|
1486
1836
|
const items = page.data ?? [];
|
|
1487
1837
|
pageCount++;
|
|
1488
1838
|
if (items.length === 0 && pageCount === 1) {
|
|
1489
|
-
console.log(
|
|
1839
|
+
console.log(chalk.yellow(`No ${itemName} found.`));
|
|
1490
1840
|
return;
|
|
1491
1841
|
}
|
|
1492
1842
|
if (items.length === 0) break;
|
|
1493
1843
|
if (pageCount > 1) {
|
|
1494
1844
|
console.clear();
|
|
1495
|
-
console.log(
|
|
1845
|
+
console.log(chalk.blue(`\u{1F4CB} ${getListTitle(functionInfo)}
|
|
1496
1846
|
`));
|
|
1497
1847
|
}
|
|
1498
1848
|
renderItemsForDisplay(items, functionInfo, totalShown);
|
|
1499
1849
|
totalShown += items.length;
|
|
1500
1850
|
console.log(
|
|
1501
|
-
|
|
1851
|
+
chalk.green(
|
|
1502
1852
|
`
|
|
1503
1853
|
\u2705 Showing ${totalShown} ${itemName} (page ${pageCount})`
|
|
1504
1854
|
)
|
|
@@ -1517,7 +1867,7 @@ function createInteractiveRenderer() {
|
|
|
1517
1867
|
break;
|
|
1518
1868
|
}
|
|
1519
1869
|
}
|
|
1520
|
-
console.log(
|
|
1870
|
+
console.log(chalk.gray(`
|
|
1521
1871
|
\u{1F4C4} Finished browsing ${itemName}`));
|
|
1522
1872
|
},
|
|
1523
1873
|
renderCollectedList(items, { maxItems, userSpecifiedMaxItems, functionInfo } = {}) {
|
|
@@ -1527,30 +1877,30 @@ function createInteractiveRenderer() {
|
|
|
1527
1877
|
}
|
|
1528
1878
|
const itemName = getItemName(functionInfo);
|
|
1529
1879
|
if (items.length === 0) {
|
|
1530
|
-
console.log(
|
|
1880
|
+
console.log(chalk.yellow(`No ${itemName} found.`));
|
|
1531
1881
|
return;
|
|
1532
1882
|
}
|
|
1533
|
-
console.log(
|
|
1883
|
+
console.log(chalk.green(`
|
|
1534
1884
|
\u2705 Found ${items.length} ${itemName}:
|
|
1535
1885
|
`));
|
|
1536
1886
|
renderItemsForDisplay(items, functionInfo);
|
|
1537
1887
|
if (userSpecifiedMaxItems && maxItems) {
|
|
1538
1888
|
console.log(
|
|
1539
|
-
|
|
1889
|
+
chalk.gray(
|
|
1540
1890
|
`
|
|
1541
1891
|
\u{1F4C4} Showing up to ${maxItems} ${itemName} (--max-items ${maxItems})`
|
|
1542
1892
|
)
|
|
1543
1893
|
);
|
|
1544
1894
|
} else {
|
|
1545
|
-
console.log(
|
|
1895
|
+
console.log(chalk.gray(`
|
|
1546
1896
|
\u{1F4C4} All available ${itemName} shown`));
|
|
1547
1897
|
}
|
|
1548
1898
|
},
|
|
1549
1899
|
renderItem(value, options) {
|
|
1550
1900
|
if (options?.outputFile) {
|
|
1551
1901
|
const label = options.commandName ? `\u2705 ${options.commandName} completed successfully!` : "\u2705 Done!";
|
|
1552
|
-
console.log(
|
|
1553
|
-
console.log(
|
|
1902
|
+
console.log(chalk.green(label));
|
|
1903
|
+
console.log(chalk.gray(`Output written to: ${options.outputFile}`));
|
|
1554
1904
|
} else {
|
|
1555
1905
|
formatJsonOutput(value);
|
|
1556
1906
|
}
|
|
@@ -1560,17 +1910,17 @@ function createInteractiveRenderer() {
|
|
|
1560
1910
|
},
|
|
1561
1911
|
renderError(error) {
|
|
1562
1912
|
if (error instanceof ZapierCliMissingParametersError) {
|
|
1563
|
-
console.error(
|
|
1564
|
-
console.error("\n" +
|
|
1913
|
+
console.error(chalk.red("\u274C " + formatMissingParamsError(error)));
|
|
1914
|
+
console.error("\n" + chalk.dim("Use --help to see available options"));
|
|
1565
1915
|
throw new ZapierCliExitError(error.message, 1);
|
|
1566
1916
|
}
|
|
1567
1917
|
if (error instanceof ZapierError) {
|
|
1568
1918
|
const formattedMessage = formatErrorMessage(error);
|
|
1569
|
-
console.error(
|
|
1919
|
+
console.error(chalk.red("\u274C Error:"), formattedMessage);
|
|
1570
1920
|
throw new ZapierCliExitError(formattedMessage, 1);
|
|
1571
1921
|
}
|
|
1572
1922
|
const msg = error instanceof Error ? error.message : "Unknown error";
|
|
1573
|
-
console.error(
|
|
1923
|
+
console.error(chalk.red("\u274C Error:"), msg);
|
|
1574
1924
|
throw new ZapierCliExitError(msg, 1);
|
|
1575
1925
|
}
|
|
1576
1926
|
};
|
|
@@ -1680,7 +2030,7 @@ async function promptConfirm(confirmType, itemType) {
|
|
|
1680
2030
|
}
|
|
1681
2031
|
const configOrFn = CONFIRM_MESSAGES[confirmType];
|
|
1682
2032
|
const { messageBefore, messageAfter } = typeof configOrFn === "function" ? configOrFn(itemType) : configOrFn;
|
|
1683
|
-
console.log(
|
|
2033
|
+
console.log(chalk.yellow(`
|
|
1684
2034
|
${messageBefore}
|
|
1685
2035
|
`));
|
|
1686
2036
|
const { confirmed } = await inquirer.prompt([
|
|
@@ -1702,9 +2052,9 @@ function emitDeprecationWarning({
|
|
|
1702
2052
|
}
|
|
1703
2053
|
console.warn();
|
|
1704
2054
|
console.warn(
|
|
1705
|
-
|
|
2055
|
+
chalk.yellow.bold("\u26A0\uFE0F DEPRECATION WARNING") + chalk.yellow(` - \`${cliCommandName}\` is deprecated.`)
|
|
1706
2056
|
);
|
|
1707
|
-
console.warn(
|
|
2057
|
+
console.warn(chalk.yellow(` ${deprecation.message}`));
|
|
1708
2058
|
console.warn();
|
|
1709
2059
|
}
|
|
1710
2060
|
function emitParamDeprecationWarnings({
|
|
@@ -1718,12 +2068,12 @@ function emitParamDeprecationWarnings({
|
|
|
1718
2068
|
if (Array.isArray(value) && value.length === 0) continue;
|
|
1719
2069
|
console.warn();
|
|
1720
2070
|
console.warn(
|
|
1721
|
-
|
|
2071
|
+
chalk.yellow.bold("\u26A0\uFE0F DEPRECATION WARNING") + chalk.yellow(
|
|
1722
2072
|
` - \`${toKebabCase(param.name)}\` is deprecated and may be removed in a future release.`
|
|
1723
2073
|
)
|
|
1724
2074
|
);
|
|
1725
2075
|
if (param.deprecationMessage) {
|
|
1726
|
-
console.warn(
|
|
2076
|
+
console.warn(chalk.yellow(` ${param.deprecationMessage}`));
|
|
1727
2077
|
}
|
|
1728
2078
|
console.warn();
|
|
1729
2079
|
}
|
|
@@ -2054,7 +2404,7 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
|
|
|
2054
2404
|
functionInfo.itemType
|
|
2055
2405
|
);
|
|
2056
2406
|
if (!confirmResult.confirmed) {
|
|
2057
|
-
console.log(
|
|
2407
|
+
console.log(chalk.yellow("Operation cancelled."));
|
|
2058
2408
|
return;
|
|
2059
2409
|
}
|
|
2060
2410
|
confirmMessageAfter = confirmResult.messageAfter;
|
|
@@ -2116,7 +2466,7 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
|
|
|
2116
2466
|
renderer.renderItem(normalizedResult.value);
|
|
2117
2467
|
}
|
|
2118
2468
|
if (confirmMessageAfter) {
|
|
2119
|
-
console.log(
|
|
2469
|
+
console.log(chalk.yellow(`
|
|
2120
2470
|
${confirmMessageAfter}`));
|
|
2121
2471
|
}
|
|
2122
2472
|
break;
|
|
@@ -3159,20 +3509,20 @@ var spinPromise = async (promise, text) => {
|
|
|
3159
3509
|
};
|
|
3160
3510
|
var log = {
|
|
3161
3511
|
info: (message, ...args) => {
|
|
3162
|
-
console.log(
|
|
3512
|
+
console.log(chalk.blue("\u2139"), message, ...args);
|
|
3163
3513
|
},
|
|
3164
3514
|
error: (message, ...args) => {
|
|
3165
|
-
console.error(
|
|
3515
|
+
console.error(chalk.red("\u2716"), message, ...args);
|
|
3166
3516
|
},
|
|
3167
3517
|
success: (message, ...args) => {
|
|
3168
|
-
console.log(
|
|
3518
|
+
console.log(chalk.green("\u2713"), message, ...args);
|
|
3169
3519
|
},
|
|
3170
3520
|
warn: (message, ...args) => {
|
|
3171
|
-
console.log(
|
|
3521
|
+
console.log(chalk.yellow("\u26A0"), message, ...args);
|
|
3172
3522
|
},
|
|
3173
3523
|
debug: (message, ...args) => {
|
|
3174
3524
|
if (process.env.DEBUG === "true" || process.argv.includes("--debug")) {
|
|
3175
|
-
console.log(
|
|
3525
|
+
console.log(chalk.gray("\u{1F41B}"), message, ...args);
|
|
3176
3526
|
}
|
|
3177
3527
|
}
|
|
3178
3528
|
};
|
|
@@ -5382,7 +5732,7 @@ function buildTemplateVariables({
|
|
|
5382
5732
|
};
|
|
5383
5733
|
}
|
|
5384
5734
|
function cleanupProject({ projectDir }) {
|
|
5385
|
-
console.log("\n" +
|
|
5735
|
+
console.log("\n" + chalk.yellow("!") + " Cleaning up...");
|
|
5386
5736
|
rmSync(projectDir, { recursive: true, force: true });
|
|
5387
5737
|
}
|
|
5388
5738
|
async function withInterruptCleanup(cleanup, fn) {
|
|
@@ -5592,8 +5942,8 @@ function buildNextSteps({
|
|
|
5592
5942
|
}
|
|
5593
5943
|
function createConsoleDisplayHooks() {
|
|
5594
5944
|
return {
|
|
5595
|
-
onItemComplete: (message) => console.log(" " +
|
|
5596
|
-
onWarn: (message) => console.warn(
|
|
5945
|
+
onItemComplete: (message) => console.log(" " + chalk.green("\u2713") + " " + chalk.dim(message)),
|
|
5946
|
+
onWarn: (message) => console.warn(chalk.yellow("!") + " " + message),
|
|
5597
5947
|
onStepStart: ({
|
|
5598
5948
|
description,
|
|
5599
5949
|
stepNumber,
|
|
@@ -5602,31 +5952,31 @@ function createConsoleDisplayHooks() {
|
|
|
5602
5952
|
skipPrompts
|
|
5603
5953
|
}) => {
|
|
5604
5954
|
const progressMessage = `${description}...`;
|
|
5605
|
-
const stepCounter =
|
|
5955
|
+
const stepCounter = chalk.dim(`${stepNumber}/${totalSteps}`);
|
|
5606
5956
|
if (skipPrompts) {
|
|
5607
5957
|
console.log(
|
|
5608
|
-
"\n" +
|
|
5958
|
+
"\n" + chalk.bold(`\u276F ${progressMessage}`) + " " + stepCounter + "\n"
|
|
5609
5959
|
);
|
|
5610
5960
|
} else {
|
|
5611
5961
|
console.log(
|
|
5612
|
-
|
|
5962
|
+
chalk.dim("\u2192") + " " + progressMessage + " " + stepCounter
|
|
5613
5963
|
);
|
|
5614
5964
|
}
|
|
5615
5965
|
if (command) {
|
|
5616
|
-
console.log(" " +
|
|
5966
|
+
console.log(" " + chalk.cyan(`$ ${command}`));
|
|
5617
5967
|
}
|
|
5618
5968
|
},
|
|
5619
5969
|
onStepSuccess: ({ stepNumber, totalSteps }) => console.log(
|
|
5620
|
-
"\n" +
|
|
5970
|
+
"\n" + chalk.green("\u2713") + " " + chalk.dim(`Step ${stepNumber}/${totalSteps} complete`) + "\n"
|
|
5621
5971
|
),
|
|
5622
5972
|
onStepError: ({ description, command, err }) => {
|
|
5623
5973
|
const detail = err instanceof Error && err.message ? `
|
|
5624
|
-
${
|
|
5974
|
+
${chalk.dim(err.message)}` : "";
|
|
5625
5975
|
const hint = command ? `
|
|
5626
|
-
${
|
|
5976
|
+
${chalk.dim("run manually:")} ${chalk.cyan(`$ ${command}`)}` : "";
|
|
5627
5977
|
console.error(
|
|
5628
5978
|
`
|
|
5629
|
-
${
|
|
5979
|
+
${chalk.red("\u2716")} ${chalk.bold(description)}${chalk.dim(" failed")}${detail}${hint}`
|
|
5630
5980
|
);
|
|
5631
5981
|
}
|
|
5632
5982
|
};
|
|
@@ -5638,22 +5988,22 @@ function displaySummaryAndNextSteps({
|
|
|
5638
5988
|
packageManager
|
|
5639
5989
|
}) {
|
|
5640
5990
|
const formatStatus = (complete) => ({
|
|
5641
|
-
icon: complete ?
|
|
5642
|
-
text: complete ?
|
|
5991
|
+
icon: complete ? chalk.green("\u2713") : chalk.yellow("!"),
|
|
5992
|
+
text: complete ? chalk.green("Setup complete") : chalk.yellow("Setup interrupted")
|
|
5643
5993
|
});
|
|
5644
|
-
const formatNextStep = (step, i) => " " +
|
|
5645
|
-
const formatCommand = (cmd) => " " +
|
|
5646
|
-
const formatCompletedStep = (step) => " " +
|
|
5994
|
+
const formatNextStep = (step, i) => " " + chalk.dim(`${i + 1}.`) + " " + chalk.bold(step.description);
|
|
5995
|
+
const formatCommand = (cmd) => " " + chalk.cyan(`$ ${cmd}`);
|
|
5996
|
+
const formatCompletedStep = (step) => " " + chalk.green("\u2713") + " " + step.description;
|
|
5647
5997
|
const { execCmd } = getPackageManagerCommands({ packageManager });
|
|
5648
5998
|
const leftoverSteps = steps.filter(
|
|
5649
5999
|
(s) => !completedSetupStepIds.includes(s.id)
|
|
5650
6000
|
);
|
|
5651
6001
|
const isComplete = leftoverSteps.length === 0;
|
|
5652
6002
|
const status = formatStatus(isComplete);
|
|
5653
|
-
console.log("\n" +
|
|
5654
|
-
console.log(" " +
|
|
6003
|
+
console.log("\n" + chalk.bold("\u276F Summary") + "\n");
|
|
6004
|
+
console.log(" " + chalk.dim("Project") + " " + chalk.bold(projectName));
|
|
5655
6005
|
console.log(
|
|
5656
|
-
" " +
|
|
6006
|
+
" " + chalk.dim("Status") + " " + status.icon + " " + status.text
|
|
5657
6007
|
);
|
|
5658
6008
|
const completedSteps = steps.filter(
|
|
5659
6009
|
(s) => completedSetupStepIds.includes(s.id)
|
|
@@ -5663,7 +6013,7 @@ function displaySummaryAndNextSteps({
|
|
|
5663
6013
|
for (const step of completedSteps) console.log(formatCompletedStep(step));
|
|
5664
6014
|
}
|
|
5665
6015
|
const nextSteps = buildNextSteps({ projectName, leftoverSteps, execCmd });
|
|
5666
|
-
console.log("\n" +
|
|
6016
|
+
console.log("\n" + chalk.bold("\u276F Next Steps") + "\n");
|
|
5667
6017
|
nextSteps.forEach((step, i) => {
|
|
5668
6018
|
console.log(formatNextStep(step, i));
|
|
5669
6019
|
if (step.command) console.log(formatCommand(step.command));
|
|
@@ -5739,13 +6089,13 @@ function createInteractiveCallback() {
|
|
|
5739
6089
|
const attrs = message.message_attributes;
|
|
5740
6090
|
console.log(
|
|
5741
6091
|
`
|
|
5742
|
-
${
|
|
6092
|
+
${chalk.bold(`Message #${messageNumber}`)} ${chalk.dim(message.id)} ${chalk.dim(`(lease #${attrs.lease_count})`)}`
|
|
5743
6093
|
);
|
|
5744
6094
|
if (attrs.error_message) {
|
|
5745
|
-
console.log(
|
|
6095
|
+
console.log(chalk.yellow(` upstream error: ${attrs.error_message}`));
|
|
5746
6096
|
}
|
|
5747
6097
|
if (attrs.possible_duplicate_data) {
|
|
5748
|
-
console.log(
|
|
6098
|
+
console.log(chalk.yellow(" possible duplicate data"));
|
|
5749
6099
|
}
|
|
5750
6100
|
while (true) {
|
|
5751
6101
|
let action;
|
|
@@ -5775,7 +6125,7 @@ ${chalk7.bold(`Message #${messageNumber}`)} ${chalk7.dim(message.id)} ${chalk7.d
|
|
|
5775
6125
|
throw error;
|
|
5776
6126
|
}
|
|
5777
6127
|
if (action === "view") {
|
|
5778
|
-
console.log(
|
|
6128
|
+
console.log(chalk.dim(JSON.stringify(message.payload, null, 2)));
|
|
5779
6129
|
continue;
|
|
5780
6130
|
}
|
|
5781
6131
|
if (action === "ack") {
|
|
@@ -5878,7 +6228,7 @@ function describeReason(reason) {
|
|
|
5878
6228
|
}
|
|
5879
6229
|
function printDrainError(reason, message) {
|
|
5880
6230
|
console.error(
|
|
5881
|
-
|
|
6231
|
+
chalk.red(`Error processing ${message.id}: ${describeReason(reason)}`)
|
|
5882
6232
|
);
|
|
5883
6233
|
}
|
|
5884
6234
|
function printDrainSummary(counts) {
|
|
@@ -5888,7 +6238,7 @@ function printDrainSummary(counts) {
|
|
|
5888
6238
|
if (skipped > 0) parts.push(`${skipped} skipped`);
|
|
5889
6239
|
parts.push(`${counts.rejected} rejected`);
|
|
5890
6240
|
console.log(
|
|
5891
|
-
|
|
6241
|
+
chalk.dim(
|
|
5892
6242
|
`
|
|
5893
6243
|
Processed ${total} message${total === 1 ? "" : "s"} (${parts.join(", ")}).`
|
|
5894
6244
|
)
|
|
@@ -5896,7 +6246,7 @@ Processed ${total} message${total === 1 ? "" : "s"} (${parts.join(", ")}).`
|
|
|
5896
6246
|
}
|
|
5897
6247
|
function warnInteractiveContinueOnErrorOverride() {
|
|
5898
6248
|
console.warn(
|
|
5899
|
-
|
|
6249
|
+
chalk.yellow(
|
|
5900
6250
|
'Note: continueOnError=false is overridden to true in interactive mode (the "Skip (let lease expire)" choice would otherwise terminate the drain).'
|
|
5901
6251
|
)
|
|
5902
6252
|
);
|
|
@@ -6200,7 +6550,7 @@ var watchTriggerInboxCliPlugin = definePlugin(
|
|
|
6200
6550
|
// package.json with { type: 'json' }
|
|
6201
6551
|
var package_default2 = {
|
|
6202
6552
|
name: "@zapier/zapier-sdk-cli",
|
|
6203
|
-
version: "0.
|
|
6553
|
+
version: "0.49.0"};
|
|
6204
6554
|
|
|
6205
6555
|
// src/sdk.ts
|
|
6206
6556
|
injectCliLogin(login_exports);
|
|
@@ -6407,26 +6757,26 @@ function displayUpdateNotification(versionInfo, packageName) {
|
|
|
6407
6757
|
if (versionInfo.isDeprecated) {
|
|
6408
6758
|
console.error();
|
|
6409
6759
|
console.error(
|
|
6410
|
-
|
|
6760
|
+
chalk.red.bold("\u26A0\uFE0F DEPRECATION WARNING") + chalk.red(
|
|
6411
6761
|
` - ${packageName} v${versionInfo.currentVersion} is deprecated.`
|
|
6412
6762
|
)
|
|
6413
6763
|
);
|
|
6414
6764
|
if (versionInfo.deprecationMessage) {
|
|
6415
|
-
console.error(
|
|
6765
|
+
console.error(chalk.red(` ${versionInfo.deprecationMessage}`));
|
|
6416
6766
|
}
|
|
6417
|
-
console.error(
|
|
6767
|
+
console.error(chalk.red(` Please update to the latest version.`));
|
|
6418
6768
|
console.error();
|
|
6419
6769
|
}
|
|
6420
6770
|
if (versionInfo.hasUpdate) {
|
|
6421
6771
|
console.error();
|
|
6422
6772
|
console.error(
|
|
6423
|
-
|
|
6773
|
+
chalk.yellow.bold("\u{1F4E6} Update available!") + chalk.yellow(
|
|
6424
6774
|
` ${packageName} v${versionInfo.currentVersion} \u2192 v${versionInfo.latestVersion}`
|
|
6425
6775
|
)
|
|
6426
6776
|
);
|
|
6427
6777
|
console.error(
|
|
6428
|
-
|
|
6429
|
-
` Run ${
|
|
6778
|
+
chalk.yellow(
|
|
6779
|
+
` Run ${chalk.bold(getUpdateCommand(packageName))} to update.`
|
|
6430
6780
|
)
|
|
6431
6781
|
);
|
|
6432
6782
|
console.error();
|