vona-core 5.0.37 → 5.0.38
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/lib/bean/beanBaseSimple.d.ts +2 -2
- package/dist/lib/bean/beanContainer.js +1 -2
- package/dist/lib/bean/beanSimple.d.ts +1 -1
- package/dist/lib/bean/scope/beanScopeBase.js +2 -2
- package/dist/lib/core/resource.d.ts +1 -0
- package/dist/lib/core/resource.js +5 -2
- package/dist/lib/decorator/class/createBeanDecorator.d.ts +1 -1
- package/dist/lib/decorator/class/createBeanDecorator.js +1 -2
- package/dist/lib/decorator/class/index.d.ts +1 -0
- package/dist/lib/decorator/class/index.js +1 -0
- package/dist/lib/decorator/class/virtual.d.ts +1 -0
- package/dist/lib/decorator/class/virtual.js +8 -0
- package/dist/lib/mappedClass/index.d.ts +1 -0
- package/dist/lib/mappedClass/index.js +1 -0
- package/dist/lib/mappedClass/mappedClass.d.ts +1 -1
- package/dist/lib/mappedClass/mappedClass.js +1 -1
- package/dist/lib/mappedClass/pickClass.d.ts +1 -0
- package/dist/lib/mappedClass/pickClass.js +2 -10
- package/dist/lib/mappedClass/pickClassInner.d.ts +3 -0
- package/dist/lib/mappedClass/pickClassInner.js +12 -0
- package/dist/lib/utils/customKey.d.ts +9 -0
- package/dist/lib/utils/customKey.js +3 -0
- package/dist/lib/utils/index.d.ts +1 -1
- package/dist/lib/utils/index.js +1 -1
- package/dist/types/context/contextState.d.ts +0 -5
- package/dist/types/utils/type.d.ts +4 -0
- package/package.json +4 -4
- package/dist/lib/utils/isClass.d.ts +0 -2
- package/dist/lib/utils/isClass.js +0 -18
|
@@ -7,8 +7,8 @@ export declare class BeanBaseSimple extends BeanSimple {
|
|
|
7
7
|
private [SymbolBeanFullName];
|
|
8
8
|
protected get [SymbolModuleBelong](): string;
|
|
9
9
|
protected get [SymbolModuleName](): string | undefined;
|
|
10
|
-
|
|
10
|
+
get $beanFullName(): string;
|
|
11
11
|
protected get $beanOptions(): IDecoratorBeanOptionsBase;
|
|
12
|
-
|
|
12
|
+
get $onionName(): string;
|
|
13
13
|
protected get $onionOptions(): unknown | undefined;
|
|
14
14
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { isNilOrEmptyString } from '@cabloy/utils';
|
|
1
|
+
import { isClass, isNilOrEmptyString } from '@cabloy/utils';
|
|
2
2
|
import { cast } from "../../types/index.js";
|
|
3
3
|
import { appMetadata } from "../core/metadata.js";
|
|
4
4
|
import { appResource, SymbolDecoratorProxyDisable } from "../core/resource.js";
|
|
5
5
|
import { __prepareInjectSelectorInfo } from "../decorator/index.js";
|
|
6
|
-
import { isClass } from "../utils/isClass.js";
|
|
7
6
|
import { compose } from "../utils/util.js";
|
|
8
7
|
import { BeanAopBase } from "./beanAopBase.js";
|
|
9
8
|
import { BeanBase } from "./beanBase.js";
|
|
@@ -3,5 +3,5 @@ import type { VonaApplication } from '../core/application.ts';
|
|
|
3
3
|
export declare class BeanSimple {
|
|
4
4
|
protected app: VonaApplication;
|
|
5
5
|
protected get ctx(): VonaContext;
|
|
6
|
-
protected get bean(): import("
|
|
6
|
+
protected get bean(): import("vona").BeanContainer;
|
|
7
7
|
}
|
|
@@ -70,14 +70,14 @@ export class BeanScopeBase extends BeanBaseSimple {
|
|
|
70
70
|
// model
|
|
71
71
|
if (prop === 'model') {
|
|
72
72
|
if (!this[BeanModuleModel]) {
|
|
73
|
-
this[BeanModuleModel] = this.bean._newBean('a-
|
|
73
|
+
this[BeanModuleModel] = this.bean._newBean('a-orm.service.modelResolver', moduleBelong);
|
|
74
74
|
}
|
|
75
75
|
return this[BeanModuleModel];
|
|
76
76
|
}
|
|
77
77
|
// entity
|
|
78
78
|
if (prop === 'entity') {
|
|
79
79
|
if (!this[BeanModuleEntity]) {
|
|
80
|
-
this[BeanModuleEntity] = this.bean._newBean('a-
|
|
80
|
+
this[BeanModuleEntity] = this.bean._newBean('a-orm.service.entityResolver', moduleBelong);
|
|
81
81
|
}
|
|
82
82
|
return this[BeanModuleEntity];
|
|
83
83
|
}
|
|
@@ -5,6 +5,7 @@ import { BeanSimple } from '../bean/beanSimple.ts';
|
|
|
5
5
|
export declare const SymbolDecoratorBeanFullName: unique symbol;
|
|
6
6
|
export declare const SymbolDecoratorBeanInfo: unique symbol;
|
|
7
7
|
export declare const SymbolDecoratorProxyDisable: unique symbol;
|
|
8
|
+
export declare const SymbolDecoratorVirtual: unique symbol;
|
|
8
9
|
export declare const SymbolDecoratorUse: unique symbol;
|
|
9
10
|
export type IAppResourceRecord = Record<string, IDecoratorBeanOptionsBase>;
|
|
10
11
|
export declare class AppResource extends BeanSimple {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { isClass } from '@cabloy/utils';
|
|
1
2
|
import { toLowerCaseFirstChar } from '@cabloy/word-utils';
|
|
2
3
|
import { cast } from "../../types/utils/cast.js";
|
|
3
4
|
import { BeanSimple } from "../bean/beanSimple.js";
|
|
4
5
|
import { useApp } from "../framework/useApp.js";
|
|
5
6
|
import { registerMappedClassMetadataKey } from "../mappedClass/utils.js";
|
|
6
|
-
import { isClass } from "../utils/isClass.js";
|
|
7
7
|
import { deepExtend } from "../utils/util.js";
|
|
8
8
|
import { appMetadata } from "./metadata.js";
|
|
9
9
|
export const SymbolDecoratorBeanFullName = Symbol('SymbolDecoratorBeanFullName');
|
|
10
10
|
export const SymbolDecoratorBeanInfo = Symbol('SymbolDecoratorBeanInfo');
|
|
11
11
|
export const SymbolDecoratorProxyDisable = Symbol('SymbolDecoratorProxyDisable');
|
|
12
|
+
export const SymbolDecoratorVirtual = Symbol('SymbolDecoratorVirtual');
|
|
12
13
|
export const SymbolDecoratorUse = Symbol('SymbolDecoratorUse');
|
|
13
14
|
export class AppResource extends BeanSimple {
|
|
14
15
|
beans = {};
|
|
@@ -22,7 +23,9 @@ export class AppResource extends BeanSimple {
|
|
|
22
23
|
return appMetadata.getMetadata(SymbolDecoratorUse, target);
|
|
23
24
|
}
|
|
24
25
|
addBean(beanOptions) {
|
|
25
|
-
let { module, scene, name, beanClass,
|
|
26
|
+
let { module, scene, name, beanClass, options, optionsPrimitive } = beanOptions;
|
|
27
|
+
// virtual
|
|
28
|
+
const virtual = appMetadata.getOwnMetadata(SymbolDecoratorVirtual, beanClass);
|
|
26
29
|
// name
|
|
27
30
|
name = this._parseBeanName(beanClass, scene, name);
|
|
28
31
|
// module
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IBeanSceneRecord } from '../interface/beanOptions.ts';
|
|
2
2
|
import type { Constructable } from '../type/constructable.ts';
|
|
3
|
-
export declare function createBeanDecorator<T>(scene: keyof IBeanSceneRecord, options?: T, optionsPrimitive?: boolean,
|
|
3
|
+
export declare function createBeanDecorator<T>(scene: keyof IBeanSceneRecord, options?: T, optionsPrimitive?: boolean, fn?: (target: Constructable) => void): ClassDecorator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { appResource } from "../../core/resource.js";
|
|
2
2
|
import { parseModuleName } from "./util.js";
|
|
3
|
-
export function createBeanDecorator(scene, options, optionsPrimitive,
|
|
3
|
+
export function createBeanDecorator(scene, options, optionsPrimitive, fn) {
|
|
4
4
|
return function (target) {
|
|
5
5
|
const beanClass = target;
|
|
6
6
|
// module
|
|
@@ -15,7 +15,6 @@ export function createBeanDecorator(scene, options, optionsPrimitive, virtual, f
|
|
|
15
15
|
beanClass,
|
|
16
16
|
options,
|
|
17
17
|
optionsPrimitive,
|
|
18
|
-
virtual,
|
|
19
18
|
});
|
|
20
19
|
// fn
|
|
21
20
|
fn?.(beanClass);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Virtual(): ClassDecorator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { appMetadata } from "../../core/metadata.js";
|
|
2
|
+
import { SymbolDecoratorVirtual } from "../../core/resource.js";
|
|
3
|
+
export function Virtual() {
|
|
4
|
+
return function (target) {
|
|
5
|
+
// set metadata
|
|
6
|
+
appMetadata.defineMetadata(SymbolDecoratorVirtual, true, target);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
@@ -2,7 +2,7 @@ import { MixinClass } from './mixinClass.ts';
|
|
|
2
2
|
import { OmitClass } from './omitClass.ts';
|
|
3
3
|
import { PartialClass } from './partialClass.ts';
|
|
4
4
|
import { PickClass } from './pickClass.ts';
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const $Class: {
|
|
6
6
|
mixin: typeof MixinClass;
|
|
7
7
|
omit: typeof OmitClass;
|
|
8
8
|
partial: typeof PartialClass;
|
|
@@ -2,7 +2,7 @@ import { MixinClass } from "./mixinClass.js";
|
|
|
2
2
|
import { OmitClass } from "./omitClass.js";
|
|
3
3
|
import { PartialClass } from "./partialClass.js";
|
|
4
4
|
import { PickClass } from "./pickClass.js";
|
|
5
|
-
export const
|
|
5
|
+
export const $Class = {
|
|
6
6
|
mixin: MixinClass,
|
|
7
7
|
omit: OmitClass,
|
|
8
8
|
partial: PartialClass,
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { Constructable } from '../decorator/type/constructable.ts';
|
|
2
|
+
export declare function PickClass<T>(classRef: Constructable<T>, keys?: undefined): Constructable<T>;
|
|
2
3
|
export declare function PickClass<T, K extends keyof T>(classRef: Constructable<T>, keys: K[]): Constructable<Pick<T, (typeof keys)[number]>>;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PickClassInner } from 'vona';
|
|
2
2
|
export function PickClass(classRef, keys) {
|
|
3
3
|
class TargetClass {
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
if (keys.includes(key)) {
|
|
7
|
-
return rules[key];
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
copyPropertiesOfClasses(TargetClass, [classRef], key => {
|
|
11
|
-
return keys.includes(key);
|
|
12
|
-
});
|
|
13
|
-
return TargetClass;
|
|
5
|
+
return PickClassInner(TargetClass, classRef, keys);
|
|
14
6
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Constructable } from '../decorator/type/constructable.ts';
|
|
2
|
+
export declare function PickClassInner<T>(classTarget: Constructable, classRef: Constructable<T>, keys?: undefined): Constructable<T>;
|
|
3
|
+
export declare function PickClassInner<T, K extends keyof T>(classTarget: Constructable, classRef: Constructable<T>, keys: K[]): Constructable<Pick<T, (typeof keys)[number]>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { copyMetadataOfClasses, copyPropertiesOfClasses } from "./utils.js";
|
|
2
|
+
export function PickClassInner(classTarget, classRef, keys) {
|
|
3
|
+
copyMetadataOfClasses(classTarget.prototype, [classRef.prototype], (rules, key) => {
|
|
4
|
+
if (!keys || keys.includes(key)) {
|
|
5
|
+
return rules[key];
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
copyPropertiesOfClasses(classTarget, [classRef], key => {
|
|
9
|
+
return !keys || keys.includes(key);
|
|
10
|
+
});
|
|
11
|
+
return classTarget;
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ILocaleInfos } from '../bean/resource/locale/type.ts';
|
|
2
|
+
export interface ICustomKeyRecord {
|
|
3
|
+
'x-vona-locale': keyof ILocaleInfos | undefined;
|
|
4
|
+
'x-vona-instance-name': string | undefined;
|
|
5
|
+
'x-vona-passport-code': string | undefined;
|
|
6
|
+
'x-vona-oauth-code': string | undefined;
|
|
7
|
+
'x-vona-openapi-schema': 'true' | 'false' | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare function $customKey<K extends keyof ICustomKeyRecord>(key: K): K;
|
package/dist/lib/utils/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type { Constructable } from '../../lib/decorator/type/constructable.ts';
|
|
1
2
|
export interface Type<T = any> extends Function {
|
|
2
3
|
new (...args: any[]): T;
|
|
3
4
|
}
|
|
5
|
+
export type TypeClassOfClassLike<ClassLike> = ClassLike extends ((() => Constructable<infer Result>) | Constructable<infer Result>) ? Result : ClassLike extends ((() => infer Result) | infer Result) ? Result : ClassLike extends () => Constructable<infer Result> ? Result : ClassLike extends () => infer Result ? Result : ClassLike extends Constructable<infer Result> ? Result : ClassLike extends infer Result ? Result : undefined;
|
|
6
|
+
export type TypeRecordValues<TRecord> = TRecord[keyof TRecord];
|
|
7
|
+
export type TypeConfirmArray<A> = A extends any[] ? A : A[];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.38",
|
|
5
5
|
"description": "vona",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"@cabloy/extend": "^3.1.10",
|
|
31
31
|
"@cabloy/json5": "^1.0.18",
|
|
32
32
|
"@cabloy/localeutil": "^2.0.10",
|
|
33
|
-
"@cabloy/module-info": "^1.3.
|
|
34
|
-
"@cabloy/module-info-pro": "^1.0.
|
|
33
|
+
"@cabloy/module-info": "^1.3.25",
|
|
34
|
+
"@cabloy/module-info-pro": "^1.0.33",
|
|
35
35
|
"@cabloy/set": "^1.0.17",
|
|
36
|
-
"@cabloy/utils": "^1.0.
|
|
36
|
+
"@cabloy/utils": "^1.0.38",
|
|
37
37
|
"@cabloy/word-utils": "^2.0.1",
|
|
38
38
|
"fs-extra": "^10.1.0",
|
|
39
39
|
"koa": "^3.0.0",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export function isClass(fn) {
|
|
2
|
-
// just check if is function
|
|
3
|
-
return typeof fn === 'function';
|
|
4
|
-
}
|
|
5
|
-
export function isClassStrict(fn) {
|
|
6
|
-
return typeof fn === 'function' && /^class(?:\s|\{)/.test(fn.toString());
|
|
7
|
-
}
|
|
8
|
-
// function fnBody(fn) {
|
|
9
|
-
// return fn
|
|
10
|
-
// .toString()
|
|
11
|
-
// .replace(/^[^{]*{\s*/, '')
|
|
12
|
-
// .replace(/\s*}[^}]*$/, '');
|
|
13
|
-
// }
|
|
14
|
-
// export function isClassStrict(fn) {
|
|
15
|
-
// return (
|
|
16
|
-
// typeof fn === 'function' && (/^class(?:\s|{)/.test(fn.toString()) || /^.*classCallCheck\(/.test(fnBody(fn))) // babel.js
|
|
17
|
-
// );
|
|
18
|
-
// }
|