diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..d7ab96c --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +nodejs 18.20.4 \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs index f7240c9..db5dc2a 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -16,10 +16,11 @@ export default [ { ignores: [ 'node_modules/', - 'lib/' + 'lib/', + 'coverage/' ] }, - ...compat.extends('plugin:@typescript-eslint/recommended', 'prettier'), + ...compat.extends('plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', 'prettier'), { languageOptions: { parser: tsParser, diff --git a/jest.config.js b/jest.config.js index 5709969..aba9a97 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,17 +1,22 @@ const config = { - moduleFileExtensions: ['js', 'ts'], + moduleFileExtensions: ["js", "ts"], transform: { - '^.+\\.(js|jsx|ts|tsx)$': [ - 'ts-jest', + "^.+\\.(ts|tsx)$": [ + "ts-jest", { - tsconfig: '/test/tsconfig.json' - } - ] + tsconfig: "/test/tsconfig.json", + useESM: true, + }, + ], }, - testMatch: ['**/test/**/*.test.(ts|js)'], - testEnvironment: 'node', - setupFilesAfterEnv: ['jest-extended/all'], - preset: 'ts-jest' -} + extensionsToTreatAsEsm: [".ts"], + moduleNameMapper: { + "^(\\.{1,2}/.*)\\.js$": "$1", + }, + testMatch: ["**/test/**/*.test.(ts|js)"], + testEnvironment: "node", + setupFilesAfterEnv: ["jest-extended/all"], + preset: "ts-jest", +}; -export default config \ No newline at end of file +export default config; diff --git a/package-lock.json b/package-lock.json index 586d7dc..ead9f4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,10 +22,11 @@ "@types/jest": "^29.5.13", "@types/lodash": "^4.17.7", "@types/semver": "^7.5.8", - "@typescript-eslint/eslint-plugin": "^8.5.0", - "@typescript-eslint/parser": "^8.5.0", + "@typescript-eslint/eslint-plugin": "^8.17.0", + "@typescript-eslint/parser": "^8.17.0", "copyfiles": "^2.4.1", - "eslint": "^9.10.0", + "cross-env": "^7.0.3", + "eslint": "^9.16.0", "eslint-config-prettier": "^9.1.0", "esm": "^3.2.25", "jest": "^29.7.0", @@ -33,7 +34,7 @@ "prettier": "^3.3.3", "ts-jest": "^29.2.5", "ts-node": "^10.9.2", - "typescript": "^5.6.0" + "typescript": "^5.7.2" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -757,9 +758,9 @@ "license": "MIT" }, "node_modules/@eslint/js": { - "version": "9.15.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.15.0.tgz", - "integrity": "sha512-tMTqrY+EzbXmKJR5ToI8lxu7jaN5EdmrBFJpQk5JmSlyLsx6o4t27r883K5xsLuCYCpfKBCGswMSWXsM+jB7lg==", + "version": "9.16.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.16.0.tgz", + "integrity": "sha512-tw2HxzQkrbeuvyj1tG2Yqq+0H9wGoI2IMk4EOsQeX+vmd75FtJAzf+gTA69WF+baUKRYQ3x2kbLE08js5OsTVg==", "dev": true, "license": "MIT", "engines": { @@ -1476,6 +1477,7 @@ "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", "dev": true, + "license": "MIT", "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" @@ -1489,6 +1491,7 @@ "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", "dev": true, + "license": "MIT", "engines": { "node": ">= 8" } @@ -1498,6 +1501,7 @@ "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", "dev": true, + "license": "MIT", "dependencies": { "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" @@ -1711,16 +1715,17 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.5.0.tgz", - "integrity": "sha512-lHS5hvz33iUFQKuPFGheAB84LwcJ60G8vKnEhnfcK1l8kGVLro2SFYW6K0/tj8FUhRJ0VHyg1oAfg50QGbPPHw==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.17.0.tgz", + "integrity": "sha512-HU1KAdW3Tt8zQkdvNoIijfWDMvdSweFYm4hWh+KwhPstv+sCmWb89hCIP8msFm9N1R/ooh9honpSuvqKWlYy3w==", "dev": true, + "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.5.0", - "@typescript-eslint/type-utils": "8.5.0", - "@typescript-eslint/utils": "8.5.0", - "@typescript-eslint/visitor-keys": "8.5.0", + "@typescript-eslint/scope-manager": "8.17.0", + "@typescript-eslint/type-utils": "8.17.0", + "@typescript-eslint/utils": "8.17.0", + "@typescript-eslint/visitor-keys": "8.17.0", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", @@ -1744,15 +1749,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.5.0.tgz", - "integrity": "sha512-gF77eNv0Xz2UJg/NbpWJ0kqAm35UMsvZf1GHj8D9MRFTj/V3tAciIWXfmPLsAAF/vUlpWPvUDyH1jjsr0cMVWw==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.17.0.tgz", + "integrity": "sha512-Drp39TXuUlD49F7ilHHCG7TTg8IkA+hxCuULdmzWYICxGXvDXmDmWEjJYZQYgf6l/TFfYNE167m7isnc3xlIEg==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/scope-manager": "8.5.0", - "@typescript-eslint/types": "8.5.0", - "@typescript-eslint/typescript-estree": "8.5.0", - "@typescript-eslint/visitor-keys": "8.5.0", + "@typescript-eslint/scope-manager": "8.17.0", + "@typescript-eslint/types": "8.17.0", + "@typescript-eslint/typescript-estree": "8.17.0", + "@typescript-eslint/visitor-keys": "8.17.0", "debug": "^4.3.4" }, "engines": { @@ -1772,13 +1778,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.5.0.tgz", - "integrity": "sha512-06JOQ9Qgj33yvBEx6tpC8ecP9o860rsR22hWMEd12WcTRrfaFgHr2RB/CA/B+7BMhHkXT4chg2MyboGdFGawYg==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.17.0.tgz", + "integrity": "sha512-/ewp4XjvnxaREtqsZjF4Mfn078RD/9GmiEAtTeLQ7yFdKnqwTOgRMSvFz4et9U5RiJQ15WTGXPLj89zGusvxBg==", "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.5.0", - "@typescript-eslint/visitor-keys": "8.5.0" + "@typescript-eslint/types": "8.17.0", + "@typescript-eslint/visitor-keys": "8.17.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1789,13 +1796,14 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.5.0.tgz", - "integrity": "sha512-N1K8Ix+lUM+cIDhL2uekVn/ZD7TZW+9/rwz8DclQpcQ9rk4sIL5CAlBC0CugWKREmDjBzI/kQqU4wkg46jWLYA==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.17.0.tgz", + "integrity": "sha512-q38llWJYPd63rRnJ6wY/ZQqIzPrBCkPdpIsaCfkR3Q4t3p6sb422zougfad4TFW9+ElIFLVDzWGiGAfbb/v2qw==", "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/typescript-estree": "8.5.0", - "@typescript-eslint/utils": "8.5.0", + "@typescript-eslint/typescript-estree": "8.17.0", + "@typescript-eslint/utils": "8.17.0", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -1806,6 +1814,9 @@ "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + }, "peerDependenciesMeta": { "typescript": { "optional": true @@ -1813,10 +1824,11 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.5.0.tgz", - "integrity": "sha512-qjkormnQS5wF9pjSi6q60bKUHH44j2APxfh9TQRXK8wbYVeDYYdYJGIROL87LGZZ2gz3Rbmjc736qyL8deVtdw==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.17.0.tgz", + "integrity": "sha512-gY2TVzeve3z6crqh2Ic7Cr+CAv6pfb0Egee7J5UAVWCpVvDI/F71wNfolIim4FE6hT15EbpZFVUj9j5i38jYXA==", "dev": true, + "license": "MIT", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, @@ -1826,13 +1838,14 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.5.0.tgz", - "integrity": "sha512-vEG2Sf9P8BPQ+d0pxdfndw3xIXaoSjliG0/Ejk7UggByZPKXmJmw3GW5jV2gHNQNawBUyfahoSiCFVov0Ruf7Q==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.17.0.tgz", + "integrity": "sha512-JqkOopc1nRKZpX+opvKqnM3XUlM7LpFMD0lYxTqOTKQfCWAmxw45e3qlOCsEqEB2yuacujivudOFpCnqkBDNMw==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/types": "8.5.0", - "@typescript-eslint/visitor-keys": "8.5.0", + "@typescript-eslint/types": "8.17.0", + "@typescript-eslint/visitor-keys": "8.17.0", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", @@ -1858,6 +1871,7 @@ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, + "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" } @@ -1867,6 +1881,7 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, + "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -1878,15 +1893,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.5.0.tgz", - "integrity": "sha512-6yyGYVL0e+VzGYp60wvkBHiqDWOpT63pdMV2CVG4LVDd5uR6q1qQN/7LafBZtAtNIn/mqXjsSeS5ggv/P0iECw==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.17.0.tgz", + "integrity": "sha512-bQC8BnEkxqG8HBGKwG9wXlZqg37RKSMY7v/X8VEWD8JG2JuTHuNK0VFvMPMUKQcbk6B+tf05k+4AShAEtCtJ/w==", "dev": true, + "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "8.5.0", - "@typescript-eslint/types": "8.5.0", - "@typescript-eslint/typescript-estree": "8.5.0" + "@typescript-eslint/scope-manager": "8.17.0", + "@typescript-eslint/types": "8.17.0", + "@typescript-eslint/typescript-estree": "8.17.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1897,16 +1913,22 @@ }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.5.0.tgz", - "integrity": "sha512-yTPqMnbAZJNy2Xq2XU8AdtOW9tJIr+UQb64aXB9f3B1498Zx9JorVgFJcZpEc9UBuCCrdzKID2RGAMkYcDtZOw==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.17.0.tgz", + "integrity": "sha512-1Hm7THLpO6ww5QU6H/Qp+AusUUl+z/CAm3cNZZ0jQvon9yicgO7Rwd+/WWRpMKLYV6p2UvdbR27c86rzCPpreg==", "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.5.0", - "eslint-visitor-keys": "^3.4.3" + "@typescript-eslint/types": "8.17.0", + "eslint-visitor-keys": "^4.2.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1916,6 +1938,19 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/acorn": { "version": "8.14.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", @@ -2562,6 +2597,25 @@ "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", "dev": true }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -2690,9 +2744,9 @@ } }, "node_modules/eslint": { - "version": "9.15.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.15.0.tgz", - "integrity": "sha512-7CrWySmIibCgT1Os28lUU6upBshZ+GxybLOrmRzi08kS8MBuO8QA7pXEgYgY5W8vK3e74xv0lpjo9DbaGU9Rkw==", + "version": "9.16.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.16.0.tgz", + "integrity": "sha512-whp8mSQI4C8VXd+fLgSM0lh3UlmcFtVwUQjyKCFfsp+2ItAIYhlq/hqGahGqHE6cv9unM41VlqKk2VtKYR2TaA==", "dev": true, "license": "MIT", "dependencies": { @@ -2701,7 +2755,7 @@ "@eslint/config-array": "^0.19.0", "@eslint/core": "^0.9.0", "@eslint/eslintrc": "^3.2.0", - "@eslint/js": "9.15.0", + "@eslint/js": "9.16.0", "@eslint/plugin-kit": "^0.2.3", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", @@ -3079,6 +3133,7 @@ "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dev": true, + "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -3095,6 +3150,7 @@ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, + "license": "ISC", "dependencies": { "is-glob": "^4.0.1" }, @@ -3115,16 +3171,17 @@ "dev": true }, "node_modules/fast-uri": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.1.tgz", - "integrity": "sha512-MWipKbbYiYI0UC7cl8m/i/IWTqfC8YXsqjzybjddLsFjStroQzsHXkc73JutMvBiXmOvapk+axIl79ig5t55Bw==", - "license": "MIT" + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.3.tgz", + "integrity": "sha512-aLrHthzCjH5He4Z2H9YZ+v6Ujb9ocRuW6ZzkJQOrTxleEijANq4v1TsaPaVG1PZcuurEzrLcWRyYBYXD5cEiaw==", + "license": "BSD-3-Clause" }, "node_modules/fastq": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", - "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", "dev": true, + "license": "ISC", "dependencies": { "reusify": "^1.0.4" } @@ -4773,7 +4830,8 @@ "node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "license": "MIT" }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", @@ -4913,6 +4971,7 @@ "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 8" } @@ -5354,7 +5413,8 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "license": "MIT" }, "node_modules/react-is": { "version": "18.3.1", @@ -5375,6 +5435,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -5441,6 +5502,7 @@ "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", "dev": true, + "license": "MIT", "engines": { "iojs": ">=1.0.0", "node": ">=0.10.0" @@ -5465,6 +5527,7 @@ "url": "https://feross.org/support" } ], + "license": "MIT", "dependencies": { "queue-microtask": "^1.2.2" } @@ -5872,10 +5935,11 @@ } }, "node_modules/typescript": { - "version": "5.6.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", - "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/package.json b/package.json index af2a307..6d9f868 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "lint:fix": "tsc --noEmit && eslint \"**/*.{js,ts}\" --quiet --fix", "prettier": "prettier --check \"**/*.{js,ts}\"", "prettier:fix": "prettier --write \"**/*.{js,ts}\"", - "test": "jest --coverage", + "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage", "prepublish": "tsc" }, "dependencies": { @@ -38,10 +38,11 @@ "@types/jest": "^29.5.13", "@types/lodash": "^4.17.7", "@types/semver": "^7.5.8", - "@typescript-eslint/eslint-plugin": "^8.5.0", - "@typescript-eslint/parser": "^8.5.0", + "@typescript-eslint/eslint-plugin": "^8.17.0", + "@typescript-eslint/parser": "^8.17.0", "copyfiles": "^2.4.1", - "eslint": "^9.10.0", + "cross-env": "^7.0.3", + "eslint": "^9.16.0", "eslint-config-prettier": "^9.1.0", "esm": "^3.2.25", "jest": "^29.7.0", @@ -49,6 +50,6 @@ "prettier": "^3.3.3", "ts-jest": "^29.2.5", "ts-node": "^10.9.2", - "typescript": "^5.6.0" + "typescript": "^5.7.2" } } diff --git a/src/csv.ts b/src/csv.ts index e726c0f..91010d7 100644 --- a/src/csv.ts +++ b/src/csv.ts @@ -3,7 +3,7 @@ import { SchemaVersion, CsvValidationOptions, } from "./types.js"; -import { CsvValidator } from "./validators"; +import { CsvValidator } from "./validators/CsvValidator.js"; /** * diff --git a/src/errors/ValidationError.ts b/src/errors/ValidationError.ts index f8ef548..5bcc22e 100644 --- a/src/errors/ValidationError.ts +++ b/src/errors/ValidationError.ts @@ -1,5 +1,6 @@ export class ValidationError { - public field: string | undefined + public field: string | undefined; + public warning: boolean | undefined; constructor( public path: string, @@ -7,7 +8,7 @@ export class ValidationError { ) {} withField(field: string): ValidationError { - this.field = field - return this + this.field = field; + return this; } } diff --git a/src/errors/csv/AllowedValuesError.ts b/src/errors/csv/AllowedValuesError.ts index ea244d5..f0e277c 100644 --- a/src/errors/csv/AllowedValuesError.ts +++ b/src/errors/csv/AllowedValuesError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class AllowedValuesError extends CsvValidationError { constructor( diff --git a/src/errors/csv/AmbiguousFormatError.ts b/src/errors/csv/AmbiguousFormatError.ts index a9fee57..0d46778 100644 --- a/src/errors/csv/AmbiguousFormatError.ts +++ b/src/errors/csv/AmbiguousFormatError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class AmbiguousFormatError extends CsvValidationError { constructor() { diff --git a/src/errors/csv/CodePairMissingError.ts b/src/errors/csv/CodePairMissingError.ts index 3c50392..e55c034 100644 --- a/src/errors/csv/CodePairMissingError.ts +++ b/src/errors/csv/CodePairMissingError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class CodePairMissingError extends CsvValidationError { constructor(row: number, column: number) { diff --git a/src/errors/csv/ColumnMissingError.ts b/src/errors/csv/ColumnMissingError.ts index ef4504e..3212178 100644 --- a/src/errors/csv/ColumnMissingError.ts +++ b/src/errors/csv/ColumnMissingError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class ColumnMissingError extends CsvValidationError { constructor(public columnName: string) { diff --git a/src/errors/csv/CsvValidationError.ts b/src/errors/csv/CsvValidationError.ts index 3d50d1b..11d3d14 100644 --- a/src/errors/csv/CsvValidationError.ts +++ b/src/errors/csv/CsvValidationError.ts @@ -1,4 +1,4 @@ -import { ValidationError } from "../ValidationError"; +import { ValidationError } from "../ValidationError.js"; export class CsvValidationError extends ValidationError { constructor(row: number, column: number, message: string) { diff --git a/src/errors/csv/DollarNeedsMinMaxError.ts b/src/errors/csv/DollarNeedsMinMaxError.ts index d76fd22..42e885b 100644 --- a/src/errors/csv/DollarNeedsMinMaxError.ts +++ b/src/errors/csv/DollarNeedsMinMaxError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class DollarNeedsMinMaxError extends CsvValidationError { constructor(row: number, column: number) { diff --git a/src/errors/csv/DrugInformationRequiredError.ts b/src/errors/csv/DrugInformationRequiredError.ts index 4417595..540023c 100644 --- a/src/errors/csv/DrugInformationRequiredError.ts +++ b/src/errors/csv/DrugInformationRequiredError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class DrugInformationRequiredError extends CsvValidationError { constructor(row: number, column: number) { diff --git a/src/errors/csv/DuplicateColumnError.ts b/src/errors/csv/DuplicateColumnError.ts index 814539c..e6ef49a 100644 --- a/src/errors/csv/DuplicateColumnError.ts +++ b/src/errors/csv/DuplicateColumnError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class DuplicateColumnError extends CsvValidationError { constructor( diff --git a/src/errors/csv/DuplicateHeaderColumnError.ts b/src/errors/csv/DuplicateHeaderColumnError.ts index 9ee1441..3672d0f 100644 --- a/src/errors/csv/DuplicateHeaderColumnError.ts +++ b/src/errors/csv/DuplicateHeaderColumnError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class DuplicateHeaderColumnError extends CsvValidationError { constructor( diff --git a/src/errors/csv/HeaderBlankError.ts b/src/errors/csv/HeaderBlankError.ts index 3406d81..2f7e552 100644 --- a/src/errors/csv/HeaderBlankError.ts +++ b/src/errors/csv/HeaderBlankError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class HeaderBlankError extends CsvValidationError { constructor(row: number) { diff --git a/src/errors/csv/HeaderColumnMissingError.ts b/src/errors/csv/HeaderColumnMissingError.ts index 4a3856f..05260a1 100644 --- a/src/errors/csv/HeaderColumnMissingError.ts +++ b/src/errors/csv/HeaderColumnMissingError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class HeaderColumnMissingError extends CsvValidationError { constructor(public columnName: string) { diff --git a/src/errors/csv/InvalidDateError.ts b/src/errors/csv/InvalidDateError.ts index f6d9eeb..5dcf7e2 100644 --- a/src/errors/csv/InvalidDateError.ts +++ b/src/errors/csv/InvalidDateError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class InvalidDateError extends CsvValidationError { constructor( diff --git a/src/errors/csv/InvalidNumberError.ts b/src/errors/csv/InvalidNumberError.ts index 4208a43..f398fe8 100644 --- a/src/errors/csv/InvalidNumberError.ts +++ b/src/errors/csv/InvalidNumberError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class InvalidNumberError extends CsvValidationError { constructor( diff --git a/src/errors/csv/InvalidStateCodeError.ts b/src/errors/csv/InvalidStateCodeError.ts index d163fbb..5ee4818 100644 --- a/src/errors/csv/InvalidStateCodeError.ts +++ b/src/errors/csv/InvalidStateCodeError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class InvalidStateCodeError extends CsvValidationError { constructor(column: number, stateCode: string) { diff --git a/src/errors/csv/InvalidVersionError.ts b/src/errors/csv/InvalidVersionError.ts index 6183aad..ec11cee 100644 --- a/src/errors/csv/InvalidVersionError.ts +++ b/src/errors/csv/InvalidVersionError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class InvalidVersionError extends CsvValidationError { constructor() { diff --git a/src/errors/csv/ItemRequiresChargeError.ts b/src/errors/csv/ItemRequiresChargeError.ts index a5f260a..86a21c4 100644 --- a/src/errors/csv/ItemRequiresChargeError.ts +++ b/src/errors/csv/ItemRequiresChargeError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class ItemRequiresChargeError extends CsvValidationError { constructor(row: number, column: number) { diff --git a/src/errors/csv/MinRowsError.ts b/src/errors/csv/MinRowsError.ts index c7d522e..8f12e3e 100644 --- a/src/errors/csv/MinRowsError.ts +++ b/src/errors/csv/MinRowsError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class MinRowsError extends CsvValidationError { constructor() { diff --git a/src/errors/csv/ModifierMissingInfoError.ts b/src/errors/csv/ModifierMissingInfoError.ts index 3fe2a40..1bc62ec 100644 --- a/src/errors/csv/ModifierMissingInfoError.ts +++ b/src/errors/csv/ModifierMissingInfoError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class ModifierMissingInfoError extends CsvValidationError { constructor(row: number, column: number) { diff --git a/src/errors/csv/OtherMethodologyNotesError.ts b/src/errors/csv/OtherMethodologyNotesError.ts index a3835bd..52bdc53 100644 --- a/src/errors/csv/OtherMethodologyNotesError.ts +++ b/src/errors/csv/OtherMethodologyNotesError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class OtherMethodologyNotesError extends CsvValidationError { constructor(row: number, column: number) { diff --git a/src/errors/csv/PercentageAlgorithmEstimateError.ts b/src/errors/csv/PercentageAlgorithmEstimateError.ts index 62ed224..21f6274 100644 --- a/src/errors/csv/PercentageAlgorithmEstimateError.ts +++ b/src/errors/csv/PercentageAlgorithmEstimateError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class PercentageAlgorithmEstimateError extends CsvValidationError { constructor(row: number, column: number) { diff --git a/src/errors/csv/ProblemsInHeaderError.ts b/src/errors/csv/ProblemsInHeaderError.ts index 04307c3..0617525 100644 --- a/src/errors/csv/ProblemsInHeaderError.ts +++ b/src/errors/csv/ProblemsInHeaderError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class ProblemsInHeaderError extends CsvValidationError { constructor() { diff --git a/src/errors/csv/RequiredValueError.ts b/src/errors/csv/RequiredValueError.ts index 838420b..e3f7cc5 100644 --- a/src/errors/csv/RequiredValueError.ts +++ b/src/errors/csv/RequiredValueError.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "./CsvValidationError"; +import { CsvValidationError } from "./CsvValidationError.js"; export class RequiredValueError extends CsvValidationError { constructor( diff --git a/src/errors/csv/index.ts b/src/errors/csv/index.ts index 1040f5a..f83c9d4 100644 --- a/src/errors/csv/index.ts +++ b/src/errors/csv/index.ts @@ -1,22 +1,22 @@ -export * from "./CsvValidationError"; -export * from "./AllowedValuesError"; -export * from "./AmbiguousFormatError"; -export * from "./CodePairMissingError"; -export * from "./ColumnMissingError"; -export * from "./DollarNeedsMinMaxError"; -export * from "./DrugInformationRequiredError"; -export * from "./DuplicateColumnError"; -export * from "./DuplicateHeaderColumnError"; -export * from "./HeaderBlankError"; -export * from "./HeaderColumnMissingError"; -export * from "./InvalidDateError"; -export * from "./InvalidNumberError"; -export * from "./InvalidStateCodeError"; -export * from "./InvalidVersionError"; -export * from "./ItemRequiresChargeError"; -export * from "./MinRowsError"; -export * from "./ModifierMissingInfoError"; -export * from "./OtherMethodologyNotesError"; -export * from "./PercentageAlgorithmEstimateError"; -export * from "./ProblemsInHeaderError"; -export * from "./RequiredValueError"; +export * from "./CsvValidationError.js"; +export * from "./AllowedValuesError.js"; +export * from "./AmbiguousFormatError.js"; +export * from "./CodePairMissingError.js"; +export * from "./ColumnMissingError.js"; +export * from "./DollarNeedsMinMaxError.js"; +export * from "./DrugInformationRequiredError.js"; +export * from "./DuplicateColumnError.js"; +export * from "./DuplicateHeaderColumnError.js"; +export * from "./HeaderBlankError.js"; +export * from "./HeaderColumnMissingError.js"; +export * from "./InvalidDateError.js"; +export * from "./InvalidNumberError.js"; +export * from "./InvalidStateCodeError.js"; +export * from "./InvalidVersionError.js"; +export * from "./ItemRequiresChargeError.js"; +export * from "./MinRowsError.js"; +export * from "./ModifierMissingInfoError.js"; +export * from "./OtherMethodologyNotesError.js"; +export * from "./PercentageAlgorithmEstimateError.js"; +export * from "./ProblemsInHeaderError.js"; +export * from "./RequiredValueError.js"; diff --git a/src/errors/json/InvalidJsonError.ts b/src/errors/json/InvalidJsonError.ts index ce417bb..91e114a 100644 --- a/src/errors/json/InvalidJsonError.ts +++ b/src/errors/json/InvalidJsonError.ts @@ -1,4 +1,4 @@ -import { ValidationError } from "../ValidationError"; +import { ValidationError } from "../ValidationError.js"; export class InvalidJsonError extends ValidationError { constructor(public originalError: Error) { diff --git a/src/filename.ts b/src/filename.ts index b4e2d50..67b7eb4 100644 --- a/src/filename.ts +++ b/src/filename.ts @@ -1,5 +1,5 @@ const FILENAME_RE = - /^(\d{2}\-?\d{7})(\-\d{10})?(_.+_)(standardcharges)\.(csv|json)$/i + /^(\d{2}\-?\d{7})(\-\d{10})?(_.+_)(standardcharges)\.(csv|json)$/i; /** * @@ -7,5 +7,5 @@ const FILENAME_RE = * @returns boolean indicating whether the filename is valid */ export function validateFilename(filename: string): boolean { - return FILENAME_RE.test(filename) + return FILENAME_RE.test(filename); } diff --git a/src/types.ts b/src/types.ts index 5273dc0..602577d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,5 @@ import { JsonTypes } from "@streamparser/json"; -import { ValidationError } from "./errors/ValidationError"; +import { ValidationError } from "./errors/ValidationError.js"; export const SCHEMA_VERSIONS = [ "v1.1", diff --git a/src/utils.ts b/src/utils.ts index 8326ce8..b2d4976 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,5 @@ import { ErrorObject } from "ajv"; -import { ValidationError } from "./errors/ValidationError"; +import { ValidationError } from "./errors/ValidationError.js"; export function oldAddErrorsToList( newErrors: T[], diff --git a/src/validators/BaseValidator.ts b/src/validators/BaseValidator.ts index dce5f45..87ae5fc 100644 --- a/src/validators/BaseValidator.ts +++ b/src/validators/BaseValidator.ts @@ -1,9 +1,9 @@ -import { ValidationResult } from "../types" +import { ValidationResult } from "../types.js"; export abstract class BaseValidator { abstract validate( input: File | NodeJS.ReadableStream - ): Promise + ): Promise; constructor(public fileType: "csv" | "json") {} } diff --git a/src/validators/CsvFieldTypes.ts b/src/validators/CsvFieldTypes.ts index b699293..144270d 100644 --- a/src/validators/CsvFieldTypes.ts +++ b/src/validators/CsvFieldTypes.ts @@ -1,4 +1,4 @@ -import { CsvValidationError } from "../errors/csv"; +import { CsvValidationError } from "../errors/csv/index.js"; // the function gets passed the data row and row index // but there can be things before that, which get bound in when assembling the validation tree diff --git a/src/validators/CsvValidator.ts b/src/validators/CsvValidator.ts index f89cd0c..02253fe 100644 --- a/src/validators/CsvValidator.ts +++ b/src/validators/CsvValidator.ts @@ -6,9 +6,9 @@ import { STATE_CODES, StateCode, ValidationResult, -} from "../types"; -import { BaseValidator } from "./BaseValidator"; -import { removeBOM } from "../utils"; +} from "../types.js"; +import { BaseValidator } from "./BaseValidator.js"; +import { removeBOM } from "../utils.js"; import { AllowedValuesError, AmbiguousFormatError, @@ -32,10 +32,10 @@ import { PercentageAlgorithmEstimateError, ProblemsInHeaderError, RequiredValueError, -} from "../errors/csv"; -import { range, partial } from "lodash"; +} from "../errors/csv/index.js"; import _ from "lodash"; -import { ToastyValidator } from "./CsvFieldTypes"; +const { range, partial } = _; +import { ToastyValidator } from "./CsvFieldTypes.js"; export const AFFIRMATION = "To the best of its knowledge and belief, the hospital has included all applicable standard charge information in accordance with the requirements of 45 CFR 180.50, and the information encoded is true, accurate, and complete as of the date indicated."; diff --git a/src/validators/JsonValidator.ts b/src/validators/JsonValidator.ts index cc7d115..7d1bcd1 100644 --- a/src/validators/JsonValidator.ts +++ b/src/validators/JsonValidator.ts @@ -3,15 +3,15 @@ import path from "path"; import Ajv from "ajv"; import addFormats from "ajv-formats"; import { JSONParser } from "@streamparser/json"; -import { JsonValidatorOptions, ValidationResult } from "../types"; -import { BaseValidator } from "./BaseValidator"; +import { JsonValidatorOptions, ValidationResult } from "../types.js"; +import { BaseValidator } from "./BaseValidator.js"; import { addItemsWithLimit, errorObjectToValidationError, removeBOM, -} from "../utils"; -import { ValidationError } from "../errors/ValidationError"; -import { InvalidJsonError } from "../errors/json/InvalidJsonError"; +} from "../utils.js"; +import { ValidationError } from "../errors/ValidationError.js"; +import { InvalidJsonError } from "../errors/json/InvalidJsonError.js"; export class JsonValidator extends BaseValidator { private fullSchema: any; @@ -23,7 +23,11 @@ export class JsonValidator extends BaseValidator { try { this.fullSchema = JSON.parse( fs.readFileSync( - path.join(__dirname, "..", "schemas", `${version}.json`), + // path.join(__dirname, "..", "schemas", `${version}.json`), + new URL( + path.join("..", "schemas", `${version}.json`), + import.meta.url + ), "utf-8" ) ); diff --git a/src/validators/index.ts b/src/validators/index.ts index aa92312..7d7eba0 100644 --- a/src/validators/index.ts +++ b/src/validators/index.ts @@ -1,3 +1,3 @@ -export * from "./BaseValidator"; -export * from "./CsvValidator"; -export * from "./JsonValidator"; +export * from "./BaseValidator.js"; +export * from "./CsvValidator.js"; +export * from "./JsonValidator.js"; diff --git a/src/versions/1.1/types.ts b/src/versions/1.1/types.ts index b649210..1b2a0b5 100644 --- a/src/versions/1.1/types.ts +++ b/src/versions/1.1/types.ts @@ -16,17 +16,17 @@ export const BILLING_CODE_TYPES = [ "CDT", "RC", "CDM", -] as const -type BillingCodeTypeTuple = typeof BILLING_CODE_TYPES -export type BillingCodeType = BillingCodeTypeTuple[number] +] as const; +type BillingCodeTypeTuple = typeof BILLING_CODE_TYPES; +export type BillingCodeType = BillingCodeTypeTuple[number]; -export const DRUG_UNITS = ["GR", "ME", "ML", "UN"] -type DrugUnitTuple = typeof DRUG_UNITS -export type DrugUnit = DrugUnitTuple[number] +export const DRUG_UNITS = ["GR", "ME", "ML", "UN"]; +type DrugUnitTuple = typeof DRUG_UNITS; +export type DrugUnit = DrugUnitTuple[number]; -export const CHARGE_SETTINGS = ["inpatient", "outpatient", "both"] as const -type ChargeSettingTuple = typeof CHARGE_SETTINGS -export type ChargeSetting = ChargeSettingTuple[number] +export const CHARGE_SETTINGS = ["inpatient", "outpatient", "both"] as const; +type ChargeSettingTuple = typeof CHARGE_SETTINGS; +export type ChargeSetting = ChargeSettingTuple[number]; export const CONTRACTING_METHODS = [ "case rate", @@ -34,6 +34,6 @@ export const CONTRACTING_METHODS = [ "percent of total billed charges", "per diem", "other", -] as const -type ContractingMethodTuple = typeof CONTRACTING_METHODS -export type ContractingMethod = ContractingMethodTuple[number] +] as const; +type ContractingMethodTuple = typeof CONTRACTING_METHODS; +export type ContractingMethod = ContractingMethodTuple[number]; diff --git a/src/versions/2.0/types.ts b/src/versions/2.0/types.ts index eb90f5a..7e59cf2 100644 --- a/src/versions/2.0/types.ts +++ b/src/versions/2.0/types.ts @@ -18,17 +18,17 @@ export const BILLING_CODE_TYPES = [ "RC", "CDM", "TRIS-DRG", -] as const -type BillingCodeTypeTuple = typeof BILLING_CODE_TYPES -export type BillingCodeType = BillingCodeTypeTuple[number] +] as const; +type BillingCodeTypeTuple = typeof BILLING_CODE_TYPES; +export type BillingCodeType = BillingCodeTypeTuple[number]; -export const DRUG_UNITS = ["GR", "ME", "ML", "UN", "F2", "EA", "GM"] -type DrugUnitTuple = typeof DRUG_UNITS -export type DrugUnit = DrugUnitTuple[number] +export const DRUG_UNITS = ["GR", "ME", "ML", "UN", "F2", "EA", "GM"]; +type DrugUnitTuple = typeof DRUG_UNITS; +export type DrugUnit = DrugUnitTuple[number]; -export const CHARGE_SETTINGS = ["inpatient", "outpatient", "both"] as const -type ChargeSettingTuple = typeof CHARGE_SETTINGS -export type ChargeSetting = ChargeSettingTuple[number] +export const CHARGE_SETTINGS = ["inpatient", "outpatient", "both"] as const; +type ChargeSettingTuple = typeof CHARGE_SETTINGS; +export type ChargeSetting = ChargeSettingTuple[number]; export const STANDARD_CHARGE_METHODOLOGY = [ "case rate", @@ -36,6 +36,6 @@ export const STANDARD_CHARGE_METHODOLOGY = [ "percent of total billed charges", "per diem", "other", -] as const -type StandardChargeTuple = typeof STANDARD_CHARGE_METHODOLOGY -export type StandardChargeMethod = StandardChargeTuple[number] +] as const; +type StandardChargeTuple = typeof STANDARD_CHARGE_METHODOLOGY; +export type StandardChargeMethod = StandardChargeTuple[number]; diff --git a/test/testhelpers/createFixtureStream.ts b/test/testhelpers/createFixtureStream.ts index de16fde..e7cc20e 100644 --- a/test/testhelpers/createFixtureStream.ts +++ b/test/testhelpers/createFixtureStream.ts @@ -2,8 +2,11 @@ import * as fs from "fs"; import * as path from "path"; export function createFixtureStream(fixture: string) { - return fs.createReadStream(path.join(__dirname, "..", "fixtures", fixture), { - encoding: "utf-8", - highWaterMark: 1024, - }); + return fs.createReadStream( + new URL(path.join("..", "fixtures", fixture), import.meta.url), + { + encoding: "utf-8", + highWaterMark: 1024, + } + ); } diff --git a/test/validators/CsvValidator.test.ts b/test/validators/CsvValidator.test.ts index 5cc5ae1..6395dca 100644 --- a/test/validators/CsvValidator.test.ts +++ b/test/validators/CsvValidator.test.ts @@ -5,7 +5,7 @@ import { BILLING_CODE_TYPES, CsvValidator, DRUG_UNITS, -} from "../../src/validators/CsvValidator"; +} from "../../src/validators/CsvValidator.js"; import { AllowedValuesError, AmbiguousFormatError, @@ -24,8 +24,10 @@ import { OtherMethodologyNotesError, PercentageAlgorithmEstimateError, RequiredValueError, -} from "../../src/errors/csv"; -import { shuffle } from "lodash"; +} from "../../src/errors/csv/index.js"; +// import { shuffle } from "lodash"; +import _ from "lodash"; +const { shuffle } = _; describe("CsvValidator", () => { describe("constructor", () => {}); diff --git a/test/validators/JsonValidator.test.ts b/test/validators/JsonValidator.test.ts index ff7edb7..d59c223 100644 --- a/test/validators/JsonValidator.test.ts +++ b/test/validators/JsonValidator.test.ts @@ -1,6 +1,6 @@ -import { InvalidJsonError } from "../../src/errors/json/InvalidJsonError"; -import { JsonValidator } from "../../src/validators/JsonValidator"; -import { createFixtureStream } from "../testhelpers/createFixtureStream"; +import { InvalidJsonError } from "../../src/errors/json/InvalidJsonError.js"; +import { JsonValidator } from "../../src/validators/JsonValidator.js"; +import { createFixtureStream } from "../testhelpers/createFixtureStream.js"; describe("JsonValidator", () => { describe("schema v2.0.0", () => { diff --git a/tsconfig.json b/tsconfig.json index c657ce8..76b3ef4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "esModuleInterop": true, "declaration": true, "outDir": "./lib", - "baseUrl": "./" + "baseUrl": "./", + "allowSyntheticDefaultImports": true } }