@serverkgg/bridge 0.0.21 → 0.1.2
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/package.json +3 -1
- package/src/bot/botDeploy.test.ts +363 -0
- package/src/bot/botDeploy.ts +136 -0
- package/src/bot/botEnvironment.test.ts +189 -0
- package/src/bot/botEnvironment.ts +141 -0
- package/src/bot/botIdentity.test.ts +251 -0
- package/src/bot/botIdentity.ts +140 -0
- package/src/bot/botPanel.test.ts +246 -0
- package/src/bot/botPanel.ts +129 -0
- package/src/bot/botState.test.ts +45 -0
- package/src/bot/botState.ts +54 -0
- package/src/bot/botTerminal.test.ts +79 -0
- package/src/bot/botTerminal.ts +62 -0
- package/src/bot/botVariables.test.ts +193 -0
- package/src/bot/botVariables.ts +73 -0
- package/src/bot/detect/botFramework.ts +23 -0
- package/src/bot/detect/botFrameworks.ts +198 -0
- package/src/bot/detect/botInspectWarning.ts +15 -0
- package/src/bot/detect/botPackageManager.ts +6 -0
- package/src/bot/detect/botPlatform.ts +10 -0
- package/src/bot/detect/botRuntime.ts +15 -0
- package/src/bot/detect/botToken.test.ts +71 -0
- package/src/bot/detect/botToken.ts +126 -0
- package/src/bot/detect/detect.test.ts +543 -0
- package/src/bot/detect/detect.ts +842 -0
- package/src/bot/detect/detectResult.ts +40 -0
- package/src/bot/detect/detectTable.test.ts +72 -0
- package/src/bot/detect/detectTable.ts +166 -0
- package/src/bot/detect/envExample.test.ts +29 -0
- package/src/bot/detect/envExample.ts +48 -0
- package/src/bot/detect/envKey.ts +7 -0
- package/src/bot/detect/envScan.test.ts +39 -0
- package/src/bot/detect/envScan.ts +87 -0
- package/src/bot/detect/index.ts +17 -0
- package/src/bot/detect/inferBotPlatform.test.ts +60 -0
- package/src/bot/detect/inferBotPlatform.ts +28 -0
- package/src/bot/detect/keys.test.ts +28 -0
- package/src/bot/detect/keys.ts +64 -0
- package/src/bot/detect/sensitiveKey.test.ts +91 -0
- package/src/bot/detect/sensitiveKey.ts +44 -0
- package/src/bot/detect/serverkJson.test.ts +88 -0
- package/src/bot/detect/serverkJson.ts +174 -0
- package/src/bot/index.ts +8 -0
- package/src/cli/detectTable.test.ts +66 -0
- package/src/cli/detectTable.ts +43 -0
- package/src/cli/main.ts +12 -4
- package/src/cli/renderedFile.ts +35 -0
- package/src/cli/schema.ts +7 -26
- package/src/cli/validate.test.ts +283 -3
- package/src/cli/validate.ts +105 -7
- package/src/context/bridgeContext.ts +17 -1
- package/src/core/bridgeAction.ts +2 -0
- package/src/core/bridgeActivity.ts +9 -0
- package/src/core/bridgeAvailability.ts +10 -0
- package/src/core/bridgePort.test.ts +45 -0
- package/src/core/bridgePort.ts +26 -0
- package/src/core/bridgeUserError.test.ts +10 -0
- package/src/core/bridgeUserError.ts +6 -2
- package/src/core/describeDownloadFailure.test.ts +58 -0
- package/src/core/describeDownloadFailure.ts +69 -0
- package/src/core/index.ts +3 -0
- package/src/guides/compile.ts +2 -2
- package/src/manifest/index.ts +1 -0
- package/src/manifest/kind.ts +5 -0
- package/src/manifest/manifest.test.ts +630 -3
- package/src/manifest/manifest.ts +391 -87
- package/src/manifest/runtime.ts +2 -2
- package/src/manifest/source.ts +4 -4
- package/src/modules/bridge.ts +8 -1
- package/src/modules/bridgeLifecycleSubject.ts +8 -0
- package/src/modules/bridgeModule.ts +19 -1
- package/src/modules/bridgeStopSignal.ts +13 -0
- package/src/modules/index.ts +2 -0
- package/src/panel/bridgeDetail.ts +4 -1
- package/src/protocol/bridgeActivity.ts +54 -0
- package/src/protocol/bridgeConfig.ts +2 -0
- package/src/protocol/bridgeEvents.ts +30 -0
- package/src/protocol/bridgeFrame.ts +10 -1
- package/src/protocol/index.ts +1 -0
- package/src/runtime/bridgeActions.ts +19 -2
- package/src/runtime/bridgeActivity.test.ts +318 -0
- package/src/runtime/bridgeActivity.ts +268 -0
- package/src/runtime/bridgeConfigReader.test.ts +80 -0
- package/src/runtime/bridgeConfigReader.ts +20 -0
- package/src/runtime/bridgeContext.test.ts +247 -0
- package/src/runtime/bridgeContext.ts +43 -10
- package/src/runtime/bridgeDriver.test.ts +153 -1
- package/src/runtime/bridgeDriver.ts +64 -8
- package/src/runtime/bridgeFiles.test.ts +62 -0
- package/src/runtime/bridgeFiles.ts +12 -2
- package/src/runtime/bridgeLiveConfig.ts +18 -0
- package/src/runtime/bridgeLog.ts +10 -0
- package/src/runtime/bridgeRedaction.test.ts +410 -0
- package/src/runtime/bridgeRedaction.ts +214 -0
- package/src/runtime/bridgeRefusalError.ts +13 -0
- package/src/runtime/bridgeRegistry.test.ts +1056 -10
- package/src/runtime/bridgeRegistry.ts +464 -50
- package/src/runtime/bridgeScopedContext.ts +55 -0
- package/src/runtime/bridgeServer.test.ts +534 -4
- package/src/runtime/bridgeServer.ts +145 -38
- package/src/runtime/bridgeSetupHandlers.test.ts +156 -5
- package/src/runtime/bridgeSetupHandlers.ts +59 -14
- package/src/runtime/bridgeSupervisor.test.ts +670 -2
- package/src/runtime/bridgeSupervisor.ts +219 -67
- package/src/runtime/serve.ts +87 -11
- package/src/steam/steamcmd.test.ts +32 -1
- package/src/steam/steamcmd.ts +27 -4
- package/src/utils/changedSettingKeys.test.ts +65 -0
- package/src/utils/changedSettingKeys.ts +6 -0
- package/src/utils/describeExecFailure.test.ts +34 -0
- package/src/utils/describeExecFailure.ts +9 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/sameSettingValue.test.ts +35 -0
- package/src/utils/sameSettingValue.ts +40 -0
- package/src/wire/activity.test.ts +95 -0
- package/src/wire/activity.ts +41 -0
- package/src/wire/index.ts +1 -0
- package/src/wire/panel.test.ts +67 -1
- package/src/wire/panel.ts +11 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { BridgeDownloadError } from "./bridgeDownloadError";
|
|
3
|
+
import { BridgeNetError } from "./bridgeNetError";
|
|
4
|
+
import { describeDownloadFailure } from "./describeDownloadFailure";
|
|
5
|
+
|
|
6
|
+
const SUBJECT = "All the Mods 9";
|
|
7
|
+
|
|
8
|
+
describe("describeDownloadFailure", () => {
|
|
9
|
+
test("says the file is gone for 404 and 410", () => {
|
|
10
|
+
for (const status of [
|
|
11
|
+
404,
|
|
12
|
+
410,
|
|
13
|
+
]) {
|
|
14
|
+
expect(describeDownloadFailure(new BridgeDownloadError(status, "gone"), SUBJECT).en).toBe(
|
|
15
|
+
"All the Mods 9 is no longer available from its source.",
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("says the source refused for 401 and 403", () => {
|
|
21
|
+
expect(describeDownloadFailure(new BridgeNetError(403, "forbidden"), SUBJECT).en).toBe(
|
|
22
|
+
"The source refused the download of All the Mods 9.",
|
|
23
|
+
);
|
|
24
|
+
expect(describeDownloadFailure(new BridgeDownloadError(401, "unauthorized"), SUBJECT).ar).toBe(
|
|
25
|
+
"المصدر رفض تنزيل All the Mods 9.",
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("says the source is busy for 429", () => {
|
|
30
|
+
expect(describeDownloadFailure(new BridgeDownloadError(429, "slow down"), SUBJECT).en).toContain("busy");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("says the source is down for a 5xx", () => {
|
|
34
|
+
expect(describeDownloadFailure(new BridgeNetError(503, "unavailable"), SUBJECT).en).toBe(
|
|
35
|
+
"The source of All the Mods 9 is down right now. Try again in a bit.",
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("says the source could not be reached when there is no status", () => {
|
|
40
|
+
expect(describeDownloadFailure(new BridgeDownloadError(null, "ECONNRESET"), SUBJECT).en).toBe(
|
|
41
|
+
"We could not reach the source to download All the Mods 9. Try again.",
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("falls back to a plain download failure for anything else", () => {
|
|
46
|
+
const generic = "We could not download All the Mods 9. Try again.";
|
|
47
|
+
|
|
48
|
+
expect(describeDownloadFailure(new BridgeDownloadError(400, "bad request"), SUBJECT).en).toBe(generic);
|
|
49
|
+
expect(describeDownloadFailure(new Error("digest mismatch"), SUBJECT).en).toBe(generic);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("always writes both languages", () => {
|
|
53
|
+
const text = describeDownloadFailure(new BridgeDownloadError(500, "boom"), SUBJECT);
|
|
54
|
+
|
|
55
|
+
expect(text.ar.length).toBeGreaterThan(0);
|
|
56
|
+
expect(text.en.length).toBeGreaterThan(0);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { BridgeDownloadError } from "./bridgeDownloadError";
|
|
2
|
+
import { BridgeNetError } from "./bridgeNetError";
|
|
3
|
+
import type { LocalizedText } from "./bridgeValue";
|
|
4
|
+
|
|
5
|
+
const REMOVED_STATUSES: readonly number[] = [
|
|
6
|
+
404,
|
|
7
|
+
410,
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
const REFUSED_STATUSES: readonly number[] = [
|
|
11
|
+
401,
|
|
12
|
+
403,
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const BUSY_STATUS = 429;
|
|
16
|
+
|
|
17
|
+
const SERVER_ERROR_STATUS = 500;
|
|
18
|
+
|
|
19
|
+
const statusOf = (error: unknown): number | null | undefined => {
|
|
20
|
+
if (error instanceof BridgeDownloadError || error instanceof BridgeNetError) {
|
|
21
|
+
return error.status;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return undefined;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const describeDownloadFailure = (error: unknown, subject: string): LocalizedText => {
|
|
28
|
+
const status = statusOf(error);
|
|
29
|
+
|
|
30
|
+
if (status === null) {
|
|
31
|
+
return {
|
|
32
|
+
ar: `ما قدرنا نوصل للمصدر عشان ننزّل ${subject}. جرّب مرة ثانية.`,
|
|
33
|
+
en: `We could not reach the source to download ${subject}. Try again.`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (status !== undefined && REMOVED_STATUSES.includes(status)) {
|
|
38
|
+
return {
|
|
39
|
+
ar: `${subject} ما عاد موجود عند المصدر.`,
|
|
40
|
+
en: `${subject} is no longer available from its source.`,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (status !== undefined && REFUSED_STATUSES.includes(status)) {
|
|
45
|
+
return {
|
|
46
|
+
ar: `المصدر رفض تنزيل ${subject}.`,
|
|
47
|
+
en: `The source refused the download of ${subject}.`,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (status === BUSY_STATUS) {
|
|
52
|
+
return {
|
|
53
|
+
ar: `المصدر مشغول الحين وما قدرنا ننزّل ${subject}. جرّب بعد شوي.`,
|
|
54
|
+
en: `The source is busy right now, so we could not download ${subject}. Try again in a bit.`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (status !== undefined && status >= SERVER_ERROR_STATUS) {
|
|
59
|
+
return {
|
|
60
|
+
ar: `مصدر ${subject} فيه عطل الحين. جرّب بعد شوي.`,
|
|
61
|
+
en: `The source of ${subject} is down right now. Try again in a bit.`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
ar: `ما قدرنا ننزّل ${subject}. جرّب مرة ثانية.`,
|
|
67
|
+
en: `We could not download ${subject}. Try again.`,
|
|
68
|
+
};
|
|
69
|
+
};
|
package/src/core/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./bridgeAction";
|
|
2
|
+
export * from "./bridgeActivity";
|
|
3
|
+
export * from "./bridgeAvailability";
|
|
2
4
|
export * from "./bridgeDownloadError";
|
|
3
5
|
export * from "./bridgeFailure";
|
|
4
6
|
export * from "./bridgeHold";
|
|
@@ -14,3 +16,4 @@ export * from "./bridgeSetup";
|
|
|
14
16
|
export * from "./bridgeStream";
|
|
15
17
|
export * from "./bridgeUserError";
|
|
16
18
|
export * from "./bridgeValue";
|
|
19
|
+
export * from "./describeDownloadFailure";
|
package/src/guides/compile.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { verifyAsset } from "../manifest/assets";
|
|
2
2
|
import type { GuideEntry, GuideSurface, GuideTag } from "../manifest/guide";
|
|
3
3
|
import type { LocalizedText } from "../manifest/localized";
|
|
4
|
-
import type { GuidePackage,
|
|
4
|
+
import type { GuidePackage, RunnableManifest } from "../manifest/manifest";
|
|
5
5
|
import type { PackageSource } from "../manifest/source";
|
|
6
6
|
import type { GuideBlock, GuideLeafBlock } from "./blocks";
|
|
7
7
|
import { type CompiledGuide, type CompiledGuideTag, compiledGuideSchema } from "./compiled";
|
|
@@ -140,7 +140,7 @@ export const compileGuides = (source: PackageSource, guideTags: GuideTag[], entr
|
|
|
140
140
|
};
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
-
export const readGuidePack = (source: PackageSource, manifest:
|
|
143
|
+
export const readGuidePack = (source: PackageSource, manifest: RunnableManifest): GuidePack | null => {
|
|
144
144
|
if (manifest.guides.length === 0) {
|
|
145
145
|
return null;
|
|
146
146
|
}
|
package/src/manifest/index.ts
CHANGED