@liuhange/dsh-data-asset-compliance-check 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,24 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { embedPilotPolicyReference } from '../pilotPolicyReferenceEmbedder.js';
|
|
3
|
+
describe('PilotPolicyReferenceEmbedder', () => {
|
|
4
|
+
const config = {
|
|
5
|
+
enabled: true,
|
|
6
|
+
policyName: '数据资产全过程管理试点方案',
|
|
7
|
+
policyRef: '财资〔2024〕167号',
|
|
8
|
+
keyPoints: ['台账编制', '登记', '授权运营', '收益分配', '交易流通'],
|
|
9
|
+
embedMessage: '合规审查属于全过程管理试点中台账编制与登记环节的前置要求',
|
|
10
|
+
};
|
|
11
|
+
it('enabled时嵌入试点依据', () => {
|
|
12
|
+
const result = embedPilotPolicyReference(config);
|
|
13
|
+
expect(result.embedded).toBe(true);
|
|
14
|
+
expect(result.policyRef).toBe('财资〔2024〕167号');
|
|
15
|
+
expect(result.keyPoints).toHaveLength(5);
|
|
16
|
+
expect(result.message).toContain('全过程管理试点');
|
|
17
|
+
});
|
|
18
|
+
it('disabled时跳过嵌入', () => {
|
|
19
|
+
const result = embedPilotPolicyReference({ ...config, enabled: false });
|
|
20
|
+
expect(result.embedded).toBe(false);
|
|
21
|
+
expect(result.keyPoints).toHaveLength(0);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=pilotPolicyReferenceEmbedder.test.js.map
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { checkCompliance } from './complianceChecker.js';
|
|
2
2
|
import { validateComplianceArgs } from './invariant.js';
|
|
3
|
+
import { embedPilotPolicyReference } from './pilotPolicyReferenceEmbedder.js';
|
|
4
|
+
import { loadJsonConfig } from '@liuhange/dsh-data-asset-shared';
|
|
3
5
|
export const name = '@liuhange/dsh-data-asset-compliance-check';
|
|
4
6
|
export const inject = ['tools'];
|
|
5
7
|
export function apply(ctx) {
|
|
@@ -21,10 +23,9 @@ export function apply(ctx) {
|
|
|
21
23
|
async execute(args) {
|
|
22
24
|
try {
|
|
23
25
|
const validated = validateComplianceArgs(args);
|
|
24
|
-
const { readFileSync } = await import('node:fs');
|
|
25
26
|
let rulesConfig;
|
|
26
27
|
try {
|
|
27
|
-
rulesConfig =
|
|
28
|
+
rulesConfig = loadJsonConfig('BUSINESS_RULES_PATH', 'config/business-rules.json', '@liuhange/dsh-data-asset-shared/config/business-rules.json');
|
|
28
29
|
}
|
|
29
30
|
catch {
|
|
30
31
|
return JSON.stringify({ error: 'COMPLIANCE_RULES_MISSING', message: '无法加载business-rules.json' });
|
|
@@ -35,8 +36,9 @@ export function apply(ctx) {
|
|
|
35
36
|
}
|
|
36
37
|
let policyDocuments;
|
|
37
38
|
try {
|
|
38
|
-
const policyConfig =
|
|
39
|
-
const
|
|
39
|
+
const policyConfig = loadJsonConfig('POLICY_REFS_PATH', 'config/policy-references.json', '@liuhange/dsh-data-asset-shared/config/policy-references.json');
|
|
40
|
+
const refs = policyConfig.policyReferences;
|
|
41
|
+
const stage = refs?.find(s => s.stage === 'COMPLIANCE_CHECK');
|
|
40
42
|
policyDocuments = stage?.documents ?? [];
|
|
41
43
|
}
|
|
42
44
|
catch {
|
|
@@ -53,7 +55,13 @@ export function apply(ctx) {
|
|
|
53
55
|
hasPersonalInfo: validated.hasPersonalInfo,
|
|
54
56
|
personalInfoFields: validated.personalInfoFields,
|
|
55
57
|
}, complianceConfig, policyDocuments);
|
|
56
|
-
|
|
58
|
+
const pilotConfig = complianceConfig.pilotPolicyReference;
|
|
59
|
+
const pilotPolicy = pilotConfig ? embedPilotPolicyReference(pilotConfig) : null;
|
|
60
|
+
const enrichedReport = {
|
|
61
|
+
...report,
|
|
62
|
+
pilotPolicyReference: pilotPolicy,
|
|
63
|
+
};
|
|
64
|
+
return JSON.stringify(enrichedReport, null, 2);
|
|
57
65
|
}
|
|
58
66
|
catch (e) {
|
|
59
67
|
const err = e;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function embedPilotPolicyReference(config) {
|
|
2
|
+
if (!config.enabled) {
|
|
3
|
+
return { embedded: false, message: '', policyRef: config.policyRef, keyPoints: [] };
|
|
4
|
+
}
|
|
5
|
+
return {
|
|
6
|
+
embedded: true,
|
|
7
|
+
message: config.embedMessage,
|
|
8
|
+
policyRef: config.policyRef,
|
|
9
|
+
keyPoints: config.keyPoints,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=pilotPolicyReferenceEmbedder.js.map
|
package/package.json
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liuhange/dsh-data-asset-compliance-check",
|
|
3
3
|
"description": "Data asset compliance check plugin: source + processing + usage three-dimensional compliance audit",
|
|
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-compliance-check"
|
|
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
|
}
|