@syncular/server 0.59.0 → 0.60.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 +20 -16
- package/dist/admin.d.ts +32 -20
- package/dist/admin.js +42 -40
- package/dist/context.d.ts +6 -8
- package/dist/context.js +1 -3
- package/dist/d1-storage.js +42 -24
- package/dist/errors.js +8 -0
- package/dist/events.d.ts +35 -17
- package/dist/frame-bytes.js +24 -6
- package/dist/handler.js +486 -223
- package/dist/local-authority.js +7 -9
- package/dist/operations.d.ts +5 -2
- package/dist/operations.js +20 -29
- package/dist/postgres-storage.d.ts +24 -19
- package/dist/postgres-storage.js +249 -168
- package/dist/pull.d.ts +68 -53
- package/dist/pull.js +258 -287
- package/dist/push.d.ts +12 -3
- package/dist/push.js +95 -32
- package/dist/realtime.d.ts +17 -11
- package/dist/realtime.js +65 -90
- package/dist/relational-rows.d.ts +0 -57
- package/dist/relational-rows.js +0 -97
- package/dist/seed.js +10 -15
- package/dist/segment-download.d.ts +4 -1
- package/dist/segment-download.js +4 -2
- package/dist/sqlite-dialect.d.ts +36 -59
- package/dist/sqlite-dialect.js +255 -159
- package/dist/sqlite-storage.js +24 -20
- package/dist/storage-query.d.ts +30 -1
- package/dist/storage-query.js +68 -0
- package/dist/storage.d.ts +156 -54
- package/dist/storage.js +15 -0
- package/package.json +2 -2
- package/src/admin.ts +87 -59
- package/src/context.ts +7 -11
- package/src/d1-storage.ts +49 -33
- package/src/errors.ts +8 -0
- package/src/events.ts +36 -17
- package/src/frame-bytes.ts +26 -6
- package/src/handler.ts +628 -286
- package/src/local-authority.ts +10 -11
- package/src/operations.ts +44 -42
- package/src/postgres-storage.ts +336 -226
- package/src/pull.ts +394 -414
- package/src/push.ts +116 -21
- package/src/realtime.ts +85 -129
- package/src/relational-rows.ts +0 -105
- package/src/seed.ts +13 -19
- package/src/segment-download.ts +8 -3
- package/src/sqlite-dialect.ts +363 -204
- package/src/sqlite-storage.ts +45 -25
- package/src/storage-query.ts +102 -0
- package/src/storage.ts +185 -58
package/src/frame-bytes.ts
CHANGED
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
* bytes; the reference codec remains the single source of wire bytes.
|
|
10
10
|
*/
|
|
11
11
|
import {
|
|
12
|
-
|
|
12
|
+
encodeResponse,
|
|
13
13
|
PROTOCOL_WIRE_VERSION,
|
|
14
14
|
type PushResultFrame,
|
|
15
15
|
type RespHeaderFrame,
|
|
16
|
+
type LiveEndFrame,
|
|
17
|
+
type LiveStartFrame,
|
|
16
18
|
type ResponseFrame,
|
|
17
19
|
type SubEndFrame,
|
|
18
20
|
type SubStartFrame,
|
|
@@ -25,15 +27,25 @@ const stubHeader = (): RespHeaderFrame => ({
|
|
|
25
27
|
});
|
|
26
28
|
const STUB_SUB_START: SubStartFrame = {
|
|
27
29
|
type: 'SUB_START',
|
|
28
|
-
id: '',
|
|
30
|
+
id: '0'.repeat(32),
|
|
29
31
|
status: 'active',
|
|
30
32
|
reasonCode: '',
|
|
31
|
-
effectiveScopes: {},
|
|
32
33
|
bootstrap: false,
|
|
34
|
+
fenced: [],
|
|
33
35
|
};
|
|
34
36
|
const STUB_SUB_END: SubEndFrame = { type: 'SUB_END', nextCursor: 0 };
|
|
37
|
+
const STUB_LIVE_START: LiveStartFrame = {
|
|
38
|
+
type: 'LIVE_START',
|
|
39
|
+
status: 'active',
|
|
40
|
+
reasonCode: '',
|
|
41
|
+
};
|
|
42
|
+
const STUB_LIVE_END: LiveEndFrame = {
|
|
43
|
+
type: 'LIVE_END',
|
|
44
|
+
throughSeq: 0,
|
|
45
|
+
echoDigest: new Uint8Array(),
|
|
46
|
+
};
|
|
35
47
|
|
|
36
|
-
const probe =
|
|
48
|
+
const probe = encodeResponse({
|
|
37
49
|
wireVersion: PROTOCOL_WIRE_VERSION,
|
|
38
50
|
msgKind: 'response',
|
|
39
51
|
frames: [stubHeader()],
|
|
@@ -41,7 +53,7 @@ const probe = encodeMessage({
|
|
|
41
53
|
|
|
42
54
|
/** The 8-byte SSP2 response envelope header (§1.2). */
|
|
43
55
|
export function responseEnvelopeHeader(wireVersion: number): Uint8Array {
|
|
44
|
-
const encoded =
|
|
56
|
+
const encoded = encodeResponse({
|
|
45
57
|
wireVersion,
|
|
46
58
|
msgKind: 'response',
|
|
47
59
|
frames: [stubHeader()],
|
|
@@ -91,7 +103,15 @@ function wrapperFor(frame: ResponseFrame): {
|
|
|
91
103
|
frames: [stubHeader(), STUB_SUB_START, frame],
|
|
92
104
|
index: 2,
|
|
93
105
|
};
|
|
106
|
+
case 'LIVE_START':
|
|
107
|
+
return { frames: [stubHeader(), frame, STUB_LIVE_END], index: 1 };
|
|
108
|
+
case 'LIVE_END':
|
|
109
|
+
return { frames: [stubHeader(), STUB_LIVE_START, frame], index: 2 };
|
|
94
110
|
case 'COMMIT':
|
|
111
|
+
return {
|
|
112
|
+
frames: [stubHeader(), STUB_LIVE_START, frame, STUB_LIVE_END],
|
|
113
|
+
index: 2,
|
|
114
|
+
};
|
|
95
115
|
case 'SEGMENT_REF':
|
|
96
116
|
case 'SEGMENT_INLINE':
|
|
97
117
|
return {
|
|
@@ -110,7 +130,7 @@ export function encodeResponseFrame(
|
|
|
110
130
|
wireVersion = PROTOCOL_WIRE_VERSION,
|
|
111
131
|
): Uint8Array {
|
|
112
132
|
const { frames, index } = wrapperFor(frame);
|
|
113
|
-
const encoded =
|
|
133
|
+
const encoded = encodeResponse({
|
|
114
134
|
wireVersion,
|
|
115
135
|
msgKind: 'response',
|
|
116
136
|
frames,
|