@api-client/core 0.6.18 → 0.6.19

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 (69) hide show
  1. package/build/src/amf/Parsing.d.ts +46 -0
  2. package/build/src/amf/Parsing.js +2 -0
  3. package/build/src/amf/Parsing.js.map +1 -0
  4. package/build/src/events/EventTypes.d.ts +6 -0
  5. package/build/src/events/EventTypes.js +2 -0
  6. package/build/src/events/EventTypes.js.map +1 -1
  7. package/build/src/events/Events.d.ts +5 -3
  8. package/build/src/events/Events.js +2 -0
  9. package/build/src/events/Events.js.map +1 -1
  10. package/build/src/events/amf/AmfEventTypes.d.ts +6 -0
  11. package/build/src/events/amf/AmfEventTypes.js +7 -0
  12. package/build/src/events/amf/AmfEventTypes.js.map +1 -0
  13. package/build/src/events/amf/AmfEvents.d.ts +34 -0
  14. package/build/src/events/amf/AmfEvents.js +59 -0
  15. package/build/src/events/amf/AmfEvents.js.map +1 -0
  16. package/build/src/events/authorization/AuthorizationEvents.d.ts +8 -8
  17. package/build/src/events/authorization/AuthorizationEvents.js +8 -8
  18. package/build/src/events/authorization/AuthorizationEvents.js.map +1 -1
  19. package/build/src/events/cookies/CookieEvents.d.ts +8 -8
  20. package/build/src/events/cookies/CookieEvents.js +8 -8
  21. package/build/src/events/cookies/CookieEvents.js.map +1 -1
  22. package/build/src/events/encryption/EncryptionEvents.d.ts +4 -4
  23. package/build/src/events/encryption/EncryptionEvents.js +4 -4
  24. package/build/src/events/encryption/EncryptionEvents.js.map +1 -1
  25. package/build/src/events/environment/EnvironmentEvents.d.ts +2 -2
  26. package/build/src/events/environment/EnvironmentEvents.js +2 -2
  27. package/build/src/events/environment/EnvironmentEvents.js.map +1 -1
  28. package/build/src/events/models/ClientCertificateEvents.d.ts +11 -11
  29. package/build/src/events/models/ClientCertificateEvents.js +11 -11
  30. package/build/src/events/models/ClientCertificateEvents.js.map +1 -1
  31. package/build/src/events/process/ProcessEvents.d.ts +6 -6
  32. package/build/src/events/process/ProcessEvents.js +6 -6
  33. package/build/src/events/process/ProcessEvents.js.map +1 -1
  34. package/build/src/events/reporting/ReportingEvents.d.ts +2 -2
  35. package/build/src/events/reporting/ReportingEvents.js +2 -2
  36. package/build/src/events/reporting/ReportingEvents.js.map +1 -1
  37. package/build/src/events/telemetry/TelemetryEvents.d.ts +6 -6
  38. package/build/src/events/telemetry/TelemetryEvents.js +6 -6
  39. package/build/src/events/telemetry/TelemetryEvents.js.map +1 -1
  40. package/build/src/events/transport/TransportEvents.d.ts +3 -3
  41. package/build/src/events/transport/TransportEvents.js +3 -3
  42. package/build/src/events/transport/TransportEvents.js.map +1 -1
  43. package/build/src/runtime/actions/runnable/DeleteCookieRunnable.js +2 -2
  44. package/build/src/runtime/actions/runnable/DeleteCookieRunnable.js.map +1 -1
  45. package/build/src/runtime/actions/runnable/SetCookieRunnable.js +1 -1
  46. package/build/src/runtime/actions/runnable/SetCookieRunnable.js.map +1 -1
  47. package/build/src/runtime/actions/runnable/SetVariableRunnable.js +1 -1
  48. package/build/src/runtime/actions/runnable/SetVariableRunnable.js.map +1 -1
  49. package/build/src/runtime/modules/RequestCookies.js +2 -2
  50. package/build/src/runtime/modules/RequestCookies.js.map +1 -1
  51. package/package.json +1 -1
  52. package/src/amf/Parsing.ts +49 -0
  53. package/src/events/EventTypes.ts +2 -0
  54. package/src/events/Events.ts +2 -0
  55. package/src/events/amf/AmfEventTypes.ts +6 -0
  56. package/src/events/amf/AmfEvents.ts +63 -0
  57. package/src/events/authorization/AuthorizationEvents.ts +8 -8
  58. package/src/events/cookies/CookieEvents.ts +8 -8
  59. package/src/events/encryption/EncryptionEvents.ts +4 -4
  60. package/src/events/environment/EnvironmentEvents.ts +2 -2
  61. package/src/events/models/ClientCertificateEvents.ts +11 -11
  62. package/src/events/process/ProcessEvents.ts +6 -6
  63. package/src/events/reporting/ReportingEvents.ts +2 -2
  64. package/src/events/telemetry/TelemetryEvents.ts +6 -6
  65. package/src/events/transport/TransportEvents.ts +3 -3
  66. package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +2 -2
  67. package/src/runtime/actions/runnable/SetCookieRunnable.ts +1 -1
  68. package/src/runtime/actions/runnable/SetVariableRunnable.ts +1 -1
  69. package/src/runtime/modules/RequestCookies.ts +2 -2
@@ -0,0 +1,49 @@
1
+ export interface AmfServiceProcessingOptions {
2
+ /**
3
+ * When true it treats the source as a zip data. Files are unzipped to a temporary location before processing.
4
+ */
5
+ zip?: boolean;
6
+ /**
7
+ * When true it validates the API when parsing.
8
+ *
9
+ * Validation is made in the `parse` phase and results (as string) are stored in the `validationResult` property of the service.
10
+ */
11
+ validate?: boolean;
12
+ /**
13
+ * The main file to use, if known
14
+ */
15
+ mainFile?: string;
16
+ }
17
+
18
+ export interface ApiSearchCandidate {
19
+ /**
20
+ * Absolute path to the file
21
+ */
22
+ absolute: string;
23
+ /**
24
+ * Relative path to the file
25
+ */
26
+ relative: string;
27
+ }
28
+
29
+ export interface ApiSearchTypeResult {
30
+ /**
31
+ * API type
32
+ */
33
+ type: string;
34
+ /**
35
+ * File media type
36
+ */
37
+ contentType: string;
38
+ }
39
+
40
+ export interface ApiParseResult {
41
+ /**
42
+ * The parsed API
43
+ */
44
+ model: string;
45
+ /**
46
+ * Api type info
47
+ */
48
+ type: ApiSearchTypeResult;
49
+ }
@@ -7,8 +7,10 @@ import { ReportingEventTypes } from './reporting/ReportingEventTypes.js';
7
7
  import { TelemetryEventTypes } from './telemetry/TelemetryEventTypes.js';
8
8
  import { EnvironmentEventTypes } from './environment/EnvironmentEventTypes.js';
9
9
  import { TransportEventTypes } from './transport/TransportEventTypes.js';
10
+ import { AmfEventTypes } from './amf/AmfEventTypes.js';
10
11
 
11
12
  export const EventTypes = Object.freeze({
13
+ Amf: AmfEventTypes,
12
14
  Authorization: AuthorizationEventTypes,
13
15
  Cookie: CookieEventTypes,
14
16
  Encryption: EncryptionEventTypes,
@@ -7,8 +7,10 @@ import { ReportingEvents } from './reporting/ReportingEvents.js';
7
7
  import { TelemetryEvents } from './telemetry/TelemetryEvents.js';
8
8
  import { TransportEvent } from './transport/TransportEvents.js';
9
9
  import { EnvironmentEvents } from './environment/EnvironmentEvents.js';
10
+ import { AmfEvents } from './amf/AmfEvents.js';
10
11
 
11
12
  export const Events = Object.freeze({
13
+ Amf: AmfEvents,
12
14
  Authorization: AuthorizationEvents,
13
15
  Cookie: CookieEvents,
14
16
  Encryption: EncryptionEvents,
@@ -0,0 +1,6 @@
1
+ export const AmfEventTypes = Object.freeze({
2
+ processApiLink: 'amfprocessapilink',
3
+ processBuffer: 'amfprocessbuffer',
4
+ processApiFile: 'amfprocessapifile',
5
+ selectApiMainFile: 'amfselectapimainfile',
6
+ });
@@ -0,0 +1,63 @@
1
+ import { ApiParseResult, AmfServiceProcessingOptions } from "../../amf/Parsing.js";
2
+ import { ContextEvent } from "../BaseEvents.js";
3
+ import { AmfEventTypes } from './AmfEventTypes.js'
4
+
5
+ export class AmfEvents {
6
+ /**
7
+ * Downloads the file and processes it as a zipped API project.
8
+ *
9
+ * @param url API remote location.
10
+ * @param mainFile API main file. If not set the program will try to find the best match.
11
+ * @param md5 When set it will test data integrity with the MD5 hash
12
+ * @param packaging Default to `zip`.
13
+ * @returns Promise resolved to the AMF json-ld model.
14
+ */
15
+ static async processApiLink(url: string, mainFile?: string, md5?: string, packaging?: string, target: EventTarget = window): Promise<ApiParseResult> {
16
+ const e = new ContextEvent(AmfEventTypes.processApiLink, {
17
+ url, mainFile, md5, packaging,
18
+ });
19
+ target.dispatchEvent(e);
20
+ return (e.detail.result as unknown) as Promise<ApiParseResult>;
21
+ }
22
+
23
+ /**
24
+ * Parses API data to AMF model.
25
+ * @param buffer Buffer created from API file.
26
+ * @param opts Processing options
27
+ * @returns Promise resolved to the AMF json-ld model
28
+ */
29
+ static async processBuffer(buffer: Buffer, opts?: AmfServiceProcessingOptions, target: EventTarget = window): Promise<ApiParseResult> {
30
+ const e = new ContextEvent(AmfEventTypes.processBuffer, {
31
+ buffer, opts,
32
+ });
33
+ target.dispatchEvent(e);
34
+ return (e.detail.result as unknown) as Promise<ApiParseResult>;
35
+ }
36
+
37
+ /**
38
+ * Processes file data.
39
+ * If the blob is a type of `application/zip` it processes the file as a
40
+ * zip file. Otherwise it processes it as a file.
41
+ *
42
+ * @param file File to process.
43
+ * @returns Promise resolved to the AMF json-ld model
44
+ */
45
+ static async processApiFile(file: File | Blob, target: EventTarget = window): Promise<ApiParseResult> {
46
+ const e = new ContextEvent(AmfEventTypes.processApiFile, {
47
+ file,
48
+ });
49
+ target.dispatchEvent(e);
50
+ return (e.detail.result as unknown) as Promise<ApiParseResult>;
51
+ }
52
+
53
+ /**
54
+ * Informs the UI to select a single file from the list of API entry point candidates.
55
+ */
56
+ static async selectApiMainFile(candidates: string[], target: EventTarget = window): Promise<string | undefined> {
57
+ const e = new ContextEvent(AmfEventTypes.selectApiMainFile, {
58
+ candidates,
59
+ });
60
+ target.dispatchEvent(e);
61
+ return e.detail.result as Promise<string | undefined>;
62
+ }
63
+ }
@@ -14,22 +14,22 @@ export class AuthorizationEvents {
14
14
 
15
15
  class OAuth2Events {
16
16
  /**
17
- * @param target A node on which to dispatch the event.
18
17
  * @param config Authorization options.
18
+ * @param target A node on which to dispatch the event.
19
19
  * @returns Promise resolved with authorization result
20
20
  */
21
- static async authorize(target: EventTarget, config: IOAuth2Authorization): Promise<ITokenInfo | undefined> {
21
+ static async authorize(config: IOAuth2Authorization, target: EventTarget = window): Promise<ITokenInfo | undefined> {
22
22
  const e = new ContextEvent<IOAuth2Authorization, ITokenInfo>(AuthorizationEventTypes.OAuth2.authorize, config);
23
23
  target.dispatchEvent(e);
24
24
  return e.detail.result;
25
25
  }
26
26
 
27
27
  /**
28
- * @param target A node on which to dispatch the event.
29
28
  * @param config Authorization options.
29
+ * @param target A node on which to dispatch the event.
30
30
  * @returns Promise resolved when the token is removed
31
31
  */
32
- static async removeToken(target: EventTarget, config: ITokenRemoveOptions): Promise<void> {
32
+ static async removeToken(config: ITokenRemoveOptions, target: EventTarget = window): Promise<void> {
33
33
  const e = new ContextEvent<ITokenRemoveOptions, void>(AuthorizationEventTypes.OAuth2.removeToken, config);
34
34
  target.dispatchEvent(e);
35
35
  return e.detail.result;
@@ -38,22 +38,22 @@ class OAuth2Events {
38
38
 
39
39
  class OidcEvents {
40
40
  /**
41
- * @param target A node on which to dispatch the event.
42
41
  * @param config Authorization options.
42
+ * @param target A node on which to dispatch the event.
43
43
  * @returns Promise resolved with authorization result
44
44
  */
45
- static async authorize(target: EventTarget, config: IOAuth2Authorization): Promise<(IOidcTokenInfo|IOidcTokenError)[] | undefined> {
45
+ static async authorize(config: IOAuth2Authorization, target: EventTarget = window): Promise<(IOidcTokenInfo|IOidcTokenError)[] | undefined> {
46
46
  const e = new ContextEvent<IOAuth2Authorization, (IOidcTokenInfo|IOidcTokenError)[]>(AuthorizationEventTypes.Oidc.authorize, config);
47
47
  target.dispatchEvent(e);
48
48
  return e.detail.result;
49
49
  }
50
50
 
51
51
  /**
52
- * @param target A node on which to dispatch the event.
53
52
  * @param config Authorization options.
53
+ * @param target A node on which to dispatch the event.
54
54
  * @returns Promise resolved when the token is removed
55
55
  */
56
- static async removeToken(target: EventTarget, config: ITokenRemoveOptions): Promise<void> {
56
+ static async removeToken(config: ITokenRemoveOptions, target: EventTarget = window): Promise<void> {
57
57
  const e = new ContextEvent<ITokenRemoveOptions, void>(AuthorizationEventTypes.Oidc.removeTokens, config);
58
58
  target.dispatchEvent(e);
59
59
  return e.detail.result;
@@ -48,7 +48,7 @@ export class CookieEvents {
48
48
  * @param domain The cookie domain
49
49
  * @returns The list of project index objects.
50
50
  */
51
- static async listDomain(target: EventTarget, domain: string): Promise<IHttpCookie[] | undefined> {
51
+ static async listDomain(domain: string, target: EventTarget = window): Promise<IHttpCookie[] | undefined> {
52
52
  const detail: ICookieDomainListDetail = { domain };
53
53
  const e = new ContextEvent<ICookieDomainListDetail, IHttpCookie[]>(CookieEventTypes.listDomain, detail);
54
54
  target.dispatchEvent(e);
@@ -60,7 +60,7 @@ export class CookieEvents {
60
60
  * @param url The cookie URL
61
61
  * @returns The list of project index objects.
62
62
  */
63
- static async listUrl(target: EventTarget, url: string): Promise<IHttpCookie[] | undefined> {
63
+ static async listUrl(url: string, target: EventTarget = window): Promise<IHttpCookie[] | undefined> {
64
64
  const detail: ICookieUrlListDetail = { url };
65
65
  const e = new ContextEvent<ICookieUrlListDetail, IHttpCookie[]>(CookieEventTypes.listUrl, detail);
66
66
  target.dispatchEvent(e);
@@ -73,7 +73,7 @@ export class CookieEvents {
73
73
  * @param target The target on which to dispatch the event
74
74
  * @param cookies The list of cookies to remove
75
75
  */
76
- static async delete(target: EventTarget, cookies: IHttpCookie[]): Promise<void> {
76
+ static async delete(cookies: IHttpCookie[], target: EventTarget = window): Promise<void> {
77
77
  const detail: ICookieItemsDetail = { cookies };
78
78
  const e = new ContextEvent<ICookieItemsDetail, void>(CookieEventTypes.delete, detail);
79
79
  target.dispatchEvent(e);
@@ -87,7 +87,7 @@ export class CookieEvents {
87
87
  * @param url The url associated with the cookie. Depending on the session mechanism the URL or the domain and the path is used.
88
88
  * @param name The name of the cookie to remove. When not set all cookies are removed for the given URL.
89
89
  */
90
- static async deleteUrl(target: EventTarget, url: string, name?: string): Promise<void> {
90
+ static async deleteUrl(url: string, name?: string, target: EventTarget = window): Promise<void> {
91
91
  const detail: ICookieDeleteUrlDetail = { url, name };
92
92
  const e = new ContextEvent<ICookieDeleteUrlDetail, void>(CookieEventTypes.deleteUrl, detail);
93
93
  target.dispatchEvent(e);
@@ -101,7 +101,7 @@ export class CookieEvents {
101
101
  * @param cookie A cookie to update
102
102
  * @returns The change record of the updated cookie.
103
103
  */
104
- static async update(target: EventTarget, cookie: IHttpCookie): Promise<ContextChangeRecord<IHttpCookie> | undefined> {
104
+ static async update(cookie: IHttpCookie, target: EventTarget = window): Promise<ContextChangeRecord<IHttpCookie> | undefined> {
105
105
  const e = new ContextUpdateEvent(CookieEventTypes.update, { item: cookie });
106
106
  target.dispatchEvent(e);
107
107
  return e.detail.result;
@@ -114,7 +114,7 @@ export class CookieEvents {
114
114
  * @param cookies A list of cookies to update
115
115
  * @returns The change record of the updated cookie.
116
116
  */
117
- static async updateBulk(target: EventTarget, cookies: IHttpCookie[]): Promise<void> {
117
+ static async updateBulk(cookies: IHttpCookie[], target: EventTarget = window): Promise<void> {
118
118
  const detail: ICookieItemsDetail = { cookies };
119
119
  const e = new ContextEvent<ICookieItemsDetail, void>(CookieEventTypes.updateBulk, detail);
120
120
  target.dispatchEvent(e);
@@ -135,7 +135,7 @@ class StateEvents {
135
135
  * @param target The target on which to dispatch the event
136
136
  * @param cookie The schema of the removed cookie
137
137
  */
138
- static delete(target: EventTarget, cookie: IHttpCookie): void {
138
+ static delete(cookie: IHttpCookie, target: EventTarget = window): void {
139
139
  const e = new CustomEvent<ICookieDetail>(CookieEventTypes.State.delete, {
140
140
  bubbles: true,
141
141
  composed: true,
@@ -150,7 +150,7 @@ class StateEvents {
150
150
  * @param target The target on which to dispatch the event
151
151
  * @param record The change record.
152
152
  */
153
- static update(target: EventTarget, record: ContextChangeRecord<IHttpCookie>): void {
153
+ static update(record: ContextChangeRecord<IHttpCookie>, target: EventTarget = window): void {
154
154
  const e = new ContextStateUpdateEvent<IHttpCookie>(CookieEventTypes.State.update, record);
155
155
  target.dispatchEvent(e);
156
156
  }
@@ -20,13 +20,13 @@ export class EncryptionEvents {
20
20
  /**
21
21
  * Dispatches an event handled by the encryption module to encrypt the data
22
22
  *
23
- * @param target A node on which to dispatch the event.
24
23
  * @param data The data to encrypt
25
24
  * @param passphrase The passphrase to use in 2-way data encryption
26
25
  * @param method Encryption method to use
26
+ * @param target A node on which to dispatch the event.
27
27
  * @returns Promise resolved to the encryption result
28
28
  */
29
- static async encrypt(target: EventTarget, data: any, passphrase: string, method: string): Promise<string | undefined> {
29
+ static async encrypt(data: any, passphrase: string, method: string, target: EventTarget = window): Promise<string | undefined> {
30
30
  const config: IEncryptionEventDetail = { data, passphrase, method };
31
31
  const e = new ContextEvent<IEncryptionEventDetail, string>(EncryptionEventTypes.encrypt, config);
32
32
  target.dispatchEvent(e);
@@ -36,13 +36,13 @@ export class EncryptionEvents {
36
36
  /**
37
37
  * Dispatches an event handled by the encryption module to decrypt the data
38
38
  *
39
- * @param target A node on which to dispatch the event.
40
39
  * @param data The data to decrypt
41
40
  * @param passphrase The passphrase to use to decrypt the data
42
41
  * @param method Method used to encrypt the data
42
+ * @param target A node on which to dispatch the event.
43
43
  * @returns Promise resolved to the decrypted result
44
44
  */
45
- static async decrypt(target: EventTarget, data: any, passphrase: string, method: string): Promise<string | undefined> {
45
+ static async decrypt(data: any, passphrase: string, method: string, target: EventTarget = window): Promise<string | undefined> {
46
46
  const config: IEncryptionEventDetail = { data, passphrase, method };
47
47
  const e = new ContextEvent<IEncryptionEventDetail, string>(EncryptionEventTypes.decrypt, config);
48
48
  target.dispatchEvent(e);
@@ -10,12 +10,12 @@ export class EnvironmentEvents {
10
10
  /**
11
11
  * An event dispatched to set a variable in the current environment.
12
12
  *
13
- * @param target A node on which to dispatch the event.
14
13
  * @param name Variable name
15
14
  * @param value Variable value
15
+ * @param target A node on which to dispatch the event.
16
16
  * @returns Nothing. The promise resolves when the variable is set.
17
17
  */
18
- static async set(target: EventTarget, name: string, value: string): Promise<void> {
18
+ static async set(name: string, value: string, target: EventTarget = window): Promise<void> {
19
19
  const detail: ISetVariableDetail = { name, value };
20
20
  const e = new ContextEvent<ISetVariableDetail, void>(EnvironmentEventTypes.set, detail);
21
21
  target.dispatchEvent(e);
@@ -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(target: EventTarget, id: string): Promise<HttpCertificate | undefined> {
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, opts?: ContextListOptions): Promise<ContextListResult<HttpCertificate> | undefined> {
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(target: EventTarget, id: string): Promise<ContextDeleteRecord | undefined> {
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(target: EventTarget, item: ICertificateCreateOptions): Promise<ContextChangeRecord<HttpCertificate> | undefined> {
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, record: ContextChangeRecord<HttpCertificate>): void {
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(target: EventTarget, record: ContextDeleteRecord): void {
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(target: EventTarget, pid: string, message: string): void {
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(target: EventTarget, pid: string): void {
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(target: EventTarget, pid: string, message: string, error?: Error): void {
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(target: EventTarget, description: string, error?: Error, component?: string): void {
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(target: EventTarget, screenName: string, info: ITelemetryDetail = {}): void {
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(target: EventTarget, detail: ITelemetryEventDetail): void {
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(target: EventTarget, description: string, fatal?: boolean, info: ITelemetryDetail = {}): void {
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(target: EventTarget, network: string, action: string, url: string, info: ITelemetryDetail = {}): void {
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(target: EventTarget, category: string, variable: string, value: number, label?: string, info: ITelemetryDetail = {}): void {
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 (target: EventTarget, request: IHttpRequest, authorization?: IRequestAuthorization[], config?: IRequestBaseConfig): Promise<IRequestLog | undefined> => {
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 (target: EventTarget, request: IHttpRequest, init?: RequestInit): Promise<Response | undefined> => {
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 (target: EventTarget, project: HttpProject | string, opts: IProjectRunnerOptions): Promise<IProjectExecutionLog | undefined> => {
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,
@@ -19,7 +19,7 @@ export class DeleteCookieRunnable extends ActionRunnable {
19
19
  if (!url) {
20
20
  return;
21
21
  }
22
- Events.Cookie.deleteUrl(this.eventTarget, url, config.name);
22
+ Events.Cookie.deleteUrl(url, config.name, this.eventTarget);
23
23
  }
24
24
 
25
25
  async request(request: IHttpRequest): Promise<void> {
@@ -34,6 +34,6 @@ export class DeleteCookieRunnable extends ActionRunnable {
34
34
  if (!url) {
35
35
  return;
36
36
  }
37
- Events.Cookie.deleteUrl(this.eventTarget, url, config.name);
37
+ Events.Cookie.deleteUrl(url, config.name, this.eventTarget);
38
38
  }
39
39
  }
@@ -68,7 +68,7 @@ export class SetCookieRunnable extends ActionRunnable {
68
68
  if (typeof config.secure === 'boolean') {
69
69
  cookie.secure = config.secure;
70
70
  }
71
- Events.Cookie.update(this.eventTarget, cookie);
71
+ Events.Cookie.update(cookie, this.eventTarget);
72
72
  }
73
73
 
74
74
  async response(log: IRequestLog): Promise<void> {
@@ -29,7 +29,7 @@ export class SetVariableRunnable extends ActionRunnable {
29
29
 
30
30
  async setVariable(config: ISetVariableAction, value: string): Promise<void> {
31
31
  const { name } = config;
32
- Events.Environment.set(this.eventTarget, name, value);
32
+ Events.Environment.set(name, value, this.eventTarget);
33
33
  }
34
34
 
35
35
  async response(log: IRequestLog): Promise<void> {
@@ -19,7 +19,7 @@ import { Cookie } from '../../lib/cookies/Cookie.js';
19
19
  * @returns A promise that resolves to header value string.
20
20
  */
21
21
  async function getCookiesHeaderValue(eventsTarget: EventTarget, url: string): Promise<string> {
22
- const cookies = await CookieEvents.listUrl(eventsTarget, url);
22
+ const cookies = await CookieEvents.listUrl(url, eventsTarget);
23
23
  if (!cookies || !cookies.length) {
24
24
  return '';
25
25
  }
@@ -141,6 +141,6 @@ export async function processResponseCookies(log: IRequestLog, context: Executio
141
141
  const typedResponse = log.response as IResponse;
142
142
  const result = extract(typedResponse, log.request.url, log.redirects);
143
143
  if (result.cookies.length) {
144
- await CookieEvents.updateBulk(context.eventsTarget, result.cookies.map(c => HttpCookie.fromCookieParser(c).toJSON()));
144
+ await CookieEvents.updateBulk(result.cookies.map(c => HttpCookie.fromCookieParser(c).toJSON()), context.eventsTarget);
145
145
  }
146
146
  }