@sonoransoftware/sonoran.js 1.0.61 → 1.0.63

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.
@@ -251,13 +251,14 @@ class REST extends events_1.EventEmitter {
251
251
  case 'UNIT_STATUS': {
252
252
  const payload = args[0];
253
253
  if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
254
- const { apiId, account, status, serverId } = payload;
255
- return { apiId, account, status, serverId };
254
+ const { apiId, account, status, serverId, identIds } = payload;
255
+ return { apiId, account, status, serverId, identIds };
256
256
  }
257
257
  return {
258
258
  apiId: args[0],
259
259
  status: args[1],
260
- serverId: args[2]
260
+ serverId: args[2],
261
+ identIds: args[3]
261
262
  };
262
263
  }
263
264
  case 'UNIT_PANIC': {
@@ -284,13 +285,15 @@ class REST extends events_1.EventEmitter {
284
285
  return payload;
285
286
  }
286
287
  const unitsOrAccount = args[2];
288
+ const identIds = args[3];
287
289
  const account = typeof unitsOrAccount === 'string' && !Array.isArray(unitsOrAccount) ? unitsOrAccount : undefined;
288
290
  const units = Array.isArray(unitsOrAccount) ? unitsOrAccount : undefined;
289
291
  return {
290
292
  serverId: args[0],
291
293
  callId: args[1],
292
294
  units,
293
- account
295
+ account,
296
+ identIds
294
297
  };
295
298
  }
296
299
  case 'DETACH_UNIT': {
@@ -262,6 +262,7 @@ export interface CADAttachUnitsStruct {
262
262
  callId: number;
263
263
  units?: string[];
264
264
  account?: string;
265
+ identIds?: number[];
265
266
  }
266
267
  export interface CADDetachUnitsStruct {
267
268
  serverId: number;
@@ -323,6 +324,7 @@ export interface CADUnitStatusStruct {
323
324
  account?: string;
324
325
  status: number;
325
326
  serverId: number;
327
+ identIds?: number[];
326
328
  }
327
329
  export interface RESTTypedAPIDataStructs {
328
330
  GET_SERVERS: [];
@@ -401,7 +403,8 @@ export interface RESTTypedAPIDataStructs {
401
403
  UNIT_STATUS: [
402
404
  apiId: string | undefined,
403
405
  status: number,
404
- serverId: number
406
+ serverId: number,
407
+ identIds?: number[]
405
408
  ] | [
406
409
  data: CADUnitStatusStruct
407
410
  ];
@@ -422,7 +425,8 @@ export interface RESTTypedAPIDataStructs {
422
425
  ATTACH_UNIT: [
423
426
  serverId: number,
424
427
  callId: number,
425
- units: string[]
428
+ units: string[],
429
+ identIds?: number[]
426
430
  ] | [
427
431
  data: CADAttachUnitsStruct
428
432
  ];
@@ -753,6 +757,7 @@ export type PossibleRequestData = undefined | {
753
757
  callId: number;
754
758
  units?: string[];
755
759
  account?: string;
760
+ identIds?: number[];
756
761
  } | {
757
762
  serverId: number;
758
763
  units?: string[];
@@ -165,12 +165,13 @@ export declare class CADManager extends BaseManager {
165
165
  /**
166
166
  * Updates a unit's status.
167
167
  */
168
- setUnitStatus(apiId: string | undefined, status: number, serverId: number): Promise<globalTypes.CADStandardResponse>;
168
+ setUnitStatus(apiId: string | undefined, status: number, serverId: number, identIds?: number[]): Promise<globalTypes.CADStandardResponse>;
169
169
  setUnitStatus(params: {
170
170
  apiId?: string;
171
171
  account?: string;
172
172
  status: number;
173
173
  serverId: number;
174
+ identIds?: number[];
174
175
  }): Promise<globalTypes.CADStandardResponse>;
175
176
  /**
176
177
  * Retrieves live map blips for a CAD server.
@@ -226,7 +227,7 @@ export declare class CADManager extends BaseManager {
226
227
  /**
227
228
  * Attaches units to an existing dispatch call.
228
229
  */
229
- attachUnits(serverId: number, callId: number, unitsOrAccount: string[] | string): Promise<globalTypes.CADStandardResponse>;
230
+ attachUnits(serverId: number, callId: number, unitsOrAccount: string[] | string, identIds?: number[]): Promise<globalTypes.CADStandardResponse>;
230
231
  attachUnits(params: CADAttachUnitsStruct): Promise<globalTypes.CADStandardResponse>;
231
232
  /**
232
233
  * Detaches units from dispatch calls.
@@ -424,30 +424,41 @@ class CADManager extends BaseManager_1.BaseManager {
424
424
  }
425
425
  return this.executeCadRequest('UNIT_PANIC', { apiId, account, isPanic: resolvedPanic });
426
426
  }
427
- async setUnitStatus(apiIdOrParams, status, serverId) {
427
+ async setUnitStatus(apiIdOrParams, status, serverId, identIds) {
428
428
  let payload;
429
429
  if (apiIdOrParams && typeof apiIdOrParams === 'object' && !Array.isArray(apiIdOrParams)) {
430
430
  payload = {
431
431
  apiId: apiIdOrParams.apiId,
432
432
  account: apiIdOrParams.account,
433
433
  status: apiIdOrParams.status,
434
- serverId: apiIdOrParams.serverId
434
+ serverId: apiIdOrParams.serverId,
435
+ identIds: apiIdOrParams.identIds
435
436
  };
436
437
  }
437
438
  else {
438
- payload = { apiId: apiIdOrParams, status: status, serverId: serverId };
439
+ payload = { apiId: apiIdOrParams, status: status, serverId: serverId, identIds };
439
440
  }
440
- const { apiId, account, status: resolvedStatus, serverId: resolvedServerId } = payload;
441
+ const { apiId, account, status: resolvedStatus, serverId: resolvedServerId, identIds: resolvedIdentIds } = payload;
441
442
  if (!Number.isInteger(resolvedServerId)) {
442
443
  throw new Error('serverId must be an integer when updating unit status.');
443
444
  }
444
445
  if (resolvedStatus === undefined) {
445
446
  throw new Error('status is required when updating unit status.');
446
447
  }
447
- if (!apiId && !account) {
448
- throw new Error('Either apiId or account is required when updating unit status.');
448
+ if (resolvedIdentIds !== undefined && (!Array.isArray(resolvedIdentIds) || resolvedIdentIds.some((id) => !Number.isInteger(id)))) {
449
+ throw new Error('identIds must be an array of integers when updating unit status.');
450
+ }
451
+ const hasIdentIds = Array.isArray(resolvedIdentIds) && resolvedIdentIds.length > 0;
452
+ if (!apiId && !account && !hasIdentIds) {
453
+ throw new Error('Either apiId, account, or identIds is required when updating unit status.');
449
454
  }
450
- return this.executeCadRequest('UNIT_STATUS', { apiId, account, status: resolvedStatus, serverId: resolvedServerId });
455
+ return this.executeCadRequest('UNIT_STATUS', {
456
+ apiId,
457
+ account,
458
+ status: resolvedStatus,
459
+ serverId: resolvedServerId,
460
+ identIds: hasIdentIds ? resolvedIdentIds : undefined
461
+ });
451
462
  }
452
463
  /**
453
464
  * Retrieves live map blips for a CAD server.
@@ -552,7 +563,7 @@ class CADManager extends BaseManager_1.BaseManager {
552
563
  };
553
564
  return this.executeCadRequest('NEW_DISPATCH', payload);
554
565
  }
555
- async attachUnits(serverIdOrParams, callId, unitsOrAccount) {
566
+ async attachUnits(serverIdOrParams, callId, unitsOrAccount, identIds) {
556
567
  let payload;
557
568
  if (serverIdOrParams && typeof serverIdOrParams === 'object') {
558
569
  payload = { ...serverIdOrParams };
@@ -565,19 +576,30 @@ class CADManager extends BaseManager_1.BaseManager {
565
576
  ? { units: unitsOrAccount }
566
577
  : typeof unitsOrAccount === 'string'
567
578
  ? { account: unitsOrAccount }
568
- : {})
579
+ : {}),
580
+ ...(Array.isArray(identIds) ? { identIds } : {})
569
581
  };
570
582
  }
571
- const { serverId, callId: resolvedCallId, units, account } = payload;
583
+ const { serverId, callId: resolvedCallId, units, account, identIds: resolvedIdentIds } = payload;
572
584
  if (!Number.isInteger(serverId) || !Number.isInteger(resolvedCallId)) {
573
585
  throw new Error('serverId and callId must be integers when attaching units.');
574
586
  }
575
587
  const hasUnits = Array.isArray(units) && units.length > 0;
576
588
  const hasAccount = typeof account === 'string' && account.length > 0;
577
- if (!hasUnits && !hasAccount) {
578
- throw new Error('Either units or account is required when attaching units.');
579
- }
580
- return this.executeCadRequest('ATTACH_UNIT', { serverId, callId: resolvedCallId, units: hasUnits ? units : undefined, account: hasAccount ? account : undefined });
589
+ if (resolvedIdentIds !== undefined && (!Array.isArray(resolvedIdentIds) || resolvedIdentIds.some((id) => !Number.isInteger(id)))) {
590
+ throw new Error('identIds must be an array of integers when attaching units.');
591
+ }
592
+ const hasIdentIds = Array.isArray(resolvedIdentIds) && resolvedIdentIds.length > 0;
593
+ if (!hasUnits && !hasAccount && !hasIdentIds) {
594
+ throw new Error('Either units, account, or identIds is required when attaching units.');
595
+ }
596
+ return this.executeCadRequest('ATTACH_UNIT', {
597
+ serverId,
598
+ callId: resolvedCallId,
599
+ units: hasUnits ? units : undefined,
600
+ account: hasAccount ? account : undefined,
601
+ identIds: hasIdentIds ? resolvedIdentIds : undefined
602
+ });
581
603
  }
582
604
  async detachUnits(serverIdOrParams, unitsOrAccount) {
583
605
  let payload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonoransoftware/sonoran.js",
3
- "version": "1.0.61",
3
+ "version": "1.0.63",
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
@@ -105,7 +105,7 @@ const lookupByAccount = await instance.cad.lookupRecords({ account: 'd5663516-ee
105
105
  - **`getIdentifiers(apiId)`**
106
106
  - **`modifyIdentifier(change)`** / **`setIdentifier(apiId?, identId)`**
107
107
  - **`setIdentifiersToGroup(entries)`** - assigns identifiers to a group name (empty string clears).
108
- - **`setUnitPanic({ apiId?, account?, isPanic })`** / **`setUnitStatus({ status, serverId, apiId?, account? })`**
108
+ - **`setUnitPanic({ apiId?, account?, isPanic })`** / **`setUnitStatus({ status, serverId, apiId?, account?, identIds? })`**
109
109
  - **`getActiveUnits(options)`** - direct CAD fetch for active units.
110
110
  - **`kickUnit(apiId?, reason, serverId)`**
111
111
  - **`updateUnitLocations(locations)`**
@@ -115,6 +115,8 @@ const lookupByAccount = await instance.cad.lookupRecords({ account: 'd5663516-ee
115
115
  await instance.cad.setUnitStatus({ account: 'd5663516-ee35-11e9-9714-5600023b2434', status: 2, serverId: 1 });
116
116
  // Legacy positional call using an API ID
117
117
  await instance.cad.setUnitStatus('1234567890', 2, 1);
118
+ // Update status by identifier IDs
119
+ await instance.cad.setUnitStatus({ identIds: [101, 102], status: 2, serverId: 1 });
118
120
  // Trigger panic using account UUID
119
121
  await instance.cad.setUnitPanic({ account: '91de0ce8-c571-11e9-9714-5600023b2434', isPanic: true });
120
122
  ```
@@ -355,18 +355,20 @@ export class REST extends EventEmitter {
355
355
  case 'UNIT_STATUS': {
356
356
  const payload = args[0];
357
357
  if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
358
- const { apiId, account, status, serverId } = payload as {
358
+ const { apiId, account, status, serverId, identIds } = payload as {
359
359
  apiId?: string;
360
360
  account?: string;
361
361
  status: number;
362
362
  serverId: number;
363
+ identIds?: number[];
363
364
  };
364
- return { apiId, account, status, serverId };
365
+ return { apiId, account, status, serverId, identIds };
365
366
  }
366
367
  return {
367
368
  apiId: args[0],
368
369
  status: args[1],
369
- serverId: args[2]
370
+ serverId: args[2],
371
+ identIds: args[3]
370
372
  };
371
373
  }
372
374
  case 'UNIT_PANIC': {
@@ -393,13 +395,15 @@ export class REST extends EventEmitter {
393
395
  return payload;
394
396
  }
395
397
  const unitsOrAccount = args[2];
398
+ const identIds = args[3];
396
399
  const account = typeof unitsOrAccount === 'string' && !Array.isArray(unitsOrAccount) ? unitsOrAccount : undefined;
397
400
  const units = Array.isArray(unitsOrAccount) ? unitsOrAccount : undefined;
398
401
  return {
399
402
  serverId: args[0],
400
403
  callId: args[1],
401
404
  units,
402
- account
405
+ account,
406
+ identIds
403
407
  };
404
408
  }
405
409
  case 'DETACH_UNIT': {
@@ -957,6 +957,7 @@ export interface CADAttachUnitsStruct {
957
957
  callId: number;
958
958
  units?: string[];
959
959
  account?: string;
960
+ identIds?: number[];
960
961
  }
961
962
 
962
963
  export interface CADDetachUnitsStruct {
@@ -1023,6 +1024,7 @@ export interface CADUnitStatusStruct {
1023
1024
  account?: string;
1024
1025
  status: number;
1025
1026
  serverId: number;
1027
+ identIds?: number[];
1026
1028
  }
1027
1029
 
1028
1030
  export interface RESTTypedAPIDataStructs {
@@ -1101,7 +1103,8 @@ export interface RESTTypedAPIDataStructs {
1101
1103
  UNIT_STATUS: [
1102
1104
  apiId: string | undefined,
1103
1105
  status: number,
1104
- serverId: number
1106
+ serverId: number,
1107
+ identIds?: number[]
1105
1108
  ] | [
1106
1109
  data: CADUnitStatusStruct
1107
1110
  ];
@@ -1122,7 +1125,8 @@ export interface RESTTypedAPIDataStructs {
1122
1125
  ATTACH_UNIT: [
1123
1126
  serverId: number,
1124
1127
  callId: number,
1125
- units: string[]
1128
+ units: string[],
1129
+ identIds?: number[]
1126
1130
  ] | [
1127
1131
  data: CADAttachUnitsStruct
1128
1132
  ];
@@ -1480,6 +1484,7 @@ export type PossibleRequestData =
1480
1484
  callId: number;
1481
1485
  units?: string[];
1482
1486
  account?: string;
1487
+ identIds?: number[];
1483
1488
  } |
1484
1489
  {
1485
1490
  serverId: number;
@@ -459,12 +459,13 @@ export class CADManager extends BaseManager {
459
459
  /**
460
460
  * Updates a unit's status.
461
461
  */
462
- public async setUnitStatus(apiId: string | undefined, status: number, serverId: number): Promise<globalTypes.CADStandardResponse>;
463
- public async setUnitStatus(params: { apiId?: string; account?: string; status: number; serverId: number }): Promise<globalTypes.CADStandardResponse>;
462
+ public async setUnitStatus(apiId: string | undefined, status: number, serverId: number, identIds?: number[]): Promise<globalTypes.CADStandardResponse>;
463
+ public async setUnitStatus(params: { apiId?: string; account?: string; status: number; serverId: number; identIds?: number[] }): Promise<globalTypes.CADStandardResponse>;
464
464
  public async setUnitStatus(
465
- apiIdOrParams: string | undefined | { apiId?: string; account?: string; status: number; serverId: number },
465
+ apiIdOrParams: string | undefined | { apiId?: string; account?: string; status: number; serverId: number; identIds?: number[] },
466
466
  status?: number,
467
- serverId?: number
467
+ serverId?: number,
468
+ identIds?: number[]
468
469
  ): Promise<globalTypes.CADStandardResponse> {
469
470
  let payload: CADUnitStatusStruct;
470
471
  if (apiIdOrParams && typeof apiIdOrParams === 'object' && !Array.isArray(apiIdOrParams)) {
@@ -472,22 +473,33 @@ export class CADManager extends BaseManager {
472
473
  apiId: apiIdOrParams.apiId,
473
474
  account: apiIdOrParams.account,
474
475
  status: apiIdOrParams.status,
475
- serverId: apiIdOrParams.serverId
476
+ serverId: apiIdOrParams.serverId,
477
+ identIds: apiIdOrParams.identIds
476
478
  };
477
479
  } else {
478
- payload = { apiId: apiIdOrParams as string | undefined, status: status as number, serverId: serverId as number };
480
+ payload = { apiId: apiIdOrParams as string | undefined, status: status as number, serverId: serverId as number, identIds };
479
481
  }
480
- const { apiId, account, status: resolvedStatus, serverId: resolvedServerId } = payload;
482
+ const { apiId, account, status: resolvedStatus, serverId: resolvedServerId, identIds: resolvedIdentIds } = payload;
481
483
  if (!Number.isInteger(resolvedServerId)) {
482
484
  throw new Error('serverId must be an integer when updating unit status.');
483
485
  }
484
486
  if (resolvedStatus === undefined) {
485
487
  throw new Error('status is required when updating unit status.');
486
488
  }
487
- if (!apiId && !account) {
488
- throw new Error('Either apiId or account is required when updating unit status.');
489
+ if (resolvedIdentIds !== undefined && (!Array.isArray(resolvedIdentIds) || resolvedIdentIds.some((id) => !Number.isInteger(id)))) {
490
+ throw new Error('identIds must be an array of integers when updating unit status.');
491
+ }
492
+ const hasIdentIds = Array.isArray(resolvedIdentIds) && resolvedIdentIds.length > 0;
493
+ if (!apiId && !account && !hasIdentIds) {
494
+ throw new Error('Either apiId, account, or identIds is required when updating unit status.');
489
495
  }
490
- return this.executeCadRequest('UNIT_STATUS', { apiId, account, status: resolvedStatus, serverId: resolvedServerId });
496
+ return this.executeCadRequest('UNIT_STATUS', {
497
+ apiId,
498
+ account,
499
+ status: resolvedStatus,
500
+ serverId: resolvedServerId,
501
+ identIds: hasIdentIds ? resolvedIdentIds : undefined
502
+ });
491
503
  }
492
504
 
493
505
  /**
@@ -607,12 +619,13 @@ export class CADManager extends BaseManager {
607
619
  /**
608
620
  * Attaches units to an existing dispatch call.
609
621
  */
610
- public async attachUnits(serverId: number, callId: number, unitsOrAccount: string[] | string): Promise<globalTypes.CADStandardResponse>;
622
+ public async attachUnits(serverId: number, callId: number, unitsOrAccount: string[] | string, identIds?: number[]): Promise<globalTypes.CADStandardResponse>;
611
623
  public async attachUnits(params: CADAttachUnitsStruct): Promise<globalTypes.CADStandardResponse>;
612
624
  public async attachUnits(
613
625
  serverIdOrParams: number | CADAttachUnitsStruct,
614
626
  callId?: number,
615
- unitsOrAccount?: string[] | string
627
+ unitsOrAccount?: string[] | string,
628
+ identIds?: number[]
616
629
  ): Promise<globalTypes.CADStandardResponse> {
617
630
  let payload: CADAttachUnitsStruct;
618
631
  if (serverIdOrParams && typeof serverIdOrParams === 'object') {
@@ -625,20 +638,31 @@ export class CADManager extends BaseManager {
625
638
  ? { units: unitsOrAccount }
626
639
  : typeof unitsOrAccount === 'string'
627
640
  ? { account: unitsOrAccount }
628
- : {})
641
+ : {}),
642
+ ...(Array.isArray(identIds) ? { identIds } : {})
629
643
  };
630
644
  }
631
645
 
632
- const { serverId, callId: resolvedCallId, units, account } = payload;
646
+ const { serverId, callId: resolvedCallId, units, account, identIds: resolvedIdentIds } = payload;
633
647
  if (!Number.isInteger(serverId) || !Number.isInteger(resolvedCallId)) {
634
648
  throw new Error('serverId and callId must be integers when attaching units.');
635
649
  }
636
650
  const hasUnits = Array.isArray(units) && units.length > 0;
637
651
  const hasAccount = typeof account === 'string' && account.length > 0;
638
- if (!hasUnits && !hasAccount) {
639
- throw new Error('Either units or account is required when attaching units.');
640
- }
641
- return this.executeCadRequest('ATTACH_UNIT', { serverId, callId: resolvedCallId, units: hasUnits ? units : undefined, account: hasAccount ? account : undefined });
652
+ if (resolvedIdentIds !== undefined && (!Array.isArray(resolvedIdentIds) || resolvedIdentIds.some((id) => !Number.isInteger(id)))) {
653
+ throw new Error('identIds must be an array of integers when attaching units.');
654
+ }
655
+ const hasIdentIds = Array.isArray(resolvedIdentIds) && resolvedIdentIds.length > 0;
656
+ if (!hasUnits && !hasAccount && !hasIdentIds) {
657
+ throw new Error('Either units, account, or identIds is required when attaching units.');
658
+ }
659
+ return this.executeCadRequest('ATTACH_UNIT', {
660
+ serverId,
661
+ callId: resolvedCallId,
662
+ units: hasUnits ? units : undefined,
663
+ account: hasAccount ? account : undefined,
664
+ identIds: hasIdentIds ? resolvedIdentIds : undefined
665
+ });
642
666
  }
643
667
 
644
668
  /**