@abyss-project/reflex 5.12.0 → 6.0.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 (298) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/README.md +15 -15
  4. package/dist/api/index.d.ts +4 -0
  5. package/dist/api/index.js +4 -0
  6. package/dist/api/index.js.map +1 -1
  7. package/dist/api/service-completion-webhook.api.d.ts +3 -0
  8. package/dist/api/service-completion-webhook.api.js +10 -0
  9. package/dist/api/service-completion-webhook.api.js.map +1 -0
  10. package/dist/api/service-consumer.api.d.ts +7 -0
  11. package/dist/api/service-consumer.api.js +19 -0
  12. package/dist/api/service-consumer.api.js.map +1 -0
  13. package/dist/api/service-discord.api.d.ts +1 -2
  14. package/dist/api/service-discord.api.js +1 -3
  15. package/dist/api/service-discord.api.js.map +1 -1
  16. package/dist/api/service-limits.api.d.ts +3 -0
  17. package/dist/api/service-limits.api.js +10 -0
  18. package/dist/api/service-limits.api.js.map +1 -0
  19. package/dist/api/service-openapi.api.d.ts +2 -0
  20. package/dist/api/service-openapi.api.js +7 -0
  21. package/dist/api/service-openapi.api.js.map +1 -0
  22. package/dist/api/service-route.api.js.map +1 -1
  23. package/dist/index.d.ts +23 -1
  24. package/dist/index.js +23 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/types/enum/completion-delivery-status.enum.d.ts +5 -0
  27. package/dist/types/enum/completion-delivery-status.enum.js +10 -0
  28. package/dist/types/enum/completion-delivery-status.enum.js.map +1 -0
  29. package/dist/types/enum/index.d.ts +2 -0
  30. package/dist/types/enum/index.js +2 -0
  31. package/dist/types/enum/index.js.map +1 -1
  32. package/dist/types/enum/reflex-error-code.enum.d.ts +8 -1
  33. package/dist/types/enum/reflex-error-code.enum.js +7 -0
  34. package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
  35. package/dist/types/enum/run-status.enum.d.ts +2 -1
  36. package/dist/types/enum/run-status.enum.js +1 -0
  37. package/dist/types/enum/run-status.enum.js.map +1 -1
  38. package/dist/types/enum/scheduled-run-failure-code.enum.d.ts +2 -1
  39. package/dist/types/enum/scheduled-run-failure-code.enum.js +1 -0
  40. package/dist/types/enum/scheduled-run-failure-code.enum.js.map +1 -1
  41. package/dist/types/enum/service-block-reason.enum.d.ts +4 -0
  42. package/dist/types/enum/service-block-reason.enum.js +9 -0
  43. package/dist/types/enum/service-block-reason.enum.js.map +1 -0
  44. package/dist/types/interface/api/requests/function-run.request.d.ts +1 -0
  45. package/dist/types/interface/api/requests/function-test.request.d.ts +1 -0
  46. package/dist/types/interface/api/requests/index.d.ts +4 -0
  47. package/dist/types/interface/api/requests/index.js +4 -0
  48. package/dist/types/interface/api/requests/index.js.map +1 -1
  49. package/dist/types/interface/api/requests/service-completion-webhook.request.d.ts +9 -0
  50. package/dist/types/interface/api/requests/service-completion-webhook.request.js +3 -0
  51. package/dist/types/interface/api/requests/service-completion-webhook.request.js.map +1 -0
  52. package/dist/types/interface/api/requests/service-consumer.request.d.ts +41 -0
  53. package/dist/types/interface/api/requests/service-consumer.request.js +3 -0
  54. package/dist/types/interface/api/requests/service-consumer.request.js.map +1 -0
  55. package/dist/types/interface/api/requests/service-discord.request.d.ts +1 -14
  56. package/dist/types/interface/api/requests/service-limits.request.d.ts +18 -0
  57. package/dist/types/interface/api/requests/service-limits.request.js +3 -0
  58. package/dist/types/interface/api/requests/service-limits.request.js.map +1 -0
  59. package/dist/types/interface/api/requests/service-openapi.request.d.ts +8 -0
  60. package/dist/types/interface/api/requests/service-openapi.request.js +3 -0
  61. package/dist/types/interface/api/requests/service-openapi.request.js.map +1 -0
  62. package/dist/types/interface/api/requests/service-route.request.d.ts +3 -0
  63. package/dist/types/interface/api/responses/function-settings.response.d.ts +3 -1
  64. package/dist/types/interface/api/responses/function-test.response.d.ts +3 -1
  65. package/dist/types/interface/api/responses/index.d.ts +4 -0
  66. package/dist/types/interface/api/responses/index.js +4 -0
  67. package/dist/types/interface/api/responses/index.js.map +1 -1
  68. package/dist/types/interface/api/responses/service-completion-webhook.response.d.ts +8 -0
  69. package/dist/types/interface/api/responses/service-completion-webhook.response.js +3 -0
  70. package/dist/types/interface/api/responses/service-completion-webhook.response.js.map +1 -0
  71. package/dist/types/interface/api/responses/service-consumer.response.d.ts +25 -0
  72. package/dist/types/interface/api/responses/service-consumer.response.js +3 -0
  73. package/dist/types/interface/api/responses/service-consumer.response.js.map +1 -0
  74. package/dist/types/interface/api/responses/service-discord.response.d.ts +1 -9
  75. package/dist/types/interface/api/responses/service-limits.response.d.ts +10 -0
  76. package/dist/types/interface/api/responses/service-limits.response.js +3 -0
  77. package/dist/types/interface/api/responses/service-limits.response.js.map +1 -0
  78. package/dist/types/interface/api/responses/service-openapi.response.d.ts +5 -0
  79. package/dist/types/interface/api/responses/service-openapi.response.js +3 -0
  80. package/dist/types/interface/api/responses/service-openapi.response.js.map +1 -0
  81. package/dist/types/interface/models/index.d.ts +4 -0
  82. package/dist/types/interface/models/index.js +4 -0
  83. package/dist/types/interface/models/index.js.map +1 -1
  84. package/dist/types/interface/models/reflex-bot-limits.model.d.ts +0 -25
  85. package/dist/types/interface/models/reflex-bot-limits.model.js +8 -7
  86. package/dist/types/interface/models/reflex-bot-limits.model.js.map +1 -1
  87. package/dist/types/interface/models/reflex-completion-webhook.model.d.ts +48 -0
  88. package/dist/types/interface/models/reflex-completion-webhook.model.js +12 -0
  89. package/dist/types/interface/models/reflex-completion-webhook.model.js.map +1 -0
  90. package/dist/types/interface/models/reflex-consumer.model.d.ts +30 -0
  91. package/dist/types/interface/models/reflex-consumer.model.js +11 -0
  92. package/dist/types/interface/models/reflex-consumer.model.js.map +1 -0
  93. package/dist/types/interface/models/reflex-execution-settings.model.d.ts +1 -0
  94. package/dist/types/interface/models/reflex-execution-settings.model.js +1 -0
  95. package/dist/types/interface/models/reflex-execution-settings.model.js.map +1 -1
  96. package/dist/types/interface/models/reflex-route-contract.model.d.ts +22 -0
  97. package/dist/types/interface/models/reflex-route-contract.model.js +13 -0
  98. package/dist/types/interface/models/reflex-route-contract.model.js.map +1 -0
  99. package/dist/types/interface/models/reflex-route.model.d.ts +2 -0
  100. package/dist/types/interface/models/reflex-run.model.d.ts +21 -0
  101. package/dist/types/interface/models/reflex-run.model.js.map +1 -1
  102. package/dist/types/interface/models/reflex-service-limits.model.d.ts +41 -0
  103. package/dist/types/interface/models/reflex-service-limits.model.js +13 -0
  104. package/dist/types/interface/models/reflex-service-limits.model.js.map +1 -0
  105. package/dist/types/interface/models/reflex-service-version.model.d.ts +2 -0
  106. package/jest.config.ts +11 -11
  107. package/package.json +1 -1
  108. package/src/api/alert-rule.api.test.ts +72 -72
  109. package/src/api/alert-rule.api.ts +57 -57
  110. package/src/api/application-insights.api.test.ts +42 -42
  111. package/src/api/application-insights.api.ts +38 -38
  112. package/src/api/application-run-settings.api.test.ts +51 -51
  113. package/src/api/application-run-settings.api.ts +30 -30
  114. package/src/api/function-access.api.ts +87 -87
  115. package/src/api/function-insights.api.test.ts +27 -27
  116. package/src/api/function-insights.api.ts +18 -18
  117. package/src/api/function-run.api.ts +38 -38
  118. package/src/api/function-settings.api.ts +74 -74
  119. package/src/api/function-template.api.test.ts +72 -72
  120. package/src/api/function-template.api.ts +52 -52
  121. package/src/api/function-test.api.ts +34 -34
  122. package/src/api/function-version.api.ts +66 -66
  123. package/src/api/function.api.test.ts +2 -1
  124. package/src/api/function.api.ts +62 -62
  125. package/src/api/health.api.ts +10 -10
  126. package/src/api/index.ts +4 -0
  127. package/src/api/route-stats.api.test.ts +45 -45
  128. package/src/api/route-stats.api.ts +36 -36
  129. package/src/api/service-completion-webhook.api.test.ts +87 -0
  130. package/src/api/service-completion-webhook.api.ts +37 -0
  131. package/src/api/service-configuration.api.ts +16 -16
  132. package/src/api/service-consumer.api.test.ts +104 -0
  133. package/src/api/service-consumer.api.ts +88 -0
  134. package/src/api/service-deployment.api.ts +79 -79
  135. package/src/api/service-discord-event.api.test.ts +106 -106
  136. package/src/api/service-discord-event.api.ts +78 -78
  137. package/src/api/service-discord.api.test.ts +0 -19
  138. package/src/api/service-discord.api.ts +0 -19
  139. package/src/api/service-insights.api.test.ts +36 -36
  140. package/src/api/service-insights.api.ts +42 -42
  141. package/src/api/service-limits.api.test.ts +100 -0
  142. package/src/api/service-limits.api.ts +37 -0
  143. package/src/api/service-openapi.api.test.ts +52 -0
  144. package/src/api/service-openapi.api.ts +21 -0
  145. package/src/api/service-route.api.ts +8 -6
  146. package/src/api/service-task.api.test.ts +140 -140
  147. package/src/api/service-task.api.ts +141 -141
  148. package/src/api/service-version.api.ts +54 -54
  149. package/src/api/service.api.test.ts +215 -215
  150. package/src/api/service.api.ts +55 -55
  151. package/src/discord/discord-event-filter-cases.ts +261 -261
  152. package/src/discord/discord-event-filters.test.ts +91 -91
  153. package/src/discord/discord-event-filters.ts +95 -95
  154. package/src/discord/discord-event-intents.test.ts +112 -112
  155. package/src/discord/discord-event-intents.ts +55 -55
  156. package/src/discord/index.ts +3 -3
  157. package/src/index.test.ts +18 -1
  158. package/src/index.ts +46 -3
  159. package/src/insights/index.ts +1 -1
  160. package/src/insights/percentiles.test.ts +75 -75
  161. package/src/insights/percentiles.ts +37 -37
  162. package/src/types/enum/access-grant-status.enum.ts +12 -12
  163. package/src/types/enum/access-kind.enum.ts +7 -7
  164. package/src/types/enum/access-request-status.enum.ts +11 -11
  165. package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
  166. package/src/types/enum/completion-delivery-status.enum.ts +9 -0
  167. package/src/types/enum/configuration-read-as.enum.ts +5 -5
  168. package/src/types/enum/discord-activity-type.enum.ts +9 -9
  169. package/src/types/enum/discord-channel-type.enum.ts +11 -11
  170. package/src/types/enum/discord-component-kind.enum.ts +7 -7
  171. package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
  172. package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
  173. package/src/types/enum/discord-event-status.enum.ts +13 -13
  174. package/src/types/enum/discord-event-type.enum.ts +7 -7
  175. package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
  176. package/src/types/enum/discord-gateway-state.enum.ts +11 -11
  177. package/src/types/enum/discord-host-action.enum.ts +35 -35
  178. package/src/types/enum/discord-locale.enum.ts +35 -35
  179. package/src/types/enum/discord-option-type.enum.ts +12 -12
  180. package/src/types/enum/discord-presence-status.enum.ts +8 -8
  181. package/src/types/enum/discord-sync-status.enum.ts +6 -6
  182. package/src/types/enum/discord-token-state.enum.ts +11 -11
  183. package/src/types/enum/execution-mode.enum.ts +9 -9
  184. package/src/types/enum/execution-profile.enum.ts +20 -20
  185. package/src/types/enum/execution-settings-source.enum.ts +9 -9
  186. package/src/types/enum/health-status.enum.ts +4 -4
  187. package/src/types/enum/index.ts +2 -0
  188. package/src/types/enum/insights-period.enum.ts +8 -8
  189. package/src/types/enum/log-cap-mode.enum.ts +6 -6
  190. package/src/types/enum/log-drop-cause.enum.ts +8 -8
  191. package/src/types/enum/reflex-alert-metric.enum.ts +5 -5
  192. package/src/types/enum/reflex-alert-notification-state.enum.ts +6 -6
  193. package/src/types/enum/reflex-alert-scope.enum.ts +6 -6
  194. package/src/types/enum/reflex-error-code.enum.ts +31 -1
  195. package/src/types/enum/route-method.enum.ts +9 -9
  196. package/src/types/enum/run-log-level.enum.ts +6 -6
  197. package/src/types/enum/run-mode.enum.ts +11 -11
  198. package/src/types/enum/run-status.enum.ts +5 -0
  199. package/src/types/enum/run-step-status.enum.ts +7 -7
  200. package/src/types/enum/schedule-sync-status.enum.ts +6 -6
  201. package/src/types/enum/scheduled-run-failure-code.enum.ts +3 -1
  202. package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
  203. package/src/types/enum/scheduled-run-status.enum.ts +17 -17
  204. package/src/types/enum/service-block-reason.enum.ts +13 -0
  205. package/src/types/enum/service-deployment-action.enum.ts +11 -11
  206. package/src/types/enum/service-deployment-status.enum.ts +5 -5
  207. package/src/types/enum/service-type.enum.ts +9 -9
  208. package/src/types/enum/service-version-change-kind.enum.ts +6 -6
  209. package/src/types/enum/trace-effect-type.enum.ts +12 -12
  210. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  211. package/src/types/enum/trigger-kind.enum.ts +8 -8
  212. package/src/types/enum/vault-value-source.enum.ts +12 -12
  213. package/src/types/enum/vault-visibility.enum.ts +5 -5
  214. package/src/types/index.ts +2 -2
  215. package/src/types/interface/api/index.ts +3 -3
  216. package/src/types/interface/api/requests/alert-rule.request.ts +53 -53
  217. package/src/types/interface/api/requests/application-insights.request.ts +18 -18
  218. package/src/types/interface/api/requests/application-run-settings.request.ts +11 -11
  219. package/src/types/interface/api/requests/function-access.request.ts +51 -51
  220. package/src/types/interface/api/requests/function-run.request.ts +2 -0
  221. package/src/types/interface/api/requests/function-settings.request.ts +34 -34
  222. package/src/types/interface/api/requests/function-template.request.ts +29 -29
  223. package/src/types/interface/api/requests/function-test.request.ts +5 -0
  224. package/src/types/interface/api/requests/function-version.request.ts +38 -38
  225. package/src/types/interface/api/requests/function.request.ts +36 -36
  226. package/src/types/interface/api/requests/index.ts +4 -0
  227. package/src/types/interface/api/requests/route-stats.request.ts +22 -22
  228. package/src/types/interface/api/requests/service-completion-webhook.request.ts +11 -0
  229. package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
  230. package/src/types/interface/api/requests/service-consumer.request.ts +51 -0
  231. package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
  232. package/src/types/interface/api/requests/service-discord-event.request.ts +68 -68
  233. package/src/types/interface/api/requests/service-discord.request.ts +1 -25
  234. package/src/types/interface/api/requests/service-insights.request.ts +31 -31
  235. package/src/types/interface/api/requests/service-limits.request.ts +28 -0
  236. package/src/types/interface/api/requests/service-openapi.request.ts +10 -0
  237. package/src/types/interface/api/requests/service-route.request.ts +8 -0
  238. package/src/types/interface/api/requests/service-task.request.ts +80 -80
  239. package/src/types/interface/api/requests/service-version.request.ts +24 -24
  240. package/src/types/interface/api/requests/service.request.ts +46 -46
  241. package/src/types/interface/api/response.ts +4 -4
  242. package/src/types/interface/api/responses/alert-rule.response.ts +24 -24
  243. package/src/types/interface/api/responses/application-insights.response.ts +11 -11
  244. package/src/types/interface/api/responses/application-run-settings.response.ts +8 -8
  245. package/src/types/interface/api/responses/function-access.response.ts +45 -45
  246. package/src/types/interface/api/responses/function-run.response.ts +18 -18
  247. package/src/types/interface/api/responses/function-settings.response.ts +8 -0
  248. package/src/types/interface/api/responses/function-template.response.ts +21 -21
  249. package/src/types/interface/api/responses/function-test.response.ts +8 -1
  250. package/src/types/interface/api/responses/function-version.response.ts +42 -42
  251. package/src/types/interface/api/responses/function.response.ts +25 -25
  252. package/src/types/interface/api/responses/index.ts +4 -0
  253. package/src/types/interface/api/responses/route-stats.response.ts +15 -15
  254. package/src/types/interface/api/responses/service-completion-webhook.response.ts +13 -0
  255. package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
  256. package/src/types/interface/api/responses/service-consumer.response.ts +33 -0
  257. package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
  258. package/src/types/interface/api/responses/service-discord-event.response.ts +24 -24
  259. package/src/types/interface/api/responses/service-discord.response.ts +4 -16
  260. package/src/types/interface/api/responses/service-insights.response.ts +11 -11
  261. package/src/types/interface/api/responses/service-limits.response.ts +13 -0
  262. package/src/types/interface/api/responses/service-openapi.response.ts +7 -0
  263. package/src/types/interface/api/responses/service-route.response.ts +3 -3
  264. package/src/types/interface/api/responses/service-task.response.ts +57 -57
  265. package/src/types/interface/api/responses/service-version.response.ts +112 -112
  266. package/src/types/interface/api/responses/service.response.ts +31 -31
  267. package/src/types/interface/health.response.ts +7 -7
  268. package/src/types/interface/index.ts +3 -3
  269. package/src/types/interface/models/index.ts +4 -0
  270. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  271. package/src/types/interface/models/reflex-access-request.model.ts +15 -15
  272. package/src/types/interface/models/reflex-alert-rule.model.ts +56 -56
  273. package/src/types/interface/models/reflex-bot-limits.model.ts +12 -51
  274. package/src/types/interface/models/reflex-completion-webhook.model.ts +85 -0
  275. package/src/types/interface/models/reflex-consumer.model.ts +50 -0
  276. package/src/types/interface/models/reflex-definition.model.ts +31 -31
  277. package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -58
  278. package/src/types/interface/models/reflex-discord-event.model.ts +79 -79
  279. package/src/types/interface/models/reflex-discord.model.ts +196 -196
  280. package/src/types/interface/models/reflex-execution-settings.model.ts +7 -0
  281. package/src/types/interface/models/reflex-function-template.model.ts +18 -18
  282. package/src/types/interface/models/reflex-function-version.model.ts +19 -19
  283. package/src/types/interface/models/reflex-function.model.ts +30 -30
  284. package/src/types/interface/models/reflex-insights.model.ts +215 -215
  285. package/src/types/interface/models/reflex-price-list.model.ts +20 -20
  286. package/src/types/interface/models/reflex-route-contract.model.ts +46 -0
  287. package/src/types/interface/models/reflex-route.model.ts +5 -1
  288. package/src/types/interface/models/reflex-run-settings.model.ts +28 -28
  289. package/src/types/interface/models/reflex-run.model.ts +47 -3
  290. package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
  291. package/src/types/interface/models/reflex-service-deployment.model.ts +46 -46
  292. package/src/types/interface/models/reflex-service-limits.model.ts +73 -0
  293. package/src/types/interface/models/reflex-service-version.model.ts +3 -0
  294. package/src/types/interface/models/reflex-service.model.ts +45 -45
  295. package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
  296. package/src/types/interface/models/reflex-task.model.ts +97 -97
  297. package/tsconfig.check.json +15 -15
  298. package/tsconfig.json +35 -35
@@ -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
@@ -20,3 +20,7 @@ export * from './application-insights.api';
20
20
  export * from './alert-rule.api';
21
21
  export * from './route-stats.api';
22
22
  export * from './function-template.api';
23
+ export * from './service-consumer.api';
24
+ export * from './service-openapi.api';
25
+ export * from './service-limits.api';
26
+ export * from './service-completion-webhook.api';
@@ -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;
@@ -0,0 +1,87 @@
1
+ import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
+ import {
3
+ AbyssReflexCore,
4
+ COMPLETION_DELIVERY_ID_HEADER,
5
+ CompletionDeliveryStatus,
6
+ DEFAULT_REFLEX_EXECUTION_SETTINGS,
7
+ REFLEX_COMPLETION_WEBHOOK_LIMITS,
8
+ RESERVED_EXECUTIONS_SEGMENT,
9
+ RunStatus,
10
+ } from '..';
11
+
12
+ const APP = 'app-1';
13
+ const SVC = 'svc-1';
14
+ const BASE = `api/service/${APP}/${SVC}`;
15
+ const SERVICE = { applicationId: APP, serviceId: SVC };
16
+
17
+ interface Call {
18
+ label: string;
19
+ method: string;
20
+ url: string;
21
+ body?: unknown;
22
+ run: () => Promise<unknown>;
23
+ }
24
+
25
+ const webhook = () => AbyssReflexCore.sdk.service.completionWebhook;
26
+
27
+ const calls: Call[] = [
28
+ {
29
+ label: 'get',
30
+ method: 'get',
31
+ url: `${BASE}/completion-webhook`,
32
+ run: () => webhook().get(SERVICE),
33
+ },
34
+ {
35
+ label: 'rotateSecret',
36
+ method: 'post',
37
+ url: `${BASE}/completion-webhook/e-1/secret`,
38
+ body: {},
39
+ run: () => webhook().rotateSecret({ ...SERVICE, environmentId: 'e-1' }),
40
+ },
41
+ ];
42
+
43
+ describe('AbyssReflexCore completion webhook routes', () => {
44
+ const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
45
+ async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
46
+ );
47
+
48
+ beforeAll(() => {
49
+ AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
50
+ AbyssReflexCore.axios.defaults.adapter = adapter;
51
+ });
52
+
53
+ beforeEach(() => adapter.mockClear());
54
+
55
+ it.each(calls)('$label calls $method $url', async (call) => {
56
+ await call.run();
57
+
58
+ const config = adapter.mock.calls[0][0];
59
+ expect(config.method).toBe(call.method);
60
+ expect(config.url).toBe(call.url);
61
+ expect(config.baseURL).toBe('http://reflex.test/');
62
+ if (call.body !== undefined) {
63
+ expect(JSON.parse(config.data)).toEqual(call.body);
64
+ }
65
+ });
66
+
67
+ it('exposes no route twice', () => {
68
+ expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
69
+ });
70
+
71
+ it('carries the bounds and the names of the completion webhook', () => {
72
+ expect(REFLEX_COMPLETION_WEBHOOK_LIMITS).toEqual({
73
+ urlMaxLength: 2048,
74
+ retryDelaysMinutes: [1, 5, 15, 30, 60],
75
+ sendTimeoutMs: 10_000,
76
+ outputMaxBytes: 65_536,
77
+ });
78
+ expect(COMPLETION_DELIVERY_ID_HEADER).toBe('x-abyss-delivery-id');
79
+ expect(RESERVED_EXECUTIONS_SEGMENT).toBe('_executions');
80
+ expect(Object.values(CompletionDeliveryStatus)).toEqual(['PENDING', 'DELIVERED', 'FAILED']);
81
+ expect(RunStatus.REFUSED).toBe('REFUSED');
82
+ });
83
+
84
+ it('sets no completion webhook by default', () => {
85
+ expect(DEFAULT_REFLEX_EXECUTION_SETTINGS.completionWebhookUrl).toBeNull();
86
+ });
87
+ });
@@ -0,0 +1,37 @@
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IGetServiceCompletionWebhookParams,
4
+ IGetServiceCompletionWebhookResponse,
5
+ IRotateServiceCompletionWebhookSecretParams,
6
+ IRotateServiceCompletionWebhookSecretResponse,
7
+ } from '../types';
8
+
9
+ const completionWebhookUrl = (params: { applicationId: string; serviceId: string }): string =>
10
+ `api/service/${params.applicationId}/${params.serviceId}/completion-webhook`;
11
+
12
+ /**
13
+ * `GET .../completion-webhook`: the environments where the completion webhook of the Service has a signing
14
+ * secret, never the secret itself. Needs REFLEX_READ.
15
+ */
16
+ export const getServiceCompletionWebhook = async (
17
+ params: IGetServiceCompletionWebhookParams,
18
+ ): Promise<IGetServiceCompletionWebhookResponse> =>
19
+ (
20
+ await AbyssReflexCore.axios.get<IGetServiceCompletionWebhookResponse>(
21
+ completionWebhookUrl(params),
22
+ )
23
+ ).data;
24
+
25
+ /**
26
+ * `POST .../completion-webhook/:environmentId/secret`: a new signing secret of the completion webhook in the
27
+ * environment, in clear ONCE; the next deliveries are signed with it. Needs REFLEX_PUBLISH.
28
+ */
29
+ export const rotateServiceCompletionWebhookSecret = async (
30
+ params: IRotateServiceCompletionWebhookSecretParams,
31
+ ): Promise<IRotateServiceCompletionWebhookSecretResponse> =>
32
+ (
33
+ await AbyssReflexCore.axios.post<IRotateServiceCompletionWebhookSecretResponse>(
34
+ `${completionWebhookUrl(params)}/${params.environmentId}/secret`,
35
+ {},
36
+ )
37
+ ).data;
@@ -1,16 +1,16 @@
1
- import { AbyssReflexCore } from '..';
2
- import type { IListServiceConfigurationParams, IListServiceConfigurationResponse } from '../types';
3
-
4
- /**
5
- * `GET .../configuration`: per key the functions of the Service read (draft and versions in service),
6
- * and per environment of the application, where the Console vault gets its value from; never a value.
7
- * Needs REFLEX_READ, and SECRET_READ on the project (Console re-checks it).
8
- */
9
- export const listServiceConfiguration = async (
10
- params: IListServiceConfigurationParams,
11
- ): Promise<IListServiceConfigurationResponse> =>
12
- (
13
- await AbyssReflexCore.axios.get<IListServiceConfigurationResponse>(
14
- `api/service/${params.applicationId}/${params.serviceId}/configuration`,
15
- )
16
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type { IListServiceConfigurationParams, IListServiceConfigurationResponse } from '../types';
3
+
4
+ /**
5
+ * `GET .../configuration`: per key the functions of the Service read (draft and versions in service),
6
+ * and per environment of the application, where the Console vault gets its value from; never a value.
7
+ * Needs REFLEX_READ, and SECRET_READ on the project (Console re-checks it).
8
+ */
9
+ export const listServiceConfiguration = async (
10
+ params: IListServiceConfigurationParams,
11
+ ): Promise<IListServiceConfigurationResponse> =>
12
+ (
13
+ await AbyssReflexCore.axios.get<IListServiceConfigurationResponse>(
14
+ `api/service/${params.applicationId}/${params.serviceId}/configuration`,
15
+ )
16
+ ).data;
@@ -0,0 +1,104 @@
1
+ import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
+ import { AbyssReflexCore, REFLEX_CONSUMER_LIMITS, ReflexErrorCode } from '..';
3
+
4
+ const APP = 'app-1';
5
+ const SVC = 'svc-1';
6
+ const BASE = `api/service/${APP}/${SVC}`;
7
+ const SERVICE = { applicationId: APP, serviceId: SVC };
8
+
9
+ interface Call {
10
+ label: string;
11
+ method: string;
12
+ url: string;
13
+ body?: unknown;
14
+ run: () => Promise<unknown>;
15
+ }
16
+
17
+ const consumer = () => AbyssReflexCore.sdk.service.consumer;
18
+
19
+ const created = { name: 'Billing partner', routeIds: ['r-1'], rateLimitPerMinute: 120 };
20
+
21
+ const calls: Call[] = [
22
+ {
23
+ label: 'list',
24
+ method: 'get',
25
+ url: `${BASE}/consumer`,
26
+ run: () => consumer().list(SERVICE),
27
+ },
28
+ {
29
+ label: 'create',
30
+ method: 'post',
31
+ url: `${BASE}/consumer`,
32
+ body: created,
33
+ run: () => consumer().create(SERVICE, created),
34
+ },
35
+ {
36
+ label: 'update',
37
+ method: 'patch',
38
+ url: `${BASE}/consumer/c-1`,
39
+ body: { name: 'Partner', routeIds: null },
40
+ run: () =>
41
+ consumer().update({ ...SERVICE, consumerId: 'c-1' }, { name: 'Partner', routeIds: null }),
42
+ },
43
+ {
44
+ label: 'delete',
45
+ method: 'delete',
46
+ url: `${BASE}/consumer/c-1`,
47
+ run: () => consumer().delete({ ...SERVICE, consumerId: 'c-1' }),
48
+ },
49
+ {
50
+ label: 'createKey',
51
+ method: 'post',
52
+ url: `${BASE}/consumer/c-1/key`,
53
+ body: {},
54
+ run: () => consumer().createKey({ ...SERVICE, consumerId: 'c-1' }),
55
+ },
56
+ {
57
+ label: 'revokeKey',
58
+ method: 'post',
59
+ url: `${BASE}/consumer/c-1/key/k-1/revoke`,
60
+ body: {},
61
+ run: () => consumer().revokeKey({ ...SERVICE, consumerId: 'c-1', keyId: 'k-1' }),
62
+ },
63
+ ];
64
+
65
+ describe('AbyssReflexCore consumer routes', () => {
66
+ const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
67
+ async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
68
+ );
69
+
70
+ beforeAll(() => {
71
+ AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
72
+ AbyssReflexCore.axios.defaults.adapter = adapter;
73
+ });
74
+
75
+ beforeEach(() => adapter.mockClear());
76
+
77
+ it.each(calls)('$label calls $method $url', async (call) => {
78
+ await call.run();
79
+
80
+ const config = adapter.mock.calls[0][0];
81
+ expect(config.method).toBe(call.method);
82
+ expect(config.url).toBe(call.url);
83
+ expect(config.baseURL).toBe('http://reflex.test/');
84
+ if (call.body !== undefined) {
85
+ expect(JSON.parse(config.data)).toEqual(call.body);
86
+ }
87
+ });
88
+
89
+ it('exposes no route twice', () => {
90
+ expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
91
+ });
92
+
93
+ it('carries the bounds of the consumers and their refusal codes', () => {
94
+ expect(REFLEX_CONSUMER_LIMITS).toEqual({
95
+ perService: 100,
96
+ activeKeysPerConsumer: 5,
97
+ nameMaxLength: 64,
98
+ descriptionMaxLength: 500,
99
+ rateLimitPerMinute: { min: 1, max: 100_000 },
100
+ });
101
+ expect(ReflexErrorCode.CONSUMER_LIMIT_REACHED).toBe('CONSUMER_LIMIT_REACHED');
102
+ expect(ReflexErrorCode.CONSUMER_KEY_LIMIT_REACHED).toBe('CONSUMER_KEY_LIMIT_REACHED');
103
+ });
104
+ });
@@ -0,0 +1,88 @@
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ ICreateServiceConsumerBody,
4
+ ICreateServiceConsumerKeyParams,
5
+ ICreateServiceConsumerKeyResponse,
6
+ ICreateServiceConsumerParams,
7
+ ICreateServiceConsumerResponse,
8
+ IDeleteServiceConsumerParams,
9
+ IDeleteServiceConsumerResponse,
10
+ IListServiceConsumerParams,
11
+ IListServiceConsumerResponse,
12
+ IRevokeServiceConsumerKeyParams,
13
+ IRevokeServiceConsumerKeyResponse,
14
+ IUpdateServiceConsumerBody,
15
+ IUpdateServiceConsumerParams,
16
+ IUpdateServiceConsumerResponse,
17
+ } from '../types';
18
+
19
+ const consumerUrl = (params: { applicationId: string; serviceId: string }): string =>
20
+ `api/service/${params.applicationId}/${params.serviceId}/consumer`;
21
+
22
+ /** `GET .../consumer`: the consumers of the Service with their keys, by name. Needs REFLEX_READ. */
23
+ export const listServiceConsumer = async (
24
+ params: IListServiceConsumerParams,
25
+ ): Promise<IListServiceConsumerResponse> =>
26
+ (await AbyssReflexCore.axios.get<IListServiceConsumerResponse>(consumerUrl(params))).data;
27
+
28
+ /**
29
+ * `POST .../consumer`: a consumer of the `API_KEY` routes of the Service, without key yet.
30
+ * `409 ALREADY_EXISTS` for a name taken whatever the case, `409 CONSUMER_LIMIT_REACHED` past
31
+ * `REFLEX_CONSUMER_LIMITS.perService`. Needs REFLEX_PUBLISH.
32
+ */
33
+ export const createServiceConsumer = async (
34
+ params: ICreateServiceConsumerParams,
35
+ body: ICreateServiceConsumerBody,
36
+ ): Promise<ICreateServiceConsumerResponse> =>
37
+ (await AbyssReflexCore.axios.post<ICreateServiceConsumerResponse>(consumerUrl(params), body))
38
+ .data;
39
+
40
+ /** `PATCH .../consumer/:consumerId`: renames the consumer or changes its routes or its rate, at once. Needs REFLEX_PUBLISH. */
41
+ export const updateServiceConsumer = async (
42
+ params: IUpdateServiceConsumerParams,
43
+ body: IUpdateServiceConsumerBody,
44
+ ): Promise<IUpdateServiceConsumerResponse> =>
45
+ (
46
+ await AbyssReflexCore.axios.patch<IUpdateServiceConsumerResponse>(
47
+ `${consumerUrl(params)}/${params.consumerId}`,
48
+ body,
49
+ )
50
+ ).data;
51
+
52
+ /** `DELETE .../consumer/:consumerId`: the consumer and its keys, refused at once by the edge. Needs REFLEX_PUBLISH. */
53
+ export const deleteServiceConsumer = async (
54
+ params: IDeleteServiceConsumerParams,
55
+ ): Promise<IDeleteServiceConsumerResponse> =>
56
+ (
57
+ await AbyssReflexCore.axios.delete<IDeleteServiceConsumerResponse>(
58
+ `${consumerUrl(params)}/${params.consumerId}`,
59
+ )
60
+ ).data;
61
+
62
+ /**
63
+ * `POST .../consumer/:consumerId/key`: a new key of the consumer, in clear ONCE in `secret`.
64
+ * `409 CONSUMER_KEY_LIMIT_REACHED` past `REFLEX_CONSUMER_LIMITS.activeKeysPerConsumer` active keys. Needs REFLEX_PUBLISH.
65
+ */
66
+ export const createServiceConsumerKey = async (
67
+ params: ICreateServiceConsumerKeyParams,
68
+ ): Promise<ICreateServiceConsumerKeyResponse> =>
69
+ (
70
+ await AbyssReflexCore.axios.post<ICreateServiceConsumerKeyResponse>(
71
+ `${consumerUrl(params)}/${params.consumerId}/key`,
72
+ {},
73
+ )
74
+ ).data;
75
+
76
+ /**
77
+ * `POST .../consumer/:consumerId/key/:keyId/revoke`: revokes the key; the edge refuses it (`401`) as soon as
78
+ * this answers. Needs REFLEX_PUBLISH.
79
+ */
80
+ export const revokeServiceConsumerKey = async (
81
+ params: IRevokeServiceConsumerKeyParams,
82
+ ): Promise<IRevokeServiceConsumerKeyResponse> =>
83
+ (
84
+ await AbyssReflexCore.axios.post<IRevokeServiceConsumerKeyResponse>(
85
+ `${consumerUrl(params)}/${params.consumerId}/key/${params.keyId}/revoke`,
86
+ {},
87
+ )
88
+ ).data;