@forklaunch/validator 0.3.13 → 0.4.1

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 (74) hide show
  1. package/lib/index.d.mts +17 -0
  2. package/lib/index.d.ts +17 -2
  3. package/lib/index.js +44 -1
  4. package/lib/index.mjs +17 -0
  5. package/lib/schema.types-Do9dhcdB.d.mts +476 -0
  6. package/lib/schema.types-Do9dhcdB.d.ts +476 -0
  7. package/lib/src/typebox/index.d.mts +213 -0
  8. package/lib/src/typebox/index.d.ts +213 -3
  9. package/lib/src/typebox/index.js +435 -1
  10. package/lib/src/typebox/index.mjs +393 -0
  11. package/lib/src/zod/index.d.mts +106 -0
  12. package/lib/src/zod/index.d.ts +106 -3
  13. package/lib/src/zod/index.js +289 -1
  14. package/lib/src/zod/index.mjs +242 -0
  15. package/lib/tests/utils/mockSchemaValidator.d.mts +69 -0
  16. package/lib/tests/utils/mockSchemaValidator.d.ts +29 -25
  17. package/lib/tests/utils/mockSchemaValidator.js +143 -79
  18. package/lib/tests/utils/mockSchemaValidator.mjs +99 -0
  19. package/package.json +48 -35
  20. package/lib/index.d.ts.map +0 -1
  21. package/lib/src/shared/types/schema.types.d.ts +0 -255
  22. package/lib/src/shared/types/schema.types.d.ts.map +0 -1
  23. package/lib/src/shared/types/schema.types.js +0 -1
  24. package/lib/src/typebox/index.d.ts.map +0 -1
  25. package/lib/src/typebox/staticSchemaValidator.d.ts +0 -99
  26. package/lib/src/typebox/staticSchemaValidator.d.ts.map +0 -1
  27. package/lib/src/typebox/staticSchemaValidator.js +0 -99
  28. package/lib/src/typebox/typeboxSchemaValidator.d.ts +0 -122
  29. package/lib/src/typebox/typeboxSchemaValidator.d.ts.map +0 -1
  30. package/lib/src/typebox/typeboxSchemaValidator.js +0 -362
  31. package/lib/src/typebox/types/schema.types.d.ts +0 -59
  32. package/lib/src/typebox/types/schema.types.d.ts.map +0 -1
  33. package/lib/src/typebox/types/schema.types.js +0 -1
  34. package/lib/src/zod/index.d.ts.map +0 -1
  35. package/lib/src/zod/staticSchemaValidator.d.ts +0 -99
  36. package/lib/src/zod/staticSchemaValidator.d.ts.map +0 -1
  37. package/lib/src/zod/staticSchemaValidator.js +0 -99
  38. package/lib/src/zod/types/schema.types.d.ts +0 -71
  39. package/lib/src/zod/types/schema.types.d.ts.map +0 -1
  40. package/lib/src/zod/types/schema.types.js +0 -1
  41. package/lib/src/zod/zodSchemaValidator.d.ts +0 -110
  42. package/lib/src/zod/zodSchemaValidator.d.ts.map +0 -1
  43. package/lib/src/zod/zodSchemaValidator.js +0 -192
  44. package/lib/tests/typebox/advancedParse.test.d.ts +0 -2
  45. package/lib/tests/typebox/advancedParse.test.d.ts.map +0 -1
  46. package/lib/tests/typebox/advancedParse.test.js +0 -514
  47. package/lib/tests/typebox/largeSchema.test.d.ts +0 -2
  48. package/lib/tests/typebox/largeSchema.test.d.ts.map +0 -1
  49. package/lib/tests/typebox/largeSchema.test.js +0 -150
  50. package/lib/tests/typebox/schemaValidator.test.d.ts +0 -2
  51. package/lib/tests/typebox/schemaValidator.test.d.ts.map +0 -1
  52. package/lib/tests/typebox/schemaValidator.test.js +0 -253
  53. package/lib/tests/typebox/typeEquality.test.d.ts +0 -2
  54. package/lib/tests/typebox/typeEquality.test.d.ts.map +0 -1
  55. package/lib/tests/typebox/typeEquality.test.js +0 -100
  56. package/lib/tests/utils/compare.d.ts +0 -2
  57. package/lib/tests/utils/compare.d.ts.map +0 -1
  58. package/lib/tests/utils/compare.js +0 -8
  59. package/lib/tests/utils/mockSchemaValidator.d.ts.map +0 -1
  60. package/lib/tests/zod/advancedParse.test.d.ts +0 -2
  61. package/lib/tests/zod/advancedParse.test.d.ts.map +0 -1
  62. package/lib/tests/zod/advancedParse.test.js +0 -514
  63. package/lib/tests/zod/largeSchema.test.d.ts +0 -2
  64. package/lib/tests/zod/largeSchema.test.d.ts.map +0 -1
  65. package/lib/tests/zod/largeSchema.test.js +0 -150
  66. package/lib/tests/zod/schemaValidator.test.d.ts +0 -2
  67. package/lib/tests/zod/schemaValidator.test.d.ts.map +0 -1
  68. package/lib/tests/zod/schemaValidator.test.js +0 -205
  69. package/lib/tests/zod/typeEquality.test.d.ts +0 -2
  70. package/lib/tests/zod/typeEquality.test.d.ts.map +0 -1
  71. package/lib/tests/zod/typeEquality.test.js +0 -100
  72. package/lib/vitest.config.d.ts +0 -3
  73. package/lib/vitest.config.d.ts.map +0 -1
  74. package/lib/vitest.config.js +0 -7
@@ -1,79 +1,143 @@
1
- export class MockSchemaValidator {
2
- _Type;
3
- _SchemaCatchall;
4
- _ValidSchemaObject;
5
- string = 'string';
6
- uuid = 'uuid';
7
- email = 'email';
8
- uri = 'uri';
9
- number = 'number';
10
- bigint = 'bigint';
11
- boolean = 'boolean';
12
- date = 'date';
13
- symbol = 'symbol';
14
- nullish = 'nullish';
15
- any = 'any';
16
- unknown = 'unknown';
17
- never = 'never';
18
- compile(schema) {
19
- return schema;
20
- }
21
- schemify(schema) {
22
- return schema;
23
- }
24
- optional(schema) {
25
- return `optional ${schema}`;
26
- }
27
- array(schema) {
28
- return `array ${schema}`;
29
- }
30
- union(schemas) {
31
- return schemas.join(' | ');
32
- }
33
- literal(schema) {
34
- return `literal ${schema}`;
35
- }
36
- enum_(schemaEnum) {
37
- return `enum ${Object.values(schemaEnum).join(' | ')}`;
38
- }
39
- isSchema(value) {
40
- return typeof value === 'string';
41
- }
42
- validate(schema, value) {
43
- return schema === value;
44
- }
45
- parse(schema, value) {
46
- return JSON.stringify(schema) === JSON.stringify(value)
47
- ? {
48
- ok: true,
49
- value: schema
50
- }
51
- : {
52
- ok: false,
53
- error: 'Some error'
54
- };
55
- }
56
- openapi(_schema) {
57
- return {};
58
- }
59
- }
60
- export const mockSchemaValidator = new MockSchemaValidator();
61
- export const string = mockSchemaValidator.string;
62
- export const number = mockSchemaValidator.number;
63
- export const bigint = mockSchemaValidator.bigint;
64
- export const boolean = mockSchemaValidator.boolean;
65
- export const date = mockSchemaValidator.date;
66
- export const symbol = mockSchemaValidator.symbol;
67
- export const nullish = mockSchemaValidator.nullish;
68
- export const any = mockSchemaValidator.any;
69
- export const unknown = mockSchemaValidator.unknown;
70
- export const never = mockSchemaValidator.never;
71
- export const schemify = mockSchemaValidator.schemify.bind(mockSchemaValidator);
72
- export const optional = mockSchemaValidator.optional.bind(mockSchemaValidator);
73
- export const array = mockSchemaValidator.array.bind(mockSchemaValidator);
74
- // note, use 'as const' when calling on the input array, for proper type parsing
75
- export const union = mockSchemaValidator.union.bind(mockSchemaValidator);
76
- export const literal = mockSchemaValidator.literal.bind(mockSchemaValidator);
77
- export const enum_ = mockSchemaValidator.enum_.bind(mockSchemaValidator);
78
- export const validate = mockSchemaValidator.validate.bind(mockSchemaValidator);
79
- export const openapi = mockSchemaValidator.openapi.bind(mockSchemaValidator);
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // tests/utils/mockSchemaValidator.ts
21
+ var mockSchemaValidator_exports = {};
22
+ __export(mockSchemaValidator_exports, {
23
+ MockSchemaValidator: () => MockSchemaValidator,
24
+ any: () => any,
25
+ array: () => array,
26
+ bigint: () => bigint,
27
+ boolean: () => boolean,
28
+ date: () => date,
29
+ enum_: () => enum_,
30
+ literal: () => literal,
31
+ mockSchemaValidator: () => mockSchemaValidator,
32
+ never: () => never,
33
+ nullish: () => nullish,
34
+ number: () => number,
35
+ openapi: () => openapi,
36
+ optional: () => optional,
37
+ schemify: () => schemify,
38
+ string: () => string,
39
+ symbol: () => symbol,
40
+ union: () => union,
41
+ unknown: () => unknown,
42
+ validate: () => validate
43
+ });
44
+ module.exports = __toCommonJS(mockSchemaValidator_exports);
45
+ var MockSchemaValidator = class {
46
+ _Type;
47
+ _SchemaCatchall;
48
+ _ValidSchemaObject;
49
+ string = "string";
50
+ uuid = "uuid";
51
+ email = "email";
52
+ uri = "uri";
53
+ number = "number";
54
+ bigint = "bigint";
55
+ boolean = "boolean";
56
+ date = "date";
57
+ symbol = "symbol";
58
+ nullish = "nullish";
59
+ any = "any";
60
+ unknown = "unknown";
61
+ never = "never";
62
+ compile(schema) {
63
+ return schema;
64
+ }
65
+ schemify(schema) {
66
+ return schema;
67
+ }
68
+ optional(schema) {
69
+ return `optional ${schema}`;
70
+ }
71
+ array(schema) {
72
+ return `array ${schema}`;
73
+ }
74
+ union(schemas) {
75
+ return schemas.join(" | ");
76
+ }
77
+ literal(schema) {
78
+ return `literal ${schema}`;
79
+ }
80
+ enum_(schemaEnum) {
81
+ return `enum ${Object.values(schemaEnum).join(" | ")}`;
82
+ }
83
+ isSchema(value) {
84
+ return typeof value === "string";
85
+ }
86
+ validate(schema, value) {
87
+ return schema === value;
88
+ }
89
+ parse(schema, value) {
90
+ return JSON.stringify(schema) === JSON.stringify(value) ? {
91
+ ok: true,
92
+ value: schema
93
+ } : {
94
+ ok: false,
95
+ errors: [{ path: [], message: "Some error" }]
96
+ };
97
+ }
98
+ openapi(_schema) {
99
+ return {};
100
+ }
101
+ };
102
+ var mockSchemaValidator = new MockSchemaValidator();
103
+ var string = mockSchemaValidator.string;
104
+ var number = mockSchemaValidator.number;
105
+ var bigint = mockSchemaValidator.bigint;
106
+ var boolean = mockSchemaValidator.boolean;
107
+ var date = mockSchemaValidator.date;
108
+ var symbol = mockSchemaValidator.symbol;
109
+ var nullish = mockSchemaValidator.nullish;
110
+ var any = mockSchemaValidator.any;
111
+ var unknown = mockSchemaValidator.unknown;
112
+ var never = mockSchemaValidator.never;
113
+ var schemify = mockSchemaValidator.schemify.bind(mockSchemaValidator);
114
+ var optional = mockSchemaValidator.optional.bind(mockSchemaValidator);
115
+ var array = mockSchemaValidator.array.bind(mockSchemaValidator);
116
+ var union = mockSchemaValidator.union.bind(mockSchemaValidator);
117
+ var literal = mockSchemaValidator.literal.bind(mockSchemaValidator);
118
+ var enum_ = mockSchemaValidator.enum_.bind(mockSchemaValidator);
119
+ var validate = mockSchemaValidator.validate.bind(mockSchemaValidator);
120
+ var openapi = mockSchemaValidator.openapi.bind(mockSchemaValidator);
121
+ // Annotate the CommonJS export names for ESM import in node:
122
+ 0 && (module.exports = {
123
+ MockSchemaValidator,
124
+ any,
125
+ array,
126
+ bigint,
127
+ boolean,
128
+ date,
129
+ enum_,
130
+ literal,
131
+ mockSchemaValidator,
132
+ never,
133
+ nullish,
134
+ number,
135
+ openapi,
136
+ optional,
137
+ schemify,
138
+ string,
139
+ symbol,
140
+ union,
141
+ unknown,
142
+ validate
143
+ });
@@ -0,0 +1,99 @@
1
+ // tests/utils/mockSchemaValidator.ts
2
+ var MockSchemaValidator = class {
3
+ _Type;
4
+ _SchemaCatchall;
5
+ _ValidSchemaObject;
6
+ string = "string";
7
+ uuid = "uuid";
8
+ email = "email";
9
+ uri = "uri";
10
+ number = "number";
11
+ bigint = "bigint";
12
+ boolean = "boolean";
13
+ date = "date";
14
+ symbol = "symbol";
15
+ nullish = "nullish";
16
+ any = "any";
17
+ unknown = "unknown";
18
+ never = "never";
19
+ compile(schema) {
20
+ return schema;
21
+ }
22
+ schemify(schema) {
23
+ return schema;
24
+ }
25
+ optional(schema) {
26
+ return `optional ${schema}`;
27
+ }
28
+ array(schema) {
29
+ return `array ${schema}`;
30
+ }
31
+ union(schemas) {
32
+ return schemas.join(" | ");
33
+ }
34
+ literal(schema) {
35
+ return `literal ${schema}`;
36
+ }
37
+ enum_(schemaEnum) {
38
+ return `enum ${Object.values(schemaEnum).join(" | ")}`;
39
+ }
40
+ isSchema(value) {
41
+ return typeof value === "string";
42
+ }
43
+ validate(schema, value) {
44
+ return schema === value;
45
+ }
46
+ parse(schema, value) {
47
+ return JSON.stringify(schema) === JSON.stringify(value) ? {
48
+ ok: true,
49
+ value: schema
50
+ } : {
51
+ ok: false,
52
+ errors: [{ path: [], message: "Some error" }]
53
+ };
54
+ }
55
+ openapi(_schema) {
56
+ return {};
57
+ }
58
+ };
59
+ var mockSchemaValidator = new MockSchemaValidator();
60
+ var string = mockSchemaValidator.string;
61
+ var number = mockSchemaValidator.number;
62
+ var bigint = mockSchemaValidator.bigint;
63
+ var boolean = mockSchemaValidator.boolean;
64
+ var date = mockSchemaValidator.date;
65
+ var symbol = mockSchemaValidator.symbol;
66
+ var nullish = mockSchemaValidator.nullish;
67
+ var any = mockSchemaValidator.any;
68
+ var unknown = mockSchemaValidator.unknown;
69
+ var never = mockSchemaValidator.never;
70
+ var schemify = mockSchemaValidator.schemify.bind(mockSchemaValidator);
71
+ var optional = mockSchemaValidator.optional.bind(mockSchemaValidator);
72
+ var array = mockSchemaValidator.array.bind(mockSchemaValidator);
73
+ var union = mockSchemaValidator.union.bind(mockSchemaValidator);
74
+ var literal = mockSchemaValidator.literal.bind(mockSchemaValidator);
75
+ var enum_ = mockSchemaValidator.enum_.bind(mockSchemaValidator);
76
+ var validate = mockSchemaValidator.validate.bind(mockSchemaValidator);
77
+ var openapi = mockSchemaValidator.openapi.bind(mockSchemaValidator);
78
+ export {
79
+ MockSchemaValidator,
80
+ any,
81
+ array,
82
+ bigint,
83
+ boolean,
84
+ date,
85
+ enum_,
86
+ literal,
87
+ mockSchemaValidator,
88
+ never,
89
+ nullish,
90
+ number,
91
+ openapi,
92
+ optional,
93
+ schemify,
94
+ string,
95
+ symbol,
96
+ union,
97
+ unknown,
98
+ validate
99
+ };
package/package.json CHANGED
@@ -1,77 +1,90 @@
1
1
  {
2
2
  "name": "@forklaunch/validator",
3
- "version": "0.3.13",
3
+ "version": "0.4.1",
4
4
  "description": "Schema validator for ForkLaunch components.",
5
- "files": [
6
- "lib"
7
- ],
8
- "types": "lib/index.d.ts",
9
- "directories": {
10
- "test": "tests"
5
+ "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/forklaunch/forklaunch-js/issues"
11
8
  },
12
9
  "repository": {
13
10
  "type": "git",
14
11
  "url": "git+https://github.com/forklaunch/forklaunch-js.git"
15
12
  },
16
- "author": "Rohin Bhargava",
17
13
  "license": "MIT",
18
- "bugs": {
19
- "url": "https://github.com/forklaunch/forklaunch-js/issues"
20
- },
21
- "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
22
- "dependencies": {
23
- "@anatine/zod-openapi": "^2.2.6",
24
- "@sinclair/typebox": "^0.34.9",
25
- "zod": "^3.23.8",
26
- "@forklaunch/common": "0.1.14"
27
- },
28
- "devDependencies": {
29
- "@eslint/js": "^9.16.0",
30
- "@types/jest": "^29.5.14",
31
- "@vitest/coverage-v8": "^2.1.8",
32
- "eslint-config-prettier": "^9.1.0",
33
- "eslint-plugin-prettier": "^5.2.1",
34
- "globals": "^15.13.0",
35
- "jest": "^29.7.0",
36
- "openapi3-ts": "^4.4.0",
37
- "ts-jest": "^29.2.5",
38
- "ts-node": "^10.9.2",
39
- "typescript-eslint": "^8.17.0"
40
- },
14
+ "author": "Rohin Bhargava",
41
15
  "exports": {
42
16
  ".": {
43
17
  "types": "./lib/index.d.ts",
18
+ "import": "./lib/index.mjs",
19
+ "require": "./lib/index.js",
44
20
  "default": "./lib/index.js"
45
21
  },
46
22
  "./typebox": {
47
23
  "types": "./lib/src/typebox/index.d.ts",
24
+ "import": "./lib/src/typebox/index.mjs",
25
+ "require": "./lib/src/typebox/index.js",
48
26
  "default": "./lib/src/typebox/index.js"
49
27
  },
50
28
  "./zod": {
51
29
  "types": "./lib/src/zod/index.d.ts",
30
+ "import": "./lib/src/zod/index.mjs",
31
+ "require": "./lib/src/zod/index.js",
52
32
  "default": "./lib/src/zod/index.js"
53
33
  },
54
34
  "./typebox/types": {
55
35
  "types": "./lib/src/typebox/types/schema.types.d.ts",
36
+ "import": "./lib/src/typebox/types/schema.types.mjs",
37
+ "require": "./lib/src/typebox/types/schema.types.js",
56
38
  "default": "./lib/src/typebox/types/schema.types.js"
57
39
  },
58
40
  "./zod/types": {
59
41
  "types": "./lib/src/zod/types/schema.types.d.ts",
42
+ "import": "./lib/src/zod/types/schema.types.mjs",
43
+ "require": "./lib/src/zod/types/schema.types.js",
60
44
  "default": "./lib/src/zod/types/schema.types.js"
61
45
  },
62
46
  "./tests/mockSchemaValidator": {
63
47
  "types": "./lib/tests/utils/mockSchemaValidator.d.ts",
48
+ "import": "./lib/tests/utils/mockSchemaValidator.mjs",
49
+ "require": "./lib/tests/utils/mockSchemaValidator.js",
64
50
  "default": "./lib/tests/utils/mockSchemaValidator.js"
65
51
  }
66
52
  },
53
+ "types": "lib/index.d.ts",
54
+ "directories": {
55
+ "test": "tests"
56
+ },
57
+ "files": [
58
+ "lib"
59
+ ],
60
+ "dependencies": {
61
+ "@anatine/zod-openapi": "^2.2.6",
62
+ "@sinclair/typebox": "^0.34.13",
63
+ "zod": "^3.24.1",
64
+ "@forklaunch/common": "0.2.0"
65
+ },
66
+ "devDependencies": {
67
+ "@eslint/js": "^9.17.0",
68
+ "@types/jest": "^29.5.14",
69
+ "@vitest/coverage-v8": "^2.1.8",
70
+ "eslint-config-prettier": "^9.1.0",
71
+ "eslint-plugin-prettier": "^5.2.1",
72
+ "globals": "^15.14.0",
73
+ "jest": "^29.7.0",
74
+ "openapi3-ts": "^4.4.0",
75
+ "ts-jest": "^29.2.5",
76
+ "ts-node": "^10.9.2",
77
+ "tsup": "^8.3.5",
78
+ "typescript-eslint": "^8.19.1"
79
+ },
67
80
  "scripts": {
68
- "test": "vitest --passWithNoTests",
69
- "build": "tsc",
81
+ "build": "tsc --noEmit && tsup index.ts src/typebox/index.ts src/zod/index.ts tests/utils/mockSchemaValidator.ts --format cjs,esm --no-splitting --tsconfig tsconfig.json --outDir lib --dts --clean",
70
82
  "clean": "rm -rf lib pnpm.lock.yaml node_modules",
71
83
  "docs": "typedoc --out docs *",
84
+ "format": "prettier --ignore-path=.prettierignore --config .prettierrc '**/*.{ts,tsx,json}' --write",
72
85
  "lint": "eslint . -c eslint.config.mjs",
73
86
  "lint:fix": "eslint . -c eslint.config.mjs --fix",
74
- "format": "prettier --ignore-path=.prettierignore --config .prettierrc '**/*.ts' --write",
75
- "publish:package": "./publish-package.bash"
87
+ "publish:package": "./publish-package.bash",
88
+ "test": "vitest --passWithNoTests"
76
89
  }
77
90
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC"}