@atproto/sync 0.1.15 → 0.1.17
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 +18 -0
- package/dist/events.d.ts +10 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/firehose/index.d.ts +4 -2
- package/dist/firehose/index.d.ts.map +1 -1
- package/dist/firehose/index.js +18 -1
- package/dist/firehose/index.js.map +1 -1
- package/dist/firehose/lexicons.d.ts +16 -27
- package/dist/firehose/lexicons.d.ts.map +1 -1
- package/dist/firehose/lexicons.js +78 -44
- package/dist/firehose/lexicons.js.map +1 -1
- package/dist/runner/types.d.ts +1 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +1 -1
- package/dist/util.js.map +1 -1
- package/package.json +6 -5
- package/src/events.ts +11 -1
- package/src/firehose/index.ts +22 -0
- package/src/firehose/lexicons.ts +120 -80
- package/src/runner/types.ts +1 -1
- package/src/util.ts +8 -2
- package/tests/firehose.test.ts +21 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atproto/sync
|
|
2
2
|
|
|
3
|
+
## 0.1.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#3599](https://github.com/bluesky-social/atproto/pull/3599) [`b20907a70`](https://github.com/bluesky-social/atproto/commit/b20907a7056970ab627e6c661882cb16491801e2) Thanks [@mozzius](https://github.com/mozzius)! - Fix types of `FirehoseOptions`
|
|
8
|
+
|
|
9
|
+
- [`d96b03956`](https://github.com/bluesky-social/atproto/commit/d96b03956d5c26c238f586c6bdf257c080f12746) Thanks [@devinivy](https://github.com/devinivy)! - Support firehose sync event
|
|
10
|
+
|
|
11
|
+
## 0.1.16
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`850e39843`](https://github.com/bluesky-social/atproto/commit/850e39843cb0ec9ea716675f7568c0c601f45e29)]:
|
|
16
|
+
- @atproto/syntax@0.3.4
|
|
17
|
+
- @atproto/lexicon@0.4.8
|
|
18
|
+
- @atproto/repo@0.7.1
|
|
19
|
+
- @atproto/xrpc-server@0.7.12
|
|
20
|
+
|
|
3
21
|
## 0.1.15
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/events.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { DidDocument } from '@atproto/identity';
|
|
|
3
3
|
import type { RepoRecord } from '@atproto/lexicon';
|
|
4
4
|
import { BlockMap } from '@atproto/repo';
|
|
5
5
|
import { AtUri } from '@atproto/syntax';
|
|
6
|
-
export type Event = CommitEvt | IdentityEvt | AccountEvt;
|
|
6
|
+
export type Event = CommitEvt | SyncEvt | IdentityEvt | AccountEvt;
|
|
7
7
|
export type CommitMeta = {
|
|
8
8
|
seq: number;
|
|
9
9
|
time: string;
|
|
@@ -29,6 +29,15 @@ export type Update = CommitMeta & {
|
|
|
29
29
|
export type Delete = CommitMeta & {
|
|
30
30
|
event: 'delete';
|
|
31
31
|
};
|
|
32
|
+
export type SyncEvt = {
|
|
33
|
+
seq: number;
|
|
34
|
+
time: string;
|
|
35
|
+
event: 'sync';
|
|
36
|
+
did: string;
|
|
37
|
+
cid: CID;
|
|
38
|
+
rev: string;
|
|
39
|
+
blocks: BlockMap;
|
|
40
|
+
};
|
|
32
41
|
export type IdentityEvt = {
|
|
33
42
|
seq: number;
|
|
34
43
|
time: string;
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA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AAG;IAChC,KAAK,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,GAAG,CAAA;IACR,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,QAAQ,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,UAAU,CAAA;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,SAAS,CAAA;IAChB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,aAAa,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,WAAW,GACX,SAAS,GACT,aAAa,CAAA"}
|
package/dist/firehose/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ClientOptions } from 'ws';
|
|
2
2
|
import { IdResolver } from '@atproto/identity';
|
|
3
|
-
import { AccountEvt, CommitEvt, Event, IdentityEvt } from '../events';
|
|
3
|
+
import { AccountEvt, CommitEvt, Event, IdentityEvt, SyncEvt } from '../events';
|
|
4
4
|
import { EventRunner } from '../runner';
|
|
5
|
-
import { type Account, type Commit, type Identity, type RepoEvent } from './lexicons';
|
|
5
|
+
import { type Account, type Commit, type Identity, type RepoEvent, type Sync } from './lexicons';
|
|
6
6
|
export type FirehoseOptions = ClientOptions & {
|
|
7
7
|
idResolver: IdResolver;
|
|
8
8
|
handleEvent: (evt: Event) => Awaited<void>;
|
|
@@ -17,6 +17,7 @@ export type FirehoseOptions = ClientOptions & {
|
|
|
17
17
|
excludeIdentity?: boolean;
|
|
18
18
|
excludeAccount?: boolean;
|
|
19
19
|
excludeCommit?: boolean;
|
|
20
|
+
excludeSync?: boolean;
|
|
20
21
|
};
|
|
21
22
|
export declare class Firehose {
|
|
22
23
|
opts: FirehoseOptions;
|
|
@@ -31,6 +32,7 @@ export declare class Firehose {
|
|
|
31
32
|
}
|
|
32
33
|
export declare const parseCommitAuthenticated: (idResolver: IdResolver, evt: Commit, filterCollections?: string[], forceKeyRefresh?: boolean) => Promise<CommitEvt[]>;
|
|
33
34
|
export declare const parseCommitUnauthenticated: (evt: Commit, filterCollections?: string[]) => Promise<CommitEvt[]>;
|
|
35
|
+
export declare const parseSync: (evt: Sync) => Promise<SyncEvt | null>;
|
|
34
36
|
export declare const parseIdentity: (idResolver: IdResolver, evt: Identity, unauthenticated?: boolean) => Promise<IdentityEvt | null>;
|
|
35
37
|
export declare const parseAccount: (evt: Account) => AccountEvt | undefined;
|
|
36
38
|
export declare class FirehoseValidationError extends Error {
|
|
@@ -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;
|
|
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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0BAA0B,QAChC,MAAM,sBACS,MAAM,EAAE,KAC3B,OAAO,CAAC,SAAS,EAAE,CAGrB,CAAA;AAyDD,eAAO,MAAM,SAAS,QAAe,IAAI,KAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAYjE,CAAA;AAED,eAAO,MAAM,aAAa,eACZ,UAAU,OACjB,QAAQ,gCAEZ,OAAO,CAAC,WAAW,GAAG,IAAI,CAe5B,CAAA;AAeD,eAAO,MAAM,YAAY,QAAS,OAAO,KAAG,UAAU,GAAG,SAUxD,CAAA;AAMD,qBAAa,uBAAwB,SAAQ,KAAK;IAGvC,KAAK,EAAE,OAAO;gBADrB,GAAG,EAAE,OAAO,EACL,KAAK,EAAE,OAAO;CAIxB;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAGlC,KAAK,EAAE,SAAS;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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FirehoseHandlerError = exports.FirehoseSubscriptionError = exports.FirehoseParseError = exports.FirehoseValidationError = exports.parseAccount = exports.parseIdentity = exports.parseCommitUnauthenticated = exports.parseCommitAuthenticated = exports.Firehose = void 0;
|
|
3
|
+
exports.FirehoseHandlerError = exports.FirehoseSubscriptionError = exports.FirehoseParseError = exports.FirehoseValidationError = exports.parseAccount = exports.parseIdentity = exports.parseSync = exports.parseCommitUnauthenticated = exports.parseCommitAuthenticated = exports.Firehose = void 0;
|
|
4
4
|
const common_1 = require("@atproto/common");
|
|
5
5
|
const identity_1 = require("@atproto/identity");
|
|
6
6
|
const repo_1 = require("@atproto/repo");
|
|
@@ -112,6 +112,10 @@ class Firehose {
|
|
|
112
112
|
const parsed = await (0, exports.parseIdentity)(this.opts.idResolver, evt, this.opts.unauthenticatedHandles);
|
|
113
113
|
return parsed ? [parsed] : [];
|
|
114
114
|
}
|
|
115
|
+
else if ((0, lexicons_1.isSync)(evt) && !this.opts.excludeSync) {
|
|
116
|
+
const parsed = await (0, exports.parseSync)(evt);
|
|
117
|
+
return parsed ? [parsed] : [];
|
|
118
|
+
}
|
|
115
119
|
else {
|
|
116
120
|
return [];
|
|
117
121
|
}
|
|
@@ -230,6 +234,19 @@ const formatCommitOps = async (evt, ops) => {
|
|
|
230
234
|
}
|
|
231
235
|
return evts;
|
|
232
236
|
};
|
|
237
|
+
const parseSync = async (evt) => {
|
|
238
|
+
const car = await (0, repo_1.readCarWithRoot)(evt.blocks);
|
|
239
|
+
return {
|
|
240
|
+
event: 'sync',
|
|
241
|
+
seq: evt.seq,
|
|
242
|
+
time: evt.time,
|
|
243
|
+
did: evt.did,
|
|
244
|
+
cid: car.root,
|
|
245
|
+
rev: evt.rev,
|
|
246
|
+
blocks: car.blocks,
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
exports.parseSync = parseSync;
|
|
233
250
|
const parseIdentity = async (idResolver, evt, unauthenticated = false) => {
|
|
234
251
|
const res = await idResolver.did.resolve(evt.did);
|
|
235
252
|
const handle = res && !unauthenticated
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/firehose/index.ts"],"names":[],"mappings":";;;AAEA,4CAAoE;AACpE,gDAI0B;AAC1B,
|
|
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,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,gCAAgC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACzD,CAAC;CACF;AAJD,8DAIC;AAED,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YACE,GAAY,EACL,KAAY;QAEnB,KAAK,CAAC,iCAAiC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;QAFxD;;;;mBAAO,KAAK;WAAO;IAGrB,CAAC;CACF;AAPD,oDAOC"}
|
|
@@ -8,7 +8,7 @@ export interface QueryParams {
|
|
|
8
8
|
/** The last known event seq number to backfill from. */
|
|
9
9
|
cursor?: number;
|
|
10
10
|
}
|
|
11
|
-
export type RepoEvent = Commit | Identity | Account |
|
|
11
|
+
export type RepoEvent = Commit | Identity | Account | Sync | Info | {
|
|
12
12
|
$type: string;
|
|
13
13
|
[k: string]: unknown;
|
|
14
14
|
};
|
|
@@ -48,6 +48,21 @@ export interface Commit {
|
|
|
48
48
|
[k: string]: unknown;
|
|
49
49
|
}
|
|
50
50
|
export declare function isCommit(v: unknown): v is Commit;
|
|
51
|
+
/** 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. */
|
|
52
|
+
export interface Sync {
|
|
53
|
+
$type?: 'com.atproto.sync.subscribeRepos#sync';
|
|
54
|
+
/** The stream sequence number of this message. */
|
|
55
|
+
seq: number;
|
|
56
|
+
/** The account this repo event corresponds to. Must match that in the commit object. */
|
|
57
|
+
did: string;
|
|
58
|
+
/** CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'. */
|
|
59
|
+
blocks: Uint8Array;
|
|
60
|
+
/** The rev of the commit. This value must match that in the commit object. */
|
|
61
|
+
rev: string;
|
|
62
|
+
/** Timestamp of when this message was originally broadcast. */
|
|
63
|
+
time: string;
|
|
64
|
+
}
|
|
65
|
+
export declare function isSync(v: unknown): v is Sync;
|
|
51
66
|
/** 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. */
|
|
52
67
|
export interface Identity {
|
|
53
68
|
seq: number;
|
|
@@ -70,32 +85,6 @@ export interface Account {
|
|
|
70
85
|
[k: string]: unknown;
|
|
71
86
|
}
|
|
72
87
|
export declare function isAccount(v: unknown): v is Account;
|
|
73
|
-
/** DEPRECATED -- Use #identity event instead */
|
|
74
|
-
export interface Handle {
|
|
75
|
-
seq: number;
|
|
76
|
-
did: string;
|
|
77
|
-
handle: string;
|
|
78
|
-
time: string;
|
|
79
|
-
[k: string]: unknown;
|
|
80
|
-
}
|
|
81
|
-
export declare function isHandle(v: unknown): v is Handle;
|
|
82
|
-
/** DEPRECATED -- Use #account event instead */
|
|
83
|
-
export interface Migrate {
|
|
84
|
-
seq: number;
|
|
85
|
-
did: string;
|
|
86
|
-
migrateTo: string | null;
|
|
87
|
-
time: string;
|
|
88
|
-
[k: string]: unknown;
|
|
89
|
-
}
|
|
90
|
-
export declare function isMigrate(v: unknown): v is Migrate;
|
|
91
|
-
/** DEPRECATED -- Use #account event instead */
|
|
92
|
-
export interface Tombstone {
|
|
93
|
-
seq: number;
|
|
94
|
-
did: string;
|
|
95
|
-
time: string;
|
|
96
|
-
[k: string]: unknown;
|
|
97
|
-
}
|
|
98
|
-
export declare function isTombstone(v: unknown): v is Tombstone;
|
|
99
88
|
export interface Info {
|
|
100
89
|
name: 'OutdatedCursor' | string;
|
|
101
90
|
message?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexicons.d.ts","sourceRoot":"","sources":["../../src/firehose/lexicons.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,kBAAkB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;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C,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,IAAI,CAM5C;AAED,0DAA0D;AAC1D,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAA;IAC/C,IAAI,EAAE,MAAM,CAAA;IACZ,wEAAwE;IACxE,GAAG,EAAE,GAAG,GAAG,IAAI,CAAA;IACf,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACrB;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAMhD;AAED,eAAO,MAAM,4BAA4B,EAAE,UA2Q1C,CAAA;AAID,eAAO,MAAM,gBAAgB,QAAS,OAAO,cAK5C,CAAA"}
|
|
@@ -4,11 +4,9 @@ exports.isValidRepoEvent = exports.ComAtprotoSyncSubscribeRepos = void 0;
|
|
|
4
4
|
exports.isObj = isObj;
|
|
5
5
|
exports.hasProp = hasProp;
|
|
6
6
|
exports.isCommit = isCommit;
|
|
7
|
+
exports.isSync = isSync;
|
|
7
8
|
exports.isIdentity = isIdentity;
|
|
8
9
|
exports.isAccount = isAccount;
|
|
9
|
-
exports.isHandle = isHandle;
|
|
10
|
-
exports.isMigrate = isMigrate;
|
|
11
|
-
exports.isTombstone = isTombstone;
|
|
12
10
|
exports.isInfo = isInfo;
|
|
13
11
|
exports.isRepoOp = isRepoOp;
|
|
14
12
|
const lexicon_1 = require("@atproto/lexicon");
|
|
@@ -24,6 +22,11 @@ function isCommit(v) {
|
|
|
24
22
|
hasProp(v, '$type') &&
|
|
25
23
|
v.$type === 'com.atproto.sync.subscribeRepos#commit');
|
|
26
24
|
}
|
|
25
|
+
function isSync(v) {
|
|
26
|
+
return (isObj(v) &&
|
|
27
|
+
hasProp(v, '$type') &&
|
|
28
|
+
v.$type === 'com.atproto.sync.subscribeRepos#sync');
|
|
29
|
+
}
|
|
27
30
|
function isIdentity(v) {
|
|
28
31
|
return (isObj(v) &&
|
|
29
32
|
hasProp(v, '$type') &&
|
|
@@ -34,21 +37,6 @@ function isAccount(v) {
|
|
|
34
37
|
hasProp(v, '$type') &&
|
|
35
38
|
v.$type === 'com.atproto.sync.subscribeRepos#account');
|
|
36
39
|
}
|
|
37
|
-
function isHandle(v) {
|
|
38
|
-
return (isObj(v) &&
|
|
39
|
-
hasProp(v, '$type') &&
|
|
40
|
-
v.$type === 'com.atproto.sync.subscribeRepos#handle');
|
|
41
|
-
}
|
|
42
|
-
function isMigrate(v) {
|
|
43
|
-
return (isObj(v) &&
|
|
44
|
-
hasProp(v, '$type') &&
|
|
45
|
-
v.$type === 'com.atproto.sync.subscribeRepos#migrate');
|
|
46
|
-
}
|
|
47
|
-
function isTombstone(v) {
|
|
48
|
-
return (isObj(v) &&
|
|
49
|
-
hasProp(v, '$type') &&
|
|
50
|
-
v.$type === 'com.atproto.sync.subscribeRepos#tombstone');
|
|
51
|
-
}
|
|
52
40
|
function isInfo(v) {
|
|
53
41
|
return (isObj(v) &&
|
|
54
42
|
hasProp(v, '$type') &&
|
|
@@ -65,13 +53,13 @@ exports.ComAtprotoSyncSubscribeRepos = {
|
|
|
65
53
|
defs: {
|
|
66
54
|
main: {
|
|
67
55
|
type: 'subscription',
|
|
68
|
-
description: '
|
|
56
|
+
description: '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.',
|
|
69
57
|
parameters: {
|
|
70
58
|
type: 'params',
|
|
71
59
|
properties: {
|
|
72
60
|
cursor: {
|
|
73
61
|
type: 'integer',
|
|
74
|
-
description: 'The last known event to backfill from.',
|
|
62
|
+
description: 'The last known event seq number to backfill from.',
|
|
75
63
|
},
|
|
76
64
|
},
|
|
77
65
|
},
|
|
@@ -80,9 +68,9 @@ exports.ComAtprotoSyncSubscribeRepos = {
|
|
|
80
68
|
type: 'union',
|
|
81
69
|
refs: [
|
|
82
70
|
'lex:com.atproto.sync.subscribeRepos#commit',
|
|
83
|
-
'lex:com.atproto.sync.subscribeRepos#
|
|
84
|
-
'lex:com.atproto.sync.subscribeRepos#
|
|
85
|
-
'lex:com.atproto.sync.subscribeRepos#
|
|
71
|
+
'lex:com.atproto.sync.subscribeRepos#sync',
|
|
72
|
+
'lex:com.atproto.sync.subscribeRepos#identity',
|
|
73
|
+
'lex:com.atproto.sync.subscribeRepos#account',
|
|
86
74
|
'lex:com.atproto.sync.subscribeRepos#info',
|
|
87
75
|
],
|
|
88
76
|
},
|
|
@@ -93,11 +81,13 @@ exports.ComAtprotoSyncSubscribeRepos = {
|
|
|
93
81
|
},
|
|
94
82
|
{
|
|
95
83
|
name: 'ConsumerTooSlow',
|
|
84
|
+
description: 'If the consumer of the stream can not keep up with events, and a backlog gets too large, the server will drop the connection.',
|
|
96
85
|
},
|
|
97
86
|
],
|
|
98
87
|
},
|
|
99
88
|
commit: {
|
|
100
89
|
type: 'object',
|
|
90
|
+
description: '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.',
|
|
101
91
|
required: [
|
|
102
92
|
'seq',
|
|
103
93
|
'rebase',
|
|
@@ -111,45 +101,50 @@ exports.ComAtprotoSyncSubscribeRepos = {
|
|
|
111
101
|
'blobs',
|
|
112
102
|
'time',
|
|
113
103
|
],
|
|
114
|
-
nullable: ['
|
|
104
|
+
nullable: ['since'],
|
|
115
105
|
properties: {
|
|
116
106
|
seq: {
|
|
117
107
|
type: 'integer',
|
|
108
|
+
description: 'The stream sequence number of this message.',
|
|
118
109
|
},
|
|
119
110
|
rebase: {
|
|
120
111
|
type: 'boolean',
|
|
112
|
+
description: 'DEPRECATED -- unused',
|
|
121
113
|
},
|
|
122
114
|
tooBig: {
|
|
123
115
|
type: 'boolean',
|
|
116
|
+
description: '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.',
|
|
124
117
|
},
|
|
125
118
|
repo: {
|
|
126
119
|
type: 'string',
|
|
127
120
|
format: 'did',
|
|
121
|
+
description: "The repo this event comes from. Note that all other message types name this field 'did'.",
|
|
128
122
|
},
|
|
129
123
|
commit: {
|
|
130
124
|
type: 'cid-link',
|
|
131
|
-
|
|
132
|
-
prev: {
|
|
133
|
-
type: 'cid-link',
|
|
125
|
+
description: 'Repo commit object CID.',
|
|
134
126
|
},
|
|
135
127
|
rev: {
|
|
136
128
|
type: 'string',
|
|
137
|
-
|
|
129
|
+
format: 'tid',
|
|
130
|
+
description: '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.',
|
|
138
131
|
},
|
|
139
132
|
since: {
|
|
140
133
|
type: 'string',
|
|
141
|
-
|
|
134
|
+
format: 'tid',
|
|
135
|
+
description: 'The rev of the last emitted commit from this repo (if any).',
|
|
142
136
|
},
|
|
143
137
|
blocks: {
|
|
144
138
|
type: 'bytes',
|
|
145
|
-
description:
|
|
146
|
-
maxLength:
|
|
139
|
+
description: "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.",
|
|
140
|
+
maxLength: 2000000,
|
|
147
141
|
},
|
|
148
142
|
ops: {
|
|
149
143
|
type: 'array',
|
|
150
144
|
items: {
|
|
151
145
|
type: 'ref',
|
|
152
146
|
ref: 'lex:com.atproto.sync.subscribeRepos#repoOp',
|
|
147
|
+
description: 'List of repo mutation operations in this commit (eg, records created, updated, or deleted).',
|
|
153
148
|
},
|
|
154
149
|
maxLength: 200,
|
|
155
150
|
},
|
|
@@ -157,39 +152,54 @@ exports.ComAtprotoSyncSubscribeRepos = {
|
|
|
157
152
|
type: 'array',
|
|
158
153
|
items: {
|
|
159
154
|
type: 'cid-link',
|
|
155
|
+
description: 'DEPRECATED -- will soon always be empty. List of new blobs (by CID) referenced by records in this commit.',
|
|
160
156
|
},
|
|
161
157
|
},
|
|
158
|
+
prevData: {
|
|
159
|
+
type: 'cid-link',
|
|
160
|
+
description: "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.",
|
|
161
|
+
},
|
|
162
162
|
time: {
|
|
163
163
|
type: 'string',
|
|
164
164
|
format: 'datetime',
|
|
165
|
+
description: 'Timestamp of when this message was originally broadcast.',
|
|
165
166
|
},
|
|
166
167
|
},
|
|
167
168
|
},
|
|
168
|
-
|
|
169
|
+
sync: {
|
|
169
170
|
type: 'object',
|
|
170
|
-
|
|
171
|
+
description: '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.',
|
|
172
|
+
required: ['seq', 'did', 'blocks', 'rev', 'time'],
|
|
171
173
|
properties: {
|
|
172
174
|
seq: {
|
|
173
175
|
type: 'integer',
|
|
176
|
+
description: 'The stream sequence number of this message.',
|
|
174
177
|
},
|
|
175
178
|
did: {
|
|
176
179
|
type: 'string',
|
|
177
180
|
format: 'did',
|
|
181
|
+
description: 'The account this repo event corresponds to. Must match that in the commit object.',
|
|
178
182
|
},
|
|
179
|
-
|
|
183
|
+
blocks: {
|
|
184
|
+
type: 'bytes',
|
|
185
|
+
description: "CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'.",
|
|
186
|
+
maxLength: 10000,
|
|
187
|
+
},
|
|
188
|
+
rev: {
|
|
180
189
|
type: 'string',
|
|
181
|
-
|
|
190
|
+
description: 'The rev of the commit. This value must match that in the commit object.',
|
|
182
191
|
},
|
|
183
192
|
time: {
|
|
184
193
|
type: 'string',
|
|
185
194
|
format: 'datetime',
|
|
195
|
+
description: 'Timestamp of when this message was originally broadcast.',
|
|
186
196
|
},
|
|
187
197
|
},
|
|
188
198
|
},
|
|
189
|
-
|
|
199
|
+
identity: {
|
|
190
200
|
type: 'object',
|
|
191
|
-
|
|
192
|
-
|
|
201
|
+
description: "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.",
|
|
202
|
+
required: ['seq', 'did', 'time'],
|
|
193
203
|
properties: {
|
|
194
204
|
seq: {
|
|
195
205
|
type: 'integer',
|
|
@@ -198,18 +208,21 @@ exports.ComAtprotoSyncSubscribeRepos = {
|
|
|
198
208
|
type: 'string',
|
|
199
209
|
format: 'did',
|
|
200
210
|
},
|
|
201
|
-
migrateTo: {
|
|
202
|
-
type: 'string',
|
|
203
|
-
},
|
|
204
211
|
time: {
|
|
205
212
|
type: 'string',
|
|
206
213
|
format: 'datetime',
|
|
207
214
|
},
|
|
215
|
+
handle: {
|
|
216
|
+
type: 'string',
|
|
217
|
+
format: 'handle',
|
|
218
|
+
description: "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.",
|
|
219
|
+
},
|
|
208
220
|
},
|
|
209
221
|
},
|
|
210
|
-
|
|
222
|
+
account: {
|
|
211
223
|
type: 'object',
|
|
212
|
-
|
|
224
|
+
description: "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.",
|
|
225
|
+
required: ['seq', 'did', 'time', 'active'],
|
|
213
226
|
properties: {
|
|
214
227
|
seq: {
|
|
215
228
|
type: 'integer',
|
|
@@ -222,6 +235,22 @@ exports.ComAtprotoSyncSubscribeRepos = {
|
|
|
222
235
|
type: 'string',
|
|
223
236
|
format: 'datetime',
|
|
224
237
|
},
|
|
238
|
+
active: {
|
|
239
|
+
type: 'boolean',
|
|
240
|
+
description: 'Indicates that the account has a repository which can be fetched from the host that emitted this event.',
|
|
241
|
+
},
|
|
242
|
+
status: {
|
|
243
|
+
type: 'string',
|
|
244
|
+
description: 'If active=false, this optional field indicates a reason for why the account is not active.',
|
|
245
|
+
knownValues: [
|
|
246
|
+
'takendown',
|
|
247
|
+
'suspended',
|
|
248
|
+
'deleted',
|
|
249
|
+
'deactivated',
|
|
250
|
+
'desynchronized',
|
|
251
|
+
'throttled',
|
|
252
|
+
],
|
|
253
|
+
},
|
|
225
254
|
},
|
|
226
255
|
},
|
|
227
256
|
info: {
|
|
@@ -239,7 +268,7 @@ exports.ComAtprotoSyncSubscribeRepos = {
|
|
|
239
268
|
},
|
|
240
269
|
repoOp: {
|
|
241
270
|
type: 'object',
|
|
242
|
-
description:
|
|
271
|
+
description: 'A repo operation, ie a mutation of a single record.',
|
|
243
272
|
required: ['action', 'path', 'cid'],
|
|
244
273
|
nullable: ['cid'],
|
|
245
274
|
properties: {
|
|
@@ -252,6 +281,11 @@ exports.ComAtprotoSyncSubscribeRepos = {
|
|
|
252
281
|
},
|
|
253
282
|
cid: {
|
|
254
283
|
type: 'cid-link',
|
|
284
|
+
description: 'For creates and updates, the new record CID. For deletions, null.',
|
|
285
|
+
},
|
|
286
|
+
prev: {
|
|
287
|
+
type: 'cid-link',
|
|
288
|
+
description: 'For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined.',
|
|
255
289
|
},
|
|
256
290
|
},
|
|
257
291
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexicons.js","sourceRoot":"","sources":["../../src/firehose/lexicons.ts"],"names":[],"mappings":";;;AAOA,sBAEC;AAED,0BAKC;
|
|
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;I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EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,CAAC,MAAM,CAAC;YAClB,UAAU,EAAE;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"}
|
package/dist/runner/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface EventRunner {
|
|
2
2
|
getCursor(): Awaited<number | undefined>;
|
|
3
|
-
trackEvent(did: string, seq: number,
|
|
3
|
+
trackEvent(did: string, seq: number, handler: () => Promise<void>): Promise<void>;
|
|
4
4
|
}
|
|
5
5
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAKV,MAAM,qBAAqB,CAAA;AAE5B,eAAO,MAAM,eAAe,QACrB,SAAS,KACb;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,SAKjC,CAAA"}
|
package/dist/util.js
CHANGED
|
@@ -5,7 +5,7 @@ const lexicons_1 = require("./firehose/lexicons");
|
|
|
5
5
|
const didAndSeqForEvt = (evt) => {
|
|
6
6
|
if ((0, lexicons_1.isCommit)(evt))
|
|
7
7
|
return { seq: evt.seq, did: evt.repo };
|
|
8
|
-
else if ((0, lexicons_1.isAccount)(evt) || (0, lexicons_1.isIdentity)(evt))
|
|
8
|
+
else if ((0, lexicons_1.isAccount)(evt) || (0, lexicons_1.isIdentity)(evt) || (0, lexicons_1.isSync)(evt))
|
|
9
9
|
return { seq: evt.seq, did: evt.did };
|
|
10
10
|
return undefined;
|
|
11
11
|
};
|
package/dist/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAAA,
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/sync",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "atproto sync library",
|
|
6
6
|
"keywords": [
|
|
@@ -26,12 +26,13 @@
|
|
|
26
26
|
"ws": "^8.12.0",
|
|
27
27
|
"@atproto/common": "^0.4.8",
|
|
28
28
|
"@atproto/identity": "^0.4.6",
|
|
29
|
-
"@atproto/lexicon": "^0.4.
|
|
30
|
-
"@atproto/repo": "^0.7.
|
|
31
|
-
"@atproto/syntax": "^0.3.
|
|
32
|
-
"@atproto/xrpc-server": "^0.7.
|
|
29
|
+
"@atproto/lexicon": "^0.4.8",
|
|
30
|
+
"@atproto/repo": "^0.7.1",
|
|
31
|
+
"@atproto/syntax": "^0.3.4",
|
|
32
|
+
"@atproto/xrpc-server": "^0.7.12"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
+
"@types/ws": "^8.5.4",
|
|
35
36
|
"jest": "^28.1.2",
|
|
36
37
|
"typescript": "^5.6.3"
|
|
37
38
|
},
|
package/src/events.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { RepoRecord } from '@atproto/lexicon'
|
|
|
4
4
|
import { BlockMap } from '@atproto/repo'
|
|
5
5
|
import { AtUri } from '@atproto/syntax'
|
|
6
6
|
|
|
7
|
-
export type Event = CommitEvt | IdentityEvt | AccountEvt
|
|
7
|
+
export type Event = CommitEvt | SyncEvt | IdentityEvt | AccountEvt
|
|
8
8
|
|
|
9
9
|
export type CommitMeta = {
|
|
10
10
|
seq: number
|
|
@@ -36,6 +36,16 @@ export type Delete = CommitMeta & {
|
|
|
36
36
|
event: 'delete'
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
export type SyncEvt = {
|
|
40
|
+
seq: number
|
|
41
|
+
time: string
|
|
42
|
+
event: 'sync'
|
|
43
|
+
did: string
|
|
44
|
+
cid: CID
|
|
45
|
+
rev: string
|
|
46
|
+
blocks: BlockMap
|
|
47
|
+
}
|
|
48
|
+
|
|
39
49
|
export type IdentityEvt = {
|
|
40
50
|
seq: number
|
|
41
51
|
time: string
|
package/src/firehose/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
formatDataKey,
|
|
13
13
|
parseDataKey,
|
|
14
14
|
readCar,
|
|
15
|
+
readCarWithRoot,
|
|
15
16
|
verifyProofs,
|
|
16
17
|
} from '@atproto/repo'
|
|
17
18
|
import { AtUri } from '@atproto/syntax'
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
CommitMeta,
|
|
24
25
|
Event,
|
|
25
26
|
IdentityEvt,
|
|
27
|
+
SyncEvt,
|
|
26
28
|
} from '../events'
|
|
27
29
|
import { EventRunner } from '../runner'
|
|
28
30
|
import { didAndSeqForEvt } from '../util'
|
|
@@ -32,9 +34,11 @@ import {
|
|
|
32
34
|
type Identity,
|
|
33
35
|
type RepoEvent,
|
|
34
36
|
RepoOp,
|
|
37
|
+
type Sync,
|
|
35
38
|
isAccount,
|
|
36
39
|
isCommit,
|
|
37
40
|
isIdentity,
|
|
41
|
+
isSync,
|
|
38
42
|
isValidRepoEvent,
|
|
39
43
|
} from './lexicons'
|
|
40
44
|
|
|
@@ -57,6 +61,7 @@ export type FirehoseOptions = ClientOptions & {
|
|
|
57
61
|
excludeIdentity?: boolean
|
|
58
62
|
excludeAccount?: boolean
|
|
59
63
|
excludeCommit?: boolean
|
|
64
|
+
excludeSync?: boolean
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
export class Firehose {
|
|
@@ -147,6 +152,9 @@ export class Firehose {
|
|
|
147
152
|
this.opts.unauthenticatedHandles,
|
|
148
153
|
)
|
|
149
154
|
return parsed ? [parsed] : []
|
|
155
|
+
} else if (isSync(evt) && !this.opts.excludeSync) {
|
|
156
|
+
const parsed = await parseSync(evt)
|
|
157
|
+
return parsed ? [parsed] : []
|
|
150
158
|
} else {
|
|
151
159
|
return []
|
|
152
160
|
}
|
|
@@ -279,6 +287,20 @@ const formatCommitOps = async (evt: Commit, ops: RepoOp[]) => {
|
|
|
279
287
|
return evts
|
|
280
288
|
}
|
|
281
289
|
|
|
290
|
+
export const parseSync = async (evt: Sync): Promise<SyncEvt | null> => {
|
|
291
|
+
const car = await readCarWithRoot(evt.blocks)
|
|
292
|
+
|
|
293
|
+
return {
|
|
294
|
+
event: 'sync',
|
|
295
|
+
seq: evt.seq,
|
|
296
|
+
time: evt.time,
|
|
297
|
+
did: evt.did,
|
|
298
|
+
cid: car.root,
|
|
299
|
+
rev: evt.rev,
|
|
300
|
+
blocks: car.blocks,
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
282
304
|
export const parseIdentity = async (
|
|
283
305
|
idResolver: IdResolver,
|
|
284
306
|
evt: Identity,
|
package/src/firehose/lexicons.ts
CHANGED
|
@@ -25,9 +25,7 @@ export type RepoEvent =
|
|
|
25
25
|
| Commit
|
|
26
26
|
| Identity
|
|
27
27
|
| Account
|
|
28
|
-
|
|
|
29
|
-
| Migrate
|
|
30
|
-
| Tombstone
|
|
28
|
+
| Sync
|
|
31
29
|
| Info
|
|
32
30
|
| { $type: string; [k: string]: unknown }
|
|
33
31
|
export type HandlerError = ErrorFrame<'FutureCursor' | 'ConsumerTooSlow'>
|
|
@@ -77,6 +75,29 @@ export function isCommit(v: unknown): v is Commit {
|
|
|
77
75
|
)
|
|
78
76
|
}
|
|
79
77
|
|
|
78
|
+
/** 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. */
|
|
79
|
+
export interface Sync {
|
|
80
|
+
$type?: 'com.atproto.sync.subscribeRepos#sync'
|
|
81
|
+
/** The stream sequence number of this message. */
|
|
82
|
+
seq: number
|
|
83
|
+
/** The account this repo event corresponds to. Must match that in the commit object. */
|
|
84
|
+
did: string
|
|
85
|
+
/** CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'. */
|
|
86
|
+
blocks: Uint8Array
|
|
87
|
+
/** The rev of the commit. This value must match that in the commit object. */
|
|
88
|
+
rev: string
|
|
89
|
+
/** Timestamp of when this message was originally broadcast. */
|
|
90
|
+
time: string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function isSync(v: unknown): v is Sync {
|
|
94
|
+
return (
|
|
95
|
+
isObj(v) &&
|
|
96
|
+
hasProp(v, '$type') &&
|
|
97
|
+
v.$type === 'com.atproto.sync.subscribeRepos#sync'
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
80
101
|
/** 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. */
|
|
81
102
|
export interface Identity {
|
|
82
103
|
seq: number
|
|
@@ -115,56 +136,6 @@ export function isAccount(v: unknown): v is Account {
|
|
|
115
136
|
)
|
|
116
137
|
}
|
|
117
138
|
|
|
118
|
-
/** DEPRECATED -- Use #identity event instead */
|
|
119
|
-
export interface Handle {
|
|
120
|
-
seq: number
|
|
121
|
-
did: string
|
|
122
|
-
handle: string
|
|
123
|
-
time: string
|
|
124
|
-
[k: string]: unknown
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export function isHandle(v: unknown): v is Handle {
|
|
128
|
-
return (
|
|
129
|
-
isObj(v) &&
|
|
130
|
-
hasProp(v, '$type') &&
|
|
131
|
-
v.$type === 'com.atproto.sync.subscribeRepos#handle'
|
|
132
|
-
)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** DEPRECATED -- Use #account event instead */
|
|
136
|
-
export interface Migrate {
|
|
137
|
-
seq: number
|
|
138
|
-
did: string
|
|
139
|
-
migrateTo: string | null
|
|
140
|
-
time: string
|
|
141
|
-
[k: string]: unknown
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function isMigrate(v: unknown): v is Migrate {
|
|
145
|
-
return (
|
|
146
|
-
isObj(v) &&
|
|
147
|
-
hasProp(v, '$type') &&
|
|
148
|
-
v.$type === 'com.atproto.sync.subscribeRepos#migrate'
|
|
149
|
-
)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/** DEPRECATED -- Use #account event instead */
|
|
153
|
-
export interface Tombstone {
|
|
154
|
-
seq: number
|
|
155
|
-
did: string
|
|
156
|
-
time: string
|
|
157
|
-
[k: string]: unknown
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export function isTombstone(v: unknown): v is Tombstone {
|
|
161
|
-
return (
|
|
162
|
-
isObj(v) &&
|
|
163
|
-
hasProp(v, '$type') &&
|
|
164
|
-
v.$type === 'com.atproto.sync.subscribeRepos#tombstone'
|
|
165
|
-
)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
139
|
export interface Info {
|
|
169
140
|
name: 'OutdatedCursor' | string
|
|
170
141
|
message?: string
|
|
@@ -202,13 +173,14 @@ export const ComAtprotoSyncSubscribeRepos: LexiconDoc = {
|
|
|
202
173
|
defs: {
|
|
203
174
|
main: {
|
|
204
175
|
type: 'subscription',
|
|
205
|
-
description:
|
|
176
|
+
description:
|
|
177
|
+
'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.',
|
|
206
178
|
parameters: {
|
|
207
179
|
type: 'params',
|
|
208
180
|
properties: {
|
|
209
181
|
cursor: {
|
|
210
182
|
type: 'integer',
|
|
211
|
-
description: 'The last known event to backfill from.',
|
|
183
|
+
description: 'The last known event seq number to backfill from.',
|
|
212
184
|
},
|
|
213
185
|
},
|
|
214
186
|
},
|
|
@@ -217,9 +189,9 @@ export const ComAtprotoSyncSubscribeRepos: LexiconDoc = {
|
|
|
217
189
|
type: 'union',
|
|
218
190
|
refs: [
|
|
219
191
|
'lex:com.atproto.sync.subscribeRepos#commit',
|
|
220
|
-
'lex:com.atproto.sync.subscribeRepos#
|
|
221
|
-
'lex:com.atproto.sync.subscribeRepos#
|
|
222
|
-
'lex:com.atproto.sync.subscribeRepos#
|
|
192
|
+
'lex:com.atproto.sync.subscribeRepos#sync',
|
|
193
|
+
'lex:com.atproto.sync.subscribeRepos#identity',
|
|
194
|
+
'lex:com.atproto.sync.subscribeRepos#account',
|
|
223
195
|
'lex:com.atproto.sync.subscribeRepos#info',
|
|
224
196
|
],
|
|
225
197
|
},
|
|
@@ -230,11 +202,15 @@ export const ComAtprotoSyncSubscribeRepos: LexiconDoc = {
|
|
|
230
202
|
},
|
|
231
203
|
{
|
|
232
204
|
name: 'ConsumerTooSlow',
|
|
205
|
+
description:
|
|
206
|
+
'If the consumer of the stream can not keep up with events, and a backlog gets too large, the server will drop the connection.',
|
|
233
207
|
},
|
|
234
208
|
],
|
|
235
209
|
},
|
|
236
210
|
commit: {
|
|
237
211
|
type: 'object',
|
|
212
|
+
description:
|
|
213
|
+
'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.',
|
|
238
214
|
required: [
|
|
239
215
|
'seq',
|
|
240
216
|
'rebase',
|
|
@@ -248,45 +224,56 @@ export const ComAtprotoSyncSubscribeRepos: LexiconDoc = {
|
|
|
248
224
|
'blobs',
|
|
249
225
|
'time',
|
|
250
226
|
],
|
|
251
|
-
nullable: ['
|
|
227
|
+
nullable: ['since'],
|
|
252
228
|
properties: {
|
|
253
229
|
seq: {
|
|
254
230
|
type: 'integer',
|
|
231
|
+
description: 'The stream sequence number of this message.',
|
|
255
232
|
},
|
|
256
233
|
rebase: {
|
|
257
234
|
type: 'boolean',
|
|
235
|
+
description: 'DEPRECATED -- unused',
|
|
258
236
|
},
|
|
259
237
|
tooBig: {
|
|
260
238
|
type: 'boolean',
|
|
239
|
+
description:
|
|
240
|
+
'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.',
|
|
261
241
|
},
|
|
262
242
|
repo: {
|
|
263
243
|
type: 'string',
|
|
264
244
|
format: 'did',
|
|
245
|
+
description:
|
|
246
|
+
"The repo this event comes from. Note that all other message types name this field 'did'.",
|
|
265
247
|
},
|
|
266
248
|
commit: {
|
|
267
249
|
type: 'cid-link',
|
|
268
|
-
|
|
269
|
-
prev: {
|
|
270
|
-
type: 'cid-link',
|
|
250
|
+
description: 'Repo commit object CID.',
|
|
271
251
|
},
|
|
272
252
|
rev: {
|
|
273
253
|
type: 'string',
|
|
274
|
-
|
|
254
|
+
format: 'tid',
|
|
255
|
+
description:
|
|
256
|
+
'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.',
|
|
275
257
|
},
|
|
276
258
|
since: {
|
|
277
259
|
type: 'string',
|
|
278
|
-
|
|
260
|
+
format: 'tid',
|
|
261
|
+
description:
|
|
262
|
+
'The rev of the last emitted commit from this repo (if any).',
|
|
279
263
|
},
|
|
280
264
|
blocks: {
|
|
281
265
|
type: 'bytes',
|
|
282
|
-
description:
|
|
283
|
-
|
|
266
|
+
description:
|
|
267
|
+
"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.",
|
|
268
|
+
maxLength: 2000000,
|
|
284
269
|
},
|
|
285
270
|
ops: {
|
|
286
271
|
type: 'array',
|
|
287
272
|
items: {
|
|
288
273
|
type: 'ref',
|
|
289
274
|
ref: 'lex:com.atproto.sync.subscribeRepos#repoOp',
|
|
275
|
+
description:
|
|
276
|
+
'List of repo mutation operations in this commit (eg, records created, updated, or deleted).',
|
|
290
277
|
},
|
|
291
278
|
maxLength: 200,
|
|
292
279
|
},
|
|
@@ -294,39 +281,63 @@ export const ComAtprotoSyncSubscribeRepos: LexiconDoc = {
|
|
|
294
281
|
type: 'array',
|
|
295
282
|
items: {
|
|
296
283
|
type: 'cid-link',
|
|
284
|
+
description:
|
|
285
|
+
'DEPRECATED -- will soon always be empty. List of new blobs (by CID) referenced by records in this commit.',
|
|
297
286
|
},
|
|
298
287
|
},
|
|
288
|
+
prevData: {
|
|
289
|
+
type: 'cid-link',
|
|
290
|
+
description:
|
|
291
|
+
"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.",
|
|
292
|
+
},
|
|
299
293
|
time: {
|
|
300
294
|
type: 'string',
|
|
301
295
|
format: 'datetime',
|
|
296
|
+
description:
|
|
297
|
+
'Timestamp of when this message was originally broadcast.',
|
|
302
298
|
},
|
|
303
299
|
},
|
|
304
300
|
},
|
|
305
|
-
|
|
301
|
+
sync: {
|
|
306
302
|
type: 'object',
|
|
307
|
-
|
|
303
|
+
description:
|
|
304
|
+
'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.',
|
|
305
|
+
required: ['seq', 'did', 'blocks', 'rev', 'time'],
|
|
308
306
|
properties: {
|
|
309
307
|
seq: {
|
|
310
308
|
type: 'integer',
|
|
309
|
+
description: 'The stream sequence number of this message.',
|
|
311
310
|
},
|
|
312
311
|
did: {
|
|
313
312
|
type: 'string',
|
|
314
313
|
format: 'did',
|
|
314
|
+
description:
|
|
315
|
+
'The account this repo event corresponds to. Must match that in the commit object.',
|
|
315
316
|
},
|
|
316
|
-
|
|
317
|
+
blocks: {
|
|
318
|
+
type: 'bytes',
|
|
319
|
+
description:
|
|
320
|
+
"CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'.",
|
|
321
|
+
maxLength: 10000,
|
|
322
|
+
},
|
|
323
|
+
rev: {
|
|
317
324
|
type: 'string',
|
|
318
|
-
|
|
325
|
+
description:
|
|
326
|
+
'The rev of the commit. This value must match that in the commit object.',
|
|
319
327
|
},
|
|
320
328
|
time: {
|
|
321
329
|
type: 'string',
|
|
322
330
|
format: 'datetime',
|
|
331
|
+
description:
|
|
332
|
+
'Timestamp of when this message was originally broadcast.',
|
|
323
333
|
},
|
|
324
334
|
},
|
|
325
335
|
},
|
|
326
|
-
|
|
336
|
+
identity: {
|
|
327
337
|
type: 'object',
|
|
328
|
-
|
|
329
|
-
|
|
338
|
+
description:
|
|
339
|
+
"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.",
|
|
340
|
+
required: ['seq', 'did', 'time'],
|
|
330
341
|
properties: {
|
|
331
342
|
seq: {
|
|
332
343
|
type: 'integer',
|
|
@@ -335,18 +346,23 @@ export const ComAtprotoSyncSubscribeRepos: LexiconDoc = {
|
|
|
335
346
|
type: 'string',
|
|
336
347
|
format: 'did',
|
|
337
348
|
},
|
|
338
|
-
migrateTo: {
|
|
339
|
-
type: 'string',
|
|
340
|
-
},
|
|
341
349
|
time: {
|
|
342
350
|
type: 'string',
|
|
343
351
|
format: 'datetime',
|
|
344
352
|
},
|
|
353
|
+
handle: {
|
|
354
|
+
type: 'string',
|
|
355
|
+
format: 'handle',
|
|
356
|
+
description:
|
|
357
|
+
"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.",
|
|
358
|
+
},
|
|
345
359
|
},
|
|
346
360
|
},
|
|
347
|
-
|
|
361
|
+
account: {
|
|
348
362
|
type: 'object',
|
|
349
|
-
|
|
363
|
+
description:
|
|
364
|
+
"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.",
|
|
365
|
+
required: ['seq', 'did', 'time', 'active'],
|
|
350
366
|
properties: {
|
|
351
367
|
seq: {
|
|
352
368
|
type: 'integer',
|
|
@@ -359,6 +375,24 @@ export const ComAtprotoSyncSubscribeRepos: LexiconDoc = {
|
|
|
359
375
|
type: 'string',
|
|
360
376
|
format: 'datetime',
|
|
361
377
|
},
|
|
378
|
+
active: {
|
|
379
|
+
type: 'boolean',
|
|
380
|
+
description:
|
|
381
|
+
'Indicates that the account has a repository which can be fetched from the host that emitted this event.',
|
|
382
|
+
},
|
|
383
|
+
status: {
|
|
384
|
+
type: 'string',
|
|
385
|
+
description:
|
|
386
|
+
'If active=false, this optional field indicates a reason for why the account is not active.',
|
|
387
|
+
knownValues: [
|
|
388
|
+
'takendown',
|
|
389
|
+
'suspended',
|
|
390
|
+
'deleted',
|
|
391
|
+
'deactivated',
|
|
392
|
+
'desynchronized',
|
|
393
|
+
'throttled',
|
|
394
|
+
],
|
|
395
|
+
},
|
|
362
396
|
},
|
|
363
397
|
},
|
|
364
398
|
info: {
|
|
@@ -376,8 +410,7 @@ export const ComAtprotoSyncSubscribeRepos: LexiconDoc = {
|
|
|
376
410
|
},
|
|
377
411
|
repoOp: {
|
|
378
412
|
type: 'object',
|
|
379
|
-
description:
|
|
380
|
-
"A repo operation, ie a write of a single record. For creates and updates, cid is the record's CID as of this operation. For deletes, it's null.",
|
|
413
|
+
description: 'A repo operation, ie a mutation of a single record.',
|
|
381
414
|
required: ['action', 'path', 'cid'],
|
|
382
415
|
nullable: ['cid'],
|
|
383
416
|
properties: {
|
|
@@ -390,6 +423,13 @@ export const ComAtprotoSyncSubscribeRepos: LexiconDoc = {
|
|
|
390
423
|
},
|
|
391
424
|
cid: {
|
|
392
425
|
type: 'cid-link',
|
|
426
|
+
description:
|
|
427
|
+
'For creates and updates, the new record CID. For deletions, null.',
|
|
428
|
+
},
|
|
429
|
+
prev: {
|
|
430
|
+
type: 'cid-link',
|
|
431
|
+
description:
|
|
432
|
+
'For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined.',
|
|
393
433
|
},
|
|
394
434
|
},
|
|
395
435
|
},
|
package/src/runner/types.ts
CHANGED
package/src/util.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
RepoEvent,
|
|
3
|
+
isAccount,
|
|
4
|
+
isCommit,
|
|
5
|
+
isIdentity,
|
|
6
|
+
isSync,
|
|
7
|
+
} from './firehose/lexicons'
|
|
2
8
|
|
|
3
9
|
export const didAndSeqForEvt = (
|
|
4
10
|
evt: RepoEvent,
|
|
5
11
|
): { did: string; seq: number } | undefined => {
|
|
6
12
|
if (isCommit(evt)) return { seq: evt.seq, did: evt.repo }
|
|
7
|
-
else if (isAccount(evt) || isIdentity(evt))
|
|
13
|
+
else if (isAccount(evt) || isIdentity(evt) || isSync(evt))
|
|
8
14
|
return { seq: evt.seq, did: evt.did }
|
|
9
15
|
return undefined
|
|
10
16
|
}
|
package/tests/firehose.test.ts
CHANGED
|
@@ -60,7 +60,7 @@ describe('firehose', () => {
|
|
|
60
60
|
let alice: string
|
|
61
61
|
|
|
62
62
|
it('reads events from firehose', async () => {
|
|
63
|
-
const evtsPromise = createAndReadFirehose(
|
|
63
|
+
const evtsPromise = createAndReadFirehose(6)
|
|
64
64
|
await wait(10) // give the websocket just a second to spin up
|
|
65
65
|
const aliceRes = await sc.createAccount('alice', {
|
|
66
66
|
handle: 'alice.test',
|
|
@@ -73,7 +73,7 @@ describe('firehose', () => {
|
|
|
73
73
|
await sc.post(alice, 'three')
|
|
74
74
|
|
|
75
75
|
const evts = await evtsPromise
|
|
76
|
-
expect(evts.length).toBe(
|
|
76
|
+
expect(evts.length).toBe(6)
|
|
77
77
|
expect(evts.at(0)).toMatchObject({
|
|
78
78
|
event: 'identity',
|
|
79
79
|
did: alice,
|
|
@@ -89,6 +89,10 @@ describe('firehose', () => {
|
|
|
89
89
|
status: undefined,
|
|
90
90
|
})
|
|
91
91
|
expect(evts.at(2)).toMatchObject({
|
|
92
|
+
event: 'sync',
|
|
93
|
+
did: alice,
|
|
94
|
+
})
|
|
95
|
+
expect(evts.at(3)).toMatchObject({
|
|
92
96
|
event: 'create',
|
|
93
97
|
did: alice,
|
|
94
98
|
collection: 'app.bsky.feed.post',
|
|
@@ -96,7 +100,7 @@ describe('firehose', () => {
|
|
|
96
100
|
text: 'one',
|
|
97
101
|
},
|
|
98
102
|
})
|
|
99
|
-
expect(evts.at(
|
|
103
|
+
expect(evts.at(4)).toMatchObject({
|
|
100
104
|
event: 'create',
|
|
101
105
|
did: alice,
|
|
102
106
|
collection: 'app.bsky.feed.post',
|
|
@@ -104,7 +108,7 @@ describe('firehose', () => {
|
|
|
104
108
|
text: 'two',
|
|
105
109
|
},
|
|
106
110
|
})
|
|
107
|
-
expect(evts.at(
|
|
111
|
+
expect(evts.at(5)).toMatchObject({
|
|
108
112
|
event: 'create',
|
|
109
113
|
did: alice,
|
|
110
114
|
collection: 'app.bsky.feed.post',
|
|
@@ -130,7 +134,7 @@ describe('firehose', () => {
|
|
|
130
134
|
const runner = new MemoryRunner({
|
|
131
135
|
startCursor: currCursor ?? undefined,
|
|
132
136
|
})
|
|
133
|
-
const evtsPromise = createAndReadFirehose(
|
|
137
|
+
const evtsPromise = createAndReadFirehose(24, { runner }, true)
|
|
134
138
|
const createAndPost = async (name: string) => {
|
|
135
139
|
const user = await sc.createAccount('name', {
|
|
136
140
|
handle: `${name}.test`,
|
|
@@ -159,22 +163,29 @@ describe('firehose', () => {
|
|
|
159
163
|
const user2Evts = evts.filter((e) => e.did === res[1].did)
|
|
160
164
|
const user3Evts = evts.filter((e) => e.did === res[2].did)
|
|
161
165
|
const user4Evts = evts.filter((e) => e.did === res[3].did)
|
|
162
|
-
const EVT_ORDER = [
|
|
166
|
+
const EVT_ORDER = [
|
|
167
|
+
'identity',
|
|
168
|
+
'account',
|
|
169
|
+
'sync',
|
|
170
|
+
'create',
|
|
171
|
+
'create',
|
|
172
|
+
'create',
|
|
173
|
+
]
|
|
163
174
|
expect(user1Evts.map((e) => e.event)).toEqual(EVT_ORDER)
|
|
164
175
|
expect(user2Evts.map((e) => e.event)).toEqual(EVT_ORDER)
|
|
165
176
|
expect(user3Evts.map((e) => e.event)).toEqual(EVT_ORDER)
|
|
166
177
|
expect(user4Evts.map((e) => e.event)).toEqual(EVT_ORDER)
|
|
167
178
|
expect(
|
|
168
|
-
user1Evts.slice(
|
|
179
|
+
user1Evts.slice(3, 6).map((e) => (e as Create).uri.toString()),
|
|
169
180
|
).toEqual([res[0].post1, res[0].post2, res[0].post3])
|
|
170
181
|
expect(
|
|
171
|
-
user2Evts.slice(
|
|
182
|
+
user2Evts.slice(3, 6).map((e) => (e as Create).uri.toString()),
|
|
172
183
|
).toEqual([res[1].post1, res[1].post2, res[1].post3])
|
|
173
184
|
expect(
|
|
174
|
-
user3Evts.slice(
|
|
185
|
+
user3Evts.slice(3, 6).map((e) => (e as Create).uri.toString()),
|
|
175
186
|
).toEqual([res[2].post1, res[2].post2, res[2].post3])
|
|
176
187
|
expect(
|
|
177
|
-
user4Evts.slice(
|
|
188
|
+
user4Evts.slice(3, 6).map((e) => (e as Create).uri.toString()),
|
|
178
189
|
).toEqual([res[3].post1, res[3].post2, res[3].post3])
|
|
179
190
|
})
|
|
180
191
|
})
|