@syncular/server 0.59.0 → 0.60.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.
Files changed (54) hide show
  1. package/README.md +20 -16
  2. package/dist/admin.d.ts +32 -20
  3. package/dist/admin.js +42 -40
  4. package/dist/context.d.ts +6 -8
  5. package/dist/context.js +1 -3
  6. package/dist/d1-storage.js +42 -24
  7. package/dist/errors.js +8 -0
  8. package/dist/events.d.ts +35 -17
  9. package/dist/frame-bytes.js +24 -6
  10. package/dist/handler.js +486 -223
  11. package/dist/local-authority.js +7 -9
  12. package/dist/operations.d.ts +5 -2
  13. package/dist/operations.js +20 -29
  14. package/dist/postgres-storage.d.ts +24 -19
  15. package/dist/postgres-storage.js +249 -168
  16. package/dist/pull.d.ts +68 -53
  17. package/dist/pull.js +258 -287
  18. package/dist/push.d.ts +12 -3
  19. package/dist/push.js +95 -32
  20. package/dist/realtime.d.ts +17 -11
  21. package/dist/realtime.js +65 -90
  22. package/dist/relational-rows.d.ts +0 -57
  23. package/dist/relational-rows.js +4 -100
  24. package/dist/seed.js +10 -15
  25. package/dist/segment-download.d.ts +4 -1
  26. package/dist/segment-download.js +4 -2
  27. package/dist/sqlite-dialect.d.ts +36 -59
  28. package/dist/sqlite-dialect.js +255 -159
  29. package/dist/sqlite-storage.js +24 -20
  30. package/dist/storage-query.d.ts +30 -1
  31. package/dist/storage-query.js +68 -0
  32. package/dist/storage.d.ts +156 -54
  33. package/dist/storage.js +15 -0
  34. package/package.json +2 -2
  35. package/src/admin.ts +87 -59
  36. package/src/context.ts +7 -11
  37. package/src/d1-storage.ts +49 -33
  38. package/src/errors.ts +8 -0
  39. package/src/events.ts +36 -17
  40. package/src/frame-bytes.ts +26 -6
  41. package/src/handler.ts +628 -286
  42. package/src/local-authority.ts +10 -11
  43. package/src/operations.ts +44 -42
  44. package/src/postgres-storage.ts +336 -226
  45. package/src/pull.ts +394 -414
  46. package/src/push.ts +116 -21
  47. package/src/realtime.ts +85 -129
  48. package/src/relational-rows.ts +4 -107
  49. package/src/seed.ts +13 -19
  50. package/src/segment-download.ts +8 -3
  51. package/src/sqlite-dialect.ts +363 -204
  52. package/src/sqlite-storage.ts +45 -25
  53. package/src/storage-query.ts +102 -0
  54. package/src/storage.ts +185 -58
@@ -9,10 +9,12 @@
9
9
  * bytes; the reference codec remains the single source of wire bytes.
10
10
  */
11
11
  import {
12
- encodeMessage,
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 = encodeMessage({
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 = encodeMessage({
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 = encodeMessage({
133
+ const encoded = encodeResponse({
114
134
  wireVersion,
115
135
  msgKind: 'response',
116
136
  frames,