@abyss-project/reflex 5.6.0 → 5.8.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/dist/types/enum/discord-channel-type.enum.d.ts +7 -0
- package/dist/types/enum/discord-channel-type.enum.js +12 -0
- package/dist/types/enum/discord-channel-type.enum.js.map +1 -0
- package/dist/types/enum/discord-host-action.enum.d.ts +31 -0
- package/dist/types/enum/discord-host-action.enum.js +36 -0
- package/dist/types/enum/discord-host-action.enum.js.map +1 -0
- package/dist/types/enum/discord-locale.enum.d.ts +34 -0
- package/dist/types/enum/discord-locale.enum.js +39 -0
- package/dist/types/enum/discord-locale.enum.js.map +1 -0
- package/dist/types/enum/index.d.ts +3 -0
- package/dist/types/enum/index.js +3 -0
- package/dist/types/enum/index.js.map +1 -1
- package/dist/types/interface/api/requests/service-discord.request.d.ts +7 -1
- package/dist/types/interface/models/reflex-discord-event.model.d.ts +1 -1
- package/dist/types/interface/models/reflex-discord-event.model.js +1 -1
- package/dist/types/interface/models/reflex-discord-event.model.js.map +1 -1
- package/dist/types/interface/models/reflex-discord.model.d.ts +20 -2
- package/dist/types/interface/models/reflex-discord.model.js +2 -0
- package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
- package/package.json +1 -1
- package/src/api/function-insights.api.test.ts +27 -27
- package/src/api/function-insights.api.ts +18 -18
- package/src/api/index.ts +17 -17
- package/src/api/service-discord-event.api.test.ts +106 -106
- package/src/api/service-discord-event.api.ts +78 -78
- package/src/api/service-discord.api.test.ts +197 -197
- package/src/api/service-discord.api.ts +241 -241
- package/src/api/service-insights.api.test.ts +36 -36
- package/src/api/service-insights.api.ts +42 -42
- package/src/discord/discord-event-filter-cases.ts +261 -261
- package/src/discord/discord-event-filters.test.ts +91 -91
- package/src/discord/discord-event-filters.ts +95 -95
- package/src/discord/discord-event-intents.test.ts +112 -112
- package/src/discord/discord-event-intents.ts +55 -55
- package/src/discord/index.ts +3 -3
- package/src/index.test.ts +75 -75
- package/src/index.ts +317 -317
- package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
- package/src/types/enum/discord-channel-type.enum.ts +11 -0
- package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
- package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
- package/src/types/enum/discord-event-status.enum.ts +13 -13
- package/src/types/enum/discord-event-type.enum.ts +7 -7
- package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
- package/src/types/enum/discord-host-action.enum.ts +35 -0
- package/src/types/enum/discord-locale.enum.ts +35 -0
- package/src/types/enum/index.ts +43 -40
- package/src/types/enum/insights-period.enum.ts +8 -8
- package/src/types/enum/reflex-error-code.enum.ts +43 -43
- package/src/types/enum/scheduled-run-failure-code.enum.ts +12 -12
- package/src/types/enum/trigger-kind.enum.ts +8 -8
- package/src/types/interface/api/requests/index.ts +15 -15
- package/src/types/interface/api/requests/service-discord-event.request.ts +68 -68
- package/src/types/interface/api/requests/service-discord.request.ts +173 -161
- package/src/types/interface/api/requests/service-insights.request.ts +31 -31
- package/src/types/interface/api/responses/index.ts +15 -15
- package/src/types/interface/api/responses/service-discord-event.response.ts +24 -24
- package/src/types/interface/api/responses/service-discord.response.ts +122 -122
- package/src/types/interface/api/responses/service-insights.response.ts +11 -11
- package/src/types/interface/api/responses/service-version.response.ts +106 -106
- package/src/types/interface/models/index.ts +19 -19
- package/src/types/interface/models/reflex-bot-limits.model.ts +92 -92
- package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -58
- package/src/types/interface/models/reflex-discord-event.model.ts +79 -77
- package/src/types/interface/models/reflex-discord.model.ts +45 -4
- package/src/types/interface/models/reflex-insights.model.ts +120 -120
- package/src/types/interface/models/reflex-run.model.ts +186 -183
- package/src/types/interface/models/reflex-service-version.model.ts +61 -61
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
import type { BotEventBlockReason } from '../../enum';
|
|
2
|
-
|
|
3
|
-
/** Bounds of the per-bot limits and of their alerts. */
|
|
4
|
-
export const REFLEX_BOT_LIMITS = {
|
|
5
|
-
/** Events per minute added by one lot of the `reflex-bot-events` module. */
|
|
6
|
-
eventsPerMinutePerLot: 500,
|
|
7
|
-
/** Monthly spend cap, in cents: 10 EUR by default, from 1 to 500 EUR. */
|
|
8
|
-
monthlySpendCapDefaultCents: 1000,
|
|
9
|
-
monthlySpendCapMinCents: 100,
|
|
10
|
-
monthlySpendCapMaxCents: 50000,
|
|
11
|
-
/** Alert thresholds: at most 5 values, each from 1 to 100 (percent). */
|
|
12
|
-
alertThresholdsMax: 5,
|
|
13
|
-
alertThresholdMin: 1,
|
|
14
|
-
alertThresholdMax: 100,
|
|
15
|
-
/** Thresholds a bot starts with, for the monthly spend cap. */
|
|
16
|
-
spendCapDefaultThresholds: [80, 100],
|
|
17
|
-
/** Rate alert: minutes of the UTC day above `rateAlertDefaultPercent` of the rate, by default. */
|
|
18
|
-
rateAlertDefaultMinutes: 5,
|
|
19
|
-
rateAlertDefaultPercent: 80,
|
|
20
|
-
} as const;
|
|
21
|
-
|
|
22
|
-
/** The events per minute of a bot in one environment: the plan base plus the lots allocated to it. */
|
|
23
|
-
export interface IReflexBotEventRate {
|
|
24
|
-
/** From the plan of the organization (100, 250 or 500). */
|
|
25
|
-
baseEventsPerMinute: number;
|
|
26
|
-
/** Lots of 500 allocated to this bot, from 0 to `lotsMax`. */
|
|
27
|
-
lots: number;
|
|
28
|
-
lotsMax: number;
|
|
29
|
-
/** `baseEventsPerMinute + 500 * lots`. */
|
|
30
|
-
eventsPerMinute: number;
|
|
31
|
-
/** Event runs at once: `min(maxConcurrencyPerBot, ceil(eventsPerMinute / runsPerSlotPerMinute))`. */
|
|
32
|
-
concurrency: number;
|
|
33
|
-
/** Lots of the reserve of the organization nobody holds yet. */
|
|
34
|
-
reserveLotsFree: number;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** The lots of the reserve of the organization a bot holds in one environment. */
|
|
38
|
-
export interface IReflexBotEventRateAllocation {
|
|
39
|
-
serviceId: string;
|
|
40
|
-
environmentId: string;
|
|
41
|
-
lots: number;
|
|
42
|
-
updatedAt: Date;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** A bot going past its rate, as the Gateway counted it. */
|
|
46
|
-
export interface IReflexBotRateExcess {
|
|
47
|
-
/** Minutes of the UTC day spent above the alert percent of the rate. */
|
|
48
|
-
minutesAboveAlertToday: number;
|
|
49
|
-
/** Highest count of retained events in one minute, over the period. */
|
|
50
|
-
peakPerMinute: number;
|
|
51
|
-
/** Minutes in which at least one event was rejected for the rate. */
|
|
52
|
-
minutesAtCap: number;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** The monthly spend cap of a bot: all its consumption of the month, included credits too, at the price of the lot. */
|
|
56
|
-
export interface IReflexBotMonthlySpendCap {
|
|
57
|
-
capCents: number;
|
|
58
|
-
spentCents: number;
|
|
59
|
-
/** `spentCents / capCents`, in percent; may go past 100. */
|
|
60
|
-
usedPercent: number;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** Credits of the month a bot consumed, and its overage setting. */
|
|
64
|
-
export interface IReflexBotCredits {
|
|
65
|
-
/** `YYYY-MM`. */
|
|
66
|
-
month: string;
|
|
67
|
-
consumedMillicredits: number;
|
|
68
|
-
/** True when the bot bills overage past the credits of the organization. */
|
|
69
|
-
overageEnabled: boolean;
|
|
70
|
-
/** True when the organization allows overage of the credits metric at all. */
|
|
71
|
-
overageAllowedByOrganization: boolean;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** Alert settings of one limit of a bot. */
|
|
75
|
-
export interface IReflexBotAlertSettings {
|
|
76
|
-
/** Percent values, at most 5, each from 1 to 100. */
|
|
77
|
-
thresholds: number[];
|
|
78
|
-
email: boolean;
|
|
79
|
-
inApp: boolean;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** Alert settings of a bot in one environment. */
|
|
83
|
-
export interface IReflexBotAlerts {
|
|
84
|
-
rate: IReflexBotAlertSettings;
|
|
85
|
-
monthlySpendCap: IReflexBotAlertSettings;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/** What stops the events of a bot at the Gateway. */
|
|
89
|
-
export interface IReflexBotBlock {
|
|
90
|
-
reason: BotEventBlockReason;
|
|
91
|
-
since: Date;
|
|
92
|
-
}
|
|
1
|
+
import type { BotEventBlockReason } from '../../enum';
|
|
2
|
+
|
|
3
|
+
/** Bounds of the per-bot limits and of their alerts. */
|
|
4
|
+
export const REFLEX_BOT_LIMITS = {
|
|
5
|
+
/** Events per minute added by one lot of the `reflex-bot-events` module. */
|
|
6
|
+
eventsPerMinutePerLot: 500,
|
|
7
|
+
/** Monthly spend cap, in cents: 10 EUR by default, from 1 to 500 EUR. */
|
|
8
|
+
monthlySpendCapDefaultCents: 1000,
|
|
9
|
+
monthlySpendCapMinCents: 100,
|
|
10
|
+
monthlySpendCapMaxCents: 50000,
|
|
11
|
+
/** Alert thresholds: at most 5 values, each from 1 to 100 (percent). */
|
|
12
|
+
alertThresholdsMax: 5,
|
|
13
|
+
alertThresholdMin: 1,
|
|
14
|
+
alertThresholdMax: 100,
|
|
15
|
+
/** Thresholds a bot starts with, for the monthly spend cap. */
|
|
16
|
+
spendCapDefaultThresholds: [80, 100],
|
|
17
|
+
/** Rate alert: minutes of the UTC day above `rateAlertDefaultPercent` of the rate, by default. */
|
|
18
|
+
rateAlertDefaultMinutes: 5,
|
|
19
|
+
rateAlertDefaultPercent: 80,
|
|
20
|
+
} as const;
|
|
21
|
+
|
|
22
|
+
/** The events per minute of a bot in one environment: the plan base plus the lots allocated to it. */
|
|
23
|
+
export interface IReflexBotEventRate {
|
|
24
|
+
/** From the plan of the organization (100, 250 or 500). */
|
|
25
|
+
baseEventsPerMinute: number;
|
|
26
|
+
/** Lots of 500 allocated to this bot, from 0 to `lotsMax`. */
|
|
27
|
+
lots: number;
|
|
28
|
+
lotsMax: number;
|
|
29
|
+
/** `baseEventsPerMinute + 500 * lots`. */
|
|
30
|
+
eventsPerMinute: number;
|
|
31
|
+
/** Event runs at once: `min(maxConcurrencyPerBot, ceil(eventsPerMinute / runsPerSlotPerMinute))`. */
|
|
32
|
+
concurrency: number;
|
|
33
|
+
/** Lots of the reserve of the organization nobody holds yet. */
|
|
34
|
+
reserveLotsFree: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The lots of the reserve of the organization a bot holds in one environment. */
|
|
38
|
+
export interface IReflexBotEventRateAllocation {
|
|
39
|
+
serviceId: string;
|
|
40
|
+
environmentId: string;
|
|
41
|
+
lots: number;
|
|
42
|
+
updatedAt: Date;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A bot going past its rate, as the Gateway counted it. */
|
|
46
|
+
export interface IReflexBotRateExcess {
|
|
47
|
+
/** Minutes of the UTC day spent above the alert percent of the rate. */
|
|
48
|
+
minutesAboveAlertToday: number;
|
|
49
|
+
/** Highest count of retained events in one minute, over the period. */
|
|
50
|
+
peakPerMinute: number;
|
|
51
|
+
/** Minutes in which at least one event was rejected for the rate. */
|
|
52
|
+
minutesAtCap: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The monthly spend cap of a bot: all its consumption of the month, included credits too, at the price of the lot. */
|
|
56
|
+
export interface IReflexBotMonthlySpendCap {
|
|
57
|
+
capCents: number;
|
|
58
|
+
spentCents: number;
|
|
59
|
+
/** `spentCents / capCents`, in percent; may go past 100. */
|
|
60
|
+
usedPercent: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Credits of the month a bot consumed, and its overage setting. */
|
|
64
|
+
export interface IReflexBotCredits {
|
|
65
|
+
/** `YYYY-MM`. */
|
|
66
|
+
month: string;
|
|
67
|
+
consumedMillicredits: number;
|
|
68
|
+
/** True when the bot bills overage past the credits of the organization. */
|
|
69
|
+
overageEnabled: boolean;
|
|
70
|
+
/** True when the organization allows overage of the credits metric at all. */
|
|
71
|
+
overageAllowedByOrganization: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Alert settings of one limit of a bot. */
|
|
75
|
+
export interface IReflexBotAlertSettings {
|
|
76
|
+
/** Percent values, at most 5, each from 1 to 100. */
|
|
77
|
+
thresholds: number[];
|
|
78
|
+
email: boolean;
|
|
79
|
+
inApp: boolean;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Alert settings of a bot in one environment. */
|
|
83
|
+
export interface IReflexBotAlerts {
|
|
84
|
+
rate: IReflexBotAlertSettings;
|
|
85
|
+
monthlySpendCap: IReflexBotAlertSettings;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** What stops the events of a bot at the Gateway. */
|
|
89
|
+
export interface IReflexBotBlock {
|
|
90
|
+
reason: BotEventBlockReason;
|
|
91
|
+
since: Date;
|
|
92
|
+
}
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DiscordEventDropReason,
|
|
3
|
-
DiscordEventFilterName,
|
|
4
|
-
DiscordEventStatus,
|
|
5
|
-
DiscordEventType,
|
|
6
|
-
} from '../../enum';
|
|
7
|
-
|
|
8
|
-
/** A retained event, from the inbox of the execution plane. */
|
|
9
|
-
export interface IReflexDiscordEventLogRetained {
|
|
10
|
-
id: string;
|
|
11
|
-
eventType: DiscordEventType;
|
|
12
|
-
guildId: string | null;
|
|
13
|
-
channelId: string | null;
|
|
14
|
-
authorId: string | null;
|
|
15
|
-
receivedAt: Date;
|
|
16
|
-
status: DiscordEventStatus;
|
|
17
|
-
triggerId: string;
|
|
18
|
-
/** The name of the trigger in the version in service; null when that version no longer has it. */
|
|
19
|
-
triggerName: string | null;
|
|
20
|
-
functionId: string | null;
|
|
21
|
-
/** The execution it started; null before it ran. */
|
|
22
|
-
liveRunId: string | null;
|
|
23
|
-
durationMs: number | null;
|
|
24
|
-
costMillicredits: number | null;
|
|
25
|
-
/** Failure code of a FAILED event: `EVENT_TRIGGER_REMOVED` or the error code of the run; null otherwise. */
|
|
26
|
-
failureCode: string | null;
|
|
27
|
-
/** The id of its inbox row without dashes. */
|
|
28
|
-
traceId: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** A dropped event, from the sample kept per bot and per reason. */
|
|
32
|
-
export interface IReflexDiscordEventLogDropped {
|
|
33
|
-
id: string;
|
|
34
|
-
eventType: DiscordEventType;
|
|
35
|
-
guildId: string | null;
|
|
36
|
-
channelId: string | null;
|
|
37
|
-
authorId: string | null;
|
|
38
|
-
receivedAt: Date;
|
|
39
|
-
reason: DiscordEventDropReason;
|
|
40
|
-
/** The filter that rejected it, when `reason` is FILTERED; null otherwise. */
|
|
41
|
-
filterName: DiscordEventFilterName | null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** Shown instead of the events when Discord refused the intents (close code 4014): it sends none, so none can be listed. */
|
|
45
|
-
export interface IReflexDiscordEventLogIntentsRefused {
|
|
46
|
-
since: Date;
|
|
47
|
-
/** The privileged intents the version in service asks for, as Discord intent bits. */
|
|
48
|
-
privilegedIntents: number[];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** One page of the event log of a bot in one environment. */
|
|
52
|
-
export interface IReflexDiscordEventLogPage {
|
|
53
|
-
retained: IReflexDiscordEventLogRetained[];
|
|
54
|
-
dropped: IReflexDiscordEventLogDropped[];
|
|
55
|
-
/** Null unless the bot is refused its intents. */
|
|
56
|
-
intentsRefused: IReflexDiscordEventLogIntentsRefused | null;
|
|
57
|
-
nextCursor: string | null;
|
|
58
|
-
}
|
|
1
|
+
import type {
|
|
2
|
+
DiscordEventDropReason,
|
|
3
|
+
DiscordEventFilterName,
|
|
4
|
+
DiscordEventStatus,
|
|
5
|
+
DiscordEventType,
|
|
6
|
+
} from '../../enum';
|
|
7
|
+
|
|
8
|
+
/** A retained event, from the inbox of the execution plane. */
|
|
9
|
+
export interface IReflexDiscordEventLogRetained {
|
|
10
|
+
id: string;
|
|
11
|
+
eventType: DiscordEventType;
|
|
12
|
+
guildId: string | null;
|
|
13
|
+
channelId: string | null;
|
|
14
|
+
authorId: string | null;
|
|
15
|
+
receivedAt: Date;
|
|
16
|
+
status: DiscordEventStatus;
|
|
17
|
+
triggerId: string;
|
|
18
|
+
/** The name of the trigger in the version in service; null when that version no longer has it. */
|
|
19
|
+
triggerName: string | null;
|
|
20
|
+
functionId: string | null;
|
|
21
|
+
/** The execution it started; null before it ran. */
|
|
22
|
+
liveRunId: string | null;
|
|
23
|
+
durationMs: number | null;
|
|
24
|
+
costMillicredits: number | null;
|
|
25
|
+
/** Failure code of a FAILED event: `EVENT_TRIGGER_REMOVED` or the error code of the run; null otherwise. */
|
|
26
|
+
failureCode: string | null;
|
|
27
|
+
/** The id of its inbox row without dashes. */
|
|
28
|
+
traceId: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** A dropped event, from the sample kept per bot and per reason. */
|
|
32
|
+
export interface IReflexDiscordEventLogDropped {
|
|
33
|
+
id: string;
|
|
34
|
+
eventType: DiscordEventType;
|
|
35
|
+
guildId: string | null;
|
|
36
|
+
channelId: string | null;
|
|
37
|
+
authorId: string | null;
|
|
38
|
+
receivedAt: Date;
|
|
39
|
+
reason: DiscordEventDropReason;
|
|
40
|
+
/** The filter that rejected it, when `reason` is FILTERED; null otherwise. */
|
|
41
|
+
filterName: DiscordEventFilterName | null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Shown instead of the events when Discord refused the intents (close code 4014): it sends none, so none can be listed. */
|
|
45
|
+
export interface IReflexDiscordEventLogIntentsRefused {
|
|
46
|
+
since: Date;
|
|
47
|
+
/** The privileged intents the version in service asks for, as Discord intent bits. */
|
|
48
|
+
privilegedIntents: number[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** One page of the event log of a bot in one environment. */
|
|
52
|
+
export interface IReflexDiscordEventLogPage {
|
|
53
|
+
retained: IReflexDiscordEventLogRetained[];
|
|
54
|
+
dropped: IReflexDiscordEventLogDropped[];
|
|
55
|
+
/** Null unless the bot is refused its intents. */
|
|
56
|
+
intentsRefused: IReflexDiscordEventLogIntentsRefused | null;
|
|
57
|
+
nextCursor: string | null;
|
|
58
|
+
}
|
|
@@ -1,77 +1,79 @@
|
|
|
1
|
-
import type { DiscordEventType } from '../../enum';
|
|
2
|
-
|
|
3
|
-
/** Bounds of the Discord event triggers of a bot; the API, the Gateway and their databases apply the same ones. */
|
|
4
|
-
export const REFLEX_DISCORD_EVENT_LIMITS = {
|
|
5
|
-
/** `^[-_a-z0-9]{1,32}$`: the name of a trigger, unique within the Service. */
|
|
6
|
-
namePattern: /^[-_a-z0-9]{1,32}$/,
|
|
7
|
-
nameMaxLength: 32,
|
|
8
|
-
maxTriggersPerService: 25,
|
|
9
|
-
guildIdsMax: 25,
|
|
10
|
-
channelIdsMax: 50,
|
|
11
|
-
roleIdsMax: 25,
|
|
12
|
-
contentPrefixMaxLength: 32,
|
|
13
|
-
/** Characters of the payload of a retained event, serialized to JSON. */
|
|
14
|
-
payloadMaxLength: 8192,
|
|
15
|
-
/** Characters of the summary kept with an event, retained or dropped. */
|
|
16
|
-
summaryMaxLength: 512,
|
|
17
|
-
/** Dropped events kept as a sample, per bot and per reason. */
|
|
18
|
-
dropSamplesPerReason: 200,
|
|
19
|
-
/** Lateness past which a retained event is EXPIRED instead of run. */
|
|
20
|
-
toleranceMinutes: 15,
|
|
21
|
-
} as const;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* What one bot can take in (decision 6 of the J2 spec).
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/** `
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
/** True when absent
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
import type { DiscordEventType } from '../../enum';
|
|
2
|
+
|
|
3
|
+
/** Bounds of the Discord event triggers of a bot; the API, the Gateway and their databases apply the same ones. */
|
|
4
|
+
export const REFLEX_DISCORD_EVENT_LIMITS = {
|
|
5
|
+
/** `^[-_a-z0-9]{1,32}$`: the name of a trigger, unique within the Service. */
|
|
6
|
+
namePattern: /^[-_a-z0-9]{1,32}$/,
|
|
7
|
+
nameMaxLength: 32,
|
|
8
|
+
maxTriggersPerService: 25,
|
|
9
|
+
guildIdsMax: 25,
|
|
10
|
+
channelIdsMax: 50,
|
|
11
|
+
roleIdsMax: 25,
|
|
12
|
+
contentPrefixMaxLength: 32,
|
|
13
|
+
/** Characters of the payload of a retained event, serialized to JSON. */
|
|
14
|
+
payloadMaxLength: 8192,
|
|
15
|
+
/** Characters of the summary kept with an event, retained or dropped. */
|
|
16
|
+
summaryMaxLength: 512,
|
|
17
|
+
/** Dropped events kept as a sample, per bot and per reason. */
|
|
18
|
+
dropSamplesPerReason: 200,
|
|
19
|
+
/** Lateness past which a retained event is EXPIRED instead of run. */
|
|
20
|
+
toleranceMinutes: 15,
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* What one bot can take in (decision 6 of the J2 spec, ADR-0307). Measured on staging (C1, run 2, 24/11/2026, after
|
|
25
|
+
* the per-bot claim and the sharded rollups): a bot sustains about 3 000 events per minute, bounded by the database
|
|
26
|
+
* (WAL and the `execution_counters` row) more than by its slots: 20 usable slots at 150 each on staging. The formula
|
|
27
|
+
* `min(lotsMaxCeiling, floor((maxConcurrencyPerBot * runsPerSlotPerMinute - base) / 500))` is kept, with
|
|
28
|
+
* `maxConcurrencyPerBot × runsPerSlotPerMinute` = 30 × 100 = the measured 3 000; `lotsMax` is its value for the largest base.
|
|
29
|
+
*/
|
|
30
|
+
export const REFLEX_BOT_EVENT_CAPACITY = {
|
|
31
|
+
/** With `maxConcurrencyPerBot` (the configuration ceiling 30), keeps the product at the measured 3 000 per bot. */
|
|
32
|
+
runsPerSlotPerMinute: 100,
|
|
33
|
+
/** `maxReplicas` (3) times the ceiling per pod (10) of the edge fleet. */
|
|
34
|
+
maxConcurrencyPerBot: 30,
|
|
35
|
+
/** The most lots of 500 events per minute a bot can be allocated, whatever the measure says. */
|
|
36
|
+
lotsMaxCeiling: 40,
|
|
37
|
+
/** The most lots a bot can be allocated: floor((30 × 100 − 500) / 500) = 5. */
|
|
38
|
+
lotsMax: 5,
|
|
39
|
+
} as const;
|
|
40
|
+
|
|
41
|
+
/** Optional filters of a trigger, combined with AND. An absent or empty list is no filter. */
|
|
42
|
+
export interface IReflexDiscordEventFilters {
|
|
43
|
+
/** 25 at most, every type. */
|
|
44
|
+
guildIds?: string[];
|
|
45
|
+
/** 50 at most, message and reaction. */
|
|
46
|
+
channelIds?: string[];
|
|
47
|
+
/** 25 at most, member arrival, message and reaction: the member has one of these roles. */
|
|
48
|
+
roleIds?: string[];
|
|
49
|
+
/** 32 characters at most, message: the content starts with it; needs the MESSAGE_CONTENT intent. */
|
|
50
|
+
contentPrefix?: string;
|
|
51
|
+
/** True when absent: an author or member that is a bot is ignored. */
|
|
52
|
+
ignoreBots?: boolean;
|
|
53
|
+
/** True when absent, message and reaction: the bot itself is ignored. */
|
|
54
|
+
ignoreSelf?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A Discord event trigger of the draft of a bot Service: a named target of one event type. */
|
|
58
|
+
export interface IReflexDiscordEvent {
|
|
59
|
+
id: string;
|
|
60
|
+
serviceId: string;
|
|
61
|
+
/** A function of the same Service. */
|
|
62
|
+
functionId: string;
|
|
63
|
+
/** Unique within the Service. */
|
|
64
|
+
name: string;
|
|
65
|
+
eventType: DiscordEventType;
|
|
66
|
+
filters: IReflexDiscordEventFilters;
|
|
67
|
+
/** True by default: events of one channel (or one server for member events) run one after the other. */
|
|
68
|
+
ordered: boolean;
|
|
69
|
+
/** False by default, MESSAGE_CREATE only: the function receives the message content. */
|
|
70
|
+
includeContent: boolean;
|
|
71
|
+
createdAt: Date;
|
|
72
|
+
updatedAt: Date;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** A Discord event trigger as a version of the Service froze it. */
|
|
76
|
+
export type IReflexDiscordEventSnapshot = Pick<
|
|
77
|
+
IReflexDiscordEvent,
|
|
78
|
+
'id' | 'functionId' | 'name' | 'eventType' | 'filters' | 'ordered' | 'includeContent'
|
|
79
|
+
>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
DiscordActivityType,
|
|
3
|
+
DiscordChannelType,
|
|
3
4
|
DiscordComponentKind,
|
|
5
|
+
DiscordLocale,
|
|
4
6
|
DiscordGatewayFailureCode,
|
|
5
7
|
DiscordGatewayState,
|
|
6
8
|
DiscordOptionType,
|
|
@@ -19,15 +21,29 @@ export const REFLEX_DISCORD_LIMITS = {
|
|
|
19
21
|
/** `^[a-z0-9_-]{1,40}$`: the start of the `custom_id` of a button, a menu or a form. */
|
|
20
22
|
componentPrefixPattern: /^[a-z0-9_-]{1,40}$/,
|
|
21
23
|
syncErrorMaxLength: 500,
|
|
24
|
+
/** Bounds of `minLength` and `maxLength` of a STRING option (`maxLength` is 1 at least). */
|
|
25
|
+
optionLengthMax: 6000,
|
|
26
|
+
/** Length of the name of a choice, localized or not. */
|
|
27
|
+
choiceNameMaxLength: 100,
|
|
22
28
|
} as const;
|
|
23
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Translations of a name or a description, by Discord locale. A localized command or option name
|
|
32
|
+
* follows `commandNamePattern`, a description 1 to 100 characters, a choice name 1 to 100.
|
|
33
|
+
*/
|
|
34
|
+
export type ReflexDiscordLocalizations = Partial<Record<DiscordLocale, string>>;
|
|
35
|
+
|
|
24
36
|
/** A fixed answer a user picks for a STRING, INTEGER or NUMBER option. */
|
|
25
37
|
export interface IReflexDiscordOptionChoice {
|
|
26
38
|
name: string;
|
|
27
39
|
value: string | number;
|
|
40
|
+
nameLocalizations?: ReflexDiscordLocalizations;
|
|
28
41
|
}
|
|
29
42
|
|
|
30
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* An option of a command. Required options come first. A bound only exists on the types it applies
|
|
45
|
+
* to: the API refuses it on another one.
|
|
46
|
+
*/
|
|
31
47
|
export interface IReflexDiscordCommandOption {
|
|
32
48
|
type: DiscordOptionType;
|
|
33
49
|
/** Same pattern as the command name. */
|
|
@@ -35,8 +51,18 @@ export interface IReflexDiscordCommandOption {
|
|
|
35
51
|
/** 1 to 100 characters. */
|
|
36
52
|
description: string;
|
|
37
53
|
required: boolean;
|
|
38
|
-
/** 25 at most, only for STRING, INTEGER and NUMBER
|
|
54
|
+
/** 25 at most, only for STRING, INTEGER and NUMBER; within `minValue`/`maxValue` and `minLength`/`maxLength`. */
|
|
39
55
|
choices?: IReflexDiscordOptionChoice[];
|
|
56
|
+
/** INTEGER and NUMBER: safe numbers, `minValue` <= `maxValue`. */
|
|
57
|
+
minValue?: number;
|
|
58
|
+
maxValue?: number;
|
|
59
|
+
/** STRING: 0 to 6000 (`maxLength` 1 at least), `minLength` <= `maxLength`. */
|
|
60
|
+
minLength?: number;
|
|
61
|
+
maxLength?: number;
|
|
62
|
+
/** CHANNEL: the channel types a user may pick, not empty, no duplicate. */
|
|
63
|
+
channelTypes?: DiscordChannelType[];
|
|
64
|
+
nameLocalizations?: ReflexDiscordLocalizations;
|
|
65
|
+
descriptionLocalizations?: ReflexDiscordLocalizations;
|
|
40
66
|
}
|
|
41
67
|
|
|
42
68
|
/** A slash command of the draft of a Discord bot Service. */
|
|
@@ -52,6 +78,14 @@ export interface IReflexDiscordCommand {
|
|
|
52
78
|
/** Discord permission bits as a decimal string, or null for everyone. */
|
|
53
79
|
defaultMemberPermissions: string | null;
|
|
54
80
|
allowedInDirectMessages: boolean;
|
|
81
|
+
/** Null without translations. */
|
|
82
|
+
nameLocalizations: ReflexDiscordLocalizations | null;
|
|
83
|
+
descriptionLocalizations: ReflexDiscordLocalizations | null;
|
|
84
|
+
/**
|
|
85
|
+
* Users may install the bot on their account and use the command outside the servers it is in (in
|
|
86
|
+
* group messages too). It can then act on no server in the bot's name.
|
|
87
|
+
*/
|
|
88
|
+
userInstallable: boolean;
|
|
55
89
|
createdAt: Date;
|
|
56
90
|
updatedAt: Date;
|
|
57
91
|
}
|
|
@@ -69,7 +103,10 @@ export interface IReflexDiscordComponent {
|
|
|
69
103
|
updatedAt: Date;
|
|
70
104
|
}
|
|
71
105
|
|
|
72
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* A command as a version of the Service froze it. The fields of card 846 are only there when set (a
|
|
108
|
+
* translation, `userInstallable` true): a command without them keeps the fingerprint it had.
|
|
109
|
+
*/
|
|
73
110
|
export type IReflexDiscordCommandSnapshot = Pick<
|
|
74
111
|
IReflexDiscordCommand,
|
|
75
112
|
| 'id'
|
|
@@ -79,7 +116,11 @@ export type IReflexDiscordCommandSnapshot = Pick<
|
|
|
79
116
|
| 'options'
|
|
80
117
|
| 'defaultMemberPermissions'
|
|
81
118
|
| 'allowedInDirectMessages'
|
|
82
|
-
|
|
119
|
+
> & {
|
|
120
|
+
nameLocalizations?: ReflexDiscordLocalizations;
|
|
121
|
+
descriptionLocalizations?: ReflexDiscordLocalizations;
|
|
122
|
+
userInstallable?: true;
|
|
123
|
+
};
|
|
83
124
|
|
|
84
125
|
/** A component as a version of the Service froze it. */
|
|
85
126
|
export type IReflexDiscordComponentSnapshot = Pick<
|