@atproto/ozone 0.1.132 → 0.1.134
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 +17 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/moderation/getAccountTimeline.d.ts +4 -0
- package/dist/api/moderation/getAccountTimeline.d.ts.map +1 -0
- package/dist/api/moderation/getAccountTimeline.js +139 -0
- package/dist/api/moderation/getAccountTimeline.js.map +1 -0
- package/dist/api/util.d.ts +1 -1
- package/dist/lexicon/index.d.ts +9 -4
- package/dist/lexicon/index.d.ts.map +1 -1
- package/dist/lexicon/index.js +15 -8
- package/dist/lexicon/index.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +427 -259
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +250 -134
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/{app/bsky/unspecced → com/atproto/temp}/checkHandleAvailability.d.ts +6 -6
- package/dist/lexicon/types/com/atproto/temp/checkHandleAvailability.d.ts.map +1 -0
- package/dist/lexicon/types/{app/bsky/unspecced → com/atproto/temp}/checkHandleAvailability.js +1 -1
- package/dist/lexicon/types/com/atproto/temp/checkHandleAvailability.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts +6 -0
- package/dist/lexicon/types/tools/ozone/moderation/defs.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/defs.js +7 -1
- package/dist/lexicon/types/tools/ozone/moderation/defs.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/moderation/getAccountTimeline.d.ts +41 -0
- package/dist/lexicon/types/tools/ozone/moderation/getAccountTimeline.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/moderation/getAccountTimeline.js +25 -0
- package/dist/lexicon/types/tools/ozone/moderation/getAccountTimeline.js.map +1 -0
- package/dist/mod-service/index.d.ts +7 -1
- package/dist/mod-service/index.d.ts.map +1 -1
- package/dist/mod-service/index.js +20 -0
- package/dist/mod-service/index.js.map +1 -1
- package/dist/mod-service/util.d.ts +3 -0
- package/dist/mod-service/util.d.ts.map +1 -1
- package/dist/mod-service/util.js +11 -1
- package/dist/mod-service/util.js.map +1 -1
- package/package.json +5 -5
- package/src/api/index.ts +2 -0
- package/src/api/moderation/getAccountTimeline.ts +160 -0
- package/src/lexicon/index.ts +43 -24
- package/src/lexicon/lexicons.ts +264 -143
- package/src/lexicon/types/{app/bsky/unspecced → com/atproto/temp}/checkHandleAvailability.ts +4 -4
- package/src/lexicon/types/tools/ozone/moderation/defs.ts +7 -0
- package/src/lexicon/types/tools/ozone/moderation/getAccountTimeline.ts +102 -0
- package/src/mod-service/index.ts +24 -0
- package/src/mod-service/util.ts +11 -0
- package/tests/__snapshots__/get-account-timeline.test.ts.snap +36 -0
- package/tests/get-account-timeline.test.ts +85 -0
- package/tests/repo-search.test.ts +5 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.tests.tsbuildinfo +1 -1
- package/dist/lexicon/types/app/bsky/unspecced/checkHandleAvailability.d.ts.map +0 -1
- package/dist/lexicon/types/app/bsky/unspecced/checkHandleAvailability.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/mod-service/util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/mod-service/util.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,yCAAyC,CAAA;AAE/D,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG;IAAE,GAAG,EAAE,UAAU,CAAA;CAAE,CAAA;AAErD,eAAO,MAAM,WAAW,GAAI,KAAK,QAAQ,KAAG,KAY3C,CAAA;AAED,eAAO,MAAM,cAAc,GACzB,OAAO,KAAK,EACZ,eAAe,MAAM,KACpB,IAAI,CAAC,QAAQ,EAAE,IAAI,CAYrB,CAAA;AAED,eAAO,MAAM,SAAS,GACpB,OAAO,KAAK,EACZ,YAAY,OAAO,KAClB,OAAO,CAAC,WAAW,CAmBrB,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,KAAK,GAAG,YAKjC,CAAA;AAED,eAAO,MAAM,kBAAkB,GAC7B,YAAY,UAAU,EACtB,KAAK,MAAM,EACX,UAAU,OAAO;;;;;;EASlB,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,UAAU,IAAI,WAG9C,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,SAAS,KAAK,wCAEhD,CAAA"}
|
package/dist/mod-service/util.js
CHANGED
|
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPdsAgentForRepo = exports.isSafeUrl = exports.signLabel = exports.formatLabelRow = exports.formatLabel = void 0;
|
|
6
|
+
exports.dateFromDbDatetime = exports.dateFromDatetime = exports.getPdsAgentForRepo = exports.isSafeUrl = exports.signLabel = exports.formatLabelRow = exports.formatLabel = void 0;
|
|
7
7
|
const node_net_1 = __importDefault(require("node:net"));
|
|
8
|
+
const kysely_1 = require("kysely");
|
|
8
9
|
const api_1 = __importDefault(require("@atproto/api"));
|
|
9
10
|
const common_1 = require("@atproto/common");
|
|
10
11
|
const formatLabel = (row) => {
|
|
@@ -74,4 +75,13 @@ const getPdsAgentForRepo = async (idResolver, did, devMode) => {
|
|
|
74
75
|
return { url, agent: new api_1.default({ service: url }) };
|
|
75
76
|
};
|
|
76
77
|
exports.getPdsAgentForRepo = getPdsAgentForRepo;
|
|
78
|
+
const dateFromDatetime = (datetime) => {
|
|
79
|
+
const [date] = datetime.toISOString().split('T');
|
|
80
|
+
return date;
|
|
81
|
+
};
|
|
82
|
+
exports.dateFromDatetime = dateFromDatetime;
|
|
83
|
+
const dateFromDbDatetime = (dateRef) => {
|
|
84
|
+
return (0, kysely_1.sql) `SPLIT_PART(${dateRef}, 'T', 1)`;
|
|
85
|
+
};
|
|
86
|
+
exports.dateFromDbDatetime = dateFromDbDatetime;
|
|
77
87
|
//# sourceMappingURL=util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/mod-service/util.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0B;AAC1B,uDAAmC;AACnC,4CAA6D;
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/mod-service/util.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA0B;AAC1B,mCAA4B;AAC5B,uDAAmC;AACnC,4CAA6D;AAStD,MAAM,WAAW,GAAG,CAAC,GAAa,EAAS,EAAE;IAClD,OAAO,IAAA,wBAAe,EAAC;QACrB,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG;QACzC,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QACxC,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,SA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,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAChD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAHY,QAAA,gBAAgB,oBAG5B;AAEM,MAAM,kBAAkB,GAAG,CAAC,OAAc,EAAE,EAAE;IACnD,OAAO,IAAA,YAAG,EAAQ,cAAc,OAAO,WAAW,CAAA;AACpD,CAAC,CAAA;AAFY,QAAA,kBAAkB,sBAE9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/ozone",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.134",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Backend service for moderating the Bluesky network.",
|
|
6
6
|
"keywords": [
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"uint8arrays": "3.0.0",
|
|
36
36
|
"undici": "^6.14.1",
|
|
37
37
|
"ws": "^8.12.0",
|
|
38
|
-
"@atproto/api": "^0.15.27",
|
|
39
38
|
"@atproto/common": "^0.4.11",
|
|
39
|
+
"@atproto/api": "^0.16.1",
|
|
40
40
|
"@atproto/crypto": "^0.4.4",
|
|
41
41
|
"@atproto/identity": "^0.4.8",
|
|
42
42
|
"@atproto/lexicon": "^0.4.12",
|
|
43
43
|
"@atproto/syntax": "^0.4.0",
|
|
44
44
|
"@atproto/xrpc": "^0.7.1",
|
|
45
|
-
"@atproto/xrpc-server": "^0.9.
|
|
45
|
+
"@atproto/xrpc-server": "^0.9.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@did-plc/server": "^0.0.1",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"jest": "^28.1.2",
|
|
55
55
|
"ts-node": "^10.8.2",
|
|
56
56
|
"typescript": "^5.6.3",
|
|
57
|
-
"@atproto/lex-cli": "^0.9.
|
|
58
|
-
"@atproto/pds": "^0.4.
|
|
57
|
+
"@atproto/lex-cli": "^0.9.1",
|
|
58
|
+
"@atproto/pds": "^0.4.164"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"codegen": "lex gen-server --yes ./src/lexicon ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/* ../../lexicons/chat/bsky/*/* ../../lexicons/tools/ozone/*/*",
|
package/src/api/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import fetchLabels from './label/fetchLabels'
|
|
|
9
9
|
import queryLabels from './label/queryLabels'
|
|
10
10
|
import subscribeLabels from './label/subscribeLabels'
|
|
11
11
|
import emitEvent from './moderation/emitEvent'
|
|
12
|
+
import getAccountTimeline from './moderation/getAccountTimeline'
|
|
12
13
|
import getEvent from './moderation/getEvent'
|
|
13
14
|
import adminGetRecord from './moderation/getRecord'
|
|
14
15
|
import adminGetRecords from './moderation/getRecords'
|
|
@@ -92,5 +93,6 @@ export default function (server: Server, ctx: AppContext) {
|
|
|
92
93
|
removeSafelinkRule(server, ctx)
|
|
93
94
|
querySafelinkEvents(server, ctx)
|
|
94
95
|
querySafelinkRules(server, ctx)
|
|
96
|
+
getAccountTimeline(server, ctx)
|
|
95
97
|
return server
|
|
96
98
|
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { ToolsOzoneModerationGetAccountTimeline } from '@atproto/api'
|
|
2
|
+
import { AppContext } from '../../context'
|
|
3
|
+
import { Server } from '../../lexicon'
|
|
4
|
+
import { ids } from '../../lexicon/lexicons'
|
|
5
|
+
import { dateFromDatetime } from '../../mod-service/util'
|
|
6
|
+
|
|
7
|
+
export default function (server: Server, ctx: AppContext) {
|
|
8
|
+
server.tools.ozone.moderation.getAccountTimeline({
|
|
9
|
+
auth: ctx.authVerifier.modOrAdminToken,
|
|
10
|
+
handler: async ({ params }) => {
|
|
11
|
+
const { did } = params
|
|
12
|
+
const db = ctx.db
|
|
13
|
+
const modService = ctx.modService(db)
|
|
14
|
+
const [modEventHistory, accountHistory, plcHistory] =
|
|
15
|
+
await Promise.allSettled([
|
|
16
|
+
modService.getAccountTimeline(did),
|
|
17
|
+
getAccountHistory(ctx, did),
|
|
18
|
+
getPlcHistory(ctx, did),
|
|
19
|
+
])
|
|
20
|
+
const timelineByDay = new Map<
|
|
21
|
+
string,
|
|
22
|
+
ToolsOzoneModerationGetAccountTimeline.TimelineItemSummary[]
|
|
23
|
+
>()
|
|
24
|
+
|
|
25
|
+
if (modEventHistory.status === 'fulfilled') {
|
|
26
|
+
for (const row of modEventHistory.value) {
|
|
27
|
+
const day = timelineByDay.get(row.day)
|
|
28
|
+
const summary = {
|
|
29
|
+
eventSubjectType: row.subjectUri ? 'record' : 'account',
|
|
30
|
+
eventType: row.action,
|
|
31
|
+
count: row.count,
|
|
32
|
+
}
|
|
33
|
+
if (day) {
|
|
34
|
+
day.push(summary)
|
|
35
|
+
timelineByDay.set(row.day, day)
|
|
36
|
+
} else {
|
|
37
|
+
timelineByDay.set(row.day, [summary])
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
throw modEventHistory.reason
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (accountHistory.status === 'fulfilled') {
|
|
45
|
+
for (const [rowDay, row] of Object.entries(accountHistory.value)) {
|
|
46
|
+
const day = timelineByDay.get(rowDay)
|
|
47
|
+
const summaries: ToolsOzoneModerationGetAccountTimeline.TimelineItemSummary[] =
|
|
48
|
+
[]
|
|
49
|
+
for (const [eventType, count] of Object.entries(row)) {
|
|
50
|
+
summaries.push({
|
|
51
|
+
eventSubjectType: 'account',
|
|
52
|
+
eventType,
|
|
53
|
+
count,
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
if (day) {
|
|
57
|
+
day.push(...summaries)
|
|
58
|
+
timelineByDay.set(rowDay, day)
|
|
59
|
+
} else {
|
|
60
|
+
timelineByDay.set(rowDay, summaries)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (plcHistory.status === 'fulfilled') {
|
|
66
|
+
for (const [rowDay, row] of Object.entries(plcHistory.value)) {
|
|
67
|
+
const day = timelineByDay.get(rowDay)
|
|
68
|
+
const summaries: ToolsOzoneModerationGetAccountTimeline.TimelineItemSummary[] =
|
|
69
|
+
[]
|
|
70
|
+
for (const [eventType, count] of Object.entries(row)) {
|
|
71
|
+
summaries.push({
|
|
72
|
+
eventSubjectType: 'account',
|
|
73
|
+
eventType,
|
|
74
|
+
count,
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
if (day) {
|
|
78
|
+
day.push(...summaries)
|
|
79
|
+
timelineByDay.set(rowDay, day)
|
|
80
|
+
} else {
|
|
81
|
+
timelineByDay.set(rowDay, summaries)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const timeline: ToolsOzoneModerationGetAccountTimeline.TimelineItem[] = []
|
|
87
|
+
|
|
88
|
+
for (const [day, summary] of timelineByDay.entries()) {
|
|
89
|
+
timeline.push({ day, summary: summary.flat() })
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
encoding: 'application/json',
|
|
94
|
+
body: { timeline },
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const getAccountHistory = async (ctx: AppContext, did: string) => {
|
|
101
|
+
const events: Record<string, Record<string, number>> = {}
|
|
102
|
+
|
|
103
|
+
if (!ctx.pdsAgent) {
|
|
104
|
+
return events
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const auth = await ctx.pdsAuth(ids.ToolsOzoneHostingGetAccountHistory)
|
|
108
|
+
let cursor: string | undefined = undefined
|
|
109
|
+
|
|
110
|
+
do {
|
|
111
|
+
const { data } = await ctx.pdsAgent.tools.ozone.hosting.getAccountHistory(
|
|
112
|
+
{ did, cursor },
|
|
113
|
+
auth,
|
|
114
|
+
)
|
|
115
|
+
cursor = data.cursor
|
|
116
|
+
for (const event of data.events) {
|
|
117
|
+
// This should never happen and the check is here only because typescript screams at us otherwise
|
|
118
|
+
if (!event.$type) {
|
|
119
|
+
continue
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const day = dateFromDatetime(new Date(event.createdAt))
|
|
123
|
+
events[day] ??= {}
|
|
124
|
+
events[day][event.$type] ??= 0
|
|
125
|
+
events[day][event.$type]++
|
|
126
|
+
}
|
|
127
|
+
} while (cursor)
|
|
128
|
+
|
|
129
|
+
return events
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const PLC_OPERATION_MAP = {
|
|
133
|
+
create: 'tools.ozone.moderation.defs#timelineEventPlcCreate',
|
|
134
|
+
plc_operation: 'tools.ozone.moderation.defs#timelineEventPlcOperation',
|
|
135
|
+
plc_tombstone: 'tools.ozone.moderation.defs#timelineEventPlcTombstone',
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const getPlcHistory = async (ctx: AppContext, did: string) => {
|
|
139
|
+
const events: Record<string, Record<string, number>> = {}
|
|
140
|
+
|
|
141
|
+
if (!ctx.plcClient) {
|
|
142
|
+
return events
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const result = await ctx.plcClient.getAuditableLog(did)
|
|
146
|
+
for (const event of result) {
|
|
147
|
+
// Skip events that are not mapped, this means we will have to add correct mapping if/when new event types are introduced here
|
|
148
|
+
if (!Object.hasOwn(PLC_OPERATION_MAP, event.operation.type)) {
|
|
149
|
+
continue
|
|
150
|
+
}
|
|
151
|
+
const day = dateFromDatetime(new Date(event.createdAt))
|
|
152
|
+
events[day] ??= {}
|
|
153
|
+
const eventType =
|
|
154
|
+
PLC_OPERATION_MAP[event.operation.type] || event.operation.type
|
|
155
|
+
events[day][eventType] ??= 0
|
|
156
|
+
events[day][eventType]++
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return events
|
|
160
|
+
}
|
package/src/lexicon/index.ts
CHANGED
|
@@ -89,6 +89,7 @@ import * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOf
|
|
|
89
89
|
import * as ComAtprotoSyncRequestCrawl from './types/com/atproto/sync/requestCrawl.js'
|
|
90
90
|
import * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscribeRepos.js'
|
|
91
91
|
import * as ComAtprotoTempAddReservedHandle from './types/com/atproto/temp/addReservedHandle.js'
|
|
92
|
+
import * as ComAtprotoTempCheckHandleAvailability from './types/com/atproto/temp/checkHandleAvailability.js'
|
|
92
93
|
import * as ComAtprotoTempCheckSignupQueue from './types/com/atproto/temp/checkSignupQueue.js'
|
|
93
94
|
import * as ComAtprotoTempFetchLabels from './types/com/atproto/temp/fetchLabels.js'
|
|
94
95
|
import * as ComAtprotoTempRequestPhoneVerification from './types/com/atproto/temp/requestPhoneVerification.js'
|
|
@@ -109,8 +110,8 @@ import * as AppBskyFeedGetFeedGenerators from './types/app/bsky/feed/getFeedGene
|
|
|
109
110
|
import * as AppBskyFeedGetFeedSkeleton from './types/app/bsky/feed/getFeedSkeleton.js'
|
|
110
111
|
import * as AppBskyFeedGetLikes from './types/app/bsky/feed/getLikes.js'
|
|
111
112
|
import * as AppBskyFeedGetListFeed from './types/app/bsky/feed/getListFeed.js'
|
|
112
|
-
import * as AppBskyFeedGetPosts from './types/app/bsky/feed/getPosts.js'
|
|
113
113
|
import * as AppBskyFeedGetPostThread from './types/app/bsky/feed/getPostThread.js'
|
|
114
|
+
import * as AppBskyFeedGetPosts from './types/app/bsky/feed/getPosts.js'
|
|
114
115
|
import * as AppBskyFeedGetQuotes from './types/app/bsky/feed/getQuotes.js'
|
|
115
116
|
import * as AppBskyFeedGetRepostedBy from './types/app/bsky/feed/getRepostedBy.js'
|
|
116
117
|
import * as AppBskyFeedGetSuggestedFeeds from './types/app/bsky/feed/getSuggestedFeeds.js'
|
|
@@ -149,7 +150,6 @@ import * as AppBskyNotificationPutPreferencesV2 from './types/app/bsky/notificat
|
|
|
149
150
|
import * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/registerPush.js'
|
|
150
151
|
import * as AppBskyNotificationUnregisterPush from './types/app/bsky/notification/unregisterPush.js'
|
|
151
152
|
import * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen.js'
|
|
152
|
-
import * as AppBskyUnspeccedCheckHandleAvailability from './types/app/bsky/unspecced/checkHandleAvailability.js'
|
|
153
153
|
import * as AppBskyUnspeccedGetAgeAssuranceState from './types/app/bsky/unspecced/getAgeAssuranceState.js'
|
|
154
154
|
import * as AppBskyUnspeccedGetConfig from './types/app/bsky/unspecced/getConfig.js'
|
|
155
155
|
import * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators.js'
|
|
@@ -201,6 +201,7 @@ import * as ToolsOzoneCommunicationListTemplates from './types/tools/ozone/commu
|
|
|
201
201
|
import * as ToolsOzoneCommunicationUpdateTemplate from './types/tools/ozone/communication/updateTemplate.js'
|
|
202
202
|
import * as ToolsOzoneHostingGetAccountHistory from './types/tools/ozone/hosting/getAccountHistory.js'
|
|
203
203
|
import * as ToolsOzoneModerationEmitEvent from './types/tools/ozone/moderation/emitEvent.js'
|
|
204
|
+
import * as ToolsOzoneModerationGetAccountTimeline from './types/tools/ozone/moderation/getAccountTimeline.js'
|
|
204
205
|
import * as ToolsOzoneModerationGetEvent from './types/tools/ozone/moderation/getEvent.js'
|
|
205
206
|
import * as ToolsOzoneModerationGetRecord from './types/tools/ozone/moderation/getRecord.js'
|
|
206
207
|
import * as ToolsOzoneModerationGetRecords from './types/tools/ozone/moderation/getRecords.js'
|
|
@@ -275,6 +276,12 @@ export const TOOLS_OZONE_MODERATION = {
|
|
|
275
276
|
DefsReviewEscalated: 'tools.ozone.moderation.defs#reviewEscalated',
|
|
276
277
|
DefsReviewClosed: 'tools.ozone.moderation.defs#reviewClosed',
|
|
277
278
|
DefsReviewNone: 'tools.ozone.moderation.defs#reviewNone',
|
|
279
|
+
DefsTimelineEventPlcCreate:
|
|
280
|
+
'tools.ozone.moderation.defs#timelineEventPlcCreate',
|
|
281
|
+
DefsTimelineEventPlcOperation:
|
|
282
|
+
'tools.ozone.moderation.defs#timelineEventPlcOperation',
|
|
283
|
+
DefsTimelineEventPlcTombstone:
|
|
284
|
+
'tools.ozone.moderation.defs#timelineEventPlcTombstone',
|
|
278
285
|
}
|
|
279
286
|
export const TOOLS_OZONE_TEAM = {
|
|
280
287
|
DefsRoleAdmin: 'tools.ozone.team.defs#roleAdmin',
|
|
@@ -1356,6 +1363,18 @@ export class ComAtprotoTempNS {
|
|
|
1356
1363
|
return this._server.xrpc.method(nsid, cfg)
|
|
1357
1364
|
}
|
|
1358
1365
|
|
|
1366
|
+
checkHandleAvailability<A extends Auth = void>(
|
|
1367
|
+
cfg: MethodConfigOrHandler<
|
|
1368
|
+
A,
|
|
1369
|
+
ComAtprotoTempCheckHandleAvailability.QueryParams,
|
|
1370
|
+
ComAtprotoTempCheckHandleAvailability.HandlerInput,
|
|
1371
|
+
ComAtprotoTempCheckHandleAvailability.HandlerOutput
|
|
1372
|
+
>,
|
|
1373
|
+
) {
|
|
1374
|
+
const nsid = 'com.atproto.temp.checkHandleAvailability' // @ts-ignore
|
|
1375
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1359
1378
|
checkSignupQueue<A extends Auth = void>(
|
|
1360
1379
|
cfg: MethodConfigOrHandler<
|
|
1361
1380
|
A,
|
|
@@ -1656,27 +1675,27 @@ export class AppBskyFeedNS {
|
|
|
1656
1675
|
return this._server.xrpc.method(nsid, cfg)
|
|
1657
1676
|
}
|
|
1658
1677
|
|
|
1659
|
-
|
|
1678
|
+
getPostThread<A extends Auth = void>(
|
|
1660
1679
|
cfg: MethodConfigOrHandler<
|
|
1661
1680
|
A,
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1681
|
+
AppBskyFeedGetPostThread.QueryParams,
|
|
1682
|
+
AppBskyFeedGetPostThread.HandlerInput,
|
|
1683
|
+
AppBskyFeedGetPostThread.HandlerOutput
|
|
1665
1684
|
>,
|
|
1666
1685
|
) {
|
|
1667
|
-
const nsid = 'app.bsky.feed.
|
|
1686
|
+
const nsid = 'app.bsky.feed.getPostThread' // @ts-ignore
|
|
1668
1687
|
return this._server.xrpc.method(nsid, cfg)
|
|
1669
1688
|
}
|
|
1670
1689
|
|
|
1671
|
-
|
|
1690
|
+
getPosts<A extends Auth = void>(
|
|
1672
1691
|
cfg: MethodConfigOrHandler<
|
|
1673
1692
|
A,
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1693
|
+
AppBskyFeedGetPosts.QueryParams,
|
|
1694
|
+
AppBskyFeedGetPosts.HandlerInput,
|
|
1695
|
+
AppBskyFeedGetPosts.HandlerOutput
|
|
1677
1696
|
>,
|
|
1678
1697
|
) {
|
|
1679
|
-
const nsid = 'app.bsky.feed.
|
|
1698
|
+
const nsid = 'app.bsky.feed.getPosts' // @ts-ignore
|
|
1680
1699
|
return this._server.xrpc.method(nsid, cfg)
|
|
1681
1700
|
}
|
|
1682
1701
|
|
|
@@ -2176,18 +2195,6 @@ export class AppBskyUnspeccedNS {
|
|
|
2176
2195
|
this._server = server
|
|
2177
2196
|
}
|
|
2178
2197
|
|
|
2179
|
-
checkHandleAvailability<A extends Auth = void>(
|
|
2180
|
-
cfg: MethodConfigOrHandler<
|
|
2181
|
-
A,
|
|
2182
|
-
AppBskyUnspeccedCheckHandleAvailability.QueryParams,
|
|
2183
|
-
AppBskyUnspeccedCheckHandleAvailability.HandlerInput,
|
|
2184
|
-
AppBskyUnspeccedCheckHandleAvailability.HandlerOutput
|
|
2185
|
-
>,
|
|
2186
|
-
) {
|
|
2187
|
-
const nsid = 'app.bsky.unspecced.checkHandleAvailability' // @ts-ignore
|
|
2188
|
-
return this._server.xrpc.method(nsid, cfg)
|
|
2189
|
-
}
|
|
2190
|
-
|
|
2191
2198
|
getAgeAssuranceState<A extends Auth = void>(
|
|
2192
2199
|
cfg: MethodConfigOrHandler<
|
|
2193
2200
|
A,
|
|
@@ -2918,6 +2925,18 @@ export class ToolsOzoneModerationNS {
|
|
|
2918
2925
|
return this._server.xrpc.method(nsid, cfg)
|
|
2919
2926
|
}
|
|
2920
2927
|
|
|
2928
|
+
getAccountTimeline<A extends Auth = void>(
|
|
2929
|
+
cfg: MethodConfigOrHandler<
|
|
2930
|
+
A,
|
|
2931
|
+
ToolsOzoneModerationGetAccountTimeline.QueryParams,
|
|
2932
|
+
ToolsOzoneModerationGetAccountTimeline.HandlerInput,
|
|
2933
|
+
ToolsOzoneModerationGetAccountTimeline.HandlerOutput
|
|
2934
|
+
>,
|
|
2935
|
+
) {
|
|
2936
|
+
const nsid = 'tools.ozone.moderation.getAccountTimeline' // @ts-ignore
|
|
2937
|
+
return this._server.xrpc.method(nsid, cfg)
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2921
2940
|
getEvent<A extends Auth = void>(
|
|
2922
2941
|
cfg: MethodConfigOrHandler<
|
|
2923
2942
|
A,
|