@livestore/common 0.0.0-snapshot-3ea7644e665c5c8292d2309fb7f837b9146af912 → 0.0.0-snapshot-ba25981b6de87a90976fc39e1c2551844d384a05

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 (70) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/__tests__/fixture.d.ts +34 -46
  3. package/dist/__tests__/fixture.d.ts.map +1 -1
  4. package/dist/adapter-types.d.ts +1 -1
  5. package/dist/adapter-types.js +1 -1
  6. package/dist/derived-mutations.d.ts +4 -4
  7. package/dist/derived-mutations.d.ts.map +1 -1
  8. package/dist/derived-mutations.js.map +1 -1
  9. package/dist/devtools/devtools-messages.d.ts +45 -45
  10. package/dist/devtools/devtools-messages.js +1 -1
  11. package/dist/devtools/devtools-messages.js.map +1 -1
  12. package/dist/index.d.ts +0 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +0 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/mutation.d.ts +1 -1
  17. package/dist/mutation.d.ts.map +1 -1
  18. package/dist/mutation.js +1 -6
  19. package/dist/mutation.js.map +1 -1
  20. package/dist/query-info.d.ts +39 -29
  21. package/dist/query-info.d.ts.map +1 -1
  22. package/dist/query-info.js +35 -4
  23. package/dist/query-info.js.map +1 -1
  24. package/dist/schema/index.d.ts +2 -2
  25. package/dist/schema/index.d.ts.map +1 -1
  26. package/dist/schema/index.js +0 -1
  27. package/dist/schema/index.js.map +1 -1
  28. package/dist/schema/schema-helpers.d.ts +2 -2
  29. package/dist/schema/schema-helpers.d.ts.map +1 -1
  30. package/dist/schema/system-tables.d.ts +204 -246
  31. package/dist/schema/system-tables.d.ts.map +1 -1
  32. package/dist/schema/table-def.d.ts +24 -45
  33. package/dist/schema/table-def.d.ts.map +1 -1
  34. package/dist/schema/table-def.js +1 -10
  35. package/dist/schema/table-def.js.map +1 -1
  36. package/dist/version.d.ts +1 -1
  37. package/dist/version.d.ts.map +1 -1
  38. package/dist/version.js +1 -1
  39. package/dist/version.js.map +1 -1
  40. package/package.json +3 -3
  41. package/src/adapter-types.ts +1 -1
  42. package/src/derived-mutations.ts +8 -4
  43. package/src/devtools/devtools-messages.ts +1 -1
  44. package/src/index.ts +0 -1
  45. package/src/mutation.ts +2 -9
  46. package/src/query-info.ts +93 -66
  47. package/src/schema/index.ts +2 -4
  48. package/src/schema/schema-helpers.ts +2 -2
  49. package/src/schema/table-def.ts +68 -99
  50. package/src/version.ts +1 -1
  51. package/dist/query-builder/api.d.ts +0 -190
  52. package/dist/query-builder/api.d.ts.map +0 -1
  53. package/dist/query-builder/api.js +0 -8
  54. package/dist/query-builder/api.js.map +0 -1
  55. package/dist/query-builder/impl.d.ts +0 -12
  56. package/dist/query-builder/impl.d.ts.map +0 -1
  57. package/dist/query-builder/impl.js +0 -226
  58. package/dist/query-builder/impl.js.map +0 -1
  59. package/dist/query-builder/impl.test.d.ts +0 -2
  60. package/dist/query-builder/impl.test.d.ts.map +0 -1
  61. package/dist/query-builder/impl.test.js +0 -183
  62. package/dist/query-builder/impl.test.js.map +0 -1
  63. package/dist/query-builder/mod.d.ts +0 -10
  64. package/dist/query-builder/mod.d.ts.map +0 -1
  65. package/dist/query-builder/mod.js +0 -10
  66. package/dist/query-builder/mod.js.map +0 -1
  67. package/src/query-builder/api.ts +0 -288
  68. package/src/query-builder/impl.test.ts +0 -205
  69. package/src/query-builder/impl.ts +0 -268
  70. package/src/query-builder/mod.ts +0 -10
@@ -5,83 +5,76 @@ import { ReadonlyRecord, Schema } from '@livestore/utils/effect'
5
5
 
6
6
  import type { DerivedMutationHelperFns } from '../derived-mutations.js'
7
7
  import { makeDerivedMutationDefsForTable } from '../derived-mutations.js'
8
- import type { QueryBuilder } from '../query-builder/mod.js'
9
- import { makeQueryBuilder } from '../query-builder/mod.js'
10
8
 
11
9
  export const { blob, boolean, column, datetime, integer, isColumnDefinition, json, real, text } = SqliteDsl
12
10
 
13
- export { SqliteDsl } from '@livestore/db-schema'
11
+ export { type SqliteDsl } from '@livestore/db-schema'
14
12
 
15
13
  export type StateType = 'singleton' | 'dynamic'
16
14
 
17
15
  export type DefaultSqliteTableDef = SqliteDsl.TableDefinition<string, SqliteDsl.Columns>
18
16
  export type DefaultSqliteTableDefConstrained = SqliteDsl.TableDefinition<string, SqliteDsl.ConstraintColumns>
19
17
 
20
- export type TableDefBase<
21
- TSqliteDef extends DefaultSqliteTableDef = DefaultSqliteTableDefConstrained,
22
- TOptions extends TableOptions = TableOptions,
23
- TSchema = SqliteDsl.StructSchemaForColumns<TSqliteDef['columns']>,
24
- > = {
25
- sqliteDef: TSqliteDef
26
- options: TOptions
27
- // Derived from `sqliteDef`, so only exposed for convenience
28
- schema: TSchema
29
- }
18
+ // export type TableDefConstraint<
19
+ // TSqliteDef extends DefaultSqliteTableDef = DefaultSqliteTableDef,
20
+ // TIsSingleColumn extends boolean = boolean,
21
+ // TOptions extends TableOptions = TableOptions,
22
+ // > = TableDefBase<TSqliteDef, TIsSingleColumn, TOptions> & { schema: Schema.Schema<any> }
23
+
24
+ // /**
25
+ // * NOTE in the past we used to have a single `TableDef` but there are some TS issues when indroducing
26
+ // * `schema: SqliteDsl.StructSchemaForColumns<TSqliteDef>` so we split it into two types
27
+ // * and only use `TableDefConstraint` in some places
28
+ // */
29
+ // export type TableDefBase<
30
+ // TSqliteDef extends DefaultSqliteTableDef = DefaultSqliteTableDef,
31
+ // TIsSingleColumn extends boolean = boolean,
32
+ // TOptions extends TableOptions = TableOptions,
33
+ // > = {
34
+ // sqliteDef: TSqliteDef
35
+ // // schema: SqliteDsl.StructSchemaForColumns<TSqliteDef>
36
+ // // schema: any;
37
+ // isSingleColumn: TIsSingleColumn
38
+ // options: TOptions
39
+ // }
30
40
 
31
41
  export type TableDef<
32
42
  TSqliteDef extends DefaultSqliteTableDef = DefaultSqliteTableDefConstrained,
43
+ TIsSingleColumn extends boolean = boolean,
33
44
  TOptions extends TableOptions = TableOptions,
34
45
  // NOTE we're not using `SqliteDsl.StructSchemaForColumns<TSqliteDef['columns']>`
35
- // as we don't want the alias type for users to show up, so we're redefining it here
46
+ // as we don't want the alias type for users to show up
36
47
  TSchema = Schema.Schema<
37
48
  SqliteDsl.AnyIfConstained<
38
49
  TSqliteDef['columns'],
39
- { readonly [K in keyof TSqliteDef['columns']]: TSqliteDef['columns'][K]['schema']['Type'] }
50
+ { readonly [K in keyof TSqliteDef['columns']]: Schema.Schema.Type<TSqliteDef['columns'][K]['schema']> }
40
51
  >,
41
52
  SqliteDsl.AnyIfConstained<
42
53
  TSqliteDef['columns'],
43
- { readonly [K in keyof TSqliteDef['columns']]: TSqliteDef['columns'][K]['schema']['Encoded'] }
54
+ { readonly [K in keyof TSqliteDef['columns']]: Schema.Schema.Encoded<TSqliteDef['columns'][K]['schema']> }
44
55
  >
45
56
  >,
46
57
  > = {
47
58
  sqliteDef: TSqliteDef
59
+ // TODO move this into options (for now it's duplicated)
60
+ isSingleColumn: TIsSingleColumn
48
61
  options: TOptions
49
- // Derived from `sqliteDef`, so only exposed for convenience
50
62
  schema: TSchema
51
- query: QueryBuilder<ReadonlyArray<Schema.Schema.Type<TSchema>>, TableDef<TSqliteDef & {}, TOptions>>
52
63
  } & (TOptions['deriveMutations']['enabled'] extends true
53
64
  ? DerivedMutationHelperFns<TSqliteDef['columns'], TOptions>
54
65
  : {})
55
66
 
56
- export type TableOptionsInput = Partial<{
57
- indexes: SqliteDsl.Index[]
58
- disableAutomaticIdColumn: boolean
59
- isSingleton: boolean
60
- deriveMutations:
61
- | boolean
62
- | {
63
- enabled: true
64
- localOnly?: boolean
65
- }
66
- }>
67
-
68
- type ToColumns<TColumns extends SqliteDsl.Columns | SqliteDsl.ColumnDefinition<any, any>> =
69
- TColumns extends SqliteDsl.Columns
70
- ? TColumns
71
- : TColumns extends SqliteDsl.ColumnDefinition<any, any>
72
- ? { value: TColumns }
73
- : never
74
-
75
- type ValidateTableOptionsInput<
76
- TColumns extends SqliteDsl.Columns | SqliteDsl.ColumnDefinition<any, any>,
77
- TOptionsInput extends TableOptionsInput,
78
- TPassthroughIfValid,
79
- > =
80
- SqliteDsl.FromColumns.RequiresInsertValues<ToColumns<TColumns>> extends true
81
- ? TOptionsInput['isSingleton'] extends true
82
- ? 'Error: To use `isSingleton: true` with this table, each column must have a default value or be nullable'
83
- : TPassthroughIfValid
84
- : TPassthroughIfValid
67
+ export type TableOptionsInput = Partial<
68
+ Omit<TableOptions, 'isSingleColumn' | 'deriveMutations'> & {
69
+ indexes: SqliteDsl.Index[]
70
+ deriveMutations:
71
+ | boolean
72
+ | {
73
+ enabled: true
74
+ localOnly?: boolean
75
+ }
76
+ }
77
+ >
85
78
 
86
79
  export type TableOptions = {
87
80
  /**
@@ -92,10 +85,8 @@ export type TableOptions = {
92
85
  *
93
86
  * @default false
94
87
  */
95
- readonly isSingleton: boolean
96
-
97
- readonly disableAutomaticIdColumn: boolean
98
-
88
+ isSingleton: boolean
89
+ disableAutomaticIdColumn: boolean
99
90
  /**
100
91
  * Setting this to true will automatically derive insert, update and delete mutations for this table. Example:
101
92
  *
@@ -108,7 +99,7 @@ export type TableOptions = {
108
99
  *
109
100
  * Important: When using this option, make sure you're following the "Rules of mutations" for the table schema.
110
101
  */
111
- readonly deriveMutations:
102
+ deriveMutations:
112
103
  | { enabled: false }
113
104
  | {
114
105
  enabled: true
@@ -117,34 +108,30 @@ export type TableOptions = {
117
108
  */
118
109
  localOnly: boolean
119
110
  }
120
-
121
111
  /** Derived based on whether the table definition has one or more columns (besides the `id` column) */
122
- readonly isSingleColumn: boolean
123
-
124
- /**
125
- * Derived based on whether the table definition has one or more columns (besides the `id` column) that require
126
- * insert values (i.e. are not nullable and don't have a default value)
127
- *
128
- * `isSingleton` tables always imply `requiresInsertValues: false`
129
- */
130
- readonly requiredInsertColumnNames: string
112
+ isSingleColumn: boolean
131
113
  }
132
114
 
133
115
  export const table = <
134
116
  TName extends string,
135
117
  TColumns extends SqliteDsl.Columns | SqliteDsl.ColumnDefinition<any, any>,
136
- TOptionsInput extends TableOptionsInput = TableOptionsInput,
118
+ const TOptionsInput extends TableOptionsInput = TableOptionsInput,
137
119
  >(
138
120
  name: TName,
139
121
  columnOrColumns: TColumns,
140
122
  options?: TOptionsInput,
141
- ): ValidateTableOptionsInput<
142
- TColumns,
143
- TOptionsInput,
144
- TableDef<
145
- SqliteTableDefForInput<TName, TColumns, WithDefaults<TOptionsInput, TColumns>>,
146
- WithDefaults<TOptionsInput, TColumns>
147
- >
123
+ ): TableDef<
124
+ SqliteDsl.TableDefinition<
125
+ TName,
126
+ PrettifyFlat<
127
+ WithId<
128
+ TColumns extends SqliteDsl.Columns ? TColumns : { value: TColumns },
129
+ WithDefaults<TOptionsInput, SqliteDsl.IsSingleColumn<TColumns>>
130
+ >
131
+ >
132
+ >,
133
+ SqliteDsl.IsSingleColumn<TColumns>,
134
+ WithDefaults<TOptionsInput, SqliteDsl.IsSingleColumn<TColumns>>
148
135
  > => {
149
136
  const tablePath = name
150
137
 
@@ -160,7 +147,6 @@ export const table = <
160
147
  ? { enabled: false as const }
161
148
  : { enabled: true as const, localOnly: options.deriveMutations.localOnly ?? false },
162
149
  isSingleColumn: SqliteDsl.isColumnDefinition(columnOrColumns) === true,
163
- requiredInsertColumnNames: 'type-level-only',
164
150
  }
165
151
 
166
152
  const columns = (
@@ -197,14 +183,7 @@ export const table = <
197
183
  const isSingleColumn = SqliteDsl.isColumnDefinition(columnOrColumns) === true
198
184
 
199
185
  const schema = SqliteDsl.structSchemaForTable(sqliteDef)
200
- const tableDef = { sqliteDef, options: options_, schema } satisfies TableDefBase
201
- const query = makeQueryBuilder(tableDef)
202
- // const tableDef = { ...tableDefBase, query } satisfies TableDef
203
-
204
- // NOTE we're currently patching the existing tableDef object
205
- // as it's being used as part of the query builder API
206
- // @ts-expect-error TODO properly implement this
207
- tableDef.query = query
186
+ const tableDef = { sqliteDef, isSingleColumn, options: options_, schema } satisfies TableDef
208
187
 
209
188
  if (tableHasDerivedMutations(tableDef)) {
210
189
  const derivedMutationDefs = makeDerivedMutationDefsForTable(tableDef)
@@ -231,23 +210,17 @@ export const table = <
231
210
  return tableDef as any
232
211
  }
233
212
 
234
- export const tableHasDerivedMutations = <TTableDef extends TableDefBase>(
213
+ export const tableHasDerivedMutations = <TTableDef extends TableDef>(
235
214
  tableDef: TTableDef,
236
215
  ): tableDef is TTableDef & {
237
216
  options: { deriveMutations: { enabled: true; localOnly: boolean } }
238
217
  } & DerivedMutationHelperFns<TTableDef['sqliteDef']['columns'], TTableDef['options']> =>
239
218
  tableDef.options.deriveMutations.enabled === true
240
219
 
241
- export const tableIsSingleton = <TTableDef extends TableDefBase>(
220
+ export const tableIsSingleton = <TTableDef extends TableDef>(
242
221
  tableDef: TTableDef,
243
222
  ): tableDef is TTableDef & { options: { isSingleton: true } } => tableDef.options.isSingleton === true
244
223
 
245
- type SqliteTableDefForInput<
246
- TName extends string,
247
- TColumns extends SqliteDsl.Columns | SqliteDsl.ColumnDefinition<any, any>,
248
- TOptions extends TableOptions,
249
- > = SqliteDsl.TableDefinition<TName, PrettifyFlat<WithId<ToColumns<TColumns>, TOptions>>>
250
-
251
224
  type WithId<TColumns extends SqliteDsl.Columns, TOptions extends TableOptions> = TColumns &
252
225
  ('id' extends keyof TColumns
253
226
  ? {}
@@ -261,10 +234,7 @@ type WithId<TColumns extends SqliteDsl.Columns, TOptions extends TableOptions> =
261
234
  id: SqliteDsl.ColumnDefinition<string, string>
262
235
  })
263
236
 
264
- type WithDefaults<
265
- TOptionsInput extends TableOptionsInput,
266
- TColumns extends SqliteDsl.Columns | SqliteDsl.ColumnDefinition<any, any>,
267
- > = {
237
+ type WithDefaults<TOptionsInput extends TableOptionsInput, TIsSingleColumn extends boolean> = {
268
238
  isSingleton: TOptionsInput['isSingleton'] extends true ? true : false
269
239
  disableAutomaticIdColumn: TOptionsInput['disableAutomaticIdColumn'] extends true ? true : false
270
240
  deriveMutations: TOptionsInput['deriveMutations'] extends true
@@ -277,37 +247,36 @@ type WithDefaults<
277
247
  localOnly: TOptionsInput['deriveMutations']['localOnly'] extends true ? true : false
278
248
  }
279
249
  : never
280
- isSingleColumn: SqliteDsl.IsSingleColumn<TColumns>
281
- requiredInsertColumnNames: SqliteDsl.FromColumns.RequiredInsertColumnNames<ToColumns<TColumns>>
250
+ isSingleColumn: TIsSingleColumn
282
251
  }
283
252
 
284
253
  export namespace FromTable {
285
254
  // TODO this sometimes doesn't preserve the order of columns
286
- export type RowDecoded<TTableDef extends TableDefBase> = PrettifyFlat<
255
+ export type RowDecoded<TTableDef extends TableDef> = PrettifyFlat<
287
256
  Nullable<Pick<RowDecodedAll<TTableDef>, NullableColumnNames<TTableDef>>> &
288
257
  Omit<RowDecodedAll<TTableDef>, NullableColumnNames<TTableDef>>
289
258
  >
290
259
 
291
- export type NullableColumnNames<TTableDef extends TableDefBase> = FromColumns.NullableColumnNames<
260
+ export type NullableColumnNames<TTableDef extends TableDef> = FromColumns.NullableColumnNames<
292
261
  TTableDef['sqliteDef']['columns']
293
262
  >
294
263
 
295
- export type Columns<TTableDef extends TableDefBase> = {
264
+ export type Columns<TTableDef extends TableDef> = {
296
265
  [K in keyof TTableDef['sqliteDef']['columns']]: TTableDef['sqliteDef']['columns'][K]['columnType']
297
266
  }
298
267
 
299
- export type RowEncodeNonNullable<TTableDef extends TableDefBase> = {
268
+ export type RowEncodeNonNullable<TTableDef extends TableDef> = {
300
269
  [K in keyof TTableDef['sqliteDef']['columns']]: Schema.Schema.Encoded<
301
270
  TTableDef['sqliteDef']['columns'][K]['schema']
302
271
  >
303
272
  }
304
273
 
305
- export type RowEncoded<TTableDef extends TableDefBase> = PrettifyFlat<
274
+ export type RowEncoded<TTableDef extends TableDef> = PrettifyFlat<
306
275
  Nullable<Pick<RowEncodeNonNullable<TTableDef>, NullableColumnNames<TTableDef>>> &
307
276
  Omit<RowEncodeNonNullable<TTableDef>, NullableColumnNames<TTableDef>>
308
277
  >
309
278
 
310
- export type RowDecodedAll<TTableDef extends TableDefBase> = {
279
+ export type RowDecodedAll<TTableDef extends TableDef> = {
311
280
  [K in keyof TTableDef['sqliteDef']['columns']]: Schema.Schema.Type<TTableDef['sqliteDef']['columns'][K]['schema']>
312
281
  }
313
282
  }
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.2.0-dev.2' as const
5
+ export const liveStoreVersion = '0.1.0' as const
6
6
 
7
7
  /**
8
8
  * This version number is incremented whenever the internal storage format changes in a breaking way.
@@ -1,190 +0,0 @@
1
- import type { GetValForKey } from '@livestore/utils';
2
- import { type Option, type Schema } from '@livestore/utils/effect';
3
- import type { SessionIdSymbol } from '../adapter-types.js';
4
- import type { QueryInfo } from '../query-info.js';
5
- import type { DbSchema } from '../schema/index.js';
6
- import type { SqliteDsl } from '../schema/table-def.js';
7
- import type { SqlValue } from '../util.js';
8
- export type QueryBuilderAst = QueryBuilderAst.SelectQuery | QueryBuilderAst.CountQuery | QueryBuilderAst.RowQuery;
9
- export declare namespace QueryBuilderAst {
10
- type SelectQuery = {
11
- readonly _tag: 'SelectQuery';
12
- readonly columns: string[];
13
- readonly pickFirst: false | {
14
- fallback: () => any;
15
- };
16
- readonly select: {
17
- columns: ReadonlyArray<string>;
18
- };
19
- readonly orderBy: ReadonlyArray<OrderBy>;
20
- readonly offset: Option.Option<number>;
21
- readonly limit: Option.Option<number>;
22
- readonly tableDef: DbSchema.TableDefBase;
23
- readonly where: ReadonlyArray<QueryBuilderAst.Where>;
24
- readonly resultSchemaSingle: Schema.Schema<any>;
25
- };
26
- type CountQuery = {
27
- readonly _tag: 'CountQuery';
28
- readonly tableDef: DbSchema.TableDefBase;
29
- readonly where: ReadonlyArray<QueryBuilderAst.Where>;
30
- readonly resultSchema: Schema.Schema<number, ReadonlyArray<{
31
- count: number;
32
- }>>;
33
- };
34
- type RowQuery = {
35
- readonly _tag: 'RowQuery';
36
- readonly tableDef: DbSchema.TableDefBase;
37
- readonly id: string | SessionIdSymbol;
38
- readonly insertValues: Record<string, unknown>;
39
- };
40
- type Where = {
41
- readonly col: string;
42
- readonly op: QueryBuilder.WhereOps;
43
- readonly value: unknown;
44
- };
45
- type OrderBy = {
46
- readonly col: string;
47
- readonly direction: 'asc' | 'desc';
48
- };
49
- }
50
- export declare const QueryBuilderAstSymbol: unique symbol;
51
- export type QueryBuilderAstSymbol = typeof QueryBuilderAstSymbol;
52
- export declare const TypeId: unique symbol;
53
- export type TypeId = typeof TypeId;
54
- export declare const isQueryBuilder: (value: unknown) => value is QueryBuilder<any, any, any>;
55
- export type QueryBuilder<TResult, TTableDef extends DbSchema.TableDefBase,
56
- /** Used to gradually remove features from the API based on the query context */
57
- TWithout extends QueryBuilder.ApiFeature = never, TQueryInfo extends QueryInfo = QueryInfo.None> = {
58
- readonly [TypeId]: TypeId;
59
- readonly [QueryBuilderAstSymbol]: QueryBuilderAst;
60
- readonly asSql: () => {
61
- query: string;
62
- bindValues: SqlValue[];
63
- };
64
- readonly toString: () => string;
65
- } & Omit<QueryBuilder.ApiFull<TResult, TTableDef, TWithout, TQueryInfo>, TWithout>;
66
- export declare namespace QueryBuilder {
67
- type Any = QueryBuilder<any, any, any, any>;
68
- type WhereOps = WhereOps.Equality | WhereOps.Order | WhereOps.Like | WhereOps.In;
69
- namespace WhereOps {
70
- type Equality = '=' | '!=';
71
- type Order = '<' | '>' | '<=' | '>=';
72
- type Like = 'LIKE' | 'NOT LIKE' | 'ILIKE' | 'NOT ILIKE';
73
- type In = 'IN' | 'NOT IN';
74
- type SingleValue = Equality | Order | Like;
75
- type MultiValue = In;
76
- }
77
- type ApiFeature = 'select' | 'where' | 'count' | 'orderBy' | 'offset' | 'limit' | 'first' | 'row';
78
- type WhereParams<TTableDef extends DbSchema.TableDefBase> = Partial<{
79
- [K in keyof TTableDef['sqliteDef']['columns']]: TTableDef['sqliteDef']['columns'][K]['schema']['Type'] | {
80
- op: QueryBuilder.WhereOps.SingleValue;
81
- value: TTableDef['sqliteDef']['columns'][K]['schema']['Type'];
82
- } | {
83
- op: QueryBuilder.WhereOps.MultiValue;
84
- value: ReadonlyArray<TTableDef['sqliteDef']['columns'][K]['schema']['Type']>;
85
- } | undefined;
86
- }>;
87
- type OrderByParams<TTableDef extends DbSchema.TableDefBase> = ReadonlyArray<{
88
- col: keyof TTableDef['sqliteDef']['columns'] & string;
89
- direction: 'asc' | 'desc';
90
- }>;
91
- type ApiFull<TResult, TTableDef extends DbSchema.TableDefBase, TWithout extends ApiFeature, TQueryInfo extends QueryInfo> = {
92
- /**
93
- * `SELECT *` is the default
94
- *
95
- * Example:
96
- * ```ts
97
- * db.todos.select('id', 'text', 'completed')
98
- * db.todos.select('id', { pluck: true })
99
- * ```
100
- */
101
- readonly select: {
102
- <TColumn extends keyof TTableDef['sqliteDef']['columns'] & string, TPluck extends boolean = false>(column: TColumn, options?: {
103
- pluck: TPluck;
104
- }): QueryBuilder<TPluck extends true ? ReadonlyArray<TTableDef['sqliteDef']['columns'][TColumn]['schema']['Type']> : ReadonlyArray<{
105
- readonly [K in TColumn]: TTableDef['sqliteDef']['columns'][K]['schema']['Type'];
106
- }>, TTableDef, TWithout | 'row' | 'select', TQueryInfo>;
107
- <TColumns extends keyof TTableDef['sqliteDef']['columns'] & string>(...columns: TColumns[]): QueryBuilder<ReadonlyArray<{
108
- readonly [K in TColumns]: TTableDef['sqliteDef']['columns'][K]['schema']['Type'];
109
- }>, TTableDef, TWithout | 'row' | 'select' | 'count', TQueryInfo>;
110
- };
111
- /**
112
- * Notes:
113
- * - All where clauses are `AND`ed together by default.
114
- * - `null` values only support `=` and `!=` which is translated to `IS NULL` and `IS NOT NULL`.
115
- *
116
- * Example:
117
- * ```ts
118
- * db.todos.where('completed', true)
119
- * db.todos.where('completed', '!=', true)
120
- * db.todos.where({ completed: true })
121
- * db.todos.where({ completed: { op: '!=', value: true } })
122
- * ```
123
- *
124
- * TODO: Also support `OR`
125
- */
126
- readonly where: {
127
- <TParams extends QueryBuilder.WhereParams<TTableDef>>(params: TParams): QueryBuilder<TResult, TTableDef, TWithout | 'row' | 'select', TQueryInfo>;
128
- <TColName extends keyof TTableDef['sqliteDef']['columns']>(col: TColName, value: TTableDef['sqliteDef']['columns'][TColName]['schema']['Type']): QueryBuilder<TResult, TTableDef, TWithout | 'row' | 'select', TQueryInfo>;
129
- <TColName extends keyof TTableDef['sqliteDef']['columns']>(col: TColName, op: QueryBuilder.WhereOps, value: TTableDef['sqliteDef']['columns'][TColName]['schema']['Type']): QueryBuilder<TResult, TTableDef, TWithout | 'row' | 'select', TQueryInfo>;
130
- };
131
- /**
132
- * Example:
133
- * ```ts
134
- * db.todos.count()
135
- * db.todos.count().where('completed', true)
136
- * ```
137
- */
138
- readonly count: () => QueryBuilder<number, TTableDef, TWithout | 'row' | 'count' | 'select' | 'orderBy' | 'first' | 'offset' | 'limit', TQueryInfo>;
139
- /**
140
- * Example:
141
- * ```ts
142
- * db.todos.orderBy('createdAt', 'desc')
143
- * ```
144
- */
145
- readonly orderBy: {
146
- <TColName extends keyof TTableDef['sqliteDef']['columns'] & string>(col: TColName, direction: 'asc' | 'desc'): QueryBuilder<TResult, TTableDef, TWithout, TQueryInfo>;
147
- <TParams extends QueryBuilder.OrderByParams<TTableDef>>(params: TParams): QueryBuilder<TResult, TTableDef, TWithout, TQueryInfo>;
148
- };
149
- /**
150
- * Example:
151
- * ```ts
152
- * db.todos.offset(10)
153
- * ```
154
- */
155
- readonly offset: (offset: number) => QueryBuilder<TResult, TTableDef, TWithout | 'row' | 'offset' | 'orderBy', TQueryInfo>;
156
- /**
157
- * Example:
158
- * ```ts
159
- * db.todos.limit(10)
160
- * ```
161
- */
162
- readonly limit: (limit: number) => QueryBuilder<TResult, TTableDef, TWithout | 'row' | 'limit' | 'offset' | 'first' | 'orderBy', TQueryInfo>;
163
- /**
164
- * Example:
165
- * ```ts
166
- * db.todos.first()
167
- * ```
168
- */
169
- readonly first: <TFallback extends GetSingle<TResult> = never>(options?: {
170
- fallback?: () => TFallback;
171
- }) => QueryBuilder<TFallback | GetSingle<TResult>, TTableDef, TWithout | 'row' | 'first' | 'orderBy' | 'select' | 'limit' | 'offset' | 'where', TQueryInfo>;
172
- /**
173
- *
174
- */
175
- readonly row: TTableDef['options']['isSingleton'] extends true ? () => QueryBuilder<RowQuery.Result<TTableDef>, TTableDef, QueryBuilder.ApiFeature, QueryInfo.Row> : TTableDef['options']['deriveMutations']['enabled'] extends false ? (_: 'Error: Need to enable deriveMutations to use row()') => any : TTableDef['options']['requiredInsertColumnNames'] extends never ? (id: string | SessionIdSymbol) => QueryBuilder<RowQuery.Result<TTableDef>, TTableDef, QueryBuilder.ApiFeature, QueryInfo.Row> : <TOptions extends RowQuery.RequiredColumnsOptions<TTableDef>>(id: string | SessionIdSymbol, opts: TOptions) => QueryBuilder<RowQuery.Result<TTableDef>, TTableDef, QueryBuilder.ApiFeature, QueryInfo.Row>;
176
- };
177
- }
178
- export declare namespace RowQuery {
179
- type RequiredColumnsOptions<TTableDef extends DbSchema.TableDefBase> = {
180
- /**
181
- * Values to be inserted into the row if it doesn't exist yet
182
- */
183
- insertValues: Pick<SqliteDsl.FromColumns.RowDecodedAll<TTableDef['sqliteDef']['columns']>, SqliteDsl.FromColumns.RequiredInsertColumnNames<Omit<TTableDef['sqliteDef']['columns'], 'id'>>>;
184
- };
185
- type Result<TTableDef extends DbSchema.TableDefBase> = TTableDef['options']['isSingleColumn'] extends true ? GetValForKey<SqliteDsl.FromColumns.RowDecoded<TTableDef['sqliteDef']['columns']>, 'value'> : SqliteDsl.FromColumns.RowDecoded<TTableDef['sqliteDef']['columns']>;
186
- type ResultEncoded<TTableDef extends DbSchema.TableDefBase> = TTableDef['options']['isSingleColumn'] extends true ? GetValForKey<SqliteDsl.FromColumns.RowEncoded<TTableDef['sqliteDef']['columns']>, 'value'> : SqliteDsl.FromColumns.RowEncoded<TTableDef['sqliteDef']['columns']>;
187
- }
188
- type GetSingle<T> = T extends ReadonlyArray<infer U> ? U : never;
189
- export {};
190
- //# sourceMappingURL=api.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/query-builder/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,KAAK,MAAM,EAAa,KAAK,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAE7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,MAAM,MAAM,eAAe,GAAG,eAAe,CAAC,WAAW,GAAG,eAAe,CAAC,UAAU,GAAG,eAAe,CAAC,QAAQ,CAAA;AAEjH,yBAAiB,eAAe,CAAC;IAC/B,KAAY,WAAW,GAAG;QACxB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;QAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAA;QAC1B,QAAQ,CAAC,SAAS,EAAE,KAAK,GAAG;YAAE,QAAQ,EAAE,MAAM,GAAG,CAAA;SAAE,CAAA;QACnD,QAAQ,CAAC,MAAM,EAAE;YACf,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;SAC/B,CAAA;QACD,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;QACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACrC,QAAQ,CAAC,Q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CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IAEvE,KAAY,aAAa,CAAC,SAAS,SAAS,QAAQ,CAAC,YAAY,IAC/D,SAAS,CAAC,SAAS,CAAC,CAAC,gBAAgB,CAAC,SAAS,IAAI,GAC/C,YAAY,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,GAC1F,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;CAC1E;AAED,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA"}
@@ -1,8 +0,0 @@
1
- import { Predicate } from '@livestore/utils/effect';
2
- export const QueryBuilderAstSymbol = Symbol.for('QueryBuilderAst');
3
- export const TypeId = Symbol.for('QueryBuilder');
4
- export const isQueryBuilder = (value) => Predicate.hasProperty(value, TypeId);
5
- // export type QueryBuilderParamRef = { _tag: 'QueryBuilderParamRef' }
6
- // export type QueryBuilderSelectParams = { [key: string]: QueryBuilderSelectParam }
7
- // export type QueryBuilderSelectParam = boolean | ((ref: QueryBuilderParamRef) => QueryBuilder<any, any>)
8
- //# sourceMappingURL=api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/query-builder/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,SAAS,EAAe,MAAM,yBAAyB,CAAA;AAoD7E,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;AAElE,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;AAGhD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAc,EAAwC,EAAE,CACrF,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AAkOtC,sEAAsE;AACtE,oFAAoF;AACpF,0GAA0G"}
@@ -1,12 +0,0 @@
1
- import { Schema } from '@livestore/utils/effect';
2
- import type { QueryInfo } from '../query-info.js';
3
- import type { DbSchema } from '../schema/index.js';
4
- import type { QueryBuilder, QueryBuilderAst } from './api.js';
5
- export declare const makeQueryBuilder: <TResult, TTableDef extends DbSchema.TableDefBase>(tableDef: TTableDef, ast?: QueryBuilderAst) => QueryBuilder<TResult, TTableDef, never, QueryInfo.None>;
6
- export declare const invalidQueryBuilder: (msg?: string) => never;
7
- export declare const getResultSchema: (qb: QueryBuilder<any, any, any>) => Schema.Array$<Schema.Schema<any, any, never>> | Schema.SchemaClass<any, readonly any[], never> | Schema.SchemaClass<number, readonly {
8
- readonly count: number;
9
- }[], never> | Schema.SchemaClass<any, readonly {
10
- readonly value: any;
11
- }[], never>;
12
- //# sourceMappingURL=impl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"impl.d.ts","sourceRoot":"","sources":["../../src/query-builder/impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAG7D,eAAO,MAAM,gBAAgB,GAAI,OAAO,EAAE,SAAS,SAAS,QAAQ,CAAC,YAAY,YACrE,SAAS,QACd,eAAe,KACnB,YAAY,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,CAqJxD,CAAA;AAsFD,eAAO,MAAM,mBAAmB,SAAU,MAAM,UAE/C,CAAA;AAED,eAAO,MAAM,eAAe,OAAQ,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;;;;WAkB9D,CAAA"}