@liuhange/dsh-match-registration-agency 3.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,23 @@
1
+ # @liuhange/dsh-match-registration-agency
2
+
3
+ 登记机构匹配插件:根据数据类型推荐登记机构。
4
+
5
+ ## 功能说明
6
+
7
+ 全国仅3家登记机构:
8
+ - 金融/征信/支付 → 上海数据交易所(金融数据交易活跃度最高)
9
+ - 医疗/健康/生物 → 北京国际大数据交易所(医疗数据登记案例集中)
10
+ - 交通/物流/地理 → 深圳数据交易所(交通数据登记案例较多)
11
+ - 其他 → 建议咨询专业机构
12
+
13
+ ## 依赖
14
+
15
+ - `@liuhange/dsh-data-asset-shared: ^3.0.0`
16
+ - `@deepseek-ai/cordis: ^4.0.0`
17
+ - `@deepseek-ai/dsh-tools: 0.0.1-rc.1`
18
+
19
+ ## 安装
20
+
21
+ ```bash
22
+ npm install @liuhange/dsh-match-registration-agency
23
+ ```
@@ -0,0 +1,33 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { AgencyMatcher } from '../agencyMatcher.js';
3
+ describe('AgencyMatcher', () => {
4
+ const matcher = new AgencyMatcher();
5
+ it('金融 → 上海数据交易所', () => {
6
+ const result = matcher.match('金融');
7
+ expect(result.agency).toBe('shanghai');
8
+ expect(result.agencyName).toBe('上海数据交易所');
9
+ });
10
+ it('医疗 → 北京国际大数据交易所', () => {
11
+ const result = matcher.match('医疗');
12
+ expect(result.agency).toBe('beijing');
13
+ expect(result.agencyName).toBe('北京国际大数据交易所');
14
+ });
15
+ it('交通 → 深圳数据交易所', () => {
16
+ const result = matcher.match('交通');
17
+ expect(result.agency).toBe('shenzhen');
18
+ expect(result.agencyName).toBe('深圳数据交易所');
19
+ });
20
+ it('未知类型 → 建议咨询', () => {
21
+ const result = matcher.match('未知类型');
22
+ expect(result.agency).toBeNull();
23
+ expect(result.agencyName).toContain('建议咨询');
24
+ });
25
+ it('匹配结果含 agency/basis/dataType/ruleVersion 四字段', () => {
26
+ const result = matcher.match('金融');
27
+ expect(result).toHaveProperty('agency');
28
+ expect(result).toHaveProperty('basis');
29
+ expect(result).toHaveProperty('dataType');
30
+ expect(result).toHaveProperty('ruleVersion');
31
+ });
32
+ });
33
+ //# sourceMappingURL=agencyMatcher.test.js.map
@@ -0,0 +1,48 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { defaultRegistrationConfig } from '@liuhange/dsh-data-asset-shared';
4
+ export class AgencyMatcher {
5
+ config;
6
+ configPath;
7
+ constructor(configPath) {
8
+ this.configPath = configPath
9
+ ? path.resolve(configPath)
10
+ : path.resolve(process.cwd(), 'config', 'registration-agencies.json');
11
+ this.config = this.loadConfig();
12
+ }
13
+ loadConfig() {
14
+ try {
15
+ if (fs.existsSync(this.configPath)) {
16
+ const raw = fs.readFileSync(this.configPath, 'utf-8');
17
+ return JSON.parse(raw);
18
+ }
19
+ }
20
+ catch {
21
+ console.warn('[AgencyMatcher] 配置加载失败,使用默认值');
22
+ }
23
+ return defaultRegistrationConfig;
24
+ }
25
+ match(dataType) {
26
+ const agencyId = this.config.dataTypeMapping[dataType];
27
+ if (agencyId) {
28
+ const agency = this.config.agencies.find(a => a.id === agencyId);
29
+ if (agency) {
30
+ return {
31
+ agency: agency.id,
32
+ agencyName: agency.name,
33
+ basis: agency.basis,
34
+ dataType,
35
+ ruleVersion: this.config.ruleVersion,
36
+ };
37
+ }
38
+ }
39
+ return {
40
+ agency: null,
41
+ agencyName: this.config.defaultRecommendation.message,
42
+ basis: this.config.defaultRecommendation.basis,
43
+ dataType,
44
+ ruleVersion: this.config.ruleVersion,
45
+ };
46
+ }
47
+ }
48
+ //# sourceMappingURL=agencyMatcher.js.map
package/lib/index.js ADDED
@@ -0,0 +1,29 @@
1
+ import { defineTool } from '@deepseek-ai/dsh-tools';
2
+ import { AgencyMatcher } from './agencyMatcher.js';
3
+ export const name = 'match-registration-agency';
4
+ export const inject = ['tools'];
5
+ export function apply(ctx) {
6
+ const matcher = new AgencyMatcher();
7
+ ctx.tools.register(defineTool({
8
+ name: 'match_registration_agency',
9
+ description: '根据数据类型匹配推荐登记机构(北京/上海/深圳数据交易所)',
10
+ parameters: {
11
+ dataType: {
12
+ type: 'string',
13
+ required: true,
14
+ description: '数据类型(如:金融/医疗/交通等)',
15
+ },
16
+ },
17
+ output: {
18
+ schema: { type: 'string' },
19
+ render: (_args, value) => [{ type: 'text', text: value }],
20
+ },
21
+ async execute(args) {
22
+ const dataType = args.dataType;
23
+ const result = matcher.match(dataType);
24
+ return JSON.stringify(result, null, 2);
25
+ },
26
+ }));
27
+ console.log('[match-registration-agency] 登记机构匹配插件已加载');
28
+ }
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=agencyMatcher.test.d.ts.map
@@ -0,0 +1,9 @@
1
+ import type { AgencyMatchResult } from '@liuhange/dsh-data-asset-shared';
2
+ export declare class AgencyMatcher {
3
+ private config;
4
+ private configPath;
5
+ constructor(configPath?: string);
6
+ private loadConfig;
7
+ match(dataType: string): AgencyMatchResult;
8
+ }
9
+ //# sourceMappingURL=agencyMatcher.d.ts.map
@@ -0,0 +1,5 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ export declare const name = "match-registration-agency";
3
+ export declare const inject: string[];
4
+ export declare function apply(ctx: Context): void;
5
+ //# sourceMappingURL=index.d.ts.map
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@liuhange/dsh-match-registration-agency",
3
+ "description": "Match registration agency: recommend data exchange based on data type",
4
+ "version": "3.0.0",
5
+ "publishConfig": { "access": "public" },
6
+ "repository": { "type": "git", "url": "git+https://github.com/liuhange789/data-asset-inspector.git", "directory": "packages/data-asset/match-registration-agency" },
7
+ "type": "module",
8
+ "main": "lib/index.js",
9
+ "types": "lib/types/index.d.ts",
10
+ "exports": {
11
+ ".": { "types": "./lib/types/index.d.ts", "default": "./lib/index.js" },
12
+ "./src/*": "./src/*",
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": ["lib/**/*.js", "lib/types/**/*.d.ts"],
16
+ "license": "MIT",
17
+ "scripts": {
18
+ "typecheck": "tsc --noEmit",
19
+ "test": "vitest run",
20
+ "build": "tsc"
21
+ },
22
+ "peerDependencies": {
23
+ "@deepseek-ai/cordis": "^4.0.0",
24
+ "@deepseek-ai/dsh-tools": "0.0.1-rc.1",
25
+ "@liuhange/dsh-data-asset-shared": "^3.0.0"
26
+ },
27
+ "dsh": { "bundle": { "patch": true } }
28
+ }