@sonoransoftware/sonoran.js 1.0.62 → 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': {
@@ -324,6 +324,7 @@ export interface CADUnitStatusStruct {
324
324
  account?: string;
325
325
  status: number;
326
326
  serverId: number;
327
+ identIds?: number[];
327
328
  }
328
329
  export interface RESTTypedAPIDataStructs {
329
330
  GET_SERVERS: [];
@@ -402,7 +403,8 @@ export interface RESTTypedAPIDataStructs {
402
403
  UNIT_STATUS: [
403
404
  apiId: string | undefined,
404
405
  status: number,
405
- serverId: number
406
+ serverId: number,
407
+ identIds?: number[]
406
408
  ] | [
407
409
  data: CADUnitStatusStruct
408
410
  ];
@@ -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.
@@ -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.');
449
450
  }
450
- return this.executeCadRequest('UNIT_STATUS', { apiId, account, status: resolvedStatus, serverId: resolvedServerId });
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.');
454
+ }
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonoransoftware/sonoran.js",
3
- "version": "1.0.62",
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': {
@@ -1024,6 +1024,7 @@ export interface CADUnitStatusStruct {
1024
1024
  account?: string;
1025
1025
  status: number;
1026
1026
  serverId: number;
1027
+ identIds?: number[];
1027
1028
  }
1028
1029
 
1029
1030
  export interface RESTTypedAPIDataStructs {
@@ -1102,7 +1103,8 @@ export interface RESTTypedAPIDataStructs {
1102
1103
  UNIT_STATUS: [
1103
1104
  apiId: string | undefined,
1104
1105
  status: number,
1105
- serverId: number
1106
+ serverId: number,
1107
+ identIds?: number[]
1106
1108
  ] | [
1107
1109
  data: CADUnitStatusStruct
1108
1110
  ];
@@ -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.');
489
491
  }
490
- return this.executeCadRequest('UNIT_STATUS', { apiId, account, status: resolvedStatus, serverId: resolvedServerId });
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.');
495
+ }
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
  /**