@atproto/repo 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-diff.d.ts +11 -9
- package/dist/index.d.ts +0 -1
- package/dist/index.js +404 -1655
- package/dist/index.js.map +4 -4
- package/dist/mst/mst.d.ts +10 -6
- package/dist/readable-repo.d.ts +1 -1
- package/dist/repo.d.ts +1 -4
- package/dist/storage/index.d.ts +0 -1
- package/dist/storage/memory-blockstore.d.ts +7 -12
- package/dist/storage/types.d.ts +28 -0
- package/dist/sync/consumer.d.ts +13 -17
- package/dist/sync/provider.d.ts +1 -5
- package/dist/types.d.ts +228 -39
- package/dist/util.d.ts +3 -5
- package/package.json +2 -2
- package/src/data-diff.ts +46 -44
- package/src/index.ts +0 -1
- package/src/mst/diff.ts +14 -36
- package/src/mst/mst.ts +14 -4
- package/src/readable-repo.ts +3 -3
- package/src/repo.ts +49 -70
- package/src/storage/index.ts +0 -1
- package/src/storage/memory-blockstore.ts +18 -77
- package/src/storage/types.ts +29 -0
- package/src/sync/consumer.ts +170 -116
- package/src/sync/provider.ts +2 -40
- package/src/types.ts +49 -23
- package/src/util.ts +24 -79
- package/tests/_util.ts +38 -67
- package/tests/mst.test.ts +4 -1
- package/tests/{sync/narrow.test.ts → proofs.test.ts} +9 -20
- package/tests/repo.test.ts +5 -4
- package/tests/sync.test.ts +97 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/src/block-map.d.ts +0 -23
- package/dist/src/blockstore/index.d.ts +0 -2
- package/dist/src/blockstore/ipld-store.d.ts +0 -27
- package/dist/src/blockstore/memory-blockstore.d.ts +0 -13
- package/dist/src/blockstore/persistent-blockstore.d.ts +0 -12
- package/dist/src/cid-set.d.ts +0 -14
- package/dist/src/collection.d.ts +0 -22
- package/dist/src/data-diff.d.ts +0 -34
- package/dist/src/error.d.ts +0 -21
- package/dist/src/index.d.ts +0 -7
- package/dist/src/logger.d.ts +0 -2
- package/dist/src/mst/diff.d.ts +0 -33
- package/dist/src/mst/index.d.ts +0 -4
- package/dist/src/mst/mst.d.ts +0 -106
- package/dist/src/mst/util.d.ts +0 -9
- package/dist/src/mst/walker.d.ts +0 -22
- package/dist/src/parse.d.ts +0 -11
- package/dist/src/readable-repo.d.ts +0 -25
- package/dist/src/repo.d.ts +0 -39
- package/dist/src/storage/error.d.ts +0 -22
- package/dist/src/storage/index.d.ts +0 -1
- package/dist/src/storage/memory-blobstore.d.ts +0 -1
- package/dist/src/storage/memory-blockstore.d.ts +0 -28
- package/dist/src/storage/readable-blockstore.d.ts +0 -21
- package/dist/src/storage/repo-storage.d.ts +0 -18
- package/dist/src/storage/sync-storage.d.ts +0 -15
- package/dist/src/storage/types.d.ts +0 -12
- package/dist/src/storage/util.d.ts +0 -17
- package/dist/src/structure.d.ts +0 -39
- package/dist/src/sync/consumer.d.ts +0 -19
- package/dist/src/sync/index.d.ts +0 -2
- package/dist/src/sync/producer.d.ts +0 -13
- package/dist/src/sync/provider.d.ts +0 -11
- package/dist/src/sync.d.ts +0 -9
- package/dist/src/types.d.ts +0 -368
- package/dist/src/util.d.ts +0 -13
- package/dist/src/verify.d.ts +0 -5
- package/dist/storage/repo-storage.d.ts +0 -19
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/verify.d.ts +0 -32
- package/src/storage/repo-storage.ts +0 -43
- package/src/verify.ts +0 -268
- package/tests/rebase.test.ts +0 -37
- package/tests/sync/checkout.test.ts +0 -75
- package/tests/sync/diff.test.ts +0 -92
package/dist/src/mst/mst.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import z from 'zod';
|
|
2
|
-
import { CID } from 'multiformats';
|
|
3
|
-
import IpldStore from '../blockstore/ipld-store';
|
|
4
|
-
import { DataDiff } from './diff';
|
|
5
|
-
import { DataStore } from '../types';
|
|
6
|
-
import { BlockWriter } from '@ipld/car/api';
|
|
7
|
-
export declare const nodeDataDef: z.ZodObject<{
|
|
8
|
-
l: z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>>;
|
|
9
|
-
e: z.ZodArray<z.ZodObject<{
|
|
10
|
-
p: z.ZodNumber;
|
|
11
|
-
k: z.ZodString;
|
|
12
|
-
v: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
|
|
13
|
-
t: z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>>;
|
|
14
|
-
}, "strip", z.ZodTypeAny, {
|
|
15
|
-
t: CID | null;
|
|
16
|
-
p: number;
|
|
17
|
-
k: string;
|
|
18
|
-
v: CID;
|
|
19
|
-
}, {
|
|
20
|
-
t?: any;
|
|
21
|
-
v?: any;
|
|
22
|
-
p: number;
|
|
23
|
-
k: string;
|
|
24
|
-
}>, "many">;
|
|
25
|
-
}, "strip", z.ZodTypeAny, {
|
|
26
|
-
l: CID | null;
|
|
27
|
-
e: {
|
|
28
|
-
t: CID | null;
|
|
29
|
-
p: number;
|
|
30
|
-
k: string;
|
|
31
|
-
v: CID;
|
|
32
|
-
}[];
|
|
33
|
-
}, {
|
|
34
|
-
l?: any;
|
|
35
|
-
e: {
|
|
36
|
-
t?: any;
|
|
37
|
-
v?: any;
|
|
38
|
-
p: number;
|
|
39
|
-
k: string;
|
|
40
|
-
}[];
|
|
41
|
-
}>;
|
|
42
|
-
export declare type NodeData = z.infer<typeof nodeDataDef>;
|
|
43
|
-
export declare type NodeEntry = MST | Leaf;
|
|
44
|
-
export declare type Fanout = 2 | 8 | 16 | 32 | 64;
|
|
45
|
-
export declare type MstOpts = {
|
|
46
|
-
layer: number;
|
|
47
|
-
fanout: Fanout;
|
|
48
|
-
};
|
|
49
|
-
export declare class MST implements DataStore {
|
|
50
|
-
blockstore: IpldStore;
|
|
51
|
-
fanout: Fanout;
|
|
52
|
-
entries: NodeEntry[] | null;
|
|
53
|
-
layer: number | null;
|
|
54
|
-
pointer: CID;
|
|
55
|
-
outdatedPointer: boolean;
|
|
56
|
-
constructor(blockstore: IpldStore, fanout: Fanout, pointer: CID, entries: NodeEntry[] | null, layer: number | null);
|
|
57
|
-
static create(blockstore: IpldStore, entries?: NodeEntry[], opts?: Partial<MstOpts>): Promise<MST>;
|
|
58
|
-
static fromData(blockstore: IpldStore, data: NodeData, opts?: Partial<MstOpts>): Promise<MST>;
|
|
59
|
-
static load(blockstore: IpldStore, cid: CID, opts?: Partial<MstOpts>): MST;
|
|
60
|
-
newTree(entries: NodeEntry[]): Promise<MST>;
|
|
61
|
-
getEntries(): Promise<NodeEntry[]>;
|
|
62
|
-
getPointer(): Promise<CID>;
|
|
63
|
-
getLayer(): Promise<number>;
|
|
64
|
-
attemptGetLayer(): Promise<number | null>;
|
|
65
|
-
stage(): Promise<CID>;
|
|
66
|
-
stageRecurse(trimTop?: boolean): Promise<CID>;
|
|
67
|
-
add(key: string, value: CID, knownZeros?: number): Promise<MST>;
|
|
68
|
-
get(key: string): Promise<CID | null>;
|
|
69
|
-
update(key: string, value: CID): Promise<MST>;
|
|
70
|
-
delete(key: string): Promise<MST>;
|
|
71
|
-
diff(other: MST): Promise<DataDiff>;
|
|
72
|
-
updateEntry(index: number, entry: NodeEntry): Promise<MST>;
|
|
73
|
-
removeEntry(index: number): Promise<MST>;
|
|
74
|
-
append(entry: NodeEntry): Promise<MST>;
|
|
75
|
-
prepend(entry: NodeEntry): Promise<MST>;
|
|
76
|
-
atIndex(index: number): Promise<NodeEntry | null>;
|
|
77
|
-
slice(start?: number | undefined, end?: number | undefined): Promise<NodeEntry[]>;
|
|
78
|
-
spliceIn(entry: NodeEntry, index: number): Promise<MST>;
|
|
79
|
-
replaceWithSplit(index: number, left: MST | null, leaf: Leaf, right: MST | null): Promise<MST>;
|
|
80
|
-
splitAround(key: string): Promise<[MST | null, MST | null]>;
|
|
81
|
-
appendMerge(toMerge: MST): Promise<MST>;
|
|
82
|
-
createChild(): Promise<MST>;
|
|
83
|
-
createParent(): Promise<MST>;
|
|
84
|
-
findGtOrEqualLeafIndex(key: string): Promise<number>;
|
|
85
|
-
walkLeavesFrom(key: string): AsyncIterable<Leaf>;
|
|
86
|
-
list(count: number, after?: string, before?: string): Promise<Leaf[]>;
|
|
87
|
-
listWithPrefix(prefix: string, count?: number): Promise<Leaf[]>;
|
|
88
|
-
walk(): AsyncIterable<NodeEntry>;
|
|
89
|
-
paths(): Promise<NodeEntry[][]>;
|
|
90
|
-
allNodes(): Promise<NodeEntry[]>;
|
|
91
|
-
leaves(): Promise<Leaf[]>;
|
|
92
|
-
leafCount(): Promise<number>;
|
|
93
|
-
writeToCarStream(car: BlockWriter): Promise<void>;
|
|
94
|
-
isTree(): this is MST;
|
|
95
|
-
isLeaf(): this is Leaf;
|
|
96
|
-
equals(other: NodeEntry): Promise<boolean>;
|
|
97
|
-
}
|
|
98
|
-
export declare class Leaf {
|
|
99
|
-
key: string;
|
|
100
|
-
value: CID;
|
|
101
|
-
constructor(key: string, value: CID);
|
|
102
|
-
isTree(): this is MST;
|
|
103
|
-
isLeaf(): this is Leaf;
|
|
104
|
-
equals(entry: NodeEntry): boolean;
|
|
105
|
-
}
|
|
106
|
-
export default MST;
|
package/dist/src/mst/util.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CID } from 'multiformats';
|
|
2
|
-
import IpldStore from '../blockstore/ipld-store';
|
|
3
|
-
import { NodeEntry, NodeData, MstOpts, Fanout } from './mst';
|
|
4
|
-
export declare const leadingZerosOnHash: (key: string, fanout: Fanout) => Promise<number>;
|
|
5
|
-
export declare const layerForEntries: (entries: NodeEntry[], fanout: Fanout) => Promise<number | null>;
|
|
6
|
-
export declare const deserializeNodeData: (blockstore: IpldStore, data: NodeData, opts?: Partial<MstOpts>) => Promise<NodeEntry[]>;
|
|
7
|
-
export declare const serializeNodeData: (entries: NodeEntry[]) => NodeData;
|
|
8
|
-
export declare const countPrefixLen: (a: string, b: string) => number;
|
|
9
|
-
export declare const cidForEntries: (entries: NodeEntry[]) => Promise<CID>;
|
package/dist/src/mst/walker.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { MST, NodeEntry } from './mst';
|
|
2
|
-
declare type WalkerStatusDone = {
|
|
3
|
-
done: true;
|
|
4
|
-
};
|
|
5
|
-
declare type WalkerStatusProgress = {
|
|
6
|
-
done: false;
|
|
7
|
-
curr: NodeEntry;
|
|
8
|
-
walking: MST | null;
|
|
9
|
-
index: number;
|
|
10
|
-
};
|
|
11
|
-
declare type WalkerStatus = WalkerStatusDone | WalkerStatusProgress;
|
|
12
|
-
export declare class MstWalker {
|
|
13
|
-
root: MST;
|
|
14
|
-
stack: WalkerStatus[];
|
|
15
|
-
status: WalkerStatus;
|
|
16
|
-
constructor(root: MST);
|
|
17
|
-
layer(): number;
|
|
18
|
-
stepOver(): Promise<void>;
|
|
19
|
-
stepInto(): Promise<void>;
|
|
20
|
-
advance(): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
export default MstWalker;
|
package/dist/src/parse.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { check } from '@atproto/common';
|
|
2
|
-
import { CID } from 'multiformats/cid';
|
|
3
|
-
import BlockMap from './block-map';
|
|
4
|
-
export declare const getAndParse: <T>(blocks: BlockMap, cid: CID, def: check.Def<T>) => Promise<{
|
|
5
|
-
obj: T;
|
|
6
|
-
bytes: Uint8Array;
|
|
7
|
-
}>;
|
|
8
|
-
export declare const parseObj: <T>(bytes: Uint8Array, cid: CID, def: check.Def<T>) => {
|
|
9
|
-
obj: T;
|
|
10
|
-
bytes: Uint8Array;
|
|
11
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { CID } from 'multiformats/cid';
|
|
2
|
-
import { RepoRoot, Commit, DataStore, RepoMeta, RepoContents } from './types';
|
|
3
|
-
import { ReadableBlockstore } from './storage';
|
|
4
|
-
declare type Params = {
|
|
5
|
-
storage: ReadableBlockstore;
|
|
6
|
-
data: DataStore;
|
|
7
|
-
commit: Commit;
|
|
8
|
-
root: RepoRoot;
|
|
9
|
-
meta: RepoMeta;
|
|
10
|
-
cid: CID;
|
|
11
|
-
};
|
|
12
|
-
export declare class ReadableRepo {
|
|
13
|
-
storage: ReadableBlockstore;
|
|
14
|
-
data: DataStore;
|
|
15
|
-
commit: Commit;
|
|
16
|
-
root: RepoRoot;
|
|
17
|
-
meta: RepoMeta;
|
|
18
|
-
cid: CID;
|
|
19
|
-
constructor(params: Params);
|
|
20
|
-
static load(storage: ReadableBlockstore, commitCid: CID): Promise<ReadableRepo>;
|
|
21
|
-
get did(): string;
|
|
22
|
-
getRecord(collection: string, rkey: string): Promise<unknown | null>;
|
|
23
|
-
getContents(): Promise<RepoContents>;
|
|
24
|
-
}
|
|
25
|
-
export default ReadableRepo;
|
package/dist/src/repo.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { CID } from 'multiformats/cid';
|
|
2
|
-
import { BlockWriter } from '@ipld/car/writer';
|
|
3
|
-
import { RepoRoot, Commit, DataStore, RepoMeta, RecordCreateOp, RecordWriteOp } 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: RecordWriteOp[];
|
|
14
|
-
};
|
|
15
|
-
export declare class Repo {
|
|
16
|
-
blockstore: IpldStore;
|
|
17
|
-
data: DataStore;
|
|
18
|
-
commit: Commit;
|
|
19
|
-
root: RepoRoot;
|
|
20
|
-
meta: RepoMeta;
|
|
21
|
-
cid: CID;
|
|
22
|
-
stagedWrites: RecordWriteOp[];
|
|
23
|
-
constructor(params: Params);
|
|
24
|
-
static create(blockstore: IpldStore, did: string, authStore: auth.AuthStore, initialRecords?: RecordCreateOp[]): Promise<Repo>;
|
|
25
|
-
static load(blockstore: IpldStore, cid: CID): Promise<Repo>;
|
|
26
|
-
private updateRepo;
|
|
27
|
-
get did(): string;
|
|
28
|
-
getRecord(collection: string, rkey: string): Promise<unknown | null>;
|
|
29
|
-
stageUpdate(write: RecordWriteOp | RecordWriteOp[]): Repo;
|
|
30
|
-
createCommit(authStore: auth.AuthStore, performUpdate?: (prev: CID, curr: CID) => Promise<CID | null>): Promise<Repo>;
|
|
31
|
-
revert(count: number): Promise<Repo>;
|
|
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 Repo;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Def } from '@atproto/common/src/check';
|
|
2
|
-
import { CID } from 'multiformats/cid';
|
|
3
|
-
export declare class MissingBlockError extends Error {
|
|
4
|
-
cid: CID;
|
|
5
|
-
def?: Def<unknown> | undefined;
|
|
6
|
-
constructor(cid: CID, def?: Def<unknown> | undefined);
|
|
7
|
-
}
|
|
8
|
-
export declare class MissingBlocksError extends Error {
|
|
9
|
-
context: string;
|
|
10
|
-
cids: CID[];
|
|
11
|
-
constructor(context: string, cids: CID[]);
|
|
12
|
-
}
|
|
13
|
-
export declare class MissingCommitBlocksError extends Error {
|
|
14
|
-
commit: CID;
|
|
15
|
-
cids: CID[];
|
|
16
|
-
constructor(commit: CID, cids: CID[]);
|
|
17
|
-
}
|
|
18
|
-
export declare class UnexpectedObjectError extends Error {
|
|
19
|
-
cid: CID;
|
|
20
|
-
def: Def<unknown>;
|
|
21
|
-
constructor(cid: CID, def: Def<unknown>);
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './types';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const thing = 1;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { CID } from 'multiformats/cid';
|
|
2
|
-
import { CommitData } 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
|
-
sizeInBytes(): Promise<number>;
|
|
26
|
-
destroy(): Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
export default MemoryBlockstore;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { check } from '@atproto/common';
|
|
2
|
-
import { CID } from 'multiformats/cid';
|
|
3
|
-
import BlockMap from '../block-map';
|
|
4
|
-
export declare abstract class ReadableBlockstore {
|
|
5
|
-
abstract getBytes(cid: CID): Promise<Uint8Array | null>;
|
|
6
|
-
abstract has(cid: CID): Promise<boolean>;
|
|
7
|
-
abstract getBlocks(cids: CID[]): Promise<{
|
|
8
|
-
blocks: BlockMap;
|
|
9
|
-
missing: CID[];
|
|
10
|
-
}>;
|
|
11
|
-
attemptRead<T>(cid: CID, def: check.Def<T>): Promise<{
|
|
12
|
-
obj: T;
|
|
13
|
-
bytes: Uint8Array;
|
|
14
|
-
} | null>;
|
|
15
|
-
readObjAndBytes<T>(cid: CID, def: check.Def<T>): Promise<{
|
|
16
|
-
obj: T;
|
|
17
|
-
bytes: Uint8Array;
|
|
18
|
-
}>;
|
|
19
|
-
readObj<T>(cid: CID, def: check.Def<T>): Promise<T>;
|
|
20
|
-
}
|
|
21
|
-
export default ReadableBlockstore;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CID } from 'multiformats/cid';
|
|
2
|
-
import BlockMap from '../block-map';
|
|
3
|
-
import { CommitBlockData, CommitData } 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
|
-
applyCommit(commit: CommitData): Promise<void>;
|
|
16
|
-
getCommits(latest: CID, earliest: CID | null): Promise<CommitBlockData[] | null>;
|
|
17
|
-
}
|
|
18
|
-
export default RepoStorage;
|
|
@@ -1,15 +0,0 @@
|
|
|
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;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import stream from 'stream';
|
|
3
|
-
import { CID } from 'multiformats/cid';
|
|
4
|
-
export interface BlobStore {
|
|
5
|
-
putTemp(bytes: Uint8Array | stream.Readable): Promise<string>;
|
|
6
|
-
makePermanent(key: string, cid: CID): Promise<void>;
|
|
7
|
-
putPermanent(cid: CID, bytes: Uint8Array | stream.Readable): Promise<void>;
|
|
8
|
-
getBytes(cid: CID): Promise<Uint8Array>;
|
|
9
|
-
getStream(cid: CID): Promise<stream.Readable>;
|
|
10
|
-
}
|
|
11
|
-
export declare class BlobNotFoundError extends Error {
|
|
12
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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>;
|
package/dist/src/structure.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
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;
|
|
@@ -1,19 +0,0 @@
|
|
|
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>;
|
package/dist/src/sync/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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>;
|
|
@@ -1,11 +0,0 @@
|
|
|
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>;
|
package/dist/src/sync.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as auth from '@atproto/auth';
|
|
2
|
-
import { IpldStore } from './blockstore';
|
|
3
|
-
import { DataDiff } from './mst';
|
|
4
|
-
import Repo from './repo';
|
|
5
|
-
export declare const loadRepoFromCar: (carBytes: Uint8Array, blockstore: IpldStore, verifier: auth.Verifier) => Promise<Repo>;
|
|
6
|
-
export declare const loadDiff: (repo: Repo, diffCar: Uint8Array, verifier: auth.Verifier) => Promise<{
|
|
7
|
-
repo: Repo;
|
|
8
|
-
diff: DataDiff;
|
|
9
|
-
}>;
|