@evolu/common 2.0.6 → 2.2.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"DbWorker.d.ts","sourceRoot":"","sources":["../../src/DbWorker.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EACP,MAAM,EAEN,KAAK,EAGL,aAAa,EACb,cAAc,EAEf,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,MAAM,EAAc,MAAM,aAAa,CAAC;AAoBjD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EACL,OAAO,EACP,KAAK,EAIL,MAAM,EAMP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,UAAU,EAAuB,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAQ,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAW,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAEL,UAAU,EAEV,SAAS,EACT,UAAU,EACV,4BAA4B,EAE7B,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACrD,SAAS,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;CAC7C;AAED,eAAO,MAAM,QAAQ,iCAA0B,CAAC;AAEhD,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,GACnB,iBAAiB,GACjB,kBAAkB,GAClB,yBAAyB,GACzB,4BAA4B,CAAC;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AAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,cAAc,CAC5C,KAAK,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,CACnC,CAAC;IACF,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;CAC5C;AAwED,eAAO,MAAM,sBAAsB,cACtB,cAAc,QAAQ,CAAC,KACjC,cAAc,UAAU,CAqCxB,CAAC;AAyBJ,eAAO,MAAM,6BAA6B,YAC/B,UAAU,YACT,cAAc,UAAU,CAAC,KAClC,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAiBhC,CAAC;AAoQL,eAAO,MAAM,YAAY,oEAkHxB,CAAC"}
@@ -202,15 +202,11 @@ const handleSyncResponse = ({ messages, ...response }) => Effect.gen(function* (
202
202
  const sync = ({ queries, }) => Effect.gen(function* (_) {
203
203
  if (queries.length > 0)
204
204
  yield* _(query({ queries }));
205
- const syncWorkerPostMessage = yield* _(SyncWorkerPostMessage);
206
- const config = yield* _(Config);
207
- const owner = yield* _(Owner);
208
- const timestampAndMerkleTree = yield* _(readTimestampAndMerkleTree);
209
- syncWorkerPostMessage({
210
- ...timestampAndMerkleTree,
205
+ (yield* _(SyncWorkerPostMessage))({
211
206
  _tag: "sync",
212
- syncUrl: config.syncUrl,
213
- owner,
207
+ ...(yield* _(readTimestampAndMerkleTree)),
208
+ syncUrl: (yield* _(Config)).syncUrl,
209
+ owner: yield* _(Owner),
214
210
  messages: [],
215
211
  syncLoopCount: 0,
216
212
  });
@@ -15,14 +15,11 @@ export interface Evolu<T extends Schema = Schema> {
15
15
  /**
16
16
  * Subscribe to {@link EvoluError} changes.
17
17
  *
18
- * ### Example
19
- *
20
- * ```ts
21
- * const unsubscribe = evolu.subscribeError(() => {
22
- * const error = evolu.getError();
23
- * console.log(error);
24
- * });
25
- * ```
18
+ * @example
19
+ * const unsubscribe = evolu.subscribeError(() => {
20
+ * const error = evolu.getError();
21
+ * console.log(error);
22
+ * });
26
23
  */
27
24
  readonly subscribeError: Store<EvoluError | null>["subscribe"];
28
25
  /** Get {@link EvoluError}. */
@@ -35,18 +32,15 @@ export interface Evolu<T extends Schema = Schema> {
35
32
  *
36
33
  * For mutations, use {@link create} and {@link update}.
37
34
  *
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),
35
+ * @example
36
+ * const allTodos = evolu.createQuery((db) =>
37
+ * db.selectFrom("todo").selectAll(),
48
38
  * );
49
- * ```
39
+ *
40
+ * const todoById = (id: TodoId) =>
41
+ * evolu.createQuery((db) =>
42
+ * db.selectFrom("todo").selectAll().where("id", "=", id),
43
+ * );
50
44
  */
51
45
  readonly createQuery: CreateQuery<T>;
52
46
  /**
@@ -90,16 +84,13 @@ export interface Evolu<T extends Schema = Schema> {
90
84
  * meaningful only for visible (hence subscribed) queries anyway. To subscribe
91
85
  * to a query, use {@link subscribeQuery}.
92
86
  *
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
- * ```
87
+ * @example
88
+ * const allTodos = evolu.createQuery((db) =>
89
+ * db.selectFrom("todo").selectAll(),
90
+ * );
91
+ * evolu.loadQuery(allTodos).then(({ rows }) => {
92
+ * console.log(rows);
93
+ * });
103
94
  */
104
95
  readonly loadQuery: LoadQuery;
105
96
  /**
@@ -107,88 +98,67 @@ export interface Evolu<T extends Schema = Schema> {
107
98
  * {@link QueryResult} promises. It's like `queries.map(loadQuery)` but with
108
99
  * proper types for returned promises.
109
100
  *
110
- * ### Example
111
- *
112
- * ```ts
113
- * evolu.loadQueries([allTodos, todoById(1)]);
114
- * ```
101
+ * @example
102
+ * evolu.loadQueries([allTodos, todoById(1)]);
115
103
  */
116
104
  readonly loadQueries: <R extends Row, Q extends Queries<R>>(queries: [...Q]) => [...QueryResultsPromisesFromQueries<Q>];
117
105
  /**
118
106
  * Subscribe to {@link Query} {@link QueryResult} changes.
119
107
  *
120
- * ### Example
121
- *
122
- * ```ts
123
- * const unsubscribe = evolu.subscribeQuery(allTodos)(() => {
124
- * const { rows } = evolu.getQuery(allTodos);
125
- * });
126
- * ```
108
+ * @example
109
+ * const unsubscribe = evolu.subscribeQuery(allTodos)(() => {
110
+ * const { rows } = evolu.getQuery(allTodos);
111
+ * });
127
112
  */
128
113
  readonly subscribeQuery: SubscribedQueries["subscribeQuery"];
129
114
  /**
130
115
  * Get {@link Query} {@link QueryResult}.
131
116
  *
132
- * ### Example
133
- *
134
- * ```ts
135
- * const unsubscribe = evolu.subscribeQuery(allTodos)(() => {
136
- * const { rows } = evolu.getQuery(allTodos);
137
- * });
138
- * ```
117
+ * @example
118
+ * const unsubscribe = evolu.subscribeQuery(allTodos)(() => {
119
+ * const { rows } = evolu.getQuery(allTodos);
120
+ * });
139
121
  */
140
122
  readonly getQuery: SubscribedQueries["getQuery"];
141
123
  /**
142
124
  * Subscribe to {@link Owner} changes.
143
125
  *
144
- * ### Example
145
- *
146
- * ```ts
147
- * const unsubscribe = evolu.subscribeOwner(() => {
148
- * const owner = evolu.getOwner();
149
- * });
150
- * ```
126
+ * @example
127
+ * const unsubscribe = evolu.subscribeOwner(() => {
128
+ * const owner = evolu.getOwner();
129
+ * });
151
130
  */
152
131
  readonly subscribeOwner: Store<Owner | null>["subscribe"];
153
132
  /**
154
133
  * Get {@link Owner}.
155
134
  *
156
- * ### Example
157
- *
158
- * ```ts
159
- * const unsubscribe = evolu.subscribeOwner(() => {
160
- * const owner = evolu.getOwner();
161
- * });
162
- * ```
135
+ * @example
136
+ * const unsubscribe = evolu.subscribeOwner(() => {
137
+ * const owner = evolu.getOwner();
138
+ * });
163
139
  */
164
140
  readonly getOwner: Store<Owner | null>["getState"];
165
141
  /**
166
142
  * Subscribe to {@link SyncState} changes.
167
143
  *
168
- * ### Example
169
- *
170
- * ```ts
171
- * const unsubscribe = evolu.subscribeSyncState(() => {
172
- * const syncState = evolu.getSyncState();
173
- * });
174
- * ```
144
+ * @example
145
+ * const unsubscribe = evolu.subscribeSyncState(() => {
146
+ * const syncState = evolu.getSyncState();
147
+ * });
175
148
  */
176
149
  readonly subscribeSyncState: Store<SyncState>["subscribe"];
177
150
  /**
178
151
  * Get {@link SyncState}.
179
152
  *
180
- * ### Example
181
- *
182
- * ```ts
183
- * const unsubscribe = evolu.subscribeSyncState(() => {
184
- * const syncState = evolu.getSyncState();
185
- * });
186
- * ```
153
+ * @example
154
+ * const unsubscribe = evolu.subscribeSyncState(() => {
155
+ * const syncState = evolu.getSyncState();
156
+ * });
187
157
  */
188
158
  readonly getSyncState: Store<SyncState>["getState"];
189
159
  /**
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.
160
+ * Create a row in the database and returns a new ID. The first argument is
161
+ * the table name, and the second is an object.
192
162
  *
193
163
  * The third optional argument, the onComplete callback, is generally
194
164
  * unnecessary because creating a row cannot fail. Still, UI libraries can use
@@ -202,23 +172,20 @@ export interface Evolu<T extends Schema = Schema> {
202
172
  * useful columns common to all tables. Those columns are: `createdAt`,
203
173
  * `updatedAt`, and `isDeleted`.
204
174
  *
205
- * ### Example
175
+ * @example
176
+ * import * as S from "@effect/schema/Schema";
206
177
  *
207
- * ```ts
208
- * import * as S from "@effect/schema/Schema";
178
+ * // Evolu uses the Schema to enforce domain model.
179
+ * const title = S.parseSync(Evolu.NonEmptyString1000)("A title");
209
180
  *
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
- * ```
181
+ * const { id } = evolu.create("todo", { title }, () => {
182
+ * // onComplete callback
183
+ * });
217
184
  */
218
- create: Mutate<T, "create">;
185
+ create: Create<T>;
219
186
  /**
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.
187
+ * Update a row in the database and returns the existing ID. The first
188
+ * argument is the table name, and the second is an object.
222
189
  *
223
190
  * The third optional argument, the onComplete callback, is generally
224
191
  * unnecessary because creating a row cannot fail. Still, UI libraries can use
@@ -232,20 +199,17 @@ export interface Evolu<T extends Schema = Schema> {
232
199
  * useful columns common to all tables. Those columns are: `createdAt`,
233
200
  * `updatedAt`, and `isDeleted`.
234
201
  *
235
- * ### Example
202
+ * @example
203
+ * import * as S from "@effect/schema/Schema";
236
204
  *
237
- * ```ts
238
- * import * as S from "@effect/schema/Schema";
205
+ * // Evolu uses the Schema to enforce domain model.
206
+ * const title = S.parseSync(Evolu.NonEmptyString1000)("A title");
207
+ * evolu.update("todo", { id, title });
239
208
  *
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
- * ```
209
+ * // To delete a row, set `isDeleted` to true.
210
+ * evolu.update("todo", { id, isDeleted: true });
247
211
  */
248
- update: Mutate<T, "update">;
212
+ update: Update<T>;
249
213
  /**
250
214
  * Delete {@link Owner} and all their data from the current device. After the
251
215
  * deletion, Evolu will purge the application state. For browsers, this will
@@ -256,6 +220,14 @@ export interface Evolu<T extends Schema = Schema> {
256
220
  readonly restoreOwner: (mnemonic: Mnemonic) => void;
257
221
  /** Ensure tables and columns defined in {@link Schema} exist in the database. */
258
222
  readonly ensureSchema: <From, To extends T>(schema: S.Schema<From, To>) => void;
223
+ /**
224
+ * Force sync with Evolu Server.
225
+ *
226
+ * Evolu syncs on every mutation, tab focus, and network reconnect, so it's
227
+ * generally not required to sync manually, but if you need it, you can do
228
+ * it.
229
+ */
230
+ readonly sync: () => void;
259
231
  }
260
232
  export declare const Evolu: Context.Tag<Evolu<Schema>, Evolu<Schema>>;
261
233
  type CreateQuery<S extends Schema> = <R extends Row>(queryCallback: QueryCallback<S, R>) => Query<R>;
@@ -302,12 +274,14 @@ export interface SubscribedQueries {
302
274
  }
303
275
  export declare const SubscribedQueries: Context.Tag<SubscribedQueries, SubscribedQueries>;
304
276
  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">>> & {
277
+ export type Create<S extends Schema = Schema> = Mutate<S, "create">;
278
+ export type Update<S extends Schema = Schema> = Mutate<S, "update">;
279
+ export 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
280
  readonly id: S[K]["id"];
307
281
  }>, onComplete?: () => void) => {
308
282
  readonly id: S[K]["id"];
309
283
  };
310
- declare const Mutate: Context.Tag<Mutate<Schema, "update">, Mutate<Schema, "update">>;
284
+ export declare const Mutate: Context.Tag<Mutate<Schema, "update">, Mutate<Schema, "update">>;
311
285
  type PartialForNullable<T, NK extends keyof T = {
312
286
  [K in keyof T]: null extends T[K] ? K : never;
313
287
  }[keyof T], NP = Pick<T, Exclude<keyof T, NK>> & Partial<Pick<T, NK>>> = {
@@ -325,5 +299,6 @@ type Castable<T> = {
325
299
  };
326
300
  /** EvoluCommonLive has only platform independent side-effects. */
327
301
  export declare const EvoluCommonLive: Layer.Layer<Config | FlushSync | AppState | DbWorker, never, Evolu<Schema>>;
302
+ export declare const makeCreateEvolu: (EvoluLive: Layer.Layer<Config, never, Evolu<Schema>>) => <From, To extends Schema>(schema: S.Schema<From, To>, config?: Partial<Config>) => Evolu<To>;
328
303
  export {};
329
304
  //# sourceMappingURL=Evolu.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Evolu.d.ts","sourceRoot":"","sources":["../../src/Evolu.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EACL,OAAO,EAGP,KAAK,EAKN,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAsB,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,OAAO,EACP,KAAK,EACL,WAAW,EACX,+BAA+B,EAC/B,GAAG,EACH,SAAS,EAET,MAAM,EAKP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAmC,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAkB,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAQ,MAAM,YAAY,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,KAAK,EAA0B,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,WAAW,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IAC9C;;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,CAAC,GAAG,CAAC,GAAG,KAAK;CAC9C,CAAC,MAAM,CAAC,CAAC,EACV,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IACvD;KAAG,CAAC,IAAI,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;CAAE,CAAC;AAE/B;;;;;;GAMG;AACH,KAAK,QAAQ,CAAC,CAAC,IAAI;IACjB,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,aAAa,GAC/C,OAAO,GAAG,aAAa,GACvB,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,aAAa,GAC/B,IAAI,GAAG,OAAO,GAAG,aAAa,GAC9B,CAAC,CAAC,CAAC,CAAC,SAAS,UAAU,GACrB,IAAI,GAAG,UAAU,GACjB,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,UAAU,GAC5B,IAAI,GAAG,IAAI,GAAG,UAAU,GACxB,CAAC,CAAC,CAAC,CAAC;CACf,CAAC;AA+IF,kEAAkE;AAClE,eAAO,MAAM,eAAe,6EAE3B,CAAC;AAEF,eAAO,MAAM,eAAe,cACd,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC,CAAC,oEAG1C,QAAQ,MAAM,CAAC,cAYzB,CAAC"}
package/dist/src/Evolu.js CHANGED
@@ -1,6 +1,6 @@
1
- import { Context, Effect, Function, Layer, Match, Number, ReadonlyArray, pipe, } from "effect";
1
+ import { Context, Effect, Function, GlobalValue, Layer, Match, Number, ReadonlyArray, pipe, } from "effect";
2
2
  import * as Kysely from "kysely";
3
- import { Config } from "./Config.js";
3
+ import { Config, ConfigLive } from "./Config.js";
4
4
  import { Time, TimeLive } from "./Crdt.js";
5
5
  import { NanoId, NanoIdLive } from "./Crypto.js";
6
6
  import { RowsStore, RowsStoreLive, emptyRows, queryResultFromRows, schemaToTables, serializeQuery, } from "./Db.js";
@@ -145,7 +145,7 @@ export const SubscribedQueriesLive = Layer.effect(SubscribedQueries, Effect.gen(
145
145
  getSubscribedQueries: () => ReadonlyArray.fromIterable(subscribedQueries.keys()),
146
146
  });
147
147
  }));
148
- const Mutate = Context.Tag();
148
+ export const Mutate = Context.Tag();
149
149
  const MutateLive = Layer.effect(Mutate, Effect.gen(function* (_) {
150
150
  const nanoid = yield* _(NanoId);
151
151
  const onCompletes = yield* _(OnCompletes);
@@ -215,14 +215,11 @@ const EvoluCommon = Layer.effect(Evolu, Effect.gen(function* (_) {
215
215
  _tag: "init",
216
216
  config: yield* _(Config),
217
217
  });
218
- appState.init({
219
- onFocus: () => {
220
- dbWorker.postMessage({ _tag: "sync", queries: getSubscribedQueries() });
221
- },
222
- onReconnect: () => {
223
- dbWorker.postMessage({ _tag: "sync", queries: [] });
224
- },
225
- });
218
+ const sync = () => {
219
+ dbWorker.postMessage({ _tag: "sync", queries: getSubscribedQueries() });
220
+ };
221
+ appState.init({ onRequestSync: sync });
222
+ sync();
226
223
  return Evolu.of({
227
224
  subscribeError: errorStore.subscribe,
228
225
  getError: errorStore.getState,
@@ -243,7 +240,14 @@ const EvoluCommon = Layer.effect(Evolu, Effect.gen(function* (_) {
243
240
  _tag: "ensureSchema",
244
241
  tables: schemaToTables(schema),
245
242
  }),
243
+ sync,
246
244
  });
247
245
  })).pipe(Layer.provide(Layer.mergeAll(LoadQueryLive, OnQueryLive, MutateLive)), Layer.provide(LoadingPromiseLive), Layer.provide(SubscribedQueriesLive), Layer.provide(Layer.merge(RowsStoreLive, OnCompletesLive)));
248
246
  /** EvoluCommonLive has only platform independent side-effects. */
249
247
  export const EvoluCommonLive = EvoluCommon.pipe(Layer.provide(Layer.merge(TimeLive, NanoIdLive)));
248
+ export const makeCreateEvolu = (EvoluLive) => (schema, config) => {
249
+ // For https://nextjs.org/docs/architecture/fast-refresh etc.
250
+ const evolu = GlobalValue.globalValue("@evolu/common", () => Evolu.pipe(Effect.provide(EvoluLive), Effect.provide(ConfigLive(config)), Effect.runSync));
251
+ evolu.ensureSchema(schema);
252
+ return evolu;
253
+ };
@@ -9,15 +9,12 @@ export type Id = S.Schema.To<typeof Id>;
9
9
  /**
10
10
  * A factory function to create {@link Id} Schema for a specific table.
11
11
  *
12
- * ### Example
12
+ * @example
13
+ * import * as S from "@effect/schema/Schema";
14
+ * import { id } from "@evolu/react";
13
15
  *
14
- * ```ts
15
- * import * as S from "@effect/schema/Schema";
16
- * import * as Evolu from "@evolu/react";
17
- *
18
- * const TodoId = Evolu.id("Todo");
19
- * type TodoId = S.Schema.To<typeof TodoId>;
20
- * ```
16
+ * const TodoId = id("Todo");
17
+ * type TodoId = S.Schema.To<typeof TodoId>;
21
18
  */
22
19
  export declare const id: <T extends string>(table: T) => S.BrandSchema<string, string & Brand.Brand<"Id"> & Brand.Brand<T>>;
23
20
  /**
@@ -39,17 +36,14 @@ export type SqliteBoolean = S.Schema.To<typeof SqliteBoolean>;
39
36
  * Date nor Boolean types, so Evolu emulates them with {@link SqliteBoolean} and
40
37
  * {@link SqliteDate}.
41
38
  *
42
- * ### Example
43
- *
44
- * ```ts
45
- * const allTodosNotDeleted = evolu.createQuery((db) =>
46
- * db
47
- * .selectFrom("todo")
48
- * .selectAll()
49
- * // isDeleted is SqliteBoolean
50
- * .where("isDeleted", "is not", Evolu.cast(true)),
51
- * );
52
- * ```
39
+ * @example
40
+ * const allTodosNotDeleted = evolu.createQuery((db) =>
41
+ * db
42
+ * .selectFrom("todo")
43
+ * .selectAll()
44
+ * // isDeleted is SqliteBoolean
45
+ * .where("isDeleted", "is not", Evolu.cast(true)),
46
+ * );
53
47
  */
54
48
  export declare function cast(value: boolean): SqliteBoolean;
55
49
  export declare function cast(value: SqliteBoolean): boolean;
@@ -66,42 +60,33 @@ export type String = S.Schema.To<typeof String>;
66
60
  /**
67
61
  * A string with a maximum length of 1000 characters.
68
62
  *
69
- * ### Example
70
- *
71
- * ```ts
72
- * import * as S from "@effect/schema/Schema";
73
- * import * as Evolu from "@evolu/react";
63
+ * @example
64
+ * import * as S from "@effect/schema/Schema";
65
+ * import { String1000 } from "@evolu/react";
74
66
  *
75
- * S.parse(Evolu.String1000)(value);
76
- * ```
67
+ * S.parse(String1000)(value);
77
68
  */
78
69
  export declare const String1000: S.BrandSchema<string, string & Brand.Brand<"String"> & Brand.Brand<"String1000">>;
79
70
  export type String1000 = S.Schema.To<typeof String1000>;
80
71
  /**
81
72
  * A nonempty string with a maximum length of 1000 characters.
82
73
  *
83
- * ### Example
74
+ * @example
75
+ * import * as S from "@effect/schema/Schema";
76
+ * import { NonEmptyString1000 } from "@evolu/react";
84
77
  *
85
- * ```ts
86
- * import * as S from "@effect/schema/Schema";
87
- * import * as Evolu from "@evolu/react";
88
- *
89
- * S.parse(Evolu.NonEmptyString1000)(value);
90
- * ```
78
+ * S.parse(NonEmptyString1000)(value);
91
79
  */
92
80
  export declare const NonEmptyString1000: S.BrandSchema<string, string & Brand.Brand<"String"> & Brand.Brand<"NonEmptyString1000">>;
93
81
  export type NonEmptyString1000 = S.Schema.To<typeof NonEmptyString1000>;
94
82
  /**
95
83
  * A positive integer.
96
84
  *
97
- * ### Example
98
- *
99
- * ```ts
100
- * import * as S from "@effect/schema/Schema";
101
- * import * as Evolu from "@evolu/react";
85
+ * @example
86
+ * import * as S from "@effect/schema/Schema";
87
+ * import { PositiveInt } from "@evolu/react";
102
88
  *
103
- * S.parse(Evolu.PositiveInt)(value);
104
- * ```
89
+ * S.parse(PositiveInt)(value);
105
90
  */
106
91
  export declare const PositiveInt: S.BrandSchema<number, number & Brand.Brand<"PositiveInt">>;
107
92
  export type PositiveInt = S.Schema.To<typeof PositiveInt>;
@@ -1 +1 @@
1
- {"version":3,"file":"Model.d.ts","sourceRoot":"","sources":["../../src/Model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,uBAAuB,CAA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,EAAE,CAAC,OAAO,MAAM,CAAC,CAAC;AAEhD;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,mFAAwD,CAAC;AAChF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,UAAU,CAAC,CAAC;AAExD;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,2FAI9B,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAExE;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,4DAIvB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,WAAW,CAAC,CAAC"}
package/dist/src/Model.js CHANGED
@@ -8,15 +8,12 @@ export const Id = S.string.pipe(S.pattern(/^[\w-]{21}$/), S.brand("Id"));
8
8
  /**
9
9
  * A factory function to create {@link Id} Schema for a specific table.
10
10
  *
11
- * ### Example
11
+ * @example
12
+ * import * as S from "@effect/schema/Schema";
13
+ * import { id } from "@evolu/react";
12
14
  *
13
- * ```ts
14
- * import * as S from "@effect/schema/Schema";
15
- * import * as Evolu from "@evolu/react";
16
- *
17
- * const TodoId = Evolu.id("Todo");
18
- * type TodoId = S.Schema.To<typeof TodoId>;
19
- * ```
15
+ * const TodoId = id("Todo");
16
+ * type TodoId = S.Schema.To<typeof TodoId>;
20
17
  */
21
18
  export const id = (table) => Id.pipe(S.brand(table));
22
19
  /**
@@ -60,39 +57,30 @@ export const String = S.string.pipe(S.filter((s) => {
60
57
  /**
61
58
  * A string with a maximum length of 1000 characters.
62
59
  *
63
- * ### Example
64
- *
65
- * ```ts
66
- * import * as S from "@effect/schema/Schema";
67
- * import * as Evolu from "@evolu/react";
60
+ * @example
61
+ * import * as S from "@effect/schema/Schema";
62
+ * import { String1000 } from "@evolu/react";
68
63
  *
69
- * S.parse(Evolu.String1000)(value);
70
- * ```
64
+ * S.parse(String1000)(value);
71
65
  */
72
66
  export const String1000 = String.pipe(S.maxLength(1000), S.brand("String1000"));
73
67
  /**
74
68
  * A nonempty string with a maximum length of 1000 characters.
75
69
  *
76
- * ### Example
70
+ * @example
71
+ * import * as S from "@effect/schema/Schema";
72
+ * import { NonEmptyString1000 } from "@evolu/react";
77
73
  *
78
- * ```ts
79
- * import * as S from "@effect/schema/Schema";
80
- * import * as Evolu from "@evolu/react";
81
- *
82
- * S.parse(Evolu.NonEmptyString1000)(value);
83
- * ```
74
+ * S.parse(NonEmptyString1000)(value);
84
75
  */
85
76
  export const NonEmptyString1000 = String.pipe(S.minLength(1), S.maxLength(1000), S.brand("NonEmptyString1000"));
86
77
  /**
87
78
  * A positive integer.
88
79
  *
89
- * ### Example
90
- *
91
- * ```ts
92
- * import * as S from "@effect/schema/Schema";
93
- * import * as Evolu from "@evolu/react";
80
+ * @example
81
+ * import * as S from "@effect/schema/Schema";
82
+ * import { PositiveInt } from "@evolu/react";
94
83
  *
95
- * S.parse(Evolu.PositiveInt)(value);
96
- * ```
84
+ * S.parse(PositiveInt)(value);
97
85
  */
98
86
  export const PositiveInt = S.number.pipe(S.int(), S.positive(), S.brand("PositiveInt"));
@@ -24,8 +24,7 @@ export interface FetchError {
24
24
  }
25
25
  export declare const FetchLive: Layer.Layer<never, never, Fetch>;
26
26
  interface AppStateConfig {
27
- readonly onFocus: () => void;
28
- readonly onReconnect: () => void;
27
+ readonly onRequestSync: () => void;
29
28
  }
30
29
  export interface AppState {
31
30
  readonly init: (config: AppStateConfig) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"Platform.d.ts","sourceRoot":"","sources":["../../src/Platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEhD,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,eAAe,GACf,kBAAkB,GAClB,cAAc,CAAC;AAEnB,eAAO,MAAM,YAA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AA0B,CAAC;AAEhD,yCAAyC;AACzC,eAAO,MAAM,SAAS,SAYlB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evolu/common",
3
- "version": "2.0.6",
3
+ "version": "2.2.0",
4
4
  "description": "Local-first platform designed for privacy, ease of use, and no vendor lock-in to sync and backup people's lifetime data",
5
5
  "keywords": [
6
6
  "evolu",
@@ -46,25 +46,25 @@
46
46
  "dependencies": {
47
47
  "@noble/ciphers": "^0.4.0",
48
48
  "@noble/hashes": "^1.3.2",
49
- "@protobuf-ts/runtime": "^2.9.1",
49
+ "@protobuf-ts/runtime": "2.9.1",
50
50
  "@scure/bip39": "^1.2.1",
51
51
  "kysely": "^0.26.3",
52
52
  "nanoid": "^5.0.4"
53
53
  },
54
54
  "devDependencies": {
55
- "@effect/schema": "0.51.1",
56
- "@protobuf-ts/plugin": "^2.9.1",
57
- "@protobuf-ts/protoc": "^2.9.1",
55
+ "@effect/schema": "0.52.0",
56
+ "@protobuf-ts/plugin": "2.9.1",
57
+ "@protobuf-ts/protoc": "2.9.1",
58
58
  "array-shuffle": "^3.0.0",
59
- "effect": "2.0.0-next.58",
59
+ "effect": "2.0.0-next.59",
60
60
  "eslint": "^8.54.0",
61
- "typescript": "^5.3.2",
62
- "vitest": "^0.34.6",
61
+ "typescript": "^5.3.3",
62
+ "vitest": "^1.0.1",
63
63
  "@evolu/tsconfig": "0.0.2",
64
64
  "eslint-config-evolu": "1.0.0"
65
65
  },
66
66
  "peerDependencies": {
67
- "@effect/schema": "0.51.1",
67
+ "@effect/schema": "0.51.4",
68
68
  "effect": "2.0.0-next.58"
69
69
  },
70
70
  "publishConfig": {
package/src/DbWorker.ts CHANGED
@@ -537,16 +537,11 @@ const sync = ({
537
537
  Effect.gen(function* (_) {
538
538
  if (queries.length > 0) yield* _(query({ queries }));
539
539
 
540
- const syncWorkerPostMessage = yield* _(SyncWorkerPostMessage);
541
- const config = yield* _(Config);
542
- const owner = yield* _(Owner);
543
- const timestampAndMerkleTree = yield* _(readTimestampAndMerkleTree);
544
-
545
- syncWorkerPostMessage({
546
- ...timestampAndMerkleTree,
540
+ (yield* _(SyncWorkerPostMessage))({
547
541
  _tag: "sync",
548
- syncUrl: config.syncUrl,
549
- owner,
542
+ ...(yield* _(readTimestampAndMerkleTree)),
543
+ syncUrl: (yield* _(Config)).syncUrl,
544
+ owner: yield* _(Owner),
550
545
  messages: [],
551
546
  syncLoopCount: 0,
552
547
  });
package/src/Evolu.ts CHANGED
@@ -3,6 +3,7 @@ import {
3
3
  Context,
4
4
  Effect,
5
5
  Function,
6
+ GlobalValue,
6
7
  Layer,
7
8
  Match,
8
9
  Number,
@@ -10,7 +11,7 @@ import {
10
11
  pipe,
11
12
  } from "effect";
12
13
  import * as Kysely from "kysely";
13
- import { Config } from "./Config.js";
14
+ import { Config, ConfigLive } from "./Config.js";
14
15
  import { Time, TimeLive } from "./Crdt.js";
15
16
  import { Mnemonic, NanoId, NanoIdLive } from "./Crypto.js";
16
17
  import {
@@ -42,14 +43,11 @@ export interface Evolu<T extends Schema = Schema> {
42
43
  /**
43
44
  * Subscribe to {@link EvoluError} changes.
44
45
  *
45
- * ### Example
46
- *
47
- * ```ts
48
- * const unsubscribe = evolu.subscribeError(() => {
49
- * const error = evolu.getError();
50
- * console.log(error);
51
- * });
52
- * ```
46
+ * @example
47
+ * const unsubscribe = evolu.subscribeError(() => {
48
+ * const error = evolu.getError();
49
+ * console.log(error);
50
+ * });
53
51
  */
54
52
  readonly subscribeError: Store<EvoluError | null>["subscribe"];
55
53
 
@@ -64,18 +62,15 @@ export interface Evolu<T extends Schema = Schema> {
64
62
  *
65
63
  * For mutations, use {@link create} and {@link update}.
66
64
  *
67
- * ### Example
68
- *
69
- * ```ts
70
- * const allTodos = evolu.createQuery((db) =>
71
- * db.selectFrom("todo").selectAll(),
72
- * );
73
- *
74
- * const todoById = (id: TodoId) =>
75
- * evolu.createQuery((db) =>
76
- * db.selectFrom("todo").selectAll().where("id", "=", id),
65
+ * @example
66
+ * const allTodos = evolu.createQuery((db) =>
67
+ * db.selectFrom("todo").selectAll(),
77
68
  * );
78
- * ```
69
+ *
70
+ * const todoById = (id: TodoId) =>
71
+ * evolu.createQuery((db) =>
72
+ * db.selectFrom("todo").selectAll().where("id", "=", id),
73
+ * );
79
74
  */
80
75
  readonly createQuery: CreateQuery<T>;
81
76
 
@@ -120,16 +115,13 @@ export interface Evolu<T extends Schema = Schema> {
120
115
  * meaningful only for visible (hence subscribed) queries anyway. To subscribe
121
116
  * to a query, use {@link subscribeQuery}.
122
117
  *
123
- * ### Example
124
- *
125
- * ```ts
126
- * const allTodos = evolu.createQuery((db) =>
127
- * db.selectFrom("todo").selectAll(),
128
- * );
129
- * evolu.loadQuery(allTodos).then(({ rows }) => {
130
- * console.log(rows);
131
- * });
132
- * ```
118
+ * @example
119
+ * const allTodos = evolu.createQuery((db) =>
120
+ * db.selectFrom("todo").selectAll(),
121
+ * );
122
+ * evolu.loadQuery(allTodos).then(({ rows }) => {
123
+ * console.log(rows);
124
+ * });
133
125
  */
134
126
  readonly loadQuery: LoadQuery;
135
127
 
@@ -138,11 +130,8 @@ export interface Evolu<T extends Schema = Schema> {
138
130
  * {@link QueryResult} promises. It's like `queries.map(loadQuery)` but with
139
131
  * proper types for returned promises.
140
132
  *
141
- * ### Example
142
- *
143
- * ```ts
144
- * evolu.loadQueries([allTodos, todoById(1)]);
145
- * ```
133
+ * @example
134
+ * evolu.loadQueries([allTodos, todoById(1)]);
146
135
  */
147
136
  readonly loadQueries: <R extends Row, Q extends Queries<R>>(
148
137
  queries: [...Q],
@@ -151,84 +140,66 @@ export interface Evolu<T extends Schema = Schema> {
151
140
  /**
152
141
  * Subscribe to {@link Query} {@link QueryResult} changes.
153
142
  *
154
- * ### Example
155
- *
156
- * ```ts
157
- * const unsubscribe = evolu.subscribeQuery(allTodos)(() => {
158
- * const { rows } = evolu.getQuery(allTodos);
159
- * });
160
- * ```
143
+ * @example
144
+ * const unsubscribe = evolu.subscribeQuery(allTodos)(() => {
145
+ * const { rows } = evolu.getQuery(allTodos);
146
+ * });
161
147
  */
162
148
  readonly subscribeQuery: SubscribedQueries["subscribeQuery"];
163
149
 
164
150
  /**
165
151
  * Get {@link Query} {@link QueryResult}.
166
152
  *
167
- * ### Example
168
- *
169
- * ```ts
170
- * const unsubscribe = evolu.subscribeQuery(allTodos)(() => {
171
- * const { rows } = evolu.getQuery(allTodos);
172
- * });
173
- * ```
153
+ * @example
154
+ * const unsubscribe = evolu.subscribeQuery(allTodos)(() => {
155
+ * const { rows } = evolu.getQuery(allTodos);
156
+ * });
174
157
  */
175
158
  readonly getQuery: SubscribedQueries["getQuery"];
176
159
 
177
160
  /**
178
161
  * Subscribe to {@link Owner} changes.
179
162
  *
180
- * ### Example
181
- *
182
- * ```ts
183
- * const unsubscribe = evolu.subscribeOwner(() => {
184
- * const owner = evolu.getOwner();
185
- * });
186
- * ```
163
+ * @example
164
+ * const unsubscribe = evolu.subscribeOwner(() => {
165
+ * const owner = evolu.getOwner();
166
+ * });
187
167
  */
188
168
  readonly subscribeOwner: Store<Owner | null>["subscribe"];
189
169
 
190
170
  /**
191
171
  * Get {@link Owner}.
192
172
  *
193
- * ### Example
194
- *
195
- * ```ts
196
- * const unsubscribe = evolu.subscribeOwner(() => {
197
- * const owner = evolu.getOwner();
198
- * });
199
- * ```
173
+ * @example
174
+ * const unsubscribe = evolu.subscribeOwner(() => {
175
+ * const owner = evolu.getOwner();
176
+ * });
200
177
  */
201
178
  readonly getOwner: Store<Owner | null>["getState"];
202
179
 
203
180
  /**
204
181
  * Subscribe to {@link SyncState} changes.
205
182
  *
206
- * ### Example
207
- *
208
- * ```ts
209
- * const unsubscribe = evolu.subscribeSyncState(() => {
210
- * const syncState = evolu.getSyncState();
211
- * });
212
- * ```
183
+ * @example
184
+ * const unsubscribe = evolu.subscribeSyncState(() => {
185
+ * const syncState = evolu.getSyncState();
186
+ * });
213
187
  */
214
188
  readonly subscribeSyncState: Store<SyncState>["subscribe"];
215
189
 
216
190
  /**
217
191
  * Get {@link SyncState}.
218
192
  *
219
- * ### Example
220
- *
221
- * ```ts
222
- * const unsubscribe = evolu.subscribeSyncState(() => {
223
- * const syncState = evolu.getSyncState();
224
- * });
225
- * ```
193
+ * @example
194
+ * const unsubscribe = evolu.subscribeSyncState(() => {
195
+ * const syncState = evolu.getSyncState();
196
+ * });
226
197
  */
227
198
  readonly getSyncState: Store<SyncState>["getState"];
228
199
 
229
200
  /**
230
- * The function creates a row in the database and returns a new ID. The first
231
- * argument is the table name, and the second is an object.
201
+ * Create a row in the database and returns a new ID. The first argument is
202
+ * the table name, and the second is an object.
232
203
  *
233
204
  * The third optional argument, the onComplete callback, is generally
234
205
  * unnecessary because creating a row cannot fail. Still, UI libraries can use
@@ -242,24 +213,21 @@ export interface Evolu<T extends Schema = Schema> {
242
213
  * useful columns common to all tables. Those columns are: `createdAt`,
243
214
  * `updatedAt`, and `isDeleted`.
244
215
  *
245
- * ### Example
246
- *
247
- * ```ts
248
- * import * as S from "@effect/schema/Schema";
216
+ * @example
217
+ * import * as S from "@effect/schema/Schema";
249
218
  *
250
- * // Evolu uses the Schema to enforce domain model.
251
- * const title = S.parseSync(Evolu.NonEmptyString1000)("A title");
219
+ * // Evolu uses the Schema to enforce domain model.
220
+ * const title = S.parseSync(Evolu.NonEmptyString1000)("A title");
252
221
  *
253
- * const { id } = evolu.create("todo", { title }, () => {
254
- * // onComplete callback
255
- * });
256
- * ```
222
+ * const { id } = evolu.create("todo", { title }, () => {
223
+ * // onComplete callback
224
+ * });
257
225
  */
258
- create: Mutate<T, "create">;
226
+ create: Create<T>;
259
227
 
260
228
  /**
261
- * The function updates a row in the database and returns the existing ID. The
262
- * first argument is the table name, and the second is an object.
229
+ * Update a row in the database and returns the existing ID. The first
230
+ * argument is the table name, and the second is an object.
263
231
  *
264
232
  * The third optional argument, the onComplete callback, is generally
265
233
  * unnecessary because creating a row cannot fail. Still, UI libraries can use
@@ -273,20 +241,17 @@ export interface Evolu<T extends Schema = Schema> {
273
241
  * useful columns common to all tables. Those columns are: `createdAt`,
274
242
  * `updatedAt`, and `isDeleted`.
275
243
  *
276
- * ### Example
277
- *
278
- * ```ts
279
- * import * as S from "@effect/schema/Schema";
244
+ * @example
245
+ * import * as S from "@effect/schema/Schema";
280
246
  *
281
- * // Evolu uses the Schema to enforce domain model.
282
- * const title = S.parseSync(Evolu.NonEmptyString1000)("A title");
283
- * evolu.update("todo", { id, title });
247
+ * // Evolu uses the Schema to enforce domain model.
248
+ * const title = S.parseSync(Evolu.NonEmptyString1000)("A title");
249
+ * evolu.update("todo", { id, title });
284
250
  *
285
- * // To delete a row, set `isDeleted` to true.
286
- * evolu.update("todo", { id, isDeleted: true });
287
- * ```
251
+ * // To delete a row, set `isDeleted` to true.
252
+ * evolu.update("todo", { id, isDeleted: true });
288
253
  */
289
- update: Mutate<T, "update">;
254
+ update: Update<T>;
290
255
 
291
256
  /**
292
257
  * Delete {@link Owner} and all their data from the current device. After the
@@ -302,6 +267,15 @@ export interface Evolu<T extends Schema = Schema> {
302
267
  readonly ensureSchema: <From, To extends T>(
303
268
  schema: S.Schema<From, To>,
304
269
  ) => void;
270
+
271
+ /**
272
+ * Force sync with Evolu Server.
273
+ *
274
+ * Evolu syncs on every mutation, tab focus, and network reconnect, so it's
275
+ * generally not required to sync manually, but if you need it, you can do
276
+ * it.
277
+ */
278
+ readonly sync: () => void;
305
279
  }
306
280
 
307
281
  export const Evolu = Context.Tag<Evolu>();
@@ -574,7 +548,11 @@ export const SubscribedQueriesLive = Layer.effect(
574
548
  }),
575
549
  );
576
550
 
577
- type Mutate<
551
+ export type Create<S extends Schema = Schema> = Mutate<S, "create">;
552
+
553
+ export type Update<S extends Schema = Schema> = Mutate<S, "update">;
554
+
555
+ export type Mutate<
578
556
  S extends Schema = Schema,
579
557
  Mode extends "create" | "update" = "update",
580
558
  > = <K extends keyof S>(
@@ -591,7 +569,7 @@ type Mutate<
591
569
  readonly id: S[K]["id"];
592
570
  };
593
571
 
594
- const Mutate = Context.Tag<Mutate>();
572
+ export const Mutate = Context.Tag<Mutate>();
595
573
 
596
574
  // https://stackoverflow.com/a/54713648/233902
597
575
  type PartialForNullable<
@@ -711,14 +689,13 @@ const EvoluCommon = Layer.effect(
711
689
  config: yield* _(Config),
712
690
  });
713
691
 
714
- appState.init({
715
- onFocus: () => {
716
- dbWorker.postMessage({ _tag: "sync", queries: getSubscribedQueries() });
717
- },
718
- onReconnect: () => {
719
- dbWorker.postMessage({ _tag: "sync", queries: [] });
720
- },
721
- });
692
+ const sync = (): void => {
693
+ dbWorker.postMessage({ _tag: "sync", queries: getSubscribedQueries() });
694
+ };
695
+
696
+ appState.init({ onRequestSync: sync });
697
+
698
+ sync();
722
699
 
723
700
  return Evolu.of({
724
701
  subscribeError: errorStore.subscribe,
@@ -752,6 +729,8 @@ const EvoluCommon = Layer.effect(
752
729
  _tag: "ensureSchema",
753
730
  tables: schemaToTables(schema),
754
731
  }),
732
+
733
+ sync,
755
734
  });
756
735
  }),
757
736
  ).pipe(
@@ -765,3 +744,21 @@ const EvoluCommon = Layer.effect(
765
744
  export const EvoluCommonLive = EvoluCommon.pipe(
766
745
  Layer.provide(Layer.merge(TimeLive, NanoIdLive)),
767
746
  );
747
+
748
+ export const makeCreateEvolu =
749
+ (EvoluLive: Layer.Layer<Config, never, Evolu<Schema>>) =>
750
+ <From, To extends Schema>(
751
+ schema: S.Schema<From, To>,
752
+ config?: Partial<Config>,
753
+ ): Evolu<To> => {
754
+ // For https://nextjs.org/docs/architecture/fast-refresh etc.
755
+ const evolu = GlobalValue.globalValue("@evolu/common", () =>
756
+ Evolu.pipe(
757
+ Effect.provide(EvoluLive),
758
+ Effect.provide(ConfigLive(config)),
759
+ Effect.runSync,
760
+ ),
761
+ );
762
+ evolu.ensureSchema(schema);
763
+ return evolu as Evolu<To>;
764
+ };
package/src/Model.ts CHANGED
@@ -12,15 +12,12 @@ export type Id = S.Schema.To<typeof Id>;
12
12
  /**
13
13
  * A factory function to create {@link Id} Schema for a specific table.
14
14
  *
15
- * ### Example
15
+ * @example
16
+ * import * as S from "@effect/schema/Schema";
17
+ * import { id } from "@evolu/react";
16
18
  *
17
- * ```ts
18
- * import * as S from "@effect/schema/Schema";
19
- * import * as Evolu from "@evolu/react";
20
- *
21
- * const TodoId = Evolu.id("Todo");
22
- * type TodoId = S.Schema.To<typeof TodoId>;
23
- * ```
19
+ * const TodoId = id("Todo");
20
+ * type TodoId = S.Schema.To<typeof TodoId>;
24
21
  */
25
22
  export const id = <T extends string>(
26
23
  table: T,
@@ -55,17 +52,14 @@ export type SqliteBoolean = S.Schema.To<typeof SqliteBoolean>;
55
52
  * Date nor Boolean types, so Evolu emulates them with {@link SqliteBoolean} and
56
53
  * {@link SqliteDate}.
57
54
  *
58
- * ### Example
59
- *
60
- * ```ts
61
- * const allTodosNotDeleted = evolu.createQuery((db) =>
62
- * db
63
- * .selectFrom("todo")
64
- * .selectAll()
65
- * // isDeleted is SqliteBoolean
66
- * .where("isDeleted", "is not", Evolu.cast(true)),
67
- * );
68
- * ```
55
+ * @example
56
+ * const allTodosNotDeleted = evolu.createQuery((db) =>
57
+ * db
58
+ * .selectFrom("todo")
59
+ * .selectAll()
60
+ * // isDeleted is SqliteBoolean
61
+ * .where("isDeleted", "is not", Evolu.cast(true)),
62
+ * );
69
63
  */
70
64
  export function cast(value: boolean): SqliteBoolean;
71
65
  export function cast(value: SqliteBoolean): boolean;
@@ -107,14 +101,11 @@ export type String = S.Schema.To<typeof String>;
107
101
  /**
108
102
  * A string with a maximum length of 1000 characters.
109
103
  *
110
- * ### Example
111
- *
112
- * ```ts
113
- * import * as S from "@effect/schema/Schema";
114
- * import * as Evolu from "@evolu/react";
104
+ * @example
105
+ * import * as S from "@effect/schema/Schema";
106
+ * import { String1000 } from "@evolu/react";
115
107
  *
116
- * S.parse(Evolu.String1000)(value);
117
- * ```
108
+ * S.parse(String1000)(value);
118
109
  */
119
110
  export const String1000 = String.pipe(S.maxLength(1000), S.brand("String1000"));
120
111
  export type String1000 = S.Schema.To<typeof String1000>;
@@ -122,14 +113,11 @@ export type String1000 = S.Schema.To<typeof String1000>;
122
113
  /**
123
114
  * A nonempty string with a maximum length of 1000 characters.
124
115
  *
125
- * ### Example
116
+ * @example
117
+ * import * as S from "@effect/schema/Schema";
118
+ * import { NonEmptyString1000 } from "@evolu/react";
126
119
  *
127
- * ```ts
128
- * import * as S from "@effect/schema/Schema";
129
- * import * as Evolu from "@evolu/react";
130
- *
131
- * S.parse(Evolu.NonEmptyString1000)(value);
132
- * ```
120
+ * S.parse(NonEmptyString1000)(value);
133
121
  */
134
122
  export const NonEmptyString1000 = String.pipe(
135
123
  S.minLength(1),
@@ -141,14 +129,11 @@ export type NonEmptyString1000 = S.Schema.To<typeof NonEmptyString1000>;
141
129
  /**
142
130
  * A positive integer.
143
131
  *
144
- * ### Example
145
- *
146
- * ```ts
147
- * import * as S from "@effect/schema/Schema";
148
- * import * as Evolu from "@evolu/react";
132
+ * @example
133
+ * import * as S from "@effect/schema/Schema";
134
+ * import { PositiveInt } from "@evolu/react";
149
135
  *
150
- * S.parse(Evolu.PositiveInt)(value);
151
- * ```
136
+ * S.parse(PositiveInt)(value);
152
137
  */
153
138
  export const PositiveInt = S.number.pipe(
154
139
  S.int(),
package/src/Platform.ts CHANGED
@@ -59,8 +59,7 @@ export const FetchLive = Layer.succeed(
59
59
  );
60
60
 
61
61
  interface AppStateConfig {
62
- readonly onFocus: () => void;
63
- readonly onReconnect: () => void;
62
+ readonly onRequestSync: () => void;
64
63
  }
65
64
 
66
65
  export interface AppState {