@livestore/common 0.3.2-dev.1 → 0.3.2-dev.6
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/schema/EventDef.d.ts +178 -132
- package/dist/schema/EventDef.d.ts.map +1 -1
- package/dist/schema/EventDef.js +0 -15
- package/dist/schema/EventDef.js.map +1 -1
- package/dist/schema/schema.d.ts +1 -5
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/schema/schema.js +0 -2
- package/dist/schema/schema.js.map +1 -1
- package/dist/schema/state/sqlite/client-document-def.d.ts +12 -0
- package/dist/schema/state/sqlite/client-document-def.d.ts.map +1 -1
- package/dist/schema/state/sqlite/client-document-def.js +12 -0
- package/dist/schema/state/sqlite/client-document-def.js.map +1 -1
- package/dist/schema/state/sqlite/db-schema/dsl/mod.d.ts +165 -65
- package/dist/schema/state/sqlite/mod.d.ts +1 -1
- package/dist/schema/state/sqlite/mod.d.ts.map +1 -1
- package/dist/schema/state/sqlite/mod.js +0 -2
- package/dist/schema/state/sqlite/mod.js.map +1 -1
- package/dist/schema/state/sqlite/query-builder/api.d.ts +560 -307
- package/dist/schema/state/sqlite/table-def.d.ts +152 -70
- package/dist/sql-queries/types.d.ts +133 -37
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +10 -49
- package/src/schema/EventDef.ts +1 -21
- package/src/schema/schema.ts +3 -6
- package/src/schema/state/sqlite/client-document-def.ts +12 -0
- package/src/schema/state/sqlite/mod.ts +1 -3
- package/src/version.ts +1 -1
@@ -1,84 +1,166 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
3
|
-
import { SqliteDsl } from
|
4
|
-
import type { QueryBuilder } from
|
5
|
-
export declare const blob: SqliteDsl.ColDefFn<"blob">,
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
import type { Schema, Types } from "@livestore/utils/effect";
|
2
|
+
import type { Nullable } from "../../../../../utils/dist/mod.ts";
|
3
|
+
import type { SqliteDsl } from "./db-schema/mod.ts";
|
4
|
+
import type { QueryBuilder } from "./query-builder/mod.ts";
|
5
|
+
export declare const blob: SqliteDsl.ColDefFn<"blob">,
|
6
|
+
boolean: SqliteDsl.SpecializedColDefFn<"integer", false, boolean>,
|
7
|
+
column: <TColumnType extends SqliteDsl.FieldColumnType>(
|
8
|
+
columnType: TColumnType,
|
9
|
+
) => SqliteDsl.ColDefFn<TColumnType>,
|
10
|
+
datetime: SqliteDsl.SpecializedColDefFn<"text", false, Date>,
|
11
|
+
integer: SqliteDsl.ColDefFn<"integer">,
|
12
|
+
isColumnDefinition: (
|
13
|
+
value: unknown,
|
14
|
+
) => value is SqliteDsl.ColumnDefinition<any, any>,
|
15
|
+
json: SqliteDsl.SpecializedColDefFn<"text", true, unknown>,
|
16
|
+
real: SqliteDsl.ColDefFn<"real">,
|
17
|
+
text: SqliteDsl.ColDefFn<"text">;
|
18
|
+
export type StateType = "singleton" | "dynamic";
|
19
|
+
export type DefaultSqliteTableDef = SqliteDsl.TableDefinition<
|
20
|
+
string,
|
21
|
+
SqliteDsl.Columns
|
22
|
+
>;
|
23
|
+
export type DefaultSqliteTableDefConstrained = SqliteDsl.TableDefinition<
|
24
|
+
string,
|
25
|
+
SqliteDsl.ConstraintColumns
|
26
|
+
>;
|
9
27
|
export declare const TableDefInternalsSymbol: unique symbol;
|
10
28
|
export type TableDefInternalsSymbol = typeof TableDefInternalsSymbol;
|
11
|
-
export type TableDefBase<
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
29
|
+
export type TableDefBase<
|
30
|
+
TSqliteDef extends DefaultSqliteTableDef = DefaultSqliteTableDefConstrained,
|
31
|
+
TOptions extends TableOptions = TableOptions,
|
32
|
+
> = {
|
33
|
+
sqliteDef: TSqliteDef;
|
34
|
+
options: TOptions;
|
35
|
+
rowSchema: SqliteDsl.StructSchemaForColumns<TSqliteDef["columns"]>;
|
36
|
+
insertSchema: SqliteDsl.InsertStructSchemaForColumns<TSqliteDef["columns"]>;
|
16
37
|
};
|
17
|
-
export type TableDef<
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
38
|
+
export type TableDef<
|
39
|
+
TSqliteDef extends DefaultSqliteTableDef = DefaultSqliteTableDefConstrained,
|
40
|
+
TOptions extends TableOptions = TableOptions,
|
41
|
+
TSchema = Schema.Schema<
|
42
|
+
SqliteDsl.AnyIfConstained<
|
43
|
+
TSqliteDef["columns"],
|
44
|
+
{
|
45
|
+
readonly [K in keyof TSqliteDef["columns"]]: TSqliteDef["columns"][K]["schema"]["Type"];
|
46
|
+
}
|
47
|
+
>,
|
48
|
+
SqliteDsl.AnyIfConstained<
|
49
|
+
TSqliteDef["columns"],
|
50
|
+
{
|
51
|
+
readonly [K in keyof TSqliteDef["columns"]]: TSqliteDef["columns"][K]["schema"]["Encoded"];
|
52
|
+
}
|
53
|
+
>
|
54
|
+
>,
|
55
|
+
> = {
|
56
|
+
sqliteDef: TSqliteDef;
|
57
|
+
options: TOptions;
|
58
|
+
rowSchema: TSchema;
|
59
|
+
insertSchema: SqliteDsl.InsertStructSchemaForColumns<TSqliteDef["columns"]>;
|
60
|
+
readonly Type: Schema.Schema.Type<TSchema>;
|
61
|
+
readonly Encoded: Schema.Schema.Encoded<TSchema>;
|
62
|
+
} & QueryBuilder<
|
63
|
+
ReadonlyArray<Schema.Schema.Type<TSchema>>,
|
64
|
+
TableDefBase<TSqliteDef & {}, TOptions>
|
65
|
+
>;
|
29
66
|
export type TableOptionsInput = Partial<{
|
30
|
-
|
67
|
+
indexes: SqliteDsl.Index[];
|
31
68
|
}>;
|
32
69
|
export declare namespace TableDef {
|
33
|
-
|
70
|
+
type Any = TableDef<any, any>;
|
34
71
|
}
|
35
72
|
export type TableOptions = {
|
36
|
-
|
37
|
-
|
73
|
+
/** Derived based on whether the table definition has one or more columns (besides the `id` column) */
|
74
|
+
readonly isClientDocumentTable: boolean;
|
38
75
|
};
|
39
|
-
export declare const table: <
|
40
|
-
|
41
|
-
|
42
|
-
|
76
|
+
export declare const table: <
|
77
|
+
TName extends string,
|
78
|
+
TColumns extends SqliteDsl.Columns | SqliteDsl.ColumnDefinition<any, any>,
|
79
|
+
const TOptionsInput extends TableOptionsInput = TableOptionsInput,
|
80
|
+
>(
|
81
|
+
args: {
|
82
|
+
name: TName;
|
83
|
+
columns: TColumns;
|
84
|
+
} & Partial<TOptionsInput>,
|
85
|
+
) => TableDef<SqliteTableDefForInput<TName, TColumns>, WithDefaults<TColumns>>;
|
43
86
|
export declare namespace FromTable {
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
87
|
+
type RowDecoded<TTableDef extends TableDefBase> = Types.Simplify<
|
88
|
+
Nullable<Pick<RowDecodedAll<TTableDef>, NullableColumnNames<TTableDef>>> &
|
89
|
+
Omit<RowDecodedAll<TTableDef>, NullableColumnNames<TTableDef>>
|
90
|
+
>;
|
91
|
+
type NullableColumnNames<TTableDef extends TableDefBase> =
|
92
|
+
FromColumns.NullableColumnNames<TTableDef["sqliteDef"]["columns"]>;
|
93
|
+
type Columns<TTableDef extends TableDefBase> = {
|
94
|
+
[K in keyof TTableDef["sqliteDef"]["columns"]]: TTableDef["sqliteDef"]["columns"][K]["columnType"];
|
95
|
+
};
|
96
|
+
type RowEncodeNonNullable<TTableDef extends TableDefBase> = {
|
97
|
+
[K in keyof TTableDef["sqliteDef"]["columns"]]: Schema.Schema.Encoded<
|
98
|
+
TTableDef["sqliteDef"]["columns"][K]["schema"]
|
99
|
+
>;
|
100
|
+
};
|
101
|
+
type RowEncoded<TTableDef extends TableDefBase> = Types.Simplify<
|
102
|
+
Nullable<
|
103
|
+
Pick<RowEncodeNonNullable<TTableDef>, NullableColumnNames<TTableDef>>
|
104
|
+
> &
|
105
|
+
Omit<RowEncodeNonNullable<TTableDef>, NullableColumnNames<TTableDef>>
|
106
|
+
>;
|
107
|
+
type RowDecodedAll<TTableDef extends TableDefBase> = {
|
108
|
+
[K in keyof TTableDef["sqliteDef"]["columns"]]: Schema.Schema.Type<
|
109
|
+
TTableDef["sqliteDef"]["columns"][K]["schema"]
|
110
|
+
>;
|
111
|
+
};
|
56
112
|
}
|
57
113
|
export declare namespace FromColumns {
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
114
|
+
type RowDecoded<TColumns extends SqliteDsl.Columns> = Types.Simplify<
|
115
|
+
Nullable<Pick<RowDecodedAll<TColumns>, NullableColumnNames<TColumns>>> &
|
116
|
+
Omit<RowDecodedAll<TColumns>, NullableColumnNames<TColumns>>
|
117
|
+
>;
|
118
|
+
type RowDecodedAll<TColumns extends SqliteDsl.Columns> = {
|
119
|
+
[K in keyof TColumns]: Schema.Schema.Type<TColumns[K]["schema"]>;
|
120
|
+
};
|
121
|
+
type RowEncoded<TColumns extends SqliteDsl.Columns> = Types.Simplify<
|
122
|
+
Nullable<
|
123
|
+
Pick<RowEncodeNonNullable<TColumns>, NullableColumnNames<TColumns>>
|
124
|
+
> &
|
125
|
+
Omit<RowEncodeNonNullable<TColumns>, NullableColumnNames<TColumns>>
|
126
|
+
>;
|
127
|
+
type RowEncodeNonNullable<TColumns extends SqliteDsl.Columns> = {
|
128
|
+
[K in keyof TColumns]: Schema.Schema.Encoded<TColumns[K]["schema"]>;
|
129
|
+
};
|
130
|
+
type NullableColumnNames<TColumns extends SqliteDsl.Columns> = keyof {
|
131
|
+
[K in keyof TColumns as TColumns[K]["default"] extends true
|
132
|
+
? K
|
133
|
+
: never]: {};
|
134
|
+
};
|
135
|
+
type RequiredInsertColumnNames<TColumns extends SqliteDsl.Columns> =
|
136
|
+
SqliteDsl.FromColumns.RequiredInsertColumnNames<TColumns>;
|
137
|
+
type InsertRowDecoded<TColumns extends SqliteDsl.Columns> =
|
138
|
+
SqliteDsl.FromColumns.InsertRowDecoded<TColumns>;
|
71
139
|
}
|
72
|
-
export type SqliteTableDefForInput<
|
73
|
-
|
74
|
-
|
75
|
-
|
140
|
+
export type SqliteTableDefForInput<
|
141
|
+
TName extends string,
|
142
|
+
TColumns extends SqliteDsl.Columns | SqliteDsl.ColumnDefinition<any, any>,
|
143
|
+
> = SqliteDsl.TableDefinition<TName, PrettifyFlat<ToColumns<TColumns>>>;
|
144
|
+
type WithDefaults<
|
145
|
+
TColumns extends SqliteDsl.Columns | SqliteDsl.ColumnDefinition<any, any>,
|
146
|
+
> = {
|
147
|
+
isClientDocumentTable: false;
|
148
|
+
requiredInsertColumnNames: SqliteDsl.FromColumns.RequiredInsertColumnNames<
|
149
|
+
ToColumns<TColumns>
|
150
|
+
>;
|
76
151
|
};
|
77
|
-
export type PrettifyFlat<T> = T extends infer U
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
152
|
+
export type PrettifyFlat<T> = T extends infer U
|
153
|
+
? {
|
154
|
+
[K in keyof U]: U[K];
|
155
|
+
}
|
156
|
+
: never;
|
157
|
+
type ToColumns<
|
158
|
+
TColumns extends SqliteDsl.Columns | SqliteDsl.ColumnDefinition<any, any>,
|
159
|
+
> = TColumns extends SqliteDsl.Columns
|
160
|
+
? TColumns
|
161
|
+
: TColumns extends SqliteDsl.ColumnDefinition<any, any>
|
162
|
+
? {
|
163
|
+
value: TColumns;
|
164
|
+
}
|
165
|
+
: never;
|
166
|
+
//# sourceMappingURL=table-def.d.ts.map
|
@@ -1,51 +1,147 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
3
|
-
import type { SqliteDsl } from
|
4
|
-
export type DecodedValuesForTableAll<
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
import type { Schema } from "@livestore/utils/effect";
|
2
|
+
import type { Prettify } from "../../../utils/dist/mod.ts";
|
3
|
+
import type { SqliteDsl } from "../schema/state/sqlite/db-schema/mod.ts";
|
4
|
+
export type DecodedValuesForTableAll<
|
5
|
+
TSchema extends SqliteDsl.DbSchema,
|
6
|
+
TTableName extends keyof TSchema,
|
7
|
+
> = {
|
8
|
+
[K in keyof GetColumns<TSchema, TTableName>]: Schema.Schema.Type<
|
9
|
+
GetColumn<TSchema, TTableName, K>["schema"]
|
10
|
+
>;
|
11
|
+
};
|
12
|
+
export type DecodedValuesForTablePretty<
|
13
|
+
TSchema extends SqliteDsl.DbSchema,
|
14
|
+
TTableName extends keyof TSchema,
|
15
|
+
> = Prettify<DecodedValuesForTable<TSchema, TTableName>>;
|
16
|
+
export type DecodedValuesForTable<
|
17
|
+
TSchema extends SqliteDsl.DbSchema,
|
18
|
+
TTableName extends keyof TSchema,
|
19
|
+
> = Partial<
|
20
|
+
Pick<
|
21
|
+
DecodedValuesForTableAll<TSchema, TTableName>,
|
22
|
+
GetNullableColumnNamesForTable<TSchema, TTableName>
|
23
|
+
>
|
24
|
+
> &
|
25
|
+
Omit<
|
26
|
+
DecodedValuesForTableAll<TSchema, TTableName>,
|
27
|
+
GetNullableColumnNamesForTable<TSchema, TTableName>
|
28
|
+
>;
|
29
|
+
export type DecodedValuesForTableOrNull<
|
30
|
+
TSchema extends SqliteDsl.DbSchema,
|
31
|
+
TTableName extends keyof TSchema,
|
32
|
+
> = NullableObj<
|
33
|
+
Pick<
|
34
|
+
DecodedValuesForTableAll<TSchema, TTableName>,
|
35
|
+
GetNullableColumnNamesForTable<TSchema, TTableName>
|
36
|
+
>
|
37
|
+
> &
|
38
|
+
Omit<
|
39
|
+
DecodedValuesForTableAll<TSchema, TTableName>,
|
40
|
+
GetNullableColumnNamesForTable<TSchema, TTableName>
|
41
|
+
>;
|
42
|
+
export type WhereValuesForTable<
|
43
|
+
TSchema extends SqliteDsl.DbSchema,
|
44
|
+
TTableName extends keyof TSchema,
|
45
|
+
> = PartialOrNull<{
|
46
|
+
[K in keyof DecodedValuesForTableAll<
|
47
|
+
TSchema,
|
48
|
+
TTableName
|
49
|
+
>]: WhereValueForDecoded<DecodedValuesForTableAll<TSchema, TTableName>[K]>;
|
12
50
|
}>;
|
13
|
-
export type WhereValueForDecoded<TDecoded> =
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
51
|
+
export type WhereValueForDecoded<TDecoded> =
|
52
|
+
| TDecoded
|
53
|
+
| {
|
54
|
+
op: WhereOp;
|
55
|
+
val: TDecoded;
|
56
|
+
}
|
57
|
+
| {
|
58
|
+
op: "in";
|
59
|
+
val: TDecoded[];
|
60
|
+
};
|
61
|
+
export type WhereOp = ">" | "<" | "=";
|
21
62
|
export declare const isValidWhereOp: (op: string) => op is WhereOp;
|
22
|
-
export type EncodedValuesForTableAll<
|
23
|
-
|
63
|
+
export type EncodedValuesForTableAll<
|
64
|
+
TSchema extends SqliteDsl.DbSchema,
|
65
|
+
TTableName extends keyof TSchema,
|
66
|
+
> = {
|
67
|
+
[K in keyof GetColumns<TSchema, TTableName>]: Schema.Schema.Type<
|
68
|
+
GetColumn<TSchema, TTableName, K>["schema"]
|
69
|
+
>;
|
24
70
|
};
|
25
|
-
export type EncodedValuesForTable<
|
26
|
-
|
27
|
-
|
71
|
+
export type EncodedValuesForTable<
|
72
|
+
TSchema extends SqliteDsl.DbSchema,
|
73
|
+
TTableName extends keyof TSchema,
|
74
|
+
> = Partial<
|
75
|
+
Pick<
|
76
|
+
EncodedValuesForTableAll<TSchema, TTableName>,
|
77
|
+
GetNullableColumnNamesForTable<TSchema, TTableName>
|
78
|
+
>
|
79
|
+
> &
|
80
|
+
Omit<
|
81
|
+
EncodedValuesForTableAll<TSchema, TTableName>,
|
82
|
+
GetNullableColumnNamesForTable<TSchema, TTableName>
|
83
|
+
>;
|
84
|
+
export type GetNullableColumnNamesForTable<
|
85
|
+
TSchema extends SqliteDsl.DbSchema,
|
86
|
+
TTableName extends keyof TSchema,
|
87
|
+
> = keyof {
|
88
|
+
[K in keyof GetColumns<TSchema, TTableName> as GetColumn<
|
89
|
+
TSchema,
|
90
|
+
TTableName,
|
91
|
+
K
|
92
|
+
>["nullable"] extends true
|
93
|
+
? K
|
94
|
+
: never]: {};
|
28
95
|
};
|
29
|
-
export type GetColumns<
|
30
|
-
|
96
|
+
export type GetColumns<
|
97
|
+
TSchema extends SqliteDsl.DbSchema,
|
98
|
+
TTableName extends keyof TSchema,
|
99
|
+
> = TSchema[TTableName]["columns"];
|
100
|
+
export type GetColumn<
|
101
|
+
TSchema extends SqliteDsl.DbSchema,
|
102
|
+
TTableName extends keyof TSchema,
|
103
|
+
TColumnName extends keyof TSchema[TTableName]["columns"],
|
104
|
+
> = TSchema[TTableName]["columns"][TColumnName];
|
31
105
|
export type DecodedValuesForColumnsAll<TColumns extends SqliteDsl.Columns> = {
|
32
|
-
|
106
|
+
[K in keyof TColumns]: Schema.Schema.Type<TColumns[K]["schema"]>;
|
33
107
|
};
|
34
|
-
export type DecodedValuesForColumns<TColumns extends SqliteDsl.Columns> =
|
108
|
+
export type DecodedValuesForColumns<TColumns extends SqliteDsl.Columns> =
|
109
|
+
Partial<
|
110
|
+
Pick<DecodedValuesForColumnsAll<TColumns>, GetNullableColumnNames<TColumns>>
|
111
|
+
> &
|
112
|
+
Omit<
|
113
|
+
DecodedValuesForColumnsAll<TColumns>,
|
114
|
+
GetNullableColumnNames<TColumns>
|
115
|
+
>;
|
35
116
|
export type EncodedValuesForColumnsAll<TColumns extends SqliteDsl.Columns> = {
|
36
|
-
|
117
|
+
[K in keyof TColumns]: Schema.Schema.Encoded<TColumns[K]["schema"]>;
|
37
118
|
};
|
38
|
-
export type EncodedValuesForColumns<TColumns extends SqliteDsl.Columns> =
|
39
|
-
|
40
|
-
|
41
|
-
|
119
|
+
export type EncodedValuesForColumns<TColumns extends SqliteDsl.Columns> =
|
120
|
+
Partial<
|
121
|
+
Pick<EncodedValuesForColumnsAll<TColumns>, GetNullableColumnNames<TColumns>>
|
122
|
+
> &
|
123
|
+
Omit<
|
124
|
+
EncodedValuesForColumnsAll<TColumns>,
|
125
|
+
GetNullableColumnNames<TColumns>
|
126
|
+
>;
|
127
|
+
export type WhereValuesForColumns<TColumns extends SqliteDsl.Columns> =
|
128
|
+
PartialOrNull<{
|
129
|
+
[K in keyof EncodedValuesForColumns<TColumns>]: WhereValueForDecoded<
|
130
|
+
DecodedValuesForColumnsAll<TColumns>[K]
|
131
|
+
>;
|
132
|
+
}>;
|
42
133
|
export type GetNullableColumnNames<TColumns extends SqliteDsl.Columns> = keyof {
|
43
|
-
|
134
|
+
[K in keyof TColumns as TColumns[K] extends SqliteDsl.ColumnDefinition<
|
135
|
+
any,
|
136
|
+
true
|
137
|
+
>
|
138
|
+
? K
|
139
|
+
: never]: unknown;
|
44
140
|
};
|
45
141
|
export type PartialOrNull<T> = {
|
46
|
-
|
142
|
+
[P in keyof T]?: T[P] | null;
|
47
143
|
};
|
48
144
|
export type NullableObj<T> = {
|
49
|
-
|
145
|
+
[P in keyof T]: T[P] | null;
|
50
146
|
};
|
51
|
-
//# sourceMappingURL=types.d.ts.map
|
147
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/version.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export declare const liveStoreVersion: "0.3.2-dev.
|
1
|
+
export declare const liveStoreVersion: "0.3.2-dev.6";
|
2
2
|
/**
|
3
3
|
* This version number is incremented whenever the internal storage format changes in a breaking way.
|
4
4
|
* Whenever this version changes, LiveStore will start with fresh database files. Old database files are not deleted.
|
package/dist/version.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
// TODO bring back when Expo and Playwright supports `with` imports
|
2
2
|
// import packageJson from '../package.json' with { type: 'json' }
|
3
3
|
// export const liveStoreVersion = packageJson.version
|
4
|
-
export const liveStoreVersion = '0.3.2-dev.
|
4
|
+
export const liveStoreVersion = '0.3.2-dev.6';
|
5
5
|
/**
|
6
6
|
* This version number is incremented whenever the internal storage format changes in a breaking way.
|
7
7
|
* Whenever this version changes, LiveStore will start with fresh database files. Old database files are not deleted.
|
package/package.json
CHANGED
@@ -1,66 +1,27 @@
|
|
1
1
|
{
|
2
2
|
"name": "@livestore/common",
|
3
|
-
"version": "0.3.2-dev.
|
3
|
+
"version": "0.3.2-dev.6",
|
4
4
|
"type": "module",
|
5
5
|
"sideEffects": false,
|
6
6
|
"exports": {
|
7
|
-
".":
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
"./
|
13
|
-
"types": "./dist/sql-queries/index.d.ts",
|
14
|
-
"default": "./dist/sql-queries/index.js"
|
15
|
-
},
|
16
|
-
"./leader-thread": {
|
17
|
-
"types": "./dist/leader-thread/mod.d.ts",
|
18
|
-
"default": "./dist/leader-thread/mod.js"
|
19
|
-
},
|
20
|
-
"./schema": {
|
21
|
-
"types": "./dist/schema/mod.d.ts",
|
22
|
-
"default": "./dist/schema/mod.js"
|
23
|
-
},
|
24
|
-
"./sync/next": {
|
25
|
-
"types": "./dist/sync/next/mod.d.ts",
|
26
|
-
"default": "./dist/sync/next/mod.js"
|
27
|
-
},
|
28
|
-
"./sync/next/test": {
|
29
|
-
"types": "./dist/sync/next/test/mod.d.ts",
|
30
|
-
"default": "./dist/sync/next/test/mod.js"
|
31
|
-
}
|
32
|
-
},
|
33
|
-
"types": "./dist/index.d.ts",
|
34
|
-
"typesVersions": {
|
35
|
-
"*": {
|
36
|
-
"schema": [
|
37
|
-
"./dist/schema/mod.d.ts"
|
38
|
-
],
|
39
|
-
"sql-queries": [
|
40
|
-
"./dist/sql-queries/index.d.ts"
|
41
|
-
],
|
42
|
-
"leader-thread": [
|
43
|
-
"./dist/leader-thread/mod.d.ts"
|
44
|
-
],
|
45
|
-
"sync/next": [
|
46
|
-
"./dist/sync/next/mod.d.ts"
|
47
|
-
],
|
48
|
-
"sync/next/test": [
|
49
|
-
"./dist/sync/next/test/mod.d.ts"
|
50
|
-
]
|
51
|
-
}
|
7
|
+
".": "./dist/index.js",
|
8
|
+
"./sql-queries": "./dist/sql-queries/index.js",
|
9
|
+
"./leader-thread": "./dist/leader-thread/mod.js",
|
10
|
+
"./schema": "./dist/schema/mod.js",
|
11
|
+
"./sync/next": "./dist/sync/next/mod.js",
|
12
|
+
"./sync/next/test": "./dist/sync/next/test/mod.js"
|
52
13
|
},
|
53
14
|
"dependencies": {
|
54
15
|
"@opentelemetry/api": "1.9.0",
|
55
16
|
"graphology": "0.26.0-alpha1",
|
56
17
|
"graphology-dag": "0.4.1",
|
57
18
|
"graphology-types": "0.24.8",
|
58
|
-
"@livestore/
|
59
|
-
"@livestore/
|
19
|
+
"@livestore/utils": "0.3.2-dev.6",
|
20
|
+
"@livestore/webmesh": "0.3.2-dev.6"
|
60
21
|
},
|
61
22
|
"devDependencies": {
|
62
23
|
"vitest": "3.2.4",
|
63
|
-
"@livestore/utils-dev": "0.3.2-dev.
|
24
|
+
"@livestore/utils-dev": "0.3.2-dev.6"
|
64
25
|
},
|
65
26
|
"files": [
|
66
27
|
"package.json",
|
package/src/schema/EventDef.ts
CHANGED
@@ -7,10 +7,9 @@ import type { ParamsObject } from '../util.ts'
|
|
7
7
|
import type { QueryBuilder } from './state/sqlite/query-builder/mod.ts'
|
8
8
|
|
9
9
|
export type EventDefMap = {
|
10
|
-
map: Map<string
|
10
|
+
map: Map<string, EventDef.Any>
|
11
11
|
}
|
12
12
|
export type EventDefRecord = {
|
13
|
-
'livestore.RawSql': RawSqlEvent
|
14
13
|
[name: string]: EventDef.Any
|
15
14
|
}
|
16
15
|
|
@@ -218,22 +217,3 @@ export const materializers = <TInputRecord extends Record<string, EventDef.AnyWi
|
|
218
217
|
) => {
|
219
218
|
return handlers
|
220
219
|
}
|
221
|
-
|
222
|
-
export const rawSqlEvent = defineEvent({
|
223
|
-
name: 'livestore.RawSql',
|
224
|
-
schema: Schema.Struct({
|
225
|
-
sql: Schema.String,
|
226
|
-
bindValues: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),
|
227
|
-
writeTables: Schema.optional(Schema.ReadonlySet(Schema.String)),
|
228
|
-
}),
|
229
|
-
clientOnly: true,
|
230
|
-
derived: true,
|
231
|
-
})
|
232
|
-
|
233
|
-
export const rawSqlMaterializer = defineMaterializer(rawSqlEvent, ({ sql, bindValues, writeTables }) => ({
|
234
|
-
sql,
|
235
|
-
bindValues: bindValues ?? {},
|
236
|
-
writeTables,
|
237
|
-
}))
|
238
|
-
|
239
|
-
export type RawSqlEvent = typeof rawSqlEvent
|
package/src/schema/schema.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
import { isReadonlyArray, shouldNeverHappen } from '@livestore/utils'
|
2
2
|
|
3
3
|
import type { MigrationOptions } from '../adapter-types.ts'
|
4
|
-
import type { EventDef, EventDefRecord, Materializer
|
5
|
-
import { rawSqlEvent } from './EventDef.ts'
|
4
|
+
import type { EventDef, EventDefRecord, Materializer } from './EventDef.ts'
|
6
5
|
import { tableIsClientDocumentTable } from './state/sqlite/client-document-def.ts'
|
7
6
|
import type { SqliteDsl } from './state/sqlite/db-schema/mod.ts'
|
8
7
|
import { stateSystemTables } from './state/sqlite/system-tables.ts'
|
@@ -80,8 +79,6 @@ export const makeSchema = <TInputSchema extends InputSchema>(
|
|
80
79
|
}
|
81
80
|
}
|
82
81
|
|
83
|
-
eventsDefsMap.set(rawSqlEvent.name, rawSqlEvent)
|
84
|
-
|
85
82
|
for (const tableDef of tables.values()) {
|
86
83
|
if (tableIsClientDocumentTable(tableDef) && eventsDefsMap.has(tableDef.set.name) === false) {
|
87
84
|
eventsDefsMap.set(tableDef.set.name, tableDef.set)
|
@@ -138,8 +135,8 @@ export namespace FromInputSchema {
|
|
138
135
|
|
139
136
|
type EventDefRecordFromInputSchemaEvents<TEvents extends InputSchema['events']> =
|
140
137
|
TEvents extends ReadonlyArray<EventDef.Any>
|
141
|
-
? { [K in TEvents[number] as K['name']]: K }
|
138
|
+
? { [K in TEvents[number] as K['name']]: K }
|
142
139
|
: TEvents extends { [name: string]: EventDef.Any }
|
143
|
-
? { [K in keyof TEvents as TEvents[K]['name']]: TEvents[K] }
|
140
|
+
? { [K in keyof TEvents as TEvents[K]['name']]: TEvents[K] }
|
144
141
|
: never
|
145
142
|
}
|
@@ -23,6 +23,18 @@ import { table } from './table-def.ts'
|
|
23
23
|
* Careful:
|
24
24
|
* - When changing the table definitions in a non-backwards compatible way, the state might be lost without
|
25
25
|
* explicit reducers to handle the old auto-generated events
|
26
|
+
*
|
27
|
+
* Usage:
|
28
|
+
*
|
29
|
+
* ```ts
|
30
|
+
* // Querying data
|
31
|
+
* // `'some-id'` can be ommited for SessionIdSymbol
|
32
|
+
* store.queryDb(clientDocumentTable.get('some-id'))
|
33
|
+
*
|
34
|
+
* // Setting data
|
35
|
+
* // Again, `'some-id'` can be ommited for SessionIdSymbol
|
36
|
+
* store.commit(clientDocumentTable.set({ someField: 'some-value' }, 'some-id'))
|
37
|
+
* ```
|
26
38
|
*/
|
27
39
|
export const clientDocument = <
|
28
40
|
TName extends string,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { shouldNeverHappen } from '@livestore/utils'
|
2
2
|
|
3
3
|
import type { MigrationOptions } from '../../../adapter-types.ts'
|
4
|
-
import {
|
4
|
+
import type { Materializer } from '../../EventDef.ts'
|
5
5
|
import type { InternalState } from '../../schema.ts'
|
6
6
|
import { ClientDocumentTableDefSymbol, tableIsClientDocumentTable } from './client-document-def.ts'
|
7
7
|
import { SqliteAst } from './db-schema/mod.ts'
|
@@ -44,8 +44,6 @@ export const makeState = <TStateInput extends InputState>(inputSchema: TStateInp
|
|
44
44
|
materializers.set(name, materializer)
|
45
45
|
}
|
46
46
|
|
47
|
-
materializers.set(rawSqlEvent.name, rawSqlMaterializer)
|
48
|
-
|
49
47
|
for (const tableDef of inputTables) {
|
50
48
|
if (tableIsClientDocumentTable(tableDef)) {
|
51
49
|
materializers.set(
|
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.2-dev.
|
5
|
+
export const liveStoreVersion = '0.3.2-dev.6' as const
|
6
6
|
|
7
7
|
/**
|
8
8
|
* This version number is incremented whenever the internal storage format changes in a breaking way.
|