@ksp-gonogo/sitrep-sdk 0.0.1
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/LICENSE +32 -0
- package/README.md +75 -0
- package/dist/__generated__/contract.d.ts +936 -0
- package/dist/__generated__/contract.d.ts.map +1 -0
- package/dist/__generated__/contract.js +143 -0
- package/dist/__generated__/contract.js.map +1 -0
- package/dist/__generated__/topic-map.d.ts +58 -0
- package/dist/__generated__/topic-map.d.ts.map +1 -0
- package/dist/__generated__/topic-map.js +66 -0
- package/dist/__generated__/topic-map.js.map +1 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +18 -0
- package/dist/client.js.map +1 -0
- package/dist/envelope.d.ts +4 -0
- package/dist/envelope.d.ts.map +1 -0
- package/dist/envelope.js +2 -0
- package/dist/envelope.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/topics.d.ts +46 -0
- package/dist/topics.d.ts.map +1 -0
- package/dist/topics.js +49 -0
- package/dist/topics.js.map +1 -0
- package/package.json +32 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jon Pepler
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
This license applies ONLY to the Sitrep.Contract assembly (and its generated
|
|
26
|
+
TypeScript counterpart, @ksp-gonogo/sitrep-sdk in mod/sitrep-sdk). It is a
|
|
27
|
+
deliberate permissive carve-out from the rest of the gonogo/Sitrep codebase,
|
|
28
|
+
which is licensed GPL-3.0-only (see the repository root LICENSE) because it
|
|
29
|
+
directly links kOS. Sitrep.Contract ships no kOS code and exists specifically
|
|
30
|
+
so that third-party Uplinks — under any license, including proprietary or
|
|
31
|
+
GPLv2 — can reference the public telemetry contract without inheriting GPL
|
|
32
|
+
obligations.
|
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @ksp-gonogo/sitrep-sdk
|
|
2
|
+
|
|
3
|
+
`@ksp-gonogo/sitrep-*` is the Gonogo telemetry mod, codename Sitrep.
|
|
4
|
+
|
|
5
|
+
TypeScript client SDK for the gonogo-native telemetry mod. The wire contract
|
|
6
|
+
(message envelopes, `Meta`, enums) is defined once in C# and generated into
|
|
7
|
+
this package — the SDK never redefines the shape by hand.
|
|
8
|
+
|
|
9
|
+
## Generated code — do not hand-edit
|
|
10
|
+
|
|
11
|
+
`src/__generated__/contract.ts` is produced by
|
|
12
|
+
[Reinforced.Typings](https://github.com/reinforced/Reinforced.Typings) from
|
|
13
|
+
the C# source of truth in `mod/Sitrep.Contract/`. The file carries its own
|
|
14
|
+
"generated, changes will be lost" header — treat that as load-bearing, not
|
|
15
|
+
boilerplate. If a type needs to change, change the C# class (or
|
|
16
|
+
`mod/Sitrep.Contract/RtConfig.cs` for export configuration) and regenerate;
|
|
17
|
+
never patch the emitted `.ts` directly.
|
|
18
|
+
|
|
19
|
+
Regenerate from the repo root:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm codegen
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This runs `mod/codegen.sh`, which builds `Sitrep.Contract.csproj` and invokes
|
|
26
|
+
the `rtcli` tool against the compiled assembly to rewrite
|
|
27
|
+
`src/__generated__/contract.ts`.
|
|
28
|
+
|
|
29
|
+
## The drift gate
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm codegen:check
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Regenerates the contract and then runs `git diff --exit-code` against
|
|
36
|
+
`src/__generated__/`. A non-zero exit means one of two things:
|
|
37
|
+
|
|
38
|
+
- The C# contract changed and the generated output is out of date — commit
|
|
39
|
+
the regenerated file alongside the C# change.
|
|
40
|
+
- The build is non-deterministic (unexpected member/type ordering from
|
|
41
|
+
reflection) — this should not happen; see `RtConfig.Configure` if it ever
|
|
42
|
+
does, since RT export order is explicit there rather than left to
|
|
43
|
+
`GetProperties()` reflection order.
|
|
44
|
+
|
|
45
|
+
This is the check that should run in CI once dotnet is wired into the CI
|
|
46
|
+
image (tracked separately) — for now, run it locally before committing any
|
|
47
|
+
change under `mod/Sitrep.Contract/`.
|
|
48
|
+
|
|
49
|
+
## The hand-owned seams: `envelope.ts` and `client.ts`
|
|
50
|
+
|
|
51
|
+
`src/envelope.ts` defines `ServerMessage` and `ClientMessage` as discriminated
|
|
52
|
+
unions over the generated interfaces (`StreamData<unknown> | EventMsg | ...`).
|
|
53
|
+
Reinforced.Typings emits one interface per C# class — it has no way to know
|
|
54
|
+
which subset of those interfaces the transport layer treats as a "server
|
|
55
|
+
message" versus a "client message," so that grouping is authored by hand in
|
|
56
|
+
this file instead of generated. `envelope.ts` is covered by tests
|
|
57
|
+
(`envelope.test.ts`) and is the only source file in this package that isn't
|
|
58
|
+
derived from `__generated__/contract.ts`; everything else (`client.ts`,
|
|
59
|
+
`index.ts`) is built on top of the generated types plus this one seam.
|
|
60
|
+
|
|
61
|
+
`src/client.ts` has a second, smaller hand-owned seam: `SERVER_TYPE_TAGS`, the
|
|
62
|
+
runtime lookup `parseServerMessage` uses to validate an incoming envelope's
|
|
63
|
+
`type` tag against the `ServerMessage` union. It's a second hand-owned copy of
|
|
64
|
+
the union's membership (a `Set` can't be derived from a type at runtime), but
|
|
65
|
+
it's compile-time-guarded — `SERVER_TYPE_TAGS` is declared `satisfies
|
|
66
|
+
Record<ServerMessage["type"], true>`, so adding a variant to `ServerMessage`
|
|
67
|
+
without adding its tag to `SERVER_TYPE_TAGS` fails `tsc`.
|
|
68
|
+
|
|
69
|
+
## Usage
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { parseServerMessage, type ServerMessage } from "@ksp-gonogo/sitrep-sdk";
|
|
73
|
+
|
|
74
|
+
const msg: ServerMessage = parseServerMessage(rawJson);
|
|
75
|
+
```
|