dsh-d365-kit 0.34.1 → 0.34.3
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/CHANGELOG.md +318 -308
- package/CHANGELOG.zh-CN.md +317 -307
- package/INSTALL.md +94 -94
- package/INSTALL.zh-CN.md +93 -93
- package/LICENSE +21 -21
- package/README.md +336 -327
- package/README.zh-CN.md +336 -327
- package/client.js +1818 -1818
- package/cordis.patch.yml +44 -44
- package/docs/en/architecture.md +172 -172
- package/docs/en/checks.md +184 -184
- package/docs/en/installation.md +151 -151
- package/docs/en/permissions.md +161 -161
- package/docs/en/scenarios.md +202 -202
- package/docs/en/tools.md +665 -665
- package/docs/en/troubleshooting.md +131 -131
- package/docs/zh/architecture.md +172 -172
- package/docs/zh/checks.md +184 -184
- package/docs/zh/installation.md +151 -151
- package/docs/zh/permissions.md +161 -161
- package/docs/zh/scenarios.md +202 -202
- package/docs/zh/tools.md +665 -665
- package/docs/zh/troubleshooting.md +131 -131
- package/examples/prompts.en.md +206 -206
- package/examples/prompts.zh-CN.md +206 -206
- package/examples/waivers.example.json +20 -20
- package/icon.svg +6 -6
- package/index.js +139 -139
- package/lib/auth.js +181 -181
- package/lib/client.js +496 -496
- package/lib/code-check.js +549 -549
- package/lib/config.js +323 -323
- package/lib/contract-history.js +49 -49
- package/lib/contract.js +583 -583
- package/lib/csharp-check.js +493 -493
- package/lib/data-migrate.js +1318 -1318
- package/lib/data-policy.js +78 -78
- package/lib/error-codes.js +80 -80
- package/lib/gitlab.js +161 -161
- package/lib/health.js +205 -205
- package/lib/migrate.js +732 -732
- package/lib/preflight.js +116 -116
- package/lib/refs.js +191 -191
- package/lib/resources.js +320 -320
- package/lib/retention-defaults.js +17 -17
- package/lib/retention.js +384 -384
- package/lib/runtime.js +232 -232
- package/lib/settings-http.js +512 -512
- package/lib/settings-store.js +371 -371
- package/lib/snapshot.js +149 -149
- package/lib/tool-code-check.js +133 -133
- package/lib/tool-configure.js +169 -169
- package/lib/tool-contract.js +376 -376
- package/lib/tool-data-sync.js +559 -559
- package/lib/tool-data-write.js +203 -203
- package/lib/tool-data.js +282 -282
- package/lib/tool-diff.js +484 -484
- package/lib/tool-environments.js +106 -106
- package/lib/tool-flows.js +540 -540
- package/lib/tool-health.js +127 -127
- package/lib/tool-layers.js +497 -497
- package/lib/tool-metadata.js +417 -417
- package/lib/tool-migrate.js +102 -102
- package/lib/tool-refs.js +206 -206
- package/lib/tool-reports.js +299 -299
- package/lib/tool-sync.js +430 -430
- package/lib/tool-write.js +563 -563
- package/lib/waivers.js +83 -83
- package/lib/write-actions.js +1374 -1374
- package/lib/write-policy.js +199 -199
- package/lib/write-store.js +167 -167
- package/locale/en.json +68 -68
- package/locale/zh.json +68 -68
- package/package.json +2 -2
- package/skills/d365-troubleshooting/SKILL.md +115 -115
package/lib/tool-health.js
CHANGED
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `d365_health` — is the environment busy, what failed recently, what got
|
|
3
|
-
* installed lately. Read-only; meant to be run before a release.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { loadConfig } from './config.js'
|
|
7
|
-
import { D365Error } from './errors.js'
|
|
8
|
-
import { readHealth, renderHealth } from './health.js'
|
|
9
|
-
import { writeArtifact } from './runtime.js'
|
|
10
|
-
|
|
11
|
-
function pickEnvironments(config, args) {
|
|
12
|
-
const keys = Object.keys(config.environments)
|
|
13
|
-
if (!keys.length) throw new D365Error('还没有配置任何 D365 环境', { hint: '在设置页「环境」里添加环境。' })
|
|
14
|
-
if (args.allEnvironments === true) return keys
|
|
15
|
-
if (Array.isArray(args.environments) && args.environments.length) {
|
|
16
|
-
for (const key of args.environments) {
|
|
17
|
-
if (!config.environments[key]) throw new D365Error(`未知环境:${key}`, { hint: `可用:${keys.join(', ')}` })
|
|
18
|
-
}
|
|
19
|
-
return args.environments
|
|
20
|
-
}
|
|
21
|
-
return [config.defaultEnvironment ?? keys[0]]
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function register(ctx, state) {
|
|
25
|
-
const dispose = ctx.tools.register({
|
|
26
|
-
name: 'd365_health',
|
|
27
|
-
description:
|
|
28
|
-
'环境健康检查:挂起/失败的后台作业、正在运行的导入发布、最近安装的解决方案与组织版本。只读。',
|
|
29
|
-
parameters: {
|
|
30
|
-
type: 'object',
|
|
31
|
-
additionalProperties: false,
|
|
32
|
-
properties: {
|
|
33
|
-
environments: {
|
|
34
|
-
type: 'array',
|
|
35
|
-
items: { type: 'string' },
|
|
36
|
-
description: '环境 key 列表,省略则用默认环境。',
|
|
37
|
-
},
|
|
38
|
-
allEnvironments: { type: 'boolean', description: '对全部已配置环境执行同一查询。' },
|
|
39
|
-
hours: { type: 'number', description: '失败作业的回看小时数,默认 24。' },
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
output: {
|
|
43
|
-
schema: {
|
|
44
|
-
type: 'object',
|
|
45
|
-
additionalProperties: false,
|
|
46
|
-
required: ['schemaVersion', 'rows', 'artifactPath'],
|
|
47
|
-
properties: {
|
|
48
|
-
schemaVersion: { type: 'number' },
|
|
49
|
-
artifactPath: { type: 'string' },
|
|
50
|
-
rows: {
|
|
51
|
-
type: 'array',
|
|
52
|
-
items: {
|
|
53
|
-
type: 'object',
|
|
54
|
-
additionalProperties: false,
|
|
55
|
-
properties: {
|
|
56
|
-
env: { type: 'string' },
|
|
57
|
-
url: { type: 'string' },
|
|
58
|
-
version: { type: 'string' },
|
|
59
|
-
organization: { type: 'string' },
|
|
60
|
-
queued: { type: 'number' },
|
|
61
|
-
suspended: { type: 'number' },
|
|
62
|
-
failed: { type: 'number' },
|
|
63
|
-
traceLevel: { type: 'number' },
|
|
64
|
-
denied: { type: 'boolean' },
|
|
65
|
-
warnings: { type: 'array', items: { type: 'string' } },
|
|
66
|
-
hours: { type: 'number' },
|
|
67
|
-
failures: {
|
|
68
|
-
type: 'array',
|
|
69
|
-
items: {
|
|
70
|
-
type: 'object',
|
|
71
|
-
additionalProperties: false,
|
|
72
|
-
properties: {
|
|
73
|
-
name: { type: 'string' },
|
|
74
|
-
message: { type: 'string' },
|
|
75
|
-
operationtype: { type: 'number' },
|
|
76
|
-
modifiedon: { type: 'string' },
|
|
77
|
-
count: { type: 'number' },
|
|
78
|
-
errorcode: { type: 'number' },
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
runningSolutions: {
|
|
83
|
-
type: 'array',
|
|
84
|
-
items: {
|
|
85
|
-
type: 'object',
|
|
86
|
-
additionalProperties: false,
|
|
87
|
-
properties: {
|
|
88
|
-
name: { type: 'string' },
|
|
89
|
-
operation: { type: 'number' },
|
|
90
|
-
startedAt: { type: 'string' },
|
|
91
|
-
managed: { type: 'boolean' },
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
recentSolutions: {
|
|
96
|
-
type: 'array',
|
|
97
|
-
items: {
|
|
98
|
-
type: 'object',
|
|
99
|
-
additionalProperties: false,
|
|
100
|
-
properties: {
|
|
101
|
-
uniquename: { type: 'string' },
|
|
102
|
-
version: { type: 'string' },
|
|
103
|
-
managed: { type: 'boolean' },
|
|
104
|
-
installedon: { type: 'string' },
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
render: (args, value) => renderHealth(value.rows),
|
|
114
|
-
},
|
|
115
|
-
async execute(args, exec) {
|
|
116
|
-
const config = await loadConfig(state.rawConfig)
|
|
117
|
-
const keys = pickEnvironments(config, args)
|
|
118
|
-
const rows = []
|
|
119
|
-
for (const key of keys) {
|
|
120
|
-
rows.push(await readHealth(config, key, { hours: args.hours, signal: exec.signal }))
|
|
121
|
-
}
|
|
122
|
-
const artifactPath = await writeArtifact(config, 'health', { generatedAt: new Date().toISOString(), rows })
|
|
123
|
-
return { schemaVersion: 1, rows, artifactPath }
|
|
124
|
-
},
|
|
125
|
-
})
|
|
126
|
-
return dispose
|
|
127
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* `d365_health` — is the environment busy, what failed recently, what got
|
|
3
|
+
* installed lately. Read-only; meant to be run before a release.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { loadConfig } from './config.js'
|
|
7
|
+
import { D365Error } from './errors.js'
|
|
8
|
+
import { readHealth, renderHealth } from './health.js'
|
|
9
|
+
import { writeArtifact } from './runtime.js'
|
|
10
|
+
|
|
11
|
+
function pickEnvironments(config, args) {
|
|
12
|
+
const keys = Object.keys(config.environments)
|
|
13
|
+
if (!keys.length) throw new D365Error('还没有配置任何 D365 环境', { hint: '在设置页「环境」里添加环境。' })
|
|
14
|
+
if (args.allEnvironments === true) return keys
|
|
15
|
+
if (Array.isArray(args.environments) && args.environments.length) {
|
|
16
|
+
for (const key of args.environments) {
|
|
17
|
+
if (!config.environments[key]) throw new D365Error(`未知环境:${key}`, { hint: `可用:${keys.join(', ')}` })
|
|
18
|
+
}
|
|
19
|
+
return args.environments
|
|
20
|
+
}
|
|
21
|
+
return [config.defaultEnvironment ?? keys[0]]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function register(ctx, state) {
|
|
25
|
+
const dispose = ctx.tools.register({
|
|
26
|
+
name: 'd365_health',
|
|
27
|
+
description:
|
|
28
|
+
'环境健康检查:挂起/失败的后台作业、正在运行的导入发布、最近安装的解决方案与组织版本。只读。',
|
|
29
|
+
parameters: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
additionalProperties: false,
|
|
32
|
+
properties: {
|
|
33
|
+
environments: {
|
|
34
|
+
type: 'array',
|
|
35
|
+
items: { type: 'string' },
|
|
36
|
+
description: '环境 key 列表,省略则用默认环境。',
|
|
37
|
+
},
|
|
38
|
+
allEnvironments: { type: 'boolean', description: '对全部已配置环境执行同一查询。' },
|
|
39
|
+
hours: { type: 'number', description: '失败作业的回看小时数,默认 24。' },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
output: {
|
|
43
|
+
schema: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
required: ['schemaVersion', 'rows', 'artifactPath'],
|
|
47
|
+
properties: {
|
|
48
|
+
schemaVersion: { type: 'number' },
|
|
49
|
+
artifactPath: { type: 'string' },
|
|
50
|
+
rows: {
|
|
51
|
+
type: 'array',
|
|
52
|
+
items: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
additionalProperties: false,
|
|
55
|
+
properties: {
|
|
56
|
+
env: { type: 'string' },
|
|
57
|
+
url: { type: 'string' },
|
|
58
|
+
version: { type: 'string' },
|
|
59
|
+
organization: { type: 'string' },
|
|
60
|
+
queued: { type: 'number' },
|
|
61
|
+
suspended: { type: 'number' },
|
|
62
|
+
failed: { type: 'number' },
|
|
63
|
+
traceLevel: { type: 'number' },
|
|
64
|
+
denied: { type: 'boolean' },
|
|
65
|
+
warnings: { type: 'array', items: { type: 'string' } },
|
|
66
|
+
hours: { type: 'number' },
|
|
67
|
+
failures: {
|
|
68
|
+
type: 'array',
|
|
69
|
+
items: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
additionalProperties: false,
|
|
72
|
+
properties: {
|
|
73
|
+
name: { type: 'string' },
|
|
74
|
+
message: { type: 'string' },
|
|
75
|
+
operationtype: { type: 'number' },
|
|
76
|
+
modifiedon: { type: 'string' },
|
|
77
|
+
count: { type: 'number' },
|
|
78
|
+
errorcode: { type: 'number' },
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
runningSolutions: {
|
|
83
|
+
type: 'array',
|
|
84
|
+
items: {
|
|
85
|
+
type: 'object',
|
|
86
|
+
additionalProperties: false,
|
|
87
|
+
properties: {
|
|
88
|
+
name: { type: 'string' },
|
|
89
|
+
operation: { type: 'number' },
|
|
90
|
+
startedAt: { type: 'string' },
|
|
91
|
+
managed: { type: 'boolean' },
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
recentSolutions: {
|
|
96
|
+
type: 'array',
|
|
97
|
+
items: {
|
|
98
|
+
type: 'object',
|
|
99
|
+
additionalProperties: false,
|
|
100
|
+
properties: {
|
|
101
|
+
uniquename: { type: 'string' },
|
|
102
|
+
version: { type: 'string' },
|
|
103
|
+
managed: { type: 'boolean' },
|
|
104
|
+
installedon: { type: 'string' },
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
render: (args, value) => renderHealth(value.rows),
|
|
114
|
+
},
|
|
115
|
+
async execute(args, exec) {
|
|
116
|
+
const config = await loadConfig(state.rawConfig)
|
|
117
|
+
const keys = pickEnvironments(config, args)
|
|
118
|
+
const rows = []
|
|
119
|
+
for (const key of keys) {
|
|
120
|
+
rows.push(await readHealth(config, key, { hours: args.hours, signal: exec.signal }))
|
|
121
|
+
}
|
|
122
|
+
const artifactPath = await writeArtifact(config, 'health', { generatedAt: new Date().toISOString(), rows })
|
|
123
|
+
return { schemaVersion: 1, rows, artifactPath }
|
|
124
|
+
},
|
|
125
|
+
})
|
|
126
|
+
return dispose
|
|
127
|
+
}
|