openxiangda 1.0.107 → 1.0.109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/cli.js +89 -11
- package/lib/design-gates.js +42 -2
- package/openxiangda-skills/SKILL.md +2 -2
- package/openxiangda-skills/references/notifications.md +8 -0
- package/openxiangda-skills/references/openxiangda-api.md +16 -1
- package/openxiangda-skills/references/resource-manifest-cheatsheet.md +2 -1
- package/openxiangda-skills/references/workflow-v3.md +1 -1
- package/openxiangda-skills/skills/openxiangda-core/SKILL.md +1 -0
- package/openxiangda-skills/skills/openxiangda-workflow-automation/SKILL.md +1 -1
- package/package.json +1 -1
- package/packages/sdk/dist/workflow/index.cjs +63 -9
- package/packages/sdk/dist/workflow/index.cjs.map +1 -1
- package/packages/sdk/dist/workflow/index.mjs +63 -9
- package/packages/sdk/dist/workflow/index.mjs.map +1 -1
package/README.md
CHANGED
|
@@ -105,7 +105,7 @@ openxiangda public-access grant-check public_register --form-code registration_f
|
|
|
105
105
|
openxiangda auth-config methods --json
|
|
106
106
|
openxiangda function invoke submit_public_registration --body-json '{"input":{}}'
|
|
107
107
|
openxiangda connector invoke sms.sendCode --body-json '{"body":{"phone":"13800000000"}}'
|
|
108
|
-
openxiangda notification preview public_register_notice --body-json '{"
|
|
108
|
+
openxiangda notification preview public_register_notice --body-json '{"payload":{"title":"测试"}}'
|
|
109
109
|
openxiangda permission audit --json
|
|
110
110
|
```
|
|
111
111
|
|
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]
|
|
@@ -2856,7 +2856,12 @@ async function notification(args) {
|
|
|
2856
2856
|
const { subcommand, rest } = parseSubcommandArgs(args);
|
|
2857
2857
|
const { flags, positional } = parseArgs(rest);
|
|
2858
2858
|
if (wantsSubcommandHelp(subcommand, flags)) {
|
|
2859
|
-
print(
|
|
2859
|
+
print([
|
|
2860
|
+
'用法: openxiangda notification template-list|template-get|template-upsert|template-delete|type-list|type-get|type-upsert|type-delete|preview|send|batch-send',
|
|
2861
|
+
' preview <templateCode> --body-json \'{"payload":{"title":"测试"}}\'',
|
|
2862
|
+
' send <notificationType> --body-json \'{"recipientId":"USER_ID","payload":{"title":"测试"}}\' --force',
|
|
2863
|
+
' batch-send <notificationType> --body-json \'{"recipients":[{"recipientId":"USER_ID","payload":{}}]}\' --force',
|
|
2864
|
+
].join('\n'));
|
|
2860
2865
|
return;
|
|
2861
2866
|
}
|
|
2862
2867
|
const config = loadConfig();
|
|
@@ -2955,13 +2960,20 @@ async function notification(args) {
|
|
|
2955
2960
|
fail(`openxiangda notification ${subcommand} 是发送动作,必须加 --force`);
|
|
2956
2961
|
}
|
|
2957
2962
|
const code = positional[0] || flags.code;
|
|
2958
|
-
const body =
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2963
|
+
const body = normalizeNotificationActionBody(
|
|
2964
|
+
subcommand,
|
|
2965
|
+
code,
|
|
2966
|
+
readDirectJsonBody(flags, `notification ${subcommand}`, { optional: true })
|
|
2967
|
+
);
|
|
2968
|
+
const actionPath =
|
|
2969
|
+
subcommand === 'preview'
|
|
2970
|
+
? 'templates/preview'
|
|
2971
|
+
: subcommand === 'batch-send'
|
|
2972
|
+
? 'batch-send-by-type'
|
|
2973
|
+
: 'send-by-type';
|
|
2962
2974
|
return runDirectRequest(config, target, flags, {
|
|
2963
2975
|
method: 'POST',
|
|
2964
|
-
path: `${appPrefix}/${
|
|
2976
|
+
path: `${appPrefix}/${actionPath}`,
|
|
2965
2977
|
body,
|
|
2966
2978
|
strictEnvelope: true,
|
|
2967
2979
|
});
|
|
@@ -3601,14 +3613,14 @@ async function resource(args) {
|
|
|
3601
3613
|
const { subcommand, rest } = parseSubcommandArgs(args);
|
|
3602
3614
|
const { flags, positional } = parseArgs(rest);
|
|
3603
3615
|
if (wantsSubcommandHelp(subcommand, flags)) {
|
|
3604
|
-
print('用法: openxiangda resource validate|plan|publish|pull|typegen|explain [type] [--profile name] [--json]');
|
|
3616
|
+
print('用法: openxiangda resource validate|plan|publish|pull|typegen|explain [type] [--profile name] [--json] [--dry-run]');
|
|
3605
3617
|
return;
|
|
3606
3618
|
}
|
|
3607
3619
|
const config = loadConfig();
|
|
3608
3620
|
const profileName = flags.profile || config.currentProfile;
|
|
3609
3621
|
|
|
3610
3622
|
if (!['validate', 'plan', 'publish', 'pull', 'typegen', 'explain'].includes(subcommand)) {
|
|
3611
|
-
fail('用法: openxiangda resource validate|plan|publish|pull|typegen|explain [--profile name] [--json]');
|
|
3623
|
+
fail('用法: openxiangda resource validate|plan|publish|pull|typegen|explain [--profile name] [--json] [--dry-run]');
|
|
3612
3624
|
}
|
|
3613
3625
|
|
|
3614
3626
|
if (subcommand === 'explain') {
|
|
@@ -3638,6 +3650,7 @@ async function resource(args) {
|
|
|
3638
3650
|
}
|
|
3639
3651
|
|
|
3640
3652
|
const validation = validateWorkspaceResources(manifest);
|
|
3653
|
+
await validateCompiledWorkflowResources(manifest, validation);
|
|
3641
3654
|
if (subcommand === 'validate') {
|
|
3642
3655
|
if (flags.json) return writeJson(validation);
|
|
3643
3656
|
printResourceValidation(validation);
|
|
@@ -3651,8 +3664,13 @@ async function resource(args) {
|
|
|
3651
3664
|
}
|
|
3652
3665
|
|
|
3653
3666
|
const target = getWorkspaceTarget(config, profileName, flags);
|
|
3654
|
-
|
|
3667
|
+
const dryRun = subcommand === 'publish' && Boolean(flags['dry-run']);
|
|
3668
|
+
if (subcommand === 'plan' || dryRun) {
|
|
3655
3669
|
const plan = await buildResourcePlan(config, target, manifest);
|
|
3670
|
+
if (dryRun) {
|
|
3671
|
+
plan.dryRun = true;
|
|
3672
|
+
plan.command = 'resource publish --dry-run';
|
|
3673
|
+
}
|
|
3656
3674
|
if (flags.json) return writeJson(plan);
|
|
3657
3675
|
printResourcePlan(plan);
|
|
3658
3676
|
return;
|
|
@@ -4587,6 +4605,47 @@ function extractNotificationTypeConfigBody(bound, body) {
|
|
|
4587
4605
|
};
|
|
4588
4606
|
}
|
|
4589
4607
|
|
|
4608
|
+
function normalizeNotificationActionBody(subcommand, code, rawBody = {}) {
|
|
4609
|
+
const body = { ...(rawBody || {}) };
|
|
4610
|
+
if (body.variables && !body.payload) {
|
|
4611
|
+
body.payload = body.variables;
|
|
4612
|
+
}
|
|
4613
|
+
delete body.variables;
|
|
4614
|
+
|
|
4615
|
+
if (subcommand === 'preview') {
|
|
4616
|
+
if (code && !body.templateCode && !body.templateId && !body.code) {
|
|
4617
|
+
body.templateCode = code;
|
|
4618
|
+
}
|
|
4619
|
+
return body;
|
|
4620
|
+
}
|
|
4621
|
+
|
|
4622
|
+
if (code && !body.notificationType) {
|
|
4623
|
+
body.notificationType = code;
|
|
4624
|
+
}
|
|
4625
|
+
|
|
4626
|
+
if (subcommand === 'send') {
|
|
4627
|
+
if (!body.recipientId && Array.isArray(body.recipientIds) && body.recipientIds.length === 1) {
|
|
4628
|
+
body.recipientId = body.recipientIds[0];
|
|
4629
|
+
}
|
|
4630
|
+
delete body.recipientIds;
|
|
4631
|
+
return body;
|
|
4632
|
+
}
|
|
4633
|
+
|
|
4634
|
+
if (subcommand === 'batch-send') {
|
|
4635
|
+
if (!body.recipients && Array.isArray(body.recipientIds)) {
|
|
4636
|
+
body.recipients = body.recipientIds.map(recipientId => ({
|
|
4637
|
+
recipientId,
|
|
4638
|
+
payload: body.payload || {},
|
|
4639
|
+
...(body.channels ? { channels: body.channels } : {}),
|
|
4640
|
+
}));
|
|
4641
|
+
}
|
|
4642
|
+
delete body.recipientIds;
|
|
4643
|
+
return body;
|
|
4644
|
+
}
|
|
4645
|
+
|
|
4646
|
+
return body;
|
|
4647
|
+
}
|
|
4648
|
+
|
|
4590
4649
|
function buildPublicGrantChecks(bound, grants, flags = {}) {
|
|
4591
4650
|
const checks = [];
|
|
4592
4651
|
const formTargets = [
|
|
@@ -5299,6 +5358,21 @@ function validateWorkspaceResources(manifest) {
|
|
|
5299
5358
|
};
|
|
5300
5359
|
}
|
|
5301
5360
|
|
|
5361
|
+
async function validateCompiledWorkflowResources(manifest, validation) {
|
|
5362
|
+
for (const item of manifest.workflows || []) {
|
|
5363
|
+
if (!item.workflowFile) continue;
|
|
5364
|
+
try {
|
|
5365
|
+
item.__compiledWorkflow = await compileWorkflowSourceFile(item, {
|
|
5366
|
+
writeFiles: false,
|
|
5367
|
+
});
|
|
5368
|
+
} catch (error) {
|
|
5369
|
+
validation.errors.push(error?.message || String(error));
|
|
5370
|
+
}
|
|
5371
|
+
}
|
|
5372
|
+
validation.valid = validation.errors.length === 0;
|
|
5373
|
+
return validation;
|
|
5374
|
+
}
|
|
5375
|
+
|
|
5302
5376
|
function generateResourceTypes(manifest, outputFile) {
|
|
5303
5377
|
const filePath = path.resolve(outputFile || path.join('src', 'generated', 'openxiangda.gen.ts'));
|
|
5304
5378
|
const menus = (manifest.menus || []).map(item => ({
|
|
@@ -8692,8 +8766,12 @@ function clonePlainJson(value) {
|
|
|
8692
8766
|
|
|
8693
8767
|
function workflowEquals(bound, desired, existing) {
|
|
8694
8768
|
if (!existing) return false;
|
|
8695
|
-
const
|
|
8769
|
+
const compiledWorkflow = desired.__compiledWorkflow;
|
|
8770
|
+
const desiredDefinition =
|
|
8771
|
+
compiledWorkflow?.definitionJson ||
|
|
8772
|
+
resolveManifestPlainJson(desired, 'definitionJson', 'definitionFile');
|
|
8696
8773
|
const desiredView =
|
|
8774
|
+
compiledWorkflow?.previewJson ??
|
|
8697
8775
|
resolveManifestPlainJson(desired, 'viewJson', 'viewFile', true) ??
|
|
8698
8776
|
resolveManifestPlainJson(desired, 'previewJson', 'previewFile', true);
|
|
8699
8777
|
const desiredFormUuid = resolveManifestFormUuid(bound, desired);
|
package/lib/design-gates.js
CHANGED
|
@@ -482,7 +482,27 @@ const RESOURCE_EXPLAINS = {
|
|
|
482
482
|
},
|
|
483
483
|
commands: [
|
|
484
484
|
'openxiangda notification template-upsert --json-file src/resources/notifications/reservation_reminder.json',
|
|
485
|
-
'openxiangda notification preview reservation_reminder --body-json \'{"
|
|
485
|
+
'openxiangda notification preview reservation_reminder --body-json \'{"payload":{"title":"测试"}}\'',
|
|
486
|
+
],
|
|
487
|
+
},
|
|
488
|
+
workflow: {
|
|
489
|
+
dir: 'src/resources/workflows/*.json + src/workflows/<code>/workflow.ts',
|
|
490
|
+
minimalManifest: {
|
|
491
|
+
code: 'expense_approval',
|
|
492
|
+
name: '费用审批',
|
|
493
|
+
formCode: 'expense_request',
|
|
494
|
+
workflowFile: '../../workflows/expense_approval/workflow.ts',
|
|
495
|
+
definitionFile: '../../generated/workflows/expense_approval/definition.v3.json',
|
|
496
|
+
previewFile: '../../generated/workflows/expense_approval/preview.json',
|
|
497
|
+
publish: true,
|
|
498
|
+
enable: true,
|
|
499
|
+
},
|
|
500
|
+
commands: [
|
|
501
|
+
'openxiangda workflow compile src/workflows/expense_approval/workflow.ts --check',
|
|
502
|
+
'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
|
+
'openxiangda resource validate workflow',
|
|
504
|
+
'openxiangda resource plan workflow',
|
|
505
|
+
'openxiangda resource publish',
|
|
486
506
|
],
|
|
487
507
|
},
|
|
488
508
|
'data-view': {
|
|
@@ -513,7 +533,27 @@ const RESOURCE_EXPLAINS = {
|
|
|
513
533
|
};
|
|
514
534
|
|
|
515
535
|
function getResourceExplain(type) {
|
|
516
|
-
const
|
|
536
|
+
const rawKey = String(type || 'route')
|
|
537
|
+
.trim()
|
|
538
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
539
|
+
.replace(/[_\s]+/g, '-')
|
|
540
|
+
.toLowerCase();
|
|
541
|
+
const aliases = {
|
|
542
|
+
routes: 'route',
|
|
543
|
+
notifications: 'notification',
|
|
544
|
+
workflows: 'workflow',
|
|
545
|
+
dataview: 'data-view',
|
|
546
|
+
dataviews: 'data-view',
|
|
547
|
+
'data-views': 'data-view',
|
|
548
|
+
publicaccess: 'public-access',
|
|
549
|
+
publicaccesspolicy: 'public-access',
|
|
550
|
+
publicaccesspolicies: 'public-access',
|
|
551
|
+
auth: 'auth-config',
|
|
552
|
+
authconfigs: 'auth-config',
|
|
553
|
+
functions: 'function',
|
|
554
|
+
connectors: 'connector',
|
|
555
|
+
};
|
|
556
|
+
const key = aliases[rawKey] || rawKey;
|
|
517
557
|
return RESOURCE_EXPLAINS[key];
|
|
518
558
|
}
|
|
519
559
|
|
|
@@ -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 workspaces through `openxiangda resource publish`
|
|
41
|
+
- ✅ Publish classic workspaces through `openxiangda workspace publish --profile <name>`; publish React SPA workspaces 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. Run `openxiangda workflow compile <workflow.ts> --check` before publish; use `sdk.process.resolveCapabilities(...)` or `ProcessActionBar` / `ProcessTimeline` from `openxiangda/runtime/react` for runtime buttons and timelines instead of hard-coded operation lists.
|
|
165
|
+
- Workflow resources should prefer `workflowFile` + `defineWorkflow` semantic DSL over hand-written raw JSON. 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
|
|
@@ -61,6 +61,14 @@ await sdk.notification.sendByType({
|
|
|
61
61
|
});
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
CLI smoke tests:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
openxiangda notification preview reservation_reminder --body-json '{"payload":{"title":"测试"}}'
|
|
68
|
+
openxiangda notification send reservation_reminder --body-json '{"recipientId":"USER_ID","payload":{"title":"测试"}}' --force
|
|
69
|
+
openxiangda notification batch-send reservation_reminder --body-json '{"recipients":[{"recipientId":"USER_ID","payload":{"title":"测试"}}]}' --force
|
|
70
|
+
```
|
|
71
|
+
|
|
64
72
|
Automation or workflow JS_CODE:
|
|
65
73
|
|
|
66
74
|
```ts
|
|
@@ -334,6 +334,21 @@ Requires Bearer token. Sends a notification in the current app scope.
|
|
|
334
334
|
|
|
335
335
|
Requires Bearer token. Sends one notification type to multiple recipients.
|
|
336
336
|
|
|
337
|
+
```json
|
|
338
|
+
{
|
|
339
|
+
"notificationType": "reservation_reminder",
|
|
340
|
+
"recipients": [
|
|
341
|
+
{
|
|
342
|
+
"recipientId": "user-id",
|
|
343
|
+
"payload": {
|
|
344
|
+
"title": "预约提醒"
|
|
345
|
+
},
|
|
346
|
+
"channels": ["inapp"]
|
|
347
|
+
}
|
|
348
|
+
]
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
337
352
|
### GET `/apps/:appType/notifications/templates`
|
|
338
353
|
|
|
339
354
|
Requires Bearer token. Lists app/form notification templates.
|
|
@@ -344,7 +359,7 @@ Requires app admin permission. Upserts an app/form notification template by code
|
|
|
344
359
|
|
|
345
360
|
### POST `/apps/:appType/notifications/templates/preview`
|
|
346
361
|
|
|
347
|
-
Requires Bearer token. Body uses `templateCode` or `templateId` plus `payload`.
|
|
362
|
+
Requires Bearer token. Body uses `templateCode` or `templateId` plus `payload`. The CLI command is `openxiangda notification preview <templateCode> --body-json '{"payload":{...}}'`.
|
|
348
363
|
|
|
349
364
|
### GET `/apps/:appType/notifications/type-configs`
|
|
350
365
|
|
|
@@ -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> # 拉取平台资源回写到本地(用于初次同步)
|
|
@@ -47,7 +48,7 @@ openxiangda connector invoke sms.sendCode --body-json '{"body":{"phone":"1380000
|
|
|
47
48
|
|
|
48
49
|
openxiangda notification template-upsert --json-file src/resources/notifications/register.json
|
|
49
50
|
openxiangda notification type-upsert --json-file src/resources/notifications/register.json
|
|
50
|
-
openxiangda notification preview public_register_notice --body-json '{"
|
|
51
|
+
openxiangda notification preview public_register_notice --body-json '{"payload":{"title":"测试"}}'
|
|
51
52
|
|
|
52
53
|
openxiangda data-view upsert --json-file src/resources/data-views/public_lookup.json
|
|
53
54
|
openxiangda menu update public_register --json-file src/resources/menus/public_register.json --write-manifest
|
|
@@ -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
|
|
|
@@ -39,6 +39,7 @@ For Phase 6 React SPA workspaces (`workspace init --runtime react-spa`), do not
|
|
|
39
39
|
```bash
|
|
40
40
|
openxiangda resource validate --profile <name>
|
|
41
41
|
openxiangda resource plan --profile <name>
|
|
42
|
+
openxiangda resource publish --profile <name> --dry-run
|
|
42
43
|
openxiangda resource publish --profile <name>
|
|
43
44
|
openxiangda runtime deploy --profile <name>
|
|
44
45
|
```
|
|
@@ -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,
|
|
@@ -74,6 +108,23 @@ function normalizeReturnConfig(value) {
|
|
|
74
108
|
...value
|
|
75
109
|
};
|
|
76
110
|
}
|
|
111
|
+
function findInitiatorReturnAction(actions) {
|
|
112
|
+
return actions.find(
|
|
113
|
+
(action) => action?.action === "return" && (action.returnTarget === "initiator" || action.returnScope === "initiator")
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
function inferReturnConfigFromActions(actions, explicitReturnConfig) {
|
|
117
|
+
const initiatorReturnAction = findInitiatorReturnAction(actions);
|
|
118
|
+
if (!initiatorReturnAction) return explicitReturnConfig;
|
|
119
|
+
const base = explicitReturnConfig || normalizeReturnConfig({
|
|
120
|
+
scopeType: "previous_all",
|
|
121
|
+
resubmitMode: initiatorReturnAction.resubmitMode || "replay"
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
...base,
|
|
125
|
+
allowOriginatorReturn: true
|
|
126
|
+
};
|
|
127
|
+
}
|
|
77
128
|
function normalizeFieldBehavior(value) {
|
|
78
129
|
const normalized = String(value || "").trim().toLowerCase();
|
|
79
130
|
if (["normal", "edit", "editable", "write", "writable"].includes(normalized)) return "NORMAL";
|
|
@@ -214,6 +265,7 @@ var WorkflowBuilder = class {
|
|
|
214
265
|
this.action.reject()
|
|
215
266
|
];
|
|
216
267
|
const returnConfig = approvalData.returnConfig !== void 0 ? normalizeReturnConfig(approvalData.returnConfig) : approvalData.returnPolicy !== void 0 ? normalizeReturnConfig(approvalData.returnPolicy) : void 0;
|
|
268
|
+
const inferredReturnConfig = inferReturnConfigFromActions(actions, returnConfig);
|
|
217
269
|
return this.node("approval", id, {
|
|
218
270
|
label: approvalData.label || "\u5BA1\u6279",
|
|
219
271
|
value: approvalData.value || "",
|
|
@@ -223,7 +275,7 @@ var WorkflowBuilder = class {
|
|
|
223
275
|
multiApprove: approvalData.multiApprove || "or",
|
|
224
276
|
...approvalData,
|
|
225
277
|
actions,
|
|
226
|
-
...
|
|
278
|
+
...inferredReturnConfig ? { returnConfig: inferredReturnConfig } : {}
|
|
227
279
|
});
|
|
228
280
|
}
|
|
229
281
|
copy(id, data) {
|
|
@@ -248,7 +300,7 @@ var WorkflowBuilder = class {
|
|
|
248
300
|
functionCall(id, data) {
|
|
249
301
|
return this.node("function_call", id, {
|
|
250
302
|
label: data.label || "\u8C03\u7528\u51FD\u6570",
|
|
251
|
-
functionCode: data.functionCode || data.code,
|
|
303
|
+
functionCode: data.functionCode || data.functionName || data.code,
|
|
252
304
|
input: data.input || data.inputMapping || {},
|
|
253
305
|
saveResponseTo: data.saveResponseTo || data.outputKey,
|
|
254
306
|
timeout: data.timeout || data.timeoutMs || 3e4,
|
|
@@ -435,14 +487,16 @@ var WorkflowBuilder = class {
|
|
|
435
487
|
this.globalSettings = { ...this.globalSettings, ...settings };
|
|
436
488
|
}
|
|
437
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);
|
|
438
498
|
return {
|
|
439
|
-
definitionJson
|
|
440
|
-
version: "v3",
|
|
441
|
-
nodes: this.nodes,
|
|
442
|
-
edges: this.edges,
|
|
443
|
-
flowConfig: this.flowConfig,
|
|
444
|
-
globalSettings: this.globalSettings
|
|
445
|
-
},
|
|
499
|
+
definitionJson,
|
|
446
500
|
previewJson: {
|
|
447
501
|
kind: "workflow_code_preview",
|
|
448
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 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 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 ...(returnConfig ? { returnConfig } : {}),\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,mBAAmB,GAAG;AACnC;AAEA,SAAS,eAAe,OAAe;AACrC,SAAO,EAAE,GAAG,KAAK,GAAG,MAAM,QAAQ,IAAI;AACxC;AAEA,SAAS,gBAAgB,Q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AAc,CAAC,IAAY,OAAoB,CAAC,MAC9C,sBAAsB,iBAAiB,IAAI,IAAI;AAAA,EACjD,eAAe,CAAC,IAAY,OAAoB,CAAC,MAC/C,sBAAsB,kBAAkB,IAAI,IAAI;AAAA,EAClD,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":[]}
|
|
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":";;;;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AAoB,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,
|
|
@@ -48,6 +82,23 @@ function normalizeReturnConfig(value) {
|
|
|
48
82
|
...value
|
|
49
83
|
};
|
|
50
84
|
}
|
|
85
|
+
function findInitiatorReturnAction(actions) {
|
|
86
|
+
return actions.find(
|
|
87
|
+
(action) => action?.action === "return" && (action.returnTarget === "initiator" || action.returnScope === "initiator")
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
function inferReturnConfigFromActions(actions, explicitReturnConfig) {
|
|
91
|
+
const initiatorReturnAction = findInitiatorReturnAction(actions);
|
|
92
|
+
if (!initiatorReturnAction) return explicitReturnConfig;
|
|
93
|
+
const base = explicitReturnConfig || normalizeReturnConfig({
|
|
94
|
+
scopeType: "previous_all",
|
|
95
|
+
resubmitMode: initiatorReturnAction.resubmitMode || "replay"
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
...base,
|
|
99
|
+
allowOriginatorReturn: true
|
|
100
|
+
};
|
|
101
|
+
}
|
|
51
102
|
function normalizeFieldBehavior(value) {
|
|
52
103
|
const normalized = String(value || "").trim().toLowerCase();
|
|
53
104
|
if (["normal", "edit", "editable", "write", "writable"].includes(normalized)) return "NORMAL";
|
|
@@ -188,6 +239,7 @@ var WorkflowBuilder = class {
|
|
|
188
239
|
this.action.reject()
|
|
189
240
|
];
|
|
190
241
|
const returnConfig = approvalData.returnConfig !== void 0 ? normalizeReturnConfig(approvalData.returnConfig) : approvalData.returnPolicy !== void 0 ? normalizeReturnConfig(approvalData.returnPolicy) : void 0;
|
|
242
|
+
const inferredReturnConfig = inferReturnConfigFromActions(actions, returnConfig);
|
|
191
243
|
return this.node("approval", id, {
|
|
192
244
|
label: approvalData.label || "\u5BA1\u6279",
|
|
193
245
|
value: approvalData.value || "",
|
|
@@ -197,7 +249,7 @@ var WorkflowBuilder = class {
|
|
|
197
249
|
multiApprove: approvalData.multiApprove || "or",
|
|
198
250
|
...approvalData,
|
|
199
251
|
actions,
|
|
200
|
-
...
|
|
252
|
+
...inferredReturnConfig ? { returnConfig: inferredReturnConfig } : {}
|
|
201
253
|
});
|
|
202
254
|
}
|
|
203
255
|
copy(id, data) {
|
|
@@ -222,7 +274,7 @@ var WorkflowBuilder = class {
|
|
|
222
274
|
functionCall(id, data) {
|
|
223
275
|
return this.node("function_call", id, {
|
|
224
276
|
label: data.label || "\u8C03\u7528\u51FD\u6570",
|
|
225
|
-
functionCode: data.functionCode || data.code,
|
|
277
|
+
functionCode: data.functionCode || data.functionName || data.code,
|
|
226
278
|
input: data.input || data.inputMapping || {},
|
|
227
279
|
saveResponseTo: data.saveResponseTo || data.outputKey,
|
|
228
280
|
timeout: data.timeout || data.timeoutMs || 3e4,
|
|
@@ -409,14 +461,16 @@ var WorkflowBuilder = class {
|
|
|
409
461
|
this.globalSettings = { ...this.globalSettings, ...settings };
|
|
410
462
|
}
|
|
411
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);
|
|
412
472
|
return {
|
|
413
|
-
definitionJson
|
|
414
|
-
version: "v3",
|
|
415
|
-
nodes: this.nodes,
|
|
416
|
-
edges: this.edges,
|
|
417
|
-
flowConfig: this.flowConfig,
|
|
418
|
-
globalSettings: this.globalSettings
|
|
419
|
-
},
|
|
473
|
+
definitionJson,
|
|
420
474
|
previewJson: {
|
|
421
475
|
kind: "workflow_code_preview",
|
|
422
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 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 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 ...(returnConfig ? { returnConfig } : {}),\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,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,gBAAgB,QAAgB,OAAe,QAAqB,CAAC,GAAG;AAC/E,SAAO;AAAA,IACL;AAAA,IACA,MAAM,EAAE,OAAO,MAAM;AAAA,IACrB,GAAG;AAAA,EACL;AACF;AAEA,IAAM,kBAAkB;AAAA,EACtB,SAAS,CAAC,QAAQ,gBAAM,QAAqB,CAAC,MAC5C,gBAAgB,SAAS,OAAO,KAAK;AAAA,EACvC,QAAQ,CAAC,QAAQ,gBAAM,QAAqB,CAAC,MAC3C,gBAAgB,YAAY,OAAO,KAAK;AAAA,EAC1C,UAAU,CAAC,QAAQ,gBAAM,QAAqB,CAAC,MAC7C,gBAAgB,YAAY,OAAO;AAAA,IACjC,QAAQ,EAAE,OAAO,MAAM,UAAU,MAAM;AAAA,IACvC,GAAG;AAAA,EACL,CAAC;AAAA,EACH,QAAQ,CAAC,QAAQ,gBAAM,QAAqB,CAAC,MAC3C,gBAAgB,UAAU,OAAO;AAAA,IAC/B,QAAQ,EAAE,OAAO,MAAM,UAAU,MAAM;AAAA,IACvC,GAAG;AAAA,EACL,CAAC;AAAA,EACH,mBAAmB,CAAC,QAAQ,kCAAS,QAAqB,CAAC,MACzD,gBAAgB,UAAU,OAAO;AAAA,IAC/B,QAAQ,EAAE,OAAO,MAA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C,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,KAAK,YAAY,GAAG;AACxC,iBAAO,KAAK,sBAAsB,MAAM,wBAAwB;AAAA,QAClE;AACA;AAAA,MACF,KAAK;AACH,YAAI,CAAC,iBAAiB,KAAK,SAAS,GAAG;AACrC,iBAAO,KAAK,sBAAsB,MAAM,qBAAqB;AAAA,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