@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.
- package/dist/api/function-insights.api.d.ts +2 -0
- package/dist/api/function-insights.api.js +7 -0
- package/dist/api/function-insights.api.js.map +1 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +3 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/service-discord-event.api.d.ts +6 -0
- package/dist/api/service-discord-event.api.js +18 -0
- package/dist/api/service-discord-event.api.js.map +1 -0
- package/dist/api/service-discord.api.d.ts +3 -1
- package/dist/api/service-discord.api.js +5 -1
- package/dist/api/service-discord.api.js.map +1 -1
- package/dist/api/service-insights.api.d.ts +3 -0
- package/dist/api/service-insights.api.js +12 -0
- package/dist/api/service-insights.api.js.map +1 -0
- package/dist/discord/discord-event-filter-cases.d.ts +15 -0
- package/dist/discord/discord-event-filter-cases.js +77 -0
- package/dist/discord/discord-event-filter-cases.js.map +1 -0
- package/dist/discord/discord-event-filters.d.ts +20 -0
- package/dist/discord/discord-event-filters.js +50 -0
- package/dist/discord/discord-event-filters.js.map +1 -0
- package/dist/discord/discord-event-intents.d.ts +14 -0
- package/dist/discord/discord-event-intents.js +38 -0
- package/dist/discord/discord-event-intents.js.map +1 -0
- package/dist/discord/index.d.ts +3 -0
- package/dist/discord/index.js +20 -0
- package/dist/discord/index.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/dist/types/enum/bot-event-block-reason.enum.d.ts +4 -0
- package/dist/types/enum/bot-event-block-reason.enum.js +9 -0
- package/dist/types/enum/bot-event-block-reason.enum.js.map +1 -0
- package/dist/types/enum/discord-event-drop-reason.enum.d.ts +7 -0
- package/dist/types/enum/discord-event-drop-reason.enum.js +12 -0
- package/dist/types/enum/discord-event-drop-reason.enum.js.map +1 -0
- package/dist/types/enum/discord-event-filter-name.enum.d.ts +9 -0
- package/dist/types/enum/discord-event-filter-name.enum.js +14 -0
- package/dist/types/enum/discord-event-filter-name.enum.js.map +1 -0
- package/dist/types/enum/discord-event-status.enum.d.ts +7 -0
- package/dist/types/enum/discord-event-status.enum.js +12 -0
- package/dist/types/enum/discord-event-status.enum.js.map +1 -0
- package/dist/types/enum/discord-event-type.enum.d.ts +6 -0
- package/dist/types/enum/discord-event-type.enum.js +11 -0
- package/dist/types/enum/discord-event-type.enum.js.map +1 -0
- package/dist/types/enum/discord-gateway-failure-code.enum.d.ts +2 -1
- package/dist/types/enum/discord-gateway-failure-code.enum.js +1 -0
- package/dist/types/enum/discord-gateway-failure-code.enum.js.map +1 -1
- package/dist/types/enum/index.d.ts +7 -0
- package/dist/types/enum/index.js +7 -0
- package/dist/types/enum/index.js.map +1 -1
- package/dist/types/enum/insights-period.enum.d.ts +7 -0
- package/dist/types/enum/insights-period.enum.js +12 -0
- package/dist/types/enum/insights-period.enum.js.map +1 -0
- package/dist/types/enum/reflex-error-code.enum.d.ts +3 -1
- package/dist/types/enum/reflex-error-code.enum.js +2 -0
- package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
- package/dist/types/enum/scheduled-run-failure-code.enum.d.ts +2 -1
- package/dist/types/enum/scheduled-run-failure-code.enum.js +1 -0
- package/dist/types/enum/scheduled-run-failure-code.enum.js.map +1 -1
- package/dist/types/enum/trigger-kind.enum.d.ts +7 -0
- package/dist/types/enum/trigger-kind.enum.js +12 -0
- package/dist/types/enum/trigger-kind.enum.js.map +1 -0
- package/dist/types/interface/api/requests/index.d.ts +2 -0
- package/dist/types/interface/api/requests/index.js +2 -0
- package/dist/types/interface/api/requests/index.js.map +1 -1
- package/dist/types/interface/api/requests/service-discord-event.request.d.ts +51 -0
- package/dist/types/interface/api/requests/service-discord-event.request.js +3 -0
- package/dist/types/interface/api/requests/service-discord-event.request.js.map +1 -0
- package/dist/types/interface/api/requests/service-discord.request.d.ts +22 -1
- package/dist/types/interface/api/requests/service-insights.request.d.ts +25 -0
- package/dist/types/interface/api/requests/service-insights.request.js +3 -0
- package/dist/types/interface/api/requests/service-insights.request.js.map +1 -0
- package/dist/types/interface/api/responses/index.d.ts +2 -0
- package/dist/types/interface/api/responses/index.js +2 -0
- package/dist/types/interface/api/responses/index.js.map +1 -1
- package/dist/types/interface/api/responses/service-discord-event.response.d.ts +18 -0
- package/dist/types/interface/api/responses/service-discord-event.response.js +3 -0
- package/dist/types/interface/api/responses/service-discord-event.response.js.map +1 -0
- package/dist/types/interface/api/responses/service-discord.response.d.ts +30 -5
- package/dist/types/interface/api/responses/service-insights.response.d.ts +8 -0
- package/dist/types/interface/api/responses/service-insights.response.js +3 -0
- package/dist/types/interface/api/responses/service-insights.response.js.map +1 -0
- package/dist/types/interface/api/responses/service-version.response.d.ts +9 -1
- package/dist/types/interface/models/index.d.ts +4 -0
- package/dist/types/interface/models/index.js +4 -0
- package/dist/types/interface/models/index.js.map +1 -1
- package/dist/types/interface/models/reflex-bot-limits.model.d.ts +56 -0
- package/dist/types/interface/models/reflex-bot-limits.model.js +16 -0
- package/dist/types/interface/models/reflex-bot-limits.model.js.map +1 -0
- package/dist/types/interface/models/reflex-discord-event-log.model.d.ts +38 -0
- package/dist/types/interface/models/reflex-discord-event-log.model.js +3 -0
- package/dist/types/interface/models/reflex-discord-event-log.model.js.map +1 -0
- package/dist/types/interface/models/reflex-discord-event.model.d.ts +41 -0
- package/dist/types/interface/models/reflex-discord-event.model.js +23 -0
- package/dist/types/interface/models/reflex-discord-event.model.js.map +1 -0
- package/dist/types/interface/models/reflex-insights.model.d.ts +83 -0
- package/dist/types/interface/models/reflex-insights.model.js +16 -0
- package/dist/types/interface/models/reflex-insights.model.js.map +1 -0
- package/dist/types/interface/models/reflex-run.model.d.ts +2 -0
- package/dist/types/interface/models/reflex-service-version.model.d.ts +2 -0
- package/package.json +1 -1
- package/src/api/function-insights.api.test.ts +27 -0
- package/src/api/function-insights.api.ts +18 -0
- package/src/api/index.ts +17 -14
- package/src/api/service-discord-event.api.test.ts +106 -0
- package/src/api/service-discord-event.api.ts +78 -0
- package/src/api/service-discord.api.test.ts +197 -170
- package/src/api/service-discord.api.ts +241 -203
- package/src/api/service-insights.api.test.ts +36 -0
- package/src/api/service-insights.api.ts +42 -0
- package/src/api/service-task.api.test.ts +140 -140
- package/src/api/service-task.api.ts +141 -141
- package/src/discord/discord-event-filter-cases.ts +261 -0
- package/src/discord/discord-event-filters.test.ts +91 -0
- package/src/discord/discord-event-filters.ts +95 -0
- package/src/discord/discord-event-intents.test.ts +112 -0
- package/src/discord/discord-event-intents.ts +55 -0
- package/src/discord/index.ts +3 -0
- package/src/index.test.ts +75 -50
- package/src/index.ts +46 -0
- package/src/types/enum/bot-event-block-reason.enum.ts +7 -0
- package/src/types/enum/discord-event-drop-reason.enum.ts +13 -0
- package/src/types/enum/discord-event-filter-name.enum.ts +11 -0
- package/src/types/enum/discord-event-status.enum.ts +13 -0
- package/src/types/enum/discord-event-type.enum.ts +7 -0
- package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -9
- package/src/types/enum/index.ts +7 -0
- package/src/types/enum/insights-period.enum.ts +8 -0
- package/src/types/enum/reflex-error-code.enum.ts +43 -39
- package/src/types/enum/schedule-sync-status.enum.ts +6 -6
- package/src/types/enum/scheduled-run-failure-code.enum.ts +2 -0
- package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
- package/src/types/enum/scheduled-run-status.enum.ts +17 -17
- package/src/types/enum/trigger-kind.enum.ts +8 -0
- package/src/types/interface/api/requests/index.ts +15 -13
- package/src/types/interface/api/requests/service-discord-event.request.ts +68 -0
- package/src/types/interface/api/requests/service-discord.request.ts +161 -128
- package/src/types/interface/api/requests/service-insights.request.ts +31 -0
- package/src/types/interface/api/requests/service-task.request.ts +80 -80
- package/src/types/interface/api/responses/index.ts +15 -13
- package/src/types/interface/api/responses/service-discord-event.response.ts +24 -0
- package/src/types/interface/api/responses/service-discord.response.ts +122 -72
- package/src/types/interface/api/responses/service-insights.response.ts +11 -0
- package/src/types/interface/api/responses/service-task.response.ts +57 -57
- package/src/types/interface/api/responses/service-version.response.ts +106 -91
- package/src/types/interface/models/index.ts +19 -15
- package/src/types/interface/models/reflex-bot-limits.model.ts +92 -0
- package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -0
- package/src/types/interface/models/reflex-discord-event.model.ts +77 -0
- package/src/types/interface/models/reflex-insights.model.ts +120 -0
- package/src/types/interface/models/reflex-run.model.ts +183 -179
- package/src/types/interface/models/reflex-service-version.model.ts +61 -58
- 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 {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
AbyssReflexCore.setConfig({ baseURL: 'http://
|
|
28
|
-
AbyssReflexCore.axios.defaults.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
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
|
+
}
|
package/src/types/enum/index.ts
CHANGED
|
@@ -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';
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|