@abyss-project/reflex 5.7.0 → 5.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +32 -32
- package/.prettierrc +5 -5
- package/README.md +15 -15
- 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.js.map +1 -1
- package/dist/types/interface/models/reflex-discord.model.d.ts +22 -2
- package/dist/types/interface/models/reflex-discord.model.js +6 -1
- package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
- package/jest.config.ts +11 -11
- package/package.json +1 -1
- package/src/api/function-access.api.ts +36 -36
- package/src/api/function-insights.api.test.ts +27 -27
- package/src/api/function-insights.api.ts +18 -18
- package/src/api/function-run.api.ts +38 -38
- package/src/api/function-settings.api.ts +59 -59
- package/src/api/function-test.api.ts +34 -34
- package/src/api/function-version.api.ts +48 -48
- package/src/api/function.api.test.ts +249 -249
- package/src/api/function.api.ts +62 -62
- package/src/api/health.api.ts +10 -10
- package/src/api/index.ts +17 -17
- package/src/api/service-configuration.api.ts +16 -16
- package/src/api/service-deployment.api.ts +79 -79
- 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/api/service-route.api.ts +72 -72
- package/src/api/service-task.api.test.ts +140 -140
- package/src/api/service-task.api.ts +141 -141
- package/src/api/service-version.api.ts +54 -54
- package/src/api/service.api.test.ts +215 -215
- package/src/api/service.api.ts +55 -55
- 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/access-grant-status.enum.ts +12 -12
- package/src/types/enum/access-kind.enum.ts +7 -7
- package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
- package/src/types/enum/configuration-read-as.enum.ts +5 -5
- package/src/types/enum/discord-activity-type.enum.ts +9 -9
- package/src/types/enum/discord-channel-type.enum.ts +11 -0
- package/src/types/enum/discord-component-kind.enum.ts +7 -7
- 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-gateway-state.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/discord-option-type.enum.ts +12 -12
- package/src/types/enum/discord-presence-status.enum.ts +8 -8
- package/src/types/enum/discord-sync-status.enum.ts +6 -6
- package/src/types/enum/discord-token-state.enum.ts +11 -11
- package/src/types/enum/execution-mode.enum.ts +9 -9
- package/src/types/enum/execution-profile.enum.ts +20 -20
- package/src/types/enum/execution-settings-source.enum.ts +9 -9
- package/src/types/enum/health-status.enum.ts +4 -4
- 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/route-method.enum.ts +9 -9
- package/src/types/enum/run-log-level.enum.ts +6 -6
- package/src/types/enum/run-mode.enum.ts +11 -11
- package/src/types/enum/run-status.enum.ts +11 -11
- package/src/types/enum/run-step-status.enum.ts +7 -7
- package/src/types/enum/schedule-sync-status.enum.ts +6 -6
- package/src/types/enum/scheduled-run-failure-code.enum.ts +12 -12
- package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
- package/src/types/enum/scheduled-run-status.enum.ts +17 -17
- package/src/types/enum/service-deployment-action.enum.ts +11 -11
- package/src/types/enum/service-deployment-status.enum.ts +5 -5
- package/src/types/enum/service-type.enum.ts +9 -9
- package/src/types/enum/service-version-change-kind.enum.ts +6 -6
- package/src/types/enum/trace-effect-type.enum.ts +12 -12
- package/src/types/enum/trigger-access-mode.enum.ts +12 -12
- package/src/types/enum/trigger-kind.enum.ts +8 -8
- package/src/types/enum/vault-value-source.enum.ts +12 -12
- package/src/types/enum/vault-visibility.enum.ts +5 -5
- package/src/types/index.ts +2 -2
- package/src/types/interface/api/index.ts +3 -3
- package/src/types/interface/api/requests/function-access.request.ts +25 -25
- package/src/types/interface/api/requests/function-run.request.ts +30 -30
- package/src/types/interface/api/requests/function-settings.request.ts +27 -27
- package/src/types/interface/api/requests/function-test.request.ts +39 -39
- package/src/types/interface/api/requests/function-version.request.ts +20 -20
- package/src/types/interface/api/requests/function.request.ts +36 -36
- package/src/types/interface/api/requests/index.ts +15 -15
- package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
- package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
- 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/requests/service-route.request.ts +44 -44
- package/src/types/interface/api/requests/service-task.request.ts +80 -80
- package/src/types/interface/api/requests/service-version.request.ts +24 -24
- package/src/types/interface/api/requests/service.request.ts +46 -46
- package/src/types/interface/api/response.ts +4 -4
- package/src/types/interface/api/responses/function-access.response.ts +17 -17
- package/src/types/interface/api/responses/function-run.response.ts +18 -18
- package/src/types/interface/api/responses/function-settings.response.ts +36 -36
- package/src/types/interface/api/responses/function-test.response.ts +12 -12
- package/src/types/interface/api/responses/function-version.response.ts +31 -31
- package/src/types/interface/api/responses/function.response.ts +25 -25
- package/src/types/interface/api/responses/index.ts +15 -15
- package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
- package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
- 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-route.response.ts +31 -31
- package/src/types/interface/api/responses/service-task.response.ts +57 -57
- package/src/types/interface/api/responses/service-version.response.ts +106 -106
- package/src/types/interface/api/responses/service.response.ts +31 -31
- package/src/types/interface/health.response.ts +7 -7
- package/src/types/interface/index.ts +3 -3
- package/src/types/interface/models/index.ts +19 -19
- package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
- package/src/types/interface/models/reflex-bot-limits.model.ts +92 -92
- package/src/types/interface/models/reflex-definition.model.ts +31 -31
- package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -58
- package/src/types/interface/models/reflex-discord-event.model.ts +79 -78
- package/src/types/interface/models/reflex-discord.model.ts +54 -4
- package/src/types/interface/models/reflex-execution-settings.model.ts +50 -50
- package/src/types/interface/models/reflex-function-version.model.ts +14 -14
- package/src/types/interface/models/reflex-function.model.ts +16 -16
- package/src/types/interface/models/reflex-insights.model.ts +120 -120
- package/src/types/interface/models/reflex-price-list.model.ts +20 -20
- package/src/types/interface/models/reflex-route.model.ts +19 -19
- package/src/types/interface/models/reflex-run.model.ts +186 -186
- package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
- package/src/types/interface/models/reflex-service-deployment.model.ts +46 -46
- package/src/types/interface/models/reflex-service-version.model.ts +61 -61
- package/src/types/interface/models/reflex-service.model.ts +45 -45
- package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
- package/src/types/interface/models/reflex-task.model.ts +97 -97
- package/tsconfig.check.json +15 -15
- package/tsconfig.json +35 -35
|
@@ -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,78 +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, ADR-
|
|
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)
|
|
27
|
-
* `min(lotsMaxCeiling, floor((maxConcurrencyPerBot * runsPerSlotPerMinute - base) / 500))`
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
78
|
-
|
|
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,
|
|
@@ -12,6 +14,11 @@ import type {
|
|
|
12
14
|
export const REFLEX_DISCORD_LIMITS = {
|
|
13
15
|
/** `^[-_a-z0-9]{1,32}$`: the name typed after the slash. */
|
|
14
16
|
commandNamePattern: /^[-_a-z0-9]{1,32}$/,
|
|
17
|
+
/**
|
|
18
|
+
* Discord's pattern of a translated command or option name: letters and digits of any script, `-`, `_` and
|
|
19
|
+
* `'`, 1 to 32 characters. It must also be lower case where the script has one (see `isValidLocalizedName`).
|
|
20
|
+
*/
|
|
21
|
+
localizedNamePattern: /^[-_'\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$/u,
|
|
15
22
|
commandDescriptionMaxLength: 100,
|
|
16
23
|
commandsPerServiceMax: 100,
|
|
17
24
|
optionsPerCommandMax: 25,
|
|
@@ -19,15 +26,33 @@ export const REFLEX_DISCORD_LIMITS = {
|
|
|
19
26
|
/** `^[a-z0-9_-]{1,40}$`: the start of the `custom_id` of a button, a menu or a form. */
|
|
20
27
|
componentPrefixPattern: /^[a-z0-9_-]{1,40}$/,
|
|
21
28
|
syncErrorMaxLength: 500,
|
|
29
|
+
/** Bounds of `minLength` and `maxLength` of a STRING option (`maxLength` is 1 at least). */
|
|
30
|
+
optionLengthMax: 6000,
|
|
31
|
+
/** Length of the name of a choice, localized or not. */
|
|
32
|
+
choiceNameMaxLength: 100,
|
|
22
33
|
} as const;
|
|
23
34
|
|
|
35
|
+
/** A translated command or option name Discord accepts: its pattern, and lower case where the script has one. */
|
|
36
|
+
export const isValidLocalizedName = (name: string): boolean =>
|
|
37
|
+
REFLEX_DISCORD_LIMITS.localizedNamePattern.test(name) && name === name.toLowerCase();
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Translations of a name or a description, by Discord locale. A localized command or option name
|
|
41
|
+
* passes `isValidLocalizedName`, a description 1 to 100 characters, a choice name 1 to 100.
|
|
42
|
+
*/
|
|
43
|
+
export type ReflexDiscordLocalizations = Partial<Record<DiscordLocale, string>>;
|
|
44
|
+
|
|
24
45
|
/** A fixed answer a user picks for a STRING, INTEGER or NUMBER option. */
|
|
25
46
|
export interface IReflexDiscordOptionChoice {
|
|
26
47
|
name: string;
|
|
27
48
|
value: string | number;
|
|
49
|
+
nameLocalizations?: ReflexDiscordLocalizations;
|
|
28
50
|
}
|
|
29
51
|
|
|
30
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* An option of a command. Required options come first. A bound only exists on the types it applies
|
|
54
|
+
* to: the API refuses it on another one.
|
|
55
|
+
*/
|
|
31
56
|
export interface IReflexDiscordCommandOption {
|
|
32
57
|
type: DiscordOptionType;
|
|
33
58
|
/** Same pattern as the command name. */
|
|
@@ -35,8 +60,18 @@ export interface IReflexDiscordCommandOption {
|
|
|
35
60
|
/** 1 to 100 characters. */
|
|
36
61
|
description: string;
|
|
37
62
|
required: boolean;
|
|
38
|
-
/** 25 at most, only for STRING, INTEGER and NUMBER
|
|
63
|
+
/** 25 at most, only for STRING, INTEGER and NUMBER; within `minValue`/`maxValue` and `minLength`/`maxLength`. */
|
|
39
64
|
choices?: IReflexDiscordOptionChoice[];
|
|
65
|
+
/** INTEGER and NUMBER: safe numbers, `minValue` <= `maxValue`. */
|
|
66
|
+
minValue?: number;
|
|
67
|
+
maxValue?: number;
|
|
68
|
+
/** STRING: 0 to 6000 (`maxLength` 1 at least), `minLength` <= `maxLength`. */
|
|
69
|
+
minLength?: number;
|
|
70
|
+
maxLength?: number;
|
|
71
|
+
/** CHANNEL: the channel types a user may pick, not empty, no duplicate. */
|
|
72
|
+
channelTypes?: DiscordChannelType[];
|
|
73
|
+
nameLocalizations?: ReflexDiscordLocalizations;
|
|
74
|
+
descriptionLocalizations?: ReflexDiscordLocalizations;
|
|
40
75
|
}
|
|
41
76
|
|
|
42
77
|
/** A slash command of the draft of a Discord bot Service. */
|
|
@@ -52,6 +87,14 @@ export interface IReflexDiscordCommand {
|
|
|
52
87
|
/** Discord permission bits as a decimal string, or null for everyone. */
|
|
53
88
|
defaultMemberPermissions: string | null;
|
|
54
89
|
allowedInDirectMessages: boolean;
|
|
90
|
+
/** Null without translations. */
|
|
91
|
+
nameLocalizations: ReflexDiscordLocalizations | null;
|
|
92
|
+
descriptionLocalizations: ReflexDiscordLocalizations | null;
|
|
93
|
+
/**
|
|
94
|
+
* Users may install the bot on their account and use the command outside the servers it is in (in
|
|
95
|
+
* group messages too). It can then act on no server in the bot's name.
|
|
96
|
+
*/
|
|
97
|
+
userInstallable: boolean;
|
|
55
98
|
createdAt: Date;
|
|
56
99
|
updatedAt: Date;
|
|
57
100
|
}
|
|
@@ -69,7 +112,10 @@ export interface IReflexDiscordComponent {
|
|
|
69
112
|
updatedAt: Date;
|
|
70
113
|
}
|
|
71
114
|
|
|
72
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* A command as a version of the Service froze it. The fields of card 846 are only there when set (a
|
|
117
|
+
* translation, `userInstallable` true): a command without them keeps the fingerprint it had.
|
|
118
|
+
*/
|
|
73
119
|
export type IReflexDiscordCommandSnapshot = Pick<
|
|
74
120
|
IReflexDiscordCommand,
|
|
75
121
|
| 'id'
|
|
@@ -79,7 +125,11 @@ export type IReflexDiscordCommandSnapshot = Pick<
|
|
|
79
125
|
| 'options'
|
|
80
126
|
| 'defaultMemberPermissions'
|
|
81
127
|
| 'allowedInDirectMessages'
|
|
82
|
-
|
|
128
|
+
> & {
|
|
129
|
+
nameLocalizations?: ReflexDiscordLocalizations;
|
|
130
|
+
descriptionLocalizations?: ReflexDiscordLocalizations;
|
|
131
|
+
userInstallable?: true;
|
|
132
|
+
};
|
|
83
133
|
|
|
84
134
|
/** A component as a version of the Service froze it. */
|
|
85
135
|
export type IReflexDiscordComponentSnapshot = Pick<
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { ExecutionMode, ExecutionProfile } from '../../enum';
|
|
2
|
-
import type { ExecutionSettingsSource } from '../../enum';
|
|
3
|
-
|
|
4
|
-
/** The execution settings of a function in an environment. */
|
|
5
|
-
export interface IReflexExecutionSettingsValues {
|
|
6
|
-
profile: ExecutionProfile;
|
|
7
|
-
/** Past this, a synchronous caller that got no answer receives 504 and the execution goes on. */
|
|
8
|
-
responseTimeoutMs: number;
|
|
9
|
-
/** Past this, the execution is stopped with TIMEOUT. */
|
|
10
|
-
maxDurationMs: number;
|
|
11
|
-
mode: ExecutionMode;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** Bounds of the settings, in milliseconds. */
|
|
15
|
-
export const REFLEX_EXECUTION_SETTINGS_LIMITS = {
|
|
16
|
-
responseTimeoutMs: { min: 1_000, max: 100_000 },
|
|
17
|
-
maxDurationMs: { min: 1_000, max: 3_600_000 },
|
|
18
|
-
} as const;
|
|
19
|
-
|
|
20
|
-
/** What a function runs with when nothing is set. */
|
|
21
|
-
export const DEFAULT_REFLEX_EXECUTION_SETTINGS: Readonly<IReflexExecutionSettingsValues> = {
|
|
22
|
-
profile: ExecutionProfile.S,
|
|
23
|
-
responseTimeoutMs: 30_000,
|
|
24
|
-
maxDurationMs: 30_000,
|
|
25
|
-
mode: ExecutionMode.SYNC,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/** A row of settings: the default of the function (`environmentId` null) or the override of one environment. */
|
|
29
|
-
export interface IReflexExecutionSettings extends IReflexExecutionSettingsValues {
|
|
30
|
-
id: string;
|
|
31
|
-
functionId: string;
|
|
32
|
-
/** An environment of the application (abyss-main's id); null for the default of every environment. */
|
|
33
|
-
environmentId: string | null;
|
|
34
|
-
updatedByUserId: string;
|
|
35
|
-
createdAt: Date;
|
|
36
|
-
updatedAt: Date;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** What one environment of the application runs with. */
|
|
40
|
-
export interface IReflexEffectiveExecutionSettings {
|
|
41
|
-
environmentId: string;
|
|
42
|
-
/** The name of the environment (abyss-main), immutable. */
|
|
43
|
-
environmentSlug: string;
|
|
44
|
-
/** Changing what a production environment runs with needs REFLEX_PUBLISH_PRODUCTION. */
|
|
45
|
-
isProduction: boolean;
|
|
46
|
-
source: ExecutionSettingsSource;
|
|
47
|
-
settings: IReflexExecutionSettingsValues;
|
|
48
|
-
/** The version promoted in this environment, whose step statistics drive the profile warning; null when none. */
|
|
49
|
-
runningVersionId: string | null;
|
|
50
|
-
}
|
|
1
|
+
import { ExecutionMode, ExecutionProfile } from '../../enum';
|
|
2
|
+
import type { ExecutionSettingsSource } from '../../enum';
|
|
3
|
+
|
|
4
|
+
/** The execution settings of a function in an environment. */
|
|
5
|
+
export interface IReflexExecutionSettingsValues {
|
|
6
|
+
profile: ExecutionProfile;
|
|
7
|
+
/** Past this, a synchronous caller that got no answer receives 504 and the execution goes on. */
|
|
8
|
+
responseTimeoutMs: number;
|
|
9
|
+
/** Past this, the execution is stopped with TIMEOUT. */
|
|
10
|
+
maxDurationMs: number;
|
|
11
|
+
mode: ExecutionMode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Bounds of the settings, in milliseconds. */
|
|
15
|
+
export const REFLEX_EXECUTION_SETTINGS_LIMITS = {
|
|
16
|
+
responseTimeoutMs: { min: 1_000, max: 100_000 },
|
|
17
|
+
maxDurationMs: { min: 1_000, max: 3_600_000 },
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
/** What a function runs with when nothing is set. */
|
|
21
|
+
export const DEFAULT_REFLEX_EXECUTION_SETTINGS: Readonly<IReflexExecutionSettingsValues> = {
|
|
22
|
+
profile: ExecutionProfile.S,
|
|
23
|
+
responseTimeoutMs: 30_000,
|
|
24
|
+
maxDurationMs: 30_000,
|
|
25
|
+
mode: ExecutionMode.SYNC,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** A row of settings: the default of the function (`environmentId` null) or the override of one environment. */
|
|
29
|
+
export interface IReflexExecutionSettings extends IReflexExecutionSettingsValues {
|
|
30
|
+
id: string;
|
|
31
|
+
functionId: string;
|
|
32
|
+
/** An environment of the application (abyss-main's id); null for the default of every environment. */
|
|
33
|
+
environmentId: string | null;
|
|
34
|
+
updatedByUserId: string;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** What one environment of the application runs with. */
|
|
40
|
+
export interface IReflexEffectiveExecutionSettings {
|
|
41
|
+
environmentId: string;
|
|
42
|
+
/** The name of the environment (abyss-main), immutable. */
|
|
43
|
+
environmentSlug: string;
|
|
44
|
+
/** Changing what a production environment runs with needs REFLEX_PUBLISH_PRODUCTION. */
|
|
45
|
+
isProduction: boolean;
|
|
46
|
+
source: ExecutionSettingsSource;
|
|
47
|
+
settings: IReflexExecutionSettingsValues;
|
|
48
|
+
/** The version promoted in this environment, whose step statistics drive the profile warning; null when none. */
|
|
49
|
+
runningVersionId: string | null;
|
|
50
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { IReflexDefinition } from './reflex-definition.model';
|
|
2
|
-
|
|
3
|
-
export interface IReflexFunctionVersion {
|
|
4
|
-
id: string;
|
|
5
|
-
functionId: string;
|
|
6
|
-
/** 1, 2, 3...: counted per function. */
|
|
7
|
-
number: number;
|
|
8
|
-
/** The frozen definition. */
|
|
9
|
-
definition: IReflexDefinition;
|
|
10
|
-
/** SHA-256 of the definition, lowercase hex. */
|
|
11
|
-
hash: string;
|
|
12
|
-
publishedByUserId: string;
|
|
13
|
-
publishedAt: Date;
|
|
14
|
-
}
|
|
1
|
+
import type { IReflexDefinition } from './reflex-definition.model';
|
|
2
|
+
|
|
3
|
+
export interface IReflexFunctionVersion {
|
|
4
|
+
id: string;
|
|
5
|
+
functionId: string;
|
|
6
|
+
/** 1, 2, 3...: counted per function. */
|
|
7
|
+
number: number;
|
|
8
|
+
/** The frozen definition. */
|
|
9
|
+
definition: IReflexDefinition;
|
|
10
|
+
/** SHA-256 of the definition, lowercase hex. */
|
|
11
|
+
hash: string;
|
|
12
|
+
publishedByUserId: string;
|
|
13
|
+
publishedAt: Date;
|
|
14
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { IReflexDefinition } from './reflex-definition.model';
|
|
2
|
-
|
|
3
|
-
export interface IReflexFunction {
|
|
4
|
-
id: string;
|
|
5
|
-
applicationId: string;
|
|
6
|
-
/** The Service the function belongs to; deleting the Service deletes it. */
|
|
7
|
-
serviceId: string;
|
|
8
|
-
projectId: string;
|
|
9
|
-
name: string;
|
|
10
|
-
/** The definition being edited; a publication freezes a copy of it. */
|
|
11
|
-
draftDefinition: IReflexDefinition;
|
|
12
|
-
createdByUserId: string;
|
|
13
|
-
updatedByUserId: string;
|
|
14
|
-
createdAt: Date;
|
|
15
|
-
updatedAt: Date;
|
|
16
|
-
}
|
|
1
|
+
import type { IReflexDefinition } from './reflex-definition.model';
|
|
2
|
+
|
|
3
|
+
export interface IReflexFunction {
|
|
4
|
+
id: string;
|
|
5
|
+
applicationId: string;
|
|
6
|
+
/** The Service the function belongs to; deleting the Service deletes it. */
|
|
7
|
+
serviceId: string;
|
|
8
|
+
projectId: string;
|
|
9
|
+
name: string;
|
|
10
|
+
/** The definition being edited; a publication freezes a copy of it. */
|
|
11
|
+
draftDefinition: IReflexDefinition;
|
|
12
|
+
createdByUserId: string;
|
|
13
|
+
updatedByUserId: string;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
updatedAt: Date;
|
|
16
|
+
}
|