@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,70 @@
1
+ import { Question } from '@serenity-js/core';
2
+ import { HTTPRequest } from './HTTPRequest.js';
3
+ /**
4
+ * The PATCH method requests that a set of changes described in the
5
+ * request entity be applied to the resource identified by the `resourceUri`.
6
+ *
7
+ * ## Add new resource to a collection
8
+ *
9
+ * ```ts
10
+ * import { actorCalled } from '@serenity-js/core'
11
+ * import { CallAnApi, LastResponse, PatchRequest, Send } from '@serenity-js/rest'
12
+ * import { Ensure, equals } from '@serenity-js/assertions'
13
+ *
14
+ * await actorCalled('Apisitt')
15
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
16
+ * .attemptsTo(
17
+ * Send.a(PatchRequest.to('/books/0-688-00230-7').with({
18
+ * lastReadOn: '2016-06-16',
19
+ * })),
20
+ * Ensure.that(LastResponse.status(), equals(204)),
21
+ * )
22
+ * ```
23
+ *
24
+ * ## Learn more
25
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH
26
+ * - https://tools.ietf.org/html/rfc5789
27
+ *
28
+ * @group Models
29
+ */
30
+ export class PatchRequest 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 PatchRequest(resourceUri);
44
+ }
45
+ /**
46
+ * Configures the object with a request body.
47
+ *
48
+ * @param data
49
+ * Data to be sent to the `resourceUri`
50
+ */
51
+ with(data) {
52
+ return new PatchRequest(this.resourceUri, data, this.config);
53
+ }
54
+ /**
55
+ * Overrides the default Axios request configuration provided
56
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
57
+ *
58
+ * #### Learn more
59
+ * - [`Answerable`](https://serenity-js.org/api/core/#Answerable)
60
+ * - [`WithAnswerableProperties`](https://serenity-js.org/api/core/#WithAnswerableProperties)
61
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
62
+ *
63
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
64
+ * Axios request configuration overrides
65
+ */
66
+ using(config) {
67
+ return new PatchRequest(this.resourceUri, this.data, Question.fromObject(config));
68
+ }
69
+ }
70
+ //# sourceMappingURL=PatchRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PatchRequest.js","sourceRoot":"","sources":["../../../src/screenplay/models/PatchRequest.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,YAAa,SAAQ,WAAW;IAEzC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAA+B;QACrC,OAAO,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,IAAqB;QACtB,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAgE;QAClE,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACtF,CAAC;CACJ"}
@@ -0,0 +1,105 @@
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 POST method requests that the origin server accepts
6
+ * the entity enclosed in the request as a new subordinate of the resource
7
+ * identified by the `resourceUri`.
8
+ *
9
+ * This means that the POST should be used when you want to create a child resource under
10
+ * a collection of resources.
11
+ *
12
+ * POST request is neither [safe](https://developer.mozilla.org/en-US/docs/Glossary/Safe),
13
+ * nor [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent).
14
+ * This means that if you retry a POST request N times,
15
+ * a correctly implemented HTTP REST API will create N resources with N different URIs.
16
+ *
17
+ * ## Add new resource to a collection
18
+ *
19
+ * ```ts
20
+ * import { actorCalled } from '@serenity-js/core'
21
+ * import { CallAnApi, LastResponse, PostRequest, Send } from '@serenity-js/rest'
22
+ * import { Ensure, equals } from '@serenity-js/assertions'
23
+ *
24
+ * await actorCalled('Apisitt')
25
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
26
+ * .attemptsTo(
27
+ * Send.a(PostRequest.to('/books').with({
28
+ * isbn: '0-688-00230-7',
29
+ * title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
30
+ * author: 'Robert M. Pirsig',
31
+ * })),
32
+ * Ensure.that(LastResponse.status(), equals(201)),
33
+ * Ensure.that(LastResponse.header('Location'), equals('/books/0-688-00230-7')),
34
+ * )
35
+ * ```
36
+ *
37
+ * ## Submit an HTML form
38
+ *
39
+ * ```ts
40
+ * import { actorCalled } from '@serenity-js/core'
41
+ * import { CallAnApi, LastResponse, PostRequest, Send } from '@serenity-js/rest'
42
+ * import { Ensure, equals } from '@serenity-js/assertions'
43
+ * import { stringify } from 'querystring'
44
+ *
45
+ * const formData = stringify({
46
+ * name: actor.name,
47
+ * email: `${ actor.name }@example.com`,
48
+ * text: 'Your website is great! Learnt a lot :-)'
49
+ * });
50
+ *
51
+ * await actorCalled('Apisitt')
52
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
53
+ * .attemptsTo(
54
+ * Send.a(PostRequest.to('/feedback').with(formData).using({
55
+ * headers: {
56
+ * 'Content-Type': 'application/x-www-form-urlencoded',
57
+ * 'Content-Length': formData.length
58
+ * }
59
+ * })),
60
+ * Ensure.that(LastResponse.status(), equals(200)),
61
+ * Ensure.that(LastResponse.header('Location'), equals('/feedback/thank-you.html')),
62
+ * )
63
+ * ```
64
+ *
65
+ * ## Learn more
66
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
67
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.3
68
+ *
69
+ * @group Models
70
+ */
71
+ export declare class PostRequest extends HTTPRequest {
72
+ /**
73
+ * Configures the object with a destination URI.
74
+ *
75
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
76
+ * it gets concatenated with the URL provided to the Axios instance
77
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
78
+ *
79
+ * @param resourceUri
80
+ * The URI where the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
81
+ * should send the [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/)
82
+ */
83
+ static to(resourceUri: Answerable<string>): PostRequest;
84
+ /**
85
+ * Configures the object with a request body.
86
+ *
87
+ * @param data
88
+ * Data to be sent to the `resourceUri`
89
+ */
90
+ with(data: Answerable<any>): PostRequest;
91
+ /**
92
+ * Overrides the default Axios request configuration provided
93
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
94
+ *
95
+ * #### Learn more
96
+ * - [`Answerable`](https://serenity-js.org/api/core/#Answerable)
97
+ * - [`WithAnswerableProperties`](https://serenity-js.org/api/core/#WithAnswerableProperties)
98
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
99
+ *
100
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
101
+ * Axios request configuration overrides
102
+ */
103
+ using(config: Answerable<WithAnswerableProperties<AxiosRequestConfig>>): PostRequest;
104
+ }
105
+ //# sourceMappingURL=PostRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PostRequest.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/PostRequest.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,qBAAa,WAAY,SAAQ,WAAW;IAExC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,WAAW;IAIvD;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,WAAW;IAIxC;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC,GAAG,WAAW;CAGvF"}
@@ -0,0 +1,110 @@
1
+ import { Question } from '@serenity-js/core';
2
+ import { HTTPRequest } from './HTTPRequest.js';
3
+ /**
4
+ * The HTTP POST method requests that the origin server accepts
5
+ * the entity enclosed in the request as a new subordinate of the resource
6
+ * identified by the `resourceUri`.
7
+ *
8
+ * This means that the POST should be used when you want to create a child resource under
9
+ * a collection of resources.
10
+ *
11
+ * POST request is neither [safe](https://developer.mozilla.org/en-US/docs/Glossary/Safe),
12
+ * nor [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent).
13
+ * This means that if you retry a POST request N times,
14
+ * a correctly implemented HTTP REST API will create N resources with N different URIs.
15
+ *
16
+ * ## Add new resource to a collection
17
+ *
18
+ * ```ts
19
+ * import { actorCalled } from '@serenity-js/core'
20
+ * import { CallAnApi, LastResponse, PostRequest, Send } from '@serenity-js/rest'
21
+ * import { Ensure, equals } from '@serenity-js/assertions'
22
+ *
23
+ * await actorCalled('Apisitt')
24
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
25
+ * .attemptsTo(
26
+ * Send.a(PostRequest.to('/books').with({
27
+ * isbn: '0-688-00230-7',
28
+ * title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
29
+ * author: 'Robert M. Pirsig',
30
+ * })),
31
+ * Ensure.that(LastResponse.status(), equals(201)),
32
+ * Ensure.that(LastResponse.header('Location'), equals('/books/0-688-00230-7')),
33
+ * )
34
+ * ```
35
+ *
36
+ * ## Submit an HTML form
37
+ *
38
+ * ```ts
39
+ * import { actorCalled } from '@serenity-js/core'
40
+ * import { CallAnApi, LastResponse, PostRequest, Send } from '@serenity-js/rest'
41
+ * import { Ensure, equals } from '@serenity-js/assertions'
42
+ * import { stringify } from 'querystring'
43
+ *
44
+ * const formData = stringify({
45
+ * name: actor.name,
46
+ * email: `${ actor.name }@example.com`,
47
+ * text: 'Your website is great! Learnt a lot :-)'
48
+ * });
49
+ *
50
+ * await actorCalled('Apisitt')
51
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
52
+ * .attemptsTo(
53
+ * Send.a(PostRequest.to('/feedback').with(formData).using({
54
+ * headers: {
55
+ * 'Content-Type': 'application/x-www-form-urlencoded',
56
+ * 'Content-Length': formData.length
57
+ * }
58
+ * })),
59
+ * Ensure.that(LastResponse.status(), equals(200)),
60
+ * Ensure.that(LastResponse.header('Location'), equals('/feedback/thank-you.html')),
61
+ * )
62
+ * ```
63
+ *
64
+ * ## Learn more
65
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
66
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.3
67
+ *
68
+ * @group Models
69
+ */
70
+ export class PostRequest extends HTTPRequest {
71
+ /**
72
+ * Configures the object with a destination URI.
73
+ *
74
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
75
+ * it gets concatenated with the URL provided to the Axios instance
76
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
77
+ *
78
+ * @param resourceUri
79
+ * The URI where the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
80
+ * should send the [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/)
81
+ */
82
+ static to(resourceUri) {
83
+ return new PostRequest(resourceUri);
84
+ }
85
+ /**
86
+ * Configures the object with a request body.
87
+ *
88
+ * @param data
89
+ * Data to be sent to the `resourceUri`
90
+ */
91
+ with(data) {
92
+ return new PostRequest(this.resourceUri, data, this.config);
93
+ }
94
+ /**
95
+ * Overrides the default Axios request configuration provided
96
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
97
+ *
98
+ * #### Learn more
99
+ * - [`Answerable`](https://serenity-js.org/api/core/#Answerable)
100
+ * - [`WithAnswerableProperties`](https://serenity-js.org/api/core/#WithAnswerableProperties)
101
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
102
+ *
103
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
104
+ * Axios request configuration overrides
105
+ */
106
+ using(config) {
107
+ return new PostRequest(this.resourceUri, this.data, Question.fromObject(config));
108
+ }
109
+ }
110
+ //# sourceMappingURL=PostRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PostRequest.js","sourceRoot":"","sources":["../../../src/screenplay/models/PostRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;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;;;;;OAKG;IACH,IAAI,CAAC,IAAqB;QACtB,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAChE,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAgE;QAClE,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF,CAAC;CACJ"}
@@ -0,0 +1,75 @@
1
+ import type { Answerable, WithAnswerableProperties } from '@serenity-js/core';
2
+ import type { AxiosRequestConfig } from 'axios';
3
+ import { HTTPRequest } from './HTTPRequest.js';
4
+ /**
5
+ * The PUT method requests that the state of the target resource be
6
+ * created or replaced with the state defined by the representation
7
+ * enclosed in the request message payload.
8
+ *
9
+ * PUT request should be used when you want to create
10
+ * a new resource at a known `resourceUri` (e.g. `/books/0-688-00230-7`)
11
+ * or replace an existing resource at such `resourceUri`.
12
+ *
13
+ * PUT request is [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent):
14
+ * calling it once or several times successively has the same effect (that is no _side effect_).
15
+ *
16
+ * ## Create a new resource at a known location
17
+ *
18
+ * ```ts
19
+ * import { actorCalled } from '@serenity-js/core';
20
+ * import { CallAnApi, LastResponse, PutRequest, Send } from '@serenity-js/rest';
21
+ * import { Ensure, equals } from '@serenity-js/assertions';
22
+ *
23
+ * await actorCalled('Apisitt')
24
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
25
+ * .attemptsTo(
26
+ * Send.a(PutRequest.to('/books/0-688-00230-7').with({
27
+ * isbn: '0-688-00230-7',
28
+ * title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
29
+ * author: 'Robert M. Pirsig',
30
+ * })),
31
+ * Ensure.that(LastResponse.status(), equals(201)),
32
+ * )
33
+ * ```
34
+ *
35
+ * ## Learn more
36
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT
37
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.4
38
+ *
39
+ * @group Models
40
+ */
41
+ export declare class PutRequest extends HTTPRequest {
42
+ /**
43
+ * Configures the object with a destination URI.
44
+ *
45
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
46
+ * it gets concatenated with the URL provided to the Axios instance
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
+ * @param resourceUri
50
+ * The URI where the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
51
+ * should send the [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/)
52
+ */
53
+ static to(resourceUri: Answerable<string>): PutRequest;
54
+ /**
55
+ * Configures the object with a request body.
56
+ *
57
+ * @param data
58
+ * Data to be sent to the `resourceUri`
59
+ */
60
+ with(data: Answerable<any>): PutRequest;
61
+ /**
62
+ * Overrides the default Axios request configuration provided
63
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
64
+ *
65
+ * #### Learn more
66
+ * - [`Answerable`](https://serenity-js.org/api/core/#Answerable)
67
+ * - [`WithAnswerableProperties`](https://serenity-js.org/api/core/#WithAnswerableProperties)
68
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
69
+ *
70
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
71
+ * Axios request configuration overrides
72
+ */
73
+ using(config: Answerable<WithAnswerableProperties<AxiosRequestConfig>>): PutRequest;
74
+ }
75
+ //# sourceMappingURL=PutRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PutRequest.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/PutRequest.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,UAAW,SAAQ,WAAW;IAEvC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,UAAU;IAItD;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,UAAU;IAIvC;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC,GAAG,UAAU;CAGtF"}
@@ -0,0 +1,80 @@
1
+ import { Question } from '@serenity-js/core';
2
+ import { HTTPRequest } from './HTTPRequest.js';
3
+ /**
4
+ * The PUT method requests that the state of the target resource be
5
+ * created or replaced with the state defined by the representation
6
+ * enclosed in the request message payload.
7
+ *
8
+ * PUT request should be used when you want to create
9
+ * a new resource at a known `resourceUri` (e.g. `/books/0-688-00230-7`)
10
+ * or replace an existing resource at such `resourceUri`.
11
+ *
12
+ * PUT request is [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent):
13
+ * calling it once or several times successively has the same effect (that is no _side effect_).
14
+ *
15
+ * ## Create a new resource at a known location
16
+ *
17
+ * ```ts
18
+ * import { actorCalled } from '@serenity-js/core';
19
+ * import { CallAnApi, LastResponse, PutRequest, Send } from '@serenity-js/rest';
20
+ * import { Ensure, equals } from '@serenity-js/assertions';
21
+ *
22
+ * await actorCalled('Apisitt')
23
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
24
+ * .attemptsTo(
25
+ * Send.a(PutRequest.to('/books/0-688-00230-7').with({
26
+ * isbn: '0-688-00230-7',
27
+ * title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
28
+ * author: 'Robert M. Pirsig',
29
+ * })),
30
+ * Ensure.that(LastResponse.status(), equals(201)),
31
+ * )
32
+ * ```
33
+ *
34
+ * ## Learn more
35
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT
36
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.4
37
+ *
38
+ * @group Models
39
+ */
40
+ export class PutRequest extends HTTPRequest {
41
+ /**
42
+ * Configures the object with a destination URI.
43
+ *
44
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
45
+ * it gets concatenated with the URL provided to the Axios instance
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
+ * @param resourceUri
49
+ * The URI where the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
50
+ * should send the [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/)
51
+ */
52
+ static to(resourceUri) {
53
+ return new PutRequest(resourceUri);
54
+ }
55
+ /**
56
+ * Configures the object with a request body.
57
+ *
58
+ * @param data
59
+ * Data to be sent to the `resourceUri`
60
+ */
61
+ with(data) {
62
+ return new PutRequest(this.resourceUri, data, this.config);
63
+ }
64
+ /**
65
+ * Overrides the default Axios request configuration provided
66
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
67
+ *
68
+ * #### Learn more
69
+ * - [`Answerable`](https://serenity-js.org/api/core/#Answerable)
70
+ * - [`WithAnswerableProperties`](https://serenity-js.org/api/core/#WithAnswerableProperties)
71
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
72
+ *
73
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
74
+ * Axios request configuration overrides
75
+ */
76
+ using(config) {
77
+ return new PutRequest(this.resourceUri, this.data, Question.fromObject(config));
78
+ }
79
+ }
80
+ //# sourceMappingURL=PutRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PutRequest.js","sourceRoot":"","sources":["../../../src/screenplay/models/PutRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;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;;;;;OAKG;IACH,IAAI,CAAC,IAAqB;QACtB,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAgE;QAClE,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACpF,CAAC;CACJ"}
@@ -0,0 +1,9 @@
1
+ export * from './DeleteRequest.js';
2
+ export * from './GetRequest.js';
3
+ export * from './HeadRequest.js';
4
+ export * from './HTTPRequest.js';
5
+ export * from './OptionsRequest.js';
6
+ export * from './PatchRequest.js';
7
+ export * from './PostRequest.js';
8
+ export * from './PutRequest.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from './DeleteRequest.js';
2
+ export * from './GetRequest.js';
3
+ export * from './HeadRequest.js';
4
+ export * from './HTTPRequest.js';
5
+ export * from './OptionsRequest.js';
6
+ export * from './PatchRequest.js';
7
+ export * from './PostRequest.js';
8
+ export * from './PutRequest.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}