@livestore/react 0.4.0-dev.2 → 0.4.0-dev.21

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 (96) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/LiveStoreContext.d.ts +27 -0
  3. package/dist/LiveStoreContext.d.ts.map +1 -1
  4. package/dist/LiveStoreContext.js +18 -0
  5. package/dist/LiveStoreContext.js.map +1 -1
  6. package/dist/LiveStoreProvider.d.ts +14 -8
  7. package/dist/LiveStoreProvider.d.ts.map +1 -1
  8. package/dist/LiveStoreProvider.js +40 -24
  9. package/dist/LiveStoreProvider.js.map +1 -1
  10. package/dist/LiveStoreProvider.test.js +7 -7
  11. package/dist/LiveStoreProvider.test.js.map +1 -1
  12. package/dist/__tests__/fixture.d.ts +34 -12
  13. package/dist/__tests__/fixture.d.ts.map +1 -1
  14. package/dist/__tests__/fixture.js +13 -5
  15. package/dist/__tests__/fixture.js.map +1 -1
  16. package/dist/experimental/components/LiveList.js +1 -1
  17. package/dist/experimental/mod.d.ts +1 -0
  18. package/dist/experimental/mod.d.ts.map +1 -1
  19. package/dist/experimental/mod.js +1 -0
  20. package/dist/experimental/mod.js.map +1 -1
  21. package/dist/experimental/multi-store/StoreRegistry.d.ts +105 -0
  22. package/dist/experimental/multi-store/StoreRegistry.d.ts.map +1 -0
  23. package/dist/experimental/multi-store/StoreRegistry.js +184 -0
  24. package/dist/experimental/multi-store/StoreRegistry.js.map +1 -0
  25. package/dist/experimental/multi-store/StoreRegistry.test.d.ts +2 -0
  26. package/dist/experimental/multi-store/StoreRegistry.test.d.ts.map +1 -0
  27. package/dist/experimental/multi-store/StoreRegistry.test.js +381 -0
  28. package/dist/experimental/multi-store/StoreRegistry.test.js.map +1 -0
  29. package/dist/experimental/multi-store/StoreRegistryContext.d.ts +10 -0
  30. package/dist/experimental/multi-store/StoreRegistryContext.d.ts.map +1 -0
  31. package/dist/experimental/multi-store/StoreRegistryContext.js +15 -0
  32. package/dist/experimental/multi-store/StoreRegistryContext.js.map +1 -0
  33. package/dist/experimental/multi-store/mod.d.ts +6 -0
  34. package/dist/experimental/multi-store/mod.d.ts.map +1 -0
  35. package/dist/experimental/multi-store/mod.js +6 -0
  36. package/dist/experimental/multi-store/mod.js.map +1 -0
  37. package/dist/experimental/multi-store/storeOptions.d.ts +4 -0
  38. package/dist/experimental/multi-store/storeOptions.d.ts.map +1 -0
  39. package/dist/experimental/multi-store/storeOptions.js +4 -0
  40. package/dist/experimental/multi-store/storeOptions.js.map +1 -0
  41. package/dist/experimental/multi-store/types.d.ts +25 -0
  42. package/dist/experimental/multi-store/types.d.ts.map +1 -0
  43. package/dist/experimental/multi-store/types.js +2 -0
  44. package/dist/experimental/multi-store/types.js.map +1 -0
  45. package/dist/experimental/multi-store/useStore.d.ts +11 -0
  46. package/dist/experimental/multi-store/useStore.d.ts.map +1 -0
  47. package/dist/experimental/multi-store/useStore.js +16 -0
  48. package/dist/experimental/multi-store/useStore.js.map +1 -0
  49. package/dist/experimental/multi-store/useStore.test.d.ts +2 -0
  50. package/dist/experimental/multi-store/useStore.test.d.ts.map +1 -0
  51. package/dist/experimental/multi-store/useStore.test.js +198 -0
  52. package/dist/experimental/multi-store/useStore.test.js.map +1 -0
  53. package/dist/mod.d.ts +1 -1
  54. package/dist/mod.d.ts.map +1 -1
  55. package/dist/mod.js.map +1 -1
  56. package/dist/useClientDocument.d.ts +43 -13
  57. package/dist/useClientDocument.d.ts.map +1 -1
  58. package/dist/useClientDocument.js +4 -5
  59. package/dist/useClientDocument.js.map +1 -1
  60. package/dist/useClientDocument.test.js +29 -7
  61. package/dist/useClientDocument.test.js.map +1 -1
  62. package/dist/useQuery.d.ts +28 -6
  63. package/dist/useQuery.d.ts.map +1 -1
  64. package/dist/useQuery.js +63 -18
  65. package/dist/useQuery.js.map +1 -1
  66. package/dist/useQuery.test.js +35 -11
  67. package/dist/useQuery.test.js.map +1 -1
  68. package/dist/useRcResource.test.js +1 -1
  69. package/dist/useStore.d.ts +53 -1
  70. package/dist/useStore.d.ts.map +1 -1
  71. package/dist/useStore.js +52 -1
  72. package/dist/useStore.js.map +1 -1
  73. package/package.json +14 -14
  74. package/src/LiveStoreContext.ts +27 -0
  75. package/src/LiveStoreProvider.test.tsx +7 -7
  76. package/src/LiveStoreProvider.tsx +67 -45
  77. package/src/__snapshots__/useClientDocument.test.tsx.snap +208 -100
  78. package/src/__snapshots__/useQuery.test.tsx.snap +400 -128
  79. package/src/__tests__/fixture.tsx +23 -24
  80. package/src/experimental/components/LiveList.tsx +1 -1
  81. package/src/experimental/mod.ts +1 -0
  82. package/src/experimental/multi-store/StoreRegistry.test.ts +518 -0
  83. package/src/experimental/multi-store/StoreRegistry.ts +253 -0
  84. package/src/experimental/multi-store/StoreRegistryContext.tsx +23 -0
  85. package/src/experimental/multi-store/mod.ts +5 -0
  86. package/src/experimental/multi-store/storeOptions.ts +8 -0
  87. package/src/experimental/multi-store/types.ts +37 -0
  88. package/src/experimental/multi-store/useStore.test.tsx +269 -0
  89. package/src/experimental/multi-store/useStore.ts +26 -0
  90. package/src/mod.ts +2 -1
  91. package/src/useClientDocument.test.tsx +105 -75
  92. package/src/useClientDocument.ts +58 -13
  93. package/src/useQuery.test.tsx +62 -11
  94. package/src/useQuery.ts +98 -27
  95. package/src/useRcResource.test.tsx +1 -1
  96. package/src/useStore.ts +55 -3
@@ -1,5 +1,5 @@
1
1
  import type { Adapter, BootStatus, IntentionalShutdownCause, MigrationsReport, SyncError } from '@livestore/common'
2
- import { provideOtel, UnexpectedError } from '@livestore/common'
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: UnexpectedError | unknown) => React.ReactNode
40
+ renderError?: (error: UnknownError | unknown) => React.ReactNode
51
41
  renderShutdown?: (cause: IntentionalShutdownCause | StoreInterrupted | SyncError) => React.ReactNode
52
42
  adapter: Adapter
53
43
  /**
@@ -72,25 +62,33 @@ export interface LiveStoreProviderProps {
72
62
  * @default true
73
63
  */
74
64
  confirmUnsavedChanges?: boolean
65
+ /**
66
+ * Advanced store parameters forwarded to `createStore`.
67
+ * Currently supports:
68
+ * - `leaderPushBatchSize`: max events pushed to the leader per write batch.
69
+ * - `eventQueryBatchSize`: chunk size used when the stream replays confirmed events.
70
+ */
71
+ params?: CreateStoreOptions<LiveStoreSchema>['params']
75
72
  /**
76
73
  * Payload that will be passed to the sync backend when connecting
77
74
  *
78
75
  * @default undefined
79
76
  */
80
- syncPayload?: Schema.JsonValue
77
+ syncPayloadSchema?: TSyncPayloadSchema
78
+ syncPayload?: Schema.Schema.Type<TSyncPayloadSchema>
81
79
  debug?: {
82
80
  instanceId?: string
83
81
  }
84
82
  }
85
83
 
86
- const defaultRenderError = (error: UnexpectedError | unknown) =>
87
- IS_REACT_NATIVE ? null : Schema.is(UnexpectedError)(error) ? error.toString() : errorToString(error)
84
+ const defaultRenderError = (error: UnknownError | unknown) =>
85
+ IS_REACT_NATIVE ? null : Schema.is(UnknownError)(error) ? error.toString() : errorToString(error)
88
86
 
89
87
  const defaultRenderShutdown = (cause: IntentionalShutdownCause | StoreInterrupted | SyncError) => {
90
88
  const reason =
91
89
  cause._tag === 'LiveStore.StoreInterrupted'
92
90
  ? `interrupted due to: ${cause.reason}`
93
- : cause._tag === 'LiveStore.SyncError'
91
+ : cause._tag === 'InvalidPushError' || cause._tag === 'InvalidPullError'
94
92
  ? `sync error: ${cause.cause}`
95
93
  : cause.reason === 'devtools-import'
96
94
  ? 'devtools import'
@@ -108,7 +106,7 @@ const defaultRenderShutdown = (cause: IntentionalShutdownCause | StoreInterrupte
108
106
  const defaultRenderLoading = (status: BootStatus) =>
109
107
  IS_REACT_NATIVE ? null : <>LiveStore is loading ({status.stage})...</>
110
108
 
111
- export const LiveStoreProvider = ({
109
+ export const LiveStoreProvider = <TSyncPayloadSchema extends Schema.Schema<any> = typeof Schema.JsonValue>({
112
110
  renderLoading = defaultRenderLoading,
113
111
  renderError = defaultRenderError,
114
112
  renderShutdown = defaultRenderShutdown,
@@ -122,21 +120,31 @@ export const LiveStoreProvider = ({
122
120
  disableDevtools,
123
121
  signal,
124
122
  confirmUnsavedChanges = true,
123
+ params,
125
124
  syncPayload,
125
+ syncPayloadSchema,
126
126
  debug,
127
- }: LiveStoreProviderProps & { children?: React.ReactNode }): React.ReactNode => {
127
+ logger,
128
+ logLevel,
129
+ }: LiveStoreProviderProps<TSyncPayloadSchema> & React.PropsWithChildren): React.ReactNode => {
128
130
  const storeCtx = useCreateStore({
129
131
  storeId,
130
132
  schema,
131
- otelOptions,
132
- boot,
133
133
  adapter,
134
134
  batchUpdates,
135
- disableDevtools,
136
- signal,
137
135
  confirmUnsavedChanges,
138
- syncPayload,
139
- debug,
136
+ ...omitUndefineds({
137
+ otelOptions,
138
+ boot,
139
+ disableDevtools,
140
+ params,
141
+ signal,
142
+ syncPayload,
143
+ syncPayloadSchema,
144
+ debug,
145
+ }),
146
+ logger,
147
+ logLevel,
140
148
  })
141
149
 
142
150
  if (storeCtx.stage === 'error') {
@@ -173,11 +181,15 @@ const useCreateStore = ({
173
181
  params,
174
182
  confirmUnsavedChanges,
175
183
  syncPayload,
184
+ syncPayloadSchema,
176
185
  debug,
177
- }: CreateStoreOptions<LiveStoreSchema> & {
178
- signal?: AbortSignal
179
- otelOptions?: Partial<OtelOptions>
180
- }) => {
186
+ logger,
187
+ logLevel,
188
+ }: CreateStoreOptions<LiveStoreSchema> &
189
+ LogConfig.WithLoggerOptions & {
190
+ signal?: AbortSignal
191
+ otelOptions?: Partial<OtelOptions>
192
+ }) => {
181
193
  const [_, rerender] = React.useState(0)
182
194
  const ctxValueRef = React.useRef<{
183
195
  value: StoreContext_ | BootStatus
@@ -209,6 +221,7 @@ const useCreateStore = ({
209
221
  params,
210
222
  confirmUnsavedChanges,
211
223
  syncPayload,
224
+ syncPayloadSchema,
212
225
  debugInstanceId,
213
226
  })
214
227
 
@@ -237,6 +250,7 @@ const useCreateStore = ({
237
250
  params: inputPropsCacheRef.current.params !== params,
238
251
  confirmUnsavedChanges: inputPropsCacheRef.current.confirmUnsavedChanges !== confirmUnsavedChanges,
239
252
  syncPayload: inputPropsCacheRef.current.syncPayload !== syncPayload,
253
+ syncPayloadSchema: inputPropsCacheRef.current.syncPayloadSchema !== syncPayloadSchema,
240
254
  debugInstanceId: inputPropsCacheRef.current.debugInstanceId !== debugInstanceId,
241
255
  }
242
256
 
@@ -251,7 +265,8 @@ const useCreateStore = ({
251
265
  inputPropChanges.context ||
252
266
  inputPropChanges.params ||
253
267
  inputPropChanges.confirmUnsavedChanges ||
254
- inputPropChanges.syncPayload
268
+ inputPropChanges.syncPayload ||
269
+ inputPropChanges.syncPayloadSchema
255
270
  ) {
256
271
  inputPropsCacheRef.current = {
257
272
  schema,
@@ -265,6 +280,7 @@ const useCreateStore = ({
265
280
  params,
266
281
  confirmUnsavedChanges,
267
282
  syncPayload,
283
+ syncPayloadSchema,
268
284
  debugInstanceId,
269
285
  }
270
286
  if (ctxValueRef.current.componentScope !== undefined && ctxValueRef.current.shutdownDeferred !== undefined) {
@@ -330,21 +346,24 @@ const useCreateStore = ({
330
346
  const store = yield* createStore({
331
347
  schema,
332
348
  storeId,
333
- boot,
334
349
  adapter,
335
- batchUpdates,
336
- disableDevtools,
337
350
  shutdownDeferred,
338
- context,
339
- params,
340
- confirmUnsavedChanges,
341
- syncPayload,
351
+ ...omitUndefineds({
352
+ boot,
353
+ batchUpdates,
354
+ disableDevtools,
355
+ context,
356
+ params,
357
+ confirmUnsavedChanges,
358
+ syncPayload,
359
+ syncPayloadSchema,
360
+ }),
342
361
  onBootStatus: (status) => {
343
362
  if (ctxValueRef.current.value.stage === 'running' || ctxValueRef.current.value.stage === 'error') return
344
363
  // NOTE sometimes when status come in in rapid succession, only the last value will be rendered by React
345
364
  setContextValue(status)
346
365
  },
347
- debug: { instanceId: debugInstanceId },
366
+ debug: { ...omitUndefineds({ instanceId: debugInstanceId }) },
348
367
  }).pipe(Effect.tapErrorCause((cause) => Deferred.failCause(shutdownDeferred, cause)))
349
368
 
350
369
  setContextValue({ stage: 'running', store })
@@ -356,7 +375,8 @@ const useCreateStore = ({
356
375
  yield* Deferred.await(shutdownDeferred).pipe(
357
376
  Effect.tapErrorCause((cause) => Effect.logDebug('[@livestore/livestore/react] shutdown', Cause.pretty(cause))),
358
377
  Effect.tap((intentionalShutdown) => shutdownContext(intentionalShutdown)),
359
- Effect.catchTag('LiveStore.SyncError', (cause) => shutdownContext(cause)),
378
+ Effect.catchTag('InvalidPushError', (cause) => shutdownContext(cause)),
379
+ Effect.catchTag('InvalidPullError', (cause) => shutdownContext(cause)),
360
380
  Effect.catchTag('LiveStore.StoreInterrupted', (cause) => shutdownContext(cause)),
361
381
  Effect.tapError((error) => Effect.sync(() => setContextValue({ stage: 'error', error }))),
362
382
  Effect.tapDefect((defect) => Effect.sync(() => setContextValue({ stage: 'error', error: defect }))),
@@ -366,11 +386,10 @@ const useCreateStore = ({
366
386
  Effect.scoped,
367
387
  Effect.withSpan('@livestore/react:useCreateStore'),
368
388
  LS_DEV ? TaskTracing.withAsyncTaggingTracing((name: string) => (console as any).createTask(name)) : identity,
369
- provideOtel({ parentSpanContext: otelOptions?.rootSpanContext, otelTracer: otelOptions?.tracer }),
389
+ provideOtel(omitUndefineds({ parentSpanContext: otelOptions?.rootSpanContext, otelTracer: otelOptions?.tracer })),
370
390
  Effect.tapCauseLogPretty,
371
391
  Effect.annotateLogs({ thread: 'window' }),
372
- Effect.provide(Logger.prettyWithThread('window')),
373
- Logger.withMinimumLogLevel(LogLevel.Debug),
392
+ LogConfig.withLoggerConfig({ logger, logLevel }, { threadName: 'window' }),
374
393
  Effect.runCallback,
375
394
  )
376
395
 
@@ -400,8 +419,11 @@ const useCreateStore = ({
400
419
  params,
401
420
  confirmUnsavedChanges,
402
421
  syncPayload,
422
+ syncPayloadSchema,
403
423
  debugInstanceId,
404
424
  interrupt,
425
+ logger,
426
+ logLevel,
405
427
  ])
406
428
 
407
429
  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-5",
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": "thunk",
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-6",
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-6",
583
+ "id": "node-7",
493
584
  "invocations": 1,
494
585
  "isDestroyed": false,
495
586
  "label": "subscribe:UserInfo.get:u1",
496
587
  "sub": [
497
- "node-5",
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-7",
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-7",
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-8",
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-8",
711
+ "id": "node-9",
604
712
  "invocations": 1,
605
713
  "isDestroyed": false,
606
714
  "label": "subscribe:UserInfo.get:u2",
607
715
  "sub": [
608
- "node-7",
716
+ "node-8",
609
717
  ],
610
718
  },
611
719
  ],