@zipbul/baker 2.1.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.
Files changed (91) hide show
  1. package/CHANGELOG.md +256 -0
  2. package/MIGRATION-3.0.md +104 -0
  3. package/README.md +121 -75
  4. package/dist/index.d.ts +8 -7
  5. package/dist/index.js +10 -229
  6. package/dist/src/collect.d.ts +13 -10
  7. package/dist/src/collect.js +26 -0
  8. package/dist/src/configure.d.ts +8 -11
  9. package/dist/src/configure.js +43 -0
  10. package/dist/src/create-rule.d.ts +1 -1
  11. package/dist/src/create-rule.js +41 -0
  12. package/dist/src/decorators/field.d.ts +22 -18
  13. package/dist/src/decorators/field.js +268 -0
  14. package/dist/src/decorators/index.d.ts +1 -0
  15. package/dist/src/decorators/index.js +2 -2
  16. package/dist/src/decorators/recipe.d.ts +17 -0
  17. package/dist/src/decorators/recipe.js +23 -0
  18. package/dist/src/errors.d.ts +28 -17
  19. package/dist/src/errors.js +52 -0
  20. package/dist/src/functions/check-call-options.d.ts +8 -0
  21. package/dist/src/functions/check-call-options.js +51 -0
  22. package/dist/src/functions/deserialize.d.ts +14 -6
  23. package/dist/src/functions/deserialize.js +57 -0
  24. package/dist/src/functions/serialize.d.ts +10 -3
  25. package/dist/src/functions/serialize.js +52 -0
  26. package/dist/src/functions/validate.d.ts +13 -8
  27. package/dist/src/functions/validate.js +49 -0
  28. package/dist/src/interfaces.d.ts +1 -1
  29. package/dist/src/interfaces.js +4 -0
  30. package/dist/src/meta-access.d.ts +19 -0
  31. package/dist/src/meta-access.js +75 -0
  32. package/dist/src/registry.js +8 -0
  33. package/dist/src/rule-metadata.d.ts +11 -0
  34. package/dist/src/rule-metadata.js +17 -0
  35. package/dist/src/rule-plan.d.ts +29 -0
  36. package/dist/src/rule-plan.js +117 -0
  37. package/dist/src/rules/array.d.ts +7 -6
  38. package/dist/src/rules/array.js +96 -0
  39. package/dist/src/rules/common.d.ts +2 -2
  40. package/dist/src/rules/common.js +77 -0
  41. package/dist/src/rules/date.js +35 -0
  42. package/dist/src/rules/index.d.ts +2 -4
  43. package/dist/src/rules/index.js +8 -11
  44. package/dist/src/rules/locales.d.ts +5 -4
  45. package/dist/src/rules/locales.js +249 -0
  46. package/dist/src/rules/number.d.ts +2 -2
  47. package/dist/src/rules/number.js +79 -0
  48. package/dist/src/rules/object.d.ts +1 -1
  49. package/dist/src/rules/object.js +49 -0
  50. package/dist/src/rules/string.d.ts +83 -80
  51. package/dist/src/rules/string.js +1998 -0
  52. package/dist/src/rules/typechecker.d.ts +6 -6
  53. package/dist/src/rules/typechecker.js +143 -0
  54. package/dist/src/seal/circular-analyzer.js +63 -0
  55. package/dist/src/seal/codegen-utils.d.ts +7 -0
  56. package/dist/src/seal/codegen-utils.js +18 -0
  57. package/dist/src/seal/deserialize-builder.d.ts +8 -3
  58. package/dist/src/seal/deserialize-builder.js +1546 -0
  59. package/dist/src/seal/expose-validator.d.ts +3 -2
  60. package/dist/src/seal/expose-validator.js +65 -0
  61. package/dist/src/seal/seal-state.d.ts +10 -0
  62. package/dist/src/seal/seal-state.js +18 -0
  63. package/dist/src/seal/seal.d.ts +22 -21
  64. package/dist/src/seal/seal.js +431 -0
  65. package/dist/src/seal/serialize-builder.d.ts +3 -2
  66. package/dist/src/seal/serialize-builder.js +374 -0
  67. package/dist/src/seal/validate-meta.d.ts +13 -0
  68. package/dist/src/seal/validate-meta.js +61 -0
  69. package/dist/src/symbols.d.ts +1 -1
  70. package/dist/src/symbols.js +13 -2
  71. package/dist/src/transformers/collection.transformer.js +25 -0
  72. package/dist/src/transformers/date.transformer.js +18 -0
  73. package/dist/src/transformers/index.js +6 -2
  74. package/dist/src/transformers/luxon.transformer.d.ts +4 -2
  75. package/dist/src/transformers/luxon.transformer.js +34 -0
  76. package/dist/src/transformers/moment.transformer.d.ts +4 -2
  77. package/dist/src/transformers/moment.transformer.js +32 -0
  78. package/dist/src/transformers/number.transformer.js +8 -0
  79. package/dist/src/transformers/string.transformer.js +12 -0
  80. package/dist/src/types.d.ts +68 -28
  81. package/dist/src/types.js +1 -0
  82. package/dist/src/utils.d.ts +4 -2
  83. package/dist/src/utils.js +10 -0
  84. package/package.json +80 -67
  85. package/dist/index-fnv35wrf.js +0 -3
  86. package/dist/index-k3d659ad.js +0 -3
  87. package/dist/index-s0n74vx1.js +0 -3
  88. package/dist/index-xdn55cz3.js +0 -1
  89. package/dist/src/functions/_run-sealed.d.ts +0 -7
  90. package/dist/src/functions/index.d.ts +0 -3
  91. package/dist/src/seal/index.d.ts +0 -5
@@ -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;
@@ -9,6 +12,10 @@ export interface EmitContext {
9
12
  fail(code: string): string;
10
13
  /** Whether error collection mode is enabled (= !stopAtFirstError) */
11
14
  collectErrors: boolean;
15
+ /** Whether this emit runs inside a type gate (typeof/instanceof already verified) */
16
+ insideTypeGate?: boolean;
17
+ /** @internal Path expression for inline nested — used by makeRuleEmitCtx */
18
+ pathExpr?: string;
12
19
  }
13
20
  export interface EmittableRule {
14
21
  (value: unknown): boolean | Promise<boolean>;
@@ -17,14 +24,45 @@ export interface EmittableRule {
17
24
  /**
18
25
  * Meta for the builder to determine whether to insert a typeof guard.
19
26
  * Only set for rules that assume a specific type (e.g., isEmail → 'string').
20
- * @IsString itself is undefined (it includes its own typeof check).
27
+ * `@IsString` itself is undefined (it includes its own typeof check).
21
28
  */
22
- readonly requiresType?: 'string' | 'number' | 'boolean' | 'date';
29
+ readonly requiresType?: 'string' | 'number' | 'boolean' | 'date' | 'array' | 'object';
23
30
  /** Expose rule parameters for external reading */
24
31
  readonly constraints?: Record<string, unknown>;
25
- /** true when using an async validate function deserialize-builder generates await code */
32
+ /** true when the rule is explicitly async and must be awaited */
26
33
  readonly isAsync?: boolean;
27
34
  }
35
+ /** @internal internal rule shape used by builders for optimization metadata */
36
+ export interface InternalRule extends EmittableRule {
37
+ readonly plan?: RulePlan;
38
+ }
39
+ export type RulePlanExpr = {
40
+ kind: 'value';
41
+ } | {
42
+ kind: 'member';
43
+ object: RulePlanExpr;
44
+ property: 'length';
45
+ } | {
46
+ kind: 'call0';
47
+ object: RulePlanExpr;
48
+ method: 'getTime';
49
+ } | {
50
+ kind: 'literal';
51
+ value: number;
52
+ };
53
+ export type RulePlanCheck = {
54
+ kind: 'compare';
55
+ left: RulePlanExpr;
56
+ op: '<' | '<=' | '>' | '>=' | '===' | '!==';
57
+ right: RulePlanExpr;
58
+ } | {
59
+ kind: 'and' | 'or';
60
+ checks: RulePlanCheck[];
61
+ };
62
+ export interface RulePlan {
63
+ cacheKey?: 'length' | 'time';
64
+ failure: RulePlanCheck;
65
+ }
28
66
  /** Arguments for user-defined message callback */
29
67
  export interface MessageArgs {
30
68
  property: string;
@@ -32,12 +70,12 @@ export interface MessageArgs {
32
70
  constraints: Record<string, unknown>;
33
71
  }
34
72
  export interface RuleDef {
35
- rule: EmittableRule;
73
+ rule: InternalRule;
36
74
  each?: boolean;
37
75
  groups?: string[];
38
- /** Value to include in BakerError.message on validation failure */
76
+ /** Value to include in BakerIssue.message on validation failure */
39
77
  message?: string | ((args: MessageArgs) => string);
40
- /** Arbitrary value to include in BakerError.context on validation failure */
78
+ /** Arbitrary value to include in BakerIssue.context on validation failure */
41
79
  context?: unknown;
42
80
  }
43
81
  export interface TransformParams {
@@ -46,13 +84,14 @@ export interface TransformParams {
46
84
  obj: Record<string, unknown>;
47
85
  }
48
86
  export interface Transformer {
49
- deserialize(params: TransformParams): unknown;
50
- serialize(params: TransformParams): unknown;
87
+ deserialize(params: TransformParams): unknown | Promise<unknown>;
88
+ serialize(params: TransformParams): unknown | Promise<unknown>;
51
89
  }
52
90
  /** Internal — direction-specific transform function stored after @Field processing */
53
- export type TransformFunction = (params: TransformParams) => unknown;
91
+ export type TransformFunction = (params: TransformParams) => unknown | Promise<unknown>;
54
92
  export interface TransformDef {
55
93
  fn: TransformFunction;
94
+ isAsync?: boolean;
56
95
  options?: {
57
96
  groups?: string[];
58
97
  deserializeOnly?: boolean;
@@ -69,8 +108,10 @@ export interface ExcludeDef {
69
108
  deserializeOnly?: boolean;
70
109
  serializeOnly?: boolean;
71
110
  }
111
+ /** Generic class constructor — contravariant `never[]` args accept any user constructor */
112
+ export type ClassCtor<T = object> = new (...args: never[]) => T;
72
113
  export interface TypeDef {
73
- fn: () => (new (...args: any[]) => any) | (new (...args: any[]) => any)[];
114
+ fn: () => ClassCtor | ClassCtor[] | MapConstructor | SetConstructor;
74
115
  discriminator?: {
75
116
  property: string;
76
117
  subTypes: {
@@ -82,26 +123,26 @@ export interface TypeDef {
82
123
  /** seal() normalization result — true if fn() returns an array */
83
124
  isArray?: boolean;
84
125
  /** seal() normalization result — cached class after resolving fn() (DTOs only, excluding primitives) */
85
- resolvedClass?: new (...args: any[]) => any;
126
+ resolvedClass?: ClassCtor;
86
127
  /** seal() normalization result — Map or Set collection type */
87
128
  collection?: 'Map' | 'Set';
88
129
  /** Nested DTO class thunk for Map value / Set element */
89
- collectionValue?: () => new (...args: any[]) => any;
130
+ collectionValue?: () => ClassCtor;
90
131
  /** seal() normalization result — cached class after resolving collectionValue */
91
- resolvedCollectionValue?: new (...args: any[]) => any;
132
+ resolvedCollectionValue?: ClassCtor;
92
133
  }
93
134
  export interface PropertyFlags {
94
- /** @IsOptional() — skip all validation when undefined/null */
135
+ /** `@IsOptional`() — skip all validation when undefined/null */
95
136
  isOptional?: boolean;
96
- /** @IsDefined() — disallow undefined (overrides @IsOptional). Current code rejects only undefined; null is delegated to subsequent validation */
137
+ /** `@IsDefined`() — disallow undefined (overrides @IsOptional). Current code rejects only undefined; null is delegated to subsequent validation */
97
138
  isDefined?: boolean;
98
- /** @IsNullable() — allow and assign null, reject undefined */
139
+ /** `@IsNullable`() — allow and assign null, reject undefined */
99
140
  isNullable?: boolean;
100
- /** @ValidateIf(cond) — skip all field validation when false */
101
- validateIf?: (obj: Record<string, any>) => boolean;
102
- /** @ValidateNested() — trigger recursive validation for nested DTOs. Used with @Type */
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 */
103
144
  validateNested?: boolean;
104
- /** @ValidateNested({ each: true }) — validate nested DTOs per array element */
145
+ /** `@ValidateNested`({ each: true }) — validate nested DTOs per array element */
105
146
  validateNestedEach?: boolean;
106
147
  }
107
148
  export interface RawPropertyMeta {
@@ -115,18 +156,17 @@ export interface RawPropertyMeta {
115
156
  export interface RawClassMeta {
116
157
  [propertyKey: string]: RawPropertyMeta;
117
158
  }
118
- import type { RuntimeOptions } from './interfaces';
119
- import type { BakerError } from './errors';
120
- import type { Result, ResultAsync } from '@zipbul/result';
121
159
  export interface SealedExecutors<T> {
122
160
  /** Internal executor — Result pattern. deserialize() wraps and converts to throw */
123
- _deserialize(input: unknown, options?: RuntimeOptions): Result<T, BakerError[]> | ResultAsync<T, BakerError[]>;
161
+ deserialize(input: unknown, options?: RuntimeOptions): Result<T, BakerIssue[]> | ResultAsync<T, BakerIssue[]>;
124
162
  /** Internal executor — always succeeds. serialize assumes no validation */
125
- _serialize(instance: T, options?: RuntimeOptions): Record<string, unknown> | Promise<Record<string, unknown>>;
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>;
126
166
  /** true if the deserialize direction has async rules/transforms/nested */
127
- _isAsync: boolean;
167
+ isAsync: boolean;
128
168
  /** true if the serialize direction has async transforms/nested */
129
- _isSerializeAsync: boolean;
169
+ isSerializeAsync: boolean;
130
170
  /** Merged metadata cache — used internally by unseal helper */
131
- _merged?: RawClassMeta;
171
+ merged?: RawClassMeta;
132
172
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,4 @@
1
- /** minification-safe async function detection (uses Symbol.toStringTag, not constructor.name) */
2
- export declare function isAsyncFunction(fn: Function): boolean;
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
+ /** Promise-like detection used to enforce sync/async contract at runtime */
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": "2.1.0",
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
- "validation",
15
- "validator",
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
- "aot",
31
- "bun",
12
+ "decorator",
13
+ "deserialize",
14
+ "dto",
32
15
  "fast-validation",
33
- "schema-validation"
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
- "engines": {
36
- "bun": ">=1.0.0"
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
- "import": "./dist/index.js",
46
- "types": "./dist/index.d.ts"
50
+ "types": "./dist/index.d.ts",
51
+ "import": "./dist/index.js"
47
52
  },
48
53
  "./decorators": {
49
- "import": "./dist/src/decorators/index.js",
50
- "types": "./dist/src/decorators/index.d.ts"
54
+ "types": "./dist/src/decorators/index.d.ts",
55
+ "import": "./dist/src/decorators/index.js"
51
56
  },
52
57
  "./rules": {
53
- "import": "./dist/src/rules/index.js",
54
- "types": "./dist/src/rules/index.d.ts"
58
+ "types": "./dist/src/rules/index.d.ts",
59
+ "import": "./dist/src/rules/index.js"
55
60
  },
56
61
  "./symbols": {
57
- "import": "./dist/src/symbols.js",
58
- "types": "./dist/src/symbols.d.ts"
62
+ "types": "./dist/src/symbols.d.ts",
63
+ "import": "./dist/src/symbols.js"
59
64
  },
60
65
  "./transformers": {
61
- "import": "./dist/src/transformers/index.js",
62
- "types": "./dist/src/transformers/index.d.ts"
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": "bun build index.ts src/decorators/index.ts src/rules/index.ts src/symbols.ts src/transformers/index.ts --outdir dist --target bun --format esm --splitting --packages external --root . --production && tsc -p tsconfig.build.json",
92
- "typecheck": "tsc --noEmit",
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
- "changeset": "changeset",
97
- "version-packages": "changeset version",
98
- "release": "changeset publish",
99
- "prepare": "husky"
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
+ }
@@ -1,3 +0,0 @@
1
- // @bun
2
- var f=Symbol.for("baker:raw"),g=Symbol.for("baker:sealed");
3
- export{f as d,g as e};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{d as v}from"./index-fnv35wrf.js";var z=new Set;function B(h,w){if(!Object.prototype.hasOwnProperty.call(h,v))h[v]=Object.create(null),z.add(h);let G=h[v];return G[w]??={validation:[],transform:[],expose:[],exclude:null,type:null,flags:{}}}var H=Symbol.for("baker:arrayOf");function T(...h){let w={rules:h};return w[H]=!0,w}function J(h){return typeof h==="object"&&h!==null&&h[H]===!0}var U=new Set(["type","discriminator","keepDiscriminatorProperty","rules","optional","nullable","name","deserializeName","serializeName","exclude","groups","when","transform","message","context","mapValue","setValue"]);function C(h){if(typeof h==="function")return!1;if(typeof h!=="object"||h===null)return!1;if(J(h))return!1;let w=Object.keys(h);if(w.length===0)return!0;return w.some((G)=>U.has(G))}function X(h){if(h.length===0)return{rules:[],options:{}};if(h.length===1&&C(h[0])){let G=h[0];return{rules:G.rules??[],options:G}}let w=h[h.length-1];if(C(w)){let G=w,j=h.slice(0,-1);if(G.rules)j=[...j,...G.rules];return{rules:j,options:G}}return{rules:h,options:{}}}function Z(h,w,G){for(let j of w)if(J(j))for(let q of j.rules){let b={rule:q,each:!0,groups:G.groups};if(G.message!==void 0)b.message=G.message;if(G.context!==void 0)b.context=G.context;h.validation.push(b)}else{let q={rule:j,groups:G.groups};if(G.message!==void 0)q.message=G.message;if(G.context!==void 0)q.context=G.context;h.validation.push(q)}}function $(h,w){if(w.name)h.expose.push({name:w.name,groups:w.groups});else if(w.deserializeName||w.serializeName){if(w.deserializeName)h.expose.push({name:w.deserializeName,deserializeOnly:!0,groups:w.groups});if(w.serializeName)h.expose.push({name:w.serializeName,serializeOnly:!0,groups:w.groups})}else if(w.groups)h.expose.push({groups:w.groups});else h.expose.push({})}function K(h,w){if(!w.transform)return;let G=Array.isArray(w.transform)?w.transform:[w.transform];for(let j of G)h.transform.push({fn:j.deserialize,options:{deserializeOnly:!0}},{fn:j.serialize,options:{serializeOnly:!0}})}function E(...h){return(w,G)=>{let j=w.constructor,b=B(j,G),{rules:Q,options:S}=X(h);if(Z(b,Q,S),S.optional)b.flags.isOptional=!0;if(S.nullable)b.flags.isNullable=!0;if(S.when)b.flags.validateIf=S.when;if(S.type)b.type={fn:S.type,discriminator:S.discriminator,keepDiscriminatorProperty:S.keepDiscriminatorProperty,collectionValue:S.mapValue??S.setValue};if($(b,S),S.exclude){if(S.exclude===!0)b.exclude={};else if(S.exclude==="deserializeOnly")b.exclude={deserializeOnly:!0};else if(S.exclude==="serializeOnly")b.exclude={serializeOnly:!0}}K(b,S)}}
3
- export{z as a,T as b,E as c};
@@ -1,3 +0,0 @@
1
- // @bun
2
- var a=import.meta.require;
3
- export{a as f};
@@ -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>;
@@ -1,3 +0,0 @@
1
- export { deserialize } from './deserialize';
2
- export { serialize } from './serialize';
3
- export { validate } from './validate';
@@ -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';