@serenity-js/core 3.23.2 → 3.24.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.
Files changed (137) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/lib/errors/ErrorFactory.js +4 -4
  3. package/lib/errors/ErrorFactory.js.map +1 -1
  4. package/lib/errors/RaiseErrors.d.ts +2 -2
  5. package/lib/errors/RaiseErrors.js +2 -2
  6. package/lib/io/index.d.ts +0 -1
  7. package/lib/io/index.d.ts.map +1 -1
  8. package/lib/io/index.js +0 -1
  9. package/lib/io/index.js.map +1 -1
  10. package/lib/io/inspectedObject.js +1 -1
  11. package/lib/io/inspectedObject.js.map +1 -1
  12. package/lib/io/reflection/ValueInspector.d.ts +56 -0
  13. package/lib/io/reflection/ValueInspector.d.ts.map +1 -0
  14. package/lib/io/reflection/ValueInspector.js +149 -0
  15. package/lib/io/reflection/ValueInspector.js.map +1 -0
  16. package/lib/io/reflection/index.d.ts +1 -2
  17. package/lib/io/reflection/index.d.ts.map +1 -1
  18. package/lib/io/reflection/index.js +1 -2
  19. package/lib/io/reflection/index.js.map +1 -1
  20. package/lib/io/stringified.js +7 -90
  21. package/lib/io/stringified.js.map +1 -1
  22. package/lib/screenplay/Activity.d.ts +5 -12
  23. package/lib/screenplay/Activity.d.ts.map +1 -1
  24. package/lib/screenplay/Activity.js +3 -14
  25. package/lib/screenplay/Activity.js.map +1 -1
  26. package/lib/screenplay/Actor.js +1 -1
  27. package/lib/screenplay/Actor.js.map +1 -1
  28. package/lib/screenplay/Interaction.d.ts +4 -3
  29. package/lib/screenplay/Interaction.d.ts.map +1 -1
  30. package/lib/screenplay/Interaction.js +2 -2
  31. package/lib/screenplay/Interaction.js.map +1 -1
  32. package/lib/screenplay/Question.d.ts +73 -21
  33. package/lib/screenplay/Question.d.ts.map +1 -1
  34. package/lib/screenplay/Question.js +237 -30
  35. package/lib/screenplay/Question.js.map +1 -1
  36. package/lib/screenplay/Task.d.ts +16 -15
  37. package/lib/screenplay/Task.d.ts.map +1 -1
  38. package/lib/screenplay/Task.js +14 -14
  39. package/lib/screenplay/Task.js.map +1 -1
  40. package/lib/screenplay/abilities/Ability.d.ts +8 -6
  41. package/lib/screenplay/abilities/Ability.d.ts.map +1 -1
  42. package/lib/screenplay/abilities/Ability.js +8 -6
  43. package/lib/screenplay/abilities/Ability.js.map +1 -1
  44. package/lib/screenplay/abilities/AbilityType.d.ts +3 -3
  45. package/lib/screenplay/abilities/AnswerQuestions.d.ts +0 -1
  46. package/lib/screenplay/abilities/AnswerQuestions.d.ts.map +1 -1
  47. package/lib/screenplay/abilities/AnswerQuestions.js +2 -4
  48. package/lib/screenplay/abilities/AnswerQuestions.js.map +1 -1
  49. package/lib/screenplay/abilities/PerformActivities.d.ts +5 -3
  50. package/lib/screenplay/abilities/PerformActivities.d.ts.map +1 -1
  51. package/lib/screenplay/abilities/PerformActivities.js +12 -10
  52. package/lib/screenplay/abilities/PerformActivities.js.map +1 -1
  53. package/lib/screenplay/artifacts/CollectsArtifacts.d.ts +2 -2
  54. package/lib/screenplay/notes/NotepadAdapter.d.ts.map +1 -1
  55. package/lib/screenplay/notes/NotepadAdapter.js +44 -4
  56. package/lib/screenplay/notes/NotepadAdapter.js.map +1 -1
  57. package/lib/screenplay/questions/Describable.d.ts +27 -0
  58. package/lib/screenplay/questions/Describable.d.ts.map +1 -0
  59. package/lib/screenplay/questions/Describable.js +40 -0
  60. package/lib/screenplay/questions/Describable.js.map +1 -0
  61. package/lib/screenplay/questions/DescriptionFormattingOptions.d.ts +14 -0
  62. package/lib/screenplay/questions/DescriptionFormattingOptions.d.ts.map +1 -0
  63. package/lib/screenplay/questions/DescriptionFormattingOptions.js +3 -0
  64. package/lib/screenplay/questions/DescriptionFormattingOptions.js.map +1 -0
  65. package/lib/screenplay/questions/Expectation.d.ts +6 -10
  66. package/lib/screenplay/questions/Expectation.d.ts.map +1 -1
  67. package/lib/screenplay/questions/Expectation.js +12 -15
  68. package/lib/screenplay/questions/Expectation.js.map +1 -1
  69. package/lib/screenplay/questions/List.d.ts +1 -3
  70. package/lib/screenplay/questions/List.d.ts.map +1 -1
  71. package/lib/screenplay/questions/List.js +6 -31
  72. package/lib/screenplay/questions/List.js.map +1 -1
  73. package/lib/screenplay/questions/Unanswered.d.ts +1 -0
  74. package/lib/screenplay/questions/Unanswered.d.ts.map +1 -1
  75. package/lib/screenplay/questions/Unanswered.js +3 -0
  76. package/lib/screenplay/questions/Unanswered.js.map +1 -1
  77. package/lib/screenplay/questions/expectations/ExpectationDetails.js +1 -1
  78. package/lib/screenplay/questions/expectations/ExpectationDetails.js.map +1 -1
  79. package/lib/screenplay/questions/index.d.ts +3 -1
  80. package/lib/screenplay/questions/index.d.ts.map +1 -1
  81. package/lib/screenplay/questions/index.js +3 -1
  82. package/lib/screenplay/questions/index.js.map +1 -1
  83. package/lib/screenplay/questions/tag-functions.d.ts +228 -0
  84. package/lib/screenplay/questions/tag-functions.d.ts.map +1 -0
  85. package/lib/screenplay/questions/tag-functions.js +115 -0
  86. package/lib/screenplay/questions/tag-functions.js.map +1 -0
  87. package/lib/screenplay/time/activities/Wait.d.ts.map +1 -1
  88. package/lib/screenplay/time/activities/Wait.js +4 -3
  89. package/lib/screenplay/time/activities/Wait.js.map +1 -1
  90. package/package.json +4 -4
  91. package/src/errors/ErrorFactory.ts +5 -5
  92. package/src/errors/RaiseErrors.ts +2 -2
  93. package/src/io/index.ts +0 -1
  94. package/src/io/inspectedObject.ts +2 -2
  95. package/src/io/reflection/ValueInspector.ts +165 -0
  96. package/src/io/reflection/index.ts +1 -2
  97. package/src/io/stringified.ts +7 -103
  98. package/src/screenplay/Activity.ts +6 -17
  99. package/src/screenplay/Actor.ts +2 -2
  100. package/src/screenplay/Interaction.ts +5 -4
  101. package/src/screenplay/Question.ts +299 -49
  102. package/src/screenplay/Task.ts +18 -17
  103. package/src/screenplay/abilities/Ability.ts +8 -6
  104. package/src/screenplay/abilities/AbilityType.ts +3 -3
  105. package/src/screenplay/abilities/AnswerQuestions.ts +2 -5
  106. package/src/screenplay/abilities/PerformActivities.ts +35 -18
  107. package/src/screenplay/artifacts/CollectsArtifacts.ts +2 -2
  108. package/src/screenplay/notes/NotepadAdapter.ts +57 -6
  109. package/src/screenplay/questions/Describable.ts +48 -0
  110. package/src/screenplay/questions/DescriptionFormattingOptions.ts +13 -0
  111. package/src/screenplay/questions/Expectation.ts +19 -19
  112. package/src/screenplay/questions/List.ts +7 -41
  113. package/src/screenplay/questions/Unanswered.ts +4 -0
  114. package/src/screenplay/questions/expectations/ExpectationDetails.ts +2 -2
  115. package/src/screenplay/questions/index.ts +3 -1
  116. package/src/screenplay/questions/tag-functions.ts +313 -0
  117. package/src/screenplay/time/activities/Wait.ts +4 -3
  118. package/lib/io/isPlainObject.d.ts +0 -7
  119. package/lib/io/isPlainObject.d.ts.map +0 -1
  120. package/lib/io/isPlainObject.js +0 -25
  121. package/lib/io/isPlainObject.js.map +0 -1
  122. package/lib/io/reflection/isPrimitive.d.ts +0 -8
  123. package/lib/io/reflection/isPrimitive.d.ts.map +0 -1
  124. package/lib/io/reflection/isPrimitive.js +0 -24
  125. package/lib/io/reflection/isPrimitive.js.map +0 -1
  126. package/lib/io/reflection/typeOf.d.ts +0 -7
  127. package/lib/io/reflection/typeOf.d.ts.map +0 -1
  128. package/lib/io/reflection/typeOf.js +0 -35
  129. package/lib/io/reflection/typeOf.js.map +0 -1
  130. package/lib/screenplay/questions/q.d.ts +0 -66
  131. package/lib/screenplay/questions/q.d.ts.map +0 -1
  132. package/lib/screenplay/questions/q.js +0 -77
  133. package/lib/screenplay/questions/q.js.map +0 -1
  134. package/src/io/isPlainObject.ts +0 -24
  135. package/src/io/reflection/isPrimitive.ts +0 -20
  136. package/src/io/reflection/typeOf.ts +0 -31
  137. package/src/screenplay/questions/q.ts +0 -82
@@ -1,66 +0,0 @@
1
- import type { Answerable } from '../Answerable';
2
- import type { QuestionAdapter } from '../Question';
3
- /**
4
- * A Serenity/JS Screenplay Pattern-flavour
5
- * of a [tagged template literal](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates),
6
- * `q` is a tag function capable of resolving any `Answerable<string>` or `Answerable<number>`
7
- * you parametrise it with, and returning a `QuestionAdapter<string>`.
8
- *
9
- * Use `q` to concatenate `string` and `number` values returned from synchronous an asynchronous sources.
10
- *
11
- * ## Interpolating questions
12
- *
13
- * ```ts
14
- * import { q, actorCalled } from '@serenity-js/core'
15
- * import { Send, DeleteRequest } from '@serenity-js/rest'
16
- * import { Text } from '@serenity-js/web'
17
- *
18
- * await actorCalled('Alice').attemptsTo(
19
- * Send.a(DeleteRequest.to(
20
- * q `/articles/${ Text.of(Article.id()) }`
21
- * ))
22
- * )
23
- * ```
24
- *
25
- * ## Using a custom description
26
- *
27
- * ```ts
28
- * import { q, actorCalled } from '@serenity-js/core'
29
- * import { Send, DeleteRequest } from '@serenity-js/rest'
30
- *
31
- * await actorCalled('Alice').attemptsTo(
32
- * Send.a(DeleteRequest.to(
33
- * q `/articles/${ Text.of(Article.id()) }`.describedAs('/articles/:id')
34
- * ))
35
- * )
36
- * ```
37
- *
38
- * ## Transforming the interpolated string
39
- *
40
- * The mechanism presented below relies on {@apilink QuestionAdapter}.
41
- *
42
- * ```ts
43
- * import { q, actorCalled } from '@serenity-js/core'
44
- * import { Send, DeleteRequest } from '@serenity-js/rest'
45
- *
46
- * await actorCalled('Alice').attemptsTo(
47
- * Send.a(DeleteRequest.to(
48
- * q `/articles/${ Text.of(Article.id()) }`.toLocaleLowerCase()
49
- * ))
50
- * )
51
- * ```
52
- *
53
- * ## Learn more
54
- *
55
- * - {@apilink Answerable}
56
- * - {@apilink Question}
57
- * - {@apilink Question.describedAs}
58
- * - {@apilink QuestionAdapter}
59
- *
60
- * @group Questions
61
- *
62
- * @param templates
63
- * @param parameters
64
- */
65
- export declare function q(templates: TemplateStringsArray, ...parameters: Array<Answerable<string | number>>): QuestionAdapter<string>;
66
- //# sourceMappingURL=q.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"q.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/q.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,wBAAgB,CAAC,CAAC,SAAS,EAAE,oBAAoB,EAAE,GAAG,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC,CAe7H"}
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.q = void 0;
4
- const Question_1 = require("../Question");
5
- /**
6
- * A Serenity/JS Screenplay Pattern-flavour
7
- * of a [tagged template literal](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates),
8
- * `q` is a tag function capable of resolving any `Answerable<string>` or `Answerable<number>`
9
- * you parametrise it with, and returning a `QuestionAdapter<string>`.
10
- *
11
- * Use `q` to concatenate `string` and `number` values returned from synchronous an asynchronous sources.
12
- *
13
- * ## Interpolating questions
14
- *
15
- * ```ts
16
- * import { q, actorCalled } from '@serenity-js/core'
17
- * import { Send, DeleteRequest } from '@serenity-js/rest'
18
- * import { Text } from '@serenity-js/web'
19
- *
20
- * await actorCalled('Alice').attemptsTo(
21
- * Send.a(DeleteRequest.to(
22
- * q `/articles/${ Text.of(Article.id()) }`
23
- * ))
24
- * )
25
- * ```
26
- *
27
- * ## Using a custom description
28
- *
29
- * ```ts
30
- * import { q, actorCalled } from '@serenity-js/core'
31
- * import { Send, DeleteRequest } from '@serenity-js/rest'
32
- *
33
- * await actorCalled('Alice').attemptsTo(
34
- * Send.a(DeleteRequest.to(
35
- * q `/articles/${ Text.of(Article.id()) }`.describedAs('/articles/:id')
36
- * ))
37
- * )
38
- * ```
39
- *
40
- * ## Transforming the interpolated string
41
- *
42
- * The mechanism presented below relies on {@apilink QuestionAdapter}.
43
- *
44
- * ```ts
45
- * import { q, actorCalled } from '@serenity-js/core'
46
- * import { Send, DeleteRequest } from '@serenity-js/rest'
47
- *
48
- * await actorCalled('Alice').attemptsTo(
49
- * Send.a(DeleteRequest.to(
50
- * q `/articles/${ Text.of(Article.id()) }`.toLocaleLowerCase()
51
- * ))
52
- * )
53
- * ```
54
- *
55
- * ## Learn more
56
- *
57
- * - {@apilink Answerable}
58
- * - {@apilink Question}
59
- * - {@apilink Question.describedAs}
60
- * - {@apilink QuestionAdapter}
61
- *
62
- * @group Questions
63
- *
64
- * @param templates
65
- * @param parameters
66
- */
67
- function q(templates, ...parameters) {
68
- return Question_1.Question.about(templates.join('{}'), actor => Promise.all(parameters.map(parameter => actor.answer(parameter)))
69
- .then(answers => templates
70
- .map((template, i) => i < answers.length
71
- ? [template, answers[i]]
72
- : [template])
73
- .reduce((acc, tuple) => acc.concat(tuple))
74
- .join('')));
75
- }
76
- exports.q = q;
77
- //# sourceMappingURL=q.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"q.js","sourceRoot":"","sources":["../../../src/screenplay/questions/q.ts"],"names":[],"mappings":";;;AAEA,0CAAuC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,SAAgB,CAAC,CAAC,SAA+B,EAAE,GAAG,UAA8C;IAChG,OAAO,mBAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAChD,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;SAC5D,IAAI,CAAC,OAAO,CAAC,EAAE,CACZ,SAAS;SACJ,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CACjB,CAAC,GAAG,OAAO,CAAC,MAAM;QACd,CAAC,CAAC,CAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAE;QAC1B,CAAC,CAAC,CAAE,QAAQ,CAAE,CAAC;SACtB,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CACnB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CACpB;SACA,IAAI,CAAC,EAAE,CAAC,CAChB,CACR,CAAC;AACN,CAAC;AAfD,cAeC"}
@@ -1,24 +0,0 @@
1
- /**
2
- * Checks if the value has a good chance of being a plain JavaScript object
3
- *
4
- * @param v
5
- */
6
- export function isPlainObject(v: unknown): v is object { // eslint-disable-line @typescript-eslint/ban-types
7
-
8
- // Basic check for Type object that's not null
9
- if (typeof v === 'object' && v !== null) {
10
-
11
- // If Object.getPrototypeOf supported, use it
12
- if (typeof Object.getPrototypeOf === 'function') {
13
- const proto = Object.getPrototypeOf(v);
14
- return proto === Object.prototype || proto === null;
15
- }
16
-
17
- // Otherwise, use internal class
18
- // This should be reliable as if getPrototypeOf not supported, is pre-ES5
19
- return Object.prototype.toString.call(v) === '[object Object]';
20
- }
21
-
22
- // Not an object
23
- return false;
24
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Returns true if `value` is a [JavaScript primitive](https://developer.mozilla.org/en-US/docs/Glossary/Primitive),
3
- * false otherwise.
4
- *
5
- * @param value
6
- */
7
- export function isPrimitive(value: unknown): boolean {
8
- if (value === null) {
9
- return true;
10
- }
11
-
12
- return [
13
- 'string',
14
- 'number',
15
- 'bigint',
16
- 'boolean',
17
- 'undefined',
18
- 'symbol'
19
- ].includes(typeof value);
20
- }
@@ -1,31 +0,0 @@
1
- import { types } from 'util';
2
-
3
- /**
4
- * Describes the type of the provided value.
5
- *
6
- * @param value
7
- */
8
- export function typeOf(value: unknown): string {
9
- switch (true) {
10
- case value === null:
11
- return 'null';
12
- case types.isProxy(value):
13
- return `Proxy<${ Reflect.getPrototypeOf(value as object).constructor.name }>`;
14
- case typeof value !== 'object':
15
- return typeof value;
16
- case value instanceof Date:
17
- return `Date`;
18
- case Array.isArray(value):
19
- return `Array`;
20
- case value instanceof RegExp:
21
- return `RegExp`
22
- case value instanceof Set:
23
- return 'Set';
24
- case value instanceof Map:
25
- return 'Map';
26
- case !! value.constructor && value.constructor !== Object:
27
- return value.constructor.name
28
- default:
29
- return 'object';
30
- }
31
- }
@@ -1,82 +0,0 @@
1
- import type { Answerable } from '../Answerable';
2
- import type { QuestionAdapter } from '../Question';
3
- import { Question } from '../Question';
4
-
5
- /**
6
- * A Serenity/JS Screenplay Pattern-flavour
7
- * of a [tagged template literal](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates),
8
- * `q` is a tag function capable of resolving any `Answerable<string>` or `Answerable<number>`
9
- * you parametrise it with, and returning a `QuestionAdapter<string>`.
10
- *
11
- * Use `q` to concatenate `string` and `number` values returned from synchronous an asynchronous sources.
12
- *
13
- * ## Interpolating questions
14
- *
15
- * ```ts
16
- * import { q, actorCalled } from '@serenity-js/core'
17
- * import { Send, DeleteRequest } from '@serenity-js/rest'
18
- * import { Text } from '@serenity-js/web'
19
- *
20
- * await actorCalled('Alice').attemptsTo(
21
- * Send.a(DeleteRequest.to(
22
- * q `/articles/${ Text.of(Article.id()) }`
23
- * ))
24
- * )
25
- * ```
26
- *
27
- * ## Using a custom description
28
- *
29
- * ```ts
30
- * import { q, actorCalled } from '@serenity-js/core'
31
- * import { Send, DeleteRequest } from '@serenity-js/rest'
32
- *
33
- * await actorCalled('Alice').attemptsTo(
34
- * Send.a(DeleteRequest.to(
35
- * q `/articles/${ Text.of(Article.id()) }`.describedAs('/articles/:id')
36
- * ))
37
- * )
38
- * ```
39
- *
40
- * ## Transforming the interpolated string
41
- *
42
- * The mechanism presented below relies on {@apilink QuestionAdapter}.
43
- *
44
- * ```ts
45
- * import { q, actorCalled } from '@serenity-js/core'
46
- * import { Send, DeleteRequest } from '@serenity-js/rest'
47
- *
48
- * await actorCalled('Alice').attemptsTo(
49
- * Send.a(DeleteRequest.to(
50
- * q `/articles/${ Text.of(Article.id()) }`.toLocaleLowerCase()
51
- * ))
52
- * )
53
- * ```
54
- *
55
- * ## Learn more
56
- *
57
- * - {@apilink Answerable}
58
- * - {@apilink Question}
59
- * - {@apilink Question.describedAs}
60
- * - {@apilink QuestionAdapter}
61
- *
62
- * @group Questions
63
- *
64
- * @param templates
65
- * @param parameters
66
- */
67
- export function q(templates: TemplateStringsArray, ...parameters: Array<Answerable<string | number>>): QuestionAdapter<string> {
68
- return Question.about(templates.join('{}'), actor =>
69
- Promise.all(parameters.map(parameter => actor.answer(parameter)))
70
- .then(answers =>
71
- templates
72
- .map((template, i) =>
73
- i < answers.length
74
- ? [ template, answers[i] ]
75
- : [ template ])
76
- .reduce((acc, tuple) =>
77
- acc.concat(tuple)
78
- )
79
- .join('')
80
- )
81
- );
82
- }