@hadoku/platform-wire 0.1.257 → 0.1.258

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.
@@ -1,4 +1,8 @@
1
1
  import { z } from 'zod';
2
+ /** The longest string fact, the longest fact name and the most facts one event carries. */
3
+ export declare const CLIENT_TEXT_MAX = 80;
4
+ export declare const CLIENT_KEY_MAX = 32;
5
+ export declare const CLIENT_FIELDS_MAX = 16;
2
6
  /** An event's facts: flat scalars, a bounded field set. */
3
7
  export declare const ClientDataSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
4
8
  /** One event from a match's socket, of one of the game's own `kinds`. */
@@ -14,14 +18,19 @@ export declare const PAGE_EVENT_PATH = "client-events";
14
18
  * into the server's log as a `client` event keyed by page and user. `kind: 'perf'`: on `page: 'front'`,
15
19
  * a list's scroll smoothness, one summary per scroll burst; on `'front'` and `'draft'`, the screen's frame
16
20
  * rate, the same events a match's frame watch sends (bad stretches, long frames, summaries, the machine).
21
+ * `kind: 'trouble'`: on `page: 'match'` and `'replay'`, a board that could not connect or play, told over
22
+ * HTTP because the socket is what is in trouble; `data.what` names it.
17
23
  */
18
24
  export declare const PageEventSchema: z.ZodObject<{
19
25
  page: z.ZodEnum<{
26
+ match: "match";
20
27
  front: "front";
21
28
  draft: "draft";
29
+ replay: "replay";
22
30
  }>;
23
31
  kind: z.ZodEnum<{
24
32
  perf: "perf";
33
+ trouble: "trouble";
25
34
  }>;
26
35
  data: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
27
36
  }, z.core.$strict>;
package/dist/telemetry.js CHANGED
@@ -4,9 +4,13 @@
4
4
  * always confirm everything with telemetry."*). Flat scalars, no hidden information, nothing relayed.
5
5
  */
6
6
  import { z } from 'zod';
7
- const ScalarSchema = z.union([z.string().max(80), z.number().finite(), z.boolean()]);
7
+ /** The longest string fact, the longest fact name and the most facts one event carries. */
8
+ export const CLIENT_TEXT_MAX = 80;
9
+ export const CLIENT_KEY_MAX = 32;
10
+ export const CLIENT_FIELDS_MAX = 16;
11
+ const ScalarSchema = z.union([z.string().max(CLIENT_TEXT_MAX), z.number().finite(), z.boolean()]);
8
12
  /** An event's facts: flat scalars, a bounded field set. */
9
- export const ClientDataSchema = z.record(z.string().min(1).max(32), ScalarSchema).refine((d) => Object.keys(d).length <= 16, 'at most 16 fields');
13
+ export const ClientDataSchema = z.record(z.string().min(1).max(CLIENT_KEY_MAX), ScalarSchema).refine((d) => Object.keys(d).length <= CLIENT_FIELDS_MAX, `at most ${CLIENT_FIELDS_MAX} fields`);
10
14
  /** One event from a match's socket, of one of the game's own `kinds`. */
11
15
  export const clientEventSchema = (kinds) => z.object({ matchId: z.string().min(1), kind: z.enum(kinds), data: ClientDataSchema }).strict();
12
16
  /** Where a page event is sent, under `/api/`: a screen with no match has no match socket to carry it. */
@@ -16,8 +20,10 @@ export const PAGE_EVENT_PATH = 'client-events';
16
20
  * into the server's log as a `client` event keyed by page and user. `kind: 'perf'`: on `page: 'front'`,
17
21
  * a list's scroll smoothness, one summary per scroll burst; on `'front'` and `'draft'`, the screen's frame
18
22
  * rate, the same events a match's frame watch sends (bad stretches, long frames, summaries, the machine).
23
+ * `kind: 'trouble'`: on `page: 'match'` and `'replay'`, a board that could not connect or play, told over
24
+ * HTTP because the socket is what is in trouble; `data.what` names it.
19
25
  */
20
- export const PageEventSchema = z.object({ page: z.enum(['front', 'draft']), kind: z.enum(['perf']), data: ClientDataSchema }).strict();
26
+ export const PageEventSchema = z.object({ page: z.enum(['front', 'draft', 'match', 'replay']), kind: z.enum(['perf', 'trouble']), data: ClientDataSchema }).strict();
21
27
  /** A socket sending more than this in one second is a client bug; the rest of that second is dropped. */
22
28
  export const CLIENT_EVENT_MAX_PER_SECOND = 20;
23
29
  /** Where the browser's usage batches go, under `/api/`. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/platform-wire",
3
- "version": "0.1.257",
4
- "gitHead": "200c3dd1e6887b83b9d7572babb84ffbd8f38ec9",
3
+ "version": "0.1.258",
4
+ "gitHead": "7a37d4cacbc4f864ecaa4a14a0878be5b90e863f",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "The wire any game speaks: room ids, telemetry, presence, events and tables, the Discord relay, looks, the room request bodies and room view, room settings, the game-type registry, the restart notice, secure random and a generic server envelope. Knows no game; a game's own part rides as a type parameter. MIT; imports only zod.",