vona-core 5.0.99 → 5.0.101

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.
@@ -20,10 +20,12 @@ export declare class VonaApplication extends KoaApplication {
20
20
  server: Server;
21
21
  ctxStorage: VonaAsyncLocalStorage;
22
22
  constructor(options: VonaApplicationOptions);
23
+ get name(): string;
24
+ get projectPath(): string;
25
+ get configMeta(): import("@cabloy/module-info").VonaConfigMeta;
23
26
  get ctx(): VonaContext;
24
27
  /** get specific module's scope */
25
28
  scope<K extends TypeBeanScopeRecordKeys>(moduleScope: K): IBeanScopeRecord[K];
26
- get name(): string;
27
29
  createAnonymousContext(req?: any, res?: any): VonaContext;
28
30
  close(terminate?: boolean): Promise<void>;
29
31
  }
@@ -43,6 +43,15 @@ export class VonaApplication extends KoaApplication {
43
43
  // zod
44
44
  zodEnhance(this);
45
45
  }
46
+ get name() {
47
+ return this.options.name;
48
+ }
49
+ get projectPath() {
50
+ return this.options.projectPath;
51
+ }
52
+ get configMeta() {
53
+ return this.options.configMeta;
54
+ }
46
55
  get ctx() {
47
56
  return this.currentContext;
48
57
  }
@@ -50,9 +59,6 @@ export class VonaApplication extends KoaApplication {
50
59
  scope(moduleScope) {
51
60
  return this.bean.scope(moduleScope);
52
61
  }
53
- get name() {
54
- return this.options.name;
55
- }
56
62
  createAnonymousContext(req, res) {
57
63
  let request;
58
64
  if (req) {
@@ -52,6 +52,7 @@ function __createApp({ modulesMeta, locales, config, env, AppMonkey }) {
52
52
  const options = {
53
53
  name: appInfo.name,
54
54
  projectPath: appInfo.projectPath,
55
+ configMeta: appInfo.configMeta,
55
56
  modulesMeta,
56
57
  locales,
57
58
  config: appConfig,
@@ -3,12 +3,13 @@ export function PartialClass(classRef, keys) {
3
3
  class TargetClass {
4
4
  }
5
5
  copyMetadataOfClasses(TargetClass.prototype, [classRef.prototype], (rules, key, metadataKeyOptions) => {
6
+ const schema = rules[key];
6
7
  if (keys && !keys.includes(key))
7
- return rules[key];
8
+ return schema;
8
9
  if (metadataKeyOptions?.partialClass) {
9
- return metadataKeyOptions?.partialClass(rules[key]);
10
+ return metadataKeyOptions?.partialClass(schema);
10
11
  }
11
- return rules[key];
12
+ return schema;
12
13
  });
13
14
  copyPropertiesOfClasses(TargetClass, [classRef]);
14
15
  return TargetClass;
@@ -1,3 +1,4 @@
1
1
  export * from './customKey.ts';
2
+ export * from './redis.ts';
2
3
  export * from './retry.ts';
3
4
  export * from './util.ts';
@@ -1,5 +1,6 @@
1
1
  import { zodExtendOpenApi } from "./zod-openapi.js";
2
2
  export * from "./customKey.js";
3
+ export * from "./redis.js";
3
4
  export * from "./retry.js";
4
5
  export * from "./util.js";
5
6
  zodExtendOpenApi();
@@ -0,0 +1,3 @@
1
+ import type { VonaAppInfo } from '../../types/application/app.ts';
2
+ import type { VonaApplication } from '../core/application.ts';
3
+ export declare function getRedisClientKeyPrefix(clientName: string, appInfo: VonaAppInfo | VonaApplication): string;
@@ -0,0 +1,4 @@
1
+ export function getRedisClientKeyPrefix(clientName, appInfo) {
2
+ const mode = ['test', 'dev'].includes(appInfo.configMeta.mode) ? '_local' : '';
3
+ return `${clientName}_${appInfo.name}${mode}:`;
4
+ }
@@ -62,4 +62,6 @@ export declare function beanFullNameFromOnionName(onionName: string, sceneName:
62
62
  export declare function onionNameFromBeanFullName(beanFullName: string, sceneName: keyof IBeanSceneRecord): string;
63
63
  export declare function filterHeaders(headers: object | undefined, whitelist: string[]): {} | undefined;
64
64
  export declare function combineFilePathSafe(dir: string, file: string): string;
65
+ export declare function loadJSONFile(fileName: string): Promise<any>;
66
+ export declare function saveJSONFile(fileName: string, json: object): Promise<void>;
65
67
  export {};
@@ -307,3 +307,10 @@ export function combineFilePathSafe(dir, file) {
307
307
  throw new Error(`unsafe dir: ${dir}`);
308
308
  return fullPath;
309
309
  }
310
+ export async function loadJSONFile(fileName) {
311
+ const pkgContent = (await fse.readFile(fileName)).toString();
312
+ return JSON.parse(pkgContent);
313
+ }
314
+ export async function saveJSONFile(fileName, json) {
315
+ await fse.writeFile(fileName, `${JSON.stringify(json, null, 2)}\n`);
316
+ }
@@ -27,6 +27,7 @@ export interface VonaAppInfo {
27
27
  export interface VonaApplicationOptions {
28
28
  name: string;
29
29
  projectPath: string;
30
+ configMeta: VonaConfigMeta;
30
31
  modulesMeta: TypeOptionsModulesMeta;
31
32
  locales: VonaLocaleOptionalMap;
32
33
  config: VonaConfig;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-core",
3
3
  "type": "module",
4
- "version": "5.0.99",
4
+ "version": "5.0.101",
5
5
  "description": "vona",
6
6
  "publishConfig": {
7
7
  "access": "public"