@nocobase/plugin-workflow 1.7.0-beta.2 → 1.7.0-beta.21
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/dist/client/3d24e559cfbba5d8.js +10 -0
- package/dist/client/90a4f6d29bd453a7.js +10 -0
- package/dist/client/WorkflowTasks.d.ts +11 -11
- package/dist/client/a2fc280565d1c746.js +10 -0
- package/dist/client/f4370978c40502d7.js +10 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +1 -1
- package/dist/client/locale/index.d.ts +2 -1
- package/dist/client/schemas/executions.d.ts +126 -125
- package/dist/client/triggers/schedule/RepeatField.d.ts +2 -1
- package/dist/common/collections/executions.d.ts +136 -0
- package/dist/common/collections/executions.js +125 -0
- package/dist/common/collections/flow_nodes.d.ts +44 -0
- package/dist/common/collections/flow_nodes.js +88 -0
- package/dist/common/collections/jobs.d.ts +37 -0
- package/dist/common/collections/jobs.js +74 -0
- package/dist/common/collections/workflowStats.d.ts +37 -0
- package/dist/common/collections/workflowStats.js +59 -0
- package/dist/common/collections/workflowTasks.d.ts +10 -0
- package/dist/common/collections/workflowTasks.js +64 -0
- package/dist/common/collections/workflowVersionStats.d.ts +37 -0
- package/dist/common/collections/workflowVersionStats.js +59 -0
- package/dist/common/collections/workflows.d.ts +250 -0
- package/dist/common/collections/workflows.js +225 -0
- package/dist/common/constants.d.ts +9 -0
- package/dist/common/constants.js +36 -0
- package/dist/externalVersion.js +13 -13
- package/dist/locale/it-IT.json +123 -18
- package/dist/locale/zh-CN.json +4 -0
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/LICENSE +201 -0
- package/dist/node_modules/nodejs-snowflake/nodejs_snowflake.d.ts +62 -0
- package/dist/node_modules/nodejs-snowflake/nodejs_snowflake.js +1 -0
- package/dist/node_modules/nodejs-snowflake/nodejs_snowflake_bg.wasm +0 -0
- package/dist/node_modules/nodejs-snowflake/package.json +1 -0
- package/dist/server/Dispatcher.d.ts +11 -0
- package/dist/server/Dispatcher.js +35 -0
- package/dist/server/Plugin.d.ts +8 -1
- package/dist/server/Plugin.js +118 -70
- package/dist/server/Processor.d.ts +4 -11
- package/dist/server/Processor.js +48 -45
- package/dist/server/actions/nodes.js +7 -5
- package/dist/server/actions/workflowTasks.js +4 -2
- package/dist/server/actions/workflows.js +5 -2
- package/dist/server/collections/executions.js +12 -44
- package/dist/server/collections/flow_nodes.js +12 -57
- package/dist/server/collections/jobs.js +12 -36
- package/dist/server/collections/workflowStats.d.ts +11 -0
- package/dist/server/collections/workflowStats.js +43 -0
- package/dist/server/collections/workflowTasks.d.ts +2 -1
- package/dist/server/collections/workflowTasks.js +12 -33
- package/dist/server/collections/workflowVersionStats.d.ts +11 -0
- package/dist/server/collections/workflowVersionStats.js +43 -0
- package/dist/server/collections/workflows.d.ts +2 -1
- package/dist/server/collections/workflows.js +12 -101
- package/dist/server/migrations/20250320223415-stats.d.ts +14 -0
- package/dist/server/migrations/20250320223415-stats.js +82 -0
- package/dist/server/migrations/20250409164913-remove-jobs-auto-increment.d.ts +14 -0
- package/dist/server/migrations/20250409164913-remove-jobs-auto-increment.js +57 -0
- package/dist/server/repositories/WorkflowRepository.js +1 -2
- package/dist/server/triggers/ScheduleTrigger/DateFieldScheduleTrigger.d.ts +5 -3
- package/dist/server/triggers/ScheduleTrigger/DateFieldScheduleTrigger.js +39 -36
- package/dist/server/triggers/ScheduleTrigger/StaticScheduleTrigger.d.ts +4 -2
- package/dist/server/triggers/ScheduleTrigger/StaticScheduleTrigger.js +26 -24
- package/dist/server/triggers/ScheduleTrigger/index.d.ts +2 -1
- package/dist/server/triggers/ScheduleTrigger/index.js +4 -8
- package/dist/server/triggers/index.d.ts +1 -1
- package/dist/server/types/Workflow.d.ts +0 -2
- package/dist/swagger/index.d.ts +0 -14
- package/dist/swagger/index.js +0 -14
- package/package.json +4 -3
- package/dist/client/4d75ef32f02d7285.js +0 -10
- package/dist/client/56ce448358002e64.js +0 -10
- package/dist/client/58bb427e05b600de.js +0 -10
- package/dist/client/739d458621edf81f.js +0 -10
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2020 Utkarsh Srivastava
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export interface SnowflakeOpts {
|
|
5
|
+
custom_epoch?: number;
|
|
6
|
+
instance_id?: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*/
|
|
12
|
+
export class Snowflake {
|
|
13
|
+
free(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Constructs a Snowflake object which stores method for generation
|
|
16
|
+
* of a unique 64 bit time sortable ID
|
|
17
|
+
* @param {SnowflakeOpts | undefined} opts
|
|
18
|
+
*/
|
|
19
|
+
constructor(opts?: SnowflakeOpts);
|
|
20
|
+
/**
|
|
21
|
+
* getUniqueID generates a 64 bit unique ID
|
|
22
|
+
*
|
|
23
|
+
* NOTE: This method is blocking in nature, the function also
|
|
24
|
+
* has theorotical limit of generating 1,024,000 IDs/sec
|
|
25
|
+
* @returns {BigInt}
|
|
26
|
+
*/
|
|
27
|
+
getUniqueID(): BigInt;
|
|
28
|
+
/**
|
|
29
|
+
* idFromTimestamp takes a UNIX timestamp without any offset
|
|
30
|
+
* and returns an ID that has timestamp set to the given timestamp
|
|
31
|
+
* @param {number} timestamp
|
|
32
|
+
* @returns {BigInt}
|
|
33
|
+
*/
|
|
34
|
+
idFromTimestamp(timestamp: number): BigInt;
|
|
35
|
+
/**
|
|
36
|
+
* instanceID returns the current node id
|
|
37
|
+
* @returns {number}
|
|
38
|
+
*/
|
|
39
|
+
instanceID(): number;
|
|
40
|
+
/**
|
|
41
|
+
* customEpoch returns the current custom epoch
|
|
42
|
+
* @returns {number}
|
|
43
|
+
*/
|
|
44
|
+
customEpoch(): number;
|
|
45
|
+
/**
|
|
46
|
+
* timestampFromID takes a unique ID and returns the timestamp
|
|
47
|
+
* when the Unique ID was created
|
|
48
|
+
* @param {BigInt} unique_id
|
|
49
|
+
* @param {number} epoch_offset
|
|
50
|
+
* @returns {number}
|
|
51
|
+
*/
|
|
52
|
+
static timestampFromID(unique_id: BigInt, epoch_offset: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* instanceIDFromID takes a unique ID and returns the instance
|
|
55
|
+
* ID where the unique ID was created
|
|
56
|
+
*
|
|
57
|
+
* NOTE: The unique ID could be created on ANY instance
|
|
58
|
+
* @param {BigInt} unique_id
|
|
59
|
+
* @returns {number}
|
|
60
|
+
*/
|
|
61
|
+
static instanceIDFromID(unique_id: BigInt): number;
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){var e={363:function(e,t,n){let r={};r["__wbindgen_placeholder__"]=e.exports;let o;const{TextDecoder:i,TextEncoder:a}=n(837);let s=new i("utf-8",{ignoreBOM:true,fatal:true});s.decode();let _=null;function getUint8Memory0(){if(_===null||_.buffer!==o.memory.buffer){_=new Uint8Array(o.memory.buffer)}return _}function getStringFromWasm0(e,t){return s.decode(getUint8Memory0().subarray(e,e+t))}const c=new Array(32).fill(undefined);c.push(undefined,null,true,false);let u=c.length;function addHeapObject(e){if(u===c.length)c.push(c.length+1);const t=u;u=c[t];c[t]=e;return t}function getObject(e){return c[e]}function dropObject(e){if(e<36)return;c[e]=u;u=e}function takeObject(e){const t=getObject(e);dropObject(e);return t}let f=0;let d=new a("utf-8");const l=typeof d.encodeInto==="function"?function(e,t){return d.encodeInto(e,t)}:function(e,t){const n=d.encode(e);t.set(n);return{read:e.length,written:n.length}};function passStringToWasm0(e,t,n){if(n===undefined){const n=d.encode(e);const r=t(n.length);getUint8Memory0().subarray(r,r+n.length).set(n);f=n.length;return r}let r=e.length;let o=t(r);const i=getUint8Memory0();let a=0;for(;a<r;a++){const t=e.charCodeAt(a);if(t>127)break;i[o+a]=t}if(a!==r){if(a!==0){e=e.slice(a)}o=n(o,r,r=a+e.length*3);const t=getUint8Memory0().subarray(o+a,o+r);const i=l(e,t);a+=i.written}f=a;return o}let w=null;function getInt32Memory0(){if(w===null||w.buffer!==o.memory.buffer){w=new Int32Array(o.memory.buffer)}return w}function isLikeNone(e){return e===undefined||e===null}const g=new Uint32Array(2);const m=new BigUint64Array(g.buffer);function notDefined(e){return()=>{throw new Error(`${e} is not defined`)}}class Snowflake{static __wrap(e){const t=Object.create(Snowflake.prototype);t.ptr=e;return t}__destroy_into_raw(){const e=this.ptr;this.ptr=0;return e}free(){const e=this.__destroy_into_raw();o.__wbg_snowflake_free(e)}constructor(e){try{const i=o.__wbindgen_add_to_stack_pointer(-16);o.snowflake_new(i,isLikeNone(e)?0:addHeapObject(e));var t=getInt32Memory0()[i/4+0];var n=getInt32Memory0()[i/4+1];var r=getInt32Memory0()[i/4+2];if(r){throw takeObject(n)}return Snowflake.__wrap(t)}finally{o.__wbindgen_add_to_stack_pointer(16)}}getUniqueID(){try{const n=o.__wbindgen_add_to_stack_pointer(-16);o.snowflake_getUniqueID(n,this.ptr);var e=getInt32Memory0()[n/4+0];var t=getInt32Memory0()[n/4+1];g[0]=e;g[1]=t;const r=m[0];return r}finally{o.__wbindgen_add_to_stack_pointer(16)}}idFromTimestamp(e){try{const r=o.__wbindgen_add_to_stack_pointer(-16);o.snowflake_idFromTimestamp(r,this.ptr,e);var t=getInt32Memory0()[r/4+0];var n=getInt32Memory0()[r/4+1];g[0]=t;g[1]=n;const i=m[0];return i}finally{o.__wbindgen_add_to_stack_pointer(16)}}instanceID(){var e=o.snowflake_instanceID(this.ptr);return e}customEpoch(){var e=o.snowflake_customEpoch(this.ptr);return e}static timestampFromID(e,t){m[0]=e;const n=g[0];const r=g[1];var i=o.snowflake_timestampFromID(n,r,t);return i}static instanceIDFromID(e){m[0]=e;const t=g[0];const n=g[1];var r=o.snowflake_instanceIDFromID(t,n);return r}}e.exports.Snowflake=Snowflake;e.exports.__wbindgen_string_new=function(e,t){var n=getStringFromWasm0(e,t);return addHeapObject(n)};e.exports.__wbindgen_object_drop_ref=function(e){takeObject(e)};e.exports.__wbindgen_json_serialize=function(e,t){const n=getObject(t);var r=JSON.stringify(n===undefined?null:n);var i=passStringToWasm0(r,o.__wbindgen_malloc,o.__wbindgen_realloc);var a=f;getInt32Memory0()[e/4+1]=a;getInt32Memory0()[e/4+0]=i};e.exports.__wbg_now_e6c39c10a5e8aec7=function(){var e=Date.now();return e};e.exports.__wbg_random_7b8246250fd79f60=typeof Math.random=="function"?Math.random:notDefined("Math.random");e.exports.__wbindgen_throw=function(e,t){throw new Error(getStringFromWasm0(e,t))};const p=n.ab+"nodejs_snowflake_bg.wasm";const b=n(147).readFileSync(n.ab+"nodejs_snowflake_bg.wasm");const y=new WebAssembly.Module(b);const k=new WebAssembly.Instance(y,r);o=k.exports;e.exports.__wasm=o},147:function(e){"use strict";e.exports=require("fs")},837:function(e){"use strict";e.exports=require("util")}};var t={};function __nccwpck_require__(n){var r=t[n];if(r!==undefined){return r.exports}var o=t[n]={exports:{}};var i=true;try{e[n](o,o.exports,__nccwpck_require__);i=false}finally{if(i)delete t[n]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n=__nccwpck_require__(363);module.exports=n})();
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"nodejs-snowflake","collaborators":["Utkarsh Srivastava <utkarsh@sagacious.dev>"],"description":"Generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)","version":"2.0.1","license":"Apache 2.0","repository":{"type":"git","url":"https://github.com/utkarsh-pro/nodejs-snowflake.git"},"files":["nodejs_snowflake_bg.wasm","nodejs_snowflake.js","nodejs_snowflake.d.ts"],"main":"nodejs_snowflake.js","types":"nodejs_snowflake.d.ts","_lastModified":"2025-04-23T10:34:21.069Z"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export default class Dispatcher {
|
|
10
|
+
constructor();
|
|
11
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var Dispatcher_exports = {};
|
|
28
|
+
__export(Dispatcher_exports, {
|
|
29
|
+
default: () => Dispatcher
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(Dispatcher_exports);
|
|
32
|
+
class Dispatcher {
|
|
33
|
+
constructor() {
|
|
34
|
+
}
|
|
35
|
+
}
|
package/dist/server/Plugin.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
import { Snowflake } from 'nodejs-snowflake';
|
|
9
10
|
import { Transactionable } from 'sequelize';
|
|
10
11
|
import { Plugin } from '@nocobase/server';
|
|
11
12
|
import { Registry } from '@nocobase/utils';
|
|
@@ -31,6 +32,7 @@ export default class PluginWorkflowServer extends Plugin {
|
|
|
31
32
|
triggers: Registry<Trigger>;
|
|
32
33
|
functions: Registry<CustomFunction>;
|
|
33
34
|
enabledCache: Map<number, WorkflowModel>;
|
|
35
|
+
snowflake: Snowflake;
|
|
34
36
|
private ready;
|
|
35
37
|
private executing;
|
|
36
38
|
private pending;
|
|
@@ -40,6 +42,11 @@ export default class PluginWorkflowServer extends Plugin {
|
|
|
40
42
|
private meter;
|
|
41
43
|
private checker;
|
|
42
44
|
private onBeforeSave;
|
|
45
|
+
private onAfterCreate;
|
|
46
|
+
private onAfterUpdate;
|
|
47
|
+
private onAfterDestroy;
|
|
48
|
+
private onAfterStart;
|
|
49
|
+
private onBeforeStop;
|
|
43
50
|
handleSyncMessage(message: any): Promise<void>;
|
|
44
51
|
/**
|
|
45
52
|
* @experimental
|
|
@@ -91,6 +98,6 @@ export default class PluginWorkflowServer extends Plugin {
|
|
|
91
98
|
/**
|
|
92
99
|
* @experimental
|
|
93
100
|
*/
|
|
94
|
-
toggleTaskStatus(task: WorkflowTaskModel,
|
|
101
|
+
toggleTaskStatus(task: WorkflowTaskModel, on: boolean, { transaction }: Transactionable): Promise<void>;
|
|
95
102
|
}
|
|
96
103
|
export {};
|
package/dist/server/Plugin.js
CHANGED
|
@@ -41,6 +41,7 @@ __export(Plugin_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(Plugin_exports);
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var import_crypto = require("crypto");
|
|
44
|
+
var import_nodejs_snowflake = require("nodejs-snowflake");
|
|
44
45
|
var import_sequelize = require("sequelize");
|
|
45
46
|
var import_lru_cache = __toESM(require("lru-cache"));
|
|
46
47
|
var import_database = require("@nocobase/database");
|
|
@@ -66,6 +67,7 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
66
67
|
triggers = new import_utils.Registry();
|
|
67
68
|
functions = new import_utils.Registry();
|
|
68
69
|
enabledCache = /* @__PURE__ */ new Map();
|
|
70
|
+
snowflake;
|
|
69
71
|
ready = false;
|
|
70
72
|
executing = null;
|
|
71
73
|
pending = [];
|
|
@@ -76,6 +78,9 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
76
78
|
checker = null;
|
|
77
79
|
onBeforeSave = async (instance, { transaction }) => {
|
|
78
80
|
const Model = instance.constructor;
|
|
81
|
+
if (!instance.key) {
|
|
82
|
+
instance.set("key", (0, import_utils.uid)());
|
|
83
|
+
}
|
|
79
84
|
if (instance.enabled) {
|
|
80
85
|
instance.set("current", true);
|
|
81
86
|
}
|
|
@@ -103,6 +108,82 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
103
108
|
this.toggle(previous, false, { transaction });
|
|
104
109
|
}
|
|
105
110
|
};
|
|
111
|
+
onAfterCreate = async (model, { transaction }) => {
|
|
112
|
+
const WorkflowStatsModel = this.db.getModel("workflowStats");
|
|
113
|
+
let stats = await WorkflowStatsModel.findOne({
|
|
114
|
+
where: { key: model.key },
|
|
115
|
+
transaction
|
|
116
|
+
});
|
|
117
|
+
if (!stats) {
|
|
118
|
+
stats = await model.createStats({ executed: 0 }, { transaction });
|
|
119
|
+
}
|
|
120
|
+
model.stats = stats;
|
|
121
|
+
model.versionStats = await model.createVersionStats({ id: model.id }, { transaction });
|
|
122
|
+
if (model.enabled) {
|
|
123
|
+
this.toggle(model, true, { transaction });
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
onAfterUpdate = async (model, { transaction }) => {
|
|
127
|
+
model.stats = await model.getStats({ transaction });
|
|
128
|
+
model.versionStats = await model.getVersionStats({ transaction });
|
|
129
|
+
this.toggle(model, model.enabled, { transaction });
|
|
130
|
+
};
|
|
131
|
+
onAfterDestroy = async (model, { transaction }) => {
|
|
132
|
+
this.toggle(model, false, { transaction });
|
|
133
|
+
const TaskRepo = this.db.getRepository("workflowTasks");
|
|
134
|
+
await TaskRepo.destroy({
|
|
135
|
+
filter: {
|
|
136
|
+
workflowId: model.id
|
|
137
|
+
},
|
|
138
|
+
transaction
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
// [Life Cycle]:
|
|
142
|
+
// * load all workflows in db
|
|
143
|
+
// * add all hooks for enabled workflows
|
|
144
|
+
// * add hooks for create/update[enabled]/delete workflow to add/remove specific hooks
|
|
145
|
+
onAfterStart = async () => {
|
|
146
|
+
this.ready = true;
|
|
147
|
+
const collection = this.db.getCollection("workflows");
|
|
148
|
+
const workflows = await collection.repository.find({
|
|
149
|
+
filter: { enabled: true },
|
|
150
|
+
appends: ["stats", "versionStats"]
|
|
151
|
+
});
|
|
152
|
+
for (const workflow of workflows) {
|
|
153
|
+
if (!workflow.stats) {
|
|
154
|
+
workflow.stats = await workflow.createStats({ executed: 0 });
|
|
155
|
+
}
|
|
156
|
+
if (!workflow.versionStats) {
|
|
157
|
+
workflow.versionStats = await workflow.createVersionStats({ executed: 0 });
|
|
158
|
+
}
|
|
159
|
+
this.toggle(workflow, true, { silent: true });
|
|
160
|
+
}
|
|
161
|
+
this.checker = setInterval(() => {
|
|
162
|
+
this.getLogger("dispatcher").info(`(cycling) check for queueing executions`);
|
|
163
|
+
this.dispatch();
|
|
164
|
+
}, 3e5);
|
|
165
|
+
this.app.on("workflow:dispatch", () => {
|
|
166
|
+
this.app.logger.info("workflow:dispatch");
|
|
167
|
+
this.dispatch();
|
|
168
|
+
});
|
|
169
|
+
this.getLogger("dispatcher").info("(starting) check for queueing executions");
|
|
170
|
+
this.dispatch();
|
|
171
|
+
};
|
|
172
|
+
onBeforeStop = async () => {
|
|
173
|
+
for (const workflow of this.enabledCache.values()) {
|
|
174
|
+
this.toggle(workflow, false, { silent: true });
|
|
175
|
+
}
|
|
176
|
+
this.ready = false;
|
|
177
|
+
if (this.events.length) {
|
|
178
|
+
await this.prepare();
|
|
179
|
+
}
|
|
180
|
+
if (this.executing) {
|
|
181
|
+
await this.executing;
|
|
182
|
+
}
|
|
183
|
+
if (this.checker) {
|
|
184
|
+
clearInterval(this.checker);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
106
187
|
async handleSyncMessage(message) {
|
|
107
188
|
if (message.type === "statusChange") {
|
|
108
189
|
if (message.enabled) {
|
|
@@ -196,6 +277,13 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
196
277
|
WorkflowRepository: import_WorkflowRepository.default,
|
|
197
278
|
WorkflowTasksRepository: import_WorkflowTasksRepository.default
|
|
198
279
|
});
|
|
280
|
+
const PluginRepo = this.db.getRepository("applicationPlugins");
|
|
281
|
+
const pluginRecord = await PluginRepo.findOne({
|
|
282
|
+
filter: { name: this.name }
|
|
283
|
+
});
|
|
284
|
+
this.snowflake = new import_nodejs_snowflake.Snowflake({
|
|
285
|
+
custom_epoch: pluginRecord == null ? void 0 : pluginRecord.createdAt.getTime()
|
|
286
|
+
});
|
|
199
287
|
}
|
|
200
288
|
/**
|
|
201
289
|
* @internal
|
|
@@ -247,54 +335,11 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
247
335
|
}
|
|
248
336
|
});
|
|
249
337
|
db.on("workflows.beforeSave", this.onBeforeSave);
|
|
250
|
-
db.on("workflows.afterCreate",
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
db.on(
|
|
256
|
-
"workflows.afterUpdate",
|
|
257
|
-
(model, { transaction }) => this.toggle(model, model.enabled, { transaction })
|
|
258
|
-
);
|
|
259
|
-
db.on(
|
|
260
|
-
"workflows.afterDestroy",
|
|
261
|
-
(model, { transaction }) => this.toggle(model, false, { transaction })
|
|
262
|
-
);
|
|
263
|
-
this.app.on("afterStart", async () => {
|
|
264
|
-
this.ready = true;
|
|
265
|
-
const collection = db.getCollection("workflows");
|
|
266
|
-
const workflows = await collection.repository.find({
|
|
267
|
-
filter: { enabled: true }
|
|
268
|
-
});
|
|
269
|
-
workflows.forEach((workflow) => {
|
|
270
|
-
this.toggle(workflow, true, { silent: true });
|
|
271
|
-
});
|
|
272
|
-
this.checker = setInterval(() => {
|
|
273
|
-
this.getLogger("dispatcher").info(`(cycling) check for queueing executions`);
|
|
274
|
-
this.dispatch();
|
|
275
|
-
}, 3e5);
|
|
276
|
-
this.app.on("workflow:dispatch", () => {
|
|
277
|
-
this.app.logger.info("workflow:dispatch");
|
|
278
|
-
this.dispatch();
|
|
279
|
-
});
|
|
280
|
-
this.getLogger("dispatcher").info("(starting) check for queueing executions");
|
|
281
|
-
this.dispatch();
|
|
282
|
-
});
|
|
283
|
-
this.app.on("beforeStop", async () => {
|
|
284
|
-
for (const workflow of this.enabledCache.values()) {
|
|
285
|
-
this.toggle(workflow, false, { silent: true });
|
|
286
|
-
}
|
|
287
|
-
this.ready = false;
|
|
288
|
-
if (this.events.length) {
|
|
289
|
-
await this.prepare();
|
|
290
|
-
}
|
|
291
|
-
if (this.executing) {
|
|
292
|
-
await this.executing;
|
|
293
|
-
}
|
|
294
|
-
if (this.checker) {
|
|
295
|
-
clearInterval(this.checker);
|
|
296
|
-
}
|
|
297
|
-
});
|
|
338
|
+
db.on("workflows.afterCreate", this.onAfterCreate);
|
|
339
|
+
db.on("workflows.afterUpdate", this.onAfterUpdate);
|
|
340
|
+
db.on("workflows.afterDestroy", this.onAfterDestroy);
|
|
341
|
+
this.app.on("afterStart", this.onAfterStart);
|
|
342
|
+
this.app.on("beforeStop", this.onBeforeStop);
|
|
298
343
|
}
|
|
299
344
|
toggle(workflow, enable, { silent, transaction } = {}) {
|
|
300
345
|
const type = workflow.get("type");
|
|
@@ -308,11 +353,14 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
308
353
|
const prev = workflow.previous();
|
|
309
354
|
if (prev.config) {
|
|
310
355
|
trigger.off({ ...workflow.get(), ...prev });
|
|
356
|
+
this.getLogger(workflow.id).info(`toggle OFF workflow ${workflow.id} based on configuration before updated`);
|
|
311
357
|
}
|
|
312
358
|
trigger.on(workflow);
|
|
359
|
+
this.getLogger(workflow.id).info(`toggle ON workflow ${workflow.id}`);
|
|
313
360
|
this.enabledCache.set(workflow.id, workflow);
|
|
314
361
|
} else {
|
|
315
362
|
trigger.off(workflow);
|
|
363
|
+
this.getLogger(workflow.id).info(`toggle OFF workflow ${workflow.id}`);
|
|
316
364
|
this.enabledCache.delete(workflow.id);
|
|
317
365
|
}
|
|
318
366
|
if (!silent) {
|
|
@@ -464,21 +512,20 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
464
512
|
throw err;
|
|
465
513
|
}
|
|
466
514
|
this.getLogger(workflow.id).info(`execution of workflow ${workflow.id} created as ${execution.id}`);
|
|
467
|
-
|
|
515
|
+
if (!workflow.stats) {
|
|
516
|
+
workflow.stats = await workflow.getStats({ transaction });
|
|
517
|
+
}
|
|
518
|
+
await workflow.stats.increment("executed", { transaction });
|
|
468
519
|
if (this.db.options.dialect !== "postgres") {
|
|
469
|
-
await workflow.reload({ transaction });
|
|
520
|
+
await workflow.stats.reload({ transaction });
|
|
521
|
+
}
|
|
522
|
+
if (!workflow.versionStats) {
|
|
523
|
+
workflow.versionStats = await workflow.getVersionStats({ transaction });
|
|
524
|
+
}
|
|
525
|
+
await workflow.versionStats.increment("executed", { transaction });
|
|
526
|
+
if (this.db.options.dialect !== "postgres") {
|
|
527
|
+
await workflow.versionStats.reload({ transaction });
|
|
470
528
|
}
|
|
471
|
-
await workflow.constructor.update(
|
|
472
|
-
{
|
|
473
|
-
allExecuted: workflow.allExecuted
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
where: {
|
|
477
|
-
key: workflow.key
|
|
478
|
-
},
|
|
479
|
-
transaction
|
|
480
|
-
}
|
|
481
|
-
);
|
|
482
529
|
if (!sameTransaction) {
|
|
483
530
|
await transaction.commit();
|
|
484
531
|
}
|
|
@@ -632,10 +679,16 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
632
679
|
/**
|
|
633
680
|
* @experimental
|
|
634
681
|
*/
|
|
635
|
-
async toggleTaskStatus(task,
|
|
682
|
+
async toggleTaskStatus(task, on, { transaction }) {
|
|
636
683
|
const { db } = this.app;
|
|
637
684
|
const repository = db.getRepository("workflowTasks");
|
|
638
|
-
if (
|
|
685
|
+
if (on) {
|
|
686
|
+
await repository.updateOrCreate({
|
|
687
|
+
filterKeys: ["key", "type"],
|
|
688
|
+
values: task,
|
|
689
|
+
transaction
|
|
690
|
+
});
|
|
691
|
+
} else {
|
|
639
692
|
await repository.destroy({
|
|
640
693
|
filter: {
|
|
641
694
|
type: task.type,
|
|
@@ -643,17 +696,12 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
643
696
|
},
|
|
644
697
|
transaction
|
|
645
698
|
});
|
|
646
|
-
} else {
|
|
647
|
-
await repository.updateOrCreate({
|
|
648
|
-
filterKeys: ["key", "type"],
|
|
649
|
-
values: task,
|
|
650
|
-
transaction
|
|
651
|
-
});
|
|
652
699
|
}
|
|
653
700
|
if (task.userId) {
|
|
654
701
|
const counts = await repository.countAll({
|
|
655
702
|
where: {
|
|
656
|
-
userId: task.userId
|
|
703
|
+
userId: task.userId,
|
|
704
|
+
workflowId: { [import_database.Op.ne]: null }
|
|
657
705
|
},
|
|
658
706
|
transaction
|
|
659
707
|
}) || [];
|
|
@@ -44,16 +44,9 @@ export default class Processor {
|
|
|
44
44
|
* @experimental
|
|
45
45
|
*/
|
|
46
46
|
nodesMap: Map<number, FlowNodeModel>;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
jobsMap: Map<number, JobModel>;
|
|
51
|
-
/**
|
|
52
|
-
* @experimental
|
|
53
|
-
*/
|
|
54
|
-
jobsMapByNodeKey: {
|
|
55
|
-
[key: string]: any;
|
|
56
|
-
};
|
|
47
|
+
private jobsMapByNodeKey;
|
|
48
|
+
private jobResultsMapByNodeKey;
|
|
49
|
+
private jobsToSave;
|
|
57
50
|
/**
|
|
58
51
|
* @experimental
|
|
59
52
|
*/
|
|
@@ -72,7 +65,7 @@ export default class Processor {
|
|
|
72
65
|
/**
|
|
73
66
|
* @experimental
|
|
74
67
|
*/
|
|
75
|
-
saveJob(payload: JobModel | Record<string, any>):
|
|
68
|
+
saveJob(payload: JobModel | Record<string, any>): JobModel;
|
|
76
69
|
/**
|
|
77
70
|
* @experimental
|
|
78
71
|
*/
|