@zipbul/baker 1.0.0 → 1.1.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.
@@ -1,11 +1,11 @@
1
1
  import type { RawClassMeta } from '../types';
2
2
  /**
3
- * @Expose 스택 정적 검증 (§4.1, §3.3)
3
+ * Static validation of @Expose stacks (§4.1, §3.3)
4
4
  *
5
- * 검사 ①: 동일 @Expose 항목에 deserializeOnly: true + serializeOnly: true → 양쪽 방향 모두 제외
6
- * 검사 ②: 같은 방향에 2 이상 @Expose 있고 groups 겹치면 SealError
7
- * - groups=[] (ungrouped) → 겹침
8
- * - non-empty groups이며 교집합 존재겹침
9
- * - 하나는 ungrouped, 다른 하나는 grouped → 겹치지 않음 (다른 적용 범위)
5
+ * Check 1: same @Expose entry has deserializeOnly: true + serializeOnly: true → excluded from both directions
6
+ * Check 2: if 2+ @Expose entries in the same direction have overlapping groups SealError
7
+ * - both groups=[] (ungrouped) → overlap
8
+ * - both non-empty groups with intersectionoverlap
9
+ * - one ungrouped + one grouped → no overlap (different scope)
10
10
  */
11
11
  export declare function validateExposeStacks(merged: RawClassMeta, className?: string): void;
@@ -1,38 +1,38 @@
1
1
  import type { RawClassMeta, SealedExecutors } from '../types';
2
2
  /** @internal Placeholder executor for circular dependency detection during seal */
3
3
  declare function _circularPlaceholder(className: string): SealedExecutors<unknown>;
4
- /** @internal — configure()에서 사후 호출 경고용 */
4
+ /** @internal — used by configure() to warn about post-seal calls */
5
5
  export declare function _isSealed(): boolean;
6
- /** seal 완료된 클래스 목록 — unseal에서 SEALED 제거 사용 */
6
+ /** List of sealed classesused by unseal to remove SEALED */
7
7
  export declare const _sealedClasses: Set<Function>;
8
8
  /**
9
- * @internal — deserialize/serialize에서 호출.
10
- * 이미 sealed면 no-op.
9
+ * @internal — called from deserialize/serialize.
10
+ * No-op if already sealed.
11
11
  */
12
12
  export declare function _autoSeal(): void;
13
13
  /**
14
- * @internal — 동적 import로 auto-seal 이후에 등록된 클래스를 즉석 seal.
15
- * Class[RAW] 있고 Class[SEALED] 없는 경우에만 동작.
14
+ * @internal — on-demand seal for classes registered after auto-seal via dynamic import.
15
+ * Only operates when Class[RAW] exists and Class[SEALED] does not.
16
16
  */
17
17
  export declare function _sealOnDemand(Class: Function): void;
18
18
  /**
19
- * @internal 테스트 전용testing.ts의 unseal()에서 호출
19
+ * @internal testing onlycalled by unseal() in testing.ts
20
20
  */
21
21
  export declare function _resetForTesting(): void;
22
22
  /**
23
- * @internal — serialize/deserialize에서 사용. sealed executor를 보장하여 반환.
23
+ * @internal — used by serialize/deserialize. Ensures and returns a sealed executor.
24
24
  */
25
25
  export declare function _ensureSealed(Class: Function): SealedExecutors<unknown>;
26
26
  /**
27
- * Class의 prototype chain을 따라 RAW 메타데이터를 child-first 병합한다.
27
+ * Merges RAW metadata child-first along the prototype chain of Class.
28
28
  *
29
- * 병합 규칙:
30
- * - validation: union merge (부모+자식 모두 적용, 중복 rule 제거)
31
- * - transform: 자식 우선, 자식에 없으면 부모 계승
32
- * - expose: 자식 우선, 자식에 없으면 부모 계승
33
- * - exclude: 자식 우선, 자식에 없으면 부모 계승
34
- * - type: 자식 우선, 자식에 없으면 부모 계승
35
- * - flags: 자식 우선, 자식에 없는 플래그만 부모에서 보충
29
+ * Merge rules:
30
+ * - validation: union merge (both parent and child apply, duplicate rules removed)
31
+ * - transform: child takes priority, inherits from parent if absent in child
32
+ * - expose: child takes priority, inherits from parent if absent in child
33
+ * - exclude: child takes priority, inherits from parent if absent in child
34
+ * - type: child takes priority, inherits from parent if absent in child
35
+ * - flags: child takes priority, only missing flags are supplemented from parent
36
36
  */
37
37
  export declare function mergeInheritance(Class: Function): RawClassMeta;
38
38
  export declare const __testing__: {
@@ -1,7 +1,7 @@
1
1
  import type { RawClassMeta } from '../types';
2
2
  import type { SealOptions, RuntimeOptions } from '../interfaces';
3
3
  /**
4
- * serialize executor 코드 생성.
5
- * 무검증 전제항상 Record<string, unknown> 반환 (§4.3).
4
+ * Generate serialize executor code.
5
+ * Assumes no validation always returns Record<string, unknown> (§4.3).
6
6
  */
7
7
  export declare function buildSerializeCode<T>(Class: Function, merged: RawClassMeta, options: SealOptions | undefined, isAsync: boolean): (instance: T, opts?: RuntimeOptions) => Record<string, unknown> | Promise<Record<string, unknown>>;
@@ -1,10 +1,10 @@
1
1
  /**
2
- * 2개의 Symbol외부 저장소 0, 글로벌 오염 0
3
- * Symbol.for 사용: AOT 코드와 런타임 코드가 동일 Symbol 공유할 있도록 global registry 사용
2
+ * 2 Symbolszero external storage, zero global pollution
3
+ * Uses Symbol.for: allows AOT code and runtime code to share the same Symbol via the global registry
4
4
  */
5
- /** Tier 1 수집 메타데이터 (데코레이터가 Class 저장) */
5
+ /** Tier 1 collection metadata (stored on Class by decorators) */
6
6
  export declare const RAW: unique symbol;
7
- /** Tier 2 봉인 결과 (seal()이 Class 저장하는 dual executor) */
7
+ /** Tier 2 seal result (dual executor stored on Class by seal()) */
8
8
  export declare const SEALED: unique symbol;
9
- /** 클래스 레벨 @Schema() 메타데이터 */
9
+ /** Class-level @Schema() metadata */
10
10
  export declare const RAW_CLASS_SCHEMA: unique symbol;
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{e as a,f as b,g as c}from"../index-aegrb1kn.js";export{b as SEALED,c as RAW_CLASS_SCHEMA,a as RAW};
2
+ import{e as a,f as b,g as c}from"../index-70ggmxsa.js";export{b as SEALED,c as RAW_CLASS_SCHEMA,a as RAW};
3
3
 
4
4
  //# debugId=51B5F46B85FFE3B364756E2164756E21
5
5
  //# sourceMappingURL=symbols.js.map
@@ -1,13 +1,13 @@
1
1
  export interface EmitContext {
2
- /** RegExp 참조 배열에 등록, 인덱스 반환 */
2
+ /** Register a RegExp in the reference array, return its index */
3
3
  addRegex(re: RegExp): number;
4
- /** 참조 배열에 등록, 인덱스 반환함수, 배열, Set, 원시값 */
4
+ /** Register in the reference array, return its index functions, arrays, Sets, primitives, etc. */
5
5
  addRef(value: unknown): number;
6
- /** SealedExecutors 객체 참조 배열에 등록중첩 @Type DTO용 */
6
+ /** Register a SealedExecutors object in the reference array for nested @Type DTOs */
7
7
  addExecutor(executor: SealedExecutors<unknown>): number;
8
- /** 에러 코드로 실패 처리 코드 문자열 생성 — path builder 바인딩 */
8
+ /** Generate a failure code string from an error code — path is bound by the builder */
9
9
  fail(code: string): string;
10
- /** 에러 수집 모드 여부 (= !stopAtFirstError) */
10
+ /** Whether error collection mode is enabled (= !stopAtFirstError) */
11
11
  collectErrors: boolean;
12
12
  }
13
13
  export interface EmittableRule {
@@ -15,17 +15,17 @@ export interface EmittableRule {
15
15
  emit(varName: string, ctx: EmitContext): string;
16
16
  readonly ruleName: string;
17
17
  /**
18
- * builder typeof 가드 삽입 여부를 판단하는 메타.
19
- * 해당 타입을 전제하는 rule만 설정 (예: isEmail → 'string').
20
- * @IsString 자체는 undefined (자체 typeof 포함).
18
+ * Meta for the builder to determine whether to insert a typeof guard.
19
+ * Only set for rules that assume a specific type (e.g., isEmail → 'string').
20
+ * @IsString itself is undefined (it includes its own typeof check).
21
21
  */
22
22
  readonly requiresType?: 'string' | 'number' | 'boolean' | 'date';
23
- /** 파라미터를 외부에서 읽을 있도록 노출 — toJsonSchema 매핑에 사용 */
23
+ /** Expose rule parameters for external readingused for toJsonSchema mapping */
24
24
  readonly constraints?: Record<string, unknown>;
25
- /** async validate 함수 사용 true — deserialize-builder await 코드를 생성 */
25
+ /** true when using an async validate function — deserialize-builder generates await code */
26
26
  readonly isAsync?: boolean;
27
27
  }
28
- /** 사용자 정의 메시지 콜백 인자 */
28
+ /** Arguments for user-defined message callback */
29
29
  export interface MessageArgs {
30
30
  property: string;
31
31
  value: unknown;
@@ -35,17 +35,17 @@ export interface RuleDef {
35
35
  rule: EmittableRule;
36
36
  each?: boolean;
37
37
  groups?: string[];
38
- /** 검증 실패 BakerError.message 포함할 */
38
+ /** Value to include in BakerError.message on validation failure */
39
39
  message?: string | ((args: MessageArgs) => string);
40
- /** 검증 실패 BakerError.context 포함할 임의 */
40
+ /** Arbitrary value to include in BakerError.context on validation failure */
41
41
  context?: unknown;
42
42
  }
43
- /** @Transform 콜백 시그니처 */
43
+ /** @Transform callback signature */
44
44
  export type TransformFunction = (params: TransformParams) => unknown;
45
45
  export interface TransformParams {
46
46
  value: unknown;
47
47
  key: string;
48
- /** deserialize: input 원본 객체, serialize: class 인스턴스 */
48
+ /** deserialize: original input object, serialize: class instance */
49
49
  obj: Record<string, unknown>;
50
50
  type: 'deserialize' | 'serialize';
51
51
  }
@@ -77,23 +77,29 @@ export interface TypeDef {
77
77
  }[];
78
78
  };
79
79
  keepDiscriminatorProperty?: boolean;
80
- /** seal() 정규화 결과 — fn() 배열을 반환하면 true */
80
+ /** seal() normalization resulttrue if fn() returns an array */
81
81
  isArray?: boolean;
82
- /** seal() 정규화 결과fn() 해석 캐시된 클래스 (프리미티브 제외, DTO만) */
82
+ /** seal() normalization resultcached class after resolving fn() (DTOs only, excluding primitives) */
83
83
  resolvedClass?: new (...args: any[]) => any;
84
+ /** seal() normalization result — Map or Set collection type */
85
+ collection?: 'Map' | 'Set';
86
+ /** Nested DTO class thunk for Map value / Set element */
87
+ collectionValue?: () => new (...args: any[]) => any;
88
+ /** seal() normalization result — cached class after resolving collectionValue */
89
+ resolvedCollectionValue?: new (...args: any[]) => any;
84
90
  }
85
91
  export interface PropertyFlags {
86
- /** @IsOptional() — undefined/null validation 전체 skip */
92
+ /** @IsOptional() — skip all validation when undefined/null */
87
93
  isOptional?: boolean;
88
- /** @IsDefined() — undefined 불허 (@IsOptional 오버라이드). 현재 코드는 undefined 거부, null 후속 검증에 위임 */
94
+ /** @IsDefined() — disallow undefined (overrides @IsOptional). Current code rejects only undefined; null is delegated to subsequent validation */
89
95
  isDefined?: boolean;
90
- /** @IsNullable() — null 허용+할당, undefined 거부 */
96
+ /** @IsNullable() — allow and assign null, reject undefined */
91
97
  isNullable?: boolean;
92
- /** @ValidateIf(cond) — false 필드 전체 검증 skip */
98
+ /** @ValidateIf(cond) — skip all field validation when false */
93
99
  validateIf?: (obj: any) => boolean;
94
- /** @ValidateNested() — 중첩 DTO 재귀 검증 트리거. @Type 함께 사용 */
100
+ /** @ValidateNested() — trigger recursive validation for nested DTOs. Used with @Type */
95
101
  validateNested?: boolean;
96
- /** @ValidateNested({ each: true }) — 배열 원소별 중첩 DTO 검증 */
102
+ /** @ValidateNested({ each: true }) — validate nested DTOs per array element */
97
103
  validateNestedEach?: boolean;
98
104
  }
99
105
  export interface RawPropertyMeta {
@@ -112,15 +118,15 @@ import type { RuntimeOptions } from './interfaces';
112
118
  import type { BakerError } from './errors';
113
119
  import type { Result, ResultAsync } from '@zipbul/result';
114
120
  export interface SealedExecutors<T> {
115
- /** 내부 executor — Result 패턴. deserialize() 감싸서 throw 변환 */
121
+ /** Internal executor — Result pattern. deserialize() wraps and converts to throw */
116
122
  _deserialize(input: unknown, options?: RuntimeOptions): Result<T, BakerError[]> | ResultAsync<T, BakerError[]>;
117
- /** 내부 executor — 항상 성공. serialize 무검증 전제 */
123
+ /** Internal executor — always succeeds. serialize assumes no validation */
118
124
  _serialize(instance: T, options?: RuntimeOptions): Record<string, unknown> | Promise<Record<string, unknown>>;
119
- /** deserialize 방향에 async 규칙/transform/nested 있으면 true */
125
+ /** true if the deserialize direction has async rules/transforms/nested */
120
126
  _isAsync: boolean;
121
- /** serialize 방향에 async transform/nested 있으면 true */
127
+ /** true if the serialize direction has async transforms/nested */
122
128
  _isSerializeAsync: boolean;
123
- /** seal 병합된 메타데이터 캐시 — toJsonSchema에서 사용 (RAW 삭제 후에도 유효) */
129
+ /** Merged metadata cache at seal time used by toJsonSchema (valid even after RAW is deleted) */
124
130
  _merged?: RawClassMeta;
125
131
  }
126
132
  export interface JsonSchema202012 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipbul/baker",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Decorator-based validate + transform with inline code generation. class-validator DX, AOT-level performance, zero reflect-metadata.",
5
5
  "license": "MIT",
6
6
  "author": "Junhyung Park (https://github.com/parkrevil)",
@@ -1,6 +0,0 @@
1
- // @bun
2
- import{e as J}from"./index-aegrb1kn.js";var Q=new Set;function T(b,w){if(!Object.prototype.hasOwnProperty.call(b,J))b[J]=Object.create(null),Q.add(b);let j=b[J];return j[w]??={validation:[],transform:[],expose:[],exclude:null,type:null,flags:{},schema:null}}function U(b){return b[Symbol.toStringTag]==="AsyncFunction"}var Z=Symbol.for("baker:arrayOf");function d(...b){let w={rules:b};return w[Z]=!0,w}function $(b){return typeof b==="object"&&b!==null&&b[Z]===!0}var K=new Set(["type","discriminator","keepDiscriminatorProperty","rules","optional","nullable","name","deserializeName","serializeName","exclude","groups","when","schema","transform","transformDirection"]);function X(b){if(typeof b==="function")return!1;if(typeof b!=="object"||b===null)return!1;if($(b))return!1;let w=Object.keys(b);if(w.length===0)return!0;return w.some((j)=>K.has(j))}function N(b){if(b.length===0)return{rules:[],options:{}};if(b.length===1&&X(b[0])){let j=b[0];return{rules:j.rules??[],options:j}}let w=b[b.length-1];if(X(w)){let j=w,B=b.slice(0,-1);if(j.rules)B=[...B,...j.rules];return{rules:B,options:j}}return{rules:b,options:{}}}function P(b,w,j){for(let B of w)if($(B))for(let G of B.rules)b.validation.push({rule:G,each:!0,groups:j.groups});else b.validation.push({rule:B,groups:j.groups})}function S(b,w){if(w.name)b.expose.push({name:w.name,groups:w.groups});else if(w.deserializeName||w.serializeName){if(w.deserializeName)b.expose.push({name:w.deserializeName,deserializeOnly:!0,groups:w.groups});if(w.serializeName)b.expose.push({name:w.serializeName,serializeOnly:!0,groups:w.groups})}else if(w.groups)b.expose.push({groups:w.groups});else b.expose.push({})}function V(b,w){if(!w.transform)return;let j=w.transform,G=U(j)?async(z)=>j({value:z.value,key:z.key,obj:z.obj,direction:z.type}):(z)=>j({value:z.value,key:z.key,obj:z.obj,direction:z.type});if(w.transformDirection&&w.transformDirection!=="deserializeOnly"&&w.transformDirection!=="serializeOnly")throw Error(`Invalid transformDirection: "${w.transformDirection}". Expected 'deserializeOnly' or 'serializeOnly'.`);let q={};if(w.transformDirection==="deserializeOnly")q.deserializeOnly=!0;if(w.transformDirection==="serializeOnly")q.serializeOnly=!0;b.transform.push({fn:G,options:Object.keys(q).length>0?q:void 0})}function F(...b){return(w,j)=>{let B=w.constructor,q=T(B,j),{rules:z,options:v}=N(b);if(P(q,z,v),v.optional)q.flags.isOptional=!0;if(v.nullable)q.flags.isNullable=!0;if(v.when)q.flags.validateIf=v.when;if(v.type)q.type={fn:v.type,discriminator:v.discriminator,keepDiscriminatorProperty:v.keepDiscriminatorProperty};if(S(q,v),v.exclude){if(v.exclude===!0)q.exclude={};else if(v.exclude==="deserializeOnly")q.exclude={deserializeOnly:!0};else if(v.exclude==="serializeOnly")q.exclude={serializeOnly:!0}}if(V(q,v),v.schema)if(typeof q.schema==="function");else q.schema={...q.schema??{},...v.schema}}}
3
- export{Q as a,U as b,d as c,F as d};
4
-
5
- //# debugId=3AECA7367D7355B264756E2164756E21
6
- //# sourceMappingURL=index-57gr0v18.js.map
@@ -1,6 +0,0 @@
1
- // @bun
2
- var b=Symbol.for("baker:raw"),d=Symbol.for("baker:sealed"),f=Symbol.for("baker:rawClassSchema");
3
- export{b as e,d as f,f as g};
4
-
5
- //# debugId=BEECA922A80577C664756E2164756E21
6
- //# sourceMappingURL=index-aegrb1kn.js.map