@atproto/repo 0.9.0 → 0.10.0-next.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/CHANGELOG.md +34 -0
- package/dist/block-map.js +10 -19
- package/dist/block-map.js.map +1 -1
- package/dist/car.d.ts +2 -2
- package/dist/car.d.ts.map +1 -1
- package/dist/car.js +30 -104
- package/dist/car.js.map +1 -1
- package/dist/cid-set.js +4 -14
- package/dist/cid-set.js.map +1 -1
- package/dist/data-diff.d.ts +3 -3
- package/dist/data-diff.d.ts.map +1 -1
- package/dist/data-diff.js +11 -45
- package/dist/data-diff.js.map +1 -1
- package/dist/error.js +11 -53
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -27
- package/dist/index.js.map +1 -1
- package/dist/logger.js +3 -6
- package/dist/logger.js.map +1 -1
- package/dist/mst/diff.d.ts +2 -2
- package/dist/mst/diff.d.ts.map +1 -1
- package/dist/mst/diff.js +9 -14
- package/dist/mst/diff.js.map +1 -1
- package/dist/mst/index.d.ts +4 -4
- package/dist/mst/index.d.ts.map +1 -1
- package/dist/mst/index.js +4 -43
- package/dist/mst/index.js.map +1 -1
- package/dist/mst/mst.d.ts +14 -14
- package/dist/mst/mst.d.ts.map +1 -1
- package/dist/mst/mst.js +41 -118
- package/dist/mst/mst.js.map +1 -1
- package/dist/mst/util.d.ts +2 -2
- package/dist/mst/util.d.ts.map +1 -1
- package/dist/mst/util.js +29 -47
- package/dist/mst/util.js.map +1 -1
- package/dist/mst/walker.d.ts +1 -1
- package/dist/mst/walker.d.ts.map +1 -1
- package/dist/mst/walker.js +3 -23
- package/dist/mst/walker.js.map +1 -1
- package/dist/parse.d.ts +1 -1
- package/dist/parse.d.ts.map +1 -1
- package/dist/parse.js +12 -18
- package/dist/parse.js.map +1 -1
- package/dist/readable-repo.d.ts +3 -3
- package/dist/readable-repo.d.ts.map +1 -1
- package/dist/readable-repo.js +13 -77
- package/dist/readable-repo.js.map +1 -1
- package/dist/repo.d.ts +6 -6
- package/dist/repo.d.ts.map +1 -1
- package/dist/repo.js +31 -77
- package/dist/repo.js.map +1 -1
- package/dist/storage/index.d.ts +4 -4
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +4 -20
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/memory-blockstore.d.ts +4 -4
- package/dist/storage/memory-blockstore.d.ts.map +1 -1
- package/dist/storage/memory-blockstore.js +7 -27
- package/dist/storage/memory-blockstore.js.map +1 -1
- package/dist/storage/readable-blockstore.d.ts +1 -1
- package/dist/storage/readable-blockstore.d.ts.map +1 -1
- package/dist/storage/readable-blockstore.js +9 -13
- package/dist/storage/readable-blockstore.js.map +1 -1
- package/dist/storage/sync-storage.d.ts +2 -2
- package/dist/storage/sync-storage.d.ts.map +1 -1
- package/dist/storage/sync-storage.js +5 -19
- package/dist/storage/sync-storage.js.map +1 -1
- package/dist/storage/types.d.ts +2 -2
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/types.js +1 -5
- package/dist/storage/types.js.map +1 -1
- package/dist/sync/consumer.d.ts +3 -3
- package/dist/sync/consumer.d.ts.map +1 -1
- package/dist/sync/consumer.js +32 -75
- package/dist/sync/consumer.js.map +1 -1
- package/dist/sync/index.d.ts +2 -2
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +2 -18
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/provider.d.ts +2 -2
- package/dist/sync/provider.d.ts.map +1 -1
- package/dist/sync/provider.js +17 -55
- package/dist/sync/provider.js.map +1 -1
- package/dist/types.d.ts +39 -39
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +41 -44
- package/dist/types.js.map +1 -1
- package/dist/util.d.ts +2 -2
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +28 -75
- package/dist/util.js.map +1 -1
- package/jest.config.cjs +17 -0
- package/package.json +19 -14
- package/src/car.ts +5 -4
- package/src/data-diff.ts +3 -3
- package/src/index.ts +11 -11
- package/src/mst/diff.ts +3 -3
- package/src/mst/index.ts +4 -4
- package/src/mst/mst.ts +7 -7
- package/src/mst/util.ts +3 -3
- package/src/mst/walker.ts +1 -1
- package/src/parse.ts +3 -3
- package/src/readable-repo.ts +7 -7
- package/src/repo.ts +9 -9
- package/src/storage/index.ts +4 -4
- package/src/storage/memory-blockstore.ts +4 -4
- package/src/storage/readable-blockstore.ts +4 -4
- package/src/storage/sync-storage.ts +2 -2
- package/src/storage/types.ts +2 -2
- package/src/sync/consumer.ts +12 -8
- package/src/sync/index.ts +2 -2
- package/src/sync/provider.ts +7 -7
- package/src/types.ts +7 -7
- package/src/util.ts +2 -2
- package/tests/_util.ts +4 -4
- package/tests/car.test.ts +2 -2
- package/tests/commit-data.test.ts +7 -2
- package/tests/commit-proofs.test.ts +4 -4
- package/tests/covering-proofs.test.ts +4 -4
- package/tests/mst.test.ts +5 -5
- package/tests/proofs.test.ts +4 -4
- package/tests/repo.test.ts +4 -4
- package/tests/sync.test.ts +4 -4
- package/tsconfig.build.tsbuildinfo +1 -1
- package/jest.config.js +0 -7
package/src/types.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
import { Cid, LexMap, ifCid } from '@atproto/lex-data'
|
|
3
3
|
import { NsidString, RecordKeyString } from '@atproto/syntax'
|
|
4
|
-
import { BlockMap } from './block-map'
|
|
5
|
-
import { CidSet } from './cid-set'
|
|
4
|
+
import { BlockMap } from './block-map.js'
|
|
5
|
+
import { CidSet } from './cid-set.js'
|
|
6
6
|
|
|
7
7
|
// Repo nodes
|
|
8
8
|
// ---------------
|
|
@@ -18,7 +18,7 @@ const cidSchema = z.unknown().transform((input, ctx): Cid => {
|
|
|
18
18
|
return z.NEVER
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const _unsignedCommit = z.object({
|
|
22
22
|
did: z.string(),
|
|
23
23
|
version: z.literal(3),
|
|
24
24
|
data: cidSchema,
|
|
@@ -26,7 +26,7 @@ const unsignedCommit = z.object({
|
|
|
26
26
|
// `prev` added for backwards compatibility with v2, no requirement of keeping around history
|
|
27
27
|
prev: cidSchema.nullable(),
|
|
28
28
|
})
|
|
29
|
-
export type UnsignedCommit = z.infer<typeof
|
|
29
|
+
export type UnsignedCommit = z.infer<typeof _unsignedCommit> & { sig?: never }
|
|
30
30
|
|
|
31
31
|
const commit = z.object({
|
|
32
32
|
did: z.string(),
|
|
@@ -34,7 +34,7 @@ const commit = z.object({
|
|
|
34
34
|
data: cidSchema,
|
|
35
35
|
rev: z.string(),
|
|
36
36
|
prev: cidSchema.nullable(),
|
|
37
|
-
sig: z.instanceof(Uint8Array),
|
|
37
|
+
sig: z.instanceof(Uint8Array<ArrayBufferLike>),
|
|
38
38
|
})
|
|
39
39
|
export type Commit = z.infer<typeof commit>
|
|
40
40
|
|
|
@@ -44,7 +44,7 @@ const legacyV2Commit = z.object({
|
|
|
44
44
|
data: cidSchema,
|
|
45
45
|
rev: z.string().optional(),
|
|
46
46
|
prev: cidSchema.nullable(),
|
|
47
|
-
sig: z.instanceof(Uint8Array),
|
|
47
|
+
sig: z.instanceof(Uint8Array<ArrayBufferLike>),
|
|
48
48
|
})
|
|
49
49
|
export type LegacyV2Commit = z.infer<typeof legacyV2Commit>
|
|
50
50
|
|
|
@@ -60,7 +60,7 @@ export const schema = {
|
|
|
60
60
|
version: z.literal(1),
|
|
61
61
|
roots: z.array(cidSchema),
|
|
62
62
|
}),
|
|
63
|
-
bytes: z.instanceof(Uint8Array),
|
|
63
|
+
bytes: z.instanceof(Uint8Array<ArrayBufferLike>),
|
|
64
64
|
string: z.string(),
|
|
65
65
|
array: z.array(z.unknown()),
|
|
66
66
|
map: z.record(z.string(), z.unknown()),
|
package/src/util.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as crypto from '@atproto/crypto'
|
|
|
3
3
|
import { Keypair } from '@atproto/crypto'
|
|
4
4
|
import * as cbor from '@atproto/lex-cbor'
|
|
5
5
|
import { Cid, LexMap, LexValue, isPlainObject } from '@atproto/lex-data'
|
|
6
|
-
import { DataDiff } from './data-diff'
|
|
6
|
+
import { DataDiff } from './data-diff.js'
|
|
7
7
|
import {
|
|
8
8
|
Commit,
|
|
9
9
|
LegacyV2Commit,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
RecordWriteDescript,
|
|
15
15
|
UnsignedCommit,
|
|
16
16
|
WriteOpAction,
|
|
17
|
-
} from './types'
|
|
17
|
+
} from './types.js'
|
|
18
18
|
|
|
19
19
|
export const diffToWriteDescripts = (
|
|
20
20
|
diff: DataDiff,
|
package/tests/_util.ts
CHANGED
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
RecordWriteOp,
|
|
16
16
|
RepoContents,
|
|
17
17
|
WriteOpAction,
|
|
18
|
-
} from '../src'
|
|
19
|
-
import { MST } from '../src/mst'
|
|
20
|
-
import { Repo } from '../src/repo'
|
|
21
|
-
import { RepoStorage } from '../src/storage'
|
|
18
|
+
} from '../src/index.js'
|
|
19
|
+
import { MST } from '../src/mst/index.js'
|
|
20
|
+
import { Repo } from '../src/repo.js'
|
|
21
|
+
import { RepoStorage } from '../src/storage/index.js'
|
|
22
22
|
|
|
23
23
|
type IdMapping = Record<string, Cid>
|
|
24
24
|
|
package/tests/car.test.ts
CHANGED
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
parseCid,
|
|
9
9
|
toBase64,
|
|
10
10
|
} from '@atproto/lex-data'
|
|
11
|
-
import { CarBlock, readCarStream, writeCarStream } from '../src'
|
|
12
|
-
import fixtures from './car-file-fixtures.json'
|
|
11
|
+
import { CarBlock, readCarStream, writeCarStream } from '../src/index.js'
|
|
12
|
+
import fixtures from './car-file-fixtures.json' with { type: 'json' }
|
|
13
13
|
|
|
14
14
|
async function dataToCborBlock(data: LexValue): Promise<{
|
|
15
15
|
cid: Cid
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Secp256k1Keypair } from '@atproto/crypto'
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
Repo,
|
|
4
|
+
WriteOpAction,
|
|
5
|
+
blocksToCarFile,
|
|
6
|
+
verifyProofs,
|
|
7
|
+
} from '../src/index.js'
|
|
8
|
+
import { MemoryBlockstore } from '../src/storage/index.js'
|
|
4
9
|
|
|
5
10
|
describe('Commit data', () => {
|
|
6
11
|
// @NOTE this test uses a fully deterministic tree structure
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { parseCid } from '@atproto/lex-data'
|
|
2
|
-
import { BlockMap } from '../src'
|
|
3
|
-
import { MST } from '../src/mst'
|
|
4
|
-
import { MemoryBlockstore } from '../src/storage'
|
|
5
|
-
import fixtures from './commit-proof-fixtures.json'
|
|
2
|
+
import { BlockMap } from '../src/index.js'
|
|
3
|
+
import { MST } from '../src/mst/index.js'
|
|
4
|
+
import { MemoryBlockstore } from '../src/storage/index.js'
|
|
5
|
+
import fixtures from './commit-proof-fixtures.json' with { type: 'json' }
|
|
6
6
|
|
|
7
7
|
describe('commit proofs', () => {
|
|
8
8
|
for (const fixture of fixtures) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { parseCid } from '@atproto/lex-data'
|
|
2
|
-
import { BlockMap } from '../src'
|
|
3
|
-
import { MST } from '../src/mst'
|
|
4
|
-
import { MemoryBlockstore } from '../src/storage'
|
|
5
|
-
import * as k from './_keys'
|
|
2
|
+
import { BlockMap } from '../src/index.js'
|
|
3
|
+
import { MST } from '../src/mst/index.js'
|
|
4
|
+
import { MemoryBlockstore } from '../src/storage/index.js'
|
|
5
|
+
import * as k from './_keys.js'
|
|
6
6
|
|
|
7
7
|
// @NOTE these tests are the exact same as the tests in commit-proof-fixtures.json but in code from
|
|
8
8
|
// kept around currently because they are a bit easier to understand/work with
|
package/tests/mst.test.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import assert from 'node:assert'
|
|
2
2
|
import { Cid, parseCid } from '@atproto/lex-data'
|
|
3
|
-
import { DataAdd, DataDelete, DataDiff, DataUpdate } from '../src/data-diff'
|
|
4
|
-
import { MST } from '../src/mst'
|
|
5
|
-
import { InvalidMstKeyError, countPrefixLen } from '../src/mst/util'
|
|
6
|
-
import { MemoryBlockstore } from '../src/storage'
|
|
7
|
-
import * as util from './_util'
|
|
3
|
+
import { DataAdd, DataDelete, DataDiff, DataUpdate } from '../src/data-diff.js'
|
|
4
|
+
import { MST } from '../src/mst/index.js'
|
|
5
|
+
import { InvalidMstKeyError, countPrefixLen } from '../src/mst/util.js'
|
|
6
|
+
import { MemoryBlockstore } from '../src/storage/index.js'
|
|
7
|
+
import * as util from './_util.js'
|
|
8
8
|
|
|
9
9
|
describe('Merkle Search Tree', () => {
|
|
10
10
|
let blockstore: MemoryBlockstore
|
package/tests/proofs.test.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { TID } from '@atproto/common-web'
|
|
|
2
2
|
import * as crypto from '@atproto/crypto'
|
|
3
3
|
import { cidForLex } from '@atproto/lex-cbor'
|
|
4
4
|
import { NsidString } from '@atproto/syntax'
|
|
5
|
-
import { RecordCidClaim, RecordPath, Repo, RepoContents } from '../src'
|
|
6
|
-
import { MemoryBlockstore } from '../src/storage'
|
|
7
|
-
import * as sync from '../src/sync'
|
|
8
|
-
import * as util from './_util'
|
|
5
|
+
import { RecordCidClaim, RecordPath, Repo, RepoContents } from '../src/index.js'
|
|
6
|
+
import { MemoryBlockstore } from '../src/storage/index.js'
|
|
7
|
+
import * as sync from '../src/sync/index.js'
|
|
8
|
+
import * as util from './_util.js'
|
|
9
9
|
|
|
10
10
|
describe('Repo Proofs', () => {
|
|
11
11
|
let storage: MemoryBlockstore
|
package/tests/repo.test.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TID } from '@atproto/common-web'
|
|
2
2
|
import * as crypto from '@atproto/crypto'
|
|
3
3
|
import { Secp256k1Keypair } from '@atproto/crypto'
|
|
4
|
-
import { RepoContents, WriteOpAction, verifyCommitSig } from '../src'
|
|
5
|
-
import { Repo } from '../src/repo'
|
|
6
|
-
import { MemoryBlockstore } from '../src/storage'
|
|
7
|
-
import * as util from './_util'
|
|
4
|
+
import { RepoContents, WriteOpAction, verifyCommitSig } from '../src/index.js'
|
|
5
|
+
import { Repo } from '../src/repo.js'
|
|
6
|
+
import { MemoryBlockstore } from '../src/storage/index.js'
|
|
7
|
+
import * as util from './_util.js'
|
|
8
8
|
|
|
9
9
|
describe('Repo', () => {
|
|
10
10
|
const collName = 'com.example.posts'
|
package/tests/sync.test.ts
CHANGED
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
getAndParseRecord,
|
|
8
8
|
readCar,
|
|
9
9
|
readCarWithRoot,
|
|
10
|
-
} from '../src'
|
|
11
|
-
import { MemoryBlockstore } from '../src/storage'
|
|
12
|
-
import * as sync from '../src/sync'
|
|
13
|
-
import * as util from './_util'
|
|
10
|
+
} from '../src/index.js'
|
|
11
|
+
import { MemoryBlockstore } from '../src/storage/index.js'
|
|
12
|
+
import * as sync from '../src/sync/index.js'
|
|
13
|
+
import * as util from './_util.js'
|
|
14
14
|
|
|
15
15
|
describe('Repo Sync', () => {
|
|
16
16
|
let storage: MemoryBlockstore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/block-map.ts","./src/car.ts","./src/cid-set.ts","./src/data-diff.ts","./src/error.ts","./src/index.ts","./src/logger.ts","./src/parse.ts","./src/readable-repo.ts","./src/repo.ts","./src/types.ts","./src/util.ts","./src/mst/diff.ts","./src/mst/index.ts","./src/mst/mst.ts","./src/mst/util.ts","./src/mst/walker.ts","./src/storage/index.ts","./src/storage/memory-blockstore.ts","./src/storage/readable-blockstore.ts","./src/storage/sync-storage.ts","./src/storage/types.ts","./src/sync/consumer.ts","./src/sync/index.ts","./src/sync/provider.ts"],"version":"
|
|
1
|
+
{"root":["./src/block-map.ts","./src/car.ts","./src/cid-set.ts","./src/data-diff.ts","./src/error.ts","./src/index.ts","./src/logger.ts","./src/parse.ts","./src/readable-repo.ts","./src/repo.ts","./src/types.ts","./src/util.ts","./src/mst/diff.ts","./src/mst/index.ts","./src/mst/mst.ts","./src/mst/util.ts","./src/mst/walker.ts","./src/storage/index.ts","./src/storage/memory-blockstore.ts","./src/storage/readable-blockstore.ts","./src/storage/sync-storage.ts","./src/storage/types.ts","./src/sync/consumer.ts","./src/sync/index.ts","./src/sync/provider.ts"],"version":"6.0.3"}
|
package/jest.config.js
DELETED