@atproto/repo 0.0.1 → 0.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.
- package/bench/mst.bench.ts +7 -4
- package/bench/repo.bench.ts +25 -16
- package/dist/block-map.d.ts +27 -0
- package/dist/data-diff.d.ts +36 -0
- package/dist/error.d.ts +20 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +22870 -12456
- package/dist/index.js.map +4 -4
- package/dist/mst/diff.d.ts +4 -33
- package/dist/mst/mst.d.ts +73 -31
- package/dist/mst/util.d.ts +13 -5
- package/dist/parse.d.ts +16 -0
- package/dist/readable-repo.d.ts +23 -0
- package/dist/repo.d.ts +19 -31
- package/dist/src/block-map.d.ts +23 -0
- package/dist/src/blockstore/persistent-blockstore.d.ts +12 -0
- package/dist/src/cid-set.d.ts +14 -0
- package/dist/src/collection.d.ts +22 -0
- package/dist/src/data-diff.d.ts +34 -0
- package/dist/src/error.d.ts +21 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/logger.d.ts +2 -0
- package/dist/src/mst/diff.d.ts +33 -0
- package/dist/src/mst/index.d.ts +4 -0
- package/dist/src/mst/mst.d.ts +106 -0
- package/dist/src/mst/util.d.ts +9 -0
- package/dist/src/mst/walker.d.ts +22 -0
- package/dist/src/parse.d.ts +11 -0
- package/dist/src/readable-repo.d.ts +25 -0
- package/dist/src/repo.d.ts +39 -0
- package/dist/src/storage/error.d.ts +22 -0
- package/dist/src/storage/index.d.ts +1 -0
- package/dist/src/storage/memory-blobstore.d.ts +1 -0
- package/dist/src/storage/memory-blockstore.d.ts +28 -0
- package/dist/src/storage/readable-blockstore.d.ts +21 -0
- package/dist/src/storage/repo-storage.d.ts +18 -0
- package/dist/src/storage/sync-storage.d.ts +15 -0
- package/dist/src/storage/types.d.ts +12 -0
- package/dist/src/storage/util.d.ts +17 -0
- package/dist/src/structure.d.ts +39 -0
- package/dist/src/sync/consumer.d.ts +19 -0
- package/dist/src/sync/index.d.ts +2 -0
- package/dist/src/sync/producer.d.ts +13 -0
- package/dist/src/sync/provider.d.ts +11 -0
- package/dist/src/types.d.ts +368 -0
- package/dist/src/util.d.ts +13 -0
- package/dist/src/verify.d.ts +5 -0
- package/dist/storage/index.d.ts +4 -0
- package/dist/storage/memory-blockstore.d.ts +29 -0
- package/dist/storage/readable-blockstore.d.ts +24 -0
- package/dist/storage/repo-storage.d.ts +19 -0
- package/dist/storage/sync-storage.d.ts +15 -0
- package/dist/storage/types.d.ts +4 -0
- package/dist/sync/consumer.d.ts +19 -0
- package/dist/sync/index.d.ts +2 -0
- package/dist/sync/provider.d.ts +9 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types.d.ts +137 -331
- package/dist/util.d.ts +35 -12
- package/dist/verify.d.ts +31 -4
- package/jest.bench.config.js +2 -1
- package/package.json +13 -6
- package/src/block-map.ts +103 -0
- package/src/cid-set.ts +1 -2
- package/src/data-diff.ts +117 -0
- package/src/error.ts +31 -0
- package/src/index.ts +4 -1
- package/src/mst/diff.ts +120 -90
- package/src/mst/mst.ts +179 -187
- package/src/mst/util.ts +54 -31
- package/src/parse.ts +44 -0
- package/src/readable-repo.ts +75 -0
- package/src/repo.ts +145 -244
- package/src/storage/index.ts +4 -0
- package/src/storage/memory-blockstore.ts +133 -0
- package/src/storage/readable-blockstore.ts +56 -0
- package/src/storage/repo-storage.ts +43 -0
- package/src/storage/sync-storage.ts +35 -0
- package/src/storage/types.ts +4 -0
- package/src/sync/consumer.ts +140 -0
- package/src/sync/index.ts +2 -0
- package/src/sync/provider.ts +91 -0
- package/src/types.ts +110 -73
- package/src/util.ts +258 -56
- package/src/verify.ts +248 -42
- package/tests/_util.ts +132 -97
- package/tests/mst.test.ts +269 -122
- package/tests/rebase.test.ts +37 -0
- package/tests/repo.test.ts +48 -50
- package/tests/sync/checkout.test.ts +75 -0
- package/tests/sync/diff.test.ts +92 -0
- package/tests/sync/narrow.test.ts +149 -0
- package/tests/util.test.ts +21 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +2 -1
- package/src/blockstore/index.ts +0 -2
- package/src/blockstore/ipld-store.ts +0 -103
- package/src/blockstore/memory-blockstore.ts +0 -49
- package/src/sync.ts +0 -38
- package/tests/sync.test.ts +0 -129
- /package/dist/{blockstore → src/blockstore}/index.d.ts +0 -0
- /package/dist/{blockstore → src/blockstore}/ipld-store.d.ts +0 -0
- /package/dist/{blockstore → src/blockstore}/memory-blockstore.d.ts +0 -0
- /package/dist/{sync.d.ts → src/sync.d.ts} +0 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BlockWriter } from '@ipld/car/writer';
|
|
3
|
+
import { CID } from 'multiformats';
|
|
4
|
+
import { DataDiff } from './mst';
|
|
5
|
+
declare const repoMeta: z.ZodObject<{
|
|
6
|
+
did: z.ZodString;
|
|
7
|
+
version: z.ZodNumber;
|
|
8
|
+
datastore: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
did: string;
|
|
11
|
+
version: number;
|
|
12
|
+
datastore: string;
|
|
13
|
+
}, {
|
|
14
|
+
did: string;
|
|
15
|
+
version: number;
|
|
16
|
+
datastore: string;
|
|
17
|
+
}>;
|
|
18
|
+
export declare type RepoMeta = z.infer<typeof repoMeta>;
|
|
19
|
+
declare const repoRoot: z.ZodObject<{
|
|
20
|
+
meta: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
|
|
21
|
+
prev: z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>>;
|
|
22
|
+
auth_token: z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>>;
|
|
23
|
+
data: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
data: CID;
|
|
26
|
+
meta: CID;
|
|
27
|
+
prev: CID | null;
|
|
28
|
+
auth_token: CID | null;
|
|
29
|
+
}, {
|
|
30
|
+
data?: any;
|
|
31
|
+
meta?: any;
|
|
32
|
+
prev?: any;
|
|
33
|
+
auth_token?: any;
|
|
34
|
+
}>;
|
|
35
|
+
export declare type RepoRoot = z.infer<typeof repoRoot>;
|
|
36
|
+
declare const commit: z.ZodObject<{
|
|
37
|
+
root: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
|
|
38
|
+
sig: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
root: CID;
|
|
41
|
+
sig: Uint8Array;
|
|
42
|
+
}, {
|
|
43
|
+
root?: any;
|
|
44
|
+
sig: Uint8Array;
|
|
45
|
+
}>;
|
|
46
|
+
export declare type Commit = z.infer<typeof commit>;
|
|
47
|
+
export declare const cidCreateOp: z.ZodObject<{
|
|
48
|
+
action: z.ZodLiteral<"create">;
|
|
49
|
+
collection: z.ZodString;
|
|
50
|
+
rkey: z.ZodString;
|
|
51
|
+
cid: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
collection: string;
|
|
54
|
+
action: "create";
|
|
55
|
+
rkey: string;
|
|
56
|
+
cid: CID;
|
|
57
|
+
}, {
|
|
58
|
+
cid?: any;
|
|
59
|
+
collection: string;
|
|
60
|
+
action: "create";
|
|
61
|
+
rkey: string;
|
|
62
|
+
}>;
|
|
63
|
+
export declare type CidCreateOp = z.infer<typeof cidCreateOp>;
|
|
64
|
+
export declare const cidUpdateOp: z.ZodObject<{
|
|
65
|
+
action: z.ZodLiteral<"update">;
|
|
66
|
+
collection: z.ZodString;
|
|
67
|
+
rkey: z.ZodString;
|
|
68
|
+
cid: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
collection: string;
|
|
71
|
+
action: "update";
|
|
72
|
+
rkey: string;
|
|
73
|
+
cid: CID;
|
|
74
|
+
}, {
|
|
75
|
+
cid?: any;
|
|
76
|
+
collection: string;
|
|
77
|
+
action: "update";
|
|
78
|
+
rkey: string;
|
|
79
|
+
}>;
|
|
80
|
+
export declare type CidUpdateOp = z.infer<typeof cidUpdateOp>;
|
|
81
|
+
export declare const deleteOp: z.ZodObject<{
|
|
82
|
+
action: z.ZodLiteral<"delete">;
|
|
83
|
+
collection: z.ZodString;
|
|
84
|
+
rkey: z.ZodString;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
collection: string;
|
|
87
|
+
action: "delete";
|
|
88
|
+
rkey: string;
|
|
89
|
+
}, {
|
|
90
|
+
collection: string;
|
|
91
|
+
action: "delete";
|
|
92
|
+
rkey: string;
|
|
93
|
+
}>;
|
|
94
|
+
export declare type DeleteOp = z.infer<typeof deleteOp>;
|
|
95
|
+
export declare const cidWriteOp: z.ZodUnion<[z.ZodObject<{
|
|
96
|
+
action: z.ZodLiteral<"create">;
|
|
97
|
+
collection: z.ZodString;
|
|
98
|
+
rkey: z.ZodString;
|
|
99
|
+
cid: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
|
|
100
|
+
}, "strip", z.ZodTypeAny, {
|
|
101
|
+
collection: string;
|
|
102
|
+
action: "create";
|
|
103
|
+
rkey: string;
|
|
104
|
+
cid: CID;
|
|
105
|
+
}, {
|
|
106
|
+
cid?: any;
|
|
107
|
+
collection: string;
|
|
108
|
+
action: "create";
|
|
109
|
+
rkey: string;
|
|
110
|
+
}>, z.ZodObject<{
|
|
111
|
+
action: z.ZodLiteral<"update">;
|
|
112
|
+
collection: z.ZodString;
|
|
113
|
+
rkey: z.ZodString;
|
|
114
|
+
cid: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
|
|
115
|
+
}, "strip", z.ZodTypeAny, {
|
|
116
|
+
collection: string;
|
|
117
|
+
action: "update";
|
|
118
|
+
rkey: string;
|
|
119
|
+
cid: CID;
|
|
120
|
+
}, {
|
|
121
|
+
cid?: any;
|
|
122
|
+
collection: string;
|
|
123
|
+
action: "update";
|
|
124
|
+
rkey: string;
|
|
125
|
+
}>, z.ZodObject<{
|
|
126
|
+
action: z.ZodLiteral<"delete">;
|
|
127
|
+
collection: z.ZodString;
|
|
128
|
+
rkey: z.ZodString;
|
|
129
|
+
}, "strip", z.ZodTypeAny, {
|
|
130
|
+
collection: string;
|
|
131
|
+
action: "delete";
|
|
132
|
+
rkey: string;
|
|
133
|
+
}, {
|
|
134
|
+
collection: string;
|
|
135
|
+
action: "delete";
|
|
136
|
+
rkey: string;
|
|
137
|
+
}>]>;
|
|
138
|
+
export declare type CidWriteOp = z.infer<typeof cidWriteOp>;
|
|
139
|
+
export declare const recordCreateOp: z.ZodObject<{
|
|
140
|
+
action: z.ZodLiteral<"create">;
|
|
141
|
+
collection: z.ZodString;
|
|
142
|
+
rkey: z.ZodString;
|
|
143
|
+
value: z.ZodAny;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
value?: any;
|
|
146
|
+
collection: string;
|
|
147
|
+
action: "create";
|
|
148
|
+
rkey: string;
|
|
149
|
+
}, {
|
|
150
|
+
value?: any;
|
|
151
|
+
collection: string;
|
|
152
|
+
action: "create";
|
|
153
|
+
rkey: string;
|
|
154
|
+
}>;
|
|
155
|
+
export declare type RecordCreateOp = z.infer<typeof recordCreateOp>;
|
|
156
|
+
export declare const recordUpdateOp: z.ZodObject<{
|
|
157
|
+
action: z.ZodLiteral<"update">;
|
|
158
|
+
collection: z.ZodString;
|
|
159
|
+
rkey: z.ZodString;
|
|
160
|
+
value: z.ZodAny;
|
|
161
|
+
}, "strip", z.ZodTypeAny, {
|
|
162
|
+
value?: any;
|
|
163
|
+
collection: string;
|
|
164
|
+
action: "update";
|
|
165
|
+
rkey: string;
|
|
166
|
+
}, {
|
|
167
|
+
value?: any;
|
|
168
|
+
collection: string;
|
|
169
|
+
action: "update";
|
|
170
|
+
rkey: string;
|
|
171
|
+
}>;
|
|
172
|
+
export declare type RecordUpdateOp = z.infer<typeof recordUpdateOp>;
|
|
173
|
+
export declare const recordWriteOp: z.ZodUnion<[z.ZodObject<{
|
|
174
|
+
action: z.ZodLiteral<"create">;
|
|
175
|
+
collection: z.ZodString;
|
|
176
|
+
rkey: z.ZodString;
|
|
177
|
+
value: z.ZodAny;
|
|
178
|
+
}, "strip", z.ZodTypeAny, {
|
|
179
|
+
value?: any;
|
|
180
|
+
collection: string;
|
|
181
|
+
action: "create";
|
|
182
|
+
rkey: string;
|
|
183
|
+
}, {
|
|
184
|
+
value?: any;
|
|
185
|
+
collection: string;
|
|
186
|
+
action: "create";
|
|
187
|
+
rkey: string;
|
|
188
|
+
}>, z.ZodObject<{
|
|
189
|
+
action: z.ZodLiteral<"update">;
|
|
190
|
+
collection: z.ZodString;
|
|
191
|
+
rkey: z.ZodString;
|
|
192
|
+
value: z.ZodAny;
|
|
193
|
+
}, "strip", z.ZodTypeAny, {
|
|
194
|
+
value?: any;
|
|
195
|
+
collection: string;
|
|
196
|
+
action: "update";
|
|
197
|
+
rkey: string;
|
|
198
|
+
}, {
|
|
199
|
+
value?: any;
|
|
200
|
+
collection: string;
|
|
201
|
+
action: "update";
|
|
202
|
+
rkey: string;
|
|
203
|
+
}>, z.ZodObject<{
|
|
204
|
+
action: z.ZodLiteral<"delete">;
|
|
205
|
+
collection: z.ZodString;
|
|
206
|
+
rkey: z.ZodString;
|
|
207
|
+
}, "strip", z.ZodTypeAny, {
|
|
208
|
+
collection: string;
|
|
209
|
+
action: "delete";
|
|
210
|
+
rkey: string;
|
|
211
|
+
}, {
|
|
212
|
+
collection: string;
|
|
213
|
+
action: "delete";
|
|
214
|
+
rkey: string;
|
|
215
|
+
}>]>;
|
|
216
|
+
export declare type RecordWriteOp = z.infer<typeof recordWriteOp>;
|
|
217
|
+
export declare const def: {
|
|
218
|
+
repoMeta: z.ZodObject<{
|
|
219
|
+
did: z.ZodString;
|
|
220
|
+
version: z.ZodNumber;
|
|
221
|
+
datastore: z.ZodString;
|
|
222
|
+
}, "strip", z.ZodTypeAny, {
|
|
223
|
+
did: string;
|
|
224
|
+
version: number;
|
|
225
|
+
datastore: string;
|
|
226
|
+
}, {
|
|
227
|
+
did: string;
|
|
228
|
+
version: number;
|
|
229
|
+
datastore: string;
|
|
230
|
+
}>;
|
|
231
|
+
repoRoot: z.ZodObject<{
|
|
232
|
+
meta: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
|
|
233
|
+
prev: z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>>;
|
|
234
|
+
auth_token: z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>>;
|
|
235
|
+
data: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
|
|
236
|
+
}, "strip", z.ZodTypeAny, {
|
|
237
|
+
data: CID;
|
|
238
|
+
meta: CID;
|
|
239
|
+
prev: CID | null;
|
|
240
|
+
auth_token: CID | null;
|
|
241
|
+
}, {
|
|
242
|
+
data?: any;
|
|
243
|
+
meta?: any;
|
|
244
|
+
prev?: any;
|
|
245
|
+
auth_token?: any;
|
|
246
|
+
}>;
|
|
247
|
+
commit: z.ZodObject<{
|
|
248
|
+
root: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
|
|
249
|
+
sig: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
|
|
250
|
+
}, "strip", z.ZodTypeAny, {
|
|
251
|
+
root: CID;
|
|
252
|
+
sig: Uint8Array;
|
|
253
|
+
}, {
|
|
254
|
+
root?: any;
|
|
255
|
+
sig: Uint8Array;
|
|
256
|
+
}>;
|
|
257
|
+
cidWriteOp: z.ZodUnion<[z.ZodObject<{
|
|
258
|
+
action: z.ZodLiteral<"create">;
|
|
259
|
+
collection: z.ZodString;
|
|
260
|
+
rkey: z.ZodString;
|
|
261
|
+
cid: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
|
|
262
|
+
}, "strip", z.ZodTypeAny, {
|
|
263
|
+
collection: string;
|
|
264
|
+
action: "create";
|
|
265
|
+
rkey: string;
|
|
266
|
+
cid: CID;
|
|
267
|
+
}, {
|
|
268
|
+
cid?: any;
|
|
269
|
+
collection: string;
|
|
270
|
+
action: "create";
|
|
271
|
+
rkey: string;
|
|
272
|
+
}>, z.ZodObject<{
|
|
273
|
+
action: z.ZodLiteral<"update">;
|
|
274
|
+
collection: z.ZodString;
|
|
275
|
+
rkey: z.ZodString;
|
|
276
|
+
cid: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
|
|
277
|
+
}, "strip", z.ZodTypeAny, {
|
|
278
|
+
collection: string;
|
|
279
|
+
action: "update";
|
|
280
|
+
rkey: string;
|
|
281
|
+
cid: CID;
|
|
282
|
+
}, {
|
|
283
|
+
cid?: any;
|
|
284
|
+
collection: string;
|
|
285
|
+
action: "update";
|
|
286
|
+
rkey: string;
|
|
287
|
+
}>, z.ZodObject<{
|
|
288
|
+
action: z.ZodLiteral<"delete">;
|
|
289
|
+
collection: z.ZodString;
|
|
290
|
+
rkey: z.ZodString;
|
|
291
|
+
}, "strip", z.ZodTypeAny, {
|
|
292
|
+
collection: string;
|
|
293
|
+
action: "delete";
|
|
294
|
+
rkey: string;
|
|
295
|
+
}, {
|
|
296
|
+
collection: string;
|
|
297
|
+
action: "delete";
|
|
298
|
+
rkey: string;
|
|
299
|
+
}>]>;
|
|
300
|
+
recordWriteOp: z.ZodUnion<[z.ZodObject<{
|
|
301
|
+
action: z.ZodLiteral<"create">;
|
|
302
|
+
collection: z.ZodString;
|
|
303
|
+
rkey: z.ZodString;
|
|
304
|
+
value: z.ZodAny;
|
|
305
|
+
}, "strip", z.ZodTypeAny, {
|
|
306
|
+
value?: any;
|
|
307
|
+
collection: string;
|
|
308
|
+
action: "create";
|
|
309
|
+
rkey: string;
|
|
310
|
+
}, {
|
|
311
|
+
value?: any;
|
|
312
|
+
collection: string;
|
|
313
|
+
action: "create";
|
|
314
|
+
rkey: string;
|
|
315
|
+
}>, z.ZodObject<{
|
|
316
|
+
action: z.ZodLiteral<"update">;
|
|
317
|
+
collection: z.ZodString;
|
|
318
|
+
rkey: z.ZodString;
|
|
319
|
+
value: z.ZodAny;
|
|
320
|
+
}, "strip", z.ZodTypeAny, {
|
|
321
|
+
value?: any;
|
|
322
|
+
collection: string;
|
|
323
|
+
action: "update";
|
|
324
|
+
rkey: string;
|
|
325
|
+
}, {
|
|
326
|
+
value?: any;
|
|
327
|
+
collection: string;
|
|
328
|
+
action: "update";
|
|
329
|
+
rkey: string;
|
|
330
|
+
}>, z.ZodObject<{
|
|
331
|
+
action: z.ZodLiteral<"delete">;
|
|
332
|
+
collection: z.ZodString;
|
|
333
|
+
rkey: z.ZodString;
|
|
334
|
+
}, "strip", z.ZodTypeAny, {
|
|
335
|
+
collection: string;
|
|
336
|
+
action: "delete";
|
|
337
|
+
rkey: string;
|
|
338
|
+
}, {
|
|
339
|
+
collection: string;
|
|
340
|
+
action: "delete";
|
|
341
|
+
rkey: string;
|
|
342
|
+
}>]>;
|
|
343
|
+
string: z.ZodString;
|
|
344
|
+
cid: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
|
|
345
|
+
strToCid: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, CID, string>;
|
|
346
|
+
bytes: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
|
|
347
|
+
strToInt: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, number, string>;
|
|
348
|
+
strToBool: z.ZodEffects<z.ZodString, boolean, string>;
|
|
349
|
+
};
|
|
350
|
+
export interface CarStreamable {
|
|
351
|
+
writeToCarStream(car: BlockWriter): Promise<void>;
|
|
352
|
+
}
|
|
353
|
+
export declare type DataValue = {
|
|
354
|
+
key: string;
|
|
355
|
+
value: CID;
|
|
356
|
+
};
|
|
357
|
+
export interface DataStore {
|
|
358
|
+
add(key: string, value: CID): Promise<DataStore>;
|
|
359
|
+
update(key: string, value: CID): Promise<DataStore>;
|
|
360
|
+
delete(key: string): Promise<DataStore>;
|
|
361
|
+
get(key: string): Promise<CID | null>;
|
|
362
|
+
list(count: number, after?: string, before?: string): Promise<DataValue[]>;
|
|
363
|
+
listWithPrefix(prefix: string, count?: number): Promise<DataValue[]>;
|
|
364
|
+
diff(other: DataStore): Promise<DataDiff>;
|
|
365
|
+
stage(): Promise<CID>;
|
|
366
|
+
writeToCarStream(car: BlockWriter): Promise<void>;
|
|
367
|
+
}
|
|
368
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CID } from 'multiformats/cid';
|
|
2
|
+
import * as auth from '@atproto/auth';
|
|
3
|
+
import { DataDiff } from './mst';
|
|
4
|
+
import { IpldStore } from './blockstore';
|
|
5
|
+
import { DataStore, RecordWriteOp } from './types';
|
|
6
|
+
export declare const ucanForOperation: (prevData: DataStore, newData: DataStore, rootDid: string, authStore: auth.AuthStore) => Promise<string>;
|
|
7
|
+
export declare const getCommitPath: (blockstore: IpldStore, earliest: CID | null, latest: CID) => Promise<CID[] | null>;
|
|
8
|
+
export declare const getWriteOpLog: (blockstore: IpldStore, earliest: CID | null, latest: CID) => Promise<RecordWriteOp[][]>;
|
|
9
|
+
export declare const diffToWriteOps: (blockstore: IpldStore, diff: DataDiff) => Promise<RecordWriteOp[]>;
|
|
10
|
+
export declare const parseRecordKey: (key: string) => {
|
|
11
|
+
collection: string;
|
|
12
|
+
rkey: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CID } from 'multiformats/cid';
|
|
2
|
+
import * as auth from '@atproto/auth';
|
|
3
|
+
import { IpldStore } from './blockstore';
|
|
4
|
+
import { DataDiff } from './mst';
|
|
5
|
+
export declare const verifyUpdates: (blockstore: IpldStore, earliest: CID | null, latest: CID, verifier: auth.Verifier) => Promise<DataDiff>;
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CID } from 'multiformats/cid';
|
|
2
|
+
import { CommitData, RebaseData } from '../types';
|
|
3
|
+
import BlockMap from '../block-map';
|
|
4
|
+
import RepoStorage from './repo-storage';
|
|
5
|
+
export declare class MemoryBlockstore extends RepoStorage {
|
|
6
|
+
blocks: BlockMap;
|
|
7
|
+
head: CID | null;
|
|
8
|
+
constructor(blocks?: BlockMap);
|
|
9
|
+
getHead(): Promise<CID | null>;
|
|
10
|
+
getBytes(cid: CID): Promise<Uint8Array | null>;
|
|
11
|
+
has(cid: CID): Promise<boolean>;
|
|
12
|
+
getBlocks(cids: CID[]): Promise<{
|
|
13
|
+
blocks: BlockMap;
|
|
14
|
+
missing: CID[];
|
|
15
|
+
}>;
|
|
16
|
+
putBlock(cid: CID, block: Uint8Array): Promise<void>;
|
|
17
|
+
putMany(blocks: BlockMap): Promise<void>;
|
|
18
|
+
indexCommits(commits: CommitData[]): Promise<void>;
|
|
19
|
+
updateHead(cid: CID, _prev: CID | null): Promise<void>;
|
|
20
|
+
applyCommit(commit: CommitData): Promise<void>;
|
|
21
|
+
getCommitPath(latest: CID, earliest: CID | null): Promise<CID[] | null>;
|
|
22
|
+
getBlocksForCommits(commits: CID[]): Promise<{
|
|
23
|
+
[commit: string]: BlockMap;
|
|
24
|
+
}>;
|
|
25
|
+
applyRebase(rebase: RebaseData): Promise<void>;
|
|
26
|
+
sizeInBytes(): Promise<number>;
|
|
27
|
+
destroy(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export default MemoryBlockstore;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { check } from '@atproto/common';
|
|
2
|
+
import { RepoRecord } from '@atproto/lexicon';
|
|
3
|
+
import { CID } from 'multiformats/cid';
|
|
4
|
+
import BlockMap from '../block-map';
|
|
5
|
+
export declare abstract class ReadableBlockstore {
|
|
6
|
+
abstract getBytes(cid: CID): Promise<Uint8Array | null>;
|
|
7
|
+
abstract has(cid: CID): Promise<boolean>;
|
|
8
|
+
abstract getBlocks(cids: CID[]): Promise<{
|
|
9
|
+
blocks: BlockMap;
|
|
10
|
+
missing: CID[];
|
|
11
|
+
}>;
|
|
12
|
+
attemptRead<T>(cid: CID, def: check.Def<T>): Promise<{
|
|
13
|
+
obj: T;
|
|
14
|
+
bytes: Uint8Array;
|
|
15
|
+
} | null>;
|
|
16
|
+
readObjAndBytes<T>(cid: CID, def: check.Def<T>): Promise<{
|
|
17
|
+
obj: T;
|
|
18
|
+
bytes: Uint8Array;
|
|
19
|
+
}>;
|
|
20
|
+
readObj<T>(cid: CID, def: check.Def<T>): Promise<T>;
|
|
21
|
+
attemptReadRecord(cid: CID): Promise<RepoRecord | null>;
|
|
22
|
+
readRecord(cid: CID): Promise<RepoRecord>;
|
|
23
|
+
}
|
|
24
|
+
export default ReadableBlockstore;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CID } from 'multiformats/cid';
|
|
2
|
+
import BlockMap from '../block-map';
|
|
3
|
+
import { CommitBlockData, CommitData, RebaseData } from '../types';
|
|
4
|
+
import ReadableBlockstore from './readable-blockstore';
|
|
5
|
+
export declare abstract class RepoStorage extends ReadableBlockstore {
|
|
6
|
+
abstract getHead(forUpdate?: boolean): Promise<CID | null>;
|
|
7
|
+
abstract getCommitPath(latest: CID, earliest: CID | null): Promise<CID[] | null>;
|
|
8
|
+
abstract getBlocksForCommits(commits: CID[]): Promise<{
|
|
9
|
+
[commit: string]: BlockMap;
|
|
10
|
+
}>;
|
|
11
|
+
abstract putBlock(cid: CID, block: Uint8Array): Promise<void>;
|
|
12
|
+
abstract putMany(blocks: BlockMap): Promise<void>;
|
|
13
|
+
abstract updateHead(cid: CID, prev: CID | null): Promise<void>;
|
|
14
|
+
abstract indexCommits(commit: CommitData[]): Promise<void>;
|
|
15
|
+
abstract applyRebase(rebase: RebaseData): Promise<void>;
|
|
16
|
+
applyCommit(commit: CommitData): Promise<void>;
|
|
17
|
+
getCommits(latest: CID, earliest: CID | null): Promise<CommitBlockData[] | null>;
|
|
18
|
+
}
|
|
19
|
+
export default RepoStorage;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CID } from 'multiformats/cid';
|
|
2
|
+
import BlockMap from '../block-map';
|
|
3
|
+
import ReadableBlockstore from './readable-blockstore';
|
|
4
|
+
export declare class SyncStorage extends ReadableBlockstore {
|
|
5
|
+
staged: ReadableBlockstore;
|
|
6
|
+
saved: ReadableBlockstore;
|
|
7
|
+
constructor(staged: ReadableBlockstore, saved: ReadableBlockstore);
|
|
8
|
+
getBytes(cid: CID): Promise<Uint8Array | null>;
|
|
9
|
+
getBlocks(cids: CID[]): Promise<{
|
|
10
|
+
blocks: BlockMap;
|
|
11
|
+
missing: CID[];
|
|
12
|
+
}>;
|
|
13
|
+
has(cid: CID): Promise<boolean>;
|
|
14
|
+
}
|
|
15
|
+
export default SyncStorage;
|
package/dist/storage/types.d.ts
CHANGED
|
@@ -5,8 +5,12 @@ export interface BlobStore {
|
|
|
5
5
|
putTemp(bytes: Uint8Array | stream.Readable): Promise<string>;
|
|
6
6
|
makePermanent(key: string, cid: CID): Promise<void>;
|
|
7
7
|
putPermanent(cid: CID, bytes: Uint8Array | stream.Readable): Promise<void>;
|
|
8
|
+
quarantine(cid: CID): Promise<void>;
|
|
9
|
+
unquarantine(cid: CID): Promise<void>;
|
|
8
10
|
getBytes(cid: CID): Promise<Uint8Array>;
|
|
9
11
|
getStream(cid: CID): Promise<stream.Readable>;
|
|
12
|
+
hasStored(cid: CID): Promise<boolean>;
|
|
13
|
+
delete(cid: CID): Promise<void>;
|
|
10
14
|
}
|
|
11
15
|
export declare class BlobNotFoundError extends Error {
|
|
12
16
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CID } from 'multiformats/cid';
|
|
2
|
+
import { RepoStorage } from '../storage';
|
|
3
|
+
import Repo from '../repo';
|
|
4
|
+
import * as verify from '../verify';
|
|
5
|
+
import { RepoContents, WriteLog } from '../types';
|
|
6
|
+
export declare const loadCheckout: (storage: RepoStorage, repoCar: Uint8Array, did: string, signingKey: string) => Promise<{
|
|
7
|
+
root: CID;
|
|
8
|
+
contents: RepoContents;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const loadFullRepo: (storage: RepoStorage, repoCar: Uint8Array, did: string, signingKey: string) => Promise<{
|
|
11
|
+
root: CID;
|
|
12
|
+
writeLog: WriteLog;
|
|
13
|
+
repo: Repo;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const loadDiff: (repo: Repo, diffCar: Uint8Array, did: string, signingKey: string) => Promise<{
|
|
16
|
+
root: CID;
|
|
17
|
+
writeLog: WriteLog;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const persistUpdates: (storage: RepoStorage, updateStorage: RepoStorage, updates: verify.VerifiedUpdate[]) => Promise<WriteLog>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RecordPath } from '../types';
|
|
2
|
+
import { BlockWriter } from '@ipld/car/writer';
|
|
3
|
+
import { CID } from 'multiformats/cid';
|
|
4
|
+
import { RepoStorage } from '../storage';
|
|
5
|
+
export declare const getCheckout: (storage: RepoStorage, commitCid: CID) => AsyncIterable<Uint8Array>;
|
|
6
|
+
export declare const getCommits: (storage: RepoStorage, latest: CID, earliest: CID | null) => AsyncIterable<Uint8Array>;
|
|
7
|
+
export declare const getFullRepo: (storage: RepoStorage, cid: CID) => AsyncIterable<Uint8Array>;
|
|
8
|
+
export declare const writeCommitsToCarStream: (storage: RepoStorage, car: BlockWriter, latest: CID, earliest: CID | null) => Promise<void>;
|
|
9
|
+
export declare const getRecords: (storage: RepoStorage, commitCid: CID, paths: RecordPath[]) => AsyncIterable<Uint8Array>;
|