@serenity-js/core 3.8.0 → 3.9.1
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 +23 -0
- package/lib/model/CorrelationId.js +1 -1
- package/lib/model/CorrelationId.js.map +1 -1
- package/lib/screenplay/Question.d.ts +18 -5
- package/lib/screenplay/Question.d.ts.map +1 -1
- package/lib/screenplay/Question.js +22 -20
- package/lib/screenplay/Question.js.map +1 -1
- package/lib/screenplay/questions/MetaQuestion.d.ts +8 -7
- package/lib/screenplay/questions/MetaQuestion.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/model/CorrelationId.ts +1 -1
- package/src/screenplay/Question.ts +67 -8
- package/src/screenplay/questions/MetaQuestion.ts +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
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.9.1](https://github.com/serenity-js/serenity-js/compare/v3.9.0...v3.9.1) (2023-08-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **core:** support iOS window handles in CorrelationId ([4e15e1a](https://github.com/serenity-js/serenity-js/commit/4e15e1aac28bf2952bf578edbf972968c6892270))
|
|
12
|
+
* **deps:** update dependency @paralleldrive/cuid2 to ^2.2.2 ([1bec9da](https://github.com/serenity-js/serenity-js/commit/1bec9da27a44dd6f7fed3c68c03e346d87e77cbd))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# [3.9.0](https://github.com/serenity-js/serenity-js/compare/v3.8.0...v3.9.0) (2023-08-04)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* **core:** introduced MetaQuestionAdapter ([b6676fd](https://github.com/serenity-js/serenity-js/commit/b6676fd6ee2a2f67fd56e0642b3af72027d50a75))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
# [3.8.0](https://github.com/serenity-js/serenity-js/compare/v3.7.2...v3.8.0) (2023-08-01)
|
|
7
30
|
|
|
8
31
|
|
|
@@ -13,7 +13,7 @@ class CorrelationId extends tiny_types_1.TinyType {
|
|
|
13
13
|
constructor(value) {
|
|
14
14
|
super();
|
|
15
15
|
this.value = value;
|
|
16
|
-
(0, tiny_types_1.ensure)(this.constructor.name, value, (0, tiny_types_1.or)(isACuid(), (0, tiny_types_1.matches)(/^[\
|
|
16
|
+
(0, tiny_types_1.ensure)(this.constructor.name, value, (0, tiny_types_1.or)(isACuid(), (0, tiny_types_1.matches)(/^[\d.A-Za-z-]+$/)));
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
exports.CorrelationId = CorrelationId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CorrelationId.js","sourceRoot":"","sources":["../../src/model/CorrelationId.ts"],"names":[],"mappings":";;;AAAA,gDAAwD;AACxD,2CAAsE;AAEtE,MAAa,aAAc,SAAQ,qBAAQ;IACvC,MAAM,CAAC,QAAQ,CAAC,CAAS;QACrB,OAAO,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,MAAM;QACT,OAAO,IAAI,aAAa,CAAC,IAAA,gBAAQ,GAAE,CAAC,CAAC;IACzC,CAAC;IAED,YAA4B,KAAa;QACrC,KAAK,EAAE,CAAC;QADgB,UAAK,GAAL,KAAK,CAAQ;QAErC,IAAA,mBAAM,EAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,IAAA,eAAE,EAAC,OAAO,EAAE,EAAE,IAAA,oBAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"CorrelationId.js","sourceRoot":"","sources":["../../src/model/CorrelationId.ts"],"names":[],"mappings":";;;AAAA,gDAAwD;AACxD,2CAAsE;AAEtE,MAAa,aAAc,SAAQ,qBAAQ;IACvC,MAAM,CAAC,QAAQ,CAAC,CAAS;QACrB,OAAO,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,MAAM;QACT,OAAO,IAAI,aAAa,CAAC,IAAA,gBAAQ,GAAE,CAAC,CAAC;IACzC,CAAC;IAED,YAA4B,KAAa;QACrC,KAAK,EAAE,CAAC;QADgB,UAAK,GAAL,KAAK,CAAQ;QAErC,IAAA,mBAAM,EAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,IAAA,eAAE,EAAC,OAAO,EAAE,EAAE,IAAA,oBAAO,EAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACpF,CAAC;CACJ;AAbD,sCAaC;AAED,SAAS,OAAO;IACZ,OAAO,sBAAS,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as util from 'util';
|
|
3
|
+
import type { FileSystemLocation } from '../io';
|
|
3
4
|
import type { UsesAbilities } from './abilities';
|
|
4
5
|
import type { Answerable } from './Answerable';
|
|
5
6
|
import { Interaction } from './Interaction';
|
|
6
7
|
import type { Optional } from './Optional';
|
|
7
8
|
import type { AnswersQuestions } from './questions/AnswersQuestions';
|
|
9
|
+
import type { MetaQuestion } from './questions/MetaQuestion';
|
|
8
10
|
import type { RecursivelyAnswered } from './RecursivelyAnswered';
|
|
9
11
|
import type { WithAnswerableProperties } from './WithAnswerableProperties';
|
|
10
12
|
/**
|
|
@@ -117,8 +119,10 @@ export declare abstract class Question<T> {
|
|
|
117
119
|
*
|
|
118
120
|
* @param description
|
|
119
121
|
* @param body
|
|
122
|
+
* @param [metaQuestionBody]
|
|
120
123
|
*/
|
|
121
|
-
static about<
|
|
124
|
+
static about<Answer_Type, Supported_Context_Type>(description: string, body: (actor: AnswersQuestions & UsesAbilities) => Promise<Answer_Type> | Answer_Type, metaQuestionBody: (answerable: Answerable<Supported_Context_Type>) => Question<Promise<Answer_Type>> | Question<Answer_Type>): MetaQuestionAdapter<Supported_Context_Type, Awaited<Answer_Type>>;
|
|
125
|
+
static about<Answer_Type>(description: string, body: (actor: AnswersQuestions & UsesAbilities) => Promise<Answer_Type> | Answer_Type): QuestionAdapter<Awaited<Answer_Type>>;
|
|
122
126
|
/**
|
|
123
127
|
* Generates a {@apilink QuestionAdapter} that recursively resolves
|
|
124
128
|
* any {@apilink Answerable} fields of the provided object,
|
|
@@ -244,15 +248,24 @@ export type QuestionAdapterFieldDecorator<Original_Type> = {
|
|
|
244
248
|
*
|
|
245
249
|
* @group Questions
|
|
246
250
|
*/
|
|
247
|
-
export type QuestionAdapter<
|
|
251
|
+
export type QuestionAdapter<Answer_Type> = Question<Promise<Answer_Type>> & Interaction & {
|
|
248
252
|
isPresent(): Question<Promise<boolean>>;
|
|
249
|
-
} & QuestionAdapterFieldDecorator<
|
|
250
|
-
/**
|
|
253
|
+
} & QuestionAdapterFieldDecorator<Answer_Type>;
|
|
254
|
+
/**
|
|
255
|
+
* An extension of {@apilink QuestionAdapter}, that in addition to proxying methods and fields
|
|
256
|
+
* of the wrapped object can also act as a {@apilink MetaQuestion}.
|
|
257
|
+
*
|
|
258
|
+
* @group Questions
|
|
259
|
+
*/
|
|
260
|
+
export type MetaQuestionAdapter<Context_Type, Answer_Type> = QuestionAdapter<Answer_Type> & MetaQuestion<Context_Type, Answer_Type>;
|
|
261
|
+
/**
|
|
262
|
+
* @package
|
|
263
|
+
*/
|
|
251
264
|
declare class QuestionStatement<Answer_Type> extends Interaction implements Question<Promise<Answer_Type>>, Optional {
|
|
252
265
|
private subject;
|
|
253
266
|
private readonly body;
|
|
254
267
|
private answer;
|
|
255
|
-
constructor(subject: string, body: (actor: AnswersQuestions & UsesAbilities, ...Parameters: any[]) => Promise<Answer_Type> | Answer_Type);
|
|
268
|
+
constructor(subject: string, body: (actor: AnswersQuestions & UsesAbilities, ...Parameters: any[]) => Promise<Answer_Type> | Answer_Type, location?: FileSystemLocation);
|
|
256
269
|
/**
|
|
257
270
|
* Returns a Question that resolves to `true` if resolving the {@apilink QuestionStatement}
|
|
258
271
|
* returns a value other than `null` or `undefined`, and doesn't throw errors.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Question.d.ts","sourceRoot":"","sources":["../../src/screenplay/Question.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"Question.d.ts","sourceRoot":"","sources":["../../src/screenplay/Question.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FG;AACH,8BAAsB,QAAQ,CAAC,CAAC;IAE5B;;;;;;;;;;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I,CAAC;IAIvE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,sBAAsB,EAAE,OAAO,EAAE,OAAO,IAAI,CAAC,OAAO,GAAG,MAAM;IAIhH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKzB,QAAQ,IAAI,MAAM;IAI3B,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;CAWzF"}
|
|
@@ -126,23 +126,11 @@ const Unanswered_1 = require("./questions/Unanswered");
|
|
|
126
126
|
* @group Screenplay Pattern
|
|
127
127
|
*/
|
|
128
128
|
class Question {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
* ```ts
|
|
135
|
-
* import { Question } from '@serenity-js/core'
|
|
136
|
-
*
|
|
137
|
-
* const EnvVariable = (name: string) =>
|
|
138
|
-
* Question.about(`the ${ name } env variable`, actor => process.env[name])
|
|
139
|
-
* ```
|
|
140
|
-
*
|
|
141
|
-
* @param description
|
|
142
|
-
* @param body
|
|
143
|
-
*/
|
|
144
|
-
static about(description, body) {
|
|
145
|
-
return Question.createAdapter(new QuestionStatement(description, body));
|
|
129
|
+
static about(description, body, metaQuestionBody) {
|
|
130
|
+
const statement = typeof metaQuestionBody === 'function'
|
|
131
|
+
? new MetaQuestionStatement(description, body, metaQuestionBody)
|
|
132
|
+
: new QuestionStatement(description, body);
|
|
133
|
+
return Question.createAdapter(statement);
|
|
146
134
|
}
|
|
147
135
|
/**
|
|
148
136
|
* Generates a {@apilink QuestionAdapter} that recursively resolves
|
|
@@ -342,10 +330,12 @@ class Question {
|
|
|
342
330
|
}
|
|
343
331
|
}
|
|
344
332
|
exports.Question = Question;
|
|
345
|
-
/**
|
|
333
|
+
/**
|
|
334
|
+
* @package
|
|
335
|
+
*/
|
|
346
336
|
class QuestionStatement extends Interaction_1.Interaction {
|
|
347
|
-
constructor(subject, body) {
|
|
348
|
-
super(subject,
|
|
337
|
+
constructor(subject, body, location = QuestionStatement.callerLocation(4)) {
|
|
338
|
+
super(subject, location);
|
|
349
339
|
this.subject = subject;
|
|
350
340
|
this.body = body;
|
|
351
341
|
this.answer = new Unanswered_1.Unanswered();
|
|
@@ -384,6 +374,18 @@ class QuestionStatement extends Interaction_1.Interaction {
|
|
|
384
374
|
});
|
|
385
375
|
}
|
|
386
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* @package
|
|
379
|
+
*/
|
|
380
|
+
class MetaQuestionStatement extends QuestionStatement {
|
|
381
|
+
constructor(subject, body, metaQuestionBody) {
|
|
382
|
+
super(subject, body);
|
|
383
|
+
this.metaQuestionBody = metaQuestionBody;
|
|
384
|
+
}
|
|
385
|
+
of(answerable) {
|
|
386
|
+
return Question.about((0, io_1.d) `${this.toString()} of ${answerable}`, actor => actor.answer(this.metaQuestionBody(answerable)));
|
|
387
|
+
}
|
|
388
|
+
}
|
|
387
389
|
/**
|
|
388
390
|
* @package
|
|
389
391
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Question.js","sourceRoot":"","sources":["../../src/screenplay/Question.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAkD;AAClD,2CAA6B,CAAC,2CAA2C;AAEzE,sCAAuC;
|
|
1
|
+
{"version":3,"file":"Question.js","sourceRoot":"","sources":["../../src/screenplay/Question.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAkD;AAClD,2CAA6B,CAAC,2CAA2C;AAEzE,sCAAuC;AAEvC,8BAA8C;AAG9C,+CAA4C;AAI5C,uDAAoD;AAIpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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|
3
3
|
/**
|
|
4
|
-
* A
|
|
5
|
-
*
|
|
4
|
+
* A meta-question is a {@apilink Question} that can be answered
|
|
5
|
+
* in the context of another {@apilink Answerable},
|
|
6
|
+
* typically to transform its value.
|
|
6
7
|
*
|
|
7
|
-
* For example, the question {@apilink Text.of}
|
|
8
|
-
*
|
|
8
|
+
* For example, the question {@apilink Text.of} can be answered in the context
|
|
9
|
+
* of a {@apilink PageElement} to return its text content.
|
|
9
10
|
*
|
|
10
11
|
* {@apilink MetaQuestion|Meta questions} are typically used when filtering a {@apilink List}.
|
|
11
12
|
*
|
|
@@ -14,14 +15,14 @@ import type { Question } from '../Question';
|
|
|
14
15
|
*
|
|
15
16
|
* @group Questions
|
|
16
17
|
*/
|
|
17
|
-
export interface MetaQuestion<
|
|
18
|
+
export interface MetaQuestion<Supported_Context_Type, Answer_Type> {
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
+
* Answers the given `MetaQuestion` in the context of another {@apilink Answerable}.
|
|
20
21
|
*
|
|
21
22
|
* #### Learn more
|
|
22
23
|
* - {@apilink List}
|
|
23
24
|
*/
|
|
24
|
-
of(
|
|
25
|
+
of(context: Answerable<Supported_Context_Type>): Question<Promise<Answer_Type>> | Question<Answer_Type>;
|
|
25
26
|
/**
|
|
26
27
|
* Human-readable description of this {@apilink MetaQuestion},
|
|
27
28
|
* typically involving the description of the subject.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetaQuestion.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/MetaQuestion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"MetaQuestion.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/MetaQuestion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,YAAY,CAAC,sBAAsB,EAAE,WAAW;IAE7D;;;;;OAKG;IACH,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,sBAAsB,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;IAExG;;;;;;OAMG;IACH,QAAQ,IAAI,MAAM,CAAC;CACtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.1",
|
|
4
4
|
"description": "Serenity/JS Screenplay, reporting engine and core interfaces.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"compile": "rimraf lib && tsc --project tsconfig.build.json"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@paralleldrive/cuid2": "^2.2.
|
|
35
|
+
"@paralleldrive/cuid2": "^2.2.2",
|
|
36
36
|
"chalk": "^4.1.2",
|
|
37
37
|
"diff": "^5.1.0",
|
|
38
38
|
"error-stack-parser": "2.1.4",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@types/validate-npm-package-name": "^4.0.0",
|
|
55
55
|
"assertion-error-formatter": "^3.0.0",
|
|
56
56
|
"c8": "8.0.1",
|
|
57
|
-
"memfs": "^4.2.
|
|
57
|
+
"memfs": "^4.2.1",
|
|
58
58
|
"mocha": "^10.2.0",
|
|
59
59
|
"mocha-multi": "^1.1.7",
|
|
60
60
|
"ts-node": "^10.9.1",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"engines": {
|
|
72
72
|
"node": "^16.13 || ^18.12 || ^20"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "237e0291a7eca71e5f5c0777e1f9d637e8622113"
|
|
75
75
|
}
|
|
@@ -12,7 +12,7 @@ export class CorrelationId extends TinyType {
|
|
|
12
12
|
|
|
13
13
|
constructor(public readonly value: string) {
|
|
14
14
|
super();
|
|
15
|
-
ensure(this.constructor.name, value, or(isACuid(), matches(/^[\
|
|
15
|
+
ensure(this.constructor.name, value, or(isACuid(), matches(/^[\d.A-Za-z-]+$/)));
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -2,12 +2,14 @@ import { isRecord } from 'tiny-types/lib/objects';
|
|
|
2
2
|
import * as util from 'util'; // eslint-disable-line unicorn/import-style
|
|
3
3
|
|
|
4
4
|
import { LogicError } from '../errors';
|
|
5
|
-
import {
|
|
5
|
+
import type { FileSystemLocation } from '../io';
|
|
6
|
+
import { d, f, inspectedObject } from '../io';
|
|
6
7
|
import type { UsesAbilities } from './abilities';
|
|
7
8
|
import type { Answerable } from './Answerable';
|
|
8
9
|
import { Interaction } from './Interaction';
|
|
9
10
|
import type { Optional } from './Optional';
|
|
10
11
|
import type { AnswersQuestions } from './questions/AnswersQuestions';
|
|
12
|
+
import type { MetaQuestion } from './questions/MetaQuestion';
|
|
11
13
|
import { Unanswered } from './questions/Unanswered';
|
|
12
14
|
import type { RecursivelyAnswered } from './RecursivelyAnswered';
|
|
13
15
|
import type { WithAnswerableProperties } from './WithAnswerableProperties';
|
|
@@ -123,9 +125,30 @@ export abstract class Question<T> {
|
|
|
123
125
|
*
|
|
124
126
|
* @param description
|
|
125
127
|
* @param body
|
|
128
|
+
* @param [metaQuestionBody]
|
|
126
129
|
*/
|
|
127
|
-
static about<
|
|
128
|
-
|
|
130
|
+
static about<Answer_Type, Supported_Context_Type>(
|
|
131
|
+
description: string,
|
|
132
|
+
body: (actor: AnswersQuestions & UsesAbilities) => Promise<Answer_Type> | Answer_Type,
|
|
133
|
+
metaQuestionBody: (answerable: Answerable<Supported_Context_Type>) => Question<Promise<Answer_Type>> | Question<Answer_Type>,
|
|
134
|
+
): MetaQuestionAdapter<Supported_Context_Type, Awaited<Answer_Type>>
|
|
135
|
+
|
|
136
|
+
static about<Answer_Type>(
|
|
137
|
+
description: string,
|
|
138
|
+
body: (actor: AnswersQuestions & UsesAbilities) => Promise<Answer_Type> | Answer_Type
|
|
139
|
+
): QuestionAdapter<Awaited<Answer_Type>>
|
|
140
|
+
|
|
141
|
+
static about<Answer_Type, Supported_Context_Type extends Answerable<any>>(
|
|
142
|
+
description: string,
|
|
143
|
+
body: (actor: AnswersQuestions & UsesAbilities) => Promise<Answer_Type> | Answer_Type,
|
|
144
|
+
metaQuestionBody?: (answerable: Supported_Context_Type) => QuestionAdapter<Answer_Type>,
|
|
145
|
+
): any
|
|
146
|
+
{
|
|
147
|
+
const statement = typeof metaQuestionBody === 'function'
|
|
148
|
+
? new MetaQuestionStatement(description, body, metaQuestionBody)
|
|
149
|
+
: new QuestionStatement(description, body);
|
|
150
|
+
|
|
151
|
+
return Question.createAdapter(statement);
|
|
129
152
|
}
|
|
130
153
|
|
|
131
154
|
/**
|
|
@@ -429,13 +452,25 @@ export type QuestionAdapterFieldDecorator<Original_Type> = {
|
|
|
429
452
|
*
|
|
430
453
|
* @group Questions
|
|
431
454
|
*/
|
|
432
|
-
export type QuestionAdapter<
|
|
433
|
-
& Question<Promise<
|
|
455
|
+
export type QuestionAdapter<Answer_Type> =
|
|
456
|
+
& Question<Promise<Answer_Type>>
|
|
434
457
|
& Interaction
|
|
435
458
|
& { isPresent(): Question<Promise<boolean>>; } // more specialised Optional
|
|
436
|
-
& QuestionAdapterFieldDecorator<
|
|
459
|
+
& QuestionAdapterFieldDecorator<Answer_Type>;
|
|
437
460
|
|
|
438
|
-
/**
|
|
461
|
+
/**
|
|
462
|
+
* An extension of {@apilink QuestionAdapter}, that in addition to proxying methods and fields
|
|
463
|
+
* of the wrapped object can also act as a {@apilink MetaQuestion}.
|
|
464
|
+
*
|
|
465
|
+
* @group Questions
|
|
466
|
+
*/
|
|
467
|
+
export type MetaQuestionAdapter<Context_Type, Answer_Type> =
|
|
468
|
+
& QuestionAdapter<Answer_Type>
|
|
469
|
+
& MetaQuestion<Context_Type, Answer_Type>
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* @package
|
|
473
|
+
*/
|
|
439
474
|
class QuestionStatement<Answer_Type> extends Interaction implements Question<Promise<Answer_Type>>, Optional {
|
|
440
475
|
|
|
441
476
|
private answer: Answer_Type | Unanswered = new Unanswered();
|
|
@@ -443,8 +478,9 @@ class QuestionStatement<Answer_Type> extends Interaction implements Question<Pro
|
|
|
443
478
|
constructor(
|
|
444
479
|
private subject: string,
|
|
445
480
|
private readonly body: (actor: AnswersQuestions & UsesAbilities, ...Parameters) => Promise<Answer_Type> | Answer_Type,
|
|
481
|
+
location: FileSystemLocation = QuestionStatement.callerLocation(4),
|
|
446
482
|
) {
|
|
447
|
-
super(subject,
|
|
483
|
+
super(subject, location);
|
|
448
484
|
}
|
|
449
485
|
|
|
450
486
|
/**
|
|
@@ -490,6 +526,29 @@ class QuestionStatement<Answer_Type> extends Interaction implements Question<Pro
|
|
|
490
526
|
}
|
|
491
527
|
}
|
|
492
528
|
|
|
529
|
+
/**
|
|
530
|
+
* @package
|
|
531
|
+
*/
|
|
532
|
+
class MetaQuestionStatement<Answer_Type, Supported_Context_Type extends Answerable<any>>
|
|
533
|
+
extends QuestionStatement<Answer_Type>
|
|
534
|
+
implements MetaQuestion<Supported_Context_Type, Answer_Type>
|
|
535
|
+
{
|
|
536
|
+
constructor(
|
|
537
|
+
subject: string,
|
|
538
|
+
body: (actor: AnswersQuestions & UsesAbilities, ...Parameters) => Promise<Answer_Type> | Answer_Type,
|
|
539
|
+
private readonly metaQuestionBody: (answerable: Answerable<Supported_Context_Type>) => QuestionAdapter<Answer_Type>,
|
|
540
|
+
) {
|
|
541
|
+
super(subject, body);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
of(answerable: Answerable<Supported_Context_Type>): Question<Promise<Answer_Type>> | Question<Answer_Type> {
|
|
545
|
+
return Question.about(
|
|
546
|
+
d`${ this.toString() } of ${ answerable }`,
|
|
547
|
+
actor => actor.answer(this.metaQuestionBody(answerable))
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
493
552
|
/**
|
|
494
553
|
* @package
|
|
495
554
|
*/
|
|
@@ -2,11 +2,12 @@ import type { Answerable } from '../Answerable';
|
|
|
2
2
|
import type { Question } from '../Question';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* A
|
|
6
|
-
*
|
|
5
|
+
* A meta-question is a {@apilink Question} that can be answered
|
|
6
|
+
* in the context of another {@apilink Answerable},
|
|
7
|
+
* typically to transform its value.
|
|
7
8
|
*
|
|
8
|
-
* For example, the question {@apilink Text.of}
|
|
9
|
-
*
|
|
9
|
+
* For example, the question {@apilink Text.of} can be answered in the context
|
|
10
|
+
* of a {@apilink PageElement} to return its text content.
|
|
10
11
|
*
|
|
11
12
|
* {@apilink MetaQuestion|Meta questions} are typically used when filtering a {@apilink List}.
|
|
12
13
|
*
|
|
@@ -15,15 +16,15 @@ import type { Question } from '../Question';
|
|
|
15
16
|
*
|
|
16
17
|
* @group Questions
|
|
17
18
|
*/
|
|
18
|
-
export interface MetaQuestion<
|
|
19
|
+
export interface MetaQuestion<Supported_Context_Type, Answer_Type> {
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* Answers the given `MetaQuestion` in the context of another {@apilink Answerable}.
|
|
22
23
|
*
|
|
23
24
|
* #### Learn more
|
|
24
25
|
* - {@apilink List}
|
|
25
26
|
*/
|
|
26
|
-
of(
|
|
27
|
+
of(context: Answerable<Supported_Context_Type>): Question<Promise<Answer_Type>> | Question<Answer_Type>;
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Human-readable description of this {@apilink MetaQuestion},
|