@sonoransoftware/sonoran.js 1.0.63 → 1.0.64

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.
@@ -264,12 +264,13 @@ class REST extends events_1.EventEmitter {
264
264
  case 'UNIT_PANIC': {
265
265
  const payload = args[0];
266
266
  if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
267
- const { apiId, account, isPanic } = payload;
268
- return { apiId, account, isPanic };
267
+ const { apiId, account, isPanic, identIds } = payload;
268
+ return { apiId, account, isPanic, identIds };
269
269
  }
270
270
  return {
271
271
  apiId: args[0],
272
- isPanic: args[1]
272
+ isPanic: args[1],
273
+ identIds: args[2]
273
274
  };
274
275
  }
275
276
  case 'IDENTS_TO_GROUP': {
@@ -273,6 +273,7 @@ export interface CADUnitPanicStruct {
273
273
  apiId?: string;
274
274
  account?: string;
275
275
  isPanic: boolean;
276
+ identIds?: number[];
276
277
  }
277
278
  export declare enum CADDispatchOriginEnums {
278
279
  Caller = 0,
@@ -396,7 +397,8 @@ export interface RESTTypedAPIDataStructs {
396
397
  IDENTS_TO_GROUP: [data: CADIdentsToGroupStruct[]];
397
398
  UNIT_PANIC: [
398
399
  apiId: string | undefined,
399
- isPanic: boolean
400
+ isPanic: boolean,
401
+ identIds?: number[]
400
402
  ] | [
401
403
  data: CADUnitPanicStruct
402
404
  ];
@@ -160,7 +160,7 @@ export declare class CADManager extends BaseManager {
160
160
  /**
161
161
  * Toggles panic state for a unit.
162
162
  */
163
- setUnitPanic(apiId: string | undefined, isPanic: boolean): Promise<globalTypes.CADStandardResponse>;
163
+ setUnitPanic(apiId: string | undefined, isPanic: boolean, identIds?: number[]): Promise<globalTypes.CADStandardResponse>;
164
164
  setUnitPanic(params: CADUnitPanicStruct): Promise<globalTypes.CADStandardResponse>;
165
165
  /**
166
166
  * Updates a unit's status.
@@ -407,22 +407,31 @@ class CADManager extends BaseManager_1.BaseManager {
407
407
  });
408
408
  return this.executeCadRequest('IDENTS_TO_GROUP', payload);
409
409
  }
410
- async setUnitPanic(apiIdOrParams, isPanic) {
410
+ async setUnitPanic(apiIdOrParams, isPanic, identIds) {
411
411
  let payload;
412
412
  if (apiIdOrParams && typeof apiIdOrParams === 'object') {
413
413
  payload = { ...apiIdOrParams };
414
414
  }
415
415
  else {
416
- payload = { apiId: apiIdOrParams, isPanic: isPanic };
416
+ payload = { apiId: apiIdOrParams, isPanic: isPanic, identIds };
417
417
  }
418
- const { apiId, account, isPanic: resolvedPanic } = payload;
418
+ const { apiId, account, isPanic: resolvedPanic, identIds: resolvedIdentIds } = payload;
419
419
  if (resolvedPanic === undefined) {
420
420
  throw new Error('isPanic is required when setting unit panic.');
421
421
  }
422
- if (!apiId && !account) {
423
- throw new Error('Either apiId or account is required when setting unit panic.');
422
+ if (resolvedIdentIds !== undefined && (!Array.isArray(resolvedIdentIds) || resolvedIdentIds.some((id) => !Number.isInteger(id)))) {
423
+ throw new Error('identIds must be an array of integers when setting unit panic.');
424
+ }
425
+ const hasIdentIds = Array.isArray(resolvedIdentIds) && resolvedIdentIds.length > 0;
426
+ if (!apiId && !account && !hasIdentIds) {
427
+ throw new Error('Either apiId, account, or identIds is required when setting unit panic.');
424
428
  }
425
- return this.executeCadRequest('UNIT_PANIC', { apiId, account, isPanic: resolvedPanic });
429
+ return this.executeCadRequest('UNIT_PANIC', {
430
+ apiId,
431
+ account,
432
+ isPanic: resolvedPanic,
433
+ identIds: hasIdentIds ? resolvedIdentIds : undefined
434
+ });
426
435
  }
427
436
  async setUnitStatus(apiIdOrParams, status, serverId, identIds) {
428
437
  let payload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonoransoftware/sonoran.js",
3
- "version": "1.0.63",
3
+ "version": "1.0.64",
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?, identIds? })`**
108
+ - **`setUnitPanic({ apiId?, account?, isPanic, identIds? })`** / **`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)`**
@@ -119,6 +119,8 @@ await instance.cad.setUnitStatus('1234567890', 2, 1);
119
119
  await instance.cad.setUnitStatus({ identIds: [101, 102], status: 2, serverId: 1 });
120
120
  // Trigger panic using account UUID
121
121
  await instance.cad.setUnitPanic({ account: '91de0ce8-c571-11e9-9714-5600023b2434', isPanic: true });
122
+ // Trigger panic by identifier IDs
123
+ await instance.cad.setUnitPanic({ identIds: [101, 102], isPanic: true });
122
124
  ```
123
125
 
124
126
  ### Map & Streetsigns
@@ -374,12 +374,13 @@ export class REST extends EventEmitter {
374
374
  case 'UNIT_PANIC': {
375
375
  const payload = args[0];
376
376
  if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
377
- const { apiId, account, isPanic } = payload as { apiId?: string; account?: string; isPanic: boolean };
378
- return { apiId, account, isPanic };
377
+ const { apiId, account, isPanic, identIds } = payload as { apiId?: string; account?: string; isPanic: boolean; identIds?: number[] };
378
+ return { apiId, account, isPanic, identIds };
379
379
  }
380
380
  return {
381
381
  apiId: args[0],
382
- isPanic: args[1]
382
+ isPanic: args[1],
383
+ identIds: args[2]
383
384
  };
384
385
  }
385
386
  case 'IDENTS_TO_GROUP': {
@@ -970,6 +970,7 @@ export interface CADUnitPanicStruct {
970
970
  apiId?: string;
971
971
  account?: string;
972
972
  isPanic: boolean;
973
+ identIds?: number[];
973
974
  }
974
975
 
975
976
  export enum CADDispatchOriginEnums {
@@ -1096,7 +1097,8 @@ export interface RESTTypedAPIDataStructs {
1096
1097
  IDENTS_TO_GROUP: [data: CADIdentsToGroupStruct[]];
1097
1098
  UNIT_PANIC: [
1098
1099
  apiId: string | undefined,
1099
- isPanic: boolean
1100
+ isPanic: boolean,
1101
+ identIds?: number[]
1100
1102
  ] | [
1101
1103
  data: CADUnitPanicStruct
1102
1104
  ];
@@ -437,23 +437,32 @@ export class CADManager extends BaseManager {
437
437
  /**
438
438
  * Toggles panic state for a unit.
439
439
  */
440
- public async setUnitPanic(apiId: string | undefined, isPanic: boolean): Promise<globalTypes.CADStandardResponse>;
440
+ public async setUnitPanic(apiId: string | undefined, isPanic: boolean, identIds?: number[]): Promise<globalTypes.CADStandardResponse>;
441
441
  public async setUnitPanic(params: CADUnitPanicStruct): Promise<globalTypes.CADStandardResponse>;
442
- public async setUnitPanic(apiIdOrParams: string | CADUnitPanicStruct | undefined, isPanic?: boolean): Promise<globalTypes.CADStandardResponse> {
442
+ public async setUnitPanic(apiIdOrParams: string | CADUnitPanicStruct | undefined, isPanic?: boolean, identIds?: number[]): Promise<globalTypes.CADStandardResponse> {
443
443
  let payload: CADUnitPanicStruct;
444
444
  if (apiIdOrParams && typeof apiIdOrParams === 'object') {
445
445
  payload = { ...apiIdOrParams };
446
446
  } else {
447
- payload = { apiId: apiIdOrParams as string | undefined, isPanic: isPanic as boolean };
447
+ payload = { apiId: apiIdOrParams as string | undefined, isPanic: isPanic as boolean, identIds };
448
448
  }
449
- const { apiId, account, isPanic: resolvedPanic } = payload;
449
+ const { apiId, account, isPanic: resolvedPanic, identIds: resolvedIdentIds } = payload;
450
450
  if (resolvedPanic === undefined) {
451
451
  throw new Error('isPanic is required when setting unit panic.');
452
452
  }
453
- if (!apiId && !account) {
454
- throw new Error('Either apiId or account is required when setting unit panic.');
453
+ if (resolvedIdentIds !== undefined && (!Array.isArray(resolvedIdentIds) || resolvedIdentIds.some((id) => !Number.isInteger(id)))) {
454
+ throw new Error('identIds must be an array of integers when setting unit panic.');
455
+ }
456
+ const hasIdentIds = Array.isArray(resolvedIdentIds) && resolvedIdentIds.length > 0;
457
+ if (!apiId && !account && !hasIdentIds) {
458
+ throw new Error('Either apiId, account, or identIds is required when setting unit panic.');
455
459
  }
456
- return this.executeCadRequest('UNIT_PANIC', { apiId, account, isPanic: resolvedPanic });
460
+ return this.executeCadRequest('UNIT_PANIC', {
461
+ apiId,
462
+ account,
463
+ isPanic: resolvedPanic,
464
+ identIds: hasIdentIds ? resolvedIdentIds : undefined
465
+ });
457
466
  }
458
467
 
459
468
  /**