@livestore/livestore 0.0.41-dev.0 → 0.0.41-dev.2
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/__tests__/react/fixture.d.ts +51 -51
- package/dist/__tests__/react/fixture.d.ts.map +1 -1
- package/dist/effect/LiveStore.d.ts +6 -6
- package/dist/effect/LiveStore.d.ts.map +1 -1
- package/dist/effect/LiveStore.js +2 -2
- package/dist/effect/LiveStore.js.map +1 -1
- package/dist/react/useRow.d.ts.map +1 -1
- package/dist/react/useRow.js +3 -2
- package/dist/react/useRow.js.map +1 -1
- package/dist/react/useTemporaryQuery.d.ts.map +1 -1
- package/dist/react/useTemporaryQuery.js +3 -2
- package/dist/react/useTemporaryQuery.js.map +1 -1
- package/dist/react/useTemporaryQuery.test.d.ts +2 -0
- package/dist/react/useTemporaryQuery.test.d.ts.map +1 -0
- package/dist/react/useTemporaryQuery.test.js +33 -0
- package/dist/react/useTemporaryQuery.test.js.map +1 -0
- package/dist/react/utils/useCleanup.d.ts +7 -0
- package/dist/react/utils/useCleanup.d.ts.map +1 -0
- package/dist/react/utils/useCleanup.js +19 -0
- package/dist/react/utils/useCleanup.js.map +1 -0
- package/dist/reactiveQueries/graphql.d.ts +1 -1
- package/dist/reactiveQueries/graphql.d.ts.map +1 -1
- package/dist/reactiveQueries/graphql.js.map +1 -1
- package/dist/reactiveQueries/sql.d.ts +1 -1
- package/dist/reactiveQueries/sql.d.ts.map +1 -1
- package/dist/reactiveQueries/sql.js.map +1 -1
- package/dist/schema/mutations.d.ts +5 -5
- package/dist/schema/mutations.d.ts.map +1 -1
- package/dist/schema/mutations.js.map +1 -1
- package/dist/schema/system-tables.d.ts +10 -10
- package/dist/schema/system-tables.d.ts.map +1 -1
- package/dist/schema/table-def.d.ts +10 -10
- package/dist/schema/table-def.d.ts.map +1 -1
- package/dist/schema/table-def.js.map +1 -1
- package/package.json +7 -7
- package/src/effect/LiveStore.ts +10 -10
- package/src/react/useRow.ts +4 -4
- package/src/react/useTemporaryQuery.test.tsx +51 -0
- package/src/react/useTemporaryQuery.ts +4 -4
- package/src/react/utils/useCleanup.ts +25 -0
- package/src/reactiveQueries/graphql.ts +2 -2
- package/src/reactiveQueries/sql.ts +2 -2
- package/src/schema/mutations.ts +4 -5
- package/src/schema/table-def.ts +3 -4
|
@@ -14,7 +14,7 @@ import { LiveStoreQueryBase, makeGetAtomResult } from './base-class.js'
|
|
|
14
14
|
|
|
15
15
|
export type MapRows<TResult, TRaw = any> =
|
|
16
16
|
| ((rows: ReadonlyArray<TRaw>) => TResult)
|
|
17
|
-
| Schema.Schema<
|
|
17
|
+
| Schema.Schema<TResult, ReadonlyArray<TRaw>>
|
|
18
18
|
|
|
19
19
|
export const querySQL = <TResult, TRaw = any>(
|
|
20
20
|
query: string | ((get: GetAtomResult) => string),
|
|
@@ -96,7 +96,7 @@ export class LiveStoreSQLQuery<TResult, TQueryInfo extends QueryInfo = QueryInfo
|
|
|
96
96
|
? (rows: any) => rows as TResult
|
|
97
97
|
: Schema.isSchema(map)
|
|
98
98
|
? (rows: any) => {
|
|
99
|
-
const parseResult = Schema.decodeEither(map as Schema.Schema<
|
|
99
|
+
const parseResult = Schema.decodeEither(map as Schema.Schema<TResult, ReadonlyArray<any>>)(rows)
|
|
100
100
|
if (parseResult._tag === 'Left') {
|
|
101
101
|
console.error(`Error parsing SQL query result: ${TreeFormatter.formatError(parseResult.left)}`)
|
|
102
102
|
return shouldNeverHappen(`Error parsing SQL query result: ${parseResult.left}`)
|
package/src/schema/mutations.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type InternalMutationSchema<TRecord extends MutationDefRecord = MutationD
|
|
|
19
19
|
|
|
20
20
|
export type MutationDef<TName extends string, TFrom, TTo> = {
|
|
21
21
|
name: TName
|
|
22
|
-
schema: Schema.Schema<
|
|
22
|
+
schema: Schema.Schema<TTo, TFrom>
|
|
23
23
|
sql:
|
|
24
24
|
| string
|
|
25
25
|
| ((args: TTo) =>
|
|
@@ -42,7 +42,7 @@ export namespace MutationDef {
|
|
|
42
42
|
// TODO possibly also allow for mutation event subsumption behaviour
|
|
43
43
|
export const defineMutation = <TName extends string, TFrom, TTo>(
|
|
44
44
|
name: TName,
|
|
45
|
-
schema: Schema.Schema<
|
|
45
|
+
schema: Schema.Schema<TTo, TFrom>,
|
|
46
46
|
sql: string | ((args: TTo) => string | { sql: string; bindValues: BindValues; writeTables?: ReadonlySet<string> }),
|
|
47
47
|
): MutationDef<TName, TFrom, TTo> => {
|
|
48
48
|
const makeEvent = (args: TTo) => ({ mutation: name, args, id: cuid() })
|
|
@@ -98,18 +98,17 @@ export namespace MutationEvent {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
export type MutationEventSchema<TMutationsDefRecord extends MutationDefRecord> = Schema.Schema<
|
|
101
|
-
never,
|
|
102
101
|
{
|
|
103
102
|
[K in keyof TMutationsDefRecord]: {
|
|
104
103
|
mutation: K
|
|
105
|
-
args: Schema.Schema.
|
|
104
|
+
args: Schema.Schema.To<TMutationsDefRecord[K]['schema']>
|
|
106
105
|
id: string
|
|
107
106
|
}
|
|
108
107
|
}[keyof TMutationsDefRecord],
|
|
109
108
|
{
|
|
110
109
|
[K in keyof TMutationsDefRecord]: {
|
|
111
110
|
mutation: K
|
|
112
|
-
args: Schema.Schema.
|
|
111
|
+
args: Schema.Schema.From<TMutationsDefRecord[K]['schema']>
|
|
113
112
|
id: string
|
|
114
113
|
}
|
|
115
114
|
}[keyof TMutationsDefRecord]
|
package/src/schema/table-def.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type DefaultSqliteTableDefConstrained = SqliteDsl.TableDefinition<string,
|
|
|
18
18
|
// TSqliteDef extends DefaultSqliteTableDef = DefaultSqliteTableDef,
|
|
19
19
|
// TIsSingleColumn extends boolean = boolean,
|
|
20
20
|
// TOptions extends TableOptions = TableOptions,
|
|
21
|
-
// > = TableDefBase<TSqliteDef, TIsSingleColumn, TOptions> & { schema: Schema.Schema<
|
|
21
|
+
// > = TableDefBase<TSqliteDef, TIsSingleColumn, TOptions> & { schema: Schema.Schema<any> }
|
|
22
22
|
|
|
23
23
|
// /**
|
|
24
24
|
// * NOTE in the past we used to have a single `TableDef` but there are some TS issues when indroducing
|
|
@@ -44,14 +44,13 @@ export type TableDef<
|
|
|
44
44
|
// NOTE we're not using `SqliteDsl.StructSchemaForColumns<TSqliteDef['columns']>`
|
|
45
45
|
// as we don't want the alias type for users to show up
|
|
46
46
|
TSchema = Schema.Schema<
|
|
47
|
-
never,
|
|
48
47
|
SqliteDsl.AnyIfConstained<
|
|
49
48
|
TSqliteDef['columns'],
|
|
50
|
-
{ readonly [K in keyof TSqliteDef['columns']]: Schema.Schema.
|
|
49
|
+
{ readonly [K in keyof TSqliteDef['columns']]: Schema.Schema.To<TSqliteDef['columns'][K]['schema']> }
|
|
51
50
|
>,
|
|
52
51
|
SqliteDsl.AnyIfConstained<
|
|
53
52
|
TSqliteDef['columns'],
|
|
54
|
-
{ readonly [K in keyof TSqliteDef['columns']]: Schema.Schema.
|
|
53
|
+
{ readonly [K in keyof TSqliteDef['columns']]: Schema.Schema.From<TSqliteDef['columns'][K]['schema']> }
|
|
55
54
|
>
|
|
56
55
|
>,
|
|
57
56
|
> = {
|