@serenity-js/rest 3.0.0-rc.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/CHANGELOG.md +80 -1851
  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
@@ -0,0 +1,61 @@
1
+ import { Answerable, WithAnswerableProperties } from '@serenity-js/core';
2
+ import { AxiosRequestConfig } from 'axios';
3
+ import { HTTPRequest } from './HTTPRequest';
4
+ /**
5
+ * The OPTIONS method requests information about the communication
6
+ * options available for the target resource, at either the origin
7
+ * server or an intervening intermediary. This method allows a client
8
+ * to determine the options and/or requirements associated with a
9
+ * resource, or the capabilities of a server, without implying a
10
+ * resource action.
11
+ *
12
+ * ## File download test
13
+ *
14
+ * ```ts
15
+ * import { actorCalled } from '@serenity-js/core'
16
+ * import { CallAnApi, OptionsRequest, LastResponse, Send } from '@serenity-js/rest'
17
+ * import { Ensure, equals } from '@serenity-js/assertions'
18
+ *
19
+ * await actorCalled('Apisitt')
20
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
21
+ * .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
+ *
28
+ * ## Learn more
29
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS
30
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.7
31
+ *
32
+ * @group Models
33
+ */
34
+ export declare class OptionsRequest extends HTTPRequest {
35
+ /**
36
+ * Configures the object with a destination URI.
37
+ *
38
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
39
+ * it gets concatenated with the URL provided to the Axios instance
40
+ * when the {@apilink Ability|ability} to {@apilink CallAnApi} was instantiated.
41
+ *
42
+ * @param resourceUri
43
+ * The URI where the {@apilink Actor}
44
+ * should send the {@apilink HTTPRequest}
45
+ */
46
+ static to(resourceUri: Answerable<string>): OptionsRequest;
47
+ /**
48
+ * Overrides the default Axios request configuration provided
49
+ * when the {@apilink Ability|ability} to {@apilink CallAnApi} was instantiated.
50
+ *
51
+ * #### Learn more
52
+ * - {@apilink Answerable}
53
+ * - {@apilink WithAnswerableProperties}
54
+ * - [AxiosRequestConfig](https://github.com/axios/axios/blob/v0.27.2/index.d.ts#L75-L113)
55
+ *
56
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
57
+ * Axios request configuration overrides
58
+ */
59
+ using(config: Answerable<WithAnswerableProperties<AxiosRequestConfig>>): OptionsRequest;
60
+ }
61
+ //# sourceMappingURL=OptionsRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptionsRequest.d.ts","sourceRoot":"","sources":["../../src/models/OptionsRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,cAAe,SAAQ,WAAW;IAE3C;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,cAAc;IAI1D;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC,GAAG,cAAc;CAG1F"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OptionsRequest = void 0;
4
+ const core_1 = require("@serenity-js/core");
5
+ const HTTPRequest_1 = require("./HTTPRequest");
6
+ /**
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
+ * ## File download test
15
+ *
16
+ * ```ts
17
+ * import { actorCalled } from '@serenity-js/core'
18
+ * import { CallAnApi, OptionsRequest, LastResponse, Send } from '@serenity-js/rest'
19
+ * import { Ensure, equals } from '@serenity-js/assertions'
20
+ *
21
+ * await actorCalled('Apisitt')
22
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
23
+ * .attemptsTo(
24
+ * Send.a(OptionsRequest.to('/downloads/my-test-document.pdf')),
25
+ * Ensure.that(LastResponse.status(), equals(200)),
26
+ * Ensure.that(LastResponse.header('Allow'), equals('OPTIONS, GET, HEAD')),
27
+ * )
28
+ * ```
29
+ *
30
+ * ## Learn more
31
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS
32
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.7
33
+ *
34
+ * @group Models
35
+ */
36
+ class OptionsRequest extends HTTPRequest_1.HTTPRequest {
37
+ /**
38
+ * Configures the object with a destination URI.
39
+ *
40
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
41
+ * it gets concatenated with the URL provided to the Axios instance
42
+ * when the {@apilink Ability|ability} to {@apilink CallAnApi} was instantiated.
43
+ *
44
+ * @param resourceUri
45
+ * The URI where the {@apilink Actor}
46
+ * should send the {@apilink HTTPRequest}
47
+ */
48
+ static to(resourceUri) {
49
+ return new OptionsRequest(resourceUri);
50
+ }
51
+ /**
52
+ * Overrides the default Axios request configuration provided
53
+ * when the {@apilink Ability|ability} to {@apilink CallAnApi} was instantiated.
54
+ *
55
+ * #### Learn more
56
+ * - {@apilink Answerable}
57
+ * - {@apilink WithAnswerableProperties}
58
+ * - [AxiosRequestConfig](https://github.com/axios/axios/blob/v0.27.2/index.d.ts#L75-L113)
59
+ *
60
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
61
+ * Axios request configuration overrides
62
+ */
63
+ using(config) {
64
+ return new OptionsRequest(this.resourceUri, undefined, core_1.Question.fromObject(config));
65
+ }
66
+ }
67
+ exports.OptionsRequest = OptionsRequest;
68
+ //# sourceMappingURL=OptionsRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptionsRequest.js","sourceRoot":"","sources":["../../src/models/OptionsRequest.ts"],"names":[],"mappings":";;;AAAA,4CAAmF;AAGnF,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,cAAe,SAAQ,yBAAW;IAE3C;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAA+B;QACrC,OAAO,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAgE;QAClE,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,eAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACxF,CAAC;CACJ;AAhCD,wCAgCC"}
@@ -0,0 +1,65 @@
1
+ import { Answerable, WithAnswerableProperties } from '@serenity-js/core';
2
+ import { AxiosRequestConfig } from 'axios';
3
+ import { HTTPRequest } from './HTTPRequest';
4
+ /**
5
+ * The PATCH method requests that a set of changes described in the
6
+ * request entity be applied to the resource identified by the `resourceUri`.
7
+ *
8
+ * ## Add new resource to a collection
9
+ *
10
+ * ```ts
11
+ * import { actorCalled } from '@serenity-js/core'
12
+ * import { CallAnApi, LastResponse, PatchRequest, Send } from '@serenity-js/rest'
13
+ * import { Ensure, equals } from '@serenity-js/assertions'
14
+ *
15
+ * await actorCalled('Apisitt')
16
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
17
+ * .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
+ *
25
+ * ## Learn more
26
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH
27
+ * - https://tools.ietf.org/html/rfc5789
28
+ *
29
+ * @group Models
30
+ */
31
+ export declare class PatchRequest extends HTTPRequest {
32
+ /**
33
+ * Configures the object with a destination URI.
34
+ *
35
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
36
+ * it gets concatenated with the URL provided to the Axios instance
37
+ * when the {@apilink Ability|ability} to {@apilink CallAnApi} was instantiated.
38
+ *
39
+ * @param resourceUri
40
+ * The URI where the {@apilink Actor}
41
+ * should send the {@apilink HTTPRequest}
42
+ */
43
+ static to(resourceUri: Answerable<string>): PatchRequest;
44
+ /**
45
+ * Configures the object with a request body.
46
+ *
47
+ * @param data
48
+ * Data to be sent to the `resourceUri`
49
+ */
50
+ with(data: Answerable<any>): PatchRequest;
51
+ /**
52
+ * Overrides the default Axios request configuration provided
53
+ * when the {@apilink Ability|ability} to {@apilink CallAnApi} was instantiated.
54
+ *
55
+ * #### Learn more
56
+ * - {@apilink Answerable}
57
+ * - {@apilink WithAnswerableProperties}
58
+ * - [AxiosRequestConfig](https://github.com/axios/axios/blob/v0.27.2/index.d.ts#L75-L113)
59
+ *
60
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
61
+ * Axios request configuration overrides
62
+ */
63
+ using(config: Answerable<WithAnswerableProperties<AxiosRequestConfig>>): PatchRequest;
64
+ }
65
+ //# sourceMappingURL=PatchRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PatchRequest.d.ts","sourceRoot":"","sources":["../../src/models/PatchRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAEzC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,YAAY;IAIxD;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,YAAY;IAIzC;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC,GAAG,YAAY;CAGxF"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PatchRequest = void 0;
4
+ const core_1 = require("@serenity-js/core");
5
+ const HTTPRequest_1 = require("./HTTPRequest");
6
+ /**
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
+ * ## Add new resource to a collection
11
+ *
12
+ * ```ts
13
+ * import { actorCalled } from '@serenity-js/core'
14
+ * import { CallAnApi, LastResponse, PatchRequest, Send } from '@serenity-js/rest'
15
+ * import { Ensure, equals } from '@serenity-js/assertions'
16
+ *
17
+ * await actorCalled('Apisitt')
18
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
19
+ * .attemptsTo(
20
+ * Send.a(PatchRequest.to('/books/0-688-00230-7').with({
21
+ * lastReadOn: '2016-06-16',
22
+ * })),
23
+ * Ensure.that(LastResponse.status(), equals(204)),
24
+ * )
25
+ * ```
26
+ *
27
+ * ## Learn more
28
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH
29
+ * - https://tools.ietf.org/html/rfc5789
30
+ *
31
+ * @group Models
32
+ */
33
+ class PatchRequest extends HTTPRequest_1.HTTPRequest {
34
+ /**
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 {@apilink Ability|ability} to {@apilink CallAnApi} was instantiated.
40
+ *
41
+ * @param resourceUri
42
+ * The URI where the {@apilink Actor}
43
+ * should send the {@apilink HTTPRequest}
44
+ */
45
+ static to(resourceUri) {
46
+ return new PatchRequest(resourceUri);
47
+ }
48
+ /**
49
+ * Configures the object with a request body.
50
+ *
51
+ * @param data
52
+ * Data to be sent to the `resourceUri`
53
+ */
54
+ with(data) {
55
+ return new PatchRequest(this.resourceUri, data, this.config);
56
+ }
57
+ /**
58
+ * Overrides the default Axios request configuration provided
59
+ * when the {@apilink Ability|ability} to {@apilink CallAnApi} was instantiated.
60
+ *
61
+ * #### Learn more
62
+ * - {@apilink Answerable}
63
+ * - {@apilink WithAnswerableProperties}
64
+ * - [AxiosRequestConfig](https://github.com/axios/axios/blob/v0.27.2/index.d.ts#L75-L113)
65
+ *
66
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
67
+ * Axios request configuration overrides
68
+ */
69
+ using(config) {
70
+ return new PatchRequest(this.resourceUri, this.data, core_1.Question.fromObject(config));
71
+ }
72
+ }
73
+ exports.PatchRequest = PatchRequest;
74
+ //# sourceMappingURL=PatchRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PatchRequest.js","sourceRoot":"","sources":["../../src/models/PatchRequest.ts"],"names":[],"mappings":";;;AAAA,4CAAmF;AAGnF,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,YAAa,SAAQ,yBAAW;IAEzC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAA+B;QACrC,OAAO,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,IAAqB;QACtB,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAgE;QAClE,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,eAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACtF,CAAC;CACJ;AA1CD,oCA0CC"}
@@ -0,0 +1,105 @@
1
+ import { Answerable, WithAnswerableProperties } from '@serenity-js/core';
2
+ import { AxiosRequestConfig } from 'axios';
3
+ import { HTTPRequest } from './HTTPRequest';
4
+ /**
5
+ * The HTTP POST method requests that the origin server accepts
6
+ * the entity enclosed in the request as a new subordinate of the resource
7
+ * identified by the `resourceUri`.
8
+ *
9
+ * This means that the POST should be used when you want to create a child resource under
10
+ * a collection of resources.
11
+ *
12
+ * POST request is neither [safe](https://developer.mozilla.org/en-US/docs/Glossary/Safe),
13
+ * nor [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent).
14
+ * This means that if you retry a POST request N times,
15
+ * a correctly implemented HTTP REST API will create N resources with N different URIs.
16
+ *
17
+ * ## Add new resource to a collection
18
+ *
19
+ * ```ts
20
+ * import { actorCalled } from '@serenity-js/core'
21
+ * import { CallAnApi, LastResponse, PostRequest, Send } from '@serenity-js/rest'
22
+ * import { Ensure, equals } from '@serenity-js/assertions'
23
+ *
24
+ * await actorCalled('Apisitt')
25
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
26
+ * .attemptsTo(
27
+ * Send.a(PostRequest.to('/books').with({
28
+ * isbn: '0-688-00230-7',
29
+ * title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
30
+ * author: 'Robert M. Pirsig',
31
+ * })),
32
+ * Ensure.that(LastResponse.status(), equals(201)),
33
+ * Ensure.that(LastResponse.header('Location'), equals('/books/0-688-00230-7')),
34
+ * )
35
+ * ```
36
+ *
37
+ * ## Submit an HTML form
38
+ *
39
+ * ```ts
40
+ * import { actorCalled } from '@serenity-js/core'
41
+ * import { CallAnApi, LastResponse, PostRequest, Send } from '@serenity-js/rest'
42
+ * import { Ensure, equals } from '@serenity-js/assertions'
43
+ * import { stringify } from 'querystring'
44
+ *
45
+ * const formData = stringify({
46
+ * name: actor.name,
47
+ * email: `${ actor.name }@example.com`,
48
+ * text: 'Your website is great! Learnt a lot :-)'
49
+ * });
50
+ *
51
+ * await actorCalled('Apisitt')
52
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
53
+ * .attemptsTo(
54
+ * Send.a(PostRequest.to('/feedback').with(postData).using({
55
+ * headers: {
56
+ * 'Content-Type': 'application/x-www-form-urlencoded',
57
+ * 'Content-Length': formData.length
58
+ * }
59
+ * })),
60
+ * Ensure.that(LastResponse.status(), equals(200)),
61
+ * Ensure.that(LastResponse.header('Location'), equals('/feedback/thank-you.html')),
62
+ * )
63
+ * ```
64
+ *
65
+ * ## Learn more
66
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
67
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.3
68
+ *
69
+ * @group Models
70
+ */
71
+ export declare class PostRequest extends HTTPRequest {
72
+ /**
73
+ * Configures the object with a destination URI.
74
+ *
75
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
76
+ * it gets concatenated with the URL provided to the Axios instance
77
+ * when the {@apilink Ability|ability} to {@apilink CallAnApi} was instantiated.
78
+ *
79
+ * @param resourceUri
80
+ * The URI where the {@apilink Actor}
81
+ * should send the {@apilink HTTPRequest}
82
+ */
83
+ static to(resourceUri: Answerable<string>): PostRequest;
84
+ /**
85
+ * Configures the object with a request body.
86
+ *
87
+ * @param data
88
+ * Data to be sent to the `resourceUri`
89
+ */
90
+ with(data: Answerable<any>): PostRequest;
91
+ /**
92
+ * Overrides the default Axios request configuration provided
93
+ * when the {@apilink Ability|ability} to {@apilink CallAnApi} was instantiated.
94
+ *
95
+ * #### Learn more
96
+ * - {@apilink Answerable}
97
+ * - {@apilink WithAnswerableProperties}
98
+ * - [AxiosRequestConfig](https://github.com/axios/axios/blob/v0.27.2/index.d.ts#L75-L113)
99
+ *
100
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
101
+ * Axios request configuration overrides
102
+ */
103
+ using(config: Answerable<WithAnswerableProperties<AxiosRequestConfig>>): PostRequest;
104
+ }
105
+ //# sourceMappingURL=PostRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PostRequest.d.ts","sourceRoot":"","sources":["../../src/models/PostRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,qBAAa,WAAY,SAAQ,WAAW;IAExC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,WAAW;IAIvD;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,WAAW;IAIxC;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC,GAAG,WAAW;CAGvF"}
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PostRequest = void 0;
4
+ const core_1 = require("@serenity-js/core");
5
+ const HTTPRequest_1 = require("./HTTPRequest");
6
+ /**
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
+ * ## Add new resource to a collection
20
+ *
21
+ * ```ts
22
+ * import { actorCalled } from '@serenity-js/core'
23
+ * import { CallAnApi, LastResponse, PostRequest, Send } from '@serenity-js/rest'
24
+ * import { Ensure, equals } from '@serenity-js/assertions'
25
+ *
26
+ * await actorCalled('Apisitt')
27
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
28
+ * .attemptsTo(
29
+ * Send.a(PostRequest.to('/books').with({
30
+ * isbn: '0-688-00230-7',
31
+ * title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
32
+ * author: 'Robert M. Pirsig',
33
+ * })),
34
+ * Ensure.that(LastResponse.status(), equals(201)),
35
+ * Ensure.that(LastResponse.header('Location'), equals('/books/0-688-00230-7')),
36
+ * )
37
+ * ```
38
+ *
39
+ * ## Submit an HTML form
40
+ *
41
+ * ```ts
42
+ * import { actorCalled } from '@serenity-js/core'
43
+ * import { CallAnApi, LastResponse, PostRequest, Send } from '@serenity-js/rest'
44
+ * import { Ensure, equals } from '@serenity-js/assertions'
45
+ * import { stringify } from 'querystring'
46
+ *
47
+ * const formData = stringify({
48
+ * name: actor.name,
49
+ * email: `${ actor.name }@example.com`,
50
+ * text: 'Your website is great! Learnt a lot :-)'
51
+ * });
52
+ *
53
+ * await actorCalled('Apisitt')
54
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
55
+ * .attemptsTo(
56
+ * Send.a(PostRequest.to('/feedback').with(postData).using({
57
+ * headers: {
58
+ * 'Content-Type': 'application/x-www-form-urlencoded',
59
+ * 'Content-Length': formData.length
60
+ * }
61
+ * })),
62
+ * Ensure.that(LastResponse.status(), equals(200)),
63
+ * Ensure.that(LastResponse.header('Location'), equals('/feedback/thank-you.html')),
64
+ * )
65
+ * ```
66
+ *
67
+ * ## Learn more
68
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
69
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.3
70
+ *
71
+ * @group Models
72
+ */
73
+ class PostRequest extends HTTPRequest_1.HTTPRequest {
74
+ /**
75
+ * Configures the object with a destination URI.
76
+ *
77
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
78
+ * it gets concatenated with the URL provided to the Axios instance
79
+ * when the {@apilink Ability|ability} to {@apilink CallAnApi} was instantiated.
80
+ *
81
+ * @param resourceUri
82
+ * The URI where the {@apilink Actor}
83
+ * should send the {@apilink HTTPRequest}
84
+ */
85
+ static to(resourceUri) {
86
+ return new PostRequest(resourceUri);
87
+ }
88
+ /**
89
+ * Configures the object with a request body.
90
+ *
91
+ * @param data
92
+ * Data to be sent to the `resourceUri`
93
+ */
94
+ with(data) {
95
+ return new PostRequest(this.resourceUri, data, this.config);
96
+ }
97
+ /**
98
+ * Overrides the default Axios request configuration provided
99
+ * when the {@apilink Ability|ability} to {@apilink CallAnApi} was instantiated.
100
+ *
101
+ * #### Learn more
102
+ * - {@apilink Answerable}
103
+ * - {@apilink WithAnswerableProperties}
104
+ * - [AxiosRequestConfig](https://github.com/axios/axios/blob/v0.27.2/index.d.ts#L75-L113)
105
+ *
106
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
107
+ * Axios request configuration overrides
108
+ */
109
+ using(config) {
110
+ return new PostRequest(this.resourceUri, this.data, core_1.Question.fromObject(config));
111
+ }
112
+ }
113
+ exports.PostRequest = PostRequest;
114
+ //# sourceMappingURL=PostRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PostRequest.js","sourceRoot":"","sources":["../../src/models/PostRequest.ts"],"names":[],"mappings":";;;AAAA,4CAAmF;AAGnF,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,MAAa,WAAY,SAAQ,yBAAW;IAExC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAA+B;QACrC,OAAO,IAAI,WAAW,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,IAAqB;QACtB,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAChE,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAgE;QAClE,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,eAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF,CAAC;CACJ;AA1CD,kCA0CC"}
@@ -0,0 +1,75 @@
1
+ import { Answerable, WithAnswerableProperties } from '@serenity-js/core';
2
+ import { AxiosRequestConfig } from 'axios';
3
+ import { HTTPRequest } from './HTTPRequest';
4
+ /**
5
+ * The PUT method requests that the state of the target resource be
6
+ * created or replaced with the state defined by the representation
7
+ * enclosed in the request message payload.
8
+ *
9
+ * PUT request should be used when you want to create
10
+ * a new resource at a known `resourceUri` (e.g. `/books/0-688-00230-7`)
11
+ * or replace an existing resource at such `resourceUri`.
12
+ *
13
+ * PUT request is [idempotent](https://developer.mozilla.org/en-US/docs/Glossary/Idempotent):
14
+ * calling it once or several times successively has the same effect (that is no _side effect_).
15
+ *
16
+ * ## Create a new resource at a known location
17
+ *
18
+ * ```ts
19
+ * import { actorCalled } from '@serenity-js/core';
20
+ * import { CallAnApi, LastResponse, PutRequest, Send } from '@serenity-js/rest';
21
+ * import { Ensure, equals } from '@serenity-js/assertions';
22
+ *
23
+ * await actorCalled('Apisit')
24
+ * .whoCan(CallAnApi.at('https://api.example.org/'))
25
+ * .attemptsTo(
26
+ * Send.a(PutRequest.to('/books/0-688-00230-7').with({
27
+ * isbn: '0-688-00230-7',
28
+ * title: 'Zen and the Art of Motorcycle Maintenance: An Inquiry into Values',
29
+ * author: 'Robert M. Pirsig',
30
+ * })),
31
+ * Ensure.that(LastResponse.status(), equals(201)),
32
+ * )
33
+ * ```
34
+ *
35
+ * ## Learn more
36
+ * - https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT
37
+ * - https://tools.ietf.org/html/rfc7231#section-4.3.4
38
+ *
39
+ * @group Models
40
+ */
41
+ export declare class PutRequest extends HTTPRequest {
42
+ /**
43
+ * Configures the object with a destination URI.
44
+ *
45
+ * When the `resourceUri` is not a fully qualified URL but a path, such as `/products/2`,
46
+ * it gets concatenated with the URL provided to the Axios instance
47
+ * when the {@apilink Ability|ability} to {@apilink CallAnApi} was instantiated.
48
+ *
49
+ * @param resourceUri
50
+ * The URI where the {@apilink Actor}
51
+ * should send the {@apilink HTTPRequest}
52
+ */
53
+ static to(resourceUri: Answerable<string>): PutRequest;
54
+ /**
55
+ * Configures the object with a request body.
56
+ *
57
+ * @param data
58
+ * Data to be sent to the `resourceUri`
59
+ */
60
+ with(data: Answerable<any>): PutRequest;
61
+ /**
62
+ * Overrides the default Axios request configuration provided
63
+ * when the {@apilink Ability|ability} to {@apilink CallAnApi} was instantiated.
64
+ *
65
+ * #### Learn more
66
+ * - {@apilink Answerable}
67
+ * - {@apilink WithAnswerableProperties}
68
+ * - [AxiosRequestConfig](https://github.com/axios/axios/blob/v0.27.2/index.d.ts#L75-L113)
69
+ *
70
+ * @param {Answerable<WithAnswerableProperties<AxiosRequestConfig>>} config
71
+ * Axios request configuration overrides
72
+ */
73
+ using(config: Answerable<WithAnswerableProperties<AxiosRequestConfig>>): PutRequest;
74
+ }
75
+ //# sourceMappingURL=PutRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PutRequest.d.ts","sourceRoot":"","sources":["../../src/models/PutRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,UAAW,SAAQ,WAAW;IAEvC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,UAAU;IAItD;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,UAAU;IAIvC;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC,GAAG,UAAU;CAGtF"}