@abyss-project/reflex 6.6.0 → 6.9.1

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 (268) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/README.md +15 -15
  4. package/dist/api/function-run.api.d.ts +1 -2
  5. package/dist/api/function-run.api.js +1 -3
  6. package/dist/api/function-run.api.js.map +1 -1
  7. package/dist/api/index.d.ts +1 -0
  8. package/dist/api/index.js +1 -0
  9. package/dist/api/index.js.map +1 -1
  10. package/dist/api/reflex-admin.admin.api.d.ts +5 -0
  11. package/dist/api/reflex-admin.admin.api.js +18 -0
  12. package/dist/api/reflex-admin.admin.api.js.map +1 -0
  13. package/dist/discord/discord-event-filter-cases.js +11 -27
  14. package/dist/discord/discord-event-filter-cases.js.map +1 -1
  15. package/dist/discord/discord-event-filters.js +3 -7
  16. package/dist/discord/discord-event-filters.js.map +1 -1
  17. package/dist/discord/discord-event-intents.d.ts +2 -8
  18. package/dist/discord/discord-event-intents.js +2 -13
  19. package/dist/discord/discord-event-intents.js.map +1 -1
  20. package/dist/discord/index.d.ts +0 -1
  21. package/dist/discord/index.js +0 -1
  22. package/dist/discord/index.js.map +1 -1
  23. package/dist/index.d.ts +13 -1
  24. package/dist/index.js +13 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/types/enum/discord-event-type.enum.d.ts +1 -3
  27. package/dist/types/enum/discord-event-type.enum.js +0 -2
  28. package/dist/types/enum/discord-event-type.enum.js.map +1 -1
  29. package/dist/types/enum/index.d.ts +2 -2
  30. package/dist/types/enum/index.js +2 -2
  31. package/dist/types/enum/index.js.map +1 -1
  32. package/dist/types/enum/reflex-abuse-rule.enum.d.ts +5 -0
  33. package/dist/types/enum/reflex-abuse-rule.enum.js +10 -0
  34. package/dist/types/enum/reflex-abuse-rule.enum.js.map +1 -0
  35. package/dist/types/enum/reflex-admin-hold-kind.enum.d.ts +4 -0
  36. package/dist/types/enum/reflex-admin-hold-kind.enum.js +9 -0
  37. package/dist/types/enum/reflex-admin-hold-kind.enum.js.map +1 -0
  38. package/dist/types/enum/reflex-error-code.enum.d.ts +3 -11
  39. package/dist/types/enum/reflex-error-code.enum.js +2 -10
  40. package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
  41. package/dist/types/interface/api/requests/function-run.request.d.ts +0 -8
  42. package/dist/types/interface/api/requests/index.d.ts +1 -0
  43. package/dist/types/interface/api/requests/index.js +1 -0
  44. package/dist/types/interface/api/requests/index.js.map +1 -1
  45. package/dist/types/interface/api/requests/reflex-admin.admin.request.d.ts +21 -0
  46. package/dist/types/interface/api/requests/reflex-admin.admin.request.js +3 -0
  47. package/dist/types/interface/api/requests/reflex-admin.admin.request.js.map +1 -0
  48. package/dist/types/interface/api/requests/service-discord.request.d.ts +3 -7
  49. package/dist/types/interface/api/responses/function-run.response.d.ts +0 -8
  50. package/dist/types/interface/api/responses/index.d.ts +1 -0
  51. package/dist/types/interface/api/responses/index.js +1 -0
  52. package/dist/types/interface/api/responses/index.js.map +1 -1
  53. package/dist/types/interface/api/responses/reflex-admin.admin.response.d.ts +22 -0
  54. package/dist/types/interface/api/responses/reflex-admin.admin.response.js +3 -0
  55. package/dist/types/interface/api/responses/reflex-admin.admin.response.js.map +1 -0
  56. package/dist/types/interface/models/index.d.ts +1 -0
  57. package/dist/types/interface/models/index.js +1 -0
  58. package/dist/types/interface/models/index.js.map +1 -1
  59. package/dist/types/interface/models/reflex-admin-hold.model.d.ts +50 -0
  60. package/dist/types/interface/models/reflex-admin-hold.model.js +11 -0
  61. package/dist/types/interface/models/reflex-admin-hold.model.js.map +1 -0
  62. package/dist/types/interface/models/reflex-discord.model.d.ts +2 -18
  63. package/dist/types/interface/models/reflex-discord.model.js +0 -4
  64. package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
  65. package/dist/types/interface/models/reflex-run.model.d.ts +0 -4
  66. package/dist/types/interface/models/reflex-run.model.js +1 -4
  67. package/dist/types/interface/models/reflex-run.model.js.map +1 -1
  68. package/dist/types/interface/models/reflex-service-deployment.model.d.ts +2 -1
  69. package/dist/types/interface/models/reflex-service.model.d.ts +2 -0
  70. package/dist/types/interface/models/reflex-service.model.js.map +1 -1
  71. package/jest.config.ts +11 -11
  72. package/package.json +1 -1
  73. package/src/api/alert-rule.api.test.ts +72 -72
  74. package/src/api/alert-rule.api.ts +57 -57
  75. package/src/api/application-insights.api.test.ts +42 -42
  76. package/src/api/application-insights.api.ts +38 -38
  77. package/src/api/application-run-settings.api.ts +30 -30
  78. package/src/api/function-access.api.ts +87 -87
  79. package/src/api/function-insights.api.test.ts +27 -27
  80. package/src/api/function-insights.api.ts +18 -18
  81. package/src/api/function-run.api.ts +53 -72
  82. package/src/api/function-template.api.test.ts +72 -72
  83. package/src/api/function-template.api.ts +52 -52
  84. package/src/api/function-test.api.ts +34 -34
  85. package/src/api/function-version.api.ts +66 -66
  86. package/src/api/function.api.ts +62 -62
  87. package/src/api/health.api.ts +10 -10
  88. package/src/api/index.ts +1 -0
  89. package/src/api/reflex-admin.admin.api.test.ts +78 -0
  90. package/src/api/reflex-admin.admin.api.ts +53 -0
  91. package/src/api/route-stats.api.test.ts +45 -45
  92. package/src/api/route-stats.api.ts +36 -36
  93. package/src/api/service-completion-webhook.api.test.ts +97 -97
  94. package/src/api/service-completion-webhook.api.ts +39 -39
  95. package/src/api/service-configuration.api.ts +16 -16
  96. package/src/api/service-consumer.api.test.ts +104 -104
  97. package/src/api/service-consumer.api.ts +90 -90
  98. package/src/api/service-deployment.api.ts +79 -79
  99. package/src/api/service-discord-event.api.test.ts +106 -106
  100. package/src/api/service-discord-event.api.ts +78 -78
  101. package/src/api/service-discord.api.test.ts +178 -178
  102. package/src/api/service-discord.api.ts +222 -222
  103. package/src/api/service-insights.api.test.ts +36 -36
  104. package/src/api/service-insights.api.ts +42 -42
  105. package/src/api/service-limits.api.test.ts +100 -100
  106. package/src/api/service-limits.api.ts +37 -37
  107. package/src/api/service-openapi.api.test.ts +52 -52
  108. package/src/api/service-openapi.api.ts +21 -21
  109. package/src/api/service-route.api.ts +74 -74
  110. package/src/api/service-task.api.test.ts +140 -140
  111. package/src/api/service-task.api.ts +141 -141
  112. package/src/api/service-version.api.ts +54 -54
  113. package/src/api/service.api.ts +55 -55
  114. package/src/discord/discord-event-filter-cases.ts +261 -299
  115. package/src/discord/discord-event-filters.test.ts +91 -120
  116. package/src/discord/discord-event-filters.ts +95 -103
  117. package/src/discord/discord-event-intents.test.ts +112 -139
  118. package/src/discord/discord-event-intents.ts +55 -80
  119. package/src/discord/index.ts +3 -4
  120. package/src/index.test.ts +104 -104
  121. package/src/index.ts +26 -2
  122. package/src/insights/index.ts +1 -1
  123. package/src/insights/percentiles.test.ts +75 -75
  124. package/src/insights/percentiles.ts +37 -37
  125. package/src/types/enum/access-grant-status.enum.ts +12 -12
  126. package/src/types/enum/access-kind.enum.ts +7 -7
  127. package/src/types/enum/access-request-status.enum.ts +11 -11
  128. package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
  129. package/src/types/enum/completion-delivery-status.enum.ts +9 -9
  130. package/src/types/enum/configuration-read-as.enum.ts +5 -5
  131. package/src/types/enum/discord-activity-type.enum.ts +9 -9
  132. package/src/types/enum/discord-channel-type.enum.ts +11 -11
  133. package/src/types/enum/discord-component-kind.enum.ts +7 -7
  134. package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
  135. package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
  136. package/src/types/enum/discord-event-status.enum.ts +13 -13
  137. package/src/types/enum/discord-event-type.enum.ts +7 -11
  138. package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
  139. package/src/types/enum/discord-gateway-state.enum.ts +11 -11
  140. package/src/types/enum/discord-host-action.enum.ts +37 -37
  141. package/src/types/enum/discord-locale.enum.ts +35 -35
  142. package/src/types/enum/discord-option-type.enum.ts +12 -12
  143. package/src/types/enum/discord-presence-status.enum.ts +8 -8
  144. package/src/types/enum/discord-sync-status.enum.ts +6 -6
  145. package/src/types/enum/discord-token-state.enum.ts +11 -11
  146. package/src/types/enum/execution-mode.enum.ts +9 -9
  147. package/src/types/enum/execution-profile.enum.ts +20 -20
  148. package/src/types/enum/execution-settings-source.enum.ts +9 -9
  149. package/src/types/enum/health-status.enum.ts +4 -4
  150. package/src/types/enum/index.ts +53 -53
  151. package/src/types/enum/insights-period.enum.ts +8 -8
  152. package/src/types/enum/log-cap-mode.enum.ts +6 -6
  153. package/src/types/enum/log-drop-cause.enum.ts +8 -8
  154. package/src/types/enum/reflex-abuse-rule.enum.ts +9 -0
  155. package/src/types/enum/reflex-admin-hold-kind.enum.ts +7 -0
  156. package/src/types/enum/reflex-error-code.enum.ts +7 -23
  157. package/src/types/enum/route-method.enum.ts +9 -9
  158. package/src/types/enum/run-log-level.enum.ts +6 -6
  159. package/src/types/enum/run-mode.enum.ts +11 -11
  160. package/src/types/enum/run-status.enum.ts +16 -16
  161. package/src/types/enum/run-step-status.enum.ts +7 -7
  162. package/src/types/enum/schedule-sync-status.enum.ts +6 -6
  163. package/src/types/enum/scheduled-run-failure-code.enum.ts +14 -14
  164. package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
  165. package/src/types/enum/scheduled-run-status.enum.ts +17 -17
  166. package/src/types/enum/service-block-reason.enum.ts +13 -13
  167. package/src/types/enum/service-deployment-action.enum.ts +11 -11
  168. package/src/types/enum/service-deployment-status.enum.ts +5 -5
  169. package/src/types/enum/service-type.enum.ts +9 -9
  170. package/src/types/enum/service-version-change-kind.enum.ts +6 -6
  171. package/src/types/enum/trace-effect-type.enum.ts +12 -12
  172. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  173. package/src/types/enum/trigger-kind.enum.ts +8 -8
  174. package/src/types/enum/vault-value-source.enum.ts +12 -12
  175. package/src/types/enum/vault-visibility.enum.ts +5 -5
  176. package/src/types/index.ts +2 -2
  177. package/src/types/interface/api/index.ts +3 -3
  178. package/src/types/interface/api/requests/alert-rule.request.ts +53 -53
  179. package/src/types/interface/api/requests/application-insights.request.ts +18 -18
  180. package/src/types/interface/api/requests/function-access.request.ts +51 -51
  181. package/src/types/interface/api/requests/function-run.request.ts +0 -11
  182. package/src/types/interface/api/requests/function-template.request.ts +29 -29
  183. package/src/types/interface/api/requests/function-test.request.ts +44 -44
  184. package/src/types/interface/api/requests/function-version.request.ts +38 -38
  185. package/src/types/interface/api/requests/function.request.ts +36 -36
  186. package/src/types/interface/api/requests/index.ts +1 -0
  187. package/src/types/interface/api/requests/reflex-admin.admin.request.ts +26 -0
  188. package/src/types/interface/api/requests/route-stats.request.ts +22 -22
  189. package/src/types/interface/api/requests/service-completion-webhook.request.ts +11 -11
  190. package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
  191. package/src/types/interface/api/requests/service-consumer.request.ts +51 -51
  192. package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
  193. package/src/types/interface/api/requests/service-discord-event.request.ts +68 -68
  194. package/src/types/interface/api/requests/service-discord.request.ts +155 -168
  195. package/src/types/interface/api/requests/service-insights.request.ts +31 -31
  196. package/src/types/interface/api/requests/service-limits.request.ts +28 -28
  197. package/src/types/interface/api/requests/service-openapi.request.ts +10 -10
  198. package/src/types/interface/api/requests/service-route.request.ts +52 -52
  199. package/src/types/interface/api/requests/service-task.request.ts +80 -80
  200. package/src/types/interface/api/requests/service-version.request.ts +24 -24
  201. package/src/types/interface/api/response.ts +4 -4
  202. package/src/types/interface/api/responses/alert-rule.response.ts +24 -24
  203. package/src/types/interface/api/responses/application-insights.response.ts +11 -11
  204. package/src/types/interface/api/responses/application-run-settings.response.ts +8 -8
  205. package/src/types/interface/api/responses/function-access.response.ts +45 -45
  206. package/src/types/interface/api/responses/function-run.response.ts +0 -12
  207. package/src/types/interface/api/responses/function-template.response.ts +21 -21
  208. package/src/types/interface/api/responses/function-test.response.ts +19 -19
  209. package/src/types/interface/api/responses/function-version.response.ts +42 -42
  210. package/src/types/interface/api/responses/function.response.ts +25 -25
  211. package/src/types/interface/api/responses/index.ts +1 -0
  212. package/src/types/interface/api/responses/reflex-admin.admin.response.ts +32 -0
  213. package/src/types/interface/api/responses/route-stats.response.ts +15 -15
  214. package/src/types/interface/api/responses/service-completion-webhook.response.ts +13 -13
  215. package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
  216. package/src/types/interface/api/responses/service-consumer.response.ts +33 -33
  217. package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
  218. package/src/types/interface/api/responses/service-discord-event.response.ts +24 -24
  219. package/src/types/interface/api/responses/service-discord.response.ts +110 -110
  220. package/src/types/interface/api/responses/service-insights.response.ts +11 -11
  221. package/src/types/interface/api/responses/service-limits.response.ts +13 -13
  222. package/src/types/interface/api/responses/service-openapi.response.ts +7 -7
  223. package/src/types/interface/api/responses/service-route.response.ts +31 -31
  224. package/src/types/interface/api/responses/service-task.response.ts +57 -57
  225. package/src/types/interface/api/responses/service-version.response.ts +112 -112
  226. package/src/types/interface/api/responses/service.response.ts +31 -31
  227. package/src/types/interface/health.response.ts +7 -7
  228. package/src/types/interface/index.ts +3 -3
  229. package/src/types/interface/models/index.ts +1 -0
  230. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  231. package/src/types/interface/models/reflex-access-request.model.ts +15 -15
  232. package/src/types/interface/models/reflex-admin-hold.model.ts +64 -0
  233. package/src/types/interface/models/reflex-alert-rule.model.ts +56 -56
  234. package/src/types/interface/models/reflex-bot-limits.model.ts +53 -53
  235. package/src/types/interface/models/reflex-completion-webhook.model.ts +111 -111
  236. package/src/types/interface/models/reflex-consumer.model.ts +50 -50
  237. package/src/types/interface/models/reflex-definition.model.ts +31 -31
  238. package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -58
  239. package/src/types/interface/models/reflex-discord-event.model.ts +79 -79
  240. package/src/types/interface/models/reflex-discord.model.ts +208 -249
  241. package/src/types/interface/models/reflex-execution-settings.model.ts +57 -57
  242. package/src/types/interface/models/reflex-function-template.model.ts +18 -18
  243. package/src/types/interface/models/reflex-function-version.model.ts +19 -19
  244. package/src/types/interface/models/reflex-function.model.ts +30 -30
  245. package/src/types/interface/models/reflex-insights.model.ts +215 -215
  246. package/src/types/interface/models/reflex-price-list.model.ts +22 -22
  247. package/src/types/interface/models/reflex-route-contract.model.ts +46 -46
  248. package/src/types/interface/models/reflex-route.model.ts +23 -23
  249. package/src/types/interface/models/reflex-run.model.ts +0 -8
  250. package/src/types/interface/models/reflex-service-deployment.model.ts +51 -48
  251. package/src/types/interface/models/reflex-service.model.ts +50 -47
  252. package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
  253. package/src/types/interface/models/reflex-task.model.ts +97 -97
  254. package/tsconfig.check.json +15 -15
  255. package/tsconfig.json +35 -35
  256. package/dist/discord/discord-command-tree.d.ts +0 -5
  257. package/dist/discord/discord-command-tree.js +0 -38
  258. package/dist/discord/discord-command-tree.js.map +0 -1
  259. package/dist/types/enum/discord-command-node-type.enum.d.ts +0 -5
  260. package/dist/types/enum/discord-command-node-type.enum.js +0 -10
  261. package/dist/types/enum/discord-command-node-type.enum.js.map +0 -1
  262. package/dist/types/enum/discord-command-type.enum.d.ts +0 -5
  263. package/dist/types/enum/discord-command-type.enum.js +0 -10
  264. package/dist/types/enum/discord-command-type.enum.js.map +0 -1
  265. package/src/discord/discord-command-tree.test.ts +0 -47
  266. package/src/discord/discord-command-tree.ts +0 -60
  267. package/src/types/enum/discord-command-node-type.enum.ts +0 -10
  268. package/src/types/enum/discord-command-type.enum.ts +0 -9
@@ -1,66 +1,66 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IGetFunctionVersionParams,
4
- IGetFunctionVersionResponse,
5
- IGetFunctionVersionStepStatsParams,
6
- IGetFunctionVersionStepStatsQuery,
7
- IGetFunctionVersionStepStatsResponse,
8
- IListFunctionVersionParams,
9
- IListFunctionVersionQuery,
10
- IOpenFunctionVersionParams,
11
- IOpenFunctionVersionResponse,
12
- IListFunctionVersionResponse,
13
- } from '../types';
14
-
15
- const versionUrl = (params: { applicationId: string; functionId: string }): string =>
16
- `api/function/${params.applicationId}/${params.functionId}/version`;
17
-
18
- /**
19
- * `GET .../version`: the frozen versions, newest first, one page of those matching the filters. Needs REFLEX_READ. A version of the function's
20
- * Service publishes its draft when it changed (`service.version.create`).
21
- */
22
- export const listFunctionVersion = async (
23
- params: IListFunctionVersionParams,
24
- query: IListFunctionVersionQuery = {},
25
- ): Promise<IListFunctionVersionResponse> =>
26
- (
27
- await AbyssReflexCore.axios.get<IListFunctionVersionResponse>(versionUrl(params), {
28
- params: query,
29
- })
30
- ).data;
31
-
32
- /** `GET .../version/:versionId`. Needs REFLEX_READ. */
33
- export const getFunctionVersion = async (
34
- params: IGetFunctionVersionParams,
35
- ): Promise<IGetFunctionVersionResponse> =>
36
- (
37
- await AbyssReflexCore.axios.get<IGetFunctionVersionResponse>(
38
- `${versionUrl(params)}/${params.versionId}`,
39
- )
40
- ).data;
41
-
42
- /**
43
- * `GET .../version/:versionId/step-stats`: per step, over the retention window, the executions, the median
44
- * and p95 of duration, CPU, heap peak and cost, and the share of the cost; interrupted executions left
45
- * out. With `environmentId`, also the p99 heap peak per step of the version running there. Needs REFLEX_LOG_READ.
46
- */
47
- export const getFunctionVersionStepStats = async (
48
- params: IGetFunctionVersionStepStatsParams,
49
- query: IGetFunctionVersionStepStatsQuery = {},
50
- ): Promise<IGetFunctionVersionStepStatsResponse> =>
51
- (
52
- await AbyssReflexCore.axios.get<IGetFunctionVersionStepStatsResponse>(
53
- `${versionUrl(params)}/${params.versionId}/step-stats`,
54
- { params: query },
55
- )
56
- ).data;
57
-
58
- /** `POST .../version/:versionId/open`: replaces the draft with the definition of the version and records it as the base of the draft. Needs REFLEX_FUNCTION_UPDATE. */
59
- export const openFunctionVersion = async (
60
- params: IOpenFunctionVersionParams,
61
- ): Promise<IOpenFunctionVersionResponse> =>
62
- (
63
- await AbyssReflexCore.axios.post<IOpenFunctionVersionResponse>(
64
- `${versionUrl(params)}/${params.versionId}/open`,
65
- )
66
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IGetFunctionVersionParams,
4
+ IGetFunctionVersionResponse,
5
+ IGetFunctionVersionStepStatsParams,
6
+ IGetFunctionVersionStepStatsQuery,
7
+ IGetFunctionVersionStepStatsResponse,
8
+ IListFunctionVersionParams,
9
+ IListFunctionVersionQuery,
10
+ IOpenFunctionVersionParams,
11
+ IOpenFunctionVersionResponse,
12
+ IListFunctionVersionResponse,
13
+ } from '../types';
14
+
15
+ const versionUrl = (params: { applicationId: string; functionId: string }): string =>
16
+ `api/function/${params.applicationId}/${params.functionId}/version`;
17
+
18
+ /**
19
+ * `GET .../version`: the frozen versions, newest first, one page of those matching the filters. Needs REFLEX_READ. A version of the function's
20
+ * Service publishes its draft when it changed (`service.version.create`).
21
+ */
22
+ export const listFunctionVersion = async (
23
+ params: IListFunctionVersionParams,
24
+ query: IListFunctionVersionQuery = {},
25
+ ): Promise<IListFunctionVersionResponse> =>
26
+ (
27
+ await AbyssReflexCore.axios.get<IListFunctionVersionResponse>(versionUrl(params), {
28
+ params: query,
29
+ })
30
+ ).data;
31
+
32
+ /** `GET .../version/:versionId`. Needs REFLEX_READ. */
33
+ export const getFunctionVersion = async (
34
+ params: IGetFunctionVersionParams,
35
+ ): Promise<IGetFunctionVersionResponse> =>
36
+ (
37
+ await AbyssReflexCore.axios.get<IGetFunctionVersionResponse>(
38
+ `${versionUrl(params)}/${params.versionId}`,
39
+ )
40
+ ).data;
41
+
42
+ /**
43
+ * `GET .../version/:versionId/step-stats`: per step, over the retention window, the executions, the median
44
+ * and p95 of duration, CPU, heap peak and cost, and the share of the cost; interrupted executions left
45
+ * out. With `environmentId`, also the p99 heap peak per step of the version running there. Needs REFLEX_LOG_READ.
46
+ */
47
+ export const getFunctionVersionStepStats = async (
48
+ params: IGetFunctionVersionStepStatsParams,
49
+ query: IGetFunctionVersionStepStatsQuery = {},
50
+ ): Promise<IGetFunctionVersionStepStatsResponse> =>
51
+ (
52
+ await AbyssReflexCore.axios.get<IGetFunctionVersionStepStatsResponse>(
53
+ `${versionUrl(params)}/${params.versionId}/step-stats`,
54
+ { params: query },
55
+ )
56
+ ).data;
57
+
58
+ /** `POST .../version/:versionId/open`: replaces the draft with the definition of the version and records it as the base of the draft. Needs REFLEX_FUNCTION_UPDATE. */
59
+ export const openFunctionVersion = async (
60
+ params: IOpenFunctionVersionParams,
61
+ ): Promise<IOpenFunctionVersionResponse> =>
62
+ (
63
+ await AbyssReflexCore.axios.post<IOpenFunctionVersionResponse>(
64
+ `${versionUrl(params)}/${params.versionId}/open`,
65
+ )
66
+ ).data;
@@ -1,62 +1,62 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- ICreateFunctionBody,
4
- ICreateFunctionParams,
5
- ICreateFunctionResponse,
6
- IDeleteFunctionParams,
7
- IDeleteFunctionResponse,
8
- IGetFunctionParams,
9
- IGetFunctionResponse,
10
- IListFunctionParams,
11
- IListFunctionResponse,
12
- IUpdateFunctionBody,
13
- IUpdateFunctionParams,
14
- IUpdateFunctionResponse,
15
- } from '../types';
16
-
17
- /** `GET /api/function/:applicationId`: needs REFLEX_READ. */
18
- export const listFunction = async (params: IListFunctionParams): Promise<IListFunctionResponse> =>
19
- (await AbyssReflexCore.axios.get<IListFunctionResponse>(`api/function/${params.applicationId}`))
20
- .data;
21
-
22
- /** `POST /api/function/:applicationId`: needs REFLEX_FUNCTION_CREATE. A definition that breaks the format is a `400` naming the path of each fault. */
23
- export const createFunction = async (
24
- params: ICreateFunctionParams,
25
- body: ICreateFunctionBody,
26
- ): Promise<ICreateFunctionResponse> =>
27
- (
28
- await AbyssReflexCore.axios.post<ICreateFunctionResponse>(
29
- `api/function/${params.applicationId}`,
30
- body,
31
- )
32
- ).data;
33
-
34
- /** `GET /api/function/:applicationId/:functionId`: needs REFLEX_READ. */
35
- export const getFunction = async (params: IGetFunctionParams): Promise<IGetFunctionResponse> =>
36
- (
37
- await AbyssReflexCore.axios.get<IGetFunctionResponse>(
38
- `api/function/${params.applicationId}/${params.functionId}`,
39
- )
40
- ).data;
41
-
42
- /** `PUT /api/function/:applicationId/:functionId`: needs REFLEX_FUNCTION_UPDATE. */
43
- export const updateFunction = async (
44
- params: IUpdateFunctionParams,
45
- body: IUpdateFunctionBody,
46
- ): Promise<IUpdateFunctionResponse> =>
47
- (
48
- await AbyssReflexCore.axios.put<IUpdateFunctionResponse>(
49
- `api/function/${params.applicationId}/${params.functionId}`,
50
- body,
51
- )
52
- ).data;
53
-
54
- /** `DELETE /api/function/:applicationId/:functionId`: needs REFLEX_FUNCTION_DELETE. Takes the function off every environment. */
55
- export const deleteFunction = async (
56
- params: IDeleteFunctionParams,
57
- ): Promise<IDeleteFunctionResponse> =>
58
- (
59
- await AbyssReflexCore.axios.delete<IDeleteFunctionResponse>(
60
- `api/function/${params.applicationId}/${params.functionId}`,
61
- )
62
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ ICreateFunctionBody,
4
+ ICreateFunctionParams,
5
+ ICreateFunctionResponse,
6
+ IDeleteFunctionParams,
7
+ IDeleteFunctionResponse,
8
+ IGetFunctionParams,
9
+ IGetFunctionResponse,
10
+ IListFunctionParams,
11
+ IListFunctionResponse,
12
+ IUpdateFunctionBody,
13
+ IUpdateFunctionParams,
14
+ IUpdateFunctionResponse,
15
+ } from '../types';
16
+
17
+ /** `GET /api/function/:applicationId`: needs REFLEX_READ. */
18
+ export const listFunction = async (params: IListFunctionParams): Promise<IListFunctionResponse> =>
19
+ (await AbyssReflexCore.axios.get<IListFunctionResponse>(`api/function/${params.applicationId}`))
20
+ .data;
21
+
22
+ /** `POST /api/function/:applicationId`: needs REFLEX_FUNCTION_CREATE. A definition that breaks the format is a `400` naming the path of each fault. */
23
+ export const createFunction = async (
24
+ params: ICreateFunctionParams,
25
+ body: ICreateFunctionBody,
26
+ ): Promise<ICreateFunctionResponse> =>
27
+ (
28
+ await AbyssReflexCore.axios.post<ICreateFunctionResponse>(
29
+ `api/function/${params.applicationId}`,
30
+ body,
31
+ )
32
+ ).data;
33
+
34
+ /** `GET /api/function/:applicationId/:functionId`: needs REFLEX_READ. */
35
+ export const getFunction = async (params: IGetFunctionParams): Promise<IGetFunctionResponse> =>
36
+ (
37
+ await AbyssReflexCore.axios.get<IGetFunctionResponse>(
38
+ `api/function/${params.applicationId}/${params.functionId}`,
39
+ )
40
+ ).data;
41
+
42
+ /** `PUT /api/function/:applicationId/:functionId`: needs REFLEX_FUNCTION_UPDATE. */
43
+ export const updateFunction = async (
44
+ params: IUpdateFunctionParams,
45
+ body: IUpdateFunctionBody,
46
+ ): Promise<IUpdateFunctionResponse> =>
47
+ (
48
+ await AbyssReflexCore.axios.put<IUpdateFunctionResponse>(
49
+ `api/function/${params.applicationId}/${params.functionId}`,
50
+ body,
51
+ )
52
+ ).data;
53
+
54
+ /** `DELETE /api/function/:applicationId/:functionId`: needs REFLEX_FUNCTION_DELETE. Takes the function off every environment. */
55
+ export const deleteFunction = async (
56
+ params: IDeleteFunctionParams,
57
+ ): Promise<IDeleteFunctionResponse> =>
58
+ (
59
+ await AbyssReflexCore.axios.delete<IDeleteFunctionResponse>(
60
+ `api/function/${params.applicationId}/${params.functionId}`,
61
+ )
62
+ ).data;
@@ -1,10 +1,10 @@
1
- import { AbyssReflexCore } from '..';
2
- import type { IHealthResponse } from '../types';
3
-
4
- /**
5
- * `GET /health` — status of the database and Redis behind the API. Resolves on `200`; a `503`
6
- * (a component down) rejects as an axios error whose `response.data` is the same
7
- * {@link IHealthResponse}, naming the component that failed.
8
- */
9
- export const health = async (): Promise<IHealthResponse> =>
10
- (await AbyssReflexCore.axios.get<IHealthResponse>('health')).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type { IHealthResponse } from '../types';
3
+
4
+ /**
5
+ * `GET /health` — status of the database and Redis behind the API. Resolves on `200`; a `503`
6
+ * (a component down) rejects as an axios error whose `response.data` is the same
7
+ * {@link IHealthResponse}, naming the component that failed.
8
+ */
9
+ export const health = async (): Promise<IHealthResponse> =>
10
+ (await AbyssReflexCore.axios.get<IHealthResponse>('health')).data;
package/src/api/index.ts CHANGED
@@ -25,3 +25,4 @@ export * from './service-openapi.api';
25
25
  export * from './service-limits.api';
26
26
  export * from './service-completion-webhook.api';
27
27
  export * from './storage-surplus.admin.api';
28
+ export * from './reflex-admin.admin.api';
@@ -0,0 +1,78 @@
1
+ import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
+ import {
3
+ ADMIN_TOKEN_HEADER,
4
+ AbyssReflexCore,
5
+ IReflexAdminServiceContext,
6
+ ReflexAdminHoldKind,
7
+ } from '..';
8
+
9
+ const BASE = 'api/reflex/admin/service/svc-1/environment/env-1';
10
+ const PARAMS = { serviceId: 'svc-1', environmentId: 'env-1' };
11
+
12
+ describe('AbyssReflexCore admin hold and usage routes (back-office of abyss-main)', () => {
13
+ const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
14
+ async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
15
+ );
16
+
17
+ beforeAll(() => {
18
+ AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', adminToken: 'mesh-admin-token' });
19
+ AbyssReflexCore.axios.defaults.adapter = adapter;
20
+ });
21
+
22
+ beforeEach(() => adapter.mockClear());
23
+
24
+ const sent = () => adapter.mock.calls[0][0];
25
+
26
+ it('set posts the kind to .../hold with the admin token', async () => {
27
+ await AbyssReflexCore.sdk.serviceHold.admin.set(PARAMS, { kind: ReflexAdminHoldKind.SUSPEND });
28
+
29
+ expect(sent().method).toBe('post');
30
+ expect(sent().url).toBe(`${BASE}/hold`);
31
+ expect(JSON.parse(sent().data)).toEqual({ kind: 'SUSPEND' });
32
+ expect(sent().headers.get(ADMIN_TOKEN_HEADER)).toBe('mesh-admin-token');
33
+ });
34
+
35
+ it('lift deletes .../hold', async () => {
36
+ await AbyssReflexCore.sdk.serviceHold.admin.lift(PARAMS);
37
+
38
+ expect(sent().method).toBe('delete');
39
+ expect(sent().url).toBe(`${BASE}/hold`);
40
+ });
41
+
42
+ it('withdraw posts to .../withdraw', async () => {
43
+ await AbyssReflexCore.sdk.serviceHold.admin.withdraw(PARAMS);
44
+
45
+ expect(sent().method).toBe('post');
46
+ expect(sent().url).toBe(`${BASE}/withdraw`);
47
+ });
48
+
49
+ it('answers the context of the Service next to what the gesture did', async () => {
50
+ const context: IReflexAdminServiceContext = {
51
+ id: 'svc-1',
52
+ name: 'Orders',
53
+ applicationId: 'app-1',
54
+ projectId: 'project-1',
55
+ };
56
+ adapter.mockImplementationOnce(async (config) => ({
57
+ data: { data: { withdrawn: true, service: context } },
58
+ status: 200,
59
+ statusText: '',
60
+ headers: {},
61
+ config,
62
+ }));
63
+
64
+ const response = await AbyssReflexCore.sdk.serviceHold.admin.withdraw(PARAMS);
65
+
66
+ expect(response.data.service).toEqual(context);
67
+ expect(response.data.withdrawn).toBe(true);
68
+ });
69
+
70
+ it('usage list gets /usage with window, sort and page as query', async () => {
71
+ await AbyssReflexCore.sdk.usage.admin.list({ window: '7d', sort: 'netOut', page: 2 });
72
+
73
+ expect(sent().method).toBe('get');
74
+ expect(sent().url).toBe('api/reflex/admin/usage');
75
+ expect(sent().params).toEqual({ window: '7d', sort: 'netOut', page: 2 });
76
+ expect(sent().headers.get(ADMIN_TOKEN_HEADER)).toBe('mesh-admin-token');
77
+ });
78
+ });
@@ -0,0 +1,53 @@
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IListUsageAdminQuery,
4
+ IListUsageAdminResponse,
5
+ ILiftServiceHoldAdminParams,
6
+ ILiftServiceHoldAdminResponse,
7
+ ISetServiceHoldAdminBody,
8
+ ISetServiceHoldAdminParams,
9
+ ISetServiceHoldAdminResponse,
10
+ IWithdrawServiceHoldAdminParams,
11
+ IWithdrawServiceHoldAdminResponse,
12
+ } from '../types';
13
+
14
+ const holdUrl = (params: { serviceId: string; environmentId: string }): string =>
15
+ `api/reflex/admin/service/${params.serviceId}/environment/${params.environmentId}`;
16
+
17
+ /**
18
+ * `POST /api/reflex/admin/service/:serviceId/environment/:environmentId/hold`: Abyss pauses or suspends the Service in
19
+ * the environment. For abyss-main only: behind the admin token (`setConfig({ adminToken })`).
20
+ */
21
+ export const setServiceHoldAdmin = async (
22
+ params: ISetServiceHoldAdminParams,
23
+ body: ISetServiceHoldAdminBody,
24
+ ): Promise<ISetServiceHoldAdminResponse> =>
25
+ (await AbyssReflexCore.axios.post<ISetServiceHoldAdminResponse>(`${holdUrl(params)}/hold`, body))
26
+ .data;
27
+
28
+ /** `DELETE .../hold`: lifts the hold; the Service runs again if the hold was what paused it. Admin token. */
29
+ export const liftServiceHoldAdmin = async (
30
+ params: ILiftServiceHoldAdminParams,
31
+ ): Promise<ILiftServiceHoldAdminResponse> =>
32
+ (await AbyssReflexCore.axios.delete<ILiftServiceHoldAdminResponse>(`${holdUrl(params)}/hold`))
33
+ .data;
34
+
35
+ /** `POST .../withdraw`: withdraws the Service from the environment (deployments, settings, runs) and drops the hold. Admin token. */
36
+ export const withdrawServiceHoldAdmin = async (
37
+ params: IWithdrawServiceHoldAdminParams,
38
+ ): Promise<IWithdrawServiceHoldAdminResponse> =>
39
+ (
40
+ await AbyssReflexCore.axios.post<IWithdrawServiceHoldAdminResponse>(
41
+ `${holdUrl(params)}/withdraw`,
42
+ )
43
+ ).data;
44
+
45
+ /** `GET /api/reflex/admin/usage`: the usage of each Service per environment over the window, 50 rows a page. Admin token. */
46
+ export const listUsageAdmin = async (
47
+ query: IListUsageAdminQuery,
48
+ ): Promise<IListUsageAdminResponse> =>
49
+ (
50
+ await AbyssReflexCore.axios.get<IListUsageAdminResponse>('api/reflex/admin/usage', {
51
+ params: query,
52
+ })
53
+ ).data;
@@ -1,45 +1,45 @@
1
- import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
- import { AbyssReflexCore, InsightsPeriod } from '..';
3
-
4
- const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(async (config) => ({
5
- data: { data: {} },
6
- status: 200,
7
- statusText: '',
8
- headers: {},
9
- 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
- const QUERY = { environmentId: 'e-1', period: InsightsPeriod.HOURS_24 };
20
-
21
- describe('AbyssReflexCore route statistics routes', () => {
22
- it('routeStats.list calls GET .../route-stats with the environment and the period', async () => {
23
- await AbyssReflexCore.sdk.service.routeStats.list(
24
- { applicationId: 'app-1', serviceId: 'svc-1' },
25
- QUERY,
26
- );
27
-
28
- const config = adapter.mock.calls[0][0];
29
- expect(config.method).toBe('get');
30
- expect(config.url).toBe('api/service/app-1/svc-1/route-stats');
31
- expect(config.params).toEqual({ environmentId: 'e-1', period: '24h' });
32
- });
33
-
34
- it('routeStats.insights calls GET .../route/:routeId/insights', async () => {
35
- await AbyssReflexCore.sdk.service.routeStats.insights(
36
- { applicationId: 'app-1', serviceId: 'svc-1', routeId: 'r-1' },
37
- QUERY,
38
- );
39
-
40
- const config = adapter.mock.calls[0][0];
41
- expect(config.method).toBe('get');
42
- expect(config.url).toBe('api/service/app-1/svc-1/route/r-1/insights');
43
- expect(config.params).toEqual({ environmentId: 'e-1', period: '24h' });
44
- });
45
- });
1
+ import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
+ import { AbyssReflexCore, InsightsPeriod } from '..';
3
+
4
+ const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(async (config) => ({
5
+ data: { data: {} },
6
+ status: 200,
7
+ statusText: '',
8
+ headers: {},
9
+ 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
+ const QUERY = { environmentId: 'e-1', period: InsightsPeriod.HOURS_24 };
20
+
21
+ describe('AbyssReflexCore route statistics routes', () => {
22
+ it('routeStats.list calls GET .../route-stats with the environment and the period', async () => {
23
+ await AbyssReflexCore.sdk.service.routeStats.list(
24
+ { applicationId: 'app-1', serviceId: 'svc-1' },
25
+ QUERY,
26
+ );
27
+
28
+ const config = adapter.mock.calls[0][0];
29
+ expect(config.method).toBe('get');
30
+ expect(config.url).toBe('api/service/app-1/svc-1/route-stats');
31
+ expect(config.params).toEqual({ environmentId: 'e-1', period: '24h' });
32
+ });
33
+
34
+ it('routeStats.insights calls GET .../route/:routeId/insights', async () => {
35
+ await AbyssReflexCore.sdk.service.routeStats.insights(
36
+ { applicationId: 'app-1', serviceId: 'svc-1', routeId: 'r-1' },
37
+ QUERY,
38
+ );
39
+
40
+ const config = adapter.mock.calls[0][0];
41
+ expect(config.method).toBe('get');
42
+ expect(config.url).toBe('api/service/app-1/svc-1/route/r-1/insights');
43
+ expect(config.params).toEqual({ environmentId: 'e-1', period: '24h' });
44
+ });
45
+ });
@@ -1,36 +1,36 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IGetRouteInsightsParams,
4
- IGetRouteInsightsQuery,
5
- IGetRouteInsightsResponse,
6
- IGetServiceRouteStatsParams,
7
- IGetServiceRouteStatsQuery,
8
- IGetServiceRouteStatsResponse,
9
- } from '../types';
10
-
11
- /**
12
- * `GET .../route-stats`: every route of a Service over a period: runs, failures, p50, p95, p99, HTTP classes and
13
- * a short series. Needs REFLEX_READ.
14
- */
15
- export const getServiceRouteStats = async (
16
- params: IGetServiceRouteStatsParams,
17
- query: IGetServiceRouteStatsQuery,
18
- ): Promise<IGetServiceRouteStatsResponse> =>
19
- (
20
- await AbyssReflexCore.axios.get<IGetServiceRouteStatsResponse>(
21
- `api/service/${params.applicationId}/${params.serviceId}/route-stats`,
22
- { params: query },
23
- )
24
- ).data;
25
-
26
- /** `GET .../route/:routeId/insights`: runs, HTTP classes and percentiles of one route, step by step. Needs REFLEX_READ. */
27
- export const getRouteInsights = async (
28
- params: IGetRouteInsightsParams,
29
- query: IGetRouteInsightsQuery,
30
- ): Promise<IGetRouteInsightsResponse> =>
31
- (
32
- await AbyssReflexCore.axios.get<IGetRouteInsightsResponse>(
33
- `api/service/${params.applicationId}/${params.serviceId}/route/${params.routeId}/insights`,
34
- { params: query },
35
- )
36
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IGetRouteInsightsParams,
4
+ IGetRouteInsightsQuery,
5
+ IGetRouteInsightsResponse,
6
+ IGetServiceRouteStatsParams,
7
+ IGetServiceRouteStatsQuery,
8
+ IGetServiceRouteStatsResponse,
9
+ } from '../types';
10
+
11
+ /**
12
+ * `GET .../route-stats`: every route of a Service over a period: runs, failures, p50, p95, p99, HTTP classes and
13
+ * a short series. Needs REFLEX_READ.
14
+ */
15
+ export const getServiceRouteStats = async (
16
+ params: IGetServiceRouteStatsParams,
17
+ query: IGetServiceRouteStatsQuery,
18
+ ): Promise<IGetServiceRouteStatsResponse> =>
19
+ (
20
+ await AbyssReflexCore.axios.get<IGetServiceRouteStatsResponse>(
21
+ `api/service/${params.applicationId}/${params.serviceId}/route-stats`,
22
+ { params: query },
23
+ )
24
+ ).data;
25
+
26
+ /** `GET .../route/:routeId/insights`: runs, HTTP classes and percentiles of one route, step by step. Needs REFLEX_READ. */
27
+ export const getRouteInsights = async (
28
+ params: IGetRouteInsightsParams,
29
+ query: IGetRouteInsightsQuery,
30
+ ): Promise<IGetRouteInsightsResponse> =>
31
+ (
32
+ await AbyssReflexCore.axios.get<IGetRouteInsightsResponse>(
33
+ `api/service/${params.applicationId}/${params.serviceId}/route/${params.routeId}/insights`,
34
+ { params: query },
35
+ )
36
+ ).data;