@livestore/livestore 0.0.0-snapshot-c70175cc471a448781cfe8f01001b0034e29a384 → 0.0.0-snapshot-057a9e3a18ca69a310d4eb8cf35a34e94fa1841e
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/QueryCache.js +1 -1
- package/dist/QueryCache.js.map +1 -1
- package/dist/SqliteDbWrapper.d.ts +3 -2
- package/dist/SqliteDbWrapper.d.ts.map +1 -1
- package/dist/SqliteDbWrapper.js +8 -5
- package/dist/SqliteDbWrapper.js.map +1 -1
- package/dist/effect/LiveStore.js +1 -1
- package/dist/effect/LiveStore.js.map +1 -1
- package/dist/effect/mod.d.ts +2 -2
- package/dist/effect/mod.d.ts.map +1 -1
- package/dist/effect/mod.js +2 -2
- package/dist/effect/mod.js.map +1 -1
- package/dist/live-queries/base-class.d.ts.map +1 -1
- package/dist/live-queries/base-class.js.map +1 -1
- package/dist/live-queries/db-query.test.js +7 -3
- package/dist/live-queries/db-query.test.js.map +1 -1
- package/dist/mod.d.ts +9 -9
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +8 -8
- package/dist/mod.js.map +1 -1
- package/dist/reactive.d.ts.map +1 -1
- package/dist/reactive.js +1 -2
- package/dist/reactive.js.map +1 -1
- package/dist/store/store.d.ts +4 -3
- package/dist/store/store.d.ts.map +1 -1
- package/dist/store/store.js +8 -6
- package/dist/store/store.js.map +1 -1
- package/dist/utils/dev.d.ts.map +1 -1
- package/dist/utils/dev.js +0 -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 +5 -1
- package/dist/utils/stack-info.js.map +1 -1
- package/dist/utils/stack-info.test.js +6 -2
- package/dist/utils/stack-info.test.js.map +1 -1
- package/dist/utils/tests/mod.d.ts +1 -1
- package/dist/utils/tests/mod.d.ts.map +1 -1
- package/dist/utils/tests/mod.js +1 -1
- package/dist/utils/tests/mod.js.map +1 -1
- package/dist/utils/tests/otel.d.ts.map +1 -1
- package/dist/utils/tests/otel.js +1 -1
- package/dist/utils/tests/otel.js.map +1 -1
- package/package.json +7 -7
- package/src/QueryCache.ts +1 -1
- package/src/SqliteDbWrapper.ts +12 -11
- package/src/ambient.d.ts +0 -2
- package/src/effect/LiveStore.ts +1 -1
- package/src/effect/mod.ts +3 -3
- package/src/live-queries/__snapshots__/db-query.test.ts.snap +0 -42
- package/src/live-queries/base-class.ts +7 -6
- package/src/live-queries/db-query.test.ts +9 -3
- package/src/mod.ts +32 -38
- package/src/reactive.ts +1 -3
- package/src/store/store.ts +13 -11
- package/src/utils/dev.ts +0 -1
- package/src/utils/stack-info.test.ts +6 -2
- package/src/utils/stack-info.ts +5 -1
- package/src/utils/tests/mod.ts +1 -1
- package/src/utils/tests/otel.ts +2 -1
package/src/store/store.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type Bindable,
|
|
2
3
|
type ClientSession,
|
|
3
4
|
type ClientSessionSyncProcessor,
|
|
4
|
-
type ParamsObject,
|
|
5
|
-
type PreparedBindValues,
|
|
6
|
-
type QueryBuilder,
|
|
7
|
-
UnexpectedError,
|
|
8
|
-
} from '@livestore/common'
|
|
9
|
-
import {
|
|
10
5
|
Devtools,
|
|
11
6
|
getDurationMsFromSpan,
|
|
12
7
|
getExecStatementsFromMaterializer,
|
|
@@ -16,9 +11,12 @@ import {
|
|
|
16
11
|
isQueryBuilder,
|
|
17
12
|
liveStoreVersion,
|
|
18
13
|
makeClientSessionSyncProcessor,
|
|
14
|
+
type PreparedBindValues,
|
|
19
15
|
prepareBindValues,
|
|
16
|
+
type QueryBuilder,
|
|
20
17
|
QueryBuilderAstSymbol,
|
|
21
18
|
replaceSessionIdSymbol,
|
|
19
|
+
UnexpectedError,
|
|
22
20
|
} from '@livestore/common'
|
|
23
21
|
import type { LiveStoreSchema } from '@livestore/common/schema'
|
|
24
22
|
import { getEventDef, LiveStoreEvent, SystemTables } from '@livestore/common/schema'
|
|
@@ -164,6 +162,8 @@ export class Store<TSchema extends LiveStoreSchema = LiveStoreSchema, TContext =
|
|
|
164
162
|
for (const table of writeTables) {
|
|
165
163
|
writeTablesForEvent.add(table)
|
|
166
164
|
}
|
|
165
|
+
|
|
166
|
+
this.sqliteDbWrapper.debug.head = eventDecoded.seqNum
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
@@ -413,13 +413,17 @@ export class Store<TSchema extends LiveStoreSchema = LiveStoreSchema, TContext =
|
|
|
413
413
|
| LiveQuery<TResult>
|
|
414
414
|
| LiveQueryDef<TResult>
|
|
415
415
|
| SignalDef<TResult>
|
|
416
|
-
| { query: string; bindValues:
|
|
416
|
+
| { query: string; bindValues: Bindable; schema?: Schema.Schema<TResult> },
|
|
417
417
|
options?: { otelContext?: otel.Context; debugRefreshReason?: RefreshReason },
|
|
418
418
|
): TResult => {
|
|
419
419
|
if (typeof query === 'object' && 'query' in query && 'bindValues' in query) {
|
|
420
|
-
|
|
420
|
+
const res = this.sqliteDbWrapper.cachedSelect(query.query, prepareBindValues(query.bindValues, query.query), {
|
|
421
421
|
otelContext: options?.otelContext,
|
|
422
422
|
}) as any
|
|
423
|
+
if (query.schema) {
|
|
424
|
+
return Schema.decodeSync(query.schema)(res)
|
|
425
|
+
}
|
|
426
|
+
return res
|
|
423
427
|
} else if (isQueryBuilder(query)) {
|
|
424
428
|
const ast = query[QueryBuilderAstSymbol]
|
|
425
429
|
if (ast._tag === 'RowQuery') {
|
|
@@ -589,9 +593,7 @@ export class Store<TSchema extends LiveStoreSchema = LiveStoreSchema, TContext =
|
|
|
589
593
|
// Materialize events to state
|
|
590
594
|
const { writeTables } = (() => {
|
|
591
595
|
try {
|
|
592
|
-
const materializeEvents = () => {
|
|
593
|
-
return Runtime.runSync(this.effectContext.runtime, this.syncProcessor.push(events, { otelContext }))
|
|
594
|
-
}
|
|
596
|
+
const materializeEvents = () => this.syncProcessor.push(events, { otelContext })
|
|
595
597
|
|
|
596
598
|
if (events.length > 1) {
|
|
597
599
|
return this.sqliteDbWrapper.txn(materializeEvents)
|
package/src/utils/dev.ts
CHANGED
|
@@ -19,7 +19,9 @@ Error
|
|
|
19
19
|
|
|
20
20
|
const stackInfo = extractStackInfoFromStackTrace(stackTrace)
|
|
21
21
|
// Replacing file paths for snapshot testing as they are not stable
|
|
22
|
-
stackInfo.frames.forEach((_) =>
|
|
22
|
+
stackInfo.frames.forEach((_) => {
|
|
23
|
+
_.filePath = '__REPLACED_FOR_SNAPSHOT__'
|
|
24
|
+
})
|
|
23
25
|
expect(stackInfo).toMatchInlineSnapshot(`
|
|
24
26
|
{
|
|
25
27
|
"frames": [
|
|
@@ -61,7 +63,9 @@ Error
|
|
|
61
63
|
|
|
62
64
|
const stackInfo = extractStackInfoFromStackTrace(stackTrace)
|
|
63
65
|
// Replacing file paths for snapshot testing as they are not stable
|
|
64
|
-
stackInfo.frames.forEach((_) =>
|
|
66
|
+
stackInfo.frames.forEach((_) => {
|
|
67
|
+
_.filePath = '__REPLACED_FOR_SNAPSHOT__'
|
|
68
|
+
})
|
|
65
69
|
expect(stackInfo).toMatchInlineSnapshot(`
|
|
66
70
|
{
|
|
67
71
|
"frames": [
|
package/src/utils/stack-info.ts
CHANGED
|
@@ -32,7 +32,11 @@ export const extractStackInfoFromStackTrace = (stackTrace: string): StackInfo =>
|
|
|
32
32
|
const frames: StackFrame[] = []
|
|
33
33
|
let hasReachedStart = false
|
|
34
34
|
|
|
35
|
-
while (
|
|
35
|
+
while (true) {
|
|
36
|
+
match = namePattern.exec(stackTrace)
|
|
37
|
+
if (match === null) {
|
|
38
|
+
break
|
|
39
|
+
}
|
|
36
40
|
const [, name, filePath] = match as any as [string, string, string]
|
|
37
41
|
// console.debug(name, filePath)
|
|
38
42
|
|
package/src/utils/tests/mod.ts
CHANGED
package/src/utils/tests/otel.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { identity } from '@livestore/utils/effect'
|
|
2
2
|
import type { Attributes } from '@opentelemetry/api'
|
|
3
3
|
import type { InMemorySpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base'
|
|
4
|
+
|
|
4
5
|
type SimplifiedNestedSpan = { _name: string; attributes: any; children: SimplifiedNestedSpan[] }
|
|
5
6
|
|
|
6
7
|
export const getSimplifiedRootSpan = (
|
|
@@ -24,7 +25,7 @@ export const getSimplifiedRootSpan = (
|
|
|
24
25
|
const createStoreSpanData = spans.find((_) => _.name === 'createStore')
|
|
25
26
|
if (createStoreSpanData === undefined) {
|
|
26
27
|
throw new Error(
|
|
27
|
-
|
|
28
|
+
`Could not find the root span named 'createStore'. Available spans: ${spans.map((s) => s.name).join(', ')}`,
|
|
28
29
|
)
|
|
29
30
|
}
|
|
30
31
|
const rootSpan = spansMap.get(createStoreSpanData.spanContext().spanId)!
|