@livestore/livestore 0.4.0 → 0.5.0-dev.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/dist/.tsbuildinfo +1 -1
- package/dist/SqliteDbWrapper.d.ts.map +1 -1
- package/dist/SqliteDbWrapper.js +7 -5
- package/dist/SqliteDbWrapper.js.map +1 -1
- package/dist/SqliteDbWrapper.test.js +20 -3
- package/dist/SqliteDbWrapper.test.js.map +1 -1
- package/dist/effect/LiveStore.d.ts +15 -15
- package/dist/effect/LiveStore.d.ts.map +1 -1
- package/dist/effect/LiveStore.js +17 -17
- package/dist/effect/LiveStore.js.map +1 -1
- package/dist/effect/LiveStore.test.js +5 -6
- package/dist/effect/LiveStore.test.js.map +1 -1
- package/dist/live-queries/base-class.d.ts +19 -2
- package/dist/live-queries/base-class.d.ts.map +1 -1
- package/dist/live-queries/base-class.js +28 -2
- package/dist/live-queries/base-class.js.map +1 -1
- package/dist/live-queries/computed.d.ts.map +1 -1
- package/dist/live-queries/computed.js +4 -4
- package/dist/live-queries/computed.js.map +1 -1
- package/dist/live-queries/db-query.d.ts +2 -2
- package/dist/live-queries/db-query.d.ts.map +1 -1
- package/dist/live-queries/db-query.js +26 -17
- package/dist/live-queries/db-query.js.map +1 -1
- package/dist/live-queries/db-query.test.js +9 -9
- package/dist/live-queries/db-query.test.js.map +1 -1
- package/dist/live-queries/signal.d.ts.map +1 -1
- package/dist/live-queries/signal.js +2 -2
- package/dist/live-queries/signal.js.map +1 -1
- package/dist/live-queries/signal.test.js +2 -2
- package/dist/live-queries/signal.test.js.map +1 -1
- package/dist/reactive.d.ts +1 -1
- package/dist/reactive.d.ts.map +1 -1
- package/dist/reactive.js +20 -1
- package/dist/reactive.js.map +1 -1
- package/dist/store/StoreRegistry.d.ts +12 -12
- package/dist/store/StoreRegistry.d.ts.map +1 -1
- package/dist/store/StoreRegistry.js +24 -24
- package/dist/store/StoreRegistry.js.map +1 -1
- package/dist/store/StoreRegistry.test.js +62 -59
- package/dist/store/StoreRegistry.test.js.map +1 -1
- package/dist/store/create-store.d.ts +12 -15
- package/dist/store/create-store.d.ts.map +1 -1
- package/dist/store/create-store.js +43 -24
- package/dist/store/create-store.js.map +1 -1
- package/dist/store/devtools.d.ts +1 -2
- package/dist/store/devtools.d.ts.map +1 -1
- package/dist/store/devtools.js +3 -2
- package/dist/store/devtools.js.map +1 -1
- package/dist/store/store-eventstream.test.js +5 -5
- package/dist/store/store-eventstream.test.js.map +1 -1
- package/dist/store/store-types.d.ts +10 -28
- package/dist/store/store-types.d.ts.map +1 -1
- package/dist/store/store-types.js +2 -38
- package/dist/store/store-types.js.map +1 -1
- package/dist/store/store-types.test.js +1 -1
- package/dist/store/store.d.ts +2 -2
- package/dist/store/store.d.ts.map +1 -1
- package/dist/store/store.js +114 -56
- package/dist/store/store.js.map +1 -1
- package/dist/utils/dev.js +1 -1
- package/dist/utils/dev.js.map +1 -1
- package/dist/utils/stack-info.d.ts.map +1 -1
- package/dist/utils/stack-info.js +2 -1
- package/dist/utils/stack-info.js.map +1 -1
- package/dist/utils/tests/fixture.d.ts +26 -34
- package/dist/utils/tests/fixture.d.ts.map +1 -1
- package/package.json +14 -24
- package/src/SqliteDbWrapper.test.ts +25 -3
- package/src/SqliteDbWrapper.ts +12 -9
- package/src/effect/LiveStore.test.ts +16 -16
- package/src/effect/LiveStore.ts +79 -50
- package/src/live-queries/__snapshots__/db-query.test.ts.snap +273 -49
- package/src/live-queries/base-class.ts +38 -6
- package/src/live-queries/computed.ts +5 -5
- package/src/live-queries/db-query.test.ts +9 -9
- package/src/live-queries/db-query.ts +42 -30
- package/src/live-queries/signal.test.ts +2 -2
- package/src/live-queries/signal.ts +3 -3
- package/src/reactive.ts +45 -35
- package/src/store/StoreRegistry.test.ts +62 -59
- package/src/store/StoreRegistry.ts +49 -38
- package/src/store/create-store.ts +85 -51
- package/src/store/devtools.ts +283 -283
- package/src/store/store-eventstream.test.ts +16 -7
- package/src/store/store-types.test.ts +1 -1
- package/src/store/store-types.ts +10 -56
- package/src/store/store.ts +148 -71
- package/src/utils/dev.ts +1 -1
- package/src/utils/stack-info.ts +4 -1
|
@@ -27,16 +27,17 @@ exports[`otel > QueryBuilder subscription - async iterator 1`] = `
|
|
|
27
27
|
"_name": "client-session-sync-processor:boot",
|
|
28
28
|
"children": [
|
|
29
29
|
{
|
|
30
|
-
"_name": "
|
|
30
|
+
"_name": "client-session-sync-processor:pull",
|
|
31
31
|
"attributes": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"span.label": "⚠︎ Interrupted",
|
|
33
|
+
"status.interrupted": true,
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
|
-
"_name": "
|
|
37
|
+
"_name": "@livestore/common:LeaderSyncProcessor:push",
|
|
38
38
|
"attributes": {
|
|
39
|
-
"
|
|
39
|
+
"batch": "undefined",
|
|
40
|
+
"batchSize": 1,
|
|
40
41
|
"span.label": "⚠︎ Interrupted",
|
|
41
42
|
"status.interrupted": true,
|
|
42
43
|
},
|
|
@@ -48,6 +49,52 @@ exports[`otel > QueryBuilder subscription - async iterator 1`] = `
|
|
|
48
49
|
},
|
|
49
50
|
{
|
|
50
51
|
"_name": "LiveStore:queries",
|
|
52
|
+
"children": [
|
|
53
|
+
{
|
|
54
|
+
"_name": "LiveStore.subscribe",
|
|
55
|
+
"attributes": {
|
|
56
|
+
"queryLabel": "SELECT * FROM 'todos' WHERE "completed" = ? LIMIT ?",
|
|
57
|
+
},
|
|
58
|
+
"children": [
|
|
59
|
+
{
|
|
60
|
+
"_name": "db:SELECT * FROM 'todos' WHERE "completed" = ? LIMIT ",
|
|
61
|
+
"attributes": {
|
|
62
|
+
"livestore.debugRefreshReason": "subscribe-initial-run:undefined",
|
|
63
|
+
"sql.query": "SELECT * FROM 'todos' WHERE "completed" = ? LIMIT ?",
|
|
64
|
+
"sql.rowsCount": 0,
|
|
65
|
+
},
|
|
66
|
+
"children": [
|
|
67
|
+
{
|
|
68
|
+
"_name": "sql-in-memory-select",
|
|
69
|
+
"attributes": {
|
|
70
|
+
"sql.cached": false,
|
|
71
|
+
"sql.query": "SELECT * FROM 'todos' WHERE "completed" = ? LIMIT ?",
|
|
72
|
+
"sql.rowsCount": 0,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"_name": "db:SELECT * FROM 'todos' WHERE "completed" = ? LIMIT ",
|
|
79
|
+
"attributes": {
|
|
80
|
+
"livestore.debugRefreshReason": "commit",
|
|
81
|
+
"sql.query": "SELECT * FROM 'todos' WHERE "completed" = ? LIMIT ?",
|
|
82
|
+
"sql.rowsCount": 1,
|
|
83
|
+
},
|
|
84
|
+
"children": [
|
|
85
|
+
{
|
|
86
|
+
"_name": "sql-in-memory-select",
|
|
87
|
+
"attributes": {
|
|
88
|
+
"sql.cached": false,
|
|
89
|
+
"sql.query": "SELECT * FROM 'todos' WHERE "completed" = ? LIMIT ?",
|
|
90
|
+
"sql.rowsCount": 1,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
],
|
|
51
98
|
},
|
|
52
99
|
],
|
|
53
100
|
}
|
|
@@ -79,6 +126,19 @@ exports[`otel > QueryBuilder subscription - async iterator 2`] = `
|
|
|
79
126
|
"sql.query": "INSERT INTO 'todos' ("id", "text", "completed") VALUES (?, ?, ?)",
|
|
80
127
|
},
|
|
81
128
|
},
|
|
129
|
+
{
|
|
130
|
+
"_name": "@livestore/common:execSql",
|
|
131
|
+
"attributes": {
|
|
132
|
+
"bindValueKeys": "[
|
|
133
|
+
"$id",
|
|
134
|
+
"$seqNumGlobal",
|
|
135
|
+
"$seqNumClient",
|
|
136
|
+
"$seqNumRebaseGeneration"
|
|
137
|
+
]",
|
|
138
|
+
"span.label": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
139
|
+
"sql": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
140
|
+
},
|
|
141
|
+
},
|
|
82
142
|
],
|
|
83
143
|
},
|
|
84
144
|
],
|
|
@@ -125,16 +185,17 @@ exports[`otel > QueryBuilder subscription - async iterator with skipInitialRun 1
|
|
|
125
185
|
"_name": "client-session-sync-processor:boot",
|
|
126
186
|
"children": [
|
|
127
187
|
{
|
|
128
|
-
"_name": "
|
|
188
|
+
"_name": "client-session-sync-processor:pull",
|
|
129
189
|
"attributes": {
|
|
130
|
-
"
|
|
131
|
-
"
|
|
190
|
+
"span.label": "⚠︎ Interrupted",
|
|
191
|
+
"status.interrupted": true,
|
|
132
192
|
},
|
|
133
193
|
},
|
|
134
194
|
{
|
|
135
|
-
"_name": "
|
|
195
|
+
"_name": "@livestore/common:LeaderSyncProcessor:push",
|
|
136
196
|
"attributes": {
|
|
137
|
-
"
|
|
197
|
+
"batch": "undefined",
|
|
198
|
+
"batchSize": 1,
|
|
138
199
|
"span.label": "⚠︎ Interrupted",
|
|
139
200
|
"status.interrupted": true,
|
|
140
201
|
},
|
|
@@ -146,6 +207,52 @@ exports[`otel > QueryBuilder subscription - async iterator with skipInitialRun 1
|
|
|
146
207
|
},
|
|
147
208
|
{
|
|
148
209
|
"_name": "LiveStore:queries",
|
|
210
|
+
"children": [
|
|
211
|
+
{
|
|
212
|
+
"_name": "LiveStore.subscribe",
|
|
213
|
+
"attributes": {
|
|
214
|
+
"queryLabel": "SELECT * FROM 'todos' WHERE "completed" = ? LIMIT ?",
|
|
215
|
+
},
|
|
216
|
+
"children": [
|
|
217
|
+
{
|
|
218
|
+
"_name": "db:SELECT * FROM 'todos' WHERE "completed" = ? LIMIT ",
|
|
219
|
+
"attributes": {
|
|
220
|
+
"livestore.debugRefreshReason": "subscribe-initial-run:undefined",
|
|
221
|
+
"sql.query": "SELECT * FROM 'todos' WHERE "completed" = ? LIMIT ?",
|
|
222
|
+
"sql.rowsCount": 0,
|
|
223
|
+
},
|
|
224
|
+
"children": [
|
|
225
|
+
{
|
|
226
|
+
"_name": "sql-in-memory-select",
|
|
227
|
+
"attributes": {
|
|
228
|
+
"sql.cached": false,
|
|
229
|
+
"sql.query": "SELECT * FROM 'todos' WHERE "completed" = ? LIMIT ?",
|
|
230
|
+
"sql.rowsCount": 0,
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"_name": "db:SELECT * FROM 'todos' WHERE "completed" = ? LIMIT ",
|
|
237
|
+
"attributes": {
|
|
238
|
+
"livestore.debugRefreshReason": "commit",
|
|
239
|
+
"sql.query": "SELECT * FROM 'todos' WHERE "completed" = ? LIMIT ?",
|
|
240
|
+
"sql.rowsCount": 1,
|
|
241
|
+
},
|
|
242
|
+
"children": [
|
|
243
|
+
{
|
|
244
|
+
"_name": "sql-in-memory-select",
|
|
245
|
+
"attributes": {
|
|
246
|
+
"sql.cached": false,
|
|
247
|
+
"sql.query": "SELECT * FROM 'todos' WHERE "completed" = ? LIMIT ?",
|
|
248
|
+
"sql.rowsCount": 1,
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
},
|
|
255
|
+
],
|
|
149
256
|
},
|
|
150
257
|
],
|
|
151
258
|
}
|
|
@@ -177,6 +284,19 @@ exports[`otel > QueryBuilder subscription - async iterator with skipInitialRun 2
|
|
|
177
284
|
"sql.query": "INSERT INTO 'todos' ("id", "text", "completed") VALUES (?, ?, ?)",
|
|
178
285
|
},
|
|
179
286
|
},
|
|
287
|
+
{
|
|
288
|
+
"_name": "@livestore/common:execSql",
|
|
289
|
+
"attributes": {
|
|
290
|
+
"bindValueKeys": "[
|
|
291
|
+
"$id",
|
|
292
|
+
"$seqNumGlobal",
|
|
293
|
+
"$seqNumClient",
|
|
294
|
+
"$seqNumRebaseGeneration"
|
|
295
|
+
]",
|
|
296
|
+
"span.label": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
297
|
+
"sql": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
298
|
+
},
|
|
299
|
+
},
|
|
180
300
|
],
|
|
181
301
|
},
|
|
182
302
|
],
|
|
@@ -223,16 +343,17 @@ exports[`otel > QueryBuilder subscription - basic functionality 1`] = `
|
|
|
223
343
|
"_name": "client-session-sync-processor:boot",
|
|
224
344
|
"children": [
|
|
225
345
|
{
|
|
226
|
-
"_name": "
|
|
346
|
+
"_name": "client-session-sync-processor:pull",
|
|
227
347
|
"attributes": {
|
|
228
|
-
"
|
|
229
|
-
"
|
|
348
|
+
"span.label": "⚠︎ Interrupted",
|
|
349
|
+
"status.interrupted": true,
|
|
230
350
|
},
|
|
231
351
|
},
|
|
232
352
|
{
|
|
233
|
-
"_name": "
|
|
353
|
+
"_name": "@livestore/common:LeaderSyncProcessor:push",
|
|
234
354
|
"attributes": {
|
|
235
|
-
"
|
|
355
|
+
"batch": "undefined",
|
|
356
|
+
"batchSize": 1,
|
|
236
357
|
"span.label": "⚠︎ Interrupted",
|
|
237
358
|
"status.interrupted": true,
|
|
238
359
|
},
|
|
@@ -321,6 +442,19 @@ exports[`otel > QueryBuilder subscription - basic functionality 2`] = `
|
|
|
321
442
|
"sql.query": "INSERT INTO 'todos' ("id", "text", "completed") VALUES (?, ?, ?)",
|
|
322
443
|
},
|
|
323
444
|
},
|
|
445
|
+
{
|
|
446
|
+
"_name": "@livestore/common:execSql",
|
|
447
|
+
"attributes": {
|
|
448
|
+
"bindValueKeys": "[
|
|
449
|
+
"$id",
|
|
450
|
+
"$seqNumGlobal",
|
|
451
|
+
"$seqNumClient",
|
|
452
|
+
"$seqNumRebaseGeneration"
|
|
453
|
+
]",
|
|
454
|
+
"span.label": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
455
|
+
"sql": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
456
|
+
},
|
|
457
|
+
},
|
|
324
458
|
],
|
|
325
459
|
},
|
|
326
460
|
],
|
|
@@ -367,16 +501,17 @@ exports[`otel > QueryBuilder subscription - direct table subscription 1`] = `
|
|
|
367
501
|
"_name": "client-session-sync-processor:boot",
|
|
368
502
|
"children": [
|
|
369
503
|
{
|
|
370
|
-
"_name": "
|
|
504
|
+
"_name": "client-session-sync-processor:pull",
|
|
371
505
|
"attributes": {
|
|
372
|
-
"
|
|
373
|
-
"
|
|
506
|
+
"span.label": "⚠︎ Interrupted",
|
|
507
|
+
"status.interrupted": true,
|
|
374
508
|
},
|
|
375
509
|
},
|
|
376
510
|
{
|
|
377
|
-
"_name": "
|
|
511
|
+
"_name": "@livestore/common:LeaderSyncProcessor:push",
|
|
378
512
|
"attributes": {
|
|
379
|
-
"
|
|
513
|
+
"batch": "undefined",
|
|
514
|
+
"batchSize": 1,
|
|
380
515
|
"span.label": "⚠︎ Interrupted",
|
|
381
516
|
"status.interrupted": true,
|
|
382
517
|
},
|
|
@@ -465,6 +600,19 @@ exports[`otel > QueryBuilder subscription - direct table subscription 2`] = `
|
|
|
465
600
|
"sql.query": "INSERT INTO 'todos' ("id", "text", "completed") VALUES (?, ?, ?)",
|
|
466
601
|
},
|
|
467
602
|
},
|
|
603
|
+
{
|
|
604
|
+
"_name": "@livestore/common:execSql",
|
|
605
|
+
"attributes": {
|
|
606
|
+
"bindValueKeys": "[
|
|
607
|
+
"$id",
|
|
608
|
+
"$seqNumGlobal",
|
|
609
|
+
"$seqNumClient",
|
|
610
|
+
"$seqNumRebaseGeneration"
|
|
611
|
+
]",
|
|
612
|
+
"span.label": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
613
|
+
"sql": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
614
|
+
},
|
|
615
|
+
},
|
|
468
616
|
],
|
|
469
617
|
},
|
|
470
618
|
],
|
|
@@ -511,16 +659,17 @@ exports[`otel > QueryBuilder subscription - skipInitialRun 1`] = `
|
|
|
511
659
|
"_name": "client-session-sync-processor:boot",
|
|
512
660
|
"children": [
|
|
513
661
|
{
|
|
514
|
-
"_name": "
|
|
662
|
+
"_name": "client-session-sync-processor:pull",
|
|
515
663
|
"attributes": {
|
|
516
|
-
"
|
|
517
|
-
"
|
|
664
|
+
"span.label": "⚠︎ Interrupted",
|
|
665
|
+
"status.interrupted": true,
|
|
518
666
|
},
|
|
519
667
|
},
|
|
520
668
|
{
|
|
521
|
-
"_name": "
|
|
669
|
+
"_name": "@livestore/common:LeaderSyncProcessor:push",
|
|
522
670
|
"attributes": {
|
|
523
|
-
"
|
|
671
|
+
"batch": "undefined",
|
|
672
|
+
"batchSize": 1,
|
|
524
673
|
"span.label": "⚠︎ Interrupted",
|
|
525
674
|
"status.interrupted": true,
|
|
526
675
|
},
|
|
@@ -609,6 +758,19 @@ exports[`otel > QueryBuilder subscription - skipInitialRun 2`] = `
|
|
|
609
758
|
"sql.query": "INSERT INTO 'todos' ("id", "text", "completed") VALUES (?, ?, ?)",
|
|
610
759
|
},
|
|
611
760
|
},
|
|
761
|
+
{
|
|
762
|
+
"_name": "@livestore/common:execSql",
|
|
763
|
+
"attributes": {
|
|
764
|
+
"bindValueKeys": "[
|
|
765
|
+
"$id",
|
|
766
|
+
"$seqNumGlobal",
|
|
767
|
+
"$seqNumClient",
|
|
768
|
+
"$seqNumRebaseGeneration"
|
|
769
|
+
]",
|
|
770
|
+
"span.label": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
771
|
+
"sql": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
772
|
+
},
|
|
773
|
+
},
|
|
612
774
|
],
|
|
613
775
|
},
|
|
614
776
|
],
|
|
@@ -655,10 +817,10 @@ exports[`otel > QueryBuilder subscription - unsubscribe functionality 1`] = `
|
|
|
655
817
|
"_name": "client-session-sync-processor:boot",
|
|
656
818
|
"children": [
|
|
657
819
|
{
|
|
658
|
-
"_name": "
|
|
820
|
+
"_name": "client-session-sync-processor:pull",
|
|
659
821
|
"attributes": {
|
|
660
|
-
"
|
|
661
|
-
"
|
|
822
|
+
"span.label": "⚠︎ Interrupted",
|
|
823
|
+
"status.interrupted": true,
|
|
662
824
|
},
|
|
663
825
|
},
|
|
664
826
|
{
|
|
@@ -666,12 +828,6 @@ exports[`otel > QueryBuilder subscription - unsubscribe functionality 1`] = `
|
|
|
666
828
|
"attributes": {
|
|
667
829
|
"batch": "undefined",
|
|
668
830
|
"batchSize": 1,
|
|
669
|
-
},
|
|
670
|
-
},
|
|
671
|
-
{
|
|
672
|
-
"_name": "client-session-sync-processor:pull",
|
|
673
|
-
"attributes": {
|
|
674
|
-
"code.stacktrace": "<STACKTRACE>",
|
|
675
831
|
"span.label": "⚠︎ Interrupted",
|
|
676
832
|
"status.interrupted": true,
|
|
677
833
|
},
|
|
@@ -786,6 +942,19 @@ exports[`otel > QueryBuilder subscription - unsubscribe functionality 2`] = `
|
|
|
786
942
|
"sql.query": "INSERT INTO 'todos' ("id", "text", "completed") VALUES (?, ?, ?)",
|
|
787
943
|
},
|
|
788
944
|
},
|
|
945
|
+
{
|
|
946
|
+
"_name": "@livestore/common:execSql",
|
|
947
|
+
"attributes": {
|
|
948
|
+
"bindValueKeys": "[
|
|
949
|
+
"$id",
|
|
950
|
+
"$seqNumGlobal",
|
|
951
|
+
"$seqNumClient",
|
|
952
|
+
"$seqNumRebaseGeneration"
|
|
953
|
+
]",
|
|
954
|
+
"span.label": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
955
|
+
"sql": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
956
|
+
},
|
|
957
|
+
},
|
|
789
958
|
],
|
|
790
959
|
},
|
|
791
960
|
],
|
|
@@ -826,6 +995,19 @@ exports[`otel > QueryBuilder subscription - unsubscribe functionality 2`] = `
|
|
|
826
995
|
"sql.query": "INSERT INTO 'todos' ("id", "text", "completed") VALUES (?, ?, ?)",
|
|
827
996
|
},
|
|
828
997
|
},
|
|
998
|
+
{
|
|
999
|
+
"_name": "@livestore/common:execSql",
|
|
1000
|
+
"attributes": {
|
|
1001
|
+
"bindValueKeys": "[
|
|
1002
|
+
"$id",
|
|
1003
|
+
"$seqNumGlobal",
|
|
1004
|
+
"$seqNumClient",
|
|
1005
|
+
"$seqNumRebaseGeneration"
|
|
1006
|
+
]",
|
|
1007
|
+
"span.label": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
1008
|
+
"sql": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
1009
|
+
},
|
|
1010
|
+
},
|
|
829
1011
|
],
|
|
830
1012
|
},
|
|
831
1013
|
],
|
|
@@ -872,16 +1054,17 @@ exports[`otel > otel 3`] = `
|
|
|
872
1054
|
"_name": "client-session-sync-processor:boot",
|
|
873
1055
|
"children": [
|
|
874
1056
|
{
|
|
875
|
-
"_name": "
|
|
1057
|
+
"_name": "client-session-sync-processor:pull",
|
|
876
1058
|
"attributes": {
|
|
877
|
-
"
|
|
878
|
-
"
|
|
1059
|
+
"span.label": "⚠︎ Interrupted",
|
|
1060
|
+
"status.interrupted": true,
|
|
879
1061
|
},
|
|
880
1062
|
},
|
|
881
1063
|
{
|
|
882
|
-
"_name": "
|
|
1064
|
+
"_name": "@livestore/common:LeaderSyncProcessor:push",
|
|
883
1065
|
"attributes": {
|
|
884
|
-
"
|
|
1066
|
+
"batch": "undefined",
|
|
1067
|
+
"batchSize": 1,
|
|
885
1068
|
"span.label": "⚠︎ Interrupted",
|
|
886
1069
|
"status.interrupted": true,
|
|
887
1070
|
},
|
|
@@ -960,6 +1143,19 @@ exports[`otel > otel 4`] = `
|
|
|
960
1143
|
"sql.query": "INSERT INTO 'todos' ("id", "text", "completed") VALUES (?, ?, ?)",
|
|
961
1144
|
},
|
|
962
1145
|
},
|
|
1146
|
+
{
|
|
1147
|
+
"_name": "@livestore/common:execSql",
|
|
1148
|
+
"attributes": {
|
|
1149
|
+
"bindValueKeys": "[
|
|
1150
|
+
"$id",
|
|
1151
|
+
"$seqNumGlobal",
|
|
1152
|
+
"$seqNumClient",
|
|
1153
|
+
"$seqNumRebaseGeneration"
|
|
1154
|
+
]",
|
|
1155
|
+
"span.label": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
1156
|
+
"sql": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
1157
|
+
},
|
|
1158
|
+
},
|
|
963
1159
|
],
|
|
964
1160
|
},
|
|
965
1161
|
],
|
|
@@ -1178,16 +1374,17 @@ exports[`otel > with thunks 7`] = `
|
|
|
1178
1374
|
"_name": "client-session-sync-processor:boot",
|
|
1179
1375
|
"children": [
|
|
1180
1376
|
{
|
|
1181
|
-
"_name": "
|
|
1377
|
+
"_name": "client-session-sync-processor:pull",
|
|
1182
1378
|
"attributes": {
|
|
1183
|
-
"
|
|
1184
|
-
"
|
|
1379
|
+
"span.label": "⚠︎ Interrupted",
|
|
1380
|
+
"status.interrupted": true,
|
|
1185
1381
|
},
|
|
1186
1382
|
},
|
|
1187
1383
|
{
|
|
1188
|
-
"_name": "
|
|
1384
|
+
"_name": "@livestore/common:LeaderSyncProcessor:push",
|
|
1189
1385
|
"attributes": {
|
|
1190
|
-
"
|
|
1386
|
+
"batch": "undefined",
|
|
1387
|
+
"batchSize": 1,
|
|
1191
1388
|
"span.label": "⚠︎ Interrupted",
|
|
1192
1389
|
"status.interrupted": true,
|
|
1193
1390
|
},
|
|
@@ -1272,6 +1469,19 @@ exports[`otel > with thunks 8`] = `
|
|
|
1272
1469
|
"sql.query": "INSERT INTO 'todos' ("id", "text", "completed") VALUES (?, ?, ?)",
|
|
1273
1470
|
},
|
|
1274
1471
|
},
|
|
1472
|
+
{
|
|
1473
|
+
"_name": "@livestore/common:execSql",
|
|
1474
|
+
"attributes": {
|
|
1475
|
+
"bindValueKeys": "[
|
|
1476
|
+
"$id",
|
|
1477
|
+
"$seqNumGlobal",
|
|
1478
|
+
"$seqNumClient",
|
|
1479
|
+
"$seqNumRebaseGeneration"
|
|
1480
|
+
]",
|
|
1481
|
+
"span.label": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
1482
|
+
"sql": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
1483
|
+
},
|
|
1484
|
+
},
|
|
1275
1485
|
],
|
|
1276
1486
|
},
|
|
1277
1487
|
],
|
|
@@ -1318,16 +1528,17 @@ exports[`otel > with thunks with query builder and without labels 3`] = `
|
|
|
1318
1528
|
"_name": "client-session-sync-processor:boot",
|
|
1319
1529
|
"children": [
|
|
1320
1530
|
{
|
|
1321
|
-
"_name": "
|
|
1531
|
+
"_name": "client-session-sync-processor:pull",
|
|
1322
1532
|
"attributes": {
|
|
1323
|
-
"
|
|
1324
|
-
"
|
|
1533
|
+
"span.label": "⚠︎ Interrupted",
|
|
1534
|
+
"status.interrupted": true,
|
|
1325
1535
|
},
|
|
1326
1536
|
},
|
|
1327
1537
|
{
|
|
1328
|
-
"_name": "
|
|
1538
|
+
"_name": "@livestore/common:LeaderSyncProcessor:push",
|
|
1329
1539
|
"attributes": {
|
|
1330
|
-
"
|
|
1540
|
+
"batch": "undefined",
|
|
1541
|
+
"batchSize": 1,
|
|
1331
1542
|
"span.label": "⚠︎ Interrupted",
|
|
1332
1543
|
"status.interrupted": true,
|
|
1333
1544
|
},
|
|
@@ -1412,6 +1623,19 @@ exports[`otel > with thunks with query builder and without labels 4`] = `
|
|
|
1412
1623
|
"sql.query": "INSERT INTO 'todos' ("id", "text", "completed") VALUES (?, ?, ?)",
|
|
1413
1624
|
},
|
|
1414
1625
|
},
|
|
1626
|
+
{
|
|
1627
|
+
"_name": "@livestore/common:execSql",
|
|
1628
|
+
"attributes": {
|
|
1629
|
+
"bindValueKeys": "[
|
|
1630
|
+
"$id",
|
|
1631
|
+
"$seqNumGlobal",
|
|
1632
|
+
"$seqNumClient",
|
|
1633
|
+
"$seqNumRebaseGeneration"
|
|
1634
|
+
]",
|
|
1635
|
+
"span.label": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
1636
|
+
"sql": "INSERT OR REPLACE INTO __livestore_state_head (id, seqNumGlobal, seqNumClient, seqNumRebaseGeneration) VALUES ($id, $seqNumGlobal, $seqNumClient, $seqNumRebaseGeneration)",
|
|
1637
|
+
},
|
|
1638
|
+
},
|
|
1415
1639
|
],
|
|
1416
1640
|
},
|
|
1417
1641
|
],
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type * as otel from '@opentelemetry/api'
|
|
2
2
|
|
|
3
|
-
import { isNotNil } from '@livestore/utils'
|
|
4
3
|
import { Equal, Hash, Predicate } from '@livestore/utils/effect'
|
|
5
4
|
|
|
6
5
|
import * as RG from '../reactive.ts'
|
|
@@ -54,7 +53,7 @@ export interface SignalDef<T> extends LiveQueryDef<T, 'signal-def'> {
|
|
|
54
53
|
label: string
|
|
55
54
|
/** Creates a reference-counted signal instance bound to a Store's reactivity graph */
|
|
56
55
|
make: (ctx: ReactivityGraphContext) => RcRef<ISignal<T>>
|
|
57
|
-
[Equal.symbol](that:
|
|
56
|
+
[Equal.symbol](that: Equal.Equal): boolean
|
|
58
57
|
[Hash.symbol](): number
|
|
59
58
|
}
|
|
60
59
|
|
|
@@ -122,7 +121,7 @@ export const depsToString = (deps: DepKey): string => {
|
|
|
122
121
|
if (typeof deps === 'string' || typeof deps === 'number') {
|
|
123
122
|
return deps.toString()
|
|
124
123
|
}
|
|
125
|
-
return deps.filter(
|
|
124
|
+
return deps.filter(Predicate.isNotNullish).join(',')
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
/**
|
|
@@ -146,7 +145,7 @@ export interface LiveQueryDef<TResult, TTag extends string = 'def'> {
|
|
|
146
145
|
label: string
|
|
147
146
|
/** Unique identifier derived from the query string or explicit deps; used for caching */
|
|
148
147
|
hash: string
|
|
149
|
-
[Equal.symbol](that:
|
|
148
|
+
[Equal.symbol](that: Equal.Equal): boolean
|
|
150
149
|
[Hash.symbol](): number
|
|
151
150
|
}
|
|
152
151
|
|
|
@@ -154,6 +153,39 @@ export namespace LiveQueryDef {
|
|
|
154
153
|
export type Any = LiveQueryDef<any, 'def' | 'signal-def'>
|
|
155
154
|
}
|
|
156
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Type guard that checks if a value is a query or signal definition.
|
|
158
|
+
*
|
|
159
|
+
* Use this to distinguish between definitions (blueprints) and instances (live queries).
|
|
160
|
+
* Definitions are created by `queryDb()`, `computed()`, and `signal()`.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* const todos$ = queryDb(tables.todos.all())
|
|
165
|
+
*
|
|
166
|
+
* if (isLiveQueryDef(todos$)) {
|
|
167
|
+
* console.log('This is a definition:', todos$.label)
|
|
168
|
+
* }
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export const isLiveQueryDef = (value: unknown): value is LiveQueryDef<any> | SignalDef<any> => {
|
|
172
|
+
if (Predicate.isTagged(value, 'def') === false && Predicate.isTagged(value, 'signal-def') === false) {
|
|
173
|
+
return false
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
Predicate.hasProperty(value, 'make') &&
|
|
178
|
+
Predicate.isFunction(value.make) &&
|
|
179
|
+
Predicate.hasProperty(value, 'hash') &&
|
|
180
|
+
Predicate.isString(value.hash) &&
|
|
181
|
+
Predicate.hasProperty(value, 'label') &&
|
|
182
|
+
Predicate.isString(value.label)
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export const isSignalDef = (value: unknown): value is SignalDef<any> =>
|
|
187
|
+
isLiveQueryDef(value) && Predicate.isTagged(value, 'signal-def')
|
|
188
|
+
|
|
157
189
|
/**
|
|
158
190
|
* A live query instance bound to a specific Store.
|
|
159
191
|
*
|
|
@@ -273,8 +305,8 @@ export abstract class LiveStoreQueryBase<TResult> implements LiveQuery<TResult>
|
|
|
273
305
|
*/
|
|
274
306
|
export type GetAtomResult = <T>(
|
|
275
307
|
atom: RG.Atom<T, any, RefreshReason> | LiveQueryDef<T> | LiveQuery<T> | ISignal<T> | SignalDef<T>,
|
|
276
|
-
otelContext?: otel.Context
|
|
277
|
-
debugRefreshReason?: RefreshReason
|
|
308
|
+
otelContext?: otel.Context,
|
|
309
|
+
debugRefreshReason?: RefreshReason,
|
|
278
310
|
) => T
|
|
279
311
|
|
|
280
312
|
export type DependencyQueriesRef = Set<RcRef<LiveQuery.Any | ISignal<any>>>
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as otel from '@opentelemetry/api'
|
|
2
2
|
|
|
3
|
-
import { getDurationMsFromSpan } from '@livestore/common'
|
|
4
3
|
import { Equal, Hash } from '@livestore/utils/effect'
|
|
5
4
|
|
|
6
5
|
import type { Thunk } from '../reactive.ts'
|
|
7
6
|
import type { RefreshReason } from '../store/store-types.ts'
|
|
8
7
|
import { isValidFunctionString } from '../utils/function-string.ts'
|
|
9
8
|
import type { DepKey, GetAtomResult, LiveQueryDef, ReactivityGraph, ReactivityGraphContext } from './base-class.ts'
|
|
10
|
-
import { depsToString, LiveStoreQueryBase, makeGetAtomResult, withRCMap } from './base-class.ts'
|
|
9
|
+
import { depsToString, isLiveQueryDef, LiveStoreQueryBase, makeGetAtomResult, withRCMap } from './base-class.ts'
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Creates a derived query that computes a value from other queries or signals.
|
|
@@ -86,8 +85,8 @@ export const computed = <TResult>(
|
|
|
86
85
|
// TODO we should figure out whether this could cause some problems and/or if there's a better way to do this
|
|
87
86
|
// NOTE `fn.toString()` doesn't work in Expo as it always produces `[native code]`
|
|
88
87
|
hash,
|
|
89
|
-
[Equal.symbol](that:
|
|
90
|
-
return this.hash === that.hash
|
|
88
|
+
[Equal.symbol](that: Equal.Equal): boolean {
|
|
89
|
+
return isLiveQueryDef(that) && that._tag === 'def' && this.hash === that.hash
|
|
91
90
|
},
|
|
92
91
|
[Hash.symbol](): number {
|
|
93
92
|
return Hash.string(this.hash)
|
|
@@ -137,12 +136,13 @@ export class LiveStoreComputedQuery<TResult> extends LiveStoreQueryBase<TResult>
|
|
|
137
136
|
this.results$ = this.reactivityGraph.makeThunk(
|
|
138
137
|
(get, setDebugInfo, ctx, otelContext) =>
|
|
139
138
|
ctx.otelTracer.startActiveSpan(`js:${label}`, {}, otelContext ?? ctx.rootOtelContext, (span) => {
|
|
139
|
+
const startTimePerfNow = performance.now()
|
|
140
140
|
const otelContext = otel.trace.setSpan(otel.context.active(), span)
|
|
141
141
|
const res = fn(makeGetAtomResult(get, ctx, otelContext, this.dependencyQueriesRef))
|
|
142
142
|
|
|
143
143
|
span.end()
|
|
144
144
|
|
|
145
|
-
const durationMs =
|
|
145
|
+
const durationMs = performance.now() - startTimePerfNow
|
|
146
146
|
|
|
147
147
|
this.executionTimes.push(durationMs)
|
|
148
148
|
|