@sonoransoftware/sonoran.js 1.0.35 → 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/dist/constants.d.ts +42 -0
- package/dist/index.d.ts +1 -1
- package/dist/libs/rest/src/lib/REST.js +10 -0
- package/dist/libs/rest/src/lib/RequestManager.js +8 -0
- package/dist/libs/rest/src/lib/utils/constants.d.ts +8 -4
- package/dist/libs/rest/src/lib/utils/constants.js +12 -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/package.json +1 -1
- package/readme.md +143 -31
- package/src/constants.ts +49 -0
- package/src/index.ts +7 -0
- package/src/libs/rest/src/lib/REST.ts +10 -0
- package/src/libs/rest/src/lib/RequestManager.ts +8 -0
- package/src/libs/rest/src/lib/utils/constants.ts +20 -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
|
@@ -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.
|
|
@@ -420,6 +470,32 @@ class CMSManager extends BaseManager_1.BaseManager {
|
|
|
420
470
|
}
|
|
421
471
|
});
|
|
422
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
|
+
}
|
|
423
499
|
/**
|
|
424
500
|
* Retrieves submissions for a specific form template.
|
|
425
501
|
*/
|
|
@@ -7,5 +7,10 @@ import { CMSManager } from './CMSManager';
|
|
|
7
7
|
export declare class CMSServerManager extends CacheManager<number, CMSServer, CMSServerAPIStruct> {
|
|
8
8
|
private readonly manager;
|
|
9
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;
|
|
10
15
|
setGameServers(servers: globalTypes.CMSSetGameServerStruct[]): Promise<globalTypes.CMSSetGameServersPromiseResult>;
|
|
11
16
|
}
|
|
@@ -8,30 +8,39 @@ class CMSServerManager extends CacheManager_1.CacheManager {
|
|
|
8
8
|
constructor(instance, manager) {
|
|
9
9
|
super(instance, CMSServer_1.CMSServer, []);
|
|
10
10
|
this.manager = manager;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
+
}
|
|
35
44
|
}
|
|
36
45
|
async setGameServers(servers) {
|
|
37
46
|
if (!Array.isArray(servers) || servers.length === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonoransoftware/sonoran.js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.36",
|
|
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
|
@@ -3,7 +3,7 @@ Sonoran.js is a library that allows you to interact with the [Sonoran CAD](https
|
|
|
3
3
|
|
|
4
4
|
## Example Instance Setup
|
|
5
5
|
|
|
6
|
-
Utilizing
|
|
6
|
+
Utilizing Sonoran CMS, Sonoran CAD & Sonoran Radio
|
|
7
7
|
```js
|
|
8
8
|
const Sonoran = require('sonoran.js');
|
|
9
9
|
const instance = Sonoran.instance({
|
|
@@ -11,6 +11,8 @@ const instance = Sonoran.instance({
|
|
|
11
11
|
cadApiKey: 'DF58F1E-FD8A-44C5-BA',
|
|
12
12
|
cmsCommunityId: 'mycommunity',
|
|
13
13
|
cmsApiKey: 'e6ba9d68-ca7a-4e59-a9e2-93e275b4e0bf'
|
|
14
|
+
radioCommunityId: 'mycommunity'
|
|
15
|
+
radioApiKey: 'e6ba9d68-ca7a-4e59-a9e2-93e275b4e0bf'
|
|
14
16
|
});
|
|
15
17
|
```
|
|
16
18
|
|
|
@@ -51,50 +53,117 @@ instance.cms.verifyWhitelist({
|
|
|
51
53
|
```
|
|
52
54
|
|
|
53
55
|
## CAD Functions
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
Most CAD manager helpers return a `CADStandardResponse<T>` of `{ success, data?, reason? }`. Legacy helpers (`getAccount`, `setClockTime`, `joinCommunity`, `leaveCommunity`) keep their original response shapes.
|
|
57
|
+
|
|
58
|
+
### Account & Configuration
|
|
59
|
+
- **`getVersion()`** - resolves to the numeric CAD subscription level.
|
|
60
|
+
- **`getAccount({ apiId?, username? })`** - fetches account details.
|
|
61
|
+
- **`setClockTime({ serverId, currentUtc, currentGame, secondsPerHour })`** - synchronizes in-game time.
|
|
62
|
+
- **`joinCommunity(internalKey, accounts)`** / **`leaveCommunity(internalKey, accounts)`** - manages community membership (requires an internal key).
|
|
63
|
+
- **`setPenalCodes(codes)`** - replaces the penal code configuration.
|
|
64
|
+
- **`setAccountApiIds(data)`** - assigns API IDs to a username.
|
|
65
|
+
- **`checkApiId(apiId)`** - confirms whether an API ID exists.
|
|
66
|
+
- **`applyPermissionKey(apiId?, permissionKey)`** - applies a permission key to an account.
|
|
67
|
+
- **`setAccountPermissions(changes)`** - bulk add/remove CAD permissions.
|
|
68
|
+
- **`banUser(data)`** - kicks or bans an account via the CAD API.
|
|
69
|
+
- **`verifySecret(secret)`** - validates a configured secret.
|
|
70
|
+
- **`authorizeStreetSigns(serverId)`** - authorizes map street-sign updates.
|
|
71
|
+
- **`setPostals(entries)`** - overwrites the postal table.
|
|
72
|
+
- **`sendPhoto(apiId?, url)`** - attaches a photo to an account.
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
const account = await instance.cad.getAccount({ apiId: '1234567890' });
|
|
76
|
+
const penalCodes = await instance.cad.setPenalCodes([
|
|
77
|
+
{ code: '1A', type: 'Felony', title: 'Example', bondType: 'None', jailTime: '0', bondAmount: 0 }
|
|
78
|
+
]);
|
|
79
|
+
await instance.cad.setAccountApiIds({ username: 'SomeUser', apiIds: ['1234567890'], pushNew: true });
|
|
80
|
+
const permissionUpdate = await instance.cad.setAccountPermissions({ apiId: '1234567890', add: ['admin'], remove: [] });
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Records & Lookups
|
|
84
|
+
- **`getRecordTemplates(recordTypeId?)`**
|
|
85
|
+
- **`createRecord(data)`** / **`updateRecord(data)`** / **`removeRecord(id)`**
|
|
86
|
+
- **`lookupByInt(criteria)`** - identifier-based lookup.
|
|
87
|
+
- **`lookupRecords(query)`** - plate/name-based lookup.
|
|
88
|
+
|
|
58
89
|
```js
|
|
59
|
-
|
|
60
|
-
apiId: '',
|
|
61
|
-
username: 'SomeUser',
|
|
62
|
-
};
|
|
63
|
-
// Get user account object
|
|
64
|
-
const account = await instance.cad.getAccount(params);
|
|
90
|
+
await instance.cad.createRecord({ user: '1234567890', useDictionary: true, recordTypeId: 2, replaceValues: { NAME: 'Jane Doe' } });
|
|
91
|
+
const lookup = await instance.cad.lookupRecords({ apiId: '1234567890', types: [2], first: 'Jane', last: 'Doe', mi: '', plate: '', partial: false });
|
|
65
92
|
```
|
|
66
93
|
|
|
67
|
-
###
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
94
|
+
### Civilian Tools
|
|
95
|
+
- **`getCharacters(apiId)`** - lists civilian characters for an API ID.
|
|
96
|
+
- **`createCharacter(data)`** / **`updateCharacter(data)`** / **`removeCharacter(id)`** - CRUD helpers for civilian profiles.
|
|
97
|
+
|
|
98
|
+
### Identifiers & Units
|
|
99
|
+
- **`getIdentifiers(apiId)`**
|
|
100
|
+
- **`modifyIdentifier(change)`** / **`setIdentifier(apiId?, identId)`**
|
|
101
|
+
- **`setUnitPanic(apiId?, isPanic)`** / **`setUnitStatus(apiId?, status, serverId)`**
|
|
102
|
+
- **`getActiveUnits(options)`** - direct CAD fetch for active units.
|
|
103
|
+
- **`kickUnit(apiId?, reason, serverId)`**
|
|
104
|
+
- **`updateUnitLocations(locations)`**
|
|
105
|
+
|
|
106
|
+
### Map & Streetsigns
|
|
107
|
+
- **`getBlips(serverId)`**
|
|
108
|
+
- **`addBlips(blips)`** / **`updateBlips(blips)`** / **`removeBlip(id)`**
|
|
109
|
+
- **`setStreetSignConfig(serverId, signConfig)`**
|
|
110
|
+
- **`updateStreetSign(serverId, signData)`**
|
|
111
|
+
|
|
112
|
+
### Calls & Dispatch
|
|
113
|
+
- **`create911Call(details)`** / **`remove911Call(callId)`**
|
|
114
|
+
- **`getCalls(options)`**
|
|
115
|
+
- **`createDispatch(data)`**
|
|
116
|
+
- **`attachUnits(serverId, callId, units)`** / **`detachUnits(serverId, units)`**
|
|
117
|
+
- **`setCallPostal(serverId, callId, postal)`** / **`setCallPrimary(serverId, callId, primary, trackPrimary)`**
|
|
118
|
+
- **`addCallNote(serverId, callId, note)`**
|
|
119
|
+
- **`closeCall(serverId, callId)`**
|
|
120
|
+
|
|
71
121
|
```js
|
|
72
|
-
await instance.cad.
|
|
122
|
+
const dispatch = await instance.cad.createDispatch({
|
|
73
123
|
serverId: 1,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
124
|
+
origin: Sonoran.CADDispatchOriginEnums.Caller,
|
|
125
|
+
status: Sonoran.CADDispatchStatusEnums.Active,
|
|
126
|
+
priority: 1,
|
|
127
|
+
block: '123',
|
|
128
|
+
address: 'Main St',
|
|
129
|
+
postal: '100',
|
|
130
|
+
title: 'Traffic Stop',
|
|
131
|
+
code: 'TS',
|
|
132
|
+
primary: 42,
|
|
133
|
+
trackPrimary: true,
|
|
134
|
+
description: 'Blue sedan headed north',
|
|
135
|
+
metaData: {},
|
|
136
|
+
units: ['unit-1']
|
|
77
137
|
});
|
|
138
|
+
await instance.cad.attachUnits(1, 1001, ['unit-2']);
|
|
78
139
|
```
|
|
79
140
|
|
|
80
|
-
|
|
81
|
-
|
|
141
|
+
## CAD Server Functions
|
|
142
|
+
- **`getServers()`** - fetches configured CAD servers.
|
|
143
|
+
- **`setServers(servers, deployMap?)`** - updates server configuration and refreshes the cache.
|
|
144
|
+
|
|
82
145
|
```js
|
|
83
|
-
await instance.cad.
|
|
84
|
-
|
|
85
|
-
'0987654321'
|
|
86
|
-
]);
|
|
146
|
+
const servers = await instance.cad.servers?.getServers();
|
|
147
|
+
await instance.cad.servers?.setServers(servers ?? [], false);
|
|
87
148
|
```
|
|
88
149
|
|
|
89
|
-
|
|
90
|
-
|
|
150
|
+
## CAD Active Unit Functions
|
|
151
|
+
`CADActiveUnitsManager#getActiveUnits(options?)` proxies the CAD endpoint and returns a `CADStandardResponse`.
|
|
152
|
+
|
|
91
153
|
```js
|
|
92
|
-
await
|
|
93
|
-
|
|
94
|
-
|
|
154
|
+
const activeUnits = await cadActiveUnitsManager.getActiveUnits({ includeOffline: true, limit: 25 });
|
|
155
|
+
if (activeUnits.success) {
|
|
156
|
+
console.log(activeUnits.data);
|
|
157
|
+
}
|
|
95
158
|
```
|
|
96
159
|
|
|
97
160
|
## CMS Functions
|
|
161
|
+
### getSubscriptionVersion()
|
|
162
|
+
Returns the community's CMS subscription version.
|
|
163
|
+
```js
|
|
164
|
+
const version = await instance.cms.getSubscriptionVersion();
|
|
165
|
+
```
|
|
166
|
+
|
|
98
167
|
### verifyWhitelist(obj)
|
|
99
168
|
Verifies that a user is whitelisted in the specified server.
|
|
100
169
|
#### Arugment `params`
|
|
@@ -188,7 +257,7 @@ const getDepts = await instance.cms.getDepartments();
|
|
|
188
257
|
```
|
|
189
258
|
|
|
190
259
|
### setAccountRanks(obj, apiId, accId, username, discord, uniqueId)
|
|
191
|
-
|
|
260
|
+
Updates the CMS account's ranks using the identifiers provided.
|
|
192
261
|
#### Arugment `params`
|
|
193
262
|
##### Type `object` `{set?: string[]; add?: string[]; remove?: string[]}`
|
|
194
263
|
#### Arguments `apiId`, `accId`, `username`, `discord`, `uniqueId`
|
|
@@ -230,6 +299,23 @@ Manually triggers a CMS force-sync for the targeted identifiers.
|
|
|
230
299
|
await instance.cms.forceSync({ username: 'SomeUser' });
|
|
231
300
|
```
|
|
232
301
|
|
|
302
|
+
### getPromotionFlows()
|
|
303
|
+
Fetches the configured promotion flows.
|
|
304
|
+
```js
|
|
305
|
+
const flows = await instance.cms.getPromotionFlows();
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### triggerPromotionFlows(flows)
|
|
309
|
+
Executes promotion or demotion flows for one or more users.
|
|
310
|
+
```js
|
|
311
|
+
await instance.cms.triggerPromotionFlows([{
|
|
312
|
+
userId: 'u-123',
|
|
313
|
+
flowId: 'flow-abc',
|
|
314
|
+
users: ['u-123', 'u-456'],
|
|
315
|
+
promote: true
|
|
316
|
+
}]);
|
|
317
|
+
```
|
|
318
|
+
|
|
233
319
|
### getCurrentClockIn(params)
|
|
234
320
|
Fetches the current clock-in entry for the account if one exists.
|
|
235
321
|
```js
|
|
@@ -260,6 +346,17 @@ Retrieves form submissions with optional pagination.
|
|
|
260
346
|
const submissions = await instance.cms.getFormSubmissions(42, { skip: 0, take: 25 });
|
|
261
347
|
```
|
|
262
348
|
|
|
349
|
+
### changeFormStage(params)
|
|
350
|
+
Moves a form to the specified stage for an account.
|
|
351
|
+
```js
|
|
352
|
+
await instance.cms.changeFormStage({
|
|
353
|
+
formId: 42,
|
|
354
|
+
newStageId: 'approved',
|
|
355
|
+
accId: 'account-uuid',
|
|
356
|
+
uniqueId: 1234
|
|
357
|
+
});
|
|
358
|
+
```
|
|
359
|
+
|
|
263
360
|
### editAccountProfileFields(params)
|
|
264
361
|
Updates profile fields for an account.
|
|
265
362
|
```js
|
|
@@ -294,6 +391,21 @@ await instance.cms.erlcAddNewRecord({
|
|
|
294
391
|
});
|
|
295
392
|
```
|
|
296
393
|
|
|
394
|
+
## CMS Server Functions
|
|
395
|
+
### getGameServers()
|
|
396
|
+
Fetches the configured CMS game servers. Returns an array of server objects.
|
|
397
|
+
```js
|
|
398
|
+
const cmsServers = await instance.cms.servers?.getGameServers();
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### setGameServers(servers)
|
|
402
|
+
Replaces the configured CMS game servers and refreshes the cache with the response payload.
|
|
403
|
+
```js
|
|
404
|
+
await instance.cms.servers?.setGameServers([
|
|
405
|
+
{ name: 'Server 1', description: 'Primary server', allowedRanks: ['admin'] }
|
|
406
|
+
]);
|
|
407
|
+
```
|
|
408
|
+
|
|
297
409
|
## Radio Functions
|
|
298
410
|
### getCommunityChannels()
|
|
299
411
|
Retrieves configured community channel groups and channels.
|
package/src/constants.ts
CHANGED
|
@@ -271,6 +271,12 @@ export interface CADLeaveCommunityPromiseResult {
|
|
|
271
271
|
data?: unknown;
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
+
export interface CADStandardResponse<T = unknown> {
|
|
275
|
+
success: boolean;
|
|
276
|
+
data?: T;
|
|
277
|
+
reason?: unknown;
|
|
278
|
+
}
|
|
279
|
+
|
|
274
280
|
export interface CMSProfileField {
|
|
275
281
|
id: string;
|
|
276
282
|
type: string;
|
|
@@ -348,6 +354,12 @@ export interface CMSRsvpPromiseResult {
|
|
|
348
354
|
data?: unknown;
|
|
349
355
|
}
|
|
350
356
|
|
|
357
|
+
export interface CMSChangeFormStagePromiseResult {
|
|
358
|
+
success: boolean;
|
|
359
|
+
reason?: string;
|
|
360
|
+
data?: unknown;
|
|
361
|
+
}
|
|
362
|
+
|
|
351
363
|
export interface CMSSetGameServerStruct {
|
|
352
364
|
id?: number;
|
|
353
365
|
name: string;
|
|
@@ -365,6 +377,43 @@ export interface CMSSetGameServersPromiseResult {
|
|
|
365
377
|
data?: CMSSetGameServerStruct[];
|
|
366
378
|
}
|
|
367
379
|
|
|
380
|
+
export interface CMSExecuteRankPromotionResult {
|
|
381
|
+
users: string[];
|
|
382
|
+
flow: string;
|
|
383
|
+
promote: boolean;
|
|
384
|
+
succeeded: boolean;
|
|
385
|
+
message?: string;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export interface CMSTriggerPromotionFlowPayload {
|
|
389
|
+
userId: string;
|
|
390
|
+
flowId: string;
|
|
391
|
+
users: string[];
|
|
392
|
+
promote: boolean;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export interface CMSPromotionFlow {
|
|
396
|
+
id: string;
|
|
397
|
+
communityUuid: string;
|
|
398
|
+
labelFrom: string;
|
|
399
|
+
labelTo: string;
|
|
400
|
+
ranksToAdd: string[];
|
|
401
|
+
ranksToRemove: string[];
|
|
402
|
+
actions: unknown[];
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export interface CMSTriggerPromotionFlowsPromiseResult {
|
|
406
|
+
success: boolean;
|
|
407
|
+
reason?: string;
|
|
408
|
+
data?: CMSExecuteRankPromotionResult[];
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export interface CMSGetPromotionFlowsPromiseResult {
|
|
412
|
+
success: boolean;
|
|
413
|
+
reason?: string;
|
|
414
|
+
data?: CMSPromotionFlow[];
|
|
415
|
+
}
|
|
416
|
+
|
|
368
417
|
export interface CMSGetFormSubmissionsPromiseResult<T = unknown> {
|
|
369
418
|
success: boolean;
|
|
370
419
|
reason?: string;
|
package/src/index.ts
CHANGED
|
@@ -23,6 +23,7 @@ export {
|
|
|
23
23
|
CADSetClockTimePromiseResult,
|
|
24
24
|
CADJoinCommunityPromiseResult,
|
|
25
25
|
CADLeaveCommunityPromiseResult,
|
|
26
|
+
CADStandardResponse,
|
|
26
27
|
CMSProfileField,
|
|
27
28
|
CMSGetCurrentClockInPromiseResult,
|
|
28
29
|
CMSAccountsPage,
|
|
@@ -32,7 +33,13 @@ export {
|
|
|
32
33
|
CMSProfileFieldUpdate,
|
|
33
34
|
CMSEditAccountProfileFieldsPromiseResult,
|
|
34
35
|
CMSRsvpPromiseResult,
|
|
36
|
+
CMSChangeFormStagePromiseResult,
|
|
35
37
|
CMSSetGameServerStruct,
|
|
36
38
|
CMSSetGameServersPromiseResult,
|
|
39
|
+
CMSExecuteRankPromotionResult,
|
|
40
|
+
CMSTriggerPromotionFlowPayload,
|
|
41
|
+
CMSPromotionFlow,
|
|
42
|
+
CMSTriggerPromotionFlowsPromiseResult,
|
|
43
|
+
CMSGetPromotionFlowsPromiseResult,
|
|
37
44
|
CMSGetFormSubmissionsPromiseResult
|
|
38
45
|
} from './constants';
|
|
@@ -373,6 +373,16 @@ export class REST extends EventEmitter {
|
|
|
373
373
|
uniqueId: args[4],
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
|
+
case 'TRIGGER_PROMOTION_FLOWS': {
|
|
377
|
+
const payload = args[0];
|
|
378
|
+
if (!Array.isArray(payload)) {
|
|
379
|
+
throw new Error('TRIGGER_PROMOTION_FLOWS requires an array of promotion flow payloads.');
|
|
380
|
+
}
|
|
381
|
+
return payload;
|
|
382
|
+
}
|
|
383
|
+
case 'GET_PROMOTION_FLOWS': {
|
|
384
|
+
return [];
|
|
385
|
+
}
|
|
376
386
|
case 'ERLC_GET_ONLINE_PLAYERS': {
|
|
377
387
|
return {
|
|
378
388
|
robloxJoinCode: args[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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { productEnums, RadioSetUserChannelsOptions, RadioSpeakerLocation, CMSProfileFieldUpdate, CMSSetGameServerStruct } from '../../../../../constants';
|
|
1
|
+
import { productEnums, RadioSetUserChannelsOptions, RadioSpeakerLocation, 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
|
|
|
@@ -601,7 +613,7 @@ function formatForAll(array: APITypeData[], product: productEnums): AllAPITypeDa
|
|
|
601
613
|
|
|
602
614
|
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
615
|
|
|
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';
|
|
616
|
+
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';
|
|
605
617
|
|
|
606
618
|
export interface CMSServerAPIStruct {
|
|
607
619
|
id: number;
|
|
@@ -984,7 +996,7 @@ export interface RESTTypedAPIDataStructs {
|
|
|
984
996
|
serverId: number,
|
|
985
997
|
callId: number
|
|
986
998
|
];
|
|
987
|
-
'
|
|
999
|
+
'911_CALL': [
|
|
988
1000
|
serverId: number,
|
|
989
1001
|
isEmergency: boolean,
|
|
990
1002
|
caller: string,
|
|
@@ -1074,6 +1086,10 @@ export interface RESTTypedAPIDataStructs {
|
|
|
1074
1086
|
discordId: string | undefined,
|
|
1075
1087
|
uniqueId: string | undefined,
|
|
1076
1088
|
],
|
|
1089
|
+
TRIGGER_PROMOTION_FLOWS: [
|
|
1090
|
+
data: CMSTriggerPromotionFlowPayload[]
|
|
1091
|
+
];
|
|
1092
|
+
GET_PROMOTION_FLOWS: [];
|
|
1077
1093
|
// CMS - Servers
|
|
1078
1094
|
GET_GAME_SERVERS: [];
|
|
1079
1095
|
SET_GAME_SERVERS: [servers: CMSSetGameServerStruct[]];
|
|
@@ -1176,7 +1192,7 @@ export interface RESTTypedAPIDataStructs {
|
|
|
1176
1192
|
export type PossibleRequestData =
|
|
1177
1193
|
undefined |
|
|
1178
1194
|
{
|
|
1179
|
-
data: CADPenalCodeStruct[] | CADSetAPIIDStruct | CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct | CADLookupByIntStruct | CADLookupStruct | CADModifyAccountPermsStruct | CADKickBanUserStruct | CADSetPostalStruct[] | CADModifyIdentifierStruct | CADAddBlipStruct[] | CADModifyBlipStruct[] | CADGetCallsStruct | CADGetActiveUnitsStruct | CADNewDispatchStruct
|
|
1195
|
+
data: CADPenalCodeStruct[] | CADSetAPIIDStruct | CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct | CADLookupByIntStruct | CADLookupStruct | CADModifyAccountPermsStruct | CADKickBanUserStruct | CADSetPostalStruct[] | CADModifyIdentifierStruct | CADAddBlipStruct[] | CADModifyBlipStruct[] | CADGetCallsStruct | CADGetActiveUnitsStruct | CADNewDispatchStruct | CMSTriggerPromotionFlowPayload[]
|
|
1180
1196
|
} |
|
|
1181
1197
|
{
|
|
1182
1198
|
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
|
+
}
|