@livestore/react 0.4.0-dev.2 → 0.4.0-dev.20
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/LiveStoreProvider.d.ts +6 -7
- package/dist/LiveStoreProvider.d.ts.map +1 -1
- package/dist/LiveStoreProvider.js +39 -24
- package/dist/LiveStoreProvider.js.map +1 -1
- package/dist/LiveStoreProvider.test.js +7 -7
- package/dist/LiveStoreProvider.test.js.map +1 -1
- package/dist/__tests__/fixture.d.ts +34 -12
- package/dist/__tests__/fixture.d.ts.map +1 -1
- package/dist/__tests__/fixture.js +13 -5
- package/dist/__tests__/fixture.js.map +1 -1
- package/dist/experimental/components/LiveList.js +1 -1
- package/dist/experimental/mod.d.ts +1 -0
- package/dist/experimental/mod.d.ts.map +1 -1
- package/dist/experimental/mod.js +1 -0
- package/dist/experimental/mod.js.map +1 -1
- package/dist/experimental/multi-store/StoreRegistry.d.ts +61 -0
- package/dist/experimental/multi-store/StoreRegistry.d.ts.map +1 -0
- package/dist/experimental/multi-store/StoreRegistry.js +275 -0
- package/dist/experimental/multi-store/StoreRegistry.js.map +1 -0
- package/dist/experimental/multi-store/StoreRegistry.test.d.ts +2 -0
- package/dist/experimental/multi-store/StoreRegistry.test.d.ts.map +1 -0
- package/dist/experimental/multi-store/StoreRegistry.test.js +464 -0
- package/dist/experimental/multi-store/StoreRegistry.test.js.map +1 -0
- package/dist/experimental/multi-store/StoreRegistryContext.d.ts +10 -0
- package/dist/experimental/multi-store/StoreRegistryContext.d.ts.map +1 -0
- package/dist/experimental/multi-store/StoreRegistryContext.js +15 -0
- package/dist/experimental/multi-store/StoreRegistryContext.js.map +1 -0
- package/dist/experimental/multi-store/mod.d.ts +6 -0
- package/dist/experimental/multi-store/mod.d.ts.map +1 -0
- package/dist/experimental/multi-store/mod.js +6 -0
- package/dist/experimental/multi-store/mod.js.map +1 -0
- package/dist/experimental/multi-store/storeOptions.d.ts +4 -0
- package/dist/experimental/multi-store/storeOptions.d.ts.map +1 -0
- package/dist/experimental/multi-store/storeOptions.js +4 -0
- package/dist/experimental/multi-store/storeOptions.js.map +1 -0
- package/dist/experimental/multi-store/types.d.ts +44 -0
- package/dist/experimental/multi-store/types.d.ts.map +1 -0
- package/dist/experimental/multi-store/types.js +2 -0
- package/dist/experimental/multi-store/types.js.map +1 -0
- package/dist/experimental/multi-store/useStore.d.ts +11 -0
- package/dist/experimental/multi-store/useStore.d.ts.map +1 -0
- package/dist/experimental/multi-store/useStore.js +21 -0
- package/dist/experimental/multi-store/useStore.js.map +1 -0
- package/dist/experimental/multi-store/useStore.test.d.ts +2 -0
- package/dist/experimental/multi-store/useStore.test.d.ts.map +1 -0
- package/dist/experimental/multi-store/useStore.test.js +144 -0
- package/dist/experimental/multi-store/useStore.test.js.map +1 -0
- package/dist/mod.d.ts +1 -1
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js.map +1 -1
- package/dist/useClientDocument.d.ts +10 -13
- package/dist/useClientDocument.d.ts.map +1 -1
- package/dist/useClientDocument.js +4 -5
- package/dist/useClientDocument.js.map +1 -1
- package/dist/useClientDocument.test.js +29 -7
- package/dist/useClientDocument.test.js.map +1 -1
- package/dist/useQuery.d.ts +28 -6
- package/dist/useQuery.d.ts.map +1 -1
- package/dist/useQuery.js +63 -18
- package/dist/useQuery.js.map +1 -1
- package/dist/useQuery.test.js +35 -11
- package/dist/useQuery.test.js.map +1 -1
- package/dist/useRcResource.test.js +1 -1
- package/dist/useStore.d.ts +2 -1
- package/dist/useStore.d.ts.map +1 -1
- package/dist/useStore.js +1 -1
- package/dist/useStore.js.map +1 -1
- package/package.json +14 -14
- package/src/LiveStoreProvider.test.tsx +7 -7
- package/src/LiveStoreProvider.tsx +58 -45
- package/src/__snapshots__/useClientDocument.test.tsx.snap +208 -100
- package/src/__snapshots__/useQuery.test.tsx.snap +400 -128
- package/src/__tests__/fixture.tsx +23 -24
- package/src/experimental/components/LiveList.tsx +1 -1
- package/src/experimental/mod.ts +1 -0
- package/src/experimental/multi-store/StoreRegistry.test.ts +631 -0
- package/src/experimental/multi-store/StoreRegistry.ts +347 -0
- package/src/experimental/multi-store/StoreRegistryContext.tsx +23 -0
- package/src/experimental/multi-store/mod.ts +5 -0
- package/src/experimental/multi-store/storeOptions.ts +8 -0
- package/src/experimental/multi-store/types.ts +55 -0
- package/src/experimental/multi-store/useStore.test.tsx +197 -0
- package/src/experimental/multi-store/useStore.ts +34 -0
- package/src/mod.ts +2 -1
- package/src/useClientDocument.test.tsx +105 -75
- package/src/useClientDocument.ts +23 -13
- package/src/useQuery.test.tsx +62 -11
- package/src/useQuery.ts +98 -27
- package/src/useRcResource.test.tsx +1 -1
- package/src/useStore.ts +4 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Adapter, BootStatus, IntentionalShutdownCause, MigrationsReport, SyncError } from '@livestore/common'
|
|
2
|
-
import { provideOtel,
|
|
2
|
+
import { LogConfig, provideOtel, UnknownError } from '@livestore/common'
|
|
3
3
|
import type { LiveStoreSchema } from '@livestore/common/schema'
|
|
4
4
|
import type {
|
|
5
5
|
CreateStoreOptions,
|
|
@@ -9,26 +9,16 @@ import type {
|
|
|
9
9
|
LiveStoreContext as StoreContext_,
|
|
10
10
|
} from '@livestore/livestore'
|
|
11
11
|
import { createStore, makeShutdownDeferred, StoreInterrupted } from '@livestore/livestore'
|
|
12
|
-
import { errorToString, IS_REACT_NATIVE, LS_DEV } from '@livestore/utils'
|
|
12
|
+
import { errorToString, IS_REACT_NATIVE, LS_DEV, omitUndefineds } from '@livestore/utils'
|
|
13
13
|
import type { OtelTracer } from '@livestore/utils/effect'
|
|
14
|
-
import {
|
|
15
|
-
Cause,
|
|
16
|
-
Deferred,
|
|
17
|
-
Effect,
|
|
18
|
-
Exit,
|
|
19
|
-
identity,
|
|
20
|
-
Logger,
|
|
21
|
-
LogLevel,
|
|
22
|
-
Schema,
|
|
23
|
-
Scope,
|
|
24
|
-
TaskTracing,
|
|
25
|
-
} from '@livestore/utils/effect'
|
|
14
|
+
import { Cause, Deferred, Effect, Exit, identity, Schema, Scope, TaskTracing } from '@livestore/utils/effect'
|
|
26
15
|
import type * as otel from '@opentelemetry/api'
|
|
27
16
|
import React from 'react'
|
|
28
17
|
|
|
29
18
|
import { LiveStoreContext } from './LiveStoreContext.ts'
|
|
30
19
|
|
|
31
|
-
export interface LiveStoreProviderProps
|
|
20
|
+
export interface LiveStoreProviderProps<TSyncPayloadSchema extends Schema.Schema<any> = typeof Schema.JsonValue>
|
|
21
|
+
extends LogConfig.WithLoggerOptions {
|
|
32
22
|
schema: LiveStoreSchema
|
|
33
23
|
/**
|
|
34
24
|
* The `storeId` can be used to isolate multiple stores from each other.
|
|
@@ -47,7 +37,7 @@ export interface LiveStoreProviderProps {
|
|
|
47
37
|
) => void | Promise<void> | Effect.Effect<void, unknown, OtelTracer.OtelTracer>
|
|
48
38
|
otelOptions?: Partial<OtelOptions>
|
|
49
39
|
renderLoading?: (status: BootStatus) => React.ReactNode
|
|
50
|
-
renderError?: (error:
|
|
40
|
+
renderError?: (error: UnknownError | unknown) => React.ReactNode
|
|
51
41
|
renderShutdown?: (cause: IntentionalShutdownCause | StoreInterrupted | SyncError) => React.ReactNode
|
|
52
42
|
adapter: Adapter
|
|
53
43
|
/**
|
|
@@ -77,20 +67,21 @@ export interface LiveStoreProviderProps {
|
|
|
77
67
|
*
|
|
78
68
|
* @default undefined
|
|
79
69
|
*/
|
|
80
|
-
|
|
70
|
+
syncPayloadSchema?: TSyncPayloadSchema
|
|
71
|
+
syncPayload?: Schema.Schema.Type<TSyncPayloadSchema>
|
|
81
72
|
debug?: {
|
|
82
73
|
instanceId?: string
|
|
83
74
|
}
|
|
84
75
|
}
|
|
85
76
|
|
|
86
|
-
const defaultRenderError = (error:
|
|
87
|
-
IS_REACT_NATIVE ? null : Schema.is(
|
|
77
|
+
const defaultRenderError = (error: UnknownError | unknown) =>
|
|
78
|
+
IS_REACT_NATIVE ? null : Schema.is(UnknownError)(error) ? error.toString() : errorToString(error)
|
|
88
79
|
|
|
89
80
|
const defaultRenderShutdown = (cause: IntentionalShutdownCause | StoreInterrupted | SyncError) => {
|
|
90
81
|
const reason =
|
|
91
82
|
cause._tag === 'LiveStore.StoreInterrupted'
|
|
92
83
|
? `interrupted due to: ${cause.reason}`
|
|
93
|
-
: cause._tag === '
|
|
84
|
+
: cause._tag === 'InvalidPushError' || cause._tag === 'InvalidPullError'
|
|
94
85
|
? `sync error: ${cause.cause}`
|
|
95
86
|
: cause.reason === 'devtools-import'
|
|
96
87
|
? 'devtools import'
|
|
@@ -108,7 +99,7 @@ const defaultRenderShutdown = (cause: IntentionalShutdownCause | StoreInterrupte
|
|
|
108
99
|
const defaultRenderLoading = (status: BootStatus) =>
|
|
109
100
|
IS_REACT_NATIVE ? null : <>LiveStore is loading ({status.stage})...</>
|
|
110
101
|
|
|
111
|
-
export const LiveStoreProvider = ({
|
|
102
|
+
export const LiveStoreProvider = <TSyncPayloadSchema extends Schema.Schema<any> = typeof Schema.JsonValue>({
|
|
112
103
|
renderLoading = defaultRenderLoading,
|
|
113
104
|
renderError = defaultRenderError,
|
|
114
105
|
renderShutdown = defaultRenderShutdown,
|
|
@@ -123,20 +114,28 @@ export const LiveStoreProvider = ({
|
|
|
123
114
|
signal,
|
|
124
115
|
confirmUnsavedChanges = true,
|
|
125
116
|
syncPayload,
|
|
117
|
+
syncPayloadSchema,
|
|
126
118
|
debug,
|
|
127
|
-
|
|
119
|
+
logger,
|
|
120
|
+
logLevel,
|
|
121
|
+
}: LiveStoreProviderProps<TSyncPayloadSchema> & React.PropsWithChildren): React.ReactNode => {
|
|
128
122
|
const storeCtx = useCreateStore({
|
|
129
123
|
storeId,
|
|
130
124
|
schema,
|
|
131
|
-
otelOptions,
|
|
132
|
-
boot,
|
|
133
125
|
adapter,
|
|
134
126
|
batchUpdates,
|
|
135
|
-
disableDevtools,
|
|
136
|
-
signal,
|
|
137
127
|
confirmUnsavedChanges,
|
|
138
|
-
|
|
139
|
-
|
|
128
|
+
...omitUndefineds({
|
|
129
|
+
otelOptions,
|
|
130
|
+
boot,
|
|
131
|
+
disableDevtools,
|
|
132
|
+
signal,
|
|
133
|
+
syncPayload,
|
|
134
|
+
syncPayloadSchema,
|
|
135
|
+
debug,
|
|
136
|
+
}),
|
|
137
|
+
logger,
|
|
138
|
+
logLevel,
|
|
140
139
|
})
|
|
141
140
|
|
|
142
141
|
if (storeCtx.stage === 'error') {
|
|
@@ -173,11 +172,15 @@ const useCreateStore = ({
|
|
|
173
172
|
params,
|
|
174
173
|
confirmUnsavedChanges,
|
|
175
174
|
syncPayload,
|
|
175
|
+
syncPayloadSchema,
|
|
176
176
|
debug,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
logger,
|
|
178
|
+
logLevel,
|
|
179
|
+
}: CreateStoreOptions<LiveStoreSchema> &
|
|
180
|
+
LogConfig.WithLoggerOptions & {
|
|
181
|
+
signal?: AbortSignal
|
|
182
|
+
otelOptions?: Partial<OtelOptions>
|
|
183
|
+
}) => {
|
|
181
184
|
const [_, rerender] = React.useState(0)
|
|
182
185
|
const ctxValueRef = React.useRef<{
|
|
183
186
|
value: StoreContext_ | BootStatus
|
|
@@ -209,6 +212,7 @@ const useCreateStore = ({
|
|
|
209
212
|
params,
|
|
210
213
|
confirmUnsavedChanges,
|
|
211
214
|
syncPayload,
|
|
215
|
+
syncPayloadSchema,
|
|
212
216
|
debugInstanceId,
|
|
213
217
|
})
|
|
214
218
|
|
|
@@ -237,6 +241,7 @@ const useCreateStore = ({
|
|
|
237
241
|
params: inputPropsCacheRef.current.params !== params,
|
|
238
242
|
confirmUnsavedChanges: inputPropsCacheRef.current.confirmUnsavedChanges !== confirmUnsavedChanges,
|
|
239
243
|
syncPayload: inputPropsCacheRef.current.syncPayload !== syncPayload,
|
|
244
|
+
syncPayloadSchema: inputPropsCacheRef.current.syncPayloadSchema !== syncPayloadSchema,
|
|
240
245
|
debugInstanceId: inputPropsCacheRef.current.debugInstanceId !== debugInstanceId,
|
|
241
246
|
}
|
|
242
247
|
|
|
@@ -251,7 +256,8 @@ const useCreateStore = ({
|
|
|
251
256
|
inputPropChanges.context ||
|
|
252
257
|
inputPropChanges.params ||
|
|
253
258
|
inputPropChanges.confirmUnsavedChanges ||
|
|
254
|
-
inputPropChanges.syncPayload
|
|
259
|
+
inputPropChanges.syncPayload ||
|
|
260
|
+
inputPropChanges.syncPayloadSchema
|
|
255
261
|
) {
|
|
256
262
|
inputPropsCacheRef.current = {
|
|
257
263
|
schema,
|
|
@@ -265,6 +271,7 @@ const useCreateStore = ({
|
|
|
265
271
|
params,
|
|
266
272
|
confirmUnsavedChanges,
|
|
267
273
|
syncPayload,
|
|
274
|
+
syncPayloadSchema,
|
|
268
275
|
debugInstanceId,
|
|
269
276
|
}
|
|
270
277
|
if (ctxValueRef.current.componentScope !== undefined && ctxValueRef.current.shutdownDeferred !== undefined) {
|
|
@@ -330,21 +337,24 @@ const useCreateStore = ({
|
|
|
330
337
|
const store = yield* createStore({
|
|
331
338
|
schema,
|
|
332
339
|
storeId,
|
|
333
|
-
boot,
|
|
334
340
|
adapter,
|
|
335
|
-
batchUpdates,
|
|
336
|
-
disableDevtools,
|
|
337
341
|
shutdownDeferred,
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
+
...omitUndefineds({
|
|
343
|
+
boot,
|
|
344
|
+
batchUpdates,
|
|
345
|
+
disableDevtools,
|
|
346
|
+
context,
|
|
347
|
+
params,
|
|
348
|
+
confirmUnsavedChanges,
|
|
349
|
+
syncPayload,
|
|
350
|
+
syncPayloadSchema,
|
|
351
|
+
}),
|
|
342
352
|
onBootStatus: (status) => {
|
|
343
353
|
if (ctxValueRef.current.value.stage === 'running' || ctxValueRef.current.value.stage === 'error') return
|
|
344
354
|
// NOTE sometimes when status come in in rapid succession, only the last value will be rendered by React
|
|
345
355
|
setContextValue(status)
|
|
346
356
|
},
|
|
347
|
-
debug: { instanceId: debugInstanceId },
|
|
357
|
+
debug: { ...omitUndefineds({ instanceId: debugInstanceId }) },
|
|
348
358
|
}).pipe(Effect.tapErrorCause((cause) => Deferred.failCause(shutdownDeferred, cause)))
|
|
349
359
|
|
|
350
360
|
setContextValue({ stage: 'running', store })
|
|
@@ -356,7 +366,8 @@ const useCreateStore = ({
|
|
|
356
366
|
yield* Deferred.await(shutdownDeferred).pipe(
|
|
357
367
|
Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/react] shutdown', Cause.pretty(cause))),
|
|
358
368
|
Effect.tap((intentionalShutdown) => shutdownContext(intentionalShutdown)),
|
|
359
|
-
Effect.catchTag('
|
|
369
|
+
Effect.catchTag('InvalidPushError', (cause) => shutdownContext(cause)),
|
|
370
|
+
Effect.catchTag('InvalidPullError', (cause) => shutdownContext(cause)),
|
|
360
371
|
Effect.catchTag('LiveStore.StoreInterrupted', (cause) => shutdownContext(cause)),
|
|
361
372
|
Effect.tapError((error) => Effect.sync(() => setContextValue({ stage: 'error', error }))),
|
|
362
373
|
Effect.tapDefect((defect) => Effect.sync(() => setContextValue({ stage: 'error', error: defect }))),
|
|
@@ -366,11 +377,10 @@ const useCreateStore = ({
|
|
|
366
377
|
Effect.scoped,
|
|
367
378
|
Effect.withSpan('@livestore/react:useCreateStore'),
|
|
368
379
|
LS_DEV ? TaskTracing.withAsyncTaggingTracing((name: string) => (console as any).createTask(name)) : identity,
|
|
369
|
-
provideOtel({ parentSpanContext: otelOptions?.rootSpanContext, otelTracer: otelOptions?.tracer }),
|
|
380
|
+
provideOtel(omitUndefineds({ parentSpanContext: otelOptions?.rootSpanContext, otelTracer: otelOptions?.tracer })),
|
|
370
381
|
Effect.tapCauseLogPretty,
|
|
371
382
|
Effect.annotateLogs({ thread: 'window' }),
|
|
372
|
-
|
|
373
|
-
Logger.withMinimumLogLevel(LogLevel.Debug),
|
|
383
|
+
LogConfig.withLoggerConfig({ logger, logLevel }, { threadName: 'window' }),
|
|
374
384
|
Effect.runCallback,
|
|
375
385
|
)
|
|
376
386
|
|
|
@@ -400,8 +410,11 @@ const useCreateStore = ({
|
|
|
400
410
|
params,
|
|
401
411
|
confirmUnsavedChanges,
|
|
402
412
|
syncPayload,
|
|
413
|
+
syncPayloadSchema,
|
|
403
414
|
debugInstanceId,
|
|
404
415
|
interrupt,
|
|
416
|
+
logger,
|
|
417
|
+
logLevel,
|
|
405
418
|
])
|
|
406
419
|
|
|
407
420
|
return ctxValueRef.current.value
|
|
@@ -47,29 +47,6 @@ exports[`useClientDocument > otel > should update the data based on component ke
|
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
"_name": "LiveStore:commits",
|
|
50
|
-
"children": [
|
|
51
|
-
{
|
|
52
|
-
"_name": "LiveStore:commit",
|
|
53
|
-
"attributes": {
|
|
54
|
-
"livestore.eventTags": [
|
|
55
|
-
"UserInfoSet",
|
|
56
|
-
],
|
|
57
|
-
"livestore.eventsCount": 1,
|
|
58
|
-
},
|
|
59
|
-
"children": [
|
|
60
|
-
{
|
|
61
|
-
"_name": "livestore.in-memory-db:execute",
|
|
62
|
-
"attributes": {
|
|
63
|
-
"sql.query": "
|
|
64
|
-
INSERT INTO 'UserInfo' (id, value)
|
|
65
|
-
VALUES (?, ?)
|
|
66
|
-
ON CONFLICT (id) DO UPDATE SET value = json_set(value, ?, json(?))
|
|
67
|
-
",
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
50
|
},
|
|
74
51
|
{
|
|
75
52
|
"_name": "LiveStore:queries",
|
|
@@ -89,28 +66,6 @@ exports[`useClientDocument > otel > should update the data based on component ke
|
|
|
89
66
|
"sql.rowsCount": 0,
|
|
90
67
|
},
|
|
91
68
|
},
|
|
92
|
-
{
|
|
93
|
-
"_name": "LiveStore:commit",
|
|
94
|
-
"attributes": {
|
|
95
|
-
"livestore.commitLabel": "UserInfo.set:u1",
|
|
96
|
-
"livestore.eventTags": [
|
|
97
|
-
"UserInfoSet",
|
|
98
|
-
],
|
|
99
|
-
"livestore.eventsCount": 1,
|
|
100
|
-
},
|
|
101
|
-
"children": [
|
|
102
|
-
{
|
|
103
|
-
"_name": "livestore.in-memory-db:execute",
|
|
104
|
-
"attributes": {
|
|
105
|
-
"sql.query": "
|
|
106
|
-
INSERT INTO 'UserInfo' (id, value)
|
|
107
|
-
VALUES (?, ?)
|
|
108
|
-
ON CONFLICT (id) DO UPDATE SET value = json_set(json_set(value, ?, json(?)), ?, json(?))
|
|
109
|
-
",
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
69
|
{
|
|
115
70
|
"_name": "db:SELECT * FROM 'UserInfo' WHERE id = ?",
|
|
116
71
|
"attributes": {
|
|
@@ -226,6 +181,88 @@ exports[`useClientDocument > otel > should update the data based on component ke
|
|
|
226
181
|
}
|
|
227
182
|
`;
|
|
228
183
|
|
|
184
|
+
exports[`useClientDocument > otel > should update the data based on component key strictMode={ strictMode: false } 2`] = `
|
|
185
|
+
[
|
|
186
|
+
{
|
|
187
|
+
"_name": "LiveStore:commit",
|
|
188
|
+
"attributes": {
|
|
189
|
+
"livestore.commitLabel": "UserInfo.set:u1",
|
|
190
|
+
"livestore.eventTags": "[
|
|
191
|
+
"UserInfoSet"
|
|
192
|
+
]",
|
|
193
|
+
"livestore.eventsCount": 1,
|
|
194
|
+
},
|
|
195
|
+
"children": [
|
|
196
|
+
{
|
|
197
|
+
"_name": "client-session-sync-processor:push",
|
|
198
|
+
"attributes": {
|
|
199
|
+
"batchSize": 1,
|
|
200
|
+
"eventCounts": "{
|
|
201
|
+
"UserInfoSet": 1
|
|
202
|
+
}",
|
|
203
|
+
"mergeResultTag": "advance",
|
|
204
|
+
},
|
|
205
|
+
"children": [
|
|
206
|
+
{
|
|
207
|
+
"_name": "client-session-sync-processor:materialize-event",
|
|
208
|
+
"children": [
|
|
209
|
+
{
|
|
210
|
+
"_name": "livestore.in-memory-db:execute",
|
|
211
|
+
"attributes": {
|
|
212
|
+
"sql.query": "
|
|
213
|
+
INSERT INTO 'UserInfo' (id, value)
|
|
214
|
+
VALUES (?, ?)
|
|
215
|
+
ON CONFLICT (id) DO UPDATE SET value = json_set(json_set(value, ?, json(?)), ?, json(?))
|
|
216
|
+
",
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"_name": "LiveStore:commit",
|
|
227
|
+
"attributes": {
|
|
228
|
+
"livestore.eventTags": "[
|
|
229
|
+
"UserInfoSet"
|
|
230
|
+
]",
|
|
231
|
+
"livestore.eventsCount": 1,
|
|
232
|
+
},
|
|
233
|
+
"children": [
|
|
234
|
+
{
|
|
235
|
+
"_name": "client-session-sync-processor:push",
|
|
236
|
+
"attributes": {
|
|
237
|
+
"batchSize": 1,
|
|
238
|
+
"eventCounts": "{
|
|
239
|
+
"UserInfoSet": 1
|
|
240
|
+
}",
|
|
241
|
+
"mergeResultTag": "advance",
|
|
242
|
+
},
|
|
243
|
+
"children": [
|
|
244
|
+
{
|
|
245
|
+
"_name": "client-session-sync-processor:materialize-event",
|
|
246
|
+
"children": [
|
|
247
|
+
{
|
|
248
|
+
"_name": "livestore.in-memory-db:execute",
|
|
249
|
+
"attributes": {
|
|
250
|
+
"sql.query": "
|
|
251
|
+
INSERT INTO 'UserInfo' (id, value)
|
|
252
|
+
VALUES (?, ?)
|
|
253
|
+
ON CONFLICT (id) DO UPDATE SET value = json_set(value, ?, json(?))
|
|
254
|
+
",
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
],
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
},
|
|
263
|
+
]
|
|
264
|
+
`;
|
|
265
|
+
|
|
229
266
|
exports[`useClientDocument > otel > should update the data based on component key strictMode={ strictMode: true } 1`] = `
|
|
230
267
|
{
|
|
231
268
|
"_name": "createStore",
|
|
@@ -273,29 +310,6 @@ exports[`useClientDocument > otel > should update the data based on component ke
|
|
|
273
310
|
},
|
|
274
311
|
{
|
|
275
312
|
"_name": "LiveStore:commits",
|
|
276
|
-
"children": [
|
|
277
|
-
{
|
|
278
|
-
"_name": "LiveStore:commit",
|
|
279
|
-
"attributes": {
|
|
280
|
-
"livestore.eventTags": [
|
|
281
|
-
"UserInfoSet",
|
|
282
|
-
],
|
|
283
|
-
"livestore.eventsCount": 1,
|
|
284
|
-
},
|
|
285
|
-
"children": [
|
|
286
|
-
{
|
|
287
|
-
"_name": "livestore.in-memory-db:execute",
|
|
288
|
-
"attributes": {
|
|
289
|
-
"sql.query": "
|
|
290
|
-
INSERT INTO 'UserInfo' (id, value)
|
|
291
|
-
VALUES (?, ?)
|
|
292
|
-
ON CONFLICT (id) DO UPDATE SET value = json_set(value, ?, json(?))
|
|
293
|
-
",
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
],
|
|
297
|
-
},
|
|
298
|
-
],
|
|
299
313
|
},
|
|
300
314
|
{
|
|
301
315
|
"_name": "LiveStore:queries",
|
|
@@ -315,28 +329,6 @@ exports[`useClientDocument > otel > should update the data based on component ke
|
|
|
315
329
|
"sql.rowsCount": 0,
|
|
316
330
|
},
|
|
317
331
|
},
|
|
318
|
-
{
|
|
319
|
-
"_name": "LiveStore:commit",
|
|
320
|
-
"attributes": {
|
|
321
|
-
"livestore.commitLabel": "UserInfo.set:u1",
|
|
322
|
-
"livestore.eventTags": [
|
|
323
|
-
"UserInfoSet",
|
|
324
|
-
],
|
|
325
|
-
"livestore.eventsCount": 1,
|
|
326
|
-
},
|
|
327
|
-
"children": [
|
|
328
|
-
{
|
|
329
|
-
"_name": "livestore.in-memory-db:execute",
|
|
330
|
-
"attributes": {
|
|
331
|
-
"sql.query": "
|
|
332
|
-
INSERT INTO 'UserInfo' (id, value)
|
|
333
|
-
VALUES (?, ?)
|
|
334
|
-
ON CONFLICT (id) DO UPDATE SET value = json_set(json_set(value, ?, json(?)), ?, json(?))
|
|
335
|
-
",
|
|
336
|
-
},
|
|
337
|
-
},
|
|
338
|
-
],
|
|
339
|
-
},
|
|
340
332
|
{
|
|
341
333
|
"_name": "db:SELECT * FROM 'UserInfo' WHERE id = ?",
|
|
342
334
|
"attributes": {
|
|
@@ -390,6 +382,88 @@ exports[`useClientDocument > otel > should update the data based on component ke
|
|
|
390
382
|
}
|
|
391
383
|
`;
|
|
392
384
|
|
|
385
|
+
exports[`useClientDocument > otel > should update the data based on component key strictMode={ strictMode: true } 2`] = `
|
|
386
|
+
[
|
|
387
|
+
{
|
|
388
|
+
"_name": "LiveStore:commit",
|
|
389
|
+
"attributes": {
|
|
390
|
+
"livestore.commitLabel": "UserInfo.set:u1",
|
|
391
|
+
"livestore.eventTags": "[
|
|
392
|
+
"UserInfoSet"
|
|
393
|
+
]",
|
|
394
|
+
"livestore.eventsCount": 1,
|
|
395
|
+
},
|
|
396
|
+
"children": [
|
|
397
|
+
{
|
|
398
|
+
"_name": "client-session-sync-processor:push",
|
|
399
|
+
"attributes": {
|
|
400
|
+
"batchSize": 1,
|
|
401
|
+
"eventCounts": "{
|
|
402
|
+
"UserInfoSet": 1
|
|
403
|
+
}",
|
|
404
|
+
"mergeResultTag": "advance",
|
|
405
|
+
},
|
|
406
|
+
"children": [
|
|
407
|
+
{
|
|
408
|
+
"_name": "client-session-sync-processor:materialize-event",
|
|
409
|
+
"children": [
|
|
410
|
+
{
|
|
411
|
+
"_name": "livestore.in-memory-db:execute",
|
|
412
|
+
"attributes": {
|
|
413
|
+
"sql.query": "
|
|
414
|
+
INSERT INTO 'UserInfo' (id, value)
|
|
415
|
+
VALUES (?, ?)
|
|
416
|
+
ON CONFLICT (id) DO UPDATE SET value = json_set(json_set(value, ?, json(?)), ?, json(?))
|
|
417
|
+
",
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
],
|
|
421
|
+
},
|
|
422
|
+
],
|
|
423
|
+
},
|
|
424
|
+
],
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
"_name": "LiveStore:commit",
|
|
428
|
+
"attributes": {
|
|
429
|
+
"livestore.eventTags": "[
|
|
430
|
+
"UserInfoSet"
|
|
431
|
+
]",
|
|
432
|
+
"livestore.eventsCount": 1,
|
|
433
|
+
},
|
|
434
|
+
"children": [
|
|
435
|
+
{
|
|
436
|
+
"_name": "client-session-sync-processor:push",
|
|
437
|
+
"attributes": {
|
|
438
|
+
"batchSize": 1,
|
|
439
|
+
"eventCounts": "{
|
|
440
|
+
"UserInfoSet": 1
|
|
441
|
+
}",
|
|
442
|
+
"mergeResultTag": "advance",
|
|
443
|
+
},
|
|
444
|
+
"children": [
|
|
445
|
+
{
|
|
446
|
+
"_name": "client-session-sync-processor:materialize-event",
|
|
447
|
+
"children": [
|
|
448
|
+
{
|
|
449
|
+
"_name": "livestore.in-memory-db:execute",
|
|
450
|
+
"attributes": {
|
|
451
|
+
"sql.query": "
|
|
452
|
+
INSERT INTO 'UserInfo' (id, value)
|
|
453
|
+
VALUES (?, ?)
|
|
454
|
+
ON CONFLICT (id) DO UPDATE SET value = json_set(value, ?, json(?))
|
|
455
|
+
",
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
],
|
|
459
|
+
},
|
|
460
|
+
],
|
|
461
|
+
},
|
|
462
|
+
],
|
|
463
|
+
},
|
|
464
|
+
]
|
|
465
|
+
`;
|
|
466
|
+
|
|
393
467
|
exports[`useClientDocument > should update the data based on component key 1`] = `
|
|
394
468
|
{
|
|
395
469
|
"atoms": [
|
|
@@ -443,7 +517,7 @@ exports[`useClientDocument > should update the data based on component key 1`] =
|
|
|
443
517
|
"refreshes": 1,
|
|
444
518
|
"sub": [],
|
|
445
519
|
"super": [
|
|
446
|
-
"node-
|
|
520
|
+
"node-6",
|
|
447
521
|
],
|
|
448
522
|
},
|
|
449
523
|
{
|
|
@@ -464,10 +538,27 @@ exports[`useClientDocument > should update the data based on component key 1`] =
|
|
|
464
538
|
"super": [],
|
|
465
539
|
},
|
|
466
540
|
{
|
|
467
|
-
"_tag": "
|
|
541
|
+
"_tag": "ref",
|
|
468
542
|
"id": "node-5",
|
|
469
543
|
"isDestroyed": false,
|
|
470
544
|
"isDirty": false,
|
|
545
|
+
"label": "tableRef:Kv",
|
|
546
|
+
"meta": {
|
|
547
|
+
"liveStoreRefType": "table",
|
|
548
|
+
},
|
|
549
|
+
"previousResult": {
|
|
550
|
+
"_tag": "Some",
|
|
551
|
+
"value": "null",
|
|
552
|
+
},
|
|
553
|
+
"refreshes": 0,
|
|
554
|
+
"sub": [],
|
|
555
|
+
"super": [],
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
"_tag": "thunk",
|
|
559
|
+
"id": "node-6",
|
|
560
|
+
"isDestroyed": false,
|
|
561
|
+
"isDirty": false,
|
|
471
562
|
"label": "UserInfo.get:u1:results",
|
|
472
563
|
"meta": {
|
|
473
564
|
"liveStoreThunkType": "db.result",
|
|
@@ -481,7 +572,7 @@ exports[`useClientDocument > should update the data based on component key 1`] =
|
|
|
481
572
|
"node-3",
|
|
482
573
|
],
|
|
483
574
|
"super": [
|
|
484
|
-
"node-
|
|
575
|
+
"node-7",
|
|
485
576
|
],
|
|
486
577
|
},
|
|
487
578
|
],
|
|
@@ -489,12 +580,12 @@ exports[`useClientDocument > should update the data based on component key 1`] =
|
|
|
489
580
|
"effects": [
|
|
490
581
|
{
|
|
491
582
|
"_tag": "effect",
|
|
492
|
-
"id": "node-
|
|
583
|
+
"id": "node-7",
|
|
493
584
|
"invocations": 1,
|
|
494
585
|
"isDestroyed": false,
|
|
495
586
|
"label": "subscribe:UserInfo.get:u1",
|
|
496
587
|
"sub": [
|
|
497
|
-
"node-
|
|
588
|
+
"node-6",
|
|
498
589
|
],
|
|
499
590
|
},
|
|
500
591
|
],
|
|
@@ -554,7 +645,7 @@ exports[`useClientDocument > should update the data based on component key 2`] =
|
|
|
554
645
|
"refreshes": 2,
|
|
555
646
|
"sub": [],
|
|
556
647
|
"super": [
|
|
557
|
-
"node-
|
|
648
|
+
"node-8",
|
|
558
649
|
],
|
|
559
650
|
},
|
|
560
651
|
{
|
|
@@ -574,9 +665,26 @@ exports[`useClientDocument > should update the data based on component key 2`] =
|
|
|
574
665
|
"sub": [],
|
|
575
666
|
"super": [],
|
|
576
667
|
},
|
|
668
|
+
{
|
|
669
|
+
"_tag": "ref",
|
|
670
|
+
"id": "node-5",
|
|
671
|
+
"isDestroyed": false,
|
|
672
|
+
"isDirty": false,
|
|
673
|
+
"label": "tableRef:Kv",
|
|
674
|
+
"meta": {
|
|
675
|
+
"liveStoreRefType": "table",
|
|
676
|
+
},
|
|
677
|
+
"previousResult": {
|
|
678
|
+
"_tag": "Some",
|
|
679
|
+
"value": "null",
|
|
680
|
+
},
|
|
681
|
+
"refreshes": 0,
|
|
682
|
+
"sub": [],
|
|
683
|
+
"super": [],
|
|
684
|
+
},
|
|
577
685
|
{
|
|
578
686
|
"_tag": "thunk",
|
|
579
|
-
"id": "node-
|
|
687
|
+
"id": "node-8",
|
|
580
688
|
"isDestroyed": false,
|
|
581
689
|
"isDirty": false,
|
|
582
690
|
"label": "UserInfo.get:u2:results",
|
|
@@ -592,7 +700,7 @@ exports[`useClientDocument > should update the data based on component key 2`] =
|
|
|
592
700
|
"node-3",
|
|
593
701
|
],
|
|
594
702
|
"super": [
|
|
595
|
-
"node-
|
|
703
|
+
"node-9",
|
|
596
704
|
],
|
|
597
705
|
},
|
|
598
706
|
],
|
|
@@ -600,12 +708,12 @@ exports[`useClientDocument > should update the data based on component key 2`] =
|
|
|
600
708
|
"effects": [
|
|
601
709
|
{
|
|
602
710
|
"_tag": "effect",
|
|
603
|
-
"id": "node-
|
|
711
|
+
"id": "node-9",
|
|
604
712
|
"invocations": 1,
|
|
605
713
|
"isDestroyed": false,
|
|
606
714
|
"label": "subscribe:UserInfo.get:u2",
|
|
607
715
|
"sub": [
|
|
608
|
-
"node-
|
|
716
|
+
"node-8",
|
|
609
717
|
],
|
|
610
718
|
},
|
|
611
719
|
],
|