phecda-core 4.5.1 → 5.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/dist/index.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ export * from 'reflect-metadata';
2
+
1
3
  declare function Init(proto: any, property: PropertyKey): void;
2
4
  declare function Unmount(proto: any, property: PropertyKey): void;
3
5
  declare function Expose(proto: any, property?: PropertyKey, index?: any): void;
@@ -76,10 +78,26 @@ declare function Storage({ key, json, stringify }?: {
76
78
  key?: string;
77
79
  }): (proto: any, property?: PropertyKey) => void;
78
80
 
79
- declare function Rule(...rules: ((value: any) => void | string | boolean | Promise<void | string | boolean>)[]): (target: any, property: PropertyKey, index?: any) => void;
81
+ declare function Doc(doc: string): (target: any, property: PropertyKey, index?: any) => void;
82
+
83
+ interface RuleArgs {
84
+ model: Construct;
85
+ property: string;
86
+ value: any;
87
+ /**
88
+ * paramIndex work for params' @Rule
89
+ */
90
+ index?: number;
91
+ meta: any;
92
+ }
93
+ declare function Rule(...rules: ((args: RuleArgs) => void | string | any | true | Promise<void | string | any | true>)[]): (target: any, property?: PropertyKey, index?: any) => void;
80
94
  declare function Required(target: any, property: PropertyKey, index?: any): void;
81
95
  declare function Optional(target: any, property: PropertyKey, index?: any): void;
82
- declare function Doc(doc: string): (target: any, property: PropertyKey, index?: any) => void;
96
+ declare function Min(min: number): (target: any, property?: PropertyKey, index?: any) => void;
97
+ declare function Max(max: number): (target: any, property?: PropertyKey, index?: any) => void;
98
+ declare function Nested(model: Construct): (target: any, property: string) => void;
99
+ declare function OneOf(...models: Construct[]): (target: any, property: string) => void;
100
+ declare function Enum(map: Record<string, any>): (target: any, property: string) => void;
83
101
 
84
102
  declare function getTag<M extends Construct | AbConstruct>(moduleOrInstance: M | InstanceType<M>): PropertyKey;
85
103
  /**
@@ -124,4 +142,7 @@ declare abstract class Base {
124
142
  private _unmount;
125
143
  }
126
144
 
127
- export { type AbConstruct, Assign, Base, CLEAR_KEY, type ClassValue, Clear, type Construct, DataMap, Doc, Effect, Empty, Err, type Events, Expose, Global, If, Init, Inject, type InjectData, Injectable, Isolate, type NameSpace, Optional, PHECDA_KEY, type Phecda, Pipeline, Provide, Required, Rule, SHARE_KEY, Storage, type StorageParam, Tag, Unique, Unmount, Watcher, type WatcherParam, activeInstance, addDecoToClass, functionToClass, get, getInject, getMergedMeta, getMeta, getMetaKey, getMetaParams, getOwnMeta, getOwnMetaKey, getOwnMetaParams, getPhecdaFromTarget, getTag, init, invoke, invokeInit, invokeUnmount, isAsyncFunc, isPhecda, objectToClass, omit, override, partial, pick, set, setInject, setMeta, wait };
145
+ declare const _createErrorMessage: (type: string, { property, meta }: RuleArgs) => string;
146
+ declare function validate(model: Construct, data: any, collectErrors?: boolean, createErrMsg?: (type: string, { property, meta }: RuleArgs) => string): Promise<any[]>;
147
+
148
+ export { type AbConstruct, Assign, Base, CLEAR_KEY, type ClassValue, Clear, type Construct, DataMap, Doc, Effect, Empty, Enum, Err, type Events, Expose, Global, If, Init, Inject, type InjectData, Injectable, Isolate, Max, Min, type NameSpace, Nested, OneOf, Optional, PHECDA_KEY, type Phecda, Pipeline, Provide, Required, Rule, type RuleArgs, SHARE_KEY, Storage, type StorageParam, Tag, Unique, Unmount, Watcher, type WatcherParam, _createErrorMessage, activeInstance, addDecoToClass, functionToClass, get, getInject, getMergedMeta, getMeta, getMetaKey, getMetaParams, getOwnMeta, getOwnMetaKey, getOwnMetaParams, getPhecdaFromTarget, getTag, init, invoke, invokeInit, invokeUnmount, isAsyncFunc, isPhecda, objectToClass, omit, override, partial, pick, set, setInject, setMeta, validate, wait };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export * from 'reflect-metadata';
2
+
1
3
  declare function Init(proto: any, property: PropertyKey): void;
2
4
  declare function Unmount(proto: any, property: PropertyKey): void;
3
5
  declare function Expose(proto: any, property?: PropertyKey, index?: any): void;
@@ -76,10 +78,26 @@ declare function Storage({ key, json, stringify }?: {
76
78
  key?: string;
77
79
  }): (proto: any, property?: PropertyKey) => void;
78
80
 
79
- declare function Rule(...rules: ((value: any) => void | string | boolean | Promise<void | string | boolean>)[]): (target: any, property: PropertyKey, index?: any) => void;
81
+ declare function Doc(doc: string): (target: any, property: PropertyKey, index?: any) => void;
82
+
83
+ interface RuleArgs {
84
+ model: Construct;
85
+ property: string;
86
+ value: any;
87
+ /**
88
+ * paramIndex work for params' @Rule
89
+ */
90
+ index?: number;
91
+ meta: any;
92
+ }
93
+ declare function Rule(...rules: ((args: RuleArgs) => void | string | any | true | Promise<void | string | any | true>)[]): (target: any, property?: PropertyKey, index?: any) => void;
80
94
  declare function Required(target: any, property: PropertyKey, index?: any): void;
81
95
  declare function Optional(target: any, property: PropertyKey, index?: any): void;
82
- declare function Doc(doc: string): (target: any, property: PropertyKey, index?: any) => void;
96
+ declare function Min(min: number): (target: any, property?: PropertyKey, index?: any) => void;
97
+ declare function Max(max: number): (target: any, property?: PropertyKey, index?: any) => void;
98
+ declare function Nested(model: Construct): (target: any, property: string) => void;
99
+ declare function OneOf(...models: Construct[]): (target: any, property: string) => void;
100
+ declare function Enum(map: Record<string, any>): (target: any, property: string) => void;
83
101
 
84
102
  declare function getTag<M extends Construct | AbConstruct>(moduleOrInstance: M | InstanceType<M>): PropertyKey;
85
103
  /**
@@ -124,4 +142,7 @@ declare abstract class Base {
124
142
  private _unmount;
125
143
  }
126
144
 
127
- export { type AbConstruct, Assign, Base, CLEAR_KEY, type ClassValue, Clear, type Construct, DataMap, Doc, Effect, Empty, Err, type Events, Expose, Global, If, Init, Inject, type InjectData, Injectable, Isolate, type NameSpace, Optional, PHECDA_KEY, type Phecda, Pipeline, Provide, Required, Rule, SHARE_KEY, Storage, type StorageParam, Tag, Unique, Unmount, Watcher, type WatcherParam, activeInstance, addDecoToClass, functionToClass, get, getInject, getMergedMeta, getMeta, getMetaKey, getMetaParams, getOwnMeta, getOwnMetaKey, getOwnMetaParams, getPhecdaFromTarget, getTag, init, invoke, invokeInit, invokeUnmount, isAsyncFunc, isPhecda, objectToClass, omit, override, partial, pick, set, setInject, setMeta, wait };
145
+ declare const _createErrorMessage: (type: string, { property, meta }: RuleArgs) => string;
146
+ declare function validate(model: Construct, data: any, collectErrors?: boolean, createErrMsg?: (type: string, { property, meta }: RuleArgs) => string): Promise<any[]>;
147
+
148
+ export { type AbConstruct, Assign, Base, CLEAR_KEY, type ClassValue, Clear, type Construct, DataMap, Doc, Effect, Empty, Enum, Err, type Events, Expose, Global, If, Init, Inject, type InjectData, Injectable, Isolate, Max, Min, type NameSpace, Nested, OneOf, Optional, PHECDA_KEY, type Phecda, Pipeline, Provide, Required, Rule, type RuleArgs, SHARE_KEY, Storage, type StorageParam, Tag, Unique, Unmount, Watcher, type WatcherParam, _createErrorMessage, activeInstance, addDecoToClass, functionToClass, get, getInject, getMergedMeta, getMeta, getMetaKey, getMetaParams, getOwnMeta, getOwnMetaKey, getOwnMetaParams, getPhecdaFromTarget, getTag, init, invoke, invokeInit, invokeUnmount, isAsyncFunc, isPhecda, objectToClass, omit, override, partial, pick, set, setInject, setMeta, validate, wait };