@evolu/common 1.0.17 → 2.0.1
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/README.md +7 -7
- package/dist/src/Config.d.ts +4 -6
- package/dist/src/Config.d.ts.map +1 -1
- package/dist/src/Config.js +1 -1
- package/dist/src/Crdt.d.ts +15 -9
- package/dist/src/Crdt.d.ts.map +1 -1
- package/dist/src/Crdt.js +15 -14
- package/dist/src/Crypto.d.ts +7 -13
- package/dist/src/Crypto.d.ts.map +1 -1
- package/dist/src/Crypto.js +7 -9
- package/dist/src/Db.d.ts +36 -70
- package/dist/src/Db.d.ts.map +1 -1
- package/dist/src/Db.js +45 -51
- package/dist/src/DbWorker.d.ts +13 -14
- package/dist/src/DbWorker.d.ts.map +1 -1
- package/dist/src/DbWorker.js +56 -57
- package/dist/src/Diff.d.ts +3 -1
- package/dist/src/Diff.d.ts.map +1 -1
- package/dist/src/Diff.js +3 -7
- package/dist/src/{Errors.d.ts → ErrorStore.d.ts} +14 -7
- package/dist/src/ErrorStore.d.ts.map +1 -0
- package/dist/src/{Errors.js → ErrorStore.js} +2 -0
- package/dist/src/Evolu.d.ts +316 -58
- package/dist/src/Evolu.d.ts.map +1 -1
- package/dist/src/Evolu.js +199 -185
- package/dist/src/Model.d.ts +47 -57
- package/dist/src/Model.d.ts.map +1 -1
- package/dist/src/Model.js +30 -35
- package/dist/src/OnCompletes.d.ts +11 -0
- package/dist/src/OnCompletes.d.ts.map +1 -0
- package/dist/src/OnCompletes.js +21 -0
- package/dist/src/Owner.d.ts +31 -0
- package/dist/src/Owner.d.ts.map +1 -0
- package/dist/src/Owner.js +20 -0
- package/dist/src/Platform.d.ts +16 -12
- package/dist/src/Platform.d.ts.map +1 -1
- package/dist/src/Platform.js +18 -12
- package/dist/src/Protobuf.d.ts +25 -73
- package/dist/src/Protobuf.d.ts.map +1 -1
- package/dist/src/Protobuf.js +4 -12
- package/dist/src/Public.d.ts +5 -3
- package/dist/src/Public.d.ts.map +1 -1
- package/dist/src/Public.js +1 -0
- package/dist/src/Sqlite.d.ts +8 -11
- package/dist/src/Sqlite.d.ts.map +1 -1
- package/dist/src/Sqlite.js +7 -7
- package/dist/src/Store.d.ts +6 -5
- package/dist/src/Store.d.ts.map +1 -1
- package/dist/src/Store.js +21 -16
- package/dist/src/SyncWorker.d.ts +8 -2
- package/dist/src/SyncWorker.d.ts.map +1 -1
- package/dist/src/SyncWorker.js +12 -19
- package/dist/src/index.d.ts +6 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -2
- package/package.json +23 -13
- package/src/Config.ts +7 -7
- package/src/Crdt.ts +29 -26
- package/src/Crypto.ts +14 -19
- package/src/Db.ts +113 -166
- package/src/DbWorker.ts +110 -140
- package/src/Diff.ts +5 -7
- package/src/{Errors.ts → ErrorStore.ts} +17 -8
- package/src/Evolu.ts +682 -442
- package/src/Model.ts +60 -85
- package/src/OnCompletes.ts +46 -0
- package/src/Owner.ts +65 -0
- package/src/Platform.ts +38 -25
- package/src/Protobuf.ts +25 -73
- package/src/Public.ts +5 -3
- package/src/Sqlite.ts +13 -24
- package/src/Store.ts +36 -24
- package/src/SyncWorker.ts +30 -38
- package/src/index.ts +6 -2
- package/dist/src/Errors.d.ts.map +0 -1
package/dist/src/Evolu.d.ts
CHANGED
|
@@ -1,71 +1,329 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as S from "@effect/schema/Schema";
|
|
2
|
+
import { Context, Layer } from "effect";
|
|
3
|
+
import * as Kysely from "kysely";
|
|
3
4
|
import { Config } from "./Config.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
5
|
+
import { Mnemonic } from "./Crypto.js";
|
|
6
|
+
import { Queries, Query, QueryResult, QueryResultsPromisesFromQueries, Row, RowsStore, Schema } from "./Db.js";
|
|
7
|
+
import { DbWorker } from "./DbWorker.js";
|
|
8
|
+
import { EvoluError } from "./ErrorStore.js";
|
|
9
|
+
import { SqliteBoolean, SqliteDate } from "./Model.js";
|
|
10
|
+
import { Owner } from "./Owner.js";
|
|
10
11
|
import { AppState, FlushSync } from "./Platform.js";
|
|
11
|
-
import {
|
|
12
|
-
import { Store, StoreListener, StoreUnsubscribe } from "./Store.js";
|
|
12
|
+
import { Store } from "./Store.js";
|
|
13
13
|
import { SyncState } from "./SyncWorker.js";
|
|
14
|
-
export interface Evolu<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
readonly
|
|
28
|
-
|
|
14
|
+
export interface Evolu<T extends Schema = Schema> {
|
|
15
|
+
/**
|
|
16
|
+
* Subscribe to {@link EvoluError} changes.
|
|
17
|
+
*
|
|
18
|
+
* ### Example
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* const unsubscribe = evolu.subscribeError(() => {
|
|
22
|
+
* const error = evolu.getError();
|
|
23
|
+
* console.log(error);
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
readonly subscribeError: Store<EvoluError | null>["subscribe"];
|
|
28
|
+
/** Get {@link EvoluError}. */
|
|
29
|
+
readonly getError: Store<EvoluError | null>["getState"];
|
|
30
|
+
/**
|
|
31
|
+
* Create type-safe SQL {@link Query}.
|
|
32
|
+
*
|
|
33
|
+
* Evolu uses Kysely - the type-safe SQL query builder for TypeScript. See
|
|
34
|
+
* https://kysely.dev.
|
|
35
|
+
*
|
|
36
|
+
* For mutations, use {@link create} and {@link update}.
|
|
37
|
+
*
|
|
38
|
+
* ### Example
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* const allTodos = evolu.createQuery((db) =>
|
|
42
|
+
* db.selectFrom("todo").selectAll(),
|
|
43
|
+
* );
|
|
44
|
+
*
|
|
45
|
+
* const todoById = (id: TodoId) =>
|
|
46
|
+
* evolu.createQuery((db) =>
|
|
47
|
+
* db.selectFrom("todo").selectAll().where("id", "=", id),
|
|
48
|
+
* );
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
readonly createQuery: CreateQuery<T>;
|
|
52
|
+
/**
|
|
53
|
+
* Load {@link Query} and return a promise with {@link QueryResult}.
|
|
54
|
+
*
|
|
55
|
+
* A returned promise always resolves successfully because there is no reason
|
|
56
|
+
* why loading should fail. All data are local, and the query is typed. A
|
|
57
|
+
* serious unexpected Evolu error shall be handled with
|
|
58
|
+
* {@link subscribeError}.
|
|
59
|
+
*
|
|
60
|
+
* Loading is batched, and returned promises are cached, so there is no need
|
|
61
|
+
* for an additional cache. Evolu's internal cache is invalidated on
|
|
62
|
+
* mutation.
|
|
63
|
+
*
|
|
64
|
+
* The returned promise is enriched with special status and value properties
|
|
65
|
+
* for the upcoming React `use` Hook, but other UI libraries can also leverage
|
|
66
|
+
* them. Speaking of React, there are two essential React Suspense-related
|
|
67
|
+
* patterns that every developer should be aware of—passing promises to
|
|
68
|
+
* children and caching over mutations.
|
|
69
|
+
*
|
|
70
|
+
* With promises passed to children, we can load a query as soon as possible,
|
|
71
|
+
* but we don't have to use the returned promise immediately. That's useful
|
|
72
|
+
* for prefetching, which is generally not necessary for local-first apps but
|
|
73
|
+
* can be if a query takes a long time to load.
|
|
74
|
+
*
|
|
75
|
+
* Caching over mutation is a pattern that every developer should know. As we
|
|
76
|
+
* said, Evolu caches promise until a mutation happens. A query loaded after
|
|
77
|
+
* that will return a new pending promise. That's okay for general usage but
|
|
78
|
+
* not for UI with React Suspense because a mutation would suspend rerendered
|
|
79
|
+
* queries on a page, and that's not a good UX.
|
|
80
|
+
*
|
|
81
|
+
* We call this pattern "caching over mutation" because it has no globally
|
|
82
|
+
* accepted name yet. React RFC for React Cache does not exist yet.
|
|
83
|
+
*
|
|
84
|
+
* For better UX, a query must be subscribed for updates. This way, instead of
|
|
85
|
+
* Suspense flashes, the user sees new data immediately because Evolu replaces
|
|
86
|
+
* cached promises with fresh, already resolved new ones.
|
|
87
|
+
*
|
|
88
|
+
* If you are curious why Evolu does not do that for all queries by default,
|
|
89
|
+
* the answer is simple: performance. Tracking changes is costly and
|
|
90
|
+
* meaningful only for visible (hence subscribed) queries anyway. To subscribe
|
|
91
|
+
* to a query, use {@link subscribeQuery}.
|
|
92
|
+
*
|
|
93
|
+
* ### Example
|
|
94
|
+
*
|
|
95
|
+
* ```ts
|
|
96
|
+
* const allTodos = evolu.createQuery((db) =>
|
|
97
|
+
* db.selectFrom("todo").selectAll(),
|
|
98
|
+
* );
|
|
99
|
+
* evolu.loadQuery(allTodos).then(({ rows }) => {
|
|
100
|
+
* console.log(rows);
|
|
101
|
+
* });
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
readonly loadQuery: LoadQuery;
|
|
105
|
+
/**
|
|
106
|
+
* Load an array of {@link Query} queries and return an array of
|
|
107
|
+
* {@link QueryResult} promises. It's like `queries.map(loadQuery)` but with
|
|
108
|
+
* proper types for returned promises.
|
|
109
|
+
*
|
|
110
|
+
* ### Example
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* evolu.loadQueries([allTodos, todoById(1)]);
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
readonly loadQueries: <R extends Row, Q extends Queries<R>>(queries: [...Q]) => [...QueryResultsPromisesFromQueries<Q>];
|
|
117
|
+
/**
|
|
118
|
+
* Subscribe to {@link Query} {@link QueryResult} changes.
|
|
119
|
+
*
|
|
120
|
+
* ### Example
|
|
121
|
+
*
|
|
122
|
+
* ```ts
|
|
123
|
+
* const unsubscribe = evolu.subscribeQuery(allTodos)(() => {
|
|
124
|
+
* const { rows } = evolu.getQuery(allTodos);
|
|
125
|
+
* });
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
readonly subscribeQuery: SubscribedQueries["subscribeQuery"];
|
|
129
|
+
/**
|
|
130
|
+
* Get {@link Query} {@link QueryResult}.
|
|
131
|
+
*
|
|
132
|
+
* ### Example
|
|
133
|
+
*
|
|
134
|
+
* ```ts
|
|
135
|
+
* const unsubscribe = evolu.subscribeQuery(allTodos)(() => {
|
|
136
|
+
* const { rows } = evolu.getQuery(allTodos);
|
|
137
|
+
* });
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
readonly getQuery: SubscribedQueries["getQuery"];
|
|
141
|
+
/**
|
|
142
|
+
* Subscribe to {@link Owner} changes.
|
|
143
|
+
*
|
|
144
|
+
* ### Example
|
|
145
|
+
*
|
|
146
|
+
* ```ts
|
|
147
|
+
* const unsubscribe = evolu.subscribeOwner(() => {
|
|
148
|
+
* const owner = evolu.getOwner();
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
readonly subscribeOwner: Store<Owner | null>["subscribe"];
|
|
153
|
+
/**
|
|
154
|
+
* Get {@link Owner}.
|
|
155
|
+
*
|
|
156
|
+
* ### Example
|
|
157
|
+
*
|
|
158
|
+
* ```ts
|
|
159
|
+
* const unsubscribe = evolu.subscribeOwner(() => {
|
|
160
|
+
* const owner = evolu.getOwner();
|
|
161
|
+
* });
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
readonly getOwner: Store<Owner | null>["getState"];
|
|
165
|
+
/**
|
|
166
|
+
* Subscribe to {@link SyncState} changes.
|
|
167
|
+
*
|
|
168
|
+
* ### Example
|
|
169
|
+
*
|
|
170
|
+
* ```ts
|
|
171
|
+
* const unsubscribe = evolu.subscribeSyncState(() => {
|
|
172
|
+
* const syncState = evolu.getSyncState();
|
|
173
|
+
* });
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
readonly subscribeSyncState: Store<SyncState>["subscribe"];
|
|
177
|
+
/**
|
|
178
|
+
* Get {@link SyncState}.
|
|
179
|
+
*
|
|
180
|
+
* ### Example
|
|
181
|
+
*
|
|
182
|
+
* ```ts
|
|
183
|
+
* const unsubscribe = evolu.subscribeSyncState(() => {
|
|
184
|
+
* const syncState = evolu.getSyncState();
|
|
185
|
+
* });
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
readonly getSyncState: Store<SyncState>["getState"];
|
|
189
|
+
/**
|
|
190
|
+
* The function creates a row in the database and returns a new ID. The first
|
|
191
|
+
* argument is the table name, and the second is an object.
|
|
192
|
+
*
|
|
193
|
+
* The third optional argument, the onComplete callback, is generally
|
|
194
|
+
* unnecessary because creating a row cannot fail. Still, UI libraries can use
|
|
195
|
+
* it to ensure the DOM is updated if we want to manipulate it, for example,
|
|
196
|
+
* to focus an element.
|
|
197
|
+
*
|
|
198
|
+
* Evolu does not use SQL for mutations to ensure data can be safely and
|
|
199
|
+
* predictably merged without conflicts.
|
|
200
|
+
*
|
|
201
|
+
* Explicit mutations also allow Evolu to automatically add and update a few
|
|
202
|
+
* useful columns common to all tables. Those columns are: `createdAt`,
|
|
203
|
+
* `updatedAt`, and `isDeleted`.
|
|
204
|
+
*
|
|
205
|
+
* ### Example
|
|
206
|
+
*
|
|
207
|
+
* ```ts
|
|
208
|
+
* import * as S from "@effect/schema/Schema";
|
|
209
|
+
*
|
|
210
|
+
* // Evolu uses the Schema to enforce domain model.
|
|
211
|
+
* const title = S.parseSync(Evolu.NonEmptyString1000)("A title");
|
|
212
|
+
*
|
|
213
|
+
* const { id } = evolu.create("todo", { title }, () => {
|
|
214
|
+
* // onComplete callback
|
|
215
|
+
* });
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
create: Mutate<T, "create">;
|
|
219
|
+
/**
|
|
220
|
+
* The function updates a row in the database and returns the existing ID. The
|
|
221
|
+
* first argument is the table name, and the second is an object.
|
|
222
|
+
*
|
|
223
|
+
* The third optional argument, the onComplete callback, is generally
|
|
224
|
+
* unnecessary because creating a row cannot fail. Still, UI libraries can use
|
|
225
|
+
* it to ensure the DOM is updated if we want to manipulate it, for example,
|
|
226
|
+
* to focus an element.
|
|
227
|
+
*
|
|
228
|
+
* Evolu does not use SQL for mutations to ensure data can be safely and
|
|
229
|
+
* predictably merged without conflicts.
|
|
230
|
+
*
|
|
231
|
+
* Explicit mutations also allow Evolu to automatically add and update a few
|
|
232
|
+
* useful columns common to all tables. Those columns are: `createdAt`,
|
|
233
|
+
* `updatedAt`, and `isDeleted`.
|
|
234
|
+
*
|
|
235
|
+
* ### Example
|
|
236
|
+
*
|
|
237
|
+
* ```ts
|
|
238
|
+
* import * as S from "@effect/schema/Schema";
|
|
239
|
+
*
|
|
240
|
+
* // Evolu uses the Schema to enforce domain model.
|
|
241
|
+
* const title = S.parseSync(Evolu.NonEmptyString1000)("A title");
|
|
242
|
+
* evolu.update("todo", { id, title });
|
|
243
|
+
*
|
|
244
|
+
* // To delete a row, set `isDeleted` to true.
|
|
245
|
+
* evolu.update("todo", { id, isDeleted: true });
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
update: Mutate<T, "update">;
|
|
249
|
+
/**
|
|
250
|
+
* Delete {@link Owner} and all their data from the current device. After the
|
|
251
|
+
* deletion, Evolu will purge the application state. For browsers, this will
|
|
252
|
+
* reload all tabs using Evolu. For native apps, it will restart the app.
|
|
253
|
+
*/
|
|
254
|
+
readonly resetOwner: () => void;
|
|
255
|
+
/** Restore {@link Owner} with all their synced data. */
|
|
256
|
+
readonly restoreOwner: (mnemonic: Mnemonic) => void;
|
|
257
|
+
/** Ensure tables and columns defined in {@link Schema} exist in the database. */
|
|
258
|
+
readonly ensureSchema: <From, To extends T>(schema: S.Schema<From, To>) => void;
|
|
259
|
+
}
|
|
260
|
+
export declare const Evolu: Context.Tag<Evolu<Schema>, Evolu<Schema>>;
|
|
261
|
+
type CreateQuery<S extends Schema> = <R extends Row>(queryCallback: QueryCallback<S, R>) => Query<R>;
|
|
262
|
+
type QueryCallback<S extends Schema, R extends Row> = (db: Pick<Kysely.Kysely<QuerySchema<S>>, "selectFrom" | "fn">) => Kysely.SelectQueryBuilder<any, any, R>;
|
|
263
|
+
type QuerySchema<S extends Schema> = {
|
|
264
|
+
readonly [Table in keyof S]: NullableExceptId<{
|
|
265
|
+
readonly [Column in keyof S[Table]]: S[Table][Column];
|
|
266
|
+
} & CommonColumns>;
|
|
267
|
+
};
|
|
268
|
+
type NullableExceptId<T> = {
|
|
269
|
+
readonly [K in keyof T]: K extends "id" ? T[K] : T[K] | null;
|
|
270
|
+
};
|
|
271
|
+
export interface CommonColumns {
|
|
272
|
+
readonly createdAt: SqliteDate;
|
|
273
|
+
readonly updatedAt: SqliteDate;
|
|
274
|
+
readonly isDeleted: SqliteBoolean;
|
|
275
|
+
}
|
|
276
|
+
export declare const makeCreateQuery: <S extends Schema = Schema>() => CreateQuery<S>;
|
|
277
|
+
export interface LoadingPromises {
|
|
278
|
+
readonly get: <R extends Row>(query: Query<R>) => {
|
|
279
|
+
readonly promise: LoadingPromise<R>;
|
|
280
|
+
readonly isNew: boolean;
|
|
281
|
+
};
|
|
282
|
+
readonly resolve: <R extends Row>(query: Query<R>, rows: ReadonlyArray<R>) => void;
|
|
283
|
+
/**
|
|
284
|
+
* Release all unsubscribed queries on mutation because only subscribed
|
|
285
|
+
* queries are automatically updated.
|
|
286
|
+
*/
|
|
287
|
+
readonly release: () => void;
|
|
29
288
|
}
|
|
30
|
-
export declare const
|
|
31
|
-
type
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
289
|
+
export declare const LoadingPromises: Context.Tag<LoadingPromises, LoadingPromises>;
|
|
290
|
+
export type LoadingPromise<R extends Row> = Promise<QueryResult<R>> & {
|
|
291
|
+
status?: "pending" | "fulfilled" | "rejected";
|
|
292
|
+
value?: QueryResult<R>;
|
|
293
|
+
reason?: unknown;
|
|
294
|
+
};
|
|
295
|
+
export declare const LoadingPromiseLive: Layer.Layer<SubscribedQueries, never, LoadingPromises>;
|
|
296
|
+
type LoadQuery = <R extends Row>(query: Query<R>) => Promise<QueryResult<R>>;
|
|
297
|
+
declare const LoadQuery: Context.Tag<LoadQuery, LoadQuery>;
|
|
298
|
+
export interface SubscribedQueries {
|
|
299
|
+
readonly subscribeQuery: (query: Query) => Store<Row>["subscribe"];
|
|
300
|
+
readonly getQuery: <R extends Row>(query: Query<R>) => QueryResult<R>;
|
|
301
|
+
readonly getSubscribedQueries: () => Queries;
|
|
38
302
|
}
|
|
39
|
-
declare const
|
|
40
|
-
export
|
|
41
|
-
|
|
303
|
+
export declare const SubscribedQueries: Context.Tag<SubscribedQueries, SubscribedQueries>;
|
|
304
|
+
export declare const SubscribedQueriesLive: Layer.Layer<RowsStore, never, SubscribedQueries>;
|
|
305
|
+
type Mutate<S extends Schema = Schema, Mode extends "create" | "update" = "update"> = <K extends keyof S>(table: K, values: Kysely.Simplify<Mode extends "create" ? PartialForNullable<Castable<Omit<S[K], "id">>> : Partial<Castable<Omit<S[K], "id"> & Pick<CommonColumns, "isDeleted">>> & {
|
|
306
|
+
readonly id: S[K]["id"];
|
|
307
|
+
}>, onComplete?: () => void) => {
|
|
308
|
+
readonly id: S[K]["id"];
|
|
42
309
|
};
|
|
43
|
-
|
|
310
|
+
declare const Mutate: Context.Tag<Mutate<Schema, "update">, Mutate<Schema, "update">>;
|
|
311
|
+
type PartialForNullable<T, NK extends keyof T = {
|
|
44
312
|
[K in keyof T]: null extends T[K] ? K : never;
|
|
45
313
|
}[keyof T], NP = Pick<T, Exclude<keyof T, NK>> & Partial<Pick<T, NK>>> = {
|
|
46
314
|
[K in keyof NP]: NP[K];
|
|
47
315
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
316
|
+
/**
|
|
317
|
+
* SQLite doesn't support Date nor Boolean types, so Evolu emulates them with
|
|
318
|
+
* {@link SqliteBoolean} and {@link SqliteDate}.
|
|
319
|
+
*
|
|
320
|
+
* For {@link SqliteBoolean}, you can use JavaScript boolean. For
|
|
321
|
+
* {@link SqliteDate}, you can use JavaScript Date.
|
|
322
|
+
*/
|
|
323
|
+
type Castable<T> = {
|
|
324
|
+
readonly [K in keyof T]: T[K] extends SqliteBoolean ? boolean | SqliteBoolean : T[K] extends null | SqliteBoolean ? null | boolean | SqliteBoolean : T[K] extends SqliteDate ? Date | SqliteDate : T[K] extends null | SqliteDate ? null | Date | SqliteDate : T[K];
|
|
52
325
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* Use `reset` to delete all local data from the current device.
|
|
56
|
-
* After the deletion, Evolu reloads all browser tabs that use Evolu.
|
|
57
|
-
*/
|
|
58
|
-
readonly reset: () => void;
|
|
59
|
-
/**
|
|
60
|
-
* Use `restore` to restore `Owner` with synced data on a different device.
|
|
61
|
-
*/
|
|
62
|
-
readonly restore: (mnemonic: string) => Promise<Either.Either<RestoreOwnerError, void>>;
|
|
63
|
-
}
|
|
64
|
-
interface RestoreOwnerError {
|
|
65
|
-
readonly _tag: "RestoreOwnerError";
|
|
66
|
-
}
|
|
67
|
-
export declare const loadingPromisesPromiseProp = "rows";
|
|
68
|
-
export declare const EvoluLive: <S extends Schema>(tables: Tables) => Layer.Layer<Config | Bip39 | NanoId | Time | FlushSync | AppState | DbWorker, never, Evolu<S>>;
|
|
69
|
-
export declare const makeEvoluForPlatform: <S extends Schema>(PlatformLayer: Layer.Layer<never, never, DbWorker | Bip39 | NanoId | FlushSync | AppState>, tables: Tables, config?: Partial<Config>) => Evolu<S>;
|
|
326
|
+
/** EvoluCommonLive has only platform independent side-effects. */
|
|
327
|
+
export declare const EvoluCommonLive: Layer.Layer<Config | FlushSync | AppState | DbWorker, never, Evolu<Schema>>;
|
|
70
328
|
export {};
|
|
71
329
|
//# sourceMappingURL=Evolu.d.ts.map
|
package/dist/src/Evolu.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Evolu.d.ts","sourceRoot":"","sources":["../../src/Evolu.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":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