@webda/async 4.0.0-beta.1 → 4.0.0-beta.2

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 (38) hide show
  1. package/lib/index.d.ts +1 -0
  2. package/lib/index.d.ts.map +1 -0
  3. package/lib/models.d.ts +3 -7
  4. package/lib/models.d.ts.map +1 -0
  5. package/lib/models.js +3 -1
  6. package/lib/models.js.map +1 -1
  7. package/lib/models.spec.d.ts +7 -0
  8. package/lib/models.spec.d.ts.map +1 -0
  9. package/lib/models.spec.js +64 -0
  10. package/lib/models.spec.js.map +1 -0
  11. package/lib/services/asyncjobservice.d.ts +3 -15
  12. package/lib/services/asyncjobservice.d.ts.map +1 -0
  13. package/lib/services/asyncjobservice.js +13 -49
  14. package/lib/services/asyncjobservice.js.map +1 -1
  15. package/lib/services/asyncjobservice.spec.d.ts +2 -0
  16. package/lib/services/asyncjobservice.spec.d.ts.map +1 -0
  17. package/lib/services/asyncjobservice.spec.js +561 -0
  18. package/lib/services/asyncjobservice.spec.js.map +1 -0
  19. package/lib/services/localrunner.d.ts +1 -0
  20. package/lib/services/localrunner.d.ts.map +1 -0
  21. package/lib/services/localrunner.js +1 -1
  22. package/lib/services/localrunner.js.map +1 -1
  23. package/lib/services/localrunner.spec.d.ts +2 -0
  24. package/lib/services/localrunner.spec.d.ts.map +1 -0
  25. package/lib/services/localrunner.spec.js +113 -0
  26. package/lib/services/localrunner.spec.js.map +1 -0
  27. package/lib/services/runner.d.ts +1 -0
  28. package/lib/services/runner.d.ts.map +1 -0
  29. package/lib/services/servicerunner.d.ts +1 -0
  30. package/lib/services/servicerunner.d.ts.map +1 -0
  31. package/lib/services/servicerunner.js +1 -1
  32. package/lib/services/servicerunner.js.map +1 -1
  33. package/lib/services/servicerunner.spec.d.ts +2 -0
  34. package/lib/services/servicerunner.spec.d.ts.map +1 -0
  35. package/lib/services/servicerunner.spec.js +111 -0
  36. package/lib/services/servicerunner.spec.js.map +1 -0
  37. package/package.json +19 -13
  38. package/webda.module.json +24 -21
@@ -0,0 +1,113 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { suite, test } from "@testdeck/mocha";
8
+ import { WebdaTest } from "@webda/core/lib/test.js";
9
+ import * as assert from "assert";
10
+ import { EventEmitter } from "events";
11
+ import { nextTick } from "process";
12
+ import { stub } from "sinon";
13
+ import LocalRunner from "./localrunner.js";
14
+ import { Runner } from "./runner.js";
15
+ class FakeRunner extends Runner {
16
+ launchAction(action) {
17
+ throw new Error("Method not implemented.");
18
+ }
19
+ }
20
+ class FakeChildProcess extends EventEmitter {
21
+ constructor() {
22
+ super(...arguments);
23
+ this.pid = 666;
24
+ this.stdout = new EventEmitter();
25
+ this.stderr = new EventEmitter();
26
+ }
27
+ send(type, ...args) {
28
+ this.emit(type, ...args);
29
+ }
30
+ }
31
+ let LocalRunnerTest = class LocalRunnerTest extends WebdaTest {
32
+ cov() {
33
+ new LocalRunner(this.webda, "runner", {});
34
+ const runner = new LocalRunner(this.webda, "runner", { actions: ["plop"], options: { env: { OK: "test" } } });
35
+ assert.strictEqual(runner.handleType("plop"), true);
36
+ assert.strictEqual(runner.handleType("plop2"), false);
37
+ new LocalRunner(this.webda, "runner", { options: { env: { OK: "test" } } });
38
+ // Just for loadParameters
39
+ new FakeRunner(this.webda, "fake", {});
40
+ }
41
+ getJobInfo(action) {
42
+ return {
43
+ JOB_HOOK: "",
44
+ JOB_ID: action.getUuid(),
45
+ JOB_ORCHESTRATOR: "test",
46
+ JOB_SECRET_KEY: action.__secretKey
47
+ };
48
+ }
49
+ async launchAction() {
50
+ const runner = new LocalRunner(this.webda, "runner", {});
51
+ // @ts-expect-error
52
+ const spawn = stub(runner, "spawn").returns({ pid: "fake" });
53
+ try {
54
+ const action = await this.getService("AsyncJobs").save({ status: "STARTING", logs: [] });
55
+ const job = await runner.launchAction(action, this.getJobInfo(action));
56
+ assert.strictEqual(spawn.calledOnce, true);
57
+ assert.strictEqual(job.pid, "fake");
58
+ await action.refresh();
59
+ assert.strictEqual(action.status, "STARTING");
60
+ runner.getParameters().args = ["test"];
61
+ await runner.launchAction(action, this.getJobInfo(action));
62
+ }
63
+ finally {
64
+ spawn.restore();
65
+ }
66
+ }
67
+ async launchActionAutoStatus() {
68
+ const child = new FakeChildProcess();
69
+ const runner = new LocalRunner(this.webda, "runner", { autoStatus: true });
70
+ // @ts-expect-error
71
+ const spawn = stub(runner, "spawn").returns(child);
72
+ try {
73
+ const action = await this.getService("AsyncJobs").save({ status: "STARTING", logs: [] });
74
+ const job = await runner.launchAction(action, this.getJobInfo(action));
75
+ assert.strictEqual(spawn.calledOnce, true);
76
+ assert.strictEqual(job.pid, 666);
77
+ await action.refresh();
78
+ assert.strictEqual(action.status, "RUNNING");
79
+ assert.deepStrictEqual(action.logs, []);
80
+ child.stdout.emit("data", "stdout output");
81
+ child.stderr.emit("data", "stderr output");
82
+ await new Promise(resolve => nextTick(resolve));
83
+ await this.sleep(1000);
84
+ await action.refresh();
85
+ assert.strictEqual(action.status, "RUNNING");
86
+ assert.deepStrictEqual(action.logs, ["stdout output", "stderr output"]);
87
+ child.emit("exit", 1);
88
+ await new Promise(resolve => nextTick(resolve));
89
+ await action.refresh();
90
+ assert.strictEqual(action.status, "ERROR");
91
+ child.emit("exit", 0);
92
+ await new Promise(resolve => nextTick(resolve));
93
+ await action.refresh();
94
+ assert.strictEqual(action.status, "SUCCESS");
95
+ }
96
+ finally {
97
+ spawn.restore();
98
+ }
99
+ }
100
+ };
101
+ __decorate([
102
+ test
103
+ ], LocalRunnerTest.prototype, "cov", null);
104
+ __decorate([
105
+ test
106
+ ], LocalRunnerTest.prototype, "launchAction", null);
107
+ __decorate([
108
+ test
109
+ ], LocalRunnerTest.prototype, "launchActionAutoStatus", null);
110
+ LocalRunnerTest = __decorate([
111
+ suite
112
+ ], LocalRunnerTest);
113
+ //# sourceMappingURL=localrunner.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localrunner.spec.js","sourceRoot":"","sources":["../../src/services/localrunner.spec.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7B,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,UAAW,SAAQ,MAAM;IAC7B,YAAY,CAAC,MAAc;QACzB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF;AAED,MAAM,gBAAiB,SAAQ,YAAY;IAA3C;;QACE,QAAG,GAAW,GAAG,CAAC;QAClB,WAAM,GAAiB,IAAI,YAAY,EAAE,CAAC;QAC1C,WAAM,GAAiB,IAAI,YAAY,EAAE,CAAC;IAK5C,CAAC;IAHC,IAAI,CAAC,IAAY,EAAE,GAAG,IAAW;QAC/B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;IAC3B,CAAC;CACF;AAGD,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,SAAS;IAErC,GAAG;QACD,IAAI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AAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACtB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;YAChD,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;YACvB,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAC/C,CAAC;gBAAS,CAAC;YACT,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAA;AA5EC;IADC,IAAI;0CASJ;AAYK;IADL,IAAI;mDAmBJ;AAGK;IADL,IAAI;6DAmCJ;AA7EG,eAAe;IADpB,KAAK;GACA,eAAe,CA8EpB"}
@@ -50,3 +50,4 @@ export declare abstract class Runner<T extends RunnerParameters = RunnerParamete
50
50
  */
51
51
  abstract launchAction(action: AsyncAction, info: JobInfo): Promise<any>;
52
52
  }
53
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/services/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,gBAAiB,SAAQ,iBAAiB;IACrD;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;gBAEP,MAAM,EAAE,GAAG;CAIxB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,8BAAsB,MAAM,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IAC5F;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,iBAAiB;IAG9C;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIjC;;;OAGG;IACH,MAAM,CAAC,YAAY,IAAI,SAAS;IAShC;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;CACxE"}
@@ -65,3 +65,4 @@ export default class ServiceRunner<T extends ServiceRunnerParameters = ServiceRu
65
65
  */
66
66
  launchAction(action: AsyncAction, info: JobInfo): Promise<ServiceAction>;
67
67
  }
68
+ //# sourceMappingURL=servicerunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"servicerunner.d.ts","sourceRoot":"","sources":["../../src/services/servicerunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EAAE,WAAW,EAA0C,MAAM,WAAW,CAAC;AAChF,OAAwB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;IACjB;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,YAAY;IAOhD,SAAS,CAAC,MAAM,EAAE,WAAW;IACtB,YAAY,EAAE,MAAM;IACpB,MAAM,CAAC,EAAE,MAAM;IARxB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC;gBAGhC,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,MAAM,EACH,MAAM,EAAE,WAAW,EACtB,YAAY,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,MAAM;IAKxB,SAAS,CAAC,GAAG,EAAE,aAAa;IAO5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQf,YAAY;CAInB;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,gBAAgB;IAC3D;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;gBAEV,MAAM,EAAE,GAAG;CAIxB;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa,CAAC,CAAC,SAAS,uBAAuB,GAAG,uBAAuB,CAAE,SAAQ,MAAM,CAAC,CAAC,CAAC;IAC/G;;;;OAIG;IACH,cAAc,CAAC,MAAM,EAAE,GAAG;IAG1B;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;CAiD/E"}
@@ -61,7 +61,7 @@ export default class ServiceRunner extends Runner {
61
61
  throw new Error("Can only handle AsyncWebdaAction or AsyncOperationAction got " + action.constructor.name);
62
62
  }
63
63
  // Launch within current process
64
- let promise = (async (action) => {
64
+ const promise = (async (action) => {
65
65
  let logger;
66
66
  try {
67
67
  await action.patch({ status: "RUNNING" });
@@ -1 +1 @@
1
- {"version":3,"file":"servicerunner.js","sourceRoot":"","sources":["../../src/services/servicerunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAA+C,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EAAe,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE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{};
2
+ //# sourceMappingURL=servicerunner.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"servicerunner.spec.d.ts","sourceRoot":"","sources":["../../src/services/servicerunner.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,111 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { suite, test } from "@testdeck/mocha";
8
+ import { CoreModel, Operation, OperationContext, SimpleOperationContext } from "@webda/core";
9
+ import { WebdaTest } from "@webda/core/lib/test.js";
10
+ import assert from "assert";
11
+ import { AsyncOperationAction, AsyncWebdaAction } from "../models.js";
12
+ import { Runner } from "./runner.js";
13
+ import ServiceRunner from "./servicerunner.js";
14
+ class FakeRunner extends Runner {
15
+ launchAction(action) {
16
+ throw new Error("Method not implemented.");
17
+ }
18
+ test(arg) {
19
+ this.log("INFO", "FakeRunner test", arg);
20
+ if (arg === 666) {
21
+ throw new Error("Error");
22
+ }
23
+ }
24
+ operation(ctx) {
25
+ this.log("INFO", "Logging test");
26
+ }
27
+ }
28
+ __decorate([
29
+ Operation()
30
+ ], FakeRunner.prototype, "operation", null);
31
+ let ServiceRunnerTest = class ServiceRunnerTest extends WebdaTest {
32
+ async operationAction() {
33
+ this.registerService(new FakeRunner(this.webda, "calledRunner"));
34
+ this.webda.initStatics();
35
+ const runner = new ServiceRunner(this.webda, "runner", { actions: ["plop"] });
36
+ const ctx = new OperationContext(this.webda);
37
+ const action = new AsyncOperationAction("calledRunner.testOp", ctx);
38
+ await this.getService("AsyncJobs").save(action);
39
+ await runner.launchAction(action, {
40
+ JOB_HOOK: "",
41
+ JOB_ID: action.getUuid(),
42
+ JOB_ORCHESTRATOR: "test",
43
+ JOB_SECRET_KEY: ""
44
+ });
45
+ }
46
+ async cov() {
47
+ this.registerService(new FakeRunner(this.webda, "calledRunner"));
48
+ const runner = new ServiceRunner(this.webda, "runner", { actions: ["plop"] });
49
+ const action = new AsyncWebdaAction();
50
+ action.serviceName = "calledRunner";
51
+ action.method = "test";
52
+ await this.getService("AsyncJobs").save(action);
53
+ let serviceAction = await runner.launchAction(action, {
54
+ JOB_HOOK: "",
55
+ JOB_ID: action.getUuid(),
56
+ JOB_ORCHESTRATOR: "test",
57
+ JOB_SECRET_KEY: ""
58
+ });
59
+ await serviceAction.promise;
60
+ await action.refresh();
61
+ assert.strictEqual(action.logs?.length, 1);
62
+ assert.ok(action.logs[0].endsWith(" [ INFO] [calledRunner] FakeRunner test undefined"));
63
+ const action2 = new AsyncWebdaAction();
64
+ action2.serviceName = "calledRunner";
65
+ action2.method = "test";
66
+ action2.arguments = [666];
67
+ await this.getService("AsyncJobs").save(action2);
68
+ serviceAction = await runner.launchAction(action2, {
69
+ JOB_HOOK: "",
70
+ JOB_ID: action2.getUuid(),
71
+ JOB_ORCHESTRATOR: "test",
72
+ JOB_SECRET_KEY: ""
73
+ });
74
+ await serviceAction.promise;
75
+ await action2.refresh();
76
+ assert.strictEqual(action2.status, "ERROR");
77
+ assert.strictEqual(action2.logs?.length, 1);
78
+ assert.ok(action2.logs[0].endsWith(" [ INFO] [calledRunner] FakeRunner test 666"));
79
+ action.type = "plop";
80
+ await assert.rejects(() => runner.launchAction(new CoreModel(), {
81
+ JOB_HOOK: "",
82
+ JOB_ID: action2.getUuid(),
83
+ JOB_ORCHESTRATOR: "test",
84
+ JOB_SECRET_KEY: ""
85
+ }), /Can only handle AsyncWebdaAction or AsyncOperationAction got CoreModel/);
86
+ const opAction = new AsyncOperationAction("CalledRunner.Operation", new SimpleOperationContext(this.webda).setInput(Buffer.from("{}")));
87
+ this.webda.initStatics();
88
+ await this.getService("AsyncJobs").save(opAction);
89
+ serviceAction = await runner.launchAction(opAction, {
90
+ JOB_HOOK: "",
91
+ JOB_ID: opAction.getUuid(),
92
+ JOB_ORCHESTRATOR: "test",
93
+ JOB_SECRET_KEY: ""
94
+ });
95
+ await serviceAction.promise;
96
+ await opAction.refresh();
97
+ assert.strictEqual(opAction.status, "SUCCESS");
98
+ assert.strictEqual(opAction.logs?.length, 1);
99
+ assert.ok(opAction.logs[0].endsWith(" [ INFO] [calledRunner] Logging test"));
100
+ }
101
+ };
102
+ __decorate([
103
+ test
104
+ ], ServiceRunnerTest.prototype, "operationAction", null);
105
+ __decorate([
106
+ test
107
+ ], ServiceRunnerTest.prototype, "cov", null);
108
+ ServiceRunnerTest = __decorate([
109
+ suite
110
+ ], ServiceRunnerTest);
111
+ //# sourceMappingURL=servicerunner.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"servicerunner.spec.js","sourceRoot":"","sources":["../../src/services/servicerunner.spec.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,sBAAsB,EAAS,MAAM,aAAa,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAe,EAAe,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACxF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,MAAM,UAAW,SAAQ,MAAM;IAC7B,YAAY,CAAC,MAAc;QACzB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,GAAG;QACN,IAAI,CAAC,GAAG,CAAC,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AC,OAAO,CAAC;QAC5B,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;QACzB,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAC/C,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAC7C,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,sCAAsC,CAAC,CAAC,CAAC;IAC/E,CAAC;CACF,CAAA;AA/EO;IADL,IAAI;wDAcJ;AAGK;IADL,IAAI;4CA+DJ;AAhFG,iBAAiB;IADtB,KAAK;GACA,iBAAiB,CAiFtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webda/async",
3
- "version": "4.0.0-beta.1",
3
+ "version": "4.0.0-beta.2",
4
4
  "description": "Async System",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -8,9 +8,13 @@
8
8
  "build:module": "webda build",
9
9
  "build:watch": "webda build --watch",
10
10
  "pretest": "npm run build",
11
- "test": "c8 mocha -r ../../node_modules/ts-node/register",
12
- "test:debug": "mocha --recursive --exit --no-timeouts 'src/**/*.spec.ts'",
13
- "run": "node core"
11
+ "test": "c8 mocha",
12
+ "test:debug": "mocha --no-timeouts",
13
+ "run": "node core",
14
+ "format": "prettier --check src/**/*",
15
+ "lint": "eslint",
16
+ "lint:fix": "eslint --fix",
17
+ "format:fix": "prettier --write src/**/*"
14
18
  },
15
19
  "keywords": [
16
20
  "webda-module"
@@ -21,21 +25,22 @@
21
25
  "package.json"
22
26
  ],
23
27
  "dependencies": {
24
- "@webda/core": "^4.0.0-beta.1",
25
- "@webda/workout": "^4.0.0-beta.1",
28
+ "@webda/core": "^4.0.0-beta.2",
29
+ "@webda/ql": "^4.0.0-beta.2",
30
+ "@webda/workout": "^4.0.0-beta.2",
26
31
  "axios": "^1.1.3",
27
32
  "json-schema": "^0.4.0",
28
33
  "node-cron": "^3.0.2"
29
34
  },
30
35
  "devDependencies": {
31
36
  "@testdeck/mocha": "^0.3.3",
32
- "@types/node": "18.11.13",
33
- "@webda/tsc-esm": "^4.0.0-beta.1",
37
+ "@types/node": "20.0.0",
38
+ "@webda/tsc-esm": "^4.0.0-beta.2",
34
39
  "mocha": "^10.0.0",
35
- "sinon": "^18.0.0",
40
+ "sinon": "^19.0.2",
36
41
  "source-map-support": "^0.5.19",
37
- "ts-node": "^10.2.0",
38
- "typescript": "~5.5.3"
42
+ "tsx": "^4.17.0",
43
+ "typescript": "^5.6.2"
39
44
  },
40
45
  "c8": {
41
46
  "report-dir": "./reports",
@@ -65,7 +70,7 @@
65
70
  },
66
71
  "type": "module",
67
72
  "engines": {
68
- "node": ">=18.0.0"
73
+ "node": ">=20.0.0"
69
74
  },
70
75
  "nx": {
71
76
  "implicitDependencies": [
@@ -73,5 +78,6 @@
73
78
  "@webda/tsc-esm"
74
79
  ]
75
80
  },
76
- "gitHead": "9f0c12d5e43b3484794b2a49c5701b8b9675c4a8"
81
+ "license": "LGPL-3.0-only",
82
+ "gitHead": "e992dcfb82cefa6cd5c61c54a0e63778b6f53d8e"
77
83
  }
package/webda.module.json CHANGED
@@ -31,7 +31,7 @@
31
31
  "scheduled": "number",
32
32
  "errorMessage": "string",
33
33
  "errorName": "string",
34
- "job": "Job",
34
+ "job": "any",
35
35
  "_lastJobUpdate": "number",
36
36
  "results": "any",
37
37
  "statusDetails": "any",
@@ -56,7 +56,7 @@
56
56
  "scheduled": "number",
57
57
  "errorMessage": "string",
58
58
  "errorName": "string",
59
- "job": "Job",
59
+ "job": "any",
60
60
  "_lastJobUpdate": "number",
61
61
  "results": "any",
62
62
  "statusDetails": "any",
@@ -82,7 +82,7 @@
82
82
  "scheduled": "number",
83
83
  "errorMessage": "string",
84
84
  "errorName": "string",
85
- "job": "Job",
85
+ "job": "any",
86
86
  "_lastJobUpdate": "number",
87
87
  "results": "any",
88
88
  "statusDetails": "any",
@@ -149,7 +149,6 @@
149
149
  "description": "If an error occured it should contain the name"
150
150
  },
151
151
  "job": {
152
- "type": "object",
153
152
  "description": "Job information"
154
153
  },
155
154
  "_lastJobUpdate": {
@@ -205,13 +204,7 @@
205
204
  "url": {
206
205
  "type": "string",
207
206
  "description": "URL to expose job status report hook",
208
- "default": "/async/jobs",
209
- "deprecated": "will be removed in 4.0 to only use object AsyncAction"
210
- },
211
- "binaryStore": {
212
- "type": "string",
213
- "description": "If we want to expose a way to upload/download binary for the job\n\nIt will expose a /download and /upload additional url",
214
- "deprecated": "will be removed in 4.0 to only use object AsyncAction"
207
+ "default": "/async"
215
208
  },
216
209
  "localLaunch": {
217
210
  "type": "boolean",
@@ -338,7 +331,6 @@
338
331
  "description": "If an error occured it should contain the name"
339
332
  },
340
333
  "job": {
341
- "type": "object",
342
334
  "description": "Job information"
343
335
  },
344
336
  "_lastJobUpdate": {
@@ -382,12 +374,13 @@
382
374
  "description": "Contain all registered promises to this context",
383
375
  "readOnly": true
384
376
  },
377
+ "parameters": {},
385
378
  "_stream": {
386
379
  "type": "object",
387
380
  "properties": {
388
381
  "writable": {
389
382
  "type": "boolean",
390
- "description": "Is `true` if it is safe to call `writable.write()`, which means the stream has not been destroyed, errored or ended."
383
+ "description": "Is `true` if it is safe to call `writable.write()`, which means the stream has not been destroyed, errored, or ended."
391
384
  },
392
385
  "writableEnded": {
393
386
  "type": "boolean",
@@ -419,7 +412,7 @@
419
412
  },
420
413
  "closed": {
421
414
  "type": "boolean",
422
- "description": "Is true after 'close' has been emitted."
415
+ "description": "Is `true` after `'close'` has been emitted."
423
416
  },
424
417
  "errored": {
425
418
  "anyOf": [
@@ -449,7 +442,7 @@
449
442
  },
450
443
  "writableNeedDrain": {
451
444
  "type": "boolean",
452
- "description": "Is `true` if the stream's buffer has been full and stream will emit 'drain'."
445
+ "description": "Is `true` if the stream's buffer has been full and stream will emit `'drain'`."
453
446
  }
454
447
  },
455
448
  "required": [
@@ -469,6 +462,9 @@
469
462
  "readOnly": true
470
463
  }
471
464
  },
465
+ "required": [
466
+ "parameters"
467
+ ],
472
468
  "description": "OperationContext is used when call to an operation"
473
469
  },
474
470
  "logLevel": {
@@ -549,7 +545,6 @@
549
545
  "description": "If an error occured it should contain the name"
550
546
  },
551
547
  "job": {
552
- "type": "object",
553
548
  "description": "Job information"
554
549
  },
555
550
  "_lastJobUpdate": {
@@ -761,7 +756,7 @@
761
756
  },
762
757
  "hostname": {
763
758
  "type": "string",
764
- "description": "Gets and sets the host name portion of the URL. The key difference between`url.host` and `url.hostname` is that `url.hostname` does _not_ include the port.\n\n```js const myURL = new URL('https://example.org:81/foo'); console.log(myURL.hostname); // Prints example.org\n\n// Setting the hostname does not change the port myURL.hostname = 'example.com:82'; console.log(myURL.href); // Prints https://example.com:81/foo\n\n// Use myURL.host to change the hostname and port myURL.host = 'example.org:82'; console.log(myURL.href); // Prints https://example.org:82/foo ```\n\nInvalid host name values assigned to the `hostname` property are ignored."
759
+ "description": "Gets and sets the host name portion of the URL. The key difference between`url.host` and `url.hostname` is that `url.hostname` does _not_ include the port.\n\n```js const myURL = new URL('https://example.org:81/foo'); console.log(myURL.hostname); // Prints example.org\n\n// Setting the hostname does not change the port myURL.hostname = 'example.com'; console.log(myURL.href); // Prints https://example.com:81/foo\n\n// Use myURL.host to change the hostname and port myURL.host = 'example.org:82'; console.log(myURL.href); // Prints https://example.org:82/foo ```\n\nInvalid host name values assigned to the `hostname` property are ignored."
765
760
  },
766
761
  "href": {
767
762
  "type": "string",
@@ -773,7 +768,7 @@
773
768
  },
774
769
  "password": {
775
770
  "type": "string",
776
- "description": "Gets and sets the password portion of the URL.\n\n```js const myURL = new URL('https://abc:xyz@example.com'); console.log(myURL.password); // Prints xyz\n\nmyURL.password = '123'; console.log(myURL.href); // Prints https://abc:123@example.com ```\n\nInvalid URL characters included in the value assigned to the `password` property are `percent-encoded`. The selection of which characters to percent-encode may vary somewhat from what the {@link parse } and {@link format } methods would produce."
771
+ "description": "Gets and sets the password portion of the URL.\n\n```js const myURL = new URL('https://abc:xyz@example.com'); console.log(myURL.password); // Prints xyz\n\nmyURL.password = '123'; console.log(myURL.href); // Prints https://abc:123@example.com/ ```\n\nInvalid URL characters included in the value assigned to the `password` property are `percent-encoded`. The selection of which characters to percent-encode may vary somewhat from what the {@link parse } and {@link format } methods would produce."
777
772
  },
778
773
  "pathname": {
779
774
  "type": "string",
@@ -793,8 +788,16 @@
793
788
  },
794
789
  "searchParams": {
795
790
  "type": "object",
796
- "properties": {},
797
- "description": "Gets the `URLSearchParams` object representing the query parameters of the URL. This property is read-only but the `URLSearchParams` object it provides can be used to mutate the URL instance; to replace the entirety of query parameters of the URL, use the {@link search } setter. See `URLSearchParams` documentation for details.\n\nUse care when using `.searchParams` to modify the `URL` because, per the WHATWG specification, the `URLSearchParams` object uses different rules to determine which characters to percent-encode. For instance, the `URL` object will not percent encode the ASCII tilde (`~`) character, while `URLSearchParams` will always encode it:\n\n```js const myUrl = new URL('https://example.org/abc?foo=~bar');\n\nconsole.log(myUrl.search); // prints ?foo=~bar\n\n// Modify the URL via searchParams... myUrl.searchParams.sort();\n\nconsole.log(myUrl.search); // prints ?foo=%7Ebar ```"
791
+ "properties": {
792
+ "size": {
793
+ "type": "number",
794
+ "description": "The total number of parameter entries."
795
+ }
796
+ },
797
+ "required": [
798
+ "size"
799
+ ],
800
+ "description": "Gets the `URLSearchParams` object representing the query parameters of the URL. This property is read-only but the `URLSearchParams` object it provides can be used to mutate the URL instance; to replace the entirety of query parameters of the URL, use the {@link search } setter. See `URLSearchParams` documentation for details.\n\nUse care when using `.searchParams` to modify the `URL` because, per the WHATWG specification, the `URLSearchParams` object uses different rules to determine which characters to percent-encode. For instance, the `URL` object will not percent encode the ASCII tilde (`~`) character, while `URLSearchParams` will always encode it:\n\n```js const myURL = new URL('https://example.org/abc?foo=~bar');\n\nconsole.log(myURL.search); // prints ?foo=~bar\n\n// Modify the URL via searchParams... myURL.searchParams.sort();\n\nconsole.log(myURL.search); // prints ?foo=%7Ebar ```"
798
801
  },
799
802
  "username": {
800
803
  "type": "string",
@@ -830,7 +833,7 @@
830
833
  },
831
834
  "windowsHide": {
832
835
  "type": "boolean",
833
- "default": true
836
+ "default": false
834
837
  },
835
838
  "argv0": {
836
839
  "type": "string"