@medrunner/api-client 0.0.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +674 -0
- package/README.md +18 -0
- package/dist/index.d.ts +444 -0
- package/dist/index.js +663 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +607 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +71 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/index.ts
|
|
32
|
+
var src_exports = {};
|
|
33
|
+
__export(src_exports, {
|
|
34
|
+
AccountDeactivationReason: () => AccountDeactivationReason,
|
|
35
|
+
ApiEndpoint: () => ApiEndpoint,
|
|
36
|
+
AuthEndpoint: () => AuthEndpoint,
|
|
37
|
+
CancellationReason: () => CancellationReason,
|
|
38
|
+
ChatMessageEndpoint: () => ChatMessageEndpoint,
|
|
39
|
+
Class: () => Class,
|
|
40
|
+
ClientEndpoint: () => ClientEndpoint,
|
|
41
|
+
EmergencyEndpoint: () => EmergencyEndpoint,
|
|
42
|
+
Level: () => Level,
|
|
43
|
+
LocationType: () => LocationType,
|
|
44
|
+
MedrunnerApiClient: () => MedrunnerApiClient,
|
|
45
|
+
MissionServices: () => MissionServices,
|
|
46
|
+
MissionStatus: () => MissionStatus,
|
|
47
|
+
Origin: () => Origin,
|
|
48
|
+
PersonType: () => PersonType,
|
|
49
|
+
ResponseRating: () => ResponseRating,
|
|
50
|
+
StaffEndpoint: () => StaffEndpoint,
|
|
51
|
+
SubmissionSource: () => SubmissionSource,
|
|
52
|
+
ThreatLevel: () => ThreatLevel,
|
|
53
|
+
TokenManager: () => TokenManager,
|
|
54
|
+
UserRoles: () => UserRoles,
|
|
55
|
+
WebsocketEndpoint: () => WebsocketEndpoint
|
|
56
|
+
});
|
|
57
|
+
module.exports = __toCommonJS(src_exports);
|
|
58
|
+
|
|
59
|
+
// src/api/endpoints/ApiEndpoint.ts
|
|
60
|
+
var import_axios = __toESM(require("axios"));
|
|
61
|
+
var ApiEndpoint = class {
|
|
62
|
+
constructor(baseUrl, tokenManager, log, headerProvider) {
|
|
63
|
+
this.baseUrl = baseUrl;
|
|
64
|
+
this.tokenManager = tokenManager;
|
|
65
|
+
this.log = log;
|
|
66
|
+
this.headerProvider = headerProvider;
|
|
67
|
+
}
|
|
68
|
+
endpointUrl() {
|
|
69
|
+
return `${this.baseUrl}/${this.endpoint()}`;
|
|
70
|
+
}
|
|
71
|
+
async headersForRequest(noAuthentication) {
|
|
72
|
+
const config = {
|
|
73
|
+
baseURL: this.baseUrl,
|
|
74
|
+
headers: {}
|
|
75
|
+
};
|
|
76
|
+
if (config.headers !== void 0) {
|
|
77
|
+
if (!noAuthentication) {
|
|
78
|
+
const accessToken = await this.tokenManager.getAccessToken();
|
|
79
|
+
if (accessToken !== void 0) {
|
|
80
|
+
config.headers.Authorization = `Bearer ${accessToken}`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (this.headerProvider !== void 0) {
|
|
84
|
+
for (const header of Object.entries(await this.headerProvider())) {
|
|
85
|
+
config.headers[header[0]] = header[1];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return config;
|
|
90
|
+
}
|
|
91
|
+
async getRequest(endpoint, queryParams, noAuthentication) {
|
|
92
|
+
return await this.makeRequestWithoutBody(endpoint, "GET", import_axios.default.get, queryParams, noAuthentication);
|
|
93
|
+
}
|
|
94
|
+
async postRequest(endpoint, data, noAuthentication) {
|
|
95
|
+
return await this.makeRequestWithBody(endpoint, "POST", import_axios.default.post, data, noAuthentication);
|
|
96
|
+
}
|
|
97
|
+
async putRequest(endpoint, data, noAuthentication) {
|
|
98
|
+
return await this.makeRequestWithBody(endpoint, "PUT", import_axios.default.put, data, noAuthentication);
|
|
99
|
+
}
|
|
100
|
+
async patchRequest(endpoint, data, noAuthentication) {
|
|
101
|
+
return await this.makeRequestWithBody(endpoint, "PATCH", import_axios.default.patch, data, noAuthentication);
|
|
102
|
+
}
|
|
103
|
+
async deleteRequest(endpoint, queryParams, noAuthentication) {
|
|
104
|
+
return await this.makeRequestWithoutBody(endpoint, "DELETE", import_axios.default.delete, queryParams, noAuthentication);
|
|
105
|
+
}
|
|
106
|
+
async makeRequestWithBody(endpoint, requestType, axiosRequest, data, noAuthentication) {
|
|
107
|
+
const wrappedRequest = /* @__PURE__ */ __name(async (requestUrl, config) => await axiosRequest(requestUrl, data, config), "wrappedRequest");
|
|
108
|
+
return await this.makeRequest(endpoint, requestType, wrappedRequest, void 0, noAuthentication);
|
|
109
|
+
}
|
|
110
|
+
async makeRequestWithoutBody(endpoint, requestType, axiosRequest, queryParams, noAuthentication) {
|
|
111
|
+
const wrappedRequest = /* @__PURE__ */ __name(async (requestUrl, config) => await axiosRequest(requestUrl, config), "wrappedRequest");
|
|
112
|
+
return await this.makeRequest(endpoint, requestType, wrappedRequest, queryParams, noAuthentication);
|
|
113
|
+
}
|
|
114
|
+
buildUrl(endpoint) {
|
|
115
|
+
const baseUrl = this.endpointUrl();
|
|
116
|
+
if (baseUrl.endsWith("/")) {
|
|
117
|
+
if (endpoint.startsWith("/")) {
|
|
118
|
+
return `${baseUrl}${endpoint.substring(1)}`;
|
|
119
|
+
}
|
|
120
|
+
return `${baseUrl}${endpoint}`;
|
|
121
|
+
}
|
|
122
|
+
if (endpoint.startsWith("/")) {
|
|
123
|
+
return `${baseUrl}${endpoint}`;
|
|
124
|
+
}
|
|
125
|
+
return `${baseUrl}/${endpoint}`;
|
|
126
|
+
}
|
|
127
|
+
async makeRequest(endpoint, requestType, request, queryParams, noAuthentication = false) {
|
|
128
|
+
const requestUrl = this.buildUrl(endpoint);
|
|
129
|
+
this.log?.debug(`sending ${requestType} request to ${requestUrl}`);
|
|
130
|
+
try {
|
|
131
|
+
const config = await this.headersForRequest(noAuthentication);
|
|
132
|
+
if (queryParams !== void 0) {
|
|
133
|
+
config.params = queryParams;
|
|
134
|
+
}
|
|
135
|
+
const result = await request(requestUrl, config);
|
|
136
|
+
return {
|
|
137
|
+
success: true,
|
|
138
|
+
data: result.data
|
|
139
|
+
};
|
|
140
|
+
} catch (e) {
|
|
141
|
+
this.log?.warn(`Error for ${requestType} request to ${requestUrl}: ${e}`);
|
|
142
|
+
return {
|
|
143
|
+
success: false,
|
|
144
|
+
errorMessage: e instanceof import_axios.AxiosError ? e.response?.data : void 0,
|
|
145
|
+
statusCode: e instanceof import_axios.AxiosError ? e.response?.status : void 0
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
__name(ApiEndpoint, "ApiEndpoint");
|
|
151
|
+
|
|
152
|
+
// src/api/endpoints/auth/AuthEndpoint.ts
|
|
153
|
+
var AuthEndpoint = class extends ApiEndpoint {
|
|
154
|
+
constructor(baseUrl, tokenManager, log, headerProvider) {
|
|
155
|
+
super(baseUrl, tokenManager, log, headerProvider);
|
|
156
|
+
}
|
|
157
|
+
endpoint() {
|
|
158
|
+
return "auth";
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Invalidate a refresh token.
|
|
162
|
+
*
|
|
163
|
+
* @param oldToken - Token to be invalidated
|
|
164
|
+
*
|
|
165
|
+
* @virtual
|
|
166
|
+
* */
|
|
167
|
+
async signOut(oldToken) {
|
|
168
|
+
return await this.postRequest("/signOut", oldToken);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Gets all api tokens for the user.
|
|
172
|
+
*
|
|
173
|
+
* */
|
|
174
|
+
async getApiTokens() {
|
|
175
|
+
return await this.getRequest(`/apiTokens`);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Creates an api token.
|
|
179
|
+
*
|
|
180
|
+
* @param newToken - Emergency details for the new emergency
|
|
181
|
+
* @returns The newly-created api token
|
|
182
|
+
*
|
|
183
|
+
* @virtual
|
|
184
|
+
* */
|
|
185
|
+
async createApiToken(newToken) {
|
|
186
|
+
return await this.postRequest("/apiTokens", {
|
|
187
|
+
name: newToken.name,
|
|
188
|
+
expirationDate: newToken.expirationDate?.toISOString()
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Delete an api token.
|
|
193
|
+
*
|
|
194
|
+
* @param id - The id of the api token to delete
|
|
195
|
+
*
|
|
196
|
+
* */
|
|
197
|
+
async deleteApiToken(id) {
|
|
198
|
+
return await this.deleteRequest(`/apiTokens/${id}`);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
__name(AuthEndpoint, "AuthEndpoint");
|
|
202
|
+
|
|
203
|
+
// src/api/endpoints/auth/TokenManager.ts
|
|
204
|
+
var TokenManager = class extends ApiEndpoint {
|
|
205
|
+
constructor(config, refreshCallback, log, headerProvider) {
|
|
206
|
+
super(config.baseUrl, null, log, headerProvider);
|
|
207
|
+
this.refreshCallback = refreshCallback;
|
|
208
|
+
this.accessToken = config.accessToken;
|
|
209
|
+
this.refreshToken = config.refreshToken;
|
|
210
|
+
}
|
|
211
|
+
accessToken;
|
|
212
|
+
refreshToken;
|
|
213
|
+
endpoint() {
|
|
214
|
+
return "auth";
|
|
215
|
+
}
|
|
216
|
+
async getAccessToken() {
|
|
217
|
+
if (this.accessToken !== void 0) {
|
|
218
|
+
const exp = TokenManager.getJwtFromAccessToken(this.accessToken).exp;
|
|
219
|
+
if (exp > Date.now() / 1e3 - 60 * 5)
|
|
220
|
+
return this.accessToken;
|
|
221
|
+
}
|
|
222
|
+
if (this.refreshToken === void 0)
|
|
223
|
+
return this.accessToken;
|
|
224
|
+
const tokens = await this.fetchToken(this.refreshToken);
|
|
225
|
+
if (this.refreshCallback !== void 0) {
|
|
226
|
+
await this.refreshCallback(tokens);
|
|
227
|
+
}
|
|
228
|
+
this.accessToken = tokens.accessToken;
|
|
229
|
+
this.refreshToken = tokens.refreshToken;
|
|
230
|
+
return tokens.accessToken;
|
|
231
|
+
}
|
|
232
|
+
async fetchToken(refreshToken) {
|
|
233
|
+
const result = await this.postRequest("/exchange", { refreshToken }, true);
|
|
234
|
+
if (!result.success || result.data === void 0) {
|
|
235
|
+
throw Error(result.statusCode?.toString());
|
|
236
|
+
}
|
|
237
|
+
return result.data;
|
|
238
|
+
}
|
|
239
|
+
static getJwtFromAccessToken(accessToken) {
|
|
240
|
+
return JSON.parse(atob(accessToken.split(".")[1]));
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
__name(TokenManager, "TokenManager");
|
|
244
|
+
|
|
245
|
+
// src/api/endpoints/chatMessage/ChatMessageEndpoint.ts
|
|
246
|
+
var ChatMessageEndpoint = class extends ApiEndpoint {
|
|
247
|
+
constructor(baseUrl, tokenManager, log, headerProvider) {
|
|
248
|
+
super(baseUrl, tokenManager, log, headerProvider);
|
|
249
|
+
}
|
|
250
|
+
endpoint() {
|
|
251
|
+
return "chatMessage";
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Gets the specified amount of chat messages for a given emergency.
|
|
255
|
+
*
|
|
256
|
+
* @param emergencyId - The emergency for which to fetch the chat history
|
|
257
|
+
* @param limit - The number of emergencies to get
|
|
258
|
+
* @param paginationToken - The number to use for pagination
|
|
259
|
+
* */
|
|
260
|
+
async getHistory(emergencyId, limit, paginationToken) {
|
|
261
|
+
return await this.getRequest(`/${emergencyId}`, { limit, paginationToken });
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Sends a new chat message
|
|
265
|
+
*
|
|
266
|
+
* @param message - The message to send
|
|
267
|
+
* @returns The newly-created chat message
|
|
268
|
+
*
|
|
269
|
+
* */
|
|
270
|
+
async sendMessage(message) {
|
|
271
|
+
return await this.postRequest("", message);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
__name(ChatMessageEndpoint, "ChatMessageEndpoint");
|
|
275
|
+
|
|
276
|
+
// src/api/endpoints/client/ClientEndpoint.ts
|
|
277
|
+
var ClientEndpoint = class extends ApiEndpoint {
|
|
278
|
+
constructor(baseUrl, tokenManager, log, headerProvider) {
|
|
279
|
+
super(baseUrl, tokenManager, log, headerProvider);
|
|
280
|
+
}
|
|
281
|
+
endpoint() {
|
|
282
|
+
return "client";
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Gets the current client.
|
|
286
|
+
* */
|
|
287
|
+
async get() {
|
|
288
|
+
return await this.getRequest("");
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Gets the specified amount of emergencies the client has created.
|
|
292
|
+
* @param limit - The number of emergencies to get
|
|
293
|
+
* @param paginationToken - The number to use for pagination
|
|
294
|
+
* */
|
|
295
|
+
async getHistory(limit, paginationToken) {
|
|
296
|
+
return await this.getRequest("/history", { limit, paginationToken });
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Links the current user to a rsiHandle.
|
|
300
|
+
*
|
|
301
|
+
* @param rsiHandle - The RSI handle of the client
|
|
302
|
+
*
|
|
303
|
+
* */
|
|
304
|
+
async linkClient(rsiHandle) {
|
|
305
|
+
return await this.postRequest("/link", { rsiHandle });
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Updates the settings of the current user for the Client Portal.
|
|
309
|
+
*
|
|
310
|
+
* @param settings - The object settings to add or update
|
|
311
|
+
* @returns The updated settings object
|
|
312
|
+
*
|
|
313
|
+
* */
|
|
314
|
+
async setSettings(settings) {
|
|
315
|
+
return await this.patchRequest("/settings/clientPortal", settings);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
__name(ClientEndpoint, "ClientEndpoint");
|
|
319
|
+
|
|
320
|
+
// src/api/endpoints/emergency/EmergencyEndpoint.ts
|
|
321
|
+
var EmergencyEndpoint = class extends ApiEndpoint {
|
|
322
|
+
constructor(baseUrl, tokenManager, log, headerProvider) {
|
|
323
|
+
super(baseUrl, tokenManager, log, headerProvider);
|
|
324
|
+
}
|
|
325
|
+
endpoint() {
|
|
326
|
+
return "emergency";
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Gets an emergency by id.
|
|
330
|
+
*
|
|
331
|
+
* @param id - The id of the emergency to retrieve
|
|
332
|
+
* */
|
|
333
|
+
async getEmergency(id) {
|
|
334
|
+
return await this.getRequest(`/${id}`);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Bulk fetches emergencies by id.
|
|
338
|
+
*
|
|
339
|
+
* @param ids - a list of emergencies to retrieve
|
|
340
|
+
* */
|
|
341
|
+
async getEmergencies(ids) {
|
|
342
|
+
return await this.getRequest(`/bulk?id=${ids.join("&id=")}`);
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Creates a new emergency.
|
|
346
|
+
*
|
|
347
|
+
* @param newEmergency - Emergency details for the new emergency
|
|
348
|
+
* @returns The newly-created emergency
|
|
349
|
+
*
|
|
350
|
+
* @virtual
|
|
351
|
+
* */
|
|
352
|
+
async createEmergency(newEmergency) {
|
|
353
|
+
return await this.postRequest("create", newEmergency);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Cancels an existing emergency.
|
|
357
|
+
*
|
|
358
|
+
* @remarks
|
|
359
|
+
* Emergency must still be in the {@link MissionStatus.RECEIVED} state in order to be canceled.
|
|
360
|
+
*
|
|
361
|
+
* @param id - The id of the emergency to cancel
|
|
362
|
+
* @param reason - The reason the emergency was canceled
|
|
363
|
+
* */
|
|
364
|
+
async cancelEmergencyWithReason(id, reason) {
|
|
365
|
+
return await this.postRequest(`/${id}/cancelWithReason`, {
|
|
366
|
+
reason
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Allows the client to rate their emergency.
|
|
371
|
+
*
|
|
372
|
+
* @param id - The id of the emergency to rate
|
|
373
|
+
* @param rating - The rating to give the services provided
|
|
374
|
+
* @param remarks - Additional remarks provided by the client
|
|
375
|
+
*
|
|
376
|
+
* @internal
|
|
377
|
+
* */
|
|
378
|
+
async rateServices(id, rating, remarks) {
|
|
379
|
+
return await this.postRequest(`/${id}/rate/`, {
|
|
380
|
+
rating,
|
|
381
|
+
remarks
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Fetches additional details about the responding team for an alert.
|
|
386
|
+
*
|
|
387
|
+
* @param id - The id of the emergency to get team details about
|
|
388
|
+
* */
|
|
389
|
+
async teamDetails(id) {
|
|
390
|
+
return await this.getRequest(`/${id}/teamDetails`);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Gets a tree of valid locations from which an emergency may be submitted.
|
|
394
|
+
* */
|
|
395
|
+
async emergencyLocations() {
|
|
396
|
+
return await this.getRequest("/meta/locations");
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
__name(EmergencyEndpoint, "EmergencyEndpoint");
|
|
400
|
+
|
|
401
|
+
// src/api/endpoints/staff/StaffEndpoint.ts
|
|
402
|
+
var StaffEndpoint = class extends ApiEndpoint {
|
|
403
|
+
constructor(baseUrl, tokenManager, log, headerProvider) {
|
|
404
|
+
super(baseUrl, tokenManager, log, headerProvider);
|
|
405
|
+
}
|
|
406
|
+
endpoint() {
|
|
407
|
+
return "staff";
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Gets detailed information about medals.
|
|
411
|
+
* */
|
|
412
|
+
async medalsInformation() {
|
|
413
|
+
return await this.getRequest("/meta/medals");
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
__name(StaffEndpoint, "StaffEndpoint");
|
|
417
|
+
|
|
418
|
+
// src/api/endpoints/websocket/WebsocketManager.ts
|
|
419
|
+
var import_signalr = require("@microsoft/signalr");
|
|
420
|
+
var WebsocketManager = class {
|
|
421
|
+
constructor(baseUrl, tokenManager) {
|
|
422
|
+
this.baseUrl = baseUrl;
|
|
423
|
+
this.tokenManager = tokenManager;
|
|
424
|
+
}
|
|
425
|
+
tokenManager;
|
|
426
|
+
async establishConnection() {
|
|
427
|
+
return new import_signalr.HubConnectionBuilder().withAutomaticReconnect({
|
|
428
|
+
nextRetryDelayInMilliseconds: (retryContext) => retryContext.previousRetryCount > 5 ? null : 2e3
|
|
429
|
+
}).withUrl(`${this.baseUrl}/hub/emergency`, {
|
|
430
|
+
accessTokenFactory: async () => await this.tokenManager.getAccessToken() ?? ""
|
|
431
|
+
}).configureLogging(import_signalr.LogLevel.None).build();
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
__name(WebsocketManager, "WebsocketManager");
|
|
435
|
+
|
|
436
|
+
// src/api/endpoints/websocket/WebsocketEndpoint.ts
|
|
437
|
+
var WebsocketEndpoint = class extends ApiEndpoint {
|
|
438
|
+
constructor(baseUrl, tokenManager, log, headerProvider) {
|
|
439
|
+
super(baseUrl, tokenManager, log, headerProvider);
|
|
440
|
+
}
|
|
441
|
+
websocketManager = new WebsocketManager(this.baseUrl, this.tokenManager);
|
|
442
|
+
endpoint() {
|
|
443
|
+
return "websocket";
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Gets realtime updates.
|
|
447
|
+
*
|
|
448
|
+
* */
|
|
449
|
+
async initialize() {
|
|
450
|
+
if (this.websocketManager === void 0) {
|
|
451
|
+
throw new Error("WebsocketManager is undefined");
|
|
452
|
+
}
|
|
453
|
+
return await this.websocketManager.establishConnection();
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
__name(WebsocketEndpoint, "WebsocketEndpoint");
|
|
457
|
+
|
|
458
|
+
// src/api/MedrunnerApiClient.ts
|
|
459
|
+
var MedrunnerApiClient = class {
|
|
460
|
+
constructor(emergency, client, staff, chatMessage, auth, websocket) {
|
|
461
|
+
this.emergency = emergency;
|
|
462
|
+
this.client = client;
|
|
463
|
+
this.staff = staff;
|
|
464
|
+
this.chatMessage = chatMessage;
|
|
465
|
+
this.auth = auth;
|
|
466
|
+
this.websocket = websocket;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Constructs a new API client.
|
|
470
|
+
*
|
|
471
|
+
* @param config - The API configuration
|
|
472
|
+
* @param refreshCallback - a callback function called whenever a refresh token exchange is performed
|
|
473
|
+
* @param log - A logger which logs request details
|
|
474
|
+
* */
|
|
475
|
+
static buildClient(config, refreshCallback, log) {
|
|
476
|
+
const tokenManager = new TokenManager(config, refreshCallback, log);
|
|
477
|
+
return new MedrunnerApiClient(
|
|
478
|
+
new EmergencyEndpoint(config.baseUrl, tokenManager, log),
|
|
479
|
+
new ClientEndpoint(config.baseUrl, tokenManager, log),
|
|
480
|
+
new StaffEndpoint(config.baseUrl, tokenManager, log),
|
|
481
|
+
new ChatMessageEndpoint(config.baseUrl, tokenManager, log),
|
|
482
|
+
new AuthEndpoint(config.baseUrl, tokenManager, log),
|
|
483
|
+
new WebsocketEndpoint(config.baseUrl, tokenManager, log)
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
__name(MedrunnerApiClient, "MedrunnerApiClient");
|
|
488
|
+
|
|
489
|
+
// src/api/endpoints/emergency/response/LocationDetail.ts
|
|
490
|
+
var LocationType = /* @__PURE__ */ ((LocationType2) => {
|
|
491
|
+
LocationType2[LocationType2["UNKNOWN"] = 0] = "UNKNOWN";
|
|
492
|
+
LocationType2[LocationType2["SYSTEM"] = 1] = "SYSTEM";
|
|
493
|
+
LocationType2[LocationType2["PLANET"] = 2] = "PLANET";
|
|
494
|
+
LocationType2[LocationType2["MOON"] = 3] = "MOON";
|
|
495
|
+
return LocationType2;
|
|
496
|
+
})(LocationType || {});
|
|
497
|
+
|
|
498
|
+
// src/models/CancellationReason.ts
|
|
499
|
+
var CancellationReason = /* @__PURE__ */ ((CancellationReason2) => {
|
|
500
|
+
CancellationReason2[CancellationReason2["NONE"] = 0] = "NONE";
|
|
501
|
+
CancellationReason2[CancellationReason2["OTHER"] = 1] = "OTHER";
|
|
502
|
+
CancellationReason2[CancellationReason2["SUCCUMBED_TO_WOUNDS"] = 2] = "SUCCUMBED_TO_WOUNDS";
|
|
503
|
+
CancellationReason2[CancellationReason2["SERVER_ERROR"] = 3] = "SERVER_ERROR";
|
|
504
|
+
CancellationReason2[CancellationReason2["RESPAWNED"] = 4] = "RESPAWNED";
|
|
505
|
+
CancellationReason2[CancellationReason2["RESCUED"] = 5] = "RESCUED";
|
|
506
|
+
return CancellationReason2;
|
|
507
|
+
})(CancellationReason || {});
|
|
508
|
+
|
|
509
|
+
// src/models/Class.ts
|
|
510
|
+
var Class = /* @__PURE__ */ ((Class2) => {
|
|
511
|
+
Class2[Class2["NONE"] = 0] = "NONE";
|
|
512
|
+
Class2[Class2["MEDIC"] = 1] = "MEDIC";
|
|
513
|
+
Class2[Class2["SECURITY"] = 2] = "SECURITY";
|
|
514
|
+
Class2[Class2["PILOT"] = 3] = "PILOT";
|
|
515
|
+
Class2[Class2["LEAD"] = 4] = "LEAD";
|
|
516
|
+
Class2[Class2["DISPATCH"] = 5] = "DISPATCH";
|
|
517
|
+
Class2[Class2["DISPATCH_LEAD"] = 6] = "DISPATCH_LEAD";
|
|
518
|
+
Class2[Class2["DISPATCH_TRAINEE"] = 7] = "DISPATCH_TRAINEE";
|
|
519
|
+
Class2[Class2["DISPATCH_OBSERVER"] = 8] = "DISPATCH_OBSERVER";
|
|
520
|
+
Class2[Class2["QRF"] = 9] = "QRF";
|
|
521
|
+
Class2[Class2["LOGISTICS"] = 10] = "LOGISTICS";
|
|
522
|
+
return Class2;
|
|
523
|
+
})(Class || {});
|
|
524
|
+
|
|
525
|
+
// src/models/Emergency.ts
|
|
526
|
+
var MissionServices = /* @__PURE__ */ ((MissionServices2) => {
|
|
527
|
+
MissionServices2[MissionServices2["NONE"] = 0] = "NONE";
|
|
528
|
+
MissionServices2[MissionServices2["PVE"] = 1] = "PVE";
|
|
529
|
+
MissionServices2[MissionServices2["PVP"] = 2] = "PVP";
|
|
530
|
+
MissionServices2[MissionServices2["REVIVED_HEALED"] = 4] = "REVIVED_HEALED";
|
|
531
|
+
MissionServices2[MissionServices2["HEALED_IN_SHIP"] = 8] = "HEALED_IN_SHIP";
|
|
532
|
+
MissionServices2[MissionServices2["EXTRACT_SAFE_ZONE"] = 16] = "EXTRACT_SAFE_ZONE";
|
|
533
|
+
return MissionServices2;
|
|
534
|
+
})(MissionServices || {});
|
|
535
|
+
var Origin = /* @__PURE__ */ ((Origin2) => {
|
|
536
|
+
Origin2[Origin2["UNKNOWN"] = 0] = "UNKNOWN";
|
|
537
|
+
Origin2[Origin2["REPORT"] = 1] = "REPORT";
|
|
538
|
+
Origin2[Origin2["BEACON"] = 2] = "BEACON";
|
|
539
|
+
Origin2[Origin2["EVALUATION"] = 3] = "EVALUATION";
|
|
540
|
+
return Origin2;
|
|
541
|
+
})(Origin || {});
|
|
542
|
+
var SubmissionSource = /* @__PURE__ */ ((SubmissionSource2) => {
|
|
543
|
+
SubmissionSource2[SubmissionSource2["UNKNOWN"] = 0] = "UNKNOWN";
|
|
544
|
+
SubmissionSource2[SubmissionSource2["API"] = 1] = "API";
|
|
545
|
+
SubmissionSource2[SubmissionSource2["BOT"] = 2] = "BOT";
|
|
546
|
+
return SubmissionSource2;
|
|
547
|
+
})(SubmissionSource || {});
|
|
548
|
+
|
|
549
|
+
// src/models/MissionStatus.ts
|
|
550
|
+
var MissionStatus = /* @__PURE__ */ ((MissionStatus2) => {
|
|
551
|
+
MissionStatus2[MissionStatus2["CREATED"] = 0] = "CREATED";
|
|
552
|
+
MissionStatus2[MissionStatus2["RECEIVED"] = 1] = "RECEIVED";
|
|
553
|
+
MissionStatus2[MissionStatus2["IN_PROGRESS"] = 2] = "IN_PROGRESS";
|
|
554
|
+
MissionStatus2[MissionStatus2["SUCCESS"] = 3] = "SUCCESS";
|
|
555
|
+
MissionStatus2[MissionStatus2["FAILED"] = 4] = "FAILED";
|
|
556
|
+
MissionStatus2[MissionStatus2["NO_CONTACT"] = 5] = "NO_CONTACT";
|
|
557
|
+
MissionStatus2[MissionStatus2["CANCELED"] = 6] = "CANCELED";
|
|
558
|
+
MissionStatus2[MissionStatus2["REFUSED"] = 7] = "REFUSED";
|
|
559
|
+
MissionStatus2[MissionStatus2["ABORTED"] = 8] = "ABORTED";
|
|
560
|
+
MissionStatus2[MissionStatus2["SERVER_ERROR"] = 9] = "SERVER_ERROR";
|
|
561
|
+
return MissionStatus2;
|
|
562
|
+
})(MissionStatus || {});
|
|
563
|
+
|
|
564
|
+
// src/models/Person.ts
|
|
565
|
+
var UserRoles = /* @__PURE__ */ ((UserRoles2) => {
|
|
566
|
+
UserRoles2[UserRoles2["CLIENT"] = 1] = "CLIENT";
|
|
567
|
+
UserRoles2[UserRoles2["STAFF"] = 2] = "STAFF";
|
|
568
|
+
UserRoles2[UserRoles2["DEVELOPER"] = 524288] = "DEVELOPER";
|
|
569
|
+
UserRoles2[UserRoles2["BOT"] = 1048576] = "BOT";
|
|
570
|
+
return UserRoles2;
|
|
571
|
+
})(UserRoles || {});
|
|
572
|
+
var PersonType = /* @__PURE__ */ ((PersonType2) => {
|
|
573
|
+
PersonType2[PersonType2["CLIENT"] = 0] = "CLIENT";
|
|
574
|
+
PersonType2[PersonType2["STAFF"] = 1] = "STAFF";
|
|
575
|
+
PersonType2[PersonType2["BOT"] = 2] = "BOT";
|
|
576
|
+
return PersonType2;
|
|
577
|
+
})(PersonType || {});
|
|
578
|
+
var AccountDeactivationReason = /* @__PURE__ */ ((AccountDeactivationReason2) => {
|
|
579
|
+
AccountDeactivationReason2[AccountDeactivationReason2["NONE"] = 0] = "NONE";
|
|
580
|
+
AccountDeactivationReason2[AccountDeactivationReason2["CLIENT_DRIVEN_DELETION"] = 1] = "CLIENT_DRIVEN_DELETION";
|
|
581
|
+
AccountDeactivationReason2[AccountDeactivationReason2["TERMINATED"] = 2] = "TERMINATED";
|
|
582
|
+
AccountDeactivationReason2[AccountDeactivationReason2["BLOCKED"] = 3] = "BLOCKED";
|
|
583
|
+
return AccountDeactivationReason2;
|
|
584
|
+
})(AccountDeactivationReason || {});
|
|
585
|
+
|
|
586
|
+
// src/models/Level.ts
|
|
587
|
+
var Level = /* @__PURE__ */ ((Level2) => {
|
|
588
|
+
Level2[Level2["None"] = 0] = "None";
|
|
589
|
+
Level2[Level2["Tier1Section1"] = 101] = "Tier1Section1";
|
|
590
|
+
Level2[Level2["Tier1Section2"] = 102] = "Tier1Section2";
|
|
591
|
+
Level2[Level2["Tier1Section3"] = 103] = "Tier1Section3";
|
|
592
|
+
Level2[Level2["Tier2Section1"] = 201] = "Tier2Section1";
|
|
593
|
+
Level2[Level2["Tier2Section2"] = 202] = "Tier2Section2";
|
|
594
|
+
Level2[Level2["Tier2Section3"] = 203] = "Tier2Section3";
|
|
595
|
+
Level2[Level2["Tier3Section1"] = 301] = "Tier3Section1";
|
|
596
|
+
Level2[Level2["Tier3Section2"] = 302] = "Tier3Section2";
|
|
597
|
+
Level2[Level2["Tier3Section3"] = 303] = "Tier3Section3";
|
|
598
|
+
Level2[Level2["Tier4Section1"] = 401] = "Tier4Section1";
|
|
599
|
+
Level2[Level2["Tier4Section2"] = 402] = "Tier4Section2";
|
|
600
|
+
Level2[Level2["Tier4Section3"] = 403] = "Tier4Section3";
|
|
601
|
+
Level2[Level2["Tier5Section1"] = 501] = "Tier5Section1";
|
|
602
|
+
Level2[Level2["Tier5Section2"] = 502] = "Tier5Section2";
|
|
603
|
+
Level2[Level2["Tier5Section3"] = 503] = "Tier5Section3";
|
|
604
|
+
Level2[Level2["Tier6Section1"] = 601] = "Tier6Section1";
|
|
605
|
+
Level2[Level2["Tier6Section2"] = 602] = "Tier6Section2";
|
|
606
|
+
Level2[Level2["Tier6Section3"] = 603] = "Tier6Section3";
|
|
607
|
+
Level2[Level2["Tier7Section1"] = 701] = "Tier7Section1";
|
|
608
|
+
Level2[Level2["Tier7Section2"] = 702] = "Tier7Section2";
|
|
609
|
+
Level2[Level2["Tier7Section3"] = 703] = "Tier7Section3";
|
|
610
|
+
Level2[Level2["Tier8Section1"] = 801] = "Tier8Section1";
|
|
611
|
+
Level2[Level2["Tier8Section2"] = 802] = "Tier8Section2";
|
|
612
|
+
Level2[Level2["Tier8Section3"] = 803] = "Tier8Section3";
|
|
613
|
+
Level2[Level2["Tier9Section1"] = 901] = "Tier9Section1";
|
|
614
|
+
Level2[Level2["Tier9Section2"] = 902] = "Tier9Section2";
|
|
615
|
+
Level2[Level2["Tier9Section3"] = 903] = "Tier9Section3";
|
|
616
|
+
Level2[Level2["Tier10Section1"] = 1001] = "Tier10Section1";
|
|
617
|
+
Level2[Level2["Tier10Section2"] = 1002] = "Tier10Section2";
|
|
618
|
+
Level2[Level2["Tier10Section3"] = 1003] = "Tier10Section3";
|
|
619
|
+
return Level2;
|
|
620
|
+
})(Level || {});
|
|
621
|
+
|
|
622
|
+
// src/models/ResponseRating.ts
|
|
623
|
+
var ResponseRating = /* @__PURE__ */ ((ResponseRating2) => {
|
|
624
|
+
ResponseRating2[ResponseRating2["NONE"] = 0] = "NONE";
|
|
625
|
+
ResponseRating2[ResponseRating2["GOOD"] = 1] = "GOOD";
|
|
626
|
+
ResponseRating2[ResponseRating2["BAD"] = 2] = "BAD";
|
|
627
|
+
return ResponseRating2;
|
|
628
|
+
})(ResponseRating || {});
|
|
629
|
+
|
|
630
|
+
// src/models/ThreatLevel.ts
|
|
631
|
+
var ThreatLevel = /* @__PURE__ */ ((ThreatLevel2) => {
|
|
632
|
+
ThreatLevel2[ThreatLevel2["UNKNOWN"] = 0] = "UNKNOWN";
|
|
633
|
+
ThreatLevel2[ThreatLevel2["LOW"] = 1] = "LOW";
|
|
634
|
+
ThreatLevel2[ThreatLevel2["MEDIUM"] = 2] = "MEDIUM";
|
|
635
|
+
ThreatLevel2[ThreatLevel2["HIGH"] = 3] = "HIGH";
|
|
636
|
+
return ThreatLevel2;
|
|
637
|
+
})(ThreatLevel || {});
|
|
638
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
639
|
+
0 && (module.exports = {
|
|
640
|
+
AccountDeactivationReason,
|
|
641
|
+
ApiEndpoint,
|
|
642
|
+
AuthEndpoint,
|
|
643
|
+
CancellationReason,
|
|
644
|
+
ChatMessageEndpoint,
|
|
645
|
+
Class,
|
|
646
|
+
ClientEndpoint,
|
|
647
|
+
EmergencyEndpoint,
|
|
648
|
+
Level,
|
|
649
|
+
LocationType,
|
|
650
|
+
MedrunnerApiClient,
|
|
651
|
+
MissionServices,
|
|
652
|
+
MissionStatus,
|
|
653
|
+
Origin,
|
|
654
|
+
PersonType,
|
|
655
|
+
ResponseRating,
|
|
656
|
+
StaffEndpoint,
|
|
657
|
+
SubmissionSource,
|
|
658
|
+
ThreatLevel,
|
|
659
|
+
TokenManager,
|
|
660
|
+
UserRoles,
|
|
661
|
+
WebsocketEndpoint
|
|
662
|
+
});
|
|
663
|
+
//# sourceMappingURL=index.js.map
|