@sonoransoftware/sonoran.js 1.0.35 → 1.0.37
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/LICENSE +24 -0
- package/dist/constants.d.ts +56 -0
- package/dist/index.d.ts +1 -1
- package/dist/libs/rest/src/lib/REST.js +17 -0
- package/dist/libs/rest/src/lib/RequestManager.js +37 -0
- package/dist/libs/rest/src/lib/utils/constants.d.ts +13 -4
- package/dist/libs/rest/src/lib/utils/constants.js +18 -0
- package/dist/managers/CADActiveUnitsManager.d.ts +3 -0
- package/dist/managers/CADActiveUnitsManager.js +16 -6
- package/dist/managers/CADManager.d.ts +195 -0
- package/dist/managers/CADManager.js +423 -4
- package/dist/managers/CADServerManager.d.ts +11 -0
- package/dist/managers/CADServerManager.js +56 -13
- package/dist/managers/CMSManager.d.ts +24 -0
- package/dist/managers/CMSManager.js +79 -3
- package/dist/managers/CMSServerManager.d.ts +5 -0
- package/dist/managers/CMSServerManager.js +33 -24
- package/dist/managers/RadioManager.d.ts +7 -0
- package/dist/managers/RadioManager.js +23 -0
- package/package.json +1 -1
- package/readme.md +158 -32
- package/src/constants.ts +66 -0
- package/src/index.ts +7 -0
- package/src/libs/rest/src/lib/REST.ts +17 -0
- package/src/libs/rest/src/lib/RequestManager.ts +37 -0
- package/src/libs/rest/src/lib/utils/constants.ts +31 -4
- package/src/managers/CADActiveUnitsManager.ts +19 -6
- package/src/managers/CADManager.ts +488 -3
- package/src/managers/CADServerManager.ts +59 -15
- package/src/managers/CMSManager.ts +75 -2
- package/src/managers/CMSServerManager.ts +33 -22
- package/src/managers/RadioManager.ts +21 -0
|
@@ -166,6 +166,14 @@ export class RequestManager extends EventEmitter {
|
|
|
166
166
|
apiData.data.data = clonedData;
|
|
167
167
|
break;
|
|
168
168
|
}
|
|
169
|
+
case 'TRIGGER_PROMOTION_FLOWS': {
|
|
170
|
+
apiData.data.data = clonedData;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
case 'GET_PROMOTION_FLOWS': {
|
|
174
|
+
apiData.data.data = [];
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
169
177
|
case 'SET_PENAL_CODES': {
|
|
170
178
|
apiData.data.data = [clonedData[0]];
|
|
171
179
|
break;
|
|
@@ -449,6 +457,35 @@ export class RequestManager extends EventEmitter {
|
|
|
449
457
|
path = apiType.path;
|
|
450
458
|
break;
|
|
451
459
|
}
|
|
460
|
+
case 'PLAY_TONE': {
|
|
461
|
+
const auth = ensureAuth();
|
|
462
|
+
const roomIdRaw = payload?.roomId;
|
|
463
|
+
if (roomIdRaw === undefined || roomIdRaw === null) {
|
|
464
|
+
throw new Error('roomId is required for PLAY_TONE requests.');
|
|
465
|
+
}
|
|
466
|
+
const roomIdNumber = typeof roomIdRaw === 'number' ? roomIdRaw : Number(roomIdRaw);
|
|
467
|
+
if (Number.isNaN(roomIdNumber)) {
|
|
468
|
+
throw new Error('roomId must be a number for PLAY_TONE requests.');
|
|
469
|
+
}
|
|
470
|
+
const tones = payload?.tones;
|
|
471
|
+
if (!Array.isArray(tones) || tones.length === 0) {
|
|
472
|
+
throw new Error('tones array is required for PLAY_TONE requests.');
|
|
473
|
+
}
|
|
474
|
+
const playTo = payload?.playTo;
|
|
475
|
+
if (!Array.isArray(playTo) || playTo.length === 0) {
|
|
476
|
+
throw new Error('playTo array is required for PLAY_TONE requests.');
|
|
477
|
+
}
|
|
478
|
+
method = 'POST';
|
|
479
|
+
body = {
|
|
480
|
+
id: auth.id,
|
|
481
|
+
key: auth.key,
|
|
482
|
+
roomId: roomIdNumber,
|
|
483
|
+
tones,
|
|
484
|
+
playTo
|
|
485
|
+
};
|
|
486
|
+
path = apiType.path;
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
452
489
|
default: {
|
|
453
490
|
throw new Error(`Unsupported radio API type received: ${apiType.type}`);
|
|
454
491
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { productEnums, RadioSetUserChannelsOptions, RadioSpeakerLocation, CMSProfileFieldUpdate, CMSSetGameServerStruct } from '../../../../../constants';
|
|
1
|
+
import { productEnums, RadioSetUserChannelsOptions, RadioSpeakerLocation, RadioTonePlayTarget, CMSProfileFieldUpdate, CMSSetGameServerStruct, CMSTriggerPromotionFlowPayload } from '../../../../../constants';
|
|
2
2
|
import type { RESTOptions } from '../REST';
|
|
3
3
|
|
|
4
4
|
export const DefaultUserAgent = 'Sonoran.js NPM Module';
|
|
@@ -455,6 +455,18 @@ export const GeneralCMSAPITypes: APITypeData[] = [
|
|
|
455
455
|
path: 'general/force_sync',
|
|
456
456
|
method: 'POST',
|
|
457
457
|
minVersion: 0
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
type: 'TRIGGER_PROMOTION_FLOWS',
|
|
461
|
+
path: 'general/trigger_promotion_flows',
|
|
462
|
+
method: 'POST',
|
|
463
|
+
minVersion: 0
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
type: 'GET_PROMOTION_FLOWS',
|
|
467
|
+
path: 'general/get_promotion_flows',
|
|
468
|
+
method: 'POST',
|
|
469
|
+
minVersion: 0
|
|
458
470
|
}
|
|
459
471
|
];
|
|
460
472
|
|
|
@@ -587,6 +599,12 @@ export const RadioAPITypes: APITypeData[] = [
|
|
|
587
599
|
path: 'radio/set-server-speakers',
|
|
588
600
|
method: 'POST',
|
|
589
601
|
minVersion: 0
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
type: 'PLAY_TONE',
|
|
605
|
+
path: 'api/play-tone',
|
|
606
|
+
method: 'POST',
|
|
607
|
+
minVersion: 0
|
|
590
608
|
}
|
|
591
609
|
];
|
|
592
610
|
|
|
@@ -601,7 +619,7 @@ function formatForAll(array: APITypeData[], product: productEnums): AllAPITypeDa
|
|
|
601
619
|
|
|
602
620
|
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) ];
|
|
603
621
|
|
|
604
|
-
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' | 'UNIT_PANIC' | 'UNIT_STATUS' | 'GET_BLIPS' | 'ADD_BLIP' | 'MODIFY_BLIP' | 'REMOVE_BLIP' | '911_CALL' | 'REMOVE_911' | 'GET_CALLS' | '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_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' | 'KICK_ACCOUNT' | 'BAN_ACCOUNT' | 'LOOKUP' | 'EDIT_ACC_PROFLIE_FIELDS' | 'SET_ACCOUNT_NAME' | 'FORCE_SYNC' | 'SET_GAME_SERVERS' | 'ERLC_GET_ONLINE_PLAYERS' | 'ERLC_GET_PLAYER_QUEUE' | 'ERLC_ADD_NEW_RECORD' | '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';
|
|
622
|
+
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' | 'UNIT_PANIC' | 'UNIT_STATUS' | 'GET_BLIPS' | 'ADD_BLIP' | 'MODIFY_BLIP' | 'REMOVE_BLIP' | '911_CALL' | 'REMOVE_911' | 'GET_CALLS' | '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_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' | 'KICK_ACCOUNT' | 'BAN_ACCOUNT' | 'LOOKUP' | 'EDIT_ACC_PROFLIE_FIELDS' | 'SET_ACCOUNT_NAME' | 'FORCE_SYNC' | 'TRIGGER_PROMOTION_FLOWS' | 'GET_PROMOTION_FLOWS' | 'SET_GAME_SERVERS' | 'ERLC_GET_ONLINE_PLAYERS' | 'ERLC_GET_PLAYER_QUEUE' | 'ERLC_ADD_NEW_RECORD' | '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';
|
|
605
623
|
|
|
606
624
|
export interface CMSServerAPIStruct {
|
|
607
625
|
id: number;
|
|
@@ -984,7 +1002,7 @@ export interface RESTTypedAPIDataStructs {
|
|
|
984
1002
|
serverId: number,
|
|
985
1003
|
callId: number
|
|
986
1004
|
];
|
|
987
|
-
'
|
|
1005
|
+
'911_CALL': [
|
|
988
1006
|
serverId: number,
|
|
989
1007
|
isEmergency: boolean,
|
|
990
1008
|
caller: string,
|
|
@@ -1074,6 +1092,10 @@ export interface RESTTypedAPIDataStructs {
|
|
|
1074
1092
|
discordId: string | undefined,
|
|
1075
1093
|
uniqueId: string | undefined,
|
|
1076
1094
|
],
|
|
1095
|
+
TRIGGER_PROMOTION_FLOWS: [
|
|
1096
|
+
data: CMSTriggerPromotionFlowPayload[]
|
|
1097
|
+
];
|
|
1098
|
+
GET_PROMOTION_FLOWS: [];
|
|
1077
1099
|
// CMS - Servers
|
|
1078
1100
|
GET_GAME_SERVERS: [];
|
|
1079
1101
|
SET_GAME_SERVERS: [servers: CMSSetGameServerStruct[]];
|
|
@@ -1171,12 +1193,17 @@ export interface RESTTypedAPIDataStructs {
|
|
|
1171
1193
|
locations: RadioSpeakerLocation[],
|
|
1172
1194
|
token?: string
|
|
1173
1195
|
];
|
|
1196
|
+
PLAY_TONE: [
|
|
1197
|
+
roomId: number,
|
|
1198
|
+
tones: number[],
|
|
1199
|
+
playTo: RadioTonePlayTarget[]
|
|
1200
|
+
];
|
|
1174
1201
|
}
|
|
1175
1202
|
|
|
1176
1203
|
export type PossibleRequestData =
|
|
1177
1204
|
undefined |
|
|
1178
1205
|
{
|
|
1179
|
-
data: CADPenalCodeStruct[] | CADSetAPIIDStruct | CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct | CADLookupByIntStruct | CADLookupStruct | CADModifyAccountPermsStruct | CADKickBanUserStruct | CADSetPostalStruct[] | CADModifyIdentifierStruct | CADAddBlipStruct[] | CADModifyBlipStruct[] | CADGetCallsStruct | CADGetActiveUnitsStruct | CADNewDispatchStruct
|
|
1206
|
+
data: CADPenalCodeStruct[] | CADSetAPIIDStruct | CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct | CADLookupByIntStruct | CADLookupStruct | CADModifyAccountPermsStruct | CADKickBanUserStruct | CADSetPostalStruct[] | CADModifyIdentifierStruct | CADAddBlipStruct[] | CADModifyBlipStruct[] | CADGetCallsStruct | CADGetActiveUnitsStruct | CADNewDispatchStruct | CMSTriggerPromotionFlowPayload[]
|
|
1180
1207
|
} |
|
|
1181
1208
|
{
|
|
1182
1209
|
servers: CADServerAPIStruct[];
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
// import { CADActiveUnitFetchOptions } from '../constants';
|
|
4
4
|
import { Instance } from '../instance/Instance';
|
|
5
|
+
import * as globalTypes from '../constants';
|
|
6
|
+
import type { CADGetActiveUnitsStruct } from '../libs/rest/src';
|
|
5
7
|
import { CADActiveUnit, CADActiveUnitResolvable, CADActiveUnitStruct } from '../structures/CADActiveUnit';
|
|
6
8
|
import { CacheManager } from './CacheManager';
|
|
7
9
|
|
|
@@ -27,6 +29,20 @@ export class CADActiveUnitsManager extends CacheManager<number, CADActiveUnit, C
|
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
public async getActiveUnits(options: Partial<CADGetActiveUnitsStruct> = {}): Promise<globalTypes.CADStandardResponse> {
|
|
33
|
+
if (!this.instance.cad) {
|
|
34
|
+
throw new Error('CAD manager is not initialized.');
|
|
35
|
+
}
|
|
36
|
+
const payload: CADGetActiveUnitsStruct = {
|
|
37
|
+
serverId: options.serverId ?? this.serverId,
|
|
38
|
+
includeOffline: options.includeOffline ?? false,
|
|
39
|
+
onlyUnits: options.onlyUnits,
|
|
40
|
+
limit: options.limit,
|
|
41
|
+
offset: options.offset
|
|
42
|
+
};
|
|
43
|
+
return this.instance.cad.getActiveUnits(payload);
|
|
44
|
+
}
|
|
45
|
+
|
|
30
46
|
async _fetchSingle({
|
|
31
47
|
unit,
|
|
32
48
|
includeOffline = false,
|
|
@@ -41,10 +57,7 @@ export class CADActiveUnitsManager extends CacheManager<number, CADActiveUnit, C
|
|
|
41
57
|
if (existing) return existing;
|
|
42
58
|
}
|
|
43
59
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
includeOffline
|
|
47
|
-
});
|
|
48
|
-
console.log(data);
|
|
60
|
+
const result = await this.getActiveUnits({ includeOffline });
|
|
61
|
+
console.log(result);
|
|
49
62
|
}
|
|
50
|
-
}
|
|
63
|
+
}
|