@api-client/core 0.3.2 → 0.3.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.
- package/build/browser.d.ts +1 -0
- package/build/browser.js +1 -0
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/src/models/ErrorResponse.d.ts +5 -4
- package/build/src/models/ErrorResponse.js +18 -5
- package/build/src/models/ErrorResponse.js.map +1 -1
- package/build/src/models/SerializableError.d.ts +30 -0
- package/build/src/models/SerializableError.js +63 -0
- package/build/src/models/SerializableError.js.map +1 -0
- package/build/src/runtime/http-engine/ArcEngine.js +8 -4
- package/build/src/runtime/http-engine/ArcEngine.js.map +1 -1
- package/build/src/runtime/http-engine/HttpEngine.d.ts +3 -3
- package/build/src/runtime/http-engine/HttpEngine.js +3 -3
- package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
- package/build/src/runtime/http-engine/NodeEngine.js +9 -4
- package/build/src/runtime/http-engine/NodeEngine.js.map +1 -1
- package/build/src/runtime/http-engine/NodeEngineDirect.js +8 -2
- package/build/src/runtime/http-engine/NodeEngineDirect.js.map +1 -1
- package/build/src/runtime/node/ProjectRunner.d.ts +2 -2
- package/build/src/runtime/node/ProjectRunner.js +9 -2
- package/build/src/runtime/node/ProjectRunner.js.map +1 -1
- package/build/src/runtime/store/StoreSdk.js +10 -15
- package/build/src/runtime/store/StoreSdk.js.map +1 -1
- 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 +113 -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/SerializableError.ts +80 -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 +1068 -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 +792 -0
- package/src/runtime/http-engine/NodeEngineDirect.ts +482 -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 +281 -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
- package/build/src/runtime/http-engine/Errors.d.ts +0 -10
- package/build/src/runtime/http-engine/Errors.js +0 -14
- package/build/src/runtime/http-engine/Errors.js.map +0 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { IClientCertificate, ICertificateIndex, IRequestCertificate } from '../../models/ClientCertificate.js';
|
|
2
|
+
import { ContextReadEvent, ContextListEvent, ContextListOptions, ContextListResult, ContextDeleteEvent, ContextDeleteRecord, ContextUpdateEvent, ContextChangeRecord, ContextStateUpdateEvent, ContextStateDeleteEvent } from '../BaseEvents.js';
|
|
3
|
+
import { ModelEventTypes } from './ModelEventTypes.js';
|
|
4
|
+
|
|
5
|
+
export class ClientCertificateEvents {
|
|
6
|
+
/**
|
|
7
|
+
* Dispatches an event handled by the data store to read the client certificate.
|
|
8
|
+
*
|
|
9
|
+
* @param target A node on which to dispatch the event.
|
|
10
|
+
* @param id The id of the client certificate
|
|
11
|
+
* @param rev The revision of the client certificate. If not set then the latest revision is used.
|
|
12
|
+
* @returns Promise resolved to a client certificate model.
|
|
13
|
+
*/
|
|
14
|
+
static async read(target: EventTarget, id: string, rev?: string): Promise<IRequestCertificate | undefined> {
|
|
15
|
+
const e = new ContextReadEvent<IClientCertificate>(ModelEventTypes.ClientCertificate.read, id, rev);
|
|
16
|
+
target.dispatchEvent(e);
|
|
17
|
+
return e.detail.result;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Dispatches an event to list the client certificates data.
|
|
22
|
+
*
|
|
23
|
+
* @param target A node on which to dispatch the event.
|
|
24
|
+
* @param opts Query options.
|
|
25
|
+
* @returns The list result.
|
|
26
|
+
*/
|
|
27
|
+
static async list(target: EventTarget, opts?: ContextListOptions): Promise<ContextListResult<ICertificateIndex> | undefined> {
|
|
28
|
+
const e = new ContextListEvent<ICertificateIndex>(ModelEventTypes.ClientCertificate.list, opts);
|
|
29
|
+
target.dispatchEvent(e);
|
|
30
|
+
return e.detail.result;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Dispatches an event handled by the data store to delete a client certificate
|
|
35
|
+
*
|
|
36
|
+
* @param target A node on which to dispatch the event.
|
|
37
|
+
* @param id The id of the project to delete.
|
|
38
|
+
* @param rev The revision of the project. If not set then the latest revision is used.
|
|
39
|
+
* @returns Promise resolved to a new revision after delete.
|
|
40
|
+
*/
|
|
41
|
+
static async delete(target: EventTarget, id: string, rev?: string): Promise<ContextDeleteRecord | undefined> {
|
|
42
|
+
const e = new ContextDeleteEvent(ModelEventTypes.ClientCertificate.delete, id, undefined, rev);
|
|
43
|
+
target.dispatchEvent(e);
|
|
44
|
+
return e.detail.result;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Dispatches an event handled by the data store to insert a new client certificate.
|
|
49
|
+
*
|
|
50
|
+
* @param target A node on which to dispatch the event.
|
|
51
|
+
* @param item The certificate object.
|
|
52
|
+
* @returns Promise resolved to the change record
|
|
53
|
+
*/
|
|
54
|
+
static async insert(target: EventTarget, item: IClientCertificate): Promise<ContextChangeRecord<ICertificateIndex> | undefined> {
|
|
55
|
+
const e = new ContextUpdateEvent<IClientCertificate>(ModelEventTypes.ClientCertificate.insert, { item, });
|
|
56
|
+
target.dispatchEvent(e);
|
|
57
|
+
return e.detail.result;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static get State(): typeof StateEvents {
|
|
61
|
+
return StateEvents;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
class StateEvents {
|
|
66
|
+
/**
|
|
67
|
+
* Dispatches an event after a client certificate was updated
|
|
68
|
+
*
|
|
69
|
+
* @param target A node on which to dispatch the event.
|
|
70
|
+
* @param record Change record
|
|
71
|
+
*/
|
|
72
|
+
static update(target: EventTarget, record: ContextChangeRecord<ICertificateIndex>): void {
|
|
73
|
+
const e = new ContextStateUpdateEvent<ICertificateIndex>(ModelEventTypes.ClientCertificate.State.update, record);
|
|
74
|
+
target.dispatchEvent(e);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Dispatches an event after a client certificate was deleted
|
|
79
|
+
*
|
|
80
|
+
* @param target A node on which to dispatch the event.
|
|
81
|
+
* @param record The context store delete record
|
|
82
|
+
*/
|
|
83
|
+
static delete(target: EventTarget, record: ContextDeleteRecord): void {
|
|
84
|
+
const e = new ContextStateDeleteEvent(ModelEventTypes.ClientCertificate.State.delete, record);
|
|
85
|
+
target.dispatchEvent(e);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const ModelEventTypes = {
|
|
2
|
+
ClientCertificate: Object.freeze({
|
|
3
|
+
read: 'storeclientcertificateread',
|
|
4
|
+
list: 'storeclientcertificatelist',
|
|
5
|
+
delete: 'storeclientcertificatedelete',
|
|
6
|
+
update: 'storeclientcertificateupdate',
|
|
7
|
+
insert: 'storeclientcertificateinsert',
|
|
8
|
+
State: Object.freeze({
|
|
9
|
+
update: 'storestateclientcertificateupdate',
|
|
10
|
+
delete: 'storestateclientcertificatedelete',
|
|
11
|
+
}),
|
|
12
|
+
}),
|
|
13
|
+
Project: Object.freeze({
|
|
14
|
+
create: 'storeprojectcreate',
|
|
15
|
+
read: 'storeprojectread',
|
|
16
|
+
update: 'storeprojectupdate',
|
|
17
|
+
delete: 'storeprojectdelete',
|
|
18
|
+
/**
|
|
19
|
+
* Moves objects inside a project between position and/or folders.
|
|
20
|
+
*/
|
|
21
|
+
move: 'storeprojectmove',
|
|
22
|
+
/**
|
|
23
|
+
* Makes a copy of the project and stores it as new.
|
|
24
|
+
*/
|
|
25
|
+
clone: 'storeprojectclone',
|
|
26
|
+
listAll: 'storeprojectlistall', // without pagination
|
|
27
|
+
Folder: Object.freeze({
|
|
28
|
+
create: 'storeprojectfoldercreate',
|
|
29
|
+
delete: 'storeprojectfolderdelete',
|
|
30
|
+
update: 'storeprojectfolderupdate',
|
|
31
|
+
}),
|
|
32
|
+
Request: Object.freeze({
|
|
33
|
+
create: 'storeprojectrequestcreate',
|
|
34
|
+
delete: 'storeprojectrequestdelete',
|
|
35
|
+
update: 'storeprojectrequestupdate',
|
|
36
|
+
}),
|
|
37
|
+
Environment: Object.freeze({
|
|
38
|
+
create: 'storeprojectenvironmentcreate',
|
|
39
|
+
delete: 'storeprojectenvironmentdelete',
|
|
40
|
+
update: 'storeprojectenvironmentupdate',
|
|
41
|
+
}),
|
|
42
|
+
State: Object.freeze({
|
|
43
|
+
update: 'storeprojectstateupdate',
|
|
44
|
+
delete: 'storeprojectstatedelete',
|
|
45
|
+
})
|
|
46
|
+
}),
|
|
47
|
+
}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { IHttpProject, IProjectInitOptions, IProjectMoveOptions, IHttpProjectIndex, IFolderCreateOptions, IRequestAddOptions } from "../../models/HttpProject.js";
|
|
2
|
+
import { IProjectFolder } from "../../models/ProjectFolder.js";
|
|
3
|
+
import { IProjectRequest } from "../../models/ProjectRequest.js";
|
|
4
|
+
import { IEnvironment } from "../../models/Environment.js";
|
|
5
|
+
import { ContextChangeRecord, ContextEvent, ContextReadEvent, ContextUpdateEvent, ContextDeleteRecord, ContextDeleteEvent, ContextEventDetailWithResult } from "../BaseEvents.js";
|
|
6
|
+
import { ModelEventTypes } from './ModelEventTypes.js';
|
|
7
|
+
import CustomEvent from '../CustomEvent.js';
|
|
8
|
+
|
|
9
|
+
export interface ProjectMoveEventDetail {
|
|
10
|
+
type: 'request' | 'folder';
|
|
11
|
+
key: string;
|
|
12
|
+
opts?: IProjectMoveOptions;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ProjectCloneEventDetail {
|
|
16
|
+
/**
|
|
17
|
+
* The id of the project to clone in the data store.
|
|
18
|
+
*/
|
|
19
|
+
id: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A list of options to initialize a folder in a project.
|
|
24
|
+
*/
|
|
25
|
+
export interface IFolderInitOptions extends IFolderCreateOptions {
|
|
26
|
+
/**
|
|
27
|
+
* The store id of the project.
|
|
28
|
+
*/
|
|
29
|
+
id: string;
|
|
30
|
+
/**
|
|
31
|
+
* Optional name of the new folder.
|
|
32
|
+
*/
|
|
33
|
+
name?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A list of options to initialize a request in a project.
|
|
38
|
+
*/
|
|
39
|
+
export interface IRequestInitOptions extends IRequestAddOptions {
|
|
40
|
+
/**
|
|
41
|
+
* The store id of the project.
|
|
42
|
+
*/
|
|
43
|
+
id: string;
|
|
44
|
+
/**
|
|
45
|
+
* The URL of the request.
|
|
46
|
+
*/
|
|
47
|
+
url: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface IEnvironmentInitOptions {
|
|
51
|
+
/**
|
|
52
|
+
* The store id of the project.
|
|
53
|
+
*/
|
|
54
|
+
id: string;
|
|
55
|
+
/**
|
|
56
|
+
* The name of the environment to create.
|
|
57
|
+
*/
|
|
58
|
+
name: string;
|
|
59
|
+
/**
|
|
60
|
+
* The optional key of the parent folder.
|
|
61
|
+
*/
|
|
62
|
+
key?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
class ProjectFolderEvents {
|
|
66
|
+
/**
|
|
67
|
+
* Creates a folder in a project.
|
|
68
|
+
*
|
|
69
|
+
* @param target The target on which to dispatch the event
|
|
70
|
+
* @param id The store id of the project
|
|
71
|
+
* @param name Optionally, name of the folder to create.
|
|
72
|
+
* @param opts Optional options to create a folder.
|
|
73
|
+
* @returns The change record of the created folder. Note, the client should either refresh the project from the store or append the change record to the instance of the project.
|
|
74
|
+
*/
|
|
75
|
+
static async create(target: EventTarget, id: string, name?: string, opts: IFolderCreateOptions = {}): Promise<ContextChangeRecord<IProjectFolder> | undefined> {
|
|
76
|
+
const init: IFolderInitOptions = { ...opts, id, name, };
|
|
77
|
+
const e = new ContextEvent<IFolderInitOptions, ContextChangeRecord<IProjectFolder>>(ModelEventTypes.Project.Folder.create, init);
|
|
78
|
+
target.dispatchEvent(e);
|
|
79
|
+
return e.detail.result;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Deletes a folder from a project
|
|
84
|
+
*
|
|
85
|
+
* @param target The target on which to dispatch the event
|
|
86
|
+
* @param id The data store id of the project
|
|
87
|
+
* @param key The key of the folder to delete.
|
|
88
|
+
*/
|
|
89
|
+
static async delete(target: EventTarget, id: string, key: string): Promise<ContextDeleteRecord | undefined> {
|
|
90
|
+
const e = new ContextDeleteEvent(ModelEventTypes.Project.Folder.delete, key, id);
|
|
91
|
+
target.dispatchEvent(e);
|
|
92
|
+
return e.detail.result;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Updates the entire folder schema in a project.
|
|
97
|
+
*
|
|
98
|
+
* @param target The target on which to dispatch the event
|
|
99
|
+
* @param id The data store id of the project
|
|
100
|
+
* @param folder The folder to replace the schema for.
|
|
101
|
+
* @returns The change record of the updated folder.
|
|
102
|
+
*/
|
|
103
|
+
static async update(target: EventTarget, id: string, folder: IProjectFolder): Promise<ContextChangeRecord<IProjectFolder> | undefined> {
|
|
104
|
+
const e = new ContextUpdateEvent(ModelEventTypes.Project.Folder.update, { item: folder, parent: id });
|
|
105
|
+
target.dispatchEvent(e);
|
|
106
|
+
return e.detail.result;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
class ProjectRequestEvents {
|
|
111
|
+
/**
|
|
112
|
+
* Creates a request in a project.
|
|
113
|
+
*
|
|
114
|
+
* @param target The target on which to dispatch the event
|
|
115
|
+
* @param id The store id of the project
|
|
116
|
+
* @param url The URL of the request.
|
|
117
|
+
* @param opts Optional options to create a request.
|
|
118
|
+
* @returns The change record of the created request. Note, the client should either refresh the project from the store or append the change record to the instance of the project.
|
|
119
|
+
*/
|
|
120
|
+
static async create(target: EventTarget, id: string, url: string, opts: IRequestAddOptions = {}): Promise<ContextChangeRecord<IProjectRequest> | undefined> {
|
|
121
|
+
const init: IRequestInitOptions = { ...opts, id, url, };
|
|
122
|
+
const e = new ContextEvent<IRequestInitOptions, ContextChangeRecord<IProjectRequest>>(ModelEventTypes.Project.Request.create, init);
|
|
123
|
+
target.dispatchEvent(e);
|
|
124
|
+
return e.detail.result;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Deletes a request from a project
|
|
129
|
+
*
|
|
130
|
+
* @param target The target on which to dispatch the event
|
|
131
|
+
* @param id The data store id of the project
|
|
132
|
+
* @param key The key of the request to delete.
|
|
133
|
+
*/
|
|
134
|
+
static async delete(target: EventTarget, id: string, key: string): Promise<ContextDeleteRecord | undefined> {
|
|
135
|
+
const e = new ContextDeleteEvent(ModelEventTypes.Project.Request.delete, key, id);
|
|
136
|
+
target.dispatchEvent(e);
|
|
137
|
+
return e.detail.result;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Updates the entire request schema in a project.
|
|
142
|
+
*
|
|
143
|
+
* @param target The target on which to dispatch the event
|
|
144
|
+
* @param id The data store id of the project
|
|
145
|
+
* @param request The request to replace the schema for.
|
|
146
|
+
* @returns The change record of the updated request.
|
|
147
|
+
*/
|
|
148
|
+
static async update(target: EventTarget, id: string, request: IProjectRequest): Promise<ContextChangeRecord<IProjectRequest> | undefined> {
|
|
149
|
+
const e = new ContextUpdateEvent(ModelEventTypes.Project.Request.update, { item: request, parent: id });
|
|
150
|
+
target.dispatchEvent(e);
|
|
151
|
+
return e.detail.result;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
class ProjectEnvironmentEvents {
|
|
156
|
+
/**
|
|
157
|
+
* Creates an environment in a project.
|
|
158
|
+
*
|
|
159
|
+
* @param target The target on which to dispatch the event
|
|
160
|
+
* @param id The store id of the project
|
|
161
|
+
* @param name The name of the environment.
|
|
162
|
+
* @param key The optional key of the parent folder.
|
|
163
|
+
* @returns The change record of the created environment. Note, the client should either refresh the project from the store or append the change record to the instance of the project.
|
|
164
|
+
*/
|
|
165
|
+
static async create(target: EventTarget, id: string, name: string, key?: string): Promise<ContextChangeRecord<IEnvironment> | undefined> {
|
|
166
|
+
const init: IEnvironmentInitOptions = { id, name, key };
|
|
167
|
+
const e = new ContextEvent<IEnvironmentInitOptions, ContextChangeRecord<IEnvironment>>(ModelEventTypes.Project.Environment.create, init);
|
|
168
|
+
target.dispatchEvent(e);
|
|
169
|
+
return e.detail.result;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Deletes an environment from a project
|
|
174
|
+
*
|
|
175
|
+
* @param target The target on which to dispatch the event
|
|
176
|
+
* @param id The data store id of the project
|
|
177
|
+
* @param key The key of the environment to delete.
|
|
178
|
+
*/
|
|
179
|
+
static async delete(target: EventTarget, id: string, key: string): Promise<ContextDeleteRecord | undefined> {
|
|
180
|
+
const e = new ContextDeleteEvent(ModelEventTypes.Project.Environment.delete, key, id);
|
|
181
|
+
target.dispatchEvent(e);
|
|
182
|
+
return e.detail.result;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Updates the entire environment schema in a project.
|
|
187
|
+
*
|
|
188
|
+
* @param target The target on which to dispatch the event
|
|
189
|
+
* @param id The data store id of the project
|
|
190
|
+
* @param environment The environment to replace the schema for.
|
|
191
|
+
* @returns The change record of the updated environment.
|
|
192
|
+
*/
|
|
193
|
+
static async update(target: EventTarget, id: string, environment: IEnvironment): Promise<ContextChangeRecord<IEnvironment> | undefined> {
|
|
194
|
+
const e = new ContextUpdateEvent(ModelEventTypes.Project.Environment.update, { item: environment, parent: id });
|
|
195
|
+
target.dispatchEvent(e);
|
|
196
|
+
return e.detail.result;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* ARC's HTTP project events.
|
|
202
|
+
*
|
|
203
|
+
* Note, `id`s refers to datastore ids but `key`s are internal identifiers inside the project.
|
|
204
|
+
* Whenever id is used it refers to the store's ids. When `key` is used it is the id of the project or any of its components.
|
|
205
|
+
*/
|
|
206
|
+
export class ProjectEvents {
|
|
207
|
+
/**
|
|
208
|
+
* Creates a new project in the data store.
|
|
209
|
+
*
|
|
210
|
+
* @param target The target on which to dispatch the event
|
|
211
|
+
* @param name The name of the project to create
|
|
212
|
+
* @returns The change record of the created project.
|
|
213
|
+
*/
|
|
214
|
+
static async create(target: EventTarget, name: string): Promise<ContextChangeRecord<IHttpProject> | undefined> {
|
|
215
|
+
const e = new ContextEvent<IProjectInitOptions, ContextChangeRecord<IHttpProject>>(ModelEventTypes.Project.create, { name });
|
|
216
|
+
target.dispatchEvent(e);
|
|
217
|
+
return e.detail.result;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Reads a project from the data store.
|
|
222
|
+
*
|
|
223
|
+
* @param target The target on which to dispatch the event
|
|
224
|
+
* @param id The data store id of the project to read.
|
|
225
|
+
* @param rev Optional revision version, when supported.
|
|
226
|
+
*/
|
|
227
|
+
static async read(target: EventTarget, id: string, rev?: string): Promise<IHttpProject | undefined> {
|
|
228
|
+
const e = new ContextReadEvent<IHttpProject>(ModelEventTypes.Project.read, id, rev);
|
|
229
|
+
target.dispatchEvent(e);
|
|
230
|
+
return e.detail.result;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Updates the entire object in the store.
|
|
235
|
+
*
|
|
236
|
+
* @param target The target on which to dispatch the event
|
|
237
|
+
* @param project The project to replace the value for.
|
|
238
|
+
* @returns The change record of the updated project.
|
|
239
|
+
*/
|
|
240
|
+
static async update(target: EventTarget, project: IHttpProject): Promise<ContextChangeRecord<IHttpProject> | undefined> {
|
|
241
|
+
const e = new ContextUpdateEvent(ModelEventTypes.Project.update, { item: project });
|
|
242
|
+
target.dispatchEvent(e);
|
|
243
|
+
return e.detail.result;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Deletes a project from the data store.
|
|
248
|
+
*
|
|
249
|
+
* @param target The target on which to dispatch the event
|
|
250
|
+
* @param id The data store id of the project to delete.
|
|
251
|
+
*/
|
|
252
|
+
static async delete(target: EventTarget, id: string): Promise<ContextDeleteRecord | undefined> {
|
|
253
|
+
const e = new ContextDeleteEvent(ModelEventTypes.Project.delete, id);
|
|
254
|
+
target.dispatchEvent(e);
|
|
255
|
+
return e.detail.result;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Moves a request or a folder inside the project.
|
|
260
|
+
*
|
|
261
|
+
* @param target The target on which to dispatch the event
|
|
262
|
+
* @param type The type of the object to move within the project.
|
|
263
|
+
* @param key The `key` of the request of the folder
|
|
264
|
+
* @param opts The move options. When omitted then it moves the object to the project root at the last position.
|
|
265
|
+
* @returns The change record of the updated project.
|
|
266
|
+
*/
|
|
267
|
+
static async move(target: EventTarget, type: 'request' | 'folder', key: string, opts?: IProjectMoveOptions): Promise<ContextChangeRecord<IHttpProject> | undefined> {
|
|
268
|
+
const e = new ContextEvent<ProjectMoveEventDetail, ContextChangeRecord<IHttpProject>>(ModelEventTypes.Project.move, {
|
|
269
|
+
key,
|
|
270
|
+
type,
|
|
271
|
+
opts,
|
|
272
|
+
});
|
|
273
|
+
target.dispatchEvent(e);
|
|
274
|
+
return e.detail.result;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Clones a project that is stored in the data store.
|
|
279
|
+
*
|
|
280
|
+
* @param target The target on which to dispatch the event
|
|
281
|
+
* @param id The data store id of the project to clone.
|
|
282
|
+
* @returns The cloned project (the copy).
|
|
283
|
+
*/
|
|
284
|
+
static async clone(target: EventTarget, id: string): Promise<ContextChangeRecord<IHttpProject> | undefined> {
|
|
285
|
+
const e = new ContextEvent<ProjectCloneEventDetail, ContextChangeRecord<IHttpProject>>(ModelEventTypes.Project.clone, {
|
|
286
|
+
id,
|
|
287
|
+
});
|
|
288
|
+
target.dispatchEvent(e);
|
|
289
|
+
return e.detail.result;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Lists all projects in the data store.
|
|
294
|
+
* This does not return the whole project record. Instead it only returns the index object of the project.
|
|
295
|
+
*
|
|
296
|
+
* @param target The target on which to dispatch the event
|
|
297
|
+
* @returns The list of project index objects.
|
|
298
|
+
*/
|
|
299
|
+
static async listAll(target: EventTarget): Promise<IHttpProjectIndex[] | undefined> {
|
|
300
|
+
const detail: ContextEventDetailWithResult<IHttpProjectIndex[]> = {};
|
|
301
|
+
const e = new CustomEvent(ModelEventTypes.Project.listAll, {
|
|
302
|
+
bubbles: true,
|
|
303
|
+
composed: true,
|
|
304
|
+
cancelable: true,
|
|
305
|
+
detail,
|
|
306
|
+
});
|
|
307
|
+
target.dispatchEvent(e);
|
|
308
|
+
return e.detail.result;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Events related to a folder manipulation in a project.
|
|
313
|
+
*/
|
|
314
|
+
static get Folder(): typeof ProjectFolderEvents {
|
|
315
|
+
return ProjectFolderEvents;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Events related to a request manipulation in a project.
|
|
320
|
+
*/
|
|
321
|
+
static get Request(): typeof ProjectRequestEvents {
|
|
322
|
+
return ProjectRequestEvents;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Events related to an environment manipulation in a project.
|
|
327
|
+
*/
|
|
328
|
+
static get Environment(): typeof ProjectEnvironmentEvents {
|
|
329
|
+
return ProjectEnvironmentEvents;
|
|
330
|
+
}
|
|
331
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ProcessEventTypes } from './ProcessEventTypes.js';
|
|
2
|
+
|
|
3
|
+
export interface IProcessStartDetail {
|
|
4
|
+
pid: string;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IProcessStopDetail {
|
|
9
|
+
pid: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IProcessErrorDetail {
|
|
13
|
+
pid: string;
|
|
14
|
+
message: string;
|
|
15
|
+
error?: Error
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class ProcessEvents {
|
|
19
|
+
/**
|
|
20
|
+
* An event to be dispatched when the application is stating a long running process
|
|
21
|
+
* in the background. The side effect of the event is the UI showing a process
|
|
22
|
+
* indicator.
|
|
23
|
+
*
|
|
24
|
+
* @param target A node on which to dispatch the event.
|
|
25
|
+
* @param pid The id of the process. The same id has to be passed to the stop event.
|
|
26
|
+
* @param message Optional message rendered in the UI.
|
|
27
|
+
*/
|
|
28
|
+
static loadingStart(target: EventTarget, pid: string, message: string): void {
|
|
29
|
+
const detail: IProcessStartDetail = { pid, message };
|
|
30
|
+
const e = new CustomEvent(ProcessEventTypes.loadingStart, {
|
|
31
|
+
cancelable: true,
|
|
32
|
+
composed: true,
|
|
33
|
+
bubbles: true,
|
|
34
|
+
detail,
|
|
35
|
+
});
|
|
36
|
+
target.dispatchEvent(e);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* An event to be dispatched when the application has finished a long running process
|
|
41
|
+
* in the background.
|
|
42
|
+
*
|
|
43
|
+
* @param target A node on which to dispatch the event.
|
|
44
|
+
* @param pid The id of the process. The same id has to be passed to the stop event.
|
|
45
|
+
*/
|
|
46
|
+
static loadingStop(target: EventTarget, pid: string): void {
|
|
47
|
+
const detail: IProcessStopDetail = { pid };
|
|
48
|
+
const e = new CustomEvent(ProcessEventTypes.loadingStop, {
|
|
49
|
+
cancelable: true,
|
|
50
|
+
composed: true,
|
|
51
|
+
bubbles: true,
|
|
52
|
+
detail,
|
|
53
|
+
});
|
|
54
|
+
target.dispatchEvent(e);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* An event to be dispatched when the application has finished a long running process
|
|
59
|
+
* in the background with an error.
|
|
60
|
+
*
|
|
61
|
+
* @param target A node on which to dispatch the event.
|
|
62
|
+
* @param pid The id of the process used to start it.
|
|
63
|
+
* @param message The message to be rendered to the user.
|
|
64
|
+
* @param error The error object caused the event. Optional.
|
|
65
|
+
*/
|
|
66
|
+
static loadingError(target: EventTarget, pid: string, message: string, error?: Error): void {
|
|
67
|
+
const detail: IProcessErrorDetail = { pid, message, error };
|
|
68
|
+
const e = new CustomEvent(ProcessEventTypes.loadingError, {
|
|
69
|
+
cancelable: true,
|
|
70
|
+
composed: true,
|
|
71
|
+
bubbles: true,
|
|
72
|
+
detail,
|
|
73
|
+
});
|
|
74
|
+
target.dispatchEvent(e);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Events
|
|
2
|
+
|
|
3
|
+
This package contains a definition of events used by the ARC ecosystem to communicate with context providers.
|
|
4
|
+
|
|
5
|
+
## Context provider
|
|
6
|
+
|
|
7
|
+
A context provider is any service that is listening for relevant events and responds to them by taking some action.
|
|
8
|
+
|
|
9
|
+
For example a Store Context Provider is a provider that listens to events related to the data models and performs CRUD operations on the data store. The result of the operation is passed to the `result` object of the event. The event is an instance of the CustomEvent class.
|
|
10
|
+
|
|
11
|
+
## Communication architecture
|
|
12
|
+
|
|
13
|
+
A module or an application wants to read the context value from a context provider. The module dispatches a CustomEvent on the application's EventTarget with the corresponding `type` handled by the context provider.
|
|
14
|
+
|
|
15
|
+
The provider handles the event, cancels it (when applicable, prevents duplication), and calls the corresponding asynchronous logic. The result of the operation is always a Promise. The promise is resolved when the operation finish
|
|
16
|
+
|
|
17
|
+
The promise is set on the `detail` object if the `CustomEvent` as the `result` property.
|
|
18
|
+
|
|
19
|
+
This has the following implications:
|
|
20
|
+
|
|
21
|
+
- all events are processed asynchronously
|
|
22
|
+
- all events must extend `CustomEvent` class, unless they have no side effects (no result, no data to pass to the provider)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReportingEventTypes } from './ReportingEventTypes.js';
|
|
2
|
+
|
|
3
|
+
export interface IReportingErrorDetail {
|
|
4
|
+
description: string;
|
|
5
|
+
error?: Error;
|
|
6
|
+
component?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class ReportingEvents {
|
|
10
|
+
/**
|
|
11
|
+
* Dispatches the general error event for UI logging purposes.
|
|
12
|
+
*
|
|
13
|
+
* @param target A node on which to dispatch the event
|
|
14
|
+
* @param description The error description
|
|
15
|
+
* @param error Optional original error object that has caused this event
|
|
16
|
+
* @param component Optional component name.
|
|
17
|
+
*/
|
|
18
|
+
static error(target: EventTarget, description: string, error?: Error, component?: string): void {
|
|
19
|
+
const detail: IReportingErrorDetail = { error, description, component };
|
|
20
|
+
const e = new CustomEvent(ReportingEventTypes.error, {
|
|
21
|
+
bubbles: true,
|
|
22
|
+
composed: true,
|
|
23
|
+
cancelable: true,
|
|
24
|
+
detail,
|
|
25
|
+
});
|
|
26
|
+
target.dispatchEvent(e);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const TelemetryEventTypes = Object.freeze({
|
|
2
|
+
view: 'telemetryscreenview',
|
|
3
|
+
event: 'telemetryevent',
|
|
4
|
+
exception: 'telemetryexception',
|
|
5
|
+
social: 'telemetrysocial',
|
|
6
|
+
timing: 'telemetrytiming',
|
|
7
|
+
State: Object.freeze({
|
|
8
|
+
set: 'telemetrystateset',
|
|
9
|
+
}),
|
|
10
|
+
});
|