@abyss-project/reflex 6.6.0 → 6.9.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 (268) 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 +1 -2
  5. package/dist/api/function-run.api.js +1 -3
  6. package/dist/api/function-run.api.js.map +1 -1
  7. package/dist/api/index.d.ts +1 -0
  8. package/dist/api/index.js +1 -0
  9. package/dist/api/index.js.map +1 -1
  10. package/dist/api/reflex-admin.admin.api.d.ts +5 -0
  11. package/dist/api/reflex-admin.admin.api.js +18 -0
  12. package/dist/api/reflex-admin.admin.api.js.map +1 -0
  13. package/dist/discord/discord-event-filter-cases.js +11 -27
  14. package/dist/discord/discord-event-filter-cases.js.map +1 -1
  15. package/dist/discord/discord-event-filters.js +3 -7
  16. package/dist/discord/discord-event-filters.js.map +1 -1
  17. package/dist/discord/discord-event-intents.d.ts +2 -8
  18. package/dist/discord/discord-event-intents.js +2 -13
  19. package/dist/discord/discord-event-intents.js.map +1 -1
  20. package/dist/discord/index.d.ts +0 -1
  21. package/dist/discord/index.js +0 -1
  22. package/dist/discord/index.js.map +1 -1
  23. package/dist/index.d.ts +13 -1
  24. package/dist/index.js +13 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/types/enum/discord-event-type.enum.d.ts +1 -3
  27. package/dist/types/enum/discord-event-type.enum.js +0 -2
  28. package/dist/types/enum/discord-event-type.enum.js.map +1 -1
  29. package/dist/types/enum/index.d.ts +2 -2
  30. package/dist/types/enum/index.js +2 -2
  31. package/dist/types/enum/index.js.map +1 -1
  32. package/dist/types/enum/reflex-abuse-rule.enum.d.ts +5 -0
  33. package/dist/types/enum/reflex-abuse-rule.enum.js +10 -0
  34. package/dist/types/enum/reflex-abuse-rule.enum.js.map +1 -0
  35. package/dist/types/enum/reflex-admin-hold-kind.enum.d.ts +4 -0
  36. package/dist/types/enum/reflex-admin-hold-kind.enum.js +9 -0
  37. package/dist/types/enum/reflex-admin-hold-kind.enum.js.map +1 -0
  38. package/dist/types/enum/reflex-error-code.enum.d.ts +3 -11
  39. package/dist/types/enum/reflex-error-code.enum.js +2 -10
  40. package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
  41. package/dist/types/interface/api/requests/function-run.request.d.ts +0 -8
  42. package/dist/types/interface/api/requests/index.d.ts +1 -0
  43. package/dist/types/interface/api/requests/index.js +1 -0
  44. package/dist/types/interface/api/requests/index.js.map +1 -1
  45. package/dist/types/interface/api/requests/reflex-admin.admin.request.d.ts +21 -0
  46. package/dist/types/interface/api/requests/reflex-admin.admin.request.js +3 -0
  47. package/dist/types/interface/api/requests/reflex-admin.admin.request.js.map +1 -0
  48. package/dist/types/interface/api/requests/service-discord.request.d.ts +3 -7
  49. package/dist/types/interface/api/responses/function-run.response.d.ts +0 -8
  50. package/dist/types/interface/api/responses/index.d.ts +1 -0
  51. package/dist/types/interface/api/responses/index.js +1 -0
  52. package/dist/types/interface/api/responses/index.js.map +1 -1
  53. package/dist/types/interface/api/responses/reflex-admin.admin.response.d.ts +19 -0
  54. package/dist/types/interface/api/responses/reflex-admin.admin.response.js +3 -0
  55. package/dist/types/interface/api/responses/reflex-admin.admin.response.js.map +1 -0
  56. package/dist/types/interface/models/index.d.ts +1 -0
  57. package/dist/types/interface/models/index.js +1 -0
  58. package/dist/types/interface/models/index.js.map +1 -1
  59. package/dist/types/interface/models/reflex-admin-hold.model.d.ts +44 -0
  60. package/dist/types/interface/models/reflex-admin-hold.model.js +11 -0
  61. package/dist/types/interface/models/reflex-admin-hold.model.js.map +1 -0
  62. package/dist/types/interface/models/reflex-discord.model.d.ts +2 -18
  63. package/dist/types/interface/models/reflex-discord.model.js +0 -4
  64. package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
  65. package/dist/types/interface/models/reflex-run.model.d.ts +0 -4
  66. package/dist/types/interface/models/reflex-run.model.js +1 -4
  67. package/dist/types/interface/models/reflex-run.model.js.map +1 -1
  68. package/dist/types/interface/models/reflex-service-deployment.model.d.ts +2 -1
  69. package/dist/types/interface/models/reflex-service.model.d.ts +2 -0
  70. package/dist/types/interface/models/reflex-service.model.js.map +1 -1
  71. package/jest.config.ts +11 -11
  72. package/package.json +1 -1
  73. package/src/api/alert-rule.api.test.ts +72 -72
  74. package/src/api/alert-rule.api.ts +57 -57
  75. package/src/api/application-insights.api.test.ts +42 -42
  76. package/src/api/application-insights.api.ts +38 -38
  77. package/src/api/application-run-settings.api.ts +30 -30
  78. package/src/api/function-access.api.ts +87 -87
  79. package/src/api/function-insights.api.test.ts +27 -27
  80. package/src/api/function-insights.api.ts +18 -18
  81. package/src/api/function-run.api.ts +53 -72
  82. package/src/api/function-template.api.test.ts +72 -72
  83. package/src/api/function-template.api.ts +52 -52
  84. package/src/api/function-test.api.ts +34 -34
  85. package/src/api/function-version.api.ts +66 -66
  86. package/src/api/function.api.ts +62 -62
  87. package/src/api/health.api.ts +10 -10
  88. package/src/api/index.ts +1 -0
  89. package/src/api/reflex-admin.admin.api.test.ts +52 -0
  90. package/src/api/reflex-admin.admin.api.ts +53 -0
  91. package/src/api/route-stats.api.test.ts +45 -45
  92. package/src/api/route-stats.api.ts +36 -36
  93. package/src/api/service-completion-webhook.api.test.ts +97 -97
  94. package/src/api/service-completion-webhook.api.ts +39 -39
  95. package/src/api/service-configuration.api.ts +16 -16
  96. package/src/api/service-consumer.api.test.ts +104 -104
  97. package/src/api/service-consumer.api.ts +90 -90
  98. package/src/api/service-deployment.api.ts +79 -79
  99. package/src/api/service-discord-event.api.test.ts +106 -106
  100. package/src/api/service-discord-event.api.ts +78 -78
  101. package/src/api/service-discord.api.test.ts +178 -178
  102. package/src/api/service-discord.api.ts +222 -222
  103. package/src/api/service-insights.api.test.ts +36 -36
  104. package/src/api/service-insights.api.ts +42 -42
  105. package/src/api/service-limits.api.test.ts +100 -100
  106. package/src/api/service-limits.api.ts +37 -37
  107. package/src/api/service-openapi.api.test.ts +52 -52
  108. package/src/api/service-openapi.api.ts +21 -21
  109. package/src/api/service-route.api.ts +74 -74
  110. package/src/api/service-task.api.test.ts +140 -140
  111. package/src/api/service-task.api.ts +141 -141
  112. package/src/api/service-version.api.ts +54 -54
  113. package/src/api/service.api.ts +55 -55
  114. package/src/discord/discord-event-filter-cases.ts +261 -299
  115. package/src/discord/discord-event-filters.test.ts +91 -120
  116. package/src/discord/discord-event-filters.ts +95 -103
  117. package/src/discord/discord-event-intents.test.ts +112 -139
  118. package/src/discord/discord-event-intents.ts +55 -80
  119. package/src/discord/index.ts +3 -4
  120. package/src/index.test.ts +104 -104
  121. package/src/index.ts +26 -2
  122. package/src/insights/index.ts +1 -1
  123. package/src/insights/percentiles.test.ts +75 -75
  124. package/src/insights/percentiles.ts +37 -37
  125. package/src/types/enum/access-grant-status.enum.ts +12 -12
  126. package/src/types/enum/access-kind.enum.ts +7 -7
  127. package/src/types/enum/access-request-status.enum.ts +11 -11
  128. package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
  129. package/src/types/enum/completion-delivery-status.enum.ts +9 -9
  130. package/src/types/enum/configuration-read-as.enum.ts +5 -5
  131. package/src/types/enum/discord-activity-type.enum.ts +9 -9
  132. package/src/types/enum/discord-channel-type.enum.ts +11 -11
  133. package/src/types/enum/discord-component-kind.enum.ts +7 -7
  134. package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
  135. package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
  136. package/src/types/enum/discord-event-status.enum.ts +13 -13
  137. package/src/types/enum/discord-event-type.enum.ts +7 -11
  138. package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
  139. package/src/types/enum/discord-gateway-state.enum.ts +11 -11
  140. package/src/types/enum/discord-host-action.enum.ts +37 -37
  141. package/src/types/enum/discord-locale.enum.ts +35 -35
  142. package/src/types/enum/discord-option-type.enum.ts +12 -12
  143. package/src/types/enum/discord-presence-status.enum.ts +8 -8
  144. package/src/types/enum/discord-sync-status.enum.ts +6 -6
  145. package/src/types/enum/discord-token-state.enum.ts +11 -11
  146. package/src/types/enum/execution-mode.enum.ts +9 -9
  147. package/src/types/enum/execution-profile.enum.ts +20 -20
  148. package/src/types/enum/execution-settings-source.enum.ts +9 -9
  149. package/src/types/enum/health-status.enum.ts +4 -4
  150. package/src/types/enum/index.ts +53 -53
  151. package/src/types/enum/insights-period.enum.ts +8 -8
  152. package/src/types/enum/log-cap-mode.enum.ts +6 -6
  153. package/src/types/enum/log-drop-cause.enum.ts +8 -8
  154. package/src/types/enum/reflex-abuse-rule.enum.ts +9 -0
  155. package/src/types/enum/reflex-admin-hold-kind.enum.ts +7 -0
  156. package/src/types/enum/reflex-error-code.enum.ts +7 -23
  157. package/src/types/enum/route-method.enum.ts +9 -9
  158. package/src/types/enum/run-log-level.enum.ts +6 -6
  159. package/src/types/enum/run-mode.enum.ts +11 -11
  160. package/src/types/enum/run-status.enum.ts +16 -16
  161. package/src/types/enum/run-step-status.enum.ts +7 -7
  162. package/src/types/enum/schedule-sync-status.enum.ts +6 -6
  163. package/src/types/enum/scheduled-run-failure-code.enum.ts +14 -14
  164. package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
  165. package/src/types/enum/scheduled-run-status.enum.ts +17 -17
  166. package/src/types/enum/service-block-reason.enum.ts +13 -13
  167. package/src/types/enum/service-deployment-action.enum.ts +11 -11
  168. package/src/types/enum/service-deployment-status.enum.ts +5 -5
  169. package/src/types/enum/service-type.enum.ts +9 -9
  170. package/src/types/enum/service-version-change-kind.enum.ts +6 -6
  171. package/src/types/enum/trace-effect-type.enum.ts +12 -12
  172. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  173. package/src/types/enum/trigger-kind.enum.ts +8 -8
  174. package/src/types/enum/vault-value-source.enum.ts +12 -12
  175. package/src/types/enum/vault-visibility.enum.ts +5 -5
  176. package/src/types/index.ts +2 -2
  177. package/src/types/interface/api/index.ts +3 -3
  178. package/src/types/interface/api/requests/alert-rule.request.ts +53 -53
  179. package/src/types/interface/api/requests/application-insights.request.ts +18 -18
  180. package/src/types/interface/api/requests/function-access.request.ts +51 -51
  181. package/src/types/interface/api/requests/function-run.request.ts +0 -11
  182. package/src/types/interface/api/requests/function-template.request.ts +29 -29
  183. package/src/types/interface/api/requests/function-test.request.ts +44 -44
  184. package/src/types/interface/api/requests/function-version.request.ts +38 -38
  185. package/src/types/interface/api/requests/function.request.ts +36 -36
  186. package/src/types/interface/api/requests/index.ts +1 -0
  187. package/src/types/interface/api/requests/reflex-admin.admin.request.ts +26 -0
  188. package/src/types/interface/api/requests/route-stats.request.ts +22 -22
  189. package/src/types/interface/api/requests/service-completion-webhook.request.ts +11 -11
  190. package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
  191. package/src/types/interface/api/requests/service-consumer.request.ts +51 -51
  192. package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
  193. package/src/types/interface/api/requests/service-discord-event.request.ts +68 -68
  194. package/src/types/interface/api/requests/service-discord.request.ts +155 -168
  195. package/src/types/interface/api/requests/service-insights.request.ts +31 -31
  196. package/src/types/interface/api/requests/service-limits.request.ts +28 -28
  197. package/src/types/interface/api/requests/service-openapi.request.ts +10 -10
  198. package/src/types/interface/api/requests/service-route.request.ts +52 -52
  199. package/src/types/interface/api/requests/service-task.request.ts +80 -80
  200. package/src/types/interface/api/requests/service-version.request.ts +24 -24
  201. package/src/types/interface/api/response.ts +4 -4
  202. package/src/types/interface/api/responses/alert-rule.response.ts +24 -24
  203. package/src/types/interface/api/responses/application-insights.response.ts +11 -11
  204. package/src/types/interface/api/responses/application-run-settings.response.ts +8 -8
  205. package/src/types/interface/api/responses/function-access.response.ts +45 -45
  206. package/src/types/interface/api/responses/function-run.response.ts +0 -12
  207. package/src/types/interface/api/responses/function-template.response.ts +21 -21
  208. package/src/types/interface/api/responses/function-test.response.ts +19 -19
  209. package/src/types/interface/api/responses/function-version.response.ts +42 -42
  210. package/src/types/interface/api/responses/function.response.ts +25 -25
  211. package/src/types/interface/api/responses/index.ts +1 -0
  212. package/src/types/interface/api/responses/reflex-admin.admin.response.ts +25 -0
  213. package/src/types/interface/api/responses/route-stats.response.ts +15 -15
  214. package/src/types/interface/api/responses/service-completion-webhook.response.ts +13 -13
  215. package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
  216. package/src/types/interface/api/responses/service-consumer.response.ts +33 -33
  217. package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
  218. package/src/types/interface/api/responses/service-discord-event.response.ts +24 -24
  219. package/src/types/interface/api/responses/service-discord.response.ts +110 -110
  220. package/src/types/interface/api/responses/service-insights.response.ts +11 -11
  221. package/src/types/interface/api/responses/service-limits.response.ts +13 -13
  222. package/src/types/interface/api/responses/service-openapi.response.ts +7 -7
  223. package/src/types/interface/api/responses/service-route.response.ts +31 -31
  224. package/src/types/interface/api/responses/service-task.response.ts +57 -57
  225. package/src/types/interface/api/responses/service-version.response.ts +112 -112
  226. package/src/types/interface/api/responses/service.response.ts +31 -31
  227. package/src/types/interface/health.response.ts +7 -7
  228. package/src/types/interface/index.ts +3 -3
  229. package/src/types/interface/models/index.ts +1 -0
  230. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  231. package/src/types/interface/models/reflex-access-request.model.ts +15 -15
  232. package/src/types/interface/models/reflex-admin-hold.model.ts +55 -0
  233. package/src/types/interface/models/reflex-alert-rule.model.ts +56 -56
  234. package/src/types/interface/models/reflex-bot-limits.model.ts +53 -53
  235. package/src/types/interface/models/reflex-completion-webhook.model.ts +111 -111
  236. package/src/types/interface/models/reflex-consumer.model.ts +50 -50
  237. package/src/types/interface/models/reflex-definition.model.ts +31 -31
  238. package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -58
  239. package/src/types/interface/models/reflex-discord-event.model.ts +79 -79
  240. package/src/types/interface/models/reflex-discord.model.ts +208 -249
  241. package/src/types/interface/models/reflex-execution-settings.model.ts +57 -57
  242. package/src/types/interface/models/reflex-function-template.model.ts +18 -18
  243. package/src/types/interface/models/reflex-function-version.model.ts +19 -19
  244. package/src/types/interface/models/reflex-function.model.ts +30 -30
  245. package/src/types/interface/models/reflex-insights.model.ts +215 -215
  246. package/src/types/interface/models/reflex-price-list.model.ts +22 -22
  247. package/src/types/interface/models/reflex-route-contract.model.ts +46 -46
  248. package/src/types/interface/models/reflex-route.model.ts +23 -23
  249. package/src/types/interface/models/reflex-run.model.ts +0 -8
  250. package/src/types/interface/models/reflex-service-deployment.model.ts +51 -48
  251. package/src/types/interface/models/reflex-service.model.ts +50 -47
  252. package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
  253. package/src/types/interface/models/reflex-task.model.ts +97 -97
  254. package/tsconfig.check.json +15 -15
  255. package/tsconfig.json +35 -35
  256. package/dist/discord/discord-command-tree.d.ts +0 -5
  257. package/dist/discord/discord-command-tree.js +0 -38
  258. package/dist/discord/discord-command-tree.js.map +0 -1
  259. package/dist/types/enum/discord-command-node-type.enum.d.ts +0 -5
  260. package/dist/types/enum/discord-command-node-type.enum.js +0 -10
  261. package/dist/types/enum/discord-command-node-type.enum.js.map +0 -1
  262. package/dist/types/enum/discord-command-type.enum.d.ts +0 -5
  263. package/dist/types/enum/discord-command-type.enum.js +0 -10
  264. package/dist/types/enum/discord-command-type.enum.js.map +0 -1
  265. package/src/discord/discord-command-tree.test.ts +0 -47
  266. package/src/discord/discord-command-tree.ts +0 -60
  267. package/src/types/enum/discord-command-node-type.enum.ts +0 -10
  268. package/src/types/enum/discord-command-type.enum.ts +0 -9
@@ -1,249 +1,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
+ 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,57 +1,57 @@
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
- * Where the edge `POST`s the end of an async execution (`IReflexCompletionWebhookPayload`): `https` only,
14
- * `REFLEX_COMPLETION_WEBHOOK_LIMITS.urlMaxLength` characters at most, never a private or internal address;
15
- * null for no webhook. Unused by a synchronous execution.
16
- */
17
- completionWebhookUrl: string | null;
18
- }
19
-
20
- /** Bounds of the settings, in milliseconds. */
21
- export const REFLEX_EXECUTION_SETTINGS_LIMITS = {
22
- responseTimeoutMs: { min: 1_000, max: 100_000 },
23
- maxDurationMs: { min: 1_000, max: 3_600_000 },
24
- } as const;
25
-
26
- /** What a function runs with when nothing is set. */
27
- export const DEFAULT_REFLEX_EXECUTION_SETTINGS: Readonly<IReflexExecutionSettingsValues> = {
28
- profile: ExecutionProfile.S,
29
- responseTimeoutMs: 30_000,
30
- maxDurationMs: 30_000,
31
- mode: ExecutionMode.SYNC,
32
- completionWebhookUrl: null,
33
- };
34
-
35
- /** A row of settings: the default of the function (`environmentId` null) or the override of one environment. */
36
- export interface IReflexExecutionSettings extends IReflexExecutionSettingsValues {
37
- id: string;
38
- functionId: string;
39
- /** An environment of the application (abyss-main's id); null for the default of every environment. */
40
- environmentId: string | null;
41
- updatedByUserId: string;
42
- createdAt: Date;
43
- updatedAt: Date;
44
- }
45
-
46
- /** What one environment of the application runs with. */
47
- export interface IReflexEffectiveExecutionSettings {
48
- environmentId: string;
49
- /** The name of the environment (abyss-main), immutable. */
50
- environmentSlug: string;
51
- /** Changing what a production environment runs with needs REFLEX_PUBLISH_PRODUCTION. */
52
- isProduction: boolean;
53
- source: ExecutionSettingsSource;
54
- settings: IReflexExecutionSettingsValues;
55
- /** The version promoted in this environment, whose step statistics drive the profile warning; null when none. */
56
- runningVersionId: string | null;
57
- }
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
+ * Where the edge `POST`s the end of an async execution (`IReflexCompletionWebhookPayload`): `https` only,
14
+ * `REFLEX_COMPLETION_WEBHOOK_LIMITS.urlMaxLength` characters at most, never a private or internal address;
15
+ * null for no webhook. Unused by a synchronous execution.
16
+ */
17
+ completionWebhookUrl: string | null;
18
+ }
19
+
20
+ /** Bounds of the settings, in milliseconds. */
21
+ export const REFLEX_EXECUTION_SETTINGS_LIMITS = {
22
+ responseTimeoutMs: { min: 1_000, max: 100_000 },
23
+ maxDurationMs: { min: 1_000, max: 3_600_000 },
24
+ } as const;
25
+
26
+ /** What a function runs with when nothing is set. */
27
+ export const DEFAULT_REFLEX_EXECUTION_SETTINGS: Readonly<IReflexExecutionSettingsValues> = {
28
+ profile: ExecutionProfile.S,
29
+ responseTimeoutMs: 30_000,
30
+ maxDurationMs: 30_000,
31
+ mode: ExecutionMode.SYNC,
32
+ completionWebhookUrl: null,
33
+ };
34
+
35
+ /** A row of settings: the default of the function (`environmentId` null) or the override of one environment. */
36
+ export interface IReflexExecutionSettings extends IReflexExecutionSettingsValues {
37
+ id: string;
38
+ functionId: string;
39
+ /** An environment of the application (abyss-main's id); null for the default of every environment. */
40
+ environmentId: string | null;
41
+ updatedByUserId: string;
42
+ createdAt: Date;
43
+ updatedAt: Date;
44
+ }
45
+
46
+ /** What one environment of the application runs with. */
47
+ export interface IReflexEffectiveExecutionSettings {
48
+ environmentId: string;
49
+ /** The name of the environment (abyss-main), immutable. */
50
+ environmentSlug: string;
51
+ /** Changing what a production environment runs with needs REFLEX_PUBLISH_PRODUCTION. */
52
+ isProduction: boolean;
53
+ source: ExecutionSettingsSource;
54
+ settings: IReflexExecutionSettingsValues;
55
+ /** The version promoted in this environment, whose step statistics drive the profile warning; null when none. */
56
+ runningVersionId: string | null;
57
+ }
@@ -1,18 +1,18 @@
1
- import type { ServiceType } from '../../enum';
2
- import type { IReflexDefinition } from './reflex-definition.model';
3
-
4
- /** A function saved by a member to start other functions of the application from it. */
5
- export interface IReflexFunctionTemplate {
6
- id: string;
7
- applicationId: string;
8
- /** Unique within the application, 100 characters at most. */
9
- name: string;
10
- /** 500 characters at most. */
11
- description: string | null;
12
- /** The type of Service the template suits; null for any. */
13
- serviceType: ServiceType | null;
14
- definition: IReflexDefinition;
15
- createdByUserId: string;
16
- createdAt: Date;
17
- updatedAt: Date;
18
- }
1
+ import type { ServiceType } from '../../enum';
2
+ import type { IReflexDefinition } from './reflex-definition.model';
3
+
4
+ /** A function saved by a member to start other functions of the application from it. */
5
+ export interface IReflexFunctionTemplate {
6
+ id: string;
7
+ applicationId: string;
8
+ /** Unique within the application, 100 characters at most. */
9
+ name: string;
10
+ /** 500 characters at most. */
11
+ description: string | null;
12
+ /** The type of Service the template suits; null for any. */
13
+ serviceType: ServiceType | null;
14
+ definition: IReflexDefinition;
15
+ createdByUserId: string;
16
+ createdAt: Date;
17
+ updatedAt: Date;
18
+ }