openxiangda-contracts 2.77.0 → 2.79.1

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.
Files changed (136) hide show
  1. package/dist/ai.d.ts +31 -0
  2. package/dist/ai.d.ts.map +1 -1
  3. package/dist/ai.js +14 -0
  4. package/dist/ai.js.map +1 -1
  5. package/dist/browser.d.ts +11 -0
  6. package/dist/browser.d.ts.map +1 -1
  7. package/dist/browser.js +10 -0
  8. package/dist/browser.js.map +1 -1
  9. package/dist/cli.d.ts +5 -0
  10. package/dist/cli.d.ts.map +1 -1
  11. package/dist/data-field-validation.js +26 -23
  12. package/dist/data-field-validation.js.map +1 -1
  13. package/dist/index.d.ts +13 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +13 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/native-compiler/address-value.d.ts +13 -0
  18. package/dist/native-compiler/address-value.d.ts.map +1 -0
  19. package/dist/native-compiler/address-value.js +70 -0
  20. package/dist/native-compiler/address-value.js.map +1 -0
  21. package/dist/native-compiler/cascade-value.d.ts +6 -0
  22. package/dist/native-compiler/cascade-value.d.ts.map +1 -0
  23. package/dist/native-compiler/cascade-value.js +47 -0
  24. package/dist/native-compiler/cascade-value.js.map +1 -0
  25. package/dist/native-compiler/compiler.d.ts +1 -1
  26. package/dist/native-compiler/compiler.d.ts.map +1 -1
  27. package/dist/native-compiler/compiler.js +99 -54
  28. package/dist/native-compiler/compiler.js.map +1 -1
  29. package/dist/native-compiler/data-field.d.ts +3 -0
  30. package/dist/native-compiler/data-field.d.ts.map +1 -1
  31. package/dist/native-compiler/data-field.js +10 -2
  32. package/dist/native-compiler/data-field.js.map +1 -1
  33. package/dist/native-compiler/index.cjs +6 -6
  34. package/dist/native-compiler/index.d.ts +12 -0
  35. package/dist/native-compiler/index.d.ts.map +1 -1
  36. package/dist/native-compiler/index.js +6 -6
  37. package/dist/native-compiler/resource-query.d.ts +21 -0
  38. package/dist/native-compiler/resource-query.d.ts.map +1 -0
  39. package/dist/native-compiler/resource-query.js +154 -0
  40. package/dist/native-compiler/resource-query.js.map +1 -0
  41. package/dist/native-compiler/service-mutations.d.ts +13 -0
  42. package/dist/native-compiler/service-mutations.d.ts.map +1 -0
  43. package/dist/native-compiler/service-mutations.js +25 -0
  44. package/dist/native-compiler/service-mutations.js.map +1 -0
  45. package/dist/native-compiler/workflow-approval-empty.d.ts +1 -1
  46. package/dist/native-compiler/workflow-approval-empty.d.ts.map +1 -1
  47. package/dist/native-compiler/workflow-approval-empty.js +1 -1
  48. package/dist/native-compiler/workflow-approval-empty.js.map +1 -1
  49. package/dist/native-compiler/workflow-business-command.d.ts +10 -0
  50. package/dist/native-compiler/workflow-business-command.d.ts.map +1 -1
  51. package/dist/native-compiler/workflow-business-command.js +6 -0
  52. package/dist/native-compiler/workflow-business-command.js.map +1 -1
  53. package/dist/native-compiler/workflow-business-step.d.ts +8 -2
  54. package/dist/native-compiler/workflow-business-step.d.ts.map +1 -1
  55. package/dist/native-compiler/workflow-business-step.js +10 -5
  56. package/dist/native-compiler/workflow-business-step.js.map +1 -1
  57. package/dist/native-compiler/workflow-completion-deadline.d.ts +1 -0
  58. package/dist/native-compiler/workflow-completion-deadline.d.ts.map +1 -1
  59. package/dist/native-compiler/workflow-completion-deadline.js +1 -1
  60. package/dist/native-compiler/workflow-completion-deadline.js.map +1 -1
  61. package/dist/native-compiler/workflow-correction.d.ts +1 -0
  62. package/dist/native-compiler/workflow-correction.d.ts.map +1 -1
  63. package/dist/native-compiler/workflow-correction.js +5 -4
  64. package/dist/native-compiler/workflow-correction.js.map +1 -1
  65. package/dist/native-compiler/workflow-designer.d.ts +127 -0
  66. package/dist/native-compiler/workflow-designer.d.ts.map +1 -0
  67. package/dist/native-compiler/workflow-designer.js +397 -0
  68. package/dist/native-compiler/workflow-designer.js.map +1 -0
  69. package/dist/native-compiler/workflow-events.d.ts +8 -0
  70. package/dist/native-compiler/workflow-events.d.ts.map +1 -0
  71. package/dist/native-compiler/workflow-events.js +53 -0
  72. package/dist/native-compiler/workflow-events.js.map +1 -0
  73. package/dist/native-compiler/workflow-graph.d.ts +16 -1
  74. package/dist/native-compiler/workflow-graph.d.ts.map +1 -1
  75. package/dist/native-compiler/workflow-graph.js +27 -5
  76. package/dist/native-compiler/workflow-graph.js.map +1 -1
  77. package/dist/native-compiler/workflow-handle.d.ts +4 -0
  78. package/dist/native-compiler/workflow-handle.d.ts.map +1 -0
  79. package/dist/native-compiler/workflow-handle.js +20 -0
  80. package/dist/native-compiler/workflow-handle.js.map +1 -0
  81. package/dist/native-compiler/workflow-initiator-approval.d.ts +1 -0
  82. package/dist/native-compiler/workflow-initiator-approval.d.ts.map +1 -1
  83. package/dist/native-compiler/workflow-initiator-approval.js +1 -1
  84. package/dist/native-compiler/workflow-initiator-approval.js.map +1 -1
  85. package/dist/native-compiler/workflow-node-administration.d.ts +12 -1
  86. package/dist/native-compiler/workflow-node-administration.d.ts.map +1 -1
  87. package/dist/native-compiler/workflow-node-administration.js +66 -14
  88. package/dist/native-compiler/workflow-node-administration.js.map +1 -1
  89. package/dist/native-compiler/workflow-parallel.d.ts +69 -0
  90. package/dist/native-compiler/workflow-parallel.d.ts.map +1 -0
  91. package/dist/native-compiler/workflow-parallel.js +178 -0
  92. package/dist/native-compiler/workflow-parallel.js.map +1 -0
  93. package/dist/native-compiler/workflow-platform-notify.d.ts +41 -0
  94. package/dist/native-compiler/workflow-platform-notify.d.ts.map +1 -0
  95. package/dist/native-compiler/workflow-platform-notify.js +49 -0
  96. package/dist/native-compiler/workflow-platform-notify.js.map +1 -0
  97. package/dist/native-compiler/workflow-reminders.d.ts +11 -0
  98. package/dist/native-compiler/workflow-reminders.d.ts.map +1 -0
  99. package/dist/native-compiler/workflow-reminders.js +12 -0
  100. package/dist/native-compiler/workflow-reminders.js.map +1 -0
  101. package/dist/native-compiler/workflow-return-policy.d.ts +20 -0
  102. package/dist/native-compiler/workflow-return-policy.d.ts.map +1 -0
  103. package/dist/native-compiler/workflow-return-policy.js +37 -0
  104. package/dist/native-compiler/workflow-return-policy.js.map +1 -0
  105. package/dist/native-compiler/workflow-role-union.d.ts +5 -1
  106. package/dist/native-compiler/workflow-role-union.d.ts.map +1 -1
  107. package/dist/native-compiler/workflow-role-union.js +1 -1
  108. package/dist/native-compiler/workflow-role-union.js.map +1 -1
  109. package/dist/native-compiler/workflow-source-sync.d.ts +109 -0
  110. package/dist/native-compiler/workflow-source-sync.d.ts.map +1 -0
  111. package/dist/native-compiler/workflow-source-sync.js +120 -0
  112. package/dist/native-compiler/workflow-source-sync.js.map +1 -0
  113. package/dist/native-compiler/workflow-supervisor-chain.d.ts +16 -0
  114. package/dist/native-compiler/workflow-supervisor-chain.d.ts.map +1 -0
  115. package/dist/native-compiler/workflow-supervisor-chain.js +44 -0
  116. package/dist/native-compiler/workflow-supervisor-chain.js.map +1 -0
  117. package/dist/native-compiler/workflow-task-page.js +1 -1
  118. package/dist/native-compiler/workflow-task-page.js.map +1 -1
  119. package/dist/native-version.d.ts +7 -0
  120. package/dist/native-version.d.ts.map +1 -1
  121. package/dist/native-version.js +7 -0
  122. package/dist/native-version.js.map +1 -1
  123. package/dist/native.d.ts +12 -0
  124. package/dist/native.d.ts.map +1 -1
  125. package/dist/native.js.map +1 -1
  126. package/dist/references.d.ts +4 -0
  127. package/dist/references.d.ts.map +1 -1
  128. package/dist/schemas.d.ts +1266 -10
  129. package/dist/schemas.d.ts.map +1 -1
  130. package/dist/schemas.js +83 -8
  131. package/dist/schemas.js.map +1 -1
  132. package/dist/types.d.ts +54 -12
  133. package/dist/types.d.ts.map +1 -1
  134. package/dist/types.js +1 -40
  135. package/dist/types.js.map +1 -1
  136. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-completion-deadline.d.ts","sourceRoot":"","sources":["../../src/native-compiler/workflow-completion-deadline.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,+BAA+B;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAC;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;IACpE,eAAe,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE;YAAE,eAAe,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,CAAC;CAC/D,CAAC;AACF,KAAK,UAAU,GAAG;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,CAAC;IAClD,eAAe,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACzC,CAAC;AASF,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,0BAA0B,GAAG,MAAM,CAIzF;AAED,iFAAiF;AACjF,wBAAgB,mCAAmC,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE,CAuBpF"}
1
+ {"version":3,"file":"workflow-completion-deadline.d.ts","sourceRoot":"","sources":["../../src/native-compiler/workflow-completion-deadline.ts"],"names":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,EAAE,UAAU,GAAG,MAAM,EAAE,CAuBpF"}
@@ -31,7 +31,7 @@ export function validateWorkflowCompletionDeadlines(definition) {
31
31
  const page = node.taskPageCode ? definition.taskPages?.[node.taskPageCode] : undefined;
32
32
  if (node.taskPageCode && (!page || requiresInput(page.fields)) ||
33
33
  [node.fieldPolicy?.default, ...Object.values(node.fieldPolicy?.fields || {})].includes('edit_required') ||
34
- node.operationPolicy?.approve?.commentRequired === true || definition.commandHandlers?.approve !== undefined) {
34
+ (node.operationPolicy?.approve?.opinion === 'required' || node.operationPolicy?.approve?.commentRequired === true) || definition.commandHandlers?.approve !== undefined) {
35
35
  errors.push(`WORKFLOW_COMPLETION_DEADLINE_INPUT_REQUIRED:${id}`);
36
36
  }
37
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-completion-deadline.js","sourceRoot":"","sources":["../../src/native-compiler/workflow-completion-deadline.ts"],"names":[],"mappings":"AA4BA,SAAS,aAAa,CAAC,MAAe,EAAE,KAAK,GAAG,CAAC;IAC/C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,EAAE,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3E,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrF,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS;QAC3D,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,IAAI,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1G,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,IAAgC;IAC/E,MAAM,OAAO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OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC;YACvG,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,EAAE,OAAO,KAAK,UAAU,IAAI,IAAI,CAAC,eAAe,EAAE,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC,IAAI,UAAU,CAAC,eAAe,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1K,MAAM,CAAC,IAAI,CAAC,+CAA+C,EAAE,EAAE,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  /** Fixed data correction task; assignment always belongs to the instance initiator. */
2
2
  export interface WorkflowCorrectionNode {
3
+ reminders?: import('./workflow-reminders.js').WorkflowReminders;
3
4
  id: string;
4
5
  kind: 'correction';
5
6
  title: string;
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-correction.d.ts","sourceRoot":"","sources":["../../src/native-compiler/workflow-correction.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,KAAK,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAA;CAAE,CAAC;AAE1J,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE,CAsC5E"}
1
+ {"version":3,"file":"workflow-correction.d.ts","sourceRoot":"","sources":["../../src/native-compiler/workflow-correction.ts"],"names":[],"mappings":"AACA,uFAAuF;AACvF,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,OAAO,yBAAyB,EAAE,iBAAiB,CAAC;IAChE,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,KAAK,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAA;CAAE,CAAC;AAE1J,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE,CAsC5E"}
@@ -1,3 +1,4 @@
1
+ import { workflowReturnTargets } from './workflow-return-policy.js';
1
2
  const object = (value) => !!value && typeof value === 'object' && !Array.isArray(value) && [null, Object.prototype].includes(Object.getPrototypeOf(value));
2
3
  export function validateWorkflowCorrections(definition) {
3
4
  const nodes = definition?.nodes || {};
@@ -7,7 +8,7 @@ export function validateWorkflowCorrections(definition) {
7
8
  const errors = [];
8
9
  const targets = (node) => node?.kind === 'approval' ? [node.onApprove, node.onReject]
9
10
  : node?.kind === 'condition' ? [...(Array.isArray(node.branches) ? node.branches : []).map((branch) => branch.target), node.otherwise]
10
- : node?.kind === 'action' || node?.kind === 'cc' ? [node.next] : [];
11
+ : node?.kind === 'action' || node?.kind === 'cc' || node?.kind === 'handle' ? [node.next] : [];
11
12
  const forward = new Set();
12
13
  const pending = [definition.startAt];
13
14
  while (pending.length) {
@@ -18,7 +19,7 @@ export function validateWorkflowCorrections(definition) {
18
19
  pending.push(...targets(nodes[id]));
19
20
  }
20
21
  for (const node of corrections) {
21
- if (!object(node) || Object.keys(node).some(key => !['id', 'kind', 'title', 'taskPageCode', 'next'].includes(key)) ||
22
+ if (!object(node) || Object.keys(node).some(key => !['id', 'kind', 'title', 'taskPageCode', 'next', 'reminders'].includes(key)) ||
22
23
  typeof node.id !== 'string' || !/^[A-Za-z][A-Za-z0-9_-]{0,127}$/.test(node.id) ||
23
24
  ['__proto__', 'prototype', 'constructor'].includes(node.id) || nodes[node.id] !== node ||
24
25
  typeof node.title !== 'string' || !node.title.trim() || node.title.length > 255 ||
@@ -28,8 +29,8 @@ export function validateWorkflowCorrections(definition) {
28
29
  errors.push('WORKFLOW_CORRECTION_REPLAY_TARGET_INVALID');
29
30
  if (forward.has(node.id) || Object.values(nodes).some(current => targets(current).includes(node.id)))
30
31
  errors.push('WORKFLOW_CORRECTION_FORWARD_ENTRY_FORBIDDEN');
31
- if (!Object.values(nodes).some(current => current?.kind === 'approval' && forward.has(current.id) &&
32
- Array.isArray(current.returnTargets) && current.returnTargets.includes(node.id)))
32
+ if (!Object.values(nodes).some(current => (current?.kind === 'approval' || current?.kind === 'handle') && forward.has(current.id) &&
33
+ workflowReturnTargets(current).includes(node.id)))
33
34
  errors.push('WORKFLOW_CORRECTION_RETURN_SOURCE_REQUIRED');
34
35
  const page = definition.taskPages?.[node.taskPageCode];
35
36
  if (!page || !Array.isArray(page.fields))
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-correction.js","sourceRoot":"","sources":["../../src/native-compiler/workflow-correction.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,GAAG,CAAC,KAAc,EAAgC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAA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AAY,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;QAC3F,wEAAwE;QACxE,4EAA4E;aACvE,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,EAAE,QAAQ;YACvD,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,cAAc,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAClE,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;YAC5D,MAAM,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,127 @@
1
+ import type { WorkflowBinding, WorkflowDefinition, WorkflowExpression, WorkflowNode } from '../types.js';
2
+ export type WorkflowPublicationScope = 'running_and_new' | 'new_only';
3
+ export type WorkflowAdoptionOutcome = 'eligible' | 'migrated' | 'deferred' | 'excepted' | 'held' | 'failed' | 'superseded' | 'completed';
4
+ export interface WorkflowDesignerDraft {
5
+ workflowCode: string;
6
+ environmentKey: string;
7
+ revision: number;
8
+ baseHeadRevision: number;
9
+ definitionVersion: number;
10
+ bindingVersion: number;
11
+ definition: WorkflowDefinition;
12
+ binding: WorkflowBinding;
13
+ publishedDefinition: WorkflowDefinition;
14
+ publishedBinding: WorkflowBinding;
15
+ updatedAt?: string;
16
+ updatedBy?: string;
17
+ }
18
+ export interface WorkflowDesignerSave {
19
+ expectedRevision: number;
20
+ expectedHeadRevision: number;
21
+ operationId: string;
22
+ definition: WorkflowDefinition;
23
+ binding: WorkflowBinding;
24
+ }
25
+ export interface WorkflowPublicationHold {
26
+ instanceIds?: string[];
27
+ nodeIds?: string[];
28
+ reason: string;
29
+ }
30
+ export interface WorkflowDesignerPublish {
31
+ expectedRevision: number;
32
+ expectedHeadRevision: number;
33
+ operationId: string;
34
+ reason: string;
35
+ scope?: WorkflowPublicationScope;
36
+ holds?: WorkflowPublicationHold[];
37
+ acknowledgeExceptions?: boolean;
38
+ }
39
+ export interface WorkflowPublicationPreview {
40
+ revision: number;
41
+ total: number;
42
+ counts: Partial<Record<WorkflowAdoptionOutcome, number>>;
43
+ items: Array<{
44
+ instanceId: string;
45
+ businessKey: string;
46
+ nodeTitle: string;
47
+ fromVersion: number;
48
+ outcome: WorkflowAdoptionOutcome;
49
+ reason?: string;
50
+ }>;
51
+ truncated: boolean;
52
+ }
53
+ export interface WorkflowPublicationReceipt {
54
+ publicationId: string;
55
+ workflowCode: string;
56
+ definitionVersion: number;
57
+ bindingVersion: number;
58
+ headRevision: number;
59
+ scope: WorkflowPublicationScope;
60
+ status: 'running' | 'completed' | 'paused' | 'superseded';
61
+ counts: Partial<Record<WorkflowAdoptionOutcome, number>>;
62
+ replayed?: boolean;
63
+ }
64
+ export declare function workflowDesignerTargets(node: Record<string, any>): string[];
65
+ /** The canvas can route released capabilities; it cannot invent a business validator, page or handler. */
66
+ export declare function validateWorkflowDesignerCapabilities(base: WorkflowDefinition, next: WorkflowDefinition, baseBinding: WorkflowBinding, nextBinding: WorkflowBinding): string[];
67
+ export type WorkflowDesignerEdit = {
68
+ type: 'insert_parallel';
69
+ from: string;
70
+ target: string;
71
+ id: string;
72
+ joinId: string;
73
+ title: string;
74
+ branches: Array<{
75
+ id: string;
76
+ title: string;
77
+ when?: WorkflowExpression;
78
+ }>;
79
+ edge?: 'approve' | 'reject' | 'next' | 'default' | number;
80
+ } | {
81
+ type: 'remove_parallel_branch';
82
+ nodeId: string;
83
+ branchId: string;
84
+ } | {
85
+ type: 'insert';
86
+ from: string;
87
+ target: string;
88
+ node: WorkflowNode;
89
+ edge?: 'approve' | 'reject' | 'next' | 'default' | number;
90
+ } | {
91
+ type: 'remove';
92
+ nodeId: string;
93
+ reconnectTo?: string;
94
+ } | {
95
+ type: 'node';
96
+ nodeId: string;
97
+ patch: Record<string, unknown>;
98
+ } | {
99
+ type: 'branch';
100
+ nodeId: string;
101
+ index: number;
102
+ when: WorkflowExpression;
103
+ label?: string;
104
+ target: string;
105
+ };
106
+ /** Semantic edits are independent of canvas coordinates and preserve stable existing ids. */
107
+ export declare function editWorkflowDesignerDefinition(source: WorkflowDefinition, edit: WorkflowDesignerEdit): WorkflowDefinition;
108
+ export interface WorkflowAdoptionState {
109
+ currentNodeId?: string;
110
+ activeNodeIds?: string[];
111
+ forkNodeId?: string;
112
+ unarrivedBranchIds?: string[];
113
+ facts: Record<string, unknown>;
114
+ returnTargetNodeIds?: string[];
115
+ businessStepPending?: boolean;
116
+ held?: boolean;
117
+ }
118
+ /** Classification is pure; the caller locks and re-reads before applying a result. */
119
+ export declare function classifyWorkflowAdoption(source: WorkflowDefinition, target: WorkflowDefinition, state: WorkflowAdoptionState): {
120
+ outcome: WorkflowAdoptionOutcome;
121
+ reason?: string;
122
+ };
123
+ /** Typed expression validation shared by canvas, AI proposals and publication. */
124
+ export declare function validateWorkflowDesignerDocument(definition: WorkflowDefinition): string[];
125
+ /** Enumerate all typed fact leaves, including fields not used in an existing branch. */
126
+ export declare function workflowDesignerVariables(definition: WorkflowDefinition): import("./workflow-graph.js").WorkflowGraphVariable[];
127
+ //# sourceMappingURL=workflow-designer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-designer.d.ts","sourceRoot":"","sources":["../../src/native-compiler/workflow-designer.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIzG,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,GAAG,UAAU,CAAC;AACtE,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,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAID,sFAAsF;AACtF,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,qBAAqB,GAAG;IAAE,OAAO,EAAE,uBAAuB,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAsCpL;AAED,kFAAkF;AAClF,wBAAgB,gCAAgC,CAAC,UAAU,EAAE,kBAAkB,GAAG,MAAM,EAAE,CA4DzF;AAED,wFAAwF;AACxF,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,kBAAkB,yDAUvE"}
@@ -0,0 +1,397 @@
1
+ import { inspectWorkflowParallel, validateWorkflowParallel } from './workflow-parallel.js';
2
+ import { validateWorkflowSupervisorChains } from './workflow-supervisor-chain.js';
3
+ import { validateWorkflowReminders } from './workflow-reminders.js';
4
+ import { isWorkflowPlatformNotify, validateWorkflowPlatformNotify } from './workflow-platform-notify.js';
5
+ import { validateWorkflowReturnPolicies } from './workflow-return-policy.js';
6
+ import { validateWorkflowHandlingNodes } from './workflow-handle.js';
7
+ import { workflowOperationMinimumOpinion, workflowOperationOpinion } from './workflow-node-administration.js';
8
+ import { projectWorkflowGraph, workflowExpressionPaths } from './workflow-graph.js';
9
+ const record = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
10
+ const canonical = (value) => Array.isArray(value) ? value.map(canonical) : record(value) ? Object.fromEntries(Object.keys(value).sort().map(key => [key, canonical(value[key])])) : value;
11
+ const same = (a, b) => JSON.stringify(canonical(a)) === JSON.stringify(canonical(b));
12
+ export function workflowDesignerTargets(node) {
13
+ if (node.kind === 'approval')
14
+ return [node.onApprove, node.onReject];
15
+ if (node.kind === 'parallel')
16
+ return [...(node.branches || []).map((branch) => branch.target), node.join];
17
+ if (node.kind === 'condition')
18
+ return [...(node.branches || []).map((branch) => branch.target), node.otherwise];
19
+ return 'next' in node ? [node.next] : [];
20
+ }
21
+ /** The canvas can route released capabilities; it cannot invent a business validator, page or handler. */
22
+ export function validateWorkflowDesignerCapabilities(base, next, baseBinding, nextBinding) {
23
+ const errors = [...validateWorkflowReminders(next), ...validateWorkflowSupervisorChains(next, nextBinding)];
24
+ if (!record(next) || !record(next.nodes) || !record(nextBinding?.bindings))
25
+ return ['WORKFLOW_DESIGNER_DOCUMENT_INVALID'];
26
+ const editable = new Set(['title', 'startAt', 'nodes', 'readability']);
27
+ for (const key of new Set([...Object.keys(base), ...Object.keys(next)]))
28
+ if (!editable.has(key) && !same(base[key], next[key]))
29
+ errors.push(`WORKFLOW_DESIGNER_CODE_OWNED:${key}`);
30
+ if (baseBinding.workflowCode !== nextBinding.workflowCode || baseBinding.schemaVersion !== nextBinding.schemaVersion)
31
+ errors.push('WORKFLOW_DESIGNER_BINDING_IDENTITY');
32
+ const steps = Object.values(base.nodes).filter(node => node.kind === 'action');
33
+ for (const [id, node] of Object.entries(next.nodes)) {
34
+ if (!record(node) || node.id !== id || !['approval', 'handle', 'condition', 'cc', 'action', 'correction', 'end', 'parallel', 'join'].includes(node.kind)) {
35
+ errors.push(`WORKFLOW_DESIGNER_NODE_INVALID:${id}`);
36
+ continue;
37
+ }
38
+ if ('taskPageCode' in node && node.taskPageCode && !base.taskPages?.[node.taskPageCode])
39
+ errors.push(`WORKFLOW_DESIGNER_PAGE_UNRELEASED:${id}`);
40
+ if (node.kind === 'action' && !isWorkflowPlatformNotify(node) && !steps.some(step => step.kind === 'action' && same(step.handler, node.handler) && same(step.inputs, node.inputs) && same(step.outputSchema, node.outputSchema)))
41
+ errors.push(`WORKFLOW_DESIGNER_STEP_UNRELEASED:${id}`);
42
+ if (['approval', 'handle'].includes(node.kind) && 'allowedOperations' in node && node.allowedOperations && (!Array.isArray(node.allowedOperations) || !node.allowedOperations.includes(node.kind === 'handle' ? 'complete' : 'approve')))
43
+ errors.push(`WORKFLOW_DESIGNER_REQUIRED_ACTION:${id}.approve`);
44
+ const original = base.nodes[id] || (node.kind === 'approval' || node.kind === 'handle' ? Object.values(base.nodes).find(template => {
45
+ if (template.kind !== node.kind || !['approval', 'handle'].includes(template.kind) || !['fieldPolicy', 'administration', 'requiredOperations', 'taskPageCode'].every(key => same(template[key], node[key])))
46
+ return false;
47
+ const human = template;
48
+ if (node.mode !== human.mode && !human.administration?.modes?.includes(node.mode))
49
+ return false;
50
+ const ranks = ['none', 'optional', 'required'];
51
+ return Object.entries(human.operationPolicy || {}).every(([operation, policy]) => {
52
+ const nextPolicy = node.operationPolicy?.[operation];
53
+ return same(policy?.minimumOpinion, nextPolicy?.minimumOpinion) && ranks.indexOf(workflowOperationOpinion(operation, nextPolicy)) >= ranks.indexOf(workflowOperationMinimumOpinion(operation, policy));
54
+ });
55
+ }) : undefined);
56
+ if (!original && (node.kind === 'approval' || node.kind === 'handle'))
57
+ errors.push(`WORKFLOW_DESIGNER_APPROVAL_TEMPLATE_REQUIRED:${id}`);
58
+ if ((original?.kind === 'approval' || original?.kind === 'handle') && (node.kind === 'approval' || node.kind === 'handle')) {
59
+ if (node.mode !== original.mode && !original.administration?.modes?.includes(node.mode))
60
+ errors.push(`WORKFLOW_DESIGNER_MODE_NOT_ALLOWED:${id}`);
61
+ for (const key of ['requiredOperations', 'fieldPolicy', 'administration'])
62
+ if (!same(original[key], node[key]))
63
+ errors.push(`WORKFLOW_DESIGNER_CODE_OWNED:${id}.${key}`);
64
+ for (const operation of original.requiredOperations || [])
65
+ if (node.allowedOperations && !node.allowedOperations.includes(operation))
66
+ errors.push(`WORKFLOW_DESIGNER_REQUIRED_ACTION:${id}.${operation}`);
67
+ for (const [operation, policy] of Object.entries(original.operationPolicy || {})) {
68
+ const nextPolicy = node.operationPolicy?.[operation];
69
+ const ranks = ['none', 'optional', 'required'];
70
+ if (!same(policy?.minimumOpinion, nextPolicy?.minimumOpinion) || ranks.indexOf(workflowOperationOpinion(operation, nextPolicy)) < ranks.indexOf(workflowOperationMinimumOpinion(operation, policy)))
71
+ errors.push(`WORKFLOW_DESIGNER_CODE_OWNED:${id}.${operation}.minimumOpinion`);
72
+ }
73
+ }
74
+ if ('binding' in node && !nextBinding.bindings[node.binding])
75
+ errors.push(`WORKFLOW_DESIGNER_BINDING_MISSING:${id}`);
76
+ }
77
+ if (!same(base.readability?.logic, next.readability?.logic))
78
+ errors.push('WORKFLOW_DESIGNER_CODE_OWNED:readability.logic');
79
+ for (const [key, entry] of Object.entries(nextBinding.bindings)) {
80
+ const original = baseBinding.bindings[key];
81
+ if (!original && !Object.values(baseBinding.bindings).some(value => same(value, entry)))
82
+ errors.push(`WORKFLOW_DESIGNER_BINDING_UNRELEASED:${key}`);
83
+ if (original && !same(original, entry))
84
+ errors.push(`WORKFLOW_DESIGNER_BINDING_CODE_OWNED:${key}`);
85
+ }
86
+ errors.push(...validateWorkflowDesignerDocument(next));
87
+ return [...new Set(errors)];
88
+ }
89
+ /** Semantic edits are independent of canvas coordinates and preserve stable existing ids. */
90
+ export function editWorkflowDesignerDefinition(source, edit) {
91
+ if (edit.type === 'insert_parallel') {
92
+ if (source.nodes[edit.joinId] || edit.joinId === edit.id || edit.branches.length < 2 || edit.branches.length > 8)
93
+ throw new Error('WORKFLOW_DESIGNER_PARALLEL_INSERT_INVALID');
94
+ const next = editWorkflowDesignerDefinition(source, { type: 'insert', from: edit.from, target: edit.target, node: { id: edit.id, kind: 'parallel', title: edit.title, join: edit.joinId, branches: edit.branches.map(branch => ({ ...branch, target: edit.joinId })) }, ...(edit.edge === undefined ? {} : { edge: edit.edge }) });
95
+ next.nodes[edit.joinId] = { id: edit.joinId, kind: 'join', title: '全部完成后继续', parallel: edit.id, next: edit.target };
96
+ return next;
97
+ }
98
+ const definition = structuredClone(source);
99
+ const rewrite = (from, target, replacement) => {
100
+ if (from.kind === 'approval') {
101
+ if (from.onApprove === target)
102
+ from.onApprove = replacement;
103
+ if (from.onReject === target)
104
+ from.onReject = replacement;
105
+ }
106
+ else if (from.kind === 'condition') {
107
+ for (const branch of from.branches)
108
+ if (branch.target === target)
109
+ branch.target = replacement;
110
+ if (from.otherwise === target)
111
+ from.otherwise = replacement;
112
+ }
113
+ else if (from.kind === 'parallel') {
114
+ for (const branch of from.branches)
115
+ if (branch.target === target)
116
+ branch.target = replacement;
117
+ }
118
+ else if ('next' in from && from.next === target)
119
+ from.next = replacement;
120
+ };
121
+ if (edit.type === 'insert') {
122
+ const from = definition.nodes[edit.from];
123
+ if (!from || definition.nodes[edit.node.id] || !workflowDesignerTargets(from).includes(edit.target) || !definition.nodes[edit.target])
124
+ throw new Error('WORKFLOW_DESIGNER_INSERT_INVALID');
125
+ definition.nodes[edit.node.id] = structuredClone(edit.node);
126
+ if (from.kind === 'approval') {
127
+ const key = edit.edge === 'reject' ? 'onReject' : 'onApprove';
128
+ if (from[key] !== edit.target)
129
+ throw new Error('WORKFLOW_DESIGNER_INSERT_EDGE_INVALID');
130
+ from[key] = edit.node.id;
131
+ }
132
+ else if (from.kind === 'parallel') {
133
+ if (typeof edit.edge !== 'number' || from.branches[edit.edge]?.target !== edit.target)
134
+ throw new Error('WORKFLOW_DESIGNER_INSERT_EDGE_INVALID');
135
+ from.branches[edit.edge].target = edit.node.id;
136
+ }
137
+ else if (from.kind === 'condition') {
138
+ if (typeof edit.edge === 'number' && from.branches[edit.edge]?.target === edit.target)
139
+ from.branches[edit.edge].target = edit.node.id;
140
+ else if (edit.edge === 'default' && from.otherwise === edit.target)
141
+ from.otherwise = edit.node.id;
142
+ else
143
+ throw new Error('WORKFLOW_DESIGNER_INSERT_EDGE_INVALID');
144
+ }
145
+ else if ('next' in from)
146
+ from.next = edit.node.id;
147
+ else
148
+ throw new Error('WORKFLOW_DESIGNER_INSERT_EDGE_INVALID');
149
+ }
150
+ else if (edit.type === 'remove_parallel_branch') {
151
+ const fork = definition.nodes[edit.nodeId];
152
+ if (fork?.kind !== 'parallel' || fork.branches.length <= 2)
153
+ throw new Error('WORKFLOW_PARALLEL_BRANCH_LIMIT');
154
+ const region = inspectWorkflowParallel(definition).regions.find(region => region.parallelNodeId === fork.id);
155
+ const branch = region?.branches.find(branch => branch.id === edit.branchId);
156
+ if (!branch)
157
+ throw new Error('WORKFLOW_DESIGNER_PARALLEL_BRANCH_MISSING');
158
+ fork.branches = fork.branches.filter(branch => branch.id !== edit.branchId);
159
+ for (const id of branch.nodeIds)
160
+ delete definition.nodes[id];
161
+ }
162
+ else if (edit.type === 'remove') {
163
+ const node = definition.nodes[edit.nodeId];
164
+ if (node?.kind === 'parallel') {
165
+ const join = definition.nodes[node.join];
166
+ const region = inspectWorkflowParallel(definition).regions.find(region => region.parallelNodeId === node.id);
167
+ if (join?.kind !== 'join' || !region)
168
+ throw new Error('WORKFLOW_DESIGNER_PARALLEL_PAIR_INVALID');
169
+ const removed = new Set([node.id, join.id, ...region.branches.flatMap(branch => branch.nodeIds)]);
170
+ for (const other of Object.values(definition.nodes))
171
+ if (!removed.has(other.id))
172
+ for (const id of removed)
173
+ rewrite(other, id, join.next);
174
+ for (const id of removed)
175
+ delete definition.nodes[id];
176
+ if (definition.startAt === node.id)
177
+ definition.startAt = join.next;
178
+ return definition;
179
+ }
180
+ const target = edit.reconnectTo || (node?.kind === 'approval' ? node.onApprove : node && 'next' in node ? node.next : undefined);
181
+ if (!node || !target || target === node.id || !definition.nodes[target] || node.kind === 'end' || node.kind === 'correction' || node.kind === 'join')
182
+ throw new Error('WORKFLOW_DESIGNER_REMOVE_INVALID');
183
+ for (const other of Object.values(definition.nodes)) {
184
+ rewrite(other, node.id, target);
185
+ if ((other.kind === 'approval' || other.kind === 'handle') && other.returnTargets)
186
+ other.returnTargets = other.returnTargets.filter(id => id !== node.id);
187
+ if ((other.kind === 'approval' || other.kind === 'handle') && other.returnPolicy)
188
+ other.returnPolicy.targets = other.returnPolicy.targets.filter(target => target.nodeId !== node.id);
189
+ }
190
+ if (definition.startAt === node.id)
191
+ definition.startAt = target;
192
+ delete definition.nodes[node.id];
193
+ }
194
+ else {
195
+ const node = definition.nodes[edit.nodeId];
196
+ if (!node)
197
+ throw new Error('WORKFLOW_DESIGNER_NODE_MISSING');
198
+ if (edit.type === 'node') {
199
+ if ('id' in edit.patch || 'kind' in edit.patch)
200
+ throw new Error('WORKFLOW_DESIGNER_NODE_ID_IMMUTABLE');
201
+ Object.assign(node, edit.patch);
202
+ }
203
+ else {
204
+ if (node.kind !== 'condition' || edit.index < 0 || edit.index > node.branches.length)
205
+ throw new Error('WORKFLOW_DESIGNER_BRANCH_INVALID');
206
+ node.branches[edit.index] = { when: structuredClone(edit.when), target: edit.target, ...(edit.label ? { label: edit.label } : {}) };
207
+ }
208
+ }
209
+ return definition;
210
+ }
211
+ const pathValue = (value, path) => path.split('.').reduce((current, part) => record(current) && Object.hasOwn(current, part) ? current[part] : undefined, value);
212
+ const matchesType = (value, type) => type.includes(',') ? type.split(',').some(part => matchesType(value, part)) : type === 'unknown' ? true : type === 'null' ? value === null : type === 'number' || type === 'integer' ? typeof value === 'number' && Number.isFinite(value) && (type !== 'integer' || Number.isInteger(value)) : type === 'array' ? Array.isArray(value) : type === 'object' ? record(value) : typeof value === type;
213
+ /** Classification is pure; the caller locks and re-reads before applying a result. */
214
+ export function classifyWorkflowAdoption(source, target, state) {
215
+ if (state.held)
216
+ return { outcome: 'held', reason: '已指定保留在原版本' };
217
+ const active = state.activeNodeIds?.length ? state.activeNodeIds : state.currentNodeId ? [state.currentNodeId] : [];
218
+ if (!active.length)
219
+ return { outcome: 'excepted', reason: '当前运行位置无法确定' };
220
+ if (active.some(id => !target.nodes[id]))
221
+ return { outcome: 'excepted', reason: '当前节点已被删除' };
222
+ if (active.some(id => source.nodes[id]?.kind !== target.nodes[id]?.kind))
223
+ return { outcome: 'excepted', reason: '当前节点类型已改变' };
224
+ if ((state.returnTargetNodeIds || []).some(id => !target.nodes[id]))
225
+ return { outcome: 'excepted', reason: '正在退回的目标节点已被删除' };
226
+ if (!same(source.subject, target.subject) || !same(source.inputSchema, target.inputSchema))
227
+ return { outcome: 'excepted', reason: '申请数据或变量定义已改变,需要明确的数据转换' };
228
+ if (state.forkNodeId) {
229
+ const from = source.nodes[state.forkNodeId], to = target.nodes[state.forkNodeId];
230
+ if (from?.kind !== 'parallel' || to?.kind !== 'parallel' || from.join !== to.join)
231
+ return { outcome: 'excepted', reason: '正在运行的并行分支或汇合点已改变' };
232
+ const sourceRegion = inspectWorkflowParallel(source).regions.find(region => region.parallelNodeId === from.id);
233
+ const targetRegion = inspectWorkflowParallel(target).regions.find(region => region.parallelNodeId === to.id);
234
+ for (const id of state.unarrivedBranchIds || []) {
235
+ const branch = targetRegion?.branches.find(branch => branch.id === id);
236
+ if (!branch || active.some(node => sourceRegion?.branches.find(branch => branch.id === id)?.nodeIds.includes(node) && !branch.nodeIds.includes(node)))
237
+ return { outcome: 'excepted', reason: '尚未完成的并行分支或其当前节点已改变' };
238
+ }
239
+ }
240
+ if (state.businessStepPending)
241
+ return { outcome: 'deferred', reason: '业务步骤执行中,完成后自动更新' };
242
+ const reachable = new Set(), pending = [...active];
243
+ while (pending.length) {
244
+ const id = pending.pop();
245
+ if (reachable.has(id))
246
+ continue;
247
+ reachable.add(id);
248
+ pending.push(...workflowDesignerTargets(target.nodes[id] || {}).filter(id => !!target.nodes[id]));
249
+ }
250
+ const graph = projectWorkflowGraph(target, 'preview');
251
+ for (const node of Object.values(target.nodes)) {
252
+ if (!reachable.has(node.id))
253
+ continue;
254
+ const expressions = node.kind === 'condition' ? node.branches.map(branch => branch.when) : node.kind === 'action' ? Object.values(node.inputs).filter(input => input.source === 'fact').map(input => ({ op: 'path', path: input.path })) : [];
255
+ for (const expression of expressions)
256
+ for (const path of workflowExpressionPaths(expression).paths) {
257
+ const variable = graph.variables.find(variable => variable.path === path);
258
+ const value = pathValue(state.facts, path);
259
+ if (value === undefined && variable?.source.kind === 'step_output' && reachable.has(variable.source.nodeId) && !active.includes(variable.source.nodeId)) {
260
+ const withoutProducer = new Set(), queue = [...active];
261
+ while (queue.length) {
262
+ const id = queue.pop();
263
+ if (id === variable.source.nodeId || withoutProducer.has(id))
264
+ continue;
265
+ withoutProducer.add(id);
266
+ queue.push(...workflowDesignerTargets(target.nodes[id] || {}).filter(id => !!target.nodes[id]));
267
+ }
268
+ if (!withoutProducer.has(node.id))
269
+ continue;
270
+ }
271
+ if (value === undefined && variable && !variable.required && (variable.source.kind !== 'step_output' || record(pathValue(state.facts, `steps.${variable.source.nodeId}`))))
272
+ continue;
273
+ if (value === undefined || variable && !matchesType(value, variable.type))
274
+ return { outcome: 'excepted', reason: `后续条件需要的数据在该申请中不存在或类型不兼容:${variable?.label || path}` };
275
+ }
276
+ }
277
+ return { outcome: 'eligible' };
278
+ }
279
+ /** Typed expression validation shared by canvas, AI proposals and publication. */
280
+ export function validateWorkflowDesignerDocument(definition) {
281
+ if (!record(definition?.nodes))
282
+ return ['WORKFLOW_DESIGNER_DOCUMENT_INVALID'];
283
+ const errors = [];
284
+ errors.push(...validateWorkflowParallel(definition), ...validateWorkflowHandlingNodes(definition), ...validateWorkflowReturnPolicies(definition), ...validateWorkflowPlatformNotify(definition));
285
+ const nodes = Object.values(definition.nodes);
286
+ if (nodes.length > 200 || !nodes.length)
287
+ return ['WORKFLOW_DESIGNER_NODE_LIMIT'];
288
+ for (const node of nodes) {
289
+ if (!record(node) || !['approval', 'handle', 'condition', 'cc', 'action', 'correction', 'end', 'parallel', 'join'].includes(node.kind))
290
+ errors.push('WORKFLOW_DESIGNER_NODE_INVALID');
291
+ else if (node.kind === 'condition' && (!Array.isArray(node.branches) || !node.branches.length || node.branches.length > 32 || node.branches.some(branch => !record(branch) || !record(branch.when) || typeof branch.target !== 'string')))
292
+ errors.push(`WORKFLOW_DESIGNER_BRANCH_INVALID:${node.id}`);
293
+ }
294
+ if (errors.length)
295
+ return [...new Set(errors)];
296
+ const variables = projectWorkflowGraph(definition, 'draft').variables;
297
+ let expressionCount = 0;
298
+ const expressionType = (expression, nodeId, depth = 0) => {
299
+ if (!record(expression) || depth > 16 || ++expressionCount > 4096) {
300
+ errors.push(`WORKFLOW_DESIGNER_EXPRESSION_LIMIT:${nodeId}`);
301
+ return 'invalid';
302
+ }
303
+ if (expression.op === 'literal') {
304
+ const value = expression.value;
305
+ return value === null ? 'null' : Array.isArray(value) ? 'array' : typeof value === 'object' ? 'object' : typeof value;
306
+ }
307
+ if (expression.op === 'path') {
308
+ const variable = variables.find(item => item.path === expression.path);
309
+ if (!variable || variable.type === 'unknown')
310
+ errors.push(`WORKFLOW_DESIGNER_VARIABLE_UNKNOWN:${nodeId}:${expression.path}`);
311
+ const type = variable?.type.split(',').find(type => type !== 'null') || variable?.type || 'unknown';
312
+ return type === 'integer' ? 'number' : type;
313
+ }
314
+ if (expression.op === 'and' || expression.op === 'or') {
315
+ if (!Array.isArray(expression.values) || expression.values.length < 1 || expression.values.length > 32) {
316
+ errors.push(`WORKFLOW_DESIGNER_CONDITION_GROUP:${nodeId}`);
317
+ return 'invalid';
318
+ }
319
+ for (const value of expression.values)
320
+ if (expressionType(value, nodeId, depth + 1) !== 'boolean')
321
+ errors.push(`WORKFLOW_DESIGNER_CONDITION_BOOLEAN:${nodeId}`);
322
+ }
323
+ else if (expression.op === 'not' || expression.op === 'exists') {
324
+ const type = expressionType(expression.value, nodeId, depth + 1);
325
+ if (expression.op === 'not' && type !== 'boolean')
326
+ errors.push(`WORKFLOW_DESIGNER_CONDITION_BOOLEAN:${nodeId}`);
327
+ }
328
+ else if (['eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'in', 'contains'].includes(expression.op) && 'left' in expression) {
329
+ const left = expressionType(expression.left, nodeId, depth + 1), right = expressionType(expression.right, nodeId, depth + 1);
330
+ const compatible = expression.op === 'in' ? right === 'array' : expression.op === 'contains' ? left === 'array' || left === 'string' && right === 'string' : ['gt', 'gte', 'lt', 'lte'].includes(expression.op) ? left === right && ['number', 'string'].includes(left) : left === right || left === 'null' || right === 'null';
331
+ if (!compatible)
332
+ errors.push(`WORKFLOW_DESIGNER_CONDITION_TYPE:${nodeId}`);
333
+ }
334
+ else
335
+ errors.push(`WORKFLOW_DESIGNER_CONDITION_OPERATOR:${nodeId}`);
336
+ return 'boolean';
337
+ };
338
+ const completed = new Set(), active = new Set();
339
+ const walk = (id) => {
340
+ if (active.has(id)) {
341
+ errors.push(`WORKFLOW_DESIGNER_CYCLE:${id}`);
342
+ return;
343
+ }
344
+ if (completed.has(id))
345
+ return;
346
+ const node = definition.nodes[id];
347
+ if (!node) {
348
+ errors.push(`WORKFLOW_DESIGNER_TARGET_MISSING:${id}`);
349
+ return;
350
+ }
351
+ active.add(id);
352
+ for (const target of workflowDesignerTargets(node))
353
+ walk(target);
354
+ active.delete(id);
355
+ completed.add(id);
356
+ };
357
+ for (const node of nodes) {
358
+ if (!/^[a-z][a-z0-9_-]{0,127}$/.test(node.id) || definition.nodes[node.id] !== node)
359
+ errors.push(`WORKFLOW_DESIGNER_NODE_ID:${node.id}`);
360
+ if (node.kind === 'parallel')
361
+ for (const branch of node.branches)
362
+ if (branch.when && expressionType(branch.when, node.id) !== 'boolean')
363
+ errors.push(`WORKFLOW_DESIGNER_CONDITION_BOOLEAN:${node.id}`);
364
+ if (node.kind === 'condition') {
365
+ if (!node.branches.length || node.branches.length > 32)
366
+ errors.push(`WORKFLOW_DESIGNER_BRANCH_LIMIT:${node.id}`);
367
+ for (const branch of node.branches)
368
+ if (expressionType(branch.when, node.id) !== 'boolean')
369
+ errors.push(`WORKFLOW_DESIGNER_CONDITION_BOOLEAN:${node.id}`);
370
+ }
371
+ }
372
+ walk(definition.startAt);
373
+ // Unreachable correction nodes are intentional return destinations; other orphan nodes are invalid.
374
+ for (const node of nodes)
375
+ if (!completed.has(node.id) && node.kind !== 'correction')
376
+ errors.push(`WORKFLOW_DESIGNER_UNREACHABLE:${node.id}`);
377
+ return [...new Set(errors)];
378
+ }
379
+ /** Enumerate all typed fact leaves, including fields not used in an existing branch. */
380
+ export function workflowDesignerVariables(definition) {
381
+ const labels = { ...definition.readability?.variables };
382
+ const add = (schema, prefix = '', depth = 0) => {
383
+ if (depth > 8 || !record(schema))
384
+ return;
385
+ if (schema.type === 'object' && record(schema.properties))
386
+ for (const [key, child] of Object.entries(schema.properties))
387
+ add(child, prefix ? `${prefix}.${key}` : key, depth + 1);
388
+ else if (prefix)
389
+ labels[prefix] ||= { label: String(schema.title || prefix) };
390
+ };
391
+ add(definition.inputSchema);
392
+ for (const node of Object.values(definition.nodes))
393
+ if (node.kind === 'action')
394
+ add(node.outputSchema, `steps.${node.id}`);
395
+ return projectWorkflowGraph({ ...definition, readability: { ...definition.readability, variables: labels } }, 'draft').variables.filter(variable => variable.type !== 'unknown');
396
+ }
397
+ //# sourceMappingURL=workflow-designer.js.map