vona-core 5.0.36 → 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.
@@ -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
- protected get $beanFullName(): string;
10
+ get $beanFullName(): string;
11
11
  protected get $beanOptions(): IDecoratorBeanOptionsBase;
12
- protected get $onionName(): string;
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("./beanContainer.ts").BeanContainer;
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-database.service.modelResolver', moduleBelong);
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-database.service.entityResolver', moduleBelong);
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, virtual, options, optionsPrimitive } = beanOptions;
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, virtual?: boolean, fn?: (target: Constructable) => void): ClassDecorator;
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, virtual, fn) {
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);
@@ -2,3 +2,4 @@ export * from './beanInfo.ts';
2
2
  export * from './createBeanDecorator.ts';
3
3
  export * from './proxyDisable.ts';
4
4
  export * from './use.ts';
5
+ export * from './virtual.ts';
@@ -2,3 +2,4 @@ export * from "./beanInfo.js";
2
2
  export * from "./createBeanDecorator.js";
3
3
  export * from "./proxyDisable.js";
4
4
  export * from "./use.js";
5
+ export * from "./virtual.js";
@@ -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
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './mappedClass.ts';
2
+ export * from './pickClassInner.ts';
2
3
  export * from './type.ts';
3
4
  export * from './utils.ts';
@@ -1,3 +1,4 @@
1
1
  export * from "./mappedClass.js";
2
+ export * from "./pickClassInner.js";
2
3
  export * from "./type.js";
3
4
  export * from "./utils.js";
@@ -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 ClassMapped: {
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 ClassMapped = {
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 { copyMetadataOfClasses, copyPropertiesOfClasses } from "./utils.js";
1
+ import { PickClassInner } from 'vona';
2
2
  export function PickClass(classRef, keys) {
3
3
  class TargetClass {
4
4
  }
5
- copyMetadataOfClasses(TargetClass.prototype, [classRef.prototype], (rules, key) => {
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
+ }
@@ -3,6 +3,7 @@ import type { Constructable } from '../decorator/index.ts';
3
3
  import type { IMappedClassMetadataOptions, MappedClassMetadataKeys } from './type.ts';
4
4
  export declare function registerMappedClassMetadataKey(target: object, metadataKey: MetadataKey, options?: IMappedClassMetadataOptions): void;
5
5
  export declare function getMappedClassMetadataKeys(target: object): MappedClassMetadataKeys | undefined;
6
+ export declare function setMappedClassMetadataKeys(target: object, metadataKeys?: MappedClassMetadataKeys): void;
6
7
  export declare function copyPropertiesOfClasses(target: Constructable, sources: Constructable[], filter?: Function): void;
7
8
  export declare function copyProperties(target: object, source: object, keysIgnore: MetadataKey[], filter?: Function): void;
8
9
  export declare function copyMetadataOfClasses(target: object, sources: object[], transform?: Function): void;
@@ -9,6 +9,9 @@ export function registerMappedClassMetadataKey(target, metadataKey, options) {
9
9
  export function getMappedClassMetadataKeys(target) {
10
10
  return appMetadata.getMetadata(SymbolMappedClassMetadataKeys, target);
11
11
  }
12
+ export function setMappedClassMetadataKeys(target, metadataKeys) {
13
+ return appMetadata.defineMetadata(SymbolMappedClassMetadataKeys, metadataKeys, target);
14
+ }
12
15
  export function copyPropertiesOfClasses(target, sources, filter) {
13
16
  for (const source of sources) {
14
17
  copyProperties(target, source, ['constructor', 'prototype', 'length', 'name'], filter); // copy static
@@ -51,6 +54,7 @@ export function copyMetadataOfClasses(target, sources, transform) {
51
54
  Object.assign(metadataKeys, _metadataKeys);
52
55
  }
53
56
  }
57
+ setMappedClassMetadataKeys(target, metadataKeys);
54
58
  //
55
59
  for (const metadataKey of Object.getOwnPropertySymbols(metadataKeys)) {
56
60
  const metadataKeyOptions = metadataKeys[metadataKey];
@@ -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;
@@ -0,0 +1,3 @@
1
+ export function $customKey(key) {
2
+ return key;
3
+ }
@@ -1,4 +1,4 @@
1
1
  import './zod-openapi.ts';
2
- export * from './isClass.ts';
2
+ export * from './customKey.ts';
3
3
  export * from './retry.ts';
4
4
  export * from './util.ts';
@@ -1,4 +1,4 @@
1
1
  import "./zod-openapi.js";
2
- export * from "./isClass.js";
2
+ export * from "./customKey.js";
3
3
  export * from "./retry.js";
4
4
  export * from "./util.js";
@@ -1,7 +1,2 @@
1
- export interface JwtPayload {
2
- exp: number;
3
- token: string;
4
- }
5
1
  export interface ContextState {
6
- jwt?: JwtPayload;
7
2
  }
@@ -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.36",
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.24",
34
- "@cabloy/module-info-pro": "^1.0.32",
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",
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,2 +0,0 @@
1
- export declare function isClass(fn: any): boolean;
2
- export declare function isClassStrict(fn: any): boolean;
@@ -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
- // }