@juherr/mobilityid 0.0.1 → 0.2.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/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/check-digit-din.ts","../src/check-digit-iso.ts","../src/contract-id-standard.ts","../src/country-code.ts","../src/provider-id.ts","../src/party-id.ts","../src/contract-id.ts","../src/operator-id.ts","../src/phone-country-code.ts","../src/evse-id.ts","../src/parsers.ts"],"sourcesContent":["/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst values = new Map<string, number>();\n\nfor (let index = 0; index <= 9; index += 1) {\n values.set(String(index), index);\n}\n\nfor (let index = 0; index < 26; index += 1) {\n values.set(String.fromCharCode(\"A\".charCodeAt(0) + index), 10 + index);\n}\n\nexport function checkDigitDin(code: string): string {\n const normalized = code.toUpperCase();\n const lookup = Array.from(normalized, (char) => {\n const value = values.get(char);\n if (value === undefined) {\n throw new TypeError(\n `invalid character '${char}' in code '${code}'; must consist of uppercase ASCII letters and digits`,\n );\n }\n\n return value;\n });\n\n let sum = 0;\n let coefficient = 0;\n\n for (const current of lookup) {\n if (current < 10) {\n sum += current * 2 ** coefficient;\n coefficient += 1;\n continue;\n }\n\n sum += Math.floor(current / 10) * 2 ** coefficient + (current % 10) * 2 ** (coefficient + 1);\n coefficient += 2;\n }\n\n const mod = sum % 11;\n\n if (mod >= 10) {\n return \"X\";\n }\n\n return String(mod);\n}\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\ntype Matrix = Readonly<{ m11: number; m12: number; m21: number; m22: number }>;\ntype Vec = Readonly<{ v1: number; v2: number }>;\n\nconst checkDigitInputRegex = /^[A-Z0-9]+$/;\n\nconst matrixKey = (m: Matrix): string => `${m.m11},${m.m12},${m.m21},${m.m22}`;\n\nconst multiplyMatrix = (a: Matrix, b: Matrix): Matrix => ({\n m11: a.m11 * b.m11 + a.m12 * b.m21,\n m12: a.m11 * b.m12 + a.m12 * b.m22,\n m21: a.m21 * b.m11 + a.m22 * b.m21,\n m22: a.m21 * b.m12 + a.m22 * b.m22,\n});\n\nconst addVec = (a: Vec, b: Vec): Vec => ({\n v1: a.v1 + b.v1,\n v2: a.v2 + b.v2,\n});\n\nconst multiplyVec = (v: Vec, m: Matrix): Vec => ({\n v1: v.v1 * m.m11 + v.v2 * m.m21,\n v2: v.v1 * m.m12 + v.v2 * m.m22,\n});\n\nconst decodeMatrix = (x: number): Matrix => ({\n m11: x & 1,\n m12: (x >> 1) & 1,\n m21: (x >> 2) & 3,\n m22: x >> 4,\n});\n\nconst encodingValues: Readonly<Record<string, number>> = {\n \"0\": 0,\n \"1\": 16,\n \"2\": 32,\n \"3\": 4,\n \"4\": 20,\n \"5\": 36,\n \"6\": 8,\n \"7\": 24,\n \"8\": 40,\n \"9\": 2,\n A: 18,\n B: 34,\n C: 6,\n D: 22,\n E: 38,\n F: 10,\n G: 26,\n H: 42,\n I: 1,\n J: 17,\n K: 33,\n L: 5,\n M: 21,\n N: 37,\n O: 9,\n P: 25,\n Q: 41,\n R: 3,\n S: 19,\n T: 35,\n U: 7,\n V: 23,\n W: 39,\n X: 11,\n Y: 27,\n Z: 43,\n};\n\nconst encoding = new Map<string, Matrix>();\nconst decoding = new Map<string, string>();\n\nfor (const [char, value] of Object.entries(encodingValues)) {\n const matrix = decodeMatrix(value);\n encoding.set(char, matrix);\n decoding.set(matrixKey(matrix), char);\n}\n\nconst p1: Matrix = { m11: 0, m12: 1, m21: 1, m22: 1 };\nconst p2: Matrix = { m11: 0, m12: 1, m21: 1, m22: 2 };\n\nconst p1s: Matrix[] = [];\nconst p2s: Matrix[] = [];\n\nlet currentP1 = p1;\nlet currentP2 = p2;\nfor (let index = 0; index < 14; index += 1) {\n p1s.push(currentP1);\n p2s.push(currentP2);\n currentP1 = multiplyMatrix(currentP1, p1);\n currentP2 = multiplyMatrix(currentP2, p2);\n}\n\nconst negP2minus15: Matrix = { m11: 0, m12: 2, m21: 2, m22: 1 };\n\nexport function checkDigitIso(code: string): string {\n const normalized = code.toUpperCase();\n\n if (normalized.length !== p1s.length || normalized.length !== p2s.length) {\n throw new TypeError(`Code must have a length of ${p1s.length}`);\n }\n\n if (!checkDigitInputRegex.test(normalized)) {\n throw new TypeError(\"Code must consist of uppercase ASCII letters and digits\");\n }\n\n const sumEq = (matrices: Matrix[], toVec: (matrix: Matrix) => Vec): Vec => {\n let value: Vec = { v1: 0, v2: 0 };\n\n for (let index = 0; index < matrices.length; index += 1) {\n const character = normalized.charAt(index);\n const matrix = encoding.get(character);\n if (!matrix) {\n throw new TypeError(`Invalid character: ${character}.`);\n }\n\n const positionMatrix = matrices[index];\n if (!positionMatrix) {\n throw new TypeError(`Missing matrix at index: ${index}.`);\n }\n\n const qr = toVec(matrix);\n value = addVec(value, multiplyVec(qr, positionMatrix));\n }\n\n return value;\n };\n\n const t1 = sumEq(p1s, (matrix) => ({ v1: matrix.m11, v2: matrix.m12 }));\n const t2 = multiplyVec(\n sumEq(p2s, (matrix) => ({ v1: matrix.m21, v2: matrix.m22 })),\n negP2minus15,\n );\n\n const m15: Matrix = {\n m11: t1.v1 & 1,\n m12: t1.v2 & 1,\n m21: t2.v1 % 3,\n m22: t2.v2 % 3,\n };\n\n const decoded = decoding.get(matrixKey(m15));\n if (!decoded) {\n throw new TypeError(`Undecodable matrix: ${matrixKey(m15)}.`);\n }\n\n return decoded;\n}\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ContractIdStandards = {\n ISO: \"ISO\",\n EMI3: \"EMI3\",\n DIN: \"DIN\",\n} as const;\n\nexport type ContractIdStandard = (typeof ContractIdStandards)[keyof typeof ContractIdStandards];\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst COUNTRY_CODE_REGEX = /^[A-Za-z]{2}$/;\n\nconst regionNames = new Intl.DisplayNames([\"en\"], { type: \"region\" });\n\nexport class CountryCode {\n public readonly value: string;\n\n private constructor(value: string) {\n this.value = value;\n Object.freeze(this);\n }\n\n public static isValid(raw: string): boolean {\n if (!COUNTRY_CODE_REGEX.test(raw)) {\n return false;\n }\n\n const normalized = raw.toUpperCase();\n const display = regionNames.of(normalized);\n return display !== undefined && display !== normalized && display !== \"Unknown Region\";\n }\n\n public static from(raw: string): CountryCode {\n if (!CountryCode.isValid(raw)) {\n throw new TypeError(\"Country Code must be valid according to ISO 3166-1 alpha-2\");\n }\n\n return new CountryCode(raw.toUpperCase());\n }\n\n public static parse(raw: string): CountryCode | null {\n try {\n return CountryCode.from(raw);\n } catch {\n return null;\n }\n }\n\n public toString(): string {\n return this.value;\n }\n}\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst PARTY_CODE_REGEX = /^[A-Za-z0-9]{3}$/;\n\nexport function isValidPartyCode(value: string): boolean {\n return PARTY_CODE_REGEX.test(value);\n}\n\nexport class ProviderId {\n public readonly value: string;\n\n private constructor(value: string) {\n this.value = value;\n Object.freeze(this);\n }\n\n public static isValid(raw: string): boolean {\n return isValidPartyCode(raw);\n }\n\n public static from(raw: string): ProviderId {\n if (!ProviderId.isValid(raw)) {\n throw new TypeError(\"OperatorId must have a length of 3 and be ASCII letters or digits\");\n }\n\n return new ProviderId(raw.toUpperCase());\n }\n\n public static parse(raw: string): ProviderId | null {\n try {\n return ProviderId.from(raw);\n } catch {\n return null;\n }\n }\n\n public toString(): string {\n return this.value;\n }\n}\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CountryCode } from \"./country-code.js\";\nimport type { OperatorIdIso } from \"./operator-id.js\";\nimport { ProviderId } from \"./provider-id.js\";\n\nconst PARTY_ID_REGEX = /^([A-Za-z]{2})[-*]?([A-Za-z0-9]{3})$/;\n\nexport class PartyId {\n public readonly countryCode: CountryCode;\n public readonly partyCode: string;\n\n private constructor(countryCode: CountryCode, partyCode: string) {\n this.countryCode = countryCode;\n this.partyCode = partyCode;\n Object.freeze(this);\n }\n\n public static parse(raw: string): PartyId | null {\n const match = PARTY_ID_REGEX.exec(raw);\n if (!match) {\n return null;\n }\n\n try {\n const country = match[1];\n const party = match[2];\n if (country === undefined || party === undefined) {\n return null;\n }\n\n const countryCode = CountryCode.from(country);\n const partyCode = ProviderId.from(party).value;\n return new PartyId(countryCode, partyCode);\n } catch {\n return null;\n }\n }\n\n public static parseStrict(raw: string): PartyId {\n const parsed = PartyId.parse(raw);\n if (parsed === null) {\n throw new TypeError(`Invalid party ID: ${raw}`);\n }\n\n return parsed;\n }\n\n public static fromCountryAndProvider(countryCode: CountryCode, providerId: ProviderId): PartyId {\n return new PartyId(countryCode, providerId.value);\n }\n\n public static fromCountryAndOperator(\n countryCode: CountryCode,\n operatorId: OperatorIdIso,\n ): PartyId {\n return new PartyId(countryCode, operatorId.value);\n }\n\n public toCompactString(): string {\n return `${this.countryCode.toString()}${this.partyCode}`;\n }\n\n public toString(): string {\n return `${this.countryCode.toString()}-${this.partyCode}`;\n }\n}\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { checkDigitDin } from \"./check-digit-din.js\";\nimport { checkDigitIso } from \"./check-digit-iso.js\";\nimport { ContractIdStandards, type ContractIdStandard } from \"./contract-id-standard.js\";\nimport { CountryCode } from \"./country-code.js\";\nimport { PartyId } from \"./party-id.js\";\nimport { ProviderId } from \"./provider-id.js\";\n\ntype Parser = Readonly<{\n instanceRegex: RegExp;\n fullRegex: RegExp;\n name: string;\n computeCheckDigit: (value: string) => string;\n}>;\n\nconst parsers: Readonly<Record<ContractIdStandard, Parser>> = {\n ISO: {\n instanceRegex: /^([A-Za-z0-9]{9})$/,\n fullRegex:\n /^([A-Za-z]{2})(?:-?)([A-Za-z0-9]{3})(?:-?)([A-Za-z0-9]{9})(?:(?:-?)([A-Za-z0-9]))?$/,\n name: \"ISO 15118-1\",\n computeCheckDigit: checkDigitIso,\n },\n EMI3: {\n instanceRegex: /^([Cc][A-Za-z0-9]{8})$/,\n fullRegex:\n /^([A-Za-z]{2})(?:-?)([A-Za-z0-9]{3})(?:-?)([Cc][A-Za-z0-9]{8})(?:(?:-?)([A-Za-z0-9]))?$/,\n name: \"EMI3\",\n computeCheckDigit: checkDigitIso,\n },\n DIN: {\n instanceRegex: /^([A-Za-z0-9]{6})$/,\n fullRegex:\n /^([A-Za-z]{2})(?:[*-]?)([A-Za-z0-9]{3})(?:[*-]?)([A-Za-z0-9]{6})(?:(?:[*-]?)([A-Za-z0-9]))?$/,\n name: \"DIN SPEC 91286\",\n computeCheckDigit: checkDigitDin,\n },\n};\n\nexport class ContractId {\n public readonly standard: ContractIdStandard;\n public readonly countryCode: CountryCode;\n public readonly providerId: ProviderId;\n public readonly instanceValue: string;\n public readonly checkDigit: string;\n\n private constructor(\n standard: ContractIdStandard,\n countryCode: CountryCode,\n providerId: ProviderId,\n instanceValue: string,\n checkDigit: string,\n ) {\n this.standard = standard;\n this.countryCode = countryCode;\n this.providerId = providerId;\n this.instanceValue = instanceValue;\n this.checkDigit = checkDigit;\n Object.freeze(this);\n }\n\n public static fromParts(\n standard: ContractIdStandard,\n countryCode: string | CountryCode,\n providerId: string | ProviderId,\n instanceValue: string,\n checkDigit?: string,\n ): ContractId {\n const parser = parsers[standard];\n const cc = typeof countryCode === \"string\" ? CountryCode.from(countryCode) : countryCode;\n const provider = typeof providerId === \"string\" ? ProviderId.from(providerId) : providerId;\n const normalizedInstance = instanceValue.toUpperCase();\n\n if (!parser.instanceRegex.test(normalizedInstance)) {\n throw new TypeError(\n `${instanceValue} is not a valid instance value for ${parser.name} format`,\n );\n }\n\n const computed = parser.computeCheckDigit(\n `${cc.toString()}${provider.toString()}${normalizedInstance}`,\n );\n if (checkDigit !== undefined && checkDigit.toUpperCase() !== computed) {\n throw new TypeError(\n `Given check digit '${checkDigit}' is not equal to computed '${computed}'`,\n );\n }\n\n return new ContractId(standard, cc, provider, normalizedInstance, computed);\n }\n\n public static parse(standard: ContractIdStandard, raw: string): ContractId | null {\n try {\n return ContractId.parseStrict(standard, raw);\n } catch {\n return null;\n }\n }\n\n public static parseStrict(standard: ContractIdStandard, raw: string): ContractId {\n const parser = parsers[standard];\n const match = parser.fullRegex.exec(raw);\n if (!match || match[1] === undefined || match[2] === undefined || match[3] === undefined) {\n throw new TypeError(`${raw} is not a valid Contract Id for ${parser.name}`);\n }\n\n const [, country, provider, instance, check] = match;\n return ContractId.fromParts(standard, country, provider, instance, check);\n }\n\n public toCompactString(): string {\n return `${this.countryCode.toString()}${this.providerId.toString()}${this.instanceValue}${this.checkDigit}`;\n }\n\n public toCompactStringWithoutCheckDigit(): string {\n return `${this.countryCode.toString()}${this.providerId.toString()}${this.instanceValue}`;\n }\n\n public get partyId(): PartyId {\n return PartyId.fromCountryAndProvider(this.countryCode, this.providerId);\n }\n\n public convertTo(targetStandard: ContractIdStandard): ContractId {\n if (targetStandard === this.standard) {\n return this;\n }\n\n if (this.standard === ContractIdStandards.DIN && targetStandard === ContractIdStandards.EMI3) {\n return ContractId.fromParts(\n ContractIdStandards.EMI3,\n this.countryCode,\n this.providerId,\n `C0${this.instanceValue}${this.checkDigit}`,\n );\n }\n\n if (this.standard === ContractIdStandards.EMI3 && targetStandard === ContractIdStandards.DIN) {\n if (!this.instanceValue.startsWith(\"C0\")) {\n throw new TypeError(`${this.toString()} cannot be converted to ${parsers.DIN.name} format`);\n }\n\n const dinInstance = this.instanceValue.slice(2, 8);\n const dinCheck = this.instanceValue.slice(8, 9);\n return ContractId.fromParts(\n ContractIdStandards.DIN,\n this.countryCode,\n this.providerId,\n dinInstance,\n dinCheck,\n );\n }\n\n if (this.standard === ContractIdStandards.ISO && targetStandard === ContractIdStandards.DIN) {\n if (!this.instanceValue.startsWith(\"00\")) {\n throw new TypeError(`${this.toString()} cannot be converted to ${parsers.DIN.name} format`);\n }\n\n const dinInstance = this.instanceValue.slice(2, 8);\n const dinCheck = this.instanceValue.slice(8, 9);\n return ContractId.fromParts(\n ContractIdStandards.DIN,\n this.countryCode,\n this.providerId,\n dinInstance,\n dinCheck,\n );\n }\n\n if (this.standard === ContractIdStandards.DIN && targetStandard === ContractIdStandards.ISO) {\n return ContractId.fromParts(\n ContractIdStandards.ISO,\n this.countryCode,\n this.providerId,\n `00${this.instanceValue}${this.checkDigit}`,\n );\n }\n\n if (this.standard === ContractIdStandards.EMI3 && targetStandard === ContractIdStandards.ISO) {\n return ContractId.fromParts(\n ContractIdStandards.ISO,\n this.countryCode,\n this.providerId,\n this.instanceValue,\n this.checkDigit,\n );\n }\n\n if (this.standard === ContractIdStandards.ISO && targetStandard === ContractIdStandards.EMI3) {\n return ContractId.fromParts(\n ContractIdStandards.EMI3,\n this.countryCode,\n this.providerId,\n this.instanceValue,\n this.checkDigit,\n );\n }\n\n throw new TypeError(`It is not possible to convert ${this.standard} to ${targetStandard}`);\n }\n\n public toString(): string {\n return `${this.countryCode.toString()}-${this.providerId.toString()}-${this.instanceValue}-${this.checkDigit}`;\n }\n}\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isValidPartyCode } from \"./provider-id.js\";\n\nconst OPERATOR_DIN_REGEX = /^[0-9]{3,6}$/;\n\nexport class OperatorIdIso {\n public readonly value: string;\n\n private constructor(value: string) {\n this.value = value;\n Object.freeze(this);\n }\n\n public static isValid(raw: string): boolean {\n return isValidPartyCode(raw);\n }\n\n public static from(raw: string): OperatorIdIso {\n if (!OperatorIdIso.isValid(raw)) {\n throw new TypeError(\"OperatorId must have a length of 3 and be ASCII letters or digits\");\n }\n\n return new OperatorIdIso(raw.toUpperCase());\n }\n\n public static parse(raw: string): OperatorIdIso | null {\n try {\n return OperatorIdIso.from(raw);\n } catch {\n return null;\n }\n }\n\n public toString(): string {\n return this.value;\n }\n}\n\nexport class OperatorIdDin {\n public readonly value: string;\n\n private constructor(value: string) {\n this.value = value;\n Object.freeze(this);\n }\n\n public static isValid(raw: string): boolean {\n return OPERATOR_DIN_REGEX.test(raw);\n }\n\n public static from(raw: string): OperatorIdDin {\n if (!OperatorIdDin.isValid(raw)) {\n throw new TypeError(\"OperatorId must have a length of 3-6 chars and be digits\");\n }\n\n return new OperatorIdDin(raw.toUpperCase());\n }\n\n public static parse(raw: string): OperatorIdDin | null {\n try {\n return OperatorIdDin.from(raw);\n } catch {\n return null;\n }\n }\n\n public toString(): string {\n return this.value;\n }\n}\n\nexport type OperatorId = OperatorIdIso | OperatorIdDin;\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst PHONE_COUNTRY_CODE_REGEX = /^\\+?[0-9]{1,3}$/;\n\nexport class PhoneCountryCode {\n public readonly value: string;\n\n private constructor(value: string) {\n this.value = value;\n Object.freeze(this);\n }\n\n public static isValid(raw: string): boolean {\n return PHONE_COUNTRY_CODE_REGEX.test(raw);\n }\n\n public static from(raw: string): PhoneCountryCode {\n if (!PhoneCountryCode.isValid(raw)) {\n throw new TypeError(\n `phone Country Code must start with a '+' sign and be followed by 1-3 digits. (Was: ${raw})`,\n );\n }\n\n return new PhoneCountryCode(raw);\n }\n\n public static parse(raw: string): PhoneCountryCode | null {\n try {\n return PhoneCountryCode.from(raw);\n } catch {\n return null;\n }\n }\n\n public toString(): string {\n return this.value;\n }\n}\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CountryCode } from \"./country-code.js\";\nimport { OperatorIdDin, OperatorIdIso, type OperatorId } from \"./operator-id.js\";\nimport { PartyId } from \"./party-id.js\";\nimport { PhoneCountryCode } from \"./phone-country-code.js\";\n\ntype ValidationError = Readonly<{ priority: number; description: string }>;\n\nconst ISO_COUNTRY_REGEX = /^([A-Za-z]{2})$/;\nconst ISO_OPERATOR_REGEX = /^([A-Za-z0-9]{3})$/;\nconst ISO_POWER_OUTLET_REGEX = /^([A-Za-z0-9*]{1,31})$/;\nconst ISO_EVSE_REGEX = /^([A-Za-z]{2})\\*?([A-Za-z0-9]{3})\\*?E([A-Za-z0-9*]{1,31})$/;\n\nconst DIN_COUNTRY_REGEX = /^(\\+?[0-9]{1,3})$/;\nconst DIN_OPERATOR_REGEX = /^([0-9]{3,6})$/;\nconst DIN_POWER_OUTLET_REGEX = /^([0-9*]{1,32})$/;\nconst DIN_EVSE_REGEX = /^(\\+?[0-9]{1,3})\\*([0-9]{3,6})\\*([0-9*]{1,32})$/;\n\nabstract class EvseIdBase {\n public abstract readonly countryCode: CountryCode | PhoneCountryCode;\n public abstract readonly operatorId: OperatorId;\n public abstract readonly powerOutletId: string;\n\n public abstract toString(): string;\n}\n\nexport class EvseIdIso extends EvseIdBase {\n public readonly countryCode: CountryCode;\n public readonly operatorId: OperatorIdIso;\n public readonly powerOutletId: string;\n\n public constructor(countryCode: CountryCode, operatorId: OperatorIdIso, powerOutletId: string) {\n super();\n this.countryCode = countryCode;\n this.operatorId = operatorId;\n this.powerOutletId = powerOutletId;\n Object.freeze(this);\n }\n\n public static fromParts(\n countryCode: string,\n operatorId: string,\n powerOutletId: string,\n ): EvseIdIso {\n return createIso(\n countryCode.toUpperCase(),\n operatorId.toUpperCase(),\n powerOutletId.toUpperCase(),\n );\n }\n\n public static parse(raw: string): EvseIdIso | null {\n const match = ISO_EVSE_REGEX.exec(raw);\n if (!match || match[1] === undefined || match[2] === undefined || match[3] === undefined) {\n return null;\n }\n\n try {\n return createIso(match[1].toUpperCase(), match[2].toUpperCase(), match[3].toUpperCase());\n } catch {\n return null;\n }\n }\n\n public static parseStrict(raw: string): EvseIdIso {\n const parsed = EvseIdIso.parse(raw);\n if (parsed === null) {\n throw new TypeError(`Invalid ISO EVSE ID: ${raw}`);\n }\n\n return parsed;\n }\n\n public get partyId(): PartyId {\n return PartyId.fromCountryAndOperator(this.countryCode, this.operatorId);\n }\n\n public toCompactString(): string {\n return this.toString().replaceAll(\"*\", \"\");\n }\n\n public toString(): string {\n return `${this.countryCode.toString()}*${this.operatorId.toString()}*E${this.powerOutletId}`;\n }\n}\n\nexport class EvseIdDin extends EvseIdBase {\n public readonly countryCode: PhoneCountryCode;\n public readonly operatorId: OperatorIdDin;\n public readonly powerOutletId: string;\n\n public constructor(\n countryCode: PhoneCountryCode,\n operatorId: OperatorIdDin,\n powerOutletId: string,\n ) {\n super();\n this.countryCode = countryCode;\n this.operatorId = operatorId;\n this.powerOutletId = powerOutletId;\n Object.freeze(this);\n }\n\n public static fromParts(\n countryCode: string,\n operatorId: string,\n powerOutletId: string,\n ): EvseIdDin {\n return createDin(\n countryCode.toUpperCase(),\n operatorId.toUpperCase(),\n powerOutletId.toUpperCase(),\n );\n }\n\n public static parse(raw: string): EvseIdDin | null {\n const match = DIN_EVSE_REGEX.exec(raw);\n if (!match || match[1] === undefined || match[2] === undefined || match[3] === undefined) {\n return null;\n }\n\n try {\n return createDin(match[1].toUpperCase(), match[2].toUpperCase(), match[3].toUpperCase());\n } catch {\n return null;\n }\n }\n\n public static parseStrict(raw: string): EvseIdDin {\n const parsed = EvseIdDin.parse(raw);\n if (parsed === null) {\n throw new TypeError(`Invalid DIN EVSE ID: ${raw}`);\n }\n\n return parsed;\n }\n\n public toString(): string {\n return `${this.countryCode.toString()}*${this.operatorId.toString()}*${this.powerOutletId}`;\n }\n}\n\nfunction validateIso(\n countryCode: string,\n operatorId: string,\n powerOutletId: string,\n): ValidationError | null {\n if (!ISO_COUNTRY_REGEX.test(countryCode)) {\n return { priority: 1, description: \"Invalid countryCode for ISO or DIN format\" };\n }\n if (!ISO_OPERATOR_REGEX.test(operatorId)) {\n return { priority: 2, description: \"Invalid operatorId for ISO format\" };\n }\n if (!ISO_POWER_OUTLET_REGEX.test(powerOutletId)) {\n return { priority: 3, description: \"Invalid powerOutletId for ISO format\" };\n }\n\n return null;\n}\n\nfunction validateDin(\n countryCode: string,\n operatorId: string,\n powerOutletId: string,\n): ValidationError | null {\n if (!DIN_COUNTRY_REGEX.test(countryCode)) {\n return { priority: 1, description: \"Invalid countryCode for ISO or DIN format\" };\n }\n if (!DIN_OPERATOR_REGEX.test(operatorId)) {\n return { priority: 2, description: \"Invalid operatorId for DIN format\" };\n }\n if (!DIN_POWER_OUTLET_REGEX.test(powerOutletId)) {\n return { priority: 3, description: \"Invalid powerOutletId for DIN format\" };\n }\n\n return null;\n}\n\nfunction createIso(countryCode: string, operatorId: string, powerOutletId: string): EvseIdIso {\n const country = CountryCode.from(countryCode);\n const operator = OperatorIdIso.from(operatorId);\n const normalizedPowerOutletId = powerOutletId.startsWith(\"E\")\n ? powerOutletId.slice(1)\n : powerOutletId;\n return new EvseIdIso(country, operator, normalizedPowerOutletId);\n}\n\nfunction createDin(countryCode: string, operatorId: string, powerOutletId: string): EvseIdDin {\n const countryWithPlus = countryCode.startsWith(\"+\") ? countryCode : `+${countryCode}`;\n const country = PhoneCountryCode.from(countryWithPlus);\n const operator = OperatorIdDin.from(operatorId);\n return new EvseIdDin(country, operator, powerOutletId);\n}\n\nexport type EvseId = EvseIdIso | EvseIdDin;\n\nexport const EvseId = {\n fromParts(countryCode: string, operatorId: string, powerOutletId: string): EvseId {\n const normalizedCountry = countryCode.toUpperCase();\n const normalizedOperator = operatorId.toUpperCase();\n const normalizedPowerOutlet = powerOutletId.toUpperCase();\n\n const isoError = validateIso(normalizedCountry, normalizedOperator, normalizedPowerOutlet);\n if (isoError === null) {\n return createIso(normalizedCountry, normalizedOperator, normalizedPowerOutlet);\n }\n\n const dinError = validateDin(normalizedCountry, normalizedOperator, normalizedPowerOutlet);\n if (dinError === null) {\n return createDin(normalizedCountry, normalizedOperator, normalizedPowerOutlet);\n }\n\n if (isoError.priority >= dinError.priority) {\n throw new TypeError(isoError.description);\n }\n\n throw new TypeError(dinError.description);\n },\n\n parse(raw: string): EvseId | null {\n const iso = EvseIdIso.parse(raw);\n if (iso !== null) {\n return iso;\n }\n\n return EvseIdDin.parse(raw);\n },\n\n parseStrict(raw: string): EvseId {\n const parsed = this.parse(raw);\n if (parsed === null) {\n throw new TypeError(`Invalid EVSE ID: ${raw}`);\n }\n\n return parsed;\n },\n};\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ContractId } from \"./contract-id.js\";\nimport { ContractIdStandards } from \"./contract-id-standard.js\";\nimport { CountryCode } from \"./country-code.js\";\nimport { EvseId, EvseIdDin, EvseIdIso } from \"./evse-id.js\";\nimport { OperatorIdDin, OperatorIdIso } from \"./operator-id.js\";\nimport { PartyId } from \"./party-id.js\";\nimport { PhoneCountryCode } from \"./phone-country-code.js\";\nimport { ProviderId } from \"./provider-id.js\";\n\nexport const MobilityIdParsers = {\n parseCountryCode(raw: string): CountryCode | null {\n return CountryCode.parse(raw);\n },\n\n parsePhoneCountryCode(raw: string): PhoneCountryCode | null {\n return PhoneCountryCode.parse(raw);\n },\n\n parseProviderId(raw: string): ProviderId | null {\n return ProviderId.parse(raw);\n },\n\n parseOperatorIdIso(raw: string): OperatorIdIso | null {\n return OperatorIdIso.parse(raw);\n },\n\n parseOperatorIdDin(raw: string): OperatorIdDin | null {\n return OperatorIdDin.parse(raw);\n },\n\n parsePartyId(raw: string): PartyId | null {\n return PartyId.parse(raw);\n },\n\n parseContractIdIso(raw: string): ContractId | null {\n return ContractId.parse(ContractIdStandards.ISO, raw);\n },\n\n parseContractIdDin(raw: string): ContractId | null {\n return ContractId.parse(ContractIdStandards.DIN, raw);\n },\n\n parseContractIdEmi3(raw: string): ContractId | null {\n return ContractId.parse(ContractIdStandards.EMI3, raw);\n },\n\n parseEvseId(raw: string): EvseId | null {\n return EvseId.parse(raw);\n },\n\n parseEvseIdIso(raw: string): EvseIdIso | null {\n return EvseIdIso.parse(raw);\n },\n\n parseEvseIdDin(raw: string): EvseIdDin | null {\n return EvseIdDin.parse(raw);\n },\n};\n"],"mappings":";AAiBA,MAAM,yBAAS,IAAI,KAAqB;AAExC,KAAK,IAAI,QAAQ,GAAG,SAAS,GAAG,SAAS,EACvC,QAAO,IAAI,OAAO,MAAM,EAAE,MAAM;AAGlC,KAAK,IAAI,QAAQ,GAAG,QAAQ,IAAI,SAAS,EACvC,QAAO,IAAI,OAAO,aAAa,IAAI,WAAW,EAAE,GAAG,MAAM,EAAE,KAAK,MAAM;AAGxE,SAAgB,cAAc,MAAsB;CAClD,MAAM,aAAa,KAAK,aAAa;CACrC,MAAM,SAAS,MAAM,KAAK,aAAa,SAAS;EAC9C,MAAM,QAAQ,OAAO,IAAI,KAAK;AAC9B,MAAI,UAAU,KAAA,EACZ,OAAM,IAAI,UACR,sBAAsB,KAAK,aAAa,KAAK,uDAC9C;AAGH,SAAO;GACP;CAEF,IAAI,MAAM;CACV,IAAI,cAAc;AAElB,MAAK,MAAM,WAAW,QAAQ;AAC5B,MAAI,UAAU,IAAI;AAChB,UAAO,UAAU,KAAK;AACtB,kBAAe;AACf;;AAGF,SAAO,KAAK,MAAM,UAAU,GAAG,GAAG,KAAK,cAAe,UAAU,KAAM,MAAM,cAAc;AAC1F,iBAAe;;CAGjB,MAAM,MAAM,MAAM;AAElB,KAAI,OAAO,GACT,QAAO;AAGT,QAAO,OAA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;;CAG9B,mBAAmB,KAAmC;AACpD,SAAO,cAAc,MAAM,IAAI;;CAGjC,mBAAmB,KAAmC;AACpD,SAAO,cAAc,MAAM,IAAI;;CAGjC,aAAa,KAA6B;AACxC,SAAO,QAAQ,MAAM,IAAI;;CAG3B,mBAAmB,KAAgC;AACjD,SAAO,WAAW,MAAM,oBAAoB,KAAK,IAAI;;CAGvD,mBAAmB,KAAgC;AACjD,SAAO,WAAW,MAAM,oBAAoB,KAAK,IAAI;;CAGvD,oBAAoB,KAAgC;AAClD,SAAO,WAAW,MAAM,oBAAoB,MAAM,IAAI;;CAGxD,YAAY,KAA4B;AACtC,SAAO,OAAO,MAAM,IAAI;;CAG1B,eAAe,KAA+B;AAC5C,SAAO,UAAU,MAAM,IAAI;;CAG7B,eAAe,KAA+B;AAC5C,SAAO,UAAU,MAAM,IAAI;;CAE9B"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/ascii.ts","../src/parse-result.ts","../src/check-digit-din.ts","../src/check-digit-iso.ts","../src/contract-id-standard.ts","../src/iso3166-alpha2.ts","../src/string-id.ts","../src/country-code.ts","../src/provider-id.ts","../src/party-id.ts","../src/separator-policy.ts","../src/contract-id.ts","../src/operator-id.ts","../src/phone-country-code.ts","../src/evse-id.ts","../src/parsers.ts"],"sourcesContent":["/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Uppercases ASCII letters only. `String.prototype.toUpperCase` also maps some non-ASCII letters\n * to ASCII ones ('ſ' U+017F to 'S', 'ı' U+0131 to 'I'), which would let the ASCII-only patterns\n * accept them; every factory and parser normalizes through this function instead, like the\n * other ports.\n */\nexport function asciiUpperCase(value: string): string {\n return value.replace(/[a-z]+/g, (letters) => letters.toUpperCase());\n}\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Machine-readable reason of a parse failure, stable across releases: count failures or report\n * a broken record on it, show `error` to humans. A component code is given only when the failing\n * component can be told apart reliably; anything else is `format`. The codes check structure\n * and the standards' tables (ISO 3166-1), never real-world registrations.\n *\n * - `format`: the overall shape is not recognized, or the failing part cannot be told apart.\n * - `country-code`: ISO 3166-1 alpha-2 country code.\n * - `phone-country-code`: DIN phone country code.\n * - `provider-id`: provider id of a contract id, party code of a party id.\n * - `operator-id`: operator id of an EVSE id (ISO or DIN).\n * - `id-type`: ISO EVSE id without the `E` id type in front of the power outlet id.\n * - `power-outlet-id`: power outlet id of an EVSE id.\n * - `instance`: instance value of a contract id.\n * - `check-digit`: check digit of a contract id differs from the computed one.\n * - `unconvertible`: a contract id cannot be converted to the requested standard.\n */\nexport type ParseFailureReason =\n | \"format\"\n | \"country-code\"\n | \"phone-country-code\"\n | \"provider-id\"\n | \"operator-id\"\n | \"id-type\"\n | \"power-outlet-id\"\n | \"instance\"\n | \"check-digit\"\n | \"unconvertible\";\n\n/**\n * Thrown by the strict factories and parsers when the input is not a valid identifier. It extends\n * `TypeError` for compatibility with callers that catch `TypeError`; `attempt` captures exactly\n * this class so that a genuine programming `TypeError` (`undefined is not a function`) is never\n * mistaken for an invalid input. `reason` is the code `tryParse` reports.\n */\nexport class ValidationError extends TypeError {\n public readonly reason: ParseFailureReason;\n\n public constructor(message: string, reason: ParseFailureReason = \"format\") {\n super(message);\n this.name = \"ValidationError\";\n this.reason = reason;\n }\n}\n\n/**\n * Outcome of a `tryParse` call: the parsed value, or the message and reason code the strict\n * parser would have thrown. Narrow on `ok`; both variants are frozen like the domain objects.\n */\nexport type ParseResult<T> =\n | Readonly<{ ok: true; value: T }>\n | Readonly<{ ok: false; error: string; reason: ParseFailureReason }>;\n\nexport function success<T>(value: T): ParseResult<T> {\n return Object.freeze({ ok: true, value });\n}\n\nexport function failure<T>(error: string, reason: ParseFailureReason): ParseResult<T> {\n return Object.freeze({ ok: false, error, reason });\n}\n\n/** Collapses a `ParseResult` to the tolerant contract: the value, or `null` on failure. */\nexport function valueOrNull<T>(result: ParseResult<T>): T | null {\n return result.ok ? result.value : null;\n}\n\n/**\n * Runs a strict parser and captures its `ValidationError` as a failure. Any other error, a plain\n * `TypeError` included, is a bug rather than an invalid input and keeps propagating.\n */\nexport function attempt<T>(parse: () => T): ParseResult<T> {\n try {\n return success(parse());\n } catch (error) {\n if (error instanceof ValidationError) {\n return failure(error.message, error.reason);\n }\n throw error;\n }\n}\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { asciiUpperCase } from \"./ascii.js\";\nimport { ValidationError } from \"./parse-result.js\";\n\nconst values = new Map<string, number>();\n\nfor (let index = 0; index <= 9; index += 1) {\n values.set(String(index), index);\n}\n\nfor (let index = 0; index < 26; index += 1) {\n values.set(String.fromCharCode(\"A\".charCodeAt(0) + index), 10 + index);\n}\n\nexport function checkDigitDin(code: string): string {\n const normalized = asciiUpperCase(code);\n const lookup = Array.from(normalized, (char) => {\n const value = values.get(char);\n if (value === undefined) {\n throw new ValidationError(\n `invalid character '${char}' in code '${code}'; must consist of uppercase ASCII letters and digits`,\n );\n }\n\n return value;\n });\n\n let sum = 0;\n let coefficient = 0;\n\n for (const current of lookup) {\n if (current < 10) {\n sum += current * 2 ** coefficient;\n coefficient += 1;\n continue;\n }\n\n sum += Math.floor(current / 10) * 2 ** coefficient + (current % 10) * 2 ** (coefficient + 1);\n coefficient += 2;\n }\n\n const mod = sum % 11;\n\n if (mod >= 10) {\n return \"X\";\n }\n\n return String(mod);\n}\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { asciiUpperCase } from \"./ascii.js\";\nimport { ValidationError } from \"./parse-result.js\";\n\ntype Matrix = Readonly<{ m11: number; m12: number; m21: number; m22: number }>;\ntype Vec = Readonly<{ v1: number; v2: number }>;\n\nconst checkDigitInputRegex = /^[A-Z0-9]+$/;\n\nconst matrixKey = (m: Matrix): string => `${m.m11},${m.m12},${m.m21},${m.m22}`;\n\nconst multiplyMatrix = (a: Matrix, b: Matrix): Matrix => ({\n m11: a.m11 * b.m11 + a.m12 * b.m21,\n m12: a.m11 * b.m12 + a.m12 * b.m22,\n m21: a.m21 * b.m11 + a.m22 * b.m21,\n m22: a.m21 * b.m12 + a.m22 * b.m22,\n});\n\nconst addVec = (a: Vec, b: Vec): Vec => ({\n v1: a.v1 + b.v1,\n v2: a.v2 + b.v2,\n});\n\nconst multiplyVec = (v: Vec, m: Matrix): Vec => ({\n v1: v.v1 * m.m11 + v.v2 * m.m21,\n v2: v.v1 * m.m12 + v.v2 * m.m22,\n});\n\nconst decodeMatrix = (x: number): Matrix => ({\n m11: x & 1,\n m12: (x >> 1) & 1,\n m21: (x >> 2) & 3,\n m22: x >> 4,\n});\n\nconst encodingValues: Readonly<Record<string, number>> = {\n \"0\": 0,\n \"1\": 16,\n \"2\": 32,\n \"3\": 4,\n \"4\": 20,\n \"5\": 36,\n \"6\": 8,\n \"7\": 24,\n \"8\": 40,\n \"9\": 2,\n A: 18,\n B: 34,\n C: 6,\n D: 22,\n E: 38,\n F: 10,\n G: 26,\n H: 42,\n I: 1,\n J: 17,\n K: 33,\n L: 5,\n M: 21,\n N: 37,\n O: 9,\n P: 25,\n Q: 41,\n R: 3,\n S: 19,\n T: 35,\n U: 7,\n V: 23,\n W: 39,\n X: 11,\n Y: 27,\n Z: 43,\n};\n\nconst encoding = new Map<string, Matrix>();\nconst decoding = new Map<string, string>();\n\nfor (const [char, value] of Object.entries(encodingValues)) {\n const matrix = decodeMatrix(value);\n encoding.set(char, matrix);\n decoding.set(matrixKey(matrix), char);\n}\n\nconst p1: Matrix = { m11: 0, m12: 1, m21: 1, m22: 1 };\nconst p2: Matrix = { m11: 0, m12: 1, m21: 1, m22: 2 };\n\nconst p1s: Matrix[] = [];\nconst p2s: Matrix[] = [];\n\nlet currentP1 = p1;\nlet currentP2 = p2;\nfor (let index = 0; index < 14; index += 1) {\n p1s.push(currentP1);\n p2s.push(currentP2);\n currentP1 = multiplyMatrix(currentP1, p1);\n currentP2 = multiplyMatrix(currentP2, p2);\n}\n\nconst negP2minus15: Matrix = { m11: 0, m12: 2, m21: 2, m22: 1 };\n\nexport function checkDigitIso(code: string): string {\n const normalized = asciiUpperCase(code);\n\n if (normalized.length !== p1s.length || normalized.length !== p2s.length) {\n throw new ValidationError(`Code must have a length of ${p1s.length}`);\n }\n\n if (!checkDigitInputRegex.test(normalized)) {\n throw new ValidationError(\"Code must consist of uppercase ASCII letters and digits\");\n }\n\n const sumEq = (matrices: Matrix[], toVec: (matrix: Matrix) => Vec): Vec => {\n let value: Vec = { v1: 0, v2: 0 };\n\n for (let index = 0; index < matrices.length; index += 1) {\n const character = normalized.charAt(index);\n const matrix = encoding.get(character);\n if (!matrix) {\n throw new ValidationError(`Invalid character: ${character}.`);\n }\n\n const positionMatrix = matrices[index];\n if (!positionMatrix) {\n throw new Error(`Missing matrix at index: ${index}.`);\n }\n\n const qr = toVec(matrix);\n value = addVec(value, multiplyVec(qr, positionMatrix));\n }\n\n return value;\n };\n\n const t1 = sumEq(p1s, (matrix) => ({ v1: matrix.m11, v2: matrix.m12 }));\n const t2 = multiplyVec(\n sumEq(p2s, (matrix) => ({ v1: matrix.m21, v2: matrix.m22 })),\n negP2minus15,\n );\n\n const m15: Matrix = {\n m11: t1.v1 & 1,\n m12: t1.v2 & 1,\n m21: t2.v1 % 3,\n m22: t2.v2 % 3,\n };\n\n const decoded = decoding.get(matrixKey(m15));\n if (!decoded) {\n throw new Error(`Undecodable matrix: ${matrixKey(m15)}.`);\n }\n\n return decoded;\n}\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ContractIdStandards = {\n ISO: \"ISO\",\n EMI3: \"EMI3\",\n DIN: \"DIN\",\n} as const;\n\nexport type ContractIdStandard = (typeof ContractIdStandards)[keyof typeof ContractIdStandards];\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Code generated by scripts/generate-iso3166.sh; DO NOT EDIT.\n\n/**\n * The 249 ISO 3166-1 alpha-2 codes returned by the JDK's `Locale.getISOCountries()`, the\n * reference the Scala library validates country codes against. Sorted.\n */\nexport const ISO_3166_ALPHA2 = [\n \"AD\",\n \"AE\",\n \"AF\",\n \"AG\",\n \"AI\",\n \"AL\",\n \"AM\",\n \"AO\",\n \"AQ\",\n \"AR\",\n \"AS\",\n \"AT\",\n \"AU\",\n \"AW\",\n \"AX\",\n \"AZ\",\n \"BA\",\n \"BB\",\n \"BD\",\n \"BE\",\n \"BF\",\n \"BG\",\n \"BH\",\n \"BI\",\n \"BJ\",\n \"BL\",\n \"BM\",\n \"BN\",\n \"BO\",\n \"BQ\",\n \"BR\",\n \"BS\",\n \"BT\",\n \"BV\",\n \"BW\",\n \"BY\",\n \"BZ\",\n \"CA\",\n \"CC\",\n \"CD\",\n \"CF\",\n \"CG\",\n \"CH\",\n \"CI\",\n \"CK\",\n \"CL\",\n \"CM\",\n \"CN\",\n \"CO\",\n \"CR\",\n \"CU\",\n \"CV\",\n \"CW\",\n \"CX\",\n \"CY\",\n \"CZ\",\n \"DE\",\n \"DJ\",\n \"DK\",\n \"DM\",\n \"DO\",\n \"DZ\",\n \"EC\",\n \"EE\",\n \"EG\",\n \"EH\",\n \"ER\",\n \"ES\",\n \"ET\",\n \"FI\",\n \"FJ\",\n \"FK\",\n \"FM\",\n \"FO\",\n \"FR\",\n \"GA\",\n \"GB\",\n \"GD\",\n \"GE\",\n \"GF\",\n \"GG\",\n \"GH\",\n \"GI\",\n \"GL\",\n \"GM\",\n \"GN\",\n \"GP\",\n \"GQ\",\n \"GR\",\n \"GS\",\n \"GT\",\n \"GU\",\n \"GW\",\n \"GY\",\n \"HK\",\n \"HM\",\n \"HN\",\n \"HR\",\n \"HT\",\n \"HU\",\n \"ID\",\n \"IE\",\n \"IL\",\n \"IM\",\n \"IN\",\n \"IO\",\n \"IQ\",\n \"IR\",\n \"IS\",\n \"IT\",\n \"JE\",\n \"JM\",\n \"JO\",\n \"JP\",\n \"KE\",\n \"KG\",\n \"KH\",\n \"KI\",\n \"KM\",\n \"KN\",\n \"KP\",\n \"KR\",\n \"KW\",\n \"KY\",\n \"KZ\",\n \"LA\",\n \"LB\",\n \"LC\",\n \"LI\",\n \"LK\",\n \"LR\",\n \"LS\",\n \"LT\",\n \"LU\",\n \"LV\",\n \"LY\",\n \"MA\",\n \"MC\",\n \"MD\",\n \"ME\",\n \"MF\",\n \"MG\",\n \"MH\",\n \"MK\",\n \"ML\",\n \"MM\",\n \"MN\",\n \"MO\",\n \"MP\",\n \"MQ\",\n \"MR\",\n \"MS\",\n \"MT\",\n \"MU\",\n \"MV\",\n \"MW\",\n \"MX\",\n \"MY\",\n \"MZ\",\n \"NA\",\n \"NC\",\n \"NE\",\n \"NF\",\n \"NG\",\n \"NI\",\n \"NL\",\n \"NO\",\n \"NP\",\n \"NR\",\n \"NU\",\n \"NZ\",\n \"OM\",\n \"PA\",\n \"PE\",\n \"PF\",\n \"PG\",\n \"PH\",\n \"PK\",\n \"PL\",\n \"PM\",\n \"PN\",\n \"PR\",\n \"PS\",\n \"PT\",\n \"PW\",\n \"PY\",\n \"QA\",\n \"RE\",\n \"RO\",\n \"RS\",\n \"RU\",\n \"RW\",\n \"SA\",\n \"SB\",\n \"SC\",\n \"SD\",\n \"SE\",\n \"SG\",\n \"SH\",\n \"SI\",\n \"SJ\",\n \"SK\",\n \"SL\",\n \"SM\",\n \"SN\",\n \"SO\",\n \"SR\",\n \"SS\",\n \"ST\",\n \"SV\",\n \"SX\",\n \"SY\",\n \"SZ\",\n \"TC\",\n \"TD\",\n \"TF\",\n \"TG\",\n \"TH\",\n \"TJ\",\n \"TK\",\n \"TL\",\n \"TM\",\n \"TN\",\n \"TO\",\n \"TR\",\n \"TT\",\n \"TV\",\n \"TW\",\n \"TZ\",\n \"UA\",\n \"UG\",\n \"UM\",\n \"US\",\n \"UY\",\n \"UZ\",\n \"VA\",\n \"VC\",\n \"VE\",\n \"VG\",\n \"VI\",\n \"VN\",\n \"VU\",\n \"WF\",\n \"WS\",\n \"YE\",\n \"YT\",\n \"ZA\",\n \"ZM\",\n \"ZW\",\n] as const;\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { asciiUpperCase } from \"./ascii.js\";\nimport {\n type ParseFailureReason,\n type ParseResult,\n ValidationError,\n attempt,\n valueOrNull,\n} from \"./parse-result.js\";\n\ndeclare const brand: unique symbol;\n\n/**\n * Branded string for an open set of values: a `StringId<\"ProviderId\">` is a plain string at\n * runtime that only the `ProviderId` factory can produce at the type level. The symbol is never\n * assigned; it exists only in the type system, so a branded value costs nothing over the\n * underlying string. A closed set (`CountryCode`) uses a literal union instead and only shares\n * the companion below.\n */\nexport type StringId<B extends string> = string & { readonly [brand]: B };\n\n/** Validation rule of a string identifier: the predicate, the `ValidationError` message and reason. */\nexport type StringIdSpec = Readonly<{\n isValid: (raw: string) => boolean;\n message: (raw: string) => string;\n reason: ParseFailureReason;\n}>;\n\n/**\n * The three parsing entry points of a single-valued identifier plus its predicate. `from` is\n * strict and throws `ValidationError`; `tryParse` and `parse` are derived from it.\n */\nexport type StringIdCompanion<T extends string> = Readonly<{\n isValid(raw: string): boolean;\n from(raw: string): T;\n tryParse(raw: string): ParseResult<T>;\n parse(raw: string): T | null;\n}>;\n\n/**\n * Builds the companion of a string identifier (branded or literal union). Valid input is\n * normalized to uppercase (a no-op for the digit-only identifiers); `isValid` stays a boolean\n * rather than a type guard because it accepts the non-normalized input that `from` still has to\n * uppercase.\n */\nexport function defineStringId<T extends string>(spec: StringIdSpec): StringIdCompanion<T> {\n const from = (raw: string): T => {\n if (!spec.isValid(raw)) {\n throw new ValidationError(spec.message(raw), spec.reason);\n }\n\n return asciiUpperCase(raw) as T;\n };\n const tryParse = (raw: string): ParseResult<T> => attempt(() => from(raw));\n const parse = (raw: string): T | null => valueOrNull(tryParse(raw));\n\n return Object.freeze({ isValid: spec.isValid, from, tryParse, parse });\n}\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { asciiUpperCase } from \"./ascii.js\";\nimport { ISO_3166_ALPHA2 } from \"./iso3166-alpha2.js\";\nimport { type StringIdCompanion, defineStringId } from \"./string-id.js\";\n\nconst COUNTRY_CODE_REGEX = /^[A-Za-z]{2}$/;\n\nconst KNOWN_CODES: ReadonlySet<string> = new Set(ISO_3166_ALPHA2);\n\n// A literal union rather than a brand: the set is closed and published, so known literals\n// type-check directly and a switch over codes is exhaustiveness-checkable. Lowercase literals do\n// not type-check, but `CountryCode.from` still normalizes them: external input goes through it.\nexport type CountryCode = (typeof ISO_3166_ALPHA2)[number];\n\nexport const CountryCode: StringIdCompanion<CountryCode> = defineStringId({\n isValid: (raw) => COUNTRY_CODE_REGEX.test(raw) && KNOWN_CODES.has(asciiUpperCase(raw)),\n message: () => \"Country Code must be valid according to ISO 3166-1 alpha-2\",\n reason: \"country-code\",\n});\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n type StringId,\n type StringIdCompanion,\n type StringIdSpec,\n defineStringId,\n} from \"./string-id.js\";\n\nconst PARTY_CODE_REGEX = /^[A-Za-z0-9]{3}$/;\n\n/**\n * Shared by `ProviderId` and `OperatorIdIso`: both are the 3-character party code of a party id.\n * The message names `OperatorId` for both on purpose: it is the wording of the Scala reference\n * (`PartyCode` in `basicIdentifiers.scala`, also shared by its two identifiers) and of the Java\n * port, kept for cross-port parity of the error contract. The reason is `provider-id`;\n * `OperatorIdIso` overrides it with `operator-id`.\n */\nexport const partyCodeSpec: StringIdSpec = {\n isValid: (raw) => PARTY_CODE_REGEX.test(raw),\n message: () => \"OperatorId must have a length of 3 and be ASCII letters or digits\",\n reason: \"provider-id\",\n};\n\nexport type ProviderId = StringId<\"ProviderId\">;\n\nexport const ProviderId: StringIdCompanion<ProviderId> = defineStringId(partyCodeSpec);\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CountryCode } from \"./country-code.js\";\nimport type { OperatorIdIso } from \"./operator-id.js\";\nimport { type ParseResult, ValidationError, attempt, valueOrNull } from \"./parse-result.js\";\nimport { ProviderId } from \"./provider-id.js\";\n\nconst PARTY_ID_REGEX = /^([A-Za-z]{2})[-*]?([A-Za-z0-9]{3})$/;\n\nexport class PartyId {\n public readonly countryCode: CountryCode;\n public readonly partyCode: string;\n\n private constructor(countryCode: CountryCode, partyCode: string) {\n this.countryCode = countryCode;\n this.partyCode = partyCode;\n Object.freeze(this);\n }\n\n public static tryParse(raw: string): ParseResult<PartyId> {\n return attempt(() => PartyId.parseStrict(raw));\n }\n\n public static parse(raw: string): PartyId | null {\n return valueOrNull(PartyId.tryParse(raw));\n }\n\n public static parseStrict(raw: string): PartyId {\n const match = PARTY_ID_REGEX.exec(raw);\n const country = match?.[1];\n const party = match?.[2];\n if (country === undefined || party === undefined) {\n throw new ValidationError(`Invalid party ID: ${raw}`);\n }\n\n return new PartyId(CountryCode.from(country), ProviderId.from(party));\n }\n\n public static fromCountryAndProvider(countryCode: CountryCode, providerId: ProviderId): PartyId {\n return new PartyId(countryCode, providerId);\n }\n\n public static fromCountryAndOperator(\n countryCode: CountryCode,\n operatorId: OperatorIdIso,\n ): PartyId {\n return new PartyId(countryCode, operatorId);\n }\n\n public toCompactString(): string {\n return `${this.countryCode}${this.partyCode}`;\n }\n\n public toString(): string {\n return `${this.countryCode}-${this.partyCode}`;\n }\n}\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * How strictly `ContractId` parsing treats the optional separators between country code,\n * provider id, instance and check digit. A rejected input fails with the `format` reason.\n *\n * - `LENIENT`: any combination of separators the standard's format allows.\n * - `CONSISTENT`: no separator at all, or the same separator at every position (the default).\n * - `COMPACT`: no separator at all.\n */\nexport const SeparatorPolicies = {\n LENIENT: \"LENIENT\",\n CONSISTENT: \"CONSISTENT\",\n COMPACT: \"COMPACT\",\n} as const;\n\nexport type SeparatorPolicy = (typeof SeparatorPolicies)[keyof typeof SeparatorPolicies];\n\n/**\n * Whether the separators of `raw`, an input the full pattern of its standard already matched,\n * follow a policy; `positions` is 3 when a check digit was given, 2 otherwise.\n *\n * @internal\n */\nexport type SeparatorRule = (raw: string, positions: number) => boolean;\n\nconst separatorsOf = (raw: string): string => raw.replace(/[A-Za-z0-9]/g, \"\");\n\nconst rules: Readonly<Record<SeparatorPolicy, SeparatorRule>> = {\n LENIENT: () => true,\n // The same separator at every position, or none.\n CONSISTENT: (raw, positions) => {\n const separators = separatorsOf(raw);\n return separators.length === 0 || separators === separators.charAt(0).repeat(positions);\n },\n COMPACT: (raw) => separatorsOf(raw).length === 0,\n};\n\n/**\n * The rule of `policy`; an unknown policy is a programming error and throws a plain `TypeError`\n * (not a `ValidationError`), so callers resolve it before parsing anything.\n *\n * @internal\n */\nexport function separatorRule(policy: SeparatorPolicy): SeparatorRule {\n if (!Object.hasOwn(rules, policy)) {\n throw new TypeError(`Unknown separator policy ${String(policy)}`);\n }\n return rules[policy];\n}\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { asciiUpperCase } from \"./ascii.js\";\nimport { checkDigitDin } from \"./check-digit-din.js\";\nimport { checkDigitIso } from \"./check-digit-iso.js\";\nimport { ContractIdStandards, type ContractIdStandard } from \"./contract-id-standard.js\";\nimport { CountryCode } from \"./country-code.js\";\nimport { type ParseResult, ValidationError, attempt, valueOrNull } from \"./parse-result.js\";\nimport { PartyId } from \"./party-id.js\";\nimport { ProviderId } from \"./provider-id.js\";\nimport { SeparatorPolicies, type SeparatorPolicy, separatorRule } from \"./separator-policy.js\";\n\ntype Parser = Readonly<{\n instanceRegex: RegExp;\n fullRegex: RegExp;\n name: string;\n computeCheckDigit: (value: string) => string;\n}>;\n\nconst parsers: Readonly<Record<ContractIdStandard, Parser>> = {\n ISO: {\n instanceRegex: /^([A-Za-z0-9]{9})$/,\n fullRegex:\n /^([A-Za-z]{2})(?:-?)([A-Za-z0-9]{3})(?:-?)([A-Za-z0-9]{9})(?:(?:-?)([A-Za-z0-9]))?$/,\n name: \"ISO 15118-1\",\n computeCheckDigit: checkDigitIso,\n },\n EMI3: {\n instanceRegex: /^([Cc][A-Za-z0-9]{8})$/,\n fullRegex:\n /^([A-Za-z]{2})(?:-?)([A-Za-z0-9]{3})(?:-?)([Cc][A-Za-z0-9]{8})(?:(?:-?)([A-Za-z0-9]))?$/,\n name: \"EMI3\",\n computeCheckDigit: checkDigitIso,\n },\n DIN: {\n instanceRegex: /^([A-Za-z0-9]{6})$/,\n fullRegex:\n /^([A-Za-z]{2})(?:[*-]?)([A-Za-z0-9]{3})(?:[*-]?)([A-Za-z0-9]{6})(?:(?:[*-]?)([A-Za-z0-9]))?$/,\n name: \"DIN SPEC 91286\",\n computeCheckDigit: checkDigitDin,\n },\n};\n\nexport class ContractId {\n public readonly standard: ContractIdStandard;\n public readonly countryCode: CountryCode;\n public readonly providerId: ProviderId;\n public readonly instanceValue: string;\n public readonly checkDigit: string;\n\n private constructor(\n standard: ContractIdStandard,\n countryCode: CountryCode,\n providerId: ProviderId,\n instanceValue: string,\n checkDigit: string,\n ) {\n this.standard = standard;\n this.countryCode = countryCode;\n this.providerId = providerId;\n this.instanceValue = instanceValue;\n this.checkDigit = checkDigit;\n Object.freeze(this);\n }\n\n public static fromParts(\n standard: ContractIdStandard,\n countryCode: string,\n providerId: string,\n instanceValue: string,\n checkDigit?: string,\n ): ContractId {\n const parser = parsers[standard];\n const cc = CountryCode.from(countryCode);\n const provider = ProviderId.from(providerId);\n const normalizedInstance = asciiUpperCase(instanceValue);\n\n if (!parser.instanceRegex.test(normalizedInstance)) {\n throw new ValidationError(\n `${instanceValue} is not a valid instance value for ${parser.name} format`,\n \"instance\",\n );\n }\n\n const computed = parser.computeCheckDigit(`${cc}${provider}${normalizedInstance}`);\n if (checkDigit !== undefined && asciiUpperCase(checkDigit) !== computed) {\n throw new ValidationError(\n `Given check digit '${checkDigit}' is not equal to computed '${computed}'`,\n \"check-digit\",\n );\n }\n\n return new ContractId(standard, cc, provider, normalizedInstance, computed);\n }\n\n public static tryParse(\n standard: ContractIdStandard,\n raw: string,\n policy: SeparatorPolicy = SeparatorPolicies.CONSISTENT,\n ): ParseResult<ContractId> {\n return attempt(() => ContractId.parseStrict(standard, raw, policy));\n }\n\n public static parse(\n standard: ContractIdStandard,\n raw: string,\n policy: SeparatorPolicy = SeparatorPolicies.CONSISTENT,\n ): ContractId | null {\n return valueOrNull(ContractId.tryParse(standard, raw, policy));\n }\n\n /**\n * Parses `raw` under `standard`, then rejects its separators with the `format` reason when they\n * break `policy` (default `CONSISTENT`). An unknown policy throws a plain `TypeError` before any\n * parsing.\n */\n public static parseStrict(\n standard: ContractIdStandard,\n raw: string,\n policy: SeparatorPolicy = SeparatorPolicies.CONSISTENT,\n ): ContractId {\n const followsPolicy = separatorRule(policy);\n const parser = parsers[standard];\n const match = parser.fullRegex.exec(raw);\n if (!match || match[1] === undefined || match[2] === undefined || match[3] === undefined) {\n throw new ValidationError(`${raw} is not a valid Contract Id for ${parser.name}`);\n }\n if (!followsPolicy(raw, match[4] === undefined ? 2 : 3)) {\n throw new ValidationError(\n `${raw} does not follow the ${policy} separator policy for ${parser.name}`,\n );\n }\n\n const [, country, provider, instance, check] = match;\n return ContractId.fromParts(standard, country, provider, instance, check);\n }\n\n public toCompactString(): string {\n return `${this.countryCode}${this.providerId}${this.instanceValue}${this.checkDigit}`;\n }\n\n public toCompactStringWithoutCheckDigit(): string {\n return `${this.countryCode}${this.providerId}${this.instanceValue}`;\n }\n\n public get partyId(): PartyId {\n return PartyId.fromCountryAndProvider(this.countryCode, this.providerId);\n }\n\n public convertTo(targetStandard: ContractIdStandard): ContractId {\n if (targetStandard === this.standard) {\n return this;\n }\n\n if (this.standard === ContractIdStandards.DIN && targetStandard === ContractIdStandards.EMI3) {\n return ContractId.fromParts(\n ContractIdStandards.EMI3,\n this.countryCode,\n this.providerId,\n `C0${this.instanceValue}${this.checkDigit}`,\n );\n }\n\n if (this.standard === ContractIdStandards.EMI3 && targetStandard === ContractIdStandards.DIN) {\n if (!this.instanceValue.startsWith(\"C0\")) {\n throw new ValidationError(\n `${this.toString()} cannot be converted to ${parsers.DIN.name} format`,\n \"unconvertible\",\n );\n }\n\n const dinInstance = this.instanceValue.slice(2, 8);\n const dinCheck = this.instanceValue.slice(8, 9);\n return ContractId.fromParts(\n ContractIdStandards.DIN,\n this.countryCode,\n this.providerId,\n dinInstance,\n dinCheck,\n );\n }\n\n if (this.standard === ContractIdStandards.ISO && targetStandard === ContractIdStandards.DIN) {\n if (!this.instanceValue.startsWith(\"00\")) {\n throw new ValidationError(\n `${this.toString()} cannot be converted to ${parsers.DIN.name} format`,\n \"unconvertible\",\n );\n }\n\n const dinInstance = this.instanceValue.slice(2, 8);\n const dinCheck = this.instanceValue.slice(8, 9);\n return ContractId.fromParts(\n ContractIdStandards.DIN,\n this.countryCode,\n this.providerId,\n dinInstance,\n dinCheck,\n );\n }\n\n if (this.standard === ContractIdStandards.DIN && targetStandard === ContractIdStandards.ISO) {\n return ContractId.fromParts(\n ContractIdStandards.ISO,\n this.countryCode,\n this.providerId,\n `00${this.instanceValue}${this.checkDigit}`,\n );\n }\n\n if (this.standard === ContractIdStandards.EMI3 && targetStandard === ContractIdStandards.ISO) {\n return ContractId.fromParts(\n ContractIdStandards.ISO,\n this.countryCode,\n this.providerId,\n this.instanceValue,\n this.checkDigit,\n );\n }\n\n if (this.standard === ContractIdStandards.ISO && targetStandard === ContractIdStandards.EMI3) {\n // A valid ISO instance that is not an EMI3 one (no leading C) makes the conversion fail,\n // not the instance: fromParts would report it as an invalid instance.\n if (!parsers.EMI3.instanceRegex.test(this.instanceValue)) {\n throw new ValidationError(\n `${this.instanceValue} is not a valid instance value for ${parsers.EMI3.name} format`,\n \"unconvertible\",\n );\n }\n return ContractId.fromParts(\n ContractIdStandards.EMI3,\n this.countryCode,\n this.providerId,\n this.instanceValue,\n this.checkDigit,\n );\n }\n\n throw new ValidationError(\n `It is not possible to convert ${this.standard} to ${targetStandard}`,\n \"unconvertible\",\n );\n }\n\n public toString(): string {\n return `${this.countryCode}-${this.providerId}-${this.instanceValue}-${this.checkDigit}`;\n }\n}\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type StringId, type StringIdCompanion, defineStringId } from \"./string-id.js\";\nimport { partyCodeSpec } from \"./provider-id.js\";\n\nconst OPERATOR_DIN_REGEX = /^[0-9]{3,6}$/;\n\nexport type OperatorIdIso = StringId<\"OperatorIdIso\">;\n\nexport const OperatorIdIso: StringIdCompanion<OperatorIdIso> = defineStringId({\n ...partyCodeSpec,\n reason: \"operator-id\",\n});\n\nexport type OperatorIdDin = StringId<\"OperatorIdDin\">;\n\nexport const OperatorIdDin: StringIdCompanion<OperatorIdDin> = defineStringId({\n isValid: (raw) => OPERATOR_DIN_REGEX.test(raw),\n message: () => \"OperatorId must have a length of 3-6 chars and be digits\",\n reason: \"operator-id\",\n});\n\nexport type OperatorId = OperatorIdIso | OperatorIdDin;\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type StringId, type StringIdCompanion, defineStringId } from \"./string-id.js\";\n\nconst PHONE_COUNTRY_CODE_REGEX = /^\\+?[0-9]{1,3}$/;\n\nexport type PhoneCountryCode = StringId<\"PhoneCountryCode\">;\n\nexport const PhoneCountryCode: StringIdCompanion<PhoneCountryCode> = defineStringId({\n isValid: (raw) => PHONE_COUNTRY_CODE_REGEX.test(raw),\n message: (raw) =>\n `phone Country Code must start with a '+' sign and be followed by 1-3 digits. (Was: ${raw})`,\n reason: \"phone-country-code\",\n});\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { asciiUpperCase } from \"./ascii.js\";\nimport { CountryCode } from \"./country-code.js\";\nimport { OperatorIdDin, OperatorIdIso, type OperatorId } from \"./operator-id.js\";\nimport {\n type ParseFailureReason,\n type ParseResult,\n ValidationError,\n attempt,\n failure,\n valueOrNull,\n} from \"./parse-result.js\";\nimport { PartyId } from \"./party-id.js\";\nimport { PhoneCountryCode } from \"./phone-country-code.js\";\n\ntype FormatError = Readonly<{ priority: number; description: string; reason: ParseFailureReason }>;\n\nconst ISO_COUNTRY_REGEX = /^([A-Za-z]{2})$/;\nconst ISO_OPERATOR_REGEX = /^([A-Za-z0-9]{3})$/;\nconst ISO_POWER_OUTLET_REGEX = /^([A-Za-z0-9*]{1,31})$/;\n// A first starred segment that starts with a country and an operator without separator, or a\n// second one that starts with an operator and the id type: the input is compact or mixes the\n// compact and starred forms (a power outlet id may hold separators), so its segments cannot be\n// attributed reliably.\nconst ISO_COUNTRY_AND_OPERATOR_REGEX = /^[A-Za-z]{2}[A-Za-z0-9]{3}/;\nconst ISO_OPERATOR_AND_ID_TYPE_REGEX = /^[A-Za-z0-9]{3}[Ee]/;\n// The E id type is matched case-insensitively like the rest of the id (OCPI CiString, OCHP ABNF);\n// toString() renders it in uppercase.\nconst ISO_EVSE_REGEX = /^([A-Za-z]{2})\\*?([A-Za-z0-9]{3})\\*?[Ee]([A-Za-z0-9*]{1,31})$/;\n\nconst DIN_COUNTRY_REGEX = /^(\\+?[0-9]{1,3})$/;\nconst DIN_OPERATOR_REGEX = /^([0-9]{3,6})$/;\nconst DIN_POWER_OUTLET_REGEX = /^([0-9*]{1,32})$/;\n// More digits than a phone country code or an operator id holds.\nconst DIN_COUNTRY_AND_OPERATOR_REGEX = /^\\+?[0-9]{4,}$/;\nconst DIN_OVERLONG_OPERATOR_REGEX = /^[0-9]{7,}$/;\nconst DIN_EVSE_REGEX = /^(\\+?[0-9]{1,3})\\*([0-9]{3,6})\\*([0-9*]{1,32})$/;\n\nabstract class EvseIdBase {\n public abstract readonly countryCode: CountryCode | PhoneCountryCode;\n public abstract readonly operatorId: OperatorId;\n public abstract readonly powerOutletId: string;\n\n public abstract toString(): string;\n}\n\nexport class EvseIdIso extends EvseIdBase {\n public readonly countryCode: CountryCode;\n public readonly operatorId: OperatorIdIso;\n public readonly powerOutletId: string;\n\n public constructor(countryCode: CountryCode, operatorId: OperatorIdIso, powerOutletId: string) {\n super();\n this.countryCode = countryCode;\n this.operatorId = operatorId;\n this.powerOutletId = powerOutletId;\n Object.freeze(this);\n }\n\n public static fromParts(\n countryCode: string,\n operatorId: string,\n powerOutletId: string,\n ): EvseIdIso {\n return createIso(\n asciiUpperCase(countryCode),\n asciiUpperCase(operatorId),\n asciiUpperCase(powerOutletId),\n );\n }\n\n public static tryParse(raw: string): ParseResult<EvseIdIso> {\n return attempt(() => EvseIdIso.parseStrict(raw));\n }\n\n public static parse(raw: string): EvseIdIso | null {\n return valueOrNull(EvseIdIso.tryParse(raw));\n }\n\n public static parseStrict(raw: string): EvseIdIso {\n const match = ISO_EVSE_REGEX.exec(raw);\n if (!match || match[1] === undefined || match[2] === undefined || match[3] === undefined) {\n throw new ValidationError(`Invalid ISO EVSE ID: ${raw}`, diagnoseIso(raw));\n }\n\n return createIso(asciiUpperCase(match[1]), asciiUpperCase(match[2]), asciiUpperCase(match[3]));\n }\n\n public get partyId(): PartyId {\n return PartyId.fromCountryAndOperator(this.countryCode, this.operatorId);\n }\n\n public toCompactString(): string {\n return this.toString().replaceAll(\"*\", \"\");\n }\n\n public toString(): string {\n return `${this.countryCode}*${this.operatorId}*E${this.powerOutletId}`;\n }\n}\n\nexport class EvseIdDin extends EvseIdBase {\n public readonly countryCode: PhoneCountryCode;\n public readonly operatorId: OperatorIdDin;\n public readonly powerOutletId: string;\n\n public constructor(\n countryCode: PhoneCountryCode,\n operatorId: OperatorIdDin,\n powerOutletId: string,\n ) {\n super();\n this.countryCode = countryCode;\n this.operatorId = operatorId;\n this.powerOutletId = powerOutletId;\n Object.freeze(this);\n }\n\n public static fromParts(\n countryCode: string,\n operatorId: string,\n powerOutletId: string,\n ): EvseIdDin {\n return createDin(\n asciiUpperCase(countryCode),\n asciiUpperCase(operatorId),\n asciiUpperCase(powerOutletId),\n );\n }\n\n public static tryParse(raw: string): ParseResult<EvseIdDin> {\n return attempt(() => EvseIdDin.parseStrict(raw));\n }\n\n public static parse(raw: string): EvseIdDin | null {\n return valueOrNull(EvseIdDin.tryParse(raw));\n }\n\n public static parseStrict(raw: string): EvseIdDin {\n const match = DIN_EVSE_REGEX.exec(raw);\n if (!match || match[1] === undefined || match[2] === undefined || match[3] === undefined) {\n throw new ValidationError(`Invalid DIN EVSE ID: ${raw}`, diagnoseDin(raw));\n }\n\n return createDin(asciiUpperCase(match[1]), asciiUpperCase(match[2]), asciiUpperCase(match[3]));\n }\n\n public toString(): string {\n return `${this.countryCode}*${this.operatorId}*${this.powerOutletId}`;\n }\n}\n\nfunction validateIso(\n countryCode: string,\n operatorId: string,\n powerOutletId: string,\n): FormatError | null {\n if (!ISO_COUNTRY_REGEX.test(countryCode)) {\n return {\n priority: 1,\n description: \"Invalid countryCode for ISO or DIN format\",\n reason: \"country-code\",\n };\n }\n if (!ISO_OPERATOR_REGEX.test(operatorId)) {\n return { priority: 2, description: \"Invalid operatorId for ISO format\", reason: \"operator-id\" };\n }\n if (!ISO_POWER_OUTLET_REGEX.test(powerOutletId)) {\n return {\n priority: 3,\n description: \"Invalid powerOutletId for ISO format\",\n reason: \"power-outlet-id\",\n };\n }\n\n return null;\n}\n\nfunction validateDin(\n countryCode: string,\n operatorId: string,\n powerOutletId: string,\n): FormatError | null {\n if (!DIN_COUNTRY_REGEX.test(countryCode)) {\n return {\n priority: 1,\n description: \"Invalid countryCode for ISO or DIN format\",\n reason: \"phone-country-code\",\n };\n }\n if (!DIN_OPERATOR_REGEX.test(operatorId)) {\n return { priority: 2, description: \"Invalid operatorId for DIN format\", reason: \"operator-id\" };\n }\n if (!DIN_POWER_OUTLET_REGEX.test(powerOutletId)) {\n return {\n priority: 3,\n description: \"Invalid powerOutletId for DIN format\",\n reason: \"power-outlet-id\",\n };\n }\n\n return null;\n}\n\n/**\n * Names the failing segment of an ISO EVSE id the full pattern rejected. Only the starred form\n * `country*operator*Eoutlet` splits reliably; compact or mixed forms are `format`.\n */\nfunction diagnoseIso(raw: string): ParseFailureReason {\n const [country, operator, ...rest] = raw.split(\"*\");\n if (operator === undefined || rest.length === 0) {\n return \"format\";\n }\n if (ISO_COUNTRY_AND_OPERATOR_REGEX.test(country ?? \"\")) {\n return \"format\";\n }\n if (operator.length > 3 && ISO_OPERATOR_AND_ID_TYPE_REGEX.test(operator)) {\n return \"format\";\n }\n if (!CountryCode.isValid(country ?? \"\")) {\n return \"country-code\";\n }\n if (!ISO_OPERATOR_REGEX.test(operator)) {\n return \"operator-id\";\n }\n const typedOutlet = rest.join(\"*\");\n if (!typedOutlet.startsWith(\"E\") && !typedOutlet.startsWith(\"e\")) {\n return \"id-type\";\n }\n if (!ISO_POWER_OUTLET_REGEX.test(typedOutlet.slice(1))) {\n return \"power-outlet-id\";\n }\n return \"format\";\n}\n\n/**\n * Names the failing segment of a DIN EVSE id, whose separators are mandatory. A digit run too\n * long for its segment may be a missing separator (`+49810*000*1`), so it is `format`.\n */\nfunction diagnoseDin(raw: string): ParseFailureReason {\n const [country, operator, ...rest] = raw.split(\"*\");\n if (operator === undefined || rest.length === 0) {\n return \"format\";\n }\n if (\n DIN_COUNTRY_AND_OPERATOR_REGEX.test(country ?? \"\") ||\n DIN_OVERLONG_OPERATOR_REGEX.test(operator)\n ) {\n return \"format\";\n }\n const error = validateDin(country ?? \"\", operator, rest.join(\"*\"));\n return error === null ? \"format\" : error.reason;\n}\n\nfunction createIso(countryCode: string, operatorId: string, powerOutletId: string): EvseIdIso {\n const country = CountryCode.from(countryCode);\n const operator = OperatorIdIso.from(operatorId);\n if (!ISO_POWER_OUTLET_REGEX.test(powerOutletId)) {\n throw new ValidationError(\"Invalid powerOutletId for ISO format\", \"power-outlet-id\");\n }\n // The E type marker is part of the rendering, not of the power outlet id: parsing already\n // consumed it and a power outlet id given by parts may itself start with E (as in Scala).\n return new EvseIdIso(country, operator, powerOutletId);\n}\n\nfunction createDin(countryCode: string, operatorId: string, powerOutletId: string): EvseIdDin {\n const countryWithPlus = countryCode.startsWith(\"+\") ? countryCode : `+${countryCode}`;\n const country = PhoneCountryCode.from(countryWithPlus);\n const operator = OperatorIdDin.from(operatorId);\n if (!DIN_POWER_OUTLET_REGEX.test(powerOutletId)) {\n throw new ValidationError(\"Invalid powerOutletId for DIN format\", \"power-outlet-id\");\n }\n return new EvseIdDin(country, operator, powerOutletId);\n}\n\nexport type EvseId = EvseIdIso | EvseIdDin;\n\nexport const EvseId = {\n fromParts(countryCode: string, operatorId: string, powerOutletId: string): EvseId {\n const normalizedCountry = asciiUpperCase(countryCode);\n const normalizedOperator = asciiUpperCase(operatorId);\n const normalizedPowerOutlet = asciiUpperCase(powerOutletId);\n\n const isoError = validateIso(normalizedCountry, normalizedOperator, normalizedPowerOutlet);\n if (isoError === null) {\n return createIso(normalizedCountry, normalizedOperator, normalizedPowerOutlet);\n }\n\n const dinError = validateDin(normalizedCountry, normalizedOperator, normalizedPowerOutlet);\n if (dinError === null) {\n return createDin(normalizedCountry, normalizedOperator, normalizedPowerOutlet);\n }\n\n const error = isoError.priority >= dinError.priority ? isoError : dinError;\n throw new ValidationError(error.description, error.reason);\n },\n\n // ISO is tried first, then DIN; a failure message carries both reasons since neither format is\n // implied. The reason code is the one of the format the input looks like: a leading letter is\n // ISO, a leading `+` or digit is DIN, anything else is `format`.\n tryParse(raw: string): ParseResult<EvseId> {\n const iso = EvseIdIso.tryParse(raw);\n if (iso.ok) {\n return iso;\n }\n\n const din = EvseIdDin.tryParse(raw);\n if (din.ok) {\n return din;\n }\n\n const reason = /^[A-Za-z]/.test(raw) ? iso.reason : /^[+0-9]/.test(raw) ? din.reason : \"format\";\n return failure(`Invalid EVSE ID: ${raw} (ISO: ${iso.error}; DIN: ${din.error})`, reason);\n },\n\n parse(raw: string): EvseId | null {\n return valueOrNull(EvseId.tryParse(raw));\n },\n\n parseStrict(raw: string): EvseId {\n const result = EvseId.tryParse(raw);\n if (!result.ok) {\n throw new ValidationError(result.error, result.reason);\n }\n\n return result.value;\n },\n};\n","/*\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ContractId } from \"./contract-id.js\";\nimport { ContractIdStandards } from \"./contract-id-standard.js\";\nimport { CountryCode } from \"./country-code.js\";\nimport { EvseId, EvseIdDin, EvseIdIso } from \"./evse-id.js\";\nimport { OperatorIdDin, OperatorIdIso } from \"./operator-id.js\";\nimport type { ParseResult } from \"./parse-result.js\";\nimport { PartyId } from \"./party-id.js\";\nimport { PhoneCountryCode } from \"./phone-country-code.js\";\nimport { ProviderId } from \"./provider-id.js\";\n\nexport const MobilityIdParsers = {\n parseCountryCode(raw: string): CountryCode | null {\n return CountryCode.parse(raw);\n },\n\n parsePhoneCountryCode(raw: string): PhoneCountryCode | null {\n return PhoneCountryCode.parse(raw);\n },\n\n parseProviderId(raw: string): ProviderId | null {\n return ProviderId.parse(raw);\n },\n\n parseOperatorIdIso(raw: string): OperatorIdIso | null {\n return OperatorIdIso.parse(raw);\n },\n\n parseOperatorIdDin(raw: string): OperatorIdDin | null {\n return OperatorIdDin.parse(raw);\n },\n\n parsePartyId(raw: string): PartyId | null {\n return PartyId.parse(raw);\n },\n\n parseContractIdIso(raw: string): ContractId | null {\n return ContractId.parse(ContractIdStandards.ISO, raw);\n },\n\n parseContractIdDin(raw: string): ContractId | null {\n return ContractId.parse(ContractIdStandards.DIN, raw);\n },\n\n parseContractIdEmi3(raw: string): ContractId | null {\n return ContractId.parse(ContractIdStandards.EMI3, raw);\n },\n\n parseEvseId(raw: string): EvseId | null {\n return EvseId.parse(raw);\n },\n\n parseEvseIdIso(raw: string): EvseIdIso | null {\n return EvseIdIso.parse(raw);\n },\n\n parseEvseIdDin(raw: string): EvseIdDin | null {\n return EvseIdDin.parse(raw);\n },\n\n tryParseCountryCode(raw: string): ParseResult<CountryCode> {\n return CountryCode.tryParse(raw);\n },\n\n tryParsePhoneCountryCode(raw: string): ParseResult<PhoneCountryCode> {\n return PhoneCountryCode.tryParse(raw);\n },\n\n tryParseProviderId(raw: string): ParseResult<ProviderId> {\n return ProviderId.tryParse(raw);\n },\n\n tryParseOperatorIdIso(raw: string): ParseResult<OperatorIdIso> {\n return OperatorIdIso.tryParse(raw);\n },\n\n tryParseOperatorIdDin(raw: string): ParseResult<OperatorIdDin> {\n return OperatorIdDin.tryParse(raw);\n },\n\n tryParsePartyId(raw: string): ParseResult<PartyId> {\n return PartyId.tryParse(raw);\n },\n\n tryParseContractIdIso(raw: string): ParseResult<ContractId> {\n return ContractId.tryParse(ContractIdStandards.ISO, raw);\n },\n\n tryParseContractIdDin(raw: string): ParseResult<ContractId> {\n return ContractId.tryParse(ContractIdStandards.DIN, raw);\n },\n\n tryParseContractIdEmi3(raw: string): ParseResult<ContractId> {\n return ContractId.tryParse(ContractIdStandards.EMI3, raw);\n },\n\n tryParseEvseId(raw: string): ParseResult<EvseId> {\n return EvseId.tryParse(raw);\n },\n\n tryParseEvseIdIso(raw: string): ParseResult<EvseIdIso> {\n return EvseIdIso.tryParse(raw);\n },\n\n tryParseEvseIdDin(raw: string): ParseResult<EvseIdDin> {\n return EvseIdDin.tryParse(raw);\n },\n};\n"],"mappings":";;;;;;;AAsBA,SAAgB,eAAe,OAAuB;CACpD,OAAO,MAAM,QAAQ,YAAY,YAAY,QAAQ,YAAY,CAAC;AACpE;;;;;;;;AC2BA,IAAa,kBAAb,cAAqC,UAAU;CAC7B;CAET,YAAY,SAAiB,SAA6B,UAAU;EACzE,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;AACF;AAUA,SAAgB,QAAW,OAA0B;CACnD,OAAO,OAAO,OAAO;EAAE,IAAI;EAAM;CAAM,CAAC;AAC1C;AAEA,S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AAO,YAAY,IAAI,cAAc,CAAC;EACvD;EAEA,OAAO;CACT;CAEA,MAAM,KAAK,MAAM,MAAM,YAAY;EAAE,IAAI,OAAO;EAAK,IAAI,OAAO;CAAI,EAAE;CACtE,MAAM,KAAK,YACT,MAAM,MAAM,YAAY;EAAE,IAAI,OAAO;EAAK,IAAI,OAAO;CAAI,EAAE,GAC3D,YACF;CAEA,MAAM,MAAc;EAClB,KAAK,GAAG,KAAK;EACb,KAAK,GAAG,KAAK;EACb,KAAK,GAAG,KAAK;EACb,KAAK,GAAG,KAAK;CACf;CAEA,MAAM,UAAU,SAAS,IAAI,UAAU,GAAG,CAAC;CAC3C,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,uBAAuB,UAAU,GAAG,EAAE,EAAE;CAG1D,OAAO;AACT;;ACvJA,MAAa,sBAAsB;CACjC,KAAK;CACL,MAAM;CACN,KAAK;AACP;;;;;;ACEA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;ACpNA,SAAgB,eAAiC,MAA0C;CACzF,MAAM,QAAQ,QAAmB;EAC/B,IAAI,CAAC,KAAK,QAAQ,GAAG,GACnB,MAAM,IAAI,gBAAgB,KAAK,QAAQ,GAAG,GAAG,KAAK,MAAM;EAG1D,OAAO,eAAe,GAAG;CAC3B;CACA,MAAM,YAAY,QAAgC,cAAc,KAAK,GAAG,CAAC;CACzE,MAAM,SAAS,QAA0B,YAAY,SAAS,GAAG,CAAC;CAElE,OAAO,OAAO,OAAO;EAAE,SAAS,KAAK;EAAS;EAAM;EAAU;CAAM,CAAC;AACvE;;ACpDA,MAAM,qBAAqB;AAE3B,MAAM,cAAmC,IAAI,IAAI,eAAe;AAOhE,MAAa,cAA8C,eAAe;CACxE,UAAU,QAAQ,mBAAmB,KAAK,GAAG,KAAK,YAAY,IAAI,eAAe,GAAG,CAAC;CACrF,eAAe;CACf,QAAQ;AACV,CAAC;;ACVD,MAAM,mBAAmB;;;;;;;;AASzB,MAAa,gBAA8B;CACzC,UAAU,QAAQ,iBAAiB,KAAK,GAAG;CAC3C,eAAe;C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BAAmB,KAAgC;EACjD,OAAO,WAAW,MAAM,oBAAoB,KAAK,GAAG;CACtD;CAEA,oBAAoB,KAAgC;EAClD,OAAO,WAAW,MAAM,oBAAoB,MAAM,GAAG;CACvD;CAEA,YAAY,KAA4B;EACtC,OAAO,OAAO,MAAM,GAAG;CACzB;CAEA,eAAe,KAA+B;EAC5C,OAAO,UAAU,MAAM,GAAG;CAC5B;CAEA,eAAe,KAA+B;EAC5C,OAAO,UAAU,MAAM,GAAG;CAC5B;CAEA,oBAAoB,KAAuC;EACzD,OAAO,YAAY,SAAS,GAAG;CACjC;CAEA,yBAAyB,KAA4C;EACnE,OAAO,iBAAiB,SAAS,GAAG;CACtC;CAEA,mBAAmB,KAAsC;EACvD,OAAO,WAAW,SAAS,GAAG;CAChC;CAEA,sBAAsB,KAAyC;EAC7D,OAAO,cAAc,SAAS,GAAG;CACnC;CAEA,sBAAsB,KAAyC;EAC7D,OAAO,cAAc,SAAS,GAAG;CACnC;CAEA,gBAAgB,KAAmC;EACjD,OAAO,QAAQ,SAAS,GAAG;CAC7B;CAEA,sBAAsB,KAAsC;EAC1D,OAAO,WAAW,SAAS,oBAAoB,KAAK,GAAG;CACzD;CAEA,sBAAsB,KAAsC;EAC1D,OAAO,WAAW,SAAS,oBAAoB,KAAK,GAAG;CACzD;CAEA,uBAAuB,KAAsC;EAC3D,OAAO,WAAW,SAAS,oBAAoB,MAAM,GAAG;CAC1D;CAEA,eAAe,KAAkC;EAC/C,OAAO,OAAO,SAAS,GAAG;CAC5B;CAEA,kBAAkB,KAAqC;EACrD,OAAO,UAAU,SAAS,GAAG;CAC/B;CAEA,kBAAkB,KAAqC;EACrD,OAAO,UAAU,SAAS,GAAG;CAC/B;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juherr/mobilityid",
3
- "version": "0.0.1",
3
+ "version": "0.2.0",
4
4
  "description": "TypeScript mobility ID domain model, validation, and parsers",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -24,8 +24,6 @@
24
24
  ],
25
25
  "type": "module",
26
26
  "sideEffects": false,
27
- "main": "./dist/index.js",
28
- "types": "./dist/index.d.ts",
29
27
  "exports": {
30
28
  ".": {
31
29
  "types": "./dist/index.d.ts",
@@ -34,30 +32,40 @@
34
32
  },
35
33
  "files": [
36
34
  "dist",
37
- "README.md"
35
+ "README.md",
36
+ "NOTICE"
38
37
  ],
39
38
  "publishConfig": {
40
39
  "access": "public",
41
40
  "registry": "https://registry.npmjs.org/"
42
41
  },
43
- "packageManager": "bun@1.3.12",
42
+ "packageManager": "bun@1.4.5",
44
43
  "engines": {
45
44
  "node": ">=22",
46
45
  "bun": ">=1.3.12"
47
46
  },
48
47
  "scripts": {
49
48
  "build": "vp pack",
49
+ "generate:iso3166": "scripts/generate-iso3166.sh",
50
50
  "lint": "vp lint src test",
51
51
  "lint:fix": "vp lint --fix src test",
52
+ "check:headers": "scripts/tests/header-policy.test.sh",
52
53
  "format": "vp fmt . --write",
53
54
  "format:check": "vp fmt --check",
54
55
  "typecheck": "vp check",
55
- "test": "vp test",
56
- "check": "vp check && vp test && vp pack"
56
+ "test": "vp test --coverage",
57
+ "check:shape": "publint --strict && attw --pack . --profile esm-only",
58
+ "check": "vp check && vp test --coverage && vp pack && bun run check:shape",
59
+ "check:package": "scripts/verify-package.sh"
57
60
  },
58
61
  "devDependencies": {
59
- "@tony.ganchev/eslint-plugin-header": "^3.4.3",
60
- "@types/node": "^24.0.0",
61
- "vite-plus": "^0.1.16"
62
+ "@arethetypeswrong/cli": "^0.18.5",
63
+ "@tony.ganchev/eslint-plugin-header": "3.4.4",
64
+ "@types/node": "^26.6.11",
65
+ "@vitest/coverage-v8": "5.1.2",
66
+ "fast-check": "^4.10.0",
67
+ "publint": "^0.3.24",
68
+ "typescript": "^6.0.3",
69
+ "vite-plus": "1.9.0"
62
70
  }
63
71
  }