@livestore/sync-s2 0.4.0 → 0.5.0-dev.0
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 +3 -3
- package/dist/api-schema.js.map +1 -1
- package/dist/api-schema.test.js +15 -10
- package/dist/api-schema.test.js.map +1 -1
- package/dist/decode.js +3 -3
- 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 +223 -220
- 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 +8 -9
- package/dist/limits.js.map +1 -1
- package/dist/limits.test.js.map +1 -1
- package/dist/make-s2-url.js +4 -4
- package/dist/make-s2-url.js.map +1 -1
- package/dist/sync-provider.d.ts +3 -3
- package/dist/sync-provider.d.ts.map +1 -1
- package/dist/sync-provider.js +8 -7
- 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 +29 -48
- package/src/api-schema.test.ts +15 -11
- package/src/api-schema.ts +3 -3
- package/src/decode.ts +3 -3
- package/src/http-client-generated.ts +166 -258
- package/src/limits.test.ts +1 -2
- package/src/limits.ts +17 -19
- package/src/make-s2-url.ts +4 -4
- package/src/sync-provider.ts +13 -12
- package/src/types.ts +1 -1
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,11 +7,11 @@ 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
17
|
readBatch: typeof HttpClientGenerated.ReadBatch.Type,
|
|
@@ -21,7 +21,7 @@ export const decodeReadBatch = (
|
|
|
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 }),
|