@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.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() {
|
|
@@ -170,14 +171,8 @@ var SchemaParameterResolver = class {
|
|
|
170
171
|
const hasValue = this.getNestedValue(providedParams, param.path) !== void 0;
|
|
171
172
|
return !hasValue;
|
|
172
173
|
});
|
|
173
|
-
const required = missingResolvable.filter((param) =>
|
|
174
|
-
|
|
175
|
-
if (param.name === "inputs") return interactiveMode;
|
|
176
|
-
return false;
|
|
177
|
-
});
|
|
178
|
-
const optional = missingResolvable.filter(
|
|
179
|
-
(param) => !required.includes(param)
|
|
180
|
-
);
|
|
174
|
+
const required = missingResolvable.filter((param) => param.isRequired);
|
|
175
|
+
const optional = missingResolvable.filter((param) => !param.isRequired);
|
|
181
176
|
if (parseResult.success && required.length === 0 && optional.length === 0) {
|
|
182
177
|
return parseResult.data;
|
|
183
178
|
}
|
|
@@ -234,7 +229,7 @@ var SchemaParameterResolver = class {
|
|
|
234
229
|
}
|
|
235
230
|
} catch (error) {
|
|
236
231
|
if (this.isUserCancellation(error)) {
|
|
237
|
-
console.log(
|
|
232
|
+
console.log(chalk.yellow("\n\nOperation cancelled by user"));
|
|
238
233
|
throw new ZapierCliUserCancellationError();
|
|
239
234
|
}
|
|
240
235
|
throw error;
|
|
@@ -271,7 +266,7 @@ var SchemaParameterResolver = class {
|
|
|
271
266
|
}
|
|
272
267
|
} catch (error) {
|
|
273
268
|
if (this.isUserCancellation(error)) {
|
|
274
|
-
console.log(
|
|
269
|
+
console.log(chalk.yellow("\n\nOperation cancelled by user"));
|
|
275
270
|
throw new ZapierCliUserCancellationError();
|
|
276
271
|
}
|
|
277
272
|
throw error;
|
|
@@ -382,6 +377,237 @@ var SchemaParameterResolver = class {
|
|
|
382
377
|
throw new ZapierCliMissingParametersError(missingParams);
|
|
383
378
|
}
|
|
384
379
|
}
|
|
380
|
+
/**
|
|
381
|
+
* Wrap a PromptConfig.validate so internal sentinels (Symbols) bypass
|
|
382
|
+
* it. The resolver's validator is intended for actual user values; our
|
|
383
|
+
* Skip / Custom / Load-more sentinels are internal control-flow and
|
|
384
|
+
* should pass through. Returns `undefined` when the resolver didn't
|
|
385
|
+
* supply a validator (so `await search({ ...rest })` doesn't get a
|
|
386
|
+
* pass-through identity function).
|
|
387
|
+
*/
|
|
388
|
+
wrapPromptValidate(validate) {
|
|
389
|
+
if (!validate) return void 0;
|
|
390
|
+
return (value) => typeof value === "symbol" ? true : validate(value);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Apply a PromptConfig.filter to a selected value, but only when the
|
|
394
|
+
* value is a real data choice (not an internal sentinel). @inquirer/search
|
|
395
|
+
* has no built-in filter hook, so the search-backed paths call this
|
|
396
|
+
* explicitly before returning.
|
|
397
|
+
*/
|
|
398
|
+
applyPromptFilter(filter, value) {
|
|
399
|
+
if (!filter || typeof value === "symbol") return value;
|
|
400
|
+
return filter(value);
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* If the resolver's PromptConfig sets a `default` value, move the
|
|
404
|
+
* matching choice to the front so it's the first selectable item in
|
|
405
|
+
* the rendered source. @inquirer/search has no built-in `default`
|
|
406
|
+
* option; first-selectable is what Enter picks, so reordering achieves
|
|
407
|
+
* the same semantics inquirer.prompt's list had natively.
|
|
408
|
+
*
|
|
409
|
+
* Returns the original array if no default is set or the default
|
|
410
|
+
* doesn't match any current choice.
|
|
411
|
+
*/
|
|
412
|
+
reorderForDefault(matches, defaultValue) {
|
|
413
|
+
if (defaultValue === void 0) return matches;
|
|
414
|
+
const idx = matches.findIndex((c) => c.value === defaultValue);
|
|
415
|
+
if (idx <= 0) return matches;
|
|
416
|
+
return [matches[idx], ...matches.slice(0, idx), ...matches.slice(idx + 1)];
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Build the disabled "if you had X capability, more results would show"
|
|
420
|
+
* hints for any unmet capabilities the resolver declared. Returns the
|
|
421
|
+
* raw hint strings — callers wrap them into choice objects with whatever
|
|
422
|
+
* sentinel value they prefer (disabled choices' values are inert).
|
|
423
|
+
*/
|
|
424
|
+
async computeCapabilityHints(resolver, context) {
|
|
425
|
+
if (!resolver.requireCapabilities) return [];
|
|
426
|
+
const capContext = context.sdk.context;
|
|
427
|
+
if (!capContext.hasCapability) return [];
|
|
428
|
+
const messages = [];
|
|
429
|
+
for (const cap of resolver.requireCapabilities) {
|
|
430
|
+
const enabled = await capContext.hasCapability(cap);
|
|
431
|
+
if (!enabled) messages.push(buildCapabilityMessage(cap));
|
|
432
|
+
}
|
|
433
|
+
return messages;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Unpack a DynamicResolver.fetch result into the three shapes the caller
|
|
437
|
+
* cares about: a flat items array, an optional AsyncIterator for further
|
|
438
|
+
* pagination, and a hasMore flag. Centralizing keeps the AsyncIterable /
|
|
439
|
+
* `{data, nextCursor}` / `TItem[]` discrimination in one place — both
|
|
440
|
+
* the main dropdown loop and the search-mode flow consume it.
|
|
441
|
+
*
|
|
442
|
+
* The function is `async` for the AsyncIterable branch only (we eagerly
|
|
443
|
+
* consume the first page so callers don't have to discriminate). The
|
|
444
|
+
* other two branches return synchronously; an explicit Promise.resolve
|
|
445
|
+
* is unnecessary because async automatically wraps.
|
|
446
|
+
*
|
|
447
|
+
* Note: callers in search mode intentionally drop `pageIterator` /
|
|
448
|
+
* `hasMore` because each search() invocation re-prompts from scratch;
|
|
449
|
+
* pagination only matters when the prompt is the dropdown itself.
|
|
450
|
+
*/
|
|
451
|
+
async unpackFetchResult(fetchResult, promptLabel) {
|
|
452
|
+
if (fetchResult != null && typeof fetchResult === "object" && Symbol.asyncIterator in fetchResult) {
|
|
453
|
+
const pageIterator = fetchResult[Symbol.asyncIterator]();
|
|
454
|
+
const first = await pageIterator.next();
|
|
455
|
+
if (!first.done && first.value) {
|
|
456
|
+
return {
|
|
457
|
+
items: Array.isArray(first.value.data) ? first.value.data : [],
|
|
458
|
+
pageIterator,
|
|
459
|
+
hasMore: first.value.nextCursor != null
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
return { items: [], pageIterator, hasMore: false };
|
|
463
|
+
}
|
|
464
|
+
if (fetchResult != null && typeof fetchResult === "object" && "data" in fetchResult) {
|
|
465
|
+
const page = fetchResult;
|
|
466
|
+
const hasMore = page.nextCursor != null;
|
|
467
|
+
if (hasMore) {
|
|
468
|
+
this.debugLog(
|
|
469
|
+
`Resolver for ${promptLabel} has more pages but no iterator. Use toIterable() to enable "Load more..." support.`
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
return {
|
|
473
|
+
items: Array.isArray(page.data) ? page.data : [],
|
|
474
|
+
pageIterator: null,
|
|
475
|
+
hasMore
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
return {
|
|
479
|
+
items: Array.isArray(fetchResult) ? fetchResult : [],
|
|
480
|
+
pageIterator: null,
|
|
481
|
+
hasMore: false
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Search-mode dynamic resolver: prompts the user for free-form text, passes
|
|
486
|
+
* it to fetch via `search`, and either short-circuits on a primitive return
|
|
487
|
+
* (exact match) or renders the results as a search-filterable dropdown.
|
|
488
|
+
* Empty results still render the dropdown so the user can fall through to
|
|
489
|
+
* "(Use 'foo' as-is)" or "(Try a different search)" rather than being
|
|
490
|
+
* stuck.
|
|
491
|
+
*
|
|
492
|
+
* Known limitation: pagination beyond the first page is dropped. Each
|
|
493
|
+
* search() invocation re-prompts from scratch and the user is expected
|
|
494
|
+
* to refine their query if too many results came back. If a future
|
|
495
|
+
* high-cardinality search resolver needs Load-more here, the
|
|
496
|
+
* `pageIterator` / `hasMore` from `unpackFetchResult` is what to wire in.
|
|
497
|
+
*/
|
|
498
|
+
async resolveDynamicWithSearchInput({
|
|
499
|
+
resolver,
|
|
500
|
+
context,
|
|
501
|
+
promptLabel,
|
|
502
|
+
isOptional
|
|
503
|
+
}) {
|
|
504
|
+
const parenParts = [];
|
|
505
|
+
if (isOptional) parenParts.push("optional");
|
|
506
|
+
if (resolver.placeholder) parenParts.push(resolver.placeholder);
|
|
507
|
+
const parens = parenParts.length > 0 ? ` (${parenParts.join(", ")})` : "";
|
|
508
|
+
const message = `Enter or search ${promptLabel}${parens}:`;
|
|
509
|
+
const SKIP_SENTINEL = Symbol("SKIP");
|
|
510
|
+
const USE_AS_IS_SENTINEL = Symbol("USE_AS_IS");
|
|
511
|
+
const TRY_AGAIN_SENTINEL = Symbol("TRY_AGAIN");
|
|
512
|
+
let lastNote;
|
|
513
|
+
while (true) {
|
|
514
|
+
this.stopSpinner();
|
|
515
|
+
if (lastNote) {
|
|
516
|
+
console.log(chalk.yellow(lastNote));
|
|
517
|
+
lastNote = void 0;
|
|
518
|
+
}
|
|
519
|
+
const answers = await inquirer.prompt([
|
|
520
|
+
{ type: "input", name: "search", message }
|
|
521
|
+
]);
|
|
522
|
+
const rawInput = answers.search;
|
|
523
|
+
const searchInput = typeof rawInput === "string" ? rawInput.trim() : "";
|
|
524
|
+
if (!searchInput) {
|
|
525
|
+
if (isOptional) return void 0;
|
|
526
|
+
lastNote = `${promptLabel} is required.`;
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
const searchParams = {
|
|
530
|
+
...context.resolvedParams,
|
|
531
|
+
search: searchInput
|
|
532
|
+
};
|
|
533
|
+
this.startSpinner();
|
|
534
|
+
this.debugLog(`Searching ${promptLabel} for "${searchInput}"`);
|
|
535
|
+
let fetchResult;
|
|
536
|
+
try {
|
|
537
|
+
fetchResult = await resolver.fetch(context.sdk, searchParams);
|
|
538
|
+
} finally {
|
|
539
|
+
this.stopSpinner();
|
|
540
|
+
}
|
|
541
|
+
if (typeof fetchResult === "string" || typeof fetchResult === "number") {
|
|
542
|
+
return fetchResult;
|
|
543
|
+
}
|
|
544
|
+
const { items } = await this.unpackFetchResult(fetchResult, promptLabel);
|
|
545
|
+
const choicesConfig = resolver.prompt(items, searchParams);
|
|
546
|
+
const dataChoices = choicesConfig.choices ?? [];
|
|
547
|
+
const capabilityHintMessages = await this.computeCapabilityHints(
|
|
548
|
+
resolver,
|
|
549
|
+
context
|
|
550
|
+
);
|
|
551
|
+
const selected = await search({
|
|
552
|
+
message: choicesConfig.message,
|
|
553
|
+
validate: this.wrapPromptValidate(choicesConfig.validate),
|
|
554
|
+
// @inquirer/search passes an AbortSignal as the second arg for
|
|
555
|
+
// cancelling async sources. All three of our source callbacks are
|
|
556
|
+
// pure-local (filter an already-fetched array), so we intentionally
|
|
557
|
+
// ignore the signal. A future server-side filter implementation
|
|
558
|
+
// would need to honor it.
|
|
559
|
+
source: (term) => {
|
|
560
|
+
const trimmed = (term ?? "").trim();
|
|
561
|
+
const lower = trimmed.toLowerCase();
|
|
562
|
+
const matches = trimmed ? dataChoices.filter((c) => c.name.toLowerCase().includes(lower)) : dataChoices;
|
|
563
|
+
const orderedMatches = trimmed ? matches : this.reorderForDefault(matches, choicesConfig.default);
|
|
564
|
+
const skipChoice = isOptional ? [{ name: chalk.dim("(Skip)"), value: SKIP_SENTINEL }] : [];
|
|
565
|
+
const useAsIsChoice = {
|
|
566
|
+
name: chalk.dim(`(Use ${JSON.stringify(searchInput)} as-is)`),
|
|
567
|
+
value: USE_AS_IS_SENTINEL
|
|
568
|
+
};
|
|
569
|
+
const tryAgainChoice = {
|
|
570
|
+
name: chalk.dim("(Try a different search)"),
|
|
571
|
+
value: TRY_AGAIN_SENTINEL
|
|
572
|
+
};
|
|
573
|
+
const out = [];
|
|
574
|
+
if (orderedMatches.length === 0) {
|
|
575
|
+
out.push(useAsIsChoice);
|
|
576
|
+
out.push(tryAgainChoice);
|
|
577
|
+
out.push(...skipChoice);
|
|
578
|
+
} else {
|
|
579
|
+
out.push(...orderedMatches);
|
|
580
|
+
out.push(...skipChoice);
|
|
581
|
+
out.push(useAsIsChoice);
|
|
582
|
+
out.push(tryAgainChoice);
|
|
583
|
+
}
|
|
584
|
+
for (const message2 of capabilityHintMessages) {
|
|
585
|
+
out.push({
|
|
586
|
+
name: chalk.dim(message2),
|
|
587
|
+
value: SKIP_SENTINEL,
|
|
588
|
+
disabled: true
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
return out;
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
if (selected === SKIP_SENTINEL) return void 0;
|
|
595
|
+
if (selected === USE_AS_IS_SENTINEL) {
|
|
596
|
+
const validationResult = choicesConfig.validate?.(searchInput);
|
|
597
|
+
if (validationResult === false) {
|
|
598
|
+
lastNote = `${promptLabel}: invalid value.`;
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
601
|
+
if (typeof validationResult === "string") {
|
|
602
|
+
lastNote = validationResult;
|
|
603
|
+
continue;
|
|
604
|
+
}
|
|
605
|
+
return this.applyPromptFilter(choicesConfig.filter, searchInput);
|
|
606
|
+
}
|
|
607
|
+
if (selected === TRY_AGAIN_SENTINEL) continue;
|
|
608
|
+
return this.applyPromptFilter(choicesConfig.filter, selected);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
385
611
|
async resolveParameter(param, context, functionName, options) {
|
|
386
612
|
const resolver = this.getResolver(
|
|
387
613
|
param.name,
|
|
@@ -395,6 +621,27 @@ var SchemaParameterResolver = class {
|
|
|
395
621
|
isOptional: options?.isOptional
|
|
396
622
|
});
|
|
397
623
|
}
|
|
624
|
+
/**
|
|
625
|
+
* Run a resolver to obtain a value for one parameter, prompting the
|
|
626
|
+
* user when necessary. Routes to one of several prompt backends and
|
|
627
|
+
* has to keep the `PromptConfig` contract honest across each one.
|
|
628
|
+
*
|
|
629
|
+
* `PromptConfig` field × prompt-backend handling:
|
|
630
|
+
*
|
|
631
|
+
* | field | list (search()) | checkbox/confirm (inquirer.prompt) | search-mode dropdown (search()) |
|
|
632
|
+
* | -------- | --------------- | ---------------------------------- | ------------------------------- |
|
|
633
|
+
* | type | required | required | required |
|
|
634
|
+
* | name | (set internally)| forwarded | (set internally) |
|
|
635
|
+
* | message | forwarded | forwarded | forwarded |
|
|
636
|
+
* | choices | filtered in src | passed to inquirer | filtered in src |
|
|
637
|
+
* | default | reorder matches | passed (also internal cursor jump) | reorder matches |
|
|
638
|
+
* | validate | wrapped | passed (inquirer native) | wrapped + manual for (Use as-is)|
|
|
639
|
+
* | filter | manual once | inquirer native (do NOT double) | manual once |
|
|
640
|
+
*
|
|
641
|
+
* Escape-hatch sentinels (Skip / Custom value / Use as-is / Load more
|
|
642
|
+
* / Try again) bypass the resolver's validate/filter because they
|
|
643
|
+
* aren't real user values — they're CLI control-flow.
|
|
644
|
+
*/
|
|
398
645
|
async resolveWithResolver(resolver, param, context, options = {}) {
|
|
399
646
|
const { arrayIndex, isOptional } = options;
|
|
400
647
|
const inArrayContext = arrayIndex != null;
|
|
@@ -433,41 +680,52 @@ var SchemaParameterResolver = class {
|
|
|
433
680
|
this.stopSpinner();
|
|
434
681
|
return autoResolution.resolvedValue;
|
|
435
682
|
}
|
|
683
|
+
if (dynamicResolver.inputType === "search") {
|
|
684
|
+
this.stopSpinner();
|
|
685
|
+
return await this.resolveDynamicWithSearchInput({
|
|
686
|
+
resolver: dynamicResolver,
|
|
687
|
+
context,
|
|
688
|
+
promptLabel,
|
|
689
|
+
isOptional: isOptional ?? false
|
|
690
|
+
});
|
|
691
|
+
}
|
|
436
692
|
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
|
-
|
|
693
|
+
let fetchResult;
|
|
694
|
+
try {
|
|
695
|
+
fetchResult = await dynamicResolver.fetch(
|
|
696
|
+
context.sdk,
|
|
697
|
+
context.resolvedParams
|
|
698
|
+
);
|
|
699
|
+
} finally {
|
|
700
|
+
this.stopSpinner();
|
|
701
|
+
}
|
|
702
|
+
if (typeof fetchResult === "string" || typeof fetchResult === "number") {
|
|
703
|
+
console.error(
|
|
704
|
+
chalk.yellow(
|
|
705
|
+
`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.`
|
|
706
|
+
)
|
|
707
|
+
);
|
|
708
|
+
const fallbackAnswers = await inquirer.prompt([
|
|
709
|
+
{
|
|
710
|
+
type: "input",
|
|
711
|
+
name: promptName,
|
|
712
|
+
message: `Enter ${promptLabel}${isOptional ? " (optional)" : ""}:`
|
|
713
|
+
}
|
|
714
|
+
]);
|
|
715
|
+
const fallbackValue = fallbackAnswers[promptName];
|
|
716
|
+
if (isOptional && (fallbackValue === void 0 || fallbackValue === "")) {
|
|
717
|
+
return void 0;
|
|
461
718
|
}
|
|
462
|
-
|
|
463
|
-
items = fetchResult || [];
|
|
464
|
-
pageIterator = null;
|
|
719
|
+
return fallbackValue;
|
|
465
720
|
}
|
|
721
|
+
const unpacked = await this.unpackFetchResult(fetchResult, promptLabel);
|
|
722
|
+
let pageIterator = unpacked.pageIterator;
|
|
723
|
+
let items = unpacked.items;
|
|
724
|
+
let hasMore = unpacked.hasMore;
|
|
466
725
|
const LOAD_MORE_SENTINEL = Symbol("LOAD_MORE");
|
|
467
726
|
const SKIP_SENTINEL = Symbol("SKIP");
|
|
468
727
|
const CUSTOM_VALUE_SENTINEL = Symbol("CUSTOM_VALUE");
|
|
469
728
|
let newItemsStartIndex = -1;
|
|
470
|
-
this.stopSpinner();
|
|
471
729
|
while (true) {
|
|
472
730
|
const promptConfig = dynamicResolver.prompt(
|
|
473
731
|
items,
|
|
@@ -482,50 +740,97 @@ var SchemaParameterResolver = class {
|
|
|
482
740
|
`No ${promptLabel} available to select.`
|
|
483
741
|
);
|
|
484
742
|
}
|
|
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
|
-
});
|
|
743
|
+
const capabilityHints = [];
|
|
744
|
+
if (!hasMore) {
|
|
745
|
+
const hintMessages = await this.computeCapabilityHints(
|
|
746
|
+
dynamicResolver,
|
|
747
|
+
context
|
|
748
|
+
);
|
|
749
|
+
for (const message of hintMessages) {
|
|
750
|
+
capabilityHints.push({
|
|
751
|
+
name: chalk.dim(message),
|
|
752
|
+
value: SKIP_SENTINEL,
|
|
753
|
+
disabled: true
|
|
754
|
+
});
|
|
755
|
+
}
|
|
503
756
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
757
|
+
let selected;
|
|
758
|
+
if (promptConfig.type === "list") {
|
|
759
|
+
const dataChoices = promptConfig.choices ?? [];
|
|
760
|
+
selected = await search({
|
|
761
|
+
message: promptConfig.message,
|
|
762
|
+
validate: this.wrapPromptValidate(promptConfig.validate),
|
|
763
|
+
source: (term) => {
|
|
764
|
+
const trimmed = (term ?? "").trim();
|
|
765
|
+
const lower = trimmed.toLowerCase();
|
|
766
|
+
const matches = trimmed ? dataChoices.filter(
|
|
767
|
+
(c) => c.name.toLowerCase().includes(lower)
|
|
768
|
+
) : dataChoices;
|
|
769
|
+
const out = [];
|
|
770
|
+
const skipChoice = isOptional ? [
|
|
771
|
+
{
|
|
772
|
+
name: chalk.dim("(Skip)"),
|
|
773
|
+
value: SKIP_SENTINEL
|
|
774
|
+
}
|
|
775
|
+
] : [];
|
|
776
|
+
const customValueChoice = {
|
|
777
|
+
name: chalk.dim("(Enter custom value)"),
|
|
778
|
+
value: CUSTOM_VALUE_SENTINEL
|
|
779
|
+
};
|
|
780
|
+
const orderedMatches = trimmed ? matches : this.reorderForDefault(matches, promptConfig.default);
|
|
781
|
+
const matchesFirst = trimmed || promptConfig.default !== void 0;
|
|
782
|
+
const loadMoreChoice = hasMore && pageIterator ? {
|
|
783
|
+
name: chalk.dim("(Load more...)"),
|
|
784
|
+
value: LOAD_MORE_SENTINEL
|
|
785
|
+
} : null;
|
|
786
|
+
if (matchesFirst && orderedMatches.length > 0) {
|
|
787
|
+
out.push(...orderedMatches);
|
|
788
|
+
out.push(...skipChoice);
|
|
789
|
+
out.push(customValueChoice);
|
|
790
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
791
|
+
} else if (matchesFirst) {
|
|
792
|
+
out.push(customValueChoice);
|
|
793
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
794
|
+
out.push(...skipChoice);
|
|
795
|
+
} else {
|
|
796
|
+
out.push(...skipChoice);
|
|
797
|
+
out.push(customValueChoice);
|
|
798
|
+
out.push(...orderedMatches);
|
|
799
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
515
800
|
}
|
|
801
|
+
if (capabilityHints.length > 0 && (!trimmed || matches.length > 0)) {
|
|
802
|
+
out.push(...capabilityHints);
|
|
803
|
+
}
|
|
804
|
+
return out;
|
|
516
805
|
}
|
|
806
|
+
});
|
|
807
|
+
} else {
|
|
808
|
+
if (isOptional && promptConfig.choices) {
|
|
809
|
+
promptConfig.choices.unshift({
|
|
810
|
+
name: chalk.dim("(Skip)"),
|
|
811
|
+
value: SKIP_SENTINEL
|
|
812
|
+
});
|
|
517
813
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
promptConfig.default = promptConfig.choices[adjustedIndex].value;
|
|
814
|
+
if (hasMore && pageIterator && promptConfig.choices) {
|
|
815
|
+
promptConfig.choices.push({
|
|
816
|
+
name: chalk.dim("(Load more...)"),
|
|
817
|
+
value: LOAD_MORE_SENTINEL
|
|
818
|
+
});
|
|
524
819
|
}
|
|
525
|
-
|
|
820
|
+
if (capabilityHints.length > 0 && promptConfig.choices) {
|
|
821
|
+
promptConfig.choices.push(...capabilityHints);
|
|
822
|
+
}
|
|
823
|
+
if (newItemsStartIndex >= 0 && promptConfig.choices) {
|
|
824
|
+
const injectedBefore = isOptional ? 1 : 0;
|
|
825
|
+
const adjustedIndex = newItemsStartIndex + injectedBefore;
|
|
826
|
+
if (promptConfig.choices[adjustedIndex]) {
|
|
827
|
+
promptConfig.default = promptConfig.choices[adjustedIndex].value;
|
|
828
|
+
}
|
|
829
|
+
newItemsStartIndex = -1;
|
|
830
|
+
}
|
|
831
|
+
const answers = await inquirer.prompt([promptConfig]);
|
|
832
|
+
selected = answers[promptName];
|
|
526
833
|
}
|
|
527
|
-
const answers = await inquirer.prompt([promptConfig]);
|
|
528
|
-
let selected = answers[promptName];
|
|
529
834
|
if (selected === SKIP_SENTINEL) {
|
|
530
835
|
return void 0;
|
|
531
836
|
}
|
|
@@ -564,7 +869,7 @@ var SchemaParameterResolver = class {
|
|
|
564
869
|
}
|
|
565
870
|
continue;
|
|
566
871
|
}
|
|
567
|
-
return selected;
|
|
872
|
+
return promptConfig.type === "list" ? this.applyPromptFilter(promptConfig.filter, selected) : selected;
|
|
568
873
|
}
|
|
569
874
|
} else if (resolver.type === "fields") {
|
|
570
875
|
if (isOptional && !inArrayContext) {
|
|
@@ -622,7 +927,7 @@ var SchemaParameterResolver = class {
|
|
|
622
927
|
if (!rootFieldItems || rootFieldItems.length === 0) {
|
|
623
928
|
if (iteration === 1) {
|
|
624
929
|
console.log(
|
|
625
|
-
|
|
930
|
+
chalk.yellow(`No input fields required for this action.`)
|
|
626
931
|
);
|
|
627
932
|
}
|
|
628
933
|
break;
|
|
@@ -645,7 +950,7 @@ var SchemaParameterResolver = class {
|
|
|
645
950
|
}
|
|
646
951
|
if (iteration >= maxIterations) {
|
|
647
952
|
console.log(
|
|
648
|
-
|
|
953
|
+
chalk.yellow(
|
|
649
954
|
`
|
|
650
955
|
\u26A0\uFE0F Maximum field resolution iterations reached. Some dynamic fields may not have been discovered.`
|
|
651
956
|
)
|
|
@@ -696,7 +1001,7 @@ var SchemaParameterResolver = class {
|
|
|
696
1001
|
};
|
|
697
1002
|
}
|
|
698
1003
|
if (items.length >= maxItems) {
|
|
699
|
-
console.log(
|
|
1004
|
+
console.log(chalk.gray(`Maximum of ${maxItems} items reached.`));
|
|
700
1005
|
}
|
|
701
1006
|
return items;
|
|
702
1007
|
}
|
|
@@ -714,7 +1019,7 @@ var SchemaParameterResolver = class {
|
|
|
714
1019
|
const fieldsetTitle = typedItem.title || typedItem.key;
|
|
715
1020
|
const pathDisplay = fieldsetPath.length > 0 ? ` (in ${fieldsetPath.join(" > ")})` : "";
|
|
716
1021
|
console.log(
|
|
717
|
-
|
|
1022
|
+
chalk.cyan(
|
|
718
1023
|
`
|
|
719
1024
|
\u{1F4C1} Processing fieldset: ${fieldsetTitle}${pathDisplay}`
|
|
720
1025
|
)
|
|
@@ -782,7 +1087,7 @@ var SchemaParameterResolver = class {
|
|
|
782
1087
|
}
|
|
783
1088
|
} else {
|
|
784
1089
|
console.log(
|
|
785
|
-
|
|
1090
|
+
chalk.gray(
|
|
786
1091
|
`
|
|
787
1092
|
There are ${optionalFields.length} ${iteration === 1 ? "" : "additional "}optional field(s) available${pathContext}.`
|
|
788
1093
|
)
|
|
@@ -797,7 +1102,7 @@ There are ${optionalFields.length} ${iteration === 1 ? "" : "additional "}option
|
|
|
797
1102
|
}
|
|
798
1103
|
]);
|
|
799
1104
|
if (shouldConfigureOptional.configure) {
|
|
800
|
-
console.log(
|
|
1105
|
+
console.log(chalk.cyan(`
|
|
801
1106
|
Optional fields${pathContext}:`));
|
|
802
1107
|
for (const field of optionalFields) {
|
|
803
1108
|
await this.promptForField(field, targetInputs, context);
|
|
@@ -813,7 +1118,7 @@ Optional fields${pathContext}:`));
|
|
|
813
1118
|
}
|
|
814
1119
|
} catch (error) {
|
|
815
1120
|
if (this.isUserCancellation(error)) {
|
|
816
|
-
console.log(
|
|
1121
|
+
console.log(chalk.yellow("\n\nOperation cancelled by user"));
|
|
817
1122
|
throw new ZapierCliUserCancellationError();
|
|
818
1123
|
}
|
|
819
1124
|
throw error;
|
|
@@ -889,7 +1194,7 @@ Optional fields${pathContext}:`));
|
|
|
889
1194
|
}));
|
|
890
1195
|
if (choices.length === 0 && !cursor) {
|
|
891
1196
|
console.log(
|
|
892
|
-
|
|
1197
|
+
chalk.yellow(`No choices available for ${fieldMeta.title}`)
|
|
893
1198
|
);
|
|
894
1199
|
}
|
|
895
1200
|
return {
|
|
@@ -899,14 +1204,17 @@ Optional fields${pathContext}:`));
|
|
|
899
1204
|
} catch (error) {
|
|
900
1205
|
this.stopSpinner();
|
|
901
1206
|
console.warn(
|
|
902
|
-
|
|
1207
|
+
chalk.yellow(`Failed to fetch choices for ${fieldMeta.title}:`),
|
|
903
1208
|
error
|
|
904
1209
|
);
|
|
905
1210
|
return { choices: [] };
|
|
906
1211
|
}
|
|
907
1212
|
}
|
|
908
1213
|
/**
|
|
909
|
-
* Prompt user with choices (handles both single and multi-select with pagination)
|
|
1214
|
+
* Prompt user with choices (handles both single and multi-select with pagination).
|
|
1215
|
+
* Single-select goes through @inquirer/search so users can type-to-filter long
|
|
1216
|
+
* dropdowns (SELECT fields); multi-select stays on inquirer.prompt since search
|
|
1217
|
+
* is single-select only.
|
|
910
1218
|
*/
|
|
911
1219
|
async promptWithChoices({
|
|
912
1220
|
fieldMeta,
|
|
@@ -919,45 +1227,81 @@ Optional fields${pathContext}:`));
|
|
|
919
1227
|
const choices = [...initialChoices];
|
|
920
1228
|
let nextCursor = initialCursor;
|
|
921
1229
|
const LOAD_MORE_SENTINEL = Symbol("LOAD_MORE");
|
|
1230
|
+
const SKIP_SENTINEL = Symbol("SKIP");
|
|
922
1231
|
const CUSTOM_VALUE_SENTINEL = Symbol("CUSTOM_VALUE");
|
|
1232
|
+
const message = `${fieldMeta.title}${fieldMeta.isRequired ? " (required)" : " (optional)"}:`;
|
|
923
1233
|
while (true) {
|
|
924
|
-
|
|
925
|
-
name: choice.label,
|
|
926
|
-
value: choice.value
|
|
927
|
-
}));
|
|
1234
|
+
let selectedValue;
|
|
928
1235
|
if (!fieldMeta.isMultiSelect) {
|
|
929
|
-
|
|
930
|
-
name:
|
|
931
|
-
value:
|
|
932
|
-
});
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
1236
|
+
const dataChoices = choices.map((c) => ({
|
|
1237
|
+
name: c.label,
|
|
1238
|
+
value: c.value
|
|
1239
|
+
}));
|
|
1240
|
+
selectedValue = await search({
|
|
1241
|
+
message,
|
|
1242
|
+
source: (term) => {
|
|
1243
|
+
const trimmed = (term ?? "").trim();
|
|
1244
|
+
const lower = trimmed.toLowerCase();
|
|
1245
|
+
const matches = trimmed ? dataChoices.filter((c) => c.name.toLowerCase().includes(lower)) : dataChoices;
|
|
1246
|
+
const out = [];
|
|
1247
|
+
const skipChoice = !fieldMeta.isRequired ? [{ name: chalk.dim("(Skip)"), value: SKIP_SENTINEL }] : [];
|
|
1248
|
+
const customValueChoice = {
|
|
1249
|
+
name: chalk.dim("(Enter custom value)"),
|
|
1250
|
+
value: CUSTOM_VALUE_SENTINEL
|
|
1251
|
+
};
|
|
1252
|
+
const loadMoreChoice = nextCursor && context ? {
|
|
1253
|
+
name: chalk.dim("(Load more...)"),
|
|
1254
|
+
value: LOAD_MORE_SENTINEL
|
|
1255
|
+
} : null;
|
|
1256
|
+
if (trimmed && matches.length > 0) {
|
|
1257
|
+
out.push(...matches);
|
|
1258
|
+
out.push(...skipChoice);
|
|
1259
|
+
out.push(customValueChoice);
|
|
1260
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
1261
|
+
} else if (trimmed) {
|
|
1262
|
+
out.push(customValueChoice);
|
|
1263
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
1264
|
+
out.push(...skipChoice);
|
|
1265
|
+
} else {
|
|
1266
|
+
out.push(...skipChoice);
|
|
1267
|
+
out.push(customValueChoice);
|
|
1268
|
+
out.push(...matches);
|
|
1269
|
+
if (loadMoreChoice) out.push(loadMoreChoice);
|
|
1270
|
+
}
|
|
1271
|
+
return out;
|
|
1272
|
+
}
|
|
938
1273
|
});
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1274
|
+
if (selectedValue === SKIP_SENTINEL) {
|
|
1275
|
+
return void 0;
|
|
1276
|
+
}
|
|
1277
|
+
if (selectedValue === CUSTOM_VALUE_SENTINEL) {
|
|
1278
|
+
return await this.promptFreeForm(fieldMeta);
|
|
1279
|
+
}
|
|
1280
|
+
} else {
|
|
1281
|
+
const promptChoices = choices.map((c) => ({
|
|
1282
|
+
name: c.label,
|
|
1283
|
+
value: c.value
|
|
1284
|
+
}));
|
|
1285
|
+
if (nextCursor) {
|
|
1286
|
+
promptChoices.push({
|
|
1287
|
+
name: chalk.dim("(Load more...)"),
|
|
1288
|
+
value: LOAD_MORE_SENTINEL
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
const promptConfig = {
|
|
1292
|
+
type: "checkbox",
|
|
1293
|
+
name: fieldMeta.key,
|
|
1294
|
+
message,
|
|
1295
|
+
choices: promptChoices,
|
|
949
1296
|
validate: (input) => {
|
|
950
1297
|
if (fieldMeta.isRequired && (!input || input.length === 0)) {
|
|
951
1298
|
return "At least one selection is required";
|
|
952
1299
|
}
|
|
953
1300
|
return true;
|
|
954
1301
|
}
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
let selectedValue = answer[fieldMeta.key];
|
|
959
|
-
if (selectedValue === CUSTOM_VALUE_SENTINEL) {
|
|
960
|
-
return await this.promptFreeForm(fieldMeta);
|
|
1302
|
+
};
|
|
1303
|
+
const answer = await inquirer.prompt([promptConfig]);
|
|
1304
|
+
selectedValue = answer[fieldMeta.key];
|
|
961
1305
|
}
|
|
962
1306
|
const wantsMore = fieldMeta.isMultiSelect ? Array.isArray(selectedValue) && selectedValue.includes(LOAD_MORE_SENTINEL) : selectedValue === LOAD_MORE_SENTINEL;
|
|
963
1307
|
if (wantsMore && nextCursor && context) {
|
|
@@ -1020,7 +1364,7 @@ Optional fields${pathContext}:`));
|
|
|
1020
1364
|
};
|
|
1021
1365
|
}
|
|
1022
1366
|
if (fieldMeta.description) {
|
|
1023
|
-
promptConfig.prefix =
|
|
1367
|
+
promptConfig.prefix = chalk.gray(`\u2139 ${fieldMeta.description}
|
|
1024
1368
|
`);
|
|
1025
1369
|
}
|
|
1026
1370
|
try {
|
|
@@ -1028,7 +1372,7 @@ Optional fields${pathContext}:`));
|
|
|
1028
1372
|
return answer[fieldMeta.key];
|
|
1029
1373
|
} catch (error) {
|
|
1030
1374
|
if (this.isUserCancellation(error)) {
|
|
1031
|
-
console.log(
|
|
1375
|
+
console.log(chalk.yellow("\n\nOperation cancelled by user"));
|
|
1032
1376
|
throw new ZapierCliUserCancellationError();
|
|
1033
1377
|
}
|
|
1034
1378
|
throw error;
|
|
@@ -1046,7 +1390,7 @@ Optional fields${pathContext}:`));
|
|
|
1046
1390
|
}
|
|
1047
1391
|
} catch (error) {
|
|
1048
1392
|
if (this.isUserCancellation(error)) {
|
|
1049
|
-
console.log(
|
|
1393
|
+
console.log(chalk.yellow("\n\nOperation cancelled by user"));
|
|
1050
1394
|
throw new ZapierCliUserCancellationError();
|
|
1051
1395
|
}
|
|
1052
1396
|
throw error;
|
|
@@ -1169,7 +1513,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
|
|
|
1169
1513
|
|
|
1170
1514
|
// package.json
|
|
1171
1515
|
var package_default = {
|
|
1172
|
-
version: "0.
|
|
1516
|
+
version: "0.49.1"};
|
|
1173
1517
|
|
|
1174
1518
|
// src/telemetry/builders.ts
|
|
1175
1519
|
function createCliBaseEvent(context = {}) {
|
|
@@ -1254,7 +1598,7 @@ async function formatItemsFromSchema(functionInfo, items, startingNumber = 0, op
|
|
|
1254
1598
|
});
|
|
1255
1599
|
}
|
|
1256
1600
|
function formatSingleItem(formatted, itemNumber) {
|
|
1257
|
-
let titleLine = `${
|
|
1601
|
+
let titleLine = `${chalk.gray(`${itemNumber + 1}.`)} ${chalk.cyan(formatted.title)}`;
|
|
1258
1602
|
const subtitleParts = [];
|
|
1259
1603
|
if (formatted.keys) {
|
|
1260
1604
|
subtitleParts.push(...formatted.keys);
|
|
@@ -1266,11 +1610,11 @@ function formatSingleItem(formatted, itemNumber) {
|
|
|
1266
1610
|
}
|
|
1267
1611
|
const uniqueParts = [...new Set(subtitleParts)];
|
|
1268
1612
|
if (uniqueParts.length > 0) {
|
|
1269
|
-
titleLine += ` ${
|
|
1613
|
+
titleLine += ` ${chalk.gray(`(${uniqueParts.join(", ")})`)}`;
|
|
1270
1614
|
}
|
|
1271
1615
|
console.log(titleLine);
|
|
1272
1616
|
if (formatted.description) {
|
|
1273
|
-
console.log(` ${
|
|
1617
|
+
console.log(` ${chalk.dim(formatted.description)}`);
|
|
1274
1618
|
}
|
|
1275
1619
|
if (formatted.data !== void 0) {
|
|
1276
1620
|
formatJsonOutput(formatted.data);
|
|
@@ -1281,7 +1625,7 @@ function formatSingleItem(formatted, itemNumber) {
|
|
|
1281
1625
|
if (detail.label) {
|
|
1282
1626
|
const isMultiline = detail.text.includes("\n");
|
|
1283
1627
|
if (isMultiline) {
|
|
1284
|
-
console.log(` ${
|
|
1628
|
+
console.log(` ${chalk.gray(detail.label + ":")}`);
|
|
1285
1629
|
const displayText = formatDetailText(
|
|
1286
1630
|
detail.text,
|
|
1287
1631
|
DETAIL_INDENT + " "
|
|
@@ -1290,7 +1634,7 @@ function formatSingleItem(formatted, itemNumber) {
|
|
|
1290
1634
|
console.log(`${DETAIL_INDENT} ${styledText}`);
|
|
1291
1635
|
} else {
|
|
1292
1636
|
const styledValue = applyStyle(detail.text, detail.style);
|
|
1293
|
-
console.log(` ${
|
|
1637
|
+
console.log(` ${chalk.gray(detail.label + ":")} ${styledValue}`);
|
|
1294
1638
|
}
|
|
1295
1639
|
} else {
|
|
1296
1640
|
const displayText = formatDetailText(detail.text, DETAIL_INDENT);
|
|
@@ -1314,16 +1658,16 @@ function formatDetailText(text, indent = DETAIL_INDENT) {
|
|
|
1314
1658
|
function applyStyle(value, style) {
|
|
1315
1659
|
switch (style) {
|
|
1316
1660
|
case "dim":
|
|
1317
|
-
return
|
|
1661
|
+
return chalk.dim(value);
|
|
1318
1662
|
case "accent":
|
|
1319
|
-
return
|
|
1663
|
+
return chalk.magenta(value);
|
|
1320
1664
|
case "warning":
|
|
1321
|
-
return
|
|
1665
|
+
return chalk.red(value);
|
|
1322
1666
|
case "success":
|
|
1323
|
-
return
|
|
1667
|
+
return chalk.green(value);
|
|
1324
1668
|
case "normal":
|
|
1325
1669
|
default:
|
|
1326
|
-
return
|
|
1670
|
+
return chalk.blue(value);
|
|
1327
1671
|
}
|
|
1328
1672
|
}
|
|
1329
1673
|
function convertGenericItemToFormattedItem(item) {
|
|
@@ -1455,10 +1799,10 @@ function renderItemsForDisplay(items, functionInfo, startingNumber = 0) {
|
|
|
1455
1799
|
const obj = item;
|
|
1456
1800
|
const name = obj?.name || obj?.key || obj?.id || "Item";
|
|
1457
1801
|
console.log(
|
|
1458
|
-
`${
|
|
1802
|
+
`${chalk.gray(`${startingNumber + index + 1}.`)} ${chalk.cyan(String(name))}`
|
|
1459
1803
|
);
|
|
1460
1804
|
if (obj?.description)
|
|
1461
|
-
console.log(` ${
|
|
1805
|
+
console.log(` ${chalk.dim(String(obj.description))}`);
|
|
1462
1806
|
console.log();
|
|
1463
1807
|
});
|
|
1464
1808
|
}
|
|
@@ -1470,35 +1814,35 @@ function createInteractiveRenderer() {
|
|
|
1470
1814
|
if (!(Symbol.asyncIterator in Object(source))) {
|
|
1471
1815
|
const items = source?.data;
|
|
1472
1816
|
if (!Array.isArray(items) || items.length === 0) {
|
|
1473
|
-
console.log(
|
|
1817
|
+
console.log(chalk.yellow(`No ${itemName} found.`));
|
|
1474
1818
|
return;
|
|
1475
1819
|
}
|
|
1476
1820
|
renderItemsForDisplay(items, functionInfo, 0);
|
|
1477
|
-
console.log(
|
|
1821
|
+
console.log(chalk.green(`
|
|
1478
1822
|
\u2705 Showing ${items.length} ${itemName}`));
|
|
1479
1823
|
return;
|
|
1480
1824
|
}
|
|
1481
1825
|
let totalShown = 0;
|
|
1482
1826
|
let pageCount = 0;
|
|
1483
|
-
console.log(
|
|
1827
|
+
console.log(chalk.blue(`\u{1F4CB} ${getListTitle(functionInfo)}
|
|
1484
1828
|
`));
|
|
1485
1829
|
for await (const page of source) {
|
|
1486
1830
|
const items = page.data ?? [];
|
|
1487
1831
|
pageCount++;
|
|
1488
1832
|
if (items.length === 0 && pageCount === 1) {
|
|
1489
|
-
console.log(
|
|
1833
|
+
console.log(chalk.yellow(`No ${itemName} found.`));
|
|
1490
1834
|
return;
|
|
1491
1835
|
}
|
|
1492
1836
|
if (items.length === 0) break;
|
|
1493
1837
|
if (pageCount > 1) {
|
|
1494
1838
|
console.clear();
|
|
1495
|
-
console.log(
|
|
1839
|
+
console.log(chalk.blue(`\u{1F4CB} ${getListTitle(functionInfo)}
|
|
1496
1840
|
`));
|
|
1497
1841
|
}
|
|
1498
1842
|
renderItemsForDisplay(items, functionInfo, totalShown);
|
|
1499
1843
|
totalShown += items.length;
|
|
1500
1844
|
console.log(
|
|
1501
|
-
|
|
1845
|
+
chalk.green(
|
|
1502
1846
|
`
|
|
1503
1847
|
\u2705 Showing ${totalShown} ${itemName} (page ${pageCount})`
|
|
1504
1848
|
)
|
|
@@ -1517,7 +1861,7 @@ function createInteractiveRenderer() {
|
|
|
1517
1861
|
break;
|
|
1518
1862
|
}
|
|
1519
1863
|
}
|
|
1520
|
-
console.log(
|
|
1864
|
+
console.log(chalk.gray(`
|
|
1521
1865
|
\u{1F4C4} Finished browsing ${itemName}`));
|
|
1522
1866
|
},
|
|
1523
1867
|
renderCollectedList(items, { maxItems, userSpecifiedMaxItems, functionInfo } = {}) {
|
|
@@ -1527,30 +1871,30 @@ function createInteractiveRenderer() {
|
|
|
1527
1871
|
}
|
|
1528
1872
|
const itemName = getItemName(functionInfo);
|
|
1529
1873
|
if (items.length === 0) {
|
|
1530
|
-
console.log(
|
|
1874
|
+
console.log(chalk.yellow(`No ${itemName} found.`));
|
|
1531
1875
|
return;
|
|
1532
1876
|
}
|
|
1533
|
-
console.log(
|
|
1877
|
+
console.log(chalk.green(`
|
|
1534
1878
|
\u2705 Found ${items.length} ${itemName}:
|
|
1535
1879
|
`));
|
|
1536
1880
|
renderItemsForDisplay(items, functionInfo);
|
|
1537
1881
|
if (userSpecifiedMaxItems && maxItems) {
|
|
1538
1882
|
console.log(
|
|
1539
|
-
|
|
1883
|
+
chalk.gray(
|
|
1540
1884
|
`
|
|
1541
1885
|
\u{1F4C4} Showing up to ${maxItems} ${itemName} (--max-items ${maxItems})`
|
|
1542
1886
|
)
|
|
1543
1887
|
);
|
|
1544
1888
|
} else {
|
|
1545
|
-
console.log(
|
|
1889
|
+
console.log(chalk.gray(`
|
|
1546
1890
|
\u{1F4C4} All available ${itemName} shown`));
|
|
1547
1891
|
}
|
|
1548
1892
|
},
|
|
1549
1893
|
renderItem(value, options) {
|
|
1550
1894
|
if (options?.outputFile) {
|
|
1551
1895
|
const label = options.commandName ? `\u2705 ${options.commandName} completed successfully!` : "\u2705 Done!";
|
|
1552
|
-
console.log(
|
|
1553
|
-
console.log(
|
|
1896
|
+
console.log(chalk.green(label));
|
|
1897
|
+
console.log(chalk.gray(`Output written to: ${options.outputFile}`));
|
|
1554
1898
|
} else {
|
|
1555
1899
|
formatJsonOutput(value);
|
|
1556
1900
|
}
|
|
@@ -1560,17 +1904,17 @@ function createInteractiveRenderer() {
|
|
|
1560
1904
|
},
|
|
1561
1905
|
renderError(error) {
|
|
1562
1906
|
if (error instanceof ZapierCliMissingParametersError) {
|
|
1563
|
-
console.error(
|
|
1564
|
-
console.error("\n" +
|
|
1907
|
+
console.error(chalk.red("\u274C " + formatMissingParamsError(error)));
|
|
1908
|
+
console.error("\n" + chalk.dim("Use --help to see available options"));
|
|
1565
1909
|
throw new ZapierCliExitError(error.message, 1);
|
|
1566
1910
|
}
|
|
1567
1911
|
if (error instanceof ZapierError) {
|
|
1568
1912
|
const formattedMessage = formatErrorMessage(error);
|
|
1569
|
-
console.error(
|
|
1913
|
+
console.error(chalk.red("\u274C Error:"), formattedMessage);
|
|
1570
1914
|
throw new ZapierCliExitError(formattedMessage, 1);
|
|
1571
1915
|
}
|
|
1572
1916
|
const msg = error instanceof Error ? error.message : "Unknown error";
|
|
1573
|
-
console.error(
|
|
1917
|
+
console.error(chalk.red("\u274C Error:"), msg);
|
|
1574
1918
|
throw new ZapierCliExitError(msg, 1);
|
|
1575
1919
|
}
|
|
1576
1920
|
};
|
|
@@ -1680,7 +2024,7 @@ async function promptConfirm(confirmType, itemType) {
|
|
|
1680
2024
|
}
|
|
1681
2025
|
const configOrFn = CONFIRM_MESSAGES[confirmType];
|
|
1682
2026
|
const { messageBefore, messageAfter } = typeof configOrFn === "function" ? configOrFn(itemType) : configOrFn;
|
|
1683
|
-
console.log(
|
|
2027
|
+
console.log(chalk.yellow(`
|
|
1684
2028
|
${messageBefore}
|
|
1685
2029
|
`));
|
|
1686
2030
|
const { confirmed } = await inquirer.prompt([
|
|
@@ -1702,9 +2046,9 @@ function emitDeprecationWarning({
|
|
|
1702
2046
|
}
|
|
1703
2047
|
console.warn();
|
|
1704
2048
|
console.warn(
|
|
1705
|
-
|
|
2049
|
+
chalk.yellow.bold("\u26A0\uFE0F DEPRECATION WARNING") + chalk.yellow(` - \`${cliCommandName}\` is deprecated.`)
|
|
1706
2050
|
);
|
|
1707
|
-
console.warn(
|
|
2051
|
+
console.warn(chalk.yellow(` ${deprecation.message}`));
|
|
1708
2052
|
console.warn();
|
|
1709
2053
|
}
|
|
1710
2054
|
function emitParamDeprecationWarnings({
|
|
@@ -1718,12 +2062,12 @@ function emitParamDeprecationWarnings({
|
|
|
1718
2062
|
if (Array.isArray(value) && value.length === 0) continue;
|
|
1719
2063
|
console.warn();
|
|
1720
2064
|
console.warn(
|
|
1721
|
-
|
|
2065
|
+
chalk.yellow.bold("\u26A0\uFE0F DEPRECATION WARNING") + chalk.yellow(
|
|
1722
2066
|
` - \`${toKebabCase(param.name)}\` is deprecated and may be removed in a future release.`
|
|
1723
2067
|
)
|
|
1724
2068
|
);
|
|
1725
2069
|
if (param.deprecationMessage) {
|
|
1726
|
-
console.warn(
|
|
2070
|
+
console.warn(chalk.yellow(` ${param.deprecationMessage}`));
|
|
1727
2071
|
}
|
|
1728
2072
|
console.warn();
|
|
1729
2073
|
}
|
|
@@ -2054,7 +2398,7 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
|
|
|
2054
2398
|
functionInfo.itemType
|
|
2055
2399
|
);
|
|
2056
2400
|
if (!confirmResult.confirmed) {
|
|
2057
|
-
console.log(
|
|
2401
|
+
console.log(chalk.yellow("Operation cancelled."));
|
|
2058
2402
|
return;
|
|
2059
2403
|
}
|
|
2060
2404
|
confirmMessageAfter = confirmResult.messageAfter;
|
|
@@ -2116,7 +2460,7 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
|
|
|
2116
2460
|
renderer.renderItem(normalizedResult.value);
|
|
2117
2461
|
}
|
|
2118
2462
|
if (confirmMessageAfter) {
|
|
2119
|
-
console.log(
|
|
2463
|
+
console.log(chalk.yellow(`
|
|
2120
2464
|
${confirmMessageAfter}`));
|
|
2121
2465
|
}
|
|
2122
2466
|
break;
|
|
@@ -3159,20 +3503,20 @@ var spinPromise = async (promise, text) => {
|
|
|
3159
3503
|
};
|
|
3160
3504
|
var log = {
|
|
3161
3505
|
info: (message, ...args) => {
|
|
3162
|
-
console.log(
|
|
3506
|
+
console.log(chalk.blue("\u2139"), message, ...args);
|
|
3163
3507
|
},
|
|
3164
3508
|
error: (message, ...args) => {
|
|
3165
|
-
console.error(
|
|
3509
|
+
console.error(chalk.red("\u2716"), message, ...args);
|
|
3166
3510
|
},
|
|
3167
3511
|
success: (message, ...args) => {
|
|
3168
|
-
console.log(
|
|
3512
|
+
console.log(chalk.green("\u2713"), message, ...args);
|
|
3169
3513
|
},
|
|
3170
3514
|
warn: (message, ...args) => {
|
|
3171
|
-
console.log(
|
|
3515
|
+
console.log(chalk.yellow("\u26A0"), message, ...args);
|
|
3172
3516
|
},
|
|
3173
3517
|
debug: (message, ...args) => {
|
|
3174
3518
|
if (process.env.DEBUG === "true" || process.argv.includes("--debug")) {
|
|
3175
|
-
console.log(
|
|
3519
|
+
console.log(chalk.gray("\u{1F41B}"), message, ...args);
|
|
3176
3520
|
}
|
|
3177
3521
|
}
|
|
3178
3522
|
};
|
|
@@ -5382,7 +5726,7 @@ function buildTemplateVariables({
|
|
|
5382
5726
|
};
|
|
5383
5727
|
}
|
|
5384
5728
|
function cleanupProject({ projectDir }) {
|
|
5385
|
-
console.log("\n" +
|
|
5729
|
+
console.log("\n" + chalk.yellow("!") + " Cleaning up...");
|
|
5386
5730
|
rmSync(projectDir, { recursive: true, force: true });
|
|
5387
5731
|
}
|
|
5388
5732
|
async function withInterruptCleanup(cleanup, fn) {
|
|
@@ -5592,8 +5936,8 @@ function buildNextSteps({
|
|
|
5592
5936
|
}
|
|
5593
5937
|
function createConsoleDisplayHooks() {
|
|
5594
5938
|
return {
|
|
5595
|
-
onItemComplete: (message) => console.log(" " +
|
|
5596
|
-
onWarn: (message) => console.warn(
|
|
5939
|
+
onItemComplete: (message) => console.log(" " + chalk.green("\u2713") + " " + chalk.dim(message)),
|
|
5940
|
+
onWarn: (message) => console.warn(chalk.yellow("!") + " " + message),
|
|
5597
5941
|
onStepStart: ({
|
|
5598
5942
|
description,
|
|
5599
5943
|
stepNumber,
|
|
@@ -5602,31 +5946,31 @@ function createConsoleDisplayHooks() {
|
|
|
5602
5946
|
skipPrompts
|
|
5603
5947
|
}) => {
|
|
5604
5948
|
const progressMessage = `${description}...`;
|
|
5605
|
-
const stepCounter =
|
|
5949
|
+
const stepCounter = chalk.dim(`${stepNumber}/${totalSteps}`);
|
|
5606
5950
|
if (skipPrompts) {
|
|
5607
5951
|
console.log(
|
|
5608
|
-
"\n" +
|
|
5952
|
+
"\n" + chalk.bold(`\u276F ${progressMessage}`) + " " + stepCounter + "\n"
|
|
5609
5953
|
);
|
|
5610
5954
|
} else {
|
|
5611
5955
|
console.log(
|
|
5612
|
-
|
|
5956
|
+
chalk.dim("\u2192") + " " + progressMessage + " " + stepCounter
|
|
5613
5957
|
);
|
|
5614
5958
|
}
|
|
5615
5959
|
if (command) {
|
|
5616
|
-
console.log(" " +
|
|
5960
|
+
console.log(" " + chalk.cyan(`$ ${command}`));
|
|
5617
5961
|
}
|
|
5618
5962
|
},
|
|
5619
5963
|
onStepSuccess: ({ stepNumber, totalSteps }) => console.log(
|
|
5620
|
-
"\n" +
|
|
5964
|
+
"\n" + chalk.green("\u2713") + " " + chalk.dim(`Step ${stepNumber}/${totalSteps} complete`) + "\n"
|
|
5621
5965
|
),
|
|
5622
5966
|
onStepError: ({ description, command, err }) => {
|
|
5623
5967
|
const detail = err instanceof Error && err.message ? `
|
|
5624
|
-
${
|
|
5968
|
+
${chalk.dim(err.message)}` : "";
|
|
5625
5969
|
const hint = command ? `
|
|
5626
|
-
${
|
|
5970
|
+
${chalk.dim("run manually:")} ${chalk.cyan(`$ ${command}`)}` : "";
|
|
5627
5971
|
console.error(
|
|
5628
5972
|
`
|
|
5629
|
-
${
|
|
5973
|
+
${chalk.red("\u2716")} ${chalk.bold(description)}${chalk.dim(" failed")}${detail}${hint}`
|
|
5630
5974
|
);
|
|
5631
5975
|
}
|
|
5632
5976
|
};
|
|
@@ -5638,22 +5982,22 @@ function displaySummaryAndNextSteps({
|
|
|
5638
5982
|
packageManager
|
|
5639
5983
|
}) {
|
|
5640
5984
|
const formatStatus = (complete) => ({
|
|
5641
|
-
icon: complete ?
|
|
5642
|
-
text: complete ?
|
|
5985
|
+
icon: complete ? chalk.green("\u2713") : chalk.yellow("!"),
|
|
5986
|
+
text: complete ? chalk.green("Setup complete") : chalk.yellow("Setup interrupted")
|
|
5643
5987
|
});
|
|
5644
|
-
const formatNextStep = (step, i) => " " +
|
|
5645
|
-
const formatCommand = (cmd) => " " +
|
|
5646
|
-
const formatCompletedStep = (step) => " " +
|
|
5988
|
+
const formatNextStep = (step, i) => " " + chalk.dim(`${i + 1}.`) + " " + chalk.bold(step.description);
|
|
5989
|
+
const formatCommand = (cmd) => " " + chalk.cyan(`$ ${cmd}`);
|
|
5990
|
+
const formatCompletedStep = (step) => " " + chalk.green("\u2713") + " " + step.description;
|
|
5647
5991
|
const { execCmd } = getPackageManagerCommands({ packageManager });
|
|
5648
5992
|
const leftoverSteps = steps.filter(
|
|
5649
5993
|
(s) => !completedSetupStepIds.includes(s.id)
|
|
5650
5994
|
);
|
|
5651
5995
|
const isComplete = leftoverSteps.length === 0;
|
|
5652
5996
|
const status = formatStatus(isComplete);
|
|
5653
|
-
console.log("\n" +
|
|
5654
|
-
console.log(" " +
|
|
5997
|
+
console.log("\n" + chalk.bold("\u276F Summary") + "\n");
|
|
5998
|
+
console.log(" " + chalk.dim("Project") + " " + chalk.bold(projectName));
|
|
5655
5999
|
console.log(
|
|
5656
|
-
" " +
|
|
6000
|
+
" " + chalk.dim("Status") + " " + status.icon + " " + status.text
|
|
5657
6001
|
);
|
|
5658
6002
|
const completedSteps = steps.filter(
|
|
5659
6003
|
(s) => completedSetupStepIds.includes(s.id)
|
|
@@ -5663,7 +6007,7 @@ function displaySummaryAndNextSteps({
|
|
|
5663
6007
|
for (const step of completedSteps) console.log(formatCompletedStep(step));
|
|
5664
6008
|
}
|
|
5665
6009
|
const nextSteps = buildNextSteps({ projectName, leftoverSteps, execCmd });
|
|
5666
|
-
console.log("\n" +
|
|
6010
|
+
console.log("\n" + chalk.bold("\u276F Next Steps") + "\n");
|
|
5667
6011
|
nextSteps.forEach((step, i) => {
|
|
5668
6012
|
console.log(formatNextStep(step, i));
|
|
5669
6013
|
if (step.command) console.log(formatCommand(step.command));
|
|
@@ -5739,13 +6083,13 @@ function createInteractiveCallback() {
|
|
|
5739
6083
|
const attrs = message.message_attributes;
|
|
5740
6084
|
console.log(
|
|
5741
6085
|
`
|
|
5742
|
-
${
|
|
6086
|
+
${chalk.bold(`Message #${messageNumber}`)} ${chalk.dim(message.id)} ${chalk.dim(`(lease #${attrs.lease_count})`)}`
|
|
5743
6087
|
);
|
|
5744
6088
|
if (attrs.error_message) {
|
|
5745
|
-
console.log(
|
|
6089
|
+
console.log(chalk.yellow(` upstream error: ${attrs.error_message}`));
|
|
5746
6090
|
}
|
|
5747
6091
|
if (attrs.possible_duplicate_data) {
|
|
5748
|
-
console.log(
|
|
6092
|
+
console.log(chalk.yellow(" possible duplicate data"));
|
|
5749
6093
|
}
|
|
5750
6094
|
while (true) {
|
|
5751
6095
|
let action;
|
|
@@ -5775,7 +6119,7 @@ ${chalk7.bold(`Message #${messageNumber}`)} ${chalk7.dim(message.id)} ${chalk7.d
|
|
|
5775
6119
|
throw error;
|
|
5776
6120
|
}
|
|
5777
6121
|
if (action === "view") {
|
|
5778
|
-
console.log(
|
|
6122
|
+
console.log(chalk.dim(JSON.stringify(message.payload, null, 2)));
|
|
5779
6123
|
continue;
|
|
5780
6124
|
}
|
|
5781
6125
|
if (action === "ack") {
|
|
@@ -5878,7 +6222,7 @@ function describeReason(reason) {
|
|
|
5878
6222
|
}
|
|
5879
6223
|
function printDrainError(reason, message) {
|
|
5880
6224
|
console.error(
|
|
5881
|
-
|
|
6225
|
+
chalk.red(`Error processing ${message.id}: ${describeReason(reason)}`)
|
|
5882
6226
|
);
|
|
5883
6227
|
}
|
|
5884
6228
|
function printDrainSummary(counts) {
|
|
@@ -5888,7 +6232,7 @@ function printDrainSummary(counts) {
|
|
|
5888
6232
|
if (skipped > 0) parts.push(`${skipped} skipped`);
|
|
5889
6233
|
parts.push(`${counts.rejected} rejected`);
|
|
5890
6234
|
console.log(
|
|
5891
|
-
|
|
6235
|
+
chalk.dim(
|
|
5892
6236
|
`
|
|
5893
6237
|
Processed ${total} message${total === 1 ? "" : "s"} (${parts.join(", ")}).`
|
|
5894
6238
|
)
|
|
@@ -5896,7 +6240,7 @@ Processed ${total} message${total === 1 ? "" : "s"} (${parts.join(", ")}).`
|
|
|
5896
6240
|
}
|
|
5897
6241
|
function warnInteractiveContinueOnErrorOverride() {
|
|
5898
6242
|
console.warn(
|
|
5899
|
-
|
|
6243
|
+
chalk.yellow(
|
|
5900
6244
|
'Note: continueOnError=false is overridden to true in interactive mode (the "Skip (let lease expire)" choice would otherwise terminate the drain).'
|
|
5901
6245
|
)
|
|
5902
6246
|
);
|
|
@@ -6200,7 +6544,7 @@ var watchTriggerInboxCliPlugin = definePlugin(
|
|
|
6200
6544
|
// package.json with { type: 'json' }
|
|
6201
6545
|
var package_default2 = {
|
|
6202
6546
|
name: "@zapier/zapier-sdk-cli",
|
|
6203
|
-
version: "0.
|
|
6547
|
+
version: "0.49.1"};
|
|
6204
6548
|
|
|
6205
6549
|
// src/sdk.ts
|
|
6206
6550
|
injectCliLogin(login_exports);
|
|
@@ -6407,26 +6751,26 @@ function displayUpdateNotification(versionInfo, packageName) {
|
|
|
6407
6751
|
if (versionInfo.isDeprecated) {
|
|
6408
6752
|
console.error();
|
|
6409
6753
|
console.error(
|
|
6410
|
-
|
|
6754
|
+
chalk.red.bold("\u26A0\uFE0F DEPRECATION WARNING") + chalk.red(
|
|
6411
6755
|
` - ${packageName} v${versionInfo.currentVersion} is deprecated.`
|
|
6412
6756
|
)
|
|
6413
6757
|
);
|
|
6414
6758
|
if (versionInfo.deprecationMessage) {
|
|
6415
|
-
console.error(
|
|
6759
|
+
console.error(chalk.red(` ${versionInfo.deprecationMessage}`));
|
|
6416
6760
|
}
|
|
6417
|
-
console.error(
|
|
6761
|
+
console.error(chalk.red(` Please update to the latest version.`));
|
|
6418
6762
|
console.error();
|
|
6419
6763
|
}
|
|
6420
6764
|
if (versionInfo.hasUpdate) {
|
|
6421
6765
|
console.error();
|
|
6422
6766
|
console.error(
|
|
6423
|
-
|
|
6767
|
+
chalk.yellow.bold("\u{1F4E6} Update available!") + chalk.yellow(
|
|
6424
6768
|
` ${packageName} v${versionInfo.currentVersion} \u2192 v${versionInfo.latestVersion}`
|
|
6425
6769
|
)
|
|
6426
6770
|
);
|
|
6427
6771
|
console.error(
|
|
6428
|
-
|
|
6429
|
-
` Run ${
|
|
6772
|
+
chalk.yellow(
|
|
6773
|
+
` Run ${chalk.bold(getUpdateCommand(packageName))} to update.`
|
|
6430
6774
|
)
|
|
6431
6775
|
);
|
|
6432
6776
|
console.error();
|