@rindle/client 0.3.1 → 0.4.3
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/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/mutation-ops.d.ts +200 -0
- package/dist/mutation-ops.d.ts.map +1 -0
- package/dist/mutation-ops.js +79 -0
- package/dist/mutation-ops.js.map +1 -0
- package/dist/schema.d.ts +147 -15
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +90 -4
- package/dist/schema.js.map +1 -1
- package/dist/ssr.d.ts +14 -0
- package/dist/ssr.d.ts.map +1 -1
- package/dist/ssr.js +15 -0
- package/dist/ssr.js.map +1 -1
- package/dist/store.d.ts +7 -3
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +29 -1
- package/src/mutation-ops.ts +264 -0
- package/src/schema.ts +260 -24
- package/src/ssr.ts +21 -0
- package/src/store.ts +7 -3
package/src/ssr.ts
CHANGED
|
@@ -111,6 +111,27 @@ export class ServerStore<S extends ColsMap> {
|
|
|
111
111
|
dehydrate(): DehydratedState {
|
|
112
112
|
return this.store.dehydrate();
|
|
113
113
|
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Loader-phase convenience over {@link preload} + {@link dehydrate}: preload EVERY query (reads run
|
|
117
|
+
* concurrently) and return the dehydrated first-paint cache. Composition keeps this to one read per
|
|
118
|
+
* composed root query — no request waterfall (SSR-DESIGN.md §6.2).
|
|
119
|
+
*
|
|
120
|
+
* A failed read degrades to NO seed for that one query — `onError` fires and the browser's live
|
|
121
|
+
* engine fills it in right after hydration — rather than rejecting the whole batch (which would trip
|
|
122
|
+
* the route's error boundary). The seed is a first-paint optimization; the live `subscribe` is the
|
|
123
|
+
* source of truth, so a missing seed never affects correctness. Without `onError` a failed read is
|
|
124
|
+
* swallowed silently — pass one to log.
|
|
125
|
+
*/
|
|
126
|
+
async preloadAll(
|
|
127
|
+
queries: Array<Query<any, any, any>>,
|
|
128
|
+
opts: { onError?: (query: Query<any, any, any>, err: unknown) => void } = {},
|
|
129
|
+
): Promise<DehydratedState> {
|
|
130
|
+
await Promise.all(
|
|
131
|
+
queries.map((query) => this.preload(query).catch((err) => opts.onError?.(query, err))),
|
|
132
|
+
);
|
|
133
|
+
return this.dehydrate();
|
|
134
|
+
}
|
|
114
135
|
}
|
|
115
136
|
|
|
116
137
|
/** Construct a {@link ServerStore} — the one-shot REST Store for server-side rendering. */
|
package/src/store.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import type { Ast } from "./ast.ts";
|
|
11
11
|
import { stableKey } from "./key.ts";
|
|
12
12
|
import { queries, type Query, type QueryRoot } from "./query.ts";
|
|
13
|
-
import type { ColsMap, RowOf, Schema } from "./schema.ts";
|
|
13
|
+
import type { ColsMap, InsertOf, RowOf, Schema } from "./schema.ts";
|
|
14
14
|
import type { Backend, ChangeEvent, ColType, FlatChange, Mutation, QueryId, RemoteQuery, ResultType, WireSchema, WireValue } from "./types.ts";
|
|
15
15
|
import { type ArrayView, FlatArrayView, type SingularArrayView, SingularView, type ViewTypes } from "./view.ts";
|
|
16
16
|
|
|
@@ -36,9 +36,13 @@ export interface AssembledNode {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/** The write transaction handed to `store.write(tx => …)`. Rows are objects keyed by column;
|
|
39
|
-
* the Store positionalizes them (and stringifies json columns) before the backend sees them.
|
|
39
|
+
* the Store positionalizes them (and stringifies json columns) before the backend sees them.
|
|
40
|
+
*
|
|
41
|
+
* `add` takes an {@link InsertOf} row — a nullable column may be omitted (it is filled with `null`,
|
|
42
|
+
* design 206 §7). `remove`/`edit` take a full {@link RowOf} row: they identify an EXISTING row, so
|
|
43
|
+
* every column (nullable ones as their actual `T | null` value) must be present. */
|
|
40
44
|
export interface WriteTx<S extends ColsMap> {
|
|
41
|
-
add<N extends keyof S & string>(table: N, row:
|
|
45
|
+
add<N extends keyof S & string>(table: N, row: InsertOf<S[N]>): void;
|
|
42
46
|
remove<N extends keyof S & string>(table: N, row: RowOf<S[N]>): void;
|
|
43
47
|
edit<N extends keyof S & string>(table: N, oldRow: RowOf<S[N]>, newRow: RowOf<S[N]>): void;
|
|
44
48
|
}
|