vona-core 5.0.131 → 5.0.133
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.js
CHANGED
|
@@ -46,10 +46,6 @@ class BeanSimple {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const localeDefault = {
|
|
50
|
-
modules: {}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
49
|
const EnumAppEvent = {
|
|
54
50
|
AppStarted: 'eb:event:appStarted',
|
|
55
51
|
AppStartError: 'eb:event:appStartError'
|
|
@@ -2182,7 +2178,7 @@ class AppLogger extends BeanSimple {
|
|
|
2182
2178
|
name: childName
|
|
2183
2179
|
});
|
|
2184
2180
|
}
|
|
2185
|
-
|
|
2181
|
+
getFilterLevel(clientName) {
|
|
2186
2182
|
clientName = clientName || 'default';
|
|
2187
2183
|
const envName = `LOGGER_CLIENT_${clientName.toUpperCase()}`;
|
|
2188
2184
|
const level = this.app.meta.env[envName];
|
|
@@ -2190,11 +2186,28 @@ class AppLogger extends BeanSimple {
|
|
|
2190
2186
|
if (level === 'true' || !level) return 'info';
|
|
2191
2187
|
return level;
|
|
2192
2188
|
}
|
|
2193
|
-
|
|
2189
|
+
setFilterLevel(level, clientName) {
|
|
2194
2190
|
clientName = clientName || 'default';
|
|
2195
2191
|
const envName = `LOGGER_CLIENT_${clientName.toUpperCase()}`;
|
|
2196
2192
|
this.app.meta.env[envName] = level.toString();
|
|
2197
2193
|
}
|
|
2194
|
+
getFilterChild(clientName) {
|
|
2195
|
+
clientName = clientName || 'default';
|
|
2196
|
+
const envName = `LOGGER_CHILD_${clientName.toUpperCase()}`;
|
|
2197
|
+
let child = this.app.meta.env[envName];
|
|
2198
|
+
if (!child) {
|
|
2199
|
+
const envName = 'LOGGER_CHILD';
|
|
2200
|
+
child = this.app.meta.env[envName];
|
|
2201
|
+
}
|
|
2202
|
+
if (!child) return;
|
|
2203
|
+
return child.split(',');
|
|
2204
|
+
}
|
|
2205
|
+
setFilterChild(child, clientName) {
|
|
2206
|
+
if (Array.isArray(child)) child = child.join(',');
|
|
2207
|
+
clientName = clientName || 'default';
|
|
2208
|
+
const envName = `LOGGER_CHILD_${clientName.toUpperCase()}`;
|
|
2209
|
+
this.app.meta.env[envName] = child;
|
|
2210
|
+
}
|
|
2198
2211
|
_createClient(clientName) {
|
|
2199
2212
|
const configClient = this.app.config.logger.clients[clientName];
|
|
2200
2213
|
if (!configClient) throw new Error(`logger client not found: ${clientName}`);
|
|
@@ -2209,7 +2222,8 @@ class AppLogger extends BeanSimple {
|
|
|
2209
2222
|
if (typeof configClient !== 'function') return configClient;
|
|
2210
2223
|
return configClient.call(this.app, {
|
|
2211
2224
|
clientName,
|
|
2212
|
-
level: () => this.
|
|
2225
|
+
level: () => this.getFilterLevel(clientName),
|
|
2226
|
+
child: () => this.getFilterChild(clientName)
|
|
2213
2227
|
}, Winston);
|
|
2214
2228
|
}
|
|
2215
2229
|
createTransportFile(fileName, clientInfo, options) {
|
|
@@ -2653,6 +2667,13 @@ const formatLoggerDummy = Winston.format(info => {
|
|
|
2653
2667
|
return info;
|
|
2654
2668
|
});
|
|
2655
2669
|
const formatLoggerFilter = Winston.format((info, opts) => {
|
|
2670
|
+
// check client
|
|
2671
|
+
const child = typeof opts.child === 'function' ? opts.child() : opts.child;
|
|
2672
|
+
if (child && !child.includes(info.name)) {
|
|
2673
|
+
if (opts.silly && info.level === 'silly') return __formatLoggerFilterCheckInfo(info);
|
|
2674
|
+
return false;
|
|
2675
|
+
}
|
|
2676
|
+
// check level
|
|
2656
2677
|
const level = typeof opts.level === 'function' ? opts.level() : opts.level;
|
|
2657
2678
|
if (!level) return false;
|
|
2658
2679
|
if (opts.strict) {
|
|
@@ -2795,10 +2816,14 @@ async function loadLocales (app, modules) {
|
|
|
2795
2816
|
// load locales
|
|
2796
2817
|
await loadLocales();
|
|
2797
2818
|
async function loadLocales() {
|
|
2798
|
-
const
|
|
2799
|
-
// project locales
|
|
2800
|
-
for (const locale in
|
|
2801
|
-
_initLocales(locale,
|
|
2819
|
+
const localesAll = await app.options.locales();
|
|
2820
|
+
// project locales default
|
|
2821
|
+
for (const locale in localesAll.localesDefault) {
|
|
2822
|
+
_initLocales(locale, localesAll.localesDefault[locale]);
|
|
2823
|
+
}
|
|
2824
|
+
// project locales modules
|
|
2825
|
+
for (const locale in localesAll.localesModules) {
|
|
2826
|
+
_initLocales(locale, localesAll.localesModules[locale]);
|
|
2802
2827
|
}
|
|
2803
2828
|
// app cache
|
|
2804
2829
|
app.meta.hmrCacheLocaleModules = deepExtend({}, app.meta.localeModules);
|
|
@@ -3312,4 +3337,4 @@ function prepareNativeBinding(nativeBinding) {
|
|
|
3312
3337
|
|
|
3313
3338
|
zodExtendOpenApi();
|
|
3314
3339
|
|
|
3315
|
-
export { $Class, $customKey, $localeScope, $makeLocaleMagic, AppHmr, AppHmrDeps, AppLocale, AppLogger, AppMeta, AppMetadata, AppResource, AppUtil, BeanAopBase, BeanAopMethodBase, BeanBase, BeanBaseSimple, BeanContainer, BeanInfo, BeanScopeBase, BeanScopeContainer, BeanScopeError, BeanScopeErrorImpl, BeanScopeLocale, BeanScopeScene, BeanScopeUtil, BeanSimple, EnumAppEvent, ErrorClass, Global, LocaleModuleNameSeparator, PickClassInner, ProxyDisable, SymbolBeanContainerInstances, SymbolBeanFullName, SymbolBeanInstanceKey, SymbolBeanInstancePropsLazy, SymbolCacheAopChains, SymbolCacheAopChainsKey, SymbolDecoratorBeanFullName, SymbolDecoratorBeanInfo, SymbolDecoratorGlobal, SymbolDecoratorProxyDisable, SymbolDecoratorUse, SymbolDecoratorVirtual, SymbolHmrStateLoad, SymbolHmrStateSave, SymbolMappedClassMetadataKeys, SymbolModuleBelong, SymbolModuleName, Use, Virtual, VonaApplication, __prepareInjectSelectorInfo, appHmrDeps, appMetadata, appResource, beanFullNameFromOnionName, bootstrap, cast, closeApp, combineConfigDefault, combineFilePathSafe, compose, copyMetadataOfClasses, copyProperties, copyPropertiesOfClasses, copySqlite3NativeBinding, createApp, createAppMaster, createBeanDecorator, createGeneralApp, createHash, deepExtend, disposeInstance, errorsInternal, filterHeaders, formatLoggerAxiosError, formatLoggerConsole, formatLoggerCtx, formatLoggerDummy, formatLoggerFilter, functionNoop, getLoggerPathPhysicalRoot, getMappedClassMetadataKeys, getPublicPathPhysicalRoot, getRuntimePathPhysicalRoot, getSqlite3DatabaseNameDefault, getSqlite3NativeBinding, instanceDesp, isLocaleMagic, loadJSONFile,
|
|
3340
|
+
export { $Class, $customKey, $localeScope, $makeLocaleMagic, AppHmr, AppHmrDeps, AppLocale, AppLogger, AppMeta, AppMetadata, AppResource, AppUtil, BeanAopBase, BeanAopMethodBase, BeanBase, BeanBaseSimple, BeanContainer, BeanInfo, BeanScopeBase, BeanScopeContainer, BeanScopeError, BeanScopeErrorImpl, BeanScopeLocale, BeanScopeScene, BeanScopeUtil, BeanSimple, EnumAppEvent, ErrorClass, Global, LocaleModuleNameSeparator, PickClassInner, ProxyDisable, SymbolBeanContainerInstances, SymbolBeanFullName, SymbolBeanInstanceKey, SymbolBeanInstancePropsLazy, SymbolCacheAopChains, SymbolCacheAopChainsKey, SymbolDecoratorBeanFullName, SymbolDecoratorBeanInfo, SymbolDecoratorGlobal, SymbolDecoratorProxyDisable, SymbolDecoratorUse, SymbolDecoratorVirtual, SymbolHmrStateLoad, SymbolHmrStateSave, SymbolMappedClassMetadataKeys, SymbolModuleBelong, SymbolModuleName, Use, Virtual, VonaApplication, __prepareInjectSelectorInfo, appHmrDeps, appMetadata, appResource, beanFullNameFromOnionName, bootstrap, cast, closeApp, combineConfigDefault, combineFilePathSafe, compose, copyMetadataOfClasses, copyProperties, copyPropertiesOfClasses, copySqlite3NativeBinding, createApp, createAppMaster, createBeanDecorator, createGeneralApp, createHash, deepExtend, disposeInstance, errorsInternal, filterHeaders, formatLoggerAxiosError, formatLoggerConsole, formatLoggerCtx, formatLoggerDummy, formatLoggerFilter, functionNoop, getLoggerPathPhysicalRoot, getMappedClassMetadataKeys, getPublicPathPhysicalRoot, getRuntimePathPhysicalRoot, getSqlite3DatabaseNameDefault, getSqlite3NativeBinding, instanceDesp, isLocaleMagic, loadJSONFile, onionNameFromBeanFullName, pathToHref, polyfillDispose, prepareEnv, registerMappedClassMetadataKey, requireDynamic, retry, saveJSONFile, setMappedClassMetadataKeys, text, useApp, usePrepareArg, usePrepareArgs, uuidv4 };
|
|
@@ -8,8 +8,10 @@ export declare class AppLogger extends BeanSimple {
|
|
|
8
8
|
dispose(): Promise<void>;
|
|
9
9
|
get(clientName?: keyof ILoggerClientRecord): Winston.Logger;
|
|
10
10
|
child(childName?: keyof ILoggerChildRecord, clientName?: keyof ILoggerClientRecord): Winston.Logger;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
getFilterLevel(clientName?: keyof ILoggerClientRecord): LoggerLevel | false;
|
|
12
|
+
setFilterLevel(level: LoggerLevel | boolean, clientName?: keyof ILoggerClientRecord): void;
|
|
13
|
+
getFilterChild(clientName?: keyof ILoggerClientRecord): string[] | undefined;
|
|
14
|
+
setFilterChild(child: string | string[], clientName?: keyof ILoggerClientRecord): void;
|
|
13
15
|
private _createClient;
|
|
14
16
|
private _prepareConfigClient;
|
|
15
17
|
createTransportFile(fileName: string, clientInfo: ILoggerOptionsClientInfo, options: Winston.transports.FileTransportOptions | DailyRotateFile.DailyRotateFileTransportOptions): DailyRotateFile | Winston.transports.FileTransportInstance;
|
|
@@ -8,15 +8,17 @@ export interface VonaModulesMeta {
|
|
|
8
8
|
modules: Record<string, IModule>;
|
|
9
9
|
moduleNames: string[];
|
|
10
10
|
}
|
|
11
|
+
export interface IBootstrapOptionsLocales {
|
|
12
|
+
localesDefault: {};
|
|
13
|
+
localesModules: VonaLocaleOptionalMap;
|
|
14
|
+
}
|
|
11
15
|
export type TypeBootstrapOptionsModulesMeta = () => Promise<{
|
|
12
16
|
modulesMeta: VonaModulesMeta;
|
|
13
17
|
}>;
|
|
14
18
|
export type TypeBootstrapOptionsConfig = () => Promise<{
|
|
15
19
|
default: TypeAppInfoConfig[];
|
|
16
20
|
}>;
|
|
17
|
-
export type TypeBootstrapOptionsLocales = () => Promise<
|
|
18
|
-
locales: VonaLocaleOptionalMap;
|
|
19
|
-
}>;
|
|
21
|
+
export type TypeBootstrapOptionsLocales = () => Promise<IBootstrapOptionsLocales>;
|
|
20
22
|
export interface KoaApplicationOptions {
|
|
21
23
|
env?: string | undefined;
|
|
22
24
|
keys?: string[] | undefined;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { ILocaleRecord } from '../../lib/bean/resource/locale/type.ts';
|
|
2
2
|
import type { IBeanScopeLocale } from '../../lib/bean/type.ts';
|
|
3
3
|
import type { PowerPartial } from '../utils/powerPartial.ts';
|
|
4
|
-
export
|
|
5
|
-
modules: {};
|
|
6
|
-
};
|
|
7
|
-
export type VonaLocale = {
|
|
4
|
+
export interface VonaLocale {
|
|
8
5
|
modules: IBeanScopeLocale;
|
|
9
|
-
}
|
|
6
|
+
}
|
|
10
7
|
export type VonaLocaleOptional = PowerPartial<VonaLocale>;
|
|
11
8
|
export type VonaLocaleOptionalMap = Record<keyof ILocaleRecord, VonaLocaleOptional>;
|
|
@@ -3,6 +3,13 @@ import type DailyRotateFile from 'winston-daily-rotate-file';
|
|
|
3
3
|
export interface ILoggerOptionsClientInfo {
|
|
4
4
|
clientName: keyof ILoggerClientRecord;
|
|
5
5
|
level: () => (LoggerLevel | false);
|
|
6
|
+
child: () => (string[] | undefined);
|
|
7
|
+
}
|
|
8
|
+
export interface ILoggerFormatFilterOpts {
|
|
9
|
+
level: (() => (LoggerLevel | false)) | (LoggerLevel | false);
|
|
10
|
+
child: (() => (string[] | undefined)) | (string[] | undefined);
|
|
11
|
+
strict?: boolean;
|
|
12
|
+
silly?: boolean;
|
|
6
13
|
}
|
|
7
14
|
export type TypeLoggerOptions = Winston.LoggerOptions | ((clientInfo: ILoggerOptionsClientInfo, winston: typeof Winston) => Winston.LoggerOptions);
|
|
8
15
|
export type TypeLoggerRotateOptions = DailyRotateFile.DailyRotateFileTransportOptions & {
|
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.133",
|
|
5
5
|
"description": "vona",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@cabloy/module-info": "^1.3.41",
|
|
33
33
|
"@cabloy/module-info-pro": "^1.0.45",
|
|
34
34
|
"@cabloy/type-fest": "^5.3.1",
|
|
35
|
-
"@cabloy/utils": "^2.0.
|
|
35
|
+
"@cabloy/utils": "^2.0.22",
|
|
36
36
|
"@cabloy/word-utils": "^2.0.2",
|
|
37
37
|
"@cabloy/zod-errors-custom": "^2.0.6",
|
|
38
38
|
"@cabloy/zod-openapi": "^1.0.8",
|