@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.
Files changed (127) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/block-map.js +10 -19
  3. package/dist/block-map.js.map +1 -1
  4. package/dist/car.d.ts +2 -2
  5. package/dist/car.d.ts.map +1 -1
  6. package/dist/car.js +30 -104
  7. package/dist/car.js.map +1 -1
  8. package/dist/cid-set.js +4 -14
  9. package/dist/cid-set.js.map +1 -1
  10. package/dist/data-diff.d.ts +3 -3
  11. package/dist/data-diff.d.ts.map +1 -1
  12. package/dist/data-diff.js +11 -45
  13. package/dist/data-diff.js.map +1 -1
  14. package/dist/error.js +11 -53
  15. package/dist/error.js.map +1 -1
  16. package/dist/index.d.ts +11 -11
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +11 -27
  19. package/dist/index.js.map +1 -1
  20. package/dist/logger.js +3 -6
  21. package/dist/logger.js.map +1 -1
  22. package/dist/mst/diff.d.ts +2 -2
  23. package/dist/mst/diff.d.ts.map +1 -1
  24. package/dist/mst/diff.js +9 -14
  25. package/dist/mst/diff.js.map +1 -1
  26. package/dist/mst/index.d.ts +4 -4
  27. package/dist/mst/index.d.ts.map +1 -1
  28. package/dist/mst/index.js +4 -43
  29. package/dist/mst/index.js.map +1 -1
  30. package/dist/mst/mst.d.ts +14 -14
  31. package/dist/mst/mst.d.ts.map +1 -1
  32. package/dist/mst/mst.js +41 -118
  33. package/dist/mst/mst.js.map +1 -1
  34. package/dist/mst/util.d.ts +2 -2
  35. package/dist/mst/util.d.ts.map +1 -1
  36. package/dist/mst/util.js +29 -47
  37. package/dist/mst/util.js.map +1 -1
  38. package/dist/mst/walker.d.ts +1 -1
  39. package/dist/mst/walker.d.ts.map +1 -1
  40. package/dist/mst/walker.js +3 -23
  41. package/dist/mst/walker.js.map +1 -1
  42. package/dist/parse.d.ts +1 -1
  43. package/dist/parse.d.ts.map +1 -1
  44. package/dist/parse.js +12 -18
  45. package/dist/parse.js.map +1 -1
  46. package/dist/readable-repo.d.ts +3 -3
  47. package/dist/readable-repo.d.ts.map +1 -1
  48. package/dist/readable-repo.js +13 -77
  49. package/dist/readable-repo.js.map +1 -1
  50. package/dist/repo.d.ts +6 -6
  51. package/dist/repo.d.ts.map +1 -1
  52. package/dist/repo.js +31 -77
  53. package/dist/repo.js.map +1 -1
  54. package/dist/storage/index.d.ts +4 -4
  55. package/dist/storage/index.d.ts.map +1 -1
  56. package/dist/storage/index.js +4 -20
  57. package/dist/storage/index.js.map +1 -1
  58. package/dist/storage/memory-blockstore.d.ts +4 -4
  59. package/dist/storage/memory-blockstore.d.ts.map +1 -1
  60. package/dist/storage/memory-blockstore.js +7 -27
  61. package/dist/storage/memory-blockstore.js.map +1 -1
  62. package/dist/storage/readable-blockstore.d.ts +1 -1
  63. package/dist/storage/readable-blockstore.d.ts.map +1 -1
  64. package/dist/storage/readable-blockstore.js +9 -13
  65. package/dist/storage/readable-blockstore.js.map +1 -1
  66. package/dist/storage/sync-storage.d.ts +2 -2
  67. package/dist/storage/sync-storage.d.ts.map +1 -1
  68. package/dist/storage/sync-storage.js +5 -19
  69. package/dist/storage/sync-storage.js.map +1 -1
  70. package/dist/storage/types.d.ts +2 -2
  71. package/dist/storage/types.d.ts.map +1 -1
  72. package/dist/storage/types.js +1 -5
  73. package/dist/storage/types.js.map +1 -1
  74. package/dist/sync/consumer.d.ts +3 -3
  75. package/dist/sync/consumer.d.ts.map +1 -1
  76. package/dist/sync/consumer.js +32 -75
  77. package/dist/sync/consumer.js.map +1 -1
  78. package/dist/sync/index.d.ts +2 -2
  79. package/dist/sync/index.d.ts.map +1 -1
  80. package/dist/sync/index.js +2 -18
  81. package/dist/sync/index.js.map +1 -1
  82. package/dist/sync/provider.d.ts +2 -2
  83. package/dist/sync/provider.d.ts.map +1 -1
  84. package/dist/sync/provider.js +17 -55
  85. package/dist/sync/provider.js.map +1 -1
  86. package/dist/types.d.ts +39 -39
  87. package/dist/types.d.ts.map +1 -1
  88. package/dist/types.js +41 -44
  89. package/dist/types.js.map +1 -1
  90. package/dist/util.d.ts +2 -2
  91. package/dist/util.d.ts.map +1 -1
  92. package/dist/util.js +28 -75
  93. package/dist/util.js.map +1 -1
  94. package/jest.config.cjs +17 -0
  95. package/package.json +19 -14
  96. package/src/car.ts +5 -4
  97. package/src/data-diff.ts +3 -3
  98. package/src/index.ts +11 -11
  99. package/src/mst/diff.ts +3 -3
  100. package/src/mst/index.ts +4 -4
  101. package/src/mst/mst.ts +7 -7
  102. package/src/mst/util.ts +3 -3
  103. package/src/mst/walker.ts +1 -1
  104. package/src/parse.ts +3 -3
  105. package/src/readable-repo.ts +7 -7
  106. package/src/repo.ts +9 -9
  107. package/src/storage/index.ts +4 -4
  108. package/src/storage/memory-blockstore.ts +4 -4
  109. package/src/storage/readable-blockstore.ts +4 -4
  110. package/src/storage/sync-storage.ts +2 -2
  111. package/src/storage/types.ts +2 -2
  112. package/src/sync/consumer.ts +12 -8
  113. package/src/sync/index.ts +2 -2
  114. package/src/sync/provider.ts +7 -7
  115. package/src/types.ts +7 -7
  116. package/src/util.ts +2 -2
  117. package/tests/_util.ts +4 -4
  118. package/tests/car.test.ts +2 -2
  119. package/tests/commit-data.test.ts +7 -2
  120. package/tests/commit-proofs.test.ts +4 -4
  121. package/tests/covering-proofs.test.ts +4 -4
  122. package/tests/mst.test.ts +5 -5
  123. package/tests/proofs.test.ts +4 -4
  124. package/tests/repo.test.ts +4 -4
  125. package/tests/sync.test.ts +4 -4
  126. package/tsconfig.build.tsbuildinfo +1 -1
  127. 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 unsignedCommit = z.object({
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 unsignedCommit> & { sig?: never }
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 { Repo, WriteOpAction, blocksToCarFile, verifyProofs } from '../src'
3
- import { MemoryBlockstore } from '../src/storage'
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
@@ -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
@@ -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'
@@ -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":"5.8.2"}
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
@@ -1,7 +0,0 @@
1
- /** @type {import('jest').Config} */
2
- module.exports = {
3
- displayName: 'Repo',
4
- transform: { '^.+\\.(t|j)s$': '@swc/jest' },
5
- setupFiles: ['<rootDir>/../../jest.setup.ts'],
6
- moduleNameMapper: { '^(\\.\\.?\\/.+)\\.js$': ['$1.ts', '$1.js'] },
7
- }