@serenity-js/rest 3.0.0-rc.9 → 3.0.1

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 (127) hide show
  1. package/CHANGELOG.md +81 -1852
  2. package/README.md +8 -10
  3. package/lib/index.d.ts +2 -1
  4. package/lib/index.d.ts.map +1 -0
  5. package/lib/index.js +6 -2
  6. package/lib/index.js.map +1 -1
  7. package/lib/models/DeleteRequest.d.ts +66 -0
  8. package/lib/models/DeleteRequest.d.ts.map +1 -0
  9. package/lib/models/DeleteRequest.js +73 -0
  10. package/lib/models/DeleteRequest.js.map +1 -0
  11. package/lib/models/GetRequest.d.ts +73 -0
  12. package/lib/models/GetRequest.d.ts.map +1 -0
  13. package/lib/models/GetRequest.js +80 -0
  14. package/lib/models/GetRequest.js.map +1 -0
  15. package/lib/models/HTTPRequest.d.ts +48 -0
  16. package/lib/models/HTTPRequest.d.ts.map +1 -0
  17. package/lib/{model → models}/HTTPRequest.js +14 -23
  18. package/lib/models/HTTPRequest.js.map +1 -0
  19. package/lib/models/HeadRequest.d.ts +58 -0
  20. package/lib/models/HeadRequest.d.ts.map +1 -0
  21. package/lib/models/HeadRequest.js +65 -0
  22. package/lib/models/HeadRequest.js.map +1 -0
  23. package/lib/models/OptionsRequest.d.ts +61 -0
  24. package/lib/models/OptionsRequest.d.ts.map +1 -0
  25. package/lib/models/OptionsRequest.js +68 -0
  26. package/lib/models/OptionsRequest.js.map +1 -0
  27. package/lib/models/PatchRequest.d.ts +65 -0
  28. package/lib/models/PatchRequest.d.ts.map +1 -0
  29. package/lib/models/PatchRequest.js +74 -0
  30. package/lib/models/PatchRequest.js.map +1 -0
  31. package/lib/models/PostRequest.d.ts +105 -0
  32. package/lib/models/PostRequest.d.ts.map +1 -0
  33. package/lib/models/PostRequest.js +114 -0
  34. package/lib/models/PostRequest.js.map +1 -0
  35. package/lib/models/PutRequest.d.ts +75 -0
  36. package/lib/models/PutRequest.d.ts.map +1 -0
  37. package/lib/models/PutRequest.js +84 -0
  38. package/lib/models/PutRequest.js.map +1 -0
  39. package/lib/{model → models}/index.d.ts +1 -0
  40. package/lib/models/index.d.ts.map +1 -0
  41. package/lib/{model → models}/index.js +5 -1
  42. package/lib/models/index.js.map +1 -0
  43. package/lib/screenplay/abilities/CallAnApi.d.ts +88 -99
  44. package/lib/screenplay/abilities/CallAnApi.d.ts.map +1 -0
  45. package/lib/screenplay/abilities/CallAnApi.js +94 -107
  46. package/lib/screenplay/abilities/CallAnApi.js.map +1 -1
  47. package/lib/screenplay/abilities/index.d.ts +1 -0
  48. package/lib/screenplay/abilities/index.d.ts.map +1 -0
  49. package/lib/screenplay/abilities/index.js +5 -1
  50. package/lib/screenplay/abilities/index.js.map +1 -1
  51. package/lib/screenplay/index.d.ts +1 -0
  52. package/lib/screenplay/index.d.ts.map +1 -0
  53. package/lib/screenplay/index.js +5 -1
  54. package/lib/screenplay/index.js.map +1 -1
  55. package/lib/screenplay/interactions/ChangeApiConfig.d.ts +96 -95
  56. package/lib/screenplay/interactions/ChangeApiConfig.d.ts.map +1 -0
  57. package/lib/screenplay/interactions/ChangeApiConfig.js +98 -107
  58. package/lib/screenplay/interactions/ChangeApiConfig.js.map +1 -1
  59. package/lib/screenplay/interactions/Send.d.ts +24 -41
  60. package/lib/screenplay/interactions/Send.d.ts.map +1 -0
  61. package/lib/screenplay/interactions/Send.js +37 -51
  62. package/lib/screenplay/interactions/Send.js.map +1 -1
  63. package/lib/screenplay/interactions/index.d.ts +1 -1
  64. package/lib/screenplay/interactions/index.d.ts.map +1 -0
  65. package/lib/screenplay/interactions/index.js +5 -2
  66. package/lib/screenplay/interactions/index.js.map +1 -1
  67. package/lib/screenplay/questions/LastResponse.d.ts +152 -98
  68. package/lib/screenplay/questions/LastResponse.d.ts.map +1 -0
  69. package/lib/screenplay/questions/LastResponse.js +149 -97
  70. package/lib/screenplay/questions/LastResponse.js.map +1 -1
  71. package/lib/screenplay/questions/index.d.ts +1 -0
  72. package/lib/screenplay/questions/index.d.ts.map +1 -0
  73. package/lib/screenplay/questions/index.js +5 -1
  74. package/lib/screenplay/questions/index.js.map +1 -1
  75. package/package.json +20 -43
  76. package/src/index.ts +1 -1
  77. package/src/models/DeleteRequest.ts +73 -0
  78. package/src/models/GetRequest.ts +80 -0
  79. package/src/{model → models}/HTTPRequest.ts +17 -26
  80. package/src/models/HeadRequest.ts +65 -0
  81. package/src/models/OptionsRequest.ts +68 -0
  82. package/src/models/PatchRequest.ts +75 -0
  83. package/src/models/PostRequest.ts +115 -0
  84. package/src/models/PutRequest.ts +85 -0
  85. package/src/screenplay/abilities/CallAnApi.ts +90 -108
  86. package/src/screenplay/interactions/ChangeApiConfig.ts +99 -111
  87. package/src/screenplay/interactions/Send.ts +46 -61
  88. package/src/screenplay/interactions/index.ts +0 -1
  89. package/src/screenplay/questions/LastResponse.ts +153 -100
  90. package/tsconfig.build.json +10 -0
  91. package/lib/model/DeleteRequest.d.ts +0 -63
  92. package/lib/model/DeleteRequest.js +0 -70
  93. package/lib/model/DeleteRequest.js.map +0 -1
  94. package/lib/model/GetRequest.d.ts +0 -70
  95. package/lib/model/GetRequest.js +0 -77
  96. package/lib/model/GetRequest.js.map +0 -1
  97. package/lib/model/HTTPRequest.d.ts +0 -56
  98. package/lib/model/HTTPRequest.js.map +0 -1
  99. package/lib/model/HeadRequest.d.ts +0 -55
  100. package/lib/model/HeadRequest.js +0 -62
  101. package/lib/model/HeadRequest.js.map +0 -1
  102. package/lib/model/OptionsRequest.d.ts +0 -58
  103. package/lib/model/OptionsRequest.js +0 -65
  104. package/lib/model/OptionsRequest.js.map +0 -1
  105. package/lib/model/PatchRequest.d.ts +0 -65
  106. package/lib/model/PatchRequest.js +0 -74
  107. package/lib/model/PatchRequest.js.map +0 -1
  108. package/lib/model/PostRequest.d.ts +0 -102
  109. package/lib/model/PostRequest.js +0 -111
  110. package/lib/model/PostRequest.js.map +0 -1
  111. package/lib/model/PutRequest.d.ts +0 -75
  112. package/lib/model/PutRequest.js +0 -84
  113. package/lib/model/PutRequest.js.map +0 -1
  114. package/lib/model/index.js.map +0 -1
  115. package/lib/screenplay/interactions/ChangeApiUrl.d.ts +0 -82
  116. package/lib/screenplay/interactions/ChangeApiUrl.js +0 -97
  117. package/lib/screenplay/interactions/ChangeApiUrl.js.map +0 -1
  118. package/src/model/DeleteRequest.ts +0 -71
  119. package/src/model/GetRequest.ts +0 -78
  120. package/src/model/HeadRequest.ts +0 -63
  121. package/src/model/OptionsRequest.ts +0 -66
  122. package/src/model/PatchRequest.ts +0 -76
  123. package/src/model/PostRequest.ts +0 -113
  124. package/src/model/PutRequest.ts +0 -86
  125. package/src/screenplay/interactions/ChangeApiUrl.ts +0 -97
  126. package/tsconfig.eslint.json +0 -10
  127. /package/src/{model → models}/index.ts +0 -0
@@ -1,102 +0,0 @@
1
- import { Answerable } from '@serenity-js/core';
2
- import { AxiosRequestConfig } from 'axios';
3
- import { HTTPRequest } from './HTTPRequest';
4
- /**
5
- * @desc
6
- * The HTTP POST method requests that the origin server accepts
7
- * the entity enclosed in the request as a new subordinate of the resource
8
- * identified by the `resourceUri`.
9
- *
10
- * This means that the POST should be used when you want to create a child resource under
11
- * a collection of resources.
12
- *
13
- * POST request is neither [safe](https://developer.mozilla.org/en-US/docs/Glossary/Safe),
14
- * nor [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent).
15
- * This means that if you retry a POST request N times,
16
- * a correctly implemented HTTP REST API will create N resources with N different URIs.
17
- *
18
- * @example <caption>Add new resource to a collection</caption>
19
- * import { Actor } from '@serenity-js/core';
20
- * import { CallAnApi, LastResponse, PostRequest, Send } from '@serenity-js/rest'
21
- * import { Ensure, equals } from '@serenity-js/assertions';
22
- *
23
- * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
24
- *
25
- * actor.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
- * @example <caption>Submit a HTML form</caption>
36
- * import { Actor } from '@serenity-js/core';
37
- * import { CallAnApi, LastResponse, PostRequest, Send } from '@serenity-js/rest'
38
- * import { Ensure, equals } from '@serenity-js/assertions';
39
- * import { stringify } from 'querystring';
40
- *
41
- * const
42
- * actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com')),
43
- * formData = stringify({
44
- * name: actor.name,
45
- * email: `${ actor.name }@example.com`,
46
- * text: 'Your website is great! Learnt a lot :-)'
47
- * });
48
- *
49
- * actor.attemptsTo(
50
- * Send.a(PostRequest.to('/feedback').with(postData).using({
51
- * headers: {
52
- * 'Content-Type': 'application/x-www-form-urlencoded',
53
- * 'Content-Length': formData.length
54
- * }
55
- * })),
56
- * Ensure.that(LastResponse.status(), equals(200)),
57
- * Ensure.that(LastResponse.header('Location'), equals('/feedback/thank-you.html')),
58
- * );
59
- *
60
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
61
- * @see https://tools.ietf.org/html/rfc7231#section-4.3.3
62
- *
63
- * @extends {HTTPRequest}
64
- */
65
- export declare class PostRequest extends HTTPRequest {
66
- /**
67
- * @desc
68
- * Configures the object with a destination URI.
69
- *
70
- * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
71
- * it gets concatenated with the URL provided to the Axios instance
72
- * when the {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
73
- *
74
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} resourceUri
75
- * The URI where the {@link @serenity-js/core/lib/screenplay/actor~Actor}
76
- * should send the {@link HTTPRequest}.
77
- *
78
- * @returns {PostRequest}
79
- */
80
- static to(resourceUri: Answerable<string>): PostRequest;
81
- /**
82
- * @desc
83
- * Configures the object with a request body.
84
- *
85
- * @param {@serenity-js/core/lib/screenplay~Answerable<any>} data
86
- * Data to be sent to the `resourceUri`
87
- *
88
- * @returns {PostRequest}
89
- */
90
- with(data: Answerable<any>): PostRequest;
91
- /**
92
- * @desc
93
- * Overrides the default Axios request configuration provided
94
- * when {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
95
- *
96
- * @param {@serenity-js/core/lib/screenplay~Answerable<AxiosRequestConfig>} config
97
- * Axios request configuration overrides
98
- *
99
- * @returns {PostRequest}
100
- */
101
- using(config: Answerable<AxiosRequestConfig>): PostRequest;
102
- }
@@ -1,111 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostRequest = void 0;
4
- const HTTPRequest_1 = require("./HTTPRequest");
5
- /**
6
- * @desc
7
- * The HTTP POST method requests that the origin server accepts
8
- * the entity enclosed in the request as a new subordinate of the resource
9
- * identified by the `resourceUri`.
10
- *
11
- * This means that the POST should be used when you want to create a child resource under
12
- * a collection of resources.
13
- *
14
- * POST request is neither [safe](https://developer.mozilla.org/en-US/docs/Glossary/Safe),
15
- * nor [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent).
16
- * This means that if you retry a POST request N times,
17
- * a correctly implemented HTTP REST API will create N resources with N different URIs.
18
- *
19
- * @example <caption>Add new resource to a collection</caption>
20
- * import { Actor } from '@serenity-js/core';
21
- * import { CallAnApi, LastResponse, PostRequest, Send } from '@serenity-js/rest'
22
- * import { Ensure, equals } from '@serenity-js/assertions';
23
- *
24
- * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
25
- *
26
- * actor.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
- * @example <caption>Submit a HTML form</caption>
37
- * import { Actor } from '@serenity-js/core';
38
- * import { CallAnApi, LastResponse, PostRequest, Send } from '@serenity-js/rest'
39
- * import { Ensure, equals } from '@serenity-js/assertions';
40
- * import { stringify } from 'querystring';
41
- *
42
- * const
43
- * actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com')),
44
- * formData = stringify({
45
- * name: actor.name,
46
- * email: `${ actor.name }@example.com`,
47
- * text: 'Your website is great! Learnt a lot :-)'
48
- * });
49
- *
50
- * actor.attemptsTo(
51
- * Send.a(PostRequest.to('/feedback').with(postData).using({
52
- * headers: {
53
- * 'Content-Type': 'application/x-www-form-urlencoded',
54
- * 'Content-Length': formData.length
55
- * }
56
- * })),
57
- * Ensure.that(LastResponse.status(), equals(200)),
58
- * Ensure.that(LastResponse.header('Location'), equals('/feedback/thank-you.html')),
59
- * );
60
- *
61
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
62
- * @see https://tools.ietf.org/html/rfc7231#section-4.3.3
63
- *
64
- * @extends {HTTPRequest}
65
- */
66
- class PostRequest extends HTTPRequest_1.HTTPRequest {
67
- /**
68
- * @desc
69
- * Configures the object with a destination URI.
70
- *
71
- * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
72
- * it gets concatenated with the URL provided to the Axios instance
73
- * when the {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
74
- *
75
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} resourceUri
76
- * The URI where the {@link @serenity-js/core/lib/screenplay/actor~Actor}
77
- * should send the {@link HTTPRequest}.
78
- *
79
- * @returns {PostRequest}
80
- */
81
- static to(resourceUri) {
82
- return new PostRequest(resourceUri);
83
- }
84
- /**
85
- * @desc
86
- * Configures the object with a request body.
87
- *
88
- * @param {@serenity-js/core/lib/screenplay~Answerable<any>} data
89
- * Data to be sent to the `resourceUri`
90
- *
91
- * @returns {PostRequest}
92
- */
93
- with(data) {
94
- return new PostRequest(this.resourceUri, data, this.config);
95
- }
96
- /**
97
- * @desc
98
- * Overrides the default Axios request configuration provided
99
- * when {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
100
- *
101
- * @param {@serenity-js/core/lib/screenplay~Answerable<AxiosRequestConfig>} config
102
- * Axios request configuration overrides
103
- *
104
- * @returns {PostRequest}
105
- */
106
- using(config) {
107
- return new PostRequest(this.resourceUri, this.data, config);
108
- }
109
- }
110
- exports.PostRequest = PostRequest;
111
- //# sourceMappingURL=PostRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PostRequest.js","sourceRoot":"","sources":["../../src/model/PostRequest.ts"],"names":[],"mappings":";;;AAGA,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,MAAa,WAAY,SAAQ,yBAAW;IAExC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,CAAC,WAA+B;QACrC,OAAO,IAAI,WAAW,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;;;OAQG;IACH,IAAI,CAAC,IAAqB;QACtB,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAChE,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,MAAsC;QACxC,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAChE,CAAC;CACJ;AA9CD,kCA8CC"}
@@ -1,75 +0,0 @@
1
- import { Answerable } from '@serenity-js/core';
2
- import { AxiosRequestConfig } from 'axios';
3
- import { HTTPRequest } from './HTTPRequest';
4
- /**
5
- * @desc
6
- * The PUT method requests that the state of the target resource be
7
- * created or replaced with the state defined by the representation
8
- * enclosed in the request message payload.
9
- *
10
- * PUT request should be used when you want to create
11
- * a new resource at a known `resourceUri` (e.g. `/books/0-688-00230-7`)
12
- * or replace an existing resource at such `resourceUri`.
13
- *
14
- * PUT request is [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent):
15
- * calling it once or several times successively has the same effect (that is no _side effect_).
16
- *
17
- * @example <caption>Create a new resource at a known location</caption>
18
- * import { Actor } from '@serenity-js/core';
19
- * import { CallAnApi, LastResponse, PutRequest, Send } from '@serenity-js/rest'
20
- * import { Ensure, equals } from '@serenity-js/assertions';
21
- *
22
- * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
23
- *
24
- * actor.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
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT
34
- * @see https://tools.ietf.org/html/rfc7231#section-4.3.4
35
- *
36
- * @extends {HTTPRequest}
37
- */
38
- export declare class PutRequest extends HTTPRequest {
39
- /**
40
- * @desc
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 {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
46
- *
47
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} resourceUri
48
- * The URI where the {@link @serenity-js/core/lib/screenplay/actor~Actor}
49
- * should send the {@link HTTPRequest}.
50
- *
51
- * @returns {PutRequest}
52
- */
53
- static to(resourceUri: Answerable<string>): PutRequest;
54
- /**
55
- * @desc
56
- * Configures the object with a request body.
57
- *
58
- * @param {@serenity-js/core/lib/screenplay~Answerable<any>} data
59
- * Data to be sent to the `resourceUri`
60
- *
61
- * @returns {PutRequest}
62
- */
63
- with(data: Answerable<any>): PutRequest;
64
- /**
65
- * @desc
66
- * Overrides the default Axios request configuration provided
67
- * when {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
68
- *
69
- * @param {@serenity-js/core/lib/screenplay~Answerable<AxiosRequestConfig>} config
70
- * Axios request configuration overrides
71
- *
72
- * @returns {PutRequest}
73
- */
74
- using(config: Answerable<AxiosRequestConfig>): PutRequest;
75
- }
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PutRequest = void 0;
4
- const HTTPRequest_1 = require("./HTTPRequest");
5
- /**
6
- * @desc
7
- * The PUT method requests that the state of the target resource be
8
- * created or replaced with the state defined by the representation
9
- * enclosed in the request message payload.
10
- *
11
- * PUT request should be used when you want to create
12
- * a new resource at a known `resourceUri` (e.g. `/books/0-688-00230-7`)
13
- * or replace an existing resource at such `resourceUri`.
14
- *
15
- * PUT request is [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent):
16
- * calling it once or several times successively has the same effect (that is no _side effect_).
17
- *
18
- * @example <caption>Create a new resource at a known location</caption>
19
- * import { Actor } from '@serenity-js/core';
20
- * import { CallAnApi, LastResponse, PutRequest, Send } from '@serenity-js/rest'
21
- * import { Ensure, equals } from '@serenity-js/assertions';
22
- *
23
- * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
24
- *
25
- * actor.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
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT
35
- * @see https://tools.ietf.org/html/rfc7231#section-4.3.4
36
- *
37
- * @extends {HTTPRequest}
38
- */
39
- class PutRequest extends HTTPRequest_1.HTTPRequest {
40
- /**
41
- * @desc
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 {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
47
- *
48
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} resourceUri
49
- * The URI where the {@link @serenity-js/core/lib/screenplay/actor~Actor}
50
- * should send the {@link HTTPRequest}.
51
- *
52
- * @returns {PutRequest}
53
- */
54
- static to(resourceUri) {
55
- return new PutRequest(resourceUri);
56
- }
57
- /**
58
- * @desc
59
- * Configures the object with a request body.
60
- *
61
- * @param {@serenity-js/core/lib/screenplay~Answerable<any>} data
62
- * Data to be sent to the `resourceUri`
63
- *
64
- * @returns {PutRequest}
65
- */
66
- with(data) {
67
- return new PutRequest(this.resourceUri, data, this.config);
68
- }
69
- /**
70
- * @desc
71
- * Overrides the default Axios request configuration provided
72
- * when {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
73
- *
74
- * @param {@serenity-js/core/lib/screenplay~Answerable<AxiosRequestConfig>} config
75
- * Axios request configuration overrides
76
- *
77
- * @returns {PutRequest}
78
- */
79
- using(config) {
80
- return new PutRequest(this.resourceUri, this.data, config);
81
- }
82
- }
83
- exports.PutRequest = PutRequest;
84
- //# sourceMappingURL=PutRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PutRequest.js","sourceRoot":"","sources":["../../src/model/PutRequest.ts"],"names":[],"mappings":";;;AAGA,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAa,UAAW,SAAQ,yBAAW;IAEvC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,CAAC,WAA+B;QACrC,OAAO,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;;;OAQG;IACH,IAAI,CAAC,IAAqB;QACtB,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,MAAsC;QACxC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;CACJ;AA9CD,gCA8CC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAgC;AAChC,+CAA6B;AAC7B,gDAA8B;AAC9B,gDAA8B;AAC9B,mDAAiC;AACjC,iDAA+B;AAC/B,gDAA8B;AAC9B,+CAA6B"}
@@ -1,82 +0,0 @@
1
- import { Answerable, AnswersQuestions, CollectsArtifacts, Interaction, UsesAbilities } from '@serenity-js/core';
2
- /**
3
- * @desc
4
- * Changes the base URL the {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability}
5
- * has been configured with. Useful when we don't know the URL before the test is started,
6
- * for example when the URL is dynamically generated and needs to be read from the website under test.
7
- *
8
- * @example <caption>Changing the API URL</caption>
9
- * import { Actor } from '@serenity-js/core';
10
- * import { Navigate, Target, Text } from '@serenity-js/protractor';
11
- * import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
12
- * import { protractor, by } from 'protractor';
13
- *
14
- * import axios from 'axios';
15
- *
16
- * const actor = Actor.named('Apisit').whoCan(
17
- * BrowseTheWeb.using(protractor.browser),
18
- *
19
- * // Note: no default base URL is given when the axios instance is created
20
- * CallAnApi.using(axios.create()),
21
- * );
22
- *
23
- * // Let's imagine that the website under test displays
24
- * // a dynamically generated API URL we'd like to use
25
- * const ApiDetailsWidget = {
26
- * Url: Target.the('API URL').located(by.id('api-url')),
27
- * }
28
- *
29
- * actor.attemptsTo(
30
- * Navigate.to('/profile'),
31
- *
32
- * // We change the API URL based on the text displayed in the widget
33
- * // (although we could change it to some arbitrary string too).
34
- * ChangeApiUrl.to(Text.of(ApiDetailsWidget.Url)),
35
- *
36
- * // Any subsequent request will be sent to the newly set URL
37
- * Send.a(GetRequest.to('/projects')),
38
- * Ensure.that(LastResponse.status(), equals(200)),
39
- * );
40
- *
41
- * @deprecated Use ChangeApiConfig.setUrlTo(newUrl) instead
42
- *
43
- * @see {@link ChangeApiConfig}
44
- *
45
- * @extends {@serenity-js/core/lib/screenplay~Interaction}
46
- */
47
- export declare class ChangeApiUrl extends Interaction {
48
- private readonly newApiUrl;
49
- /**
50
- * @desc
51
- * Instantiates a new {@link ChangeApiUrl} {@link @serenity-js/core/lib/screenplay~Interaction}.
52
- *
53
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} newApiUrl
54
- * @returns {@serenity-js/core/lib/screenplay~Interaction}
55
- */
56
- static to(newApiUrl: Answerable<string>): Interaction;
57
- /**
58
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} newApiUrl
59
- */
60
- constructor(newApiUrl: Answerable<string>);
61
- /**
62
- * @desc
63
- * Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
64
- * perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
65
- *
66
- * @param {UsesAbilities & CollectsArtifacts & AnswersQuestions} actor
67
- * @returns {Promise<void>}
68
- *
69
- * @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
70
- * @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
71
- * @see {@link @serenity-js/core/lib/screenplay/actor~CollectsArtifacts}
72
- * @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
73
- */
74
- performAs(actor: UsesAbilities & CollectsArtifacts & AnswersQuestions): Promise<void>;
75
- /**
76
- * @desc
77
- * Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
78
- *
79
- * @returns {string}
80
- */
81
- toString(): string;
82
- }
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChangeApiUrl = void 0;
4
- const core_1 = require("@serenity-js/core");
5
- const abilities_1 = require("../abilities");
6
- /**
7
- * @desc
8
- * Changes the base URL the {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability}
9
- * has been configured with. Useful when we don't know the URL before the test is started,
10
- * for example when the URL is dynamically generated and needs to be read from the website under test.
11
- *
12
- * @example <caption>Changing the API URL</caption>
13
- * import { Actor } from '@serenity-js/core';
14
- * import { Navigate, Target, Text } from '@serenity-js/protractor';
15
- * import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
16
- * import { protractor, by } from 'protractor';
17
- *
18
- * import axios from 'axios';
19
- *
20
- * const actor = Actor.named('Apisit').whoCan(
21
- * BrowseTheWeb.using(protractor.browser),
22
- *
23
- * // Note: no default base URL is given when the axios instance is created
24
- * CallAnApi.using(axios.create()),
25
- * );
26
- *
27
- * // Let's imagine that the website under test displays
28
- * // a dynamically generated API URL we'd like to use
29
- * const ApiDetailsWidget = {
30
- * Url: Target.the('API URL').located(by.id('api-url')),
31
- * }
32
- *
33
- * actor.attemptsTo(
34
- * Navigate.to('/profile'),
35
- *
36
- * // We change the API URL based on the text displayed in the widget
37
- * // (although we could change it to some arbitrary string too).
38
- * ChangeApiUrl.to(Text.of(ApiDetailsWidget.Url)),
39
- *
40
- * // Any subsequent request will be sent to the newly set URL
41
- * Send.a(GetRequest.to('/projects')),
42
- * Ensure.that(LastResponse.status(), equals(200)),
43
- * );
44
- *
45
- * @deprecated Use ChangeApiConfig.setUrlTo(newUrl) instead
46
- *
47
- * @see {@link ChangeApiConfig}
48
- *
49
- * @extends {@serenity-js/core/lib/screenplay~Interaction}
50
- */
51
- class ChangeApiUrl extends core_1.Interaction {
52
- /**
53
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} newApiUrl
54
- */
55
- constructor(newApiUrl) {
56
- super();
57
- this.newApiUrl = newApiUrl;
58
- }
59
- /**
60
- * @desc
61
- * Instantiates a new {@link ChangeApiUrl} {@link @serenity-js/core/lib/screenplay~Interaction}.
62
- *
63
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} newApiUrl
64
- * @returns {@serenity-js/core/lib/screenplay~Interaction}
65
- */
66
- static to(newApiUrl) {
67
- return new ChangeApiUrl(newApiUrl);
68
- }
69
- /**
70
- * @desc
71
- * Makes the provided {@link @serenity-js/core/lib/screenplay/actor~Actor}
72
- * perform this {@link @serenity-js/core/lib/screenplay~Interaction}.
73
- *
74
- * @param {UsesAbilities & CollectsArtifacts & AnswersQuestions} actor
75
- * @returns {Promise<void>}
76
- *
77
- * @see {@link @serenity-js/core/lib/screenplay/actor~Actor}
78
- * @see {@link @serenity-js/core/lib/screenplay/actor~UsesAbilities}
79
- * @see {@link @serenity-js/core/lib/screenplay/actor~CollectsArtifacts}
80
- * @see {@link @serenity-js/core/lib/screenplay/actor~AnswersQuestions}
81
- */
82
- performAs(actor) {
83
- return actor.answer(this.newApiUrl)
84
- .then(newApiUrl => abilities_1.CallAnApi.as(actor).modifyConfig(config => config.baseURL = newApiUrl));
85
- }
86
- /**
87
- * @desc
88
- * Generates a description to be used when reporting this {@link @serenity-js/core/lib/screenplay~Activity}.
89
- *
90
- * @returns {string}
91
- */
92
- toString() {
93
- return `#actor changes the API URL to ${this.newApiUrl.toString()}`;
94
- }
95
- }
96
- exports.ChangeApiUrl = ChangeApiUrl;
97
- //# sourceMappingURL=ChangeApiUrl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChangeApiUrl.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/ChangeApiUrl.ts"],"names":[],"mappings":";;;AAAA,4CAAgH;AAEhH,4CAAyC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAa,YAAa,SAAQ,kBAAW;IAazC;;OAEG;IACH,YAA6B,SAA6B;QACtD,KAAK,EAAE,CAAC;QADiB,cAAS,GAAT,SAAS,CAAoB;IAE1D,CAAC;IAhBD;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,CAAC,SAA6B;QACnC,OAAO,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IASD;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,KAA2D;QACjE,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;aAC9B,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,qBAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC;IACnG,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACJ,OAAO,iCAAkC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAG,EAAE,CAAC;IAC1E,CAAC;CACJ;AA/CD,oCA+CC"}
@@ -1,71 +0,0 @@
1
- import { Answerable } from '@serenity-js/core';
2
- import { AxiosRequestConfig } from 'axios';
3
-
4
- import { HTTPRequest } from './HTTPRequest';
5
-
6
- /**
7
- * @desc
8
- * The DELETE method requests that the origin server remove the
9
- * association between the target resource and its current
10
- * functionality.
11
- *
12
- * @example <caption>Create and remove a resource</caption>
13
- * import { Actor } from '@serenity-js/core';
14
- * import { CallAnApi, DeleteRequest, LastResponse, PostRequest, Send } from '@serenity-js/rest'
15
- * import { Ensure, equals, startsWith } from '@serenity-js/assertions';
16
- *
17
- * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
18
- *
19
- * actor.attemptsTo(
20
- * // create a new test user account
21
- * Send.a(PostRequest.to('/users').with({
22
- * login: 'tester',
23
- * password: 'P@ssword1',
24
- * }),
25
- * Ensure.that(LastResponse.status(), equals(201)),
26
- * Ensure.that(LastResponse.header('Location'), startsWith('/users')),
27
- *
28
- * // delete the test user account
29
- * Send.a(DeleteRequest.to(LastResponse.header('Location'))),
30
- * Ensure.that(LastResponse.status(), equals(200)),
31
- * );
32
- *
33
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE
34
- * @see https://tools.ietf.org/html/rfc7231#section-4.3.5
35
- *
36
- * @extends {HTTPRequest}
37
- */
38
- export class DeleteRequest extends HTTPRequest {
39
-
40
- /**
41
- * @desc
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 {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
47
- *
48
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} resourceUri
49
- * The URI where the {@link @serenity-js/core/lib/screenplay/actor~Actor}
50
- * should send the {@link HTTPRequest}.
51
- *
52
- * @returns {DeleteRequest}
53
- */
54
- static to(resourceUri: Answerable<string>): DeleteRequest {
55
- return new DeleteRequest(resourceUri);
56
- }
57
-
58
- /**
59
- * @desc
60
- * Overrides the default Axios request configuration provided
61
- * when {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
62
- *
63
- * @param {@serenity-js/core/lib/screenplay~Answerable<AxiosRequestConfig>} config
64
- * Axios request configuration overrides
65
- *
66
- * @returns {DeleteRequest}
67
- */
68
- using(config: Answerable<AxiosRequestConfig>): DeleteRequest {
69
- return new DeleteRequest(this.resourceUri, undefined, config);
70
- }
71
- }