@sonoransoftware/sonoran.js 1.0.63 → 1.0.65
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 +4 -3
- package/dist/libs/rest/src/lib/RequestManager.js +4 -0
- package/dist/libs/rest/src/lib/utils/constants.d.ts +12 -3
- package/dist/libs/rest/src/lib/utils/constants.js +6 -0
- package/dist/managers/CADManager.d.ts +6 -2
- package/dist/managers/CADManager.js +33 -6
- package/package.json +1 -1
- package/readme.md +3 -1
- package/src/libs/rest/src/lib/REST.ts +4 -3
- package/src/libs/rest/src/lib/RequestManager.ts +4 -0
- package/src/libs/rest/src/lib/utils/constants.ts +19 -3
- package/src/managers/CADManager.ts +36 -7
|
@@ -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': {
|
|
@@ -133,6 +133,10 @@ class RequestManager extends events_1.EventEmitter {
|
|
|
133
133
|
apiData.data.data = [clonedData[0]];
|
|
134
134
|
break;
|
|
135
135
|
}
|
|
136
|
+
case 'SEND_DRAFT': {
|
|
137
|
+
apiData.data.data = [clonedData[0]];
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
136
140
|
case 'EDIT_RECORD': {
|
|
137
141
|
apiData.data.data = [clonedData[0]];
|
|
138
142
|
break;
|
|
@@ -38,7 +38,7 @@ export declare const CommunitiesCMSAPITypes: APITypeData[];
|
|
|
38
38
|
export declare const ERLCMSAPITypes: APITypeData[];
|
|
39
39
|
export declare const RadioAPITypes: APITypeData[];
|
|
40
40
|
export declare const AllAPITypes: AllAPITypeData[];
|
|
41
|
-
export type AllAPITypesType = 'GET_SERVERS' | 'SET_SERVERS' | 'GET_VERSION' | 'SET_PENAL_CODES' | 'SET_API_ID' | 'GET_TEMPLATES' | 'NEW_RECORD' | 'EDIT_RECORD' | 'REMOVE_RECORD' | 'LOOKUP_INT' | 'LOOKUP' | 'GET_ACCOUNT' | 'CHECK_APIID' | 'APPLY_PERMISSION_KEY' | 'SET_ACCOUNT_PERMISSIONS' | 'BAN_USER' | 'VERIFY_SECRET' | 'AUTH_STREETSIGNS' | 'SET_POSTALS' | 'SEND_PHOTO' | 'SET_CLOCK' | 'JOIN_COMMUNITY' | 'LEAVE_COMMUNITY' | 'GET_CHARACTERS' | 'NEW_CHARACTER' | 'EDIT_CHARACTER' | 'REMOVE_CHARACTER' | 'GET_IDENTIFIERS' | 'MODIFY_IDENTIFIER' | 'SET_IDENTIFIER' | 'IDENTS_TO_GROUP' | 'UNIT_PANIC' | 'UNIT_STATUS' | 'GET_BLIPS' | 'ADD_BLIP' | 'MODIFY_BLIP' | 'REMOVE_BLIP' | '911_CALL' | 'REMOVE_911' | 'GET_CALLS' | 'GET_MY_CALL' | 'GET_ACTIVE_UNITS' | 'KICK_UNIT' | 'NEW_DISPATCH' | 'ATTACH_UNIT' | 'DETACH_UNIT' | 'SET_CALL_POSTAL' | 'SET_CALL_PRIMARY' | 'ADD_CALL_NOTE' | 'CLOSE_CALL' | 'UNIT_LOCATION' | 'SET_STREETSIGN_CONFIG' | 'UPDATE_STREETSIGN' | 'GET_COM_ACCOUNT' | 'GET_DEPARTMENTS' | 'GET_SUB_VERSION' | 'GET_CURRENT_CLOCK_IN' | 'GET_CLOCKIN_TYPES' | 'GET_LATEST_ACTIVITY' | 'GET_ACCOUNTS' | 'GET_PROFILE_FIELDS' | 'CHECK_COM_APIID' | 'VERIFY_WHITELIST' | 'CLOCK_IN_OUT' | 'FULL_WHITELIST' | 'GET_ACCOUNT_RANKS' | 'SET_ACCOUNT_RANKS' | 'RSVP' | 'CHANGE_FORM_STAGE' | 'GET_FORM_TEMPLATE_SUBMISSIONS' | 'GET_FORM_LOCK_STATUS' | 'SET_FORM_LOCK_STATUS' | 'GET_CURRENT_SESSION' | 'START_SESSION' | 'STOP_SESSION' | 'CANCEL_SESSION' | 'KICK_ACCOUNT' | 'BAN_ACCOUNT' | 'LOOKUP' | 'EDIT_ACC_PROFLIE_FIELDS' | 'SET_ACCOUNT_NAME' | 'FORCE_SYNC' | 'TRIGGER_PROMOTION_FLOWS' | 'GET_PROMOTION_FLOWS' | 'GET_CUSTOM_LOG_TYPES' | 'SET_GAME_SERVERS' | 'ERLC_GET_ONLINE_PLAYERS' | 'ERLC_GET_PLAYER_QUEUE' | 'ERLC_ADD_NEW_RECORD' | 'ERLC_EXECUTE_COMMAND' | 'ERLC_TEAMS_LOCK' | 'ERLC_TEAMS_UNLOCK' | 'RADIO_GET_COMMUNITY_CHANNELS' | 'RADIO_GET_CONNECTED_USERS' | 'RADIO_GET_CONNECTED_USER' | 'RADIO_SET_USER_CHANNELS' | 'RADIO_SET_USER_DISPLAY_NAME' | 'RADIO_GET_SERVER_SUBSCRIPTION_FROM_IP' | 'RADIO_SET_SERVER_IP' | 'RADIO_SET_IN_GAME_SPEAKER_LOCATIONS' | 'PLAY_TONE';
|
|
41
|
+
export type AllAPITypesType = 'GET_SERVERS' | 'SET_SERVERS' | 'GET_VERSION' | 'SET_PENAL_CODES' | 'SET_API_ID' | 'GET_TEMPLATES' | 'NEW_RECORD' | 'SEND_DRAFT' | 'EDIT_RECORD' | 'REMOVE_RECORD' | 'LOOKUP_INT' | 'LOOKUP' | 'GET_ACCOUNT' | 'CHECK_APIID' | 'APPLY_PERMISSION_KEY' | 'SET_ACCOUNT_PERMISSIONS' | 'BAN_USER' | 'VERIFY_SECRET' | 'AUTH_STREETSIGNS' | 'SET_POSTALS' | 'SEND_PHOTO' | 'SET_CLOCK' | 'JOIN_COMMUNITY' | 'LEAVE_COMMUNITY' | 'GET_CHARACTERS' | 'NEW_CHARACTER' | 'EDIT_CHARACTER' | 'REMOVE_CHARACTER' | 'GET_IDENTIFIERS' | 'MODIFY_IDENTIFIER' | 'SET_IDENTIFIER' | 'IDENTS_TO_GROUP' | 'UNIT_PANIC' | 'UNIT_STATUS' | 'GET_BLIPS' | 'ADD_BLIP' | 'MODIFY_BLIP' | 'REMOVE_BLIP' | '911_CALL' | 'REMOVE_911' | 'GET_CALLS' | 'GET_MY_CALL' | 'GET_ACTIVE_UNITS' | 'KICK_UNIT' | 'NEW_DISPATCH' | 'ATTACH_UNIT' | 'DETACH_UNIT' | 'SET_CALL_POSTAL' | 'SET_CALL_PRIMARY' | 'ADD_CALL_NOTE' | 'CLOSE_CALL' | 'UNIT_LOCATION' | 'SET_STREETSIGN_CONFIG' | 'UPDATE_STREETSIGN' | 'GET_COM_ACCOUNT' | 'GET_DEPARTMENTS' | 'GET_SUB_VERSION' | 'GET_CURRENT_CLOCK_IN' | 'GET_CLOCKIN_TYPES' | 'GET_LATEST_ACTIVITY' | 'GET_ACCOUNTS' | 'GET_PROFILE_FIELDS' | 'CHECK_COM_APIID' | 'VERIFY_WHITELIST' | 'CLOCK_IN_OUT' | 'FULL_WHITELIST' | 'GET_ACCOUNT_RANKS' | 'SET_ACCOUNT_RANKS' | 'RSVP' | 'CHANGE_FORM_STAGE' | 'GET_FORM_TEMPLATE_SUBMISSIONS' | 'GET_FORM_LOCK_STATUS' | 'SET_FORM_LOCK_STATUS' | 'GET_CURRENT_SESSION' | 'START_SESSION' | 'STOP_SESSION' | 'CANCEL_SESSION' | 'KICK_ACCOUNT' | 'BAN_ACCOUNT' | 'LOOKUP' | 'EDIT_ACC_PROFLIE_FIELDS' | 'SET_ACCOUNT_NAME' | 'FORCE_SYNC' | 'TRIGGER_PROMOTION_FLOWS' | 'GET_PROMOTION_FLOWS' | 'GET_CUSTOM_LOG_TYPES' | 'SET_GAME_SERVERS' | 'ERLC_GET_ONLINE_PLAYERS' | 'ERLC_GET_PLAYER_QUEUE' | 'ERLC_ADD_NEW_RECORD' | 'ERLC_EXECUTE_COMMAND' | 'ERLC_TEAMS_LOCK' | 'ERLC_TEAMS_UNLOCK' | 'RADIO_GET_COMMUNITY_CHANNELS' | 'RADIO_GET_CONNECTED_USERS' | 'RADIO_GET_CONNECTED_USER' | 'RADIO_SET_USER_CHANNELS' | 'RADIO_SET_USER_DISPLAY_NAME' | 'RADIO_GET_SERVER_SUBSCRIPTION_FROM_IP' | 'RADIO_SET_SERVER_IP' | 'RADIO_SET_IN_GAME_SPEAKER_LOCATIONS' | 'PLAY_TONE';
|
|
42
42
|
export interface CMSServerAPIStruct {
|
|
43
43
|
id: number;
|
|
44
44
|
name: string;
|
|
@@ -145,6 +145,12 @@ export interface CADNewEditRecordOptionTwoStruct {
|
|
|
145
145
|
user: string;
|
|
146
146
|
record: CADRecordStruct;
|
|
147
147
|
}
|
|
148
|
+
export interface CADSendDraftStruct {
|
|
149
|
+
apiId?: string;
|
|
150
|
+
account?: string;
|
|
151
|
+
recordTypeId: number;
|
|
152
|
+
replaceValues: Record<string, string>;
|
|
153
|
+
}
|
|
148
154
|
export declare enum CADLookupByIntSearchTypeEnums {
|
|
149
155
|
IDENTIFIER = 0,
|
|
150
156
|
SUPERVISOR_STATUS = 1,
|
|
@@ -273,6 +279,7 @@ export interface CADUnitPanicStruct {
|
|
|
273
279
|
apiId?: string;
|
|
274
280
|
account?: string;
|
|
275
281
|
isPanic: boolean;
|
|
282
|
+
identIds?: number[];
|
|
276
283
|
}
|
|
277
284
|
export declare enum CADDispatchOriginEnums {
|
|
278
285
|
Caller = 0,
|
|
@@ -337,6 +344,7 @@ export interface RESTTypedAPIDataStructs {
|
|
|
337
344
|
SET_API_ID: [data: CADSetAPIIDStruct];
|
|
338
345
|
GET_TEMPLATES: [recordTypeId?: number];
|
|
339
346
|
NEW_RECORD: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
|
|
347
|
+
SEND_DRAFT: [data: CADSendDraftStruct];
|
|
340
348
|
EDIT_RECORD: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
|
|
341
349
|
REMOVE_RECORD: [id: number];
|
|
342
350
|
LOOKUP_INT: [data: CADLookupByIntStruct];
|
|
@@ -396,7 +404,8 @@ export interface RESTTypedAPIDataStructs {
|
|
|
396
404
|
IDENTS_TO_GROUP: [data: CADIdentsToGroupStruct[]];
|
|
397
405
|
UNIT_PANIC: [
|
|
398
406
|
apiId: string | undefined,
|
|
399
|
-
isPanic: boolean
|
|
407
|
+
isPanic: boolean,
|
|
408
|
+
identIds?: number[]
|
|
400
409
|
] | [
|
|
401
410
|
data: CADUnitPanicStruct
|
|
402
411
|
];
|
|
@@ -698,7 +707,7 @@ export interface RESTTypedAPIDataStructs {
|
|
|
698
707
|
];
|
|
699
708
|
}
|
|
700
709
|
export type PossibleRequestData = undefined | {
|
|
701
|
-
data: CADPenalCodeStruct[] | CADSetAPIIDStruct | CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct | CADLookupByIntStruct | CADLookupStruct | CADModifyAccountPermsStruct | CADKickBanUserStruct | CADSetPostalStruct[] | CADModifyIdentifierStruct | CADIdentsToGroupStruct[] | CADAddBlipStruct[] | CADModifyBlipStruct[] | CADGetCallsStruct | CADGetActiveUnitsStruct | CADNewDispatchStruct | CMSTriggerPromotionFlowPayload[];
|
|
710
|
+
data: CADPenalCodeStruct[] | CADSetAPIIDStruct | CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct | CADSendDraftStruct | CADLookupByIntStruct | CADLookupStruct | CADModifyAccountPermsStruct | CADKickBanUserStruct | CADSetPostalStruct[] | CADModifyIdentifierStruct | CADIdentsToGroupStruct[] | CADAddBlipStruct[] | CADModifyBlipStruct[] | CADGetCallsStruct | CADGetActiveUnitsStruct | CADNewDispatchStruct | CMSTriggerPromotionFlowPayload[];
|
|
702
711
|
} | {
|
|
703
712
|
servers: CADServerAPIStruct[];
|
|
704
713
|
deployMap: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Instance } from '../instance/Instance';
|
|
2
2
|
import { CADSubscriptionVersionEnum } from '../constants';
|
|
3
3
|
import { REST } from '../libs/rest/src';
|
|
4
|
-
import type { CADPenalCodeStruct, CADSetAPIIDStruct, CADNewEditRecordOptionOneStruct, CADNewEditRecordOptionTwoStruct, CADLookupByIntStruct, CADLookupStruct, CADModifyAccountPermsStruct, CADKickBanUserStruct, CADSetPostalStruct, CADModifyIdentifierStruct, CADIdentsToGroupStruct, CADAddBlipStruct, CADModifyBlipStruct, CADGetCallsStruct, CADGetMyCallStruct, CADAddCallNoteStruct, CADGetActiveUnitsStruct, CADNewDispatchStruct, CADAttachUnitsStruct, CADDetachUnitsStruct, CADStreetSignStruct, CADUnitLocationStruct, CADUnitPanicStruct } from '../libs/rest/src';
|
|
4
|
+
import type { CADPenalCodeStruct, CADSetAPIIDStruct, CADNewEditRecordOptionOneStruct, CADNewEditRecordOptionTwoStruct, CADSendDraftStruct, CADLookupByIntStruct, CADLookupStruct, CADModifyAccountPermsStruct, CADKickBanUserStruct, CADSetPostalStruct, CADModifyIdentifierStruct, CADIdentsToGroupStruct, CADAddBlipStruct, CADModifyBlipStruct, CADGetCallsStruct, CADGetMyCallStruct, CADAddCallNoteStruct, CADGetActiveUnitsStruct, CADNewDispatchStruct, CADAttachUnitsStruct, CADDetachUnitsStruct, CADStreetSignStruct, CADUnitLocationStruct, CADUnitPanicStruct } from '../libs/rest/src';
|
|
5
5
|
import { BaseManager } from './BaseManager';
|
|
6
6
|
import * as globalTypes from '../constants';
|
|
7
7
|
import { CADServerManager } from './CADServerManager';
|
|
@@ -76,6 +76,10 @@ export declare class CADManager extends BaseManager {
|
|
|
76
76
|
* Creates a new record entry.
|
|
77
77
|
*/
|
|
78
78
|
createRecord(data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct): Promise<globalTypes.CADStandardResponse>;
|
|
79
|
+
/**
|
|
80
|
+
* Sends a record draft with populated fields.
|
|
81
|
+
*/
|
|
82
|
+
sendDraft(data: CADSendDraftStruct): Promise<globalTypes.CADStandardResponse>;
|
|
79
83
|
/**
|
|
80
84
|
* Updates an existing record entry.
|
|
81
85
|
*/
|
|
@@ -160,7 +164,7 @@ export declare class CADManager extends BaseManager {
|
|
|
160
164
|
/**
|
|
161
165
|
* Toggles panic state for a unit.
|
|
162
166
|
*/
|
|
163
|
-
setUnitPanic(apiId: string | undefined, isPanic: boolean): Promise<globalTypes.CADStandardResponse>;
|
|
167
|
+
setUnitPanic(apiId: string | undefined, isPanic: boolean, identIds?: number[]): Promise<globalTypes.CADStandardResponse>;
|
|
164
168
|
setUnitPanic(params: CADUnitPanicStruct): Promise<globalTypes.CADStandardResponse>;
|
|
165
169
|
/**
|
|
166
170
|
* Updates a unit's status.
|
|
@@ -217,6 +217,24 @@ class CADManager extends BaseManager_1.BaseManager {
|
|
|
217
217
|
async createRecord(data) {
|
|
218
218
|
return this.executeCadRequest('NEW_RECORD', data);
|
|
219
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Sends a record draft with populated fields.
|
|
222
|
+
*/
|
|
223
|
+
async sendDraft(data) {
|
|
224
|
+
if (!data || typeof data !== 'object') {
|
|
225
|
+
throw new Error('data is required when sending a draft.');
|
|
226
|
+
}
|
|
227
|
+
if (!data.apiId && !data.account) {
|
|
228
|
+
throw new Error('apiId or account is required when sending a draft.');
|
|
229
|
+
}
|
|
230
|
+
if (!Number.isInteger(data.recordTypeId)) {
|
|
231
|
+
throw new Error('recordTypeId must be an integer when sending a draft.');
|
|
232
|
+
}
|
|
233
|
+
if (!data.replaceValues || typeof data.replaceValues !== 'object') {
|
|
234
|
+
throw new Error('replaceValues is required when sending a draft.');
|
|
235
|
+
}
|
|
236
|
+
return this.executeCadRequest('SEND_DRAFT', data);
|
|
237
|
+
}
|
|
220
238
|
/**
|
|
221
239
|
* Updates an existing record entry.
|
|
222
240
|
*/
|
|
@@ -407,22 +425,31 @@ class CADManager extends BaseManager_1.BaseManager {
|
|
|
407
425
|
});
|
|
408
426
|
return this.executeCadRequest('IDENTS_TO_GROUP', payload);
|
|
409
427
|
}
|
|
410
|
-
async setUnitPanic(apiIdOrParams, isPanic) {
|
|
428
|
+
async setUnitPanic(apiIdOrParams, isPanic, identIds) {
|
|
411
429
|
let payload;
|
|
412
430
|
if (apiIdOrParams && typeof apiIdOrParams === 'object') {
|
|
413
431
|
payload = { ...apiIdOrParams };
|
|
414
432
|
}
|
|
415
433
|
else {
|
|
416
|
-
payload = { apiId: apiIdOrParams, isPanic: isPanic };
|
|
434
|
+
payload = { apiId: apiIdOrParams, isPanic: isPanic, identIds };
|
|
417
435
|
}
|
|
418
|
-
const { apiId, account, isPanic: resolvedPanic } = payload;
|
|
436
|
+
const { apiId, account, isPanic: resolvedPanic, identIds: resolvedIdentIds } = payload;
|
|
419
437
|
if (resolvedPanic === undefined) {
|
|
420
438
|
throw new Error('isPanic is required when setting unit panic.');
|
|
421
439
|
}
|
|
422
|
-
if (
|
|
423
|
-
throw new Error('
|
|
440
|
+
if (resolvedIdentIds !== undefined && (!Array.isArray(resolvedIdentIds) || resolvedIdentIds.some((id) => !Number.isInteger(id)))) {
|
|
441
|
+
throw new Error('identIds must be an array of integers when setting unit panic.');
|
|
424
442
|
}
|
|
425
|
-
|
|
443
|
+
const hasIdentIds = Array.isArray(resolvedIdentIds) && resolvedIdentIds.length > 0;
|
|
444
|
+
if (!apiId && !account && !hasIdentIds) {
|
|
445
|
+
throw new Error('Either apiId, account, or identIds is required when setting unit panic.');
|
|
446
|
+
}
|
|
447
|
+
return this.executeCadRequest('UNIT_PANIC', {
|
|
448
|
+
apiId,
|
|
449
|
+
account,
|
|
450
|
+
isPanic: resolvedPanic,
|
|
451
|
+
identIds: hasIdentIds ? resolvedIdentIds : undefined
|
|
452
|
+
});
|
|
426
453
|
}
|
|
427
454
|
async setUnitStatus(apiIdOrParams, status, serverId, identIds) {
|
|
428
455
|
let payload;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonoransoftware/sonoran.js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.65",
|
|
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': {
|
|
@@ -206,6 +206,10 @@ export class RequestManager extends EventEmitter {
|
|
|
206
206
|
apiData.data.data = [clonedData[0]];
|
|
207
207
|
break;
|
|
208
208
|
}
|
|
209
|
+
case 'SEND_DRAFT': {
|
|
210
|
+
apiData.data.data = [clonedData[0]];
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
209
213
|
case 'EDIT_RECORD': {
|
|
210
214
|
apiData.data.data = [clonedData[0]];
|
|
211
215
|
break;
|
|
@@ -93,6 +93,12 @@ export const GeneralCADAPITypes: APITypeData[] = [
|
|
|
93
93
|
method: 'POST',
|
|
94
94
|
minVersion: 3
|
|
95
95
|
},
|
|
96
|
+
{
|
|
97
|
+
type: 'SEND_DRAFT',
|
|
98
|
+
path: 'general/send_draft',
|
|
99
|
+
method: 'POST',
|
|
100
|
+
minVersion: 3
|
|
101
|
+
},
|
|
96
102
|
{
|
|
97
103
|
type: 'EDIT_RECORD',
|
|
98
104
|
path: 'general/edit_record',
|
|
@@ -703,7 +709,7 @@ function formatForAll(array: APITypeData[], product: productEnums): AllAPITypeDa
|
|
|
703
709
|
|
|
704
710
|
export const AllAPITypes: AllAPITypeData[] = [ ...formatForAll(GeneralCADAPITypes, productEnums.CAD), ...formatForAll(CivilianCADAPITypes, productEnums.CAD), ...formatForAll(EmergencyCADAPITypes, productEnums.CAD), ...formatForAll(GeneralCMSAPITypes, productEnums.CMS), ...formatForAll(ServersCMSAPITypes, productEnums.CMS), ...formatForAll(EventsCMSAPITypes, productEnums.CMS), ...formatForAll(FormsCMSAPITypes, productEnums.CMS), ...formatForAll(CommunitiesCMSAPITypes, productEnums.CMS), ...formatForAll(ERLCMSAPITypes, productEnums.CMS), ...formatForAll(RadioAPITypes, productEnums.RADIO) ];
|
|
705
711
|
|
|
706
|
-
export type AllAPITypesType = 'GET_SERVERS' | 'SET_SERVERS' | 'GET_VERSION' | 'SET_PENAL_CODES' | 'SET_API_ID' | 'GET_TEMPLATES' | 'NEW_RECORD' | 'EDIT_RECORD' | 'REMOVE_RECORD' | 'LOOKUP_INT' | 'LOOKUP' | 'GET_ACCOUNT' | 'CHECK_APIID' | 'APPLY_PERMISSION_KEY' | 'SET_ACCOUNT_PERMISSIONS' | 'BAN_USER' | 'VERIFY_SECRET' | 'AUTH_STREETSIGNS' | 'SET_POSTALS' | 'SEND_PHOTO' | 'SET_CLOCK' | 'JOIN_COMMUNITY' | 'LEAVE_COMMUNITY' | 'GET_CHARACTERS' | 'NEW_CHARACTER' | 'EDIT_CHARACTER' | 'REMOVE_CHARACTER' | 'GET_IDENTIFIERS' | 'MODIFY_IDENTIFIER' | 'SET_IDENTIFIER' | 'IDENTS_TO_GROUP' | 'UNIT_PANIC' | 'UNIT_STATUS' | 'GET_BLIPS' | 'ADD_BLIP' | 'MODIFY_BLIP' | 'REMOVE_BLIP' | '911_CALL' | 'REMOVE_911' | 'GET_CALLS' | 'GET_MY_CALL' | 'GET_ACTIVE_UNITS' | 'KICK_UNIT' | 'NEW_DISPATCH' | 'ATTACH_UNIT' | 'DETACH_UNIT' | 'SET_CALL_POSTAL' | 'SET_CALL_PRIMARY' | 'ADD_CALL_NOTE' | 'CLOSE_CALL' | 'UNIT_LOCATION' | 'SET_STREETSIGN_CONFIG' | 'UPDATE_STREETSIGN' | 'GET_COM_ACCOUNT' | 'GET_DEPARTMENTS' | 'GET_SUB_VERSION' | 'GET_CURRENT_CLOCK_IN' | 'GET_CLOCKIN_TYPES' | 'GET_LATEST_ACTIVITY' | 'GET_ACCOUNTS' | 'GET_PROFILE_FIELDS' | 'CHECK_COM_APIID' | 'VERIFY_WHITELIST' | 'CLOCK_IN_OUT' | 'FULL_WHITELIST' | 'GET_ACCOUNT_RANKS' | 'SET_ACCOUNT_RANKS' | 'RSVP' | 'CHANGE_FORM_STAGE' | 'GET_FORM_TEMPLATE_SUBMISSIONS' | 'GET_FORM_LOCK_STATUS' | 'SET_FORM_LOCK_STATUS' | 'GET_CURRENT_SESSION' | 'START_SESSION' | 'STOP_SESSION' | 'CANCEL_SESSION' | 'KICK_ACCOUNT' | 'BAN_ACCOUNT' | 'LOOKUP' | 'EDIT_ACC_PROFLIE_FIELDS' | 'SET_ACCOUNT_NAME' | 'FORCE_SYNC' | 'TRIGGER_PROMOTION_FLOWS' | 'GET_PROMOTION_FLOWS' | 'GET_CUSTOM_LOG_TYPES' | 'SET_GAME_SERVERS' | 'ERLC_GET_ONLINE_PLAYERS' | 'ERLC_GET_PLAYER_QUEUE' | 'ERLC_ADD_NEW_RECORD' | 'ERLC_EXECUTE_COMMAND' | 'ERLC_TEAMS_LOCK' | 'ERLC_TEAMS_UNLOCK' | 'RADIO_GET_COMMUNITY_CHANNELS' | 'RADIO_GET_CONNECTED_USERS' | 'RADIO_GET_CONNECTED_USER' | 'RADIO_SET_USER_CHANNELS' | 'RADIO_SET_USER_DISPLAY_NAME' | 'RADIO_GET_SERVER_SUBSCRIPTION_FROM_IP' | 'RADIO_SET_SERVER_IP' | 'RADIO_SET_IN_GAME_SPEAKER_LOCATIONS' | 'PLAY_TONE';
|
|
712
|
+
export type AllAPITypesType = 'GET_SERVERS' | 'SET_SERVERS' | 'GET_VERSION' | 'SET_PENAL_CODES' | 'SET_API_ID' | 'GET_TEMPLATES' | 'NEW_RECORD' | 'SEND_DRAFT' | 'EDIT_RECORD' | 'REMOVE_RECORD' | 'LOOKUP_INT' | 'LOOKUP' | 'GET_ACCOUNT' | 'CHECK_APIID' | 'APPLY_PERMISSION_KEY' | 'SET_ACCOUNT_PERMISSIONS' | 'BAN_USER' | 'VERIFY_SECRET' | 'AUTH_STREETSIGNS' | 'SET_POSTALS' | 'SEND_PHOTO' | 'SET_CLOCK' | 'JOIN_COMMUNITY' | 'LEAVE_COMMUNITY' | 'GET_CHARACTERS' | 'NEW_CHARACTER' | 'EDIT_CHARACTER' | 'REMOVE_CHARACTER' | 'GET_IDENTIFIERS' | 'MODIFY_IDENTIFIER' | 'SET_IDENTIFIER' | 'IDENTS_TO_GROUP' | 'UNIT_PANIC' | 'UNIT_STATUS' | 'GET_BLIPS' | 'ADD_BLIP' | 'MODIFY_BLIP' | 'REMOVE_BLIP' | '911_CALL' | 'REMOVE_911' | 'GET_CALLS' | 'GET_MY_CALL' | 'GET_ACTIVE_UNITS' | 'KICK_UNIT' | 'NEW_DISPATCH' | 'ATTACH_UNIT' | 'DETACH_UNIT' | 'SET_CALL_POSTAL' | 'SET_CALL_PRIMARY' | 'ADD_CALL_NOTE' | 'CLOSE_CALL' | 'UNIT_LOCATION' | 'SET_STREETSIGN_CONFIG' | 'UPDATE_STREETSIGN' | 'GET_COM_ACCOUNT' | 'GET_DEPARTMENTS' | 'GET_SUB_VERSION' | 'GET_CURRENT_CLOCK_IN' | 'GET_CLOCKIN_TYPES' | 'GET_LATEST_ACTIVITY' | 'GET_ACCOUNTS' | 'GET_PROFILE_FIELDS' | 'CHECK_COM_APIID' | 'VERIFY_WHITELIST' | 'CLOCK_IN_OUT' | 'FULL_WHITELIST' | 'GET_ACCOUNT_RANKS' | 'SET_ACCOUNT_RANKS' | 'RSVP' | 'CHANGE_FORM_STAGE' | 'GET_FORM_TEMPLATE_SUBMISSIONS' | 'GET_FORM_LOCK_STATUS' | 'SET_FORM_LOCK_STATUS' | 'GET_CURRENT_SESSION' | 'START_SESSION' | 'STOP_SESSION' | 'CANCEL_SESSION' | 'KICK_ACCOUNT' | 'BAN_ACCOUNT' | 'LOOKUP' | 'EDIT_ACC_PROFLIE_FIELDS' | 'SET_ACCOUNT_NAME' | 'FORCE_SYNC' | 'TRIGGER_PROMOTION_FLOWS' | 'GET_PROMOTION_FLOWS' | 'GET_CUSTOM_LOG_TYPES' | 'SET_GAME_SERVERS' | 'ERLC_GET_ONLINE_PLAYERS' | 'ERLC_GET_PLAYER_QUEUE' | 'ERLC_ADD_NEW_RECORD' | 'ERLC_EXECUTE_COMMAND' | 'ERLC_TEAMS_LOCK' | 'ERLC_TEAMS_UNLOCK' | 'RADIO_GET_COMMUNITY_CHANNELS' | 'RADIO_GET_CONNECTED_USERS' | 'RADIO_GET_CONNECTED_USER' | 'RADIO_SET_USER_CHANNELS' | 'RADIO_SET_USER_DISPLAY_NAME' | 'RADIO_GET_SERVER_SUBSCRIPTION_FROM_IP' | 'RADIO_SET_SERVER_IP' | 'RADIO_SET_IN_GAME_SPEAKER_LOCATIONS' | 'PLAY_TONE';
|
|
707
713
|
|
|
708
714
|
export interface CMSServerAPIStruct {
|
|
709
715
|
id: number;
|
|
@@ -823,6 +829,13 @@ export interface CADNewEditRecordOptionTwoStruct {
|
|
|
823
829
|
record: CADRecordStruct;
|
|
824
830
|
}
|
|
825
831
|
|
|
832
|
+
export interface CADSendDraftStruct {
|
|
833
|
+
apiId?: string;
|
|
834
|
+
account?: string;
|
|
835
|
+
recordTypeId: number;
|
|
836
|
+
replaceValues: Record<string, string>;
|
|
837
|
+
}
|
|
838
|
+
|
|
826
839
|
export enum CADLookupByIntSearchTypeEnums {
|
|
827
840
|
IDENTIFIER,
|
|
828
841
|
SUPERVISOR_STATUS,
|
|
@@ -970,6 +983,7 @@ export interface CADUnitPanicStruct {
|
|
|
970
983
|
apiId?: string;
|
|
971
984
|
account?: string;
|
|
972
985
|
isPanic: boolean;
|
|
986
|
+
identIds?: number[];
|
|
973
987
|
}
|
|
974
988
|
|
|
975
989
|
export enum CADDispatchOriginEnums {
|
|
@@ -1039,6 +1053,7 @@ export interface RESTTypedAPIDataStructs {
|
|
|
1039
1053
|
SET_API_ID: [data: CADSetAPIIDStruct];
|
|
1040
1054
|
GET_TEMPLATES: [recordTypeId?: number];
|
|
1041
1055
|
NEW_RECORD: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
|
|
1056
|
+
SEND_DRAFT: [data: CADSendDraftStruct];
|
|
1042
1057
|
EDIT_RECORD: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
|
|
1043
1058
|
REMOVE_RECORD: [id: number];
|
|
1044
1059
|
LOOKUP_INT: [data: CADLookupByIntStruct];
|
|
@@ -1096,7 +1111,8 @@ export interface RESTTypedAPIDataStructs {
|
|
|
1096
1111
|
IDENTS_TO_GROUP: [data: CADIdentsToGroupStruct[]];
|
|
1097
1112
|
UNIT_PANIC: [
|
|
1098
1113
|
apiId: string | undefined,
|
|
1099
|
-
isPanic: boolean
|
|
1114
|
+
isPanic: boolean,
|
|
1115
|
+
identIds?: number[]
|
|
1100
1116
|
] | [
|
|
1101
1117
|
data: CADUnitPanicStruct
|
|
1102
1118
|
];
|
|
@@ -1406,7 +1422,7 @@ export interface RESTTypedAPIDataStructs {
|
|
|
1406
1422
|
export type PossibleRequestData =
|
|
1407
1423
|
undefined |
|
|
1408
1424
|
{
|
|
1409
|
-
data: CADPenalCodeStruct[] | CADSetAPIIDStruct | CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct | CADLookupByIntStruct | CADLookupStruct | CADModifyAccountPermsStruct | CADKickBanUserStruct | CADSetPostalStruct[] | CADModifyIdentifierStruct | CADIdentsToGroupStruct[] | CADAddBlipStruct[] | CADModifyBlipStruct[] | CADGetCallsStruct | CADGetActiveUnitsStruct | CADNewDispatchStruct | CMSTriggerPromotionFlowPayload[]
|
|
1425
|
+
data: CADPenalCodeStruct[] | CADSetAPIIDStruct | CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct | CADSendDraftStruct | CADLookupByIntStruct | CADLookupStruct | CADModifyAccountPermsStruct | CADKickBanUserStruct | CADSetPostalStruct[] | CADModifyIdentifierStruct | CADIdentsToGroupStruct[] | CADAddBlipStruct[] | CADModifyBlipStruct[] | CADGetCallsStruct | CADGetActiveUnitsStruct | CADNewDispatchStruct | CMSTriggerPromotionFlowPayload[]
|
|
1410
1426
|
} |
|
|
1411
1427
|
{
|
|
1412
1428
|
servers: CADServerAPIStruct[];
|
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
CADSetAPIIDStruct,
|
|
8
8
|
CADNewEditRecordOptionOneStruct,
|
|
9
9
|
CADNewEditRecordOptionTwoStruct,
|
|
10
|
+
CADSendDraftStruct,
|
|
10
11
|
CADLookupByIntStruct,
|
|
11
12
|
CADLookupStruct,
|
|
12
13
|
CADModifyAccountPermsStruct,
|
|
@@ -224,6 +225,25 @@ export class CADManager extends BaseManager {
|
|
|
224
225
|
return this.executeCadRequest('NEW_RECORD', data);
|
|
225
226
|
}
|
|
226
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Sends a record draft with populated fields.
|
|
230
|
+
*/
|
|
231
|
+
public async sendDraft(data: CADSendDraftStruct): Promise<globalTypes.CADStandardResponse> {
|
|
232
|
+
if (!data || typeof data !== 'object') {
|
|
233
|
+
throw new Error('data is required when sending a draft.');
|
|
234
|
+
}
|
|
235
|
+
if (!data.apiId && !data.account) {
|
|
236
|
+
throw new Error('apiId or account is required when sending a draft.');
|
|
237
|
+
}
|
|
238
|
+
if (!Number.isInteger(data.recordTypeId)) {
|
|
239
|
+
throw new Error('recordTypeId must be an integer when sending a draft.');
|
|
240
|
+
}
|
|
241
|
+
if (!data.replaceValues || typeof data.replaceValues !== 'object') {
|
|
242
|
+
throw new Error('replaceValues is required when sending a draft.');
|
|
243
|
+
}
|
|
244
|
+
return this.executeCadRequest('SEND_DRAFT', data);
|
|
245
|
+
}
|
|
246
|
+
|
|
227
247
|
/**
|
|
228
248
|
* Updates an existing record entry.
|
|
229
249
|
*/
|
|
@@ -437,23 +457,32 @@ export class CADManager extends BaseManager {
|
|
|
437
457
|
/**
|
|
438
458
|
* Toggles panic state for a unit.
|
|
439
459
|
*/
|
|
440
|
-
public async setUnitPanic(apiId: string | undefined, isPanic: boolean): Promise<globalTypes.CADStandardResponse>;
|
|
460
|
+
public async setUnitPanic(apiId: string | undefined, isPanic: boolean, identIds?: number[]): Promise<globalTypes.CADStandardResponse>;
|
|
441
461
|
public async setUnitPanic(params: CADUnitPanicStruct): Promise<globalTypes.CADStandardResponse>;
|
|
442
|
-
public async setUnitPanic(apiIdOrParams: string | CADUnitPanicStruct | undefined, isPanic?: boolean): Promise<globalTypes.CADStandardResponse> {
|
|
462
|
+
public async setUnitPanic(apiIdOrParams: string | CADUnitPanicStruct | undefined, isPanic?: boolean, identIds?: number[]): Promise<globalTypes.CADStandardResponse> {
|
|
443
463
|
let payload: CADUnitPanicStruct;
|
|
444
464
|
if (apiIdOrParams && typeof apiIdOrParams === 'object') {
|
|
445
465
|
payload = { ...apiIdOrParams };
|
|
446
466
|
} else {
|
|
447
|
-
payload = { apiId: apiIdOrParams as string | undefined, isPanic: isPanic as boolean };
|
|
467
|
+
payload = { apiId: apiIdOrParams as string | undefined, isPanic: isPanic as boolean, identIds };
|
|
448
468
|
}
|
|
449
|
-
const { apiId, account, isPanic: resolvedPanic } = payload;
|
|
469
|
+
const { apiId, account, isPanic: resolvedPanic, identIds: resolvedIdentIds } = payload;
|
|
450
470
|
if (resolvedPanic === undefined) {
|
|
451
471
|
throw new Error('isPanic is required when setting unit panic.');
|
|
452
472
|
}
|
|
453
|
-
if (
|
|
454
|
-
throw new Error('
|
|
473
|
+
if (resolvedIdentIds !== undefined && (!Array.isArray(resolvedIdentIds) || resolvedIdentIds.some((id) => !Number.isInteger(id)))) {
|
|
474
|
+
throw new Error('identIds must be an array of integers when setting unit panic.');
|
|
475
|
+
}
|
|
476
|
+
const hasIdentIds = Array.isArray(resolvedIdentIds) && resolvedIdentIds.length > 0;
|
|
477
|
+
if (!apiId && !account && !hasIdentIds) {
|
|
478
|
+
throw new Error('Either apiId, account, or identIds is required when setting unit panic.');
|
|
455
479
|
}
|
|
456
|
-
return this.executeCadRequest('UNIT_PANIC', {
|
|
480
|
+
return this.executeCadRequest('UNIT_PANIC', {
|
|
481
|
+
apiId,
|
|
482
|
+
account,
|
|
483
|
+
isPanic: resolvedPanic,
|
|
484
|
+
identIds: hasIdentIds ? resolvedIdentIds : undefined
|
|
485
|
+
});
|
|
457
486
|
}
|
|
458
487
|
|
|
459
488
|
/**
|