@sonoransoftware/sonoran.js 1.0.38 → 1.0.39
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/constants.d.ts +1 -0
- package/dist/libs/rest/src/lib/REST.js +10 -1
- package/dist/libs/rest/src/lib/utils/constants.js +1 -1
- package/dist/managers/CMSManager.js +25 -1
- package/package.json +1 -1
- package/src/constants.ts +1 -0
- package/src/libs/rest/src/lib/REST.ts +10 -1
- package/src/libs/rest/src/lib/utils/constants.ts +1 -1
- package/src/managers/CMSManager.ts +28 -1
package/dist/constants.d.ts
CHANGED
|
@@ -305,7 +305,16 @@ class REST extends events_1.EventEmitter {
|
|
|
305
305
|
if (!Array.isArray(payload)) {
|
|
306
306
|
throw new Error('ERLC_EXECUTE_COMMAND requires an array of command payloads.');
|
|
307
307
|
}
|
|
308
|
-
return payload
|
|
308
|
+
return payload.map((cmd) => {
|
|
309
|
+
const serverId = cmd.serverId;
|
|
310
|
+
if (typeof serverId !== 'string' || serverId.length === 0) {
|
|
311
|
+
throw new Error('ERLC_EXECUTE_COMMAND requires each command to include a valid serverId.');
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
...cmd,
|
|
315
|
+
serverId
|
|
316
|
+
};
|
|
317
|
+
});
|
|
309
318
|
}
|
|
310
319
|
case 'RADIO_GET_COMMUNITY_CHANNELS':
|
|
311
320
|
case 'RADIO_GET_CONNECTED_USERS':
|
|
@@ -634,10 +634,34 @@ class CMSManager extends BaseManager_1.BaseManager {
|
|
|
634
634
|
if (!Array.isArray(commands) || commands.length === 0) {
|
|
635
635
|
throw new Error('ERLC execute command requires at least one command payload.');
|
|
636
636
|
}
|
|
637
|
+
const normalizedCommands = commands.map((cmd) => {
|
|
638
|
+
const type = cmd.type;
|
|
639
|
+
const args = cmd.args;
|
|
640
|
+
const discordId = cmd.discordId;
|
|
641
|
+
const includesPlayerNameOrId = cmd.includesPlayerNameOrId;
|
|
642
|
+
const serverId = cmd.serverId;
|
|
643
|
+
if (!type) {
|
|
644
|
+
throw new Error('Each ERLC command requires a type.');
|
|
645
|
+
}
|
|
646
|
+
if (!discordId) {
|
|
647
|
+
throw new Error('Each ERLC command requires a discordId.');
|
|
648
|
+
}
|
|
649
|
+
if (typeof serverId !== 'string' || serverId.length === 0) {
|
|
650
|
+
throw new Error('Each ERLC command requires a serverId.');
|
|
651
|
+
}
|
|
652
|
+
return {
|
|
653
|
+
...cmd,
|
|
654
|
+
type,
|
|
655
|
+
args,
|
|
656
|
+
discordId,
|
|
657
|
+
includesPlayerNameOrId,
|
|
658
|
+
serverId,
|
|
659
|
+
};
|
|
660
|
+
});
|
|
637
661
|
return new Promise(async (resolve, reject) => {
|
|
638
662
|
var _a;
|
|
639
663
|
try {
|
|
640
|
-
const erlcExecuteCommandRequest = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('ERLC_EXECUTE_COMMAND',
|
|
664
|
+
const erlcExecuteCommandRequest = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('ERLC_EXECUTE_COMMAND', normalizedCommands));
|
|
641
665
|
resolve({ success: true, data: erlcExecuteCommandRequest });
|
|
642
666
|
}
|
|
643
667
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonoransoftware/sonoran.js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.39",
|
|
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/src/constants.ts
CHANGED
|
@@ -409,7 +409,16 @@ export class REST extends EventEmitter {
|
|
|
409
409
|
if (!Array.isArray(payload)) {
|
|
410
410
|
throw new Error('ERLC_EXECUTE_COMMAND requires an array of command payloads.');
|
|
411
411
|
}
|
|
412
|
-
return payload
|
|
412
|
+
return payload.map((cmd) => {
|
|
413
|
+
const serverId = cmd.serverId;
|
|
414
|
+
if (typeof serverId !== 'string' || serverId.length === 0) {
|
|
415
|
+
throw new Error('ERLC_EXECUTE_COMMAND requires each command to include a valid serverId.');
|
|
416
|
+
}
|
|
417
|
+
return {
|
|
418
|
+
...cmd,
|
|
419
|
+
serverId
|
|
420
|
+
};
|
|
421
|
+
});
|
|
413
422
|
}
|
|
414
423
|
case 'RADIO_GET_COMMUNITY_CHANNELS':
|
|
415
424
|
case 'RADIO_GET_CONNECTED_USERS':
|
|
@@ -570,9 +570,36 @@ export class CMSManager extends BaseManager {
|
|
|
570
570
|
throw new Error('ERLC execute command requires at least one command payload.');
|
|
571
571
|
}
|
|
572
572
|
|
|
573
|
+
const normalizedCommands = commands.map((cmd) => {
|
|
574
|
+
const type = cmd.type;
|
|
575
|
+
const args = cmd.args;
|
|
576
|
+
const discordId = cmd.discordId;
|
|
577
|
+
const includesPlayerNameOrId = cmd.includesPlayerNameOrId;
|
|
578
|
+
const serverId = cmd.serverId;
|
|
579
|
+
|
|
580
|
+
if (!type) {
|
|
581
|
+
throw new Error('Each ERLC command requires a type.');
|
|
582
|
+
}
|
|
583
|
+
if (!discordId) {
|
|
584
|
+
throw new Error('Each ERLC command requires a discordId.');
|
|
585
|
+
}
|
|
586
|
+
if (typeof serverId !== 'string' || serverId.length === 0) {
|
|
587
|
+
throw new Error('Each ERLC command requires a serverId.');
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
return {
|
|
591
|
+
...cmd,
|
|
592
|
+
type,
|
|
593
|
+
args,
|
|
594
|
+
discordId,
|
|
595
|
+
includesPlayerNameOrId,
|
|
596
|
+
serverId,
|
|
597
|
+
};
|
|
598
|
+
});
|
|
599
|
+
|
|
573
600
|
return new Promise(async (resolve, reject) => {
|
|
574
601
|
try {
|
|
575
|
-
const erlcExecuteCommandRequest: any = await this.rest?.request('ERLC_EXECUTE_COMMAND',
|
|
602
|
+
const erlcExecuteCommandRequest: any = await this.rest?.request('ERLC_EXECUTE_COMMAND', normalizedCommands);
|
|
576
603
|
resolve({ success: true, data: erlcExecuteCommandRequest });
|
|
577
604
|
} catch (err) {
|
|
578
605
|
if (err instanceof APIError) {
|