@liuhange/dsh-gov-data-inspector 3.1.2 → 3.1.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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -0
  3. package/package.json +20 -10
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 liuhange789
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -36,3 +36,80 @@ apply(ctx); // 注册工具: inspect_gov_data
36
36
  ## License
37
37
 
38
38
  MIT
39
+ ## 无凭据降级模式
40
+
41
+ 当官方数据源(国家/省级)凭据未配置或不可达时,插件自动进入**降级模式**而非中止运行。
42
+
43
+ ### 降级触发条件
44
+
45
+ - 国家和省级数据源均未配置 API Key / Endpoint
46
+ - 国家和省级数据源均不可达(网络超时、HTTP 错误等)
47
+
48
+ ### 降级表现
49
+
50
+ | 检测模式 | 完整模式表现 | 降级模式表现 |
51
+ |---------|------------|------------|
52
+ | classification | 正常分类 | **正常分类**(不依赖知识库) |
53
+ | guide | 语义检测基于官方知识库 | 语义检测降级为本地规则检测 |
54
+ | full | 全量检测 | 分类正常 + 语义/逻辑降级 |
55
+
56
+ ### 降级标记
57
+
58
+ 降级模式下,巡检报告包含以下额外字段:
59
+
60
+ ```json
61
+ {
62
+ "degradedMode": true,
63
+ "degradedReason": "官方数据源全部不可用,已降级为本地规则检测模式"
64
+ }
65
+ ```
66
+
67
+ ### 端点协议宽松化
68
+
69
+ 数据源端点支持以下三种协议:
70
+ - `https://` — HTTPS 远程端点
71
+ - `http://` — HTTP 远程端点(不再强制 HTTPS)
72
+ - 本地文件路径 — 直接读取本地 JSON 文件
73
+
74
+ ## 异常输入处理
75
+
76
+ 插件对以下异常输入场景提供明确的友好错误提示,不会崩溃或产生未捕获异常:
77
+
78
+ | 异常场景 | 错误码 | 错误提示 |
79
+ |---------|--------|---------|
80
+ | 格式错误的 JSON | `GOV_DATA_INPUT_INVALID` | JSON 格式错误,请检查文件内容 |
81
+ | 空数据(空文件/空数组) | `GOV_DATA_INPUT_INVALID` | 无数据,请确认输入文件内容 |
82
+ | 超长数据(超 100 万字段) | `GOV_DATA_SCALE_EXCEEDED` | 数据量超出处理上限 |
83
+ | 无效 URL / 不可达路径 | `GOV_DATA_URL_UNREACHABLE` | 数据源不可达,请检查路径或 URL |
84
+ | 非 UTF-8 编码文件 | `GOV_DATA_ENCODING_ERROR` | 文件编码非 UTF-8 |
85
+ | 部分字段缺失 | 正常处理 | 报告中列出缺失字段清单 |
86
+
87
+ ### itemTypeOverride 参数
88
+
89
+ 当自动匹配无法识别事项类型时,用户可通过 `itemTypeOverride` 参数手动指定:
90
+
91
+ ```javascript
92
+ execute({
93
+ dataSource: './data.json',
94
+ inspectionMode: 'guide',
95
+ itemTypeOverride: '现场勘查类'
96
+ })
97
+ ```
98
+
99
+ ### 未匹配事项类型警告
100
+
101
+ 当事项无法匹配到任何检测规则时,报告中会包含 `UNMATCHED_ITEM_TYPE` 警告:
102
+
103
+ ```json
104
+ {
105
+ "warnings": [
106
+ {
107
+ "type": "UNMATCHED_ITEM_TYPE",
108
+ "guideId": "建设工程规划核实",
109
+ "message": "该事项未匹配到检测规则,语义检测被跳过"
110
+ }
111
+ ]
112
+ }
113
+ ```
114
+
115
+ 匹配逻辑支持四通道:手动指定 → 名称关键词 → 编码前缀 → 流程字段关键词。
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@liuhange/dsh-gov-data-inspector",
3
3
  "description": "Government data inspection plugin: service guide quality check and public data asset classification",
4
- "version": "3.1.2",
4
+ "version": "3.1.3",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -26,11 +26,6 @@
26
26
  "lib/types/**/*.d.ts"
27
27
  ],
28
28
  "license": "MIT",
29
- "scripts": {
30
- "typecheck": "tsc --noEmit",
31
- "test": "vitest run",
32
- "build": "tsc"
33
- },
34
29
  "dependencies": {
35
30
  "@liuhange/dsh-data-asset-shared": "^3.1.0"
36
31
  },
@@ -40,7 +35,7 @@
40
35
  },
41
36
  "dsh": {
42
37
  "bundle": {
43
- "patch": true
38
+ "patch": "./cordis.patch.yml"
44
39
  }
45
40
  },
46
41
  "keywords": [
@@ -56,7 +51,22 @@
56
51
  "gbt-47949",
57
52
  "政务数据",
58
53
  "公共数据",
59
- "办事指南"
54
+ "办事指南",
55
+ "dsh",
56
+ "typescript",
57
+ "nodejs",
58
+ "automation",
59
+ "audit",
60
+ "compliance",
61
+ "data-governance",
62
+ "data-quality",
63
+ "plugin",
64
+ "open-source"
60
65
  ],
61
- "homepage": "https://github.com/liuhange789/data-asset-inspector#readme"
62
- }
66
+ "homepage": "https://github.com/liuhange789/data-asset-inspector#readme",
67
+ "scripts": {
68
+ "typecheck": "tsc --noEmit",
69
+ "test": "vitest run",
70
+ "build": "tsc"
71
+ }
72
+ }