@thoughts-on-things/beacon-protocol 0.0.0-stage → 0.0.0
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 +201 -0
- package/README.md +27 -2
- package/dist/beacon-management.d.ts +203 -0
- package/dist/beacon-management.d.ts.map +1 -0
- package/dist/beacon-management.js +94 -0
- package/dist/beacon-management.js.map +1 -0
- package/dist/directory.d.ts +100 -0
- package/dist/directory.d.ts.map +1 -0
- package/dist/directory.js +12 -0
- package/dist/directory.js.map +1 -0
- package/dist/fixtures.d.ts +141 -0
- package/dist/fixtures.d.ts.map +1 -0
- package/dist/fixtures.js +141 -0
- package/dist/fixtures.js.map +1 -0
- package/dist/index.d.ts +430 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +455 -0
- package/dist/index.js.map +1 -0
- package/dist/mod-relay.d.ts +26 -0
- package/dist/mod-relay.d.ts.map +1 -0
- package/dist/mod-relay.js +79 -0
- package/dist/mod-relay.js.map +1 -0
- package/dist/play.d.ts +57 -0
- package/dist/play.d.ts.map +1 -0
- package/dist/play.js +122 -0
- package/dist/play.js.map +1 -0
- package/dist/publish.d.ts +117 -0
- package/dist/publish.d.ts.map +1 -0
- package/dist/publish.js +133 -0
- package/dist/publish.js.map +1 -0
- package/package.json +66 -3
- package/src/beacon-management.ts +210 -0
- package/src/directory.ts +115 -0
- package/src/fixtures.ts +169 -0
- package/src/index.ts +538 -0
- package/src/mod-relay.ts +125 -0
- package/src/play.ts +152 -0
- package/src/publish.ts +237 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Current wire-format version. Bumped only on a breaking change: see the
|
|
4
|
+
* versioning note above. Additive-optional fields do not bump it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SCHEMA_VERSION = 1;
|
|
7
|
+
/**
|
|
8
|
+
* Hard cap on a heartbeat request body, in bytes. The ingest route rejects a
|
|
9
|
+
* larger body with 413 before parsing. A legitimate worst-case heartbeat: a
|
|
10
|
+
* full 300-entry roster, 300 mods, 50 activity rows: lands around 50 KiB;
|
|
11
|
+
* 64 KiB leaves headroom without letting a beacon flood the endpoint.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MAX_HEARTBEAT_BYTES: number;
|
|
14
|
+
/**
|
|
15
|
+
* Freshness window for `status.sampledAt`, relative to the Atlas's clock.
|
|
16
|
+
* A heartbeat sampled too far in the past is stale (or replayed); one too far
|
|
17
|
+
* in the future means a badly skewed beacon clock. Both are rejected. The
|
|
18
|
+
* past bound is generous enough to absorb publisher retry/backoff.
|
|
19
|
+
*/
|
|
20
|
+
export declare const HEARTBEAT_MAX_AGE_MS: number;
|
|
21
|
+
export declare const HEARTBEAT_MAX_SKEW_MS: number;
|
|
22
|
+
/**
|
|
23
|
+
* Normalize a single-line text field: NFC-normalize, replace C0/C1 control
|
|
24
|
+
* characters with spaces, collapse runs of whitespace, and trim. Applied to
|
|
25
|
+
* every bounded text field before length validation, so the beacon and the
|
|
26
|
+
* Atlas treat input identically.
|
|
27
|
+
*/
|
|
28
|
+
export declare function sanitizeText(value: string): string;
|
|
29
|
+
/** Coarse geographic regions, used for directory filtering. */
|
|
30
|
+
export declare const REGIONS: readonly ["na", "sa", "eu", "uk", "africa", "asia", "oce", "other"];
|
|
31
|
+
export declare const regionSchema: z.ZodEnum<{
|
|
32
|
+
na: "na";
|
|
33
|
+
sa: "sa";
|
|
34
|
+
eu: "eu";
|
|
35
|
+
uk: "uk";
|
|
36
|
+
africa: "africa";
|
|
37
|
+
asia: "asia";
|
|
38
|
+
oce: "oce";
|
|
39
|
+
other: "other";
|
|
40
|
+
}>;
|
|
41
|
+
export type Region = z.infer<typeof regionSchema>;
|
|
42
|
+
/** Granular public placement, still privacy-preserving by default. */
|
|
43
|
+
export declare const coordinateSchema: z.ZodObject<{
|
|
44
|
+
lat: z.ZodNumber;
|
|
45
|
+
lon: z.ZodNumber;
|
|
46
|
+
precisionKm: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export type Coordinates = z.infer<typeof coordinateSchema>;
|
|
49
|
+
export declare const serverLocationSchema: z.ZodObject<{
|
|
50
|
+
region: z.ZodEnum<{
|
|
51
|
+
na: "na";
|
|
52
|
+
sa: "sa";
|
|
53
|
+
eu: "eu";
|
|
54
|
+
uk: "uk";
|
|
55
|
+
africa: "africa";
|
|
56
|
+
asia: "asia";
|
|
57
|
+
oce: "oce";
|
|
58
|
+
other: "other";
|
|
59
|
+
}>;
|
|
60
|
+
countryCode: z.ZodOptional<z.ZodString>;
|
|
61
|
+
subdivisionCode: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
62
|
+
locality: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
63
|
+
coordinates: z.ZodOptional<z.ZodObject<{
|
|
64
|
+
lat: z.ZodNumber;
|
|
65
|
+
lon: z.ZodNumber;
|
|
66
|
+
precisionKm: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
export type ServerLocation = z.infer<typeof serverLocationSchema>;
|
|
70
|
+
export declare const communityLocationSchema: z.ZodObject<{
|
|
71
|
+
region: z.ZodEnum<{
|
|
72
|
+
na: "na";
|
|
73
|
+
sa: "sa";
|
|
74
|
+
eu: "eu";
|
|
75
|
+
uk: "uk";
|
|
76
|
+
africa: "africa";
|
|
77
|
+
asia: "asia";
|
|
78
|
+
oce: "oce";
|
|
79
|
+
other: "other";
|
|
80
|
+
}>;
|
|
81
|
+
countryCode: z.ZodOptional<z.ZodString>;
|
|
82
|
+
subdivisionCode: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
83
|
+
locality: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
84
|
+
coordinates: z.ZodOptional<z.ZodObject<{
|
|
85
|
+
lat: z.ZodNumber;
|
|
86
|
+
lon: z.ZodNumber;
|
|
87
|
+
precisionKm: z.ZodOptional<z.ZodNumber>;
|
|
88
|
+
}, z.core.$strip>>;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
export type CommunityLocation = z.infer<typeof communityLocationSchema>;
|
|
91
|
+
/**
|
|
92
|
+
* How a player gets into the beacon, surfaced so the Atlas renders the right
|
|
93
|
+
* call to action: `gated` links to the beacon's own `/join` flow (the operator
|
|
94
|
+
* still approves), `open` means Atlas deep-links to a public Minecraft login
|
|
95
|
+
* flow that the beacon auto-approves after re-checking its Atlas profile.
|
|
96
|
+
*/
|
|
97
|
+
export declare const joinPolicySchema: z.ZodEnum<{
|
|
98
|
+
gated: "gated";
|
|
99
|
+
open: "open";
|
|
100
|
+
}>;
|
|
101
|
+
export type JoinPolicy = z.infer<typeof joinPolicySchema>;
|
|
102
|
+
/**
|
|
103
|
+
* The mod loader / server software a beacon runs: part of core identity.
|
|
104
|
+
* These mirror `@beacon/shared`'s `LoaderId` exactly: a beacon publishes the
|
|
105
|
+
* loader it runs, so the publisher passes the value straight through with no
|
|
106
|
+
* mapping. Keep the two enums in lockstep.
|
|
107
|
+
*/
|
|
108
|
+
export declare const loaderSchema: z.ZodEnum<{
|
|
109
|
+
vanilla: "vanilla";
|
|
110
|
+
paper: "paper";
|
|
111
|
+
purpur: "purpur";
|
|
112
|
+
folia: "folia";
|
|
113
|
+
fabric: "fabric";
|
|
114
|
+
quilt: "quilt";
|
|
115
|
+
forge: "forge";
|
|
116
|
+
neoforge: "neoforge";
|
|
117
|
+
}>;
|
|
118
|
+
export type Loader = z.infer<typeof loaderSchema>;
|
|
119
|
+
/**
|
|
120
|
+
* A Beacon-hosted Vantage protocol endpoint. Atlas never receives the tile
|
|
121
|
+
* tree: this capability tells the public profile that it may connect directly
|
|
122
|
+
* to the Beacon's public map boundary and speak Vantage protocol v1 there.
|
|
123
|
+
*/
|
|
124
|
+
export declare const vantageStreamSchema: z.ZodObject<{
|
|
125
|
+
protocolVersion: z.ZodLiteral<1>;
|
|
126
|
+
mode: z.ZodLiteral<"live">;
|
|
127
|
+
dimensions: z.ZodOptional<z.ZodNumber>;
|
|
128
|
+
}, z.core.$strip>;
|
|
129
|
+
export type VantageStream = z.infer<typeof vantageStreamSchema>;
|
|
130
|
+
/**
|
|
131
|
+
* The slow-changing server-derived facts a beacon publishes about itself.
|
|
132
|
+
* These are values the running server measures or knows about its own
|
|
133
|
+
* runtime, not anything the operator typed. Operator-typed identity
|
|
134
|
+
* (name, description, addresses, locations, tags, …) lives on the Atlas
|
|
135
|
+
* listing row and never crosses this wire.
|
|
136
|
+
*
|
|
137
|
+
* Coordinates, invite codes, the audit log, and any operator account
|
|
138
|
+
* data have no field to ride on. Player identities leave a beacon only
|
|
139
|
+
* through the opt-in `profile.roster` / `profile.activity` fields.
|
|
140
|
+
*/
|
|
141
|
+
export declare const manifestSchema: z.ZodObject<{
|
|
142
|
+
mcVersion: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
143
|
+
loader: z.ZodEnum<{
|
|
144
|
+
vanilla: "vanilla";
|
|
145
|
+
paper: "paper";
|
|
146
|
+
purpur: "purpur";
|
|
147
|
+
folia: "folia";
|
|
148
|
+
fabric: "fabric";
|
|
149
|
+
quilt: "quilt";
|
|
150
|
+
forge: "forge";
|
|
151
|
+
neoforge: "neoforge";
|
|
152
|
+
}>;
|
|
153
|
+
mods: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>>;
|
|
154
|
+
renderDistance: z.ZodOptional<z.ZodNumber>;
|
|
155
|
+
worldAgeDays: z.ZodOptional<z.ZodNumber>;
|
|
156
|
+
worldSizeMib: z.ZodOptional<z.ZodNumber>;
|
|
157
|
+
vantage: z.ZodOptional<z.ZodObject<{
|
|
158
|
+
protocolVersion: z.ZodLiteral<1>;
|
|
159
|
+
mode: z.ZodLiteral<"live">;
|
|
160
|
+
dimensions: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
}, z.core.$strip>>;
|
|
162
|
+
}, z.core.$strip>;
|
|
163
|
+
export type BeaconManifest = z.infer<typeof manifestSchema>;
|
|
164
|
+
/** World difficulty: stored on the Atlas listing row, surfaced on `/b/[slug]`. */
|
|
165
|
+
export declare const difficultySchema: z.ZodEnum<{
|
|
166
|
+
peaceful: "peaceful";
|
|
167
|
+
easy: "easy";
|
|
168
|
+
normal: "normal";
|
|
169
|
+
hard: "hard";
|
|
170
|
+
hardcore: "hardcore";
|
|
171
|
+
}>;
|
|
172
|
+
export type Difficulty = z.infer<typeof difficultySchema>;
|
|
173
|
+
/**
|
|
174
|
+
* Per-section visibility the host configures on the Atlas dashboard.
|
|
175
|
+
* `public` shows the section to everyone; `members` restricts it to the
|
|
176
|
+
* beacon's members; `hidden` hides it from everyone but the host. The
|
|
177
|
+
* Atlas renders a `members`/`hidden` section as a locked placeholder for
|
|
178
|
+
* visitors. `coords` also gates the federated Vantage world; its bytes stay on
|
|
179
|
+
* the Beacon and never cross the heartbeat wire.
|
|
180
|
+
*/
|
|
181
|
+
export declare const privacyLevelSchema: z.ZodEnum<{
|
|
182
|
+
public: "public";
|
|
183
|
+
members: "members";
|
|
184
|
+
hidden: "hidden";
|
|
185
|
+
}>;
|
|
186
|
+
export type PrivacyLevel = z.infer<typeof privacyLevelSchema>;
|
|
187
|
+
/** The profile sections whose visibility a host can configure. */
|
|
188
|
+
export declare const PRIVACY_SECTIONS: readonly ["coords", "roster", "activity", "mods", "perf"];
|
|
189
|
+
export type PrivacySection = (typeof PRIVACY_SECTIONS)[number];
|
|
190
|
+
/** Visibility map, one level per gateable section. Defaults to `public`. */
|
|
191
|
+
export declare const privacySchema: z.ZodObject<{
|
|
192
|
+
coords: z.ZodDefault<z.ZodEnum<{
|
|
193
|
+
public: "public";
|
|
194
|
+
members: "members";
|
|
195
|
+
hidden: "hidden";
|
|
196
|
+
}>>;
|
|
197
|
+
roster: z.ZodDefault<z.ZodEnum<{
|
|
198
|
+
public: "public";
|
|
199
|
+
members: "members";
|
|
200
|
+
hidden: "hidden";
|
|
201
|
+
}>>;
|
|
202
|
+
activity: z.ZodDefault<z.ZodEnum<{
|
|
203
|
+
public: "public";
|
|
204
|
+
members: "members";
|
|
205
|
+
hidden: "hidden";
|
|
206
|
+
}>>;
|
|
207
|
+
mods: z.ZodDefault<z.ZodEnum<{
|
|
208
|
+
public: "public";
|
|
209
|
+
members: "members";
|
|
210
|
+
hidden: "hidden";
|
|
211
|
+
}>>;
|
|
212
|
+
perf: z.ZodDefault<z.ZodEnum<{
|
|
213
|
+
public: "public";
|
|
214
|
+
members: "members";
|
|
215
|
+
hidden: "hidden";
|
|
216
|
+
}>>;
|
|
217
|
+
}, z.core.$strip>;
|
|
218
|
+
export type ProfilePrivacy = z.infer<typeof privacySchema>;
|
|
219
|
+
/** A staff/member role, used to tally and badge the roster. */
|
|
220
|
+
export declare const rosterRoleSchema: z.ZodEnum<{
|
|
221
|
+
host: "host";
|
|
222
|
+
admin: "admin";
|
|
223
|
+
mod: "mod";
|
|
224
|
+
builder: "builder";
|
|
225
|
+
member: "member";
|
|
226
|
+
}>;
|
|
227
|
+
export type RosterRole = z.infer<typeof rosterRoleSchema>;
|
|
228
|
+
/** One entry in the published roster: opt-in player-identity data. */
|
|
229
|
+
export declare const rosterEntrySchema: z.ZodObject<{
|
|
230
|
+
name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
231
|
+
role: z.ZodEnum<{
|
|
232
|
+
host: "host";
|
|
233
|
+
admin: "admin";
|
|
234
|
+
mod: "mod";
|
|
235
|
+
builder: "builder";
|
|
236
|
+
member: "member";
|
|
237
|
+
}>;
|
|
238
|
+
online: z.ZodDefault<z.ZodBoolean>;
|
|
239
|
+
}, z.core.$strip>;
|
|
240
|
+
export type RosterEntry = z.infer<typeof rosterEntrySchema>;
|
|
241
|
+
/** The kind of a recent-activity row. */
|
|
242
|
+
export declare const activityKindSchema: z.ZodEnum<{
|
|
243
|
+
join: "join";
|
|
244
|
+
leave: "leave";
|
|
245
|
+
death: "death";
|
|
246
|
+
advancement: "advancement";
|
|
247
|
+
build: "build";
|
|
248
|
+
broadcast: "broadcast";
|
|
249
|
+
}>;
|
|
250
|
+
export type ActivityKind = z.infer<typeof activityKindSchema>;
|
|
251
|
+
/** One row in the published recent-activity feed: opt-in player data. */
|
|
252
|
+
export declare const activityEntrySchema: z.ZodObject<{
|
|
253
|
+
kind: z.ZodEnum<{
|
|
254
|
+
join: "join";
|
|
255
|
+
leave: "leave";
|
|
256
|
+
death: "death";
|
|
257
|
+
advancement: "advancement";
|
|
258
|
+
build: "build";
|
|
259
|
+
broadcast: "broadcast";
|
|
260
|
+
}>;
|
|
261
|
+
actor: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
262
|
+
detail: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
263
|
+
at: z.ZodString;
|
|
264
|
+
}, z.core.$strip>;
|
|
265
|
+
export type ActivityEntry = z.infer<typeof activityEntrySchema>;
|
|
266
|
+
/** An upcoming community event for the "Up next" panel. Stored on the
|
|
267
|
+
* Atlas listing row (operator-typed), not on the wire. */
|
|
268
|
+
export declare const eventEntrySchema: z.ZodObject<{
|
|
269
|
+
at: z.ZodString;
|
|
270
|
+
title: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
271
|
+
detail: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
272
|
+
}, z.core.$strip>;
|
|
273
|
+
export type EventEntry = z.infer<typeof eventEntrySchema>;
|
|
274
|
+
/** A pinned note from the host. Stored on the Atlas listing row. */
|
|
275
|
+
export declare const hostNoteSchema: z.ZodObject<{
|
|
276
|
+
body: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
277
|
+
postedAt: z.ZodString;
|
|
278
|
+
}, z.core.$strip>;
|
|
279
|
+
export type HostNote = z.infer<typeof hostNoteSchema>;
|
|
280
|
+
/**
|
|
281
|
+
* The optional opt-in player-data block on a heartbeat. Both fields are
|
|
282
|
+
* gated by the matching consent toggle on the Atlas listing row: the
|
|
283
|
+
* beacon must not publish them unless the operator opted in.
|
|
284
|
+
*/
|
|
285
|
+
export declare const profileSchema: z.ZodObject<{
|
|
286
|
+
roster: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
287
|
+
name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
288
|
+
role: z.ZodEnum<{
|
|
289
|
+
host: "host";
|
|
290
|
+
admin: "admin";
|
|
291
|
+
mod: "mod";
|
|
292
|
+
builder: "builder";
|
|
293
|
+
member: "member";
|
|
294
|
+
}>;
|
|
295
|
+
online: z.ZodDefault<z.ZodBoolean>;
|
|
296
|
+
}, z.core.$strip>>>;
|
|
297
|
+
activity: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
298
|
+
kind: z.ZodEnum<{
|
|
299
|
+
join: "join";
|
|
300
|
+
leave: "leave";
|
|
301
|
+
death: "death";
|
|
302
|
+
advancement: "advancement";
|
|
303
|
+
build: "build";
|
|
304
|
+
broadcast: "broadcast";
|
|
305
|
+
}>;
|
|
306
|
+
actor: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
307
|
+
detail: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
308
|
+
at: z.ZodString;
|
|
309
|
+
}, z.core.$strip>>>;
|
|
310
|
+
}, z.core.$strip>;
|
|
311
|
+
export type BeaconProfile = z.infer<typeof profileSchema>;
|
|
312
|
+
/**
|
|
313
|
+
* The live, fast-changing slice of a heartbeat: re-measured every tick.
|
|
314
|
+
* Self-reported: the Atlas independently Server-List-Pings `manifest.mcAddress`
|
|
315
|
+
* and treats the ping result as authoritative over these numbers.
|
|
316
|
+
*/
|
|
317
|
+
export declare const statusSchema: z.ZodObject<{
|
|
318
|
+
online: z.ZodBoolean;
|
|
319
|
+
playersOnline: z.ZodNumber;
|
|
320
|
+
playersMax: z.ZodNumber;
|
|
321
|
+
tps: z.ZodOptional<z.ZodNumber>;
|
|
322
|
+
uptimeSeconds: z.ZodOptional<z.ZodNumber>;
|
|
323
|
+
uptimePct: z.ZodOptional<z.ZodNumber>;
|
|
324
|
+
playersPeak7d: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
325
|
+
sampledAt: z.ZodString;
|
|
326
|
+
}, z.core.$strip>;
|
|
327
|
+
export type BeaconStatusReport = z.infer<typeof statusSchema>;
|
|
328
|
+
export declare const heartbeatSchema: z.ZodObject<{
|
|
329
|
+
schemaVersion: z.ZodNumber;
|
|
330
|
+
beaconId: z.ZodString;
|
|
331
|
+
manifest: z.ZodObject<{
|
|
332
|
+
mcVersion: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
333
|
+
loader: z.ZodEnum<{
|
|
334
|
+
vanilla: "vanilla";
|
|
335
|
+
paper: "paper";
|
|
336
|
+
purpur: "purpur";
|
|
337
|
+
folia: "folia";
|
|
338
|
+
fabric: "fabric";
|
|
339
|
+
quilt: "quilt";
|
|
340
|
+
forge: "forge";
|
|
341
|
+
neoforge: "neoforge";
|
|
342
|
+
}>;
|
|
343
|
+
mods: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>>;
|
|
344
|
+
renderDistance: z.ZodOptional<z.ZodNumber>;
|
|
345
|
+
worldAgeDays: z.ZodOptional<z.ZodNumber>;
|
|
346
|
+
worldSizeMib: z.ZodOptional<z.ZodNumber>;
|
|
347
|
+
vantage: z.ZodOptional<z.ZodObject<{
|
|
348
|
+
protocolVersion: z.ZodLiteral<1>;
|
|
349
|
+
mode: z.ZodLiteral<"live">;
|
|
350
|
+
dimensions: z.ZodOptional<z.ZodNumber>;
|
|
351
|
+
}, z.core.$strip>>;
|
|
352
|
+
}, z.core.$strip>;
|
|
353
|
+
profile: z.ZodOptional<z.ZodObject<{
|
|
354
|
+
roster: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
355
|
+
name: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
356
|
+
role: z.ZodEnum<{
|
|
357
|
+
host: "host";
|
|
358
|
+
admin: "admin";
|
|
359
|
+
mod: "mod";
|
|
360
|
+
builder: "builder";
|
|
361
|
+
member: "member";
|
|
362
|
+
}>;
|
|
363
|
+
online: z.ZodDefault<z.ZodBoolean>;
|
|
364
|
+
}, z.core.$strip>>>;
|
|
365
|
+
activity: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
366
|
+
kind: z.ZodEnum<{
|
|
367
|
+
join: "join";
|
|
368
|
+
leave: "leave";
|
|
369
|
+
death: "death";
|
|
370
|
+
advancement: "advancement";
|
|
371
|
+
build: "build";
|
|
372
|
+
broadcast: "broadcast";
|
|
373
|
+
}>;
|
|
374
|
+
actor: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>>;
|
|
375
|
+
detail: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
|
|
376
|
+
at: z.ZodString;
|
|
377
|
+
}, z.core.$strip>>>;
|
|
378
|
+
}, z.core.$strip>>;
|
|
379
|
+
status: z.ZodObject<{
|
|
380
|
+
online: z.ZodBoolean;
|
|
381
|
+
playersOnline: z.ZodNumber;
|
|
382
|
+
playersMax: z.ZodNumber;
|
|
383
|
+
tps: z.ZodOptional<z.ZodNumber>;
|
|
384
|
+
uptimeSeconds: z.ZodOptional<z.ZodNumber>;
|
|
385
|
+
uptimePct: z.ZodOptional<z.ZodNumber>;
|
|
386
|
+
playersPeak7d: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
387
|
+
sampledAt: z.ZodString;
|
|
388
|
+
}, z.core.$strip>;
|
|
389
|
+
}, z.core.$strip>;
|
|
390
|
+
export type Heartbeat = z.infer<typeof heartbeatSchema>;
|
|
391
|
+
/**
|
|
392
|
+
* Stamp a heartbeat with the current {@link SCHEMA_VERSION}. The beacon-side
|
|
393
|
+
* publisher uses this so the version is set in exactly one place.
|
|
394
|
+
*/
|
|
395
|
+
export declare function buildHeartbeat(beaconId: string, manifest: BeaconManifest, status: BeaconStatusReport, profile?: BeaconProfile): Heartbeat;
|
|
396
|
+
export type HeartbeatParseResult = {
|
|
397
|
+
ok: true;
|
|
398
|
+
heartbeat: Heartbeat;
|
|
399
|
+
futureSchema: boolean;
|
|
400
|
+
} | {
|
|
401
|
+
ok: false;
|
|
402
|
+
error: string;
|
|
403
|
+
};
|
|
404
|
+
/**
|
|
405
|
+
* Parse and validate an inbound heartbeat body on the Atlas side.
|
|
406
|
+
*
|
|
407
|
+
* Schema-version tolerant by design: a heartbeat is accepted regardless of its
|
|
408
|
+
* `schemaVersion`. A beacon on a newer version may send extra fields: zod
|
|
409
|
+
* strips unknown keys, so the known shape still validates. A beacon on an
|
|
410
|
+
* older version is fine as long as it satisfies the current required fields;
|
|
411
|
+
* future additive fields must therefore be optional. `futureSchema` flags a
|
|
412
|
+
* heartbeat newer than this build so callers can log or surface it.
|
|
413
|
+
*/
|
|
414
|
+
export declare function parseHeartbeat(input: unknown): HeartbeatParseResult;
|
|
415
|
+
export type HeartbeatFreshness = {
|
|
416
|
+
fresh: true;
|
|
417
|
+
} | {
|
|
418
|
+
fresh: false;
|
|
419
|
+
reason: "stale" | "future";
|
|
420
|
+
};
|
|
421
|
+
/**
|
|
422
|
+
* Check that a heartbeat's `status.sampledAt` sits inside the freshness
|
|
423
|
+
* window around the Atlas's clock. A too-old sample is `stale` (a delayed or
|
|
424
|
+
* replayed heartbeat); a too-far-ahead sample is `future` (a skewed beacon
|
|
425
|
+
* clock). The ingest route rejects either. This is a key-free replay bound:
|
|
426
|
+
* a captured heartbeat is worthless once it ages past {@link
|
|
427
|
+
* HEARTBEAT_MAX_AGE_MS}.
|
|
428
|
+
*/
|
|
429
|
+
export declare function checkHeartbeatFreshness(sampledAt: string, now?: Date): HeartbeatFreshness;
|
|
430
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAyDA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,QAAY,CAAC;AAE7C;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,QAAc,CAAC;AAChD,eAAO,MAAM,qBAAqB,QAAa,CAAC;AAWhD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMlD;AAqDD,+DAA+D;AAC/D,eAAO,MAAM,OAAO,qEASV,CAAC;AAEX,eAAO,MAAM,YAAY;;;;;;;;;EAAkB,CAAC;AAC5C,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD,sEAAsE;AACtE,eAAO,MAAM,gBAAgB;;;;iBAO3B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAsB3D,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;iBAAuB,CAAC;AACzD,MAA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