@livestore/common 0.3.0-dev.29 → 0.3.0-dev.30
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/devtools/devtools-messages-client-session.d.ts +21 -21
- package/dist/devtools/devtools-messages-common.d.ts +6 -6
- package/dist/devtools/devtools-messages-leader.d.ts +24 -24
- package/dist/query-builder/api.d.ts +1 -1
- package/dist/query-builder/api.d.ts.map +1 -1
- package/dist/query-builder/impl.d.ts.map +1 -1
- package/dist/query-builder/impl.js +11 -5
- package/dist/query-builder/impl.js.map +1 -1
- package/dist/query-builder/impl.test.d.ts.map +1 -1
- package/dist/query-builder/impl.test.js +155 -130
- package/dist/query-builder/impl.test.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/src/query-builder/api.ts +1 -1
- package/src/query-builder/impl.test.ts +165 -143
- package/src/query-builder/impl.ts +11 -6
- package/src/version.ts +1 -1
@@ -144,8 +144,7 @@ export const makeQueryBuilder = <TResult, TTableDef extends State.SQLite.TableDe
|
|
144
144
|
return makeQueryBuilder(tableDef, {
|
145
145
|
...ast,
|
146
146
|
limit: Option.some(1),
|
147
|
-
|
148
|
-
pickFirst: options?.fallback ? { fallback: options.fallback } : { fallback: () => undefined },
|
147
|
+
pickFirst: options?.fallback ? { fallback: options.fallback } : 'no-fallback',
|
149
148
|
})
|
150
149
|
},
|
151
150
|
// // eslint-disable-next-line prefer-arrow/prefer-arrow-functions
|
@@ -309,11 +308,17 @@ export const getResultSchema = (qb: QueryBuilder<any, any, any>): Schema.Schema<
|
|
309
308
|
switch (queryAst._tag) {
|
310
309
|
case 'SelectQuery': {
|
311
310
|
const arraySchema = Schema.Array(queryAst.resultSchemaSingle)
|
312
|
-
if (queryAst.pickFirst
|
313
|
-
return arraySchema
|
311
|
+
if (queryAst.pickFirst === false) {
|
312
|
+
return arraySchema
|
313
|
+
} else if (queryAst.pickFirst === 'no-fallback') {
|
314
|
+
// Will throw if the array is empty
|
315
|
+
return arraySchema.pipe(Schema.headOrElse())
|
316
|
+
} else {
|
317
|
+
const fallbackValue = queryAst.pickFirst.fallback()
|
318
|
+
return Schema.Union(arraySchema, Schema.Tuple(Schema.Literal(fallbackValue))).pipe(
|
319
|
+
Schema.headOrElse(() => fallbackValue),
|
320
|
+
)
|
314
321
|
}
|
315
|
-
|
316
|
-
return arraySchema
|
317
322
|
}
|
318
323
|
case 'CountQuery': {
|
319
324
|
return Schema.Struct({ count: Schema.Number }).pipe(Schema.pluck('count'), Schema.Array, Schema.headOrElse())
|
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.
|
5
|
+
export const liveStoreVersion = '0.3.0-dev.30' as const
|
6
6
|
|
7
7
|
/**
|
8
8
|
* This version number is incremented whenever the internal storage format changes in a breaking way.
|