@loro-dev/flock-sqlite 0.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.
- package/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/index.cjs +27 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +175 -0
- package/dist/index.d.ts +175 -0
- package/dist/index.mjs +27 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +76 -0
- package/src/digest.ts +259 -0
- package/src/index.ts +1040 -0
- package/src/key-encoding.ts +106 -0
- package/src/memcomparable.d.ts +5 -0
- package/src/memcomparable.ts +1852 -0
- package/src/moonbit.d.ts +57 -0
- package/src/types.ts +128 -0
package/src/moonbit.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A non-public unique symbol used to mark the brand of a type.
|
|
3
|
+
* And avoid user to construct values of the type.
|
|
4
|
+
*/
|
|
5
|
+
export const __brand: unique symbol;
|
|
6
|
+
|
|
7
|
+
export type Unit = undefined;
|
|
8
|
+
export type Bool = boolean;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A signed integer in 32-bit two's complement format.
|
|
12
|
+
*/
|
|
13
|
+
export type Int = number;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* An unsigned integer in 32-bit two's complement format.
|
|
17
|
+
*/
|
|
18
|
+
export type UInt = number;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A character in the range 0-0x10FFFF.
|
|
22
|
+
*/
|
|
23
|
+
export type Char = number;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A byte in the range 0-255.
|
|
27
|
+
*/
|
|
28
|
+
export type Byte = number;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Single-precision floating point number.
|
|
32
|
+
*/
|
|
33
|
+
export type Float = number;
|
|
34
|
+
|
|
35
|
+
export type Double = number;
|
|
36
|
+
|
|
37
|
+
export type Int64 = { [__brand]: 568910272 };
|
|
38
|
+
|
|
39
|
+
export type UInt64 = { [__brand]: 689305396 };
|
|
40
|
+
|
|
41
|
+
export type String = string;
|
|
42
|
+
|
|
43
|
+
export type Bytes = Uint8Array;
|
|
44
|
+
|
|
45
|
+
export type FixedArray<T> = T[];
|
|
46
|
+
|
|
47
|
+
export type UnboxedOption<T> =
|
|
48
|
+
| /* Some */ T
|
|
49
|
+
| /* None */ undefined;
|
|
50
|
+
|
|
51
|
+
export type UnboxedOptionAsInt<T> =
|
|
52
|
+
| /* Some */ T
|
|
53
|
+
| /* None */ -1;
|
|
54
|
+
|
|
55
|
+
export type Result<T, E> =
|
|
56
|
+
| /* Ok */ { $tag: 1, _0: T }
|
|
57
|
+
| /* Err */ { $tag: 0, _0: E };
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export type Value =
|
|
2
|
+
| string
|
|
3
|
+
| number
|
|
4
|
+
| boolean
|
|
5
|
+
| null
|
|
6
|
+
| Array<Value>
|
|
7
|
+
| { [key: string]: Value };
|
|
8
|
+
|
|
9
|
+
export type KeyPart = Value;
|
|
10
|
+
|
|
11
|
+
export type MetadataMap = Record<string, unknown>;
|
|
12
|
+
|
|
13
|
+
export type ExportRecord = {
|
|
14
|
+
c: string;
|
|
15
|
+
d?: Value;
|
|
16
|
+
m?: MetadataMap;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type ExportBundle = { version: number; entries: Record<string, ExportRecord> };
|
|
20
|
+
|
|
21
|
+
export type EntryClock = {
|
|
22
|
+
physicalTime: number;
|
|
23
|
+
logicalCounter: number;
|
|
24
|
+
peerId: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type ExportPayload = {
|
|
28
|
+
data?: Value;
|
|
29
|
+
metadata?: MetadataMap;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type ExportHookContext = {
|
|
33
|
+
key: KeyPart[];
|
|
34
|
+
clock: EntryClock;
|
|
35
|
+
raw: ExportRecord;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
39
|
+
|
|
40
|
+
export type ExportHooks = {
|
|
41
|
+
transform?: (context: ExportHookContext, payload: ExportPayload) => MaybePromise<ExportPayload | void>;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type ImportPayload = ExportPayload;
|
|
45
|
+
|
|
46
|
+
export type ImportHookContext = ExportHookContext;
|
|
47
|
+
|
|
48
|
+
export type ImportAccept = { accept: true };
|
|
49
|
+
export type ImportSkip = { accept: false; reason: string };
|
|
50
|
+
export type ImportDecision = ImportAccept | ImportSkip | ImportPayload | void;
|
|
51
|
+
|
|
52
|
+
export type ImportHooks = {
|
|
53
|
+
preprocess?: (context: ImportHookContext, payload: ImportPayload) => MaybePromise<ImportDecision>;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type ImportReport = {
|
|
57
|
+
accepted: number;
|
|
58
|
+
skipped: Array<{ key: KeyPart[]; reason: string }>;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type VersionVectorEntry = {
|
|
62
|
+
physicalTime: number;
|
|
63
|
+
logicalCounter: number;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type VersionVector = Record<string, VersionVectorEntry>;
|
|
67
|
+
|
|
68
|
+
export type ScanBound =
|
|
69
|
+
| { kind: "inclusive"; key: KeyPart[] }
|
|
70
|
+
| { kind: "exclusive"; key: KeyPart[] }
|
|
71
|
+
| { kind: "unbounded" };
|
|
72
|
+
|
|
73
|
+
export type ScanOptions = {
|
|
74
|
+
start?: ScanBound;
|
|
75
|
+
end?: ScanBound;
|
|
76
|
+
prefix?: KeyPart[];
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export type ScanRow = {
|
|
80
|
+
key: KeyPart[];
|
|
81
|
+
raw: ExportRecord;
|
|
82
|
+
value?: Value;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export type EventPayload = ExportPayload;
|
|
86
|
+
|
|
87
|
+
export type Event = {
|
|
88
|
+
key: KeyPart[];
|
|
89
|
+
value?: Value;
|
|
90
|
+
metadata?: MetadataMap;
|
|
91
|
+
payload: EventPayload;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export type EventBatch = {
|
|
95
|
+
source: string;
|
|
96
|
+
events: Event[];
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export type ExportOptions = {
|
|
100
|
+
from?: VersionVector;
|
|
101
|
+
hooks?: ExportHooks;
|
|
102
|
+
pruneTombstonesBefore?: number;
|
|
103
|
+
peerId?: string;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type ImportOptions = {
|
|
107
|
+
bundle: ExportBundle;
|
|
108
|
+
hooks?: ImportHooks;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export type PutPayload = ExportPayload;
|
|
112
|
+
|
|
113
|
+
export type PutHookContext = {
|
|
114
|
+
key: KeyPart[];
|
|
115
|
+
now?: number;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export type PutHooks = {
|
|
119
|
+
transform?: (context: PutHookContext, payload: PutPayload) => MaybePromise<PutPayload | void>;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export type PutWithMetaOptions = {
|
|
123
|
+
metadata?: MetadataMap;
|
|
124
|
+
now?: number;
|
|
125
|
+
hooks?: PutHooks;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export type EventListener = (batch: EventBatch) => void;
|