@sonoransoftware/sonoran.js 1.0.42 → 1.0.46
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/libs/rest/src/lib/REST.js +19 -2
- package/dist/libs/rest/src/lib/RequestManager.js +21 -5
- package/dist/libs/rest/src/lib/utils/constants.d.ts +12 -1
- package/dist/managers/CADManager.d.ts +7 -0
- package/dist/managers/CADManager.js +23 -6
- package/dist/managers/RadioManager.d.ts +2 -1
- package/dist/managers/RadioManager.js +3 -2
- package/package.json +1 -1
- package/readme.md +12 -4
- package/src/libs/rest/src/lib/REST.ts +24 -2
- package/src/libs/rest/src/lib/RequestManager.ts +16 -2
- package/src/libs/rest/src/lib/utils/constants.ts +14 -2
- package/src/managers/CADManager.ts +30 -4
- package/src/managers/RadioManager.ts +3 -2
|
@@ -195,6 +195,18 @@ class REST extends events_1.EventEmitter {
|
|
|
195
195
|
type: args[5]
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
|
+
case 'UNIT_STATUS': {
|
|
199
|
+
const payload = args[0];
|
|
200
|
+
if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
|
|
201
|
+
const { apiId, account, status, serverId } = payload;
|
|
202
|
+
return { apiId, account, status, serverId };
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
apiId: args[0],
|
|
206
|
+
status: args[1],
|
|
207
|
+
serverId: args[2]
|
|
208
|
+
};
|
|
209
|
+
}
|
|
198
210
|
case 'CHECK_COM_APIID': {
|
|
199
211
|
return {
|
|
200
212
|
apiId: args[0]
|
|
@@ -254,6 +266,10 @@ class REST extends events_1.EventEmitter {
|
|
|
254
266
|
};
|
|
255
267
|
}
|
|
256
268
|
case 'LOOKUP': {
|
|
269
|
+
const payload = args[0];
|
|
270
|
+
if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
|
|
271
|
+
return args;
|
|
272
|
+
}
|
|
257
273
|
return {
|
|
258
274
|
id: args[0],
|
|
259
275
|
uuid: args[1]
|
|
@@ -348,8 +364,9 @@ class REST extends events_1.EventEmitter {
|
|
|
348
364
|
}
|
|
349
365
|
case 'RADIO_SET_USER_CHANNELS': {
|
|
350
366
|
return {
|
|
351
|
-
|
|
352
|
-
|
|
367
|
+
roomId: args[0],
|
|
368
|
+
identity: args[1],
|
|
369
|
+
options: (_c = args[2]) !== null && _c !== void 0 ? _c : {}
|
|
353
370
|
};
|
|
354
371
|
}
|
|
355
372
|
case 'RADIO_SET_USER_DISPLAY_NAME': {
|
|
@@ -130,7 +130,15 @@ class RequestManager extends events_1.EventEmitter {
|
|
|
130
130
|
break;
|
|
131
131
|
}
|
|
132
132
|
case 'LOOKUP': {
|
|
133
|
-
|
|
133
|
+
if (Array.isArray(clonedData)) {
|
|
134
|
+
apiData.data.data = clonedData.length > 0 ? clonedData : [];
|
|
135
|
+
}
|
|
136
|
+
else if (clonedData !== undefined && clonedData !== null) {
|
|
137
|
+
apiData.data.data = [clonedData];
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
apiData.data.data = [];
|
|
141
|
+
}
|
|
134
142
|
break;
|
|
135
143
|
}
|
|
136
144
|
case 'SET_ACCOUNT_PERMISSIONS': {
|
|
@@ -238,7 +246,7 @@ class RequestManager extends events_1.EventEmitter {
|
|
|
238
246
|
return apiData;
|
|
239
247
|
}
|
|
240
248
|
static resolveRadioRequest(instance, apiURL, apiType, request, apiData) {
|
|
241
|
-
var _a, _b, _c;
|
|
249
|
+
var _a, _b, _c, _d;
|
|
242
250
|
if (!apiURL || typeof apiURL !== 'string') {
|
|
243
251
|
throw new Error('Radio API URL could not be resolved for request.');
|
|
244
252
|
}
|
|
@@ -313,12 +321,20 @@ class RequestManager extends events_1.EventEmitter {
|
|
|
313
321
|
}
|
|
314
322
|
case 'RADIO_SET_USER_CHANNELS': {
|
|
315
323
|
const auth = ensureAuth();
|
|
324
|
+
const roomIdRaw = (_b = payload === null || payload === void 0 ? void 0 : payload.roomId) !== null && _b !== void 0 ? _b : payload === null || payload === void 0 ? void 0 : payload.roomID;
|
|
325
|
+
if (roomIdRaw === undefined) {
|
|
326
|
+
throw new Error('roomId is required for RADIO_SET_USER_CHANNELS requests.');
|
|
327
|
+
}
|
|
328
|
+
const roomIdNumeric = typeof roomIdRaw === 'number' ? roomIdRaw : Number(roomIdRaw);
|
|
329
|
+
if (Number.isNaN(roomIdNumeric)) {
|
|
330
|
+
throw new Error('roomId must be a number for RADIO_SET_USER_CHANNELS requests.');
|
|
331
|
+
}
|
|
316
332
|
const identity = payload === null || payload === void 0 ? void 0 : payload.identity;
|
|
317
333
|
if (!identity) {
|
|
318
334
|
throw new Error('identity is required for RADIO_SET_USER_CHANNELS requests.');
|
|
319
335
|
}
|
|
320
|
-
const options = (
|
|
321
|
-
path = `${apiType.path}/${auth.encodedId}/${auth.encodedKey}/${encodeSegment(identity)}`;
|
|
336
|
+
const options = (_c = payload === null || payload === void 0 ? void 0 : payload.options) !== null && _c !== void 0 ? _c : {};
|
|
337
|
+
path = `${apiType.path}/${auth.encodedId}/${auth.encodedKey}/${encodeSegment(roomIdNumeric)}/${encodeSegment(identity)}`;
|
|
322
338
|
method = 'POST';
|
|
323
339
|
const requestBody = {};
|
|
324
340
|
if ((options === null || options === void 0 ? void 0 : options.transmit) !== undefined) {
|
|
@@ -379,7 +395,7 @@ class RequestManager extends events_1.EventEmitter {
|
|
|
379
395
|
key: auth.key,
|
|
380
396
|
locations
|
|
381
397
|
};
|
|
382
|
-
const token = (
|
|
398
|
+
const token = (_d = payload === null || payload === void 0 ? void 0 : payload.token) !== null && _d !== void 0 ? _d : auth.key;
|
|
383
399
|
if (token) {
|
|
384
400
|
headers.Authorization = `Bearer ${token}`;
|
|
385
401
|
}
|
|
@@ -161,6 +161,7 @@ export interface CADLookupByIntStruct {
|
|
|
161
161
|
}
|
|
162
162
|
export interface CADLookupStruct {
|
|
163
163
|
apiId?: string;
|
|
164
|
+
account?: string;
|
|
164
165
|
types: number[];
|
|
165
166
|
first: string;
|
|
166
167
|
last: string;
|
|
@@ -273,6 +274,12 @@ export interface CADUnitLocationStruct {
|
|
|
273
274
|
apiId: string;
|
|
274
275
|
location: string;
|
|
275
276
|
}
|
|
277
|
+
export interface CADUnitStatusStruct {
|
|
278
|
+
apiId?: string;
|
|
279
|
+
account?: string;
|
|
280
|
+
status: number;
|
|
281
|
+
serverId: number;
|
|
282
|
+
}
|
|
276
283
|
export interface RESTTypedAPIDataStructs {
|
|
277
284
|
GET_SERVERS: [];
|
|
278
285
|
SET_SERVERS: [
|
|
@@ -348,6 +355,8 @@ export interface RESTTypedAPIDataStructs {
|
|
|
348
355
|
apiId: string | undefined,
|
|
349
356
|
status: number,
|
|
350
357
|
serverId: number
|
|
358
|
+
] | [
|
|
359
|
+
data: CADUnitStatusStruct
|
|
351
360
|
];
|
|
352
361
|
GET_BLIPS: [serverId: number];
|
|
353
362
|
ADD_BLIP: [data: CADAddBlipStruct[]];
|
|
@@ -575,6 +584,7 @@ export interface RESTTypedAPIDataStructs {
|
|
|
575
584
|
identity: string
|
|
576
585
|
];
|
|
577
586
|
RADIO_SET_USER_CHANNELS: [
|
|
587
|
+
roomId: number,
|
|
578
588
|
identity: string,
|
|
579
589
|
options?: RadioSetUserChannelsOptions
|
|
580
590
|
];
|
|
@@ -636,7 +646,8 @@ export type PossibleRequestData = undefined | {
|
|
|
636
646
|
apiId: string;
|
|
637
647
|
isPanic: boolean;
|
|
638
648
|
} | {
|
|
639
|
-
apiId
|
|
649
|
+
apiId?: string;
|
|
650
|
+
account?: string;
|
|
640
651
|
status: number;
|
|
641
652
|
serverId: number;
|
|
642
653
|
} | {
|
|
@@ -90,6 +90,7 @@ export declare class CADManager extends BaseManager {
|
|
|
90
90
|
lookupByInt(data: CADLookupByIntStruct): Promise<globalTypes.CADStandardResponse>;
|
|
91
91
|
/**
|
|
92
92
|
* Executes a CAD lookup using first/last name, plate, or other values.
|
|
93
|
+
* Supports identifying the requester via `apiId` or `account` (UUID).
|
|
93
94
|
*/
|
|
94
95
|
lookupRecords(data: CADLookupStruct): Promise<globalTypes.CADStandardResponse>;
|
|
95
96
|
/**
|
|
@@ -160,6 +161,12 @@ export declare class CADManager extends BaseManager {
|
|
|
160
161
|
* Updates a unit's status.
|
|
161
162
|
*/
|
|
162
163
|
setUnitStatus(apiId: string | undefined, status: number, serverId: number): Promise<globalTypes.CADStandardResponse>;
|
|
164
|
+
setUnitStatus(params: {
|
|
165
|
+
apiId?: string;
|
|
166
|
+
account?: string;
|
|
167
|
+
status: number;
|
|
168
|
+
serverId: number;
|
|
169
|
+
}): Promise<globalTypes.CADStandardResponse>;
|
|
163
170
|
/**
|
|
164
171
|
* Retrieves live map blips for a CAD server.
|
|
165
172
|
*/
|
|
@@ -243,6 +243,7 @@ class CADManager extends BaseManager_1.BaseManager {
|
|
|
243
243
|
}
|
|
244
244
|
/**
|
|
245
245
|
* Executes a CAD lookup using first/last name, plate, or other values.
|
|
246
|
+
* Supports identifying the requester via `apiId` or `account` (UUID).
|
|
246
247
|
*/
|
|
247
248
|
async lookupRecords(data) {
|
|
248
249
|
return this.executeCadRequest('LOOKUP', data);
|
|
@@ -382,14 +383,30 @@ class CADManager extends BaseManager_1.BaseManager {
|
|
|
382
383
|
async setUnitPanic(apiId, isPanic) {
|
|
383
384
|
return this.executeCadRequest('UNIT_PANIC', apiId, isPanic);
|
|
384
385
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
386
|
+
async setUnitStatus(apiIdOrParams, status, serverId) {
|
|
387
|
+
let payload;
|
|
388
|
+
if (apiIdOrParams && typeof apiIdOrParams === 'object' && !Array.isArray(apiIdOrParams)) {
|
|
389
|
+
payload = {
|
|
390
|
+
apiId: apiIdOrParams.apiId,
|
|
391
|
+
account: apiIdOrParams.account,
|
|
392
|
+
status: apiIdOrParams.status,
|
|
393
|
+
serverId: apiIdOrParams.serverId
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
payload = { apiId: apiIdOrParams, status: status, serverId: serverId };
|
|
398
|
+
}
|
|
399
|
+
const { apiId, account, status: resolvedStatus, serverId: resolvedServerId } = payload;
|
|
400
|
+
if (!Number.isInteger(resolvedServerId)) {
|
|
390
401
|
throw new Error('serverId must be an integer when updating unit status.');
|
|
391
402
|
}
|
|
392
|
-
|
|
403
|
+
if (resolvedStatus === undefined) {
|
|
404
|
+
throw new Error('status is required when updating unit status.');
|
|
405
|
+
}
|
|
406
|
+
if (!apiId && !account) {
|
|
407
|
+
throw new Error('Either apiId or account is required when updating unit status.');
|
|
408
|
+
}
|
|
409
|
+
return this.executeCadRequest('UNIT_STATUS', { apiId, account, status: resolvedStatus, serverId: resolvedServerId });
|
|
393
410
|
}
|
|
394
411
|
/**
|
|
395
412
|
* Retrieves live map blips for a CAD server.
|
|
@@ -27,10 +27,11 @@ export declare class RadioManager extends BaseManager {
|
|
|
27
27
|
getConnectedUser(roomId: number, identity: string): Promise<globalTypes.RadioGetConnectedUserPromiseResult>;
|
|
28
28
|
/**
|
|
29
29
|
* Updates a user's transmit and scanned channel configuration.
|
|
30
|
+
* @param {number} roomId Multi-server room id.
|
|
30
31
|
* @param {string} identity The user's UUID.
|
|
31
32
|
* @param {RadioSetUserChannelsOptions} options Transmit and scan channel configuration.
|
|
32
33
|
*/
|
|
33
|
-
setUserChannels(identity: string, options?: globalTypes.RadioSetUserChannelsOptions): Promise<globalTypes.RadioSetUserChannelsPromiseResult>;
|
|
34
|
+
setUserChannels(roomId: number, identity: string, options?: globalTypes.RadioSetUserChannelsOptions): Promise<globalTypes.RadioSetUserChannelsPromiseResult>;
|
|
34
35
|
/**
|
|
35
36
|
* Updates a user's display name.
|
|
36
37
|
* @param {string} accId The user's account UUID.
|
|
@@ -115,14 +115,15 @@ class RadioManager extends BaseManager_1.BaseManager {
|
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* Updates a user's transmit and scanned channel configuration.
|
|
118
|
+
* @param {number} roomId Multi-server room id.
|
|
118
119
|
* @param {string} identity The user's UUID.
|
|
119
120
|
* @param {RadioSetUserChannelsOptions} options Transmit and scan channel configuration.
|
|
120
121
|
*/
|
|
121
|
-
async setUserChannels(identity, options = {}) {
|
|
122
|
+
async setUserChannels(roomId, identity, options = {}) {
|
|
122
123
|
return new Promise(async (resolve, reject) => {
|
|
123
124
|
var _a, _b;
|
|
124
125
|
try {
|
|
125
|
-
const response = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('RADIO_SET_USER_CHANNELS', identity, options));
|
|
126
|
+
const response = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('RADIO_SET_USER_CHANNELS', roomId, identity, options));
|
|
126
127
|
resolve({ success: true, result: (_b = response === null || response === void 0 ? void 0 : response.result) !== null && _b !== void 0 ? _b : response });
|
|
127
128
|
}
|
|
128
129
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonoransoftware/sonoran.js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.46",
|
|
4
4
|
"description": "Sonoran.js is a library that allows you to interact with the Sonoran CAD and Sonoran CMS API. Based off of and utilizes several Discord.js library techniques for ease of use.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/readme.md
CHANGED
|
@@ -94,6 +94,7 @@ const permissionUpdate = await instance.cad.setAccountPermissions({ apiId: '1234
|
|
|
94
94
|
```js
|
|
95
95
|
await instance.cad.createRecord({ user: '1234567890', useDictionary: true, recordTypeId: 2, replaceValues: { NAME: 'Jane Doe' } });
|
|
96
96
|
const lookup = await instance.cad.lookupRecords({ apiId: '1234567890', types: [2], first: 'Jane', last: 'Doe', mi: '', plate: '', partial: false });
|
|
97
|
+
const lookupByAccount = await instance.cad.lookupRecords({ account: 'd5663516-ee35-11e9-9714-5600023b2434', types: [2], first: 'Jane', last: 'Doe', mi: '', plate: '', partial: false });
|
|
97
98
|
```
|
|
98
99
|
|
|
99
100
|
### Civilian Tools
|
|
@@ -103,11 +104,18 @@ const lookup = await instance.cad.lookupRecords({ apiId: '1234567890', types: [2
|
|
|
103
104
|
### Identifiers & Units
|
|
104
105
|
- **`getIdentifiers(apiId)`**
|
|
105
106
|
- **`modifyIdentifier(change)`** / **`setIdentifier(apiId?, identId)`**
|
|
106
|
-
- **`setUnitPanic(apiId?, isPanic)`** / **`setUnitStatus(
|
|
107
|
+
- **`setUnitPanic(apiId?, isPanic)`** / **`setUnitStatus({ status, serverId, apiId?, account? })`**
|
|
107
108
|
- **`getActiveUnits(options)`** - direct CAD fetch for active units.
|
|
108
109
|
- **`kickUnit(apiId?, reason, serverId)`**
|
|
109
110
|
- **`updateUnitLocations(locations)`**
|
|
110
111
|
|
|
112
|
+
```js
|
|
113
|
+
// Update a unit's status using an account UUID
|
|
114
|
+
await instance.cad.setUnitStatus({ account: 'd5663516-ee35-11e9-9714-5600023b2434', status: 2, serverId: 1 });
|
|
115
|
+
// Legacy positional call using an API ID
|
|
116
|
+
await instance.cad.setUnitStatus('1234567890', 2, 1);
|
|
117
|
+
```
|
|
118
|
+
|
|
111
119
|
### Map & Streetsigns
|
|
112
120
|
- **`getBlips(serverId)`**
|
|
113
121
|
- **`addBlips(blips)`** / **`updateBlips(blips)`** / **`removeBlip(id)`**
|
|
@@ -448,10 +456,10 @@ Fetches a specific connected radio user by room and identity.
|
|
|
448
456
|
const user = await instance.radio.getConnectedUser(1, 'account-uuid');
|
|
449
457
|
```
|
|
450
458
|
|
|
451
|
-
### setUserChannels(identity, options)
|
|
452
|
-
Updates a user's transmit or scan channels.
|
|
459
|
+
### setUserChannels(roomId, identity, options)
|
|
460
|
+
Updates a user's transmit or scan channels for a specific radio room.
|
|
453
461
|
```js
|
|
454
|
-
await instance.radio.setUserChannels('account-uuid', { transmit: 12, scan: [10, 11, 12] });
|
|
462
|
+
await instance.radio.setUserChannels(1, 'account-uuid', { transmit: 12, scan: [10, 11, 12] });
|
|
455
463
|
```
|
|
456
464
|
|
|
457
465
|
### setUserDisplayName(accId, displayName)
|
|
@@ -299,6 +299,23 @@ export class REST extends EventEmitter {
|
|
|
299
299
|
type: args[5]
|
|
300
300
|
};
|
|
301
301
|
}
|
|
302
|
+
case 'UNIT_STATUS': {
|
|
303
|
+
const payload = args[0];
|
|
304
|
+
if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
|
|
305
|
+
const { apiId, account, status, serverId } = payload as {
|
|
306
|
+
apiId?: string;
|
|
307
|
+
account?: string;
|
|
308
|
+
status: number;
|
|
309
|
+
serverId: number;
|
|
310
|
+
};
|
|
311
|
+
return { apiId, account, status, serverId };
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
apiId: args[0],
|
|
315
|
+
status: args[1],
|
|
316
|
+
serverId: args[2]
|
|
317
|
+
};
|
|
318
|
+
}
|
|
302
319
|
case 'CHECK_COM_APIID': {
|
|
303
320
|
return {
|
|
304
321
|
apiId: args[0]
|
|
@@ -358,6 +375,10 @@ export class REST extends EventEmitter {
|
|
|
358
375
|
};
|
|
359
376
|
}
|
|
360
377
|
case 'LOOKUP': {
|
|
378
|
+
const payload = args[0];
|
|
379
|
+
if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
|
|
380
|
+
return args;
|
|
381
|
+
}
|
|
361
382
|
return {
|
|
362
383
|
id: args[0],
|
|
363
384
|
uuid: args[1]
|
|
@@ -452,8 +473,9 @@ export class REST extends EventEmitter {
|
|
|
452
473
|
}
|
|
453
474
|
case 'RADIO_SET_USER_CHANNELS': {
|
|
454
475
|
return {
|
|
455
|
-
|
|
456
|
-
|
|
476
|
+
roomId: args[0],
|
|
477
|
+
identity: args[1],
|
|
478
|
+
options: args[2] ?? {}
|
|
457
479
|
}
|
|
458
480
|
}
|
|
459
481
|
case 'RADIO_SET_USER_DISPLAY_NAME': {
|
|
@@ -203,7 +203,13 @@ export class RequestManager extends EventEmitter {
|
|
|
203
203
|
break;
|
|
204
204
|
}
|
|
205
205
|
case 'LOOKUP': {
|
|
206
|
-
|
|
206
|
+
if (Array.isArray(clonedData)) {
|
|
207
|
+
apiData.data.data = clonedData.length > 0 ? clonedData : [];
|
|
208
|
+
} else if (clonedData !== undefined && clonedData !== null) {
|
|
209
|
+
apiData.data.data = [clonedData];
|
|
210
|
+
} else {
|
|
211
|
+
apiData.data.data = [];
|
|
212
|
+
}
|
|
207
213
|
break;
|
|
208
214
|
}
|
|
209
215
|
case 'SET_ACCOUNT_PERMISSIONS': {
|
|
@@ -392,12 +398,20 @@ export class RequestManager extends EventEmitter {
|
|
|
392
398
|
}
|
|
393
399
|
case 'RADIO_SET_USER_CHANNELS': {
|
|
394
400
|
const auth = ensureAuth();
|
|
401
|
+
const roomIdRaw = payload?.roomId ?? payload?.roomID;
|
|
402
|
+
if (roomIdRaw === undefined) {
|
|
403
|
+
throw new Error('roomId is required for RADIO_SET_USER_CHANNELS requests.');
|
|
404
|
+
}
|
|
405
|
+
const roomIdNumeric = typeof roomIdRaw === 'number' ? roomIdRaw : Number(roomIdRaw);
|
|
406
|
+
if (Number.isNaN(roomIdNumeric)) {
|
|
407
|
+
throw new Error('roomId must be a number for RADIO_SET_USER_CHANNELS requests.');
|
|
408
|
+
}
|
|
395
409
|
const identity = payload?.identity;
|
|
396
410
|
if (!identity) {
|
|
397
411
|
throw new Error('identity is required for RADIO_SET_USER_CHANNELS requests.');
|
|
398
412
|
}
|
|
399
413
|
const options = payload?.options ?? {};
|
|
400
|
-
path = `${apiType.path}/${auth.encodedId}/${auth.encodedKey}/${encodeSegment(identity)}`;
|
|
414
|
+
path = `${apiType.path}/${auth.encodedId}/${auth.encodedKey}/${encodeSegment(roomIdNumeric)}/${encodeSegment(identity)}`;
|
|
401
415
|
method = 'POST';
|
|
402
416
|
const requestBody: Record<string, unknown> = {};
|
|
403
417
|
if (options?.transmit !== undefined) {
|
|
@@ -775,6 +775,7 @@ export interface CADLookupByIntStruct {
|
|
|
775
775
|
|
|
776
776
|
export interface CADLookupStruct {
|
|
777
777
|
apiId?: string;
|
|
778
|
+
account?: string;
|
|
778
779
|
types: number[];
|
|
779
780
|
first: string;
|
|
780
781
|
last: string;
|
|
@@ -900,7 +901,14 @@ export interface CADStreetSignStruct {
|
|
|
900
901
|
|
|
901
902
|
export interface CADUnitLocationStruct {
|
|
902
903
|
apiId: string;
|
|
903
|
-
location: string;
|
|
904
|
+
location: string;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
export interface CADUnitStatusStruct {
|
|
908
|
+
apiId?: string;
|
|
909
|
+
account?: string;
|
|
910
|
+
status: number;
|
|
911
|
+
serverId: number;
|
|
904
912
|
}
|
|
905
913
|
|
|
906
914
|
export interface RESTTypedAPIDataStructs {
|
|
@@ -977,6 +985,8 @@ export interface RESTTypedAPIDataStructs {
|
|
|
977
985
|
apiId: string | undefined,
|
|
978
986
|
status: number,
|
|
979
987
|
serverId: number
|
|
988
|
+
] | [
|
|
989
|
+
data: CADUnitStatusStruct
|
|
980
990
|
];
|
|
981
991
|
GET_BLIPS: [serverId: number];
|
|
982
992
|
ADD_BLIP: [data: CADAddBlipStruct[]];
|
|
@@ -1209,6 +1219,7 @@ export interface RESTTypedAPIDataStructs {
|
|
|
1209
1219
|
identity: string
|
|
1210
1220
|
];
|
|
1211
1221
|
RADIO_SET_USER_CHANNELS: [
|
|
1222
|
+
roomId: number,
|
|
1212
1223
|
identity: string,
|
|
1213
1224
|
options?: RadioSetUserChannelsOptions
|
|
1214
1225
|
];
|
|
@@ -1287,7 +1298,8 @@ export type PossibleRequestData =
|
|
|
1287
1298
|
isPanic: boolean;
|
|
1288
1299
|
} |
|
|
1289
1300
|
{
|
|
1290
|
-
apiId
|
|
1301
|
+
apiId?: string;
|
|
1302
|
+
account?: string;
|
|
1291
1303
|
status: number;
|
|
1292
1304
|
serverId: number;
|
|
1293
1305
|
} |
|
|
@@ -19,7 +19,8 @@ import type {
|
|
|
19
19
|
CADGetActiveUnitsStruct,
|
|
20
20
|
CADNewDispatchStruct,
|
|
21
21
|
CADStreetSignStruct,
|
|
22
|
-
CADUnitLocationStruct
|
|
22
|
+
CADUnitLocationStruct,
|
|
23
|
+
CADUnitStatusStruct
|
|
23
24
|
} from '../libs/rest/src';
|
|
24
25
|
import { BaseManager } from './BaseManager';
|
|
25
26
|
import * as globalTypes from '../constants';
|
|
@@ -246,6 +247,7 @@ export class CADManager extends BaseManager {
|
|
|
246
247
|
|
|
247
248
|
/**
|
|
248
249
|
* Executes a CAD lookup using first/last name, plate, or other values.
|
|
250
|
+
* Supports identifying the requester via `apiId` or `account` (UUID).
|
|
249
251
|
*/
|
|
250
252
|
public async lookupRecords(data: CADLookupStruct): Promise<globalTypes.CADStandardResponse> {
|
|
251
253
|
return this.executeCadRequest('LOOKUP', data);
|
|
@@ -405,11 +407,35 @@ export class CADManager extends BaseManager {
|
|
|
405
407
|
/**
|
|
406
408
|
* Updates a unit's status.
|
|
407
409
|
*/
|
|
408
|
-
public async setUnitStatus(apiId: string | undefined, status: number, serverId: number): Promise<globalTypes.CADStandardResponse
|
|
409
|
-
|
|
410
|
+
public async setUnitStatus(apiId: string | undefined, status: number, serverId: number): Promise<globalTypes.CADStandardResponse>;
|
|
411
|
+
public async setUnitStatus(params: { apiId?: string; account?: string; status: number; serverId: number }): Promise<globalTypes.CADStandardResponse>;
|
|
412
|
+
public async setUnitStatus(
|
|
413
|
+
apiIdOrParams: string | undefined | { apiId?: string; account?: string; status: number; serverId: number },
|
|
414
|
+
status?: number,
|
|
415
|
+
serverId?: number
|
|
416
|
+
): Promise<globalTypes.CADStandardResponse> {
|
|
417
|
+
let payload: CADUnitStatusStruct;
|
|
418
|
+
if (apiIdOrParams && typeof apiIdOrParams === 'object' && !Array.isArray(apiIdOrParams)) {
|
|
419
|
+
payload = {
|
|
420
|
+
apiId: apiIdOrParams.apiId,
|
|
421
|
+
account: apiIdOrParams.account,
|
|
422
|
+
status: apiIdOrParams.status,
|
|
423
|
+
serverId: apiIdOrParams.serverId
|
|
424
|
+
};
|
|
425
|
+
} else {
|
|
426
|
+
payload = { apiId: apiIdOrParams as string | undefined, status: status as number, serverId: serverId as number };
|
|
427
|
+
}
|
|
428
|
+
const { apiId, account, status: resolvedStatus, serverId: resolvedServerId } = payload;
|
|
429
|
+
if (!Number.isInteger(resolvedServerId)) {
|
|
410
430
|
throw new Error('serverId must be an integer when updating unit status.');
|
|
411
431
|
}
|
|
412
|
-
|
|
432
|
+
if (resolvedStatus === undefined) {
|
|
433
|
+
throw new Error('status is required when updating unit status.');
|
|
434
|
+
}
|
|
435
|
+
if (!apiId && !account) {
|
|
436
|
+
throw new Error('Either apiId or account is required when updating unit status.');
|
|
437
|
+
}
|
|
438
|
+
return this.executeCadRequest('UNIT_STATUS', { apiId, account, status: resolvedStatus, serverId: resolvedServerId });
|
|
413
439
|
}
|
|
414
440
|
|
|
415
441
|
/**
|
|
@@ -90,13 +90,14 @@ export class RadioManager extends BaseManager {
|
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Updates a user's transmit and scanned channel configuration.
|
|
93
|
+
* @param {number} roomId Multi-server room id.
|
|
93
94
|
* @param {string} identity The user's UUID.
|
|
94
95
|
* @param {RadioSetUserChannelsOptions} options Transmit and scan channel configuration.
|
|
95
96
|
*/
|
|
96
|
-
public async setUserChannels(identity: string, options: globalTypes.RadioSetUserChannelsOptions = {}): Promise<globalTypes.RadioSetUserChannelsPromiseResult> {
|
|
97
|
+
public async setUserChannels(roomId: number, identity: string, options: globalTypes.RadioSetUserChannelsOptions = {}): Promise<globalTypes.RadioSetUserChannelsPromiseResult> {
|
|
97
98
|
return new Promise(async (resolve, reject) => {
|
|
98
99
|
try {
|
|
99
|
-
const response: any = await this.rest?.request('RADIO_SET_USER_CHANNELS', identity, options);
|
|
100
|
+
const response: any = await this.rest?.request('RADIO_SET_USER_CHANNELS', roomId, identity, options);
|
|
100
101
|
resolve({ success: true, result: response?.result ?? response });
|
|
101
102
|
} catch (err) {
|
|
102
103
|
if (err instanceof APIError) {
|