@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.
- package/CHANGELOG.md +28 -0
- package/esm/index.d.ts +3 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +3 -0
- package/esm/index.js.map +1 -0
- package/esm/io/AxiosRequestConfigDefaults.d.ts +15 -0
- package/esm/io/AxiosRequestConfigDefaults.d.ts.map +1 -0
- package/esm/io/AxiosRequestConfigDefaults.js +2 -0
- package/esm/io/AxiosRequestConfigDefaults.js.map +1 -0
- package/esm/io/EnvironmentVariables.d.ts +9 -0
- package/esm/io/EnvironmentVariables.d.ts.map +1 -0
- package/esm/io/EnvironmentVariables.js +35 -0
- package/esm/io/EnvironmentVariables.js.map +1 -0
- package/esm/io/ProxyAgent.d.ts +52 -0
- package/esm/io/ProxyAgent.d.ts.map +1 -0
- package/esm/io/ProxyAgent.js +83 -0
- package/esm/io/ProxyAgent.js.map +1 -0
- package/esm/io/ProxyBypass.d.ts +6 -0
- package/esm/io/ProxyBypass.d.ts.map +1 -0
- package/esm/io/ProxyBypass.js +66 -0
- package/esm/io/ProxyBypass.js.map +1 -0
- package/esm/io/createAxios.d.ts +9 -0
- package/esm/io/createAxios.d.ts.map +1 -0
- package/esm/io/createAxios.js +40 -0
- package/esm/io/createAxios.js.map +1 -0
- package/esm/io/createUrl.d.ts +9 -0
- package/esm/io/createUrl.d.ts.map +1 -0
- package/esm/io/createUrl.js +26 -0
- package/esm/io/createUrl.js.map +1 -0
- package/esm/io/index.d.ts +3 -0
- package/esm/io/index.d.ts.map +1 -0
- package/esm/io/index.js +3 -0
- package/esm/io/index.js.map +1 -0
- package/esm/io/proxy.d.ts +14 -0
- package/esm/io/proxy.d.ts.map +1 -0
- package/esm/io/proxy.js +66 -0
- package/esm/io/proxy.js.map +1 -0
- package/esm/screenplay/abilities/AxiosRequestConfigDefaults.d.ts +14 -0
- package/esm/screenplay/abilities/AxiosRequestConfigDefaults.d.ts.map +1 -0
- package/esm/screenplay/abilities/AxiosRequestConfigDefaults.js +2 -0
- package/esm/screenplay/abilities/AxiosRequestConfigDefaults.js.map +1 -0
- package/esm/screenplay/abilities/CallAnApi.d.ts +443 -0
- package/esm/screenplay/abilities/CallAnApi.d.ts.map +1 -0
- package/esm/screenplay/abilities/CallAnApi.js +555 -0
- package/esm/screenplay/abilities/CallAnApi.js.map +1 -0
- package/esm/screenplay/abilities/index.d.ts +2 -0
- package/esm/screenplay/abilities/index.d.ts.map +1 -0
- package/esm/screenplay/abilities/index.js +2 -0
- package/esm/screenplay/abilities/index.js.map +1 -0
- package/esm/screenplay/index.d.ts +5 -0
- package/esm/screenplay/index.d.ts.map +1 -0
- package/esm/screenplay/index.js +5 -0
- package/esm/screenplay/index.js.map +1 -0
- package/esm/screenplay/interactions/ChangeApiConfig.d.ts +135 -0
- package/esm/screenplay/interactions/ChangeApiConfig.d.ts.map +1 -0
- package/esm/screenplay/interactions/ChangeApiConfig.js +212 -0
- package/esm/screenplay/interactions/ChangeApiConfig.js.map +1 -0
- package/esm/screenplay/interactions/Send.d.ts +48 -0
- package/esm/screenplay/interactions/Send.d.ts.map +1 -0
- package/esm/screenplay/interactions/Send.js +83 -0
- package/esm/screenplay/interactions/Send.js.map +1 -0
- package/esm/screenplay/interactions/index.d.ts +3 -0
- package/esm/screenplay/interactions/index.d.ts.map +1 -0
- package/esm/screenplay/interactions/index.js +3 -0
- package/esm/screenplay/interactions/index.js.map +1 -0
- package/esm/screenplay/models/DeleteRequest.d.ts +66 -0
- package/esm/screenplay/models/DeleteRequest.d.ts.map +1 -0
- package/esm/screenplay/models/DeleteRequest.js +69 -0
- package/esm/screenplay/models/DeleteRequest.js.map +1 -0
- package/esm/screenplay/models/GetRequest.d.ts +73 -0
- package/esm/screenplay/models/GetRequest.d.ts.map +1 -0
- package/esm/screenplay/models/GetRequest.js +76 -0
- package/esm/screenplay/models/GetRequest.js.map +1 -0
- package/esm/screenplay/models/HTTPRequest.d.ts +40 -0
- package/esm/screenplay/models/HTTPRequest.d.ts.map +1 -0
- package/esm/screenplay/models/HTTPRequest.js +62 -0
- package/esm/screenplay/models/HTTPRequest.js.map +1 -0
- package/esm/screenplay/models/HeadRequest.d.ts +58 -0
- package/esm/screenplay/models/HeadRequest.d.ts.map +1 -0
- package/esm/screenplay/models/HeadRequest.js +61 -0
- package/esm/screenplay/models/HeadRequest.js.map +1 -0
- package/esm/screenplay/models/OptionsRequest.d.ts +61 -0
- package/esm/screenplay/models/OptionsRequest.d.ts.map +1 -0
- package/esm/screenplay/models/OptionsRequest.js +64 -0
- package/esm/screenplay/models/OptionsRequest.js.map +1 -0
- package/esm/screenplay/models/PatchRequest.d.ts +65 -0
- package/esm/screenplay/models/PatchRequest.d.ts.map +1 -0
- package/esm/screenplay/models/PatchRequest.js +70 -0
- package/esm/screenplay/models/PatchRequest.js.map +1 -0
- package/esm/screenplay/models/PostRequest.d.ts +105 -0
- package/esm/screenplay/models/PostRequest.d.ts.map +1 -0
- package/esm/screenplay/models/PostRequest.js +110 -0
- package/esm/screenplay/models/PostRequest.js.map +1 -0
- package/esm/screenplay/models/PutRequest.d.ts +75 -0
- package/esm/screenplay/models/PutRequest.d.ts.map +1 -0
- package/esm/screenplay/models/PutRequest.js +80 -0
- package/esm/screenplay/models/PutRequest.js.map +1 -0
- package/esm/screenplay/models/index.d.ts +9 -0
- package/esm/screenplay/models/index.d.ts.map +1 -0
- package/esm/screenplay/models/index.js +9 -0
- package/esm/screenplay/models/index.js.map +1 -0
- package/esm/screenplay/questions/LastResponse.d.ts +189 -0
- package/esm/screenplay/questions/LastResponse.d.ts.map +1 -0
- package/esm/screenplay/questions/LastResponse.js +205 -0
- package/esm/screenplay/questions/LastResponse.js.map +1 -0
- package/esm/screenplay/questions/index.d.ts +2 -0
- package/esm/screenplay/questions/index.d.ts.map +1 -0
- package/esm/screenplay/questions/index.js +2 -0
- package/esm/screenplay/questions/index.js.map +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/io/ProxyBypass.js +2 -2
- package/lib/io/ProxyBypass.js.map +1 -1
- package/lib/io/createAxios.d.ts +1 -1
- package/lib/io/createAxios.d.ts.map +1 -1
- package/lib/io/createAxios.js +2 -2
- package/lib/io/createAxios.js.map +1 -1
- package/lib/io/index.d.ts +2 -2
- package/lib/io/index.d.ts.map +1 -1
- package/lib/io/index.js +2 -2
- package/lib/io/index.js.map +1 -1
- package/lib/io/proxy.d.ts +2 -2
- package/lib/io/proxy.d.ts.map +1 -1
- package/lib/io/proxy.js +9 -9
- package/lib/io/proxy.js.map +1 -1
- package/lib/package.json +1 -0
- package/lib/screenplay/abilities/CallAnApi.d.ts +1 -1
- package/lib/screenplay/abilities/CallAnApi.d.ts.map +1 -1
- package/lib/screenplay/abilities/CallAnApi.js +4 -4
- package/lib/screenplay/abilities/CallAnApi.js.map +1 -1
- package/lib/screenplay/abilities/index.d.ts +1 -1
- package/lib/screenplay/abilities/index.d.ts.map +1 -1
- package/lib/screenplay/abilities/index.js +1 -1
- package/lib/screenplay/abilities/index.js.map +1 -1
- package/lib/screenplay/index.d.ts +4 -4
- package/lib/screenplay/index.d.ts.map +1 -1
- package/lib/screenplay/index.js +4 -4
- package/lib/screenplay/index.js.map +1 -1
- package/lib/screenplay/interactions/ChangeApiConfig.js +4 -4
- package/lib/screenplay/interactions/ChangeApiConfig.js.map +1 -1
- package/lib/screenplay/interactions/Send.js +3 -3
- package/lib/screenplay/interactions/Send.js.map +1 -1
- package/lib/screenplay/interactions/index.d.ts +2 -2
- package/lib/screenplay/interactions/index.d.ts.map +1 -1
- package/lib/screenplay/interactions/index.js +2 -2
- package/lib/screenplay/interactions/index.js.map +1 -1
- package/lib/screenplay/models/DeleteRequest.d.ts +1 -1
- package/lib/screenplay/models/DeleteRequest.d.ts.map +1 -1
- package/lib/screenplay/models/DeleteRequest.js +2 -2
- package/lib/screenplay/models/DeleteRequest.js.map +1 -1
- package/lib/screenplay/models/GetRequest.d.ts +1 -1
- package/lib/screenplay/models/GetRequest.d.ts.map +1 -1
- package/lib/screenplay/models/GetRequest.js +2 -2
- package/lib/screenplay/models/GetRequest.js.map +1 -1
- package/lib/screenplay/models/HTTPRequest.js +1 -1
- package/lib/screenplay/models/HTTPRequest.js.map +1 -1
- package/lib/screenplay/models/HeadRequest.d.ts +1 -1
- package/lib/screenplay/models/HeadRequest.d.ts.map +1 -1
- package/lib/screenplay/models/HeadRequest.js +2 -2
- package/lib/screenplay/models/HeadRequest.js.map +1 -1
- package/lib/screenplay/models/OptionsRequest.d.ts +1 -1
- package/lib/screenplay/models/OptionsRequest.d.ts.map +1 -1
- package/lib/screenplay/models/OptionsRequest.js +2 -2
- package/lib/screenplay/models/OptionsRequest.js.map +1 -1
- package/lib/screenplay/models/PatchRequest.d.ts +1 -1
- package/lib/screenplay/models/PatchRequest.d.ts.map +1 -1
- package/lib/screenplay/models/PatchRequest.js +2 -2
- package/lib/screenplay/models/PatchRequest.js.map +1 -1
- package/lib/screenplay/models/PostRequest.d.ts +1 -1
- package/lib/screenplay/models/PostRequest.d.ts.map +1 -1
- package/lib/screenplay/models/PostRequest.js +2 -2
- package/lib/screenplay/models/PostRequest.js.map +1 -1
- package/lib/screenplay/models/PutRequest.d.ts +1 -1
- package/lib/screenplay/models/PutRequest.d.ts.map +1 -1
- package/lib/screenplay/models/PutRequest.js +2 -2
- package/lib/screenplay/models/PutRequest.js.map +1 -1
- package/lib/screenplay/models/index.d.ts +8 -8
- package/lib/screenplay/models/index.d.ts.map +1 -1
- package/lib/screenplay/models/index.js +8 -8
- package/lib/screenplay/models/index.js.map +1 -1
- package/lib/screenplay/questions/LastResponse.js +5 -5
- package/lib/screenplay/questions/LastResponse.js.map +1 -1
- package/lib/screenplay/questions/index.d.ts +1 -1
- package/lib/screenplay/questions/index.d.ts.map +1 -1
- package/lib/screenplay/questions/index.js +1 -1
- package/lib/screenplay/questions/index.js.map +1 -1
- package/package.json +29 -11
- package/src/index.ts +2 -2
- package/src/io/ProxyBypass.ts +1 -1
- package/src/io/createAxios.ts +2 -2
- package/src/io/index.ts +2 -2
- package/src/io/proxy.ts +5 -5
- package/src/screenplay/abilities/CallAnApi.ts +3 -3
- package/src/screenplay/abilities/index.ts +1 -1
- package/src/screenplay/index.ts +4 -4
- package/src/screenplay/interactions/ChangeApiConfig.ts +1 -1
- package/src/screenplay/interactions/Send.ts +3 -3
- package/src/screenplay/interactions/index.ts +2 -2
- package/src/screenplay/models/DeleteRequest.ts +1 -1
- package/src/screenplay/models/GetRequest.ts +1 -1
- package/src/screenplay/models/HTTPRequest.ts +1 -1
- package/src/screenplay/models/HeadRequest.ts +1 -1
- package/src/screenplay/models/OptionsRequest.ts +1 -1
- package/src/screenplay/models/PatchRequest.ts +1 -1
- package/src/screenplay/models/PostRequest.ts +1 -1
- package/src/screenplay/models/PutRequest.ts +1 -1
- package/src/screenplay/models/index.ts +8 -8
- package/src/screenplay/questions/LastResponse.ts +1 -1
- package/src/screenplay/questions/index.ts +1 -1
- package/tsconfig-cjs.build.json +17 -0
- package/tsconfig-esm.build.json +18 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { QuestionAdapter } from '@serenity-js/core';
|
|
2
|
+
import type { RawAxiosResponseHeaders } from 'axios';
|
|
3
|
+
/**
|
|
4
|
+
* Provides access to the properties of the last [`AxiosResponse`](https://axios-http.com/docs/res_schema) object,
|
|
5
|
+
* cached on the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/).
|
|
6
|
+
*
|
|
7
|
+
* ## Verify response to a GET request
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
11
|
+
* import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
|
|
12
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
13
|
+
*
|
|
14
|
+
* interface Book {
|
|
15
|
+
* title: string;
|
|
16
|
+
* author: string;
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* await actorCalled('Apisitt')
|
|
20
|
+
* .whoCan(CallAnApi.at('https://api.example.org/'))
|
|
21
|
+
* .attemptsTo(
|
|
22
|
+
* Send.a(GetRequest.to('/books/0-688-00230-7')),
|
|
23
|
+
* Ensure.that(LastResponse.status(), equals(200)),
|
|
24
|
+
* Ensure.that(LastResponse.header('Content-Type'), equals('application/json')),
|
|
25
|
+
* Ensure.that(LastResponse.body<Book>(), equals({
|
|
26
|
+
* title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
|
|
27
|
+
* author: 'Robert M. Pirsig',
|
|
28
|
+
* })),
|
|
29
|
+
* )
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* ## Use Serenity/JS adapters to navigate complex response objects
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
36
|
+
* import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
|
|
37
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
38
|
+
*
|
|
39
|
+
* interface Developer {
|
|
40
|
+
* name: string;
|
|
41
|
+
* id: string;
|
|
42
|
+
* projects: Project[];
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* interface Project {
|
|
46
|
+
* name: string;
|
|
47
|
+
* repoUrl: string;
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* await actorCalled('Apisitt')
|
|
51
|
+
* .whoCan(CallAnApi.at('https://api.example.org/'))
|
|
52
|
+
* .attemptsTo(
|
|
53
|
+
* Send.a(GetRequest.to('/developers/jan-molak')),
|
|
54
|
+
* Ensure.that(LastResponse.status(), equals(200)),
|
|
55
|
+
* Ensure.that(LastResponse.body<Developer>().name, equals('Jan Molak')),
|
|
56
|
+
* Ensure.that(LastResponse.body<Developer>().projects[0].name, equals('Serenity/JS')),
|
|
57
|
+
* )
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* ## Learn more
|
|
61
|
+
* - [AxiosResponse](https://axios-http.com/docs/res_schema)
|
|
62
|
+
*
|
|
63
|
+
* @group Questions
|
|
64
|
+
*/
|
|
65
|
+
export declare class LastResponse {
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves the status code of the [last response](https://serenity-js.org/api/rest/class/LastResponse/)
|
|
68
|
+
*
|
|
69
|
+
* #### Learn more
|
|
70
|
+
* - [HTTP response status codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)
|
|
71
|
+
*/
|
|
72
|
+
static status(): QuestionAdapter<number>;
|
|
73
|
+
/**
|
|
74
|
+
* Retrieves the body of the [last response](https://serenity-js.org/api/rest/class/LastResponse/)
|
|
75
|
+
*
|
|
76
|
+
* #### A type-safe approach using generics
|
|
77
|
+
*
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
80
|
+
* import { CallAnApi, LastResponse } from '@serenity-js/rest'
|
|
81
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
82
|
+
*
|
|
83
|
+
* interface Book {
|
|
84
|
+
* title: string;
|
|
85
|
+
* author: string;
|
|
86
|
+
* }
|
|
87
|
+
*
|
|
88
|
+
* await actorCalled('Apisitt')
|
|
89
|
+
* .whoCan(CallAnApi.at('https://api.example.org/'))
|
|
90
|
+
* .attemptsTo(
|
|
91
|
+
* // ...
|
|
92
|
+
*
|
|
93
|
+
* // note body<T>() parameterised with type "Book"
|
|
94
|
+
* Ensure.that(LastResponse.body<Book>(), equals({
|
|
95
|
+
* title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
|
|
96
|
+
* author: 'Robert M. Pirsig',
|
|
97
|
+
* })),
|
|
98
|
+
* )
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* ## A not type-safe approach using `any`
|
|
102
|
+
*
|
|
103
|
+
* ```ts
|
|
104
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
105
|
+
* import { CallAnApi, LastResponse } from '@serenity-js/rest'
|
|
106
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
107
|
+
*
|
|
108
|
+
* await actorCalled('Apisitt')
|
|
109
|
+
* .whoCan(CallAnApi.at('https://api.example.org/'))
|
|
110
|
+
* .attemptsTo(
|
|
111
|
+
* // ...
|
|
112
|
+
*
|
|
113
|
+
* // note body<T>() parameterised with "any" or with no parameter is not type-safe!
|
|
114
|
+
* Ensure.that(LastResponse.body<any>(), equals({
|
|
115
|
+
* title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
|
|
116
|
+
* author: 'Robert M. Pirsig',
|
|
117
|
+
* })),
|
|
118
|
+
* )
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* ## Iterating over the items in the response body
|
|
122
|
+
*
|
|
123
|
+
* ```ts
|
|
124
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
125
|
+
* import { CallAnApi, LastResponse } from '@serenity-js/rest'
|
|
126
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
127
|
+
*
|
|
128
|
+
* interface Product {
|
|
129
|
+
* id: number;
|
|
130
|
+
* name: string;
|
|
131
|
+
* }
|
|
132
|
+
*
|
|
133
|
+
* await actorCalled('Apisitt')
|
|
134
|
+
* .whoCan(CallAnApi.at('https://api.example.org/'))
|
|
135
|
+
* .attemptsTo(
|
|
136
|
+
* Send.a(GetRequest.to(`/products`)),
|
|
137
|
+
* List.of<Product>(LastResponse.body<{ products: Product[] }>().products)
|
|
138
|
+
* .forEach(({ item, actor }) =>
|
|
139
|
+
* actor.attemptsTo(
|
|
140
|
+
* Send.a(GetRequest.to(`/products/${ item.id }`)),
|
|
141
|
+
* Ensure.that(LastResponse.body<Product>().id, equals(item.id)),
|
|
142
|
+
* )
|
|
143
|
+
* ),
|
|
144
|
+
* )
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
static body<T = any>(): QuestionAdapter<T>;
|
|
148
|
+
/**
|
|
149
|
+
* Retrieves a header of the [last response](https://serenity-js.org/api/rest/class/LastResponse/), identified by `name`
|
|
150
|
+
*
|
|
151
|
+
* ## Asserting on a header
|
|
152
|
+
*
|
|
153
|
+
* ```ts
|
|
154
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
155
|
+
* import { CallAnApi, LastResponse } from '@serenity-js/rest'
|
|
156
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
157
|
+
*
|
|
158
|
+
* await actorCalled('Apisitt')
|
|
159
|
+
* .whoCan(CallAnApi.at('https://api.example.org/'))
|
|
160
|
+
* .attemptsTo(
|
|
161
|
+
* Send.a(GetRequest.to(`/products`)),
|
|
162
|
+
* Ensure.that(LastResponse.header('Content-Type'), equals('application/json')),
|
|
163
|
+
* )
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @param name
|
|
167
|
+
*/
|
|
168
|
+
static header(name: string): QuestionAdapter<string>;
|
|
169
|
+
/**
|
|
170
|
+
* Retrieves all the headers of the [last response](https://serenity-js.org/api/rest/class/LastResponse/).
|
|
171
|
+
*
|
|
172
|
+
* ## Asserting on a header
|
|
173
|
+
*
|
|
174
|
+
* ```ts
|
|
175
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
176
|
+
* import { CallAnApi, LastResponse } from '@serenity-js/rest'
|
|
177
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
178
|
+
*
|
|
179
|
+
* await actorCalled('Apisitt')
|
|
180
|
+
* .whoCan(CallAnApi.at('https://api.example.org/'))
|
|
181
|
+
* .attemptsTo(
|
|
182
|
+
* Send.a(GetRequest.to(`/products`)),
|
|
183
|
+
* Ensure.that(LastResponse.headers()['Content-Type'], equals('application/json')),
|
|
184
|
+
* )
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
static headers(): QuestionAdapter<RawAxiosResponseHeaders>;
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=LastResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LastResponse.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/LastResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAC;AAIrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,qBAAa,YAAY;IAErB;;;;;OAKG;IACH,MAAM,CAAC,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC;IAMxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyEG;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,KAAK,eAAe,CAAC,CAAC,CAAC;IAM1C;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;IAMpD;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,OAAO,IAAI,eAAe,CAAC,uBAAuB,CAAC;CAK7D"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { Question } from '@serenity-js/core';
|
|
2
|
+
import { CallAnApi } from '../abilities/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provides access to the properties of the last [`AxiosResponse`](https://axios-http.com/docs/res_schema) object,
|
|
5
|
+
* cached on the [ability](https://serenity-js.org/api/core/class/Ability/) to [`CallAnApi`](https://serenity-js.org/api/rest/class/CallAnApi/).
|
|
6
|
+
*
|
|
7
|
+
* ## Verify response to a GET request
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
11
|
+
* import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
|
|
12
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
13
|
+
*
|
|
14
|
+
* interface Book {
|
|
15
|
+
* title: string;
|
|
16
|
+
* author: string;
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* await actorCalled('Apisitt')
|
|
20
|
+
* .whoCan(CallAnApi.at('https://api.example.org/'))
|
|
21
|
+
* .attemptsTo(
|
|
22
|
+
* Send.a(GetRequest.to('/books/0-688-00230-7')),
|
|
23
|
+
* Ensure.that(LastResponse.status(), equals(200)),
|
|
24
|
+
* Ensure.that(LastResponse.header('Content-Type'), equals('application/json')),
|
|
25
|
+
* Ensure.that(LastResponse.body<Book>(), equals({
|
|
26
|
+
* title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
|
|
27
|
+
* author: 'Robert M. Pirsig',
|
|
28
|
+
* })),
|
|
29
|
+
* )
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* ## Use Serenity/JS adapters to navigate complex response objects
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
36
|
+
* import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
|
|
37
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
38
|
+
*
|
|
39
|
+
* interface Developer {
|
|
40
|
+
* name: string;
|
|
41
|
+
* id: string;
|
|
42
|
+
* projects: Project[];
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* interface Project {
|
|
46
|
+
* name: string;
|
|
47
|
+
* repoUrl: string;
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* await actorCalled('Apisitt')
|
|
51
|
+
* .whoCan(CallAnApi.at('https://api.example.org/'))
|
|
52
|
+
* .attemptsTo(
|
|
53
|
+
* Send.a(GetRequest.to('/developers/jan-molak')),
|
|
54
|
+
* Ensure.that(LastResponse.status(), equals(200)),
|
|
55
|
+
* Ensure.that(LastResponse.body<Developer>().name, equals('Jan Molak')),
|
|
56
|
+
* Ensure.that(LastResponse.body<Developer>().projects[0].name, equals('Serenity/JS')),
|
|
57
|
+
* )
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* ## Learn more
|
|
61
|
+
* - [AxiosResponse](https://axios-http.com/docs/res_schema)
|
|
62
|
+
*
|
|
63
|
+
* @group Questions
|
|
64
|
+
*/
|
|
65
|
+
export class LastResponse {
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves the status code of the [last response](https://serenity-js.org/api/rest/class/LastResponse/)
|
|
68
|
+
*
|
|
69
|
+
* #### Learn more
|
|
70
|
+
* - [HTTP response status codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)
|
|
71
|
+
*/
|
|
72
|
+
static status() {
|
|
73
|
+
return Question.about(`the status of the last response`, async (actor) => {
|
|
74
|
+
return CallAnApi.as(actor).mapLastResponse(response => response.status);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves the body of the [last response](https://serenity-js.org/api/rest/class/LastResponse/)
|
|
79
|
+
*
|
|
80
|
+
* #### A type-safe approach using generics
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
84
|
+
* import { CallAnApi, LastResponse } from '@serenity-js/rest'
|
|
85
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
86
|
+
*
|
|
87
|
+
* interface Book {
|
|
88
|
+
* title: string;
|
|
89
|
+
* author: string;
|
|
90
|
+
* }
|
|
91
|
+
*
|
|
92
|
+
* await actorCalled('Apisitt')
|
|
93
|
+
* .whoCan(CallAnApi.at('https://api.example.org/'))
|
|
94
|
+
* .attemptsTo(
|
|
95
|
+
* // ...
|
|
96
|
+
*
|
|
97
|
+
* // note body<T>() parameterised with type "Book"
|
|
98
|
+
* Ensure.that(LastResponse.body<Book>(), equals({
|
|
99
|
+
* title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
|
|
100
|
+
* author: 'Robert M. Pirsig',
|
|
101
|
+
* })),
|
|
102
|
+
* )
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* ## A not type-safe approach using `any`
|
|
106
|
+
*
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
109
|
+
* import { CallAnApi, LastResponse } from '@serenity-js/rest'
|
|
110
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
111
|
+
*
|
|
112
|
+
* await actorCalled('Apisitt')
|
|
113
|
+
* .whoCan(CallAnApi.at('https://api.example.org/'))
|
|
114
|
+
* .attemptsTo(
|
|
115
|
+
* // ...
|
|
116
|
+
*
|
|
117
|
+
* // note body<T>() parameterised with "any" or with no parameter is not type-safe!
|
|
118
|
+
* Ensure.that(LastResponse.body<any>(), equals({
|
|
119
|
+
* title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
|
|
120
|
+
* author: 'Robert M. Pirsig',
|
|
121
|
+
* })),
|
|
122
|
+
* )
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* ## Iterating over the items in the response body
|
|
126
|
+
*
|
|
127
|
+
* ```ts
|
|
128
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
129
|
+
* import { CallAnApi, LastResponse } from '@serenity-js/rest'
|
|
130
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
131
|
+
*
|
|
132
|
+
* interface Product {
|
|
133
|
+
* id: number;
|
|
134
|
+
* name: string;
|
|
135
|
+
* }
|
|
136
|
+
*
|
|
137
|
+
* await actorCalled('Apisitt')
|
|
138
|
+
* .whoCan(CallAnApi.at('https://api.example.org/'))
|
|
139
|
+
* .attemptsTo(
|
|
140
|
+
* Send.a(GetRequest.to(`/products`)),
|
|
141
|
+
* List.of<Product>(LastResponse.body<{ products: Product[] }>().products)
|
|
142
|
+
* .forEach(({ item, actor }) =>
|
|
143
|
+
* actor.attemptsTo(
|
|
144
|
+
* Send.a(GetRequest.to(`/products/${ item.id }`)),
|
|
145
|
+
* Ensure.that(LastResponse.body<Product>().id, equals(item.id)),
|
|
146
|
+
* )
|
|
147
|
+
* ),
|
|
148
|
+
* )
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
static body() {
|
|
152
|
+
return Question.about(`the body of the last response`, async (actor) => {
|
|
153
|
+
return CallAnApi.as(actor).mapLastResponse(response => response.data);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Retrieves a header of the [last response](https://serenity-js.org/api/rest/class/LastResponse/), identified by `name`
|
|
158
|
+
*
|
|
159
|
+
* ## Asserting on a header
|
|
160
|
+
*
|
|
161
|
+
* ```ts
|
|
162
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
163
|
+
* import { CallAnApi, LastResponse } from '@serenity-js/rest'
|
|
164
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
165
|
+
*
|
|
166
|
+
* await actorCalled('Apisitt')
|
|
167
|
+
* .whoCan(CallAnApi.at('https://api.example.org/'))
|
|
168
|
+
* .attemptsTo(
|
|
169
|
+
* Send.a(GetRequest.to(`/products`)),
|
|
170
|
+
* Ensure.that(LastResponse.header('Content-Type'), equals('application/json')),
|
|
171
|
+
* )
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @param name
|
|
175
|
+
*/
|
|
176
|
+
static header(name) {
|
|
177
|
+
return Question.about(`the '${name}' header of the last response`, async (actor) => {
|
|
178
|
+
return CallAnApi.as(actor).mapLastResponse(response => response.headers[name]);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Retrieves all the headers of the [last response](https://serenity-js.org/api/rest/class/LastResponse/).
|
|
183
|
+
*
|
|
184
|
+
* ## Asserting on a header
|
|
185
|
+
*
|
|
186
|
+
* ```ts
|
|
187
|
+
* import { actorCalled } from '@serenity-js/core'
|
|
188
|
+
* import { CallAnApi, LastResponse } from '@serenity-js/rest'
|
|
189
|
+
* import { Ensure, equals } from '@serenity-js/assertions'
|
|
190
|
+
*
|
|
191
|
+
* await actorCalled('Apisitt')
|
|
192
|
+
* .whoCan(CallAnApi.at('https://api.example.org/'))
|
|
193
|
+
* .attemptsTo(
|
|
194
|
+
* Send.a(GetRequest.to(`/products`)),
|
|
195
|
+
* Ensure.that(LastResponse.headers()['Content-Type'], equals('application/json')),
|
|
196
|
+
* )
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
static headers() {
|
|
200
|
+
return Question.about(`the headers or the last response`, async (actor) => {
|
|
201
|
+
return CallAnApi.as(actor).mapLastResponse(response => response.headers);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=LastResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LastResponse.js","sourceRoot":"","sources":["../../../src/screenplay/questions/LastResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,MAAM,OAAO,YAAY;IAErB;;;;;OAKG;IACH,MAAM,CAAC,MAAM;QACT,OAAO,QAAQ,CAAC,KAAK,CAAS,iCAAiC,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YAC3E,OAAO,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC5E,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyEG;IACH,MAAM,CAAC,IAAI;QACP,OAAO,QAAQ,CAAC,KAAK,CAAI,+BAA+B,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YACpE,OAAO,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,CAAI,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAS,CAAC,CAAC;QAClF,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,MAAM,CAAC,IAAY;QACtB,OAAO,QAAQ,CAAC,KAAK,CAAS,QAAS,IAAK,+BAA+B,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YACvF,OAAO,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACnF,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,OAAO;QACV,OAAO,QAAQ,CAAC,KAAK,CAA0B,kCAAkC,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;YAC7F,OAAO,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAkC,CAAC,CAAC;QACxG,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/screenplay/questions/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './io';
|
|
2
|
-
export * from './screenplay';
|
|
1
|
+
export * from './io/index.js';
|
|
2
|
+
export * from './screenplay/index.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./io"), exports);
|
|
18
|
-
__exportStar(require("./screenplay"), exports);
|
|
17
|
+
__exportStar(require("./io/index.js"), exports);
|
|
18
|
+
__exportStar(require("./screenplay/index.js"), exports);
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,wDAAsC"}
|
package/lib/io/ProxyBypass.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProxyBypass = void 0;
|
|
4
|
-
const
|
|
4
|
+
const createUrl_js_1 = require("./createUrl.js");
|
|
5
5
|
class ProxyBypass {
|
|
6
6
|
static create(value) {
|
|
7
7
|
if (value === undefined || value === '') {
|
|
@@ -58,7 +58,7 @@ class BypassMatching extends ProxyBypass {
|
|
|
58
58
|
this.patterns = value.split(',').map(patternConfig => BypassHostnamePattern.create(patternConfig.trim()));
|
|
59
59
|
}
|
|
60
60
|
matches(url) {
|
|
61
|
-
const normalisedUrl = (0,
|
|
61
|
+
const normalisedUrl = (0, createUrl_js_1.createUrl)(url);
|
|
62
62
|
for (const pattern of this.patterns) {
|
|
63
63
|
if (pattern.matches(normalisedUrl)) {
|
|
64
64
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProxyBypass.js","sourceRoot":"","sources":["../../src/io/ProxyBypass.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"ProxyBypass.js","sourceRoot":"","sources":["../../src/io/ProxyBypass.ts"],"names":[],"mappings":";;;AAEA,iDAA2C;AAE3C,MAAsB,WAAW;IAC7B,MAAM,CAAC,MAAM,CAAC,KAAyB;QACnC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;YACtC,OAAO,IAAI,UAAU,EAAE,CAAC;QAC5B,CAAC;QAED,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;YAChB,OAAO,IAAI,SAAS,EAAE,CAAC;QAC3B,CAAC;QAED,OAAO,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;CAGJ;AAdD,kCAcC;AAED,MAAM,UAAW,SAAQ,WAAW;IAChC,OAAO,CAAC,IAAS;QACb,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AAED,MAAM,SAAU,SAAQ,WAAW;IAC/B,OAAO,CAAC,IAAS;QACb,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,MAAM,qBAAsB,SAAQ,WAAW;IAiBN;IAAmC;IAhBhE,MAAM,CAAU,QAAQ,GAAG,wCAAwC,CAAC;IACpE,MAAM,CAAC,YAAY,GAAG;QAC1B,MAAM,EAAE,IAAI;QACZ,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,KAAK;QACf,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,KAAK;KAChB,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC,aAAqB;QAC/B,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,MAAM,IAAI,EAAE,CAAC;QAE3E,OAAO,IAAI,qBAAqB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;IAED,YAAqC,QAAgB,EAAmB,IAAwB;QAC5F,KAAK,EAAE,CAAC;QADyB,aAAQ,GAAR,QAAQ,CAAQ;QAAmB,SAAI,GAAJ,IAAI,CAAoB;IAEhG,CAAC;IAED,OAAO,CAAC,GAAQ;QACZ,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,qBAAqB,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAE5E,OAAO,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;eACpC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;;AAGL,MAAM,cAAe,SAAQ,WAAW;IAEnB,QAAQ,CAA0B;IAEnD,YAAY,KAAa;QACrB,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,qBAAqB,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9G,CAAC;IAED,OAAO,CAAC,GAAQ;QACZ,MAAM,aAAa,GAAG,IAAA,wBAAS,EAAC,GAAG,CAAC,CAAC;QAErC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,IAAI,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;gBACjC,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ"}
|
package/lib/io/createAxios.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AxiosInstance } from 'axios';
|
|
2
|
-
import type { AxiosRequestConfigDefaults } from './AxiosRequestConfigDefaults';
|
|
2
|
+
import type { AxiosRequestConfigDefaults } from './AxiosRequestConfigDefaults.js';
|
|
3
3
|
/**
|
|
4
4
|
* Creates an Axios instance with desired configuration and proxy support.
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAxios.d.ts","sourceRoot":"","sources":["../../src/io/createAxios.ts"],"names":[],"mappings":"AACA,OAAc,EAAS,KAAK,aAAa,EAA2B,MAAM,OAAO,CAAC;AAElF,OAAO,KAAK,EAAE,0BAA0B,EAAmC,MAAM,
|
|
1
|
+
{"version":3,"file":"createAxios.d.ts","sourceRoot":"","sources":["../../src/io/createAxios.ts"],"names":[],"mappings":"AACA,OAAc,EAAS,KAAK,aAAa,EAA2B,MAAM,OAAO,CAAC;AAElF,OAAO,KAAK,EAAE,0BAA0B,EAAmC,MAAM,iCAAiC,CAAC;AAGnH;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,qBAAqB,GAAE,aAAa,GAAG,0BAA+B,GAAG,aAAa,CAoBjH"}
|
package/lib/io/createAxios.js
CHANGED
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.createAxios = createAxios;
|
|
37
37
|
const core_1 = require("@serenity-js/core");
|
|
38
38
|
const axios_1 = __importStar(require("axios"));
|
|
39
|
-
const
|
|
39
|
+
const proxy_js_1 = require("./proxy.js");
|
|
40
40
|
/**
|
|
41
41
|
* Creates an Axios instance with desired configuration and proxy support.
|
|
42
42
|
*
|
|
@@ -53,7 +53,7 @@ function createAxios(axiosInstanceOrConfig = {}) {
|
|
|
53
53
|
const proxyConfig = axiosInstanceGiven
|
|
54
54
|
? axiosInstanceOrConfig.defaults.proxy
|
|
55
55
|
: axiosInstanceOrConfig.proxy;
|
|
56
|
-
const proxyOverrides = (0,
|
|
56
|
+
const proxyOverrides = (0, proxy_js_1.axiosProxyOverridesFor)({
|
|
57
57
|
...axiosInstance.defaults,
|
|
58
58
|
proxy: proxyConfig || undefined,
|
|
59
59
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAxios.js","sourceRoot":"","sources":["../../src/io/createAxios.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,kCAoBC;AA/BD,4CAA6C;AAC7C,+CAAkF;AAGlF,
|
|
1
|
+
{"version":3,"file":"createAxios.js","sourceRoot":"","sources":["../../src/io/createAxios.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,kCAoBC;AA/BD,4CAA6C;AAC7C,+CAAkF;AAGlF,yCAAoD;AAEpD;;;;GAIG;AACH,SAAgB,WAAW,CAAC,wBAAoE,EAAE;IAC9F,MAAM,kBAAkB,GAAG,eAAe,CAAC,qBAAqB,CAAC,CAAC;IAElE,MAAM,aAAa,GAAG,kBAAkB;QACpC,CAAC,CAAC,qBAAqB;QACvB,CAAC,CAAC,eAAK,CAAC,MAAM,CAAC;YACX,OAAO,EAAE,eAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,cAAc,EAAE;YAChD,GAAG,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC;SAC1C,CAAC,CAAC;IAEP,MAAM,WAAW,GAAwD,kBAAkB;QACvF,CAAC,CAAC,qBAAqB,CAAC,QAAQ,CAAC,KAAK;QACtC,CAAC,CAAC,qBAAqB,CAAC,KAAK,CAAC;IAElC,MAAM,cAAc,GAAG,IAAA,iCAAsB,EAAC;QAC1C,GAAG,aAAa,CAAC,QAAQ;QACzB,KAAK,EAAE,WAAW,IAAI,SAAS;KAClC,CAAC,CAAC;IAEH,OAAO,aAAa,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,eAAe,CAAC,qBAA0B;IAC/C,OAAO,qBAAqB;WACrB,CAAC,qBAAqB,YAAY,aAAK,IAAI,qBAAqB,CAAC,QAAQ,CAAC,CAAC;AACtF,CAAC;AAED,SAAS,aAAa,CAAa,aAA4B,EAAE,SAAmC;IAChG,KAAK,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACtD,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;IAC3C,CAAC;IAED,OAAO,aAAa,CAAC;AACzB,CAAC;AAED,SAAS,IAAI,CAAsC,MAAS,EAAE,GAAM;IAChE,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IAC5C,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
package/lib/io/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './AxiosRequestConfigDefaults';
|
|
2
|
-
export * from './createAxios';
|
|
1
|
+
export * from './AxiosRequestConfigDefaults.js';
|
|
2
|
+
export * from './createAxios.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/io/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/io/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/io/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC"}
|
package/lib/io/index.js
CHANGED
|
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./AxiosRequestConfigDefaults"), exports);
|
|
18
|
-
__exportStar(require("./createAxios"), exports);
|
|
17
|
+
__exportStar(require("./AxiosRequestConfigDefaults.js"), exports);
|
|
18
|
+
__exportStar(require("./createAxios.js"), exports);
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
package/lib/io/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/io/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/io/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAgD;AAChD,mDAAiC"}
|
package/lib/io/proxy.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as http from 'node:http';
|
|
2
|
-
import type { AxiosRequestConfigDefaults, AxiosRequestConfigProxyDefaults } from './AxiosRequestConfigDefaults';
|
|
3
|
-
import { EnvironmentVariables } from './EnvironmentVariables';
|
|
2
|
+
import type { AxiosRequestConfigDefaults, AxiosRequestConfigProxyDefaults } from './AxiosRequestConfigDefaults.js';
|
|
3
|
+
import { EnvironmentVariables } from './EnvironmentVariables.js';
|
|
4
4
|
/**
|
|
5
5
|
* @param options
|
|
6
6
|
*/
|
package/lib/io/proxy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/io/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AAKvC,OAAO,KAAK,EAAE,0BAA0B,EAAE,+BAA+B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/io/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AAKvC,OAAO,KAAK,EAAE,0BAA0B,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;AAEnH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAIjE;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,GAAG,GAAG,EAAE,OAAO,EAAE,0BAA0B,CAAC,IAAI,CAAC,GAAG;IAC3F,KAAK,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC;IAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAA;CAC9D,CAiBA;AAED,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,+BAA+B,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAYjI;AAED,wBAAgB,4CAA4C,CAAC,GAAG,EAAE,oBAAoB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAiB3H"}
|
package/lib/io/proxy.js
CHANGED
|
@@ -38,22 +38,22 @@ exports.createGetProxyForUrlFromConfig = createGetProxyForUrlFromConfig;
|
|
|
38
38
|
exports.createGetProxyForUrlFromEnvironmentVariables = createGetProxyForUrlFromEnvironmentVariables;
|
|
39
39
|
const process = __importStar(require("node:process"));
|
|
40
40
|
const tiny_types_1 = require("tiny-types");
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
41
|
+
const createUrl_js_1 = require("./createUrl.js");
|
|
42
|
+
const EnvironmentVariables_js_1 = require("./EnvironmentVariables.js");
|
|
43
|
+
const ProxyAgent_js_1 = require("./ProxyAgent.js");
|
|
44
|
+
const ProxyBypass_js_1 = require("./ProxyBypass.js");
|
|
45
45
|
/**
|
|
46
46
|
* @param options
|
|
47
47
|
*/
|
|
48
48
|
function axiosProxyOverridesFor(options) {
|
|
49
|
-
const agent = new
|
|
49
|
+
const agent = new ProxyAgent_js_1.ProxyAgent({
|
|
50
50
|
httpAgent: options.httpAgent,
|
|
51
51
|
httpsAgent: options.httpsAgent,
|
|
52
52
|
// if there's a specific proxy override configured, use it
|
|
53
53
|
// if not - detect proxy automatically based on the env variables
|
|
54
54
|
getProxyForUrl: options.proxy
|
|
55
55
|
? createGetProxyForUrlFromConfig(options.proxy)
|
|
56
|
-
: createGetProxyForUrlFromEnvironmentVariables(new
|
|
56
|
+
: createGetProxyForUrlFromEnvironmentVariables(new EnvironmentVariables_js_1.EnvironmentVariables(process.env)),
|
|
57
57
|
});
|
|
58
58
|
return {
|
|
59
59
|
proxy: false,
|
|
@@ -62,9 +62,9 @@ function axiosProxyOverridesFor(options) {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
function createGetProxyForUrlFromConfig(proxyOptions) {
|
|
65
|
-
const proxyBypass =
|
|
65
|
+
const proxyBypass = ProxyBypass_js_1.ProxyBypass.create(proxyOptions?.bypass);
|
|
66
66
|
return createGetProxyForUrl(proxyBypass, (url) => {
|
|
67
|
-
return (0,
|
|
67
|
+
return (0, createUrl_js_1.createUrl)({
|
|
68
68
|
username: proxyOptions.auth?.username,
|
|
69
69
|
password: proxyOptions.auth?.password,
|
|
70
70
|
protocol: proxyOptions.protocol,
|
|
@@ -74,7 +74,7 @@ function createGetProxyForUrlFromConfig(proxyOptions) {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
function createGetProxyForUrlFromEnvironmentVariables(env) {
|
|
77
|
-
const proxyBypass =
|
|
77
|
+
const proxyBypass = ProxyBypass_js_1.ProxyBypass.create(env.findFirst('npm_config_no_proxy', 'no_proxy'));
|
|
78
78
|
return createGetProxyForUrl(proxyBypass, (url) => {
|
|
79
79
|
const protocolName = url.protocol.replace(/:$/, '');
|
|
80
80
|
const proxyUrl = env.findFirst(`npm_config_${protocolName}_proxy`, `${protocolName}_proxy`, 'npm_config_proxy', 'all_proxy');
|
package/lib/io/proxy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/io/proxy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,wDAmBC;AAED,wEAYC;AAED,oGAiBC;AAjED,sDAAwC;AAExC,2CAA+C;AAG/C,
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/io/proxy.ts"],"names":[],"mappings":"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"}
|
package/lib/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "commonjs" }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { URL } from 'node:url';
|
|
2
2
|
import { Ability, type SerialisedAbility } from '@serenity-js/core';
|
|
3
3
|
import { type AxiosDefaults, type AxiosInstance, type AxiosRequestConfig, type AxiosResponse } from 'axios';
|
|
4
|
-
import type { AxiosRequestConfigDefaults } from '../../io';
|
|
4
|
+
import type { AxiosRequestConfigDefaults } from '../../io/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* An [ability](https://serenity-js.org/api/core/class/Ability/) that wraps [axios client](https://axios-http.com/docs/api_intro) and enables
|
|
7
7
|
* the [actor](https://serenity-js.org/api/core/class/Actor/) to [send](https://serenity-js.org/api/rest/class/Send/)
|