@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.
- package/package.json +1 -1
- package/src/data/DataReader.ts +11 -0
- package/src/data/DataUtils.ts +108 -0
- package/src/data/JmesparthReader.ts +26 -0
- package/src/data/Json2Xml.ts +190 -0
- package/src/data/JsonReader.ts +41 -0
- package/src/data/PayloadPointer.ts +48 -0
- package/src/data/RequestDataExtractor.ts +133 -0
- package/src/data/UrlEncodedReader.ts +20 -0
- package/src/data/XmlReader.ts +103 -0
- package/src/events/BaseEvents.ts +259 -0
- package/src/events/CustomEvent.ts +27 -0
- package/src/events/EventTypes.ts +19 -0
- package/src/events/Events.ts +19 -0
- package/src/events/authorization/AuthorizationEventTypes.ts +22 -0
- package/src/events/authorization/AuthorizationEvents.ts +61 -0
- package/src/events/cookies/CookieEventTypes.ts +13 -0
- package/src/events/cookies/CookieEvents.ts +157 -0
- package/src/events/encryption/EncryptionEventTypes.ts +4 -0
- package/src/events/encryption/EncryptionEvents.ts +51 -0
- package/src/events/environment/EnvironmentEventTypes.ts +3 -0
- package/src/events/environment/EnvironmentEvents.ts +24 -0
- package/src/events/models/ClientCertificateEvents.ts +87 -0
- package/src/events/models/ModelEventTypes.ts +47 -0
- package/src/events/models/ModelEvents.ts +7 -0
- package/src/events/models/ProjectEvents.ts +331 -0
- package/src/events/process/ProcessEventTypes.ts +5 -0
- package/src/events/process/ProcessEvents.ts +76 -0
- package/src/events/readme.md +22 -0
- package/src/events/reporting/ReportingEventTypes.ts +3 -0
- package/src/events/reporting/ReportingEvents.ts +28 -0
- package/src/events/telemetry/TelemetryEventTypes.ts +10 -0
- package/src/events/telemetry/TelemetryEvents.ts +156 -0
- package/src/lib/cookies/Cookie.ts +312 -0
- package/src/lib/cookies/Cookies.ts +326 -0
- package/src/lib/cookies/Utils.ts +168 -0
- package/src/lib/headers/Headers.ts +219 -0
- package/src/lib/logging/DefaultLogger.ts +19 -0
- package/src/lib/logging/DummyLogger.ts +21 -0
- package/src/lib/logging/Logger.ts +16 -0
- package/src/lib/transformers/PayloadSerializer.ts +332 -0
- package/src/lib/transformers/Utils.ts +18 -0
- package/src/lib/uuid.ts +40 -0
- package/src/mocking/LegacyInterfaces.ts +52 -0
- package/src/mocking/LegacyMock.ts +37 -0
- package/src/mocking/legacy/Authorization.ts +39 -0
- package/src/mocking/legacy/Certificates.ts +145 -0
- package/src/mocking/legacy/Cookies.ts +51 -0
- package/src/mocking/legacy/HostRules.ts +43 -0
- package/src/mocking/legacy/Http.ts +236 -0
- package/src/mocking/legacy/HttpResponse.ts +106 -0
- package/src/mocking/legacy/RestApi.ts +68 -0
- package/src/mocking/legacy/Urls.ts +44 -0
- package/src/mocking/legacy/Variables.ts +53 -0
- package/src/models/ArcResponse.ts +166 -0
- package/src/models/Authorization.ts +481 -0
- package/src/models/AuthorizationData.ts +60 -0
- package/src/models/Backend.ts +107 -0
- package/src/models/ClientCertificate.ts +68 -0
- package/src/models/Environment.ts +279 -0
- package/src/models/ErrorResponse.ts +101 -0
- package/src/models/HistoryIndex.ts +76 -0
- package/src/models/HistoryRequest.ts +28 -0
- package/src/models/HostRule.ts +163 -0
- package/src/models/HttpCookie.ts +285 -0
- package/src/models/HttpProject.ts +1294 -0
- package/src/models/HttpProjectListItem.ts +23 -0
- package/src/models/HttpRequest.ts +124 -0
- package/src/models/HttpResponse.ts +143 -0
- package/src/models/License.ts +113 -0
- package/src/models/ProjectDefinitionProperty.ts +40 -0
- package/src/models/ProjectFolder.ts +439 -0
- package/src/models/ProjectItem.ts +135 -0
- package/src/models/ProjectParent.ts +113 -0
- package/src/models/ProjectRequest.ts +277 -0
- package/src/models/ProjectSchema.ts +202 -0
- package/src/models/Property.ts +423 -0
- package/src/models/Provider.ts +98 -0
- package/src/models/README.md +20 -0
- package/src/models/Request.ts +452 -0
- package/src/models/RequestActions.ts +163 -0
- package/src/models/RequestAuthorization.ts +115 -0
- package/src/models/RequestConfig.ts +317 -0
- package/src/models/RequestLog.ts +159 -0
- package/src/models/RequestTime.ts +108 -0
- package/src/models/RequestUiMeta.ts +258 -0
- package/src/models/RequestsSize.ts +65 -0
- package/src/models/ResponseAuthorization.ts +104 -0
- package/src/models/ResponseRedirect.ts +158 -0
- package/src/models/RevisionInfo.ts +37 -0
- package/src/models/SentRequest.ts +125 -0
- package/src/models/SerializablePayload.ts +68 -0
- package/src/models/Server.ts +153 -0
- package/src/models/Thing.ts +110 -0
- package/src/models/Url.ts +90 -0
- package/src/models/User.ts +120 -0
- package/src/models/WebApi.ts +234 -0
- package/src/models/WebApiIndex.ts +122 -0
- package/src/models/Workspace.ts +182 -0
- package/src/models/actions/Action.ts +213 -0
- package/src/models/actions/ActionView.ts +40 -0
- package/src/models/actions/Condition.ts +207 -0
- package/src/models/actions/ConditionView.ts +42 -0
- package/src/models/actions/Enums.ts +29 -0
- package/src/models/actions/RunnableAction.ts +144 -0
- package/src/models/actions/runnable/DeleteCookieAction.ts +113 -0
- package/src/models/actions/runnable/Runnable.ts +9 -0
- package/src/models/actions/runnable/SetCookieAction.ts +216 -0
- package/src/models/actions/runnable/SetVariableAction.ts +81 -0
- package/src/models/legacy/DataExport.ts +172 -0
- package/src/models/legacy/Normalizer.ts +110 -0
- package/src/models/legacy/actions/Actions.ts +269 -0
- package/src/models/legacy/authorization/Authorization.ts +572 -0
- package/src/models/legacy/models/ApiTypes.ts +202 -0
- package/src/models/legacy/models/ArcLegacyProject.ts +39 -0
- package/src/models/legacy/models/AuthData.ts +17 -0
- package/src/models/legacy/models/ClientCertificate.ts +95 -0
- package/src/models/legacy/models/Cookies.ts +52 -0
- package/src/models/legacy/models/HostRule.ts +35 -0
- package/src/models/legacy/models/RestApi.ts +49 -0
- package/src/models/legacy/models/UrlHistory.ts +37 -0
- package/src/models/legacy/models/Variable.ts +43 -0
- package/src/models/legacy/models/base.d.ts +95 -0
- package/src/models/legacy/request/ArcRequest.ts +405 -0
- package/src/models/legacy/request/ArcResponse.ts +177 -0
- package/src/models/legacy/request/HistoryData.ts +47 -0
- package/src/models/legacy/request/Legacy.ts +45 -0
- package/src/models/legacy/request/RequestBody.ts +87 -0
- package/src/models/transformers/ArcDexieTransformer.ts +323 -0
- package/src/models/transformers/ArcLegacyNormalizer.ts +85 -0
- package/src/models/transformers/ArcLegacyTransformer.ts +200 -0
- package/src/models/transformers/ArcPouchTransformer.ts +184 -0
- package/src/models/transformers/BaseTransformer.ts +116 -0
- package/src/models/transformers/ImportUtils.ts +141 -0
- package/src/models/transformers/LegacyDataExportToApiProject.ts +76 -0
- package/src/models/transformers/LegacyExportProcessor.ts +252 -0
- package/src/models/transformers/PostmanBackupTransformer.ts +306 -0
- package/src/models/transformers/PostmanDataTransformer.ts +50 -0
- package/src/models/transformers/PostmanTransformer.ts +106 -0
- package/src/models/transformers/PostmanV21Transformer.ts +311 -0
- package/src/models/transformers/PostmanV2Transformer.ts +308 -0
- package/src/models/transformers/har.ts +865 -0
- package/src/runtime/actions/ActionRunner.ts +83 -0
- package/src/runtime/actions/ConditionRunner.ts +194 -0
- package/src/runtime/actions/RunnableCondition.ts +57 -0
- package/src/runtime/actions/runnable/ActionRunnable.ts +19 -0
- package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +39 -0
- package/src/runtime/actions/runnable/SetCookieRunnable.ts +92 -0
- package/src/runtime/actions/runnable/SetVariableRunnable.ts +53 -0
- package/src/runtime/http-engine/ArcEngine.ts +1064 -0
- package/src/runtime/http-engine/Errors.ts +13 -0
- package/src/runtime/http-engine/FormData.ts +85 -0
- package/src/runtime/http-engine/HttpEngine.ts +874 -0
- package/src/runtime/http-engine/HttpErrorCodes.ts +270 -0
- package/src/runtime/http-engine/NodeEngine.ts +787 -0
- package/src/runtime/http-engine/NodeEngineDirect.ts +476 -0
- package/src/runtime/http-engine/PayloadSupport.ts +84 -0
- package/src/runtime/http-engine/RequestUtils.ts +164 -0
- package/src/runtime/http-engine/ntlm/Des.ts +345 -0
- package/src/runtime/http-engine/ntlm/MD4.ts +135 -0
- package/src/runtime/http-engine/ntlm/NtlmAuth.ts +186 -0
- package/src/runtime/http-engine/ntlm/NtlmMessage.ts +57 -0
- package/src/runtime/modules/BasicAuthCache.ts +133 -0
- package/src/runtime/modules/ExecutionResponse.ts +4 -0
- package/src/runtime/modules/ModulesRegistry.ts +136 -0
- package/src/runtime/modules/RequestAuthorization.ts +110 -0
- package/src/runtime/modules/RequestCookies.ts +145 -0
- package/src/runtime/node/ProjectRunner.ts +275 -0
- package/src/runtime/node/RequestFactory.ts +422 -0
- package/src/runtime/node/VariablesStore.ts +25 -0
- package/src/runtime/store/StoreSdk.ts +838 -0
- package/src/runtime/variables/Cache.ts +53 -0
- package/src/runtime/variables/EvalFunctions.ts +132 -0
- package/src/runtime/variables/ProjectVariables.ts +6 -0
- package/src/runtime/variables/VariablesProcessor.ts +543 -0
- 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
|
+
}
|