@evolu/common 2.0.5 → 2.1.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.
@@ -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
206
- *
207
- * ```ts
208
- * import * as S from "@effect/schema/Schema";
175
+ * @example
176
+ * import * as S from "@effect/schema/Schema";
209
177
  *
210
- * // Evolu uses the Schema to enforce domain model.
211
- * const title = S.parseSync(Evolu.NonEmptyString1000)("A title");
178
+ * // Evolu uses the Schema to enforce domain model.
179
+ * const title = S.parseSync(Evolu.NonEmptyString1000)("A title");
212
180
  *
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
236
- *
237
- * ```ts
238
- * import * as S from "@effect/schema/Schema";
202
+ * @example
203
+ * import * as S from "@effect/schema/Schema";
239
204
  *
240
- * // Evolu uses the Schema to enforce domain model.
241
- * const title = S.parseSync(Evolu.NonEmptyString1000)("A title");
242
- * evolu.update("todo", { id, title });
205
+ * // Evolu uses the Schema to enforce domain model.
206
+ * const title = S.parseSync(Evolu.NonEmptyString1000)("A title");
207
+ * evolu.update("todo", { id, title });
243
208
  *
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
@@ -302,12 +266,14 @@ export interface SubscribedQueries {
302
266
  }
303
267
  export declare const SubscribedQueries: Context.Tag<SubscribedQueries, SubscribedQueries>;
304
268
  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">>> & {
269
+ export type Create<S extends Schema = Schema> = Mutate<S, "create">;
270
+ export type Update<S extends Schema = Schema> = Mutate<S, "update">;
271
+ 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
272
  readonly id: S[K]["id"];
307
273
  }>, onComplete?: () => void) => {
308
274
  readonly id: S[K]["id"];
309
275
  };
310
- declare const Mutate: Context.Tag<Mutate<Schema, "update">, Mutate<Schema, "update">>;
276
+ export declare const Mutate: Context.Tag<Mutate<Schema, "update">, Mutate<Schema, "update">>;
311
277
  type PartialForNullable<T, NK extends keyof T = {
312
278
  [K in keyof T]: null extends T[K] ? K : never;
313
279
  }[keyof T], NP = Pick<T, Exclude<keyof T, NK>> & Partial<Pick<T, NK>>> = {
@@ -325,5 +291,6 @@ type Castable<T> = {
325
291
  };
326
292
  /** EvoluCommonLive has only platform independent side-effects. */
327
293
  export declare const EvoluCommonLive: Layer.Layer<Config | FlushSync | AppState | DbWorker, never, Evolu<Schema>>;
294
+ export declare const makeCreateEvolu: (EvoluLive: Layer.Layer<Config, never, Evolu<Schema>>) => <From, To extends Schema>(schema: S.Schema<From, To>, config?: Partial<Config>) =>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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;AA8IF,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);
@@ -247,3 +247,9 @@ const EvoluCommon = Layer.effect(Evolu, Effect.gen(function* (_) {
247
247
  })).pipe(Layer.provide(Layer.mergeAll(LoadQueryLive, OnQueryLive, MutateLive)), Layer.provide(LoadingPromiseLive), Layer.provide(SubscribedQueriesLive), Layer.provide(Layer.merge(RowsStoreLive, OnCompletesLive)));
248
248
  /** EvoluCommonLive has only platform independent side-effects. */
249
249
  export const EvoluCommonLive = EvoluCommon.pipe(Layer.provide(Layer.merge(TimeLive, NanoIdLive)));
250
+ export const makeCreateEvolu = (EvoluLive) => (schema, config) => {
251
+ // For https://nextjs.org/docs/architecture/fast-refresh etc.
252
+ const evolu = GlobalValue.globalValue("@evolu/common", () => Evolu.pipe(Effect.provide(EvoluLive), Effect.provide(ConfigLive(config)), Effect.runSync));
253
+ evolu.ensureSchema(schema);
254
+ return evolu;
255
+ };
@@ -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,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAG/B;;;GAGG;AACH,eAAO,MAAM,EAAE,mDAAyD,CAAC;AACzE,MAAM,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;AAExC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,EAAE,oGAGU,CAAC;AAE1B;;;;GAIG;AACH,eAAO,MAAM,UAAU,2DAGtB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,UAAU,CAAC,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,aAAa,8DAIzB,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC;AAE9D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAAC;AACpD,wBAAgB,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC;AACpD,wBAAgB,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,UAAU,CAAC;AAC9C,wBAAgB,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;AAW9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aAAa,CAAC,CAAC;AAE9D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAAC;AACpD,wBAAgB,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC;AACpD,wBAAgB,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,UAAU,CAAC;AAC9C,wBAAgB,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;AAW9C;;;;;GAKG;AACH,eAAO,MAAM,MAAM,uDAclB,CAAC;AACF,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,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"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evolu/common",
3
- "version": "2.0.5",
3
+ "version": "2.1.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",
@@ -49,14 +49,13 @@
49
49
  "@protobuf-ts/runtime": "^2.9.1",
50
50
  "@scure/bip39": "^1.2.1",
51
51
  "kysely": "^0.26.3",
52
- "nanoid": "^5.0.3"
52
+ "nanoid": "^5.0.4"
53
53
  },
54
54
  "devDependencies": {
55
- "@effect/schema": "0.51.1",
55
+ "@effect/schema": "0.51.3",
56
56
  "@protobuf-ts/plugin": "^2.9.1",
57
57
  "@protobuf-ts/protoc": "^2.9.1",
58
58
  "array-shuffle": "^3.0.0",
59
- "better-sqlite3": "^9.1.1",
60
59
  "effect": "2.0.0-next.58",
61
60
  "eslint": "^8.54.0",
62
61
  "typescript": "^5.3.2",
@@ -65,7 +64,7 @@
65
64
  "eslint-config-evolu": "1.0.0"
66
65
  },
67
66
  "peerDependencies": {
68
- "@effect/schema": "0.51.1",
67
+ "@effect/schema": "0.51.3",
69
68
  "effect": "2.0.0-next.58"
70
69
  },
71
70
  "publishConfig": {
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
@@ -574,7 +539,11 @@ export const SubscribedQueriesLive = Layer.effect(
574
539
  }),
575
540
  );
576
541
 
577
- type Mutate<
542
+ export type Create<S extends Schema = Schema> = Mutate<S, "create">;
543
+
544
+ export type Update<S extends Schema = Schema> = Mutate<S, "update">;
545
+
546
+ export type Mutate<
578
547
  S extends Schema = Schema,
579
548
  Mode extends "create" | "update" = "update",
580
549
  > = <K extends keyof S>(
@@ -591,7 +560,7 @@ type Mutate<
591
560
  readonly id: S[K]["id"];
592
561
  };
593
562
 
594
- const Mutate = Context.Tag<Mutate>();
563
+ export const Mutate = Context.Tag<Mutate>();
595
564
 
596
565
  // https://stackoverflow.com/a/54713648/233902
597
566
  type PartialForNullable<
@@ -765,3 +734,21 @@ const EvoluCommon = Layer.effect(
765
734
  export const EvoluCommonLive = EvoluCommon.pipe(
766
735
  Layer.provide(Layer.merge(TimeLive, NanoIdLive)),
767
736
  );
737
+
738
+ export const makeCreateEvolu =
739
+ (EvoluLive: Layer.Layer<Config, never, Evolu<Schema>>) =>
740
+ <From, To extends Schema>(
741
+ schema: S.Schema<From, To>,
742
+ config?: Partial<Config>,
743
+ ): Evolu<To> => {
744
+ // For https://nextjs.org/docs/architecture/fast-refresh etc.
745
+ const evolu = GlobalValue.globalValue("@evolu/common", () =>
746
+ Evolu.pipe(
747
+ Effect.provide(EvoluLive),
748
+ Effect.provide(ConfigLive(config)),
749
+ Effect.runSync,
750
+ ),
751
+ );
752
+ evolu.ensureSchema(schema);
753
+ return evolu as Evolu<To>;
754
+ };
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(),