@sonoransoftware/sonoran.js 1.0.33 → 1.0.35
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 +205 -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 +113 -0
- package/dist/libs/rest/src/lib/RequestManager.d.ts +2 -0
- package/dist/libs/rest/src/lib/RequestManager.js +201 -0
- package/dist/libs/rest/src/lib/errors/RateLimitError.js +19 -1
- package/dist/libs/rest/src/lib/utils/constants.d.ts +105 -22
- package/dist/libs/rest/src/lib/utils/constants.js +112 -2
- package/dist/managers/CADManager.d.ts +28 -0
- package/dist/managers/CADManager.js +90 -0
- package/dist/managers/CMSManager.d.ts +60 -0
- package/dist/managers/CMSManager.js +156 -0
- package/dist/managers/CMSServerManager.d.ts +3 -0
- package/dist/managers/CMSServerManager.js +36 -2
- package/dist/managers/RadioManager.d.ts +55 -0
- package/dist/managers/RadioManager.js +224 -0
- package/package.json +1 -1
- package/readme.md +170 -0
- package/src/constants.ts +239 -2
- package/src/index.ts +35 -1
- package/src/instance/Instance.ts +30 -1
- package/src/instance/instance.types.ts +4 -1
- package/src/libs/rest/src/lib/REST.ts +112 -1
- package/src/libs/rest/src/lib/RequestManager.ts +221 -10
- package/src/libs/rest/src/lib/errors/RateLimitError.ts +20 -2
- package/src/libs/rest/src/lib/utils/constants.ts +215 -25
- package/src/managers/CADManager.ts +86 -1
- package/src/managers/CMSManager.ts +142 -1
- package/src/managers/CMSServerManager.ts +39 -6
- package/src/managers/RadioManager.ts +187 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
name: Auto PR for new branch (trigger Codex)
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- 'feat/**'
|
|
7
|
+
- 'fix/**'
|
|
8
|
+
- 'tweak/**'
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: write
|
|
12
|
+
pull-requests: write
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
ensure-pr:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
env:
|
|
18
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
19
|
+
BRANCH: ${{ github.ref_name }}
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
with: { fetch-depth: 0 }
|
|
23
|
+
|
|
24
|
+
- name: Auth gh
|
|
25
|
+
run: gh auth status || true
|
|
26
|
+
|
|
27
|
+
- name: Ensure PR exists
|
|
28
|
+
id: pr
|
|
29
|
+
run: |
|
|
30
|
+
PR_NUMBER=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number')
|
|
31
|
+
if [ -n "$PR_NUMBER" ]; then
|
|
32
|
+
echo "PR exists: #$PR_NUMBER"
|
|
33
|
+
echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
|
|
34
|
+
echo "created=false" >> "$GITHUB_OUTPUT"
|
|
35
|
+
exit 0
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
TITLE="Auto Review: $BRANCH"
|
|
39
|
+
BODY_FILE="$(mktemp)"
|
|
40
|
+
{
|
|
41
|
+
echo "Auto-created to trigger Codex code review for branch **$BRANCH** targeting \`staging\`."
|
|
42
|
+
echo
|
|
43
|
+
echo "Codex instructions: .github/codex_instructions.md"
|
|
44
|
+
} > "$BODY_FILE"
|
|
45
|
+
|
|
46
|
+
gh pr create \
|
|
47
|
+
--head "$BRANCH" \
|
|
48
|
+
--base "staging" \
|
|
49
|
+
--title "$TITLE" \
|
|
50
|
+
--body-file "$BODY_FILE" \
|
|
51
|
+
--draft
|
|
52
|
+
PR_NUMBER=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number')
|
|
53
|
+
if [ -z "$PR_NUMBER" ]; then
|
|
54
|
+
echo "Failed to determine PR number after creation" >&2
|
|
55
|
+
exit 1
|
|
56
|
+
fi
|
|
57
|
+
echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
|
|
58
|
+
echo "created=true" >> "$GITHUB_OUTPUT"
|
|
59
|
+
|
|
60
|
+
- name: Ensure auto-review label exists
|
|
61
|
+
if: steps.pr.outputs.number
|
|
62
|
+
run: |
|
|
63
|
+
if ! gh label list --json name --limit 100 | jq -e '.[] | select(.name == "auto-review")' > /dev/null; then
|
|
64
|
+
gh label create "auto-review" --color "0E8A16" --description "PRs ready for Codex auto review"
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
- name: Label PR (optional)
|
|
68
|
+
if: steps.pr.outputs.number
|
|
69
|
+
run: |
|
|
70
|
+
gh pr edit "${{ steps.pr.outputs.number }}" --add-label "auto-review"
|
|
71
|
+
|
|
72
|
+
- name: Mark PR ready for review
|
|
73
|
+
if: steps.pr.outputs.created == 'true'
|
|
74
|
+
run: gh pr ready "${{ steps.pr.outputs.number }}"
|
|
75
|
+
|
|
76
|
+
- name: Trigger initial Codex review
|
|
77
|
+
if: steps.pr.outputs.created == 'true'
|
|
78
|
+
env:
|
|
79
|
+
PR: ${{ steps.pr.outputs.number }}
|
|
80
|
+
GH_TOKEN: ${{ secrets.CODEX_TRIGGER_TOKEN }}
|
|
81
|
+
run: |
|
|
82
|
+
TMP=$(mktemp)
|
|
83
|
+
{
|
|
84
|
+
echo "@codex review"
|
|
85
|
+
echo
|
|
86
|
+
echo "instructions: .github/codex_instructions.md"
|
|
87
|
+
} > "$TMP"
|
|
88
|
+
|
|
89
|
+
gh pr comment "$PR" --body-file "$TMP"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Codex Review Instructions
|
|
2
|
+
|
|
3
|
+
## Context
|
|
4
|
+
- Branch naming: feat/*, fix/*, tweak/*
|
|
5
|
+
- Target: merge to `staging` after preview validation
|
|
6
|
+
|
|
7
|
+
## What to prioritize
|
|
8
|
+
1. Security pitfalls (injection, authz, secret handling)
|
|
9
|
+
2. Reliability & edge cases
|
|
10
|
+
3. Breaking changes / migration notes
|
|
11
|
+
4. Performance hotspots (N+1, O(n^2), heavy I/O)
|
|
12
|
+
5. Code style & maintainability (prefer actionable diffs)
|
|
13
|
+
6. Any new English words, phrases, or sentences should be added as an i18n key
|
|
14
|
+
|
|
15
|
+
## Project-specific rules
|
|
16
|
+
- Backend: Prefer async handlers for network I/O.
|
|
17
|
+
- Frontend: Avoid blocking renders; use Suspense on data boundaries.
|
|
18
|
+
- Infra: Terraform modules must be idempotent and tagged.
|
|
19
|
+
|
|
20
|
+
## Test expectations
|
|
21
|
+
- New endpoints/components: at least 1 direct test.
|
|
22
|
+
- Bug fixes: a regression test.
|
|
23
|
+
|
|
24
|
+
> If you recommend changes, include concrete diffs.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: Nudge Codex on push
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- 'feat/**'
|
|
7
|
+
- 'fix/**'
|
|
8
|
+
- 'tweak/**'
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
pull-requests: write
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
nudge:
|
|
16
|
+
if: ${{ !github.event.created }}
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
env:
|
|
19
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
20
|
+
BRANCH: ${{ github.ref_name }}
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
with: { fetch-depth: 0 }
|
|
24
|
+
|
|
25
|
+
- name: Auth gh
|
|
26
|
+
run: gh auth status || true
|
|
27
|
+
|
|
28
|
+
- name: Find PR for this branch
|
|
29
|
+
id: pr
|
|
30
|
+
run: |
|
|
31
|
+
PR_NUMBER=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number')
|
|
32
|
+
if [ -z "$PR_NUMBER" ]; then
|
|
33
|
+
echo "No open PR for $BRANCH"; exit 0
|
|
34
|
+
fi
|
|
35
|
+
echo "pr=$PR_NUMBER" >> "$GITHUB_OUTPUT"
|
|
36
|
+
|
|
37
|
+
- name: Post Codex trigger comment with instructions
|
|
38
|
+
if: steps.pr.outputs.pr
|
|
39
|
+
env:
|
|
40
|
+
PR: ${{ steps.pr.outputs.pr }}
|
|
41
|
+
GH_TOKEN: ${{ secrets.CODEX_TRIGGER_TOKEN }}
|
|
42
|
+
run: |
|
|
43
|
+
TMP=$(mktemp)
|
|
44
|
+
{
|
|
45
|
+
echo "@codex review"
|
|
46
|
+
echo
|
|
47
|
+
echo "instructions: .github/codex_instructions.md"
|
|
48
|
+
} > "$TMP"
|
|
49
|
+
|
|
50
|
+
gh pr comment "$PR" --body-file "$TMP"
|
package/dist/constants.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { CADActiveUnitsManager } from './managers/CADActiveUnitsManager';
|
|
|
5
5
|
import { CADActiveUnit } from './structures/CADActiveUnit';
|
|
6
6
|
export declare enum productEnums {
|
|
7
7
|
CAD = 0,
|
|
8
|
-
CMS = 1
|
|
8
|
+
CMS = 1,
|
|
9
|
+
RADIO = 2
|
|
9
10
|
}
|
|
10
11
|
export interface CADNewDispatchBuilderOptions {
|
|
11
12
|
serverId?: number;
|
|
@@ -231,6 +232,27 @@ export interface CMSSetAccountNamePromiseResult {
|
|
|
231
232
|
data?: string;
|
|
232
233
|
reason?: string;
|
|
233
234
|
}
|
|
235
|
+
export interface CADSetClockTimePromiseResult {
|
|
236
|
+
success: boolean;
|
|
237
|
+
reason?: string;
|
|
238
|
+
data?: unknown;
|
|
239
|
+
}
|
|
240
|
+
export interface CADJoinCommunityPromiseResult {
|
|
241
|
+
success: boolean;
|
|
242
|
+
reason?: string;
|
|
243
|
+
data?: unknown;
|
|
244
|
+
}
|
|
245
|
+
export interface CADLeaveCommunityPromiseResult {
|
|
246
|
+
success: boolean;
|
|
247
|
+
reason?: string;
|
|
248
|
+
data?: unknown;
|
|
249
|
+
}
|
|
250
|
+
export interface CMSProfileField {
|
|
251
|
+
id: string;
|
|
252
|
+
type: string;
|
|
253
|
+
label: string;
|
|
254
|
+
options: unknown;
|
|
255
|
+
}
|
|
234
256
|
export interface CMSKickAccountPromiseResult {
|
|
235
257
|
success: boolean;
|
|
236
258
|
reason?: string;
|
|
@@ -243,6 +265,73 @@ export interface CMSForceSyncPromiseResult {
|
|
|
243
265
|
success: boolean;
|
|
244
266
|
reason?: string;
|
|
245
267
|
}
|
|
268
|
+
export interface CMSGetCurrentClockInPromiseResult {
|
|
269
|
+
success: boolean;
|
|
270
|
+
reason?: string;
|
|
271
|
+
data?: clockInOutRequest | null;
|
|
272
|
+
}
|
|
273
|
+
export interface CMSAccountSummary {
|
|
274
|
+
accId: string;
|
|
275
|
+
accName: string;
|
|
276
|
+
activeApiIds: string[];
|
|
277
|
+
discordId?: string;
|
|
278
|
+
sysStatus: boolean;
|
|
279
|
+
comStatus: boolean;
|
|
280
|
+
archived: boolean;
|
|
281
|
+
banned: boolean;
|
|
282
|
+
[key: string]: unknown;
|
|
283
|
+
}
|
|
284
|
+
export interface CMSAccountsPage {
|
|
285
|
+
total: number;
|
|
286
|
+
skip: number;
|
|
287
|
+
take: number;
|
|
288
|
+
accounts: CMSAccountSummary[];
|
|
289
|
+
}
|
|
290
|
+
export interface CMSGetAccountsPromiseResult {
|
|
291
|
+
success: boolean;
|
|
292
|
+
reason?: string;
|
|
293
|
+
data?: CMSAccountsPage;
|
|
294
|
+
}
|
|
295
|
+
export interface CMSGetProfileFieldsPromiseResult {
|
|
296
|
+
success: boolean;
|
|
297
|
+
reason?: string;
|
|
298
|
+
data?: CMSProfileField[];
|
|
299
|
+
}
|
|
300
|
+
export interface CMSProfileFieldUpdate {
|
|
301
|
+
id: string;
|
|
302
|
+
value: unknown;
|
|
303
|
+
}
|
|
304
|
+
export interface CMSEditAccountProfileFieldsPromiseResult {
|
|
305
|
+
success: boolean;
|
|
306
|
+
reason?: string;
|
|
307
|
+
data?: CMSProfileFieldUpdate[];
|
|
308
|
+
}
|
|
309
|
+
export interface CMSRsvpPromiseResult {
|
|
310
|
+
success: boolean;
|
|
311
|
+
reason?: string;
|
|
312
|
+
status?: string;
|
|
313
|
+
data?: unknown;
|
|
314
|
+
}
|
|
315
|
+
export interface CMSSetGameServerStruct {
|
|
316
|
+
id?: number;
|
|
317
|
+
name: string;
|
|
318
|
+
description?: string;
|
|
319
|
+
ip?: string;
|
|
320
|
+
port?: string;
|
|
321
|
+
allowedRanks?: string[];
|
|
322
|
+
blockedRanks?: string[];
|
|
323
|
+
[key: string]: unknown;
|
|
324
|
+
}
|
|
325
|
+
export interface CMSSetGameServersPromiseResult {
|
|
326
|
+
success: boolean;
|
|
327
|
+
reason?: string;
|
|
328
|
+
data?: CMSSetGameServerStruct[];
|
|
329
|
+
}
|
|
330
|
+
export interface CMSGetFormSubmissionsPromiseResult<T = unknown> {
|
|
331
|
+
success: boolean;
|
|
332
|
+
reason?: string;
|
|
333
|
+
data?: T[];
|
|
334
|
+
}
|
|
246
335
|
export interface CMSERLCGetOnlinePlayersPromiseResult {
|
|
247
336
|
success: boolean;
|
|
248
337
|
reason?: string;
|
|
@@ -253,8 +342,123 @@ export interface CMSERLCGetOnlinePlayersPromiseResult {
|
|
|
253
342
|
Team?: string;
|
|
254
343
|
}[];
|
|
255
344
|
}
|
|
345
|
+
export interface CMSERLCGetPlayerQueuePromiseResult {
|
|
346
|
+
success: boolean;
|
|
347
|
+
reason?: string;
|
|
348
|
+
data?: number;
|
|
349
|
+
}
|
|
256
350
|
export interface CMSERLCAddNewRecordPromiseResult {
|
|
257
351
|
success: boolean;
|
|
258
352
|
reason?: string;
|
|
259
353
|
logId?: string;
|
|
260
354
|
}
|
|
355
|
+
export interface RadioChannelGroup {
|
|
356
|
+
id: number;
|
|
357
|
+
name: string;
|
|
358
|
+
orderIndex: number;
|
|
359
|
+
}
|
|
360
|
+
export interface RadioChannel {
|
|
361
|
+
id: number;
|
|
362
|
+
groupId: number;
|
|
363
|
+
displayName: string;
|
|
364
|
+
recvFreqMajor: number;
|
|
365
|
+
recvFreqMinor: number;
|
|
366
|
+
xmitFreqMajor: number;
|
|
367
|
+
xmitFreqMinor: number;
|
|
368
|
+
repeatsXmit: boolean;
|
|
369
|
+
status: boolean;
|
|
370
|
+
orderIndex: number;
|
|
371
|
+
talkoverProtection: boolean;
|
|
372
|
+
[key: string]: unknown;
|
|
373
|
+
}
|
|
374
|
+
export interface RadioConnectedUserMetadataScanList {
|
|
375
|
+
id: number;
|
|
376
|
+
name: string;
|
|
377
|
+
channelIds: number[];
|
|
378
|
+
[key: string]: unknown;
|
|
379
|
+
}
|
|
380
|
+
export interface RadioConnectedUserMetadataState {
|
|
381
|
+
primaryChId?: number;
|
|
382
|
+
scannedChIds?: number[];
|
|
383
|
+
scanLists?: RadioConnectedUserMetadataScanList[];
|
|
384
|
+
spec?: number;
|
|
385
|
+
[key: string]: unknown;
|
|
386
|
+
}
|
|
387
|
+
export interface RadioConnectedUserMetadata {
|
|
388
|
+
sonrad?: boolean;
|
|
389
|
+
state?: RadioConnectedUserMetadataState;
|
|
390
|
+
[key: string]: unknown;
|
|
391
|
+
}
|
|
392
|
+
export interface RadioConnectedUser {
|
|
393
|
+
identity: string;
|
|
394
|
+
name: string;
|
|
395
|
+
roomId?: number;
|
|
396
|
+
metadata: RadioConnectedUserMetadata;
|
|
397
|
+
[key: string]: unknown;
|
|
398
|
+
}
|
|
399
|
+
export interface RadioSpeakerLocation {
|
|
400
|
+
label: string;
|
|
401
|
+
id: string;
|
|
402
|
+
}
|
|
403
|
+
export interface RadioSetUserChannelsOptions {
|
|
404
|
+
transmit?: number;
|
|
405
|
+
scan?: number[];
|
|
406
|
+
}
|
|
407
|
+
export type RadioSubscriptionLevel = 0 | 1 | 2;
|
|
408
|
+
export interface RadioGetCommunityChannelsPromiseResult {
|
|
409
|
+
success: boolean;
|
|
410
|
+
reason?: string;
|
|
411
|
+
data?: {
|
|
412
|
+
result: string;
|
|
413
|
+
groups: RadioChannelGroup[];
|
|
414
|
+
channels: RadioChannel[];
|
|
415
|
+
[key: string]: unknown;
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
export interface RadioGetConnectedUsersPromiseResult {
|
|
419
|
+
success: boolean;
|
|
420
|
+
reason?: string;
|
|
421
|
+
data?: {
|
|
422
|
+
result: string;
|
|
423
|
+
connectedUsers: RadioConnectedUser[];
|
|
424
|
+
[key: string]: unknown;
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
export interface RadioGetConnectedUserPromiseResult {
|
|
428
|
+
success: boolean;
|
|
429
|
+
reason?: string;
|
|
430
|
+
data?: {
|
|
431
|
+
result: string;
|
|
432
|
+
data: RadioConnectedUser;
|
|
433
|
+
[key: string]: unknown;
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
export interface RadioSetUserChannelsPromiseResult {
|
|
437
|
+
success: boolean;
|
|
438
|
+
reason?: string;
|
|
439
|
+
result?: string;
|
|
440
|
+
}
|
|
441
|
+
export interface RadioSetUserDisplayNamePromiseResult {
|
|
442
|
+
success: boolean;
|
|
443
|
+
reason?: string;
|
|
444
|
+
result?: string;
|
|
445
|
+
}
|
|
446
|
+
export interface RadioGetServerSubscriptionFromIpPromiseResult {
|
|
447
|
+
success: boolean;
|
|
448
|
+
reason?: string;
|
|
449
|
+
data?: {
|
|
450
|
+
result: string;
|
|
451
|
+
subscription: RadioSubscriptionLevel;
|
|
452
|
+
[key: string]: unknown;
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
export interface RadioSetServerIpPromiseResult {
|
|
456
|
+
success: boolean;
|
|
457
|
+
reason?: string;
|
|
458
|
+
result?: string;
|
|
459
|
+
}
|
|
460
|
+
export interface RadioSetInGameSpeakerLocationsPromiseResult {
|
|
461
|
+
success: boolean;
|
|
462
|
+
reason?: string;
|
|
463
|
+
result?: string;
|
|
464
|
+
}
|
package/dist/constants.js
CHANGED
|
@@ -5,6 +5,7 @@ var productEnums;
|
|
|
5
5
|
(function (productEnums) {
|
|
6
6
|
productEnums[productEnums["CAD"] = 0] = "CAD";
|
|
7
7
|
productEnums[productEnums["CMS"] = 1] = "CMS";
|
|
8
|
+
productEnums[productEnums["RADIO"] = 2] = "RADIO";
|
|
8
9
|
})(productEnums = exports.productEnums || (exports.productEnums = {}));
|
|
9
10
|
var CADSubscriptionVersionEnum;
|
|
10
11
|
(function (CADSubscriptionVersionEnum) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './instance/Instance';
|
|
2
2
|
export * from './builders';
|
|
3
3
|
export * from './libs/rest/src';
|
|
4
|
-
export { productEnums, CADNewDispatchBuilderOptions, CADSubscriptionVersionEnum, CMSSubscriptionVersionEnum } from './constants';
|
|
4
|
+
export { productEnums, CADNewDispatchBuilderOptions, CADSubscriptionVersionEnum, CMSSubscriptionVersionEnum, RadioSubscriptionLevel, RadioSetUserChannelsOptions, RadioChannel, RadioChannelGroup, RadioConnectedUser, RadioSpeakerLocation, RadioGetCommunityChannelsPromiseResult, RadioGetConnectedUsersPromiseResult, RadioGetConnectedUserPromiseResult, RadioSetUserChannelsPromiseResult, RadioSetUserDisplayNamePromiseResult, RadioGetServerSubscriptionFromIpPromiseResult, RadioSetServerIpPromiseResult, RadioSetInGameSpeakerLocationsPromiseResult, CADSetClockTimePromiseResult, CADJoinCommunityPromiseResult, CADLeaveCommunityPromiseResult, CMSProfileField, CMSGetCurrentClockInPromiseResult, CMSAccountsPage, CMSAccountSummary, CMSGetAccountsPromiseResult, CMSGetProfileFieldsPromiseResult, CMSProfileFieldUpdate, CMSEditAccountProfileFieldsPromiseResult, CMSRsvpPromiseResult, CMSSetGameServerStruct, CMSSetGameServersPromiseResult, CMSGetFormSubmissionsPromiseResult } from './constants';
|
|
@@ -3,6 +3,7 @@ import EventEmitter from 'events';
|
|
|
3
3
|
import * as InstanceTypes from './instance.types';
|
|
4
4
|
import { CADManager } from '../managers/CADManager';
|
|
5
5
|
import { CMSManager } from '../managers/CMSManager';
|
|
6
|
+
import { RadioManager } from '../managers/RadioManager';
|
|
6
7
|
export declare class Instance extends EventEmitter {
|
|
7
8
|
cadCommunityId: string | undefined;
|
|
8
9
|
cadApiKey: string | undefined;
|
|
@@ -14,8 +15,13 @@ export declare class Instance extends EventEmitter {
|
|
|
14
15
|
cmsApiUrl: string;
|
|
15
16
|
cmsDefaultServerId: number;
|
|
16
17
|
isCMSSuccessful: boolean;
|
|
18
|
+
radioCommunityId: string | undefined;
|
|
19
|
+
radioApiKey: string | undefined;
|
|
20
|
+
radioApiUrl: string;
|
|
21
|
+
isRadioSuccessful: boolean;
|
|
17
22
|
cad: CADManager | undefined;
|
|
18
23
|
cms: CMSManager | undefined;
|
|
24
|
+
radio: RadioManager | undefined;
|
|
19
25
|
debug: boolean;
|
|
20
26
|
apiHeaders: HeadersInit;
|
|
21
27
|
constructor(options: InstanceTypes.InstanceOptions);
|
|
@@ -31,6 +31,7 @@ const events_1 = __importDefault(require("events"));
|
|
|
31
31
|
const globalTypes = __importStar(require("../constants"));
|
|
32
32
|
const CADManager_1 = require("../managers/CADManager");
|
|
33
33
|
const CMSManager_1 = require("../managers/CMSManager");
|
|
34
|
+
const RadioManager_1 = require("../managers/RadioManager");
|
|
34
35
|
const utils_1 = require("../utils");
|
|
35
36
|
class Instance extends events_1.default {
|
|
36
37
|
constructor(options) {
|
|
@@ -41,6 +42,8 @@ class Instance extends events_1.default {
|
|
|
41
42
|
this.cmsApiUrl = 'https://api.sonorancms.com';
|
|
42
43
|
this.cmsDefaultServerId = 1;
|
|
43
44
|
this.isCMSSuccessful = false;
|
|
45
|
+
this.radioApiUrl = 'https://api.sonoranradio.com';
|
|
46
|
+
this.isRadioSuccessful = false;
|
|
44
47
|
this.debug = false;
|
|
45
48
|
this.apiHeaders = {};
|
|
46
49
|
if (options.debug) {
|
|
@@ -81,6 +84,17 @@ class Instance extends events_1.default {
|
|
|
81
84
|
this.initialize();
|
|
82
85
|
break;
|
|
83
86
|
}
|
|
87
|
+
case globalTypes.productEnums.RADIO: {
|
|
88
|
+
this.radioCommunityId = options.communityId;
|
|
89
|
+
this.radioApiKey = options.apiKey;
|
|
90
|
+
if (Object.prototype.hasOwnProperty.call(options, 'radioApiUrl') && typeof options.radioApiUrl === 'string') {
|
|
91
|
+
this._debugLog(`Overriding Radio API URL... ${options.radioApiUrl}`);
|
|
92
|
+
this.radioApiUrl = options.radioApiUrl;
|
|
93
|
+
}
|
|
94
|
+
this._debugLog('About to initialize instance.');
|
|
95
|
+
this.initialize();
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
84
98
|
default: {
|
|
85
99
|
throw new Error('Invalid product enum given for constructor.');
|
|
86
100
|
}
|
|
@@ -95,6 +109,8 @@ class Instance extends events_1.default {
|
|
|
95
109
|
this.cadApiKey = options.cadApiKey;
|
|
96
110
|
this.cmsCommunityId = options.cmsCommunityId;
|
|
97
111
|
this.cmsApiKey = options.cmsApiKey;
|
|
112
|
+
this.radioCommunityId = options.radioCommunityId;
|
|
113
|
+
this.radioApiKey = options.radioApiKey;
|
|
98
114
|
if (options.cadDefaultServerId !== undefined) {
|
|
99
115
|
this._debugLog(`Overriding default CAD server id... ${options.serverId}`);
|
|
100
116
|
this.cadDefaultServerId = options.cadDefaultServerId;
|
|
@@ -111,6 +127,10 @@ class Instance extends events_1.default {
|
|
|
111
127
|
this._debugLog(`Overriding CMS API URL... ${options.cmsApiUrl}`);
|
|
112
128
|
this.cmsApiUrl = options.cmsApiUrl;
|
|
113
129
|
}
|
|
130
|
+
if (Object.prototype.hasOwnProperty.call(options, 'radioApiUrl') && typeof options.radioApiUrl === 'string') {
|
|
131
|
+
this._debugLog(`Overriding Radio API URL... ${options.radioApiUrl}`);
|
|
132
|
+
this.radioApiUrl = options.radioApiUrl;
|
|
133
|
+
}
|
|
114
134
|
this.initialize();
|
|
115
135
|
}
|
|
116
136
|
}
|
|
@@ -129,6 +149,13 @@ class Instance extends events_1.default {
|
|
|
129
149
|
else {
|
|
130
150
|
this._debugLog('Not initializing CMS Manager due to a missing community id, api key, or api url.');
|
|
131
151
|
}
|
|
152
|
+
if (this.radioCommunityId && this.radioApiKey && this.radioApiUrl) {
|
|
153
|
+
this._debugLog('About to initialize Radio Manager');
|
|
154
|
+
this.radio = new RadioManager_1.RadioManager(this);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
this._debugLog('Not initializing Radio Manager due to a missing community id, api key, or api url.');
|
|
158
|
+
}
|
|
132
159
|
}
|
|
133
160
|
_debugLog(message) {
|
|
134
161
|
if (this.debug) {
|
|
@@ -10,6 +10,7 @@ import type { RequestInit, Response } from 'node-fetch';
|
|
|
10
10
|
import { Instance } from '../../../../instance/Instance';
|
|
11
11
|
import { CADManager } from '../../../../managers/CADManager';
|
|
12
12
|
import { CMSManager } from '../../../../managers/CMSManager';
|
|
13
|
+
import { RadioManager } from '../../../../managers/RadioManager';
|
|
13
14
|
/**
|
|
14
15
|
* Options to be passed when creating the REST instance
|
|
15
16
|
*/
|
|
@@ -86,7 +87,7 @@ export interface REST {
|
|
|
86
87
|
off: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
|
|
87
88
|
removeAllListeners: (<K extends keyof RestEvents>(event?: K) => this) & (<S extends string | symbol>(event?: Exclude<S, keyof RestEvents>) => this);
|
|
88
89
|
}
|
|
89
|
-
export type RestManagerTypes = CADManager | CMSManager;
|
|
90
|
+
export type RestManagerTypes = CADManager | CMSManager | RadioManager;
|
|
90
91
|
export declare class REST extends EventEmitter {
|
|
91
92
|
readonly requestManager: RequestManager;
|
|
92
93
|
readonly instance: Instance;
|
|
@@ -44,6 +44,11 @@ class REST extends events_1.EventEmitter {
|
|
|
44
44
|
apiKey = this.instance.cmsApiKey;
|
|
45
45
|
break;
|
|
46
46
|
}
|
|
47
|
+
case constants_2.productEnums.RADIO: {
|
|
48
|
+
communityId = this.instance.radioCommunityId;
|
|
49
|
+
apiKey = this.instance.radioApiKey;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
47
52
|
}
|
|
48
53
|
if (!communityId || !apiKey)
|
|
49
54
|
throw new Error(`Community ID or API Key could not be found for request. P${apiType.product}`);
|
|
@@ -59,6 +64,7 @@ class REST extends events_1.EventEmitter {
|
|
|
59
64
|
return this.requestManager.queueRequest(options);
|
|
60
65
|
}
|
|
61
66
|
formatDataArguments(type, args) {
|
|
67
|
+
var _a, _b, _c;
|
|
62
68
|
switch (type) {
|
|
63
69
|
case 'VERIFY_WHITELIST': {
|
|
64
70
|
return {
|
|
@@ -73,6 +79,9 @@ class REST extends events_1.EventEmitter {
|
|
|
73
79
|
serverId: args[0]
|
|
74
80
|
};
|
|
75
81
|
}
|
|
82
|
+
case 'SET_GAME_SERVERS': {
|
|
83
|
+
return (_a = args[0]) !== null && _a !== void 0 ? _a : [];
|
|
84
|
+
}
|
|
76
85
|
case 'RSVP': {
|
|
77
86
|
return {
|
|
78
87
|
eventId: args[0],
|
|
@@ -100,6 +109,64 @@ class REST extends events_1.EventEmitter {
|
|
|
100
109
|
uniqueId: args[4]
|
|
101
110
|
};
|
|
102
111
|
}
|
|
112
|
+
case 'GET_CURRENT_CLOCK_IN': {
|
|
113
|
+
return {
|
|
114
|
+
apiId: args[0],
|
|
115
|
+
username: args[1],
|
|
116
|
+
accId: args[2],
|
|
117
|
+
discord: args[3],
|
|
118
|
+
uniqueId: args[4]
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
case 'GET_ACCOUNTS': {
|
|
122
|
+
return (_b = args[0]) !== null && _b !== void 0 ? _b : {};
|
|
123
|
+
}
|
|
124
|
+
case 'GET_PROFILE_FIELDS': {
|
|
125
|
+
return {};
|
|
126
|
+
}
|
|
127
|
+
case 'SET_CLOCK': {
|
|
128
|
+
if (args[0] && typeof args[0] === 'object' && !Array.isArray(args[0])) {
|
|
129
|
+
return args[0];
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
serverId: args[0],
|
|
133
|
+
currentUtc: args[1],
|
|
134
|
+
currentGame: args[2],
|
|
135
|
+
secondsPerHour: args[3]
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
case 'JOIN_COMMUNITY':
|
|
139
|
+
case 'LEAVE_COMMUNITY': {
|
|
140
|
+
const payload = args[0] && typeof args[0] === 'object' && !Array.isArray(args[0]) && 'internalKey' in args[0]
|
|
141
|
+
? args[0]
|
|
142
|
+
: null;
|
|
143
|
+
const internalKey = payload ? payload.internalKey : args[0];
|
|
144
|
+
const accountsInput = payload ? payload.accounts : args[1];
|
|
145
|
+
let accounts = [];
|
|
146
|
+
if (Array.isArray(accountsInput)) {
|
|
147
|
+
accounts = accountsInput.map((entry) => {
|
|
148
|
+
if (typeof entry === 'string') {
|
|
149
|
+
return { account: entry };
|
|
150
|
+
}
|
|
151
|
+
if (entry && typeof entry === 'object' && 'account' in entry) {
|
|
152
|
+
return entry;
|
|
153
|
+
}
|
|
154
|
+
return { account: String(entry) };
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
else if (accountsInput) {
|
|
158
|
+
if (typeof accountsInput === 'string') {
|
|
159
|
+
accounts = [{ account: accountsInput }];
|
|
160
|
+
}
|
|
161
|
+
else if (typeof accountsInput === 'object' && 'account' in accountsInput) {
|
|
162
|
+
accounts = [accountsInput];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
internalKey,
|
|
167
|
+
accounts
|
|
168
|
+
};
|
|
169
|
+
}
|
|
103
170
|
case 'CLOCK_IN_OUT': {
|
|
104
171
|
return {
|
|
105
172
|
apiId: args[0],
|
|
@@ -131,6 +198,13 @@ class REST extends events_1.EventEmitter {
|
|
|
131
198
|
secret: args[0],
|
|
132
199
|
};
|
|
133
200
|
}
|
|
201
|
+
case 'GET_FORM_TEMPLATE_SUBMISSIONS': {
|
|
202
|
+
return {
|
|
203
|
+
templateId: args[0],
|
|
204
|
+
skip: args[1],
|
|
205
|
+
take: args[2],
|
|
206
|
+
};
|
|
207
|
+
}
|
|
134
208
|
case 'CHANGE_FORM_STAGE': {
|
|
135
209
|
return {
|
|
136
210
|
accId: args[0],
|
|
@@ -200,6 +274,11 @@ class REST extends events_1.EventEmitter {
|
|
|
200
274
|
robloxJoinCode: args[0]
|
|
201
275
|
};
|
|
202
276
|
}
|
|
277
|
+
case 'ERLC_GET_PLAYER_QUEUE': {
|
|
278
|
+
return {
|
|
279
|
+
robloxJoinCode: args[0]
|
|
280
|
+
};
|
|
281
|
+
}
|
|
203
282
|
case 'ERLC_ADD_NEW_RECORD': {
|
|
204
283
|
return {
|
|
205
284
|
robloxJoinCode: args[0],
|
|
@@ -211,6 +290,40 @@ class REST extends events_1.EventEmitter {
|
|
|
211
290
|
points: args[6],
|
|
212
291
|
};
|
|
213
292
|
}
|
|
293
|
+
case 'RADIO_GET_COMMUNITY_CHANNELS':
|
|
294
|
+
case 'RADIO_GET_CONNECTED_USERS':
|
|
295
|
+
case 'RADIO_GET_SERVER_SUBSCRIPTION_FROM_IP': {
|
|
296
|
+
return undefined;
|
|
297
|
+
}
|
|
298
|
+
case 'RADIO_GET_CONNECTED_USER': {
|
|
299
|
+
return {
|
|
300
|
+
roomId: args[0],
|
|
301
|
+
identity: args[1]
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
case 'RADIO_SET_USER_CHANNELS': {
|
|
305
|
+
return {
|
|
306
|
+
identity: args[0],
|
|
307
|
+
options: (_c = args[1]) !== null && _c !== void 0 ? _c : {}
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
case 'RADIO_SET_USER_DISPLAY_NAME': {
|
|
311
|
+
return {
|
|
312
|
+
accId: args[0],
|
|
313
|
+
displayName: args[1]
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
case 'RADIO_SET_SERVER_IP': {
|
|
317
|
+
return {
|
|
318
|
+
pushUrl: args[0]
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
case 'RADIO_SET_IN_GAME_SPEAKER_LOCATIONS': {
|
|
322
|
+
return {
|
|
323
|
+
locations: args[0],
|
|
324
|
+
token: args[1]
|
|
325
|
+
};
|
|
326
|
+
}
|
|
214
327
|
default: {
|
|
215
328
|
return args;
|
|
216
329
|
}
|