@h-ai/core 0.1.0-alpha9 → 1.0.0-beta.10
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/README.en.md +820 -0
- package/README.ja.md +820 -0
- package/README.md +715 -317
- package/dist/browser.d.ts +11 -31
- package/dist/browser.js +114 -26
- package/dist/browser.js.map +1 -1
- package/dist/{chunk-FVCFFZP6.js → chunk-MYNB4HIZ.js} +9786 -3163
- package/dist/chunk-MYNB4HIZ.js.map +1 -0
- package/dist/core-types-DM_AiIaS.d.ts +2885 -0
- package/dist/node.d.ts +13 -70
- package/dist/node.js +750 -88
- package/dist/node.js.map +1 -1
- package/package.json +23 -16
- package/dist/chunk-FVCFFZP6.js.map +0 -1
- package/dist/core-util-module-B-wH5_ZT.d.ts +0 -1626
package/dist/node.d.ts
CHANGED
|
@@ -1,82 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { f as
|
|
3
|
-
import
|
|
1
|
+
import { W as NodeCoreFunctions } from './core-types-DM_AiIaS.js';
|
|
2
|
+
export { A as AccessCondition, a as AccessConditionSchema, b as AccessDecision, c as AccessFunctions, d as ArrayFn, e as AsyncFn, f as BrowserConfigFn, B as BrowserCoreFunctions, C as ConfigFn, g as CoreConfig, h as CoreConfigSchema, i as CoreFunctions, j as CoreLogger, k as CoreOptions, l as CreateNotInitializedKitFn, E as Env, m as EnvSchema, n as ErrorFn, o as ErrorInfo, p as ErrorInfoValue, H as HaiCommonError, q as HaiConfigError, r as HaiError, s as HaiErrorDef, t as HaiResult, I as I18nFn, u as IdFn, v as InterpolationParams, L as Locale, w as LocaleInfo, x as LocaleMessages, y as LogContext, z as LogFormat, D as LogFormatSchema, F as LogLevel, G as LogLevelSchema, J as LogObserver, K as LogRecord, M as Logger, N as LoggerFunctions, O as LoggerOptions, P as LoggingConfig, Q as LoggingConfigSchema, R as MatchHandlers, S as MessageDictionary, T as MessageOptions, U as ModuleFn, V as ModuleRuntime, X as NotInitializedKit, Y as ObjectFn, Z as PaginatedResult, _ as PaginationOptions, $ as PaginationOptionsInput, a0 as RequestAccessCheck, a1 as RequestAccessConfigInput, a2 as RequestAccessConfigSchema, a3 as RequestAccessPolicy, a4 as RequestAccessPolicySchema, a5 as RequestContext, a6 as RequestEncryptionMode, a7 as RuntimeStep, a8 as SanitizeFn, a9 as SanitizeSensitiveFieldsOptions, aa as SensitiveKeyMatcher, ab as StringFn, ac as TimeFn, ad as TrustedProxies, ae as TrustedProxiesSchema, af as TypeUtilFn, ag as ValidationFormError, ah as WatchCallback, ai as ZodMessageGetter, aj as ZodValidationFn, ak as ZodValidationMessageKey, al as err, am as ok } from './core-types-DM_AiIaS.js';
|
|
3
|
+
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @h-ai/core —
|
|
6
|
+
* @h-ai/core — Core 服务聚合(Node.js)
|
|
7
7
|
*
|
|
8
|
-
* 提供
|
|
9
|
-
* @module core-
|
|
8
|
+
* 提供 Node.js 环境的 core 对象,聚合常用功能。 所有功能统一通过 core 对象访问,并提供配置加载能力。
|
|
9
|
+
* @module core-main.node
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* 监听回调类型。
|
|
14
|
-
*
|
|
15
|
-
* @template T - 配置数据类型
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* const callback: WatchCallback<AppConfig> = (cfg, error) => {
|
|
20
|
-
* if (error) { core.logger.error('Config reload failed', { error }); return }
|
|
21
|
-
* // 使用更新后的 cfg
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
type WatchCallback<T = unknown> = (config: T | null, error?: HaiError) => void;
|
|
26
|
-
|
|
27
12
|
/**
|
|
28
13
|
* Core 服务对象 - 聚合常用功能(Node.js)。
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* import { core } from '@h-ai/core'
|
|
33
|
-
* core.init({ configDir: './config' })
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
declare const core: {
|
|
37
|
-
/** 配置管理 */
|
|
38
|
-
config: {
|
|
39
|
-
load<T>(name: string, filePath: string, schema?: zod.ZodType<T>): HaiResult<T>;
|
|
40
|
-
validate<T>(name: string, schema: zod.ZodType<T>): HaiResult<T>;
|
|
41
|
-
get<T>(name: string): T | undefined;
|
|
42
|
-
getOrThrow<T>(name: string): T;
|
|
43
|
-
reload(name: string): HaiResult<unknown>;
|
|
44
|
-
has(name: string): boolean;
|
|
45
|
-
clear(name?: string): void;
|
|
46
|
-
keys(): string[];
|
|
47
|
-
watch<T = unknown>(name: string, callback: WatchCallback<T>): () => void;
|
|
48
|
-
unwatch(name?: string): void;
|
|
49
|
-
isWatching(name: string): boolean;
|
|
50
|
-
};
|
|
51
|
-
/** 初始化 Core */
|
|
52
|
-
init: typeof initCore;
|
|
53
|
-
logger: CoreLogger;
|
|
54
|
-
i18n: I18nFn;
|
|
55
|
-
id: IdFn;
|
|
56
|
-
typeUtils: TypeUtilFn;
|
|
57
|
-
object: ObjectFn;
|
|
58
|
-
string: StringFn;
|
|
59
|
-
array: ArrayFn;
|
|
60
|
-
async: AsyncFn;
|
|
61
|
-
time: TimeFn;
|
|
62
|
-
error: ErrorFn;
|
|
63
|
-
module: ModuleFn;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* 初始化 Core(内部实现,通过 `core.init()` 调用)。
|
|
67
|
-
*
|
|
68
|
-
* 执行流程:
|
|
69
|
-
* 1. 配置日志(若提供 `options.logging`)
|
|
70
|
-
* 2. 扫描并加载配置目录中的所有 YAML 文件
|
|
71
|
-
* 3. 启用配置文件监听(若 `options.watchConfig` 为 true)
|
|
72
|
-
*
|
|
73
|
-
* @param options - 初始化选项
|
|
74
|
-
*
|
|
75
14
|
* @example
|
|
76
15
|
* ```ts
|
|
77
|
-
*
|
|
16
|
+
* import { core, CoreConfigSchema } from '@h-ai/core'
|
|
17
|
+
* core.init({ configDir: './config' }) // 单项加载失败记录日志并继续。
|
|
18
|
+
* const required = core.config.validate('core', CoreConfigSchema)
|
|
19
|
+
* if (!required.success) core.logger.error('Required config unavailable', { error: required.error })
|
|
20
|
+
* else core.logger.info('Application ready', { name: required.data.name })
|
|
78
21
|
* ```
|
|
79
22
|
*/
|
|
80
|
-
declare
|
|
23
|
+
declare const core: NodeCoreFunctions;
|
|
81
24
|
|
|
82
|
-
export {
|
|
25
|
+
export { NodeCoreFunctions, core };
|