@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 +2 -2
- package/lib/index.js +23 -1
- package/lib/index.js.map +1 -1
- package/lib/validator.d.ts.map +1 -1
- package/lib/validator.js.map +1 -1
- package/lib/zod.d.ts +4 -12
- package/lib/zod.d.ts.map +1 -1
- package/lib/zod.js +8 -18
- package/lib/zod.js.map +1 -1
- package/package.json +33 -34
- package/vitest.config.mts +21 -0
package/.gitlab-ci.yml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
image: node:
|
|
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
|
+
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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,6CAA4B"}
|
package/lib/validator.d.ts.map
CHANGED
|
@@ -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,
|
|
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"}
|
package/lib/validator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":";;;AACA,
|
|
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 {
|
|
2
|
-
import { ZodSchema, z } from 'zod';
|
|
1
|
+
import { z, ZodType } from 'zod';
|
|
3
2
|
import { Optional } from '@othree.io/optional';
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
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 {
|
|
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:
|
|
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,
|
|
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 =
|
|
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.
|
|
25
|
-
if (
|
|
26
|
-
return issue.keys.reduce((
|
|
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
|
-
...
|
|
29
|
-
[
|
|
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
|
|
31
|
+
* Generates a validation function using the provided ZodType.
|
|
42
32
|
*
|
|
43
33
|
* @template T
|
|
44
|
-
* @param {
|
|
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":";;;
|
|
1
|
+
{"version":3,"file":"zod.js","sourceRoot":"","sources":["../src/zod.ts"],"names":[],"mappings":";;;AAAA,6BAA4D;AAC5D,kDAAmD;AACnD,gDAAkD;AAElD;;;;;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,KAAK,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;YACrC,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,eAAe,EAAE,EAAE;gBACjD,OAAO;oBACH,GAAG,MAAM;oBACT,CAAC,eAAe,CAAC,EAAE,CAAC,qBAAqB,eAAe,EAAE,CAAC;iBAC9D,CAAA;YACL,CAAC,EAAE,MAAM,CAAC,CAAA;QACd,CAAC;QACD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACpE,OAAO;YACH,GAAG,MAAM;YACT,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,O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|
34
|
-
|
|
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
|
+
})
|