@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.
Files changed (205) hide show
  1. package/build/browser.d.ts +1 -0
  2. package/build/browser.js +1 -0
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +1 -1
  5. package/build/index.js +1 -1
  6. package/build/index.js.map +1 -1
  7. package/build/src/models/ErrorResponse.d.ts +5 -4
  8. package/build/src/models/ErrorResponse.js +18 -5
  9. package/build/src/models/ErrorResponse.js.map +1 -1
  10. package/build/src/models/SerializableError.d.ts +30 -0
  11. package/build/src/models/SerializableError.js +63 -0
  12. package/build/src/models/SerializableError.js.map +1 -0
  13. package/build/src/runtime/http-engine/ArcEngine.js +8 -4
  14. package/build/src/runtime/http-engine/ArcEngine.js.map +1 -1
  15. package/build/src/runtime/http-engine/HttpEngine.d.ts +3 -3
  16. package/build/src/runtime/http-engine/HttpEngine.js +3 -3
  17. package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
  18. package/build/src/runtime/http-engine/NodeEngine.js +9 -4
  19. package/build/src/runtime/http-engine/NodeEngine.js.map +1 -1
  20. package/build/src/runtime/http-engine/NodeEngineDirect.js +8 -2
  21. package/build/src/runtime/http-engine/NodeEngineDirect.js.map +1 -1
  22. package/build/src/runtime/node/ProjectRunner.d.ts +2 -2
  23. package/build/src/runtime/node/ProjectRunner.js +9 -2
  24. package/build/src/runtime/node/ProjectRunner.js.map +1 -1
  25. package/build/src/runtime/store/StoreSdk.js +10 -15
  26. package/build/src/runtime/store/StoreSdk.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/data/DataReader.ts +11 -0
  29. package/src/data/DataUtils.ts +108 -0
  30. package/src/data/JmesparthReader.ts +26 -0
  31. package/src/data/Json2Xml.ts +190 -0
  32. package/src/data/JsonReader.ts +41 -0
  33. package/src/data/PayloadPointer.ts +48 -0
  34. package/src/data/RequestDataExtractor.ts +133 -0
  35. package/src/data/UrlEncodedReader.ts +20 -0
  36. package/src/data/XmlReader.ts +103 -0
  37. package/src/events/BaseEvents.ts +259 -0
  38. package/src/events/CustomEvent.ts +27 -0
  39. package/src/events/EventTypes.ts +19 -0
  40. package/src/events/Events.ts +19 -0
  41. package/src/events/authorization/AuthorizationEventTypes.ts +22 -0
  42. package/src/events/authorization/AuthorizationEvents.ts +61 -0
  43. package/src/events/cookies/CookieEventTypes.ts +13 -0
  44. package/src/events/cookies/CookieEvents.ts +157 -0
  45. package/src/events/encryption/EncryptionEventTypes.ts +4 -0
  46. package/src/events/encryption/EncryptionEvents.ts +51 -0
  47. package/src/events/environment/EnvironmentEventTypes.ts +3 -0
  48. package/src/events/environment/EnvironmentEvents.ts +24 -0
  49. package/src/events/models/ClientCertificateEvents.ts +87 -0
  50. package/src/events/models/ModelEventTypes.ts +47 -0
  51. package/src/events/models/ModelEvents.ts +7 -0
  52. package/src/events/models/ProjectEvents.ts +331 -0
  53. package/src/events/process/ProcessEventTypes.ts +5 -0
  54. package/src/events/process/ProcessEvents.ts +76 -0
  55. package/src/events/readme.md +22 -0
  56. package/src/events/reporting/ReportingEventTypes.ts +3 -0
  57. package/src/events/reporting/ReportingEvents.ts +28 -0
  58. package/src/events/telemetry/TelemetryEventTypes.ts +10 -0
  59. package/src/events/telemetry/TelemetryEvents.ts +156 -0
  60. package/src/lib/cookies/Cookie.ts +312 -0
  61. package/src/lib/cookies/Cookies.ts +326 -0
  62. package/src/lib/cookies/Utils.ts +168 -0
  63. package/src/lib/headers/Headers.ts +219 -0
  64. package/src/lib/logging/DefaultLogger.ts +19 -0
  65. package/src/lib/logging/DummyLogger.ts +21 -0
  66. package/src/lib/logging/Logger.ts +16 -0
  67. package/src/lib/transformers/PayloadSerializer.ts +332 -0
  68. package/src/lib/transformers/Utils.ts +18 -0
  69. package/src/lib/uuid.ts +40 -0
  70. package/src/mocking/LegacyInterfaces.ts +52 -0
  71. package/src/mocking/LegacyMock.ts +37 -0
  72. package/src/mocking/legacy/Authorization.ts +39 -0
  73. package/src/mocking/legacy/Certificates.ts +145 -0
  74. package/src/mocking/legacy/Cookies.ts +51 -0
  75. package/src/mocking/legacy/HostRules.ts +43 -0
  76. package/src/mocking/legacy/Http.ts +236 -0
  77. package/src/mocking/legacy/HttpResponse.ts +106 -0
  78. package/src/mocking/legacy/RestApi.ts +68 -0
  79. package/src/mocking/legacy/Urls.ts +44 -0
  80. package/src/mocking/legacy/Variables.ts +53 -0
  81. package/src/models/ArcResponse.ts +166 -0
  82. package/src/models/Authorization.ts +481 -0
  83. package/src/models/AuthorizationData.ts +60 -0
  84. package/src/models/Backend.ts +107 -0
  85. package/src/models/ClientCertificate.ts +68 -0
  86. package/src/models/Environment.ts +279 -0
  87. package/src/models/ErrorResponse.ts +113 -0
  88. package/src/models/HistoryIndex.ts +76 -0
  89. package/src/models/HistoryRequest.ts +28 -0
  90. package/src/models/HostRule.ts +163 -0
  91. package/src/models/HttpCookie.ts +285 -0
  92. package/src/models/HttpProject.ts +1294 -0
  93. package/src/models/HttpProjectListItem.ts +23 -0
  94. package/src/models/HttpRequest.ts +124 -0
  95. package/src/models/HttpResponse.ts +143 -0
  96. package/src/models/License.ts +113 -0
  97. package/src/models/ProjectDefinitionProperty.ts +40 -0
  98. package/src/models/ProjectFolder.ts +439 -0
  99. package/src/models/ProjectItem.ts +135 -0
  100. package/src/models/ProjectParent.ts +113 -0
  101. package/src/models/ProjectRequest.ts +277 -0
  102. package/src/models/ProjectSchema.ts +202 -0
  103. package/src/models/Property.ts +423 -0
  104. package/src/models/Provider.ts +98 -0
  105. package/src/models/README.md +20 -0
  106. package/src/models/Request.ts +452 -0
  107. package/src/models/RequestActions.ts +163 -0
  108. package/src/models/RequestAuthorization.ts +115 -0
  109. package/src/models/RequestConfig.ts +317 -0
  110. package/src/models/RequestLog.ts +159 -0
  111. package/src/models/RequestTime.ts +108 -0
  112. package/src/models/RequestUiMeta.ts +258 -0
  113. package/src/models/RequestsSize.ts +65 -0
  114. package/src/models/ResponseAuthorization.ts +104 -0
  115. package/src/models/ResponseRedirect.ts +158 -0
  116. package/src/models/RevisionInfo.ts +37 -0
  117. package/src/models/SentRequest.ts +125 -0
  118. package/src/models/SerializableError.ts +80 -0
  119. package/src/models/SerializablePayload.ts +68 -0
  120. package/src/models/Server.ts +153 -0
  121. package/src/models/Thing.ts +110 -0
  122. package/src/models/Url.ts +90 -0
  123. package/src/models/User.ts +120 -0
  124. package/src/models/WebApi.ts +234 -0
  125. package/src/models/WebApiIndex.ts +122 -0
  126. package/src/models/Workspace.ts +182 -0
  127. package/src/models/actions/Action.ts +213 -0
  128. package/src/models/actions/ActionView.ts +40 -0
  129. package/src/models/actions/Condition.ts +207 -0
  130. package/src/models/actions/ConditionView.ts +42 -0
  131. package/src/models/actions/Enums.ts +29 -0
  132. package/src/models/actions/RunnableAction.ts +144 -0
  133. package/src/models/actions/runnable/DeleteCookieAction.ts +113 -0
  134. package/src/models/actions/runnable/Runnable.ts +9 -0
  135. package/src/models/actions/runnable/SetCookieAction.ts +216 -0
  136. package/src/models/actions/runnable/SetVariableAction.ts +81 -0
  137. package/src/models/legacy/DataExport.ts +172 -0
  138. package/src/models/legacy/Normalizer.ts +110 -0
  139. package/src/models/legacy/actions/Actions.ts +269 -0
  140. package/src/models/legacy/authorization/Authorization.ts +572 -0
  141. package/src/models/legacy/models/ApiTypes.ts +202 -0
  142. package/src/models/legacy/models/ArcLegacyProject.ts +39 -0
  143. package/src/models/legacy/models/AuthData.ts +17 -0
  144. package/src/models/legacy/models/ClientCertificate.ts +95 -0
  145. package/src/models/legacy/models/Cookies.ts +52 -0
  146. package/src/models/legacy/models/HostRule.ts +35 -0
  147. package/src/models/legacy/models/RestApi.ts +49 -0
  148. package/src/models/legacy/models/UrlHistory.ts +37 -0
  149. package/src/models/legacy/models/Variable.ts +43 -0
  150. package/src/models/legacy/models/base.d.ts +95 -0
  151. package/src/models/legacy/request/ArcRequest.ts +405 -0
  152. package/src/models/legacy/request/ArcResponse.ts +177 -0
  153. package/src/models/legacy/request/HistoryData.ts +47 -0
  154. package/src/models/legacy/request/Legacy.ts +45 -0
  155. package/src/models/legacy/request/RequestBody.ts +87 -0
  156. package/src/models/transformers/ArcDexieTransformer.ts +323 -0
  157. package/src/models/transformers/ArcLegacyNormalizer.ts +85 -0
  158. package/src/models/transformers/ArcLegacyTransformer.ts +200 -0
  159. package/src/models/transformers/ArcPouchTransformer.ts +184 -0
  160. package/src/models/transformers/BaseTransformer.ts +116 -0
  161. package/src/models/transformers/ImportUtils.ts +141 -0
  162. package/src/models/transformers/LegacyDataExportToApiProject.ts +76 -0
  163. package/src/models/transformers/LegacyExportProcessor.ts +252 -0
  164. package/src/models/transformers/PostmanBackupTransformer.ts +306 -0
  165. package/src/models/transformers/PostmanDataTransformer.ts +50 -0
  166. package/src/models/transformers/PostmanTransformer.ts +106 -0
  167. package/src/models/transformers/PostmanV21Transformer.ts +311 -0
  168. package/src/models/transformers/PostmanV2Transformer.ts +308 -0
  169. package/src/models/transformers/har.ts +865 -0
  170. package/src/runtime/actions/ActionRunner.ts +83 -0
  171. package/src/runtime/actions/ConditionRunner.ts +194 -0
  172. package/src/runtime/actions/RunnableCondition.ts +57 -0
  173. package/src/runtime/actions/runnable/ActionRunnable.ts +19 -0
  174. package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +39 -0
  175. package/src/runtime/actions/runnable/SetCookieRunnable.ts +92 -0
  176. package/src/runtime/actions/runnable/SetVariableRunnable.ts +53 -0
  177. package/src/runtime/http-engine/ArcEngine.ts +1068 -0
  178. package/src/runtime/http-engine/FormData.ts +85 -0
  179. package/src/runtime/http-engine/HttpEngine.ts +874 -0
  180. package/src/runtime/http-engine/HttpErrorCodes.ts +270 -0
  181. package/src/runtime/http-engine/NodeEngine.ts +792 -0
  182. package/src/runtime/http-engine/NodeEngineDirect.ts +482 -0
  183. package/src/runtime/http-engine/PayloadSupport.ts +84 -0
  184. package/src/runtime/http-engine/RequestUtils.ts +164 -0
  185. package/src/runtime/http-engine/ntlm/Des.ts +345 -0
  186. package/src/runtime/http-engine/ntlm/MD4.ts +135 -0
  187. package/src/runtime/http-engine/ntlm/NtlmAuth.ts +186 -0
  188. package/src/runtime/http-engine/ntlm/NtlmMessage.ts +57 -0
  189. package/src/runtime/modules/BasicAuthCache.ts +133 -0
  190. package/src/runtime/modules/ExecutionResponse.ts +4 -0
  191. package/src/runtime/modules/ModulesRegistry.ts +136 -0
  192. package/src/runtime/modules/RequestAuthorization.ts +110 -0
  193. package/src/runtime/modules/RequestCookies.ts +145 -0
  194. package/src/runtime/node/ProjectRunner.ts +281 -0
  195. package/src/runtime/node/RequestFactory.ts +422 -0
  196. package/src/runtime/node/VariablesStore.ts +25 -0
  197. package/src/runtime/store/StoreSdk.ts +838 -0
  198. package/src/runtime/variables/Cache.ts +53 -0
  199. package/src/runtime/variables/EvalFunctions.ts +132 -0
  200. package/src/runtime/variables/ProjectVariables.ts +6 -0
  201. package/src/runtime/variables/VariablesProcessor.ts +543 -0
  202. package/src/runtime/variables/VariablesTokenizer.ts +55 -0
  203. package/build/src/runtime/http-engine/Errors.d.ts +0 -10
  204. package/build/src/runtime/http-engine/Errors.js +0 -14
  205. package/build/src/runtime/http-engine/Errors.js.map +0 -1
@@ -0,0 +1,259 @@
1
+ import CustomEvent from './CustomEvent.js';
2
+
3
+ /**
4
+ * Base event detail definition for the events that returns a `result`
5
+ * property on the `detail` object
6
+ */
7
+ export interface ContextEventDetailWithResult<T> {
8
+ /**
9
+ * This property is set by the context provider, a promise resolved when the operation finish
10
+ * with the corresponding result.
11
+ */
12
+ result?: Promise<T> | undefined;
13
+ }
14
+
15
+ /**
16
+ * A base class to use with context providers.
17
+ */
18
+ export class ContextEvent<S extends object, R> extends CustomEvent<ContextEventDetailWithResult<R>> {
19
+ /**
20
+ * @param type The event type
21
+ * @param detail The optional detail object. It adds object's properties to the `detail` with the `result` property.
22
+ */
23
+ constructor(type: string, detail: S) {
24
+ super(type, {
25
+ bubbles: true,
26
+ composed: true,
27
+ cancelable: true,
28
+ detail: {
29
+ result: undefined,
30
+ ...detail,
31
+ }
32
+ });
33
+ }
34
+ }
35
+
36
+ export interface ContextReadEventDetail {
37
+ /**
38
+ * The id of the state object to read.
39
+ */
40
+ id: string;
41
+ /**
42
+ * Optional revision of the state, when supported by the context provider.
43
+ */
44
+ rev?: string;
45
+ }
46
+
47
+ /**
48
+ * An event to be used to read a state from a context provider.
49
+ */
50
+ export class ContextReadEvent<T> extends ContextEvent<ContextReadEventDetail, T> {
51
+ /**
52
+ * @param type The type of the event
53
+ * @param id The domain id of the object to read
54
+ * @param rev Optional revision of the state, when supported by the context provider.
55
+ */
56
+ constructor(type: string, id: string, rev?: string) {
57
+ super(type, { id, rev });
58
+ }
59
+ }
60
+
61
+ export interface ContextReadBulkEventDetail {
62
+ /**
63
+ * The list of ids to read.
64
+ */
65
+ ids: string[];
66
+ }
67
+
68
+ /**
69
+ * An event to be used to read a list of object from the API store.
70
+ */
71
+ export class ContextReadBulkEvent<T> extends ContextEvent<ContextReadBulkEventDetail, T> {
72
+ /**
73
+ * @param type The type of the event
74
+ * @param ids The list of domain ids to read. These must be of the same domain type.
75
+ */
76
+ constructor(type: string, ids: string[]) {
77
+ super(type, { ids });
78
+ }
79
+ }
80
+
81
+ /**
82
+ * A general purpose change record.
83
+ * Set on the `detail` object of the `CustomEvent` when a change occurs in the context store.
84
+ */
85
+ export interface ContextChangeRecord<T> {
86
+ /**
87
+ * The data kind of the changed item.
88
+ * May not be present when this is used with the old architecture.
89
+ */
90
+ kind?: string;
91
+ /**
92
+ * The ID of the changed context state object.
93
+ */
94
+ key: string;
95
+ /**
96
+ * The revision of the updated context state object.
97
+ * It is not set when old revision is unavailable (new entity is created) or when the context provider does not support this value.
98
+ */
99
+ oldRev?: string;
100
+ /**
101
+ * New revision of updated state object. May not be set when the context provider does not support this value.
102
+ */
103
+ rev?: string;
104
+ /**
105
+ * The updated context state object.
106
+ */
107
+ item?: T;
108
+ /**
109
+ * Optionally, when relevant, the id of the parent of the changed object.
110
+ */
111
+ parent?: string;
112
+ }
113
+
114
+ export interface ContextDeleteEventDetail {
115
+ /**
116
+ * The id of the domain object to remove.
117
+ */
118
+ id: string;
119
+ /**
120
+ * The id of the parent object, if applicable.
121
+ */
122
+ parent?: string;
123
+ /**
124
+ * The revision to delete, when applicable.
125
+ */
126
+ rev?: string;
127
+ }
128
+
129
+ /**
130
+ * An event to be used to delete a state in the context provider.
131
+ */
132
+ export class ContextDeleteEvent extends ContextEvent<ContextDeleteEventDetail, ContextDeleteRecord> {
133
+ /**
134
+ * @param type The type of the event to dispatch.
135
+ * @param id The id of the object to delete
136
+ * @param parent The id of the parent object, if applicable.
137
+ */
138
+ constructor(type: string, id: string, parent?: string, rev?: string) {
139
+ super(type, { id, parent, rev });
140
+ }
141
+ }
142
+
143
+ export interface ContextDeleteRecord {
144
+ /**
145
+ * The data kind of the deleted item.
146
+ * May not be present when this is used with the old architecture.
147
+ */
148
+ kind?: string;
149
+ /**
150
+ * The id of the removed object.
151
+ */
152
+ id: string;
153
+ /**
154
+ * The id of the parent object, if applicable.
155
+ */
156
+ parent?: string;
157
+ }
158
+
159
+ /**
160
+ * An event dispatched when a context store object has been deleted.
161
+ * In general a single context store uses the same event to dispatch the change record.
162
+ * For example the `data-store` dispatches the `x` event and the change record has the
163
+ * `kind` property that is used to recognize the type of the data object.
164
+ */
165
+ export class ContextStateDeleteEvent extends CustomEvent<ContextDeleteRecord> {
166
+ /**
167
+ * @param type The type of the event to dispatch.
168
+ * @param record The delete record.
169
+ */
170
+ constructor(type: string, record: ContextDeleteRecord) {
171
+ super(type, {
172
+ bubbles: true,
173
+ composed: true,
174
+ cancelable: false,
175
+ detail: record,
176
+ });
177
+ }
178
+ }
179
+
180
+ /**
181
+ * An event dispatched when a context store object has been updated.
182
+ */
183
+ export class ContextStateUpdateEvent<T> extends CustomEvent<ContextChangeRecord<T>> {
184
+ /**
185
+ * @param type The type of the event to dispatch.
186
+ * @param record The delete record.
187
+ */
188
+ constructor(type: string, record: ContextChangeRecord<T>) {
189
+ super(type, {
190
+ bubbles: true,
191
+ composed: true,
192
+ cancelable: false,
193
+ detail: record,
194
+ });
195
+ }
196
+ }
197
+
198
+ export interface ContextUpdateEventDetail<T> {
199
+ /**
200
+ * The context store object to be updated by the context provider.
201
+ */
202
+ item: T;
203
+ /**
204
+ * The id of the parent object, if applicable.
205
+ */
206
+ parent?: string;
207
+ }
208
+
209
+ /**
210
+ * An event that is dispatched to update the entire object in the store.
211
+ * This is equivalent to PUT operation in REST HTTP.
212
+ *
213
+ * @template T The object that is being updated.
214
+ */
215
+ export class ContextUpdateEvent<T extends object> extends ContextEvent<ContextUpdateEventDetail<T>, ContextChangeRecord<T>> {
216
+ constructor(type: string, updateInfo: ContextUpdateEventDetail<T>) {
217
+ super(type, updateInfo);
218
+ }
219
+ }
220
+
221
+ /**
222
+ * Data store query result object.
223
+ */
224
+ export interface ContextListResult<T> {
225
+ /**
226
+ * Next page token to be used with pagination.
227
+ * It is not set when the query has not returned any results.
228
+ */
229
+ nextPageToken?: string;
230
+ /**
231
+ * The list of items in the response.
232
+ * May be empty array when there was no more results.
233
+ */
234
+ items: T[];
235
+ }
236
+
237
+ /**
238
+ * Base query options for the data store.
239
+ */
240
+ export interface ContextListOptions {
241
+ /**
242
+ * The number of results per the page.
243
+ */
244
+ limit?: number;
245
+ /**
246
+ * A string that should be used with the pagination.
247
+ */
248
+ nextPageToken?: string;
249
+ }
250
+
251
+ export class ContextListEvent<T> extends ContextEvent<ContextListOptions, ContextListResult<T>> {
252
+ /**
253
+ * @param type The type of the event
254
+ * @param opts Query options.
255
+ */
256
+ constructor(type: string, opts: ContextListOptions = {}) {
257
+ super(type, opts);
258
+ }
259
+ }
@@ -0,0 +1,27 @@
1
+ var ctor: typeof CustomEvent;
2
+
3
+ if (typeof CustomEvent === 'function') {
4
+ ctor = CustomEvent;
5
+ } else {
6
+ const detailSymbol = Symbol('detail');
7
+ ctor = class CustomEvent<T> extends Event {
8
+ [detailSymbol]: T;
9
+
10
+ get detail(): T {
11
+ return this[detailSymbol];
12
+ }
13
+
14
+ constructor(type: string, eventInitDict?: CustomEventInit | undefined) {
15
+ super(type, eventInitDict);
16
+ if (eventInitDict && eventInitDict.detail) {
17
+ this[detailSymbol] = eventInitDict.detail;
18
+ }
19
+ }
20
+
21
+ initCustomEvent(type: string, bubbles?: boolean, cancelable?: boolean, detail?: T): void {
22
+ throw new Error(`This is deprecated. Do not use this function.`);
23
+ }
24
+ }
25
+ }
26
+
27
+ export default ctor;
@@ -0,0 +1,19 @@
1
+ import { ModelEventTypes } from './models/ModelEventTypes.js';
2
+ import { CookieEventTypes } from './cookies/CookieEventTypes.js';
3
+ import { AuthorizationEventTypes } from './authorization/AuthorizationEventTypes.js';
4
+ import { EncryptionEventTypes } from './encryption/EncryptionEventTypes.js';
5
+ import { ProcessEventTypes } from './process/ProcessEventTypes.js';
6
+ import { ReportingEventTypes } from './reporting/ReportingEventTypes.js';
7
+ import { TelemetryEventTypes } from './telemetry/TelemetryEventTypes.js';
8
+ import { EnvironmentEventTypes } from './environment/EnvironmentEventTypes.js';
9
+
10
+ export const EventTypes = Object.freeze({
11
+ Authorization: AuthorizationEventTypes,
12
+ Cookie: CookieEventTypes,
13
+ Encryption: EncryptionEventTypes,
14
+ Model: ModelEventTypes,
15
+ Process: ProcessEventTypes,
16
+ Reporting: ReportingEventTypes,
17
+ Telemetry: TelemetryEventTypes,
18
+ Environment: EnvironmentEventTypes,
19
+ });
@@ -0,0 +1,19 @@
1
+ import { ModelEvents } from './models/ModelEvents.js';
2
+ import { CookieEvents } from './cookies/CookieEvents.js';
3
+ import { AuthorizationEvents } from './authorization/AuthorizationEvents.js';
4
+ import { EncryptionEvents } from './encryption/EncryptionEvents.js';
5
+ import { ProcessEvents } from './process/ProcessEvents.js';
6
+ import { ReportingEvents } from './reporting/ReportingEvents.js';
7
+ import { TelemetryEvents } from './telemetry/TelemetryEvents.js';
8
+ import { EnvironmentEvents } from './environment/EnvironmentEvents.js';
9
+
10
+ export const Events = Object.freeze({
11
+ Authorization: AuthorizationEvents,
12
+ Cookie: CookieEvents,
13
+ Encryption: EncryptionEvents,
14
+ Model: ModelEvents,
15
+ Process: ProcessEvents,
16
+ Reporting: ReportingEvents,
17
+ Telemetry: TelemetryEvents,
18
+ Environment: EnvironmentEvents,
19
+ });
@@ -0,0 +1,22 @@
1
+ export const AuthorizationEventTypes = Object.freeze({
2
+ OAuth2: Object.freeze({
3
+ /**
4
+ * Authorization with auth configuration on detail
5
+ */
6
+ authorize: 'oauth2authorize',
7
+ /**
8
+ * Removes cached token for the provider
9
+ */
10
+ removeToken: 'oauth2removetoken',
11
+ }),
12
+ Oidc: Object.freeze({
13
+ /**
14
+ * Authorization the user with the provided configuration.
15
+ */
16
+ authorize: 'oidcauthorize',
17
+ /**
18
+ * Removes cached tokens for the provider
19
+ */
20
+ removeTokens: 'oidcremovetokens',
21
+ }),
22
+ });
@@ -0,0 +1,61 @@
1
+ import { IOAuth2Authorization, ITokenRemoveOptions, IOidcTokenInfo, IOidcTokenError, ITokenInfo } from '../../models/Authorization.js';
2
+ import { AuthorizationEventTypes } from './AuthorizationEventTypes.js';
3
+ import { ContextEvent } from "../BaseEvents.js";
4
+
5
+ export class AuthorizationEvents {
6
+ static get OAuth2(): typeof OAuth2Events {
7
+ return OAuth2Events;
8
+ }
9
+
10
+ static get Oidc(): typeof OidcEvents {
11
+ return OidcEvents;
12
+ }
13
+ }
14
+
15
+ class OAuth2Events {
16
+ /**
17
+ * @param target A node on which to dispatch the event.
18
+ * @param config Authorization options.
19
+ * @returns Promise resolved with authorization result
20
+ */
21
+ static async authorize(target: EventTarget, config: IOAuth2Authorization): Promise<ITokenInfo | undefined> {
22
+ const e = new ContextEvent<IOAuth2Authorization, ITokenInfo>(AuthorizationEventTypes.OAuth2.authorize, config);
23
+ target.dispatchEvent(e);
24
+ return e.detail.result;
25
+ }
26
+
27
+ /**
28
+ * @param target A node on which to dispatch the event.
29
+ * @param config Authorization options.
30
+ * @returns Promise resolved when the token is removed
31
+ */
32
+ static async removeToken(target: EventTarget, config: ITokenRemoveOptions): Promise<void> {
33
+ const e = new ContextEvent<ITokenRemoveOptions, void>(AuthorizationEventTypes.OAuth2.removeToken, config);
34
+ target.dispatchEvent(e);
35
+ return e.detail.result;
36
+ }
37
+ }
38
+
39
+ class OidcEvents {
40
+ /**
41
+ * @param target A node on which to dispatch the event.
42
+ * @param config Authorization options.
43
+ * @returns Promise resolved with authorization result
44
+ */
45
+ static async authorize(target: EventTarget, config: IOAuth2Authorization): Promise<(IOidcTokenInfo|IOidcTokenError)[] | undefined> {
46
+ const e = new ContextEvent<IOAuth2Authorization, (IOidcTokenInfo|IOidcTokenError)[]>(AuthorizationEventTypes.Oidc.authorize, config);
47
+ target.dispatchEvent(e);
48
+ return e.detail.result;
49
+ }
50
+
51
+ /**
52
+ * @param target A node on which to dispatch the event.
53
+ * @param config Authorization options.
54
+ * @returns Promise resolved when the token is removed
55
+ */
56
+ static async removeToken(target: EventTarget, config: ITokenRemoveOptions): Promise<void> {
57
+ const e = new ContextEvent<ITokenRemoveOptions, void>(AuthorizationEventTypes.Oidc.removeTokens, config);
58
+ target.dispatchEvent(e);
59
+ return e.detail.result;
60
+ }
61
+ }
@@ -0,0 +1,13 @@
1
+ export const CookieEventTypes = Object.freeze({
2
+ listAll: 'sessioncookielistall',
3
+ listDomain: 'sessioncookielistdomain',
4
+ listUrl: 'sessioncookielisturl',
5
+ delete: 'sessioncookiedelete',
6
+ deleteUrl: 'sessioncookiedeleteurl',
7
+ update: 'sessioncookieupdate',
8
+ updateBulk: 'sessioncookieupdatebulk',
9
+ State: Object.freeze({
10
+ delete: 'sessioncookiestatedelete',
11
+ update: 'sessioncookiestateupdate',
12
+ }),
13
+ });
@@ -0,0 +1,157 @@
1
+ import { CookieEventTypes } from './CookieEventTypes.js';
2
+ import { IHttpCookie } from "../../models/HttpCookie.js";
3
+ import { ContextEventDetailWithResult, ContextEvent, ContextChangeRecord, ContextUpdateEvent, ContextStateUpdateEvent } from "../BaseEvents.js";
4
+
5
+ export interface ICookieDomainListDetail {
6
+ domain: string;
7
+ }
8
+
9
+ export interface ICookieUrlListDetail {
10
+ url: string;
11
+ }
12
+
13
+ export interface ICookieItemsDetail {
14
+ cookies: IHttpCookie[];
15
+ }
16
+
17
+ export interface ICookieDetail {
18
+ cookie: IHttpCookie;
19
+ }
20
+
21
+ export interface ICookieDeleteUrlDetail {
22
+ url: string;
23
+ name?: string
24
+ }
25
+
26
+ export class CookieEvents {
27
+ /**
28
+ * Lists all projects in the data store.
29
+ * This does not return the whole project record. Instead it only returns the index object of the project.
30
+ *
31
+ * @param target The target on which to dispatch the event
32
+ * @returns The list of project index objects.
33
+ */
34
+ static async listAll(target: EventTarget): Promise<IHttpCookie[] | undefined> {
35
+ const detail: ContextEventDetailWithResult<IHttpCookie[]> = {};
36
+ const e = new CustomEvent(CookieEventTypes.listAll, {
37
+ bubbles: true,
38
+ composed: true,
39
+ cancelable: true,
40
+ detail,
41
+ });
42
+ target.dispatchEvent(e);
43
+ return e.detail.result;
44
+ }
45
+
46
+ /**
47
+ * @param target The target on which to dispatch the event
48
+ * @param domain The cookie domain
49
+ * @returns The list of project index objects.
50
+ */
51
+ static async listDomain(target: EventTarget, domain: string): Promise<IHttpCookie[] | undefined> {
52
+ const detail: ICookieDomainListDetail = { domain };
53
+ const e = new ContextEvent<ICookieDomainListDetail, IHttpCookie[]>(CookieEventTypes.listDomain, detail);
54
+ target.dispatchEvent(e);
55
+ return e.detail.result;
56
+ }
57
+
58
+ /**
59
+ * @param target The target on which to dispatch the event
60
+ * @param url The cookie URL
61
+ * @returns The list of project index objects.
62
+ */
63
+ static async listUrl(target: EventTarget, url: string): Promise<IHttpCookie[] | undefined> {
64
+ const detail: ICookieUrlListDetail = { url };
65
+ const e = new ContextEvent<ICookieUrlListDetail, IHttpCookie[]>(CookieEventTypes.listUrl, detail);
66
+ target.dispatchEvent(e);
67
+ return e.detail.result;
68
+ }
69
+
70
+ /**
71
+ * Deletes cookies from the store.
72
+ *
73
+ * @param target The target on which to dispatch the event
74
+ * @param cookies The list of cookies to remove
75
+ */
76
+ static async delete(target: EventTarget, cookies: IHttpCookie[]): Promise<void> {
77
+ const detail: ICookieItemsDetail = { cookies };
78
+ const e = new ContextEvent<ICookieItemsDetail, void>(CookieEventTypes.delete, detail);
79
+ target.dispatchEvent(e);
80
+ return e.detail.result;
81
+ }
82
+
83
+ /**
84
+ * Deletes cookies from the store.
85
+ *
86
+ * @param target The target on which to dispatch the event
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
+ * @param name The name of the cookie to remove. When not set all cookies are removed for the given URL.
89
+ */
90
+ static async deleteUrl(target: EventTarget, url: string, name?: string): Promise<void> {
91
+ const detail: ICookieDeleteUrlDetail = { url, name };
92
+ const e = new ContextEvent<ICookieDeleteUrlDetail, void>(CookieEventTypes.deleteUrl, detail);
93
+ target.dispatchEvent(e);
94
+ return e.detail.result;
95
+ }
96
+
97
+ /**
98
+ * Updates a cookie in the store.
99
+ *
100
+ * @param target The target on which to dispatch the event
101
+ * @param cookie A cookie to update
102
+ * @returns The change record of the updated cookie.
103
+ */
104
+ static async update(target: EventTarget, cookie: IHttpCookie): Promise<ContextChangeRecord<IHttpCookie> | undefined> {
105
+ const e = new ContextUpdateEvent(CookieEventTypes.update, { item: cookie });
106
+ target.dispatchEvent(e);
107
+ return e.detail.result;
108
+ }
109
+
110
+ /**
111
+ * Updates a cookie in the store in a bulk operation.
112
+ *
113
+ * @param target The target on which to dispatch the event
114
+ * @param cookies A list of cookies to update
115
+ * @returns The change record of the updated cookie.
116
+ */
117
+ static async updateBulk(target: EventTarget, cookies: IHttpCookie[]): Promise<void> {
118
+ const detail: ICookieItemsDetail = { cookies };
119
+ const e = new ContextEvent<ICookieItemsDetail, void>(CookieEventTypes.updateBulk, detail);
120
+ target.dispatchEvent(e);
121
+ return e.detail.result;
122
+ }
123
+
124
+ /**
125
+ * Events related to a state of a cookie store.
126
+ */
127
+ static get State(): typeof StateEvents {
128
+ return StateEvents;
129
+ }
130
+ }
131
+
132
+ class StateEvents {
133
+ /**
134
+ * Event dispatched when a cookie was deleted from the context store
135
+ * @param target The target on which to dispatch the event
136
+ * @param cookie The schema of the removed cookie
137
+ */
138
+ static delete(target: EventTarget, cookie: IHttpCookie): void {
139
+ const e = new CustomEvent<ICookieDetail>(CookieEventTypes.State.delete, {
140
+ bubbles: true,
141
+ composed: true,
142
+ cancelable: false,
143
+ detail: { cookie },
144
+ });
145
+ target.dispatchEvent(e);
146
+ }
147
+
148
+ /**
149
+ * Event dispatched when a cookie was deleted from the context store
150
+ * @param target The target on which to dispatch the event
151
+ * @param record The change record.
152
+ */
153
+ static update(target: EventTarget, record: ContextChangeRecord<IHttpCookie>): void {
154
+ const e = new ContextStateUpdateEvent<IHttpCookie>(CookieEventTypes.State.update, record);
155
+ target.dispatchEvent(e);
156
+ }
157
+ }
@@ -0,0 +1,4 @@
1
+ export const EncryptionEventTypes = Object.freeze({
2
+ encrypt: 'encryptionencrypt',
3
+ decrypt: 'encryptiondecrypt',
4
+ });
@@ -0,0 +1,51 @@
1
+ import { EncryptionEventTypes } from './EncryptionEventTypes.js';
2
+ import { ContextEvent } from "../BaseEvents.js";
3
+
4
+ export interface IEncryptionEventDetail {
5
+ /**
6
+ * The data to export
7
+ */
8
+ data: any;
9
+ /**
10
+ * The passphrase to use in 2-way data encryption
11
+ */
12
+ passphrase: string;
13
+ /**
14
+ * Encryption method to use
15
+ */
16
+ method: string;
17
+ }
18
+
19
+ export class EncryptionEvents {
20
+ /**
21
+ * Dispatches an event handled by the encryption module to encrypt the data
22
+ *
23
+ * @param target A node on which to dispatch the event.
24
+ * @param data The data to encrypt
25
+ * @param passphrase The passphrase to use in 2-way data encryption
26
+ * @param method Encryption method to use
27
+ * @returns Promise resolved to the encryption result
28
+ */
29
+ static async encrypt(target: EventTarget, data: any, passphrase: string, method: string): Promise<string | undefined> {
30
+ const config: IEncryptionEventDetail = { data, passphrase, method };
31
+ const e = new ContextEvent<IEncryptionEventDetail, string>(EncryptionEventTypes.encrypt, config);
32
+ target.dispatchEvent(e);
33
+ return e.detail.result;
34
+ }
35
+
36
+ /**
37
+ * Dispatches an event handled by the encryption module to decrypt the data
38
+ *
39
+ * @param target A node on which to dispatch the event.
40
+ * @param data The data to decrypt
41
+ * @param passphrase The passphrase to use to decrypt the data
42
+ * @param method Method used to encrypt the data
43
+ * @returns Promise resolved to the decrypted result
44
+ */
45
+ static async decrypt(target: EventTarget, data: any, passphrase: string, method: string): Promise<string | undefined> {
46
+ const config: IEncryptionEventDetail = { data, passphrase, method };
47
+ const e = new ContextEvent<IEncryptionEventDetail, string>(EncryptionEventTypes.decrypt, config);
48
+ target.dispatchEvent(e);
49
+ return e.detail.result;
50
+ }
51
+ }
@@ -0,0 +1,3 @@
1
+ export const EnvironmentEventTypes = Object.freeze({
2
+ set: 'environmentsetvariable',
3
+ });
@@ -0,0 +1,24 @@
1
+ import { EnvironmentEventTypes } from './EnvironmentEventTypes.js';
2
+ import { ContextEvent } from "../BaseEvents.js";
3
+
4
+ export interface ISetVariableDetail {
5
+ name: string;
6
+ value: string;
7
+ }
8
+
9
+ export class EnvironmentEvents {
10
+ /**
11
+ * An event dispatched to set a variable in the current environment.
12
+ *
13
+ * @param target A node on which to dispatch the event.
14
+ * @param name Variable name
15
+ * @param value Variable value
16
+ * @returns Nothing. The promise resolves when the variable is set.
17
+ */
18
+ static async set(target: EventTarget, name: string, value: string): Promise<void> {
19
+ const detail: ISetVariableDetail = { name, value };
20
+ const e = new ContextEvent<ISetVariableDetail, void>(EnvironmentEventTypes.set, detail);
21
+ target.dispatchEvent(e);
22
+ return e.detail.result;
23
+ }
24
+ }