@h-ai/core 0.1.0-alpha9 → 1.0.0-beta.2

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/node.d.ts CHANGED
@@ -1,82 +1,25 @@
1
- import { H as HaiError, a as HaiResult, C as CoreOptions, b as CoreLogger, I as I18nFn, c as IdFn, T as TypeUtilFn, O as ObjectFn, S as StringFn, A as ArrayFn, d as AsyncFn, e as TimeFn, E as ErrorFn, M as ModuleFn } from './core-util-module-B-wH5_ZT.js';
2
- export { f as CoreConfig, g as CoreConfigSchema, h as CoreFunctions, i as Env, j as EnvSchema, k as ErrorInfo, l as ErrorInfoValue, m as HaiCommonError, n as HaiConfigError, o as HaiErrorDef, p as IdConfig, q as IdConfigSchema, r as InterpolationParams, L as Locale, s as LocaleInfo, t as LocaleMessages, u as LogContext, v as LogFormat, w as LogFormatSchema, x as LogLevel, y as LogLevelSchema, z as Logger, B as LoggerFunctions, D as LoggerOptions, F as LoggingConfig, G as LoggingConfigSchema, J as MatchHandlers, K as MessageDictionary, N as MessageOptions, P as PaginatedResult, Q as PaginationOptions, R as PaginationOptionsInput, U as err, V as ok } from './core-util-module-B-wH5_ZT.js';
3
- import * as zod from 'zod';
1
+ import { W as NodeCoreFunctions } from './core-types-_JqVAGGT.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-_JqVAGGT.js';
3
+ import 'zod';
4
4
 
5
5
  /**
6
- * @h-ai/core — 配置管理(Node.js 专用)
6
+ * @h-ai/core — Core 服务聚合(Node.js)
7
7
  *
8
- * 提供 YAML 配置文件加载、环境变量插值、缓存管理。
9
- * @module core-function-config
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
- * core.init({ configDir: './config', watchConfig: true })
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 function initCore(options?: CoreOptions): void;
23
+ declare const core: NodeCoreFunctions;
81
24
 
82
- export { CoreLogger, CoreOptions, HaiError, HaiResult, core };
25
+ export { NodeCoreFunctions, core };