@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,70 +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 GET method requests a representation of the specified resource.
7
- * It is the most frequent type of request made by consumers of a typical HTTP API.
8
- * For this reason it's important to test every known endpoint that responds to GET requests and ensure that it
9
- * behaves correctly.
10
- *
11
- * Since the GET method is used to _retrieve_ data from a server, it should be implemented
12
- * as [safe](https://developer.mozilla.org/en-US/docs/Glossary/Safe)
13
- * and [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent).
14
- * This means that an identical request can be made once or several times in a row with the same effect while leaving
15
- * the server in the same state.
16
- *
17
- * @example <caption>Verify response to a GET request</caption>
18
- * import { Actor } from '@serenity-js/core';
19
- * import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
20
- * import { Ensure, equals } from '@serenity-js/assertions';
21
- *
22
- * interface Book {
23
- * title: string;
24
- * author: string;
25
- * }
26
- *
27
- * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
28
- *
29
- * actor.attemptsTo(
30
- * Send.a(GetRequest.to('/books/0-688-00230-7')),
31
- * Ensure.that(LastResponse.status(), equals(200)),
32
- * Ensure.that(LastResponse.body<Book>(), equals({
33
- * title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
34
- * author: 'Robert M. Pirsig',
35
- * })),
36
- * );
37
- *
38
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET
39
- * @see https://tools.ietf.org/html/rfc7231#section-4.3.1
40
- *
41
- * @extends {HTTPRequest}
42
- */
43
- export declare class GetRequest extends HTTPRequest {
44
- /**
45
- * @desc
46
- * Configures the object with a destination URI.
47
- *
48
- * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
49
- * it gets concatenated with the URL provided to the Axios instance
50
- * when the {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
51
- *
52
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} resourceUri
53
- * The URI where the {@link @serenity-js/core/lib/screenplay/actor~Actor}
54
- * should send the {@link HTTPRequest}.
55
- *
56
- * @returns {GetRequest}
57
- */
58
- static to(resourceUri: Answerable<string>): GetRequest;
59
- /**
60
- * @desc
61
- * Overrides the default Axios request configuration provided
62
- * when {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
63
- *
64
- * @param {@serenity-js/core/lib/screenplay~Answerable<AxiosRequestConfig>} config
65
- * Axios request configuration overrides
66
- *
67
- * @returns {GetRequest}
68
- */
69
- using(config: Answerable<AxiosRequestConfig>): GetRequest;
70
- }
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetRequest = void 0;
4
- const HTTPRequest_1 = require("./HTTPRequest");
5
- /**
6
- * @desc
7
- * The HTTP GET method requests a representation of the specified resource.
8
- * It is the most frequent type of request made by consumers of a typical HTTP API.
9
- * For this reason it's important to test every known endpoint that responds to GET requests and ensure that it
10
- * behaves correctly.
11
- *
12
- * Since the GET method is used to _retrieve_ data from a server, it should be implemented
13
- * as [safe](https://developer.mozilla.org/en-US/docs/Glossary/Safe)
14
- * and [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent).
15
- * This means that an identical request can be made once or several times in a row with the same effect while leaving
16
- * the server in the same state.
17
- *
18
- * @example <caption>Verify response to a GET request</caption>
19
- * import { Actor } from '@serenity-js/core';
20
- * import { CallAnApi, GetRequest, LastResponse, Send } from '@serenity-js/rest'
21
- * import { Ensure, equals } from '@serenity-js/assertions';
22
- *
23
- * interface Book {
24
- * title: string;
25
- * author: string;
26
- * }
27
- *
28
- * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
29
- *
30
- * actor.attemptsTo(
31
- * Send.a(GetRequest.to('/books/0-688-00230-7')),
32
- * Ensure.that(LastResponse.status(), equals(200)),
33
- * Ensure.that(LastResponse.body<Book>(), equals({
34
- * title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
35
- * author: 'Robert M. Pirsig',
36
- * })),
37
- * );
38
- *
39
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET
40
- * @see https://tools.ietf.org/html/rfc7231#section-4.3.1
41
- *
42
- * @extends {HTTPRequest}
43
- */
44
- class GetRequest extends HTTPRequest_1.HTTPRequest {
45
- /**
46
- * @desc
47
- * Configures the object with a destination URI.
48
- *
49
- * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
50
- * it gets concatenated with the URL provided to the Axios instance
51
- * when the {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
52
- *
53
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} resourceUri
54
- * The URI where the {@link @serenity-js/core/lib/screenplay/actor~Actor}
55
- * should send the {@link HTTPRequest}.
56
- *
57
- * @returns {GetRequest}
58
- */
59
- static to(resourceUri) {
60
- return new GetRequest(resourceUri);
61
- }
62
- /**
63
- * @desc
64
- * Overrides the default Axios request configuration provided
65
- * when {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
66
- *
67
- * @param {@serenity-js/core/lib/screenplay~Answerable<AxiosRequestConfig>} config
68
- * Axios request configuration overrides
69
- *
70
- * @returns {GetRequest}
71
- */
72
- using(config) {
73
- return new GetRequest(this.resourceUri, undefined, config);
74
- }
75
- }
76
- exports.GetRequest = GetRequest;
77
- //# sourceMappingURL=GetRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GetRequest.js","sourceRoot":"","sources":["../../src/model/GetRequest.ts"],"names":[],"mappings":";;;AAGA,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;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;;;;;;;;;OASG;IACH,KAAK,CAAC,MAAsC;QACxC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;CACJ;AAjCD,gCAiCC"}
@@ -1,56 +0,0 @@
1
- import { Answerable, AnswersQuestions, Question, UsesAbilities } from '@serenity-js/core';
2
- import { AxiosRequestConfig } from 'axios';
3
- /**
4
- * @desc
5
- * HTTP Request sent by the {@link @serenity-js/core/lib/screenplay/actor~Actor}
6
- * using the {@link Send} {@link @serenity-js/core/lib/screenplay~Interaction}
7
- *
8
- * @abstract
9
- * @extends {Question<Promise<AxiosRequestConfig>>}
10
- */
11
- export declare abstract class HTTPRequest extends Question<Promise<AxiosRequestConfig>> {
12
- protected readonly resourceUri?: Answerable<string>;
13
- protected readonly data?: Answerable<any>;
14
- protected readonly config?: Answerable<AxiosRequestConfig>;
15
- private subject;
16
- /**
17
- * @protected
18
- *
19
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} [resourceUri]
20
- * URL to which the request should be sent
21
- *
22
- * @param {@serenity-js/core/lib/screenplay~Answerable<any>} [data]
23
- * Request body to be sent as part of the Put, Post or Patch request
24
- *
25
- * @param {@serenity-js/core/lib/screenplay~Answerable<AxiosRequestConfig>} [config]
26
- * Axios request configuration, which can be used to override the defaults
27
- * provided when the {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} is instantiated
28
- */
29
- protected constructor(resourceUri?: Answerable<string>, data?: Answerable<any>, config?: Answerable<AxiosRequestConfig>);
30
- /**
31
- * @desc
32
- * Resolves the {@link Question} in the context of a given {@link @serenity-js/core/lib/screenplay/actor~Actor}
33
- *
34
- * @param {AnswersQuestions & UsesAbilities} actor
35
- * @returns {Promise<AxiosRequestConfig>}
36
- */
37
- answeredBy(actor: AnswersQuestions & UsesAbilities): Promise<AxiosRequestConfig>;
38
- /**
39
- * @desc
40
- * Changes the description of this question's subject.
41
- *
42
- * @param {string} subject
43
- * @returns {Question<T>}
44
- */
45
- describedAs(subject: string): this;
46
- toString(): string;
47
- /**
48
- * Determines the request method based on the name of the request class.
49
- * For example: GetRequest => GET, PostRequest => POST, etc.
50
- */
51
- private httpMethodName;
52
- /**
53
- * A human-readable description of the request, such as "a GET request", "an OPTIONS request", etc.
54
- */
55
- private requestDescription;
56
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"HTTPRequest.js","sourceRoot":"","sources":["../../src/model/HTTPRequest.ts"],"names":[],"mappings":";;;AAAA,4CAA0F;AAC1F,iDAAqD;AAGrD;;;;;;;GAOG;AACH,MAAsB,WAAY,SAAQ,eAAqC;IAI3E;;;;;;;;;;;;OAYG;IACH,YACuB,WAAgC,EAChC,IAAsB,EACtB,MAAuC;QAE1D,KAAK,EAAE,CAAC;QAJW,gBAAW,GAAX,WAAW,CAAqB;QAChC,SAAI,GAAJ,IAAI,CAAkB;QACtB,WAAM,GAAN,MAAM,CAAiC;QAG1D,IAAI,CAAC,OAAO,GAAG,GAAI,IAAI,CAAC,kBAAkB,EAAG,OAAQ,IAAA,cAAS,EAAC,GAAI,IAAI,CAAC,WAAY,EAAG,EAAE,CAAC;IAC9F,CAAC;IAED;;;;;;OAMG;IACH,UAAU,CAAC,KAAuC;QAC9C,OAAO,OAAO,CAAC,GAAG,CAAC;YACf,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC7E,IAAI,CAAC,MAAM,CAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAQ,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACzE,IAAI,CAAC,IAAI,CAAQ,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAU,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SAChF,CAAC;YACF,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAEzB,MAAM,CAAC,MAAM,CACT,EAAE,EACF,EAAE,GAAG,EAAE,IAAI,EAAE,EACb,MAAM,EACN,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,EAAE,CACpC,CACJ;YACD,IAAI,CAAC,MAAM,CAAC,EAAE;QACV,8DAA8D;QAC9D,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACpC,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE;gBACb,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;aAC1B;YACD,OAAO,GAAG,CAAC;QACf,CAAC,EAAE,EAAE,CAAC,CACT,CAAC;IACN,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,OAAe;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;OAGG;IACK,cAAc;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACtE,CAAC;IAED;;OAEG;IACK,kBAAkB;QACtB,MACI,MAAM,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAE,EACpC,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAEnC,OAAO,GAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAI,IAAK,MAAO,UAAU,CAAC;IAC9E,CAAC;CACJ;AA7FD,kCA6FC"}
@@ -1,55 +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 HEAD method requests the headers that are returned if the specified resource
7
- * would be requested with an HTTP GET method.
8
- * Such a request can be done before deciding to download a large resource to save bandwidth, for example.
9
- *
10
- * @example <caption>File download test</caption>
11
- * import { Actor } from '@serenity-js/core';
12
- * import { CallAnApi, HeadRequest, LastResponse, Send } from '@serenity-js/rest'
13
- * import { Ensure, equals } from '@serenity-js/assertions';
14
- *
15
- * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
16
- *
17
- * actor.attemptsTo(
18
- * Send.a(HeadRequest.to('/downloads/my-test-document.pdf')),
19
- * Ensure.that(LastResponse.status(), equals(200)),
20
- * Ensure.that(LastResponse.header('Content-Length'), equals(256)), // assuming we know the size of the document
21
- * );
22
- *
23
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD
24
- * @see https://tools.ietf.org/html/rfc7231#section-4.3.2
25
- *
26
- * @extends {HTTPRequest}
27
- */
28
- export declare class HeadRequest extends HTTPRequest {
29
- /**
30
- * @desc
31
- * Configures the object with a destination URI.
32
- *
33
- * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
34
- * it gets concatenated with the URL provided to the Axios instance
35
- * when the {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
36
- *
37
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} resourceUri
38
- * The URI where the {@link @serenity-js/core/lib/screenplay/actor~Actor}
39
- * should send the {@link HTTPRequest}.
40
- *
41
- * @returns {HeadRequest}
42
- */
43
- static to(resourceUri: Answerable<string>): HeadRequest;
44
- /**
45
- * @desc
46
- * Overrides the default Axios request configuration provided
47
- * when {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
48
- *
49
- * @param {@serenity-js/core/lib/screenplay~Answerable<AxiosRequestConfig>} config
50
- * Axios request configuration overrides
51
- *
52
- * @returns {HeadRequest}
53
- */
54
- using(config: Answerable<AxiosRequestConfig>): HeadRequest;
55
- }
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HeadRequest = void 0;
4
- const HTTPRequest_1 = require("./HTTPRequest");
5
- /**
6
- * @desc
7
- * The HTTP HEAD method requests the headers that are returned if the specified resource
8
- * would be requested with an HTTP GET method.
9
- * Such a request can be done before deciding to download a large resource to save bandwidth, for example.
10
- *
11
- * @example <caption>File download test</caption>
12
- * import { Actor } from '@serenity-js/core';
13
- * import { CallAnApi, HeadRequest, LastResponse, Send } from '@serenity-js/rest'
14
- * import { Ensure, equals } from '@serenity-js/assertions';
15
- *
16
- * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
17
- *
18
- * actor.attemptsTo(
19
- * Send.a(HeadRequest.to('/downloads/my-test-document.pdf')),
20
- * Ensure.that(LastResponse.status(), equals(200)),
21
- * Ensure.that(LastResponse.header('Content-Length'), equals(256)), // assuming we know the size of the document
22
- * );
23
- *
24
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD
25
- * @see https://tools.ietf.org/html/rfc7231#section-4.3.2
26
- *
27
- * @extends {HTTPRequest}
28
- */
29
- class HeadRequest extends HTTPRequest_1.HTTPRequest {
30
- /**
31
- * @desc
32
- * Configures the object with a destination URI.
33
- *
34
- * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
35
- * it gets concatenated with the URL provided to the Axios instance
36
- * when the {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
37
- *
38
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} resourceUri
39
- * The URI where the {@link @serenity-js/core/lib/screenplay/actor~Actor}
40
- * should send the {@link HTTPRequest}.
41
- *
42
- * @returns {HeadRequest}
43
- */
44
- static to(resourceUri) {
45
- return new HeadRequest(resourceUri);
46
- }
47
- /**
48
- * @desc
49
- * Overrides the default Axios request configuration provided
50
- * when {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
51
- *
52
- * @param {@serenity-js/core/lib/screenplay~Answerable<AxiosRequestConfig>} config
53
- * Axios request configuration overrides
54
- *
55
- * @returns {HeadRequest}
56
- */
57
- using(config) {
58
- return new HeadRequest(this.resourceUri, undefined, config);
59
- }
60
- }
61
- exports.HeadRequest = HeadRequest;
62
- //# sourceMappingURL=HeadRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HeadRequest.js","sourceRoot":"","sources":["../../src/model/HeadRequest.ts"],"names":[],"mappings":";;;AAGA,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;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;;;;;;;;;OASG;IACH,KAAK,CAAC,MAAsC;QACxC,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAChE,CAAC;CACJ;AAjCD,kCAiCC"}
@@ -1,58 +0,0 @@
1
- import { Answerable } from '@serenity-js/core';
2
- import { AxiosRequestConfig } from 'axios';
3
- import { HTTPRequest } from './HTTPRequest';
4
- /**
5
- * @desc
6
- * The OPTIONS method requests information about the communication
7
- * options available for the target resource, at either the origin
8
- * server or an intervening intermediary. This method allows a client
9
- * to determine the options and/or requirements associated with a
10
- * resource, or the capabilities of a server, without implying a
11
- * resource action.
12
- *
13
- * @example <caption>File download test</caption>
14
- * import { Actor } from '@serenity-js/core';
15
- * import { CallAnApi, OptionsRequest, LastResponse, Send } from '@serenity-js/rest'
16
- * import { Ensure, equals } from '@serenity-js/assertions';
17
- *
18
- * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
19
- *
20
- * actor.attemptsTo(
21
- * Send.a(OptionsRequest.to('/downloads/my-test-document.pdf')),
22
- * Ensure.that(LastResponse.status(), equals(200)),
23
- * Ensure.that(LastResponse.header('Allow'), equals('OPTIONS, GET, HEAD')),
24
- * );
25
- *
26
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS
27
- * @see https://tools.ietf.org/html/rfc7231#section-4.3.7
28
- *
29
- * @extends {HTTPRequest}
30
- */
31
- export declare class OptionsRequest extends HTTPRequest {
32
- /**
33
- * @desc
34
- * Configures the object with a destination URI.
35
- *
36
- * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
37
- * it gets concatenated with the URL provided to the Axios instance
38
- * when the {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
39
- *
40
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} resourceUri
41
- * The URI where the {@link @serenity-js/core/lib/screenplay/actor~Actor}
42
- * should send the {@link HTTPRequest}.
43
- *
44
- * @returns {OptionsRequest}
45
- */
46
- static to(resourceUri: Answerable<string>): OptionsRequest;
47
- /**
48
- * @desc
49
- * Overrides the default Axios request configuration provided
50
- * when {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
51
- *
52
- * @param {@serenity-js/core/lib/screenplay~Answerable<AxiosRequestConfig>} config
53
- * Axios request configuration overrides
54
- *
55
- * @returns {OptionsRequest}
56
- */
57
- using(config: Answerable<AxiosRequestConfig>): OptionsRequest;
58
- }
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OptionsRequest = void 0;
4
- const HTTPRequest_1 = require("./HTTPRequest");
5
- /**
6
- * @desc
7
- * The OPTIONS method requests information about the communication
8
- * options available for the target resource, at either the origin
9
- * server or an intervening intermediary. This method allows a client
10
- * to determine the options and/or requirements associated with a
11
- * resource, or the capabilities of a server, without implying a
12
- * resource action.
13
- *
14
- * @example <caption>File download test</caption>
15
- * import { Actor } from '@serenity-js/core';
16
- * import { CallAnApi, OptionsRequest, LastResponse, Send } from '@serenity-js/rest'
17
- * import { Ensure, equals } from '@serenity-js/assertions';
18
- *
19
- * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
20
- *
21
- * actor.attemptsTo(
22
- * Send.a(OptionsRequest.to('/downloads/my-test-document.pdf')),
23
- * Ensure.that(LastResponse.status(), equals(200)),
24
- * Ensure.that(LastResponse.header('Allow'), equals('OPTIONS, GET, HEAD')),
25
- * );
26
- *
27
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS
28
- * @see https://tools.ietf.org/html/rfc7231#section-4.3.7
29
- *
30
- * @extends {HTTPRequest}
31
- */
32
- class OptionsRequest extends HTTPRequest_1.HTTPRequest {
33
- /**
34
- * @desc
35
- * Configures the object with a destination URI.
36
- *
37
- * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
38
- * it gets concatenated with the URL provided to the Axios instance
39
- * when the {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
40
- *
41
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} resourceUri
42
- * The URI where the {@link @serenity-js/core/lib/screenplay/actor~Actor}
43
- * should send the {@link HTTPRequest}.
44
- *
45
- * @returns {OptionsRequest}
46
- */
47
- static to(resourceUri) {
48
- return new OptionsRequest(resourceUri);
49
- }
50
- /**
51
- * @desc
52
- * Overrides the default Axios request configuration provided
53
- * when {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
54
- *
55
- * @param {@serenity-js/core/lib/screenplay~Answerable<AxiosRequestConfig>} config
56
- * Axios request configuration overrides
57
- *
58
- * @returns {OptionsRequest}
59
- */
60
- using(config) {
61
- return new OptionsRequest(this.resourceUri, undefined, config);
62
- }
63
- }
64
- exports.OptionsRequest = OptionsRequest;
65
- //# sourceMappingURL=OptionsRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OptionsRequest.js","sourceRoot":"","sources":["../../src/model/OptionsRequest.ts"],"names":[],"mappings":";;;AAGA,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,cAAe,SAAQ,yBAAW;IAE3C;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,CAAC,WAA+B;QACrC,OAAO,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,MAAsC;QACxC,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACnE,CAAC;CACJ;AAjCD,wCAiCC"}
@@ -1,65 +0,0 @@
1
- import { Answerable } from '@serenity-js/core';
2
- import { AxiosRequestConfig } from 'axios';
3
- import { HTTPRequest } from './HTTPRequest';
4
- /**
5
- * @desc
6
- * The PATCH method requests that a set of changes described in the
7
- * request entity be applied to the resource identified by the `resourceUri`.
8
- *
9
- * @example <caption>Add new resource to a collection</caption>
10
- * import { Actor } from '@serenity-js/core';
11
- * import { CallAnApi, LastResponse, PatchRequest, Send } from '@serenity-js/rest'
12
- * import { Ensure, equals } from '@serenity-js/assertions';
13
- *
14
- * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
15
- *
16
- * actor.attemptsTo(
17
- * Send.a(PatchRequest.to('/books/0-688-00230-7').with({
18
- * lastReadOn: '2016-06-16',
19
- * })),
20
- * Ensure.that(LastResponse.status(), equals(204)),
21
- * );
22
- *
23
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH
24
- * @see https://tools.ietf.org/html/rfc5789
25
- *
26
- * @extends {HTTPRequest}
27
- */
28
- export declare class PatchRequest extends HTTPRequest {
29
- /**
30
- * @desc
31
- * Configures the object with a destination URI.
32
- *
33
- * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
34
- * it gets concatenated with the URL provided to the Axios instance
35
- * when the {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
36
- *
37
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} resourceUri
38
- * The URI where the {@link @serenity-js/core/lib/screenplay/actor~Actor}
39
- * should send the {@link HTTPRequest}.
40
- *
41
- * @returns {PatchRequest}
42
- */
43
- static to(resourceUri: Answerable<string>): PatchRequest;
44
- /**
45
- * @desc
46
- * Configures the object with a request body.
47
- *
48
- * @param {@serenity-js/core/lib/screenplay~Answerable<any>} data
49
- * Data to be sent to the `resourceUri`
50
- *
51
- * @returns {PatchRequest}
52
- */
53
- with(data: Answerable<any>): PatchRequest;
54
- /**
55
- * @desc
56
- * Overrides the default Axios request configuration provided
57
- * when {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
58
- *
59
- * @param {@serenity-js/core/lib/screenplay~Answerable<AxiosRequestConfig>} config
60
- * Axios request configuration overrides
61
- *
62
- * @returns {PatchRequest}
63
- */
64
- using(config: Answerable<AxiosRequestConfig>): PatchRequest;
65
- }
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PatchRequest = void 0;
4
- const HTTPRequest_1 = require("./HTTPRequest");
5
- /**
6
- * @desc
7
- * The PATCH method requests that a set of changes described in the
8
- * request entity be applied to the resource identified by the `resourceUri`.
9
- *
10
- * @example <caption>Add new resource to a collection</caption>
11
- * import { Actor } from '@serenity-js/core';
12
- * import { CallAnApi, LastResponse, PatchRequest, Send } from '@serenity-js/rest'
13
- * import { Ensure, equals } from '@serenity-js/assertions';
14
- *
15
- * const actor = Actor.named('Apisit').whoCan(CallAnApi.at('https://myapp.com/api'));
16
- *
17
- * actor.attemptsTo(
18
- * Send.a(PatchRequest.to('/books/0-688-00230-7').with({
19
- * lastReadOn: '2016-06-16',
20
- * })),
21
- * Ensure.that(LastResponse.status(), equals(204)),
22
- * );
23
- *
24
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH
25
- * @see https://tools.ietf.org/html/rfc5789
26
- *
27
- * @extends {HTTPRequest}
28
- */
29
- class PatchRequest extends HTTPRequest_1.HTTPRequest {
30
- /**
31
- * @desc
32
- * Configures the object with a destination URI.
33
- *
34
- * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
35
- * it gets concatenated with the URL provided to the Axios instance
36
- * when the {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
37
- *
38
- * @param {@serenity-js/core/lib/screenplay~Answerable<string>} resourceUri
39
- * The URI where the {@link @serenity-js/core/lib/screenplay/actor~Actor}
40
- * should send the {@link HTTPRequest}.
41
- *
42
- * @returns {PatchRequest}
43
- */
44
- static to(resourceUri) {
45
- return new PatchRequest(resourceUri);
46
- }
47
- /**
48
- * @desc
49
- * Configures the object with a request body.
50
- *
51
- * @param {@serenity-js/core/lib/screenplay~Answerable<any>} data
52
- * Data to be sent to the `resourceUri`
53
- *
54
- * @returns {PatchRequest}
55
- */
56
- with(data) {
57
- return new PatchRequest(this.resourceUri, data, this.config);
58
- }
59
- /**
60
- * @desc
61
- * Overrides the default Axios request configuration provided
62
- * when {@link CallAnApi} {@link @serenity-js/core/lib/screenplay~Ability} was instantiated.
63
- *
64
- * @param {@serenity-js/core/lib/screenplay~Answerable<AxiosRequestConfig>} config
65
- * Axios request configuration overrides
66
- *
67
- * @returns {PatchRequest}
68
- */
69
- using(config) {
70
- return new PatchRequest(this.resourceUri, this.data, config);
71
- }
72
- }
73
- exports.PatchRequest = PatchRequest;
74
- //# sourceMappingURL=PatchRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PatchRequest.js","sourceRoot":"","sources":["../../src/model/PatchRequest.ts"],"names":[],"mappings":";;;AAGA,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,YAAa,SAAQ,yBAAW;IAEzC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,CAAC,WAA+B;QACrC,OAAO,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;;;OAQG;IACH,IAAI,CAAC,IAAqB;QACtB,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,MAAsC;QACxC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC;CACJ;AA9CD,oCA8CC"}