@othree.io/auditor 1.0.0 → 2.0.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.
package/.gitlab-ci.yml CHANGED
@@ -1,4 +1,4 @@
1
- image: node:14-alpine
1
+ image: node:22-alpine
2
2
 
3
3
  cache:
4
4
  key: ${CI_PIPELINE_ID}
@@ -17,7 +17,7 @@ test:
17
17
  - npm test
18
18
 
19
19
  deploy:
20
- image: node:20
20
+ image: node:22
21
21
  stage: deploy
22
22
  variables:
23
23
  NPM_CONFIG_USERCONFIG: '$CI_PROJECT_DIR/.npmrc'
package/lib/index.js CHANGED
@@ -10,11 +10,33 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
13
18
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
20
  };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
16
38
  Object.defineProperty(exports, "__esModule", { value: true });
17
39
  exports.zod = void 0;
18
40
  __exportStar(require("./validator"), exports);
19
- exports.zod = require("./zod");
41
+ exports.zod = __importStar(require("./zod"));
20
42
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,+BAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,6CAA4B"}
@@ -1 +1 @@
1
- {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAQ,QAAQ,EAAM,MAAM,qBAAqB,CAAA;AAKxD;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,eAAgB,UAAU,mBAAmB,GAAG,iCAUpE,CAAA"}
1
+ {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,QAAQ,EAAM,MAAM,qBAAqB,CAAA;AAGjD;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,YAAY,UAAU,MAAM,aAAa,GAAG,MAAM,CAAC,EAAE,OAAO,CAAC,KAAG,QAAQ,CAAC,CAAC,CAUlG,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"validator.js","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":";;;AACA,kDAAwD;AACxD,gDAAkD;AAIlD;;;;;GAKG;AACI,MAAM,QAAQ,GAAG,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,WAAgB,EAAE,EAAE,CAAC,CAAI,KAAQ,EAAe,EAAE;IACnG,OAAO,IAAA,cAAG,EAAC,GAAG,EAAE;QACZ,MAAM,WAAW,GAAG,IAAA,mBAAQ,EAAM,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAA;QAE1E,IAAI,WAAW,CAAC,SAAS,EAAE;YACvB,MAAM,IAAI,yBAAe,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAA;SAC/C;QAED,OAAO,KAAK,CAAA;IAChB,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AAVY,QAAA,QAAQ,YAUpB"}
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":";;;AACA,kDAAiD;AACjD,gDAAkD;AAElD;;;;;GAKG;AACI,MAAM,QAAQ,GAAG,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,WAAgB,EAAE,EAAE,CAAC,CAAI,KAAQ,EAAe,EAAE;IACnG,OAAO,IAAA,cAAG,EAAC,GAAG,EAAE;QACZ,MAAM,WAAW,GAAG,IAAA,mBAAQ,EAAM,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAA;QAE1E,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,yBAAe,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAA;QAChD,CAAC;QAED,OAAO,KAAK,CAAA;IAChB,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AAVY,QAAA,QAAQ,YAUpB"}
package/lib/zod.d.ts CHANGED
@@ -1,21 +1,13 @@
1
- import { ZodUnrecognizedKeysIssue } from 'zod/lib/ZodError';
2
- import { ZodSchema, z } from 'zod';
1
+ import { z, ZodType } from 'zod';
3
2
  import { Optional } from '@othree.io/optional';
4
3
  /**
5
- * Type guard to check if an issue is an instance of ZodUnrecognizedKeysIssue.
6
- *
7
- * @param {any} issue - The issue to check.
8
- * @returns {issue is ZodUnrecognizedKeysIssue} True if the issue is an instance of ZodUnrecognizedKeysIssue, false otherwise.
9
- */
10
- export declare const isZodUnrecognizedKeysIssue: (issue: any) => issue is ZodUnrecognizedKeysIssue;
11
- /**
12
- * Generates a validation function using the provided ZodSchema.
4
+ * Generates a validation function using the provided ZodType.
13
5
  *
14
6
  * @template T
15
- * @param {ZodSchema<T>} constraints - ZodSchema constraints.
7
+ * @param {ZodType<T>} constraints - ZodType constraints.
16
8
  * @returns {Function} Returns a function that accepts an input of type T and returns a filled Optional<T> if valid
17
9
  */
18
- export declare const zodValidate: <T>(constraints: ZodSchema<T, z.ZodTypeDef, T>) => (input: T) => Optional<T>;
10
+ export declare const zodValidate: <T>(constraints: ZodType<T>) => (input: T) => Optional<T>;
19
11
  /**
20
12
  * Non-empty string constraint
21
13
  */
package/lib/zod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../src/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAC,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAA8C,SAAS,EAAE,CAAC,EAAC,MAAM,KAAK,CAAA;AAC7E,OAAO,EAAQ,QAAQ,EAAC,MAAM,qBAAqB,CAAA;AAGnD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,UAAW,GAAG,sCAEpD,CAAA;AA2BD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,8EAGvB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,aAA2B,CAAA;AACtD;;GAEG;AACH,eAAO,MAAM,cAAc,aAAiE,CAAA;AAC5F;;GAEG;AACH,eAAO,MAAM,YAAY,aAA8D,CAAA"}
1
+ {"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../src/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,CAAC,EAAE,OAAO,EAAqB,MAAM,KAAK,CAAA;AAC5D,OAAO,EAAQ,QAAQ,EAAC,MAAM,qBAAqB,CAAA;AA2BnD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,aAAa,OAAO,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,KAAG,QAAQ,CAAC,CAAC,CAGhF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,aAA2B,CAAA;AACtD;;GAEG;AACH,eAAO,MAAM,cAAc,aAAiE,CAAA;AAC5F;;GAEG;AACH,eAAO,MAAM,YAAY,aAA8D,CAAA"}
package/lib/zod.js CHANGED
@@ -1,19 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LanguageCode = exports.CountryISOCode = exports.NonEmptyString = exports.zodValidate = exports.isZodUnrecognizedKeysIssue = void 0;
3
+ exports.LanguageCode = exports.CountryISOCode = exports.NonEmptyString = exports.zodValidate = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const optional_1 = require("@othree.io/optional");
6
6
  const excuses_1 = require("@othree.io/excuses");
7
- /**
8
- * Type guard to check if an issue is an instance of ZodUnrecognizedKeysIssue.
9
- *
10
- * @param {any} issue - The issue to check.
11
- * @returns {issue is ZodUnrecognizedKeysIssue} True if the issue is an instance of ZodUnrecognizedKeysIssue, false otherwise.
12
- */
13
- const isZodUnrecognizedKeysIssue = (issue) => {
14
- return issue.code === zod_1.ZodIssueCode.unrecognized_keys;
15
- };
16
- exports.isZodUnrecognizedKeysIssue = isZodUnrecognizedKeysIssue;
17
7
  /**
18
8
  * Converts a ZodError into a ValidationError with formatted error messages.
19
9
  *
@@ -21,12 +11,12 @@ exports.isZodUnrecognizedKeysIssue = isZodUnrecognizedKeysIssue;
21
11
  * @returns {ValidationError} Returns a ValidationError instance.
22
12
  */
23
13
  const toValidationError = (error) => {
24
- return new excuses_1.ValidationError(error.errors.reduce((errors, issue) => {
25
- if ((0, exports.isZodUnrecognizedKeysIssue)(issue)) {
26
- return issue.keys.reduce((acum, current) => {
14
+ return new excuses_1.ValidationError(error.issues.reduce((errors, issue) => {
15
+ if (issue.code === 'unrecognized_keys') {
16
+ return issue.keys.reduce((errors, unrecognizedKey) => {
27
17
  return {
28
- ...acum,
29
- [current]: [`Unrecognized key: ${current}`]
18
+ ...errors,
19
+ [unrecognizedKey]: [`Unrecognized key: ${unrecognizedKey}`]
30
20
  };
31
21
  }, errors);
32
22
  }
@@ -38,10 +28,10 @@ const toValidationError = (error) => {
38
28
  }, {}));
39
29
  };
40
30
  /**
41
- * Generates a validation function using the provided ZodSchema.
31
+ * Generates a validation function using the provided ZodType.
42
32
  *
43
33
  * @template T
44
- * @param {ZodSchema<T>} constraints - ZodSchema constraints.
34
+ * @param {ZodType<T>} constraints - ZodType constraints.
45
35
  * @returns {Function} Returns a function that accepts an input of type T and returns a filled Optional<T> if valid
46
36
  */
47
37
  const zodValidate = (constraints) => (input) => {
package/lib/zod.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"zod.js","sourceRoot":"","sources":["../src/zod.ts"],"names":[],"mappings":";;;AACA,6BAA6E;AAC7E,kDAAmD;AACnD,gDAAkD;AAElD;;;;;GAKG;AACI,MAAM,0BAA0B,GAAG,CAAC,KAAU,EAAqC,EAAE;IACxF,OAAO,KAAK,CAAC,IAAI,KAAK,kBAAY,CAAC,iBAAiB,CAAA;AACxD,CAAC,CAAA;AAFY,QAAA,0BAA0B,8BAEtC;AAED;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,CAAC,KAAe,EAAE,EAAE;IAC1C,OAAO,IAAI,yBAAe,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAC7D,IAAI,IAAA,kCAA0B,EAAC,KAAK,CAAC,EAAE;YACnC,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;gBACvC,OAAO;oBACH,GAAG,IAAI;oBACP,CAAC,OAAO,CAAC,EAAE,CAAC,qBAAqB,OAAO,EAAE,CAAC;iBAC9C,CAAA;YACL,CAAC,EAAE,MAAM,CAAC,CAAA;SACb;QAED,MAAM,IAAI,GAAG,K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AAK,CAAC,YAAY,EAAE,0BAA0B,CAAC,CAAA;AAC5F;;GAEG;AACU,QAAA,YAAY,GAAG,sBAAc,CAAC,KAAK,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,36 +1,35 @@
1
1
  {
2
- "name": "@othree.io/auditor",
3
- "version": "1.0.0",
4
- "description": "Auditor",
5
- "main": "lib/index.js",
6
- "scripts": {
7
- "test": "jest",
8
- "build": "tsc",
9
- "semantic-release": "semantic-release"
10
- },
11
- "keywords": [
12
- "auditor"
13
- ],
14
- "author": "othree",
15
- "license": "ISC",
16
- "dependencies": {
17
- "@othree.io/optional": "^2.3.1",
18
- "@othree.io/excuses": "^1.0.0",
19
- "validate.js": "^0.13.1",
20
- "zod": "^3.21.4"
21
- },
22
- "devDependencies": {
23
- "@types/jest": "^27.4.0",
24
- "jest": "^27.4.7",
25
- "ts-jest": "^27.1.3",
26
- "typescript": "^4.5.5",
27
- "semantic-release": "^19.0.5",
28
- "semantic-release-monorepo": "^7.0.5",
29
- "jsdoc": "^4.0.2",
30
- "jsdoc-plugin-typescript": "^2.2.1",
31
- "docdash": "^2.0.1"
32
- },
33
- "publishConfig": {
34
- "access": "public"
35
- }
2
+ "name": "@othree.io/auditor",
3
+ "version": "2.0.0",
4
+ "description": "Auditor",
5
+ "main": "lib/index.js",
6
+ "scripts": {
7
+ "test": "vitest run",
8
+ "build": "tsc",
9
+ "semantic-release": "semantic-release"
10
+ },
11
+ "keywords": [
12
+ "auditor"
13
+ ],
14
+ "author": "othree",
15
+ "license": "ISC",
16
+ "peerDependencies": {
17
+ "@othree.io/excuses": "^1.1.0",
18
+ "@othree.io/optional": "^2.3.1",
19
+ "validate.js": "^0.13.1",
20
+ "zod": "^4.1.12"
21
+ },
22
+ "devDependencies": {
23
+ "@vitest/coverage-istanbul": "^4.0.4",
24
+ "docdash": "^2.0.1",
25
+ "jsdoc": "^4.0.2",
26
+ "jsdoc-plugin-typescript": "^3.2.0",
27
+ "semantic-release": "^24.2.9",
28
+ "semantic-release-monorepo": "^8.0.2",
29
+ "typescript": "^5.9.3",
30
+ "vitest": "^4.0.4"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ }
36
35
  }
@@ -0,0 +1,21 @@
1
+ import {defineConfig} from 'vitest/config'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ coverage: {
6
+ exclude: ['src/entrypoint.ts'],
7
+ include: ['src/**/*'],
8
+ enabled: true,
9
+ provider: 'istanbul',
10
+ all: true,
11
+ thresholds: {
12
+ branches: 100,
13
+ functions: 100,
14
+ lines: 100,
15
+ statements: 100,
16
+ },
17
+ reporter: ['text','html'],
18
+ reportOnFailure: true
19
+ },
20
+ },
21
+ })