@zipbul/baker 3.4.1 → 4.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 +31 -0
- package/README.md +236 -148
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/src/baker.d.ts +26 -0
- package/dist/src/baker.js +1 -0
- package/dist/src/configure.d.ts +7 -1
- package/dist/src/configure.js +1 -1
- package/dist/src/create-rule.d.ts +2 -1
- package/dist/src/decorators/field.d.ts +2 -1
- package/dist/src/decorators/field.js +1 -1
- package/dist/src/enums.d.ts +51 -0
- package/dist/src/enums.js +1 -0
- package/dist/src/rule-plan.d.ts +5 -3
- package/dist/src/rule-plan.js +1 -1
- package/dist/src/rules/array.js +1 -1
- package/dist/src/rules/date.js +1 -1
- package/dist/src/rules/locales.js +1 -1
- package/dist/src/rules/number.js +1 -1
- package/dist/src/rules/object.js +1 -1
- package/dist/src/rules/string.js +5 -5
- package/dist/src/rules/typechecker.js +5 -5
- package/dist/src/seal/deserialize-builder.js +230 -230
- package/dist/src/seal/enums.d.ts +8 -0
- package/dist/src/seal/enums.js +1 -0
- package/dist/src/seal/expose-validator.js +1 -1
- package/dist/src/seal/seal.d.ts +15 -1
- package/dist/src/seal/seal.js +1 -1
- package/dist/src/seal/serialize-builder.js +8 -8
- package/dist/src/seal/validate-meta.js +1 -1
- package/dist/src/types.d.ts +11 -10
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Null/undefined guard strategy selected per field from its optional/nullable/defined flags. */
|
|
2
|
+
export declare enum GuardKey {
|
|
3
|
+
NullableOptional = "nullable+optional",
|
|
4
|
+
Nullable = "nullable",
|
|
5
|
+
Defined = "defined",
|
|
6
|
+
Optional = "optional",
|
|
7
|
+
Default = "default"
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var GuardKey;((l)=>{l.NullableOptional="nullable+optional";l.Nullable="nullable";l.Defined="defined";l.Optional="optional";l.Default="default"})(GuardKey||={});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BakerError as K}from"../errors.js";function validateExposeStacks(F,z){const C=z?`${z}.`:"";for(const[A,H]of Object.entries(F)){for(const q of H.expose){if(q.deserializeOnly&&q.serializeOnly)throw new K(`Invalid @Expose on field '${C}${A}': cannot have both deserializeOnly:true and serializeOnly:true on the same @Expose entry. Use separate @Expose decorators for each direction.`);if(q.name==="__proto__"||q.name==="constructor"||q.name==="prototype")throw new K(`Invalid @Field name on '${C}${A}': '${q.name}' is a reserved property name and cannot be used as a serialized key.`)}const I=H.expose.filter((q)=>!q.serializeOnly),J=H.expose.filter((q)=>!q.deserializeOnly);
|
|
1
|
+
import{Direction as L}from"../enums.js";import{BakerError as K}from"../errors.js";function validateExposeStacks(F,z){const C=z?`${z}.`:"";for(const[A,H]of Object.entries(F)){for(const q of H.expose){if(q.deserializeOnly&&q.serializeOnly)throw new K(`Invalid @Expose on field '${C}${A}': cannot have both deserializeOnly:true and serializeOnly:true on the same @Expose entry. Use separate @Expose decorators for each direction.`);if(q.name==="__proto__"||q.name==="constructor"||q.name==="prototype")throw new K(`Invalid @Field name on '${C}${A}': '${q.name}' is a reserved property name and cannot be used as a serialized key.`)}const I=H.expose.filter((q)=>!q.serializeOnly),J=H.expose.filter((q)=>!q.deserializeOnly);M(C+A,I,L.Deserialize);M(C+A,J,L.Serialize)}}function M(F,z,C){for(let A=0;A<z.length;A++)for(let H=A+1;H<z.length;H++){const I=z[A].groups??[],J=z[H].groups??[];if(R(I,J)){const q=new Set(J),P=I.length===0?[]:I.filter((Q)=>q.has(Q));throw new K(`@Expose conflict on '${F}': 2 @Expose stacks with '${C}' direction and overlapping groups [${P.join(", ")}]. Each direction must have at most one @Expose per group set.`)}}}function R(F,z){if(F.length===0&&z.length===0)return!0;if(F.length===0||z.length===0)return!1;return F.some((C)=>z.includes(C))}export{validateExposeStacks};
|
package/dist/src/seal/seal.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SealOptions } from '../interfaces';
|
|
1
2
|
import type { RawClassMeta, SealedExecutors } from '../types';
|
|
2
3
|
/** @internal Placeholder executor for circular dependency detection during seal */
|
|
3
4
|
declare function circularPlaceholder(className: string): SealedExecutors<unknown>;
|
|
@@ -6,6 +7,19 @@ declare function circularPlaceholder(className: string): SealedExecutors<unknown
|
|
|
6
7
|
* Throws if the class was never sealed. Users must call `seal()` at app startup.
|
|
7
8
|
*/
|
|
8
9
|
declare function ensureSealed(Class: Function): SealedExecutors<unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Seal every class in `registry` with `options`. Shared core of both the global default `seal()`
|
|
12
|
+
* and per-scope `createBaker().seal()`. Transactional: on any failure every class sealed by this
|
|
13
|
+
* call is rolled back. Clears `registry` on success.
|
|
14
|
+
*
|
|
15
|
+
* A class already sealed (e.g. a shared value-type DTO reached from another scope's roots) is
|
|
16
|
+
* reused as-is — class identity is the isolation boundary, so a shared class carries one sealed
|
|
17
|
+
* behaviour. Distinct classes stay fully isolated because each is sealed with its scope's options.
|
|
18
|
+
*
|
|
19
|
+
* @param track Optional set recording successfully-sealed classes. The default seal passes the
|
|
20
|
+
* global `sealedClasses` so `unseal()` can restore them; instances pass nothing.
|
|
21
|
+
*/
|
|
22
|
+
declare function sealRegistry(registry: Set<Function>, options: SealOptions, track?: Set<Function>): void;
|
|
9
23
|
/**
|
|
10
24
|
* Seal a single class (and its nested DTOs). Not part of the public API — `seal()` (argless)
|
|
11
25
|
* is the only public entry. Exposed via `__testing__.sealClass` so tests can seal one class in
|
|
@@ -39,5 +53,5 @@ declare const __testing__: {
|
|
|
39
53
|
circularPlaceholder: typeof circularPlaceholder;
|
|
40
54
|
sealClass: typeof sealOneClass;
|
|
41
55
|
};
|
|
42
|
-
export { ensureSealed, seal, mergeInheritance, __testing__ };
|
|
56
|
+
export { ensureSealed, seal, sealRegistry, mergeInheritance, __testing__ };
|
|
43
57
|
export { sealedClasses, resetForTesting } from './seal-state';
|
package/dist/src/seal/seal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getGlobalOptions as
|
|
1
|
+
import{getGlobalOptions as h}from"../configure.js";import{CollectionType as O,Direction as M}from"../enums.js";import{BakerError as G}from"../errors.js";import{deleteSealed as T,freezeRaw as I,getRaw as R,getSealed as E,hasRawOwn as f,hasSealedOwn as S,setSealed as g}from"../meta-access.js";import{globalRegistry as k}from"../registry.js";import{isAsyncFunction as u}from"../utils.js";import{analyzeCircular as y}from"./circular-analyzer.js";import{buildDeserializeCode as p,buildValidateCode as C}from"./deserialize-builder.js";import{validateExposeStacks as m}from"./expose-validator.js";import{sealedClasses as v,isSealed as n,markSealed as c}from"./seal-state.js";import{buildSerializeCode as d}from"./serialize-builder.js";import{validateMeta as o}from"./validate-meta.js";const i=new Set(["__proto__","constructor","prototype"]);const D=new Set([Number,String,Boolean,Date]);function A(H){const q=`Circular dependency during seal: ${H} is still being sealed`;return{deserialize(){throw new G(q)},serialize(){throw new G(q)},validate(){throw new G(q)},isAsync:!1,isSerializeAsync:!1}}function B(H,q,J){const Q=q===M.Deserialize?"isAsync":"isSerializeAsync",j=J??new Set,$=(X)=>{if(j.has(X))return!1;j.add(X);const W=E(X);if(W?.merged)return W[Q]===!0;return B(mergeInheritance(X),q,j)};for(const X of Object.values(H)){if(q===M.Deserialize&&X.validation.some((W)=>W.rule.isAsync))return!0;for(const W of X.transform){if(q===M.Deserialize?W.options?.serializeOnly:W.options?.deserializeOnly)continue;if(W.isAsync??u(W.fn))return!0}if(r(X).some($))return!0}return!1}function r(H){const q=H.type;if(!q)return[];const J=[];if(q.resolvedClass)J.push(q.resolvedClass);if(q.resolvedCollectionValue)J.push(q.resolvedCollectionValue);if(q.discriminator)for(const Q of q.discriminator.subTypes)J.push(Q.value);if(J.length===0&&q.fn){const Q=q.fn();if(Q===Map||Q===Set){const j=q.collectionValue?.();if(typeof j==="function"&&!D.has(j))J.push(j)}else{const j=Array.isArray(Q)?Q[0]:Q;if(typeof j==="function"&&!D.has(j))J.push(j)}}return J}function ensureSealed(H){const q=E(H);if(!q){const J=H.name||"<anonymous class>";throw new G(`${J} is not sealed. Call seal() at app startup before deserialize/validate/serialize. (If ${J} has no @Field decorators, decorate at least one property.)`)}return q}function t(){if(n())return;sealRegistry(k,h(),v);c()}function sealRegistry(H,q,J){const Q=new Set;try{for(const j of H)P(j,q,Q)}catch(j){for(const $ of Q)T($);throw j}for(const j of Q){J?.add(j);I(j)}H.clear()}function l(H){if(S(H))return;const q=h(),J=new Set;try{P(H,q,J)}catch(Q){for(const j of J)T(j);throw Q}for(const Q of J){v.add(Q);I(Q);k.delete(Q)}}function seal(){t()}function P(H,q,J){if(S(H))return;const Q=A(H.name);g(H,Q);try{const j=mergeInheritance(H);for(const U of Object.keys(j))if(i.has(U))throw new G(`${H.name}: field name '${U}' is not allowed (reserved property name)`);for(const[U,K]of Object.entries(j)){if(!K.type?.fn)continue;let F;try{F=K.type.fn()}catch(w){throw new G(`${H.name}.${U}: type function threw: ${w.message}`,{cause:w})}if(F===Map||F===Set){const w=F===Map?O.Map:O.Set,b={...K.type,collection:w,isArray:!1};if(K.type.collectionValue){let x;try{x=K.type.collectionValue()}catch(z){throw new G(`${H.name}.${U}: collectionValue function threw: ${z.message}`,{cause:z})}if(x!=null&&typeof x==="function"&&!D.has(x))b.resolvedCollectionValue=x}j[U]={...K,type:b};continue}const N=Array.isArray(F),V=N?F[0]:F;if(V==null||typeof V!=="function")throw new G(`${H.name}: @Type/@Field type must return a constructor or [constructor], got ${String(V)}`);const _={...K.type,isArray:N};if(!D.has(V)){_.resolvedClass=V;if(!K.flags.validateNested||!K.flags.validateNestedEach){K.flags={...K.flags};if(!K.flags.validateNested)K.flags.validateNested=!0;if(N&&!K.flags.validateNestedEach)K.flags.validateNestedEach=!0}}j[U]={...K,type:_}}m(j,H.name);o(H,j);const $=y(H);for(const U of Object.values(j)){if(U.type?.resolvedClass)P(U.type.resolvedClass,q,J);if(U.type?.resolvedCollectionValue)P(U.type.resolvedCollectionValue,q,J);if(U.type?.discriminator)for(const K of U.type.discriminator.subTypes)P(K.value,q,J)}const X=B(j,M.Deserialize),W=B(j,M.Serialize),L=p(H,j,q,$,X),Y=C(H,j,q,$,X),Z=d(H,j,q,W);Object.assign(Q,{deserialize:L,serialize:Z,validate:Y,isAsync:X,isSerializeAsync:W,merged:j})}catch(j){T(H);throw j}J?.add(H)}function mergeInheritance(H){const q=[];let J=H;while(J&&J!==Object){if(f(J))q.push(J);const $=Object.getPrototypeOf(J);J=$===J?null:$}const Q=Object.create(null),j=q.length>1;for(const $ of q){const X=R($);for(const[W,L]of Object.entries(X))if(!Q[W])Q[W]=j?{validation:[...L.validation],transform:[...L.transform],expose:[...L.expose],exclude:L.exclude,type:L.type,flags:{...L.flags}}:L;else{const Y=Q[W],Z=L;for(const F of Z.validation)if(!Y.validation.some((N)=>N.rule.ruleName===F.rule.ruleName))Y.validation.push(F);if(Y.transform.length===0&&Z.transform.length>0)Y.transform=[...Z.transform];if(Y.expose.length===0&&Z.expose.length>0)Y.expose=[...Z.expose];if(Y.exclude===null&&Z.exclude!==null)Y.exclude=Z.exclude;if(Y.type===null&&Z.type!==null)Y.type=Z.type;const U=Y.flags,K=Z.flags;if(K.isOptional!==void 0&&U.isOptional===void 0)U.isOptional=K.isOptional;if(K.isDefined!==void 0&&U.isDefined===void 0)U.isDefined=K.isDefined;if(K.validateIf!==void 0&&U.validateIf===void 0)U.validateIf=K.validateIf;if(K.isNullable!==void 0&&U.isNullable===void 0)U.isNullable=K.isNullable;if(K.validateNested!==void 0&&U.validateNested===void 0)U.validateNested=K.validateNested;if(K.validateNestedEach!==void 0&&U.validateNestedEach===void 0)U.validateNestedEach=K.validateNestedEach}}return Q}const __testing__={mergeInheritance,circularPlaceholder:A,sealClass:l};export{ensureSealed,seal,sealRegistry,mergeInheritance,__testing__};export{sealedClasses,resetForTesting}from"./seal-state.js";
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{CollectionType as c}from"../enums.js";import{BakerError as p}from"../errors.js";import{getSealed as A}from"../meta-access.js";import{sanitizeKey as E,buildGroupsHasExpr as m}from"./codegen-utils.js";const j={out:"__bk$out",fieldVal:"__bk$fv_",groups:"__bk$groups",group0:"__bk$group0",groupsSet:"__bk$groupsSet",setArr:"__bk$sa",setItem:"__bk$si",mapObj:"__bk$m",mapEntry:"__bk$me",serResult:"__bk$sr",outItem:"__bk$out_item",discArr:"__bk$da",discIdx:"__bk$di",nestedArr:"__bk$na",nestedIdx:"__bk$ni",nestedItem:"__bk$nitem"};function u(U,q){const L=q.find((R)=>R.serializeOnly&&R.name);if(L)return L.name;const M=q.find((R)=>!R.deserializeOnly&&!R.serializeOnly&&R.name);if(M)return M.name;return U}function y(U){let q=null;for(const L of U){if(L.deserializeOnly)continue;if(!L.groups||L.groups.length===0)return;if(q===null)q=new Set;for(const M of L.groups)q.add(M)}return q===null?void 0:[...q]}function x(U,q,L,M){if(L.length===0)return null;if(L.length===1){const Y=L[0],W=M.length;M.push(Y.fn);const Z=`refs[${W}]({value:${U},key:${JSON.stringify(q)},obj:instance})`;return Y.isAsync?`(await ${Z})`:Z}if(L.length===2){const Y=L[1],W=L[0],Z=M.length;M.push(Y.fn);const F=M.length;M.push(W.fn);const z=`refs[${Z}]({value:${U},key:${JSON.stringify(q)},obj:instance})`,Q=Y.isAsync?`(await ${z})`:z,_=`refs[${F}]({value:${Q},key:${JSON.stringify(q)},obj:instance})`;return W.isAsync?`(await ${_})`:_}let R=U;for(let Y=L.length-1;Y>=0;Y-=1){const W=L[Y],Z=M.length;M.push(W.fn);const F=`refs[${Z}]({value:${R},key:${JSON.stringify(q)},obj:instance})`;R=W.isAsync?`(await ${F})`:F}return R}function T(U,q,L,M){const R=x(U,q,L,M);return R?`
|
|
2
2
|
${U} = ${R};`:""}function buildSerializeCode(U,q,L,M){const R=[],Y=[];let W=`'use strict';
|
|
3
3
|
`;W+=`var ${j.out} = {};
|
|
4
4
|
`;if(Object.values(q).some((_)=>{const v=y(_.expose);return v&&v.length>0})){W+=`var ${j.groups} = opts && opts.groups;
|
|
5
5
|
`;W+=`var ${j.group0} = ${j.groups} && ${j.groups}.length === 1 ? ${j.groups}[0] : null;
|
|
6
6
|
`;W+=`var ${j.groupsSet} = ${j.groups} && ${j.groups}.length > 1 ? new Set(${j.groups}) : null;
|
|
7
|
-
`}for(const[_,v]of Object.entries(q))W+=
|
|
7
|
+
`}for(const[_,v]of Object.entries(q))W+=f(_,v,R,Y,M,L,U.name);W+=`return ${j.out};
|
|
8
8
|
`;const F=U.name.replace(/[^\w$.-]/g,"_");W+=`//# sourceURL=baker://${F}/serialize
|
|
9
|
-
`;return Function("refs","execs","BakerError",`return ${M?"async function":"function"}(instance, opts) { `+W+" }")(R,Y,
|
|
9
|
+
`;return Function("refs","execs","BakerError",`return ${M?"async function":"function"}(instance, opts) { `+W+" }")(R,Y,p)}function f(U,q,L,M,R,Y,W=""){if(q.exclude){if(!q.exclude.deserializeOnly){if(Y?.debug){const X=q.exclude.serializeOnly?"serializeOnly":"bidirectional";return`// [baker] field ${JSON.stringify(U)} excluded (${X} @Exclude)
|
|
10
10
|
`}return""}}if(q.expose.length>0&&q.expose.every((X)=>X.deserializeOnly)){if(Y?.debug)return`// [baker] field ${JSON.stringify(U)} excluded (all @Expose entries are deserializeOnly)
|
|
11
|
-
`;return""}const Z=
|
|
12
|
-
`;let v="",S="";if(F&&F.length>0){v=`if ((${j.group0} !== null || ${j.groupsSet}) && (${
|
|
11
|
+
`;return""}const Z=u(U,q.expose),F=y(q.expose),z=E(U),Q=`${j.fieldVal}${z}`;let _="";_+=`var ${Q} = instance[${JSON.stringify(U)}];
|
|
12
|
+
`;let v="",S="";if(F&&F.length>0){v=`if ((${j.group0} !== null || ${j.groupsSet}) && (${m(j.group0,j.groupsSet,F)})) {
|
|
13
13
|
`;S=`}
|
|
14
|
-
`}let H="";const b=q.flags.isOptional,g=q.transform.filter((X)=>!X.options?.deserializeOnly);if(q.type?.collection){const X=`${j.out}[${JSON.stringify(Z)}]`,$=q.type.collection;let J;if($===
|
|
14
|
+
`}let H="";const b=q.flags.isOptional,g=q.transform.filter((X)=>!X.options?.deserializeOnly);if(q.type?.collection){const X=`${j.out}[${JSON.stringify(Z)}]`,$=q.type.collection;let J;if($===c.Set)if(q.type.resolvedCollectionValue){const B=A(q.type.resolvedCollectionValue),D=M.length;M.push(B);if(R)J=`{ var __ser_ps = []; for (var __ser_item of ${Q}) { __ser_ps.push(__ser_item == null ? __ser_item : execs[${D}].serialize(__ser_item, opts)); } ${X} = await Promise.all(__ser_ps); }`;else{J=`var ${j.setArr} = [];
|
|
15
15
|
`;J+=` for (var ${j.setItem} of ${Q}) {
|
|
16
16
|
`;J+=` ${j.setArr}.push(${j.setItem} == null ? ${j.setItem} : execs[${D}].serialize(${j.setItem}, opts));
|
|
17
17
|
`;J+=` }
|
|
@@ -63,8 +63,8 @@ ${U} = ${R};`:""}function buildSerializeCode(U,q,L,M){const R=[],Y=[];let W=`'us
|
|
|
63
63
|
} else {
|
|
64
64
|
${$} = ${Q};
|
|
65
65
|
}
|
|
66
|
-
`}else{const X=
|
|
66
|
+
`}else{const X=n(U,Z,Q,q,L);if(b){H+=`if (${Q} !== undefined) {
|
|
67
67
|
`;H+=" "+X+`
|
|
68
68
|
`;H+=`}
|
|
69
69
|
`}else H+=X+`
|
|
70
|
-
`}_+=v+H+S;return _}function
|
|
70
|
+
`}_+=v+H+S;return _}function n(U,q,L,M,R){const Y=`${j.out}[${JSON.stringify(q)}]`,W=M.transform.filter((Z)=>!Z.options?.deserializeOnly);if(W.length>0){const Z=x(L,U,W,R);return`${Y} = ${Z};`}return`${Y} = ${L};`}export{buildSerializeCode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BakerError as
|
|
1
|
+
import{CollectionType as K}from"../enums.js";import{BakerError as z}from"../errors.js";import{hasRawOwn as H}from"../meta-access.js";export function validateMeta(I,J){const q=I.name;for(const[x,D]of Object.entries(J)){if(D.type?.discriminator){const f=D.type.discriminator;if(typeof f.property!=="string"||f.property.length===0)throw new z(`${q}.${x}: discriminator.property must be a non-empty string.`);if(!Array.isArray(f.subTypes)||f.subTypes.length===0)throw new z(`${q}.${x}: discriminator.subTypes must be a non-empty array of { value, name } entries.`);const F=new Set;for(let A=0;A<f.subTypes.length;A++){const j=f.subTypes[A];if(typeof j.name!=="string"||j.name.length===0)throw new z(`${q}.${x}: discriminator.subTypes[${A}].name must be a non-empty string.`);if(typeof j.value!=="function")throw new z(`${q}.${x}: discriminator.subTypes[${A}].value must be a class constructor (got ${typeof j.value}).`);if(F.has(j.name))throw new z(`${q}.${x}: discriminator.subTypes has duplicate name '${j.name}'. Each subType must have a unique name.`);F.add(j.name);if(!H(j.value))throw new z(`${q}.${x}: discriminator.subTypes[${A}].value (${j.value.name}) has no @Field decorators.`)}}const G=D.type?.collection;if(G!==void 0&&D.type?.resolvedCollectionValue){const f=D.type.resolvedCollectionValue;if(!H(f)){const F=G===K.Set?"setValue":"mapValue";throw new z(`${q}.${x}: ${F} target (${f.name}) has no @Field decorators.`)}}}}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Result, ResultAsync } from '@zipbul/result';
|
|
2
|
+
import type { CacheKey, CollectionType, RequiredType, RuleOp, RulePlanCheckKind, RulePlanExprKind } from './enums';
|
|
2
3
|
import type { BakerIssue } from './errors';
|
|
3
4
|
import type { RuntimeOptions } from './interfaces';
|
|
4
5
|
export interface EmitContext {
|
|
@@ -26,7 +27,7 @@ export interface EmittableRule {
|
|
|
26
27
|
* Only set for rules that assume a specific type (e.g., isEmail → 'string').
|
|
27
28
|
* `@IsString` itself is undefined (it includes its own typeof check).
|
|
28
29
|
*/
|
|
29
|
-
readonly requiresType?:
|
|
30
|
+
readonly requiresType?: RequiredType;
|
|
30
31
|
/** Expose rule parameters for external reading */
|
|
31
32
|
readonly constraints?: Record<string, unknown>;
|
|
32
33
|
/** true when the rule is explicitly async and must be awaited */
|
|
@@ -37,30 +38,30 @@ export interface InternalRule extends EmittableRule {
|
|
|
37
38
|
readonly plan?: RulePlan;
|
|
38
39
|
}
|
|
39
40
|
export type RulePlanExpr = {
|
|
40
|
-
kind:
|
|
41
|
+
kind: RulePlanExprKind.Value;
|
|
41
42
|
} | {
|
|
42
|
-
kind:
|
|
43
|
+
kind: RulePlanExprKind.Member;
|
|
43
44
|
object: RulePlanExpr;
|
|
44
45
|
property: 'length';
|
|
45
46
|
} | {
|
|
46
|
-
kind:
|
|
47
|
+
kind: RulePlanExprKind.Call0;
|
|
47
48
|
object: RulePlanExpr;
|
|
48
49
|
method: 'getTime';
|
|
49
50
|
} | {
|
|
50
|
-
kind:
|
|
51
|
+
kind: RulePlanExprKind.Literal;
|
|
51
52
|
value: number;
|
|
52
53
|
};
|
|
53
54
|
export type RulePlanCheck = {
|
|
54
|
-
kind:
|
|
55
|
+
kind: RulePlanCheckKind.Compare;
|
|
55
56
|
left: RulePlanExpr;
|
|
56
|
-
op:
|
|
57
|
+
op: RuleOp;
|
|
57
58
|
right: RulePlanExpr;
|
|
58
59
|
} | {
|
|
59
|
-
kind:
|
|
60
|
+
kind: RulePlanCheckKind.And | RulePlanCheckKind.Or;
|
|
60
61
|
checks: RulePlanCheck[];
|
|
61
62
|
};
|
|
62
63
|
export interface RulePlan {
|
|
63
|
-
cacheKey?:
|
|
64
|
+
cacheKey?: CacheKey;
|
|
64
65
|
failure: RulePlanCheck;
|
|
65
66
|
}
|
|
66
67
|
/** Arguments for user-defined message callback */
|
|
@@ -125,7 +126,7 @@ export interface TypeDef {
|
|
|
125
126
|
/** seal() normalization result — cached class after resolving fn() (DTOs only, excluding primitives) */
|
|
126
127
|
resolvedClass?: ClassCtor;
|
|
127
128
|
/** seal() normalization result — Map or Set collection type */
|
|
128
|
-
collection?:
|
|
129
|
+
collection?: CollectionType;
|
|
129
130
|
/** Nested DTO class thunk for Map value / Set element */
|
|
130
131
|
collectionValue?: () => ClassCtor;
|
|
131
132
|
/** seal() normalization result — cached class after resolving collectionValue */
|
package/package.json
CHANGED