@serenity-js/rest 3.41.1 → 3.42.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 (213) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/esm/index.d.ts +3 -0
  3. package/esm/index.d.ts.map +1 -0
  4. package/esm/index.js +3 -0
  5. package/esm/index.js.map +1 -0
  6. package/esm/io/AxiosRequestConfigDefaults.d.ts +15 -0
  7. package/esm/io/AxiosRequestConfigDefaults.d.ts.map +1 -0
  8. package/esm/io/AxiosRequestConfigDefaults.js +2 -0
  9. package/esm/io/AxiosRequestConfigDefaults.js.map +1 -0
  10. package/esm/io/EnvironmentVariables.d.ts +9 -0
  11. package/esm/io/EnvironmentVariables.d.ts.map +1 -0
  12. package/esm/io/EnvironmentVariables.js +35 -0
  13. package/esm/io/EnvironmentVariables.js.map +1 -0
  14. package/esm/io/ProxyAgent.d.ts +52 -0
  15. package/esm/io/ProxyAgent.d.ts.map +1 -0
  16. package/esm/io/ProxyAgent.js +83 -0
  17. package/esm/io/ProxyAgent.js.map +1 -0
  18. package/esm/io/ProxyBypass.d.ts +6 -0
  19. package/esm/io/ProxyBypass.d.ts.map +1 -0
  20. package/esm/io/ProxyBypass.js +66 -0
  21. package/esm/io/ProxyBypass.js.map +1 -0
  22. package/esm/io/createAxios.d.ts +9 -0
  23. package/esm/io/createAxios.d.ts.map +1 -0
  24. package/esm/io/createAxios.js +40 -0
  25. package/esm/io/createAxios.js.map +1 -0
  26. package/esm/io/createUrl.d.ts +9 -0
  27. package/esm/io/createUrl.d.ts.map +1 -0
  28. package/esm/io/createUrl.js +26 -0
  29. package/esm/io/createUrl.js.map +1 -0
  30. package/esm/io/index.d.ts +3 -0
  31. package/esm/io/index.d.ts.map +1 -0
  32. package/esm/io/index.js +3 -0
  33. package/esm/io/index.js.map +1 -0
  34. package/esm/io/proxy.d.ts +14 -0
  35. package/esm/io/proxy.d.ts.map +1 -0
  36. package/esm/io/proxy.js +66 -0
  37. package/esm/io/proxy.js.map +1 -0
  38. package/esm/screenplay/abilities/AxiosRequestConfigDefaults.d.ts +14 -0
  39. package/esm/screenplay/abilities/AxiosRequestConfigDefaults.d.ts.map +1 -0
  40. package/esm/screenplay/abilities/AxiosRequestConfigDefaults.js +2 -0
  41. package/esm/screenplay/abilities/AxiosRequestConfigDefaults.js.map +1 -0
  42. package/esm/screenplay/abilities/CallAnApi.d.ts +443 -0
  43. package/esm/screenplay/abilities/CallAnApi.d.ts.map +1 -0
  44. package/esm/screenplay/abilities/CallAnApi.js +555 -0
  45. package/esm/screenplay/abilities/CallAnApi.js.map +1 -0
  46. package/esm/screenplay/abilities/index.d.ts +2 -0
  47. package/esm/screenplay/abilities/index.d.ts.map +1 -0
  48. package/esm/screenplay/abilities/index.js +2 -0
  49. package/esm/screenplay/abilities/index.js.map +1 -0
  50. package/esm/screenplay/index.d.ts +5 -0
  51. package/esm/screenplay/index.d.ts.map +1 -0
  52. package/esm/screenplay/index.js +5 -0
  53. package/esm/screenplay/index.js.map +1 -0
  54. package/esm/screenplay/interactions/ChangeApiConfig.d.ts +135 -0
  55. package/esm/screenplay/interactions/ChangeApiConfig.d.ts.map +1 -0
  56. package/esm/screenplay/interactions/ChangeApiConfig.js +212 -0
  57. package/esm/screenplay/interactions/ChangeApiConfig.js.map +1 -0
  58. package/esm/screenplay/interactions/Send.d.ts +48 -0
  59. package/esm/screenplay/interactions/Send.d.ts.map +1 -0
  60. package/esm/screenplay/interactions/Send.js +83 -0
  61. package/esm/screenplay/interactions/Send.js.map +1 -0
  62. package/esm/screenplay/interactions/index.d.ts +3 -0
  63. package/esm/screenplay/interactions/index.d.ts.map +1 -0
  64. package/esm/screenplay/interactions/index.js +3 -0
  65. package/esm/screenplay/interactions/index.js.map +1 -0
  66. package/esm/screenplay/models/DeleteRequest.d.ts +66 -0
  67. package/esm/screenplay/models/DeleteRequest.d.ts.map +1 -0
  68. package/esm/screenplay/models/DeleteRequest.js +69 -0
  69. package/esm/screenplay/models/DeleteRequest.js.map +1 -0
  70. package/esm/screenplay/models/GetRequest.d.ts +73 -0
  71. package/esm/screenplay/models/GetRequest.d.ts.map +1 -0
  72. package/esm/screenplay/models/GetRequest.js +76 -0
  73. package/esm/screenplay/models/GetRequest.js.map +1 -0
  74. package/esm/screenplay/models/HTTPRequest.d.ts +40 -0
  75. package/esm/screenplay/models/HTTPRequest.d.ts.map +1 -0
  76. package/esm/screenplay/models/HTTPRequest.js +62 -0
  77. package/esm/screenplay/models/HTTPRequest.js.map +1 -0
  78. package/esm/screenplay/models/HeadRequest.d.ts +58 -0
  79. package/esm/screenplay/models/HeadRequest.d.ts.map +1 -0
  80. package/esm/screenplay/models/HeadRequest.js +61 -0
  81. package/esm/screenplay/models/HeadRequest.js.map +1 -0
  82. package/esm/screenplay/models/OptionsRequest.d.ts +61 -0
  83. package/esm/screenplay/models/OptionsRequest.d.ts.map +1 -0
  84. package/esm/screenplay/models/OptionsRequest.js +64 -0
  85. package/esm/screenplay/models/OptionsRequest.js.map +1 -0
  86. package/esm/screenplay/models/PatchRequest.d.ts +65 -0
  87. package/esm/screenplay/models/PatchRequest.d.ts.map +1 -0
  88. package/esm/screenplay/models/PatchRequest.js +70 -0
  89. package/esm/screenplay/models/PatchRequest.js.map +1 -0
  90. package/esm/screenplay/models/PostRequest.d.ts +105 -0
  91. package/esm/screenplay/models/PostRequest.d.ts.map +1 -0
  92. package/esm/screenplay/models/PostRequest.js +110 -0
  93. package/esm/screenplay/models/PostRequest.js.map +1 -0
  94. package/esm/screenplay/models/PutRequest.d.ts +75 -0
  95. package/esm/screenplay/models/PutRequest.d.ts.map +1 -0
  96. package/esm/screenplay/models/PutRequest.js +80 -0
  97. package/esm/screenplay/models/PutRequest.js.map +1 -0
  98. package/esm/screenplay/models/index.d.ts +9 -0
  99. package/esm/screenplay/models/index.d.ts.map +1 -0
  100. package/esm/screenplay/models/index.js +9 -0
  101. package/esm/screenplay/models/index.js.map +1 -0
  102. package/esm/screenplay/questions/LastResponse.d.ts +189 -0
  103. package/esm/screenplay/questions/LastResponse.d.ts.map +1 -0
  104. package/esm/screenplay/questions/LastResponse.js +205 -0
  105. package/esm/screenplay/questions/LastResponse.js.map +1 -0
  106. package/esm/screenplay/questions/index.d.ts +2 -0
  107. package/esm/screenplay/questions/index.d.ts.map +1 -0
  108. package/esm/screenplay/questions/index.js +2 -0
  109. package/esm/screenplay/questions/index.js.map +1 -0
  110. package/lib/index.d.ts +2 -2
  111. package/lib/index.d.ts.map +1 -1
  112. package/lib/index.js +2 -2
  113. package/lib/index.js.map +1 -1
  114. package/lib/io/ProxyBypass.js +2 -2
  115. package/lib/io/ProxyBypass.js.map +1 -1
  116. package/lib/io/createAxios.d.ts +1 -1
  117. package/lib/io/createAxios.d.ts.map +1 -1
  118. package/lib/io/createAxios.js +2 -2
  119. package/lib/io/createAxios.js.map +1 -1
  120. package/lib/io/index.d.ts +2 -2
  121. package/lib/io/index.d.ts.map +1 -1
  122. package/lib/io/index.js +2 -2
  123. package/lib/io/index.js.map +1 -1
  124. package/lib/io/proxy.d.ts +2 -2
  125. package/lib/io/proxy.d.ts.map +1 -1
  126. package/lib/io/proxy.js +9 -9
  127. package/lib/io/proxy.js.map +1 -1
  128. package/lib/package.json +1 -0
  129. package/lib/screenplay/abilities/CallAnApi.d.ts +1 -1
  130. package/lib/screenplay/abilities/CallAnApi.d.ts.map +1 -1
  131. package/lib/screenplay/abilities/CallAnApi.js +4 -4
  132. package/lib/screenplay/abilities/CallAnApi.js.map +1 -1
  133. package/lib/screenplay/abilities/index.d.ts +1 -1
  134. package/lib/screenplay/abilities/index.d.ts.map +1 -1
  135. package/lib/screenplay/abilities/index.js +1 -1
  136. package/lib/screenplay/abilities/index.js.map +1 -1
  137. package/lib/screenplay/index.d.ts +4 -4
  138. package/lib/screenplay/index.d.ts.map +1 -1
  139. package/lib/screenplay/index.js +4 -4
  140. package/lib/screenplay/index.js.map +1 -1
  141. package/lib/screenplay/interactions/ChangeApiConfig.js +4 -4
  142. package/lib/screenplay/interactions/ChangeApiConfig.js.map +1 -1
  143. package/lib/screenplay/interactions/Send.js +3 -3
  144. package/lib/screenplay/interactions/Send.js.map +1 -1
  145. package/lib/screenplay/interactions/index.d.ts +2 -2
  146. package/lib/screenplay/interactions/index.d.ts.map +1 -1
  147. package/lib/screenplay/interactions/index.js +2 -2
  148. package/lib/screenplay/interactions/index.js.map +1 -1
  149. package/lib/screenplay/models/DeleteRequest.d.ts +1 -1
  150. package/lib/screenplay/models/DeleteRequest.d.ts.map +1 -1
  151. package/lib/screenplay/models/DeleteRequest.js +2 -2
  152. package/lib/screenplay/models/DeleteRequest.js.map +1 -1
  153. package/lib/screenplay/models/GetRequest.d.ts +1 -1
  154. package/lib/screenplay/models/GetRequest.d.ts.map +1 -1
  155. package/lib/screenplay/models/GetRequest.js +2 -2
  156. package/lib/screenplay/models/GetRequest.js.map +1 -1
  157. package/lib/screenplay/models/HTTPRequest.js +1 -1
  158. package/lib/screenplay/models/HTTPRequest.js.map +1 -1
  159. package/lib/screenplay/models/HeadRequest.d.ts +1 -1
  160. package/lib/screenplay/models/HeadRequest.d.ts.map +1 -1
  161. package/lib/screenplay/models/HeadRequest.js +2 -2
  162. package/lib/screenplay/models/HeadRequest.js.map +1 -1
  163. package/lib/screenplay/models/OptionsRequest.d.ts +1 -1
  164. package/lib/screenplay/models/OptionsRequest.d.ts.map +1 -1
  165. package/lib/screenplay/models/OptionsRequest.js +2 -2
  166. package/lib/screenplay/models/OptionsRequest.js.map +1 -1
  167. package/lib/screenplay/models/PatchRequest.d.ts +1 -1
  168. package/lib/screenplay/models/PatchRequest.d.ts.map +1 -1
  169. package/lib/screenplay/models/PatchRequest.js +2 -2
  170. package/lib/screenplay/models/PatchRequest.js.map +1 -1
  171. package/lib/screenplay/models/PostRequest.d.ts +1 -1
  172. package/lib/screenplay/models/PostRequest.d.ts.map +1 -1
  173. package/lib/screenplay/models/PostRequest.js +2 -2
  174. package/lib/screenplay/models/PostRequest.js.map +1 -1
  175. package/lib/screenplay/models/PutRequest.d.ts +1 -1
  176. package/lib/screenplay/models/PutRequest.d.ts.map +1 -1
  177. package/lib/screenplay/models/PutRequest.js +2 -2
  178. package/lib/screenplay/models/PutRequest.js.map +1 -1
  179. package/lib/screenplay/models/index.d.ts +8 -8
  180. package/lib/screenplay/models/index.d.ts.map +1 -1
  181. package/lib/screenplay/models/index.js +8 -8
  182. package/lib/screenplay/models/index.js.map +1 -1
  183. package/lib/screenplay/questions/LastResponse.js +5 -5
  184. package/lib/screenplay/questions/LastResponse.js.map +1 -1
  185. package/lib/screenplay/questions/index.d.ts +1 -1
  186. package/lib/screenplay/questions/index.d.ts.map +1 -1
  187. package/lib/screenplay/questions/index.js +1 -1
  188. package/lib/screenplay/questions/index.js.map +1 -1
  189. package/package.json +29 -11
  190. package/src/index.ts +2 -2
  191. package/src/io/ProxyBypass.ts +1 -1
  192. package/src/io/createAxios.ts +2 -2
  193. package/src/io/index.ts +2 -2
  194. package/src/io/proxy.ts +5 -5
  195. package/src/screenplay/abilities/CallAnApi.ts +3 -3
  196. package/src/screenplay/abilities/index.ts +1 -1
  197. package/src/screenplay/index.ts +4 -4
  198. package/src/screenplay/interactions/ChangeApiConfig.ts +1 -1
  199. package/src/screenplay/interactions/Send.ts +3 -3
  200. package/src/screenplay/interactions/index.ts +2 -2
  201. package/src/screenplay/models/DeleteRequest.ts +1 -1
  202. package/src/screenplay/models/GetRequest.ts +1 -1
  203. package/src/screenplay/models/HTTPRequest.ts +1 -1
  204. package/src/screenplay/models/HeadRequest.ts +1 -1
  205. package/src/screenplay/models/OptionsRequest.ts +1 -1
  206. package/src/screenplay/models/PatchRequest.ts +1 -1
  207. package/src/screenplay/models/PostRequest.ts +1 -1
  208. package/src/screenplay/models/PutRequest.ts +1 -1
  209. package/src/screenplay/models/index.ts +8 -8
  210. package/src/screenplay/questions/LastResponse.ts +1 -1
  211. package/src/screenplay/questions/index.ts +1 -1
  212. package/tsconfig-cjs.build.json +17 -0
  213. package/tsconfig-esm.build.json +18 -0
@@ -0,0 +1,73 @@
1
+ import type { Answerable, WithAnswerableProperties } from '@serenity-js/core';
2
+ import type { AxiosRequestConfig } from 'axios';
3
+ import { HTTPRequest } from './HTTPRequest.js';
4
+ /**
5
+ * The HTTP GET method requests a representation of the specified resource.
6
+ * It is the most frequent type of request made by consumers of a typical HTTP API.
7
+ * For this reason it's important to test every known endpoint that responds to GET requests and ensure that it
8
+ * behaves correctly.
9
+ *
10
+ * Since the GET method is used to _retrieve_ data from a server, it should be implemented
11
+ * as [safe](https://developer.mozilla.org/en-US/docs/Glossary/Safe)
12
+ * and [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent).
13
+ * This means that an identical request can be made once or several times in a row with the same effect while leaving
14
+ * the server in the same state.
15
+ *
16
+ * ## Verify response to a GET request
17
+ *
18
+ * ```ts
19
+ * import { actorCalled } from '@serenity-js/core'
20
+ * import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
21
+ * import { Ensure, equals } from '@serenity-js/assertions'
22
+ *
23
+ * interface Book {
24
+ * title: string;
25
+ * author: string;
26
+ * }
27
+ *
28
+ * await actorCalled('Apisitt')
29
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
30
+ * .attemptsTo(
31
+ * Send.a(GetRequest.to('/books/0-688-00230-7')),
32
+ * Ensure.that(LastResponse.status(), equals(200)),
33
+ * Ensure.that(LastResponse.body<Book>(), equals({
34
+ * title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
35
+ * author: 'Robert M. Pirsig',
36
+ * })),
37
+ * )
38
+ * ```
39
+ *
40
+ * ## Learn more
41
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET
42
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.1
43
+ *
44
+ * @group Models
45
+ */
46
+ export declare class GetRequest extends HTTPRequest {
47
+ /**
48
+ * Configures the object with a destination URI.
49
+ *
50
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
51
+ * it gets concatenated with the URL provided to the Axios instance
52
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
53
+ *
54
+ * @param resourceUri
55
+ * The URI where the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
56
+ * should send the [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/)
57
+ */
58
+ static to(resourceUri: Answerable<string>): GetRequest;
59
+ /**
60
+ * Overrides the default Axios request configuration provided
61
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
62
+ *
63
+ * #### Learn more
64
+ * - [`Answerable`](https://serenity-js.org/api/core/#Answerable)
65
+ * - [`WithAnswerableProperties`](https://serenity-js.org/api/core/#WithAnswerableProperties)
66
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
67
+ *
68
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
69
+ * Axios request configuration overrides
70
+ */
71
+ using(config: Answerable<WithAnswerableProperties<AxiosRequestConfig>>): GetRequest;
72
+ }
73
+ //# sourceMappingURL=GetRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetRequest.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/GetRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBAAa,UAAW,SAAQ,WAAW;IAEvC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,UAAU;IAItD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC,GAAG,UAAU;CAGtF"}
@@ -0,0 +1,76 @@
1
+ import { Question } from '@serenity-js/core';
2
+ import { HTTPRequest } from './HTTPRequest.js';
3
+ /**
4
+ * The HTTP GET method requests a representation of the specified resource.
5
+ * It is the most frequent type of request made by consumers of a typical HTTP API.
6
+ * For this reason it's important to test every known endpoint that responds to GET requests and ensure that it
7
+ * behaves correctly.
8
+ *
9
+ * Since the GET method is used to _retrieve_ data from a server, it should be implemented
10
+ * as [safe](https://developer.mozilla.org/en-US/docs/Glossary/Safe)
11
+ * and [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent).
12
+ * This means that an identical request can be made once or several times in a row with the same effect while leaving
13
+ * the server in the same state.
14
+ *
15
+ * ## Verify response to a GET request
16
+ *
17
+ * ```ts
18
+ * import { actorCalled } from '@serenity-js/core'
19
+ * import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
20
+ * import { Ensure, equals } from '@serenity-js/assertions'
21
+ *
22
+ * interface Book {
23
+ * title: string;
24
+ * author: string;
25
+ * }
26
+ *
27
+ * await actorCalled('Apisitt')
28
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
29
+ * .attemptsTo(
30
+ * Send.a(GetRequest.to('/books/0-688-00230-7')),
31
+ * Ensure.that(LastResponse.status(), equals(200)),
32
+ * Ensure.that(LastResponse.body<Book>(), equals({
33
+ * title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
34
+ * author: 'Robert M. Pirsig',
35
+ * })),
36
+ * )
37
+ * ```
38
+ *
39
+ * ## Learn more
40
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET
41
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.1
42
+ *
43
+ * @group Models
44
+ */
45
+ export class GetRequest extends HTTPRequest {
46
+ /**
47
+ * Configures the object with a destination URI.
48
+ *
49
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
50
+ * it gets concatenated with the URL provided to the Axios instance
51
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
52
+ *
53
+ * @param resourceUri
54
+ * The URI where the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
55
+ * should send the [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/)
56
+ */
57
+ static to(resourceUri) {
58
+ return new GetRequest(resourceUri);
59
+ }
60
+ /**
61
+ * Overrides the default Axios request configuration provided
62
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
63
+ *
64
+ * #### Learn more
65
+ * - [`Answerable`](https://serenity-js.org/api/core/#Answerable)
66
+ * - [`WithAnswerableProperties`](https://serenity-js.org/api/core/#WithAnswerableProperties)
67
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
68
+ *
69
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
70
+ * Axios request configuration overrides
71
+ */
72
+ using(config) {
73
+ return new GetRequest(this.resourceUri, undefined, Question.fromObject(config));
74
+ }
75
+ }
76
+ //# sourceMappingURL=GetRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetRequest.js","sourceRoot":"","sources":["../../../src/screenplay/models/GetRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,OAAO,UAAW,SAAQ,WAAW;IAEvC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAA+B;QACrC,OAAO,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAgE;QAClE,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACpF,CAAC;CACJ"}
@@ -0,0 +1,40 @@
1
+ import type { Answerable, AnswersQuestions, UsesAbilities, WithAnswerableProperties } from '@serenity-js/core';
2
+ import { Question } from '@serenity-js/core';
3
+ import type { AxiosRequestConfig } from 'axios';
4
+ /**
5
+ * HTTP Request sent by the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
6
+ * using the [interaction](https://serenity-js.org/api/core/class/Interaction/) to [`Send`](https://serenity-js.org/api/rest/class/Send/)
7
+ *
8
+ * @group Models
9
+ */
10
+ export declare abstract class HTTPRequest extends Question<Promise<AxiosRequestConfig>> {
11
+ protected readonly resourceUri?: Answerable<string>;
12
+ protected readonly data?: Answerable<any>;
13
+ protected readonly config?: Answerable<WithAnswerableProperties<AxiosRequestConfig>>;
14
+ /**
15
+ * @param [resourceUri]
16
+ * URL to which the request should be sent
17
+ *
18
+ * @param [data]
19
+ * Request body to be sent as part of the Put, Post or Patch request
20
+ *
21
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} [config]
22
+ * Axios request configuration, which can be used to override the defaults
23
+ * provided when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) is instantiated
24
+ */
25
+ protected constructor(resourceUri?: Answerable<string>, data?: Answerable<any>, config?: Answerable<WithAnswerableProperties<AxiosRequestConfig>>);
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<AxiosRequestConfig>;
30
+ /**
31
+ * Determines the request method based on the name of the request class.
32
+ * For example: GetRequest => GET, PostRequest => POST, etc.
33
+ */
34
+ private static httpMethodName;
35
+ /**
36
+ * A human-readable description of the request, such as "a GET request", "an OPTIONS request", etc.
37
+ */
38
+ private static requestDescription;
39
+ }
40
+ //# sourceMappingURL=HTTPRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HTTPRequest.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/HTTPRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC/G,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD;;;;;GAKG;AACH,8BAAsB,WAAY,SAAQ,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAcvE,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC;IACnD,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC;IACzC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;IAdxF;;;;;;;;;;OAUG;IACH,SAAS,aACc,WAAW,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,EAChC,IAAI,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,EACtB,MAAM,CAAC,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;IAKxF;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,gBAAgB,GAAG,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA0BhF;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAI7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAOpC"}
@@ -0,0 +1,62 @@
1
+ import { Question } from '@serenity-js/core';
2
+ import { d } from '@serenity-js/core/io';
3
+ /**
4
+ * HTTP Request sent by the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
5
+ * using the [interaction](https://serenity-js.org/api/core/class/Interaction/) to [`Send`](https://serenity-js.org/api/rest/class/Send/)
6
+ *
7
+ * @group Models
8
+ */
9
+ export class HTTPRequest extends Question {
10
+ resourceUri;
11
+ data;
12
+ config;
13
+ /**
14
+ * @param [resourceUri]
15
+ * URL to which the request should be sent
16
+ *
17
+ * @param [data]
18
+ * Request body to be sent as part of the Put, Post or Patch request
19
+ *
20
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} [config]
21
+ * Axios request configuration, which can be used to override the defaults
22
+ * provided when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) is instantiated
23
+ */
24
+ constructor(resourceUri, data, config) {
25
+ super(`${HTTPRequest.requestDescription(new.target.name)} to ${d `${resourceUri}`}`);
26
+ this.resourceUri = resourceUri;
27
+ this.data = data;
28
+ this.config = config;
29
+ }
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ answeredBy(actor) {
34
+ return Promise.all([
35
+ this.resourceUri ? actor.answer(this.resourceUri) : Promise.resolve(void 0),
36
+ this.config ? actor.answer(this.config) : Promise.resolve({}),
37
+ this.data ? actor.answer(this.data) : Promise.resolve(void 0),
38
+ ]).
39
+ then(([url, config, data]) => Object.assign({}, { url, data }, config, { method: HTTPRequest.httpMethodName(this.constructor.name) })).
40
+ then(config => Object.keys(config).reduce((acc, key) => {
41
+ if (config[key] !== null && config[key] !== undefined) {
42
+ acc[key] = config[key];
43
+ }
44
+ return acc;
45
+ }, {}));
46
+ }
47
+ /**
48
+ * Determines the request method based on the name of the request class.
49
+ * For example: GetRequest => GET, PostRequest => POST, etc.
50
+ */
51
+ static httpMethodName(className) {
52
+ return className.replace(/Request/, '').toUpperCase();
53
+ }
54
+ /**
55
+ * A human-readable description of the request, such as "a GET request", "an OPTIONS request", etc.
56
+ */
57
+ static requestDescription(className) {
58
+ const vowels = ['A', 'E', 'I', 'O', 'U'], method = HTTPRequest.httpMethodName(className);
59
+ return `${~vowels.indexOf(method[0]) ? 'an' : 'a'} ${method} request`;
60
+ }
61
+ }
62
+ //# sourceMappingURL=HTTPRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HTTPRequest.js","sourceRoot":"","sources":["../../../src/screenplay/models/HTTPRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAC;AAGzC;;;;;GAKG;AACH,MAAM,OAAgB,WAAY,SAAQ,QAAqC;IAcpD;IACA;IACA;IAdvB;;;;;;;;;;OAUG;IACH,YACuB,WAAgC,EAChC,IAAsB,EACtB,MAAiE;QAEpF,KAAK,CAAC,GAAI,WAAW,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAE,OAAQ,CAAC,CAAA,GAAI,WAAY,EAAG,EAAE,CAAC,CAAC;QAJvE,gBAAW,GAAX,WAAW,CAAqB;QAChC,SAAI,GAAJ,IAAI,CAAkB;QACtB,WAAM,GAAN,MAAM,CAA2D;IAGxF,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,KAAuC;QAC9C,OAAO,OAAO,CAAC,GAAG,CAAC;YACf,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC7E,IAAI,CAAC,MAAM,CAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAQ,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACzE,IAAI,CAAC,IAAI,CAAQ,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAU,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SAChF,CAAC;YACF,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAEzB,MAAM,CAAC,MAAM,CACT,EAAE,EACF,EAAE,GAAG,EAAE,IAAI,EAAE,EACb,MAAM,EACN,EAAE,MAAM,EAAE,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAChE,CACJ;YACD,IAAI,CAAC,MAAM,CAAC,EAAE,CAEV,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACpC,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,EAAG,CAAC;gBACrD,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAC3B,CAAC;YACD,OAAO,GAAG,CAAC;QACf,CAAC,EAAE,EAAE,CAAC,CACT,CAAC;IACN,CAAC;IAED;;;OAGG;IACK,MAAM,CAAC,cAAc,CAAC,SAAiB;QAC3C,OAAO,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,kBAAkB,CAAC,SAAiB;QAC/C,MACI,MAAM,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE,EACpC,MAAM,GAAG,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAEnD,OAAO,GAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAI,IAAK,MAAO,UAAU,CAAC;IAC9E,CAAC;CACJ"}
@@ -0,0 +1,58 @@
1
+ import type { Answerable, WithAnswerableProperties } from '@serenity-js/core';
2
+ import type { AxiosRequestConfig } from 'axios';
3
+ import { HTTPRequest } from './HTTPRequest.js';
4
+ /**
5
+ * The HTTP HEAD method requests the headers that are returned if the specified resource
6
+ * would be requested with an HTTP GET method.
7
+ * Such a request can be done before deciding to download a large resource to save bandwidth, for example.
8
+ *
9
+ * ## File download test
10
+ *
11
+ * ```ts
12
+ * import { actorCalled } from '@serenity-js/core'
13
+ * import { CallAnApi, HeadRequest, LastResponse, Send } from '@serenity-js/rest'
14
+ * import { Ensure, equals } from '@serenity-js/assertions'
15
+ *
16
+ * await actorCalled('Apisitt')
17
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
18
+ * .attemptsTo(
19
+ * Send.a(HeadRequest.to('/downloads/my-test-document.pdf')),
20
+ * Ensure.that(LastResponse.status(), equals(200)),
21
+ * Ensure.that(LastResponse.header('Content-Length'), equals(256)), // assuming we know the size of the document
22
+ * )
23
+ * ```
24
+ *
25
+ * ## Learn more
26
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD
27
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.2
28
+ *
29
+ * @group Models
30
+ */
31
+ export declare class HeadRequest extends HTTPRequest {
32
+ /**
33
+ * Configures the object with a destination URI.
34
+ *
35
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
36
+ * it gets concatenated with the URL provided to the Axios instance
37
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
38
+ *
39
+ * @param resourceUri
40
+ * The URI where the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
41
+ * should send the [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/)
42
+ */
43
+ static to(resourceUri: Answerable<string>): HeadRequest;
44
+ /**
45
+ * Overrides the default Axios request configuration provided
46
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
47
+ *
48
+ * #### Learn more
49
+ * - [`Answerable`](https://serenity-js.org/api/core/#Answerable)
50
+ * - [`WithAnswerableProperties`](https://serenity-js.org/api/core/#WithAnswerableProperties)
51
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
52
+ *
53
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
54
+ * Axios request configuration overrides
55
+ */
56
+ using(config: Answerable<WithAnswerableProperties<AxiosRequestConfig>>): HeadRequest;
57
+ }
58
+ //# sourceMappingURL=HeadRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeadRequest.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/HeadRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,WAAY,SAAQ,WAAW;IAExC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,WAAW;IAIvD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC,GAAG,WAAW;CAGvF"}
@@ -0,0 +1,61 @@
1
+ import { Question } from '@serenity-js/core';
2
+ import { HTTPRequest } from './HTTPRequest.js';
3
+ /**
4
+ * The HTTP HEAD method requests the headers that are returned if the specified resource
5
+ * would be requested with an HTTP GET method.
6
+ * Such a request can be done before deciding to download a large resource to save bandwidth, for example.
7
+ *
8
+ * ## File download test
9
+ *
10
+ * ```ts
11
+ * import { actorCalled } from '@serenity-js/core'
12
+ * import { CallAnApi, HeadRequest, LastResponse, Send } from '@serenity-js/rest'
13
+ * import { Ensure, equals } from '@serenity-js/assertions'
14
+ *
15
+ * await actorCalled('Apisitt')
16
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
17
+ * .attemptsTo(
18
+ * Send.a(HeadRequest.to('/downloads/my-test-document.pdf')),
19
+ * Ensure.that(LastResponse.status(), equals(200)),
20
+ * Ensure.that(LastResponse.header('Content-Length'), equals(256)), // assuming we know the size of the document
21
+ * )
22
+ * ```
23
+ *
24
+ * ## Learn more
25
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD
26
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.2
27
+ *
28
+ * @group Models
29
+ */
30
+ export class HeadRequest extends HTTPRequest {
31
+ /**
32
+ * Configures the object with a destination URI.
33
+ *
34
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
35
+ * it gets concatenated with the URL provided to the Axios instance
36
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
37
+ *
38
+ * @param resourceUri
39
+ * The URI where the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
40
+ * should send the [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/)
41
+ */
42
+ static to(resourceUri) {
43
+ return new HeadRequest(resourceUri);
44
+ }
45
+ /**
46
+ * Overrides the default Axios request configuration provided
47
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
48
+ *
49
+ * #### Learn more
50
+ * - [`Answerable`](https://serenity-js.org/api/core/#Answerable)
51
+ * - [`WithAnswerableProperties`](https://serenity-js.org/api/core/#WithAnswerableProperties)
52
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
53
+ *
54
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
55
+ * Axios request configuration overrides
56
+ */
57
+ using(config) {
58
+ return new HeadRequest(this.resourceUri, undefined, Question.fromObject(config));
59
+ }
60
+ }
61
+ //# sourceMappingURL=HeadRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeadRequest.js","sourceRoot":"","sources":["../../../src/screenplay/models/HeadRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,WAAY,SAAQ,WAAW;IAExC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAA+B;QACrC,OAAO,IAAI,WAAW,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAgE;QAClE,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF,CAAC;CACJ"}
@@ -0,0 +1,61 @@
1
+ import type { Answerable, WithAnswerableProperties } from '@serenity-js/core';
2
+ import type { AxiosRequestConfig } from 'axios';
3
+ import { HTTPRequest } from './HTTPRequest.js';
4
+ /**
5
+ * The OPTIONS method requests information about the communication
6
+ * options available for the target resource, at either the origin
7
+ * server or an intervening intermediary. This method allows a client
8
+ * to determine the options and/or requirements associated with a
9
+ * resource, or the capabilities of a server, without implying a
10
+ * resource action.
11
+ *
12
+ * ## File download test
13
+ *
14
+ * ```ts
15
+ * import { actorCalled } from '@serenity-js/core'
16
+ * import { CallAnApi, OptionsRequest, LastResponse, Send } from '@serenity-js/rest'
17
+ * import { Ensure, equals } from '@serenity-js/assertions'
18
+ *
19
+ * await actorCalled('Apisitt')
20
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
21
+ * .attemptsTo(
22
+ * Send.a(OptionsRequest.to('/downloads/my-test-document.pdf')),
23
+ * Ensure.that(LastResponse.status(), equals(200)),
24
+ * Ensure.that(LastResponse.header('Allow'), equals('OPTIONS, GET, HEAD')),
25
+ * )
26
+ * ```
27
+ *
28
+ * ## Learn more
29
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS
30
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.7
31
+ *
32
+ * @group Models
33
+ */
34
+ export declare class OptionsRequest extends HTTPRequest {
35
+ /**
36
+ * Configures the object with a destination URI.
37
+ *
38
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
39
+ * it gets concatenated with the URL provided to the Axios instance
40
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
41
+ *
42
+ * @param resourceUri
43
+ * The URI where the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
44
+ * should send the [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/)
45
+ */
46
+ static to(resourceUri: Answerable<string>): OptionsRequest;
47
+ /**
48
+ * Overrides the default Axios request configuration provided
49
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
50
+ *
51
+ * #### Learn more
52
+ * - [`Answerable`](https://serenity-js.org/api/core/#Answerable)
53
+ * - [`WithAnswerableProperties`](https://serenity-js.org/api/core/#WithAnswerableProperties)
54
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
55
+ *
56
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
57
+ * Axios request configuration overrides
58
+ */
59
+ using(config: Answerable<WithAnswerableProperties<AxiosRequestConfig>>): OptionsRequest;
60
+ }
61
+ //# sourceMappingURL=OptionsRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptionsRequest.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/OptionsRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,cAAe,SAAQ,WAAW;IAE3C;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,cAAc;IAI1D;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC,GAAG,cAAc;CAG1F"}
@@ -0,0 +1,64 @@
1
+ import { Question } from '@serenity-js/core';
2
+ import { HTTPRequest } from './HTTPRequest.js';
3
+ /**
4
+ * The OPTIONS method requests information about the communication
5
+ * options available for the target resource, at either the origin
6
+ * server or an intervening intermediary. This method allows a client
7
+ * to determine the options and/or requirements associated with a
8
+ * resource, or the capabilities of a server, without implying a
9
+ * resource action.
10
+ *
11
+ * ## File download test
12
+ *
13
+ * ```ts
14
+ * import { actorCalled } from '@serenity-js/core'
15
+ * import { CallAnApi, OptionsRequest, LastResponse, Send } from '@serenity-js/rest'
16
+ * import { Ensure, equals } from '@serenity-js/assertions'
17
+ *
18
+ * await actorCalled('Apisitt')
19
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
20
+ * .attemptsTo(
21
+ * Send.a(OptionsRequest.to('/downloads/my-test-document.pdf')),
22
+ * Ensure.that(LastResponse.status(), equals(200)),
23
+ * Ensure.that(LastResponse.header('Allow'), equals('OPTIONS, GET, HEAD')),
24
+ * )
25
+ * ```
26
+ *
27
+ * ## Learn more
28
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS
29
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.7
30
+ *
31
+ * @group Models
32
+ */
33
+ export class OptionsRequest extends HTTPRequest {
34
+ /**
35
+ * Configures the object with a destination URI.
36
+ *
37
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
38
+ * it gets concatenated with the URL provided to the Axios instance
39
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
40
+ *
41
+ * @param resourceUri
42
+ * The URI where the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
43
+ * should send the [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/)
44
+ */
45
+ static to(resourceUri) {
46
+ return new OptionsRequest(resourceUri);
47
+ }
48
+ /**
49
+ * Overrides the default Axios request configuration provided
50
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
51
+ *
52
+ * #### Learn more
53
+ * - [`Answerable`](https://serenity-js.org/api/core/#Answerable)
54
+ * - [`WithAnswerableProperties`](https://serenity-js.org/api/core/#WithAnswerableProperties)
55
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
56
+ *
57
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
58
+ * Axios request configuration overrides
59
+ */
60
+ using(config) {
61
+ return new OptionsRequest(this.resourceUri, undefined, Question.fromObject(config));
62
+ }
63
+ }
64
+ //# sourceMappingURL=OptionsRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptionsRequest.js","sourceRoot":"","sources":["../../../src/screenplay/models/OptionsRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,cAAe,SAAQ,WAAW;IAE3C;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAA+B;QACrC,OAAO,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAgE;QAClE,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACxF,CAAC;CACJ"}
@@ -0,0 +1,65 @@
1
+ import type { Answerable, WithAnswerableProperties } from '@serenity-js/core';
2
+ import type { AxiosRequestConfig } from 'axios';
3
+ import { HTTPRequest } from './HTTPRequest.js';
4
+ /**
5
+ * The PATCH method requests that a set of changes described in the
6
+ * request entity be applied to the resource identified by the `resourceUri`.
7
+ *
8
+ * ## Add new resource to a collection
9
+ *
10
+ * ```ts
11
+ * import { actorCalled } from '@serenity-js/core'
12
+ * import { CallAnApi, LastResponse, PatchRequest, Send } from '@serenity-js/rest'
13
+ * import { Ensure, equals } from '@serenity-js/assertions'
14
+ *
15
+ * await actorCalled('Apisitt')
16
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
17
+ * .attemptsTo(
18
+ * Send.a(PatchRequest.to('/books/0-688-00230-7').with({
19
+ * lastReadOn: '2016-06-16',
20
+ * })),
21
+ * Ensure.that(LastResponse.status(), equals(204)),
22
+ * )
23
+ * ```
24
+ *
25
+ * ## Learn more
26
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH
27
+ * - https://tools.ietf.org/html/rfc5789
28
+ *
29
+ * @group Models
30
+ */
31
+ export declare class PatchRequest extends HTTPRequest {
32
+ /**
33
+ * Configures the object with a destination URI.
34
+ *
35
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
36
+ * it gets concatenated with the URL provided to the Axios instance
37
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
38
+ *
39
+ * @param resourceUri
40
+ * The URI where the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
41
+ * should send the [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/)
42
+ */
43
+ static to(resourceUri: Answerable<string>): PatchRequest;
44
+ /**
45
+ * Configures the object with a request body.
46
+ *
47
+ * @param data
48
+ * Data to be sent to the `resourceUri`
49
+ */
50
+ with(data: Answerable<any>): PatchRequest;
51
+ /**
52
+ * Overrides the default Axios request configuration provided
53
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
54
+ *
55
+ * #### Learn more
56
+ * - [`Answerable`](https://serenity-js.org/api/core/#Answerable)
57
+ * - [`WithAnswerableProperties`](https://serenity-js.org/api/core/#WithAnswerableProperties)
58
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
59
+ *
60
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
61
+ * Axios request configuration overrides
62
+ */
63
+ using(config: Answerable<WithAnswerableProperties<AxiosRequestConfig>>): PatchRequest;
64
+ }
65
+ //# sourceMappingURL=PatchRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PatchRequest.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/PatchRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAEzC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,YAAY;IAIxD;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,YAAY;IAIzC;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC,GAAG,YAAY;CAGxF"}