@atproto/ozone 0.2.9 → 0.2.11
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 +26 -0
- package/package.json +25 -21
- package/bin/migration-create.ts +0 -38
- package/jest.config.cjs +0 -22
- package/src/api/chat/getActorMetadata.ts +0 -23
- package/src/api/chat/getConvo.ts +0 -23
- package/src/api/chat/getConvoMembers.ts +0 -23
- package/src/api/chat/getConvos.ts +0 -23
- package/src/api/chat/getMessageContext.ts +0 -42
- package/src/api/chat/index.ts +0 -16
- package/src/api/communication/createTemplate.ts +0 -51
- package/src/api/communication/deleteTemplate.ts +0 -23
- package/src/api/communication/listTemplates.ts +0 -31
- package/src/api/communication/updateTemplate.ts +0 -51
- package/src/api/health.ts +0 -27
- package/src/api/index.ts +0 -146
- package/src/api/label/fetchLabels.ts +0 -32
- package/src/api/label/queryLabels.ts +0 -57
- package/src/api/label/subscribeLabels.ts +0 -25
- package/src/api/moderation/cancelScheduledActions.ts +0 -72
- package/src/api/moderation/emitEvent.ts +0 -475
- package/src/api/moderation/getAccountTimeline.ts +0 -160
- package/src/api/moderation/getEvent.ts +0 -19
- package/src/api/moderation/getRecord.ts +0 -40
- package/src/api/moderation/getRecords.ts +0 -50
- package/src/api/moderation/getRepo.ts +0 -34
- package/src/api/moderation/getReporterStats.ts +0 -18
- package/src/api/moderation/getRepos.ts +0 -41
- package/src/api/moderation/getSubjects.ts +0 -101
- package/src/api/moderation/listScheduledActions.ts +0 -45
- package/src/api/moderation/queryEvents.ts +0 -72
- package/src/api/moderation/queryStatuses.ts +0 -23
- package/src/api/moderation/scheduleAction.ts +0 -129
- package/src/api/moderation/searchRepos.ts +0 -46
- package/src/api/moderation/util.ts +0 -96
- package/src/api/proxied.ts +0 -327
- package/src/api/queue/assignModerator.ts +0 -31
- package/src/api/queue/createQueue.ts +0 -62
- package/src/api/queue/deleteQueue.ts +0 -56
- package/src/api/queue/getAssignments.ts +0 -19
- package/src/api/queue/listQueues.ts +0 -39
- package/src/api/queue/routeReports.ts +0 -44
- package/src/api/queue/unassignModerator.ts +0 -26
- package/src/api/queue/updateQueue.ts +0 -54
- package/src/api/report/assignModerator.ts +0 -36
- package/src/api/report/createActivity.ts +0 -57
- package/src/api/report/createReport.ts +0 -93
- package/src/api/report/getAssignments.ts +0 -20
- package/src/api/report/getHistoricalStats.ts +0 -41
- package/src/api/report/getLatestReport.ts +0 -44
- package/src/api/report/getLiveStats.ts +0 -26
- package/src/api/report/getReport.ts +0 -55
- package/src/api/report/listActivities.ts +0 -37
- package/src/api/report/queryActivities.ts +0 -64
- package/src/api/report/queryReports.ts +0 -44
- package/src/api/report/reassignQueue.ts +0 -68
- package/src/api/report/refreshStats.ts +0 -27
- package/src/api/report/unassignModerator.ts +0 -21
- package/src/api/safelink/addRule.ts +0 -48
- package/src/api/safelink/queryEvents.ts +0 -32
- package/src/api/safelink/queryRules.ts +0 -58
- package/src/api/safelink/removeRule.ts +0 -42
- package/src/api/safelink/updateRule.ts +0 -48
- package/src/api/server/getConfig.ts +0 -35
- package/src/api/set/addValues.ts +0 -28
- package/src/api/set/deleteSet.ts +0 -34
- package/src/api/set/deleteValues.ts +0 -31
- package/src/api/set/getValues.ts +0 -42
- package/src/api/set/querySets.ts +0 -36
- package/src/api/set/upsertSet.ts +0 -38
- package/src/api/setting/listOptions.ts +0 -44
- package/src/api/setting/removeOptions.ts +0 -64
- package/src/api/setting/upsertOption.ts +0 -156
- package/src/api/team/addMember.ts +0 -51
- package/src/api/team/deleteMember.ts +0 -29
- package/src/api/team/listMembers.ts +0 -20
- package/src/api/team/updateMember.ts +0 -47
- package/src/api/util.ts +0 -265
- package/src/api/verification/grantVerifications.ts +0 -90
- package/src/api/verification/listVerifications.ts +0 -44
- package/src/api/verification/revokeVerifications.ts +0 -43
- package/src/api/well-known.ts +0 -46
- package/src/assignment/index.ts +0 -728
- package/src/auth-verifier.ts +0 -227
- package/src/background.ts +0 -183
- package/src/communication-service/template.ts +0 -110
- package/src/communication-service/util.ts +0 -8
- package/src/config/config.ts +0 -211
- package/src/config/env.ts +0 -95
- package/src/config/index.ts +0 -3
- package/src/config/secrets.ts +0 -17
- package/src/context.ts +0 -399
- package/src/daemon/blob-diverter.ts +0 -186
- package/src/daemon/context.ts +0 -247
- package/src/daemon/event-pusher.ts +0 -363
- package/src/daemon/event-reverser.ts +0 -128
- package/src/daemon/index.ts +0 -33
- package/src/daemon/job-cursor.ts +0 -33
- package/src/daemon/materialized-view-refresher.ts +0 -33
- package/src/daemon/queue-router.ts +0 -101
- package/src/daemon/scheduled-action-processor.ts +0 -304
- package/src/daemon/stats-computer.ts +0 -101
- package/src/daemon/strike-expiry-processor.ts +0 -95
- package/src/daemon/team-profile-synchronizer.ts +0 -15
- package/src/daemon/verification-listener.ts +0 -169
- package/src/db/index.ts +0 -203
- package/src/db/migrations/20231219T205730722Z-init.ts +0 -170
- package/src/db/migrations/20240116T085607200Z-communication-template.ts +0 -23
- package/src/db/migrations/20240201T051104136Z-mod-event-blobs.ts +0 -15
- package/src/db/migrations/20240208T213404429Z-add-tags-column-to-moderation-subject.ts +0 -31
- package/src/db/migrations/20240228T003647759Z-add-label-sigs.ts +0 -25
- package/src/db/migrations/20240408T192432676Z-mute-reporting.ts +0 -15
- package/src/db/migrations/20240506T225055595Z-message-subject.ts +0 -21
- package/src/db/migrations/20240521T211332580Z-member.ts +0 -17
- package/src/db/migrations/20240814T003647759Z-event-created-at-index.ts +0 -13
- package/src/db/migrations/20240903T205730722Z-add-template-lang.ts +0 -12
- package/src/db/migrations/20240904T205730722Z-add-subject-did-index.ts +0 -13
- package/src/db/migrations/20241001T205730722Z-subject-status-review-state-index.ts +0 -15
- package/src/db/migrations/20241008T205730722Z-sets.ts +0 -53
- package/src/db/migrations/20241018T205730722Z-setting.ts +0 -27
- package/src/db/migrations/20241026T205730722Z-add-hosting-status-to-subject-status.ts +0 -57
- package/src/db/migrations/20241220T144630860Z-stats-materialized-views.ts +0 -215
- package/src/db/migrations/20250204T003647759Z-add-subject-priority-score.ts +0 -22
- package/src/db/migrations/20250211T003647759Z-add-reporter-stats-index.ts +0 -38
- package/src/db/migrations/20250211T132135150Z-moderation-event-message-partial-idx.ts +0 -26
- package/src/db/migrations/20250221T132135150Z-member-details.ts +0 -14
- package/src/db/migrations/20250404T201720309Z-subject-status-sort-idxs.ts +0 -18
- package/src/db/migrations/20250415T201720309Z-verification.ts +0 -34
- package/src/db/migrations/20250417T201720309Z-firehose-cursor.ts +0 -16
- package/src/db/migrations/20250609T110704000Z-safelink.ts +0 -53
- package/src/db/migrations/20250618T180246000Z-add-mod-tool-to-moderation-event.ts +0 -18
- package/src/db/migrations/20250701T000000000Z-add-age-assurance-state.ts +0 -25
- package/src/db/migrations/20250715T000000000Z-add-mod-event-external-id.ts +0 -15
- package/src/db/migrations/20250718T150931000Z-update-appeal-reason-stats.ts +0 -310
- package/src/db/migrations/20250813T000000000Z-mod-tool-batch-id-index.ts +0 -14
- package/src/db/migrations/20250923T000000000Z-scheduled-actions.ts +0 -56
- package/src/db/migrations/20251008T120000000Z-add-strike-system.ts +0 -87
- package/src/db/migrations/20260210T154806448Z-mod-event-created-by-indexes.ts +0 -22
- package/src/db/migrations/20260219T164523000Z-create-report-table.ts +0 -155
- package/src/db/migrations/20260219T165302248Z-moderator-assignment.ts +0 -42
- package/src/db/migrations/20260225T000000000Z-add-report-queue-table.ts +0 -41
- package/src/db/migrations/20260313T000000000Z-add-report-activity-table.ts +0 -48
- package/src/db/migrations/20260318T152058935Z-add-report-stat.ts +0 -35
- package/src/db/migrations/20260428T000000000Z-add-expiring-tag-table.ts +0 -32
- package/src/db/migrations/20260513T202941104Z-add-subject-convo-id.ts +0 -114
- package/src/db/migrations/20260602T120000000Z-add-report-activity-created-index.ts +0 -17
- package/src/db/migrations/index.ts +0 -44
- package/src/db/migrations/provider.ts +0 -26
- package/src/db/pagination.ts +0 -335
- package/src/db/schema/account_events_stats.ts +0 -16
- package/src/db/schema/account_record_events_stats.ts +0 -15
- package/src/db/schema/account_record_status_stats.ts +0 -15
- package/src/db/schema/account_strike.ts +0 -13
- package/src/db/schema/blob_push_event.ts +0 -21
- package/src/db/schema/communication_template.ts +0 -19
- package/src/db/schema/expiring_tag.ts +0 -18
- package/src/db/schema/firehose_cursor.ts +0 -13
- package/src/db/schema/index.ts +0 -60
- package/src/db/schema/job_cursor.ts +0 -13
- package/src/db/schema/label.ts +0 -22
- package/src/db/schema/member.ts +0 -22
- package/src/db/schema/moderation_event.ts +0 -61
- package/src/db/schema/moderation_subject_status.ts +0 -52
- package/src/db/schema/moderator_assignment.ts +0 -16
- package/src/db/schema/ozone_set.ts +0 -24
- package/src/db/schema/record_events_stats.ts +0 -15
- package/src/db/schema/record_push_event.ts +0 -21
- package/src/db/schema/repo_push_event.ts +0 -19
- package/src/db/schema/report.ts +0 -28
- package/src/db/schema/report_activity.ts +0 -22
- package/src/db/schema/report_queue.ts +0 -21
- package/src/db/schema/report_stat.ts +0 -27
- package/src/db/schema/safelink.ts +0 -39
- package/src/db/schema/scheduled-action.ts +0 -25
- package/src/db/schema/setting.ts +0 -24
- package/src/db/schema/signing_key.ts +0 -10
- package/src/db/schema/verification.ts +0 -21
- package/src/db/types.ts +0 -24
- package/src/error.ts +0 -12
- package/src/image-invalidator.ts +0 -7
- package/src/index.ts +0 -154
- package/src/jetstream/service.ts +0 -107
- package/src/logger.ts +0 -29
- package/src/mod-service/expiring-tags.ts +0 -104
- package/src/mod-service/index.ts +0 -1842
- package/src/mod-service/profile.ts +0 -139
- package/src/mod-service/report.ts +0 -429
- package/src/mod-service/status.ts +0 -549
- package/src/mod-service/strike.ts +0 -96
- package/src/mod-service/subject.ts +0 -311
- package/src/mod-service/types.ts +0 -96
- package/src/mod-service/util.ts +0 -99
- package/src/mod-service/views.ts +0 -912
- package/src/queue/service.ts +0 -603
- package/src/report/activity.ts +0 -281
- package/src/report/handle-report-update.ts +0 -209
- package/src/report/reassign.ts +0 -109
- package/src/report/stats.ts +0 -852
- package/src/report/views.ts +0 -239
- package/src/safelink/service.ts +0 -304
- package/src/scheduled-action/service.ts +0 -281
- package/src/scheduled-action/types.ts +0 -17
- package/src/sequencer/index.ts +0 -2
- package/src/sequencer/outbox.ts +0 -123
- package/src/sequencer/sequencer.ts +0 -147
- package/src/set/service.ts +0 -230
- package/src/setting/constants.ts +0 -3
- package/src/setting/service.ts +0 -148
- package/src/setting/types.ts +0 -3
- package/src/setting/validators.ts +0 -333
- package/src/tag-service/content-tagger.ts +0 -30
- package/src/tag-service/embed-tagger.ts +0 -70
- package/src/tag-service/index.ts +0 -70
- package/src/tag-service/language-data.ts +0 -561
- package/src/tag-service/language-tagger.ts +0 -101
- package/src/tag-service/util.ts +0 -13
- package/src/team/index.ts +0 -296
- package/src/util.ts +0 -230
- package/src/verification/issuer.ts +0 -146
- package/src/verification/service.ts +0 -208
- package/src/verification/util.ts +0 -53
- package/test.env +0 -2
- package/tests/3p-labeler.test.ts +0 -288
- package/tests/__snapshots__/account-strikes.test.ts.snap +0 -159
- package/tests/__snapshots__/age-assurance.test.ts.snap +0 -66
- package/tests/__snapshots__/blob-divert.test.ts.snap +0 -219
- package/tests/__snapshots__/get-account-timeline.test.ts.snap +0 -36
- package/tests/__snapshots__/get-record.test.ts.snap +0 -271
- package/tests/__snapshots__/get-records.test.ts.snap +0 -175
- package/tests/__snapshots__/get-repo.test.ts.snap +0 -91
- package/tests/__snapshots__/get-repos.test.ts.snap +0 -127
- package/tests/__snapshots__/get-starter-pack.test.ts.snap +0 -535
- package/tests/__snapshots__/get-subjects.test.ts.snap +0 -529
- package/tests/__snapshots__/moderation-events.test.ts.snap +0 -347
- package/tests/__snapshots__/moderation-statuses.test.ts.snap +0 -276
- package/tests/__snapshots__/moderation.test.ts.snap +0 -85
- package/tests/__snapshots__/report-reason.test.ts.snap +0 -14
- package/tests/__snapshots__/safelink.test.ts.snap +0 -179
- package/tests/__snapshots__/scheduled-action.test.ts.snap +0 -61
- package/tests/__snapshots__/sets.test.ts.snap +0 -46
- package/tests/__snapshots__/settings.test.ts.snap +0 -52
- package/tests/__snapshots__/team.test.ts.snap +0 -374
- package/tests/__snapshots__/verification-listener.test.ts.snap +0 -152
- package/tests/__snapshots__/verification.test.ts.snap +0 -302
- package/tests/_util.ts +0 -242
- package/tests/account-strikes.test.ts +0 -184
- package/tests/ack-all-subjects-of-account.test.ts +0 -177
- package/tests/age-assurance.test.ts +0 -372
- package/tests/blob-divert.test.ts +0 -106
- package/tests/communication-templates.test.ts +0 -149
- package/tests/content-tagger.test.ts +0 -170
- package/tests/db.test.ts +0 -184
- package/tests/expiring-label.test.ts +0 -72
- package/tests/expiring-tags.test.ts +0 -232
- package/tests/get-account-timeline.test.ts +0 -85
- package/tests/get-config.test.ts +0 -55
- package/tests/get-lists.test.ts +0 -111
- package/tests/get-profiles.test.ts +0 -70
- package/tests/get-record.test.ts +0 -130
- package/tests/get-records.test.ts +0 -91
- package/tests/get-repo.test.ts +0 -171
- package/tests/get-report.test.ts +0 -136
- package/tests/get-reporter-stats.test.ts +0 -132
- package/tests/get-repos.test.ts +0 -91
- package/tests/get-starter-pack.test.ts +0 -115
- package/tests/get-subjects.test.ts +0 -81
- package/tests/mod-tool.test.ts +0 -268
- package/tests/moderation-appeals.test.ts +0 -260
- package/tests/moderation-events.test.ts +0 -756
- package/tests/moderation-status-tags.test.ts +0 -140
- package/tests/moderation-statuses.test.ts +0 -495
- package/tests/moderation.test.ts +0 -992
- package/tests/protected-tags.test.ts +0 -218
- package/tests/query-labels.test.ts +0 -238
- package/tests/query-reports.test.ts +0 -608
- package/tests/queue-assignment.test.ts +0 -428
- package/tests/queue-router.test.ts +0 -306
- package/tests/queues.test.ts +0 -690
- package/tests/record-and-account-events.test.ts +0 -197
- package/tests/repo-search.test.ts +0 -136
- package/tests/report-action.test.ts +0 -308
- package/tests/report-activity.test.ts +0 -711
- package/tests/report-assignment.test.ts +0 -517
- package/tests/report-muting.test.ts +0 -100
- package/tests/report-reason.test.ts +0 -154
- package/tests/report-reassign-queue.test.ts +0 -340
- package/tests/report-routing.test.ts +0 -245
- package/tests/report-stats.test.ts +0 -545
- package/tests/revoke-account-credentials.test.ts +0 -54
- package/tests/safelink.test.ts +0 -534
- package/tests/scheduled-action-processor.test.ts +0 -488
- package/tests/scheduled-action.test.ts +0 -334
- package/tests/sequencer.test.ts +0 -227
- package/tests/server.test.ts +0 -62
- package/tests/sets.test.ts +0 -246
- package/tests/settings.test.ts +0 -308
- package/tests/strike-expiry-processor.test.ts +0 -299
- package/tests/subject-priority-score.test.ts +0 -96
- package/tests/takedown.test.ts +0 -105
- package/tests/team.test.ts +0 -216
- package/tests/verification-listener.test.ts +0 -129
- package/tests/verification.test.ts +0 -186
- package/tsconfig.build.json +0 -9
- package/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.json +0 -7
- package/tsconfig.tests.json +0 -8
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Kysely, sql } from 'kysely'
|
|
2
|
-
|
|
3
|
-
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
4
|
-
await db.schema
|
|
5
|
-
.createTable('moderator_assignment')
|
|
6
|
-
.addColumn('id', 'serial', (col) => col.primaryKey())
|
|
7
|
-
// assignee
|
|
8
|
-
.addColumn('did', 'text', (col) => col.notNull())
|
|
9
|
-
// assigned over
|
|
10
|
-
.addColumn('reportId', 'integer')
|
|
11
|
-
.addColumn('queueId', 'integer')
|
|
12
|
-
// validity
|
|
13
|
-
.addColumn('startAt', 'varchar', (col) => col.notNull())
|
|
14
|
-
.addColumn('endAt', 'varchar')
|
|
15
|
-
.execute()
|
|
16
|
-
|
|
17
|
-
// Partial index for getting active queue assignments
|
|
18
|
-
await sql`CREATE INDEX idx_assignment_queue_active ON moderator_assignment ("endAt") WHERE "reportId" IS NULL`.execute(
|
|
19
|
-
db,
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
// Partial index for getting active report assignments for queue
|
|
23
|
-
await sql`CREATE INDEX idx_assignment_report_by_queue ON moderator_assignment ("queueId", "endAt") WHERE "reportId" IS NOT NULL`.execute(
|
|
24
|
-
db,
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
// Index for checking active report assignment
|
|
28
|
-
await db.schema
|
|
29
|
-
.createIndex('idx_assignment_report_active')
|
|
30
|
-
.on('moderator_assignment')
|
|
31
|
-
.columns(['reportId', 'endAt'])
|
|
32
|
-
.execute()
|
|
33
|
-
|
|
34
|
-
// Partial index for permanent report assignments by moderator
|
|
35
|
-
await sql`CREATE INDEX idx_assignment_permanent_did ON moderator_assignment (did, "reportId") WHERE "endAt" IS NULL`.execute(
|
|
36
|
-
db,
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
41
|
-
await db.schema.dropTable('moderator_assignment').ifExists().execute()
|
|
42
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Kysely, sql } from 'kysely'
|
|
2
|
-
|
|
3
|
-
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
4
|
-
// Report queue configuration table
|
|
5
|
-
await db.schema
|
|
6
|
-
.createTable('report_queue')
|
|
7
|
-
.addColumn('id', 'serial', (col) => col.primaryKey())
|
|
8
|
-
.addColumn('name', 'varchar', (col) => col.notNull()) // uniqueness enforced via partial index below
|
|
9
|
-
.addColumn('description', 'varchar') // Optional description of the queue
|
|
10
|
-
|
|
11
|
-
// Queue filters (determine assignment)
|
|
12
|
-
.addColumn('subjectTypes', 'jsonb', (col) => col.notNull()) // Array: ['account'] or ['record'] or both
|
|
13
|
-
.addColumn('collection', 'varchar') // Collection name (e.g., 'app.bsky.feed.post'), NULL for accounts
|
|
14
|
-
.addColumn('reportTypes', 'jsonb', (col) => col.notNull()) // Array: report reason types
|
|
15
|
-
|
|
16
|
-
// Metadata
|
|
17
|
-
.addColumn('createdBy', 'varchar', (col) => col.notNull()) // DID of mod who created queue
|
|
18
|
-
.addColumn('createdAt', 'varchar', (col) => col.notNull())
|
|
19
|
-
.addColumn('updatedAt', 'varchar', (col) => col.notNull())
|
|
20
|
-
.addColumn('enabled', 'boolean', (col) => col.notNull().defaultTo(true))
|
|
21
|
-
.addColumn('deletedAt', 'varchar') // NULL = active, timestamp = soft-deleted
|
|
22
|
-
.execute()
|
|
23
|
-
|
|
24
|
-
// Partial unique index on name — only enforces uniqueness for non-deleted queues,
|
|
25
|
-
// so a soft-deleted queue's name can be reused by a new queue.
|
|
26
|
-
await sql`CREATE UNIQUE INDEX idx_queue_name_unique ON report_queue (name) WHERE "deletedAt" IS NULL`.execute(
|
|
27
|
-
db,
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
// Partial composite index covers all list queries on active queues: filter by enabled,
|
|
31
|
-
// sort by createdAt/id. The WHERE clause keeps the index small (deleted rows excluded).
|
|
32
|
-
await sql`CREATE INDEX idx_queue_active ON report_queue (enabled, "createdAt", id) WHERE "deletedAt" IS NULL`.execute(
|
|
33
|
-
db,
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
38
|
-
await db.schema.dropIndex('idx_queue_name_unique').execute()
|
|
39
|
-
await db.schema.dropIndex('idx_queue_active').execute()
|
|
40
|
-
await db.schema.dropTable('report_queue').execute()
|
|
41
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Kysely, sql } from 'kysely'
|
|
2
|
-
|
|
3
|
-
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
4
|
-
await db.schema
|
|
5
|
-
.createTable('report_activity')
|
|
6
|
-
.addColumn('id', 'serial', (col) => col.primaryKey())
|
|
7
|
-
.addColumn('reportId', 'integer', (col) => col.notNull())
|
|
8
|
-
|
|
9
|
-
// Discriminator: one of queueActivity | assignmentActivity | escalationActivity
|
|
10
|
-
// | closeActivity | internalNoteActivity | publicNoteActivity
|
|
11
|
-
.addColumn('activityType', 'varchar', (col) => col.notNull())
|
|
12
|
-
|
|
13
|
-
// The report's status at the moment this activity was recorded.
|
|
14
|
-
// Populated for state-change activity types; null for note-only activities.
|
|
15
|
-
.addColumn('previousStatus', 'varchar')
|
|
16
|
-
|
|
17
|
-
// Note fields — separated by audience
|
|
18
|
-
.addColumn('internalNote', 'text') // moderator-only
|
|
19
|
-
.addColumn('publicNote', 'text') // potentially reporter-visible
|
|
20
|
-
|
|
21
|
-
// Free-form JSON for loose activity-specific metadata (e.g. { assignmentId: 42 })
|
|
22
|
-
.addColumn('meta', 'jsonb')
|
|
23
|
-
|
|
24
|
-
// True when created by an automated process (e.g. queue router)
|
|
25
|
-
.addColumn('isAutomated', 'boolean', (col) =>
|
|
26
|
-
col.notNull().defaultTo(false),
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
.addColumn('createdBy', 'text', (col) => col.notNull())
|
|
30
|
-
.addColumn('createdAt', 'varchar', (col) => col.notNull())
|
|
31
|
-
.execute()
|
|
32
|
-
|
|
33
|
-
// Primary filter: all activities for a given report, sorted most-recent-first
|
|
34
|
-
await db.schema
|
|
35
|
-
.createIndex('idx_report_activity_report_created')
|
|
36
|
-
.on('report_activity')
|
|
37
|
-
.columns(['reportId', 'createdAt', 'id'])
|
|
38
|
-
.execute()
|
|
39
|
-
|
|
40
|
-
// Partial index to efficiently find automated activities per report
|
|
41
|
-
await sql`CREATE INDEX idx_report_activity_automated ON report_activity ("reportId", "createdAt", id) WHERE "isAutomated" = true`.execute(
|
|
42
|
-
db,
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
47
|
-
await db.schema.dropTable('report_activity').execute()
|
|
48
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Kysely, sql } from 'kysely'
|
|
2
|
-
|
|
3
|
-
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
4
|
-
await db.schema
|
|
5
|
-
.createTable('report_stat')
|
|
6
|
-
|
|
7
|
-
// metadata
|
|
8
|
-
.addColumn('id', 'serial', (col) => col.primaryKey())
|
|
9
|
-
.addColumn('computedAt', 'varchar', (col) => col.notNull())
|
|
10
|
-
|
|
11
|
-
// group
|
|
12
|
-
.addColumn('date', 'varchar', (col) => col.notNull()) // ISO date e.g. '2026-04-15'
|
|
13
|
-
.addColumn('queueId', 'integer') // NULL = aggregate across all queues
|
|
14
|
-
.addColumn('reportTypes', 'jsonb') // NULL = aggregate across all report types
|
|
15
|
-
.addColumn('moderatorDid', 'varchar') // NULL = aggregate across all moderators
|
|
16
|
-
|
|
17
|
-
// stats
|
|
18
|
-
.addColumn('inboundCount', 'integer')
|
|
19
|
-
.addColumn('pendingCount', 'integer')
|
|
20
|
-
.addColumn('actionedCount', 'integer')
|
|
21
|
-
.addColumn('escalatedCount', 'integer')
|
|
22
|
-
.addColumn('actionRate', 'integer')
|
|
23
|
-
.addColumn('avgHandlingTimeSec', 'integer')
|
|
24
|
-
.execute()
|
|
25
|
-
|
|
26
|
-
// Lookup by date + group dimensions (covers getLiveStats and getHistoricalStats queries)
|
|
27
|
-
await sql`CREATE INDEX idx_report_stat_lookup ON report_stat (
|
|
28
|
-
date, "queueId", "moderatorDid", "reportTypes", "computedAt"
|
|
29
|
-
)`.execute(db)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
33
|
-
await db.schema.dropIndex('idx_report_stat_lookup').ifExists().execute()
|
|
34
|
-
await db.schema.dropTable('report_stat').ifExists().execute()
|
|
35
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Kysely } from 'kysely'
|
|
2
|
-
|
|
3
|
-
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
4
|
-
await db.schema
|
|
5
|
-
.createTable('expiring_tag')
|
|
6
|
-
.addColumn('id', 'serial', (col) => col.primaryKey())
|
|
7
|
-
.addColumn('eventId', 'integer', (col) => col.notNull())
|
|
8
|
-
.addColumn('did', 'varchar', (col) => col.notNull())
|
|
9
|
-
.addColumn('recordPath', 'varchar', (col) => col.notNull())
|
|
10
|
-
.addColumn('tag', 'varchar', (col) => col.notNull())
|
|
11
|
-
.addColumn('expiresAt', 'varchar', (col) => col.notNull())
|
|
12
|
-
.addColumn('createdBy', 'varchar', (col) => col.notNull())
|
|
13
|
-
.execute()
|
|
14
|
-
|
|
15
|
-
// Daemon polls for expired tags
|
|
16
|
-
await db.schema
|
|
17
|
-
.createIndex('idx_expiring_tag_expires_at')
|
|
18
|
-
.on('expiring_tag')
|
|
19
|
-
.column('expiresAt')
|
|
20
|
-
.execute()
|
|
21
|
-
|
|
22
|
-
// Cleanup queries when tags are manually removed
|
|
23
|
-
await db.schema
|
|
24
|
-
.createIndex('idx_expiring_tag_did_record_path')
|
|
25
|
-
.on('expiring_tag')
|
|
26
|
-
.columns(['did', 'recordPath'])
|
|
27
|
-
.execute()
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
31
|
-
await db.schema.dropTable('expiring_tag').execute()
|
|
32
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { Kysely, sql } from 'kysely'
|
|
2
|
-
|
|
3
|
-
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
4
|
-
// moderation_event
|
|
5
|
-
await db.schema
|
|
6
|
-
.alterTable('moderation_event')
|
|
7
|
-
.addColumn('subjectConvoId', 'varchar')
|
|
8
|
-
.execute()
|
|
9
|
-
/// broad index to support conversation-based queries
|
|
10
|
-
/// Users is a convo is capped at 50 so volume of matching events should be low
|
|
11
|
-
/// subsequent ordering and filtering will be efficient
|
|
12
|
-
await sql`
|
|
13
|
-
CREATE INDEX "moderation_event_convo_idx"
|
|
14
|
-
ON moderation_event("subjectConvoId")
|
|
15
|
-
WHERE "subjectConvoId" IS NOT NULL
|
|
16
|
-
`.execute(db)
|
|
17
|
-
|
|
18
|
-
// moderation_subject_status
|
|
19
|
-
await db.schema
|
|
20
|
-
.alterTable('moderation_subject_status')
|
|
21
|
-
.addColumn('convoId', 'varchar', (col) => col.notNull().defaultTo(''))
|
|
22
|
-
.execute()
|
|
23
|
-
/// Update unique constraint: [did, recordPath] -> [did, recordPath, convoId]
|
|
24
|
-
/// Create new unique index, drop old constraint, rename new index
|
|
25
|
-
/// Avoids gap without any constraints
|
|
26
|
-
await sql`
|
|
27
|
-
CREATE UNIQUE INDEX "moderation_status_unique_idx_new"
|
|
28
|
-
ON moderation_subject_status(did, "recordPath", "convoId")
|
|
29
|
-
`.execute(db)
|
|
30
|
-
await db.schema
|
|
31
|
-
.alterTable('moderation_subject_status')
|
|
32
|
-
.dropConstraint('moderation_status_unique_idx')
|
|
33
|
-
.execute()
|
|
34
|
-
await db.schema.dropIndex('moderation_status_unique_idx').ifExists().execute()
|
|
35
|
-
await sql`
|
|
36
|
-
ALTER INDEX "moderation_status_unique_idx_new"
|
|
37
|
-
RENAME TO "moderation_status_unique_idx"
|
|
38
|
-
`.execute(db)
|
|
39
|
-
await sql`
|
|
40
|
-
ALTER TABLE moderation_subject_status
|
|
41
|
-
ADD CONSTRAINT "moderation_status_unique_idx"
|
|
42
|
-
UNIQUE USING INDEX "moderation_status_unique_idx"
|
|
43
|
-
`.execute(db)
|
|
44
|
-
|
|
45
|
-
// expiring_tag
|
|
46
|
-
await db.schema
|
|
47
|
-
.alterTable('expiring_tag')
|
|
48
|
-
.addColumn('convoId', 'varchar', (col) => col.notNull().defaultTo(''))
|
|
49
|
-
.execute()
|
|
50
|
-
await db.schema
|
|
51
|
-
.createIndex('idx_expiring_tag_did_record_path_convo_id')
|
|
52
|
-
.on('expiring_tag')
|
|
53
|
-
.columns(['did', 'recordPath', 'convoId'])
|
|
54
|
-
.execute()
|
|
55
|
-
|
|
56
|
-
// report table
|
|
57
|
-
await db.schema
|
|
58
|
-
.alterTable('report')
|
|
59
|
-
.addColumn('subjectConvoId', 'varchar')
|
|
60
|
-
.execute()
|
|
61
|
-
await db.schema.dropIndex('idx_report_unassigned_id').execute()
|
|
62
|
-
await sql`CREATE INDEX idx_report_unassigned_id ON report
|
|
63
|
-
(id)
|
|
64
|
-
INCLUDE (status, "reportType", "recordPath", "subjectMessageId", "subjectConvoId")
|
|
65
|
-
WHERE ("queueId" IS NULL AND status != 'closed')`.execute(db)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
69
|
-
// report
|
|
70
|
-
await db.schema.dropIndex('idx_report_unassigned_id').execute()
|
|
71
|
-
await sql`CREATE INDEX idx_report_unassigned_id ON report
|
|
72
|
-
(id)
|
|
73
|
-
INCLUDE (status, "reportType", "recordPath", "subjectMessageId")
|
|
74
|
-
WHERE ("queueId" IS NULL AND status != 'closed')`.execute(db)
|
|
75
|
-
await db.schema.alterTable('report').dropColumn('subjectConvoId').execute()
|
|
76
|
-
|
|
77
|
-
// expiring_tag
|
|
78
|
-
await db.schema
|
|
79
|
-
.dropIndex('idx_expiring_tag_did_record_path_convo_id')
|
|
80
|
-
.execute()
|
|
81
|
-
await db.schema.alterTable('expiring_tag').dropColumn('convoId').execute()
|
|
82
|
-
|
|
83
|
-
// moderation_subject_status
|
|
84
|
-
/// Reverse the unique constraint change: [did, recordPath, convoId] -> [did, recordPath]
|
|
85
|
-
await sql`
|
|
86
|
-
CREATE UNIQUE INDEX "moderation_status_unique_idx_old"
|
|
87
|
-
ON moderation_subject_status(did, "recordPath")
|
|
88
|
-
`.execute(db)
|
|
89
|
-
await db.schema
|
|
90
|
-
.alterTable('moderation_subject_status')
|
|
91
|
-
.dropConstraint('moderation_status_unique_idx')
|
|
92
|
-
.execute()
|
|
93
|
-
await db.schema.dropIndex('moderation_status_unique_idx').ifExists().execute()
|
|
94
|
-
await sql`
|
|
95
|
-
ALTER INDEX "moderation_status_unique_idx_old"
|
|
96
|
-
RENAME TO "moderation_status_unique_idx"
|
|
97
|
-
`.execute(db)
|
|
98
|
-
await sql`
|
|
99
|
-
ALTER TABLE moderation_subject_status
|
|
100
|
-
ADD CONSTRAINT "moderation_status_unique_idx"
|
|
101
|
-
UNIQUE USING INDEX "moderation_status_unique_idx"
|
|
102
|
-
`.execute(db)
|
|
103
|
-
await db.schema
|
|
104
|
-
.alterTable('moderation_subject_status')
|
|
105
|
-
.dropColumn('convoId')
|
|
106
|
-
.execute()
|
|
107
|
-
|
|
108
|
-
// moderation_event
|
|
109
|
-
await db.schema.dropIndex('moderation_event_convo_idx').execute()
|
|
110
|
-
await db.schema
|
|
111
|
-
.alterTable('moderation_event')
|
|
112
|
-
.dropColumn('subjectConvoId')
|
|
113
|
-
.execute()
|
|
114
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Kysely } from 'kysely'
|
|
2
|
-
|
|
3
|
-
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
4
|
-
// Supports time-ordered scans across all reports for downstream pollers
|
|
5
|
-
// (e.g. Nimbus' report-activity watcher). The existing indexes are all
|
|
6
|
-
// leading-`reportId`, which would force a sequential scan for global
|
|
7
|
-
// ordered queries.
|
|
8
|
-
await db.schema
|
|
9
|
-
.createIndex('idx_report_activity_created')
|
|
10
|
-
.on('report_activity')
|
|
11
|
-
.columns(['createdAt', 'id'])
|
|
12
|
-
.execute()
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
16
|
-
await db.schema.dropIndex('idx_report_activity_created').execute()
|
|
17
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// NOTE this file can be edited by hand, but it is also appended to by the migration:create command.
|
|
2
|
-
// It's important that every migration is exported from here with the proper name. We'd simplify
|
|
3
|
-
// this with kysely's FileMigrationProvider, but it doesn't play nicely with the build process.
|
|
4
|
-
|
|
5
|
-
export * as _20231219T205730722Z from './20231219T205730722Z-init.js'
|
|
6
|
-
export * as _20240116T085607200Z from './20240116T085607200Z-communication-template.js'
|
|
7
|
-
export * as _20240201T051104136Z from './20240201T051104136Z-mod-event-blobs.js'
|
|
8
|
-
export * as _20240208T213404429Z from './20240208T213404429Z-add-tags-column-to-moderation-subject.js'
|
|
9
|
-
export * as _20240228T003647759Z from './20240228T003647759Z-add-label-sigs.js'
|
|
10
|
-
export * as _20240408T192432676Z from './20240408T192432676Z-mute-reporting.js'
|
|
11
|
-
export * as _20240506T225055595Z from './20240506T225055595Z-message-subject.js'
|
|
12
|
-
export * as _20240430T211332580Z from './20240521T211332580Z-member.js'
|
|
13
|
-
export * as _20240814T003647759Z from './20240814T003647759Z-event-created-at-index.js'
|
|
14
|
-
export * as _20240903T205730722Z from './20240903T205730722Z-add-template-lang.js'
|
|
15
|
-
export * as _20240904T205730722Z from './20240904T205730722Z-add-subject-did-index.js'
|
|
16
|
-
export * as _20241001T205730722Z from './20241001T205730722Z-subject-status-review-state-index.js'
|
|
17
|
-
export * as _20241008T205730722Z from './20241008T205730722Z-sets.js'
|
|
18
|
-
export * as _20241018T205730722Z from './20241018T205730722Z-setting.js'
|
|
19
|
-
export * as _20241026T205730722Z from './20241026T205730722Z-add-hosting-status-to-subject-status.js'
|
|
20
|
-
export * as _20241220T144630860Z from './20241220T144630860Z-stats-materialized-views.js'
|
|
21
|
-
export * as _20250204T003647759Z from './20250204T003647759Z-add-subject-priority-score.js'
|
|
22
|
-
export * as _20250211T003647759Z from './20250211T003647759Z-add-reporter-stats-index.js'
|
|
23
|
-
export * as _20250211T132135150Z from './20250211T132135150Z-moderation-event-message-partial-idx.js'
|
|
24
|
-
export * as _20250221T132135150Z from './20250221T132135150Z-member-details.js'
|
|
25
|
-
export * as _20250404T201720309Z from './20250404T201720309Z-subject-status-sort-idxs.js'
|
|
26
|
-
export * as _20250415T201720309Z from './20250415T201720309Z-verification.js'
|
|
27
|
-
export * as _20250417T201720309Z from './20250417T201720309Z-firehose-cursor.js'
|
|
28
|
-
export * as _20250609T110704000Z from './20250609T110704000Z-safelink.js'
|
|
29
|
-
export * as _20250618T180246000Z from './20250618T180246000Z-add-mod-tool-to-moderation-event.js'
|
|
30
|
-
export * as _20250701T000000000Z from './20250701T000000000Z-add-age-assurance-state.js'
|
|
31
|
-
export * as _20250715T000000000Z from './20250715T000000000Z-add-mod-event-external-id.js'
|
|
32
|
-
export * as _20250718T150931000Z from './20250718T150931000Z-update-appeal-reason-stats.js'
|
|
33
|
-
export * as _20250813T000000000Z from './20250813T000000000Z-mod-tool-batch-id-index.js'
|
|
34
|
-
export * as _20250923T000000000Z from './20250923T000000000Z-scheduled-actions.js'
|
|
35
|
-
export * as _20251008T120000000Z from './20251008T120000000Z-add-strike-system.js'
|
|
36
|
-
export * as _20260210T154806448Z from './20260210T154806448Z-mod-event-created-by-indexes.js'
|
|
37
|
-
export * as _20260219T164523000Z from './20260219T164523000Z-create-report-table.js'
|
|
38
|
-
export * as _20260219T165302248Z from './20260219T165302248Z-moderator-assignment.js'
|
|
39
|
-
export * as _20260225T000000000Z from './20260225T000000000Z-add-report-queue-table.js'
|
|
40
|
-
export * as _20260313T000000000Z from './20260313T000000000Z-add-report-activity-table.js'
|
|
41
|
-
export * as _20260318T152058935Z from './20260318T152058935Z-add-report-stat.js'
|
|
42
|
-
export * as _20260428T000000000Z from './20260428T000000000Z-add-expiring-tag-table.js'
|
|
43
|
-
export * as _20260513T202941104Z from './20260513T202941104Z-add-subject-convo-id.js'
|
|
44
|
-
export * as _20260602T120000000Z from './20260602T120000000Z-add-report-activity-created-index.js'
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Kysely } from 'kysely'
|
|
2
|
-
import { Migration, MigrationProvider } from 'kysely/migration'
|
|
3
|
-
|
|
4
|
-
// Passes a context argument to migrations. We use this to thread the dialect into migrations
|
|
5
|
-
|
|
6
|
-
export class CtxMigrationProvider<T> implements MigrationProvider {
|
|
7
|
-
constructor(
|
|
8
|
-
private migrations: Record<string, CtxMigration<T>>,
|
|
9
|
-
private ctx: T,
|
|
10
|
-
) {}
|
|
11
|
-
async getMigrations(): Promise<Record<string, Migration>> {
|
|
12
|
-
const ctxMigrations: Record<string, Migration> = {}
|
|
13
|
-
Object.entries(this.migrations).forEach(([name, migration]) => {
|
|
14
|
-
ctxMigrations[name] = {
|
|
15
|
-
up: async (db) => await migration.up(db, this.ctx),
|
|
16
|
-
down: async (db) => await migration.down?.(db, this.ctx),
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
return ctxMigrations
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface CtxMigration<T> {
|
|
24
|
-
up(db: Kysely<unknown>, ctx: T): Promise<void>
|
|
25
|
-
down?(db: Kysely<unknown>, ctx: T): Promise<void>
|
|
26
|
-
}
|