@atproto/sync 0.1.40 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/events.d.ts +12 -13
  3. package/dist/events.d.ts.map +1 -1
  4. package/dist/events.js.map +1 -1
  5. package/dist/firehose/index.d.ts +8 -8
  6. package/dist/firehose/index.d.ts.map +1 -1
  7. package/dist/firehose/index.js +23 -13
  8. package/dist/firehose/index.js.map +1 -1
  9. package/dist/lexicons/com/atproto/sync/subscribeRepos.d.ts +3 -0
  10. package/dist/lexicons/com/atproto/sync/subscribeRepos.d.ts.map +1 -0
  11. package/dist/lexicons/com/atproto/sync/subscribeRepos.defs.d.ts +152 -0
  12. package/dist/lexicons/com/atproto/sync/subscribeRepos.defs.d.ts.map +1 -0
  13. package/dist/lexicons/com/atproto/sync/subscribeRepos.defs.js +75 -0
  14. package/dist/lexicons/com/atproto/sync/subscribeRepos.defs.js.map +1 -0
  15. package/dist/lexicons/com/atproto/sync/subscribeRepos.js +45 -0
  16. package/dist/lexicons/com/atproto/sync/subscribeRepos.js.map +1 -0
  17. package/dist/lexicons/com/atproto/sync.d.ts +2 -0
  18. package/dist/lexicons/com/atproto/sync.d.ts.map +1 -0
  19. package/dist/lexicons/com/atproto/sync.js +41 -0
  20. package/dist/lexicons/com/atproto/sync.js.map +1 -0
  21. package/dist/lexicons/com/atproto.d.ts +2 -0
  22. package/dist/lexicons/com/atproto.d.ts.map +1 -0
  23. package/dist/lexicons/com/atproto.js +41 -0
  24. package/dist/lexicons/com/atproto.js.map +1 -0
  25. package/dist/lexicons/com.d.ts +2 -0
  26. package/dist/lexicons/com.d.ts.map +1 -0
  27. package/dist/lexicons/com.js +41 -0
  28. package/dist/lexicons/com.js.map +1 -0
  29. package/dist/lexicons/index.d.ts +2 -0
  30. package/dist/lexicons/index.d.ts.map +1 -0
  31. package/dist/lexicons/index.js +41 -0
  32. package/dist/lexicons/index.js.map +1 -0
  33. package/dist/util.d.ts +2 -2
  34. package/dist/util.d.ts.map +1 -1
  35. package/dist/util.js +7 -3
  36. package/dist/util.js.map +1 -1
  37. package/package.json +8 -7
  38. package/src/events.ts +12 -13
  39. package/src/firehose/index.ts +53 -45
  40. package/src/util.ts +10 -10
  41. package/tests/firehose.test.ts +11 -8
  42. package/tests/runner.test.ts +1 -1
  43. package/tsconfig.build.tsbuildinfo +1 -1
  44. package/tsconfig.json +4 -1
  45. package/tsconfig.tests.json +8 -0
  46. package/dist/firehose/lexicons.d.ts +0 -105
  47. package/dist/firehose/lexicons.d.ts.map +0 -1
  48. package/dist/firehose/lexicons.js +0 -299
  49. package/dist/firehose/lexicons.js.map +0 -1
  50. package/src/firehose/lexicons.ts +0 -446
@@ -1,299 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isValidRepoEvent = exports.ComAtprotoSyncSubscribeRepos = void 0;
4
- exports.isObj = isObj;
5
- exports.hasProp = hasProp;
6
- exports.isCommit = isCommit;
7
- exports.isSync = isSync;
8
- exports.isIdentity = isIdentity;
9
- exports.isAccount = isAccount;
10
- exports.isInfo = isInfo;
11
- exports.isRepoOp = isRepoOp;
12
- const lexicon_1 = require("@atproto/lexicon");
13
- // @NOTE: this file is an ugly copy job of codegen output. I'd like to clean this whole thing up
14
- function isObj(v) {
15
- return typeof v === 'object' && v !== null;
16
- }
17
- function hasProp(data, prop) {
18
- return prop in data;
19
- }
20
- function isCommit(v) {
21
- return (isObj(v) &&
22
- hasProp(v, '$type') &&
23
- v.$type === 'com.atproto.sync.subscribeRepos#commit');
24
- }
25
- function isSync(v) {
26
- return (isObj(v) &&
27
- hasProp(v, '$type') &&
28
- v.$type === 'com.atproto.sync.subscribeRepos#sync');
29
- }
30
- function isIdentity(v) {
31
- return (isObj(v) &&
32
- hasProp(v, '$type') &&
33
- v.$type === 'com.atproto.sync.subscribeRepos#identity');
34
- }
35
- function isAccount(v) {
36
- return (isObj(v) &&
37
- hasProp(v, '$type') &&
38
- v.$type === 'com.atproto.sync.subscribeRepos#account');
39
- }
40
- function isInfo(v) {
41
- return (isObj(v) &&
42
- hasProp(v, '$type') &&
43
- v.$type === 'com.atproto.sync.subscribeRepos#info');
44
- }
45
- function isRepoOp(v) {
46
- return (isObj(v) &&
47
- hasProp(v, '$type') &&
48
- v.$type === 'com.atproto.sync.subscribeRepos#repoOp');
49
- }
50
- exports.ComAtprotoSyncSubscribeRepos = {
51
- lexicon: 1,
52
- id: 'com.atproto.sync.subscribeRepos',
53
- defs: {
54
- main: {
55
- type: 'subscription',
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.',
57
- parameters: {
58
- type: 'params',
59
- properties: {
60
- cursor: {
61
- type: 'integer',
62
- description: 'The last known event seq number to backfill from.',
63
- },
64
- },
65
- },
66
- message: {
67
- schema: {
68
- type: 'union',
69
- refs: [
70
- 'lex:com.atproto.sync.subscribeRepos#commit',
71
- 'lex:com.atproto.sync.subscribeRepos#sync',
72
- 'lex:com.atproto.sync.subscribeRepos#identity',
73
- 'lex:com.atproto.sync.subscribeRepos#account',
74
- 'lex:com.atproto.sync.subscribeRepos#info',
75
- ],
76
- },
77
- },
78
- errors: [
79
- {
80
- name: 'FutureCursor',
81
- },
82
- {
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.',
85
- },
86
- ],
87
- },
88
- commit: {
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.',
91
- required: [
92
- 'seq',
93
- 'rebase',
94
- 'tooBig',
95
- 'repo',
96
- 'commit',
97
- 'rev',
98
- 'since',
99
- 'blocks',
100
- 'ops',
101
- 'blobs',
102
- 'time',
103
- ],
104
- nullable: ['since'],
105
- properties: {
106
- seq: {
107
- type: 'integer',
108
- description: 'The stream sequence number of this message.',
109
- },
110
- rebase: {
111
- type: 'boolean',
112
- description: 'DEPRECATED -- unused',
113
- },
114
- tooBig: {
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.',
117
- },
118
- repo: {
119
- type: 'string',
120
- format: 'did',
121
- description: "The repo this event comes from. Note that all other message types name this field 'did'.",
122
- },
123
- commit: {
124
- type: 'cid-link',
125
- description: 'Repo commit object CID.',
126
- },
127
- rev: {
128
- type: 'string',
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.',
131
- },
132
- since: {
133
- type: 'string',
134
- format: 'tid',
135
- description: 'The rev of the last emitted commit from this repo (if any).',
136
- },
137
- blocks: {
138
- type: 'bytes',
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,
141
- },
142
- ops: {
143
- type: 'array',
144
- items: {
145
- type: 'ref',
146
- ref: 'lex:com.atproto.sync.subscribeRepos#repoOp',
147
- description: 'List of repo mutation operations in this commit (eg, records created, updated, or deleted).',
148
- },
149
- maxLength: 200,
150
- },
151
- blobs: {
152
- type: 'array',
153
- items: {
154
- type: 'cid-link',
155
- description: 'DEPRECATED -- will soon always be empty. List of new blobs (by CID) referenced by records in this commit.',
156
- },
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
- time: {
163
- type: 'string',
164
- format: 'datetime',
165
- description: 'Timestamp of when this message was originally broadcast.',
166
- },
167
- },
168
- },
169
- sync: {
170
- type: 'object',
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'],
173
- properties: {
174
- seq: {
175
- type: 'integer',
176
- description: 'The stream sequence number of this message.',
177
- },
178
- did: {
179
- type: 'string',
180
- format: 'did',
181
- description: 'The account this repo event corresponds to. Must match that in the commit object.',
182
- },
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: {
189
- type: 'string',
190
- description: 'The rev of the commit. This value must match that in the commit object.',
191
- },
192
- time: {
193
- type: 'string',
194
- format: 'datetime',
195
- description: 'Timestamp of when this message was originally broadcast.',
196
- },
197
- },
198
- },
199
- identity: {
200
- type: 'object',
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'],
203
- properties: {
204
- seq: {
205
- type: 'integer',
206
- },
207
- did: {
208
- type: 'string',
209
- format: 'did',
210
- },
211
- time: {
212
- type: 'string',
213
- format: 'datetime',
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
- },
220
- },
221
- },
222
- account: {
223
- type: 'object',
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'],
226
- properties: {
227
- seq: {
228
- type: 'integer',
229
- },
230
- did: {
231
- type: 'string',
232
- format: 'did',
233
- },
234
- time: {
235
- type: 'string',
236
- format: 'datetime',
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
- },
254
- },
255
- },
256
- info: {
257
- type: 'object',
258
- required: ['name'],
259
- properties: {
260
- name: {
261
- type: 'string',
262
- knownValues: ['OutdatedCursor'],
263
- },
264
- message: {
265
- type: 'string',
266
- },
267
- },
268
- },
269
- repoOp: {
270
- type: 'object',
271
- description: 'A repo operation, ie a mutation of a single record.',
272
- required: ['action', 'path', 'cid'],
273
- nullable: ['cid'],
274
- properties: {
275
- action: {
276
- type: 'string',
277
- knownValues: ['create', 'update', 'delete'],
278
- },
279
- path: {
280
- type: 'string',
281
- },
282
- cid: {
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.',
289
- },
290
- },
291
- },
292
- },
293
- };
294
- const lexicons = new lexicon_1.Lexicons([exports.ComAtprotoSyncSubscribeRepos]);
295
- const isValidRepoEvent = (evt) => {
296
- return lexicons.assertValidXrpcMessage('com.atproto.sync.subscribeRepos', evt);
297
- };
298
- exports.isValidRepoEvent = isValidRepoEvent;
299
- //# sourceMappingURL=lexicons.js.map
@@ -1 +0,0 @@
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,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ACF;SACF;QACD,IAAI,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","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"]}