@lsync/transport 0.0.1
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 +9 -0
- package/dist/index.d.mts +528 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +410 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lsync contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/api.d.ts
|
|
4
|
+
declare const operationTypeSchema: z.ZodEnum<{
|
|
5
|
+
insert: "insert";
|
|
6
|
+
update: "update";
|
|
7
|
+
delete: "delete";
|
|
8
|
+
}>;
|
|
9
|
+
declare const updateSchema: z.ZodObject<{
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
collection: z.ZodString;
|
|
12
|
+
path: z.ZodOptional<z.ZodString>;
|
|
13
|
+
key: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
14
|
+
type: z.ZodEnum<{
|
|
15
|
+
insert: "insert";
|
|
16
|
+
update: "update";
|
|
17
|
+
delete: "delete";
|
|
18
|
+
}>;
|
|
19
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
20
|
+
previousValue: z.ZodOptional<z.ZodUnknown>;
|
|
21
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
22
|
+
createdAt: z.ZodNumber;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
declare const sequencedUpdateSchema: z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
collection: z.ZodString;
|
|
27
|
+
path: z.ZodOptional<z.ZodString>;
|
|
28
|
+
key: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
29
|
+
type: z.ZodEnum<{
|
|
30
|
+
insert: "insert";
|
|
31
|
+
update: "update";
|
|
32
|
+
delete: "delete";
|
|
33
|
+
}>;
|
|
34
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
35
|
+
previousValue: z.ZodOptional<z.ZodUnknown>;
|
|
36
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
37
|
+
createdAt: z.ZodNumber;
|
|
38
|
+
sequence: z.ZodNumber;
|
|
39
|
+
serverCreatedAt: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
declare const batchSchema: z.ZodObject<{
|
|
42
|
+
updates: z.ZodArray<z.ZodObject<{
|
|
43
|
+
id: z.ZodString;
|
|
44
|
+
collection: z.ZodString;
|
|
45
|
+
path: z.ZodOptional<z.ZodString>;
|
|
46
|
+
key: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
47
|
+
type: z.ZodEnum<{
|
|
48
|
+
insert: "insert";
|
|
49
|
+
update: "update";
|
|
50
|
+
delete: "delete";
|
|
51
|
+
}>;
|
|
52
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
53
|
+
previousValue: z.ZodOptional<z.ZodUnknown>;
|
|
54
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
55
|
+
createdAt: z.ZodNumber;
|
|
56
|
+
}, z.core.$strip>>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
declare const readFilterOperatorSchema: z.ZodEnum<{
|
|
59
|
+
eq: "eq";
|
|
60
|
+
ne: "ne";
|
|
61
|
+
gt: "gt";
|
|
62
|
+
gte: "gte";
|
|
63
|
+
lt: "lt";
|
|
64
|
+
lte: "lte";
|
|
65
|
+
in: "in";
|
|
66
|
+
}>;
|
|
67
|
+
declare const readFilterSchema: z.ZodObject<{
|
|
68
|
+
field: z.ZodString;
|
|
69
|
+
op: z.ZodDefault<z.ZodEnum<{
|
|
70
|
+
eq: "eq";
|
|
71
|
+
ne: "ne";
|
|
72
|
+
gt: "gt";
|
|
73
|
+
gte: "gte";
|
|
74
|
+
lt: "lt";
|
|
75
|
+
lte: "lte";
|
|
76
|
+
in: "in";
|
|
77
|
+
}>>;
|
|
78
|
+
value: z.ZodUnknown;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
type ReadPredicate = {
|
|
81
|
+
type: "comparison";
|
|
82
|
+
field: string;
|
|
83
|
+
op: z.infer<typeof readFilterOperatorSchema>;
|
|
84
|
+
value: unknown;
|
|
85
|
+
} | {
|
|
86
|
+
type: "and" | "or";
|
|
87
|
+
predicates: Array<ReadPredicate>;
|
|
88
|
+
};
|
|
89
|
+
declare const readPredicateSchema: z.ZodType<ReadPredicate>;
|
|
90
|
+
declare const readOrderBySchema: z.ZodObject<{
|
|
91
|
+
field: z.ZodString;
|
|
92
|
+
direction: z.ZodDefault<z.ZodEnum<{
|
|
93
|
+
asc: "asc";
|
|
94
|
+
desc: "desc";
|
|
95
|
+
}>>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
declare const readCursorSchema: z.ZodObject<{
|
|
98
|
+
whereCurrent: z.ZodType<ReadPredicate, unknown, z.core.$ZodTypeInternals<ReadPredicate, unknown>>;
|
|
99
|
+
whereFrom: z.ZodType<ReadPredicate, unknown, z.core.$ZodTypeInternals<ReadPredicate, unknown>>;
|
|
100
|
+
lastKey: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
declare const readQuerySchema: z.ZodObject<{
|
|
103
|
+
collection: z.ZodString;
|
|
104
|
+
filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
105
|
+
field: z.ZodString;
|
|
106
|
+
op: z.ZodDefault<z.ZodEnum<{
|
|
107
|
+
eq: "eq";
|
|
108
|
+
ne: "ne";
|
|
109
|
+
gt: "gt";
|
|
110
|
+
gte: "gte";
|
|
111
|
+
lt: "lt";
|
|
112
|
+
lte: "lte";
|
|
113
|
+
in: "in";
|
|
114
|
+
}>>;
|
|
115
|
+
value: z.ZodUnknown;
|
|
116
|
+
}, z.core.$strip>>>;
|
|
117
|
+
predicate: z.ZodOptional<z.ZodType<ReadPredicate, unknown, z.core.$ZodTypeInternals<ReadPredicate, unknown>>>;
|
|
118
|
+
orderBy: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
119
|
+
field: z.ZodString;
|
|
120
|
+
direction: z.ZodDefault<z.ZodEnum<{
|
|
121
|
+
asc: "asc";
|
|
122
|
+
desc: "desc";
|
|
123
|
+
}>>;
|
|
124
|
+
}, z.core.$strip>>>;
|
|
125
|
+
cursor: z.ZodOptional<z.ZodObject<{
|
|
126
|
+
whereCurrent: z.ZodType<ReadPredicate, unknown, z.core.$ZodTypeInternals<ReadPredicate, unknown>>;
|
|
127
|
+
whereFrom: z.ZodType<ReadPredicate, unknown, z.core.$ZodTypeInternals<ReadPredicate, unknown>>;
|
|
128
|
+
lastKey: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
129
|
+
}, z.core.$strip>>;
|
|
130
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
131
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
}, z.core.$strip>;
|
|
133
|
+
declare const readResultSchema: z.ZodObject<{
|
|
134
|
+
rows: z.ZodArray<z.ZodUnknown>;
|
|
135
|
+
}, z.core.$strip>;
|
|
136
|
+
declare const pushResultSchema: z.ZodObject<{
|
|
137
|
+
accepted: z.ZodNumber;
|
|
138
|
+
watermark: z.ZodNumber;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
declare const syncChangesQuerySchema: z.ZodObject<{
|
|
141
|
+
collections: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
142
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
143
|
+
}, z.core.$strip>;
|
|
144
|
+
declare const syncChangesResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
145
|
+
type: z.ZodLiteral<"changes">;
|
|
146
|
+
updates: z.ZodArray<z.ZodObject<{
|
|
147
|
+
id: z.ZodString;
|
|
148
|
+
collection: z.ZodString;
|
|
149
|
+
path: z.ZodOptional<z.ZodString>;
|
|
150
|
+
key: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
151
|
+
type: z.ZodEnum<{
|
|
152
|
+
insert: "insert";
|
|
153
|
+
update: "update";
|
|
154
|
+
delete: "delete";
|
|
155
|
+
}>;
|
|
156
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
157
|
+
previousValue: z.ZodOptional<z.ZodUnknown>;
|
|
158
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
159
|
+
createdAt: z.ZodNumber;
|
|
160
|
+
sequence: z.ZodNumber;
|
|
161
|
+
serverCreatedAt: z.ZodString;
|
|
162
|
+
}, z.core.$strip>>;
|
|
163
|
+
watermark: z.ZodNumber;
|
|
164
|
+
hasMore: z.ZodBoolean;
|
|
165
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
166
|
+
type: z.ZodLiteral<"resyncRequired">;
|
|
167
|
+
collections: z.ZodArray<z.ZodString>;
|
|
168
|
+
watermark: z.ZodNumber;
|
|
169
|
+
}, z.core.$strip>], "type">;
|
|
170
|
+
declare const apiCallSchema: z.ZodObject<{
|
|
171
|
+
path: z.ZodString;
|
|
172
|
+
input: z.ZodOptional<z.ZodUnknown>;
|
|
173
|
+
}, z.core.$strip>;
|
|
174
|
+
declare const collectionSubscriptionSchema: z.ZodObject<{
|
|
175
|
+
collection: z.ZodString;
|
|
176
|
+
}, z.core.$strip>;
|
|
177
|
+
declare const collectionSubscriptionResultSchema: z.ZodObject<{
|
|
178
|
+
collection: z.ZodString;
|
|
179
|
+
subscriptions: z.ZodArray<z.ZodString>;
|
|
180
|
+
}, z.core.$strip>;
|
|
181
|
+
declare const collectionInvalidationSchema: z.ZodObject<{
|
|
182
|
+
collection: z.ZodString;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
declare const broadcastSchema: z.ZodObject<{
|
|
185
|
+
type: z.ZodLiteral<"updates">;
|
|
186
|
+
shardId: z.ZodString;
|
|
187
|
+
updates: z.ZodArray<z.ZodObject<{
|
|
188
|
+
id: z.ZodString;
|
|
189
|
+
collection: z.ZodString;
|
|
190
|
+
path: z.ZodOptional<z.ZodString>;
|
|
191
|
+
key: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
192
|
+
type: z.ZodEnum<{
|
|
193
|
+
insert: "insert";
|
|
194
|
+
update: "update";
|
|
195
|
+
delete: "delete";
|
|
196
|
+
}>;
|
|
197
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
198
|
+
previousValue: z.ZodOptional<z.ZodUnknown>;
|
|
199
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
200
|
+
createdAt: z.ZodNumber;
|
|
201
|
+
sequence: z.ZodNumber;
|
|
202
|
+
serverCreatedAt: z.ZodString;
|
|
203
|
+
}, z.core.$strip>>;
|
|
204
|
+
watermark: z.ZodNumber;
|
|
205
|
+
invalidations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
206
|
+
collection: z.ZodString;
|
|
207
|
+
}, z.core.$strip>>>;
|
|
208
|
+
}, z.core.$strip>;
|
|
209
|
+
declare const webSocketAttachmentSchema: z.ZodObject<{
|
|
210
|
+
clientId: z.ZodString;
|
|
211
|
+
connectedAt: z.ZodNumber;
|
|
212
|
+
auth: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
213
|
+
subscriptions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
214
|
+
}, z.core.$strip>;
|
|
215
|
+
type OperationType = z.infer<typeof operationTypeSchema>;
|
|
216
|
+
type Update = z.infer<typeof updateSchema>;
|
|
217
|
+
type SequencedUpdate = z.infer<typeof sequencedUpdateSchema>;
|
|
218
|
+
type Batch = z.infer<typeof batchSchema>;
|
|
219
|
+
type ReadFilterOperator = z.infer<typeof readFilterOperatorSchema>;
|
|
220
|
+
type ReadFilter = z.output<typeof readFilterSchema>;
|
|
221
|
+
type ReadFilterInput = z.input<typeof readFilterSchema>;
|
|
222
|
+
type ReadCursor = z.output<typeof readCursorSchema>;
|
|
223
|
+
type ReadCursorInput = z.input<typeof readCursorSchema>;
|
|
224
|
+
type ReadOrderBy = z.output<typeof readOrderBySchema>;
|
|
225
|
+
type ReadOrderByInput = z.input<typeof readOrderBySchema>;
|
|
226
|
+
type ApiCall = z.output<typeof apiCallSchema>;
|
|
227
|
+
type ApiCallInput = z.input<typeof apiCallSchema>;
|
|
228
|
+
type CollectionSubscription = z.output<typeof collectionSubscriptionSchema>;
|
|
229
|
+
type CollectionSubscriptionInput = z.input<typeof collectionSubscriptionSchema>;
|
|
230
|
+
type CollectionSubscriptionResult = z.output<typeof collectionSubscriptionResultSchema>;
|
|
231
|
+
type CollectionInvalidation = z.output<typeof collectionInvalidationSchema>;
|
|
232
|
+
interface ApiRoute<TInput = unknown, TOutput = unknown> {
|
|
233
|
+
input: TInput;
|
|
234
|
+
output: TOutput;
|
|
235
|
+
}
|
|
236
|
+
type ApiContract = Record<string, ApiRoute>;
|
|
237
|
+
type ApiPath<TApi extends ApiContract> = Extract<keyof TApi, string>;
|
|
238
|
+
type ApiInput<TApi extends ApiContract, TPath extends ApiPath<TApi>> = TApi[TPath]["input"];
|
|
239
|
+
type ApiOutput<TApi extends ApiContract, TPath extends ApiPath<TApi>> = TApi[TPath]["output"];
|
|
240
|
+
type ApiCallArgs<TApi extends ApiContract, TPath extends ApiPath<TApi>> = undefined extends ApiInput<TApi, TPath> ? [input?: ApiInput<TApi, TPath>] : [input: ApiInput<TApi, TPath>];
|
|
241
|
+
interface ReadQuery {
|
|
242
|
+
collection: string;
|
|
243
|
+
filters?: Array<ReadFilter>;
|
|
244
|
+
predicate?: ReadPredicate;
|
|
245
|
+
orderBy?: Array<ReadOrderBy>;
|
|
246
|
+
cursor?: ReadCursor;
|
|
247
|
+
limit?: number;
|
|
248
|
+
offset?: number;
|
|
249
|
+
}
|
|
250
|
+
interface ReadQueryInput {
|
|
251
|
+
collection: string;
|
|
252
|
+
filters?: Array<ReadFilterInput>;
|
|
253
|
+
predicate?: ReadPredicate;
|
|
254
|
+
orderBy?: Array<ReadOrderByInput>;
|
|
255
|
+
cursor?: ReadCursorInput;
|
|
256
|
+
limit?: number;
|
|
257
|
+
offset?: number;
|
|
258
|
+
}
|
|
259
|
+
type PushResult = z.infer<typeof pushResultSchema>;
|
|
260
|
+
type SyncChangesQuery = z.output<typeof syncChangesQuerySchema>;
|
|
261
|
+
type SyncChangesQueryInput = z.input<typeof syncChangesQuerySchema>;
|
|
262
|
+
type SyncChangesResult = z.infer<typeof syncChangesResultSchema>;
|
|
263
|
+
type Broadcast = z.infer<typeof broadcastSchema>;
|
|
264
|
+
type WebSocketAttachment = z.infer<typeof webSocketAttachmentSchema>;
|
|
265
|
+
interface ReadResult<T = unknown> {
|
|
266
|
+
rows: Array<T>;
|
|
267
|
+
}
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/expression.d.ts
|
|
270
|
+
type ReadExpression = FuncExpression | RefExpression | ValExpression | {
|
|
271
|
+
expression: ReadExpression;
|
|
272
|
+
};
|
|
273
|
+
interface FuncExpression {
|
|
274
|
+
type: "func";
|
|
275
|
+
name: string;
|
|
276
|
+
args: Array<unknown>;
|
|
277
|
+
}
|
|
278
|
+
interface RefExpression {
|
|
279
|
+
type: "ref";
|
|
280
|
+
source?: "row" | "reference";
|
|
281
|
+
name?: string;
|
|
282
|
+
path: Array<string | number>;
|
|
283
|
+
}
|
|
284
|
+
interface ValExpression {
|
|
285
|
+
type: "val";
|
|
286
|
+
value: unknown;
|
|
287
|
+
}
|
|
288
|
+
type ReadExpressionInput = ReadExpression;
|
|
289
|
+
type ReadExpressionField = RefExpression & Record<string, any>;
|
|
290
|
+
type ReadExpressionRow<T extends object = Record<string, unknown>> = { readonly [K in keyof T]: ReadExpressionField };
|
|
291
|
+
declare function readExpressionRow<T extends object = Record<string, unknown>>(): ReadExpressionRow<T>;
|
|
292
|
+
declare function readExpressionReferences<TReferences extends Record<string, object> = Record<string, Record<string, unknown>>>(names: Array<keyof TReferences & string>): { readonly [K in keyof TReferences]: ReadExpressionRow<TReferences[K]> };
|
|
293
|
+
declare function field(path: string | Array<string | number>): RefExpression;
|
|
294
|
+
declare function val(value: unknown): ValExpression;
|
|
295
|
+
declare function eq(left: unknown, right: unknown): FuncExpression;
|
|
296
|
+
declare function ne(left: unknown, right: unknown): FuncExpression;
|
|
297
|
+
declare function gt(left: unknown, right: unknown): FuncExpression;
|
|
298
|
+
declare function gte(left: unknown, right: unknown): FuncExpression;
|
|
299
|
+
declare function lt(left: unknown, right: unknown): FuncExpression;
|
|
300
|
+
declare function lte(left: unknown, right: unknown): FuncExpression;
|
|
301
|
+
declare function inArray(left: unknown, values: unknown): FuncExpression;
|
|
302
|
+
declare function and(...expressions: Array<unknown>): FuncExpression;
|
|
303
|
+
declare function or(...expressions: Array<unknown>): FuncExpression;
|
|
304
|
+
declare function not(expression: unknown): FuncExpression;
|
|
305
|
+
declare function compileReadExpression(expression: unknown): ReadPredicate;
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/predicate-match.d.ts
|
|
308
|
+
declare function matchesReadPredicate(row: unknown, predicate: ReadPredicate | undefined): boolean;
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region src/rpc.d.ts
|
|
311
|
+
declare const rpcIdSchema: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
312
|
+
declare const clientRpcRequestSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
313
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
314
|
+
method: z.ZodLiteral<"mutation">;
|
|
315
|
+
params: z.ZodObject<{
|
|
316
|
+
path: z.ZodLiteral<"push">;
|
|
317
|
+
input: z.ZodObject<{
|
|
318
|
+
json: z.ZodObject<{
|
|
319
|
+
updates: z.ZodArray<z.ZodObject<{
|
|
320
|
+
id: z.ZodString;
|
|
321
|
+
collection: z.ZodString;
|
|
322
|
+
path: z.ZodOptional<z.ZodString>;
|
|
323
|
+
key: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
324
|
+
type: z.ZodEnum<{
|
|
325
|
+
insert: "insert";
|
|
326
|
+
update: "update";
|
|
327
|
+
delete: "delete";
|
|
328
|
+
}>;
|
|
329
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
330
|
+
previousValue: z.ZodOptional<z.ZodUnknown>;
|
|
331
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
332
|
+
createdAt: z.ZodNumber;
|
|
333
|
+
}, z.core.$strip>>;
|
|
334
|
+
}, z.core.$strip>;
|
|
335
|
+
}, z.core.$strip>;
|
|
336
|
+
}, z.core.$strip>;
|
|
337
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
338
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
339
|
+
method: z.ZodLiteral<"query">;
|
|
340
|
+
params: z.ZodObject<{
|
|
341
|
+
path: z.ZodLiteral<"read">;
|
|
342
|
+
input: z.ZodObject<{
|
|
343
|
+
json: z.ZodObject<{
|
|
344
|
+
collection: z.ZodString;
|
|
345
|
+
filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
346
|
+
field: z.ZodString;
|
|
347
|
+
op: z.ZodDefault<z.ZodEnum<{
|
|
348
|
+
eq: "eq";
|
|
349
|
+
ne: "ne";
|
|
350
|
+
gt: "gt";
|
|
351
|
+
gte: "gte";
|
|
352
|
+
lt: "lt";
|
|
353
|
+
lte: "lte";
|
|
354
|
+
in: "in";
|
|
355
|
+
}>>;
|
|
356
|
+
value: z.ZodUnknown;
|
|
357
|
+
}, z.core.$strip>>>;
|
|
358
|
+
predicate: z.ZodOptional<z.ZodType<ReadPredicate, unknown, z.core.$ZodTypeInternals<ReadPredicate, unknown>>>;
|
|
359
|
+
orderBy: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
360
|
+
field: z.ZodString;
|
|
361
|
+
direction: z.ZodDefault<z.ZodEnum<{
|
|
362
|
+
asc: "asc";
|
|
363
|
+
desc: "desc";
|
|
364
|
+
}>>;
|
|
365
|
+
}, z.core.$strip>>>;
|
|
366
|
+
cursor: z.ZodOptional<z.ZodObject<{
|
|
367
|
+
whereCurrent: z.ZodType<ReadPredicate, unknown, z.core.$ZodTypeInternals<ReadPredicate, unknown>>;
|
|
368
|
+
whereFrom: z.ZodType<ReadPredicate, unknown, z.core.$ZodTypeInternals<ReadPredicate, unknown>>;
|
|
369
|
+
lastKey: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
370
|
+
}, z.core.$strip>>;
|
|
371
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
372
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
373
|
+
}, z.core.$strip>;
|
|
374
|
+
}, z.core.$strip>;
|
|
375
|
+
}, z.core.$strip>;
|
|
376
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
377
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
378
|
+
method: z.ZodLiteral<"query">;
|
|
379
|
+
params: z.ZodObject<{
|
|
380
|
+
path: z.ZodLiteral<"changes">;
|
|
381
|
+
input: z.ZodObject<{
|
|
382
|
+
json: z.ZodObject<{
|
|
383
|
+
collections: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
384
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
385
|
+
}, z.core.$strip>;
|
|
386
|
+
}, z.core.$strip>;
|
|
387
|
+
}, z.core.$strip>;
|
|
388
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
389
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
390
|
+
method: z.ZodLiteral<"mutation">;
|
|
391
|
+
params: z.ZodObject<{
|
|
392
|
+
path: z.ZodLiteral<"api">;
|
|
393
|
+
input: z.ZodObject<{
|
|
394
|
+
json: z.ZodObject<{
|
|
395
|
+
path: z.ZodString;
|
|
396
|
+
input: z.ZodOptional<z.ZodUnknown>;
|
|
397
|
+
}, z.core.$strip>;
|
|
398
|
+
}, z.core.$strip>;
|
|
399
|
+
}, z.core.$strip>;
|
|
400
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
401
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
402
|
+
method: z.ZodEnum<{
|
|
403
|
+
subscribe: "subscribe";
|
|
404
|
+
unsubscribe: "unsubscribe";
|
|
405
|
+
}>;
|
|
406
|
+
params: z.ZodObject<{
|
|
407
|
+
input: z.ZodObject<{
|
|
408
|
+
json: z.ZodObject<{
|
|
409
|
+
collection: z.ZodString;
|
|
410
|
+
}, z.core.$strip>;
|
|
411
|
+
}, z.core.$strip>;
|
|
412
|
+
}, z.core.$strip>;
|
|
413
|
+
}, z.core.$strip>]>;
|
|
414
|
+
declare const rpcResultMessageSchema: z.ZodObject<{
|
|
415
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
416
|
+
result: z.ZodObject<{
|
|
417
|
+
type: z.ZodLiteral<"data">;
|
|
418
|
+
data: z.ZodObject<{
|
|
419
|
+
json: z.ZodUnknown;
|
|
420
|
+
}, z.core.$strip>;
|
|
421
|
+
}, z.core.$strip>;
|
|
422
|
+
}, z.core.$strip>;
|
|
423
|
+
declare const rpcErrorMessageSchema: z.ZodObject<{
|
|
424
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
425
|
+
error: z.ZodObject<{
|
|
426
|
+
message: z.ZodString;
|
|
427
|
+
}, z.core.$strip>;
|
|
428
|
+
}, z.core.$strip>;
|
|
429
|
+
declare const subscriptionMessageSchema: z.ZodObject<{
|
|
430
|
+
method: z.ZodLiteral<"subscription">;
|
|
431
|
+
params: z.ZodObject<{
|
|
432
|
+
path: z.ZodLiteral<"updates">;
|
|
433
|
+
input: z.ZodObject<{
|
|
434
|
+
json: z.ZodObject<{
|
|
435
|
+
type: z.ZodLiteral<"updates">;
|
|
436
|
+
shardId: z.ZodString;
|
|
437
|
+
updates: z.ZodArray<z.ZodObject<{
|
|
438
|
+
id: z.ZodString;
|
|
439
|
+
collection: z.ZodString;
|
|
440
|
+
path: z.ZodOptional<z.ZodString>;
|
|
441
|
+
key: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
442
|
+
type: z.ZodEnum<{
|
|
443
|
+
insert: "insert";
|
|
444
|
+
update: "update";
|
|
445
|
+
delete: "delete";
|
|
446
|
+
}>;
|
|
447
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
448
|
+
previousValue: z.ZodOptional<z.ZodUnknown>;
|
|
449
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
450
|
+
createdAt: z.ZodNumber;
|
|
451
|
+
sequence: z.ZodNumber;
|
|
452
|
+
serverCreatedAt: z.ZodString;
|
|
453
|
+
}, z.core.$strip>>;
|
|
454
|
+
watermark: z.ZodNumber;
|
|
455
|
+
invalidations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
456
|
+
collection: z.ZodString;
|
|
457
|
+
}, z.core.$strip>>>;
|
|
458
|
+
}, z.core.$strip>;
|
|
459
|
+
}, z.core.$strip>;
|
|
460
|
+
}, z.core.$strip>;
|
|
461
|
+
}, z.core.$strip>;
|
|
462
|
+
declare const serverMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
463
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
464
|
+
result: z.ZodObject<{
|
|
465
|
+
type: z.ZodLiteral<"data">;
|
|
466
|
+
data: z.ZodObject<{
|
|
467
|
+
json: z.ZodUnknown;
|
|
468
|
+
}, z.core.$strip>;
|
|
469
|
+
}, z.core.$strip>;
|
|
470
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
471
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
472
|
+
error: z.ZodObject<{
|
|
473
|
+
message: z.ZodString;
|
|
474
|
+
}, z.core.$strip>;
|
|
475
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
476
|
+
method: z.ZodLiteral<"subscription">;
|
|
477
|
+
params: z.ZodObject<{
|
|
478
|
+
path: z.ZodLiteral<"updates">;
|
|
479
|
+
input: z.ZodObject<{
|
|
480
|
+
json: z.ZodObject<{
|
|
481
|
+
type: z.ZodLiteral<"updates">;
|
|
482
|
+
shardId: z.ZodString;
|
|
483
|
+
updates: z.ZodArray<z.ZodObject<{
|
|
484
|
+
id: z.ZodString;
|
|
485
|
+
collection: z.ZodString;
|
|
486
|
+
path: z.ZodOptional<z.ZodString>;
|
|
487
|
+
key: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
488
|
+
type: z.ZodEnum<{
|
|
489
|
+
insert: "insert";
|
|
490
|
+
update: "update";
|
|
491
|
+
delete: "delete";
|
|
492
|
+
}>;
|
|
493
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
494
|
+
previousValue: z.ZodOptional<z.ZodUnknown>;
|
|
495
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
496
|
+
createdAt: z.ZodNumber;
|
|
497
|
+
sequence: z.ZodNumber;
|
|
498
|
+
serverCreatedAt: z.ZodString;
|
|
499
|
+
}, z.core.$strip>>;
|
|
500
|
+
watermark: z.ZodNumber;
|
|
501
|
+
invalidations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
502
|
+
collection: z.ZodString;
|
|
503
|
+
}, z.core.$strip>>>;
|
|
504
|
+
}, z.core.$strip>;
|
|
505
|
+
}, z.core.$strip>;
|
|
506
|
+
}, z.core.$strip>;
|
|
507
|
+
}, z.core.$strip>]>;
|
|
508
|
+
type RpcId = string | number | null | undefined;
|
|
509
|
+
type ClientRpcRequest = z.input<typeof clientRpcRequestSchema>;
|
|
510
|
+
type ParsedClientRpcRequest = z.output<typeof clientRpcRequestSchema>;
|
|
511
|
+
type RpcResultMessage = z.output<typeof rpcResultMessageSchema>;
|
|
512
|
+
type RpcErrorMessage = z.output<typeof rpcErrorMessageSchema>;
|
|
513
|
+
type SubscriptionMessage = z.output<typeof subscriptionMessageSchema>;
|
|
514
|
+
type ServerMessage = z.output<typeof serverMessageSchema>;
|
|
515
|
+
type TransportPayload = ArrayBuffer | ArrayBufferView | string;
|
|
516
|
+
interface TransportSocket {
|
|
517
|
+
send(data: ArrayBuffer): void;
|
|
518
|
+
}
|
|
519
|
+
declare function parseClientRpcRequest(data: TransportPayload): ParsedClientRpcRequest;
|
|
520
|
+
declare function parseServerMessage(data: TransportPayload): ServerMessage;
|
|
521
|
+
declare function readRpcId(data: TransportPayload): RpcId;
|
|
522
|
+
declare function encodeClientRpcRequest(message: ClientRpcRequest): ArrayBuffer;
|
|
523
|
+
declare function encodeServerMessage(message: ServerMessage): ArrayBuffer;
|
|
524
|
+
declare function sendClientRpcRequest(socket: TransportSocket, message: ClientRpcRequest): void;
|
|
525
|
+
declare function sendServerMessage(socket: TransportSocket, message: ServerMessage): void;
|
|
526
|
+
//#endregion
|
|
527
|
+
export { type ApiCall, type ApiCallArgs, type ApiCallInput, type ApiContract, type ApiInput, type ApiOutput, type ApiPath, type ApiRoute, type Batch, type Broadcast, type ClientRpcRequest, type CollectionInvalidation, type CollectionSubscription, type CollectionSubscriptionInput, type CollectionSubscriptionResult, type FuncExpression, type OperationType, type ParsedClientRpcRequest, type PushResult, type ReadCursor, type ReadCursorInput, type ReadExpression, type ReadExpressionField, type ReadExpressionInput, type ReadExpressionRow, type ReadFilter, type ReadFilterInput, type ReadFilterOperator, type ReadOrderBy, type ReadOrderByInput, type ReadPredicate, type ReadQuery, type ReadQueryInput, type ReadResult, type RefExpression, type RpcErrorMessage, type RpcId, type RpcResultMessage, type SequencedUpdate, type ServerMessage, type SubscriptionMessage, type SyncChangesQuery, type SyncChangesQueryInput, type SyncChangesResult, type TransportSocket, type Update, type ValExpression, type WebSocketAttachment, and, apiCallSchema, batchSchema, broadcastSchema, clientRpcRequestSchema, collectionInvalidationSchema, collectionSubscriptionResultSchema, collectionSubscriptionSchema, compileReadExpression, encodeClientRpcRequest, encodeServerMessage, eq, field, gt, gte, inArray, lt, lte, matchesReadPredicate, ne, not, operationTypeSchema, or, parseClientRpcRequest, parseServerMessage, pushResultSchema, readCursorSchema, readExpressionReferences, readExpressionRow, readFilterOperatorSchema, readFilterSchema, readOrderBySchema, readPredicateSchema, readQuerySchema, readResultSchema, readRpcId, rpcErrorMessageSchema, rpcIdSchema, rpcResultMessageSchema, sendClientRpcRequest, sendServerMessage, sequencedUpdateSchema, serverMessageSchema, subscriptionMessageSchema, syncChangesQuerySchema, syncChangesResultSchema, updateSchema, val, webSocketAttachmentSchema };
|
|
528
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/api.ts","../src/expression.ts","../src/predicate-match.ts","../src/rpc.ts"],"mappings":";;;cAEa,mBAAA,EAAmB,CAAA,CAAA,OAAA;;;;;cAEnB,YAAA,EAAY,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;cAYZ,qBAAA,EAAqB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;cAKrB,WAAA,EAAW,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;cAIX,wBAAA,EAAwB,CAAA,CAAA,OAAA;;;;;;;;;cAExB,gBAAA,EAAgB,CAAA,CAAA,SAAA;;;;;;;;;;;;;KAMjB,aAAA;EAEN,IAAA;EACA,KAAA;EACA,EAAA,EAAI,CAAA,CAAE,KAAA,QAAa,wBAAA;EACnB,KAAA;AAAA;EAGA,IAAA;EACA,UAAA,EAAY,KAAA,CAAM,aAAA;AAAA;AAAA,cAeX,mBAAA,EAAqB,CAAA,CAAE,OAAO,CAAC,aAAA;AAAA,cAI/B,iBAAA,EAAiB,CAAA,CAAA,SAAA;;;;;;;cAKjB,gBAAA,EAAgB,CAAA,CAAA,SAAA;;;;;cAMhB,eAAA,EAAe,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAUf,gBAAA,EAAgB,CAAA,CAAA,SAAA;;;cAIhB,gBAAA,EAAgB,CAAA,CAAA,SAAA;;;;cAKhB,sBAAA,EAAsB,CAAA,CAAA,SAAA;;;;cAkBtB,uBAAA,EAAuB,CAAA,CAAA,qB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AAAA,KACtC,aAAA,GAAgB,CAAA,CAAE,MAAM,QAAQ,mBAAA;AAAA,KAEhC,gBAAA,GAAmB,WAAA,GAAc,eAAe;AAAA,UAE3C,eAAA;EACf,IAAA,CAAK,IAAA,EAAM,WAAW;AAAA;AAAA,iBAGR,qBAAA,CAAsB,IAAA,EAAM,gBAAA,GAAmB,sBAAsB;AAAA,iBAIrE,kBAAA,CAAmB,IAAA,EAAM,gBAAA,GAAmB,aAAa;AAAA,iBAIzD,SAAA,CAAU,IAAA,EAAM,gBAAA,GAAmB,KAAK;AAAA,iBASxC,sBAAA,CAAuB,OAAA,EAAS,gBAAA,GAAmB,WAAW;AAAA,iBAI9D,mBAAA,CAAoB,OAAA,EAAS,aAAA,GAAgB,WAAW;AAAA,iBAIxD,oBAAA,CAAqB,MAAA,EAAQ,eAAA,EAAiB,OAAA,EAAS,gBAAgB;AAAA,iBAIvE,iBAAA,CAAkB,MAAA,EAAQ,eAAA,EAAiB,OAAA,EAAS,aAAa"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { decode, encode } from "@msgpack/msgpack";
|
|
3
|
+
//#region src/api.ts
|
|
4
|
+
const operationTypeSchema = z.enum([
|
|
5
|
+
"insert",
|
|
6
|
+
"update",
|
|
7
|
+
"delete"
|
|
8
|
+
]);
|
|
9
|
+
const updateSchema = z.object({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
collection: z.string(),
|
|
12
|
+
path: z.string().optional(),
|
|
13
|
+
key: z.union([z.string(), z.number()]),
|
|
14
|
+
type: operationTypeSchema,
|
|
15
|
+
value: z.unknown().optional(),
|
|
16
|
+
previousValue: z.unknown().optional(),
|
|
17
|
+
clientId: z.string().optional(),
|
|
18
|
+
createdAt: z.number()
|
|
19
|
+
});
|
|
20
|
+
const sequencedUpdateSchema = updateSchema.extend({
|
|
21
|
+
sequence: z.number().int().positive(),
|
|
22
|
+
serverCreatedAt: z.string()
|
|
23
|
+
});
|
|
24
|
+
const batchSchema = z.object({ updates: z.array(updateSchema).min(1) });
|
|
25
|
+
const readFilterOperatorSchema = z.enum([
|
|
26
|
+
"eq",
|
|
27
|
+
"ne",
|
|
28
|
+
"gt",
|
|
29
|
+
"gte",
|
|
30
|
+
"lt",
|
|
31
|
+
"lte",
|
|
32
|
+
"in"
|
|
33
|
+
]);
|
|
34
|
+
const readFilterSchema = z.object({
|
|
35
|
+
field: z.string().min(1),
|
|
36
|
+
op: readFilterOperatorSchema.default("eq"),
|
|
37
|
+
value: z.unknown()
|
|
38
|
+
});
|
|
39
|
+
const readComparisonPredicateSchema = z.object({
|
|
40
|
+
type: z.literal("comparison"),
|
|
41
|
+
field: z.string().min(1),
|
|
42
|
+
op: readFilterOperatorSchema,
|
|
43
|
+
value: z.unknown()
|
|
44
|
+
});
|
|
45
|
+
const readCompoundPredicateSchema = z.object({
|
|
46
|
+
type: z.enum(["and", "or"]),
|
|
47
|
+
predicates: z.array(z.lazy(() => readPredicateSchema)).min(1)
|
|
48
|
+
});
|
|
49
|
+
const readPredicateSchema = z.lazy(() => z.discriminatedUnion("type", [readComparisonPredicateSchema, readCompoundPredicateSchema]));
|
|
50
|
+
const readOrderBySchema = z.object({
|
|
51
|
+
field: z.string().min(1),
|
|
52
|
+
direction: z.enum(["asc", "desc"]).default("asc")
|
|
53
|
+
});
|
|
54
|
+
const readCursorSchema = z.object({
|
|
55
|
+
whereCurrent: readPredicateSchema,
|
|
56
|
+
whereFrom: readPredicateSchema,
|
|
57
|
+
lastKey: z.union([z.string(), z.number()]).optional()
|
|
58
|
+
});
|
|
59
|
+
const readQuerySchema = z.object({
|
|
60
|
+
collection: z.string(),
|
|
61
|
+
filters: z.array(readFilterSchema).optional(),
|
|
62
|
+
predicate: readPredicateSchema.optional(),
|
|
63
|
+
orderBy: z.array(readOrderBySchema).optional(),
|
|
64
|
+
cursor: readCursorSchema.optional(),
|
|
65
|
+
limit: z.number().int().positive().max(1e3).optional(),
|
|
66
|
+
offset: z.number().int().nonnegative().optional()
|
|
67
|
+
});
|
|
68
|
+
const readResultSchema = z.object({ rows: z.array(z.unknown()) });
|
|
69
|
+
const pushResultSchema = z.object({
|
|
70
|
+
accepted: z.number().int().nonnegative(),
|
|
71
|
+
watermark: z.number().int().nonnegative()
|
|
72
|
+
});
|
|
73
|
+
const syncChangesQuerySchema = z.object({
|
|
74
|
+
collections: z.record(z.string(), z.number().int().nonnegative()),
|
|
75
|
+
limit: z.number().int().positive().max(1e3).optional()
|
|
76
|
+
});
|
|
77
|
+
const syncChangesPageResultSchema = z.object({
|
|
78
|
+
type: z.literal("changes"),
|
|
79
|
+
updates: z.array(sequencedUpdateSchema),
|
|
80
|
+
watermark: z.number().int().nonnegative(),
|
|
81
|
+
hasMore: z.boolean()
|
|
82
|
+
});
|
|
83
|
+
const syncChangesResyncRequiredResultSchema = z.object({
|
|
84
|
+
type: z.literal("resyncRequired"),
|
|
85
|
+
collections: z.array(z.string()),
|
|
86
|
+
watermark: z.number().int().nonnegative()
|
|
87
|
+
});
|
|
88
|
+
const syncChangesResultSchema = z.discriminatedUnion("type", [syncChangesPageResultSchema, syncChangesResyncRequiredResultSchema]);
|
|
89
|
+
const apiCallSchema = z.object({
|
|
90
|
+
path: z.string().min(1),
|
|
91
|
+
input: z.unknown().optional()
|
|
92
|
+
});
|
|
93
|
+
const collectionSubscriptionSchema = z.object({ collection: z.string().min(1) });
|
|
94
|
+
const collectionSubscriptionResultSchema = z.object({
|
|
95
|
+
collection: z.string(),
|
|
96
|
+
subscriptions: z.array(z.string())
|
|
97
|
+
});
|
|
98
|
+
const collectionInvalidationSchema = z.object({ collection: z.string() });
|
|
99
|
+
const broadcastSchema = z.object({
|
|
100
|
+
type: z.literal("updates"),
|
|
101
|
+
shardId: z.string(),
|
|
102
|
+
updates: z.array(sequencedUpdateSchema),
|
|
103
|
+
watermark: z.number().int().nonnegative(),
|
|
104
|
+
invalidations: z.array(collectionInvalidationSchema).optional()
|
|
105
|
+
});
|
|
106
|
+
const webSocketAttachmentSchema = z.object({
|
|
107
|
+
clientId: z.string(),
|
|
108
|
+
connectedAt: z.number(),
|
|
109
|
+
auth: z.record(z.string(), z.unknown()).optional(),
|
|
110
|
+
subscriptions: z.array(z.string()).default([])
|
|
111
|
+
});
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/expression.ts
|
|
114
|
+
function readExpressionRow() {
|
|
115
|
+
return refProxy([], "row");
|
|
116
|
+
}
|
|
117
|
+
function readExpressionReferences(names) {
|
|
118
|
+
return Object.fromEntries(names.map((name) => [name, refProxy([], "reference", name)]));
|
|
119
|
+
}
|
|
120
|
+
function field(path) {
|
|
121
|
+
return {
|
|
122
|
+
type: "ref",
|
|
123
|
+
source: "row",
|
|
124
|
+
path: Array.isArray(path) ? path : path.split(".")
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function val(value) {
|
|
128
|
+
return {
|
|
129
|
+
type: "val",
|
|
130
|
+
value
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function eq(left, right) {
|
|
134
|
+
return func("eq", left, right);
|
|
135
|
+
}
|
|
136
|
+
function ne(left, right) {
|
|
137
|
+
return func("not_eq", left, right);
|
|
138
|
+
}
|
|
139
|
+
function gt(left, right) {
|
|
140
|
+
return func("gt", left, right);
|
|
141
|
+
}
|
|
142
|
+
function gte(left, right) {
|
|
143
|
+
return func("gte", left, right);
|
|
144
|
+
}
|
|
145
|
+
function lt(left, right) {
|
|
146
|
+
return func("lt", left, right);
|
|
147
|
+
}
|
|
148
|
+
function lte(left, right) {
|
|
149
|
+
return func("lte", left, right);
|
|
150
|
+
}
|
|
151
|
+
function inArray(left, values) {
|
|
152
|
+
return func("in", left, values);
|
|
153
|
+
}
|
|
154
|
+
function and(...expressions) {
|
|
155
|
+
return func("and", ...expressions);
|
|
156
|
+
}
|
|
157
|
+
function or(...expressions) {
|
|
158
|
+
return func("or", ...expressions);
|
|
159
|
+
}
|
|
160
|
+
function not(expression) {
|
|
161
|
+
return func("not", expression);
|
|
162
|
+
}
|
|
163
|
+
function compileReadExpression(expression) {
|
|
164
|
+
const unwrapped = unwrapExpression(expression);
|
|
165
|
+
if (!isFuncExpression(unwrapped)) throw new Error("Read access expressions must be function expressions");
|
|
166
|
+
if (unwrapped.name === "and" || unwrapped.name === "or") return {
|
|
167
|
+
type: unwrapped.name,
|
|
168
|
+
predicates: unwrapped.args.map(compileReadExpression)
|
|
169
|
+
};
|
|
170
|
+
if (unwrapped.name === "not") return negatePredicate(compileReadExpression(unwrapped.args[0]));
|
|
171
|
+
const comparison = comparisonFromExpression(unwrapped);
|
|
172
|
+
if (!comparison) throw new Error(`Unsupported read access operator: ${unwrapped.name}`);
|
|
173
|
+
return {
|
|
174
|
+
type: "comparison",
|
|
175
|
+
...comparison
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function func(name, ...args) {
|
|
179
|
+
return {
|
|
180
|
+
type: "func",
|
|
181
|
+
name,
|
|
182
|
+
args: args.map(toExpressionArg)
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function toExpressionArg(value) {
|
|
186
|
+
return isReadExpressionInput(value) ? value : val(value);
|
|
187
|
+
}
|
|
188
|
+
function comparisonFromExpression(expression) {
|
|
189
|
+
const op = toReadFilterOperator(expression.name);
|
|
190
|
+
const [left, right] = expression.args;
|
|
191
|
+
const leftExpression = unwrapExpression(left);
|
|
192
|
+
const rightExpression = unwrapExpression(right);
|
|
193
|
+
if (!op || !isRefExpression(leftExpression) || !isValExpression(rightExpression)) return;
|
|
194
|
+
return {
|
|
195
|
+
field: rowField(leftExpression),
|
|
196
|
+
op,
|
|
197
|
+
value: rightExpression.value
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function rowField(expression) {
|
|
201
|
+
if (expression.source && expression.source !== "row") throw new Error("Read access expressions must reduce reference refs before compilation");
|
|
202
|
+
return expression.path.join(".");
|
|
203
|
+
}
|
|
204
|
+
function toReadFilterOperator(operator) {
|
|
205
|
+
switch (operator) {
|
|
206
|
+
case "eq":
|
|
207
|
+
case "gt":
|
|
208
|
+
case "gte":
|
|
209
|
+
case "lt":
|
|
210
|
+
case "lte":
|
|
211
|
+
case "in": return operator;
|
|
212
|
+
case "not_eq": return "ne";
|
|
213
|
+
default: return;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function negatePredicate(predicate) {
|
|
217
|
+
if (predicate.type === "and" || predicate.type === "or") return {
|
|
218
|
+
type: predicate.type === "and" ? "or" : "and",
|
|
219
|
+
predicates: predicate.predicates.map(negatePredicate)
|
|
220
|
+
};
|
|
221
|
+
const comparison = predicate;
|
|
222
|
+
return {
|
|
223
|
+
...comparison,
|
|
224
|
+
op: negateOperator(comparison.op)
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function negateOperator(operator) {
|
|
228
|
+
switch (operator) {
|
|
229
|
+
case "eq": return "ne";
|
|
230
|
+
case "ne": return "eq";
|
|
231
|
+
case "gt": return "lte";
|
|
232
|
+
case "gte": return "lt";
|
|
233
|
+
case "lt": return "gte";
|
|
234
|
+
case "lte": return "gt";
|
|
235
|
+
case "in": throw new Error("Unsupported read access operator: not(in)");
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function refProxy(path, source, name) {
|
|
239
|
+
return new Proxy({
|
|
240
|
+
type: "ref",
|
|
241
|
+
source,
|
|
242
|
+
...name ? { name } : {},
|
|
243
|
+
path
|
|
244
|
+
}, { get(target, property) {
|
|
245
|
+
if (property in target) return target[property];
|
|
246
|
+
if (typeof property === "symbol") return;
|
|
247
|
+
return refProxy([...path, property], source, name);
|
|
248
|
+
} });
|
|
249
|
+
}
|
|
250
|
+
function unwrapExpression(value) {
|
|
251
|
+
if (typeof value === "object" && value !== null && "expression" in value && isExpressionLike(value.expression)) return value.expression;
|
|
252
|
+
return value;
|
|
253
|
+
}
|
|
254
|
+
function isReadExpressionInput(value) {
|
|
255
|
+
return isExpressionLike(value) || typeof value === "object" && value !== null && "expression" in value && isReadExpressionInput(value.expression);
|
|
256
|
+
}
|
|
257
|
+
function isExpressionLike(value) {
|
|
258
|
+
return typeof value === "object" && value !== null && "type" in value;
|
|
259
|
+
}
|
|
260
|
+
function isFuncExpression(value) {
|
|
261
|
+
return isExpressionLike(value) && value.type === "func" && typeof value.name === "string" && Array.isArray(value.args);
|
|
262
|
+
}
|
|
263
|
+
function isRefExpression(value) {
|
|
264
|
+
return isExpressionLike(value) && value.type === "ref" && Array.isArray(value.path);
|
|
265
|
+
}
|
|
266
|
+
function isValExpression(value) {
|
|
267
|
+
return isExpressionLike(value) && value.type === "val";
|
|
268
|
+
}
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/predicate-match.ts
|
|
271
|
+
function matchesReadPredicate(row, predicate) {
|
|
272
|
+
if (!predicate) return true;
|
|
273
|
+
if (predicate.type === "comparison") return matchesComparison(row, predicate);
|
|
274
|
+
if (predicate.type === "and") return predicate.predicates.every((child) => matchesReadPredicate(row, child));
|
|
275
|
+
return predicate.predicates.some((child) => matchesReadPredicate(row, child));
|
|
276
|
+
}
|
|
277
|
+
function matchesComparison(row, predicate) {
|
|
278
|
+
const value = valueAtPath(row, predicate.field);
|
|
279
|
+
switch (predicate.op) {
|
|
280
|
+
case "eq": return value === predicate.value;
|
|
281
|
+
case "ne": return value !== predicate.value;
|
|
282
|
+
case "gt": return compareValues(value, predicate.value, (left, right) => left > right);
|
|
283
|
+
case "gte": return compareValues(value, predicate.value, (left, right) => left >= right);
|
|
284
|
+
case "lt": return compareValues(value, predicate.value, (left, right) => left < right);
|
|
285
|
+
case "lte": return compareValues(value, predicate.value, (left, right) => left <= right);
|
|
286
|
+
case "in": return Array.isArray(predicate.value) && predicate.value.includes(value);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function compareValues(left, right, compare) {
|
|
290
|
+
if (typeof left === "number" && typeof right === "number") return compare(left, right);
|
|
291
|
+
if (typeof left === "string" && typeof right === "string") return compare(left, right);
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
function valueAtPath(row, fieldName) {
|
|
295
|
+
return fieldName.split(".").reduce((value, segment) => {
|
|
296
|
+
if (typeof value !== "object" || value === null) return;
|
|
297
|
+
return value[segment];
|
|
298
|
+
}, row);
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/rpc.ts
|
|
302
|
+
const rpcIdSchema = z.union([z.string(), z.number()]).nullable().optional();
|
|
303
|
+
const rpcInputSchema = z.object({ json: z.unknown() });
|
|
304
|
+
const clientRpcMutationRequestSchema = z.object({
|
|
305
|
+
id: rpcIdSchema,
|
|
306
|
+
method: z.literal("mutation"),
|
|
307
|
+
params: z.object({
|
|
308
|
+
path: z.literal("push"),
|
|
309
|
+
input: z.object({ json: batchSchema })
|
|
310
|
+
})
|
|
311
|
+
});
|
|
312
|
+
const clientRpcReadQueryRequestSchema = z.object({
|
|
313
|
+
id: rpcIdSchema,
|
|
314
|
+
method: z.literal("query"),
|
|
315
|
+
params: z.object({
|
|
316
|
+
path: z.literal("read"),
|
|
317
|
+
input: z.object({ json: readQuerySchema })
|
|
318
|
+
})
|
|
319
|
+
});
|
|
320
|
+
const clientRpcChangesQueryRequestSchema = z.object({
|
|
321
|
+
id: rpcIdSchema,
|
|
322
|
+
method: z.literal("query"),
|
|
323
|
+
params: z.object({
|
|
324
|
+
path: z.literal("changes"),
|
|
325
|
+
input: z.object({ json: syncChangesQuerySchema })
|
|
326
|
+
})
|
|
327
|
+
});
|
|
328
|
+
const clientRpcApiCallRequestSchema = z.object({
|
|
329
|
+
id: rpcIdSchema,
|
|
330
|
+
method: z.literal("mutation"),
|
|
331
|
+
params: z.object({
|
|
332
|
+
path: z.literal("api"),
|
|
333
|
+
input: z.object({ json: apiCallSchema })
|
|
334
|
+
})
|
|
335
|
+
});
|
|
336
|
+
const clientRpcSubscriptionRequestSchema = z.object({
|
|
337
|
+
id: rpcIdSchema,
|
|
338
|
+
method: z.enum(["subscribe", "unsubscribe"]),
|
|
339
|
+
params: z.object({ input: z.object({ json: collectionSubscriptionSchema }) })
|
|
340
|
+
});
|
|
341
|
+
const clientRpcRequestSchema = z.union([
|
|
342
|
+
clientRpcMutationRequestSchema,
|
|
343
|
+
clientRpcReadQueryRequestSchema,
|
|
344
|
+
clientRpcChangesQueryRequestSchema,
|
|
345
|
+
clientRpcApiCallRequestSchema,
|
|
346
|
+
clientRpcSubscriptionRequestSchema
|
|
347
|
+
]);
|
|
348
|
+
const rpcResultMessageSchema = z.object({
|
|
349
|
+
id: rpcIdSchema,
|
|
350
|
+
result: z.object({
|
|
351
|
+
type: z.literal("data"),
|
|
352
|
+
data: rpcInputSchema
|
|
353
|
+
})
|
|
354
|
+
});
|
|
355
|
+
const rpcErrorMessageSchema = z.object({
|
|
356
|
+
id: rpcIdSchema,
|
|
357
|
+
error: z.object({ message: z.string() })
|
|
358
|
+
});
|
|
359
|
+
const subscriptionMessageSchema = z.object({
|
|
360
|
+
method: z.literal("subscription"),
|
|
361
|
+
params: z.object({
|
|
362
|
+
path: z.literal("updates"),
|
|
363
|
+
input: z.object({ json: broadcastSchema })
|
|
364
|
+
})
|
|
365
|
+
});
|
|
366
|
+
const serverMessageSchema = z.union([
|
|
367
|
+
rpcResultMessageSchema,
|
|
368
|
+
rpcErrorMessageSchema,
|
|
369
|
+
subscriptionMessageSchema
|
|
370
|
+
]);
|
|
371
|
+
function parseClientRpcRequest(data) {
|
|
372
|
+
return clientRpcRequestSchema.parse(decodeMessage(data));
|
|
373
|
+
}
|
|
374
|
+
function parseServerMessage(data) {
|
|
375
|
+
return serverMessageSchema.parse(decodeMessage(data));
|
|
376
|
+
}
|
|
377
|
+
function readRpcId(data) {
|
|
378
|
+
try {
|
|
379
|
+
const message = z.object({ id: rpcIdSchema }).safeParse(decodeMessage(data));
|
|
380
|
+
return message.success ? message.data.id : null;
|
|
381
|
+
} catch {
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function encodeClientRpcRequest(message) {
|
|
386
|
+
return encodeMessage(message);
|
|
387
|
+
}
|
|
388
|
+
function encodeServerMessage(message) {
|
|
389
|
+
return encodeMessage(message);
|
|
390
|
+
}
|
|
391
|
+
function sendClientRpcRequest(socket, message) {
|
|
392
|
+
socket.send(encodeClientRpcRequest(message));
|
|
393
|
+
}
|
|
394
|
+
function sendServerMessage(socket, message) {
|
|
395
|
+
socket.send(encodeServerMessage(message));
|
|
396
|
+
}
|
|
397
|
+
function decodeMessage(data) {
|
|
398
|
+
if (typeof data === "string") return decode(new TextEncoder().encode(data));
|
|
399
|
+
return decode(data);
|
|
400
|
+
}
|
|
401
|
+
function encodeMessage(message) {
|
|
402
|
+
const bytes = encode(message);
|
|
403
|
+
const buffer = new ArrayBuffer(bytes.byteLength);
|
|
404
|
+
new Uint8Array(buffer).set(bytes);
|
|
405
|
+
return buffer;
|
|
406
|
+
}
|
|
407
|
+
//#endregion
|
|
408
|
+
export { and, apiCallSchema, batchSchema, broadcastSchema, clientRpcRequestSchema, collectionInvalidationSchema, collectionSubscriptionResultSchema, collectionSubscriptionSchema, compileReadExpression, encodeClientRpcRequest, encodeServerMessage, eq, field, gt, gte, inArray, lt, lte, matchesReadPredicate, ne, not, operationTypeSchema, or, parseClientRpcRequest, parseServerMessage, pushResultSchema, readCursorSchema, readExpressionReferences, readExpressionRow, readFilterOperatorSchema, readFilterSchema, readOrderBySchema, readPredicateSchema, readQuerySchema, readResultSchema, readRpcId, rpcErrorMessageSchema, rpcIdSchema, rpcResultMessageSchema, sendClientRpcRequest, sendServerMessage, sequencedUpdateSchema, serverMessageSchema, subscriptionMessageSchema, syncChangesQuerySchema, syncChangesResultSchema, updateSchema, val, webSocketAttachmentSchema };
|
|
409
|
+
|
|
410
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/api.ts","../src/expression.ts","../src/predicate-match.ts","../src/rpc.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const operationTypeSchema = z.enum([\"insert\", \"update\", \"delete\"]);\n\nexport const updateSchema = z.object({\n id: z.string(),\n collection: z.string(),\n path: z.string().optional(),\n key: z.union([z.string(), z.number()]),\n type: operationTypeSchema,\n value: z.unknown().optional(),\n previousValue: z.unknown().optional(),\n clientId: z.string().optional(),\n createdAt: z.number(),\n});\n\nexport const sequencedUpdateSchema = updateSchema.extend({\n sequence: z.number().int().positive(),\n serverCreatedAt: z.string(),\n});\n\nexport const batchSchema = z.object({\n updates: z.array(updateSchema).min(1),\n});\n\nexport const readFilterOperatorSchema = z.enum([\"eq\", \"ne\", \"gt\", \"gte\", \"lt\", \"lte\", \"in\"]);\n\nexport const readFilterSchema = z.object({\n field: z.string().min(1),\n op: readFilterOperatorSchema.default(\"eq\"),\n value: z.unknown(),\n});\n\nexport type ReadPredicate =\n | {\n type: \"comparison\";\n field: string;\n op: z.infer<typeof readFilterOperatorSchema>;\n value: unknown;\n }\n | {\n type: \"and\" | \"or\";\n predicates: Array<ReadPredicate>;\n };\n\nconst readComparisonPredicateSchema = z.object({\n type: z.literal(\"comparison\"),\n field: z.string().min(1),\n op: readFilterOperatorSchema,\n value: z.unknown(),\n});\n\nconst readCompoundPredicateSchema = z.object({\n type: z.enum([\"and\", \"or\"]),\n predicates: z.array(z.lazy(() => readPredicateSchema)).min(1),\n});\n\nexport const readPredicateSchema: z.ZodType<ReadPredicate> = z.lazy(() =>\n z.discriminatedUnion(\"type\", [readComparisonPredicateSchema, readCompoundPredicateSchema]),\n);\n\nexport const readOrderBySchema = z.object({\n field: z.string().min(1),\n direction: z.enum([\"asc\", \"desc\"]).default(\"asc\"),\n});\n\nexport const readCursorSchema = z.object({\n whereCurrent: readPredicateSchema,\n whereFrom: readPredicateSchema,\n lastKey: z.union([z.string(), z.number()]).optional(),\n});\n\nexport const readQuerySchema = z.object({\n collection: z.string(),\n filters: z.array(readFilterSchema).optional(),\n predicate: readPredicateSchema.optional(),\n orderBy: z.array(readOrderBySchema).optional(),\n cursor: readCursorSchema.optional(),\n limit: z.number().int().positive().max(1000).optional(),\n offset: z.number().int().nonnegative().optional(),\n});\n\nexport const readResultSchema = z.object({\n rows: z.array(z.unknown()),\n});\n\nexport const pushResultSchema = z.object({\n accepted: z.number().int().nonnegative(),\n watermark: z.number().int().nonnegative(),\n});\n\nexport const syncChangesQuerySchema = z.object({\n collections: z.record(z.string(), z.number().int().nonnegative()),\n limit: z.number().int().positive().max(1000).optional(),\n});\n\nconst syncChangesPageResultSchema = z.object({\n type: z.literal(\"changes\"),\n updates: z.array(sequencedUpdateSchema),\n watermark: z.number().int().nonnegative(),\n hasMore: z.boolean(),\n});\n\nconst syncChangesResyncRequiredResultSchema = z.object({\n type: z.literal(\"resyncRequired\"),\n collections: z.array(z.string()),\n watermark: z.number().int().nonnegative(),\n});\n\nexport const syncChangesResultSchema = z.discriminatedUnion(\"type\", [\n syncChangesPageResultSchema,\n syncChangesResyncRequiredResultSchema,\n]);\n\nexport const apiCallSchema = z.object({\n path: z.string().min(1),\n input: z.unknown().optional(),\n});\n\nexport const collectionSubscriptionSchema = z.object({\n collection: z.string().min(1),\n});\n\nexport const collectionSubscriptionResultSchema = z.object({\n collection: z.string(),\n subscriptions: z.array(z.string()),\n});\n\nexport const collectionInvalidationSchema = z.object({\n collection: z.string(),\n});\n\nexport const broadcastSchema = z.object({\n type: z.literal(\"updates\"),\n shardId: z.string(),\n updates: z.array(sequencedUpdateSchema),\n watermark: z.number().int().nonnegative(),\n invalidations: z.array(collectionInvalidationSchema).optional(),\n});\n\nexport const webSocketAttachmentSchema = z.object({\n clientId: z.string(),\n connectedAt: z.number(),\n auth: z.record(z.string(), z.unknown()).optional(),\n subscriptions: z.array(z.string()).default([]),\n});\n\nexport type OperationType = z.infer<typeof operationTypeSchema>;\nexport type Update = z.infer<typeof updateSchema>;\nexport type SequencedUpdate = z.infer<typeof sequencedUpdateSchema>;\nexport type Batch = z.infer<typeof batchSchema>;\nexport type ReadFilterOperator = z.infer<typeof readFilterOperatorSchema>;\nexport type ReadFilter = z.output<typeof readFilterSchema>;\nexport type ReadFilterInput = z.input<typeof readFilterSchema>;\nexport type ReadCursor = z.output<typeof readCursorSchema>;\nexport type ReadCursorInput = z.input<typeof readCursorSchema>;\nexport type ReadOrderBy = z.output<typeof readOrderBySchema>;\nexport type ReadOrderByInput = z.input<typeof readOrderBySchema>;\nexport type ApiCall = z.output<typeof apiCallSchema>;\nexport type ApiCallInput = z.input<typeof apiCallSchema>;\nexport type CollectionSubscription = z.output<typeof collectionSubscriptionSchema>;\nexport type CollectionSubscriptionInput = z.input<typeof collectionSubscriptionSchema>;\nexport type CollectionSubscriptionResult = z.output<typeof collectionSubscriptionResultSchema>;\nexport type CollectionInvalidation = z.output<typeof collectionInvalidationSchema>;\n\nexport interface ApiRoute<TInput = unknown, TOutput = unknown> {\n input: TInput;\n output: TOutput;\n}\n\nexport type ApiContract = Record<string, ApiRoute>;\nexport type ApiPath<TApi extends ApiContract> = Extract<keyof TApi, string>;\nexport type ApiInput<TApi extends ApiContract, TPath extends ApiPath<TApi>> = TApi[TPath][\"input\"];\nexport type ApiOutput<\n TApi extends ApiContract,\n TPath extends ApiPath<TApi>,\n> = TApi[TPath][\"output\"];\nexport type ApiCallArgs<TApi extends ApiContract, TPath extends ApiPath<TApi>> =\n undefined extends ApiInput<TApi, TPath>\n ? [input?: ApiInput<TApi, TPath>]\n : [input: ApiInput<TApi, TPath>];\n\nexport interface ReadQuery {\n collection: string;\n filters?: Array<ReadFilter>;\n predicate?: ReadPredicate;\n orderBy?: Array<ReadOrderBy>;\n cursor?: ReadCursor;\n limit?: number;\n offset?: number;\n}\nexport interface ReadQueryInput {\n collection: string;\n filters?: Array<ReadFilterInput>;\n predicate?: ReadPredicate;\n orderBy?: Array<ReadOrderByInput>;\n cursor?: ReadCursorInput;\n limit?: number;\n offset?: number;\n}\nexport type PushResult = z.infer<typeof pushResultSchema>;\nexport type SyncChangesQuery = z.output<typeof syncChangesQuerySchema>;\nexport type SyncChangesQueryInput = z.input<typeof syncChangesQuerySchema>;\nexport type SyncChangesResult = z.infer<typeof syncChangesResultSchema>;\nexport type Broadcast = z.infer<typeof broadcastSchema>;\nexport type WebSocketAttachment = z.infer<typeof webSocketAttachmentSchema>;\n\nexport interface ReadResult<T = unknown> {\n rows: Array<T>;\n}\n","import type { ReadFilterOperator, ReadPredicate } from \"./api\";\n\nexport type ReadExpression =\n | FuncExpression\n | RefExpression\n | ValExpression\n | { expression: ReadExpression };\ntype ReadExpressionNode = FuncExpression | RefExpression | ValExpression;\n\nexport interface FuncExpression {\n type: \"func\";\n name: string;\n args: Array<unknown>;\n}\n\nexport interface RefExpression {\n type: \"ref\";\n source?: \"row\" | \"reference\";\n name?: string;\n path: Array<string | number>;\n}\n\nexport interface ValExpression {\n type: \"val\";\n value: unknown;\n}\n\nexport type ReadExpressionInput = ReadExpression;\nexport type ReadExpressionField = RefExpression & Record<string, any>;\nexport type ReadExpressionRow<T extends object = Record<string, unknown>> = {\n readonly [K in keyof T]: ReadExpressionField;\n};\n\nexport function readExpressionRow<\n T extends object = Record<string, unknown>,\n>(): ReadExpressionRow<T> {\n return refProxy([], \"row\") as ReadExpressionRow<T>;\n}\n\nexport function readExpressionReferences<\n TReferences extends Record<string, object> = Record<string, Record<string, unknown>>,\n>(\n names: Array<keyof TReferences & string>,\n): {\n readonly [K in keyof TReferences]: ReadExpressionRow<TReferences[K]>;\n} {\n return Object.fromEntries(\n names.map((name) => [name, refProxy([], \"reference\", name)]),\n ) as unknown as {\n readonly [K in keyof TReferences]: ReadExpressionRow<TReferences[K]>;\n };\n}\n\nexport function field(path: string | Array<string | number>): RefExpression {\n return {\n type: \"ref\",\n source: \"row\",\n path: Array.isArray(path) ? path : path.split(\".\"),\n };\n}\n\nexport function val(value: unknown): ValExpression {\n return { type: \"val\", value };\n}\n\nexport function eq(left: unknown, right: unknown): FuncExpression {\n return func(\"eq\", left, right);\n}\n\nexport function ne(left: unknown, right: unknown): FuncExpression {\n return func(\"not_eq\", left, right);\n}\n\nexport function gt(left: unknown, right: unknown): FuncExpression {\n return func(\"gt\", left, right);\n}\n\nexport function gte(left: unknown, right: unknown): FuncExpression {\n return func(\"gte\", left, right);\n}\n\nexport function lt(left: unknown, right: unknown): FuncExpression {\n return func(\"lt\", left, right);\n}\n\nexport function lte(left: unknown, right: unknown): FuncExpression {\n return func(\"lte\", left, right);\n}\n\nexport function inArray(left: unknown, values: unknown): FuncExpression {\n return func(\"in\", left, values);\n}\n\nexport function and(...expressions: Array<unknown>): FuncExpression {\n return func(\"and\", ...expressions);\n}\n\nexport function or(...expressions: Array<unknown>): FuncExpression {\n return func(\"or\", ...expressions);\n}\n\nexport function not(expression: unknown): FuncExpression {\n return func(\"not\", expression);\n}\n\nexport function compileReadExpression(expression: unknown): ReadPredicate {\n const unwrapped = unwrapExpression(expression);\n\n if (!isFuncExpression(unwrapped)) {\n throw new Error(\"Read access expressions must be function expressions\");\n }\n\n if (unwrapped.name === \"and\" || unwrapped.name === \"or\") {\n return {\n type: unwrapped.name,\n predicates: unwrapped.args.map(compileReadExpression),\n };\n }\n\n if (unwrapped.name === \"not\") {\n return negatePredicate(compileReadExpression(unwrapped.args[0]));\n }\n\n const comparison = comparisonFromExpression(unwrapped);\n if (!comparison) {\n throw new Error(`Unsupported read access operator: ${unwrapped.name}`);\n }\n\n return {\n type: \"comparison\",\n ...comparison,\n };\n}\n\nfunction func(name: string, ...args: Array<unknown>): FuncExpression {\n return {\n type: \"func\",\n name,\n args: args.map(toExpressionArg),\n };\n}\n\nfunction toExpressionArg(value: unknown): unknown {\n return isReadExpressionInput(value) ? value : val(value);\n}\n\nfunction comparisonFromExpression(\n expression: FuncExpression,\n): Omit<Extract<ReadPredicate, { type: \"comparison\" }>, \"type\"> | undefined {\n const op = toReadFilterOperator(expression.name);\n const [left, right] = expression.args;\n const leftExpression = unwrapExpression(left);\n const rightExpression = unwrapExpression(right);\n if (!op || !isRefExpression(leftExpression) || !isValExpression(rightExpression)) {\n return undefined;\n }\n\n return {\n field: rowField(leftExpression),\n op,\n value: rightExpression.value,\n };\n}\n\nfunction rowField(expression: RefExpression): string {\n if (expression.source && expression.source !== \"row\") {\n throw new Error(\"Read access expressions must reduce reference refs before compilation\");\n }\n\n return expression.path.join(\".\");\n}\n\nfunction toReadFilterOperator(operator: string): ReadFilterOperator | undefined {\n switch (operator) {\n case \"eq\":\n case \"gt\":\n case \"gte\":\n case \"lt\":\n case \"lte\":\n case \"in\":\n return operator;\n case \"not_eq\":\n return \"ne\";\n default:\n return undefined;\n }\n}\n\nfunction negatePredicate(predicate: ReadPredicate): ReadPredicate {\n if (predicate.type === \"and\" || predicate.type === \"or\") {\n return {\n type: predicate.type === \"and\" ? \"or\" : \"and\",\n predicates: predicate.predicates.map(negatePredicate),\n };\n }\n\n const comparison = predicate as Extract<ReadPredicate, { type: \"comparison\" }>;\n return {\n ...comparison,\n op: negateOperator(comparison.op),\n };\n}\n\nfunction negateOperator(operator: ReadFilterOperator): ReadFilterOperator {\n switch (operator) {\n case \"eq\":\n return \"ne\";\n case \"ne\":\n return \"eq\";\n case \"gt\":\n return \"lte\";\n case \"gte\":\n return \"lt\";\n case \"lt\":\n return \"gte\";\n case \"lte\":\n return \"gt\";\n case \"in\":\n throw new Error(\"Unsupported read access operator: not(in)\");\n }\n}\n\nfunction refProxy(\n path: Array<string | number>,\n source: RefExpression[\"source\"],\n name?: string,\n): ReadExpressionField {\n return new Proxy({ type: \"ref\", source, ...(name ? { name } : {}), path } as RefExpression, {\n get(target, property) {\n if (property in target) {\n return target[property as keyof RefExpression];\n }\n\n if (typeof property === \"symbol\") {\n return undefined;\n }\n\n return refProxy([...path, property], source, name);\n },\n }) as ReadExpressionField;\n}\n\nfunction unwrapExpression(value: unknown): unknown {\n if (\n typeof value === \"object\" &&\n value !== null &&\n \"expression\" in value &&\n isExpressionLike((value as { expression: unknown }).expression)\n ) {\n return (value as { expression: unknown }).expression;\n }\n\n return value;\n}\n\nfunction isReadExpressionInput(value: unknown): value is ReadExpression {\n return (\n isExpressionLike(value) ||\n (typeof value === \"object\" &&\n value !== null &&\n \"expression\" in value &&\n isReadExpressionInput((value as { expression: unknown }).expression))\n );\n}\n\nfunction isExpressionLike(value: unknown): value is ReadExpressionNode {\n return typeof value === \"object\" && value !== null && \"type\" in value;\n}\n\nfunction isFuncExpression(value: unknown): value is FuncExpression {\n return (\n isExpressionLike(value) &&\n value.type === \"func\" &&\n typeof value.name === \"string\" &&\n Array.isArray(value.args)\n );\n}\n\nfunction isRefExpression(value: unknown): value is RefExpression {\n return isExpressionLike(value) && value.type === \"ref\" && Array.isArray(value.path);\n}\n\nfunction isValExpression(value: unknown): value is ValExpression {\n return isExpressionLike(value) && value.type === \"val\";\n}\n","import type { ReadPredicate } from \"./api\";\n\nexport function matchesReadPredicate(row: unknown, predicate: ReadPredicate | undefined): boolean {\n if (!predicate) {\n return true;\n }\n\n if (predicate.type === \"comparison\") {\n return matchesComparison(row, predicate);\n }\n\n if (predicate.type === \"and\") {\n return predicate.predicates.every((child) => matchesReadPredicate(row, child));\n }\n\n return predicate.predicates.some((child) => matchesReadPredicate(row, child));\n}\n\nfunction matchesComparison(\n row: unknown,\n predicate: Extract<ReadPredicate, { type: \"comparison\" }>,\n): boolean {\n const value = valueAtPath(row, predicate.field);\n\n switch (predicate.op) {\n case \"eq\":\n return value === predicate.value;\n case \"ne\":\n return value !== predicate.value;\n case \"gt\":\n return compareValues(value, predicate.value, (left, right) => left > right);\n case \"gte\":\n return compareValues(value, predicate.value, (left, right) => left >= right);\n case \"lt\":\n return compareValues(value, predicate.value, (left, right) => left < right);\n case \"lte\":\n return compareValues(value, predicate.value, (left, right) => left <= right);\n case \"in\":\n return Array.isArray(predicate.value) && predicate.value.includes(value);\n }\n}\n\nfunction compareValues(\n left: unknown,\n right: unknown,\n compare: (left: number | string, right: number | string) => boolean,\n): boolean {\n if (typeof left === \"number\" && typeof right === \"number\") {\n return compare(left, right);\n }\n\n if (typeof left === \"string\" && typeof right === \"string\") {\n return compare(left, right);\n }\n\n return false;\n}\n\nfunction valueAtPath(row: unknown, fieldName: string): unknown {\n return fieldName.split(\".\").reduce<unknown>((value, segment) => {\n if (typeof value !== \"object\" || value === null) {\n return undefined;\n }\n\n return (value as Record<string, unknown>)[segment];\n }, row);\n}\n","import { decode, encode } from \"@msgpack/msgpack\";\nimport { z } from \"zod\";\nimport {\n apiCallSchema,\n batchSchema,\n broadcastSchema,\n collectionSubscriptionSchema,\n readQuerySchema,\n syncChangesQuerySchema,\n} from \"./api\";\n\nexport const rpcIdSchema = z.union([z.string(), z.number()]).nullable().optional();\n\nconst rpcInputSchema = z.object({\n json: z.unknown(),\n});\n\nconst clientRpcMutationRequestSchema = z.object({\n id: rpcIdSchema,\n method: z.literal(\"mutation\"),\n params: z.object({\n path: z.literal(\"push\"),\n input: z.object({\n json: batchSchema,\n }),\n }),\n});\n\nconst clientRpcReadQueryRequestSchema = z.object({\n id: rpcIdSchema,\n method: z.literal(\"query\"),\n params: z.object({\n path: z.literal(\"read\"),\n input: z.object({\n json: readQuerySchema,\n }),\n }),\n});\n\nconst clientRpcChangesQueryRequestSchema = z.object({\n id: rpcIdSchema,\n method: z.literal(\"query\"),\n params: z.object({\n path: z.literal(\"changes\"),\n input: z.object({\n json: syncChangesQuerySchema,\n }),\n }),\n});\n\nconst clientRpcApiCallRequestSchema = z.object({\n id: rpcIdSchema,\n method: z.literal(\"mutation\"),\n params: z.object({\n path: z.literal(\"api\"),\n input: z.object({\n json: apiCallSchema,\n }),\n }),\n});\n\nconst clientRpcSubscriptionRequestSchema = z.object({\n id: rpcIdSchema,\n method: z.enum([\"subscribe\", \"unsubscribe\"]),\n params: z.object({\n input: z.object({\n json: collectionSubscriptionSchema,\n }),\n }),\n});\n\nexport const clientRpcRequestSchema = z.union([\n clientRpcMutationRequestSchema,\n clientRpcReadQueryRequestSchema,\n clientRpcChangesQueryRequestSchema,\n clientRpcApiCallRequestSchema,\n clientRpcSubscriptionRequestSchema,\n]);\n\nexport const rpcResultMessageSchema = z.object({\n id: rpcIdSchema,\n result: z.object({\n type: z.literal(\"data\"),\n data: rpcInputSchema,\n }),\n});\n\nexport const rpcErrorMessageSchema = z.object({\n id: rpcIdSchema,\n error: z.object({\n message: z.string(),\n }),\n});\n\nexport const subscriptionMessageSchema = z.object({\n method: z.literal(\"subscription\"),\n params: z.object({\n path: z.literal(\"updates\"),\n input: z.object({\n json: broadcastSchema,\n }),\n }),\n});\n\nexport const serverMessageSchema = z.union([\n rpcResultMessageSchema,\n rpcErrorMessageSchema,\n subscriptionMessageSchema,\n]);\n\nexport type RpcId = string | number | null | undefined;\nexport type ClientRpcRequest = z.input<typeof clientRpcRequestSchema>;\nexport type ParsedClientRpcRequest = z.output<typeof clientRpcRequestSchema>;\nexport type RpcResultMessage = z.output<typeof rpcResultMessageSchema>;\nexport type RpcErrorMessage = z.output<typeof rpcErrorMessageSchema>;\nexport type SubscriptionMessage = z.output<typeof subscriptionMessageSchema>;\nexport type ServerMessage = z.output<typeof serverMessageSchema>;\n\nexport type TransportPayload = ArrayBuffer | ArrayBufferView | string;\n\nexport interface TransportSocket {\n send(data: ArrayBuffer): void;\n}\n\nexport function parseClientRpcRequest(data: TransportPayload): ParsedClientRpcRequest {\n return clientRpcRequestSchema.parse(decodeMessage(data));\n}\n\nexport function parseServerMessage(data: TransportPayload): ServerMessage {\n return serverMessageSchema.parse(decodeMessage(data));\n}\n\nexport function readRpcId(data: TransportPayload): RpcId {\n try {\n const message = z.object({ id: rpcIdSchema }).safeParse(decodeMessage(data));\n return message.success ? message.data.id : null;\n } catch {\n return null;\n }\n}\n\nexport function encodeClientRpcRequest(message: ClientRpcRequest): ArrayBuffer {\n return encodeMessage(message);\n}\n\nexport function encodeServerMessage(message: ServerMessage): ArrayBuffer {\n return encodeMessage(message);\n}\n\nexport function sendClientRpcRequest(socket: TransportSocket, message: ClientRpcRequest): void {\n socket.send(encodeClientRpcRequest(message));\n}\n\nexport function sendServerMessage(socket: TransportSocket, message: ServerMessage): void {\n socket.send(encodeServerMessage(message));\n}\n\nfunction decodeMessage(data: TransportPayload): unknown {\n if (typeof data === \"string\") {\n return decode(new TextEncoder().encode(data));\n }\n\n return decode(data);\n}\n\nfunction encodeMessage(message: unknown): ArrayBuffer {\n const bytes = encode(message);\n const buffer = new ArrayBuffer(bytes.byteLength);\n new Uint8Array(buffer).set(bytes);\n return buffer;\n}\n"],"mappings":";;;AAEA,MAAa,sBAAsB,EAAE,KAAK;CAAC;CAAU;CAAU;AAAQ,CAAC;AAExE,MAAa,eAAe,EAAE,OAAO;CACnC,IAAI,EAAE,OAAO;CACb,YAAY,EAAE,OAAO;CACrB,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,KAAK,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;CACrC,MAAM;CACN,OAAO,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC5B,eAAe,EAAE,QAAQ,CAAC,CAAC,SAAS;CACpC,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS;CAC9B,WAAW,EAAE,OAAO;AACtB,CAAC;AAED,MAAa,wBAAwB,aAAa,OAAO;CACvD,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;CACpC,iBAAiB,EAAE,OAAO;AAC5B,CAAC;AAED,MAAa,cAAc,EAAE,OAAO,EAClC,SAAS,EAAE,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,EACtC,CAAC;AAED,MAAa,2BAA2B,EAAE,KAAK;CAAC;CAAM;CAAM;CAAM;CAAO;CAAM;CAAO;AAAI,CAAC;AAE3F,MAAa,mBAAmB,EAAE,OAAO;CACvC,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACvB,IAAI,yBAAyB,QAAQ,IAAI;CACzC,OAAO,EAAE,QAAQ;AACnB,CAAC;AAcD,MAAM,gCAAgC,EAAE,OAAO;CAC7C,MAAM,EAAE,QAAQ,YAAY;CAC5B,OAAO,EAAE,OAAO,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O,oBAAoB,MAAM,cAAc,IAAI,CAAC;AACtD;AAEA,SAAgB,UAAU,MAA+B;CACvD,IAAI;EACF,MAAM,UAAU,EAAE,OAAO,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,UAAU,cAAc,IAAI,CAAC;EAC3E,OAAO,QAAQ,UAAU,QAAQ,KAAK,KAAK;CAC7C,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAgB,uBAAuB,SAAwC;CAC7E,OAAO,cAAc,OAAO;AAC9B;AAEA,SAAgB,oBAAoB,SAAqC;CACvE,OAAO,cAAc,OAAO;AAC9B;AAEA,SAAgB,qBAAqB,QAAyB,SAAiC;CAC7F,OAAO,KAAK,uBAAuB,OAAO,CAAC;AAC7C;AAEA,SAAgB,kBAAkB,QAAyB,SAA8B;CACvF,OAAO,KAAK,oBAAoB,OAAO,CAAC;AAC1C;AAEA,SAAS,cAAc,MAAiC;CACtD,IAAI,OAAO,SAAS,UAClB,OAAO,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,IAAI,CAAC;CAG9C,OAAO,OAAO,IAAI;AACpB;AAEA,SAAS,cAAc,SAA+B;CACpD,MAAM,QAAQ,OAAO,OAAO;CAC5B,MAAM,SAAS,IAAI,YAAY,MAAM,UAAU;CAC/C,IAAI,WAAW,MAAM,CAAC,CAAC,IAAI,KAAK;CAChC,OAAO;AACT"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lsync/transport",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"homepage": "https://github.com/Myrannas/lsync#readme",
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "https://github.com/Myrannas/lsync/issues"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Myrannas/lsync.git",
|
|
12
|
+
"directory": "packages/transport"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.mts",
|
|
22
|
+
"import": "./dist/index.mjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public",
|
|
27
|
+
"registry": "https://registry.npmjs.org/"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@msgpack/msgpack": "^3.1.3",
|
|
31
|
+
"zod": "^4.4.3"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"typescript": "^6.0.3",
|
|
35
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.2.2",
|
|
36
|
+
"vite-plus": "0.2.2"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "vp pack"
|
|
40
|
+
}
|
|
41
|
+
}
|