@abyss-project/reflex 5.3.0 → 5.5.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 (161) 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/api/service-task.api.d.ts +2 -1
  17. package/dist/api/service-task.api.js +3 -1
  18. package/dist/api/service-task.api.js.map +1 -1
  19. package/dist/discord/discord-event-filter-cases.d.ts +15 -0
  20. package/dist/discord/discord-event-filter-cases.js +77 -0
  21. package/dist/discord/discord-event-filter-cases.js.map +1 -0
  22. package/dist/discord/discord-event-filters.d.ts +20 -0
  23. package/dist/discord/discord-event-filters.js +50 -0
  24. package/dist/discord/discord-event-filters.js.map +1 -0
  25. package/dist/discord/discord-event-intents.d.ts +14 -0
  26. package/dist/discord/discord-event-intents.js +38 -0
  27. package/dist/discord/discord-event-intents.js.map +1 -0
  28. package/dist/discord/index.d.ts +3 -0
  29. package/dist/discord/index.js +20 -0
  30. package/dist/discord/index.js.map +1 -0
  31. package/dist/index.d.ts +25 -0
  32. package/dist/index.js +25 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/types/enum/bot-event-block-reason.enum.d.ts +4 -0
  35. package/dist/types/enum/bot-event-block-reason.enum.js +9 -0
  36. package/dist/types/enum/bot-event-block-reason.enum.js.map +1 -0
  37. package/dist/types/enum/discord-event-drop-reason.enum.d.ts +7 -0
  38. package/dist/types/enum/discord-event-drop-reason.enum.js +12 -0
  39. package/dist/types/enum/discord-event-drop-reason.enum.js.map +1 -0
  40. package/dist/types/enum/discord-event-filter-name.enum.d.ts +9 -0
  41. package/dist/types/enum/discord-event-filter-name.enum.js +14 -0
  42. package/dist/types/enum/discord-event-filter-name.enum.js.map +1 -0
  43. package/dist/types/enum/discord-event-status.enum.d.ts +7 -0
  44. package/dist/types/enum/discord-event-status.enum.js +12 -0
  45. package/dist/types/enum/discord-event-status.enum.js.map +1 -0
  46. package/dist/types/enum/discord-event-type.enum.d.ts +6 -0
  47. package/dist/types/enum/discord-event-type.enum.js +11 -0
  48. package/dist/types/enum/discord-event-type.enum.js.map +1 -0
  49. package/dist/types/enum/discord-gateway-failure-code.enum.d.ts +2 -1
  50. package/dist/types/enum/discord-gateway-failure-code.enum.js +1 -0
  51. package/dist/types/enum/discord-gateway-failure-code.enum.js.map +1 -1
  52. package/dist/types/enum/index.d.ts +9 -0
  53. package/dist/types/enum/index.js +9 -0
  54. package/dist/types/enum/index.js.map +1 -1
  55. package/dist/types/enum/insights-period.enum.d.ts +7 -0
  56. package/dist/types/enum/insights-period.enum.js +12 -0
  57. package/dist/types/enum/insights-period.enum.js.map +1 -0
  58. package/dist/types/enum/scheduled-run-failure-code.enum.d.ts +5 -0
  59. package/dist/types/enum/scheduled-run-failure-code.enum.js +10 -0
  60. package/dist/types/enum/scheduled-run-failure-code.enum.js.map +1 -0
  61. package/dist/types/enum/scheduled-run-status.enum.d.ts +9 -0
  62. package/dist/types/enum/scheduled-run-status.enum.js +14 -0
  63. package/dist/types/enum/scheduled-run-status.enum.js.map +1 -0
  64. package/dist/types/enum/trigger-kind.enum.d.ts +7 -0
  65. package/dist/types/enum/trigger-kind.enum.js +12 -0
  66. package/dist/types/enum/trigger-kind.enum.js.map +1 -0
  67. package/dist/types/interface/api/requests/index.d.ts +2 -0
  68. package/dist/types/interface/api/requests/index.js +2 -0
  69. package/dist/types/interface/api/requests/index.js.map +1 -1
  70. package/dist/types/interface/api/requests/service-discord-event.request.d.ts +51 -0
  71. package/dist/types/interface/api/requests/service-discord-event.request.js +3 -0
  72. package/dist/types/interface/api/requests/service-discord-event.request.js.map +1 -0
  73. package/dist/types/interface/api/requests/service-discord.request.d.ts +22 -1
  74. package/dist/types/interface/api/requests/service-insights.request.d.ts +25 -0
  75. package/dist/types/interface/api/requests/service-insights.request.js +3 -0
  76. package/dist/types/interface/api/requests/service-insights.request.js.map +1 -0
  77. package/dist/types/interface/api/requests/service-task.request.d.ts +10 -0
  78. package/dist/types/interface/api/responses/index.d.ts +2 -0
  79. package/dist/types/interface/api/responses/index.js +2 -0
  80. package/dist/types/interface/api/responses/index.js.map +1 -1
  81. package/dist/types/interface/api/responses/service-discord-event.response.d.ts +18 -0
  82. package/dist/types/interface/api/responses/service-discord-event.response.js +3 -0
  83. package/dist/types/interface/api/responses/service-discord-event.response.js.map +1 -0
  84. package/dist/types/interface/api/responses/service-discord.response.d.ts +30 -5
  85. package/dist/types/interface/api/responses/service-insights.response.d.ts +8 -0
  86. package/dist/types/interface/api/responses/service-insights.response.js +3 -0
  87. package/dist/types/interface/api/responses/service-insights.response.js.map +1 -0
  88. package/dist/types/interface/api/responses/service-task.response.d.ts +6 -1
  89. package/dist/types/interface/api/responses/service-version.response.d.ts +9 -1
  90. package/dist/types/interface/models/index.d.ts +4 -0
  91. package/dist/types/interface/models/index.js +4 -0
  92. package/dist/types/interface/models/index.js.map +1 -1
  93. package/dist/types/interface/models/reflex-bot-limits.model.d.ts +56 -0
  94. package/dist/types/interface/models/reflex-bot-limits.model.js +16 -0
  95. package/dist/types/interface/models/reflex-bot-limits.model.js.map +1 -0
  96. package/dist/types/interface/models/reflex-discord-event-log.model.d.ts +38 -0
  97. package/dist/types/interface/models/reflex-discord-event-log.model.js +3 -0
  98. package/dist/types/interface/models/reflex-discord-event-log.model.js.map +1 -0
  99. package/dist/types/interface/models/reflex-discord-event.model.d.ts +41 -0
  100. package/dist/types/interface/models/reflex-discord-event.model.js +23 -0
  101. package/dist/types/interface/models/reflex-discord-event.model.js.map +1 -0
  102. package/dist/types/interface/models/reflex-insights.model.d.ts +83 -0
  103. package/dist/types/interface/models/reflex-insights.model.js +16 -0
  104. package/dist/types/interface/models/reflex-insights.model.js.map +1 -0
  105. package/dist/types/interface/models/reflex-run.model.d.ts +2 -0
  106. package/dist/types/interface/models/reflex-service-version.model.d.ts +2 -0
  107. package/dist/types/interface/models/reflex-task.model.d.ts +13 -0
  108. package/dist/types/interface/models/reflex-task.model.js +1 -0
  109. package/dist/types/interface/models/reflex-task.model.js.map +1 -1
  110. package/package.json +1 -1
  111. package/src/api/function-insights.api.test.ts +27 -0
  112. package/src/api/function-insights.api.ts +18 -0
  113. package/src/api/index.ts +17 -14
  114. package/src/api/service-discord-event.api.test.ts +106 -0
  115. package/src/api/service-discord-event.api.ts +78 -0
  116. package/src/api/service-discord.api.test.ts +197 -170
  117. package/src/api/service-discord.api.ts +241 -203
  118. package/src/api/service-insights.api.test.ts +36 -0
  119. package/src/api/service-insights.api.ts +42 -0
  120. package/src/api/service-task.api.test.ts +140 -124
  121. package/src/api/service-task.api.ts +141 -122
  122. package/src/discord/discord-event-filter-cases.ts +261 -0
  123. package/src/discord/discord-event-filters.test.ts +91 -0
  124. package/src/discord/discord-event-filters.ts +95 -0
  125. package/src/discord/discord-event-intents.test.ts +112 -0
  126. package/src/discord/discord-event-intents.ts +55 -0
  127. package/src/discord/index.ts +3 -0
  128. package/src/index.test.ts +75 -50
  129. package/src/index.ts +317 -264
  130. package/src/types/enum/bot-event-block-reason.enum.ts +7 -0
  131. package/src/types/enum/discord-event-drop-reason.enum.ts +13 -0
  132. package/src/types/enum/discord-event-filter-name.enum.ts +11 -0
  133. package/src/types/enum/discord-event-status.enum.ts +13 -0
  134. package/src/types/enum/discord-event-type.enum.ts +7 -0
  135. package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -9
  136. package/src/types/enum/index.ts +40 -31
  137. package/src/types/enum/insights-period.enum.ts +8 -0
  138. package/src/types/enum/schedule-sync-status.enum.ts +6 -6
  139. package/src/types/enum/scheduled-run-failure-code.enum.ts +12 -0
  140. package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
  141. package/src/types/enum/scheduled-run-status.enum.ts +17 -0
  142. package/src/types/enum/trigger-kind.enum.ts +8 -0
  143. package/src/types/interface/api/requests/index.ts +15 -13
  144. package/src/types/interface/api/requests/service-discord-event.request.ts +68 -0
  145. package/src/types/interface/api/requests/service-discord.request.ts +161 -128
  146. package/src/types/interface/api/requests/service-insights.request.ts +31 -0
  147. package/src/types/interface/api/requests/service-task.request.ts +80 -66
  148. package/src/types/interface/api/responses/index.ts +15 -13
  149. package/src/types/interface/api/responses/service-discord-event.response.ts +24 -0
  150. package/src/types/interface/api/responses/service-discord.response.ts +119 -72
  151. package/src/types/interface/api/responses/service-insights.response.ts +11 -0
  152. package/src/types/interface/api/responses/service-task.response.ts +57 -48
  153. package/src/types/interface/api/responses/service-version.response.ts +106 -91
  154. package/src/types/interface/models/index.ts +19 -15
  155. package/src/types/interface/models/reflex-bot-limits.model.ts +92 -0
  156. package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -0
  157. package/src/types/interface/models/reflex-discord-event.model.ts +77 -0
  158. package/src/types/interface/models/reflex-insights.model.ts +120 -0
  159. package/src/types/interface/models/reflex-run.model.ts +183 -179
  160. package/src/types/interface/models/reflex-service-version.model.ts +61 -58
  161. package/src/types/interface/models/reflex-task.model.ts +97 -61
package/src/index.ts CHANGED
@@ -1,264 +1,317 @@
1
- import axios from 'axios';
2
- import * as healthApi from './api/health.api';
3
- import * as functionApi from './api/function.api';
4
- import * as functionAccessApi from './api/function-access.api';
5
- import * as functionTestApi from './api/function-test.api';
6
- import * as functionVersionApi from './api/function-version.api';
7
- import * as functionRunApi from './api/function-run.api';
8
- import * as functionSettingsApi from './api/function-settings.api';
9
- import * as serviceApi from './api/service.api';
10
- import * as serviceRouteApi from './api/service-route.api';
11
- import * as serviceVersionApi from './api/service-version.api';
12
- import * as serviceDeploymentApi from './api/service-deployment.api';
13
- import * as serviceConfigurationApi from './api/service-configuration.api';
14
- import * as serviceDiscordApi from './api/service-discord.api';
15
- import * as serviceTaskApi from './api/service-task.api';
16
-
17
- export * from './api';
18
- export * from './types';
19
-
20
- const DEFAULT_BASE_URL = 'https://reflex-api.abyss-project.fr/';
21
-
22
- type CoreConfig = {
23
- baseURL?: string;
24
- /** The session token of the member (`Authorization: Bearer`). Every route but `health` needs it. */
25
- token?: string;
26
- };
27
-
28
- type AbyssReflexCoreSDK = {
29
- /** `GET /health` — status of the database and Redis behind the API. */
30
- health: typeof healthApi.health;
31
- function: {
32
- list: typeof functionApi.listFunction;
33
- create: typeof functionApi.createFunction;
34
- get: typeof functionApi.getFunction;
35
- update: typeof functionApi.updateFunction;
36
- delete: typeof functionApi.deleteFunction;
37
- access: {
38
- list: typeof functionAccessApi.listFunctionAccess;
39
- grant: typeof functionAccessApi.grantFunctionAccess;
40
- revoke: typeof functionAccessApi.revokeFunctionAccess;
41
- };
42
- test: {
43
- simulate: typeof functionTestApi.simulateFunction;
44
- dryRun: typeof functionTestApi.dryRunFunction;
45
- };
46
- version: {
47
- list: typeof functionVersionApi.listFunctionVersion;
48
- get: typeof functionVersionApi.getFunctionVersion;
49
- stepStats: typeof functionVersionApi.getFunctionVersionStepStats;
50
- };
51
- run: {
52
- list: typeof functionRunApi.listFunctionRun;
53
- get: typeof functionRunApi.getFunctionRun;
54
- state: typeof functionRunApi.getFunctionRunState;
55
- };
56
- settings: {
57
- get: typeof functionSettingsApi.getFunctionSettings;
58
- setDefault: typeof functionSettingsApi.setFunctionDefaultSettings;
59
- setEnvironment: typeof functionSettingsApi.setFunctionEnvironmentSettings;
60
- removeEnvironment: typeof functionSettingsApi.removeFunctionEnvironmentSettings;
61
- };
62
- };
63
- /** Services: the unit versioned, put in service and paused as one (`/api/service/:applicationId/...`). */
64
- service: {
65
- list: typeof serviceApi.listService;
66
- create: typeof serviceApi.createService;
67
- get: typeof serviceApi.getService;
68
- update: typeof serviceApi.updateService;
69
- delete: typeof serviceApi.deleteService;
70
- route: {
71
- list: typeof serviceRouteApi.listServiceRoute;
72
- create: typeof serviceRouteApi.createServiceRoute;
73
- update: typeof serviceRouteApi.updateServiceRoute;
74
- delete: typeof serviceRouteApi.deleteServiceRoute;
75
- rotate: typeof serviceRouteApi.rotateServiceRoute;
76
- };
77
- version: {
78
- list: typeof serviceVersionApi.listServiceVersion;
79
- create: typeof serviceVersionApi.createServiceVersion;
80
- get: typeof serviceVersionApi.getServiceVersion;
81
- draftStatus: typeof serviceVersionApi.getServiceVersionDraftStatus;
82
- };
83
- deployment: {
84
- list: typeof serviceDeploymentApi.listServiceDeployment;
85
- goLive: typeof serviceDeploymentApi.goLiveService;
86
- rollback: typeof serviceDeploymentApi.rollbackService;
87
- pause: typeof serviceDeploymentApi.pauseService;
88
- resume: typeof serviceDeploymentApi.resumeService;
89
- };
90
- configuration: {
91
- list: typeof serviceConfigurationApi.listServiceConfiguration;
92
- };
93
- /** A Discord bot Service: its commands and components, its connection, the push to Discord. */
94
- discord: {
95
- command: {
96
- list: typeof serviceDiscordApi.listServiceDiscordCommand;
97
- create: typeof serviceDiscordApi.createServiceDiscordCommand;
98
- update: typeof serviceDiscordApi.updateServiceDiscordCommand;
99
- delete: typeof serviceDiscordApi.deleteServiceDiscordCommand;
100
- };
101
- component: {
102
- list: typeof serviceDiscordApi.listServiceDiscordComponent;
103
- create: typeof serviceDiscordApi.createServiceDiscordComponent;
104
- update: typeof serviceDiscordApi.updateServiceDiscordComponent;
105
- delete: typeof serviceDiscordApi.deleteServiceDiscordComponent;
106
- };
107
- connection: {
108
- get: typeof serviceDiscordApi.getServiceDiscordConnection;
109
- setTokenSecret: typeof serviceDiscordApi.setServiceDiscordTokenSecret;
110
- setEnvironment: typeof serviceDiscordApi.setServiceDiscordEnvironment;
111
- check: typeof serviceDiscordApi.checkServiceDiscordConnection;
112
- };
113
- /** Pushes the interactions address and the commands to Discord again. */
114
- sync: typeof serviceDiscordApi.retryServiceDiscordSync;
115
- };
116
- /** The tasks of the Service (cron and delayed runs), their delayed runs, the synchronization with Flow. */
117
- task: {
118
- list: typeof serviceTaskApi.listServiceTask;
119
- create: typeof serviceTaskApi.createServiceTask;
120
- update: typeof serviceTaskApi.updateServiceTask;
121
- delete: typeof serviceTaskApi.deleteServiceTask;
122
- testRun: typeof serviceTaskApi.testRunServiceTask;
123
- delayedRun: {
124
- list: typeof serviceTaskApi.listServiceDelayedRun;
125
- cancel: typeof serviceTaskApi.cancelServiceDelayedRun;
126
- };
127
- /** Synchronizes the cron tasks of the version in service with Flow again. */
128
- sync: typeof serviceTaskApi.retryServiceScheduleSync;
129
- };
130
- };
131
- };
132
-
133
- export class AbyssReflexCore {
134
- private static config: CoreConfig = {
135
- baseURL: DEFAULT_BASE_URL,
136
- };
137
- static axios = axios.create({
138
- baseURL: DEFAULT_BASE_URL,
139
- });
140
-
141
- private static _sdk: AbyssReflexCoreSDK | null = null;
142
-
143
- public static get sdk(): AbyssReflexCoreSDK {
144
- if (!AbyssReflexCore._sdk) {
145
- AbyssReflexCore._sdk = {
146
- health: healthApi.health,
147
- function: {
148
- list: functionApi.listFunction,
149
- create: functionApi.createFunction,
150
- get: functionApi.getFunction,
151
- update: functionApi.updateFunction,
152
- delete: functionApi.deleteFunction,
153
- access: {
154
- list: functionAccessApi.listFunctionAccess,
155
- grant: functionAccessApi.grantFunctionAccess,
156
- revoke: functionAccessApi.revokeFunctionAccess,
157
- },
158
- test: {
159
- simulate: functionTestApi.simulateFunction,
160
- dryRun: functionTestApi.dryRunFunction,
161
- },
162
- version: {
163
- list: functionVersionApi.listFunctionVersion,
164
- get: functionVersionApi.getFunctionVersion,
165
- stepStats: functionVersionApi.getFunctionVersionStepStats,
166
- },
167
- run: {
168
- list: functionRunApi.listFunctionRun,
169
- get: functionRunApi.getFunctionRun,
170
- state: functionRunApi.getFunctionRunState,
171
- },
172
- settings: {
173
- get: functionSettingsApi.getFunctionSettings,
174
- setDefault: functionSettingsApi.setFunctionDefaultSettings,
175
- setEnvironment: functionSettingsApi.setFunctionEnvironmentSettings,
176
- removeEnvironment: functionSettingsApi.removeFunctionEnvironmentSettings,
177
- },
178
- },
179
- service: {
180
- list: serviceApi.listService,
181
- create: serviceApi.createService,
182
- get: serviceApi.getService,
183
- update: serviceApi.updateService,
184
- delete: serviceApi.deleteService,
185
- route: {
186
- list: serviceRouteApi.listServiceRoute,
187
- create: serviceRouteApi.createServiceRoute,
188
- update: serviceRouteApi.updateServiceRoute,
189
- delete: serviceRouteApi.deleteServiceRoute,
190
- rotate: serviceRouteApi.rotateServiceRoute,
191
- },
192
- version: {
193
- list: serviceVersionApi.listServiceVersion,
194
- create: serviceVersionApi.createServiceVersion,
195
- get: serviceVersionApi.getServiceVersion,
196
- draftStatus: serviceVersionApi.getServiceVersionDraftStatus,
197
- },
198
- deployment: {
199
- list: serviceDeploymentApi.listServiceDeployment,
200
- goLive: serviceDeploymentApi.goLiveService,
201
- rollback: serviceDeploymentApi.rollbackService,
202
- pause: serviceDeploymentApi.pauseService,
203
- resume: serviceDeploymentApi.resumeService,
204
- },
205
- configuration: {
206
- list: serviceConfigurationApi.listServiceConfiguration,
207
- },
208
- discord: {
209
- command: {
210
- list: serviceDiscordApi.listServiceDiscordCommand,
211
- create: serviceDiscordApi.createServiceDiscordCommand,
212
- update: serviceDiscordApi.updateServiceDiscordCommand,
213
- delete: serviceDiscordApi.deleteServiceDiscordCommand,
214
- },
215
- component: {
216
- list: serviceDiscordApi.listServiceDiscordComponent,
217
- create: serviceDiscordApi.createServiceDiscordComponent,
218
- update: serviceDiscordApi.updateServiceDiscordComponent,
219
- delete: serviceDiscordApi.deleteServiceDiscordComponent,
220
- },
221
- connection: {
222
- get: serviceDiscordApi.getServiceDiscordConnection,
223
- setTokenSecret: serviceDiscordApi.setServiceDiscordTokenSecret,
224
- setEnvironment: serviceDiscordApi.setServiceDiscordEnvironment,
225
- check: serviceDiscordApi.checkServiceDiscordConnection,
226
- },
227
- sync: serviceDiscordApi.retryServiceDiscordSync,
228
- },
229
- task: {
230
- list: serviceTaskApi.listServiceTask,
231
- create: serviceTaskApi.createServiceTask,
232
- update: serviceTaskApi.updateServiceTask,
233
- delete: serviceTaskApi.deleteServiceTask,
234
- testRun: serviceTaskApi.testRunServiceTask,
235
- delayedRun: {
236
- list: serviceTaskApi.listServiceDelayedRun,
237
- cancel: serviceTaskApi.cancelServiceDelayedRun,
238
- },
239
- sync: serviceTaskApi.retryServiceScheduleSync,
240
- },
241
- },
242
- };
243
- }
244
- return AbyssReflexCore._sdk;
245
- }
246
-
247
- public static setConfig(config: CoreConfig): void {
248
- AbyssReflexCore._sdk = null;
249
-
250
- AbyssReflexCore.config = { ...AbyssReflexCore.config, ...config };
251
-
252
- if (config.baseURL) {
253
- AbyssReflexCore.axios.defaults.baseURL = config.baseURL;
254
- }
255
-
256
- if (config.token) {
257
- AbyssReflexCore.axios.defaults.headers.common.Authorization = `Bearer ${config.token}`;
258
- }
259
- }
260
-
261
- public static getConfig(): CoreConfig {
262
- return AbyssReflexCore.config;
263
- }
264
- }
1
+ import axios from 'axios';
2
+ import * as healthApi from './api/health.api';
3
+ import * as functionApi from './api/function.api';
4
+ import * as functionAccessApi from './api/function-access.api';
5
+ import * as functionTestApi from './api/function-test.api';
6
+ import * as functionVersionApi from './api/function-version.api';
7
+ import * as functionRunApi from './api/function-run.api';
8
+ import * as functionSettingsApi from './api/function-settings.api';
9
+ import * as serviceApi from './api/service.api';
10
+ import * as serviceRouteApi from './api/service-route.api';
11
+ import * as serviceVersionApi from './api/service-version.api';
12
+ import * as serviceDeploymentApi from './api/service-deployment.api';
13
+ import * as serviceConfigurationApi from './api/service-configuration.api';
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';
18
+ import * as serviceTaskApi from './api/service-task.api';
19
+
20
+ export * from './api';
21
+ export * from './types';
22
+ export * from './discord';
23
+
24
+ const DEFAULT_BASE_URL = 'https://reflex-api.abyss-project.fr/';
25
+
26
+ type CoreConfig = {
27
+ baseURL?: string;
28
+ /** The session token of the member (`Authorization: Bearer`). Every route but `health` needs it. */
29
+ token?: string;
30
+ };
31
+
32
+ type AbyssReflexCoreSDK = {
33
+ /** `GET /health` — status of the database and Redis behind the API. */
34
+ health: typeof healthApi.health;
35
+ function: {
36
+ list: typeof functionApi.listFunction;
37
+ create: typeof functionApi.createFunction;
38
+ get: typeof functionApi.getFunction;
39
+ update: typeof functionApi.updateFunction;
40
+ delete: typeof functionApi.deleteFunction;
41
+ access: {
42
+ list: typeof functionAccessApi.listFunctionAccess;
43
+ grant: typeof functionAccessApi.grantFunctionAccess;
44
+ revoke: typeof functionAccessApi.revokeFunctionAccess;
45
+ };
46
+ test: {
47
+ simulate: typeof functionTestApi.simulateFunction;
48
+ dryRun: typeof functionTestApi.dryRunFunction;
49
+ };
50
+ version: {
51
+ list: typeof functionVersionApi.listFunctionVersion;
52
+ get: typeof functionVersionApi.getFunctionVersion;
53
+ stepStats: typeof functionVersionApi.getFunctionVersionStepStats;
54
+ };
55
+ run: {
56
+ list: typeof functionRunApi.listFunctionRun;
57
+ get: typeof functionRunApi.getFunctionRun;
58
+ state: typeof functionRunApi.getFunctionRunState;
59
+ };
60
+ /** The dashboard of the function: tiles, series, ranking. */
61
+ insights: {
62
+ get: typeof functionInsightsApi.getFunctionInsights;
63
+ };
64
+ settings: {
65
+ get: typeof functionSettingsApi.getFunctionSettings;
66
+ setDefault: typeof functionSettingsApi.setFunctionDefaultSettings;
67
+ setEnvironment: typeof functionSettingsApi.setFunctionEnvironmentSettings;
68
+ removeEnvironment: typeof functionSettingsApi.removeFunctionEnvironmentSettings;
69
+ };
70
+ };
71
+ /** Services: the unit versioned, put in service and paused as one (`/api/service/:applicationId/...`). */
72
+ service: {
73
+ list: typeof serviceApi.listService;
74
+ create: typeof serviceApi.createService;
75
+ get: typeof serviceApi.getService;
76
+ update: typeof serviceApi.updateService;
77
+ delete: typeof serviceApi.deleteService;
78
+ route: {
79
+ list: typeof serviceRouteApi.listServiceRoute;
80
+ create: typeof serviceRouteApi.createServiceRoute;
81
+ update: typeof serviceRouteApi.updateServiceRoute;
82
+ delete: typeof serviceRouteApi.deleteServiceRoute;
83
+ rotate: typeof serviceRouteApi.rotateServiceRoute;
84
+ };
85
+ version: {
86
+ list: typeof serviceVersionApi.listServiceVersion;
87
+ create: typeof serviceVersionApi.createServiceVersion;
88
+ get: typeof serviceVersionApi.getServiceVersion;
89
+ draftStatus: typeof serviceVersionApi.getServiceVersionDraftStatus;
90
+ };
91
+ deployment: {
92
+ list: typeof serviceDeploymentApi.listServiceDeployment;
93
+ goLive: typeof serviceDeploymentApi.goLiveService;
94
+ rollback: typeof serviceDeploymentApi.rollbackService;
95
+ pause: typeof serviceDeploymentApi.pauseService;
96
+ resume: typeof serviceDeploymentApi.resumeService;
97
+ };
98
+ configuration: {
99
+ list: typeof serviceConfigurationApi.listServiceConfiguration;
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
+ };
106
+ /** A Discord bot Service: its commands and components, its connection, the push to Discord. */
107
+ discord: {
108
+ command: {
109
+ list: typeof serviceDiscordApi.listServiceDiscordCommand;
110
+ create: typeof serviceDiscordApi.createServiceDiscordCommand;
111
+ update: typeof serviceDiscordApi.updateServiceDiscordCommand;
112
+ delete: typeof serviceDiscordApi.deleteServiceDiscordCommand;
113
+ };
114
+ component: {
115
+ list: typeof serviceDiscordApi.listServiceDiscordComponent;
116
+ create: typeof serviceDiscordApi.createServiceDiscordComponent;
117
+ update: typeof serviceDiscordApi.updateServiceDiscordComponent;
118
+ delete: typeof serviceDiscordApi.deleteServiceDiscordComponent;
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
+ };
131
+ connection: {
132
+ get: typeof serviceDiscordApi.getServiceDiscordConnection;
133
+ setTokenSecret: typeof serviceDiscordApi.setServiceDiscordTokenSecret;
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;
139
+ check: typeof serviceDiscordApi.checkServiceDiscordConnection;
140
+ };
141
+ /** Pushes the interactions address and the commands to Discord again. */
142
+ sync: typeof serviceDiscordApi.retryServiceDiscordSync;
143
+ };
144
+ /** The tasks of the Service (cron and delayed runs), their delayed runs, the synchronization with Flow. */
145
+ task: {
146
+ list: typeof serviceTaskApi.listServiceTask;
147
+ create: typeof serviceTaskApi.createServiceTask;
148
+ update: typeof serviceTaskApi.updateServiceTask;
149
+ delete: typeof serviceTaskApi.deleteServiceTask;
150
+ testRun: typeof serviceTaskApi.testRunServiceTask;
151
+ /** The history of a task in an environment: its runs of every status, those that ran nothing included. */
152
+ scheduledRun: {
153
+ list: typeof serviceTaskApi.listServiceTaskScheduledRun;
154
+ };
155
+ delayedRun: {
156
+ list: typeof serviceTaskApi.listServiceDelayedRun;
157
+ cancel: typeof serviceTaskApi.cancelServiceDelayedRun;
158
+ };
159
+ /** Synchronizes the cron tasks of the version in service with Flow again. */
160
+ sync: typeof serviceTaskApi.retryServiceScheduleSync;
161
+ };
162
+ };
163
+ };
164
+
165
+ export class AbyssReflexCore {
166
+ private static config: CoreConfig = {
167
+ baseURL: DEFAULT_BASE_URL,
168
+ };
169
+ static axios = axios.create({
170
+ baseURL: DEFAULT_BASE_URL,
171
+ });
172
+
173
+ private static _sdk: AbyssReflexCoreSDK | null = null;
174
+
175
+ public static get sdk(): AbyssReflexCoreSDK {
176
+ if (!AbyssReflexCore._sdk) {
177
+ AbyssReflexCore._sdk = {
178
+ health: healthApi.health,
179
+ function: {
180
+ list: functionApi.listFunction,
181
+ create: functionApi.createFunction,
182
+ get: functionApi.getFunction,
183
+ update: functionApi.updateFunction,
184
+ delete: functionApi.deleteFunction,
185
+ access: {
186
+ list: functionAccessApi.listFunctionAccess,
187
+ grant: functionAccessApi.grantFunctionAccess,
188
+ revoke: functionAccessApi.revokeFunctionAccess,
189
+ },
190
+ test: {
191
+ simulate: functionTestApi.simulateFunction,
192
+ dryRun: functionTestApi.dryRunFunction,
193
+ },
194
+ version: {
195
+ list: functionVersionApi.listFunctionVersion,
196
+ get: functionVersionApi.getFunctionVersion,
197
+ stepStats: functionVersionApi.getFunctionVersionStepStats,
198
+ },
199
+ run: {
200
+ list: functionRunApi.listFunctionRun,
201
+ get: functionRunApi.getFunctionRun,
202
+ state: functionRunApi.getFunctionRunState,
203
+ },
204
+ insights: {
205
+ get: functionInsightsApi.getFunctionInsights,
206
+ },
207
+ settings: {
208
+ get: functionSettingsApi.getFunctionSettings,
209
+ setDefault: functionSettingsApi.setFunctionDefaultSettings,
210
+ setEnvironment: functionSettingsApi.setFunctionEnvironmentSettings,
211
+ removeEnvironment: functionSettingsApi.removeFunctionEnvironmentSettings,
212
+ },
213
+ },
214
+ service: {
215
+ list: serviceApi.listService,
216
+ create: serviceApi.createService,
217
+ get: serviceApi.getService,
218
+ update: serviceApi.updateService,
219
+ delete: serviceApi.deleteService,
220
+ route: {
221
+ list: serviceRouteApi.listServiceRoute,
222
+ create: serviceRouteApi.createServiceRoute,
223
+ update: serviceRouteApi.updateServiceRoute,
224
+ delete: serviceRouteApi.deleteServiceRoute,
225
+ rotate: serviceRouteApi.rotateServiceRoute,
226
+ },
227
+ version: {
228
+ list: serviceVersionApi.listServiceVersion,
229
+ create: serviceVersionApi.createServiceVersion,
230
+ get: serviceVersionApi.getServiceVersion,
231
+ draftStatus: serviceVersionApi.getServiceVersionDraftStatus,
232
+ },
233
+ deployment: {
234
+ list: serviceDeploymentApi.listServiceDeployment,
235
+ goLive: serviceDeploymentApi.goLiveService,
236
+ rollback: serviceDeploymentApi.rollbackService,
237
+ pause: serviceDeploymentApi.pauseService,
238
+ resume: serviceDeploymentApi.resumeService,
239
+ },
240
+ configuration: {
241
+ list: serviceConfigurationApi.listServiceConfiguration,
242
+ },
243
+ insights: {
244
+ get: serviceInsightsApi.getServiceInsights,
245
+ events: serviceInsightsApi.getServiceEventInsights,
246
+ },
247
+ discord: {
248
+ command: {
249
+ list: serviceDiscordApi.listServiceDiscordCommand,
250
+ create: serviceDiscordApi.createServiceDiscordCommand,
251
+ update: serviceDiscordApi.updateServiceDiscordCommand,
252
+ delete: serviceDiscordApi.deleteServiceDiscordCommand,
253
+ },
254
+ component: {
255
+ list: serviceDiscordApi.listServiceDiscordComponent,
256
+ create: serviceDiscordApi.createServiceDiscordComponent,
257
+ update: serviceDiscordApi.updateServiceDiscordComponent,
258
+ delete: serviceDiscordApi.deleteServiceDiscordComponent,
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
+ },
269
+ connection: {
270
+ get: serviceDiscordApi.getServiceDiscordConnection,
271
+ setTokenSecret: serviceDiscordApi.setServiceDiscordTokenSecret,
272
+ setEnvironment: serviceDiscordApi.setServiceDiscordEnvironment,
273
+ setAllocation: serviceDiscordApi.setServiceDiscordAllocation,
274
+ setBotSettings: serviceDiscordApi.setServiceDiscordBotSettings,
275
+ check: serviceDiscordApi.checkServiceDiscordConnection,
276
+ },
277
+ sync: serviceDiscordApi.retryServiceDiscordSync,
278
+ },
279
+ task: {
280
+ list: serviceTaskApi.listServiceTask,
281
+ create: serviceTaskApi.createServiceTask,
282
+ update: serviceTaskApi.updateServiceTask,
283
+ delete: serviceTaskApi.deleteServiceTask,
284
+ testRun: serviceTaskApi.testRunServiceTask,
285
+ scheduledRun: {
286
+ list: serviceTaskApi.listServiceTaskScheduledRun,
287
+ },
288
+ delayedRun: {
289
+ list: serviceTaskApi.listServiceDelayedRun,
290
+ cancel: serviceTaskApi.cancelServiceDelayedRun,
291
+ },
292
+ sync: serviceTaskApi.retryServiceScheduleSync,
293
+ },
294
+ },
295
+ };
296
+ }
297
+ return AbyssReflexCore._sdk;
298
+ }
299
+
300
+ public static setConfig(config: CoreConfig): void {
301
+ AbyssReflexCore._sdk = null;
302
+
303
+ AbyssReflexCore.config = { ...AbyssReflexCore.config, ...config };
304
+
305
+ if (config.baseURL) {
306
+ AbyssReflexCore.axios.defaults.baseURL = config.baseURL;
307
+ }
308
+
309
+ if (config.token) {
310
+ AbyssReflexCore.axios.defaults.headers.common.Authorization = `Bearer ${config.token}`;
311
+ }
312
+ }
313
+
314
+ public static getConfig(): CoreConfig {
315
+ return AbyssReflexCore.config;
316
+ }
317
+ }
@@ -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
+ }