gbflowengine 0.1.0 → 0.1.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 (79) hide show
  1. package/README.md +271 -271
  2. package/dist/gbflowengine.css +1 -1
  3. package/dist/gbflowengine.js +8232 -6913
  4. package/dist/gbflowengine.js.map +1 -1
  5. package/dist/gbflowengine.umd.cjs +2 -2
  6. package/dist/gbflowengine.umd.cjs.map +1 -1
  7. package/package.json +85 -84
  8. package/src/center/DefinitionInspect.vue +291 -291
  9. package/src/center/FlowCenter.vue +33 -33
  10. package/src/center/index.js +29 -29
  11. package/src/center/storage.js +748 -748
  12. package/src/core/flow/condition.js +160 -160
  13. package/src/core/flow/customNode.js +385 -385
  14. package/src/core/flow/defaults.js +124 -124
  15. package/src/core/flow/flowConstant.js +265 -265
  16. package/src/core/flow/flowNodeUtils.js +29 -29
  17. package/src/core/flow/index.js +47 -47
  18. package/src/core/flow/node.js +44 -44
  19. package/src/core/flow/nodeFactory.js +58 -58
  20. package/src/core/flow/prediction.js +325 -325
  21. package/src/core/flow/schema.js +864 -864
  22. package/src/definition/FlowDefinitionDesigner.vue +338 -338
  23. package/src/definition/index.js +9 -9
  24. package/src/index.js +39 -39
  25. package/src/storage.js +200 -200
  26. package/src/testing/FlowTestPanel.vue +2502 -2502
  27. package/src/testing/UserConfigDrawer.vue +376 -376
  28. package/src/testing/diagram/FlowProgressDiagram.vue +318 -318
  29. package/src/testing/diagramModel.js +517 -517
  30. package/src/testing/index.js +23 -23
  31. package/src/testing/mock.js +246 -246
  32. package/src/testing/oaExecutors.js +51 -51
  33. package/src/testing/oaSeed.js +467 -467
  34. package/src/testing/sample.js +412 -412
  35. package/src/testing/seed.js +122 -122
  36. package/src/utils/format.js +27 -27
  37. package/src/visual/FlowCanvas.vue +440 -440
  38. package/src/visual/NodeProgressDetail.vue +43 -43
  39. package/src/visual/NodeStatusBadge.vue +17 -17
  40. package/src/visual/NodeWrap.vue +46 -46
  41. package/src/visual/ScWorkflow.vue +49 -49
  42. package/src/visual/SelectDialog.vue +459 -459
  43. package/src/visual/conditionHelpers.js +116 -116
  44. package/src/visual/index.js +6 -6
  45. package/src/visual/nodes/AddNode.vue +222 -222
  46. package/src/visual/nodes/ApproverNode.vue +347 -347
  47. package/src/visual/nodes/BranchNode.vue +441 -441
  48. package/src/visual/nodes/CustomNode.vue +339 -339
  49. package/src/visual/nodes/EndNode.vue +21 -21
  50. package/src/visual/nodes/PassNode.vue +100 -100
  51. package/src/visual/nodes/PromoterNode.vue +134 -134
  52. package/src/visual/nodes/RejectNode.vue +100 -100
  53. package/src/visual/nodes/SendNode.vue +151 -151
  54. package/src/visual/styles.scss +879 -879
  55. package/src/visual/useScNodeStatus.js +18 -18
  56. package/src/workbench/OaWorkbench.vue +1341 -1341
  57. package/src/workbench/components/ApprovalWorkspace.vue +2090 -2090
  58. package/src/workbench/components/CategoryIcon.vue +74 -74
  59. package/src/workbench/components/NotificationIcon.vue +73 -73
  60. package/src/workbench/components/ProcessSteps.vue +557 -557
  61. package/src/workbench/components/ResubmitDialog.vue +227 -227
  62. package/src/workbench/components/SidebarNav.vue +138 -138
  63. package/src/workbench/components/StartFlowDialog.vue +1058 -1058
  64. package/src/workbench/components/UserAvatar.vue +68 -68
  65. package/src/workbench/model.js +1080 -1080
  66. package/src/workbench/pages/DesignPage.vue +798 -798
  67. package/src/workbench/pages/HomePage.vue +1050 -1050
  68. package/src/workbench/pages/MonitorPage.vue +1029 -1029
  69. package/src/workbench/pages/NotificationsPage.vue +554 -554
  70. package/src/workbench/pages/RequestsPage.vue +644 -644
  71. package/src/workbench/pages/TaskCenterPage.vue +1155 -1155
  72. package/src/workbench/pages/TemplatesPage.vue +680 -680
  73. package/src/workbench/styles.scss +555 -555
  74. package/types/center.d.ts +5 -5
  75. package/types/core.d.ts +479 -479
  76. package/types/definition.d.ts +4 -4
  77. package/types/index.d.ts +34 -34
  78. package/types/testing.d.ts +20 -20
  79. package/types/visual.d.ts +20 -20
@@ -1,9 +1,9 @@
1
- /**
2
- * 流程定义编排层:把「基本信息 + 表单设计 + 流程设计」组装成一个可编辑的流程定义。
3
- *
4
- * 职责边界:
5
- * - 表单编辑交给 gbformdesign(FormDesigner)
6
- * - 流程编辑使用本包 visual 层(FlowCanvas)
7
- * - 本层只负责定义结构(meta / form / workflow)的归一化、同步与导入导出
8
- */
9
- export { default as FlowDefinitionDesigner } from './FlowDefinitionDesigner.vue'
1
+ /**
2
+ * 流程定义编排层:把「基本信息 + 表单设计 + 流程设计」组装成一个可编辑的流程定义。
3
+ *
4
+ * 职责边界:
5
+ * - 表单编辑交给 gbformdesign(FormDesigner)
6
+ * - 流程编辑使用本包 visual 层(FlowCanvas)
7
+ * - 本层只负责定义结构(meta / form / workflow)的归一化、同步与导入导出
8
+ */
9
+ export { default as FlowDefinitionDesigner } from './FlowDefinitionDesigner.vue'
package/src/index.js CHANGED
@@ -1,39 +1,39 @@
1
- import FlowTestPanel from './testing/FlowTestPanel.vue'
2
- import UserConfigDrawer from './testing/UserConfigDrawer.vue'
3
- import FlowProgressDiagram from './testing/diagram/FlowProgressDiagram.vue'
4
- import FlowDefinitionDesigner from './definition/FlowDefinitionDesigner.vue'
5
- import FlowCenter from './center/FlowCenter.vue'
6
- import { FlowCanvas, ScWorkflow, NodeStatusBadge, NodeProgressDetail } from './visual/index.js'
7
-
8
- export {
9
- FlowCenter,
10
- FlowTestPanel,
11
- UserConfigDrawer,
12
- FlowProgressDiagram,
13
- FlowDefinitionDesigner,
14
- FlowCanvas,
15
- ScWorkflow,
16
- NodeStatusBadge,
17
- NodeProgressDetail
18
- }
19
-
20
- export * from './core/flow/index.js'
21
- export * from './visual/index.js'
22
- export * from './testing/mock.js'
23
- export * from './testing/sample.js'
24
- export * from './testing/oaSeed.js'
25
- export * from './testing/oaExecutors.js'
26
- export { buildDiagramModel, pruneUnselectedBranches } from './testing/diagramModel.js'
27
-
28
- export const version = '0.1.0'
29
-
30
- const components = [FlowCenter, FlowTestPanel, FlowProgressDiagram, FlowDefinitionDesigner, FlowCanvas, ScWorkflow]
31
-
32
- export default {
33
- version,
34
- install(app) {
35
- components.forEach((component) => {
36
- if (component.name) app.component(component.name, component)
37
- })
38
- }
39
- }
1
+ import FlowTestPanel from './testing/FlowTestPanel.vue'
2
+ import UserConfigDrawer from './testing/UserConfigDrawer.vue'
3
+ import FlowProgressDiagram from './testing/diagram/FlowProgressDiagram.vue'
4
+ import FlowDefinitionDesigner from './definition/FlowDefinitionDesigner.vue'
5
+ import FlowCenter from './center/FlowCenter.vue'
6
+ import { FlowCanvas, ScWorkflow, NodeStatusBadge, NodeProgressDetail } from './visual/index.js'
7
+
8
+ export {
9
+ FlowCenter,
10
+ FlowTestPanel,
11
+ UserConfigDrawer,
12
+ FlowProgressDiagram,
13
+ FlowDefinitionDesigner,
14
+ FlowCanvas,
15
+ ScWorkflow,
16
+ NodeStatusBadge,
17
+ NodeProgressDetail
18
+ }
19
+
20
+ export * from './core/flow/index.js'
21
+ export * from './visual/index.js'
22
+ export * from './testing/mock.js'
23
+ export * from './testing/sample.js'
24
+ export * from './testing/oaSeed.js'
25
+ export * from './testing/oaExecutors.js'
26
+ export { buildDiagramModel, pruneUnselectedBranches } from './testing/diagramModel.js'
27
+
28
+ export const version = '0.1.0'
29
+
30
+ const components = [FlowCenter, FlowTestPanel, FlowProgressDiagram, FlowDefinitionDesigner, FlowCanvas, ScWorkflow]
31
+
32
+ export default {
33
+ version,
34
+ install(app) {
35
+ components.forEach((component) => {
36
+ if (component.name) app.component(component.name, component)
37
+ })
38
+ }
39
+ }
package/src/storage.js CHANGED
@@ -1,200 +1,200 @@
1
- /**
2
- * Small async storage facade used by the flow center and the workbench.
3
- * Prefers IndexedDB, falls back to localStorage, then to memory (SSR/tests).
4
- * Values are JSON strings so all backends stay interchangeable.
5
- */
6
-
7
- const DB_NAME = 'gbflowengine'
8
- const STORE_NAME = 'kv'
9
- const DB_VERSION = 1
10
- const memory = new Map()
11
-
12
- const IDB_TIMEOUT = 1500
13
-
14
- let dbPromise = null
15
- let idbUnavailable = false
16
-
17
- function hasIndexedDB() {
18
- return !idbUnavailable && typeof indexedDB !== 'undefined' && indexedDB !== null
19
- }
20
-
21
- function withTimeout(promise, label) {
22
- return new Promise((resolve, reject) => {
23
- const timer = setTimeout(() => reject(new Error(label)), IDB_TIMEOUT)
24
- promise.then(
25
- (value) => {
26
- clearTimeout(timer)
27
- resolve(value)
28
- },
29
- (error) => {
30
- clearTimeout(timer)
31
- reject(error)
32
- }
33
- )
34
- })
35
- }
36
-
37
- function hasLocalStorage() {
38
- try {
39
- return typeof localStorage !== 'undefined' && localStorage !== null
40
- } catch {
41
- return false
42
- }
43
- }
44
-
45
- function openDatabase() {
46
- if (!hasIndexedDB()) return Promise.reject(new Error('IndexedDB unavailable'))
47
- if (dbPromise) return dbPromise
48
- dbPromise = new Promise((resolve, reject) => {
49
- const request = indexedDB.open(DB_NAME, DB_VERSION)
50
- request.onupgradeneeded = () => {
51
- const db = request.result
52
- if (!db.objectStoreNames.contains(STORE_NAME)) db.createObjectStore(STORE_NAME)
53
- }
54
- request.onsuccess = () => resolve(request.result)
55
- request.onerror = () => reject(request.error || new Error('IndexedDB open failed'))
56
- request.onblocked = () => reject(new Error('IndexedDB open blocked'))
57
- }).catch((error) => {
58
- dbPromise = null
59
- throw error
60
- })
61
- return dbPromise
62
- }
63
-
64
- async function idbGet(key) {
65
- const db = await openDatabase()
66
- return new Promise((resolve, reject) => {
67
- const transaction = db.transaction(STORE_NAME, 'readonly')
68
- const request = transaction.objectStore(STORE_NAME).get(key)
69
- request.onsuccess = () => resolve(request.result)
70
- request.onerror = () => reject(request.error)
71
- })
72
- }
73
-
74
- async function idbSet(key, value) {
75
- const db = await openDatabase()
76
- return new Promise((resolve, reject) => {
77
- const transaction = db.transaction(STORE_NAME, 'readwrite')
78
- transaction.objectStore(STORE_NAME).put(value, key)
79
- transaction.oncomplete = () => resolve()
80
- transaction.onerror = () => reject(transaction.error)
81
- })
82
- }
83
-
84
- async function idbDelete(key) {
85
- const db = await openDatabase()
86
- return new Promise((resolve, reject) => {
87
- const transaction = db.transaction(STORE_NAME, 'readwrite')
88
- transaction.objectStore(STORE_NAME).delete(key)
89
- transaction.oncomplete = () => resolve()
90
- transaction.onerror = () => reject(transaction.error)
91
- })
92
- }
93
-
94
- function localGet(key) {
95
- if (!hasLocalStorage()) return null
96
- try {
97
- return localStorage.getItem(key)
98
- } catch {
99
- return null
100
- }
101
- }
102
-
103
- function localSet(key, value) {
104
- if (!hasLocalStorage()) return false
105
- try {
106
- localStorage.setItem(key, value)
107
- return true
108
- } catch {
109
- return false
110
- }
111
- }
112
-
113
- function localRemove(key) {
114
- if (!hasLocalStorage()) return
115
- try {
116
- localStorage.removeItem(key)
117
- } catch {
118
- // ignore quota/security failures
119
- }
120
- }
121
-
122
- async function readRaw(key) {
123
- if (hasIndexedDB()) {
124
- try {
125
- const value = await withTimeout(idbGet(key), 'IndexedDB read timeout')
126
- if (value !== undefined && value !== null) return value
127
- } catch {
128
- idbUnavailable = true
129
- // fall through to localStorage / memory
130
- }
131
- }
132
- const legacy = localGet(key)
133
- if (legacy !== null) {
134
- // One-time migration from the previous localStorage-only version.
135
- if (hasIndexedDB()) {
136
- try {
137
- await withTimeout(idbSet(key, legacy), 'IndexedDB migration timeout')
138
- localRemove(key)
139
- } catch {
140
- idbUnavailable = true
141
- // keep the localStorage copy if IndexedDB rejects the write
142
- }
143
- }
144
- return legacy
145
- }
146
- return memory.get(key) ?? null
147
- }
148
-
149
- async function writeRaw(key, value) {
150
- memory.set(key, value)
151
- if (hasIndexedDB()) {
152
- try {
153
- await withTimeout(idbSet(key, value), 'IndexedDB write timeout')
154
- } catch {
155
- idbUnavailable = true
156
- // localStorage below remains the fallback
157
- }
158
- }
159
- // Mirrored on purpose: keeps a synchronous fallback if IndexedDB later fails.
160
- localSet(key, value)
161
- }
162
-
163
- async function removeRaw(key) {
164
- memory.delete(key)
165
- if (hasIndexedDB()) {
166
- try {
167
- await withTimeout(idbDelete(key), 'IndexedDB delete timeout')
168
- } catch {
169
- idbUnavailable = true
170
- // ignore and still clear the other backends
171
- }
172
- }
173
- localRemove(key)
174
- }
175
-
176
- export const flowStorage = {
177
- async getJSON(key, fallback = null) {
178
- const raw = await readRaw(key)
179
- if (raw === null || raw === undefined || raw === '') return fallback
180
- try {
181
- return JSON.parse(raw)
182
- } catch {
183
- return fallback
184
- }
185
- },
186
-
187
- async setJSON(key, value) {
188
- await writeRaw(key, JSON.stringify(value))
189
- },
190
-
191
- async remove(key) {
192
- await removeRaw(key)
193
- }
194
- }
195
-
196
- /** Test/DI hook: drop the cached IndexedDB connection. */
197
- export function resetFlowStorageConnection() {
198
- dbPromise = null
199
- idbUnavailable = false
200
- }
1
+ /**
2
+ * Small async storage facade used by the flow center and the workbench.
3
+ * Prefers IndexedDB, falls back to localStorage, then to memory (SSR/tests).
4
+ * Values are JSON strings so all backends stay interchangeable.
5
+ */
6
+
7
+ const DB_NAME = 'gbflowengine'
8
+ const STORE_NAME = 'kv'
9
+ const DB_VERSION = 1
10
+ const memory = new Map()
11
+
12
+ const IDB_TIMEOUT = 1500
13
+
14
+ let dbPromise = null
15
+ let idbUnavailable = false
16
+
17
+ function hasIndexedDB() {
18
+ return !idbUnavailable && typeof indexedDB !== 'undefined' && indexedDB !== null
19
+ }
20
+
21
+ function withTimeout(promise, label) {
22
+ return new Promise((resolve, reject) => {
23
+ const timer = setTimeout(() => reject(new Error(label)), IDB_TIMEOUT)
24
+ promise.then(
25
+ (value) => {
26
+ clearTimeout(timer)
27
+ resolve(value)
28
+ },
29
+ (error) => {
30
+ clearTimeout(timer)
31
+ reject(error)
32
+ }
33
+ )
34
+ })
35
+ }
36
+
37
+ function hasLocalStorage() {
38
+ try {
39
+ return typeof localStorage !== 'undefined' && localStorage !== null
40
+ } catch {
41
+ return false
42
+ }
43
+ }
44
+
45
+ function openDatabase() {
46
+ if (!hasIndexedDB()) return Promise.reject(new Error('IndexedDB unavailable'))
47
+ if (dbPromise) return dbPromise
48
+ dbPromise = new Promise((resolve, reject) => {
49
+ const request = indexedDB.open(DB_NAME, DB_VERSION)
50
+ request.onupgradeneeded = () => {
51
+ const db = request.result
52
+ if (!db.objectStoreNames.contains(STORE_NAME)) db.createObjectStore(STORE_NAME)
53
+ }
54
+ request.onsuccess = () => resolve(request.result)
55
+ request.onerror = () => reject(request.error || new Error('IndexedDB open failed'))
56
+ request.onblocked = () => reject(new Error('IndexedDB open blocked'))
57
+ }).catch((error) => {
58
+ dbPromise = null
59
+ throw error
60
+ })
61
+ return dbPromise
62
+ }
63
+
64
+ async function idbGet(key) {
65
+ const db = await openDatabase()
66
+ return new Promise((resolve, reject) => {
67
+ const transaction = db.transaction(STORE_NAME, 'readonly')
68
+ const request = transaction.objectStore(STORE_NAME).get(key)
69
+ request.onsuccess = () => resolve(request.result)
70
+ request.onerror = () => reject(request.error)
71
+ })
72
+ }
73
+
74
+ async function idbSet(key, value) {
75
+ const db = await openDatabase()
76
+ return new Promise((resolve, reject) => {
77
+ const transaction = db.transaction(STORE_NAME, 'readwrite')
78
+ transaction.objectStore(STORE_NAME).put(value, key)
79
+ transaction.oncomplete = () => resolve()
80
+ transaction.onerror = () => reject(transaction.error)
81
+ })
82
+ }
83
+
84
+ async function idbDelete(key) {
85
+ const db = await openDatabase()
86
+ return new Promise((resolve, reject) => {
87
+ const transaction = db.transaction(STORE_NAME, 'readwrite')
88
+ transaction.objectStore(STORE_NAME).delete(key)
89
+ transaction.oncomplete = () => resolve()
90
+ transaction.onerror = () => reject(transaction.error)
91
+ })
92
+ }
93
+
94
+ function localGet(key) {
95
+ if (!hasLocalStorage()) return null
96
+ try {
97
+ return localStorage.getItem(key)
98
+ } catch {
99
+ return null
100
+ }
101
+ }
102
+
103
+ function localSet(key, value) {
104
+ if (!hasLocalStorage()) return false
105
+ try {
106
+ localStorage.setItem(key, value)
107
+ return true
108
+ } catch {
109
+ return false
110
+ }
111
+ }
112
+
113
+ function localRemove(key) {
114
+ if (!hasLocalStorage()) return
115
+ try {
116
+ localStorage.removeItem(key)
117
+ } catch {
118
+ // ignore quota/security failures
119
+ }
120
+ }
121
+
122
+ async function readRaw(key) {
123
+ if (hasIndexedDB()) {
124
+ try {
125
+ const value = await withTimeout(idbGet(key), 'IndexedDB read timeout')
126
+ if (value !== undefined && value !== null) return value
127
+ } catch {
128
+ idbUnavailable = true
129
+ // fall through to localStorage / memory
130
+ }
131
+ }
132
+ const legacy = localGet(key)
133
+ if (legacy !== null) {
134
+ // One-time migration from the previous localStorage-only version.
135
+ if (hasIndexedDB()) {
136
+ try {
137
+ await withTimeout(idbSet(key, legacy), 'IndexedDB migration timeout')
138
+ localRemove(key)
139
+ } catch {
140
+ idbUnavailable = true
141
+ // keep the localStorage copy if IndexedDB rejects the write
142
+ }
143
+ }
144
+ return legacy
145
+ }
146
+ return memory.get(key) ?? null
147
+ }
148
+
149
+ async function writeRaw(key, value) {
150
+ memory.set(key, value)
151
+ if (hasIndexedDB()) {
152
+ try {
153
+ await withTimeout(idbSet(key, value), 'IndexedDB write timeout')
154
+ } catch {
155
+ idbUnavailable = true
156
+ // localStorage below remains the fallback
157
+ }
158
+ }
159
+ // Mirrored on purpose: keeps a synchronous fallback if IndexedDB later fails.
160
+ localSet(key, value)
161
+ }
162
+
163
+ async function removeRaw(key) {
164
+ memory.delete(key)
165
+ if (hasIndexedDB()) {
166
+ try {
167
+ await withTimeout(idbDelete(key), 'IndexedDB delete timeout')
168
+ } catch {
169
+ idbUnavailable = true
170
+ // ignore and still clear the other backends
171
+ }
172
+ }
173
+ localRemove(key)
174
+ }
175
+
176
+ export const flowStorage = {
177
+ async getJSON(key, fallback = null) {
178
+ const raw = await readRaw(key)
179
+ if (raw === null || raw === undefined || raw === '') return fallback
180
+ try {
181
+ return JSON.parse(raw)
182
+ } catch {
183
+ return fallback
184
+ }
185
+ },
186
+
187
+ async setJSON(key, value) {
188
+ await writeRaw(key, JSON.stringify(value))
189
+ },
190
+
191
+ async remove(key) {
192
+ await removeRaw(key)
193
+ }
194
+ }
195
+
196
+ /** Test/DI hook: drop the cached IndexedDB connection. */
197
+ export function resetFlowStorageConnection() {
198
+ dbPromise = null
199
+ idbUnavailable = false
200
+ }