@helyx/module-reactionroles 1.0.15 → 1.0.18
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 +20 -0
- package/README.md +37 -53
- package/dist/builder-interactions.d.ts +11 -0
- package/dist/builder-interactions.js +293 -0
- package/dist/builder-presentation.d.ts +30 -0
- package/dist/builder-presentation.js +343 -0
- package/dist/builder.d.ts +3 -0
- package/dist/builder.js +22 -16
- package/dist/cleanup-repository.d.ts +24 -0
- package/dist/cleanup-repository.js +118 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +4 -1
- package/dist/health.d.ts +16 -0
- package/dist/health.js +85 -0
- package/dist/index.js +66 -1147
- package/dist/logging.d.ts +33 -0
- package/dist/logging.js +40 -0
- package/dist/managed-resource.d.ts +2 -0
- package/dist/managed-resource.js +72 -0
- package/dist/member-interactions.d.ts +27 -0
- package/dist/member-interactions.js +360 -0
- package/dist/module-lifecycle.d.ts +3 -0
- package/dist/module-lifecycle.js +48 -0
- package/dist/panel-cache.d.ts +30 -0
- package/dist/panel-cache.js +197 -0
- package/dist/panel-create.d.ts +10 -0
- package/dist/panel-create.js +80 -0
- package/dist/panel-lifecycle.d.ts +47 -0
- package/dist/panel-lifecycle.js +272 -0
- package/dist/panel-managed.d.ts +14 -0
- package/dist/panel-managed.js +27 -0
- package/dist/panel-service.d.ts +13 -36
- package/dist/panel-service.js +48 -722
- package/dist/panel-support.d.ts +35 -0
- package/dist/panel-support.js +291 -0
- package/dist/permissions.d.ts +2 -0
- package/dist/permissions.js +8 -0
- package/dist/privacy.d.ts +5 -0
- package/dist/privacy.js +12 -0
- package/dist/record-mapping.d.ts +28 -0
- package/dist/record-mapping.js +161 -0
- package/dist/record-schema.d.ts +203 -0
- package/dist/record-schema.js +137 -0
- package/dist/records.d.ts +9 -201
- package/dist/records.js +32 -383
- package/dist/runtime-state.d.ts +9 -0
- package/dist/runtime-state.js +30 -0
- package/manifest.json +1 -1
- package/package.json +3 -3
package/dist/health.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { HELYX_SERVICE_NAMES, } from "@helyx/sdk";
|
|
2
|
+
const REQUIRED_SERVICES = [
|
|
3
|
+
HELYX_SERVICE_NAMES.audit,
|
|
4
|
+
HELYX_SERVICE_NAMES.discordOwnedMessages,
|
|
5
|
+
HELYX_SERVICE_NAMES.discordResources,
|
|
6
|
+
HELYX_SERVICE_NAMES.memberRoles,
|
|
7
|
+
HELYX_SERVICE_NAMES.messageBuilder,
|
|
8
|
+
HELYX_SERVICE_NAMES.rateLimits,
|
|
9
|
+
HELYX_SERVICE_NAMES.records,
|
|
10
|
+
HELYX_SERVICE_NAMES.scheduledTasks,
|
|
11
|
+
HELYX_SERVICE_NAMES.sessions,
|
|
12
|
+
];
|
|
13
|
+
export class ReactionRolesHealthTracker {
|
|
14
|
+
#started = false;
|
|
15
|
+
#services = null;
|
|
16
|
+
#primaryFailures = new Set();
|
|
17
|
+
#cacheWarmFailed = false;
|
|
18
|
+
#cacheSaturated = false;
|
|
19
|
+
#cleanupFailures = 0;
|
|
20
|
+
start(context) {
|
|
21
|
+
this.#started = true;
|
|
22
|
+
this.#services = context.services;
|
|
23
|
+
this.#primaryFailures.clear();
|
|
24
|
+
this.#cacheWarmFailed = false;
|
|
25
|
+
this.#cacheSaturated = false;
|
|
26
|
+
this.#cleanupFailures = 0;
|
|
27
|
+
}
|
|
28
|
+
startupResult(input) {
|
|
29
|
+
this.#cacheWarmFailed = input.cacheWarmFailed === true;
|
|
30
|
+
this.#cacheSaturated = input.cacheSaturated === true;
|
|
31
|
+
this.#cleanupFailures = input.cleanupFailures ?? 0;
|
|
32
|
+
}
|
|
33
|
+
primarySuccess(source = "resource") {
|
|
34
|
+
this.#primaryFailures.delete(source);
|
|
35
|
+
}
|
|
36
|
+
primaryFailure(source = "resource") {
|
|
37
|
+
this.#primaryFailures.add(source);
|
|
38
|
+
}
|
|
39
|
+
cleanupRecovered() {
|
|
40
|
+
if (this.#cleanupFailures > 0)
|
|
41
|
+
this.#cleanupFailures -= 1;
|
|
42
|
+
}
|
|
43
|
+
stop() {
|
|
44
|
+
this.#started = false;
|
|
45
|
+
this.#services = null;
|
|
46
|
+
this.#primaryFailures.clear();
|
|
47
|
+
this.#cacheWarmFailed = false;
|
|
48
|
+
this.#cacheSaturated = false;
|
|
49
|
+
this.#cleanupFailures = 0;
|
|
50
|
+
}
|
|
51
|
+
health() {
|
|
52
|
+
if (!this.#started)
|
|
53
|
+
return {
|
|
54
|
+
status: "unhealthy",
|
|
55
|
+
message: "Reaction Roles is not started",
|
|
56
|
+
};
|
|
57
|
+
if (!this.#services ||
|
|
58
|
+
!REQUIRED_SERVICES.every((name) => this.#services?.has(name)))
|
|
59
|
+
return {
|
|
60
|
+
status: "unhealthy",
|
|
61
|
+
message: "Reaction Roles required services are unavailable",
|
|
62
|
+
};
|
|
63
|
+
if (this.#primaryFailures.size > 0)
|
|
64
|
+
return {
|
|
65
|
+
status: "unhealthy",
|
|
66
|
+
message: "A recent Reaction Roles operation failed",
|
|
67
|
+
};
|
|
68
|
+
if (this.#cacheWarmFailed)
|
|
69
|
+
return {
|
|
70
|
+
status: "degraded",
|
|
71
|
+
message: "Reaction Roles is using cold panel lookups",
|
|
72
|
+
};
|
|
73
|
+
if (this.#cacheSaturated)
|
|
74
|
+
return {
|
|
75
|
+
status: "degraded",
|
|
76
|
+
message: "Reaction Roles reached its bounded panel cache capacity",
|
|
77
|
+
};
|
|
78
|
+
if (this.#cleanupFailures > 0)
|
|
79
|
+
return {
|
|
80
|
+
status: "degraded",
|
|
81
|
+
message: "Reaction Roles has pending owned-message cleanup",
|
|
82
|
+
};
|
|
83
|
+
return { status: "healthy", message: "Reaction Roles is ready" };
|
|
84
|
+
}
|
|
85
|
+
}
|