@party-stack/tanstack-db-patches 0.0.0-stage → 0.2.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 +21 -0
- package/README.md +107 -2
- package/lib/cli.js +30425 -0
- package/ordered-window.md +93 -0
- package/package.json +24 -3
- package/patches/@tanstack__db@1.0.0-rc.1.4.patch +611 -0
- package/patches/@tanstack__react-db@1.0.0-rc.1.4.patch +136 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Exact ordered-prefix capability
|
|
2
|
+
|
|
3
|
+
This is a proposed upstream change and the contract implemented by the local DB
|
|
4
|
+
patch. The upstream proposal is filed as [TanStack DB #2398](https://github.com/TanStack/db/issues/2398).
|
|
5
|
+
|
|
6
|
+
## Problem
|
|
7
|
+
|
|
8
|
+
The ordered source loader currently requests a finite page, then separately loads
|
|
9
|
+
every row equal to its leading sort value. A boolean leading field can therefore
|
|
10
|
+
turn a 51-row page into a 1,400-row acquisition. A leading `Temporal.Instant`
|
|
11
|
+
cannot form the existing scalar cursor, so it instead triggers a full-source
|
|
12
|
+
request without ordering or a limit.
|
|
13
|
+
|
|
14
|
+
A deterministic regression reproduces the current Notes query:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
q.from({ note: notes })
|
|
18
|
+
.where(({ note }) => eq(note.trashed, true))
|
|
19
|
+
.orderBy(({ note }) => note.updatedAt, "desc")
|
|
20
|
+
.orderBy(({ note }) => note.id, "asc")
|
|
21
|
+
.limit(51);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The released package acquires `[51, 1400]`; the candidate acquires `[51]` with the
|
|
25
|
+
same results. Source, published ESM and published CJS variants pass that oracle.
|
|
26
|
+
|
|
27
|
+
## Proposed public contract
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
interface SyncConfig {
|
|
31
|
+
supportsOrderedWindow?: (options: LoadSubsetOptions) => boolean;
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Core supplies the normalized source WHERE, complete resolved ORDER BY and initial
|
|
36
|
+
finite prefix size. The callback is pure. Returning `true` is a semantic promise
|
|
37
|
+
for every finite prefix of that fixed WHERE/ORDER, including larger windows and
|
|
38
|
+
optimistic headroom. It must not depend on the particular initial limit.
|
|
39
|
+
|
|
40
|
+
The adapter promises:
|
|
41
|
+
|
|
42
|
+
- Its complete filter and ordering are exact, or it conservatively supplies every
|
|
43
|
+
row needed for that exact prefix.
|
|
44
|
+
- Each ordered field has a homogeneous comparison domain matching DB's comparator.
|
|
45
|
+
- The final sort term is a unique, non-null key.
|
|
46
|
+
- Refetch preserves the served full-order prefix or reports an ordering invalidation.
|
|
47
|
+
|
|
48
|
+
The declaration establishes no freshness, completeness of an entire collection,
|
|
49
|
+
or readiness. Applied receipts, ownership, cancellation and failure rules remain
|
|
50
|
+
unchanged. An absent or declined declaration retains existing behavior.
|
|
51
|
+
|
|
52
|
+
## Implementation
|
|
53
|
+
|
|
54
|
+
Only direct source plans qualify. Core rejects joins, residual or functional
|
|
55
|
+
filters, computed sorts, groups, distinct and unions before asking the adapter.
|
|
56
|
+
For admitted plans, the existing loader:
|
|
57
|
+
|
|
58
|
+
1. Acquires a full-order prefix from offset zero using `requestSnapshot`.
|
|
59
|
+
2. Compares installed boundaries and sort-changing updates using every sort term.
|
|
60
|
+
3. Skips the leading-value tie acquisition.
|
|
61
|
+
4. Reuses its existing bounded repair, optimistic refill, receipt, retry and release paths.
|
|
62
|
+
|
|
63
|
+
Growth initially rereads a larger prefix, such as 51 → 101. This repeats some
|
|
64
|
+
provider work, but avoids changing cursor predicates or equality semantics. There
|
|
65
|
+
is no composite cursor, new index or additional result cache. A leading-only index
|
|
66
|
+
is never treated as a composite cursor index. An admitted window moved to a
|
|
67
|
+
negative offset, or incompatible admission across merged metadata views, uses the
|
|
68
|
+
established full-source fallback.
|
|
69
|
+
|
|
70
|
+
Party Stack derives admission from its ontology IR: exact filter/order analysis,
|
|
71
|
+
resolved scalar families, lexical string collation and a non-optional final
|
|
72
|
+
primary key. Optional non-key values retain explicit null placement. Unknown or
|
|
73
|
+
mixed domains, unsupported fields and custom/locale collation are declined.
|
|
74
|
+
Cached row samples cannot prove the declaration.
|
|
75
|
+
|
|
76
|
+
## Validation and upstreaming
|
|
77
|
+
|
|
78
|
+
Repository regressions cover typed admission, the timestamp-first query above,
|
|
79
|
+
boolean-leading ordering, window movement, negative offsets, mixed-domain and
|
|
80
|
+
missing-key fallback, deletes, trailing-sort changes, optimistic rollback and
|
|
81
|
+
confirmation, explicit invalidation, late receipts, retry and scoped cancellation.
|
|
82
|
+
The prototype additionally checks ascending/descending and null placement across
|
|
83
|
+
primitive, Instant and PlainDate domains against independent full-sort oracles,
|
|
84
|
+
and incompatible merged-source admission.
|
|
85
|
+
|
|
86
|
+
Before upstream acceptance, run DB's full ordered-loading, lifecycle, publication,
|
|
87
|
+
replay and optimistic oracle suites. The local patch changes three modules and
|
|
88
|
+
their distributed runtime/declaration equivalents. Published Party Stack consumers
|
|
89
|
+
do not inherit workspace pnpm patches; an upstream release is the distribution path.
|
|
90
|
+
|
|
91
|
+
Related reports: [boundary wait #2166](https://github.com/TanStack/db/issues/2166),
|
|
92
|
+
[leading-column pagination #1893](https://github.com/TanStack/db/pull/1893), and
|
|
93
|
+
[composite ordering #416](https://github.com/TanStack/db/issues/416).
|
package/package.json
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@party-stack/tanstack-db-patches",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Effect CLI setup for Party Stack's tested TanStack DB patches",
|
|
5
|
+
"bin": {
|
|
6
|
+
"tanstack-db-patches": "./lib/cli.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"lib",
|
|
10
|
+
"patches",
|
|
11
|
+
"ordered-window.md"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@effect/platform-node": "^4.0.5",
|
|
19
|
+
"@effect/vitest": "^4.0.5",
|
|
20
|
+
"@types/node": "^24.10.1",
|
|
21
|
+
"effect": "^4.0.5",
|
|
22
|
+
"typescript": "~7.0.2",
|
|
23
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.2.0",
|
|
24
|
+
"vite-plus": "1.2.0",
|
|
25
|
+
"@party-stack/build-config": "0.2.0"
|
|
26
|
+
}
|
|
6
27
|
}
|