@nocobase/plugin-async-task-manager 1.7.0-beta.32 → 1.7.0-beta.33

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 (29) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/externalVersion.js +4 -4
  3. package/dist/locale/en-US.json +2 -1
  4. package/dist/locale/zh-CN.json +1 -1
  5. package/dist/node_modules/p-queue/dist/index.d.ts +101 -0
  6. package/dist/node_modules/p-queue/dist/index.js +1 -0
  7. package/dist/node_modules/p-queue/dist/lower-bound.d.ts +1 -0
  8. package/dist/node_modules/p-queue/dist/lower-bound.js +21 -0
  9. package/dist/node_modules/p-queue/dist/options.d.ts +64 -0
  10. package/dist/node_modules/p-queue/dist/options.js +2 -0
  11. package/dist/node_modules/p-queue/dist/priority-queue.d.ts +12 -0
  12. package/dist/node_modules/p-queue/dist/priority-queue.js +32 -0
  13. package/dist/node_modules/p-queue/dist/queue.d.ts +7 -0
  14. package/dist/node_modules/p-queue/dist/queue.js +2 -0
  15. package/dist/node_modules/p-queue/license +9 -0
  16. package/dist/node_modules/p-queue/node_modules/eventemitter3/index.d.ts +134 -0
  17. package/dist/node_modules/p-queue/node_modules/eventemitter3/index.js +336 -0
  18. package/dist/node_modules/p-queue/node_modules/eventemitter3/package.json +56 -0
  19. package/dist/node_modules/p-queue/node_modules/eventemitter3/umd/eventemitter3.js +340 -0
  20. package/dist/node_modules/p-queue/node_modules/eventemitter3/umd/eventemitter3.min.js +1 -0
  21. package/dist/node_modules/p-queue/package.json +1 -0
  22. package/dist/node_modules/uuid/package.json +1 -1
  23. package/dist/server/base-task-manager.d.ts +14 -0
  24. package/dist/server/base-task-manager.js +64 -0
  25. package/dist/server/interfaces/async-task-manager.d.ts +11 -0
  26. package/dist/server/interfaces/task.d.ts +9 -0
  27. package/dist/server/task-type.d.ts +1 -0
  28. package/dist/server/task-type.js +7 -4
  29. package/package.json +5 -2
@@ -0,0 +1,340 @@
1
+ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.EventEmitter3 = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2
+ 'use strict';
3
+
4
+ var has = Object.prototype.hasOwnProperty
5
+ , prefix = '~';
6
+
7
+ /**
8
+ * Constructor to create a storage for our `EE` objects.
9
+ * An `Events` instance is a plain object whose properties are event names.
10
+ *
11
+ * @constructor
12
+ * @private
13
+ */
14
+ function Events() {}
15
+
16
+ //
17
+ // We try to not inherit from `Object.prototype`. In some engines creating an
18
+ // instance in this way is faster than calling `Object.create(null)` directly.
19
+ // If `Object.create(null)` is not supported we prefix the event names with a
20
+ // character to make sure that the built-in object properties are not
21
+ // overridden or used as an attack vector.
22
+ //
23
+ if (Object.create) {
24
+ Events.prototype = Object.create(null);
25
+
26
+ //
27
+ // This hack is needed because the `__proto__` property is still inherited in
28
+ // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
29
+ //
30
+ if (!new Events().__proto__) prefix = false;
31
+ }
32
+
33
+ /**
34
+ * Representation of a single event listener.
35
+ *
36
+ * @param {Function} fn The listener function.
37
+ * @param {*} context The context to invoke the listener with.
38
+ * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
39
+ * @constructor
40
+ * @private
41
+ */
42
+ function EE(fn, context, once) {
43
+ this.fn = fn;
44
+ this.context = context;
45
+ this.once = once || false;
46
+ }
47
+
48
+ /**
49
+ * Add a listener for a given event.
50
+ *
51
+ * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
52
+ * @param {(String|Symbol)} event The event name.
53
+ * @param {Function} fn The listener function.
54
+ * @param {*} context The context to invoke the listener with.
55
+ * @param {Boolean} once Specify if the listener is a one-time listener.
56
+ * @returns {EventEmitter}
57
+ * @private
58
+ */
59
+ function addListener(emitter, event, fn, context, once) {
60
+ if (typeof fn !== 'function') {
61
+ throw new TypeError('The listener must be a function');
62
+ }
63
+
64
+ var listener = new EE(fn, context || emitter, once)
65
+ , evt = prefix ? prefix + event : event;
66
+
67
+ if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
68
+ else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
69
+ else emitter._events[evt] = [emitter._events[evt], listener];
70
+
71
+ return emitter;
72
+ }
73
+
74
+ /**
75
+ * Clear event by name.
76
+ *
77
+ * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
78
+ * @param {(String|Symbol)} evt The Event name.
79
+ * @private
80
+ */
81
+ function clearEvent(emitter, evt) {
82
+ if (--emitter._eventsCount === 0) emitter._events = new Events();
83
+ else delete emitter._events[evt];
84
+ }
85
+
86
+ /**
87
+ * Minimal `EventEmitter` interface that is molded against the Node.js
88
+ * `EventEmitter` interface.
89
+ *
90
+ * @constructor
91
+ * @public
92
+ */
93
+ function EventEmitter() {
94
+ this._events = new Events();
95
+ this._eventsCount = 0;
96
+ }
97
+
98
+ /**
99
+ * Return an array listing the events for which the emitter has registered
100
+ * listeners.
101
+ *
102
+ * @returns {Array}
103
+ * @public
104
+ */
105
+ EventEmitter.prototype.eventNames = function eventNames() {
106
+ var names = []
107
+ , events
108
+ , name;
109
+
110
+ if (this._eventsCount === 0) return names;
111
+
112
+ for (name in (events = this._events)) {
113
+ if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
114
+ }
115
+
116
+ if (Object.getOwnPropertySymbols) {
117
+ return names.concat(Object.getOwnPropertySymbols(events));
118
+ }
119
+
120
+ return names;
121
+ };
122
+
123
+ /**
124
+ * Return the listeners registered for a given event.
125
+ *
126
+ * @param {(String|Symbol)} event The event name.
127
+ * @returns {Array} The registered listeners.
128
+ * @public
129
+ */
130
+ EventEmitter.prototype.listeners = function listeners(event) {
131
+ var evt = prefix ? prefix + event : event
132
+ , handlers = this._events[evt];
133
+
134
+ if (!handlers) return [];
135
+ if (handlers.fn) return [handlers.fn];
136
+
137
+ for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
138
+ ee[i] = handlers[i].fn;
139
+ }
140
+
141
+ return ee;
142
+ };
143
+
144
+ /**
145
+ * Return the number of listeners listening to a given event.
146
+ *
147
+ * @param {(String|Symbol)} event The event name.
148
+ * @returns {Number} The number of listeners.
149
+ * @public
150
+ */
151
+ EventEmitter.prototype.listenerCount = function listenerCount(event) {
152
+ var evt = prefix ? prefix + event : event
153
+ , listeners = this._events[evt];
154
+
155
+ if (!listeners) return 0;
156
+ if (listeners.fn) return 1;
157
+ return listeners.length;
158
+ };
159
+
160
+ /**
161
+ * Calls each of the listeners registered for a given event.
162
+ *
163
+ * @param {(String|Symbol)} event The event name.
164
+ * @returns {Boolean} `true` if the event had listeners, else `false`.
165
+ * @public
166
+ */
167
+ EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
168
+ var evt = prefix ? prefix + event : event;
169
+
170
+ if (!this._events[evt]) return false;
171
+
172
+ var listeners = this._events[evt]
173
+ , len = arguments.length
174
+ , args
175
+ , i;
176
+
177
+ if (listeners.fn) {
178
+ if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
179
+
180
+ switch (len) {
181
+ case 1: return listeners.fn.call(listeners.context), true;
182
+ case 2: return listeners.fn.call(listeners.context, a1), true;
183
+ case 3: return listeners.fn.call(listeners.context, a1, a2), true;
184
+ case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
185
+ case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
186
+ case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
187
+ }
188
+
189
+ for (i = 1, args = new Array(len -1); i < len; i++) {
190
+ args[i - 1] = arguments[i];
191
+ }
192
+
193
+ listeners.fn.apply(listeners.context, args);
194
+ } else {
195
+ var length = listeners.length
196
+ , j;
197
+
198
+ for (i = 0; i < length; i++) {
199
+ if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
200
+
201
+ switch (len) {
202
+ case 1: listeners[i].fn.call(listeners[i].context); break;
203
+ case 2: listeners[i].fn.call(listeners[i].context, a1); break;
204
+ case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
205
+ case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
206
+ default:
207
+ if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
208
+ args[j - 1] = arguments[j];
209
+ }
210
+
211
+ listeners[i].fn.apply(listeners[i].context, args);
212
+ }
213
+ }
214
+ }
215
+
216
+ return true;
217
+ };
218
+
219
+ /**
220
+ * Add a listener for a given event.
221
+ *
222
+ * @param {(String|Symbol)} event The event name.
223
+ * @param {Function} fn The listener function.
224
+ * @param {*} [context=this] The context to invoke the listener with.
225
+ * @returns {EventEmitter} `this`.
226
+ * @public
227
+ */
228
+ EventEmitter.prototype.on = function on(event, fn, context) {
229
+ return addListener(this, event, fn, context, false);
230
+ };
231
+
232
+ /**
233
+ * Add a one-time listener for a given event.
234
+ *
235
+ * @param {(String|Symbol)} event The event name.
236
+ * @param {Function} fn The listener function.
237
+ * @param {*} [context=this] The context to invoke the listener with.
238
+ * @returns {EventEmitter} `this`.
239
+ * @public
240
+ */
241
+ EventEmitter.prototype.once = function once(event, fn, context) {
242
+ return addListener(this, event, fn, context, true);
243
+ };
244
+
245
+ /**
246
+ * Remove the listeners of a given event.
247
+ *
248
+ * @param {(String|Symbol)} event The event name.
249
+ * @param {Function} fn Only remove the listeners that match this function.
250
+ * @param {*} context Only remove the listeners that have this context.
251
+ * @param {Boolean} once Only remove one-time listeners.
252
+ * @returns {EventEmitter} `this`.
253
+ * @public
254
+ */
255
+ EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
256
+ var evt = prefix ? prefix + event : event;
257
+
258
+ if (!this._events[evt]) return this;
259
+ if (!fn) {
260
+ clearEvent(this, evt);
261
+ return this;
262
+ }
263
+
264
+ var listeners = this._events[evt];
265
+
266
+ if (listeners.fn) {
267
+ if (
268
+ listeners.fn === fn &&
269
+ (!once || listeners.once) &&
270
+ (!context || listeners.context === context)
271
+ ) {
272
+ clearEvent(this, evt);
273
+ }
274
+ } else {
275
+ for (var i = 0, events = [], length = listeners.length; i < length; i++) {
276
+ if (
277
+ listeners[i].fn !== fn ||
278
+ (once && !listeners[i].once) ||
279
+ (context && listeners[i].context !== context)
280
+ ) {
281
+ events.push(listeners[i]);
282
+ }
283
+ }
284
+
285
+ //
286
+ // Reset the array, or remove it completely if we have no more listeners.
287
+ //
288
+ if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
289
+ else clearEvent(this, evt);
290
+ }
291
+
292
+ return this;
293
+ };
294
+
295
+ /**
296
+ * Remove all listeners, or those of the specified event.
297
+ *
298
+ * @param {(String|Symbol)} [event] The event name.
299
+ * @returns {EventEmitter} `this`.
300
+ * @public
301
+ */
302
+ EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
303
+ var evt;
304
+
305
+ if (event) {
306
+ evt = prefix ? prefix + event : event;
307
+ if (this._events[evt]) clearEvent(this, evt);
308
+ } else {
309
+ this._events = new Events();
310
+ this._eventsCount = 0;
311
+ }
312
+
313
+ return this;
314
+ };
315
+
316
+ //
317
+ // Alias methods names because people roll like that.
318
+ //
319
+ EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
320
+ EventEmitter.prototype.addListener = EventEmitter.prototype.on;
321
+
322
+ //
323
+ // Expose the prefix.
324
+ //
325
+ EventEmitter.prefixed = prefix;
326
+
327
+ //
328
+ // Allow `EventEmitter` to be imported as module namespace.
329
+ //
330
+ EventEmitter.EventEmitter = EventEmitter;
331
+
332
+ //
333
+ // Expose the module.
334
+ //
335
+ if ('undefined' !== typeof module) {
336
+ module.exports = EventEmitter;
337
+ }
338
+
339
+ },{}]},{},[1])(1)
340
+ });
@@ -0,0 +1 @@
1
+ !function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).EventEmitter3=e()}(function(){return function i(s,f,c){function u(t,e){if(!f[t]){if(!s[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(a)return a(t,!0);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}var o=f[t]={exports:{}};s[t][0].call(o.exports,function(e){return u(s[t][1][e]||e)},o,o.exports,i,s,f,c)}return f[t].exports}for(var a="function"==typeof require&&require,e=0;e<c.length;e++)u(c[e]);return u}({1:[function(e,t,n){"use strict";var r=Object.prototype.hasOwnProperty,v="~";function o(){}function f(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,n,r,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var i=new f(n,r||e,o),s=v?v+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],i]:e._events[s].push(i):(e._events[s]=i,e._eventsCount++),e}function u(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function s(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(v=!1)),s.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)r.call(e,t)&&n.push(v?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},s.prototype.listeners=function(e){var t=v?v+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,o=n.length,i=new Array(o);r<o;r++)i[r]=n[r].fn;return i},s.prototype.listenerCount=function(e){var t=v?v+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,r,o,i){var s=v?v+e:e;if(!this._events[s])return!1;var f,c=this._events[s],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,i),!0}for(p=1,f=new Array(u-1);p<u;p++)f[p-1]=arguments[p];c.fn.apply(c.context,f)}else for(var a,l=c.length,p=0;p<l;p++)switch(c[p].once&&this.removeListener(e,c[p].fn,void 0,!0),u){case 1:c[p].fn.call(c[p].context);break;case 2:c[p].fn.call(c[p].context,t);break;case 3:c[p].fn.call(c[p].context,t,n);break;case 4:c[p].fn.call(c[p].context,t,n,r);break;default:if(!f)for(a=1,f=new Array(u-1);a<u;a++)f[a-1]=arguments[a];c[p].fn.apply(c[p].context,f)}return!0},s.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,n,r){var o=v?v+e:e;if(!this._events[o])return this;if(!t)return u(this,o),this;var i=this._events[o];if(i.fn)i.fn!==t||r&&!i.once||n&&i.context!==n||u(this,o);else{for(var s=0,f=[],c=i.length;s<c;s++)(i[s].fn!==t||r&&!i[s].once||n&&i[s].context!==n)&&f.push(i[s]);f.length?this._events[o]=1===f.length?f[0]:f:u(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=v?v+e:e,this._events[t]&&u(this,t)):(this._events=new o,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=v,s.EventEmitter=s,void 0!==t&&(t.exports=s)},{}]},{},[1])(1)});
@@ -0,0 +1 @@
1
+ {"name":"p-queue","version":"6.6.2","description":"Promise queue with concurrency control","license":"MIT","repository":"sindresorhus/p-queue","funding":"https://github.com/sponsors/sindresorhus","main":"dist/index.js","engines":{"node":">=8"},"scripts":{"build":"del dist && tsc","test":"xo && npm run build && nyc ava","bench":"ts-node bench.ts","prepublishOnly":"npm run build"},"files":["dist"],"types":"dist/index.d.ts","keywords":["promise","queue","enqueue","limit","limited","concurrency","throttle","throat","rate","batch","ratelimit","priority","priorityqueue","fifo","job","task","async","await","promises","bluebird"],"dependencies":{"eventemitter3":"^4.0.4","p-timeout":"^3.2.0"},"devDependencies":{"@sindresorhus/tsconfig":"^0.7.0","@types/benchmark":"^1.0.33","@types/node":"^14.6.0","ava":"^2.0.0","benchmark":"^2.1.4","codecov":"^3.7.2","del-cli":"^3.0.1","delay":"^4.4.0","in-range":"^2.0.0","nyc":"^15.1.0","random-int":"^2.0.1","time-span":"^4.0.0","ts-node":"^9.0.0","typescript":"^4.0.2","xo":"^0.33.0"},"ava":{"babel":false,"compileEnhancements":false,"extensions":["ts"],"require":["ts-node/register"],"files":["test/**"]},"xo":{"rules":{"@typescript-eslint/member-ordering":"off","node/no-unsupported-features/es-syntax":"off","@typescript-eslint/no-floating-promises":"off","import/no-named-default":"off","@typescript-eslint/no-invalid-void-type":"off"}},"nyc":{"extension":[".ts"]},"_lastModified":"2025-05-24T12:28:14.579Z"}
@@ -1 +1 @@
1
- {"name":"uuid","version":"9.0.1","description":"RFC4122 (v1, v4, and v5) UUIDs","funding":["https://github.com/sponsors/broofa","https://github.com/sponsors/ctavan"],"commitlint":{"extends":["@commitlint/config-conventional"]},"keywords":["uuid","guid","rfc4122"],"license":"MIT","bin":{"uuid":"./dist/bin/uuid"},"sideEffects":false,"main":"./dist/index.js","exports":{".":{"node":{"module":"./dist/esm-node/index.js","require":"./dist/index.js","import":"./wrapper.mjs"},"browser":{"import":"./dist/esm-browser/index.js","require":"./dist/commonjs-browser/index.js"},"default":"./dist/esm-browser/index.js"},"./package.json":"./package.json"},"module":"./dist/esm-node/index.js","browser":{"./dist/md5.js":"./dist/md5-browser.js","./dist/native.js":"./dist/native-browser.js","./dist/rng.js":"./dist/rng-browser.js","./dist/sha1.js":"./dist/sha1-browser.js","./dist/esm-node/index.js":"./dist/esm-browser/index.js"},"files":["CHANGELOG.md","CONTRIBUTING.md","LICENSE.md","README.md","dist","wrapper.mjs"],"devDependencies":{"@babel/cli":"7.18.10","@babel/core":"7.18.10","@babel/eslint-parser":"7.18.9","@babel/preset-env":"7.18.10","@commitlint/cli":"17.0.3","@commitlint/config-conventional":"17.0.3","bundlewatch":"0.3.3","eslint":"8.21.0","eslint-config-prettier":"8.5.0","eslint-config-standard":"17.0.0","eslint-plugin-import":"2.26.0","eslint-plugin-node":"11.1.0","eslint-plugin-prettier":"4.2.1","eslint-plugin-promise":"6.0.0","husky":"8.0.1","jest":"28.1.3","lint-staged":"13.0.3","npm-run-all":"4.1.5","optional-dev-dependency":"2.0.1","prettier":"2.7.1","random-seed":"0.3.0","runmd":"1.3.9","standard-version":"9.5.0"},"optionalDevDependencies":{"@wdio/browserstack-service":"7.16.10","@wdio/cli":"7.16.10","@wdio/jasmine-framework":"7.16.6","@wdio/local-runner":"7.16.10","@wdio/spec-reporter":"7.16.9","@wdio/static-server-service":"7.16.6"},"scripts":{"examples:browser:webpack:build":"cd examples/browser-webpack && npm install && npm run build","examples:browser:rollup:build":"cd examples/browser-rollup && npm install && npm run build","examples:node:commonjs:test":"cd examples/node-commonjs && npm install && npm test","examples:node:esmodules:test":"cd examples/node-esmodules && npm install && npm test","examples:node:jest:test":"cd examples/node-jest && npm install && npm test","prepare":"cd $( git rev-parse --show-toplevel ) && husky install","lint":"npm run eslint:check && npm run prettier:check","eslint:check":"eslint src/ test/ examples/ *.js","eslint:fix":"eslint --fix src/ test/ examples/ *.js","pretest":"[ -n $CI ] || npm run build","test":"BABEL_ENV=commonjsNode node --throw-deprecation node_modules/.bin/jest test/unit/","pretest:browser":"optional-dev-dependency && npm run build && npm-run-all --parallel examples:browser:**","test:browser":"wdio run ./wdio.conf.js","pretest:node":"npm run build","test:node":"npm-run-all --parallel examples:node:**","test:pack":"./scripts/testpack.sh","pretest:benchmark":"npm run build","test:benchmark":"cd examples/benchmark && npm install && npm test","prettier:check":"prettier --check '**/*.{js,jsx,json,md}'","prettier:fix":"prettier --write '**/*.{js,jsx,json,md}'","bundlewatch":"npm run pretest:browser && bundlewatch --config bundlewatch.config.json","md":"runmd --watch --output=README.md README_js.md","docs":"( node --version | grep -q 'v18' ) && ( npm run build && npx runmd --output=README.md README_js.md )","docs:diff":"npm run docs && git diff --quiet README.md","build":"./scripts/build.sh","prepack":"npm run build","release":"standard-version --no-verify"},"repository":{"type":"git","url":"https://github.com/uuidjs/uuid.git"},"lint-staged":{"*.{js,jsx,json,md}":["prettier --write"],"*.{js,jsx}":["eslint --fix"]},"standard-version":{"scripts":{"postchangelog":"prettier --write CHANGELOG.md"}},"_lastModified":"2025-05-19T03:22:47.830Z"}
1
+ {"name":"uuid","version":"9.0.1","description":"RFC4122 (v1, v4, and v5) UUIDs","funding":["https://github.com/sponsors/broofa","https://github.com/sponsors/ctavan"],"commitlint":{"extends":["@commitlint/config-conventional"]},"keywords":["uuid","guid","rfc4122"],"license":"MIT","bin":{"uuid":"./dist/bin/uuid"},"sideEffects":false,"main":"./dist/index.js","exports":{".":{"node":{"module":"./dist/esm-node/index.js","require":"./dist/index.js","import":"./wrapper.mjs"},"browser":{"import":"./dist/esm-browser/index.js","require":"./dist/commonjs-browser/index.js"},"default":"./dist/esm-browser/index.js"},"./package.json":"./package.json"},"module":"./dist/esm-node/index.js","browser":{"./dist/md5.js":"./dist/md5-browser.js","./dist/native.js":"./dist/native-browser.js","./dist/rng.js":"./dist/rng-browser.js","./dist/sha1.js":"./dist/sha1-browser.js","./dist/esm-node/index.js":"./dist/esm-browser/index.js"},"files":["CHANGELOG.md","CONTRIBUTING.md","LICENSE.md","README.md","dist","wrapper.mjs"],"devDependencies":{"@babel/cli":"7.18.10","@babel/core":"7.18.10","@babel/eslint-parser":"7.18.9","@babel/preset-env":"7.18.10","@commitlint/cli":"17.0.3","@commitlint/config-conventional":"17.0.3","bundlewatch":"0.3.3","eslint":"8.21.0","eslint-config-prettier":"8.5.0","eslint-config-standard":"17.0.0","eslint-plugin-import":"2.26.0","eslint-plugin-node":"11.1.0","eslint-plugin-prettier":"4.2.1","eslint-plugin-promise":"6.0.0","husky":"8.0.1","jest":"28.1.3","lint-staged":"13.0.3","npm-run-all":"4.1.5","optional-dev-dependency":"2.0.1","prettier":"2.7.1","random-seed":"0.3.0","runmd":"1.3.9","standard-version":"9.5.0"},"optionalDevDependencies":{"@wdio/browserstack-service":"7.16.10","@wdio/cli":"7.16.10","@wdio/jasmine-framework":"7.16.6","@wdio/local-runner":"7.16.10","@wdio/spec-reporter":"7.16.9","@wdio/static-server-service":"7.16.6"},"scripts":{"examples:browser:webpack:build":"cd examples/browser-webpack && npm install && npm run build","examples:browser:rollup:build":"cd examples/browser-rollup && npm install && npm run build","examples:node:commonjs:test":"cd examples/node-commonjs && npm install && npm test","examples:node:esmodules:test":"cd examples/node-esmodules && npm install && npm test","examples:node:jest:test":"cd examples/node-jest && npm install && npm test","prepare":"cd $( git rev-parse --show-toplevel ) && husky install","lint":"npm run eslint:check && npm run prettier:check","eslint:check":"eslint src/ test/ examples/ *.js","eslint:fix":"eslint --fix src/ test/ examples/ *.js","pretest":"[ -n $CI ] || npm run build","test":"BABEL_ENV=commonjsNode node --throw-deprecation node_modules/.bin/jest test/unit/","pretest:browser":"optional-dev-dependency && npm run build && npm-run-all --parallel examples:browser:**","test:browser":"wdio run ./wdio.conf.js","pretest:node":"npm run build","test:node":"npm-run-all --parallel examples:node:**","test:pack":"./scripts/testpack.sh","pretest:benchmark":"npm run build","test:benchmark":"cd examples/benchmark && npm install && npm test","prettier:check":"prettier --check '**/*.{js,jsx,json,md}'","prettier:fix":"prettier --write '**/*.{js,jsx,json,md}'","bundlewatch":"npm run pretest:browser && bundlewatch --config bundlewatch.config.json","md":"runmd --watch --output=README.md README_js.md","docs":"( node --version | grep -q 'v18' ) && ( npm run build && npx runmd --output=README.md README_js.md )","docs:diff":"npm run docs && git diff --quiet README.md","build":"./scripts/build.sh","prepack":"npm run build","release":"standard-version --no-verify"},"repository":{"type":"git","url":"https://github.com/uuidjs/uuid.git"},"lint-staged":{"*.{js,jsx,json,md}":["prettier --write"],"*.{js,jsx}":["eslint --fix"]},"standard-version":{"scripts":{"postchangelog":"prettier --write CHANGELOG.md"}},"_lastModified":"2025-05-24T12:28:14.744Z"}
@@ -1,3 +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
+ */
1
9
  /// <reference types="node" />
2
10
  import { EventEmitter } from 'events';
3
11
  import { AsyncTasksManager, CreateTaskOptions, TaskId, TaskStatus } from './interfaces/async-task-manager';
@@ -10,12 +18,18 @@ export declare class BaseTaskManager extends EventEmitter implements AsyncTasksM
10
18
  private readonly cleanupDelay;
11
19
  private logger;
12
20
  private app;
21
+ queue: any;
22
+ private queueOptions;
13
23
  setLogger(logger: Logger): void;
14
24
  setApp(app: Application): void;
15
25
  private scheduleCleanup;
16
26
  constructor();
27
+ private enqueueTask;
28
+ pauseQueue(): void;
29
+ resumeQueue(): void;
17
30
  cancelTask(taskId: TaskId): Promise<boolean>;
18
31
  createTask<T>(options: CreateTaskOptions): ITask;
32
+ runTask(taskId: TaskId): void;
19
33
  getTask(taskId: TaskId): ITask | undefined;
20
34
  getTaskStatus(taskId: TaskId): Promise<TaskStatus>;
21
35
  registerTaskType(taskType: TaskConstructor): void;
@@ -7,9 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
+ var __create = Object.create;
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
13
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
16
  var __export = (target, all) => {
15
17
  for (var name in all)
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
23
25
  }
24
26
  return to;
25
27
  };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
26
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
37
  var base_task_manager_exports = {};
28
38
  __export(base_task_manager_exports, {
@@ -30,6 +40,7 @@ __export(base_task_manager_exports, {
30
40
  });
31
41
  module.exports = __toCommonJS(base_task_manager_exports);
32
42
  var import_events = require("events");
43
+ var import_p_queue = __toESM(require("p-queue"));
33
44
  class BaseTaskManager extends import_events.EventEmitter {
34
45
  taskTypes = /* @__PURE__ */ new Map();
35
46
  tasks = /* @__PURE__ */ new Map();
@@ -37,6 +48,8 @@ class BaseTaskManager extends import_events.EventEmitter {
37
48
  cleanupDelay = 30 * 60 * 1e3;
38
49
  logger;
39
50
  app;
51
+ queue;
52
+ queueOptions;
40
53
  setLogger(logger) {
41
54
  this.logger = logger;
42
55
  }
@@ -51,6 +64,42 @@ class BaseTaskManager extends import_events.EventEmitter {
51
64
  }
52
65
  constructor() {
53
66
  super();
67
+ this.queueOptions = {
68
+ concurrency: process.env.ASYNC_TASK_MAX_CONCURRENCY ? parseInt(process.env.ASYNC_TASK_MAX_CONCURRENCY) : 3,
69
+ autoStart: true
70
+ };
71
+ this.queue = new import_p_queue.default(this.queueOptions);
72
+ this.queue.on("idle", () => {
73
+ this.logger.debug("Task queue is idle");
74
+ this.emit("queueIdle");
75
+ });
76
+ this.queue.on("add", () => {
77
+ this.logger.debug(`Task added to queue. Size: ${this.queue.size}, Pending: ${this.queue.pending}`);
78
+ this.emit("queueAdd", { size: this.queue.size, pending: this.queue.pending });
79
+ });
80
+ }
81
+ enqueueTask(task) {
82
+ const taskHandler = async () => {
83
+ if (task.status.type === "pending") {
84
+ try {
85
+ this.logger.debug(`Starting execution of task ${task.taskId} from queue`);
86
+ await task.run();
87
+ } catch (error) {
88
+ this.logger.error(`Error executing task ${task.taskId} from queue: ${error.message}`);
89
+ }
90
+ }
91
+ };
92
+ this.queue.add(taskHandler);
93
+ }
94
+ pauseQueue() {
95
+ this.logger.info("Pausing task queue");
96
+ this.queue.pause();
97
+ this.emit("queuePaused");
98
+ }
99
+ resumeQueue() {
100
+ this.logger.info("Resuming task queue");
101
+ this.queue.start();
102
+ this.emit("queueResumed");
54
103
  }
55
104
  async cancelTask(taskId) {
56
105
  const task = this.tasks.get(taskId);
@@ -59,6 +108,10 @@ class BaseTaskManager extends import_events.EventEmitter {
59
108
  return false;
60
109
  }
61
110
  this.logger.info(`Cancelling task ${taskId}, type: ${task.constructor.name}, tags: ${JSON.stringify(task.tags)}`);
111
+ if (task.status.type === "pending") {
112
+ await task.statusChange({ type: "cancelled" });
113
+ return true;
114
+ }
62
115
  return task.cancel();
63
116
  }
64
117
  createTask(options) {
@@ -96,8 +149,19 @@ class BaseTaskManager extends import_events.EventEmitter {
96
149
  }
97
150
  this.emit("taskStatusChange", { task, status });
98
151
  });
152
+ if (options.immediateExecute !== false) {
153
+ this.enqueueTask(task);
154
+ }
99
155
  return task;
100
156
  }
157
+ runTask(taskId) {
158
+ const task = this.tasks.get(taskId);
159
+ if (task) {
160
+ this.enqueueTask(task);
161
+ } else {
162
+ this.logger.warn(`Attempted to enqueue non-existent task ${taskId}`);
163
+ }
164
+ }
101
165
  getTask(taskId) {
102
166
  const task = this.tasks.get(taskId);
103
167
  if (!task) {
@@ -1,3 +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
+ */
1
9
  /// <reference types="node" />
2
10
  import { Logger } from '@nocobase/logger';
3
11
  import { ITask, TaskConstructor } from './task';
@@ -14,6 +22,7 @@ export interface CreateTaskOptions {
14
22
  dataSource: string;
15
23
  };
16
24
  context?: any;
25
+ immediateExecute: boolean;
17
26
  }
18
27
  export type TaskId = string;
19
28
  export type TaskStatus = PendingStatus | SuccessStatus<any> | RunningStatus | FailedStatus | CancelledStatus;
@@ -44,6 +53,7 @@ export interface CancelledStatus {
44
53
  type: 'cancelled';
45
54
  }
46
55
  export interface AsyncTasksManager extends EventEmitter {
56
+ queue: any;
47
57
  setLogger(logger: Logger): void;
48
58
  setApp(app: Application): void;
49
59
  registerTaskType(taskType: TaskConstructor): void;
@@ -52,6 +62,7 @@ export interface AsyncTasksManager extends EventEmitter {
52
62
  cancelTask(taskId: TaskId): Promise<boolean>;
53
63
  getTaskStatus(taskId: TaskId): Promise<TaskStatus>;
54
64
  getTask(taskId: TaskId): ITask | undefined;
65
+ runTask(taskId: TaskId): void;
55
66
  }
56
67
  export declare class CancelError extends Error {
57
68
  constructor(message?: string);
@@ -1,3 +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
+ */
1
9
  /// <reference types="node" />
2
10
  import { Logger } from '@nocobase/logger';
3
11
  import { TaskStatus } from './async-task-manager';
@@ -21,6 +29,7 @@ export interface ITask extends EventEmitter {
21
29
  setApp(app: Application): void;
22
30
  setContext(context: any): void;
23
31
  cancel(): Promise<boolean>;
32
+ statusChange: (status: TaskStatus) => Promise<void>;
24
33
  execute(): Promise<any>;
25
34
  reportProgress(progress: {
26
35
  total: number;
@@ -41,6 +41,7 @@ export declare abstract class TaskType extends EventEmitter implements ITask {
41
41
  * Cancel the task
42
42
  */
43
43
  cancel(): Promise<boolean>;
44
+ statusChange(status: TaskStatus): Promise<void>;
44
45
  /**
45
46
  * Execute the task implementation
46
47
  * @returns Promise that resolves with the task result
@@ -96,6 +96,10 @@ class TaskType extends import_events.default {
96
96
  (_a = this.logger) == null ? void 0 : _a.debug(`Task ${this.taskId} cancelled`);
97
97
  return true;
98
98
  }
99
+ async statusChange(status) {
100
+ this.status = status;
101
+ this.emit("statusChange", this.status);
102
+ }
99
103
  /**
100
104
  * Report task progress
101
105
  * @param progress Progress information containing total and current values
@@ -143,10 +147,9 @@ class TaskType extends import_events.default {
143
147
  this.emit("statusChange", this.status);
144
148
  } catch (error) {
145
149
  if (error instanceof import_async_task_manager.CancelError) {
146
- this.status = {
147
- type: "cancelled"
148
- };
150
+ this.statusChange({ type: "cancelled" });
149
151
  (_d = this.logger) == null ? void 0 : _d.info(`Task ${this.taskId} was cancelled during execution`);
152
+ return;
150
153
  } else {
151
154
  this.status = {
152
155
  type: "failed",
@@ -154,8 +157,8 @@ class TaskType extends import_events.default {
154
157
  errors: [{ message: this.renderErrorMessage(error) }]
155
158
  };
156
159
  (_e = this.logger) == null ? void 0 : _e.error(`Task ${this.taskId} failed with error: ${error.message}`);
160
+ this.emit("statusChange", this.status);
157
161
  }
158
- this.emit("statusChange", this.status);
159
162
  } finally {
160
163
  this.fulfilledAt = /* @__PURE__ */ new Date();
161
164
  const duration = this.fulfilledAt.getTime() - this.startedAt.getTime();
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "异步任务管理器",
5
5
  "description": "Manage and monitor asynchronous tasks such as data import/export. Support task progress tracking and notification.",
6
6
  "description.zh-CN": "管理和监控数据导入导出等异步任务。支持任务进度跟踪和通知。",
7
- "version": "1.7.0-beta.32",
7
+ "version": "1.7.0-beta.33",
8
8
  "main": "dist/server/index.js",
9
9
  "peerDependencies": {
10
10
  "@nocobase/client": "1.x",
@@ -12,5 +12,8 @@
12
12
  "@nocobase/server": "1.x",
13
13
  "@nocobase/test": "1.x"
14
14
  },
15
- "gitHead": "d78ca2740143209c6a16002e0c36e3256ed5fd88"
15
+ "dependencies": {
16
+ "p-queue": "^6.6.2"
17
+ },
18
+ "gitHead": "6fede035f813a48250c3e94e755618ea54be61c3"
16
19
  }