@rindle/client 0.1.0-rc.5

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 (58) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +65 -0
  3. package/dist/ast.d.ts +83 -0
  4. package/dist/ast.d.ts.map +1 -0
  5. package/dist/ast.js +5 -0
  6. package/dist/ast.js.map +1 -0
  7. package/dist/compare.d.ts +17 -0
  8. package/dist/compare.d.ts.map +1 -0
  9. package/dist/compare.js +81 -0
  10. package/dist/compare.js.map +1 -0
  11. package/dist/index.d.ts +12 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +13 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/key.d.ts +2 -0
  16. package/dist/key.d.ts.map +1 -0
  17. package/dist/key.js +26 -0
  18. package/dist/key.js.map +1 -0
  19. package/dist/operators.d.ts +39 -0
  20. package/dist/operators.d.ts.map +1 -0
  21. package/dist/operators.js +45 -0
  22. package/dist/operators.js.map +1 -0
  23. package/dist/query.d.ts +280 -0
  24. package/dist/query.d.ts.map +1 -0
  25. package/dist/query.js +348 -0
  26. package/dist/query.js.map +1 -0
  27. package/dist/schema.d.ts +111 -0
  28. package/dist/schema.d.ts.map +1 -0
  29. package/dist/schema.js +92 -0
  30. package/dist/schema.js.map +1 -0
  31. package/dist/ssr.d.ts +73 -0
  32. package/dist/ssr.d.ts.map +1 -0
  33. package/dist/ssr.js +66 -0
  34. package/dist/ssr.js.map +1 -0
  35. package/dist/store.d.ts +90 -0
  36. package/dist/store.d.ts.map +1 -0
  37. package/dist/store.js +225 -0
  38. package/dist/store.js.map +1 -0
  39. package/dist/types.d.ts +250 -0
  40. package/dist/types.d.ts.map +1 -0
  41. package/dist/types.js +20 -0
  42. package/dist/types.js.map +1 -0
  43. package/dist/view.d.ts +88 -0
  44. package/dist/view.d.ts.map +1 -0
  45. package/dist/view.js +294 -0
  46. package/dist/view.js.map +1 -0
  47. package/package.json +36 -0
  48. package/src/ast.ts +94 -0
  49. package/src/compare.ts +85 -0
  50. package/src/index.ts +57 -0
  51. package/src/key.ts +23 -0
  52. package/src/operators.ts +68 -0
  53. package/src/query.ts +734 -0
  54. package/src/schema.ts +181 -0
  55. package/src/ssr.ts +115 -0
  56. package/src/store.ts +279 -0
  57. package/src/types.ts +234 -0
  58. package/src/view.ts +348 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # @rindle/client — backend-agnostic flat-change client core
2
+
3
+ The shared core for the flat-change client: a **typed schema + query builder**, the
4
+ **`ArrayView`** (folds a flat change stream into a live, materialized tree), the **comparator**,
5
+ the **`Store`**, and the **`Backend`** seam. It talks to no engine directly — pair it with a
6
+ backend such as [`@rindle/wasm`](../wasm) (local, in-process) or a remote (network) backend.
7
+
8
+ ## Schema + queries
9
+
10
+ ```ts
11
+ import { table, string, number, boolean, json, createSchema, eq, gt, ilike, or, exists } from "@rindle/client";
12
+
13
+ const issue = table("issue")
14
+ .columns({ id: number(), title: string(), priority: number(), meta: json<{ tags: string[] }>() })
15
+ .primaryKey("id");
16
+
17
+ const schema = createSchema({ tables: [issue] }); // pass to `new Store(schema, backend)`
18
+ ```
19
+
20
+ - **Operators** are named value-functions: `eq / ne / gt / ge / lt / le / like / ilike / inList / …`.
21
+ - **`where`** is a typed proxy — `where.closed(false)`, `where.priority(gt(3))` — with camelCase
22
+ sugar `whereClosed(false)`. Multiple `where`s are AND-ed.
23
+ - **`or` / `and` / `exists`** are plain top-level functions (no closure): conditions carry their
24
+ table type, e.g. `where(or(issue.priority(gt(8)), exists(comment, { parent: ["id"], child: ["issueID"] })))`.
25
+ - **Nesting** is `sub(alias, childTable, correlation, build?)` — explicit correlation, inline child
26
+ table, no schema-declared relationships.
27
+ - **Paging / single-row**: `orderBy(col, dir)`, `limit(n)`, `start(cursor, { exclusive })` (cursor
28
+ paging from a partial row over the sort columns), and `one()`.
29
+
30
+ The result type flows through: `store.query.issue.sub("comments", …).materialize()` yields an
31
+ `ArrayView` whose `.data` is typed `{ …issue, comments: Comment[] }[]`.
32
+
33
+ A top-level **`.one()`** flips `materialize()` to a `SingularArrayView` whose `.data` is the single
34
+ row or `null` (the engine caps the query to `limit 1`) — the unwrap is type-level too:
35
+
36
+ ```ts
37
+ const view = store.query.issue.where.id(id).one().materialize();
38
+ view.subscribe((row) => render(row)); // row: Issue | null, not Issue[]
39
+ ```
40
+
41
+ ## The Backend seam
42
+
43
+ A `Backend` emits a per-query `ChangeEvent` stream (`hello` → `snapshot` → `batch`) and accepts
44
+ mutations. The `Store` builds one `ArrayView` per query and routes events to it. The **same**
45
+ `Store` / `ArrayView` / builder work behind a local (WASM) or remote (network) backend — only the
46
+ backend differs.
47
+
48
+ ```ts
49
+ const store = new Store(schema, backend);
50
+ const view = store.query.issue.where.closed(false).materialize();
51
+ view.subscribe(render);
52
+ await store.write((tx) => tx.add("issue", { id: 1, title: "x", priority: 3, meta: { tags: [] } }));
53
+ ```
54
+
55
+ ## Reads
56
+
57
+ `view.data` is the materialized tree, reference-stable: an update re-projects only what changed, so
58
+ unchanged subtrees keep their object identity (React/Solid memoize on it). JSON columns are parsed
59
+ to objects on read.
60
+
61
+ ## Build
62
+
63
+ `pnpm run build` (from the repo root) compiles `src/` → `dist/` (`.js` + `.d.ts`) — what the package
64
+ publishes. In-repo, tooling resolves the TS source directly via the `@rindle/source` export condition,
65
+ so `pnpm test` runs without a build.
package/dist/ast.d.ts ADDED
@@ -0,0 +1,83 @@
1
+ export type Dir = "asc" | "desc";
2
+ /** One `(field, direction)` ordering — serializes as the 2-tuple `["id", "asc"]`. */
3
+ export type OrderPart = [field: string, dir: Dir];
4
+ /** An untagged literal (`null | bool | number | string | array`). Numbers are one f64. */
5
+ export type LitValue = null | boolean | number | string | LitValue[];
6
+ /** A column reference or a literal — `type`-tagged. */
7
+ export type ValuePosition = {
8
+ type: "column";
9
+ name: string;
10
+ } | {
11
+ type: "literal";
12
+ value: LitValue;
13
+ };
14
+ /** The wire comparison operators (exact strings, `src/ast.rs` `Op`). */
15
+ export type SimpleOp = "=" | "!=" | "<" | "<=" | ">" | ">=" | "IS" | "IS NOT" | "LIKE" | "NOT LIKE" | "ILIKE" | "NOT ILIKE" | "IN" | "NOT IN";
16
+ export type ExistsOp = "EXISTS" | "NOT EXISTS";
17
+ /** The filter tree — `type`-tagged; recursive. There is no generic NOT node (negation is
18
+ * via the negated operators and `NOT EXISTS`, matching `src/ast.rs` `Condition`). */
19
+ export type Condition = {
20
+ type: "simple";
21
+ op: SimpleOp;
22
+ left: ValuePosition;
23
+ right: ValuePosition;
24
+ } | {
25
+ type: "and";
26
+ conditions: Condition[];
27
+ } | {
28
+ type: "or";
29
+ conditions: Condition[];
30
+ } | {
31
+ type: "correlatedSubquery";
32
+ related: CorrelatedSubquery;
33
+ op: ExistsOp;
34
+ flip?: boolean;
35
+ scalar?: boolean;
36
+ };
37
+ export interface Correlation {
38
+ parentField: string[];
39
+ childField: string[];
40
+ }
41
+ /** A paging lower bound (`Bound`, `src/ast.rs`). `row` is a *partial* wire row — the bound
42
+ * columns by name (only the sort columns are read by the engine's `Skip` comparator).
43
+ * `exclusive` ⇒ start *after* the bound row (`Basis::After`); else *at* it (`Basis::At`). */
44
+ export interface Bound {
45
+ row: Record<string, LitValue>;
46
+ exclusive: boolean;
47
+ }
48
+ export interface CorrelatedSubquery {
49
+ correlation: Correlation;
50
+ subquery: Ast;
51
+ system?: "client" | "permissions" | "test";
52
+ }
53
+ /** An aggregate over a (correlated) subquery's rows (`REDUCE-DESIGN.md`). v1: `count(*)`.
54
+ * Set on a `related` subquery (`Ast.aggregate`), it marks that relationship a count
55
+ * aggregate the builder lowers to a scalar-projected singular relationship (§9). */
56
+ export type Aggregate = "count";
57
+ /** The query AST. `table` is the only required field; the builder omits empty/false fields
58
+ * (matching the Rust `skip_serializing_if`), which the deserializer treats as absent. */
59
+ export interface Ast {
60
+ table: string;
61
+ alias?: string;
62
+ /** Projection (PROJECTION-SUPPORT-DESIGN.md §6). Absent ⇒ select all columns; present ⇒
63
+ * project to just these (drives what syncs + what the view reports). Serializes only when
64
+ * set, matching the Rust `Ast.select`'s `skip_serializing_if`. */
65
+ select?: string[];
66
+ where?: Condition;
67
+ related?: CorrelatedSubquery[];
68
+ start?: Bound;
69
+ limit?: number;
70
+ one?: boolean;
71
+ /** Aggregate this (sub)query's rows instead of materializing them (`REDUCE-DESIGN.md`
72
+ * §9). `count` on a `related` subquery surfaces a scalar `commentCount` field; the
73
+ * builder lowers it to a scalar-projected singular relationship. Absent ⇒ ordinary rows. */
74
+ aggregate?: Aggregate;
75
+ /** The {@link Ast.aggregate} value is **precomputed** — supplied as rows of a (synthetic)
76
+ * source table rather than reduced from child rows. Set by the normalized client's AST
77
+ * rewrite (`AGGREGATE-SYNC-DESIGN.md` §3.3) so the local engine reads the server's count
78
+ * with a plain singular join + the same projection instead of a `reduce`. Only meaningful
79
+ * with `aggregate`; absent ⇒ `false`. */
80
+ aggregatePrecomputed?: boolean;
81
+ orderBy?: OrderPart[];
82
+ }
83
+ //# sourceMappingURL=ast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,GAAG,GAAG,KAAK,GAAG,MAAM,CAAC;AAEjC,qFAAqF;AACrF,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAElD,0FAA0F;AAC1F,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,EAAE,CAAC;AAErE,uDAAuD;AACvD,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE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M,CAAC;CAC5C;AAED;;qFAEqF;AACrF,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC;AAEhC;0FAC0F;AAC1F,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;uEAEmE;IACnE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd;;iGAE6F;IAC7F,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;8CAI0C;IAC1C,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;CACvB"}
package/dist/ast.js ADDED
@@ -0,0 +1,5 @@
1
+ // The Zero-wire query AST — the exact JSON shape the Rust `Ast` deserializes
2
+ // (src/ast.rs). The builder emits these; the wasm `Db.query` (and a remote server) parse
3
+ // them. camelCase keys, `type`-tagged unions, ops as SQL-ish strings, untagged literals.
4
+ export {};
5
+ //# sourceMappingURL=ast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.js","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,yFAAyF;AACzF,yFAAyF"}
@@ -0,0 +1,17 @@
1
+ import type { WireValue } from "./types.ts";
2
+ /** The `compare_values` / `compare_rows` algorithm-contract version (=== the engine's
3
+ * `wire_schema::COMPARATOR_VERSION`). A remote subscriber hard-rejects a `hello` whose
4
+ * `comparatorVersion` differs — the total order is a code contract, not data, so a schema
5
+ * fingerprint can't cover it. Bump in lockstep with the Rust constant if the order changes. */
6
+ export declare const COMPARATOR_VERSION = 1;
7
+ /** number compare with `f64::total_cmp` semantics (NaN deterministic & last; -0 < +0). */
8
+ export declare function compareNumber(a: number, b: number): -1 | 0 | 1;
9
+ /** UTF-8 bytewise string compare (=== SQLite `BINARY` / Rust `&str` Ord). Correct for
10
+ * supplementary-plane code points, where JS `<` / `localeCompare` (UTF-16) would disagree. */
11
+ export declare function compareString(a: string, b: string): -1 | 0 | 1;
12
+ /** Compare two bare cells, dispatching on the runtime type (null sorts first). */
13
+ export declare function compareValue(a: WireValue, b: WireValue): -1 | 0 | 1;
14
+ /** Compare two rows by a resolved sort (`[columnIndex, ascending]` pairs). First non-equal
15
+ * column wins; a descending column negates. */
16
+ export declare function compareRows(a: WireValue[], b: WireValue[], sort: [number, boolean][]): -1 | 0 | 1;
17
+ //# sourceMappingURL=compare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../src/compare.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI5C;;;gGAGgG;AAChG,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAepC,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAI9D;AAED;+FAC+F;AAC/F,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAQ9D;AAED,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAiBnE;AAED;gDACgD;AAChD,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAMjG"}
@@ -0,0 +1,81 @@
1
+ // The comparator — a faithful port of the engine's `compare_values` / `compare_rows`
2
+ // (src/value.rs §4 of FLAT-CHANGES-DESIGN.md), the single most correctness-critical unit
3
+ // (WASM-CLIENT-DESIGN.md §8.1). One fixed total order, NO collation.
4
+ //
5
+ // It is **value-driven** — it switches on the runtime JS type, exactly as the engine
6
+ // switches on the `OwnedValue` variant. Bare wire values collapse Int/Float → number and
7
+ // Str/Json → string, but within a sort column values are homogeneous, and number→total_cmp
8
+ // / string→bytewise cover both, so this matches the engine without needing column types:
9
+ //
10
+ // - null sorts FIRST (null < anything; null == null)
11
+ // - number: IEEE-754 totalOrder (=== Rust `f64::total_cmp`) — NOT `<` / `-`
12
+ // - boolean: false < true
13
+ // - string: UTF-8 BYTEWISE (=== SQLite BINARY / Rust `&str` Ord) — NOT `localeCompare`/`<`
14
+ const enc = new TextEncoder();
15
+ /** The `compare_values` / `compare_rows` algorithm-contract version (=== the engine's
16
+ * `wire_schema::COMPARATOR_VERSION`). A remote subscriber hard-rejects a `hello` whose
17
+ * `comparatorVersion` differs — the total order is a code contract, not data, so a schema
18
+ * fingerprint can't cover it. Bump in lockstep with the Rust constant if the order changes. */
19
+ export const COMPARATOR_VERSION = 1;
20
+ const SIGN = 0x8000000000000000n;
21
+ const ALL = 0xffffffffffffffffn;
22
+ /** Map an f64 to an unsigned 64-bit key whose unsigned order is IEEE-754 totalOrder
23
+ * (=== Rust `f64::total_cmp`): flip all bits for negatives (incl. -0 / -NaN), else set
24
+ * the sign bit. */
25
+ function orderedKey(x) {
26
+ const dv = new DataView(new ArrayBuffer(8));
27
+ dv.setFloat64(0, x);
28
+ const bits = dv.getBigUint64(0);
29
+ return bits & SIGN ? bits ^ ALL : bits | SIGN;
30
+ }
31
+ /** number compare with `f64::total_cmp` semantics (NaN deterministic & last; -0 < +0). */
32
+ export function compareNumber(a, b) {
33
+ const ka = orderedKey(a);
34
+ const kb = orderedKey(b);
35
+ return ka < kb ? -1 : ka > kb ? 1 : 0;
36
+ }
37
+ /** UTF-8 bytewise string compare (=== SQLite `BINARY` / Rust `&str` Ord). Correct for
38
+ * supplementary-plane code points, where JS `<` / `localeCompare` (UTF-16) would disagree. */
39
+ export function compareString(a, b) {
40
+ const ba = enc.encode(a);
41
+ const bb = enc.encode(b);
42
+ const n = Math.min(ba.length, bb.length);
43
+ for (let i = 0; i < n; i++) {
44
+ if (ba[i] !== bb[i])
45
+ return ba[i] < bb[i] ? -1 : 1;
46
+ }
47
+ return ba.length === bb.length ? 0 : ba.length < bb.length ? -1 : 1;
48
+ }
49
+ /** Compare two bare cells, dispatching on the runtime type (null sorts first). */
50
+ export function compareValue(a, b) {
51
+ const an = a === null || a === undefined;
52
+ const bn = b === null || b === undefined;
53
+ if (an && bn)
54
+ return 0;
55
+ if (an)
56
+ return -1;
57
+ if (bn)
58
+ return 1;
59
+ switch (typeof a) {
60
+ case "number":
61
+ return compareNumber(a, b);
62
+ case "boolean":
63
+ return a === b ? 0 : a ? 1 : -1;
64
+ case "string":
65
+ return compareString(a, b);
66
+ default:
67
+ // A parsed-JSON object in a sort column (rare): compare its text bytewise.
68
+ return compareString(JSON.stringify(a), JSON.stringify(b));
69
+ }
70
+ }
71
+ /** Compare two rows by a resolved sort (`[columnIndex, ascending]` pairs). First non-equal
72
+ * column wins; a descending column negates. */
73
+ export function compareRows(a, b, sort) {
74
+ for (const [col, asc] of sort) {
75
+ const c = compareValue(a[col], b[col]);
76
+ if (c !== 0)
77
+ return asc ? c : (-c);
78
+ }
79
+ return 0;
80
+ }
81
+ //# sourceMappingURL=compare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.js","sourceRoot":"","sources":["../src/compare.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,yFAAyF;AACzF,qEAAqE;AACrE,EAAE;AACF,qFAAqF;AACrF,yFAAyF;AACzF,2FAA2F;AAC3F,yFAAyF;AACzF,EAAE;AACF,uDAAuD;AACvD,+EAA+E;AA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AAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC;AAED;gDACgD;AAChD,MAAM,UAAU,WAAW,CAAC,CAAc,EAAE,CAAc,EAAE,IAAyB;IACnF,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC;YAAE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAY,CAAC;IACjD,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,12 @@
1
+ export * from "./schema.ts";
2
+ export * from "./operators.ts";
3
+ export * from "./query.ts";
4
+ export * from "./view.ts";
5
+ export * from "./store.ts";
6
+ export * from "./ssr.ts";
7
+ export { stableKey } from "./key.ts";
8
+ export { COMPARATOR_VERSION, compareNumber, compareRows, compareString, compareValue } from "./compare.ts";
9
+ export type { Backend, ChangeEvent, ColType, FlatChange, FlatOp, Mutation, MutationEnvelope, NormalizedEvent, NormalizedOp, NormalizedSource, NormalizedTableSchema, OptimisticSource, PathSeg, ProgressFrame, QueryId, RemoteQuery, ResultType, WireNode, WireProjection, WireRel, WireSchema, WireValue, } from "./types.ts";
10
+ export { CLIENT_MUTATIONS_SCHEMA, CLIENT_MUTATIONS_TABLE, LMID_QUERY_NAME } from "./types.ts";
11
+ export type { Aggregate, Ast, Bound, Condition, CorrelatedSubquery, Correlation, Dir, ExistsOp, LitValue, OrderPart, SimpleOp, ValuePosition, } from "./ast.ts";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE3G,YAAY,EACV,OAAO,EACP,WAAW,EACX,OAAO,EACP,UAAU,EACV,MAAM,EACN,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,OAAO,EACP,WAAW,EACX,UAAU,EACV,QAAQ,EACR,cAAc,EACd,OAAO,EACP,UAAU,EACV,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG9F,YAAY,EACV,SAAS,EACT,GAAG,EACH,KAAK,EACL,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,aAAa,GACd,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ // @rindle/client — the backend-agnostic flat-change client core: typed schema, query builder,
2
+ // comparator, Backend seam, and the ArrayView contract. (The ArrayView folding impl + the
3
+ // Store/backend wiring land in later slices.)
4
+ export * from "./schema.js"; // table/columns/primaryKey, createSchema, string/number/boolean/json, Col, RowOf, Row, TableDef, tableSpec, SCHEMA
5
+ export * from "./operators.js"; // eq/ne/gt/ge/lt/le/like/notLike/ilike/notIlike/inList/notInList/is/isNot, and/or, Pred, Cond, Arg
6
+ export * from "./query.js"; // Query, QueryRoot, queries/newQueryBuilder, defineQuery/NamedQuery, exists, notExists, defineFragment/Fragment/FragmentRef/isFragment
7
+ export * from "./view.js"; // ArrayView, SingularArrayView, FlatArrayView, SingularView, ViewTypes
8
+ export * from "./store.js"; // Store, WriteTx, AssembledNode, DehydratedQuery, DehydratedState
9
+ export * from "./ssr.js"; // createServerStore, ServerStore, OneShotBackend, OneShotQueryFn, OneShotResult, ServerStoreOptions
10
+ export { stableKey } from "./key.js"; // canonical viewKey for an AST (shared with @rindle/react)
11
+ export { COMPARATOR_VERSION, compareNumber, compareRows, compareString, compareValue } from "./compare.js";
12
+ export { CLIENT_MUTATIONS_SCHEMA, CLIENT_MUTATIONS_TABLE, LMID_QUERY_NAME } from "./types.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,0FAA0F;AAC1F,8CAA8C;AAE9C,cAAc,aAAa,CAAC,CAAC,mHAAmH;AAChJ,cAAc,gBAAgB,CAAC,CAAC,mGAAmG;AACnI,cAAc,YAAY,CAAC,CAAC,uIAAuI;AACnK,cAAc,WAAW,CAAC,CAAC,uEAAuE;AAClG,cAAc,YAAY,CAAC,CAAC,kEAAkE;AAC9F,cAAc,UAAU,CAAC,CAAC,oGAAoG;AAE9H,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC,CAAC,2DAA2D;AAEjG,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA2B3G,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
package/dist/key.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function stableKey(value: unknown, seen?: WeakSet<object>): string;
2
+ //# sourceMappingURL=key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../src/key.ts"],"names":[],"mappings":"AAKA,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,kBAAwB,GAAG,MAAM,CAiB9E"}
package/dist/key.js ADDED
@@ -0,0 +1,26 @@
1
+ // A stable, canonical JSON string for a query AST — the `viewKey` shared by the React cache
2
+ // (one cached view per AST) and the SSR dehydrate/hydrate map (seed lookup by AST). Both sides
3
+ // MUST agree byte-for-byte, so the one canonical serializer lives here. Object keys are sorted;
4
+ // `undefined` is encoded distinctly (so `{a:undefined}` ≠ `{}`); cycles throw.
5
+ export function stableKey(value, seen = new WeakSet()) {
6
+ if (value === undefined)
7
+ return '{"$undefined":true}';
8
+ if (value === null || typeof value !== "object")
9
+ return JSON.stringify(value);
10
+ if (seen.has(value))
11
+ throw new TypeError("Rindle query keys must be acyclic JSON values");
12
+ seen.add(value);
13
+ if (Array.isArray(value)) {
14
+ const out = `[${value.map((v) => stableKey(v, seen)).join(",")}]`;
15
+ seen.delete(value);
16
+ return out;
17
+ }
18
+ const obj = value;
19
+ const out = `{${Object.keys(obj)
20
+ .sort()
21
+ .map((k) => `${JSON.stringify(k)}:${stableKey(obj[k], seen)}`)
22
+ .join(",")}}`;
23
+ seen.delete(value);
24
+ return out;
25
+ }
26
+ //# sourceMappingURL=key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key.js","sourceRoot":"","sources":["../src/key.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,+FAA+F;AAC/F,gGAAgG;AAChG,+EAA+E;AAE/E,MAAM,UAAU,SAAS,CAAC,KAAc,EAAE,OAAO,IAAI,OAAO,EAAU;IACpE,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,qBAAqB,CAAC;IACtD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9E,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,+CAA+C,CAAC,CAAC;IAC1F,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QAClE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnB,OAAO,GAAG,CAAC;IACb,CAAC;IACD,MAAM,GAAG,GAAG,KAAgC,CAAC;IAC7C,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;SAC7B,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;SAC7D,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAChB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnB,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { Condition, LitValue, SimpleOp } from "./ast.ts";
2
+ declare const PRED: unique symbol;
3
+ /** A value predicate (an operator applied to a value). `V` is a phantom for type-checking. */
4
+ export interface Pred<V> {
5
+ readonly [PRED]: true;
6
+ readonly op: SimpleOp;
7
+ readonly value: LitValue;
8
+ readonly __v?: V;
9
+ }
10
+ export declare function isPred(x: unknown): x is Pred<unknown>;
11
+ export declare const eq: <V>(v: V) => Pred<V>;
12
+ export declare const ne: <V>(v: V) => Pred<V>;
13
+ export declare const gt: <V extends number | string>(v: V) => Pred<V>;
14
+ export declare const ge: <V extends number | string>(v: V) => Pred<V>;
15
+ export declare const lt: <V extends number | string>(v: V) => Pred<V>;
16
+ export declare const le: <V extends number | string>(v: V) => Pred<V>;
17
+ export declare const like: (pattern: string) => Pred<string>;
18
+ export declare const notLike: (pattern: string) => Pred<string>;
19
+ export declare const ilike: (pattern: string) => Pred<string>;
20
+ export declare const notIlike: (pattern: string) => Pred<string>;
21
+ export declare const inList: <V>(values: V[]) => Pred<V>;
22
+ export declare const notInList: <V>(values: V[]) => Pred<V>;
23
+ export declare const is: <V>(v: V) => Pred<V>;
24
+ export declare const isNot: <V>(v: V) => Pred<V>;
25
+ /** A field argument: its typed predicate, or a bare value (bare = `eq` sugar). */
26
+ export type Arg<V> = Pred<V> | V;
27
+ /** A condition over row `R`. The runtime value is the wire {@link Condition}; `R` is a
28
+ * phantom brand so a condition for one table can't be `.where()`d onto another. */
29
+ export type Cond<R> = Condition & {
30
+ readonly __row?: R;
31
+ };
32
+ /** Build a `simple` condition from a field name + (predicate | bare value). */
33
+ export declare function fieldCondition(field: string, arg: unknown): Condition;
34
+ /** All children must hold. */
35
+ export declare function and<R>(...conds: Cond<R>[]): Cond<R>;
36
+ /** At least one child must hold. */
37
+ export declare function or<R>(...conds: Cond<R>[]): Cond<R>;
38
+ export {};
39
+ //# sourceMappingURL=operators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../src/operators.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE9D,QAAA,MAAM,IAAI,EAAE,OAAO,MAA8B,CAAC;AAElD,8FAA8F;AAC9F,MAAM,WAAW,IAAI,CAAC,CAAC;IACrB,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,GAAG,CA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