@powersync/service-module-postgres-storage 0.0.0-dev-20250813080357 → 0.0.0-dev-20250819134004

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.
@@ -10,9 +10,21 @@ exports[`sync - postgres > compacting data - invalidate checkpoint 1`] = `
10
10
  "checksum": -93886621,
11
11
  "count": 2,
12
12
  "priority": 3,
13
+ "subscriptions": [
14
+ {
15
+ "default": 0,
16
+ },
17
+ ],
13
18
  },
14
19
  ],
15
20
  "last_op_id": "2",
21
+ "streams": [
22
+ {
23
+ "errors": [],
24
+ "is_default": true,
25
+ "name": "mybucket",
26
+ },
27
+ ],
16
28
  "write_checkpoint": undefined,
17
29
  },
18
30
  },
@@ -46,6 +58,11 @@ exports[`sync - postgres > compacting data - invalidate checkpoint 2`] = `
46
58
  "checksum": 499012468,
47
59
  "count": 4,
48
60
  "priority": 3,
61
+ "subscriptions": [
62
+ {
63
+ "default": 0,
64
+ },
65
+ ],
49
66
  },
50
67
  ],
51
68
  "write_checkpoint": undefined,
@@ -105,9 +122,21 @@ exports[`sync - postgres > expiring token 1`] = `
105
122
  "checksum": 0,
106
123
  "count": 0,
107
124
  "priority": 3,
125
+ "subscriptions": [
126
+ {
127
+ "default": 0,
128
+ },
129
+ ],
108
130
  },
109
131
  ],
110
132
  "last_op_id": "0",
133
+ "streams": [
134
+ {
135
+ "errors": [],
136
+ "is_default": true,
137
+ "name": "mybucket",
138
+ },
139
+ ],
111
140
  "write_checkpoint": undefined,
112
141
  },
113
142
  },
@@ -137,9 +166,21 @@ exports[`sync - postgres > sends checkpoint complete line for empty checkpoint 1
137
166
  "checksum": -1221282404,
138
167
  "count": 1,
139
168
  "priority": 3,
169
+ "subscriptions": [
170
+ {
171
+ "default": 0,
172
+ },
173
+ ],
140
174
  },
141
175
  ],
142
176
  "last_op_id": "1",
177
+ "streams": [
178
+ {
179
+ "errors": [],
180
+ "is_default": true,
181
+ "name": "mybucket",
182
+ },
183
+ ],
143
184
  "write_checkpoint": undefined,
144
185
  },
145
186
  },
@@ -193,15 +234,37 @@ exports[`sync - postgres > sync buckets in order 1`] = `
193
234
  "checksum": 920318466,
194
235
  "count": 1,
195
236
  "priority": 2,
237
+ "subscriptions": [
238
+ {
239
+ "default": 0,
240
+ },
241
+ ],
196
242
  },
197
243
  {
198
244
  "bucket": "b1[]",
199
245
  "checksum": -1382098757,
200
246
  "count": 1,
201
247
  "priority": 1,
248
+ "subscriptions": [
249
+ {
250
+ "default": 1,
251
+ },
252
+ ],
202
253
  },
203
254
  ],
204
255
  "last_op_id": "2",
256
+ "streams": [
257
+ {
258
+ "errors": [],
259
+ "is_default": true,
260
+ "name": "b0",
261
+ },
262
+ {
263
+ "errors": [],
264
+ "is_default": true,
265
+ "name": "b1",
266
+ },
267
+ ],
205
268
  "write_checkpoint": undefined,
206
269
  },
207
270
  },
@@ -267,9 +330,21 @@ exports[`sync - postgres > sync global data 1`] = `
267
330
  "checksum": -93886621,
268
331
  "count": 2,
269
332
  "priority": 3,
333
+ "subscriptions": [
334
+ {
335
+ "default": 0,
336
+ },
337
+ ],
270
338
  },
271
339
  ],
272
340
  "last_op_id": "2",
341
+ "streams": [
342
+ {
343
+ "errors": [],
344
+ "is_default": true,
345
+ "name": "mybucket",
346
+ },
347
+ ],
273
348
  "write_checkpoint": undefined,
274
349
  },
275
350
  },
@@ -319,21 +394,53 @@ exports[`sync - postgres > sync interrupts low-priority buckets on new checkpoin
319
394
  "checksum": -659831575,
320
395
  "count": 2000,
321
396
  "priority": 2,
397
+ "subscriptions": [
398
+ {
399
+ "default": 0,
400
+ },
401
+ ],
322
402
  },
323
403
  {
324
404
  "bucket": "b0b[]",
325
405
  "checksum": -659831575,
326
406
  "count": 2000,
327
407
  "priority": 2,
408
+ "subscriptions": [
409
+ {
410
+ "default": 1,
411
+ },
412
+ ],
328
413
  },
329
414
  {
330
415
  "bucket": "b1[]",
331
416
  "checksum": -1096116670,
332
417
  "count": 1,
333
418
  "priority": 1,
419
+ "subscriptions": [
420
+ {
421
+ "default": 2,
422
+ },
423
+ ],
334
424
  },
335
425
  ],
336
426
  "last_op_id": "4001",
427
+ "streams": [
428
+ {
429
+ "errors": [],
430
+ "is_default": true,
431
+ "name": "b0a",
432
+ },
433
+ {
434
+ "errors": [],
435
+ "is_default": true,
436
+ "name": "b0b",
437
+ },
438
+ {
439
+ "errors": [],
440
+ "is_default": true,
441
+ "name": "b1",
442
+ },
443
+ ],
337
444
  "write_checkpoint": undefined,
338
445
  },
339
446
  },
@@ -380,18 +487,33 @@ exports[`sync - postgres > sync interrupts low-priority buckets on new checkpoin
380
487
  "checksum": 883076828,
381
488
  "count": 2001,
382
489
  "priority": 2,
490
+ "subscriptions": [
491
+ {
492
+ "default": 0,
493
+ },
494
+ ],
383
495
  },
384
496
  {
385
497
  "bucket": "b0b[]",
386
498
  "checksum": 883076828,
387
499
  "count": 2001,
388
500
  "priority": 2,
501
+ "subscriptions": [
502
+ {
503
+ "default": 1,
504
+ },
505
+ ],
389
506
  },
390
507
  {
391
508
  "bucket": "b1[]",
392
509
  "checksum": 1841937527,
393
510
  "count": 2,
394
511
  "priority": 1,
512
+ "subscriptions": [
513
+ {
514
+ "default": 2,
515
+ },
516
+ ],
395
517
  },
396
518
  ],
397
519
  "write_checkpoint": undefined,
@@ -466,9 +588,21 @@ exports[`sync - postgres > sync legacy non-raw data 1`] = `
466
588
  "checksum": -852817836,
467
589
  "count": 1,
468
590
  "priority": 3,
591
+ "subscriptions": [
592
+ {
593
+ "default": 0,
594
+ },
595
+ ],
469
596
  },
470
597
  ],
471
598
  "last_op_id": "1",
599
+ "streams": [
600
+ {
601
+ "errors": [],
602
+ "is_default": true,
603
+ "name": "mybucket",
604
+ },
605
+ ],
472
606
  "write_checkpoint": undefined,
473
607
  },
474
608
  },
@@ -514,9 +648,21 @@ exports[`sync - postgres > sync updates to data query only 1`] = `
514
648
  "checksum": 0,
515
649
  "count": 0,
516
650
  "priority": 3,
651
+ "subscriptions": [
652
+ {
653
+ "default": 0,
654
+ },
655
+ ],
517
656
  },
518
657
  ],
519
658
  "last_op_id": "1",
659
+ "streams": [
660
+ {
661
+ "errors": [],
662
+ "is_default": true,
663
+ "name": "by_user",
664
+ },
665
+ ],
520
666
  "write_checkpoint": undefined,
521
667
  },
522
668
  },
@@ -540,6 +686,11 @@ exports[`sync - postgres > sync updates to data query only 2`] = `
540
686
  "checksum": 1418351250,
541
687
  "count": 1,
542
688
  "priority": 3,
689
+ "subscriptions": [
690
+ {
691
+ "default": 0,
692
+ },
693
+ ],
543
694
  },
544
695
  ],
545
696
  "write_checkpoint": undefined,
@@ -582,9 +733,21 @@ exports[`sync - postgres > sync updates to global data 1`] = `
582
733
  "checksum": 0,
583
734
  "count": 0,
584
735
  "priority": 3,
736
+ "subscriptions": [
737
+ {
738
+ "default": 0,
739
+ },
740
+ ],
585
741
  },
586
742
  ],
587
743
  "last_op_id": "0",
744
+ "streams": [
745
+ {
746
+ "errors": [],
747
+ "is_default": true,
748
+ "name": "mybucket",
749
+ },
750
+ ],
588
751
  "write_checkpoint": undefined,
589
752
  },
590
753
  },
@@ -608,6 +771,11 @@ exports[`sync - postgres > sync updates to global data 2`] = `
608
771
  "checksum": 920318466,
609
772
  "count": 1,
610
773
  "priority": 3,
774
+ "subscriptions": [
775
+ {
776
+ "default": 0,
777
+ },
778
+ ],
611
779
  },
612
780
  ],
613
781
  "write_checkpoint": undefined,
@@ -652,6 +820,11 @@ exports[`sync - postgres > sync updates to global data 3`] = `
652
820
  "checksum": -93886621,
653
821
  "count": 2,
654
822
  "priority": 3,
823
+ "subscriptions": [
824
+ {
825
+ "default": 0,
826
+ },
827
+ ],
655
828
  },
656
829
  ],
657
830
  "write_checkpoint": undefined,
@@ -690,6 +863,13 @@ exports[`sync - postgres > sync updates to parameter query + data 1`] = `
690
863
  "checkpoint": {
691
864
  "buckets": [],
692
865
  "last_op_id": "0",
866
+ "streams": [
867
+ {
868
+ "errors": [],
869
+ "is_default": true,
870
+ "name": "by_user",
871
+ },
872
+ ],
693
873
  "write_checkpoint": undefined,
694
874
  },
695
875
  },
@@ -713,6 +893,11 @@ exports[`sync - postgres > sync updates to parameter query + data 2`] = `
713
893
  "checksum": 1418351250,
714
894
  "count": 1,
715
895
  "priority": 3,
896
+ "subscriptions": [
897
+ {
898
+ "default": 0,
899
+ },
900
+ ],
716
901
  },
717
902
  ],
718
903
  "write_checkpoint": undefined,
@@ -751,6 +936,13 @@ exports[`sync - postgres > sync updates to parameter query only 1`] = `
751
936
  "checkpoint": {
752
937
  "buckets": [],
753
938
  "last_op_id": "0",
939
+ "streams": [
940
+ {
941
+ "errors": [],
942
+ "is_default": true,
943
+ "name": "by_user",
944
+ },
945
+ ],
754
946
  "write_checkpoint": undefined,
755
947
  },
756
948
  },
@@ -774,6 +966,11 @@ exports[`sync - postgres > sync updates to parameter query only 2`] = `
774
966
  "checksum": 0,
775
967
  "count": 0,
776
968
  "priority": 3,
969
+ "subscriptions": [
970
+ {
971
+ "default": 0,
972
+ },
973
+ ],
777
974
  },
778
975
  ],
779
976
  "write_checkpoint": undefined,
@@ -2,9 +2,9 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest';
2
2
  import { POSTGRES_REPORT_STORAGE_FACTORY } from './util.js';
3
3
  import { event_types } from '@powersync/service-types';
4
4
 
5
- function removeVolatileFields(sdks: event_types.SdkConnectDocument[]): Partial<event_types.SdkConnectDocument>[] {
5
+ function removeVolatileFields(sdks: event_types.ClientConnection[]): Partial<event_types.ClientConnection>[] {
6
6
  return sdks.map((sdk) => {
7
- const { id, disconnect_at, connect_at, jwt_exp, ...rest } = sdk;
7
+ const { id, disconnected_at, connected_at, jwt_exp, ...rest } = sdk;
8
8
  return {
9
9
  ...rest
10
10
  };
@@ -35,7 +35,7 @@ describe('SDK reporting storage', async () => {
35
35
  const user_one = {
36
36
  user_id: 'user_one',
37
37
  client_id: 'client_one',
38
- connect_at: now.toISOString(),
38
+ connected_at: now.toISOString(),
39
39
  sdk: 'powersync-dart/1.6.4',
40
40
  user_agent: 'powersync-dart/1.6.4 Dart (flutter-web) Chrome/128 android',
41
41
  jwt_exp: nowAdd5minutes.toISOString(),
@@ -44,7 +44,7 @@ describe('SDK reporting storage', async () => {
44
44
  const user_two = {
45
45
  user_id: 'user_two',
46
46
  client_id: 'client_two',
47
- connect_at: nowLess5minutes.toISOString(),
47
+ connected_at: nowLess5minutes.toISOString(),
48
48
  sdk: 'powersync-js/1.21.1',
49
49
  user_agent: 'powersync-js/1.21.0 powersync-web Chromium/138 linux',
50
50
  jwt_exp: nowAdd5minutes.toISOString(),
@@ -53,17 +53,17 @@ describe('SDK reporting storage', async () => {
53
53
  const user_three = {
54
54
  user_id: 'user_three',
55
55
  client_id: 'client_three',
56
- connect_at: yesterday.toISOString(),
56
+ connected_at: yesterday.toISOString(),
57
57
  sdk: 'powersync-js/1.21.2',
58
58
  user_agent: 'powersync-js/1.21.0 powersync-web Firefox/141 linux',
59
- disconnect_at: yesterday.toISOString(),
59
+ disconnected_at: yesterday.toISOString(),
60
60
  id: '3'
61
61
  };
62
62
 
63
63
  const user_four = {
64
64
  user_id: 'user_four',
65
65
  client_id: 'client_four',
66
- connect_at: now.toISOString(),
66
+ connected_at: now.toISOString(),
67
67
  sdk: 'powersync-js/1.21.4',
68
68
  user_agent: 'powersync-js/1.21.0 powersync-web Firefox/141 linux',
69
69
  jwt_exp: nowLess5minutes.toISOString(),
@@ -73,27 +73,27 @@ describe('SDK reporting storage', async () => {
73
73
  const user_week = {
74
74
  user_id: 'user_week',
75
75
  client_id: 'client_week',
76
- connect_at: weekAgo.toISOString(),
76
+ connected_at: weekAgo.toISOString(),
77
77
  sdk: 'powersync-js/1.24.5',
78
78
  user_agent: 'powersync-js/1.21.0 powersync-web Firefox/141 linux',
79
- disconnect_at: weekAgo.toISOString(),
79
+ disconnected_at: weekAgo.toISOString(),
80
80
  id: 'week'
81
81
  };
82
82
 
83
83
  const user_month = {
84
84
  user_id: 'user_month',
85
85
  client_id: 'client_month',
86
- connect_at: monthAgo.toISOString(),
86
+ connected_at: monthAgo.toISOString(),
87
87
  sdk: 'powersync-js/1.23.6',
88
88
  user_agent: 'powersync-js/1.23.0 powersync-web Firefox/141 linux',
89
- disconnect_at: monthAgo.toISOString(),
89
+ disconnected_at: monthAgo.toISOString(),
90
90
  id: 'month'
91
91
  };
92
92
 
93
93
  const user_expired = {
94
94
  user_id: 'user_expired',
95
95
  client_id: 'client_expired',
96
- connect_at: monthAgo.toISOString(),
96
+ connected_at: monthAgo.toISOString(),
97
97
  sdk: 'powersync-js/1.23.7',
98
98
  user_agent: 'powersync-js/1.23.0 powersync-web Firefox/141 linux',
99
99
  jwt_exp: monthAgo.toISOString(),
@@ -106,18 +106,18 @@ describe('SDK reporting storage', async () => {
106
106
  sdk_report_events (
107
107
  user_id,
108
108
  client_id,
109
- connect_at,
109
+ connected_at,
110
110
  sdk,
111
111
  user_agent,
112
112
  jwt_exp,
113
113
  id,
114
- disconnect_at
114
+ disconnected_at
115
115
  )
116
116
  VALUES
117
117
  (
118
118
  ${{ type: 'varchar', value: user_one.user_id }},
119
119
  ${{ type: 'varchar', value: user_one.client_id }},
120
- ${{ type: 1184, value: user_one.connect_at }},
120
+ ${{ type: 1184, value: user_one.connected_at }},
121
121
  ${{ type: 'varchar', value: user_one.sdk }},
122
122
  ${{ type: 'varchar', value: user_one.user_agent }},
123
123
  ${{ type: 1184, value: user_one.jwt_exp }},
@@ -127,7 +127,7 @@ describe('SDK reporting storage', async () => {
127
127
  (
128
128
  ${{ type: 'varchar', value: user_two.user_id }},
129
129
  ${{ type: 'varchar', value: user_two.client_id }},
130
- ${{ type: 1184, value: user_two.connect_at }},
130
+ ${{ type: 1184, value: user_two.connected_at }},
131
131
  ${{ type: 'varchar', value: user_two.sdk }},
132
132
  ${{ type: 'varchar', value: user_two.user_agent }},
133
133
  ${{ type: 1184, value: user_two.jwt_exp }},
@@ -137,7 +137,7 @@ describe('SDK reporting storage', async () => {
137
137
  (
138
138
  ${{ type: 'varchar', value: user_four.user_id }},
139
139
  ${{ type: 'varchar', value: user_four.client_id }},
140
- ${{ type: 1184, value: user_four.connect_at }},
140
+ ${{ type: 1184, value: user_four.connected_at }},
141
141
  ${{ type: 'varchar', value: user_four.sdk }},
142
142
  ${{ type: 'varchar', value: user_four.user_agent }},
143
143
  ${{ type: 1184, value: user_four.jwt_exp }},
@@ -147,37 +147,37 @@ describe('SDK reporting storage', async () => {
147
147
  (
148
148
  ${{ type: 'varchar', value: user_three.user_id }},
149
149
  ${{ type: 'varchar', value: user_three.client_id }},
150
- ${{ type: 1184, value: user_three.connect_at }},
150
+ ${{ type: 1184, value: user_three.connected_at }},
151
151
  ${{ type: 'varchar', value: user_three.sdk }},
152
152
  ${{ type: 'varchar', value: user_three.user_agent }},
153
153
  NULL,
154
154
  ${{ type: 'varchar', value: user_three.id }},
155
- ${{ type: 1184, value: user_three.disconnect_at }}
155
+ ${{ type: 1184, value: user_three.disconnected_at }}
156
156
  ),
157
157
  (
158
158
  ${{ type: 'varchar', value: user_week.user_id }},
159
159
  ${{ type: 'varchar', value: user_week.client_id }},
160
- ${{ type: 1184, value: user_week.connect_at }},
160
+ ${{ type: 1184, value: user_week.connected_at }},
161
161
  ${{ type: 'varchar', value: user_week.sdk }},
162
162
  ${{ type: 'varchar', value: user_week.user_agent }},
163
163
  NULL,
164
164
  ${{ type: 'varchar', value: user_week.id }},
165
- ${{ type: 1184, value: user_week.disconnect_at }}
165
+ ${{ type: 1184, value: user_week.disconnected_at }}
166
166
  ),
167
167
  (
168
168
  ${{ type: 'varchar', value: user_month.user_id }},
169
169
  ${{ type: 'varchar', value: user_month.client_id }},
170
- ${{ type: 1184, value: user_month.connect_at }},
170
+ ${{ type: 1184, value: user_month.connected_at }},
171
171
  ${{ type: 'varchar', value: user_month.sdk }},
172
172
  ${{ type: 'varchar', value: user_month.user_agent }},
173
173
  NULL,
174
174
  ${{ type: 'varchar', value: user_month.id }},
175
- ${{ type: 1184, value: user_month.disconnect_at }}
175
+ ${{ type: 1184, value: user_month.disconnected_at }}
176
176
  ),
177
177
  (
178
178
  ${{ type: 'varchar', value: user_expired.user_id }},
179
179
  ${{ type: 'varchar', value: user_expired.client_id }},
180
- ${{ type: 1184, value: user_expired.connect_at }},
180
+ ${{ type: 1184, value: user_expired.connected_at }},
181
181
  ${{ type: 'varchar', value: user_expired.sdk }},
182
182
  ${{ type: 'varchar', value: user_expired.user_agent }},
183
183
  ${{ type: 1184, value: user_expired.jwt_exp }},
@@ -199,7 +199,7 @@ describe('SDK reporting storage', async () => {
199
199
  await deleteData();
200
200
  });
201
201
  it('Should show connected users with start range', async () => {
202
- const current = await factory.listCurrentConnections({
202
+ const current = await factory.getConnectedClients({
203
203
  range: {
204
204
  start: new Date(
205
205
  now.getFullYear(),
@@ -213,7 +213,7 @@ describe('SDK reporting storage', async () => {
213
213
  expect(current).toMatchSnapshot();
214
214
  });
215
215
  it('Should show connected users with start range and end range', async () => {
216
- const current = await factory.listCurrentConnections({
216
+ const current = await factory.getConnectedClients({
217
217
  range: {
218
218
  end: nowLess5minutes.toISOString(),
219
219
  start: new Date(
@@ -228,21 +228,21 @@ describe('SDK reporting storage', async () => {
228
228
  expect(current).toMatchSnapshot();
229
229
  });
230
230
  it('Should show SDK scrape data for user over the past month', async () => {
231
- const sdk = await factory.scrapeSdkData({
231
+ const sdk = await factory.getClientConnectionReports({
232
232
  start: monthAgo,
233
233
  end: now
234
234
  });
235
235
  expect(sdk).toMatchSnapshot();
236
236
  });
237
237
  it('Should show SDK scrape data for user over the past week', async () => {
238
- const sdk = await factory.scrapeSdkData({
238
+ const sdk = await factory.getClientConnectionReports({
239
239
  start: weekAgo,
240
240
  end: now
241
241
  });
242
242
  expect(sdk).toMatchSnapshot();
243
243
  });
244
244
  it('Should show SDK scrape data for user over the past day', async () => {
245
- const sdk = await factory.scrapeSdkData({
245
+ const sdk = await factory.getClientConnectionReports({
246
246
  start: dayAgo,
247
247
  end: now
248
248
  });
@@ -258,9 +258,9 @@ describe('SDK reporting storage', async () => {
258
258
  now.getMinutes() + 20
259
259
  );
260
260
  const jwtExp = new Date(newConnectAt.getFullYear(), newConnectAt.getMonth(), newConnectAt.getDate() + 1);
261
- await factory.reportSdkConnect({
261
+ await factory.reportClientConnection({
262
262
  sdk: user_one.sdk,
263
- connect_at: newConnectAt,
263
+ connected_at: newConnectAt,
264
264
  jwt_exp: jwtExp,
265
265
  client_id: user_one.client_id,
266
266
  user_id: user_one.user_id,
@@ -268,11 +268,11 @@ describe('SDK reporting storage', async () => {
268
268
  });
269
269
 
270
270
  const sdk = await factory.db
271
- .sql`SELECT * FROM sdk_report_events WHERE user_id = ${{ type: 'varchar', value: user_one.user_id }}`.rows<event_types.SdkConnectDocument>();
271
+ .sql`SELECT * FROM sdk_report_events WHERE user_id = ${{ type: 'varchar', value: user_one.user_id }}`.rows<event_types.ClientConnection>();
272
272
  expect(sdk).toHaveLength(1);
273
- expect(new Date(sdk[0].connect_at).toISOString()).toEqual(newConnectAt.toISOString());
273
+ expect(new Date(sdk[0].connected_at).toISOString()).toEqual(newConnectAt.toISOString());
274
274
  expect(new Date(sdk[0].jwt_exp!).toISOString()).toEqual(jwtExp.toISOString());
275
- expect(sdk[0].disconnect_at).toBeNull();
275
+ expect(sdk[0].disconnected_at).toBeNull();
276
276
  const cleaned = removeVolatileFields(sdk);
277
277
  expect(cleaned).toMatchSnapshot();
278
278
  });
@@ -287,19 +287,19 @@ describe('SDK reporting storage', async () => {
287
287
  );
288
288
  const jwtExp = new Date(disconnectAt.getFullYear(), disconnectAt.getMonth(), disconnectAt.getDate() + 1);
289
289
 
290
- await factory.reportSdkDisconnect({
291
- disconnect_at: disconnectAt,
290
+ await factory.reportClientDisconnection({
291
+ disconnected_at: disconnectAt,
292
292
  jwt_exp: jwtExp,
293
293
  client_id: user_three.client_id,
294
294
  user_id: user_three.user_id,
295
295
  user_agent: user_three.user_agent,
296
- connect_at: yesterday
296
+ connected_at: yesterday
297
297
  });
298
298
 
299
299
  const sdk = await factory.db
300
- .sql`SELECT * FROM sdk_report_events WHERE user_id = ${{ type: 'varchar', value: user_three.user_id }}`.rows<event_types.SdkConnectDocument>();
300
+ .sql`SELECT * FROM sdk_report_events WHERE user_id = ${{ type: 'varchar', value: user_three.user_id }}`.rows<event_types.ClientConnection>();
301
301
  expect(sdk).toHaveLength(1);
302
- expect(new Date(sdk[0].disconnect_at!).toISOString()).toEqual(disconnectAt.toISOString());
302
+ expect(new Date(sdk[0].disconnected_at!).toISOString()).toEqual(disconnectAt.toISOString());
303
303
  const cleaned = removeVolatileFields(sdk);
304
304
  expect(cleaned).toMatchSnapshot();
305
305
  });
@@ -308,9 +308,9 @@ describe('SDK reporting storage', async () => {
308
308
  const newConnectAt = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, now.getHours());
309
309
  const jwtExp = new Date(newConnectAt.getFullYear(), newConnectAt.getMonth(), newConnectAt.getDate() + 1);
310
310
 
311
- await factory.reportSdkConnect({
311
+ await factory.reportClientConnection({
312
312
  sdk: user_week.sdk,
313
- connect_at: newConnectAt,
313
+ connected_at: newConnectAt,
314
314
  jwt_exp: jwtExp,
315
315
  client_id: user_week.client_id,
316
316
  user_id: user_week.user_id,
@@ -318,7 +318,7 @@ describe('SDK reporting storage', async () => {
318
318
  });
319
319
 
320
320
  const sdk = await factory.db
321
- .sql`SELECT * FROM sdk_report_events WHERE user_id = ${{ type: 'varchar', value: user_week.user_id }}`.rows<event_types.SdkConnectDocument>();
321
+ .sql`SELECT * FROM sdk_report_events WHERE user_id = ${{ type: 'varchar', value: user_week.user_id }}`.rows<event_types.ClientConnection>();
322
322
  expect(sdk).toHaveLength(2);
323
323
  const cleaned = removeVolatileFields(sdk);
324
324
  expect(cleaned).toMatchSnapshot();
@@ -327,10 +327,10 @@ describe('SDK reporting storage', async () => {
327
327
  it('Should delete rows older than specified range', async () => {
328
328
  await deleteData();
329
329
  await loadData();
330
- await factory.deleteOldSdkData({
330
+ await factory.deleteOldConnectionData({
331
331
  date: weekAgo
332
332
  });
333
- const sdk = await factory.scrapeSdkData({
333
+ const sdk = await factory.getClientConnectionReports({
334
334
  start: monthAgo,
335
335
  end: now
336
336
  });