phecda-core 4.3.0 → 4.5.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 +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +15 -8
- package/dist/index.mjs +14 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -76,9 +76,10 @@ declare function Storage({ key, json, stringify }?: {
|
|
|
76
76
|
key?: string;
|
|
77
77
|
}): (proto: any, property?: PropertyKey) => void;
|
|
78
78
|
|
|
79
|
-
declare function Rule(...rules: ((value: any) => void | string | Promise<void | string>)[]): (target: any, property: PropertyKey) => void;
|
|
80
|
-
declare function Required(target: any, property: PropertyKey): void;
|
|
81
|
-
declare function Optional(target: any, property: PropertyKey): void;
|
|
79
|
+
declare function Rule(...rules: ((value: any) => void | string | boolean | Promise<void | string | boolean>)[]): (target: any, property: PropertyKey, index?: any) => void;
|
|
80
|
+
declare function Required(target: any, property: PropertyKey, index?: any): void;
|
|
81
|
+
declare function Optional(target: any, property: PropertyKey, index?: any): void;
|
|
82
|
+
declare function Doc(doc: string): (target: any, property: PropertyKey, index?: any) => void;
|
|
82
83
|
|
|
83
84
|
declare function getTag<M extends Construct | AbConstruct>(moduleOrInstance: M | InstanceType<M>): PropertyKey;
|
|
84
85
|
/**
|
|
@@ -97,6 +98,7 @@ declare function objectToClass<Obj extends Record<string, any>>(obj: Obj): new (
|
|
|
97
98
|
declare function functionToClass<Func extends (...args: any) => object>(fn: Func): new (...args: Parameters<Func>) => ReturnType<Func>;
|
|
98
99
|
declare function omit<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Omit<InstanceType<Class>, Key>>;
|
|
99
100
|
declare function pick<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Pick<InstanceType<Class>, Key>>;
|
|
101
|
+
declare function partial<Class extends Construct>(classFn: Class): Construct<Partial<InstanceType<Class>>>;
|
|
100
102
|
declare function partial<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Partial<Pick<InstanceType<Class>, Key>> & Omit<InstanceType<Class>, Key>>;
|
|
101
103
|
declare function override<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Omit<InstanceType<Class>, Key>>;
|
|
102
104
|
|
|
@@ -122,4 +124,4 @@ declare abstract class Base {
|
|
|
122
124
|
private _unmount;
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
export { type AbConstruct, Assign, Base, CLEAR_KEY, type ClassValue, Clear, type Construct, DataMap, 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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -76,9 +76,10 @@ declare function Storage({ key, json, stringify }?: {
|
|
|
76
76
|
key?: string;
|
|
77
77
|
}): (proto: any, property?: PropertyKey) => void;
|
|
78
78
|
|
|
79
|
-
declare function Rule(...rules: ((value: any) => void | string | Promise<void | string>)[]): (target: any, property: PropertyKey) => void;
|
|
80
|
-
declare function Required(target: any, property: PropertyKey): void;
|
|
81
|
-
declare function Optional(target: any, property: PropertyKey): void;
|
|
79
|
+
declare function Rule(...rules: ((value: any) => void | string | boolean | Promise<void | string | boolean>)[]): (target: any, property: PropertyKey, index?: any) => void;
|
|
80
|
+
declare function Required(target: any, property: PropertyKey, index?: any): void;
|
|
81
|
+
declare function Optional(target: any, property: PropertyKey, index?: any): void;
|
|
82
|
+
declare function Doc(doc: string): (target: any, property: PropertyKey, index?: any) => void;
|
|
82
83
|
|
|
83
84
|
declare function getTag<M extends Construct | AbConstruct>(moduleOrInstance: M | InstanceType<M>): PropertyKey;
|
|
84
85
|
/**
|
|
@@ -97,6 +98,7 @@ declare function objectToClass<Obj extends Record<string, any>>(obj: Obj): new (
|
|
|
97
98
|
declare function functionToClass<Func extends (...args: any) => object>(fn: Func): new (...args: Parameters<Func>) => ReturnType<Func>;
|
|
98
99
|
declare function omit<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Omit<InstanceType<Class>, Key>>;
|
|
99
100
|
declare function pick<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Pick<InstanceType<Class>, Key>>;
|
|
101
|
+
declare function partial<Class extends Construct>(classFn: Class): Construct<Partial<InstanceType<Class>>>;
|
|
100
102
|
declare function partial<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Partial<Pick<InstanceType<Class>, Key>> & Omit<InstanceType<Class>, Key>>;
|
|
101
103
|
declare function override<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Omit<InstanceType<Class>, Key>>;
|
|
102
104
|
|
|
@@ -122,4 +124,4 @@ declare abstract class Base {
|
|
|
122
124
|
private _unmount;
|
|
123
125
|
}
|
|
124
126
|
|
|
125
|
-
export { type AbConstruct, Assign, Base, CLEAR_KEY, type ClassValue, Clear, type Construct, DataMap, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(index_exports, {
|
|
|
33
33
|
CLEAR_KEY: () => CLEAR_KEY,
|
|
34
34
|
Clear: () => Clear,
|
|
35
35
|
DataMap: () => DataMap,
|
|
36
|
+
Doc: () => Doc,
|
|
36
37
|
Effect: () => Effect,
|
|
37
38
|
Empty: () => Empty,
|
|
38
39
|
Err: () => Err,
|
|
@@ -387,7 +388,7 @@ function partial(classFn, ...properties) {
|
|
|
387
388
|
const newClass = class extends classFn {
|
|
388
389
|
};
|
|
389
390
|
getMetaKey(classFn).forEach((k) => {
|
|
390
|
-
if (properties.includes(k))
|
|
391
|
+
if (properties.length === 0 || properties.includes(k))
|
|
391
392
|
addDecoToClass(newClass, k, Optional);
|
|
392
393
|
});
|
|
393
394
|
return newClass;
|
|
@@ -530,17 +531,22 @@ function Storage({ key, json, stringify } = {}) {
|
|
|
530
531
|
};
|
|
531
532
|
}
|
|
532
533
|
|
|
533
|
-
// src/decorators/
|
|
534
|
+
// src/decorators/other.ts
|
|
534
535
|
function Rule(...rules) {
|
|
535
|
-
return (target, property) => {
|
|
536
|
-
setMeta(target, property,
|
|
536
|
+
return (target, property, index) => {
|
|
537
|
+
setMeta(target, property, index, { rules });
|
|
537
538
|
};
|
|
538
539
|
}
|
|
539
|
-
function Required(target, property) {
|
|
540
|
-
setMeta(target, property,
|
|
540
|
+
function Required(target, property, index) {
|
|
541
|
+
setMeta(target, property, index, { required: true });
|
|
542
|
+
}
|
|
543
|
+
function Optional(target, property, index) {
|
|
544
|
+
setMeta(target, property, index, { required: false });
|
|
541
545
|
}
|
|
542
|
-
function
|
|
543
|
-
|
|
546
|
+
function Doc(doc) {
|
|
547
|
+
return (target, property, index) => {
|
|
548
|
+
setMeta(target, property, index, { doc });
|
|
549
|
+
};
|
|
544
550
|
}
|
|
545
551
|
|
|
546
552
|
// src/base.ts
|
|
@@ -590,6 +596,7 @@ Base = __decorateClass([
|
|
|
590
596
|
CLEAR_KEY,
|
|
591
597
|
Clear,
|
|
592
598
|
DataMap,
|
|
599
|
+
Doc,
|
|
593
600
|
Effect,
|
|
594
601
|
Empty,
|
|
595
602
|
Err,
|
package/dist/index.mjs
CHANGED
|
@@ -309,7 +309,7 @@ function partial(classFn, ...properties) {
|
|
|
309
309
|
const newClass = class extends classFn {
|
|
310
310
|
};
|
|
311
311
|
getMetaKey(classFn).forEach((k) => {
|
|
312
|
-
if (properties.includes(k))
|
|
312
|
+
if (properties.length === 0 || properties.includes(k))
|
|
313
313
|
addDecoToClass(newClass, k, Optional);
|
|
314
314
|
});
|
|
315
315
|
return newClass;
|
|
@@ -452,17 +452,22 @@ function Storage({ key, json, stringify } = {}) {
|
|
|
452
452
|
};
|
|
453
453
|
}
|
|
454
454
|
|
|
455
|
-
// src/decorators/
|
|
455
|
+
// src/decorators/other.ts
|
|
456
456
|
function Rule(...rules) {
|
|
457
|
-
return (target, property) => {
|
|
458
|
-
setMeta(target, property,
|
|
457
|
+
return (target, property, index) => {
|
|
458
|
+
setMeta(target, property, index, { rules });
|
|
459
459
|
};
|
|
460
460
|
}
|
|
461
|
-
function Required(target, property) {
|
|
462
|
-
setMeta(target, property,
|
|
461
|
+
function Required(target, property, index) {
|
|
462
|
+
setMeta(target, property, index, { required: true });
|
|
463
|
+
}
|
|
464
|
+
function Optional(target, property, index) {
|
|
465
|
+
setMeta(target, property, index, { required: false });
|
|
463
466
|
}
|
|
464
|
-
function
|
|
465
|
-
|
|
467
|
+
function Doc(doc) {
|
|
468
|
+
return (target, property, index) => {
|
|
469
|
+
setMeta(target, property, index, { doc });
|
|
470
|
+
};
|
|
466
471
|
}
|
|
467
472
|
|
|
468
473
|
// src/base.ts
|
|
@@ -511,6 +516,7 @@ export {
|
|
|
511
516
|
CLEAR_KEY,
|
|
512
517
|
Clear,
|
|
513
518
|
DataMap,
|
|
519
|
+
Doc,
|
|
514
520
|
Effect,
|
|
515
521
|
Empty,
|
|
516
522
|
Err,
|