@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.
Files changed (45) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/__tests__/react/fixture.d.ts +51 -51
  3. package/dist/__tests__/react/fixture.d.ts.map +1 -1
  4. package/dist/effect/LiveStore.d.ts +6 -6
  5. package/dist/effect/LiveStore.d.ts.map +1 -1
  6. package/dist/effect/LiveStore.js +2 -2
  7. package/dist/effect/LiveStore.js.map +1 -1
  8. package/dist/react/useRow.d.ts.map +1 -1
  9. package/dist/react/useRow.js +3 -2
  10. package/dist/react/useRow.js.map +1 -1
  11. package/dist/react/useTemporaryQuery.d.ts.map +1 -1
  12. package/dist/react/useTemporaryQuery.js +3 -2
  13. package/dist/react/useTemporaryQuery.js.map +1 -1
  14. package/dist/react/useTemporaryQuery.test.d.ts +2 -0
  15. package/dist/react/useTemporaryQuery.test.d.ts.map +1 -0
  16. package/dist/react/useTemporaryQuery.test.js +33 -0
  17. package/dist/react/useTemporaryQuery.test.js.map +1 -0
  18. package/dist/react/utils/useCleanup.d.ts +7 -0
  19. package/dist/react/utils/useCleanup.d.ts.map +1 -0
  20. package/dist/react/utils/useCleanup.js +19 -0
  21. package/dist/react/utils/useCleanup.js.map +1 -0
  22. package/dist/reactiveQueries/graphql.d.ts +1 -1
  23. package/dist/reactiveQueries/graphql.d.ts.map +1 -1
  24. package/dist/reactiveQueries/graphql.js.map +1 -1
  25. package/dist/reactiveQueries/sql.d.ts +1 -1
  26. package/dist/reactiveQueries/sql.d.ts.map +1 -1
  27. package/dist/reactiveQueries/sql.js.map +1 -1
  28. package/dist/schema/mutations.d.ts +5 -5
  29. package/dist/schema/mutations.d.ts.map +1 -1
  30. package/dist/schema/mutations.js.map +1 -1
  31. package/dist/schema/system-tables.d.ts +10 -10
  32. package/dist/schema/system-tables.d.ts.map +1 -1
  33. package/dist/schema/table-def.d.ts +10 -10
  34. package/dist/schema/table-def.d.ts.map +1 -1
  35. package/dist/schema/table-def.js.map +1 -1
  36. package/package.json +7 -7
  37. package/src/effect/LiveStore.ts +10 -10
  38. package/src/react/useRow.ts +4 -4
  39. package/src/react/useTemporaryQuery.test.tsx +51 -0
  40. package/src/react/useTemporaryQuery.ts +4 -4
  41. package/src/react/utils/useCleanup.ts +25 -0
  42. package/src/reactiveQueries/graphql.ts +2 -2
  43. package/src/reactiveQueries/sql.ts +2 -2
  44. package/src/schema/mutations.ts +4 -5
  45. 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<never, ReadonlyArray<TRaw>, TResult>
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<never, ReadonlyArray<any>, TResult>)(rows)
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}`)
@@ -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<never, TFrom, TTo>
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<never, TFrom, TTo>,
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.From<TMutationsDefRecord[K]['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.To<TMutationsDefRecord[K]['schema']>
111
+ args: Schema.Schema.From<TMutationsDefRecord[K]['schema']>
113
112
  id: string
114
113
  }
115
114
  }[keyof TMutationsDefRecord]
@@ -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<never, any, any> }
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.From<TSqliteDef['columns'][K]['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.To<TSqliteDef['columns'][K]['schema']> }
53
+ { readonly [K in keyof TSqliteDef['columns']]: Schema.Schema.From<TSqliteDef['columns'][K]['schema']> }
55
54
  >
56
55
  >,
57
56
  > = {