@evolu/common 3.1.8 → 4.0.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.
- package/dist/src/Config.d.ts +6 -0
- package/dist/src/Config.d.ts.map +1 -1
- package/dist/src/Config.js +1 -0
- package/dist/src/Crdt.d.ts +2 -2
- package/dist/src/Crdt.d.ts.map +1 -1
- package/dist/src/Crdt.js +2 -2
- package/dist/src/Crypto.d.ts +5 -4
- package/dist/src/Crypto.d.ts.map +1 -1
- package/dist/src/Crypto.js +2 -2
- package/dist/src/Db.d.ts +2 -2
- package/dist/src/Db.d.ts.map +1 -1
- package/dist/src/Db.js +1 -3
- package/dist/src/DbWorker.d.ts +8 -8
- package/dist/src/DbWorker.d.ts.map +1 -1
- package/dist/src/DbWorker.js +44 -28
- package/dist/src/Evolu.d.ts +3 -4
- package/dist/src/Evolu.d.ts.map +1 -1
- package/dist/src/Evolu.js +4 -9
- package/dist/src/OnCompletes.d.ts +3 -3
- package/dist/src/OnCompletes.d.ts.map +1 -1
- package/dist/src/OnCompletes.js +3 -3
- package/dist/src/Platform.d.ts +3 -1
- package/dist/src/Platform.d.ts.map +1 -1
- package/dist/src/Platform.js +1 -0
- package/dist/src/Sql.d.ts.map +1 -1
- package/dist/src/Sql.js +4 -3
- package/dist/src/Sqlite.d.ts +2 -2
- package/dist/src/Sqlite.d.ts.map +1 -1
- package/dist/src/SyncWorker.d.ts +3 -4
- package/dist/src/SyncWorker.d.ts.map +1 -1
- package/dist/src/SyncWorker.js +1 -1
- package/dist/src/Types.d.ts +13 -0
- package/dist/src/Types.d.ts.map +1 -0
- package/dist/src/Types.js +1 -0
- package/package.json +5 -5
- package/src/Config.ts +8 -0
- package/src/Crdt.ts +2 -2
- package/src/Crypto.ts +11 -7
- package/src/Db.ts +3 -5
- package/src/DbWorker.ts +54 -44
- package/src/Evolu.ts +10 -12
- package/src/OnCompletes.ts +4 -4
- package/src/Platform.ts +6 -5
- package/src/Sql.ts +4 -3
- package/src/Sqlite.ts +2 -2
- package/src/SyncWorker.ts +4 -6
- package/src/Types.ts +11 -0
package/src/Platform.ts
CHANGED
|
@@ -2,11 +2,7 @@ import * as Context from "effect/Context";
|
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
4
|
|
|
5
|
-
export type PlatformName =
|
|
6
|
-
| "server"
|
|
7
|
-
| "web-with-opfs"
|
|
8
|
-
| "web-without-opfs"
|
|
9
|
-
| "react-native";
|
|
5
|
+
export type PlatformName = "server" | "web" | "react-native";
|
|
10
6
|
|
|
11
7
|
export const PlatformName = Context.GenericTag<PlatformName>(
|
|
12
8
|
"@services/PlatformName",
|
|
@@ -40,6 +36,11 @@ export interface SyncLock {
|
|
|
40
36
|
|
|
41
37
|
export const SyncLock = Context.GenericTag<SyncLock>("@services/SyncLock");
|
|
42
38
|
|
|
39
|
+
export type DbWorkerLock = (callback: () => Promise<void>) => void;
|
|
40
|
+
export const DbWorkerLock = Context.GenericTag<DbWorkerLock>(
|
|
41
|
+
"@services/DbWorkerLock",
|
|
42
|
+
);
|
|
43
|
+
|
|
43
44
|
export type Fetch = (
|
|
44
45
|
url: string,
|
|
45
46
|
body: Uint8Array,
|
package/src/Sql.ts
CHANGED
|
@@ -80,11 +80,12 @@ export const upsertValueIntoTableRowColumn = (
|
|
|
80
80
|
column: string,
|
|
81
81
|
): string => `
|
|
82
82
|
INSERT INTO
|
|
83
|
-
"${table}" ("id", "${column}")
|
|
83
|
+
"${table}" ("id", "${column}", "createdAt", "updatedAt")
|
|
84
84
|
VALUES
|
|
85
|
-
(?, ?)
|
|
85
|
+
(?, ?, ?, ?)
|
|
86
86
|
ON CONFLICT DO UPDATE SET
|
|
87
|
-
"${column}" =
|
|
87
|
+
"${column}" = ?,
|
|
88
|
+
"updatedAt" = ?
|
|
88
89
|
`;
|
|
89
90
|
|
|
90
91
|
export const deleteTableRow = (table: string): string => `
|
package/src/Sqlite.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as Effect from "effect/Effect";
|
|
|
3
3
|
import * as Predicate from "effect/Predicate";
|
|
4
4
|
|
|
5
5
|
export interface Sqlite {
|
|
6
|
-
readonly exec: (arg: string | SqliteQuery) => Effect.Effect<
|
|
6
|
+
readonly exec: (arg: string | SqliteQuery) => Effect.Effect<SqliteExecResult>;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export const Sqlite = Context.GenericTag<Sqlite>("@services/Sqlite");
|
|
@@ -21,7 +21,7 @@ type JsonArray = ReadonlyArray<Json>;
|
|
|
21
21
|
type JsonPrimitive = string | number | boolean | null;
|
|
22
22
|
type Json = JsonPrimitive | JsonObject | JsonArray;
|
|
23
23
|
|
|
24
|
-
interface
|
|
24
|
+
export interface SqliteExecResult {
|
|
25
25
|
readonly rows: SqliteRow[];
|
|
26
26
|
readonly changes: number;
|
|
27
27
|
}
|
package/src/SyncWorker.ts
CHANGED
|
@@ -31,12 +31,10 @@ import {
|
|
|
31
31
|
SyncResponse,
|
|
32
32
|
} from "./Protobuf.js";
|
|
33
33
|
import { JsonObjectOrArray, Value } from "./Sqlite.js";
|
|
34
|
+
import { Messaging } from "./Types.js";
|
|
34
35
|
|
|
35
|
-
export interface SyncWorker
|
|
36
|
-
|
|
37
|
-
onMessage: (output: SyncWorkerOutput) => void;
|
|
38
|
-
}
|
|
39
|
-
|
|
36
|
+
export interface SyncWorker
|
|
37
|
+
extends Messaging<SyncWorkerInput, SyncWorkerOutput> {}
|
|
40
38
|
export const SyncWorker = Context.GenericTag<SyncWorker>(
|
|
41
39
|
"@services/SyncWorker",
|
|
42
40
|
);
|
|
@@ -325,7 +323,7 @@ const sync = (
|
|
|
325
323
|
);
|
|
326
324
|
});
|
|
327
325
|
|
|
328
|
-
export const
|
|
326
|
+
export const SyncWorkerCommonLive = Layer.effect(
|
|
329
327
|
SyncWorker,
|
|
330
328
|
Effect.gen(function* (_) {
|
|
331
329
|
const syncLock = yield* _(SyncLock);
|
package/src/Types.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add types for WebWorker and BroadcastChannel. Messages must have a `_tag`
|
|
3
|
+
* property.
|
|
4
|
+
*/
|
|
5
|
+
export interface Messaging<
|
|
6
|
+
Input extends { _tag: string },
|
|
7
|
+
Output extends { _tag: string },
|
|
8
|
+
> {
|
|
9
|
+
readonly postMessage: (input: Input) => void;
|
|
10
|
+
onMessage: (output: Output) => void;
|
|
11
|
+
}
|