@optique/core 1.3.0-dev.2581 → 1.3.0-dev.2583
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/dist/constructs.cjs +114 -9
- package/dist/constructs.js +115 -10
- package/dist/dependency-metadata.d.cts +15 -0
- package/dist/dependency-metadata.d.ts +15 -0
- package/dist/dependency-runtime.cjs +21 -0
- package/dist/dependency-runtime.d.cts +48 -3
- package/dist/dependency-runtime.d.ts +48 -3
- package/dist/dependency-runtime.js +20 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/valueparser.cjs +173 -0
- package/dist/valueparser.d.cts +86 -1
- package/dist/valueparser.d.ts +86 -1
- package/dist/valueparser.js +173 -1
- package/package.json +2 -2
- package/skills/optique/SKILL.md +5 -5
|
@@ -3,7 +3,7 @@ import { DependencyRegistryLike } from "./registry-types.js";
|
|
|
3
3
|
import { ValueParserResult } from "./valueparser.js";
|
|
4
4
|
import { ParserDependencyMetadata } from "./dependency-metadata.js";
|
|
5
5
|
import { InputTrace } from "./input-trace.js";
|
|
6
|
-
import { EffectfulCompletionSession, ExecutionContext } from "./internal/parser.js";
|
|
6
|
+
import { EffectfulCompletionSession, ExecutionContext, unmatchedNonCliDependencySourceStateMarker } from "./internal/parser.js";
|
|
7
7
|
|
|
8
8
|
//#region src/dependency-runtime.d.ts
|
|
9
9
|
|
|
@@ -612,13 +612,29 @@ declare function extractRawInputFromState(state: unknown): string | undefined;
|
|
|
612
612
|
* @since 1.3.0
|
|
613
613
|
*/
|
|
614
614
|
declare const effectfulSchedulingNodesKey: unique symbol;
|
|
615
|
+
/**
|
|
616
|
+
* Options that steer how far a runtime-node expansion walks.
|
|
617
|
+
*
|
|
618
|
+
* @internal
|
|
619
|
+
* @since 1.3.0
|
|
620
|
+
*/
|
|
621
|
+
interface ExpandRuntimeNodesOptions {
|
|
622
|
+
/**
|
|
623
|
+
* Stops the walk at an exclusive parser—an `or()`, `longestMatch()`, or
|
|
624
|
+
* `conditional()` alternative—that has not opted into source
|
|
625
|
+
* collection, so a scope of its own is not folded into the enclosing
|
|
626
|
+
* one. A hook that expands descendants itself must forward this to
|
|
627
|
+
* its own expansion.
|
|
628
|
+
*/
|
|
629
|
+
readonly structuralOnly?: boolean;
|
|
630
|
+
}
|
|
615
631
|
/**
|
|
616
632
|
* The shape of the {@link effectfulSchedulingNodesKey} hook.
|
|
617
633
|
*
|
|
618
634
|
* @internal
|
|
619
635
|
* @since 1.3.0
|
|
620
636
|
*/
|
|
621
|
-
type EffectfulSchedulingNodesFn = (state: unknown, parentPath: readonly PropertyKey[] | undefined) => readonly RuntimeNode[];
|
|
637
|
+
type EffectfulSchedulingNodesFn = (state: unknown, parentPath: readonly PropertyKey[] | undefined, options?: ExpandRuntimeNodesOptions) => readonly RuntimeNode[];
|
|
622
638
|
/**
|
|
623
639
|
* Opt-in marker for parsers whose {@link effectfulSchedulingNodesKey}
|
|
624
640
|
* hook also defines their explicit-source *collection* scope.
|
|
@@ -929,6 +945,22 @@ declare function resolveStateWithRuntime(state: unknown, runtime: DependencyRunt
|
|
|
929
945
|
* @since 1.0.0
|
|
930
946
|
*/
|
|
931
947
|
declare function resolveStateWithRuntimeAsync(state: unknown, runtime: DependencyRuntimeContext): Promise<unknown>;
|
|
948
|
+
/**
|
|
949
|
+
* Determines whether a parser state represents an explicit match (the user
|
|
950
|
+
* provided input) rather than an initial/pending state.
|
|
951
|
+
*
|
|
952
|
+
* @param fieldState The parser's state.
|
|
953
|
+
* @param parser The parser owning that state.
|
|
954
|
+
* @returns `true` when the state reflects command-line input, whether or
|
|
955
|
+
* not that input passed validation.
|
|
956
|
+
* @internal
|
|
957
|
+
* @since 1.3.0
|
|
958
|
+
*/
|
|
959
|
+
declare function isMatchedState(fieldState: unknown, parser: {
|
|
960
|
+
readonly dependencyMetadata?: ParserDependencyMetadata;
|
|
961
|
+
readonly initialState?: unknown;
|
|
962
|
+
readonly [unmatchedNonCliDependencySourceStateMarker]?: true;
|
|
963
|
+
}): boolean;
|
|
932
964
|
/**
|
|
933
965
|
* Builds {@link RuntimeNode}s from field→parser pairs and a state record.
|
|
934
966
|
*
|
|
@@ -961,5 +993,18 @@ declare function buildRuntimeNodesFromArray(parsers: ReadonlyArray<{
|
|
|
961
993
|
readonly dependencyMetadata?: ParserDependencyMetadata;
|
|
962
994
|
readonly initialState?: unknown;
|
|
963
995
|
}>, stateArray: readonly unknown[], parentPath?: readonly PropertyKey[]): readonly RuntimeNode[];
|
|
996
|
+
/**
|
|
997
|
+
* Reads a derived parser state's snapshotted default dependency values.
|
|
998
|
+
*
|
|
999
|
+
* Nodes must carry the parse-time snapshot so replay never re-evaluates a
|
|
1000
|
+
* dynamic `getDefaultDependencyValues()` thunk.
|
|
1001
|
+
*
|
|
1002
|
+
* @param state The derived parser's state.
|
|
1003
|
+
* @returns The snapshotted values, or `undefined` when the state carries
|
|
1004
|
+
* none.
|
|
1005
|
+
* @internal
|
|
1006
|
+
* @since 1.3.0
|
|
1007
|
+
*/
|
|
1008
|
+
declare function getDefaultDependencySnapshot(state: unknown): readonly unknown[] | undefined;
|
|
964
1009
|
//#endregion
|
|
965
|
-
export { BarrierCompletionDemandEdge, BarrierCompletionDependencies, BarrierResolution, CompleteEffectfulSourcesOptions, DependencyRequest, DependencyResolution, DependencyRuntimeContext, EffectfulSchedulingNodesFn, EffectfulSourceCompletion, EffectfulSourceCompletionResult, ReplayKey, ResolveDerivedSourceValuesOptions, RuntimeNode, SchedulingBarrierContext, SourceDefaultFailure, buildRuntimeNodesFromArray, buildRuntimeNodesFromPairs, collectDemandedDependencyIds, collectExplicitSourceValues, collectExplicitSourceValuesAsync, collectSourcesFromState, completeEffectfulSourcesAsync, createDependencyFingerprint, createDependencyRuntimeContext, createReplayKey, defineForwardedEffectfulSchedulingNodes, derivedRawInputKey, effectfulSchedulingNodesKey, exclusiveSourceScopeKey, extractRawInputFromState, fillMissingSourceDefaults, fillMissingSourceDefaultsAsync, forkRuntimeForCommittedSubtree, guaranteedStaticSourceIdsKey, hasInactiveCompletion, includeSourceFailureChain, orderDependencyNodes, recordDerivedRawInput, recordSourceScope, releaseUncollectedSourceValues, replaceCachedBarrierFailure, replayDerivedParser, replayDerivedParserAsync, resolveDerivedSourceValues, resolveDerivedSourceValuesAsync, resolveStateWithRuntime, resolveStateWithRuntimeAsync, serializeSchedulingPath, sourceCollectionExpansionKey, staticSourceScopeKey };
|
|
1010
|
+
export { BarrierCompletionDemandEdge, BarrierCompletionDependencies, BarrierResolution, CompleteEffectfulSourcesOptions, DependencyRequest, DependencyResolution, DependencyRuntimeContext, EffectfulSchedulingNodesFn, EffectfulSourceCompletion, EffectfulSourceCompletionResult, ExpandRuntimeNodesOptions, ReplayKey, ResolveDerivedSourceValuesOptions, RuntimeNode, SchedulingBarrierContext, SourceDefaultFailure, buildRuntimeNodesFromArray, buildRuntimeNodesFromPairs, collectDemandedDependencyIds, collectExplicitSourceValues, collectExplicitSourceValuesAsync, collectSourcesFromState, completeEffectfulSourcesAsync, createDependencyFingerprint, createDependencyRuntimeContext, createReplayKey, defineForwardedEffectfulSchedulingNodes, derivedRawInputKey, effectfulSchedulingNodesKey, exclusiveSourceScopeKey, extractRawInputFromState, fillMissingSourceDefaults, fillMissingSourceDefaultsAsync, forkRuntimeForCommittedSubtree, getDefaultDependencySnapshot, guaranteedStaticSourceIdsKey, hasInactiveCompletion, includeSourceFailureChain, isMatchedState, orderDependencyNodes, recordDerivedRawInput, recordSourceScope, releaseUncollectedSourceValues, replaceCachedBarrierFailure, replayDerivedParser, replayDerivedParserAsync, resolveDerivedSourceValues, resolveDerivedSourceValuesAsync, resolveStateWithRuntime, resolveStateWithRuntimeAsync, serializeSchedulingPath, sourceCollectionExpansionKey, staticSourceScopeKey };
|
|
@@ -1850,6 +1850,13 @@ async function resolveDeferredInStateAsync(state, runtime, visited = /* @__PURE_
|
|
|
1850
1850
|
/**
|
|
1851
1851
|
* Determines whether a parser state represents an explicit match (the user
|
|
1852
1852
|
* provided input) rather than an initial/pending state.
|
|
1853
|
+
*
|
|
1854
|
+
* @param fieldState The parser's state.
|
|
1855
|
+
* @param parser The parser owning that state.
|
|
1856
|
+
* @returns `true` when the state reflects command-line input, whether or
|
|
1857
|
+
* not that input passed validation.
|
|
1858
|
+
* @internal
|
|
1859
|
+
* @since 1.3.0
|
|
1853
1860
|
*/
|
|
1854
1861
|
function isMatchedState(fieldState, parser) {
|
|
1855
1862
|
if (fieldState === void 0) return false;
|
|
@@ -1922,6 +1929,18 @@ function buildRuntimeNodesFromArray(parsers, stateArray, parentPath) {
|
|
|
1922
1929
|
}
|
|
1923
1930
|
return nodes;
|
|
1924
1931
|
}
|
|
1932
|
+
/**
|
|
1933
|
+
* Reads a derived parser state's snapshotted default dependency values.
|
|
1934
|
+
*
|
|
1935
|
+
* Nodes must carry the parse-time snapshot so replay never re-evaluates a
|
|
1936
|
+
* dynamic `getDefaultDependencyValues()` thunk.
|
|
1937
|
+
*
|
|
1938
|
+
* @param state The derived parser's state.
|
|
1939
|
+
* @returns The snapshotted values, or `undefined` when the state carries
|
|
1940
|
+
* none.
|
|
1941
|
+
* @internal
|
|
1942
|
+
* @since 1.3.0
|
|
1943
|
+
*/
|
|
1925
1944
|
function getDefaultDependencySnapshot(state) {
|
|
1926
1945
|
return getDefaultDependencySnapshotInner(state, /* @__PURE__ */ new Set());
|
|
1927
1946
|
}
|
|
@@ -1947,4 +1966,4 @@ function getDefaultDependencySnapshotInner(state, visited) {
|
|
|
1947
1966
|
}
|
|
1948
1967
|
|
|
1949
1968
|
//#endregion
|
|
1950
|
-
export { buildRuntimeNodesFromArray, buildRuntimeNodesFromPairs, collectDemandedDependencyIds, collectExplicitSourceValues, collectExplicitSourceValuesAsync, collectSourcesFromState, completeEffectfulSourcesAsync, createDependencyFingerprint, createDependencyRuntimeContext, createReplayKey, defineForwardedEffectfulSchedulingNodes, derivedRawInputKey, effectfulSchedulingNodesKey, exclusiveSourceScopeKey, extractRawInputFromState, fillMissingSourceDefaults, fillMissingSourceDefaultsAsync, forkRuntimeForCommittedSubtree, guaranteedStaticSourceIdsKey, hasInactiveCompletion, includeSourceFailureChain, orderDependencyNodes, recordDerivedRawInput, recordSourceScope, releaseUncollectedSourceValues, replaceCachedBarrierFailure, replayDerivedParser, replayDerivedParserAsync, resolveDerivedSourceValues, resolveDerivedSourceValuesAsync, resolveStateWithRuntime, resolveStateWithRuntimeAsync, serializeSchedulingPath, sourceCollectionExpansionKey, staticSourceScopeKey };
|
|
1969
|
+
export { buildRuntimeNodesFromArray, buildRuntimeNodesFromPairs, collectDemandedDependencyIds, collectExplicitSourceValues, collectExplicitSourceValuesAsync, collectSourcesFromState, completeEffectfulSourcesAsync, createDependencyFingerprint, createDependencyRuntimeContext, createReplayKey, defineForwardedEffectfulSchedulingNodes, derivedRawInputKey, effectfulSchedulingNodesKey, exclusiveSourceScopeKey, extractRawInputFromState, fillMissingSourceDefaults, fillMissingSourceDefaultsAsync, forkRuntimeForCommittedSubtree, getDefaultDependencySnapshot, guaranteedStaticSourceIdsKey, hasInactiveCompletion, includeSourceFailureChain, isMatchedState, orderDependencyNodes, recordDerivedRawInput, recordSourceScope, releaseUncollectedSourceValues, replaceCachedBarrierFailure, replayDerivedParser, replayDerivedParserAsync, resolveDerivedSourceValues, resolveDerivedSourceValuesAsync, resolveStateWithRuntime, resolveStateWithRuntimeAsync, serializeSchedulingPath, sourceCollectionExpansionKey, staticSourceScopeKey };
|
package/dist/index.cjs
CHANGED
|
@@ -105,6 +105,7 @@ exports.optionName = require_message.optionName;
|
|
|
105
105
|
exports.optionNames = require_message.optionNames;
|
|
106
106
|
exports.optional = require_modifiers.optional;
|
|
107
107
|
exports.or = require_constructs.or;
|
|
108
|
+
exports.origin = require_valueparser.origin;
|
|
108
109
|
exports.parse = require_internal_parser.parse;
|
|
109
110
|
exports.parseAsync = require_internal_parser.parseAsync;
|
|
110
111
|
exports.parseDetailed = require_internal_parser.parseDetailed;
|
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ import { Message, MessageFormatOptions, MessageFormatter, MessageFormatterOption
|
|
|
4
4
|
import { ErrorLabelTerm, LabelTerm, ProgramNameTerm, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, defaultTerminalTheme } from "./terminal.cjs";
|
|
5
5
|
import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.cjs";
|
|
6
6
|
import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden } from "./doc.cjs";
|
|
7
|
-
import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.cjs";
|
|
7
|
+
import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, OriginOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, origin, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.cjs";
|
|
8
8
|
import { CombineModes, DetailedParseResult, DocState, EffectfulCompletionSession, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, createParserContext, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseDetailed, parseSync, suggest, suggestAsync, suggestSync } from "./internal/parser.cjs";
|
|
9
9
|
import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.cjs";
|
|
10
10
|
import { DeferredValue, DeferredValueOptions, DeferredValueSource, FluentParser, MultipleErrorOptions, MultipleOptions, ParserModifiers, WithDefaultError, WithDefaultOptions, deferredValue, fluent, isDeferredValue, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.cjs";
|
|
@@ -13,4 +13,4 @@ import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./c
|
|
|
13
13
|
import { AnyDependencySource, CombineMode, CombinedDependencyMode, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, dependency, deriveFrom, deriveFromAsync, deriveFromSync, getDependencySourceInfo, isDependencySource, isDerivedValueParser } from "./internal/dependency.cjs";
|
|
14
14
|
import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.cjs";
|
|
15
15
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.cjs";
|
|
16
|
-
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
|
16
|
+
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, OriginOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Message, MessageFormatOptions, MessageFormatter, MessageFormatterOption
|
|
|
4
4
|
import { ErrorLabelTerm, LabelTerm, ProgramNameTerm, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, defaultTerminalTheme } from "./terminal.js";
|
|
5
5
|
import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.js";
|
|
6
6
|
import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden } from "./doc.js";
|
|
7
|
-
import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.js";
|
|
7
|
+
import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, OriginOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, origin, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.js";
|
|
8
8
|
import { CombineModes, DetailedParseResult, DocState, EffectfulCompletionSession, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, createParserContext, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseDetailed, parseSync, suggest, suggestAsync, suggestSync } from "./internal/parser.js";
|
|
9
9
|
import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.js";
|
|
10
10
|
import { DeferredValue, DeferredValueOptions, DeferredValueSource, FluentParser, MultipleErrorOptions, MultipleOptions, ParserModifiers, WithDefaultError, WithDefaultOptions, deferredValue, fluent, isDeferredValue, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
|
|
@@ -13,4 +13,4 @@ import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./c
|
|
|
13
13
|
import { AnyDependencySource, CombineMode, CombinedDependencyMode, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, dependency, deriveFrom, deriveFromAsync, deriveFromSync, getDependencySourceInfo, isDependencySource, isDerivedValueParser } from "./internal/dependency.js";
|
|
14
14
|
import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
|
|
15
15
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.js";
|
|
16
|
-
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
|
16
|
+
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, OriginOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
package/dist/index.js
CHANGED
|
@@ -9,8 +9,8 @@ import { bash, fish, nu, pwsh, zsh } from "./completion.js";
|
|
|
9
9
|
import { WithDefaultError, deferredValue, fluent, isDeferredValue, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
|
|
10
10
|
import { DuplicateOptionError, concat, conditional, group, longestMatch, merge, object, or, seq, tuple } from "./constructs.js";
|
|
11
11
|
import { ensureNonEmptyString, isNonEmptyString } from "./nonempty.js";
|
|
12
|
-
import { biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.js";
|
|
12
|
+
import { biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, origin, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.js";
|
|
13
13
|
import { argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.js";
|
|
14
14
|
import { RunParserError, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
|
|
15
15
|
|
|
16
|
-
export { DuplicateOptionError, RunParserError, WithDefaultError, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
|
16
|
+
export { DuplicateOptionError, RunParserError, WithDefaultError, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
package/dist/valueparser.cjs
CHANGED
|
@@ -2750,6 +2750,178 @@ function url(options = {}) {
|
|
|
2750
2750
|
};
|
|
2751
2751
|
}
|
|
2752
2752
|
/**
|
|
2753
|
+
* A host name that the WHATWG URL parser has canonicalized into a dotted-quad
|
|
2754
|
+
* IPv4 address. Matching the canonical form is enough, because the parser
|
|
2755
|
+
* turns every other spelling (`0x7f.1`, `2130706433`, …) into it.
|
|
2756
|
+
*/
|
|
2757
|
+
const IPV4_PATTERN = /^\d{1,3}(?:\.\d{1,3}){3}$/u;
|
|
2758
|
+
/**
|
|
2759
|
+
* Creates a {@link ValueParser} for web origins.
|
|
2760
|
+
*
|
|
2761
|
+
* An origin is a scheme, a host, and an optional port, and nothing else. The
|
|
2762
|
+
* parser returns a `URL` whose pathname is `/` and which carries no
|
|
2763
|
+
* credentials, query, or fragment.
|
|
2764
|
+
*
|
|
2765
|
+
* Input is canonicalized rather than rejected when it carries more than an
|
|
2766
|
+
* origin: the host is lowercased, internationalized names are converted to
|
|
2767
|
+
* punycode, and a default port is elided, so `HTTPS://Example.COM/`,
|
|
2768
|
+
* `https://example.com:443/path?query#fragment` all parse to
|
|
2769
|
+
* `https://example.com`. Set `extraComponents: "reject"` to fail on a path,
|
|
2770
|
+
* query, or fragment instead. Credentials are always rejected. Schemes whose
|
|
2771
|
+
* origin is opaque (`mailto:`, `data:`, `file:`) are rejected, as is `blob:`,
|
|
2772
|
+
* whose origin belongs to the URL it wraps.
|
|
2773
|
+
*
|
|
2774
|
+
* By default a trailing root-zone dot is stripped, so `example.com.` becomes
|
|
2775
|
+
* `example.com`. This differs from the WHATWG origin, which keeps the dot, so
|
|
2776
|
+
* the two strings are not interchangeable when an exact origin comparison
|
|
2777
|
+
* matters. Use `trailingDot: "preserve"` for the WHATWG behavior or
|
|
2778
|
+
* `trailingDot: "append"` to force a fully-qualified name.
|
|
2779
|
+
*
|
|
2780
|
+
* @param options Configuration options for the origin parser.
|
|
2781
|
+
* @returns A {@link ValueParser} that converts string input to `URL` objects
|
|
2782
|
+
* that name an origin.
|
|
2783
|
+
* @throws {TypeError} If any `allowedProtocols` entry is not a valid protocol
|
|
2784
|
+
* string ending with a colon (e.g., `"https:"`).
|
|
2785
|
+
* @since 1.3.0
|
|
2786
|
+
*/
|
|
2787
|
+
function origin(options = {}) {
|
|
2788
|
+
const metavar$1 = options.metavar ?? "ORIGIN";
|
|
2789
|
+
require_nonempty.ensureNonEmptyString(metavar$1);
|
|
2790
|
+
checkEnumOption(options, "extraComponents", ["strip", "reject"]);
|
|
2791
|
+
checkEnumOption(options, "trailingDot", [
|
|
2792
|
+
"strip",
|
|
2793
|
+
"preserve",
|
|
2794
|
+
"append"
|
|
2795
|
+
]);
|
|
2796
|
+
const extraComponents = options.extraComponents ?? "strip";
|
|
2797
|
+
const trailingDot = options.trailingDot ?? "strip";
|
|
2798
|
+
const originalProtocolsList = [];
|
|
2799
|
+
const normalizedProtocolsList = [];
|
|
2800
|
+
if (options.allowedProtocols != null) {
|
|
2801
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2802
|
+
for (const protocol of options.allowedProtocols) {
|
|
2803
|
+
if (typeof protocol !== "string" || !/^[a-z][a-z0-9+\-.]*:$/i.test(protocol)) {
|
|
2804
|
+
const rendered = typeof protocol === "string" ? JSON.stringify(protocol) : String(protocol);
|
|
2805
|
+
throw new TypeError(`Each allowed protocol must be a valid protocol ending with a colon (e.g., "https:"), got: ${rendered}.`);
|
|
2806
|
+
}
|
|
2807
|
+
const normalized = protocol.toLowerCase();
|
|
2808
|
+
if (seen.has(normalized)) continue;
|
|
2809
|
+
seen.add(normalized);
|
|
2810
|
+
originalProtocolsList.push(protocol);
|
|
2811
|
+
normalizedProtocolsList.push(normalized);
|
|
2812
|
+
}
|
|
2813
|
+
if (originalProtocolsList.length === 0) throw new TypeError("allowedProtocols must not be empty.");
|
|
2814
|
+
}
|
|
2815
|
+
const originalProtocols = options.allowedProtocols != null ? Object.freeze(originalProtocolsList) : void 0;
|
|
2816
|
+
const allowedProtocols = options.allowedProtocols != null ? Object.freeze(normalizedProtocolsList) : void 0;
|
|
2817
|
+
const invalidOrigin = options.errors?.invalidOrigin;
|
|
2818
|
+
const disallowedProtocol = options.errors?.disallowedProtocol;
|
|
2819
|
+
function invalidOriginError(input) {
|
|
2820
|
+
return invalidOrigin ? typeof invalidOrigin === "function" ? invalidOrigin(input) : invalidOrigin : require_message.message`Invalid origin: ${input}.`;
|
|
2821
|
+
}
|
|
2822
|
+
function disallowedProtocolError(protocol) {
|
|
2823
|
+
return disallowedProtocol ? typeof disallowedProtocol === "function" ? disallowedProtocol(protocol, originalProtocols) : disallowedProtocol : [
|
|
2824
|
+
{
|
|
2825
|
+
type: "text",
|
|
2826
|
+
text: "URL protocol "
|
|
2827
|
+
},
|
|
2828
|
+
{
|
|
2829
|
+
type: "value",
|
|
2830
|
+
value: protocol
|
|
2831
|
+
},
|
|
2832
|
+
{
|
|
2833
|
+
type: "text",
|
|
2834
|
+
text: " is not allowed. Allowed protocols: "
|
|
2835
|
+
},
|
|
2836
|
+
...require_message.valueSet(originalProtocols, {
|
|
2837
|
+
fallback: "",
|
|
2838
|
+
locale: "en-US"
|
|
2839
|
+
}),
|
|
2840
|
+
{
|
|
2841
|
+
type: "text",
|
|
2842
|
+
text: "."
|
|
2843
|
+
}
|
|
2844
|
+
];
|
|
2845
|
+
}
|
|
2846
|
+
function withTrailingDot(url$1) {
|
|
2847
|
+
if (trailingDot === "preserve") return url$1;
|
|
2848
|
+
const { hostname: hostname$1 } = url$1;
|
|
2849
|
+
if (hostname$1.startsWith("[") || IPV4_PATTERN.test(hostname$1)) return url$1;
|
|
2850
|
+
if (trailingDot === "strip") {
|
|
2851
|
+
const stripped = hostname$1.replace(/\.+$/u, "");
|
|
2852
|
+
if (stripped !== "") url$1.hostname = stripped;
|
|
2853
|
+
} else if (!hostname$1.endsWith(".")) url$1.hostname = `${hostname$1}.`;
|
|
2854
|
+
return url$1;
|
|
2855
|
+
}
|
|
2856
|
+
function resolve(url$1, label) {
|
|
2857
|
+
if (allowedProtocols != null && !allowedProtocols.includes(url$1.protocol)) return {
|
|
2858
|
+
success: false,
|
|
2859
|
+
error: disallowedProtocolError(url$1.protocol)
|
|
2860
|
+
};
|
|
2861
|
+
if (url$1.protocol === "blob:") return {
|
|
2862
|
+
success: false,
|
|
2863
|
+
error: require_message.message`The URL ${label} wraps another origin. Pass that origin instead.`
|
|
2864
|
+
};
|
|
2865
|
+
if (url$1.origin === "null") return {
|
|
2866
|
+
success: false,
|
|
2867
|
+
error: require_message.message`The URL ${label} has no origin.`
|
|
2868
|
+
};
|
|
2869
|
+
if (url$1.username !== "" || url$1.password !== "") return {
|
|
2870
|
+
success: false,
|
|
2871
|
+
error: require_message.message`An origin must not contain credentials: ${url$1.origin}`
|
|
2872
|
+
};
|
|
2873
|
+
if (extraComponents === "reject" && (url$1.pathname !== "/" || url$1.search !== "" || url$1.hash !== "")) return {
|
|
2874
|
+
success: false,
|
|
2875
|
+
error: require_message.message`Expected only an origin, but got: ${label}`
|
|
2876
|
+
};
|
|
2877
|
+
return {
|
|
2878
|
+
success: true,
|
|
2879
|
+
value: withTrailingDot(new URL(url$1.origin))
|
|
2880
|
+
};
|
|
2881
|
+
}
|
|
2882
|
+
return {
|
|
2883
|
+
mode: "sync",
|
|
2884
|
+
metavar: metavar$1,
|
|
2885
|
+
get placeholder() {
|
|
2886
|
+
return new URL(`${allowedProtocols?.[0] ?? "http:"}//0.invalid`);
|
|
2887
|
+
},
|
|
2888
|
+
parse(input) {
|
|
2889
|
+
if (!URL.canParse(input)) return {
|
|
2890
|
+
success: false,
|
|
2891
|
+
error: invalidOriginError(input)
|
|
2892
|
+
};
|
|
2893
|
+
return resolve(new URL(input), input);
|
|
2894
|
+
},
|
|
2895
|
+
validate(value) {
|
|
2896
|
+
if (!(value instanceof URL)) return {
|
|
2897
|
+
success: false,
|
|
2898
|
+
error: invalidOriginError(String(value))
|
|
2899
|
+
};
|
|
2900
|
+
return resolve(value, value.href);
|
|
2901
|
+
},
|
|
2902
|
+
format(value) {
|
|
2903
|
+
return value.origin;
|
|
2904
|
+
},
|
|
2905
|
+
normalize(value) {
|
|
2906
|
+
if (!(value instanceof URL)) return value;
|
|
2907
|
+
const result = resolve(value, value.href);
|
|
2908
|
+
return result.success ? result.value : value;
|
|
2909
|
+
},
|
|
2910
|
+
*suggest(prefix) {
|
|
2911
|
+
if (allowedProtocols && prefix.length > 0 && !prefix.includes(":")) for (const protocol of allowedProtocols) {
|
|
2912
|
+
const cleanProtocol = protocol.replace(/:+$/, "");
|
|
2913
|
+
if (cleanProtocol.startsWith(prefix.toLowerCase())) {
|
|
2914
|
+
const suffix = SPECIAL_URL_SCHEMES.has(cleanProtocol) ? "://" : ":";
|
|
2915
|
+
yield {
|
|
2916
|
+
kind: "literal",
|
|
2917
|
+
text: `${cleanProtocol}${suffix}`
|
|
2918
|
+
};
|
|
2919
|
+
}
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2922
|
+
};
|
|
2923
|
+
}
|
|
2924
|
+
/**
|
|
2753
2925
|
* Creates a {@link ValueParser} for locale values.
|
|
2754
2926
|
*
|
|
2755
2927
|
* This parser validates that the input is a well-formed locale identifier
|
|
@@ -6691,6 +6863,7 @@ exports.json = json;
|
|
|
6691
6863
|
exports.keyValue = keyValue;
|
|
6692
6864
|
exports.locale = locale;
|
|
6693
6865
|
exports.macAddress = macAddress;
|
|
6866
|
+
exports.origin = origin;
|
|
6694
6867
|
exports.port = port;
|
|
6695
6868
|
exports.portRange = portRange;
|
|
6696
6869
|
exports.regExp = regExp;
|
package/dist/valueparser.d.cts
CHANGED
|
@@ -1189,6 +1189,91 @@ interface UrlOptions {
|
|
|
1189
1189
|
* string ending with a colon (e.g., `"https:"`).
|
|
1190
1190
|
*/
|
|
1191
1191
|
declare function url(options?: UrlOptions): ValueParser<"sync", URL>;
|
|
1192
|
+
/**
|
|
1193
|
+
* Options for creating an {@link origin} parser.
|
|
1194
|
+
*/
|
|
1195
|
+
interface OriginOptions {
|
|
1196
|
+
/**
|
|
1197
|
+
* The metavariable name for this parser. This is used in help messages to
|
|
1198
|
+
* indicate what kind of value this parser expects. Usually a single
|
|
1199
|
+
* word in uppercase, like `ORIGIN` or `BASE_URL`.
|
|
1200
|
+
* @default `"ORIGIN"`
|
|
1201
|
+
*/
|
|
1202
|
+
readonly metavar?: NonEmptyString;
|
|
1203
|
+
/**
|
|
1204
|
+
* List of allowed URL protocols (e.g., `["http:", "https:"]`).
|
|
1205
|
+
* If specified, the parsed URL must use one of these protocols.
|
|
1206
|
+
* Protocol names should include the trailing colon (e.g., `"https:"`).
|
|
1207
|
+
* If not specified, any protocol with a tuple origin is allowed.
|
|
1208
|
+
*/
|
|
1209
|
+
readonly allowedProtocols?: readonly string[];
|
|
1210
|
+
/**
|
|
1211
|
+
* How to treat a URL that carries more than an origin.
|
|
1212
|
+
*
|
|
1213
|
+
* - `"strip"`: return just the origin, discarding any path, query, or
|
|
1214
|
+
* fragment.
|
|
1215
|
+
* - `"reject"`: fail when the input has a path other than `/`, a query, or
|
|
1216
|
+
* a fragment.
|
|
1217
|
+
*
|
|
1218
|
+
* Credentials are always rejected, under either setting.
|
|
1219
|
+
* @default `"strip"`
|
|
1220
|
+
*/
|
|
1221
|
+
readonly extraComponents?: "strip" | "reject";
|
|
1222
|
+
/**
|
|
1223
|
+
* How to treat a trailing dot on a domain name, as in `example.com.`.
|
|
1224
|
+
*
|
|
1225
|
+
* - `"strip"`: remove it, so `example.com.` becomes `example.com`.
|
|
1226
|
+
* - `"preserve"`: keep it, matching the WHATWG URL origin exactly.
|
|
1227
|
+
* - `"append"`: force it, so `example.com` becomes `example.com.`. This
|
|
1228
|
+
* has no effect on an IP address literal.
|
|
1229
|
+
*
|
|
1230
|
+
* @default `"strip"`
|
|
1231
|
+
*/
|
|
1232
|
+
readonly trailingDot?: "strip" | "preserve" | "append";
|
|
1233
|
+
/**
|
|
1234
|
+
* Custom error messages for origin parsing failures.
|
|
1235
|
+
*/
|
|
1236
|
+
readonly errors?: {
|
|
1237
|
+
/**
|
|
1238
|
+
* Custom error message when input is not a valid absolute URL.
|
|
1239
|
+
*/
|
|
1240
|
+
readonly invalidOrigin?: Message | ((input: string) => Message);
|
|
1241
|
+
/**
|
|
1242
|
+
* Custom error message when URL protocol is not allowed.
|
|
1243
|
+
*/
|
|
1244
|
+
readonly disallowedProtocol?: Message | ((protocol: string, allowedProtocols: readonly string[]) => Message);
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Creates a {@link ValueParser} for web origins.
|
|
1249
|
+
*
|
|
1250
|
+
* An origin is a scheme, a host, and an optional port, and nothing else. The
|
|
1251
|
+
* parser returns a `URL` whose pathname is `/` and which carries no
|
|
1252
|
+
* credentials, query, or fragment.
|
|
1253
|
+
*
|
|
1254
|
+
* Input is canonicalized rather than rejected when it carries more than an
|
|
1255
|
+
* origin: the host is lowercased, internationalized names are converted to
|
|
1256
|
+
* punycode, and a default port is elided, so `HTTPS://Example.COM/`,
|
|
1257
|
+
* `https://example.com:443/path?query#fragment` all parse to
|
|
1258
|
+
* `https://example.com`. Set `extraComponents: "reject"` to fail on a path,
|
|
1259
|
+
* query, or fragment instead. Credentials are always rejected. Schemes whose
|
|
1260
|
+
* origin is opaque (`mailto:`, `data:`, `file:`) are rejected, as is `blob:`,
|
|
1261
|
+
* whose origin belongs to the URL it wraps.
|
|
1262
|
+
*
|
|
1263
|
+
* By default a trailing root-zone dot is stripped, so `example.com.` becomes
|
|
1264
|
+
* `example.com`. This differs from the WHATWG origin, which keeps the dot, so
|
|
1265
|
+
* the two strings are not interchangeable when an exact origin comparison
|
|
1266
|
+
* matters. Use `trailingDot: "preserve"` for the WHATWG behavior or
|
|
1267
|
+
* `trailingDot: "append"` to force a fully-qualified name.
|
|
1268
|
+
*
|
|
1269
|
+
* @param options Configuration options for the origin parser.
|
|
1270
|
+
* @returns A {@link ValueParser} that converts string input to `URL` objects
|
|
1271
|
+
* that name an origin.
|
|
1272
|
+
* @throws {TypeError} If any `allowedProtocols` entry is not a valid protocol
|
|
1273
|
+
* string ending with a colon (e.g., `"https:"`).
|
|
1274
|
+
* @since 1.3.0
|
|
1275
|
+
*/
|
|
1276
|
+
declare function origin(options?: OriginOptions): ValueParser<"sync", URL>;
|
|
1192
1277
|
/**
|
|
1193
1278
|
* Options for creating a {@link locale} parser.
|
|
1194
1279
|
*/
|
|
@@ -3337,4 +3422,4 @@ declare function firstOf<const TParsers extends readonly [ValueParser<"sync", un
|
|
|
3337
3422
|
*/
|
|
3338
3423
|
declare function firstOf<const TParsers extends readonly ValueParser<"sync", unknown>[]>(parsers: TParsers, options?: FirstOfOptions): ValueParser<"sync", ValueParserValue<TParsers[number]>>;
|
|
3339
3424
|
//#endregion
|
|
3340
|
-
export { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, type Mode, type ModeIterable, type ModeValue, type NonEmptyString, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, ensureNonEmptyString, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, json, keyValue, locale, macAddress, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid };
|
|
3425
|
+
export { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, type Mode, type ModeIterable, type ModeValue, type NonEmptyString, OriginOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, ensureNonEmptyString, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, json, keyValue, locale, macAddress, origin, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid };
|
package/dist/valueparser.d.ts
CHANGED
|
@@ -1189,6 +1189,91 @@ interface UrlOptions {
|
|
|
1189
1189
|
* string ending with a colon (e.g., `"https:"`).
|
|
1190
1190
|
*/
|
|
1191
1191
|
declare function url(options?: UrlOptions): ValueParser<"sync", URL>;
|
|
1192
|
+
/**
|
|
1193
|
+
* Options for creating an {@link origin} parser.
|
|
1194
|
+
*/
|
|
1195
|
+
interface OriginOptions {
|
|
1196
|
+
/**
|
|
1197
|
+
* The metavariable name for this parser. This is used in help messages to
|
|
1198
|
+
* indicate what kind of value this parser expects. Usually a single
|
|
1199
|
+
* word in uppercase, like `ORIGIN` or `BASE_URL`.
|
|
1200
|
+
* @default `"ORIGIN"`
|
|
1201
|
+
*/
|
|
1202
|
+
readonly metavar?: NonEmptyString;
|
|
1203
|
+
/**
|
|
1204
|
+
* List of allowed URL protocols (e.g., `["http:", "https:"]`).
|
|
1205
|
+
* If specified, the parsed URL must use one of these protocols.
|
|
1206
|
+
* Protocol names should include the trailing colon (e.g., `"https:"`).
|
|
1207
|
+
* If not specified, any protocol with a tuple origin is allowed.
|
|
1208
|
+
*/
|
|
1209
|
+
readonly allowedProtocols?: readonly string[];
|
|
1210
|
+
/**
|
|
1211
|
+
* How to treat a URL that carries more than an origin.
|
|
1212
|
+
*
|
|
1213
|
+
* - `"strip"`: return just the origin, discarding any path, query, or
|
|
1214
|
+
* fragment.
|
|
1215
|
+
* - `"reject"`: fail when the input has a path other than `/`, a query, or
|
|
1216
|
+
* a fragment.
|
|
1217
|
+
*
|
|
1218
|
+
* Credentials are always rejected, under either setting.
|
|
1219
|
+
* @default `"strip"`
|
|
1220
|
+
*/
|
|
1221
|
+
readonly extraComponents?: "strip" | "reject";
|
|
1222
|
+
/**
|
|
1223
|
+
* How to treat a trailing dot on a domain name, as in `example.com.`.
|
|
1224
|
+
*
|
|
1225
|
+
* - `"strip"`: remove it, so `example.com.` becomes `example.com`.
|
|
1226
|
+
* - `"preserve"`: keep it, matching the WHATWG URL origin exactly.
|
|
1227
|
+
* - `"append"`: force it, so `example.com` becomes `example.com.`. This
|
|
1228
|
+
* has no effect on an IP address literal.
|
|
1229
|
+
*
|
|
1230
|
+
* @default `"strip"`
|
|
1231
|
+
*/
|
|
1232
|
+
readonly trailingDot?: "strip" | "preserve" | "append";
|
|
1233
|
+
/**
|
|
1234
|
+
* Custom error messages for origin parsing failures.
|
|
1235
|
+
*/
|
|
1236
|
+
readonly errors?: {
|
|
1237
|
+
/**
|
|
1238
|
+
* Custom error message when input is not a valid absolute URL.
|
|
1239
|
+
*/
|
|
1240
|
+
readonly invalidOrigin?: Message | ((input: string) => Message);
|
|
1241
|
+
/**
|
|
1242
|
+
* Custom error message when URL protocol is not allowed.
|
|
1243
|
+
*/
|
|
1244
|
+
readonly disallowedProtocol?: Message | ((protocol: string, allowedProtocols: readonly string[]) => Message);
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Creates a {@link ValueParser} for web origins.
|
|
1249
|
+
*
|
|
1250
|
+
* An origin is a scheme, a host, and an optional port, and nothing else. The
|
|
1251
|
+
* parser returns a `URL` whose pathname is `/` and which carries no
|
|
1252
|
+
* credentials, query, or fragment.
|
|
1253
|
+
*
|
|
1254
|
+
* Input is canonicalized rather than rejected when it carries more than an
|
|
1255
|
+
* origin: the host is lowercased, internationalized names are converted to
|
|
1256
|
+
* punycode, and a default port is elided, so `HTTPS://Example.COM/`,
|
|
1257
|
+
* `https://example.com:443/path?query#fragment` all parse to
|
|
1258
|
+
* `https://example.com`. Set `extraComponents: "reject"` to fail on a path,
|
|
1259
|
+
* query, or fragment instead. Credentials are always rejected. Schemes whose
|
|
1260
|
+
* origin is opaque (`mailto:`, `data:`, `file:`) are rejected, as is `blob:`,
|
|
1261
|
+
* whose origin belongs to the URL it wraps.
|
|
1262
|
+
*
|
|
1263
|
+
* By default a trailing root-zone dot is stripped, so `example.com.` becomes
|
|
1264
|
+
* `example.com`. This differs from the WHATWG origin, which keeps the dot, so
|
|
1265
|
+
* the two strings are not interchangeable when an exact origin comparison
|
|
1266
|
+
* matters. Use `trailingDot: "preserve"` for the WHATWG behavior or
|
|
1267
|
+
* `trailingDot: "append"` to force a fully-qualified name.
|
|
1268
|
+
*
|
|
1269
|
+
* @param options Configuration options for the origin parser.
|
|
1270
|
+
* @returns A {@link ValueParser} that converts string input to `URL` objects
|
|
1271
|
+
* that name an origin.
|
|
1272
|
+
* @throws {TypeError} If any `allowedProtocols` entry is not a valid protocol
|
|
1273
|
+
* string ending with a colon (e.g., `"https:"`).
|
|
1274
|
+
* @since 1.3.0
|
|
1275
|
+
*/
|
|
1276
|
+
declare function origin(options?: OriginOptions): ValueParser<"sync", URL>;
|
|
1192
1277
|
/**
|
|
1193
1278
|
* Options for creating a {@link locale} parser.
|
|
1194
1279
|
*/
|
|
@@ -3337,4 +3422,4 @@ declare function firstOf<const TParsers extends readonly [ValueParser<"sync", un
|
|
|
3337
3422
|
*/
|
|
3338
3423
|
declare function firstOf<const TParsers extends readonly ValueParser<"sync", unknown>[]>(parsers: TParsers, options?: FirstOfOptions): ValueParser<"sync", ValueParserValue<TParsers[number]>>;
|
|
3339
3424
|
//#endregion
|
|
3340
|
-
export { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, type Mode, type ModeIterable, type ModeValue, type NonEmptyString, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, ensureNonEmptyString, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, json, keyValue, locale, macAddress, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid };
|
|
3425
|
+
export { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, type Mode, type ModeIterable, type ModeValue, type NonEmptyString, OriginOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, ensureNonEmptyString, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, json, keyValue, locale, macAddress, origin, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid };
|