weaver-work-cli 0.1.47 → 0.1.49
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-BBDP7AKJ.js → archive-oa-57R2FYHV.js} +565 -17
- package/dist/chunks/{attachment-content-MCXQBD6N.js → attachment-content-MU2LPI5P.js} +3 -3
- package/dist/chunks/{chunk-J2VEB5K3.js → chunk-2BQESR2U.js} +2 -2
- package/dist/chunks/{chunk-727FH2NI.js → chunk-2IGZUMNG.js} +15 -2
- package/dist/chunks/{chunk-IP4CWQCF.js → chunk-3NV2ETZR.js} +8 -8
- package/dist/chunks/{chunk-OXHHJWNC.js → chunk-3X7VOSBA.js} +1 -1
- package/dist/chunks/chunk-5QYE52LG.js +223 -0
- package/dist/chunks/{chunk-IRMIEDXN.js → chunk-6GWU63YF.js} +1 -1
- package/dist/chunks/{chunk-3YV7PKRL.js → chunk-6QYNE6HE.js} +12 -212
- package/dist/chunks/{chunk-Q4OYAQYH.js → chunk-72MI3MBX.js} +4 -0
- package/dist/chunks/{chunk-AD46OMQK.js → chunk-BRRW7CWA.js} +121 -46
- package/dist/chunks/{chunk-76H3IKH6.js → chunk-D2QRZUW4.js} +221 -37
- package/dist/chunks/{chunk-GSZTA43P.js → chunk-EJVA5ZVB.js} +2 -2
- package/dist/chunks/{chunk-4RWS2YYL.js → chunk-GEOMANP7.js} +3 -3
- package/dist/chunks/{chunk-LIEQJIGM.js → chunk-GR76ZDDX.js} +0 -3
- package/dist/chunks/{chunk-O6CMPO65.js → chunk-IW7A2IQY.js} +16 -146
- package/dist/chunks/chunk-JEQHNNSS.js +158 -0
- package/dist/chunks/{chunk-6V5ZPKHV.js → chunk-K3BT54CU.js} +4 -4
- package/dist/chunks/{chunk-6AXKWFKG.js → chunk-KV5SOWMS.js} +4 -4
- package/dist/chunks/{chunk-JB34OE7R.js → chunk-NBEWUR7L.js} +1 -1
- package/dist/chunks/{chunk-PSOMGA3U.js → chunk-ZKEUGS2U.js} +36 -7
- package/dist/chunks/{conflict-H7EHQXYY.js → conflict-6347A7YK.js} +2 -2
- package/dist/chunks/{contract-3QLAGYQL.js → contract-N6P2HIIE.js} +425 -187
- package/dist/chunks/{create-flow-VRVJEOBX.js → create-flow-7WG7LVX5.js} +6 -6
- package/dist/chunks/data-QO7QWOIV.js +2525 -0
- package/dist/chunks/{ehr-SH2LM3NK.js → ehr-XI4BIVR2.js} +16 -5
- package/dist/chunks/{employee-NOHNXC46.js → employee-DR5Y64TI.js} +2 -1
- package/dist/chunks/{env-66FPSJDV.js → env-LHRKSLG6.js} +2 -2
- package/dist/chunks/{factory-UH2TZBVA.js → factory-2H7Z4RWJ.js} +1 -1
- package/dist/chunks/{group-chat-CAKMMV7K.js → group-chat-EW6PNDDT.js} +3 -3
- package/dist/chunks/{hrm-UNKCCCGP.js → hrm-YGIR3HGF.js} +4 -2
- package/dist/chunks/{im-NJB7ZYMH.js → im-3RCNL5GT.js} +107 -1
- package/dist/chunks/{invoice-UEAHSYAE.js → invoice-FXWH5GPO.js} +2 -71
- package/dist/chunks/{lazy-dispatch-25XGTXLM.js → lazy-dispatch-XSAHDK6Z.js} +3 -3
- package/dist/chunks/{meeting-VTBFW4HI.js → meeting-N2FQBHXI.js} +10 -10
- package/dist/chunks/org-NFE7X7FK.js +12 -0
- package/dist/chunks/{reception-5WITA44R.js → reception-MYOKJULO.js} +905 -116
- package/dist/chunks/{recruit-stage-CAKZTUA7.js → recruit-stage-FKWS5UQF.js} +118 -29
- package/dist/chunks/{registry-VWXWPVAG.js → registry-3UGIWH53.js} +4 -2
- package/dist/chunks/{registry-AQVGHUM6.js → registry-7VZ6YJUF.js} +2 -2
- package/dist/chunks/{registry-PVUZQDDQ.js → registry-BUTEDK3C.js} +1 -1
- package/dist/chunks/{registry-JVQBLFQ5.js → registry-CKUVBS53.js} +10 -10
- package/dist/chunks/{room-recommend-5U55FMXZ.js → room-recommend-MBCYENQ2.js} +4 -4
- package/dist/chunks/{schedule-IDETODCA.js → schedule-5IFMCXME.js} +4 -4
- package/dist/chunks/{workflow-BSYT5TGL.js → workflow-2TRU2ZSP.js} +5 -5
- package/dist/core/refs.js +19 -2
- package/dist/index.js +20 -15
- package/dist/shortcuts/archive-oa/constants.js +42 -0
- package/dist/shortcuts/archive-oa/host.js +2 -2
- package/dist/shortcuts/archive-oa/index.js +38 -0
- package/dist/shortcuts/archive-oa/operations/borrow-car.js +117 -3
- 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/my-borrow-contract.js +271 -0
- package/dist/shortcuts/archive-oa/operations/registry.js +9 -4
- package/dist/shortcuts/archive-oa/operations/shared.js +41 -5
- package/dist/shortcuts/contract/index.js +9 -1
- package/dist/shortcuts/contract/manifest.js +14 -2
- package/dist/shortcuts/contract/operations/card.js +231 -0
- package/dist/shortcuts/contract/operations/registry.js +2 -0
- package/dist/shortcuts/contract/operations/review.js +16 -5
- package/dist/shortcuts/contract/operations/summary.js +25 -17
- 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/operations/recruit-write.js +22 -5
- package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +28 -12
- package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +21 -13
- package/dist/shortcuts/ehr/recruit-stage/shared.js +90 -8
- package/dist/shortcuts/im/index.js +128 -0
- package/dist/shortcuts/im/operations/session.js +6 -0
- package/dist/shortcuts/index.js +5 -0
- package/dist/shortcuts/invoice/host.js +0 -3
- package/dist/shortcuts/invoice/manifest.js +0 -1
- package/dist/shortcuts/invoice/operations/reim-subsidy.js +1 -71
- package/dist/shortcuts/meeting/operations/eb/conflict.js +26 -3
- package/dist/shortcuts/meeting/operations/eb/continuation-alias.js +63 -0
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +71 -12
- package/dist/shortcuts/meeting/operations/eb/factory.js +5 -3
- package/dist/shortcuts/meeting/operations/eb/member-expand.js +200 -0
- package/dist/shortcuts/meeting/operations/registry.js +2 -0
- package/dist/shortcuts/reception/constants.js +11 -0
- package/dist/shortcuts/reception/host.js +33 -1
- package/dist/shortcuts/reception/index.js +22 -1
- package/dist/shortcuts/reception/manifest.js +55 -2
- package/dist/shortcuts/reception/operations/ask.js +37 -1
- package/dist/shortcuts/reception/operations/compose.js +124 -3
- 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 +245 -0
- package/dist/shortcuts/reception/operations/markdown.js +22 -0
- package/dist/shortcuts/reception/operations/panels.js +84 -21
- package/dist/shortcuts/reception/operations/registry.js +2 -0
- package/dist/shortcuts/reception/operations/render.js +76 -3
- package/dist/shortcuts/reception/operations/restaurant-rooms.js +118 -0
- package/dist/shortcuts/reception/operations/restaurant.js +264 -0
- package/dist/shortcuts/reception/operations/restaurantrooms.js +42 -0
- package/dist/shortcuts/reception/operations/schedule.js +7 -1
- package/dist/shortcuts/reception/upload.js +22 -6
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +28 -12
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +21 -13
- package/dist/shortcuts/recruit-stage/shared.js +99 -14
- package/docs/SKILL.md +1 -0
- package/docs/_catalog.md +3 -0
- package/docs/archive-oa.md +4 -2
- package/docs/data.md +149 -0
- 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 +23 -0
- package/skill-template/domains/archive-oa.md +2 -1
- package/skill-template/domains/data.md +15 -0
- package/skill-template/master-skill-template.md +1 -0
- package/skill-template/skill-template.md +1 -0
- package/skills/weaver-e10-archive-oa/SKILL.md +35 -7
- package/skills/weaver-e10-archive-oa/references/borrow-car.md +32 -7
- package/skills/weaver-e10-archive-oa/references/contract-search.md +105 -4
- package/skills/weaver-e10-archive-oa/references/disabled-capabilities.md +2 -2
- package/skills/weaver-e10-archive-oa/references/my-borrow-contract.md +97 -0
- package/skills/weaver-e10-archive-oa/references/my-borrow.md +6 -1
- package/skills/weaver-e10-archive-oa/references/qys-contract-search.md +48 -2
- package/skills/weaver-e10-calendar/SKILL.md +1 -1
- package/skills/weaver-e10-calendar/references/calendar-query.md +1 -1
- package/skills/weaver-e10-calendar/references/calendar-write.md +9 -9
- package/skills/weaver-e10-cowork/SKILL.md +9 -6
- 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 +10 -7
- package/skills/weaver-e10-jinchengda/references/contract-action-card-template.html +17 -0
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +263 -35
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +8 -5
- package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +175 -22
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +124 -19
- package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +6 -0
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-risk-report-template.html +178 -0
- package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
- package/skills/weaver-e10-jinchengda/references/orchestration.md +7 -7
- package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +279 -0
- package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +450 -0
- package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +358 -0
- package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +505 -0
- package/skills/weaver-e10-jucailin/SKILL.md +7 -4
- package/skills/weaver-e10-jucailin/references/recruit-create.md +3 -2
- package/skills/weaver-e10-jucailin/references/recruit-read.md +2 -1
- package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +3 -3
- package/skills/weaver-e10-jucailin/references/safety-boundaries.md +30 -2
- package/skills/weaver-e10-mail/SKILL.md +17 -4
- package/skills/weaver-e10-meeting/SKILL.md +129 -412
- package/skills/weaver-e10-meeting/references/create-flow.md +188 -0
- package/skills/weaver-e10-meeting/references/create-guardrails.md +234 -0
- package/skills/weaver-e10-meeting/references/pitfalls.md +40 -0
- package/skills/weaver-e10-reception-flow/SKILL.md +77 -19
- package/skills/weaver-e10-reception-flow/data/fields-snapshot.json +628 -26
- package/skills/weaver-e10-reception-flow/references/fields-snapshot.md +96 -26
- package/skills/weaver-e10-reception-flow/references/guide.md +4 -3
- package/skills/weaver-e10-reception-flow/scripts/render.py +84 -3
- package/skills/weaver-e10-recruit-stage/SKILL.md +45 -12
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +78 -8
- package/skills/weaver-e10-recruit-stage/references/position-templates.md +5 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +40 -11
- package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +16 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +169 -0
- package/skills/weaver-e10-shijingran/SKILL.md +6 -2
- package/skills/weaver-e10-shijingran/references/source-manifest.json +5 -4
- package/skills/weaver-e10-workflow/SKILL.md +1 -1
- package/skills/weaver-e10-yepiaotong/SKILL.md +8 -4
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +2 -2
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +1 -0
- package/skills/weaver-e10-yimiaoban/SKILL.md +2 -1
- package/skills/weaver-e10-yimiaoban/references/msg-write.md +32 -0
- package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +3 -0
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +11 -11
- package/dist/chunks/{ebuilder-form-GWDTKEI2.js → ebuilder-form-CBYI6CQ6.js} +3 -3
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-README.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-SKILL.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-openai.yaml +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-position-templates.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-arrange-interview.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-capability-check.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-check-install.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-detail-process.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-edit-interview-feedback.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-jd-create.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-jd-template.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-list-candidate.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-list-interview.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-match-candidates.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-output-links.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-creator.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-metadata.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resume-import.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resume-parse.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-search-candidate.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-urge-feedback.md +0 -0
|
@@ -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
|
+
}
|