@stll/agent-input 0.4.1 → 0.4.3
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/country.d.ts +1 -3
- package/dist/country.js +2 -3
- package/dist/{date-value-CXL60jnN.js → date-value-BHqy-I76.js} +3 -5
- package/dist/date-value.d.ts +2 -4
- package/dist/date-value.js +1 -1
- package/dist/index.d.ts +1 -25
- package/dist/index.js +16 -29
- package/dist/locale.d.ts +2 -4
- package/dist/locale.js +2 -3
- package/dist/{normalized-Kt_5vfXW.js → normalized-DdVrroqo.js} +1 -2
- package/dist/{normalized-B9RxhmIz.d.ts → normalized-ytQiZGcH.d.ts} +0 -2
- package/dist/numeric-token.d.ts +0 -2
- package/dist/numeric-token.js +1 -2
- package/dist/string-list.d.ts +2 -4
- package/dist/string-list.js +2 -3
- package/package.json +9 -9
package/dist/country.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CountryAlpha3Code, CountryCode } from "@stll/country-codes";
|
|
2
|
-
import { t as Normalized } from "./normalized-
|
|
3
|
-
//#region src/country.d.ts
|
|
2
|
+
import { t as Normalized } from "./normalized-ytQiZGcH.js";
|
|
4
3
|
/**
|
|
5
4
|
* Jurisdictions that publish law without being ISO 3166-1 countries.
|
|
6
5
|
*
|
|
@@ -62,5 +61,4 @@ export declare const countryCodeIn: (value: CountryValue, spelling?: CountrySpel
|
|
|
62
61
|
* question about Czech law with Slovak decisions.
|
|
63
62
|
*/
|
|
64
63
|
export declare const normalizeCountry: (input: unknown, options?: CountryOptions) => Normalized<CountryValue>;
|
|
65
|
-
//#endregion
|
|
66
64
|
export {};
|
package/dist/country.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as readValueAs, t as askForFix } from "./normalized-
|
|
1
|
+
import { a as readValueAs, t as askForFix } from "./normalized-DdVrroqo.js";
|
|
2
2
|
import { foldToAscii } from "@stll/text-normalize";
|
|
3
3
|
import { COUNTRY_ALPHA3_BY_CODE, COUNTRY_CODES, countryCodeFromAlpha3, isCountryCode } from "@stll/country-codes";
|
|
4
|
-
|
|
4
|
+
// src/country.ts
|
|
5
5
|
/**
|
|
6
6
|
* Jurisdictions that publish law without being ISO 3166-1 countries.
|
|
7
7
|
*
|
|
@@ -229,5 +229,4 @@ const normalizeCountry = (input, options = {}) => {
|
|
|
229
229
|
hint: spellingHint(options)
|
|
230
230
|
});
|
|
231
231
|
};
|
|
232
|
-
//#endregion
|
|
233
232
|
export { COUNTRY_INPUT_MAX_CHARS, countryCodeIn, normalizeCountry };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as readValueAs, r as readAsAbsent, t as askForFix } from "./normalized-
|
|
1
|
+
import { a as readValueAs, r as readAsAbsent, t as askForFix } from "./normalized-DdVrroqo.js";
|
|
2
2
|
import { foldToAscii } from "@stll/text-normalize";
|
|
3
3
|
import { Temporal, parsePlainDate } from "@stll/time";
|
|
4
|
-
|
|
4
|
+
// src/absent.ts
|
|
5
5
|
/**
|
|
6
6
|
* Placeholders on optional filters.
|
|
7
7
|
*
|
|
@@ -43,8 +43,7 @@ const isAbsentPlaceholder = (input) => {
|
|
|
43
43
|
const trimmed = input.trim();
|
|
44
44
|
return trimmed === "" || PLACEHOLDERS.has(foldToAscii(trimmed).toLowerCase());
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
//#region src/date-value.ts
|
|
46
|
+
// src/date-value.ts
|
|
48
47
|
/**
|
|
49
48
|
* Calendar dates on the agent wire.
|
|
50
49
|
*
|
|
@@ -397,5 +396,4 @@ const normalizeDateBound = (input, options) => {
|
|
|
397
396
|
const year = Temporal.PlainDate.from(result.value).year;
|
|
398
397
|
return year < OPEN_BOUND_YEAR_BELOW || year >= OPEN_BOUND_YEAR_FROM ? readAsAbsent(input, "an open bound") : result;
|
|
399
398
|
};
|
|
400
|
-
//#endregion
|
|
401
399
|
export { isAbsentPlaceholder as a, ABSENT_PLACEHOLDERS as i, normalizeDateBound as n, normalizeDateValue as r, DATE_VALUE_HINT as t };
|
package/dist/date-value.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { i as NormalizedOptional, t as Normalized } from "./normalized-
|
|
2
|
-
//#region src/date-value.d.ts
|
|
1
|
+
import { i as NormalizedOptional, t as Normalized } from "./normalized-ytQiZGcH.js";
|
|
3
2
|
export declare const DATE_VALUE_HINT: string;
|
|
4
3
|
export type DateValueOptions = {
|
|
5
4
|
/** Locales to read besides English: the field's own `dateFormat` locale, so
|
|
@@ -26,5 +25,4 @@ export type DateBoundOptions = {
|
|
|
26
25
|
* is no bound at all, so the caller drops the property rather than filtering
|
|
27
26
|
* to the year 1 or 9999.
|
|
28
27
|
*/
|
|
29
|
-
export declare const normalizeDateBound: (input: unknown, options: DateBoundOptions) => NormalizedOptional<string>;
|
|
30
|
-
//#endregion
|
|
28
|
+
export declare const normalizeDateBound: (input: unknown, options: DateBoundOptions) => NormalizedOptional<string>;
|
package/dist/date-value.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as DATE_VALUE_HINT, n as normalizeDateBound, r as normalizeDateValue } from "./date-value-
|
|
1
|
+
export { t as DATE_VALUE_HINT, n as normalizeDateBound, r as normalizeDateValue } from "./date-value-BHqy-I76.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,8 @@ import { COUNTRY_INPUT_MAX_CHARS, CountryAlpha2, CountryAlpha3, CountryOptions,
|
|
|
2
2
|
import { DATE_VALUE_HINT, DateBound, DateBoundOptions, DateValueOptions, normalizeDateBound, normalizeDateValue } from "./date-value.js";
|
|
3
3
|
import { DateFormatStyle } from "@stll/template-conditions";
|
|
4
4
|
import { StringListOptions, normalizeStringList } from "./string-list.js";
|
|
5
|
-
import { a as askForFix, i as NormalizedOptional, n as NormalizedAbsent, o as askSentence, r as NormalizedAsk, s as readAsAbsent, t as Normalized } from "./normalized-
|
|
5
|
+
import { a as askForFix, i as NormalizedOptional, n as NormalizedAbsent, o as askSentence, r as NormalizedAsk, s as readAsAbsent, t as Normalized } from "./normalized-ytQiZGcH.js";
|
|
6
6
|
import { isPlausibleLocale, normalizeLocale } from "./locale.js";
|
|
7
|
-
//#region src/absent.d.ts
|
|
8
7
|
/**
|
|
9
8
|
* Placeholders on optional filters.
|
|
10
9
|
*
|
|
@@ -24,12 +23,8 @@ export declare const ABSENT_PLACEHOLDERS: readonly ["-", "--", "–", "—", "*"
|
|
|
24
23
|
/** Whether a string stands for "no value" on an optional filter: blank, or one
|
|
25
24
|
* of the placeholder words in any case and spacing. */
|
|
26
25
|
export declare const isAbsentPlaceholder: (input: unknown) => boolean;
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/boolean.d.ts
|
|
29
26
|
/** Read a yes/no answer an agent spelled its own way. */
|
|
30
27
|
export declare const normalizeBoolean: (input: unknown) => Normalized<boolean>;
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/date-format-spec.d.ts
|
|
33
28
|
type DateFormatSpec = {
|
|
34
29
|
locale: string;
|
|
35
30
|
style: DateFormatStyle;
|
|
@@ -38,8 +33,6 @@ export declare const DATE_FORMAT_SPEC_HINT: string;
|
|
|
38
33
|
/** Read a date-format spec an agent spelled its own way, as one string or as
|
|
39
34
|
* the wire object. */
|
|
40
35
|
export declare const normalizeDateFormatSpec: (input: unknown) => Normalized<DateFormatSpec>;
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/eli.d.ts
|
|
43
36
|
type EliOptions = {
|
|
44
37
|
/** ELI jurisdiction segment (lowercase, `"cz"`) to the publisher origin
|
|
45
38
|
* (`"https://www.e-sbirka.cz"`) that canonical identifiers carry. */
|
|
@@ -56,8 +49,6 @@ type EliOptions = {
|
|
|
56
49
|
* caller's citation reader before it asks.
|
|
57
50
|
*/
|
|
58
51
|
export declare const normalizeEli: (input: unknown, options: EliOptions) => Normalized<string>;
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/enum-value.d.ts
|
|
61
52
|
type EnumValueOptions = {
|
|
62
53
|
/** What the set is called in the ask: "The styles", "The registries". */
|
|
63
54
|
label?: string;
|
|
@@ -71,8 +62,6 @@ type EnumValueOptions = {
|
|
|
71
62
|
* set, which is short enough to copy from.
|
|
72
63
|
*/
|
|
73
64
|
export declare const normalizeEnumValue: <TValue extends string>(input: unknown, allowed: readonly TValue[], options?: EnumValueOptions) => Normalized<TValue>;
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/number.d.ts
|
|
76
65
|
type NumberOptions = {
|
|
77
66
|
/** The field's locale, when one is configured. It decides `1,234`. */
|
|
78
67
|
locale?: string | undefined;
|
|
@@ -95,8 +84,6 @@ type NumberInRangeOptions = NumberOptions & {
|
|
|
95
84
|
* range is a mistake to ask about, not a value to move.
|
|
96
85
|
*/
|
|
97
86
|
export declare const normalizeNumberInRange: (input: unknown, options: NumberInRangeOptions) => Normalized<number>;
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region src/uuid.d.ts
|
|
100
87
|
/** Documentation uuids a model reproduces when it has no real id: RFC 4122
|
|
101
88
|
* and RFC 9562 examples, and the ones tutorials and SDK docs print. */
|
|
102
89
|
export declare const SENTINEL_UUIDS: readonly ["123e4567-e89b-12d3-a456-426614174000", "123e4567-e89b-12d3-a456-426655440000", "01234567-89ab-cdef-0123-456789abcdef", "12345678-1234-1234-1234-123456789012", "12345678-1234-5678-1234-567812345678", "12345678-90ab-cdef-1234-567890abcdef", "00000000-0000-0000-0000-000000000001"];
|
|
@@ -112,8 +99,6 @@ type UuidOptions = {
|
|
|
112
99
|
/** Read an id an agent spelled its own way, as a lowercase dashed uuid. A
|
|
113
100
|
* placeholder or an invented id is no value. */
|
|
114
101
|
export declare const normalizeUuid: (input: unknown, options?: UuidOptions) => NormalizedOptional<string>;
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region src/vocabulary.d.ts
|
|
117
102
|
/** One allowed value, plus the other names it goes by in the data. */
|
|
118
103
|
type VocabularyEntry = {
|
|
119
104
|
value: string;
|
|
@@ -133,8 +118,6 @@ type VocabularyOptions = {
|
|
|
133
118
|
* matches several, or none, asks and names what there is.
|
|
134
119
|
*/
|
|
135
120
|
export declare const normalizeVocabularyValue: (input: unknown, entries: readonly VocabularyEntry[], options?: VocabularyOptions) => NormalizedOptional<string>;
|
|
136
|
-
//#endregion
|
|
137
|
-
//#region src/schema.d.ts
|
|
138
121
|
export declare const AGENT_INPUT_NORMALIZATION_KEY = "x-stella-agent-input";
|
|
139
122
|
export declare const AGENT_INPUT_NORMALIZATION_KIND: {
|
|
140
123
|
readonly boolean: "boolean";
|
|
@@ -246,8 +229,6 @@ export declare const normalizeAgentInput: ({ path, placeholders, readers, schema
|
|
|
246
229
|
schema: unknown;
|
|
247
230
|
value: unknown;
|
|
248
231
|
}) => AgentInputNormalizationResult;
|
|
249
|
-
//#endregion
|
|
250
|
-
//#region src/null-optionals.d.ts
|
|
251
232
|
/**
|
|
252
233
|
* Apply the common optional-null rule before any agent-value coercion. The
|
|
253
234
|
* decision comes from the same schema validation will use: nullable values keep
|
|
@@ -271,11 +252,6 @@ export declare const withModelPlaceholdersOmitted: (schema: unknown, value: unkn
|
|
|
271
252
|
* those nulls again, so the input a tool receives keeps its declared shape.
|
|
272
253
|
*/
|
|
273
254
|
export declare const withOptionalsNullable: (schema: unknown) => unknown;
|
|
274
|
-
//#endregion
|
|
275
|
-
//#region src/email-address.d.ts
|
|
276
255
|
export declare const EMAIL_ADDRESS_PATTERN: RegExp;
|
|
277
|
-
//#endregion
|
|
278
|
-
//#region src/data-box-id.d.ts
|
|
279
256
|
export declare const DATA_BOX_ID_PATTERN: RegExp;
|
|
280
|
-
//#endregion
|
|
281
257
|
export { type AgentInputCountryAnnotation, type AgentInputNormalizationAnnotation, type AgentInputNormalizationIssue, type AgentInputNormalizationKind, type AgentInputNormalizationResult, type AgentInputPlaceholderPolicy, type AgentInputReaders, COUNTRY_INPUT_MAX_CHARS, type CountryAlpha2, type CountryAlpha3, type CountryOptions, type CountrySpelling, type CountryValue, DATE_VALUE_HINT, type DateBound, type DateBoundOptions, type DateValueOptions, type EliOptions, type Normalized, type NormalizedAbsent, type NormalizedAsk, type NormalizedOptional, type NumberInRangeOptions, type NumberOptions, type StringListOptions, type UuidOptions, type VocabularyEntry, type VocabularyOptions, askForFix, askSentence, countryCodeIn, isPlausibleLocale, normalizeCountry, normalizeDateBound, normalizeDateValue, normalizeLocale, normalizeStringList, readAsAbsent };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as isAbsentPlaceholder, i as ABSENT_PLACEHOLDERS, n as normalizeDateBound, r as normalizeDateValue, t as DATE_VALUE_HINT } from "./date-value-
|
|
2
|
-
import { a as readValueAs, i as readValue, n as askSentence, r as readAsAbsent, t as askForFix } from "./normalized-
|
|
1
|
+
import { a as isAbsentPlaceholder, i as ABSENT_PLACEHOLDERS, n as normalizeDateBound, r as normalizeDateValue, t as DATE_VALUE_HINT } from "./date-value-BHqy-I76.js";
|
|
2
|
+
import { a as readValueAs, i as readValue, n as askSentence, r as readAsAbsent, t as askForFix } from "./normalized-DdVrroqo.js";
|
|
3
3
|
import { COUNTRY_INPUT_MAX_CHARS, countryCodeIn, normalizeCountry } from "./country.js";
|
|
4
4
|
import { isPlausibleLocale, normalizeLocale } from "./locale.js";
|
|
5
5
|
import { normalizeStringList } from "./string-list.js";
|
|
@@ -7,7 +7,7 @@ import { foldToAscii } from "@stll/text-normalize";
|
|
|
7
7
|
import { DATE_FORMAT_STYLES } from "@stll/template-conditions";
|
|
8
8
|
import { distance } from "@stll/fuzzy-search";
|
|
9
9
|
import { Result, panic } from "better-result";
|
|
10
|
-
|
|
10
|
+
// src/boolean.ts
|
|
11
11
|
/**
|
|
12
12
|
* Yes/no answers on the agent wire.
|
|
13
13
|
*
|
|
@@ -66,8 +66,7 @@ const normalizeBoolean = (input) => {
|
|
|
66
66
|
});
|
|
67
67
|
return readValueAs(input, word);
|
|
68
68
|
};
|
|
69
|
-
|
|
70
|
-
//#region src/enum-value.ts
|
|
69
|
+
// src/enum-value.ts
|
|
71
70
|
/**
|
|
72
71
|
* Closed vocabularies on the agent wire: a style name, a registry slug, an
|
|
73
72
|
* input type, a select option.
|
|
@@ -109,8 +108,7 @@ const normalizeEnumValue = (input, allowed, options) => {
|
|
|
109
108
|
hint: closest === void 0 ? listed : `Did you mean "${closest}"? ${listed}`
|
|
110
109
|
});
|
|
111
110
|
};
|
|
112
|
-
|
|
113
|
-
//#region src/date-format-spec.ts
|
|
111
|
+
// src/date-format-spec.ts
|
|
114
112
|
/**
|
|
115
113
|
* How a date field renders: a locale and a style.
|
|
116
114
|
*
|
|
@@ -223,8 +221,7 @@ const normalizeDateFormatSpec = (input) => {
|
|
|
223
221
|
if (isRecord$2(input)) return readObjectSpec(input);
|
|
224
222
|
return specAsk(input);
|
|
225
223
|
};
|
|
226
|
-
|
|
227
|
-
//#region src/eli.ts
|
|
224
|
+
// src/eli.ts
|
|
228
225
|
const ELI_EXPECTED = "an ELI";
|
|
229
226
|
const ELI_HINT = "Pass the eli a search result returned.";
|
|
230
227
|
/** An origin with a scheme, or a bare host a model pasted without one; a bare
|
|
@@ -329,8 +326,7 @@ const normalizeEli = (input, options) => {
|
|
|
329
326
|
}
|
|
330
327
|
return readValueAs(input, work);
|
|
331
328
|
};
|
|
332
|
-
|
|
333
|
-
//#region src/number.ts
|
|
329
|
+
// src/number.ts
|
|
334
330
|
/**
|
|
335
331
|
* Numbers on the agent wire.
|
|
336
332
|
*
|
|
@@ -457,7 +453,7 @@ const normalizeNumber = (input, options) => {
|
|
|
457
453
|
if (commas > 1 || dots > 1) return null;
|
|
458
454
|
const separator = commas === 1 ? "," : ".";
|
|
459
455
|
if (!THREE_DIGIT_TAIL_RE.test(body)) return separator;
|
|
460
|
-
const mark = options?.locale
|
|
456
|
+
const mark = options?.locale !== void 0 ? localeDecimalMark(options.locale) : null;
|
|
461
457
|
if (mark === null) return AMBIGUOUS;
|
|
462
458
|
return mark === separator ? separator : null;
|
|
463
459
|
})();
|
|
@@ -504,8 +500,7 @@ const normalizeNumberInRange = (input, options) => {
|
|
|
504
500
|
if (minimum !== void 0 && read.value < minimum) return clampTo(minimum, "the least this accepts");
|
|
505
501
|
return read;
|
|
506
502
|
};
|
|
507
|
-
|
|
508
|
-
//#region src/uuid.ts
|
|
503
|
+
// src/uuid.ts
|
|
509
504
|
/**
|
|
510
505
|
* Record ids on the agent wire.
|
|
511
506
|
*
|
|
@@ -572,8 +567,7 @@ const normalizeUuid = (input, options = {}) => {
|
|
|
572
567
|
if (isSentinelUuid(canonical)) return readAsAbsent(input, "a placeholder id, not a record");
|
|
573
568
|
return readValueAs(input, canonical);
|
|
574
569
|
};
|
|
575
|
-
|
|
576
|
-
//#region src/vocabulary.ts
|
|
570
|
+
// src/vocabulary.ts
|
|
577
571
|
/**
|
|
578
572
|
* Filter values whose allowed set comes from data: court names, decision types,
|
|
579
573
|
* register sections.
|
|
@@ -662,8 +656,7 @@ const normalizeVocabularyValue = (input, entries, options = {}) => {
|
|
|
662
656
|
if (onlyContaining === void 0) return askListing();
|
|
663
657
|
return otherContaining.length === 0 ? readValueAs(input, onlyContaining) : askAmong(containing);
|
|
664
658
|
};
|
|
665
|
-
|
|
666
|
-
//#region src/currency-code.ts
|
|
659
|
+
// src/currency-code.ts
|
|
667
660
|
const normalizeCurrencyCode = (input) => {
|
|
668
661
|
const value = typeof input === "string" ? input.trim().toUpperCase() : void 0;
|
|
669
662
|
return value !== void 0 && /^[A-Z]{3}$/u.test(value) ? readValueAs(input, value) : askForFix({
|
|
@@ -672,8 +665,7 @@ const normalizeCurrencyCode = (input) => {
|
|
|
672
665
|
hint: "Pass a three-letter currency code, such as EUR or CZK."
|
|
673
666
|
});
|
|
674
667
|
};
|
|
675
|
-
|
|
676
|
-
//#region src/data-box-id.ts
|
|
668
|
+
// src/data-box-id.ts
|
|
677
669
|
const DATA_BOX_ID_PATTERN = /^[A-Za-z0-9]{7}$/u;
|
|
678
670
|
/** Data box identifiers are case-sensitive external keys, never record UUIDs. */
|
|
679
671
|
const normalizeDataBoxId = (input) => {
|
|
@@ -684,8 +676,7 @@ const normalizeDataBoxId = (input) => {
|
|
|
684
676
|
hint: "Pass the seven letters and digits of the recipient's data box ID."
|
|
685
677
|
});
|
|
686
678
|
};
|
|
687
|
-
|
|
688
|
-
//#region src/email-address.ts
|
|
679
|
+
// src/email-address.ts
|
|
689
680
|
const EMAIL_ADDRESS_PATTERN = /^[\w+-]+(?:\.[\w+-]+)*@[\da-zA-Z]+(?:[.-][\da-zA-Z]+)*\.[a-zA-Z]{2,}$/u;
|
|
690
681
|
/** Preserve the local part's case: contact addresses are not account identity keys. */
|
|
691
682
|
const normalizeEmailAddress = (input) => {
|
|
@@ -696,8 +687,7 @@ const normalizeEmailAddress = (input) => {
|
|
|
696
687
|
hint: "Pass one email address, such as name@example.com, without a display name."
|
|
697
688
|
});
|
|
698
689
|
};
|
|
699
|
-
|
|
700
|
-
//#region src/slug.ts
|
|
690
|
+
// src/slug.ts
|
|
701
691
|
/** Case and internal separators identify a different slug; only outer whitespace is noise. */
|
|
702
692
|
const normalizeSlug = (input) => {
|
|
703
693
|
if (typeof input === "string" && /^[a-z0-9-]+$/u.test(input.trim())) return readValueAs(input, input.trim());
|
|
@@ -707,8 +697,7 @@ const normalizeSlug = (input) => {
|
|
|
707
697
|
hint: "Use lowercase ASCII letters, digits or hyphens, without spaces."
|
|
708
698
|
});
|
|
709
699
|
};
|
|
710
|
-
|
|
711
|
-
//#region src/schema.ts
|
|
700
|
+
// src/schema.ts
|
|
712
701
|
const AGENT_INPUT_NORMALIZATION_KEY = "x-stella-agent-input";
|
|
713
702
|
const AGENT_INPUT_NORMALIZATION_KIND = {
|
|
714
703
|
boolean: "boolean",
|
|
@@ -1253,8 +1242,7 @@ const normalizeAgentInput = ({ path = "", placeholders = "absent", readers = {},
|
|
|
1253
1242
|
notes: []
|
|
1254
1243
|
};
|
|
1255
1244
|
};
|
|
1256
|
-
|
|
1257
|
-
//#region src/null-optionals.ts
|
|
1245
|
+
// src/null-optionals.ts
|
|
1258
1246
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1259
1247
|
const isUnknownArray = (value) => Array.isArray(value);
|
|
1260
1248
|
const sameJsonValue = (left, right) => {
|
|
@@ -1600,5 +1588,4 @@ const widenOptionals = (schema, inheritedRequired) => {
|
|
|
1600
1588
|
* those nulls again, so the input a tool receives keeps its declared shape.
|
|
1601
1589
|
*/
|
|
1602
1590
|
const withOptionalsNullable = (schema) => widenOptionals(schema, NO_NAMES);
|
|
1603
|
-
//#endregion
|
|
1604
1591
|
export { ABSENT_PLACEHOLDERS, AGENT_INPUT_NORMALIZATION_KEY, AGENT_INPUT_NORMALIZATION_KIND, COUNTRY_INPUT_MAX_CHARS, DATA_BOX_ID_PATTERN, DATE_FORMAT_SPEC_HINT, DATE_VALUE_HINT, EMAIL_ADDRESS_PATTERN, SENTINEL_UUIDS, agentInputNormalization, agentInputNormalizationGuidance, agentInputNormalizationMetadata, askForFix, askSentence, countryCodeIn, isAbsentPlaceholder, isPlausibleLocale, isSentinelUuid, normalizeAgentInput, normalizeBoolean, normalizeCountry, normalizeDateBound, normalizeDateFormatSpec, normalizeDateValue, normalizeEli, normalizeEnumValue, normalizeLocale, normalizeNumber, normalizeNumberInRange, normalizeStringList, normalizeUuid, normalizeVocabularyValue, readAsAbsent, withModelPlaceholdersOmitted, withNullOptionalsOmitted, withOptionalsNullable };
|
package/dist/locale.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as Normalized } from "./normalized-
|
|
2
|
-
//#region src/locale.d.ts
|
|
1
|
+
import { t as Normalized } from "./normalized-ytQiZGcH.js";
|
|
3
2
|
/**
|
|
4
3
|
* Whether a tag is already the spelling `Intl` accepts. This is the check a
|
|
5
4
|
* stored or advertised locale passes: a value that reaches
|
|
@@ -8,5 +7,4 @@ import { t as Normalized } from "./normalized-B9RxhmIz.js";
|
|
|
8
7
|
*/
|
|
9
8
|
export declare const isPlausibleLocale: (value: string) => boolean;
|
|
10
9
|
/** Read a locale an agent spelled its own way, canonically. */
|
|
11
|
-
export declare const normalizeLocale: (input: unknown) => Normalized<string>;
|
|
12
|
-
//#endregion
|
|
10
|
+
export declare const normalizeLocale: (input: unknown) => Normalized<string>;
|
package/dist/locale.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as readValueAs, t as askForFix } from "./normalized-
|
|
1
|
+
import { a as readValueAs, t as askForFix } from "./normalized-DdVrroqo.js";
|
|
2
2
|
import { Result } from "better-result";
|
|
3
|
-
|
|
3
|
+
// src/locale.ts
|
|
4
4
|
/**
|
|
5
5
|
* Locale tags on the agent wire.
|
|
6
6
|
*
|
|
@@ -44,5 +44,4 @@ const normalizeLocale = (input) => {
|
|
|
44
44
|
});
|
|
45
45
|
return readValueAs(input, canonical);
|
|
46
46
|
};
|
|
47
|
-
//#endregion
|
|
48
47
|
export { isPlausibleLocale, normalizeLocale };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/normalized.ts
|
|
2
2
|
/** Wire values carry matter content and personal data, so an echo back to the
|
|
3
3
|
* model is bounded to the length of a spelling. */
|
|
4
4
|
const MAX_RECEIVED_CHARS = 80;
|
|
@@ -50,5 +50,4 @@ const readAsAbsent = (input, reason) => {
|
|
|
50
50
|
note: reason === void 0 ? `Read ${received} as no value.` : `Read ${received} as no value: ${reason}.`
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
-
//#endregion
|
|
54
53
|
export { readValueAs as a, readValue as i, askSentence as n, readAsAbsent as r, askForFix as t };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/normalized.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* One shape for every value an agent spells its own way.
|
|
4
3
|
*
|
|
@@ -59,5 +58,4 @@ type NormalizedOptional<TValue> = Normalized<TValue> | NormalizedAbsent;
|
|
|
59
58
|
/** The absent outcome, with the one "read X as no value" sentence every kind
|
|
60
59
|
* reports it with. `reason` says why, when the spelling alone does not. */
|
|
61
60
|
declare const readAsAbsent: (input: unknown, reason?: string) => NormalizedAbsent;
|
|
62
|
-
//#endregion
|
|
63
61
|
export { askForFix as a, NormalizedOptional as i, NormalizedAbsent as n, askSentence as o, NormalizedAsk as r, readAsAbsent as s, Normalized as t };
|
package/dist/numeric-token.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Result } from "better-result";
|
|
2
|
-
//#region src/numeric-token.d.ts
|
|
3
2
|
declare const InvalidNumericTokenError_base: import("better-result").TaggedErrorClass<"InvalidNumericTokenError">;
|
|
4
3
|
export declare class InvalidNumericTokenError extends InvalidNumericTokenError_base<{
|
|
5
4
|
message: string;
|
|
@@ -15,5 +14,4 @@ export type NumericTokenOptions = {
|
|
|
15
14
|
export declare const parseIntegerToken: (input: unknown, options?: NumericTokenOptions) => Result<number, InvalidNumericTokenError>;
|
|
16
15
|
/** Grammar: `-?[0-9]+(\.[0-9]+)?`; no grouping, exponent or implicit whitespace. */
|
|
17
16
|
export declare const parseDecimalToken: (input: unknown, options?: NumericTokenOptions) => Result<number, InvalidNumericTokenError>;
|
|
18
|
-
//#endregion
|
|
19
17
|
export {};
|
package/dist/numeric-token.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Result, TaggedError } from "better-result";
|
|
2
|
-
|
|
2
|
+
// src/numeric-token.ts
|
|
3
3
|
var InvalidNumericTokenError = class extends TaggedError("InvalidNumericTokenError") {};
|
|
4
4
|
const SIGNED_INTEGER = /^-?[0-9]+(?![\s\S])/u;
|
|
5
5
|
const UNSIGNED_INTEGER = /^[0-9]+(?![\s\S])/u;
|
|
@@ -41,5 +41,4 @@ const parseDecimalToken = (input, options = {}) => {
|
|
|
41
41
|
}));
|
|
42
42
|
return inRange(value, options);
|
|
43
43
|
};
|
|
44
|
-
//#endregion
|
|
45
44
|
export { InvalidNumericTokenError, parseDecimalToken, parseIntegerToken };
|
package/dist/string-list.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as Normalized } from "./normalized-
|
|
2
|
-
//#region src/string-list.d.ts
|
|
1
|
+
import { t as Normalized } from "./normalized-ytQiZGcH.js";
|
|
3
2
|
export type StringListOptions = {
|
|
4
3
|
/** `"delimiters"` splits a scalar on commas, semicolons and newlines, for
|
|
5
4
|
* items that cannot contain them (ids, codes). `"never"` wraps a scalar as
|
|
@@ -10,5 +9,4 @@ export type StringListOptions = {
|
|
|
10
9
|
* shape is read here: an array is taken as it is, and one holding anything
|
|
11
10
|
* but strings asks, since what an item should have been is the item's
|
|
12
11
|
* question, not the list's. */
|
|
13
|
-
export declare const normalizeStringList: (input: unknown, options: StringListOptions) => Normalized<string[]>;
|
|
14
|
-
//#endregion
|
|
12
|
+
export declare const normalizeStringList: (input: unknown, options: StringListOptions) => Normalized<string[]>;
|
package/dist/string-list.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as readValueAs, i as readValue, t as askForFix } from "./normalized-
|
|
1
|
+
import { a as readValueAs, i as readValue, t as askForFix } from "./normalized-DdVrroqo.js";
|
|
2
2
|
import { Result } from "better-result";
|
|
3
|
-
|
|
3
|
+
// src/string-list.ts
|
|
4
4
|
/**
|
|
5
5
|
* Lists of strings on the agent wire.
|
|
6
6
|
*
|
|
@@ -38,5 +38,4 @@ const normalizeStringList = (input, options) => {
|
|
|
38
38
|
const pieces = input.split(DELIMITERS_RE).map((piece) => piece.trim()).filter((piece) => piece !== "");
|
|
39
39
|
return readValueAs(input, pieces);
|
|
40
40
|
};
|
|
41
|
-
//#endregion
|
|
42
41
|
export { normalizeStringList };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/agent-input",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Lenient readers for values agents write: dates, date bounds, date-format specs, numbers, booleans, locales, countries, enum and vocabulary values, ids, ELIs, string lists",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -63,16 +63,16 @@
|
|
|
63
63
|
"test": "bun test src",
|
|
64
64
|
"test:property": "bun test --preload @stll/property-testing/preload $(grep -rlE 'fc\\.assert|assertProperty' src --include='*.test.ts')",
|
|
65
65
|
"typecheck": "bun check --no-pretty --all --project=tsconfig.json",
|
|
66
|
-
"lint": "cd ../.. && bun
|
|
67
|
-
"lint:fix": "cd ../.. && bun
|
|
66
|
+
"lint": "cd ../.. && bun scripts/lint.ts packages/agent-input",
|
|
67
|
+
"lint:fix": "cd ../.. && bun scripts/lint.ts --fix packages/agent-input",
|
|
68
68
|
"prepack": "bun run build"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@stll/country-codes": "^0.2.0",
|
|
72
|
-
"@stll/fuzzy-search": "1.4.
|
|
73
|
-
"@stll/template-conditions": "^0.6.
|
|
74
|
-
"@stll/text-normalize": "^0.
|
|
75
|
-
"@stll/time": "0.4.
|
|
72
|
+
"@stll/fuzzy-search": "1.4.2",
|
|
73
|
+
"@stll/template-conditions": "^0.6.5",
|
|
74
|
+
"@stll/text-normalize": "^0.8.0",
|
|
75
|
+
"@stll/time": "0.4.2",
|
|
76
76
|
"better-result": "3.0.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"@stll/typescript-config": "0.0.0",
|
|
81
81
|
"bun-types": "1.4.4",
|
|
82
82
|
"fast-check": "^4.10.2",
|
|
83
|
-
"tsdown": "0.23.
|
|
84
|
-
"tsrs": "0.
|
|
83
|
+
"tsdown": "0.23.4",
|
|
84
|
+
"tsrs": "0.20.1-ts7.1.0-beta"
|
|
85
85
|
},
|
|
86
86
|
"main": "./dist/index.js",
|
|
87
87
|
"types": "./dist/index.d.ts"
|