@zipbul/baker 2.2.0 → 3.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/CHANGELOG.md +256 -0
- package/MIGRATION-3.0.md +104 -0
- package/README.md +109 -63
- package/dist/index.d.ts +7 -6
- package/dist/index.js +10 -321
- package/dist/src/collect.d.ts +13 -10
- package/dist/src/collect.js +26 -0
- package/dist/src/configure.d.ts +8 -6
- package/dist/src/configure.js +43 -0
- package/dist/src/create-rule.js +41 -0
- package/dist/src/decorators/field.d.ts +22 -18
- package/dist/src/decorators/field.js +268 -0
- package/dist/src/decorators/index.d.ts +1 -0
- package/dist/src/decorators/index.js +2 -2
- package/dist/src/decorators/recipe.d.ts +17 -0
- package/dist/src/decorators/recipe.js +23 -0
- package/dist/src/errors.d.ts +27 -17
- package/dist/src/errors.js +52 -0
- package/dist/src/functions/check-call-options.d.ts +8 -0
- package/dist/src/functions/check-call-options.js +51 -0
- package/dist/src/functions/deserialize.d.ts +13 -6
- package/dist/src/functions/deserialize.js +57 -0
- package/dist/src/functions/serialize.d.ts +10 -4
- package/dist/src/functions/serialize.js +52 -0
- package/dist/src/functions/validate.d.ts +13 -10
- package/dist/src/functions/validate.js +49 -0
- package/dist/src/interfaces.d.ts +1 -1
- package/dist/src/interfaces.js +4 -0
- package/dist/src/meta-access.d.ts +19 -0
- package/dist/src/meta-access.js +75 -0
- package/dist/src/registry.js +8 -0
- package/dist/src/rule-metadata.d.ts +11 -0
- package/dist/src/rule-metadata.js +17 -0
- package/dist/src/rule-plan.d.ts +10 -11
- package/dist/src/rule-plan.js +117 -0
- package/dist/src/rules/array.d.ts +7 -6
- package/dist/src/rules/array.js +96 -0
- package/dist/src/rules/common.js +77 -0
- package/dist/src/rules/date.js +35 -0
- package/dist/src/rules/index.d.ts +2 -4
- package/dist/src/rules/index.js +8 -21
- package/dist/src/rules/locales.d.ts +5 -4
- package/dist/src/rules/locales.js +249 -0
- package/dist/src/rules/number.js +79 -0
- package/dist/src/rules/object.d.ts +1 -1
- package/dist/src/rules/object.js +49 -0
- package/dist/src/rules/string.d.ts +83 -80
- package/dist/src/rules/string.js +1998 -0
- package/dist/src/rules/typechecker.js +143 -0
- package/dist/src/seal/circular-analyzer.js +63 -0
- package/dist/src/seal/codegen-utils.js +18 -0
- package/dist/src/seal/deserialize-builder.d.ts +8 -4
- package/dist/src/seal/deserialize-builder.js +1546 -0
- package/dist/src/seal/expose-validator.d.ts +3 -2
- package/dist/src/seal/expose-validator.js +65 -0
- package/dist/src/seal/seal-state.d.ts +10 -0
- package/dist/src/seal/seal-state.js +18 -0
- package/dist/src/seal/seal.d.ts +22 -21
- package/dist/src/seal/seal.js +431 -0
- package/dist/src/seal/serialize-builder.d.ts +3 -2
- package/dist/src/seal/serialize-builder.js +374 -0
- package/dist/src/seal/validate-meta.d.ts +13 -0
- package/dist/src/seal/validate-meta.js +61 -0
- package/dist/src/symbols.d.ts +1 -1
- package/dist/src/symbols.js +13 -2
- package/dist/src/transformers/collection.transformer.js +25 -0
- package/dist/src/transformers/date.transformer.js +18 -0
- package/dist/src/transformers/index.js +6 -2
- package/dist/src/transformers/luxon.transformer.d.ts +4 -2
- package/dist/src/transformers/luxon.transformer.js +34 -0
- package/dist/src/transformers/moment.transformer.d.ts +4 -2
- package/dist/src/transformers/moment.transformer.js +32 -0
- package/dist/src/transformers/number.transformer.js +8 -0
- package/dist/src/transformers/string.transformer.js +12 -0
- package/dist/src/types.d.ts +27 -25
- package/dist/src/types.js +1 -0
- package/dist/src/utils.d.ts +2 -2
- package/dist/src/utils.js +10 -0
- package/package.json +80 -67
- package/dist/index-03cysbck.js +0 -3
- package/dist/index-dcbd798a.js +0 -3
- package/dist/index-jp2yjd6g.js +0 -3
- package/dist/index-mw7met6r.js +0 -3
- package/dist/index-xdn55cz3.js +0 -1
- package/dist/src/functions/_run-sealed.d.ts +0 -7
- package/dist/src/functions/index.d.ts +0 -3
- package/dist/src/seal/index.d.ts +0 -5
package/dist/src/types.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { Result, ResultAsync } from '@zipbul/result';
|
|
2
|
+
import type { BakerIssue } from './errors';
|
|
3
|
+
import type { RuntimeOptions } from './interfaces';
|
|
1
4
|
export interface EmitContext {
|
|
2
5
|
/** Register a RegExp in the reference array, return its index */
|
|
3
6
|
addRegex(re: RegExp): number;
|
|
@@ -12,7 +15,7 @@ export interface EmitContext {
|
|
|
12
15
|
/** Whether this emit runs inside a type gate (typeof/instanceof already verified) */
|
|
13
16
|
insideTypeGate?: boolean;
|
|
14
17
|
/** @internal Path expression for inline nested — used by makeRuleEmitCtx */
|
|
15
|
-
|
|
18
|
+
pathExpr?: string;
|
|
16
19
|
}
|
|
17
20
|
export interface EmittableRule {
|
|
18
21
|
(value: unknown): boolean | Promise<boolean>;
|
|
@@ -21,7 +24,7 @@ export interface EmittableRule {
|
|
|
21
24
|
/**
|
|
22
25
|
* Meta for the builder to determine whether to insert a typeof guard.
|
|
23
26
|
* Only set for rules that assume a specific type (e.g., isEmail → 'string').
|
|
24
|
-
*
|
|
27
|
+
* `@IsString` itself is undefined (it includes its own typeof check).
|
|
25
28
|
*/
|
|
26
29
|
readonly requiresType?: 'string' | 'number' | 'boolean' | 'date' | 'array' | 'object';
|
|
27
30
|
/** Expose rule parameters for external reading */
|
|
@@ -70,9 +73,9 @@ export interface RuleDef {
|
|
|
70
73
|
rule: InternalRule;
|
|
71
74
|
each?: boolean;
|
|
72
75
|
groups?: string[];
|
|
73
|
-
/** Value to include in
|
|
76
|
+
/** Value to include in BakerIssue.message on validation failure */
|
|
74
77
|
message?: string | ((args: MessageArgs) => string);
|
|
75
|
-
/** Arbitrary value to include in
|
|
78
|
+
/** Arbitrary value to include in BakerIssue.context on validation failure */
|
|
76
79
|
context?: unknown;
|
|
77
80
|
}
|
|
78
81
|
export interface TransformParams {
|
|
@@ -105,8 +108,10 @@ export interface ExcludeDef {
|
|
|
105
108
|
deserializeOnly?: boolean;
|
|
106
109
|
serializeOnly?: boolean;
|
|
107
110
|
}
|
|
111
|
+
/** Generic class constructor — contravariant `never[]` args accept any user constructor */
|
|
112
|
+
export type ClassCtor<T = object> = new (...args: never[]) => T;
|
|
108
113
|
export interface TypeDef {
|
|
109
|
-
fn: () =>
|
|
114
|
+
fn: () => ClassCtor | ClassCtor[] | MapConstructor | SetConstructor;
|
|
110
115
|
discriminator?: {
|
|
111
116
|
property: string;
|
|
112
117
|
subTypes: {
|
|
@@ -118,26 +123,26 @@ export interface TypeDef {
|
|
|
118
123
|
/** seal() normalization result — true if fn() returns an array */
|
|
119
124
|
isArray?: boolean;
|
|
120
125
|
/** seal() normalization result — cached class after resolving fn() (DTOs only, excluding primitives) */
|
|
121
|
-
resolvedClass?:
|
|
126
|
+
resolvedClass?: ClassCtor;
|
|
122
127
|
/** seal() normalization result — Map or Set collection type */
|
|
123
128
|
collection?: 'Map' | 'Set';
|
|
124
129
|
/** Nested DTO class thunk for Map value / Set element */
|
|
125
|
-
collectionValue?: () =>
|
|
130
|
+
collectionValue?: () => ClassCtor;
|
|
126
131
|
/** seal() normalization result — cached class after resolving collectionValue */
|
|
127
|
-
resolvedCollectionValue?:
|
|
132
|
+
resolvedCollectionValue?: ClassCtor;
|
|
128
133
|
}
|
|
129
134
|
export interface PropertyFlags {
|
|
130
|
-
/**
|
|
135
|
+
/** `@IsOptional`() — skip all validation when undefined/null */
|
|
131
136
|
isOptional?: boolean;
|
|
132
|
-
/**
|
|
137
|
+
/** `@IsDefined`() — disallow undefined (overrides @IsOptional). Current code rejects only undefined; null is delegated to subsequent validation */
|
|
133
138
|
isDefined?: boolean;
|
|
134
|
-
/**
|
|
139
|
+
/** `@IsNullable`() — allow and assign null, reject undefined */
|
|
135
140
|
isNullable?: boolean;
|
|
136
|
-
/**
|
|
137
|
-
validateIf?: (obj: Record<string,
|
|
138
|
-
/**
|
|
141
|
+
/** `@ValidateIf`(cond) — skip all field validation when false */
|
|
142
|
+
validateIf?: (obj: Record<string, unknown>) => boolean;
|
|
143
|
+
/** `@ValidateNested`() — trigger recursive validation for nested DTOs. Used with @Type */
|
|
139
144
|
validateNested?: boolean;
|
|
140
|
-
/**
|
|
145
|
+
/** `@ValidateNested`({ each: true }) — validate nested DTOs per array element */
|
|
141
146
|
validateNestedEach?: boolean;
|
|
142
147
|
}
|
|
143
148
|
export interface RawPropertyMeta {
|
|
@@ -151,20 +156,17 @@ export interface RawPropertyMeta {
|
|
|
151
156
|
export interface RawClassMeta {
|
|
152
157
|
[propertyKey: string]: RawPropertyMeta;
|
|
153
158
|
}
|
|
154
|
-
import type { RuntimeOptions } from './interfaces';
|
|
155
|
-
import type { BakerError } from './errors';
|
|
156
|
-
import type { Result, ResultAsync } from '@zipbul/result';
|
|
157
159
|
export interface SealedExecutors<T> {
|
|
158
160
|
/** Internal executor — Result pattern. deserialize() wraps and converts to throw */
|
|
159
|
-
|
|
161
|
+
deserialize(input: unknown, options?: RuntimeOptions): Result<T, BakerIssue[]> | ResultAsync<T, BakerIssue[]>;
|
|
160
162
|
/** Internal executor — always succeeds. serialize assumes no validation */
|
|
161
|
-
|
|
162
|
-
/** Internal executor — validate-only (no object creation). Returns null on success,
|
|
163
|
-
|
|
163
|
+
serialize(instance: T, options?: RuntimeOptions): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
164
|
+
/** Internal executor — validate-only (no object creation). Returns null on success, BakerIssue[] on failure */
|
|
165
|
+
validate(input: unknown, options?: RuntimeOptions): BakerIssue[] | null | Promise<BakerIssue[] | null>;
|
|
164
166
|
/** true if the deserialize direction has async rules/transforms/nested */
|
|
165
|
-
|
|
167
|
+
isAsync: boolean;
|
|
166
168
|
/** true if the serialize direction has async transforms/nested */
|
|
167
|
-
|
|
169
|
+
isSerializeAsync: boolean;
|
|
168
170
|
/** Merged metadata cache — used internally by unseal helper */
|
|
169
|
-
|
|
171
|
+
merged?: RawClassMeta;
|
|
170
172
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** minification-safe async function detection
|
|
2
|
-
export declare function isAsyncFunction(fn:
|
|
1
|
+
/** minification-safe async function detection — uses Object.prototype.toString brand instead of constructor.name */
|
|
2
|
+
export declare function isAsyncFunction(fn: (...args: never[]) => unknown): boolean;
|
|
3
3
|
/** Promise-like detection used to enforce sync/async contract at runtime */
|
|
4
4
|
export declare function isPromiseLike(value: unknown): value is PromiseLike<unknown>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** minification-safe async function detection — uses Object.prototype.toString brand instead of constructor.name */
|
|
2
|
+
export function isAsyncFunction(fn) {
|
|
3
|
+
return Object.prototype.toString.call(fn) === '[object AsyncFunction]';
|
|
4
|
+
}
|
|
5
|
+
/** Promise-like detection used to enforce sync/async contract at runtime */
|
|
6
|
+
export function isPromiseLike(value) {
|
|
7
|
+
return ((typeof value === 'object' || typeof value === 'function') &&
|
|
8
|
+
value !== null &&
|
|
9
|
+
typeof value.then === 'function');
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,102 +1,95 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zipbul/baker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Fastest decorator-based DTO validation for TypeScript. AOT code generation, 42ns per validation, 163x faster than class-validator. Zero reflect-metadata.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": "Junhyung Park (https://github.com/parkrevil)",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/zipbul/baker.git"
|
|
10
|
-
},
|
|
11
|
-
"bugs": "https://github.com/zipbul/baker/issues",
|
|
12
|
-
"homepage": "https://github.com/zipbul/baker#readme",
|
|
13
5
|
"keywords": [
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"transform",
|
|
17
|
-
"transformer",
|
|
18
|
-
"decorator",
|
|
19
|
-
"dto",
|
|
20
|
-
"typescript",
|
|
21
|
-
"runtime-validation",
|
|
22
|
-
"type-safe",
|
|
23
|
-
"class-validator",
|
|
6
|
+
"aot",
|
|
7
|
+
"bun",
|
|
24
8
|
"class-transformer",
|
|
9
|
+
"class-validator",
|
|
25
10
|
"class-validator-alternative",
|
|
26
|
-
"zod-alternative",
|
|
27
|
-
"serialize",
|
|
28
|
-
"deserialize",
|
|
29
11
|
"code-generation",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
12
|
+
"decorator",
|
|
13
|
+
"deserialize",
|
|
14
|
+
"dto",
|
|
32
15
|
"fast-validation",
|
|
33
|
-
"
|
|
16
|
+
"runtime-validation",
|
|
17
|
+
"schema-validation",
|
|
18
|
+
"serialize",
|
|
19
|
+
"transform",
|
|
20
|
+
"transformer",
|
|
21
|
+
"type-safe",
|
|
22
|
+
"typescript",
|
|
23
|
+
"validation",
|
|
24
|
+
"validator",
|
|
25
|
+
"zod-alternative"
|
|
34
26
|
],
|
|
35
|
-
"
|
|
36
|
-
|
|
27
|
+
"homepage": "https://github.com/zipbul/baker#readme",
|
|
28
|
+
"bugs": "https://github.com/zipbul/baker/issues",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"author": "Junhyung Park (https://github.com/parkrevil)",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/zipbul/baker.git"
|
|
37
34
|
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist/**/*.js",
|
|
37
|
+
"dist/**/*.d.ts",
|
|
38
|
+
"README.md",
|
|
39
|
+
"CHANGELOG.md",
|
|
40
|
+
"MIGRATION-3.0.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
],
|
|
38
43
|
"type": "module",
|
|
39
44
|
"sideEffects": false,
|
|
40
45
|
"main": "./dist/index.js",
|
|
41
|
-
"types": "./dist/index.d.ts",
|
|
42
46
|
"module": "./dist/index.js",
|
|
47
|
+
"types": "./dist/index.d.ts",
|
|
43
48
|
"exports": {
|
|
44
49
|
".": {
|
|
45
|
-
"
|
|
46
|
-
"
|
|
50
|
+
"types": "./dist/index.d.ts",
|
|
51
|
+
"import": "./dist/index.js"
|
|
47
52
|
},
|
|
48
53
|
"./decorators": {
|
|
49
|
-
"
|
|
50
|
-
"
|
|
54
|
+
"types": "./dist/src/decorators/index.d.ts",
|
|
55
|
+
"import": "./dist/src/decorators/index.js"
|
|
51
56
|
},
|
|
52
57
|
"./rules": {
|
|
53
|
-
"
|
|
54
|
-
"
|
|
58
|
+
"types": "./dist/src/rules/index.d.ts",
|
|
59
|
+
"import": "./dist/src/rules/index.js"
|
|
55
60
|
},
|
|
56
61
|
"./symbols": {
|
|
57
|
-
"
|
|
58
|
-
"
|
|
62
|
+
"types": "./dist/src/symbols.d.ts",
|
|
63
|
+
"import": "./dist/src/symbols.js"
|
|
59
64
|
},
|
|
60
65
|
"./transformers": {
|
|
61
|
-
"
|
|
62
|
-
"
|
|
66
|
+
"types": "./dist/src/transformers/index.d.ts",
|
|
67
|
+
"import": "./dist/src/transformers/index.js"
|
|
63
68
|
}
|
|
64
69
|
},
|
|
65
|
-
"files": [
|
|
66
|
-
"dist/**/*.js",
|
|
67
|
-
"dist/**/*.d.ts",
|
|
68
|
-
"README.md",
|
|
69
|
-
"LICENSE"
|
|
70
|
-
],
|
|
71
70
|
"publishConfig": {
|
|
72
71
|
"access": "public",
|
|
73
72
|
"provenance": true
|
|
74
73
|
},
|
|
75
|
-
"peerDependencies": {
|
|
76
|
-
"luxon": ">=3.0.0",
|
|
77
|
-
"moment": ">=2.0.0"
|
|
78
|
-
},
|
|
79
|
-
"peerDependenciesMeta": {
|
|
80
|
-
"luxon": {
|
|
81
|
-
"optional": true
|
|
82
|
-
},
|
|
83
|
-
"moment": {
|
|
84
|
-
"optional": true
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
"dependencies": {
|
|
88
|
-
"@zipbul/result": "1.0.0"
|
|
89
|
-
},
|
|
90
74
|
"scripts": {
|
|
91
|
-
"build": "
|
|
92
|
-
"
|
|
75
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && bun scripts/add-js-extensions.ts",
|
|
76
|
+
"changeset": "changeset",
|
|
77
|
+
"deps:check": "dpdm --no-warning --no-tree --no-output -T index.ts src/",
|
|
78
|
+
"format": "oxfmt",
|
|
79
|
+
"format:check": "oxfmt --check",
|
|
80
|
+
"knip": "knip",
|
|
81
|
+
"lint": "oxlint",
|
|
82
|
+
"prepare": "husky",
|
|
83
|
+
"release": "changeset publish",
|
|
93
84
|
"test": "bun test",
|
|
94
85
|
"test:coverage": "bun test --coverage",
|
|
95
86
|
"test:memory": "bun run scripts/check-memory.ts",
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
|
|
87
|
+
"typecheck": "tsc --noEmit",
|
|
88
|
+
"typecheck:bench": "tsc --noEmit -p bench/tsconfig.json && tsc --noEmit -p bench/class-validator/tsconfig.json",
|
|
89
|
+
"version-packages": "changeset version"
|
|
90
|
+
},
|
|
91
|
+
"dependencies": {
|
|
92
|
+
"@zipbul/result": "1.0.0"
|
|
100
93
|
},
|
|
101
94
|
"devDependencies": {
|
|
102
95
|
"@changesets/cli": "^2.29.8",
|
|
@@ -105,15 +98,35 @@
|
|
|
105
98
|
"@sinclair/typebox": "^0.34.48",
|
|
106
99
|
"@types/bun": "^1.3.9",
|
|
107
100
|
"@types/luxon": "^3.7.1",
|
|
108
|
-
"@types/moment": "^2.13.0",
|
|
109
101
|
"ajv": "^8.18.0",
|
|
110
102
|
"arktype": "^2.2.0",
|
|
111
103
|
"class-transformer": "^0.5.1",
|
|
112
104
|
"class-validator": "^0.15.1",
|
|
105
|
+
"dpdm": "^4.2.0",
|
|
113
106
|
"husky": "^9.1.7",
|
|
107
|
+
"knip": "^6.14.1",
|
|
108
|
+
"luxon": "^3.7.1",
|
|
114
109
|
"mitata": "^1.0.34",
|
|
110
|
+
"moment": "^2.30.1",
|
|
111
|
+
"oxfmt": "^0.50.0",
|
|
112
|
+
"oxlint": "^1.65.0",
|
|
115
113
|
"reflect-metadata": "^0.2.2",
|
|
116
114
|
"valibot": "^1.3.1",
|
|
117
115
|
"zod": "^4.3.6"
|
|
116
|
+
},
|
|
117
|
+
"peerDependencies": {
|
|
118
|
+
"luxon": ">=3.0.0",
|
|
119
|
+
"moment": ">=2.0.0"
|
|
120
|
+
},
|
|
121
|
+
"peerDependenciesMeta": {
|
|
122
|
+
"luxon": {
|
|
123
|
+
"optional": true
|
|
124
|
+
},
|
|
125
|
+
"moment": {
|
|
126
|
+
"optional": true
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"engines": {
|
|
130
|
+
"bun": ">=1.3.13"
|
|
118
131
|
}
|
|
119
|
-
}
|
|
132
|
+
}
|
package/dist/index-03cysbck.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{o as C}from"./index-jp2yjd6g.js";var H=new Set;function J(h,G){if(!Object.prototype.hasOwnProperty.call(h,C))h[C]=Object.create(null),H.add(h);let S=h[C];return S[G]??={validation:[],transform:[],expose:[],exclude:null,type:null,flags:{}}}function Q(h){return h[Symbol.toStringTag]==="AsyncFunction"}function U(h){return(typeof h==="object"||typeof h==="function")&&h!==null&&typeof h.then==="function"}var $=Symbol.for("baker:arrayOf");function M(...h){let G={rules:h};return G[$]=!0,G}function N(h){return typeof h==="object"&&h!==null&&h[$]===!0}var V=new Set(["type","discriminator","keepDiscriminatorProperty","rules","optional","nullable","name","deserializeName","serializeName","exclude","groups","when","transform","message","context","mapValue","setValue"]);function X(h){if(typeof h==="function")return!1;if(typeof h!=="object"||h===null)return!1;if(N(h))return!1;let G=Object.keys(h);if(G.length===0)return!0;return G.some((S)=>V.has(S))}function I(h){if(h.length===0)return{rules:[],options:{}};if(h.length===1&&X(h[0])){let S=h[0];return{rules:S.rules??[],options:S}}let G=h[h.length-1];if(X(G)){let S=G,q=h.slice(0,-1);if(S.rules)q=[...q,...S.rules];return{rules:q,options:S}}return{rules:h,options:{}}}function L(h,G,S){for(let q of G)if(N(q))for(let w of q.rules){let b={rule:w,each:!0,groups:S.groups};if(S.message!==void 0)b.message=S.message;if(S.context!==void 0)b.context=S.context;h.validation.push(b)}else{let w={rule:q,groups:S.groups};if(S.message!==void 0)w.message=S.message;if(S.context!==void 0)w.context=S.context;h.validation.push(w)}}function E(h,G){if(G.name)h.expose.push({name:G.name,groups:G.groups});else if(G.deserializeName||G.serializeName){if(G.deserializeName)h.expose.push({name:G.deserializeName,deserializeOnly:!0,groups:G.groups});if(G.serializeName)h.expose.push({name:G.serializeName,serializeOnly:!0,groups:G.groups})}else if(G.groups)h.expose.push({groups:G.groups});else h.expose.push({})}function Z(h,G,S){let q=Q(S);return{fn:(b)=>{let B=S(b);if(!q&&U(B))throw Error(`@Field(${h}) ${G} transform returned Promise. Declare the transform with async if it is asynchronous.`);return B},isAsync:q}}function P(h,G,S){if(!S.transform)return;let q=Array.isArray(S.transform)?S.transform:[S.transform];for(let w of q){let b=Z(G,"deserialize",w.deserialize),B=Z(G,"serialize",w.serialize);h.transform.push({fn:b.fn,isAsync:b.isAsync,options:{deserializeOnly:!0}},{fn:B.fn,isAsync:B.isAsync,options:{serializeOnly:!0}})}}function v(...h){return(G,S)=>{let q=G.constructor,w=S,b=J(q,w),{rules:B,options:j}=I(h);if(L(b,B,j),j.optional)b.flags.isOptional=!0;if(j.nullable)b.flags.isNullable=!0;if(j.when)b.flags.validateIf=j.when;if(j.type)b.type={fn:j.type,discriminator:j.discriminator,keepDiscriminatorProperty:j.keepDiscriminatorProperty,collectionValue:j.mapValue??j.setValue};if(E(b,j),j.exclude){if(j.exclude===!0)b.exclude={};else if(j.exclude==="deserializeOnly")b.exclude={deserializeOnly:!0};else if(j.exclude==="serializeOnly")b.exclude={serializeOnly:!0}}P(b,w,j)}}
|
|
3
|
-
export{H as j,Q as k,U as l,M as m,v as n};
|
package/dist/index-dcbd798a.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
var I=()=>({kind:"value"}),Y=(w=I())=>({kind:"member",object:w,property:"length"}),Z=(w=I())=>({kind:"call0",object:w,method:"getTime"}),O=(w)=>({kind:"literal",value:w}),_=(w,z,A)=>({kind:"compare",left:w,op:z,right:typeof A==="number"?O(A):A});var $=(...w)=>({kind:"or",checks:w});function L(w){return Q({name:w.name,requiresType:w.requiresType,constraints:w.constraints,plan:w.plan,validate:w.validate,emit:(z,A)=>U(z,A,w.name,w.plan)})}function Q(w){let z=(A)=>w.validate(A);if(z.emit=w.emit,z.ruleName=w.name,w.requiresType!==void 0)z.requiresType=w.requiresType;if(z.constraints=w.constraints??{},w.isAsync)z.isAsync=!0;if(w.plan)z.plan=w.plan;return z}function U(w,z,A,B,F,K){let M=K?W(B.failure):B.failure;return`if (${J(M,w,F)}) ${z.fail(A)};`}function W(w){if(w.kind==="compare")return w;let z=w.checks.filter((A)=>!X(A));if(z.length===0)return w;if(z.length===1)return z[0];return{kind:w.kind,checks:z}}function X(w){if(w.kind!=="compare"||w.op!=="!==")return!1;return H(w.left,w.right)}function H(w,z){if(w.kind!==z.kind)return!1;if(w.kind==="value")return!0;if(w.kind==="literal")return w.value===z.value;if(w.kind==="member")return H(w.object,z.object);if(w.kind==="call0")return w.method===z.method&&H(w.object,z.object);return!1}function J(w,z,A){if(w.kind==="compare")return`${D(w.left,z,A)} ${w.op} ${D(w.right,z,A)}`;let B=w.kind==="and"?" && ":" || ";return`(${w.checks.map((F)=>J(F,z,A)).join(B)})`}function D(w,z,A){switch(w.kind){case"value":return z;case"literal":return String(w.value);case"member":return A?.length??`${D(w.object,z,A)}.length`;case"call0":return A?.time??`${D(w.object,z,A)}.getTime()`}}
|
|
3
|
-
export{I as a,Y as b,Z as c,O as d,_ as e,$ as f,L as g,Q as h,U as i};
|
package/dist/index-jp2yjd6g.js
DELETED
package/dist/index-mw7met6r.js
DELETED
package/dist/index-xdn55cz3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { BakerErrors } from '../errors';
|
|
2
|
-
import type { RuntimeOptions } from '../interfaces';
|
|
3
|
-
/**
|
|
4
|
-
* @internal — shared seal+dispatch+unwrap for deserialize and validate.
|
|
5
|
-
* Calls sealed._deserialize, converts Result to BakerErrors, maps success via onSuccess.
|
|
6
|
-
*/
|
|
7
|
-
export declare function _runSealed<S>(Class: Function, input: unknown, options: RuntimeOptions | undefined, onSuccess: (result: any) => S): S | BakerErrors | Promise<S | BakerErrors>;
|
package/dist/src/seal/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { _autoSeal, _sealOnDemand, _resetForTesting, _sealedClasses, mergeInheritance } from './seal';
|
|
2
|
-
export { buildDeserializeCode } from './deserialize-builder';
|
|
3
|
-
export { buildSerializeCode } from './serialize-builder';
|
|
4
|
-
export { analyzeCircular } from './circular-analyzer';
|
|
5
|
-
export { validateExposeStacks } from './expose-validator';
|