@api-client/core 0.6.18 → 0.6.22
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 +2 -0
- package/build/browser.js +2 -0
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/legacy.d.ts +39 -0
- package/build/legacy.js +40 -0
- package/build/legacy.js.map +1 -0
- package/build/src/amf/Parsing.d.ts +46 -0
- package/build/src/amf/Parsing.js +2 -0
- package/build/src/amf/Parsing.js.map +1 -0
- package/build/src/events/EventTypes.d.ts +6 -0
- package/build/src/events/EventTypes.js +2 -0
- package/build/src/events/EventTypes.js.map +1 -1
- package/build/src/events/Events.d.ts +5 -3
- package/build/src/events/Events.js +2 -0
- package/build/src/events/Events.js.map +1 -1
- package/build/src/events/amf/AmfEventTypes.d.ts +6 -0
- package/build/src/events/amf/AmfEventTypes.js +7 -0
- package/build/src/events/amf/AmfEventTypes.js.map +1 -0
- package/build/src/events/amf/AmfEvents.d.ts +34 -0
- package/build/src/events/amf/AmfEvents.js +59 -0
- package/build/src/events/amf/AmfEvents.js.map +1 -0
- package/build/src/events/authorization/AuthorizationEvents.d.ts +8 -8
- package/build/src/events/authorization/AuthorizationEvents.js +8 -8
- package/build/src/events/authorization/AuthorizationEvents.js.map +1 -1
- package/build/src/events/cookies/CookieEvents.d.ts +8 -8
- package/build/src/events/cookies/CookieEvents.js +8 -8
- package/build/src/events/cookies/CookieEvents.js.map +1 -1
- package/build/src/events/encryption/EncryptionEvents.d.ts +4 -4
- package/build/src/events/encryption/EncryptionEvents.js +4 -4
- package/build/src/events/encryption/EncryptionEvents.js.map +1 -1
- package/build/src/events/environment/EnvironmentEvents.d.ts +2 -2
- package/build/src/events/environment/EnvironmentEvents.js +2 -2
- package/build/src/events/environment/EnvironmentEvents.js.map +1 -1
- package/build/src/events/models/ClientCertificateEvents.d.ts +11 -11
- package/build/src/events/models/ClientCertificateEvents.js +11 -11
- package/build/src/events/models/ClientCertificateEvents.js.map +1 -1
- package/build/src/events/process/ProcessEvents.d.ts +6 -6
- package/build/src/events/process/ProcessEvents.js +6 -6
- package/build/src/events/process/ProcessEvents.js.map +1 -1
- package/build/src/events/reporting/ReportingEvents.d.ts +2 -2
- package/build/src/events/reporting/ReportingEvents.js +2 -2
- package/build/src/events/reporting/ReportingEvents.js.map +1 -1
- package/build/src/events/telemetry/TelemetryEvents.d.ts +6 -6
- package/build/src/events/telemetry/TelemetryEvents.js +6 -6
- package/build/src/events/telemetry/TelemetryEvents.js.map +1 -1
- package/build/src/events/transport/TransportEvents.d.ts +3 -3
- package/build/src/events/transport/TransportEvents.js +3 -3
- package/build/src/events/transport/TransportEvents.js.map +1 -1
- package/build/src/mocking/lib/Url.js +1 -1
- package/build/src/models/AuthorizationData.d.ts +2 -0
- package/build/src/models/AuthorizationData.js +10 -3
- package/build/src/models/AuthorizationData.js.map +1 -1
- package/build/src/models/ClientCertificate.js +1 -1
- package/build/src/models/ClientCertificate.js.map +1 -1
- package/build/src/models/HostRule.d.ts +8 -0
- package/build/src/models/HostRule.js +10 -1
- package/build/src/models/HostRule.js.map +1 -1
- package/build/src/models/HttpProject.js +3 -0
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/Url.d.ts +4 -4
- package/build/src/models/Url.js +6 -6
- package/build/src/models/Url.js.map +1 -1
- package/build/src/models/arc/ArcHttpRequest.d.ts +39 -0
- package/build/src/models/arc/ArcHttpRequest.js +106 -0
- package/build/src/models/arc/ArcHttpRequest.js.map +1 -0
- package/build/src/models/arc/ArcProject.d.ts +621 -0
- package/build/src/models/arc/ArcProject.js +1242 -0
- package/build/src/models/arc/ArcProject.js.map +1 -0
- package/build/src/runtime/actions/runnable/DeleteCookieRunnable.js +2 -2
- package/build/src/runtime/actions/runnable/DeleteCookieRunnable.js.map +1 -1
- package/build/src/runtime/actions/runnable/SetCookieRunnable.js +1 -1
- package/build/src/runtime/actions/runnable/SetCookieRunnable.js.map +1 -1
- package/build/src/runtime/actions/runnable/SetVariableRunnable.js +1 -1
- package/build/src/runtime/actions/runnable/SetVariableRunnable.js.map +1 -1
- package/build/src/runtime/modules/RequestCookies.js +2 -2
- package/build/src/runtime/modules/RequestCookies.js.map +1 -1
- package/legacy.ts +41 -0
- package/package.json +3 -3
- package/src/amf/Parsing.ts +49 -0
- package/src/events/EventTypes.ts +2 -0
- package/src/events/Events.ts +2 -0
- package/src/events/amf/AmfEventTypes.ts +6 -0
- package/src/events/amf/AmfEvents.ts +63 -0
- package/src/events/authorization/AuthorizationEvents.ts +8 -8
- package/src/events/cookies/CookieEvents.ts +8 -8
- package/src/events/encryption/EncryptionEvents.ts +4 -4
- package/src/events/environment/EnvironmentEvents.ts +2 -2
- package/src/events/models/ClientCertificateEvents.ts +11 -11
- package/src/events/process/ProcessEvents.ts +6 -6
- package/src/events/reporting/ReportingEvents.ts +2 -2
- package/src/events/telemetry/TelemetryEvents.ts +6 -6
- package/src/events/transport/TransportEvents.ts +3 -3
- package/src/mocking/lib/Url.ts +1 -1
- package/src/models/AuthorizationData.ts +10 -2
- package/src/models/ClientCertificate.ts +2 -2
- package/src/models/HostRule.ts +17 -1
- package/src/models/HttpProject.ts +3 -0
- package/src/models/Url.ts +10 -10
- package/src/models/arc/ArcHttpRequest.ts +121 -0
- package/src/models/arc/ArcProject.ts +1605 -0
- package/src/models/arc/readme.md +3 -0
- package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +2 -2
- package/src/runtime/actions/runnable/SetCookieRunnable.ts +1 -1
- package/src/runtime/actions/runnable/SetVariableRunnable.ts +1 -1
- package/src/runtime/modules/RequestCookies.ts +2 -2
|
@@ -6,11 +6,11 @@ export class ClientCertificateEvents {
|
|
|
6
6
|
/**
|
|
7
7
|
* Dispatches an event handled by the data store to read the client certificate.
|
|
8
8
|
*
|
|
9
|
-
* @param target A node on which to dispatch the event.
|
|
10
9
|
* @param id The id of the client certificate
|
|
10
|
+
* @param target A node on which to dispatch the event.
|
|
11
11
|
* @returns Promise resolved to a client certificate model.
|
|
12
12
|
*/
|
|
13
|
-
static async read(
|
|
13
|
+
static async read(id: string, target: EventTarget = window): Promise<HttpCertificate | undefined> {
|
|
14
14
|
const e = new ContextReadEvent<HttpCertificate>(ModelEventTypes.ClientCertificate.read, id);
|
|
15
15
|
target.dispatchEvent(e);
|
|
16
16
|
return e.detail.result;
|
|
@@ -19,11 +19,11 @@ export class ClientCertificateEvents {
|
|
|
19
19
|
/**
|
|
20
20
|
* Dispatches an event to list the client certificates data.
|
|
21
21
|
*
|
|
22
|
-
* @param target A node on which to dispatch the event.
|
|
23
22
|
* @param opts Query options.
|
|
23
|
+
* @param target A node on which to dispatch the event.
|
|
24
24
|
* @returns The list result.
|
|
25
25
|
*/
|
|
26
|
-
static async list(target: EventTarget
|
|
26
|
+
static async list(opts?: ContextListOptions, target: EventTarget = window): Promise<ContextListResult<HttpCertificate> | undefined> {
|
|
27
27
|
const e = new ContextListEvent<HttpCertificate>(ModelEventTypes.ClientCertificate.list, opts);
|
|
28
28
|
target.dispatchEvent(e);
|
|
29
29
|
return e.detail.result;
|
|
@@ -32,11 +32,11 @@ export class ClientCertificateEvents {
|
|
|
32
32
|
/**
|
|
33
33
|
* Dispatches an event handled by the data store to delete a client certificate
|
|
34
34
|
*
|
|
35
|
-
* @param target A node on which to dispatch the event.
|
|
36
35
|
* @param id The id of the project to delete.
|
|
36
|
+
* @param target A node on which to dispatch the event.
|
|
37
37
|
* @returns Promise resolved to a new revision after delete.
|
|
38
38
|
*/
|
|
39
|
-
static async delete(
|
|
39
|
+
static async delete(id: string, target: EventTarget = window): Promise<ContextDeleteRecord | undefined> {
|
|
40
40
|
const e = new ContextDeleteEvent(ModelEventTypes.ClientCertificate.delete, id, undefined);
|
|
41
41
|
target.dispatchEvent(e);
|
|
42
42
|
return e.detail.result;
|
|
@@ -45,11 +45,11 @@ export class ClientCertificateEvents {
|
|
|
45
45
|
/**
|
|
46
46
|
* Dispatches an event handled by the data store to insert a new client certificate.
|
|
47
47
|
*
|
|
48
|
-
* @param target A node on which to dispatch the event.
|
|
49
48
|
* @param item The certificate object.
|
|
49
|
+
* @param target A node on which to dispatch the event.
|
|
50
50
|
* @returns Promise resolved to the change record
|
|
51
51
|
*/
|
|
52
|
-
static async insert(
|
|
52
|
+
static async insert(item: ICertificateCreateOptions, target: EventTarget = window): Promise<ContextChangeRecord<HttpCertificate> | undefined> {
|
|
53
53
|
const e = new ContextUpdateEvent<ICertificateCreateOptions, HttpCertificate>(ModelEventTypes.ClientCertificate.insert, { item, });
|
|
54
54
|
target.dispatchEvent(e);
|
|
55
55
|
return e.detail.result;
|
|
@@ -67,7 +67,7 @@ class StateEvents {
|
|
|
67
67
|
* @param target A node on which to dispatch the event.
|
|
68
68
|
* @param record Change record
|
|
69
69
|
*/
|
|
70
|
-
static update(target: EventTarget
|
|
70
|
+
static update(record: ContextChangeRecord<HttpCertificate>, target: EventTarget = window): void {
|
|
71
71
|
const e = new ContextStateUpdateEvent<HttpCertificate>(ModelEventTypes.ClientCertificate.State.update, record);
|
|
72
72
|
target.dispatchEvent(e);
|
|
73
73
|
}
|
|
@@ -75,10 +75,10 @@ class StateEvents {
|
|
|
75
75
|
/**
|
|
76
76
|
* Dispatches an event after a client certificate was deleted
|
|
77
77
|
*
|
|
78
|
-
* @param target A node on which to dispatch the event.
|
|
79
78
|
* @param record The context store delete record
|
|
79
|
+
* @param target A node on which to dispatch the event.
|
|
80
80
|
*/
|
|
81
|
-
static delete(
|
|
81
|
+
static delete(record: ContextDeleteRecord, target: EventTarget = window): void {
|
|
82
82
|
const e = new ContextStateDeleteEvent(ModelEventTypes.ClientCertificate.State.delete, record);
|
|
83
83
|
target.dispatchEvent(e);
|
|
84
84
|
}
|
|
@@ -21,11 +21,11 @@ export class ProcessEvents {
|
|
|
21
21
|
* in the background. The side effect of the event is the UI showing a process
|
|
22
22
|
* indicator.
|
|
23
23
|
*
|
|
24
|
-
* @param target A node on which to dispatch the event.
|
|
25
24
|
* @param pid The id of the process. The same id has to be passed to the stop event.
|
|
26
25
|
* @param message Optional message rendered in the UI.
|
|
26
|
+
* @param target A node on which to dispatch the event.
|
|
27
27
|
*/
|
|
28
|
-
static loadingStart(
|
|
28
|
+
static loadingStart(pid: string, message: string, target: EventTarget = window): void {
|
|
29
29
|
const detail: IProcessStartDetail = { pid, message };
|
|
30
30
|
const e = new CustomEvent(ProcessEventTypes.loadingStart, {
|
|
31
31
|
cancelable: true,
|
|
@@ -40,10 +40,10 @@ export class ProcessEvents {
|
|
|
40
40
|
* An event to be dispatched when the application has finished a long running process
|
|
41
41
|
* in the background.
|
|
42
42
|
*
|
|
43
|
-
* @param target A node on which to dispatch the event.
|
|
44
43
|
* @param pid The id of the process. The same id has to be passed to the stop event.
|
|
44
|
+
* @param target A node on which to dispatch the event.
|
|
45
45
|
*/
|
|
46
|
-
static loadingStop(
|
|
46
|
+
static loadingStop(pid: string, target: EventTarget = window): void {
|
|
47
47
|
const detail: IProcessStopDetail = { pid };
|
|
48
48
|
const e = new CustomEvent(ProcessEventTypes.loadingStop, {
|
|
49
49
|
cancelable: true,
|
|
@@ -58,12 +58,12 @@ export class ProcessEvents {
|
|
|
58
58
|
* An event to be dispatched when the application has finished a long running process
|
|
59
59
|
* in the background with an error.
|
|
60
60
|
*
|
|
61
|
-
* @param target A node on which to dispatch the event.
|
|
62
61
|
* @param pid The id of the process used to start it.
|
|
63
62
|
* @param message The message to be rendered to the user.
|
|
64
63
|
* @param error The error object caused the event. Optional.
|
|
64
|
+
* @param target A node on which to dispatch the event.
|
|
65
65
|
*/
|
|
66
|
-
static loadingError(
|
|
66
|
+
static loadingError(pid: string, message: string, error?: Error, target: EventTarget = window): void {
|
|
67
67
|
const detail: IProcessErrorDetail = { pid, message, error };
|
|
68
68
|
const e = new CustomEvent(ProcessEventTypes.loadingError, {
|
|
69
69
|
cancelable: true,
|
|
@@ -10,12 +10,12 @@ export class ReportingEvents {
|
|
|
10
10
|
/**
|
|
11
11
|
* Dispatches the general error event for UI logging purposes.
|
|
12
12
|
*
|
|
13
|
-
* @param target A node on which to dispatch the event
|
|
14
13
|
* @param description The error description
|
|
15
14
|
* @param error Optional original error object that has caused this event
|
|
16
15
|
* @param component Optional component name.
|
|
16
|
+
* @param target A node on which to dispatch the event
|
|
17
17
|
*/
|
|
18
|
-
static error(
|
|
18
|
+
static error(description: string, error?: Error, component?: string, target: EventTarget = window): void {
|
|
19
19
|
const detail: IReportingErrorDetail = { error, description, component };
|
|
20
20
|
const e = new CustomEvent(ReportingEventTypes.error, {
|
|
21
21
|
bubbles: true,
|
|
@@ -48,7 +48,7 @@ export class TelemetryEvents {
|
|
|
48
48
|
* @param screenName The screen name
|
|
49
49
|
* @param info Analytics base configuration
|
|
50
50
|
*/
|
|
51
|
-
static view(
|
|
51
|
+
static view(screenName: string, target: EventTarget = window, info: ITelemetryDetail = {}): void {
|
|
52
52
|
const detail: ITelemetryScreenViewDetail = {
|
|
53
53
|
...info, screenName,
|
|
54
54
|
};
|
|
@@ -66,7 +66,7 @@ export class TelemetryEvents {
|
|
|
66
66
|
* @param target A node on which to dispatch the event
|
|
67
67
|
* @param detail The event configuration
|
|
68
68
|
*/
|
|
69
|
-
static event(
|
|
69
|
+
static event(detail: ITelemetryEventDetail, target: EventTarget = window): void {
|
|
70
70
|
const e = new CustomEvent(TelemetryEventTypes.event, {
|
|
71
71
|
bubbles: true,
|
|
72
72
|
composed: true,
|
|
@@ -83,7 +83,7 @@ export class TelemetryEvents {
|
|
|
83
83
|
* @param fatal Whether the exception was fatal to the application
|
|
84
84
|
* @param info Analytics base configuration
|
|
85
85
|
*/
|
|
86
|
-
static exception(
|
|
86
|
+
static exception(description: string, fatal?: boolean, target: EventTarget = window, info: ITelemetryDetail = {}): void {
|
|
87
87
|
const detail: ITelemetryExceptionDetail = { ...info, description, fatal };
|
|
88
88
|
const e = new CustomEvent(TelemetryEventTypes.exception, {
|
|
89
89
|
bubbles: true,
|
|
@@ -102,7 +102,7 @@ export class TelemetryEvents {
|
|
|
102
102
|
* @param url The share url
|
|
103
103
|
* @param info Analytics base configuration
|
|
104
104
|
*/
|
|
105
|
-
static social(
|
|
105
|
+
static social(network: string, action: string, url: string, target: EventTarget = window, info: ITelemetryDetail = {}): void {
|
|
106
106
|
const detail: ITelemetrySocialDetail = { ...info, network, action, target: url };
|
|
107
107
|
const e = new CustomEvent(TelemetryEventTypes.social, {
|
|
108
108
|
bubbles: true,
|
|
@@ -122,7 +122,7 @@ export class TelemetryEvents {
|
|
|
122
122
|
* @param label The timing label
|
|
123
123
|
* @param info Analytics base configuration
|
|
124
124
|
*/
|
|
125
|
-
static timing(
|
|
125
|
+
static timing(category: string, variable: string, value: number, label?: string, target: EventTarget = window, info: ITelemetryDetail = {}): void {
|
|
126
126
|
const detail: ITelemetryTimingDetail = { ...info, category, variable, value, label };
|
|
127
127
|
const e = new CustomEvent(TelemetryEventTypes.timing, {
|
|
128
128
|
bubbles: true,
|
|
@@ -145,7 +145,7 @@ class StateEvents {
|
|
|
145
145
|
*
|
|
146
146
|
* @param target The node on which to dispatch the event.
|
|
147
147
|
*/
|
|
148
|
-
static set(target: EventTarget): void {
|
|
148
|
+
static set(target: EventTarget = window): void {
|
|
149
149
|
const e = new Event(TelemetryEventTypes.State.set, {
|
|
150
150
|
composed: true,
|
|
151
151
|
cancelable: true,
|
|
@@ -39,7 +39,7 @@ export const TransportEvent = Object.freeze({
|
|
|
39
39
|
* @param config Optional request configuration.
|
|
40
40
|
* @returns The execution log or `undefined` when the event was not handled.
|
|
41
41
|
*/
|
|
42
|
-
send: async (
|
|
42
|
+
send: async (request: IHttpRequest, authorization?: IRequestAuthorization[], config?: IRequestBaseConfig, target: EventTarget = window): Promise<IRequestLog | undefined> => {
|
|
43
43
|
const e = new ContextEvent<ICoreRequestDetail, IRequestLog>(TransportEventTypes.Core.send, {
|
|
44
44
|
request,
|
|
45
45
|
authorization,
|
|
@@ -62,7 +62,7 @@ export const TransportEvent = Object.freeze({
|
|
|
62
62
|
* @param init Optional request init options compatible with the Fetch API.
|
|
63
63
|
* @returns Compatible with the Fetch API Response object or `undefined` when the event was not handled.
|
|
64
64
|
*/
|
|
65
|
-
send: async (
|
|
65
|
+
send: async (request: IHttpRequest, init?: RequestInit, target: EventTarget = window): Promise<Response | undefined> => {
|
|
66
66
|
const e = new ContextEvent<IHttpRequestDetail, Response>(TransportEventTypes.Http.send, {
|
|
67
67
|
request,
|
|
68
68
|
init,
|
|
@@ -82,7 +82,7 @@ export const TransportEvent = Object.freeze({
|
|
|
82
82
|
* @param opts The project execution options.
|
|
83
83
|
* @returns
|
|
84
84
|
*/
|
|
85
|
-
send: async (
|
|
85
|
+
send: async (project: HttpProject | string, opts: IProjectRunnerOptions, target: EventTarget = window): Promise<IProjectExecutionLog | undefined> => {
|
|
86
86
|
const e = new ContextEvent<IProjectRequestDetail, IProjectExecutionLog>(TransportEventTypes.Project.send, {
|
|
87
87
|
project,
|
|
88
88
|
opts,
|
package/src/mocking/lib/Url.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import v4 from '../lib/uuid.js';
|
|
2
|
+
|
|
1
3
|
export interface IAuthorizationData {
|
|
4
|
+
key: string;
|
|
2
5
|
username?: string;
|
|
3
6
|
password?: string;
|
|
4
7
|
domain?: string;
|
|
@@ -12,6 +15,7 @@ export interface IAuthorizationData {
|
|
|
12
15
|
* Each entry represent a Basic or NTLM authorization.
|
|
13
16
|
*/
|
|
14
17
|
export class AuthorizationData {
|
|
18
|
+
key = '';
|
|
15
19
|
username?: string;
|
|
16
20
|
password?: string;
|
|
17
21
|
domain?: string;
|
|
@@ -26,7 +30,9 @@ export class AuthorizationData {
|
|
|
26
30
|
} else if (typeof input === 'object') {
|
|
27
31
|
init = input;
|
|
28
32
|
} else {
|
|
29
|
-
init = {
|
|
33
|
+
init = {
|
|
34
|
+
key: v4(),
|
|
35
|
+
};
|
|
30
36
|
}
|
|
31
37
|
this.new(init);
|
|
32
38
|
}
|
|
@@ -37,14 +43,16 @@ export class AuthorizationData {
|
|
|
37
43
|
* Note, this throws an error when the provider is not an API Client provider object.
|
|
38
44
|
*/
|
|
39
45
|
new(init: IAuthorizationData): void {
|
|
40
|
-
const { username, password, domain } = init;
|
|
46
|
+
const { username, password, domain, key = v4() } = init;
|
|
41
47
|
this.username = username;
|
|
42
48
|
this.password = password;
|
|
43
49
|
this.domain = domain;
|
|
50
|
+
this.key = key;
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
toJSON(): IAuthorizationData {
|
|
47
54
|
const result:IAuthorizationData = {
|
|
55
|
+
key: this.key,
|
|
48
56
|
};
|
|
49
57
|
if (this.username) {
|
|
50
58
|
result.username = this.username;
|
|
@@ -257,9 +257,9 @@ export class Certificate {
|
|
|
257
257
|
type: 'p12',
|
|
258
258
|
};
|
|
259
259
|
|
|
260
|
-
if (this.type === 'pem') {
|
|
260
|
+
if (this.type === 'pem' && this.certKey) {
|
|
261
261
|
const typed = (result as unknown) as IPemCertificate;
|
|
262
|
-
typed.certKey = this.toStore(this.certKey
|
|
262
|
+
typed.certKey = this.toStore(this.certKey);
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
return result;
|
package/src/models/HostRule.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import v4 from '../lib/uuid.js';
|
|
2
|
+
|
|
1
3
|
export const Kind = 'Core#HostRule';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* API Client host rule definition.
|
|
5
7
|
*/
|
|
6
8
|
export interface IHostRule {
|
|
9
|
+
/**
|
|
10
|
+
* The key of the rule.
|
|
11
|
+
*/
|
|
12
|
+
key: string;
|
|
13
|
+
|
|
7
14
|
kind?: typeof Kind;
|
|
8
15
|
/**
|
|
9
16
|
* The from rule (may contain asterisks)
|
|
@@ -24,6 +31,11 @@ export interface IHostRule {
|
|
|
24
31
|
}
|
|
25
32
|
|
|
26
33
|
export class HostRule {
|
|
34
|
+
/**
|
|
35
|
+
* The key of the rule.
|
|
36
|
+
*/
|
|
37
|
+
key = '';
|
|
38
|
+
|
|
27
39
|
kind = Kind;
|
|
28
40
|
/**
|
|
29
41
|
* The from rule (may contain asterisks)
|
|
@@ -44,6 +56,7 @@ export class HostRule {
|
|
|
44
56
|
|
|
45
57
|
static fromValues(from: string, to: string ): HostRule {
|
|
46
58
|
const result = new HostRule({
|
|
59
|
+
key: v4(),
|
|
47
60
|
kind: Kind,
|
|
48
61
|
from,
|
|
49
62
|
to,
|
|
@@ -63,6 +76,7 @@ export class HostRule {
|
|
|
63
76
|
init = input;
|
|
64
77
|
} else {
|
|
65
78
|
init = {
|
|
79
|
+
key: v4(),
|
|
66
80
|
kind: Kind,
|
|
67
81
|
from: '',
|
|
68
82
|
to: '',
|
|
@@ -80,8 +94,9 @@ export class HostRule {
|
|
|
80
94
|
if (!HostRule.isHostRule(init)) {
|
|
81
95
|
throw new Error(`Not a HostRule.`);
|
|
82
96
|
}
|
|
83
|
-
const { from='', to='', enabled, comment } = init;
|
|
97
|
+
const { from='', to='', enabled, comment, key = v4() } = init;
|
|
84
98
|
this.kind = Kind;
|
|
99
|
+
this.key = key;
|
|
85
100
|
this.from = from;
|
|
86
101
|
this.to = to;
|
|
87
102
|
this.enabled = enabled;
|
|
@@ -102,6 +117,7 @@ export class HostRule {
|
|
|
102
117
|
toJSON(): IHostRule {
|
|
103
118
|
const result: IHostRule = {
|
|
104
119
|
kind: Kind,
|
|
120
|
+
key: this.key,
|
|
105
121
|
from : this.from,
|
|
106
122
|
to : this.to,
|
|
107
123
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-this-alias */
|
|
1
4
|
import { ProjectParent } from './ProjectParent.js';
|
|
2
5
|
import { IProjectDefinitionProperty } from './ProjectDefinitionProperty.js';
|
|
3
6
|
import { Environment, IEnvironment, Kind as EnvironmentKind } from './Environment.js';
|
package/src/models/Url.ts
CHANGED
|
@@ -9,9 +9,9 @@ export interface IUrl {
|
|
|
9
9
|
*/
|
|
10
10
|
time: number;
|
|
11
11
|
/**
|
|
12
|
-
* The request URL stored in the history.
|
|
12
|
+
* The request URL stored in the history. This is also the store key.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
key: string;
|
|
15
15
|
/**
|
|
16
16
|
* A timestamp of the midnight that corresponds to the `time` property.
|
|
17
17
|
*/
|
|
@@ -30,11 +30,11 @@ export class Url {
|
|
|
30
30
|
/**
|
|
31
31
|
* Last use timestamp.
|
|
32
32
|
*/
|
|
33
|
-
time:number = Date.now();
|
|
33
|
+
time: number = Date.now();
|
|
34
34
|
/**
|
|
35
|
-
* The request URL stored in the history.
|
|
35
|
+
* The request URL stored in the history. This is also the store key.
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
key = '';
|
|
38
38
|
/**
|
|
39
39
|
* A timestamp of the midnight that corresponds to the `time` property.
|
|
40
40
|
*/
|
|
@@ -43,7 +43,7 @@ export class Url {
|
|
|
43
43
|
/**
|
|
44
44
|
* @param input The URL definition used to restore the state.
|
|
45
45
|
*/
|
|
46
|
-
constructor(input: string|IUrl) {
|
|
46
|
+
constructor(input: string | IUrl) {
|
|
47
47
|
let init: IUrl;
|
|
48
48
|
if (typeof input === 'string') {
|
|
49
49
|
init = JSON.parse(input);
|
|
@@ -53,7 +53,7 @@ export class Url {
|
|
|
53
53
|
init = {
|
|
54
54
|
cnt: 0,
|
|
55
55
|
time: Date.now(),
|
|
56
|
-
|
|
56
|
+
key: '',
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
this.new(init);
|
|
@@ -63,8 +63,8 @@ export class Url {
|
|
|
63
63
|
* Creates a new URL clearing anything that is so far defined.
|
|
64
64
|
*/
|
|
65
65
|
new(init: IUrl): void {
|
|
66
|
-
const {
|
|
67
|
-
this.
|
|
66
|
+
const { key = '', cnt = 0, time = Date.now(), midnight } = init;
|
|
67
|
+
this.key = key;
|
|
68
68
|
this.cnt = cnt;
|
|
69
69
|
this.time = time;
|
|
70
70
|
if (midnight) {
|
|
@@ -78,7 +78,7 @@ export class Url {
|
|
|
78
78
|
|
|
79
79
|
toJSON(): IUrl {
|
|
80
80
|
const result: IUrl = {
|
|
81
|
-
|
|
81
|
+
key: this.key,
|
|
82
82
|
cnt: this.cnt,
|
|
83
83
|
time: this.time,
|
|
84
84
|
midnight: this.midnight,
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { IRequest, Request } from "../Request.js";
|
|
2
|
+
import v4 from "../../lib/uuid.js";
|
|
3
|
+
import { HttpRequest, IHttpRequest } from "../HttpRequest.js";
|
|
4
|
+
import { Thing } from "../Thing.js";
|
|
5
|
+
|
|
6
|
+
export const Kind = 'Arc#ArcRequest';
|
|
7
|
+
|
|
8
|
+
export interface IArcHttpRequest extends IRequest {
|
|
9
|
+
kind: typeof Kind;
|
|
10
|
+
key: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class ArcHttpRequest extends Request {
|
|
14
|
+
kind = Kind;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The identifier of the request.
|
|
18
|
+
*/
|
|
19
|
+
key = '';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Creates a project request from an URL.
|
|
23
|
+
*
|
|
24
|
+
* @param url The Request URL. This is required.
|
|
25
|
+
*/
|
|
26
|
+
static fromUrl(url: string): ArcHttpRequest {
|
|
27
|
+
const now: number = Date.now();
|
|
28
|
+
const request = new ArcHttpRequest({
|
|
29
|
+
key: v4(),
|
|
30
|
+
kind: Kind,
|
|
31
|
+
created: now,
|
|
32
|
+
updated: now,
|
|
33
|
+
expects: HttpRequest.fromBaseValues({ url, method: 'GET' }).toJSON(),
|
|
34
|
+
info: Thing.fromName(url).toJSON(),
|
|
35
|
+
});
|
|
36
|
+
return request;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates a project request from a name.
|
|
41
|
+
*
|
|
42
|
+
* @param name The Request name.
|
|
43
|
+
*/
|
|
44
|
+
static fromName(name: string): ArcHttpRequest {
|
|
45
|
+
const now: number = Date.now();
|
|
46
|
+
const request = new ArcHttpRequest({
|
|
47
|
+
key: v4(),
|
|
48
|
+
kind: Kind,
|
|
49
|
+
created: now,
|
|
50
|
+
updated: now,
|
|
51
|
+
expects: new HttpRequest().toJSON(),
|
|
52
|
+
info: Thing.fromName(name).toJSON(),
|
|
53
|
+
});
|
|
54
|
+
return request;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Creates a request from an HttpRequest definition.
|
|
59
|
+
*
|
|
60
|
+
* @param info The request data.
|
|
61
|
+
*/
|
|
62
|
+
static fromHttpRequest(info: IHttpRequest): ArcHttpRequest {
|
|
63
|
+
const now: number = Date.now();
|
|
64
|
+
const request = new ArcHttpRequest({
|
|
65
|
+
key: v4(),
|
|
66
|
+
kind: Kind,
|
|
67
|
+
created: now,
|
|
68
|
+
updated: now,
|
|
69
|
+
expects: HttpRequest.fromBaseValues({ method: info.method, url: info.url, headers: info.headers, payload: info.payload }).toJSON(),
|
|
70
|
+
info: Thing.fromName(info.url).toJSON(),
|
|
71
|
+
});
|
|
72
|
+
return request;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Creates a request for a schema of a Request.
|
|
77
|
+
*/
|
|
78
|
+
static fromRequest(request: IArcHttpRequest): ArcHttpRequest {
|
|
79
|
+
const key = v4();
|
|
80
|
+
const init: IArcHttpRequest = {
|
|
81
|
+
...request,
|
|
82
|
+
key,
|
|
83
|
+
kind: Kind
|
|
84
|
+
};
|
|
85
|
+
const result = new ArcHttpRequest(init);
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
constructor(input?: string | IArcHttpRequest) {
|
|
90
|
+
super(input);
|
|
91
|
+
|
|
92
|
+
let init: IArcHttpRequest | undefined;
|
|
93
|
+
if (typeof input === 'string') {
|
|
94
|
+
init = JSON.parse(input);
|
|
95
|
+
} else if (typeof input === 'object') {
|
|
96
|
+
init = input;
|
|
97
|
+
}
|
|
98
|
+
if (init) {
|
|
99
|
+
this.key = init.key || v4();
|
|
100
|
+
}
|
|
101
|
+
this.kind = Kind;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
new(init: IArcHttpRequest): void {
|
|
105
|
+
super.new(init);
|
|
106
|
+
|
|
107
|
+
const { key } = init;
|
|
108
|
+
this.key = key || v4();
|
|
109
|
+
this.kind = Kind;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
toJSON(): IArcHttpRequest {
|
|
113
|
+
const request = super.toJSON();
|
|
114
|
+
const result: IArcHttpRequest = {
|
|
115
|
+
...request,
|
|
116
|
+
key: this.key,
|
|
117
|
+
kind: Kind
|
|
118
|
+
};
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
}
|