@atproto/ozone 0.2.4 → 0.2.6
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 +24 -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/label/queryLabels.d.ts.map +1 -1
- package/dist/api/label/queryLabels.js +13 -21
- package/dist/api/label/queryLabels.js.map +1 -1
- package/dist/api/report/queryActivities.d.ts +4 -0
- package/dist/api/report/queryActivities.d.ts.map +1 -0
- package/dist/api/report/queryActivities.js +36 -0
- package/dist/api/report/queryActivities.js.map +1 -0
- package/dist/assignment/index.d.ts.map +1 -1
- package/dist/assignment/index.js +9 -12
- package/dist/assignment/index.js.map +1 -1
- package/dist/background.d.ts +5 -3
- package/dist/background.d.ts.map +1 -1
- package/dist/background.js +13 -4
- package/dist/background.js.map +1 -1
- package/dist/context.js +1 -1
- package/dist/context.js.map +1 -1
- package/dist/daemon/context.js +1 -1
- package/dist/daemon/context.js.map +1 -1
- package/dist/daemon/event-pusher.d.ts +7 -1
- package/dist/daemon/event-pusher.d.ts.map +1 -1
- package/dist/daemon/verification-listener.d.ts +1 -1
- package/dist/daemon/verification-listener.d.ts.map +1 -1
- package/dist/daemon/verification-listener.js +10 -4
- package/dist/daemon/verification-listener.js.map +1 -1
- package/dist/db/index.d.ts +4 -5
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +2 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations/20241220T144630860Z-stats-materialized-views.d.ts +1 -2
- package/dist/db/migrations/20241220T144630860Z-stats-materialized-views.d.ts.map +1 -1
- package/dist/db/migrations/20241220T144630860Z-stats-materialized-views.js.map +1 -1
- package/dist/db/migrations/20250718T150931000Z-update-appeal-reason-stats.d.ts +1 -2
- package/dist/db/migrations/20250718T150931000Z-update-appeal-reason-stats.d.ts.map +1 -1
- package/dist/db/migrations/20250718T150931000Z-update-appeal-reason-stats.js.map +1 -1
- package/dist/db/migrations/20260602T120000000Z-add-report-activity-created-index.d.ts +4 -0
- package/dist/db/migrations/20260602T120000000Z-add-report-activity-created-index.d.ts.map +1 -0
- package/dist/db/migrations/20260602T120000000Z-add-report-activity-created-index.js +15 -0
- package/dist/db/migrations/20260602T120000000Z-add-report-activity-created-index.js.map +1 -0
- package/dist/db/migrations/index.d.ts +1 -0
- package/dist/db/migrations/index.d.ts.map +1 -1
- package/dist/db/migrations/index.js +1 -0
- package/dist/db/migrations/index.js.map +1 -1
- package/dist/db/migrations/provider.d.ts +2 -1
- package/dist/db/migrations/provider.d.ts.map +1 -1
- package/dist/db/migrations/provider.js.map +1 -1
- package/dist/db/pagination.d.ts +4 -3
- package/dist/db/pagination.d.ts.map +1 -1
- package/dist/db/pagination.js +4 -4
- package/dist/db/pagination.js.map +1 -1
- package/dist/db/types.d.ts +1 -1
- package/dist/db/types.d.ts.map +1 -1
- package/dist/db/types.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -13
- package/dist/index.js.map +1 -1
- package/dist/jetstream/service.d.ts +1 -1
- package/dist/jetstream/service.d.ts.map +1 -1
- package/dist/jetstream/service.js +3 -1
- package/dist/jetstream/service.js.map +1 -1
- package/dist/lexicon/index.d.ts +11 -0
- package/dist/lexicon/index.d.ts.map +1 -1
- package/dist/lexicon/index.js +18 -0
- package/dist/lexicon/index.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +338 -0
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +173 -0
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/app/bsky/notification/defs.d.ts +1 -0
- package/dist/lexicon/types/app/bsky/notification/defs.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/notification/defs.js.map +1 -1
- package/dist/lexicon/types/chat/bsky/notification/defs.d.ts +19 -0
- package/dist/lexicon/types/chat/bsky/notification/defs.d.ts.map +1 -0
- package/dist/lexicon/types/chat/bsky/notification/defs.js +19 -0
- package/dist/lexicon/types/chat/bsky/notification/defs.js.map +1 -0
- package/dist/lexicon/types/chat/bsky/notification/getPreferences.d.ts +20 -0
- package/dist/lexicon/types/chat/bsky/notification/getPreferences.d.ts.map +1 -0
- package/dist/lexicon/types/chat/bsky/notification/getPreferences.js +5 -0
- package/dist/lexicon/types/chat/bsky/notification/getPreferences.js.map +1 -0
- package/dist/lexicon/types/chat/bsky/notification/putPreferences.d.ts +26 -0
- package/dist/lexicon/types/chat/bsky/notification/putPreferences.d.ts.map +1 -0
- package/dist/lexicon/types/chat/bsky/notification/putPreferences.js +5 -0
- package/dist/lexicon/types/chat/bsky/notification/putPreferences.js.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/defs.d.ts +1 -0
- package/dist/lexicon/types/tools/ozone/report/defs.d.ts.map +1 -1
- package/dist/lexicon/types/tools/ozone/report/defs.js.map +1 -1
- package/dist/lexicon/types/tools/ozone/report/queryActivities.d.ts +32 -0
- package/dist/lexicon/types/tools/ozone/report/queryActivities.d.ts.map +1 -0
- package/dist/lexicon/types/tools/ozone/report/queryActivities.js +5 -0
- package/dist/lexicon/types/tools/ozone/report/queryActivities.js.map +1 -0
- package/dist/mod-service/index.d.ts.map +1 -1
- package/dist/mod-service/index.js +28 -52
- package/dist/mod-service/index.js.map +1 -1
- package/dist/mod-service/report.d.ts +1 -0
- package/dist/mod-service/report.d.ts.map +1 -1
- package/dist/mod-service/report.js +16 -0
- package/dist/mod-service/report.js.map +1 -1
- package/dist/mod-service/status.d.ts +23 -128
- package/dist/mod-service/status.d.ts.map +1 -1
- package/dist/mod-service/views.js +7 -11
- package/dist/mod-service/views.js.map +1 -1
- package/dist/queue/service.js +1 -3
- package/dist/queue/service.js.map +1 -1
- package/dist/report/activity.d.ts +31 -2
- package/dist/report/activity.d.ts.map +1 -1
- package/dist/report/activity.js +27 -1
- package/dist/report/activity.js.map +1 -1
- package/dist/report/stats.d.ts.map +1 -1
- package/dist/report/stats.js.map +1 -1
- package/dist/scheduled-action/service.d.ts.map +1 -1
- package/dist/scheduled-action/service.js +16 -20
- package/dist/scheduled-action/service.js.map +1 -1
- package/dist/set/service.d.ts +10 -1
- package/dist/set/service.d.ts.map +1 -1
- package/dist/set/service.js +5 -2
- package/dist/set/service.js.map +1 -1
- package/dist/team/index.d.ts.map +1 -1
- package/dist/team/index.js +5 -4
- package/dist/team/index.js.map +1 -1
- package/dist/verification/issuer.d.ts +13 -3
- package/dist/verification/issuer.d.ts.map +1 -1
- package/dist/verification/service.d.ts +13 -1
- package/dist/verification/service.d.ts.map +1 -1
- package/dist/verification/service.js +1 -1
- package/dist/verification/service.js.map +1 -1
- package/package.json +12 -11
- package/src/api/index.ts +2 -0
- package/src/api/label/queryLabels.ts +11 -14
- package/src/api/report/queryActivities.ts +64 -0
- package/src/assignment/index.ts +15 -18
- package/src/background.ts +19 -4
- package/src/context.ts +1 -1
- package/src/daemon/context.ts +1 -1
- package/src/daemon/verification-listener.ts +9 -4
- package/src/db/index.ts +1 -1
- package/src/db/migrations/20241220T144630860Z-stats-materialized-views.ts +1 -2
- package/src/db/migrations/20250718T150931000Z-update-appeal-reason-stats.ts +1 -2
- package/src/db/migrations/20260602T120000000Z-add-report-activity-created-index.ts +17 -0
- package/src/db/migrations/index.ts +1 -0
- package/src/db/migrations/provider.ts +2 -1
- package/src/db/pagination.ts +18 -18
- package/src/db/types.ts +3 -1
- package/src/index.ts +25 -15
- package/src/jetstream/service.ts +3 -1
- package/src/mod-service/index.ts +78 -71
- package/src/mod-service/report.ts +24 -3
- package/src/mod-service/views.ts +16 -16
- package/src/queue/service.ts +5 -5
- package/src/report/activity.ts +47 -0
- package/src/report/stats.ts +5 -3
- package/src/scheduled-action/service.ts +22 -20
- package/src/set/service.ts +17 -14
- package/src/team/index.ts +6 -5
- package/src/verification/service.ts +2 -2
- package/tests/3p-labeler.test.ts +2 -2
- package/tests/_util.ts +8 -25
- package/tests/account-strikes.test.ts +1 -1
- package/tests/ack-all-subjects-of-account.test.ts +1 -1
- package/tests/age-assurance.test.ts +1 -1
- package/tests/blob-divert.test.ts +1 -1
- package/tests/communication-templates.test.ts +1 -1
- package/tests/content-tagger.test.ts +1 -1
- package/tests/db.test.ts +1 -1
- package/tests/expiring-label.test.ts +1 -1
- package/tests/expiring-tags.test.ts +1 -1
- package/tests/get-account-timeline.test.ts +1 -1
- package/tests/get-config.test.ts +1 -1
- package/tests/get-lists.test.ts +2 -1
- package/tests/get-profiles.test.ts +1 -1
- package/tests/get-record.test.ts +1 -1
- package/tests/get-records.test.ts +1 -1
- package/tests/get-repo.test.ts +1 -1
- package/tests/get-report.test.ts +1 -1
- package/tests/get-reporter-stats.test.ts +1 -1
- package/tests/get-repos.test.ts +1 -1
- package/tests/get-starter-pack.test.ts +1 -1
- package/tests/get-subjects.test.ts +1 -1
- package/tests/mod-tool.test.ts +1 -1
- package/tests/moderation-appeals.test.ts +1 -1
- package/tests/moderation-events.test.ts +1 -1
- package/tests/moderation-status-tags.test.ts +1 -1
- package/tests/moderation-statuses.test.ts +1 -1
- package/tests/moderation.test.ts +1 -1
- package/tests/protected-tags.test.ts +1 -1
- package/tests/query-labels.test.ts +1 -1
- package/tests/query-reports.test.ts +1 -1
- package/tests/queue-assignment.test.ts +1 -1
- package/tests/queue-router.test.ts +1 -1
- package/tests/queues.test.ts +1 -1
- package/tests/record-and-account-events.test.ts +1 -1
- package/tests/repo-search.test.ts +2 -2
- package/tests/report-action.test.ts +1 -1
- package/tests/report-activity.test.ts +145 -1
- package/tests/report-assignment.test.ts +1 -1
- package/tests/report-muting.test.ts +1 -1
- package/tests/report-reason.test.ts +1 -1
- package/tests/report-reassign-queue.test.ts +1 -1
- package/tests/report-routing.test.ts +1 -1
- package/tests/report-stats.test.ts +1 -1
- package/tests/revoke-account-credentials.test.ts +1 -1
- package/tests/safelink.test.ts +1 -1
- package/tests/scheduled-action-processor.test.ts +1 -1
- package/tests/scheduled-action.test.ts +1 -1
- package/tests/sequencer.test.ts +1 -1
- package/tests/server.test.ts +9 -12
- package/tests/sets.test.ts +1 -1
- package/tests/settings.test.ts +1 -1
- package/tests/strike-expiry-processor.test.ts +1 -1
- package/tests/subject-priority-score.test.ts +1 -1
- package/tests/takedown.test.ts +1 -1
- package/tests/team.test.ts +1 -1
- package/tests/verification-listener.test.ts +40 -13
- package/tests/verification.test.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
package/src/report/activity.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { InvalidRequestError } from '@atproto/xrpc-server'
|
|
2
2
|
import { Database } from '../db/index.js'
|
|
3
|
+
import { TimeIdKeyset, paginate } from '../db/pagination.js'
|
|
4
|
+
import { ReportView } from '../lexicon/types/tools/ozone/report/defs.js'
|
|
5
|
+
import { QueryParams as QueryActivitiesParams } from '../lexicon/types/tools/ozone/report/queryActivities.js'
|
|
3
6
|
import { Member } from '../lexicon/types/tools/ozone/team/defs.js'
|
|
4
7
|
import {
|
|
5
8
|
AlreadyInTargetState,
|
|
@@ -190,6 +193,48 @@ export async function listReportActivities(
|
|
|
190
193
|
return { activities, cursor: nextCursor }
|
|
191
194
|
}
|
|
192
195
|
|
|
196
|
+
export async function queryReportActivities(
|
|
197
|
+
db: Database,
|
|
198
|
+
params: QueryActivitiesParams,
|
|
199
|
+
) {
|
|
200
|
+
const {
|
|
201
|
+
activityTypes,
|
|
202
|
+
createdAfter,
|
|
203
|
+
createdBefore,
|
|
204
|
+
sortDirection,
|
|
205
|
+
limit,
|
|
206
|
+
cursor,
|
|
207
|
+
} = params
|
|
208
|
+
const { ref } = db.db.dynamic
|
|
209
|
+
|
|
210
|
+
let builder = db.db.selectFrom('report_activity').selectAll()
|
|
211
|
+
|
|
212
|
+
if (activityTypes && activityTypes.length > 0) {
|
|
213
|
+
builder = builder.where('activityType', 'in', activityTypes)
|
|
214
|
+
}
|
|
215
|
+
if (createdAfter) {
|
|
216
|
+
builder = builder.where('createdAt', '>=', createdAfter)
|
|
217
|
+
}
|
|
218
|
+
if (createdBefore) {
|
|
219
|
+
builder = builder.where('createdAt', '<=', createdBefore)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const keyset = new TimeIdKeyset(
|
|
223
|
+
ref('report_activity.createdAt'),
|
|
224
|
+
ref('report_activity.id'),
|
|
225
|
+
)
|
|
226
|
+
const paginatedBuilder = paginate(builder, {
|
|
227
|
+
limit,
|
|
228
|
+
cursor,
|
|
229
|
+
keyset,
|
|
230
|
+
direction: sortDirection,
|
|
231
|
+
tryIndex: true,
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
const activities = await paginatedBuilder.execute()
|
|
235
|
+
return { activities, cursor: keyset.packFromResult(activities) }
|
|
236
|
+
}
|
|
237
|
+
|
|
193
238
|
function buildActivityObject(
|
|
194
239
|
activityType: string,
|
|
195
240
|
previousStatus: string | null,
|
|
@@ -215,6 +260,7 @@ export function formatActivityView(
|
|
|
215
260
|
createdAt: string
|
|
216
261
|
},
|
|
217
262
|
memberViews?: Map<string, Member>,
|
|
263
|
+
reportViews?: Map<number, ReportView>,
|
|
218
264
|
) {
|
|
219
265
|
return {
|
|
220
266
|
id: activity.id,
|
|
@@ -229,6 +275,7 @@ export function formatActivityView(
|
|
|
229
275
|
isAutomated: activity.isAutomated,
|
|
230
276
|
createdBy: activity.createdBy,
|
|
231
277
|
moderator: memberViews?.get(activity.createdBy),
|
|
278
|
+
report: reportViews?.get(activity.reportId),
|
|
232
279
|
createdAt: activity.createdAt,
|
|
233
280
|
}
|
|
234
281
|
}
|
package/src/report/stats.ts
CHANGED
|
@@ -672,7 +672,7 @@ export class ReportStatsService {
|
|
|
672
672
|
del =
|
|
673
673
|
r.reportTypes !== null
|
|
674
674
|
? del.where(
|
|
675
|
-
sql
|
|
675
|
+
sql<boolean>`"reportTypes"::jsonb = ${jsonb(r.reportTypes)}::jsonb`,
|
|
676
676
|
)
|
|
677
677
|
: del.where('reportTypes', 'is', null)
|
|
678
678
|
await del.execute()
|
|
@@ -720,7 +720,7 @@ export class ReportStatsService {
|
|
|
720
720
|
}
|
|
721
721
|
if (group.reportTypes !== null) {
|
|
722
722
|
qb = qb.where(
|
|
723
|
-
sql
|
|
723
|
+
sql<boolean>`"reportTypes"::jsonb = ${jsonb(group.reportTypes)}::jsonb`,
|
|
724
724
|
)
|
|
725
725
|
} else {
|
|
726
726
|
qb = qb.where('reportTypes', 'is', null)
|
|
@@ -786,7 +786,9 @@ export class ReportStatsService {
|
|
|
786
786
|
qb = qb.where('moderatorDid', 'is', null)
|
|
787
787
|
}
|
|
788
788
|
if (reportTypes !== null) {
|
|
789
|
-
qb = qb.where(
|
|
789
|
+
qb = qb.where(
|
|
790
|
+
sql<boolean>`"reportTypes"::jsonb = ${jsonb(reportTypes)}::jsonb`,
|
|
791
|
+
)
|
|
790
792
|
} else {
|
|
791
793
|
qb = qb.where('reportTypes', 'is', null)
|
|
792
794
|
}
|
|
@@ -151,24 +151,25 @@ export class ScheduledActionService {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
if (startTime) {
|
|
154
|
-
query = query.where((
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
query = query.where((eb) =>
|
|
155
|
+
eb.or([
|
|
156
|
+
eb('executeAt', '>=', startTime.toISOString()),
|
|
157
|
+
eb('executeAfter', '>=', startTime.toISOString()),
|
|
158
|
+
]),
|
|
159
|
+
)
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
if (endTime) {
|
|
162
|
-
query = query.where((
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
163
|
+
query = query.where((eb) =>
|
|
164
|
+
eb.or([
|
|
165
|
+
eb('executeAt', '<=', endTime.toISOString()),
|
|
166
|
+
eb('executeUntil', '<=', endTime.toISOString()),
|
|
167
|
+
eb.and([
|
|
168
|
+
eb('executeUntil', 'is', null),
|
|
169
|
+
eb('executeAfter', '<=', endTime.toISOString()),
|
|
170
|
+
]),
|
|
171
|
+
]),
|
|
172
|
+
)
|
|
172
173
|
}
|
|
173
174
|
|
|
174
175
|
if (cursor) {
|
|
@@ -235,11 +236,12 @@ export class ScheduledActionService {
|
|
|
235
236
|
.selectFrom('scheduled_action')
|
|
236
237
|
.selectAll()
|
|
237
238
|
.where('status', '=', 'pending')
|
|
238
|
-
.where((
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
239
|
+
.where((eb) =>
|
|
240
|
+
eb.or([
|
|
241
|
+
eb('executeAfter', '<=', now.toISOString()),
|
|
242
|
+
eb('executeAt', '<=', now.toISOString()),
|
|
243
|
+
]),
|
|
244
|
+
)
|
|
243
245
|
.execute()
|
|
244
246
|
}
|
|
245
247
|
|
package/src/set/service.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Selectable } from 'kysely'
|
|
1
|
+
import { NotNull, Selectable } from 'kysely'
|
|
2
2
|
import { Database } from '../db/index.js'
|
|
3
3
|
import { TimeIdKeyset, paginate } from '../db/pagination.js'
|
|
4
4
|
import { SetDetail } from '../db/schema/ozone_set.js'
|
|
@@ -14,19 +14,22 @@ export class SetService {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
buildQueryForSetWithSize() {
|
|
17
|
-
return this.db.db
|
|
18
|
-
's
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
return this.db.db
|
|
18
|
+
.selectFrom('set_detail as s')
|
|
19
|
+
.select([
|
|
20
|
+
's.id',
|
|
21
|
+
's.name',
|
|
22
|
+
's.description',
|
|
23
|
+
's.createdAt',
|
|
24
|
+
's.updatedAt',
|
|
25
|
+
(eb) =>
|
|
26
|
+
eb
|
|
27
|
+
.selectFrom('set_value')
|
|
28
|
+
.select((e) => e.fn.count<number>('setId').as('count'))
|
|
29
|
+
.whereRef('setId', '=', 's.id')
|
|
30
|
+
.as('setSize'),
|
|
31
|
+
])
|
|
32
|
+
.$narrowType<{ setSize: NotNull }>()
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
async query({
|
package/src/team/index.ts
CHANGED
|
@@ -67,10 +67,11 @@ export class TeamService {
|
|
|
67
67
|
builder = builder.where('disabled', disabled ? 'is' : 'is not', true)
|
|
68
68
|
}
|
|
69
69
|
if (q) {
|
|
70
|
-
builder = builder.where((
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
builder = builder.where((eb) =>
|
|
71
|
+
eb.or([
|
|
72
|
+
eb('handle', 'ilike', `%${q}%`),
|
|
73
|
+
eb('displayName', 'ilike', `%${q}%`),
|
|
74
|
+
]),
|
|
74
75
|
)
|
|
75
76
|
}
|
|
76
77
|
|
|
@@ -245,7 +246,7 @@ export class TeamService {
|
|
|
245
246
|
.selectFrom('member')
|
|
246
247
|
.select(['did'])
|
|
247
248
|
.limit(25)
|
|
248
|
-
|
|
249
|
+
.$if(!!lastDid, (q) => q.where('did', '>', lastDid))
|
|
249
250
|
.orderBy('did', 'asc')
|
|
250
251
|
.execute()
|
|
251
252
|
|
|
@@ -197,8 +197,8 @@ export class VerificationService {
|
|
|
197
197
|
.updateTable('firehose_cursor')
|
|
198
198
|
.set({ cursor })
|
|
199
199
|
.where('service', '=', 'verification')
|
|
200
|
-
.where((
|
|
201
|
-
|
|
200
|
+
.where((eb) =>
|
|
201
|
+
eb.or([eb('cursor', '<', cursor), eb('cursor', 'is', null)]),
|
|
202
202
|
)
|
|
203
203
|
.returningAll()
|
|
204
204
|
.executeTakeFirst()
|
package/tests/3p-labeler.test.ts
CHANGED
package/tests/_util.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RequestListener, createServer } from 'node:http'
|
|
2
2
|
import { AddressInfo } from 'node:net'
|
|
3
|
-
|
|
3
|
+
// eslint-disable-next-line import/default
|
|
4
|
+
import httpTerminator from 'http-terminator'
|
|
4
5
|
import { CID } from 'multiformats/cid'
|
|
5
6
|
import { lexToJson } from '@atproto/lexicon'
|
|
6
7
|
import { AtUri } from '@atproto/syntax'
|
|
@@ -215,19 +216,11 @@ export const stripViewerFromThread = <T extends ThreadViewPost>(
|
|
|
215
216
|
return thread
|
|
216
217
|
}
|
|
217
218
|
|
|
218
|
-
export async function startServer(
|
|
219
|
-
return new Promise<{
|
|
220
|
-
origin: string
|
|
221
|
-
server: Server
|
|
222
|
-
stop: () => Promise<void>
|
|
223
|
-
}>((resolve, reject) => {
|
|
219
|
+
export async function startServer(listener: RequestListener) {
|
|
220
|
+
return new Promise<AsyncDisposable & { port: number }>((resolve, reject) => {
|
|
224
221
|
const onListen = () => {
|
|
225
222
|
const port = (server.address() as AddressInfo).port
|
|
226
|
-
resolve({
|
|
227
|
-
server,
|
|
228
|
-
origin: `http://localhost:${port}`,
|
|
229
|
-
stop: () => stopServer(server),
|
|
230
|
-
})
|
|
223
|
+
resolve({ port, [Symbol.asyncDispose]: () => terminator.terminate() })
|
|
231
224
|
cleanup()
|
|
232
225
|
}
|
|
233
226
|
const onError = (err: Error) => {
|
|
@@ -239,21 +232,11 @@ export async function startServer(app: Express) {
|
|
|
239
232
|
server.removeListener('error', onError)
|
|
240
233
|
}
|
|
241
234
|
|
|
242
|
-
const server =
|
|
235
|
+
const server = createServer(listener)
|
|
243
236
|
.listen(0)
|
|
244
237
|
.once('listening', onListen)
|
|
245
238
|
.once('error', onError)
|
|
246
|
-
})
|
|
247
|
-
}
|
|
248
239
|
|
|
249
|
-
|
|
250
|
-
return new Promise<void>((resolve, reject) => {
|
|
251
|
-
server.close((err) => {
|
|
252
|
-
if (err) {
|
|
253
|
-
reject(err)
|
|
254
|
-
} else {
|
|
255
|
-
resolve()
|
|
256
|
-
}
|
|
257
|
-
})
|
|
240
|
+
const terminator = httpTerminator.createHttpTerminator({ server })
|
|
258
241
|
})
|
|
259
242
|
}
|
package/tests/db.test.ts
CHANGED
package/tests/get-config.test.ts
CHANGED
package/tests/get-lists.test.ts
CHANGED
|
@@ -35,8 +35,9 @@ describe('admin get lists', () => {
|
|
|
35
35
|
})
|
|
36
36
|
|
|
37
37
|
afterAll(async () => {
|
|
38
|
+
// @TODO figure out why we even need this in afterAll ?
|
|
38
39
|
AtpAgent.configure({ appLabelers: [BSKY_LABELER_DID] })
|
|
39
|
-
await network
|
|
40
|
+
await network?.close()
|
|
40
41
|
})
|
|
41
42
|
|
|
42
43
|
const getAlicesList = async () => {
|
package/tests/get-record.test.ts
CHANGED
package/tests/get-repo.test.ts
CHANGED
package/tests/get-report.test.ts
CHANGED
package/tests/get-repos.test.ts
CHANGED
package/tests/mod-tool.test.ts
CHANGED
package/tests/moderation.test.ts
CHANGED
package/tests/queues.test.ts
CHANGED