@helyx/module-moderation 1.0.1
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 +41 -0
- package/LICENSE +725 -0
- package/README.md +107 -0
- package/dist/action-support.d.ts +48 -0
- package/dist/action-support.js +201 -0
- package/dist/case-actions.d.ts +9 -0
- package/dist/case-actions.js +311 -0
- package/dist/case-naming.d.ts +4 -0
- package/dist/case-naming.js +9 -0
- package/dist/case-repository.d.ts +29 -0
- package/dist/case-repository.js +199 -0
- package/dist/channel-actions.d.ts +3 -0
- package/dist/channel-actions.js +267 -0
- package/dist/commands.d.ts +4 -0
- package/dist/commands.js +309 -0
- package/dist/components.d.ts +15 -0
- package/dist/components.js +381 -0
- package/dist/configuration.d.ts +16 -0
- package/dist/configuration.js +94 -0
- package/dist/constants.d.ts +53 -0
- package/dist/constants.js +53 -0
- package/dist/contracts.d.ts +109 -0
- package/dist/contracts.js +84 -0
- package/dist/domain.d.ts +29 -0
- package/dist/domain.js +101 -0
- package/dist/events.d.ts +3 -0
- package/dist/events.js +60 -0
- package/dist/health.d.ts +10 -0
- package/dist/health.js +56 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +92 -0
- package/dist/moderation-cases-resource.d.ts +14 -0
- package/dist/moderation-cases-resource.js +226 -0
- package/dist/presentation.d.ts +8 -0
- package/dist/presentation.js +69 -0
- package/dist/privacy.d.ts +8 -0
- package/dist/privacy.js +38 -0
- package/dist/provider.d.ts +4 -0
- package/dist/provider.js +335 -0
- package/dist/receipt-repository.d.ts +9 -0
- package/dist/receipt-repository.js +36 -0
- package/dist/records.d.ts +399 -0
- package/dist/records.js +303 -0
- package/dist/repository-model.d.ts +131 -0
- package/dist/repository-model.js +318 -0
- package/dist/repository.d.ts +21 -0
- package/dist/repository.js +41 -0
- package/dist/service.d.ts +75 -0
- package/dist/service.js +329 -0
- package/dist/tasks.d.ts +49 -0
- package/dist/tasks.js +391 -0
- package/dist/thread-controls.d.ts +23 -0
- package/dist/thread-controls.js +376 -0
- package/dist/thread-deletion-recovery.d.ts +13 -0
- package/dist/thread-deletion-recovery.js +46 -0
- package/dist/thread-delivery.d.ts +11 -0
- package/dist/thread-delivery.js +427 -0
- package/dist/thread-reconciliation.d.ts +24 -0
- package/dist/thread-reconciliation.js +181 -0
- package/dist/thread-repository.d.ts +16 -0
- package/dist/thread-repository.js +70 -0
- package/manifest.json +999 -0
- package/migrations/0001_moderation_foundation.sql +552 -0
- package/migrations/0002_staff_attempt_parameters.sql +27 -0
- package/package.json +56 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
export const CASE_FIELDS = [
|
|
2
|
+
"case_id",
|
|
3
|
+
"guild_id",
|
|
4
|
+
"case_number",
|
|
5
|
+
"operation_key",
|
|
6
|
+
"subject_user_id",
|
|
7
|
+
"actor_user_id",
|
|
8
|
+
"source",
|
|
9
|
+
"source_module_id",
|
|
10
|
+
"source_event_id",
|
|
11
|
+
"action",
|
|
12
|
+
"reason",
|
|
13
|
+
"private_note",
|
|
14
|
+
"evidence_channel_id",
|
|
15
|
+
"evidence_message_id",
|
|
16
|
+
"related_case_id",
|
|
17
|
+
"requested_duration_seconds",
|
|
18
|
+
"delete_message_seconds",
|
|
19
|
+
"demote_role_ids",
|
|
20
|
+
"observed_action_type",
|
|
21
|
+
"observed_timeout_duration_seconds",
|
|
22
|
+
"repeat_rule_id",
|
|
23
|
+
"repeat_rule_revision",
|
|
24
|
+
"repeat_configuration_revision",
|
|
25
|
+
"repeat_policy_fingerprint",
|
|
26
|
+
"repeat_window_starts_at",
|
|
27
|
+
"repeat_offence_ordinal",
|
|
28
|
+
"repeat_offence_count",
|
|
29
|
+
"open_violation_thread",
|
|
30
|
+
"state",
|
|
31
|
+
"safe_outcome",
|
|
32
|
+
"revision",
|
|
33
|
+
"disassociated_at",
|
|
34
|
+
"settled_at",
|
|
35
|
+
"retention_expires_at",
|
|
36
|
+
"retention_processed_at",
|
|
37
|
+
"created_at",
|
|
38
|
+
"updated_at",
|
|
39
|
+
];
|
|
40
|
+
export const ATTEMPT_FIELDS = [
|
|
41
|
+
"attempt_id",
|
|
42
|
+
"guild_id",
|
|
43
|
+
"case_id",
|
|
44
|
+
"operation_key",
|
|
45
|
+
"actor_user_id",
|
|
46
|
+
"attempt_number",
|
|
47
|
+
"action",
|
|
48
|
+
"reason",
|
|
49
|
+
"outcome",
|
|
50
|
+
"safe_code",
|
|
51
|
+
"removed_role_ids",
|
|
52
|
+
"requested_duration_seconds",
|
|
53
|
+
"requested_demote_role_ids",
|
|
54
|
+
"created_at",
|
|
55
|
+
"updated_at",
|
|
56
|
+
];
|
|
57
|
+
export const DM_RECEIPT_FIELDS = [
|
|
58
|
+
"receipt_id",
|
|
59
|
+
"guild_id",
|
|
60
|
+
"case_id",
|
|
61
|
+
"template_revision",
|
|
62
|
+
"delivery_state",
|
|
63
|
+
"safe_code",
|
|
64
|
+
"message_id",
|
|
65
|
+
"attempted_at",
|
|
66
|
+
"created_at",
|
|
67
|
+
"updated_at",
|
|
68
|
+
];
|
|
69
|
+
export const THREAD_FIELDS = [
|
|
70
|
+
"delivery_id",
|
|
71
|
+
"guild_id",
|
|
72
|
+
"case_id",
|
|
73
|
+
"case_revision",
|
|
74
|
+
"operation_key",
|
|
75
|
+
"parent_channel_id",
|
|
76
|
+
"access_role_id",
|
|
77
|
+
"thread_id",
|
|
78
|
+
"control_token",
|
|
79
|
+
"control_message_id",
|
|
80
|
+
"member_state",
|
|
81
|
+
"evidence_state",
|
|
82
|
+
"opening_state",
|
|
83
|
+
"notification_state",
|
|
84
|
+
"close_state",
|
|
85
|
+
"resolution_state",
|
|
86
|
+
"attempt_count",
|
|
87
|
+
"fence_token",
|
|
88
|
+
"safe_code",
|
|
89
|
+
"retry_at",
|
|
90
|
+
"created_at",
|
|
91
|
+
"updated_at",
|
|
92
|
+
];
|
|
93
|
+
export function mapCase(row) {
|
|
94
|
+
return {
|
|
95
|
+
caseId: text(row, "case_id"),
|
|
96
|
+
guildId: text(row, "guild_id"),
|
|
97
|
+
caseNumber: number(row, "case_number"),
|
|
98
|
+
operationKey: text(row, "operation_key"),
|
|
99
|
+
subjectUserId: optionalText(row, "subject_user_id"),
|
|
100
|
+
actorUserId: optionalText(row, "actor_user_id"),
|
|
101
|
+
source: text(row, "source"),
|
|
102
|
+
sourceModuleId: text(row, "source_module_id"),
|
|
103
|
+
sourceEventId: optionalText(row, "source_event_id"),
|
|
104
|
+
action: text(row, "action"),
|
|
105
|
+
reason: text(row, "reason"),
|
|
106
|
+
privateNote: optionalText(row, "private_note"),
|
|
107
|
+
evidenceChannelId: optionalText(row, "evidence_channel_id"),
|
|
108
|
+
evidenceMessageId: optionalText(row, "evidence_message_id"),
|
|
109
|
+
relatedCaseId: optionalText(row, "related_case_id"),
|
|
110
|
+
requestedDurationSeconds: optionalNumber(row, "requested_duration_seconds"),
|
|
111
|
+
deleteMessageSeconds: optionalNumber(row, "delete_message_seconds"),
|
|
112
|
+
demoteRoleIds: jsonStrings(row, "demote_role_ids"),
|
|
113
|
+
observedActionType: optionalText(row, "observed_action_type"),
|
|
114
|
+
observedTimeoutDurationSeconds: optionalNumber(row, "observed_timeout_duration_seconds"),
|
|
115
|
+
repeatRuleId: optionalText(row, "repeat_rule_id"),
|
|
116
|
+
repeatRuleRevision: optionalNumber(row, "repeat_rule_revision"),
|
|
117
|
+
repeatConfigurationRevision: optionalText(row, "repeat_configuration_revision"),
|
|
118
|
+
repeatPolicyFingerprint: optionalText(row, "repeat_policy_fingerprint"),
|
|
119
|
+
repeatWindowStartsAt: optionalDate(row, "repeat_window_starts_at"),
|
|
120
|
+
repeatOffenceOrdinal: optionalNumber(row, "repeat_offence_ordinal"),
|
|
121
|
+
repeatOffenceCount: optionalNumber(row, "repeat_offence_count"),
|
|
122
|
+
openViolationThread: boolean(row, "open_violation_thread"),
|
|
123
|
+
state: text(row, "state"),
|
|
124
|
+
safeOutcome: optionalText(row, "safe_outcome"),
|
|
125
|
+
revision: number(row, "revision"),
|
|
126
|
+
disassociatedAt: optionalDate(row, "disassociated_at"),
|
|
127
|
+
settledAt: optionalDate(row, "settled_at"),
|
|
128
|
+
retentionExpiresAt: optionalDate(row, "retention_expires_at"),
|
|
129
|
+
retentionProcessedAt: optionalDate(row, "retention_processed_at"),
|
|
130
|
+
createdAt: date(row, "created_at"),
|
|
131
|
+
updatedAt: date(row, "updated_at"),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export function mapAttempt(row) {
|
|
135
|
+
return {
|
|
136
|
+
attemptId: text(row, "attempt_id"),
|
|
137
|
+
guildId: text(row, "guild_id"),
|
|
138
|
+
caseId: text(row, "case_id"),
|
|
139
|
+
operationKey: text(row, "operation_key"),
|
|
140
|
+
actorUserId: optionalText(row, "actor_user_id"),
|
|
141
|
+
attemptNumber: number(row, "attempt_number"),
|
|
142
|
+
action: text(row, "action"),
|
|
143
|
+
reason: text(row, "reason"),
|
|
144
|
+
outcome: text(row, "outcome"),
|
|
145
|
+
safeCode: optionalText(row, "safe_code"),
|
|
146
|
+
removedRoleIds: jsonStrings(row, "removed_role_ids"),
|
|
147
|
+
requestedDurationSeconds: optionalNumber(row, "requested_duration_seconds"),
|
|
148
|
+
demoteRoleIds: jsonStrings(row, "requested_demote_role_ids"),
|
|
149
|
+
createdAt: date(row, "created_at"),
|
|
150
|
+
updatedAt: date(row, "updated_at"),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
export function mapDmReceipt(row) {
|
|
154
|
+
return {
|
|
155
|
+
receiptId: text(row, "receipt_id"),
|
|
156
|
+
guildId: text(row, "guild_id"),
|
|
157
|
+
caseId: text(row, "case_id"),
|
|
158
|
+
templateRevision: number(row, "template_revision"),
|
|
159
|
+
deliveryState: text(row, "delivery_state"),
|
|
160
|
+
safeCode: optionalText(row, "safe_code"),
|
|
161
|
+
messageId: optionalText(row, "message_id"),
|
|
162
|
+
attemptedAt: optionalDate(row, "attempted_at"),
|
|
163
|
+
createdAt: date(row, "created_at"),
|
|
164
|
+
updatedAt: date(row, "updated_at"),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
export function mapThreadDelivery(row) {
|
|
168
|
+
return {
|
|
169
|
+
deliveryId: text(row, "delivery_id"),
|
|
170
|
+
guildId: text(row, "guild_id"),
|
|
171
|
+
caseId: text(row, "case_id"),
|
|
172
|
+
caseRevision: number(row, "case_revision"),
|
|
173
|
+
operationKey: text(row, "operation_key"),
|
|
174
|
+
parentChannelId: optionalText(row, "parent_channel_id"),
|
|
175
|
+
accessRoleId: optionalText(row, "access_role_id"),
|
|
176
|
+
threadId: optionalText(row, "thread_id"),
|
|
177
|
+
controlToken: optionalText(row, "control_token"),
|
|
178
|
+
controlMessageId: optionalText(row, "control_message_id"),
|
|
179
|
+
memberState: text(row, "member_state"),
|
|
180
|
+
evidenceState: text(row, "evidence_state"),
|
|
181
|
+
openingState: text(row, "opening_state"),
|
|
182
|
+
notificationState: text(row, "notification_state"),
|
|
183
|
+
closeState: text(row, "close_state"),
|
|
184
|
+
resolutionState: text(row, "resolution_state"),
|
|
185
|
+
attemptCount: number(row, "attempt_count"),
|
|
186
|
+
fenceToken: number(row, "fence_token"),
|
|
187
|
+
safeCode: optionalText(row, "safe_code"),
|
|
188
|
+
retryAt: optionalDate(row, "retry_at"),
|
|
189
|
+
createdAt: date(row, "created_at"),
|
|
190
|
+
updatedAt: date(row, "updated_at"),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
export function dmReceiptWrite(input) {
|
|
194
|
+
return compact({
|
|
195
|
+
receipt_id: input.receiptId,
|
|
196
|
+
guild_id: input.guildId,
|
|
197
|
+
case_id: input.caseId,
|
|
198
|
+
template_revision: input.templateRevision,
|
|
199
|
+
delivery_state: input.deliveryState,
|
|
200
|
+
safe_code: input.safeCode,
|
|
201
|
+
message_id: input.messageId,
|
|
202
|
+
attempted_at: input.attemptedAt,
|
|
203
|
+
created_at: input.createdAt,
|
|
204
|
+
updated_at: input.updatedAt,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
export function threadDeliveryWrite(input) {
|
|
208
|
+
return compact({
|
|
209
|
+
delivery_id: input.deliveryId,
|
|
210
|
+
guild_id: input.guildId,
|
|
211
|
+
case_id: input.caseId,
|
|
212
|
+
case_revision: input.caseRevision,
|
|
213
|
+
operation_key: input.operationKey,
|
|
214
|
+
parent_channel_id: input.parentChannelId,
|
|
215
|
+
access_role_id: input.accessRoleId,
|
|
216
|
+
thread_id: input.threadId,
|
|
217
|
+
control_token: input.controlToken,
|
|
218
|
+
control_message_id: input.controlMessageId,
|
|
219
|
+
member_state: input.memberState,
|
|
220
|
+
evidence_state: input.evidenceState,
|
|
221
|
+
opening_state: input.openingState,
|
|
222
|
+
notification_state: input.notificationState,
|
|
223
|
+
close_state: input.closeState,
|
|
224
|
+
resolution_state: input.resolutionState,
|
|
225
|
+
attempt_count: input.attemptCount,
|
|
226
|
+
fence_token: input.fenceToken,
|
|
227
|
+
safe_code: input.safeCode,
|
|
228
|
+
retry_at: input.retryAt,
|
|
229
|
+
created_at: input.createdAt,
|
|
230
|
+
updated_at: input.updatedAt,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
export const THREAD_PROPERTY_FIELDS = {
|
|
234
|
+
caseRevision: "case_revision",
|
|
235
|
+
operationKey: "operation_key",
|
|
236
|
+
parentChannelId: "parent_channel_id",
|
|
237
|
+
accessRoleId: "access_role_id",
|
|
238
|
+
threadId: "thread_id",
|
|
239
|
+
controlToken: "control_token",
|
|
240
|
+
controlMessageId: "control_message_id",
|
|
241
|
+
memberState: "member_state",
|
|
242
|
+
evidenceState: "evidence_state",
|
|
243
|
+
openingState: "opening_state",
|
|
244
|
+
notificationState: "notification_state",
|
|
245
|
+
closeState: "close_state",
|
|
246
|
+
resolutionState: "resolution_state",
|
|
247
|
+
attemptCount: "attempt_count",
|
|
248
|
+
fenceToken: "fence_token",
|
|
249
|
+
safeCode: "safe_code",
|
|
250
|
+
retryAt: "retry_at",
|
|
251
|
+
updatedAt: "updated_at",
|
|
252
|
+
};
|
|
253
|
+
function compact(input) {
|
|
254
|
+
const values = {};
|
|
255
|
+
const clear = [];
|
|
256
|
+
for (const [key, value] of Object.entries(input)) {
|
|
257
|
+
if (value === null)
|
|
258
|
+
clear.push(key);
|
|
259
|
+
else
|
|
260
|
+
values[key] = value;
|
|
261
|
+
}
|
|
262
|
+
return { values, clear };
|
|
263
|
+
}
|
|
264
|
+
function text(row, key) {
|
|
265
|
+
const value = row[key];
|
|
266
|
+
if (typeof value !== "string")
|
|
267
|
+
throw new Error(`Invalid ${key} record value.`);
|
|
268
|
+
return value;
|
|
269
|
+
}
|
|
270
|
+
function optionalText(row, key) {
|
|
271
|
+
const value = row[key];
|
|
272
|
+
if (value === null || value === undefined)
|
|
273
|
+
return null;
|
|
274
|
+
if (typeof value !== "string")
|
|
275
|
+
throw new Error(`Invalid ${key} record value.`);
|
|
276
|
+
return value;
|
|
277
|
+
}
|
|
278
|
+
function number(row, key) {
|
|
279
|
+
const value = row[key];
|
|
280
|
+
if (typeof value !== "number")
|
|
281
|
+
throw new Error(`Invalid ${key} record value.`);
|
|
282
|
+
return value;
|
|
283
|
+
}
|
|
284
|
+
function optionalNumber(row, key) {
|
|
285
|
+
const value = row[key];
|
|
286
|
+
if (value === null || value === undefined)
|
|
287
|
+
return null;
|
|
288
|
+
if (typeof value !== "number")
|
|
289
|
+
throw new Error(`Invalid ${key} record value.`);
|
|
290
|
+
return value;
|
|
291
|
+
}
|
|
292
|
+
function boolean(row, key) {
|
|
293
|
+
const value = row[key];
|
|
294
|
+
if (typeof value !== "boolean")
|
|
295
|
+
throw new Error(`Invalid ${key} record value.`);
|
|
296
|
+
return value;
|
|
297
|
+
}
|
|
298
|
+
function date(row, key) {
|
|
299
|
+
const value = row[key];
|
|
300
|
+
if (!(value instanceof Date))
|
|
301
|
+
throw new Error(`Invalid ${key} record value.`);
|
|
302
|
+
return value;
|
|
303
|
+
}
|
|
304
|
+
function optionalDate(row, key) {
|
|
305
|
+
const value = row[key];
|
|
306
|
+
if (value === null || value === undefined)
|
|
307
|
+
return null;
|
|
308
|
+
if (!(value instanceof Date))
|
|
309
|
+
throw new Error(`Invalid ${key} record value.`);
|
|
310
|
+
return value;
|
|
311
|
+
}
|
|
312
|
+
function jsonStrings(row, key) {
|
|
313
|
+
const value = JSON.parse(text(row, key));
|
|
314
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string"))
|
|
315
|
+
throw new Error(`Invalid ${key} record value.`);
|
|
316
|
+
return value;
|
|
317
|
+
}
|
|
318
|
+
//# sourceMappingURL=repository-model.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ModuleRecordService, type ServiceAccess } from "@helyx/sdk";
|
|
2
|
+
import { ModerationCaseRepository } from "./case-repository.js";
|
|
3
|
+
import { ModerationReceiptRepository } from "./receipt-repository.js";
|
|
4
|
+
import { ModerationThreadRepository } from "./thread-repository.js";
|
|
5
|
+
export type { ModerationCasePage, ModerationCaseQuery, } from "./case-repository.js";
|
|
6
|
+
export type { StoredModerationAttempt, StoredModerationCase, StoredModerationDmReceipt, StoredModerationThreadDelivery, } from "./repository-model.js";
|
|
7
|
+
export declare class ModerationRepository {
|
|
8
|
+
readonly findCase: ModerationCaseRepository["findCase"];
|
|
9
|
+
readonly findCaseByNumber: ModerationCaseRepository["findCaseByNumber"];
|
|
10
|
+
readonly listCases: ModerationCaseRepository["listCases"];
|
|
11
|
+
readonly listAttempts: ModerationCaseRepository["listAttempts"];
|
|
12
|
+
readonly findDmReceipt: ModerationReceiptRepository["findDmReceipt"];
|
|
13
|
+
readonly upsertDmReceipt: ModerationReceiptRepository["upsertDmReceipt"];
|
|
14
|
+
readonly findThreadDelivery: ModerationThreadRepository["findThreadDelivery"];
|
|
15
|
+
readonly findThreadDeliveryByControlToken: ModerationThreadRepository["findThreadDeliveryByControlToken"];
|
|
16
|
+
readonly upsertThreadDelivery: ModerationThreadRepository["upsertThreadDelivery"];
|
|
17
|
+
readonly createThreadDelivery: ModerationThreadRepository["createThreadDelivery"];
|
|
18
|
+
readonly updateThreadDelivery: ModerationThreadRepository["updateThreadDelivery"];
|
|
19
|
+
constructor(services: ServiceAccess | ModuleRecordService);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=repository.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { HELYX_SERVICE_NAMES, } from "@helyx/sdk";
|
|
2
|
+
import { ModerationCaseRepository } from "./case-repository.js";
|
|
3
|
+
import { ModerationReceiptRepository } from "./receipt-repository.js";
|
|
4
|
+
import { ModerationThreadRepository } from "./thread-repository.js";
|
|
5
|
+
export class ModerationRepository {
|
|
6
|
+
findCase;
|
|
7
|
+
findCaseByNumber;
|
|
8
|
+
listCases;
|
|
9
|
+
listAttempts;
|
|
10
|
+
findDmReceipt;
|
|
11
|
+
upsertDmReceipt;
|
|
12
|
+
findThreadDelivery;
|
|
13
|
+
findThreadDeliveryByControlToken;
|
|
14
|
+
upsertThreadDelivery;
|
|
15
|
+
createThreadDelivery;
|
|
16
|
+
updateThreadDelivery;
|
|
17
|
+
constructor(services) {
|
|
18
|
+
const records = isServiceAccess(services)
|
|
19
|
+
? services.get(HELYX_SERVICE_NAMES.records)
|
|
20
|
+
: services;
|
|
21
|
+
const cases = new ModerationCaseRepository(records);
|
|
22
|
+
const receipts = new ModerationReceiptRepository(records);
|
|
23
|
+
const threads = new ModerationThreadRepository(records);
|
|
24
|
+
this.findCase = cases.findCase.bind(cases);
|
|
25
|
+
this.findCaseByNumber = cases.findCaseByNumber.bind(cases);
|
|
26
|
+
this.listCases = cases.listCases.bind(cases);
|
|
27
|
+
this.listAttempts = cases.listAttempts.bind(cases);
|
|
28
|
+
this.findDmReceipt = receipts.findDmReceipt.bind(receipts);
|
|
29
|
+
this.upsertDmReceipt = receipts.upsertDmReceipt.bind(receipts);
|
|
30
|
+
this.findThreadDelivery = threads.findThreadDelivery.bind(threads);
|
|
31
|
+
this.findThreadDeliveryByControlToken =
|
|
32
|
+
threads.findThreadDeliveryByControlToken.bind(threads);
|
|
33
|
+
this.upsertThreadDelivery = threads.upsertThreadDelivery.bind(threads);
|
|
34
|
+
this.createThreadDelivery = threads.createThreadDelivery.bind(threads);
|
|
35
|
+
this.updateThreadDelivery = threads.updateThreadDelivery.bind(threads);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function isServiceAccess(value) {
|
|
39
|
+
return "get" in value && typeof value.get === "function";
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=repository.js.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type ModerationActionAttemptTerminalOutcome, type ModerationActionProviderContext, type ModerationBanDeleteMessageSeconds, type ModerationEnforcementAction, type PermissionActor, type ScheduledTaskExecutionResult, type ServiceAccess } from "@helyx/sdk";
|
|
2
|
+
import type { ModerationCaseAction, ModerationCommandId } from "./contracts.js";
|
|
3
|
+
export interface ModerationStaffDraft {
|
|
4
|
+
operationKey: string;
|
|
5
|
+
guildId: string;
|
|
6
|
+
actor: PermissionActor;
|
|
7
|
+
permissionId: ModerationCommandId;
|
|
8
|
+
action: Exclude<ModerationCaseAction, "delete_message" | "case_only">;
|
|
9
|
+
subjectUserId: string;
|
|
10
|
+
subjectDisplayName: string;
|
|
11
|
+
reason: string;
|
|
12
|
+
privateNote?: string;
|
|
13
|
+
evidenceMessage?: {
|
|
14
|
+
channelId: string;
|
|
15
|
+
messageId: string;
|
|
16
|
+
};
|
|
17
|
+
requestedDurationSeconds?: number;
|
|
18
|
+
deleteMessageSeconds?: ModerationBanDeleteMessageSeconds;
|
|
19
|
+
demoteRoleIds?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
export interface ModerationExecutionSummary {
|
|
22
|
+
outcome: "applied" | "review_required" | "failed" | "rejected";
|
|
23
|
+
caseId?: string;
|
|
24
|
+
caseNumber?: number;
|
|
25
|
+
revision?: number;
|
|
26
|
+
safeCode: string;
|
|
27
|
+
}
|
|
28
|
+
export type ModerationDispatchAction = ModerationEnforcementAction | {
|
|
29
|
+
type: "timeout";
|
|
30
|
+
durationSeconds: number;
|
|
31
|
+
} | {
|
|
32
|
+
type: "timeout_remove";
|
|
33
|
+
} | {
|
|
34
|
+
type: "unban";
|
|
35
|
+
};
|
|
36
|
+
export interface ModerationThreadRuntime {
|
|
37
|
+
deliver(input: {
|
|
38
|
+
services: ServiceAccess;
|
|
39
|
+
guildId: string;
|
|
40
|
+
caseId: string;
|
|
41
|
+
caseNumber: number;
|
|
42
|
+
caseRevision: number;
|
|
43
|
+
subjectUserId: string;
|
|
44
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
45
|
+
operationKey: string;
|
|
46
|
+
evidence?: ModerationActionProviderContext["violationEvidence"];
|
|
47
|
+
}): Promise<"not_requested" | "created" | "already_exists" | "retry_pending" | "review_required">;
|
|
48
|
+
reconcileAccess(services: ServiceAccess, guildId: string): Promise<ScheduledTaskExecutionResult>;
|
|
49
|
+
}
|
|
50
|
+
export declare class ModerationService {
|
|
51
|
+
#private;
|
|
52
|
+
attachThreadRuntime(runtime: ModerationThreadRuntime): void;
|
|
53
|
+
canExecuteStaffAction(services: ServiceAccess, draft: ModerationStaffDraft): Promise<boolean>;
|
|
54
|
+
executeStaffAction(services: ServiceAccess, draft: ModerationStaffDraft): Promise<ModerationExecutionSummary>;
|
|
55
|
+
dispatchAction(services: ServiceAccess, input: {
|
|
56
|
+
guildId: string;
|
|
57
|
+
subjectUserId: string;
|
|
58
|
+
actorUserId?: string;
|
|
59
|
+
action: ModerationDispatchAction;
|
|
60
|
+
reason: string;
|
|
61
|
+
operationKey: string;
|
|
62
|
+
sourceMessage?: {
|
|
63
|
+
channelId: string;
|
|
64
|
+
messageId: string | null;
|
|
65
|
+
} | null;
|
|
66
|
+
protectedRoleIds: readonly string[];
|
|
67
|
+
revalidate(): Promise<boolean>;
|
|
68
|
+
}): Promise<{
|
|
69
|
+
outcome: ModerationActionAttemptTerminalOutcome;
|
|
70
|
+
safeCode?: string;
|
|
71
|
+
removedRoleIds?: readonly string[];
|
|
72
|
+
}>;
|
|
73
|
+
deliverViolationThread(input: Parameters<ModerationThreadRuntime["deliver"]>[0]): Promise<"not_requested" | "created" | "already_exists" | "retry_pending" | "review_required">;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=service.d.ts.map
|