@sonoransoftware/sonoran.js 1.0.62 → 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.
@@ -251,24 +251,26 @@ 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': {
264
265
  const payload = args[0];
265
266
  if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
266
- const { apiId, account, isPanic } = payload;
267
- return { apiId, account, isPanic };
267
+ const { apiId, account, isPanic, identIds } = payload;
268
+ return { apiId, account, isPanic, identIds };
268
269
  }
269
270
  return {
270
271
  apiId: args[0],
271
- isPanic: args[1]
272
+ isPanic: args[1],
273
+ identIds: args[2]
272
274
  };
273
275
  }
274
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,
@@ -324,6 +325,7 @@ export interface CADUnitStatusStruct {
324
325
  account?: string;
325
326
  status: number;
326
327
  serverId: number;
328
+ identIds?: number[];
327
329
  }
328
330
  export interface RESTTypedAPIDataStructs {
329
331
  GET_SERVERS: [];
@@ -395,14 +397,16 @@ export interface RESTTypedAPIDataStructs {
395
397
  IDENTS_TO_GROUP: [data: CADIdentsToGroupStruct[]];
396
398
  UNIT_PANIC: [
397
399
  apiId: string | undefined,
398
- isPanic: boolean
400
+ isPanic: boolean,
401
+ identIds?: number[]
399
402
  ] | [
400
403
  data: CADUnitPanicStruct
401
404
  ];
402
405
  UNIT_STATUS: [
403
406
  apiId: string | undefined,
404
407
  status: number,
405
- serverId: number
408
+ serverId: number,
409
+ identIds?: number[]
406
410
  ] | [
407
411
  data: CADUnitStatusStruct
408
412
  ];
@@ -160,17 +160,18 @@ 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.
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.
@@ -407,47 +407,67 @@ 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
- async setUnitStatus(apiIdOrParams, status, serverId) {
436
+ async setUnitStatus(apiIdOrParams, status, serverId, identIds) {
428
437
  let payload;
429
438
  if (apiIdOrParams && typeof apiIdOrParams === 'object' && !Array.isArray(apiIdOrParams)) {
430
439
  payload = {
431
440
  apiId: apiIdOrParams.apiId,
432
441
  account: apiIdOrParams.account,
433
442
  status: apiIdOrParams.status,
434
- serverId: apiIdOrParams.serverId
443
+ serverId: apiIdOrParams.serverId,
444
+ identIds: apiIdOrParams.identIds
435
445
  };
436
446
  }
437
447
  else {
438
- payload = { apiId: apiIdOrParams, status: status, serverId: serverId };
448
+ payload = { apiId: apiIdOrParams, status: status, serverId: serverId, identIds };
439
449
  }
440
- const { apiId, account, status: resolvedStatus, serverId: resolvedServerId } = payload;
450
+ const { apiId, account, status: resolvedStatus, serverId: resolvedServerId, identIds: resolvedIdentIds } = payload;
441
451
  if (!Number.isInteger(resolvedServerId)) {
442
452
  throw new Error('serverId must be an integer when updating unit status.');
443
453
  }
444
454
  if (resolvedStatus === undefined) {
445
455
  throw new Error('status is required when updating unit status.');
446
456
  }
447
- if (!apiId && !account) {
448
- throw new Error('Either apiId or account is required when updating unit status.');
457
+ if (resolvedIdentIds !== undefined && (!Array.isArray(resolvedIdentIds) || resolvedIdentIds.some((id) => !Number.isInteger(id)))) {
458
+ throw new Error('identIds must be an array of integers when updating unit status.');
449
459
  }
450
- return this.executeCadRequest('UNIT_STATUS', { apiId, account, status: resolvedStatus, serverId: resolvedServerId });
460
+ const hasIdentIds = Array.isArray(resolvedIdentIds) && resolvedIdentIds.length > 0;
461
+ if (!apiId && !account && !hasIdentIds) {
462
+ throw new Error('Either apiId, account, or identIds is required when updating unit status.');
463
+ }
464
+ return this.executeCadRequest('UNIT_STATUS', {
465
+ apiId,
466
+ account,
467
+ status: resolvedStatus,
468
+ serverId: resolvedServerId,
469
+ identIds: hasIdentIds ? resolvedIdentIds : undefined
470
+ });
451
471
  }
452
472
  /**
453
473
  * 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.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? })`**
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)`**
@@ -115,8 +115,12 @@ 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 });
122
+ // Trigger panic by identifier IDs
123
+ await instance.cad.setUnitPanic({ identIds: [101, 102], isPanic: true });
120
124
  ```
121
125
 
122
126
  ### Map & Streetsigns
@@ -355,29 +355,32 @@ 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': {
373
375
  const payload = args[0];
374
376
  if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
375
- const { apiId, account, isPanic } = payload as { apiId?: string; account?: string; isPanic: boolean };
376
- 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 };
377
379
  }
378
380
  return {
379
381
  apiId: args[0],
380
- isPanic: args[1]
382
+ isPanic: args[1],
383
+ identIds: args[2]
381
384
  };
382
385
  }
383
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 {
@@ -1024,6 +1025,7 @@ export interface CADUnitStatusStruct {
1024
1025
  account?: string;
1025
1026
  status: number;
1026
1027
  serverId: number;
1028
+ identIds?: number[];
1027
1029
  }
1028
1030
 
1029
1031
  export interface RESTTypedAPIDataStructs {
@@ -1095,14 +1097,16 @@ export interface RESTTypedAPIDataStructs {
1095
1097
  IDENTS_TO_GROUP: [data: CADIdentsToGroupStruct[]];
1096
1098
  UNIT_PANIC: [
1097
1099
  apiId: string | undefined,
1098
- isPanic: boolean
1100
+ isPanic: boolean,
1101
+ identIds?: number[]
1099
1102
  ] | [
1100
1103
  data: CADUnitPanicStruct
1101
1104
  ];
1102
1105
  UNIT_STATUS: [
1103
1106
  apiId: string | undefined,
1104
1107
  status: number,
1105
- serverId: number
1108
+ serverId: number,
1109
+ identIds?: number[]
1106
1110
  ] | [
1107
1111
  data: CADUnitStatusStruct
1108
1112
  ];
@@ -437,34 +437,44 @@ 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
  /**
460
469
  * Updates a unit's status.
461
470
  */
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>;
471
+ public async setUnitStatus(apiId: string | undefined, status: number, serverId: number, identIds?: number[]): Promise<globalTypes.CADStandardResponse>;
472
+ public async setUnitStatus(params: { apiId?: string; account?: string; status: number; serverId: number; identIds?: number[] }): Promise<globalTypes.CADStandardResponse>;
464
473
  public async setUnitStatus(
465
- apiIdOrParams: string | undefined | { apiId?: string; account?: string; status: number; serverId: number },
474
+ apiIdOrParams: string | undefined | { apiId?: string; account?: string; status: number; serverId: number; identIds?: number[] },
466
475
  status?: number,
467
- serverId?: number
476
+ serverId?: number,
477
+ identIds?: number[]
468
478
  ): Promise<globalTypes.CADStandardResponse> {
469
479
  let payload: CADUnitStatusStruct;
470
480
  if (apiIdOrParams && typeof apiIdOrParams === 'object' && !Array.isArray(apiIdOrParams)) {
@@ -472,22 +482,33 @@ export class CADManager extends BaseManager {
472
482
  apiId: apiIdOrParams.apiId,
473
483
  account: apiIdOrParams.account,
474
484
  status: apiIdOrParams.status,
475
- serverId: apiIdOrParams.serverId
485
+ serverId: apiIdOrParams.serverId,
486
+ identIds: apiIdOrParams.identIds
476
487
  };
477
488
  } else {
478
- payload = { apiId: apiIdOrParams as string | undefined, status: status as number, serverId: serverId as number };
489
+ payload = { apiId: apiIdOrParams as string | undefined, status: status as number, serverId: serverId as number, identIds };
479
490
  }
480
- const { apiId, account, status: resolvedStatus, serverId: resolvedServerId } = payload;
491
+ const { apiId, account, status: resolvedStatus, serverId: resolvedServerId, identIds: resolvedIdentIds } = payload;
481
492
  if (!Number.isInteger(resolvedServerId)) {
482
493
  throw new Error('serverId must be an integer when updating unit status.');
483
494
  }
484
495
  if (resolvedStatus === undefined) {
485
496
  throw new Error('status is required when updating unit status.');
486
497
  }
487
- if (!apiId && !account) {
488
- throw new Error('Either apiId or account is required when updating unit status.');
498
+ if (resolvedIdentIds !== undefined && (!Array.isArray(resolvedIdentIds) || resolvedIdentIds.some((id) => !Number.isInteger(id)))) {
499
+ throw new Error('identIds must be an array of integers when updating unit status.');
489
500
  }
490
- return this.executeCadRequest('UNIT_STATUS', { apiId, account, status: resolvedStatus, serverId: resolvedServerId });
501
+ const hasIdentIds = Array.isArray(resolvedIdentIds) && resolvedIdentIds.length > 0;
502
+ if (!apiId && !account && !hasIdentIds) {
503
+ throw new Error('Either apiId, account, or identIds is required when updating unit status.');
504
+ }
505
+ return this.executeCadRequest('UNIT_STATUS', {
506
+ apiId,
507
+ account,
508
+ status: resolvedStatus,
509
+ serverId: resolvedServerId,
510
+ identIds: hasIdentIds ? resolvedIdentIds : undefined
511
+ });
491
512
  }
492
513
 
493
514
  /**