@atproto/sync 0.1.34 → 0.1.36
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 +13 -0
- package/dist/events.js.map +1 -1
- package/dist/firehose/index.d.ts +3 -2
- package/dist/firehose/index.d.ts.map +1 -1
- package/dist/firehose/index.js +37 -10
- package/dist/firehose/index.js.map +1 -1
- package/dist/firehose/lexicons.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/runner/consecutive-list.js.map +1 -1
- package/dist/runner/index.js.map +1 -1
- package/dist/runner/memory-runner.js.map +1 -1
- package/dist/runner/types.js.map +1 -1
- package/dist/util.js.map +1 -1
- package/package.json +2 -2
- package/src/firehose/index.ts +30 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atproto/sync
|
|
2
2
|
|
|
3
|
+
## 0.1.36
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4038](https://github.com/bluesky-social/atproto/pull/4038) [`756ab5d87`](https://github.com/bluesky-social/atproto/commit/756ab5d87fea75e8648a6bdd545d8b441bfb2dd6) Thanks [@knotbin](https://github.com/knotbin)! - filtercollections wildcard endings
|
|
8
|
+
|
|
9
|
+
## 0.1.35
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`8dd77bad2`](https://github.com/bluesky-social/atproto/commit/8dd77bad2fdee20e39d3787198d960c19d8df3d0)]:
|
|
14
|
+
- @atproto/repo@0.8.10
|
|
15
|
+
|
|
3
16
|
## 0.1.34
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"","sourcesContent":["import type { CID } from 'multiformats/cid'\nimport { DidDocument } from '@atproto/identity'\nimport type { RepoRecord } from '@atproto/lexicon'\nimport { BlockMap } from '@atproto/repo'\nimport { AtUri } from '@atproto/syntax'\n\nexport type Event = CommitEvt | SyncEvt | IdentityEvt | AccountEvt\n\nexport type CommitMeta = {\n seq: number\n time: string\n commit: CID\n blocks: BlockMap\n rev: string\n uri: AtUri\n did: string\n collection: string\n rkey: string\n}\n\nexport type CommitEvt = Create | Update | Delete\n\nexport type Create = CommitMeta & {\n event: 'create'\n record: RepoRecord\n cid: CID\n}\n\nexport type Update = CommitMeta & {\n event: 'update'\n record: RepoRecord\n cid: CID\n}\n\nexport type Delete = CommitMeta & {\n event: 'delete'\n}\n\nexport type SyncEvt = {\n seq: number\n time: string\n event: 'sync'\n did: string\n cid: CID\n rev: string\n blocks: BlockMap\n}\n\nexport type IdentityEvt = {\n seq: number\n time: string\n event: 'identity'\n did: string\n handle?: string\n didDocument?: DidDocument\n}\n\nexport type AccountEvt = {\n seq: number\n time: string\n event: 'account'\n did: string\n active: boolean\n status?: AccountStatus\n}\n\nexport type AccountStatus =\n | 'takendown'\n | 'suspended'\n | 'deleted'\n | 'deactivated'\n"]}
|
package/dist/firehose/index.d.ts
CHANGED
|
@@ -24,14 +24,15 @@ export declare class Firehose {
|
|
|
24
24
|
private sub;
|
|
25
25
|
private abortController;
|
|
26
26
|
private destoryDefer;
|
|
27
|
+
private matchCollection;
|
|
27
28
|
constructor(opts: FirehoseOptions);
|
|
28
29
|
start(): any;
|
|
29
30
|
private parseEvt;
|
|
30
31
|
private processEvt;
|
|
31
32
|
destroy(): Promise<void>;
|
|
32
33
|
}
|
|
33
|
-
export declare const parseCommitAuthenticated: (idResolver: IdResolver, evt: Commit,
|
|
34
|
-
export declare const parseCommitUnauthenticated: (evt: Commit,
|
|
34
|
+
export declare const parseCommitAuthenticated: (idResolver: IdResolver, evt: Commit, matchCollection?: ((col: string) => boolean) | null, forceKeyRefresh?: boolean) => Promise<CommitEvt[]>;
|
|
35
|
+
export declare const parseCommitUnauthenticated: (evt: Commit, matchCollection?: ((col: string) => boolean) | null) => Promise<CommitEvt[]>;
|
|
35
36
|
export declare const parseSync: (evt: Sync) => Promise<SyncEvt | null>;
|
|
36
37
|
export declare const parseIdentity: (idResolver: IdResolver, evt: Identity, unauthenticated?: boolean) => Promise<IdentityEvt | null>;
|
|
37
38
|
export declare const parseAccount: (evt: Account) => AccountEvt | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/firehose/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAEvC,OAAO,EAEL,UAAU,EAEX,MAAM,mBAAmB,CAAA;AAY1B,OAAO,EACL,UAAU,EAEV,SAAS,EAET,KAAK,EACL,WAAW,EACX,OAAO,EACR,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,SAAS,EAEd,KAAK,IAAI,EAMV,MAAM,YAAY,CAAA;AAEnB,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,OA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AS;gBADvB,GAAG,EAAE,OAAO,EACL,KAAK,EAAE,SAAS;CAI1B;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"}
|
package/dist/firehose/index.js
CHANGED
|
@@ -34,11 +34,38 @@ class Firehose {
|
|
|
34
34
|
writable: true,
|
|
35
35
|
value: void 0
|
|
36
36
|
});
|
|
37
|
+
Object.defineProperty(this, "matchCollection", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: null
|
|
42
|
+
});
|
|
37
43
|
this.destoryDefer = (0, common_1.createDeferrable)();
|
|
38
44
|
this.abortController = new AbortController();
|
|
39
45
|
if (this.opts.getCursor && this.opts.runner) {
|
|
40
46
|
throw new Error('Must set only `getCursor` or `runner`');
|
|
41
47
|
}
|
|
48
|
+
if (opts.filterCollections) {
|
|
49
|
+
const exact = new Set();
|
|
50
|
+
const prefixes = [];
|
|
51
|
+
for (const pattern of opts.filterCollections) {
|
|
52
|
+
if (pattern.endsWith('.*')) {
|
|
53
|
+
prefixes.push(pattern.slice(0, -2));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
exact.add(pattern);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
this.matchCollection = (col) => {
|
|
60
|
+
if (exact.has(col))
|
|
61
|
+
return true;
|
|
62
|
+
for (const prefix of prefixes) {
|
|
63
|
+
if (col.startsWith(prefix))
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
42
69
|
this.sub = new xrpc_server_1.Subscription({
|
|
43
70
|
...opts,
|
|
44
71
|
service: opts.service ?? 'wss://bsky.network',
|
|
@@ -101,8 +128,8 @@ class Firehose {
|
|
|
101
128
|
try {
|
|
102
129
|
if ((0, lexicons_1.isCommit)(evt) && !this.opts.excludeCommit) {
|
|
103
130
|
return this.opts.unauthenticatedCommits
|
|
104
|
-
? await (0, exports.parseCommitUnauthenticated)(evt, this.
|
|
105
|
-
: await (0, exports.parseCommitAuthenticated)(this.opts.idResolver, evt, this.
|
|
131
|
+
? await (0, exports.parseCommitUnauthenticated)(evt, this.matchCollection)
|
|
132
|
+
: await (0, exports.parseCommitAuthenticated)(this.opts.idResolver, evt, this.matchCollection);
|
|
106
133
|
}
|
|
107
134
|
else if ((0, lexicons_1.isAccount)(evt) && !this.opts.excludeAccount) {
|
|
108
135
|
const parsed = (0, exports.parseAccount)(evt);
|
|
@@ -142,9 +169,9 @@ class Firehose {
|
|
|
142
169
|
}
|
|
143
170
|
}
|
|
144
171
|
exports.Firehose = Firehose;
|
|
145
|
-
const parseCommitAuthenticated = async (idResolver, evt,
|
|
172
|
+
const parseCommitAuthenticated = async (idResolver, evt, matchCollection, forceKeyRefresh = false) => {
|
|
146
173
|
const did = evt.repo;
|
|
147
|
-
const ops = maybeFilterOps(evt.ops,
|
|
174
|
+
const ops = maybeFilterOps(evt.ops, matchCollection);
|
|
148
175
|
if (ops.length === 0) {
|
|
149
176
|
return [];
|
|
150
177
|
}
|
|
@@ -167,7 +194,7 @@ const parseCommitAuthenticated = async (idResolver, evt, filterCollections, forc
|
|
|
167
194
|
}
|
|
168
195
|
catch (err) {
|
|
169
196
|
if (err instanceof repo_1.RepoVerificationError && !forceKeyRefresh) {
|
|
170
|
-
return (0, exports.parseCommitAuthenticated)(idResolver, evt,
|
|
197
|
+
return (0, exports.parseCommitAuthenticated)(idResolver, evt, matchCollection, true);
|
|
171
198
|
}
|
|
172
199
|
throw err;
|
|
173
200
|
}
|
|
@@ -184,17 +211,17 @@ const parseCommitAuthenticated = async (idResolver, evt, filterCollections, forc
|
|
|
184
211
|
});
|
|
185
212
|
};
|
|
186
213
|
exports.parseCommitAuthenticated = parseCommitAuthenticated;
|
|
187
|
-
const parseCommitUnauthenticated = async (evt,
|
|
188
|
-
const ops = maybeFilterOps(evt.ops,
|
|
214
|
+
const parseCommitUnauthenticated = async (evt, matchCollection) => {
|
|
215
|
+
const ops = maybeFilterOps(evt.ops, matchCollection);
|
|
189
216
|
return formatCommitOps(evt, ops);
|
|
190
217
|
};
|
|
191
218
|
exports.parseCommitUnauthenticated = parseCommitUnauthenticated;
|
|
192
|
-
const maybeFilterOps = (ops,
|
|
193
|
-
if (!
|
|
219
|
+
const maybeFilterOps = (ops, matchCollection) => {
|
|
220
|
+
if (!matchCollection)
|
|
194
221
|
return ops;
|
|
195
222
|
return ops.filter((op) => {
|
|
196
223
|
const { collection } = (0, repo_1.parseDataKey)(op.path);
|
|
197
|
-
return
|
|
224
|
+
return matchCollection(collection);
|
|
198
225
|
});
|
|
199
226
|
};
|
|
200
227
|
const formatCommitOps = async (evt, ops, options) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/firehose/index.ts"],"names":[],"mappings":";;;AAEA,4CAAoE;AACpE,gDAI0B;AAC1B,wCAQsB;AACtB,4CAAuC;AACvC,sDAAmD;AAWnD,kCAAyC;AACzC,yCAYmB;AAwBnB,MAAa,QAAQ;IAKnB,YAAmB,IAAqB;QAA5B;;;;mBAAO,IAAI;WAAiB;QAJhC;;;;;WAA4B;QAC5B;;;;;WAAgC;QAChC;;;;;WAAwB;QAG9B,IAAI,CAAC,YAAY,GAAG,IAAA,yBAAgB,GAAE,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,KAAK,CAAC,uCAAuC,CAAC,CAAA;QAC1D,CAAC;QACD,IAAI,CAAC,GAAG,GAAG,IAAI,0BAAY,CAAC;YAC1B,GAAG,I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{ CID } from 'multiformats/cid'\nimport type { ClientOptions } from 'ws'\nimport { Deferrable, createDeferrable, wait } from '@atproto/common'\nimport {\n DidDocument,\n IdResolver,\n parseToAtprotoDocument,\n} from '@atproto/identity'\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'\nimport { EventRunner } from '../runner'\nimport { didAndSeqForEvt } from '../util'\nimport {\n type Account,\n type Commit,\n type Identity,\n type RepoEvent,\n RepoOp,\n type Sync,\n isAccount,\n isCommit,\n isIdentity,\n isSync,\n isValidRepoEvent,\n} from './lexicons'\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<RepoEvent>\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',\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 try {\n return isValidRepoEvent(value)\n } catch (err) {\n this.opts.onError(new FirehoseValidationError(err, 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(evt: RepoEvent): Promise<Event[]> {\n try {\n if (isCommit(evt) && !this.opts.excludeCommit) {\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 (isAccount(evt) && !this.opts.excludeAccount) {\n const parsed = parseAccount(evt)\n return parsed ? [parsed] : []\n } else if (isIdentity(evt) && !this.opts.excludeIdentity) {\n const parsed = await parseIdentity(\n this.opts.idResolver,\n evt,\n this.opts.unauthenticatedHandles,\n )\n return parsed ? [parsed] : []\n } else if (isSync(evt) && !this.opts.excludeSync) {\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: RepoEvent) {\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: 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: RepoOp[] = ops.filter((op) => {\n if (op.action === 'delete') {\n return verifiedCids[op.path] === null\n } else {\n return op.cid !== null && op.cid.equals(verifiedCids[op.path])\n }\n })\n return formatCommitOps(evt, verifiedOps, {\n skipCidVerification: true, // already checked via verifyProofs()\n })\n}\n\nexport const parseCommitUnauthenticated = async (\n evt: 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: RepoOp[],\n matchCollection?: ((col: string) => boolean) | null,\n): 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: Commit,\n ops: 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.host,\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 (evt: Sync): 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: 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 = (evt: Account): 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: RepoEvent,\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexicons.js","sourceRoot":"","sources":["../../src/firehose/lexicons.ts"],"names":[],"mappings":";;;AAOA,sBAEC;AAED,0BAKC;AAqDD,4BAMC;AAiBD,wBAMC;AAYD,gCAMC;AAcD,8BAMC;AAQD,wBAMC;AAWD,4BAMC;AArKD,8CAA4D;AAG5D,gGAAgG;AAEhG,SAAgB,KAAK,CAAC,CAAU;IAC9B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAA;AAC5C,CAAC;AAED,SAAgB,OAAO,CACrB,IAAY,EACZ,IAAO;IAEP,OAAO,IAAI,IAAI,IAAI,CAAA;AACrB,CAAC;AAqDD,SAAgB,QAAQ,CAAC,CAAU;IACjC,OAAO,CACL,KAAK,CAAC,CAAC,CAAC;QACR,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC;QACnB,CAAC,CAAC,KAAK,KAAK,wCAAwC,CACrD,CAAA;AACH,CAAC;AAiBD,SAAgB,MAAM,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gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,CAAC,gBAAgB,CAAC;iBAChC;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;iBACf;aACF;SACF;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,qDAAqD;YAClE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC;YACnC,QAAQ,EAAE,CAAC,KAAK,CAAC;YACjB,UAAU,EAAE;gBACV,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;iBAC5C;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;iBACf;gBACD,GAAG,EAAE;oBACH,IAAI,EAAE,UAAU;oBAChB,WAAW,EACT,mEAAmE;iBACtE;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,UAAU;oBAChB,WAAW,EACT,iIAAiI;iBACpI;aACF;SACF;KACF;CACF,CAAA;AAED,MAAM,QAAQ,GAAG,IAAI,kBAAQ,CAAC,CAAC,oCAA4B,CAAC,CAAC,CAAA;AAEtD,MAAM,gBAAgB,GAAG,CAAC,GAAY,EAAE,EAAE;IAC/C,OAAO,QAAQ,CAAC,sBAAsB,CACpC,iCAAiC,EACjC,GAAG,CACJ,CAAA;AACH,CAAC,CAAA;AALY,QAAA,gBAAgB,oBAK5B","sourcesContent":["import type { IncomingMessage } from 'node:http'\nimport type { CID } from 'multiformats/cid'\nimport { type LexiconDoc, Lexicons } from '@atproto/lexicon'\nimport type { Auth, ErrorFrame } from '@atproto/xrpc-server'\n\n// @NOTE: this file is an ugly copy job of codegen output. I'd like to clean this whole thing up\n\nexport function isObj(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null\n}\n\nexport function hasProp<K extends PropertyKey>(\n data: object,\n prop: K,\n): data is Record<K, unknown> {\n return prop in data\n}\n\nexport interface QueryParams {\n /** The last known event seq number to backfill from. */\n cursor?: number\n}\n\nexport type RepoEvent =\n | Commit\n | Identity\n | Account\n | Sync\n | Info\n | { $type: string; [k: string]: unknown }\nexport type HandlerError = ErrorFrame<'FutureCursor' | 'ConsumerTooSlow'>\nexport type HandlerOutput = HandlerError | RepoEvent\nexport type HandlerReqCtx<HA extends Auth = never> = {\n auth: HA\n params: QueryParams\n req: IncomingMessage\n signal: AbortSignal\n}\nexport type Handler<HA extends Auth = never> = (\n ctx: HandlerReqCtx<HA>,\n) => AsyncIterable<HandlerOutput>\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. */\nexport interface Commit {\n /** The stream sequence number of this message. */\n seq: number\n /** DEPRECATED -- unused */\n rebase: boolean\n /** 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 tooBig: boolean\n /** The repo this event comes from. */\n repo: string\n /** Repo commit object CID. */\n commit: CID\n /** DEPRECATED -- unused. WARNING -- nullable and optional; stick with optional to ensure golang interoperability. */\n prev?: CID | null\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 rev: string\n /** The rev of the last emitted commit from this repo (if any). */\n since: string | null\n /** CAR file containing relevant blocks, as a diff since the previous repo state. */\n blocks: Uint8Array\n ops: RepoOp[]\n blobs: CID[]\n /** Timestamp of when this message was originally broadcast. */\n time: string\n [k: string]: unknown\n}\n\nexport function isCommit(v: unknown): v is Commit {\n return (\n isObj(v) &&\n hasProp(v, '$type') &&\n v.$type === 'com.atproto.sync.subscribeRepos#commit'\n )\n}\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. */\nexport interface Sync {\n $type?: 'com.atproto.sync.subscribeRepos#sync'\n /** The stream sequence number of this message. */\n seq: number\n /** The account this repo event corresponds to. Must match that in the commit object. */\n did: string\n /** CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'. */\n blocks: Uint8Array\n /** The rev of the commit. This value must match that in the commit object. */\n rev: string\n /** Timestamp of when this message was originally broadcast. */\n time: string\n}\n\nexport function isSync(v: unknown): v is Sync {\n return (\n isObj(v) &&\n hasProp(v, '$type') &&\n v.$type === 'com.atproto.sync.subscribeRepos#sync'\n )\n}\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. */\nexport interface Identity {\n seq: number\n did: string\n time: string\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 handle?: string\n [k: string]: unknown\n}\n\nexport function isIdentity(v: unknown): v is Identity {\n return (\n isObj(v) &&\n hasProp(v, '$type') &&\n v.$type === 'com.atproto.sync.subscribeRepos#identity'\n )\n}\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. */\nexport interface Account {\n seq: number\n did: string\n time: string\n /** Indicates that the account has a repository which can be fetched from the host that emitted this event. */\n active: boolean\n /** If active=false, this optional field indicates a reason for why the account is not active. */\n status?: 'takendown' | 'suspended' | 'deleted' | 'deactivated' | string\n [k: string]: unknown\n}\n\nexport function isAccount(v: unknown): v is Account {\n return (\n isObj(v) &&\n hasProp(v, '$type') &&\n v.$type === 'com.atproto.sync.subscribeRepos#account'\n )\n}\n\nexport interface Info {\n name: 'OutdatedCursor' | string\n message?: string\n [k: string]: unknown\n}\n\nexport function isInfo(v: unknown): v is Info {\n return (\n isObj(v) &&\n hasProp(v, '$type') &&\n v.$type === 'com.atproto.sync.subscribeRepos#info'\n )\n}\n\n/** A repo operation, ie a mutation of a single record. */\nexport interface RepoOp {\n action: 'create' | 'update' | 'delete' | string\n path: string\n /** For creates and updates, the new record CID. For deletions, null. */\n cid: CID | null\n [k: string]: unknown\n}\n\nexport function isRepoOp(v: unknown): v is RepoOp {\n return (\n isObj(v) &&\n hasProp(v, '$type') &&\n v.$type === 'com.atproto.sync.subscribeRepos#repoOp'\n )\n}\n\nexport const ComAtprotoSyncSubscribeRepos: LexiconDoc = {\n lexicon: 1,\n id: 'com.atproto.sync.subscribeRepos',\n defs: {\n main: {\n type: 'subscription',\n description:\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.',\n parameters: {\n type: 'params',\n properties: {\n cursor: {\n type: 'integer',\n description: 'The last known event seq number to backfill from.',\n },\n },\n },\n message: {\n schema: {\n type: 'union',\n refs: [\n 'lex:com.atproto.sync.subscribeRepos#commit',\n 'lex:com.atproto.sync.subscribeRepos#sync',\n 'lex:com.atproto.sync.subscribeRepos#identity',\n 'lex:com.atproto.sync.subscribeRepos#account',\n 'lex:com.atproto.sync.subscribeRepos#info',\n ],\n },\n },\n errors: [\n {\n name: 'FutureCursor',\n },\n {\n name: 'ConsumerTooSlow',\n description:\n 'If the consumer of the stream can not keep up with events, and a backlog gets too large, the server will drop the connection.',\n },\n ],\n },\n commit: {\n type: 'object',\n description:\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.',\n required: [\n 'seq',\n 'rebase',\n 'tooBig',\n 'repo',\n 'commit',\n 'rev',\n 'since',\n 'blocks',\n 'ops',\n 'blobs',\n 'time',\n ],\n nullable: ['since'],\n properties: {\n seq: {\n type: 'integer',\n description: 'The stream sequence number of this message.',\n },\n rebase: {\n type: 'boolean',\n description: 'DEPRECATED -- unused',\n },\n tooBig: {\n type: 'boolean',\n description:\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 repo: {\n type: 'string',\n format: 'did',\n description:\n \"The repo this event comes from. Note that all other message types name this field 'did'.\",\n },\n commit: {\n type: 'cid-link',\n description: 'Repo commit object CID.',\n },\n rev: {\n type: 'string',\n format: 'tid',\n description:\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 since: {\n type: 'string',\n format: 'tid',\n description:\n 'The rev of the last emitted commit from this repo (if any).',\n },\n blocks: {\n type: 'bytes',\n description:\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 maxLength: 2000000,\n },\n ops: {\n type: 'array',\n items: {\n type: 'ref',\n ref: 'lex:com.atproto.sync.subscribeRepos#repoOp',\n description:\n 'List of repo mutation operations in this commit (eg, records created, updated, or deleted).',\n },\n maxLength: 200,\n },\n blobs: {\n type: 'array',\n items: {\n type: 'cid-link',\n description:\n 'DEPRECATED -- will soon always be empty. List of new blobs (by CID) referenced by records in this commit.',\n },\n },\n prevData: {\n type: 'cid-link',\n description:\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 time: {\n type: 'string',\n format: 'datetime',\n description:\n 'Timestamp of when this message was originally broadcast.',\n },\n },\n },\n sync: {\n type: 'object',\n description:\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.',\n required: ['seq', 'did', 'blocks', 'rev', 'time'],\n properties: {\n seq: {\n type: 'integer',\n description: 'The stream sequence number of this message.',\n },\n did: {\n type: 'string',\n format: 'did',\n description:\n 'The account this repo event corresponds to. Must match that in the commit object.',\n },\n blocks: {\n type: 'bytes',\n description:\n \"CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'.\",\n maxLength: 10000,\n },\n rev: {\n type: 'string',\n description:\n 'The rev of the commit. This value must match that in the commit object.',\n },\n time: {\n type: 'string',\n format: 'datetime',\n description:\n 'Timestamp of when this message was originally broadcast.',\n },\n },\n },\n identity: {\n type: 'object',\n description:\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.\",\n required: ['seq', 'did', 'time'],\n properties: {\n seq: {\n type: 'integer',\n },\n did: {\n type: 'string',\n format: 'did',\n },\n time: {\n type: 'string',\n format: 'datetime',\n },\n handle: {\n type: 'string',\n format: 'handle',\n description:\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 },\n },\n account: {\n type: 'object',\n description:\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.\",\n required: ['seq', 'did', 'time', 'active'],\n properties: {\n seq: {\n type: 'integer',\n },\n did: {\n type: 'string',\n format: 'did',\n },\n time: {\n type: 'string',\n format: 'datetime',\n },\n active: {\n type: 'boolean',\n description:\n 'Indicates that the account has a repository which can be fetched from the host that emitted this event.',\n },\n status: {\n type: 'string',\n description:\n 'If active=false, this optional field indicates a reason for why the account is not active.',\n knownValues: [\n 'takendown',\n 'suspended',\n 'deleted',\n 'deactivated',\n 'desynchronized',\n 'throttled',\n ],\n },\n },\n },\n info: {\n type: 'object',\n required: ['name'],\n properties: {\n name: {\n type: 'string',\n knownValues: ['OutdatedCursor'],\n },\n message: {\n type: 'string',\n },\n },\n },\n repoOp: {\n type: 'object',\n description: 'A repo operation, ie a mutation of a single record.',\n required: ['action', 'path', 'cid'],\n nullable: ['cid'],\n properties: {\n action: {\n type: 'string',\n knownValues: ['create', 'update', 'delete'],\n },\n path: {\n type: 'string',\n },\n cid: {\n type: 'cid-link',\n description:\n 'For creates and updates, the new record CID. For deletions, null.',\n },\n prev: {\n type: 'cid-link',\n description:\n 'For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined.',\n },\n },\n },\n },\n}\n\nconst lexicons = new Lexicons([ComAtprotoSyncSubscribeRepos])\n\nexport const isValidRepoEvent = (evt: unknown) => {\n return lexicons.assertValidXrpcMessage<RepoEvent>(\n 'com.atproto.sync.subscribeRepos',\n evt,\n )\n}\n"]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,6CAA0B;AAC1B,2CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,6CAA0B;AAC1B,2CAAwB","sourcesContent":["export * from './runner'\nexport * from './firehose'\nexport * from './events'\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consecutive-list.js","sourceRoot":"","sources":["../../src/runner/consecutive-list.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,MAAa,eAAe;IAA5B;QACE;;;;mBAA6B,EAAE;WAAA;IAejC,CAAC;IAbC,IAAI,CAAC,KAAQ;QACX,MAAM,IAAI,GAAG,IAAI,eAAe,CAAI,IAAI,EAAE,KAAK,CAAC,CAAA;QAChD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACpB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,GAAG,CAAC,CAAA;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;YAChC,CAAC,IAAI,CAAC,CAAA;QACR,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAA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,IAAI,CAAA;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAA;IACpC,CAAC;CACF;AAXD,0CAWC","sourcesContent":["/**\n * Add items to a list, and mark those items as\n * completed. Upon item completion, get list of consecutive\n * items completed at the head of the list. Example:\n *\n * const consecutive = new ConsecutiveList<number>()\n * const item1 = consecutive.push(1)\n * const item2 = consecutive.push(2)\n * const item3 = consecutive.push(3)\n * item2.complete() // []\n * item1.complete() // [1, 2]\n * item3.complete() // [3]\n *\n */\nexport class ConsecutiveList<T> {\n list: ConsecutiveItem<T>[] = []\n\n push(value: T) {\n const item = new ConsecutiveItem<T>(this, value)\n this.list.push(item)\n return item\n }\n\n complete(): T[] {\n let i = 0\n while (this.list[i]?.isComplete) {\n i += 1\n }\n return this.list.splice(0, i).map((item) => item.value)\n }\n}\n\nexport class ConsecutiveItem<T> {\n isComplete = false\n constructor(\n private consecutive: ConsecutiveList<T>,\n public value: T,\n ) {}\n\n complete() {\n this.isComplete = true\n return this.consecutive.complete()\n }\n}\n"]}
|
package/dist/runner/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runner/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAkC;AAClC,kDAA+B;AAC/B,0CAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runner/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAkC;AAClC,kDAA+B;AAC/B,0CAAuB","sourcesContent":["export * from './consecutive-list'\nexport * from './memory-runner'\nexport * from './types'\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-runner.js","sourceRoot":"","sources":["../../src/runner/memory-runner.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA4B;AAC5B,yDAAoD;AASpD,+EAA+E;AAC/E,2EAA2E;AAC3E,MAAa,YAAY;IAMvB,YAAmB,OA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AAI,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;AAzDD,oCAyDC","sourcesContent":["import PQueue from 'p-queue'\nimport { ConsecutiveList } from './consecutive-list'\nimport { EventRunner } from './types'\n\nexport type MemoryRunnerOptions = {\n setCursor?: (cursor: number) => Promise<void>\n concurrency?: number\n startCursor?: number\n}\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: PQueue\n partitions = new Map<string, PQueue>()\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"]}
|
package/dist/runner/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/runner/types.ts"],"names":[],"mappings":""}
|
|
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"]}
|
package/dist/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAAA,kDAM4B;AAErB,MAAM,eAAe,GAAG,CAC7B,GAAc,EAC4B,EAAE;IAC5C,IAAI,IAAA,mBAAQ,EAAC,GAAG,CAAC;QAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,CAAA;SACpD,IAAI,IAAA,oBAAS,EAAC,GAAG,CAAC,IAAI,IAAA,qBAAU,EAAC,GAAG,CAAC,IAAI,IAAA,iBAAM,EAAC,GAAG,CAAC;QACvD,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAA;IACvC,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAPY,QAAA,eAAe,mBAO3B"}
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAAA,kDAM4B;AAErB,MAAM,eAAe,GAAG,CAC7B,GAAc,EAC4B,EAAE;IAC5C,IAAI,IAAA,mBAAQ,EAAC,GAAG,CAAC;QAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,CAAA;SACpD,IAAI,IAAA,oBAAS,EAAC,GAAG,CAAC,IAAI,IAAA,qBAAU,EAAC,GAAG,CAAC,IAAI,IAAA,iBAAM,EAAC,GAAG,CAAC;QACvD,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAA;IACvC,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAPY,QAAA,eAAe,mBAO3B","sourcesContent":["import {\n RepoEvent,\n isAccount,\n isCommit,\n isIdentity,\n isSync,\n} from './firehose/lexicons'\n\nexport const didAndSeqForEvt = (\n evt: RepoEvent,\n): { did: string; seq: number } | undefined => {\n if (isCommit(evt)) return { seq: evt.seq, did: evt.repo }\n else if (isAccount(evt) || isIdentity(evt) || isSync(evt))\n return { seq: evt.seq, did: evt.did }\n return undefined\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/sync",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.36",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "atproto sync library",
|
|
6
6
|
"keywords": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@atproto/common": "^0.4.12",
|
|
28
28
|
"@atproto/identity": "^0.4.9",
|
|
29
29
|
"@atproto/lexicon": "^0.5.1",
|
|
30
|
-
"@atproto/repo": "^0.8.
|
|
30
|
+
"@atproto/repo": "^0.8.10",
|
|
31
31
|
"@atproto/syntax": "^0.4.1",
|
|
32
32
|
"@atproto/xrpc-server": "^0.9.5"
|
|
33
33
|
},
|
package/src/firehose/index.ts
CHANGED
|
@@ -68,6 +68,7 @@ export class Firehose {
|
|
|
68
68
|
private sub: Subscription<RepoEvent>
|
|
69
69
|
private abortController: AbortController
|
|
70
70
|
private destoryDefer: Deferrable
|
|
71
|
+
private matchCollection: ((col: string) => boolean) | null = null
|
|
71
72
|
|
|
72
73
|
constructor(public opts: FirehoseOptions) {
|
|
73
74
|
this.destoryDefer = createDeferrable()
|
|
@@ -75,6 +76,25 @@ export class Firehose {
|
|
|
75
76
|
if (this.opts.getCursor && this.opts.runner) {
|
|
76
77
|
throw new Error('Must set only `getCursor` or `runner`')
|
|
77
78
|
}
|
|
79
|
+
if (opts.filterCollections) {
|
|
80
|
+
const exact = new Set<string>()
|
|
81
|
+
const prefixes: string[] = []
|
|
82
|
+
|
|
83
|
+
for (const pattern of opts.filterCollections) {
|
|
84
|
+
if (pattern.endsWith('.*')) {
|
|
85
|
+
prefixes.push(pattern.slice(0, -2))
|
|
86
|
+
} else {
|
|
87
|
+
exact.add(pattern)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
this.matchCollection = (col: string): boolean => {
|
|
91
|
+
if (exact.has(col)) return true
|
|
92
|
+
for (const prefix of prefixes) {
|
|
93
|
+
if (col.startsWith(prefix)) return true
|
|
94
|
+
}
|
|
95
|
+
return false
|
|
96
|
+
}
|
|
97
|
+
}
|
|
78
98
|
this.sub = new Subscription({
|
|
79
99
|
...opts,
|
|
80
100
|
service: opts.service ?? 'wss://bsky.network',
|
|
@@ -136,11 +156,11 @@ export class Firehose {
|
|
|
136
156
|
try {
|
|
137
157
|
if (isCommit(evt) && !this.opts.excludeCommit) {
|
|
138
158
|
return this.opts.unauthenticatedCommits
|
|
139
|
-
? await parseCommitUnauthenticated(evt, this.
|
|
159
|
+
? await parseCommitUnauthenticated(evt, this.matchCollection)
|
|
140
160
|
: await parseCommitAuthenticated(
|
|
141
161
|
this.opts.idResolver,
|
|
142
162
|
evt,
|
|
143
|
-
this.
|
|
163
|
+
this.matchCollection,
|
|
144
164
|
)
|
|
145
165
|
} else if (isAccount(evt) && !this.opts.excludeAccount) {
|
|
146
166
|
const parsed = parseAccount(evt)
|
|
@@ -184,11 +204,11 @@ export class Firehose {
|
|
|
184
204
|
export const parseCommitAuthenticated = async (
|
|
185
205
|
idResolver: IdResolver,
|
|
186
206
|
evt: Commit,
|
|
187
|
-
|
|
207
|
+
matchCollection?: ((col: string) => boolean) | null,
|
|
188
208
|
forceKeyRefresh = false,
|
|
189
209
|
): Promise<CommitEvt[]> => {
|
|
190
210
|
const did = evt.repo
|
|
191
|
-
const ops = maybeFilterOps(evt.ops,
|
|
211
|
+
const ops = maybeFilterOps(evt.ops, matchCollection)
|
|
192
212
|
if (ops.length === 0) {
|
|
193
213
|
return []
|
|
194
214
|
}
|
|
@@ -210,7 +230,7 @@ export const parseCommitAuthenticated = async (
|
|
|
210
230
|
})
|
|
211
231
|
} catch (err) {
|
|
212
232
|
if (err instanceof RepoVerificationError && !forceKeyRefresh) {
|
|
213
|
-
return parseCommitAuthenticated(idResolver, evt,
|
|
233
|
+
return parseCommitAuthenticated(idResolver, evt, matchCollection, true)
|
|
214
234
|
}
|
|
215
235
|
throw err
|
|
216
236
|
}
|
|
@@ -228,20 +248,20 @@ export const parseCommitAuthenticated = async (
|
|
|
228
248
|
|
|
229
249
|
export const parseCommitUnauthenticated = async (
|
|
230
250
|
evt: Commit,
|
|
231
|
-
|
|
251
|
+
matchCollection?: ((col: string) => boolean) | null,
|
|
232
252
|
): Promise<CommitEvt[]> => {
|
|
233
|
-
const ops = maybeFilterOps(evt.ops,
|
|
253
|
+
const ops = maybeFilterOps(evt.ops, matchCollection)
|
|
234
254
|
return formatCommitOps(evt, ops)
|
|
235
255
|
}
|
|
236
256
|
|
|
237
257
|
const maybeFilterOps = (
|
|
238
258
|
ops: RepoOp[],
|
|
239
|
-
|
|
259
|
+
matchCollection?: ((col: string) => boolean) | null,
|
|
240
260
|
): RepoOp[] => {
|
|
241
|
-
if (!
|
|
261
|
+
if (!matchCollection) return ops
|
|
242
262
|
return ops.filter((op) => {
|
|
243
263
|
const { collection } = parseDataKey(op.path)
|
|
244
|
-
return
|
|
264
|
+
return matchCollection(collection)
|
|
245
265
|
})
|
|
246
266
|
}
|
|
247
267
|
|