@metriport/shared 0.7.4 → 0.7.5
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/common/__tests__/normalize-zip.test.d.ts +2 -0
- package/dist/common/__tests__/normalize-zip.test.d.ts.map +1 -0
- package/dist/common/__tests__/normalize-zip.test.js +38 -0
- package/dist/common/__tests__/normalize-zip.test.js.map +1 -0
- package/dist/common/normalize-zip.d.ts +10 -0
- package/dist/common/normalize-zip.d.ts.map +1 -0
- package/dist/common/normalize-zip.js +30 -0
- package/dist/common/normalize-zip.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-zip.test.d.ts","sourceRoot":"","sources":["../../../src/common/__tests__/normalize-zip.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const normalize_zip_1 = require("../normalize-zip");
|
|
4
|
+
describe("normalizeZipCode", () => {
|
|
5
|
+
test("should handle short zip codes", () => {
|
|
6
|
+
const input = "1234";
|
|
7
|
+
const expectedOutput = "1234";
|
|
8
|
+
expect((0, normalize_zip_1.normalizeZipCode)(input)).toBe(expectedOutput);
|
|
9
|
+
});
|
|
10
|
+
test("should return first 4 characters when zip code length is 9", () => {
|
|
11
|
+
const input = "1234-6677";
|
|
12
|
+
const expectedOutput = "1234";
|
|
13
|
+
expect((0, normalize_zip_1.normalizeZipCode)(input)).toBe(expectedOutput);
|
|
14
|
+
});
|
|
15
|
+
test("should return first 5 characters when zip code length is 10", () => {
|
|
16
|
+
const input = "12345-6677";
|
|
17
|
+
const expectedOutput = "12345";
|
|
18
|
+
expect((0, normalize_zip_1.normalizeZipCode)(input)).toBe(expectedOutput);
|
|
19
|
+
});
|
|
20
|
+
test("should return first 5 characters when zip code length is 5", () => {
|
|
21
|
+
const input = "54321";
|
|
22
|
+
const expectedOutput = "54321";
|
|
23
|
+
expect((0, normalize_zip_1.normalizeZipCode)(input)).toBe(expectedOutput);
|
|
24
|
+
});
|
|
25
|
+
test("should throw an error if zip contains non-digit and non-dash characters (length 9)", () => {
|
|
26
|
+
const input = "12345-667a";
|
|
27
|
+
expect(() => (0, normalize_zip_1.normalizeZipCode)(input)).toThrow();
|
|
28
|
+
});
|
|
29
|
+
test("should throw an error if zip contains non-digit and non-dash characters (length 5)", () => {
|
|
30
|
+
const input = "1234a";
|
|
31
|
+
expect(() => (0, normalize_zip_1.normalizeZipCode)(input)).toThrow();
|
|
32
|
+
});
|
|
33
|
+
test("should throw an error if zip is an empty string", () => {
|
|
34
|
+
const input = "";
|
|
35
|
+
expect(() => (0, normalize_zip_1.normalizeZipCode)(input)).toThrow();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=normalize-zip.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-zip.test.js","sourceRoot":"","sources":["../../../src/common/__tests__/normalize-zip.test.ts"],"names":[],"mappings":";;AAAA,oDAAoD;AAEpD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,IAAI,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACzC,MAAM,KAAK,GAAG,MAAM,CAAC;QACrB,MAAM,cAAc,GAAG,MAAM,CAAC;QAC9B,MAAM,CAAC,IAAA,gCAAgB,EAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACtE,MAAM,KAAK,GAAG,WAAW,CAAC;QAC1B,MAAM,cAAc,GAAG,MAAM,CAAC;QAC9B,MAAM,CAAC,IAAA,gCAAgB,EAAC,KAAK,CAAC,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Normalizes a zip code by taking the first 4-5 characters.
|
|
3
|
+
* @param zipCode - The zip code to be normalized.
|
|
4
|
+
* @returns The normalized zip code as a string.
|
|
5
|
+
*
|
|
6
|
+
* TODO: Refactor, so `normalize` simply returns a zip of a certain format and returns undefined if it cannot,
|
|
7
|
+
* while `validate` would throw an error.
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeZipCode(zipCode: string): string;
|
|
10
|
+
//# sourceMappingURL=normalize-zip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-zip.d.ts","sourceRoot":"","sources":["../../src/common/normalize-zip.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQxD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeZipCode = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Normalizes a zip code by taking the first 4-5 characters.
|
|
6
|
+
* @param zipCode - The zip code to be normalized.
|
|
7
|
+
* @returns The normalized zip code as a string.
|
|
8
|
+
*
|
|
9
|
+
* TODO: Refactor, so `normalize` simply returns a zip of a certain format and returns undefined if it cannot,
|
|
10
|
+
* while `validate` would throw an error.
|
|
11
|
+
*/
|
|
12
|
+
function normalizeZipCode(zipCode) {
|
|
13
|
+
const trimmedZip = zipCode.trim();
|
|
14
|
+
if (!isValidZipCode(trimmedZip)) {
|
|
15
|
+
throw new Error("Zip codes may only contain numbers (0-9) and a dash (-)");
|
|
16
|
+
}
|
|
17
|
+
if (trimmedZip.includes("-") && trimmedZip.trim().length === 9)
|
|
18
|
+
return trimmedZip.slice(0, 4);
|
|
19
|
+
if (trimmedZip.trim().length === 8)
|
|
20
|
+
return trimmedZip.slice(0, 4);
|
|
21
|
+
return trimmedZip.slice(0, 5);
|
|
22
|
+
}
|
|
23
|
+
exports.normalizeZipCode = normalizeZipCode;
|
|
24
|
+
function isValidZipCode(zipCode) {
|
|
25
|
+
if (zipCode.length === 0)
|
|
26
|
+
return false;
|
|
27
|
+
const regex = /^[0-9-]+$/;
|
|
28
|
+
return regex.test(zipCode);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=normalize-zip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-zip.js","sourceRoot":"","sources":["../../src/common/normalize-zip.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAAC,OAAe;IAC9C,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAClC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;KAC5E;IACD,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9F,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAClE,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAChC,CAAC;AARD,4CAQC;AAED,SAAS,cAAc,CAAC,OAAe;IACrC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACvC,MAAM,KAAK,GAAG,WAAW,CAAC;IAC1B,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ export { optionalDateSchema } from "./common/date";
|
|
|
2
2
|
export { getDomainFromEmailWithoutTld } from "./common/email";
|
|
3
3
|
export { errorToString } from "./common/error";
|
|
4
4
|
export { emptyFunction } from "./common/general";
|
|
5
|
+
export { metriportOrganization } from "./common/metriport-organization";
|
|
5
6
|
export { normalizeOid } from "./common/normalize-oid";
|
|
7
|
+
export { normalizeZipCode } from "./common/normalize-zip";
|
|
6
8
|
export { PurposeOfUse } from "./common/purpose-of-use";
|
|
7
9
|
export { executeWithRetries, executeWithRetriesOrFail } from "./common/retry";
|
|
8
10
|
export { sleep } from "./common/sleep";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.metriportCompanyDetails = exports.validateNPI = exports.stringToBoolean = exports.limitStringLength = exports.sleep = exports.executeWithRetriesOrFail = exports.executeWithRetries = exports.PurposeOfUse = exports.normalizeOid = exports.emptyFunction = exports.errorToString = exports.getDomainFromEmailWithoutTld = exports.optionalDateSchema = void 0;
|
|
3
|
+
exports.metriportCompanyDetails = exports.validateNPI = exports.stringToBoolean = exports.limitStringLength = exports.sleep = exports.executeWithRetriesOrFail = exports.executeWithRetries = exports.PurposeOfUse = exports.normalizeZipCode = exports.normalizeOid = exports.metriportOrganization = exports.emptyFunction = exports.errorToString = exports.getDomainFromEmailWithoutTld = exports.optionalDateSchema = void 0;
|
|
4
4
|
var date_1 = require("./common/date");
|
|
5
5
|
Object.defineProperty(exports, "optionalDateSchema", { enumerable: true, get: function () { return date_1.optionalDateSchema; } });
|
|
6
6
|
var email_1 = require("./common/email");
|
|
@@ -9,8 +9,12 @@ var error_1 = require("./common/error");
|
|
|
9
9
|
Object.defineProperty(exports, "errorToString", { enumerable: true, get: function () { return error_1.errorToString; } });
|
|
10
10
|
var general_1 = require("./common/general");
|
|
11
11
|
Object.defineProperty(exports, "emptyFunction", { enumerable: true, get: function () { return general_1.emptyFunction; } });
|
|
12
|
+
var metriport_organization_1 = require("./common/metriport-organization");
|
|
13
|
+
Object.defineProperty(exports, "metriportOrganization", { enumerable: true, get: function () { return metriport_organization_1.metriportOrganization; } });
|
|
12
14
|
var normalize_oid_1 = require("./common/normalize-oid");
|
|
13
15
|
Object.defineProperty(exports, "normalizeOid", { enumerable: true, get: function () { return normalize_oid_1.normalizeOid; } });
|
|
16
|
+
var normalize_zip_1 = require("./common/normalize-zip");
|
|
17
|
+
Object.defineProperty(exports, "normalizeZipCode", { enumerable: true, get: function () { return normalize_zip_1.normalizeZipCode; } });
|
|
14
18
|
var purpose_of_use_1 = require("./common/purpose-of-use");
|
|
15
19
|
Object.defineProperty(exports, "PurposeOfUse", { enumerable: true, get: function () { return purpose_of_use_1.PurposeOfUse; } });
|
|
16
20
|
var retry_1 = require("./common/retry");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sCAAmD;AAA1C,0GAAA,kBAAkB,OAAA;AAC3B,wCAA8D;AAArD,qHAAA,4BAA4B,OAAA;AACrC,wCAA+C;AAAtC,sGAAA,aAAa,OAAA;AACtB,4CAAiD;AAAxC,wGAAA,aAAa,OAAA;AACtB,wDAAsD;AAA7C,6GAAA,YAAY,OAAA;AACrB,0DAAuD;AAA9C,8GAAA,YAAY,OAAA;AACrB,wCAA8E;AAArE,2GAAA,kBAAkB,OAAA;AAAE,iHAAA,wBAAwB,OAAA;AACrD,wCAAuC;AAA9B,8FAAA,KAAK,OAAA;AACd,0CAAoD;AAA3C,2GAAA,iBAAiB,OAAA;AAC1B,wCAA6D;AAAxC,wGAAA,eAAe,OAAA;AACpC,sDAAoD;AAA3C,2GAAA,WAAW,OAAA;AACpB,gDAA6D;AAApD,oHAAA,uBAAuB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sCAAmD;AAA1C,0GAAA,kBAAkB,OAAA;AAC3B,wCAA8D;AAArD,qHAAA,4BAA4B,OAAA;AACrC,wCAA+C;AAAtC,sGAAA,aAAa,OAAA;AACtB,4CAAiD;AAAxC,wGAAA,aAAa,OAAA;AACtB,0EAAwE;AAA/D,+HAAA,qBAAqB,OAAA;AAC9B,wDAAsD;AAA7C,6GAAA,YAAY,OAAA;AACrB,wDAA0D;AAAjD,iHAAA,gBAAgB,OAAA;AACzB,0DAAuD;AAA9C,8GAAA,YAAY,OAAA;AACrB,wCAA8E;AAArE,2GAAA,kBAAkB,OAAA;AAAE,iHAAA,wBAAwB,OAAA;AACrD,wCAAuC;AAA9B,8FAAA,KAAK,OAAA;AACd,0CAAoD;AAA3C,2GAAA,iBAAiB,OAAA;AAC1B,wCAA6D;AAAxC,wGAAA,eAAe,OAAA;AACpC,sDAAoD;AAA3C,2GAAA,WAAW,OAAA;AACpB,gDAA6D;AAApD,oHAAA,uBAAuB,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metriport/shared",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "Common code shared across packages - by Metriport Inc.",
|
|
5
5
|
"author": "Metriport Inc. <contact@metriport.com>",
|
|
6
6
|
"homepage": "https://metriport.com/",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@faker-js/faker": "^8.0.2"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "55f1014f7d7c0de798010861981bc50774a06442"
|
|
58
58
|
}
|