@api-client/core 0.3.3 → 0.3.4

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 (176) hide show
  1. package/package.json +1 -1
  2. package/src/data/DataReader.ts +11 -0
  3. package/src/data/DataUtils.ts +108 -0
  4. package/src/data/JmesparthReader.ts +26 -0
  5. package/src/data/Json2Xml.ts +190 -0
  6. package/src/data/JsonReader.ts +41 -0
  7. package/src/data/PayloadPointer.ts +48 -0
  8. package/src/data/RequestDataExtractor.ts +133 -0
  9. package/src/data/UrlEncodedReader.ts +20 -0
  10. package/src/data/XmlReader.ts +103 -0
  11. package/src/events/BaseEvents.ts +259 -0
  12. package/src/events/CustomEvent.ts +27 -0
  13. package/src/events/EventTypes.ts +19 -0
  14. package/src/events/Events.ts +19 -0
  15. package/src/events/authorization/AuthorizationEventTypes.ts +22 -0
  16. package/src/events/authorization/AuthorizationEvents.ts +61 -0
  17. package/src/events/cookies/CookieEventTypes.ts +13 -0
  18. package/src/events/cookies/CookieEvents.ts +157 -0
  19. package/src/events/encryption/EncryptionEventTypes.ts +4 -0
  20. package/src/events/encryption/EncryptionEvents.ts +51 -0
  21. package/src/events/environment/EnvironmentEventTypes.ts +3 -0
  22. package/src/events/environment/EnvironmentEvents.ts +24 -0
  23. package/src/events/models/ClientCertificateEvents.ts +87 -0
  24. package/src/events/models/ModelEventTypes.ts +47 -0
  25. package/src/events/models/ModelEvents.ts +7 -0
  26. package/src/events/models/ProjectEvents.ts +331 -0
  27. package/src/events/process/ProcessEventTypes.ts +5 -0
  28. package/src/events/process/ProcessEvents.ts +76 -0
  29. package/src/events/readme.md +22 -0
  30. package/src/events/reporting/ReportingEventTypes.ts +3 -0
  31. package/src/events/reporting/ReportingEvents.ts +28 -0
  32. package/src/events/telemetry/TelemetryEventTypes.ts +10 -0
  33. package/src/events/telemetry/TelemetryEvents.ts +156 -0
  34. package/src/lib/cookies/Cookie.ts +312 -0
  35. package/src/lib/cookies/Cookies.ts +326 -0
  36. package/src/lib/cookies/Utils.ts +168 -0
  37. package/src/lib/headers/Headers.ts +219 -0
  38. package/src/lib/logging/DefaultLogger.ts +19 -0
  39. package/src/lib/logging/DummyLogger.ts +21 -0
  40. package/src/lib/logging/Logger.ts +16 -0
  41. package/src/lib/transformers/PayloadSerializer.ts +332 -0
  42. package/src/lib/transformers/Utils.ts +18 -0
  43. package/src/lib/uuid.ts +40 -0
  44. package/src/mocking/LegacyInterfaces.ts +52 -0
  45. package/src/mocking/LegacyMock.ts +37 -0
  46. package/src/mocking/legacy/Authorization.ts +39 -0
  47. package/src/mocking/legacy/Certificates.ts +145 -0
  48. package/src/mocking/legacy/Cookies.ts +51 -0
  49. package/src/mocking/legacy/HostRules.ts +43 -0
  50. package/src/mocking/legacy/Http.ts +236 -0
  51. package/src/mocking/legacy/HttpResponse.ts +106 -0
  52. package/src/mocking/legacy/RestApi.ts +68 -0
  53. package/src/mocking/legacy/Urls.ts +44 -0
  54. package/src/mocking/legacy/Variables.ts +53 -0
  55. package/src/models/ArcResponse.ts +166 -0
  56. package/src/models/Authorization.ts +481 -0
  57. package/src/models/AuthorizationData.ts +60 -0
  58. package/src/models/Backend.ts +107 -0
  59. package/src/models/ClientCertificate.ts +68 -0
  60. package/src/models/Environment.ts +279 -0
  61. package/src/models/ErrorResponse.ts +101 -0
  62. package/src/models/HistoryIndex.ts +76 -0
  63. package/src/models/HistoryRequest.ts +28 -0
  64. package/src/models/HostRule.ts +163 -0
  65. package/src/models/HttpCookie.ts +285 -0
  66. package/src/models/HttpProject.ts +1294 -0
  67. package/src/models/HttpProjectListItem.ts +23 -0
  68. package/src/models/HttpRequest.ts +124 -0
  69. package/src/models/HttpResponse.ts +143 -0
  70. package/src/models/License.ts +113 -0
  71. package/src/models/ProjectDefinitionProperty.ts +40 -0
  72. package/src/models/ProjectFolder.ts +439 -0
  73. package/src/models/ProjectItem.ts +135 -0
  74. package/src/models/ProjectParent.ts +113 -0
  75. package/src/models/ProjectRequest.ts +277 -0
  76. package/src/models/ProjectSchema.ts +202 -0
  77. package/src/models/Property.ts +423 -0
  78. package/src/models/Provider.ts +98 -0
  79. package/src/models/README.md +20 -0
  80. package/src/models/Request.ts +452 -0
  81. package/src/models/RequestActions.ts +163 -0
  82. package/src/models/RequestAuthorization.ts +115 -0
  83. package/src/models/RequestConfig.ts +317 -0
  84. package/src/models/RequestLog.ts +159 -0
  85. package/src/models/RequestTime.ts +108 -0
  86. package/src/models/RequestUiMeta.ts +258 -0
  87. package/src/models/RequestsSize.ts +65 -0
  88. package/src/models/ResponseAuthorization.ts +104 -0
  89. package/src/models/ResponseRedirect.ts +158 -0
  90. package/src/models/RevisionInfo.ts +37 -0
  91. package/src/models/SentRequest.ts +125 -0
  92. package/src/models/SerializablePayload.ts +68 -0
  93. package/src/models/Server.ts +153 -0
  94. package/src/models/Thing.ts +110 -0
  95. package/src/models/Url.ts +90 -0
  96. package/src/models/User.ts +120 -0
  97. package/src/models/WebApi.ts +234 -0
  98. package/src/models/WebApiIndex.ts +122 -0
  99. package/src/models/Workspace.ts +182 -0
  100. package/src/models/actions/Action.ts +213 -0
  101. package/src/models/actions/ActionView.ts +40 -0
  102. package/src/models/actions/Condition.ts +207 -0
  103. package/src/models/actions/ConditionView.ts +42 -0
  104. package/src/models/actions/Enums.ts +29 -0
  105. package/src/models/actions/RunnableAction.ts +144 -0
  106. package/src/models/actions/runnable/DeleteCookieAction.ts +113 -0
  107. package/src/models/actions/runnable/Runnable.ts +9 -0
  108. package/src/models/actions/runnable/SetCookieAction.ts +216 -0
  109. package/src/models/actions/runnable/SetVariableAction.ts +81 -0
  110. package/src/models/legacy/DataExport.ts +172 -0
  111. package/src/models/legacy/Normalizer.ts +110 -0
  112. package/src/models/legacy/actions/Actions.ts +269 -0
  113. package/src/models/legacy/authorization/Authorization.ts +572 -0
  114. package/src/models/legacy/models/ApiTypes.ts +202 -0
  115. package/src/models/legacy/models/ArcLegacyProject.ts +39 -0
  116. package/src/models/legacy/models/AuthData.ts +17 -0
  117. package/src/models/legacy/models/ClientCertificate.ts +95 -0
  118. package/src/models/legacy/models/Cookies.ts +52 -0
  119. package/src/models/legacy/models/HostRule.ts +35 -0
  120. package/src/models/legacy/models/RestApi.ts +49 -0
  121. package/src/models/legacy/models/UrlHistory.ts +37 -0
  122. package/src/models/legacy/models/Variable.ts +43 -0
  123. package/src/models/legacy/models/base.d.ts +95 -0
  124. package/src/models/legacy/request/ArcRequest.ts +405 -0
  125. package/src/models/legacy/request/ArcResponse.ts +177 -0
  126. package/src/models/legacy/request/HistoryData.ts +47 -0
  127. package/src/models/legacy/request/Legacy.ts +45 -0
  128. package/src/models/legacy/request/RequestBody.ts +87 -0
  129. package/src/models/transformers/ArcDexieTransformer.ts +323 -0
  130. package/src/models/transformers/ArcLegacyNormalizer.ts +85 -0
  131. package/src/models/transformers/ArcLegacyTransformer.ts +200 -0
  132. package/src/models/transformers/ArcPouchTransformer.ts +184 -0
  133. package/src/models/transformers/BaseTransformer.ts +116 -0
  134. package/src/models/transformers/ImportUtils.ts +141 -0
  135. package/src/models/transformers/LegacyDataExportToApiProject.ts +76 -0
  136. package/src/models/transformers/LegacyExportProcessor.ts +252 -0
  137. package/src/models/transformers/PostmanBackupTransformer.ts +306 -0
  138. package/src/models/transformers/PostmanDataTransformer.ts +50 -0
  139. package/src/models/transformers/PostmanTransformer.ts +106 -0
  140. package/src/models/transformers/PostmanV21Transformer.ts +311 -0
  141. package/src/models/transformers/PostmanV2Transformer.ts +308 -0
  142. package/src/models/transformers/har.ts +865 -0
  143. package/src/runtime/actions/ActionRunner.ts +83 -0
  144. package/src/runtime/actions/ConditionRunner.ts +194 -0
  145. package/src/runtime/actions/RunnableCondition.ts +57 -0
  146. package/src/runtime/actions/runnable/ActionRunnable.ts +19 -0
  147. package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +39 -0
  148. package/src/runtime/actions/runnable/SetCookieRunnable.ts +92 -0
  149. package/src/runtime/actions/runnable/SetVariableRunnable.ts +53 -0
  150. package/src/runtime/http-engine/ArcEngine.ts +1064 -0
  151. package/src/runtime/http-engine/Errors.ts +13 -0
  152. package/src/runtime/http-engine/FormData.ts +85 -0
  153. package/src/runtime/http-engine/HttpEngine.ts +874 -0
  154. package/src/runtime/http-engine/HttpErrorCodes.ts +270 -0
  155. package/src/runtime/http-engine/NodeEngine.ts +787 -0
  156. package/src/runtime/http-engine/NodeEngineDirect.ts +476 -0
  157. package/src/runtime/http-engine/PayloadSupport.ts +84 -0
  158. package/src/runtime/http-engine/RequestUtils.ts +164 -0
  159. package/src/runtime/http-engine/ntlm/Des.ts +345 -0
  160. package/src/runtime/http-engine/ntlm/MD4.ts +135 -0
  161. package/src/runtime/http-engine/ntlm/NtlmAuth.ts +186 -0
  162. package/src/runtime/http-engine/ntlm/NtlmMessage.ts +57 -0
  163. package/src/runtime/modules/BasicAuthCache.ts +133 -0
  164. package/src/runtime/modules/ExecutionResponse.ts +4 -0
  165. package/src/runtime/modules/ModulesRegistry.ts +136 -0
  166. package/src/runtime/modules/RequestAuthorization.ts +110 -0
  167. package/src/runtime/modules/RequestCookies.ts +145 -0
  168. package/src/runtime/node/ProjectRunner.ts +275 -0
  169. package/src/runtime/node/RequestFactory.ts +422 -0
  170. package/src/runtime/node/VariablesStore.ts +25 -0
  171. package/src/runtime/store/StoreSdk.ts +838 -0
  172. package/src/runtime/variables/Cache.ts +53 -0
  173. package/src/runtime/variables/EvalFunctions.ts +132 -0
  174. package/src/runtime/variables/ProjectVariables.ts +6 -0
  175. package/src/runtime/variables/VariablesProcessor.ts +543 -0
  176. package/src/runtime/variables/VariablesTokenizer.ts +55 -0
@@ -0,0 +1,53 @@
1
+ /**
2
+ * In-memory cache store for evaluated values.
3
+ */
4
+ const cache = new WeakMap();
5
+
6
+ /**
7
+ * Removes cached values from the store.
8
+ * @param target The cache target, element or object extending the mixin
9
+ */
10
+ export function clear(target: object): void {
11
+ if (cache.has(target)) {
12
+ cache.delete(target);
13
+ }
14
+ }
15
+
16
+ /**
17
+ * Finds a cached group.
18
+ *
19
+ * @param target The cache target, element or object extending the mixin
20
+ * @param key A key where a function keeps cached objects
21
+ * @param group Group name. Defined by user as an argument.
22
+ * @return Cached value.
23
+ */
24
+ export function find(target: object, key: string, group: string): string|number|null {
25
+ const value = cache.get(target);
26
+ if (!value) {
27
+ return null;
28
+ }
29
+ if (!value[key]) {
30
+ return null;
31
+ }
32
+ return value[key][group];
33
+ }
34
+
35
+ /**
36
+ * Stores value in cache.
37
+ *
38
+ * @param target The cache target, element or object extending the mixin
39
+ * @param key A key where a function keeps cached objects
40
+ * @param group Group name. Defined by user as an argument.
41
+ * @param value Cached value.
42
+ */
43
+ export function store(target: object, key: string, group: string, value: string|number): void {
44
+ let cacheValue = cache.get(target);
45
+ if (!cacheValue) {
46
+ cacheValue = {};
47
+ cache.set(target, cacheValue);
48
+ }
49
+ if (!cacheValue[key]) {
50
+ cacheValue[key] = {};
51
+ }
52
+ cacheValue[key][group] = value;
53
+ }
@@ -0,0 +1,132 @@
1
+ import { find, store } from './Cache.js';
2
+
3
+ export const hasBuffer: boolean = typeof Buffer === 'function';
4
+
5
+ /**
6
+ * A map of functions that evaluates values with native functions.
7
+ */
8
+ export class EvalFunctions {
9
+ static [key: string]: (cacheTarget: object, args?: string[]) => string | number;
10
+
11
+ /**
12
+ * Calls `encodeURIComponent()` function on the first item of arguments array
13
+ * @param args List of expression arguments
14
+ * @return Encoded value
15
+ * @throws {Error} When input has no value.
16
+ */
17
+ static EncodeURIComponent(cacheTarget: object, args?: string[]): string {
18
+ const value = args && args[0];
19
+ if (!value) {
20
+ throw new Error('encodeURIComponent() requires a value');
21
+ }
22
+ return encodeURIComponent(value);
23
+ }
24
+
25
+ /**
26
+ * Calls `decodeURIComponent()` function on the first item of arguments array
27
+ * @param args List of expression arguments
28
+ * @return Decoded value
29
+ * @throws {Error} When input has no value.
30
+ */
31
+ static DecodeURIComponent(cacheTarget: object, args?: string[]): string {
32
+ const value = args && args[0];
33
+ if (!value) {
34
+ throw new Error('decodeURIComponent() requires a value');
35
+ }
36
+ return decodeURIComponent(value);
37
+ }
38
+
39
+ /**
40
+ * Calls the `btoa()` function on the first item on the arguments array
41
+ * @param args List of expression arguments
42
+ * @return Decoded value
43
+ * @throws {Error} When input has no value.
44
+ */
45
+ static Btoa(cacheTarget: object, args: string[] = []): string {
46
+ const [value] = args;
47
+ if (!value) {
48
+ throw new Error('btoa() requires a value');
49
+ }
50
+ if (hasBuffer) {
51
+ const b = Buffer.from(value);
52
+ return b.toString('base64');
53
+ }
54
+ return btoa(value);
55
+ }
56
+
57
+ /**
58
+ * Calls the `atob()` function on the first item on the arguments array
59
+ * @param args List of expression arguments
60
+ * @return Decoded value
61
+ * @throws {Error} When input has no value.
62
+ */
63
+ static Atob(cacheTarget: object, args: string[] = []): string {
64
+ const [value] = args;
65
+ if (!value) {
66
+ throw new Error('atob() requires a value');
67
+ }
68
+ if (hasBuffer) {
69
+ const b = Buffer.from(value, 'base64');
70
+ return b.toString('utf8');
71
+ }
72
+ return atob(value);
73
+ }
74
+
75
+ /**
76
+ * Calls the `now()` function. Returns current timestamp.
77
+ * If argument is passed is will try to retrieve existing cached value
78
+ * or create new one.
79
+ *
80
+ * @param args Arguments passed to the function
81
+ * @return Current timestamp
82
+ */
83
+ static Now(cacheTarget: object, args?: string[]): number {
84
+ const key = '__evalFnNow';
85
+ const hasGroup = !!(args && args[0]);
86
+ let value;
87
+ if (hasGroup) {
88
+ value = find(cacheTarget, key, args[0]);
89
+ }
90
+ if (!value) {
91
+ value = Date.now();
92
+ }
93
+ if (hasGroup) {
94
+ store(cacheTarget, key, args[0], value);
95
+ }
96
+ return value as number;
97
+ }
98
+
99
+ /**
100
+ * Generates random integer value. If a group is passed in the `args` then
101
+ * it looks for the value in the cache and prefers it if available.
102
+ *
103
+ * @param args Arguments passed to the function
104
+ * @returns Current timestamp
105
+ */
106
+ static Random(cacheTarget: object, args?: string[]): number {
107
+ const key = '__evalFnRandom';
108
+ const hasGroup = !!(args && args[0]);
109
+ let value;
110
+ if (hasGroup) {
111
+ value = find(cacheTarget, key, args[0]);
112
+ }
113
+ if (!value) {
114
+ value = EvalFunctions.randomInt();
115
+ }
116
+ if (hasGroup) {
117
+ store(cacheTarget, key, args[0], value);
118
+ }
119
+ return value as number;
120
+ }
121
+
122
+ /**
123
+ * Returns a random `int` between 0 (inclusive) and
124
+ * `Number.MAX_SAFE_INTEGER` (exclusive) with roughly equal probability of
125
+ * returning any particular `int` in this range.
126
+ */
127
+ static randomInt(): number {
128
+ // "|0" forces the value to a 32 bit integer.
129
+ // Number.MAX_SAFE_INTEGER
130
+ return Math.abs(Math.floor(Math.random() * 9007199254740991) | 0);
131
+ }
132
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A class that processes values in the request object.
3
+ */
4
+ export class RequestVariables {
5
+
6
+ }