@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/Model.js
CHANGED
|
@@ -1,38 +1,36 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as S from "@effect/schema/Schema";
|
|
2
2
|
import { maybeJson } from "./Sqlite.js";
|
|
3
3
|
/**
|
|
4
|
-
* Branded Id Schema for any table Id.
|
|
5
|
-
*
|
|
4
|
+
* Branded Id Schema for any table Id. To create Id Schema for a specific table,
|
|
5
|
+
* use {@link id}.
|
|
6
6
|
*/
|
|
7
|
-
export const Id =
|
|
7
|
+
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
11
|
* ### Example
|
|
12
12
|
*
|
|
13
|
-
* ```
|
|
14
|
-
* import * as
|
|
13
|
+
* ```ts
|
|
14
|
+
* import * as S from "@effect/schema/Schema";
|
|
15
15
|
* import * as Evolu from "@evolu/react";
|
|
16
16
|
*
|
|
17
17
|
* const TodoId = Evolu.id("Todo");
|
|
18
|
-
* type TodoId =
|
|
19
|
-
*
|
|
20
|
-
* if (!Schema.is(TodoId)(value)) return;
|
|
18
|
+
* type TodoId = S.Schema.To<typeof TodoId>;
|
|
21
19
|
* ```
|
|
22
20
|
*/
|
|
23
|
-
export const id = (table) => Id.pipe(
|
|
21
|
+
export const id = (table) => Id.pipe(S.brand(table));
|
|
24
22
|
/**
|
|
25
|
-
* SQLite doesn't support the Date type, so Evolu uses SqliteDate instead.
|
|
26
|
-
*
|
|
23
|
+
* SQLite doesn't support the Date type, so Evolu uses SqliteDate instead. Use
|
|
24
|
+
* the {@link cast} helper to cast SqliteDate from Date and back.
|
|
27
25
|
* https://www.sqlite.org/quirks.html#no_separate_datetime_datatype
|
|
28
26
|
*/
|
|
29
|
-
export const SqliteDate =
|
|
27
|
+
export const SqliteDate = S.string.pipe(S.filter((s) => !isNaN(Date.parse(s))), S.brand("SqliteDate"));
|
|
30
28
|
/**
|
|
31
29
|
* SQLite doesn't support the boolean type, so Evolu uses SqliteBoolean instead.
|
|
32
30
|
* Use the {@link cast} helper to cast SqliteBoolean from boolean and back.
|
|
33
31
|
* https://www.sqlite.org/quirks.html#no_separate_boolean_datatype
|
|
34
32
|
*/
|
|
35
|
-
export const SqliteBoolean =
|
|
33
|
+
export const SqliteBoolean = S.number.pipe(S.int(), S.filter((s) => s === 0 || s === 1), S.brand("SqliteBoolean"));
|
|
36
34
|
export function cast(value) {
|
|
37
35
|
if (typeof value === "boolean")
|
|
38
36
|
return (value === true ? 1 : 0);
|
|
@@ -43,12 +41,12 @@ export function cast(value) {
|
|
|
43
41
|
return new Date(value);
|
|
44
42
|
}
|
|
45
43
|
/**
|
|
46
|
-
* String schema represents a string that is not stringified JSON. Using
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
44
|
+
* String schema represents a string that is not stringified JSON. Using String
|
|
45
|
+
* schema for strings stored in SQLite is crucial to ensure a stored string is
|
|
46
|
+
* not automatically parsed to a JSON object or array when retrieved. Use String
|
|
47
|
+
* schema for all string-based schemas.
|
|
50
48
|
*/
|
|
51
|
-
export const String =
|
|
49
|
+
export const String = S.string.pipe(S.filter((s) => {
|
|
52
50
|
if (!maybeJson(s))
|
|
53
51
|
return true;
|
|
54
52
|
try {
|
|
@@ -58,46 +56,43 @@ export const String = Schema.string.pipe(Schema.filter((s) => {
|
|
|
58
56
|
return true;
|
|
59
57
|
}
|
|
60
58
|
return false;
|
|
61
|
-
}, { message: () => "a string that is not stringified JSON" }),
|
|
59
|
+
}, { message: () => "a string that is not stringified JSON" }), S.brand("String"));
|
|
62
60
|
/**
|
|
63
61
|
* A string with a maximum length of 1000 characters.
|
|
64
62
|
*
|
|
65
63
|
* ### Example
|
|
66
64
|
*
|
|
67
|
-
* ```
|
|
68
|
-
* import * as
|
|
65
|
+
* ```ts
|
|
66
|
+
* import * as S from "@effect/schema/Schema";
|
|
69
67
|
* import * as Evolu from "@evolu/react";
|
|
70
68
|
*
|
|
71
|
-
*
|
|
72
|
-
* function foo(value: Evolu.String1000) {}
|
|
69
|
+
* S.parse(Evolu.String1000)(value);
|
|
73
70
|
* ```
|
|
74
71
|
*/
|
|
75
|
-
export const String1000 = String.pipe(
|
|
72
|
+
export const String1000 = String.pipe(S.maxLength(1000), S.brand("String1000"));
|
|
76
73
|
/**
|
|
77
74
|
* A nonempty string with a maximum length of 1000 characters.
|
|
78
75
|
*
|
|
79
76
|
* ### Example
|
|
80
77
|
*
|
|
81
|
-
* ```
|
|
82
|
-
* import * as
|
|
78
|
+
* ```ts
|
|
79
|
+
* import * as S from "@effect/schema/Schema";
|
|
83
80
|
* import * as Evolu from "@evolu/react";
|
|
84
81
|
*
|
|
85
|
-
*
|
|
86
|
-
* function foo(value: Evolu.NonEmptyString1000) {}
|
|
82
|
+
* S.parse(Evolu.NonEmptyString1000)(value);
|
|
87
83
|
* ```
|
|
88
84
|
*/
|
|
89
|
-
export const NonEmptyString1000 = String.pipe(
|
|
85
|
+
export const NonEmptyString1000 = String.pipe(S.minLength(1), S.maxLength(1000), S.brand("NonEmptyString1000"));
|
|
90
86
|
/**
|
|
91
87
|
* A positive integer.
|
|
92
88
|
*
|
|
93
89
|
* ### Example
|
|
94
90
|
*
|
|
95
|
-
* ```
|
|
96
|
-
* import * as
|
|
91
|
+
* ```ts
|
|
92
|
+
* import * as S from "@effect/schema/Schema";
|
|
97
93
|
* import * as Evolu from "@evolu/react";
|
|
98
94
|
*
|
|
99
|
-
*
|
|
100
|
-
* function foo(value: Evolu.PositiveInt) {}
|
|
95
|
+
* S.parse(Evolu.PositiveInt)(value);
|
|
101
96
|
* ```
|
|
102
97
|
*/
|
|
103
|
-
export const PositiveInt =
|
|
98
|
+
export const PositiveInt = S.number.pipe(S.int(), S.positive(), S.brand("PositiveInt"));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Brand, Context, Effect, Layer } from "effect";
|
|
2
|
+
import { NanoId } from "./Crypto.js";
|
|
3
|
+
export interface OnCompletes {
|
|
4
|
+
readonly add: (onComplete: OnComplete) => Effect.Effect<never, never, OnCompleteId>;
|
|
5
|
+
readonly complete: (onCompleteIds: readonly OnCompleteId[]) => Effect.Effect<never, never, void>;
|
|
6
|
+
}
|
|
7
|
+
export type OnComplete = () => void;
|
|
8
|
+
export type OnCompleteId = string & Brand.Brand<"OnCompleteId">;
|
|
9
|
+
export declare const OnCompletes: Context.Tag<OnCompletes, OnCompletes>;
|
|
10
|
+
export declare const OnCompletesLive: Layer.Layer<NanoId, never, OnCompletes>;
|
|
11
|
+
//# sourceMappingURL=OnCompletes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnCompletes.d.ts","sourceRoot":"","sources":["../../src/OnCompletes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAyB,MAAM,QAAQ,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,GAAG,EAAE,CACZ,UAAU,EAAE,UAAU,KACnB,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IAE/C,QAAQ,CAAC,QAAQ,EAAE,CACjB,aAAa,EAAE,SAAS,YAAY,EAAE,KACnC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;CACxC;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC;AAEpC,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAEhE,eAAO,MAAM,WAAW,uCAA6B,CAAC;AAEtD,eAAO,MAAM,eAAe,yCA0B3B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Option, ReadonlyArray } from "effect";
|
|
2
|
+
import { NanoId } from "./Crypto.js";
|
|
3
|
+
export const OnCompletes = Context.Tag();
|
|
4
|
+
export const OnCompletesLive = Layer.effect(OnCompletes, Effect.gen(function* (_) {
|
|
5
|
+
const nanoid = yield* _(NanoId);
|
|
6
|
+
const map = new Map();
|
|
7
|
+
return OnCompletes.of({
|
|
8
|
+
add: (onComplete) => nanoid.nanoid.pipe(Effect.map((nanoid) => {
|
|
9
|
+
const id = nanoid;
|
|
10
|
+
map.set(id, onComplete);
|
|
11
|
+
return id;
|
|
12
|
+
})),
|
|
13
|
+
complete: (onCompleteIds) => Effect.sync(() => {
|
|
14
|
+
ReadonlyArray.filterMap(onCompleteIds, (id) => {
|
|
15
|
+
const onComplete = map.get(id);
|
|
16
|
+
map.delete(id);
|
|
17
|
+
return Option.fromNullable(onComplete);
|
|
18
|
+
}).forEach((onComplete) => onComplete());
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
}));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Brand, Context, Effect } from "effect";
|
|
2
|
+
import { Bip39, Mnemonic } from "./Crypto.js";
|
|
3
|
+
import { Id } from "./Model.js";
|
|
4
|
+
/**
|
|
5
|
+
* The Owner represents the Evolu database owner, a user. Instead of traditional
|
|
6
|
+
* email with a password, the Owner uses a mnemonic, also known as a "seed
|
|
7
|
+
* phrase," which is a set of 12 words in a specific order chosen from a
|
|
8
|
+
* predefined list.
|
|
9
|
+
*
|
|
10
|
+
* The purpose of the BIP39 mnemonic is to provide a human-readable way of
|
|
11
|
+
* storing a private key.
|
|
12
|
+
*
|
|
13
|
+
* Mnemonic is generated safely in the user's device and must not be shared with
|
|
14
|
+
* anyone.
|
|
15
|
+
*/
|
|
16
|
+
export interface Owner {
|
|
17
|
+
/** The {@link Mnemonic} associated with {@link Owner}. */
|
|
18
|
+
readonly mnemonic: Mnemonic;
|
|
19
|
+
/** The unique identifier safely derived from {@link Mnemonic}. */
|
|
20
|
+
readonly id: OwnerId;
|
|
21
|
+
/** The encryption key safely derived from {@link Mnemonic}. */
|
|
22
|
+
readonly encryptionKey: Uint8Array;
|
|
23
|
+
}
|
|
24
|
+
export declare const Owner: Context.Tag<Owner, Owner>;
|
|
25
|
+
/**
|
|
26
|
+
* The unique identifier of {@link Owner} safely derived from its
|
|
27
|
+
* {@link Mnemonic}.
|
|
28
|
+
*/
|
|
29
|
+
export type OwnerId = Id & Brand.Brand<"Owner">;
|
|
30
|
+
export declare const makeOwner: (mnemonic?: Mnemonic) => Effect.Effect<Bip39, never, Owner>;
|
|
31
|
+
//# sourceMappingURL=Owner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Owner.d.ts","sourceRoot":"","sources":["../../src/Owner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAgB,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAEhC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,KAAK;IACpB,0DAA0D;IAC1D,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAE5B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IAErB,+DAA+D;IAC/D,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC;CACpC;AAED,eAAO,MAAM,KAAK,2BAAuB,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAEhD,eAAO,MAAM,SAAS,cACT,QAAQ,KAClB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CA0BhC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Context, Effect } from "effect";
|
|
2
|
+
import { urlAlphabet } from "nanoid";
|
|
3
|
+
import { Bip39, slip21Derive } from "./Crypto.js";
|
|
4
|
+
export const Owner = Context.Tag();
|
|
5
|
+
export const makeOwner = (mnemonic) => Effect.gen(function* (_) {
|
|
6
|
+
const bip39 = yield* _(Bip39);
|
|
7
|
+
if (mnemonic == null)
|
|
8
|
+
mnemonic = yield* _(bip39.make);
|
|
9
|
+
const seed = yield* _(bip39.toSeed(mnemonic));
|
|
10
|
+
const id = yield* _(slip21Derive(seed, ["Evolu", "Owner Id"]).pipe(Effect.map((key) => {
|
|
11
|
+
// convert key to nanoid
|
|
12
|
+
let id = "";
|
|
13
|
+
for (let i = 0; i < 21; i++) {
|
|
14
|
+
id += urlAlphabet[key[i] & 63];
|
|
15
|
+
}
|
|
16
|
+
return id;
|
|
17
|
+
})));
|
|
18
|
+
const encryptionKey = yield* _(slip21Derive(seed, ["Evolu", "Encryption Key"]));
|
|
19
|
+
return { mnemonic, id, encryptionKey };
|
|
20
|
+
});
|
package/dist/src/Platform.d.ts
CHANGED
|
@@ -1,34 +1,38 @@
|
|
|
1
1
|
import { Context, Effect, Layer } from "effect";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
export declare const Platform: Context.Tag<Platform, Platform>;
|
|
2
|
+
export type PlatformName = "server" | "web-with-opfs" | "web-without-opfs" | "react-native";
|
|
3
|
+
export declare const PlatformName: Context.Tag<PlatformName, PlatformName>;
|
|
6
4
|
export type FlushSync = (callback: () => void) => void;
|
|
7
5
|
export declare const FlushSync: Context.Tag<FlushSync, FlushSync>;
|
|
8
6
|
export interface SyncLock {
|
|
7
|
+
/**
|
|
8
|
+
* Try to acquire a sync lock. The caller must not call sync if a sync lock
|
|
9
|
+
* can't be acquired.
|
|
10
|
+
*/
|
|
9
11
|
readonly acquire: Effect.Effect<never, never, boolean>;
|
|
12
|
+
/** Release a sync lock. */
|
|
10
13
|
readonly release: Effect.Effect<never, never, void>;
|
|
11
14
|
}
|
|
12
15
|
export declare const SyncLock: Context.Tag<SyncLock, SyncLock>;
|
|
13
16
|
export type Fetch = (url: string, body: Uint8Array) => Effect.Effect<never, FetchError, Response>;
|
|
14
17
|
export declare const Fetch: Context.Tag<Fetch, Fetch>;
|
|
15
18
|
/**
|
|
16
|
-
* This error occurs when there is a problem with the network connection,
|
|
17
|
-
*
|
|
19
|
+
* This error occurs when there is a problem with the network connection, or the
|
|
20
|
+
* server cannot be reached.
|
|
18
21
|
*/
|
|
19
22
|
export interface FetchError {
|
|
20
23
|
readonly _tag: "FetchError";
|
|
21
24
|
}
|
|
22
25
|
export declare const FetchLive: Layer.Layer<never, never, Fetch>;
|
|
26
|
+
interface AppStateConfig {
|
|
27
|
+
readonly onFocus: () => void;
|
|
28
|
+
readonly onReconnect: () => void;
|
|
29
|
+
}
|
|
23
30
|
export interface AppState {
|
|
24
|
-
readonly
|
|
25
|
-
readonly onReconnect: (callback: () => void) => void;
|
|
31
|
+
readonly init: (config: AppStateConfig) => void;
|
|
26
32
|
readonly reset: Effect.Effect<never, never, void>;
|
|
27
33
|
}
|
|
28
34
|
export declare const AppState: Context.Tag<AppState, AppState>;
|
|
29
|
-
/**
|
|
30
|
-
* To detect whether DOM can be used.
|
|
31
|
-
* https://github.com/facebook/fbjs/blob/main/packages/fbjs/src/core/ExecutionEnvironment.js
|
|
32
|
-
*/
|
|
35
|
+
/** To detect whether DOM can be used. */
|
|
33
36
|
export declare const canUseDom: boolean;
|
|
37
|
+
export {};
|
|
34
38
|
//# sourceMappingURL=Platform.d.ts.map
|
|
@@ -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,
|
|
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,YAAY,yCAA8B,CAAC;AAExD,MAAM,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;AAEvD,eAAO,MAAM,SAAS,mCAA2B,CAAC;AAElD,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAEvD,2BAA2B;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;CACrD;AAED,eAAO,MAAM,QAAQ,iCAA0B,CAAC;AAEhD,MAAM,MAAM,KAAK,GAAG,CAClB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,UAAU,KACb,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAEhD,eAAO,MAAM,KAAK,2BAAuB,CAAC;AAE1C;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;CAC7B;AAED,eAAO,MAAM,SAAS,kCAgBrB,CAAC;AAEF,UAAU,cAAc;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;CACnD;AAED,eAAO,MAAM,QAAQ,iCAA0B,CAAC;AAEhD,yCAAyC;AACzC,eAAO,MAAM,SAAS,SAYlB,CAAC"}
|
package/dist/src/Platform.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Context, Effect, Layer } from "effect";
|
|
2
|
-
export const
|
|
3
|
-
export const FlushSync = Context.Tag(
|
|
4
|
-
export const SyncLock = Context.Tag(
|
|
5
|
-
export const Fetch = Context.Tag(
|
|
2
|
+
export const PlatformName = Context.Tag();
|
|
3
|
+
export const FlushSync = Context.Tag();
|
|
4
|
+
export const SyncLock = Context.Tag();
|
|
5
|
+
export const Fetch = Context.Tag();
|
|
6
6
|
export const FetchLive = Layer.succeed(Fetch, Fetch.of((url, body) => Effect.tryPromise({
|
|
7
7
|
try: () => fetch(url, {
|
|
8
8
|
method: "POST",
|
|
@@ -14,11 +14,17 @@ export const FetchLive = Layer.succeed(Fetch, Fetch.of((url, body) => Effect.try
|
|
|
14
14
|
}),
|
|
15
15
|
catch: () => ({ _tag: "FetchError" }),
|
|
16
16
|
})));
|
|
17
|
-
export const AppState = Context.Tag(
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
export const AppState = Context.Tag();
|
|
18
|
+
/** To detect whether DOM can be used. */
|
|
19
|
+
export const canUseDom = (() => {
|
|
20
|
+
// IDK why try-catch is necessary, but it is.
|
|
21
|
+
// "ReferenceError: window is not defined" should not happen, but it does.
|
|
22
|
+
try {
|
|
23
|
+
return !!(typeof window !== "undefined" &&
|
|
24
|
+
window.document &&
|
|
25
|
+
window.document.createElement);
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
})();
|
package/dist/src/Protobuf.d.ts
CHANGED
|
@@ -1,97 +1,57 @@
|
|
|
1
1
|
import { MessageType } from "@protobuf-ts/runtime";
|
|
2
2
|
import { MerkleTreeString, TimestampString } from "./Crdt.js";
|
|
3
3
|
import { NodeId } from "./Crypto.js";
|
|
4
|
-
import { OwnerId } from "./
|
|
4
|
+
import { OwnerId } from "./Owner.js";
|
|
5
5
|
import { Id } from "./Model.js";
|
|
6
|
-
/**
|
|
7
|
-
* @generated from protobuf message SyncRequest
|
|
8
|
-
*/
|
|
6
|
+
/** @generated from protobuf message SyncRequest */
|
|
9
7
|
export interface SyncRequest {
|
|
10
|
-
/**
|
|
11
|
-
* @generated from protobuf field: repeated EncryptedMessage messages = 1;
|
|
12
|
-
*/
|
|
8
|
+
/** @generated from protobuf field: repeated EncryptedMessage messages = 1; */
|
|
13
9
|
messages: ReadonlyArray<EncryptedMessage>;
|
|
14
|
-
/**
|
|
15
|
-
* @generated from protobuf field: string userId = 2;
|
|
16
|
-
*/
|
|
10
|
+
/** @generated from protobuf field: string userId = 2; */
|
|
17
11
|
userId: OwnerId;
|
|
18
|
-
/**
|
|
19
|
-
* @generated from protobuf field: string nodeId = 3;
|
|
20
|
-
*/
|
|
12
|
+
/** @generated from protobuf field: string nodeId = 3; */
|
|
21
13
|
nodeId: NodeId;
|
|
22
|
-
/**
|
|
23
|
-
* @generated from protobuf field: string merkleTree = 4;
|
|
24
|
-
*/
|
|
14
|
+
/** @generated from protobuf field: string merkleTree = 4; */
|
|
25
15
|
merkleTree: MerkleTreeString;
|
|
26
16
|
}
|
|
27
|
-
/**
|
|
28
|
-
* @generated from protobuf message SyncResponse
|
|
29
|
-
*/
|
|
17
|
+
/** @generated from protobuf message SyncResponse */
|
|
30
18
|
export interface SyncResponse {
|
|
31
|
-
/**
|
|
32
|
-
* @generated from protobuf field: repeated EncryptedMessage messages = 1;
|
|
33
|
-
*/
|
|
19
|
+
/** @generated from protobuf field: repeated EncryptedMessage messages = 1; */
|
|
34
20
|
messages: ReadonlyArray<EncryptedMessage>;
|
|
35
|
-
/**
|
|
36
|
-
* @generated from protobuf field: string merkleTree = 2;
|
|
37
|
-
*/
|
|
21
|
+
/** @generated from protobuf field: string merkleTree = 2; */
|
|
38
22
|
merkleTree: MerkleTreeString;
|
|
39
23
|
}
|
|
40
|
-
/**
|
|
41
|
-
* @generated from protobuf message EncryptedMessage
|
|
42
|
-
*/
|
|
24
|
+
/** @generated from protobuf message EncryptedMessage */
|
|
43
25
|
export interface EncryptedMessage {
|
|
44
|
-
/**
|
|
45
|
-
* @generated from protobuf field: string timestamp = 1;
|
|
46
|
-
*/
|
|
26
|
+
/** @generated from protobuf field: string timestamp = 1; */
|
|
47
27
|
timestamp: TimestampString;
|
|
48
|
-
/**
|
|
49
|
-
* @generated from protobuf field: bytes content = 2;
|
|
50
|
-
*/
|
|
28
|
+
/** @generated from protobuf field: bytes content = 2; */
|
|
51
29
|
content: Uint8Array;
|
|
52
30
|
}
|
|
53
|
-
/**
|
|
54
|
-
* @generated from protobuf message MessageContent
|
|
55
|
-
*/
|
|
31
|
+
/** @generated from protobuf message MessageContent */
|
|
56
32
|
export interface MessageContent {
|
|
57
|
-
/**
|
|
58
|
-
* @generated from protobuf field: string table = 1;
|
|
59
|
-
*/
|
|
33
|
+
/** @generated from protobuf field: string table = 1; */
|
|
60
34
|
table: string;
|
|
61
|
-
/**
|
|
62
|
-
* @generated from protobuf field: string row = 2;
|
|
63
|
-
*/
|
|
35
|
+
/** @generated from protobuf field: string row = 2; */
|
|
64
36
|
row: Id;
|
|
65
|
-
/**
|
|
66
|
-
* @generated from protobuf field: string column = 3;
|
|
67
|
-
*/
|
|
37
|
+
/** @generated from protobuf field: string column = 3; */
|
|
68
38
|
column: string;
|
|
69
|
-
/**
|
|
70
|
-
* @generated from protobuf oneof: value
|
|
71
|
-
*/
|
|
39
|
+
/** @generated from protobuf oneof: value */
|
|
72
40
|
value: {
|
|
73
41
|
oneofKind: "stringValue";
|
|
74
|
-
/**
|
|
75
|
-
* @generated from protobuf field: string stringValue = 4;
|
|
76
|
-
*/
|
|
42
|
+
/** @generated from protobuf field: string stringValue = 4; */
|
|
77
43
|
stringValue: string;
|
|
78
44
|
} | {
|
|
79
45
|
oneofKind: "numberValue";
|
|
80
|
-
/**
|
|
81
|
-
* @generated from protobuf field: int32 numberValue = 5;
|
|
82
|
-
*/
|
|
46
|
+
/** @generated from protobuf field: int32 numberValue = 5; */
|
|
83
47
|
numberValue: number;
|
|
84
48
|
} | {
|
|
85
49
|
oneofKind: "bytesValue";
|
|
86
|
-
/**
|
|
87
|
-
* @generated from protobuf field: bytes bytesValue = 6;
|
|
88
|
-
*/
|
|
50
|
+
/** @generated from protobuf field: bytes bytesValue = 6; */
|
|
89
51
|
bytesValue: Uint8Array;
|
|
90
52
|
} | {
|
|
91
53
|
oneofKind: "jsonValue";
|
|
92
|
-
/**
|
|
93
|
-
* @generated from protobuf field: string jsonValue = 7;
|
|
94
|
-
*/
|
|
54
|
+
/** @generated from protobuf field: string jsonValue = 7; */
|
|
95
55
|
jsonValue: string;
|
|
96
56
|
} | {
|
|
97
57
|
oneofKind: undefined;
|
|
@@ -100,30 +60,22 @@ export interface MessageContent {
|
|
|
100
60
|
declare class SyncRequest$Type extends MessageType<SyncRequest> {
|
|
101
61
|
constructor();
|
|
102
62
|
}
|
|
103
|
-
/**
|
|
104
|
-
* @generated MessageType for protobuf message SyncRequest
|
|
105
|
-
*/
|
|
63
|
+
/** @generated MessageType for protobuf message SyncRequest */
|
|
106
64
|
export declare const SyncRequest: SyncRequest$Type;
|
|
107
65
|
declare class SyncResponse$Type extends MessageType<SyncResponse> {
|
|
108
66
|
constructor();
|
|
109
67
|
}
|
|
110
|
-
/**
|
|
111
|
-
* @generated MessageType for protobuf message SyncResponse
|
|
112
|
-
*/
|
|
68
|
+
/** @generated MessageType for protobuf message SyncResponse */
|
|
113
69
|
export declare const SyncResponse: SyncResponse$Type;
|
|
114
70
|
declare class EncryptedMessage$Type extends MessageType<EncryptedMessage> {
|
|
115
71
|
constructor();
|
|
116
72
|
}
|
|
117
|
-
/**
|
|
118
|
-
* @generated MessageType for protobuf message EncryptedMessage
|
|
119
|
-
*/
|
|
73
|
+
/** @generated MessageType for protobuf message EncryptedMessage */
|
|
120
74
|
export declare const EncryptedMessage: EncryptedMessage$Type;
|
|
121
75
|
declare class MessageContent$Type extends MessageType<MessageContent> {
|
|
122
76
|
constructor();
|
|
123
77
|
}
|
|
124
|
-
/**
|
|
125
|
-
* @generated MessageType for protobuf message MessageContent
|
|
126
|
-
*/
|
|
78
|
+
/** @generated MessageType for protobuf message MessageContent */
|
|
127
79
|
export declare const MessageContent: MessageContent$Type;
|
|
128
80
|
export {};
|
|
129
81
|
//# sourceMappingURL=Protobuf.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Protobuf.d.ts","sourceRoot":"","sources":["../../src/Protobuf.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Protobuf.d.ts","sourceRoot":"","sources":["../../src/Protobuf.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAChC,mDAAmD;AACnD,MAAM,WAAW,WAAW;IAC1B,8EAA8E;IAC9E,QAAQ,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC1C,yDAAyD;IACzD,MAAM,EAAE,OAAO,CAAC;IAChB,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AACD,oDAAoD;AACpD,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,QAAQ,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC1C,6DAA6D;IAC7D,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AACD,wDAAwD;AACxD,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,SAAS,EAAE,eAAe,CAAC;IAC3B,yDAAyD;IACzD,OAAO,EAAE,UAAU,CAAC;CACrB;AACD,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,GAAG,EAAE,EAAE,CAAC;IACR,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,KAAK,EACD;QACE,SAAS,EAAE,aAAa,CAAC;QACzB,8DAA8D;QAC9D,WAAW,EAAE,MAAM,CAAC;KACrB,GACD;QACE,SAAS,EAAE,aAAa,CAAC;QACzB,6DAA6D;QAC7D,WAAW,EAAE,MAAM,CAAC;KACrB,GACD;QACE,SAAS,EAAE,YAAY,CAAC;QACxB,4DAA4D;QAC5D,UAAU,EAAE,UAAU,CAAC;KACxB,GACD;QACE,SAAS,EAAE,WAAW,CAAC;QACvB,4DAA4D;QAC5D,SAAS,EAAE,MAAM,CAAC;KACnB,GACD;QACE,SAAS,EAAE,SAAS,CAAC;KACtB,CAAC;CACP;AAED,cAAM,gBAAiB,SAAQ,WAAW,CAAC,WAAW,CAAC;;CAetD;AACD,8DAA8D;AAC9D,eAAO,MAAM,WAAW,kBAAyB,CAAC;AAElD,cAAM,iBAAkB,SAAQ,WAAW,CAAC,YAAY,CAAC;;CAaxD;AACD,+DAA+D;AAC/D,eAAO,MAAM,YAAY,mBAA0B,CAAC;AAEpD,cAAM,qBAAsB,SAAQ,WAAW,CAAC,gBAAgB,CAAC;;CAOhE;AACD,mEAAmE;AACnE,eAAO,MAAM,gBAAgB,uBAA8B,CAAC;AAE5D,cAAM,mBAAoB,SAAQ,WAAW,CAAC,cAAc,CAAC;;CAoC5D;AACD,iEAAiE;AACjE,eAAO,MAAM,cAAc,qBAA4B,CAAC"}
|
package/dist/src/Protobuf.js
CHANGED
|
@@ -20,9 +20,7 @@ class SyncRequest$Type extends MessageType {
|
|
|
20
20
|
]);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* @generated MessageType for protobuf message SyncRequest
|
|
25
|
-
*/
|
|
23
|
+
/** @generated MessageType for protobuf message SyncRequest */
|
|
26
24
|
export const SyncRequest = new SyncRequest$Type();
|
|
27
25
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
28
26
|
class SyncResponse$Type extends MessageType {
|
|
@@ -39,9 +37,7 @@ class SyncResponse$Type extends MessageType {
|
|
|
39
37
|
]);
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
/**
|
|
43
|
-
* @generated MessageType for protobuf message SyncResponse
|
|
44
|
-
*/
|
|
40
|
+
/** @generated MessageType for protobuf message SyncResponse */
|
|
45
41
|
export const SyncResponse = new SyncResponse$Type();
|
|
46
42
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
47
43
|
class EncryptedMessage$Type extends MessageType {
|
|
@@ -52,9 +48,7 @@ class EncryptedMessage$Type extends MessageType {
|
|
|
52
48
|
]);
|
|
53
49
|
}
|
|
54
50
|
}
|
|
55
|
-
/**
|
|
56
|
-
* @generated MessageType for protobuf message EncryptedMessage
|
|
57
|
-
*/
|
|
51
|
+
/** @generated MessageType for protobuf message EncryptedMessage */
|
|
58
52
|
export const EncryptedMessage = new EncryptedMessage$Type();
|
|
59
53
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
60
54
|
class MessageContent$Type extends MessageType {
|
|
@@ -94,7 +88,5 @@ class MessageContent$Type extends MessageType {
|
|
|
94
88
|
]);
|
|
95
89
|
}
|
|
96
90
|
}
|
|
97
|
-
/**
|
|
98
|
-
* @generated MessageType for protobuf message MessageContent
|
|
99
|
-
*/
|
|
91
|
+
/** @generated MessageType for protobuf message MessageContent */
|
|
100
92
|
export const MessageContent = new MessageContent$Type();
|
package/dist/src/Public.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { jsonArrayFrom, jsonObjectFrom } from "kysely/helpers/sqlite";
|
|
2
|
-
export type {
|
|
3
|
-
export type {
|
|
4
|
-
export type { EvoluError } from "./
|
|
2
|
+
export type { Timestamp, TimestampError } from "./Crdt.js";
|
|
3
|
+
export type { Mnemonic, InvalidMnemonicError } from "./Crypto.js";
|
|
4
|
+
export type { EvoluError, UnexpectedError } from "./ErrorStore.js";
|
|
5
5
|
export * from "./Model.js";
|
|
6
|
+
export type { Owner, OwnerId } from "./Owner.js";
|
|
7
|
+
export { canUseDom } from "./Platform.js";
|
|
6
8
|
export type { SyncState } from "./SyncWorker.js";
|
|
7
9
|
//# sourceMappingURL=Public.d.ts.map
|
package/dist/src/Public.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Public.d.ts","sourceRoot":"","sources":["../../src/Public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"Public.d.ts","sourceRoot":"","sources":["../../src/Public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3D,YAAY,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAClE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACnE,cAAc,YAAY,CAAC;AAC3B,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/src/Public.js
CHANGED
package/dist/src/Sqlite.d.ts
CHANGED
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context, Effect, Predicate, ReadonlyRecord } from "effect";
|
|
2
2
|
export interface Sqlite {
|
|
3
|
-
readonly exec: (arg: string |
|
|
3
|
+
readonly exec: (arg: string | SqliteQuery) => Effect.Effect<never, never, ExecResult>;
|
|
4
4
|
}
|
|
5
5
|
export declare const Sqlite: Context.Tag<Sqlite, Sqlite>;
|
|
6
|
-
export interface
|
|
6
|
+
export interface SqliteQuery {
|
|
7
7
|
readonly sql: string;
|
|
8
|
-
readonly parameters:
|
|
8
|
+
readonly parameters: Value[];
|
|
9
9
|
}
|
|
10
10
|
export type Value = SqliteValue | JsonObjectOrArray;
|
|
11
11
|
export type SqliteValue = null | string | number | Uint8Array;
|
|
12
|
-
export type SqliteRow = Record<string, SqliteValue>;
|
|
13
12
|
export type JsonObjectOrArray = JsonObject | JsonArray;
|
|
14
13
|
type JsonObject = ReadonlyRecord.ReadonlyRecord<Json>;
|
|
15
14
|
type JsonArray = ReadonlyArray<Json>;
|
|
16
15
|
type Json = string | number | boolean | null | JsonObject | JsonArray;
|
|
17
16
|
interface ExecResult {
|
|
18
|
-
readonly rows:
|
|
17
|
+
readonly rows: SqliteRow[];
|
|
19
18
|
readonly changes: number;
|
|
20
19
|
}
|
|
21
|
-
export type
|
|
22
|
-
export type Query = string & Brand.Brand<"Query">;
|
|
20
|
+
export type SqliteRow = Record<string, SqliteValue>;
|
|
23
21
|
export declare const isJsonObjectOrArray: Predicate.Refinement<Value, JsonObjectOrArray>;
|
|
24
22
|
export declare const valuesToSqliteValues: (values: ReadonlyArray<Value>) => SqliteValue[];
|
|
25
|
-
export declare const
|
|
26
|
-
export declare const
|
|
27
|
-
export declare const parseJsonResults: (rows: SqliteRow[]) => void;
|
|
23
|
+
export declare const ensureSqliteQuery: (arg: string | SqliteQuery) => SqliteQuery;
|
|
24
|
+
export declare const maybeParseJson: (rows: SqliteRow[]) => SqliteRow[];
|
|
28
25
|
export declare const maybeJson: Predicate.Predicate<string>;
|
|
29
26
|
export {};
|
|
30
27
|
//# sourceMappingURL=Sqlite.d.ts.map
|
package/dist/src/Sqlite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sqlite.d.ts","sourceRoot":"","sources":["../../src/Sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Sqlite.d.ts","sourceRoot":"","sources":["../../src/Sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAEpE,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,CACb,GAAG,EAAE,MAAM,GAAG,WAAW,KACtB,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;CAC9C;AAED,eAAO,MAAM,MAAM,6BAAwB,CAAC;AAE5C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC;CAC9B;AAED,MAAM,MAAM,KAAK,GAAG,WAAW,GAAG,iBAAiB,CAAC;AACpD,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;AAC9D,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,SAAS,CAAC;AACvD,KAAK,UAAU,GAAG,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AACtD,KAAK,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;AACrC,KAAK,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU,GAAG,SAAS,CAAC;AAEtE,UAAU,UAAU;IAClB,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAEpD,eAAO,MAAM,mBAAmB,EAAE,SAAS,CAAC,UAAU,CACpD,KAAK,EACL,iBAAiB,CAE4D,CAAC;AAEhF,eAAO,MAAM,oBAAoB,WACvB,cAAc,KAAK,CAAC,KAC3B,WAAW,EAGX,CAAC;AAEJ,eAAO,MAAM,iBAAiB,QAAS,MAAM,GAAG,WAAW,KAAG,WAG7D,CAAC;AAEF,eAAO,MAAM,cAAc,SAAU,SAAS,EAAE,KAAG,SAAS,EAC1C,CAAC;AA0BnB,eAAO,MAAM,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,CACpB,CAAC"}
|
package/dist/src/Sqlite.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Context, Predicate } from "effect";
|
|
2
|
-
export const Sqlite = Context.Tag(
|
|
3
|
-
export const isJsonObjectOrArray = (value) => value !== null && typeof value === "object" && !(value
|
|
2
|
+
export const Sqlite = Context.Tag();
|
|
3
|
+
export const isJsonObjectOrArray = (value) => value !== null && typeof value === "object" && !Predicate.isUint8Array(value);
|
|
4
4
|
export const valuesToSqliteValues = (values) => values.map((value) => isJsonObjectOrArray(value) ? JSON.stringify(value) : value);
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export const ensureSqliteQuery = (arg) => {
|
|
6
|
+
if (typeof arg !== "string")
|
|
7
|
+
return arg;
|
|
8
|
+
return { sql: arg, parameters: [] };
|
|
9
9
|
};
|
|
10
|
+
export const maybeParseJson = (rows) => parseArray(rows);
|
|
10
11
|
const parseArray = (a) => {
|
|
11
12
|
for (let i = 0; i < a.length; ++i)
|
|
12
13
|
a[i] = parse(a[i]);
|
|
@@ -18,7 +19,6 @@ const parse = (o) => {
|
|
|
18
19
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
19
20
|
if (Array.isArray(o))
|
|
20
21
|
return parseArray(o);
|
|
21
|
-
// Predicate.isReadonlyRecord
|
|
22
22
|
if (typeof o === "object" && o !== null && !Predicate.isUint8Array(o))
|
|
23
23
|
return parseObject(o);
|
|
24
24
|
return o;
|