weaver-work-cli 0.1.48 → 0.1.50
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/dist/chunks/{archive-oa-EDJDU3V4.js → archive-oa-57R2FYHV.js} +111 -12
- package/dist/chunks/{attachment-content-4KSNBPRO.js → attachment-content-EJYIOJPH.js} +3 -3
- package/dist/chunks/{chunk-FEP6ELMR.js → chunk-3NCFFHB2.js} +1 -1
- package/dist/chunks/chunk-5QYE52LG.js +223 -0
- package/dist/chunks/{chunk-3YV7PKRL.js → chunk-6QYNE6HE.js} +12 -212
- package/dist/chunks/{chunk-NBEWUR7L.js → chunk-6T53BSWZ.js} +158 -44
- package/dist/chunks/{chunk-OCYRVZGN.js → chunk-7AYQJSFY.js} +2 -2
- package/dist/chunks/{chunk-5B5JXTY2.js → chunk-7ECB22G3.js} +221 -30
- package/dist/chunks/{chunk-72MI3MBX.js → chunk-ATEXBEPD.js} +55 -15
- package/dist/chunks/{chunk-WMSAWAWZ.js → chunk-BFKLQLBK.js} +8 -8
- package/dist/chunks/{chunk-EFOUMXIX.js → chunk-HARQF5IP.js} +28 -28
- package/dist/chunks/{chunk-O6CMPO65.js → chunk-IW7A2IQY.js} +16 -146
- package/dist/chunks/chunk-JEQHNNSS.js +158 -0
- package/dist/chunks/{chunk-NK74RE5F.js → chunk-K67FODVC.js} +3 -3
- package/dist/chunks/{chunk-YLCYX7LE.js → chunk-KMRT7NAT.js} +18 -5
- package/dist/chunks/{chunk-BCACE6VV.js → chunk-MCZG6HPM.js} +3 -3
- package/dist/chunks/{chunk-SVFG6EMV.js → chunk-RYFRGTUV.js} +5 -5
- package/dist/chunks/{chunk-PSPOFLSU.js → chunk-WNJUGI2F.js} +1 -1
- package/dist/chunks/{chunk-R2HHLJNN.js → chunk-YB3AJYPY.js} +4 -4
- package/dist/chunks/{conflict-APGSD5E7.js → conflict-C4UDHCWV.js} +2 -2
- package/dist/chunks/{contract-N6P2HIIE.js → contract-VUC6JOPG.js} +464 -9
- package/dist/chunks/{create-flow-5TXFOC7X.js → create-flow-6OG2LYBD.js} +6 -6
- package/dist/chunks/data-QO7QWOIV.js +2525 -0
- package/dist/chunks/{employee-NOHNXC46.js → employee-DR5Y64TI.js} +2 -1
- package/dist/chunks/{env-B6GKA2J3.js → env-WP57TF2S.js} +2 -2
- package/dist/chunks/{factory-MFCKLUT6.js → factory-VUXI7N5C.js} +1 -1
- package/dist/chunks/{fna-ZVB2IILI.js → fna-ECOYBQYL.js} +328 -5
- package/dist/chunks/{group-chat-YE7WIBFO.js → group-chat-UQRGXILK.js} +3 -3
- package/dist/chunks/{hrm-UNKCCCGP.js → hrm-YGIR3HGF.js} +4 -2
- package/dist/chunks/{im-3RCNL5GT.js → im-TN2JYVGJ.js} +2 -2
- package/dist/chunks/{invoice-FXWH5GPO.js → invoice-E7GOITEU.js} +1 -1
- package/dist/chunks/{meeting-RYZV2JTQ.js → meeting-4BBLVAWM.js} +10 -10
- package/dist/chunks/{msg-parse-4GSQ2WTO.js → msg-parse-FPFVPMYI.js} +5 -1
- package/dist/chunks/org-NFE7X7FK.js +12 -0
- package/dist/chunks/{reception-VL6TKVAW.js → reception-QGPNTGHG.js} +526 -175
- package/dist/chunks/{recruit-stage-ERZD3ZNB.js → recruit-stage-FKWS5UQF.js} +66 -13
- package/dist/chunks/{registry-VWXWPVAG.js → registry-3UGIWH53.js} +4 -2
- package/dist/chunks/{registry-22O6UG4I.js → registry-5CRCN2TV.js} +10 -10
- package/dist/chunks/{registry-BUTEDK3C.js → registry-E5RQJVWN.js} +2 -2
- package/dist/chunks/{registry-7VZ6YJUF.js → registry-V4CHRQDI.js} +1 -1
- package/dist/chunks/{room-recommend-IMZPJMYB.js → room-recommend-AYR3UG7R.js} +4 -4
- package/dist/chunks/{schedule-SPPAHER2.js → schedule-JZEFIXUS.js} +4 -4
- package/dist/chunks/{workflow-WVEFJ6KC.js → workflow-3ZAF2J5E.js} +4 -4
- package/dist/index.js +16 -11
- package/dist/shortcuts/archive-oa/operations/contract-modules.js +57 -0
- package/dist/shortcuts/archive-oa/operations/contract.js +23 -8
- package/dist/shortcuts/archive-oa/operations/registry.js +4 -1
- package/dist/shortcuts/archive-oa/operations/shared.js +41 -5
- package/dist/shortcuts/contract/host.js +11 -0
- package/dist/shortcuts/contract/index.js +13 -0
- package/dist/shortcuts/contract/manifest.js +53 -0
- package/dist/shortcuts/contract/operations/performance.js +58 -7
- package/dist/shortcuts/contract/operations/quote.js +283 -1
- package/dist/shortcuts/contract/operations/registry.js +2 -0
- package/dist/shortcuts/contract/operations/save-recognize.js +151 -0
- package/dist/shortcuts/data/errors.js +64 -0
- package/dist/shortcuts/data/host.js +140 -0
- package/dist/shortcuts/data/index.js +429 -0
- package/dist/shortcuts/data/manifest.js +133 -0
- package/dist/shortcuts/data/operations/attend.js +62 -0
- package/dist/shortcuts/data/operations/conf.js +384 -0
- package/dist/shortcuts/data/operations/ds.js +686 -0
- package/dist/shortcuts/data/operations/field.js +68 -0
- package/dist/shortcuts/data/operations/index.js +65 -0
- package/dist/shortcuts/data/operations/module.js +383 -0
- package/dist/shortcuts/data/operations/noun.js +102 -0
- package/dist/shortcuts/data/operations/query.js +85 -0
- package/dist/shortcuts/data/operations/scene.js +235 -0
- package/dist/shortcuts/data/operations/shared.js +279 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +12 -5
- package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +21 -13
- package/dist/shortcuts/ehr/recruit-stage/shared.js +57 -0
- package/dist/shortcuts/fna/host.js +4 -2
- package/dist/shortcuts/fna/manifest.js +14 -5
- package/dist/shortcuts/fna/operations/audit.js +334 -0
- package/dist/shortcuts/fna/operations/registry.js +2 -0
- package/dist/shortcuts/im/operations/at-mention.js +6 -3
- package/dist/shortcuts/im/operations/msg-parse.js +35 -5
- package/dist/shortcuts/im/operations/msg-sync.js +3 -1
- package/dist/shortcuts/im/operations/msg-write.js +57 -9
- package/dist/shortcuts/index.js +5 -0
- package/dist/shortcuts/invoice/manifest.js +1 -1
- package/dist/shortcuts/meeting/operations/eb/member-expand.js +200 -0
- package/dist/shortcuts/meeting/operations/from-group-chat.js +16 -2
- package/dist/shortcuts/meeting/operations/registry.js +2 -0
- package/dist/shortcuts/reception/constants.js +13 -6
- package/dist/shortcuts/reception/index.js +3 -1
- package/dist/shortcuts/reception/manifest.js +3 -2
- package/dist/shortcuts/reception/operations/ask.js +20 -2
- package/dist/shortcuts/reception/operations/compose.js +11 -0
- package/dist/shortcuts/reception/operations/doc.js +59 -0
- package/dist/shortcuts/reception/operations/docrender.js +25 -1
- package/dist/shortcuts/reception/operations/leads.js +31 -7
- package/dist/shortcuts/reception/operations/panels.js +86 -22
- package/dist/shortcuts/reception/operations/render.js +40 -0
- package/dist/shortcuts/reception/operations/restaurant.js +17 -4
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +12 -5
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +21 -13
- package/dist/shortcuts/recruit-stage/shared.js +57 -0
- package/dist/shortcuts/workflow/operations/read.js +58 -14
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +140 -24
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +42 -14
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +4 -6
- package/docs/SKILL.md +2 -1
- package/docs/_catalog.md +4 -1
- package/docs/data.md +149 -0
- package/docs/fna.md +11 -4
- package/docs/reception.md +59 -5
- package/package.json +1 -1
- package/scripts/check-skill-sync.mjs +188 -0
- package/scripts/package-skill.mjs +17 -3
- package/skill-template/business-info.json +29 -1
- package/skill-template/domains/data.md +15 -0
- package/skill-template/domains/qiyecheng.md +4 -2
- package/skills/weaver-e10-archive-oa/SKILL.md +7 -6
- package/skills/weaver-e10-archive-oa/references/contract-search.md +83 -14
- package/skills/weaver-e10-archive-oa/references/disabled-capabilities.md +1 -1
- package/skills/weaver-e10-archive-oa/references/qys-contract-search.md +35 -11
- package/skills/weaver-e10-data/SKILL.md +118 -0
- package/skills/weaver-e10-data/references/config-center.md +90 -0
- package/skills/weaver-e10-data/references/datasource.md +136 -0
- package/skills/weaver-e10-data/references/scene-and-misc.md +82 -0
- package/skills/weaver-e10-jinchengda/SKILL.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +5 -5
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +44 -2
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +219 -0
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +50 -30
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +24 -15
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +96 -2
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +43 -0
- package/skills/weaver-e10-jinchengda/scripts/fill_plan.py +997 -0
- package/skills/weaver-e10-jinchengda/scripts/render_ebdf_list_card.py +265 -0
- package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +83 -0
- package/skills/weaver-e10-jinchengda/scripts/verify_docx_placeholders.py +118 -0
- package/skills/weaver-e10-meeting/SKILL.md +39 -7
- package/skills/weaver-e10-qiyecheng/SKILL.md +21 -7
- package/skills/weaver-e10-qiyecheng/references/ai-check-audit.md +104 -0
- package/skills/weaver-e10-qiyecheng/references/catalog.md +17 -3
- package/skills/weaver-e10-qiyecheng/references/source-manifest.json +136 -30
- package/skills/weaver-e10-reception-flow/SKILL.md +70 -19
- package/skills/weaver-e10-reception-flow/references/guide.md +5 -4
- package/skills/weaver-e10-reception-flow/scripts/render.py +5 -3
- package/skills/weaver-e10-recruit-stage/SKILL.md +1 -1
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +26 -6
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +3 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +6 -4
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +3 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +53 -11
- package/skills/weaver-e10-workflow/SKILL.md +2 -1
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +29 -6
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +162 -10
- package/skills/weaver-e10-yepiaotong/SKILL.md +10 -5
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +19 -32
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +6 -45
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +5 -5
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +4 -37
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +2 -2
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +4 -4
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +22 -35
- package/skills/weaver-e10-yimiaoban/SKILL.md +8 -6
- package/skills/weaver-e10-yimiaoban/references/msg-read.md +20 -0
- package/skills/weaver-e10-yimiaoban/references/msg-write.md +7 -0
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +18 -15
- package/dist/chunks/{ebuilder-form-I5ZIX4WO.js → ebuilder-form-CBYI6CQ6.js} +4 -4
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { operationDefinitions } from './operations/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* data 模块的对外契约。
|
|
4
|
+
*
|
|
5
|
+
* 命名分工沿用仓库约定:顶层命令用**业务域**(`data`),skill 目录用品牌(`weaver-e10-data`)。
|
|
6
|
+
* 命令树顺序固定 `schema` → `run <operation>` → 各业务便捷子命令。
|
|
7
|
+
*/
|
|
8
|
+
const INPUT_SCHEMAS = {
|
|
9
|
+
'data.dsl.query': {
|
|
10
|
+
required: ['conn', 'model', 'schema', 'dsl'],
|
|
11
|
+
optional: ['table_id', 'debug', 'dimension', 'conf_group', 'username', 'start_date'],
|
|
12
|
+
},
|
|
13
|
+
'data.ds.groups': { required: [], optional: ['pattern'] },
|
|
14
|
+
'data.ds.find': {
|
|
15
|
+
required: ['name'],
|
|
16
|
+
optional: ['source_type', 'size', 'pages', 'concurrency', 'groups', 'all_groups', 'max_groups', 'app_id', 'limit', 'loose', 'no_escalate'],
|
|
17
|
+
},
|
|
18
|
+
'data.ds.describe': { required: ['group', 'table'], optional: ['source_type', 'app_id', 'skill', 'require'] },
|
|
19
|
+
'data.ds.tables': { required: ['group'], optional: ['name', 'page', 'size', 'source_type', 'app_id'] },
|
|
20
|
+
'data.ds.fields': { required: ['group', 'table'], optional: ['source_type', 'app_id'] },
|
|
21
|
+
'data.ds.fields-dsl': { required: ['group', 'table'], optional: ['source_type', 'app_id'] },
|
|
22
|
+
'data.ds.list': {
|
|
23
|
+
required: ['group', 'table', 'fields'],
|
|
24
|
+
optional: ['where', 'order', 'page', 'size', 'source_type', 'app_id'],
|
|
25
|
+
},
|
|
26
|
+
'data.ds.chart': {
|
|
27
|
+
required: ['group', 'table', 'group_by', 'stat'],
|
|
28
|
+
optional: ['where', 'page', 'size', 'source_type', 'app_id'],
|
|
29
|
+
},
|
|
30
|
+
'data.ds.stat': { required: ['group', 'table', 'stat'], optional: ['where', 'source_type', 'app_id'] },
|
|
31
|
+
'data.ds.count': { required: ['group', 'table'], optional: ['where', 'source_type', 'app_id'] },
|
|
32
|
+
'data.noun.list': { required: ['skill'], optional: ['source_type', 'source_group', 'source_table'] },
|
|
33
|
+
'data.noun.scope': { required: ['ids'], optional: [] },
|
|
34
|
+
'data.field.name2id': { required: ['module', 'type', 'name'], optional: ['form_param', 'eb_browser_param', 'property_type'] },
|
|
35
|
+
'data.field.options': { required: ['field_name', 'obj_id', 'group'], optional: ['source_type'] },
|
|
36
|
+
'data.conf.get': { required: ['key'], optional: ['type', 'group'] },
|
|
37
|
+
'data.conf.batch': { required: ['keys'], optional: ['type', 'group'] },
|
|
38
|
+
'data.conf.batch-file': { required: ['batch_file'], optional: [] },
|
|
39
|
+
'data.conf.group': { required: ['conf_type', 'conf_group'], optional: ['key'] },
|
|
40
|
+
'data.conf.group-file': { required: ['group_file'], optional: [] },
|
|
41
|
+
'data.conf.resolve': { required: ['text'], optional: ['group'] },
|
|
42
|
+
'data.conf.resolve-file': { required: ['path'], optional: ['group'] },
|
|
43
|
+
'data.conf.add': { required: ['key', 'value'], optional: ['name', 'attrs', 'type', 'group', 'force'] },
|
|
44
|
+
'data.conf.add-file': { required: ['add_file'], optional: ['type', 'group'] },
|
|
45
|
+
'data.conf.update': { required: ['key'], optional: ['value', 'name', 'attrs', 'type', 'group'] },
|
|
46
|
+
'data.conf.delete': { required: ['key'], optional: ['type', 'group'] },
|
|
47
|
+
'data.scene.groups': { required: [], optional: ['client'] },
|
|
48
|
+
'data.scene.items': { required: ['group'], optional: ['client'] },
|
|
49
|
+
'data.scene.search': {
|
|
50
|
+
required: ['keywords'],
|
|
51
|
+
optional: ['client', 'max_groups', 'max_items', 'scope_group_id', 'server_filter'],
|
|
52
|
+
},
|
|
53
|
+
'data.module.call': {
|
|
54
|
+
required: [],
|
|
55
|
+
optional: [
|
|
56
|
+
'conf_key', 'group', 'type', 'conf_file', 'args', 'query', 'header', 'headers',
|
|
57
|
+
'method', 'limit', 'fields', 'raw', 'show_params', 'full', 'with_example', 'no_example',
|
|
58
|
+
'dry_run', 'timeout',
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
'data.attend.statis': { required: [], optional: ['user', 'begin', 'end'] },
|
|
62
|
+
};
|
|
63
|
+
function inputSchemaOf(name) {
|
|
64
|
+
const spec = INPUT_SCHEMAS[name] || { required: [], optional: [] };
|
|
65
|
+
const properties = {};
|
|
66
|
+
for (const key of [...spec.required, ...spec.optional]) {
|
|
67
|
+
properties[key] = { type: key === 'keys' || key === 'ids' ? 'array' : 'string' };
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties,
|
|
72
|
+
required: spec.required,
|
|
73
|
+
additionalProperties: false,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export const dataOperations = operationDefinitions().map((definition) => ({
|
|
77
|
+
name: definition.name,
|
|
78
|
+
resource: definition.capability,
|
|
79
|
+
summary: definition.summary,
|
|
80
|
+
command: definition.command,
|
|
81
|
+
inputSchema: inputSchemaOf(definition.name),
|
|
82
|
+
}));
|
|
83
|
+
export const dataManifest = {
|
|
84
|
+
schemaVersion: 1,
|
|
85
|
+
name: 'data',
|
|
86
|
+
title: '泛微E10数据助手(数据源查询 / 配置中心 / 场景定位)',
|
|
87
|
+
version: '0.1.0',
|
|
88
|
+
host: 'e10-data',
|
|
89
|
+
status: 'builtin',
|
|
90
|
+
sourceSkill: 'weaver-e10-data',
|
|
91
|
+
capabilities: ['dsl', 'discovery', 'metadata', 'fetch', 'lexicon', 'field', 'config', 'scene', 'module', 'attend'],
|
|
92
|
+
auth: {
|
|
93
|
+
required: 'e10-session',
|
|
94
|
+
note: '所有操作都要求已登录 E10;登录统一走 `weaver-work-cli auth login --base-url <域名>`,data 模块不提供任何登录入口。',
|
|
95
|
+
},
|
|
96
|
+
rules: [
|
|
97
|
+
'便捷命令(`data ds count` …)与统一入口(`data run data.ds.count`)共用同一份实现;参数名逐字保留,老调用无需改动。',
|
|
98
|
+
'`data --json` 输出**与旧 CLI 逐字一致的原始响应体**(技能里的 jq 路径不变);`data run` 输出 `{schemaVersion, ok, operation, data, warnings}` 信封。',
|
|
99
|
+
'流程类问题一律走 WORKFLOW 模块接口,不用 DSL、也不走数据源;`ds find` 的 routeHint 已给出通道建议。',
|
|
100
|
+
'`ds.find` 的 `/ds/listByPage` 端点当前忽略 name ⇒ 未命中只代表未落在抓取窗口内,不等于表不存在。',
|
|
101
|
+
'`module call` 的 `token` 头在运行时属保留头,必须走 trustedHeaders(INVOICE 已内置换取逻辑)。',
|
|
102
|
+
'人员 / 部门 / 岗位一律走 `weaver-work-cli hrm`;data 通道对 /api/hrm/ 路径有黑名单(退出码 6)。',
|
|
103
|
+
'`hasSearchRight=false` 是权限受限(终端态):结果照常给出但退出码 4,不得交付为「无数据」。',
|
|
104
|
+
'`field name2id`(名称→字段值 id)与 `ds fields`(字段元数据)是两件事;`id2name` 已停用并在本次迁移中删除。',
|
|
105
|
+
],
|
|
106
|
+
operations: dataOperations,
|
|
107
|
+
withheldOperations: [
|
|
108
|
+
{
|
|
109
|
+
name: 'data.doc.count',
|
|
110
|
+
reason: '文档数量由配置中心 DOCUMENT.POST_DOCUMENT_DOCUMENT_LIST_COUNT 覆盖(conf group api DOCUMENT → module call),不在 data 模块重复封装。',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'data.doc.list',
|
|
114
|
+
reason: '同上:DOCUMENT.POST_DOCUMENT_DOCUMENT_LIST。注意 documentList 的 data.total 实测恒为 0,总量必须取 count 接口。',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'data.field.id2name',
|
|
118
|
+
reason: '已停用:技能里 19 处均为禁令;该实现打的是 /api/bcw/test/testRemoteBrowser 探针接口。选项值显示映射改走 field options。',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'data.refusal.get',
|
|
122
|
+
reason: '拒答话术属智能问数宿主平台职责;场景技能明确「不做拒答 / 话术判定」,迁入只会扩出一个被禁止调用的入口。',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'data.refusal.rules',
|
|
126
|
+
reason: '同上:getRefusalSpeechRules 由平台在加载完成 / 取数前 / 交付前自行拉取并替换话术。',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'data.exp.*',
|
|
130
|
+
reason: '专家包远端版本管理属 `weaver-work-cli skills repo …` 资源域,不进 data。',
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { dataValidationError } from '../errors.js';
|
|
2
|
+
import { scanTips, tipsLines } from './shared.js';
|
|
3
|
+
/**
|
|
4
|
+
* 考勤假期余额:`POST /api/attend/web/attendInfoV2/getAttendInfoStatis`。
|
|
5
|
+
*
|
|
6
|
+
* 这是配置中心 `EHR.POST_EHR_GET_ATTEND_INFO_STATIS` 的专用封装(同一端点)。
|
|
7
|
+
* 技能把它定位为「年假 / 带薪病假 / 带薪事假」的**首选调用**,并明确「勿再走 conf group api 翻接口」;
|
|
8
|
+
* 其余假种(婚假 / 产假 / 育儿假 …)走 `POST_EHR_GET_REPORT_LIST`,与本命令互不替代。
|
|
9
|
+
*
|
|
10
|
+
* 返回 `data.vacationBalanceList[]`:`{ id, title, data:[{name, value, key}] }`,
|
|
11
|
+
* key ∈ lastRemaining(历年可请) / remaining(今年可请) / total(总计可请)。
|
|
12
|
+
* ⚠️ 条目数因假种而异(实测年假仅 1 条 `key=total`,带薪病假/带薪事假各 3 条)⇒ 按 key 取值,勿按下标。
|
|
13
|
+
*/
|
|
14
|
+
function defaultMonthRange() {
|
|
15
|
+
const now = new Date();
|
|
16
|
+
const year = now.getFullYear();
|
|
17
|
+
const month = now.getMonth() + 1;
|
|
18
|
+
const lastDay = new Date(year, month, 0).getDate();
|
|
19
|
+
const pad = (value) => String(value).padStart(2, '0');
|
|
20
|
+
return { begin: `${year}-${pad(month)}-01`, end: `${year}-${pad(month)}-${pad(lastDay)}` };
|
|
21
|
+
}
|
|
22
|
+
export async function attendStatis(input, host) {
|
|
23
|
+
const session = await host.session();
|
|
24
|
+
const userId = String(input.user || session.userId || '');
|
|
25
|
+
if (!userId) {
|
|
26
|
+
throw dataValidationError('missing_argument', '缺少查询人员:--user <人员ID>(查本人可不传,默认当前登录用户)');
|
|
27
|
+
}
|
|
28
|
+
const range = defaultMonthRange();
|
|
29
|
+
const body = {
|
|
30
|
+
beginDate: String(input.begin || range.begin),
|
|
31
|
+
endDate: String(input.end || range.end),
|
|
32
|
+
userId,
|
|
33
|
+
};
|
|
34
|
+
const response = await host.request({
|
|
35
|
+
method: 'POST',
|
|
36
|
+
path: '/api/attend/web/attendInfoV2/getAttendInfoStatis',
|
|
37
|
+
body,
|
|
38
|
+
operation: 'attend.statis',
|
|
39
|
+
});
|
|
40
|
+
if (String(response?.code) !== '200') {
|
|
41
|
+
const message = String(response?.msg || '');
|
|
42
|
+
if (/没有权限|无权限|权限不足|未授权|无权访问|无查询权限/i.test(message)) {
|
|
43
|
+
throw dataValidationError('permission_denied', '当前用户对该人员考勤数据无查询权限,请检查登录态或联系管理员开通', 4);
|
|
44
|
+
}
|
|
45
|
+
return { data: response, text: `code=${response?.code} msg=${message}` };
|
|
46
|
+
}
|
|
47
|
+
const data = response?.data || {};
|
|
48
|
+
const list = Array.isArray(data.vacationBalanceList) ? data.vacationBalanceList : [];
|
|
49
|
+
const lines = tipsLines(scanTips(response));
|
|
50
|
+
if (!list.length) {
|
|
51
|
+
lines.push(`(空:该人员无假期余额数据) userId=${userId} ${body.beginDate}~${body.endDate}`);
|
|
52
|
+
return { data: response, text: lines.join('\n') };
|
|
53
|
+
}
|
|
54
|
+
lines.push(`== 考勤假期余额 userId=${userId}(${body.beginDate} ~ ${body.endDate})==`);
|
|
55
|
+
for (const item of list) {
|
|
56
|
+
lines.push(`${item.title || item.id || '?'}${item.id ? ` [${item.id}]` : ''}`);
|
|
57
|
+
if (Array.isArray(item.data) && item.data.length) {
|
|
58
|
+
lines.push(` ${item.data.map((cell) => `${cell.name || cell.key}=${cell.value ?? ''}`).join(' ')}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return { data: response, text: lines.join('\n') };
|
|
62
|
+
}
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { dataApiError, dataValidationError } from '../errors.js';
|
|
3
|
+
import { parseJsonSafe, readJsonArg, renderTable } from './shared.js';
|
|
4
|
+
/**
|
|
5
|
+
* 环境参数配置中心(chatBi config map)。
|
|
6
|
+
*
|
|
7
|
+
* confType 默认由 confKey 前缀推导(CONN_→conn / DS_→ds / WF_→wf / API_→api),
|
|
8
|
+
* 可用 `--type` 显式指定任意大类(如 ebu / pmo / contract / partner 这类域级分组)。
|
|
9
|
+
* confGroup 仅在 confType=api 或调用方显式指定时下发,避免污染没有分组列的配置类型。
|
|
10
|
+
*/
|
|
11
|
+
const CONF_PREFIX_TYPE = [['CONN_', 'conn'], ['DS_', 'ds'], ['WF_', 'wf'], ['API_', 'api']];
|
|
12
|
+
const CONF_GET_PATH = '/api/dw/newetl/chatBi/getChatBiConfigMap';
|
|
13
|
+
const CONF_BATCH_PATH = '/api/dw/newetl/chatBi/batchGetChatBiConfigMap';
|
|
14
|
+
const CONF_BATCH_GROUP_PATH = '/api/dw/newetl/chatBi/batchGetChatBiConfigMapByTypeAndGroup';
|
|
15
|
+
const CONF_ADD_PATH = '/api/dw/newetl/chatBi/batchAddChatBiConfigMap';
|
|
16
|
+
const CONF_UPDATE_PATH = '/api/dw/newetl/chatBi/updateChatBiConfigMap';
|
|
17
|
+
const CONF_DELETE_PATH = '/api/dw/newetl/chatBi/deleteChatBiConfigMap';
|
|
18
|
+
/** 文本里的 `#{KEY}` 占位符(至少 3 字符、下划线大写,排除 `#{}` 与短键)。 */
|
|
19
|
+
const CONF_TOKEN_RE = /#\{([A-Z][A-Z0-9_]{2,})\}/g;
|
|
20
|
+
function confKeyType(key, explicitType) {
|
|
21
|
+
if (typeof explicitType === 'string' && explicitType)
|
|
22
|
+
return explicitType;
|
|
23
|
+
for (const [prefix, type] of CONF_PREFIX_TYPE) {
|
|
24
|
+
if (key.startsWith(prefix))
|
|
25
|
+
return type;
|
|
26
|
+
}
|
|
27
|
+
throw dataValidationError('conf_type_unknown', `无法由 confKey 推导 confType(需 CONN_/DS_/WF_/API_ 前缀或显式 --type): ${key}`);
|
|
28
|
+
}
|
|
29
|
+
function useGroup(confType, group) {
|
|
30
|
+
return confType === 'api' || (group !== undefined && group !== null && group !== '');
|
|
31
|
+
}
|
|
32
|
+
function putGroup(body, confType, group) {
|
|
33
|
+
if (useGroup(confType, group))
|
|
34
|
+
body.confGroup = group === undefined || group === null ? '' : String(group);
|
|
35
|
+
return body;
|
|
36
|
+
}
|
|
37
|
+
function groupSuffix(confType, group) {
|
|
38
|
+
return useGroup(confType, group)
|
|
39
|
+
? `&confGroup=${encodeURIComponent(group === undefined || group === null ? '' : String(group))}`
|
|
40
|
+
: '';
|
|
41
|
+
}
|
|
42
|
+
/** 同 confKey 可分布在多个 confGroup ⇒ 带分组时用「组|键」做映射键,避免互相覆盖。 */
|
|
43
|
+
function itemId(item) {
|
|
44
|
+
const group = item?.confGroup;
|
|
45
|
+
return group ? `${group}|${item?.confKey || ''}` : (item?.confKey || '');
|
|
46
|
+
}
|
|
47
|
+
function lookup(map, item) {
|
|
48
|
+
return map[itemId(item)] || map[item.confKey];
|
|
49
|
+
}
|
|
50
|
+
function normalizeBatch(payload) {
|
|
51
|
+
const data = payload?.data ?? null;
|
|
52
|
+
const out = {};
|
|
53
|
+
const put = (row, fallbackKey) => {
|
|
54
|
+
if (!row || typeof row !== 'object')
|
|
55
|
+
return;
|
|
56
|
+
const key = row.confKey || row.conf_key || fallbackKey;
|
|
57
|
+
if (!key)
|
|
58
|
+
return;
|
|
59
|
+
if (row.confGroup === undefined && row.conf_group !== undefined && row.conf_group !== null && row.conf_group !== '') {
|
|
60
|
+
row.confGroup = row.conf_group;
|
|
61
|
+
}
|
|
62
|
+
out[itemId({ confGroup: row.confGroup, confKey: key })] = row;
|
|
63
|
+
};
|
|
64
|
+
if (Array.isArray(data))
|
|
65
|
+
for (const row of data)
|
|
66
|
+
put(row);
|
|
67
|
+
else if (data && typeof data === 'object')
|
|
68
|
+
for (const [key, value] of Object.entries(data))
|
|
69
|
+
put(value, key);
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
async function confGetData(host, confType, key, silent, group) {
|
|
73
|
+
let response;
|
|
74
|
+
try {
|
|
75
|
+
response = await host.request({
|
|
76
|
+
method: 'GET',
|
|
77
|
+
path: `${CONF_GET_PATH}?confType=${encodeURIComponent(confType)}&confKey=${encodeURIComponent(key)}${groupSuffix(confType, group)}`,
|
|
78
|
+
operation: 'conf.get',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (silent)
|
|
83
|
+
return null;
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
const data = response?.data ?? null;
|
|
87
|
+
if (!silent && (!data || data.confValue === undefined || data.confValue === null || data.confValue === '')) {
|
|
88
|
+
throw dataApiError('conf_missing', `配置不存在或为空: confType=${confType}${group ? ` confGroup=${group}` : ''} confKey=${key}`, {
|
|
89
|
+
details: { confType, confGroup: group, confKey: key },
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return data;
|
|
93
|
+
}
|
|
94
|
+
async function batchByTypeAndGroup(host, pairs) {
|
|
95
|
+
const payload = pairs.map((pair) => ({
|
|
96
|
+
confType: pair.confType,
|
|
97
|
+
confGroup: pair.confGroup === undefined || pair.confGroup === null ? '' : String(pair.confGroup),
|
|
98
|
+
}));
|
|
99
|
+
const response = await host.request({ method: 'POST', path: CONF_BATCH_GROUP_PATH, body: payload, operation: 'conf.group' });
|
|
100
|
+
return normalizeBatch(response);
|
|
101
|
+
}
|
|
102
|
+
function positionals(input, key) {
|
|
103
|
+
const value = input[key];
|
|
104
|
+
return Array.isArray(value) ? value.map((item) => String(item)) : [];
|
|
105
|
+
}
|
|
106
|
+
export async function confGet(input, host) {
|
|
107
|
+
const keys = positionals(input, 'keys');
|
|
108
|
+
const key = keys[0] || (typeof input.key === 'string' ? input.key : '');
|
|
109
|
+
if (!key)
|
|
110
|
+
throw dataValidationError('missing_argument', 'conf get 缺少 confKey(用法: conf get <key> [--type t] [--group g])');
|
|
111
|
+
const confType = confKeyType(key, input.type);
|
|
112
|
+
let data;
|
|
113
|
+
try {
|
|
114
|
+
data = await confGetData(host, confType, key, false, input.group);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
if (confType === 'api' && !input.group) {
|
|
118
|
+
throw dataApiError('conf_missing', `${error.message}(confType=api 建议用 --group 指定分组,如 --group workflow;或用 conf group api <分组> 查看该分组下全部配置)`);
|
|
119
|
+
}
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
return { data, text: JSON.stringify(data, null, 1) };
|
|
123
|
+
}
|
|
124
|
+
export async function confBatch(input, host) {
|
|
125
|
+
const keys = positionals(input, 'keys');
|
|
126
|
+
if (!keys.length) {
|
|
127
|
+
throw dataValidationError('missing_argument', 'conf batch 缺少 confKey 列表(用法: conf batch <key1> [key2 ...] [--type t] [--group g])');
|
|
128
|
+
}
|
|
129
|
+
const items = keys.map((key) => {
|
|
130
|
+
const confType = confKeyType(key, input.type);
|
|
131
|
+
return putGroup({ confType, confKey: key }, confType, input.group);
|
|
132
|
+
});
|
|
133
|
+
let map = {};
|
|
134
|
+
try {
|
|
135
|
+
const response = await host.request({ method: 'POST', path: CONF_BATCH_PATH, body: items, operation: 'conf.batch' });
|
|
136
|
+
map = normalizeBatch(response);
|
|
137
|
+
for (const item of items) {
|
|
138
|
+
const current = lookup(map, item);
|
|
139
|
+
if (!current || current.confValue === undefined || current.confValue === null || current.confValue === '') {
|
|
140
|
+
throw dataApiError('conf_batch_missing', `批量响应缺失 confKey=${item.confKey}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
if (String(error.message).startsWith('批量响应缺失'))
|
|
146
|
+
throw error;
|
|
147
|
+
process.stderr.write(`[config-resolve] 批量接口不可用,降级逐条单查: ${error.message}\n`);
|
|
148
|
+
map = {};
|
|
149
|
+
for (const item of items) {
|
|
150
|
+
map[itemId(item)] = await confGetData(host, item.confType, item.confKey, false, item.confGroup);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const rows = keys.map((key) => {
|
|
154
|
+
const item = items.find((candidate) => candidate.confKey === key);
|
|
155
|
+
const current = lookup(map, item) || {};
|
|
156
|
+
return { key, confType: item.confType, confGroup: item.confGroup ?? '', confValue: current.confValue ?? '', confName: current.confName ?? '' };
|
|
157
|
+
});
|
|
158
|
+
return { data: map, text: renderTable(`配置 ${items.length} 条`, rows, ['key', 'confType', 'confGroup', 'confValue', 'confName']) };
|
|
159
|
+
}
|
|
160
|
+
export async function confBatchFile(input, host) {
|
|
161
|
+
const raw = input.batch_file ?? input.file ?? positionals(input, 'keys')[0];
|
|
162
|
+
if (raw === undefined) {
|
|
163
|
+
throw dataValidationError('missing_argument', 'conf batch-file 缺少参数(用法: conf batch-file @items.json)');
|
|
164
|
+
}
|
|
165
|
+
const parsed = readJsonArg(String(raw), '--batch-file');
|
|
166
|
+
const list = Array.isArray(parsed) ? parsed : [parsed];
|
|
167
|
+
const map = {};
|
|
168
|
+
const meta = {};
|
|
169
|
+
for (const item of list) {
|
|
170
|
+
if (!item.confKey || !item.confType)
|
|
171
|
+
continue;
|
|
172
|
+
const id = itemId(item);
|
|
173
|
+
map[id] = await confGetData(host, item.confType, item.confKey, false, item.confGroup);
|
|
174
|
+
meta[id] = item;
|
|
175
|
+
}
|
|
176
|
+
const rows = Object.keys(map).map((id) => ({
|
|
177
|
+
key: meta[id].confKey,
|
|
178
|
+
confGroup: meta[id].confGroup ?? '',
|
|
179
|
+
confValue: (map[id] || {}).confValue ?? '',
|
|
180
|
+
confName: (map[id] || {}).confName ?? '',
|
|
181
|
+
}));
|
|
182
|
+
return { data: map, text: renderTable(`配置 ${Object.keys(map).length} 条`, rows, ['key', 'confGroup', 'confValue', 'confName']) };
|
|
183
|
+
}
|
|
184
|
+
export async function confGroup(input, host) {
|
|
185
|
+
const keys = positionals(input, 'keys');
|
|
186
|
+
const confType = keys[0] || input.type;
|
|
187
|
+
const group = keys[1] !== undefined ? keys[1] : input.group;
|
|
188
|
+
if (!confType)
|
|
189
|
+
throw dataValidationError('missing_argument', 'conf group 缺少 confType(用法: conf group <confType> <confGroup>)');
|
|
190
|
+
if (group === undefined)
|
|
191
|
+
throw dataValidationError('missing_argument', 'conf group 缺少 confGroup(用法: conf group <confType> <confGroup>)');
|
|
192
|
+
const map = await batchByTypeAndGroup(host, [{ confType, confGroup: group }]);
|
|
193
|
+
const rows = Object.values(map);
|
|
194
|
+
const onlyKey = input.key;
|
|
195
|
+
const filtered = onlyKey ? rows.filter((row) => (row.confKey || row.conf_key) === onlyKey) : rows;
|
|
196
|
+
if (onlyKey && !filtered.length) {
|
|
197
|
+
throw dataApiError('conf_missing', `配置不存在: confType=${confType} confGroup=${group} confKey=${onlyKey}`);
|
|
198
|
+
}
|
|
199
|
+
const rendered = filtered.map((row) => ({
|
|
200
|
+
confKey: row.confKey || row.conf_key || '',
|
|
201
|
+
confValue: row.confValue ?? '',
|
|
202
|
+
confName: row.confName ?? '',
|
|
203
|
+
confAttrs: row.confAttrs ?? '',
|
|
204
|
+
}));
|
|
205
|
+
return {
|
|
206
|
+
data: onlyKey ? (filtered[0] ?? null) : filtered,
|
|
207
|
+
text: renderTable(`confType=${confType} confGroup=${group} 配置 ${filtered.length} 条`, rendered, ['confKey', 'confValue', 'confName', 'confAttrs']),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
export async function confGroupFile(input, host) {
|
|
211
|
+
const raw = input.group_file ?? positionals(input, 'keys')[0];
|
|
212
|
+
if (raw === undefined) {
|
|
213
|
+
throw dataValidationError('missing_argument', 'conf group-file 缺少参数(用法: conf group-file @items.json)');
|
|
214
|
+
}
|
|
215
|
+
const parsed = readJsonArg(String(raw), '--group-file');
|
|
216
|
+
const list = (Array.isArray(parsed) ? parsed : [parsed]).filter((item) => item && item.confType);
|
|
217
|
+
if (!list.length)
|
|
218
|
+
throw dataValidationError('conf_group_file_empty', 'conf group-file 内容为空或缺少 confType');
|
|
219
|
+
const map = await batchByTypeAndGroup(host, list);
|
|
220
|
+
const rows = Object.values(map).map((row) => ({
|
|
221
|
+
confType: row.confType ?? '',
|
|
222
|
+
confGroup: row.confGroup ?? '',
|
|
223
|
+
confKey: row.confKey || row.conf_key || '',
|
|
224
|
+
confValue: row.confValue ?? '',
|
|
225
|
+
confName: row.confName ?? '',
|
|
226
|
+
}));
|
|
227
|
+
return { data: map, text: renderTable(`批量分组配置 ${rows.length} 条`, rows, ['confType', 'confGroup', 'confKey', 'confValue', 'confName']) };
|
|
228
|
+
}
|
|
229
|
+
async function resolveAll(host, keys, group) {
|
|
230
|
+
const items = keys.map((key) => {
|
|
231
|
+
const confType = confKeyType(key, '');
|
|
232
|
+
return putGroup({ confType, confKey: key }, confType, group);
|
|
233
|
+
});
|
|
234
|
+
const map = {};
|
|
235
|
+
try {
|
|
236
|
+
const response = await host.request({ method: 'POST', path: CONF_BATCH_PATH, body: items, operation: 'conf.resolve' });
|
|
237
|
+
const got = normalizeBatch(response);
|
|
238
|
+
for (const item of items) {
|
|
239
|
+
const current = lookup(got, item);
|
|
240
|
+
if (!current || current.confValue === undefined || current.confValue === null || current.confValue === '') {
|
|
241
|
+
throw dataApiError('conf_batch_missing', `缺失 ${item.confKey}`);
|
|
242
|
+
}
|
|
243
|
+
map[item.confKey] = current;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
for (const item of items)
|
|
248
|
+
map[item.confKey] = await confGetData(host, item.confType, item.confKey, false, item.confGroup);
|
|
249
|
+
}
|
|
250
|
+
return map;
|
|
251
|
+
}
|
|
252
|
+
async function resolveText(host, text, group) {
|
|
253
|
+
const found = [...new Set([...text.matchAll(CONF_TOKEN_RE)].map((match) => match[1]))];
|
|
254
|
+
const map = found.length ? await resolveAll(host, found, group) : {};
|
|
255
|
+
const output = text.replace(CONF_TOKEN_RE, (whole, key) => {
|
|
256
|
+
const config = map[key];
|
|
257
|
+
if (!config)
|
|
258
|
+
throw dataApiError('conf_missing', `配置不存在或为空: ${key}`, { code: key });
|
|
259
|
+
return config.confValue ?? '';
|
|
260
|
+
});
|
|
261
|
+
return {
|
|
262
|
+
input: text,
|
|
263
|
+
output,
|
|
264
|
+
resolved: Object.fromEntries(Object.entries(map).map(([key, value]) => [key, value.confValue ?? ''])),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
export async function confResolve(input, host) {
|
|
268
|
+
let text = input.text ?? positionals(input, 'keys')[0];
|
|
269
|
+
if (!text)
|
|
270
|
+
throw dataValidationError('missing_argument', "conf resolve 缺少文本(用法: conf resolve '<含#{KEY}文本>' | @file.txt [--group g])");
|
|
271
|
+
text = String(text);
|
|
272
|
+
if (text.startsWith('@'))
|
|
273
|
+
text = readFileSync(text.slice(1), 'utf-8');
|
|
274
|
+
const result = await resolveText(host, text, input.group);
|
|
275
|
+
return { data: result, text: result.output };
|
|
276
|
+
}
|
|
277
|
+
export async function confResolveFile(input, host) {
|
|
278
|
+
const path = input.resolve_file ?? positionals(input, 'keys')[0];
|
|
279
|
+
if (!path)
|
|
280
|
+
throw dataValidationError('missing_argument', 'conf resolve-file 缺少文件路径');
|
|
281
|
+
const text = readFileSync(String(path), 'utf-8');
|
|
282
|
+
const result = await resolveText(host, text, input.group);
|
|
283
|
+
return { data: result, text: result.output };
|
|
284
|
+
}
|
|
285
|
+
export async function confAdd(input, host) {
|
|
286
|
+
const key = positionals(input, 'keys')[0] || (typeof input.key === 'string' ? input.key : '');
|
|
287
|
+
if (!key || input.value === undefined) {
|
|
288
|
+
throw dataValidationError('missing_argument', 'conf add 缺少 confKey/confValue(用法: conf add <key> --value <真实值>)');
|
|
289
|
+
}
|
|
290
|
+
const confType = confKeyType(key, input.type);
|
|
291
|
+
if (!input.force && await confGetData(host, confType, key, true, input.group)) {
|
|
292
|
+
process.stderr.write(`[config-resolve] 配置已存在,跳过新增(如需修改请用 conf update): ${key}\n`);
|
|
293
|
+
return { data: null, text: `已存在,跳过: ${key}` };
|
|
294
|
+
}
|
|
295
|
+
const item = putGroup({
|
|
296
|
+
confType,
|
|
297
|
+
confKey: key,
|
|
298
|
+
confValue: String(input.value),
|
|
299
|
+
confAttrs: input.attrs || '',
|
|
300
|
+
confName: input.name || '',
|
|
301
|
+
}, confType, input.group);
|
|
302
|
+
const response = await host.request({ method: 'POST', path: CONF_ADD_PATH, body: [item], operation: 'conf.add' });
|
|
303
|
+
return {
|
|
304
|
+
data: response,
|
|
305
|
+
text: `新增成功: ${item.confGroup ? `${item.confGroup}/` : ''}${key} = ${item.confValue}`,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
export async function confAddFile(input, host) {
|
|
309
|
+
const raw = input.add_file ?? positionals(input, 'keys')[0];
|
|
310
|
+
if (raw === undefined)
|
|
311
|
+
throw dataValidationError('missing_argument', 'conf add-file 缺少参数(用法: conf add-file @items.json)');
|
|
312
|
+
const parsed = readJsonArg(String(raw), '--add-file');
|
|
313
|
+
const list = Array.isArray(parsed) ? parsed : [parsed];
|
|
314
|
+
const toAdd = [];
|
|
315
|
+
for (const item of list) {
|
|
316
|
+
if (!item.confKey || item.confValue === undefined)
|
|
317
|
+
continue;
|
|
318
|
+
const confType = item.confType || confKeyType(item.confKey, input.type);
|
|
319
|
+
const group = item.confGroup !== undefined ? item.confGroup : input.group;
|
|
320
|
+
if (await confGetData(host, confType, item.confKey, true, group)) {
|
|
321
|
+
process.stderr.write(`[config-resolve] 已存在跳过: ${item.confKey}\n`);
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
toAdd.push(putGroup({
|
|
325
|
+
confType,
|
|
326
|
+
confKey: item.confKey,
|
|
327
|
+
confValue: String(item.confValue),
|
|
328
|
+
confAttrs: item.confAttrs || '',
|
|
329
|
+
confName: item.confName || '',
|
|
330
|
+
}, confType, group));
|
|
331
|
+
}
|
|
332
|
+
if (!toAdd.length)
|
|
333
|
+
return { data: null, text: '全部已存在,无新增' };
|
|
334
|
+
const response = await host.request({ method: 'POST', path: CONF_ADD_PATH, body: toAdd, operation: 'conf.add-file' });
|
|
335
|
+
return { data: response, text: `批量新增 ${toAdd.length} 条成功` };
|
|
336
|
+
}
|
|
337
|
+
export async function confUpdate(input, host) {
|
|
338
|
+
const key = positionals(input, 'keys')[0] || (typeof input.key === 'string' ? input.key : '');
|
|
339
|
+
if (!key)
|
|
340
|
+
throw dataValidationError('missing_argument', 'conf update 缺少 confKey');
|
|
341
|
+
if (input.value === undefined && input.name === undefined && input.attrs === undefined) {
|
|
342
|
+
throw dataValidationError('nothing_to_update', 'conf update 至少需提供 --value / --name / --attrs 之一');
|
|
343
|
+
}
|
|
344
|
+
const confType = confKeyType(key, input.type);
|
|
345
|
+
const body = putGroup({ confType, confKey: key }, confType, input.group);
|
|
346
|
+
if (input.value !== undefined)
|
|
347
|
+
body.confValue = String(input.value);
|
|
348
|
+
if (input.name !== undefined)
|
|
349
|
+
body.confName = input.name;
|
|
350
|
+
if (input.attrs !== undefined)
|
|
351
|
+
body.confAttrs = input.attrs;
|
|
352
|
+
const response = await host.request({ method: 'POST', path: CONF_UPDATE_PATH, body, operation: 'conf.update' });
|
|
353
|
+
return { data: response, text: `更新成功: ${body.confGroup ? `${body.confGroup}/` : ''}${key}` };
|
|
354
|
+
}
|
|
355
|
+
export async function confDelete(input, host) {
|
|
356
|
+
const key = positionals(input, 'keys')[0] || (typeof input.key === 'string' ? input.key : '');
|
|
357
|
+
if (!key)
|
|
358
|
+
throw dataValidationError('missing_argument', 'conf delete 缺少 confKey');
|
|
359
|
+
const confType = confKeyType(key, input.type);
|
|
360
|
+
const response = await host.request({
|
|
361
|
+
method: 'DELETE',
|
|
362
|
+
path: `${CONF_DELETE_PATH}?confType=${encodeURIComponent(confType)}&confKey=${encodeURIComponent(key)}${groupSuffix(confType, input.group)}`,
|
|
363
|
+
operation: 'conf.delete',
|
|
364
|
+
});
|
|
365
|
+
return {
|
|
366
|
+
data: response,
|
|
367
|
+
text: `删除成功: ${useGroup(confType, input.group) && input.group ? `${input.group}/` : ''}${key}`,
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
export { confGetData, confKeyType, normalizeBatch, CONF_BATCH_PATH };
|
|
371
|
+
/** `confAttrs` 可能是字符串或对象——统一成对象,供 module call 使用。 */
|
|
372
|
+
export function attributesOf(record) {
|
|
373
|
+
const attrs = record?.confAttrs;
|
|
374
|
+
if (!attrs)
|
|
375
|
+
return {};
|
|
376
|
+
if (typeof attrs === 'object')
|
|
377
|
+
return attrs;
|
|
378
|
+
try {
|
|
379
|
+
return parseJsonSafe(String(attrs));
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
throw dataApiError('conf_attrs_invalid', 'confAttrs 二次解析失败(非 JSON 字符串)', { code: 'confAttrs' });
|
|
383
|
+
}
|
|
384
|
+
}
|