@abyss-project/reflex 6.4.0 → 6.6.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.
Files changed (133) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/README.md +15 -15
  4. package/dist/api/function-run.api.d.ts +2 -1
  5. package/dist/api/function-run.api.js +3 -1
  6. package/dist/api/function-run.api.js.map +1 -1
  7. package/dist/discord/discord-command-tree.d.ts +5 -0
  8. package/dist/discord/discord-command-tree.js +38 -0
  9. package/dist/discord/discord-command-tree.js.map +1 -0
  10. package/dist/discord/discord-event-filter-cases.js +27 -11
  11. package/dist/discord/discord-event-filter-cases.js.map +1 -1
  12. package/dist/discord/discord-event-filters.js +7 -3
  13. package/dist/discord/discord-event-filters.js.map +1 -1
  14. package/dist/discord/discord-event-intents.d.ts +8 -2
  15. package/dist/discord/discord-event-intents.js +13 -2
  16. package/dist/discord/discord-event-intents.js.map +1 -1
  17. package/dist/discord/index.d.ts +1 -0
  18. package/dist/discord/index.js +1 -0
  19. package/dist/discord/index.js.map +1 -1
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.js +1 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/types/enum/discord-command-node-type.enum.d.ts +5 -0
  24. package/dist/types/enum/discord-command-node-type.enum.js +10 -0
  25. package/dist/types/enum/discord-command-node-type.enum.js.map +1 -0
  26. package/dist/types/enum/discord-command-type.enum.d.ts +5 -0
  27. package/dist/types/enum/discord-command-type.enum.js +10 -0
  28. package/dist/types/enum/discord-command-type.enum.js.map +1 -0
  29. package/dist/types/enum/discord-event-type.enum.d.ts +3 -1
  30. package/dist/types/enum/discord-event-type.enum.js +2 -0
  31. package/dist/types/enum/discord-event-type.enum.js.map +1 -1
  32. package/dist/types/enum/index.d.ts +2 -0
  33. package/dist/types/enum/index.js +2 -0
  34. package/dist/types/enum/index.js.map +1 -1
  35. package/dist/types/enum/reflex-error-code.enum.d.ts +10 -0
  36. package/dist/types/enum/reflex-error-code.enum.js +10 -0
  37. package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
  38. package/dist/types/interface/api/requests/function-run.request.d.ts +8 -0
  39. package/dist/types/interface/api/requests/service-discord.request.d.ts +7 -3
  40. package/dist/types/interface/api/responses/function-run.response.d.ts +8 -0
  41. package/dist/types/interface/models/reflex-discord.model.d.ts +18 -2
  42. package/dist/types/interface/models/reflex-discord.model.js +4 -0
  43. package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
  44. package/dist/types/interface/models/reflex-run.model.d.ts +4 -0
  45. package/dist/types/interface/models/reflex-run.model.js +4 -1
  46. package/dist/types/interface/models/reflex-run.model.js.map +1 -1
  47. package/jest.config.ts +11 -11
  48. package/package.json +1 -1
  49. package/src/api/alert-rule.api.test.ts +72 -72
  50. package/src/api/alert-rule.api.ts +57 -57
  51. package/src/api/application-insights.api.test.ts +42 -42
  52. package/src/api/application-insights.api.ts +38 -38
  53. package/src/api/application-run-settings.api.test.ts +62 -62
  54. package/src/api/application-run-settings.api.ts +30 -30
  55. package/src/api/function-access.api.ts +87 -87
  56. package/src/api/function-insights.api.test.ts +27 -27
  57. package/src/api/function-insights.api.ts +18 -18
  58. package/src/api/function-run.api.ts +19 -0
  59. package/src/api/function-settings.api.ts +96 -96
  60. package/src/api/function-template.api.test.ts +72 -72
  61. package/src/api/function-template.api.ts +52 -52
  62. package/src/api/function-test.api.ts +34 -34
  63. package/src/api/function-version.api.ts +66 -66
  64. package/src/api/function.api.test.ts +346 -346
  65. package/src/api/function.api.ts +62 -62
  66. package/src/api/health.api.ts +10 -10
  67. package/src/api/route-stats.api.test.ts +45 -45
  68. package/src/api/route-stats.api.ts +36 -36
  69. package/src/api/service-completion-webhook.api.test.ts +97 -97
  70. package/src/api/service-completion-webhook.api.ts +39 -39
  71. package/src/api/service-configuration.api.ts +16 -16
  72. package/src/api/service-consumer.api.test.ts +104 -104
  73. package/src/api/service-consumer.api.ts +90 -90
  74. package/src/api/service-deployment.api.ts +79 -79
  75. package/src/api/service-discord-event.api.test.ts +106 -106
  76. package/src/api/service-discord-event.api.ts +78 -78
  77. package/src/api/service-discord.api.test.ts +178 -178
  78. package/src/api/service-discord.api.ts +222 -222
  79. package/src/api/service-insights.api.test.ts +36 -36
  80. package/src/api/service-insights.api.ts +42 -42
  81. package/src/api/service-limits.api.test.ts +100 -100
  82. package/src/api/service-limits.api.ts +37 -37
  83. package/src/api/service-openapi.api.test.ts +52 -52
  84. package/src/api/service-openapi.api.ts +21 -21
  85. package/src/api/service-route.api.ts +74 -74
  86. package/src/api/service-task.api.test.ts +140 -140
  87. package/src/api/service-task.api.ts +141 -141
  88. package/src/api/service-version.api.ts +54 -54
  89. package/src/api/service.api.test.ts +220 -220
  90. package/src/api/service.api.ts +55 -55
  91. package/src/api/storage-surplus.admin.api.test.ts +66 -66
  92. package/src/api/storage-surplus.admin.api.ts +45 -45
  93. package/src/discord/discord-command-tree.test.ts +47 -0
  94. package/src/discord/discord-command-tree.ts +60 -0
  95. package/src/discord/discord-event-filter-cases.ts +299 -261
  96. package/src/discord/discord-event-filters.test.ts +120 -91
  97. package/src/discord/discord-event-filters.ts +103 -95
  98. package/src/discord/discord-event-intents.test.ts +139 -112
  99. package/src/discord/discord-event-intents.ts +80 -55
  100. package/src/discord/index.ts +4 -3
  101. package/src/index.test.ts +104 -104
  102. package/src/index.ts +2 -0
  103. package/src/insights/index.ts +1 -1
  104. package/src/insights/percentiles.test.ts +75 -75
  105. package/src/insights/percentiles.ts +37 -37
  106. package/src/types/enum/discord-command-node-type.enum.ts +10 -0
  107. package/src/types/enum/discord-command-type.enum.ts +9 -0
  108. package/src/types/enum/discord-event-type.enum.ts +4 -0
  109. package/src/types/enum/discord-host-action.enum.ts +37 -37
  110. package/src/types/enum/index.ts +2 -0
  111. package/src/types/enum/reflex-error-code.enum.ts +112 -89
  112. package/src/types/interface/api/requests/application-run-settings.request.ts +13 -13
  113. package/src/types/interface/api/requests/function-run.request.ts +53 -42
  114. package/src/types/interface/api/requests/function-settings.request.ts +50 -50
  115. package/src/types/interface/api/requests/index.ts +25 -25
  116. package/src/types/interface/api/requests/service-discord.request.ts +168 -155
  117. package/src/types/interface/api/requests/service.request.ts +48 -48
  118. package/src/types/interface/api/requests/storage-surplus.admin.request.ts +12 -12
  119. package/src/types/interface/api/responses/function-run.response.ts +35 -23
  120. package/src/types/interface/api/responses/function-settings.response.ts +57 -57
  121. package/src/types/interface/api/responses/index.ts +25 -25
  122. package/src/types/interface/api/responses/storage-surplus.admin.response.ts +10 -10
  123. package/src/types/interface/models/index.ts +29 -29
  124. package/src/types/interface/models/reflex-discord.model.ts +249 -208
  125. package/src/types/interface/models/reflex-price-list.model.ts +22 -22
  126. package/src/types/interface/models/reflex-run-retention.model.ts +24 -24
  127. package/src/types/interface/models/reflex-run-settings.model.ts +39 -39
  128. package/src/types/interface/models/reflex-run.model.ts +317 -309
  129. package/src/types/interface/models/reflex-service-deployment.model.ts +48 -48
  130. package/src/types/interface/models/reflex-service.model.ts +47 -47
  131. package/src/types/interface/models/reflex-storage-surplus.model.ts +23 -23
  132. package/tsconfig.check.json +15 -15
  133. package/tsconfig.json +35 -35
@@ -1,208 +1,249 @@
1
- import type {
2
- DiscordActivityType,
3
- DiscordChannelType,
4
- DiscordComponentKind,
5
- DiscordLocale,
6
- DiscordGatewayFailureCode,
7
- DiscordGatewayState,
8
- DiscordOptionType,
9
- DiscordPresenceStatus,
10
- DiscordTokenState,
11
- } from '../../enum';
12
-
13
- /** Bounds of the commands and components of a Discord bot; the API and its database apply the same ones. */
14
- export const REFLEX_DISCORD_LIMITS = {
15
- /** `^[-_a-z0-9]{1,32}$`: the name typed after the slash. */
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,
22
- commandDescriptionMaxLength: 100,
23
- commandsPerServiceMax: 100,
24
- optionsPerCommandMax: 25,
25
- choicesPerOptionMax: 25,
26
- /** `^[a-z0-9_-]{1,40}$`: the start of the `custom_id` of a button, a menu or a form. */
27
- componentPrefixPattern: /^[a-z0-9_-]{1,40}$/,
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,
33
- /** Largest file a bot receives or sends, per bot and environment (#915): the default, and the bound the setting may not pass. */
34
- attachmentMaxBytesDefault: 2 * 1024 * 1024,
35
- attachmentMaxBytesBound: 8 * 1024 * 1024,
36
- } as const;
37
-
38
- /** A translated command or option name Discord accepts: its pattern, and lower case where the script has one. */
39
- export const isValidLocalizedName = (name: string): boolean =>
40
- REFLEX_DISCORD_LIMITS.localizedNamePattern.test(name) && name === name.toLowerCase();
41
-
42
- /**
43
- * Translations of a name or a description, by Discord locale. A localized command or option name
44
- * passes `isValidLocalizedName`, a description 1 to 100 characters, a choice name 1 to 100.
45
- */
46
- export type ReflexDiscordLocalizations = Partial<Record<DiscordLocale, string>>;
47
-
48
- /** A fixed answer a user picks for a STRING, INTEGER or NUMBER option. */
49
- export interface IReflexDiscordOptionChoice {
50
- name: string;
51
- value: string | number;
52
- nameLocalizations?: ReflexDiscordLocalizations;
53
- }
54
-
55
- /**
56
- * An option of a command. Required options come first. A bound only exists on the types it applies
57
- * to: the API refuses it on another one.
58
- */
59
- export interface IReflexDiscordCommandOption {
60
- type: DiscordOptionType;
61
- /** Same pattern as the command name. */
62
- name: string;
63
- /** 1 to 100 characters. */
64
- description: string;
65
- required: boolean;
66
- /** 25 at most, only for STRING, INTEGER and NUMBER; within `minValue`/`maxValue` and `minLength`/`maxLength`. */
67
- choices?: IReflexDiscordOptionChoice[];
68
- /**
69
- * Discord asks the function for the choices while the user types. Only for STRING, INTEGER and NUMBER,
70
- * never together with `choices`. Absent means false.
71
- */
72
- autocomplete?: boolean;
73
- /** INTEGER and NUMBER: safe numbers, `minValue` <= `maxValue`. */
74
- minValue?: number;
75
- maxValue?: number;
76
- /** STRING: 0 to 6000 (`maxLength` 1 at least), `minLength` <= `maxLength`. */
77
- minLength?: number;
78
- maxLength?: number;
79
- /** CHANNEL: the channel types a user may pick, not empty, no duplicate. */
80
- channelTypes?: DiscordChannelType[];
81
- nameLocalizations?: ReflexDiscordLocalizations;
82
- descriptionLocalizations?: ReflexDiscordLocalizations;
83
- }
84
-
85
- /** A slash command of the draft of a Discord bot Service. */
86
- export interface IReflexDiscordCommand {
87
- id: string;
88
- serviceId: string;
89
- /** A function of the same Service. */
90
- functionId: string;
91
- /** Unique within the Service. */
92
- name: string;
93
- description: string;
94
- options: IReflexDiscordCommandOption[];
95
- /** Discord permission bits as a decimal string, or null for everyone. */
96
- defaultMemberPermissions: string | null;
97
- allowedInDirectMessages: boolean;
98
- /** Null without translations. */
99
- nameLocalizations: ReflexDiscordLocalizations | null;
100
- descriptionLocalizations: ReflexDiscordLocalizations | null;
101
- /**
102
- * Users may install the bot on their account and use the command outside the servers it is in (in
103
- * group messages too). It can then act on no server in the bot's name.
104
- */
105
- userInstallable: boolean;
106
- createdAt: Date;
107
- updatedAt: Date;
108
- }
109
-
110
- /** A button, select menu or form of the draft of a Discord bot Service, routed by the start of its `custom_id`. */
111
- export interface IReflexDiscordComponent {
112
- id: string;
113
- serviceId: string;
114
- /** A function of the same Service. */
115
- functionId: string;
116
- /** Unique within the Service; no prefix starts another one. An interaction matches the prefix followed by `:`, or equal to its `custom_id`. */
117
- customIdPrefix: string;
118
- kind: DiscordComponentKind;
119
- createdAt: Date;
120
- updatedAt: Date;
121
- }
122
-
123
- /**
124
- * A command as a version of the Service froze it. The fields of card 846 are only there when set (a
125
- * translation, `userInstallable` true): a command without them keeps the fingerprint it had.
126
- */
127
- export type IReflexDiscordCommandSnapshot = Pick<
128
- IReflexDiscordCommand,
129
- | 'id'
130
- | 'functionId'
131
- | 'name'
132
- | 'description'
133
- | 'options'
134
- | 'defaultMemberPermissions'
135
- | 'allowedInDirectMessages'
136
- > & {
137
- nameLocalizations?: ReflexDiscordLocalizations;
138
- descriptionLocalizations?: ReflexDiscordLocalizations;
139
- userInstallable?: true;
140
- };
141
-
142
- /** A component as a version of the Service froze it. */
143
- export type IReflexDiscordComponentSnapshot = Pick<
144
- IReflexDiscordComponent,
145
- 'id' | 'functionId' | 'customIdPrefix' | 'kind'
146
- >;
147
-
148
- /** Settings of a Discord bot Service in one environment, kept outside the versions. */
149
- export interface IReflexDiscordEnvironmentSettings {
150
- id: string;
151
- serviceId: string;
152
- environmentId: string;
153
- /** Discord server (snowflake) the commands are pushed to outside production; required there. */
154
- testGuildId: string | null;
155
- /** Discord permission bits as a decimal string, put in the invitation link. */
156
- invitePermissions: string;
157
- /** What the bot shows while connected. */
158
- presenceStatus: DiscordPresenceStatus;
159
- /** Null for no activity. */
160
- activityType: DiscordActivityType | null;
161
- /** 1 to 128 characters with an `activityType`, null without. */
162
- activityText: string | null;
163
- /** Largest file the bot receives or sends, in bytes: `REFLEX_DISCORD_LIMITS.attachmentMaxBytesDefault` until set. */
164
- maxAttachmentBytes: number;
165
- createdAt: Date;
166
- updatedAt: Date;
167
- }
168
-
169
- /** The Gateway connection of the bot of one environment, as its row in the execution plane says. */
170
- export interface IReflexDiscordPresence {
171
- state: DiscordGatewayState;
172
- /** Set if and only if `state` is `FAILED`. */
173
- failureCode: DiscordGatewayFailureCode | null;
174
- stateChangedAt: Date;
175
- /** Null until the bot connected once. */
176
- lastConnectedAt: Date | null;
177
- }
178
-
179
- /** What the Connection screen shows of the bot of one environment. Never carries the token. */
180
- export interface IReflexDiscordEnvironmentConnection {
181
- environmentId: string;
182
- /** The Discord application read from the token; null while the token is missing, rejected or unchecked. */
183
- applicationId: string | null;
184
- publicKey: string | null;
185
- botName: string | null;
186
- botAvatarUrl: string | null;
187
- tokenState: DiscordTokenState;
188
- testGuildId: string | null;
189
- invitePermissions: string;
190
- presenceStatus: DiscordPresenceStatus;
191
- activityType: DiscordActivityType | null;
192
- activityText: string | null;
193
- /** Largest file the bot receives or sends, in bytes (1 to `REFLEX_DISCORD_LIMITS.attachmentMaxBytesBound`). */
194
- maxAttachmentBytes: number;
195
- /** The Gateway connection; null while the bot is not in service in this environment. */
196
- presence: IReflexDiscordPresence | null;
197
- /** Address to give Discord for interactions in this environment. */
198
- interactionsUrl: string;
199
- /** Link that adds the bot to a Discord server; null while the application is unknown. */
200
- inviteUrl: string | null;
201
- }
202
-
203
- /** The Vault entry holding the token, and the bot of each environment of the application. */
204
- export interface IReflexDiscordConnection {
205
- /** Vault entry (secret) that holds the bot token, one value per environment; null until chosen. */
206
- discordTokenSecretId: string | null;
207
- environments: IReflexDiscordEnvironmentConnection[];
208
- }
1
+ import type {
2
+ DiscordActivityType,
3
+ DiscordChannelType,
4
+ DiscordCommandNodeType,
5
+ DiscordCommandType,
6
+ DiscordComponentKind,
7
+ DiscordLocale,
8
+ DiscordGatewayFailureCode,
9
+ DiscordGatewayState,
10
+ DiscordOptionType,
11
+ DiscordPresenceStatus,
12
+ DiscordTokenState,
13
+ } from '../../enum';
14
+
15
+ /** Bounds of the commands and components of a Discord bot; the API and its database apply the same ones. */
16
+ export const REFLEX_DISCORD_LIMITS = {
17
+ /** `^[-_a-z0-9]{1,32}$`: the name typed after the slash. */
18
+ commandNamePattern: /^[-_a-z0-9]{1,32}$/,
19
+ /**
20
+ * Discord's pattern of a translated command or option name: letters and digits of any script, `-`, `_` and
21
+ * `'`, 1 to 32 characters. It must also be lower case where the script has one (see `isValidLocalizedName`).
22
+ */
23
+ localizedNamePattern: /^[-_'\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$/u,
24
+ commandDescriptionMaxLength: 100,
25
+ /** Slash commands (roots) per Service; a subcommand or a group does not count. */
26
+ commandsPerServiceMax: 100,
27
+ /** Context menus of each type per Service, as Discord allows. */
28
+ userCommandsPerServiceMax: 15,
29
+ messageCommandsPerServiceMax: 15,
30
+ /** Name of a context menu: 1 to 32 characters, capitals and spaces allowed, no space at either end. */
31
+ contextMenuNameMaxLength: 32,
32
+ /** Children of a command with subcommands, and subcommands of a group. */
33
+ subcommandsPerLevelMax: 25,
34
+ optionsPerCommandMax: 25,
35
+ choicesPerOptionMax: 25,
36
+ /** `^[a-z0-9_-]{1,40}$`: the start of the `custom_id` of a button, a menu or a form. */
37
+ componentPrefixPattern: /^[a-z0-9_-]{1,40}$/,
38
+ syncErrorMaxLength: 500,
39
+ /** Bounds of `minLength` and `maxLength` of a STRING option (`maxLength` is 1 at least). */
40
+ optionLengthMax: 6000,
41
+ /** Length of the name of a choice, localized or not. */
42
+ choiceNameMaxLength: 100,
43
+ /** Largest file a bot receives or sends, per bot and environment (#915): the default, and the bound the setting may not pass. */
44
+ attachmentMaxBytesDefault: 2 * 1024 * 1024,
45
+ attachmentMaxBytesBound: 8 * 1024 * 1024,
46
+ } as const;
47
+
48
+ /** A translated command or option name Discord accepts: its pattern, and lower case where the script has one. */
49
+ export const isValidLocalizedName = (name: string): boolean =>
50
+ REFLEX_DISCORD_LIMITS.localizedNamePattern.test(name) && name === name.toLowerCase();
51
+
52
+ /**
53
+ * Translations of a name or a description, by Discord locale. A localized command or option name
54
+ * passes `isValidLocalizedName`, a description 1 to 100 characters, a choice name 1 to 100.
55
+ */
56
+ export type ReflexDiscordLocalizations = Partial<Record<DiscordLocale, string>>;
57
+
58
+ /** A fixed answer a user picks for a STRING, INTEGER or NUMBER option. */
59
+ export interface IReflexDiscordOptionChoice {
60
+ name: string;
61
+ value: string | number;
62
+ nameLocalizations?: ReflexDiscordLocalizations;
63
+ }
64
+
65
+ /**
66
+ * An option of a command. Required options come first. A bound only exists on the types it applies
67
+ * to: the API refuses it on another one.
68
+ */
69
+ export interface IReflexDiscordCommandOption {
70
+ type: DiscordOptionType;
71
+ /** Same pattern as the command name. */
72
+ name: string;
73
+ /** 1 to 100 characters. */
74
+ description: string;
75
+ required: boolean;
76
+ /** 25 at most, only for STRING, INTEGER and NUMBER; within `minValue`/`maxValue` and `minLength`/`maxLength`. */
77
+ choices?: IReflexDiscordOptionChoice[];
78
+ /**
79
+ * Discord asks the function for the choices while the user types. Only for STRING, INTEGER and NUMBER,
80
+ * never together with `choices`. Absent means false.
81
+ */
82
+ autocomplete?: boolean;
83
+ /** INTEGER and NUMBER: safe numbers, `minValue` <= `maxValue`. */
84
+ minValue?: number;
85
+ maxValue?: number;
86
+ /** STRING: 0 to 6000 (`maxLength` 1 at least), `minLength` <= `maxLength`. */
87
+ minLength?: number;
88
+ maxLength?: number;
89
+ /** CHANNEL: the channel types a user may pick, not empty, no duplicate. */
90
+ channelTypes?: DiscordChannelType[];
91
+ nameLocalizations?: ReflexDiscordLocalizations;
92
+ descriptionLocalizations?: ReflexDiscordLocalizations;
93
+ }
94
+
95
+ /**
96
+ * A node of the commands of the draft of a Discord bot Service: a slash command, a subcommand group, a
97
+ * subcommand, or a context menu. Every leaf (a command without children, a subcommand, a context menu) runs its
98
+ * own function; a command with children and a group have none.
99
+ */
100
+ export interface IReflexDiscordCommand {
101
+ id: string;
102
+ serviceId: string;
103
+ /** `CHAT_INPUT` for a slash command and all its nodes. */
104
+ type: DiscordCommandType;
105
+ nodeType: DiscordCommandNodeType;
106
+ /** The command (or group) this node belongs to; null for a command. */
107
+ parentId: string | null;
108
+ /** A function of the same Service; null for a command with subcommands and for a group. */
109
+ functionId: string | null;
110
+ /**
111
+ * Slash command and its nodes: `^[-_a-z0-9]{1,32}$`, unique among the nodes of the same parent. Context menu: 1 to
112
+ * 32 characters, capitals and spaces allowed, unique among the menus of its type.
113
+ */
114
+ name: string;
115
+ /** 1 to 100 characters; the empty string for a context menu. */
116
+ description: string;
117
+ /** Empty on a command with subcommands, a group and a context menu. */
118
+ options: IReflexDiscordCommandOption[];
119
+ /** Discord permission bits as a decimal string, or null for everyone. */
120
+ defaultMemberPermissions: string | null;
121
+ allowedInDirectMessages: boolean;
122
+ /** Null without translations. */
123
+ nameLocalizations: ReflexDiscordLocalizations | null;
124
+ descriptionLocalizations: ReflexDiscordLocalizations | null;
125
+ /**
126
+ * Users may install the bot on their account and use the command outside the servers it is in (in
127
+ * group messages too). It can then act on no server in the bot's name.
128
+ */
129
+ userInstallable: boolean;
130
+ createdAt: Date;
131
+ updatedAt: Date;
132
+ }
133
+
134
+ /** A button, select menu or form of the draft of a Discord bot Service, routed by the start of its `custom_id`. */
135
+ export interface IReflexDiscordComponent {
136
+ id: string;
137
+ serviceId: string;
138
+ /** A function of the same Service. */
139
+ functionId: string;
140
+ /** Unique within the Service; no prefix starts another one. An interaction matches the prefix followed by `:`, or equal to its `custom_id`. */
141
+ customIdPrefix: string;
142
+ kind: DiscordComponentKind;
143
+ createdAt: Date;
144
+ updatedAt: Date;
145
+ }
146
+
147
+ /**
148
+ * A command as a version of the Service froze it. The fields of card 846 are only there when set (a
149
+ * translation, `userInstallable` true): a command without them keeps the fingerprint it had.
150
+ */
151
+ export type IReflexDiscordCommandSnapshot = Pick<
152
+ IReflexDiscordCommand,
153
+ | 'id'
154
+ | 'functionId'
155
+ | 'name'
156
+ | 'description'
157
+ | 'options'
158
+ | 'defaultMemberPermissions'
159
+ | 'allowedInDirectMessages'
160
+ > & {
161
+ nameLocalizations?: ReflexDiscordLocalizations;
162
+ descriptionLocalizations?: ReflexDiscordLocalizations;
163
+ userInstallable?: true;
164
+ /** Card 943: only when not `CHAT_INPUT`. */
165
+ type?: DiscordCommandType;
166
+ /** Card 943: only on a group or a subcommand, with its `parentId`. */
167
+ nodeType?: DiscordCommandNodeType;
168
+ parentId?: string;
169
+ };
170
+
171
+ /** A node of a command and its children, in name order (see `buildDiscordCommandTree`). */
172
+ export interface IReflexDiscordCommandTreeNode<
173
+ T extends Pick<IReflexDiscordCommand, 'id' | 'parentId' | 'name'> = IReflexDiscordCommand,
174
+ > {
175
+ command: T;
176
+ children: IReflexDiscordCommandTreeNode<T>[];
177
+ }
178
+
179
+ /** A component as a version of the Service froze it. */
180
+ export type IReflexDiscordComponentSnapshot = Pick<
181
+ IReflexDiscordComponent,
182
+ 'id' | 'functionId' | 'customIdPrefix' | 'kind'
183
+ >;
184
+
185
+ /** Settings of a Discord bot Service in one environment, kept outside the versions. */
186
+ export interface IReflexDiscordEnvironmentSettings {
187
+ id: string;
188
+ serviceId: string;
189
+ environmentId: string;
190
+ /** Discord server (snowflake) the commands are pushed to outside production; required there. */
191
+ testGuildId: string | null;
192
+ /** Discord permission bits as a decimal string, put in the invitation link. */
193
+ invitePermissions: string;
194
+ /** What the bot shows while connected. */
195
+ presenceStatus: DiscordPresenceStatus;
196
+ /** Null for no activity. */
197
+ activityType: DiscordActivityType | null;
198
+ /** 1 to 128 characters with an `activityType`, null without. */
199
+ activityText: string | null;
200
+ /** Largest file the bot receives or sends, in bytes: `REFLEX_DISCORD_LIMITS.attachmentMaxBytesDefault` until set. */
201
+ maxAttachmentBytes: number;
202
+ /** The bot receives poll votes (intent `GUILD_MESSAGE_POLLS`); false until the developer turns them on. */
203
+ pollVotesEnabled: boolean;
204
+ createdAt: Date;
205
+ updatedAt: Date;
206
+ }
207
+
208
+ /** The Gateway connection of the bot of one environment, as its row in the execution plane says. */
209
+ export interface IReflexDiscordPresence {
210
+ state: DiscordGatewayState;
211
+ /** Set if and only if `state` is `FAILED`. */
212
+ failureCode: DiscordGatewayFailureCode | null;
213
+ stateChangedAt: Date;
214
+ /** Null until the bot connected once. */
215
+ lastConnectedAt: Date | null;
216
+ }
217
+
218
+ /** What the Connection screen shows of the bot of one environment. Never carries the token. */
219
+ export interface IReflexDiscordEnvironmentConnection {
220
+ environmentId: string;
221
+ /** The Discord application read from the token; null while the token is missing, rejected or unchecked. */
222
+ applicationId: string | null;
223
+ publicKey: string | null;
224
+ botName: string | null;
225
+ botAvatarUrl: string | null;
226
+ tokenState: DiscordTokenState;
227
+ testGuildId: string | null;
228
+ invitePermissions: string;
229
+ presenceStatus: DiscordPresenceStatus;
230
+ activityType: DiscordActivityType | null;
231
+ activityText: string | null;
232
+ /** Largest file the bot receives or sends, in bytes (1 to `REFLEX_DISCORD_LIMITS.attachmentMaxBytesBound`). */
233
+ maxAttachmentBytes: number;
234
+ /** The bot receives poll votes; false until turned on. */
235
+ pollVotesEnabled: boolean;
236
+ /** The Gateway connection; null while the bot is not in service in this environment. */
237
+ presence: IReflexDiscordPresence | null;
238
+ /** Address to give Discord for interactions in this environment. */
239
+ interactionsUrl: string;
240
+ /** Link that adds the bot to a Discord server; null while the application is unknown. */
241
+ inviteUrl: string | null;
242
+ }
243
+
244
+ /** The Vault entry holding the token, and the bot of each environment of the application. */
245
+ export interface IReflexDiscordConnection {
246
+ /** Vault entry (secret) that holds the bot token, one value per environment; null until chosen. */
247
+ discordTokenSecretId: string | null;
248
+ environments: IReflexDiscordEnvironmentConnection[];
249
+ }
@@ -1,22 +1,22 @@
1
- import type { ExecutionProfile } from '../../enum';
2
-
3
- /**
4
- * The price list an execution is billed with (ADR-0244), served by the API from the runtime's
5
- * `COST_RATES` and `RESOURCE_PROFILES`, so that a screen that estimates a cost never holds a copy of it.
6
- * Prices are in millicredits (thousandths of a credit).
7
- */
8
- export interface IReflexPriceList {
9
- /** Once per execution; 0 for an interrupted or refused execution. */
10
- executionMillicredits: number;
11
- /** Once per autocomplete execution, in place of `executionMillicredits`; its CPU and memory are not billed. */
12
- autocompleteExecutionMillicredits: number;
13
- cpuMillicreditsPerSecond: number;
14
- /** Per GB-second of the memory the profile allocates, GB = 1024 MB. */
15
- memoryMillicreditsPerGbSecond: number;
16
- /** Per MB sent out, MB = 1024 x 1024 bytes. */
17
- networkOutMillicreditsPerMb: number;
18
- httpCallMillicredits: number;
19
- storeWriteMillicredits: number;
20
- /** The memory of each profile, and the coefficient its CPU part is multiplied by. */
21
- profiles: Record<ExecutionProfile, { memoryMb: number; cpuCoefficient: number }>;
22
- }
1
+ import type { ExecutionProfile } from '../../enum';
2
+
3
+ /**
4
+ * The price list an execution is billed with (ADR-0244), served by the API from the runtime's
5
+ * `COST_RATES` and `RESOURCE_PROFILES`, so that a screen that estimates a cost never holds a copy of it.
6
+ * Prices are in millicredits (thousandths of a credit).
7
+ */
8
+ export interface IReflexPriceList {
9
+ /** Once per execution; 0 for an interrupted or refused execution. */
10
+ executionMillicredits: number;
11
+ /** Once per autocomplete execution, in place of `executionMillicredits`; its CPU and memory are not billed. */
12
+ autocompleteExecutionMillicredits: number;
13
+ cpuMillicreditsPerSecond: number;
14
+ /** Per GB-second of the memory the profile allocates, GB = 1024 MB. */
15
+ memoryMillicreditsPerGbSecond: number;
16
+ /** Per MB sent out, MB = 1024 x 1024 bytes. */
17
+ networkOutMillicreditsPerMb: number;
18
+ httpCallMillicredits: number;
19
+ storeWriteMillicredits: number;
20
+ /** The memory of each profile, and the coefficient its CPU part is multiplied by. */
21
+ profiles: Record<ExecutionProfile, { memoryMb: number; cpuCoefficient: number }>;
22
+ }
@@ -1,24 +1,24 @@
1
- /**
2
- * The retention tiers of the runs a customer may choose, in days (AbyssReflex L3a, #893). The plan's retention is
3
- * the default; a tier is chosen per application, and per function over it. Same list as the database CHECKs.
4
- */
5
- export const REFLEX_RUN_RETENTION_TIER_DAYS = [3, 7, 15, 30, 90, 180, 365] as const;
6
-
7
- /** Bounds of the number of versions the purge keeps, per function and per Service. */
8
- export const REFLEX_VERSIONS_KEPT = { default: 20, min: 5, max: 100 } as const;
9
-
10
- /** The detail of a run (detail, steps, log lines) moves to the archive past this age, in days, when its tier allows it. */
11
- export const REFLEX_RUN_ARCHIVE_AFTER_DAYS = 30;
12
-
13
- /** The runs of a tier under this number of days are never archived: they are purged before they would be. */
14
- export const REFLEX_RUN_ARCHIVE_MIN_TIER_DAYS = 90;
15
-
16
- /** The run retention of a function: its own tier, the one it inherits, and how many versions are kept. */
17
- export interface IReflexFunctionRunRetention {
18
- /** The tier of the function itself, one of `REFLEX_RUN_RETENTION_TIER_DAYS`; null follows the application. */
19
- runRetentionDays: number | null;
20
- /** The tier the function follows when it has none: the application's, else null for the plan's retention. Read only. */
21
- inheritedDays: number | null;
22
- /** How many versions of the function the purge keeps, `REFLEX_VERSIONS_KEPT.min` to `REFLEX_VERSIONS_KEPT.max`. */
23
- versionsKept: number;
24
- }
1
+ /**
2
+ * The retention tiers of the runs a customer may choose, in days (AbyssReflex L3a, #893). The plan's retention is
3
+ * the default; a tier is chosen per application, and per function over it. Same list as the database CHECKs.
4
+ */
5
+ export const REFLEX_RUN_RETENTION_TIER_DAYS = [3, 7, 15, 30, 90, 180, 365] as const;
6
+
7
+ /** Bounds of the number of versions the purge keeps, per function and per Service. */
8
+ export const REFLEX_VERSIONS_KEPT = { default: 20, min: 5, max: 100 } as const;
9
+
10
+ /** The detail of a run (detail, steps, log lines) moves to the archive past this age, in days, when its tier allows it. */
11
+ export const REFLEX_RUN_ARCHIVE_AFTER_DAYS = 30;
12
+
13
+ /** The runs of a tier under this number of days are never archived: they are purged before they would be. */
14
+ export const REFLEX_RUN_ARCHIVE_MIN_TIER_DAYS = 90;
15
+
16
+ /** The run retention of a function: its own tier, the one it inherits, and how many versions are kept. */
17
+ export interface IReflexFunctionRunRetention {
18
+ /** The tier of the function itself, one of `REFLEX_RUN_RETENTION_TIER_DAYS`; null follows the application. */
19
+ runRetentionDays: number | null;
20
+ /** The tier the function follows when it has none: the application's, else null for the plan's retention. Read only. */
21
+ inheritedDays: number | null;
22
+ /** How many versions of the function the purge keeps, `REFLEX_VERSIONS_KEPT.min` to `REFLEX_VERSIONS_KEPT.max`. */
23
+ versionsKept: number;
24
+ }