@aalis/api-doctor 0.5.0 → 0.6.0
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.md +27 -0
- package/dist/index.d.ts +9 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -12
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @aalis/api-doctor
|
|
2
|
+
|
|
3
|
+
诊断子系统契约:检查项注册、报告类型与 `doctor` 描述符。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @aalis/api-doctor
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 提供
|
|
12
|
+
|
|
13
|
+
服务描述符:`doctor`(服务名 `doctor`)。
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { doctor } from '@aalis/api-doctor';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
实现见 `@aalis/plugin-doctor`。
|
|
20
|
+
|
|
21
|
+
## 文档
|
|
22
|
+
|
|
23
|
+
详见 [docs/services/doctor.md](../../docs/services/doctor.md)。
|
|
24
|
+
|
|
25
|
+
## 许可
|
|
26
|
+
|
|
27
|
+
见仓库根目录 LICENSE。
|
package/dist/index.d.ts
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
*
|
|
9
9
|
* 为避免 storage/commands 等下游插件直接 runtime depend 实现包 plugin-doctor
|
|
10
10
|
* (会形成「实现包 ↔ 业务插件」的双向耦合),仿照 api-storage /
|
|
11
|
-
* api-commands 的模式抽出本 api 包,仅含类型 +
|
|
12
|
-
*
|
|
11
|
+
* api-commands 的模式抽出本 api 包,仅含类型 + 服务描述符 `doctor`
|
|
12
|
+
* (检查项的登记随激活撤回、doctor 未上线时排队到它上线)。
|
|
13
13
|
*
|
|
14
14
|
* AalisEvents 的模块增强统一在本文件做,避免多包
|
|
15
15
|
* 重复声明导致 TS 合并冲突。
|
|
16
16
|
*/
|
|
17
|
-
import type {
|
|
17
|
+
import type { ServiceRef } from '@aalis/core';
|
|
18
18
|
export type CheckLevel = 'ok' | 'warn' | 'error';
|
|
19
19
|
export type CheckCategory = 'env' | 'filesystem' | 'plugins' | 'config' | 'service' | 'other';
|
|
20
20
|
export interface CheckResult {
|
|
@@ -43,8 +43,8 @@ export interface CheckSpec {
|
|
|
43
43
|
label?: string;
|
|
44
44
|
/** 来源插件名,自动由 DoctorService 注入;外部传入也可 */
|
|
45
45
|
pluginName?: string;
|
|
46
|
-
/** 执行函数:返回 1~N 条结果(一个 spec 可输出多条相关 check
|
|
47
|
-
run(
|
|
46
|
+
/** 执行函数:返回 1~N 条结果(一个 spec 可输出多条相关 check)。要用到的能力由注册方闭包带入 */
|
|
47
|
+
run(): Promise<CheckResult | CheckResult[]> | CheckResult | CheckResult[];
|
|
48
48
|
}
|
|
49
49
|
export interface DoctorService {
|
|
50
50
|
/** 同步运行所有检查,返回报告 */
|
|
@@ -76,28 +76,10 @@ declare module '@aalis/core' {
|
|
|
76
76
|
}];
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
/**
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
* whenService 订阅。
|
|
83
|
-
*
|
|
84
|
-
* 用法:
|
|
85
|
-
* useDoctorService(ctx).registerCheck({
|
|
86
|
-
* id: 'storage.roots',
|
|
87
|
-
* category: 'filesystem',
|
|
88
|
-
* async run() { ... }
|
|
89
|
-
* });
|
|
90
|
-
*
|
|
91
|
-
* 调用方应在 inject.optional 中声明 'doctor',否则 doctor 重启时不会带动本插件。
|
|
92
|
-
*/
|
|
93
|
-
export interface ScopedDoctorService {
|
|
94
|
-
/** 立即或延迟注册一条 check;返回 dispose */
|
|
79
|
+
/** `doctor` 的绑定接口:调用那一半是 ServiceRef,登记检查项自动归属这次激活 */
|
|
80
|
+
export interface BoundDoctor extends ServiceRef<DoctorService> {
|
|
81
|
+
/** 登记一条检查项:同 id 替换,提供者换人自动重挂,随激活撤回 */
|
|
95
82
|
registerCheck(spec: CheckSpec): () => void;
|
|
96
83
|
}
|
|
97
|
-
export declare
|
|
98
|
-
declare module '@aalis/core' {
|
|
99
|
-
interface ServiceTypeMap {
|
|
100
|
-
doctor: DoctorService;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
84
|
+
export declare const doctor: import("@aalis/core").ServiceDescriptor<DoctorService, BoundDoctor>;
|
|
103
85
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAK9C,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC;AACjD,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAE9F,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,aAAa,CAAC;IACxB,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;A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 -8,20 +8,18 @@
|
|
|
8
8
|
*
|
|
9
9
|
* 为避免 storage/commands 等下游插件直接 runtime depend 实现包 plugin-doctor
|
|
10
10
|
* (会形成「实现包 ↔ 业务插件」的双向耦合),仿照 api-storage /
|
|
11
|
-
* api-commands 的模式抽出本 api 包,仅含类型 +
|
|
12
|
-
*
|
|
11
|
+
* api-commands 的模式抽出本 api 包,仅含类型 + 服务描述符 `doctor`
|
|
12
|
+
* (检查项的登记随激活撤回、doctor 未上线时排队到它上线)。
|
|
13
13
|
*
|
|
14
14
|
* AalisEvents 的模块增强统一在本文件做,避免多包
|
|
15
15
|
* 重复声明导致 TS 合并冲突。
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
}
|
|
17
|
+
import { defineService, serviceRef } from '@aalis/core';
|
|
18
|
+
export const doctor = defineService('doctor', port => {
|
|
19
|
+
const checks = port.registrar({
|
|
20
|
+
key: spec => spec.id,
|
|
21
|
+
register: (service, spec) => service.registerCheck(spec),
|
|
22
|
+
});
|
|
23
|
+
return serviceRef(port, { registerCheck: (spec) => checks.add({ pluginName: port.id, ...spec }) });
|
|
24
|
+
});
|
|
27
25
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAkExD,MAAM,CAAC,MAAM,MAAM,GAAG,aAAa,CAA6B,QAAQ,EAAE,IAAI,CAAC,EAAE;IAC/E,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAY;QACvC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE;QACpB,QAAQ,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC;KACzD,CAAC,CAAC;IACH,OAAO,UAAU,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,CAAC,IAAe,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;AAChH,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aalis/api-doctor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/node": "^22.0.0",
|
|
23
23
|
"typescript": "^5.7.0",
|
|
24
|
-
"@aalis/core": "0.
|
|
24
|
+
"@aalis/core": "0.17.0"
|
|
25
25
|
},
|
|
26
26
|
"aalis": {
|
|
27
27
|
"types": true
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@aalis/core": ">=0.
|
|
30
|
+
"@aalis/core": ">=0.17.0 <1.0.0"
|
|
31
31
|
},
|
|
32
32
|
"keywords": [
|
|
33
33
|
"aalis",
|