@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,135 @@
1
+ import type { Answerable } from '@serenity-js/core';
2
+ import { Interaction } from '@serenity-js/core';
3
+ /**
4
+ * Changes configuration of the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/)
5
+ * that the [actor](https://serenity-js.org/api/core/class/Actor/) executing this [interaction](https://serenity-js.org/api/core/class/Interaction/) has been configured with.
6
+ *
7
+ * ## Changing API URL for all subsequent requests
8
+ *
9
+ * ```ts
10
+ * import { actorCalled } from '@serenity-js/core';
11
+ * import { By Navigate, PageElement, Text } from '@serenity-js/web';
12
+ * import { axiosCreate, CallAnApi, ChangeApiConfig, GetRequest, LastResponse, Send } from '@serenity-js/rest'
13
+ * import { Ensure, equals } from '@serenity-js/assertions';
14
+ *
15
+ * import * as axios from 'axios';
16
+ *
17
+ * // Let's imagine that the website under test displays
18
+ * // a dynamically generated API URL that we would like to use
19
+ * const ApiDetailsWidget = {
20
+ * url: () => PageElement.located(By.id('api-url')).describedAs('API URL'),
21
+ * }
22
+ *
23
+ * await actorCalled('Apisitt')
24
+ * .whoCan(
25
+ * BrowseTheWeb.using(protractor.browser),
26
+ *
27
+ * // Note: no default base URL is given when the axios instance is created
28
+ * CallAnApi.using(axiosCreate()),
29
+ * )
30
+ * .attemptsTo(
31
+ * Navigate.to('/profile'),
32
+ *
33
+ * // We change the API URL based on the text displayed in the widget
34
+ * // (although we could change it to some arbitrary string too).
35
+ * ChangeApiConfig.setUrlTo(Text.of(ApiDetailsWidget.url())),
36
+ *
37
+ * // Any subsequent request will be sent to the newly set URL
38
+ * Send.a(GetRequest.to('/projects')),
39
+ * Ensure.that(LastResponse.status(), equals(200)),
40
+ * )
41
+ * ```
42
+ *
43
+ * ## Changing API port for all subsequent requests
44
+ *
45
+ * ```ts
46
+ * import { actorCalled } from '@serenity-js/core'
47
+ * import { LocalServer, ManageALocalServer, StartLocalServer } from '@serenity-js/local-server'
48
+ * import { CallAnApi, ChangeApiConfig, GetRequest, LastResponse, Send } from '@serenity-js/rest'
49
+ * import { Ensure, equals } from '@serenity-js/assertions'
50
+ *
51
+ * await actorCalled('Apisitt')
52
+ * .whoCan(
53
+ * ManageALocalServer.runningAHttpListener(someServer),
54
+ * CallAnApi.at('http://localhost'),
55
+ * )
56
+ * .attemptsTo(
57
+ * StartALocalServer.onRandomPort(),
58
+ * ChangeApiConfig.setPortTo(LocalServer.port()),
59
+ * Send.a(GetRequest.to('/api')),
60
+ * Ensure.that(LastResponse.status(), equals(200)),
61
+ * )
62
+ * ```
63
+ *
64
+ * ## Setting a header for all subsequent requests
65
+ *
66
+ * ```ts
67
+ * import { actorCalled, Question } from '@serenity-js/core'
68
+ * import { CallAnApi, ChangeApiConfig, GetRequest, LastResponse, Send } from '@serenity-js/rest'
69
+ * import { Ensure, equals } from '@serenity-js/assertions'
70
+ *
71
+ * // A sample Question reading a Node process environment variable
72
+ * const EnvVar = (var_name: string) =>
73
+ * Question.about(`${ name } environment variable`, actor => process.env[var_name]);
74
+ *
75
+ * await actorCalled('Apisitt')
76
+ * .whoCan(
77
+ * CallAnApi.at('http://localhost'),
78
+ * )
79
+ * .attemptsTo(
80
+ * ChangeApiConfig.setHeader('Authorization', EnvVar('TOKEN')),
81
+ * Send.a(GetRequest.to('/api')),
82
+ * Ensure.that(LastResponse.status(), equals(200)),
83
+ * )
84
+ * ```
85
+ *
86
+ * ## Handling sensitive information
87
+ *
88
+ * By design, any data handled by an actor appears in Serenity/JS reports.
89
+ * To prevent the exposure of any sensitive information, such as passwords or tokens, you should use [`Masked`](https://serenity-js.org/api/core/class/Masked/).
90
+ *
91
+ * ```ts
92
+ * import { actorCalled, Masked } from '@serenity-js/core'
93
+ * import { CallAnApi, ChangeApiConfig, GetRequest, LastResponse, Send } from '@serenity-js/rest'
94
+ * import { Ensure, equals } from '@serenity-js/assertions'
95
+ *
96
+ * await actorCalled('Apisitt')
97
+ * .whoCan(
98
+ * CallAnApi.at('http://localhost'),
99
+ * )
100
+ * .attemptsTo(
101
+ * ChangeApiConfig.setHeader('Authorization', Masked.valueOf('secret token')),
102
+ * Send.a(GetRequest.to('/api')),
103
+ * Ensure.that(LastResponse.status(), equals(200)),
104
+ * )
105
+ * ```
106
+ *
107
+ * @group Activities
108
+ */
109
+ export declare class ChangeApiConfig {
110
+ /**
111
+ * Instructs the [actor](https://serenity-js.org/api/core/class/Actor/) to change the base URL
112
+ * of their [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/)
113
+ *
114
+ * @param newApiUrl
115
+ */
116
+ static setUrlTo(newApiUrl: Answerable<string>): Interaction;
117
+ /**
118
+ * Instructs the [actor](https://serenity-js.org/api/core/class/Actor/) to change the port configured in the base URL
119
+ * of their [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/)
120
+ *
121
+ * @param newApiPort
122
+ */
123
+ static setPortTo(newApiPort: Answerable<number>): Interaction;
124
+ /**
125
+ * Instructs the [actor](https://serenity-js.org/api/core/class/Actor/) to change the configuration of the [`AxiosInstance`](https://axios-http.com/docs/instance)
126
+ * used by their [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/)
127
+ * and set an HTTP request header for any subsequent [HTTP requests](https://serenity-js.org/api/rest/class/HTTPRequest/)
128
+ * issued via [`Send`](https://serenity-js.org/api/rest/class/Send/).
129
+ *
130
+ * @param name
131
+ * @param value
132
+ */
133
+ static setHeader(name: Answerable<string>, value: Answerable<string>): Interaction;
134
+ }
135
+ //# sourceMappingURL=ChangeApiConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChangeApiConfig.d.ts","sourceRoot":"","sources":["../../../src/screenplay/interactions/ChangeApiConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAsD,MAAM,mBAAmB,CAAC;AACxG,OAAO,EAAK,WAAW,EAAc,MAAM,mBAAmB,CAAC;AAI/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyGG;AACH,qBAAa,eAAe;IAExB;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,WAAW;IAI3D;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,WAAW;IAI7D;;;;;;;;OAQG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,WAAW;CAGrF"}
@@ -0,0 +1,212 @@
1
+ import { URL } from 'node:url';
2
+ import { d, Interaction, LogicError } from '@serenity-js/core';
3
+ import { CallAnApi } from '../abilities/index.js';
4
+ /**
5
+ * Changes configuration of the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/)
6
+ * that the [actor](https://serenity-js.org/api/core/class/Actor/) executing this [interaction](https://serenity-js.org/api/core/class/Interaction/) has been configured with.
7
+ *
8
+ * ## Changing API URL for all subsequent requests
9
+ *
10
+ * ```ts
11
+ * import { actorCalled } from '@serenity-js/core';
12
+ * import { By Navigate, PageElement, Text } from '@serenity-js/web';
13
+ * import { axiosCreate, CallAnApi, ChangeApiConfig, GetRequest, LastResponse, Send } from '@serenity-js/rest'
14
+ * import { Ensure, equals } from '@serenity-js/assertions';
15
+ *
16
+ * import * as axios from 'axios';
17
+ *
18
+ * // Let's imagine that the website under test displays
19
+ * // a dynamically generated API URL that we would like to use
20
+ * const ApiDetailsWidget = {
21
+ * url: () => PageElement.located(By.id('api-url')).describedAs('API URL'),
22
+ * }
23
+ *
24
+ * await actorCalled('Apisitt')
25
+ * .whoCan(
26
+ * BrowseTheWeb.using(protractor.browser),
27
+ *
28
+ * // Note: no default base URL is given when the axios instance is created
29
+ * CallAnApi.using(axiosCreate()),
30
+ * )
31
+ * .attemptsTo(
32
+ * Navigate.to('/profile'),
33
+ *
34
+ * // We change the API URL based on the text displayed in the widget
35
+ * // (although we could change it to some arbitrary string too).
36
+ * ChangeApiConfig.setUrlTo(Text.of(ApiDetailsWidget.url())),
37
+ *
38
+ * // Any subsequent request will be sent to the newly set URL
39
+ * Send.a(GetRequest.to('/projects')),
40
+ * Ensure.that(LastResponse.status(), equals(200)),
41
+ * )
42
+ * ```
43
+ *
44
+ * ## Changing API port for all subsequent requests
45
+ *
46
+ * ```ts
47
+ * import { actorCalled } from '@serenity-js/core'
48
+ * import { LocalServer, ManageALocalServer, StartLocalServer } from '@serenity-js/local-server'
49
+ * import { CallAnApi, ChangeApiConfig, GetRequest, LastResponse, Send } from '@serenity-js/rest'
50
+ * import { Ensure, equals } from '@serenity-js/assertions'
51
+ *
52
+ * await actorCalled('Apisitt')
53
+ * .whoCan(
54
+ * ManageALocalServer.runningAHttpListener(someServer),
55
+ * CallAnApi.at('http://localhost'),
56
+ * )
57
+ * .attemptsTo(
58
+ * StartALocalServer.onRandomPort(),
59
+ * ChangeApiConfig.setPortTo(LocalServer.port()),
60
+ * Send.a(GetRequest.to('/api')),
61
+ * Ensure.that(LastResponse.status(), equals(200)),
62
+ * )
63
+ * ```
64
+ *
65
+ * ## Setting a header for all subsequent requests
66
+ *
67
+ * ```ts
68
+ * import { actorCalled, Question } from '@serenity-js/core'
69
+ * import { CallAnApi, ChangeApiConfig, GetRequest, LastResponse, Send } from '@serenity-js/rest'
70
+ * import { Ensure, equals } from '@serenity-js/assertions'
71
+ *
72
+ * // A sample Question reading a Node process environment variable
73
+ * const EnvVar = (var_name: string) =>
74
+ * Question.about(`${ name } environment variable`, actor => process.env[var_name]);
75
+ *
76
+ * await actorCalled('Apisitt')
77
+ * .whoCan(
78
+ * CallAnApi.at('http://localhost'),
79
+ * )
80
+ * .attemptsTo(
81
+ * ChangeApiConfig.setHeader('Authorization', EnvVar('TOKEN')),
82
+ * Send.a(GetRequest.to('/api')),
83
+ * Ensure.that(LastResponse.status(), equals(200)),
84
+ * )
85
+ * ```
86
+ *
87
+ * ## Handling sensitive information
88
+ *
89
+ * By design, any data handled by an actor appears in Serenity/JS reports.
90
+ * To prevent the exposure of any sensitive information, such as passwords or tokens, you should use [`Masked`](https://serenity-js.org/api/core/class/Masked/).
91
+ *
92
+ * ```ts
93
+ * import { actorCalled, Masked } from '@serenity-js/core'
94
+ * import { CallAnApi, ChangeApiConfig, GetRequest, LastResponse, Send } from '@serenity-js/rest'
95
+ * import { Ensure, equals } from '@serenity-js/assertions'
96
+ *
97
+ * await actorCalled('Apisitt')
98
+ * .whoCan(
99
+ * CallAnApi.at('http://localhost'),
100
+ * )
101
+ * .attemptsTo(
102
+ * ChangeApiConfig.setHeader('Authorization', Masked.valueOf('secret token')),
103
+ * Send.a(GetRequest.to('/api')),
104
+ * Ensure.that(LastResponse.status(), equals(200)),
105
+ * )
106
+ * ```
107
+ *
108
+ * @group Activities
109
+ */
110
+ export class ChangeApiConfig {
111
+ /**
112
+ * Instructs the [actor](https://serenity-js.org/api/core/class/Actor/) to change the base URL
113
+ * of their [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/)
114
+ *
115
+ * @param newApiUrl
116
+ */
117
+ static setUrlTo(newApiUrl) {
118
+ return new ChangeApiConfigSetUrl(newApiUrl);
119
+ }
120
+ /**
121
+ * Instructs the [actor](https://serenity-js.org/api/core/class/Actor/) to change the port configured in the base URL
122
+ * of their [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/)
123
+ *
124
+ * @param newApiPort
125
+ */
126
+ static setPortTo(newApiPort) {
127
+ return new ChangeApiConfigSetPort(newApiPort);
128
+ }
129
+ /**
130
+ * Instructs the [actor](https://serenity-js.org/api/core/class/Actor/) to change the configuration of the [`AxiosInstance`](https://axios-http.com/docs/instance)
131
+ * used by their [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/)
132
+ * and set an HTTP request header for any subsequent [HTTP requests](https://serenity-js.org/api/rest/class/HTTPRequest/)
133
+ * issued via [`Send`](https://serenity-js.org/api/rest/class/Send/).
134
+ *
135
+ * @param name
136
+ * @param value
137
+ */
138
+ static setHeader(name, value) {
139
+ return new ChangeApiConfigSetHeader(name, value);
140
+ }
141
+ }
142
+ /**
143
+ * @package
144
+ */
145
+ class ChangeApiConfigSetUrl extends Interaction {
146
+ newApiUrl;
147
+ constructor(newApiUrl) {
148
+ super(d `#actor changes API url configuration to ${newApiUrl}`);
149
+ this.newApiUrl = newApiUrl;
150
+ }
151
+ performAs(actor) {
152
+ return actor.answer(this.newApiUrl)
153
+ .then(newApiUrl => CallAnApi.as(actor).modifyConfig(config => config.baseURL = newApiUrl));
154
+ }
155
+ }
156
+ /**
157
+ * @package
158
+ */
159
+ class ChangeApiConfigSetPort extends Interaction {
160
+ newPort;
161
+ constructor(newPort) {
162
+ super(`#actor changes API port configuration to ${newPort}`);
163
+ this.newPort = newPort;
164
+ }
165
+ performAs(actor) {
166
+ return actor.answer(this.newPort)
167
+ .then(newPort => CallAnApi.as(actor).modifyConfig(config => {
168
+ if (!config.baseURL) {
169
+ throw new LogicError(`Can't change the port of a baseURL that has not been set`);
170
+ }
171
+ try {
172
+ const newUrl = new URL(config.baseURL);
173
+ newUrl.port = `${newPort}`;
174
+ config.baseURL = newUrl.toString();
175
+ }
176
+ catch (error) {
177
+ throw new LogicError(`Could not change the API port`, error);
178
+ }
179
+ }));
180
+ }
181
+ }
182
+ /**
183
+ * @package
184
+ *
185
+ * @see https://github.com/axios/axios#custom-instance-defaults
186
+ */
187
+ class ChangeApiConfigSetHeader extends Interaction {
188
+ name;
189
+ value;
190
+ constructor(name, value) {
191
+ super(`#actor changes API URL and sets header "${name}" to "${value}"`);
192
+ this.name = name;
193
+ this.value = value;
194
+ }
195
+ performAs(actor) {
196
+ return Promise.all([
197
+ actor.answer(this.name),
198
+ actor.answer(this.value),
199
+ ]).
200
+ then(([name, value]) => {
201
+ if (!name) {
202
+ throw new LogicError(`Looks like the name of the header is missing, "${name}" given`);
203
+ }
204
+ // A header with an empty value might still be valid so we don't validate the value
205
+ // see: https://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.1
206
+ return CallAnApi.as(actor).modifyConfig(config => {
207
+ config.headers.common[name] = value;
208
+ });
209
+ });
210
+ }
211
+ }
212
+ //# sourceMappingURL=ChangeApiConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChangeApiConfig.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/ChangeApiConfig.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,48 @@
1
+ import type { Answerable, AnswersQuestions, CollectsArtifacts, UsesAbilities } from '@serenity-js/core';
2
+ import { Interaction } from '@serenity-js/core';
3
+ import type { AxiosRequestConfig } from 'axios';
4
+ /**
5
+ * Sends a [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/) to a specified URL.
6
+ *
7
+ * The response to the request is made available via [`LastResponse`](https://serenity-js.org/api/rest/class/LastResponse/).
8
+ *
9
+ * ## Send a GET request
10
+ *
11
+ * ```ts
12
+ * import { actorCalled } from '@serenity-js/core'
13
+ * import { CallAnApi, GetRequest, 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(GetRequest.to('/books/0-688-00230-7')),
20
+ * Ensure.that(LastResponse.status(), equals(200)),
21
+ * )
22
+ * ```
23
+ *
24
+ * @group Activities
25
+ */
26
+ export declare class Send extends Interaction {
27
+ private readonly request;
28
+ /**
29
+ * Instantiates a new [interaction](https://serenity-js.org/api/core/class/Interaction/) to [`Send`](https://serenity-js.org/api/rest/class/Send/).
30
+ *
31
+ * #### Learn more
32
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
33
+ *
34
+ * @param request
35
+ */
36
+ static a(request: Answerable<AxiosRequestConfig>): Interaction;
37
+ /**
38
+ * @param request
39
+ */
40
+ protected constructor(request: Answerable<AxiosRequestConfig>);
41
+ /**
42
+ * @inheritDoc
43
+ */
44
+ performAs(actor: UsesAbilities & CollectsArtifacts & AnswersQuestions): Promise<void>;
45
+ private responseToArtifact;
46
+ private requestToArtifactName;
47
+ }
48
+ //# sourceMappingURL=Send.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Send.d.ts","sourceRoot":"","sources":["../../../src/screenplay/interactions/Send.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACxG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAE,kBAAkB,EAAgE,MAAM,OAAO,CAAC;AAK9G;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,IAAK,SAAQ,WAAW;IAiBX,OAAO,CAAC,QAAQ,CAAC,OAAO;IAf9C;;;;;;;OAOG;IACH,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,kBAAkB,CAAC,GAAG,WAAW;IAI9D;;OAEG;IACH,SAAS,aAA8B,OAAO,EAAE,UAAU,CAAC,kBAAkB,CAAC;IAI9E;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBrF,OAAO,CAAC,kBAAkB;IA0B1B,OAAO,CAAC,qBAAqB;CAGhC"}
@@ -0,0 +1,83 @@
1
+ import { Interaction } from '@serenity-js/core';
2
+ import { HTTPRequestResponse, Name } from '@serenity-js/core/model';
3
+ import { AxiosHeaders } from 'axios';
4
+ import { CallAnApi } from '../abilities/index.js';
5
+ /**
6
+ * Sends a [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/) to a specified URL.
7
+ *
8
+ * The response to the request is made available via [`LastResponse`](https://serenity-js.org/api/rest/class/LastResponse/).
9
+ *
10
+ * ## Send a GET request
11
+ *
12
+ * ```ts
13
+ * import { actorCalled } from '@serenity-js/core'
14
+ * import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
15
+ * import { Ensure, equals } from '@serenity-js/assertions'
16
+ *
17
+ * await actorCalled('Apisitt')
18
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
19
+ * .attemptsTo(
20
+ * Send.a(GetRequest.to('/books/0-688-00230-7')),
21
+ * Ensure.that(LastResponse.status(), equals(200)),
22
+ * )
23
+ * ```
24
+ *
25
+ * @group Activities
26
+ */
27
+ export class Send extends Interaction {
28
+ request;
29
+ /**
30
+ * Instantiates a new [interaction](https://serenity-js.org/api/core/class/Interaction/) to [`Send`](https://serenity-js.org/api/rest/class/Send/).
31
+ *
32
+ * #### Learn more
33
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
34
+ *
35
+ * @param request
36
+ */
37
+ static a(request) {
38
+ return new Send(request);
39
+ }
40
+ /**
41
+ * @param request
42
+ */
43
+ constructor(request) {
44
+ super(`#actor sends ${request.toString()}`);
45
+ this.request = request;
46
+ }
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ performAs(actor) {
51
+ const callAnApi = CallAnApi.as(actor);
52
+ return actor.answer(this.request)
53
+ .then(config => callAnApi.request(config).then((response) => {
54
+ const resolvedUrl = callAnApi.resolveUrl(config);
55
+ actor.collect(this.responseToArtifact(resolvedUrl, response), this.requestToArtifactName(response.config.method, resolvedUrl));
56
+ }));
57
+ }
58
+ responseToArtifact(targetUrl, response) {
59
+ const request = response.config;
60
+ const axiosRequestHeaders = request.headers;
61
+ const requestHeaders = AxiosHeaders.from(axiosRequestHeaders).toJSON(true);
62
+ const axiosResponseHeaders = response.headers;
63
+ const responseHeaders = AxiosHeaders.from(axiosResponseHeaders).toJSON(false);
64
+ const requestAndResponse = {
65
+ request: {
66
+ method: request.method,
67
+ url: targetUrl,
68
+ headers: requestHeaders,
69
+ data: request.data,
70
+ },
71
+ response: {
72
+ status: response.status,
73
+ headers: responseHeaders,
74
+ data: response.data,
75
+ },
76
+ };
77
+ return HTTPRequestResponse.fromJSON(requestAndResponse);
78
+ }
79
+ requestToArtifactName(method, url) {
80
+ return new Name(`${method.toUpperCase()} ${url}`);
81
+ }
82
+ }
83
+ //# sourceMappingURL=Send.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Send.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/Send.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpE,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,IAAK,SAAQ,WAAW;IAiBM;IAfvC;;;;;;;OAOG;IACH,MAAM,CAAC,CAAC,CAAC,OAAuC;QAC5C,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,YAAuC,OAAuC;QAC1E,KAAK,CAAC,gBAAiB,OAAO,CAAC,QAAQ,EAAG,EAAE,CAAC,CAAC;QADX,YAAO,GAAP,OAAO,CAAgC;IAE9E,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,KAA2D;QACjE,MAAM,SAAS,GAAG,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QAEtC,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;aAC5B,IAAI,CAAC,MAAM,CAAC,EAAE,CACX,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,QAAuB,EAAE,EAAE;YACvD,MAAM,WAAW,GAAG,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAEjD,KAAK,CAAC,OAAO,CACT,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,QAAQ,CAAC,EAC9C,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAClE,CAAC;QACN,CAAC,CAAC,CACL,CAAC;IACV,CAAC;IAEO,kBAAkB,CAAC,SAAiB,EAAE,QAAuB;QACjE,MAAM,OAAO,GAAuB,QAAQ,CAAC,MAAM,CAAC;QAEpD,MAAM,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;QAC5C,MAAM,cAAc,GAA8C,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,MAAM,CAAC,IAAI,CAA8C,CAAC;QAEnK,MAAM,oBAAoB,GAAmD,QAAQ,CAAC,OAAO,CAAC;QAC9F,MAAM,eAAe,GAAG,YAAY,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,KAAK,CAA4B,CAAC;QAEzG,MAAM,kBAAkB,GAAuB;YAC3C,OAAO,EAAE;gBACL,MAAM,EAAM,OAAO,CAAC,MAAM;gBAC1B,GAAG,EAAS,SAAS;gBACrB,OAAO,EAAK,cAAc;gBAC1B,IAAI,EAAQ,OAAO,CAAC,IAAI;aAC3B;YACD,QAAQ,EAAE;gBACN,MAAM,EAAM,QAAQ,CAAC,MAAM;gBAC3B,OAAO,EAAK,eAAkF;gBAC9F,IAAI,EAAQ,QAAQ,CAAC,IAAI;aAC5B;SACJ,CAAC;QAEF,OAAO,mBAAmB,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC5D,CAAC;IAEO,qBAAqB,CAAC,MAAc,EAAE,GAAW;QACrD,OAAO,IAAI,IAAI,CAAC,GAAI,MAAM,CAAC,WAAW,EAAG,IAAK,GAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;CACJ"}
@@ -0,0 +1,3 @@
1
+ export * from './ChangeApiConfig.js';
2
+ export * from './Send.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/interactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './ChangeApiConfig.js';
2
+ export * from './Send.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC"}
@@ -0,0 +1,66 @@
1
+ import type { Answerable, WithAnswerableProperties } from '@serenity-js/core';
2
+ import type { AxiosRequestConfig } from 'axios';
3
+ import { HTTPRequest } from './HTTPRequest.js';
4
+ /**
5
+ * The DELETE method requests that the origin server remove the
6
+ * association between the target resource and its current
7
+ * functionality.
8
+ *
9
+ * ## Create and then remove a resource
10
+ *
11
+ * ```ts
12
+ * import { actorCalled } from '@serenity-js/core'
13
+ * import { CallAnApi, DeleteRequest, LastResponse, PostRequest, Send } from '@serenity-js/rest'
14
+ * import { Ensure, equals, startsWith } from '@serenity-js/assertions'
15
+ *
16
+ * await actorCalled('Apisitt')
17
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
18
+ * .attemptsTo(
19
+ * // create a new test user account
20
+ * Send.a(PostRequest.to('/users').with({
21
+ * login: 'tester',
22
+ * password: 'P@ssword1',
23
+ * }),
24
+ * Ensure.that(LastResponse.status(), equals(201)),
25
+ * Ensure.that(LastResponse.header('Location'), startsWith('/users')),
26
+ *
27
+ * // delete the test user account
28
+ * Send.a(DeleteRequest.to(LastResponse.header('Location'))),
29
+ * Ensure.that(LastResponse.status(), equals(200)),
30
+ * )
31
+ * ```
32
+ *
33
+ * ## Learn more
34
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE
35
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.5
36
+ *
37
+ * @group Models
38
+ */
39
+ export declare class DeleteRequest extends HTTPRequest {
40
+ /**
41
+ * Configures the object with a destination URI.
42
+ *
43
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
44
+ * it gets concatenated with the URL provided to the Axios instance
45
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
46
+ *
47
+ * @param resourceUri
48
+ * The URI where the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
49
+ * should send the [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/)
50
+ */
51
+ static to(resourceUri: Answerable<string>): DeleteRequest;
52
+ /**
53
+ * Overrides the default Axios request configuration provided
54
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
55
+ *
56
+ * #### Learn more
57
+ * - [`Answerable`](https://serenity-js.org/api/core/#Answerable)
58
+ * - [`WithAnswerableProperties`](https://serenity-js.org/api/core/#WithAnswerableProperties)
59
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
60
+ *
61
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
62
+ * Axios request configuration overrides
63
+ */
64
+ using(config: Answerable<WithAnswerableProperties<AxiosRequestConfig>>): DeleteRequest;
65
+ }
66
+ //# sourceMappingURL=DeleteRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeleteRequest.d.ts","sourceRoot":"","sources":["../../../src/screenplay/models/DeleteRequest.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAE1C;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,aAAa;IAIzD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC,GAAG,aAAa;CAGzF"}
@@ -0,0 +1,69 @@
1
+ import { Question } from '@serenity-js/core';
2
+ import { HTTPRequest } from './HTTPRequest.js';
3
+ /**
4
+ * The DELETE method requests that the origin server remove the
5
+ * association between the target resource and its current
6
+ * functionality.
7
+ *
8
+ * ## Create and then remove a resource
9
+ *
10
+ * ```ts
11
+ * import { actorCalled } from '@serenity-js/core'
12
+ * import { CallAnApi, DeleteRequest, LastResponse, PostRequest, Send } from '@serenity-js/rest'
13
+ * import { Ensure, equals, startsWith } from '@serenity-js/assertions'
14
+ *
15
+ * await actorCalled('Apisitt')
16
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
17
+ * .attemptsTo(
18
+ * // create a new test user account
19
+ * Send.a(PostRequest.to('/users').with({
20
+ * login: 'tester',
21
+ * password: 'P@ssword1',
22
+ * }),
23
+ * Ensure.that(LastResponse.status(), equals(201)),
24
+ * Ensure.that(LastResponse.header('Location'), startsWith('/users')),
25
+ *
26
+ * // delete the test user account
27
+ * Send.a(DeleteRequest.to(LastResponse.header('Location'))),
28
+ * Ensure.that(LastResponse.status(), equals(200)),
29
+ * )
30
+ * ```
31
+ *
32
+ * ## Learn more
33
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE
34
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.5
35
+ *
36
+ * @group Models
37
+ */
38
+ export class DeleteRequest extends HTTPRequest {
39
+ /**
40
+ * Configures the object with a destination URI.
41
+ *
42
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
43
+ * it gets concatenated with the URL provided to the Axios instance
44
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
45
+ *
46
+ * @param resourceUri
47
+ * The URI where the [`Actor`](https://serenity-js.org/api/core/class/Actor/)
48
+ * should send the [`HTTPRequest`](https://serenity-js.org/api/rest/class/HTTPRequest/)
49
+ */
50
+ static to(resourceUri) {
51
+ return new DeleteRequest(resourceUri);
52
+ }
53
+ /**
54
+ * Overrides the default Axios request configuration provided
55
+ * when the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/) was instantiated.
56
+ *
57
+ * #### Learn more
58
+ * - [`Answerable`](https://serenity-js.org/api/core/#Answerable)
59
+ * - [`WithAnswerableProperties`](https://serenity-js.org/api/core/#WithAnswerableProperties)
60
+ * - [AxiosRequestConfig](https://axios-http.com/docs/req_config)
61
+ *
62
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
63
+ * Axios request configuration overrides
64
+ */
65
+ using(config) {
66
+ return new DeleteRequest(this.resourceUri, undefined, Question.fromObject(config));
67
+ }
68
+ }
69
+ //# sourceMappingURL=DeleteRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeleteRequest.js","sourceRoot":"","sources":["../../../src/screenplay/models/DeleteRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,OAAO,aAAc,SAAQ,WAAW;IAE1C;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAA+B;QACrC,OAAO,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAgE;QAClE,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACvF,CAAC;CACJ"}