@chatwarden/core 0.1.1 → 0.1.2
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/README.md +128 -4
- package/dist/src/audit.d.ts +27 -5
- package/dist/src/audit.d.ts.map +1 -1
- package/dist/src/audit.js +57 -6
- package/dist/src/audit.js.map +1 -1
- package/dist/src/chatwarden.d.ts +183 -11
- package/dist/src/chatwarden.d.ts.map +1 -1
- package/dist/src/chatwarden.js +65 -10
- package/dist/src/chatwarden.js.map +1 -1
- package/dist/src/documents.d.ts +12 -2
- package/dist/src/documents.d.ts.map +1 -1
- package/dist/src/documents.js +56 -34
- package/dist/src/documents.js.map +1 -1
- package/dist/src/events.d.ts +3 -0
- package/dist/src/events.d.ts.map +1 -1
- package/dist/src/events.js.map +1 -1
- package/dist/src/index.d.ts +20 -11
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +11 -6
- package/dist/src/index.js.map +1 -1
- package/dist/src/ladder.d.ts +2 -0
- package/dist/src/ladder.d.ts.map +1 -1
- package/dist/src/ladder.js +1 -1
- package/dist/src/ladder.js.map +1 -1
- package/dist/src/policy.d.ts +129 -0
- package/dist/src/policy.d.ts.map +1 -0
- package/dist/src/policy.js +242 -0
- package/dist/src/policy.js.map +1 -0
- package/dist/src/profile.d.ts +120 -7
- package/dist/src/profile.d.ts.map +1 -1
- package/dist/src/profile.js +295 -7
- package/dist/src/profile.js.map +1 -1
- package/dist/src/reporting.d.ts +127 -0
- package/dist/src/reporting.d.ts.map +1 -0
- package/dist/src/reporting.js +172 -0
- package/dist/src/reporting.js.map +1 -0
- package/dist/src/reports.d.ts +80 -4
- package/dist/src/reports.d.ts.map +1 -1
- package/dist/src/reports.js +120 -6
- package/dist/src/reports.js.map +1 -1
- package/dist/src/staffReports.d.ts +17 -5
- package/dist/src/staffReports.d.ts.map +1 -1
- package/dist/src/staffReports.js +22 -5
- package/dist/src/staffReports.js.map +1 -1
- package/dist/src/staffViews.d.ts +138 -0
- package/dist/src/staffViews.d.ts.map +1 -0
- package/dist/src/staffViews.js +205 -0
- package/dist/src/staffViews.js.map +1 -0
- package/dist/src/team.d.ts +149 -0
- package/dist/src/team.d.ts.map +1 -0
- package/dist/src/team.js +385 -0
- package/dist/src/team.js.map +1 -0
- package/dist/src/types.d.ts +245 -4
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +5 -0
- package/dist/src/types.js.map +1 -1
- package/package.json +2 -2
- package/src/audit.ts +71 -7
- package/src/chatwarden.ts +245 -20
- package/src/documents.ts +70 -43
- package/src/events.ts +10 -1
- package/src/index.ts +109 -4
- package/src/ladder.ts +1 -1
- package/src/policy.ts +288 -0
- package/src/profile.ts +369 -14
- package/src/reporting.ts +251 -0
- package/src/reports.ts +163 -10
- package/src/staffReports.ts +33 -7
- package/src/staffViews.ts +325 -0
- package/src/team.ts +422 -0
- package/src/types.ts +257 -4
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { ReportCategory } from './types.js';
|
|
2
|
+
/** How the player's reporting screen works. The kit treats `one_tap` and `reason_first` the same; only `reason_required` refuses. */
|
|
3
|
+
export type ReportFlow = 'one_tap' | 'reason_first' | 'reason_required';
|
|
4
|
+
/** Every flow, in the order a settings screen lists them. */
|
|
5
|
+
export declare const REPORT_FLOWS: readonly ReportFlow[];
|
|
6
|
+
/** The default flow: "Report this message" sends at once; a reason is offered afterwards and is optional. */
|
|
7
|
+
export declare const DEFAULT_REPORT_FLOW: ReportFlow;
|
|
8
|
+
/** The default thank-you shown to the reporter. */
|
|
9
|
+
export declare const DEFAULT_REPORT_THANKS = "Thanks for the report. We'll look into it.";
|
|
10
|
+
/** The most reasons a profile may list. */
|
|
11
|
+
export declare const MAX_REPORT_REASONS = 20;
|
|
12
|
+
/** The longest reason id, label, hint, group and thank-you, in characters. */
|
|
13
|
+
export declare const REPORT_ID_MAX = 32;
|
|
14
|
+
export declare const REPORT_LABEL_MAX = 60;
|
|
15
|
+
export declare const REPORT_HINT_MAX = 160;
|
|
16
|
+
export declare const REPORT_GROUP_MAX = 40;
|
|
17
|
+
export declare const REPORT_THANKS_MAX = 300;
|
|
18
|
+
/** The most Community Rule numbers one reason may map to. */
|
|
19
|
+
export declare const MAX_REASON_RULES = 20;
|
|
20
|
+
/** True for a well-formed reason id: a lowercase slug of letters, digits, `_` and `-` (at most 32 characters), and not `none`. */
|
|
21
|
+
export declare function isReasonId(v: unknown): v is string;
|
|
22
|
+
/** The id of the reason that can never be removed or switched off: the fallback and what an old `other` category reads as. */
|
|
23
|
+
export declare const OTHER_REASON_ID = "other";
|
|
24
|
+
/**
|
|
25
|
+
* One reason as you write it. `id` (a lowercase slug, unique) and `label` are required; the rest default to
|
|
26
|
+
* `hint: ''`, `group: ''` (no group), `rules: []`, `asksNote: false` and `enabled: true`.
|
|
27
|
+
*/
|
|
28
|
+
export interface ReportReasonInput {
|
|
29
|
+
/** A unique lowercase slug of letters, digits, `_` and `-` (at most 32 characters). `none` is reserved. */
|
|
30
|
+
id: string;
|
|
31
|
+
/** What the player sees (at most 60 characters). */
|
|
32
|
+
label: string;
|
|
33
|
+
/** One line under the label (at most 160 characters). */
|
|
34
|
+
hint?: string;
|
|
35
|
+
/** The heading the reason is listed under, for example `Chat` or `Gameplay`; `''` lists it with no heading (at most 40 characters). */
|
|
36
|
+
group?: string;
|
|
37
|
+
/** The Community Rule numbers this reason usually means. The first one is the moderator's suggested rule; a decision under any of them counts as "matched" for the reporter. */
|
|
38
|
+
rules?: number[];
|
|
39
|
+
/** Ask the player for a short note when they pick it. */
|
|
40
|
+
asksNote?: boolean;
|
|
41
|
+
/** Offered to players. A switched-off reason stays valid for reports already filed. */
|
|
42
|
+
enabled?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** One reason with every field filled in. */
|
|
45
|
+
export interface ReportReason {
|
|
46
|
+
id: string;
|
|
47
|
+
label: string;
|
|
48
|
+
hint: string;
|
|
49
|
+
group: string;
|
|
50
|
+
rules: number[];
|
|
51
|
+
asksNote: boolean;
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
}
|
|
54
|
+
/** The reporting settings as you write them: every field is optional and defaulted. */
|
|
55
|
+
export interface ReportingSettings {
|
|
56
|
+
/** Default `'one_tap'`. */
|
|
57
|
+
flow?: ReportFlow;
|
|
58
|
+
/** The whole ordered list (a layer or an override replaces it, never merges). Default {@link DEFAULT_REPORT_REASONS}. 1 to 20 reasons, at least one enabled, and `other` present and enabled. */
|
|
59
|
+
reasons?: ReportReasonInput[];
|
|
60
|
+
/** What the reporter is told after sending a report (at most 300 characters). Default {@link DEFAULT_REPORT_THANKS}. */
|
|
61
|
+
thanks?: string;
|
|
62
|
+
}
|
|
63
|
+
/** The reporting settings in force: every field filled in. */
|
|
64
|
+
export interface ResolvedReporting {
|
|
65
|
+
flow: ReportFlow;
|
|
66
|
+
reasons: ReportReason[];
|
|
67
|
+
thanks: string;
|
|
68
|
+
}
|
|
69
|
+
/** What a player's client may read: the enabled reasons and nothing of the staff side (no rule mapping). */
|
|
70
|
+
export interface PlayerReporting {
|
|
71
|
+
flow: ReportFlow;
|
|
72
|
+
reasons: Array<{
|
|
73
|
+
id: string;
|
|
74
|
+
label: string;
|
|
75
|
+
hint: string;
|
|
76
|
+
group: string;
|
|
77
|
+
asksNote: boolean;
|
|
78
|
+
}>;
|
|
79
|
+
thanks: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The default reasons, deep-frozen: Chat (insults or harassment, hate, sexual content, threats, spam or ads, sharing personal
|
|
83
|
+
* info), Gameplay (cheating, throwing or griefing, leaving or AFK), then Something else. Each maps to the starter Community
|
|
84
|
+
* Rules it usually means: harassment, threats and personal info to CR 2, hate to CR 1, sexual content to CR 3, spam to CR 4,
|
|
85
|
+
* cheating to CR 5, griefing and AFK to CR 6. `other` maps to none.
|
|
86
|
+
*/
|
|
87
|
+
export declare const DEFAULT_REPORT_REASONS: readonly Readonly<ReportReason>[];
|
|
88
|
+
/** A fresh, unfrozen copy of the default reporting settings. */
|
|
89
|
+
export declare function defaultReporting(): ResolvedReporting;
|
|
90
|
+
/**
|
|
91
|
+
* Old ids that read as a new one. `disruption` (the 0.1.1 category) is `griefing`. An exact id in the list always wins, so a
|
|
92
|
+
* studio that defines its own `disruption` reason keeps it.
|
|
93
|
+
*/
|
|
94
|
+
export declare const LEGACY_REASON_ALIASES: Readonly<Record<string, string>>;
|
|
95
|
+
/** The six 0.1.1 categories. They stay valid reason ids (through {@link LEGACY_REASON_ALIASES} for `disruption`). */
|
|
96
|
+
export declare const LEGACY_CATEGORIES: readonly ReportCategory[];
|
|
97
|
+
/** The reason in `reasons` that `id` names (exactly, else as an old alias), or undefined. Disabled reasons are found too. */
|
|
98
|
+
export declare function findReason(reasons: readonly ReportReason[], id: string): ReportReason | undefined;
|
|
99
|
+
/** The id `id` stands for in `reasons` (`disruption` becomes `griefing` unless the list has its own), or `id` itself when it is in no list. */
|
|
100
|
+
export declare function canonicalReasonId(reasons: readonly ReportReason[], id: string): string;
|
|
101
|
+
/** The player-facing label of a reason id (an old alias included), or null when there is no such reason. */
|
|
102
|
+
export declare function reasonLabel(reasons: readonly ReportReason[], id: string | null): string | null;
|
|
103
|
+
/**
|
|
104
|
+
* The 0.1.1 category a reason id is kept under in the stored report's `category` column (which old consumers still read): the
|
|
105
|
+
* six old ids are themselves, `griefing` and `afk` are `disruption`, `threat` is `harassment`, and everything else (no reason,
|
|
106
|
+
* `sexual`, `personal_info`, a studio's own) is `other`.
|
|
107
|
+
*/
|
|
108
|
+
export declare function legacyCategoryOf(id: string | null): ReportCategory;
|
|
109
|
+
/** The reason id a stored 0.1.1 category reads as: `disruption` is `griefing`, the others are themselves. */
|
|
110
|
+
export declare function reasonOfCategory(category: string): string;
|
|
111
|
+
/**
|
|
112
|
+
* The Community Rule a moderator is suggested for a reported reason: the first of the reason's rules that is still citable, or
|
|
113
|
+
* `'uncovered'` (no reason, an unknown reason, a reason with no rules). The report is never decided by it.
|
|
114
|
+
*/
|
|
115
|
+
export declare function suggestedRule(reasons: readonly ReportReason[], id: string | null, rules: {
|
|
116
|
+
isCitable(ref: number): boolean;
|
|
117
|
+
}): number | 'uncovered';
|
|
118
|
+
/** What a player may read: the enabled reasons in order, with no rule mapping. Each field is copied by name, so nothing added later leaks. */
|
|
119
|
+
export declare function playerReporting(reporting: ResolvedReporting): PlayerReporting;
|
|
120
|
+
/**
|
|
121
|
+
* Fill the optional parts of reporting settings: a missing flow, thank-you, reason list or reason field gets its default. It never
|
|
122
|
+
* throws and never judges: anything of the wrong shape is returned as it is, for the profile validator to name. Copies.
|
|
123
|
+
*/
|
|
124
|
+
export declare function fillReporting(value: unknown): unknown;
|
|
125
|
+
/** {@link fillReporting} for settings already known to be valid: the typed result. */
|
|
126
|
+
export declare function resolveReporting(settings: ReportingSettings | undefined): ResolvedReporting;
|
|
127
|
+
//# sourceMappingURL=reporting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporting.d.ts","sourceRoot":"","sources":["../../src/reporting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AASjD,qIAAqI;AACrI,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,cAAc,GAAG,iBAAiB,CAAC;AAExE,6DAA6D;AAC7D,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAAmD,CAAC;AAElG,6GAA6G;AAC7G,eAAO,MAAM,mBAAmB,EAAE,UAAsB,CAAC;AAEzD,mDAAmD;AACnD,eAAO,MAAM,qBAAqB,+CAA+C,CAAC;AAElF,2CAA2C;AAC3C,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,8EAA8E;AAC9E,eAAO,MAAM,aAAa,KAAK,CAAC;AAChC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,iBAAiB,MAAM,CAAC;A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ChC,EAAE,EAAE,MAAM,GAAG,IAAI,EACjB,KAAK,EAAE;IAAE,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GACzC,MAAM,GAAG,WAAW,CAKtB;AAED,8IAA8I;AAC9I,wBAAgB,eAAe,CAAC,SAAS,EAAE,iBAAiB,GAAG,eAAe,CAQ7E;AAID;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAqBrD;AAED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,SAAS,GAAG,iBAAiB,CAE3F"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/** Every flow, in the order a settings screen lists them. */
|
|
2
|
+
export const REPORT_FLOWS = ['one_tap', 'reason_first', 'reason_required'];
|
|
3
|
+
/** The default flow: "Report this message" sends at once; a reason is offered afterwards and is optional. */
|
|
4
|
+
export const DEFAULT_REPORT_FLOW = 'one_tap';
|
|
5
|
+
/** The default thank-you shown to the reporter. */
|
|
6
|
+
export const DEFAULT_REPORT_THANKS = "Thanks for the report. We'll look into it.";
|
|
7
|
+
/** The most reasons a profile may list. */
|
|
8
|
+
export const MAX_REPORT_REASONS = 20;
|
|
9
|
+
/** The longest reason id, label, hint, group and thank-you, in characters. */
|
|
10
|
+
export const REPORT_ID_MAX = 32;
|
|
11
|
+
export const REPORT_LABEL_MAX = 60;
|
|
12
|
+
export const REPORT_HINT_MAX = 160;
|
|
13
|
+
export const REPORT_GROUP_MAX = 40;
|
|
14
|
+
export const REPORT_THANKS_MAX = 300;
|
|
15
|
+
/** The most Community Rule numbers one reason may map to. */
|
|
16
|
+
export const MAX_REASON_RULES = 20;
|
|
17
|
+
/** True for a well-formed reason id: a lowercase slug of letters, digits, `_` and `-` (at most 32 characters), and not `none`. */
|
|
18
|
+
export function isReasonId(v) {
|
|
19
|
+
return typeof v === 'string' && v.length <= REPORT_ID_MAX && /^[a-z0-9]+(?:[_-][a-z0-9]+)*$/.test(v) && v !== 'none';
|
|
20
|
+
}
|
|
21
|
+
/** The id of the reason that can never be removed or switched off: the fallback and what an old `other` category reads as. */
|
|
22
|
+
export const OTHER_REASON_ID = 'other';
|
|
23
|
+
const reason = (id, label, hint, group, rules, asksNote = false) => ({
|
|
24
|
+
id,
|
|
25
|
+
label,
|
|
26
|
+
hint,
|
|
27
|
+
group,
|
|
28
|
+
rules,
|
|
29
|
+
asksNote,
|
|
30
|
+
enabled: true,
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* The default reasons, deep-frozen: Chat (insults or harassment, hate, sexual content, threats, spam or ads, sharing personal
|
|
34
|
+
* info), Gameplay (cheating, throwing or griefing, leaving or AFK), then Something else. Each maps to the starter Community
|
|
35
|
+
* Rules it usually means: harassment, threats and personal info to CR 2, hate to CR 1, sexual content to CR 3, spam to CR 4,
|
|
36
|
+
* cheating to CR 5, griefing and AFK to CR 6. `other` maps to none.
|
|
37
|
+
*/
|
|
38
|
+
export const DEFAULT_REPORT_REASONS = Object.freeze([
|
|
39
|
+
reason('harassment', 'Insults or harassment', 'Insults, put-downs or picking on someone', 'Chat', [2]),
|
|
40
|
+
reason('hate', 'Hate', 'Hate aimed at who someone is', 'Chat', [1]),
|
|
41
|
+
reason('sexual', 'Sexual content', 'Sexual messages or pressure', 'Chat', [3]),
|
|
42
|
+
reason('threat', 'Threats', 'Threatening someone', 'Chat', [2]),
|
|
43
|
+
reason('spam', 'Spam or ads', 'Repeated messages, flooding or advertising', 'Chat', [4]),
|
|
44
|
+
reason('personal_info', 'Sharing personal info', "Posting someone's private details", 'Chat', [2]),
|
|
45
|
+
reason('cheating', 'Cheating', 'Cheating or exploiting a bug', 'Gameplay', [5]),
|
|
46
|
+
reason('griefing', 'Throwing or griefing', 'Losing on purpose or ruining the game', 'Gameplay', [6]),
|
|
47
|
+
reason('afk', 'Leaving or AFK', 'Leaving the game or not playing', 'Gameplay', [6]),
|
|
48
|
+
reason(OTHER_REASON_ID, 'Something else', 'Anything else you want us to look at', '', [], true),
|
|
49
|
+
].map((r) => Object.freeze({ ...r, rules: Object.freeze([...r.rules]) })));
|
|
50
|
+
/** A fresh, unfrozen copy of the default reporting settings. */
|
|
51
|
+
export function defaultReporting() {
|
|
52
|
+
return {
|
|
53
|
+
flow: DEFAULT_REPORT_FLOW,
|
|
54
|
+
reasons: DEFAULT_REPORT_REASONS.map((r) => ({ ...r, rules: [...r.rules] })),
|
|
55
|
+
thanks: DEFAULT_REPORT_THANKS,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Old ids that read as a new one. `disruption` (the 0.1.1 category) is `griefing`. An exact id in the list always wins, so a
|
|
60
|
+
* studio that defines its own `disruption` reason keeps it.
|
|
61
|
+
*/
|
|
62
|
+
export const LEGACY_REASON_ALIASES = Object.freeze({ disruption: 'griefing' });
|
|
63
|
+
/** The six 0.1.1 categories. They stay valid reason ids (through {@link LEGACY_REASON_ALIASES} for `disruption`). */
|
|
64
|
+
export const LEGACY_CATEGORIES = ['harassment', 'hate', 'cheating', 'spam', 'disruption', 'other'];
|
|
65
|
+
/** The reason in `reasons` that `id` names (exactly, else as an old alias), or undefined. Disabled reasons are found too. */
|
|
66
|
+
export function findReason(reasons, id) {
|
|
67
|
+
const exact = reasons.find((r) => r.id === id);
|
|
68
|
+
if (exact !== undefined)
|
|
69
|
+
return exact;
|
|
70
|
+
const alias = Object.hasOwn(LEGACY_REASON_ALIASES, id) ? LEGACY_REASON_ALIASES[id] : undefined;
|
|
71
|
+
return alias === undefined ? undefined : reasons.find((r) => r.id === alias);
|
|
72
|
+
}
|
|
73
|
+
/** The id `id` stands for in `reasons` (`disruption` becomes `griefing` unless the list has its own), or `id` itself when it is in no list. */
|
|
74
|
+
export function canonicalReasonId(reasons, id) {
|
|
75
|
+
return findReason(reasons, id)?.id ?? id;
|
|
76
|
+
}
|
|
77
|
+
/** The player-facing label of a reason id (an old alias included), or null when there is no such reason. */
|
|
78
|
+
export function reasonLabel(reasons, id) {
|
|
79
|
+
return id === null ? null : (findReason(reasons, id)?.label ?? null);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The 0.1.1 category a reason id is kept under in the stored report's `category` column (which old consumers still read): the
|
|
83
|
+
* six old ids are themselves, `griefing` and `afk` are `disruption`, `threat` is `harassment`, and everything else (no reason,
|
|
84
|
+
* `sexual`, `personal_info`, a studio's own) is `other`.
|
|
85
|
+
*/
|
|
86
|
+
export function legacyCategoryOf(id) {
|
|
87
|
+
switch (id) {
|
|
88
|
+
case 'harassment':
|
|
89
|
+
case 'hate':
|
|
90
|
+
case 'cheating':
|
|
91
|
+
case 'spam':
|
|
92
|
+
case 'other':
|
|
93
|
+
return id;
|
|
94
|
+
case 'griefing':
|
|
95
|
+
case 'afk':
|
|
96
|
+
case 'disruption':
|
|
97
|
+
return 'disruption';
|
|
98
|
+
case 'threat':
|
|
99
|
+
return 'harassment';
|
|
100
|
+
default:
|
|
101
|
+
return 'other';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** The reason id a stored 0.1.1 category reads as: `disruption` is `griefing`, the others are themselves. */
|
|
105
|
+
export function reasonOfCategory(category) {
|
|
106
|
+
return Object.hasOwn(LEGACY_REASON_ALIASES, category) ? LEGACY_REASON_ALIASES[category] : category;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The Community Rule a moderator is suggested for a reported reason: the first of the reason's rules that is still citable, or
|
|
110
|
+
* `'uncovered'` (no reason, an unknown reason, a reason with no rules). The report is never decided by it.
|
|
111
|
+
*/
|
|
112
|
+
export function suggestedRule(reasons, id, rules) {
|
|
113
|
+
if (id === null)
|
|
114
|
+
return 'uncovered';
|
|
115
|
+
const found = findReason(reasons, id);
|
|
116
|
+
if (found === undefined)
|
|
117
|
+
return 'uncovered';
|
|
118
|
+
return found.rules.find((n) => rules.isCitable(n)) ?? 'uncovered';
|
|
119
|
+
}
|
|
120
|
+
/** What a player may read: the enabled reasons in order, with no rule mapping. Each field is copied by name, so nothing added later leaks. */
|
|
121
|
+
export function playerReporting(reporting) {
|
|
122
|
+
return {
|
|
123
|
+
flow: reporting.flow,
|
|
124
|
+
reasons: reporting.reasons
|
|
125
|
+
.filter((r) => r.enabled)
|
|
126
|
+
.map((r) => ({ id: r.id, label: r.label, hint: r.hint, group: r.group, asksNote: r.asksNote })),
|
|
127
|
+
thanks: reporting.thanks,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
131
|
+
/**
|
|
132
|
+
* Fill the optional parts of reporting settings: a missing flow, thank-you, reason list or reason field gets its default. It never
|
|
133
|
+
* throws and never judges: anything of the wrong shape is returned as it is, for the profile validator to name. Copies.
|
|
134
|
+
*/
|
|
135
|
+
export function fillReporting(value) {
|
|
136
|
+
if (value === undefined)
|
|
137
|
+
return defaultReporting();
|
|
138
|
+
if (!isObj(value))
|
|
139
|
+
return value;
|
|
140
|
+
const out = { ...value };
|
|
141
|
+
if (!Object.hasOwn(out, 'flow'))
|
|
142
|
+
out['flow'] = DEFAULT_REPORT_FLOW;
|
|
143
|
+
if (!Object.hasOwn(out, 'thanks'))
|
|
144
|
+
out['thanks'] = DEFAULT_REPORT_THANKS;
|
|
145
|
+
if (!Object.hasOwn(out, 'reasons')) {
|
|
146
|
+
out['reasons'] = defaultReporting().reasons;
|
|
147
|
+
}
|
|
148
|
+
else if (Array.isArray(out['reasons'])) {
|
|
149
|
+
out['reasons'] = out['reasons'].map((r) => {
|
|
150
|
+
if (!isObj(r))
|
|
151
|
+
return r;
|
|
152
|
+
const filled = { ...r };
|
|
153
|
+
if (!Object.hasOwn(filled, 'hint'))
|
|
154
|
+
filled['hint'] = '';
|
|
155
|
+
if (!Object.hasOwn(filled, 'group'))
|
|
156
|
+
filled['group'] = '';
|
|
157
|
+
if (!Object.hasOwn(filled, 'rules'))
|
|
158
|
+
filled['rules'] = [];
|
|
159
|
+
if (!Object.hasOwn(filled, 'asksNote'))
|
|
160
|
+
filled['asksNote'] = false;
|
|
161
|
+
if (!Object.hasOwn(filled, 'enabled'))
|
|
162
|
+
filled['enabled'] = true;
|
|
163
|
+
return filled;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
/** {@link fillReporting} for settings already known to be valid: the typed result. */
|
|
169
|
+
export function resolveReporting(settings) {
|
|
170
|
+
return fillReporting(settings);
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=reporting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporting.js","sourceRoot":"","sources":["../../src/reporting.ts"],"names":[],"mappings":"AAYA,6DAA6D;AAC7D,MAAM,CAAC,MAAM,YAAY,GAA0B,CAAC,SAAS,EAAE,cAAc,EAAE,iBAAiB,CAAC,CAAC;AAElG,6GAA6G;AAC7G,MAAM,CAAC,MAAM,mBAAmB,GAAe,SAAS,CAAC;AAEzD,mDAAmD;AACnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,4CAA4C,CAAC;AAElF,2CAA2C;AAC3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AACrC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAChC,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AACnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAEnC,kIAAkI;AAClI,MAAM,UAAU,UAAU,CAAC,CAAU;IACnC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,IAAI,aAAa,IAAI,+BAA+B,CAAC,IAAI,CA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AU,CAAC;gBAAE,MAAM,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC;YACnE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;gBAAE,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;YAChE,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,gBAAgB,CAAC,QAAuC;IACtE,OAAO,aAAa,CAAC,QAAQ,CAAsB,CAAC;AACtD,CAAC"}
|
package/dist/src/reports.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EvidenceBuffer, RoomRoster } from './evidence.js';
|
|
2
2
|
import type { Limits } from './limits.js';
|
|
3
|
+
import type { ResolvedReporting } from './reporting.js';
|
|
3
4
|
import type { SubjectIndex } from './subjects.js';
|
|
4
5
|
import type { Clock, Logger, ReportCategory, Store, StoredReport } from './types.js';
|
|
5
6
|
export type { StoredReport } from './types.js';
|
|
@@ -11,26 +12,60 @@ export declare const SUSPEND_AFTER = 3;
|
|
|
11
12
|
export declare const SUSPEND_WINDOW_MS: number;
|
|
12
13
|
/** A note is trimmed, then cut to this many characters. */
|
|
13
14
|
export declare const REPORT_NOTE_MAX = 500;
|
|
14
|
-
/**
|
|
15
|
+
/** The 0.1.1 categories. A report's stored `category` is always one of these (see `legacyCategoryOf`); they stay valid ids for `ReportInput.category`. */
|
|
15
16
|
export declare const REPORT_CATEGORIES: readonly ReportCategory[];
|
|
16
17
|
/** Why a report was not taken. In the order they are checked. */
|
|
17
|
-
export type ReportRefusal = 'off'
|
|
18
|
+
export type ReportRefusal = 'off'
|
|
19
|
+
/** The `reason_required` flow, and no reason was given. */
|
|
20
|
+
| 'reason_required'
|
|
21
|
+
/** A reason that is not an enabled id in the profile's reporting reasons (in every flow). */
|
|
22
|
+
| 'reason_unknown' | 'not_player' | 'self' | 'suspended' | 'rate' | 'duplicate';
|
|
23
|
+
/** How long after a report its reporter may add their one follow-up: 10 minutes. */
|
|
24
|
+
export declare const REPORT_DETAIL_WINDOW_MS: number;
|
|
25
|
+
/** The follow-up a reporter may add to their report: a reason, a note, or both. Both are optional; a blank one is "not given". */
|
|
26
|
+
export interface ReportDetailInput {
|
|
27
|
+
reason?: string | null;
|
|
28
|
+
note?: string | null;
|
|
29
|
+
}
|
|
30
|
+
/** Why a follow-up was not taken, in the order they are checked. */
|
|
31
|
+
export type ReportDetailRefusal = 'off' | 'not_found' | 'not_reporter' | 'too_late' | 'already_added' | 'reason_unknown';
|
|
32
|
+
export type ReportDetailResult = {
|
|
33
|
+
ok: true;
|
|
34
|
+
} | {
|
|
35
|
+
ok: false;
|
|
36
|
+
refused: ReportDetailRefusal;
|
|
37
|
+
};
|
|
18
38
|
export interface ReportInput {
|
|
19
39
|
roomId: string;
|
|
20
40
|
/** The seat the reporter sits in. */
|
|
21
41
|
reporterSeat: string;
|
|
22
42
|
/** The seat reported. Ignored when `lineId` names a line still in the evidence buffer. */
|
|
23
43
|
targetSeat: string;
|
|
24
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Why the player is reporting: an enabled id from the profile's reporting reasons. Optional: with the default `one_tap` flow
|
|
46
|
+
* and with `reason_first` a report with no reason (missing, null or blank) is taken; with `reason_required` it is refused
|
|
47
|
+
* `reason_required`. An id that is not an enabled reason is `reason_unknown`, in every flow. It is a hint for the moderator
|
|
48
|
+
* and never decides the case.
|
|
49
|
+
*/
|
|
50
|
+
reason?: string | null;
|
|
51
|
+
/**
|
|
52
|
+
* The 0.1.1 name for `reason`, still accepted as an alias (the six old ids are valid; `disruption` reads as `griefing`) and still
|
|
53
|
+
* lenient: an unknown, non-text or switched-off id is taken as `other`. `reason` wins when both are given; a blank `reason` falls back to this.
|
|
54
|
+
*/
|
|
55
|
+
category?: string | null;
|
|
25
56
|
note?: string;
|
|
26
57
|
lineId?: string;
|
|
27
58
|
}
|
|
28
59
|
export type ReportResult =
|
|
29
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* `remaining` is how many more reports the reporter may file today, this one counted. `detailUntil` (epoch ms) is the last instant
|
|
62
|
+
* `addDetail` still takes a follow-up (the filing time plus `REPORT_DETAIL_WINDOW_MS`); a screen can stop offering one after it.
|
|
63
|
+
*/
|
|
30
64
|
{
|
|
31
65
|
ok: true;
|
|
32
66
|
reportId: string;
|
|
33
67
|
remaining: number;
|
|
68
|
+
detailUntil?: number;
|
|
34
69
|
}
|
|
35
70
|
/** `remaining` is present on `'rate'` (always 0). */
|
|
36
71
|
| {
|
|
@@ -55,6 +90,8 @@ export interface ReportServiceDeps {
|
|
|
55
90
|
clock: Clock;
|
|
56
91
|
/** Read per call, so a kill switch works live. Defaults to always on. */
|
|
57
92
|
enabled?: () => boolean;
|
|
93
|
+
/** The reporting settings in force, read per call so an edit applies to the next report. Defaults to the built-in reporting defaults. */
|
|
94
|
+
reporting?: () => ResolvedReporting;
|
|
58
95
|
/**
|
|
59
96
|
* Called once for each stored report, after the result is decided. Fenced: a synchronous throw or an async
|
|
60
97
|
* rejection is logged and never reaches the reporter. It receives a copy of the report.
|
|
@@ -68,6 +105,15 @@ export interface ReportServiceDeps {
|
|
|
68
105
|
*/
|
|
69
106
|
limits?: Limits['reports'];
|
|
70
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* When a reporter's suspension ends, or null when they are not suspended. `marks` are the `actionedAt` times of the
|
|
110
|
+
* reporter's bad-faith dismissals that are still inside the window (the rows `loadBadFaithMarks` returns for it).
|
|
111
|
+
* Suspended means `suspendAfter` or more of them; the suspension lifts once enough of the oldest have aged out for the
|
|
112
|
+
* count to fall below `suspendAfter`, that is one millisecond after the window has passed the first mark that must go
|
|
113
|
+
* (a mark counts while `actionedAt >= now - suspendWindowMs`). The single place the rule lives: intake refuses with it
|
|
114
|
+
* and the staff view reports it.
|
|
115
|
+
*/
|
|
116
|
+
export declare function reporterSuspendedUntil(marks: readonly number[], limits: Pick<Limits['reports'], 'suspendAfter' | 'suspendWindowMs'>): number | null;
|
|
71
117
|
export declare class ReportService {
|
|
72
118
|
private readonly roster;
|
|
73
119
|
private readonly buffer;
|
|
@@ -75,6 +121,7 @@ export declare class ReportService {
|
|
|
75
121
|
private readonly store;
|
|
76
122
|
private readonly clock;
|
|
77
123
|
private readonly enabled;
|
|
124
|
+
private readonly reporting;
|
|
78
125
|
private readonly onReport;
|
|
79
126
|
private readonly logger;
|
|
80
127
|
private readonly limits;
|
|
@@ -84,6 +131,10 @@ export declare class ReportService {
|
|
|
84
131
|
*
|
|
85
132
|
* - `off`: moderation is disabled, the reporter's seat has no occupant or no subject (nothing to count or
|
|
86
133
|
* dedupe their reports by), or the store failed (logged by event and error class only).
|
|
134
|
+
* - `reason_required`: the flow is `reason_required` and the report names no reason (see {@link ReportInput.reason}).
|
|
135
|
+
* - `reason_unknown`: `reason` is not an enabled reason, in every flow. A refused reason uses up nothing: it never counts toward
|
|
136
|
+
* the daily allowance. The 0.1.1 `category` alias is not refused for this: an id that is not an enabled reason (or not text) is
|
|
137
|
+
* taken as `other`, as it was in 0.1.1. A blank `reason` falls back to `category`.
|
|
87
138
|
* - `not_player`: the target seat has no occupant, or the occupant (or the line's author) has no subject.
|
|
88
139
|
* - `self`: reporter and target are the same canonical subject.
|
|
89
140
|
* - `suspended`: three or more of the reporter's reports were dismissed as bad faith within 30 days.
|
|
@@ -97,6 +148,31 @@ export declare class ReportService {
|
|
|
97
148
|
* snapshot: each line stores `p`, its writer's index in the report's `people` list, and no identity.
|
|
98
149
|
*/
|
|
99
150
|
submit(input: ReportInput): Promise<ReportResult>;
|
|
151
|
+
/**
|
|
152
|
+
* Add the reporter's one follow-up to their report: a reason, a note, or both. Never rejects. Refusals, in this order:
|
|
153
|
+
*
|
|
154
|
+
* - `off`: moderation is disabled, the store cannot take a follow-up (it has no `addReportDetail`), or it failed (logged by
|
|
155
|
+
* event and error class only).
|
|
156
|
+
* - `not_found`: no such report.
|
|
157
|
+
* - `not_reporter`: `reporterSeat` is not the seat the report was filed from, or that seat, in the report's room, no longer
|
|
158
|
+
* holds the reporter (the same canonical person; a merged alias counts). The player must still be in the room.
|
|
159
|
+
* - `too_late`: more than ten minutes after the report (`REPORT_DETAIL_WINDOW_MS`; exactly ten is still in time), or the
|
|
160
|
+
* report has been decided.
|
|
161
|
+
* - `already_added`: the follow-up was already taken once.
|
|
162
|
+
* - `reason_unknown`: the reason is not an enabled reason.
|
|
163
|
+
*
|
|
164
|
+
* A reason given replaces the report's reported reason (it is only a hint); a note replaces its note (trimmed and cut like a
|
|
165
|
+
* report note). One left out (missing, null or blank) keeps what the report had. A follow-up that gives neither is `ok: true`
|
|
166
|
+
* and changes nothing, and does not use up the one allowed. It never changes the target, the excerpt or the line, and
|
|
167
|
+
* announces nothing.
|
|
168
|
+
*/
|
|
169
|
+
addDetail(reportId: string, reporterSeat: string, detail: ReportDetailInput): Promise<ReportDetailResult>;
|
|
170
|
+
/**
|
|
171
|
+
* The reason a report names: `{ id }` (an enabled one; null for none), or why it cannot be taken. A blank reason is none; the
|
|
172
|
+
* `category` alias is read when there is no `reason`. A match is exact, after trimming; an old `disruption` finds `griefing`.
|
|
173
|
+
*/
|
|
174
|
+
private readReason;
|
|
175
|
+
private runDetail;
|
|
100
176
|
private run;
|
|
101
177
|
/**
|
|
102
178
|
* Suspended, rate, duplicate, in that order: the refusal, or how many reports the reporter filed in the last
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../../src/reports.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../../src/reports.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC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