weaver-work-cli 0.1.50 → 0.1.53
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 +1 -1
- package/dist/chunks/{attachment-content-EJYIOJPH.js → attachment-content-W3TSJC3Y.js} +3 -3
- package/dist/chunks/{chunk-BFKLQLBK.js → chunk-2J3XY4ED.js} +7 -7
- package/dist/chunks/{chunk-K67FODVC.js → chunk-6GCXWKG6.js} +1 -1
- package/dist/chunks/{chunk-WNJUGI2F.js → chunk-76PRVYH4.js} +1 -1
- package/dist/chunks/{chunk-RYFRGTUV.js → chunk-DEHJ7PMA.js} +4 -4
- package/dist/chunks/{chunk-3NCFFHB2.js → chunk-IF33CG4V.js} +1 -1
- package/dist/chunks/{chunk-YB3AJYPY.js → chunk-PE334WL3.js} +4 -4
- package/dist/chunks/{chunk-MCZG6HPM.js → chunk-QQXMHM3J.js} +2 -2
- package/dist/chunks/{chunk-7ECB22G3.js → chunk-U7ROML5E.js} +23 -23
- package/dist/chunks/{chunk-7AYQJSFY.js → chunk-WTLQGS6D.js} +2 -2
- package/dist/chunks/{chunk-6T53BSWZ.js → chunk-XPQN4E5O.js} +50 -19
- package/dist/chunks/{chunk-HARQF5IP.js → chunk-Z4G7LLDD.js} +25 -25
- package/dist/chunks/{conflict-C4UDHCWV.js → conflict-57WDJWL7.js} +2 -2
- package/dist/chunks/{contract-VUC6JOPG.js → contract-LJRAXVZU.js} +8587 -1421
- package/dist/chunks/{create-flow-6OG2LYBD.js → create-flow-3FMMZBCA.js} +6 -6
- package/dist/chunks/{data-QO7QWOIV.js → data-WK5CQXNF.js} +17 -32
- package/dist/chunks/{env-WP57TF2S.js → env-JYZE3BZB.js} +2 -2
- package/dist/chunks/{factory-VUXI7N5C.js → factory-66SCIKW3.js} +1 -1
- package/dist/chunks/{group-chat-UQRGXILK.js → group-chat-MNRYMLNG.js} +3 -3
- package/dist/chunks/{invoice-E7GOITEU.js → invoice-V7ZTITUO.js} +725 -205
- package/dist/chunks/{meeting-4BBLVAWM.js → meeting-IIY4UAJL.js} +10 -10
- package/dist/chunks/{recruit-stage-FKWS5UQF.js → recruit-stage-XCMVEQA2.js} +718 -131
- package/dist/chunks/{registry-V4CHRQDI.js → registry-CJOVECZD.js} +1 -1
- package/dist/chunks/{registry-5CRCN2TV.js → registry-METZ2LWE.js} +10 -10
- package/dist/chunks/{room-recommend-AYR3UG7R.js → room-recommend-YFY7HTOF.js} +4 -4
- package/dist/chunks/{schedule-JZEFIXUS.js → schedule-6I63TERA.js} +4 -4
- package/dist/chunks/smart-extract-FOUYNIG3.js +2882 -0
- package/dist/chunks/{workflow-3ZAF2J5E.js → workflow-YHXFIU63.js} +1 -1
- package/dist/index.js +11 -6
- package/dist/shortcuts/contract/manifest.js +251 -0
- package/dist/shortcuts/contract/ooxml/docx-table.js +233 -0
- package/dist/shortcuts/contract/operations/card-action.js +1165 -0
- package/dist/shortcuts/contract/operations/card-ebdf-list.js +571 -0
- package/dist/shortcuts/contract/operations/card-plan.js +327 -0
- package/dist/shortcuts/contract/operations/card-risk-report.js +565 -0
- package/dist/shortcuts/contract/operations/card.js +6 -5
- package/dist/shortcuts/contract/operations/docx-fillfromquote.js +532 -0
- package/dist/shortcuts/contract/operations/docx-verify.js +258 -0
- package/dist/shortcuts/contract/operations/elements-build.js +761 -0
- package/dist/shortcuts/contract/operations/elements-spec.js +216 -0
- package/dist/shortcuts/contract/operations/first-screen.js +588 -0
- package/dist/shortcuts/contract/operations/flow.js +81 -25
- package/dist/shortcuts/contract/operations/ledger.js +438 -0
- package/dist/shortcuts/contract/operations/modeltext.js +132 -0
- package/dist/shortcuts/contract/operations/op-resolver.js +22 -0
- package/dist/shortcuts/contract/operations/performance.js +104 -3
- package/dist/shortcuts/contract/operations/quote.js +131 -25
- package/dist/shortcuts/contract/operations/quotescreen.js +529 -0
- package/dist/shortcuts/contract/operations/registry.js +30 -0
- package/dist/shortcuts/contract/operations/review.js +73 -58
- package/dist/shortcuts/contract/operations/summary-validate.js +293 -0
- package/dist/shortcuts/contract/operations/summary.js +4 -2
- package/dist/shortcuts/contract/operations/triage.js +1100 -0
- package/dist/shortcuts/contract/operations/upload.js +48 -7
- package/dist/shortcuts/contract/prewarm-cache.js +90 -0
- package/dist/shortcuts/contract/prewarm.js +88 -0
- package/dist/shortcuts/contract/upload-cache.js +49 -4
- package/dist/shortcuts/data/index.js +1 -6
- package/dist/shortcuts/data/manifest.js +2 -2
- package/dist/shortcuts/data/operations/index.js +1 -1
- package/dist/shortcuts/data/operations/query.js +23 -46
- package/dist/shortcuts/index.js +5 -0
- package/dist/shortcuts/invoice/index.js +0 -12
- package/dist/shortcuts/invoice/manifest.js +200 -49
- package/dist/shortcuts/invoice/operations/registry.js +4 -2
- package/dist/shortcuts/invoice/operations/reim-relation.js +438 -0
- package/dist/shortcuts/invoice/operations/shared.js +3 -19
- package/dist/shortcuts/invoice/operations/upload-and-validate.js +109 -73
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +4 -2
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +6 -2
- package/dist/shortcuts/recruit-stage/operations/list.js +217 -1
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +144 -158
- package/dist/shortcuts/recruit-stage/operations/search.js +348 -0
- package/dist/shortcuts/recruit-stage/shared.js +5 -0
- package/dist/shortcuts/recruit-stage/tag-lookup.js +136 -0
- package/dist/shortcuts/smart-extract/constants.js +79 -0
- package/dist/shortcuts/smart-extract/continuation.js +71 -0
- package/dist/shortcuts/smart-extract/errors.js +68 -0
- package/dist/shortcuts/smart-extract/host.js +191 -0
- package/dist/shortcuts/smart-extract/index.js +105 -0
- package/dist/shortcuts/smart-extract/ledger.js +70 -0
- package/dist/shortcuts/smart-extract/manifest.js +35 -0
- package/dist/shortcuts/smart-extract/operations/attachment.js +212 -0
- package/dist/shortcuts/smart-extract/operations/batch.js +67 -0
- package/dist/shortcuts/smart-extract/operations/config.js +118 -0
- package/dist/shortcuts/smart-extract/operations/fill.js +492 -0
- package/dist/shortcuts/smart-extract/operations/preview.js +174 -0
- package/dist/shortcuts/smart-extract/operations/registry.js +34 -0
- package/dist/shortcuts/smart-extract/operations/save.js +355 -0
- package/dist/shortcuts/smart-extract/operations/shared.js +191 -0
- package/dist/shortcuts/smart-extract/operations/structure.js +401 -0
- package/dist/shortcuts/smart-extract/operations/target.js +167 -0
- package/dist/shortcuts/smart-extract/operations/types.js +22 -0
- package/dist/shortcuts/smart-extract/operations/validate.js +454 -0
- package/dist/shortcuts/workflow/operations/form.js +68 -33
- package/dist/shortcuts/workflow/operations/read.js +19 -1
- package/docs/SKILL.md +1 -1
- package/docs/_catalog.md +3 -0
- package/docs/agent-invoice.md +5 -7
- package/docs/data.md +5 -1
- package/docs/fna.md +14 -1
- package/docs/invoice.md +7 -5
- package/docs/smart-extract.md +156 -0
- package/package.json +1 -1
- package/skill-template/business-info.json +16 -1
- package/skill-template/domains/qiyecheng.md +2 -0
- package/skill-template/domains/smart-extract.md +16 -0
- package/skill-template/domains/yepiaotong.md +2 -2
- package/skills/weaver-e10-data/references/scene-and-misc.md +4 -3
- package/skills/weaver-e10-jinchengda/SKILL.md +223 -35
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +47 -481
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +11 -11
- package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +32 -16
- package/skills/weaver-e10-jinchengda/references/contract-card-render-internals.md +478 -0
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +39 -61
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +18 -13
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +21 -6
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +6 -4
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +263 -0
- package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +525 -0
- package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +36 -0
- package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +128 -0
- package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +87 -0
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +80 -54
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +110 -14
- package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +19 -21
- package/skills/weaver-e10-jinchengda/references/orchestration.md +12 -12
- package/skills/weaver-e10-jinchengda/references/source-manifest.json +1 -6
- package/skills/weaver-e10-jinchengda/scripts/fill_plan.py +2 -1
- package/skills/weaver-e10-qiyecheng/SKILL.md +37 -0
- package/skills/weaver-e10-qiyecheng/references/ai-check-audit.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/budget.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/catalog.md +25 -0
- package/skills/weaver-e10-qiyecheng/references/expense-center.md +8 -0
- package/skills/weaver-e10-qiyecheng/references/expense-chart.md +9 -0
- package/skills/weaver-e10-qiyecheng/references/invoice-writeoff.md +13 -0
- package/skills/weaver-e10-qiyecheng/references/loan-management.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/self-hosted-mode.md +239 -0
- package/skills/weaver-e10-qiyecheng/references/source-manifest.json +34 -27
- package/skills/weaver-e10-recruit-stage/SKILL.md +62 -4
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +42 -8
- package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +79 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +11 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +3 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +153 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +7 -4
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +66 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +156 -42
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +122 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +36 -8
- package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +157 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +35 -0
- package/skills/weaver-e10-smart-extract/SKILL.md +180 -0
- package/skills/weaver-e10-smart-extract/references/api-contract.md +71 -0
- package/skills/weaver-e10-smart-extract/references/result-format.md +102 -0
- package/skills/weaver-e10-smart-extract/references/troubleshooting.md +106 -0
- package/skills/weaver-e10-workflow/references/workflow-create.md +6 -5
- package/skills/weaver-e10-workflow/references/workflow-edit.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-query.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-view.md +1 -1
- package/skills/weaver-e10-yepiaotong/SKILL.md +46 -33
- package/skills/weaver-e10-yepiaotong/references/invoice-add.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-file-upload.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-import.md +19 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-ocr-preview.md +8 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +407 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +12 -8
- package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +97 -39
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +91 -2
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +12 -12
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +8 -4
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +136 -91
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +109 -23
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +110 -43
- package/dist/shortcuts/invoice/operations/validate-preview.js +0 -40
- package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +0 -279
- package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +0 -450
- package/skills/weaver-e10-jinchengda/scripts/render_ebdf_list_card.py +0 -265
- package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +0 -358
- package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +0 -588
- package/skills/weaver-e10-jinchengda/scripts/verify_docx_placeholders.py +0 -118
- package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +0 -40
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import { PATHS } from '../constants.js';
|
|
2
|
+
import { smartExtractValidationError } from '../errors.js';
|
|
3
|
+
import { record } from '../host.js';
|
|
4
|
+
import { smartExtractSuccess, schemaOf, SCHEMA_ID } from './types.js';
|
|
5
|
+
import { optionalId, parseIdList } from './shared.js';
|
|
6
|
+
/** 只有这些类型会带 options;其余即使返回了 options 也不当作候选值。 */
|
|
7
|
+
const OPTION_TYPES = new Set(['Select', 'SelectMultiple', 'RadioBox', 'CheckBox', 'Cascader']);
|
|
8
|
+
/**
|
|
9
|
+
* 天然单值的字段类型:物理上装不下第二个值。
|
|
10
|
+
*
|
|
11
|
+
* 只在拿不到 EB 表单定义时兜底:`getSimple?formModeType=wf` 会丢掉
|
|
12
|
+
* Text/TextArea 的 `single`(同一表单在 `formModeType=eb` 下是 `true`),照抄会把「案件号」
|
|
13
|
+
* 标成 multiple,模型就会给数组,写入必然失败。
|
|
14
|
+
*/
|
|
15
|
+
const ALWAYS_SINGLE_TYPES = new Set([
|
|
16
|
+
'Text',
|
|
17
|
+
'TextArea',
|
|
18
|
+
'RichText',
|
|
19
|
+
'Number',
|
|
20
|
+
'Money',
|
|
21
|
+
'Amount',
|
|
22
|
+
'Percent',
|
|
23
|
+
'Score',
|
|
24
|
+
'DateComponent',
|
|
25
|
+
'TimeComponent',
|
|
26
|
+
]);
|
|
27
|
+
export function isOptionType(fieldType) {
|
|
28
|
+
return OPTION_TYPES.has(fieldType);
|
|
29
|
+
}
|
|
30
|
+
function boolOf(value, fallback) {
|
|
31
|
+
if (typeof value === 'boolean')
|
|
32
|
+
return value;
|
|
33
|
+
if (typeof value === 'number')
|
|
34
|
+
return value !== 0;
|
|
35
|
+
if (typeof value === 'string') {
|
|
36
|
+
const text = value.trim().toLowerCase();
|
|
37
|
+
if (text === 'true' || text === '1')
|
|
38
|
+
return true;
|
|
39
|
+
if (text === 'false' || text === '0')
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return fallback;
|
|
43
|
+
}
|
|
44
|
+
function textOf(value) {
|
|
45
|
+
if (value === undefined || value === null)
|
|
46
|
+
return '';
|
|
47
|
+
return String(value).trim();
|
|
48
|
+
}
|
|
49
|
+
function normalizeOptions(raw) {
|
|
50
|
+
if (!Array.isArray(raw))
|
|
51
|
+
return [];
|
|
52
|
+
return raw
|
|
53
|
+
.map((item) => {
|
|
54
|
+
const option = record(item);
|
|
55
|
+
const optionName = textOf(option.optionName ?? option.name ?? option.label);
|
|
56
|
+
const optionValue = textOf(option.optionValue ?? option.value ?? option.id ?? option.optionId);
|
|
57
|
+
if (!optionName && !optionValue)
|
|
58
|
+
return null;
|
|
59
|
+
return {
|
|
60
|
+
...(option.optionId === undefined || option.optionId === null
|
|
61
|
+
? {}
|
|
62
|
+
: { optionId: textOf(option.optionId) }),
|
|
63
|
+
optionName,
|
|
64
|
+
optionValue: optionValue || optionName,
|
|
65
|
+
};
|
|
66
|
+
})
|
|
67
|
+
.filter((item) => item !== null);
|
|
68
|
+
}
|
|
69
|
+
function compactOf(field) {
|
|
70
|
+
const head = [
|
|
71
|
+
field.fieldId,
|
|
72
|
+
field.fieldName,
|
|
73
|
+
field.marked ? 'isMarked' : 'notMarked',
|
|
74
|
+
field.single ? 'single' : 'multiple',
|
|
75
|
+
field.fieldType || 'Text',
|
|
76
|
+
].join('#');
|
|
77
|
+
const options = field.options?.length
|
|
78
|
+
? `#${field.options.map((option) => `[optionName:${option.optionName},optionValue:${option.optionValue}]`).join('、')}`
|
|
79
|
+
: '';
|
|
80
|
+
return `${head}${options}`;
|
|
81
|
+
}
|
|
82
|
+
export function normalizeField(raw) {
|
|
83
|
+
const field = record(raw);
|
|
84
|
+
const fieldId = textOf(field.fieldId ?? field.id);
|
|
85
|
+
if (!fieldId)
|
|
86
|
+
return null;
|
|
87
|
+
const fieldType = textOf(field.fieldType ?? field.type) || 'Text';
|
|
88
|
+
const options = isOptionType(fieldType) ? normalizeOptions(field.options) : [];
|
|
89
|
+
const normalized = {
|
|
90
|
+
fieldId,
|
|
91
|
+
fieldName: textOf(field.fieldName ?? field.name) || fieldId,
|
|
92
|
+
fieldType,
|
|
93
|
+
// 照抄服务端;wf 模式会丢值,由 correctSingleFromEb / applyTypeBasedSingle 事后校正。
|
|
94
|
+
single: boolOf(field.single ?? field.isSingle, false),
|
|
95
|
+
marked: boolOf(field.marked ?? field.isMarked, false),
|
|
96
|
+
...(textOf(field.fieldDbName) ? { fieldDbName: textOf(field.fieldDbName) } : {}),
|
|
97
|
+
...(textOf(field.browserModule) ? { browserModule: textOf(field.browserModule) } : {}),
|
|
98
|
+
...(textOf(field.browserType) ? { browserType: textOf(field.browserType) } : {}),
|
|
99
|
+
...(textOf(field.fieldAlias) ? { fieldAlias: textOf(field.fieldAlias) } : {}),
|
|
100
|
+
...(textOf(field.parentFieldId) ? { parentFieldId: textOf(field.parentFieldId) } : {}),
|
|
101
|
+
...(options.length > 0 ? { options } : {}),
|
|
102
|
+
compact: '',
|
|
103
|
+
};
|
|
104
|
+
normalized.compact = compactOf(normalized);
|
|
105
|
+
return normalized;
|
|
106
|
+
}
|
|
107
|
+
export function normalizeStructure(raw, mode, source) {
|
|
108
|
+
if (!raw || typeof raw !== 'object') {
|
|
109
|
+
throw smartExtractValidationError('structure_invalid', '表单结构响应不是对象');
|
|
110
|
+
}
|
|
111
|
+
const main = record(raw);
|
|
112
|
+
const layoutFields = [];
|
|
113
|
+
const mainFields = [];
|
|
114
|
+
for (const item of Array.isArray(main.mainFields) ? main.mainFields : []) {
|
|
115
|
+
const field = normalizeField(item);
|
|
116
|
+
if (!field)
|
|
117
|
+
continue;
|
|
118
|
+
if (field.fieldType === 'Fold') {
|
|
119
|
+
layoutFields.push({ fieldId: field.fieldId, fieldName: field.fieldName });
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
mainFields.push(field);
|
|
123
|
+
}
|
|
124
|
+
const subTables = [];
|
|
125
|
+
for (const item of Array.isArray(main.subTables) ? main.subTables : []) {
|
|
126
|
+
const sub = record(item);
|
|
127
|
+
const subFormId = textOf(sub.subFormId ?? sub.id);
|
|
128
|
+
if (!subFormId)
|
|
129
|
+
continue;
|
|
130
|
+
const fields = [];
|
|
131
|
+
for (const subField of Array.isArray(sub.subFields) ? sub.subFields : []) {
|
|
132
|
+
const field = normalizeField(subField);
|
|
133
|
+
if (!field || field.fieldType === 'Fold')
|
|
134
|
+
continue;
|
|
135
|
+
fields.push(field);
|
|
136
|
+
}
|
|
137
|
+
subTables.push({
|
|
138
|
+
subFormId,
|
|
139
|
+
subFormName: textOf(sub.subFormName ?? sub.name) || subFormId,
|
|
140
|
+
...(textOf(sub.subDbTableName) ? { subDbTableName: textOf(sub.subDbTableName) } : {}),
|
|
141
|
+
fields,
|
|
142
|
+
subFieldsStr: fields.map((field) => field.compact),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const mainFormId = textOf(main.mainFormId ?? main.formId);
|
|
146
|
+
if (!mainFormId) {
|
|
147
|
+
throw smartExtractValidationError('structure_invalid', '表单结构缺少 mainFormId');
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
mode,
|
|
151
|
+
source,
|
|
152
|
+
mainFormId,
|
|
153
|
+
...(textOf(main.mainFormName) ? { mainFormName: textOf(main.mainFormName) } : {}),
|
|
154
|
+
...(textOf(main.mainFormDesc) ? { mainFormDesc: textOf(main.mainFormDesc) } : {}),
|
|
155
|
+
...(textOf(main.mainDbTableName) ? { mainDbTableName: textOf(main.mainDbTableName) } : {}),
|
|
156
|
+
...(main.appId === undefined || main.appId === null ? {} : { appId: textOf(main.appId) }),
|
|
157
|
+
mainFields,
|
|
158
|
+
mainFieldsStr: mainFields.map((field) => field.compact),
|
|
159
|
+
subTables,
|
|
160
|
+
layoutFields,
|
|
161
|
+
stats: {
|
|
162
|
+
mainFieldCount: mainFields.length,
|
|
163
|
+
subTableCount: subTables.length,
|
|
164
|
+
subFieldCount: subTables.reduce((total, table) => total + table.fields.length, 0),
|
|
165
|
+
layoutFieldCount: layoutFields.length,
|
|
166
|
+
optionFieldCount: mainFields.filter((field) => (field.options?.length ?? 0) > 0).length,
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/** 改完后重算压缩串(压缩串直接把 single 写成 single|multiple)。 */
|
|
171
|
+
function rewriteCompact(structure, touched) {
|
|
172
|
+
if (!touched)
|
|
173
|
+
return;
|
|
174
|
+
structure.mainFieldsStr = structure.mainFields.map((field) => field.compact);
|
|
175
|
+
for (const table of structure.subTables) {
|
|
176
|
+
table.subFieldsStr = table.fields.map((field) => field.compact);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function eachField(structure) {
|
|
180
|
+
return [...structure.mainFields, ...structure.subTables.flatMap((table) => table.fields)];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* 用同一表单的 **EB 定义**校正 `single`。
|
|
184
|
+
*
|
|
185
|
+
* `getSimple?formModeType=wf` 会丢 Text/TextArea 的 `single`(返回 false,
|
|
186
|
+
* 而 EB 下同一字段是 true),只有 Select/Employee/Date 这类保留。字段定义是表单级属性,
|
|
187
|
+
* 节点只决定「能不能填」,所以以 EB 为准最可靠。返回被改动的字段数。
|
|
188
|
+
*/
|
|
189
|
+
async function correctSingleFromEb(host, structure) {
|
|
190
|
+
if (!structure.mainFormId)
|
|
191
|
+
return 0;
|
|
192
|
+
const raw = await host.requestData({
|
|
193
|
+
operation: 'smart-extract.form.structure',
|
|
194
|
+
method: 'GET',
|
|
195
|
+
path: PATHS.governFormSimple,
|
|
196
|
+
query: { formId: structure.mainFormId, formModeType: 'eb' },
|
|
197
|
+
});
|
|
198
|
+
const truth = new Map();
|
|
199
|
+
const collect = (list) => {
|
|
200
|
+
for (const entry of list) {
|
|
201
|
+
const item = record(entry);
|
|
202
|
+
const fieldId = textOf(item.fieldId ?? item.id);
|
|
203
|
+
if (!fieldId)
|
|
204
|
+
continue;
|
|
205
|
+
if (item.single === undefined && item.isSingle === undefined)
|
|
206
|
+
continue;
|
|
207
|
+
truth.set(fieldId, boolOf(item.single ?? item.isSingle, false));
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const data = record(raw);
|
|
211
|
+
collect(Array.isArray(data.mainFields) ? data.mainFields : []);
|
|
212
|
+
for (const entry of Array.isArray(data.subTables) ? data.subTables : []) {
|
|
213
|
+
const sub = record(entry);
|
|
214
|
+
collect(Array.isArray(sub.subFields) ? sub.subFields : []);
|
|
215
|
+
}
|
|
216
|
+
let corrected = 0;
|
|
217
|
+
for (const field of eachField(structure)) {
|
|
218
|
+
const expected = truth.get(field.fieldId);
|
|
219
|
+
if (expected === undefined || expected === field.single)
|
|
220
|
+
continue;
|
|
221
|
+
field.single = expected;
|
|
222
|
+
field.compact = compactOf(field);
|
|
223
|
+
corrected += 1;
|
|
224
|
+
}
|
|
225
|
+
rewriteCompact(structure, corrected > 0);
|
|
226
|
+
return corrected;
|
|
227
|
+
}
|
|
228
|
+
/** 兜底:拿不到 EB 定义时,按「物理上只能放一个值」的字段类型纠正。 */
|
|
229
|
+
export function applyTypeBasedSingle(structure) {
|
|
230
|
+
let corrected = 0;
|
|
231
|
+
for (const field of eachField(structure)) {
|
|
232
|
+
if (field.single || !ALWAYS_SINGLE_TYPES.has(field.fieldType))
|
|
233
|
+
continue;
|
|
234
|
+
field.single = true;
|
|
235
|
+
field.compact = compactOf(field);
|
|
236
|
+
corrected += 1;
|
|
237
|
+
}
|
|
238
|
+
rewriteCompact(structure, corrected > 0);
|
|
239
|
+
return corrected;
|
|
240
|
+
}
|
|
241
|
+
/** 只保留指定字段(targetFieldIdList);同时用于 validate 的「只校验这些字段」。 */
|
|
242
|
+
function filterByFieldIds(structure, keep) {
|
|
243
|
+
if (keep.length === 0)
|
|
244
|
+
return structure;
|
|
245
|
+
const wanted = new Set(keep);
|
|
246
|
+
const mainFields = structure.mainFields.filter((field) => wanted.has(field.fieldId));
|
|
247
|
+
const subTables = structure.subTables.map((table) => {
|
|
248
|
+
const fields = table.fields.filter((field) => wanted.has(field.fieldId));
|
|
249
|
+
return { ...table, fields, subFieldsStr: fields.map((field) => field.compact) };
|
|
250
|
+
});
|
|
251
|
+
return {
|
|
252
|
+
...structure,
|
|
253
|
+
mainFields,
|
|
254
|
+
mainFieldsStr: mainFields.map((field) => field.compact),
|
|
255
|
+
subTables,
|
|
256
|
+
stats: {
|
|
257
|
+
...structure.stats,
|
|
258
|
+
mainFieldCount: mainFields.length,
|
|
259
|
+
subFieldCount: subTables.reduce((total, table) => total + table.fields.length, 0),
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/** 取流程发起节点:`getFlowStartNode`。返回 nodeId/nodeName,取不到就抛。 */
|
|
264
|
+
export async function resolveStartNode(host, workflowId) {
|
|
265
|
+
const data = record(await host.requestData({
|
|
266
|
+
operation: 'smart-extract.form.structure',
|
|
267
|
+
method: 'GET',
|
|
268
|
+
path: PATHS.flowStartNode,
|
|
269
|
+
query: { workflowId },
|
|
270
|
+
}));
|
|
271
|
+
const node = record(data.node);
|
|
272
|
+
const resolved = node.id ?? node.nodeId;
|
|
273
|
+
if (data.success === false || !resolved) {
|
|
274
|
+
throw smartExtractValidationError('node_id_required', '未指定 nodeId 且自动取发起节点失败;请显式传 nodeId', { workflowId, result: data });
|
|
275
|
+
}
|
|
276
|
+
const nodeName = textOf(node.nodeName) || undefined;
|
|
277
|
+
return {
|
|
278
|
+
nodeId: String(resolved),
|
|
279
|
+
...(nodeName ? { nodeName } : {}),
|
|
280
|
+
warnings: [`未指定节点,已使用流程发起节点${nodeName ? `「${nodeName}」` : ''}(nodeId=${resolved})`],
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* 流程 + 指定节点:`getSimple?formModeType=wf` → 归一化 → 用 EB 定义校正 `single`。
|
|
285
|
+
*
|
|
286
|
+
* 这是填单场景唯一需要的结构来源;`fill` 与本模块的 `form.structure` 共用。
|
|
287
|
+
*/
|
|
288
|
+
export async function fetchWfNodeStructure(host, workflowId, nodeId, options = {}) {
|
|
289
|
+
const keep = options.keep ?? [];
|
|
290
|
+
const warnings = [];
|
|
291
|
+
const raw = await host.requestData({
|
|
292
|
+
operation: 'smart-extract.form.structure',
|
|
293
|
+
method: 'GET',
|
|
294
|
+
path: PATHS.governFormSimple,
|
|
295
|
+
query: {
|
|
296
|
+
workflowId,
|
|
297
|
+
nodeId,
|
|
298
|
+
formModeType: 'wf',
|
|
299
|
+
...(keep.length > 0 ? { targetFieldIdList: keep.join(',') } : {}),
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
const structure = normalizeStructure(raw, 'wf-node', {
|
|
303
|
+
workflowId,
|
|
304
|
+
nodeId,
|
|
305
|
+
...(options.nodeName ? { nodeName: options.nodeName } : {}),
|
|
306
|
+
});
|
|
307
|
+
// wf 接口会丢字段级 `single`,用同一表单的 EB 定义补回来;EB 读不到时按字段类型兜底。
|
|
308
|
+
try {
|
|
309
|
+
const corrected = await correctSingleFromEb(host, structure);
|
|
310
|
+
if (corrected > 0) {
|
|
311
|
+
warnings.push(`已按 EB 表单定义校正 ${corrected} 个字段的单值/多值标记(wf 接口会丢该标记)`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
const corrected = applyTypeBasedSingle(structure);
|
|
316
|
+
if (corrected > 0) {
|
|
317
|
+
warnings.push(`未能取到 EB 表单定义,已按字段类型推断 ${corrected} 个字段为单值;人员/浏览框/多选类仍以服务端为准`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return { structure, warnings };
|
|
321
|
+
}
|
|
322
|
+
const formStructure = {
|
|
323
|
+
name: 'smart-extract.form.structure',
|
|
324
|
+
risk: 'read',
|
|
325
|
+
summary: '取表单结构并归一化:传 workflowId(+nodeId,缺省自动取发起节点) 走流程节点字段,传 formId 走 EB 表单。输出 mainFieldsStr/subFieldsStr 压缩串,可直接进提示词。',
|
|
326
|
+
inputSchema: schemaOf({
|
|
327
|
+
workflowId: { ...SCHEMA_ID, description: '流程模板 ID(wf)' },
|
|
328
|
+
nodeId: { ...SCHEMA_ID, description: '流程节点 ID;不传时自动取发起节点' },
|
|
329
|
+
formId: { ...SCHEMA_ID, description: 'EB 表单 ID(与 workflowId 二选一)' },
|
|
330
|
+
targetFieldIdList: {
|
|
331
|
+
type: 'array',
|
|
332
|
+
items: { type: 'string' },
|
|
333
|
+
description: '只输出这些字段 ID(可选)',
|
|
334
|
+
},
|
|
335
|
+
}),
|
|
336
|
+
handler: async (args, env) => {
|
|
337
|
+
const workflowId = optionalId(args.workflowId, 'workflowId');
|
|
338
|
+
const formId = optionalId(args.formId, 'formId');
|
|
339
|
+
const nodeIdInput = optionalId(args.nodeId, 'nodeId');
|
|
340
|
+
if (workflowId && formId) {
|
|
341
|
+
throw smartExtractValidationError('target_conflict', 'workflowId 与 formId 只能传一个');
|
|
342
|
+
}
|
|
343
|
+
if (!workflowId && !formId) {
|
|
344
|
+
throw smartExtractValidationError('target_required', '必须提供 workflowId 或 formId');
|
|
345
|
+
}
|
|
346
|
+
const keep = parseIdList(args.targetFieldIdList, 'targetFieldIdList');
|
|
347
|
+
const warnings = [];
|
|
348
|
+
let structure;
|
|
349
|
+
if (formId) {
|
|
350
|
+
const raw = await env.host.requestData({
|
|
351
|
+
operation: 'smart-extract.form.structure',
|
|
352
|
+
method: 'GET',
|
|
353
|
+
path: PATHS.governFormSimple,
|
|
354
|
+
query: {
|
|
355
|
+
formId,
|
|
356
|
+
formModeType: 'eb',
|
|
357
|
+
...(keep.length > 0 ? { targetFieldIdList: keep.join(',') } : {}),
|
|
358
|
+
},
|
|
359
|
+
});
|
|
360
|
+
structure = normalizeStructure(raw, 'eb', { formId });
|
|
361
|
+
if (nodeIdInput)
|
|
362
|
+
warnings.push('EB 模式不支持 nodeId,已忽略');
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
if (!workflowId) {
|
|
366
|
+
throw smartExtractValidationError('target_required', '流程模式必须提供 workflowId');
|
|
367
|
+
}
|
|
368
|
+
let nodeId = nodeIdInput;
|
|
369
|
+
let nodeName;
|
|
370
|
+
if (!nodeId) {
|
|
371
|
+
const start = await resolveStartNode(env.host, workflowId);
|
|
372
|
+
nodeId = start.nodeId;
|
|
373
|
+
nodeName = start.nodeName;
|
|
374
|
+
warnings.push(...start.warnings);
|
|
375
|
+
}
|
|
376
|
+
const loaded = await fetchWfNodeStructure(env.host, workflowId, nodeId, {
|
|
377
|
+
keep,
|
|
378
|
+
...(nodeName ? { nodeName } : {}),
|
|
379
|
+
});
|
|
380
|
+
structure = loaded.structure;
|
|
381
|
+
warnings.push(...loaded.warnings);
|
|
382
|
+
warnings.push('流程节点模式只返回该节点「可编辑或必填」的字段;只读字段已被服务端过滤');
|
|
383
|
+
}
|
|
384
|
+
const filtered = keep.length > 0 ? filterByFieldIds(structure, keep) : structure;
|
|
385
|
+
if (keep.length > 0) {
|
|
386
|
+
const present = new Set([
|
|
387
|
+
...filtered.mainFields.map((field) => field.fieldId),
|
|
388
|
+
...filtered.subTables.flatMap((table) => table.fields.map((field) => field.fieldId)),
|
|
389
|
+
]);
|
|
390
|
+
const missing = keep.filter((id) => !present.has(id));
|
|
391
|
+
if (missing.length > 0) {
|
|
392
|
+
warnings.push(`以下字段不在当前结构/节点可填范围内,已忽略:${missing.join(',')}`);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (filtered.mainFields.length === 0) {
|
|
396
|
+
warnings.push('主表没有可填字段:该节点可能全部只读,或 targetFieldIdList 过滤后为空');
|
|
397
|
+
}
|
|
398
|
+
return smartExtractSuccess('smart-extract.form.structure', filtered, { warnings });
|
|
399
|
+
},
|
|
400
|
+
};
|
|
401
|
+
export const structureOperations = [formStructure];
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { PATHS } from '../constants.js';
|
|
2
|
+
import { smartExtractBusinessError, smartExtractValidationError } from '../errors.js';
|
|
3
|
+
import { record } from '../host.js';
|
|
4
|
+
import { smartExtractSuccess, schemaOf, SCHEMA_ID } from './types.js';
|
|
5
|
+
import { optionalId, optionalString, requiredId } from './shared.js';
|
|
6
|
+
function flowSummary(flow) {
|
|
7
|
+
return {
|
|
8
|
+
workflowId: flow.workflowid ?? flow.workflowId ?? null,
|
|
9
|
+
workflowName: flow.workflowname ?? flow.workflowName ?? null,
|
|
10
|
+
workflowDesc: flow.workflowdesc ?? null,
|
|
11
|
+
typeName: flow.typeName ?? null,
|
|
12
|
+
pcUrl: flow.pcUrl ?? null,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const targetResolve = {
|
|
16
|
+
name: 'smart-extract.target.resolve',
|
|
17
|
+
risk: 'read',
|
|
18
|
+
summary: '把目标收敛成 ID:workflowId/formId/objId 直接回显校验;给 workflowKeyword 时列出当前用户可发起的流程并做名称匹配。返回 modeType 与命中项。',
|
|
19
|
+
inputSchema: schemaOf({
|
|
20
|
+
workflowId: { ...SCHEMA_ID, description: '流程模板 ID' },
|
|
21
|
+
formId: { ...SCHEMA_ID, description: 'EB 表单 ID' },
|
|
22
|
+
objId: { ...SCHEMA_ID, description: 'EB 建模对象 ID(会自动转换成 formId)' },
|
|
23
|
+
workflowKeyword: { type: 'string', description: '流程名称关键字(只在可发起流程里做包含匹配)' },
|
|
24
|
+
limit: { type: 'integer', description: '关键字匹配返回条数上限,默认 10' },
|
|
25
|
+
}),
|
|
26
|
+
handler: async (args, env) => {
|
|
27
|
+
const workflowId = optionalId(args.workflowId, 'workflowId');
|
|
28
|
+
const formId = optionalId(args.formId, 'formId');
|
|
29
|
+
const objId = optionalId(args.objId, 'objId');
|
|
30
|
+
const keyword = optionalString(args.workflowKeyword, 'workflowKeyword');
|
|
31
|
+
const limit = Math.max(1, Math.min(50, Number(args.limit ?? 10) || 10));
|
|
32
|
+
if (workflowId) {
|
|
33
|
+
return smartExtractSuccess('smart-extract.target.resolve', {
|
|
34
|
+
modeType: 'wf',
|
|
35
|
+
resolved: true,
|
|
36
|
+
workflowId,
|
|
37
|
+
hint: '需要按节点字段抽取时,再调 smart-extract.flow.start-node 取首节点 nodeId',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (formId) {
|
|
41
|
+
// objId 只是给 EB 侧后续调用用的附加信息:查不到映射不影响目标本身,不要因此失败。
|
|
42
|
+
let resolvedObjId = null;
|
|
43
|
+
try {
|
|
44
|
+
const data = record(await env.host.requestData({
|
|
45
|
+
operation: 'smart-extract.target.resolve',
|
|
46
|
+
method: 'GET',
|
|
47
|
+
path: PATHS.governObjId,
|
|
48
|
+
query: { formId },
|
|
49
|
+
}));
|
|
50
|
+
resolvedObjId = data.value ?? data.objId ?? null;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
resolvedObjId = null;
|
|
54
|
+
}
|
|
55
|
+
return smartExtractSuccess('smart-extract.target.resolve', {
|
|
56
|
+
modeType: 'eb',
|
|
57
|
+
resolved: true,
|
|
58
|
+
formId,
|
|
59
|
+
objId: resolvedObjId,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (objId) {
|
|
63
|
+
const data = await env.host.requestData({
|
|
64
|
+
operation: 'smart-extract.target.resolve',
|
|
65
|
+
method: 'GET',
|
|
66
|
+
path: PATHS.governFormId,
|
|
67
|
+
query: { objId },
|
|
68
|
+
});
|
|
69
|
+
const resolvedFormId = typeof data === 'string' ? data : record(data).value;
|
|
70
|
+
if (!resolvedFormId) {
|
|
71
|
+
throw smartExtractBusinessError('form_id_not_found', `objId=${objId} 没有对应的表单 ID`, {
|
|
72
|
+
details: { objId },
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return smartExtractSuccess('smart-extract.target.resolve', {
|
|
76
|
+
modeType: 'eb',
|
|
77
|
+
resolved: true,
|
|
78
|
+
objId,
|
|
79
|
+
formId: String(resolvedFormId),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (!keyword) {
|
|
83
|
+
throw smartExtractValidationError('target_required', '必须提供 workflowId、formId、objId 或 workflowKeyword 之一');
|
|
84
|
+
}
|
|
85
|
+
// 可发起流程列表是「锦上添花」:它挂了不代表整条链路不可用,用户手里往往有 workflowId。
|
|
86
|
+
// 真实环境里该接口会在部分租户上返回 HTTP 200 + `code:500 系统错误`(服务端流程组 RPC 失败),
|
|
87
|
+
// 所以这里必须降级成「没匹配到 + 让人补 ID」,而不是把 target.resolve 整个判失败。
|
|
88
|
+
let payload;
|
|
89
|
+
try {
|
|
90
|
+
payload = record(await env.host.requestData({
|
|
91
|
+
operation: 'smart-extract.target.resolve',
|
|
92
|
+
method: 'GET',
|
|
93
|
+
path: PATHS.creatableFlows,
|
|
94
|
+
query: { onlyLoadListData: 1, identityTypes: '0', loadOfsFlow: 0, wfpBelongTypeCode: 1 },
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
const message = error?.message || '获取可发起流程失败';
|
|
99
|
+
return smartExtractSuccess('smart-extract.target.resolve', {
|
|
100
|
+
modeType: 'wf',
|
|
101
|
+
resolved: false,
|
|
102
|
+
keyword,
|
|
103
|
+
candidateCount: 0,
|
|
104
|
+
candidates: [],
|
|
105
|
+
flowListAvailable: false,
|
|
106
|
+
flowListError: message,
|
|
107
|
+
hint: `可发起流程列表接口不可用(${message})。不要据此判断「没有这个流程」:请让用户直接给出流程 ID(workflowId),或给出精确流程名由用户确认后取 ID`,
|
|
108
|
+
}, { warnings: ['可发起流程列表接口报错,已降级为「按关键字无法自动匹配」,请改用 workflowId 直接定位'] });
|
|
109
|
+
}
|
|
110
|
+
if (payload.success === false) {
|
|
111
|
+
throw smartExtractBusinessError('creatable_flows_failed', String(payload.message || '获取可发起流程失败'));
|
|
112
|
+
}
|
|
113
|
+
const flows = (Array.isArray(payload.list) ? payload.list : []);
|
|
114
|
+
const needle = keyword.toLowerCase();
|
|
115
|
+
const matched = flows
|
|
116
|
+
.map((flow) => flowSummary(flow))
|
|
117
|
+
.filter((flow) => String(flow.workflowName ?? '').toLowerCase().includes(needle)
|
|
118
|
+
|| String(flow.workflowDesc ?? '').toLowerCase().includes(needle));
|
|
119
|
+
const candidates = matched.slice(0, limit);
|
|
120
|
+
return smartExtractSuccess('smart-extract.target.resolve', {
|
|
121
|
+
modeType: 'wf',
|
|
122
|
+
resolved: candidates.length === 1,
|
|
123
|
+
keyword,
|
|
124
|
+
candidateCount: matched.length,
|
|
125
|
+
candidates,
|
|
126
|
+
totalCreatableFlows: flows.length,
|
|
127
|
+
hint: candidates.length === 1
|
|
128
|
+
? '命中唯一流程,可直接用其 workflowId'
|
|
129
|
+
: '命中多个/零个流程:请把候选列表给用户选,或让用户给出更精确的名称/流程 ID',
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
const flowStartNode = {
|
|
134
|
+
name: 'smart-extract.flow.start-node',
|
|
135
|
+
risk: 'read',
|
|
136
|
+
summary: '按 workflowId 取流程发起节点(nodeId/nodeName)。用户没提具体节点时,用它决定 getSimple(wf) 的 nodeId。',
|
|
137
|
+
inputSchema: schemaOf({ workflowId: { ...SCHEMA_ID, description: '流程模板 ID' } }, {
|
|
138
|
+
required: ['workflowId'],
|
|
139
|
+
}),
|
|
140
|
+
handler: async (args, env) => {
|
|
141
|
+
const workflowId = requiredId(args.workflowId, 'workflowId');
|
|
142
|
+
const data = record(await env.host.requestData({
|
|
143
|
+
operation: 'smart-extract.flow.start-node',
|
|
144
|
+
method: 'GET',
|
|
145
|
+
path: PATHS.flowStartNode,
|
|
146
|
+
query: { workflowId },
|
|
147
|
+
}));
|
|
148
|
+
if (data.success === false) {
|
|
149
|
+
throw smartExtractBusinessError('start_node_not_found', String(data.message || '未取到流程发起节点'), {
|
|
150
|
+
details: { workflowId },
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const node = record(data.node);
|
|
154
|
+
const nodeId = node.id ?? node.nodeId;
|
|
155
|
+
if (!nodeId) {
|
|
156
|
+
throw smartExtractBusinessError('start_node_invalid', '发起节点缺少 id', { details: { result: data } });
|
|
157
|
+
}
|
|
158
|
+
return smartExtractSuccess('smart-extract.flow.start-node', {
|
|
159
|
+
workflowId,
|
|
160
|
+
nodeId: String(nodeId),
|
|
161
|
+
nodeName: node.nodeName ?? null,
|
|
162
|
+
nodeType: node.nodeType ?? null,
|
|
163
|
+
nodeTypeCode: node.nodeTypeCode ?? null,
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
export const targetOperations = [targetResolve, flowStartNode];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function smartExtractSuccess(action, data, options = {}) {
|
|
2
|
+
const envelope = { ok: true, action, data };
|
|
3
|
+
if (options.meta && Object.keys(options.meta).length > 0)
|
|
4
|
+
envelope.meta = options.meta;
|
|
5
|
+
if (options.warnings && options.warnings.length > 0)
|
|
6
|
+
envelope.warnings = options.warnings;
|
|
7
|
+
return envelope;
|
|
8
|
+
}
|
|
9
|
+
/** 构造「对象类型 + 严格禁止额外字段」的 JSON Schema。 */
|
|
10
|
+
export function schemaOf(properties, options = {}) {
|
|
11
|
+
return {
|
|
12
|
+
type: 'object',
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
properties,
|
|
15
|
+
...(options.required?.length ? { required: options.required } : {}),
|
|
16
|
+
...(options.description ? { description: options.description } : {}),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** E10 长 ID:入参同时接受数字或数字字符串(超 2^53 必须字符串)。 */
|
|
20
|
+
export const SCHEMA_ID = {
|
|
21
|
+
oneOf: [{ type: 'integer' }, { type: 'string', pattern: '^\\d+$' }],
|
|
22
|
+
};
|