@ellipticltd/aml-utils 0.15.18 → 0.15.20

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 (67) hide show
  1. package/.eslintrc.js +22 -0
  2. package/dist/libs/aml-utils/libs/aml-utils/README.md +19 -0
  3. package/jest.config.ts +13 -0
  4. package/lib/errors/errors.js +30 -19
  5. package/lib/errors/errors.spec.js +49 -0
  6. package/lib/file-parser/__tests/parse-row.spec.js +34 -0
  7. package/lib/file-parser/__tests/sanitize-rows.spec.js +85 -0
  8. package/lib/file-parser/errors.ts +6 -0
  9. package/lib/file-parser/file-parser.ts +67 -0
  10. package/lib/file-parser/parse-row.ts +46 -0
  11. package/lib/file-parser/sanitizeRows.ts +22 -0
  12. package/lib/formatting/formatting.js +12 -11
  13. package/lib/formatting/formatting.spec.js +47 -0
  14. package/lib/{index.d.ts → index.ts} +1 -0
  15. package/lib/middleware/middleware.js +17 -14
  16. package/lib/orm-helpers/ormHelpers.js +9 -7
  17. package/lib/orm-helpers/ormHelpers.spec.js +47 -0
  18. package/lib/structured-file-parser/errors.ts +25 -0
  19. package/lib/structured-file-parser/parse-row.ts +46 -0
  20. package/lib/structured-file-parser/sanitize-rows.ts +17 -0
  21. package/lib/structured-file-parser/structured-file-parser.ts +129 -0
  22. package/lib/types/types.js +200 -190
  23. package/lib/validations/validations.js +465 -444
  24. package/lib/validations/validations.spec.js +869 -0
  25. package/package.json +1 -16
  26. package/project.json +55 -0
  27. package/tsconfig.json +13 -0
  28. package/tsconfig.lib.json +13 -0
  29. package/tsconfig.spec.json +10 -0
  30. package/lib/errors/errors.d.ts +0 -9
  31. package/lib/errors/errors.js.map +0 -1
  32. package/lib/file-parser/errors.d.ts +0 -3
  33. package/lib/file-parser/errors.js +0 -11
  34. package/lib/file-parser/errors.js.map +0 -1
  35. package/lib/file-parser/file-parser.d.ts +0 -6
  36. package/lib/file-parser/file-parser.js +0 -60
  37. package/lib/file-parser/file-parser.js.map +0 -1
  38. package/lib/file-parser/parse-row.d.ts +0 -2
  39. package/lib/file-parser/parse-row.js +0 -40
  40. package/lib/file-parser/parse-row.js.map +0 -1
  41. package/lib/file-parser/sanitizeRows.d.ts +0 -5
  42. package/lib/file-parser/sanitizeRows.js +0 -15
  43. package/lib/file-parser/sanitizeRows.js.map +0 -1
  44. package/lib/formatting/formatting.d.ts +0 -2
  45. package/lib/formatting/formatting.js.map +0 -1
  46. package/lib/index.js +0 -21
  47. package/lib/index.js.map +0 -1
  48. package/lib/middleware/middleware.d.ts +0 -4
  49. package/lib/middleware/middleware.js.map +0 -1
  50. package/lib/orm-helpers/ormHelpers.d.ts +0 -1
  51. package/lib/orm-helpers/ormHelpers.js.map +0 -1
  52. package/lib/structured-file-parser/errors.d.ts +0 -12
  53. package/lib/structured-file-parser/errors.js +0 -33
  54. package/lib/structured-file-parser/errors.js.map +0 -1
  55. package/lib/structured-file-parser/parse-row.d.ts +0 -2
  56. package/lib/structured-file-parser/parse-row.js +0 -40
  57. package/lib/structured-file-parser/parse-row.js.map +0 -1
  58. package/lib/structured-file-parser/sanitize-rows.d.ts +0 -2
  59. package/lib/structured-file-parser/sanitize-rows.js +0 -14
  60. package/lib/structured-file-parser/sanitize-rows.js.map +0 -1
  61. package/lib/structured-file-parser/structured-file-parser.d.ts +0 -10
  62. package/lib/structured-file-parser/structured-file-parser.js +0 -96
  63. package/lib/structured-file-parser/structured-file-parser.js.map +0 -1
  64. package/lib/types/types.d.ts +0 -17
  65. package/lib/types/types.js.map +0 -1
  66. package/lib/validations/validations.d.ts +0 -240
  67. package/lib/validations/validations.js.map +0 -1
package/package.json CHANGED
@@ -1,19 +1,4 @@
1
1
  {
2
2
  "name": "@ellipticltd/aml-utils",
3
- "version": "0.15.18",
4
- "main": "./lib/index.js",
5
- "types": "./lib/index.d.ts",
6
- "dependencies": {
7
- "create-error": "0.3.1",
8
- "lodash": "4.17.21",
9
- "type-check": "0.3.2",
10
- "validator": "10.10.0",
11
- "bitcore-lib": "8.25.47",
12
- "multicoin-address-validator": "0.5.12",
13
- "@zilliqa-js/util": "0.8.8",
14
- "web3-utils": "1.0.0",
15
- "stellar-sdk": "4.0.2",
16
- "tslib": "2.5.0"
17
- },
18
- "peerDependencies": {}
3
+ "version": "0.15.20"
19
4
  }
package/project.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "aml-utils",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "libs/aml-utils/lib",
5
+ "projectType": "library",
6
+ "targets": {
7
+ "build": {
8
+ "executor": "@nrwl/js:tsc",
9
+ "outputs": ["{options.outputPath}"],
10
+ "options": {
11
+ "outputPath": "dist/libs/aml-utils",
12
+ "main": "libs/aml-utils/lib/index.ts",
13
+ "packageJson": "libs/aml-utils/package.json",
14
+ "tsConfig": "libs/aml-utils/tsconfig.lib.json",
15
+ "assets": ["libs/aml-utils/*.md"],
16
+ "updateBuildableProjectDepsInPackageJson": true,
17
+ "buildableProjectDepsInPackageJsonType": "dependencies"
18
+ }
19
+ },
20
+ "lint": {
21
+ "executor": "@nx/linter:eslint",
22
+ "outputs": ["{options.outputFile}"],
23
+ "options": {
24
+ "lintFilePatterns": ["libs/aml-utils/**/*.{ts,tsx,js,jsx}"]
25
+ }
26
+ },
27
+ "lint:fix": {
28
+ "executor": "@nx/linter:eslint",
29
+ "outputs": ["{options.outputFile}"],
30
+ "options": {
31
+ "lintFilePatterns": ["libs/aml-utils/**/*.{ts,tsx,js,jsx}"]
32
+ },
33
+ "fix": true
34
+ },
35
+ "test": {
36
+ "executor": "@nx/jest:jest",
37
+ "outputs": ["{workspaceRoot}/coverage/libs/aml-utils"],
38
+ "options": {
39
+ "jestConfig": "libs/aml-utils/jest.config.ts",
40
+ "testPathPattern": ["libs/aml-utils/lib/"],
41
+ "codeCoverage": true,
42
+ "reporters": ["default"],
43
+ "passWithNoTests": true,
44
+ "verbose": true
45
+ }
46
+ },
47
+ "publish": {
48
+ "executor": "nx:run-commands",
49
+ "options": {
50
+ "command": "npm publish dist/libs/aml-utils"
51
+ }
52
+ }
53
+ },
54
+ "tags": []
55
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "files": [],
4
+ "include": [],
5
+ "references": [
6
+ {
7
+ "path": "./tsconfig.lib.json"
8
+ },
9
+ {
10
+ "path": "./tsconfig.spec.json"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "outDir": "../../dist/out-tsc",
6
+ "declaration": true,
7
+ "types": ["node"],
8
+ "allowJs": true,
9
+ "esModuleInterop": true
10
+ },
11
+ "exclude": ["jest.config.ts", "**/*.spec.js"],
12
+ "include": ["**/*.ts", "**/*.js"]
13
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "types": ["jest", "node"],
7
+ "esModuleInterop": true
8
+ },
9
+ "include": ["jest.config.ts", "**/*.spec.js", "**/*.d.ts"]
10
+ }
@@ -1,9 +0,0 @@
1
- export const RequestError: any;
2
- export const ServerError: any;
3
- export const Forbidden: any;
4
- export const Unauthorized: any;
5
- export const BadRequest: any;
6
- export const NotFound: any;
7
- export const ConflictError: any;
8
- export const InvalidArguments: any;
9
- export const ServerTimeout: any;
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/errors/errors.js"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAEvC,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAEpC,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AAEtD,YAAY,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,CAAC;IAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;CACtB,CAAC,CAAC;AAEH,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,gBAAgB,EAAE;IACvD,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,EAAE,mBAAmB,EAAE;IAC7D,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,EAAE,iBAAiB,EAAE;IACzD,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,EAAE,eAAe,EAAE;IACrD,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,EAAE,eAAe,EAAE;IAC1D,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,EAAE,aAAa,EAAE;IACtD,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,MAAM,CAAC,YAAY,EAAE,uBAAuB,EAAE;IACrE,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,EAAE,oBAAoB,EAAE;IAC/D,MAAM,EAAE,GAAG;CACZ,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,GAAG;IACf,YAAY;IACZ,WAAW;IACX,SAAS;IACT,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,aAAa;IACb,gBAAgB;IAChB,aAAa;CACd,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare class TooManyRowsError extends Error {
2
- constructor();
3
- }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TooManyRowsError = void 0;
4
- class TooManyRowsError extends Error {
5
- constructor() {
6
- super('More than configured number of rows imported');
7
- this.name = 'TooManyRowsError';
8
- }
9
- }
10
- exports.TooManyRowsError = TooManyRowsError;
11
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/file-parser/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAiB,SAAQ,KAAK;IACzC;QACE,KAAK,CAAC,8CAA8C,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AALD,4CAKC"}
@@ -1,6 +0,0 @@
1
- import { ProcessingEntry } from './sanitizeRows';
2
- declare type Dependencies<T extends ProcessingEntry> = {
3
- processRow: (cells: string[]) => T;
4
- };
5
- declare function parseFile<T extends ProcessingEntry>(fileContent: string, maxRows: number, dependencies: Dependencies<T>): Promise<T[]>;
6
- export default parseFile;
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const parse_row_1 = tslib_1.__importDefault(require("./parse-row"));
5
- const errors_1 = require("./errors");
6
- const sanitizeRows_1 = tslib_1.__importDefault(require("./sanitizeRows"));
7
- function chunk(array, size) {
8
- if (!array.length) {
9
- return [];
10
- }
11
- const head = array.slice(0, size);
12
- const tail = array.slice(size);
13
- return [head, ...chunk(tail, size)];
14
- }
15
- function processChunk(parsedRows, dependencies) {
16
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
- const { processRow } = dependencies;
18
- return new Promise((resolve, reject) => {
19
- setTimeout(() => {
20
- try {
21
- const processedRows = parsedRows.map(processRow);
22
- resolve(processedRows);
23
- }
24
- catch (ex) {
25
- if (ex instanceof Error) {
26
- reject(ex);
27
- }
28
- }
29
- }, 0);
30
- });
31
- });
32
- }
33
- function parseFile(fileContent, maxRows, dependencies) {
34
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
35
- const { processRow } = dependencies;
36
- if (fileContent === 'invalidFileType') {
37
- throw Error('Invalid file type');
38
- }
39
- const rows = fileContent.split('\n');
40
- const parsedRows = rows.map(parse_row_1.default);
41
- const sanitizedRows = (0, sanitizeRows_1.default)(parsedRows, processRow);
42
- if (sanitizedRows.length > maxRows) {
43
- throw new errors_1.TooManyRowsError();
44
- }
45
- if (sanitizedRows.length === 0) {
46
- throw new Error('No rows');
47
- }
48
- const parsedRowChunks = chunk(sanitizedRows, 30);
49
- let results = [];
50
- // eslint-disable-next-line no-restricted-syntax
51
- for (const currentRowChunk of parsedRowChunks) {
52
- // eslint-disable-next-line no-await-in-loop
53
- const chunkResult = yield processChunk(currentRowChunk, dependencies);
54
- results = results.concat(chunkResult);
55
- }
56
- return results;
57
- });
58
- }
59
- exports.default = parseFile;
60
- //# sourceMappingURL=file-parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-parser.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/file-parser/file-parser.ts"],"names":[],"mappings":";;;AAAA,oEAAmC;AACnC,qCAA4C;AAC5C,0EAA+D;AAM/D,SAAS,KAAK,CAAI,KAAU,EAAE,IAAY;IACxC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;QACjB,OAAO,EAAE,CAAC;KACX;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/B,OAAO,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,SAAe,YAAY,CAA4B,UAAsB,EAAE,YAA6B;;QAC1G,MAAM,EAAE,UAAU,EAAE,GAAG,YAAY,CAAC;QACpC,OAAO,IAAI,OAAO,CAAC,CAAC,OAA6B,EAAE,MAA8B,EAAQ,EAAE;YACzF,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI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CAAC;IACjB,CAAC;CAAA;AAED,kBAAe,SAAS,CAAC"}
@@ -1,2 +0,0 @@
1
- declare const parseRow: (row: string) => string[];
2
- export default parseRow;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fp_1 = require("lodash/fp");
4
- const parseRow = (row) => {
5
- const trySplitByTab = (line) => {
6
- if (typeof line === 'string' && line.match('\t')) {
7
- return line.split('\t');
8
- }
9
- return line;
10
- };
11
- const trySplitByComa = (line) => {
12
- if (typeof line === 'string' && line.match(',')) {
13
- return line.split(',');
14
- }
15
- return line;
16
- };
17
- const trySplitByMultipleSpaces = (line) => {
18
- if (typeof line === 'string' && line.match(/ {3,}/)) {
19
- return line.split(/ {3,}/);
20
- }
21
- return line;
22
- };
23
- const trySplitBySpace = (line) => {
24
- if (typeof line === 'string' && line.match(' ')) {
25
- return line.split(' ');
26
- }
27
- return line;
28
- };
29
- const trySplitByNothing = (line) => {
30
- if (typeof line === 'string') {
31
- return [line];
32
- }
33
- return line;
34
- };
35
- const splitRow = (0, fp_1.pipe)(trySplitByTab, trySplitByComa, trySplitByMultipleSpaces, trySplitBySpace, trySplitByNothing);
36
- const cells = splitRow(row);
37
- return cells.map((c) => c.trim());
38
- };
39
- exports.default = parseRow;
40
- //# sourceMappingURL=parse-row.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-row.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/file-parser/parse-row.ts"],"names":[],"mappings":";;AAAA,kCAAiC;AAEjC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAY,EAAE;IACzC,MAAM,aAAa,GAAG,CAAC,IAAuB,EAAqB,EAAE;QACnE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;YAChD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACzB;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAA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 @@
1
- export declare type ProcessingEntry = {
2
- isValid: boolean;
3
- };
4
- declare function sanitizeRows<T extends ProcessingEntry>(parsedRows: string[][], processRow: (row: string[]) => T): string[][];
5
- export default sanitizeRows;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const sensicalRowCheck = (cells) => cells.some((cell) => !!cell);
4
- function sanitizeRows(parsedRows, processRow) {
5
- const firstSensicalRowIndex = parsedRows.findIndex(sensicalRowCheck);
6
- const lastSensicalRowIndex = [...parsedRows].reverse().findIndex(sensicalRowCheck);
7
- const sanitizedRows = parsedRows.splice(firstSensicalRowIndex, parsedRows.length - firstSensicalRowIndex - lastSensicalRowIndex);
8
- const firstRow = processRow(sanitizedRows[0]);
9
- if (firstRow.isValid) {
10
- return sanitizedRows;
11
- }
12
- return sanitizedRows.splice(1);
13
- }
14
- exports.default = sanitizeRows;
15
- //# sourceMappingURL=sanitizeRows.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sanitizeRows.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/file-parser/sanitizeRows.ts"],"names":[],"mappings":";;AAIA,MAAM,gBAAgB,GAAG,CAAC,KAAe,EAAW,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAE5F,SAAS,YAAY,CAA4B,UAAsB,EAAE,UAAgC;IACvG,MAAM,qBAAqB,GAAG,UAAU,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAErE,MAAM,oBAAoB,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAEnF,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,qBAAqB,EAAE,UAAU,CAAC,MAAM,GAAG,qBAAqB,GAAG,oBAAoB,CAAC,CAAC;IAEjI,MAAM,QAAQ,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9C,IAAI,QAAQ,CAAC,OAAO,EAAE;QACpB,OAAO,aAAa,CAAC;KACtB;IACD,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACjC,CAAC;AAED,kBAAe,YAAY,CAAC"}
@@ -1,2 +0,0 @@
1
- export function rethrowError(fnName: any, e: any): string;
2
- export function sqlEscapeWildcard(str: any): any;
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatting.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/formatting/formatting.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE5B,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;IACjC,IAAI,cAAc,CAAC;IACnB,IAAI,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;QAClD,cAAc,GAAG,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;KAC1D;SAAM;QACL,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC;KAC1B;IACD,OAAO,GAAG,MAAM,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,UAAU,MAAM,cAAc,EAAE,CAAC;AACtE,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAE3E,MAAM,CAAC,OAAO,GAAG;IACf,YAAY;IACZ,iBAAiB;CAClB,CAAC"}
package/lib/index.js DELETED
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ormHelpers = exports.middleware = exports.structuredFileParser = exports.fileParser = exports.formatting = exports.errors = exports.validations = exports.types = void 0;
4
- const tslib_1 = require("tslib");
5
- const types_1 = tslib_1.__importDefault(require("./types/types"));
6
- exports.types = types_1.default;
7
- const validations_1 = tslib_1.__importDefault(require("./validations/validations"));
8
- exports.validations = validations_1.default;
9
- const errors_1 = tslib_1.__importDefault(require("./errors/errors"));
10
- exports.errors = errors_1.default;
11
- const formatting_1 = tslib_1.__importDefault(require("./formatting/formatting"));
12
- exports.formatting = formatting_1.default;
13
- const middleware_1 = tslib_1.__importDefault(require("./middleware/middleware"));
14
- exports.middleware = middleware_1.default;
15
- const ormHelpers_1 = tslib_1.__importDefault(require("./orm-helpers/ormHelpers"));
16
- exports.ormHelpers = ormHelpers_1.default;
17
- const file_parser_1 = tslib_1.__importDefault(require("./file-parser/file-parser"));
18
- exports.fileParser = file_parser_1.default;
19
- const structured_file_parser_1 = tslib_1.__importDefault(require("./structured-file-parser/structured-file-parser"));
20
- exports.structuredFileParser = structured_file_parser_1.default;
21
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/aml-utils/lib/index.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AASzB,gBATF,eAAK,CASE;AARd,oFAAoD;AAQpC,sBART,qBAAW,CAQS;AAP3B,qEAAqC;AAOR,iBAPtB,gBAAM,CAOsB;AANnC,iFAAiD;AAMZ,qBAN9B,oBAAU,CAM8B;AAL/C,iFAAiD;AAKkC,qBAL5E,oBAAU,CAK4E;AAJ7F,kFAAkD;AAI6C,qBAJxF,oBAAU,CAIwF;AAHzG,oFAAmD;AAGF,qBAH1C,qBAAU,CAG0C;AAF3D,qHAAmF;AAEtB,+BAFtD,gCAAoB,CAEsD"}
@@ -1,4 +0,0 @@
1
- export function ensureType(type: any): (req: any, res: any, next: any, id: any, name: any) => any;
2
- export function ensureUUID(req: any, res: any, next: any, id: any, name: any): any;
3
- export function ensureHex32(req: any, res: any, next: any, id: any, name: any): any;
4
- export function ensureInteger(req: any, res: any, next: any, id: any, name: any): any;
@@ -1 +0,0 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/middleware/middleware.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAEpC,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;IACxD,IAAI,KAAK,CAAC;IACV,IAAI;QACF,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,EAAE,WAAW,IAAI,EAAE,CAAC,CAAC;QAC1C,OAAO,IAAI,EAAE,CAAC;KACf;IAAC,OAAO,MAAM,EAAE;QACf,KAAK,GAAG,MAAM,CAAC;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;AAEtC,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;AAExC,MAAM,aAAa,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;AAE9C,MAAM,CAAC,OAAO,GAAG;IACf,UAAU;IACV,UAAU;IACV,WAAW;IACX,aAAa;CACd,CAAC"}
@@ -1 +0,0 @@
1
- export function includeNested(orm: any, models: any): any;
@@ -1 +0,0 @@
1
- {"version":3,"file":"ormHelpers.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/orm-helpers/ormHelpers.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE5B,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CACpC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;IAC/B,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,GAAG,GAAG,CAAC;IACnC,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;IAC7B,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACtB,OAAO,KAAK,CAAC;KACd;IACD,OAAO;QACL,KAAK;QACL,OAAO;KACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEL,MAAM,CAAC,OAAO,GAAG;IACf,aAAa;CACd,CAAC"}
@@ -1,12 +0,0 @@
1
- export declare class InvalidFileError extends Error {
2
- constructor();
3
- }
4
- export declare class TooManyRowsError extends Error {
5
- constructor();
6
- }
7
- export declare class NoRowsError extends Error {
8
- constructor();
9
- }
10
- export declare class InvalidHeadersError extends Error {
11
- constructor();
12
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidHeadersError = exports.NoRowsError = exports.TooManyRowsError = exports.InvalidFileError = void 0;
4
- /* eslint-disable max-classes-per-file */
5
- class InvalidFileError extends Error {
6
- constructor() {
7
- super('Invalid file type');
8
- this.name = 'InvalidFileError';
9
- }
10
- }
11
- exports.InvalidFileError = InvalidFileError;
12
- class TooManyRowsError extends Error {
13
- constructor() {
14
- super('More than configured number of rows imported');
15
- this.name = 'TooManyRowsError';
16
- }
17
- }
18
- exports.TooManyRowsError = TooManyRowsError;
19
- class NoRowsError extends Error {
20
- constructor() {
21
- super('No rows');
22
- this.name = 'NoRowsError';
23
- }
24
- }
25
- exports.NoRowsError = NoRowsError;
26
- class InvalidHeadersError extends Error {
27
- constructor() {
28
- super('Invalid or incomplete headers list');
29
- this.name = 'InvalidHeadersError';
30
- }
31
- }
32
- exports.InvalidHeadersError = InvalidHeadersError;
33
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/structured-file-parser/errors.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC,MAAa,gBAAiB,SAAQ,KAAK;IACzC;QACE,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AALD,4CAKC;AACD,MAAa,gBAAiB,SAAQ,KAAK;IACzC;QACE,KAAK,CAAC,8CAA8C,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AALD,4CAKC;AACD,MAAa,WAAY,SAAQ,KAAK;IACpC;QACE,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AALD,kCAKC;AACD,MAAa,mBAAoB,SAAQ,KAAK;IAC5C;QACE,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AALD,kDAKC"}
@@ -1,2 +0,0 @@
1
- declare const parseRow: (row: string) => string[];
2
- export default parseRow;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fp_1 = require("lodash/fp");
4
- const parseRow = (row) => {
5
- const trySplitByTab = (line) => {
6
- if (typeof line === 'string' && line.match('\t')) {
7
- return line.split('\t');
8
- }
9
- return line;
10
- };
11
- const trySplitByComa = (line) => {
12
- if (typeof line === 'string' && line.match(',')) {
13
- return line.split(',');
14
- }
15
- return line;
16
- };
17
- const trySplitByMultipleSpaces = (line) => {
18
- if (typeof line === 'string' && line.match(/ {3,}/)) {
19
- return line.split(/ {3,}/);
20
- }
21
- return line;
22
- };
23
- const trySplitBySpace = (line) => {
24
- if (typeof line === 'string' && line.match(' ')) {
25
- return line.split(' ');
26
- }
27
- return line;
28
- };
29
- const trySplitByNothing = (line) => {
30
- if (typeof line === 'string') {
31
- return [line];
32
- }
33
- return line;
34
- };
35
- const splitRow = (0, fp_1.pipe)(trySplitByTab, trySplitByComa, trySplitByMultipleSpaces, trySplitBySpace, trySplitByNothing);
36
- const cells = splitRow(row);
37
- return cells.map((c) => c.trim());
38
- };
39
- exports.default = parseRow;
40
- //# sourceMappingURL=parse-row.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-row.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/structured-file-parser/parse-row.ts"],"names":[],"mappings":";;AAAA,kCAAiC;AAEjC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAY,EAAE;IACzC,MAAM,aAAa,GAAG,CAAC,IAAuB,EAAqB,EAAE;QACnE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;YAChD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACzB;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,CAAC,IAAuB,EAAqB,EAAE;QACpE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;YAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACxB;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,wBAAwB,GAAG,CAAC,IAAuB,EAAqB,EAAE;QAC9E,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;YACnD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SAC5B;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,eAAe,GAAG,CAAC,IAAuB,EAAqB,EAAE;QACrE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;YAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACxB;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,iBAAiB,GAAG,CAAC,IAAuB,EAAY,EAAE;QAC9D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,OAAO,CAAC,IAAI,CAAC,CAAC;SACf;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,IAAA,SAAI,EAAC,aAAa,EAAE,cAAc,EAAE,wBAAwB,EAAE,eAAe,EAAE,iBAAiB,CAAC,CAAC;IAEnH,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAE5B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF,kBAAe,QAAQ,CAAC"}
@@ -1,2 +0,0 @@
1
- declare function sanitizeRows(parsedRows: string[][]): string[][];
2
- export default sanitizeRows;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const sensicalRowCheck = (cells) => cells.some((cell) => !!cell);
4
- function sanitizeRows(parsedRows) {
5
- const firstSensicalRowIndex = parsedRows.findIndex(sensicalRowCheck);
6
- const lastSensicalRowIndex = [...parsedRows].reverse().findIndex(sensicalRowCheck);
7
- if (firstSensicalRowIndex < 0) {
8
- return [];
9
- }
10
- const sanitizedRows = [...parsedRows].splice(firstSensicalRowIndex, parsedRows.length - firstSensicalRowIndex - lastSensicalRowIndex);
11
- return sanitizedRows;
12
- }
13
- exports.default = sanitizeRows;
14
- //# sourceMappingURL=sanitize-rows.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sanitize-rows.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/structured-file-parser/sanitize-rows.ts"],"names":[],"mappings":";;AAAA,MAAM,gBAAgB,GAAG,CAAC,KAAe,EAAW,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAE5F,SAAS,YAAY,CAAC,UAAsB;IAC1C,MAAM,qBAAqB,GAAG,UAAU,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAErE,MAAM,oBAAoB,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAEnF,IAAI,qBAAqB,GAAG,CAAC,EAAE;QAC7B,OAAO,EAAE,CAAC;KACX;IAED,MAAM,aAAa,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,MAAM,CAAC,qBAAqB,EAAE,UAAU,CAAC,MAAM,GAAG,qBAAqB,GAAG,oBAAoB,CAAC,CAAC;IAEtI,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,kBAAe,YAAY,CAAC"}
@@ -1,10 +0,0 @@
1
- export declare type ProcessingEntry = {
2
- isValid: boolean;
3
- };
4
- declare type Dependencies<T extends ProcessingEntry> = {
5
- processRow: (cells: string[], headers: string[]) => T;
6
- };
7
- export declare const hasHeaderRow: (rows: string[][], requiredHeaderNames: string[]) => boolean;
8
- export declare const isHeaderRowValid: (rows: string[][], requiredHeaderNames: string[]) => boolean;
9
- declare function parseFile<T extends ProcessingEntry>(fileContent: string, maxRows: number, requiredHeaderNames: string[], dependencies: Dependencies<T>): Promise<T[]>;
10
- export default parseFile;
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isHeaderRowValid = exports.hasHeaderRow = void 0;
4
- const tslib_1 = require("tslib");
5
- /* eslint-disable no-await-in-loop */
6
- /* eslint-disable no-restricted-syntax */
7
- const parse_row_1 = tslib_1.__importDefault(require("./parse-row"));
8
- const errors_1 = require("./errors");
9
- const sanitize_rows_1 = tslib_1.__importDefault(require("./sanitize-rows"));
10
- function chunk(array, size) {
11
- if (!array.length) {
12
- return [];
13
- }
14
- const head = array.slice(0, size);
15
- const tail = array.slice(size);
16
- return [head, ...chunk(tail, size)];
17
- }
18
- function processChunk(parsedRows, dependencies) {
19
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
- const { processRow, headers } = dependencies;
21
- return new Promise((resolve, reject) => {
22
- setTimeout(() => {
23
- try {
24
- const processedRows = parsedRows.map((row) => processRow(row, headers));
25
- resolve(processedRows);
26
- }
27
- catch (ex) {
28
- reject(ex);
29
- }
30
- }, 0);
31
- });
32
- });
33
- }
34
- // a row is said to contain headers if two valid header names are present
35
- const hasHeaderRow = (rows, requiredHeaderNames) => {
36
- const firstRow = rows[0];
37
- if (!firstRow) {
38
- return false;
39
- }
40
- const foundIndex = firstRow.findIndex((value) => requiredHeaderNames.includes(value.toLowerCase()));
41
- if (foundIndex < 0) {
42
- return false;
43
- }
44
- const containsSecondHeader = firstRow
45
- .filter((_val, i) => i !== foundIndex)
46
- .some((value) => requiredHeaderNames.includes(value.toLowerCase()));
47
- return containsSecondHeader;
48
- };
49
- exports.hasHeaderRow = hasHeaderRow;
50
- const isHeaderRowValid = (rows, requiredHeaderNames) => {
51
- const firstRow = rows[0];
52
- if (!firstRow) {
53
- return false;
54
- }
55
- return (requiredHeaderNames.every((header) => firstRow.map((value) => value.toLowerCase()).includes(header)) &&
56
- requiredHeaderNames.length === firstRow.length);
57
- };
58
- exports.isHeaderRowValid = isHeaderRowValid;
59
- function parseFile(fileContent, maxRows, requiredHeaderNames, dependencies) {
60
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
61
- if (fileContent === 'invalidFileType') {
62
- throw new errors_1.InvalidFileError();
63
- }
64
- const rows = fileContent.split('\n');
65
- const parsedRows = rows.map(parse_row_1.default);
66
- const sanitizedRows = (0, sanitize_rows_1.default)(parsedRows);
67
- if (sanitizedRows.length > maxRows) {
68
- throw new errors_1.TooManyRowsError();
69
- }
70
- if (sanitizedRows.length === 0) {
71
- throw new errors_1.NoRowsError();
72
- }
73
- const containsHeaders = (0, exports.hasHeaderRow)(sanitizedRows, requiredHeaderNames);
74
- if (containsHeaders && !(0, exports.isHeaderRowValid)(sanitizedRows, requiredHeaderNames)) {
75
- throw new errors_1.InvalidHeadersError();
76
- }
77
- const firstSanitizedRow = sanitizedRows[0];
78
- if (!firstSanitizedRow) {
79
- throw new errors_1.NoRowsError();
80
- }
81
- const headers = containsHeaders ? firstSanitizedRow.map((value) => value.toLowerCase()) : requiredHeaderNames;
82
- const dataRows = containsHeaders ? sanitizedRows.splice(1) : sanitizedRows;
83
- if (dataRows.length === 0) {
84
- throw new errors_1.NoRowsError();
85
- }
86
- const parsedRowChunks = chunk(dataRows, 30);
87
- let results = [];
88
- for (const currentRowChunk of parsedRowChunks) {
89
- const chunkResult = yield processChunk(currentRowChunk, Object.assign(Object.assign({}, dependencies), { headers }));
90
- results = results.concat(chunkResult);
91
- }
92
- return results;
93
- });
94
- }
95
- exports.default = parseFile;
96
- //# sourceMappingURL=structured-file-parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"structured-file-parser.js","sourceRoot":"","sources":["../../../../../libs/aml-utils/lib/structured-file-parser/structured-file-parser.ts"],"names":[],"mappings":";;;;AAAA,qCAAqC;AACrC,yCAAyC;AACzC,oEAAmC;AACnC,qCAAgG;AAChG,4EAA2C;AAe3C,SAAS,KAAK,CAAI,KAAU,EAAE,IAAY;IACxC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;QACjB,OAAO,EAAE,CAAC;KACX;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/B,OAAO,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,C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AAM,IAAI,4BAAmB,EAAE,CAAC;SACjC;QAED,MAAM,iBAAiB,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;QAE3C,IAAI,CAAC,iBAAiB,EAAE;YACtB,MAAM,IAAI,oBAAW,EAAE,CAAC;SACzB;QAED,MAAM,OAAO,GAAG,eAAe,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC;QAE9G,MAAM,QAAQ,GAAG,eAAe,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;QAE3E,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YACzB,MAAM,IAAI,oBAAW,EAAE,CAAC;SACzB;QAED,MAAM,eAAe,GAAG,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC5C,IAAI,OAAO,GAAQ,EAAE,CAAC;QACtB,KAAK,MAAM,eAAe,IAAI,eAAe,EAAE;YAC7C,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,eAAe,kCACjD,YAAY,KACf,OAAO,IACP,CAAC;YACH,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;SACvC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CAAA;AAED,kBAAe,SAAS,CAAC"}
@@ -1,17 +0,0 @@
1
- declare const withNullable: {};
2
- export function parseType(str: any): any;
3
- export function parseType(str: any): any;
4
- export function parsedTypeCheck(type: any, obj: any): any;
5
- export function parsedTypeCheck(type: any, obj: any): any;
6
- export function typeCheck(type: any, obj: any): any;
7
- export function typeCheck(type: any, obj: any): any;
8
- export namespace opts {
9
- export { withNullable as customTypes };
10
- }
11
- export function ensureType(type: any, obj: any, msg: any): boolean;
12
- export function ensureType(type: any, obj: any, msg: any): boolean;
13
- export function checkArg(obj: any, prop: any, type: any, msg: any): any;
14
- export function checkArg(obj: any, prop: any, type: any, msg: any): any;
15
- export function checkArgs(input: any, types: any): void;
16
- export function checkArgs(input: any, types: any): void;
17
- export {};