@voltro/protocol 0.53.0 → 0.55.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/dist/rest.d.ts CHANGED
@@ -1000,21 +1000,52 @@ declare type Subject = typeof Subject.Type;
1000
1000
 
1001
1001
  declare type Target<Input = unknown, Row = unknown> = TargetSpec<Input, Row> | ReadonlyArray<TargetSpec<Input, Row>>;
1002
1002
 
1003
+ /**
1004
+ * ONE declared many-to-many relation of a write target: the junction table
1005
+ * plus its two reference columns.
1006
+ *
1007
+ * **Why the columns are declared and not derived.** The server can derive
1008
+ * them (`store.relationLinks` reads the junction's `reference()` targets),
1009
+ * and it still does — but the same declaration drives JUNCTION AUTO-OPTIMISTIC
1010
+ * in the BROWSER, and the browser has no table registry to derive from
1011
+ * (`@voltro/database` is server-only by construction). Guessing a column name
1012
+ * from the table name is the failure mode this codebase refuses everywhere
1013
+ * else, so the pair is stated. It is not taken on trust: before it writes, the
1014
+ * server compares the declaration against the junction's real reference
1015
+ * columns and refuses — naming the right pair — if they disagree. A wrong
1016
+ * declaration is a boot-loud error, never a silent client/server divergence.
1017
+ */
1018
+ declare interface TargetRelation {
1019
+ /** The junction (link) table. */
1020
+ readonly junction: string;
1021
+ /** The junction's reference column pointing at the TARGET's own table. */
1022
+ readonly anchorColumn: string;
1023
+ /** The junction's other reference column — the linked row's id. */
1024
+ readonly targetColumn: string;
1025
+ }
1026
+
1003
1027
  /**
1004
1028
  * Declared many-to-many RELATIONS of a write target: `{ inputField:
1005
- * junctionTable }`. After the executor succeeds — inside the SAME
1029
+ * TargetRelation }`. After the executor succeeds — inside the SAME
1006
1030
  * transaction — the framework reconciles the junction's links for the
1007
1031
  * written row against `input[inputField]` (an array of target ids) via the
1008
1032
  * diff-based `store.relationLinks`, so a form's multi-reference field saves
1009
- * in one mutation with no hand-written junction code. The anchor column is
1010
- * derived from the junction's `reference()` targets (a self-junction is
1011
- * refused, never guessed).
1033
+ * in one mutation with no hand-written junction code.
1034
+ *
1035
+ * The SAME declaration drives the client's junction auto-optimistic: the
1036
+ * cache reconciles the junction rows of every subscription sourced on
1037
+ * `junction` the moment the mutation is sent, so a multi-reference field
1038
+ * flips as instantly as a scalar one instead of waiting for the server delta.
1039
+ * Those patches ride the ordinary optimistic lane (staged under the mutation
1040
+ * id): reverted on failure, kept on success until the base actually moves.
1012
1041
  *
1013
1042
  * An ABSENT input field leaves the links untouched (absent ≠ empty — an
1014
1043
  * empty array is the explicit "clear them all"). The row id is the
1015
- * executor's `output.id`, falling back to `input.id`.
1044
+ * executor's `output.id`, falling back to `input.id`; the client, which
1045
+ * cannot see `output` yet, uses `input.id` (and, for an insert, the same
1046
+ * optimistic id it stamped on the new row).
1016
1047
  */
1017
- declare type TargetRelations = Readonly<Record<string, string>>;
1048
+ declare type TargetRelations = Readonly<Record<string, TargetRelation>>;
1018
1049
 
1019
1050
  declare type TargetSpec<Input = unknown, Row = unknown> = InsertTarget<Input, Row> | UpdateTarget<Input, Row> | DeleteTarget<Input>;
1020
1051
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/protocol",
3
- "version": "0.53.0",
3
+ "version": "0.55.0",
4
4
  "description": "The Voltro wire + plugin contract — defineQuery/Mutation/Action/Stream, definePlugin, sessions / JWT / API-keys, and the RPC protocol.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -54,8 +54,8 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@effect/sql": "^0.52.0",
57
- "@voltro/database": "0.53.0",
58
- "@voltro/logger": "0.53.0",
57
+ "@voltro/database": "0.55.0",
58
+ "@voltro/logger": "0.55.0",
59
59
  "jose": "^6.2.8"
60
60
  },
61
61
  "peerDependencies": {