@abyss-project/reflex 5.11.0 → 6.0.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 (208) hide show
  1. package/dist/api/index.d.ts +4 -0
  2. package/dist/api/index.js +4 -0
  3. package/dist/api/index.js.map +1 -1
  4. package/dist/api/service-completion-webhook.api.d.ts +3 -0
  5. package/dist/api/service-completion-webhook.api.js +10 -0
  6. package/dist/api/service-completion-webhook.api.js.map +1 -0
  7. package/dist/api/service-consumer.api.d.ts +7 -0
  8. package/dist/api/service-consumer.api.js +19 -0
  9. package/dist/api/service-consumer.api.js.map +1 -0
  10. package/dist/api/service-discord.api.d.ts +1 -2
  11. package/dist/api/service-discord.api.js +1 -3
  12. package/dist/api/service-discord.api.js.map +1 -1
  13. package/dist/api/service-limits.api.d.ts +3 -0
  14. package/dist/api/service-limits.api.js +10 -0
  15. package/dist/api/service-limits.api.js.map +1 -0
  16. package/dist/api/service-openapi.api.d.ts +2 -0
  17. package/dist/api/service-openapi.api.js +7 -0
  18. package/dist/api/service-openapi.api.js.map +1 -0
  19. package/dist/api/service-route.api.js.map +1 -1
  20. package/dist/index.d.ts +23 -1
  21. package/dist/index.js +23 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/types/enum/completion-delivery-status.enum.d.ts +5 -0
  24. package/dist/types/enum/completion-delivery-status.enum.js +10 -0
  25. package/dist/types/enum/completion-delivery-status.enum.js.map +1 -0
  26. package/dist/types/enum/index.d.ts +2 -0
  27. package/dist/types/enum/index.js +2 -0
  28. package/dist/types/enum/index.js.map +1 -1
  29. package/dist/types/enum/reflex-error-code.enum.d.ts +8 -1
  30. package/dist/types/enum/reflex-error-code.enum.js +7 -0
  31. package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
  32. package/dist/types/enum/run-status.enum.d.ts +2 -1
  33. package/dist/types/enum/run-status.enum.js +1 -0
  34. package/dist/types/enum/run-status.enum.js.map +1 -1
  35. package/dist/types/enum/scheduled-run-failure-code.enum.d.ts +2 -1
  36. package/dist/types/enum/scheduled-run-failure-code.enum.js +1 -0
  37. package/dist/types/enum/scheduled-run-failure-code.enum.js.map +1 -1
  38. package/dist/types/enum/service-block-reason.enum.d.ts +4 -0
  39. package/dist/types/enum/service-block-reason.enum.js +9 -0
  40. package/dist/types/enum/service-block-reason.enum.js.map +1 -0
  41. package/dist/types/interface/api/requests/function-run.request.d.ts +1 -0
  42. package/dist/types/interface/api/requests/function-test.request.d.ts +1 -0
  43. package/dist/types/interface/api/requests/index.d.ts +4 -0
  44. package/dist/types/interface/api/requests/index.js +4 -0
  45. package/dist/types/interface/api/requests/index.js.map +1 -1
  46. package/dist/types/interface/api/requests/service-completion-webhook.request.d.ts +9 -0
  47. package/dist/types/interface/api/requests/service-completion-webhook.request.js +3 -0
  48. package/dist/types/interface/api/requests/service-completion-webhook.request.js.map +1 -0
  49. package/dist/types/interface/api/requests/service-consumer.request.d.ts +41 -0
  50. package/dist/types/interface/api/requests/service-consumer.request.js +3 -0
  51. package/dist/types/interface/api/requests/service-consumer.request.js.map +1 -0
  52. package/dist/types/interface/api/requests/service-discord.request.d.ts +1 -14
  53. package/dist/types/interface/api/requests/service-limits.request.d.ts +18 -0
  54. package/dist/types/interface/api/requests/service-limits.request.js +3 -0
  55. package/dist/types/interface/api/requests/service-limits.request.js.map +1 -0
  56. package/dist/types/interface/api/requests/service-openapi.request.d.ts +8 -0
  57. package/dist/types/interface/api/requests/service-openapi.request.js +3 -0
  58. package/dist/types/interface/api/requests/service-openapi.request.js.map +1 -0
  59. package/dist/types/interface/api/requests/service-route.request.d.ts +3 -0
  60. package/dist/types/interface/api/responses/function-settings.response.d.ts +3 -1
  61. package/dist/types/interface/api/responses/function-test.response.d.ts +3 -1
  62. package/dist/types/interface/api/responses/index.d.ts +4 -0
  63. package/dist/types/interface/api/responses/index.js +4 -0
  64. package/dist/types/interface/api/responses/index.js.map +1 -1
  65. package/dist/types/interface/api/responses/service-completion-webhook.response.d.ts +8 -0
  66. package/dist/types/interface/api/responses/service-completion-webhook.response.js +3 -0
  67. package/dist/types/interface/api/responses/service-completion-webhook.response.js.map +1 -0
  68. package/dist/types/interface/api/responses/service-consumer.response.d.ts +25 -0
  69. package/dist/types/interface/api/responses/service-consumer.response.js +3 -0
  70. package/dist/types/interface/api/responses/service-consumer.response.js.map +1 -0
  71. package/dist/types/interface/api/responses/service-discord.response.d.ts +1 -9
  72. package/dist/types/interface/api/responses/service-limits.response.d.ts +10 -0
  73. package/dist/types/interface/api/responses/service-limits.response.js +3 -0
  74. package/dist/types/interface/api/responses/service-limits.response.js.map +1 -0
  75. package/dist/types/interface/api/responses/service-openapi.response.d.ts +5 -0
  76. package/dist/types/interface/api/responses/service-openapi.response.js +3 -0
  77. package/dist/types/interface/api/responses/service-openapi.response.js.map +1 -0
  78. package/dist/types/interface/api/responses/service-version.response.d.ts +1 -0
  79. package/dist/types/interface/models/index.d.ts +4 -0
  80. package/dist/types/interface/models/index.js +4 -0
  81. package/dist/types/interface/models/index.js.map +1 -1
  82. package/dist/types/interface/models/reflex-bot-limits.model.d.ts +0 -25
  83. package/dist/types/interface/models/reflex-bot-limits.model.js +8 -7
  84. package/dist/types/interface/models/reflex-bot-limits.model.js.map +1 -1
  85. package/dist/types/interface/models/reflex-completion-webhook.model.d.ts +48 -0
  86. package/dist/types/interface/models/reflex-completion-webhook.model.js +12 -0
  87. package/dist/types/interface/models/reflex-completion-webhook.model.js.map +1 -0
  88. package/dist/types/interface/models/reflex-consumer.model.d.ts +30 -0
  89. package/dist/types/interface/models/reflex-consumer.model.js +11 -0
  90. package/dist/types/interface/models/reflex-consumer.model.js.map +1 -0
  91. package/dist/types/interface/models/reflex-execution-settings.model.d.ts +1 -0
  92. package/dist/types/interface/models/reflex-execution-settings.model.js +1 -0
  93. package/dist/types/interface/models/reflex-execution-settings.model.js.map +1 -1
  94. package/dist/types/interface/models/reflex-route-contract.model.d.ts +22 -0
  95. package/dist/types/interface/models/reflex-route-contract.model.js +13 -0
  96. package/dist/types/interface/models/reflex-route-contract.model.js.map +1 -0
  97. package/dist/types/interface/models/reflex-route.model.d.ts +2 -0
  98. package/dist/types/interface/models/reflex-run.model.d.ts +21 -0
  99. package/dist/types/interface/models/reflex-run.model.js.map +1 -1
  100. package/dist/types/interface/models/reflex-service-limits.model.d.ts +41 -0
  101. package/dist/types/interface/models/reflex-service-limits.model.js +13 -0
  102. package/dist/types/interface/models/reflex-service-limits.model.js.map +1 -0
  103. package/dist/types/interface/models/reflex-service-version.model.d.ts +2 -0
  104. package/package.json +15 -10
  105. package/src/api/function-access.api.ts +87 -87
  106. package/src/api/function-template.api.test.ts +72 -72
  107. package/src/api/function-template.api.ts +52 -52
  108. package/src/api/function-version.api.ts +66 -66
  109. package/src/api/function.api.test.ts +2 -1
  110. package/src/api/index.ts +4 -0
  111. package/src/api/service-completion-webhook.api.test.ts +87 -0
  112. package/src/api/service-completion-webhook.api.ts +37 -0
  113. package/src/api/service-consumer.api.test.ts +104 -0
  114. package/src/api/service-consumer.api.ts +88 -0
  115. package/src/api/service-discord.api.test.ts +178 -197
  116. package/src/api/service-discord.api.ts +222 -241
  117. package/src/api/service-limits.api.test.ts +100 -0
  118. package/src/api/service-limits.api.ts +37 -0
  119. package/src/api/service-openapi.api.test.ts +52 -0
  120. package/src/api/service-openapi.api.ts +21 -0
  121. package/src/api/service-route.api.ts +74 -72
  122. package/src/index.test.ts +104 -87
  123. package/src/index.ts +46 -3
  124. package/src/types/enum/access-request-status.enum.ts +11 -11
  125. package/src/types/enum/completion-delivery-status.enum.ts +9 -0
  126. package/src/types/enum/index.ts +2 -0
  127. package/src/types/enum/reflex-error-code.enum.ts +73 -43
  128. package/src/types/enum/run-status.enum.ts +16 -11
  129. package/src/types/enum/scheduled-run-failure-code.enum.ts +14 -12
  130. package/src/types/enum/service-block-reason.enum.ts +13 -0
  131. package/src/types/interface/api/requests/alert-rule.request.ts +53 -53
  132. package/src/types/interface/api/requests/application-insights.request.ts +18 -18
  133. package/src/types/interface/api/requests/application-run-settings.request.ts +11 -11
  134. package/src/types/interface/api/requests/function-access.request.ts +51 -51
  135. package/src/types/interface/api/requests/function-run.request.ts +2 -0
  136. package/src/types/interface/api/requests/function-settings.request.ts +34 -34
  137. package/src/types/interface/api/requests/function-template.request.ts +29 -29
  138. package/src/types/interface/api/requests/function-test.request.ts +5 -0
  139. package/src/types/interface/api/requests/function-version.request.ts +38 -38
  140. package/src/types/interface/api/requests/function.request.ts +36 -36
  141. package/src/types/interface/api/requests/index.ts +4 -0
  142. package/src/types/interface/api/requests/route-stats.request.ts +22 -22
  143. package/src/types/interface/api/requests/service-completion-webhook.request.ts +11 -0
  144. package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
  145. package/src/types/interface/api/requests/service-consumer.request.ts +51 -0
  146. package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
  147. package/src/types/interface/api/requests/service-discord-event.request.ts +68 -68
  148. package/src/types/interface/api/requests/service-discord.request.ts +1 -25
  149. package/src/types/interface/api/requests/service-insights.request.ts +31 -31
  150. package/src/types/interface/api/requests/service-limits.request.ts +28 -0
  151. package/src/types/interface/api/requests/service-openapi.request.ts +10 -0
  152. package/src/types/interface/api/requests/service-route.request.ts +8 -0
  153. package/src/types/interface/api/requests/service-task.request.ts +80 -80
  154. package/src/types/interface/api/requests/service-version.request.ts +24 -24
  155. package/src/types/interface/api/requests/service.request.ts +46 -46
  156. package/src/types/interface/api/responses/alert-rule.response.ts +24 -24
  157. package/src/types/interface/api/responses/application-insights.response.ts +11 -11
  158. package/src/types/interface/api/responses/application-run-settings.response.ts +8 -8
  159. package/src/types/interface/api/responses/function-access.response.ts +45 -45
  160. package/src/types/interface/api/responses/function-run.response.ts +18 -18
  161. package/src/types/interface/api/responses/function-settings.response.ts +8 -0
  162. package/src/types/interface/api/responses/function-template.response.ts +21 -21
  163. package/src/types/interface/api/responses/function-test.response.ts +8 -1
  164. package/src/types/interface/api/responses/function-version.response.ts +42 -42
  165. package/src/types/interface/api/responses/function.response.ts +25 -25
  166. package/src/types/interface/api/responses/index.ts +4 -0
  167. package/src/types/interface/api/responses/route-stats.response.ts +15 -15
  168. package/src/types/interface/api/responses/service-completion-webhook.response.ts +13 -0
  169. package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
  170. package/src/types/interface/api/responses/service-consumer.response.ts +33 -0
  171. package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
  172. package/src/types/interface/api/responses/service-discord-event.response.ts +24 -24
  173. package/src/types/interface/api/responses/service-discord.response.ts +4 -16
  174. package/src/types/interface/api/responses/service-insights.response.ts +11 -11
  175. package/src/types/interface/api/responses/service-limits.response.ts +13 -0
  176. package/src/types/interface/api/responses/service-openapi.response.ts +7 -0
  177. package/src/types/interface/api/responses/service-route.response.ts +3 -3
  178. package/src/types/interface/api/responses/service-task.response.ts +57 -57
  179. package/src/types/interface/api/responses/service-version.response.ts +112 -106
  180. package/src/types/interface/api/responses/service.response.ts +31 -31
  181. package/src/types/interface/models/index.ts +4 -0
  182. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  183. package/src/types/interface/models/reflex-access-request.model.ts +15 -15
  184. package/src/types/interface/models/reflex-alert-rule.model.ts +56 -56
  185. package/src/types/interface/models/reflex-bot-limits.model.ts +12 -51
  186. package/src/types/interface/models/reflex-completion-webhook.model.ts +85 -0
  187. package/src/types/interface/models/reflex-consumer.model.ts +50 -0
  188. package/src/types/interface/models/reflex-definition.model.ts +31 -31
  189. package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -58
  190. package/src/types/interface/models/reflex-discord-event.model.ts +79 -79
  191. package/src/types/interface/models/reflex-discord.model.ts +196 -196
  192. package/src/types/interface/models/reflex-execution-settings.model.ts +7 -0
  193. package/src/types/interface/models/reflex-function-template.model.ts +18 -18
  194. package/src/types/interface/models/reflex-function-version.model.ts +19 -19
  195. package/src/types/interface/models/reflex-function.model.ts +30 -30
  196. package/src/types/interface/models/reflex-insights.model.ts +215 -215
  197. package/src/types/interface/models/reflex-price-list.model.ts +20 -20
  198. package/src/types/interface/models/reflex-route-contract.model.ts +46 -0
  199. package/src/types/interface/models/reflex-route.model.ts +5 -1
  200. package/src/types/interface/models/reflex-run-settings.model.ts +28 -28
  201. package/src/types/interface/models/reflex-run.model.ts +47 -3
  202. package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
  203. package/src/types/interface/models/reflex-service-deployment.model.ts +46 -46
  204. package/src/types/interface/models/reflex-service-limits.model.ts +73 -0
  205. package/src/types/interface/models/reflex-service-version.model.ts +3 -0
  206. package/src/types/interface/models/reflex-service.model.ts +45 -45
  207. package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
  208. package/src/types/interface/models/reflex-task.model.ts +97 -97
@@ -1,196 +1,196 @@
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
- } as const;
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
-
45
- /** A fixed answer a user picks for a STRING, INTEGER or NUMBER option. */
46
- export interface IReflexDiscordOptionChoice {
47
- name: string;
48
- value: string | number;
49
- nameLocalizations?: ReflexDiscordLocalizations;
50
- }
51
-
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
- */
56
- export interface IReflexDiscordCommandOption {
57
- type: DiscordOptionType;
58
- /** Same pattern as the command name. */
59
- name: string;
60
- /** 1 to 100 characters. */
61
- description: string;
62
- required: boolean;
63
- /** 25 at most, only for STRING, INTEGER and NUMBER; within `minValue`/`maxValue` and `minLength`/`maxLength`. */
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;
75
- }
76
-
77
- /** A slash command of the draft of a Discord bot Service. */
78
- export interface IReflexDiscordCommand {
79
- id: string;
80
- serviceId: string;
81
- /** A function of the same Service. */
82
- functionId: string;
83
- /** Unique within the Service. */
84
- name: string;
85
- description: string;
86
- options: IReflexDiscordCommandOption[];
87
- /** Discord permission bits as a decimal string, or null for everyone. */
88
- defaultMemberPermissions: string | null;
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;
98
- createdAt: Date;
99
- updatedAt: Date;
100
- }
101
-
102
- /** A button, select menu or form of the draft of a Discord bot Service, routed by the start of its `custom_id`. */
103
- export interface IReflexDiscordComponent {
104
- id: string;
105
- serviceId: string;
106
- /** A function of the same Service. */
107
- functionId: string;
108
- /** Unique within the Service; no prefix starts another one. An interaction matches the prefix followed by `:`, or equal to its `custom_id`. */
109
- customIdPrefix: string;
110
- kind: DiscordComponentKind;
111
- createdAt: Date;
112
- updatedAt: Date;
113
- }
114
-
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
- */
119
- export type IReflexDiscordCommandSnapshot = Pick<
120
- IReflexDiscordCommand,
121
- | 'id'
122
- | 'functionId'
123
- | 'name'
124
- | 'description'
125
- | 'options'
126
- | 'defaultMemberPermissions'
127
- | 'allowedInDirectMessages'
128
- > & {
129
- nameLocalizations?: ReflexDiscordLocalizations;
130
- descriptionLocalizations?: ReflexDiscordLocalizations;
131
- userInstallable?: true;
132
- };
133
-
134
- /** A component as a version of the Service froze it. */
135
- export type IReflexDiscordComponentSnapshot = Pick<
136
- IReflexDiscordComponent,
137
- 'id' | 'functionId' | 'customIdPrefix' | 'kind'
138
- >;
139
-
140
- /** Settings of a Discord bot Service in one environment, kept outside the versions. */
141
- export interface IReflexDiscordEnvironmentSettings {
142
- id: string;
143
- serviceId: string;
144
- environmentId: string;
145
- /** Discord server (snowflake) the commands are pushed to outside production; required there. */
146
- testGuildId: string | null;
147
- /** Discord permission bits as a decimal string, put in the invitation link. */
148
- invitePermissions: string;
149
- /** What the bot shows while connected. */
150
- presenceStatus: DiscordPresenceStatus;
151
- /** Null for no activity. */
152
- activityType: DiscordActivityType | null;
153
- /** 1 to 128 characters with an `activityType`, null without. */
154
- activityText: string | null;
155
- createdAt: Date;
156
- updatedAt: Date;
157
- }
158
-
159
- /** The Gateway connection of the bot of one environment, as its row in the execution plane says. */
160
- export interface IReflexDiscordPresence {
161
- state: DiscordGatewayState;
162
- /** Set if and only if `state` is `FAILED`. */
163
- failureCode: DiscordGatewayFailureCode | null;
164
- stateChangedAt: Date;
165
- /** Null until the bot connected once. */
166
- lastConnectedAt: Date | null;
167
- }
168
-
169
- /** What the Connection screen shows of the bot of one environment. Never carries the token. */
170
- export interface IReflexDiscordEnvironmentConnection {
171
- environmentId: string;
172
- /** The Discord application read from the token; null while the token is missing, rejected or unchecked. */
173
- applicationId: string | null;
174
- publicKey: string | null;
175
- botName: string | null;
176
- botAvatarUrl: string | null;
177
- tokenState: DiscordTokenState;
178
- testGuildId: string | null;
179
- invitePermissions: string;
180
- presenceStatus: DiscordPresenceStatus;
181
- activityType: DiscordActivityType | null;
182
- activityText: string | null;
183
- /** The Gateway connection; null while the bot is not in service in this environment. */
184
- presence: IReflexDiscordPresence | null;
185
- /** Address to give Discord for interactions in this environment. */
186
- interactionsUrl: string;
187
- /** Link that adds the bot to a Discord server; null while the application is unknown. */
188
- inviteUrl: string | null;
189
- }
190
-
191
- /** The Vault entry holding the token, and the bot of each environment of the application. */
192
- export interface IReflexDiscordConnection {
193
- /** Vault entry (secret) that holds the bot token, one value per environment; null until chosen. */
194
- discordTokenSecretId: string | null;
195
- environments: IReflexDiscordEnvironmentConnection[];
196
- }
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
+ } as const;
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
+
45
+ /** A fixed answer a user picks for a STRING, INTEGER or NUMBER option. */
46
+ export interface IReflexDiscordOptionChoice {
47
+ name: string;
48
+ value: string | number;
49
+ nameLocalizations?: ReflexDiscordLocalizations;
50
+ }
51
+
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
+ */
56
+ export interface IReflexDiscordCommandOption {
57
+ type: DiscordOptionType;
58
+ /** Same pattern as the command name. */
59
+ name: string;
60
+ /** 1 to 100 characters. */
61
+ description: string;
62
+ required: boolean;
63
+ /** 25 at most, only for STRING, INTEGER and NUMBER; within `minValue`/`maxValue` and `minLength`/`maxLength`. */
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;
75
+ }
76
+
77
+ /** A slash command of the draft of a Discord bot Service. */
78
+ export interface IReflexDiscordCommand {
79
+ id: string;
80
+ serviceId: string;
81
+ /** A function of the same Service. */
82
+ functionId: string;
83
+ /** Unique within the Service. */
84
+ name: string;
85
+ description: string;
86
+ options: IReflexDiscordCommandOption[];
87
+ /** Discord permission bits as a decimal string, or null for everyone. */
88
+ defaultMemberPermissions: string | null;
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;
98
+ createdAt: Date;
99
+ updatedAt: Date;
100
+ }
101
+
102
+ /** A button, select menu or form of the draft of a Discord bot Service, routed by the start of its `custom_id`. */
103
+ export interface IReflexDiscordComponent {
104
+ id: string;
105
+ serviceId: string;
106
+ /** A function of the same Service. */
107
+ functionId: string;
108
+ /** Unique within the Service; no prefix starts another one. An interaction matches the prefix followed by `:`, or equal to its `custom_id`. */
109
+ customIdPrefix: string;
110
+ kind: DiscordComponentKind;
111
+ createdAt: Date;
112
+ updatedAt: Date;
113
+ }
114
+
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
+ */
119
+ export type IReflexDiscordCommandSnapshot = Pick<
120
+ IReflexDiscordCommand,
121
+ | 'id'
122
+ | 'functionId'
123
+ | 'name'
124
+ | 'description'
125
+ | 'options'
126
+ | 'defaultMemberPermissions'
127
+ | 'allowedInDirectMessages'
128
+ > & {
129
+ nameLocalizations?: ReflexDiscordLocalizations;
130
+ descriptionLocalizations?: ReflexDiscordLocalizations;
131
+ userInstallable?: true;
132
+ };
133
+
134
+ /** A component as a version of the Service froze it. */
135
+ export type IReflexDiscordComponentSnapshot = Pick<
136
+ IReflexDiscordComponent,
137
+ 'id' | 'functionId' | 'customIdPrefix' | 'kind'
138
+ >;
139
+
140
+ /** Settings of a Discord bot Service in one environment, kept outside the versions. */
141
+ export interface IReflexDiscordEnvironmentSettings {
142
+ id: string;
143
+ serviceId: string;
144
+ environmentId: string;
145
+ /** Discord server (snowflake) the commands are pushed to outside production; required there. */
146
+ testGuildId: string | null;
147
+ /** Discord permission bits as a decimal string, put in the invitation link. */
148
+ invitePermissions: string;
149
+ /** What the bot shows while connected. */
150
+ presenceStatus: DiscordPresenceStatus;
151
+ /** Null for no activity. */
152
+ activityType: DiscordActivityType | null;
153
+ /** 1 to 128 characters with an `activityType`, null without. */
154
+ activityText: string | null;
155
+ createdAt: Date;
156
+ updatedAt: Date;
157
+ }
158
+
159
+ /** The Gateway connection of the bot of one environment, as its row in the execution plane says. */
160
+ export interface IReflexDiscordPresence {
161
+ state: DiscordGatewayState;
162
+ /** Set if and only if `state` is `FAILED`. */
163
+ failureCode: DiscordGatewayFailureCode | null;
164
+ stateChangedAt: Date;
165
+ /** Null until the bot connected once. */
166
+ lastConnectedAt: Date | null;
167
+ }
168
+
169
+ /** What the Connection screen shows of the bot of one environment. Never carries the token. */
170
+ export interface IReflexDiscordEnvironmentConnection {
171
+ environmentId: string;
172
+ /** The Discord application read from the token; null while the token is missing, rejected or unchecked. */
173
+ applicationId: string | null;
174
+ publicKey: string | null;
175
+ botName: string | null;
176
+ botAvatarUrl: string | null;
177
+ tokenState: DiscordTokenState;
178
+ testGuildId: string | null;
179
+ invitePermissions: string;
180
+ presenceStatus: DiscordPresenceStatus;
181
+ activityType: DiscordActivityType | null;
182
+ activityText: string | null;
183
+ /** The Gateway connection; null while the bot is not in service in this environment. */
184
+ presence: IReflexDiscordPresence | null;
185
+ /** Address to give Discord for interactions in this environment. */
186
+ interactionsUrl: string;
187
+ /** Link that adds the bot to a Discord server; null while the application is unknown. */
188
+ inviteUrl: string | null;
189
+ }
190
+
191
+ /** The Vault entry holding the token, and the bot of each environment of the application. */
192
+ export interface IReflexDiscordConnection {
193
+ /** Vault entry (secret) that holds the bot token, one value per environment; null until chosen. */
194
+ discordTokenSecretId: string | null;
195
+ environments: IReflexDiscordEnvironmentConnection[];
196
+ }
@@ -9,6 +9,12 @@ export interface IReflexExecutionSettingsValues {
9
9
  /** Past this, the execution is stopped with TIMEOUT. */
10
10
  maxDurationMs: number;
11
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;
12
18
  }
13
19
 
14
20
  /** Bounds of the settings, in milliseconds. */
@@ -23,6 +29,7 @@ export const DEFAULT_REFLEX_EXECUTION_SETTINGS: Readonly<IReflexExecutionSetting
23
29
  responseTimeoutMs: 30_000,
24
30
  maxDurationMs: 30_000,
25
31
  mode: ExecutionMode.SYNC,
32
+ completionWebhookUrl: null,
26
33
  };
27
34
 
28
35
  /** A row of settings: the default of the function (`environmentId` null) or the override of one environment. */
@@ -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
+ }
@@ -1,19 +1,19 @@
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
- }
15
-
16
- /** A row of the version list: the version and whether a Service version running it was ever put in service. */
17
- export interface IReflexFunctionVersionRow extends IReflexFunctionVersion {
18
- deployed: boolean;
19
- }
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
+ }
15
+
16
+ /** A row of the version list: the version and whether a Service version running it was ever put in service. */
17
+ export interface IReflexFunctionVersionRow extends IReflexFunctionVersion {
18
+ deployed: boolean;
19
+ }
@@ -1,30 +1,30 @@
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
- /** SHA-256 of the saved draft, computed like the hash of a version (`IReflexFunctionVersion.hash`). */
13
- draftHash: string;
14
- /** The newest frozen version; null when none exists. */
15
- latestVersion: IReflexFunctionLatestVersion | null;
16
- /** The version the draft started from (set by opening a version); null otherwise. */
17
- draftBaseVersionId: string | null;
18
- /** Number of `draftBaseVersionId`; null when it is. */
19
- draftBaseVersionNumber: number | null;
20
- createdByUserId: string;
21
- updatedByUserId: string;
22
- createdAt: Date;
23
- updatedAt: Date;
24
- }
25
-
26
- export interface IReflexFunctionLatestVersion {
27
- id: string;
28
- number: number;
29
- hash: string;
30
- }
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
+ /** SHA-256 of the saved draft, computed like the hash of a version (`IReflexFunctionVersion.hash`). */
13
+ draftHash: string;
14
+ /** The newest frozen version; null when none exists. */
15
+ latestVersion: IReflexFunctionLatestVersion | null;
16
+ /** The version the draft started from (set by opening a version); null otherwise. */
17
+ draftBaseVersionId: string | null;
18
+ /** Number of `draftBaseVersionId`; null when it is. */
19
+ draftBaseVersionNumber: number | null;
20
+ createdByUserId: string;
21
+ updatedByUserId: string;
22
+ createdAt: Date;
23
+ updatedAt: Date;
24
+ }
25
+
26
+ export interface IReflexFunctionLatestVersion {
27
+ id: string;
28
+ number: number;
29
+ hash: string;
30
+ }