@atproto/repo 0.3.9-next.0 → 0.3.9

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 (109) hide show
  1. package/CHANGELOG.md +8 -8
  2. package/babel.config.js +1 -0
  3. package/build.js +14 -0
  4. package/dist/block-map.d.ts +0 -1
  5. package/dist/cid-set.d.ts +0 -1
  6. package/dist/data-diff.d.ts +0 -1
  7. package/dist/error.d.ts +0 -1
  8. package/dist/index.d.ts +0 -1
  9. package/dist/index.js +27225 -26
  10. package/dist/index.js.map +7 -1
  11. package/dist/logger.d.ts +0 -1
  12. package/dist/mst/diff.d.ts +0 -1
  13. package/dist/mst/index.d.ts +0 -1
  14. package/dist/mst/mst.d.ts +5 -6
  15. package/dist/mst/util.d.ts +0 -1
  16. package/dist/mst/walker.d.ts +0 -1
  17. package/dist/parse.d.ts +0 -1
  18. package/dist/readable-repo.d.ts +0 -1
  19. package/dist/repo.d.ts +0 -1
  20. package/dist/storage/index.d.ts +0 -1
  21. package/dist/storage/memory-blockstore.d.ts +0 -1
  22. package/dist/storage/readable-blockstore.d.ts +0 -1
  23. package/dist/storage/sync-storage.d.ts +0 -1
  24. package/dist/storage/types.d.ts +0 -1
  25. package/dist/sync/consumer.d.ts +0 -1
  26. package/dist/sync/index.d.ts +0 -1
  27. package/dist/sync/provider.d.ts +0 -1
  28. package/dist/types.d.ts +19 -22
  29. package/dist/util.d.ts +1 -2
  30. package/jest.bench.config.js +8 -0
  31. package/jest.config.js +3 -3
  32. package/package.json +14 -11
  33. package/src/mst/mst.ts +1 -1
  34. package/src/types.ts +2 -4
  35. package/src/util.ts +1 -1
  36. package/tests/_util.ts +0 -4
  37. package/tsconfig.build.json +2 -6
  38. package/tsconfig.json +11 -3
  39. package/dist/block-map.d.ts.map +0 -1
  40. package/dist/block-map.js +0 -119
  41. package/dist/block-map.js.map +0 -1
  42. package/dist/cid-set.d.ts.map +0 -1
  43. package/dist/cid-set.js +0 -48
  44. package/dist/cid-set.js.map +0 -1
  45. package/dist/data-diff.d.ts.map +0 -1
  46. package/dist/data-diff.js +0 -134
  47. package/dist/data-diff.js.map +0 -1
  48. package/dist/error.d.ts.map +0 -1
  49. package/dist/error.js +0 -76
  50. package/dist/error.js.map +0 -1
  51. package/dist/index.d.ts.map +0 -1
  52. package/dist/logger.d.ts.map +0 -1
  53. package/dist/logger.js +0 -7
  54. package/dist/logger.js.map +0 -1
  55. package/dist/mst/diff.d.ts.map +0 -1
  56. package/dist/mst/diff.js +0 -120
  57. package/dist/mst/diff.js.map +0 -1
  58. package/dist/mst/index.d.ts.map +0 -1
  59. package/dist/mst/index.js +0 -34
  60. package/dist/mst/index.js.map +0 -1
  61. package/dist/mst/mst.d.ts.map +0 -1
  62. package/dist/mst/mst.js +0 -770
  63. package/dist/mst/mst.js.map +0 -1
  64. package/dist/mst/util.d.ts.map +0 -1
  65. package/dist/mst/util.js +0 -167
  66. package/dist/mst/util.js.map +0 -1
  67. package/dist/mst/walker.d.ts.map +0 -1
  68. package/dist/mst/walker.js +0 -123
  69. package/dist/mst/walker.js.map +0 -1
  70. package/dist/parse.d.ts.map +0 -1
  71. package/dist/parse.js +0 -35
  72. package/dist/parse.js.map +0 -1
  73. package/dist/readable-repo.d.ts.map +0 -1
  74. package/dist/readable-repo.js +0 -117
  75. package/dist/readable-repo.js.map +0 -1
  76. package/dist/repo.d.ts.map +0 -1
  77. package/dist/repo.js +0 -190
  78. package/dist/repo.js.map +0 -1
  79. package/dist/storage/index.d.ts.map +0 -1
  80. package/dist/storage/index.js +0 -21
  81. package/dist/storage/index.js.map +0 -1
  82. package/dist/storage/memory-blockstore.d.ts.map +0 -1
  83. package/dist/storage/memory-blockstore.js +0 -80
  84. package/dist/storage/memory-blockstore.js.map +0 -1
  85. package/dist/storage/readable-blockstore.d.ts.map +0 -1
  86. package/dist/storage/readable-blockstore.js +0 -66
  87. package/dist/storage/readable-blockstore.js.map +0 -1
  88. package/dist/storage/sync-storage.d.ts.map +0 -1
  89. package/dist/storage/sync-storage.js +0 -46
  90. package/dist/storage/sync-storage.js.map +0 -1
  91. package/dist/storage/types.d.ts.map +0 -1
  92. package/dist/storage/types.js +0 -7
  93. package/dist/storage/types.js.map +0 -1
  94. package/dist/sync/consumer.d.ts.map +0 -1
  95. package/dist/sync/consumer.js +0 -178
  96. package/dist/sync/consumer.js.map +0 -1
  97. package/dist/sync/index.d.ts.map +0 -1
  98. package/dist/sync/index.js +0 -19
  99. package/dist/sync/index.js.map +0 -1
  100. package/dist/sync/provider.d.ts.map +0 -1
  101. package/dist/sync/provider.js +0 -67
  102. package/dist/sync/provider.js.map +0 -1
  103. package/dist/types.d.ts.map +0 -1
  104. package/dist/types.js +0 -62
  105. package/dist/types.js.map +0 -1
  106. package/dist/util.d.ts.map +0 -1
  107. package/dist/util.js +0 -219
  108. package/dist/util.js.map +0 -1
  109. package/tsconfig.tests.json +0 -7
package/dist/logger.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import { subsystemLogger } from '@atproto/common';
2
2
  export declare const logger: ReturnType<typeof subsystemLogger>;
3
3
  export default logger;
4
- //# sourceMappingURL=logger.d.ts.map
@@ -2,4 +2,3 @@ import { DataDiff } from '../data-diff';
2
2
  import MST from './mst';
3
3
  export declare const nullDiff: (tree: MST) => Promise<DataDiff>;
4
4
  export declare const mstDiff: (curr: MST, prev: MST | null) => Promise<DataDiff>;
5
- //# sourceMappingURL=diff.d.ts.map
@@ -2,4 +2,3 @@ export * from './mst';
2
2
  export * from './diff';
3
3
  export * from './walker';
4
4
  export * as mstUtil from './util';
5
- //# sourceMappingURL=index.d.ts.map
package/dist/mst/mst.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import z from 'zod';
2
2
  import { CID } from 'multiformats';
3
3
  import { ReadableBlockstore } from '../storage';
4
- import { BlockWriter } from '@ipld/car/writer';
4
+ import { BlockWriter } from '@ipld/car/api';
5
5
  import BlockMap from '../block-map';
6
6
  import CidSet from '../cid-set';
7
7
  declare const nodeData: z.ZodObject<{
@@ -12,10 +12,10 @@ declare const nodeData: z.ZodObject<{
12
12
  v: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
13
13
  t: z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>>;
14
14
  }, "strip", z.ZodTypeAny, {
15
+ t: CID | null;
15
16
  p: number;
16
17
  k: Uint8Array;
17
18
  v: CID;
18
- t: CID | null;
19
19
  }, {
20
20
  p: number;
21
21
  k: Uint8Array;
@@ -25,10 +25,10 @@ declare const nodeData: z.ZodObject<{
25
25
  }, "strip", z.ZodTypeAny, {
26
26
  l: CID | null;
27
27
  e: {
28
+ t: CID | null;
28
29
  p: number;
29
30
  k: Uint8Array;
30
31
  v: CID;
31
- t: CID | null;
32
32
  }[];
33
33
  }, {
34
34
  e: {
@@ -50,10 +50,10 @@ export declare const nodeDataDef: {
50
50
  v: z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>;
51
51
  t: z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>>;
52
52
  }, "strip", z.ZodTypeAny, {
53
+ t: CID | null;
53
54
  p: number;
54
55
  k: Uint8Array;
55
56
  v: CID;
56
- t: CID | null;
57
57
  }, {
58
58
  p: number;
59
59
  k: Uint8Array;
@@ -63,10 +63,10 @@ export declare const nodeDataDef: {
63
63
  }, "strip", z.ZodTypeAny, {
64
64
  l: CID | null;
65
65
  e: {
66
+ t: CID | null;
66
67
  p: number;
67
68
  k: Uint8Array;
68
69
  v: CID;
69
- t: CID | null;
70
70
  }[];
71
71
  }, {
72
72
  e: {
@@ -150,4 +150,3 @@ export declare class Leaf {
150
150
  equals(entry: NodeEntry): boolean;
151
151
  }
152
152
  export default MST;
153
- //# sourceMappingURL=mst.d.ts.map
@@ -15,4 +15,3 @@ export declare class InvalidMstKeyError extends Error {
15
15
  key: string;
16
16
  constructor(key: string);
17
17
  }
18
- //# sourceMappingURL=util.d.ts.map
@@ -20,4 +20,3 @@ export declare class MstWalker {
20
20
  advance(): Promise<void>;
21
21
  }
22
22
  export default MstWalker;
23
- //# sourceMappingURL=walker.d.ts.map
package/dist/parse.d.ts CHANGED
@@ -14,4 +14,3 @@ export declare const parseObjByDef: <T>(bytes: Uint8Array, cid: CID, def: check.
14
14
  obj: T;
15
15
  bytes: Uint8Array;
16
16
  };
17
- //# sourceMappingURL=parse.d.ts.map
@@ -28,4 +28,3 @@ export declare class ReadableRepo {
28
28
  getContents(): Promise<RepoContents>;
29
29
  }
30
30
  export default ReadableRepo;
31
- //# sourceMappingURL=readable-repo.d.ts.map
package/dist/repo.d.ts CHANGED
@@ -33,4 +33,3 @@ export declare class Repo extends ReadableRepo {
33
33
  resignCommit(rev: string, keypair: crypto.Keypair): Promise<Repo>;
34
34
  }
35
35
  export default Repo;
36
- //# sourceMappingURL=repo.d.ts.map
@@ -2,4 +2,3 @@ export * from './readable-blockstore';
2
2
  export * from './memory-blockstore';
3
3
  export * from './sync-storage';
4
4
  export * from './types';
5
- //# sourceMappingURL=index.d.ts.map
@@ -23,4 +23,3 @@ export declare class MemoryBlockstore extends ReadableBlockstore implements Repo
23
23
  destroy(): Promise<void>;
24
24
  }
25
25
  export default MemoryBlockstore;
26
- //# sourceMappingURL=memory-blockstore.d.ts.map
@@ -22,4 +22,3 @@ export declare abstract class ReadableBlockstore {
22
22
  readRecord(cid: CID): Promise<RepoRecord>;
23
23
  }
24
24
  export default ReadableBlockstore;
25
- //# sourceMappingURL=readable-blockstore.d.ts.map
@@ -13,4 +13,3 @@ export declare class SyncStorage extends ReadableBlockstore {
13
13
  has(cid: CID): Promise<boolean>;
14
14
  }
15
15
  export default SyncStorage;
16
- //# sourceMappingURL=sync-storage.d.ts.map
@@ -44,4 +44,3 @@ export interface BlobStore {
44
44
  }
45
45
  export declare class BlobNotFoundError extends Error {
46
46
  }
47
- //# sourceMappingURL=types.d.ts.map
@@ -19,4 +19,3 @@ export declare const verifyProofs: (proofs: Uint8Array, claims: RecordClaim[], d
19
19
  export declare const verifyRecords: (proofs: Uint8Array, did: string, signingKey: string) => Promise<RecordClaim[]>;
20
20
  export declare class RepoVerificationError extends Error {
21
21
  }
22
- //# sourceMappingURL=consumer.d.ts.map
@@ -1,3 +1,2 @@
1
1
  export * from './consumer';
2
2
  export * from './provider';
3
- //# sourceMappingURL=index.d.ts.map
@@ -3,4 +3,3 @@ import { CID } from 'multiformats/cid';
3
3
  import { ReadableBlockstore, RepoStorage } from '../storage';
4
4
  export declare const getFullRepo: (storage: RepoStorage, commitCid: CID) => AsyncIterable<Uint8Array>;
5
5
  export declare const getRecords: (storage: ReadableBlockstore, commitCid: CID, paths: RecordPath[]) => AsyncIterable<Uint8Array>;
6
- //# sourceMappingURL=provider.d.ts.map
package/dist/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { CID } from 'multiformats';
3
+ import * as car from '@ipld/car/api';
3
4
  import BlockMap from './block-map';
4
5
  import { RepoRecord } from '@atproto/lexicon';
5
6
  import CidSet from './cid-set';
@@ -11,8 +12,8 @@ declare const unsignedCommit: z.ZodObject<{
11
12
  prev: z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodAny, any, any>, CID, any>>;
12
13
  }, "strip", z.ZodTypeAny, {
13
14
  did: string;
14
- version: 3;
15
15
  data: CID;
16
+ version: 3;
16
17
  rev: string;
17
18
  prev: CID | null;
18
19
  }, {
@@ -34,8 +35,8 @@ declare const commit: z.ZodObject<{
34
35
  sig: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
35
36
  }, "strip", z.ZodTypeAny, {
36
37
  did: string;
37
- version: 3;
38
38
  data: CID;
39
+ version: 3;
39
40
  rev: string;
40
41
  prev: CID | null;
41
42
  sig: Uint8Array;
@@ -57,8 +58,8 @@ declare const legacyV2Commit: z.ZodObject<{
57
58
  sig: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
58
59
  }, "strip", z.ZodTypeAny, {
59
60
  did: string;
60
- version: 2;
61
61
  data: CID;
62
+ version: 2;
62
63
  prev: CID | null;
63
64
  sig: Uint8Array;
64
65
  rev?: string | undefined;
@@ -80,8 +81,8 @@ declare const versionedCommit: z.ZodDiscriminatedUnion<"version", [z.ZodObject<{
80
81
  sig: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
81
82
  }, "strip", z.ZodTypeAny, {
82
83
  did: string;
83
- version: 3;
84
84
  data: CID;
85
+ version: 3;
85
86
  rev: string;
86
87
  prev: CID | null;
87
88
  sig: Uint8Array;
@@ -101,8 +102,8 @@ declare const versionedCommit: z.ZodDiscriminatedUnion<"version", [z.ZodObject<{
101
102
  sig: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
102
103
  }, "strip", z.ZodTypeAny, {
103
104
  did: string;
104
- version: 2;
105
105
  data: CID;
106
+ version: 2;
106
107
  prev: CID | null;
107
108
  sig: Uint8Array;
108
109
  rev?: string | undefined;
@@ -125,8 +126,8 @@ export declare const schema: {
125
126
  sig: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
126
127
  }, "strip", z.ZodTypeAny, {
127
128
  did: string;
128
- version: 3;
129
129
  data: CID;
130
+ version: 3;
130
131
  rev: string;
131
132
  prev: CID | null;
132
133
  sig: Uint8Array;
@@ -147,8 +148,8 @@ export declare const schema: {
147
148
  sig: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
148
149
  }, "strip", z.ZodTypeAny, {
149
150
  did: string;
150
- version: 2;
151
151
  data: CID;
152
+ version: 2;
152
153
  prev: CID | null;
153
154
  sig: Uint8Array;
154
155
  rev?: string | undefined;
@@ -169,8 +170,8 @@ export declare const schema: {
169
170
  sig: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
170
171
  }, "strip", z.ZodTypeAny, {
171
172
  did: string;
172
- version: 3;
173
173
  data: CID;
174
+ version: 3;
174
175
  rev: string;
175
176
  prev: CID | null;
176
177
  sig: Uint8Array;
@@ -190,8 +191,8 @@ export declare const schema: {
190
191
  sig: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
191
192
  }, "strip", z.ZodTypeAny, {
192
193
  did: string;
193
- version: 2;
194
194
  data: CID;
195
+ version: 2;
195
196
  prev: CID | null;
196
197
  sig: Uint8Array;
197
198
  rev?: string | undefined;
@@ -222,8 +223,8 @@ export declare const def: {
222
223
  sig: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
223
224
  }, "strip", z.ZodTypeAny, {
224
225
  did: string;
225
- version: 3;
226
226
  data: CID;
227
+ version: 3;
227
228
  rev: string;
228
229
  prev: CID | null;
229
230
  sig: Uint8Array;
@@ -247,8 +248,8 @@ export declare const def: {
247
248
  sig: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
248
249
  }, "strip", z.ZodTypeAny, {
249
250
  did: string;
250
- version: 3;
251
251
  data: CID;
252
+ version: 3;
252
253
  rev: string;
253
254
  prev: CID | null;
254
255
  sig: Uint8Array;
@@ -268,8 +269,8 @@ export declare const def: {
268
269
  sig: z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>;
269
270
  }, "strip", z.ZodTypeAny, {
270
271
  did: string;
271
- version: 2;
272
272
  data: CID;
273
+ version: 2;
273
274
  prev: CID | null;
274
275
  sig: Uint8Array;
275
276
  rev?: string | undefined;
@@ -282,11 +283,11 @@ export declare const def: {
282
283
  prev?: any;
283
284
  }>]>;
284
285
  };
285
- cid: import("@atproto/common-web/dist/check").Def<CID>;
286
- bytes: import("@atproto/common-web/dist/check").Def<Uint8Array>;
287
- string: import("@atproto/common-web/dist/check").Def<string>;
288
- map: import("@atproto/common-web/dist/check").Def<Record<string, unknown>>;
289
- unknown: import("@atproto/common-web/dist/check").Def<unknown>;
286
+ cid: import("@atproto/common-web/src/check").Def<CID>;
287
+ bytes: import("@atproto/common-web/src/check").Def<Uint8Array>;
288
+ string: import("@atproto/common-web/src/check").Def<string>;
289
+ map: import("@atproto/common-web/src/check").Def<Record<string, unknown>>;
290
+ unknown: import("@atproto/common-web/src/check").Def<unknown>;
290
291
  };
291
292
  export declare enum WriteOpAction {
292
293
  Create = "create",
@@ -369,9 +370,5 @@ export type VerifiedRepo = {
369
370
  creates: RecordCreateDescript[];
370
371
  commit: CommitData;
371
372
  };
372
- export type CarBlock = {
373
- cid: CID;
374
- bytes: Uint8Array;
375
- };
373
+ export type CarBlock = car.Block;
376
374
  export {};
377
- //# sourceMappingURL=types.d.ts.map
package/dist/util.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { CID } from 'multiformats/cid';
3
- import { CarBlockIterator } from '@ipld/car/iterator';
3
+ import { CarBlockIterator } from '@ipld/car';
4
4
  import { BlockWriter } from '@ipld/car/writer';
5
5
  import { LexValue, RepoRecord } from '@atproto/lexicon';
6
6
  import DataDiff from './data-diff';
@@ -40,4 +40,3 @@ export declare const cborToLex: (val: Uint8Array) => LexValue;
40
40
  export declare const cborToLexRecord: (val: Uint8Array) => RepoRecord;
41
41
  export declare const cidForRecord: (val: LexValue) => Promise<CID>;
42
42
  export declare const ensureV3Commit: (commit: LegacyV2Commit | Commit) => Commit;
43
- //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1,8 @@
1
+ const base = require('./jest.config')
2
+
3
+ module.exports = {
4
+ ...base,
5
+ roots: ['<rootDir>/bench'],
6
+ testRegex: '(.*.bench)',
7
+ testTimeout: 3000000,
8
+ }
package/jest.config.js CHANGED
@@ -1,6 +1,6 @@
1
- /** @type {import('jest').Config} */
1
+ const base = require('../../jest.config.base.js')
2
+
2
3
  module.exports = {
4
+ ...base,
3
5
  displayName: 'Repo',
4
- transform: { '^.+\\.(t|j)s$': '@swc/jest' },
5
- setupFiles: ['<rootDir>/../../jest.setup.ts'],
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/repo",
3
- "version": "0.3.9-next.0",
3
+ "version": "0.3.9",
4
4
  "license": "MIT",
5
5
  "description": "atproto repo and MST implementation",
6
6
  "keywords": [
@@ -14,24 +14,27 @@
14
14
  "directory": "packages/repo"
15
15
  },
16
16
  "main": "dist/index.js",
17
- "types": "dist/index.d.ts",
18
17
  "dependencies": {
19
18
  "@ipld/car": "^3.2.3",
20
19
  "@ipld/dag-cbor": "^7.0.0",
21
20
  "multiformats": "^9.9.0",
22
21
  "uint8arrays": "3.0.0",
23
22
  "zod": "^3.21.4",
24
- "@atproto/common": "^0.3.4-next.0",
25
- "@atproto/crypto": "^0.3.1-next.0",
26
- "@atproto/lexicon": "^0.3.3-next.0",
27
- "@atproto/common-web": "^0.2.4-next.0"
28
- },
29
- "devDependencies": {
30
- "jest": "^28.1.2"
23
+ "@atproto/common": "^0.3.4",
24
+ "@atproto/common-web": "^0.2.4",
25
+ "@atproto/crypto": "^0.3.0",
26
+ "@atproto/identity": "^0.3.3",
27
+ "@atproto/lexicon": "^0.3.3",
28
+ "@atproto/syntax": "^0.2.1"
31
29
  },
32
30
  "scripts": {
33
31
  "test": "jest",
34
32
  "test:profile": "node --inspect ../../node_modules/.bin/jest",
35
- "build": "tsc --build tsconfig.build.json"
36
- }
33
+ "bench": "jest --config jest.bench.config.js",
34
+ "bench:profile": "node --inspect-brk ../../node_modules/.bin/jest --config jest.bench.config.js",
35
+ "build": "node ./build.js",
36
+ "postbuild": "tsc --build tsconfig.build.json",
37
+ "update-main-to-dist": "node ../../update-main-to-dist.js packages/repo"
38
+ },
39
+ "types": "dist/index.d.ts"
37
40
  }
package/src/mst/mst.ts CHANGED
@@ -3,7 +3,7 @@ import { CID } from 'multiformats'
3
3
 
4
4
  import { ReadableBlockstore } from '../storage'
5
5
  import { schema as common, cidForCbor, dataToCborBlock } from '@atproto/common'
6
- import { BlockWriter } from '@ipld/car/writer'
6
+ import { BlockWriter } from '@ipld/car/api'
7
7
  import * as util from './util'
8
8
  import BlockMap from '../block-map'
9
9
  import CidSet from '../cid-set'
package/src/types.ts CHANGED
@@ -2,6 +2,7 @@ import { z } from 'zod'
2
2
  import { def as commonDef } from '@atproto/common-web'
3
3
  import { schema as common } from '@atproto/common'
4
4
  import { CID } from 'multiformats'
5
+ import * as car from '@ipld/car/api'
5
6
  import BlockMap from './block-map'
6
7
  import { RepoRecord } from '@atproto/lexicon'
7
8
  import CidSet from './cid-set'
@@ -173,7 +174,4 @@ export type VerifiedRepo = {
173
174
  commit: CommitData
174
175
  }
175
176
 
176
- export type CarBlock = {
177
- cid: CID
178
- bytes: Uint8Array
179
- }
177
+ export type CarBlock = car.Block
package/src/util.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { setImmediate } from 'node:timers/promises'
2
2
  import { CID } from 'multiformats/cid'
3
3
  import * as cbor from '@ipld/dag-cbor'
4
- import { CarBlockIterator } from '@ipld/car/iterator'
4
+ import { CarBlockIterator } from '@ipld/car'
5
5
  import { BlockWriter, CarWriter } from '@ipld/car/writer'
6
6
  import {
7
7
  streamToBuffer,
package/tests/_util.ts CHANGED
@@ -24,7 +24,6 @@ type IdMapping = Record<string, CID>
24
24
  export const randomCid = async (storage?: RepoStorage): Promise<CID> => {
25
25
  const block = await dataToCborBlock({ test: randomStr(50) })
26
26
  if (storage) {
27
- // @ts-expect-error FIXME remove this comment (and fix the TS error)
28
27
  await storage.putBlock(block.cid, block.bytes)
29
28
  }
30
29
  return block.cid
@@ -190,7 +189,6 @@ export const pathsForOps = (ops: RecordWriteOp[]): RecordPath[] =>
190
189
 
191
190
  export const saveMst = async (storage: RepoStorage, mst: MST): Promise<CID> => {
192
191
  const diff = await mst.getUnstoredBlocks()
193
- // @ts-expect-error FIXME remove this comment (and fix the TS error)
194
192
  await storage.putMany(diff.blocks)
195
193
  return diff.root
196
194
  }
@@ -217,8 +215,6 @@ export const addBadCommit = async (
217
215
  sig: await keypair.sign(randomBytes(256)),
218
216
  }
219
217
  const commitCid = await newBlocks.add(commit)
220
-
221
- // @ts-expect-error FIXME remove this comment (and fix the TS error)
222
218
  await repo.storage.applyCommit({
223
219
  cid: commitCid,
224
220
  rev,
@@ -1,8 +1,4 @@
1
1
  {
2
- "extends": "../../tsconfig/node.json",
3
- "compilerOptions": {
4
- "rootDir": "./src",
5
- "outDir": "./dist"
6
- },
7
- "include": ["./src"]
2
+ "extends": "./tsconfig.json",
3
+ "exclude": ["**/*.spec.ts", "**/*.test.ts"]
8
4
  }
package/tsconfig.json CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
- "include": [],
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./dist", // Your outDir,
6
+ "emitDeclarationOnly": true
7
+ },
8
+ "include": ["./src", "__tests__/**/**.ts"],
3
9
  "references": [
4
- { "path": "./tsconfig.build.json" },
5
- { "path": "./tsconfig.tests.json" }
10
+ { "path": "../common/tsconfig.build.json" },
11
+ { "path": "../crypto/tsconfig.build.json" },
12
+ { "path": "../identity/tsconfig.build.json" },
13
+ { "path": "../nsid/tsconfig.build.json" }
6
14
  ]
7
15
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"block-map.d.ts","sourceRoot":"","sources":["../src/block-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAGtC,qBAAa,QAAQ;IACnB,OAAO,CAAC,GAAG,CAAqC;IAE1C,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAMxC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU;IAI/B,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,GAAG,SAAS;IAIrC,MAAM,CAAC,GAAG,EAAE,GAAG;IAIf,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG;QAAE,MAAM,EAAE,QAAQ,CAAC;QAAC,OAAO,EAAE,GAAG,EAAE,CAAA;KAAE;IAc1D,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO;IAItB,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAIxD,OAAO,IAAI,KAAK,EAAE;IAQlB,IAAI,IAAI,GAAG,EAAE;IAIb,MAAM,CAAC,KAAK,EAAE,QAAQ;IAMtB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,QAAQ,IAAI,MAAM,CAMrB;IAED,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;CAajC;AAED,KAAK,KAAK,GAAG;IACX,GAAG,EAAE,GAAG,CAAA;IACR,KAAK,EAAE,UAAU,CAAA;CAClB,CAAA;AAED,eAAe,QAAQ,CAAA"}
package/dist/block-map.js DELETED
@@ -1,119 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.BlockMap = void 0;
27
- const lexicon_1 = require("@atproto/lexicon");
28
- const common_1 = require("@atproto/common");
29
- const cid_1 = require("multiformats/cid");
30
- const uint8arrays = __importStar(require("uint8arrays"));
31
- class BlockMap {
32
- constructor() {
33
- Object.defineProperty(this, "map", {
34
- enumerable: true,
35
- configurable: true,
36
- writable: true,
37
- value: new Map()
38
- });
39
- }
40
- async add(value) {
41
- const block = await (0, common_1.dataToCborBlock)((0, lexicon_1.lexToIpld)(value));
42
- this.set(block.cid, block.bytes);
43
- return block.cid;
44
- }
45
- set(cid, bytes) {
46
- this.map.set(cid.toString(), bytes);
47
- }
48
- get(cid) {
49
- return this.map.get(cid.toString());
50
- }
51
- delete(cid) {
52
- this.map.delete(cid.toString());
53
- }
54
- getMany(cids) {
55
- const missing = [];
56
- const blocks = new BlockMap();
57
- for (const cid of cids) {
58
- const got = this.map.get(cid.toString());
59
- if (got) {
60
- blocks.set(cid, got);
61
- }
62
- else {
63
- missing.push(cid);
64
- }
65
- }
66
- return { blocks, missing };
67
- }
68
- has(cid) {
69
- return this.map.has(cid.toString());
70
- }
71
- clear() {
72
- this.map.clear();
73
- }
74
- forEach(cb) {
75
- this.map.forEach((val, key) => cb(val, cid_1.CID.parse(key)));
76
- }
77
- entries() {
78
- const entries = [];
79
- this.forEach((bytes, cid) => {
80
- entries.push({ cid, bytes });
81
- });
82
- return entries;
83
- }
84
- cids() {
85
- return this.entries().map((e) => e.cid);
86
- }
87
- addMap(toAdd) {
88
- toAdd.forEach((bytes, cid) => {
89
- this.set(cid, bytes);
90
- });
91
- }
92
- get size() {
93
- return this.map.size;
94
- }
95
- get byteSize() {
96
- let size = 0;
97
- this.forEach((bytes) => {
98
- size += bytes.length;
99
- });
100
- return size;
101
- }
102
- equals(other) {
103
- if (this.size !== other.size) {
104
- return false;
105
- }
106
- for (const entry of this.entries()) {
107
- const otherBytes = other.get(entry.cid);
108
- if (!otherBytes)
109
- return false;
110
- if (!uint8arrays.equals(entry.bytes, otherBytes)) {
111
- return false;
112
- }
113
- }
114
- return true;
115
- }
116
- }
117
- exports.BlockMap = BlockMap;
118
- exports.default = BlockMap;
119
- //# sourceMappingURL=block-map.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"block-map.js","sourceRoot":"","sources":["../src/block-map.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAsD;AACtD,4CAAiD;AACjD,0CAAsC;AACtC,yDAA0C;AAE1C,MAAa,QAAQ;IAArB;QACU;;;;mBAA+B,IAAI,GAAG,EAAE;WAAA;IAyFlD,CAAC;IAvFC,KAAK,CAAC,GAAG,CAAC,KAAe;QACvB,MAAM,KAAK,GAAG,MAAM,IAAA,wBAAe,EAAC,IAAA,mBAAS,EAAC,KAAK,CAAC,CAAC,CAAA;QACrD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;QAChC,OAAO,KAAK,CAAC,GAAG,CAAA;IAClB,CAAC;IAED,GAAG,CAAC,GAAQ,EAAE,KAAiB;QAC7B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAA;IACrC,CAAC;IAED,GAAG,CAAC,GAAQ;QACV,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAA;IACrC,CAAC;IAED,MAAM,CAAC,GAAQ;QACb,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAA;IACjC,CAAC;IAED,OAAO,CAAC,IAAW;QACjB,MAAM,OAAO,GAAU,EAAE,CAAA;QACzB,MAAM,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAA;QAC7B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAA;YACxC,IAAI,GAAG,EA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