@re-cinq/floor-contracts 0.6.0 → 0.6.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 (2) hide show
  1. package/README.md +11 -9
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # @re-cinq/floor-contracts
2
2
 
3
- The floor's wire, as types. What its HTTP routes and its live socket take and answer, and nothing else — no runtime, no dependencies. Installing it adds declarations and not one byte of code.
3
+ The floor's wire, as types: what its HTTP routes and its live socket take and answer. It has no runtime and no dependencies, so installing it adds declarations and no code.
4
4
 
5
5
  ## Where this fits
6
6
 
7
- One declaration, three readers: [`@floor/store`](../store/README.md) instantiates the row shapes and re-exports the rest, `apps/api` annotates its handlers with them, and [`@re-cinq/floor-client`](../client/README.md) reads them back off the wire. That is the point of the package — before it, the same shapes were written out four times, and the copies had already drifted apart: one omitted a git need's `access`, another omitted a visit's `iteration`, and a field the route renames on its way out was named nowhere at all.
7
+ One declaration has three readers. [`@floor/store`](../store/README.md) instantiates the row shapes and re-exports the rest, `apps/api` annotates its handlers with them, and [`@re-cinq/floor-client`](../client/README.md) reads them back off the wire.
8
+
9
+ Before this package the same shapes were written out four times, and the copies had drifted apart. One omitted a git need's `access`, another omitted a visit's `iteration`, and a field the route renames on its way out was named nowhere at all.
8
10
 
9
11
  It depends on nothing, which is what lets a published SDK depend on it. See [the map](../../README.md).
10
12
 
@@ -12,7 +14,7 @@ It depends on nothing, which is what lets a published SDK depend on it. See [the
12
14
 
13
15
  **A type belongs here only if its declaration is already valid JSON-after-parse.** No `Date`, no `Buffer`.
14
16
 
15
- That rule is what keeps the package honest, and it is the thing to get wrong. A row the store keeps has `finishedAt: Date`; the same row on the wire has `finishedAt: string`, because hapi wrote it out. So a row is declared once, parameterised on its timestamp type, and read two ways:
17
+ This is the rule to get wrong. A row the store keeps has `finishedAt: Date`. The same row on the wire has `finishedAt: string`, because hapi wrote it out. So a row is declared once, parameterised on its timestamp type, and read two ways:
16
18
 
17
19
  ```ts
18
20
  export interface RunFields<Time> { /* … */ finishedAt: Time | null }
@@ -21,16 +23,16 @@ export type RunView = RunFields<string>; // here: what a client reads
21
23
  export type Run = RunFields<Date>; // in @floor/store: what Postgres holds
22
24
  ```
23
25
 
24
- Never name a wire type `Run` or `Visit`. The `*View` suffix is the distinction, in the identifier where it cannot be missed. `apps/api/src/wire-contract.test-d.ts` holds the two sides together at compile time, asserting that jsonifying each row gives exactly its view — including every frame of the live socket.
26
+ Never name a wire type `Run` or `Visit`. The `*View` suffix is the distinction, in the identifier where it cannot be missed. `apps/api/src/wire-contract.test-d.ts` holds the two sides together at compile time. It asserts that jsonifying each row gives exactly its view, including every frame of the live socket.
25
27
 
26
28
  ## What is here
27
29
 
28
- - `definitions.ts` — the bodies a floor is given: `LineBody`, `StationBody`, `AgentDefinitionBody`, `ScheduleBody`, and what they are made of (`Item`, `Report`, `NeedSpec`, `ProduceSpec`, `AgentSettings`, `ModelPrice`).
29
- - `wire.ts` — what exists only on the wire: `Problem` (RFC 9457), `VisitBrief` and its `BriefNeed`, `BriefSettings` and `BriefConversation`, `ClaimedEvent`, `BlobRef`, `PutResult`, `GitCredential`, `MigrationBody`.
30
- - `views.ts` — the row shapes and their views, and `LiveFrame`.
30
+ - `definitions.ts` has the bodies a floor is given: `LineBody`, `StationBody`, `AgentDefinitionBody`, `ScheduleBody`, and what they are made of (`Item`, `Report`, `NeedSpec`, `ProduceSpec`, `AgentSettings`, `ModelPrice`).
31
+ - `wire.ts` has what exists only on the wire: `Problem` (RFC 9457), `VisitBrief` and its `BriefNeed`, `BriefSettings` and `BriefConversation`, `ClaimedEvent`, `BlobRef`, `PutResult`, `GitCredential`, `MigrationBody`.
32
+ - `views.ts` has the row shapes and their views, and `LiveFrame`.
31
33
 
32
34
  ## Two names worth knowing
33
35
 
34
- **`BriefConversation` says `sessionRef`; the store's `DispatchConversation` says `visitId`.** They are the same field. The route renames it on the way out, and until this package existed that rename was a translation buried in a handler with a name on neither side.
36
+ `BriefConversation` says `sessionRef` and the store's `DispatchConversation` says `visitId`. They are the same field. The route renames it on the way out. Until this package existed, that rename was a translation in a handler with a name on neither side.
35
37
 
36
- **`unsupported` is the one frame with no `seq`.** It is the floor's answer to anything a viewer says, and a client that says nothing never sees it.
38
+ `unsupported` is the one frame with no `seq`. It is the floor's answer to anything a viewer says, and a client that says nothing never sees it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@re-cinq/floor-contracts",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "The floor's wire, as types: what its HTTP routes and its live socket take and answer, and nothing else. No runtime, no dependencies.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {