@medrunner/api-client 0.3.7 → 0.4.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.
- package/dist/index.d.mts +364 -17
- package/dist/index.d.ts +364 -17
- package/dist/index.js +15 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -16,9 +16,21 @@ interface DbItem {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
interface ApiToken extends DbItem {
|
|
19
|
+
/**
|
|
20
|
+
* The user who created the token
|
|
21
|
+
* */
|
|
19
22
|
userId: string;
|
|
23
|
+
/**
|
|
24
|
+
* Human-readable name for the token, assigned by the user
|
|
25
|
+
* */
|
|
20
26
|
name: string;
|
|
27
|
+
/**
|
|
28
|
+
* The timestamp at which the token will expire in Unix seconds
|
|
29
|
+
* */
|
|
21
30
|
expirationDate?: number;
|
|
31
|
+
/**
|
|
32
|
+
* When the token was last used to generate a new access token, iso-8601 timestamp
|
|
33
|
+
* */
|
|
22
34
|
lastUsed?: string;
|
|
23
35
|
}
|
|
24
36
|
|
|
@@ -36,10 +48,28 @@ interface TokenGrant {
|
|
|
36
48
|
refreshTokenExpiration?: string;
|
|
37
49
|
}
|
|
38
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Configuration for the Medrunner API.
|
|
53
|
+
* */
|
|
39
54
|
interface ApiConfig {
|
|
55
|
+
/**
|
|
56
|
+
* The base URL of the API - defaults to https://api.medrunner.space
|
|
57
|
+
* */
|
|
40
58
|
baseUrl?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Your API token retrieved after logging in. If none is provided, the refresh token will be used to retrieve an
|
|
61
|
+
* access token.
|
|
62
|
+
* */
|
|
41
63
|
accessToken?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Your refresh token, used to obtain new API tokens. If none is provided, authenticated requests will not be possible
|
|
66
|
+
* when the {@link accessToken} expires. If no access token is provided either, only unauthenticated requests are
|
|
67
|
+
* possible.
|
|
68
|
+
* */
|
|
42
69
|
refreshToken?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Use cookie base auth instead of tokens - defaults to false
|
|
72
|
+
* */
|
|
43
73
|
cookieAuth?: boolean;
|
|
44
74
|
}
|
|
45
75
|
|
|
@@ -88,49 +118,162 @@ declare abstract class ApiEndpoint {
|
|
|
88
118
|
private makeRequest;
|
|
89
119
|
}
|
|
90
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Request body for creating an api token.
|
|
123
|
+
* */
|
|
91
124
|
interface CreateApiTokenRequest {
|
|
125
|
+
/**
|
|
126
|
+
* Human-readable name for the token
|
|
127
|
+
* */
|
|
92
128
|
name: string;
|
|
129
|
+
/**
|
|
130
|
+
* Optional expiration date for the token
|
|
131
|
+
* */
|
|
93
132
|
expirationDate?: Date;
|
|
94
133
|
}
|
|
95
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Request body for sign-out.
|
|
137
|
+
* */
|
|
96
138
|
interface SignOutRequest {
|
|
139
|
+
/**
|
|
140
|
+
* The refresh token to be invalidated
|
|
141
|
+
* */
|
|
97
142
|
refreshToken: string;
|
|
98
143
|
}
|
|
99
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Endpoints for interacting with auth.
|
|
147
|
+
* */
|
|
100
148
|
declare class AuthEndpoint extends ApiEndpoint {
|
|
101
149
|
constructor(config: DefaultApiConfig, tokenManager: TokenManager, log?: Logger, headerProvider?: HeaderProvider);
|
|
102
150
|
protected endpoint(): string;
|
|
151
|
+
/**
|
|
152
|
+
* Invalidate a refresh token.
|
|
153
|
+
*
|
|
154
|
+
* @param oldToken - Token to be invalidated
|
|
155
|
+
*
|
|
156
|
+
* */
|
|
103
157
|
signOut(oldToken?: SignOutRequest): Promise<ApiResponse>;
|
|
158
|
+
/**
|
|
159
|
+
* Gets all api tokens for the user.
|
|
160
|
+
*
|
|
161
|
+
* */
|
|
104
162
|
getApiTokens(): Promise<ApiResponse<ApiToken[]>>;
|
|
163
|
+
/**
|
|
164
|
+
* Creates an api token.
|
|
165
|
+
*
|
|
166
|
+
* @param newToken - Emergency details for the new emergency
|
|
167
|
+
* @returns The newly-created api token
|
|
168
|
+
*
|
|
169
|
+
* */
|
|
105
170
|
createApiToken(newToken: CreateApiTokenRequest): Promise<ApiResponse<string>>;
|
|
171
|
+
/**
|
|
172
|
+
* Delete an api token.
|
|
173
|
+
*
|
|
174
|
+
* @param id - The id of the api token to delete
|
|
175
|
+
*
|
|
176
|
+
* */
|
|
106
177
|
deleteApiToken(id: string): Promise<ApiResponse>;
|
|
107
178
|
}
|
|
108
179
|
|
|
109
180
|
interface ChatMessage extends DbItem {
|
|
181
|
+
/**
|
|
182
|
+
* The emergency associated with the chat message
|
|
183
|
+
* */
|
|
110
184
|
emergencyId: string;
|
|
185
|
+
/**
|
|
186
|
+
* The user id of the message sender
|
|
187
|
+
* */
|
|
111
188
|
senderId: string;
|
|
189
|
+
/**
|
|
190
|
+
* The timestamp at which the message was sent in Unix seconds
|
|
191
|
+
* */
|
|
112
192
|
messageSentTimestamp: number;
|
|
193
|
+
/**
|
|
194
|
+
* The contents of the message
|
|
195
|
+
* */
|
|
113
196
|
contents: string;
|
|
197
|
+
/**
|
|
198
|
+
* Whether the message has been edited
|
|
199
|
+
* */
|
|
114
200
|
edited: boolean;
|
|
115
201
|
}
|
|
116
202
|
|
|
203
|
+
/**
|
|
204
|
+
* Response data which is paginated and includes the data and a token to get the next page.
|
|
205
|
+
* */
|
|
117
206
|
interface PaginatedResponse<T = unknown> {
|
|
207
|
+
/**
|
|
208
|
+
* The page of data returned by the request
|
|
209
|
+
* */
|
|
118
210
|
data: T[];
|
|
211
|
+
/**
|
|
212
|
+
* The pagination token to get the next page of data in a subsequent request
|
|
213
|
+
* */
|
|
119
214
|
paginationToken?: string;
|
|
120
215
|
}
|
|
121
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Request body for creating a new chat message.
|
|
219
|
+
* */
|
|
122
220
|
interface ChatMessageRequest {
|
|
221
|
+
/**
|
|
222
|
+
* The id of the emergency associated with the message
|
|
223
|
+
* */
|
|
123
224
|
emergencyId: string;
|
|
225
|
+
/**
|
|
226
|
+
* The message contents
|
|
227
|
+
* */
|
|
124
228
|
contents: string;
|
|
125
229
|
}
|
|
126
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Endpoints for interacting with chat messages.
|
|
233
|
+
* */
|
|
127
234
|
declare class ChatMessageEndpoint extends ApiEndpoint {
|
|
128
235
|
constructor(config: DefaultApiConfig, tokenManager: TokenManager, log?: Logger, headerProvider?: HeaderProvider);
|
|
129
236
|
protected endpoint(): string;
|
|
130
|
-
|
|
237
|
+
/**
|
|
238
|
+
* Fetch a chat message
|
|
239
|
+
*
|
|
240
|
+
* @param id - The id of the message
|
|
241
|
+
* @returns The chat message
|
|
242
|
+
*
|
|
243
|
+
* */
|
|
244
|
+
getMessage(id: string): Promise<ApiResponse<ChatMessage>>;
|
|
245
|
+
/**
|
|
246
|
+
* Gets the specified amount of chat messages for a given emergency.
|
|
247
|
+
*
|
|
248
|
+
* @param emergencyId - The emergency for which to fetch the chat history
|
|
249
|
+
* @param limit - The number of emergencies to get
|
|
250
|
+
* @param paginationToken - The number to use for pagination
|
|
251
|
+
* */
|
|
131
252
|
getMessageHistory(emergencyId: string, limit: number, paginationToken?: string): Promise<ApiResponse<PaginatedResponse<ChatMessage>>>;
|
|
253
|
+
/**
|
|
254
|
+
* Sends a new chat message
|
|
255
|
+
*
|
|
256
|
+
* @param message - The message to send
|
|
257
|
+
* @returns The newly-created chat message
|
|
258
|
+
*
|
|
259
|
+
* */
|
|
132
260
|
sendMessage(message: ChatMessageRequest): Promise<ApiResponse<ChatMessage>>;
|
|
261
|
+
/**
|
|
262
|
+
* Update a chat message
|
|
263
|
+
*
|
|
264
|
+
* @param id - The id of the message to update
|
|
265
|
+
* @param contents - The new content of the message
|
|
266
|
+
* @returns The updated chat message
|
|
267
|
+
*
|
|
268
|
+
* */
|
|
133
269
|
updateMessage(id: string, contents: string): Promise<ApiResponse<ChatMessage>>;
|
|
270
|
+
/**
|
|
271
|
+
* Delete a chat message
|
|
272
|
+
*
|
|
273
|
+
* @param id - The id of the message to delete
|
|
274
|
+
*
|
|
275
|
+
* */
|
|
276
|
+
deleteMessage(id: string): Promise<ApiResponse>;
|
|
134
277
|
}
|
|
135
278
|
|
|
136
279
|
interface ClientHistory extends DbItem {
|
|
@@ -162,6 +305,9 @@ interface Person extends WritableDbItem {
|
|
|
162
305
|
deactivationReason: AccountDeactivationReason;
|
|
163
306
|
clientStats: ClientStats;
|
|
164
307
|
activeEmergency?: string;
|
|
308
|
+
/**
|
|
309
|
+
* @deprecated Use {@link Person.clientPortalPreferencesBlob} instead.
|
|
310
|
+
*/
|
|
165
311
|
clientPortalPreferences: Record<string, unknown>;
|
|
166
312
|
clientPortalPreferencesBlob?: string;
|
|
167
313
|
redeemedCodes: RedeemedCode[];
|
|
@@ -200,21 +346,58 @@ declare enum CodeType {
|
|
|
200
346
|
CitizenCon2954 = 1
|
|
201
347
|
}
|
|
202
348
|
|
|
349
|
+
/**
|
|
350
|
+
* Endpoints for interacting with clients.
|
|
351
|
+
* */
|
|
203
352
|
declare class ClientEndpoint extends ApiEndpoint {
|
|
204
353
|
constructor(config: DefaultApiConfig, tokenManager: TokenManager, log?: Logger, headerProvider?: HeaderProvider);
|
|
205
354
|
protected endpoint(): string;
|
|
355
|
+
/**
|
|
356
|
+
* Gets the current client.
|
|
357
|
+
* */
|
|
206
358
|
get(): Promise<ApiResponse<Person>>;
|
|
359
|
+
/**
|
|
360
|
+
* Gets the specified amount of emergencies the client has created.
|
|
361
|
+
* @param limit - The number of emergencies to get
|
|
362
|
+
* @param paginationToken - The number to use for pagination
|
|
363
|
+
* */
|
|
207
364
|
getHistory(limit: number, paginationToken?: string): Promise<ApiResponse<PaginatedResponse<ClientHistory>>>;
|
|
365
|
+
/**
|
|
366
|
+
* Gets the blocklist status of the current client.
|
|
367
|
+
* */
|
|
208
368
|
getBlockedStatus(): Promise<ApiResponse<BlockedStatus>>;
|
|
209
|
-
|
|
210
|
-
|
|
369
|
+
/**
|
|
370
|
+
* Links the current user to a rsiHandle.
|
|
371
|
+
*
|
|
372
|
+
* @param rsiHandle - The RSI handle of the client
|
|
373
|
+
* @returns The updated Person object of the client
|
|
374
|
+
*
|
|
375
|
+
* */
|
|
376
|
+
linkClient(rsiHandle: string): Promise<ApiResponse<Person>>;
|
|
377
|
+
/**
|
|
378
|
+
* Updates the settings of the current user for the Client Portal.
|
|
379
|
+
*
|
|
380
|
+
* @param settings - The object settings to add or update
|
|
381
|
+
*
|
|
382
|
+
* */
|
|
211
383
|
setUserSettings(settings: string): Promise<ApiResponse>;
|
|
384
|
+
/**
|
|
385
|
+
* Deactivate the current client.
|
|
386
|
+
* */
|
|
212
387
|
deactivate(): Promise<ApiResponse>;
|
|
213
388
|
}
|
|
214
389
|
|
|
390
|
+
/**
|
|
391
|
+
* Endpoints for interacting with promotional codes.
|
|
392
|
+
* */
|
|
215
393
|
declare class CodeEndpoint extends ApiEndpoint {
|
|
216
394
|
constructor(config: DefaultApiConfig, tokenManager: TokenManager, log?: Logger, headerProvider?: HeaderProvider);
|
|
217
395
|
protected endpoint(): string;
|
|
396
|
+
/**
|
|
397
|
+
* Redeems the specified promotional code for the current user
|
|
398
|
+
*
|
|
399
|
+
* @param code - The code to redeem.
|
|
400
|
+
* */
|
|
218
401
|
redeem(code: string): Promise<ApiResponse>;
|
|
219
402
|
}
|
|
220
403
|
|
|
@@ -297,7 +480,6 @@ interface Emergency extends WritableDbItem {
|
|
|
297
480
|
clientMessage?: MessageCache;
|
|
298
481
|
coordinationThread?: MessageCache;
|
|
299
482
|
afterActionReportMessage?: MessageCache;
|
|
300
|
-
interactionMessageId?: string;
|
|
301
483
|
respondingTeam: Team;
|
|
302
484
|
respondingTeams: RespondingTeam[];
|
|
303
485
|
creationTimestamp: number;
|
|
@@ -363,30 +545,51 @@ interface RespondingTeam {
|
|
|
363
545
|
teamName: string;
|
|
364
546
|
}
|
|
365
547
|
|
|
548
|
+
/**
|
|
549
|
+
* Request body for creating a new emergency.
|
|
550
|
+
* */
|
|
366
551
|
interface CreateEmergencyRequest {
|
|
552
|
+
/**
|
|
553
|
+
* Additional details or remarks to include
|
|
554
|
+
* */
|
|
367
555
|
remarks?: string;
|
|
556
|
+
/**
|
|
557
|
+
* The location of the emergency
|
|
558
|
+
* */
|
|
368
559
|
location: Location;
|
|
560
|
+
/**
|
|
561
|
+
* The threat level of the emergency
|
|
562
|
+
*
|
|
563
|
+
* @remarks
|
|
564
|
+
* This will be removed in the future.
|
|
565
|
+
* */
|
|
369
566
|
threatLevel: ThreatLevel;
|
|
567
|
+
/**
|
|
568
|
+
* The rsiHandle of the client
|
|
569
|
+
*
|
|
570
|
+
* @remarks
|
|
571
|
+
* This is optional, if the client already has an RSI handle set on his profile, this will be ignored.
|
|
572
|
+
* */
|
|
370
573
|
rsiHandle?: string;
|
|
371
574
|
}
|
|
575
|
+
/**
|
|
576
|
+
* Only real matching locations will be accepted (see /emergency/meta/locations).
|
|
577
|
+
* */
|
|
372
578
|
interface Location {
|
|
579
|
+
/**
|
|
580
|
+
* The star system the emergency is located in
|
|
581
|
+
* */
|
|
373
582
|
system: string;
|
|
583
|
+
/**
|
|
584
|
+
* The nearest planetary body to the emergency
|
|
585
|
+
* */
|
|
374
586
|
subsystem: string;
|
|
587
|
+
/**
|
|
588
|
+
* The nearest moon to the emergency, if applicable
|
|
589
|
+
* */
|
|
375
590
|
tertiaryLocation?: string;
|
|
376
591
|
}
|
|
377
592
|
|
|
378
|
-
interface LocationDetail {
|
|
379
|
-
name: string;
|
|
380
|
-
type: LocationType;
|
|
381
|
-
children: LocationDetail[];
|
|
382
|
-
}
|
|
383
|
-
declare enum LocationType {
|
|
384
|
-
UNKNOWN = 0,
|
|
385
|
-
SYSTEM = 1,
|
|
386
|
-
PLANET = 2,
|
|
387
|
-
MOON = 3
|
|
388
|
-
}
|
|
389
|
-
|
|
390
593
|
declare enum Level {
|
|
391
594
|
None = 0,
|
|
392
595
|
Tier1Section1 = 101,
|
|
@@ -421,27 +624,93 @@ declare enum Level {
|
|
|
421
624
|
Tier10Section3 = 1003
|
|
422
625
|
}
|
|
423
626
|
|
|
627
|
+
/**
|
|
628
|
+
* Details about a team responding to an alert.
|
|
629
|
+
* */
|
|
424
630
|
interface TeamDetailsResponse {
|
|
631
|
+
/**
|
|
632
|
+
* Details about each individual responder.
|
|
633
|
+
* */
|
|
425
634
|
stats: ResponderDetails[];
|
|
635
|
+
/**
|
|
636
|
+
* The aggregated mission success rate from all responders, appropriately weighted by number of missions.
|
|
637
|
+
* */
|
|
426
638
|
aggregatedSuccessRate: number;
|
|
427
639
|
}
|
|
640
|
+
/**
|
|
641
|
+
* Details about an alert responder.
|
|
642
|
+
* */
|
|
428
643
|
interface ResponderDetails {
|
|
644
|
+
/**
|
|
645
|
+
* The responder's id.
|
|
646
|
+
* */
|
|
429
647
|
id: string;
|
|
648
|
+
/**
|
|
649
|
+
* The responder's level.
|
|
650
|
+
* */
|
|
430
651
|
level: Level;
|
|
652
|
+
/**
|
|
653
|
+
* The success rate of all prior missions this staff member has responded to.
|
|
654
|
+
* */
|
|
431
655
|
missionSuccessRate: number;
|
|
656
|
+
/**
|
|
657
|
+
* The success rate of all prior missions this staff member has acted as a dispatcher for.
|
|
658
|
+
* */
|
|
432
659
|
dispatchSuccessRate: number;
|
|
433
660
|
}
|
|
434
661
|
|
|
662
|
+
/**
|
|
663
|
+
* Endpoints for interacting with emergencies.
|
|
664
|
+
* */
|
|
435
665
|
declare class EmergencyEndpoint extends ApiEndpoint {
|
|
436
666
|
constructor(config: DefaultApiConfig, tokenManager: TokenManager, log?: Logger, headerProvider?: HeaderProvider);
|
|
437
667
|
protected endpoint(): string;
|
|
668
|
+
/**
|
|
669
|
+
* Gets an emergency by id.
|
|
670
|
+
*
|
|
671
|
+
* @param id - The id of the emergency to retrieve
|
|
672
|
+
* */
|
|
438
673
|
getEmergency(id: string): Promise<ApiResponse<Emergency>>;
|
|
674
|
+
/**
|
|
675
|
+
* Bulk fetches emergencies by id.
|
|
676
|
+
*
|
|
677
|
+
* @param ids - a list of emergencies to retrieve
|
|
678
|
+
* */
|
|
439
679
|
getEmergencies(ids: string[]): Promise<ApiResponse<Emergency[]>>;
|
|
680
|
+
/**
|
|
681
|
+
* Creates a new emergency.
|
|
682
|
+
*
|
|
683
|
+
* @param newEmergency - Emergency details for the new emergency
|
|
684
|
+
* @returns The newly-created emergency
|
|
685
|
+
*
|
|
686
|
+
* */
|
|
440
687
|
createEmergency(newEmergency: CreateEmergencyRequest): Promise<ApiResponse<Emergency>>;
|
|
688
|
+
/**
|
|
689
|
+
* Cancels an existing emergency.
|
|
690
|
+
*
|
|
691
|
+
* @remarks
|
|
692
|
+
* Emergency must still be in the {@link MissionStatus.RECEIVED} state in order to be canceled.
|
|
693
|
+
*
|
|
694
|
+
* @param id - The id of the emergency to cancel
|
|
695
|
+
* @param reason - The reason the emergency was canceled
|
|
696
|
+
* */
|
|
441
697
|
cancelEmergencyWithReason(id: string, reason: CancellationReason): Promise<ApiResponse>;
|
|
698
|
+
/**
|
|
699
|
+
* Allows the client to rate their emergency.
|
|
700
|
+
*
|
|
701
|
+
* @param id - The id of the emergency to rate
|
|
702
|
+
* @param rating - The rating to give the services provided
|
|
703
|
+
* @param remarks - Additional remarks provided by the client
|
|
704
|
+
*
|
|
705
|
+
* @internal
|
|
706
|
+
* */
|
|
442
707
|
rateServices(id: string, rating: ResponseRating, remarks?: string): Promise<ApiResponse>;
|
|
708
|
+
/**
|
|
709
|
+
* Fetches additional details about the responding team for an alert.
|
|
710
|
+
*
|
|
711
|
+
* @param id - The id of the emergency to get team details about
|
|
712
|
+
* */
|
|
443
713
|
teamDetails(id: string): Promise<ApiResponse<TeamDetailsResponse>>;
|
|
444
|
-
emergencyLocations(): Promise<ApiResponse<LocationDetail[]>>;
|
|
445
714
|
}
|
|
446
715
|
|
|
447
716
|
interface OrgSettings extends WritableDbItem {
|
|
@@ -486,27 +755,56 @@ declare enum ServiceStatus {
|
|
|
486
755
|
OFFLINE = 4
|
|
487
756
|
}
|
|
488
757
|
|
|
758
|
+
/**
|
|
759
|
+
* Endpoints for interacting with the public org settings.
|
|
760
|
+
* */
|
|
489
761
|
declare class OrgSettingsEndpoint extends ApiEndpoint {
|
|
490
762
|
constructor(config: DefaultApiConfig, tokenManager: TokenManager, log?: Logger, headerProvider?: HeaderProvider);
|
|
491
763
|
protected endpoint(): string;
|
|
764
|
+
/**
|
|
765
|
+
* Get the public org settings.
|
|
766
|
+
*
|
|
767
|
+
* */
|
|
492
768
|
getPublicSettings(): Promise<ApiResponse<PublicOrgSettings>>;
|
|
493
769
|
}
|
|
494
770
|
|
|
771
|
+
/**
|
|
772
|
+
* Information about a medal
|
|
773
|
+
* */
|
|
495
774
|
interface MedalInformation {
|
|
775
|
+
/**
|
|
776
|
+
* The level linked to the medal
|
|
777
|
+
* */
|
|
496
778
|
level: Level;
|
|
779
|
+
/**
|
|
780
|
+
* The number of successful missions required to earn the medal
|
|
781
|
+
* */
|
|
497
782
|
successfulMissions: number;
|
|
498
783
|
}
|
|
499
784
|
|
|
785
|
+
/**
|
|
786
|
+
* Endpoints for interacting with staff.
|
|
787
|
+
* */
|
|
500
788
|
declare class StaffEndpoint extends ApiEndpoint {
|
|
501
789
|
constructor(config: DefaultApiConfig, tokenManager: TokenManager, log?: Logger, headerProvider?: HeaderProvider);
|
|
502
790
|
protected endpoint(): string;
|
|
791
|
+
/**
|
|
792
|
+
* Gets detailed information about medals.
|
|
793
|
+
* */
|
|
503
794
|
medalsInformation(): Promise<ApiResponse<MedalInformation[]>>;
|
|
504
795
|
}
|
|
505
796
|
|
|
797
|
+
/**
|
|
798
|
+
* Endpoints for interacting with emergencies.
|
|
799
|
+
* */
|
|
506
800
|
declare class WebsocketEndpoint extends ApiEndpoint {
|
|
507
801
|
constructor(config: DefaultApiConfig, tokenManager: TokenManager, log?: Logger, headerProvider?: HeaderProvider);
|
|
508
802
|
private websocketManager;
|
|
509
803
|
protected endpoint(): string;
|
|
804
|
+
/**
|
|
805
|
+
* Gets realtime updates.
|
|
806
|
+
*
|
|
807
|
+
* */
|
|
510
808
|
initialize(): Promise<HubConnection>;
|
|
511
809
|
}
|
|
512
810
|
|
|
@@ -521,6 +819,9 @@ interface ApiClient<TEmergency extends EmergencyEndpoint = EmergencyEndpoint, TC
|
|
|
521
819
|
websocket: TWebsocket;
|
|
522
820
|
}
|
|
523
821
|
|
|
822
|
+
/**
|
|
823
|
+
* An API client for basic client interactions with the Medrunner API.
|
|
824
|
+
* */
|
|
524
825
|
declare class MedrunnerApiClient<TEmergency extends EmergencyEndpoint = EmergencyEndpoint, TClient extends ClientEndpoint = ClientEndpoint, TStaff extends StaffEndpoint = StaffEndpoint, TOrgSettings extends OrgSettingsEndpoint = OrgSettingsEndpoint, TChatMessage extends ChatMessageEndpoint = ChatMessageEndpoint, TCode extends CodeEndpoint = CodeEndpoint, TAuth extends AuthEndpoint = AuthEndpoint, TWebsocket extends WebsocketEndpoint = WebsocketEndpoint> implements ApiClient<TEmergency, TClient, TStaff, TOrgSettings, TChatMessage, TCode, TAuth, TWebsocket> {
|
|
525
826
|
readonly emergency: TEmergency;
|
|
526
827
|
readonly client: TClient;
|
|
@@ -531,9 +832,55 @@ declare class MedrunnerApiClient<TEmergency extends EmergencyEndpoint = Emergenc
|
|
|
531
832
|
readonly auth: TAuth;
|
|
532
833
|
readonly websocket: TWebsocket;
|
|
533
834
|
protected constructor(emergency: TEmergency, client: TClient, staff: TStaff, orgSettings: TOrgSettings, chatMessage: TChatMessage, code: TCode, auth: TAuth, websocket: TWebsocket);
|
|
835
|
+
/**
|
|
836
|
+
* Constructs a new API client.
|
|
837
|
+
*
|
|
838
|
+
* @param config - The API configuration
|
|
839
|
+
* @param refreshCallback - a callback function called whenever a refresh token exchange is performed
|
|
840
|
+
* @param log - A logger which logs request details
|
|
841
|
+
* */
|
|
534
842
|
static buildClient(config: ApiConfig, refreshCallback?: AsyncAction<TokenGrant>, log?: Logger): MedrunnerApiClient;
|
|
535
843
|
}
|
|
536
844
|
|
|
845
|
+
/**
|
|
846
|
+
* A supported location from which an emergency may be submitted.
|
|
847
|
+
* */
|
|
848
|
+
interface LocationDetail {
|
|
849
|
+
/**
|
|
850
|
+
* The name of this location
|
|
851
|
+
* */
|
|
852
|
+
name: string;
|
|
853
|
+
/**
|
|
854
|
+
* The type of this location
|
|
855
|
+
* */
|
|
856
|
+
type: LocationType;
|
|
857
|
+
/**
|
|
858
|
+
* Additional locations which are within this location (e.g. moons of a planet, or planets of a system)
|
|
859
|
+
* */
|
|
860
|
+
children: LocationDetail[];
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* The type of location.
|
|
864
|
+
* */
|
|
865
|
+
declare enum LocationType {
|
|
866
|
+
/**
|
|
867
|
+
* The location type is not known
|
|
868
|
+
* */
|
|
869
|
+
UNKNOWN = 0,
|
|
870
|
+
/**
|
|
871
|
+
* A system, e.g. Stanton
|
|
872
|
+
* */
|
|
873
|
+
SYSTEM = 1,
|
|
874
|
+
/**
|
|
875
|
+
* A planet, e.g. Crusader
|
|
876
|
+
* */
|
|
877
|
+
PLANET = 2,
|
|
878
|
+
/**
|
|
879
|
+
* A moon, e.g. Daymar
|
|
880
|
+
* */
|
|
881
|
+
MOON = 3
|
|
882
|
+
}
|
|
883
|
+
|
|
537
884
|
interface Deployment {
|
|
538
885
|
clientType: ClientType;
|
|
539
886
|
version: string;
|
package/dist/index.js
CHANGED
|
@@ -326,16 +326,14 @@ var ChatMessageEndpoint = class extends ApiEndpoint {
|
|
|
326
326
|
return "chatMessage";
|
|
327
327
|
}
|
|
328
328
|
/**
|
|
329
|
-
*
|
|
329
|
+
* Fetch a chat message
|
|
330
330
|
*
|
|
331
|
-
* @
|
|
331
|
+
* @param id - The id of the message
|
|
332
|
+
* @returns The chat message
|
|
332
333
|
*
|
|
333
|
-
* @param emergencyId - The emergency for which to fetch the chat history
|
|
334
|
-
* @param limit - The number of emergencies to get
|
|
335
|
-
* @param paginationToken - The number to use for pagination
|
|
336
334
|
* */
|
|
337
|
-
async
|
|
338
|
-
return await this.getRequest(
|
|
335
|
+
async getMessage(id) {
|
|
336
|
+
return await this.getRequest(id);
|
|
339
337
|
}
|
|
340
338
|
/**
|
|
341
339
|
* Gets the specified amount of chat messages for a given emergency.
|
|
@@ -371,6 +369,15 @@ var ChatMessageEndpoint = class extends ApiEndpoint {
|
|
|
371
369
|
async updateMessage(id, contents) {
|
|
372
370
|
return await this.putRequest(id, { contents });
|
|
373
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* Delete a chat message
|
|
374
|
+
*
|
|
375
|
+
* @param id - The id of the message to delete
|
|
376
|
+
*
|
|
377
|
+
* */
|
|
378
|
+
async deleteMessage(id) {
|
|
379
|
+
return await this.deleteRequest(id);
|
|
380
|
+
}
|
|
374
381
|
};
|
|
375
382
|
|
|
376
383
|
// src/api/endpoints/client/ClientEndpoint.ts
|
|
@@ -408,22 +415,12 @@ var ClientEndpoint = class extends ApiEndpoint {
|
|
|
408
415
|
* Links the current user to a rsiHandle.
|
|
409
416
|
*
|
|
410
417
|
* @param rsiHandle - The RSI handle of the client
|
|
418
|
+
* @returns The updated Person object of the client
|
|
411
419
|
*
|
|
412
420
|
* */
|
|
413
421
|
async linkClient(rsiHandle) {
|
|
414
422
|
return await this.postRequest("/link", { rsiHandle });
|
|
415
423
|
}
|
|
416
|
-
/**
|
|
417
|
-
* Updates the settings of the current user for the Client Portal.
|
|
418
|
-
*
|
|
419
|
-
* @deprecated Use {@link setUserSettings} instead
|
|
420
|
-
* @param settings - The stringfied new object settings that will replace the old one
|
|
421
|
-
* @returns The updated settings object
|
|
422
|
-
*
|
|
423
|
-
* */
|
|
424
|
-
async setSettings(settings) {
|
|
425
|
-
return await this.patchRequest("/settings/clientPortal", settings);
|
|
426
|
-
}
|
|
427
424
|
/**
|
|
428
425
|
* Updates the settings of the current user for the Client Portal.
|
|
429
426
|
*
|
|
@@ -536,14 +533,6 @@ var EmergencyEndpoint = class extends ApiEndpoint {
|
|
|
536
533
|
async teamDetails(id) {
|
|
537
534
|
return await this.getRequest(`/${id}/teamDetails`);
|
|
538
535
|
}
|
|
539
|
-
/**
|
|
540
|
-
* Gets a tree of valid locations from which an emergency may be submitted.
|
|
541
|
-
*
|
|
542
|
-
* @deprecated Use {@link getPublicSettings} instead.
|
|
543
|
-
* */
|
|
544
|
-
async emergencyLocations() {
|
|
545
|
-
return await this.getRequest("/meta/locations");
|
|
546
|
-
}
|
|
547
536
|
};
|
|
548
537
|
|
|
549
538
|
// src/api/endpoints/orgSettings/OrgSettingsEndpoint.ts
|