@budiauktioner/buildi-primitives 0.2.1 → 0.3.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/PARITY.md +7 -7
  3. package/README.md +18 -1
  4. package/dist/cjs/contact/phone-number-test-data.js +1 -1
  5. package/dist/cjs/contact/phone-number-test-data.js.map +1 -1
  6. package/dist/cjs/contact/phone-number.js +36 -14
  7. package/dist/cjs/contact/phone-number.js.map +2 -2
  8. package/dist/cjs/organization/swedish-organization-number.js.map +2 -2
  9. package/dist/cjs/register-default-text-scanners.js +2 -0
  10. package/dist/cjs/register-default-text-scanners.js.map +2 -2
  11. package/dist/cjs/sample-data/index.js +18 -1
  12. package/dist/cjs/sample-data/index.js.map +2 -2
  13. package/dist/cjs/text-scanning/text-scan-result.js +3 -0
  14. package/dist/cjs/text-scanning/text-scan-result.js.map +2 -2
  15. package/dist/cjs/validation/validation-error-reason.js +6 -1
  16. package/dist/cjs/validation/validation-error-reason.js.map +2 -2
  17. package/dist/cjs/vehicle/index.js +4 -0
  18. package/dist/cjs/vehicle/index.js.map +2 -2
  19. package/dist/cjs/vehicle/watercraft-identification-number.js +332 -0
  20. package/dist/cjs/vehicle/watercraft-identification-number.js.map +7 -0
  21. package/dist/esm/contact/phone-number-test-data.js +1 -1
  22. package/dist/esm/contact/phone-number-test-data.js.map +1 -1
  23. package/dist/esm/contact/phone-number.js +36 -14
  24. package/dist/esm/contact/phone-number.js.map +2 -2
  25. package/dist/esm/organization/swedish-organization-number.js.map +2 -2
  26. package/dist/esm/register-default-text-scanners.js +2 -0
  27. package/dist/esm/register-default-text-scanners.js.map +2 -2
  28. package/dist/esm/sample-data/index.js +18 -1
  29. package/dist/esm/sample-data/index.js.map +2 -2
  30. package/dist/esm/text-scanning/text-scan-result.js +3 -0
  31. package/dist/esm/text-scanning/text-scan-result.js.map +2 -2
  32. package/dist/esm/validation/validation-error-reason.js +6 -1
  33. package/dist/esm/validation/validation-error-reason.js.map +2 -2
  34. package/dist/esm/vehicle/index.js +8 -0
  35. package/dist/esm/vehicle/index.js.map +2 -2
  36. package/dist/esm/vehicle/watercraft-identification-number.js +315 -0
  37. package/dist/esm/vehicle/watercraft-identification-number.js.map +7 -0
  38. package/dist/types/banking/index.d.cts +2 -2
  39. package/dist/types/banking/index.d.ts +2 -2
  40. package/dist/types/contact/index.d.cts +1 -1
  41. package/dist/types/contact/index.d.ts +1 -1
  42. package/dist/types/index.d.cts +2 -1
  43. package/dist/types/index.d.ts +2 -1
  44. package/dist/types/sample-data/index.d.cts +10 -2
  45. package/dist/types/sample-data/index.d.ts +10 -2
  46. package/dist/types/text-scanning/index.d.cts +3 -1
  47. package/dist/types/text-scanning/index.d.ts +3 -1
  48. package/dist/types/validation/index.d.cts +4 -0
  49. package/dist/types/validation/index.d.ts +4 -0
  50. package/dist/types/vehicle/index.d.cts +2 -0
  51. package/dist/types/vehicle/index.d.ts +2 -0
  52. package/dist/types/watercraft-identification-number-Db1I2LQM.d.cts +123 -0
  53. package/dist/types/watercraft-identification-number-o8B3C6Nx.d.ts +123 -0
  54. package/package.json +18 -13
  55. package/dist/types/{swedish-swish-number-CL6Gx_h3.d.cts → swedish-swish-number-Bh-UbVoN.d.cts} +136 -136
  56. package/dist/types/{swedish-swish-number-DDG3mNDg.d.ts → swedish-swish-number-C2Wccuyr.d.ts} +136 -136
@@ -1,5 +1,5 @@
1
1
  import { T as TextCandidate, a as TextCandidateCategory, b as TextMatchConfidence } from '../text-candidate-qg2bD9PY.js';
2
- import { I as Iban, B as Bic, d as SwedishBankgiroNumber, f as SwedishPostgiroNumber, b as SwedishBankAccount, e as SwedishOcrReferenceNumber, g as SwedishSwishNumber } from '../swedish-swish-number-DDG3mNDg.js';
2
+ import { I as Iban, B as Bic, d as SwedishBankgiroNumber, f as SwedishPostgiroNumber, b as SwedishBankAccount, e as SwedishOcrReferenceNumber, g as SwedishSwishNumber } from '../swedish-swish-number-C2Wccuyr.js';
3
3
  import { c as AddressZipCode, A as Address, S as SwedishAddress } from '../swedish-address-GMzjqgxb.js';
4
4
  import { a as PhoneNumber } from '../phone-number-C24--ggy.js';
5
5
  import { I as Isin } from '../isin-EeVPpNWu.js';
@@ -15,6 +15,7 @@ import { S as SwedishPropertyDesignation } from '../swedish-property-designation
15
15
  import { EmailAddress, Url } from '../web/index.js';
16
16
  import { h as Gtin8, G as Gtin12, d as Gtin13, f as Gtin14, I as IpRating, E as ElectricalPhase, R as Refrigerant, C as Color, S as ScreenResolution, n as ScreenSize } from '../screen-size-DUmjNjxG.js';
17
17
  import { o as SwedishVehicleRegistrationNumber, V as VehicleIdentificationNumber, O as OperatingHours, B as BoltPattern, W as WheelRimDimension, T as TireDimension, e as EuTypeApprovalNumber, c as EnginePower, F as FuelConsumption, E as EmissionRate, g as EuroEmissionClass, m as SwedishEcoVehicleClassification, S as SwedishDrivingLicenseCategory } from '../wheel-rim-dimension-CVCmLASl.js';
18
+ import { W as WatercraftIdentificationNumber } from '../watercraft-identification-number-o8B3C6Nx.js';
18
19
  import '../validation/index.js';
19
20
  import '../swedish-organization-type-CZOdETwG.js';
20
21
 
@@ -94,6 +95,7 @@ declare class TextScanResult {
94
95
  get weights(): TextCandidate<Weight>[];
95
96
  get vehicleRegistrationNumbers(): TextCandidate<SwedishVehicleRegistrationNumber>[];
96
97
  get vehicleIdentificationNumbers(): TextCandidate<VehicleIdentificationNumber>[];
98
+ get watercraftIdentificationNumbers(): TextCandidate<WatercraftIdentificationNumber>[];
97
99
  get operatingHourValues(): TextCandidate<OperatingHours>[];
98
100
  get boltPatterns(): TextCandidate<BoltPattern>[];
99
101
  get wheelRimDimensions(): TextCandidate<WheelRimDimension>[];
@@ -26,6 +26,10 @@ declare const ValidationErrorReason: {
26
26
  readonly MissingAtSign: "MissingAtSign";
27
27
  readonly InvalidLocalPart: "InvalidLocalPart";
28
28
  readonly InvalidDomain: "InvalidDomain";
29
+ readonly InvalidManufacturerCode: "InvalidManufacturerCode";
30
+ readonly InvalidSerialNumber: "InvalidSerialNumber";
31
+ readonly InvalidMonthCode: "InvalidMonthCode";
32
+ readonly InvalidYearDigits: "InvalidYearDigits";
29
33
  };
30
34
  type ValidationErrorReason = (typeof ValidationErrorReason)[keyof typeof ValidationErrorReason];
31
35
 
@@ -26,6 +26,10 @@ declare const ValidationErrorReason: {
26
26
  readonly MissingAtSign: "MissingAtSign";
27
27
  readonly InvalidLocalPart: "InvalidLocalPart";
28
28
  readonly InvalidDomain: "InvalidDomain";
29
+ readonly InvalidManufacturerCode: "InvalidManufacturerCode";
30
+ readonly InvalidSerialNumber: "InvalidSerialNumber";
31
+ readonly InvalidMonthCode: "InvalidMonthCode";
32
+ readonly InvalidYearDigits: "InvalidYearDigits";
29
33
  };
30
34
  type ValidationErrorReason = (typeof ValidationErrorReason)[keyof typeof ValidationErrorReason];
31
35
 
@@ -3,7 +3,9 @@ import { o as SwedishVehicleRegistrationNumber, m as SwedishEcoVehicleClassifica
3
3
  export { B as BoltPattern, a as BoltPatternFormatOptions, E as EmissionRate, b as EmissionRateFormatOptions, c as EnginePower, d as EnginePowerFormatOptions, e as EuTypeApprovalNumber, f as EuTypeApprovalNumberFormatOptions, g as EuroEmissionClass, h as EuroEmissionClassFormatOptions, F as FuelConsumption, i as FuelConsumptionFormatOptions, O as OperatingHours, j as OperatingHoursFormatOptions, S as SwedishDrivingLicenseCategory, k as SwedishDrivingLicenseCategoryFormatOptions, l as SwedishDrivingLicenseVehicleGroup, n as SwedishEcoVehicleClassificationFormatOptions, p as SwedishVehicleRegistrationNumberFormatOptions, T as TireDimension, q as TireDimensionFormatOptions, V as VehicleIdentificationNumber, r as VehicleIdentificationNumberFormatOptions, W as WheelRimDimension, s as WheelRimDimensionFormatOptions, t as maskBoltPattern, u as maskEmissionRate, v as maskEnginePower, w as maskEuTypeApprovalNumber, x as maskFuelConsumption, y as maskOperatingHours, z as maskSwedishVehicleRegistrationNumber, A as maskTireDimension, C as maskVehicleIdentificationNumber, D as maskWheelRimDimension } from '../wheel-rim-dimension-CdkDrzad.cjs';
4
4
  import { D as Decimal, L as Length, b as LengthUnit } from '../length-XRL5Eg7F.cjs';
5
5
  import { V as Volume, d as VolumeUnit } from '../volume-CFA4e3dc.cjs';
6
+ export { W as WatercraftIdentificationNumber, a as WatercraftIdentificationNumberFormatOptions, b as WatercraftIdentificationNumberScheme, m as maskWatercraftIdentificationNumber } from '../watercraft-identification-number-Db1I2LQM.cjs';
6
7
  import '../validation/index.cjs';
8
+ import '../country-BhD51LDL.cjs';
7
9
 
8
10
  /** Options shared by the string-in, string-out helpers. */
9
11
  interface BoatCeDesignCategoryFormatOptions {
@@ -3,7 +3,9 @@ import { o as SwedishVehicleRegistrationNumber, m as SwedishEcoVehicleClassifica
3
3
  export { B as BoltPattern, a as BoltPatternFormatOptions, E as EmissionRate, b as EmissionRateFormatOptions, c as EnginePower, d as EnginePowerFormatOptions, e as EuTypeApprovalNumber, f as EuTypeApprovalNumberFormatOptions, g as EuroEmissionClass, h as EuroEmissionClassFormatOptions, F as FuelConsumption, i as FuelConsumptionFormatOptions, O as OperatingHours, j as OperatingHoursFormatOptions, S as SwedishDrivingLicenseCategory, k as SwedishDrivingLicenseCategoryFormatOptions, l as SwedishDrivingLicenseVehicleGroup, n as SwedishEcoVehicleClassificationFormatOptions, p as SwedishVehicleRegistrationNumberFormatOptions, T as TireDimension, q as TireDimensionFormatOptions, V as VehicleIdentificationNumber, r as VehicleIdentificationNumberFormatOptions, W as WheelRimDimension, s as WheelRimDimensionFormatOptions, t as maskBoltPattern, u as maskEmissionRate, v as maskEnginePower, w as maskEuTypeApprovalNumber, x as maskFuelConsumption, y as maskOperatingHours, z as maskSwedishVehicleRegistrationNumber, A as maskTireDimension, C as maskVehicleIdentificationNumber, D as maskWheelRimDimension } from '../wheel-rim-dimension-CVCmLASl.js';
4
4
  import { D as Decimal, L as Length, b as LengthUnit } from '../length-CceXIJYY.js';
5
5
  import { V as Volume, d as VolumeUnit } from '../volume-DGLPQypt.js';
6
+ export { W as WatercraftIdentificationNumber, a as WatercraftIdentificationNumberFormatOptions, b as WatercraftIdentificationNumberScheme, m as maskWatercraftIdentificationNumber } from '../watercraft-identification-number-o8B3C6Nx.js';
6
7
  import '../validation/index.js';
8
+ import '../country-p0n0EVQ9.js';
7
9
 
8
10
  /** Options shared by the string-in, string-out helpers. */
9
11
  interface BoatCeDesignCategoryFormatOptions {
@@ -0,0 +1,123 @@
1
+ import { a as Country } from './country-BhD51LDL.cjs';
2
+ import { P as PrimitiveTypeInfo, T as TextCandidate } from './text-candidate-qg2bD9PY.cjs';
3
+ import { ValidationResult } from './validation/index.cjs';
4
+
5
+ /** Options for {@link WatercraftIdentificationNumber.format} and `normalize`. */
6
+ interface WatercraftIdentificationNumberFormatOptions {
7
+ fallbackToTrimmedInputWhenInvalid?: boolean;
8
+ }
9
+ /** The scheme a {@link WatercraftIdentificationNumber} was written in. */
10
+ declare const WatercraftIdentificationNumberScheme: {
11
+ readonly Unknown: 0;
12
+ /**
13
+ * ISO 10087 craft or watercraft identification number (CIN/WIN): a two-letter
14
+ * country code, a hyphen and twelve characters, e.g. `NL-HXAB7A33G506`.
15
+ */
16
+ readonly Iso10087: 1;
17
+ /**
18
+ * United States hull identification number (HIN) in the twelve-character format
19
+ * required since 1 August 1984 by 33 CFR 181.25, e.g. `ZZZ00001A020`.
20
+ */
21
+ readonly UnitedStatesHullIdentificationNumber: 2;
22
+ };
23
+ type WatercraftIdentificationNumberScheme = (typeof WatercraftIdentificationNumberScheme)[keyof typeof WatercraftIdentificationNumberScheme];
24
+ /**
25
+ * A watercraft identification number (`skrovnummer`), the hull marking of a small
26
+ * craft: either the ISO 10087 craft identification number (CIN, now called WIN by
27
+ * Transportstyrelsen) of fourteen characters plus a hyphen, or the twelve-character
28
+ * US hull identification number (HIN).
29
+ *
30
+ * The number is assigned by the manufacturer and carries no check digit, so a parsed
31
+ * value is structurally valid only — it does not prove that the manufacturer code is
32
+ * registered or that the number belongs to a particular craft. The production year
33
+ * and model year are encoded as one and two digits respectively, so the century
34
+ * cannot be derived from the number alone; they are exposed as digits rather than
35
+ * full years. Older markings that predate these formats (for example US HINs from
36
+ * before August 1984) are not accepted.
37
+ *
38
+ * Sources:
39
+ * - https://www.iso.org/standard/82383.html
40
+ * - https://www.ecfr.gov/current/title-33/chapter-I/subchapter-S/part-181/subpart-C/section-181.25
41
+ * - https://www.transportstyrelsen.se/sv/sjofart/fritidsbatar/lagar-och-regler-for-fritidsbatar/cemarkning/bygga-om-tillverka-distribuera-och-importera/tillverka/instruktionsbok-tillverkarskylt-och-win/
42
+ */
43
+ declare class WatercraftIdentificationNumber {
44
+ static readonly typeInfo: PrimitiveTypeInfo;
45
+ /**
46
+ * The number in uppercase without separators: fourteen characters for ISO 10087,
47
+ * e.g. `NLHXAB7A33G506`, or twelve for a US HIN, e.g. `ZZZ00001A020`.
48
+ */
49
+ readonly value: string;
50
+ /**
51
+ * The number as it is marked on the hull: ISO 10087 with the hyphen after the
52
+ * country code, e.g. `NL-HXAB7A33G506`, and a US HIN unchanged, e.g. `ZZZ00001A020`.
53
+ */
54
+ readonly formatted: string;
55
+ /** Which of the two supported formats the number follows. */
56
+ readonly scheme: WatercraftIdentificationNumberScheme;
57
+ /**
58
+ * The ISO 3166-1 alpha-2 code of the country where the manufacturer is established,
59
+ * e.g. `NL`, or `null` for a US HIN, which carries no country.
60
+ */
61
+ readonly countryCode: string | null;
62
+ /** The country of {@link countryCode}, or `null` for a US HIN. */
63
+ readonly country: Country | null;
64
+ /** The three-character manufacturer identification code (MIC), e.g. `HXA`. */
65
+ readonly manufacturerCode: string;
66
+ /** The five-character serial number assigned by the manufacturer, e.g. `B7A33`. */
67
+ readonly serialNumber: string;
68
+ /**
69
+ * The production month letter, `A` for January through `L` for December. For a US
70
+ * HIN this is the month of certification when one is required, otherwise the month
71
+ * of manufacture.
72
+ */
73
+ readonly productionMonthCode: string;
74
+ /** The production month decoded from {@link productionMonthCode}, 1–12. */
75
+ readonly productionMonth: number;
76
+ /** The last digit of the production year, 0–9. The decade is not encoded. */
77
+ readonly productionYearDigit: number;
78
+ /** The last two digits of the model year as written, e.g. `06`. The century is not encoded. */
79
+ readonly modelYearDigits: string;
80
+ private constructor();
81
+ static tryParse(input: string | null | undefined): WatercraftIdentificationNumber | null;
82
+ static parse(input: string): WatercraftIdentificationNumber;
83
+ static isValid(input: string | null | undefined): boolean;
84
+ /**
85
+ * Returns the number as it is marked on the hull, e.g. `NL-HXAB7A33G506` or
86
+ * `ZZZ00001A020`.
87
+ */
88
+ static format(input: string | null | undefined, options?: WatercraftIdentificationNumberFormatOptions): string | null;
89
+ /**
90
+ * Returns the number in uppercase without separators, e.g. `NLHXAB7A33G506` or
91
+ * `ZZZ00001A020`.
92
+ */
93
+ static normalize(input: string | null | undefined, options?: WatercraftIdentificationNumberFormatOptions): string | null;
94
+ static isNormalized(input: string | null | undefined): boolean;
95
+ /**
96
+ * Describes every invalid segment of the input, one issue per segment, or reports
97
+ * it as valid.
98
+ */
99
+ static validate(input: string | null | undefined): ValidationResult;
100
+ /**
101
+ * Finds watercraft identification number candidates in unstructured text. An ISO
102
+ * 10087 number written with its hyphen is reported with medium confidence; one
103
+ * without the hyphen, and a US HIN, are bare runs of letters and digits and
104
+ * reported with low confidence. Results are heuristic and may include false
105
+ * positives.
106
+ */
107
+ static findCandidatesInText(text: string): readonly TextCandidate<WatercraftIdentificationNumber>[];
108
+ /** Returns the number without separators, e.g. `NLHXAB7A33G506`. */
109
+ toNormalizedString(): string;
110
+ /** Returns the number as it is marked on the hull, e.g. `NL-HXAB7A33G506`. */
111
+ toString(): string;
112
+ equals(other: WatercraftIdentificationNumber | null | undefined): boolean;
113
+ compareTo(other: WatercraftIdentificationNumber | null | undefined): number;
114
+ private static tryParseCore;
115
+ }
116
+ /**
117
+ * Returns a watercraft identification number with only the country and manufacturer
118
+ * codes visible, e.g. `NL-HXAB7A33G506` becomes `NL-HXA*********` and
119
+ * `ZZZ00001A020` becomes `ZZZ*********`.
120
+ */
121
+ declare function maskWatercraftIdentificationNumber(win: WatercraftIdentificationNumber): string;
122
+
123
+ export { WatercraftIdentificationNumber as W, type WatercraftIdentificationNumberFormatOptions as a, WatercraftIdentificationNumberScheme as b, maskWatercraftIdentificationNumber as m };
@@ -0,0 +1,123 @@
1
+ import { a as Country } from './country-p0n0EVQ9.js';
2
+ import { P as PrimitiveTypeInfo, T as TextCandidate } from './text-candidate-qg2bD9PY.js';
3
+ import { ValidationResult } from './validation/index.js';
4
+
5
+ /** Options for {@link WatercraftIdentificationNumber.format} and `normalize`. */
6
+ interface WatercraftIdentificationNumberFormatOptions {
7
+ fallbackToTrimmedInputWhenInvalid?: boolean;
8
+ }
9
+ /** The scheme a {@link WatercraftIdentificationNumber} was written in. */
10
+ declare const WatercraftIdentificationNumberScheme: {
11
+ readonly Unknown: 0;
12
+ /**
13
+ * ISO 10087 craft or watercraft identification number (CIN/WIN): a two-letter
14
+ * country code, a hyphen and twelve characters, e.g. `NL-HXAB7A33G506`.
15
+ */
16
+ readonly Iso10087: 1;
17
+ /**
18
+ * United States hull identification number (HIN) in the twelve-character format
19
+ * required since 1 August 1984 by 33 CFR 181.25, e.g. `ZZZ00001A020`.
20
+ */
21
+ readonly UnitedStatesHullIdentificationNumber: 2;
22
+ };
23
+ type WatercraftIdentificationNumberScheme = (typeof WatercraftIdentificationNumberScheme)[keyof typeof WatercraftIdentificationNumberScheme];
24
+ /**
25
+ * A watercraft identification number (`skrovnummer`), the hull marking of a small
26
+ * craft: either the ISO 10087 craft identification number (CIN, now called WIN by
27
+ * Transportstyrelsen) of fourteen characters plus a hyphen, or the twelve-character
28
+ * US hull identification number (HIN).
29
+ *
30
+ * The number is assigned by the manufacturer and carries no check digit, so a parsed
31
+ * value is structurally valid only — it does not prove that the manufacturer code is
32
+ * registered or that the number belongs to a particular craft. The production year
33
+ * and model year are encoded as one and two digits respectively, so the century
34
+ * cannot be derived from the number alone; they are exposed as digits rather than
35
+ * full years. Older markings that predate these formats (for example US HINs from
36
+ * before August 1984) are not accepted.
37
+ *
38
+ * Sources:
39
+ * - https://www.iso.org/standard/82383.html
40
+ * - https://www.ecfr.gov/current/title-33/chapter-I/subchapter-S/part-181/subpart-C/section-181.25
41
+ * - https://www.transportstyrelsen.se/sv/sjofart/fritidsbatar/lagar-och-regler-for-fritidsbatar/cemarkning/bygga-om-tillverka-distribuera-och-importera/tillverka/instruktionsbok-tillverkarskylt-och-win/
42
+ */
43
+ declare class WatercraftIdentificationNumber {
44
+ static readonly typeInfo: PrimitiveTypeInfo;
45
+ /**
46
+ * The number in uppercase without separators: fourteen characters for ISO 10087,
47
+ * e.g. `NLHXAB7A33G506`, or twelve for a US HIN, e.g. `ZZZ00001A020`.
48
+ */
49
+ readonly value: string;
50
+ /**
51
+ * The number as it is marked on the hull: ISO 10087 with the hyphen after the
52
+ * country code, e.g. `NL-HXAB7A33G506`, and a US HIN unchanged, e.g. `ZZZ00001A020`.
53
+ */
54
+ readonly formatted: string;
55
+ /** Which of the two supported formats the number follows. */
56
+ readonly scheme: WatercraftIdentificationNumberScheme;
57
+ /**
58
+ * The ISO 3166-1 alpha-2 code of the country where the manufacturer is established,
59
+ * e.g. `NL`, or `null` for a US HIN, which carries no country.
60
+ */
61
+ readonly countryCode: string | null;
62
+ /** The country of {@link countryCode}, or `null` for a US HIN. */
63
+ readonly country: Country | null;
64
+ /** The three-character manufacturer identification code (MIC), e.g. `HXA`. */
65
+ readonly manufacturerCode: string;
66
+ /** The five-character serial number assigned by the manufacturer, e.g. `B7A33`. */
67
+ readonly serialNumber: string;
68
+ /**
69
+ * The production month letter, `A` for January through `L` for December. For a US
70
+ * HIN this is the month of certification when one is required, otherwise the month
71
+ * of manufacture.
72
+ */
73
+ readonly productionMonthCode: string;
74
+ /** The production month decoded from {@link productionMonthCode}, 1–12. */
75
+ readonly productionMonth: number;
76
+ /** The last digit of the production year, 0–9. The decade is not encoded. */
77
+ readonly productionYearDigit: number;
78
+ /** The last two digits of the model year as written, e.g. `06`. The century is not encoded. */
79
+ readonly modelYearDigits: string;
80
+ private constructor();
81
+ static tryParse(input: string | null | undefined): WatercraftIdentificationNumber | null;
82
+ static parse(input: string): WatercraftIdentificationNumber;
83
+ static isValid(input: string | null | undefined): boolean;
84
+ /**
85
+ * Returns the number as it is marked on the hull, e.g. `NL-HXAB7A33G506` or
86
+ * `ZZZ00001A020`.
87
+ */
88
+ static format(input: string | null | undefined, options?: WatercraftIdentificationNumberFormatOptions): string | null;
89
+ /**
90
+ * Returns the number in uppercase without separators, e.g. `NLHXAB7A33G506` or
91
+ * `ZZZ00001A020`.
92
+ */
93
+ static normalize(input: string | null | undefined, options?: WatercraftIdentificationNumberFormatOptions): string | null;
94
+ static isNormalized(input: string | null | undefined): boolean;
95
+ /**
96
+ * Describes every invalid segment of the input, one issue per segment, or reports
97
+ * it as valid.
98
+ */
99
+ static validate(input: string | null | undefined): ValidationResult;
100
+ /**
101
+ * Finds watercraft identification number candidates in unstructured text. An ISO
102
+ * 10087 number written with its hyphen is reported with medium confidence; one
103
+ * without the hyphen, and a US HIN, are bare runs of letters and digits and
104
+ * reported with low confidence. Results are heuristic and may include false
105
+ * positives.
106
+ */
107
+ static findCandidatesInText(text: string): readonly TextCandidate<WatercraftIdentificationNumber>[];
108
+ /** Returns the number without separators, e.g. `NLHXAB7A33G506`. */
109
+ toNormalizedString(): string;
110
+ /** Returns the number as it is marked on the hull, e.g. `NL-HXAB7A33G506`. */
111
+ toString(): string;
112
+ equals(other: WatercraftIdentificationNumber | null | undefined): boolean;
113
+ compareTo(other: WatercraftIdentificationNumber | null | undefined): number;
114
+ private static tryParseCore;
115
+ }
116
+ /**
117
+ * Returns a watercraft identification number with only the country and manufacturer
118
+ * codes visible, e.g. `NL-HXAB7A33G506` becomes `NL-HXA*********` and
119
+ * `ZZZ00001A020` becomes `ZZZ*********`.
120
+ */
121
+ declare function maskWatercraftIdentificationNumber(win: WatercraftIdentificationNumber): string;
122
+
123
+ export { WatercraftIdentificationNumber as W, type WatercraftIdentificationNumberFormatOptions as a, WatercraftIdentificationNumberScheme as b, maskWatercraftIdentificationNumber as m };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@budiauktioner/buildi-primitives",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Swedish, EU and international value-object primitives — validation, normalization, masking, and text scanning. TypeScript port of Buildi.Primitives (.NET).",
5
5
  "license": "MIT",
6
6
  "author": "Budi Auktioner",
@@ -228,19 +228,24 @@
228
228
  "publint": "publint",
229
229
  "attw": "attw --pack . --profile node16"
230
230
  },
231
+ "pnpm": {
232
+ "overrides": {
233
+ "esbuild@>=0.27.3 <0.28.1": "^0.28.1"
234
+ }
235
+ },
231
236
  "devDependencies": {
232
237
  "@arethetypeswrong/cli": "^0.18.5",
233
- "@eslint/js": "^9.18.0",
234
- "@types/node": "^22.10.7",
235
- "@vitest/coverage-v8": "^2.1.8",
236
- "esbuild": "^0.28.1",
237
- "eslint": "^9.18.0",
238
- "prettier": "^3.4.2",
239
- "publint": "^0.3.2",
240
- "tsup": "^8.3.5",
241
- "tsx": "^4.19.2",
242
- "typescript": "^5.7.3",
243
- "typescript-eslint": "^8.21.0",
244
- "vitest": "^2.1.8"
238
+ "@eslint/js": "^9.39.5",
239
+ "@types/node": "^22.20.5",
240
+ "@vitest/coverage-v8": "^4.1.12",
241
+ "esbuild": "^0.28.2",
242
+ "eslint": "^9.39.5",
243
+ "prettier": "^3.9.10",
244
+ "publint": "^0.3.25",
245
+ "tsup": "^8.5.1",
246
+ "tsx": "^4.23.15",
247
+ "typescript": "^5.9.3",
248
+ "typescript-eslint": "^8.72.1",
249
+ "vitest": "^4.1.12"
245
250
  }
246
251
  }
@@ -80,6 +80,142 @@ declare class Bic {
80
80
  */
81
81
  declare function maskBic(bic: Bic): string;
82
82
 
83
+ /**
84
+ * A Swedish Bankgiro number (`bankgironummer`), e.g. `5805-6201`.
85
+ * 7 or 8 digits with Luhn check digit.
86
+ */
87
+ declare class SwedishBankgiroNumber {
88
+ static readonly typeInfo: PrimitiveTypeInfo;
89
+ static readonly displayName = "Bankgiro";
90
+ static readonly displayNameShort = "BG";
91
+ /** Digit-only value, e.g. `58056201`. */
92
+ readonly digits: string;
93
+ /** Hyphenated display form, e.g. `5805-6201`. */
94
+ readonly formatted: string;
95
+ private constructor();
96
+ static tryParse(input: string | null | undefined): SwedishBankgiroNumber | null;
97
+ static parse(input: string): SwedishBankgiroNumber;
98
+ static isValid(input: string | null | undefined): boolean;
99
+ static format(input: string | null | undefined, options?: {
100
+ fallbackToTrimmedInputWhenInvalid?: boolean;
101
+ }): string | null;
102
+ static normalize(input: string | null | undefined, options?: {
103
+ fallbackToTrimmedInputWhenInvalid?: boolean;
104
+ }): string | null;
105
+ static isNormalized(input: string | null | undefined): boolean;
106
+ toNormalizedString(): string;
107
+ toDisplayString(): string;
108
+ toShortDisplayString(): string;
109
+ toString(): string;
110
+ static validate(input: string | null | undefined): ValidationResult;
111
+ static findCandidatesInText(text: string): readonly TextCandidate<SwedishBankgiroNumber>[];
112
+ equals(other: SwedishBankgiroNumber | null | undefined): boolean;
113
+ compareTo(other: SwedishBankgiroNumber | null | undefined): number;
114
+ }
115
+ /** Returns the Bankgirot search URL for this Bankgiro number. */
116
+ declare function getBankgirotUrl(bg: SwedishBankgiroNumber): string;
117
+ /**
118
+ * Returns a masked Bankgiro number, e.g. `****-6201` (default) or `5805-****` when
119
+ * `showLastDigits` is `false`.
120
+ */
121
+ declare function maskSwedishBankgiroNumber(bg: SwedishBankgiroNumber, options?: {
122
+ showLastDigits?: boolean;
123
+ }): string;
124
+
125
+ /**
126
+ * A Swedish Plusgiro number (`plusgironummer`), e.g. `1234567-9`.
127
+ * 2–8 digits with Luhn check digit.
128
+ */
129
+ declare class SwedishPostgiroNumber {
130
+ static readonly typeInfo: PrimitiveTypeInfo;
131
+ static readonly displayName = "Plusgiro";
132
+ static readonly displayNameShort = "PG";
133
+ /** Digit-only value, e.g. `41313008`. */
134
+ readonly digits: string;
135
+ /** Hyphenated display form, e.g. `4131300-8`. */
136
+ readonly formatted: string;
137
+ private constructor();
138
+ static tryParse(input: string | null | undefined): SwedishPostgiroNumber | null;
139
+ static parse(input: string): SwedishPostgiroNumber;
140
+ static isValid(input: string | null | undefined): boolean;
141
+ static format(input: string | null | undefined, options?: {
142
+ fallbackToTrimmedInputWhenInvalid?: boolean;
143
+ }): string | null;
144
+ static normalize(input: string | null | undefined, options?: {
145
+ fallbackToTrimmedInputWhenInvalid?: boolean;
146
+ }): string | null;
147
+ static isNormalized(input: string | null | undefined): boolean;
148
+ toNormalizedString(): string;
149
+ toDisplayString(): string;
150
+ toShortDisplayString(): string;
151
+ toString(): string;
152
+ static validate(input: string | null | undefined): ValidationResult;
153
+ static findCandidatesInText(text: string): readonly TextCandidate<SwedishPostgiroNumber>[];
154
+ equals(other: SwedishPostgiroNumber | null | undefined): boolean;
155
+ compareTo(other: SwedishPostgiroNumber | null | undefined): number;
156
+ }
157
+ /**
158
+ * Returns a masked Plusgiro number, e.g. `******-9` (default, showing the control digit) or
159
+ * `123456-*` when `showControlDigit` is `false`.
160
+ */
161
+ declare function maskSwedishPostgiroNumber(pg: SwedishPostgiroNumber, options?: {
162
+ showControlDigit?: boolean;
163
+ }): string;
164
+
165
+ /** OCR reference control type. */
166
+ declare const OcrReferenceControlType: {
167
+ readonly CheckDigitOnly: "CheckDigitOnly";
168
+ readonly VariableLengthDigit: "VariableLengthDigit";
169
+ readonly FixedLength: "FixedLength";
170
+ };
171
+ type OcrReferenceControlType = (typeof OcrReferenceControlType)[keyof typeof OcrReferenceControlType];
172
+ /** Options controlling OCR reference parsing. */
173
+ declare class OcrReferenceOptions {
174
+ static readonly Default: OcrReferenceOptions;
175
+ static readonly VariableLengthDigit: OcrReferenceOptions;
176
+ readonly controlType: OcrReferenceControlType;
177
+ readonly allowedLengths: readonly number[];
178
+ constructor(controlType?: OcrReferenceControlType, allowedLengths?: readonly number[]);
179
+ static fixedLength(...allowedLengths: number[]): OcrReferenceOptions;
180
+ }
181
+ /**
182
+ * A Swedish OCR reference number (`OCR-nummer`), used in payment flows.
183
+ * 2–25 digits with Luhn check digit; optional length-digit and fixed-length variants.
184
+ */
185
+ declare class SwedishOcrReferenceNumber {
186
+ static readonly typeInfo: PrimitiveTypeInfo;
187
+ static readonly displayName = "OCR";
188
+ static readonly displayNameShort = "OCR";
189
+ readonly value: string;
190
+ readonly formatted: string;
191
+ readonly lengthDigit: number | null;
192
+ get length(): number;
193
+ get checkDigit(): number;
194
+ private constructor();
195
+ static tryParse(input: string | null | undefined, options?: OcrReferenceOptions): SwedishOcrReferenceNumber | null;
196
+ static tryParseVariableLengthDigit(input: string | null | undefined): SwedishOcrReferenceNumber | null;
197
+ static tryParseFixedLength(input: string | null | undefined, fixedLengths: number | readonly number[]): SwedishOcrReferenceNumber | null;
198
+ static parse(input: string, options?: OcrReferenceOptions): SwedishOcrReferenceNumber;
199
+ static isValid(input: string | null | undefined, options?: OcrReferenceOptions): boolean;
200
+ static format(input: string | null | undefined, options?: {
201
+ fallbackToTrimmedInputWhenInvalid?: boolean;
202
+ }): string | null;
203
+ static normalize(input: string | null | undefined, options?: {
204
+ fallbackToTrimmedInputWhenInvalid?: boolean;
205
+ }): string | null;
206
+ static isNormalized(input: string | null | undefined): boolean;
207
+ toNormalizedString(): string;
208
+ toDisplayString(): string;
209
+ toShortDisplayString(): string;
210
+ toString(): string;
211
+ static validate(input: string | null | undefined): ValidationResult;
212
+ static findCandidatesInText(text: string): readonly TextCandidate<SwedishOcrReferenceNumber>[];
213
+ equals(other: SwedishOcrReferenceNumber | null | undefined): boolean;
214
+ compareTo(other: SwedishOcrReferenceNumber | null | undefined): number;
215
+ }
216
+ /** Returns a fully masked OCR reference, e.g. `12345678901` → `***********`. */
217
+ declare function maskSwedishOcrReferenceNumber(ocr: SwedishOcrReferenceNumber): string;
218
+
83
219
  /**
84
220
  * Known Swedish banks, identified by clearing number ranges.
85
221
  *
@@ -220,142 +356,6 @@ declare function maskSwedishBankAccount(account: SwedishBankAccount, options?: {
220
356
  maskClearingNumber?: boolean;
221
357
  }): string;
222
358
 
223
- /**
224
- * A Swedish Bankgiro number (`bankgironummer`), e.g. `5805-6201`.
225
- * 7 or 8 digits with Luhn check digit.
226
- */
227
- declare class SwedishBankgiroNumber {
228
- static readonly typeInfo: PrimitiveTypeInfo;
229
- static readonly displayName = "Bankgiro";
230
- static readonly displayNameShort = "BG";
231
- /** Digit-only value, e.g. `58056201`. */
232
- readonly digits: string;
233
- /** Hyphenated display form, e.g. `5805-6201`. */
234
- readonly formatted: string;
235
- private constructor();
236
- static tryParse(input: string | null | undefined): SwedishBankgiroNumber | null;
237
- static parse(input: string): SwedishBankgiroNumber;
238
- static isValid(input: string | null | undefined): boolean;
239
- static format(input: string | null | undefined, options?: {
240
- fallbackToTrimmedInputWhenInvalid?: boolean;
241
- }): string | null;
242
- static normalize(input: string | null | undefined, options?: {
243
- fallbackToTrimmedInputWhenInvalid?: boolean;
244
- }): string | null;
245
- static isNormalized(input: string | null | undefined): boolean;
246
- toNormalizedString(): string;
247
- toDisplayString(): string;
248
- toShortDisplayString(): string;
249
- toString(): string;
250
- static validate(input: string | null | undefined): ValidationResult;
251
- static findCandidatesInText(text: string): readonly TextCandidate<SwedishBankgiroNumber>[];
252
- equals(other: SwedishBankgiroNumber | null | undefined): boolean;
253
- compareTo(other: SwedishBankgiroNumber | null | undefined): number;
254
- }
255
- /** Returns the Bankgirot search URL for this Bankgiro number. */
256
- declare function getBankgirotUrl(bg: SwedishBankgiroNumber): string;
257
- /**
258
- * Returns a masked Bankgiro number, e.g. `****-6201` (default) or `5805-****` when
259
- * `showLastDigits` is `false`.
260
- */
261
- declare function maskSwedishBankgiroNumber(bg: SwedishBankgiroNumber, options?: {
262
- showLastDigits?: boolean;
263
- }): string;
264
-
265
- /** OCR reference control type. */
266
- declare const OcrReferenceControlType: {
267
- readonly CheckDigitOnly: "CheckDigitOnly";
268
- readonly VariableLengthDigit: "VariableLengthDigit";
269
- readonly FixedLength: "FixedLength";
270
- };
271
- type OcrReferenceControlType = (typeof OcrReferenceControlType)[keyof typeof OcrReferenceControlType];
272
- /** Options controlling OCR reference parsing. */
273
- declare class OcrReferenceOptions {
274
- static readonly Default: OcrReferenceOptions;
275
- static readonly VariableLengthDigit: OcrReferenceOptions;
276
- readonly controlType: OcrReferenceControlType;
277
- readonly allowedLengths: readonly number[];
278
- constructor(controlType?: OcrReferenceControlType, allowedLengths?: readonly number[]);
279
- static fixedLength(...allowedLengths: number[]): OcrReferenceOptions;
280
- }
281
- /**
282
- * A Swedish OCR reference number (`OCR-nummer`), used in payment flows.
283
- * 2–25 digits with Luhn check digit; optional length-digit and fixed-length variants.
284
- */
285
- declare class SwedishOcrReferenceNumber {
286
- static readonly typeInfo: PrimitiveTypeInfo;
287
- static readonly displayName = "OCR";
288
- static readonly displayNameShort = "OCR";
289
- readonly value: string;
290
- readonly formatted: string;
291
- readonly lengthDigit: number | null;
292
- get length(): number;
293
- get checkDigit(): number;
294
- private constructor();
295
- static tryParse(input: string | null | undefined, options?: OcrReferenceOptions): SwedishOcrReferenceNumber | null;
296
- static tryParseVariableLengthDigit(input: string | null | undefined): SwedishOcrReferenceNumber | null;
297
- static tryParseFixedLength(input: string | null | undefined, fixedLengths: number | readonly number[]): SwedishOcrReferenceNumber | null;
298
- static parse(input: string, options?: OcrReferenceOptions): SwedishOcrReferenceNumber;
299
- static isValid(input: string | null | undefined, options?: OcrReferenceOptions): boolean;
300
- static format(input: string | null | undefined, options?: {
301
- fallbackToTrimmedInputWhenInvalid?: boolean;
302
- }): string | null;
303
- static normalize(input: string | null | undefined, options?: {
304
- fallbackToTrimmedInputWhenInvalid?: boolean;
305
- }): string | null;
306
- static isNormalized(input: string | null | undefined): boolean;
307
- toNormalizedString(): string;
308
- toDisplayString(): string;
309
- toShortDisplayString(): string;
310
- toString(): string;
311
- static validate(input: string | null | undefined): ValidationResult;
312
- static findCandidatesInText(text: string): readonly TextCandidate<SwedishOcrReferenceNumber>[];
313
- equals(other: SwedishOcrReferenceNumber | null | undefined): boolean;
314
- compareTo(other: SwedishOcrReferenceNumber | null | undefined): number;
315
- }
316
- /** Returns a fully masked OCR reference, e.g. `12345678901` → `***********`. */
317
- declare function maskSwedishOcrReferenceNumber(ocr: SwedishOcrReferenceNumber): string;
318
-
319
- /**
320
- * A Swedish Plusgiro number (`plusgironummer`), e.g. `1234567-9`.
321
- * 2–8 digits with Luhn check digit.
322
- */
323
- declare class SwedishPostgiroNumber {
324
- static readonly typeInfo: PrimitiveTypeInfo;
325
- static readonly displayName = "Plusgiro";
326
- static readonly displayNameShort = "PG";
327
- /** Digit-only value, e.g. `41313008`. */
328
- readonly digits: string;
329
- /** Hyphenated display form, e.g. `4131300-8`. */
330
- readonly formatted: string;
331
- private constructor();
332
- static tryParse(input: string | null | undefined): SwedishPostgiroNumber | null;
333
- static parse(input: string): SwedishPostgiroNumber;
334
- static isValid(input: string | null | undefined): boolean;
335
- static format(input: string | null | undefined, options?: {
336
- fallbackToTrimmedInputWhenInvalid?: boolean;
337
- }): string | null;
338
- static normalize(input: string | null | undefined, options?: {
339
- fallbackToTrimmedInputWhenInvalid?: boolean;
340
- }): string | null;
341
- static isNormalized(input: string | null | undefined): boolean;
342
- toNormalizedString(): string;
343
- toDisplayString(): string;
344
- toShortDisplayString(): string;
345
- toString(): string;
346
- static validate(input: string | null | undefined): ValidationResult;
347
- static findCandidatesInText(text: string): readonly TextCandidate<SwedishPostgiroNumber>[];
348
- equals(other: SwedishPostgiroNumber | null | undefined): boolean;
349
- compareTo(other: SwedishPostgiroNumber | null | undefined): number;
350
- }
351
- /**
352
- * Returns a masked Plusgiro number, e.g. `******-9` (default, showing the control digit) or
353
- * `123456-*` when `showControlDigit` is `false`.
354
- */
355
- declare function maskSwedishPostgiroNumber(pg: SwedishPostgiroNumber, options?: {
356
- showControlDigit?: boolean;
357
- }): string;
358
-
359
359
  /**
360
360
  * A Swedish Swish payment number (`Swish-nummer`).
361
361
  * Accepts: