@emuanalytics/flow-engine-client 2.1.0 → 2.2.0

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 (164) hide show
  1. package/dist/bundle.js +9 -3
  2. package/dist/index.cjs +1 -0
  3. package/dist/index.d.cts +668 -0
  4. package/dist/index.d.mts +668 -0
  5. package/dist/index.d.ts +668 -0
  6. package/dist/index.mjs +1 -0
  7. package/package.json +33 -40
  8. package/dist/bundle.js.map +0 -7
  9. package/dist/cjs/index.js +0 -25
  10. package/dist/cjs/index.js.map +0 -1
  11. package/dist/cjs/lib/__mocks__/client.js +0 -57
  12. package/dist/cjs/lib/__mocks__/client.js.map +0 -1
  13. package/dist/cjs/lib/api-interfaces.js +0 -6
  14. package/dist/cjs/lib/api-interfaces.js.map +0 -1
  15. package/dist/cjs/lib/apikey.endpoints.js +0 -31
  16. package/dist/cjs/lib/apikey.endpoints.js.map +0 -1
  17. package/dist/cjs/lib/appconfig.endpoints.js +0 -49
  18. package/dist/cjs/lib/appconfig.endpoints.js.map +0 -1
  19. package/dist/cjs/lib/application.endpoints.js +0 -31
  20. package/dist/cjs/lib/application.endpoints.js.map +0 -1
  21. package/dist/cjs/lib/auth.edpoints.js +0 -60
  22. package/dist/cjs/lib/auth.edpoints.js.map +0 -1
  23. package/dist/cjs/lib/base.endpoints.js +0 -78
  24. package/dist/cjs/lib/base.endpoints.js.map +0 -1
  25. package/dist/cjs/lib/client.js +0 -198
  26. package/dist/cjs/lib/client.js.map +0 -1
  27. package/dist/cjs/lib/contact-point.endpoints.js +0 -46
  28. package/dist/cjs/lib/contact-point.endpoints.js.map +0 -1
  29. package/dist/cjs/lib/database.endpoints.js +0 -39
  30. package/dist/cjs/lib/database.endpoints.js.map +0 -1
  31. package/dist/cjs/lib/dataset.endpoints.js +0 -88
  32. package/dist/cjs/lib/dataset.endpoints.js.map +0 -1
  33. package/dist/cjs/lib/errors.js +0 -36
  34. package/dist/cjs/lib/errors.js.map +0 -1
  35. package/dist/cjs/lib/job.endpoints.js +0 -46
  36. package/dist/cjs/lib/job.endpoints.js.map +0 -1
  37. package/dist/cjs/lib/map.endoints.js +0 -18
  38. package/dist/cjs/lib/map.endoints.js.map +0 -1
  39. package/dist/cjs/lib/maplayer.endpoints.js +0 -34
  40. package/dist/cjs/lib/maplayer.endpoints.js.map +0 -1
  41. package/dist/cjs/lib/media.endpoints.js +0 -106
  42. package/dist/cjs/lib/media.endpoints.js.map +0 -1
  43. package/dist/cjs/lib/pipeline-component.endpoints.js +0 -37
  44. package/dist/cjs/lib/pipeline-component.endpoints.js.map +0 -1
  45. package/dist/cjs/lib/pipeline-metric.endpoint.js +0 -31
  46. package/dist/cjs/lib/pipeline-metric.endpoint.js.map +0 -1
  47. package/dist/cjs/lib/pipeline.endpoints.js +0 -87
  48. package/dist/cjs/lib/pipeline.endpoints.js.map +0 -1
  49. package/dist/cjs/lib/style.endpoint.js +0 -31
  50. package/dist/cjs/lib/style.endpoint.js.map +0 -1
  51. package/dist/cjs/lib/tile-source.endpoints.js +0 -39
  52. package/dist/cjs/lib/tile-source.endpoints.js.map +0 -1
  53. package/dist/cjs/lib/tile.endpoints.js +0 -22
  54. package/dist/cjs/lib/tile.endpoints.js.map +0 -1
  55. package/dist/cjs/lib/upload.endpoints.js +0 -121
  56. package/dist/cjs/lib/upload.endpoints.js.map +0 -1
  57. package/dist/cjs/lib/user.endpoints.js +0 -36
  58. package/dist/cjs/lib/user.endpoints.js.map +0 -1
  59. package/dist/cjs/lib/web-socket-gateway.js +0 -160
  60. package/dist/cjs/lib/web-socket-gateway.js.map +0 -1
  61. package/dist/esm/index.js +0 -9
  62. package/dist/esm/index.js.map +0 -1
  63. package/dist/esm/lib/__mocks__/client.js +0 -54
  64. package/dist/esm/lib/__mocks__/client.js.map +0 -1
  65. package/dist/esm/lib/api-interfaces.js +0 -5
  66. package/dist/esm/lib/api-interfaces.js.map +0 -1
  67. package/dist/esm/lib/apikey.endpoints.js +0 -28
  68. package/dist/esm/lib/apikey.endpoints.js.map +0 -1
  69. package/dist/esm/lib/appconfig.endpoints.js +0 -46
  70. package/dist/esm/lib/appconfig.endpoints.js.map +0 -1
  71. package/dist/esm/lib/application.endpoints.js +0 -28
  72. package/dist/esm/lib/application.endpoints.js.map +0 -1
  73. package/dist/esm/lib/auth.edpoints.js +0 -57
  74. package/dist/esm/lib/auth.edpoints.js.map +0 -1
  75. package/dist/esm/lib/base.endpoints.js +0 -75
  76. package/dist/esm/lib/base.endpoints.js.map +0 -1
  77. package/dist/esm/lib/client.js +0 -192
  78. package/dist/esm/lib/client.js.map +0 -1
  79. package/dist/esm/lib/contact-point.endpoints.js +0 -43
  80. package/dist/esm/lib/contact-point.endpoints.js.map +0 -1
  81. package/dist/esm/lib/database.endpoints.js +0 -36
  82. package/dist/esm/lib/database.endpoints.js.map +0 -1
  83. package/dist/esm/lib/dataset.endpoints.js +0 -85
  84. package/dist/esm/lib/dataset.endpoints.js.map +0 -1
  85. package/dist/esm/lib/errors.js +0 -33
  86. package/dist/esm/lib/errors.js.map +0 -1
  87. package/dist/esm/lib/job.endpoints.js +0 -43
  88. package/dist/esm/lib/job.endpoints.js.map +0 -1
  89. package/dist/esm/lib/map.endoints.js +0 -15
  90. package/dist/esm/lib/map.endoints.js.map +0 -1
  91. package/dist/esm/lib/maplayer.endpoints.js +0 -31
  92. package/dist/esm/lib/maplayer.endpoints.js.map +0 -1
  93. package/dist/esm/lib/media.endpoints.js +0 -100
  94. package/dist/esm/lib/media.endpoints.js.map +0 -1
  95. package/dist/esm/lib/pipeline-component.endpoints.js +0 -34
  96. package/dist/esm/lib/pipeline-component.endpoints.js.map +0 -1
  97. package/dist/esm/lib/pipeline-metric.endpoint.js +0 -28
  98. package/dist/esm/lib/pipeline-metric.endpoint.js.map +0 -1
  99. package/dist/esm/lib/pipeline.endpoints.js +0 -84
  100. package/dist/esm/lib/pipeline.endpoints.js.map +0 -1
  101. package/dist/esm/lib/style.endpoint.js +0 -28
  102. package/dist/esm/lib/style.endpoint.js.map +0 -1
  103. package/dist/esm/lib/tile-source.endpoints.js +0 -36
  104. package/dist/esm/lib/tile-source.endpoints.js.map +0 -1
  105. package/dist/esm/lib/tile.endpoints.js +0 -19
  106. package/dist/esm/lib/tile.endpoints.js.map +0 -1
  107. package/dist/esm/lib/upload.endpoints.js +0 -115
  108. package/dist/esm/lib/upload.endpoints.js.map +0 -1
  109. package/dist/esm/lib/user.endpoints.js +0 -33
  110. package/dist/esm/lib/user.endpoints.js.map +0 -1
  111. package/dist/esm/lib/web-socket-gateway.js +0 -157
  112. package/dist/esm/lib/web-socket-gateway.js.map +0 -1
  113. package/dist/types/index.d.ts +0 -9
  114. package/dist/types/index.d.ts.map +0 -1
  115. package/dist/types/lib/__mocks__/client.d.ts +0 -3
  116. package/dist/types/lib/__mocks__/client.d.ts.map +0 -1
  117. package/dist/types/lib/api-interfaces.d.ts +0 -314
  118. package/dist/types/lib/api-interfaces.d.ts.map +0 -1
  119. package/dist/types/lib/apikey.endpoints.d.ts +0 -10
  120. package/dist/types/lib/apikey.endpoints.d.ts.map +0 -1
  121. package/dist/types/lib/appconfig.endpoints.d.ts +0 -15
  122. package/dist/types/lib/appconfig.endpoints.d.ts.map +0 -1
  123. package/dist/types/lib/application.endpoints.d.ts +0 -10
  124. package/dist/types/lib/application.endpoints.d.ts.map +0 -1
  125. package/dist/types/lib/auth.edpoints.d.ts +0 -20
  126. package/dist/types/lib/auth.edpoints.d.ts.map +0 -1
  127. package/dist/types/lib/base.endpoints.d.ts +0 -20
  128. package/dist/types/lib/base.endpoints.d.ts.map +0 -1
  129. package/dist/types/lib/client.d.ts +0 -68
  130. package/dist/types/lib/client.d.ts.map +0 -1
  131. package/dist/types/lib/contact-point.endpoints.d.ts +0 -20
  132. package/dist/types/lib/contact-point.endpoints.d.ts.map +0 -1
  133. package/dist/types/lib/database.endpoints.d.ts +0 -11
  134. package/dist/types/lib/database.endpoints.d.ts.map +0 -1
  135. package/dist/types/lib/dataset.endpoints.d.ts +0 -26
  136. package/dist/types/lib/dataset.endpoints.d.ts.map +0 -1
  137. package/dist/types/lib/errors.d.ts +0 -9
  138. package/dist/types/lib/errors.d.ts.map +0 -1
  139. package/dist/types/lib/job.endpoints.d.ts +0 -15
  140. package/dist/types/lib/job.endpoints.d.ts.map +0 -1
  141. package/dist/types/lib/map.endoints.d.ts +0 -11
  142. package/dist/types/lib/map.endoints.d.ts.map +0 -1
  143. package/dist/types/lib/maplayer.endpoints.d.ts +0 -12
  144. package/dist/types/lib/maplayer.endpoints.d.ts.map +0 -1
  145. package/dist/types/lib/media.endpoints.d.ts +0 -20
  146. package/dist/types/lib/media.endpoints.d.ts.map +0 -1
  147. package/dist/types/lib/pipeline-component.endpoints.d.ts +0 -13
  148. package/dist/types/lib/pipeline-component.endpoints.d.ts.map +0 -1
  149. package/dist/types/lib/pipeline-metric.endpoint.d.ts +0 -10
  150. package/dist/types/lib/pipeline-metric.endpoint.d.ts.map +0 -1
  151. package/dist/types/lib/pipeline.endpoints.d.ts +0 -14
  152. package/dist/types/lib/pipeline.endpoints.d.ts.map +0 -1
  153. package/dist/types/lib/style.endpoint.d.ts +0 -10
  154. package/dist/types/lib/style.endpoint.d.ts.map +0 -1
  155. package/dist/types/lib/tile-source.endpoints.d.ts +0 -11
  156. package/dist/types/lib/tile-source.endpoints.d.ts.map +0 -1
  157. package/dist/types/lib/tile.endpoints.d.ts +0 -12
  158. package/dist/types/lib/tile.endpoints.d.ts.map +0 -1
  159. package/dist/types/lib/upload.endpoints.d.ts +0 -22
  160. package/dist/types/lib/upload.endpoints.d.ts.map +0 -1
  161. package/dist/types/lib/user.endpoints.d.ts +0 -11
  162. package/dist/types/lib/user.endpoints.d.ts.map +0 -1
  163. package/dist/types/lib/web-socket-gateway.d.ts +0 -42
  164. package/dist/types/lib/web-socket-gateway.d.ts.map +0 -1
@@ -0,0 +1,668 @@
1
+ import Debug from 'debug';
2
+ import { Socket, ManagerOptions, SocketOptions } from 'socket.io-client';
3
+
4
+ /**
5
+ * Copyright © 2018 Emu Analytics
6
+ */
7
+ interface IQuery {
8
+ filter?: {
9
+ [key: string]: any;
10
+ };
11
+ attributes?: string | string[];
12
+ join?: string | string[];
13
+ limit?: number;
14
+ offset?: number;
15
+ sort?: string | string[];
16
+ }
17
+ interface IBaseResource {
18
+ id: string;
19
+ }
20
+ interface IMetadata {
21
+ [key: string]: any;
22
+ }
23
+ interface IPermissions {
24
+ [key: string]: {
25
+ [key: string]: string;
26
+ };
27
+ }
28
+ interface IApiKey extends IBaseResource {
29
+ applicationId: string;
30
+ application?: IApplication;
31
+ id: string;
32
+ description: string;
33
+ type: 'app' | 'master';
34
+ permissions: IPermissions;
35
+ metadata: IMetadata;
36
+ userId: string;
37
+ createdAt: string;
38
+ updatedAt: string;
39
+ }
40
+ interface IApplication extends IBaseResource {
41
+ id: string;
42
+ name: string;
43
+ databases?: IDatabase[];
44
+ description: string;
45
+ contact: string;
46
+ metadata: IMetadata;
47
+ createdAt: string;
48
+ updatedAt: string;
49
+ }
50
+ interface IAppConfig extends IBaseResource {
51
+ applicationId: string;
52
+ config: object;
53
+ }
54
+ interface IDatabase extends IBaseResource {
55
+ applicationId: string;
56
+ application?: IApplication;
57
+ id: string;
58
+ type: string;
59
+ name: string;
60
+ default: boolean;
61
+ description: string;
62
+ host: string;
63
+ port: number;
64
+ user: string;
65
+ password: string;
66
+ db: string;
67
+ createdAt: string;
68
+ updatedAt: string;
69
+ }
70
+ interface IDatasetAttribute {
71
+ attribute: string;
72
+ type: string;
73
+ dbType: string;
74
+ isGeometry?: boolean;
75
+ srid?: number;
76
+ extent?: number[];
77
+ extentLngLat?: number[];
78
+ primaryKey?: boolean;
79
+ default?: string;
80
+ nullable?: boolean;
81
+ description?: string;
82
+ }
83
+ interface IDataset extends IBaseResource {
84
+ applicationId: string;
85
+ application?: IApplication;
86
+ id: string;
87
+ type: 'table' | 'sql';
88
+ source: string;
89
+ name: string;
90
+ databaseId: string;
91
+ database?: IDatabase;
92
+ description: string;
93
+ bytes: number;
94
+ metadata: IMetadata;
95
+ ownerId: string;
96
+ createdAt: string;
97
+ updatedAt: string;
98
+ attributes: IDatasetAttribute[];
99
+ options?: {
100
+ [key: string]: any;
101
+ };
102
+ }
103
+ interface IMapLayer extends IBaseResource {
104
+ applicationId: string;
105
+ application?: IApplication;
106
+ ownerId: string;
107
+ createdAt: string;
108
+ updatedAt: string;
109
+ id: string;
110
+ name: string;
111
+ description: string;
112
+ layerSpec: any;
113
+ type: string;
114
+ group: string;
115
+ metadata: IMetadata;
116
+ }
117
+ type FileExportFormat = 'geojson' | 'gpkg' | 'shapefile';
118
+ interface ITileSource extends IBaseResource {
119
+ applicationId: string;
120
+ application?: IApplication;
121
+ metadata: IMetadata;
122
+ id: string;
123
+ type: string;
124
+ source: string;
125
+ attribution: string;
126
+ minZoom: number;
127
+ maxZoom: number;
128
+ headers: {
129
+ [key: string]: string;
130
+ };
131
+ extentLngLat: number[];
132
+ createdAt: string;
133
+ updatedAt: string;
134
+ }
135
+ interface IUpload extends IBaseResource {
136
+ id: string;
137
+ fileName: string;
138
+ path: string;
139
+ options: {
140
+ name: string;
141
+ description?: string;
142
+ datasetId: string;
143
+ attribution?: string;
144
+ schema?: string;
145
+ };
146
+ size: number;
147
+ status: string;
148
+ error: {
149
+ message: string;
150
+ stdout: string;
151
+ stderr: string;
152
+ };
153
+ applicationId: string;
154
+ application?: IApplication;
155
+ ownerId: string;
156
+ updatedAt: string;
157
+ createdAt: string;
158
+ }
159
+ interface IUser extends IBaseResource {
160
+ [key: string]: any;
161
+ }
162
+ interface IStyle extends IBaseResource {
163
+ [key: string]: any;
164
+ }
165
+ interface ITileSpec {
166
+ [key: string]: any;
167
+ }
168
+ interface IConfig {
169
+ version: {
170
+ tag: string;
171
+ hash: string;
172
+ timestamp: number;
173
+ };
174
+ }
175
+ interface ILoginResponse {
176
+ accessToken: string;
177
+ refreshToken: string;
178
+ }
179
+ interface ITokenRefreshResponse {
180
+ accessToken: string;
181
+ }
182
+ interface UsersMeResponse {
183
+ applicationId: string;
184
+ email: string;
185
+ firstName: string;
186
+ id: string;
187
+ lastName: string;
188
+ metadata: object;
189
+ roles: string[];
190
+ }
191
+ type JobStatus = 'pending' | 'processing' | 'done' | 'cancelled' | 'error';
192
+ interface IJob {
193
+ id: string;
194
+ applicationId: string;
195
+ ownerId?: string;
196
+ metadata: IMetadata;
197
+ type: string;
198
+ name?: string;
199
+ description?: string;
200
+ params: any;
201
+ status: JobStatus;
202
+ error?: object;
203
+ progress?: number;
204
+ progressText?: string;
205
+ datasetId?: string;
206
+ createdAt: string;
207
+ updatedAt: string;
208
+ }
209
+ interface IJobStatus {
210
+ status?: JobStatus;
211
+ error?: object;
212
+ progress?: number;
213
+ progressText?: string;
214
+ }
215
+ interface IJobSubmission {
216
+ type: string;
217
+ name?: string;
218
+ description?: string;
219
+ params: any;
220
+ }
221
+ interface IJobRequest {
222
+ type: string;
223
+ }
224
+ type IngestAction = 'insert' | 'upsert' | 'delete';
225
+ interface IIngestMessage {
226
+ datasetId: string;
227
+ action: IngestAction;
228
+ data: any;
229
+ }
230
+ interface IPipeline extends IBaseResource {
231
+ applicationId: string;
232
+ application?: IApplication;
233
+ id: string;
234
+ environment: string;
235
+ description: string;
236
+ config: Record<string, any>;
237
+ metadata: IMetadata;
238
+ startedAt: string;
239
+ heartbeatAt: string;
240
+ createdAt: string;
241
+ updatedAt: string;
242
+ components?: IPipelineComponent[];
243
+ }
244
+ interface IPipelineComponent extends IBaseResource {
245
+ id: string;
246
+ description: string;
247
+ config: Record<string, any>;
248
+ class: string;
249
+ type: string;
250
+ metadata: IMetadata;
251
+ index: number;
252
+ createdAt: string;
253
+ updatedAt: string;
254
+ metrics?: IPipelineMetric[];
255
+ }
256
+ interface IPipelineMetric extends IBaseResource {
257
+ id: string;
258
+ applicationId: string;
259
+ pipelineId: string;
260
+ componentId: string;
261
+ name: string;
262
+ type: string;
263
+ timestamp: string;
264
+ value: number;
265
+ labels: Record<string, string>;
266
+ createdAt: string;
267
+ updatedAt: string;
268
+ }
269
+ /**
270
+ * Contact point resource.
271
+ */
272
+ interface IContactPoint extends IBaseResource {
273
+ id: string;
274
+ applicationId: string;
275
+ type: string;
276
+ description: string;
277
+ templates: string[];
278
+ recipients: string[];
279
+ /** Driver-specific host configuration for the contact point */
280
+ host: string;
281
+ /** Driver-specific port configuration for the contact point */
282
+ port: number;
283
+ /** Driver-specific user configuration for the contact point */
284
+ user: string;
285
+ /** Driver-specific password configuration for the contact point */
286
+ password: string;
287
+ metadata: IMetadata;
288
+ createdAt: string;
289
+ updatedAt: string;
290
+ }
291
+ /**
292
+ * Request body for sending a notification to a contact point.
293
+ */
294
+ interface IContactPointSendRequest {
295
+ /** ID of the template to use for the notification */
296
+ template?: string;
297
+ /** Subject of the notification */
298
+ subject?: string;
299
+ /** Recipients of the notification */
300
+ recipients?: string[];
301
+ /** Template key/value data for expanding the notification template */
302
+ data?: any;
303
+ }
304
+ /**
305
+ * Media resource.
306
+ */
307
+ interface IMedia extends IBaseResource {
308
+ id: string;
309
+ applicationId: string;
310
+ type: string;
311
+ mimeType: string;
312
+ fileName: string;
313
+ metadata: IMetadata;
314
+ createdAt: string;
315
+ updatedAt: string;
316
+ }
317
+
318
+ /**
319
+ * Copyright © 2018 Emu Analytics
320
+ */
321
+
322
+ declare class BaseEndpoints<T extends IBaseResource> {
323
+ protected readonly client: Client;
324
+ private readonly resourcePath;
325
+ constructor(client: Client, resourcePath: string);
326
+ protected get resourceEndpoint(): string;
327
+ list(params?: IQuery): Promise<T[]>;
328
+ get(id: string, params?: Record<string, any>): Promise<T>;
329
+ create(data: Partial<T>, params?: Record<string, any>): Promise<T>;
330
+ update(id: string, data: Partial<T>, params?: Record<string, any>): Promise<T>;
331
+ delete(id: string, params?: Record<string, any>): Promise<any>;
332
+ getMetadata(id: string, key?: string, params?: Record<string, any>): Promise<any>;
333
+ setMetadata(id: string, key: string, value: any, params?: Record<string, any>): Promise<any>;
334
+ deleteMetadata(id: string, key: string, params?: Record<string, any>): Promise<any>;
335
+ }
336
+
337
+ /**
338
+ * Copyright © 2018 Emu Analytics
339
+ */
340
+
341
+ declare class ApiKeyEndpoints extends BaseEndpoints<IApiKey> {
342
+ constructor(client: Client);
343
+ }
344
+
345
+ declare enum WebSocketChannel {
346
+ System = "system",
347
+ AppConfig = "appconfig",
348
+ Dataset = "dataset/"
349
+ }
350
+ interface WebSocketPublishMessage {
351
+ channel: string;
352
+ messageType?: string;
353
+ payload: unknown;
354
+ }
355
+ interface WebSocketSubscribeMessage {
356
+ channel: string;
357
+ }
358
+ interface WebSocketErrorResponse {
359
+ status: 'error';
360
+ code: string;
361
+ message: string;
362
+ }
363
+ interface WebSocketOkResponse {
364
+ status: 'ok';
365
+ }
366
+ type WebSocketResponse = WebSocketOkResponse | WebSocketErrorResponse;
367
+ type WebSocketManagerOptions = Partial<ManagerOptions & SocketOptions>;
368
+ type WebSocketSubscribeCallback = (err: Error | null, msg?: WebSocketPublishMessage) => void;
369
+ type WebSocketUnsubscribeCallback = (err: Error | null) => void;
370
+ type WebSocketUnsubscriber = (cb?: WebSocketUnsubscribeCallback) => void;
371
+ declare class WebSocketGateway {
372
+ readonly client: Client;
373
+ private readonly options?;
374
+ private connected;
375
+ private subscribedChannels;
376
+ socket: Socket;
377
+ get isConnected(): boolean;
378
+ constructor(client: Client, options?: WebSocketManagerOptions | undefined);
379
+ connect(): Promise<void>;
380
+ disconnect(): Promise<void>;
381
+ subscribe(channel: string, cb: WebSocketSubscribeCallback): WebSocketUnsubscriber;
382
+ unsubscribe(channel: string, cb?: WebSocketUnsubscribeCallback): void;
383
+ }
384
+
385
+ /**
386
+ * Copyright © 2018 Emu Analytics
387
+ */
388
+
389
+ declare class AppConfigEndpoints {
390
+ private readonly client;
391
+ constructor(client: Client);
392
+ private get resourceEndpoint();
393
+ get(path?: string, params?: Record<string, any>): Promise<any>;
394
+ set(path: string | null, value: any, params?: Record<string, any>): Promise<any>;
395
+ delete(path: string, params?: Record<string, any>): Promise<any>;
396
+ subscribe(cb: WebSocketSubscribeCallback): WebSocketUnsubscriber;
397
+ }
398
+
399
+ /**
400
+ * Copyright © 2018 Emu Analytics
401
+ */
402
+
403
+ declare class ApplicationEndpoints extends BaseEndpoints<IApplication> {
404
+ constructor(client: Client);
405
+ }
406
+
407
+ /**
408
+ * Copyright © 2018 Emu Analytics
409
+ */
410
+
411
+ declare class UserEndpoint extends BaseEndpoints<IUser> {
412
+ constructor(client: Client);
413
+ me(token: string): Promise<UsersMeResponse>;
414
+ }
415
+
416
+ /**
417
+ * Copyright © 2018 Emu Analytics
418
+ */
419
+
420
+ declare class AuthEndpoints {
421
+ private readonly client;
422
+ users: UserEndpoint;
423
+ constructor(client: Client);
424
+ login(email: string, password: string, applicationId?: string): Promise<ILoginResponse>;
425
+ logout(accessToken: string, refreshToken: string): Promise<void>;
426
+ refresh(refreshToken: string, applicationId: string): Promise<ITokenRefreshResponse>;
427
+ changePassword(password: string, newPassword: string, token: string): Promise<void>;
428
+ signUp(firstName: string, lastName: string, email: string, password: string, applicationId: string, confirmUrl: string, redirectUrl?: string): Promise<void>;
429
+ confirmSignUp(email: string, token: string, redirect?: string): Promise<void>;
430
+ requestPasswordReset(email: string, applicationId: string, redirectUrl: string): Promise<void>;
431
+ resetPassword(email: string, password: string, applicationId: string, token: string): Promise<void>;
432
+ }
433
+
434
+ /**
435
+ * Copyright © 2018-present Emu Analytics
436
+ */
437
+
438
+ declare class ContactPointEndpoints extends BaseEndpoints<IContactPoint> {
439
+ constructor(client: Client);
440
+ /**
441
+ * Send a notification to a contact point.
442
+ */
443
+ send(contactPointId: string, params?: IContactPointSendRequest): Promise<void>;
444
+ /**
445
+ * Get a list of available contact point drivers. Supported types include 'email', 'slack', 'teams', 'sns'.
446
+ *
447
+ * Drivers have different required parameters - refer to documentation for details.
448
+ */
449
+ drivers(): Promise<string[]>;
450
+ }
451
+
452
+ /**
453
+ * Copyright © 2018 Emu Analytics
454
+ */
455
+
456
+ declare class DatabaseEndpoints extends BaseEndpoints<IDatabase> {
457
+ constructor(client: Client);
458
+ drivers(): Promise<string[]>;
459
+ }
460
+
461
+ /**
462
+ * Copyright © 2018 Emu Analytics
463
+ */
464
+
465
+ interface DatasetQuery {
466
+ [key: string]: any;
467
+ }
468
+ type QueryOutputFormat = 'plain' | 'json' | 'csv' | 'geojson';
469
+ interface DatasetQueryOptions {
470
+ [param: string]: any;
471
+ format?: QueryOutputFormat;
472
+ explain?: boolean | string;
473
+ abortController?: AbortController;
474
+ }
475
+ declare class DatasetEndpoints extends BaseEndpoints<IDataset> {
476
+ constructor(client: Client);
477
+ query(datasetId: string | DatasetQuery, query?: DatasetQuery, params?: DatasetQueryOptions | QueryOutputFormat): Promise<any>;
478
+ ingest(ingestMessage: IIngestMessage, params?: Record<string, any>): Promise<any>;
479
+ getExportUrl(datasetId: string, format: FileExportFormat): string;
480
+ subscribe(datasetId: string, cb: WebSocketSubscribeCallback): WebSocketUnsubscriber;
481
+ }
482
+
483
+ /**
484
+ * Copyright © 2018 Emu Analytics
485
+ */
486
+
487
+ declare class JobEndpoints extends BaseEndpoints<IJob> {
488
+ constructor(client: Client);
489
+ submit(submission: IJobSubmission): Promise<IJob>;
490
+ getStatus(jobId: string): Promise<IJobStatus>;
491
+ setStatus(jobId: string, status: IJobStatus): Promise<IJob>;
492
+ cancel(jobId: string): Promise<IJob>;
493
+ request(jobType: string): Promise<IJob>;
494
+ }
495
+
496
+ /**
497
+ * Copyright © 2018 Emu Analytics
498
+ */
499
+
500
+ declare class MapEndpoints {
501
+ private readonly client;
502
+ constructor(client: Client);
503
+ get(id: string, params?: Record<string, any>): Promise<IStyle>;
504
+ }
505
+
506
+ /**
507
+ * Copyright © 2018 Emu Analytics
508
+ */
509
+
510
+ declare class MapLayerEndpoints extends BaseEndpoints<IMapLayer> {
511
+ constructor(client: Client);
512
+ subscribe(cb: WebSocketSubscribeCallback): WebSocketUnsubscriber;
513
+ }
514
+
515
+ /**
516
+ * Copyright © 2018-present Emu Analytics
517
+ */
518
+
519
+ interface IMediaUploadRequest {
520
+ type: string;
521
+ mimeType?: string;
522
+ metadata?: IMetadata;
523
+ fileName: string;
524
+ data: any;
525
+ }
526
+ declare class MediaEndpoints extends BaseEndpoints<IMedia> {
527
+ constructor(client: Client);
528
+ upload(mediaId: string, request: IMediaUploadRequest, params?: Record<string, any>): Promise<IMedia>;
529
+ content(mediaId: string): Promise<any>;
530
+ }
531
+
532
+ /**
533
+ * Copyright © 2018-present Emu Analytics
534
+ */
535
+
536
+ declare class PipelineMetricEndpoints extends BaseEndpoints<IPipelineMetric> {
537
+ constructor(client: Client, pipelineId: string, componentId: string);
538
+ }
539
+
540
+ /**
541
+ * Copyright © 2018-present Emu Analytics
542
+ */
543
+
544
+ declare class PipelineComponentEndpoints extends BaseEndpoints<IPipelineComponent> {
545
+ private pipelineId;
546
+ constructor(client: Client, pipelineId: string);
547
+ metrics(componentId: string): PipelineMetricEndpoints;
548
+ }
549
+
550
+ /**
551
+ * Copyright © 2018-present Emu Analytics
552
+ */
553
+
554
+ declare class PipelineEndpoints extends BaseEndpoints<IPipeline> {
555
+ constructor(client: Client);
556
+ components(pipelineId: string): PipelineComponentEndpoints;
557
+ heartbeat(id: string, params?: Record<string, any>): Promise<void>;
558
+ publishMetrics(metrics: object, params?: Record<string, any>): Promise<void>;
559
+ }
560
+
561
+ /**
562
+ * Copyright © 2018 Emu Analytics
563
+ */
564
+
565
+ declare class StyleEndpoints extends BaseEndpoints<IStyle> {
566
+ constructor(client: Client);
567
+ }
568
+
569
+ /**
570
+ * Copyright © 2018 Emu Analytics
571
+ */
572
+
573
+ declare class TileSourceEndpoints extends BaseEndpoints<ITileSource> {
574
+ constructor(client: Client);
575
+ drivers(): Promise<string[]>;
576
+ }
577
+
578
+ /**
579
+ * Copyright © 2018 Emu Analytics
580
+ */
581
+
582
+ declare class TileEndpoints {
583
+ private readonly client;
584
+ constructor(client: Client);
585
+ getTileSpec(tilesourceId: string, params?: Record<string, any>): Promise<ITileSpec>;
586
+ getPreviewStyle(tilesourceId: string, params?: Record<string, any>): Promise<ITileSpec>;
587
+ }
588
+
589
+ interface UploadOptions {
590
+ data: any;
591
+ filename: string;
592
+ datasetId?: string;
593
+ datasetName?: string;
594
+ datasetDescription?: string;
595
+ attribution?: string;
596
+ sourceSrid?: number;
597
+ targetSrid?: number;
598
+ schema?: string;
599
+ metadata?: any;
600
+ abortController?: AbortController;
601
+ progress?: (event: any) => void;
602
+ }
603
+ declare class UploadEndpoints extends BaseEndpoints<IUpload> {
604
+ constructor(client: Client);
605
+ upload(options: UploadOptions, params?: Record<string, any>): Promise<IUpload>;
606
+ }
607
+
608
+ /**
609
+ * Copyright © 2018 Emu Analytics
610
+ */
611
+
612
+ type ClientOptions = WebSocketManagerOptions;
613
+ declare class Client {
614
+ baseUrl: string;
615
+ readonly apiKey: string | null;
616
+ private readonly axios;
617
+ readonly debug: Debug.Debugger;
618
+ webSocketGateway: WebSocketGateway;
619
+ accessToken: string | null;
620
+ auth: AuthEndpoints;
621
+ tiles: TileEndpoints;
622
+ maps: MapEndpoints;
623
+ apiKeys: ApiKeyEndpoints;
624
+ applications: ApplicationEndpoints;
625
+ appconfig: AppConfigEndpoints;
626
+ contactpoints: ContactPointEndpoints;
627
+ databases: DatabaseEndpoints;
628
+ datasets: DatasetEndpoints;
629
+ styles: StyleEndpoints;
630
+ tileSources: TileSourceEndpoints;
631
+ uploads: UploadEndpoints;
632
+ jobs: JobEndpoints;
633
+ maplayers: MapLayerEndpoints;
634
+ media: MediaEndpoints;
635
+ pipelines: PipelineEndpoints;
636
+ useRequestInterceptor(interceptor: (config: any) => any): number;
637
+ ejectRequestInterceptor(id: number): void;
638
+ constructor(baseUrl: string, apiKey?: string | null, options?: ClientOptions);
639
+ connect(): Promise<void>;
640
+ disconnect(): Promise<void>;
641
+ config(): Promise<IConfig>;
642
+ _get(path: string, options?: any): Promise<any>;
643
+ _post(path: string, data: object, options?: any): Promise<any>;
644
+ _put(path: string, data: object, options?: any): Promise<any>;
645
+ _delete(path: string, options?: any): Promise<any>;
646
+ _subscribe(channel: string, cb: WebSocketSubscribeCallback): WebSocketUnsubscriber;
647
+ _unsubscribe(channel: string, cb?: WebSocketUnsubscribeCallback): void;
648
+ /**
649
+ * Normalize errors
650
+ * Throws a new error based on type of input error
651
+ *
652
+ * @param {AxiosError} e
653
+ */
654
+ private handleError;
655
+ private headers;
656
+ }
657
+
658
+ /**
659
+ * Copyright © 2018 Emu Analytics
660
+ */
661
+ declare class FlowEngineError extends Error {
662
+ error: object | null;
663
+ statusCode: number;
664
+ constructor(message: string, underlyingError?: Error | null, statusCode?: number);
665
+ }
666
+
667
+ export { BaseEndpoints, Client, FlowEngineError, WebSocketChannel, WebSocketGateway };
668
+ export type { ClientOptions, FileExportFormat, IApiKey, IAppConfig, IApplication, IBaseResource, IConfig, IContactPoint, IContactPointSendRequest, IDatabase, IDataset, IDatasetAttribute, IIngestMessage, IJob, IJobRequest, IJobStatus, IJobSubmission, ILoginResponse, IMapLayer, IMedia, IMetadata, IPermissions, IPipeline, IPipelineComponent, IPipelineMetric, IQuery, IStyle, ITileSource, ITileSpec, ITokenRefreshResponse, IUpload, IUser, IngestAction, JobStatus, UsersMeResponse, WebSocketErrorResponse, WebSocketManagerOptions, WebSocketOkResponse, WebSocketPublishMessage, WebSocketResponse, WebSocketSubscribeCallback, WebSocketSubscribeMessage, WebSocketUnsubscribeCallback, WebSocketUnsubscriber };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import h from"axios";import m from"debug";import d from"form-data";import{io as b}from"socket.io-client";class a{constructor(e,t){this.client=e,this.resourcePath=t}get resourceEndpoint(){return`/api/v1/${this.resourcePath}`}list(e){if(e?.filter){const t=e.filter;Object.keys(t).forEach(s=>{e[`filter[${s}]`]=t[s]}),delete e.filter}return this.client._get(this.resourceEndpoint,{params:e})}get(e,t={}){return this.client._get(`${this.resourceEndpoint}/${e}`,{params:t})}create(e,t={}){return this.client._post(`${this.resourceEndpoint}`,e,{params:t})}update(e,t,s={}){return this.client._put(`${this.resourceEndpoint}/${e}`,t,{params:s})}delete(e,t={}){return this.client._delete(`${this.resourceEndpoint}/${e}`,{params:t})}getMetadata(e,t,s={}){const n=t?`${this.resourceEndpoint}/${e}/metadata/${t}`:`${this.resourceEndpoint}/${e}/metadata`;return this.client._get(n,{params:s})}setMetadata(e,t,s,n={}){return(typeof s=="string"||typeof s=="number"||typeof s=="boolean")&&(s={value:s}),this.client._put(`${this.resourceEndpoint}/${e}/metadata/${t}`,s,{headers:{"Content-Type":"application/json"},params:n})}deleteMetadata(e,t,s={}){return this.client._delete(`${this.resourceEndpoint}/${e}/metadata/${t}`,{headers:{"Content-Type":"application/json"},params:s})}}class g extends a{constructor(e){super(e,"apikeys")}}class y{constructor(e){this.client=e}get resourceEndpoint(){return"/api/v1/appconfig"}get(e,t={}){return this.client._get(e?`${this.resourceEndpoint}/${e}`:this.resourceEndpoint,{params:t})}set(e,t,s={}){return(typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null||Array.isArray(t))&&(t={value:t}),this.client._put(e?`${this.resourceEndpoint}/${e}`:this.resourceEndpoint,t,{headers:{"Content-Type":"application/json"},params:s})}delete(e,t={}){return this.client._delete(`${this.resourceEndpoint}/${e}`,{params:t})}subscribe(e){return this.client._subscribe("appconfig",e)}}class w extends a{constructor(e){super(e,"applications")}}class f extends a{constructor(e){super(e,"auth/users")}me(e){return this.client._get(`${this.resourceEndpoint}/me`,{headers:{Authorization:`Bearer ${e}`}})}}class ${constructor(e){this.client=e}users=new f(this.client);login(e,t,s){return this.client._post("/api/v1/auth/login",{email:e,password:t,applicationId:s})}logout(e,t){return this.client._post("/api/v1/auth/logout",{refreshToken:t},{headers:{Authorization:`Bearer ${e}`}})}refresh(e,t){return this.client._post("/api/v1/auth/refresh",{refreshToken:e,applicationId:t})}changePassword(e,t,s){return this.client._post("/api/v1/auth/changepassword",{password:e,newPassword:t},{headers:{Authorization:`Bearer ${s}`}})}signUp(e,t,s,n,i,c,p){return p||(p=c,c=`${this.client.baseUrl}/api/v1/auth/confirmsignup`),this.client._post("/api/v1/auth/signup",{firstName:e,lastName:t,email:s,password:n,applicationId:i,confirmUrl:c,redirectUrl:p})}confirmSignUp(e,t,s){return this.client._get("/api/v1/auth/confirmsignup",{params:{email:e,token:t,redirect:s}})}requestPasswordReset(e,t,s){return this.client._post("/api/v1/auth/requestpasswordreset",{email:e,applicationId:t,redirectUrl:s})}resetPassword(e,t,s,n){return this.client._post("/api/v1/auth/resetpassword",{email:e,password:t,applicationId:s,token:n})}}class E extends a{constructor(e){super(e,"contactpoints")}send(e,t={}){return this.client._post(`${this.resourceEndpoint}/${e}/send`,t)}drivers(){return this.client._get(`${this.resourceEndpoint}/drivers`)}}class _ extends a{constructor(e){super(e,"databases")}drivers(){return this.client._get("/api/v1/databases/drivers").catch(e=>{if(e.status===404)return["postgis","postgis-mapnik"]})}}class k extends a{constructor(e){super(e,"datasets")}query(e,t={},s={}){typeof e=="object"&&(s={...e.params,format:e.format||"json"},t=e,e=t.datasetId,delete t.datasetId,delete t.format),typeof s=="string"&&(s={format:s});let n=null;return s.abortController&&(n=s.abortController,delete s.abortController),this.client._post(`/api/v1/datasets/${e}/query`,t,{params:{...s,format:s.format||"json",explain:s.explain||!1},signal:n?.signal}).catch(i=>{throw i.message==="Network Error"?new Error("Query timed out"):i})}ingest(e,t={}){return this.client._post(`/api/v1/datasets/${e.datasetId}/ingest`,e,t)}getExportUrl(e,t){const s=this.client.accessToken?`accesstoken=${this.client.accessToken}`:`apikey=${this.client.apiKey}`;return`${this.client.baseUrl}/api/v1/datasets/${e}/export?format=${t}&${s}`}subscribe(e,t){return this.client._subscribe(`dataset/${e}`,t)}}class o extends Error{error;statusCode;constructor(e,t=null,s=500){super(e||"Unknown Error"),Object.setPrototypeOf(this,o.prototype),this.statusCode=s,this.error=t}}class S extends a{constructor(e){super(e,"jobs")}submit(e){return this.client._post("/api/v1/jobs/submit",e)}getStatus(e){return this.client._get(`/api/v1/jobs/${e}/status`)}setStatus(e,t){return this.client._post(`/api/v1/jobs/${e}/status`,t)}cancel(e){return this.client._post(`/api/v1/jobs/${e}/cancel`,{})}request(e){return this.client._post("/api/v1/jobs/request",{type:e})}}class v{constructor(e){this.client=e}get(e,t={}){return this.client._get(`/maps/${e}.json`,{params:t})}}class x extends a{constructor(e){super(e,"maplayers")}subscribe(e){return this.client._subscribe("maplayers",e)}}class C extends a{constructor(e){super(e,"media")}async upload(e,t,s={}){const n=new d;return n.append("id",e),t.type&&n.append("type",t.type),t.mimeType&&n.append("mimeType",t.mimeType),t.metadata&&n.append("metadata",JSON.stringify(t.metadata)),n.append("file",t.data,t.fileName),await this.client._post(this.resourceEndpoint,n,{headers:n.getHeaders?.()??{"Content-Type":"multipart/form-data"},params:s})}content(e){return this.client._get(`${this.resourceEndpoint}/${e}/content`,{responseType:"stream"})}}class K extends a{constructor(e,t,s){super(e,`pipelines/${t}/components/${s}/metrics`)}}class j extends a{constructor(e,t){super(e,`pipelines/${t}/components`),this.pipelineId=t}metrics(e){return new K(this.client,this.pipelineId,e)}}class T extends a{constructor(e){super(e,"pipelines")}components(e){return new j(this.client,e)}async heartbeat(e,t={}){return this.client._post(`${this.resourceEndpoint}/${e}/heartbeat`,{params:t})}async publishMetrics(e,t={}){return this.client._post(`${this.resourceEndpoint}/publish-metrics`,e,{params:t})}}class P extends a{constructor(e){super(e,"styles")}}class U extends a{constructor(e){super(e,"tilesources")}drivers(){return this.client._get("/api/v1/tilesources/drivers").catch(e=>{if(e.statusCode===404)return["tilelive","dataset"]})}}class I{constructor(e){this.client=e}getTileSpec(e,t={}){return this.client._get(`/tiles/${e}/index.json`,{params:t})}getPreviewStyle(e,t={}){return this.client._get(`/tiles/${e}/style.json`,{params:t})}}class A extends a{constructor(e){super(e,"uploads")}async upload(e,t={}){const s=new d;return e.datasetName&&s.append("name",e.datasetName),e.datasetDescription&&s.append("description",e.datasetDescription),e.attribution&&s.append("attribution",e.attribution),e.datasetId&&s.append("datasetId",e.datasetId),e.sourceSrid&&s.append("sourceSrid",e.sourceSrid),e.targetSrid&&s.append("targetSrid",e.targetSrid),e.schema&&s.append("schema",e.schema),e.metadata&&s.append("metadata",JSON.stringify(e.metadata)),s.append("file",e.data,e.filename),await this.client._post(this.resourceEndpoint,s,{headers:s.getHeaders?.()??{"Content-Type":"multipart/form-data"},signal:e.abortController?.signal,params:t,onUploadProgress:e.progress})}}var u=(r=>(r.System="system",r.AppConfig="appconfig",r.Dataset="dataset/",r))(u||{});class l{constructor(e,t){this.client=e,this.options=t}connected=!1;subscribedChannels=new Set;socket;get isConnected(){return this.connected}connect(){return this.isConnected?Promise.resolve():new Promise((e,t)=>{const s=b(this.client.baseUrl,{...this.options,autoConnect:!1,auth:n=>{const i={};this.client.apiKey&&(i["x-api-key"]=this.client.apiKey),this.client.accessToken&&(i["x-socket-token"]=`Bearer ${this.client.accessToken}`),n(i)}});s.on("connect",()=>{this.client.debug(`Socket connected: ${s.id}`),this.subscribedChannels.size&&this.subscribedChannels.forEach(n=>{s.emit("subscribe",{channel:n},i=>{i.status==="error"?console.error(`Error re-subscribing to channel '${n}`,i):this.client.debug(`Re-subscribed to channel '${n}`)})})}),s.io.on("reconnect_attempt",n=>{this.client.debug(`Socket reconnect attempt: ${n}`)}),s.io.on("reconnect_error",n=>{this.client.debug(`Socket reconnect error: ${n.message}`)}),s.io.on("reconnect_failed",()=>{this.client.debug("Socket reconnect failed")}),s.io.on("reconnect",()=>{this.client.debug("Socket reconnected")}),s.on("disconnect",n=>{this.client.debug(`Socket disconnected: ${n}`)}),s.on("error",n=>{this.client.debug(`Socket error: ${n.messaage}`)}),this.socket=s,this.connected=!0,s.on("connect",()=>{e()}),s.connect()})}disconnect(){return this.isConnected?new Promise(e=>{this.socket.once("disconnect",()=>{this.connected=!1,e()}),this.socket.disconnect()}):Promise.resolve()}subscribe(e,t){if(!this.isConnected)throw new Error("WebSocketGateway is not initialized");this.client.debug(`Subscribing to channel '${e}`);const s=i=>{i.channel===e&&t(null,i)},n=i=>{this.socket.off("message",s),this.unsubscribe(e,i)};return this.socket.emit("subscribe",{channel:e},i=>{if(i.status==="error")return this.client.debug(`Error subscribed to channel '${e}`,i),t(new Error(i.message));this.subscribedChannels.add(e),this.client.debug(`Subscribed to channel '${e}`),this.socket.on("message",s)}),n}unsubscribe(e,t){if(!this.isConnected)throw new Error("WebSocketGateway is not initialized");this.client.debug(`Unsubscribing from channel '${e}`),this.socket.emit("unsubscribe",{channel:e},s=>{s.status==="error"?(this.client.debug(`Error unsubscribing from channel '${e}`,s),t&&t(new Error(s.message))):(this.subscribedChannels.delete(e),this.client.debug(`Unsubscribed from channel '${e}`),t&&t(null))})}}class G{constructor(e,t=null,s){this.baseUrl=e,this.apiKey=t,this.axios=h.create({baseURL:e,maxContentLength:524288e3,transformResponse:[function(n,i){return i?.["content-type"]?.toString().startsWith("application/json")?JSON.parse(n):n}]}),this.webSocketGateway=new l(this,s)}axios;debug=m("flow-engine-client");webSocketGateway;accessToken=null;auth=new $(this);tiles=new I(this);maps=new v(this);apiKeys=new g(this);applications=new w(this);appconfig=new y(this);contactpoints=new E(this);databases=new _(this);datasets=new k(this);styles=new P(this);tileSources=new U(this);uploads=new A(this);jobs=new S(this);maplayers=new x(this);media=new C(this);pipelines=new T(this);useRequestInterceptor(e){return this.axios.interceptors.request.use(e)}ejectRequestInterceptor(e){this.axios.interceptors.request.eject(e)}connect(){return this.webSocketGateway.connect()}disconnect(){return this.webSocketGateway.disconnect()}config(){return this._get("/api/v1/config")}_get(e,t={}){return t.params?.apiKey&&(t.apiKey=t.params.apiKey,delete t.params.apiKey),this.axios({method:"get",url:e,...t,...this.headers(t)}).then(s=>s.data).catch(this.handleError)}_post(e,t,s={}){return s.params?.apiKey&&(s.apiKey=s.params.apiKey,delete s.params.apiKey),this.axios({method:"post",url:e,data:t,maxContentLength:1/0,maxBodyLength:1/0,...s,...this.headers(s)}).then(n=>n.data).catch(this.handleError)}_put(e,t,s={}){return s.params?.apiKey&&(s.apiKey=s.params.apiKey,delete s.params.apiKey),this.axios({method:"put",url:e,data:t,...s,...this.headers(s)}).then(n=>n.data).catch(this.handleError)}_delete(e,t={}){return t.params?.apiKey&&(t.apiKey=t.params.apiKey,delete t.params.apiKey),this.axios({method:"delete",url:e,...t,...this.headers(t)}).then(s=>s.data).catch(this.handleError)}_subscribe(e,t){return this.webSocketGateway.isConnected||this.webSocketGateway.connect(),this.webSocketGateway.subscribe(e,t)}_unsubscribe(e,t){this.webSocketGateway.isConnected||this.webSocketGateway.connect(),this.webSocketGateway.unsubscribe(e,t)}handleError(e){if(e.response&&e.response.data){if(typeof e.response.data=="object"){const s=e.response.data;throw new o(s.message||s.error,s.error,e.response.status)}else if(typeof e.response.data=="string")throw new o(e.response.data,null,e.response.status)}const t=e;throw delete t.config,delete t.request,delete t.response,new o(t.message,t)}headers(e){const t=e.headers||{};return(e.apiKey||this.apiKey)&&(t["X-Api-Key"]=e.apiKey||this.apiKey),this.accessToken&&(t.Authorization=t.Authorization||`Bearer ${this.accessToken}`),{headers:t}}}export{a as BaseEndpoints,G as Client,o as FlowEngineError,u as WebSocketChannel,l as WebSocketGateway};