@metriport/shared 0.23.6 → 0.23.7-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/common/date.d.ts +16 -0
  2. package/dist/common/date.d.ts.map +1 -1
  3. package/dist/common/date.js +63 -1
  4. package/dist/common/date.js.map +1 -1
  5. package/dist/common/titleCase.d.ts +2 -0
  6. package/dist/common/titleCase.d.ts.map +1 -0
  7. package/dist/common/titleCase.js +10 -0
  8. package/dist/common/titleCase.js.map +1 -0
  9. package/dist/domain/address/__tests__/normalize-zip.test.d.ts +2 -0
  10. package/dist/domain/address/__tests__/normalize-zip.test.d.ts.map +1 -0
  11. package/dist/domain/address/__tests__/normalize-zip.test.js +83 -0
  12. package/dist/domain/address/__tests__/normalize-zip.test.js.map +1 -0
  13. package/dist/domain/organization.d.ts +87 -0
  14. package/dist/domain/organization.d.ts.map +1 -0
  15. package/dist/domain/organization.js +39 -0
  16. package/dist/domain/organization.js.map +1 -0
  17. package/dist/domain/patient/patient-import.d.ts +6 -6
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +1 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/interface/external/athenahealth/index.d.ts +0 -1
  23. package/dist/interface/external/athenahealth/index.d.ts.map +1 -1
  24. package/dist/interface/external/athenahealth/index.js +0 -1
  25. package/dist/interface/external/athenahealth/index.js.map +1 -1
  26. package/dist/interface/external/athenahealth/jwt-token.d.ts +11 -2
  27. package/dist/interface/external/athenahealth/jwt-token.d.ts.map +1 -1
  28. package/dist/interface/external/athenahealth/jwt-token.js +6 -1
  29. package/dist/interface/external/athenahealth/jwt-token.js.map +1 -1
  30. package/dist/interface/external/athenahealth/patient.d.ts +32 -238
  31. package/dist/interface/external/athenahealth/patient.d.ts.map +1 -1
  32. package/dist/interface/external/athenahealth/patient.js +11 -30
  33. package/dist/interface/external/athenahealth/patient.js.map +1 -1
  34. package/dist/interface/external/ehr/patient.d.ts +12 -12
  35. package/dist/interface/external/elation/patient.d.ts +18 -18
  36. package/dist/interface/external/elation/subscription.d.ts +2 -0
  37. package/dist/interface/external/elation/subscription.d.ts.map +1 -0
  38. package/dist/interface/external/elation/subscription.js +3 -0
  39. package/dist/interface/external/elation/subscription.js.map +1 -0
  40. package/dist/interface/external/shared/ehr/patient.d.ts +32 -32
  41. package/dist/interface/schema/feedback.d.ts +2 -2
  42. package/dist/medical/fhir/bundle.d.ts +3 -0
  43. package/dist/medical/fhir/bundle.d.ts.map +1 -1
  44. package/dist/medical/fhir/bundle.js.map +1 -1
  45. package/dist/util/duration.d.ts +10 -0
  46. package/dist/util/duration.d.ts.map +1 -0
  47. package/dist/util/duration.js +20 -0
  48. package/dist/util/duration.js.map +1 -0
  49. package/dist/validators/driver-license/__tests__/index.test.d.ts +2 -0
  50. package/dist/validators/driver-license/__tests__/index.test.d.ts.map +1 -0
  51. package/dist/validators/driver-license/__tests__/index.test.js +87 -0
  52. package/dist/validators/driver-license/__tests__/index.test.js.map +1 -0
  53. package/dist/validators/driver-license/ca-dl.d.ts +6 -0
  54. package/dist/validators/driver-license/ca-dl.d.ts.map +1 -0
  55. package/dist/validators/driver-license/ca-dl.js +87 -0
  56. package/dist/validators/driver-license/ca-dl.js.map +1 -0
  57. package/dist/validators/driver-license/index.d.ts +18 -0
  58. package/dist/validators/driver-license/index.d.ts.map +1 -0
  59. package/dist/validators/driver-license/index.js +86 -0
  60. package/dist/validators/driver-license/index.js.map +1 -0
  61. package/dist/validators/driver-license/interfaces.d.ts +33 -0
  62. package/dist/validators/driver-license/interfaces.d.ts.map +1 -0
  63. package/dist/validators/driver-license/interfaces.js +3 -0
  64. package/dist/validators/driver-license/interfaces.js.map +1 -0
  65. package/dist/validators/driver-license/us-dl.d.ts +6 -0
  66. package/dist/validators/driver-license/us-dl.d.ts.map +1 -0
  67. package/dist/validators/driver-license/us-dl.js +471 -0
  68. package/dist/validators/driver-license/us-dl.js.map +1 -0
  69. package/package.json +6 -2
@@ -44,10 +44,6 @@ export declare const patientSchema: z.ZodObject<{
44
44
  }, "strip", z.ZodTypeAny, {
45
45
  gender: string;
46
46
  birthDate: string;
47
- name?: {
48
- family?: string | undefined;
49
- given?: string[] | undefined;
50
- }[] | undefined;
51
47
  address?: {
52
48
  state?: string | undefined;
53
49
  city?: string | undefined;
@@ -55,6 +51,10 @@ export declare const patientSchema: z.ZodObject<{
55
51
  postalCode?: string | undefined;
56
52
  country?: string | undefined;
57
53
  }[] | undefined;
54
+ name?: {
55
+ family?: string | undefined;
56
+ given?: string[] | undefined;
57
+ }[] | undefined;
58
58
  telecom?: {
59
59
  value?: string | undefined;
60
60
  system?: "phone" | "email" | undefined;
@@ -62,10 +62,6 @@ export declare const patientSchema: z.ZodObject<{
62
62
  }, {
63
63
  gender: string;
64
64
  birthDate: string;
65
- name?: {
66
- family?: string | undefined;
67
- given?: string[] | undefined;
68
- }[] | undefined;
69
65
  address?: {
70
66
  state?: string | undefined;
71
67
  city?: string | undefined;
@@ -73,6 +69,10 @@ export declare const patientSchema: z.ZodObject<{
73
69
  postalCode?: string | undefined;
74
70
  country?: string | undefined;
75
71
  }[] | undefined;
72
+ name?: {
73
+ family?: string | undefined;
74
+ given?: string[] | undefined;
75
+ }[] | undefined;
76
76
  telecom?: {
77
77
  value?: string | undefined;
78
78
  system?: "phone" | "email" | undefined;
@@ -126,10 +126,6 @@ export declare const patientSearchSchema: z.ZodObject<{
126
126
  }, "strip", z.ZodTypeAny, {
127
127
  gender: string;
128
128
  birthDate: string;
129
- name?: {
130
- family?: string | undefined;
131
- given?: string[] | undefined;
132
- }[] | undefined;
133
129
  address?: {
134
130
  state?: string | undefined;
135
131
  city?: string | undefined;
@@ -137,6 +133,10 @@ export declare const patientSearchSchema: z.ZodObject<{
137
133
  postalCode?: string | undefined;
138
134
  country?: string | undefined;
139
135
  }[] | undefined;
136
+ name?: {
137
+ family?: string | undefined;
138
+ given?: string[] | undefined;
139
+ }[] | undefined;
140
140
  telecom?: {
141
141
  value?: string | undefined;
142
142
  system?: "phone" | "email" | undefined;
@@ -144,10 +144,6 @@ export declare const patientSearchSchema: z.ZodObject<{
144
144
  }, {
145
145
  gender: string;
146
146
  birthDate: string;
147
- name?: {
148
- family?: string | undefined;
149
- given?: string[] | undefined;
150
- }[] | undefined;
151
147
  address?: {
152
148
  state?: string | undefined;
153
149
  city?: string | undefined;
@@ -155,6 +151,10 @@ export declare const patientSearchSchema: z.ZodObject<{
155
151
  postalCode?: string | undefined;
156
152
  country?: string | undefined;
157
153
  }[] | undefined;
154
+ name?: {
155
+ family?: string | undefined;
156
+ given?: string[] | undefined;
157
+ }[] | undefined;
158
158
  telecom?: {
159
159
  value?: string | undefined;
160
160
  system?: "phone" | "email" | undefined;
@@ -164,10 +164,6 @@ export declare const patientSearchSchema: z.ZodObject<{
164
164
  resource: {
165
165
  gender: string;
166
166
  birthDate: string;
167
- name?: {
168
- family?: string | undefined;
169
- given?: string[] | undefined;
170
- }[] | undefined;
171
167
  address?: {
172
168
  state?: string | undefined;
173
169
  city?: string | undefined;
@@ -175,6 +171,10 @@ export declare const patientSearchSchema: z.ZodObject<{
175
171
  postalCode?: string | undefined;
176
172
  country?: string | undefined;
177
173
  }[] | undefined;
174
+ name?: {
175
+ family?: string | undefined;
176
+ given?: string[] | undefined;
177
+ }[] | undefined;
178
178
  telecom?: {
179
179
  value?: string | undefined;
180
180
  system?: "phone" | "email" | undefined;
@@ -184,10 +184,6 @@ export declare const patientSearchSchema: z.ZodObject<{
184
184
  resource: {
185
185
  gender: string;
186
186
  birthDate: string;
187
- name?: {
188
- family?: string | undefined;
189
- given?: string[] | undefined;
190
- }[] | undefined;
191
187
  address?: {
192
188
  state?: string | undefined;
193
189
  city?: string | undefined;
@@ -195,6 +191,10 @@ export declare const patientSearchSchema: z.ZodObject<{
195
191
  postalCode?: string | undefined;
196
192
  country?: string | undefined;
197
193
  }[] | undefined;
194
+ name?: {
195
+ family?: string | undefined;
196
+ given?: string[] | undefined;
197
+ }[] | undefined;
198
198
  telecom?: {
199
199
  value?: string | undefined;
200
200
  system?: "phone" | "email" | undefined;
@@ -206,10 +206,6 @@ export declare const patientSearchSchema: z.ZodObject<{
206
206
  resource: {
207
207
  gender: string;
208
208
  birthDate: string;
209
- name?: {
210
- family?: string | undefined;
211
- given?: string[] | undefined;
212
- }[] | undefined;
213
209
  address?: {
214
210
  state?: string | undefined;
215
211
  city?: string | undefined;
@@ -217,6 +213,10 @@ export declare const patientSearchSchema: z.ZodObject<{
217
213
  postalCode?: string | undefined;
218
214
  country?: string | undefined;
219
215
  }[] | undefined;
216
+ name?: {
217
+ family?: string | undefined;
218
+ given?: string[] | undefined;
219
+ }[] | undefined;
220
220
  telecom?: {
221
221
  value?: string | undefined;
222
222
  system?: "phone" | "email" | undefined;
@@ -228,10 +228,6 @@ export declare const patientSearchSchema: z.ZodObject<{
228
228
  resource: {
229
229
  gender: string;
230
230
  birthDate: string;
231
- name?: {
232
- family?: string | undefined;
233
- given?: string[] | undefined;
234
- }[] | undefined;
235
231
  address?: {
236
232
  state?: string | undefined;
237
233
  city?: string | undefined;
@@ -239,6 +235,10 @@ export declare const patientSearchSchema: z.ZodObject<{
239
235
  postalCode?: string | undefined;
240
236
  country?: string | undefined;
241
237
  }[] | undefined;
238
+ name?: {
239
+ family?: string | undefined;
240
+ given?: string[] | undefined;
241
+ }[] | undefined;
242
242
  telecom?: {
243
243
  value?: string | undefined;
244
244
  system?: "phone" | "email" | undefined;
@@ -9,14 +9,14 @@ export declare const createFeedbackSchema: z.ZodObject<{
9
9
  cxId: string;
10
10
  entityId: string;
11
11
  content: string;
12
- version?: string | null | undefined;
13
12
  location?: string | null | undefined;
13
+ version?: string | null | undefined;
14
14
  }, {
15
15
  cxId: string;
16
16
  entityId: string;
17
17
  content: string;
18
- version?: string | null | undefined;
19
18
  location?: string | null | undefined;
19
+ version?: string | null | undefined;
20
20
  }>;
21
21
  export type CreateFeedback = z.infer<typeof createFeedbackSchema>;
22
22
  export declare const createFeedbackEntrySchema: z.ZodObject<{
@@ -2,6 +2,9 @@ import { Bundle, Resource } from "@medplum/fhirtypes";
2
2
  export interface SearchSetBundle<T extends Resource = Resource> extends Omit<Bundle<T>, "type"> {
3
3
  type: "searchset";
4
4
  }
5
+ export interface CollectionBundle<T extends Resource = Resource> extends Omit<Bundle<T>, "type"> {
6
+ type: "collection";
7
+ }
5
8
  export declare function parseFhirBundle(value: string): Bundle | undefined;
6
9
  export declare function parseSearchsetFhirBundle(value: string): SearchSetBundle | undefined;
7
10
  export declare function toSearchSet(bundle: Bundle): SearchSetBundle;
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/medical/fhir/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,CAAE,SAAQ,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAC7F,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMjE;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAMnF;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAE3D"}
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/medical/fhir/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,CAAE,SAAQ,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAC7F,IAAI,EAAE,WAAW,CA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1
+ {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../src/medical/fhir/bundle.ts"],"names":[],"mappings":";;;AAUA,SAAgB,eAAe,CAAC,KAAa;IAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,YAAY,KAAK,QAAQ,EAAE;QAC5E,OAAO,MAAM,CAAC;KACf;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAND,0CAMC;AAED,SAAgB,wBAAwB,CAAC,KAAa;IACpD,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACtC,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE;QACzC,OAAO,MAAyB,CAAC;KAClC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAND,4DAMC;AAED,SAAgB,WAAW,CAAC,MAAc;IACxC,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC5F,CAAC;AAFD,kCAEC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Wraps a function and logs the time it took to execute it.
3
+ *
4
+ * @param fn - The function to execute.
5
+ * @param name - The name of the function to log.
6
+ * @param log - The logger to use.
7
+ * @returns The result of the function.
8
+ */
9
+ export declare function timed<T>(fn: () => Promise<T>, name: string, log: typeof console.log): Promise<T>;
10
+ //# sourceMappingURL=duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/util/duration.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAsB,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,OAAO,CAAC,GAAG,cAMzF"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.timed = void 0;
4
+ /**
5
+ * Wraps a function and logs the time it took to execute it.
6
+ *
7
+ * @param fn - The function to execute.
8
+ * @param name - The name of the function to log.
9
+ * @param log - The logger to use.
10
+ * @returns The result of the function.
11
+ */
12
+ async function timed(fn, name, log) {
13
+ const startedAt = Date.now();
14
+ const res = await fn();
15
+ const elapsedTime = Date.now() - startedAt;
16
+ log(`Done ${name} in ${elapsedTime} ms`);
17
+ return res;
18
+ }
19
+ exports.timed = timed;
20
+ //# sourceMappingURL=duration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.js","sourceRoot":"","sources":["../../src/util/duration.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACI,KAAK,UAAU,KAAK,CAAI,EAAoB,EAAE,IAAY,EAAE,GAAuB;IACxF,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,MAAM,EAAE,EAAE,CAAC;IACvB,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IAC3C,GAAG,CAAC,QAAQ,IAAI,OAAO,WAAW,KAAK,CAAC,CAAC;IACzC,OAAO,GAAG,CAAC;AACb,CAAC;AAND,sBAMC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../../src/validators/driver-license/__tests__/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_1 = require("../index");
4
+ describe("driver-license-validator", () => {
5
+ describe("isValid", () => {
6
+ it("should return true for valid driver license numbers", () => {
7
+ expect((0, index_1.isValid)("A1234567")).toBe(true);
8
+ expect((0, index_1.isValid)("123456789")).toBe(true);
9
+ expect((0, index_1.isValid)("AB12345")).toBe(true);
10
+ expect((0, index_1.isValid)("1234567")).toBe(true);
11
+ });
12
+ it("should return false for invalid driver license numbers", () => {
13
+ expect((0, index_1.isValid)("")).toBe(false);
14
+ expect((0, index_1.isValid)("invalid_dl")).toBe(false);
15
+ expect((0, index_1.isValid)("AB@123")).toBe(false); // Invalid characters
16
+ expect((0, index_1.isValid)("ABCDEFGHIJKLM")).toBe(false); // Invalid format
17
+ });
18
+ it("should filter by country", () => {
19
+ expect((0, index_1.isValid)("A1234567", { country: "CA" })).toBe(false);
20
+ expect((0, index_1.isValid)("A123456789", { country: "CA" })).toBe(true);
21
+ });
22
+ it("should filter by state", () => {
23
+ expect((0, index_1.isValid)("A1234567", { states: "CA" })).toBe(true);
24
+ expect((0, index_1.isValid)("A1234567", { states: "TX" })).toBe(false);
25
+ expect((0, index_1.isValid)("A1234567", { states: ["CA", "NY"] })).toBe(true);
26
+ });
27
+ it("should respect ignoreCase option", () => {
28
+ expect((0, index_1.isValid)("a1234567")).toBe(false);
29
+ expect((0, index_1.isValid)("a1234567", { ignoreCase: true })).toBe(true);
30
+ });
31
+ // Massachusetts driver's license formats
32
+ it("should validate Massachusetts driver's license formats", () => {
33
+ // Test the "SA + 7 numbers" format (2 letters followed by 7 numbers)
34
+ expect((0, index_1.isValid)("SA1234567", { states: "MA" })).toBe(true);
35
+ expect((0, index_1.isValid)("S12345678", { states: "MA" })).toBe(true);
36
+ expect((0, index_1.isValid)("123456789", { states: "MA" })).toBe(true);
37
+ expect((0, index_1.isValid)("S123456", { states: "MA" })).toBe(false); // Invalid format for MA
38
+ });
39
+ });
40
+ describe("getMatches", () => {
41
+ it("should return matching formats for valid driver license numbers", () => {
42
+ const matches = (0, index_1.getMatches)("A1234567");
43
+ expect(matches).not.toBeNull();
44
+ if (matches) {
45
+ expect(Array.isArray(matches)).toBe(true);
46
+ expect(matches.length).toBeGreaterThan(0);
47
+ const caMatch = matches.find(m => m.state === "CA");
48
+ expect(caMatch).toBeDefined();
49
+ if (caMatch) {
50
+ expect(caMatch.description).toBe("1 letter followed by 7 numbers");
51
+ }
52
+ }
53
+ });
54
+ it("should return null for invalid driver license numbers", () => {
55
+ expect((0, index_1.getMatches)("invalid_dl")).toBeNull();
56
+ });
57
+ it("should filter matches by country", () => {
58
+ const matches = (0, index_1.getMatches)("A123456789", { country: "CA" });
59
+ expect(matches).not.toBeNull();
60
+ if (matches) {
61
+ matches.forEach(match => {
62
+ expect(["AB", "BC", "MB", "NB", "NL", "NT", "NS", "NU", "ON", "PE", "QC", "SK", "YT"]).toContain(match.state);
63
+ });
64
+ }
65
+ });
66
+ it("should filter matches by state", () => {
67
+ const matches = (0, index_1.getMatches)("A1234567", { states: "CA" });
68
+ expect(matches).not.toBeNull();
69
+ if (matches) {
70
+ expect(matches.length).toBe(1);
71
+ const firstMatch = matches[0];
72
+ expect(firstMatch.state).toBe("CA");
73
+ }
74
+ const multiMatches = (0, index_1.getMatches)("A1234567", { states: ["CA", "NY"] });
75
+ expect(multiMatches).not.toBeNull();
76
+ if (multiMatches) {
77
+ expect(multiMatches.length).toBe(2);
78
+ const stateList = multiMatches.map(m => m.state).sort();
79
+ expect(stateList).toEqual(["CA", "NY"]);
80
+ }
81
+ });
82
+ it("should throw an error for invalid state", () => {
83
+ expect(() => (0, index_1.getMatches)("A1234567", { states: "XX" })).toThrow();
84
+ });
85
+ });
86
+ });
87
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../../../src/validators/driver-license/__tests__/index.test.ts"],"names":[],"mappings":";;AAAA,oCAA+C;AAG/C,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;QACvB,EAAE,CAAC,qDAAqD,EAAE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MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;aACzC;QACH,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;YACjD,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,kBAAU,EAAC,UAAU,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACnE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { CountryFormats } from './interfaces';
2
+ /**
3
+ * Canada driver license formats.
4
+ */
5
+ export declare const CA_DL: CountryFormats;
6
+ //# sourceMappingURL=ca-dl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ca-dl.d.ts","sourceRoot":"","sources":["../../../src/validators/driver-license/ca-dl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,KAAK,EAAE,cA+EnB,CAAC"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CA_DL = void 0;
4
+ /**
5
+ * Canada driver license formats.
6
+ */
7
+ exports.CA_DL = {
8
+ AB: [
9
+ {
10
+ regex: /^[0-9]{9}$/,
11
+ description: '9 numbers',
12
+ },
13
+ ],
14
+ BC: [
15
+ {
16
+ regex: /^[0-9]{7}$/,
17
+ description: '7 numbers',
18
+ },
19
+ ],
20
+ MB: [
21
+ {
22
+ regex: /^[A-Z0-9]{12}$/,
23
+ description: 'any combination of letters or numbers for a total of 12 characters',
24
+ },
25
+ ],
26
+ NB: [
27
+ {
28
+ regex: /^[0-9]{5,7}$/,
29
+ description: '5-7 numbers',
30
+ },
31
+ ],
32
+ NL: [
33
+ {
34
+ regex: /^[A-Z]{1}[0-9]{9}$/,
35
+ description: '1 letter followed by 9 numbers',
36
+ },
37
+ ],
38
+ NT: [
39
+ {
40
+ regex: /^[0-9]{6}$/,
41
+ description: '6 numbers',
42
+ },
43
+ ],
44
+ NS: [
45
+ {
46
+ regex: /^[A-Z]{5}[0-9]{9}$/,
47
+ description: '5 letters followed by 9 numbers',
48
+ },
49
+ ],
50
+ NU: [
51
+ {
52
+ regex: /^[0-9]{9}$/,
53
+ description: '9 numbers',
54
+ },
55
+ ],
56
+ ON: [
57
+ {
58
+ regex: /^[A-Z]{1}[0-9]{14}$/,
59
+ description: '1 letter followed by 14 numbers',
60
+ },
61
+ ],
62
+ PE: [
63
+ {
64
+ regex: /^[0-9]{5,6}$/,
65
+ description: '5-6 numbers',
66
+ },
67
+ ],
68
+ QC: [
69
+ {
70
+ regex: /^[A-Z]{1}[0-9]{12}$/,
71
+ description: '1 letter followed by 12 numbers',
72
+ },
73
+ ],
74
+ SK: [
75
+ {
76
+ regex: /^[0-9]{8}$/,
77
+ description: '8 numbers',
78
+ },
79
+ ],
80
+ YT: [
81
+ {
82
+ regex: /^[0-9]{10}$/,
83
+ description: '10 numbers',
84
+ },
85
+ ],
86
+ };
87
+ //# sourceMappingURL=ca-dl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ca-dl.js","sourceRoot":"","sources":["../../../src/validators/driver-license/ca-dl.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACU,QAAA,KAAK,GAAmB;IACnC,EAAE,EAAE;QACF;YACE,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,WAAW;SACzB;KACF;IACD,EAAE,EAAE;QACF;YACE,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,WAAW;SACzB;KACF;IACD,EAAE,EAAE;QACF;YACE,KAAK,EAAE,gBAAgB;YACvB,WAAW,EAAE,oEAAoE;SAClF;KACF;IACD,EAAE,EAAE;QACF;YACE,KAAK,EAAE,cAAc;YACrB,WAAW,EAAE,aAAa;SAC3B;KACF;IACD,EAAE,EAAE;QACF;YACE,KAAK,EAAE,oBAAoB;YAC3B,WAAW,EAAE,gCAAgC;SAC9C;KACF;IACD,EAAE,EAAE;QACF;YACE,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,WAAW;SACzB;KACF;IACD,EAAE,EAAE;QACF;YACE,KAAK,EAAE,oBAAoB;YAC3B,WAAW,EAAE,iCAAiC;SAC/C;KACF;IACD,EAAE,EAAE;QACF;YACE,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,WAAW;SACzB;KACF;IACD,EAAE,EAAE;QACF;YACE,KAAK,EAAE,qBAAqB;YAC5B,WAAW,EAAE,iCAAiC;SAC/C;KACF;IACD,EAAE,EAAE;QACF;YACE,KAAK,EAAE,cAAc;YACrB,WAAW,EAAE,aAAa;SAC3B;KACF;IACD,EAAE,EAAE;QACF;YACE,KAAK,EAAE,qBAAqB;YAC5B,WAAW,EAAE,iCAAiC;SAC/C;KACF;IACD,EAAE,EAAE;QACF;YACE,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,WAAW;SACzB;KACF;IACD,EAAE,EAAE;QACF;YACE,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,YAAY;SAC1B;KACF;CACF,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { ValidateOptions, ValidationMatch } from "./interfaces";
2
+ /**
3
+ * Validates if a driver license number is valid.
4
+ *
5
+ * @param dl Driver license number
6
+ * @param options Validation options
7
+ * @returns True if valid, false otherwise
8
+ */
9
+ export declare function isValid(dl: string, options?: ValidateOptions): boolean;
10
+ /**
11
+ * Gets all matching formats for a driver license number.
12
+ *
13
+ * @param dl Driver license number
14
+ * @param options Validation options
15
+ * @returns Array of matching formats or null if no matches
16
+ */
17
+ export declare function getMatches(dl: string, options?: ValidateOptions): ValidationMatch[] | null;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/validators/driver-license/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAWhE;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,WAGhE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,4BA0DnE"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMatches = exports.isValid = void 0;
4
+ const us_dl_1 = require("./us-dl");
5
+ const ca_dl_1 = require("./ca-dl");
6
+ const metriport_error_1 = require("../../error/metriport-error");
7
+ /**
8
+ * Supported countries.
9
+ */
10
+ const COUNTRIES = {
11
+ US: us_dl_1.US_DL,
12
+ CA: ca_dl_1.CA_DL,
13
+ };
14
+ /**
15
+ * Validates if a driver license number is valid.
16
+ *
17
+ * @param dl Driver license number
18
+ * @param options Validation options
19
+ * @returns True if valid, false otherwise
20
+ */
21
+ function isValid(dl, options = {}) {
22
+ const result = getMatches(dl, options);
23
+ return result !== null && result.length > 0;
24
+ }
25
+ exports.isValid = isValid;
26
+ /**
27
+ * Gets all matching formats for a driver license number.
28
+ *
29
+ * @param dl Driver license number
30
+ * @param options Validation options
31
+ * @returns Array of matching formats or null if no matches
32
+ */
33
+ function getMatches(dl, options = {}) {
34
+ if (!dl) {
35
+ return null;
36
+ }
37
+ const country = options.country || "US";
38
+ const countryFormats = COUNTRIES[country];
39
+ if (!countryFormats) {
40
+ throw new metriport_error_1.MetriportError(`Country ${country} not supported`, undefined, { country });
41
+ }
42
+ // Filter by state if provided
43
+ let states = [];
44
+ if (options.states) {
45
+ if (typeof options.states === "string") {
46
+ states = [options.states];
47
+ }
48
+ else {
49
+ states = options.states;
50
+ }
51
+ // Validate states
52
+ for (const state of states) {
53
+ if (!countryFormats[state]) {
54
+ throw new metriport_error_1.MetriportError(`State ${state} not supported for country ${country}`, undefined, {
55
+ state,
56
+ country,
57
+ });
58
+ }
59
+ }
60
+ }
61
+ else {
62
+ // Use all states if not specified
63
+ states = Object.keys(countryFormats);
64
+ }
65
+ const matches = [];
66
+ // Check each state
67
+ for (const state of states) {
68
+ const stateFormats = countryFormats[state];
69
+ if (!stateFormats)
70
+ continue;
71
+ // Check each format for the state
72
+ for (const format of stateFormats) {
73
+ const regex = options.ignoreCase ? new RegExp(format.regex.source, "i") : format.regex;
74
+ if (regex.test(dl)) {
75
+ matches.push({
76
+ state,
77
+ description: format.description,
78
+ });
79
+ break; // Found a match for this state, move to next state
80
+ }
81
+ }
82
+ }
83
+ return matches.length > 0 ? matches : null;
84
+ }
85
+ exports.getMatches = getMatches;
86
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validators/driver-license/index.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAChC,mCAAgC;AAEhC,iEAA6D;AAE7D;;GAEG;AACH,MAAM,SAAS,GAAG;IAChB,EAAE,EAAE,aAAK;IACT,EAAE,EAAE,aAAK;CACV,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,OAAO,CAAC,EAAU,EAAE,UAA2B,EAAE;IAC/D,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACvC,OAAO,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9C,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,EAAU,EAAE,UAA2B,EAAE;IAClE,IAAI,CAAC,EAAE,EAAE;QACP,OAAO,IAAI,CAAC;KACb;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC;IACxC,MAAM,cAAc,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAE1C,IAAI,CAAC,cAAc,EAAE;QACnB,MAAM,IAAI,gCAAc,CAAC,WAA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H,MAAM,CAAC,mDAAmD;aAC3D;SACF;KACF;IAED,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC;AA1DD,gCA0DC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Country formats.
3
+ */
4
+ export interface CountryFormats {
5
+ [index: string]: DriverLicenseFormat[];
6
+ }
7
+ /**
8
+ * Driver license format.
9
+ */
10
+ export interface DriverLicenseFormat {
11
+ regex: RegExp;
12
+ description: string;
13
+ }
14
+ /**
15
+ * Validation match results.
16
+ */
17
+ export interface ValidationMatch {
18
+ state: string;
19
+ description: string;
20
+ }
21
+ /**
22
+ * Supported country codes.
23
+ */
24
+ export type CountryCode = 'US' | 'CA';
25
+ /**
26
+ * Validate options.
27
+ */
28
+ export interface ValidateOptions {
29
+ country?: CountryCode;
30
+ states?: string | string[];
31
+ ignoreCase?: boolean;
32
+ }
33
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/validators/driver-license/interfaces.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,CAAC,KAAK,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/validators/driver-license/interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { CountryFormats } from './interfaces';
2
+ /**
3
+ * USA driver license formats.
4
+ */
5
+ export declare const US_DL: CountryFormats;
6
+ //# sourceMappingURL=us-dl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"us-dl.d.ts","sourceRoot":"","sources":["../../../src/validators/driver-license/us-dl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,KAAK,EAAE,cA+cnB,CAAC"}