@abyss-project/reflex 5.4.0 → 5.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 (154) hide show
  1. package/dist/api/function-insights.api.d.ts +2 -0
  2. package/dist/api/function-insights.api.js +7 -0
  3. package/dist/api/function-insights.api.js.map +1 -0
  4. package/dist/api/index.d.ts +3 -0
  5. package/dist/api/index.js +3 -0
  6. package/dist/api/index.js.map +1 -1
  7. package/dist/api/service-discord-event.api.d.ts +6 -0
  8. package/dist/api/service-discord-event.api.js +18 -0
  9. package/dist/api/service-discord-event.api.js.map +1 -0
  10. package/dist/api/service-discord.api.d.ts +3 -1
  11. package/dist/api/service-discord.api.js +5 -1
  12. package/dist/api/service-discord.api.js.map +1 -1
  13. package/dist/api/service-insights.api.d.ts +3 -0
  14. package/dist/api/service-insights.api.js +12 -0
  15. package/dist/api/service-insights.api.js.map +1 -0
  16. package/dist/discord/discord-event-filter-cases.d.ts +15 -0
  17. package/dist/discord/discord-event-filter-cases.js +77 -0
  18. package/dist/discord/discord-event-filter-cases.js.map +1 -0
  19. package/dist/discord/discord-event-filters.d.ts +20 -0
  20. package/dist/discord/discord-event-filters.js +50 -0
  21. package/dist/discord/discord-event-filters.js.map +1 -0
  22. package/dist/discord/discord-event-intents.d.ts +14 -0
  23. package/dist/discord/discord-event-intents.js +38 -0
  24. package/dist/discord/discord-event-intents.js.map +1 -0
  25. package/dist/discord/index.d.ts +3 -0
  26. package/dist/discord/index.js +20 -0
  27. package/dist/discord/index.js.map +1 -0
  28. package/dist/index.d.ts +22 -0
  29. package/dist/index.js +22 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/types/enum/bot-event-block-reason.enum.d.ts +4 -0
  32. package/dist/types/enum/bot-event-block-reason.enum.js +9 -0
  33. package/dist/types/enum/bot-event-block-reason.enum.js.map +1 -0
  34. package/dist/types/enum/discord-event-drop-reason.enum.d.ts +7 -0
  35. package/dist/types/enum/discord-event-drop-reason.enum.js +12 -0
  36. package/dist/types/enum/discord-event-drop-reason.enum.js.map +1 -0
  37. package/dist/types/enum/discord-event-filter-name.enum.d.ts +9 -0
  38. package/dist/types/enum/discord-event-filter-name.enum.js +14 -0
  39. package/dist/types/enum/discord-event-filter-name.enum.js.map +1 -0
  40. package/dist/types/enum/discord-event-status.enum.d.ts +7 -0
  41. package/dist/types/enum/discord-event-status.enum.js +12 -0
  42. package/dist/types/enum/discord-event-status.enum.js.map +1 -0
  43. package/dist/types/enum/discord-event-type.enum.d.ts +6 -0
  44. package/dist/types/enum/discord-event-type.enum.js +11 -0
  45. package/dist/types/enum/discord-event-type.enum.js.map +1 -0
  46. package/dist/types/enum/discord-gateway-failure-code.enum.d.ts +2 -1
  47. package/dist/types/enum/discord-gateway-failure-code.enum.js +1 -0
  48. package/dist/types/enum/discord-gateway-failure-code.enum.js.map +1 -1
  49. package/dist/types/enum/index.d.ts +7 -0
  50. package/dist/types/enum/index.js +7 -0
  51. package/dist/types/enum/index.js.map +1 -1
  52. package/dist/types/enum/insights-period.enum.d.ts +7 -0
  53. package/dist/types/enum/insights-period.enum.js +12 -0
  54. package/dist/types/enum/insights-period.enum.js.map +1 -0
  55. package/dist/types/enum/reflex-error-code.enum.d.ts +3 -1
  56. package/dist/types/enum/reflex-error-code.enum.js +2 -0
  57. package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
  58. package/dist/types/enum/scheduled-run-failure-code.enum.d.ts +2 -1
  59. package/dist/types/enum/scheduled-run-failure-code.enum.js +1 -0
  60. package/dist/types/enum/scheduled-run-failure-code.enum.js.map +1 -1
  61. package/dist/types/enum/trigger-kind.enum.d.ts +7 -0
  62. package/dist/types/enum/trigger-kind.enum.js +12 -0
  63. package/dist/types/enum/trigger-kind.enum.js.map +1 -0
  64. package/dist/types/interface/api/requests/index.d.ts +2 -0
  65. package/dist/types/interface/api/requests/index.js +2 -0
  66. package/dist/types/interface/api/requests/index.js.map +1 -1
  67. package/dist/types/interface/api/requests/service-discord-event.request.d.ts +51 -0
  68. package/dist/types/interface/api/requests/service-discord-event.request.js +3 -0
  69. package/dist/types/interface/api/requests/service-discord-event.request.js.map +1 -0
  70. package/dist/types/interface/api/requests/service-discord.request.d.ts +22 -1
  71. package/dist/types/interface/api/requests/service-insights.request.d.ts +25 -0
  72. package/dist/types/interface/api/requests/service-insights.request.js +3 -0
  73. package/dist/types/interface/api/requests/service-insights.request.js.map +1 -0
  74. package/dist/types/interface/api/responses/index.d.ts +2 -0
  75. package/dist/types/interface/api/responses/index.js +2 -0
  76. package/dist/types/interface/api/responses/index.js.map +1 -1
  77. package/dist/types/interface/api/responses/service-discord-event.response.d.ts +18 -0
  78. package/dist/types/interface/api/responses/service-discord-event.response.js +3 -0
  79. package/dist/types/interface/api/responses/service-discord-event.response.js.map +1 -0
  80. package/dist/types/interface/api/responses/service-discord.response.d.ts +30 -5
  81. package/dist/types/interface/api/responses/service-insights.response.d.ts +8 -0
  82. package/dist/types/interface/api/responses/service-insights.response.js +3 -0
  83. package/dist/types/interface/api/responses/service-insights.response.js.map +1 -0
  84. package/dist/types/interface/api/responses/service-version.response.d.ts +9 -1
  85. package/dist/types/interface/models/index.d.ts +4 -0
  86. package/dist/types/interface/models/index.js +4 -0
  87. package/dist/types/interface/models/index.js.map +1 -1
  88. package/dist/types/interface/models/reflex-bot-limits.model.d.ts +56 -0
  89. package/dist/types/interface/models/reflex-bot-limits.model.js +16 -0
  90. package/dist/types/interface/models/reflex-bot-limits.model.js.map +1 -0
  91. package/dist/types/interface/models/reflex-discord-event-log.model.d.ts +38 -0
  92. package/dist/types/interface/models/reflex-discord-event-log.model.js +3 -0
  93. package/dist/types/interface/models/reflex-discord-event-log.model.js.map +1 -0
  94. package/dist/types/interface/models/reflex-discord-event.model.d.ts +41 -0
  95. package/dist/types/interface/models/reflex-discord-event.model.js +23 -0
  96. package/dist/types/interface/models/reflex-discord-event.model.js.map +1 -0
  97. package/dist/types/interface/models/reflex-insights.model.d.ts +83 -0
  98. package/dist/types/interface/models/reflex-insights.model.js +16 -0
  99. package/dist/types/interface/models/reflex-insights.model.js.map +1 -0
  100. package/dist/types/interface/models/reflex-run.model.d.ts +2 -0
  101. package/dist/types/interface/models/reflex-service-version.model.d.ts +2 -0
  102. package/package.json +1 -1
  103. package/src/api/function-insights.api.test.ts +27 -0
  104. package/src/api/function-insights.api.ts +18 -0
  105. package/src/api/index.ts +17 -14
  106. package/src/api/service-discord-event.api.test.ts +106 -0
  107. package/src/api/service-discord-event.api.ts +78 -0
  108. package/src/api/service-discord.api.test.ts +197 -170
  109. package/src/api/service-discord.api.ts +241 -203
  110. package/src/api/service-insights.api.test.ts +36 -0
  111. package/src/api/service-insights.api.ts +42 -0
  112. package/src/api/service-task.api.test.ts +140 -140
  113. package/src/api/service-task.api.ts +141 -141
  114. package/src/discord/discord-event-filter-cases.ts +261 -0
  115. package/src/discord/discord-event-filters.test.ts +91 -0
  116. package/src/discord/discord-event-filters.ts +95 -0
  117. package/src/discord/discord-event-intents.test.ts +112 -0
  118. package/src/discord/discord-event-intents.ts +55 -0
  119. package/src/discord/index.ts +3 -0
  120. package/src/index.test.ts +75 -50
  121. package/src/index.ts +46 -0
  122. package/src/types/enum/bot-event-block-reason.enum.ts +7 -0
  123. package/src/types/enum/discord-event-drop-reason.enum.ts +13 -0
  124. package/src/types/enum/discord-event-filter-name.enum.ts +11 -0
  125. package/src/types/enum/discord-event-status.enum.ts +13 -0
  126. package/src/types/enum/discord-event-type.enum.ts +7 -0
  127. package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -9
  128. package/src/types/enum/index.ts +7 -0
  129. package/src/types/enum/insights-period.enum.ts +8 -0
  130. package/src/types/enum/reflex-error-code.enum.ts +43 -39
  131. package/src/types/enum/schedule-sync-status.enum.ts +6 -6
  132. package/src/types/enum/scheduled-run-failure-code.enum.ts +2 -0
  133. package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
  134. package/src/types/enum/scheduled-run-status.enum.ts +17 -17
  135. package/src/types/enum/trigger-kind.enum.ts +8 -0
  136. package/src/types/interface/api/requests/index.ts +15 -13
  137. package/src/types/interface/api/requests/service-discord-event.request.ts +68 -0
  138. package/src/types/interface/api/requests/service-discord.request.ts +161 -128
  139. package/src/types/interface/api/requests/service-insights.request.ts +31 -0
  140. package/src/types/interface/api/requests/service-task.request.ts +80 -80
  141. package/src/types/interface/api/responses/index.ts +15 -13
  142. package/src/types/interface/api/responses/service-discord-event.response.ts +24 -0
  143. package/src/types/interface/api/responses/service-discord.response.ts +122 -72
  144. package/src/types/interface/api/responses/service-insights.response.ts +11 -0
  145. package/src/types/interface/api/responses/service-task.response.ts +57 -57
  146. package/src/types/interface/api/responses/service-version.response.ts +106 -91
  147. package/src/types/interface/models/index.ts +19 -15
  148. package/src/types/interface/models/reflex-bot-limits.model.ts +92 -0
  149. package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -0
  150. package/src/types/interface/models/reflex-discord-event.model.ts +77 -0
  151. package/src/types/interface/models/reflex-insights.model.ts +120 -0
  152. package/src/types/interface/models/reflex-run.model.ts +183 -179
  153. package/src/types/interface/models/reflex-service-version.model.ts +61 -58
  154. package/src/types/interface/models/reflex-task.model.ts +97 -97
package/src/index.test.ts CHANGED
@@ -1,50 +1,75 @@
1
- import { AxiosAdapter, AxiosError, InternalAxiosRequestConfig } from 'axios';
2
- import { AbyssReflexCore, HealthStatus, IHealthResponse } from '.';
3
-
4
- const answer =
5
- (status: number, data: IHealthResponse): AxiosAdapter =>
6
- async (config: InternalAxiosRequestConfig) => {
7
- const response = { data, status, statusText: '', headers: {}, config };
8
- if (status >= 400) {
9
- throw new AxiosError('failed', 'ERR_BAD_RESPONSE', config, null, response);
10
- }
11
- return response;
12
- };
13
-
14
- describe('AbyssReflexCore', () => {
15
- it('points at the production API until setConfig says otherwise', () => {
16
- expect(AbyssReflexCore.getConfig().baseURL).toBe('https://reflex-api.abyss-project.fr/');
17
- });
18
-
19
- it('setConfig changes the base URL of the axios instance', () => {
20
- AbyssReflexCore.setConfig({ baseURL: 'http://localhost:10141/' });
21
- expect(AbyssReflexCore.axios.defaults.baseURL).toBe('http://localhost:10141/');
22
- expect(AbyssReflexCore.getConfig().baseURL).toBe('http://localhost:10141/');
23
- });
24
-
25
- it('health() calls GET /health on the configured URL and returns the typed body', async () => {
26
- const adapter = jest.fn(answer(200, { database: HealthStatus.UP, redis: HealthStatus.UP }));
27
- AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/' });
28
- AbyssReflexCore.axios.defaults.adapter = adapter;
29
-
30
- const body = await AbyssReflexCore.sdk.health();
31
-
32
- expect(body).toEqual({ database: 'up', redis: 'up' });
33
- const config = adapter.mock.calls[0][0];
34
- expect(config.method).toBe('get');
35
- expect(config.url).toBe('health');
36
- expect(config.baseURL).toBe('http://reflex.test/');
37
- });
38
-
39
- it('health() rejects on a 503 and the error carries the component that is down', async () => {
40
- AbyssReflexCore.axios.defaults.adapter = answer(503, {
41
- database: HealthStatus.DOWN,
42
- redis: HealthStatus.UP,
43
- });
44
-
45
- const error = await AbyssReflexCore.sdk.health().catch((e: AxiosError<IHealthResponse>) => e);
46
-
47
- expect((error as AxiosError<IHealthResponse>).response?.status).toBe(503);
48
- expect((error as AxiosError<IHealthResponse>).response?.data.database).toBe(HealthStatus.DOWN);
49
- });
50
- });
1
+ import { AxiosAdapter, AxiosError, InternalAxiosRequestConfig } from 'axios';
2
+ import {
3
+ AbyssReflexCore,
4
+ HealthStatus,
5
+ IHealthResponse,
6
+ intentsOf,
7
+ matchesEventFilters,
8
+ privilegedIntentsOf,
9
+ } from '.';
10
+
11
+ const answer =
12
+ (status: number, data: IHealthResponse): AxiosAdapter =>
13
+ async (config: InternalAxiosRequestConfig) => {
14
+ const response = { data, status, statusText: '', headers: {}, config };
15
+ if (status >= 400) {
16
+ throw new AxiosError('failed', 'ERR_BAD_RESPONSE', config, null, response);
17
+ }
18
+ return response;
19
+ };
20
+
21
+ describe('AbyssReflexCore', () => {
22
+ it('points at the production API until setConfig says otherwise', () => {
23
+ expect(AbyssReflexCore.getConfig().baseURL).toBe('https://reflex-api.abyss-project.fr/');
24
+ });
25
+
26
+ it('setConfig changes the base URL of the axios instance', () => {
27
+ AbyssReflexCore.setConfig({ baseURL: 'http://localhost:10141/' });
28
+ expect(AbyssReflexCore.axios.defaults.baseURL).toBe('http://localhost:10141/');
29
+ expect(AbyssReflexCore.getConfig().baseURL).toBe('http://localhost:10141/');
30
+ });
31
+
32
+ it('health() calls GET /health on the configured URL and returns the typed body', async () => {
33
+ const adapter = jest.fn(answer(200, { database: HealthStatus.UP, redis: HealthStatus.UP }));
34
+ AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/' });
35
+ AbyssReflexCore.axios.defaults.adapter = adapter;
36
+
37
+ const body = await AbyssReflexCore.sdk.health();
38
+
39
+ expect(body).toEqual({ database: 'up', redis: 'up' });
40
+ const config = adapter.mock.calls[0][0];
41
+ expect(config.method).toBe('get');
42
+ expect(config.url).toBe('health');
43
+ expect(config.baseURL).toBe('http://reflex.test/');
44
+ });
45
+
46
+ it('health() rejects on a 503 and the error carries the component that is down', async () => {
47
+ AbyssReflexCore.axios.defaults.adapter = answer(503, {
48
+ database: HealthStatus.DOWN,
49
+ redis: HealthStatus.UP,
50
+ });
51
+
52
+ const error = await AbyssReflexCore.sdk.health().catch((e: AxiosError<IHealthResponse>) => e);
53
+
54
+ expect((error as AxiosError<IHealthResponse>).response?.status).toBe(503);
55
+ expect((error as AxiosError<IHealthResponse>).response?.data.database).toBe(HealthStatus.DOWN);
56
+ });
57
+ });
58
+
59
+ describe('AbyssReflexCore facade of the Discord events', () => {
60
+ it('exposes the pure event helpers of the SDK', () => {
61
+ expect(intentsOf([])).toBe(0);
62
+ expect(typeof matchesEventFilters).toBe('function');
63
+ expect(typeof privilegedIntentsOf).toBe('function');
64
+ });
65
+
66
+ it('exposes the event, insights and bot limit routes under short names', () => {
67
+ const { service, function: fn } = AbyssReflexCore.sdk;
68
+ expect(Object.keys(service.discord.event)).toEqual(['list', 'create', 'update', 'delete']);
69
+ expect(Object.keys(service.discord.eventLog)).toEqual(['list']);
70
+ expect(Object.keys(service.insights)).toEqual(['get', 'events']);
71
+ expect(Object.keys(fn.insights)).toEqual(['get']);
72
+ expect(service.discord.connection.setAllocation).toBeInstanceOf(Function);
73
+ expect(service.discord.connection.setBotSettings).toBeInstanceOf(Function);
74
+ });
75
+ });
package/src/index.ts CHANGED
@@ -12,10 +12,14 @@ import * as serviceVersionApi from './api/service-version.api';
12
12
  import * as serviceDeploymentApi from './api/service-deployment.api';
13
13
  import * as serviceConfigurationApi from './api/service-configuration.api';
14
14
  import * as serviceDiscordApi from './api/service-discord.api';
15
+ import * as serviceDiscordEventApi from './api/service-discord-event.api';
16
+ import * as serviceInsightsApi from './api/service-insights.api';
17
+ import * as functionInsightsApi from './api/function-insights.api';
15
18
  import * as serviceTaskApi from './api/service-task.api';
16
19
 
17
20
  export * from './api';
18
21
  export * from './types';
22
+ export * from './discord';
19
23
 
20
24
  const DEFAULT_BASE_URL = 'https://reflex-api.abyss-project.fr/';
21
25
 
@@ -53,6 +57,10 @@ type AbyssReflexCoreSDK = {
53
57
  get: typeof functionRunApi.getFunctionRun;
54
58
  state: typeof functionRunApi.getFunctionRunState;
55
59
  };
60
+ /** The dashboard of the function: tiles, series, ranking. */
61
+ insights: {
62
+ get: typeof functionInsightsApi.getFunctionInsights;
63
+ };
56
64
  settings: {
57
65
  get: typeof functionSettingsApi.getFunctionSettings;
58
66
  setDefault: typeof functionSettingsApi.setFunctionDefaultSettings;
@@ -90,6 +98,11 @@ type AbyssReflexCoreSDK = {
90
98
  configuration: {
91
99
  list: typeof serviceConfigurationApi.listServiceConfiguration;
92
100
  };
101
+ /** The dashboards of the Service, and of the Discord events of a bot. */
102
+ insights: {
103
+ get: typeof serviceInsightsApi.getServiceInsights;
104
+ events: typeof serviceInsightsApi.getServiceEventInsights;
105
+ };
93
106
  /** A Discord bot Service: its commands and components, its connection, the push to Discord. */
94
107
  discord: {
95
108
  command: {
@@ -104,10 +117,25 @@ type AbyssReflexCoreSDK = {
104
117
  update: typeof serviceDiscordApi.updateServiceDiscordComponent;
105
118
  delete: typeof serviceDiscordApi.deleteServiceDiscordComponent;
106
119
  };
120
+ /** The Discord event triggers of the draft (message, reaction, member arrival and departure). */
121
+ event: {
122
+ list: typeof serviceDiscordEventApi.listServiceDiscordEvent;
123
+ create: typeof serviceDiscordEventApi.createServiceDiscordEvent;
124
+ update: typeof serviceDiscordEventApi.updateServiceDiscordEvent;
125
+ delete: typeof serviceDiscordEventApi.deleteServiceDiscordEvent;
126
+ };
127
+ /** The events of the bot in an environment: the retained ones and a sample of the dropped ones. */
128
+ eventLog: {
129
+ list: typeof serviceDiscordEventApi.listServiceDiscordEventLog;
130
+ };
107
131
  connection: {
108
132
  get: typeof serviceDiscordApi.getServiceDiscordConnection;
109
133
  setTokenSecret: typeof serviceDiscordApi.setServiceDiscordTokenSecret;
110
134
  setEnvironment: typeof serviceDiscordApi.setServiceDiscordEnvironment;
135
+ /** The lots of the reserve of events per minute the bot holds in an environment. */
136
+ setAllocation: typeof serviceDiscordApi.setServiceDiscordAllocation;
137
+ /** Credit overage, monthly spend cap and alerts of the bot in an environment. */
138
+ setBotSettings: typeof serviceDiscordApi.setServiceDiscordBotSettings;
111
139
  check: typeof serviceDiscordApi.checkServiceDiscordConnection;
112
140
  };
113
141
  /** Pushes the interactions address and the commands to Discord again. */
@@ -173,6 +201,9 @@ export class AbyssReflexCore {
173
201
  get: functionRunApi.getFunctionRun,
174
202
  state: functionRunApi.getFunctionRunState,
175
203
  },
204
+ insights: {
205
+ get: functionInsightsApi.getFunctionInsights,
206
+ },
176
207
  settings: {
177
208
  get: functionSettingsApi.getFunctionSettings,
178
209
  setDefault: functionSettingsApi.setFunctionDefaultSettings,
@@ -209,6 +240,10 @@ export class AbyssReflexCore {
209
240
  configuration: {
210
241
  list: serviceConfigurationApi.listServiceConfiguration,
211
242
  },
243
+ insights: {
244
+ get: serviceInsightsApi.getServiceInsights,
245
+ events: serviceInsightsApi.getServiceEventInsights,
246
+ },
212
247
  discord: {
213
248
  command: {
214
249
  list: serviceDiscordApi.listServiceDiscordCommand,
@@ -222,10 +257,21 @@ export class AbyssReflexCore {
222
257
  update: serviceDiscordApi.updateServiceDiscordComponent,
223
258
  delete: serviceDiscordApi.deleteServiceDiscordComponent,
224
259
  },
260
+ event: {
261
+ list: serviceDiscordEventApi.listServiceDiscordEvent,
262
+ create: serviceDiscordEventApi.createServiceDiscordEvent,
263
+ update: serviceDiscordEventApi.updateServiceDiscordEvent,
264
+ delete: serviceDiscordEventApi.deleteServiceDiscordEvent,
265
+ },
266
+ eventLog: {
267
+ list: serviceDiscordEventApi.listServiceDiscordEventLog,
268
+ },
225
269
  connection: {
226
270
  get: serviceDiscordApi.getServiceDiscordConnection,
227
271
  setTokenSecret: serviceDiscordApi.setServiceDiscordTokenSecret,
228
272
  setEnvironment: serviceDiscordApi.setServiceDiscordEnvironment,
273
+ setAllocation: serviceDiscordApi.setServiceDiscordAllocation,
274
+ setBotSettings: serviceDiscordApi.setServiceDiscordBotSettings,
229
275
  check: serviceDiscordApi.checkServiceDiscordConnection,
230
276
  },
231
277
  sync: serviceDiscordApi.retryServiceDiscordSync,
@@ -0,0 +1,7 @@
1
+ /** Why the events of a bot are rejected at the Gateway. */
2
+ export enum BotEventBlockReason {
3
+ /** The monthly spend cap of the bot is reached. */
4
+ MONTHLY_CAP = 'MONTHLY_CAP',
5
+ /** The credits of the organization are spent and the bot has no overage. */
6
+ CREDITS_EXHAUSTED = 'CREDITS_EXHAUSTED',
7
+ }
@@ -0,0 +1,13 @@
1
+ /** Why a Discord event the Gateway received was not kept for execution. */
2
+ export enum DiscordEventDropReason {
3
+ /** A filter of the trigger rejected it (see `DiscordEventFilterName`). */
4
+ FILTERED = 'FILTERED',
5
+ /** The bot went past its events per minute. */
6
+ RATE = 'RATE',
7
+ /** The monthly spend cap of the bot is reached. */
8
+ MONTHLY_CAP = 'MONTHLY_CAP',
9
+ /** The credits of the organization are spent and the bot has no overage. */
10
+ CREDITS_EXHAUSTED = 'CREDITS_EXHAUSTED',
11
+ /** It waited in the inbox past the tolerance. */
12
+ EXPIRED = 'EXPIRED',
13
+ }
@@ -0,0 +1,11 @@
1
+ /** A filter of a Discord event trigger; the value is its key in `IReflexDiscordEventFilters` (and the name reported when it rejects an event), except `guildOnly`. */
2
+ export enum DiscordEventFilterName {
3
+ GUILD_IDS = 'guildIds',
4
+ CHANNEL_IDS = 'channelIds',
5
+ ROLE_IDS = 'roleIds',
6
+ CONTENT_PREFIX = 'contentPrefix',
7
+ IGNORE_BOTS = 'ignoreBots',
8
+ IGNORE_SELF = 'ignoreSelf',
9
+ /** Not a setting: events outside a server (direct messages) are always ignored. */
10
+ GUILD_ONLY = 'guildOnly',
11
+ }
@@ -0,0 +1,13 @@
1
+ /** Where a retained Discord event is in the inbox of the execution plane. */
2
+ export enum DiscordEventStatus {
3
+ /** Waiting to be taken by an edge. */
4
+ PENDING = 'PENDING',
5
+ /** Taken by an edge, running. */
6
+ CLAIMED = 'CLAIMED',
7
+ /** The function ran to its end. */
8
+ DONE = 'DONE',
9
+ /** The function failed, or the trigger left the version in service: never retried. */
10
+ FAILED = 'FAILED',
11
+ /** Not taken within the tolerance: never run, never billed. */
12
+ EXPIRED = 'EXPIRED',
13
+ }
@@ -0,0 +1,7 @@
1
+ /** A Discord Gateway event a function of a bot Service can be triggered by. */
2
+ export enum DiscordEventType {
3
+ GUILD_MEMBER_ADD = 'GUILD_MEMBER_ADD',
4
+ GUILD_MEMBER_REMOVE = 'GUILD_MEMBER_REMOVE',
5
+ MESSAGE_CREATE = 'MESSAGE_CREATE',
6
+ MESSAGE_REACTION_ADD = 'MESSAGE_REACTION_ADD',
7
+ }
@@ -1,9 +1,11 @@
1
- /** Why a Gateway connection is `FAILED`. */
2
- export enum DiscordGatewayFailureCode {
3
- /** Discord rejected the token (close code 4004). */
4
- TOKEN_REJECTED = 'TOKEN_REJECTED',
5
- /** The bot spent its identifications of the UTC day. */
6
- IDENTIFY_BUDGET = 'IDENTIFY_BUDGET',
7
- /** Discord refused the connection (close codes 4010 to 4014: invalid shard, sharding required, invalid or disallowed intents). */
8
- DISCORD_REFUSED = 'DISCORD_REFUSED',
9
- }
1
+ /** Why a Gateway connection is `FAILED`. */
2
+ export enum DiscordGatewayFailureCode {
3
+ /** Discord rejected the token (close code 4004). */
4
+ TOKEN_REJECTED = 'TOKEN_REJECTED',
5
+ /** The bot spent its identifications of the UTC day. */
6
+ IDENTIFY_BUDGET = 'IDENTIFY_BUDGET',
7
+ /** Discord refused the connection (close codes 4010 to 4013: invalid shard, sharding required, invalid API version, invalid intents). */
8
+ DISCORD_REFUSED = 'DISCORD_REFUSED',
9
+ /** Discord refused the intents the version in service asks for (close code 4014): a privileged intent is not enabled in the Discord portal. */
10
+ INTENTS_DISALLOWED = 'INTENTS_DISALLOWED',
11
+ }
@@ -31,3 +31,10 @@ export * from './schedule-sync-status.enum';
31
31
  export * from './scheduled-run-origin.enum';
32
32
  export * from './scheduled-run-status.enum';
33
33
  export * from './scheduled-run-failure-code.enum';
34
+ export * from './discord-event-type.enum';
35
+ export * from './discord-event-status.enum';
36
+ export * from './discord-event-drop-reason.enum';
37
+ export * from './discord-event-filter-name.enum';
38
+ export * from './bot-event-block-reason.enum';
39
+ export * from './insights-period.enum';
40
+ export * from './trigger-kind.enum';
@@ -0,0 +1,8 @@
1
+ /** The period a dashboard covers; the value is what the query string carries. */
2
+ export enum InsightsPeriod {
3
+ HOUR_1 = '1h',
4
+ HOURS_24 = '24h',
5
+ DAYS_7 = '7d',
6
+ DAYS_30 = '30d',
7
+ DAYS_90 = '90d',
8
+ }
@@ -1,39 +1,43 @@
1
- /** `error.code` of the refusals a client acts on. */
2
- export enum ReflexErrorCode {
3
- /** 400: the definition does not match the format; `error.details` holds the path of each fault. */
4
- INVALID_DEFINITION = 'INVALID_DEFINITION',
5
- /** 409: an access granted to the function is suspended; revoke it and grant it again. */
6
- GRANT_SUSPENDED = 'GRANT_SUSPENDED',
7
- /** 409: the function has no frozen version of its own draft yet, or none to go back to. */
8
- NO_VERSION = 'NO_VERSION',
9
- /** 409: the access to grant is not declared by the draft of the function. */
10
- ACCESS_NOT_DECLARED = 'ACCESS_NOT_DECLARED',
11
- /** 404: the environment is not one of the application's environments (abyss-main). */
12
- ENVIRONMENT_NOT_FOUND = 'ENVIRONMENT_NOT_FOUND',
13
- /** 409: a name, a path or an access already exists. */
14
- ALREADY_EXISTS = 'ALREADY_EXISTS',
15
- /** 403: the function is promoted in a production environment and the member lacks REFLEX_PUBLISH_PRODUCTION. */
16
- PUBLISH_PRODUCTION_REQUIRED = 'PUBLISH_PRODUCTION_REQUIRED',
17
- /** 503 (edge): the Service is paused in this environment; nothing ran, nothing is billed. */
18
- SERVICE_PAUSED = 'SERVICE_PAUSED',
19
- /** 429: the caller went past the limit; `Retry-After` and `RateLimit-*` say when to come back. */
20
- RATE_LIMIT_EXCEEDED = 'RATE_LIMIT_EXCEEDED',
21
- /** 409: the route would hide another one of the Service (same method, paths equal but for their parameters). */
22
- ROUTE_CONFLICT = 'ROUTE_CONFLICT',
23
- /** 409: the Service has not changed since its last version. */
24
- VERSION_UNCHANGED = 'VERSION_UNCHANGED',
25
- /** 409: the Discord bot token has no value in this environment's Vault entry. */
26
- DISCORD_TOKEN_MISSING = 'DISCORD_TOKEN_MISSING',
27
- /** 409: Discord refused the bot token (401). */
28
- DISCORD_TOKEN_REJECTED = 'DISCORD_TOKEN_REJECTED',
29
- /** 409: a non-production environment needs a test server before a Discord bot goes live there. */
30
- DISCORD_TEST_GUILD_REQUIRED = 'DISCORD_TEST_GUILD_REQUIRED',
31
- /** 409: a command of that name already exists in the Service. */
32
- DISCORD_COMMAND_CONFLICT = 'DISCORD_COMMAND_CONFLICT',
33
- /** 409: the component prefix equals, starts or is started by another prefix of the Service. */
34
- DISCORD_COMPONENT_PREFIX_CONFLICT = 'DISCORD_COMPONENT_PREFIX_CONFLICT',
35
- /** 400: the field does not exist for this type of Service (CORS or rate limit on a Discord bot). */
36
- SERVICE_TYPE_FIELD_REFUSED = 'SERVICE_TYPE_FIELD_REFUSED',
37
- /** 400: a route path cannot start with `_abyss`, the segment the edge keeps for its own addresses (ticks of the cron tasks). */
38
- ROUTE_SEGMENT_RESERVED = 'ROUTE_SEGMENT_RESERVED',
39
- }
1
+ /** `error.code` of the refusals a client acts on. */
2
+ export enum ReflexErrorCode {
3
+ /** 400: the definition does not match the format; `error.details` holds the path of each fault. */
4
+ INVALID_DEFINITION = 'INVALID_DEFINITION',
5
+ /** 409: an access granted to the function is suspended; revoke it and grant it again. */
6
+ GRANT_SUSPENDED = 'GRANT_SUSPENDED',
7
+ /** 409: the function has no frozen version of its own draft yet, or none to go back to. */
8
+ NO_VERSION = 'NO_VERSION',
9
+ /** 409: the access to grant is not declared by the draft of the function. */
10
+ ACCESS_NOT_DECLARED = 'ACCESS_NOT_DECLARED',
11
+ /** 404: the environment is not one of the application's environments (abyss-main). */
12
+ ENVIRONMENT_NOT_FOUND = 'ENVIRONMENT_NOT_FOUND',
13
+ /** 409: a name, a path or an access already exists. */
14
+ ALREADY_EXISTS = 'ALREADY_EXISTS',
15
+ /** 403: the function is promoted in a production environment and the member lacks REFLEX_PUBLISH_PRODUCTION. */
16
+ PUBLISH_PRODUCTION_REQUIRED = 'PUBLISH_PRODUCTION_REQUIRED',
17
+ /** 503 (edge): the Service is paused in this environment; nothing ran, nothing is billed. */
18
+ SERVICE_PAUSED = 'SERVICE_PAUSED',
19
+ /** 429: the caller went past the limit; `Retry-After` and `RateLimit-*` say when to come back. */
20
+ RATE_LIMIT_EXCEEDED = 'RATE_LIMIT_EXCEEDED',
21
+ /** 409: the route would hide another one of the Service (same method, paths equal but for their parameters). */
22
+ ROUTE_CONFLICT = 'ROUTE_CONFLICT',
23
+ /** 409: the Service has not changed since its last version. */
24
+ VERSION_UNCHANGED = 'VERSION_UNCHANGED',
25
+ /** 409: the Discord bot token has no value in this environment's Vault entry. */
26
+ DISCORD_TOKEN_MISSING = 'DISCORD_TOKEN_MISSING',
27
+ /** 409: Discord refused the bot token (401). */
28
+ DISCORD_TOKEN_REJECTED = 'DISCORD_TOKEN_REJECTED',
29
+ /** 409: a non-production environment needs a test server before a Discord bot goes live there. */
30
+ DISCORD_TEST_GUILD_REQUIRED = 'DISCORD_TEST_GUILD_REQUIRED',
31
+ /** 409: a command of that name already exists in the Service. */
32
+ DISCORD_COMMAND_CONFLICT = 'DISCORD_COMMAND_CONFLICT',
33
+ /** 409: the component prefix equals, starts or is started by another prefix of the Service. */
34
+ DISCORD_COMPONENT_PREFIX_CONFLICT = 'DISCORD_COMPONENT_PREFIX_CONFLICT',
35
+ /** 400: the field does not exist for this type of Service (CORS or rate limit on a Discord bot). */
36
+ SERVICE_TYPE_FIELD_REFUSED = 'SERVICE_TYPE_FIELD_REFUSED',
37
+ /** 400: a route path cannot start with `_abyss`, the segment the edge keeps for its own addresses (ticks of the cron tasks). */
38
+ ROUTE_SEGMENT_RESERVED = 'ROUTE_SEGMENT_RESERVED',
39
+ /** 409: the bot bills credit overage but the organization does not allow overage of the credits metric. */
40
+ CREDIT_OVERAGE_NOT_ALLOWED = 'CREDIT_OVERAGE_NOT_ALLOWED',
41
+ /** 409: the lots asked for do not fit in the event rate reserve of the organization (the sum of its allocations would go past it). */
42
+ BOT_EVENT_RESERVE_EXCEEDED = 'BOT_EVENT_RESERVE_EXCEEDED',
43
+ }
@@ -1,6 +1,6 @@
1
- /** State of the synchronization of the cron tasks of the version in service with Flow, per environment. */
2
- export enum ScheduleSyncStatus {
3
- PENDING = 'PENDING',
4
- SYNCED = 'SYNCED',
5
- FAILED = 'FAILED',
6
- }
1
+ /** State of the synchronization of the cron tasks of the version in service with Flow, per environment. */
2
+ export enum ScheduleSyncStatus {
3
+ PENDING = 'PENDING',
4
+ SYNCED = 'SYNCED',
5
+ FAILED = 'FAILED',
6
+ }
@@ -7,4 +7,6 @@ export enum ScheduledRunFailureCode {
7
7
  TASK_REMOVED = 'TASK_REMOVED',
8
8
  /** Every attempt was interrupted by the end of its edge. */
9
9
  ATTEMPTS_EXHAUSTED = 'ATTEMPTS_EXHAUSTED',
10
+ /** The credits of the organization are spent and the bot has no overage: the run stopped, nothing ran, nothing is billed. */
11
+ CREDITS_EXHAUSTED = 'CREDITS_EXHAUSTED',
10
12
  }
@@ -1,5 +1,5 @@
1
- /** What queued a scheduled run of a task: a tick of its cron (sent by Flow), or a delayed run the code scheduled. */
2
- export enum ScheduledRunOrigin {
3
- RECURRING = 'RECURRING',
4
- DELAYED = 'DELAYED',
5
- }
1
+ /** What queued a scheduled run of a task: a tick of its cron (sent by Flow), or a delayed run the code scheduled. */
2
+ export enum ScheduledRunOrigin {
3
+ RECURRING = 'RECURRING',
4
+ DELAYED = 'DELAYED',
5
+ }
@@ -1,17 +1,17 @@
1
- /** Where a scheduled run of a task stands (`scheduled_runs.status` of the execution plane). */
2
- export enum ScheduledRunStatus {
3
- /** Waiting for its due date, or due and not yet taken by an edge. */
4
- PENDING = 'PENDING',
5
- /** An edge runs it. */
6
- CLAIMED = 'CLAIMED',
7
- /** Ran to its end. */
8
- DONE = 'DONE',
9
- /** Did not run to its end: `failureCode` says why. */
10
- FAILED = 'FAILED',
11
- /** Cancelled before it ran (`abyss.schedule.cancel` or the screen). */
12
- CANCELLED = 'CANCELLED',
13
- /** Taken too late, past the tolerance (after a pause or an outage): ran nothing, cost nothing. */
14
- EXPIRED = 'EXPIRED',
15
- /** A tick of a cron that came while the previous one still ran: ran nothing, cost nothing. */
16
- SKIPPED = 'SKIPPED',
17
- }
1
+ /** Where a scheduled run of a task stands (`scheduled_runs.status` of the execution plane). */
2
+ export enum ScheduledRunStatus {
3
+ /** Waiting for its due date, or due and not yet taken by an edge. */
4
+ PENDING = 'PENDING',
5
+ /** An edge runs it. */
6
+ CLAIMED = 'CLAIMED',
7
+ /** Ran to its end. */
8
+ DONE = 'DONE',
9
+ /** Did not run to its end: `failureCode` says why. */
10
+ FAILED = 'FAILED',
11
+ /** Cancelled before it ran (`abyss.schedule.cancel` or the screen). */
12
+ CANCELLED = 'CANCELLED',
13
+ /** Taken too late, past the tolerance (after a pause or an outage): ran nothing, cost nothing. */
14
+ EXPIRED = 'EXPIRED',
15
+ /** A tick of a cron that came while the previous one still ran: ran nothing, cost nothing. */
16
+ SKIPPED = 'SKIPPED',
17
+ }
@@ -0,0 +1,8 @@
1
+ /** What started an execution of a Service. */
2
+ export enum TriggerKind {
3
+ COMMAND = 'COMMAND',
4
+ COMPONENT = 'COMPONENT',
5
+ EVENT = 'EVENT',
6
+ TASK = 'TASK',
7
+ ROUTE = 'ROUTE',
8
+ }
@@ -1,13 +1,15 @@
1
- export * from './function.request';
2
- export * from './function-access.request';
3
- export * from './function-test.request';
4
- export * from './function-version.request';
5
- export * from './function-run.request';
6
- export * from './function-settings.request';
7
- export * from './service.request';
8
- export * from './service-route.request';
9
- export * from './service-version.request';
10
- export * from './service-deployment.request';
11
- export * from './service-configuration.request';
12
- export * from './service-discord.request';
13
- export * from './service-task.request';
1
+ export * from './function.request';
2
+ export * from './function-access.request';
3
+ export * from './function-test.request';
4
+ export * from './function-version.request';
5
+ export * from './function-run.request';
6
+ export * from './function-settings.request';
7
+ export * from './service.request';
8
+ export * from './service-route.request';
9
+ export * from './service-version.request';
10
+ export * from './service-deployment.request';
11
+ export * from './service-configuration.request';
12
+ export * from './service-discord.request';
13
+ export * from './service-task.request';
14
+ export * from './service-discord-event.request';
15
+ export * from './service-insights.request';
@@ -0,0 +1,68 @@
1
+ import type { DiscordEventDropReason, DiscordEventStatus, DiscordEventType } from '../../../enum';
2
+ import type { IReflexDiscordEventFilters } from '../../models';
3
+
4
+ export interface IListServiceDiscordEventParams {
5
+ applicationId: string;
6
+ serviceId: string;
7
+ }
8
+
9
+ export interface ICreateServiceDiscordEventParams {
10
+ applicationId: string;
11
+ serviceId: string;
12
+ }
13
+ export interface ICreateServiceDiscordEventBody {
14
+ /** `^[-_a-z0-9]{1,32}$`, unique within the Service. */
15
+ name: string;
16
+ eventType: DiscordEventType;
17
+ /** A function of the same Service. */
18
+ functionId: string;
19
+ /** Empty by default: no filter. */
20
+ filters?: IReflexDiscordEventFilters;
21
+ /** `true` by default. */
22
+ ordered?: boolean;
23
+ /** `false` by default, `MESSAGE_CREATE` only; asks for the MESSAGE_CONTENT intent. */
24
+ includeContent?: boolean;
25
+ }
26
+
27
+ export interface IUpdateServiceDiscordEventParams {
28
+ applicationId: string;
29
+ serviceId: string;
30
+ eventId: string;
31
+ }
32
+ export interface IUpdateServiceDiscordEventBody {
33
+ name?: string;
34
+ eventType?: DiscordEventType;
35
+ functionId?: string;
36
+ filters?: IReflexDiscordEventFilters;
37
+ ordered?: boolean;
38
+ includeContent?: boolean;
39
+ }
40
+
41
+ export interface IDeleteServiceDiscordEventParams {
42
+ applicationId: string;
43
+ serviceId: string;
44
+ eventId: string;
45
+ }
46
+
47
+ export interface IListServiceDiscordEventLogParams {
48
+ applicationId: string;
49
+ serviceId: string;
50
+ }
51
+ export interface IListServiceDiscordEventLogQuery {
52
+ /** The environment of the application (abyss-main's id). */
53
+ environmentId: string;
54
+ /** Only the retained events in this status; drops the dropped ones from the page. */
55
+ status?: DiscordEventStatus;
56
+ /** Only the dropped events for this reason; drops the retained ones from the page. */
57
+ reason?: DiscordEventDropReason;
58
+ type?: DiscordEventType;
59
+ triggerId?: string;
60
+ /** ISO 8601, included. */
61
+ from?: string;
62
+ /** ISO 8601, excluded. */
63
+ to?: string;
64
+ /** The `nextCursor` of the previous page. */
65
+ cursor?: string;
66
+ /** 1 to 100, 50 by default. */
67
+ limit?: number;
68
+ }