@atproto/sync 0.3.0 → 0.3.2

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,5 +1,29 @@
1
1
  # @atproto/sync
2
2
 
3
+ ## 0.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4967](https://github.com/bluesky-social/atproto/pull/4967) [`9fc720c`](https://github.com/bluesky-social/atproto/commit/9fc720ce75f3ee88a5e48a9be919b07c7647f6f5) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Use TypeScript 7 to build package
8
+
9
+ - Updated dependencies [[`9fc720c`](https://github.com/bluesky-social/atproto/commit/9fc720ce75f3ee88a5e48a9be919b07c7647f6f5)]:
10
+ - @atproto/xrpc-server@0.11.2
11
+ - @atproto/identity@0.5.1
12
+ - @atproto/lex@0.1.4
13
+ - @atproto/common@0.6.3
14
+ - @atproto/syntax@0.6.2
15
+ - @atproto/repo@0.10.1
16
+
17
+ ## 0.3.1
18
+
19
+ ### Patch Changes
20
+
21
+ - [#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
22
+
23
+ - Updated dependencies [[`e6c6343`](https://github.com/bluesky-social/atproto/commit/e6c6343bd3727455bd0da12300bb4929a944e4f1), [`25e0233`](https://github.com/bluesky-social/atproto/commit/25e02339a383740e762c9a9633a701d2fb0cab86)]:
24
+ - @atproto/common@0.6.1
25
+ - @atproto/lex@0.1.1
26
+
3
27
  ## 0.3.0
4
28
 
5
29
  ### Minor Changes
@@ -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,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGhD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,UAAU,EAAE,UAAU,CAAA;IAEtB,WAAW,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1C,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAA;IAC7B,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAE7C,MAAM,CAAC,EAAE,WAAW,CAAA;IAEpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,0BAA0B,CAAC,EAAE,MAAM,CAAA;IAEnC,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAEhC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,qBAAa,QAAQ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AAQ,gCAE5C,OAAO,CAAC,WAAW,GAAG,IAAI,CAe5B,CAAA;AAeD,eAAO,MAAM,YAAY,QAClB,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,KAC3C,UAAU,GAAG,SAUf,CAAA;AAMD,qBAAa,uBAAwB,SAAQ,KAAK;IAGvC,KAAK,EAAE,OAAO;IAFvB,YACE,GAAG,EAAE,OAAO,EACL,KAAK,EAAE,OAAO,EAGtB;CACF;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAGlC,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ;IAFxD,YACE,GAAG,EAAE,OAAO,EACL,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAGvD;CACF;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,YAAY,GAAG,EAAE,OAAO,EAEvB;CACF;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IAGpC,KAAK,EAAE,KAAK;IAFrB,YACE,GAAG,EAAE,OAAO,EACL,KAAK,EAAE,KAAK,EAGpB;CACF"}
@@ -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":[],"m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AAG,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) => 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"],"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,MAAM,OAAO,QAAQ;IAMnB,YAAmB,IAAqB;QAArB,SAAI,GAAJ,IAAI,CAAiB;QAFhC,oBAAe,GAAsC,IAAI,CAAA;QAG/D,IAAI,CAAC,YAAY,GAAG,gBAAgB,EAAE,CAAA;QACtC,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,EAAE,CAAA;QAC5C,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAC5C,MAAM,IAAI,K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AC,GAAG,CAAC,MAAM,CAAC;QAAE,OAAM;IACpD,OAAO;QACL,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,MAAM,EAAE,GAAG,CAAC,MAAmC;KAChD,CAAA;AACH,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,CAAC,GAAW,EAAwB,EAAE;IAC1D,OAAO,CAAC,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AAC3E,CAAC,CAAA;AAED,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YACE,GAAY,EACL,KAAc;QAErB,KAAK,CAAC,4CAA4C,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;qBAF5D,KAAK;IAGd,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;qBAFpE,KAAK;IAGd,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;qBAFjD,KAAK;IAGd,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,3 +1,3 @@
1
1
  export * from './subscribeRepos.defs.js';
2
- export * as $defs from './subscribeRepos.defs.js';
2
+ export { main as default } from './subscribeRepos.defs.js';
3
3
  //# sourceMappingURL=subscribeRepos.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"subscribeRepos.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/sync/subscribeRepos.ts"],"names":[],"mappings":"AAIA,cAAc,0BAA0B,CAAA;AACxC,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAA"}
1
+ {"version":3,"file":"subscribeRepos.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/sync/subscribeRepos.ts"],"names":[],"mappings":"AAIA,cAAc,0BAA0B,CAAA;AACxC,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,0BAA0B,CAAA"}
@@ -1,16 +1,18 @@
1
1
  import { l } from '@atproto/lex';
2
2
  declare const $nsid = "com.atproto.sync.subscribeRepos";
3
3
  export { $nsid };
4
+ export declare const $params: l.ParamsSchema<{
5
+ readonly cursor: l.OptionalSchema<l.IntegerSchema>;
6
+ }>;
7
+ export type $Params = l.InferOutput<typeof $params>;
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>;
9
+ export type $Message = l.InferOutput<typeof $message>;
4
10
  /** 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
11
  declare const main: l.Subscription<"com.atproto.sync.subscribeRepos", l.ParamsSchema<{
6
12
  readonly cursor: l.OptionalSchema<l.IntegerSchema>;
7
13
  }>, 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>, readonly ["FutureCursor", "ConsumerTooSlow"]>;
8
14
  export { main };
9
- export type $Params = l.InferMethodParams<typeof main>;
10
- 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>;
15
+ export declare const $lxm = "com.atproto.sync.subscribeRepos";
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;IAEhD;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IAEX;;OAEG;IAC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AA,MAAM,MAAM,4FAWX,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
@@ -4,69 +4,85 @@
4
4
  import { l } from '@atproto/lex';
5
5
  const $nsid = 'com.atproto.sync.subscribeRepos';
6
6
  export { $nsid };
7
+ export const $params = /*#__PURE__*/ l.params({
8
+ cursor: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.integer()),
9
+ });
10
+ export const $message = /*#__PURE__*/ l.typedUnion([
11
+ /*#__PURE__*/ l.typedRef((() => commit)),
12
+ /*#__PURE__*/ l.typedRef((() => sync)),
13
+ /*#__PURE__*/ l.typedRef((() => identity)),
14
+ /*#__PURE__*/ l.typedRef((() => account)),
15
+ /*#__PURE__*/ l.typedRef((() => info)),
16
+ ], false);
7
17
  /** 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([
9
- l.typedRef((() => commit)),
10
- l.typedRef((() => sync)),
11
- l.typedRef((() => identity)),
12
- l.typedRef((() => account)),
13
- l.typedRef((() => info)),
14
- ], false), ['FutureCursor', 'ConsumerTooSlow']);
18
+ const main = /*#__PURE__*/ l.subscription($nsid, $params, $message, [
19
+ 'FutureCursor',
20
+ 'ConsumerTooSlow',
21
+ ]);
15
22
  export { main };
16
- export const $lxm = main.nsid, $params = main.parameters, $message = main.message;
23
+ export const $lxm = $nsid;
17
24
  /** 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
- const commit = l.typedObject($nsid, 'commit', l.object({
19
- seq: l.integer(),
20
- rebase: l.boolean(),
21
- tooBig: l.boolean(),
22
- repo: l.string({ format: 'did' }),
23
- commit: l.cid(),
24
- rev: l.string({ format: 'tid' }),
25
- since: l.nullable(l.string({ format: 'tid' })),
26
- blocks: l.bytes({ maxLength: 2000000 }),
27
- ops: l.array(l.ref((() => repoOp)), { maxLength: 200 }),
28
- blobs: l.array(l.cid()),
29
- prevData: l.optional(l.cid()),
30
- time: l.string({ format: 'datetime' }),
25
+ const commit = /*#__PURE__*/ l.typedObject($nsid, 'commit',
26
+ /*#__PURE__*/ l.object({
27
+ seq: /*#__PURE__*/ l.integer(),
28
+ rebase: /*#__PURE__*/ l.boolean(),
29
+ tooBig: /*#__PURE__*/ l.boolean(),
30
+ repo: /*#__PURE__*/ l.string({ format: 'did' }),
31
+ commit: /*#__PURE__*/ l.cid(),
32
+ rev: /*#__PURE__*/ l.string({ format: 'tid' }),
33
+ since: /*#__PURE__*/ l.nullable(/*#__PURE__*/ l.string({ format: 'tid' })),
34
+ blocks: /*#__PURE__*/ l.bytes({ maxLength: 2000000 }),
35
+ ops: /*#__PURE__*/ l.array(
36
+ /*#__PURE__*/ l.ref((() => repoOp)), { maxLength: 200 }),
37
+ blobs: /*#__PURE__*/ l.array(/*#__PURE__*/ l.cid()),
38
+ prevData: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.cid()),
39
+ time: /*#__PURE__*/ l.string({ format: 'datetime' }),
31
40
  }));
32
41
  export { commit };
33
42
  /** 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. */
34
- const sync = l.typedObject($nsid, 'sync', l.object({
35
- seq: l.integer(),
36
- did: l.string({ format: 'did' }),
37
- blocks: l.bytes({ maxLength: 10000 }),
38
- rev: l.string(),
39
- time: l.string({ format: 'datetime' }),
43
+ const sync = /*#__PURE__*/ l.typedObject($nsid, 'sync',
44
+ /*#__PURE__*/ l.object({
45
+ seq: /*#__PURE__*/ l.integer(),
46
+ did: /*#__PURE__*/ l.string({ format: 'did' }),
47
+ blocks: /*#__PURE__*/ l.bytes({ maxLength: 10000 }),
48
+ rev: /*#__PURE__*/ l.string(),
49
+ time: /*#__PURE__*/ l.string({ format: 'datetime' }),
40
50
  }));
41
51
  export { sync };
42
52
  /** 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. */
43
- const identity = l.typedObject($nsid, 'identity', l.object({
44
- seq: l.integer(),
45
- did: l.string({ format: 'did' }),
46
- time: l.string({ format: 'datetime' }),
47
- handle: l.optional(l.string({ format: 'handle' })),
53
+ const identity = /*#__PURE__*/ l.typedObject($nsid, 'identity',
54
+ /*#__PURE__*/ l.object({
55
+ seq: /*#__PURE__*/ l.integer(),
56
+ did: /*#__PURE__*/ l.string({ format: 'did' }),
57
+ time: /*#__PURE__*/ l.string({ format: 'datetime' }),
58
+ handle: /*#__PURE__*/ l.optional(
59
+ /*#__PURE__*/ l.string({ format: 'handle' })),
48
60
  }));
49
61
  export { identity };
50
62
  /** 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. */
51
- const account = l.typedObject($nsid, 'account', l.object({
52
- seq: l.integer(),
53
- did: l.string({ format: 'did' }),
54
- time: l.string({ format: 'datetime' }),
55
- active: l.boolean(),
56
- status: l.optional(l.string()),
63
+ const account = /*#__PURE__*/ l.typedObject($nsid, 'account',
64
+ /*#__PURE__*/ l.object({
65
+ seq: /*#__PURE__*/ l.integer(),
66
+ did: /*#__PURE__*/ l.string({ format: 'did' }),
67
+ time: /*#__PURE__*/ l.string({ format: 'datetime' }),
68
+ active: /*#__PURE__*/ l.boolean(),
69
+ status: /*#__PURE__*/ l.optional(
70
+ /*#__PURE__*/ l.string()),
57
71
  }));
58
72
  export { account };
59
- const info = l.typedObject($nsid, 'info', l.object({
60
- name: l.string(),
61
- message: l.optional(l.string()),
73
+ const info = /*#__PURE__*/ l.typedObject($nsid, 'info',
74
+ /*#__PURE__*/ l.object({
75
+ name: /*#__PURE__*/ l.string(),
76
+ message: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
62
77
  }));
63
78
  export { info };
64
79
  /** A repo operation, ie a mutation of a single record. */
65
- const repoOp = l.typedObject($nsid, 'repoOp', l.object({
66
- action: l.string(),
67
- path: l.string(),
68
- cid: l.nullable(l.cid()),
69
- prev: l.optional(l.cid()),
80
+ const repoOp = /*#__PURE__*/ l.typedObject($nsid, 'repoOp',
81
+ /*#__PURE__*/ l.object({
82
+ action: /*#__PURE__*/ l.string(),
83
+ path: /*#__PURE__*/ l.string(),
84
+ cid: /*#__PURE__*/ l.nullable(/*#__PURE__*/ l.cid()),
85
+ prev: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.cid()),
70
86
  }));
71
87
  export { repoOp };
72
88
  //# sourceMappingURL=subscribeRepos.defs.js.map
@@ -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,iCAAiC,CAAA;AAE/C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,oVAAoV;AACpV,MAAM,IAAI,GAAG,CAAC,CAAC,YAAY,CACzB,KAAK,EACL,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,EAC7C,CAAC,CAAC,UAAU,CACV;IACE,CAAC,CAAC,QAAQ,CAAS,CAAC,GAAG,EAAE,CAAC,MAAM,CAAQ,CAAC;IACzC,CAAC,CAAC,QAAQ,CAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAQ,CAAC;IACrC,CAAC,CAAC,QAAQ,CAAW,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAQ,CAAC;IAC7C,CAAC,CAAC,QAAQ,CAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAQ,CAAC;IAC3C,CAAC,CAAC,QAAQ,CAAO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AChB,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IACtC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;IACnB,MAAM,EAAE,CAAC,CAAC,QAAQ,CAChB,CAAC,CAAC,MAAM,EASJ,CACL;CACF,CAAC,CACH,CAAA;AAED,OAAO,EAAE,OAAO,EAAE,CAAA;AAUlB,MAAM,IAAI,GAAG,CAAC,CAAC,WAAW,CACxB,KAAK,EACL,MAAM,EACN,CAAC,CAAC,MAAM,CAAC;IACP,IAAI,EAAE,CAAC,CAAC,MAAM,EAAuC;IACrD,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,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\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":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAEhC,MAAM,KAAK,GAAG,iCAAiC,CAAA;AAE/C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;CAC5D,CAAC,CAAA;AAIF,MAAM,CAAC,MAAM,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,UAAU,CAChD;IACE,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAS,CAAC,GAAG,EAAE,CAAC,MAAM,CAAQ,CAAC;IACvD,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAQ,CAAC;IACnD,aAAa,C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nE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CAC5D,CAAC,CACH,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,CAAA;AAqBf,0DAA0D;AAC1D,MAAM,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,WAAW,CACxC,KAAK,EACL,QAAQ;AACR,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC;IACrB,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,EAE1B;IACJ,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,EAAE;IAC9B,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACpD,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;CACtD,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 $params = /*#__PURE__*/ l.params({\n cursor: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.integer()),\n})\n\nexport type $Params = l.InferOutput<typeof $params>\n\nexport const $message = /*#__PURE__*/ l.typedUnion(\n [\n /*#__PURE__*/ l.typedRef<Commit>((() => commit) as any),\n /*#__PURE__*/ l.typedRef<Sync>((() => sync) as any),\n /*#__PURE__*/ l.typedRef<Identity>((() => identity) as any),\n /*#__PURE__*/ l.typedRef<Account>((() => account) as any),\n /*#__PURE__*/ l.typedRef<Info>((() => info) as any),\n ],\n false,\n)\n\nexport type $Message = l.InferOutput<typeof $message>\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 = /*#__PURE__*/ l.subscription($nsid, $params, $message, [\n 'FutureCursor',\n 'ConsumerTooSlow',\n])\n\nexport { main }\n\nexport const $lxm = $nsid\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 = /*#__PURE__*/ l.typedObject<Commit>(\n $nsid,\n 'commit',\n /*#__PURE__*/ l.object({\n seq: /*#__PURE__*/ l.integer(),\n rebase: /*#__PURE__*/ l.boolean(),\n tooBig: /*#__PURE__*/ l.boolean(),\n repo: /*#__PURE__*/ l.string({ format: 'did' }),\n commit: /*#__PURE__*/ l.cid(),\n rev: /*#__PURE__*/ l.string({ format: 'tid' }),\n since: /*#__PURE__*/ l.nullable(/*#__PURE__*/ l.string({ format: 'tid' })),\n blocks: /*#__PURE__*/ l.bytes({ maxLength: 2000000 }),\n ops: /*#__PURE__*/ l.array(\n /*#__PURE__*/ l.ref<RepoOp>((() => repoOp) as any),\n { maxLength: 200 },\n ),\n blobs: /*#__PURE__*/ l.array(/*#__PURE__*/ l.cid()),\n prevData: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.cid()),\n time: /*#__PURE__*/ 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 = /*#__PURE__*/ l.typedObject<Sync>(\n $nsid,\n 'sync',\n /*#__PURE__*/ l.object({\n seq: /*#__PURE__*/ l.integer(),\n did: /*#__PURE__*/ l.string({ format: 'did' }),\n blocks: /*#__PURE__*/ l.bytes({ maxLength: 10000 }),\n rev: /*#__PURE__*/ l.string(),\n time: /*#__PURE__*/ 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 = /*#__PURE__*/ l.typedObject<Identity>(\n $nsid,\n 'identity',\n /*#__PURE__*/ l.object({\n seq: /*#__PURE__*/ l.integer(),\n did: /*#__PURE__*/ l.string({ format: 'did' }),\n time: /*#__PURE__*/ l.string({ format: 'datetime' }),\n handle: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string({ format: 'handle' }),\n ),\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 = /*#__PURE__*/ l.typedObject<Account>(\n $nsid,\n 'account',\n /*#__PURE__*/ l.object({\n seq: /*#__PURE__*/ l.integer(),\n did: /*#__PURE__*/ l.string({ format: 'did' }),\n time: /*#__PURE__*/ l.string({ format: 'datetime' }),\n active: /*#__PURE__*/ l.boolean(),\n status: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ 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 = /*#__PURE__*/ l.typedObject<Info>(\n $nsid,\n 'info',\n /*#__PURE__*/ l.object({\n name: /*#__PURE__*/ l.string<{ knownValues: ['OutdatedCursor'] }>(),\n message: /*#__PURE__*/ l.optional(/*#__PURE__*/ 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 = /*#__PURE__*/ l.typedObject<RepoOp>(\n $nsid,\n 'repoOp',\n /*#__PURE__*/ l.object({\n action: /*#__PURE__*/ l.string<{\n knownValues: ['create', 'update', 'delete']\n }>(),\n path: /*#__PURE__*/ l.string(),\n cid: /*#__PURE__*/ l.nullable(/*#__PURE__*/ l.cid()),\n prev: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.cid()),\n }),\n)\n\nexport { repoOp }\n"]}
@@ -2,5 +2,5 @@
2
2
  * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
3
3
  */
4
4
  export * from './subscribeRepos.defs.js';
5
- export * as $defs from './subscribeRepos.defs.js';
5
+ export { main as default } from './subscribeRepos.defs.js';
6
6
  //# sourceMappingURL=subscribeRepos.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"subscribeRepos.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/sync/subscribeRepos.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,0BAA0B,CAAA;AACxC,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * from './subscribeRepos.defs.js'\nexport * as $defs from './subscribeRepos.defs.js'\n"]}
1
+ {"version":3,"file":"subscribeRepos.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/sync/subscribeRepos.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,0BAA0B,CAAA;AACxC,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,0BAA0B,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * from './subscribeRepos.defs.js'\nexport { main as default } from './subscribeRepos.defs.js'\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"consecutive-list.d.ts","sourceRoot":"","sources":["../../src/runner/consecutive-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,qBAAa,eAAe,CAAC,CAAC;IAC5B,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAK;IAE/B,IAAI,CAAC,KAAK,EAAE,CAAC;IAMb,QAAQ,IAAI,CAAC,EAAE;CAOhB;AAED,qBAAa,eAAe,CAAC,CAAC;IAG1B,OAAO,CAAC,WAAW;IACZ,KAAK,EAAE,CAAC;IAHjB,UAAU,UAAQ;gBAER,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,EAChC,KAAK,EAAE,CAAC;IAGjB,QAAQ;CAIT"}
1
+ {"version":3,"file":"consecutive-list.d.ts","sourceRoot":"","sources":["../../src/runner/consecutive-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;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AC,YAAY;IAUd,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;IAejE,UAAU;IAIV,OAAO;CAMd"}
1
+ {"version":3,"file":"memory-runner.d.ts","sourceRoot":"","sources":["../../src/runner/memory-runner.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,KAAK,KAAK,GAAG,YAAY,CAAC,OAAO,MAAM,CAAC,CAAA;AAIxC,qBAAa,YAAa,YAAW,WAAW;IAM3B,IAAI,EAAE,mBAAmB;IAL5C,WAAW,0BAAgC;IAC3C,SAAS,EAAE,KAAK,CAAA;IAChB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAY;IAC1C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAE1B,YAAmB,IAAI,GAAE,mBAAwB,EAGhD;IAED,SAAS,uBAER;IAEK,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,iBAK3D;IAED,OAAO,CAAC,YAAY;IAUd,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,iBAatE;IAEK,UAAU,kBAEf;IAEK,OAAO,kBAKZ;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"memory-runner.js","sourceRoot":"","s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G,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;QAC7C,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,GAAW,EAAE,GAAW,EAAE,OAA4B;QACrE,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ;YAAE,OAAM;QACnC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACvC,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE;YACjC,MAAM,OAAO,EAAE,CAAA;YACf,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;YACrC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;gBACpB,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;oBACxB,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;gBACxC,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAA;IAC/B,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;QACtB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;QACtB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;QACzC,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAA;IAC/B,CAAC;CACF","sourcesContent":["import PQueue from 'p-queue'\nimport { ConsecutiveList } from './consecutive-list.js'\nimport { EventRunner } from './types.js'\n\nexport type MemoryRunnerOptions = {\n setCursor?: (cursor: number) => Promise<void>\n concurrency?: number\n startCursor?: number\n}\n\ntype Queue = InstanceType<typeof PQueue>\n\n// A queue with arbitrarily many partitions, each processing work sequentially.\n// Partitions are created lazily and taken out of memory when they go idle.\nexport class MemoryRunner implements EventRunner {\n consecutive = new ConsecutiveList<number>()\n mainQueue: Queue\n partitions: Map<string, Queue> = new Map()\n cursor: number | undefined\n\n constructor(public opts: MemoryRunnerOptions = {}) {\n this.mainQueue = new PQueue({ concurrency: opts.concurrency ?? Infinity })\n this.cursor = opts.startCursor\n }\n\n getCursor() {\n return this.cursor\n }\n\n async addTask(partitionId: string, task: () => Promise<void>) {\n if (this.mainQueue.isPaused) return\n return this.mainQueue.add(() => {\n return this.getPartition(partitionId).add(task)\n })\n }\n\n private getPartition(partitionId: string) {\n let partition = this.partitions.get(partitionId)\n if (!partition) {\n partition = new PQueue({ concurrency: 1 })\n partition.once('idle', () => this.partitions.delete(partitionId))\n this.partitions.set(partitionId, partition)\n }\n return partition\n }\n\n async trackEvent(did: string, seq: number, handler: () => Promise<void>) {\n if (this.mainQueue.isPaused) return\n const item = this.consecutive.push(seq)\n await this.addTask(did, async () => {\n await handler()\n const latest = item.complete().at(-1)\n if (latest !== undefined) {\n this.cursor = latest\n if (this.opts.setCursor) {\n await this.opts.setCursor(this.cursor)\n }\n }\n })\n }\n\n async processAll() {\n await this.mainQueue.onIdle()\n }\n\n async destroy() {\n this.mainQueue.pause()\n this.mainQueue.clear()\n this.partitions.forEach((p) => p.clear())\n await this.mainQueue.onIdle()\n }\n}\n"]}
1
+ {"version":3,"file":"memory-runner.js","sourceRoot":"","sources":["../../src/runner/memory-runner.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAWvD,+EAA+E;AAC/E,2EAA2E;AAC3E,MAAM,OAAO,YAAY;IAMvB,YAAmB,IAAI,GAAwB,EAAE;QAA9B,SAA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GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACvC,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE;YACjC,MAAM,OAAO,EAAE,CAAA;YACf,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;YACrC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;gBACpB,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;oBACxB,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;gBACxC,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAA;IAC/B,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;QACtB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;QACtB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;QACzC,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAA;IAC/B,CAAC;CACF","sourcesContent":["import PQueue from 'p-queue'\nimport { ConsecutiveList } from './consecutive-list.js'\nimport { EventRunner } from './types.js'\n\nexport type MemoryRunnerOptions = {\n setCursor?: (cursor: number) => Promise<void>\n concurrency?: number\n startCursor?: number\n}\n\ntype Queue = InstanceType<typeof PQueue>\n\n// A queue with arbitrarily many partitions, each processing work sequentially.\n// Partitions are created lazily and taken out of memory when they go idle.\nexport class MemoryRunner implements EventRunner {\n consecutive = new ConsecutiveList<number>()\n mainQueue: Queue\n partitions: Map<string, Queue> = new Map()\n cursor: number | undefined\n\n constructor(public opts: MemoryRunnerOptions = {}) {\n this.mainQueue = new PQueue({ concurrency: opts.concurrency ?? Infinity })\n this.cursor = opts.startCursor\n }\n\n getCursor() {\n return this.cursor\n }\n\n async addTask(partitionId: string, task: () => Promise<void>) {\n if (this.mainQueue.isPaused) return\n return this.mainQueue.add(() => {\n return this.getPartition(partitionId).add(task)\n })\n }\n\n private getPartition(partitionId: string) {\n let partition = this.partitions.get(partitionId)\n if (!partition) {\n partition = new PQueue({ concurrency: 1 })\n partition.once('idle', () => this.partitions.delete(partitionId))\n this.partitions.set(partitionId, partition)\n }\n return partition\n }\n\n async trackEvent(did: string, seq: number, handler: () => Promise<void>) {\n if (this.mainQueue.isPaused) return\n const item = this.consecutive.push(seq)\n await this.addTask(did, async () => {\n await handler()\n const latest = item.complete().at(-1)\n if (latest !== undefined) {\n this.cursor = latest\n if (this.opts.setCursor) {\n await this.opts.setCursor(this.cursor)\n }\n }\n })\n }\n\n async processAll() {\n await this.mainQueue.onIdle()\n }\n\n async destroy() {\n this.mainQueue.pause()\n this.mainQueue.clear()\n this.partitions.forEach((p) => p.clear())\n await this.mainQueue.onIdle()\n }\n}\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAEzC,eAAO,MAAM,eAAe,GAC1B,KAAK,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,KAC5C;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,SAWjC,CAAA"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAEzC,eAAO,MAAM,eAAe,QACrB,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,KAC5C;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,SAWjC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/sync",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "license": "MIT",
5
5
  "description": "atproto sync library",
6
6
  "keywords": [
@@ -21,17 +21,16 @@
21
21
  "dependencies": {
22
22
  "p-queue": "^8.0.0",
23
23
  "ws": "^8.12.0",
24
- "@atproto/common": "^0.6.0",
25
- "@atproto/identity": "^0.5.0",
26
- "@atproto/lex": "^0.1.0",
27
- "@atproto/repo": "^0.10.0",
28
- "@atproto/syntax": "^0.6.0",
29
- "@atproto/xrpc-server": "^0.11.0"
24
+ "@atproto/common": "^0.6.3",
25
+ "@atproto/identity": "^0.5.1",
26
+ "@atproto/lex": "^0.1.4",
27
+ "@atproto/syntax": "^0.6.2",
28
+ "@atproto/xrpc-server": "^0.11.2",
29
+ "@atproto/repo": "^0.10.1"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/ws": "^8.5.4",
33
- "jest": "^30.0.0",
34
- "typescript": "^6.0.3"
33
+ "jest": "^30.0.0"
35
34
  },
36
35
  "type": "module",
37
36
  "exports": {
@@ -43,7 +42,7 @@
43
42
  "scripts": {
44
43
  "codegen": "lex build --clear --indexFile --lexicons ../../lexicons --include com.atproto.sync.subscribeRepos",
45
44
  "prebuild": "pnpm run codegen",
46
- "build": "tsc --build tsconfig.build.json",
45
+ "build": "tsgo --build tsconfig.build.json",
47
46
  "test": "NODE_OPTIONS=--experimental-vm-modules ../dev-infra/with-test-redis-and-db.sh jest"
48
47
  }
49
48
  }
@@ -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,
@@ -130,10 +130,7 @@ describe('firehose', () => {
130
130
  it('does not naively pass through invalid handle evts', async () => {
131
131
  const evtsPromise = createAndReadFirehose(1)
132
132
  await wait(10) // give the websocket just a second to spin up
133
- await network.pds.ctx.sequencer.sequenceIdentityEvt(
134
- alice,
135
- 'bad-handle.test',
136
- )
133
+ await network.pds.ctx.sequencer.sequenceIdentity(alice, 'bad-handle.test')
137
134
  const evts = await evtsPromise
138
135
  expect(evts.at(0)).toMatchObject({ handle: 'alice.test' })
139
136
  })
@@ -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
 
@@ -2,7 +2,7 @@
2
2
  "extends": "../../tsconfig/node.json",
3
3
  "compilerOptions": {
4
4
  "rootDir": "./src",
5
- "outDir": "./dist"
5
+ "outDir": "./dist",
6
6
  },
7
- "include": ["./src"]
7
+ "include": ["./src"],
8
8
  }
@@ -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
+ {"version":"7.0.0-dev.20260614.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"]}
package/tsconfig.json CHANGED
@@ -2,6 +2,6 @@
2
2
  "include": [],
3
3
  "references": [
4
4
  { "path": "./tsconfig.build.json" },
5
- { "path": "./tsconfig.tests.json" }
6
- ]
5
+ { "path": "./tsconfig.tests.json" },
6
+ ],
7
7
  }
@@ -2,7 +2,7 @@
2
2
  "extends": "../../tsconfig/tests.json",
3
3
  "compilerOptions": {
4
4
  "rootDir": ".",
5
- "noUnusedLocals": false
5
+ "noUnusedLocals": false,
6
6
  },
7
- "include": ["./tests"]
7
+ "include": ["./tests"],
8
8
  }