@livestore/sync-s2 0.4.0 → 0.5.0-dev.1
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/api-schema.d.ts +19 -19
- package/dist/api-schema.d.ts.map +1 -1
- package/dist/api-schema.js +4 -4
- package/dist/api-schema.js.map +1 -1
- package/dist/api-schema.test.js +18 -13
- package/dist/api-schema.test.js.map +1 -1
- package/dist/decode.d.ts +1 -1
- package/dist/decode.d.ts.map +1 -1
- package/dist/decode.js +4 -4
- package/dist/decode.js.map +1 -1
- package/dist/http-client-generated.d.ts +337 -1051
- package/dist/http-client-generated.d.ts.map +1 -1
- package/dist/http-client-generated.js +224 -221
- package/dist/http-client-generated.js.map +1 -1
- package/dist/limits.d.ts +6 -8
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +11 -12
- package/dist/limits.js.map +1 -1
- package/dist/limits.test.js +1 -1
- package/dist/limits.test.js.map +1 -1
- package/dist/make-s2-url.d.ts +1 -1
- package/dist/make-s2-url.d.ts.map +1 -1
- package/dist/make-s2-url.js +5 -5
- package/dist/make-s2-url.js.map +1 -1
- package/dist/mod.js +7 -7
- package/dist/s2-proxy-helpers.d.ts.map +1 -1
- package/dist/s2-proxy-helpers.js +2 -2
- package/dist/sync-provider.d.ts +3 -3
- package/dist/sync-provider.d.ts.map +1 -1
- package/dist/sync-provider.js +15 -11
- package/dist/sync-provider.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +44 -63
- package/src/api-schema.test.ts +15 -11
- package/src/api-schema.ts +3 -3
- package/src/decode.ts +4 -4
- package/src/http-client-generated.ts +186 -278
- package/src/limits.test.ts +1 -2
- package/src/limits.ts +20 -22
- package/src/make-s2-url.ts +5 -5
- package/src/sync-provider.ts +16 -13
- package/src/types.ts +1 -1
package/package.json
CHANGED
|
@@ -1,89 +1,70 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$genie": {
|
|
3
|
+
"source": "package.json.genie.ts",
|
|
4
|
+
"warning": "DO NOT EDIT - changes will be overwritten",
|
|
5
|
+
"workspaceClosureDirs": [
|
|
6
|
+
"packages/@livestore/sync-s2",
|
|
7
|
+
"repos/livestore/packages/@livestore/adapter-web",
|
|
8
|
+
"repos/livestore/packages/@livestore/common",
|
|
9
|
+
"repos/livestore/packages/@livestore/common-cf",
|
|
10
|
+
"repos/livestore/packages/@livestore/livestore",
|
|
11
|
+
"repos/livestore/packages/@livestore/sqlite-wasm",
|
|
12
|
+
"repos/livestore/packages/@livestore/utils",
|
|
13
|
+
"repos/livestore/packages/@livestore/utils-dev",
|
|
14
|
+
"repos/livestore/packages/@livestore/wa-sqlite",
|
|
15
|
+
"repos/livestore/packages/@livestore/webmesh"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
2
18
|
"name": "@livestore/sync-s2",
|
|
3
|
-
"version": "0.
|
|
19
|
+
"version": "0.5.0-dev.1",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"sideEffects": false,
|
|
4
22
|
"license": "Apache-2.0",
|
|
5
23
|
"repository": {
|
|
6
24
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/livestorejs/livestore.git"
|
|
25
|
+
"url": "git+https://github.com/livestorejs/livestore-contrib.git"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": "./dist/mod.js",
|
|
29
|
+
"./s2-proxy-helpers": "./dist/s2-proxy-helpers.js"
|
|
8
30
|
},
|
|
9
31
|
"files": [
|
|
10
32
|
"dist",
|
|
11
33
|
"package.json",
|
|
12
34
|
"src"
|
|
13
35
|
],
|
|
14
|
-
"type": "module",
|
|
15
|
-
"sideEffects": false,
|
|
16
|
-
"exports": {
|
|
17
|
-
".": "./dist/mod.js",
|
|
18
|
-
"./s2-proxy-helpers": "./dist/s2-proxy-helpers.js"
|
|
19
|
-
},
|
|
20
|
-
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
22
|
-
},
|
|
23
36
|
"dependencies": {
|
|
24
|
-
"@livestore/common": "
|
|
25
|
-
"@livestore/livestore": "
|
|
26
|
-
"@livestore/utils": "
|
|
37
|
+
"@livestore/common": "0.5.0-dev.1",
|
|
38
|
+
"@livestore/livestore": "0.5.0-dev.1",
|
|
39
|
+
"@livestore/utils": "0.5.0-dev.1"
|
|
27
40
|
},
|
|
28
41
|
"devDependencies": {
|
|
29
|
-
"@effect/
|
|
30
|
-
"@effect/
|
|
31
|
-
"@effect/
|
|
32
|
-
"@effect/
|
|
33
|
-
"@effect/
|
|
34
|
-
"@effect/
|
|
35
|
-
"@effect/platform-browser": "0.76.0",
|
|
36
|
-
"@effect/platform-bun": "0.89.0",
|
|
37
|
-
"@effect/platform-node": "0.106.0",
|
|
38
|
-
"@effect/printer": "0.49.0",
|
|
39
|
-
"@effect/printer-ansi": "0.49.0",
|
|
40
|
-
"@effect/rpc": "0.75.1",
|
|
41
|
-
"@effect/sql": "0.51.1",
|
|
42
|
-
"@effect/typeclass": "0.40.0",
|
|
43
|
-
"@effect/vitest": "0.29.0",
|
|
42
|
+
"@effect/opentelemetry": "4.0.3",
|
|
43
|
+
"@effect/platform-browser": "4.0.3",
|
|
44
|
+
"@effect/platform-bun": "4.0.3",
|
|
45
|
+
"@effect/platform-node": "4.0.3",
|
|
46
|
+
"@effect/platform-node-shared": "4.0.3",
|
|
47
|
+
"@effect/vitest": "4.0.3",
|
|
44
48
|
"@opentelemetry/api": "1.9.0",
|
|
45
49
|
"@opentelemetry/resources": "2.2.0",
|
|
46
50
|
"@standard-schema/spec": "1.1.0",
|
|
47
|
-
"effect": "
|
|
48
|
-
"vitest": "
|
|
51
|
+
"effect": "4.0.3",
|
|
52
|
+
"vitest": "4.1.9"
|
|
49
53
|
},
|
|
50
54
|
"peerDependencies": {
|
|
51
|
-
"@effect/
|
|
52
|
-
"@effect/
|
|
53
|
-
"@effect/
|
|
54
|
-
"@effect/
|
|
55
|
-
"@effect/
|
|
56
|
-
"@effect/
|
|
57
|
-
"@effect/platform-browser": "^0.76.0",
|
|
58
|
-
"@effect/platform-bun": "^0.89.0",
|
|
59
|
-
"@effect/platform-node": "^0.106.0",
|
|
60
|
-
"@effect/printer": "^0.49.0",
|
|
61
|
-
"@effect/printer-ansi": "^0.49.0",
|
|
62
|
-
"@effect/rpc": "^0.75.1",
|
|
63
|
-
"@effect/sql": "^0.51.1",
|
|
64
|
-
"@effect/typeclass": "^0.40.0",
|
|
65
|
-
"@effect/vitest": "^0.29.0",
|
|
55
|
+
"@effect/opentelemetry": "^4.0.3",
|
|
56
|
+
"@effect/platform-browser": "^4.0.3",
|
|
57
|
+
"@effect/platform-bun": "^4.0.3",
|
|
58
|
+
"@effect/platform-node": "^4.0.3",
|
|
59
|
+
"@effect/platform-node-shared": "^4.0.3",
|
|
60
|
+
"@effect/vitest": "^4.0.3",
|
|
66
61
|
"@opentelemetry/api": "^1.9.0",
|
|
67
62
|
"@opentelemetry/resources": "^2.2.0",
|
|
68
63
|
"@standard-schema/spec": "^1.1.0",
|
|
69
|
-
"effect": "^
|
|
64
|
+
"effect": "^4.0.3"
|
|
70
65
|
},
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"warning": "DO NOT EDIT - changes will be overwritten",
|
|
74
|
-
"workspaceClosureDirs": [
|
|
75
|
-
"packages/@livestore/adapter-web",
|
|
76
|
-
"packages/@livestore/common",
|
|
77
|
-
"packages/@livestore/common-cf",
|
|
78
|
-
"packages/@livestore/devtools-web-common",
|
|
79
|
-
"packages/@livestore/livestore",
|
|
80
|
-
"packages/@livestore/sqlite-wasm",
|
|
81
|
-
"packages/@livestore/sync-s2",
|
|
82
|
-
"packages/@livestore/utils",
|
|
83
|
-
"packages/@livestore/utils-dev",
|
|
84
|
-
"packages/@livestore/wa-sqlite",
|
|
85
|
-
"packages/@livestore/webmesh"
|
|
86
|
-
]
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public"
|
|
87
68
|
},
|
|
88
69
|
"scripts": {
|
|
89
70
|
"build": "",
|
package/src/api-schema.test.ts
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
|
+
import { Result, Schema } from '@livestore/utils/effect'
|
|
1
2
|
import { describe, expect, it } from 'vitest'
|
|
2
3
|
|
|
3
|
-
import { Schema } from '@livestore/utils/effect'
|
|
4
|
-
|
|
5
4
|
import * as Api from './api-schema.ts'
|
|
6
5
|
import { decodePullArgsFromSearchParams } from './make-s2-url.ts'
|
|
7
6
|
import { s2SeqNum } from './types.ts'
|
|
8
7
|
|
|
9
8
|
describe('ApiSchema', () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
for (const { name, payload } of [
|
|
10
|
+
{ name: 'an omitted payload', payload: undefined },
|
|
11
|
+
{ name: 'an explicit payload', payload: { a: 1 } },
|
|
12
|
+
] as const) {
|
|
13
|
+
it(`encodes and decodes PullArgs with ${name} via args search param`, () => {
|
|
14
|
+
const args = Api.PullArgs.make({ storeId: 'store-1', s2SeqNum: s2SeqNum(42), live: true, payload })
|
|
15
|
+
const encoded = Schema.encodeSync(Api.ArgsSchema)(args)
|
|
16
|
+
const sp = new URLSearchParams({ args: encoded })
|
|
17
|
+
const roundtrip = decodePullArgsFromSearchParams(sp)
|
|
18
|
+
expect(roundtrip).toEqual(args)
|
|
19
|
+
})
|
|
20
|
+
}
|
|
17
21
|
|
|
18
22
|
it('decodes PushPayload with typed events', () => {
|
|
19
23
|
const payload = Api.PushPayload.make({ storeId: 's', batch: [] })
|
|
20
|
-
const decoded = Schema.
|
|
21
|
-
expect(decoded
|
|
24
|
+
const decoded = Schema.decodeResult(Api.PushPayload)(payload)
|
|
25
|
+
expect(Result.isSuccess(decoded)).toBe(true)
|
|
22
26
|
})
|
|
23
27
|
})
|
package/src/api-schema.ts
CHANGED
|
@@ -5,9 +5,9 @@ import { S2SeqNum } from './types.ts'
|
|
|
5
5
|
|
|
6
6
|
export const PullArgs = Schema.Struct({
|
|
7
7
|
storeId: Schema.String,
|
|
8
|
-
s2SeqNum: Schema.Union(S2SeqNum, Schema.Literal('from-start')),
|
|
8
|
+
s2SeqNum: Schema.Union([S2SeqNum, Schema.Literal('from-start')]),
|
|
9
9
|
live: Schema.Boolean,
|
|
10
|
-
payload: Schema.
|
|
10
|
+
payload: Schema.optional(Schema.Json),
|
|
11
11
|
})
|
|
12
12
|
|
|
13
13
|
export const PushPayload = Schema.Struct({
|
|
@@ -19,7 +19,7 @@ export type PullArgs = typeof PullArgs.Type
|
|
|
19
19
|
export type PushPayload = typeof PushPayload.Type
|
|
20
20
|
|
|
21
21
|
/** Encoded form for query parameter `args` */
|
|
22
|
-
export const ArgsSchema = Schema.
|
|
22
|
+
export const ArgsSchema = Schema.StringFromUriComponent.pipe(Schema.decodeTo(Schema.fromJsonString(PullArgs)))
|
|
23
23
|
|
|
24
24
|
export const PushResponse = Schema.Struct({ success: Schema.Boolean })
|
|
25
25
|
export type PushResponse = typeof PushResponse.Type
|
package/src/decode.ts
CHANGED
|
@@ -7,21 +7,21 @@ import { S2SeqNum } from './types.ts'
|
|
|
7
7
|
const ReadBatchSchema = Schema.Struct({
|
|
8
8
|
records: Schema.Array(
|
|
9
9
|
Schema.Struct({
|
|
10
|
-
body: Schema.optional(Schema.
|
|
10
|
+
body: Schema.optional(Schema.NullOr(Schema.fromJsonString(LiveStoreEvent.Global.Encoded))),
|
|
11
11
|
seq_num: S2SeqNum,
|
|
12
12
|
}),
|
|
13
13
|
),
|
|
14
|
-
}).
|
|
14
|
+
}).annotate({ title: '@livestore/sync-s2:ReadBatchSchema' })
|
|
15
15
|
|
|
16
16
|
export const decodeReadBatch = (
|
|
17
|
-
readBatch:
|
|
17
|
+
readBatch: HttpClientGenerated.ReadBatch,
|
|
18
18
|
): ReadonlyArray<{
|
|
19
19
|
eventEncoded: LiveStoreEvent.Global.Encoded
|
|
20
20
|
metadata: Option.Option<{ s2SeqNum: S2SeqNum }>
|
|
21
21
|
}> => {
|
|
22
22
|
const decoded = Schema.decodeSync(ReadBatchSchema)(readBatch)
|
|
23
23
|
return decoded.records
|
|
24
|
-
.filter((r): r is { body: LiveStoreEvent.Global.Encoded; seq_num: S2SeqNum } => r.body
|
|
24
|
+
.filter((r): r is { body: LiveStoreEvent.Global.Encoded; seq_num: S2SeqNum } => r.body != null)
|
|
25
25
|
.map((r) => ({
|
|
26
26
|
eventEncoded: r.body,
|
|
27
27
|
metadata: Option.some({ s2SeqNum: r.seq_num }),
|