@gcoredev/fastedge-test 0.0.1-beta.4 → 0.1.0-beta.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.
Files changed (41) hide show
  1. package/README.md +6 -6
  2. package/dist/fastedge-cli/METADATA.json +1 -3
  3. package/dist/fastedge-cli/{fastedge-run-linux-x64-unkown → fastedge-run-darwin-arm64} +0 -0
  4. package/dist/fastedge-cli/fastedge-run-linux-x64 +0 -0
  5. package/dist/fastedge-cli/fastedge-run.exe +0 -0
  6. package/dist/frontend/assets/index-CEFjsU8e.js +35 -0
  7. package/dist/frontend/assets/index-DdlINQc_.css +1 -0
  8. package/dist/frontend/index.html +2 -2
  9. package/dist/lib/index.cjs +299 -107
  10. package/dist/lib/index.js +301 -110
  11. package/dist/lib/runner/HostFunctions.d.ts +8 -0
  12. package/dist/lib/runner/HttpWasmRunner.d.ts +34 -14
  13. package/dist/lib/runner/IStateManager.d.ts +3 -2
  14. package/dist/lib/runner/IWasmRunner.d.ts +16 -1
  15. package/dist/lib/runner/NullStateManager.d.ts +1 -0
  16. package/dist/lib/runner/PortManager.d.ts +17 -19
  17. package/dist/lib/runner/ProxyWasmRunner.d.ts +7 -0
  18. package/dist/lib/schemas/api.d.ts +8 -2
  19. package/dist/lib/schemas/config.d.ts +4 -1
  20. package/dist/lib/test-framework/index.cjs +301 -108
  21. package/dist/lib/test-framework/index.js +303 -111
  22. package/dist/lib/test-framework/suite-runner.d.ts +1 -1
  23. package/dist/server.js +30 -29
  24. package/docs/API.md +758 -360
  25. package/docs/DEBUGGER.md +151 -0
  26. package/docs/INDEX.md +111 -0
  27. package/docs/RUNNER.md +582 -0
  28. package/docs/TEST_CONFIG.md +242 -0
  29. package/docs/TEST_FRAMEWORK.md +384 -284
  30. package/docs/WEBSOCKET.md +499 -0
  31. package/docs/quickstart.md +171 -0
  32. package/llms.txt +72 -14
  33. package/package.json +15 -5
  34. package/schemas/api-config.schema.json +12 -5
  35. package/schemas/api-load.schema.json +11 -6
  36. package/schemas/{test-config.schema.json → fastedge-config.test.schema.json} +12 -5
  37. package/dist/fastedge-cli/.gitkeep +0 -0
  38. package/dist/frontend/assets/index-CnXStFTd.css +0 -1
  39. package/dist/frontend/assets/index-FR9Oqsow.js +0 -37
  40. package/docs/HYBRID_LOADING.md +0 -546
  41. package/docs/LOCAL_SERVER.md +0 -153
@@ -0,0 +1,151 @@
1
+ # Debugger Server
2
+
3
+ Runs the FastEdge debugger HTTP server, which hosts the web UI, REST API, and WebSocket endpoint for loading and testing WASM modules.
4
+
5
+ ## CLI Usage
6
+
7
+ The package exposes a `fastedge-debug` binary. Run it with `npx` without installing:
8
+
9
+ ```bash
10
+ npx @gcoredev/fastedge-test
11
+ ```
12
+
13
+ Or using the explicit binary name:
14
+
15
+ ```bash
16
+ npx fastedge-debug
17
+ ```
18
+
19
+ Once started, the server listens on `http://localhost:5179` by default and logs the bound address to stdout.
20
+
21
+ ## Programmatic Usage
22
+
23
+ Import `startServer` from the `./server` export to start the server from your own script or test setup:
24
+
25
+ ```typescript
26
+ import { startServer } from "@gcoredev/fastedge-test/server";
27
+
28
+ // Start on the default port (5179)
29
+ await startServer();
30
+
31
+ // Start on a custom port
32
+ await startServer(3000);
33
+ ```
34
+
35
+ **Signature:**
36
+
37
+ ```typescript
38
+ function startServer(port?: number): Promise<void>;
39
+ ```
40
+
41
+ The returned promise resolves once the server is bound and ready to accept connections.
42
+
43
+ **Example: start and stop in a test setup**
44
+
45
+ ```typescript
46
+ import { startServer } from "@gcoredev/fastedge-test/server";
47
+
48
+ // Start server for integration tests
49
+ await startServer(5200);
50
+
51
+ // ... run tests ...
52
+
53
+ // Send SIGTERM to trigger graceful shutdown
54
+ process.kill(process.pid, "SIGTERM");
55
+ ```
56
+
57
+ ## Port Configuration
58
+
59
+ | Source | Value |
60
+ | -------------- | --------------------- |
61
+ | Default | `5179` |
62
+ | `PORT` env var | Any valid port number |
63
+
64
+ ```bash
65
+ PORT=8080 npx fastedge-debug
66
+ ```
67
+
68
+ When `WORKSPACE_PATH` is set, the server writes the bound port number to `$WORKSPACE_PATH/.debug-port` on startup and deletes it on shutdown.
69
+
70
+ ## Health Check
71
+
72
+ ```
73
+ GET /health
74
+ ```
75
+
76
+ Returns `200 OK` with a JSON body:
77
+
78
+ ```json
79
+ {
80
+ "status": "ok",
81
+ "service": "fastedge-debugger"
82
+ }
83
+ ```
84
+
85
+ Use this endpoint to verify the server is running before sending requests. The `service` field is always `"fastedge-debugger"`.
86
+
87
+ ```bash
88
+ curl http://localhost:5179/health
89
+ ```
90
+
91
+ ## Environment Variables
92
+
93
+ | Variable | Type | Default | Description |
94
+ | -------------------- | -------- | ------- | --------------------------------------------------------------------------------------------- |
95
+ | `PORT` | `number` | `5179` | Port the HTTP server listens on |
96
+ | `PROXY_RUNNER_DEBUG` | `"1"` | unset | Enable verbose debug logging for WebSocket and runner activity |
97
+ | `WORKSPACE_PATH` | `string` | unset | Absolute path to the workspace root; used as the `.env` file base and for port file placement |
98
+ | `FASTEDGE_RUN_PATH` | `string` | unset | Override the path to the `fastedge-run` CLI binary used to execute WASM modules |
99
+
100
+ ### Usage examples
101
+
102
+ ```bash
103
+ # Enable debug logging
104
+ PROXY_RUNNER_DEBUG=1 npx fastedge-debug
105
+
106
+ # Use a non-default port with debug logging
107
+ PORT=8080 PROXY_RUNNER_DEBUG=1 npx fastedge-debug
108
+
109
+ # Point to a workspace and override the fastedge-run binary
110
+ WORKSPACE_PATH=/home/user/myproject \
111
+ FASTEDGE_RUN_PATH=/usr/local/bin/fastedge-run \
112
+ npx fastedge-debug
113
+ ```
114
+
115
+ ## Graceful Shutdown
116
+
117
+ The server handles `SIGTERM` and `SIGINT`:
118
+
119
+ 1. Logs the received signal
120
+ 2. Cleans up the active WASM runner (frees memory, closes child processes)
121
+ 3. Closes all WebSocket connections
122
+ 4. Deletes the `.debug-port` file (if `WORKSPACE_PATH` is set)
123
+ 5. Closes the HTTP server
124
+ 6. Exits with code `0`
125
+
126
+ The `.debug-port` file is also deleted on the Node.js `exit` event, which covers Windows environments where `SIGTERM` is not delivered.
127
+
128
+ Send `SIGTERM` to trigger shutdown programmatically:
129
+
130
+ ```bash
131
+ kill -SIGTERM <pid>
132
+ ```
133
+
134
+ Or press `Ctrl+C` in the terminal to send `SIGINT`.
135
+
136
+ ## Web UI
137
+
138
+ When the server starts, it serves a browser-based UI at the root URL:
139
+
140
+ ```
141
+ http://localhost:5179
142
+ ```
143
+
144
+ The UI provides a graphical interface for loading WASM modules, configuring requests, and inspecting results. All UI interactions use the same REST and WebSocket endpoints available to API consumers.
145
+
146
+ ## See Also
147
+
148
+ - [API.md](API.md) — REST endpoint reference for loading WASM, sending requests, and managing configuration
149
+ - [WEBSOCKET.md](WEBSOCKET.md) — WebSocket protocol, event types, and real-time state updates
150
+ - [TEST_FRAMEWORK.md](TEST_FRAMEWORK.md) — Programmatic test framework for writing automated WASM tests
151
+ - [TEST_CONFIG.md](TEST_CONFIG.md) — `fastedge-config.test.json` schema and configuration options
package/docs/INDEX.md ADDED
@@ -0,0 +1,111 @@
1
+ # fastedge-test Documentation
2
+
3
+ `@gcoredev/fastedge-test` — local test runner and debugger for FastEdge WASM modules.
4
+
5
+ ## Documentation Files
6
+
7
+ | File | Audience | Description |
8
+ | --------------------------------------- | --------------------- | ------------------------------------------------------------------------------------------------ |
9
+ | [quickstart.md](quickstart.md) | All users | Install, configure, and run your first test in under five minutes |
10
+ | [TEST_FRAMEWORK.md](TEST_FRAMEWORK.md) | Test authors | High-level API (`defineTestSuite`, `runTestSuite`, assertions) for writing automated test suites |
11
+ | [TEST_CONFIG.md](TEST_CONFIG.md) | Test authors | `fastedge-config.test.json` schema — all fields, defaults, and validation rules |
12
+ | [RUNNER.md](RUNNER.md) | Advanced / CI tooling | Low-level programmatic API for direct runner lifecycle control |
13
+ | [DEBUGGER.md](DEBUGGER.md) | All users | `fastedge-debug` CLI — starting the interactive debugger server |
14
+ | [API.md](API.md) | Tooling integrators | HTTP REST API exposed by the debugger server |
15
+ | [WEBSOCKET.md](WEBSOCKET.md) | Tooling integrators | WebSocket event stream API for real-time server events |
16
+
17
+ ## Quick Links
18
+
19
+ | Goal | Start here |
20
+ | ------------------------------------------------ | -------------------------------------- |
21
+ | Writing tests for a WASM module | [TEST_FRAMEWORK.md](TEST_FRAMEWORK.md) |
22
+ | Understanding the test config file format | [TEST_CONFIG.md](TEST_CONFIG.md) |
23
+ | Running the interactive debugger UI | [DEBUGGER.md](DEBUGGER.md) |
24
+ | Building custom CI or automation tooling | [API.md](API.md) |
25
+ | Subscribing to real-time server events | [WEBSOCKET.md](WEBSOCKET.md) |
26
+ | Direct runner control without the test framework | [RUNNER.md](RUNNER.md) |
27
+ | First time using this package | [quickstart.md](quickstart.md) |
28
+
29
+ ## Package Exports
30
+
31
+ | Entry point | Description |
32
+ | ----------- | ---------------------------------------------------------------------------------------------- |
33
+ | `.` | Main entry — runner API and core types |
34
+ | `./test` | Test framework API — use this for writing and running test suites |
35
+ | `./server` | Debugger server entry — used by the `fastedge-debug` CLI binary; not intended for direct import |
36
+ | `./schemas` | JSON Schema files for `fastedge-config.test.json` — reference in editors for validation |
37
+
38
+ ### `@gcoredev/fastedge-test` (`.`)
39
+
40
+ Exports the low-level runner API. See [RUNNER.md](RUNNER.md) for full reference.
41
+
42
+ ```typescript
43
+ import { createRunner, createRunnerFromBuffer } from "@gcoredev/fastedge-test";
44
+ ```
45
+
46
+ | Export | Kind | Description |
47
+ | ---------------------- | -------- | --------------------------------------------------------- |
48
+ | `createRunner` | function | Creates a runner instance from a WASM file path |
49
+ | `createRunnerFromBuffer` | function | Creates a runner instance from a `Buffer` or `Uint8Array` |
50
+ | `ProxyWasmRunner` | class | Runner implementation for proxy-wasm (CDN) modules |
51
+ | `HttpWasmRunner` | class | Runner implementation for HTTP WASM modules |
52
+ | `WasmRunnerFactory` | class | Factory for creating the appropriate runner by WASM type |
53
+ | `NullStateManager` | class | No-op state manager for stateless runner use |
54
+ | `IWasmRunner` | type | Interface all runner implementations satisfy |
55
+ | `IStateManager` | type | Interface for runner state managers |
56
+ | `WasmType` | type | Union of supported WASM module types |
57
+ | `RunnerConfig` | type | Configuration options passed to runner constructors |
58
+ | `HttpRequest` | type | HTTP request shape used by the runner |
59
+ | `HttpResponse` | type | HTTP response shape returned by the runner |
60
+ | `HookResult` | type | Result of a single proxy-wasm hook invocation |
61
+ | `FullFlowResult` | type | Aggregated result of a complete request flow |
62
+ | `HookCall` | type | Descriptor for a proxy-wasm hook call |
63
+
64
+ ### `@gcoredev/fastedge-test/test`
65
+
66
+ Exports the high-level test framework. See [TEST_FRAMEWORK.md](TEST_FRAMEWORK.md) for full reference.
67
+
68
+ ```typescript
69
+ import { defineTestSuite, runAndExit } from "@gcoredev/fastedge-test/test";
70
+ ```
71
+
72
+ | Export | Kind | Description |
73
+ | ------------------------- | -------- | -------------------------------------------------------------------- |
74
+ | `defineTestSuite` | function | Validates and returns a typed `TestSuite` definition |
75
+ | `runTestSuite` | function | Executes a `TestSuite` and returns a `SuiteResult` |
76
+ | `runAndExit` | function | Runs a suite and exits the process with a pass/fail code |
77
+ | `runFlow` | function | Executes a single request flow directly |
78
+ | `loadConfigFile` | function | Loads and validates a `fastedge-config.test.json` file |
79
+ | `assertRequestHeader` | function | Asserts a header is present on the outgoing request |
80
+ | `assertNoRequestHeader` | function | Asserts a header is absent from the outgoing request |
81
+ | `assertResponseHeader` | function | Asserts a header is present on the final response |
82
+ | `assertNoResponseHeader` | function | Asserts a header is absent from the final response |
83
+ | `assertFinalStatus` | function | Asserts the final HTTP status code |
84
+ | `assertFinalHeader` | function | Asserts a header on the final response (alias for response header) |
85
+ | `assertReturnCode` | function | Asserts the proxy-wasm return code |
86
+ | `assertLog` | function | Asserts a log entry was emitted |
87
+ | `assertNoLog` | function | Asserts a log entry was not emitted |
88
+ | `logsContain` | function | Returns whether logs contain a matching entry |
89
+ | `hasPropertyAccessViolation` | function | Returns whether any property access violation was recorded |
90
+ | `assertPropertyAllowed` | function | Asserts that a WASM property read was allowed |
91
+ | `assertPropertyDenied` | function | Asserts that a WASM property read was denied |
92
+ | `TestSuite` | type | Suite definition — one of `wasmPath` or `wasmBuffer` plus test cases |
93
+ | `TestCase` | type | A single test scenario with config and assertions |
94
+ | `TestResult` | type | Result of a single test case execution |
95
+ | `SuiteResult` | type | Aggregated result returned by `runTestSuite` |
96
+ | `FlowOptions` | type | Options accepted by `runFlow` |
97
+ | `RunnerConfig` | type | Configuration options for the underlying runner |
98
+
99
+ ### `@gcoredev/fastedge-test/server`
100
+
101
+ The debugger server entrypoint. This export is used internally by the `fastedge-debug` binary and is not intended for direct import. Start the server via the CLI instead — see [DEBUGGER.md](DEBUGGER.md).
102
+
103
+ ### `@gcoredev/fastedge-test/schemas`
104
+
105
+ Directory of JSON Schema files. Point your editor's `$schema` field at the appropriate file to enable validation and autocompletion in `fastedge-config.test.json`. See [TEST_CONFIG.md](TEST_CONFIG.md) for usage.
106
+
107
+ ## Internal Documentation
108
+
109
+ Contributors and developers working in this repository should refer to the internal context documentation:
110
+
111
+ - [`context/CONTEXT_INDEX.md`](../context/CONTEXT_INDEX.md) — discovery-based index of all internal developer docs