@firtoz/collection-sync 5.0.0 → 6.0.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/README.md +46 -0
- package/dist/cache-manager.d.ts +52 -0
- package/dist/cache-manager.js +5 -0
- package/dist/cache-manager.js.map +1 -0
- package/dist/chunk-3EHHMLSV.js +57 -0
- package/dist/chunk-3EHHMLSV.js.map +1 -0
- package/dist/chunk-43KYAIKY.js +46 -0
- package/dist/chunk-43KYAIKY.js.map +1 -0
- package/dist/chunk-4BEXLBCH.js +64 -0
- package/dist/chunk-4BEXLBCH.js.map +1 -0
- package/dist/chunk-5V6BSQAB.js +148 -0
- package/dist/chunk-5V6BSQAB.js.map +1 -0
- package/dist/chunk-5VMFQT5Z.js +112 -0
- package/dist/chunk-5VMFQT5Z.js.map +1 -0
- package/dist/chunk-6EHROJFY.js +111 -0
- package/dist/chunk-6EHROJFY.js.map +1 -0
- package/dist/chunk-6X3434GJ.js +21 -0
- package/dist/chunk-6X3434GJ.js.map +1 -0
- package/dist/chunk-BGJH6PH2.js +175 -0
- package/dist/chunk-BGJH6PH2.js.map +1 -0
- package/dist/chunk-BJJEAKXL.js +252 -0
- package/dist/chunk-BJJEAKXL.js.map +1 -0
- package/dist/chunk-GWIOC5CP.js +51 -0
- package/dist/chunk-GWIOC5CP.js.map +1 -0
- package/dist/chunk-HMLY7DHA.js +12 -0
- package/dist/chunk-HMLY7DHA.js.map +1 -0
- package/dist/chunk-I6RJWBGF.js +112 -0
- package/dist/chunk-I6RJWBGF.js.map +1 -0
- package/dist/chunk-M5MJHS6A.js +10 -0
- package/dist/chunk-M5MJHS6A.js.map +1 -0
- package/dist/chunk-O3KBDCEI.js +615 -0
- package/dist/chunk-O3KBDCEI.js.map +1 -0
- package/dist/chunk-OP53UBPN.js +19 -0
- package/dist/chunk-OP53UBPN.js.map +1 -0
- package/dist/chunk-P3JOTUAB.js +802 -0
- package/dist/chunk-P3JOTUAB.js.map +1 -0
- package/dist/chunk-QJP4GSJH.js +373 -0
- package/dist/chunk-QJP4GSJH.js.map +1 -0
- package/dist/chunk-RDDS7JQW.js +623 -0
- package/dist/chunk-RDDS7JQW.js.map +1 -0
- package/dist/chunk-TEH7V76G.js +209 -0
- package/dist/chunk-TEH7V76G.js.map +1 -0
- package/dist/chunk-UJ24XW52.js +20 -0
- package/dist/chunk-UJ24XW52.js.map +1 -0
- package/dist/chunk-UVZJL6QV.js +18 -0
- package/dist/chunk-UVZJL6QV.js.map +1 -0
- package/dist/chunk-XC4QNFSQ.js +238 -0
- package/dist/chunk-XC4QNFSQ.js.map +1 -0
- package/dist/chunk-YD5LVGWX.js +125 -0
- package/dist/chunk-YD5LVGWX.js.map +1 -0
- package/dist/chunk-YYGPIHHJ.js +166 -0
- package/dist/chunk-YYGPIHHJ.js.map +1 -0
- package/dist/connect-partial-sync.d.ts +41 -0
- package/dist/connect-partial-sync.js +6 -0
- package/dist/connect-partial-sync.js.map +1 -0
- package/dist/connect-sync.d.ts +26 -0
- package/dist/connect-sync.js +5 -0
- package/dist/connect-sync.js.map +1 -0
- package/dist/create-partial-synced-collection.d.ts +24 -0
- package/dist/create-partial-synced-collection.js +8 -0
- package/dist/create-partial-synced-collection.js.map +1 -0
- package/dist/create-synced-collection.d.ts +26 -0
- package/dist/create-synced-collection.js +8 -0
- package/dist/create-synced-collection.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/partial-sync-client-bridge.d.ts +157 -0
- package/dist/partial-sync-client-bridge.js +6 -0
- package/dist/partial-sync-client-bridge.js.map +1 -0
- package/dist/partial-sync-interest.d.ts +48 -0
- package/dist/partial-sync-interest.js +6 -0
- package/dist/partial-sync-interest.js.map +1 -0
- package/dist/partial-sync-mutation-handler.d.ts +31 -0
- package/dist/partial-sync-mutation-handler.js +6 -0
- package/dist/partial-sync-mutation-handler.js.map +1 -0
- package/dist/partial-sync-predicate-match.d.ts +8 -0
- package/dist/partial-sync-predicate-match.js +4 -0
- package/dist/partial-sync-predicate-match.js.map +1 -0
- package/dist/partial-sync-row-key.d.ts +41 -0
- package/dist/partial-sync-row-key.js +4 -0
- package/dist/partial-sync-row-key.js.map +1 -0
- package/dist/partial-sync-server-bridge.d.ts +102 -0
- package/dist/partial-sync-server-bridge.js +8 -0
- package/dist/partial-sync-server-bridge.js.map +1 -0
- package/dist/react/constants.d.ts +12 -0
- package/dist/react/constants.js +4 -0
- package/dist/react/constants.js.map +1 -0
- package/dist/react/index.d.ts +19 -0
- package/dist/react/index.js +17 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/partial-sync-adapter.d.ts +40 -0
- package/dist/react/partial-sync-adapter.js +4 -0
- package/dist/react/partial-sync-adapter.js.map +1 -0
- package/dist/react/partial-sync-utils.d.ts +42 -0
- package/dist/react/partial-sync-utils.js +5 -0
- package/dist/react/partial-sync-utils.js.map +1 -0
- package/dist/react/range-conditions-expression.d.ts +49 -0
- package/dist/react/range-conditions-expression.js +4 -0
- package/dist/react/range-conditions-expression.js.map +1 -0
- package/dist/react/types.d.ts +196 -0
- package/dist/react/types.js +3 -0
- package/dist/react/types.js.map +1 -0
- package/dist/react/usePartialSyncCollection.d.ts +20 -0
- package/dist/react/usePartialSyncCollection.js +10 -0
- package/dist/react/usePartialSyncCollection.js.map +1 -0
- package/dist/react/usePartialSyncViewport.d.ts +20 -0
- package/dist/react/usePartialSyncViewport.js +7 -0
- package/dist/react/usePartialSyncViewport.js.map +1 -0
- package/dist/react/usePartialSyncWindow.d.ts +17 -0
- package/dist/react/usePartialSyncWindow.js +12 -0
- package/dist/react/usePartialSyncWindow.js.map +1 -0
- package/dist/react/usePredicateFilteredRows.d.ts +20 -0
- package/dist/react/usePredicateFilteredRows.js +6 -0
- package/dist/react/usePredicateFilteredRows.js.map +1 -0
- package/dist/sync-client-bridge.d.ts +48 -0
- package/dist/sync-client-bridge.js +6 -0
- package/dist/sync-client-bridge.js.map +1 -0
- package/dist/sync-protocol.d.ts +378 -0
- package/dist/sync-protocol.js +4 -0
- package/dist/sync-protocol.js.map +1 -0
- package/dist/sync-server-bridge.d.ts +35 -0
- package/dist/sync-server-bridge.js +6 -0
- package/dist/sync-server-bridge.js.map +1 -0
- package/dist/with-sync.d.ts +107 -0
- package/dist/with-sync.js +7 -0
- package/dist/with-sync.js.map +1 -0
- package/package.json +23 -17
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { SyncMessage } from '@firtoz/db-helpers';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/** Default {@link SyncClientMessage} / {@link SyncServerMessage} `collectionId` when omitted on the wire. */
|
|
5
|
+
declare const DEFAULT_SYNC_COLLECTION_ID: "default";
|
|
6
|
+
declare const mutationIntentSchema: z.ZodObject<{
|
|
7
|
+
clientMutationId: z.ZodString;
|
|
8
|
+
type: z.ZodEnum<{
|
|
9
|
+
insert: "insert";
|
|
10
|
+
update: "update";
|
|
11
|
+
delete: "delete";
|
|
12
|
+
truncate: "truncate";
|
|
13
|
+
}>;
|
|
14
|
+
value: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
15
|
+
previousValue: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
16
|
+
key: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
type MutationIntent = z.infer<typeof mutationIntentSchema>;
|
|
19
|
+
type SyncSortDirection = "asc" | "desc";
|
|
20
|
+
type SyncRangeSort = {
|
|
21
|
+
column: string;
|
|
22
|
+
direction: SyncSortDirection;
|
|
23
|
+
};
|
|
24
|
+
/** Fixed operator set for predicate-based range queries (e.g. spatial filters). */
|
|
25
|
+
type RangeConditionOp = "gt" | "gte" | "lt" | "lte" | "eq" | "neq" | "between";
|
|
26
|
+
type RangeCondition = {
|
|
27
|
+
column: string;
|
|
28
|
+
op: RangeConditionOp;
|
|
29
|
+
value: unknown;
|
|
30
|
+
/** Required when `op` is `"between"`. */
|
|
31
|
+
valueTo?: unknown;
|
|
32
|
+
};
|
|
33
|
+
type IndexRangeCursor = {
|
|
34
|
+
kind: "index";
|
|
35
|
+
mode: "cursor";
|
|
36
|
+
sort: SyncRangeSort;
|
|
37
|
+
limit: number;
|
|
38
|
+
afterCursor: unknown | null;
|
|
39
|
+
};
|
|
40
|
+
type IndexRangeOffset = {
|
|
41
|
+
kind: "index";
|
|
42
|
+
mode: "offset";
|
|
43
|
+
sort: SyncRangeSort;
|
|
44
|
+
limit: number;
|
|
45
|
+
offset: number;
|
|
46
|
+
};
|
|
47
|
+
type PredicateRange = {
|
|
48
|
+
kind: "predicate";
|
|
49
|
+
conditions: RangeCondition[];
|
|
50
|
+
sort?: SyncRangeSort;
|
|
51
|
+
limit?: number;
|
|
52
|
+
};
|
|
53
|
+
type SyncRange = IndexRangeCursor | IndexRangeOffset | PredicateRange;
|
|
54
|
+
/** Client watermark for reconciliation (max row version in range + count). */
|
|
55
|
+
type RangeFingerprint = {
|
|
56
|
+
version: number;
|
|
57
|
+
count: number;
|
|
58
|
+
};
|
|
59
|
+
declare const syncRangeSchema: z.ZodType<SyncRange>;
|
|
60
|
+
declare function createClientMessageSchema(): z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
61
|
+
type: z.ZodLiteral<"mutateBatch">;
|
|
62
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
63
|
+
clientId: z.ZodString;
|
|
64
|
+
mutations: z.ZodArray<z.ZodObject<{
|
|
65
|
+
clientMutationId: z.ZodString;
|
|
66
|
+
type: z.ZodEnum<{
|
|
67
|
+
insert: "insert";
|
|
68
|
+
update: "update";
|
|
69
|
+
delete: "delete";
|
|
70
|
+
truncate: "truncate";
|
|
71
|
+
}>;
|
|
72
|
+
value: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
73
|
+
previousValue: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
74
|
+
key: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
75
|
+
}, z.core.$strip>>;
|
|
76
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
77
|
+
type: z.ZodLiteral<"syncHello">;
|
|
78
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
79
|
+
clientId: z.ZodString;
|
|
80
|
+
lastAckedServerVersion: z.ZodNumber;
|
|
81
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
82
|
+
type: z.ZodLiteral<"ping">;
|
|
83
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
84
|
+
clientId: z.ZodString;
|
|
85
|
+
timestamp: z.ZodNumber;
|
|
86
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
87
|
+
type: z.ZodLiteral<"queryRange">;
|
|
88
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
89
|
+
clientId: z.ZodString;
|
|
90
|
+
requestId: z.ZodString;
|
|
91
|
+
sort: z.ZodObject<{
|
|
92
|
+
column: z.ZodString;
|
|
93
|
+
direction: z.ZodEnum<{
|
|
94
|
+
asc: "asc";
|
|
95
|
+
desc: "desc";
|
|
96
|
+
}>;
|
|
97
|
+
}, z.core.$strip>;
|
|
98
|
+
limit: z.ZodNumber;
|
|
99
|
+
afterCursor: z.ZodNullable<z.ZodUnknown>;
|
|
100
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
101
|
+
type: z.ZodLiteral<"queryByOffset">;
|
|
102
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
103
|
+
clientId: z.ZodString;
|
|
104
|
+
requestId: z.ZodString;
|
|
105
|
+
sort: z.ZodObject<{
|
|
106
|
+
column: z.ZodString;
|
|
107
|
+
direction: z.ZodEnum<{
|
|
108
|
+
asc: "asc";
|
|
109
|
+
desc: "desc";
|
|
110
|
+
}>;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
limit: z.ZodNumber;
|
|
113
|
+
offset: z.ZodNumber;
|
|
114
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
115
|
+
type: z.ZodLiteral<"rangeQuery">;
|
|
116
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
117
|
+
clientId: z.ZodString;
|
|
118
|
+
requestId: z.ZodString;
|
|
119
|
+
range: z.ZodType<SyncRange, unknown, z.core.$ZodTypeInternals<SyncRange, unknown>>;
|
|
120
|
+
fingerprint: z.ZodOptional<z.ZodObject<{
|
|
121
|
+
version: z.ZodNumber;
|
|
122
|
+
count: z.ZodNumber;
|
|
123
|
+
}, z.core.$strip>>;
|
|
124
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
125
|
+
type: z.ZodLiteral<"rangeReconcile">;
|
|
126
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
127
|
+
clientId: z.ZodString;
|
|
128
|
+
requestId: z.ZodString;
|
|
129
|
+
range: z.ZodType<SyncRange, unknown, z.core.$ZodTypeInternals<SyncRange, unknown>>;
|
|
130
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
131
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
132
|
+
version: z.ZodNumber;
|
|
133
|
+
}, z.core.$strip>>;
|
|
134
|
+
}, z.core.$strip>], "type">;
|
|
135
|
+
type SyncClientMessage = z.infer<ReturnType<typeof createClientMessageSchema>>;
|
|
136
|
+
declare const clientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
137
|
+
type: z.ZodLiteral<"mutateBatch">;
|
|
138
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
139
|
+
clientId: z.ZodString;
|
|
140
|
+
mutations: z.ZodArray<z.ZodObject<{
|
|
141
|
+
clientMutationId: z.ZodString;
|
|
142
|
+
type: z.ZodEnum<{
|
|
143
|
+
insert: "insert";
|
|
144
|
+
update: "update";
|
|
145
|
+
delete: "delete";
|
|
146
|
+
truncate: "truncate";
|
|
147
|
+
}>;
|
|
148
|
+
value: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
149
|
+
previousValue: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
150
|
+
key: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
151
|
+
}, z.core.$strip>>;
|
|
152
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
153
|
+
type: z.ZodLiteral<"syncHello">;
|
|
154
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
155
|
+
clientId: z.ZodString;
|
|
156
|
+
lastAckedServerVersion: z.ZodNumber;
|
|
157
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
158
|
+
type: z.ZodLiteral<"ping">;
|
|
159
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
160
|
+
clientId: z.ZodString;
|
|
161
|
+
timestamp: z.ZodNumber;
|
|
162
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
163
|
+
type: z.ZodLiteral<"queryRange">;
|
|
164
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
165
|
+
clientId: z.ZodString;
|
|
166
|
+
requestId: z.ZodString;
|
|
167
|
+
sort: z.ZodObject<{
|
|
168
|
+
column: z.ZodString;
|
|
169
|
+
direction: z.ZodEnum<{
|
|
170
|
+
asc: "asc";
|
|
171
|
+
desc: "desc";
|
|
172
|
+
}>;
|
|
173
|
+
}, z.core.$strip>;
|
|
174
|
+
limit: z.ZodNumber;
|
|
175
|
+
afterCursor: z.ZodNullable<z.ZodUnknown>;
|
|
176
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
177
|
+
type: z.ZodLiteral<"queryByOffset">;
|
|
178
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
179
|
+
clientId: z.ZodString;
|
|
180
|
+
requestId: z.ZodString;
|
|
181
|
+
sort: z.ZodObject<{
|
|
182
|
+
column: z.ZodString;
|
|
183
|
+
direction: z.ZodEnum<{
|
|
184
|
+
asc: "asc";
|
|
185
|
+
desc: "desc";
|
|
186
|
+
}>;
|
|
187
|
+
}, z.core.$strip>;
|
|
188
|
+
limit: z.ZodNumber;
|
|
189
|
+
offset: z.ZodNumber;
|
|
190
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
191
|
+
type: z.ZodLiteral<"rangeQuery">;
|
|
192
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
193
|
+
clientId: z.ZodString;
|
|
194
|
+
requestId: z.ZodString;
|
|
195
|
+
range: z.ZodType<SyncRange, unknown, z.core.$ZodTypeInternals<SyncRange, unknown>>;
|
|
196
|
+
fingerprint: z.ZodOptional<z.ZodObject<{
|
|
197
|
+
version: z.ZodNumber;
|
|
198
|
+
count: z.ZodNumber;
|
|
199
|
+
}, z.core.$strip>>;
|
|
200
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
201
|
+
type: z.ZodLiteral<"rangeReconcile">;
|
|
202
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
203
|
+
clientId: z.ZodString;
|
|
204
|
+
requestId: z.ZodString;
|
|
205
|
+
range: z.ZodType<SyncRange, unknown, z.core.$ZodTypeInternals<SyncRange, unknown>>;
|
|
206
|
+
manifest: z.ZodArray<z.ZodObject<{
|
|
207
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
208
|
+
version: z.ZodNumber;
|
|
209
|
+
}, z.core.$strip>>;
|
|
210
|
+
}, z.core.$strip>], "type">;
|
|
211
|
+
/** How to apply {@link SyncServerMessage} `syncBackfill` changes on the client. */
|
|
212
|
+
type SyncBackfillMode = "snapshot" | "delta";
|
|
213
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
214
|
+
/** Client payload before `collectionId` is attached (bridge outbox helpers). */
|
|
215
|
+
type SyncClientMessageBody = DistributiveOmit<SyncClientMessage, "collectionId">;
|
|
216
|
+
declare function createServerMessageSchema<TItem = unknown, TKey extends string | number = string | number>(): z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
217
|
+
type: z.ZodLiteral<"ack">;
|
|
218
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
219
|
+
clientId: z.ZodString;
|
|
220
|
+
clientMutationIds: z.ZodArray<z.ZodString>;
|
|
221
|
+
serverVersion: z.ZodNumber;
|
|
222
|
+
changes: z.ZodArray<z.ZodCustom<SyncMessage<TItem, TKey>, SyncMessage<TItem, TKey>>>;
|
|
223
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
224
|
+
type: z.ZodLiteral<"syncBatch">;
|
|
225
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
226
|
+
serverVersion: z.ZodNumber;
|
|
227
|
+
changes: z.ZodArray<z.ZodCustom<SyncMessage<TItem, TKey>, SyncMessage<TItem, TKey>>>;
|
|
228
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
229
|
+
type: z.ZodLiteral<"syncBackfill">;
|
|
230
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
231
|
+
mode: z.ZodEnum<{
|
|
232
|
+
snapshot: "snapshot";
|
|
233
|
+
delta: "delta";
|
|
234
|
+
}>;
|
|
235
|
+
serverVersion: z.ZodNumber;
|
|
236
|
+
changes: z.ZodArray<z.ZodCustom<SyncMessage<TItem, TKey>, SyncMessage<TItem, TKey>>>;
|
|
237
|
+
chunkIndex: z.ZodOptional<z.ZodNumber>;
|
|
238
|
+
totalChunks: z.ZodOptional<z.ZodNumber>;
|
|
239
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
240
|
+
type: z.ZodLiteral<"reject">;
|
|
241
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
242
|
+
clientId: z.ZodString;
|
|
243
|
+
clientMutationId: z.ZodString;
|
|
244
|
+
reason: z.ZodString;
|
|
245
|
+
correctiveChanges: z.ZodDefault<z.ZodArray<z.ZodCustom<SyncMessage<TItem, TKey>, SyncMessage<TItem, TKey>>>>;
|
|
246
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
247
|
+
type: z.ZodLiteral<"pong">;
|
|
248
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
249
|
+
timestamp: z.ZodNumber;
|
|
250
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
251
|
+
type: z.ZodLiteral<"queryRangeChunk">;
|
|
252
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
253
|
+
requestId: z.ZodString;
|
|
254
|
+
rows: z.ZodArray<z.ZodCustom<TItem, TItem>>;
|
|
255
|
+
totalCount: z.ZodNumber;
|
|
256
|
+
lastCursor: z.ZodNullable<z.ZodUnknown>;
|
|
257
|
+
hasMore: z.ZodBoolean;
|
|
258
|
+
chunkIndex: z.ZodNumber;
|
|
259
|
+
done: z.ZodBoolean;
|
|
260
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
261
|
+
type: z.ZodLiteral<"rangePatch">;
|
|
262
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
263
|
+
change: z.ZodCustom<SyncMessage<TItem, TKey>, SyncMessage<TItem, TKey>>;
|
|
264
|
+
viewTransition: z.ZodOptional<z.ZodEnum<{
|
|
265
|
+
enterView: "enterView";
|
|
266
|
+
exitView: "exitView";
|
|
267
|
+
}>>;
|
|
268
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
269
|
+
type: z.ZodLiteral<"rangeUpToDate">;
|
|
270
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
271
|
+
requestId: z.ZodString;
|
|
272
|
+
totalCount: z.ZodNumber;
|
|
273
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
274
|
+
type: z.ZodLiteral<"rangeDelta">;
|
|
275
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
276
|
+
requestId: z.ZodString;
|
|
277
|
+
totalCount: z.ZodNumber;
|
|
278
|
+
changes: z.ZodArray<z.ZodCustom<SyncMessage<TItem, TKey>, SyncMessage<TItem, TKey>>>;
|
|
279
|
+
lastCursor: z.ZodOptional<z.ZodUnknown>;
|
|
280
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
281
|
+
type: z.ZodLiteral<"rangeReconcileResult">;
|
|
282
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
283
|
+
requestId: z.ZodString;
|
|
284
|
+
added: z.ZodArray<z.ZodCustom<SyncMessage<TItem, TKey>, SyncMessage<TItem, TKey>>>;
|
|
285
|
+
updated: z.ZodArray<z.ZodCustom<SyncMessage<TItem, TKey>, SyncMessage<TItem, TKey>>>;
|
|
286
|
+
stale: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
287
|
+
movedHints: z.ZodArray<z.ZodObject<{
|
|
288
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
289
|
+
hint: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
290
|
+
}, z.core.$strip>>;
|
|
291
|
+
totalCount: z.ZodNumber;
|
|
292
|
+
}, z.core.$strip>], "type">;
|
|
293
|
+
type SyncServerMessage<TItem = unknown, TKey extends string | number = string | number> = z.infer<ReturnType<typeof createServerMessageSchema<TItem, TKey>>>;
|
|
294
|
+
/** Server payload before `collectionId` is attached (bridge outbox helpers). */
|
|
295
|
+
type SyncServerMessageBody<TItem = unknown, TKey extends string | number = string | number> = DistributiveOmit<SyncServerMessage<TItem, TKey>, "collectionId">;
|
|
296
|
+
/** Attach `collectionId` to an outbound server message (single-collection servers). */
|
|
297
|
+
declare function withServerCollectionId<TItem, TKey extends string | number>(collectionId: string, message: SyncServerMessage<TItem, TKey>): SyncServerMessage<TItem, TKey>;
|
|
298
|
+
declare const serverMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
299
|
+
type: z.ZodLiteral<"ack">;
|
|
300
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
301
|
+
clientId: z.ZodString;
|
|
302
|
+
clientMutationIds: z.ZodArray<z.ZodString>;
|
|
303
|
+
serverVersion: z.ZodNumber;
|
|
304
|
+
changes: z.ZodArray<z.ZodCustom<SyncMessage<unknown, string | number>, SyncMessage<unknown, string | number>>>;
|
|
305
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
306
|
+
type: z.ZodLiteral<"syncBatch">;
|
|
307
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
308
|
+
serverVersion: z.ZodNumber;
|
|
309
|
+
changes: z.ZodArray<z.ZodCustom<SyncMessage<unknown, string | number>, SyncMessage<unknown, string | number>>>;
|
|
310
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
311
|
+
type: z.ZodLiteral<"syncBackfill">;
|
|
312
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
313
|
+
mode: z.ZodEnum<{
|
|
314
|
+
snapshot: "snapshot";
|
|
315
|
+
delta: "delta";
|
|
316
|
+
}>;
|
|
317
|
+
serverVersion: z.ZodNumber;
|
|
318
|
+
changes: z.ZodArray<z.ZodCustom<SyncMessage<unknown, string | number>, SyncMessage<unknown, string | number>>>;
|
|
319
|
+
chunkIndex: z.ZodOptional<z.ZodNumber>;
|
|
320
|
+
totalChunks: z.ZodOptional<z.ZodNumber>;
|
|
321
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
322
|
+
type: z.ZodLiteral<"reject">;
|
|
323
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
324
|
+
clientId: z.ZodString;
|
|
325
|
+
clientMutationId: z.ZodString;
|
|
326
|
+
reason: z.ZodString;
|
|
327
|
+
correctiveChanges: z.ZodDefault<z.ZodArray<z.ZodCustom<SyncMessage<unknown, string | number>, SyncMessage<unknown, string | number>>>>;
|
|
328
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
329
|
+
type: z.ZodLiteral<"pong">;
|
|
330
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
331
|
+
timestamp: z.ZodNumber;
|
|
332
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
333
|
+
type: z.ZodLiteral<"queryRangeChunk">;
|
|
334
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
335
|
+
requestId: z.ZodString;
|
|
336
|
+
rows: z.ZodArray<z.ZodCustom<unknown, unknown>>;
|
|
337
|
+
totalCount: z.ZodNumber;
|
|
338
|
+
lastCursor: z.ZodNullable<z.ZodUnknown>;
|
|
339
|
+
hasMore: z.ZodBoolean;
|
|
340
|
+
chunkIndex: z.ZodNumber;
|
|
341
|
+
done: z.ZodBoolean;
|
|
342
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
343
|
+
type: z.ZodLiteral<"rangePatch">;
|
|
344
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
345
|
+
change: z.ZodCustom<SyncMessage<unknown, string | number>, SyncMessage<unknown, string | number>>;
|
|
346
|
+
viewTransition: z.ZodOptional<z.ZodEnum<{
|
|
347
|
+
enterView: "enterView";
|
|
348
|
+
exitView: "exitView";
|
|
349
|
+
}>>;
|
|
350
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
351
|
+
type: z.ZodLiteral<"rangeUpToDate">;
|
|
352
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
353
|
+
requestId: z.ZodString;
|
|
354
|
+
totalCount: z.ZodNumber;
|
|
355
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
356
|
+
type: z.ZodLiteral<"rangeDelta">;
|
|
357
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
358
|
+
requestId: z.ZodString;
|
|
359
|
+
totalCount: z.ZodNumber;
|
|
360
|
+
changes: z.ZodArray<z.ZodCustom<SyncMessage<unknown, string | number>, SyncMessage<unknown, string | number>>>;
|
|
361
|
+
lastCursor: z.ZodOptional<z.ZodUnknown>;
|
|
362
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
363
|
+
type: z.ZodLiteral<"rangeReconcileResult">;
|
|
364
|
+
collectionId: z.ZodDefault<z.ZodString>;
|
|
365
|
+
requestId: z.ZodString;
|
|
366
|
+
added: z.ZodArray<z.ZodCustom<SyncMessage<unknown, string | number>, SyncMessage<unknown, string | number>>>;
|
|
367
|
+
updated: z.ZodArray<z.ZodCustom<SyncMessage<unknown, string | number>, SyncMessage<unknown, string | number>>>;
|
|
368
|
+
stale: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
369
|
+
movedHints: z.ZodArray<z.ZodObject<{
|
|
370
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
371
|
+
hint: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
372
|
+
}, z.core.$strip>>;
|
|
373
|
+
totalCount: z.ZodNumber;
|
|
374
|
+
}, z.core.$strip>], "type">;
|
|
375
|
+
declare function toSyncMessage(intent: MutationIntent): SyncMessage;
|
|
376
|
+
declare function createClientMutationId(prefix?: string): string;
|
|
377
|
+
|
|
378
|
+
export { DEFAULT_SYNC_COLLECTION_ID, type IndexRangeCursor, type IndexRangeOffset, type MutationIntent, type PredicateRange, type RangeCondition, type RangeConditionOp, type RangeFingerprint, type SyncBackfillMode, type SyncClientMessage, type SyncClientMessageBody, type SyncRange, type SyncRangeSort, type SyncServerMessage, type SyncServerMessageBody, type SyncSortDirection, clientMessageSchema, createClientMessageSchema, createClientMutationId, createServerMessageSchema, mutationIntentSchema, serverMessageSchema, syncRangeSchema, toSyncMessage, withServerCollectionId };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { DEFAULT_SYNC_COLLECTION_ID, clientMessageSchema, createClientMessageSchema, createClientMutationId, createServerMessageSchema, mutationIntentSchema, serverMessageSchema, syncRangeSchema, toSyncMessage, withServerCollectionId } from './chunk-BJJEAKXL.js';
|
|
2
|
+
import './chunk-HMLY7DHA.js';
|
|
3
|
+
//# sourceMappingURL=sync-protocol.js.map
|
|
4
|
+
//# sourceMappingURL=sync-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"sync-protocol.js"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SyncMessage } from '@firtoz/db-helpers';
|
|
2
|
+
import { SyncServerMessage, SyncClientMessage } from './sync-protocol.js';
|
|
3
|
+
import { PartialSyncRowShape } from './partial-sync-row-key.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
interface SyncServerBridgeStore<TItem> {
|
|
7
|
+
applySyncMessages: (messages: SyncMessage<TItem>[]) => Promise<void>;
|
|
8
|
+
getSnapshotMessages: () => Promise<SyncMessage<TItem>[]>;
|
|
9
|
+
getRow: (key: string | number) => Promise<TItem | undefined>;
|
|
10
|
+
}
|
|
11
|
+
interface SyncServerBridgeOptions<TItem> {
|
|
12
|
+
store: SyncServerBridgeStore<TItem>;
|
|
13
|
+
sendToClient: (clientId: string, message: SyncServerMessage<TItem>) => void;
|
|
14
|
+
broadcastExcept: (excludeClientId: string, message: SyncServerMessage<TItem>) => void | Promise<void>;
|
|
15
|
+
/** Deliver a server message to every connected client (e.g. {@link SyncServerBridge.pushServerChanges}). */
|
|
16
|
+
broadcastAll?: (message: SyncServerMessage<TItem>) => void;
|
|
17
|
+
/** Maximum number of changes per `syncBackfill` frame. Defaults to 500. */
|
|
18
|
+
backfillChunkSize?: number;
|
|
19
|
+
/** Multiplex key for sync messages. Default {@link DEFAULT_SYNC_COLLECTION_ID}. */
|
|
20
|
+
collectionId?: string;
|
|
21
|
+
}
|
|
22
|
+
declare class SyncServerBridge<TItem extends PartialSyncRowShape> {
|
|
23
|
+
#private;
|
|
24
|
+
private readonly options;
|
|
25
|
+
constructor(options: SyncServerBridgeOptions<TItem>);
|
|
26
|
+
get collectionId(): string;
|
|
27
|
+
get serverVersion(): number;
|
|
28
|
+
handleClientMessage(message: SyncClientMessage): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Apply mutations that originated on the server (cron, admin API, etc.) and fan out to all clients.
|
|
31
|
+
*/
|
|
32
|
+
pushServerChanges(changes: SyncMessage<TItem>[]): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { SyncServerBridge, type SyncServerBridgeOptions, type SyncServerBridgeStore };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"sync-server-bridge.js"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import { UtilsRecord, CollectionConfig, NonSingleResult } from '@tanstack/db';
|
|
3
|
+
import { SyncClientBridge } from './sync-client-bridge.js';
|
|
4
|
+
import { PartialSyncRowShape } from './partial-sync-row-key.js';
|
|
5
|
+
import { SyncClientMessage } from './sync-protocol.js';
|
|
6
|
+
import '@firtoz/db-helpers';
|
|
7
|
+
import 'zod';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Sync cursor persistence (see {@link WithSyncOptions}):
|
|
11
|
+
*
|
|
12
|
+
* - **Ephemeral collections** (in-memory only, no durable row storage): omit `syncStateKey`.
|
|
13
|
+
* Each load gets a new `clientId` and `lastAckedServerVersion: 0`, so the server answers with a
|
|
14
|
+
* **full snapshot** backfill — correct because local rows do not survive refresh.
|
|
15
|
+
*
|
|
16
|
+
* - **Durable collections** (IndexedDB, sqlite-wasm, etc.): set `syncStateKey` (and default storage).
|
|
17
|
+
* `persistLastAckedServerVersion` defaults to **true**, so reconnect sends the last acked server
|
|
18
|
+
* version and the server can return **delta** backfill when the changelog allows.
|
|
19
|
+
*
|
|
20
|
+
* - To keep a stable `clientId` in storage but **always** request a full snapshot (rare), set
|
|
21
|
+
* `syncStateKey` and `persistLastAckedServerVersion: false`.
|
|
22
|
+
*/
|
|
23
|
+
/** Row shape required for sync (matches {@link SyncClientBridge}). */
|
|
24
|
+
type SyncableCollectionItem = PartialSyncRowShape;
|
|
25
|
+
/**
|
|
26
|
+
* Key/value persistence for sync metadata (`clientId`, `lastAckedServerVersion`).
|
|
27
|
+
* Same shape as `Storage`; use `localStorage`, `sessionStorage`, a `Map` adapter, etc.
|
|
28
|
+
*/
|
|
29
|
+
type SyncStateStorage = {
|
|
30
|
+
getItem(key: string): string | null;
|
|
31
|
+
setItem(key: string, value: string): void;
|
|
32
|
+
};
|
|
33
|
+
type WithSyncOptions = {
|
|
34
|
+
/**
|
|
35
|
+
* If set, sync metadata (`clientId`, optionally `lastAckedServerVersion`) is read/written via
|
|
36
|
+
* {@link syncStateStorage} or `localStorage`. Omit for ephemeral collections (e.g. memory) so
|
|
37
|
+
* every load handshakes as a fresh client with a full snapshot — see module note above.
|
|
38
|
+
*/
|
|
39
|
+
syncStateKey?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Where to read/write {@link syncStateKey}. Defaults to `globalThis.localStorage` when `syncStateKey` is set and this is omitted.
|
|
42
|
+
* Pass `null` to skip persistence even when `syncStateKey` is set (e.g. tests).
|
|
43
|
+
*/
|
|
44
|
+
syncStateStorage?: SyncStateStorage | null;
|
|
45
|
+
/**
|
|
46
|
+
* Persist and reuse lastAcked server version across page reloads (enables delta backfill on reconnect).
|
|
47
|
+
* Defaults to `true` when {@link syncStateKey} is set and a storage backend is resolved; set `false` to always handshake with `lastAckedServerVersion: 0` (full snapshot). When `false`, existing stored `lastAckedServerVersion` is preserved in storage so it is not wiped on load.
|
|
48
|
+
*/
|
|
49
|
+
persistLastAckedServerVersion?: boolean;
|
|
50
|
+
onRejectedMutation?: (reason: string, mutationId: string) => void;
|
|
51
|
+
/**
|
|
52
|
+
* When `false`, the bridge does not send `syncHello` on connect (use with partial sync + `mutateBatch`).
|
|
53
|
+
* Default `true`.
|
|
54
|
+
*/
|
|
55
|
+
sendSyncHelloOnConnect?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* When `false`, local {@link CollectionConfig.utils.truncate} clears storage only — it does **not**
|
|
58
|
+
* enqueue a `truncate` for the next `mutateBatch`. Partial sync calls truncate on window reset; forwarding
|
|
59
|
+
* it would batch with unrelated user edits and make the server apply `truncate` + `update`, wiping data.
|
|
60
|
+
* Default `true` (full sync). {@link createPartialSyncedCollection} sets this to `false`.
|
|
61
|
+
*/
|
|
62
|
+
forwardTruncateToMutations?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Must match the server's {@link SyncServerBridgeOptions.collectionId} on the same WebSocket.
|
|
65
|
+
*/
|
|
66
|
+
collectionId?: string;
|
|
67
|
+
/**
|
|
68
|
+
* When set to a positive number (milliseconds), local mutation batches are debounced: each
|
|
69
|
+
* burst merges into one `onLocalMutation` call after this many milliseconds of quiet time.
|
|
70
|
+
* `truncate` messages flush any pending batch immediately and are not delayed.
|
|
71
|
+
*/
|
|
72
|
+
localMutationThrottleMs?: number;
|
|
73
|
+
};
|
|
74
|
+
/** Returns `globalThis.localStorage` when it looks usable; otherwise `null`. */
|
|
75
|
+
declare function getBrowserLocalStorageSyncStateStorage(): SyncStateStorage | null;
|
|
76
|
+
/**
|
|
77
|
+
* Infer the collection row type from options passed to {@link withSync} / {@link createSyncedCollection}.
|
|
78
|
+
* Prefer `CollectionConfig`'s first type parameter (the select row). That matches Drizzle SQLite configs
|
|
79
|
+
* where `schema` is an insert schema whose {@link InferSchemaOutput} can differ from the row type.
|
|
80
|
+
*/
|
|
81
|
+
type InferItemFromCollectionOptions<T> = T extends Omit<CollectionConfig<infer TItem, infer _K, infer _S, infer _U>, "utils"> & {
|
|
82
|
+
utils: UtilsRecord;
|
|
83
|
+
} ? TItem : T extends WithSyncableCollectionConfig<infer TItem, infer _K, infer _S, infer _U> ? TItem : T extends CollectionConfig<infer TItem, infer _TKey, infer _TSchema, infer _TUtils> ? TItem : T extends {
|
|
84
|
+
getKey: (item: infer I) => unknown;
|
|
85
|
+
} ? I : never;
|
|
86
|
+
/**
|
|
87
|
+
* Any TanStack {@link CollectionConfig} (from memory / IndexedDB / SQLite helpers, etc.)
|
|
88
|
+
* that is not a single-row collection. Requires `utils` (sync backends always provide it).
|
|
89
|
+
*/
|
|
90
|
+
type WithSyncableCollectionConfig<TItem extends SyncableCollectionItem = SyncableCollectionItem, TKey extends string | number = string | number, TSchema extends StandardSchemaV1 = never, TUtils extends UtilsRecord = UtilsRecord> = Omit<CollectionConfig<TItem, TKey, TSchema, TUtils>, "utils"> & NonSingleResult & {
|
|
91
|
+
utils: TUtils;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Wraps TanStack DB collection options so local mutations are forwarded to {@link SyncClientBridge}.
|
|
95
|
+
* Pair with {@link connectSync} or {@link createSyncedCollection} to attach a WebSocket transport.
|
|
96
|
+
*
|
|
97
|
+
* Row type is inferred from your collection config via {@link InferItemFromCollectionOptions}.
|
|
98
|
+
*/
|
|
99
|
+
/** Widened config union from memory / Drizzle / IndexedDB helpers. */
|
|
100
|
+
type AnyWithSyncableCollectionConfig = WithSyncableCollectionConfig<any, any, any, any>;
|
|
101
|
+
declare function withSync<TConfig extends AnyWithSyncableCollectionConfig>(baseOptions: TConfig, syncOptions?: WithSyncOptions): {
|
|
102
|
+
options: TConfig;
|
|
103
|
+
bridge: SyncClientBridge<InferItemFromCollectionOptions<TConfig>>;
|
|
104
|
+
setTransportSend: (send: (msg: SyncClientMessage) => void) => void;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { type AnyWithSyncableCollectionConfig, type InferItemFromCollectionOptions, type SyncStateStorage, type SyncableCollectionItem, type WithSyncOptions, type WithSyncableCollectionConfig, getBrowserLocalStorageSyncStateStorage, withSync };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { getBrowserLocalStorageSyncStateStorage, withSync } from './chunk-YYGPIHHJ.js';
|
|
2
|
+
import './chunk-QJP4GSJH.js';
|
|
3
|
+
import './chunk-BJJEAKXL.js';
|
|
4
|
+
import './chunk-UJ24XW52.js';
|
|
5
|
+
import './chunk-HMLY7DHA.js';
|
|
6
|
+
//# sourceMappingURL=with-sync.js.map
|
|
7
|
+
//# sourceMappingURL=with-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"with-sync.js"}
|
package/package.json
CHANGED
|
@@ -1,34 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firtoz/collection-sync",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "WebSocket sync protocol and bridges for TanStack DB collections",
|
|
5
|
-
"main": "./
|
|
6
|
-
"module": "./
|
|
7
|
-
"types": "./
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"types": "./
|
|
12
|
-
"import": "./
|
|
13
|
-
"require": "./src/index.ts"
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
14
13
|
},
|
|
15
14
|
"./react": {
|
|
16
|
-
"types": "./
|
|
17
|
-
"import": "./
|
|
18
|
-
|
|
15
|
+
"types": "./dist/react/index.d.ts",
|
|
16
|
+
"import": "./dist/react/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./react/*": {
|
|
19
|
+
"types": "./dist/react/*.d.ts",
|
|
20
|
+
"import": "./dist/react/*.js"
|
|
19
21
|
},
|
|
20
22
|
"./*": {
|
|
21
|
-
"types": "./
|
|
22
|
-
"import": "./
|
|
23
|
-
"require": "./src/*.ts"
|
|
23
|
+
"types": "./dist/*.d.ts",
|
|
24
|
+
"import": "./dist/*.js"
|
|
24
25
|
}
|
|
25
26
|
},
|
|
26
27
|
"files": [
|
|
28
|
+
"dist/**/*.js",
|
|
29
|
+
"dist/**/*.js.map",
|
|
30
|
+
"dist/**/*.d.ts",
|
|
27
31
|
"src/**/*.ts",
|
|
28
32
|
"!src/**/*.test.ts",
|
|
29
33
|
"README.md"
|
|
30
34
|
],
|
|
31
35
|
"scripts": {
|
|
36
|
+
"build": "tsup",
|
|
37
|
+
"prepack": "bun run build",
|
|
32
38
|
"typecheck": "tsgo --noEmit -p ./tsconfig.json",
|
|
33
39
|
"lint": "biome check --write src",
|
|
34
40
|
"lint:ci": "biome ci src",
|
|
@@ -59,19 +65,19 @@
|
|
|
59
65
|
"access": "public"
|
|
60
66
|
},
|
|
61
67
|
"dependencies": {
|
|
62
|
-
"@firtoz/db-helpers": "^2.
|
|
63
|
-
"@firtoz/maybe-error": "^1.
|
|
68
|
+
"@firtoz/db-helpers": "^2.2.0",
|
|
69
|
+
"@firtoz/maybe-error": "^1.6.0",
|
|
64
70
|
"zod": "^4.3.6"
|
|
65
71
|
},
|
|
66
72
|
"peerDependencies": {
|
|
67
|
-
"@firtoz/websocket-do": "^
|
|
73
|
+
"@firtoz/websocket-do": "^13.0.0",
|
|
68
74
|
"@standard-schema/spec": ">=1.1.0",
|
|
69
75
|
"@tanstack/db": ">=0.6.3",
|
|
70
76
|
"@tanstack/react-db": ">=0.1.82",
|
|
71
77
|
"react": ">=19.2.4"
|
|
72
78
|
},
|
|
73
79
|
"devDependencies": {
|
|
74
|
-
"@firtoz/websocket-do": "^
|
|
80
|
+
"@firtoz/websocket-do": "^13.0.0",
|
|
75
81
|
"@standard-schema/spec": "^1.1.0",
|
|
76
82
|
"@tanstack/db": "^0.6.4",
|
|
77
83
|
"@tanstack/react-db": "0.1.82",
|