@helyx/bot 1.3.1 → 1.5.0
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 +100 -28
- package/README.md +65 -11
- package/dist/channel-audit-configuration.d.ts +7 -0
- package/dist/channel-audit-configuration.js +40 -0
- package/dist/channel-audit-control.d.ts +14 -0
- package/dist/channel-audit-control.js +61 -0
- package/dist/channel-audit-permissions.d.ts +56 -0
- package/dist/channel-audit-permissions.js +417 -0
- package/dist/channel-audit-routes.d.ts +4 -0
- package/dist/channel-audit-routes.js +42 -0
- package/dist/cloud-connector.d.ts +11 -4
- package/dist/cloud-connector.js +54 -15
- package/dist/cloud-control-dispatcher.d.ts +8 -3
- package/dist/cloud-control-dispatcher.js +84 -4
- package/dist/control-errors.d.ts +12 -0
- package/dist/control-errors.js +32 -0
- package/dist/control-server-schemas.d.ts +84 -0
- package/dist/control-server-schemas.js +101 -0
- package/dist/control-server.d.ts +25 -8
- package/dist/control-server.js +101 -152
- package/dist/core-retention.d.ts +26 -0
- package/dist/core-retention.js +49 -0
- package/dist/creator-guild-join-service.d.ts +25 -0
- package/dist/creator-guild-join-service.js +218 -0
- package/dist/creator-invite-service.d.ts +37 -0
- package/dist/creator-invite-service.js +686 -0
- package/dist/creator-onboarding-control.d.ts +12 -0
- package/dist/creator-onboarding-control.js +65 -0
- package/dist/creator-onboarding-platform.d.ts +20 -0
- package/dist/creator-onboarding-platform.js +58 -0
- package/dist/dashboard-action-control.d.ts +2 -2
- package/dist/dashboard-action-control.js +2 -3
- package/dist/database-bootstrap.d.ts +36 -0
- package/dist/database-bootstrap.js +101 -0
- package/dist/developer-operations-module.d.ts +1 -0
- package/dist/developer-operations-module.js +34 -16
- package/dist/discord-channel-audit.d.ts +9 -0
- package/dist/discord-channel-audit.js +195 -0
- package/dist/discord-guild-health.d.ts +2 -2
- package/dist/discord-owned-message-service.d.ts +1 -0
- package/dist/discord-owned-message-service.js +3 -0
- package/dist/discord-role-safety.d.ts +4 -0
- package/dist/discord-role-safety.js +30 -0
- package/dist/events.d.ts +2 -0
- package/dist/events.js +5 -20
- package/dist/guild-command-read-service.d.ts +8 -3
- package/dist/guild-command-read-service.js +14 -7
- package/dist/guild-command-release.d.ts +15 -8
- package/dist/guild-command-release.js +10 -3
- package/dist/guild-command-worker.d.ts +17 -4
- package/dist/guild-command-worker.js +17 -6
- package/dist/guilds.d.ts +24 -3
- package/dist/guilds.js +185 -64
- package/dist/hosted-server-moderation.js +10 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +200 -82
- package/dist/interactions.js +16 -3
- package/dist/module-configuration.d.ts +1 -1
- package/dist/module-configuration.js +5 -2
- package/dist/module-logging.d.ts +8 -3
- package/dist/module-logging.js +13 -7
- package/dist/modules.d.ts +1 -0
- package/dist/modules.js +8 -1
- package/dist/mysql-runtime-persistence.d.ts +46 -0
- package/dist/mysql-runtime-persistence.js +91 -0
- package/dist/oauth-module.js +2 -2
- package/dist/oauth-service.d.ts +7 -0
- package/dist/oauth-service.js +3 -0
- package/dist/scheduled-task-runner.d.ts +9 -85
- package/dist/scheduled-task-runner.js +1 -1
- package/dist/shard-contracts.d.ts +222 -0
- package/dist/shard-contracts.js +52 -1
- package/dist/shard-router.d.ts +4 -1
- package/dist/shard-router.js +19 -0
- package/dist/shard-supervisor.js +43 -9
- package/dist/shard-worker.d.ts +5 -2
- package/dist/shard-worker.js +41 -5
- package/dist/supervisor-cloud-directory.d.ts +9 -3
- package/dist/supervisor-cloud-directory.js +8 -12
- package/dist/trivia-data-provider.d.ts +11 -0
- package/dist/trivia-data-provider.js +46 -26
- package/dist/verification-service.d.ts +2 -2
- package/dist/verification-service.js +6 -3
- package/documentation/README.md +5 -3
- package/documentation/examples/.env.example +15 -11
- package/documentation/guides/getting-started.md +29 -12
- package/documentation/guides/privacy-and-support.md +6 -5
- package/documentation/guides/self-hosting.md +16 -11
- package/documentation/modules/auto-moderation.md +7 -5
- package/documentation/modules/building-a-module.md +48 -2
- package/documentation/modules/moderation.md +5 -5
- package/documentation/modules/publishing-a-module.md +6 -4
- package/documentation/modules/testing-a-module.md +39 -4
- package/documentation/reference/environment.md +43 -9
- package/documentation/runbooks/backup-and-recovery.md +26 -7
- package/documentation/runbooks/installation-and-upgrades.md +97 -27
- package/package.json +20 -16
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { assertCloudResponseSize, parseOperationInput, } from "@helyx/control-protocol";
|
|
2
2
|
import { CloudConnectorRepository } from "@helyx/database";
|
|
3
3
|
export class CloudControlDispatcher {
|
|
4
|
-
database;
|
|
5
4
|
control;
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
commands;
|
|
6
|
+
#repository;
|
|
7
|
+
constructor(databaseOrInput, control, commands) {
|
|
8
8
|
this.control = control;
|
|
9
|
+
this.commands = commands;
|
|
10
|
+
this.#repository =
|
|
11
|
+
"repository" in databaseOrInput
|
|
12
|
+
? databaseOrInput.repository
|
|
13
|
+
: new CloudConnectorRepository(databaseOrInput);
|
|
9
14
|
}
|
|
10
15
|
async execute(request, correlationId) {
|
|
11
16
|
const actorUserId = request.actor.kind === "customer"
|
|
@@ -52,6 +57,48 @@ export class CloudControlDispatcher {
|
|
|
52
57
|
});
|
|
53
58
|
break;
|
|
54
59
|
}
|
|
60
|
+
case "guild.commands.status.read.v1": {
|
|
61
|
+
const input = parseOperationInput(request.operation, request.input);
|
|
62
|
+
await this.#requireCommandAccess(input.guildId, actorUserId);
|
|
63
|
+
result = await this.#commands().getStatus(input.guildId);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
case "guild.commands.history.read.v1": {
|
|
67
|
+
const input = parseOperationInput(request.operation, request.input);
|
|
68
|
+
await this.#requireCommandAccess(input.guildId, actorUserId);
|
|
69
|
+
result = await this.#commands().listHistory({
|
|
70
|
+
guildId: input.guildId,
|
|
71
|
+
...(input.before ? { beforeEventId: BigInt(input.before) } : {}),
|
|
72
|
+
...(input.since ? { since: new Date(input.since) } : {}),
|
|
73
|
+
limit: input.limit,
|
|
74
|
+
});
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case "guild.commands.status.refresh.v1": {
|
|
78
|
+
const input = parseOperationInput(request.operation, request.input);
|
|
79
|
+
const actor = await this.#requireCommandAccess(input.guildId, actorUserId);
|
|
80
|
+
result = await this.#commands().refreshStatus({
|
|
81
|
+
guildId: input.guildId,
|
|
82
|
+
actorUserId: actor,
|
|
83
|
+
correlationId,
|
|
84
|
+
});
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case "guild.commands.rebuild.v1": {
|
|
88
|
+
const input = parseOperationInput(request.operation, request.input);
|
|
89
|
+
const actor = await this.#requireCommandAccess(input.guildId, actorUserId);
|
|
90
|
+
result = await this.#commands().requestReconciliation({
|
|
91
|
+
guildId: input.guildId,
|
|
92
|
+
actorUserId: actor,
|
|
93
|
+
correlationId,
|
|
94
|
+
expectedRevision: BigInt(input.expectedRevision),
|
|
95
|
+
source: "customer_rebuild",
|
|
96
|
+
budgetClass: "customer",
|
|
97
|
+
delayMs: 120_000,
|
|
98
|
+
summary: "A server manager requested a command rebuild.",
|
|
99
|
+
});
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
55
102
|
case "guild.module.public.read.v1": {
|
|
56
103
|
const input = parseOperationInput(request.operation, request.input);
|
|
57
104
|
if (request.actor.kind !== "public")
|
|
@@ -74,6 +121,28 @@ export class CloudControlDispatcher {
|
|
|
74
121
|
});
|
|
75
122
|
break;
|
|
76
123
|
}
|
|
124
|
+
case "guild.module.channel-audit.config.read.v1": {
|
|
125
|
+
const input = parseOperationInput(request.operation, request.input);
|
|
126
|
+
if (!this.control.readChannelAuditConfiguration)
|
|
127
|
+
throw new Error("Channel audit is not supported by this bot version");
|
|
128
|
+
result = await this.control.readChannelAuditConfiguration({
|
|
129
|
+
...input,
|
|
130
|
+
actorUserId: requiredActor(actorUserId),
|
|
131
|
+
correlationId,
|
|
132
|
+
});
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case "guild.module.channel-audit.check.v1": {
|
|
136
|
+
const input = parseOperationInput(request.operation, request.input);
|
|
137
|
+
if (!this.control.checkChannelAudit)
|
|
138
|
+
throw new Error("Channel audit is not supported by this bot version");
|
|
139
|
+
result = await this.control.checkChannelAudit({
|
|
140
|
+
...input,
|
|
141
|
+
actorUserId: requiredActor(actorUserId),
|
|
142
|
+
correlationId,
|
|
143
|
+
});
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
77
146
|
case "guild.module.configuration.write.v1": {
|
|
78
147
|
const input = parseOperationInput(request.operation, request.input);
|
|
79
148
|
result = await this.control.updateConfiguration({
|
|
@@ -245,8 +314,19 @@ export class CloudControlDispatcher {
|
|
|
245
314
|
assertCloudResponseSize(result);
|
|
246
315
|
return result;
|
|
247
316
|
}
|
|
317
|
+
#commands() {
|
|
318
|
+
if (!this.commands)
|
|
319
|
+
throw new Error("guild_command_state_unavailable");
|
|
320
|
+
return this.commands;
|
|
321
|
+
}
|
|
322
|
+
async #requireCommandAccess(guildId, actorUserId) {
|
|
323
|
+
const actor = requiredActor(actorUserId);
|
|
324
|
+
if (!(await this.control.canAccessDashboard({ guildId, actorUserId: actor })))
|
|
325
|
+
throw new CloudControlDeniedError("guild_command_access_denied");
|
|
326
|
+
return actor;
|
|
327
|
+
}
|
|
248
328
|
async #supportSnapshot(input) {
|
|
249
|
-
const repository =
|
|
329
|
+
const repository = this.#repository;
|
|
250
330
|
const consent = await repository.getConsent();
|
|
251
331
|
const requested = input.dataClasses.filter((dataClass) => consent.supportDataClasses.includes(dataClass));
|
|
252
332
|
if (!consent.supportInspectionEnabled || requested.length === 0) {
|
package/dist/control-errors.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { type PermissionMutationDenialReason } from "@helyx/core";
|
|
2
|
+
export declare function isUnknownGuildError(error: unknown): boolean;
|
|
3
|
+
export declare function isUnknownMemberError(error: unknown): boolean;
|
|
4
|
+
export declare class BotControlTransportError extends Error {
|
|
5
|
+
readonly status: 400 | 403 | 404 | 409 | 502 | 503 | 504;
|
|
6
|
+
constructor(status: 400 | 403 | 404 | 409 | 502 | 503 | 504, message: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class BotControlValidationError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class BotControlNotFoundError extends Error {
|
|
12
|
+
constructor(message?: string);
|
|
13
|
+
}
|
|
2
14
|
export declare class BotControlForbiddenError extends Error {
|
|
3
15
|
constructor(message?: string);
|
|
4
16
|
}
|
package/dist/control-errors.js
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
import { permissionMutationDenialMessage, } from "@helyx/core";
|
|
2
|
+
export function isUnknownGuildError(error) {
|
|
3
|
+
return (typeof error === "object" &&
|
|
4
|
+
error !== null &&
|
|
5
|
+
"code" in error &&
|
|
6
|
+
error.code === 10_004);
|
|
7
|
+
}
|
|
8
|
+
export function isUnknownMemberError(error) {
|
|
9
|
+
return (typeof error === "object" &&
|
|
10
|
+
error !== null &&
|
|
11
|
+
"code" in error &&
|
|
12
|
+
error.code === 10_007);
|
|
13
|
+
}
|
|
14
|
+
export class BotControlTransportError extends Error {
|
|
15
|
+
status;
|
|
16
|
+
constructor(status, message) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.status = status;
|
|
19
|
+
this.name = "BotControlTransportError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class BotControlValidationError extends Error {
|
|
23
|
+
constructor(message) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = "BotControlValidationError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class BotControlNotFoundError extends Error {
|
|
29
|
+
constructor(message = "Discord server is not available to Helyx") {
|
|
30
|
+
super(message);
|
|
31
|
+
this.name = "BotControlNotFoundError";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
2
34
|
export class BotControlForbiddenError extends Error {
|
|
3
35
|
constructor(message = "You no longer have permission to perform this action") {
|
|
4
36
|
super(message);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ManagedResourceValue } from "@helyx/sdk";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const snowflake: z.ZodString;
|
|
4
|
+
export declare const moduleId: z.ZodString;
|
|
5
|
+
export declare const configurationValue: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNull, z.ZodString, z.ZodBoolean, z.ZodNumber, z.ZodArray<z.ZodString>]>>;
|
|
6
|
+
export declare const permissionState: z.ZodObject<{
|
|
7
|
+
version: z.ZodNumber;
|
|
8
|
+
module: z.ZodObject<{
|
|
9
|
+
preset: z.ZodEnum<{
|
|
10
|
+
everyone: "everyone";
|
|
11
|
+
moderators: "moderators";
|
|
12
|
+
administrators: "administrators";
|
|
13
|
+
custom: "custom";
|
|
14
|
+
}>;
|
|
15
|
+
allowedRoleIds: z.ZodArray<z.ZodString>;
|
|
16
|
+
deniedRoleIds: z.ZodArray<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
commands: z.ZodArray<z.ZodObject<{
|
|
19
|
+
commandId: z.ZodString;
|
|
20
|
+
version: z.ZodNumber;
|
|
21
|
+
enabled: z.ZodBoolean;
|
|
22
|
+
policy: z.ZodObject<{
|
|
23
|
+
preset: z.ZodEnum<{
|
|
24
|
+
everyone: "everyone";
|
|
25
|
+
moderators: "moderators";
|
|
26
|
+
administrators: "administrators";
|
|
27
|
+
custom: "custom";
|
|
28
|
+
}>;
|
|
29
|
+
allowedRoleIds: z.ZodArray<z.ZodString>;
|
|
30
|
+
deniedRoleIds: z.ZodArray<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
}, z.core.$strip>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export declare const guildAccessPolicy: z.ZodObject<{
|
|
35
|
+
administratorRoleIds: z.ZodArray<z.ZodString>;
|
|
36
|
+
moderatorRoleIds: z.ZodArray<z.ZodString>;
|
|
37
|
+
dashboardModeratorsEnabled: z.ZodBoolean;
|
|
38
|
+
dashboardAllowedRoleIds: z.ZodArray<z.ZodString>;
|
|
39
|
+
dashboardDeniedRoleIds: z.ZodArray<z.ZodString>;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
export declare const mutationContext: z.ZodObject<{
|
|
42
|
+
actorUserId: z.ZodString;
|
|
43
|
+
correlationId: z.ZodUUID;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export declare const resourceId: z.ZodString;
|
|
46
|
+
export declare const resourceCursor: z.ZodString;
|
|
47
|
+
export declare const resourceActionId: z.ZodString;
|
|
48
|
+
export declare const managedResourceFilters: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
49
|
+
export declare const managedResourceObject: z.ZodRecord<z.ZodString, z.ZodCustom<ManagedResourceValue, ManagedResourceValue>>;
|
|
50
|
+
export declare const managedResourceDetailSchema: z.ZodObject<{
|
|
51
|
+
id: z.ZodString;
|
|
52
|
+
revision: z.ZodNumber;
|
|
53
|
+
status: z.ZodString;
|
|
54
|
+
title: z.ZodString;
|
|
55
|
+
description: z.ZodOptional<z.ZodString>;
|
|
56
|
+
attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodCustom<ManagedResourceValue, ManagedResourceValue>>>;
|
|
57
|
+
updatedAt: z.ZodISODateTime;
|
|
58
|
+
value: z.ZodRecord<z.ZodString, z.ZodCustom<ManagedResourceValue, ManagedResourceValue>>;
|
|
59
|
+
availableActionIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
60
|
+
}, z.core.$strict>;
|
|
61
|
+
export declare const managedResourcePageSchema: z.ZodObject<{
|
|
62
|
+
items: z.ZodArray<z.ZodObject<{
|
|
63
|
+
id: z.ZodString;
|
|
64
|
+
revision: z.ZodNumber;
|
|
65
|
+
status: z.ZodString;
|
|
66
|
+
title: z.ZodString;
|
|
67
|
+
description: z.ZodOptional<z.ZodString>;
|
|
68
|
+
attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodCustom<ManagedResourceValue, ManagedResourceValue>>>;
|
|
69
|
+
updatedAt: z.ZodISODateTime;
|
|
70
|
+
}, z.core.$strict>>;
|
|
71
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
72
|
+
total: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
}, z.core.$strict>;
|
|
74
|
+
export declare const managedResourceRelationPageSchema: z.ZodObject<{
|
|
75
|
+
items: z.ZodArray<z.ZodObject<{
|
|
76
|
+
id: z.ZodString;
|
|
77
|
+
value: z.ZodRecord<z.ZodString, z.ZodCustom<ManagedResourceValue, ManagedResourceValue>>;
|
|
78
|
+
}, z.core.$strict>>;
|
|
79
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
80
|
+
}, z.core.$strict>;
|
|
81
|
+
export declare const managedResourceDeleteResultSchema: z.ZodObject<{
|
|
82
|
+
deleted: z.ZodBoolean;
|
|
83
|
+
}, z.core.$strict>;
|
|
84
|
+
//# sourceMappingURL=control-server-schemas.d.ts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { hasBoundedManagedResourceBytes, isBoundedManagedResourceValue, } from "./dashboard-feature-control.js";
|
|
3
|
+
export const snowflake = z.string().regex(/^\d{17,20}$/u);
|
|
4
|
+
export const moduleId = z.string().regex(/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)+$/u);
|
|
5
|
+
export const configurationValue = z.record(z.string(), z.union([
|
|
6
|
+
z.null(),
|
|
7
|
+
z.string(),
|
|
8
|
+
z.boolean(),
|
|
9
|
+
z.number().finite(),
|
|
10
|
+
z.array(z.string()).max(100),
|
|
11
|
+
]));
|
|
12
|
+
const permissionPreset = z.enum([
|
|
13
|
+
"everyone",
|
|
14
|
+
"moderators",
|
|
15
|
+
"administrators",
|
|
16
|
+
"custom",
|
|
17
|
+
]);
|
|
18
|
+
const dashboardPermissionPolicy = z.object({
|
|
19
|
+
preset: permissionPreset,
|
|
20
|
+
allowedRoleIds: z.array(snowflake).max(100),
|
|
21
|
+
deniedRoleIds: z.array(snowflake).max(100),
|
|
22
|
+
});
|
|
23
|
+
export const permissionState = z.object({
|
|
24
|
+
version: z.number().int().min(0),
|
|
25
|
+
module: dashboardPermissionPolicy,
|
|
26
|
+
commands: z
|
|
27
|
+
.array(z.object({
|
|
28
|
+
commandId: z.string().min(1).max(100),
|
|
29
|
+
version: z.number().int().min(0),
|
|
30
|
+
enabled: z.boolean(),
|
|
31
|
+
policy: dashboardPermissionPolicy,
|
|
32
|
+
}))
|
|
33
|
+
.max(100),
|
|
34
|
+
});
|
|
35
|
+
export const guildAccessPolicy = z
|
|
36
|
+
.object({
|
|
37
|
+
administratorRoleIds: z.array(snowflake).max(25),
|
|
38
|
+
moderatorRoleIds: z.array(snowflake).max(25),
|
|
39
|
+
dashboardModeratorsEnabled: z.boolean(),
|
|
40
|
+
dashboardAllowedRoleIds: z.array(snowflake).max(25),
|
|
41
|
+
dashboardDeniedRoleIds: z.array(snowflake).max(25),
|
|
42
|
+
})
|
|
43
|
+
.strict();
|
|
44
|
+
export const mutationContext = z.object({
|
|
45
|
+
actorUserId: snowflake,
|
|
46
|
+
correlationId: z.uuid(),
|
|
47
|
+
});
|
|
48
|
+
export const resourceId = z.string().trim().min(1).max(100);
|
|
49
|
+
export const resourceCursor = z.string().min(1).max(2_048);
|
|
50
|
+
export const resourceActionId = z.string().regex(/^[a-z][a-z0-9_-]*$/u);
|
|
51
|
+
export const managedResourceFilters = z
|
|
52
|
+
.record(z.string().regex(/^[a-z][a-zA-Z0-9_]*$/u), z.string().trim().min(1).max(100))
|
|
53
|
+
.refine((value) => Object.keys(value).length <= 8);
|
|
54
|
+
const managedResourceValue = z.custom((value) => isBoundedManagedResourceValue(value), "Managed resource value exceeds the transport limits");
|
|
55
|
+
export const managedResourceObject = z
|
|
56
|
+
.record(z.string().min(1).max(100), managedResourceValue)
|
|
57
|
+
.refine(hasBoundedManagedResourceBytes);
|
|
58
|
+
const managedResourceSummarySchema = z
|
|
59
|
+
.object({
|
|
60
|
+
id: resourceId,
|
|
61
|
+
revision: z.number().int().min(0),
|
|
62
|
+
status: z.string().trim().min(1).max(100),
|
|
63
|
+
title: z.string().trim().min(1).max(200),
|
|
64
|
+
description: z.string().max(500).optional(),
|
|
65
|
+
attributes: managedResourceObject.optional(),
|
|
66
|
+
updatedAt: z.iso.datetime({ offset: true }),
|
|
67
|
+
})
|
|
68
|
+
.strict();
|
|
69
|
+
export const managedResourceDetailSchema = managedResourceSummarySchema
|
|
70
|
+
.extend({
|
|
71
|
+
value: managedResourceObject,
|
|
72
|
+
availableActionIds: z.array(z.string().min(1).max(100)).max(50).optional(),
|
|
73
|
+
})
|
|
74
|
+
.strict()
|
|
75
|
+
.refine(hasBoundedManagedResourceBytes);
|
|
76
|
+
export const managedResourcePageSchema = z
|
|
77
|
+
.object({
|
|
78
|
+
items: z.array(managedResourceSummarySchema).max(50),
|
|
79
|
+
nextCursor: resourceCursor.optional(),
|
|
80
|
+
total: z.number().int().min(0).optional(),
|
|
81
|
+
})
|
|
82
|
+
.strict()
|
|
83
|
+
.refine(hasBoundedManagedResourceBytes);
|
|
84
|
+
export const managedResourceRelationPageSchema = z
|
|
85
|
+
.object({
|
|
86
|
+
items: z
|
|
87
|
+
.array(z
|
|
88
|
+
.object({
|
|
89
|
+
id: resourceId,
|
|
90
|
+
value: managedResourceObject,
|
|
91
|
+
})
|
|
92
|
+
.strict())
|
|
93
|
+
.max(50),
|
|
94
|
+
nextCursor: resourceCursor.optional(),
|
|
95
|
+
})
|
|
96
|
+
.strict()
|
|
97
|
+
.refine(hasBoundedManagedResourceBytes);
|
|
98
|
+
export const managedResourceDeleteResultSchema = z
|
|
99
|
+
.object({ deleted: z.boolean() })
|
|
100
|
+
.strict();
|
|
101
|
+
//# sourceMappingURL=control-server-schemas.js.map
|
package/dist/control-server.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { type DatabasePool, type GuildShardOwnership } from "@helyx/database";
|
|
1
|
+
import { AuditRepository, GuildAccessPolicyRepository, InstallationRepository, ModuleLoggingPolicyRepository, PermissionPolicyRepository, type DatabasePool, type GuildShardOwnership } from "@helyx/database";
|
|
2
|
+
import type { MysqlPool } from "@helyx/database-mysql";
|
|
3
|
+
import type { CreatorOnboardingRequest, CreatorOnboardingResponse } from "@helyx/sdk";
|
|
2
4
|
import { type DashboardActionInspection, type DashboardActionResult, type FeatureAccessDecision, type GuildAccessPolicy, type ManagedResourceCreationIntent, type ManagedResourceDetail, type ManagedResourcePage, type ManagedResourceRelationPage, type ManagedResourceValue, type MessageResponse, type ModuleDefinition, type OAuthConsumerCleanupResult, type PermissionActor, type PrivacyCapturePage, type PrivacyErasePage, type PrivacyProviderExecutor, type PublicAchievementProjectionPage, type ServiceAccess } from "@helyx/sdk";
|
|
3
5
|
import { type ActionReceipt, type SignedAssessmentEnvelope } from "@helyx/verification-contracts";
|
|
4
6
|
import { type Client } from "discord.js";
|
|
@@ -7,6 +9,8 @@ import { type BotModuleStatusMutationResult } from "./module-status-control.js";
|
|
|
7
9
|
import { type FirstTimeCommandSetupHandler } from "./first-time-command-setup.js";
|
|
8
10
|
import { type ShardHealthSnapshot } from "./shard-contracts.js";
|
|
9
11
|
import { type DashboardPermissionState } from "./control-permissions.js";
|
|
12
|
+
export { BotControlTransportError } from "./control-errors.js";
|
|
13
|
+
import type { ChannelAuditControl } from "@helyx/sdk";
|
|
10
14
|
import { type DashboardModuleDefinition } from "./dashboard-module-projection.js";
|
|
11
15
|
import { type AvailabilityModuleCatalogue } from "./module-availability-control.js";
|
|
12
16
|
import { registerGuildCommandControlRoutes } from "./guild-command-control-routes.js";
|
|
@@ -117,7 +121,8 @@ export interface DashboardGuildAccessState extends GuildAccessPolicy {
|
|
|
117
121
|
actorHighestRolePosition: number | null;
|
|
118
122
|
updatedAt: string | null;
|
|
119
123
|
}
|
|
120
|
-
export interface BotControlHandler extends FirstTimeCommandSetupHandler, DashboardActionHandler {
|
|
124
|
+
export interface BotControlHandler extends FirstTimeCommandSetupHandler, DashboardActionHandler, ChannelAuditControl {
|
|
125
|
+
creatorOnboarding?(input: CreatorOnboardingRequest): Promise<CreatorOnboardingResponse>;
|
|
121
126
|
cleanupOAuthConsumer(input: {
|
|
122
127
|
consumerBindingId: string;
|
|
123
128
|
moduleId: string;
|
|
@@ -324,21 +329,34 @@ export interface BotControlHandler extends FirstTimeCommandSetupHandler, Dashboa
|
|
|
324
329
|
cursor?: string;
|
|
325
330
|
}): Promise<PrivacyErasePage>;
|
|
326
331
|
}
|
|
327
|
-
export
|
|
328
|
-
|
|
329
|
-
|
|
332
|
+
export interface BotControlRepositories {
|
|
333
|
+
installations: Pick<InstallationRepository, "adoptGuildsForReconciliation" | "markGuildsRemovedForReconciliation" | "listModules" | "isModuleEnabled">;
|
|
334
|
+
accessPolicies: Pick<GuildAccessPolicyRepository, "get" | "save">;
|
|
335
|
+
loggingPolicies: Pick<ModuleLoggingPolicyRepository, "listForGuild" | "save">;
|
|
336
|
+
permissionPolicies: Pick<PermissionPolicyRepository, "save" | "deleteCommandPolicy">;
|
|
337
|
+
audit: Pick<AuditRepository, "append">;
|
|
330
338
|
}
|
|
339
|
+
interface ControlPersistence {
|
|
340
|
+
readonly repositories: BotControlRepositories;
|
|
341
|
+
withTransaction<Value>(operation: (repositories: BotControlRepositories) => Promise<Value>): Promise<Value>;
|
|
342
|
+
}
|
|
343
|
+
export interface BotControlPersistence extends ControlPersistence {
|
|
344
|
+
readonly engine: "mysql";
|
|
345
|
+
}
|
|
346
|
+
export declare function createMysqlBotControlPersistence(pool: MysqlPool): Promise<BotControlPersistence>;
|
|
331
347
|
export declare class BotControlService implements BotControlHandler {
|
|
332
348
|
#private;
|
|
333
|
-
private readonly database;
|
|
334
349
|
private readonly resources;
|
|
335
350
|
private readonly supportNotifications?;
|
|
336
351
|
private readonly presenceOwnership?;
|
|
337
352
|
private readonly presenceShardCount?;
|
|
338
|
-
|
|
353
|
+
readonly readChannelAuditConfiguration: Required<ChannelAuditControl>["readChannelAuditConfiguration"];
|
|
354
|
+
readonly checkChannelAudit: Required<ChannelAuditControl>["checkChannelAudit"];
|
|
355
|
+
constructor(databaseOrPersistence: DatabasePool | BotControlPersistence, modules: readonly ModuleDefinition[], resources: BotControlGuildResourceDirectory, services: ServiceAccess, privacyExecutor?: PrivacyProviderExecutor, supportNotifications?: {
|
|
339
356
|
guildId: string;
|
|
340
357
|
channelId: string;
|
|
341
358
|
} | undefined, presenceOwnership?: GuildShardOwnership | undefined, presenceShardCount?: number | undefined, statusModules?: readonly ModuleDefinition[]);
|
|
359
|
+
creatorOnboarding(input: CreatorOnboardingRequest): Promise<CreatorOnboardingResponse>;
|
|
342
360
|
cleanupOAuthConsumer(input: {
|
|
343
361
|
consumerBindingId: string;
|
|
344
362
|
moduleId: string;
|
|
@@ -590,5 +608,4 @@ export declare function mapBotControlError(error: unknown): {
|
|
|
590
608
|
status: 400 | 403 | 404 | 409;
|
|
591
609
|
message: string;
|
|
592
610
|
} | undefined;
|
|
593
|
-
export {};
|
|
594
611
|
//# sourceMappingURL=control-server.d.ts.map
|