@liuhange/dsh-data-asset-registration-helper 3.0.0 → 3.1.1
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.
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { promptTripleAuditStandard, promptSevenStepFlow } from '../tripleAuditAndSevenStep.js';
|
|
3
|
+
describe('TripleAuditStandardPrompter', () => {
|
|
4
|
+
const config = {
|
|
5
|
+
enabled: true,
|
|
6
|
+
standards: ['数据描述准确性', '数据来源合规性', '数据产权明确性'],
|
|
7
|
+
policyRef: '国数综政策〔2026〕35号',
|
|
8
|
+
promptMessage: '登记系统审查重点为:数据描述准确性、数据来源合规性、数据产权明确性',
|
|
9
|
+
};
|
|
10
|
+
it('enabled时嵌入三重审核标准', () => {
|
|
11
|
+
const result = promptTripleAuditStandard(config);
|
|
12
|
+
expect(result.enabled).toBe(true);
|
|
13
|
+
expect(result.standards).toHaveLength(3);
|
|
14
|
+
expect(result.promptMessage).toContain('数据描述准确性');
|
|
15
|
+
expect(result.policyRef).toBe('国数综政策〔2026〕35号');
|
|
16
|
+
});
|
|
17
|
+
it('disabled时返回空标准', () => {
|
|
18
|
+
const result = promptTripleAuditStandard({ ...config, enabled: false });
|
|
19
|
+
expect(result.enabled).toBe(false);
|
|
20
|
+
expect(result.standards).toHaveLength(0);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe('SevenStepFlowPrompter', () => {
|
|
24
|
+
const config = {
|
|
25
|
+
enabled: true,
|
|
26
|
+
steps: [
|
|
27
|
+
{ step: 1, name: '申请', durationDays: null },
|
|
28
|
+
{ step: 2, name: '受理', durationDays: 3 },
|
|
29
|
+
{ step: 3, name: '审查', durationDays: null },
|
|
30
|
+
{ step: 4, name: '公示', durationDays: 5 },
|
|
31
|
+
{ step: 5, name: '异议处理', durationDays: 10 },
|
|
32
|
+
{ step: 6, name: '信息存证', durationDays: null },
|
|
33
|
+
{ step: 7, name: '凭证核发', durationDays: null },
|
|
34
|
+
],
|
|
35
|
+
policyRef: '国数综政策〔2026〕35号',
|
|
36
|
+
};
|
|
37
|
+
it('enabled时输出7步流程', () => {
|
|
38
|
+
const result = promptSevenStepFlow(config);
|
|
39
|
+
expect(result.enabled).toBe(true);
|
|
40
|
+
expect(result.steps).toHaveLength(7);
|
|
41
|
+
expect(result.totalMaxDays).toBe(18);
|
|
42
|
+
expect(result.policyRef).toBe('国数综政策〔2026〕35号');
|
|
43
|
+
});
|
|
44
|
+
it('disabled时返回空流程', () => {
|
|
45
|
+
const result = promptSevenStepFlow({ ...config, enabled: false });
|
|
46
|
+
expect(result.enabled).toBe(false);
|
|
47
|
+
expect(result.steps).toHaveLength(0);
|
|
48
|
+
expect(result.totalMaxDays).toBe(0);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=tripleAuditAndSevenStep.test.js.map
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,8 @@ import { checkDisallowedScenarios } from './disallowedScenarioChecker.js';
|
|
|
2
2
|
import { matchAgency } from './agencyMatcher.js';
|
|
3
3
|
import { generateRegistrationReport } from './registrationReportGenerator.js';
|
|
4
4
|
import { validateRegistrationArgs } from './invariant.js';
|
|
5
|
+
import { promptTripleAuditStandard, promptSevenStepFlow } from './tripleAuditAndSevenStep.js';
|
|
6
|
+
import { loadJsonConfig } from '@liuhange/dsh-data-asset-shared';
|
|
5
7
|
export const name = '@liuhange/dsh-data-asset-registration-helper';
|
|
6
8
|
export const inject = ['tools'];
|
|
7
9
|
export function apply(ctx) {
|
|
@@ -33,10 +35,9 @@ export function apply(ctx) {
|
|
|
33
35
|
async execute(args) {
|
|
34
36
|
try {
|
|
35
37
|
const validated = validateRegistrationArgs(args);
|
|
36
|
-
const { readFileSync } = await import('node:fs');
|
|
37
38
|
let rulesConfig;
|
|
38
39
|
try {
|
|
39
|
-
rulesConfig =
|
|
40
|
+
rulesConfig = loadJsonConfig('BUSINESS_RULES_PATH', 'config/business-rules.json', '@liuhange/dsh-data-asset-shared/config/business-rules.json');
|
|
40
41
|
}
|
|
41
42
|
catch {
|
|
42
43
|
return JSON.stringify({ error: 'REGISTRATION_RULES_MISSING', message: '无法加载business-rules.json' });
|
|
@@ -47,8 +48,9 @@ export function apply(ctx) {
|
|
|
47
48
|
}
|
|
48
49
|
let policyDocuments;
|
|
49
50
|
try {
|
|
50
|
-
const policyConfig =
|
|
51
|
-
const
|
|
51
|
+
const policyConfig = loadJsonConfig('POLICY_REFS_PATH', 'config/policy-references.json', '@liuhange/dsh-data-asset-shared/config/policy-references.json');
|
|
52
|
+
const refs = policyConfig.policyReferences;
|
|
53
|
+
const stage = refs?.find(s => s.stage === 'PRECHECK');
|
|
52
54
|
policyDocuments = stage?.documents ?? [];
|
|
53
55
|
}
|
|
54
56
|
catch {
|
|
@@ -61,7 +63,16 @@ export function apply(ctx) {
|
|
|
61
63
|
agencyMatch = matchAgency(validated.dataType, validated.region, registrationConfig.agencies);
|
|
62
64
|
}
|
|
63
65
|
const report = generateRegistrationReport(validated.assetName, precheck, agencyMatch, policyDocuments);
|
|
64
|
-
|
|
66
|
+
const tripleAuditConfig = registrationConfig.tripleAuditStandard;
|
|
67
|
+
const tripleAudit = tripleAuditConfig ? promptTripleAuditStandard(tripleAuditConfig) : null;
|
|
68
|
+
const sevenStepConfig = registrationConfig.sevenStepFlow;
|
|
69
|
+
const sevenStep = sevenStepConfig ? promptSevenStepFlow(sevenStepConfig) : null;
|
|
70
|
+
const enrichedReport = {
|
|
71
|
+
...report,
|
|
72
|
+
tripleAuditStandard: tripleAudit,
|
|
73
|
+
sevenStepFlow: sevenStep,
|
|
74
|
+
};
|
|
75
|
+
return JSON.stringify(enrichedReport, null, 2);
|
|
65
76
|
}
|
|
66
77
|
catch (e) {
|
|
67
78
|
const err = e;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function promptTripleAuditStandard(config) {
|
|
2
|
+
return {
|
|
3
|
+
enabled: config.enabled,
|
|
4
|
+
standards: config.enabled ? config.standards : [],
|
|
5
|
+
promptMessage: config.enabled ? config.promptMessage : '',
|
|
6
|
+
policyRef: config.policyRef,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export function promptSevenStepFlow(config) {
|
|
10
|
+
if (!config.enabled) {
|
|
11
|
+
return { enabled: false, steps: [], totalMaxDays: 0, policyRef: config.policyRef };
|
|
12
|
+
}
|
|
13
|
+
const totalMaxDays = config.steps.reduce((sum, s) => sum + (s.durationDays ?? 0), 0);
|
|
14
|
+
return {
|
|
15
|
+
enabled: true,
|
|
16
|
+
steps: config.steps,
|
|
17
|
+
totalMaxDays,
|
|
18
|
+
policyRef: config.policyRef,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=tripleAuditAndSevenStep.js.map
|
package/package.json
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liuhange/dsh-data-asset-registration-helper",
|
|
3
3
|
"description": "Registration helper plugin: disallowed scenario check + ownership dispute check + agency matching + registration workflow guidance",
|
|
4
|
-
"version": "3.
|
|
5
|
-
"publishConfig": {
|
|
6
|
-
|
|
4
|
+
"version": "3.1.1",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/liuhange789/data-asset-inspector.git",
|
|
11
|
+
"directory": "packages/data-asset/data-asset-registration-helper"
|
|
12
|
+
},
|
|
7
13
|
"type": "module",
|
|
8
14
|
"main": "lib/index.js",
|
|
9
15
|
"types": "lib/types/index.d.ts",
|
|
10
16
|
"exports": {
|
|
11
|
-
".": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
12
21
|
"./src/*": "./src/*",
|
|
13
22
|
"./package.json": "./package.json"
|
|
14
23
|
},
|
|
15
|
-
"files": [
|
|
24
|
+
"files": [
|
|
25
|
+
"lib/**/*.js",
|
|
26
|
+
"lib/types/**/*.d.ts"
|
|
27
|
+
],
|
|
16
28
|
"license": "MIT",
|
|
17
29
|
"scripts": {
|
|
18
30
|
"typecheck": "tsc --noEmit",
|
|
@@ -24,5 +36,9 @@
|
|
|
24
36
|
"@deepseek-ai/dsh-tools": "0.0.1-rc.1",
|
|
25
37
|
"@liuhange/dsh-data-asset-shared": "^3.0.0"
|
|
26
38
|
},
|
|
27
|
-
"dsh": {
|
|
39
|
+
"dsh": {
|
|
40
|
+
"bundle": {
|
|
41
|
+
"patch": true
|
|
42
|
+
}
|
|
43
|
+
}
|
|
28
44
|
}
|