openxiangda 1.0.108 → 1.0.110
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/lib/cli.js +122 -7
- package/lib/design-gates.js +1 -0
- package/openxiangda-skills/SKILL.md +2 -2
- package/openxiangda-skills/references/resource-manifest-cheatsheet.md +1 -0
- package/openxiangda-skills/references/workflow-v3.md +1 -1
- package/openxiangda-skills/skills/openxiangda-core/SKILL.md +2 -0
- package/openxiangda-skills/skills/openxiangda-workflow-automation/SKILL.md +1 -1
- package/package.json +1 -1
- package/packages/sdk/dist/workflow/index.cjs +44 -8
- package/packages/sdk/dist/workflow/index.cjs.map +1 -1
- package/packages/sdk/dist/workflow/index.mjs +44 -8
- package/packages/sdk/dist/workflow/index.mjs.map +1 -1
- package/packages/sdk/src/build-source/scripts/sync-schema.mjs +7 -0
- package/packages/sdk/src/build-source/scripts/utils/form-api.mjs +7 -0
- package/templates/openxiangda-react-spa/AGENTS.md +1 -1
- package/templates/openxiangda-react-spa/scripts/guard-publish.mjs +2 -1
package/lib/cli.js
CHANGED
|
@@ -154,7 +154,7 @@ Usage:
|
|
|
154
154
|
openxiangda permission page-group-list|page-group-create|page-group-update|page-group-delete|page-group-bind
|
|
155
155
|
openxiangda permission form-group-list|form-group-create|form-group-update|form-group-delete|form-group-bind
|
|
156
156
|
openxiangda settings get|save|indexes|indexes-save|data-management|data-management-save|public-access
|
|
157
|
-
openxiangda resource validate|plan|publish|pull|typegen|explain [--profile name] [--json]
|
|
157
|
+
openxiangda resource validate|plan|publish|pull|typegen|explain [--profile name] [--json] [--dry-run]
|
|
158
158
|
openxiangda runtime deploy [--profile name] [--dist dist] [--build-id id] [--upload-mode staged|legacy-json] [--upload-timeout-ms ms] [--no-build] [--no-activate] [--json]
|
|
159
159
|
openxiangda runtime releases [--profile name] [--json]
|
|
160
160
|
openxiangda runtime activate <releaseId> [--profile name] [--json]
|
|
@@ -1483,7 +1483,25 @@ async function workspace(args) {
|
|
|
1483
1483
|
profileName,
|
|
1484
1484
|
`/openxiangda-api/v1/apps/${encodeURIComponent(bound.appType)}/snapshot`
|
|
1485
1485
|
);
|
|
1486
|
-
|
|
1486
|
+
const reactSpaWorkspace = isReactSpaWorkspace();
|
|
1487
|
+
if (reactSpaWorkspace && !publishOptions.legacyFormBundle) {
|
|
1488
|
+
if (publishOptions.targetForm && !publishOptions.targetPage && !publishOptions.only && !publishOptions.changed) {
|
|
1489
|
+
runReactSpaFormSchemaPublish(profileName, profile, bound.appType, publishOptions);
|
|
1490
|
+
} else {
|
|
1491
|
+
fail(
|
|
1492
|
+
[
|
|
1493
|
+
'React SPA 工作区不使用 workspace publish 发布前端页面。',
|
|
1494
|
+
'如需发布表单 schema,请运行:',
|
|
1495
|
+
` openxiangda workspace publish --profile ${profileName} --form <formCode>`,
|
|
1496
|
+
'如需发布资源和前端运行时,请运行:',
|
|
1497
|
+
` openxiangda resource publish --profile ${profileName}`,
|
|
1498
|
+
` openxiangda runtime deploy --profile ${profileName}`,
|
|
1499
|
+
].join('\n')
|
|
1500
|
+
);
|
|
1501
|
+
}
|
|
1502
|
+
} else {
|
|
1503
|
+
runWorkspacePublish(profileName, profile, bound.appType, publishOptions.workspaceArgs);
|
|
1504
|
+
}
|
|
1487
1505
|
if (publishOptions.includeResources) {
|
|
1488
1506
|
if (publishOptions.dryRun) {
|
|
1489
1507
|
const manifest = loadWorkspaceResources();
|
|
@@ -3613,14 +3631,14 @@ async function resource(args) {
|
|
|
3613
3631
|
const { subcommand, rest } = parseSubcommandArgs(args);
|
|
3614
3632
|
const { flags, positional } = parseArgs(rest);
|
|
3615
3633
|
if (wantsSubcommandHelp(subcommand, flags)) {
|
|
3616
|
-
print('用法: openxiangda resource validate|plan|publish|pull|typegen|explain [type] [--profile name] [--json]');
|
|
3634
|
+
print('用法: openxiangda resource validate|plan|publish|pull|typegen|explain [type] [--profile name] [--json] [--dry-run]');
|
|
3617
3635
|
return;
|
|
3618
3636
|
}
|
|
3619
3637
|
const config = loadConfig();
|
|
3620
3638
|
const profileName = flags.profile || config.currentProfile;
|
|
3621
3639
|
|
|
3622
3640
|
if (!['validate', 'plan', 'publish', 'pull', 'typegen', 'explain'].includes(subcommand)) {
|
|
3623
|
-
fail('用法: openxiangda resource validate|plan|publish|pull|typegen|explain [--profile name] [--json]');
|
|
3641
|
+
fail('用法: openxiangda resource validate|plan|publish|pull|typegen|explain [--profile name] [--json] [--dry-run]');
|
|
3624
3642
|
}
|
|
3625
3643
|
|
|
3626
3644
|
if (subcommand === 'explain') {
|
|
@@ -3649,7 +3667,10 @@ async function resource(args) {
|
|
|
3649
3667
|
return;
|
|
3650
3668
|
}
|
|
3651
3669
|
|
|
3670
|
+
const target = getWorkspaceTarget(config, profileName, flags);
|
|
3652
3671
|
const validation = validateWorkspaceResources(manifest);
|
|
3672
|
+
validateWorkspaceResourceBindings(manifest, target.bound, validation);
|
|
3673
|
+
await validateCompiledWorkflowResources(manifest, validation);
|
|
3653
3674
|
if (subcommand === 'validate') {
|
|
3654
3675
|
if (flags.json) return writeJson(validation);
|
|
3655
3676
|
printResourceValidation(validation);
|
|
@@ -3662,9 +3683,13 @@ async function resource(args) {
|
|
|
3662
3683
|
fail(`资源配置校验失败: ${validation.errors[0]}`);
|
|
3663
3684
|
}
|
|
3664
3685
|
|
|
3665
|
-
const
|
|
3666
|
-
if (subcommand === 'plan') {
|
|
3686
|
+
const dryRun = subcommand === 'publish' && Boolean(flags['dry-run']);
|
|
3687
|
+
if (subcommand === 'plan' || dryRun) {
|
|
3667
3688
|
const plan = await buildResourcePlan(config, target, manifest);
|
|
3689
|
+
if (dryRun) {
|
|
3690
|
+
plan.dryRun = true;
|
|
3691
|
+
plan.command = 'resource publish --dry-run';
|
|
3692
|
+
}
|
|
3668
3693
|
if (flags.json) return writeJson(plan);
|
|
3669
3694
|
printResourcePlan(plan);
|
|
3670
3695
|
return;
|
|
@@ -5352,6 +5377,49 @@ function validateWorkspaceResources(manifest) {
|
|
|
5352
5377
|
};
|
|
5353
5378
|
}
|
|
5354
5379
|
|
|
5380
|
+
function validateWorkspaceResourceBindings(manifest, bound, validation) {
|
|
5381
|
+
for (const item of manifest.workflows || []) {
|
|
5382
|
+
if (!item.formCode && !item.form) continue;
|
|
5383
|
+
const formCode = item.formCode || item.form;
|
|
5384
|
+
const formBinding = bound?.resources?.forms?.[formCode];
|
|
5385
|
+
const formUuid = formBinding?.formUuid;
|
|
5386
|
+
if (!formUuid) {
|
|
5387
|
+
validation.errors.push(
|
|
5388
|
+
`${resourceLabel('workflow', item)}: formCode ${formCode} 未绑定。请先运行 openxiangda workspace publish --profile <name> --form ${formCode}`
|
|
5389
|
+
);
|
|
5390
|
+
continue;
|
|
5391
|
+
}
|
|
5392
|
+
const localSchemaPath = path.join(process.cwd(), 'src', 'forms', formCode, 'schema.ts');
|
|
5393
|
+
if (fs.existsSync(localSchemaPath) && !formBinding.schemaSyncedAt) {
|
|
5394
|
+
validation.errors.push(
|
|
5395
|
+
`${resourceLabel('workflow', item)}: formCode ${formCode} 已绑定但本地 schema 尚未同步。请先运行 openxiangda workspace publish --profile <name> --form ${formCode}`
|
|
5396
|
+
);
|
|
5397
|
+
}
|
|
5398
|
+
if (formBinding.formType && formBinding.formType !== 'process') {
|
|
5399
|
+
validation.errors.push(
|
|
5400
|
+
`${resourceLabel('workflow', item)}: formCode ${formCode} 当前 formType=${formBinding.formType},流程表单需要 process`
|
|
5401
|
+
);
|
|
5402
|
+
}
|
|
5403
|
+
}
|
|
5404
|
+
validation.valid = validation.errors.length === 0;
|
|
5405
|
+
return validation;
|
|
5406
|
+
}
|
|
5407
|
+
|
|
5408
|
+
async function validateCompiledWorkflowResources(manifest, validation) {
|
|
5409
|
+
for (const item of manifest.workflows || []) {
|
|
5410
|
+
if (!item.workflowFile) continue;
|
|
5411
|
+
try {
|
|
5412
|
+
item.__compiledWorkflow = await compileWorkflowSourceFile(item, {
|
|
5413
|
+
writeFiles: false,
|
|
5414
|
+
});
|
|
5415
|
+
} catch (error) {
|
|
5416
|
+
validation.errors.push(error?.message || String(error));
|
|
5417
|
+
}
|
|
5418
|
+
}
|
|
5419
|
+
validation.valid = validation.errors.length === 0;
|
|
5420
|
+
return validation;
|
|
5421
|
+
}
|
|
5422
|
+
|
|
5355
5423
|
function generateResourceTypes(manifest, outputFile) {
|
|
5356
5424
|
const filePath = path.resolve(outputFile || path.join('src', 'generated', 'openxiangda.gen.ts'));
|
|
5357
5425
|
const menus = (manifest.menus || []).map(item => ({
|
|
@@ -8745,8 +8813,12 @@ function clonePlainJson(value) {
|
|
|
8745
8813
|
|
|
8746
8814
|
function workflowEquals(bound, desired, existing) {
|
|
8747
8815
|
if (!existing) return false;
|
|
8748
|
-
const
|
|
8816
|
+
const compiledWorkflow = desired.__compiledWorkflow;
|
|
8817
|
+
const desiredDefinition =
|
|
8818
|
+
compiledWorkflow?.definitionJson ||
|
|
8819
|
+
resolveManifestPlainJson(desired, 'definitionJson', 'definitionFile');
|
|
8749
8820
|
const desiredView =
|
|
8821
|
+
compiledWorkflow?.previewJson ??
|
|
8750
8822
|
resolveManifestPlainJson(desired, 'viewJson', 'viewFile', true) ??
|
|
8751
8823
|
resolveManifestPlainJson(desired, 'previewJson', 'previewFile', true);
|
|
8752
8824
|
const desiredFormUuid = resolveManifestFormUuid(bound, desired);
|
|
@@ -9638,6 +9710,7 @@ function normalizeWorkspacePublishOptions(flags) {
|
|
|
9638
9710
|
if (since) workspaceArgs.push('--since', since);
|
|
9639
9711
|
if (dryRun) workspaceArgs.push('--dry-run');
|
|
9640
9712
|
if (force) workspaceArgs.push('--force');
|
|
9713
|
+
if (flags['legacy-form-bundle']) workspaceArgs.push('--legacy-form-bundle');
|
|
9641
9714
|
|
|
9642
9715
|
const targeted = Boolean(targetForm || targetPage || only || changed);
|
|
9643
9716
|
const includeResources =
|
|
@@ -9646,6 +9719,11 @@ function normalizeWorkspacePublishOptions(flags) {
|
|
|
9646
9719
|
return {
|
|
9647
9720
|
workspaceArgs,
|
|
9648
9721
|
dryRun,
|
|
9722
|
+
targetForm,
|
|
9723
|
+
targetPage,
|
|
9724
|
+
only,
|
|
9725
|
+
changed,
|
|
9726
|
+
legacyFormBundle: Boolean(flags['legacy-form-bundle']),
|
|
9649
9727
|
includeResources,
|
|
9650
9728
|
quietResourceSkip: !targeted || skipResources,
|
|
9651
9729
|
};
|
|
@@ -9683,6 +9761,43 @@ function runWorkspacePublish(profileName, profile, appType, publishArgs = []) {
|
|
|
9683
9761
|
}
|
|
9684
9762
|
}
|
|
9685
9763
|
|
|
9764
|
+
function isReactSpaWorkspace() {
|
|
9765
|
+
const configFile = path.join(process.cwd(), 'app-workspace.config.ts');
|
|
9766
|
+
if (!fs.existsSync(configFile)) return false;
|
|
9767
|
+
const content = fs.readFileSync(configFile, 'utf8');
|
|
9768
|
+
return /runtimeMode\s*:\s*['"]react-spa['"]/.test(content);
|
|
9769
|
+
}
|
|
9770
|
+
|
|
9771
|
+
function runReactSpaFormSchemaPublish(profileName, profile, appType, publishOptions) {
|
|
9772
|
+
const packageFile = path.join(process.cwd(), 'package.json');
|
|
9773
|
+
if (!fs.existsSync(packageFile)) {
|
|
9774
|
+
fail('当前目录没有 package.json,无法识别工作区发布脚本');
|
|
9775
|
+
}
|
|
9776
|
+
const pkg = JSON.parse(fs.readFileSync(packageFile, 'utf8'));
|
|
9777
|
+
const scripts = pkg.scripts || {};
|
|
9778
|
+
const usePnpm = fs.existsSync(path.join(process.cwd(), 'pnpm-lock.yaml'));
|
|
9779
|
+
const command = usePnpm ? 'pnpm' : 'npm';
|
|
9780
|
+
const syncArgs = ['--form', publishOptions.targetForm];
|
|
9781
|
+
if (publishOptions.dryRun) syncArgs.push('--dry-run');
|
|
9782
|
+
const args = scripts['sync-schema']
|
|
9783
|
+
? ['run', 'sync-schema', '--', ...syncArgs]
|
|
9784
|
+
: usePnpm
|
|
9785
|
+
? ['exec', 'lowcode-workspace', 'sync-schema', ...syncArgs]
|
|
9786
|
+
: ['exec', '--', 'lowcode-workspace', 'sync-schema', ...syncArgs];
|
|
9787
|
+
print(
|
|
9788
|
+
`React SPA 表单 schema 发布${publishOptions.dryRun ? ' (dry-run)' : ''}: ${publishOptions.targetForm}`
|
|
9789
|
+
);
|
|
9790
|
+
const globalEnv = loadGlobalEnv();
|
|
9791
|
+
const result = spawnSync(command, args, {
|
|
9792
|
+
cwd: process.cwd(),
|
|
9793
|
+
stdio: 'inherit',
|
|
9794
|
+
env: buildWorkspacePublishEnv(profileName, profile, appType, globalEnv),
|
|
9795
|
+
});
|
|
9796
|
+
if (result.status !== 0) {
|
|
9797
|
+
process.exit(result.status || 1);
|
|
9798
|
+
}
|
|
9799
|
+
}
|
|
9800
|
+
|
|
9686
9801
|
function buildWorkspacePublishEnv(profileName, profile, appType, globalEnv) {
|
|
9687
9802
|
const env = { ...process.env };
|
|
9688
9803
|
const injectedGlobalKeys = [];
|
package/lib/design-gates.js
CHANGED
|
@@ -498,6 +498,7 @@ const RESOURCE_EXPLAINS = {
|
|
|
498
498
|
enable: true,
|
|
499
499
|
},
|
|
500
500
|
commands: [
|
|
501
|
+
'openxiangda workspace publish --profile <name> --form expense_request',
|
|
501
502
|
'openxiangda workflow compile src/workflows/expense_approval/workflow.ts --check',
|
|
502
503
|
'openxiangda workflow compile src/workflows/expense_approval/workflow.ts --out-definition src/generated/workflows/expense_approval/definition.v3.json --out-preview src/generated/workflows/expense_approval/preview.json',
|
|
503
504
|
'openxiangda resource validate workflow',
|
|
@@ -38,7 +38,7 @@ OpenXiangda supports two workspace modes. Classic `sy-lowcode-app-workspace` pub
|
|
|
38
38
|
|
|
39
39
|
### Hard rules — always
|
|
40
40
|
|
|
41
|
-
- ✅ Publish classic workspaces through `openxiangda workspace publish --profile <name>`; publish React SPA
|
|
41
|
+
- ✅ Publish classic workspaces through `openxiangda workspace publish --profile <name>`; publish React SPA forms first with `openxiangda workspace publish --form <formCode>`, then resources/runtime through `openxiangda resource validate` → `openxiangda resource publish --dry-run` → `openxiangda resource publish` → `openxiangda runtime deploy`.
|
|
42
42
|
- ✅ Architecture-class requests are plan-gated by default. For 新应用、复杂页面、登录注册、公开访问、权限数据范围、流程自动化、连接器/通知、外部集成, first run `openxiangda doctor --json` when a workspace exists and `openxiangda design gates --topic <code> --json`; then ask the user to confirm the design. Before confirmation, only read files, inspect/snapshot, dry-run, ask questions, and write/output design docs. Do not edit source files, write platform resources, send notifications, publish, or deploy.
|
|
43
43
|
- ✅ `runtime deploy` defaults to staged multipart `dist/` uploads plus a final manifest. Use `--upload-mode legacy-json` only for old platform servers.
|
|
44
44
|
- ✅ User token lives in `~/.openxiangda/profiles.json`; project state in `.openxiangda/state.json` (IDs only).
|
|
@@ -162,7 +162,7 @@ When the user provides a root domain such as `https://yida.wisejob.cn/`, use it
|
|
|
162
162
|
- Use JS_CODE for node-local cross-form data queries, create/update/batch update operations, process termination, platform API calls, external HTTP calls, and backend trigger orchestration. For logic that pages, automations, and workflows should reuse through a stable backend entry, prefer App Function. Do not use JS_CODE for simple UI interactions, ordinary form validation, or display-only page behavior.
|
|
163
163
|
- For workflow/automation JS_CODE nodes, prefer V2 `runtimeMode: "trusted_node"`. AI-authored source must be TypeScript under `src/js-code-nodes/<scriptCode>/index.ts`, `src/automations/<resourceCode>/index.ts`, or `src/functions/<functionCode>/index.ts`. `pnpm build-js-code --script <scriptCode>` runs TypeScript validation before bundling, and `sourceFile.localPath` should point to the TS source; the CLI builds, uploads, and replaces it with snapshot metadata during validate/create.
|
|
164
164
|
- Form permission group resources must have stable local codes. Use unique `code` values such as `ticket_reporter_view` and `ticket_repairer_view`; do not rely on the form code when one form has multiple groups.
|
|
165
|
-
- Workflow resources should prefer `workflowFile` + `defineWorkflow` semantic DSL over hand-written raw JSON.
|
|
165
|
+
- Workflow resources should prefer `workflowFile` + `defineWorkflow` semantic DSL over hand-written raw JSON. For workflows bound by `formCode`, run `openxiangda workspace publish --form <formCode>` first so the process form schema/table is initialized, then run `openxiangda workflow compile <workflow.ts> --check` and `openxiangda resource publish --dry-run --profile <name>` before publish; use `sdk.process.resolveCapabilities(...)` or `ProcessActionBar` / `ProcessTimeline` from `openxiangda/runtime/react` for runtime buttons and timelines instead of hard-coded operation lists.
|
|
166
166
|
- Workflow resources can be created as drafts. After resource publish, verify `openxiangda workflow list --profile <name> --json` and run `openxiangda workflow publish <workflowCode> --profile <name>` until `isPublished: true` is visible.
|
|
167
167
|
|
|
168
168
|
## Subskills
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
```bash
|
|
19
19
|
openxiangda resource validate --profile <name> # 静态校验所有 manifest
|
|
20
20
|
openxiangda resource plan --profile <name> # diff:本地 vs. 平台
|
|
21
|
+
openxiangda resource publish --profile <name> --dry-run # 预览 publish 计划,不写平台和本地生成文件
|
|
21
22
|
openxiangda resource publish --profile <name> # 非破坏性 upsert(不 prune)
|
|
22
23
|
openxiangda resource publish --profile <name> --prune # 删除 manifest 未声明的平台资源(谨慎)
|
|
23
24
|
openxiangda resource pull --profile <name> # 拉取平台资源回写到本地(用于初次同步)
|
|
@@ -92,7 +92,7 @@ Resource manifest:
|
|
|
92
92
|
}
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
During `openxiangda resource publish`, the CLI compiles `workflowFile`, writes `definitionFile` and `previewFile` when configured, sends v3 `definitionJson` to the backend, and stores the preview in `viewJson` for read-only frontend display.
|
|
95
|
+
During `openxiangda resource validate`, `resource plan`, and `resource publish --dry-run`, the CLI compiles `workflowFile` without writing generated files or platform resources. During real `openxiangda resource publish`, the CLI compiles `workflowFile`, writes `definitionFile` and `previewFile` when configured, sends v3 `definitionJson` to the backend, and stores the preview in `viewJson` for read-only frontend display.
|
|
96
96
|
|
|
97
97
|
Compile locally before publishing:
|
|
98
98
|
|
|
@@ -37,8 +37,10 @@ openxiangda workspace publish --profile <name>
|
|
|
37
37
|
For Phase 6 React SPA workspaces (`workspace init --runtime react-spa`), do not use `workspace publish` for frontend routes. Publish in two explicit steps:
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
|
+
openxiangda workspace publish --profile <name> --form <formCode> # required for forms/workflows
|
|
40
41
|
openxiangda resource validate --profile <name>
|
|
41
42
|
openxiangda resource plan --profile <name>
|
|
43
|
+
openxiangda resource publish --profile <name> --dry-run
|
|
42
44
|
openxiangda resource publish --profile <name>
|
|
43
45
|
openxiangda runtime deploy --profile <name>
|
|
44
46
|
```
|
|
@@ -78,7 +78,7 @@ openxiangda form bind customer --form-uuid FORM_XXX --profile dev
|
|
|
78
78
|
"publish": true
|
|
79
79
|
}
|
|
80
80
|
```
|
|
81
|
-
Then run `openxiangda resource validate
|
|
81
|
+
Then run `openxiangda resource validate --profile dev`, `openxiangda resource publish --profile dev --dry-run`, and finally `openxiangda resource publish --profile dev`.
|
|
82
82
|
4. For low-level repair, validate compiled or pulled JSON:
|
|
83
83
|
```bash
|
|
84
84
|
openxiangda workflow validate --definition-json workflow.json --publish --profile dev
|
package/package.json
CHANGED
|
@@ -31,6 +31,40 @@ function sanitizeId(value) {
|
|
|
31
31
|
function createPosition(index) {
|
|
32
32
|
return { x: 400, y: 100 + index * 150 };
|
|
33
33
|
}
|
|
34
|
+
function hasRequiredValue(value) {
|
|
35
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
36
|
+
return value !== void 0 && value !== null && String(value).trim() !== "";
|
|
37
|
+
}
|
|
38
|
+
function validateCompiledWorkflowDefinition(definitionJson) {
|
|
39
|
+
const errors = [];
|
|
40
|
+
for (const node of definitionJson.nodes || []) {
|
|
41
|
+
const nodeId = node?.id || "<unknown>";
|
|
42
|
+
const data = node?.data || {};
|
|
43
|
+
switch (node?.type) {
|
|
44
|
+
case "function_call":
|
|
45
|
+
if (!hasRequiredValue(data.functionCode)) {
|
|
46
|
+
errors.push(`function_call node ${nodeId} requires functionCode`);
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
case "callback_wait":
|
|
50
|
+
if (!hasRequiredValue(data.eventCode)) {
|
|
51
|
+
errors.push(`callback_wait node ${nodeId} requires eventCode`);
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
case "work_notification":
|
|
55
|
+
if (!hasRequiredValue(data.title) || !hasRequiredValue(data.content) || !hasRequiredValue(data.recipientType)) {
|
|
56
|
+
errors.push(`work_notification node ${nodeId} requires title, content, and recipientType`);
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (errors.length > 0) {
|
|
64
|
+
throw new Error(`workflow DSL validation failed:
|
|
65
|
+
- ${errors.join("\n- ")}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
34
68
|
function normalizeAction(action, label, extra = {}) {
|
|
35
69
|
return {
|
|
36
70
|
action,
|
|
@@ -266,7 +300,7 @@ var WorkflowBuilder = class {
|
|
|
266
300
|
functionCall(id, data) {
|
|
267
301
|
return this.node("function_call", id, {
|
|
268
302
|
label: data.label || "\u8C03\u7528\u51FD\u6570",
|
|
269
|
-
functionCode: data.functionCode || data.code,
|
|
303
|
+
functionCode: data.functionCode || data.functionName || data.code,
|
|
270
304
|
input: data.input || data.inputMapping || {},
|
|
271
305
|
saveResponseTo: data.saveResponseTo || data.outputKey,
|
|
272
306
|
timeout: data.timeout || data.timeoutMs || 3e4,
|
|
@@ -453,14 +487,16 @@ var WorkflowBuilder = class {
|
|
|
453
487
|
this.globalSettings = { ...this.globalSettings, ...settings };
|
|
454
488
|
}
|
|
455
489
|
compile() {
|
|
490
|
+
const definitionJson = {
|
|
491
|
+
version: "v3",
|
|
492
|
+
nodes: this.nodes,
|
|
493
|
+
edges: this.edges,
|
|
494
|
+
flowConfig: this.flowConfig,
|
|
495
|
+
globalSettings: this.globalSettings
|
|
496
|
+
};
|
|
497
|
+
validateCompiledWorkflowDefinition(definitionJson);
|
|
456
498
|
return {
|
|
457
|
-
definitionJson
|
|
458
|
-
version: "v3",
|
|
459
|
-
nodes: this.nodes,
|
|
460
|
-
edges: this.edges,
|
|
461
|
-
flowConfig: this.flowConfig,
|
|
462
|
-
globalSettings: this.globalSettings
|
|
463
|
-
},
|
|
499
|
+
definitionJson,
|
|
464
500
|
previewJson: {
|
|
465
501
|
kind: "workflow_code_preview",
|
|
466
502
|
version: "preview_v1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/workflow/index.ts"],"sourcesContent":["export type WorkflowNodeRef = string;\n\nexport interface WorkflowCompileResult {\n definitionJson: {\n version: \"v3\";\n nodes: any[];\n edges: any[];\n flowConfig: Record<string, any[]>;\n globalSettings: Record<string, any>;\n };\n previewJson: {\n kind: \"workflow_code_preview\";\n version: \"preview_v1\";\n steps: any[];\n edges: any[];\n sourceMode: \"workflow_code_ts\";\n };\n}\n\nexport interface WorkflowDefinitionInput {\n name?: string;\n formCode?: string;\n formUuid?: string;\n globalSettings?: Record<string, any>;\n build: (flow: WorkflowBuilder) => void;\n}\n\nexport interface WorkflowDeclarativeInput {\n id?: string;\n name?: string;\n formCode?: string;\n formUuid?: string;\n globalSettings?: Record<string, any>;\n nodes: WorkflowDeclarativeNode[];\n edges?: WorkflowDeclarativeEdge[];\n}\n\nexport interface WorkflowDeclarativeNode {\n __openxiangdaWorkflowNode: true;\n id: WorkflowNodeRef;\n type: string;\n data: NodeOptions;\n}\n\nexport interface WorkflowDeclarativeEdge {\n __openxiangdaWorkflowEdge: true;\n source: WorkflowNodeRef;\n target: WorkflowNodeRef;\n data?: NodeOptions;\n}\n\ntype NodeOptions = Record<string, any>;\n\nfunction sanitizeId(value: string) {\n return String(value || \"\")\n .trim()\n .replace(/[^a-zA-Z0-9_-]/g, \"_\");\n}\n\nfunction createPosition(index: number) {\n return { x: 400, y: 100 + index * 150 };\n}\n\nfunction normalizeAction(action: string, label: string, extra: NodeOptions = {}) {\n return {\n action,\n name: { zh_CN: label },\n ...extra,\n };\n}\n\nconst workflowActions = {\n approve: (label = \"同意\", extra: NodeOptions = {}) =>\n normalizeAction(\"agree\", label, extra),\n reject: (label = \"拒绝\", extra: NodeOptions = {}) =>\n normalizeAction(\"rejected\", label, extra),\n transfer: (label = \"转交\", extra: NodeOptions = {}) =>\n normalizeAction(\"transfer\", label, {\n remark: { popUp: true, required: false },\n ...extra,\n }),\n return: (label = \"退回\", extra: NodeOptions = {}) =>\n normalizeAction(\"return\", label, {\n remark: { popUp: true, required: false },\n ...extra,\n }),\n returnToInitiator: (label = \"退回发起人\", extra: NodeOptions = {}) =>\n normalizeAction(\"return\", label, {\n remark: { popUp: true, required: false },\n returnTarget: \"initiator\",\n returnScope: \"initiator\",\n ...extra,\n }),\n save: (label = \"暂存\", extra: NodeOptions = {}) =>\n normalizeAction(\"save\", label, extra),\n withdraw: (label = \"撤回\", extra: NodeOptions = {}) =>\n normalizeAction(\"withdraw\", label, extra),\n resubmit: (label = \"重新提交\", extra: NodeOptions = {}) =>\n normalizeAction(\"resubmit\", label, extra),\n callback: (label = \"触发回调\", extra: NodeOptions = {}) =>\n normalizeAction(\"callback\", label, extra),\n retryException: (label = \"重试异常\", extra: NodeOptions = {}) =>\n normalizeAction(\"retryException\", label, extra),\n adminTransfer: (label = \"管理员转交\", extra: NodeOptions = {}) =>\n normalizeAction(\"adminTransfer\", label, extra),\n};\n\nfunction normalizeReturnConfig(value: any) {\n if (value === false) return { enabled: false };\n if (value === true || value === undefined) {\n return { enabled: true, scopeType: \"previous_all\" };\n }\n return {\n enabled: value.enabled !== false,\n scopeType: value.scopeType || value.scope || \"previous_all\",\n resubmitMode: value.resubmitMode || \"resume_current\",\n ...value,\n };\n}\n\nfunction findInitiatorReturnAction(actions: any[]) {\n return actions.find(\n (action) =>\n action?.action === \"return\" &&\n (action.returnTarget === \"initiator\" || action.returnScope === \"initiator\"),\n );\n}\n\nfunction inferReturnConfigFromActions(actions: any[], explicitReturnConfig?: any) {\n const initiatorReturnAction = findInitiatorReturnAction(actions);\n if (!initiatorReturnAction) return explicitReturnConfig;\n\n const base =\n explicitReturnConfig ||\n normalizeReturnConfig({\n scopeType: \"previous_all\",\n resubmitMode: initiatorReturnAction.resubmitMode || \"replay\",\n });\n\n return {\n ...base,\n allowOriginatorReturn: true,\n };\n}\n\nfunction normalizeFieldBehavior(value: any) {\n const normalized = String(value || \"\").trim().toLowerCase();\n if ([\"normal\", \"edit\", \"editable\", \"write\", \"writable\"].includes(normalized)) return \"NORMAL\";\n if ([\"readonly\", \"read\", \"view\", \"visible\"].includes(normalized)) return \"READONLY\";\n if ([\"hidden\", \"hide\", \"invisible\"].includes(normalized)) return \"HIDDEN\";\n return String(value || \"READONLY\").toUpperCase();\n}\n\nfunction normalizeFieldPermissions(value: any): any[] | undefined {\n if (Array.isArray(value)) {\n return value.map((item) => {\n if (!item || typeof item !== \"object\") return item;\n return {\n ...item,\n fieldId: item.fieldId || item.field || item.id,\n fieldBehavior: normalizeFieldBehavior(item.fieldBehavior || item.behavior || item.permission),\n };\n });\n }\n if (value && typeof value === \"object\") {\n return Object.entries(value).map(([fieldId, fieldBehavior]) => ({\n fieldId,\n fieldBehavior: normalizeFieldBehavior(fieldBehavior),\n }));\n }\n return undefined;\n}\n\nfunction createDeclarativeNode(\n type: string,\n id: string,\n data: NodeOptions = {},\n): WorkflowDeclarativeNode {\n return {\n __openxiangdaWorkflowNode: true,\n id: sanitizeId(id),\n type,\n data,\n };\n}\n\nfunction createDeclarativeEdge(\n source: WorkflowNodeRef,\n target: WorkflowNodeRef,\n data: NodeOptions = {},\n): WorkflowDeclarativeEdge {\n return {\n __openxiangdaWorkflowEdge: true,\n source,\n target,\n data,\n };\n}\n\nfunction isDeclarativeInput(input: any): input is WorkflowDeclarativeInput {\n return input && Array.isArray(input.nodes);\n}\n\nfunction isWorkflowNodeDescriptor(value: any): value is WorkflowDeclarativeNode {\n return Boolean(value?.__openxiangdaWorkflowNode);\n}\n\nfunction normalizeAssignee(value: any) {\n if (typeof value === \"string\") {\n return { type: value === \"originator\" ? \"originator\" : \"user\", id: value, name: value };\n }\n return value || {};\n}\n\nfunction normalizeApprovalData(data: NodeOptions = {}) {\n const normalized: NodeOptions = { ...data };\n const assignees = Array.isArray(data.assignees)\n ? data.assignees.map(normalizeAssignee)\n : undefined;\n\n if (assignees && !normalized.approverType) {\n const supervisor = assignees.find((item) => item.type === \"department_supervisor\");\n const initiatorSelect = assignees.find((item) => item.type === \"initiator_select\");\n const roleAssignees = assignees.filter((item) => item.type === \"role\");\n const userAssignees = assignees.filter((item) => item.type === \"user\" || item.type === \"originator\");\n\n if (supervisor) {\n normalized.approverType = \"ext_target_approval_department_supervisor\";\n normalized.supervisorConfig = {\n level: supervisor.level || 1,\n fallbackToAncestorSupervisor: supervisor.fallbackToAncestorSupervisor !== false,\n ...(normalized.supervisorConfig || {}),\n };\n normalized.approvals = normalized.approvals || [];\n normalized.approvalNames = normalized.approvalNames || [];\n } else if (initiatorSelect) {\n normalized.approverType = \"ext_target_approval_initiator_select\";\n normalized.initiatorSelectScope = initiatorSelect.scope || initiatorSelect.initiatorSelectScope || \"all\";\n normalized.approvals =\n normalized.approvals ||\n (Array.isArray(initiatorSelect.approvals)\n ? initiatorSelect.approvals\n : roleAssignees.map((item) => item.id).filter(Boolean));\n normalized.approvalNames =\n normalized.approvalNames ||\n (Array.isArray(initiatorSelect.approvalNames)\n ? initiatorSelect.approvalNames\n : roleAssignees.map((item) => item.name || item.id).filter(Boolean));\n } else if (roleAssignees.length > 0 && userAssignees.length === 0) {\n normalized.approverType = \"ext_target_approval_role\";\n normalized.approvals = normalized.approvals || roleAssignees.map((item) => item.id).filter(Boolean);\n normalized.approvalNames =\n normalized.approvalNames || roleAssignees.map((item) => item.name || item.id).filter(Boolean);\n } else {\n normalized.approverType = \"ext_target_approval\";\n normalized.approvals =\n normalized.approvals ||\n userAssignees\n .map((item) => (item.type === \"originator\" ? \"originator\" : item.id))\n .filter(Boolean);\n normalized.approvalNames =\n normalized.approvalNames ||\n userAssignees\n .map((item) => item.name || (item.type === \"originator\" ? \"发起人\" : item.id))\n .filter(Boolean);\n }\n }\n\n return normalized;\n}\n\nexport class WorkflowBuilder {\n private nodes: any[] = [];\n private edges: any[] = [];\n private flowConfig: Record<string, any[]> = {};\n private globalSettings: Record<string, any> = {};\n readonly action = workflowActions;\n\n constructor(private readonly meta: Omit<WorkflowDefinitionInput, \"build\"> = {}) {\n this.globalSettings = { ...(meta.globalSettings || {}) };\n }\n\n start(id = \"start\", data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"start\", id, { label: \"开始节点\", ...data });\n }\n\n end(id = \"end\", data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"end\", id, { label: \"结束节点\", ...data });\n }\n\n approval(id: string, data: NodeOptions): WorkflowNodeRef {\n const approvalData = normalizeApprovalData(data);\n const actions =\n approvalData.buttons || approvalData.actions || [\n this.action.approve(),\n this.action.reject(),\n ];\n const returnConfig =\n approvalData.returnConfig !== undefined\n ? normalizeReturnConfig(approvalData.returnConfig)\n : approvalData.returnPolicy !== undefined\n ? normalizeReturnConfig(approvalData.returnPolicy)\n : undefined;\n const inferredReturnConfig = inferReturnConfigFromActions(actions, returnConfig);\n return this.node(\"approval\", id, {\n label: approvalData.label || \"审批\",\n value: approvalData.value || \"\",\n approverType: approvalData.approverType || \"ext_target_approval\",\n approvals: approvalData.approvals || [],\n approvalNames: approvalData.approvalNames || [],\n multiApprove: approvalData.multiApprove || \"or\",\n ...approvalData,\n actions,\n ...(inferredReturnConfig ? { returnConfig: inferredReturnConfig } : {}),\n });\n }\n\n copy(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"copy\", id, {\n label: data.label || \"抄送\",\n value: data.value || \"\",\n approverType: data.approverType || \"ext_target_approval\",\n approvals: data.approvals || [],\n approvalNames: data.approvalNames || [],\n ...data,\n });\n }\n\n jsCode(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"js_code\", id, {\n label: data.label || \"JS代码节点\",\n runtimeMode: \"trusted_node\",\n sourceType: data.sourceFile ? \"file_snapshot\" : data.sourceType || \"inline\",\n timeout: data.timeout || data.timeoutMs || 30000,\n ...data,\n });\n }\n\n functionCall(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"function_call\", id, {\n label: data.label || \"调用函数\",\n functionCode: data.functionCode || data.code,\n input: data.input || data.inputMapping || {},\n saveResponseTo: data.saveResponseTo || data.outputKey,\n timeout: data.timeout || data.timeoutMs || 30000,\n ...data,\n });\n }\n\n callbackWait(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"callback_wait\", id, {\n type: \"callback_wait\",\n label: data.label || \"回调等待\",\n timeoutSeconds: data.timeoutSeconds || 86400,\n timeoutStrategy: data.timeoutStrategy || \"FAIL\",\n ...data,\n });\n }\n\n connectorCall(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"connector_call\", id, {\n type: \"connector_call\",\n label: data.label || \"连接器\",\n timeout: data.timeout || 30000,\n ...data,\n });\n }\n\n workNotification(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"work_notification\", id, {\n label: data.label || \"工作通知\",\n buttonText: data.buttonText || \"查看详情\",\n linkType: data.linkType || \"current_form\",\n ...data,\n });\n }\n\n notification(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.workNotification(id, data);\n }\n\n dingtalkCard(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"dingtalk_card\", id, {\n config: {\n type: \"dingtalk_card\",\n label: data.label || \"钉钉消息卡片\",\n sameFieldStrategy: \"create\",\n ...(data.config || data),\n },\n });\n }\n\n condition(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"condition_branch\", id, {\n type: \"condition_branch\",\n label: data.label || \"条件分支\",\n condition: data.condition || { ruleType: \"group\", condition: \"AND\", rules: [] },\n isElse: data.isElse === true,\n priority: data.priority || \"1\",\n trueNodeId: data.trueNodeId,\n falseNodeId: data.falseNodeId,\n ...data,\n });\n }\n\n branch(id: string, data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"branch\", id, {\n label: data.label || \"辅助分支\",\n isAuxNode: data.isAuxNode ?? true,\n branchType: data.branchType || \"controller\",\n ...data,\n });\n }\n\n parallel(\n id: string,\n branches: Array<{\n id: string;\n label?: string;\n nodes: WorkflowNodeRef[];\n }>,\n data: NodeOptions = {},\n ) {\n const entry = this.branch(`${id}_branch`, {\n label: data.label || \"并行分支\",\n branchType: \"parallel_controller\",\n hidden: true,\n });\n const converge = this.branch(`${id}_converge`, {\n label: data.convergeLabel || \"并行汇聚\",\n branchType: \"converge\",\n hidden: true,\n });\n\n branches.forEach((branch, index) => {\n const nodes = branch.nodes.filter(Boolean);\n if (nodes.length === 0) return;\n this.edge(entry, nodes[0], {\n id: `edge_${entry}_${sanitizeId(branch.id || String(index))}`,\n label: branch.label,\n });\n this.sequence(...nodes);\n this.edge(nodes[nodes.length - 1], converge, {\n id: `edge_${sanitizeId(branch.id || String(index))}_${converge}`,\n });\n });\n\n return { entry, converge };\n }\n\n conditionBranches(\n id: string,\n branches: Array<{\n id: string;\n label?: string;\n condition?: any;\n nodes: WorkflowNodeRef[];\n isElse?: boolean;\n }>,\n data: NodeOptions = {},\n ) {\n const entry = this.branch(`${id}_controller`, {\n label: data.label || \"条件分支\",\n branchType: \"condition_controller\",\n hidden: true,\n });\n const converge = this.branch(`${id}_converge`, {\n label: data.convergeLabel || \"条件汇聚\",\n branchType: \"converge\",\n hidden: true,\n });\n\n branches.forEach((branch, index) => {\n const condition = this.condition(`${id}_${branch.id}`, {\n label: branch.label || (branch.isElse ? \"其他情况\" : `条件 ${index + 1}`),\n condition:\n branch.condition || {\n ruleType: \"group\",\n condition: \"AND\",\n rules: [],\n },\n isElse: branch.isElse === true,\n priority: String(index + 1),\n });\n this.edge(entry, condition, {\n id: `edge_${entry}_${condition}`,\n label: branch.label,\n });\n const nodes = branch.nodes.filter(Boolean);\n if (nodes.length > 0) {\n this.edge(condition, nodes[0], {\n id: `edge_${condition}_${nodes[0]}`,\n label: branch.label,\n });\n this.sequence(...nodes);\n this.edge(nodes[nodes.length - 1], converge, {\n id: `edge_${nodes[nodes.length - 1]}_${converge}`,\n });\n } else {\n this.edge(condition, converge, {\n id: `edge_${condition}_${converge}`,\n });\n }\n });\n\n if (!branches.some((branch) => branch.isElse)) {\n const elseNode = this.condition(`${id}_else`, {\n label: \"其他情况\",\n isElse: true,\n priority: String(branches.length + 1),\n condition: { ruleType: \"group\", condition: \"AND\", rules: [] },\n });\n this.edge(entry, elseNode, { id: `edge_${entry}_${elseNode}`, label: \"其他情况\" });\n this.edge(elseNode, converge, { id: `edge_${elseNode}_${converge}` });\n }\n\n return { entry, converge };\n }\n\n data = {\n retrieveSingle: (id: string, data: NodeOptions) =>\n this.node(\"data_retrieve_single\", id, {\n type: \"data_retrieve_single\",\n label: data.label || \"获取单条数据\",\n filterType: data.filterType || \"condition\",\n ...data,\n }),\n retrieveBatch: (id: string, data: NodeOptions) =>\n this.node(\"data_retrieve_batch\", id, {\n type: \"data_retrieve_batch\",\n label: data.label || \"获取多条数据\",\n filterType: data.filterType || \"condition\",\n ...data,\n }),\n create: (id: string, data: NodeOptions) =>\n this.node(\"data_create\", id, {\n type: \"data_create\",\n label: data.label || \"新增数据\",\n insertType: data.insertType || \"form\",\n assignments: data.assignments || [],\n ...data,\n }),\n update: (id: string, data: NodeOptions) =>\n this.node(\"data_update\", id, {\n type: \"data_update\",\n label: data.label || \"更新数据\",\n updateType: data.updateType || \"direct_form\",\n assignments: data.assignments || [],\n noneOperation: data.noneOperation || \"ignored\",\n ...data,\n }),\n };\n\n node(type: string, id: string, data: NodeOptions): WorkflowNodeRef {\n const nodeId = sanitizeId(id);\n if (!nodeId) throw new Error(\"workflow node id is required\");\n if (this.nodes.some((node) => node.id === nodeId)) {\n throw new Error(`duplicate workflow node id: ${nodeId}`);\n }\n this.nodes.push({\n id: nodeId,\n type,\n data,\n position: createPosition(this.nodes.length),\n });\n const fieldPermissions = normalizeFieldPermissions(data.fieldPermissions);\n if (fieldPermissions) {\n this.flowConfig[nodeId] = fieldPermissions;\n }\n return nodeId;\n }\n\n edge(source: WorkflowNodeRef, target: WorkflowNodeRef, data: NodeOptions = {}) {\n const id = data.id || `edge_${source}_${target}`;\n this.edges.push({\n id,\n source,\n target,\n type: data.type || \"custom\",\n ...(data.label ? { label: data.label } : {}),\n });\n }\n\n connect(source: WorkflowNodeRef, target: WorkflowNodeRef, data: NodeOptions = {}) {\n this.edge(source, target, data);\n }\n\n sequence(...refs: WorkflowNodeRef[]) {\n for (let index = 0; index < refs.length - 1; index += 1) {\n this.edge(refs[index], refs[index + 1]);\n }\n }\n\n setFieldPermissions(nodeId: WorkflowNodeRef, permissions: any[]) {\n this.flowConfig[nodeId] = permissions;\n }\n\n setGlobalSettings(settings: Record<string, any>) {\n this.globalSettings = { ...this.globalSettings, ...settings };\n }\n\n compile(): WorkflowCompileResult {\n return {\n definitionJson: {\n version: \"v3\",\n nodes: this.nodes,\n edges: this.edges,\n flowConfig: this.flowConfig,\n globalSettings: this.globalSettings,\n },\n previewJson: {\n kind: \"workflow_code_preview\",\n version: \"preview_v1\",\n sourceMode: \"workflow_code_ts\",\n steps: this.nodes.map((node) => ({\n id: node.id,\n type: node.type,\n label: node.data?.label || node.id,\n config: node.data,\n })),\n edges: this.edges.map((edge) => ({\n source: edge.source,\n target: edge.target,\n label: edge.label,\n })),\n },\n };\n }\n}\n\nexport function defineWorkflow(input: WorkflowDefinitionInput) {\n return {\n __openxiangdaWorkflow: true,\n compile() {\n const builder = new WorkflowBuilder(input);\n input.build(builder);\n return builder.compile();\n },\n };\n}\n\nfunction addDeclarativeNode(builder: WorkflowBuilder, node: WorkflowDeclarativeNode) {\n if (!isWorkflowNodeDescriptor(node)) {\n throw new Error(\"workflow declarative nodes must be created by flow.* helpers\");\n }\n\n switch (node.type) {\n case \"start\":\n builder.start(node.id, node.data);\n return;\n case \"end\":\n builder.end(node.id, node.data);\n return;\n case \"approval\":\n builder.approval(node.id, node.data);\n return;\n case \"copy\":\n builder.copy(node.id, node.data);\n return;\n case \"js_code\":\n builder.jsCode(node.id, node.data);\n return;\n case \"function_call\":\n builder.functionCall(node.id, node.data);\n return;\n case \"callback_wait\":\n builder.callbackWait(node.id, node.data);\n return;\n case \"connector_call\":\n builder.connectorCall(node.id, node.data);\n return;\n case \"work_notification\":\n builder.workNotification(node.id, node.data);\n return;\n case \"condition_branch\":\n builder.condition(node.id, node.data);\n return;\n case \"branch\": {\n builder.branch(node.id, node.data);\n const branches = Array.isArray(node.data?.branches) ? node.data.branches : [];\n branches.forEach((branch: any, index: number) => {\n const conditionId = sanitizeId(`${node.id}_${branch.id || index + 1}`);\n builder.condition(conditionId, {\n label: branch.label || (branch.else || branch.isElse ? \"其他情况\" : `条件 ${index + 1}`),\n condition:\n branch.condition || {\n ruleType: \"group\",\n condition: \"AND\",\n rules: [],\n },\n isElse: branch.else === true || branch.isElse === true,\n priority: String(index + 1),\n });\n builder.edge(node.id, conditionId, {\n id: `edge_${node.id}_${conditionId}`,\n label: branch.label,\n });\n if (branch.next) {\n builder.edge(conditionId, sanitizeId(branch.next), {\n id: `edge_${conditionId}_${sanitizeId(branch.next)}`,\n label: branch.label,\n });\n }\n });\n return;\n }\n default:\n builder.node(node.type, node.id, node.data);\n }\n}\n\nfunction defineDeclarativeWorkflow(input: WorkflowDeclarativeInput) {\n return {\n __openxiangdaWorkflow: true,\n compile() {\n const builder = new WorkflowBuilder(input);\n input.nodes.forEach((node) => addDeclarativeNode(builder, node));\n (input.edges || []).forEach((edge) => {\n builder.edge(edge.source, edge.target, edge.data || {});\n });\n return builder.compile();\n },\n };\n}\n\nexport const flow = {\n define(input: WorkflowDefinitionInput | WorkflowDeclarativeInput) {\n if (isDeclarativeInput(input)) {\n return defineDeclarativeWorkflow(input);\n }\n return defineWorkflow(input);\n },\n action: workflowActions,\n assignee: {\n user: (id: string, name?: string) => ({ type: \"user\", id, name: name || id }),\n initiator: () => ({ type: \"originator\", id: \"originator\", name: \"发起人\" }),\n role: (id: string, name?: string) => ({ type: \"role\", id, name: name || id }),\n departmentSupervisor: (\n level = 1,\n extra: NodeOptions = {},\n ) => ({ type: \"department_supervisor\", level, ...extra }),\n initiatorSelect: (\n scope: \"all\" | \"members\" | \"roles\" = \"all\",\n extra: NodeOptions = {},\n ) => ({ type: \"initiator_select\", scope, ...extra }),\n },\n start: (id = \"start\", data: NodeOptions = {}) =>\n createDeclarativeNode(\"start\", id, data),\n end: (id = \"end\", data: NodeOptions = {}) =>\n createDeclarativeNode(\"end\", id, data),\n approval: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"approval\", id, data),\n copy: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"copy\", id, data),\n jsCode: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"js_code\", id, data),\n functionCall: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"function_call\", id, data),\n callbackWait: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"callback_wait\", id, data),\n connectorCall: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"connector_call\", id, data),\n workNotification: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"work_notification\", id, data),\n notification: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"work_notification\", id, data),\n condition: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"condition_branch\", id, data),\n branch: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"branch\", id, data),\n data: {\n retrieveSingle: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_retrieve_single\", id, data),\n retrieveBatch: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_retrieve_batch\", id, data),\n create: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_create\", id, data),\n update: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_update\", id, data),\n },\n connect: createDeclarativeEdge,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqDA,SAAS,WAAW,OAAe;AACjC,SAAO,OAAO,SAAS,EAAE,EACtB,KAAK,EACL,QAAQ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AI;AAAA,IACvD,QAAQ,CAAC,IAAY,OAAoB,CAAC,MACxC,sBAAsB,eAAe,IAAI,IAAI;AAAA,IAC/C,QAAQ,CAAC,IAAY,OAAoB,CAAC,MACxC,sBAAsB,eAAe,IAAI,IAAI;AAAA,EACjD;AAAA,EACA,SAAS;AACX;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/workflow/index.ts"],"sourcesContent":["export type WorkflowNodeRef = string;\n\nexport interface WorkflowCompileResult {\n definitionJson: {\n version: \"v3\";\n nodes: any[];\n edges: any[];\n flowConfig: Record<string, any[]>;\n globalSettings: Record<string, any>;\n };\n previewJson: {\n kind: \"workflow_code_preview\";\n version: \"preview_v1\";\n steps: any[];\n edges: any[];\n sourceMode: \"workflow_code_ts\";\n };\n}\n\nexport interface WorkflowDefinitionInput {\n name?: string;\n formCode?: string;\n formUuid?: string;\n globalSettings?: Record<string, any>;\n build: (flow: WorkflowBuilder) => void;\n}\n\nexport interface WorkflowDeclarativeInput {\n id?: string;\n name?: string;\n formCode?: string;\n formUuid?: string;\n globalSettings?: Record<string, any>;\n nodes: WorkflowDeclarativeNode[];\n edges?: WorkflowDeclarativeEdge[];\n}\n\nexport interface WorkflowDeclarativeNode {\n __openxiangdaWorkflowNode: true;\n id: WorkflowNodeRef;\n type: string;\n data: NodeOptions;\n}\n\nexport interface WorkflowDeclarativeEdge {\n __openxiangdaWorkflowEdge: true;\n source: WorkflowNodeRef;\n target: WorkflowNodeRef;\n data?: NodeOptions;\n}\n\ntype NodeOptions = Record<string, any>;\n\nfunction sanitizeId(value: string) {\n return String(value || \"\")\n .trim()\n .replace(/[^a-zA-Z0-9_-]/g, \"_\");\n}\n\nfunction createPosition(index: number) {\n return { x: 400, y: 100 + index * 150 };\n}\n\nfunction hasRequiredValue(value: any) {\n if (Array.isArray(value)) return value.length > 0;\n return value !== undefined && value !== null && String(value).trim() !== \"\";\n}\n\nfunction validateCompiledWorkflowDefinition(definitionJson: WorkflowCompileResult[\"definitionJson\"]) {\n const errors: string[] = [];\n for (const node of definitionJson.nodes || []) {\n const nodeId = node?.id || \"<unknown>\";\n const data = node?.data || {};\n switch (node?.type) {\n case \"function_call\":\n if (!hasRequiredValue(data.functionCode)) {\n errors.push(`function_call node ${nodeId} requires functionCode`);\n }\n break;\n case \"callback_wait\":\n if (!hasRequiredValue(data.eventCode)) {\n errors.push(`callback_wait node ${nodeId} requires eventCode`);\n }\n break;\n case \"work_notification\":\n if (\n !hasRequiredValue(data.title) ||\n !hasRequiredValue(data.content) ||\n !hasRequiredValue(data.recipientType)\n ) {\n errors.push(`work_notification node ${nodeId} requires title, content, and recipientType`);\n }\n break;\n default:\n break;\n }\n }\n if (errors.length > 0) {\n throw new Error(`workflow DSL validation failed:\\n- ${errors.join(\"\\n- \")}`);\n }\n}\n\nfunction normalizeAction(action: string, label: string, extra: NodeOptions = {}) {\n return {\n action,\n name: { zh_CN: label },\n ...extra,\n };\n}\n\nconst workflowActions = {\n approve: (label = \"同意\", extra: NodeOptions = {}) =>\n normalizeAction(\"agree\", label, extra),\n reject: (label = \"拒绝\", extra: NodeOptions = {}) =>\n normalizeAction(\"rejected\", label, extra),\n transfer: (label = \"转交\", extra: NodeOptions = {}) =>\n normalizeAction(\"transfer\", label, {\n remark: { popUp: true, required: false },\n ...extra,\n }),\n return: (label = \"退回\", extra: NodeOptions = {}) =>\n normalizeAction(\"return\", label, {\n remark: { popUp: true, required: false },\n ...extra,\n }),\n returnToInitiator: (label = \"退回发起人\", extra: NodeOptions = {}) =>\n normalizeAction(\"return\", label, {\n remark: { popUp: true, required: false },\n returnTarget: \"initiator\",\n returnScope: \"initiator\",\n ...extra,\n }),\n save: (label = \"暂存\", extra: NodeOptions = {}) =>\n normalizeAction(\"save\", label, extra),\n withdraw: (label = \"撤回\", extra: NodeOptions = {}) =>\n normalizeAction(\"withdraw\", label, extra),\n resubmit: (label = \"重新提交\", extra: NodeOptions = {}) =>\n normalizeAction(\"resubmit\", label, extra),\n callback: (label = \"触发回调\", extra: NodeOptions = {}) =>\n normalizeAction(\"callback\", label, extra),\n retryException: (label = \"重试异常\", extra: NodeOptions = {}) =>\n normalizeAction(\"retryException\", label, extra),\n adminTransfer: (label = \"管理员转交\", extra: NodeOptions = {}) =>\n normalizeAction(\"adminTransfer\", label, extra),\n};\n\nfunction normalizeReturnConfig(value: any) {\n if (value === false) return { enabled: false };\n if (value === true || value === undefined) {\n return { enabled: true, scopeType: \"previous_all\" };\n }\n return {\n enabled: value.enabled !== false,\n scopeType: value.scopeType || value.scope || \"previous_all\",\n resubmitMode: value.resubmitMode || \"resume_current\",\n ...value,\n };\n}\n\nfunction findInitiatorReturnAction(actions: any[]) {\n return actions.find(\n (action) =>\n action?.action === \"return\" &&\n (action.returnTarget === \"initiator\" || action.returnScope === \"initiator\"),\n );\n}\n\nfunction inferReturnConfigFromActions(actions: any[], explicitReturnConfig?: any) {\n const initiatorReturnAction = findInitiatorReturnAction(actions);\n if (!initiatorReturnAction) return explicitReturnConfig;\n\n const base =\n explicitReturnConfig ||\n normalizeReturnConfig({\n scopeType: \"previous_all\",\n resubmitMode: initiatorReturnAction.resubmitMode || \"replay\",\n });\n\n return {\n ...base,\n allowOriginatorReturn: true,\n };\n}\n\nfunction normalizeFieldBehavior(value: any) {\n const normalized = String(value || \"\").trim().toLowerCase();\n if ([\"normal\", \"edit\", \"editable\", \"write\", \"writable\"].includes(normalized)) return \"NORMAL\";\n if ([\"readonly\", \"read\", \"view\", \"visible\"].includes(normalized)) return \"READONLY\";\n if ([\"hidden\", \"hide\", \"invisible\"].includes(normalized)) return \"HIDDEN\";\n return String(value || \"READONLY\").toUpperCase();\n}\n\nfunction normalizeFieldPermissions(value: any): any[] | undefined {\n if (Array.isArray(value)) {\n return value.map((item) => {\n if (!item || typeof item !== \"object\") return item;\n return {\n ...item,\n fieldId: item.fieldId || item.field || item.id,\n fieldBehavior: normalizeFieldBehavior(item.fieldBehavior || item.behavior || item.permission),\n };\n });\n }\n if (value && typeof value === \"object\") {\n return Object.entries(value).map(([fieldId, fieldBehavior]) => ({\n fieldId,\n fieldBehavior: normalizeFieldBehavior(fieldBehavior),\n }));\n }\n return undefined;\n}\n\nfunction createDeclarativeNode(\n type: string,\n id: string,\n data: NodeOptions = {},\n): WorkflowDeclarativeNode {\n return {\n __openxiangdaWorkflowNode: true,\n id: sanitizeId(id),\n type,\n data,\n };\n}\n\nfunction createDeclarativeEdge(\n source: WorkflowNodeRef,\n target: WorkflowNodeRef,\n data: NodeOptions = {},\n): WorkflowDeclarativeEdge {\n return {\n __openxiangdaWorkflowEdge: true,\n source,\n target,\n data,\n };\n}\n\nfunction isDeclarativeInput(input: any): input is WorkflowDeclarativeInput {\n return input && Array.isArray(input.nodes);\n}\n\nfunction isWorkflowNodeDescriptor(value: any): value is WorkflowDeclarativeNode {\n return Boolean(value?.__openxiangdaWorkflowNode);\n}\n\nfunction normalizeAssignee(value: any) {\n if (typeof value === \"string\") {\n return { type: value === \"originator\" ? \"originator\" : \"user\", id: value, name: value };\n }\n return value || {};\n}\n\nfunction normalizeApprovalData(data: NodeOptions = {}) {\n const normalized: NodeOptions = { ...data };\n const assignees = Array.isArray(data.assignees)\n ? data.assignees.map(normalizeAssignee)\n : undefined;\n\n if (assignees && !normalized.approverType) {\n const supervisor = assignees.find((item) => item.type === \"department_supervisor\");\n const initiatorSelect = assignees.find((item) => item.type === \"initiator_select\");\n const roleAssignees = assignees.filter((item) => item.type === \"role\");\n const userAssignees = assignees.filter((item) => item.type === \"user\" || item.type === \"originator\");\n\n if (supervisor) {\n normalized.approverType = \"ext_target_approval_department_supervisor\";\n normalized.supervisorConfig = {\n level: supervisor.level || 1,\n fallbackToAncestorSupervisor: supervisor.fallbackToAncestorSupervisor !== false,\n ...(normalized.supervisorConfig || {}),\n };\n normalized.approvals = normalized.approvals || [];\n normalized.approvalNames = normalized.approvalNames || [];\n } else if (initiatorSelect) {\n normalized.approverType = \"ext_target_approval_initiator_select\";\n normalized.initiatorSelectScope = initiatorSelect.scope || initiatorSelect.initiatorSelectScope || \"all\";\n normalized.approvals =\n normalized.approvals ||\n (Array.isArray(initiatorSelect.approvals)\n ? initiatorSelect.approvals\n : roleAssignees.map((item) => item.id).filter(Boolean));\n normalized.approvalNames =\n normalized.approvalNames ||\n (Array.isArray(initiatorSelect.approvalNames)\n ? initiatorSelect.approvalNames\n : roleAssignees.map((item) => item.name || item.id).filter(Boolean));\n } else if (roleAssignees.length > 0 && userAssignees.length === 0) {\n normalized.approverType = \"ext_target_approval_role\";\n normalized.approvals = normalized.approvals || roleAssignees.map((item) => item.id).filter(Boolean);\n normalized.approvalNames =\n normalized.approvalNames || roleAssignees.map((item) => item.name || item.id).filter(Boolean);\n } else {\n normalized.approverType = \"ext_target_approval\";\n normalized.approvals =\n normalized.approvals ||\n userAssignees\n .map((item) => (item.type === \"originator\" ? \"originator\" : item.id))\n .filter(Boolean);\n normalized.approvalNames =\n normalized.approvalNames ||\n userAssignees\n .map((item) => item.name || (item.type === \"originator\" ? \"发起人\" : item.id))\n .filter(Boolean);\n }\n }\n\n return normalized;\n}\n\nexport class WorkflowBuilder {\n private nodes: any[] = [];\n private edges: any[] = [];\n private flowConfig: Record<string, any[]> = {};\n private globalSettings: Record<string, any> = {};\n readonly action = workflowActions;\n\n constructor(private readonly meta: Omit<WorkflowDefinitionInput, \"build\"> = {}) {\n this.globalSettings = { ...(meta.globalSettings || {}) };\n }\n\n start(id = \"start\", data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"start\", id, { label: \"开始节点\", ...data });\n }\n\n end(id = \"end\", data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"end\", id, { label: \"结束节点\", ...data });\n }\n\n approval(id: string, data: NodeOptions): WorkflowNodeRef {\n const approvalData = normalizeApprovalData(data);\n const actions =\n approvalData.buttons || approvalData.actions || [\n this.action.approve(),\n this.action.reject(),\n ];\n const returnConfig =\n approvalData.returnConfig !== undefined\n ? normalizeReturnConfig(approvalData.returnConfig)\n : approvalData.returnPolicy !== undefined\n ? normalizeReturnConfig(approvalData.returnPolicy)\n : undefined;\n const inferredReturnConfig = inferReturnConfigFromActions(actions, returnConfig);\n return this.node(\"approval\", id, {\n label: approvalData.label || \"审批\",\n value: approvalData.value || \"\",\n approverType: approvalData.approverType || \"ext_target_approval\",\n approvals: approvalData.approvals || [],\n approvalNames: approvalData.approvalNames || [],\n multiApprove: approvalData.multiApprove || \"or\",\n ...approvalData,\n actions,\n ...(inferredReturnConfig ? { returnConfig: inferredReturnConfig } : {}),\n });\n }\n\n copy(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"copy\", id, {\n label: data.label || \"抄送\",\n value: data.value || \"\",\n approverType: data.approverType || \"ext_target_approval\",\n approvals: data.approvals || [],\n approvalNames: data.approvalNames || [],\n ...data,\n });\n }\n\n jsCode(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"js_code\", id, {\n label: data.label || \"JS代码节点\",\n runtimeMode: \"trusted_node\",\n sourceType: data.sourceFile ? \"file_snapshot\" : data.sourceType || \"inline\",\n timeout: data.timeout || data.timeoutMs || 30000,\n ...data,\n });\n }\n\n functionCall(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"function_call\", id, {\n label: data.label || \"调用函数\",\n functionCode: data.functionCode || data.functionName || data.code,\n input: data.input || data.inputMapping || {},\n saveResponseTo: data.saveResponseTo || data.outputKey,\n timeout: data.timeout || data.timeoutMs || 30000,\n ...data,\n });\n }\n\n callbackWait(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"callback_wait\", id, {\n type: \"callback_wait\",\n label: data.label || \"回调等待\",\n timeoutSeconds: data.timeoutSeconds || 86400,\n timeoutStrategy: data.timeoutStrategy || \"FAIL\",\n ...data,\n });\n }\n\n connectorCall(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"connector_call\", id, {\n type: \"connector_call\",\n label: data.label || \"连接器\",\n timeout: data.timeout || 30000,\n ...data,\n });\n }\n\n workNotification(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"work_notification\", id, {\n label: data.label || \"工作通知\",\n buttonText: data.buttonText || \"查看详情\",\n linkType: data.linkType || \"current_form\",\n ...data,\n });\n }\n\n notification(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.workNotification(id, data);\n }\n\n dingtalkCard(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"dingtalk_card\", id, {\n config: {\n type: \"dingtalk_card\",\n label: data.label || \"钉钉消息卡片\",\n sameFieldStrategy: \"create\",\n ...(data.config || data),\n },\n });\n }\n\n condition(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"condition_branch\", id, {\n type: \"condition_branch\",\n label: data.label || \"条件分支\",\n condition: data.condition || { ruleType: \"group\", condition: \"AND\", rules: [] },\n isElse: data.isElse === true,\n priority: data.priority || \"1\",\n trueNodeId: data.trueNodeId,\n falseNodeId: data.falseNodeId,\n ...data,\n });\n }\n\n branch(id: string, data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"branch\", id, {\n label: data.label || \"辅助分支\",\n isAuxNode: data.isAuxNode ?? true,\n branchType: data.branchType || \"controller\",\n ...data,\n });\n }\n\n parallel(\n id: string,\n branches: Array<{\n id: string;\n label?: string;\n nodes: WorkflowNodeRef[];\n }>,\n data: NodeOptions = {},\n ) {\n const entry = this.branch(`${id}_branch`, {\n label: data.label || \"并行分支\",\n branchType: \"parallel_controller\",\n hidden: true,\n });\n const converge = this.branch(`${id}_converge`, {\n label: data.convergeLabel || \"并行汇聚\",\n branchType: \"converge\",\n hidden: true,\n });\n\n branches.forEach((branch, index) => {\n const nodes = branch.nodes.filter(Boolean);\n if (nodes.length === 0) return;\n this.edge(entry, nodes[0], {\n id: `edge_${entry}_${sanitizeId(branch.id || String(index))}`,\n label: branch.label,\n });\n this.sequence(...nodes);\n this.edge(nodes[nodes.length - 1], converge, {\n id: `edge_${sanitizeId(branch.id || String(index))}_${converge}`,\n });\n });\n\n return { entry, converge };\n }\n\n conditionBranches(\n id: string,\n branches: Array<{\n id: string;\n label?: string;\n condition?: any;\n nodes: WorkflowNodeRef[];\n isElse?: boolean;\n }>,\n data: NodeOptions = {},\n ) {\n const entry = this.branch(`${id}_controller`, {\n label: data.label || \"条件分支\",\n branchType: \"condition_controller\",\n hidden: true,\n });\n const converge = this.branch(`${id}_converge`, {\n label: data.convergeLabel || \"条件汇聚\",\n branchType: \"converge\",\n hidden: true,\n });\n\n branches.forEach((branch, index) => {\n const condition = this.condition(`${id}_${branch.id}`, {\n label: branch.label || (branch.isElse ? \"其他情况\" : `条件 ${index + 1}`),\n condition:\n branch.condition || {\n ruleType: \"group\",\n condition: \"AND\",\n rules: [],\n },\n isElse: branch.isElse === true,\n priority: String(index + 1),\n });\n this.edge(entry, condition, {\n id: `edge_${entry}_${condition}`,\n label: branch.label,\n });\n const nodes = branch.nodes.filter(Boolean);\n if (nodes.length > 0) {\n this.edge(condition, nodes[0], {\n id: `edge_${condition}_${nodes[0]}`,\n label: branch.label,\n });\n this.sequence(...nodes);\n this.edge(nodes[nodes.length - 1], converge, {\n id: `edge_${nodes[nodes.length - 1]}_${converge}`,\n });\n } else {\n this.edge(condition, converge, {\n id: `edge_${condition}_${converge}`,\n });\n }\n });\n\n if (!branches.some((branch) => branch.isElse)) {\n const elseNode = this.condition(`${id}_else`, {\n label: \"其他情况\",\n isElse: true,\n priority: String(branches.length + 1),\n condition: { ruleType: \"group\", condition: \"AND\", rules: [] },\n });\n this.edge(entry, elseNode, { id: `edge_${entry}_${elseNode}`, label: \"其他情况\" });\n this.edge(elseNode, converge, { id: `edge_${elseNode}_${converge}` });\n }\n\n return { entry, converge };\n }\n\n data = {\n retrieveSingle: (id: string, data: NodeOptions) =>\n this.node(\"data_retrieve_single\", id, {\n type: \"data_retrieve_single\",\n label: data.label || \"获取单条数据\",\n filterType: data.filterType || \"condition\",\n ...data,\n }),\n retrieveBatch: (id: string, data: NodeOptions) =>\n this.node(\"data_retrieve_batch\", id, {\n type: \"data_retrieve_batch\",\n label: data.label || \"获取多条数据\",\n filterType: data.filterType || \"condition\",\n ...data,\n }),\n create: (id: string, data: NodeOptions) =>\n this.node(\"data_create\", id, {\n type: \"data_create\",\n label: data.label || \"新增数据\",\n insertType: data.insertType || \"form\",\n assignments: data.assignments || [],\n ...data,\n }),\n update: (id: string, data: NodeOptions) =>\n this.node(\"data_update\", id, {\n type: \"data_update\",\n label: data.label || \"更新数据\",\n updateType: data.updateType || \"direct_form\",\n assignments: data.assignments || [],\n noneOperation: data.noneOperation || \"ignored\",\n ...data,\n }),\n };\n\n node(type: string, id: string, data: NodeOptions): WorkflowNodeRef {\n const nodeId = sanitizeId(id);\n if (!nodeId) throw new Error(\"workflow node id is required\");\n if (this.nodes.some((node) => node.id === nodeId)) {\n throw new Error(`duplicate workflow node id: ${nodeId}`);\n }\n this.nodes.push({\n id: nodeId,\n type,\n data,\n position: createPosition(this.nodes.length),\n });\n const fieldPermissions = normalizeFieldPermissions(data.fieldPermissions);\n if (fieldPermissions) {\n this.flowConfig[nodeId] = fieldPermissions;\n }\n return nodeId;\n }\n\n edge(source: WorkflowNodeRef, target: WorkflowNodeRef, data: NodeOptions = {}) {\n const id = data.id || `edge_${source}_${target}`;\n this.edges.push({\n id,\n source,\n target,\n type: data.type || \"custom\",\n ...(data.label ? { label: data.label } : {}),\n });\n }\n\n connect(source: WorkflowNodeRef, target: WorkflowNodeRef, data: NodeOptions = {}) {\n this.edge(source, target, data);\n }\n\n sequence(...refs: WorkflowNodeRef[]) {\n for (let index = 0; index < refs.length - 1; index += 1) {\n this.edge(refs[index], refs[index + 1]);\n }\n }\n\n setFieldPermissions(nodeId: WorkflowNodeRef, permissions: any[]) {\n this.flowConfig[nodeId] = permissions;\n }\n\n setGlobalSettings(settings: Record<string, any>) {\n this.globalSettings = { ...this.globalSettings, ...settings };\n }\n\n compile(): WorkflowCompileResult {\n const definitionJson = {\n version: \"v3\" as const,\n nodes: this.nodes,\n edges: this.edges,\n flowConfig: this.flowConfig,\n globalSettings: this.globalSettings,\n };\n validateCompiledWorkflowDefinition(definitionJson);\n return {\n definitionJson,\n previewJson: {\n kind: \"workflow_code_preview\",\n version: \"preview_v1\",\n sourceMode: \"workflow_code_ts\",\n steps: this.nodes.map((node) => ({\n id: node.id,\n type: node.type,\n label: node.data?.label || node.id,\n config: node.data,\n })),\n edges: this.edges.map((edge) => ({\n source: edge.source,\n target: edge.target,\n label: edge.label,\n })),\n },\n };\n }\n}\n\nexport function defineWorkflow(input: WorkflowDefinitionInput) {\n return {\n __openxiangdaWorkflow: true,\n compile() {\n const builder = new WorkflowBuilder(input);\n input.build(builder);\n return builder.compile();\n },\n };\n}\n\nfunction addDeclarativeNode(builder: WorkflowBuilder, node: WorkflowDeclarativeNode) {\n if (!isWorkflowNodeDescriptor(node)) {\n throw new Error(\"workflow declarative nodes must be created by flow.* helpers\");\n }\n\n switch (node.type) {\n case \"start\":\n builder.start(node.id, node.data);\n return;\n case \"end\":\n builder.end(node.id, node.data);\n return;\n case \"approval\":\n builder.approval(node.id, node.data);\n return;\n case \"copy\":\n builder.copy(node.id, node.data);\n return;\n case \"js_code\":\n builder.jsCode(node.id, node.data);\n return;\n case \"function_call\":\n builder.functionCall(node.id, node.data);\n return;\n case \"callback_wait\":\n builder.callbackWait(node.id, node.data);\n return;\n case \"connector_call\":\n builder.connectorCall(node.id, node.data);\n return;\n case \"work_notification\":\n builder.workNotification(node.id, node.data);\n return;\n case \"condition_branch\":\n builder.condition(node.id, node.data);\n return;\n case \"branch\": {\n builder.branch(node.id, node.data);\n const branches = Array.isArray(node.data?.branches) ? node.data.branches : [];\n branches.forEach((branch: any, index: number) => {\n const conditionId = sanitizeId(`${node.id}_${branch.id || index + 1}`);\n builder.condition(conditionId, {\n label: branch.label || (branch.else || branch.isElse ? \"其他情况\" : `条件 ${index + 1}`),\n condition:\n branch.condition || {\n ruleType: \"group\",\n condition: \"AND\",\n rules: [],\n },\n isElse: branch.else === true || branch.isElse === true,\n priority: String(index + 1),\n });\n builder.edge(node.id, conditionId, {\n id: `edge_${node.id}_${conditionId}`,\n label: branch.label,\n });\n if (branch.next) {\n builder.edge(conditionId, sanitizeId(branch.next), {\n id: `edge_${conditionId}_${sanitizeId(branch.next)}`,\n label: branch.label,\n });\n }\n });\n return;\n }\n default:\n builder.node(node.type, node.id, node.data);\n }\n}\n\nfunction defineDeclarativeWorkflow(input: WorkflowDeclarativeInput) {\n return {\n __openxiangdaWorkflow: true,\n compile() {\n const builder = new WorkflowBuilder(input);\n input.nodes.forEach((node) => addDeclarativeNode(builder, node));\n (input.edges || []).forEach((edge) => {\n builder.edge(edge.source, edge.target, edge.data || {});\n });\n return builder.compile();\n },\n };\n}\n\nexport const flow = {\n define(input: WorkflowDefinitionInput | WorkflowDeclarativeInput) {\n if (isDeclarativeInput(input)) {\n return defineDeclarativeWorkflow(input);\n }\n return defineWorkflow(input);\n },\n action: workflowActions,\n assignee: {\n user: (id: string, name?: string) => ({ type: \"user\", id, name: name || id }),\n initiator: () => ({ type: \"originator\", id: \"originator\", name: \"发起人\" }),\n role: (id: string, name?: string) => ({ type: \"role\", id, name: name || id }),\n departmentSupervisor: (\n level = 1,\n extra: NodeOptions = {},\n ) => ({ type: \"department_supervisor\", level, ...extra }),\n initiatorSelect: (\n scope: \"all\" | \"members\" | \"roles\" = \"all\",\n extra: NodeOptions = {},\n ) => ({ type: \"initiator_select\", scope, ...extra }),\n },\n start: (id = \"start\", data: NodeOptions = {}) =>\n createDeclarativeNode(\"start\", id, data),\n end: (id = \"end\", data: NodeOptions = {}) =>\n createDeclarativeNode(\"end\", id, data),\n approval: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"approval\", id, data),\n copy: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"copy\", id, data),\n jsCode: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"js_code\", id, data),\n functionCall: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"function_call\", id, data),\n callbackWait: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"callback_wait\", id, data),\n connectorCall: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"connector_call\", id, data),\n workNotification: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"work_notification\", id, data),\n notification: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"work_notification\", id, data),\n condition: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"condition_branch\", id, data),\n branch: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"branch\", id, data),\n data: {\n retrieveSingle: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_retrieve_single\", id, data),\n retrieveBatch: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_retrieve_batch\", id, data),\n create: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_create\", id, data),\n update: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_update\", id, data),\n },\n connect: createDeclarativeEdge,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqDA,SAAS,WAAW,OAAe;AACjC,SAAO,OAAO,SAAS,EAAE,EACtB,KAAK,EACL,QAAQ,mBAAmB,GAAG;AACnC;AAEA,SAAS,eAAe,OAAe;AACrC,SAAO,EAAE,GAAG,KAAK,GAAG,MAAM,QAAQ,IAAI;AACxC;AAEA,SAAS,iBAAiB,OAAY;AACpC,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,SAAS;AAChD,SAAO,UAAU,UAAa,UAAU,QAAQ,OAAO,KAAK,EAAE,KAAK,MAAM;AAC3E;AAEA,SAAS,mCAAmC,gBAAyD;AACnG,QAAM,SAAmB,CAAC;AAC1B,aAAW,QAAQ,eAAe,SAAS,CAAC,GAAG;AAC7C,UAAM,SAAS,MAAM,MAAM;AAC3B,UAAM,OAAO,MAAM,QAAQ,CAAC;AAC5B,YAAQ,MAAM,MAAM;AAAA,MAClB,KAAK;AACH,YAAI,CAAC,iBAA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kBAAkB,CAAC,IAAY,OAAoB,CAAC,MAClD,sBAAsB,qBAAqB,IAAI,IAAI;AAAA,EACrD,cAAc,CAAC,IAAY,OAAoB,CAAC,MAC9C,sBAAsB,qBAAqB,IAAI,IAAI;AAAA,EACrD,WAAW,CAAC,IAAY,OAAoB,CAAC,MAC3C,sBAAsB,oBAAoB,IAAI,IAAI;AAAA,EACpD,QAAQ,CAAC,IAAY,OAAoB,CAAC,MACxC,sBAAsB,UAAU,IAAI,IAAI;AAAA,EAC1C,MAAM;AAAA,IACJ,gBAAgB,CAAC,IAAY,OAAoB,CAAC,MAChD,sBAAsB,wBAAwB,IAAI,IAAI;AAAA,IACxD,eAAe,CAAC,IAAY,OAAoB,CAAC,MAC/C,sBAAsB,uBAAuB,IAAI,IAAI;AAAA,IACvD,QAAQ,CAAC,IAAY,OAAoB,CAAC,MACxC,sBAAsB,eAAe,IAAI,IAAI;AAAA,IAC/C,QAAQ,CAAC,IAAY,OAAoB,CAAC,MACxC,sBAAsB,eAAe,IAAI,IAAI;AAAA,EACjD;AAAA,EACA,SAAS;AACX;","names":[]}
|
|
@@ -5,6 +5,40 @@ function sanitizeId(value) {
|
|
|
5
5
|
function createPosition(index) {
|
|
6
6
|
return { x: 400, y: 100 + index * 150 };
|
|
7
7
|
}
|
|
8
|
+
function hasRequiredValue(value) {
|
|
9
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
10
|
+
return value !== void 0 && value !== null && String(value).trim() !== "";
|
|
11
|
+
}
|
|
12
|
+
function validateCompiledWorkflowDefinition(definitionJson) {
|
|
13
|
+
const errors = [];
|
|
14
|
+
for (const node of definitionJson.nodes || []) {
|
|
15
|
+
const nodeId = node?.id || "<unknown>";
|
|
16
|
+
const data = node?.data || {};
|
|
17
|
+
switch (node?.type) {
|
|
18
|
+
case "function_call":
|
|
19
|
+
if (!hasRequiredValue(data.functionCode)) {
|
|
20
|
+
errors.push(`function_call node ${nodeId} requires functionCode`);
|
|
21
|
+
}
|
|
22
|
+
break;
|
|
23
|
+
case "callback_wait":
|
|
24
|
+
if (!hasRequiredValue(data.eventCode)) {
|
|
25
|
+
errors.push(`callback_wait node ${nodeId} requires eventCode`);
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
case "work_notification":
|
|
29
|
+
if (!hasRequiredValue(data.title) || !hasRequiredValue(data.content) || !hasRequiredValue(data.recipientType)) {
|
|
30
|
+
errors.push(`work_notification node ${nodeId} requires title, content, and recipientType`);
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (errors.length > 0) {
|
|
38
|
+
throw new Error(`workflow DSL validation failed:
|
|
39
|
+
- ${errors.join("\n- ")}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
8
42
|
function normalizeAction(action, label, extra = {}) {
|
|
9
43
|
return {
|
|
10
44
|
action,
|
|
@@ -240,7 +274,7 @@ var WorkflowBuilder = class {
|
|
|
240
274
|
functionCall(id, data) {
|
|
241
275
|
return this.node("function_call", id, {
|
|
242
276
|
label: data.label || "\u8C03\u7528\u51FD\u6570",
|
|
243
|
-
functionCode: data.functionCode || data.code,
|
|
277
|
+
functionCode: data.functionCode || data.functionName || data.code,
|
|
244
278
|
input: data.input || data.inputMapping || {},
|
|
245
279
|
saveResponseTo: data.saveResponseTo || data.outputKey,
|
|
246
280
|
timeout: data.timeout || data.timeoutMs || 3e4,
|
|
@@ -427,14 +461,16 @@ var WorkflowBuilder = class {
|
|
|
427
461
|
this.globalSettings = { ...this.globalSettings, ...settings };
|
|
428
462
|
}
|
|
429
463
|
compile() {
|
|
464
|
+
const definitionJson = {
|
|
465
|
+
version: "v3",
|
|
466
|
+
nodes: this.nodes,
|
|
467
|
+
edges: this.edges,
|
|
468
|
+
flowConfig: this.flowConfig,
|
|
469
|
+
globalSettings: this.globalSettings
|
|
470
|
+
};
|
|
471
|
+
validateCompiledWorkflowDefinition(definitionJson);
|
|
430
472
|
return {
|
|
431
|
-
definitionJson
|
|
432
|
-
version: "v3",
|
|
433
|
-
nodes: this.nodes,
|
|
434
|
-
edges: this.edges,
|
|
435
|
-
flowConfig: this.flowConfig,
|
|
436
|
-
globalSettings: this.globalSettings
|
|
437
|
-
},
|
|
473
|
+
definitionJson,
|
|
438
474
|
previewJson: {
|
|
439
475
|
kind: "workflow_code_preview",
|
|
440
476
|
version: "preview_v1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/workflow/index.ts"],"sourcesContent":["export type WorkflowNodeRef = string;\n\nexport interface WorkflowCompileResult {\n definitionJson: {\n version: \"v3\";\n nodes: any[];\n edges: any[];\n flowConfig: Record<string, any[]>;\n globalSettings: Record<string, any>;\n };\n previewJson: {\n kind: \"workflow_code_preview\";\n version: \"preview_v1\";\n steps: any[];\n edges: any[];\n sourceMode: \"workflow_code_ts\";\n };\n}\n\nexport interface WorkflowDefinitionInput {\n name?: string;\n formCode?: string;\n formUuid?: string;\n globalSettings?: Record<string, any>;\n build: (flow: WorkflowBuilder) => void;\n}\n\nexport interface WorkflowDeclarativeInput {\n id?: string;\n name?: string;\n formCode?: string;\n formUuid?: string;\n globalSettings?: Record<string, any>;\n nodes: WorkflowDeclarativeNode[];\n edges?: WorkflowDeclarativeEdge[];\n}\n\nexport interface WorkflowDeclarativeNode {\n __openxiangdaWorkflowNode: true;\n id: WorkflowNodeRef;\n type: string;\n data: NodeOptions;\n}\n\nexport interface WorkflowDeclarativeEdge {\n __openxiangdaWorkflowEdge: true;\n source: WorkflowNodeRef;\n target: WorkflowNodeRef;\n data?: NodeOptions;\n}\n\ntype NodeOptions = Record<string, any>;\n\nfunction sanitizeId(value: string) {\n return String(value || \"\")\n .trim()\n .replace(/[^a-zA-Z0-9_-]/g, \"_\");\n}\n\nfunction createPosition(index: number) {\n return { x: 400, y: 100 + index * 150 };\n}\n\nfunction normalizeAction(action: string, label: string, extra: NodeOptions = {}) {\n return {\n action,\n name: { zh_CN: label },\n ...extra,\n };\n}\n\nconst workflowActions = {\n approve: (label = \"同意\", extra: NodeOptions = {}) =>\n normalizeAction(\"agree\", label, extra),\n reject: (label = \"拒绝\", extra: NodeOptions = {}) =>\n normalizeAction(\"rejected\", label, extra),\n transfer: (label = \"转交\", extra: NodeOptions = {}) =>\n normalizeAction(\"transfer\", label, {\n remark: { popUp: true, required: false },\n ...extra,\n }),\n return: (label = \"退回\", extra: NodeOptions = {}) =>\n normalizeAction(\"return\", label, {\n remark: { popUp: true, required: false },\n ...extra,\n }),\n returnToInitiator: (label = \"退回发起人\", extra: NodeOptions = {}) =>\n normalizeAction(\"return\", label, {\n remark: { popUp: true, required: false },\n returnTarget: \"initiator\",\n returnScope: \"initiator\",\n ...extra,\n }),\n save: (label = \"暂存\", extra: NodeOptions = {}) =>\n normalizeAction(\"save\", label, extra),\n withdraw: (label = \"撤回\", extra: NodeOptions = {}) =>\n normalizeAction(\"withdraw\", label, extra),\n resubmit: (label = \"重新提交\", extra: NodeOptions = {}) =>\n normalizeAction(\"resubmit\", label, extra),\n callback: (label = \"触发回调\", extra: NodeOptions = {}) =>\n normalizeAction(\"callback\", label, extra),\n retryException: (label = \"重试异常\", extra: NodeOptions = {}) =>\n normalizeAction(\"retryException\", label, extra),\n adminTransfer: (label = \"管理员转交\", extra: NodeOptions = {}) =>\n normalizeAction(\"adminTransfer\", label, extra),\n};\n\nfunction normalizeReturnConfig(value: any) {\n if (value === false) return { enabled: false };\n if (value === true || value === undefined) {\n return { enabled: true, scopeType: \"previous_all\" };\n }\n return {\n enabled: value.enabled !== false,\n scopeType: value.scopeType || value.scope || \"previous_all\",\n resubmitMode: value.resubmitMode || \"resume_current\",\n ...value,\n };\n}\n\nfunction findInitiatorReturnAction(actions: any[]) {\n return actions.find(\n (action) =>\n action?.action === \"return\" &&\n (action.returnTarget === \"initiator\" || action.returnScope === \"initiator\"),\n );\n}\n\nfunction inferReturnConfigFromActions(actions: any[], explicitReturnConfig?: any) {\n const initiatorReturnAction = findInitiatorReturnAction(actions);\n if (!initiatorReturnAction) return explicitReturnConfig;\n\n const base =\n explicitReturnConfig ||\n normalizeReturnConfig({\n scopeType: \"previous_all\",\n resubmitMode: initiatorReturnAction.resubmitMode || \"replay\",\n });\n\n return {\n ...base,\n allowOriginatorReturn: true,\n };\n}\n\nfunction normalizeFieldBehavior(value: any) {\n const normalized = String(value || \"\").trim().toLowerCase();\n if ([\"normal\", \"edit\", \"editable\", \"write\", \"writable\"].includes(normalized)) return \"NORMAL\";\n if ([\"readonly\", \"read\", \"view\", \"visible\"].includes(normalized)) return \"READONLY\";\n if ([\"hidden\", \"hide\", \"invisible\"].includes(normalized)) return \"HIDDEN\";\n return String(value || \"READONLY\").toUpperCase();\n}\n\nfunction normalizeFieldPermissions(value: any): any[] | undefined {\n if (Array.isArray(value)) {\n return value.map((item) => {\n if (!item || typeof item !== \"object\") return item;\n return {\n ...item,\n fieldId: item.fieldId || item.field || item.id,\n fieldBehavior: normalizeFieldBehavior(item.fieldBehavior || item.behavior || item.permission),\n };\n });\n }\n if (value && typeof value === \"object\") {\n return Object.entries(value).map(([fieldId, fieldBehavior]) => ({\n fieldId,\n fieldBehavior: normalizeFieldBehavior(fieldBehavior),\n }));\n }\n return undefined;\n}\n\nfunction createDeclarativeNode(\n type: string,\n id: string,\n data: NodeOptions = {},\n): WorkflowDeclarativeNode {\n return {\n __openxiangdaWorkflowNode: true,\n id: sanitizeId(id),\n type,\n data,\n };\n}\n\nfunction createDeclarativeEdge(\n source: WorkflowNodeRef,\n target: WorkflowNodeRef,\n data: NodeOptions = {},\n): WorkflowDeclarativeEdge {\n return {\n __openxiangdaWorkflowEdge: true,\n source,\n target,\n data,\n };\n}\n\nfunction isDeclarativeInput(input: any): input is WorkflowDeclarativeInput {\n return input && Array.isArray(input.nodes);\n}\n\nfunction isWorkflowNodeDescriptor(value: any): value is WorkflowDeclarativeNode {\n return Boolean(value?.__openxiangdaWorkflowNode);\n}\n\nfunction normalizeAssignee(value: any) {\n if (typeof value === \"string\") {\n return { type: value === \"originator\" ? \"originator\" : \"user\", id: value, name: value };\n }\n return value || {};\n}\n\nfunction normalizeApprovalData(data: NodeOptions = {}) {\n const normalized: NodeOptions = { ...data };\n const assignees = Array.isArray(data.assignees)\n ? data.assignees.map(normalizeAssignee)\n : undefined;\n\n if (assignees && !normalized.approverType) {\n const supervisor = assignees.find((item) => item.type === \"department_supervisor\");\n const initiatorSelect = assignees.find((item) => item.type === \"initiator_select\");\n const roleAssignees = assignees.filter((item) => item.type === \"role\");\n const userAssignees = assignees.filter((item) => item.type === \"user\" || item.type === \"originator\");\n\n if (supervisor) {\n normalized.approverType = \"ext_target_approval_department_supervisor\";\n normalized.supervisorConfig = {\n level: supervisor.level || 1,\n fallbackToAncestorSupervisor: supervisor.fallbackToAncestorSupervisor !== false,\n ...(normalized.supervisorConfig || {}),\n };\n normalized.approvals = normalized.approvals || [];\n normalized.approvalNames = normalized.approvalNames || [];\n } else if (initiatorSelect) {\n normalized.approverType = \"ext_target_approval_initiator_select\";\n normalized.initiatorSelectScope = initiatorSelect.scope || initiatorSelect.initiatorSelectScope || \"all\";\n normalized.approvals =\n normalized.approvals ||\n (Array.isArray(initiatorSelect.approvals)\n ? initiatorSelect.approvals\n : roleAssignees.map((item) => item.id).filter(Boolean));\n normalized.approvalNames =\n normalized.approvalNames ||\n (Array.isArray(initiatorSelect.approvalNames)\n ? initiatorSelect.approvalNames\n : roleAssignees.map((item) => item.name || item.id).filter(Boolean));\n } else if (roleAssignees.length > 0 && userAssignees.length === 0) {\n normalized.approverType = \"ext_target_approval_role\";\n normalized.approvals = normalized.approvals || roleAssignees.map((item) => item.id).filter(Boolean);\n normalized.approvalNames =\n normalized.approvalNames || roleAssignees.map((item) => item.name || item.id).filter(Boolean);\n } else {\n normalized.approverType = \"ext_target_approval\";\n normalized.approvals =\n normalized.approvals ||\n userAssignees\n .map((item) => (item.type === \"originator\" ? \"originator\" : item.id))\n .filter(Boolean);\n normalized.approvalNames =\n normalized.approvalNames ||\n userAssignees\n .map((item) => item.name || (item.type === \"originator\" ? \"发起人\" : item.id))\n .filter(Boolean);\n }\n }\n\n return normalized;\n}\n\nexport class WorkflowBuilder {\n private nodes: any[] = [];\n private edges: any[] = [];\n private flowConfig: Record<string, any[]> = {};\n private globalSettings: Record<string, any> = {};\n readonly action = workflowActions;\n\n constructor(private readonly meta: Omit<WorkflowDefinitionInput, \"build\"> = {}) {\n this.globalSettings = { ...(meta.globalSettings || {}) };\n }\n\n start(id = \"start\", data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"start\", id, { label: \"开始节点\", ...data });\n }\n\n end(id = \"end\", data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"end\", id, { label: \"结束节点\", ...data });\n }\n\n approval(id: string, data: NodeOptions): WorkflowNodeRef {\n const approvalData = normalizeApprovalData(data);\n const actions =\n approvalData.buttons || approvalData.actions || [\n this.action.approve(),\n this.action.reject(),\n ];\n const returnConfig =\n approvalData.returnConfig !== undefined\n ? normalizeReturnConfig(approvalData.returnConfig)\n : approvalData.returnPolicy !== undefined\n ? normalizeReturnConfig(approvalData.returnPolicy)\n : undefined;\n const inferredReturnConfig = inferReturnConfigFromActions(actions, returnConfig);\n return this.node(\"approval\", id, {\n label: approvalData.label || \"审批\",\n value: approvalData.value || \"\",\n approverType: approvalData.approverType || \"ext_target_approval\",\n approvals: approvalData.approvals || [],\n approvalNames: approvalData.approvalNames || [],\n multiApprove: approvalData.multiApprove || \"or\",\n ...approvalData,\n actions,\n ...(inferredReturnConfig ? { returnConfig: inferredReturnConfig } : {}),\n });\n }\n\n copy(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"copy\", id, {\n label: data.label || \"抄送\",\n value: data.value || \"\",\n approverType: data.approverType || \"ext_target_approval\",\n approvals: data.approvals || [],\n approvalNames: data.approvalNames || [],\n ...data,\n });\n }\n\n jsCode(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"js_code\", id, {\n label: data.label || \"JS代码节点\",\n runtimeMode: \"trusted_node\",\n sourceType: data.sourceFile ? \"file_snapshot\" : data.sourceType || \"inline\",\n timeout: data.timeout || data.timeoutMs || 30000,\n ...data,\n });\n }\n\n functionCall(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"function_call\", id, {\n label: data.label || \"调用函数\",\n functionCode: data.functionCode || data.code,\n input: data.input || data.inputMapping || {},\n saveResponseTo: data.saveResponseTo || data.outputKey,\n timeout: data.timeout || data.timeoutMs || 30000,\n ...data,\n });\n }\n\n callbackWait(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"callback_wait\", id, {\n type: \"callback_wait\",\n label: data.label || \"回调等待\",\n timeoutSeconds: data.timeoutSeconds || 86400,\n timeoutStrategy: data.timeoutStrategy || \"FAIL\",\n ...data,\n });\n }\n\n connectorCall(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"connector_call\", id, {\n type: \"connector_call\",\n label: data.label || \"连接器\",\n timeout: data.timeout || 30000,\n ...data,\n });\n }\n\n workNotification(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"work_notification\", id, {\n label: data.label || \"工作通知\",\n buttonText: data.buttonText || \"查看详情\",\n linkType: data.linkType || \"current_form\",\n ...data,\n });\n }\n\n notification(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.workNotification(id, data);\n }\n\n dingtalkCard(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"dingtalk_card\", id, {\n config: {\n type: \"dingtalk_card\",\n label: data.label || \"钉钉消息卡片\",\n sameFieldStrategy: \"create\",\n ...(data.config || data),\n },\n });\n }\n\n condition(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"condition_branch\", id, {\n type: \"condition_branch\",\n label: data.label || \"条件分支\",\n condition: data.condition || { ruleType: \"group\", condition: \"AND\", rules: [] },\n isElse: data.isElse === true,\n priority: data.priority || \"1\",\n trueNodeId: data.trueNodeId,\n falseNodeId: data.falseNodeId,\n ...data,\n });\n }\n\n branch(id: string, data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"branch\", id, {\n label: data.label || \"辅助分支\",\n isAuxNode: data.isAuxNode ?? true,\n branchType: data.branchType || \"controller\",\n ...data,\n });\n }\n\n parallel(\n id: string,\n branches: Array<{\n id: string;\n label?: string;\n nodes: WorkflowNodeRef[];\n }>,\n data: NodeOptions = {},\n ) {\n const entry = this.branch(`${id}_branch`, {\n label: data.label || \"并行分支\",\n branchType: \"parallel_controller\",\n hidden: true,\n });\n const converge = this.branch(`${id}_converge`, {\n label: data.convergeLabel || \"并行汇聚\",\n branchType: \"converge\",\n hidden: true,\n });\n\n branches.forEach((branch, index) => {\n const nodes = branch.nodes.filter(Boolean);\n if (nodes.length === 0) return;\n this.edge(entry, nodes[0], {\n id: `edge_${entry}_${sanitizeId(branch.id || String(index))}`,\n label: branch.label,\n });\n this.sequence(...nodes);\n this.edge(nodes[nodes.length - 1], converge, {\n id: `edge_${sanitizeId(branch.id || String(index))}_${converge}`,\n });\n });\n\n return { entry, converge };\n }\n\n conditionBranches(\n id: string,\n branches: Array<{\n id: string;\n label?: string;\n condition?: any;\n nodes: WorkflowNodeRef[];\n isElse?: boolean;\n }>,\n data: NodeOptions = {},\n ) {\n const entry = this.branch(`${id}_controller`, {\n label: data.label || \"条件分支\",\n branchType: \"condition_controller\",\n hidden: true,\n });\n const converge = this.branch(`${id}_converge`, {\n label: data.convergeLabel || \"条件汇聚\",\n branchType: \"converge\",\n hidden: true,\n });\n\n branches.forEach((branch, index) => {\n const condition = this.condition(`${id}_${branch.id}`, {\n label: branch.label || (branch.isElse ? \"其他情况\" : `条件 ${index + 1}`),\n condition:\n branch.condition || {\n ruleType: \"group\",\n condition: \"AND\",\n rules: [],\n },\n isElse: branch.isElse === true,\n priority: String(index + 1),\n });\n this.edge(entry, condition, {\n id: `edge_${entry}_${condition}`,\n label: branch.label,\n });\n const nodes = branch.nodes.filter(Boolean);\n if (nodes.length > 0) {\n this.edge(condition, nodes[0], {\n id: `edge_${condition}_${nodes[0]}`,\n label: branch.label,\n });\n this.sequence(...nodes);\n this.edge(nodes[nodes.length - 1], converge, {\n id: `edge_${nodes[nodes.length - 1]}_${converge}`,\n });\n } else {\n this.edge(condition, converge, {\n id: `edge_${condition}_${converge}`,\n });\n }\n });\n\n if (!branches.some((branch) => branch.isElse)) {\n const elseNode = this.condition(`${id}_else`, {\n label: \"其他情况\",\n isElse: true,\n priority: String(branches.length + 1),\n condition: { ruleType: \"group\", condition: \"AND\", rules: [] },\n });\n this.edge(entry, elseNode, { id: `edge_${entry}_${elseNode}`, label: \"其他情况\" });\n this.edge(elseNode, converge, { id: `edge_${elseNode}_${converge}` });\n }\n\n return { entry, converge };\n }\n\n data = {\n retrieveSingle: (id: string, data: NodeOptions) =>\n this.node(\"data_retrieve_single\", id, {\n type: \"data_retrieve_single\",\n label: data.label || \"获取单条数据\",\n filterType: data.filterType || \"condition\",\n ...data,\n }),\n retrieveBatch: (id: string, data: NodeOptions) =>\n this.node(\"data_retrieve_batch\", id, {\n type: \"data_retrieve_batch\",\n label: data.label || \"获取多条数据\",\n filterType: data.filterType || \"condition\",\n ...data,\n }),\n create: (id: string, data: NodeOptions) =>\n this.node(\"data_create\", id, {\n type: \"data_create\",\n label: data.label || \"新增数据\",\n insertType: data.insertType || \"form\",\n assignments: data.assignments || [],\n ...data,\n }),\n update: (id: string, data: NodeOptions) =>\n this.node(\"data_update\", id, {\n type: \"data_update\",\n label: data.label || \"更新数据\",\n updateType: data.updateType || \"direct_form\",\n assignments: data.assignments || [],\n noneOperation: data.noneOperation || \"ignored\",\n ...data,\n }),\n };\n\n node(type: string, id: string, data: NodeOptions): WorkflowNodeRef {\n const nodeId = sanitizeId(id);\n if (!nodeId) throw new Error(\"workflow node id is required\");\n if (this.nodes.some((node) => node.id === nodeId)) {\n throw new Error(`duplicate workflow node id: ${nodeId}`);\n }\n this.nodes.push({\n id: nodeId,\n type,\n data,\n position: createPosition(this.nodes.length),\n });\n const fieldPermissions = normalizeFieldPermissions(data.fieldPermissions);\n if (fieldPermissions) {\n this.flowConfig[nodeId] = fieldPermissions;\n }\n return nodeId;\n }\n\n edge(source: WorkflowNodeRef, target: WorkflowNodeRef, data: NodeOptions = {}) {\n const id = data.id || `edge_${source}_${target}`;\n this.edges.push({\n id,\n source,\n target,\n type: data.type || \"custom\",\n ...(data.label ? { label: data.label } : {}),\n });\n }\n\n connect(source: WorkflowNodeRef, target: WorkflowNodeRef, data: NodeOptions = {}) {\n this.edge(source, target, data);\n }\n\n sequence(...refs: WorkflowNodeRef[]) {\n for (let index = 0; index < refs.length - 1; index += 1) {\n this.edge(refs[index], refs[index + 1]);\n }\n }\n\n setFieldPermissions(nodeId: WorkflowNodeRef, permissions: any[]) {\n this.flowConfig[nodeId] = permissions;\n }\n\n setGlobalSettings(settings: Record<string, any>) {\n this.globalSettings = { ...this.globalSettings, ...settings };\n }\n\n compile(): WorkflowCompileResult {\n return {\n definitionJson: {\n version: \"v3\",\n nodes: this.nodes,\n edges: this.edges,\n flowConfig: this.flowConfig,\n globalSettings: this.globalSettings,\n },\n previewJson: {\n kind: \"workflow_code_preview\",\n version: \"preview_v1\",\n sourceMode: \"workflow_code_ts\",\n steps: this.nodes.map((node) => ({\n id: node.id,\n type: node.type,\n label: node.data?.label || node.id,\n config: node.data,\n })),\n edges: this.edges.map((edge) => ({\n source: edge.source,\n target: edge.target,\n label: edge.label,\n })),\n },\n };\n }\n}\n\nexport function defineWorkflow(input: WorkflowDefinitionInput) {\n return {\n __openxiangdaWorkflow: true,\n compile() {\n const builder = new WorkflowBuilder(input);\n input.build(builder);\n return builder.compile();\n },\n };\n}\n\nfunction addDeclarativeNode(builder: WorkflowBuilder, node: WorkflowDeclarativeNode) {\n if (!isWorkflowNodeDescriptor(node)) {\n throw new Error(\"workflow declarative nodes must be created by flow.* helpers\");\n }\n\n switch (node.type) {\n case \"start\":\n builder.start(node.id, node.data);\n return;\n case \"end\":\n builder.end(node.id, node.data);\n return;\n case \"approval\":\n builder.approval(node.id, node.data);\n return;\n case \"copy\":\n builder.copy(node.id, node.data);\n return;\n case \"js_code\":\n builder.jsCode(node.id, node.data);\n return;\n case \"function_call\":\n builder.functionCall(node.id, node.data);\n return;\n case \"callback_wait\":\n builder.callbackWait(node.id, node.data);\n return;\n case \"connector_call\":\n builder.connectorCall(node.id, node.data);\n return;\n case \"work_notification\":\n builder.workNotification(node.id, node.data);\n return;\n case \"condition_branch\":\n builder.condition(node.id, node.data);\n return;\n case \"branch\": {\n builder.branch(node.id, node.data);\n const branches = Array.isArray(node.data?.branches) ? node.data.branches : [];\n branches.forEach((branch: any, index: number) => {\n const conditionId = sanitizeId(`${node.id}_${branch.id || index + 1}`);\n builder.condition(conditionId, {\n label: branch.label || (branch.else || branch.isElse ? \"其他情况\" : `条件 ${index + 1}`),\n condition:\n branch.condition || {\n ruleType: \"group\",\n condition: \"AND\",\n rules: [],\n },\n isElse: branch.else === true || branch.isElse === true,\n priority: String(index + 1),\n });\n builder.edge(node.id, conditionId, {\n id: `edge_${node.id}_${conditionId}`,\n label: branch.label,\n });\n if (branch.next) {\n builder.edge(conditionId, sanitizeId(branch.next), {\n id: `edge_${conditionId}_${sanitizeId(branch.next)}`,\n label: branch.label,\n });\n }\n });\n return;\n }\n default:\n builder.node(node.type, node.id, node.data);\n }\n}\n\nfunction defineDeclarativeWorkflow(input: WorkflowDeclarativeInput) {\n return {\n __openxiangdaWorkflow: true,\n compile() {\n const builder = new WorkflowBuilder(input);\n input.nodes.forEach((node) => addDeclarativeNode(builder, node));\n (input.edges || []).forEach((edge) => {\n builder.edge(edge.source, edge.target, edge.data || {});\n });\n return builder.compile();\n },\n };\n}\n\nexport const flow = {\n define(input: WorkflowDefinitionInput | WorkflowDeclarativeInput) {\n if (isDeclarativeInput(input)) {\n return defineDeclarativeWorkflow(input);\n }\n return defineWorkflow(input);\n },\n action: workflowActions,\n assignee: {\n user: (id: string, name?: string) => ({ type: \"user\", id, name: name || id }),\n initiator: () => ({ type: \"originator\", id: \"originator\", name: \"发起人\" }),\n role: (id: string, name?: string) => ({ type: \"role\", id, name: name || id }),\n departmentSupervisor: (\n level = 1,\n extra: NodeOptions = {},\n ) => ({ type: \"department_supervisor\", level, ...extra }),\n initiatorSelect: (\n scope: \"all\" | \"members\" | \"roles\" = \"all\",\n extra: NodeOptions = {},\n ) => ({ type: \"initiator_select\", scope, ...extra }),\n },\n start: (id = \"start\", data: NodeOptions = {}) =>\n createDeclarativeNode(\"start\", id, data),\n end: (id = \"end\", data: NodeOptions = {}) =>\n createDeclarativeNode(\"end\", id, data),\n approval: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"approval\", id, data),\n copy: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"copy\", id, data),\n jsCode: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"js_code\", id, data),\n functionCall: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"function_call\", id, data),\n callbackWait: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"callback_wait\", id, data),\n connectorCall: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"connector_call\", id, data),\n workNotification: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"work_notification\", id, data),\n notification: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"work_notification\", id, data),\n condition: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"condition_branch\", id, data),\n branch: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"branch\", id, data),\n data: {\n retrieveSingle: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_retrieve_single\", id, data),\n retrieveBatch: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_retrieve_batch\", id, data),\n create: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_create\", id, data),\n update: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_update\", id, data),\n },\n connect: createDeclarativeEdge,\n};\n"],"mappings":";AAqDA,SAAS,WAAW,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,CAAC,IAAY,OAAoB,CAAC,MAC/C,sBAAsB,uBAAuB,IAAI,IAAI;AAAA,IACvD,QAAQ,CAAC,IAAY,OAAoB,CAAC,MACxC,sBAAsB,eAAe,IAAI,IAAI;AAAA,IAC/C,QAAQ,CAAC,IAAY,OAAoB,CAAC,MACxC,sBAAsB,eAAe,IAAI,IAAI;AAAA,EACjD;AAAA,EACA,SAAS;AACX;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/workflow/index.ts"],"sourcesContent":["export type WorkflowNodeRef = string;\n\nexport interface WorkflowCompileResult {\n definitionJson: {\n version: \"v3\";\n nodes: any[];\n edges: any[];\n flowConfig: Record<string, any[]>;\n globalSettings: Record<string, any>;\n };\n previewJson: {\n kind: \"workflow_code_preview\";\n version: \"preview_v1\";\n steps: any[];\n edges: any[];\n sourceMode: \"workflow_code_ts\";\n };\n}\n\nexport interface WorkflowDefinitionInput {\n name?: string;\n formCode?: string;\n formUuid?: string;\n globalSettings?: Record<string, any>;\n build: (flow: WorkflowBuilder) => void;\n}\n\nexport interface WorkflowDeclarativeInput {\n id?: string;\n name?: string;\n formCode?: string;\n formUuid?: string;\n globalSettings?: Record<string, any>;\n nodes: WorkflowDeclarativeNode[];\n edges?: WorkflowDeclarativeEdge[];\n}\n\nexport interface WorkflowDeclarativeNode {\n __openxiangdaWorkflowNode: true;\n id: WorkflowNodeRef;\n type: string;\n data: NodeOptions;\n}\n\nexport interface WorkflowDeclarativeEdge {\n __openxiangdaWorkflowEdge: true;\n source: WorkflowNodeRef;\n target: WorkflowNodeRef;\n data?: NodeOptions;\n}\n\ntype NodeOptions = Record<string, any>;\n\nfunction sanitizeId(value: string) {\n return String(value || \"\")\n .trim()\n .replace(/[^a-zA-Z0-9_-]/g, \"_\");\n}\n\nfunction createPosition(index: number) {\n return { x: 400, y: 100 + index * 150 };\n}\n\nfunction hasRequiredValue(value: any) {\n if (Array.isArray(value)) return value.length > 0;\n return value !== undefined && value !== null && String(value).trim() !== \"\";\n}\n\nfunction validateCompiledWorkflowDefinition(definitionJson: WorkflowCompileResult[\"definitionJson\"]) {\n const errors: string[] = [];\n for (const node of definitionJson.nodes || []) {\n const nodeId = node?.id || \"<unknown>\";\n const data = node?.data || {};\n switch (node?.type) {\n case \"function_call\":\n if (!hasRequiredValue(data.functionCode)) {\n errors.push(`function_call node ${nodeId} requires functionCode`);\n }\n break;\n case \"callback_wait\":\n if (!hasRequiredValue(data.eventCode)) {\n errors.push(`callback_wait node ${nodeId} requires eventCode`);\n }\n break;\n case \"work_notification\":\n if (\n !hasRequiredValue(data.title) ||\n !hasRequiredValue(data.content) ||\n !hasRequiredValue(data.recipientType)\n ) {\n errors.push(`work_notification node ${nodeId} requires title, content, and recipientType`);\n }\n break;\n default:\n break;\n }\n }\n if (errors.length > 0) {\n throw new Error(`workflow DSL validation failed:\\n- ${errors.join(\"\\n- \")}`);\n }\n}\n\nfunction normalizeAction(action: string, label: string, extra: NodeOptions = {}) {\n return {\n action,\n name: { zh_CN: label },\n ...extra,\n };\n}\n\nconst workflowActions = {\n approve: (label = \"同意\", extra: NodeOptions = {}) =>\n normalizeAction(\"agree\", label, extra),\n reject: (label = \"拒绝\", extra: NodeOptions = {}) =>\n normalizeAction(\"rejected\", label, extra),\n transfer: (label = \"转交\", extra: NodeOptions = {}) =>\n normalizeAction(\"transfer\", label, {\n remark: { popUp: true, required: false },\n ...extra,\n }),\n return: (label = \"退回\", extra: NodeOptions = {}) =>\n normalizeAction(\"return\", label, {\n remark: { popUp: true, required: false },\n ...extra,\n }),\n returnToInitiator: (label = \"退回发起人\", extra: NodeOptions = {}) =>\n normalizeAction(\"return\", label, {\n remark: { popUp: true, required: false },\n returnTarget: \"initiator\",\n returnScope: \"initiator\",\n ...extra,\n }),\n save: (label = \"暂存\", extra: NodeOptions = {}) =>\n normalizeAction(\"save\", label, extra),\n withdraw: (label = \"撤回\", extra: NodeOptions = {}) =>\n normalizeAction(\"withdraw\", label, extra),\n resubmit: (label = \"重新提交\", extra: NodeOptions = {}) =>\n normalizeAction(\"resubmit\", label, extra),\n callback: (label = \"触发回调\", extra: NodeOptions = {}) =>\n normalizeAction(\"callback\", label, extra),\n retryException: (label = \"重试异常\", extra: NodeOptions = {}) =>\n normalizeAction(\"retryException\", label, extra),\n adminTransfer: (label = \"管理员转交\", extra: NodeOptions = {}) =>\n normalizeAction(\"adminTransfer\", label, extra),\n};\n\nfunction normalizeReturnConfig(value: any) {\n if (value === false) return { enabled: false };\n if (value === true || value === undefined) {\n return { enabled: true, scopeType: \"previous_all\" };\n }\n return {\n enabled: value.enabled !== false,\n scopeType: value.scopeType || value.scope || \"previous_all\",\n resubmitMode: value.resubmitMode || \"resume_current\",\n ...value,\n };\n}\n\nfunction findInitiatorReturnAction(actions: any[]) {\n return actions.find(\n (action) =>\n action?.action === \"return\" &&\n (action.returnTarget === \"initiator\" || action.returnScope === \"initiator\"),\n );\n}\n\nfunction inferReturnConfigFromActions(actions: any[], explicitReturnConfig?: any) {\n const initiatorReturnAction = findInitiatorReturnAction(actions);\n if (!initiatorReturnAction) return explicitReturnConfig;\n\n const base =\n explicitReturnConfig ||\n normalizeReturnConfig({\n scopeType: \"previous_all\",\n resubmitMode: initiatorReturnAction.resubmitMode || \"replay\",\n });\n\n return {\n ...base,\n allowOriginatorReturn: true,\n };\n}\n\nfunction normalizeFieldBehavior(value: any) {\n const normalized = String(value || \"\").trim().toLowerCase();\n if ([\"normal\", \"edit\", \"editable\", \"write\", \"writable\"].includes(normalized)) return \"NORMAL\";\n if ([\"readonly\", \"read\", \"view\", \"visible\"].includes(normalized)) return \"READONLY\";\n if ([\"hidden\", \"hide\", \"invisible\"].includes(normalized)) return \"HIDDEN\";\n return String(value || \"READONLY\").toUpperCase();\n}\n\nfunction normalizeFieldPermissions(value: any): any[] | undefined {\n if (Array.isArray(value)) {\n return value.map((item) => {\n if (!item || typeof item !== \"object\") return item;\n return {\n ...item,\n fieldId: item.fieldId || item.field || item.id,\n fieldBehavior: normalizeFieldBehavior(item.fieldBehavior || item.behavior || item.permission),\n };\n });\n }\n if (value && typeof value === \"object\") {\n return Object.entries(value).map(([fieldId, fieldBehavior]) => ({\n fieldId,\n fieldBehavior: normalizeFieldBehavior(fieldBehavior),\n }));\n }\n return undefined;\n}\n\nfunction createDeclarativeNode(\n type: string,\n id: string,\n data: NodeOptions = {},\n): WorkflowDeclarativeNode {\n return {\n __openxiangdaWorkflowNode: true,\n id: sanitizeId(id),\n type,\n data,\n };\n}\n\nfunction createDeclarativeEdge(\n source: WorkflowNodeRef,\n target: WorkflowNodeRef,\n data: NodeOptions = {},\n): WorkflowDeclarativeEdge {\n return {\n __openxiangdaWorkflowEdge: true,\n source,\n target,\n data,\n };\n}\n\nfunction isDeclarativeInput(input: any): input is WorkflowDeclarativeInput {\n return input && Array.isArray(input.nodes);\n}\n\nfunction isWorkflowNodeDescriptor(value: any): value is WorkflowDeclarativeNode {\n return Boolean(value?.__openxiangdaWorkflowNode);\n}\n\nfunction normalizeAssignee(value: any) {\n if (typeof value === \"string\") {\n return { type: value === \"originator\" ? \"originator\" : \"user\", id: value, name: value };\n }\n return value || {};\n}\n\nfunction normalizeApprovalData(data: NodeOptions = {}) {\n const normalized: NodeOptions = { ...data };\n const assignees = Array.isArray(data.assignees)\n ? data.assignees.map(normalizeAssignee)\n : undefined;\n\n if (assignees && !normalized.approverType) {\n const supervisor = assignees.find((item) => item.type === \"department_supervisor\");\n const initiatorSelect = assignees.find((item) => item.type === \"initiator_select\");\n const roleAssignees = assignees.filter((item) => item.type === \"role\");\n const userAssignees = assignees.filter((item) => item.type === \"user\" || item.type === \"originator\");\n\n if (supervisor) {\n normalized.approverType = \"ext_target_approval_department_supervisor\";\n normalized.supervisorConfig = {\n level: supervisor.level || 1,\n fallbackToAncestorSupervisor: supervisor.fallbackToAncestorSupervisor !== false,\n ...(normalized.supervisorConfig || {}),\n };\n normalized.approvals = normalized.approvals || [];\n normalized.approvalNames = normalized.approvalNames || [];\n } else if (initiatorSelect) {\n normalized.approverType = \"ext_target_approval_initiator_select\";\n normalized.initiatorSelectScope = initiatorSelect.scope || initiatorSelect.initiatorSelectScope || \"all\";\n normalized.approvals =\n normalized.approvals ||\n (Array.isArray(initiatorSelect.approvals)\n ? initiatorSelect.approvals\n : roleAssignees.map((item) => item.id).filter(Boolean));\n normalized.approvalNames =\n normalized.approvalNames ||\n (Array.isArray(initiatorSelect.approvalNames)\n ? initiatorSelect.approvalNames\n : roleAssignees.map((item) => item.name || item.id).filter(Boolean));\n } else if (roleAssignees.length > 0 && userAssignees.length === 0) {\n normalized.approverType = \"ext_target_approval_role\";\n normalized.approvals = normalized.approvals || roleAssignees.map((item) => item.id).filter(Boolean);\n normalized.approvalNames =\n normalized.approvalNames || roleAssignees.map((item) => item.name || item.id).filter(Boolean);\n } else {\n normalized.approverType = \"ext_target_approval\";\n normalized.approvals =\n normalized.approvals ||\n userAssignees\n .map((item) => (item.type === \"originator\" ? \"originator\" : item.id))\n .filter(Boolean);\n normalized.approvalNames =\n normalized.approvalNames ||\n userAssignees\n .map((item) => item.name || (item.type === \"originator\" ? \"发起人\" : item.id))\n .filter(Boolean);\n }\n }\n\n return normalized;\n}\n\nexport class WorkflowBuilder {\n private nodes: any[] = [];\n private edges: any[] = [];\n private flowConfig: Record<string, any[]> = {};\n private globalSettings: Record<string, any> = {};\n readonly action = workflowActions;\n\n constructor(private readonly meta: Omit<WorkflowDefinitionInput, \"build\"> = {}) {\n this.globalSettings = { ...(meta.globalSettings || {}) };\n }\n\n start(id = \"start\", data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"start\", id, { label: \"开始节点\", ...data });\n }\n\n end(id = \"end\", data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"end\", id, { label: \"结束节点\", ...data });\n }\n\n approval(id: string, data: NodeOptions): WorkflowNodeRef {\n const approvalData = normalizeApprovalData(data);\n const actions =\n approvalData.buttons || approvalData.actions || [\n this.action.approve(),\n this.action.reject(),\n ];\n const returnConfig =\n approvalData.returnConfig !== undefined\n ? normalizeReturnConfig(approvalData.returnConfig)\n : approvalData.returnPolicy !== undefined\n ? normalizeReturnConfig(approvalData.returnPolicy)\n : undefined;\n const inferredReturnConfig = inferReturnConfigFromActions(actions, returnConfig);\n return this.node(\"approval\", id, {\n label: approvalData.label || \"审批\",\n value: approvalData.value || \"\",\n approverType: approvalData.approverType || \"ext_target_approval\",\n approvals: approvalData.approvals || [],\n approvalNames: approvalData.approvalNames || [],\n multiApprove: approvalData.multiApprove || \"or\",\n ...approvalData,\n actions,\n ...(inferredReturnConfig ? { returnConfig: inferredReturnConfig } : {}),\n });\n }\n\n copy(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"copy\", id, {\n label: data.label || \"抄送\",\n value: data.value || \"\",\n approverType: data.approverType || \"ext_target_approval\",\n approvals: data.approvals || [],\n approvalNames: data.approvalNames || [],\n ...data,\n });\n }\n\n jsCode(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"js_code\", id, {\n label: data.label || \"JS代码节点\",\n runtimeMode: \"trusted_node\",\n sourceType: data.sourceFile ? \"file_snapshot\" : data.sourceType || \"inline\",\n timeout: data.timeout || data.timeoutMs || 30000,\n ...data,\n });\n }\n\n functionCall(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"function_call\", id, {\n label: data.label || \"调用函数\",\n functionCode: data.functionCode || data.functionName || data.code,\n input: data.input || data.inputMapping || {},\n saveResponseTo: data.saveResponseTo || data.outputKey,\n timeout: data.timeout || data.timeoutMs || 30000,\n ...data,\n });\n }\n\n callbackWait(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"callback_wait\", id, {\n type: \"callback_wait\",\n label: data.label || \"回调等待\",\n timeoutSeconds: data.timeoutSeconds || 86400,\n timeoutStrategy: data.timeoutStrategy || \"FAIL\",\n ...data,\n });\n }\n\n connectorCall(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"connector_call\", id, {\n type: \"connector_call\",\n label: data.label || \"连接器\",\n timeout: data.timeout || 30000,\n ...data,\n });\n }\n\n workNotification(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"work_notification\", id, {\n label: data.label || \"工作通知\",\n buttonText: data.buttonText || \"查看详情\",\n linkType: data.linkType || \"current_form\",\n ...data,\n });\n }\n\n notification(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.workNotification(id, data);\n }\n\n dingtalkCard(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"dingtalk_card\", id, {\n config: {\n type: \"dingtalk_card\",\n label: data.label || \"钉钉消息卡片\",\n sameFieldStrategy: \"create\",\n ...(data.config || data),\n },\n });\n }\n\n condition(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"condition_branch\", id, {\n type: \"condition_branch\",\n label: data.label || \"条件分支\",\n condition: data.condition || { ruleType: \"group\", condition: \"AND\", rules: [] },\n isElse: data.isElse === true,\n priority: data.priority || \"1\",\n trueNodeId: data.trueNodeId,\n falseNodeId: data.falseNodeId,\n ...data,\n });\n }\n\n branch(id: string, data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"branch\", id, {\n label: data.label || \"辅助分支\",\n isAuxNode: data.isAuxNode ?? true,\n branchType: data.branchType || \"controller\",\n ...data,\n });\n }\n\n parallel(\n id: string,\n branches: Array<{\n id: string;\n label?: string;\n nodes: WorkflowNodeRef[];\n }>,\n data: NodeOptions = {},\n ) {\n const entry = this.branch(`${id}_branch`, {\n label: data.label || \"并行分支\",\n branchType: \"parallel_controller\",\n hidden: true,\n });\n const converge = this.branch(`${id}_converge`, {\n label: data.convergeLabel || \"并行汇聚\",\n branchType: \"converge\",\n hidden: true,\n });\n\n branches.forEach((branch, index) => {\n const nodes = branch.nodes.filter(Boolean);\n if (nodes.length === 0) return;\n this.edge(entry, nodes[0], {\n id: `edge_${entry}_${sanitizeId(branch.id || String(index))}`,\n label: branch.label,\n });\n this.sequence(...nodes);\n this.edge(nodes[nodes.length - 1], converge, {\n id: `edge_${sanitizeId(branch.id || String(index))}_${converge}`,\n });\n });\n\n return { entry, converge };\n }\n\n conditionBranches(\n id: string,\n branches: Array<{\n id: string;\n label?: string;\n condition?: any;\n nodes: WorkflowNodeRef[];\n isElse?: boolean;\n }>,\n data: NodeOptions = {},\n ) {\n const entry = this.branch(`${id}_controller`, {\n label: data.label || \"条件分支\",\n branchType: \"condition_controller\",\n hidden: true,\n });\n const converge = this.branch(`${id}_converge`, {\n label: data.convergeLabel || \"条件汇聚\",\n branchType: \"converge\",\n hidden: true,\n });\n\n branches.forEach((branch, index) => {\n const condition = this.condition(`${id}_${branch.id}`, {\n label: branch.label || (branch.isElse ? \"其他情况\" : `条件 ${index + 1}`),\n condition:\n branch.condition || {\n ruleType: \"group\",\n condition: \"AND\",\n rules: [],\n },\n isElse: branch.isElse === true,\n priority: String(index + 1),\n });\n this.edge(entry, condition, {\n id: `edge_${entry}_${condition}`,\n label: branch.label,\n });\n const nodes = branch.nodes.filter(Boolean);\n if (nodes.length > 0) {\n this.edge(condition, nodes[0], {\n id: `edge_${condition}_${nodes[0]}`,\n label: branch.label,\n });\n this.sequence(...nodes);\n this.edge(nodes[nodes.length - 1], converge, {\n id: `edge_${nodes[nodes.length - 1]}_${converge}`,\n });\n } else {\n this.edge(condition, converge, {\n id: `edge_${condition}_${converge}`,\n });\n }\n });\n\n if (!branches.some((branch) => branch.isElse)) {\n const elseNode = this.condition(`${id}_else`, {\n label: \"其他情况\",\n isElse: true,\n priority: String(branches.length + 1),\n condition: { ruleType: \"group\", condition: \"AND\", rules: [] },\n });\n this.edge(entry, elseNode, { id: `edge_${entry}_${elseNode}`, label: \"其他情况\" });\n this.edge(elseNode, converge, { id: `edge_${elseNode}_${converge}` });\n }\n\n return { entry, converge };\n }\n\n data = {\n retrieveSingle: (id: string, data: NodeOptions) =>\n this.node(\"data_retrieve_single\", id, {\n type: \"data_retrieve_single\",\n label: data.label || \"获取单条数据\",\n filterType: data.filterType || \"condition\",\n ...data,\n }),\n retrieveBatch: (id: string, data: NodeOptions) =>\n this.node(\"data_retrieve_batch\", id, {\n type: \"data_retrieve_batch\",\n label: data.label || \"获取多条数据\",\n filterType: data.filterType || \"condition\",\n ...data,\n }),\n create: (id: string, data: NodeOptions) =>\n this.node(\"data_create\", id, {\n type: \"data_create\",\n label: data.label || \"新增数据\",\n insertType: data.insertType || \"form\",\n assignments: data.assignments || [],\n ...data,\n }),\n update: (id: string, data: NodeOptions) =>\n this.node(\"data_update\", id, {\n type: \"data_update\",\n label: data.label || \"更新数据\",\n updateType: data.updateType || \"direct_form\",\n assignments: data.assignments || [],\n noneOperation: data.noneOperation || \"ignored\",\n ...data,\n }),\n };\n\n node(type: string, id: string, data: NodeOptions): WorkflowNodeRef {\n const nodeId = sanitizeId(id);\n if (!nodeId) throw new Error(\"workflow node id is required\");\n if (this.nodes.some((node) => node.id === nodeId)) {\n throw new Error(`duplicate workflow node id: ${nodeId}`);\n }\n this.nodes.push({\n id: nodeId,\n type,\n data,\n position: createPosition(this.nodes.length),\n });\n const fieldPermissions = normalizeFieldPermissions(data.fieldPermissions);\n if (fieldPermissions) {\n this.flowConfig[nodeId] = fieldPermissions;\n }\n return nodeId;\n }\n\n edge(source: WorkflowNodeRef, target: WorkflowNodeRef, data: NodeOptions = {}) {\n const id = data.id || `edge_${source}_${target}`;\n this.edges.push({\n id,\n source,\n target,\n type: data.type || \"custom\",\n ...(data.label ? { label: data.label } : {}),\n });\n }\n\n connect(source: WorkflowNodeRef, target: WorkflowNodeRef, data: NodeOptions = {}) {\n this.edge(source, target, data);\n }\n\n sequence(...refs: WorkflowNodeRef[]) {\n for (let index = 0; index < refs.length - 1; index += 1) {\n this.edge(refs[index], refs[index + 1]);\n }\n }\n\n setFieldPermissions(nodeId: WorkflowNodeRef, permissions: any[]) {\n this.flowConfig[nodeId] = permissions;\n }\n\n setGlobalSettings(settings: Record<string, any>) {\n this.globalSettings = { ...this.globalSettings, ...settings };\n }\n\n compile(): WorkflowCompileResult {\n const definitionJson = {\n version: \"v3\" as const,\n nodes: this.nodes,\n edges: this.edges,\n flowConfig: this.flowConfig,\n globalSettings: this.globalSettings,\n };\n validateCompiledWorkflowDefinition(definitionJson);\n return {\n definitionJson,\n previewJson: {\n kind: \"workflow_code_preview\",\n version: \"preview_v1\",\n sourceMode: \"workflow_code_ts\",\n steps: this.nodes.map((node) => ({\n id: node.id,\n type: node.type,\n label: node.data?.label || node.id,\n config: node.data,\n })),\n edges: this.edges.map((edge) => ({\n source: edge.source,\n target: edge.target,\n label: edge.label,\n })),\n },\n };\n }\n}\n\nexport function defineWorkflow(input: WorkflowDefinitionInput) {\n return {\n __openxiangdaWorkflow: true,\n compile() {\n const builder = new WorkflowBuilder(input);\n input.build(builder);\n return builder.compile();\n },\n };\n}\n\nfunction addDeclarativeNode(builder: WorkflowBuilder, node: WorkflowDeclarativeNode) {\n if (!isWorkflowNodeDescriptor(node)) {\n throw new Error(\"workflow declarative nodes must be created by flow.* helpers\");\n }\n\n switch (node.type) {\n case \"start\":\n builder.start(node.id, node.data);\n return;\n case \"end\":\n builder.end(node.id, node.data);\n return;\n case \"approval\":\n builder.approval(node.id, node.data);\n return;\n case \"copy\":\n builder.copy(node.id, node.data);\n return;\n case \"js_code\":\n builder.jsCode(node.id, node.data);\n return;\n case \"function_call\":\n builder.functionCall(node.id, node.data);\n return;\n case \"callback_wait\":\n builder.callbackWait(node.id, node.data);\n return;\n case \"connector_call\":\n builder.connectorCall(node.id, node.data);\n return;\n case \"work_notification\":\n builder.workNotification(node.id, node.data);\n return;\n case \"condition_branch\":\n builder.condition(node.id, node.data);\n return;\n case \"branch\": {\n builder.branch(node.id, node.data);\n const branches = Array.isArray(node.data?.branches) ? node.data.branches : [];\n branches.forEach((branch: any, index: number) => {\n const conditionId = sanitizeId(`${node.id}_${branch.id || index + 1}`);\n builder.condition(conditionId, {\n label: branch.label || (branch.else || branch.isElse ? \"其他情况\" : `条件 ${index + 1}`),\n condition:\n branch.condition || {\n ruleType: \"group\",\n condition: \"AND\",\n rules: [],\n },\n isElse: branch.else === true || branch.isElse === true,\n priority: String(index + 1),\n });\n builder.edge(node.id, conditionId, {\n id: `edge_${node.id}_${conditionId}`,\n label: branch.label,\n });\n if (branch.next) {\n builder.edge(conditionId, sanitizeId(branch.next), {\n id: `edge_${conditionId}_${sanitizeId(branch.next)}`,\n label: branch.label,\n });\n }\n });\n return;\n }\n default:\n builder.node(node.type, node.id, node.data);\n }\n}\n\nfunction defineDeclarativeWorkflow(input: WorkflowDeclarativeInput) {\n return {\n __openxiangdaWorkflow: true,\n compile() {\n const builder = new WorkflowBuilder(input);\n input.nodes.forEach((node) => addDeclarativeNode(builder, node));\n (input.edges || []).forEach((edge) => {\n builder.edge(edge.source, edge.target, edge.data || {});\n });\n return builder.compile();\n },\n };\n}\n\nexport const flow = {\n define(input: WorkflowDefinitionInput | WorkflowDeclarativeInput) {\n if (isDeclarativeInput(input)) {\n return defineDeclarativeWorkflow(input);\n }\n return defineWorkflow(input);\n },\n action: workflowActions,\n assignee: {\n user: (id: string, name?: string) => ({ type: \"user\", id, name: name || id }),\n initiator: () => ({ type: \"originator\", id: \"originator\", name: \"发起人\" }),\n role: (id: string, name?: string) => ({ type: \"role\", id, name: name || id }),\n departmentSupervisor: (\n level = 1,\n extra: NodeOptions = {},\n ) => ({ type: \"department_supervisor\", level, ...extra }),\n initiatorSelect: (\n scope: \"all\" | \"members\" | \"roles\" = \"all\",\n extra: NodeOptions = {},\n ) => ({ type: \"initiator_select\", scope, ...extra }),\n },\n start: (id = \"start\", data: NodeOptions = {}) =>\n createDeclarativeNode(\"start\", id, data),\n end: (id = \"end\", data: NodeOptions = {}) =>\n createDeclarativeNode(\"end\", id, data),\n approval: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"approval\", id, data),\n copy: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"copy\", id, data),\n jsCode: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"js_code\", id, data),\n functionCall: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"function_call\", id, data),\n callbackWait: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"callback_wait\", id, data),\n connectorCall: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"connector_call\", id, data),\n workNotification: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"work_notification\", id, data),\n notification: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"work_notification\", id, data),\n condition: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"condition_branch\", id, data),\n branch: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"branch\", id, data),\n data: {\n retrieveSingle: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_retrieve_single\", id, data),\n retrieveBatch: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_retrieve_batch\", id, data),\n create: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_create\", id, data),\n update: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_update\", id, data),\n },\n connect: createDeclarativeEdge,\n};\n"],"mappings":";AAqDA,SAAS,WAAW,OAAe;AACjC,SAAO,OAAO,SAAS,EAAE,EACtB,KAAK,EACL,QAAQ,mBAAmB,GAAG;AACnC;AAEA,SAAS,eAAe,OAAe;AACrC,SAAO,EAAE,GAAG,KAAK,GAAG,MAAM,QAAQ,IAAI;AACxC;AAEA,SAAS,iBAAiB,OAAY;AACpC,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,SAAS;AAChD,SAAO,UAAU,UAAa,UAAU,QAAQ,OAAO,KAAK,EAAE,KAAK,MAAM;AAC3E;AAEA,SAAS,mCAAmC,gBAAyD;AACnG,QAAM,SAAmB,CAAC;AAC1B,aAAW,QAAQ,eAAe,SAAS,CAAC,GAAG;AAC7C,UAAM,SAAS,MAAM,MAAM;AAC3B,UAAM,OAAO,MAAM,QAAQ,CAAC;AAC5B,YAAQ,MAAM,MAAM;AAAA,MAClB,KAAK;AACH,YAAI,CAAC,iBAAiB,KA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B,CAAC,IAAY,OAAoB,CAAC,MAClD,sBAAsB,qBAAqB,IAAI,IAAI;AAAA,EACrD,cAAc,CAAC,IAAY,OAAoB,CAAC,MAC9C,sBAAsB,qBAAqB,IAAI,IAAI;AAAA,EACrD,WAAW,CAAC,IAAY,OAAoB,CAAC,MAC3C,sBAAsB,oBAAoB,IAAI,IAAI;AAAA,EACpD,QAAQ,CAAC,IAAY,OAAoB,CAAC,MACxC,sBAAsB,UAAU,IAAI,IAAI;AAAA,EAC1C,MAAM;AAAA,IACJ,gBAAgB,CAAC,IAAY,OAAoB,CAAC,MAChD,sBAAsB,wBAAwB,IAAI,IAAI;AAAA,IACxD,eAAe,CAAC,IAAY,OAAoB,CAAC,MAC/C,sBAAsB,uBAAuB,IAAI,IAAI;AAAA,IACvD,QAAQ,CAAC,IAAY,OAAoB,CAAC,MACxC,sBAAsB,eAAe,IAAI,IAAI;AAAA,IAC/C,QAAQ,CAAC,IAAY,OAAoB,CAAC,MACxC,sBAAsB,eAAe,IAAI,IAAI;AAAA,EACjD;AAAA,EACA,SAAS;AACX;","names":[]}
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
ensureSchemaFormUuid,
|
|
23
23
|
getOpenApiAccessToken,
|
|
24
24
|
isOpenXiangdaMode,
|
|
25
|
+
markWorkspaceFormSchemaSynced,
|
|
25
26
|
} from "./utils/form-api.mjs";
|
|
26
27
|
import {
|
|
27
28
|
assertSchemaSyncResult,
|
|
@@ -305,6 +306,12 @@ async function main() {
|
|
|
305
306
|
} else {
|
|
306
307
|
try {
|
|
307
308
|
const response = await sendToApi(apiPayload, config, accessToken);
|
|
309
|
+
markWorkspaceFormSchemaSynced(config, form.name, apiPayload.formUuid, {
|
|
310
|
+
title: schema.formMeta?.title || form.name,
|
|
311
|
+
formType: apiPayload.formType || schema.formMeta?.formType || "receipt",
|
|
312
|
+
fieldCount: apiPayload.fieldCount,
|
|
313
|
+
tableName: response?.data?.tableName,
|
|
314
|
+
});
|
|
308
315
|
console.log(` ✅ 同步成功,tableName=${response.data.tableName}`);
|
|
309
316
|
results.push({ name: form.name, success: true, response });
|
|
310
317
|
} catch (error) {
|
|
@@ -116,6 +116,13 @@ function saveWorkspaceFormBinding(config, formName, formUuid, extra = {}) {
|
|
|
116
116
|
return true;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
export function markWorkspaceFormSchemaSynced(config, formName, formUuid, extra = {}) {
|
|
120
|
+
return saveWorkspaceFormBinding(config, formName, formUuid, {
|
|
121
|
+
...extra,
|
|
122
|
+
schemaSyncedAt: new Date().toISOString(),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
119
126
|
function readExportedStringConstant(filePath, exportName) {
|
|
120
127
|
if (!filePath || !fs.existsSync(filePath)) return "";
|
|
121
128
|
const content = fs.readFileSync(filePath, "utf-8");
|
|
@@ -33,7 +33,7 @@ openxiangda runtime deploy --profile <name>
|
|
|
33
33
|
openxiangda commands --json
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
`pnpm deploy -- --profile <name>` 会按顺序执行 `openxiangda resource publish --profile <name>` 与 `openxiangda runtime deploy --profile <name
|
|
36
|
+
`pnpm deploy -- --profile <name>` 会按顺序执行 `openxiangda resource publish --profile <name>` 与 `openxiangda runtime deploy --profile <name>`。如果应用包含 `src/forms/<formCode>/schema.ts`,先执行 `openxiangda workspace publish --profile <name> --form <formCode>` 初始化表单 schema/table。不要直接运行 `pnpm publish:all`、`pnpm openxiangda:publish` 或 `lowcode-workspace publish-all`;这些是 legacy classic workspace 的内部发布入口,会被 `scripts/guard-publish.mjs` 拦截。
|
|
37
37
|
|
|
38
38
|
完整发布顺序:
|
|
39
39
|
|
|
@@ -4,7 +4,8 @@ const lines = [
|
|
|
4
4
|
'',
|
|
5
5
|
'错误:React SPA 工作区不要直接调用 lowcode-workspace publish-all。',
|
|
6
6
|
'',
|
|
7
|
-
'React SPA
|
|
7
|
+
'React SPA 的发布入口必须显式指定 profile:',
|
|
8
|
+
' openxiangda workspace publish --profile <name> --form <formCode> # 仅同步表单 schema',
|
|
8
9
|
' openxiangda resource publish --profile <name>',
|
|
9
10
|
' openxiangda runtime deploy --profile <name>',
|
|
10
11
|
'',
|