@liuhange/dsh-data-asset-shared 1.0.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 ADDED
@@ -0,0 +1,25 @@
1
+ # @deepseek-ai/dsh-data-asset-shared
2
+
3
+ Shared infrastructure for data assetization plugins.
4
+
5
+ ## Modules
6
+
7
+ - **BusinessRulesLoader**: Loads `config/business-rules.json` with 5-level config degradation (CONFIG_LOADED / DEFAULT_MISSING / DEFAULT_PARSE / DEFAULT_VERSION / DEFAULT_PARTIAL)
8
+ - **FileFormatAdapter**: Reads/writes CSV, JSON, TXT, XLSX formats with unknown-format degradation to TXT
9
+ - **ReportGenerator**: Generates masking, cleaning, inventory, and packaging reports per spec 6.3-6.6
10
+ - **PathValidator**: Validates file paths against working directory, prevents path traversal attacks
11
+ - **AuditLogger**: Logs processing operations with `[pluginName] message` format
12
+
13
+ ## Usage
14
+
15
+ ```typescript
16
+ import { BusinessRulesLoader, FileFormatAdapter, ReportGenerator, PathValidator, AuditLogger } from '@deepseek-ai/dsh-data-asset-shared'
17
+
18
+ const loader = new BusinessRulesLoader()
19
+ const { config, status } = loader.load()
20
+ ```
21
+
22
+ ## Known Limitations and Deferred Work
23
+
24
+ - XLSX format support is limited to text-based line reading; full binary XLSX parsing requires the `xlsx` library
25
+ - Large file streaming (>10MB) is detected but not yet implemented with stream APIs
package/lib/index.js ADDED
@@ -0,0 +1,415 @@
1
+ import * as fs from "fs";
2
+ import * as path from "path";
3
+ //#region lib/types/defaultBusinessRules.js
4
+ const defaultBusinessRules = {
5
+ version: "1.0",
6
+ lastUpdated: "2026-08-17",
7
+ valueAssessment: {
8
+ highValue: {
9
+ keywords: [
10
+ "供应链",
11
+ "销售明细",
12
+ "设备工况",
13
+ "交易流水"
14
+ ],
15
+ score: 5,
16
+ label: "★★★★★",
17
+ recommendation: "优先交易,建议入表"
18
+ },
19
+ mediumValue: {
20
+ keywords: [
21
+ "用户行为",
22
+ "产品数据",
23
+ "行业报告"
24
+ ],
25
+ score: 3,
26
+ label: "★★★",
27
+ recommendation: "脱敏后交易"
28
+ },
29
+ lowValue: {
30
+ keywords: [
31
+ "日志",
32
+ "备份",
33
+ "临时"
34
+ ],
35
+ score: 1,
36
+ label: "★",
37
+ recommendation: "评估处理成本"
38
+ },
39
+ defaultValue: {
40
+ score: 3,
41
+ label: "★★★",
42
+ recommendation: "需进一步评估"
43
+ }
44
+ },
45
+ sensitivePatterns: {
46
+ idCard: {
47
+ pattern: "[1-9]\\d{5}(18|19|20)?\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[\\dXx]",
48
+ level: "FULL"
49
+ },
50
+ phone: {
51
+ pattern: "1[3-9]\\d{9}",
52
+ level: "PARTIAL"
53
+ },
54
+ bankCard: {
55
+ pattern: "[1-9]\\d{15,18}",
56
+ level: "PARTIAL"
57
+ },
58
+ email: {
59
+ pattern: "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}",
60
+ level: "PARTIAL"
61
+ }
62
+ },
63
+ maskingLevels: {
64
+ FULL: {
65
+ description: "完全匿名化",
66
+ applyTo: ["idCard"]
67
+ },
68
+ PARTIAL: {
69
+ description: "假名化,保留前3后4",
70
+ applyTo: ["phone", "bankCard"]
71
+ },
72
+ GENERALIZE: {
73
+ description: "泛化处理",
74
+ applyTo: ["email"]
75
+ }
76
+ },
77
+ cleaningRules: {
78
+ missingValueStrategy: {
79
+ government: "interpolation",
80
+ financial: "manual_review",
81
+ behavior: "mode_fill"
82
+ },
83
+ qualityThreshold: {
84
+ A: {
85
+ missingRate: .05,
86
+ errorRate: .01,
87
+ label: "优秀"
88
+ },
89
+ B: {
90
+ missingRate: .1,
91
+ errorRate: .03,
92
+ label: "良好"
93
+ },
94
+ C: {
95
+ missingRate: .2,
96
+ errorRate: .05,
97
+ label: "合格"
98
+ },
99
+ D: {
100
+ missingRate: .2,
101
+ errorRate: .05,
102
+ label: "不合格",
103
+ action: "不建议交易"
104
+ }
105
+ }
106
+ },
107
+ compliance: { policies: [
108
+ {
109
+ name: "数据产权登记工作指引",
110
+ doc: "国数综政策〔2026〕35号",
111
+ check: "数据来源可登记"
112
+ },
113
+ {
114
+ name: "数据流通安全治理",
115
+ doc: "发改数据〔2025〕18号",
116
+ check: "来源合法性"
117
+ },
118
+ {
119
+ name: "数据脱敏工具标准",
120
+ doc: "YD/T 6225-2024",
121
+ check: "脱敏效果达标"
122
+ }
123
+ ] },
124
+ packaging: {
125
+ complianceStatements: [
126
+ "本数据产品已完成脱敏处理",
127
+ "不包含个人身份信息",
128
+ "数据来源合法",
129
+ "建议交易前完成数据产权登记"
130
+ ],
131
+ pricingRules: [
132
+ {
133
+ valueLevel: "★★★★★",
134
+ suggestion: "根据数据质量、稀缺性和应用场景综合定价,建议高价交易"
135
+ },
136
+ {
137
+ valueLevel: "★★★★",
138
+ suggestion: "根据数据质量和应用场景定价,建议中高价交易"
139
+ },
140
+ {
141
+ valueLevel: "★★★",
142
+ suggestion: "根据数据质量和应用场景综合定价"
143
+ },
144
+ {
145
+ valueLevel: "★★",
146
+ suggestion: "建议低价交易或内部使用"
147
+ },
148
+ {
149
+ valueLevel: "★",
150
+ suggestion: "建议评估处理成本后决定是否交易"
151
+ }
152
+ ],
153
+ defaultDescription: "适用于数据分析、模型训练、行业研究等场景",
154
+ version: "V1.0"
155
+ }
156
+ };
157
+ //#endregion
158
+ //#region lib/types/businessRulesLoader.js
159
+ var BusinessRulesLoader = class {
160
+ cachedResult = null;
161
+ configPath;
162
+ constructor(configPath) {
163
+ this.configPath = configPath ? path.resolve(configPath) : path.resolve(process.cwd(), "config", "business-rules.json");
164
+ }
165
+ load() {
166
+ if (this.cachedResult) return this.cachedResult;
167
+ const result = this.loadInternal();
168
+ this.cachedResult = result;
169
+ return result;
170
+ }
171
+ loadInternal() {
172
+ if (!fs.existsSync(this.configPath)) return this.createDefaultResult("DEFAULT_MISSING");
173
+ let raw;
174
+ try {
175
+ raw = fs.readFileSync(this.configPath, "utf-8");
176
+ } catch {
177
+ return this.createDefaultResult("DEFAULT_PARSE");
178
+ }
179
+ let parsed;
180
+ try {
181
+ parsed = JSON.parse(raw);
182
+ } catch {
183
+ return this.createDefaultResult("DEFAULT_PARSE");
184
+ }
185
+ if (!this.isBusinessRulesConfig(parsed)) return this.createDefaultResult("DEFAULT_PARSE");
186
+ if (!this.isVersionCompatible(parsed.version)) return this.createDefaultResult("DEFAULT_VERSION");
187
+ if (!this.hasRequiredNodes(parsed)) return this.createDefaultResult("DEFAULT_PARTIAL");
188
+ return {
189
+ config: parsed,
190
+ status: "CONFIG_LOADED"
191
+ };
192
+ }
193
+ createDefaultResult(status) {
194
+ return {
195
+ config: defaultBusinessRules,
196
+ status
197
+ };
198
+ }
199
+ isBusinessRulesConfig(value) {
200
+ return typeof value === "object" && value !== null && "version" in value && "valueAssessment" in value && "sensitivePatterns" in value && "cleaningRules" in value && "compliance" in value && "packaging" in value;
201
+ }
202
+ isVersionCompatible(version) {
203
+ if (typeof version !== "string") return false;
204
+ return version.startsWith("1.");
205
+ }
206
+ hasRequiredNodes(config) {
207
+ return config.valueAssessment !== void 0 && config.sensitivePatterns !== void 0 && config.maskingLevels !== void 0 && config.cleaningRules !== void 0 && config.compliance !== void 0 && config.packaging !== void 0;
208
+ }
209
+ clearCache() {
210
+ this.cachedResult = null;
211
+ }
212
+ };
213
+ //#endregion
214
+ //#region lib/types/fileFormatAdapter.js
215
+ var FileFormatAdapter = class {
216
+ detectFormat(filePath) {
217
+ const ext = path.extname(filePath).toLowerCase().slice(1);
218
+ if (ext === "csv" || ext === "json" || ext === "txt" || ext === "xlsx") return ext;
219
+ return "unknown";
220
+ }
221
+ async read(filePath) {
222
+ const format = this.detectFormat(filePath);
223
+ const fullPath = path.resolve(filePath);
224
+ if (!fs.existsSync(fullPath)) throw new Error(`错误:文件不存在 - ${fullPath}`);
225
+ const isLargeFile = fs.statSync(fullPath).size >= 10 * 1024 * 1024;
226
+ switch (format) {
227
+ case "csv": return this.readCsv(fullPath);
228
+ case "json": return this.readJson(fullPath);
229
+ case "xlsx": return this.readXlsx(fullPath);
230
+ default: return this.readTxt(fullPath, format, isLargeFile);
231
+ }
232
+ }
233
+ async write(filePath, lines, format) {
234
+ const fullPath = path.resolve(filePath);
235
+ const dir = path.dirname(fullPath);
236
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
237
+ switch (format) {
238
+ case "csv":
239
+ this.writeCsv(fullPath, lines);
240
+ break;
241
+ case "json":
242
+ this.writeJson(fullPath, lines);
243
+ break;
244
+ case "xlsx":
245
+ this.writeXlsx(fullPath, lines);
246
+ break;
247
+ default:
248
+ fs.writeFileSync(fullPath, lines.join("\n"), "utf-8");
249
+ break;
250
+ }
251
+ }
252
+ readTxt(filePath, format, _isLargeFile) {
253
+ const content = fs.readFileSync(filePath, "utf-8");
254
+ return {
255
+ lines: content.split("\n").filter((line) => line.trim()),
256
+ format,
257
+ raw: content
258
+ };
259
+ }
260
+ readCsv(filePath) {
261
+ const content = fs.readFileSync(filePath, "utf-8");
262
+ return {
263
+ lines: content.split("\n").filter((line) => line.trim()),
264
+ format: "csv",
265
+ raw: content
266
+ };
267
+ }
268
+ readJson(filePath) {
269
+ const content = fs.readFileSync(filePath, "utf-8");
270
+ const parsed = JSON.parse(content);
271
+ if (Array.isArray(parsed)) return {
272
+ lines: parsed.map((item) => JSON.stringify(item)),
273
+ format: "json",
274
+ raw: parsed
275
+ };
276
+ return {
277
+ lines: [JSON.stringify(parsed)],
278
+ format: "json",
279
+ raw: parsed
280
+ };
281
+ }
282
+ readXlsx(filePath) {
283
+ const content = fs.readFileSync(filePath, "utf-8");
284
+ return {
285
+ lines: content.split("\n").filter((line) => line.trim()),
286
+ format: "xlsx",
287
+ raw: content
288
+ };
289
+ }
290
+ writeCsv(filePath, lines) {
291
+ fs.writeFileSync(filePath, lines.join("\n"), "utf-8");
292
+ }
293
+ writeJson(filePath, lines) {
294
+ const objects = lines.map((line) => {
295
+ try {
296
+ return JSON.parse(line);
297
+ } catch {
298
+ return line;
299
+ }
300
+ });
301
+ fs.writeFileSync(filePath, JSON.stringify(objects, null, 2), "utf-8");
302
+ }
303
+ writeXlsx(filePath, lines) {
304
+ fs.writeFileSync(filePath, lines.join("\n"), "utf-8");
305
+ }
306
+ };
307
+ //#endregion
308
+ //#region lib/types/reportGenerator.js
309
+ var ReportGenerator = class {
310
+ generateMaskingReport(params) {
311
+ const findingsText = Object.keys(params.fieldTypeCounts).length > 0 ? Object.entries(params.fieldTypeCounts).map(([type, count]) => `发现 ${count} 个${type}类型的敏感数据`).join(";") : "无";
312
+ return `【脱敏报告】
313
+ - 处理文件:${params.inputPath}
314
+ - 发现敏感字段:${findingsText}
315
+ - 脱敏策略:${params.strategy}
316
+ - 输出文件:${params.outputPath}
317
+ - 状态:✅ 完成`;
318
+ }
319
+ generateCleaningReport(params) {
320
+ let report = `【数据清洗报告】
321
+ - 文件:${params.inputPath}
322
+ - 原始行数:${params.originalLineCount}
323
+ - 去重后行数:${params.originalLineCount - params.duplicateRemoved}(删除 ${params.duplicateRemoved} 行重复)
324
+ `;
325
+ if (params.standardizeApplied) report += `- 格式标准化:✅ 完成\n`;
326
+ report += `- 异常值检测:发现 ${params.anomalyTotalCount} 个异常\n`;
327
+ if (params.anomalies.length > 0) {
328
+ const anomalyText = params.anomalies.slice(0, 5).map((a) => `行${a.line}: ${a.reason}`).join(";");
329
+ report += ` 异常详情:${anomalyText}`;
330
+ if (params.anomalyTotalCount > 5) report += `...等${params.anomalyTotalCount}项`;
331
+ report += `\n`;
332
+ }
333
+ report += `- 输出文件:${params.outputPath}\n- 状态:✅ 完成`;
334
+ return report;
335
+ }
336
+ generateInventoryReport(params) {
337
+ let report = `【数据资产盘点报告】\n- 目录:${params.directory}\n- 发现数据文件:${params.fileCount} 个\n\n`;
338
+ report += `| 文件名 | 大小 | 类型 | 价值评估 | 说明 |\n`;
339
+ report += `|--------|------|------|----------|------|\n`;
340
+ for (const item of params.assetItems) report += `| ${item.fileName} | ${item.size} | ${item.type} | ${item.valueAssessment} | ${item.description} |\n`;
341
+ report += `\n---\n【建议】\n`;
342
+ report += `1. 高价值数据(★★★★★)建议优先进行清洗和脱敏后交易\n`;
343
+ report += `2. 低价值数据建议评估是否值得投入处理成本\n`;
344
+ report += `3. 所有数据交易前必须完成合规审查\n`;
345
+ return report;
346
+ }
347
+ generatePackagingManual(params) {
348
+ const manual = params.productManual;
349
+ const complianceText = manual.complianceStatements.map((stmt) => `✅ ${stmt}`).join("\n");
350
+ return `========================================
351
+ 数据产品说明书
352
+ ========================================
353
+
354
+ 【产品名称】${manual.productName}
355
+ 【版本】${manual.version}
356
+ 【生成日期】${manual.generatedDate}
357
+
358
+ 【数据概览】
359
+ - 源文件:${manual.dataOverview.sourceFile}
360
+ - 数据量:${manual.dataOverview.recordCount} 条记录
361
+ - 文件大小:${manual.dataOverview.fileSizeKb.toFixed(1)} KB
362
+ - 格式:${manual.dataOverview.format}
363
+
364
+ 【数据样例】(前5行)
365
+ ${manual.sampleLines.join("\n")}
366
+
367
+ 【使用场景】
368
+ ${manual.usageScenario}
369
+
370
+ 【合规声明】
371
+ ${complianceText}
372
+
373
+ 【定价建议】
374
+ ${manual.pricingSuggestion}
375
+
376
+ --- 本产品由数据资产化工具包自动生成 ---`;
377
+ }
378
+ };
379
+ //#endregion
380
+ //#region lib/types/pathValidator.js
381
+ var PathValidator = class {
382
+ validate(filePath, workingDir) {
383
+ const resolved = path.resolve(filePath);
384
+ if (filePath.includes("..")) throw new Error(`错误:路径不合法 - ${filePath}`);
385
+ const relative = path.relative(workingDir, resolved);
386
+ if (relative.startsWith("..") || path.isAbsolute(relative)) throw new Error(`错误:路径不合法 - ${filePath}`);
387
+ return resolved;
388
+ }
389
+ validateDirectory(dirPath, workingDir) {
390
+ return this.validate(dirPath, workingDir);
391
+ }
392
+ };
393
+ //#endregion
394
+ //#region lib/types/auditLogger.js
395
+ var AuditLogger = class {
396
+ logDir;
397
+ constructor(logDir) {
398
+ this.logDir = logDir ?? path.resolve(process.cwd(), "logs");
399
+ }
400
+ log(params) {
401
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
402
+ const operator = params.operator ?? "system";
403
+ const logLine = `[${params.pluginName}] ${timestamp} | 操作: ${params.operation} | 操作人: ${operator} | 输入: ${params.inputPath} | 输出: ${params.outputPath} | 结果: ${params.result}`;
404
+ console.log(logLine);
405
+ if (params.writeToFile) this.writeToFile(logLine);
406
+ }
407
+ writeToFile(logLine) {
408
+ if (!fs.existsSync(this.logDir)) fs.mkdirSync(this.logDir, { recursive: true });
409
+ const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
410
+ const logFile = path.join(this.logDir, `audit-${date}.log`);
411
+ fs.appendFileSync(logFile, logLine + "\n", "utf-8");
412
+ }
413
+ };
414
+ //#endregion
415
+ export { AuditLogger, BusinessRulesLoader, FileFormatAdapter, PathValidator, ReportGenerator, defaultBusinessRules };
@@ -0,0 +1,5 @@
1
+ //#region lib/types/invariant.js
2
+ const invariant = "data-asset-shared";
3
+ function install() {}
4
+ //#endregion
5
+ export { install, invariant };
@@ -0,0 +1,16 @@
1
+ export interface AuditLogParams {
2
+ pluginName: string;
3
+ operation: string;
4
+ inputPath: string;
5
+ outputPath: string;
6
+ result: string;
7
+ operator?: string;
8
+ writeToFile?: boolean;
9
+ }
10
+ export declare class AuditLogger {
11
+ private readonly logDir;
12
+ constructor(logDir?: string);
13
+ log(params: AuditLogParams): void;
14
+ private writeToFile;
15
+ }
16
+ //# sourceMappingURL=auditLogger.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { BusinessRulesLoadResult } from './types.js';
2
+ export declare class BusinessRulesLoader {
3
+ private cachedResult;
4
+ private readonly configPath;
5
+ constructor(configPath?: string);
6
+ load(): BusinessRulesLoadResult;
7
+ private loadInternal;
8
+ private createDefaultResult;
9
+ private isBusinessRulesConfig;
10
+ private isVersionCompatible;
11
+ private hasRequiredNodes;
12
+ clearCache(): void;
13
+ }
14
+ //# sourceMappingURL=businessRulesLoader.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { BusinessRulesConfig } from './types.js';
2
+ export declare const defaultBusinessRules: BusinessRulesConfig;
3
+ //# sourceMappingURL=defaultBusinessRules.d.ts.map
@@ -0,0 +1,19 @@
1
+ import type { DataFormat } from './types.js';
2
+ export interface FileReadResult {
3
+ lines: string[];
4
+ format: DataFormat;
5
+ raw: unknown;
6
+ }
7
+ export declare class FileFormatAdapter {
8
+ detectFormat(filePath: string): DataFormat;
9
+ read(filePath: string): Promise<FileReadResult>;
10
+ write(filePath: string, lines: string[], format: DataFormat): Promise<void>;
11
+ private readTxt;
12
+ private readCsv;
13
+ private readJson;
14
+ private readXlsx;
15
+ private writeCsv;
16
+ private writeJson;
17
+ private writeXlsx;
18
+ }
19
+ //# sourceMappingURL=fileFormatAdapter.d.ts.map
@@ -0,0 +1,11 @@
1
+ export * from './types.js';
2
+ export { defaultBusinessRules } from './defaultBusinessRules.js';
3
+ export { BusinessRulesLoader } from './businessRulesLoader.js';
4
+ export { FileFormatAdapter } from './fileFormatAdapter.js';
5
+ export type { FileReadResult } from './fileFormatAdapter.js';
6
+ export { ReportGenerator } from './reportGenerator.js';
7
+ export type { MaskingReportParams, CleaningReportParams, InventoryReportParams, PackagingManualParams, } from './reportGenerator.js';
8
+ export { PathValidator } from './pathValidator.js';
9
+ export { AuditLogger } from './auditLogger.js';
10
+ export type { AuditLogParams } from './auditLogger.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export declare const invariant = "data-asset-shared";
2
+ export declare function install(): void;
3
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1,5 @@
1
+ export declare class PathValidator {
2
+ validate(filePath: string, workingDir: string): string;
3
+ validateDirectory(dirPath: string, workingDir: string): string;
4
+ }
5
+ //# sourceMappingURL=pathValidator.d.ts.map
@@ -0,0 +1,35 @@
1
+ import type { SensitiveField, AssetItem, ProductManual } from './types.js';
2
+ export interface MaskingReportParams {
3
+ inputPath: string;
4
+ outputPath: string;
5
+ strategy: string;
6
+ findings: SensitiveField[];
7
+ fieldTypeCounts: Record<string, number>;
8
+ }
9
+ export interface CleaningReportParams {
10
+ inputPath: string;
11
+ outputPath: string;
12
+ originalLineCount: number;
13
+ duplicateRemoved: number;
14
+ standardizeApplied: boolean;
15
+ anomalies: Array<{
16
+ line: number;
17
+ reason: string;
18
+ }>;
19
+ anomalyTotalCount: number;
20
+ }
21
+ export interface InventoryReportParams {
22
+ directory: string;
23
+ fileCount: number;
24
+ assetItems: AssetItem[];
25
+ }
26
+ export interface PackagingManualParams {
27
+ productManual: ProductManual;
28
+ }
29
+ export declare class ReportGenerator {
30
+ generateMaskingReport(params: MaskingReportParams): string;
31
+ generateCleaningReport(params: CleaningReportParams): string;
32
+ generateInventoryReport(params: InventoryReportParams): string;
33
+ generatePackagingManual(params: PackagingManualParams): string;
34
+ }
35
+ //# sourceMappingURL=reportGenerator.d.ts.map
@@ -0,0 +1,135 @@
1
+ export type SensitiveFieldType = 'idCard' | 'phone' | 'bankCard' | 'email';
2
+ export type MaskingStrategy = 'FULL' | 'PARTIAL' | 'GENERALIZE';
3
+ export type DataFormat = 'csv' | 'json' | 'txt' | 'xlsx' | 'unknown';
4
+ export type ProcessingStatus = 'SUCCESS' | 'FAILED' | 'SKIPPED';
5
+ export type ConfigStatus = 'CONFIG_LOADED' | 'DEFAULT_MISSING' | 'DEFAULT_PARSE' | 'DEFAULT_VERSION' | 'DEFAULT_PARTIAL';
6
+ export interface ValueRule {
7
+ keywords: string[];
8
+ score: number;
9
+ label: string;
10
+ recommendation: string;
11
+ }
12
+ export interface DefaultValueRule {
13
+ score: number;
14
+ label: string;
15
+ recommendation: string;
16
+ }
17
+ export interface ValueAssessmentRules {
18
+ highValue: ValueRule;
19
+ mediumValue: ValueRule;
20
+ lowValue: ValueRule;
21
+ defaultValue: DefaultValueRule;
22
+ }
23
+ export interface SensitivePattern {
24
+ pattern: string;
25
+ level: MaskingStrategy;
26
+ }
27
+ export interface SensitivePatterns {
28
+ idCard: SensitivePattern;
29
+ phone: SensitivePattern;
30
+ bankCard: SensitivePattern;
31
+ email: SensitivePattern;
32
+ }
33
+ export interface MaskingLevelConfig {
34
+ description: string;
35
+ applyTo: SensitiveFieldType[];
36
+ }
37
+ export interface MaskingLevels {
38
+ FULL: MaskingLevelConfig;
39
+ PARTIAL: MaskingLevelConfig;
40
+ GENERALIZE: MaskingLevelConfig;
41
+ }
42
+ export interface CleaningRules {
43
+ missingValueStrategy: Record<string, string>;
44
+ qualityThreshold: Record<string, QualityThreshold>;
45
+ }
46
+ export interface QualityThreshold {
47
+ missingRate: number;
48
+ errorRate: number;
49
+ label: string;
50
+ action?: string;
51
+ }
52
+ export interface CompliancePolicy {
53
+ name: string;
54
+ doc: string;
55
+ check: string;
56
+ }
57
+ export interface ComplianceConfig {
58
+ policies: CompliancePolicy[];
59
+ }
60
+ export interface PricingRule {
61
+ valueLevel: string;
62
+ suggestion: string;
63
+ }
64
+ export interface PackagingRules {
65
+ complianceStatements: string[];
66
+ pricingRules: PricingRule[];
67
+ defaultDescription: string;
68
+ version: string;
69
+ }
70
+ export interface BusinessRulesConfig {
71
+ version: string;
72
+ lastUpdated: string;
73
+ valueAssessment: ValueAssessmentRules;
74
+ sensitivePatterns: SensitivePatterns;
75
+ maskingLevels: MaskingLevels;
76
+ cleaningRules: CleaningRules;
77
+ compliance: ComplianceConfig;
78
+ packaging: PackagingRules;
79
+ }
80
+ export interface SensitiveField {
81
+ type: SensitiveFieldType;
82
+ value: string;
83
+ line: number;
84
+ column: number;
85
+ }
86
+ export interface DataFile {
87
+ fileName: string;
88
+ fullPath: string;
89
+ size: number;
90
+ format: DataFormat;
91
+ }
92
+ export interface ProcessingResult {
93
+ status: ProcessingStatus;
94
+ inputPath: string;
95
+ outputPath: string;
96
+ report: string;
97
+ error?: string;
98
+ }
99
+ export interface AssetItem {
100
+ fileName: string;
101
+ size: string;
102
+ type: string;
103
+ valueAssessment: string;
104
+ description: string;
105
+ }
106
+ export interface DataOverview {
107
+ sourceFile: string;
108
+ recordCount: number;
109
+ fileSizeKb: number;
110
+ format: string;
111
+ }
112
+ export interface ProductManual {
113
+ productName: string;
114
+ version: string;
115
+ generatedDate: string;
116
+ dataOverview: DataOverview;
117
+ sampleLines: string[];
118
+ usageScenario: string;
119
+ complianceStatements: string[];
120
+ pricingSuggestion: string;
121
+ }
122
+ export interface OrchestrationResult {
123
+ maskingReport: string;
124
+ cleaningReport: string;
125
+ inventoryReport: string;
126
+ packagingManual: string;
127
+ completedStages: number;
128
+ failedStage?: string;
129
+ error?: string;
130
+ }
131
+ export interface BusinessRulesLoadResult {
132
+ config: BusinessRulesConfig;
133
+ status: ConfigStatus;
134
+ }
135
+ //# sourceMappingURL=types.d.ts.map
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@liuhange/dsh-data-asset-shared",
3
+ "description": "Shared infrastructure for data assetization plugins: business rules loader, file format adapter, report generator, path validator, audit logger",
4
+ "version": "1.0.0",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
11
+ "directory": "packages/data-asset/data-asset-shared"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/types/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./invariant": {
22
+ "types": "./lib/types/invariant.d.ts",
23
+ "default": "./lib/invariant.js"
24
+ },
25
+ "./src/*": "./src/*",
26
+ "./package.json": "./package.json"
27
+ },
28
+ "files": [
29
+ "lib/index.js",
30
+ "lib/invariant.js",
31
+ "lib/types/**/*.d.ts"
32
+ ],
33
+ "license": "MIT",
34
+ "dependencies": {
35
+ "csv-parse": "^5.5.0"
36
+ },
37
+ "peerDependencies": {
38
+ "@deepseek-ai/cordis": "^0.1.0",
39
+ "@deepseek-ai/dsh-tools": "^0.1.0",
40
+ "@deepseek-ai/schemastery": "^0.1.0"
41
+ }
42
+ }