@atproto/repo 0.1.0 → 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.
Files changed (77) hide show
  1. package/dist/block-map.d.ts +2 -0
  2. package/dist/data-diff.d.ts +2 -2
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +12090 -2882
  5. package/dist/index.js.map +4 -4
  6. package/dist/mst/mst.d.ts +13 -14
  7. package/dist/readable-repo.d.ts +4 -3
  8. package/dist/repo.d.ts +6 -2
  9. package/dist/src/block-map.d.ts +23 -0
  10. package/dist/src/blockstore/persistent-blockstore.d.ts +12 -0
  11. package/dist/src/cid-set.d.ts +14 -0
  12. package/dist/src/collection.d.ts +22 -0
  13. package/dist/src/data-diff.d.ts +34 -0
  14. package/dist/src/error.d.ts +21 -0
  15. package/dist/src/index.d.ts +7 -0
  16. package/dist/src/logger.d.ts +2 -0
  17. package/dist/src/mst/diff.d.ts +33 -0
  18. package/dist/src/mst/index.d.ts +4 -0
  19. package/dist/src/mst/mst.d.ts +106 -0
  20. package/dist/src/mst/util.d.ts +9 -0
  21. package/dist/src/mst/walker.d.ts +22 -0
  22. package/dist/src/parse.d.ts +11 -0
  23. package/dist/src/readable-repo.d.ts +25 -0
  24. package/dist/src/repo.d.ts +39 -0
  25. package/dist/src/storage/error.d.ts +22 -0
  26. package/dist/src/storage/index.d.ts +1 -0
  27. package/dist/src/storage/memory-blobstore.d.ts +1 -0
  28. package/dist/src/storage/memory-blockstore.d.ts +28 -0
  29. package/dist/src/storage/readable-blockstore.d.ts +21 -0
  30. package/dist/src/storage/repo-storage.d.ts +18 -0
  31. package/dist/src/storage/sync-storage.d.ts +15 -0
  32. package/dist/src/storage/types.d.ts +12 -0
  33. package/dist/src/storage/util.d.ts +17 -0
  34. package/dist/src/structure.d.ts +39 -0
  35. package/dist/src/sync/consumer.d.ts +19 -0
  36. package/dist/src/sync/index.d.ts +2 -0
  37. package/dist/src/sync/producer.d.ts +13 -0
  38. package/dist/src/sync/provider.d.ts +11 -0
  39. package/dist/src/types.d.ts +368 -0
  40. package/dist/src/util.d.ts +13 -0
  41. package/dist/src/verify.d.ts +5 -0
  42. package/dist/storage/memory-blockstore.d.ts +2 -1
  43. package/dist/storage/repo-storage.d.ts +2 -1
  44. package/dist/storage/types.d.ts +1 -0
  45. package/dist/sync/consumer.d.ts +1 -0
  46. package/dist/sync/provider.d.ts +4 -4
  47. package/dist/tsconfig.build.tsbuildinfo +1 -0
  48. package/dist/types.d.ts +30 -31
  49. package/dist/util.d.ts +6 -2
  50. package/dist/verify.d.ts +6 -1
  51. package/jest.bench.config.js +2 -1
  52. package/package.json +11 -6
  53. package/src/block-map.ts +8 -0
  54. package/src/data-diff.ts +2 -6
  55. package/src/index.ts +1 -0
  56. package/src/mst/mst.ts +1 -10
  57. package/src/readable-repo.ts +3 -3
  58. package/src/repo.ts +33 -2
  59. package/src/storage/memory-blockstore.ts +20 -1
  60. package/src/storage/repo-storage.ts +2 -1
  61. package/src/storage/types.ts +1 -0
  62. package/src/sync/consumer.ts +4 -1
  63. package/src/sync/provider.ts +11 -11
  64. package/src/types.ts +19 -21
  65. package/src/util.ts +34 -13
  66. package/src/verify.ts +52 -11
  67. package/tests/rebase.test.ts +37 -0
  68. package/tests/sync/checkout.test.ts +21 -3
  69. package/tests/sync/diff.test.ts +9 -4
  70. package/tests/sync/narrow.test.ts +8 -4
  71. package/tests/util.test.ts +21 -0
  72. package/tsconfig.build.tsbuildinfo +1 -1
  73. package/tsconfig.json +1 -1
  74. /package/dist/{blockstore → src/blockstore}/index.d.ts +0 -0
  75. /package/dist/{blockstore → src/blockstore}/ipld-store.d.ts +0 -0
  76. /package/dist/{blockstore → src/blockstore}/memory-blockstore.d.ts +0 -0
  77. /package/dist/{sync.d.ts → src/sync.d.ts} +0 -0
@@ -0,0 +1,17 @@
1
+ import { check } from '@atproto/common';
2
+ import { CID } from 'multiformats/cid';
3
+ import BlockMap from '../block-map';
4
+ import { ReadableBlockstore } from './types';
5
+ export declare const readAndVerify: <T>(storage: ReadableBlockstore, cid: CID, def: check.Def<T>) => Promise<{
6
+ obj: T;
7
+ bytes: Uint8Array;
8
+ }>;
9
+ export declare const getAndVerify: <T>(blocks: BlockMap, cid: CID, def: check.Def<T>) => Promise<{
10
+ obj: T;
11
+ bytes: Uint8Array;
12
+ }>;
13
+ export declare const verifyObj: <T>(bytes: Uint8Array | null, cid: CID, def: check.Def<T>) => Promise<{
14
+ obj: T;
15
+ bytes: Uint8Array;
16
+ }>;
17
+ export declare const readObj: <T>(storage: ReadableBlockstore, cid: CID, schema: check.Def<T>) => Promise<T>;
@@ -0,0 +1,39 @@
1
+ import { CID } from 'multiformats/cid';
2
+ import { BlockWriter } from '@ipld/car/lib/writer-browser';
3
+ import { RepoRoot, Commit, CidWriteOp, DataStore, RepoMeta } from './types';
4
+ import IpldStore from './blockstore/ipld-store';
5
+ import * as auth from '@atproto/auth';
6
+ declare type Params = {
7
+ blockstore: IpldStore;
8
+ data: DataStore;
9
+ commit: Commit;
10
+ root: RepoRoot;
11
+ meta: RepoMeta;
12
+ cid: CID;
13
+ stagedWrites: CidWriteOp[];
14
+ };
15
+ export declare class RepoStructure {
16
+ blockstore: IpldStore;
17
+ data: DataStore;
18
+ commit: Commit;
19
+ root: RepoRoot;
20
+ meta: RepoMeta;
21
+ cid: CID;
22
+ stagedWrites: CidWriteOp[];
23
+ constructor(params: Params);
24
+ static create(blockstore: IpldStore, did: string, authStore: auth.AuthStore): Promise<RepoStructure>;
25
+ static load(blockstore: IpldStore, cid: CID): Promise<RepoStructure>;
26
+ private updateRepo;
27
+ did(): string;
28
+ getRecord(collection: string, rkey: string): Promise<unknown | null>;
29
+ stageUpdate(write: CidWriteOp | CidWriteOp[]): RepoStructure;
30
+ createCommit(authStore: auth.AuthStore, performUpdate?: (prev: CID, curr: CID) => Promise<CID | null>): Promise<RepoStructure>;
31
+ revert(count: number): Promise<RepoStructure>;
32
+ getCarNoHistory(): Promise<Uint8Array>;
33
+ getDiffCar(to: CID | null): Promise<Uint8Array>;
34
+ getFullHistory(): Promise<Uint8Array>;
35
+ private openCar;
36
+ writeCheckoutToCarStream(car: BlockWriter): Promise<void>;
37
+ writeCommitsToCarStream(car: BlockWriter, oldestCommit: CID | null, recentCommit: CID): Promise<void>;
38
+ }
39
+ export default RepoStructure;
@@ -0,0 +1,19 @@
1
+ import { CID } from 'multiformats/cid';
2
+ import { DidResolver } from '@atproto/did-resolver';
3
+ import { RepoStorage } from '../storage';
4
+ import Repo from '../repo';
5
+ import * as verify from '../verify';
6
+ import { RepoContents, WriteLog } from '../types';
7
+ export declare const loadCheckout: (storage: RepoStorage, repoCar: Uint8Array, didResolver: DidResolver) => Promise<{
8
+ root: CID;
9
+ contents: RepoContents;
10
+ }>;
11
+ export declare const loadFullRepo: (storage: RepoStorage, repoCar: Uint8Array, didResolver: DidResolver) => Promise<{
12
+ root: CID;
13
+ writeLog: WriteLog;
14
+ }>;
15
+ export declare const loadDiff: (repo: Repo, diffCar: Uint8Array, didResolver: DidResolver) => 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,2 @@
1
+ export * from './consumer';
2
+ export * from './provider';
@@ -0,0 +1,13 @@
1
+ import { BlockWriter } from '@ipld/car/writer';
2
+ import { CID } from 'multiformats/cid';
3
+ import { RepoStorage } from '../storage';
4
+ import { RepoRoot } from '../types';
5
+ export declare const getCheckout: (storage: RepoStorage, cid: CID) => Promise<Uint8Array>;
6
+ export declare const getDiff: (storage: RepoStorage, latest: CID, earliest: CID | null) => Promise<Uint8Array>;
7
+ export declare const getFullRepo: (storage: RepoStorage, cid: CID) => Promise<Uint8Array>;
8
+ export declare const writeCommitsToCarStream: (storage: RepoStorage, car: BlockWriter, latest: CID, earliest: CID | null) => Promise<void>;
9
+ export declare const getRecords: (storage: RepoStorage, commit: CID, paths: {
10
+ collection: string;
11
+ rkey: string;
12
+ }[]) => Promise<Uint8Array>;
13
+ export declare const writeCommitAndRootToCar: (storage: RepoStorage, car: BlockWriter, cid: CID) => Promise<RepoRoot>;
@@ -0,0 +1,11 @@
1
+ import { RecordPath } from '../types';
2
+ import { BlockWriter } from '@ipld/car/writer';
3
+ import { CID } from 'multiformats/cid';
4
+ import { RepoStorage } from '../storage';
5
+ import { RepoRoot } from '../types';
6
+ export declare const getCheckout: (storage: RepoStorage, cid: CID) => Promise<Uint8Array>;
7
+ export declare const getDiff: (storage: RepoStorage, latest: CID, earliest: CID | null) => Promise<Uint8Array>;
8
+ export declare const getFullRepo: (storage: RepoStorage, cid: CID) => Promise<Uint8Array>;
9
+ export declare const writeCommitsToCarStream: (storage: RepoStorage, car: BlockWriter, latest: CID, earliest: CID | null) => Promise<void>;
10
+ export declare const getRecords: (storage: RepoStorage, commit: CID, paths: RecordPath[]) => Promise<Uint8Array>;
11
+ export declare const writeCommitAndRootToCar: (storage: RepoStorage, car: BlockWriter, cid: CID) => Promise<RepoRoot>;
@@ -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>;
@@ -1,5 +1,5 @@
1
1
  import { CID } from 'multiformats/cid';
2
- import { CommitData } from '../types';
2
+ import { CommitData, RebaseData } from '../types';
3
3
  import BlockMap from '../block-map';
4
4
  import RepoStorage from './repo-storage';
5
5
  export declare class MemoryBlockstore extends RepoStorage {
@@ -22,6 +22,7 @@ export declare class MemoryBlockstore extends RepoStorage {
22
22
  getBlocksForCommits(commits: CID[]): Promise<{
23
23
  [commit: string]: BlockMap;
24
24
  }>;
25
+ applyRebase(rebase: RebaseData): Promise<void>;
25
26
  sizeInBytes(): Promise<number>;
26
27
  destroy(): Promise<void>;
27
28
  }
@@ -1,6 +1,6 @@
1
1
  import { CID } from 'multiformats/cid';
2
2
  import BlockMap from '../block-map';
3
- import { CommitBlockData, CommitData } from '../types';
3
+ import { CommitBlockData, CommitData, RebaseData } from '../types';
4
4
  import ReadableBlockstore from './readable-blockstore';
5
5
  export declare abstract class RepoStorage extends ReadableBlockstore {
6
6
  abstract getHead(forUpdate?: boolean): Promise<CID | null>;
@@ -12,6 +12,7 @@ export declare abstract class RepoStorage extends ReadableBlockstore {
12
12
  abstract putMany(blocks: BlockMap): Promise<void>;
13
13
  abstract updateHead(cid: CID, prev: CID | null): Promise<void>;
14
14
  abstract indexCommits(commit: CommitData[]): Promise<void>;
15
+ abstract applyRebase(rebase: RebaseData): Promise<void>;
15
16
  applyCommit(commit: CommitData): Promise<void>;
16
17
  getCommits(latest: CID, earliest: CID | null): Promise<CommitBlockData[] | null>;
17
18
  }
@@ -9,6 +9,7 @@ export interface BlobStore {
9
9
  unquarantine(cid: CID): Promise<void>;
10
10
  getBytes(cid: CID): Promise<Uint8Array>;
11
11
  getStream(cid: CID): Promise<stream.Readable>;
12
+ hasStored(cid: CID): Promise<boolean>;
12
13
  delete(cid: CID): Promise<void>;
13
14
  }
14
15
  export declare class BlobNotFoundError extends Error {
@@ -10,6 +10,7 @@ export declare const loadCheckout: (storage: RepoStorage, repoCar: Uint8Array, d
10
10
  export declare const loadFullRepo: (storage: RepoStorage, repoCar: Uint8Array, did: string, signingKey: string) => Promise<{
11
11
  root: CID;
12
12
  writeLog: WriteLog;
13
+ repo: Repo;
13
14
  }>;
14
15
  export declare const loadDiff: (repo: Repo, diffCar: Uint8Array, did: string, signingKey: string) => Promise<{
15
16
  root: CID;
@@ -2,8 +2,8 @@ import { RecordPath } from '../types';
2
2
  import { BlockWriter } from '@ipld/car/writer';
3
3
  import { CID } from 'multiformats/cid';
4
4
  import { RepoStorage } from '../storage';
5
- export declare const getCheckout: (storage: RepoStorage, commitCid: CID) => Promise<Uint8Array>;
6
- export declare const getDiff: (storage: RepoStorage, latest: CID, earliest: CID | null) => Promise<Uint8Array>;
7
- export declare const getFullRepo: (storage: RepoStorage, cid: CID) => Promise<Uint8Array>;
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
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[]) => Promise<Uint8Array>;
9
+ export declare const getRecords: (storage: RepoStorage, commitCid: CID, paths: RecordPath[]) => AsyncIterable<Uint8Array>;