@atproto/pds 0.4.100 → 0.4.102
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 +20 -0
- package/dist/actor-store/repo/transactor.d.ts +5 -5
- package/dist/actor-store/repo/transactor.d.ts.map +1 -1
- package/dist/actor-store/repo/transactor.js +38 -18
- package/dist/actor-store/repo/transactor.js.map +1 -1
- package/dist/actor-store/repo/util.d.ts +5 -0
- package/dist/actor-store/repo/util.d.ts.map +1 -0
- package/dist/actor-store/repo/util.js +25 -0
- package/dist/actor-store/repo/util.js.map +1 -0
- package/dist/api/com/atproto/repo/applyWrites.js +1 -1
- package/dist/api/com/atproto/repo/applyWrites.js.map +1 -1
- package/dist/api/com/atproto/repo/createRecord.d.ts.map +1 -1
- package/dist/api/com/atproto/repo/createRecord.js +3 -3
- package/dist/api/com/atproto/repo/createRecord.js.map +1 -1
- package/dist/api/com/atproto/repo/deleteRecord.js +1 -1
- package/dist/api/com/atproto/repo/deleteRecord.js.map +1 -1
- package/dist/api/com/atproto/repo/putRecord.d.ts.map +1 -1
- package/dist/api/com/atproto/repo/putRecord.js +1 -1
- package/dist/api/com/atproto/repo/putRecord.js.map +1 -1
- package/dist/api/com/atproto/server/activateAccount.d.ts.map +1 -1
- package/dist/api/com/atproto/server/activateAccount.js +4 -1
- package/dist/api/com/atproto/server/activateAccount.js.map +1 -1
- package/dist/api/com/atproto/server/createAccount.js +1 -1
- package/dist/api/com/atproto/server/createAccount.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lexicon/index.d.ts +2 -0
- package/dist/lexicon/index.d.ts.map +1 -1
- package/dist/lexicon/index.js +4 -0
- package/dist/lexicon/index.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +166 -32
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +105 -15
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/chat/bsky/convo/updateAllRead.d.ts +40 -0
- package/dist/lexicon/types/chat/bsky/convo/updateAllRead.d.ts.map +1 -0
- package/dist/lexicon/types/chat/bsky/convo/updateAllRead.js +7 -0
- package/dist/lexicon/types/chat/bsky/convo/updateAllRead.js.map +1 -0
- package/dist/lexicon/types/com/atproto/sync/getRepoStatus.d.ts +1 -1
- package/dist/lexicon/types/com/atproto/sync/getRepoStatus.d.ts.map +1 -1
- package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts +1 -1
- package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts.map +1 -1
- package/dist/lexicon/types/com/atproto/sync/listRepos.js.map +1 -1
- package/dist/lexicon/types/com/atproto/sync/subscribeRepos.d.ts +25 -7
- package/dist/lexicon/types/com/atproto/sync/subscribeRepos.d.ts.map +1 -1
- package/dist/lexicon/types/com/atproto/sync/subscribeRepos.js +9 -0
- package/dist/lexicon/types/com/atproto/sync/subscribeRepos.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts +2 -2
- package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts.map +1 -1
- package/dist/repo/types.d.ts +12 -1
- package/dist/repo/types.d.ts.map +1 -1
- package/dist/repo/types.js.map +1 -1
- package/dist/scripts/rebuild-repo.d.ts.map +1 -1
- package/dist/scripts/rebuild-repo.js +4 -1
- package/dist/scripts/rebuild-repo.js.map +1 -1
- package/dist/sequencer/events.d.ts +22 -16
- package/dist/sequencer/events.d.ts.map +1 -1
- package/dist/sequencer/events.js +31 -39
- package/dist/sequencer/events.js.map +1 -1
- package/dist/sequencer/sequencer.d.ts +2 -3
- package/dist/sequencer/sequencer.d.ts.map +1 -1
- package/dist/sequencer/sequencer.js +2 -2
- package/dist/sequencer/sequencer.js.map +1 -1
- package/package.json +6 -6
- package/src/actor-store/repo/transactor.ts +47 -21
- package/src/actor-store/repo/util.ts +22 -0
- package/src/api/com/atproto/repo/applyWrites.ts +1 -1
- package/src/api/com/atproto/repo/createRecord.ts +28 -31
- package/src/api/com/atproto/repo/deleteRecord.ts +1 -1
- package/src/api/com/atproto/repo/putRecord.ts +3 -3
- package/src/api/com/atproto/server/activateAccount.ts +4 -1
- package/src/api/com/atproto/server/createAccount.ts +1 -1
- package/src/index.ts +1 -1
- package/src/lexicon/index.ts +12 -0
- package/src/lexicon/lexicons.ts +114 -16
- package/src/lexicon/types/chat/bsky/convo/updateAllRead.ts +53 -0
- package/src/lexicon/types/com/atproto/sync/getRepoStatus.ts +8 -1
- package/src/lexicon/types/com/atproto/sync/listRepos.ts +8 -1
- package/src/lexicon/types/com/atproto/sync/subscribeRepos.ts +41 -6
- package/src/lexicon/types/tools/ozone/moderation/defs.ts +2 -2
- package/src/repo/types.ts +14 -1
- package/src/scripts/rebuild-repo.ts +4 -1
- package/src/sequencer/events.ts +35 -49
- package/src/sequencer/sequencer.ts +3 -5
- package/tests/crud.test.ts +1 -1
- package/tests/sequencer.test.ts +1 -5
- package/tests/sync/invertible-ops.test.ts +104 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.tests.tsbuildinfo +1 -1
package/dist/sequencer/events.js
CHANGED
@@ -5,58 +5,49 @@ const zod_1 = require("zod");
|
|
5
5
|
const common_1 = require("@atproto/common");
|
6
6
|
const repo_1 = require("@atproto/repo");
|
7
7
|
const account_manager_1 = require("../account-manager");
|
8
|
-
const formatSeqCommit = async (did, commitData
|
9
|
-
let tooBig;
|
10
|
-
const ops = [];
|
11
|
-
const blobs = new repo_1.CidSet();
|
12
|
-
let carSlice;
|
8
|
+
const formatSeqCommit = async (did, commitData) => {
|
13
9
|
const blocksToSend = new repo_1.BlockMap();
|
14
10
|
blocksToSend.addMap(commitData.newBlocks);
|
15
11
|
blocksToSend.addMap(commitData.relevantBlocks);
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
let evt;
|
13
|
+
// If event is too big (max 200 ops or 1MB of data)
|
14
|
+
if (commitData.ops.length > 200 || blocksToSend.byteSize > 1000000) {
|
19
15
|
const justRoot = new repo_1.BlockMap();
|
20
16
|
const rootBlock = blocksToSend.get(commitData.cid);
|
21
17
|
if (rootBlock) {
|
22
18
|
justRoot.set(commitData.cid, rootBlock);
|
23
19
|
}
|
24
|
-
|
20
|
+
evt = {
|
21
|
+
rebase: false,
|
22
|
+
tooBig: true,
|
23
|
+
repo: did,
|
24
|
+
commit: commitData.cid,
|
25
|
+
rev: commitData.rev,
|
26
|
+
since: commitData.since,
|
27
|
+
blocks: await (0, repo_1.blocksToCarFile)(commitData.cid, justRoot),
|
28
|
+
ops: [],
|
29
|
+
blobs: [],
|
30
|
+
prevData: commitData.prevData ?? undefined,
|
31
|
+
};
|
25
32
|
}
|
26
33
|
else {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
}
|
40
|
-
ops.push({ action: w.action, path, cid });
|
41
|
-
}
|
42
|
-
carSlice = await (0, repo_1.blocksToCarFile)(commitData.cid, blocksToSend);
|
34
|
+
evt = {
|
35
|
+
rebase: false,
|
36
|
+
tooBig: false,
|
37
|
+
repo: did,
|
38
|
+
commit: commitData.cid,
|
39
|
+
rev: commitData.rev,
|
40
|
+
since: commitData.since,
|
41
|
+
blocks: await (0, repo_1.blocksToCarFile)(commitData.cid, blocksToSend),
|
42
|
+
ops: commitData.ops,
|
43
|
+
blobs: commitData.blobs.toList(),
|
44
|
+
prevData: commitData.prevData ?? undefined,
|
45
|
+
};
|
43
46
|
}
|
44
|
-
const evt = {
|
45
|
-
rebase: false,
|
46
|
-
tooBig,
|
47
|
-
repo: did,
|
48
|
-
commit: commitData.cid,
|
49
|
-
prev: commitData.prev,
|
50
|
-
rev: commitData.rev,
|
51
|
-
since: commitData.since,
|
52
|
-
ops,
|
53
|
-
blocks: carSlice,
|
54
|
-
blobs: blobs.toList(),
|
55
|
-
};
|
56
47
|
return {
|
57
48
|
did,
|
58
49
|
eventType: 'append',
|
59
|
-
event: (0, common_1.cborEncode)(evt),
|
50
|
+
event: (0, common_1.cborEncode)((0, common_1.noUndefinedVals)(evt)),
|
60
51
|
sequencedAt: new Date().toISOString(),
|
61
52
|
};
|
62
53
|
};
|
@@ -125,18 +116,19 @@ exports.commitEvtOp = zod_1.z.object({
|
|
125
116
|
]),
|
126
117
|
path: zod_1.z.string(),
|
127
118
|
cid: common_1.schema.cid.nullable(),
|
119
|
+
prev: common_1.schema.cid.optional(),
|
128
120
|
});
|
129
121
|
exports.commitEvt = zod_1.z.object({
|
130
122
|
rebase: zod_1.z.boolean(),
|
131
123
|
tooBig: zod_1.z.boolean(),
|
132
124
|
repo: zod_1.z.string(),
|
133
125
|
commit: common_1.schema.cid,
|
134
|
-
prev: common_1.schema.cid.nullable(),
|
135
126
|
rev: zod_1.z.string(),
|
136
127
|
since: zod_1.z.string().nullable(),
|
137
128
|
blocks: common_1.schema.bytes,
|
138
129
|
ops: zod_1.z.array(exports.commitEvtOp),
|
139
130
|
blobs: zod_1.z.array(common_1.schema.cid),
|
131
|
+
prevData: common_1.schema.cid.optional(),
|
140
132
|
});
|
141
133
|
exports.handleEvt = zod_1.z.object({
|
142
134
|
did: zod_1.z.string(),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/sequencer/events.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/sequencer/events.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AACvB,4CAAqE;AACrE,wCAAyD;AACzD,wDAAkD;AAI3C,MAAM,eAAe,GAAG,KAAK,EAClC,GAAW,EACX,UAA6B,EACL,EAAE;IAC1B,MAAM,YAAY,GAAG,IAAI,eAAQ,EAAE,CAAA;IACnC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;IACzC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,CAAA;I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,EAAE;IAC5B,MAAM,EAAE,eAAM,CAAC,KAAK;IACpB,GAAG,EAAE,OAAC,CAAC,KAAK,CAAC,mBAAW,CAAC;IACzB,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,eAAM,CAAC,GAAG,CAAC;IAC1B,QAAQ,EAAE,eAAM,CAAC,GAAG,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAA;AAGW,QAAA,SAAS,GAAG,OAAC,CAAC,MAAM,CAAC;IAChC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;CACnB,CAAC,CAAA;AAGW,QAAA,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAClC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAA;AAGW,QAAA,UAAU,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,MAAM,EAAE,OAAC,CAAC,OAAO,EAAE;IACnB,MAAM,EAAE,OAAC;SACN,IAAI,CAAC;QACJ,+BAAa,CAAC,SAAS;QACvB,+BAAa,CAAC,SAAS;QACvB,+BAAa,CAAC,OAAO;QACrB,+BAAa,CAAC,WAAW;KAC1B,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAA;AAGW,QAAA,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IACnC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;CAChB,CAAC,CAAA"}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import TypedEmitter from 'typed-emitter';
|
2
|
-
import { CommitData } from '@atproto/repo';
|
3
2
|
import { AccountStatus } from '../account-manager/helpers/account';
|
4
3
|
import { Crawlers } from '../crawlers';
|
5
|
-
import {
|
4
|
+
import { CommitDataWithOps } from '../repo';
|
6
5
|
import { RepoSeqEntry, RepoSeqInsert, SequencerDb } from './db';
|
7
6
|
import { SeqEvt } from './events';
|
8
7
|
export * from './events';
|
@@ -29,7 +28,7 @@ export declare class Sequencer extends Sequencer_base {
|
|
29
28
|
private pollDb;
|
30
29
|
private exponentialBackoff;
|
31
30
|
sequenceEvt(evt: RepoSeqInsert): Promise<number>;
|
32
|
-
sequenceCommit(did: string, commitData:
|
31
|
+
sequenceCommit(did: string, commitData: CommitDataWithOps): Promise<number>;
|
33
32
|
sequenceHandleUpdate(did: string, handle: string): Promise<number>;
|
34
33
|
sequenceIdentityEvt(did: string, handle?: string): Promise<number>;
|
35
34
|
sequenceAccountEvt(did: string, status: AccountStatus): Promise<number>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sequencer.d.ts","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"sequencer.d.ts","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,WAAW,EAGZ,MAAM,MAAM,CAAA;AACb,OAAO,EAKL,MAAM,EAOP,MAAM,UAAU,CAAA;AAEjB,cAAc,UAAU,CAAA;wCAEkC,gBAAgB;AAA1E,qBAAa,SAAU,SAAQ,cAA4C;IAQhE,QAAQ,EAAE,QAAQ;IAClB,QAAQ;IARjB,EAAE,EAAE,WAAW,CAAA;IACf,SAAS,UAAQ;IACjB,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAO;IACxC,kBAAkB,SAAI;gBAGpB,UAAU,EAAE,MAAM,E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IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IAChC,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,eAAe,CAAC,CAAA;AAE5D,eAAe,SAAS,CAAA"}
|
@@ -222,8 +222,8 @@ class Sequencer extends node_events_1.default {
|
|
222
222
|
this.crawlers.notifyOfUpdate();
|
223
223
|
return res[0].seq;
|
224
224
|
}
|
225
|
-
async sequenceCommit(did, commitData
|
226
|
-
const evt = await (0, events_1.formatSeqCommit)(did, commitData
|
225
|
+
async sequenceCommit(did, commitData) {
|
226
|
+
const evt = await (0, events_1.formatSeqCommit)(did, commitData);
|
227
227
|
return await this.sequenceEvt(evt);
|
228
228
|
}
|
229
229
|
async sequenceHandleUpdate(did, handle) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sequencer.js","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,8DAAsC;AAEtC,4CAA0D;
|
1
|
+
{"version":3,"file":"sequencer.js","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,8DAAsC;AAEtC,4CAA0D;AAG1D,sCAA4C;AAE5C,6BAMa;AACb,qCAYiB;AAEjB,2CAAwB;AAExB,MAAa,SAAU,SAAS,qBAA2C;IAMzE,YACE,UAAkB,EACX,QAAkB,EAClB,WAAW,CAAC,EACnB,wBAAwB,GAAG,KAAK;QAEhC,KAAK,EAAE,CAAA;QAJP;;;;mBAAO,QAAQ;WAAU;QACzB;;;;mBAAO,QAAQ;WAAI;QARrB;;;;;WAAe;QACf;;;;mBAAY,KAAK;WAAA;QACjB;;;;mBAAoC,IAAI;WAAA;QACxC;;;;mBAAqB,CAAC;WAAA;QASpB,0EAA0E;QAC1E,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;QACzB,IAAI,CAA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": "MIT",
|
5
5
|
"description": "Reference implementation of atproto Personal Data Server (PDS)",
|
6
6
|
"keywords": [
|
@@ -50,14 +50,14 @@
|
|
50
50
|
"zod": "^3.23.8",
|
51
51
|
"@atproto-labs/fetch-node": "0.1.7",
|
52
52
|
"@atproto-labs/xrpc-utils": "0.0.7",
|
53
|
-
"@atproto/api": "^0.14.
|
54
|
-
"@atproto/aws": "^0.2.
|
53
|
+
"@atproto/api": "^0.14.6",
|
54
|
+
"@atproto/aws": "^0.2.16",
|
55
55
|
"@atproto/common": "^0.4.8",
|
56
56
|
"@atproto/crypto": "^0.4.4",
|
57
57
|
"@atproto/identity": "^0.4.6",
|
58
58
|
"@atproto/lexicon": "^0.4.7",
|
59
59
|
"@atproto/oauth-provider": "^0.3.1",
|
60
|
-
"@atproto/repo": "^0.
|
60
|
+
"@atproto/repo": "^0.7.0",
|
61
61
|
"@atproto/syntax": "^0.3.3",
|
62
62
|
"@atproto/xrpc": "^0.6.9",
|
63
63
|
"@atproto/xrpc-server": "^0.7.11"
|
@@ -78,8 +78,8 @@
|
|
78
78
|
"ts-node": "^10.8.2",
|
79
79
|
"typescript": "^5.6.3",
|
80
80
|
"ws": "^8.12.0",
|
81
|
-
"@atproto/api": "^0.14.
|
82
|
-
"@atproto/bsky": "^0.0.
|
81
|
+
"@atproto/api": "^0.14.6",
|
82
|
+
"@atproto/bsky": "^0.0.123",
|
83
83
|
"@atproto/lex-cli": "^0.6.1",
|
84
84
|
"@atproto/oauth-client-browser-example": "0.0.1"
|
85
85
|
},
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { CID } from 'multiformats/cid'
|
2
2
|
import * as crypto from '@atproto/crypto'
|
3
|
-
import { BlobStore,
|
3
|
+
import { BlobStore, Repo, WriteOpAction, formatDataKey } from '@atproto/repo'
|
4
4
|
import { AtUri } from '@atproto/syntax'
|
5
5
|
import { InvalidRequestError } from '@atproto/xrpc-server'
|
6
6
|
import { BackgroundQueue } from '../../background'
|
@@ -8,6 +8,8 @@ import { createWriteToOp, writeToOp } from '../../repo'
|
|
8
8
|
import {
|
9
9
|
BadCommitSwapError,
|
10
10
|
BadRecordSwapError,
|
11
|
+
CommitDataWithOps,
|
12
|
+
CommitOp,
|
11
13
|
PreparedCreate,
|
12
14
|
PreparedWrite,
|
13
15
|
} from '../../repo/types'
|
@@ -16,6 +18,7 @@ import { ActorDb } from '../db'
|
|
16
18
|
import { RecordTransactor } from '../record/transactor'
|
17
19
|
import { RepoReader } from './reader'
|
18
20
|
import { SqlRepoTransactor } from './sql-repo-transactor'
|
21
|
+
import { blobCidsFromWrites, commitOpsFromCreates } from './util'
|
19
22
|
|
20
23
|
export class RepoTransactor extends RepoReader {
|
21
24
|
blob: BlobTransactor
|
@@ -45,24 +48,31 @@ export class RepoTransactor extends RepoReader {
|
|
45
48
|
return res ? Repo.load(this.storage, CID.parse(res.cid)) : null
|
46
49
|
}
|
47
50
|
|
48
|
-
async createRepo(writes: PreparedCreate[]): Promise<
|
51
|
+
async createRepo(writes: PreparedCreate[]): Promise<CommitDataWithOps> {
|
49
52
|
this.db.assertTransaction()
|
50
|
-
const writeOps = writes.map(createWriteToOp)
|
51
53
|
const commit = await Repo.formatInitCommit(
|
52
54
|
this.storage,
|
53
55
|
this.did,
|
54
56
|
this.signingKey,
|
55
|
-
|
57
|
+
writes.map(createWriteToOp),
|
56
58
|
)
|
57
59
|
await Promise.all([
|
58
60
|
this.storage.applyCommit(commit, true),
|
59
61
|
this.indexWrites(writes, commit.rev),
|
60
62
|
this.blob.processWriteBlobs(commit.rev, writes),
|
61
63
|
])
|
62
|
-
return
|
64
|
+
return {
|
65
|
+
...commit,
|
66
|
+
ops: commitOpsFromCreates(writes),
|
67
|
+
blobs: blobCidsFromWrites(writes),
|
68
|
+
prevData: null,
|
69
|
+
}
|
63
70
|
}
|
64
71
|
|
65
|
-
async processWrites(
|
72
|
+
async processWrites(
|
73
|
+
writes: PreparedWrite[],
|
74
|
+
swapCommitCid?: CID,
|
75
|
+
): Promise<CommitDataWithOps> {
|
66
76
|
this.db.assertTransaction()
|
67
77
|
const commit = await this.formatCommit(writes, swapCommitCid)
|
68
78
|
await Promise.all([
|
@@ -79,7 +89,7 @@ export class RepoTransactor extends RepoReader {
|
|
79
89
|
async formatCommit(
|
80
90
|
writes: PreparedWrite[],
|
81
91
|
swapCommit?: CID,
|
82
|
-
): Promise<
|
92
|
+
): Promise<CommitDataWithOps> {
|
83
93
|
// this is not in a txn, so this won't actually hold the lock,
|
84
94
|
// we just check if it is currently held by another txn
|
85
95
|
const currRoot = await this.storage.getRootDetailed()
|
@@ -93,6 +103,7 @@ export class RepoTransactor extends RepoReader {
|
|
93
103
|
await this.storage.cacheRev(currRoot.rev)
|
94
104
|
const newRecordCids: CID[] = []
|
95
105
|
const delAndUpdateUris: AtUri[] = []
|
106
|
+
const commitOps: CommitOp[] = []
|
96
107
|
for (const write of writes) {
|
97
108
|
const { action, uri, swapCid } = write
|
98
109
|
if (action !== WriteOpAction.Delete) {
|
@@ -101,26 +112,36 @@ export class RepoTransactor extends RepoReader {
|
|
101
112
|
if (action !== WriteOpAction.Create) {
|
102
113
|
delAndUpdateUris.push(uri)
|
103
114
|
}
|
104
|
-
if (swapCid === undefined) {
|
105
|
-
continue
|
106
|
-
}
|
107
115
|
const record = await this.record.getRecord(uri, null, true)
|
108
|
-
const currRecord = record
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
116
|
+
const currRecord = record ? CID.parse(record.cid) : null
|
117
|
+
|
118
|
+
const op: CommitOp = {
|
119
|
+
action,
|
120
|
+
path: formatDataKey(uri.collection, uri.rkey),
|
121
|
+
cid: write.action === WriteOpAction.Delete ? null : write.cid,
|
114
122
|
}
|
115
|
-
if (
|
116
|
-
|
123
|
+
if (currRecord) {
|
124
|
+
op.prev = currRecord
|
117
125
|
}
|
118
|
-
|
119
|
-
|
126
|
+
commitOps.push(op)
|
127
|
+
if (swapCid !== undefined) {
|
128
|
+
if (action === WriteOpAction.Create && swapCid !== null) {
|
129
|
+
throw new BadRecordSwapError(currRecord) // There should be no current record for a create
|
130
|
+
}
|
131
|
+
if (action === WriteOpAction.Update && swapCid === null) {
|
132
|
+
throw new BadRecordSwapError(currRecord) // There should be a current record for an update
|
133
|
+
}
|
134
|
+
if (action === WriteOpAction.Delete && swapCid === null) {
|
135
|
+
throw new BadRecordSwapError(currRecord) // There should be a current record for a delete
|
136
|
+
}
|
137
|
+
if ((currRecord || swapCid) && !currRecord?.equals(swapCid)) {
|
138
|
+
throw new BadRecordSwapError(currRecord)
|
139
|
+
}
|
120
140
|
}
|
121
141
|
}
|
122
142
|
|
123
143
|
const repo = await Repo.load(this.storage, currRoot.cid)
|
144
|
+
const prevData = repo.commit.data
|
124
145
|
const writeOps = writes.map(writeToOp)
|
125
146
|
const commit = await repo.formatCommit(writeOps, this.signingKey)
|
126
147
|
|
@@ -142,7 +163,12 @@ export class RepoTransactor extends RepoReader {
|
|
142
163
|
)
|
143
164
|
commit.relevantBlocks.addMap(missingBlocks.blocks)
|
144
165
|
}
|
145
|
-
return
|
166
|
+
return {
|
167
|
+
...commit,
|
168
|
+
ops: commitOps,
|
169
|
+
blobs: blobCidsFromWrites(writes),
|
170
|
+
prevData,
|
171
|
+
}
|
146
172
|
}
|
147
173
|
|
148
174
|
async indexWrites(writes: PreparedWrite[], rev: string) {
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { CidSet, formatDataKey } from '@atproto/repo'
|
2
|
+
import { CommitOp, PreparedCreate, PreparedWrite } from '../../repo'
|
3
|
+
|
4
|
+
export const blobCidsFromWrites = (writes: PreparedWrite[]): CidSet => {
|
5
|
+
const blobCids = new CidSet()
|
6
|
+
for (const w of writes) {
|
7
|
+
if (w.action === 'create' || w.action === 'update') {
|
8
|
+
for (const blob of w.blobs) {
|
9
|
+
blobCids.add(blob.cid)
|
10
|
+
}
|
11
|
+
}
|
12
|
+
}
|
13
|
+
return blobCids
|
14
|
+
}
|
15
|
+
|
16
|
+
export const commitOpsFromCreates = (writes: PreparedCreate[]): CommitOp[] => {
|
17
|
+
return writes.map((w) => ({
|
18
|
+
action: 'create' as const,
|
19
|
+
path: formatDataKey(w.uri.collection, w.uri.rkey),
|
20
|
+
cid: w.cid,
|
21
|
+
}))
|
22
|
+
}
|
@@ -130,7 +130,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
130
130
|
}
|
131
131
|
})
|
132
132
|
|
133
|
-
await ctx.sequencer.sequenceCommit(did, commit
|
133
|
+
await ctx.sequencer.sequenceCommit(did, commit)
|
134
134
|
await ctx.accountManager.updateRepoRoot(did, commit.cid, commit.rev)
|
135
135
|
|
136
136
|
return {
|
@@ -66,40 +66,37 @@ export default function (server: Server, ctx: AppContext) {
|
|
66
66
|
throw err
|
67
67
|
}
|
68
68
|
|
69
|
-
const
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
69
|
+
const commit = await ctx.actorStore.transact(did, async (actorTxn) => {
|
70
|
+
const backlinkConflicts =
|
71
|
+
validate !== false
|
72
|
+
? await actorTxn.record.getBacklinkConflicts(
|
73
|
+
write.uri,
|
74
|
+
write.record,
|
75
|
+
)
|
76
|
+
: []
|
77
|
+
const backlinkDeletions = backlinkConflicts.map((uri) =>
|
78
|
+
prepareDelete({
|
79
|
+
did: uri.hostname,
|
80
|
+
collection: uri.collection,
|
81
|
+
rkey: uri.rkey,
|
82
|
+
}),
|
83
|
+
)
|
84
|
+
const writes = [...backlinkDeletions, write]
|
85
|
+
try {
|
86
|
+
const commit = await actorTxn.repo.processWrites(
|
87
|
+
writes,
|
88
|
+
swapCommitCid,
|
85
89
|
)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
swapCommitCid,
|
91
|
-
)
|
92
|
-
return { commit, writes }
|
93
|
-
} catch (err) {
|
94
|
-
if (err instanceof BadCommitSwapError) {
|
95
|
-
throw new InvalidRequestError(err.message, 'InvalidSwap')
|
96
|
-
}
|
97
|
-
throw err
|
90
|
+
return commit
|
91
|
+
} catch (err) {
|
92
|
+
if (err instanceof BadCommitSwapError) {
|
93
|
+
throw new InvalidRequestError(err.message, 'InvalidSwap')
|
98
94
|
}
|
99
|
-
|
100
|
-
|
95
|
+
throw err
|
96
|
+
}
|
97
|
+
})
|
101
98
|
|
102
|
-
await ctx.sequencer.sequenceCommit(did, commit
|
99
|
+
await ctx.sequencer.sequenceCommit(did, commit)
|
103
100
|
await ctx.accountManager.updateRepoRoot(did, commit.cid, commit.rev)
|
104
101
|
|
105
102
|
return {
|
@@ -71,7 +71,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
71
71
|
})
|
72
72
|
|
73
73
|
if (commit !== null) {
|
74
|
-
await ctx.sequencer.sequenceCommit(did, commit
|
74
|
+
await ctx.sequencer.sequenceCommit(did, commit)
|
75
75
|
await ctx.accountManager.updateRepoRoot(did, commit.cid, commit.rev)
|
76
76
|
}
|
77
77
|
return {
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { CID } from 'multiformats/cid'
|
2
2
|
import { BlobRef } from '@atproto/lexicon'
|
3
|
-
import { CommitData } from '@atproto/repo'
|
4
3
|
import { AtUri } from '@atproto/syntax'
|
5
4
|
import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'
|
6
5
|
import { ActorStoreTransactor } from '../../../../actor-store/actor-store-transactor'
|
@@ -11,6 +10,7 @@ import { Record as ProfileRecord } from '../../../../lexicon/types/app/bsky/acto
|
|
11
10
|
import {
|
12
11
|
BadCommitSwapError,
|
13
12
|
BadRecordSwapError,
|
13
|
+
CommitDataWithOps,
|
14
14
|
InvalidRecordError,
|
15
15
|
PreparedCreate,
|
16
16
|
PreparedUpdate,
|
@@ -104,7 +104,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
104
104
|
}
|
105
105
|
}
|
106
106
|
|
107
|
-
let commit:
|
107
|
+
let commit: CommitDataWithOps
|
108
108
|
try {
|
109
109
|
commit = await actorTxn.repo.processWrites([write], swapCommitCid)
|
110
110
|
} catch (err) {
|
@@ -122,7 +122,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
122
122
|
)
|
123
123
|
|
124
124
|
if (commit !== null) {
|
125
|
-
await ctx.sequencer.sequenceCommit(did, commit
|
125
|
+
await ctx.sequencer.sequenceCommit(did, commit)
|
126
126
|
await ctx.accountManager.updateRepoRoot(did, commit.cid, commit.rev)
|
127
127
|
}
|
128
128
|
|
@@ -43,6 +43,9 @@ export default function (server: Server, ctx: AppContext) {
|
|
43
43
|
newBlocks: blocks.blocks,
|
44
44
|
relevantBlocks: blocks.blocks,
|
45
45
|
removedCids: new CidSet(),
|
46
|
+
ops: [],
|
47
|
+
blobs: new CidSet(),
|
48
|
+
prevData: null,
|
46
49
|
}
|
47
50
|
})
|
48
51
|
|
@@ -53,7 +56,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
53
56
|
requester,
|
54
57
|
account.handle ?? INVALID_HANDLE,
|
55
58
|
)
|
56
|
-
await ctx.sequencer.sequenceCommit(requester, commitData
|
59
|
+
await ctx.sequencer.sequenceCommit(requester, commitData)
|
57
60
|
},
|
58
61
|
})
|
59
62
|
}
|
@@ -74,7 +74,7 @@ export default function (server: Server, ctx: AppContext) {
|
|
74
74
|
if (!deactivated) {
|
75
75
|
await ctx.sequencer.sequenceIdentityEvt(did, handle)
|
76
76
|
await ctx.sequencer.sequenceAccountEvt(did, AccountStatus.Active)
|
77
|
-
await ctx.sequencer.sequenceCommit(did, commit
|
77
|
+
await ctx.sequencer.sequenceCommit(did, commit)
|
78
78
|
}
|
79
79
|
await ctx.accountManager.updateRepoRoot(did, commit.cid, commit.rev)
|
80
80
|
await ctx.actorStore.clearReservedKeypair(signingKey.did(), did)
|
package/src/index.ts
CHANGED
@@ -37,7 +37,7 @@ export { createSecretKeyObject } from './auth-verifier'
|
|
37
37
|
export { type Handler as SkeletonHandler } from './lexicon/types/app/bsky/feed/getFeedSkeleton'
|
38
38
|
export { createServer as createLexiconServer } from './lexicon'
|
39
39
|
export * as sequencer from './sequencer'
|
40
|
-
export { type PreparedWrite } from './repo'
|
40
|
+
export { type CommitDataWithOps, type PreparedWrite } from './repo'
|
41
41
|
export * as repoPrepare from './repo/prepare'
|
42
42
|
export { scripts } from './scripts'
|
43
43
|
|
package/src/lexicon/index.ts
CHANGED
@@ -163,6 +163,7 @@ import * as ChatBskyConvoMuteConvo from './types/chat/bsky/convo/muteConvo.js'
|
|
163
163
|
import * as ChatBskyConvoSendMessage from './types/chat/bsky/convo/sendMessage.js'
|
164
164
|
import * as ChatBskyConvoSendMessageBatch from './types/chat/bsky/convo/sendMessageBatch.js'
|
165
165
|
import * as ChatBskyConvoUnmuteConvo from './types/chat/bsky/convo/unmuteConvo.js'
|
166
|
+
import * as ChatBskyConvoUpdateAllRead from './types/chat/bsky/convo/updateAllRead.js'
|
166
167
|
import * as ChatBskyConvoUpdateRead from './types/chat/bsky/convo/updateRead.js'
|
167
168
|
import * as ChatBskyModerationGetActorMetadata from './types/chat/bsky/moderation/getActorMetadata.js'
|
168
169
|
import * as ChatBskyModerationGetMessageContext from './types/chat/bsky/moderation/getMessageContext.js'
|
@@ -2214,6 +2215,17 @@ export class ChatBskyConvoNS {
|
|
2214
2215
|
return this._server.xrpc.method(nsid, cfg)
|
2215
2216
|
}
|
2216
2217
|
|
2218
|
+
updateAllRead<AV extends AuthVerifier>(
|
2219
|
+
cfg: ConfigOf<
|
2220
|
+
AV,
|
2221
|
+
ChatBskyConvoUpdateAllRead.Handler<ExtractAuth<AV>>,
|
2222
|
+
ChatBskyConvoUpdateAllRead.HandlerReqCtx<ExtractAuth<AV>>
|
2223
|
+
>,
|
2224
|
+
) {
|
2225
|
+
const nsid = 'chat.bsky.convo.updateAllRead' // @ts-ignore
|
2226
|
+
return this._server.xrpc.method(nsid, cfg)
|
2227
|
+
}
|
2228
|
+
|
2217
2229
|
updateRead<AV extends AuthVerifier>(
|
2218
2230
|
cfg: ConfigOf<
|
2219
2231
|
AV,
|