@serenity-js/core 3.0.0-rc.12 → 3.0.0-rc.13
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 +8 -0
- package/lib/screenplay/actor/Actor.d.ts +19 -6
- package/lib/screenplay/actor/Actor.js +21 -8
- package/lib/screenplay/actor/Actor.js.map +1 -1
- package/lib/screenplay/actor/AnswersQuestions.d.ts +8 -1
- package/lib/screenplay/actor/CanHaveAbilities.d.ts +6 -4
- package/lib/screenplay/actor/CollectsArtifacts.d.ts +6 -4
- package/lib/screenplay/actor/PerformsActivities.d.ts +10 -2
- package/lib/screenplay/actor/UsesAbilities.d.ts +4 -4
- package/package.json +5 -26
- package/src/screenplay/actor/Actor.ts +21 -8
- package/src/screenplay/actor/AnswersQuestions.ts +9 -1
- package/src/screenplay/actor/CanHaveAbilities.ts +6 -4
- package/src/screenplay/actor/CollectsArtifacts.ts +7 -4
- package/src/screenplay/actor/PerformsActivities.ts +11 -2
- package/src/screenplay/actor/UsesAbilities.ts +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.0.0-rc.13](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.12...v3.0.0-rc.13) (2022-03-02)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @serenity-js/core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [3.0.0-rc.12](https://github.com/serenity-js/serenity-js/compare/v2.33.2...v3.0.0-rc.12) (2022-02-23)
|
|
7
15
|
|
|
8
16
|
|
|
@@ -7,6 +7,17 @@ import { CanHaveAbilities } from './CanHaveAbilities';
|
|
|
7
7
|
import { CollectsArtifacts } from './CollectsArtifacts';
|
|
8
8
|
import { PerformsActivities } from './PerformsActivities';
|
|
9
9
|
import { UsesAbilities } from './UsesAbilities';
|
|
10
|
+
/**
|
|
11
|
+
* @desc
|
|
12
|
+
* Core element of the [Screenplay Pattern](/handbook/design/screenplay-pattern.html),
|
|
13
|
+
* an {@link Actor} represents a user or an external system interacting with the system under test.
|
|
14
|
+
*
|
|
15
|
+
* @implements {PerformsActivities}
|
|
16
|
+
* @implements {UsesAbilities}
|
|
17
|
+
* @implements {CanHaveAbilities}
|
|
18
|
+
* @implements {AnswersQuestions}
|
|
19
|
+
* @implements {CollectsArtifacts}
|
|
20
|
+
*/
|
|
10
21
|
export declare class Actor implements PerformsActivities, UsesAbilities, CanHaveAbilities<Actor>, AnswersQuestions, CollectsArtifacts {
|
|
11
22
|
readonly name: string;
|
|
12
23
|
private readonly stage;
|
|
@@ -14,15 +25,17 @@ export declare class Actor implements PerformsActivities, UsesAbilities, CanHave
|
|
|
14
25
|
constructor(name: string, stage: Stage, abilities?: Map<AbilityType<Ability>, Ability>);
|
|
15
26
|
/**
|
|
16
27
|
* @desc
|
|
17
|
-
* Retrieves actor's {@link Ability}
|
|
28
|
+
* Retrieves actor's {@link Ability} of `abilityType`, or one that extends `abilityType`.
|
|
18
29
|
*
|
|
19
|
-
* Please note that this method performs an
|
|
20
|
-
*
|
|
21
|
-
* the same check when abilities are assigned to the actor
|
|
30
|
+
* Please note that this method performs an {@link instanceof} check against abilities
|
|
31
|
+
* given to this actor via {@link Actor#whoCan}.
|
|
32
|
+
* Please also note that {@link Actor#whoCan} performs the same check when abilities are assigned to the actor
|
|
33
|
+
* to ensure the actor has at most one instance of a given ability type.
|
|
22
34
|
*
|
|
23
|
-
* @param
|
|
35
|
+
* @param {AbilityType<T>} abilityType
|
|
36
|
+
* @returns {T}
|
|
24
37
|
*/
|
|
25
|
-
abilityTo<T extends Ability>(
|
|
38
|
+
abilityTo<T extends Ability>(abilityType: AbilityType<T>): T;
|
|
26
39
|
/**
|
|
27
40
|
* @desc
|
|
28
41
|
* Instructs the actor to attempt to perform a number of activities
|
|
@@ -6,6 +6,17 @@ const events_1 = require("../../events");
|
|
|
6
6
|
const model_1 = require("../../model");
|
|
7
7
|
const activities_1 = require("../activities");
|
|
8
8
|
const Question_1 = require("../Question");
|
|
9
|
+
/**
|
|
10
|
+
* @desc
|
|
11
|
+
* Core element of the [Screenplay Pattern](/handbook/design/screenplay-pattern.html),
|
|
12
|
+
* an {@link Actor} represents a user or an external system interacting with the system under test.
|
|
13
|
+
*
|
|
14
|
+
* @implements {PerformsActivities}
|
|
15
|
+
* @implements {UsesAbilities}
|
|
16
|
+
* @implements {CanHaveAbilities}
|
|
17
|
+
* @implements {AnswersQuestions}
|
|
18
|
+
* @implements {CollectsArtifacts}
|
|
19
|
+
*/
|
|
9
20
|
class Actor {
|
|
10
21
|
// todo: Actor should have execution strategies
|
|
11
22
|
// todo: the default one executes every activity
|
|
@@ -17,18 +28,20 @@ class Actor {
|
|
|
17
28
|
}
|
|
18
29
|
/**
|
|
19
30
|
* @desc
|
|
20
|
-
* Retrieves actor's {@link Ability}
|
|
31
|
+
* Retrieves actor's {@link Ability} of `abilityType`, or one that extends `abilityType`.
|
|
21
32
|
*
|
|
22
|
-
* Please note that this method performs an
|
|
23
|
-
*
|
|
24
|
-
* the same check when abilities are assigned to the actor
|
|
33
|
+
* Please note that this method performs an {@link instanceof} check against abilities
|
|
34
|
+
* given to this actor via {@link Actor#whoCan}.
|
|
35
|
+
* Please also note that {@link Actor#whoCan} performs the same check when abilities are assigned to the actor
|
|
36
|
+
* to ensure the actor has at most one instance of a given ability type.
|
|
25
37
|
*
|
|
26
|
-
* @param
|
|
38
|
+
* @param {AbilityType<T>} abilityType
|
|
39
|
+
* @returns {T}
|
|
27
40
|
*/
|
|
28
|
-
abilityTo(
|
|
29
|
-
const found = this.findAbilityTo(
|
|
41
|
+
abilityTo(abilityType) {
|
|
42
|
+
const found = this.findAbilityTo(abilityType);
|
|
30
43
|
if (!found) {
|
|
31
|
-
throw new errors_1.ConfigurationError(`${this.name} can't ${
|
|
44
|
+
throw new errors_1.ConfigurationError(`${this.name} can't ${abilityType.name} yet. ` +
|
|
32
45
|
`Did you give them the ability to do so?`);
|
|
33
46
|
}
|
|
34
47
|
return found;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Actor.js","sourceRoot":"","sources":["../../../src/screenplay/actor/Actor.ts"],"names":[],"mappings":";;;AAAA,yCAAwE;AACxE,yCAAgE;AAChE,uCAA6C;AAG7C,8CAAgD;AAEhD,0CAAuC;AAOvC,MAAa,KAAK;IAOd,+CAA+C;IAC/C,gDAAgD;IAChD,oEAAoE;IAEpE,YACoB,IAAY,EACX,KAAY,EACZ,YAAgD,IAAI,GAAG,EAAiC;QAFzF,SAAI,GAAJ,IAAI,CAAQ;QACX,UAAK,GAAL,KAAK,CAAO;QACZ,cAAS,GAAT,SAAS,CAA+E;IAE7G,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"Actor.js","sourceRoot":"","sources":["../../../src/screenplay/actor/Actor.ts"],"names":[],"mappings":";;;AAAA,yCAAwE;AACxE,yCAAgE;AAChE,uCAA6C;AAG7C,8CAAgD;AAEhD,0CAAuC;AAOvC;;;;;;;;;;GAUG;AACH,MAAa,KAAK;IAOd,+CAA+C;IAC/C,gDAAgD;IAChD,oEAAoE;IAEpE,YACoB,IAAY,EACX,KAAY,EACZ,YAAgD,IAAI,GAAG,EAAiC;QAFzF,SAAI,GAAJ,IAAI,CAAQ;QACX,UAAK,GAAL,KAAK,CAAO;QACZ,cAAS,GAAT,SAAS,CAA+E;IAE7G,CAAC;IAED;;;;;;;;;;;OAWG;IACH,SAAS,CAAoB,WAA2B;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAE9C,IAAI,CAAE,KAAK,EAAE;YACT,MAAM,IAAI,2BAAkB,CAAC,GAAI,IAAI,CAAC,IAAK,UAAW,WAAW,CAAC,IAAK,QAAQ;gBAC3E,yCAAyC,C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AAW,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,OAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC;QAEhF,OAAO,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC;aAC/B,MAAM,CAAC,2BAA2B,CAAuB,CAAC;IACnE,CAAC;IAED;;;OAGG;IACK,aAAa,CAAoB,WAA2B;QAChE,KAAK,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE;YAClD,IAAI,OAAO,YAAY,WAAW,EAAE;gBAChC,OAAO,OAAY,CAAC;aACvB;SACJ;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;;;;;;;;OASG;IACK,QAAQ,CAAC,SAAwB;QACrC,OAAO,OAAO,SAAS,KAAK,QAAQ;YAChC,CAAC,CAAC,IAAI,YAAI,CAAC,SAAS,CAAC;YACrB,CAAC,CAAC,SAAS,CAAC;IACpB,CAAC;CACJ;AAtOD,sBAsOC"}
|
|
@@ -6,5 +6,12 @@ import { Answerable } from '../Answerable';
|
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
8
|
export interface AnswersQuestions {
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @desc
|
|
11
|
+
* Makes the {@link Actor} evaluate an {@link Answerable}
|
|
12
|
+
* and return the value it holds.
|
|
13
|
+
*
|
|
14
|
+
* @type {function<T>>(answerable: Answerable<T>): Promise<T>}
|
|
15
|
+
*/
|
|
16
|
+
answer: <T>(answerable: Answerable<T>) => Promise<T>;
|
|
10
17
|
}
|
|
@@ -2,14 +2,16 @@ import { Ability } from '../Ability';
|
|
|
2
2
|
import { UsesAbilities } from './UsesAbilities';
|
|
3
3
|
/**
|
|
4
4
|
* @desc
|
|
5
|
-
* Enables the {@link Actor} to have an {@link Ability} or
|
|
5
|
+
* Enables the {@link Actor} to have an {@link Ability} or abilities to perform some {@link Activity}.
|
|
6
6
|
*
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
9
|
export interface CanHaveAbilities<Returned_Type = UsesAbilities> {
|
|
10
10
|
/**
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
11
|
+
* @desc
|
|
12
|
+
* Assigns an {@link Ability} or several abilities to the {@link Actor}
|
|
13
|
+
*
|
|
14
|
+
* @type {function(...abilities: Ability[]): Returned_Type}
|
|
13
15
|
*/
|
|
14
|
-
whoCan(...abilities: Ability[])
|
|
16
|
+
whoCan: (...abilities: Ability[]) => Returned_Type;
|
|
15
17
|
}
|
|
@@ -8,10 +8,12 @@ import { Artifact, Name } from '../../model';
|
|
|
8
8
|
export interface CollectsArtifacts {
|
|
9
9
|
/**
|
|
10
10
|
* @desc
|
|
11
|
-
*
|
|
11
|
+
* Makes the {@link Actor} collect an {@link Artifact} so that it can be included in the test report.
|
|
12
12
|
*
|
|
13
|
-
* @
|
|
14
|
-
*
|
|
13
|
+
* @type {function(artifact: Artifact, name?: Name): void}
|
|
14
|
+
*
|
|
15
|
+
* @see {@link Artifact} - The artifact to be collected, such as {@link JSONData}
|
|
16
|
+
* @see {@link Name} - The name of the artifact to make it easy to recognise in the test report
|
|
15
17
|
*/
|
|
16
|
-
collect(artifact: Artifact, name?: Name)
|
|
18
|
+
collect: (artifact: Artifact, name?: Name) => void;
|
|
17
19
|
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { Activity } from '../Activity';
|
|
2
2
|
/**
|
|
3
3
|
* @desc
|
|
4
|
-
* Enables the {@link Actor} to perform an {@link Activity},
|
|
4
|
+
* Enables the {@link Actor} to perform an {@link Activity},
|
|
5
|
+
* such as a {@link Task} or an {@link Interaction}
|
|
5
6
|
*
|
|
6
7
|
* @public
|
|
7
8
|
*/
|
|
8
9
|
export interface PerformsActivities {
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* @desc
|
|
12
|
+
* Makes the {@link Actor} attempt to perform a sequence of activities.
|
|
13
|
+
*
|
|
14
|
+
* @type {function(...activities: Activity[]): Promise<void>}
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
attemptsTo: (...activities: Activity[]) => Promise<void>;
|
|
10
18
|
}
|
|
@@ -9,10 +9,10 @@ import { AbilityType } from '../AbilityType';
|
|
|
9
9
|
export interface UsesAbilities {
|
|
10
10
|
/**
|
|
11
11
|
* @desc
|
|
12
|
-
*
|
|
12
|
+
* Provides access to the {@link Actor}'s {@link Ability} to do something
|
|
13
13
|
*
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
14
|
+
* @type {function<T extends Ability>(doSomething: AbilityType<T>): T}
|
|
15
|
+
* @public
|
|
16
16
|
*/
|
|
17
|
-
abilityTo<T extends Ability>(doSomething: AbilityType<T>)
|
|
17
|
+
abilityTo: <T extends Ability>(doSomething: AbilityType<T>) => T;
|
|
18
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/core",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.13",
|
|
4
4
|
"description": "Serenity/JS Screenplay, reporting engine and core interfaces.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"clean": "rimraf .nyc_output lib target",
|
|
30
30
|
"lint": "eslint --ext ts --config ../../.eslintrc.yml .",
|
|
31
31
|
"lint:fix": "npm run lint -- --fix",
|
|
32
|
-
"test": "nyc
|
|
32
|
+
"test": "nyc mocha --config ../../.mocharc.yml 'spec/**/*.spec.*'",
|
|
33
33
|
"compile": "tsc --project tsconfig.json",
|
|
34
34
|
"site": "esdoc -c .esdoc.js"
|
|
35
35
|
},
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
},
|
|
63
63
|
"repository": {
|
|
64
64
|
"type": "git",
|
|
65
|
-
"url": "https://github.com/serenity-js/serenity-js.git"
|
|
65
|
+
"url": "https://github.com/serenity-js/serenity-js.git",
|
|
66
|
+
"directory": "packages/core"
|
|
66
67
|
},
|
|
67
68
|
"bugs": {
|
|
68
69
|
"url": "https://github.com/serenity-js/serenity-js/issues"
|
|
@@ -71,27 +72,5 @@
|
|
|
71
72
|
"node": "^14 || ^16",
|
|
72
73
|
"npm": "^6 || ^7 || ^8"
|
|
73
74
|
},
|
|
74
|
-
"
|
|
75
|
-
"include": [
|
|
76
|
-
"src/**/*.ts"
|
|
77
|
-
],
|
|
78
|
-
"exclude": [
|
|
79
|
-
"src/**/*.d.ts",
|
|
80
|
-
"lib",
|
|
81
|
-
"spec",
|
|
82
|
-
"node_modules"
|
|
83
|
-
],
|
|
84
|
-
"extension": [
|
|
85
|
-
".ts"
|
|
86
|
-
],
|
|
87
|
-
"require": [
|
|
88
|
-
"ts-node/register"
|
|
89
|
-
],
|
|
90
|
-
"reporter": [
|
|
91
|
-
"json"
|
|
92
|
-
],
|
|
93
|
-
"cache": true,
|
|
94
|
-
"all": true
|
|
95
|
-
},
|
|
96
|
-
"gitHead": "5bb8519ef9a91180860675384cfb99ad793a4263"
|
|
75
|
+
"gitHead": "9fb7df72c7f33cb10504843db890f7855b8c355a"
|
|
97
76
|
}
|
|
@@ -12,6 +12,17 @@ import { CollectsArtifacts } from './CollectsArtifacts';
|
|
|
12
12
|
import { PerformsActivities } from './PerformsActivities';
|
|
13
13
|
import { UsesAbilities } from './UsesAbilities';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* @desc
|
|
17
|
+
* Core element of the [Screenplay Pattern](/handbook/design/screenplay-pattern.html),
|
|
18
|
+
* an {@link Actor} represents a user or an external system interacting with the system under test.
|
|
19
|
+
*
|
|
20
|
+
* @implements {PerformsActivities}
|
|
21
|
+
* @implements {UsesAbilities}
|
|
22
|
+
* @implements {CanHaveAbilities}
|
|
23
|
+
* @implements {AnswersQuestions}
|
|
24
|
+
* @implements {CollectsArtifacts}
|
|
25
|
+
*/
|
|
15
26
|
export class Actor implements
|
|
16
27
|
PerformsActivities,
|
|
17
28
|
UsesAbilities,
|
|
@@ -32,19 +43,21 @@ export class Actor implements
|
|
|
32
43
|
|
|
33
44
|
/**
|
|
34
45
|
* @desc
|
|
35
|
-
* Retrieves actor's {@link Ability}
|
|
46
|
+
* Retrieves actor's {@link Ability} of `abilityType`, or one that extends `abilityType`.
|
|
36
47
|
*
|
|
37
|
-
* Please note that this method performs an
|
|
38
|
-
*
|
|
39
|
-
* the same check when abilities are assigned to the actor
|
|
48
|
+
* Please note that this method performs an {@link instanceof} check against abilities
|
|
49
|
+
* given to this actor via {@link Actor#whoCan}.
|
|
50
|
+
* Please also note that {@link Actor#whoCan} performs the same check when abilities are assigned to the actor
|
|
51
|
+
* to ensure the actor has at most one instance of a given ability type.
|
|
40
52
|
*
|
|
41
|
-
* @param
|
|
53
|
+
* @param {AbilityType<T>} abilityType
|
|
54
|
+
* @returns {T}
|
|
42
55
|
*/
|
|
43
|
-
abilityTo<T extends Ability>(
|
|
44
|
-
const found = this.findAbilityTo(
|
|
56
|
+
abilityTo<T extends Ability>(abilityType: AbilityType<T>): T {
|
|
57
|
+
const found = this.findAbilityTo(abilityType);
|
|
45
58
|
|
|
46
59
|
if (! found) {
|
|
47
|
-
throw new ConfigurationError(`${ this.name } can't ${
|
|
60
|
+
throw new ConfigurationError(`${ this.name } can't ${ abilityType.name } yet. ` +
|
|
48
61
|
`Did you give them the ability to do so?`);
|
|
49
62
|
}
|
|
50
63
|
|
|
@@ -7,5 +7,13 @@ import { Answerable } from '../Answerable';
|
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
9
|
export interface AnswersQuestions {
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @desc
|
|
13
|
+
* Makes the {@link Actor} evaluate an {@link Answerable}
|
|
14
|
+
* and return the value it holds.
|
|
15
|
+
*
|
|
16
|
+
* @type {function<T>>(answerable: Answerable<T>): Promise<T>}
|
|
17
|
+
*/
|
|
18
|
+
answer: <T>(answerable: Answerable<T>) => Promise<T>;
|
|
11
19
|
}
|
|
@@ -3,14 +3,16 @@ import { UsesAbilities } from './UsesAbilities';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @desc
|
|
6
|
-
* Enables the {@link Actor} to have an {@link Ability} or
|
|
6
|
+
* Enables the {@link Actor} to have an {@link Ability} or abilities to perform some {@link Activity}.
|
|
7
7
|
*
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
10
|
export interface CanHaveAbilities<Returned_Type = UsesAbilities> {
|
|
11
11
|
/**
|
|
12
|
-
* @
|
|
13
|
-
* @
|
|
12
|
+
* @desc
|
|
13
|
+
* Assigns an {@link Ability} or several abilities to the {@link Actor}
|
|
14
|
+
*
|
|
15
|
+
* @type {function(...abilities: Ability[]): Returned_Type}
|
|
14
16
|
*/
|
|
15
|
-
whoCan(...abilities: Ability[])
|
|
17
|
+
whoCan: (...abilities: Ability[]) => Returned_Type;
|
|
16
18
|
}
|
|
@@ -7,12 +7,15 @@ import { Artifact, Name } from '../../model';
|
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
9
|
export interface CollectsArtifacts {
|
|
10
|
+
|
|
10
11
|
/**
|
|
11
12
|
* @desc
|
|
12
|
-
*
|
|
13
|
+
* Makes the {@link Actor} collect an {@link Artifact} so that it can be included in the test report.
|
|
14
|
+
*
|
|
15
|
+
* @type {function(artifact: Artifact, name?: Name): void}
|
|
13
16
|
*
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
17
|
+
* @see {@link Artifact} - The artifact to be collected, such as {@link JSONData}
|
|
18
|
+
* @see {@link Name} - The name of the artifact to make it easy to recognise in the test report
|
|
16
19
|
*/
|
|
17
|
-
collect(artifact: Artifact, name?: Name)
|
|
20
|
+
collect: (artifact: Artifact, name?: Name) => void;
|
|
18
21
|
}
|
|
@@ -2,10 +2,19 @@ import { Activity } from '../Activity';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @desc
|
|
5
|
-
* Enables the {@link Actor} to perform an {@link Activity},
|
|
5
|
+
* Enables the {@link Actor} to perform an {@link Activity},
|
|
6
|
+
* such as a {@link Task} or an {@link Interaction}
|
|
6
7
|
*
|
|
7
8
|
* @public
|
|
8
9
|
*/
|
|
9
10
|
export interface PerformsActivities {
|
|
10
|
-
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @desc
|
|
14
|
+
* Makes the {@link Actor} attempt to perform a sequence of activities.
|
|
15
|
+
*
|
|
16
|
+
* @type {function(...activities: Activity[]): Promise<void>}
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
attemptsTo: (...activities: Activity[]) => Promise<void>;
|
|
11
20
|
}
|
|
@@ -11,10 +11,10 @@ export interface UsesAbilities {
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @desc
|
|
14
|
-
*
|
|
14
|
+
* Provides access to the {@link Actor}'s {@link Ability} to do something
|
|
15
15
|
*
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
16
|
+
* @type {function<T extends Ability>(doSomething: AbilityType<T>): T}
|
|
17
|
+
* @public
|
|
18
18
|
*/
|
|
19
|
-
abilityTo<T extends Ability>(doSomething: AbilityType<T>)
|
|
19
|
+
abilityTo: <T extends Ability>(doSomething: AbilityType<T>) => T;
|
|
20
20
|
}
|