@livestore/common 0.3.0-dev.22 → 0.3.0-dev.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livestore/common",
3
- "version": "0.3.0-dev.22",
3
+ "version": "0.3.0-dev.23",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -54,7 +54,7 @@
54
54
  "graphology": "0.26.0-alpha1",
55
55
  "graphology-dag": "0.4.1",
56
56
  "graphology-types": "0.24.8",
57
- "@livestore/utils": "0.3.0-dev.22"
57
+ "@livestore/utils": "0.3.0-dev.23"
58
58
  },
59
59
  "devDependencies": {
60
60
  "vitest": "^3.0.8"
@@ -239,6 +239,12 @@ export type Adapter = (opts: {
239
239
  bootStatusQueue: Queue.Queue<BootStatus>
240
240
  shutdown: (cause: Cause.Cause<any>) => void
241
241
  connectDevtoolsToStore: ConnectDevtoolsToStore
242
+ /**
243
+ * Payload that will be passed to the sync backend when connecting
244
+ *
245
+ * @default undefined
246
+ */
247
+ syncPayload: Schema.JsonValue | undefined
242
248
  }) => Effect.Effect<ClientSession, UnexpectedError, Scope.Scope>
243
249
 
244
250
  export const MigrationsReportEntry = Schema.Struct({
@@ -1,4 +1,4 @@
1
- import type { HttpClient, Scope } from '@livestore/utils/effect'
1
+ import type { HttpClient, Schema, Scope } from '@livestore/utils/effect'
2
2
  import { Deferred, Effect, Layer, Queue, SubscriptionRef } from '@livestore/utils/effect'
3
3
 
4
4
  import type { BootStatus, MakeSqliteDb, MigrationsReport, SqliteError } from '../adapter-types.js'
@@ -28,6 +28,7 @@ export const makeLeaderThreadLayer = ({
28
28
  schema,
29
29
  storeId,
30
30
  clientId,
31
+ syncPayload,
31
32
  makeSqliteDb,
32
33
  syncOptions,
33
34
  dbReadModel,
@@ -36,6 +37,7 @@ export const makeLeaderThreadLayer = ({
36
37
  shutdownChannel,
37
38
  }: {
38
39
  storeId: string
40
+ syncPayload: Schema.JsonValue | undefined
39
41
  clientId: string
40
42
  schema: LiveStoreSchema
41
43
  makeSqliteDb: MakeSqliteDb
@@ -54,7 +56,9 @@ export const makeLeaderThreadLayer = ({
54
56
  dbReadModel.select<{ count: number }>(sql`select count(*) as count from sqlite_master`)[0]!.count === 0
55
57
 
56
58
  const syncBackend =
57
- syncOptions?.makeBackend === undefined ? undefined : yield* syncOptions.makeBackend({ storeId, clientId })
59
+ syncOptions?.makeBackend === undefined
60
+ ? undefined
61
+ : yield* syncOptions.makeBackend({ storeId, clientId, payload: syncPayload })
58
62
 
59
63
  const initialBlockingSyncContext = yield* makeInitialBlockingSyncContext({
60
64
  initialSyncOptions: syncOptions?.initialSyncOptions ?? { _tag: 'Skip' },
package/src/sync/sync.ts CHANGED
@@ -12,10 +12,13 @@ import type * as MutationEvent from '../schema/MutationEvent.js'
12
12
  export type MakeBackendArgs = {
13
13
  storeId: string
14
14
  clientId: string
15
+ payload: Schema.JsonValue | undefined
15
16
  }
16
17
 
17
18
  export type SyncOptions = {
18
- makeBackend?: (args: MakeBackendArgs) => Effect.Effect<SyncBackend<any>, UnexpectedError, Scope.Scope>
19
+ makeBackend?: (
20
+ args: MakeBackendArgs,
21
+ ) => Effect.Effect<SyncBackend<any>, UnexpectedError, Scope.Scope | HttpClient.HttpClient>
19
22
  /** @default { _tag: 'Skip' } */
20
23
  initialSyncOptions?: InitialSyncOptions
21
24
  }
package/src/version.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // import packageJson from '../package.json' with { type: 'json' }
3
3
  // export const liveStoreVersion = packageJson.version
4
4
 
5
- export const liveStoreVersion = '0.3.0-dev.22' as const
5
+ export const liveStoreVersion = '0.3.0-dev.23' as const
6
6
 
7
7
  /**
8
8
  * This version number is incremented whenever the internal storage format changes in a breaking way.