@serverkgg/bridge 0.0.1 → 0.0.3
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 +10 -3
- package/src/cli/link.test.ts +199 -0
- package/src/cli/link.ts +319 -0
- package/src/cli/main.ts +19 -1
- package/src/cli/schema.ts +62 -0
- package/src/cli/validate.test.ts +89 -0
- package/src/cli/validate.ts +218 -35
- package/src/context/bridgeContext.ts +18 -2
- package/src/core/bridgeAction.ts +13 -0
- package/src/core/bridgeFailure.ts +16 -0
- package/src/core/bridgeKind.ts +3 -0
- package/src/core/bridgeNetError.ts +10 -0
- package/src/core/index.ts +2 -0
- package/src/guides/blocks.ts +167 -0
- package/src/guides/compile.ts +193 -0
- package/src/guides/compiled.ts +28 -0
- package/src/guides/index.ts +6 -0
- package/src/guides/markdown.test.ts +374 -0
- package/src/guides/markdown.ts +769 -0
- package/src/guides/variables.ts +52 -0
- package/src/guides/version.ts +1 -0
- package/src/main.ts +2 -1
- package/src/manifest/assets.ts +4 -4
- package/src/manifest/guide.ts +23 -18
- package/src/manifest/index.ts +3 -2
- package/src/manifest/jsonSchema.ts +16 -0
- package/src/manifest/localized.ts +7 -0
- package/src/manifest/manifest.test.ts +366 -0
- package/src/manifest/manifest.ts +354 -120
- package/src/manifest/primitives.ts +63 -0
- package/src/manifest/source.ts +5 -4
- package/src/modules/bridge.ts +25 -4
- package/src/modules/bridgeDriver.ts +4 -0
- package/src/modules/bridgeModule.ts +36 -24
- package/src/panel/bridgeAccess.ts +3 -0
- package/src/panel/bridgeLayout.ts +1 -0
- package/src/panel/bridgePanel.ts +40 -2
- package/src/panel/index.ts +1 -0
- package/src/protocol/bridgeCatalog.ts +57 -0
- package/src/protocol/bridgeEgress.ts +53 -0
- package/src/protocol/bridgeEvents.ts +20 -0
- package/src/protocol/bridgeFrame.ts +16 -0
- package/src/protocol/bridgeLimits.ts +41 -0
- package/src/protocol/bridgeLine.ts +41 -6
- package/src/protocol/bridgeManifest.ts +15 -1
- package/src/protocol/bridgeVersion.ts +1 -1
- package/src/protocol/index.ts +5 -0
- package/src/runtime/bridgeActions.ts +53 -0
- package/src/runtime/bridgeContext.ts +29 -9
- package/src/runtime/bridgeDriver.test.ts +450 -0
- package/src/runtime/bridgeDriver.ts +246 -6
- package/src/runtime/bridgeEgress.ts +360 -0
- package/src/runtime/bridgeEvents.ts +4 -1
- package/src/runtime/bridgeExec.ts +15 -5
- package/src/runtime/bridgeFiles.test.ts +334 -0
- package/src/runtime/bridgeFiles.ts +130 -31
- package/src/runtime/bridgeLog.ts +26 -3
- package/src/runtime/bridgeNet.ts +75 -22
- package/src/runtime/bridgeRegistry.test.ts +291 -0
- package/src/runtime/bridgeRegistry.ts +91 -52
- package/src/runtime/bridgeServer.ts +35 -3
- package/src/runtime/bridgeSupervisor.ts +6 -6
- package/src/runtime/bridgeZip.ts +14 -3
- package/src/runtime/index.ts +0 -17
- package/src/runtime/serve.ts +44 -3
- package/src/terminal/bridgeTerminalArg.ts +11 -0
- package/src/terminal/bridgeTerminalCommand.ts +11 -0
- package/src/terminal/bridgeTerminalLevel.ts +6 -0
- package/src/terminal/bridgeTerminalRule.ts +8 -0
- package/src/terminal/index.ts +4 -0
- package/src/manifest/checks.ts +0 -50
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { BridgeContext } from "../context";
|
|
2
2
|
import type { BridgeKind, BridgeOption, BridgeRow, BridgeStream, BridgeValues } from "../core";
|
|
3
|
+
import type { BridgeCatalogEntry, BridgeCatalogPage, BridgeCatalogQuery } from "../protocol/bridgeCatalog";
|
|
4
|
+
import type { BridgeDescribeResult } from "../protocol/bridgeFrame";
|
|
5
|
+
import type { BridgeTerminalCommand, BridgeTerminalRule } from "../terminal";
|
|
6
|
+
|
|
7
|
+
export type BridgeDescription = Omit<BridgeDescribeResult, "supported">;
|
|
3
8
|
|
|
4
9
|
export interface BridgeInstallModule {
|
|
5
10
|
kind: BridgeKind.Install;
|
|
6
11
|
run(context: BridgeContext): Promise<void>;
|
|
12
|
+
describe?(context: BridgeContext): Promise<BridgeDescription>;
|
|
7
13
|
}
|
|
8
14
|
|
|
9
15
|
export interface BridgeLifecycleModule {
|
|
@@ -15,6 +21,11 @@ export interface BridgeLifecycleModule {
|
|
|
15
21
|
onReady?(context: BridgeContext): Promise<void>;
|
|
16
22
|
}
|
|
17
23
|
|
|
24
|
+
export interface BridgeAnnounceModule {
|
|
25
|
+
kind: BridgeKind.Announce;
|
|
26
|
+
announce(context: BridgeContext, message: string): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
|
|
18
29
|
export interface BridgeBackupModule {
|
|
19
30
|
kind: BridgeKind.Backup;
|
|
20
31
|
settleSeconds?: number;
|
|
@@ -42,6 +53,13 @@ export interface BridgeEventPattern {
|
|
|
42
53
|
export interface BridgeEventsModule {
|
|
43
54
|
kind: BridgeKind.Events;
|
|
44
55
|
patterns: BridgeEventPattern[];
|
|
56
|
+
emits?: string[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface BridgeTerminalModule {
|
|
60
|
+
kind: BridgeKind.Terminal;
|
|
61
|
+
commands: BridgeTerminalCommand[];
|
|
62
|
+
rules?: BridgeTerminalRule[];
|
|
45
63
|
}
|
|
46
64
|
|
|
47
65
|
export interface BridgeOptionsModule {
|
|
@@ -57,7 +75,19 @@ export interface BridgeSettingsModule {
|
|
|
57
75
|
write?(context: BridgeContext, values: BridgeValues): Promise<void>;
|
|
58
76
|
}
|
|
59
77
|
|
|
60
|
-
export type BridgeRowAction<Row extends BridgeRow = BridgeRow> = (
|
|
78
|
+
export type BridgeRowAction<Row extends BridgeRow = BridgeRow> = (
|
|
79
|
+
context: BridgeContext,
|
|
80
|
+
row: Row,
|
|
81
|
+
args: BridgeValues,
|
|
82
|
+
) => Promise<void>;
|
|
83
|
+
|
|
84
|
+
export type BridgeServerAction = (context: BridgeContext, args: BridgeValues) => Promise<void>;
|
|
85
|
+
|
|
86
|
+
export interface BridgeActionsModule {
|
|
87
|
+
kind: BridgeKind.Actions;
|
|
88
|
+
requiresRunning?: boolean;
|
|
89
|
+
actions: Record<string, BridgeServerAction>;
|
|
90
|
+
}
|
|
61
91
|
|
|
62
92
|
export interface BridgeCollectionModule<Row extends BridgeRow = BridgeRow> {
|
|
63
93
|
kind: BridgeKind.Collection;
|
|
@@ -68,45 +98,27 @@ export interface BridgeCollectionModule<Row extends BridgeRow = BridgeRow> {
|
|
|
68
98
|
actions?: Record<string, BridgeRowAction<Row>>;
|
|
69
99
|
}
|
|
70
100
|
|
|
71
|
-
export interface BridgeCatalogHit {
|
|
72
|
-
id: string;
|
|
73
|
-
title: string;
|
|
74
|
-
description: string;
|
|
75
|
-
icon: string | null;
|
|
76
|
-
downloads: number;
|
|
77
|
-
pageUrl?: string | null;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface BridgeCatalogPage {
|
|
81
|
-
hits: BridgeCatalogHit[];
|
|
82
|
-
total: number;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface BridgeCatalogEntry {
|
|
86
|
-
id: string;
|
|
87
|
-
path: string;
|
|
88
|
-
title: string;
|
|
89
|
-
version: string | null;
|
|
90
|
-
sizeBytes: number;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
101
|
export interface BridgeCatalogModule {
|
|
94
102
|
kind: BridgeKind.Catalog;
|
|
95
103
|
pageSize?: number;
|
|
96
|
-
search(context: BridgeContext, query:
|
|
104
|
+
search(context: BridgeContext, query: BridgeCatalogQuery): Promise<BridgeCatalogPage>;
|
|
97
105
|
installed(context: BridgeContext): Promise<BridgeCatalogEntry[]>;
|
|
98
106
|
install(context: BridgeContext, id: string): Promise<BridgeCatalogEntry>;
|
|
99
107
|
remove(context: BridgeContext, id: string): Promise<void>;
|
|
108
|
+
toggle?(context: BridgeContext, id: string, enabled: boolean): Promise<void>;
|
|
100
109
|
}
|
|
101
110
|
|
|
102
111
|
export type BridgePanelModule =
|
|
112
|
+
| BridgeActionsModule
|
|
103
113
|
| BridgeCatalogModule
|
|
104
114
|
| BridgeCollectionModule
|
|
105
115
|
| BridgeOptionsModule
|
|
106
116
|
| BridgeSettingsModule;
|
|
107
117
|
|
|
108
118
|
export type BridgeModule =
|
|
119
|
+
| BridgeAnnounceModule
|
|
109
120
|
| BridgeBackupModule
|
|
121
|
+
| BridgeTerminalModule
|
|
110
122
|
| BridgeEventsModule
|
|
111
123
|
| BridgeInstallModule
|
|
112
124
|
| BridgeLifecycleModule
|
package/src/panel/bridgePanel.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BridgeOption, LocalizedText } from "../core";
|
|
2
|
+
import type { BridgeAccess } from "./bridgeAccess";
|
|
2
3
|
import type { BridgeConfirm } from "./bridgeConfirm";
|
|
3
4
|
import type { BridgeControl } from "./bridgeControl";
|
|
4
5
|
import type { BridgeFormTarget } from "./bridgeFormTarget";
|
|
@@ -7,7 +8,8 @@ import type { BridgeLayout } from "./bridgeLayout";
|
|
|
7
8
|
|
|
8
9
|
export interface BridgeVisibleWhen {
|
|
9
10
|
variable: string;
|
|
10
|
-
values
|
|
11
|
+
values?: string[];
|
|
12
|
+
empty?: boolean;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export interface BridgeOptionsRef {
|
|
@@ -33,6 +35,9 @@ export interface BridgeSectionAction {
|
|
|
33
35
|
id: string;
|
|
34
36
|
label: LocalizedText;
|
|
35
37
|
confirm?: BridgeConfirm;
|
|
38
|
+
confirmText?: LocalizedText;
|
|
39
|
+
download?: boolean;
|
|
40
|
+
fields?: BridgeField[];
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
export interface BridgeSectionAdd {
|
|
@@ -40,6 +45,23 @@ export interface BridgeSectionAdd {
|
|
|
40
45
|
placeholder?: string;
|
|
41
46
|
}
|
|
42
47
|
|
|
48
|
+
export interface BridgeSectionUpload {
|
|
49
|
+
label: LocalizedText;
|
|
50
|
+
extensions: string[];
|
|
51
|
+
staging: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface BridgeActionsSection {
|
|
55
|
+
layout: BridgeLayout.Actions;
|
|
56
|
+
id: string;
|
|
57
|
+
title?: LocalizedText;
|
|
58
|
+
help?: LocalizedText;
|
|
59
|
+
module: string;
|
|
60
|
+
actions: BridgeSectionAction[];
|
|
61
|
+
visibleWhen?: BridgeVisibleWhen;
|
|
62
|
+
access?: BridgeAccess;
|
|
63
|
+
}
|
|
64
|
+
|
|
43
65
|
export interface BridgeFormSection {
|
|
44
66
|
layout: BridgeLayout.Form;
|
|
45
67
|
id: string;
|
|
@@ -52,6 +74,7 @@ export interface BridgeFormSection {
|
|
|
52
74
|
confirmText?: LocalizedText;
|
|
53
75
|
fields: BridgeField[];
|
|
54
76
|
visibleWhen?: BridgeVisibleWhen;
|
|
77
|
+
access?: BridgeAccess;
|
|
55
78
|
}
|
|
56
79
|
|
|
57
80
|
export interface BridgeColumn {
|
|
@@ -64,11 +87,14 @@ export interface BridgeTableSection {
|
|
|
64
87
|
id: string;
|
|
65
88
|
title?: LocalizedText;
|
|
66
89
|
module: string;
|
|
90
|
+
restartHint?: boolean;
|
|
67
91
|
columns: BridgeColumn[];
|
|
68
92
|
add?: BridgeSectionAdd;
|
|
93
|
+
upload?: BridgeSectionUpload;
|
|
69
94
|
actions?: BridgeSectionAction[];
|
|
70
95
|
empty?: LocalizedText;
|
|
71
96
|
visibleWhen?: BridgeVisibleWhen;
|
|
97
|
+
access?: BridgeAccess;
|
|
72
98
|
}
|
|
73
99
|
|
|
74
100
|
export interface BridgeCardsSection {
|
|
@@ -81,6 +107,7 @@ export interface BridgeCardsSection {
|
|
|
81
107
|
actions?: BridgeSectionAction[];
|
|
82
108
|
empty?: LocalizedText;
|
|
83
109
|
visibleWhen?: BridgeVisibleWhen;
|
|
110
|
+
access?: BridgeAccess;
|
|
84
111
|
}
|
|
85
112
|
|
|
86
113
|
export interface BridgeCatalogSection {
|
|
@@ -89,17 +116,28 @@ export interface BridgeCatalogSection {
|
|
|
89
116
|
title?: LocalizedText;
|
|
90
117
|
module: string;
|
|
91
118
|
restartHint?: boolean;
|
|
119
|
+
reinstall?: boolean;
|
|
120
|
+
variable?: string;
|
|
121
|
+
confirm?: BridgeConfirm;
|
|
122
|
+
confirmText?: LocalizedText;
|
|
92
123
|
empty?: LocalizedText;
|
|
93
124
|
visibleWhen?: BridgeVisibleWhen;
|
|
125
|
+
access?: BridgeAccess;
|
|
94
126
|
}
|
|
95
127
|
|
|
96
|
-
export type BridgeSection =
|
|
128
|
+
export type BridgeSection =
|
|
129
|
+
| BridgeActionsSection
|
|
130
|
+
| BridgeCardsSection
|
|
131
|
+
| BridgeCatalogSection
|
|
132
|
+
| BridgeFormSection
|
|
133
|
+
| BridgeTableSection;
|
|
97
134
|
|
|
98
135
|
export interface BridgeTab {
|
|
99
136
|
id: string;
|
|
100
137
|
title: LocalizedText;
|
|
101
138
|
icon?: BridgeIcon;
|
|
102
139
|
sections: BridgeSection[];
|
|
140
|
+
access?: BridgeAccess;
|
|
103
141
|
}
|
|
104
142
|
|
|
105
143
|
export interface BridgePanel {
|
package/src/panel/index.ts
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { LocalizedText } from "../core";
|
|
2
|
+
|
|
3
|
+
export interface BridgeCatalogProvider {
|
|
4
|
+
id: string;
|
|
5
|
+
label: LocalizedText;
|
|
6
|
+
ready: boolean;
|
|
7
|
+
note?: LocalizedText;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface BridgeCatalogFacet {
|
|
11
|
+
value: string;
|
|
12
|
+
label: LocalizedText;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface BridgeCatalogHit {
|
|
16
|
+
id: string;
|
|
17
|
+
provider: string;
|
|
18
|
+
title: string;
|
|
19
|
+
description: string;
|
|
20
|
+
icon: string | null;
|
|
21
|
+
downloads: number;
|
|
22
|
+
author: string | null;
|
|
23
|
+
categories: string[];
|
|
24
|
+
updatedAt: string | null;
|
|
25
|
+
pageUrl: string | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface BridgeCatalogPage {
|
|
29
|
+
hits: BridgeCatalogHit[];
|
|
30
|
+
total: number;
|
|
31
|
+
providers: BridgeCatalogProvider[];
|
|
32
|
+
categories: BridgeCatalogFacet[];
|
|
33
|
+
sorts: BridgeCatalogFacet[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface BridgeCatalogEntry {
|
|
37
|
+
id: string;
|
|
38
|
+
provider: string | null;
|
|
39
|
+
path: string;
|
|
40
|
+
title: string;
|
|
41
|
+
version: string | null;
|
|
42
|
+
sizeBytes: number;
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
gameVersion: string | null;
|
|
45
|
+
stale: boolean;
|
|
46
|
+
pageUrl: string | null;
|
|
47
|
+
icon: string | null;
|
|
48
|
+
variables?: Record<string, string> | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface BridgeCatalogQuery {
|
|
52
|
+
query: string;
|
|
53
|
+
page: number;
|
|
54
|
+
provider: string | null;
|
|
55
|
+
category: string | null;
|
|
56
|
+
sort: string | null;
|
|
57
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const BRIDGE_EGRESS_SOCKET_NAME = "egress.sock";
|
|
2
|
+
|
|
3
|
+
export const BRIDGE_EGRESS_FRAME_LIMIT = 16 * 1024 * 1024;
|
|
4
|
+
|
|
5
|
+
export const BRIDGE_EGRESS_BODY_LIMIT = 8 * 1024 * 1024;
|
|
6
|
+
|
|
7
|
+
export const BRIDGE_EGRESS_DOWNLOAD_LIMIT = 512 * 1024 * 1024;
|
|
8
|
+
|
|
9
|
+
export enum BridgeEgressMethod {
|
|
10
|
+
Fetch = "fetch",
|
|
11
|
+
Download = "download",
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface BridgeEgressRequest {
|
|
15
|
+
id: number;
|
|
16
|
+
token: string;
|
|
17
|
+
method: BridgeEgressMethod;
|
|
18
|
+
url: string;
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
timeoutMs?: number;
|
|
21
|
+
cache?: boolean;
|
|
22
|
+
cacheSeconds?: number;
|
|
23
|
+
refresh?: boolean;
|
|
24
|
+
digest?: string;
|
|
25
|
+
sizeBytes?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface BridgeEgressFetchResult {
|
|
29
|
+
status: number;
|
|
30
|
+
body: string;
|
|
31
|
+
fromCache: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface BridgeEgressDownloadResult {
|
|
35
|
+
status: number;
|
|
36
|
+
sizeBytes: number;
|
|
37
|
+
fromCache: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface BridgeEgressSuccess<Result> {
|
|
41
|
+
id: number | null;
|
|
42
|
+
ok: true;
|
|
43
|
+
result: Result;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface BridgeEgressFailure {
|
|
47
|
+
id: number | null;
|
|
48
|
+
ok: false;
|
|
49
|
+
error: string;
|
|
50
|
+
status: number | null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type BridgeEgressResponse<Result> = BridgeEgressFailure | BridgeEgressSuccess<Result>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export enum BridgeEventName {
|
|
2
|
+
GameModeChanged = "GameModeChanged",
|
|
3
|
+
MissingDependency = "MissingDependency",
|
|
4
|
+
PlayerJoined = "PlayerJoined",
|
|
5
|
+
PlayerLeft = "PlayerLeft",
|
|
6
|
+
PortBindFailed = "PortBindFailed",
|
|
7
|
+
ServerCrashed = "ServerCrashed",
|
|
8
|
+
ServerStarted = "ServerStarted",
|
|
9
|
+
ServerStopping = "ServerStopping",
|
|
10
|
+
TickLagging = "TickLagging",
|
|
11
|
+
WorldCorrupt = "WorldCorrupt",
|
|
12
|
+
WorldSaved = "WorldSaved",
|
|
13
|
+
WrongJavaVersion = "WrongJavaVersion",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const BRIDGE_EVENT_NAMES: readonly string[] = Object.values(BridgeEventName);
|
|
17
|
+
|
|
18
|
+
export const isBridgeEventName = (name: string): boolean => {
|
|
19
|
+
return BRIDGE_EVENT_NAMES.includes(name);
|
|
20
|
+
};
|
|
@@ -13,7 +13,9 @@ export const BRIDGE_FRAME_LIMIT = 1024 * 1024;
|
|
|
13
13
|
export const BRIDGE_INSTALL_ERROR_LIMIT = 2048;
|
|
14
14
|
|
|
15
15
|
export enum BridgeMethod {
|
|
16
|
+
Announce = "announce",
|
|
16
17
|
Command = "command",
|
|
18
|
+
Describe = "describe",
|
|
17
19
|
Events = "events",
|
|
18
20
|
Invoke = "invoke",
|
|
19
21
|
Manifest = "manifest",
|
|
@@ -36,6 +38,7 @@ export interface BridgeRequest {
|
|
|
36
38
|
action?: string;
|
|
37
39
|
args?: BridgeValues;
|
|
38
40
|
cursor?: number;
|
|
41
|
+
message?: string;
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
export interface BridgeCommandResult {
|
|
@@ -55,6 +58,7 @@ export interface BridgeFailure {
|
|
|
55
58
|
ok: false;
|
|
56
59
|
error: string;
|
|
57
60
|
secret?: string;
|
|
61
|
+
failure?: string;
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
export type BridgeResponse = BridgeFailure | BridgeSuccess;
|
|
@@ -73,12 +77,24 @@ export interface BridgeSampleResult {
|
|
|
73
77
|
max: number | null;
|
|
74
78
|
}
|
|
75
79
|
|
|
80
|
+
export interface BridgeAnnounceResult {
|
|
81
|
+
supported: boolean;
|
|
82
|
+
delivered: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
76
85
|
export interface BridgeQuiesceResult {
|
|
77
86
|
supported: boolean;
|
|
78
87
|
quiesced: boolean;
|
|
79
88
|
settleSeconds: number;
|
|
80
89
|
}
|
|
81
90
|
|
|
91
|
+
export interface BridgeDescribeResult {
|
|
92
|
+
supported: boolean;
|
|
93
|
+
version: string | null;
|
|
94
|
+
variant: string | null;
|
|
95
|
+
build: string | null;
|
|
96
|
+
}
|
|
97
|
+
|
|
82
98
|
export interface BridgeEvent {
|
|
83
99
|
seq: number;
|
|
84
100
|
event: string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const BRIDGE_PANEL_TABS_LIMIT = 8;
|
|
2
|
+
|
|
3
|
+
export const BRIDGE_TAB_SECTIONS_LIMIT = 8;
|
|
4
|
+
|
|
5
|
+
export const BRIDGE_FORM_FIELDS_LIMIT = 32;
|
|
6
|
+
|
|
7
|
+
export const BRIDGE_TABLE_COLUMNS_LIMIT = 8;
|
|
8
|
+
|
|
9
|
+
export const BRIDGE_ROW_ACTIONS_LIMIT = 8;
|
|
10
|
+
|
|
11
|
+
export const BRIDGE_SECTION_ACTIONS_LIMIT = 10;
|
|
12
|
+
|
|
13
|
+
export const BRIDGE_ACTION_FIELDS_LIMIT = 5;
|
|
14
|
+
|
|
15
|
+
export const BRIDGE_FIELD_OPTIONS_LIMIT = 64;
|
|
16
|
+
|
|
17
|
+
export const BRIDGE_VISIBLE_VALUES_LIMIT = 16;
|
|
18
|
+
|
|
19
|
+
export const BRIDGE_UPLOAD_EXTENSIONS_LIMIT = 8;
|
|
20
|
+
|
|
21
|
+
export const BRIDGE_MODULES_LIMIT = 32;
|
|
22
|
+
|
|
23
|
+
export const BRIDGE_MODULE_ACTIONS_LIMIT = 16;
|
|
24
|
+
|
|
25
|
+
export const BRIDGE_DEPENDS_ON_LIMIT = 8;
|
|
26
|
+
|
|
27
|
+
export const BRIDGE_EVENTS_LIMIT = 32;
|
|
28
|
+
|
|
29
|
+
export const BRIDGE_ID_LENGTH_LIMIT = 32;
|
|
30
|
+
|
|
31
|
+
export const BRIDGE_KEY_LENGTH_LIMIT = 64;
|
|
32
|
+
|
|
33
|
+
export const BRIDGE_TEXT_LENGTH_LIMIT = 512;
|
|
34
|
+
|
|
35
|
+
export const BRIDGE_OPTION_VALUE_LENGTH_LIMIT = 128;
|
|
36
|
+
|
|
37
|
+
export const BRIDGE_PLACEHOLDER_LENGTH_LIMIT = 256;
|
|
38
|
+
|
|
39
|
+
export const BRIDGE_STAGING_LENGTH_LIMIT = 128;
|
|
40
|
+
|
|
41
|
+
export const BRIDGE_EXTENSION_LENGTH_LIMIT = 16;
|
|
@@ -1,10 +1,31 @@
|
|
|
1
|
+
import { BridgeTerminalLevel } from "../terminal";
|
|
2
|
+
|
|
1
3
|
export const BRIDGE_LOG_SOURCE = "bridge";
|
|
2
4
|
|
|
5
|
+
const FIELD_LIMIT = 16;
|
|
6
|
+
|
|
7
|
+
const FIELD_KEY_LIMIT = 64;
|
|
8
|
+
|
|
9
|
+
const FIELD_VALUE_LIMIT = 512;
|
|
10
|
+
|
|
3
11
|
export interface BridgeLogLine {
|
|
12
|
+
level: BridgeTerminalLevel;
|
|
4
13
|
message: string;
|
|
5
|
-
|
|
14
|
+
fields: Record<string, string>;
|
|
6
15
|
}
|
|
7
16
|
|
|
17
|
+
const LEVELS = new Set<string>(Object.values(BridgeTerminalLevel));
|
|
18
|
+
|
|
19
|
+
const levelOf = (value: unknown): BridgeTerminalLevel => {
|
|
20
|
+
return typeof value === "string" && LEVELS.has(value) ? (value as BridgeTerminalLevel) : BridgeTerminalLevel.Info;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const textOf = (value: unknown) => {
|
|
24
|
+
const text = typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
|
|
25
|
+
|
|
26
|
+
return text.slice(0, FIELD_VALUE_LIMIT);
|
|
27
|
+
};
|
|
28
|
+
|
|
8
29
|
export const parseBridgeLine = (line: string): BridgeLogLine | null => {
|
|
9
30
|
if (!line.startsWith("{") || !line.endsWith("}")) {
|
|
10
31
|
return null;
|
|
@@ -28,13 +49,27 @@ export const parseBridgeLine = (line: string): BridgeLogLine | null => {
|
|
|
28
49
|
return null;
|
|
29
50
|
}
|
|
30
51
|
|
|
31
|
-
const fields =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
52
|
+
const fields: Record<string, string> = {};
|
|
53
|
+
|
|
54
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
55
|
+
if (key === "source" || key === "message" || key === "level" || key === "driver") {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (key.length > FIELD_KEY_LIMIT) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (Object.keys(fields).length >= FIELD_LIMIT) {
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
fields[key] = textOf(value);
|
|
68
|
+
}
|
|
35
69
|
|
|
36
70
|
return {
|
|
71
|
+
level: levelOf(entry.level),
|
|
37
72
|
message: entry.message,
|
|
38
|
-
|
|
73
|
+
fields,
|
|
39
74
|
};
|
|
40
75
|
};
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import type { BridgeKind } from "../core";
|
|
1
|
+
import type { BridgeKind, BridgeStream } from "../core";
|
|
2
2
|
import type { BridgePanel } from "../panel";
|
|
3
|
+
import type { BridgeTerminalCommand, BridgeTerminalLevel } from "../terminal";
|
|
4
|
+
|
|
5
|
+
export interface BridgeTerminalRuleManifest {
|
|
6
|
+
match: string;
|
|
7
|
+
flags: string;
|
|
8
|
+
level: BridgeTerminalLevel;
|
|
9
|
+
stream?: BridgeStream;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface BridgeTerminalManifest {
|
|
13
|
+
commands: BridgeTerminalCommand[];
|
|
14
|
+
rules: BridgeTerminalRuleManifest[];
|
|
15
|
+
}
|
|
3
16
|
|
|
4
17
|
export interface BridgeModuleManifest {
|
|
5
18
|
id: string;
|
|
@@ -14,6 +27,7 @@ export interface BridgeModuleManifest {
|
|
|
14
27
|
export interface BridgeManifest {
|
|
15
28
|
version: string;
|
|
16
29
|
panel: BridgePanel | null;
|
|
30
|
+
terminal: BridgeTerminalManifest | null;
|
|
17
31
|
modules: BridgeModuleManifest[];
|
|
18
32
|
events: string[];
|
|
19
33
|
}
|
package/src/protocol/index.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
export * from "../core";
|
|
2
2
|
export * from "../panel";
|
|
3
|
+
export * from "../terminal";
|
|
4
|
+
export * from "./bridgeCatalog";
|
|
3
5
|
export * from "./bridgeConfig";
|
|
6
|
+
export * from "./bridgeEgress";
|
|
7
|
+
export * from "./bridgeEvents";
|
|
4
8
|
export * from "./bridgeFrame";
|
|
9
|
+
export * from "./bridgeLimits";
|
|
5
10
|
export * from "./bridgeLine";
|
|
6
11
|
export * from "./bridgeManifest";
|
|
7
12
|
export * from "./bridgeVersion";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { BridgeAction, BridgeKind } from "../core";
|
|
2
|
+
import type { BridgePanelModule } from "../modules";
|
|
3
|
+
|
|
4
|
+
export const actionsOf = (module: BridgePanelModule): string[] => {
|
|
5
|
+
switch (module.kind) {
|
|
6
|
+
case BridgeKind.Actions: {
|
|
7
|
+
return Object.keys(module.actions);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
case BridgeKind.Options: {
|
|
11
|
+
return [
|
|
12
|
+
BridgeAction.List,
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
case BridgeKind.Settings: {
|
|
17
|
+
return [
|
|
18
|
+
BridgeAction.Read,
|
|
19
|
+
...(module.write
|
|
20
|
+
? [
|
|
21
|
+
BridgeAction.Write,
|
|
22
|
+
]
|
|
23
|
+
: []),
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
case BridgeKind.Collection: {
|
|
28
|
+
return [
|
|
29
|
+
BridgeAction.List,
|
|
30
|
+
...(module.add
|
|
31
|
+
? [
|
|
32
|
+
BridgeAction.Add,
|
|
33
|
+
]
|
|
34
|
+
: []),
|
|
35
|
+
...Object.keys(module.actions ?? {}),
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
case BridgeKind.Catalog: {
|
|
40
|
+
return [
|
|
41
|
+
BridgeAction.Install,
|
|
42
|
+
BridgeAction.Installed,
|
|
43
|
+
BridgeAction.Remove,
|
|
44
|
+
BridgeAction.Search,
|
|
45
|
+
...(module.toggle
|
|
46
|
+
? [
|
|
47
|
+
BridgeAction.Toggle,
|
|
48
|
+
]
|
|
49
|
+
: []),
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|