@atproto/sync 0.3.0-next.0 → 0.3.1

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 CHANGED
@@ -1,28 +1,44 @@
1
1
  # @atproto/sync
2
2
 
3
- ## 0.3.0-next.0
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4973](https://github.com/bluesky-social/atproto/pull/4973) [`4801600`](https://github.com/bluesky-social/atproto/commit/48016005155c9cecabf3fa9d5e9b3555e84e2dca) Thanks [@dholms](https://github.com/dholms)! - Fix getCursor invocation
8
+
9
+ - Updated dependencies [[`e6c6343`](https://github.com/bluesky-social/atproto/commit/e6c6343bd3727455bd0da12300bb4929a944e4f1), [`25e0233`](https://github.com/bluesky-social/atproto/commit/25e02339a383740e762c9a9633a701d2fb0cab86)]:
10
+ - @atproto/common@0.6.1
11
+ - @atproto/lex@0.1.1
12
+
13
+ ## 0.3.0
4
14
 
5
15
  ### Minor Changes
6
16
 
7
- - [#4929](https://github.com/bluesky-social/atproto/pull/4929) [`bb7491c`](https://github.com/bluesky-social/atproto/commit/bb7491c29e06181e1d2f8cf6eb454f9bb8ab961b) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Drop support for Node.js 18 and 20. Node.js 22 is now the minimum supported version. Docker images now use Node.js 24.
17
+ - [#4929](https://github.com/bluesky-social/atproto/pull/4929) [`f01c59f`](https://github.com/bluesky-social/atproto/commit/f01c59f5bd3f75fb8b47a9eecd4858b84033fb7c) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Drop support for Node.js 18 and 20. Node.js 22 is now the minimum supported version. Docker images now use Node.js 24.
8
18
 
9
- - [#4943](https://github.com/bluesky-social/atproto/pull/4943) [`07ae5d4`](https://github.com/bluesky-social/atproto/commit/07ae5d4452df51e045e0239da7a04cf0bc154028) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Convert to pure ESM. All packages now ship `"type": "module"` with ES module output and Node16 module resolution.
19
+ - [#4943](https://github.com/bluesky-social/atproto/pull/4943) [`c459153`](https://github.com/bluesky-social/atproto/commit/c459153395a30ce89e050892c8fab7dc98e019b9) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Convert to pure ESM. All packages now ship `"type": "module"` with ES module output and Node16 module resolution.
10
20
 
11
21
  Node.js 22's `require()` compatibility layer can still load these packages in CommonJS code.
12
22
 
13
- - [#4930](https://github.com/bluesky-social/atproto/pull/4930) [`042df15`](https://github.com/bluesky-social/atproto/commit/042df15087c0e62cd1e715fcbf58852fab875af9) Thanks [@devinivy](https://github.com/devinivy)! - Build with TypeScript 6.0. Emitted `.d.ts` files now use TypeScript 6's stricter `Uint8Array<ArrayBuffer>` typing in places where Web/Node APIs require buffer-backed (not shared-memory) byte arrays. Consumers compiling against these types on older TypeScript should see no runtime impact, but may need to widen or cast in spots that previously relied on `Uint8Array` defaulting to `<ArrayBufferLike>`.
23
+ - [#4930](https://github.com/bluesky-social/atproto/pull/4930) [`908bece`](https://github.com/bluesky-social/atproto/commit/908bece169258bff5ad121e5eec157d6ded6f705) Thanks [@devinivy](https://github.com/devinivy)! - Build with TypeScript 6.0.
14
24
 
15
- Internal: tsconfig `moduleResolution: "node"` is silenced via `ignoreDeprecations: "6.0"` for now; the proper migration to `node16`/`bundler` resolution is deferred.
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [[`affb50c`](https://github.com/bluesky-social/atproto/commit/affb50c040b497a12631df99a6310f8e78cab557), [`f01c59f`](https://github.com/bluesky-social/atproto/commit/f01c59f5bd3f75fb8b47a9eecd4858b84033fb7c), [`c459153`](https://github.com/bluesky-social/atproto/commit/c459153395a30ce89e050892c8fab7dc98e019b9), [`908bece`](https://github.com/bluesky-social/atproto/commit/908bece169258bff5ad121e5eec157d6ded6f705)]:
28
+ - @atproto/common@0.6.0
29
+ - @atproto/identity@0.5.0
30
+ - @atproto/lex@0.1.0
31
+ - @atproto/repo@0.10.0
32
+ - @atproto/syntax@0.6.0
33
+ - @atproto/xrpc-server@0.11.0
34
+
35
+ ## 0.2.4
16
36
 
17
37
  ### Patch Changes
18
38
 
19
- - Updated dependencies [[`bb7491c`](https://github.com/bluesky-social/atproto/commit/bb7491c29e06181e1d2f8cf6eb454f9bb8ab961b), [`07ae5d4`](https://github.com/bluesky-social/atproto/commit/07ae5d4452df51e045e0239da7a04cf0bc154028), [`042df15`](https://github.com/bluesky-social/atproto/commit/042df15087c0e62cd1e715fcbf58852fab875af9)]:
20
- - @atproto/common@0.6.0-next.0
21
- - @atproto/identity@0.5.0-next.0
22
- - @atproto/lex@0.1.0-next.0
23
- - @atproto/repo@0.10.0-next.0
24
- - @atproto/syntax@0.6.0-next.0
25
- - @atproto/xrpc-server@0.11.0-next.0
39
+ - Updated dependencies []:
40
+ - @atproto/lex@0.0.27
41
+ - @atproto/xrpc-server@0.10.22
26
42
 
27
43
  ## 0.2.3
28
44
 
@@ -5,9 +5,9 @@ import { com } from '../lexicons/index.js';
5
5
  import { EventRunner } from '../runner/index.js';
6
6
  export type FirehoseOptions = ClientOptions & {
7
7
  idResolver: IdResolver;
8
- handleEvent: (evt: Event) => Awaited<void>;
8
+ handleEvent: (evt: Event) => void | Promise<void>;
9
9
  onError: (err: Error) => void;
10
- getCursor?: () => Awaited<number | undefined>;
10
+ getCursor?: () => number | undefined | Promise<number | undefined>;
11
11
  runner?: EventRunner;
12
12
  service?: string;
13
13
  subscriptionReconnectDelay?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/firehose/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAEvC,OAAO,EAEL,UAAU,EAEX,MAAM,mBAAmB,CAAA;AAa1B,OAAO,EACL,UAAU,EAEV,SAAS,EAET,KAAK,EACL,WAAW,EACX,OAAO,EACR,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CA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AAE,OAAO,EACL,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ;CAIzD;AAED,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,GAAG,EAAE,OAAO;CAGzB;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IAGpC,KAAK,EAAE,KAAK;gBADnB,GAAG,EAAE,OAAO,EACL,KAAK,EAAE,KAAK;CAItB"}
@@ -41,12 +41,14 @@ export class Firehose {
41
41
  method: com.atproto.sync.subscribeRepos.$lxm,
42
42
  signal: this.abortController.signal,
43
43
  getParams: async () => {
44
- const getCursorFn = () => this.opts.runner?.getCursor() ?? this.opts.getCursor;
45
- if (!getCursorFn) {
46
- return undefined;
44
+ let cursor;
45
+ if (this.opts.runner) {
46
+ cursor = await this.opts.runner.getCursor();
47
+ }
48
+ else if (this.opts.getCursor) {
49
+ cursor = await this.opts.getCursor();
47
50
  }
48
- const cursor = await getCursorFn();
49
- return { cursor };
51
+ return cursor === undefined ? undefined : { cursor };
50
52
  },
51
53
  validate: (value) => {
52
54
  const result = com.atproto.sync.subscribeRepos.$message.safeParse(value);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/firehose/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,gBAAgB,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACpE,OAAO,EAGL,sBAAsB,GACvB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,OAAO,EACP,eAAe,EACf,YAAY,GACb,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAUnD,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAA;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAwB5C,MA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K;IAC7C,YACE,GAAY,EACL,KAAY;QAEnB,KAAK,CAAC,iCAAiC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;QAFjD,UAAK,GAAL,KAAK,CAAO;IAGrB,CAAC;CACF","sourcesContent":["import type { ClientOptions } from 'ws'\nimport { Deferrable, createDeferrable, wait } from '@atproto/common'\nimport {\n DidDocument,\n IdResolver,\n parseToAtprotoDocument,\n} from '@atproto/identity'\nimport { Cid } from '@atproto/lex'\nimport {\n RepoVerificationError,\n cborToLexRecord,\n formatDataKey,\n parseDataKey,\n readCar,\n readCarWithRoot,\n verifyProofs,\n} from '@atproto/repo'\nimport { AtUri } from '@atproto/syntax'\nimport { Subscription } from '@atproto/xrpc-server'\nimport {\n AccountEvt,\n AccountStatus,\n CommitEvt,\n CommitMeta,\n Event,\n IdentityEvt,\n SyncEvt,\n} from '../events.js'\nimport { com } from '../lexicons/index.js'\nimport { EventRunner } from '../runner/index.js'\nimport { didAndSeqForEvt } from '../util.js'\n\nexport type FirehoseOptions = ClientOptions & {\n idResolver: IdResolver\n\n handleEvent: (evt: Event) => Awaited<void>\n onError: (err: Error) => void\n getCursor?: () => Awaited<number | undefined>\n\n runner?: EventRunner // should only set getCursor *or* runner\n\n service?: string\n subscriptionReconnectDelay?: number\n\n unauthenticatedCommits?: boolean\n unauthenticatedHandles?: boolean\n\n filterCollections?: string[]\n excludeIdentity?: boolean\n excludeAccount?: boolean\n excludeCommit?: boolean\n excludeSync?: boolean\n}\n\nexport class Firehose {\n private sub: Subscription<com.atproto.sync.subscribeRepos.$Message>\n private abortController: AbortController\n private destoryDefer: Deferrable\n private matchCollection: ((col: string) => boolean) | null = null\n\n constructor(public opts: FirehoseOptions) {\n this.destoryDefer = createDeferrable()\n this.abortController = new AbortController()\n if (this.opts.getCursor && this.opts.runner) {\n throw new Error('Must set only `getCursor` or `runner`')\n }\n if (opts.filterCollections) {\n const exact = new Set<string>()\n const prefixes: string[] = []\n\n for (const pattern of opts.filterCollections) {\n if (pattern.endsWith('.*')) {\n prefixes.push(pattern.slice(0, -2))\n } else {\n exact.add(pattern)\n }\n }\n this.matchCollection = (col: string): boolean => {\n if (exact.has(col)) return true\n for (const prefix of prefixes) {\n if (col.startsWith(prefix)) return true\n }\n return false\n }\n }\n this.sub = new Subscription({\n ...opts,\n service: opts.service ?? 'wss://bsky.network',\n method: com.atproto.sync.subscribeRepos.$lxm,\n signal: this.abortController.signal,\n getParams: async () => {\n const getCursorFn = () =>\n this.opts.runner?.getCursor() ?? this.opts.getCursor\n if (!getCursorFn) {\n return undefined\n }\n const cursor = await getCursorFn()\n return { cursor }\n },\n validate: (value: unknown) => {\n const result = com.atproto.sync.subscribeRepos.$message.safeParse(value)\n if (result.success) {\n return result.value\n } else {\n this.opts.onError(new FirehoseValidationError(result.reason, value))\n }\n },\n })\n }\n\n async start() {\n try {\n for await (const evt of this.sub) {\n if (this.opts.runner) {\n const parsed = didAndSeqForEvt(evt)\n if (!parsed) {\n continue\n }\n this.opts.runner.trackEvent(parsed.did, parsed.seq, async () => {\n const parsed = await this.parseEvt(evt)\n for (const write of parsed) {\n try {\n await this.opts.handleEvent(write)\n } catch (err) {\n this.opts.onError(new FirehoseHandlerError(err, write))\n }\n }\n })\n } else {\n await this.processEvt(evt)\n }\n }\n } catch (err) {\n if (err && err['name'] === 'AbortError') {\n this.destoryDefer.resolve()\n return\n }\n this.opts.onError(new FirehoseSubscriptionError(err))\n await wait(this.opts.subscriptionReconnectDelay ?? 3000)\n return this.start()\n }\n }\n\n private async parseEvt(\n evt: com.atproto.sync.subscribeRepos.$Message,\n ): Promise<Event[]> {\n try {\n if (com.atproto.sync.subscribeRepos.commit.$isTypeOf(evt)) {\n if (this.opts.excludeCommit) return []\n\n return this.opts.unauthenticatedCommits\n ? await parseCommitUnauthenticated(evt, this.matchCollection)\n : await parseCommitAuthenticated(\n this.opts.idResolver,\n evt,\n this.matchCollection,\n )\n } else if (com.atproto.sync.subscribeRepos.account.$isTypeOf(evt)) {\n if (this.opts.excludeAccount) return []\n\n const parsed = parseAccount(evt)\n return parsed ? [parsed] : []\n } else if (com.atproto.sync.subscribeRepos.identity.$isTypeOf(evt)) {\n if (this.opts.excludeIdentity) return []\n\n const parsed = await parseIdentity(\n this.opts.idResolver,\n evt,\n this.opts.unauthenticatedHandles,\n )\n return parsed ? [parsed] : []\n } else if (com.atproto.sync.subscribeRepos.sync.$isTypeOf(evt)) {\n if (this.opts.excludeSync) return []\n\n const parsed = await parseSync(evt)\n return parsed ? [parsed] : []\n } else {\n return []\n }\n } catch (err) {\n this.opts.onError(new FirehoseParseError(err, evt))\n return []\n }\n }\n\n private async processEvt(evt: com.atproto.sync.subscribeRepos.$Message) {\n const parsed = await this.parseEvt(evt)\n for (const write of parsed) {\n try {\n await this.opts.handleEvent(write)\n } catch (err) {\n this.opts.onError(new FirehoseHandlerError(err, write))\n }\n }\n }\n\n async destroy(): Promise<void> {\n this.abortController.abort()\n await this.destoryDefer.complete\n }\n}\n\nexport const parseCommitAuthenticated = async (\n idResolver: IdResolver,\n evt: com.atproto.sync.subscribeRepos.Commit,\n matchCollection?: ((col: string) => boolean) | null,\n forceKeyRefresh = false,\n): Promise<CommitEvt[]> => {\n const did = evt.repo\n const ops = maybeFilterOps(evt.ops, matchCollection)\n if (ops.length === 0) {\n return []\n }\n const claims = ops.map((op) => {\n const { collection, rkey } = parseDataKey(op.path)\n return {\n collection,\n rkey,\n cid: op.action === 'delete' ? null : op.cid,\n }\n })\n const key = await idResolver.did.resolveAtprotoKey(did, forceKeyRefresh)\n const verifiedCids: Record<string, Cid | null> = {}\n try {\n const results = await verifyProofs(evt.blocks, claims, did, key)\n results.verified.forEach((op) => {\n const path = formatDataKey(op.collection, op.rkey)\n verifiedCids[path] = op.cid\n })\n } catch (err) {\n if (err instanceof RepoVerificationError && !forceKeyRefresh) {\n return parseCommitAuthenticated(idResolver, evt, matchCollection, true)\n }\n throw err\n }\n const verifiedOps: com.atproto.sync.subscribeRepos.RepoOp[] = ops.filter(\n (op) => {\n const verifiedCid = verifiedCids[op.path]\n if (op.action === 'delete') {\n return verifiedCid === null\n } else {\n return (\n op.cid != null && verifiedCid != null && verifiedCid.equals(op.cid)\n )\n }\n },\n )\n return formatCommitOps(evt, verifiedOps, {\n skipCidVerification: true, // already checked via verifyProofs()\n })\n}\n\nexport const parseCommitUnauthenticated = async (\n evt: com.atproto.sync.subscribeRepos.Commit,\n matchCollection?: ((col: string) => boolean) | null,\n): Promise<CommitEvt[]> => {\n const ops = maybeFilterOps(evt.ops, matchCollection)\n return formatCommitOps(evt, ops)\n}\n\nconst maybeFilterOps = (\n ops: com.atproto.sync.subscribeRepos.RepoOp[],\n matchCollection?: ((col: string) => boolean) | null,\n): com.atproto.sync.subscribeRepos.RepoOp[] => {\n if (!matchCollection) return ops\n return ops.filter((op) => {\n const { collection } = parseDataKey(op.path)\n return matchCollection(collection)\n })\n}\n\nconst formatCommitOps = async (\n evt: com.atproto.sync.subscribeRepos.Commit,\n ops: com.atproto.sync.subscribeRepos.RepoOp[],\n options?: { skipCidVerification: boolean },\n) => {\n const car = await readCar(evt.blocks, options)\n\n const evts: CommitEvt[] = []\n\n for (const op of ops) {\n const uri = AtUri.make(evt.repo, op.path)\n\n const meta: CommitMeta = {\n seq: evt.seq,\n time: evt.time,\n commit: evt.commit,\n blocks: car.blocks,\n rev: evt.rev,\n uri,\n did: uri.did,\n collection: uri.collection,\n rkey: uri.rkey,\n }\n\n if (op.action === 'create' || op.action === 'update') {\n if (!op.cid) continue\n const recordBytes = car.blocks.get(op.cid)\n if (!recordBytes) continue\n const record = cborToLexRecord(recordBytes)\n evts.push({\n ...meta,\n event: op.action as 'create' | 'update',\n cid: op.cid,\n record,\n })\n }\n\n if (op.action === 'delete') {\n evts.push({\n ...meta,\n event: 'delete',\n })\n }\n }\n\n return evts\n}\n\nexport const parseSync = async (\n evt: com.atproto.sync.subscribeRepos.Sync,\n): Promise<SyncEvt | null> => {\n const car = await readCarWithRoot(evt.blocks)\n\n return {\n event: 'sync',\n seq: evt.seq,\n time: evt.time,\n did: evt.did,\n cid: car.root,\n rev: evt.rev,\n blocks: car.blocks,\n }\n}\n\nexport const parseIdentity = async (\n idResolver: IdResolver,\n evt: com.atproto.sync.subscribeRepos.Identity,\n unauthenticated = false,\n): Promise<IdentityEvt | null> => {\n const res = await idResolver.did.resolve(evt.did)\n const handle =\n res && !unauthenticated\n ? await verifyHandle(idResolver, evt.did, res)\n : undefined\n\n return {\n event: 'identity',\n seq: evt.seq,\n time: evt.time,\n did: evt.did,\n handle,\n didDocument: res ?? undefined,\n }\n}\n\nconst verifyHandle = async (\n idResolver: IdResolver,\n did: string,\n didDoc: DidDocument,\n): Promise<string | undefined> => {\n const { handle } = parseToAtprotoDocument(didDoc)\n if (!handle) {\n return undefined\n }\n const res = await idResolver.handle.resolve(handle)\n return res === did ? handle : undefined\n}\n\nexport const parseAccount = (\n evt: com.atproto.sync.subscribeRepos.Account,\n): AccountEvt | undefined => {\n if (evt.status && !isValidStatus(evt.status)) return\n return {\n event: 'account',\n seq: evt.seq,\n time: evt.time,\n did: evt.did,\n active: evt.active,\n status: evt.status as AccountStatus | undefined,\n }\n}\n\nconst isValidStatus = (str: string): str is AccountStatus => {\n return ['takendown', 'suspended', 'deleted', 'deactivated'].includes(str)\n}\n\nexport class FirehoseValidationError extends Error {\n constructor(\n err: unknown,\n public value: unknown,\n ) {\n super('error in firehose event lexicon validation', { cause: err })\n }\n}\n\nexport class FirehoseParseError extends Error {\n constructor(\n err: unknown,\n public event: com.atproto.sync.subscribeRepos.$Message,\n ) {\n super('error in parsing and authenticating firehose event', { cause: err })\n }\n}\n\nexport class FirehoseSubscriptionError extends Error {\n constructor(err: unknown) {\n super('error on firehose subscription', { cause: err })\n }\n}\n\nexport class FirehoseHandlerError extends Error {\n constructor(\n err: unknown,\n public event: Event,\n ) {\n super('error in firehose event handler', { cause: err })\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/firehose/index.ts"],"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AAA;AAED,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YACE,GAAY,EACL,KAAc;QAErB,KAAK,CAAC,4CAA4C,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;QAF5D,UAAK,GAAL,KAAK,CAAS;IAGvB,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YACE,GAAY,EACL,KAA+C;QAEtD,KAAK,CAAC,oDAAoD,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;QAFpE,UAAK,GAAL,KAAK,CAA0C;IAGxD,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAClD,YAAY,GAAY;QACtB,KAAK,CAAC,gCAAgC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACzD,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YACE,GAAY,EACL,KAAY;QAEnB,KAAK,CAAC,iCAAiC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;QAFjD,UAAK,GAAL,KAAK,CAAO;IAGrB,CAAC;CACF","sourcesContent":["import type { ClientOptions } from 'ws'\nimport { Deferrable, createDeferrable, wait } from '@atproto/common'\nimport {\n DidDocument,\n IdResolver,\n parseToAtprotoDocument,\n} from '@atproto/identity'\nimport { Cid } from '@atproto/lex'\nimport {\n RepoVerificationError,\n cborToLexRecord,\n formatDataKey,\n parseDataKey,\n readCar,\n readCarWithRoot,\n verifyProofs,\n} from '@atproto/repo'\nimport { AtUri } from '@atproto/syntax'\nimport { Subscription } from '@atproto/xrpc-server'\nimport {\n AccountEvt,\n AccountStatus,\n CommitEvt,\n CommitMeta,\n Event,\n IdentityEvt,\n SyncEvt,\n} from '../events.js'\nimport { com } from '../lexicons/index.js'\nimport { EventRunner } from '../runner/index.js'\nimport { didAndSeqForEvt } from '../util.js'\n\nexport type FirehoseOptions = ClientOptions & {\n idResolver: IdResolver\n\n handleEvent: (evt: Event) => void | Promise<void>\n onError: (err: Error) => void\n getCursor?: () => number | undefined | Promise<number | undefined>\n\n runner?: EventRunner // should only set getCursor *or* runner\n\n service?: string\n subscriptionReconnectDelay?: number\n\n unauthenticatedCommits?: boolean\n unauthenticatedHandles?: boolean\n\n filterCollections?: string[]\n excludeIdentity?: boolean\n excludeAccount?: boolean\n excludeCommit?: boolean\n excludeSync?: boolean\n}\n\nexport class Firehose {\n private sub: Subscription<com.atproto.sync.subscribeRepos.$Message>\n private abortController: AbortController\n private destoryDefer: Deferrable\n private matchCollection: ((col: string) => boolean) | null = null\n\n constructor(public opts: FirehoseOptions) {\n this.destoryDefer = createDeferrable()\n this.abortController = new AbortController()\n if (this.opts.getCursor && this.opts.runner) {\n throw new Error('Must set only `getCursor` or `runner`')\n }\n if (opts.filterCollections) {\n const exact = new Set<string>()\n const prefixes: string[] = []\n\n for (const pattern of opts.filterCollections) {\n if (pattern.endsWith('.*')) {\n prefixes.push(pattern.slice(0, -2))\n } else {\n exact.add(pattern)\n }\n }\n this.matchCollection = (col: string): boolean => {\n if (exact.has(col)) return true\n for (const prefix of prefixes) {\n if (col.startsWith(prefix)) return true\n }\n return false\n }\n }\n this.sub = new Subscription({\n ...opts,\n service: opts.service ?? 'wss://bsky.network',\n method: com.atproto.sync.subscribeRepos.$lxm,\n signal: this.abortController.signal,\n getParams: async () => {\n let cursor: number | undefined\n if (this.opts.runner) {\n cursor = await this.opts.runner.getCursor()\n } else if (this.opts.getCursor) {\n cursor = await this.opts.getCursor()\n }\n return cursor === undefined ? undefined : { cursor }\n },\n validate: (value: unknown) => {\n const result = com.atproto.sync.subscribeRepos.$message.safeParse(value)\n if (result.success) {\n return result.value\n } else {\n this.opts.onError(new FirehoseValidationError(result.reason, value))\n }\n },\n })\n }\n\n async start() {\n try {\n for await (const evt of this.sub) {\n if (this.opts.runner) {\n const parsed = didAndSeqForEvt(evt)\n if (!parsed) {\n continue\n }\n this.opts.runner.trackEvent(parsed.did, parsed.seq, async () => {\n const parsed = await this.parseEvt(evt)\n for (const write of parsed) {\n try {\n await this.opts.handleEvent(write)\n } catch (err) {\n this.opts.onError(new FirehoseHandlerError(err, write))\n }\n }\n })\n } else {\n await this.processEvt(evt)\n }\n }\n } catch (err) {\n if (err && err['name'] === 'AbortError') {\n this.destoryDefer.resolve()\n return\n }\n this.opts.onError(new FirehoseSubscriptionError(err))\n await wait(this.opts.subscriptionReconnectDelay ?? 3000)\n return this.start()\n }\n }\n\n private async parseEvt(\n evt: com.atproto.sync.subscribeRepos.$Message,\n ): Promise<Event[]> {\n try {\n if (com.atproto.sync.subscribeRepos.commit.$isTypeOf(evt)) {\n if (this.opts.excludeCommit) return []\n\n return this.opts.unauthenticatedCommits\n ? await parseCommitUnauthenticated(evt, this.matchCollection)\n : await parseCommitAuthenticated(\n this.opts.idResolver,\n evt,\n this.matchCollection,\n )\n } else if (com.atproto.sync.subscribeRepos.account.$isTypeOf(evt)) {\n if (this.opts.excludeAccount) return []\n\n const parsed = parseAccount(evt)\n return parsed ? [parsed] : []\n } else if (com.atproto.sync.subscribeRepos.identity.$isTypeOf(evt)) {\n if (this.opts.excludeIdentity) return []\n\n const parsed = await parseIdentity(\n this.opts.idResolver,\n evt,\n this.opts.unauthenticatedHandles,\n )\n return parsed ? [parsed] : []\n } else if (com.atproto.sync.subscribeRepos.sync.$isTypeOf(evt)) {\n if (this.opts.excludeSync) return []\n\n const parsed = await parseSync(evt)\n return parsed ? [parsed] : []\n } else {\n return []\n }\n } catch (err) {\n this.opts.onError(new FirehoseParseError(err, evt))\n return []\n }\n }\n\n private async processEvt(evt: com.atproto.sync.subscribeRepos.$Message) {\n const parsed = await this.parseEvt(evt)\n for (const write of parsed) {\n try {\n await this.opts.handleEvent(write)\n } catch (err) {\n this.opts.onError(new FirehoseHandlerError(err, write))\n }\n }\n }\n\n async destroy(): Promise<void> {\n this.abortController.abort()\n await this.destoryDefer.complete\n }\n}\n\nexport const parseCommitAuthenticated = async (\n idResolver: IdResolver,\n evt: com.atproto.sync.subscribeRepos.Commit,\n matchCollection?: ((col: string) => boolean) | null,\n forceKeyRefresh = false,\n): Promise<CommitEvt[]> => {\n const did = evt.repo\n const ops = maybeFilterOps(evt.ops, matchCollection)\n if (ops.length === 0) {\n return []\n }\n const claims = ops.map((op) => {\n const { collection, rkey } = parseDataKey(op.path)\n return {\n collection,\n rkey,\n cid: op.action === 'delete' ? null : op.cid,\n }\n })\n const key = await idResolver.did.resolveAtprotoKey(did, forceKeyRefresh)\n const verifiedCids: Record<string, Cid | null> = {}\n try {\n const results = await verifyProofs(evt.blocks, claims, did, key)\n results.verified.forEach((op) => {\n const path = formatDataKey(op.collection, op.rkey)\n verifiedCids[path] = op.cid\n })\n } catch (err) {\n if (err instanceof RepoVerificationError && !forceKeyRefresh) {\n return parseCommitAuthenticated(idResolver, evt, matchCollection, true)\n }\n throw err\n }\n const verifiedOps: com.atproto.sync.subscribeRepos.RepoOp[] = ops.filter(\n (op) => {\n const verifiedCid = verifiedCids[op.path]\n if (op.action === 'delete') {\n return verifiedCid === null\n } else {\n return (\n op.cid != null && verifiedCid != null && verifiedCid.equals(op.cid)\n )\n }\n },\n )\n return formatCommitOps(evt, verifiedOps, {\n skipCidVerification: true, // already checked via verifyProofs()\n })\n}\n\nexport const parseCommitUnauthenticated = async (\n evt: com.atproto.sync.subscribeRepos.Commit,\n matchCollection?: ((col: string) => boolean) | null,\n): Promise<CommitEvt[]> => {\n const ops = maybeFilterOps(evt.ops, matchCollection)\n return formatCommitOps(evt, ops)\n}\n\nconst maybeFilterOps = (\n ops: com.atproto.sync.subscribeRepos.RepoOp[],\n matchCollection?: ((col: string) => boolean) | null,\n): com.atproto.sync.subscribeRepos.RepoOp[] => {\n if (!matchCollection) return ops\n return ops.filter((op) => {\n const { collection } = parseDataKey(op.path)\n return matchCollection(collection)\n })\n}\n\nconst formatCommitOps = async (\n evt: com.atproto.sync.subscribeRepos.Commit,\n ops: com.atproto.sync.subscribeRepos.RepoOp[],\n options?: { skipCidVerification: boolean },\n) => {\n const car = await readCar(evt.blocks, options)\n\n const evts: CommitEvt[] = []\n\n for (const op of ops) {\n const uri = AtUri.make(evt.repo, op.path)\n\n const meta: CommitMeta = {\n seq: evt.seq,\n time: evt.time,\n commit: evt.commit,\n blocks: car.blocks,\n rev: evt.rev,\n uri,\n did: uri.did,\n collection: uri.collection,\n rkey: uri.rkey,\n }\n\n if (op.action === 'create' || op.action === 'update') {\n if (!op.cid) continue\n const recordBytes = car.blocks.get(op.cid)\n if (!recordBytes) continue\n const record = cborToLexRecord(recordBytes)\n evts.push({\n ...meta,\n event: op.action as 'create' | 'update',\n cid: op.cid,\n record,\n })\n }\n\n if (op.action === 'delete') {\n evts.push({\n ...meta,\n event: 'delete',\n })\n }\n }\n\n return evts\n}\n\nexport const parseSync = async (\n evt: com.atproto.sync.subscribeRepos.Sync,\n): Promise<SyncEvt | null> => {\n const car = await readCarWithRoot(evt.blocks)\n\n return {\n event: 'sync',\n seq: evt.seq,\n time: evt.time,\n did: evt.did,\n cid: car.root,\n rev: evt.rev,\n blocks: car.blocks,\n }\n}\n\nexport const parseIdentity = async (\n idResolver: IdResolver,\n evt: com.atproto.sync.subscribeRepos.Identity,\n unauthenticated = false,\n): Promise<IdentityEvt | null> => {\n const res = await idResolver.did.resolve(evt.did)\n const handle =\n res && !unauthenticated\n ? await verifyHandle(idResolver, evt.did, res)\n : undefined\n\n return {\n event: 'identity',\n seq: evt.seq,\n time: evt.time,\n did: evt.did,\n handle,\n didDocument: res ?? undefined,\n }\n}\n\nconst verifyHandle = async (\n idResolver: IdResolver,\n did: string,\n didDoc: DidDocument,\n): Promise<string | undefined> => {\n const { handle } = parseToAtprotoDocument(didDoc)\n if (!handle) {\n return undefined\n }\n const res = await idResolver.handle.resolve(handle)\n return res === did ? handle : undefined\n}\n\nexport const parseAccount = (\n evt: com.atproto.sync.subscribeRepos.Account,\n): AccountEvt | undefined => {\n if (evt.status && !isValidStatus(evt.status)) return\n return {\n event: 'account',\n seq: evt.seq,\n time: evt.time,\n did: evt.did,\n active: evt.active,\n status: evt.status as AccountStatus | undefined,\n }\n}\n\nconst isValidStatus = (str: string): str is AccountStatus => {\n return ['takendown', 'suspended', 'deleted', 'deactivated'].includes(str)\n}\n\nexport class FirehoseValidationError extends Error {\n constructor(\n err: unknown,\n public value: unknown,\n ) {\n super('error in firehose event lexicon validation', { cause: err })\n }\n}\n\nexport class FirehoseParseError extends Error {\n constructor(\n err: unknown,\n public event: com.atproto.sync.subscribeRepos.$Message,\n ) {\n super('error in parsing and authenticating firehose event', { cause: err })\n }\n}\n\nexport class FirehoseSubscriptionError extends Error {\n constructor(err: unknown) {\n super('error on firehose subscription', { cause: err })\n }\n}\n\nexport class FirehoseHandlerError extends Error {\n constructor(\n err: unknown,\n public event: Event,\n ) {\n super('error in firehose event handler', { cause: err })\n }\n}\n"]}
@@ -1,6 +1,11 @@
1
1
  import { l } from '@atproto/lex';
2
2
  declare const $nsid = "com.atproto.sync.subscribeRepos";
3
3
  export { $nsid };
4
+ export declare const $lxm = "com.atproto.sync.subscribeRepos";
5
+ export declare const $params: l.ParamsSchema<{
6
+ readonly cursor: l.OptionalSchema<l.IntegerSchema>;
7
+ }>;
8
+ export declare const $message: l.TypedUnionSchema<readonly [l.TypedRefSchema<l.TypedObjectValidator<Commit, Commit>>, l.TypedRefSchema<l.TypedObjectValidator<Sync, Sync>>, l.TypedRefSchema<l.TypedObjectValidator<Identity, Identity>>, l.TypedRefSchema<l.TypedObjectValidator<Account, Account>>, l.TypedRefSchema<l.TypedObjectValidator<Info, Info>>], false>;
4
9
  /** Repository event stream, aka Firehose endpoint. Outputs repo commits with diff data, and identity update events, for all repositories on the current server. See the atproto specifications for details around stream sequencing, repo versioning, CAR diff format, and more. Public and does not require auth; implemented by PDS and Relay. */
5
10
  declare const main: l.Subscription<"com.atproto.sync.subscribeRepos", l.ParamsSchema<{
6
11
  readonly cursor: l.OptionalSchema<l.IntegerSchema>;
@@ -8,9 +13,6 @@ declare const main: l.Subscription<"com.atproto.sync.subscribeRepos", l.ParamsSc
8
13
  export { main };
9
14
  export type $Params = l.InferMethodParams<typeof main>;
10
15
  export type $Message = l.InferSubscriptionMessage<typeof main>;
11
- export declare const $lxm: "com.atproto.sync.subscribeRepos", $params: l.ParamsSchema<{
12
- readonly cursor: l.OptionalSchema<l.IntegerSchema>;
13
- }>, $message: l.TypedUnionSchema<readonly [l.TypedRefSchema<l.TypedObjectValidator<Commit, Commit>>, l.TypedRefSchema<l.TypedObjectValidator<Sync, Sync>>, l.TypedRefSchema<l.TypedObjectValidator<Identity, Identity>>, l.TypedRefSchema<l.TypedObjectValidator<Account, Account>>, l.TypedRefSchema<l.TypedObjectValidator<Info, Info>>], false>;
14
16
  /** Represents an update of repository state. Note that empty commits are allowed, which include no repo data changes, but an update to rev and signature. */
15
17
  type Commit = {
16
18
  $type?: 'com.atproto.sync.subscribeRepos#commit';
@@ -1 +1 @@
1
- {"version":3,"file":"subscribeRepos.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/sync/subscribeRepos.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAEhC,QAAA,MAAM,KAAK,oCAAoC,CAAA;AAE/C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,oVAAoV;AACpV,QAAA,MAAM,IAAI;;uXAcT,CAAA;AACD,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACtD,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,wBAAwB,CAAC,OAAO,IAAI,CAAC,CAAA;AAE9D,eAAO,MAAM,IAAI,mCAAY,EAC3B,OAAO;;EAAkB,EACzB,QAAQ,sUAAe,CAAA;AAEzB,6JAA6J;AAC7J,KAAK,MAAM,GAAG;IACZ,KAAK,CAAC,EAAE,wCAAwC,CAAA;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;AAED,YAAY,EAAE,MAAM,EAAE,CAAA;AAEtB,0DAA0D;AAC1D,QAAA,MAAM,MAAM,4FASX,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
@@ -4,16 +4,21 @@
4
4
  import { l } from '@atproto/lex';
5
5
  const $nsid = 'com.atproto.sync.subscribeRepos';
6
6
  export { $nsid };
7
- /** Repository event stream, aka Firehose endpoint. Outputs repo commits with diff data, and identity update events, for all repositories on the current server. See the atproto specifications for details around stream sequencing, repo versioning, CAR diff format, and more. Public and does not require auth; implemented by PDS and Relay. */
8
- const main = l.subscription($nsid, l.params({ cursor: l.optional(l.integer()) }), l.typedUnion([
7
+ export const $lxm = $nsid;
8
+ export const $params = l.params({ cursor: l.optional(l.integer()) });
9
+ export const $message = l.typedUnion([
9
10
  l.typedRef((() => commit)),
10
11
  l.typedRef((() => sync)),
11
12
  l.typedRef((() => identity)),
12
13
  l.typedRef((() => account)),
13
14
  l.typedRef((() => info)),
14
- ], false), ['FutureCursor', 'ConsumerTooSlow']);
15
+ ], false);
16
+ /** Repository event stream, aka Firehose endpoint. Outputs repo commits with diff data, and identity update events, for all repositories on the current server. See the atproto specifications for details around stream sequencing, repo versioning, CAR diff format, and more. Public and does not require auth; implemented by PDS and Relay. */
17
+ const main = l.subscription($nsid, $params, $message, [
18
+ 'FutureCursor',
19
+ 'ConsumerTooSlow',
20
+ ]);
15
21
  export { main };
16
- export const $lxm = main.nsid, $params = main.parameters, $message = main.message;
17
22
  /** Represents an update of repository state. Note that empty commits are allowed, which include no repo data changes, but an update to rev and signature. */
18
23
  const commit = l.typedObject($nsid, 'commit', l.object({
19
24
  seq: l.integer(),
@@ -1 +1 @@
1
- {"version":3,"file":"subscribeRepos.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/sync/subscribeRepos.defs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAEhC,MAAM,KAAK,GAAG,i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AAC,CAAC,WAAW,CAC1B,KAAK,EACL,QAAQ,EACR,CAAC,CAAC,MAAM,CAAC;IACP,MAAM,EAAE,CAAC,CAAC,MAAM,EAAmD;IACnE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;CAC1B,CAAC,CACH,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex'\n\nconst $nsid = 'com.atproto.sync.subscribeRepos'\n\nexport { $nsid }\n\n/** Repository event stream, aka Firehose endpoint. Outputs repo commits with diff data, and identity update events, for all repositories on the current server. See the atproto specifications for details around stream sequencing, repo versioning, CAR diff format, and more. Public and does not require auth; implemented by PDS and Relay. */\nconst main = l.subscription(\n $nsid,\n l.params({ cursor: l.optional(l.integer()) }),\n l.typedUnion(\n [\n l.typedRef<Commit>((() => commit) as any),\n l.typedRef<Sync>((() => sync) as any),\n l.typedRef<Identity>((() => identity) as any),\n l.typedRef<Account>((() => account) as any),\n l.typedRef<Info>((() => info) as any),\n ],\n false,\n ),\n ['FutureCursor', 'ConsumerTooSlow'],\n)\nexport { main }\n\nexport type $Params = l.InferMethodParams<typeof main>\nexport type $Message = l.InferSubscriptionMessage<typeof main>\n\nexport const $lxm = main.nsid,\n $params = main.parameters,\n $message = main.message\n\n/** Represents an update of repository state. Note that empty commits are allowed, which include no repo data changes, but an update to rev and signature. */\ntype Commit = {\n $type?: 'com.atproto.sync.subscribeRepos#commit'\n\n /**\n * The stream sequence number of this message.\n */\n seq: number\n\n /**\n * @deprecated unused\n */\n rebase: boolean\n\n /**\n * @deprecated replaced by #sync event and data limits. Indicates that this commit contained too many ops, or data size was too large. Consumers will need to make a separate request to get missing data.\n */\n tooBig: boolean\n\n /**\n * The repo this event comes from. Note that all other message types name this field 'did'.\n */\n repo: l.DidString\n\n /**\n * Repo commit object CID.\n */\n commit: l.Cid\n\n /**\n * The rev of the emitted commit. Note that this information is also in the commit object included in blocks, unless this is a tooBig event.\n */\n rev: l.TidString\n\n /**\n * The rev of the last emitted commit from this repo (if any).\n */\n since: l.TidString | null\n\n /**\n * CAR file containing relevant blocks, as a diff since the previous repo state. The commit must be included as a block, and the commit block CID must be the first entry in the CAR header 'roots' list.\n */\n blocks: Uint8Array\n ops: RepoOp[]\n blobs: l.Cid[]\n\n /**\n * The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose.\n */\n prevData?: l.Cid\n\n /**\n * Timestamp of when this message was originally broadcast.\n */\n time: l.DatetimeString\n}\n\nexport type { Commit }\n\n/** Represents an update of repository state. Note that empty commits are allowed, which include no repo data changes, but an update to rev and signature. */\nconst commit = l.typedObject<Commit>(\n $nsid,\n 'commit',\n l.object({\n seq: l.integer(),\n rebase: l.boolean(),\n tooBig: l.boolean(),\n repo: l.string({ format: 'did' }),\n commit: l.cid(),\n rev: l.string({ format: 'tid' }),\n since: l.nullable(l.string({ format: 'tid' })),\n blocks: l.bytes({ maxLength: 2000000 }),\n ops: l.array(l.ref<RepoOp>((() => repoOp) as any), { maxLength: 200 }),\n blobs: l.array(l.cid()),\n prevData: l.optional(l.cid()),\n time: l.string({ format: 'datetime' }),\n }),\n)\n\nexport { commit }\n\n/** Updates the repo to a new state, without necessarily including that state on the firehose. Used to recover from broken commit streams, data loss incidents, or in situations where upstream host does not know recent state of the repository. */\ntype Sync = {\n $type?: 'com.atproto.sync.subscribeRepos#sync'\n\n /**\n * The stream sequence number of this message.\n */\n seq: number\n\n /**\n * The account this repo event corresponds to. Must match that in the commit object.\n */\n did: l.DidString\n\n /**\n * CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'.\n */\n blocks: Uint8Array\n\n /**\n * The rev of the commit. This value must match that in the commit object.\n */\n rev: string\n\n /**\n * Timestamp of when this message was originally broadcast.\n */\n time: l.DatetimeString\n}\n\nexport type { Sync }\n\n/** Updates the repo to a new state, without necessarily including that state on the firehose. Used to recover from broken commit streams, data loss incidents, or in situations where upstream host does not know recent state of the repository. */\nconst sync = l.typedObject<Sync>(\n $nsid,\n 'sync',\n l.object({\n seq: l.integer(),\n did: l.string({ format: 'did' }),\n blocks: l.bytes({ maxLength: 10000 }),\n rev: l.string(),\n time: l.string({ format: 'datetime' }),\n }),\n)\n\nexport { sync }\n\n/** Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache. */\ntype Identity = {\n $type?: 'com.atproto.sync.subscribeRepos#identity'\n seq: number\n did: l.DidString\n time: l.DatetimeString\n\n /**\n * The current handle for the account, or 'handle.invalid' if validation fails. This field is optional, might have been validated or passed-through from an upstream source. Semantics and behaviors for PDS vs Relay may evolve in the future; see atproto specs for more details.\n */\n handle?: l.HandleString\n}\n\nexport type { Identity }\n\n/** Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache. */\nconst identity = l.typedObject<Identity>(\n $nsid,\n 'identity',\n l.object({\n seq: l.integer(),\n did: l.string({ format: 'did' }),\n time: l.string({ format: 'datetime' }),\n handle: l.optional(l.string({ format: 'handle' })),\n }),\n)\n\nexport { identity }\n\n/** Represents a change to an account's status on a host (eg, PDS or Relay). The semantics of this event are that the status is at the host which emitted the event, not necessarily that at the currently active PDS. Eg, a Relay takedown would emit a takedown with active=false, even if the PDS is still active. */\ntype Account = {\n $type?: 'com.atproto.sync.subscribeRepos#account'\n seq: number\n did: l.DidString\n time: l.DatetimeString\n\n /**\n * Indicates that the account has a repository which can be fetched from the host that emitted this event.\n */\n active: boolean\n\n /**\n * If active=false, this optional field indicates a reason for why the account is not active.\n */\n status?:\n | 'takendown'\n | 'suspended'\n | 'deleted'\n | 'deactivated'\n | 'desynchronized'\n | 'throttled'\n | l.UnknownString\n}\n\nexport type { Account }\n\n/** Represents a change to an account's status on a host (eg, PDS or Relay). The semantics of this event are that the status is at the host which emitted the event, not necessarily that at the currently active PDS. Eg, a Relay takedown would emit a takedown with active=false, even if the PDS is still active. */\nconst account = l.typedObject<Account>(\n $nsid,\n 'account',\n l.object({\n seq: l.integer(),\n did: l.string({ format: 'did' }),\n time: l.string({ format: 'datetime' }),\n active: l.boolean(),\n status: l.optional(\n l.string<{\n knownValues: [\n 'takendown',\n 'suspended',\n 'deleted',\n 'deactivated',\n 'desynchronized',\n 'throttled',\n ]\n }>(),\n ),\n }),\n)\n\nexport { account }\n\ntype Info = {\n $type?: 'com.atproto.sync.subscribeRepos#info'\n name: 'OutdatedCursor' | l.UnknownString\n message?: string\n}\n\nexport type { Info }\n\nconst info = l.typedObject<Info>(\n $nsid,\n 'info',\n l.object({\n name: l.string<{ knownValues: ['OutdatedCursor'] }>(),\n message: l.optional(l.string()),\n }),\n)\n\nexport { info }\n\n/** A repo operation, ie a mutation of a single record. */\ntype RepoOp = {\n $type?: 'com.atproto.sync.subscribeRepos#repoOp'\n action: 'create' | 'update' | 'delete' | l.UnknownString\n path: string\n\n /**\n * For creates and updates, the new record CID. For deletions, null.\n */\n cid: l.Cid | null\n\n /**\n * For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined.\n */\n prev?: l.Cid\n}\n\nexport type { RepoOp }\n\n/** A repo operation, ie a mutation of a single record. */\nconst repoOp = l.typedObject<RepoOp>(\n $nsid,\n 'repoOp',\n l.object({\n action: l.string<{ knownValues: ['create', 'update', 'delete'] }>(),\n path: l.string(),\n cid: l.nullable(l.cid()),\n prev: l.optional(l.cid()),\n }),\n)\n\nexport { repoOp }\n"]}
1
+ {"version":3,"file":"subscribeRepos.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/sync/subscribeRepos.defs.ts"],"names":[],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,CAAC;CAChC,CAAC,CACH,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,CAAA;AAqBf,0DAA0D;AAC1D,MAAM,MAAM,GAAG,CAAC,CAAC,WAAW,CAC1B,KAAK,EACL,QAAQ,EACR,CAAC,CAAC,MAAM,CAAC;IACP,MAAM,EAAE,CAAC,CAAC,MAAM,EAAmD;IACnE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;CAC1B,CAAC,CACH,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex'\n\nconst $nsid = 'com.atproto.sync.subscribeRepos'\n\nexport { $nsid }\n\nexport const $lxm = $nsid\nexport const $params = l.params({ cursor: l.optional(l.integer()) })\nexport const $message = l.typedUnion(\n [\n l.typedRef<Commit>((() => commit) as any),\n l.typedRef<Sync>((() => sync) as any),\n l.typedRef<Identity>((() => identity) as any),\n l.typedRef<Account>((() => account) as any),\n l.typedRef<Info>((() => info) as any),\n ],\n false,\n)\n/** Repository event stream, aka Firehose endpoint. Outputs repo commits with diff data, and identity update events, for all repositories on the current server. See the atproto specifications for details around stream sequencing, repo versioning, CAR diff format, and more. Public and does not require auth; implemented by PDS and Relay. */\nconst main = l.subscription($nsid, $params, $message, [\n 'FutureCursor',\n 'ConsumerTooSlow',\n])\n\nexport { main }\n\nexport type $Params = l.InferMethodParams<typeof main>\nexport type $Message = l.InferSubscriptionMessage<typeof main>\n/** Represents an update of repository state. Note that empty commits are allowed, which include no repo data changes, but an update to rev and signature. */\ntype Commit = {\n $type?: 'com.atproto.sync.subscribeRepos#commit'\n\n /**\n * The stream sequence number of this message.\n */\n seq: number\n\n /**\n * @deprecated unused\n */\n rebase: boolean\n\n /**\n * @deprecated replaced by #sync event and data limits. Indicates that this commit contained too many ops, or data size was too large. Consumers will need to make a separate request to get missing data.\n */\n tooBig: boolean\n\n /**\n * The repo this event comes from. Note that all other message types name this field 'did'.\n */\n repo: l.DidString\n\n /**\n * Repo commit object CID.\n */\n commit: l.Cid\n\n /**\n * The rev of the emitted commit. Note that this information is also in the commit object included in blocks, unless this is a tooBig event.\n */\n rev: l.TidString\n\n /**\n * The rev of the last emitted commit from this repo (if any).\n */\n since: l.TidString | null\n\n /**\n * CAR file containing relevant blocks, as a diff since the previous repo state. The commit must be included as a block, and the commit block CID must be the first entry in the CAR header 'roots' list.\n */\n blocks: Uint8Array\n ops: RepoOp[]\n blobs: l.Cid[]\n\n /**\n * The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose.\n */\n prevData?: l.Cid\n\n /**\n * Timestamp of when this message was originally broadcast.\n */\n time: l.DatetimeString\n}\n\nexport type { Commit }\n\n/** Represents an update of repository state. Note that empty commits are allowed, which include no repo data changes, but an update to rev and signature. */\nconst commit = l.typedObject<Commit>(\n $nsid,\n 'commit',\n l.object({\n seq: l.integer(),\n rebase: l.boolean(),\n tooBig: l.boolean(),\n repo: l.string({ format: 'did' }),\n commit: l.cid(),\n rev: l.string({ format: 'tid' }),\n since: l.nullable(l.string({ format: 'tid' })),\n blocks: l.bytes({ maxLength: 2000000 }),\n ops: l.array(l.ref<RepoOp>((() => repoOp) as any), { maxLength: 200 }),\n blobs: l.array(l.cid()),\n prevData: l.optional(l.cid()),\n time: l.string({ format: 'datetime' }),\n }),\n)\n\nexport { commit }\n\n/** Updates the repo to a new state, without necessarily including that state on the firehose. Used to recover from broken commit streams, data loss incidents, or in situations where upstream host does not know recent state of the repository. */\ntype Sync = {\n $type?: 'com.atproto.sync.subscribeRepos#sync'\n\n /**\n * The stream sequence number of this message.\n */\n seq: number\n\n /**\n * The account this repo event corresponds to. Must match that in the commit object.\n */\n did: l.DidString\n\n /**\n * CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'.\n */\n blocks: Uint8Array\n\n /**\n * The rev of the commit. This value must match that in the commit object.\n */\n rev: string\n\n /**\n * Timestamp of when this message was originally broadcast.\n */\n time: l.DatetimeString\n}\n\nexport type { Sync }\n\n/** Updates the repo to a new state, without necessarily including that state on the firehose. Used to recover from broken commit streams, data loss incidents, or in situations where upstream host does not know recent state of the repository. */\nconst sync = l.typedObject<Sync>(\n $nsid,\n 'sync',\n l.object({\n seq: l.integer(),\n did: l.string({ format: 'did' }),\n blocks: l.bytes({ maxLength: 10000 }),\n rev: l.string(),\n time: l.string({ format: 'datetime' }),\n }),\n)\n\nexport { sync }\n\n/** Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache. */\ntype Identity = {\n $type?: 'com.atproto.sync.subscribeRepos#identity'\n seq: number\n did: l.DidString\n time: l.DatetimeString\n\n /**\n * The current handle for the account, or 'handle.invalid' if validation fails. This field is optional, might have been validated or passed-through from an upstream source. Semantics and behaviors for PDS vs Relay may evolve in the future; see atproto specs for more details.\n */\n handle?: l.HandleString\n}\n\nexport type { Identity }\n\n/** Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache. */\nconst identity = l.typedObject<Identity>(\n $nsid,\n 'identity',\n l.object({\n seq: l.integer(),\n did: l.string({ format: 'did' }),\n time: l.string({ format: 'datetime' }),\n handle: l.optional(l.string({ format: 'handle' })),\n }),\n)\n\nexport { identity }\n\n/** Represents a change to an account's status on a host (eg, PDS or Relay). The semantics of this event are that the status is at the host which emitted the event, not necessarily that at the currently active PDS. Eg, a Relay takedown would emit a takedown with active=false, even if the PDS is still active. */\ntype Account = {\n $type?: 'com.atproto.sync.subscribeRepos#account'\n seq: number\n did: l.DidString\n time: l.DatetimeString\n\n /**\n * Indicates that the account has a repository which can be fetched from the host that emitted this event.\n */\n active: boolean\n\n /**\n * If active=false, this optional field indicates a reason for why the account is not active.\n */\n status?:\n | 'takendown'\n | 'suspended'\n | 'deleted'\n | 'deactivated'\n | 'desynchronized'\n | 'throttled'\n | l.UnknownString\n}\n\nexport type { Account }\n\n/** Represents a change to an account's status on a host (eg, PDS or Relay). The semantics of this event are that the status is at the host which emitted the event, not necessarily that at the currently active PDS. Eg, a Relay takedown would emit a takedown with active=false, even if the PDS is still active. */\nconst account = l.typedObject<Account>(\n $nsid,\n 'account',\n l.object({\n seq: l.integer(),\n did: l.string({ format: 'did' }),\n time: l.string({ format: 'datetime' }),\n active: l.boolean(),\n status: l.optional(\n l.string<{\n knownValues: [\n 'takendown',\n 'suspended',\n 'deleted',\n 'deactivated',\n 'desynchronized',\n 'throttled',\n ]\n }>(),\n ),\n }),\n)\n\nexport { account }\n\ntype Info = {\n $type?: 'com.atproto.sync.subscribeRepos#info'\n name: 'OutdatedCursor' | l.UnknownString\n message?: string\n}\n\nexport type { Info }\n\nconst info = l.typedObject<Info>(\n $nsid,\n 'info',\n l.object({\n name: l.string<{ knownValues: ['OutdatedCursor'] }>(),\n message: l.optional(l.string()),\n }),\n)\n\nexport { info }\n\n/** A repo operation, ie a mutation of a single record. */\ntype RepoOp = {\n $type?: 'com.atproto.sync.subscribeRepos#repoOp'\n action: 'create' | 'update' | 'delete' | l.UnknownString\n path: string\n\n /**\n * For creates and updates, the new record CID. For deletions, null.\n */\n cid: l.Cid | null\n\n /**\n * For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined.\n */\n prev?: l.Cid\n}\n\nexport type { RepoOp }\n\n/** A repo operation, ie a mutation of a single record. */\nconst repoOp = l.typedObject<RepoOp>(\n $nsid,\n 'repoOp',\n l.object({\n action: l.string<{ knownValues: ['create', 'update', 'delete'] }>(),\n path: l.string(),\n cid: l.nullable(l.cid()),\n prev: l.optional(l.cid()),\n }),\n)\n\nexport { repoOp }\n"]}
@@ -1,5 +1,5 @@
1
1
  export interface EventRunner {
2
- getCursor(): Awaited<number | undefined>;
2
+ getCursor(): number | undefined | Promise<number | undefined>;
3
3
  trackEvent(did: string, seq: number, handler: () => Promise<void>): Promise<void>;
4
4
  }
5
5
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runner/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACxC,UAAU,CACR,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAC3B,OAAO,CAAC,IAAI,CAAC,CAAA;CACjB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runner/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,SAAS,IAAI,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC7D,UAAU,CACR,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAC3B,OAAO,CAAC,IAAI,CAAC,CAAA;CACjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/runner/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface EventRunner {\n getCursor(): Awaited<number | undefined>\n trackEvent(\n did: string,\n seq: number,\n handler: () => Promise<void>,\n ): Promise<void>\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/runner/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface EventRunner {\n getCursor(): number | undefined | Promise<number | undefined>\n trackEvent(\n did: string,\n seq: number,\n handler: () => Promise<void>,\n ): Promise<void>\n}\n"]}
package/jest.config.cjs CHANGED
@@ -4,12 +4,19 @@ module.exports = {
4
4
  transform: {
5
5
  '^.+\\.(t|j)s$': [
6
6
  '@swc/jest',
7
- { jsc: { transform: {} }, module: { type: 'es6' } },
7
+ {
8
+ jsc: {
9
+ parser: { syntax: 'typescript', importAttributes: true },
10
+ experimental: { keepImportAttributes: true },
11
+ transform: {},
12
+ },
13
+ module: { type: 'es6' },
14
+ },
8
15
  ],
9
16
  },
10
17
  extensionsToTreatAsEsm: ['.ts'],
11
18
  transformIgnorePatterns: [],
12
19
  testTimeout: 60000,
13
- setupFiles: ['<rootDir>/../../jest.setup.ts'],
20
+ setupFiles: ['<rootDir>/../../test.setup.ts'],
14
21
  moduleNameMapper: { '^(\\.\\.?\\/.+)\\.js$': ['$1.ts', '$1.js'] },
15
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/sync",
3
- "version": "0.3.0-next.0",
3
+ "version": "0.3.1",
4
4
  "license": "MIT",
5
5
  "description": "atproto sync library",
6
6
  "keywords": [
@@ -21,12 +21,12 @@
21
21
  "dependencies": {
22
22
  "p-queue": "^8.0.0",
23
23
  "ws": "^8.12.0",
24
- "@atproto/common": "^0.6.0-next.0",
25
- "@atproto/syntax": "^0.6.0-next.0",
26
- "@atproto/identity": "^0.5.0-next.0",
27
- "@atproto/xrpc-server": "^0.11.0-next.0",
28
- "@atproto/repo": "^0.10.0-next.0",
29
- "@atproto/lex": "^0.1.0-next.0"
24
+ "@atproto/common": "^0.6.1",
25
+ "@atproto/identity": "^0.5.0",
26
+ "@atproto/lex": "^0.1.1",
27
+ "@atproto/repo": "^0.10.0",
28
+ "@atproto/syntax": "^0.6.1",
29
+ "@atproto/xrpc-server": "^0.11.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/ws": "^8.5.4",
@@ -41,7 +41,7 @@
41
41
  }
42
42
  },
43
43
  "scripts": {
44
- "codegen": "lex build --override --indexFile --lexicons ../../lexicons --include com.atproto.sync.subscribeRepos",
44
+ "codegen": "lex build --clear --indexFile --lexicons ../../lexicons --include com.atproto.sync.subscribeRepos",
45
45
  "prebuild": "pnpm run codegen",
46
46
  "build": "tsc --build tsconfig.build.json",
47
47
  "test": "NODE_OPTIONS=--experimental-vm-modules ../dev-infra/with-test-redis-and-db.sh jest"
@@ -33,9 +33,9 @@ import { didAndSeqForEvt } from '../util.js'
33
33
  export type FirehoseOptions = ClientOptions & {
34
34
  idResolver: IdResolver
35
35
 
36
- handleEvent: (evt: Event) => Awaited<void>
36
+ handleEvent: (evt: Event) => void | Promise<void>
37
37
  onError: (err: Error) => void
38
- getCursor?: () => Awaited<number | undefined>
38
+ getCursor?: () => number | undefined | Promise<number | undefined>
39
39
 
40
40
  runner?: EventRunner // should only set getCursor *or* runner
41
41
 
@@ -89,13 +89,13 @@ export class Firehose {
89
89
  method: com.atproto.sync.subscribeRepos.$lxm,
90
90
  signal: this.abortController.signal,
91
91
  getParams: async () => {
92
- const getCursorFn = () =>
93
- this.opts.runner?.getCursor() ?? this.opts.getCursor
94
- if (!getCursorFn) {
95
- return undefined
92
+ let cursor: number | undefined
93
+ if (this.opts.runner) {
94
+ cursor = await this.opts.runner.getCursor()
95
+ } else if (this.opts.getCursor) {
96
+ cursor = await this.opts.getCursor()
96
97
  }
97
- const cursor = await getCursorFn()
98
- return { cursor }
98
+ return cursor === undefined ? undefined : { cursor }
99
99
  },
100
100
  validate: (value: unknown) => {
101
101
  const result = com.atproto.sync.subscribeRepos.$message.safeParse(value)
@@ -1,5 +1,5 @@
1
1
  export interface EventRunner {
2
- getCursor(): Awaited<number | undefined>
2
+ getCursor(): number | undefined | Promise<number | undefined>
3
3
  trackEvent(
4
4
  did: string,
5
5
  seq: number,
@@ -29,41 +29,48 @@ describe('EventRunner utils', () => {
29
29
  describe('MemoryRunner', () => {
30
30
  it('performs work in parallel across partitions, serial within a partition.', async () => {
31
31
  const runner = new MemoryRunner({ concurrency: Infinity })
32
- const complete: number[] = []
32
+ const complete: {
33
+ 1: number[]
34
+ 2: number[]
35
+ } = {
36
+ 1: [],
37
+ 2: [],
38
+ }
33
39
  // partition 1 items start slow but get faster: slow should still complete first.
34
40
  runner.addTask('1', async () => {
35
41
  await wait(30)
36
- complete.push(11)
42
+ complete[1].push(1)
37
43
  })
38
44
  runner.addTask('1', async () => {
39
45
  await wait(20)
40
- complete.push(12)
46
+ complete[1].push(2)
41
47
  })
42
48
  runner.addTask('1', async () => {
43
- await wait(1)
44
- complete.push(13)
49
+ complete[1].push(3)
45
50
  })
46
51
  expect(runner.partitions.size).toEqual(1)
47
52
  // partition 2 items complete quickly except the last, which is slowest of all events.
48
53
  runner.addTask('2', async () => {
49
54
  await wait(1)
50
- complete.push(21)
55
+ complete[2].push(1)
51
56
  })
52
57
  runner.addTask('2', async () => {
53
58
  await wait(1)
54
- complete.push(22)
59
+ complete[2].push(2)
55
60
  })
56
61
  runner.addTask('2', async () => {
57
- await wait(1)
58
- complete.push(23)
62
+ complete[2].push(3)
59
63
  })
60
64
  runner.addTask('2', async () => {
61
65
  await wait(60)
62
- complete.push(24)
66
+ complete[2].push(4)
63
67
  })
64
68
  expect(runner.partitions.size).toEqual(2)
65
69
  await runner.mainQueue.onIdle()
66
- expect(complete).toEqual([21, 22, 23, 11, 12, 13, 24])
70
+ expect(complete).toEqual({
71
+ 1: [1, 2, 3],
72
+ 2: [1, 2, 3, 4],
73
+ })
67
74
  expect(runner.partitions.size).toEqual(0)
68
75
  })
69
76
 
@@ -1 +1 @@
1
- {"root":["./src/events.ts","./src/index.ts","./src/util.ts","./src/firehose/index.ts","./src/lexicons/com.ts","./src/lexicons/index.ts","./src/lexicons/com/atproto.ts","./src/lexicons/com/atproto/sync.ts","./src/lexicons/com/atproto/sync/subscriberepos.defs.ts","./src/lexicons/com/atproto/sync/subscriberepos.ts","./src/runner/consecutive-list.ts","./src/runner/index.ts","./src/runner/memory-runner.ts","./src/runner/types.ts"],"version":"6.0.3"}
1
+ {"root":["./src/events.ts","./src/index.ts","./src/util.ts","./src/firehose/index.ts","./src/lexicons/com.ts","./src/lexicons/index.ts","./src/lexicons/com/atproto.ts","./src/lexicons/com/atproto/sync.ts","./src/lexicons/com/atproto/sync/subscribeRepos.defs.ts","./src/lexicons/com/atproto/sync/subscribeRepos.ts","./src/runner/consecutive-list.ts","./src/runner/index.ts","./src/runner/memory-runner.ts","./src/runner/types.ts"],"version":"6.0.3"}