@fgv/ts-bcp47 2.0.2-alpha.0 → 2.1.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ts-bcp47.d.ts +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/packlets/bcp47/common.js.map +1 -1
- package/lib/packlets/bcp47/languageRegistryData.js.map +1 -1
- package/lib/packlets/bcp47/languageTag.js +1 -1
- package/lib/packlets/bcp47/languageTag.js.map +1 -1
- package/lib/packlets/bcp47/languageTagParser.js.map +1 -1
- package/lib/packlets/bcp47/match/chooser.js.map +1 -1
- package/lib/packlets/bcp47/match/similarity.js.map +1 -1
- package/lib/packlets/bcp47/normalization/baseNormalizer.js.map +1 -1
- package/lib/packlets/bcp47/normalization/canonicalNormalizer.js.map +1 -1
- package/lib/packlets/bcp47/normalization/common.js.map +1 -1
- package/lib/packlets/bcp47/normalization/normalizeTag.js.map +1 -1
- package/lib/packlets/bcp47/normalization/preferredTagNormalizer.js.map +1 -1
- package/lib/packlets/bcp47/overrides/defaultRegistries.js.map +1 -1
- package/lib/packlets/bcp47/overrides/overridesRegistry.js.map +1 -1
- package/lib/packlets/bcp47/validation/baseValidator.js.map +1 -1
- package/lib/packlets/bcp47/validation/common.js.map +1 -1
- package/lib/packlets/bcp47/validation/isCanonical.js.map +1 -1
- package/lib/packlets/bcp47/validation/isInPreferredForm.js.map +1 -1
- package/lib/packlets/bcp47/validation/isStrictlyValid.js.map +1 -1
- package/lib/packlets/bcp47/validation/isValid.js.map +1 -1
- package/lib/packlets/bcp47/validation/isWellFormed.js.map +1 -1
- package/lib/packlets/bcp47/validation/validateTag.js.map +1 -1
- package/lib/packlets/iana/common/registeredItems.js.map +1 -1
- package/lib/packlets/iana/defaultRegistries.js.map +1 -1
- package/lib/packlets/iana/jar/jarConverters.js.map +1 -1
- package/lib/packlets/iana/jar/jarModel.d.ts +1 -1
- package/lib/packlets/iana/jar/jarModel.d.ts.map +1 -1
- package/lib/packlets/iana/jar/jarModel.js.map +1 -1
- package/lib/packlets/iana/jar/language-subtags/tags/converters.js.map +1 -1
- package/lib/packlets/iana/jar/language-subtags/tags/tagValidation.js.map +1 -1
- package/lib/packlets/iana/language-subtags/jarConverters.d.ts.map +1 -1
- package/lib/packlets/iana/language-subtags/jarConverters.js +2 -1
- package/lib/packlets/iana/language-subtags/jarConverters.js.map +1 -1
- package/lib/packlets/iana/language-subtags/scope.js.map +1 -1
- package/lib/packlets/iana/language-subtags/subtagRegistry.js.map +1 -1
- package/lib/packlets/iana/language-tag-extensions/extensionsRegistry.js.map +1 -1
- package/lib/packlets/iana/language-tag-extensions/jarConverters.d.ts.map +1 -1
- package/lib/packlets/iana/language-tag-extensions/jarConverters.js +2 -1
- package/lib/packlets/iana/language-tag-extensions/jarConverters.js.map +1 -1
- package/lib/packlets/unsd/areas.js.map +1 -1
- package/lib/packlets/unsd/csv/converters.d.ts.map +1 -1
- package/lib/packlets/unsd/csv/converters.js +2 -1
- package/lib/packlets/unsd/csv/converters.js.map +1 -1
- package/lib/packlets/unsd/defaultRegistries.js.map +1 -1
- package/lib/packlets/unsd/regionCodes.js.map +1 -1
- package/lib/packlets/unsd/regions.js.map +1 -1
- package/lib/packlets/utils/validationHelpers.js.map +1 -1
- package/package.json +32 -31
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationHelpers.js","sourceRoot":"","sources":["../../../src/packlets/utils/validationHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAyF;AAoBzF;;;;GAIG;AACH,MAAa,iBAAiB;IA8B5B;;;;;OAKG;IACH,YAAmB,IAAgD;QACjE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,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,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChE,CAAC;YACD,WAAW,EAAE,CAAC,IAAa,EAAa,EAAE;gBACxC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/D,CAAC;SACF,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IACpC,CAAC;CACF;AAlBD,0DAkBC","sourcesContent":["/*\n * Copyright (c) 2021 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Converter, Converters, Result, Validation, fail, succeed } from '@fgv/ts-utils';\n\n/**\n * A function which accepts a value of the expected type and reformats it to match\n * the canonical presentation form.\n * @public\n */\nexport type Normalizer<T extends string, TC = unknown> = (val: T, context?: TC) => Result<T>;\n\n/**\n * Initializer for {@link Utils.ValidationHelpers | validation helpers}.\n * @public\n */\nexport interface IValidationHelpersConstructorParams<T extends string, TC = unknown> {\n description: string;\n isWellFormed: Validation.TypeGuardWithContext<T, TC>;\n isCanonical: Validation.TypeGuardWithContext<T, TC>;\n toCanonical?: Normalizer<T, TC>;\n}\n\n/**\n A collection of validation and normalization helpers for constrained string\n types.\n * @public\n */\nexport class ValidationHelpers<T extends string, TC = unknown> {\n /**\n * Describes the group of tags validated by these helpers.\n */\n public readonly description: string;\n\n /**\n * A `Converter` which converts `unknown` to the tag type\n * validated by these helpers, if possible.\n */\n public readonly converter: Converter<T, TC>;\n\n /**\n * Determines is a supplied tag is well-formed according to the\n * lexical rules defined for the tag validated by these helpers.\n */\n public readonly isWellFormed: Validation.TypeGuardWithContext<T, TC>;\n\n /**\n * Determines is a supplied tag is well-formed and uses canonical\n * formatting, according to the lexical rules defined for the tag\n * validated by these helpers.\n */\n public readonly isCanonical: Validation.TypeGuardWithContext<T, TC>;\n\n /**\n * @internal\n */\n protected readonly _toCanonical?: Normalizer<T, TC>;\n\n /**\n * Constructs new {@link Utils.ValidationHelpers | validation helpers}\n * from supplied initializers.\n * @param init - The {@link Utils.ValidationHelpersConstructorParams | constructor params}\n * used to initialize this {@link Utils.ValidationHelpers | validation helpers}.\n */\n public constructor(init: IValidationHelpersConstructorParams<T, TC>) {\n this.description = init.description;\n this.isWellFormed = init.isWellFormed;\n this.isCanonical = init.isCanonical;\n this._toCanonical = init.toCanonical;\n this.converter = Converters.isA(this.description, this.isWellFormed);\n }\n\n /**\n * Converts a supplied `unknown` to the canonical form of the tag\n * validated by these helpers.\n * @param from - The `unknown` to be converted.\n * @param context - Optional context used in the conversion.\n * @returns `Success` with the corresponding canonical value,\n * or `Failure` with details if an error occurs.\n */\n public toCanonical(from: unknown, context?: TC): Result<T> {\n if (this.isWellFormed(from, context)) {\n if (this._toCanonical) {\n return this._toCanonical(from as T, context);\n }\n if (this.isCanonical(from, context)) {\n return succeed(from);\n }\n /* c8 ignore next 2 */\n return fail(`cannot convert \"${from}\" to canonical ${this.description}`);\n }\n return fail(`invalid ${this.description} (\"${JSON.stringify(from)}\")`);\n }\n\n /**\n * Determines if a supplied `unknown` is a well-formed representation\n * of the tag validated by these helpers.\n * @param from - The `unknown` to be validated.\n * @param context - Optional context used in the validation.\n * @returns `Success` with the validated value, or `Failure` with details\n * if an error occurs.\n */\n public verifyIsWellFormed(from: unknown, context?: TC): Result<T> {\n if (this.isWellFormed(from, context)) {\n return succeed(from);\n }\n return fail(`malformed ${this.description}`);\n }\n\n /**\n * Determines if a supplied `unknown` is a well-formed, canonical representation\n * of the tag validated by these helpers.\n * @param from - The `unknown` to be validated.\n * @param context - Optional context used in the validation.\n * @returns `Success` with the validated canonical value, or `Failure` with\n * details if an error occurs.\n */\n public verifyIsCanonical(from: unknown, context?: TC): Result<T> {\n if (this.isCanonical(from, context)) {\n return succeed(from);\n }\n /* c8 ignore next 3 - should never occur and very hard to test */\n if (!this.isWellFormed(from, context)) {\n return fail(`malformed ${this.description}`);\n }\n return fail(`non-canonical ${this.description}`);\n }\n}\n\n/**\n * @internal\n */\nexport interface IRegExpValidationHelperConstructorParams<T extends string, TC = unknown> {\n description: string;\n wellFormed: RegExp;\n canonical: RegExp;\n toCanonical?: Normalizer<T, TC>;\n}\n\n/**\n * @internal\n */\nexport class RegExpValidationHelpers<T extends string, TC = unknown> extends ValidationHelpers<T, TC> {\n public readonly wellFormed: RegExp;\n public readonly canonical: RegExp;\n\n public constructor(params: IRegExpValidationHelperConstructorParams<T, TC>) {\n super({\n description: params.description,\n toCanonical: params.toCanonical,\n isWellFormed: (from: unknown): from is T => {\n return typeof from === 'string' && this.wellFormed.test(from);\n },\n isCanonical: (from: unknown): from is T => {\n return typeof from === 'string' && this.canonical.test(from);\n }\n });\n this.wellFormed = params.wellFormed;\n this.canonical = params.canonical;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-bcp47",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1-alpha.0",
|
|
4
4
|
"description": "BCP-47 Tag Utilities",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "dist/ts-bcp47.d.ts",
|
|
@@ -21,44 +21,45 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://github.com/ErikFortune/ts-bcp47#readme",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@fgv/ts-json": "2.
|
|
25
|
-
"@fgv/ts-utils": "2.
|
|
26
|
-
"@fgv/ts-utils-jest": "2.
|
|
27
|
-
"@microsoft/api-documenter": "^7.
|
|
28
|
-
"@microsoft/api-extractor": "^7.
|
|
29
|
-
"@types/jest": "^29.5.
|
|
30
|
-
"@types/luxon": "^3.
|
|
31
|
-
"@types/node": "^20.
|
|
32
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
33
|
-
"@typescript-eslint/parser": "^
|
|
34
|
-
"axios": "^1.
|
|
35
|
-
"eslint": "^8.
|
|
36
|
-
"eslint-config-prettier": "^
|
|
24
|
+
"@fgv/ts-json": "2.1.1-alpha.0",
|
|
25
|
+
"@fgv/ts-utils": "2.1.1-alpha.0",
|
|
26
|
+
"@fgv/ts-utils-jest": "2.1.1-alpha.0",
|
|
27
|
+
"@microsoft/api-documenter": "^7.23.17",
|
|
28
|
+
"@microsoft/api-extractor": "^7.39.1",
|
|
29
|
+
"@types/jest": "^29.5.11",
|
|
30
|
+
"@types/luxon": "^3.4.1",
|
|
31
|
+
"@types/node": "^20.11.5",
|
|
32
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
33
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
34
|
+
"axios": "^1.6.5",
|
|
35
|
+
"eslint": "^8.56.0",
|
|
36
|
+
"eslint-config-prettier": "^9.1.0",
|
|
37
37
|
"eslint-config-standard": "^17.1.0",
|
|
38
|
-
"eslint-plugin-import": "^2.
|
|
38
|
+
"eslint-plugin-import": "^2.29.1",
|
|
39
39
|
"eslint-plugin-node": "^11.1.0",
|
|
40
|
-
"eslint-plugin-prettier": "^
|
|
40
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
41
41
|
"eslint-plugin-promise": "^6.1.1",
|
|
42
|
-
"jest": "^29.
|
|
43
|
-
"prettier": "^2.
|
|
44
|
-
"rimraf": "^5.0.
|
|
45
|
-
"ts-jest": "^29.1.
|
|
46
|
-
"ts-node": "^10.9.
|
|
47
|
-
"typescript": "^5.
|
|
48
|
-
"eslint-plugin-n": "^16.
|
|
49
|
-
"@rushstack/eslint-config": "~3.
|
|
50
|
-
"@rushstack/heft": "~0.
|
|
51
|
-
"@rushstack/heft-jest-plugin": "~0.
|
|
52
|
-
"@rushstack/heft-node-rig": "~2.
|
|
53
|
-
"@types/heft-jest": "1.0.
|
|
42
|
+
"jest": "^29.7.0",
|
|
43
|
+
"prettier": "^3.2.4",
|
|
44
|
+
"rimraf": "^5.0.5",
|
|
45
|
+
"ts-jest": "^29.1.1",
|
|
46
|
+
"ts-node": "^10.9.2",
|
|
47
|
+
"typescript": "^5.3.3",
|
|
48
|
+
"eslint-plugin-n": "^16.6.2",
|
|
49
|
+
"@rushstack/eslint-config": "~3.6.0",
|
|
50
|
+
"@rushstack/heft": "~0.64.0",
|
|
51
|
+
"@rushstack/heft-jest-plugin": "~0.11.0",
|
|
52
|
+
"@rushstack/heft-node-rig": "~2.4.0",
|
|
53
|
+
"@types/heft-jest": "1.0.6",
|
|
54
54
|
"eslint-plugin-tsdoc": "~0.2.17"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"luxon": "^3.
|
|
57
|
+
"luxon": "^3.4.4",
|
|
58
|
+
"@fgv/ts-extras": "2.1.1-alpha.0"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
60
|
-
"@fgv/ts-json": "^2.
|
|
61
|
-
"@fgv/ts-utils": "^2.
|
|
61
|
+
"@fgv/ts-json": "^2.1.1-alpha.0",
|
|
62
|
+
"@fgv/ts-utils": "^2.1.1-alpha.0"
|
|
62
63
|
},
|
|
63
64
|
"scripts": {
|
|
64
65
|
"build": "heft test --clean",
|