@serenity-js/core 3.2.1 → 3.3.0
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/CHANGELOG.md +16 -0
- package/lib/Serenity.d.ts +2 -2
- package/lib/Serenity.d.ts.map +1 -1
- package/lib/events/EmitsDomainEvents.d.ts +11 -0
- package/lib/events/EmitsDomainEvents.d.ts.map +1 -0
- package/lib/events/EmitsDomainEvents.js +3 -0
- package/lib/events/EmitsDomainEvents.js.map +1 -0
- package/lib/events/index.d.ts +1 -0
- package/lib/events/index.d.ts.map +1 -1
- package/lib/events/index.js +1 -0
- package/lib/events/index.js.map +1 -1
- package/lib/io/asyncMap.js +2 -2
- package/lib/io/asyncMap.js.map +1 -1
- package/lib/screenplay/Actor.d.ts +3 -3
- package/lib/screenplay/Actor.d.ts.map +1 -1
- package/lib/screenplay/Actor.js +14 -86
- package/lib/screenplay/Actor.js.map +1 -1
- package/lib/screenplay/abilities/AnswerQuestions.d.ts +21 -0
- package/lib/screenplay/abilities/AnswerQuestions.d.ts.map +1 -0
- package/lib/screenplay/abilities/AnswerQuestions.js +37 -0
- package/lib/screenplay/abilities/AnswerQuestions.js.map +1 -0
- package/lib/screenplay/abilities/PerformActivities.d.ts +28 -0
- package/lib/screenplay/abilities/PerformActivities.d.ts.map +1 -0
- package/lib/screenplay/abilities/PerformActivities.js +66 -0
- package/lib/screenplay/abilities/PerformActivities.js.map +1 -0
- package/lib/screenplay/abilities/index.d.ts +2 -0
- package/lib/screenplay/abilities/index.d.ts.map +1 -1
- package/lib/screenplay/abilities/index.js +2 -0
- package/lib/screenplay/abilities/index.js.map +1 -1
- package/lib/screenplay/time/abilities/ScheduleWork.d.ts +2 -4
- package/lib/screenplay/time/abilities/ScheduleWork.d.ts.map +1 -1
- package/lib/screenplay/time/abilities/ScheduleWork.js +0 -6
- package/lib/screenplay/time/abilities/ScheduleWork.js.map +1 -1
- package/lib/screenplay/time/models/Clock.d.ts +24 -0
- package/lib/screenplay/time/models/Clock.d.ts.map +1 -1
- package/lib/screenplay/time/models/Clock.js +41 -1
- package/lib/screenplay/time/models/Clock.js.map +1 -1
- package/lib/screenplay/time/models/Scheduler.d.ts +1 -10
- package/lib/screenplay/time/models/Scheduler.d.ts.map +1 -1
- package/lib/screenplay/time/models/Scheduler.js +65 -103
- package/lib/screenplay/time/models/Scheduler.js.map +1 -1
- package/lib/stage/Stage.d.ts +2 -2
- package/lib/stage/Stage.d.ts.map +1 -1
- package/lib/stage/Stage.js +4 -2
- package/lib/stage/Stage.js.map +1 -1
- package/package.json +2 -2
- package/src/Serenity.ts +2 -2
- package/src/events/EmitsDomainEvents.ts +11 -0
- package/src/events/index.ts +1 -0
- package/src/io/asyncMap.ts +2 -2
- package/src/screenplay/Actor.ts +32 -131
- package/src/screenplay/abilities/AnswerQuestions.ts +41 -0
- package/src/screenplay/abilities/PerformActivities.ts +88 -0
- package/src/screenplay/abilities/index.ts +2 -0
- package/src/screenplay/time/abilities/ScheduleWork.ts +2 -10
- package/src/screenplay/time/models/Clock.ts +47 -1
- package/src/screenplay/time/models/Scheduler.ts +89 -136
- package/src/stage/Stage.ts +15 -7
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Duration } from './Duration';
|
|
1
2
|
import { Timestamp } from './Timestamp';
|
|
2
3
|
/**
|
|
3
4
|
* A {@apilink Clock} tells the time. This abstraction allows Serenity/JS to have a single place
|
|
@@ -15,10 +16,33 @@ import { Timestamp } from './Timestamp';
|
|
|
15
16
|
*/
|
|
16
17
|
export declare class Clock {
|
|
17
18
|
private readonly checkTime;
|
|
19
|
+
private static resolution;
|
|
20
|
+
private timeAdjustment;
|
|
18
21
|
constructor(checkTime?: () => Date);
|
|
22
|
+
/**
|
|
23
|
+
* Sets the clock ahead to force early resolution of promises
|
|
24
|
+
* returned by {@apilink Clock.waitFor};
|
|
25
|
+
*
|
|
26
|
+
* Useful for test purposes to avoid unnecessary delays.
|
|
27
|
+
*
|
|
28
|
+
* @param duration
|
|
29
|
+
*/
|
|
30
|
+
setAhead(duration: Duration): void;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a Promise that resolves after one tick of the clock.
|
|
33
|
+
*
|
|
34
|
+
* Useful for test purposes to avoid unnecessary delays.
|
|
35
|
+
*/
|
|
36
|
+
tick(): Promise<void>;
|
|
19
37
|
/**
|
|
20
38
|
* Returns current time
|
|
21
39
|
*/
|
|
22
40
|
now(): Timestamp;
|
|
41
|
+
/**
|
|
42
|
+
* Returns a Promise that will be resolved after the given duration
|
|
43
|
+
*
|
|
44
|
+
* @param duration
|
|
45
|
+
*/
|
|
46
|
+
waitFor(duration: Duration): Promise<void>;
|
|
23
47
|
}
|
|
24
48
|
//# sourceMappingURL=Clock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clock.d.ts","sourceRoot":"","sources":["../../../../src/screenplay/time/models/Clock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Clock.d.ts","sourceRoot":"","sources":["../../../../src/screenplay/time/models/Clock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;;;;GAaG;AACH,qBAAa,KAAK;IAIF,OAAO,CAAC,QAAQ,CAAC,SAAS;IAHtC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAyC;IAClE,OAAO,CAAC,cAAc,CAAwC;gBAEjC,SAAS,GAAE,MAAM,IAAuB;IAGrE;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAIlC;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B;;OAEG;IACH,GAAG,IAAI,SAAS;IAIhB;;;;OAIG;IACG,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAcnD"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Clock = void 0;
|
|
4
|
+
const tiny_types_1 = require("tiny-types");
|
|
5
|
+
const Duration_1 = require("./Duration");
|
|
4
6
|
const Timestamp_1 = require("./Timestamp");
|
|
5
7
|
/**
|
|
6
8
|
* A {@apilink Clock} tells the time. This abstraction allows Serenity/JS to have a single place
|
|
@@ -19,13 +21,51 @@ const Timestamp_1 = require("./Timestamp");
|
|
|
19
21
|
class Clock {
|
|
20
22
|
constructor(checkTime = () => new Date()) {
|
|
21
23
|
this.checkTime = checkTime;
|
|
24
|
+
this.timeAdjustment = Duration_1.Duration.ofMilliseconds(0);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Sets the clock ahead to force early resolution of promises
|
|
28
|
+
* returned by {@apilink Clock.waitFor};
|
|
29
|
+
*
|
|
30
|
+
* Useful for test purposes to avoid unnecessary delays.
|
|
31
|
+
*
|
|
32
|
+
* @param duration
|
|
33
|
+
*/
|
|
34
|
+
setAhead(duration) {
|
|
35
|
+
this.timeAdjustment = (0, tiny_types_1.ensure)('duration', duration, (0, tiny_types_1.isDefined)());
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Returns a Promise that resolves after one tick of the clock.
|
|
39
|
+
*
|
|
40
|
+
* Useful for test purposes to avoid unnecessary delays.
|
|
41
|
+
*/
|
|
42
|
+
async tick() {
|
|
43
|
+
return new Promise(resolve => setTimeout(resolve, Clock.resolution.inMilliseconds()));
|
|
22
44
|
}
|
|
23
45
|
/**
|
|
24
46
|
* Returns current time
|
|
25
47
|
*/
|
|
26
48
|
now() {
|
|
27
|
-
return new Timestamp_1.Timestamp(this.checkTime());
|
|
49
|
+
return new Timestamp_1.Timestamp(this.checkTime()).plus(this.timeAdjustment);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns a Promise that will be resolved after the given duration
|
|
53
|
+
*
|
|
54
|
+
* @param duration
|
|
55
|
+
*/
|
|
56
|
+
async waitFor(duration) {
|
|
57
|
+
const stopAt = this.now().plus(duration);
|
|
58
|
+
let timer;
|
|
59
|
+
return new Promise(resolve => {
|
|
60
|
+
timer = setInterval(() => {
|
|
61
|
+
if (this.now().isAfterOrEqual(stopAt)) {
|
|
62
|
+
clearInterval(timer);
|
|
63
|
+
return resolve();
|
|
64
|
+
}
|
|
65
|
+
}, Clock.resolution.inMilliseconds());
|
|
66
|
+
});
|
|
28
67
|
}
|
|
29
68
|
}
|
|
69
|
+
Clock.resolution = Duration_1.Duration.ofMilliseconds(10);
|
|
30
70
|
exports.Clock = Clock;
|
|
31
71
|
//# sourceMappingURL=Clock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clock.js","sourceRoot":"","sources":["../../../../src/screenplay/time/models/Clock.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAExC;;;;;;;;;;;;;GAaG;AACH,MAAa,KAAK;
|
|
1
|
+
{"version":3,"file":"Clock.js","sourceRoot":"","sources":["../../../../src/screenplay/time/models/Clock.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAE/C,yCAAsC;AACtC,2CAAwC;AAExC;;;;;;;;;;;;;GAaG;AACH,MAAa,KAAK;IAId,YAA6B,YAAwB,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;QAAxC,cAAS,GAAT,SAAS,CAA+B;QAF7D,mBAAc,GAAa,mBAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAG9D,CAAC;IAED;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAkB;QACvB,IAAI,CAAC,cAAc,GAAG,IAAA,mBAAM,EAAC,UAAU,EAAE,QAAQ,EAAE,IAAA,sBAAS,GAAE,CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI;QACN,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;IAC1F,CAAC;IAED;;OAEG;IACH,GAAG;QACC,OAAO,IAAI,qBAAS,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,QAAkB;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEzC,IAAI,KAAmB,CAAC;QAExB,OAAO,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE;YAC/B,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;gBACrB,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;oBACnC,aAAa,CAAC,KAAK,CAAC,CAAC;oBACrB,OAAO,OAAO,EAAE,CAAC;iBACpB;YACL,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACP,CAAC;;AApDc,gBAAU,GAAa,mBAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,AAAxC,CAAyC;AADzD,sBAAK"}
|
|
@@ -8,10 +8,7 @@ import { RepeatUntilLimits } from './RepeatUntilLimits';
|
|
|
8
8
|
export declare class Scheduler {
|
|
9
9
|
private readonly clock;
|
|
10
10
|
private readonly interactionTimeout;
|
|
11
|
-
private
|
|
12
|
-
private completedCallbacks;
|
|
13
|
-
private failedCallbacks;
|
|
14
|
-
private timer;
|
|
11
|
+
private scheduledOperations;
|
|
15
12
|
/**
|
|
16
13
|
* @param clock
|
|
17
14
|
* @param interactionTimeout
|
|
@@ -38,12 +35,6 @@ export declare class Scheduler {
|
|
|
38
35
|
* @param limits
|
|
39
36
|
*/
|
|
40
37
|
repeatUntil<Result>(callback: DelayedCallback<Result>, limits?: RepeatUntilLimits<Result>): Promise<Result>;
|
|
41
|
-
start(): void;
|
|
42
|
-
isRunning(): boolean;
|
|
43
38
|
stop(): void;
|
|
44
|
-
invokeCallbacksScheduledForNext(duration: Duration): void;
|
|
45
|
-
private invokeCallbacksScheduledUntil;
|
|
46
|
-
private invoke;
|
|
47
|
-
private receiptFor;
|
|
48
39
|
}
|
|
49
40
|
//# sourceMappingURL=Scheduler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scheduler.d.ts","sourceRoot":"","sources":["../../../../src/screenplay/time/models/Scheduler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;GAEG;AACH,qBAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"Scheduler.d.ts","sourceRoot":"","sources":["../../../../src/screenplay/time/models/Scheduler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;GAEG;AACH,qBAAa,SAAS;IAUd,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IATvC,OAAO,CAAC,mBAAmB,CAA0C;IAErE;;;;OAIG;gBAEkB,KAAK,EAAE,KAAK,EACZ,kBAAkB,EAAE,QAAQ;IAIjD;;;;;OAKG;IACH,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAWlF;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAavC;;;;;OAKG;IACG,WAAW,CAAC,MAAM,EACpB,QAAQ,EAAE,eAAe,CAAC,MAAM,CAAC,EACjC,MAAM,GAAE,iBAAiB,CAAC,MAAM,CAAM,GACvC,OAAO,CAAC,MAAM,CAAC;IA0BlB,IAAI,IAAI,IAAI;CAKf"}
|
|
@@ -15,9 +15,7 @@ class Scheduler {
|
|
|
15
15
|
constructor(clock, interactionTimeout) {
|
|
16
16
|
this.clock = clock;
|
|
17
17
|
this.interactionTimeout = interactionTimeout;
|
|
18
|
-
this.
|
|
19
|
-
this.completedCallbacks = new Map();
|
|
20
|
-
this.failedCallbacks = new Map();
|
|
18
|
+
this.scheduledOperations = [];
|
|
21
19
|
}
|
|
22
20
|
/**
|
|
23
21
|
* Schedules a callback function to be invoked after a delay
|
|
@@ -29,7 +27,7 @@ class Scheduler {
|
|
|
29
27
|
return this.repeatUntil(callback, {
|
|
30
28
|
maxInvocations: 1,
|
|
31
29
|
delayBetweenInvocations: () => delay,
|
|
32
|
-
timeout: this.interactionTimeout,
|
|
30
|
+
timeout: this.interactionTimeout.plus(delay),
|
|
33
31
|
});
|
|
34
32
|
}
|
|
35
33
|
/**
|
|
@@ -53,120 +51,84 @@ class Scheduler {
|
|
|
53
51
|
*/
|
|
54
52
|
async repeatUntil(callback, limits = {}) {
|
|
55
53
|
const { maxInvocations = Number.POSITIVE_INFINITY, delayBetweenInvocations = noDelay, timeout = this.interactionTimeout, exitCondition = noEarlyExit, errorHandler = rethrowErrors, } = limits;
|
|
56
|
-
this.
|
|
57
|
-
exitCondition
|
|
58
|
-
|
|
59
|
-
invocationsLeft: maxInvocations,
|
|
54
|
+
const operation = new ScheduledOperation(this.clock, callback, {
|
|
55
|
+
exitCondition,
|
|
56
|
+
maxInvocations,
|
|
60
57
|
delayBetweenInvocations,
|
|
61
|
-
startedAt: this.clock.now(),
|
|
62
58
|
timeout,
|
|
63
59
|
errorHandler,
|
|
64
|
-
result: undefined,
|
|
65
60
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
start() {
|
|
69
|
-
if (!this.timer) {
|
|
70
|
-
this.timer = setInterval(() => this.invokeCallbacksScheduledUntil(this.clock.now()), 100);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
isRunning() {
|
|
74
|
-
return Boolean(this.timer);
|
|
61
|
+
this.scheduledOperations.push(operation);
|
|
62
|
+
return operation.start();
|
|
75
63
|
}
|
|
76
64
|
stop() {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
this.timer = undefined;
|
|
80
|
-
for (const [callback, info] of this.remainingCallbacks) {
|
|
81
|
-
this.remainingCallbacks.delete(callback);
|
|
82
|
-
this.failedCallbacks.set(callback, {
|
|
83
|
-
...info,
|
|
84
|
-
error: new errors_1.OperationInterruptedError(`Scheduler stopped before executing callback ${callback}`)
|
|
85
|
-
});
|
|
86
|
-
}
|
|
65
|
+
for (const operation of this.scheduledOperations) {
|
|
66
|
+
operation.cancel();
|
|
87
67
|
}
|
|
88
68
|
}
|
|
89
|
-
|
|
90
|
-
|
|
69
|
+
}
|
|
70
|
+
exports.Scheduler = Scheduler;
|
|
71
|
+
class ScheduledOperation {
|
|
72
|
+
constructor(clock, callback, limits = {}) {
|
|
73
|
+
this.clock = clock;
|
|
74
|
+
this.callback = callback;
|
|
75
|
+
this.limits = limits;
|
|
76
|
+
this.currentInvocation = 0;
|
|
77
|
+
this.invocationsLeft = 0;
|
|
78
|
+
this.isCancelled = false;
|
|
91
79
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
80
|
+
async start() {
|
|
81
|
+
this.currentInvocation = 0;
|
|
82
|
+
this.invocationsLeft = this.limits.maxInvocations;
|
|
83
|
+
this.startedAt = this.clock.now();
|
|
84
|
+
return await this.poll();
|
|
85
|
+
}
|
|
86
|
+
async poll() {
|
|
87
|
+
await this.clock.waitFor(this.limits.delayBetweenInvocations(this.currentInvocation));
|
|
88
|
+
if (this.isCancelled) {
|
|
89
|
+
throw new errors_1.OperationInterruptedError('Scheduler stopped before executing callback');
|
|
90
|
+
}
|
|
91
|
+
const receipt = await this.invoke();
|
|
92
|
+
if (receipt.hasCompleted) {
|
|
93
|
+
return receipt.result;
|
|
99
94
|
}
|
|
95
|
+
this.currentInvocation++;
|
|
96
|
+
this.invocationsLeft--;
|
|
97
|
+
return await this.poll();
|
|
100
98
|
}
|
|
101
|
-
invoke(
|
|
102
|
-
const
|
|
103
|
-
this.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
try {
|
|
114
|
-
if (timeoutExpired) {
|
|
115
|
-
throw new errors_1.TimeoutExpiredError(`Timeout of ${info.timeout} has expired`);
|
|
116
|
-
}
|
|
117
|
-
const result = await callback({ currentTime: this.clock.now(), i: info.currentInvocation });
|
|
118
|
-
return {
|
|
119
|
-
result,
|
|
120
|
-
hasCompleted: info.exitCondition(result) || isLastInvocation,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
info.errorHandler(error, info.result);
|
|
125
|
-
// if the errorHandler didn't throw, it's a recoverable error
|
|
126
|
-
return {
|
|
127
|
-
error,
|
|
128
|
-
hasCompleted: isLastInvocation,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
})
|
|
132
|
-
.then(({ result, error, hasCompleted }) => {
|
|
133
|
-
if (hasCompleted) {
|
|
134
|
-
this['completedCallbacks'].set(callback, {
|
|
135
|
-
...info,
|
|
136
|
-
result: result !== null && result !== void 0 ? result : info.result,
|
|
137
|
-
error,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
this['remainingCallbacks'].set(callback, {
|
|
142
|
-
...info,
|
|
143
|
-
currentInvocation: info.currentInvocation + 1,
|
|
144
|
-
invocationsLeft: info.invocationsLeft - 1,
|
|
145
|
-
result: result !== null && result !== void 0 ? result : info.result,
|
|
146
|
-
error,
|
|
147
|
-
});
|
|
99
|
+
async invoke() {
|
|
100
|
+
const timeoutExpired = this.startedAt.plus(this.limits.timeout).isBefore(this.clock.now());
|
|
101
|
+
const isLastInvocation = this.invocationsLeft === 1;
|
|
102
|
+
if (this.invocationsLeft === 0) {
|
|
103
|
+
return {
|
|
104
|
+
result: this.lastResult,
|
|
105
|
+
hasCompleted: true,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
if (timeoutExpired) {
|
|
110
|
+
throw new errors_1.TimeoutExpiredError(`Timeout of ${this.limits.timeout} has expired`);
|
|
148
111
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
112
|
+
this.lastResult = await this.callback({ currentTime: this.clock.now(), i: this.currentInvocation });
|
|
113
|
+
return {
|
|
114
|
+
result: this.lastResult,
|
|
115
|
+
hasCompleted: this.limits.exitCondition(this.lastResult) || isLastInvocation,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
this.limits.errorHandler(error, this.lastResult);
|
|
120
|
+
// if the errorHandler didn't throw, it's a recoverable error
|
|
121
|
+
return {
|
|
122
|
+
result: this.lastResult,
|
|
123
|
+
error,
|
|
124
|
+
hasCompleted: isLastInvocation,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
153
127
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const timer = setInterval(() => {
|
|
157
|
-
if (this.failedCallbacks.has(callback)) {
|
|
158
|
-
clearInterval(timer);
|
|
159
|
-
return reject(this.failedCallbacks.get(callback).error);
|
|
160
|
-
}
|
|
161
|
-
if (this.completedCallbacks.has(callback)) {
|
|
162
|
-
clearInterval(timer);
|
|
163
|
-
return resolve(this.completedCallbacks.get(callback).result);
|
|
164
|
-
}
|
|
165
|
-
}, 25);
|
|
166
|
-
});
|
|
128
|
+
cancel() {
|
|
129
|
+
this.isCancelled = true;
|
|
167
130
|
}
|
|
168
131
|
}
|
|
169
|
-
exports.Scheduler = Scheduler;
|
|
170
132
|
function noDelay() {
|
|
171
133
|
return Duration_1.Duration.ofMilliseconds(0);
|
|
172
134
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scheduler.js","sourceRoot":"","sources":["../../../../src/screenplay/time/models/Scheduler.ts"],"names":[],"mappings":";;;AAAA,4CAAiF;AAGjF,yCAAsC;AAItC;;GAEG;AACH,MAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"Scheduler.js","sourceRoot":"","sources":["../../../../src/screenplay/time/models/Scheduler.ts"],"names":[],"mappings":";;;AAAA,4CAAiF;AAGjF,yCAAsC;AAItC;;GAEG;AACH,MAAa,SAAS;IAIlB;;;;OAIG;IACH,YACqB,KAAY,EACZ,kBAA4B;QAD5B,UAAK,GAAL,KAAK,CAAO;QACZ,uBAAkB,GAAlB,kBAAkB,CAAU;QATzC,wBAAmB,GAAuC,EAAE,CAAC;IAWrE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAS,KAAe,EAAE,QAAiC;QAC5D,OAAO,IAAI,CAAC,WAAW,CACnB,QAAQ,EACR;YACI,cAAc,EAAE,CAAC;YACjB,uBAAuB,EAAE,GAAG,EAAE,CAAC,KAAK;YACpC,OAAO,EAAE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC;SAC/C,CACJ,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,KAAe;QACnB,OAAO,IAAI,CAAC,WAAW,CACnB,GAAG,EAAE,CAAC,KAAK,CAAC,EACZ;YACI,cAAc,EAAE,CAAC;YACjB,uBAAuB,EAAE,GAAG,EAAE,CAAC,KAAK;YAEpC,gEAAgE;YAChE,O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E,EAAE,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;YAEpG,OAAO;gBACH,MAAM,EAAQ,IAAI,CAAC,UAAU;gBAC7B,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,gBAAgB;aAC/E,CAAA;SACJ;QACD,OAAM,KAAK,EAAE;YAET,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YAEjD,6DAA6D;YAC7D,OAAO;gBACH,MAAM,EAAQ,IAAI,CAAC,UAAU;gBAC7B,KAAK;gBACL,YAAY,EAAE,gBAAgB;aACjC,CAAA;SACJ;IACL,CAAC;IAED,MAAM;QACF,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC5B,CAAC;CACJ;AAED,SAAS,OAAO;IACZ,OAAO,mBAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,WAAW;IAChB,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,aAAa,CAAC,KAAY;IAC/B,MAAM,KAAK,CAAC;AAChB,CAAC"}
|
package/lib/stage/Stage.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorFactory, ErrorOptions, RuntimeError } from '../errors';
|
|
2
|
-
import { DomainEvent } from '../events';
|
|
2
|
+
import { DomainEvent, EmitsDomainEvents } from '../events';
|
|
3
3
|
import { ActivityDetails, CorrelationId } from '../model';
|
|
4
4
|
import { Actor, Clock, Duration, Timestamp } from '../screenplay';
|
|
5
5
|
import { ListensToDomainEvents } from '../stage';
|
|
@@ -20,7 +20,7 @@ import { StageManager } from './StageManager';
|
|
|
20
20
|
*
|
|
21
21
|
* @group Stage
|
|
22
22
|
*/
|
|
23
|
-
export declare class Stage {
|
|
23
|
+
export declare class Stage implements EmitsDomainEvents {
|
|
24
24
|
private cast;
|
|
25
25
|
private readonly manager;
|
|
26
26
|
private errors;
|
package/lib/stage/Stage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stage.d.ts","sourceRoot":"","sources":["../../src/stage/Stage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,YAAY,EAAE,YAAY,EAA2B,YAAY,EAAE,MAAM,WAAW,CAAC;AAClH,OAAO,
|
|
1
|
+
{"version":3,"file":"Stage.d.ts","sourceRoot":"","sources":["../../src/stage/Stage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,YAAY,EAAE,YAAY,EAA2B,YAAY,EAAE,MAAM,WAAW,CAAC;AAClH,OAAO,EAIH,WAAW,EACX,iBAAiB,EAIpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAqB,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAgB,SAAS,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;;;;;;;;;;GAcG;AACH,qBAAa,KAAM,YAAW,iBAAiB;IAmCvC,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IArCvC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAA+B;IAErE;;;OAGG;IACH,OAAO,CAAC,kBAAkB,CAAgD;IAE1E;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAAgD;IAEzE,OAAO,CAAC,aAAa,CAA8C;IAEnE;;OAEG;IACH,OAAO,CAAC,mBAAmB,CAAoB;IAE/C,O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,10 @@ class Stage {
|
|
|
77
77
|
if (!this.instantiatedActorCalled(name)) {
|
|
78
78
|
let actor;
|
|
79
79
|
try {
|
|
80
|
-
const newActor = new screenplay_1.Actor(name, this
|
|
81
|
-
|
|
80
|
+
const newActor = new screenplay_1.Actor(name, this, [
|
|
81
|
+
new errors_1.RaiseErrors(this),
|
|
82
|
+
new screenplay_1.ScheduleWork(this.clock, this.interactionTimeout)
|
|
83
|
+
]);
|
|
82
84
|
actor = this.cast.prepare(newActor);
|
|
83
85
|
// todo this.manager.notifyOf(ActorStarts)
|
|
84
86
|
// todo: map this in Serenity BDD Reporter so that the "cast" is recorded
|
package/lib/stage/Stage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stage.js","sourceRoot":"","sources":["../../src/stage/Stage.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAE/C,sCAAkH;AAClH,
|
|
1
|
+
{"version":3,"file":"Stage.js","sourceRoot":"","sources":["../../src/stage/Stage.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAE/C,sCAAkH;AAClH,sCASmB;AACnB,oCAA6E;AAC7E,8CAAgF;AAKhF;;;;;;;;;;;;;;GAcG;AACH,MAAa,KAAK;IA2Bd;;;;;;OAMG;IACH,YACY,IAAU,EACD,OAAqB,EAC9B,MAAoB,EACX,KAAY,EACZ,kBAA4B;QAJrC,SAAI,GAAJ,IAAI,CAAM;QACD,YAAO,GAAP,OAAO,CAAc;QAC9B,WAAM,GAAN,MAAM,CAAc;QACX,UAAK,GAAL,KAAK,CAAO;QACZ,uBAAkB,GAAlB,kBAAkB,CAAU;QAnCjD;;;WAGG;QACK,uBAAkB,GAAuB,IAAI,GAAG,EAAiB,CAAC;QAE1E;;;WAGG;QACK,sBAAiB,GAAuB,IAAI,GAAG,EAAiB,CAAC;QAEjE,kBAAa,GAAuB,IAAI,CAAC,iBAAiB,CAAC;QAEnE;;WAEG;QACK,wBAAmB,GAAU,SAAS,CAAC;QAEvC,o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K,EAAE,aAAa,CAAE,IAAI,eAAe,EAAE;YACpD,IAAI;gBACA,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;gBAEtB,IAAI,CAAC,QAAQ,CAAC,IAAI,gCAAuB,CACrC,aAAa,EACb,IAAI,CAAC,WAAW,EAAE,CACrB,CAAC,CAAC;aACN;YACD,OAAO,KAAK,EAAE;gBACV,IAAI,CAAC,QAAQ,CAAC,IAAI,6BAAoB,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAK,6BAA6B;aACvH;SACJ;QAED,YAAY,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAEO,MAAM,CAAC,IAAU;QACrB,OAAO,IAAI,CAAC,WAAW,KAAK,MAAM;YAC9B,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAChC,CAAC;;AA/SuB,oBAAc,GAAG,IAAI,qBAAa,CAAC,SAAS,CAAC,AAA/B,CAA+B;AAF5D,sBAAK"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Serenity/JS Screenplay, reporting engine and core interfaces.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"engines": {
|
|
72
72
|
"node": "^16.13 || ^18.12 || ^20"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "c4a2bb6aef7b087dc9bc37269fd999d1cdc15088"
|
|
75
75
|
}
|
package/src/Serenity.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ensure, isDefined, isInstanceOf, property } from 'tiny-types';
|
|
|
3
3
|
import { OutputStream } from './adapter';
|
|
4
4
|
import { SerenityConfig } from './config';
|
|
5
5
|
import { ConfigurationError, ErrorFactory, ErrorOptions, NoOpDiffFormatter, RuntimeError } from './errors';
|
|
6
|
-
import { DomainEvent } from './events';
|
|
6
|
+
import { DomainEvent, EmitsDomainEvents } from './events';
|
|
7
7
|
import { ClassDescriptionParser, ClassLoader, d, has, ModuleLoader, Path } from './io';
|
|
8
8
|
import { ActivityDetails, CorrelationId } from './model';
|
|
9
9
|
import { Actor, Clock, Duration, Timestamp } from './screenplay';
|
|
@@ -16,7 +16,7 @@ import { StageManager } from './stage/StageManager';
|
|
|
16
16
|
/**
|
|
17
17
|
* @group Serenity
|
|
18
18
|
*/
|
|
19
|
-
export class Serenity {
|
|
19
|
+
export class Serenity implements EmitsDomainEvents{
|
|
20
20
|
private static defaultCueTimeout = Duration.ofSeconds(5);
|
|
21
21
|
private static defaultInteractionTimeout = Duration.ofSeconds(5);
|
|
22
22
|
private static defaultActors = new Extras();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ActivityDetails, CorrelationId } from '../model';
|
|
2
|
+
import { Timestamp } from '../screenplay';
|
|
3
|
+
import { DomainEvent } from './DomainEvent';
|
|
4
|
+
|
|
5
|
+
export interface EmitsDomainEvents {
|
|
6
|
+
currentSceneId(): CorrelationId;
|
|
7
|
+
assignNewActivityId(details: ActivityDetails): CorrelationId;
|
|
8
|
+
announce(event: DomainEvent): void;
|
|
9
|
+
currentTime(): Timestamp;
|
|
10
|
+
waitForNextCue(): Promise<void>,
|
|
11
|
+
}
|
package/src/events/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './AsyncOperationCompleted';
|
|
|
10
10
|
export * from './AsyncOperationFailed';
|
|
11
11
|
export * from './BusinessRuleDetected';
|
|
12
12
|
export * from './DomainEvent';
|
|
13
|
+
export * from './EmitsDomainEvents';
|
|
13
14
|
export * from './FeatureNarrativeDetected';
|
|
14
15
|
export * from './InteractionFinished';
|
|
15
16
|
export * from './InteractionStarts';
|
package/src/io/asyncMap.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param mappingFunction
|
|
6
6
|
*/
|
|
7
7
|
export function asyncMap<Item_Type, Result_Type>(items: Item_Type[], mappingFunction: (item: Item_Type) => Promise<Result_Type> | Result_Type): Promise<Result_Type[]> {
|
|
8
|
-
return items.reduce(
|
|
8
|
+
return Promise.resolve().then(() => items.reduce(
|
|
9
9
|
(previous, item) =>
|
|
10
10
|
previous.then(async (acc) => {
|
|
11
11
|
const result = await mappingFunction(item);
|
|
@@ -15,5 +15,5 @@ export function asyncMap<Item_Type, Result_Type>(items: Item_Type[], mappingFunc
|
|
|
15
15
|
return acc;
|
|
16
16
|
})
|
|
17
17
|
, Promise.resolve([])
|
|
18
|
-
);
|
|
18
|
+
));
|
|
19
19
|
}
|