@api-client/core 0.9.3 → 0.9.5

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 (228) hide show
  1. package/build/browser.d.ts +12 -2
  2. package/build/browser.js +15 -2
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +13 -3
  5. package/build/index.js +16 -3
  6. package/build/index.js.map +1 -1
  7. package/build/src/data/{JmesparthReader.d.ts → JmespathReader.d.ts} +1 -1
  8. package/build/src/data/{JmesparthReader.js → JmespathReader.js} +2 -2
  9. package/build/src/data/JmespathReader.js.map +1 -0
  10. package/build/src/data/RequestDataExtractor.d.ts +5 -5
  11. package/build/src/data/RequestDataExtractor.js.map +1 -1
  12. package/build/src/data/XmlReader.js +14 -1
  13. package/build/src/data/XmlReader.js.map +1 -1
  14. package/build/src/models/ClientCertificate.d.ts +9 -0
  15. package/build/src/models/ClientCertificate.js.map +1 -1
  16. package/build/src/models/Environment.d.ts +3 -2
  17. package/build/src/models/Environment.js +11 -6
  18. package/build/src/models/Environment.js.map +1 -1
  19. package/build/src/models/ErrorResponse.js.map +1 -1
  20. package/build/src/models/HttpRequest.d.ts +2 -7
  21. package/build/src/models/HttpRequest.js +1 -6
  22. package/build/src/models/HttpRequest.js.map +1 -1
  23. package/build/src/models/HttpResponse.d.ts +2 -7
  24. package/build/src/models/HttpResponse.js +1 -3
  25. package/build/src/models/HttpResponse.js.map +1 -1
  26. package/build/src/models/ProjectRequest.d.ts +19 -0
  27. package/build/src/models/ProjectRequest.js +50 -0
  28. package/build/src/models/ProjectRequest.js.map +1 -1
  29. package/build/src/models/Request.d.ts +12 -3
  30. package/build/src/models/Request.js +14 -1
  31. package/build/src/models/Request.js.map +1 -1
  32. package/build/src/models/RequestAuthorization.js.map +1 -1
  33. package/build/src/models/RequestLog.d.ts +11 -0
  34. package/build/src/models/RequestLog.js +15 -1
  35. package/build/src/models/RequestLog.js.map +1 -1
  36. package/build/src/models/SerializablePayload.d.ts +6 -1
  37. package/build/src/models/SerializablePayload.js +10 -6
  38. package/build/src/models/SerializablePayload.js.map +1 -1
  39. package/build/src/models/http-actions/AssertionError.d.ts +36 -0
  40. package/build/src/models/http-actions/AssertionError.js +35 -0
  41. package/build/src/models/http-actions/AssertionError.js.map +1 -0
  42. package/build/src/models/http-actions/HttpAssertion.d.ts +84 -0
  43. package/build/src/models/http-actions/HttpAssertion.js +52 -0
  44. package/build/src/models/http-actions/HttpAssertion.js.map +1 -0
  45. package/build/src/models/http-actions/HttpFlows.d.ts +109 -0
  46. package/build/src/models/http-actions/HttpFlows.js +31 -0
  47. package/build/src/models/http-actions/HttpFlows.js.map +1 -0
  48. package/build/src/models/http-actions/HttpStep.d.ts +29 -0
  49. package/build/src/models/http-actions/HttpStep.js +30 -0
  50. package/build/src/models/http-actions/HttpStep.js.map +1 -0
  51. package/build/src/models/http-actions/LegacyTranslator.d.ts +8 -7
  52. package/build/src/models/http-actions/LegacyTranslator.js +18 -13
  53. package/build/src/models/http-actions/LegacyTranslator.js.map +1 -1
  54. package/build/src/models/http-actions/steps/assertion/EqualAssertion.d.ts +76 -0
  55. package/build/src/models/http-actions/steps/assertion/EqualAssertion.js +79 -0
  56. package/build/src/models/http-actions/steps/assertion/EqualAssertion.js.map +1 -0
  57. package/build/src/models/http-actions/steps/assertion/GreaterThanAssertion.d.ts +36 -0
  58. package/build/src/models/http-actions/steps/assertion/GreaterThanAssertion.js +59 -0
  59. package/build/src/models/http-actions/steps/assertion/GreaterThanAssertion.js.map +1 -0
  60. package/build/src/models/http-actions/steps/assertion/IncludesAssertion.d.ts +28 -0
  61. package/build/src/models/http-actions/steps/assertion/IncludesAssertion.js +45 -0
  62. package/build/src/models/http-actions/steps/assertion/IncludesAssertion.js.map +1 -0
  63. package/build/src/models/http-actions/steps/assertion/IsEmptyAssertion.d.ts +18 -0
  64. package/build/src/models/http-actions/steps/assertion/IsEmptyAssertion.js +29 -0
  65. package/build/src/models/http-actions/steps/assertion/IsEmptyAssertion.js.map +1 -0
  66. package/build/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.d.ts +18 -0
  67. package/build/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.js +29 -0
  68. package/build/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.js.map +1 -0
  69. package/build/src/models/http-actions/steps/assertion/LengthOfAssertion.d.ts +28 -0
  70. package/build/src/models/http-actions/steps/assertion/LengthOfAssertion.js +45 -0
  71. package/build/src/models/http-actions/steps/assertion/LengthOfAssertion.js.map +1 -0
  72. package/build/src/models/http-actions/steps/assertion/LessThanAssertion.d.ts +36 -0
  73. package/build/src/models/http-actions/steps/assertion/LessThanAssertion.js +59 -0
  74. package/build/src/models/http-actions/steps/assertion/LessThanAssertion.js.map +1 -0
  75. package/build/src/models/http-actions/steps/assertion/MatchesAssertion.d.ts +28 -0
  76. package/build/src/models/http-actions/steps/assertion/MatchesAssertion.js +45 -0
  77. package/build/src/models/http-actions/steps/assertion/MatchesAssertion.js.map +1 -0
  78. package/build/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.d.ts +36 -0
  79. package/build/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.js +59 -0
  80. package/build/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.js.map +1 -0
  81. package/build/src/models/http-actions/steps/assertion/NotEqualAssertion.d.ts +76 -0
  82. package/build/src/models/http-actions/steps/assertion/NotEqualAssertion.js +79 -0
  83. package/build/src/models/http-actions/steps/assertion/NotEqualAssertion.js.map +1 -0
  84. package/build/src/models/http-actions/steps/assertion/NotIncludesAssertion.d.ts +28 -0
  85. package/build/src/models/http-actions/steps/assertion/NotIncludesAssertion.js +45 -0
  86. package/build/src/models/http-actions/steps/assertion/NotIncludesAssertion.js.map +1 -0
  87. package/build/src/models/http-actions/steps/assertion/NotOkAssertion.d.ts +18 -0
  88. package/build/src/models/http-actions/steps/assertion/NotOkAssertion.js +29 -0
  89. package/build/src/models/http-actions/steps/assertion/NotOkAssertion.js.map +1 -0
  90. package/build/src/models/http-actions/steps/assertion/NotToBeAssertion.d.ts +29 -0
  91. package/build/src/models/http-actions/steps/assertion/NotToBeAssertion.js +45 -0
  92. package/build/src/models/http-actions/steps/assertion/NotToBeAssertion.js.map +1 -0
  93. package/build/src/models/http-actions/steps/assertion/OkAssertion.d.ts +18 -0
  94. package/build/src/models/http-actions/steps/assertion/OkAssertion.js +29 -0
  95. package/build/src/models/http-actions/steps/assertion/OkAssertion.js.map +1 -0
  96. package/build/src/models/http-actions/steps/assertion/ToBeAssertion.d.ts +35 -0
  97. package/build/src/models/http-actions/steps/assertion/ToBeAssertion.js +53 -0
  98. package/build/src/models/http-actions/steps/assertion/ToBeAssertion.js.map +1 -0
  99. package/build/src/models/http-actions/steps/assertion/index.d.ts +15 -0
  100. package/build/src/models/http-actions/steps/assertion/index.js +16 -0
  101. package/build/src/models/http-actions/steps/assertion/index.js.map +1 -0
  102. package/build/src/models/http-actions/steps/data/DeleteCookieStep.d.ts +44 -0
  103. package/build/src/models/http-actions/steps/data/DeleteCookieStep.js +67 -0
  104. package/build/src/models/http-actions/steps/data/DeleteCookieStep.js.map +1 -0
  105. package/build/src/models/http-actions/steps/data/ReadDataSourceStep.d.ts +53 -0
  106. package/build/src/models/http-actions/steps/data/ReadDataSourceStep.js +60 -0
  107. package/build/src/models/http-actions/steps/data/ReadDataSourceStep.js.map +1 -0
  108. package/build/src/models/http-actions/steps/data/ReadDataStep.d.ts +67 -0
  109. package/build/src/models/http-actions/steps/data/ReadDataStep.js +77 -0
  110. package/build/src/models/http-actions/steps/data/ReadDataStep.js.map +1 -0
  111. package/build/src/models/http-actions/steps/data/ReadValueStep.d.ts +45 -0
  112. package/build/src/models/http-actions/steps/data/ReadValueStep.js +52 -0
  113. package/build/src/models/http-actions/steps/data/ReadValueStep.js.map +1 -0
  114. package/build/src/models/http-actions/steps/data/SetCookieStep.d.ts +100 -0
  115. package/build/src/models/http-actions/steps/data/SetCookieStep.js +138 -0
  116. package/build/src/models/http-actions/steps/data/SetCookieStep.js.map +1 -0
  117. package/build/src/models/http-actions/steps/data/SetDataStep.d.ts +77 -0
  118. package/build/src/models/http-actions/steps/data/SetDataStep.js +69 -0
  119. package/build/src/models/http-actions/steps/data/SetDataStep.js.map +1 -0
  120. package/build/src/models/http-actions/steps/data/SetVariableStep.d.ts +40 -0
  121. package/build/src/models/http-actions/steps/data/SetVariableStep.js +44 -0
  122. package/build/src/models/http-actions/steps/data/SetVariableStep.js.map +1 -0
  123. package/build/src/models/http-actions/steps/data/index.d.ts +7 -0
  124. package/build/src/models/http-actions/steps/data/index.js +8 -0
  125. package/build/src/models/http-actions/steps/data/index.js.map +1 -0
  126. package/build/src/models/http-actions/steps/transformation/AsLowerCaseStep.d.ts +18 -0
  127. package/build/src/models/http-actions/steps/transformation/AsLowerCaseStep.js +29 -0
  128. package/build/src/models/http-actions/steps/transformation/AsLowerCaseStep.js.map +1 -0
  129. package/build/src/models/http-actions/steps/transformation/AsNumberStep.d.ts +18 -0
  130. package/build/src/models/http-actions/steps/transformation/AsNumberStep.js +29 -0
  131. package/build/src/models/http-actions/steps/transformation/AsNumberStep.js.map +1 -0
  132. package/build/src/models/http-actions/steps/transformation/AsUpperCaseStep.d.ts +18 -0
  133. package/build/src/models/http-actions/steps/transformation/AsUpperCaseStep.js +29 -0
  134. package/build/src/models/http-actions/steps/transformation/AsUpperCaseStep.js.map +1 -0
  135. package/build/src/models/http-actions/steps/transformation/RoundStep.d.ts +43 -0
  136. package/build/src/models/http-actions/steps/transformation/RoundStep.js +52 -0
  137. package/build/src/models/http-actions/steps/transformation/RoundStep.js.map +1 -0
  138. package/build/src/models/http-actions/steps/transformation/SubstringStep.d.ts +38 -0
  139. package/build/src/models/http-actions/steps/transformation/SubstringStep.js +65 -0
  140. package/build/src/models/http-actions/steps/transformation/SubstringStep.js.map +1 -0
  141. package/build/src/models/http-actions/steps/transformation/TrimStep.d.ts +20 -0
  142. package/build/src/models/http-actions/steps/transformation/TrimStep.js +30 -0
  143. package/build/src/models/http-actions/steps/transformation/TrimStep.js.map +1 -0
  144. package/build/src/models/http-actions/steps/transformation/index.d.ts +6 -0
  145. package/build/src/models/http-actions/steps/transformation/index.js +7 -0
  146. package/build/src/models/http-actions/steps/transformation/index.js.map +1 -0
  147. package/build/src/proxy/RequestProxy.d.ts +7 -2
  148. package/build/src/proxy/RequestProxy.js +4 -1
  149. package/build/src/proxy/RequestProxy.js.map +1 -1
  150. package/build/src/runtime/http-runner/ConditionCheck.d.ts +10 -10
  151. package/build/src/runtime/http-runner/ConditionCheck.js.map +1 -1
  152. package/build/src/runtime/http-runner/HttpAssertionRunner.d.ts +75 -0
  153. package/build/src/runtime/http-runner/HttpAssertionRunner.js +538 -0
  154. package/build/src/runtime/http-runner/HttpAssertionRunner.js.map +1 -0
  155. package/build/src/runtime/http-runner/HttpFlowRunner.d.ts +11 -6
  156. package/build/src/runtime/http-runner/HttpFlowRunner.js +24 -15
  157. package/build/src/runtime/http-runner/HttpFlowRunner.js.map +1 -1
  158. package/build/src/runtime/http-runner/HttpRequestRunner.d.ts +14 -3
  159. package/build/src/runtime/http-runner/HttpRequestRunner.js +44 -0
  160. package/build/src/runtime/http-runner/HttpRequestRunner.js.map +1 -1
  161. package/build/src/runtime/node/ProjectParallelRunner.d.ts +1 -1
  162. package/build/src/runtime/node/ProjectParallelRunner.js +2 -2
  163. package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -1
  164. package/build/src/runtime/node/ProjectRequestRunner.js +6 -2
  165. package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
  166. package/build/src/runtime/store/FilesSdk.js +1 -1
  167. package/build/src/runtime/store/FilesSdk.js.map +1 -1
  168. package/data/models/example-generator-api.json +8 -8
  169. package/package.json +3 -2
  170. package/src/data/{JmesparthReader.ts → JmespathReader.ts} +2 -2
  171. package/src/data/RequestDataExtractor.ts +5 -5
  172. package/src/data/XmlReader.ts +16 -2
  173. package/src/models/ClientCertificate.ts +9 -0
  174. package/src/models/Environment.ts +11 -7
  175. package/src/models/ErrorResponse.ts +1 -1
  176. package/src/models/HttpRequest.ts +4 -14
  177. package/src/models/HttpResponse.ts +5 -11
  178. package/src/models/ProjectRequest.ts +54 -0
  179. package/src/models/Request.ts +23 -4
  180. package/src/models/RequestAuthorization.ts +1 -1
  181. package/src/models/RequestLog.ts +21 -1
  182. package/src/models/SerializablePayload.ts +18 -1
  183. package/src/models/http-actions/AssertionError.ts +57 -0
  184. package/src/models/http-actions/HttpAssertion.ts +89 -0
  185. package/src/models/http-actions/HttpFlows.ts +115 -0
  186. package/src/models/http-actions/HttpStep.ts +50 -0
  187. package/src/models/http-actions/LegacyTranslator.ts +42 -30
  188. package/src/models/http-actions/steps/assertion/EqualAssertion.ts +130 -0
  189. package/src/models/http-actions/steps/assertion/GreaterThanAssertion.ts +87 -0
  190. package/src/models/http-actions/steps/assertion/IncludesAssertion.ts +68 -0
  191. package/src/models/http-actions/steps/assertion/IsEmptyAssertion.ts +41 -0
  192. package/src/models/http-actions/steps/assertion/IsNotEmptyAssertion.ts +41 -0
  193. package/src/models/http-actions/steps/assertion/LengthOfAssertion.ts +68 -0
  194. package/src/models/http-actions/steps/assertion/LessThanAssertion.ts +87 -0
  195. package/src/models/http-actions/steps/assertion/MatchesAssertion.ts +68 -0
  196. package/src/models/http-actions/steps/assertion/MatchesSchemaAssertion.ts +85 -0
  197. package/src/models/http-actions/steps/assertion/NotEqualAssertion.ts +130 -0
  198. package/src/models/http-actions/steps/assertion/NotIncludesAssertion.ts +68 -0
  199. package/src/models/http-actions/steps/assertion/NotOkAssertion.ts +41 -0
  200. package/src/models/http-actions/steps/assertion/NotToBeAssertion.ts +69 -0
  201. package/src/models/http-actions/steps/assertion/OkAssertion.ts +41 -0
  202. package/src/models/http-actions/steps/assertion/ToBeAssertion.ts +76 -0
  203. package/src/models/http-actions/steps/data/DeleteCookieStep.ts +102 -0
  204. package/src/models/http-actions/steps/data/ReadDataSourceStep.ts +103 -0
  205. package/src/models/http-actions/steps/data/ReadDataStep.ts +128 -0
  206. package/src/models/http-actions/steps/data/ReadValueStep.ts +88 -0
  207. package/src/models/http-actions/steps/data/SetCookieStep.ts +206 -0
  208. package/src/models/http-actions/steps/data/SetDataStep.ts +124 -0
  209. package/src/models/http-actions/steps/data/SetVariableStep.ts +82 -0
  210. package/src/models/http-actions/steps/transformation/AsLowerCaseStep.ts +41 -0
  211. package/src/models/http-actions/steps/transformation/AsNumberStep.ts +41 -0
  212. package/src/models/http-actions/steps/transformation/AsUpperCaseStep.ts +41 -0
  213. package/src/models/http-actions/steps/transformation/RoundStep.ts +86 -0
  214. package/src/models/http-actions/steps/transformation/SubstringStep.ts +93 -0
  215. package/src/models/http-actions/steps/transformation/TrimStep.ts +43 -0
  216. package/src/proxy/RequestProxy.ts +11 -3
  217. package/src/runtime/http-runner/ConditionCheck.ts +13 -14
  218. package/src/runtime/http-runner/HttpAssertionRunner.ts +540 -0
  219. package/src/runtime/http-runner/HttpFlowRunner.ts +33 -19
  220. package/src/runtime/http-runner/HttpRequestRunner.ts +53 -5
  221. package/src/runtime/node/ProjectParallelRunner.ts +4 -4
  222. package/src/runtime/node/ProjectRequestRunner.ts +6 -2
  223. package/src/runtime/store/FilesSdk.ts +1 -1
  224. package/build/src/data/JmesparthReader.js.map +0 -1
  225. package/build/src/models/http-actions/HttpActions.d.ts +0 -256
  226. package/build/src/models/http-actions/HttpActions.js +0 -46
  227. package/build/src/models/http-actions/HttpActions.js.map +0 -1
  228. package/src/models/http-actions/HttpActions.ts +0 -270
@@ -3,7 +3,7 @@ import { IHttpRequest, HttpRequest } from '../models/HttpRequest.js';
3
3
  import { ISentRequest, SentRequest } from '../models/SentRequest.js';
4
4
  import { IHttpResponse, HttpResponse } from '../models/HttpResponse.js';
5
5
  import { IErrorResponse, ErrorResponse } from '../models/ErrorResponse.js';
6
- import { ActionRequestDataEnum, ActionResponseDataEnum, ActionSourceEnum } from '../models/http-actions/HttpActions.js';
6
+ import { FlowRequestDataEnum, FlowResponseDataEnum, FlowSourceEnum } from '../models/http-actions/HttpFlows.js';
7
7
  import { Headers } from '../lib/headers/Headers.js';
8
8
  import { JsonReader } from './JsonReader.js';
9
9
  import { XmlReader } from './XmlReader.js';
@@ -43,7 +43,7 @@ export class RequestDataExtractor {
43
43
  * @param path The path to the data.
44
44
  * @return Data to be processed
45
45
  */
46
- async extract(source: ActionSourceEnum, data?: ActionRequestDataEnum | ActionResponseDataEnum, path?: string): Promise<string | number | undefined> {
46
+ async extract(source: FlowSourceEnum, data?: FlowRequestDataEnum | FlowResponseDataEnum, path?: string): Promise<string | number | undefined> {
47
47
  const args = path ? path.split('.') : [];
48
48
  switch (data) {
49
49
  case 'url':
@@ -73,14 +73,14 @@ export class RequestDataExtractor {
73
73
  * @param source The source name
74
74
  * @returns The headers from the request / response
75
75
  */
76
- getHeaders(source?: ActionSourceEnum): string {
76
+ getHeaders(source?: FlowSourceEnum): string {
77
77
  if (source === 'request') {
78
78
  return this.request.headers || '';
79
79
  }
80
80
  return this.response && this.response.headers || '';
81
81
  }
82
82
 
83
- async processBody(path?: string, source?: ActionSourceEnum): Promise<string | undefined> {
83
+ async processBody(path?: string, source?: FlowSourceEnum): Promise<string | undefined> {
84
84
  const value = await this.getBody(source);
85
85
  if (!value) {
86
86
  return undefined;
@@ -104,7 +104,7 @@ export class RequestDataExtractor {
104
104
  * @param source The source name
105
105
  * @returns The headers from the request / response
106
106
  */
107
- async getBody(source?: ActionSourceEnum): Promise<string | undefined> {
107
+ async getBody(source?: FlowSourceEnum): Promise<string | undefined> {
108
108
  if (source === 'request') {
109
109
  return this.request.readPayloadAsString();
110
110
  }
@@ -38,7 +38,7 @@ export class XmlReader extends DataReader {
38
38
  }
39
39
 
40
40
  processNodeResult(result: XPathResult): unknown {
41
- const results: any[] = [];
41
+ const results: unknown[] = [];
42
42
  let next = result.iterateNext();
43
43
  while (next) {
44
44
  const value = next.textContent;
@@ -50,7 +50,21 @@ export class XmlReader extends DataReader {
50
50
  if (!results.length) {
51
51
  return undefined;
52
52
  }
53
- return results.length === 1 ? results[0] : results;
53
+
54
+ const mapped = results.map((item) => {
55
+ if (item === 'true') {
56
+ return true;
57
+ }
58
+ if (item === 'true') {
59
+ return false;
60
+ }
61
+ const typedNumber = Number(item);
62
+ if (!Number.isNaN(typedNumber)) {
63
+ return typedNumber;
64
+ }
65
+ return item;
66
+ });
67
+ return mapped.length === 1 ? mapped[0] : mapped;
54
68
  }
55
69
 
56
70
  async getDocument(): Promise<Document|undefined> {
@@ -73,6 +73,9 @@ export interface IPemCertificate extends ICertificate {
73
73
 
74
74
  export type HttpCertificate = IP12Certificate | IPemCertificate | ICertificate;
75
75
 
76
+ /**
77
+ * @deprecated Do not use this type anymore. Create a cert instance instead.
78
+ */
76
79
  export interface IPemCreateOptions {
77
80
  type: 'p12';
78
81
  /**
@@ -93,6 +96,9 @@ export interface IPemCreateOptions {
93
96
  passphrase?: string;
94
97
  }
95
98
 
99
+ /**
100
+ * @deprecated Do not use this type anymore. Create a cert instance instead.
101
+ */
96
102
  export interface IP12CreateOptions {
97
103
  type: 'pem';
98
104
  /**
@@ -109,6 +115,9 @@ export interface IP12CreateOptions {
109
115
  passphrase?: string;
110
116
  }
111
117
 
118
+ /**
119
+ * @deprecated Do not use this type anymore. Create a cert instance instead.
120
+ */
112
121
  export type ICertificateCreateOptions = IPemCreateOptions | IP12CreateOptions;
113
122
 
114
123
  /**
@@ -3,6 +3,7 @@ import { Server, IServer } from './Server.js';
3
3
  import { IThing, Thing, Kind as ThingKind } from './Thing.js';
4
4
  import v4 from '../lib/uuid.js';
5
5
  import { ARCVariable } from './legacy/models/Variable.js';
6
+ import { IRequestAuthorization, RequestAuthorization } from './RequestAuthorization.js';
6
7
 
7
8
  export const Kind = 'Core#Environment';
8
9
 
@@ -46,7 +47,7 @@ export interface IEnvironment {
46
47
  /**
47
48
  * The security to be applied to all requests that are going to this environment.
48
49
  */
49
- security?: unknown;
50
+ authorization?: IRequestAuthorization[];
50
51
  }
51
52
 
52
53
  /**
@@ -82,7 +83,7 @@ export class Environment {
82
83
  /**
83
84
  * The security to be applied to all requests that are going to this server.
84
85
  */
85
- security?: unknown;
86
+ authorization?: RequestAuthorization[];
86
87
 
87
88
  /**
88
89
  * Creates a new Environment object from a name.
@@ -151,11 +152,15 @@ export class Environment {
151
152
  if (!Environment.isEnvironment(init)) {
152
153
  throw new Error(`Not an environment.`);
153
154
  }
154
- const { key = v4(), variables, info, server, encapsulated = false, security } = init;
155
+ const { key = v4(), variables, info, server, encapsulated = false, authorization } = init;
155
156
  this.kind = Kind;
156
157
  this.key = key;
157
158
  this.encapsulated = encapsulated;
158
- this.security = security;
159
+ if (Array.isArray(authorization)) {
160
+ this.authorization = authorization.map(i => new RequestAuthorization(i));
161
+ } else {
162
+ this.authorization = undefined;
163
+ }
159
164
  if (Array.isArray(variables)) {
160
165
  this.variables = variables.map(i => new Property(i))
161
166
  } else {
@@ -196,9 +201,8 @@ export class Environment {
196
201
  if (server) {
197
202
  result.server = server.toJSON();
198
203
  }
199
- if (this.security) {
200
- // TODO: When this is defined then call toJSON().
201
- result.security = this.security;
204
+ if (Array.isArray(this.authorization)) {
205
+ result.authorization = this.authorization.map(i => i.toJSON());
202
206
  }
203
207
  return result;
204
208
  }
@@ -66,7 +66,7 @@ export class ErrorResponse extends HttpResponse {
66
66
  /**
67
67
  * @param input The request definition used to restore the state.
68
68
  */
69
- constructor(input?: string|IErrorResponse) {
69
+ constructor(input?: string | IErrorResponse) {
70
70
  super(input);
71
71
  let init: IErrorResponse;
72
72
  if (typeof input === 'string') {
@@ -1,11 +1,10 @@
1
- import { SerializablePayload, SerializablePayloadOptions } from './SerializablePayload.js';
2
- import { Payload } from '../lib/transformers/PayloadSerializer.js';
1
+ import { ISerializablePayload, SerializablePayload, SerializablePayloadOptions } from './SerializablePayload.js';
3
2
  import { IProperty } from './Property.js';
4
3
  import { HeadersArray } from './HeadersArray.js';
5
4
 
6
5
  export const Kind = 'Core#HttpRequest';
7
6
 
8
- export interface IBaseHttpRequest {
7
+ export interface IBaseHttpRequest extends ISerializablePayload {
9
8
  /**
10
9
  * The request URL
11
10
  */
@@ -19,10 +18,6 @@ export interface IBaseHttpRequest {
19
18
  * HTTP headers string
20
19
  */
21
20
  headers?: string;
22
- /**
23
- * The request payload.
24
- */
25
- payload?: Payload;
26
21
  }
27
22
 
28
23
  /**
@@ -136,8 +131,9 @@ export class HttpRequest extends SerializablePayload {
136
131
  return true;
137
132
  }
138
133
 
139
- toJSON(): IHttpRequest {
134
+ override toJSON(): IHttpRequest {
140
135
  const result: IHttpRequest = {
136
+ ...super.toJSON(),
141
137
  kind: this.kind,
142
138
  url: this.url,
143
139
  method: this.method,
@@ -145,15 +141,9 @@ export class HttpRequest extends SerializablePayload {
145
141
  if (this.headers) {
146
142
  result.headers = this.headers;
147
143
  }
148
- if (this.payload) {
149
- result.payload = this.payload;
150
- }
151
144
  if (this.headersModel) {
152
145
  result.headersModel = this.headersModel.toJSON();
153
146
  }
154
- if (this.payloadOptions) {
155
- result.payloadOptions = { ...this.payloadOptions };
156
- }
157
147
  return result;
158
148
  }
159
149
 
@@ -1,11 +1,11 @@
1
- import { SerializablePayload } from './SerializablePayload.js';
2
- import { Payload, PayloadSerializer } from '../lib/transformers/PayloadSerializer.js';
1
+ import { ISerializablePayload, SerializablePayload } from './SerializablePayload.js';
2
+ import { PayloadSerializer } from '../lib/transformers/PayloadSerializer.js';
3
3
  import { HTTPResponse as LegacyHttpResponse } from './legacy/request/ArcResponse.js';
4
4
  import { Normalizer } from './legacy/Normalizer.js';
5
5
 
6
6
  export const Kind = 'Core#HttpResponse';
7
7
 
8
- export interface IHttpResponse {
8
+ export interface IHttpResponse extends ISerializablePayload {
9
9
  kind?: string;
10
10
  /**
11
11
  * The response status code
@@ -19,10 +19,6 @@ export interface IHttpResponse {
19
19
  * The response headers
20
20
  */
21
21
  headers?: string;
22
- /**
23
- * The response message
24
- */
25
- payload?: Payload;
26
22
  }
27
23
 
28
24
  export class HttpResponse extends SerializablePayload {
@@ -116,8 +112,9 @@ export class HttpResponse extends SerializablePayload {
116
112
  return true;
117
113
  }
118
114
 
119
- toJSON(): IHttpResponse {
115
+ override toJSON(): IHttpResponse {
120
116
  const result: IHttpResponse = {
117
+ ...super.toJSON(),
121
118
  kind: this.kind,
122
119
  status: this.status,
123
120
  };
@@ -127,9 +124,6 @@ export class HttpResponse extends SerializablePayload {
127
124
  if (this.headers) {
128
125
  result.headers = this.headers;
129
126
  }
130
- if (this.payload) {
131
- result.payload = this.payload;
132
- }
133
127
  return result;
134
128
  }
135
129
 
@@ -9,6 +9,7 @@ import { Environment } from './Environment.js';
9
9
  import { Property } from './Property.js';
10
10
  import { Server } from './Server.js';
11
11
  import { UriTemplate } from '../lib/parsers/UriTemplate.js';
12
+ import { RequestAuthorization } from './RequestAuthorization.js';
12
13
 
13
14
  export const Kind = 'Core#ProjectRequest';
14
15
 
@@ -485,4 +486,57 @@ export class ProjectRequest extends Request implements ProjectDefinitionProperty
485
486
  }
486
487
  return result;
487
488
  }
489
+
490
+ /**
491
+ * Reads the authorization that should be applied to the request.
492
+ *
493
+ * 1) First it returns the locally (on the request) defined authorization.
494
+ * 2) Then it returns authorization defined on the selected environment.
495
+ * 3) If has defined environment but no authorization on it, then it returns empty array.
496
+ * 4) Only if the request has no selected environment then it reads first environment
497
+ * that has authorization (from the request up to the project's root).
498
+ */
499
+ readAuthorization(): RequestAuthorization[] {
500
+ if (Array.isArray(this.authorization) && this.authorization.length) {
501
+ return this.authorization;
502
+ }
503
+ const envAuth = this.readEnvironmentAuthorization();
504
+ if (envAuth) {
505
+ return envAuth;
506
+ }
507
+ if (this.environment) {
508
+ return [];
509
+ }
510
+ const inherited = this.readEnvironmentsAuthorization();
511
+ if (inherited) {
512
+ return inherited;
513
+ }
514
+ return [];
515
+ }
516
+
517
+ /**
518
+ * @returns Authorization defined on the selected environment or undefined.
519
+ */
520
+ protected readEnvironmentAuthorization(): RequestAuthorization[] | undefined {
521
+ const selfEnv = this.getEnvironment();
522
+ if (!selfEnv) {
523
+ return undefined;
524
+ }
525
+ if (Array.isArray(selfEnv.authorization) && selfEnv.authorization.length) {
526
+ return selfEnv.authorization;
527
+ }
528
+ return undefined;
529
+ }
530
+
531
+ /**
532
+ * @returns Authorization defined on any inherited environment or undefined.
533
+ */
534
+ protected readEnvironmentsAuthorization(): RequestAuthorization[] | undefined {
535
+ const envs = this.readEnvironments();
536
+ const authEnv = envs.find(i => Array.isArray(i.authorization) && !!i.authorization.length);
537
+ if (authEnv) {
538
+ return authEnv.authorization as RequestAuthorization[];
539
+ }
540
+ return undefined;
541
+ }
488
542
  }
@@ -13,7 +13,8 @@ import { ARCSavedRequest, ARCHistoryRequest } from './legacy/request/ArcRequest.
13
13
  import { ErrorResponse as LegacyErrorResponse, Response as LegacyResponse } from './legacy/request/ArcResponse.js';
14
14
  import { PayloadSerializer } from '../lib/transformers/PayloadSerializer.js';
15
15
  import { Normalizer } from './legacy/Normalizer.js';
16
- import { IHttpActionFlow } from './http-actions/HttpActions.js';
16
+ import { IHttpFlow } from './http-actions/HttpFlows.js';
17
+ import { IHttpAssertion } from './http-actions/HttpAssertion.js';
17
18
  import { LegacyTranslator } from './http-actions/LegacyTranslator.js';
18
19
 
19
20
  export const Kind = 'Core#Request';
@@ -63,7 +64,7 @@ export interface IRequest {
63
64
  * Http action flows.
64
65
  * In ARC this was "actions",
65
66
  */
66
- flows?: IHttpActionFlow[];
67
+ flows?: IHttpFlow[];
67
68
  /**
68
69
  * The certificate to use with the request.
69
70
  * Note, the certificate defined on the certificate authorization
@@ -71,6 +72,11 @@ export interface IRequest {
71
72
  * this certificate and update the configuration.
72
73
  */
73
74
  clientCertificate?: HttpCertificate;
75
+
76
+ /**
77
+ * The list of assertions (tests) to perform after the response is ready.
78
+ */
79
+ assertions?: IHttpAssertion[];
74
80
  }
75
81
 
76
82
  export class Request {
@@ -102,7 +108,7 @@ export class Request {
102
108
  * Http action flows.
103
109
  * In ARC this was "actions",
104
110
  */
105
- flows?: IHttpActionFlow[];
111
+ flows?: IHttpFlow[];
106
112
  /**
107
113
  * The certificate to use with the request.
108
114
  * Note, the certificate defined on the certificate authorization
@@ -111,6 +117,11 @@ export class Request {
111
117
  */
112
118
  clientCertificate?: Certificate;
113
119
 
120
+ /**
121
+ * The list of assertions (tests) to perform after the response is ready.
122
+ */
123
+ assertions?: IHttpAssertion[];
124
+
114
125
  /**
115
126
  * Creates a request from an URL.
116
127
  *
@@ -340,7 +351,7 @@ export class Request {
340
351
  }
341
352
 
342
353
  new(init: IRequest): void {
343
- const { expects, log, updated, created = Date.now(), midnight, config, authorization, flows, clientCertificate, info } = init;
354
+ const { expects, log, updated, created = Date.now(), midnight, config, authorization, flows, clientCertificate, info, assertions } = init;
344
355
  if (expects) {
345
356
  this.expects = new HttpRequest(expects);
346
357
  } else {
@@ -383,6 +394,11 @@ export class Request {
383
394
  } else {
384
395
  this.flows = undefined;
385
396
  }
397
+ if (Array.isArray(assertions)) {
398
+ this.assertions = assertions.map(i => JsonCore.clone(i));
399
+ } else {
400
+ this.assertions = undefined;
401
+ }
386
402
  if (clientCertificate) {
387
403
  this.clientCertificate = new Certificate(clientCertificate);
388
404
  } else {
@@ -411,6 +427,9 @@ export class Request {
411
427
  if (Array.isArray(this.flows)) {
412
428
  result.flows = this.flows.map(i => JsonCore.clone(i))
413
429
  }
430
+ if (Array.isArray(this.assertions)) {
431
+ result.assertions = this.assertions.map(i => JsonCore.clone(i))
432
+ }
414
433
  if (this.clientCertificate) {
415
434
  result.clientCertificate = this.clientCertificate.toJSON();
416
435
  }
@@ -64,7 +64,7 @@ export class RequestAuthorization {
64
64
  }
65
65
  return new RequestAuthorization({
66
66
  kind: Kind,
67
- config: (info.config as any),
67
+ config: info.config as IAuthorizationSettingsUnion,
68
68
  enabled: true,
69
69
  type: info.type as AuthorizationType,
70
70
  valid: info.valid,
@@ -4,6 +4,7 @@ import { IErrorResponse, ErrorResponse } from './ErrorResponse.js';
4
4
  import { IResponse, Response } from './Response.js';
5
5
  import { IRequestsSize, RequestsSize } from './RequestsSize.js';
6
6
  import { ResponseRedirect as LegacyRedirect } from './legacy/request/ArcResponse.js';
7
+ import { AssertionResult } from './http-actions/HttpAssertion.js';
7
8
 
8
9
  export const Kind = 'Core#ResponseLog';
9
10
 
@@ -32,6 +33,11 @@ export interface IRequestLog {
32
33
  * Optional request ID defined on an HTTP project that triggered this log.
33
34
  */
34
35
  requestId?: string;
36
+ /**
37
+ * The assertions result performed on the response.
38
+ * Note, Error response can also be passed through tests.
39
+ */
40
+ assertions?: AssertionResult[];
35
41
  }
36
42
 
37
43
  /**
@@ -60,6 +66,12 @@ export class RequestLog {
60
66
  */
61
67
  requestId?: string;
62
68
 
69
+ /**
70
+ * The assertions result performed on the response.
71
+ * Note, Error response can also be passed through tests.
72
+ */
73
+ assertions?: AssertionResult[];
74
+
63
75
  static fromRequest(request: ISentRequest): RequestLog {
64
76
  return new RequestLog({
65
77
  kind: Kind,
@@ -96,7 +108,7 @@ export class RequestLog {
96
108
  * Creates a new response clearing anything that is so far defined.
97
109
  */
98
110
  new(init: IRequestLog): void {
99
- const { request, response, redirects, size, requestId } = init;
111
+ const { request, response, redirects, size, requestId, assertions } = init;
100
112
  this.kind = Kind;
101
113
  if (request) {
102
114
  this.request = new SentRequest(request);
@@ -125,6 +137,11 @@ export class RequestLog {
125
137
  } else {
126
138
  this.requestId = undefined;
127
139
  }
140
+ if (Array.isArray(assertions) && assertions.length) {
141
+ this.assertions = assertions.map(i => ({ ...i }));
142
+ } else {
143
+ this.assertions = undefined;
144
+ }
128
145
  }
129
146
 
130
147
  toJSON(): IRequestLog {
@@ -146,6 +163,9 @@ export class RequestLog {
146
163
  if (this.requestId) {
147
164
  result.requestId = this.requestId;
148
165
  }
166
+ if (Array.isArray(this.assertions) && this.assertions.length) {
167
+ result.assertions = this.assertions.map(i => ({ ...i }));
168
+ }
149
169
  return result;
150
170
  }
151
171
 
@@ -14,7 +14,7 @@ export interface SerializablePayloadOptions {
14
14
  mime?: string;
15
15
  }
16
16
 
17
- export class SerializablePayload {
17
+ export interface ISerializablePayload {
18
18
  /**
19
19
  * The serialized payload message.
20
20
  */
@@ -24,6 +24,12 @@ export class SerializablePayload {
24
24
  * Optional meta of the payload
25
25
  */
26
26
  payloadOptions?: SerializablePayloadOptions;
27
+ }
28
+
29
+ export class SerializablePayload implements ISerializablePayload {
30
+ payload?: Payload;
31
+
32
+ payloadOptions?: SerializablePayloadOptions;
27
33
 
28
34
  /**
29
35
  * The payload in its original format.
@@ -90,4 +96,15 @@ export class SerializablePayload {
90
96
  const decoder = new TextDecoder();
91
97
  return decoder.decode(dataView);
92
98
  }
99
+
100
+ toJSON(): ISerializablePayload {
101
+ const result: ISerializablePayload = {};
102
+ if (this.payload) {
103
+ result.payload = this.payload;
104
+ }
105
+ if (this.payloadOptions) {
106
+ result.payloadOptions = { ...this.payloadOptions };
107
+ }
108
+ return result;
109
+ }
93
110
  }
@@ -0,0 +1,57 @@
1
+ export interface IAssertionError {
2
+ /**
3
+ * Set with assertions to show the actual value at the time of testing.
4
+ */
5
+ actual?: unknown;
6
+ /**
7
+ * Set with assertions to show the expected value at the time of testing.
8
+ */
9
+ expected?: unknown;
10
+ /**
11
+ * The operator used to make the assertion.
12
+ */
13
+ operator?: string;
14
+ /**
15
+ * The error message, if any.
16
+ * Assertions usually don't set error messages. Instead they set other fields.
17
+ */
18
+ message?: string;
19
+ }
20
+
21
+ export class AssertionError extends Error {
22
+ /**
23
+ * Set with assertions to show the actual value at the time of testing.
24
+ */
25
+ actual: unknown;
26
+ /**
27
+ * Set with assertions to show the expected value at the time of testing.
28
+ */
29
+ expected: unknown;
30
+ /**
31
+ * The operator used to make the assertion.
32
+ */
33
+ operator: string;
34
+
35
+ code = 'ERR_ASSERTION';
36
+
37
+ constructor(options: IAssertionError = {}) {
38
+ super(options.message || 'Unspecified AssertionError');
39
+ this.name = 'AssertionError';
40
+ this.actual = options.actual;
41
+ this.expected = options.expected;
42
+ this.operator = options.operator || '[unknown]';
43
+ }
44
+
45
+ toJSON(): IAssertionError {
46
+ const result: IAssertionError = {};
47
+ if (this.message) {
48
+ result.message = this.message;
49
+ }
50
+ result.actual = this.actual;
51
+ result.expected = this.expected;
52
+ if (this.operator) {
53
+ result.operator = this.operator;
54
+ }
55
+ return result;
56
+ }
57
+ }
@@ -0,0 +1,89 @@
1
+ import { IAssertionError } from "./AssertionError.js";
2
+ import { IHttpStep } from "./HttpStep.js";
3
+
4
+ export enum AssertionEnum {
5
+ equal = "equal",
6
+ notEqual = "not-equal",
7
+ greaterThan = "greater-than",
8
+ greaterThanEqual = "greater-than-equal",
9
+ lessThan = "less-than",
10
+ lessThanEqual = "less-than-equal",
11
+ contains = "contains",
12
+ regex = "regex",
13
+ ok = 'ok',
14
+ notOk = 'notOk',
15
+ toBe = 'toBe',
16
+ notToBe = 'notToBe',
17
+ }
18
+
19
+ export enum TransformationEnum {
20
+ /**
21
+ * Transformation of the data that reads a value from the given path.
22
+ * For example, for a body it can be xpath for XML or JSON path for JSON data.
23
+ */
24
+ readValue = 'readValue',
25
+ /**
26
+ * Transforms the value from the previous step to a number.
27
+ */
28
+ asNumber = 'asNumber',
29
+ /**
30
+ * Rounds the input value to a nearest numeric value.
31
+ * If the value is not a number it tries to convert it to a number. When it
32
+ * can't ba casted to a number then the transformation throws an error.
33
+ */
34
+ round = 'round',
35
+ /**
36
+ * Transforms the value to a lowercase value.
37
+ */
38
+ toLowerCase = 'toLowerCase',
39
+ /**
40
+ * Transforms the value to a uppercase value.
41
+ */
42
+ toUpperCase = 'toUpperCase',
43
+ /**
44
+ * Trims the string value.
45
+ */
46
+ trim = 'trim',
47
+ /**
48
+ * Transforms the part of the string from the start index up to and excluding the end index, or to the end of the string if no end index is supplied.
49
+ *
50
+ * `substring(indexStart, indexEnd)`
51
+ */
52
+ substring = 'substring',
53
+ }
54
+
55
+ export interface IHttpAssertion {
56
+ /**
57
+ * The description of the assertion reported to the UI.
58
+ */
59
+ description?: string;
60
+
61
+ /**
62
+ * The list of steps to perform. This is an ordered list of action tasks.
63
+ * Each step is described by the `kind` property which tells the runner what action to perform.
64
+ */
65
+ steps: IHttpStep[];
66
+ /**
67
+ * Whether the assertions is enabled. By default it is enabled. It is only not enabled when this is set to false.
68
+ */
69
+ enabled?: boolean;
70
+ }
71
+
72
+ /**
73
+ * An object representing a result of running a single assertion.
74
+ */
75
+ export interface AssertionResult {
76
+ /**
77
+ * Indicates whether assertion result is positive (not failed) or negative (failed).
78
+ */
79
+ ok: boolean;
80
+ /**
81
+ * The description of the association.
82
+ */
83
+ description: string;
84
+ /**
85
+ * This is always set when `ok` is false.
86
+ * This is also never set when `ok` is true.
87
+ */
88
+ error?: IAssertionError;
89
+ }