@livestore/cli 0.4.0-dev.13 → 0.4.0-dev.15

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/cli",
3
- "version": "0.4.0-dev.13",
3
+ "version": "0.4.0-dev.15",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -11,11 +11,12 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "@effect/ai-openai": "0.32.0",
14
- "@livestore/adapter-node": "0.4.0-dev.13",
15
- "@livestore/livestore": "0.4.0-dev.13",
16
- "@livestore/utils": "0.4.0-dev.13",
17
- "@livestore/common": "0.4.0-dev.13",
18
- "@livestore/sync-cf": "0.4.0-dev.13"
14
+ "@livestore/adapter-node": "0.4.0-dev.15",
15
+ "@livestore/common": "0.4.0-dev.15",
16
+ "@livestore/utils": "0.4.0-dev.15",
17
+ "@livestore/livestore": "0.4.0-dev.15",
18
+ "@livestore/peer-deps": "0.4.0-dev.15",
19
+ "@livestore/sync-cf": "0.4.0-dev.15"
19
20
  },
20
21
  "devDependencies": {
21
22
  "@types/node": "24.5.2",
@@ -4,6 +4,7 @@ import { makeAdapter as makeNodeAdapter } from '@livestore/adapter-node'
4
4
  import { isLiveStoreSchema, LiveStoreEvent, SystemTables } from '@livestore/common/schema'
5
5
  import type { Store } from '@livestore/livestore'
6
6
  import { createStorePromise } from '@livestore/livestore'
7
+ import { shouldNeverHappen } from '@livestore/utils'
7
8
  import { Effect, Option, Schema } from '@livestore/utils/effect'
8
9
 
9
10
  /** Currently connected store */
@@ -48,16 +49,29 @@ export const init = ({
48
49
  }
49
50
 
50
51
  // Optional: syncPayload for authenticated backends
51
- const syncPayload = (mod as any)?.syncPayload
52
- if (syncPayload !== undefined) {
53
- try {
54
- JSON.stringify(syncPayload)
55
- } catch {
56
- throw new Error(
57
- `Exported 'syncPayload' from ${abs} must be JSON-serializable (received non-serializable value).`,
58
- )
59
- }
60
- }
52
+ const syncPayloadSchemaExport = (mod as any)?.syncPayloadSchema
53
+ const syncPayloadSchema =
54
+ syncPayloadSchemaExport === undefined
55
+ ? Schema.JsonValue
56
+ : Schema.isSchema(syncPayloadSchemaExport)
57
+ ? (syncPayloadSchemaExport as Schema.Schema<any>)
58
+ : shouldNeverHappen(
59
+ `Exported 'syncPayloadSchema' from ${abs} must be an Effect Schema (received ${typeof syncPayloadSchemaExport}).`,
60
+ )
61
+
62
+ const syncPayloadExport = (mod as any)?.syncPayload
63
+ const syncPayload =
64
+ syncPayloadExport === undefined
65
+ ? undefined
66
+ : (() => {
67
+ try {
68
+ return Schema.decodeSync(syncPayloadSchema)(syncPayloadExport)
69
+ } catch (error) {
70
+ throw new Error(
71
+ `Failed to decode 'syncPayload' from ${abs} using the provided schema: ${(error as Error).message}`,
72
+ )
73
+ }
74
+ })()
61
75
 
62
76
  // Build Node adapter internally
63
77
  const adapter = makeNodeAdapter({
@@ -78,6 +92,7 @@ export const init = ({
78
92
  adapter,
79
93
  disableDevtools: true,
80
94
  syncPayload,
95
+ syncPayloadSchema,
81
96
  })
82
97
 
83
98
  // Replace existing store if any