@sonoransoftware/sonoran.js 1.0.34 → 1.0.36
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/.github/workflows/auto-pr-on-branch-push.yml +89 -0
- package/.github/workflows/codex_instructions.md +24 -0
- package/.github/workflows/push-pr-nudge-codex.yml +50 -0
- package/dist/constants.d.ts +242 -1
- package/dist/constants.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/instance/Instance.d.ts +6 -0
- package/dist/instance/Instance.js +27 -0
- package/dist/instance/instance.types.d.ts +3 -0
- package/dist/libs/rest/src/lib/REST.d.ts +2 -1
- package/dist/libs/rest/src/lib/REST.js +118 -0
- package/dist/libs/rest/src/lib/RequestManager.d.ts +2 -0
- package/dist/libs/rest/src/lib/RequestManager.js +209 -0
- package/dist/libs/rest/src/lib/errors/RateLimitError.js +19 -1
- package/dist/libs/rest/src/lib/utils/constants.d.ts +108 -24
- package/dist/libs/rest/src/lib/utils/constants.js +118 -2
- package/dist/managers/CADActiveUnitsManager.d.ts +3 -0
- package/dist/managers/CADActiveUnitsManager.js +16 -6
- package/dist/managers/CADManager.d.ts +223 -0
- package/dist/managers/CADManager.js +513 -4
- package/dist/managers/CADServerManager.d.ts +11 -0
- package/dist/managers/CADServerManager.js +56 -13
- package/dist/managers/CMSManager.d.ts +78 -0
- package/dist/managers/CMSManager.js +213 -3
- package/dist/managers/CMSServerManager.d.ts +8 -0
- package/dist/managers/CMSServerManager.js +61 -18
- package/dist/managers/RadioManager.d.ts +55 -0
- package/dist/managers/RadioManager.js +224 -0
- package/package.json +1 -1
- package/readme.md +294 -12
- package/src/constants.ts +281 -1
- package/src/index.ts +42 -1
- package/src/instance/Instance.ts +30 -1
- package/src/instance/instance.types.ts +4 -1
- package/src/libs/rest/src/lib/REST.ts +117 -1
- package/src/libs/rest/src/lib/RequestManager.ts +229 -10
- package/src/libs/rest/src/lib/errors/RateLimitError.ts +20 -2
- package/src/libs/rest/src/lib/utils/constants.ts +223 -26
- package/src/managers/CADActiveUnitsManager.ts +19 -6
- package/src/managers/CADManager.ts +574 -4
- package/src/managers/CADServerManager.ts +59 -15
- package/src/managers/CMSManager.ts +196 -2
- package/src/managers/CMSServerManager.ts +65 -21
- package/src/managers/RadioManager.ts +187 -0
|
@@ -15,6 +15,10 @@ export declare class CMSManager extends BaseManager {
|
|
|
15
15
|
servers: CMSServerManager | undefined;
|
|
16
16
|
constructor(instance: Instance);
|
|
17
17
|
protected buildManager(instance: Instance): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves the community's CMS subscription version.
|
|
20
|
+
*/
|
|
21
|
+
getSubscriptionVersion(): Promise<number>;
|
|
18
22
|
/**
|
|
19
23
|
* Verifies the whitelist of a given account with the given parameters to search of said account.
|
|
20
24
|
* @param {Object | string} data The object or [accId | apiId as a string] that contains data to get a community account to verify if it has whitelist to the specified server. *If given as a string it will default to the set or default cms server id (1).
|
|
@@ -170,12 +174,86 @@ export declare class CMSManager extends BaseManager {
|
|
|
170
174
|
discordId?: string;
|
|
171
175
|
uniqueId?: string;
|
|
172
176
|
}): Promise<globalTypes.CMSForceSyncPromiseResult>;
|
|
177
|
+
/**
|
|
178
|
+
* Triggers promotion flows for the specified users.
|
|
179
|
+
*/
|
|
180
|
+
triggerPromotionFlows(flows: globalTypes.CMSTriggerPromotionFlowPayload[]): Promise<globalTypes.CMSTriggerPromotionFlowsPromiseResult>;
|
|
181
|
+
/**
|
|
182
|
+
* Retrieves the available promotion flows configured in CMS.
|
|
183
|
+
*/
|
|
184
|
+
getPromotionFlows(): Promise<globalTypes.CMSGetPromotionFlowsPromiseResult>;
|
|
173
185
|
/**
|
|
174
186
|
* Gets a list of online ERLC players for the given roblox join code.
|
|
175
187
|
* @param {string} robloxJoinCode The roblox join code to get the online players for.
|
|
176
188
|
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed and the list of online players if successful.
|
|
177
189
|
*/
|
|
178
190
|
erlcGetOnlinePlayers(robloxJoinCode: string): Promise<globalTypes.CMSERLCGetOnlinePlayersPromiseResult>;
|
|
191
|
+
/**
|
|
192
|
+
* Toggles RSVP for the provided event and account.
|
|
193
|
+
*/
|
|
194
|
+
rsvp(eventId: string, params?: {
|
|
195
|
+
apiId?: string;
|
|
196
|
+
username?: string;
|
|
197
|
+
accId?: string;
|
|
198
|
+
discord?: string;
|
|
199
|
+
uniqueId?: string;
|
|
200
|
+
}): Promise<globalTypes.CMSRsvpPromiseResult>;
|
|
201
|
+
/**
|
|
202
|
+
* Updates the stage of a form for the specified account.
|
|
203
|
+
*/
|
|
204
|
+
changeFormStage(params: {
|
|
205
|
+
accId?: string;
|
|
206
|
+
formId: number;
|
|
207
|
+
newStageId: string;
|
|
208
|
+
apiId?: string;
|
|
209
|
+
username?: string;
|
|
210
|
+
discord?: string;
|
|
211
|
+
uniqueId: number;
|
|
212
|
+
}): Promise<globalTypes.CMSChangeFormStagePromiseResult>;
|
|
213
|
+
/**
|
|
214
|
+
* Retrieves submissions for a specific form template.
|
|
215
|
+
*/
|
|
216
|
+
getFormSubmissions<T = unknown>(templateId: number, options?: {
|
|
217
|
+
skip?: number;
|
|
218
|
+
take?: number;
|
|
219
|
+
}): Promise<globalTypes.CMSGetFormSubmissionsPromiseResult<T>>;
|
|
220
|
+
/**
|
|
221
|
+
* Updates profile fields for the specified account.
|
|
222
|
+
*/
|
|
223
|
+
editAccountProfileFields(params: {
|
|
224
|
+
apiId?: string;
|
|
225
|
+
username?: string;
|
|
226
|
+
accId?: string;
|
|
227
|
+
discord?: string;
|
|
228
|
+
uniqueId?: string;
|
|
229
|
+
profileFields: globalTypes.CMSProfileFieldUpdate[];
|
|
230
|
+
}): Promise<globalTypes.CMSEditAccountProfileFieldsPromiseResult>;
|
|
231
|
+
/**
|
|
232
|
+
* Gets the current clock in entry for a community member.
|
|
233
|
+
* @param {Object} params Identification parameters for the account.
|
|
234
|
+
*/
|
|
235
|
+
getCurrentClockIn(params: {
|
|
236
|
+
accId?: string;
|
|
237
|
+
apiId?: string;
|
|
238
|
+
username?: string;
|
|
239
|
+
discord?: string;
|
|
240
|
+
uniqueId?: string;
|
|
241
|
+
}): Promise<globalTypes.CMSGetCurrentClockInPromiseResult>;
|
|
242
|
+
/**
|
|
243
|
+
* Retrieves community accounts using optional pagination and status filters.
|
|
244
|
+
*/
|
|
245
|
+
getAccounts(options?: {
|
|
246
|
+
skip?: number;
|
|
247
|
+
take?: number;
|
|
248
|
+
sysStatus?: boolean;
|
|
249
|
+
comStatus?: boolean;
|
|
250
|
+
banned?: boolean;
|
|
251
|
+
archived?: boolean;
|
|
252
|
+
}): Promise<globalTypes.CMSGetAccountsPromiseResult>;
|
|
253
|
+
/**
|
|
254
|
+
* Retrieves configured profile fields for the community.
|
|
255
|
+
*/
|
|
256
|
+
getProfileFields(): Promise<globalTypes.CMSGetProfileFieldsPromiseResult>;
|
|
179
257
|
/**
|
|
180
258
|
* Gets the current ERLC player queue count for the provided roblox join code.
|
|
181
259
|
* @param {string} robloxJoinCode The roblox join code to get the player queue size for.
|
|
@@ -41,11 +41,9 @@ class CMSManager extends BaseManager_1.BaseManager {
|
|
|
41
41
|
this.buildManager(instance);
|
|
42
42
|
}
|
|
43
43
|
async buildManager(instance) {
|
|
44
|
-
var _a;
|
|
45
44
|
const mutableThis = this;
|
|
46
45
|
try {
|
|
47
|
-
const
|
|
48
|
-
const version = Number.parseInt(versionResp.replace(/(^\d+)(.+$)/i, '$1'));
|
|
46
|
+
const version = await this.getSubscriptionVersion();
|
|
49
47
|
if (version >= globalTypes.CMSSubscriptionVersionEnum.STANDARD) {
|
|
50
48
|
this.servers = new CMSServerManager_1.CMSServerManager(instance, this);
|
|
51
49
|
}
|
|
@@ -60,6 +58,15 @@ class CMSManager extends BaseManager_1.BaseManager {
|
|
|
60
58
|
throw err;
|
|
61
59
|
}
|
|
62
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves the community's CMS subscription version.
|
|
63
|
+
*/
|
|
64
|
+
async getSubscriptionVersion() {
|
|
65
|
+
var _a;
|
|
66
|
+
const versionResp = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('GET_SUB_VERSION'));
|
|
67
|
+
const versionString = String(versionResp);
|
|
68
|
+
return Number.parseInt(versionString.replace(/(^\d+)(.+$)/i, '$1'), 10);
|
|
69
|
+
}
|
|
63
70
|
/**
|
|
64
71
|
* Verifies the whitelist of a given account with the given parameters to search of said account.
|
|
65
72
|
* @param {Object | string} data The object or [accId | apiId as a string] that contains data to get a community account to verify if it has whitelist to the specified server. *If given as a string it will default to the set or default cms server id (1).
|
|
@@ -373,6 +380,49 @@ class CMSManager extends BaseManager_1.BaseManager {
|
|
|
373
380
|
}
|
|
374
381
|
});
|
|
375
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* Triggers promotion flows for the specified users.
|
|
385
|
+
*/
|
|
386
|
+
async triggerPromotionFlows(flows) {
|
|
387
|
+
if (!Array.isArray(flows) || flows.length === 0) {
|
|
388
|
+
throw new Error('flows array must include at least one promotion flow payload.');
|
|
389
|
+
}
|
|
390
|
+
return new Promise(async (resolve, reject) => {
|
|
391
|
+
var _a;
|
|
392
|
+
try {
|
|
393
|
+
const response = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('TRIGGER_PROMOTION_FLOWS', flows));
|
|
394
|
+
resolve({ success: true, data: response });
|
|
395
|
+
}
|
|
396
|
+
catch (err) {
|
|
397
|
+
if (err instanceof src_1.APIError) {
|
|
398
|
+
resolve({ success: false, reason: err.response });
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
reject(err);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Retrieves the available promotion flows configured in CMS.
|
|
408
|
+
*/
|
|
409
|
+
async getPromotionFlows() {
|
|
410
|
+
return new Promise(async (resolve, reject) => {
|
|
411
|
+
var _a;
|
|
412
|
+
try {
|
|
413
|
+
const response = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('GET_PROMOTION_FLOWS'));
|
|
414
|
+
resolve({ success: true, data: response });
|
|
415
|
+
}
|
|
416
|
+
catch (err) {
|
|
417
|
+
if (err instanceof src_1.APIError) {
|
|
418
|
+
resolve({ success: false, reason: err.response });
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
reject(err);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
}
|
|
376
426
|
/**
|
|
377
427
|
* Gets a list of online ERLC players for the given roblox join code.
|
|
378
428
|
* @param {string} robloxJoinCode The roblox join code to get the online players for.
|
|
@@ -395,6 +445,166 @@ class CMSManager extends BaseManager_1.BaseManager {
|
|
|
395
445
|
}
|
|
396
446
|
});
|
|
397
447
|
}
|
|
448
|
+
/**
|
|
449
|
+
* Toggles RSVP for the provided event and account.
|
|
450
|
+
*/
|
|
451
|
+
async rsvp(eventId, params = {}) {
|
|
452
|
+
return new Promise(async (resolve, reject) => {
|
|
453
|
+
var _a;
|
|
454
|
+
try {
|
|
455
|
+
const response = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('RSVP', eventId, params.apiId, params.accId, params.discord, params.uniqueId));
|
|
456
|
+
if (typeof response === 'string') {
|
|
457
|
+
resolve({ success: true, status: response });
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
460
|
+
resolve({ success: true, data: response });
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
catch (err) {
|
|
464
|
+
if (err instanceof src_1.APIError) {
|
|
465
|
+
resolve({ success: false, reason: err.response });
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
reject(err);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Updates the stage of a form for the specified account.
|
|
475
|
+
*/
|
|
476
|
+
async changeFormStage(params) {
|
|
477
|
+
if (!params.formId || !params.newStageId) {
|
|
478
|
+
throw new Error('formId and newStageId are required to change a form stage.');
|
|
479
|
+
}
|
|
480
|
+
if (params.uniqueId === undefined || Number.isNaN(Number(params.uniqueId))) {
|
|
481
|
+
throw new Error('uniqueId is required to change a form stage.');
|
|
482
|
+
}
|
|
483
|
+
return new Promise(async (resolve, reject) => {
|
|
484
|
+
var _a;
|
|
485
|
+
try {
|
|
486
|
+
const response = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('CHANGE_FORM_STAGE', params.accId, params.formId, params.newStageId, params.apiId, params.username, params.discord, params.uniqueId));
|
|
487
|
+
resolve({ success: true, data: response });
|
|
488
|
+
}
|
|
489
|
+
catch (err) {
|
|
490
|
+
if (err instanceof src_1.APIError) {
|
|
491
|
+
resolve({ success: false, reason: err.response });
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
reject(err);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Retrieves submissions for a specific form template.
|
|
501
|
+
*/
|
|
502
|
+
async getFormSubmissions(templateId, options = {}) {
|
|
503
|
+
return new Promise(async (resolve, reject) => {
|
|
504
|
+
var _a;
|
|
505
|
+
try {
|
|
506
|
+
const response = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('GET_FORM_TEMPLATE_SUBMISSIONS', templateId, options.skip, options.take));
|
|
507
|
+
resolve({ success: true, data: response });
|
|
508
|
+
}
|
|
509
|
+
catch (err) {
|
|
510
|
+
if (err instanceof src_1.APIError) {
|
|
511
|
+
resolve({ success: false, reason: err.response });
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
reject(err);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Updates profile fields for the specified account.
|
|
521
|
+
*/
|
|
522
|
+
async editAccountProfileFields(params) {
|
|
523
|
+
if (!params.profileFields || params.profileFields.length === 0) {
|
|
524
|
+
throw new Error('profileFields array must include at least one value.');
|
|
525
|
+
}
|
|
526
|
+
return new Promise(async (resolve, reject) => {
|
|
527
|
+
var _a;
|
|
528
|
+
try {
|
|
529
|
+
const response = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('EDIT_ACC_PROFLIE_FIELDS', params.apiId, params.username, params.accId, params.discord, params.uniqueId, params.profileFields));
|
|
530
|
+
resolve({ success: true, data: response });
|
|
531
|
+
}
|
|
532
|
+
catch (err) {
|
|
533
|
+
if (err instanceof src_1.APIError) {
|
|
534
|
+
resolve({ success: false, reason: err.response });
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
reject(err);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Gets the current clock in entry for a community member.
|
|
544
|
+
* @param {Object} params Identification parameters for the account.
|
|
545
|
+
*/
|
|
546
|
+
async getCurrentClockIn(params) {
|
|
547
|
+
return new Promise(async (resolve, reject) => {
|
|
548
|
+
var _a;
|
|
549
|
+
try {
|
|
550
|
+
const response = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('GET_CURRENT_CLOCK_IN', params.apiId, params.username, params.accId, params.discord, params.uniqueId));
|
|
551
|
+
if (typeof response === 'string') {
|
|
552
|
+
resolve({ success: true, reason: response, data: null });
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
resolve({ success: true, data: response });
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
catch (err) {
|
|
559
|
+
if (err instanceof src_1.APIError) {
|
|
560
|
+
resolve({ success: false, reason: err.response });
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
reject(err);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Retrieves community accounts using optional pagination and status filters.
|
|
570
|
+
*/
|
|
571
|
+
async getAccounts(options = {}) {
|
|
572
|
+
return new Promise(async (resolve, reject) => {
|
|
573
|
+
var _a;
|
|
574
|
+
try {
|
|
575
|
+
const response = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('GET_ACCOUNTS', options));
|
|
576
|
+
resolve({ success: true, data: response });
|
|
577
|
+
}
|
|
578
|
+
catch (err) {
|
|
579
|
+
if (err instanceof src_1.APIError) {
|
|
580
|
+
resolve({ success: false, reason: err.response });
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
reject(err);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Retrieves configured profile fields for the community.
|
|
590
|
+
*/
|
|
591
|
+
async getProfileFields() {
|
|
592
|
+
return new Promise(async (resolve, reject) => {
|
|
593
|
+
var _a;
|
|
594
|
+
try {
|
|
595
|
+
const response = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('GET_PROFILE_FIELDS'));
|
|
596
|
+
resolve({ success: true, data: response });
|
|
597
|
+
}
|
|
598
|
+
catch (err) {
|
|
599
|
+
if (err instanceof src_1.APIError) {
|
|
600
|
+
resolve({ success: false, reason: err.response });
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
reject(err);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
}
|
|
398
608
|
/**
|
|
399
609
|
* Gets the current ERLC player queue count for the provided roblox join code.
|
|
400
610
|
* @param {string} robloxJoinCode The roblox join code to get the player queue size for.
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { Instance } from '../instance/Instance';
|
|
2
2
|
import { CMSServerAPIStruct } from '../libs/rest/src';
|
|
3
|
+
import * as globalTypes from '../constants';
|
|
3
4
|
import { CMSServer } from '../structures/CMSServer';
|
|
4
5
|
import { CacheManager } from './CacheManager';
|
|
5
6
|
import { CMSManager } from './CMSManager';
|
|
6
7
|
export declare class CMSServerManager extends CacheManager<number, CMSServer, CMSServerAPIStruct> {
|
|
8
|
+
private readonly manager;
|
|
7
9
|
constructor(instance: Instance, manager: CMSManager);
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves the CMS game servers belonging to the community.
|
|
12
|
+
*/
|
|
13
|
+
getGameServers(): Promise<CMSServerAPIStruct[]>;
|
|
14
|
+
private initialize;
|
|
15
|
+
setGameServers(servers: globalTypes.CMSSetGameServerStruct[]): Promise<globalTypes.CMSSetGameServersPromiseResult>;
|
|
8
16
|
}
|
|
@@ -1,34 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CMSServerManager = void 0;
|
|
4
|
+
const src_1 = require("../libs/rest/src");
|
|
4
5
|
const CMSServer_1 = require("../structures/CMSServer");
|
|
5
6
|
const CacheManager_1 = require("./CacheManager");
|
|
6
7
|
class CMSServerManager extends CacheManager_1.CacheManager {
|
|
7
8
|
constructor(instance, manager) {
|
|
8
9
|
super(instance, CMSServer_1.CMSServer, []);
|
|
9
|
-
|
|
10
|
+
this.manager = manager;
|
|
11
|
+
void this.initialize();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves the CMS game servers belonging to the community.
|
|
15
|
+
*/
|
|
16
|
+
async getGameServers() {
|
|
17
|
+
var _a;
|
|
18
|
+
const serversRes = await ((_a = this.manager.rest) === null || _a === void 0 ? void 0 : _a.request('GET_GAME_SERVERS'));
|
|
19
|
+
const parsed = typeof serversRes === 'string' ? JSON.parse(serversRes) : serversRes;
|
|
20
|
+
const servers = Array.isArray(parsed === null || parsed === void 0 ? void 0 : parsed.servers) ? parsed.servers : [];
|
|
21
|
+
return servers;
|
|
22
|
+
}
|
|
23
|
+
async initialize() {
|
|
24
|
+
const managerRef = this.manager;
|
|
25
|
+
while (!managerRef.ready) {
|
|
26
|
+
await new Promise((resolve) => {
|
|
27
|
+
setTimeout(resolve, 100);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const servers = await this.getGameServers();
|
|
32
|
+
servers.forEach((server) => {
|
|
33
|
+
const serverStruct = {
|
|
34
|
+
id: server.id,
|
|
35
|
+
config: server
|
|
36
|
+
};
|
|
37
|
+
this._add(serverStruct, true, server.id);
|
|
38
|
+
});
|
|
39
|
+
console.log(`Found ${servers.length} servers`);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
throw new Error(String(err));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async setGameServers(servers) {
|
|
46
|
+
if (!Array.isArray(servers) || servers.length === 0) {
|
|
47
|
+
throw new Error('servers array must include at least one server configuration.');
|
|
48
|
+
}
|
|
49
|
+
return new Promise(async (resolve, reject) => {
|
|
10
50
|
var _a;
|
|
11
|
-
while (!manager.ready) {
|
|
12
|
-
await new Promise((resolve) => {
|
|
13
|
-
setTimeout(resolve, 100);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
51
|
try {
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
52
|
+
const response = await ((_a = this.manager.rest) === null || _a === void 0 ? void 0 : _a.request('SET_GAME_SERVERS', servers));
|
|
53
|
+
const updatedServers = (Array.isArray(response === null || response === void 0 ? void 0 : response.data) ? response.data : []);
|
|
54
|
+
if (updatedServers.length > 0) {
|
|
55
|
+
this.cache.clear();
|
|
56
|
+
updatedServers.forEach((server) => {
|
|
57
|
+
const serverStruct = {
|
|
58
|
+
id: server.id,
|
|
59
|
+
config: server
|
|
60
|
+
};
|
|
61
|
+
this._add(serverStruct, true, server.id);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
resolve({ success: true, data: updatedServers });
|
|
27
65
|
}
|
|
28
66
|
catch (err) {
|
|
29
|
-
|
|
67
|
+
if (err instanceof src_1.APIError) {
|
|
68
|
+
resolve({ success: false, reason: err.response });
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
reject(err);
|
|
72
|
+
}
|
|
30
73
|
}
|
|
31
|
-
})
|
|
74
|
+
});
|
|
32
75
|
}
|
|
33
76
|
}
|
|
34
77
|
exports.CMSServerManager = CMSServerManager;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Instance } from '../instance/Instance';
|
|
2
|
+
import { REST } from '../libs/rest/src';
|
|
3
|
+
import { BaseManager } from './BaseManager';
|
|
4
|
+
import * as globalTypes from '../constants';
|
|
5
|
+
/**
|
|
6
|
+
* Manages all Sonoran Radio API interactions.
|
|
7
|
+
*/
|
|
8
|
+
export declare class RadioManager extends BaseManager {
|
|
9
|
+
readonly ready: boolean;
|
|
10
|
+
readonly failReason: unknown;
|
|
11
|
+
rest: REST | undefined;
|
|
12
|
+
constructor(instance: Instance);
|
|
13
|
+
protected buildManager(instance: Instance): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves the configured community channel groups and channels.
|
|
16
|
+
*/
|
|
17
|
+
getCommunityChannels(): Promise<globalTypes.RadioGetCommunityChannelsPromiseResult>;
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves all connected users for the community.
|
|
20
|
+
*/
|
|
21
|
+
getConnectedUsers(): Promise<globalTypes.RadioGetConnectedUsersPromiseResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves a specific connected user by room id and identity.
|
|
24
|
+
* @param {number} roomId Multi-server room id.
|
|
25
|
+
* @param {string} identity User account UUID.
|
|
26
|
+
*/
|
|
27
|
+
getConnectedUser(roomId: number, identity: string): Promise<globalTypes.RadioGetConnectedUserPromiseResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Updates a user's transmit and scanned channel configuration.
|
|
30
|
+
* @param {string} identity The user's UUID.
|
|
31
|
+
* @param {RadioSetUserChannelsOptions} options Transmit and scan channel configuration.
|
|
32
|
+
*/
|
|
33
|
+
setUserChannels(identity: string, options?: globalTypes.RadioSetUserChannelsOptions): Promise<globalTypes.RadioSetUserChannelsPromiseResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Updates a user's display name.
|
|
36
|
+
* @param {string} accId The user's account UUID.
|
|
37
|
+
* @param {string} displayName The new display name.
|
|
38
|
+
*/
|
|
39
|
+
setUserDisplayName(accId: string, displayName: string): Promise<globalTypes.RadioSetUserDisplayNamePromiseResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves the community subscription level determined by the calling server's IP.
|
|
42
|
+
*/
|
|
43
|
+
getServerSubscriptionFromIp(): Promise<globalTypes.RadioGetServerSubscriptionFromIpPromiseResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Sets the push event URL for the community.
|
|
46
|
+
* @param {string} pushUrl The server push URL.
|
|
47
|
+
*/
|
|
48
|
+
setServerIp(pushUrl: string): Promise<globalTypes.RadioSetServerIpPromiseResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Sets the available in-game speaker locations for tone dispatching.
|
|
51
|
+
* @param {RadioSpeakerLocation[]} locations Collection of speaker locations.
|
|
52
|
+
* @param {string} [token] Optional bearer token for authorization. Defaults to the community API key.
|
|
53
|
+
*/
|
|
54
|
+
setInGameSpeakerLocations(locations: globalTypes.RadioSpeakerLocation[], token?: string): Promise<globalTypes.RadioSetInGameSpeakerLocationsPromiseResult>;
|
|
55
|
+
}
|