@serverkgg/bridge 0.0.9 → 0.0.11
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 +1 -1
- package/src/cli/validate.test.ts +116 -1
- package/src/cli/validate.ts +50 -3
- package/src/context/bridgeContext.ts +8 -1
- package/src/core/bridgeKind.ts +1 -0
- package/src/core/bridgeProbeError.ts +16 -0
- package/src/core/bridgeSetup.ts +20 -0
- package/src/core/bridgeValue.test.ts +29 -0
- package/src/core/bridgeValue.ts +12 -0
- package/src/core/index.ts +2 -0
- package/src/guides/blocks.ts +8 -0
- package/src/guides/markdown.test.ts +18 -0
- package/src/guides/markdown.ts +7 -1
- package/src/manifest/guide.ts +1 -0
- package/src/manifest/manifest.test.ts +49 -2
- package/src/manifest/presence.ts +9 -1
- package/src/modules/bridge.ts +20 -0
- package/src/modules/bridgeDriver.ts +2 -0
- package/src/modules/bridgeModule.ts +7 -0
- package/src/panel/bridgeControl.ts +1 -0
- package/src/panel/bridgeDetail.ts +6 -5
- package/src/panel/bridgePanel.ts +2 -0
- package/src/probes/a2s.test.ts +71 -0
- package/src/probes/a2s.ts +38 -11
- package/src/protocol/bridgeFrame.ts +5 -0
- package/src/protocol/bridgeLimits.ts +10 -0
- package/src/protocol/bridgeManifest.ts +2 -0
- package/src/protocol/bridgeSetup.ts +97 -0
- package/src/protocol/index.ts +1 -0
- package/src/runtime/bridgeConfigReader.ts +12 -8
- package/src/runtime/bridgeContext.ts +28 -2
- package/src/runtime/bridgeDriver.test.ts +512 -2
- package/src/runtime/bridgeDriver.ts +219 -1
- package/src/runtime/bridgeEvents.test.ts +96 -0
- package/src/runtime/bridgeEvents.ts +4 -1
- package/src/runtime/bridgeRegistry.test.ts +38 -1
- package/src/runtime/bridgeRegistry.ts +14 -1
- package/src/runtime/bridgeSecrets.test.ts +121 -0
- package/src/runtime/bridgeSecrets.ts +43 -0
- package/src/runtime/bridgeServer.test.ts +262 -2
- package/src/runtime/bridgeServer.ts +17 -0
- package/src/runtime/bridgeSetup.test.ts +575 -0
- package/src/runtime/bridgeSetup.ts +303 -0
- package/src/runtime/bridgeSetupHandlers.test.ts +303 -0
- package/src/runtime/bridgeSetupHandlers.ts +71 -0
- package/src/runtime/bridgeSignal.test.ts +114 -0
- package/src/runtime/bridgeSignal.ts +31 -0
- package/src/runtime/bridgeSupervisor.test.ts +111 -0
- package/src/runtime/bridgeSupervisor.ts +37 -5
- package/src/runtime/serve.ts +19 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/stripAnsi.ts +12 -0
- package/src/wire/panel.test.ts +155 -0
- package/src/wire/panel.ts +43 -0
package/src/wire/panel.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { guideOpenTargetSchema } from "@serverkgg/bridge/guides";
|
|
1
2
|
import {
|
|
2
3
|
BRIDGE_ID_PATTERN,
|
|
3
4
|
BRIDGE_MODULE_ID_PATTERN,
|
|
5
|
+
BRIDGE_PATTERN_LENGTH_LIMIT,
|
|
4
6
|
BridgeAccess,
|
|
5
7
|
BridgeConfirm,
|
|
6
8
|
BridgeControl,
|
|
@@ -11,6 +13,9 @@ import {
|
|
|
11
13
|
type BridgeManifest,
|
|
12
14
|
type BridgePanel,
|
|
13
15
|
type BridgeSection,
|
|
16
|
+
type BridgeSetupManifest,
|
|
17
|
+
type BridgeSetupStep,
|
|
18
|
+
BridgeSetupStepKind,
|
|
14
19
|
BridgeStream,
|
|
15
20
|
type BridgeTerminalArg,
|
|
16
21
|
type BridgeTerminalCommand,
|
|
@@ -30,6 +35,10 @@ const SECTION_ACTIONS_LIMIT = 10;
|
|
|
30
35
|
|
|
31
36
|
const FORM_CLEARS_LIMIT = 8;
|
|
32
37
|
|
|
38
|
+
const SETUP_STEPS_LIMIT = 8;
|
|
39
|
+
|
|
40
|
+
const SETUP_STEP_FIELDS_LIMIT = 32;
|
|
41
|
+
|
|
33
42
|
const zKey = z
|
|
34
43
|
.string()
|
|
35
44
|
.min(1)
|
|
@@ -92,6 +101,8 @@ export const bridgeFieldSchema = z.object({
|
|
|
92
101
|
max: z.number().optional(),
|
|
93
102
|
step: z.number().optional(),
|
|
94
103
|
maxLength: z.int().positive().optional(),
|
|
104
|
+
pattern: z.string().max(BRIDGE_PATTERN_LENGTH_LIMIT).optional(),
|
|
105
|
+
patternHint: panelTextSchema.optional(),
|
|
95
106
|
options: z
|
|
96
107
|
.union([
|
|
97
108
|
z.array(bridgeOptionSchema).max(64),
|
|
@@ -276,6 +287,37 @@ export const bridgeTerminalManifestSchema: z.ZodType<BridgeTerminalManifest> = z
|
|
|
276
287
|
rules: z.array(bridgeTerminalRuleSchema).max(64),
|
|
277
288
|
});
|
|
278
289
|
|
|
290
|
+
const setupStepBase = {
|
|
291
|
+
id: zBridgeId,
|
|
292
|
+
title: panelTextSchema,
|
|
293
|
+
help: panelTextSchema.optional(),
|
|
294
|
+
required: z.boolean().optional(),
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
export const bridgeSetupStepSchema: z.ZodType<BridgeSetupStep> = z.discriminatedUnion("kind", [
|
|
298
|
+
z.object({
|
|
299
|
+
...setupStepBase,
|
|
300
|
+
kind: z.literal(BridgeSetupStepKind.Driver),
|
|
301
|
+
requiresRunning: z.boolean().optional(),
|
|
302
|
+
}),
|
|
303
|
+
z.object({
|
|
304
|
+
...setupStepBase,
|
|
305
|
+
kind: z.literal(BridgeSetupStepKind.Form),
|
|
306
|
+
tab: zBridgeId,
|
|
307
|
+
section: zBridgeId,
|
|
308
|
+
fields: z.array(zKey).max(SETUP_STEP_FIELDS_LIMIT).optional(),
|
|
309
|
+
}),
|
|
310
|
+
z.object({
|
|
311
|
+
...setupStepBase,
|
|
312
|
+
kind: z.literal(BridgeSetupStepKind.Open),
|
|
313
|
+
target: guideOpenTargetSchema,
|
|
314
|
+
}),
|
|
315
|
+
]);
|
|
316
|
+
|
|
317
|
+
export const bridgeSetupManifestSchema: z.ZodType<BridgeSetupManifest> = z.object({
|
|
318
|
+
steps: z.array(bridgeSetupStepSchema).min(1).max(SETUP_STEPS_LIMIT),
|
|
319
|
+
});
|
|
320
|
+
|
|
279
321
|
export const bridgeModuleManifestSchema = z.object({
|
|
280
322
|
id: zBridgeModuleId,
|
|
281
323
|
kind: z.enum(BridgeKind),
|
|
@@ -290,6 +332,7 @@ export const bridgeManifestSchema: z.ZodType<BridgeManifest> = z.object({
|
|
|
290
332
|
version: z.string(),
|
|
291
333
|
panel: bridgePanelSchema.nullable(),
|
|
292
334
|
terminal: bridgeTerminalManifestSchema.nullable().default(null),
|
|
335
|
+
setup: bridgeSetupManifestSchema.nullable().default(null),
|
|
293
336
|
modules: z.array(bridgeModuleManifestSchema).max(32),
|
|
294
337
|
events: z.array(z.string().min(1).max(64)).max(32),
|
|
295
338
|
});
|