@abyss-project/reflex 6.1.0 → 6.3.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 (117) hide show
  1. package/.eslintrc.js +32 -32
  2. package/README.md +15 -15
  3. package/dist/api/function-run.api.d.ts +1 -2
  4. package/dist/api/function-run.api.js +1 -3
  5. package/dist/api/function-run.api.js.map +1 -1
  6. package/dist/api/function-settings.api.d.ts +1 -3
  7. package/dist/api/function-settings.api.js +1 -7
  8. package/dist/api/function-settings.api.js.map +1 -1
  9. package/dist/index.d.ts +0 -5
  10. package/dist/index.js +0 -5
  11. package/dist/index.js.map +1 -1
  12. package/dist/types/enum/discord-host-action.enum.d.ts +3 -1
  13. package/dist/types/enum/discord-host-action.enum.js +2 -0
  14. package/dist/types/enum/discord-host-action.enum.js.map +1 -1
  15. package/dist/types/enum/reflex-error-code.enum.d.ts +1 -2
  16. package/dist/types/enum/reflex-error-code.enum.js +0 -1
  17. package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
  18. package/dist/types/interface/api/requests/application-run-settings.request.d.ts +0 -1
  19. package/dist/types/interface/api/requests/function-run.request.d.ts +0 -8
  20. package/dist/types/interface/api/requests/function-settings.request.d.ts +0 -12
  21. package/dist/types/interface/api/requests/service-discord.request.d.ts +1 -0
  22. package/dist/types/interface/api/requests/service.request.d.ts +0 -1
  23. package/dist/types/interface/api/responses/function-run.response.d.ts +0 -4
  24. package/dist/types/interface/api/responses/function-settings.response.d.ts +1 -5
  25. package/dist/types/interface/models/index.d.ts +0 -2
  26. package/dist/types/interface/models/index.js +0 -2
  27. package/dist/types/interface/models/index.js.map +1 -1
  28. package/dist/types/interface/models/reflex-discord.model.d.ts +5 -0
  29. package/dist/types/interface/models/reflex-discord.model.js +2 -0
  30. package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
  31. package/dist/types/interface/models/reflex-price-list.model.d.ts +1 -0
  32. package/dist/types/interface/models/reflex-run-settings.model.d.ts +0 -4
  33. package/dist/types/interface/models/reflex-run.model.d.ts +0 -5
  34. package/dist/types/interface/models/reflex-service-deployment.model.d.ts +2 -2
  35. package/dist/types/interface/models/reflex-service.model.d.ts +0 -1
  36. package/jest.config.ts +11 -11
  37. package/package.json +1 -1
  38. package/src/api/alert-rule.api.test.ts +72 -72
  39. package/src/api/alert-rule.api.ts +57 -57
  40. package/src/api/application-insights.api.test.ts +42 -42
  41. package/src/api/application-insights.api.ts +38 -38
  42. package/src/api/application-run-settings.api.test.ts +0 -11
  43. package/src/api/application-run-settings.api.ts +30 -30
  44. package/src/api/function-access.api.ts +87 -87
  45. package/src/api/function-insights.api.test.ts +27 -27
  46. package/src/api/function-insights.api.ts +18 -18
  47. package/src/api/function-run.api.ts +0 -15
  48. package/src/api/function-settings.api.ts +0 -22
  49. package/src/api/function-template.api.test.ts +72 -72
  50. package/src/api/function-template.api.ts +52 -52
  51. package/src/api/function-test.api.ts +34 -34
  52. package/src/api/function-version.api.ts +66 -66
  53. package/src/api/function.api.test.ts +0 -55
  54. package/src/api/function.api.ts +62 -62
  55. package/src/api/health.api.ts +10 -10
  56. package/src/api/index.ts +26 -26
  57. package/src/api/route-stats.api.test.ts +45 -45
  58. package/src/api/route-stats.api.ts +36 -36
  59. package/src/api/service-completion-webhook.api.test.ts +97 -97
  60. package/src/api/service-completion-webhook.api.ts +39 -39
  61. package/src/api/service-configuration.api.ts +16 -16
  62. package/src/api/service-consumer.api.test.ts +104 -104
  63. package/src/api/service-consumer.api.ts +90 -90
  64. package/src/api/service-deployment.api.ts +79 -79
  65. package/src/api/service-discord-event.api.test.ts +106 -106
  66. package/src/api/service-discord-event.api.ts +78 -78
  67. package/src/api/service-discord.api.test.ts +178 -178
  68. package/src/api/service-discord.api.ts +222 -222
  69. package/src/api/service-insights.api.test.ts +36 -36
  70. package/src/api/service-insights.api.ts +42 -42
  71. package/src/api/service-limits.api.test.ts +100 -100
  72. package/src/api/service-limits.api.ts +37 -37
  73. package/src/api/service-openapi.api.test.ts +52 -52
  74. package/src/api/service-openapi.api.ts +21 -21
  75. package/src/api/service-route.api.ts +74 -74
  76. package/src/api/service-task.api.test.ts +140 -140
  77. package/src/api/service-task.api.ts +141 -141
  78. package/src/api/service-version.api.ts +54 -54
  79. package/src/api/service.api.test.ts +1 -6
  80. package/src/api/service.api.ts +55 -55
  81. package/src/discord/discord-event-filter-cases.ts +261 -261
  82. package/src/discord/discord-event-filters.test.ts +91 -91
  83. package/src/discord/discord-event-filters.ts +95 -95
  84. package/src/discord/discord-event-intents.test.ts +112 -112
  85. package/src/discord/discord-event-intents.ts +55 -55
  86. package/src/discord/index.ts +3 -3
  87. package/src/index.test.ts +104 -104
  88. package/src/index.ts +0 -12
  89. package/src/insights/index.ts +1 -1
  90. package/src/insights/percentiles.test.ts +75 -75
  91. package/src/insights/percentiles.ts +37 -37
  92. package/src/types/enum/discord-host-action.enum.ts +2 -0
  93. package/src/types/enum/reflex-error-code.enum.ts +0 -5
  94. package/src/types/interface/api/requests/application-run-settings.request.ts +0 -2
  95. package/src/types/interface/api/requests/function-run.request.ts +0 -10
  96. package/src/types/interface/api/requests/function-settings.request.ts +0 -16
  97. package/src/types/interface/api/requests/service-discord.request.ts +6 -0
  98. package/src/types/interface/api/requests/service.request.ts +0 -2
  99. package/src/types/interface/api/responses/function-run.response.ts +0 -5
  100. package/src/types/interface/api/responses/function-settings.response.ts +0 -7
  101. package/src/types/interface/models/index.ts +0 -2
  102. package/src/types/interface/models/reflex-discord.model.ts +12 -0
  103. package/src/types/interface/models/reflex-price-list.model.ts +2 -0
  104. package/src/types/interface/models/reflex-run-settings.model.ts +0 -11
  105. package/src/types/interface/models/reflex-run.model.ts +0 -10
  106. package/src/types/interface/models/reflex-service-deployment.model.ts +2 -4
  107. package/src/types/interface/models/reflex-service.model.ts +0 -2
  108. package/tsconfig.check.json +15 -15
  109. package/tsconfig.json +35 -35
  110. package/dist/types/interface/models/reflex-run-retention.model.d.ts +0 -13
  111. package/dist/types/interface/models/reflex-run-retention.model.js +0 -8
  112. package/dist/types/interface/models/reflex-run-retention.model.js.map +0 -1
  113. package/dist/types/interface/models/reflex-storage-surplus.model.d.ts +0 -11
  114. package/dist/types/interface/models/reflex-storage-surplus.model.js +0 -3
  115. package/dist/types/interface/models/reflex-storage-surplus.model.js.map +0 -1
  116. package/src/types/interface/models/reflex-run-retention.model.ts +0 -24
  117. package/src/types/interface/models/reflex-storage-surplus.model.ts +0 -23
@@ -1,222 +1,222 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- ICheckServiceDiscordConnectionParams,
4
- ICheckServiceDiscordConnectionResponse,
5
- ICreateServiceDiscordCommandBody,
6
- ICreateServiceDiscordCommandParams,
7
- ICreateServiceDiscordCommandResponse,
8
- ICreateServiceDiscordComponentBody,
9
- ICreateServiceDiscordComponentParams,
10
- ICreateServiceDiscordComponentResponse,
11
- IDeleteServiceDiscordCommandParams,
12
- IDeleteServiceDiscordCommandResponse,
13
- IDeleteServiceDiscordComponentParams,
14
- IDeleteServiceDiscordComponentResponse,
15
- IGetServiceDiscordConnectionParams,
16
- IGetServiceDiscordConnectionResponse,
17
- IListServiceDiscordCommandParams,
18
- IListServiceDiscordCommandResponse,
19
- IListServiceDiscordComponentParams,
20
- IListServiceDiscordComponentResponse,
21
- IRetryServiceDiscordSyncParams,
22
- IRetryServiceDiscordSyncResponse,
23
- ISetServiceDiscordAllocationBody,
24
- ISetServiceDiscordAllocationParams,
25
- ISetServiceDiscordAllocationResponse,
26
- ISetServiceDiscordEnvironmentBody,
27
- ISetServiceDiscordEnvironmentParams,
28
- ISetServiceDiscordEnvironmentResponse,
29
- ISetServiceDiscordTokenSecretBody,
30
- ISetServiceDiscordTokenSecretParams,
31
- ISetServiceDiscordTokenSecretResponse,
32
- IUpdateServiceDiscordCommandBody,
33
- IUpdateServiceDiscordCommandParams,
34
- IUpdateServiceDiscordCommandResponse,
35
- IUpdateServiceDiscordComponentBody,
36
- IUpdateServiceDiscordComponentParams,
37
- IUpdateServiceDiscordComponentResponse,
38
- } from '../types';
39
-
40
- const serviceUrl = (params: { applicationId: string; serviceId: string }): string =>
41
- `api/service/${params.applicationId}/${params.serviceId}`;
42
-
43
- const commandUrl = (params: { applicationId: string; serviceId: string }): string =>
44
- `${serviceUrl(params)}/discord/command`;
45
-
46
- const componentUrl = (params: { applicationId: string; serviceId: string }): string =>
47
- `${serviceUrl(params)}/discord/component`;
48
-
49
- const connectionUrl = (params: { applicationId: string; serviceId: string }): string =>
50
- `${serviceUrl(params)}/discord/connection`;
51
-
52
- /** `GET .../discord/command`: the commands of the draft of a Discord bot, by name. Needs REFLEX_READ. */
53
- export const listServiceDiscordCommand = async (
54
- params: IListServiceDiscordCommandParams,
55
- ): Promise<IListServiceDiscordCommandResponse> =>
56
- (await AbyssReflexCore.axios.get<IListServiceDiscordCommandResponse>(commandUrl(params))).data;
57
-
58
- /**
59
- * `POST .../discord/command`: a command of the draft, pushed to Discord once a version holding it is in
60
- * service. `409 DISCORD_COMMAND_CONFLICT` when the name is taken. Needs REFLEX_FUNCTION_UPDATE.
61
- */
62
- export const createServiceDiscordCommand = async (
63
- params: ICreateServiceDiscordCommandParams,
64
- body: ICreateServiceDiscordCommandBody,
65
- ): Promise<ICreateServiceDiscordCommandResponse> =>
66
- (await AbyssReflexCore.axios.post<ICreateServiceDiscordCommandResponse>(commandUrl(params), body))
67
- .data;
68
-
69
- /** `PATCH .../discord/command/:commandId`: changes the command in the draft. Needs REFLEX_FUNCTION_UPDATE. */
70
- export const updateServiceDiscordCommand = async (
71
- params: IUpdateServiceDiscordCommandParams,
72
- body: IUpdateServiceDiscordCommandBody,
73
- ): Promise<IUpdateServiceDiscordCommandResponse> =>
74
- (
75
- await AbyssReflexCore.axios.patch<IUpdateServiceDiscordCommandResponse>(
76
- `${commandUrl(params)}/${params.commandId}`,
77
- body,
78
- )
79
- ).data;
80
-
81
- /** `DELETE .../discord/command/:commandId`: takes the command out of the draft. Needs REFLEX_FUNCTION_UPDATE. */
82
- export const deleteServiceDiscordCommand = async (
83
- params: IDeleteServiceDiscordCommandParams,
84
- ): Promise<IDeleteServiceDiscordCommandResponse> =>
85
- (
86
- await AbyssReflexCore.axios.delete<IDeleteServiceDiscordCommandResponse>(
87
- `${commandUrl(params)}/${params.commandId}`,
88
- )
89
- ).data;
90
-
91
- /** `GET .../discord/component`: the components of the draft of a Discord bot, by prefix. Needs REFLEX_READ. */
92
- export const listServiceDiscordComponent = async (
93
- params: IListServiceDiscordComponentParams,
94
- ): Promise<IListServiceDiscordComponentResponse> =>
95
- (await AbyssReflexCore.axios.get<IListServiceDiscordComponentResponse>(componentUrl(params)))
96
- .data;
97
-
98
- /**
99
- * `POST .../discord/component`: a button, menu or form prefix of the draft. `409
100
- * DISCORD_COMPONENT_PREFIX_CONFLICT` when it equals, starts or is started by another prefix. Needs
101
- * REFLEX_FUNCTION_UPDATE.
102
- */
103
- export const createServiceDiscordComponent = async (
104
- params: ICreateServiceDiscordComponentParams,
105
- body: ICreateServiceDiscordComponentBody,
106
- ): Promise<ICreateServiceDiscordComponentResponse> =>
107
- (
108
- await AbyssReflexCore.axios.post<ICreateServiceDiscordComponentResponse>(
109
- componentUrl(params),
110
- body,
111
- )
112
- ).data;
113
-
114
- /** `PATCH .../discord/component/:componentId`: changes the component in the draft. Needs REFLEX_FUNCTION_UPDATE. */
115
- export const updateServiceDiscordComponent = async (
116
- params: IUpdateServiceDiscordComponentParams,
117
- body: IUpdateServiceDiscordComponentBody,
118
- ): Promise<IUpdateServiceDiscordComponentResponse> =>
119
- (
120
- await AbyssReflexCore.axios.patch<IUpdateServiceDiscordComponentResponse>(
121
- `${componentUrl(params)}/${params.componentId}`,
122
- body,
123
- )
124
- ).data;
125
-
126
- /** `DELETE .../discord/component/:componentId`: takes the component out of the draft. Needs REFLEX_FUNCTION_UPDATE. */
127
- export const deleteServiceDiscordComponent = async (
128
- params: IDeleteServiceDiscordComponentParams,
129
- ): Promise<IDeleteServiceDiscordComponentResponse> =>
130
- (
131
- await AbyssReflexCore.axios.delete<IDeleteServiceDiscordComponentResponse>(
132
- `${componentUrl(params)}/${params.componentId}`,
133
- )
134
- ).data;
135
-
136
- /**
137
- * `GET .../discord/connection`: the Vault entry of the token and, per environment of the application,
138
- * the bot as last checked, the state of its token, the test server, the interactions address and the
139
- * invitation link. Never the token. Needs REFLEX_READ.
140
- */
141
- export const getServiceDiscordConnection = async (
142
- params: IGetServiceDiscordConnectionParams,
143
- ): Promise<IGetServiceDiscordConnectionResponse> =>
144
- (await AbyssReflexCore.axios.get<IGetServiceDiscordConnectionResponse>(connectionUrl(params)))
145
- .data;
146
-
147
- /**
148
- * `PUT .../discord/connection`: chooses the Vault entry that holds the bot token. The environments in
149
- * service read it again at once. Needs REFLEX_BOT_MANAGE.
150
- */
151
- export const setServiceDiscordTokenSecret = async (
152
- params: ISetServiceDiscordTokenSecretParams,
153
- body: ISetServiceDiscordTokenSecretBody,
154
- ): Promise<ISetServiceDiscordTokenSecretResponse> =>
155
- (
156
- await AbyssReflexCore.axios.put<ISetServiceDiscordTokenSecretResponse>(
157
- connectionUrl(params),
158
- body,
159
- )
160
- ).data;
161
-
162
- /**
163
- * `PUT .../discord/connection/:environmentId`: the test server and the invitation permissions of one
164
- * environment. A new test server is pushed at once where the bot is in service. Needs
165
- * REFLEX_BOT_MANAGE.
166
- */
167
- export const setServiceDiscordEnvironment = async (
168
- params: ISetServiceDiscordEnvironmentParams,
169
- body: ISetServiceDiscordEnvironmentBody,
170
- ): Promise<ISetServiceDiscordEnvironmentResponse> =>
171
- (
172
- await AbyssReflexCore.axios.put<ISetServiceDiscordEnvironmentResponse>(
173
- `${connectionUrl(params)}/${params.environmentId}`,
174
- body,
175
- )
176
- ).data;
177
-
178
- /**
179
- * `PUT .../discord/connection/:environmentId/allocation`: the lots of 500 events per minute of the reserve
180
- * of the organization this bot holds in the environment (0 releases them); the Gateway takes the new rate at
181
- * once. `409` when the reserve of the organization cannot cover it. Needs REFLEX_BOT_MANAGE.
182
- */
183
- export const setServiceDiscordAllocation = async (
184
- params: ISetServiceDiscordAllocationParams,
185
- body: ISetServiceDiscordAllocationBody,
186
- ): Promise<ISetServiceDiscordAllocationResponse> =>
187
- (
188
- await AbyssReflexCore.axios.put<ISetServiceDiscordAllocationResponse>(
189
- `${connectionUrl(params)}/${params.environmentId}/allocation`,
190
- body,
191
- )
192
- ).data;
193
-
194
- /**
195
- * `POST .../discord/connection/:environmentId/check`: reads the token of the environment from the Vault
196
- * and asks Discord about it; answers the environment row, whatever the state of the token (`VALID`,
197
- * `REJECTED`, `MISSING`). Needs REFLEX_BOT_MANAGE.
198
- */
199
- export const checkServiceDiscordConnection = async (
200
- params: ICheckServiceDiscordConnectionParams,
201
- ): Promise<ICheckServiceDiscordConnectionResponse> =>
202
- (
203
- await AbyssReflexCore.axios.post<ICheckServiceDiscordConnectionResponse>(
204
- `${connectionUrl(params)}/${params.environmentId}/check`,
205
- {},
206
- )
207
- ).data;
208
-
209
- /**
210
- * `POST .../deployment/:environmentId/discord-sync`: pushes the interactions address and the commands to
211
- * Discord again for the version in service, without a new version. Needs REFLEX_PUBLISH, and
212
- * REFLEX_PUBLISH_PRODUCTION in a production environment.
213
- */
214
- export const retryServiceDiscordSync = async (
215
- params: IRetryServiceDiscordSyncParams,
216
- ): Promise<IRetryServiceDiscordSyncResponse> =>
217
- (
218
- await AbyssReflexCore.axios.post<IRetryServiceDiscordSyncResponse>(
219
- `${serviceUrl(params)}/deployment/${params.environmentId}/discord-sync`,
220
- {},
221
- )
222
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ ICheckServiceDiscordConnectionParams,
4
+ ICheckServiceDiscordConnectionResponse,
5
+ ICreateServiceDiscordCommandBody,
6
+ ICreateServiceDiscordCommandParams,
7
+ ICreateServiceDiscordCommandResponse,
8
+ ICreateServiceDiscordComponentBody,
9
+ ICreateServiceDiscordComponentParams,
10
+ ICreateServiceDiscordComponentResponse,
11
+ IDeleteServiceDiscordCommandParams,
12
+ IDeleteServiceDiscordCommandResponse,
13
+ IDeleteServiceDiscordComponentParams,
14
+ IDeleteServiceDiscordComponentResponse,
15
+ IGetServiceDiscordConnectionParams,
16
+ IGetServiceDiscordConnectionResponse,
17
+ IListServiceDiscordCommandParams,
18
+ IListServiceDiscordCommandResponse,
19
+ IListServiceDiscordComponentParams,
20
+ IListServiceDiscordComponentResponse,
21
+ IRetryServiceDiscordSyncParams,
22
+ IRetryServiceDiscordSyncResponse,
23
+ ISetServiceDiscordAllocationBody,
24
+ ISetServiceDiscordAllocationParams,
25
+ ISetServiceDiscordAllocationResponse,
26
+ ISetServiceDiscordEnvironmentBody,
27
+ ISetServiceDiscordEnvironmentParams,
28
+ ISetServiceDiscordEnvironmentResponse,
29
+ ISetServiceDiscordTokenSecretBody,
30
+ ISetServiceDiscordTokenSecretParams,
31
+ ISetServiceDiscordTokenSecretResponse,
32
+ IUpdateServiceDiscordCommandBody,
33
+ IUpdateServiceDiscordCommandParams,
34
+ IUpdateServiceDiscordCommandResponse,
35
+ IUpdateServiceDiscordComponentBody,
36
+ IUpdateServiceDiscordComponentParams,
37
+ IUpdateServiceDiscordComponentResponse,
38
+ } from '../types';
39
+
40
+ const serviceUrl = (params: { applicationId: string; serviceId: string }): string =>
41
+ `api/service/${params.applicationId}/${params.serviceId}`;
42
+
43
+ const commandUrl = (params: { applicationId: string; serviceId: string }): string =>
44
+ `${serviceUrl(params)}/discord/command`;
45
+
46
+ const componentUrl = (params: { applicationId: string; serviceId: string }): string =>
47
+ `${serviceUrl(params)}/discord/component`;
48
+
49
+ const connectionUrl = (params: { applicationId: string; serviceId: string }): string =>
50
+ `${serviceUrl(params)}/discord/connection`;
51
+
52
+ /** `GET .../discord/command`: the commands of the draft of a Discord bot, by name. Needs REFLEX_READ. */
53
+ export const listServiceDiscordCommand = async (
54
+ params: IListServiceDiscordCommandParams,
55
+ ): Promise<IListServiceDiscordCommandResponse> =>
56
+ (await AbyssReflexCore.axios.get<IListServiceDiscordCommandResponse>(commandUrl(params))).data;
57
+
58
+ /**
59
+ * `POST .../discord/command`: a command of the draft, pushed to Discord once a version holding it is in
60
+ * service. `409 DISCORD_COMMAND_CONFLICT` when the name is taken. Needs REFLEX_FUNCTION_UPDATE.
61
+ */
62
+ export const createServiceDiscordCommand = async (
63
+ params: ICreateServiceDiscordCommandParams,
64
+ body: ICreateServiceDiscordCommandBody,
65
+ ): Promise<ICreateServiceDiscordCommandResponse> =>
66
+ (await AbyssReflexCore.axios.post<ICreateServiceDiscordCommandResponse>(commandUrl(params), body))
67
+ .data;
68
+
69
+ /** `PATCH .../discord/command/:commandId`: changes the command in the draft. Needs REFLEX_FUNCTION_UPDATE. */
70
+ export const updateServiceDiscordCommand = async (
71
+ params: IUpdateServiceDiscordCommandParams,
72
+ body: IUpdateServiceDiscordCommandBody,
73
+ ): Promise<IUpdateServiceDiscordCommandResponse> =>
74
+ (
75
+ await AbyssReflexCore.axios.patch<IUpdateServiceDiscordCommandResponse>(
76
+ `${commandUrl(params)}/${params.commandId}`,
77
+ body,
78
+ )
79
+ ).data;
80
+
81
+ /** `DELETE .../discord/command/:commandId`: takes the command out of the draft. Needs REFLEX_FUNCTION_UPDATE. */
82
+ export const deleteServiceDiscordCommand = async (
83
+ params: IDeleteServiceDiscordCommandParams,
84
+ ): Promise<IDeleteServiceDiscordCommandResponse> =>
85
+ (
86
+ await AbyssReflexCore.axios.delete<IDeleteServiceDiscordCommandResponse>(
87
+ `${commandUrl(params)}/${params.commandId}`,
88
+ )
89
+ ).data;
90
+
91
+ /** `GET .../discord/component`: the components of the draft of a Discord bot, by prefix. Needs REFLEX_READ. */
92
+ export const listServiceDiscordComponent = async (
93
+ params: IListServiceDiscordComponentParams,
94
+ ): Promise<IListServiceDiscordComponentResponse> =>
95
+ (await AbyssReflexCore.axios.get<IListServiceDiscordComponentResponse>(componentUrl(params)))
96
+ .data;
97
+
98
+ /**
99
+ * `POST .../discord/component`: a button, menu or form prefix of the draft. `409
100
+ * DISCORD_COMPONENT_PREFIX_CONFLICT` when it equals, starts or is started by another prefix. Needs
101
+ * REFLEX_FUNCTION_UPDATE.
102
+ */
103
+ export const createServiceDiscordComponent = async (
104
+ params: ICreateServiceDiscordComponentParams,
105
+ body: ICreateServiceDiscordComponentBody,
106
+ ): Promise<ICreateServiceDiscordComponentResponse> =>
107
+ (
108
+ await AbyssReflexCore.axios.post<ICreateServiceDiscordComponentResponse>(
109
+ componentUrl(params),
110
+ body,
111
+ )
112
+ ).data;
113
+
114
+ /** `PATCH .../discord/component/:componentId`: changes the component in the draft. Needs REFLEX_FUNCTION_UPDATE. */
115
+ export const updateServiceDiscordComponent = async (
116
+ params: IUpdateServiceDiscordComponentParams,
117
+ body: IUpdateServiceDiscordComponentBody,
118
+ ): Promise<IUpdateServiceDiscordComponentResponse> =>
119
+ (
120
+ await AbyssReflexCore.axios.patch<IUpdateServiceDiscordComponentResponse>(
121
+ `${componentUrl(params)}/${params.componentId}`,
122
+ body,
123
+ )
124
+ ).data;
125
+
126
+ /** `DELETE .../discord/component/:componentId`: takes the component out of the draft. Needs REFLEX_FUNCTION_UPDATE. */
127
+ export const deleteServiceDiscordComponent = async (
128
+ params: IDeleteServiceDiscordComponentParams,
129
+ ): Promise<IDeleteServiceDiscordComponentResponse> =>
130
+ (
131
+ await AbyssReflexCore.axios.delete<IDeleteServiceDiscordComponentResponse>(
132
+ `${componentUrl(params)}/${params.componentId}`,
133
+ )
134
+ ).data;
135
+
136
+ /**
137
+ * `GET .../discord/connection`: the Vault entry of the token and, per environment of the application,
138
+ * the bot as last checked, the state of its token, the test server, the interactions address and the
139
+ * invitation link. Never the token. Needs REFLEX_READ.
140
+ */
141
+ export const getServiceDiscordConnection = async (
142
+ params: IGetServiceDiscordConnectionParams,
143
+ ): Promise<IGetServiceDiscordConnectionResponse> =>
144
+ (await AbyssReflexCore.axios.get<IGetServiceDiscordConnectionResponse>(connectionUrl(params)))
145
+ .data;
146
+
147
+ /**
148
+ * `PUT .../discord/connection`: chooses the Vault entry that holds the bot token. The environments in
149
+ * service read it again at once. Needs REFLEX_BOT_MANAGE.
150
+ */
151
+ export const setServiceDiscordTokenSecret = async (
152
+ params: ISetServiceDiscordTokenSecretParams,
153
+ body: ISetServiceDiscordTokenSecretBody,
154
+ ): Promise<ISetServiceDiscordTokenSecretResponse> =>
155
+ (
156
+ await AbyssReflexCore.axios.put<ISetServiceDiscordTokenSecretResponse>(
157
+ connectionUrl(params),
158
+ body,
159
+ )
160
+ ).data;
161
+
162
+ /**
163
+ * `PUT .../discord/connection/:environmentId`: the test server and the invitation permissions of one
164
+ * environment. A new test server is pushed at once where the bot is in service. Needs
165
+ * REFLEX_BOT_MANAGE.
166
+ */
167
+ export const setServiceDiscordEnvironment = async (
168
+ params: ISetServiceDiscordEnvironmentParams,
169
+ body: ISetServiceDiscordEnvironmentBody,
170
+ ): Promise<ISetServiceDiscordEnvironmentResponse> =>
171
+ (
172
+ await AbyssReflexCore.axios.put<ISetServiceDiscordEnvironmentResponse>(
173
+ `${connectionUrl(params)}/${params.environmentId}`,
174
+ body,
175
+ )
176
+ ).data;
177
+
178
+ /**
179
+ * `PUT .../discord/connection/:environmentId/allocation`: the lots of 500 events per minute of the reserve
180
+ * of the organization this bot holds in the environment (0 releases them); the Gateway takes the new rate at
181
+ * once. `409` when the reserve of the organization cannot cover it. Needs REFLEX_BOT_MANAGE.
182
+ */
183
+ export const setServiceDiscordAllocation = async (
184
+ params: ISetServiceDiscordAllocationParams,
185
+ body: ISetServiceDiscordAllocationBody,
186
+ ): Promise<ISetServiceDiscordAllocationResponse> =>
187
+ (
188
+ await AbyssReflexCore.axios.put<ISetServiceDiscordAllocationResponse>(
189
+ `${connectionUrl(params)}/${params.environmentId}/allocation`,
190
+ body,
191
+ )
192
+ ).data;
193
+
194
+ /**
195
+ * `POST .../discord/connection/:environmentId/check`: reads the token of the environment from the Vault
196
+ * and asks Discord about it; answers the environment row, whatever the state of the token (`VALID`,
197
+ * `REJECTED`, `MISSING`). Needs REFLEX_BOT_MANAGE.
198
+ */
199
+ export const checkServiceDiscordConnection = async (
200
+ params: ICheckServiceDiscordConnectionParams,
201
+ ): Promise<ICheckServiceDiscordConnectionResponse> =>
202
+ (
203
+ await AbyssReflexCore.axios.post<ICheckServiceDiscordConnectionResponse>(
204
+ `${connectionUrl(params)}/${params.environmentId}/check`,
205
+ {},
206
+ )
207
+ ).data;
208
+
209
+ /**
210
+ * `POST .../deployment/:environmentId/discord-sync`: pushes the interactions address and the commands to
211
+ * Discord again for the version in service, without a new version. Needs REFLEX_PUBLISH, and
212
+ * REFLEX_PUBLISH_PRODUCTION in a production environment.
213
+ */
214
+ export const retryServiceDiscordSync = async (
215
+ params: IRetryServiceDiscordSyncParams,
216
+ ): Promise<IRetryServiceDiscordSyncResponse> =>
217
+ (
218
+ await AbyssReflexCore.axios.post<IRetryServiceDiscordSyncResponse>(
219
+ `${serviceUrl(params)}/deployment/${params.environmentId}/discord-sync`,
220
+ {},
221
+ )
222
+ ).data;
@@ -1,36 +1,36 @@
1
- import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
- import { AbyssReflexCore, InsightsPeriod } from '..';
3
-
4
- const SERVICE = { applicationId: 'app-1', serviceId: 'svc-1' };
5
- const QUERY = { environmentId: 'e-1', period: InsightsPeriod.DAYS_7 };
6
-
7
- describe('AbyssReflexCore Service insights routes', () => {
8
- const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
9
- async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
10
- );
11
-
12
- beforeAll(() => {
13
- AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
14
- AbyssReflexCore.axios.defaults.adapter = adapter;
15
- });
16
-
17
- beforeEach(() => adapter.mockClear());
18
-
19
- it('insights.get calls GET .../insights with the environment and the period', async () => {
20
- await AbyssReflexCore.sdk.service.insights.get(SERVICE, QUERY);
21
-
22
- const config = adapter.mock.calls[0][0];
23
- expect(config.method).toBe('get');
24
- expect(config.url).toBe('api/service/app-1/svc-1/insights');
25
- expect(config.params).toEqual({ environmentId: 'e-1', period: '7d' });
26
- });
27
-
28
- it('insights.events calls GET .../insights/events with the environment and the period', async () => {
29
- await AbyssReflexCore.sdk.service.insights.events(SERVICE, QUERY);
30
-
31
- const config = adapter.mock.calls[0][0];
32
- expect(config.method).toBe('get');
33
- expect(config.url).toBe('api/service/app-1/svc-1/insights/events');
34
- expect(config.params).toEqual({ environmentId: 'e-1', period: '7d' });
35
- });
36
- });
1
+ import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
+ import { AbyssReflexCore, InsightsPeriod } from '..';
3
+
4
+ const SERVICE = { applicationId: 'app-1', serviceId: 'svc-1' };
5
+ const QUERY = { environmentId: 'e-1', period: InsightsPeriod.DAYS_7 };
6
+
7
+ describe('AbyssReflexCore Service insights routes', () => {
8
+ const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
9
+ async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
10
+ );
11
+
12
+ beforeAll(() => {
13
+ AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
14
+ AbyssReflexCore.axios.defaults.adapter = adapter;
15
+ });
16
+
17
+ beforeEach(() => adapter.mockClear());
18
+
19
+ it('insights.get calls GET .../insights with the environment and the period', async () => {
20
+ await AbyssReflexCore.sdk.service.insights.get(SERVICE, QUERY);
21
+
22
+ const config = adapter.mock.calls[0][0];
23
+ expect(config.method).toBe('get');
24
+ expect(config.url).toBe('api/service/app-1/svc-1/insights');
25
+ expect(config.params).toEqual({ environmentId: 'e-1', period: '7d' });
26
+ });
27
+
28
+ it('insights.events calls GET .../insights/events with the environment and the period', async () => {
29
+ await AbyssReflexCore.sdk.service.insights.events(SERVICE, QUERY);
30
+
31
+ const config = adapter.mock.calls[0][0];
32
+ expect(config.method).toBe('get');
33
+ expect(config.url).toBe('api/service/app-1/svc-1/insights/events');
34
+ expect(config.params).toEqual({ environmentId: 'e-1', period: '7d' });
35
+ });
36
+ });
@@ -1,42 +1,42 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IGetServiceEventInsightsParams,
4
- IGetServiceEventInsightsQuery,
5
- IGetServiceEventInsightsResponse,
6
- IGetServiceInsightsParams,
7
- IGetServiceInsightsQuery,
8
- IGetServiceInsightsResponse,
9
- } from '../types';
10
-
11
- const insightsUrl = (params: { applicationId: string; serviceId: string }): string =>
12
- `api/service/${params.applicationId}/${params.serviceId}/insights`;
13
-
14
- /**
15
- * `GET .../insights`: the dashboard of a Service in one environment over a period: tiles against the period
16
- * before, series, share by kind of trigger, ranking of the triggers. Needs REFLEX_LOG_READ.
17
- */
18
- export const getServiceInsights = async (
19
- params: IGetServiceInsightsParams,
20
- query: IGetServiceInsightsQuery,
21
- ): Promise<IGetServiceInsightsResponse> =>
22
- (
23
- await AbyssReflexCore.axios.get<IGetServiceInsightsResponse>(insightsUrl(params), {
24
- params: query,
25
- })
26
- ).data;
27
-
28
- /**
29
- * `GET .../insights/events`: the dashboard of the Discord events of a bot: received, retained, executed and
30
- * dropped by reason, the rate, the peak, the credits and the spend of the month against the cap. Needs
31
- * REFLEX_LOG_READ.
32
- */
33
- export const getServiceEventInsights = async (
34
- params: IGetServiceEventInsightsParams,
35
- query: IGetServiceEventInsightsQuery,
36
- ): Promise<IGetServiceEventInsightsResponse> =>
37
- (
38
- await AbyssReflexCore.axios.get<IGetServiceEventInsightsResponse>(
39
- `${insightsUrl(params)}/events`,
40
- { params: query },
41
- )
42
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IGetServiceEventInsightsParams,
4
+ IGetServiceEventInsightsQuery,
5
+ IGetServiceEventInsightsResponse,
6
+ IGetServiceInsightsParams,
7
+ IGetServiceInsightsQuery,
8
+ IGetServiceInsightsResponse,
9
+ } from '../types';
10
+
11
+ const insightsUrl = (params: { applicationId: string; serviceId: string }): string =>
12
+ `api/service/${params.applicationId}/${params.serviceId}/insights`;
13
+
14
+ /**
15
+ * `GET .../insights`: the dashboard of a Service in one environment over a period: tiles against the period
16
+ * before, series, share by kind of trigger, ranking of the triggers. Needs REFLEX_LOG_READ.
17
+ */
18
+ export const getServiceInsights = async (
19
+ params: IGetServiceInsightsParams,
20
+ query: IGetServiceInsightsQuery,
21
+ ): Promise<IGetServiceInsightsResponse> =>
22
+ (
23
+ await AbyssReflexCore.axios.get<IGetServiceInsightsResponse>(insightsUrl(params), {
24
+ params: query,
25
+ })
26
+ ).data;
27
+
28
+ /**
29
+ * `GET .../insights/events`: the dashboard of the Discord events of a bot: received, retained, executed and
30
+ * dropped by reason, the rate, the peak, the credits and the spend of the month against the cap. Needs
31
+ * REFLEX_LOG_READ.
32
+ */
33
+ export const getServiceEventInsights = async (
34
+ params: IGetServiceEventInsightsParams,
35
+ query: IGetServiceEventInsightsQuery,
36
+ ): Promise<IGetServiceEventInsightsResponse> =>
37
+ (
38
+ await AbyssReflexCore.axios.get<IGetServiceEventInsightsResponse>(
39
+ `${insightsUrl(params)}/events`,
40
+ { params: query },
41
+ )
42
+ ).data;