@abyss-project/reflex 5.8.1 → 5.10.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 (255) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/README.md +15 -15
  4. package/dist/api/alert-rule.api.d.ts +5 -0
  5. package/dist/api/alert-rule.api.js +16 -0
  6. package/dist/api/alert-rule.api.js.map +1 -0
  7. package/dist/api/application-insights.api.d.ts +3 -0
  8. package/dist/api/application-insights.api.js +12 -0
  9. package/dist/api/application-insights.api.js.map +1 -0
  10. package/dist/api/application-run-settings.api.d.ts +3 -0
  11. package/dist/api/application-run-settings.api.js +11 -0
  12. package/dist/api/application-run-settings.api.js.map +1 -0
  13. package/dist/api/function-settings.api.d.ts +2 -1
  14. package/dist/api/function-settings.api.js +3 -1
  15. package/dist/api/function-settings.api.js.map +1 -1
  16. package/dist/api/index.d.ts +4 -0
  17. package/dist/api/index.js +4 -0
  18. package/dist/api/index.js.map +1 -1
  19. package/dist/api/route-stats.api.d.ts +3 -0
  20. package/dist/api/route-stats.api.js +9 -0
  21. package/dist/api/route-stats.api.js.map +1 -0
  22. package/dist/index.d.ts +28 -0
  23. package/dist/index.js +28 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/insights/index.d.ts +1 -0
  26. package/dist/insights/index.js +18 -0
  27. package/dist/insights/index.js.map +1 -0
  28. package/dist/insights/percentiles.d.ts +2 -0
  29. package/dist/insights/percentiles.js +28 -0
  30. package/dist/insights/percentiles.js.map +1 -0
  31. package/dist/types/enum/index.d.ts +5 -0
  32. package/dist/types/enum/index.js +5 -0
  33. package/dist/types/enum/index.js.map +1 -1
  34. package/dist/types/enum/log-cap-mode.enum.d.ts +5 -0
  35. package/dist/types/enum/log-cap-mode.enum.js +10 -0
  36. package/dist/types/enum/log-cap-mode.enum.js.map +1 -0
  37. package/dist/types/enum/log-drop-cause.enum.d.ts +4 -0
  38. package/dist/types/enum/log-drop-cause.enum.js +9 -0
  39. package/dist/types/enum/log-drop-cause.enum.js.map +1 -0
  40. package/dist/types/enum/reflex-alert-metric.enum.d.ts +4 -0
  41. package/dist/types/enum/reflex-alert-metric.enum.js +9 -0
  42. package/dist/types/enum/reflex-alert-metric.enum.js.map +1 -0
  43. package/dist/types/enum/reflex-alert-notification-state.enum.d.ts +5 -0
  44. package/dist/types/enum/reflex-alert-notification-state.enum.js +10 -0
  45. package/dist/types/enum/reflex-alert-notification-state.enum.js.map +1 -0
  46. package/dist/types/enum/reflex-alert-scope.enum.d.ts +5 -0
  47. package/dist/types/enum/reflex-alert-scope.enum.js +10 -0
  48. package/dist/types/enum/reflex-alert-scope.enum.js.map +1 -0
  49. package/dist/types/interface/api/requests/alert-rule.request.d.ts +38 -0
  50. package/dist/types/interface/api/requests/alert-rule.request.js +3 -0
  51. package/dist/types/interface/api/requests/alert-rule.request.js.map +1 -0
  52. package/dist/types/interface/api/requests/application-insights.request.d.ts +14 -0
  53. package/dist/types/interface/api/requests/application-insights.request.js +3 -0
  54. package/dist/types/interface/api/requests/application-insights.request.js.map +1 -0
  55. package/dist/types/interface/api/requests/application-run-settings.request.d.ts +9 -0
  56. package/dist/types/interface/api/requests/application-run-settings.request.js +3 -0
  57. package/dist/types/interface/api/requests/application-run-settings.request.js.map +1 -0
  58. package/dist/types/interface/api/requests/function-settings.request.d.ts +6 -1
  59. package/dist/types/interface/api/requests/index.d.ts +4 -0
  60. package/dist/types/interface/api/requests/index.js +4 -0
  61. package/dist/types/interface/api/requests/index.js.map +1 -1
  62. package/dist/types/interface/api/requests/route-stats.request.d.ts +18 -0
  63. package/dist/types/interface/api/requests/route-stats.request.js +3 -0
  64. package/dist/types/interface/api/requests/route-stats.request.js.map +1 -0
  65. package/dist/types/interface/api/responses/alert-rule.response.d.ts +17 -0
  66. package/dist/types/interface/api/responses/alert-rule.response.js +3 -0
  67. package/dist/types/interface/api/responses/alert-rule.response.js.map +1 -0
  68. package/dist/types/interface/api/responses/application-insights.response.d.ts +8 -0
  69. package/dist/types/interface/api/responses/application-insights.response.js +3 -0
  70. package/dist/types/interface/api/responses/application-insights.response.js.map +1 -0
  71. package/dist/types/interface/api/responses/application-run-settings.response.d.ts +6 -0
  72. package/dist/types/interface/api/responses/application-run-settings.response.js +3 -0
  73. package/dist/types/interface/api/responses/application-run-settings.response.js.map +1 -0
  74. package/dist/types/interface/api/responses/function-settings.response.d.ts +4 -1
  75. package/dist/types/interface/api/responses/index.d.ts +4 -0
  76. package/dist/types/interface/api/responses/index.js +4 -0
  77. package/dist/types/interface/api/responses/index.js.map +1 -1
  78. package/dist/types/interface/api/responses/route-stats.response.d.ts +12 -0
  79. package/dist/types/interface/api/responses/route-stats.response.js +3 -0
  80. package/dist/types/interface/api/responses/route-stats.response.js.map +1 -0
  81. package/dist/types/interface/models/index.d.ts +2 -0
  82. package/dist/types/interface/models/index.js +2 -0
  83. package/dist/types/interface/models/index.js.map +1 -1
  84. package/dist/types/interface/models/reflex-alert-rule.model.d.ts +55 -0
  85. package/dist/types/interface/models/reflex-alert-rule.model.js +15 -0
  86. package/dist/types/interface/models/reflex-alert-rule.model.js.map +1 -0
  87. package/dist/types/interface/models/reflex-insights.model.d.ts +63 -0
  88. package/dist/types/interface/models/reflex-insights.model.js +4 -1
  89. package/dist/types/interface/models/reflex-insights.model.js.map +1 -1
  90. package/dist/types/interface/models/reflex-run-settings.model.d.ts +19 -0
  91. package/dist/types/interface/models/reflex-run-settings.model.js +9 -0
  92. package/dist/types/interface/models/reflex-run-settings.model.js.map +1 -0
  93. package/dist/types/interface/models/reflex-run.model.d.ts +42 -4
  94. package/dist/types/interface/models/reflex-run.model.js +9 -0
  95. package/dist/types/interface/models/reflex-run.model.js.map +1 -1
  96. package/jest.config.ts +11 -11
  97. package/package.json +15 -10
  98. package/src/api/alert-rule.api.test.ts +72 -0
  99. package/src/api/alert-rule.api.ts +57 -0
  100. package/src/api/application-insights.api.test.ts +42 -0
  101. package/src/api/application-insights.api.ts +38 -0
  102. package/src/api/application-run-settings.api.test.ts +51 -0
  103. package/src/api/application-run-settings.api.ts +30 -0
  104. package/src/api/function-access.api.ts +36 -36
  105. package/src/api/function-insights.api.test.ts +27 -27
  106. package/src/api/function-insights.api.ts +18 -18
  107. package/src/api/function-run.api.ts +38 -38
  108. package/src/api/function-settings.api.ts +74 -59
  109. package/src/api/function-test.api.ts +34 -34
  110. package/src/api/function-version.api.ts +48 -48
  111. package/src/api/function.api.test.ts +249 -249
  112. package/src/api/function.api.ts +62 -62
  113. package/src/api/health.api.ts +10 -10
  114. package/src/api/index.ts +21 -17
  115. package/src/api/route-stats.api.test.ts +45 -0
  116. package/src/api/route-stats.api.ts +36 -0
  117. package/src/api/service-configuration.api.ts +16 -16
  118. package/src/api/service-deployment.api.ts +79 -79
  119. package/src/api/service-discord-event.api.test.ts +106 -106
  120. package/src/api/service-discord-event.api.ts +78 -78
  121. package/src/api/service-discord.api.test.ts +197 -197
  122. package/src/api/service-discord.api.ts +241 -241
  123. package/src/api/service-insights.api.test.ts +36 -36
  124. package/src/api/service-insights.api.ts +42 -42
  125. package/src/api/service-route.api.ts +72 -72
  126. package/src/api/service-task.api.test.ts +140 -140
  127. package/src/api/service-task.api.ts +141 -141
  128. package/src/api/service-version.api.ts +54 -54
  129. package/src/api/service.api.test.ts +215 -215
  130. package/src/api/service.api.ts +55 -55
  131. package/src/discord/discord-event-filter-cases.ts +261 -261
  132. package/src/discord/discord-event-filters.test.ts +91 -91
  133. package/src/discord/discord-event-filters.ts +95 -95
  134. package/src/discord/discord-event-intents.test.ts +112 -112
  135. package/src/discord/discord-event-intents.ts +55 -55
  136. package/src/discord/index.ts +3 -3
  137. package/src/index.test.ts +87 -75
  138. package/src/index.ts +371 -317
  139. package/src/insights/index.ts +1 -0
  140. package/src/insights/percentiles.test.ts +75 -0
  141. package/src/insights/percentiles.ts +37 -0
  142. package/src/types/enum/access-grant-status.enum.ts +12 -12
  143. package/src/types/enum/access-kind.enum.ts +7 -7
  144. package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
  145. package/src/types/enum/configuration-read-as.enum.ts +5 -5
  146. package/src/types/enum/discord-activity-type.enum.ts +9 -9
  147. package/src/types/enum/discord-component-kind.enum.ts +7 -7
  148. package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
  149. package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
  150. package/src/types/enum/discord-event-status.enum.ts +13 -13
  151. package/src/types/enum/discord-event-type.enum.ts +7 -7
  152. package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
  153. package/src/types/enum/discord-gateway-state.enum.ts +11 -11
  154. package/src/types/enum/discord-option-type.enum.ts +12 -12
  155. package/src/types/enum/discord-presence-status.enum.ts +8 -8
  156. package/src/types/enum/discord-sync-status.enum.ts +6 -6
  157. package/src/types/enum/discord-token-state.enum.ts +11 -11
  158. package/src/types/enum/execution-mode.enum.ts +9 -9
  159. package/src/types/enum/execution-profile.enum.ts +20 -20
  160. package/src/types/enum/execution-settings-source.enum.ts +9 -9
  161. package/src/types/enum/health-status.enum.ts +4 -4
  162. package/src/types/enum/index.ts +45 -40
  163. package/src/types/enum/insights-period.enum.ts +8 -8
  164. package/src/types/enum/log-cap-mode.enum.ts +6 -0
  165. package/src/types/enum/log-drop-cause.enum.ts +8 -0
  166. package/src/types/enum/reflex-alert-metric.enum.ts +5 -0
  167. package/src/types/enum/reflex-alert-notification-state.enum.ts +6 -0
  168. package/src/types/enum/reflex-alert-scope.enum.ts +6 -0
  169. package/src/types/enum/reflex-error-code.enum.ts +43 -43
  170. package/src/types/enum/route-method.enum.ts +9 -9
  171. package/src/types/enum/run-log-level.enum.ts +6 -6
  172. package/src/types/enum/run-mode.enum.ts +11 -11
  173. package/src/types/enum/run-status.enum.ts +11 -11
  174. package/src/types/enum/run-step-status.enum.ts +7 -7
  175. package/src/types/enum/schedule-sync-status.enum.ts +6 -6
  176. package/src/types/enum/scheduled-run-failure-code.enum.ts +12 -12
  177. package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
  178. package/src/types/enum/scheduled-run-status.enum.ts +17 -17
  179. package/src/types/enum/service-deployment-action.enum.ts +11 -11
  180. package/src/types/enum/service-deployment-status.enum.ts +5 -5
  181. package/src/types/enum/service-type.enum.ts +9 -9
  182. package/src/types/enum/service-version-change-kind.enum.ts +6 -6
  183. package/src/types/enum/trace-effect-type.enum.ts +12 -12
  184. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  185. package/src/types/enum/trigger-kind.enum.ts +8 -8
  186. package/src/types/enum/vault-value-source.enum.ts +12 -12
  187. package/src/types/enum/vault-visibility.enum.ts +5 -5
  188. package/src/types/index.ts +2 -2
  189. package/src/types/interface/api/index.ts +3 -3
  190. package/src/types/interface/api/requests/alert-rule.request.ts +53 -0
  191. package/src/types/interface/api/requests/application-insights.request.ts +18 -0
  192. package/src/types/interface/api/requests/application-run-settings.request.ts +11 -0
  193. package/src/types/interface/api/requests/function-access.request.ts +25 -25
  194. package/src/types/interface/api/requests/function-run.request.ts +30 -30
  195. package/src/types/interface/api/requests/function-settings.request.ts +34 -27
  196. package/src/types/interface/api/requests/function-test.request.ts +39 -39
  197. package/src/types/interface/api/requests/function-version.request.ts +20 -20
  198. package/src/types/interface/api/requests/function.request.ts +36 -36
  199. package/src/types/interface/api/requests/index.ts +19 -15
  200. package/src/types/interface/api/requests/route-stats.request.ts +22 -0
  201. package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
  202. package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
  203. package/src/types/interface/api/requests/service-discord-event.request.ts +68 -68
  204. package/src/types/interface/api/requests/service-discord.request.ts +173 -173
  205. package/src/types/interface/api/requests/service-insights.request.ts +31 -31
  206. package/src/types/interface/api/requests/service-route.request.ts +44 -44
  207. package/src/types/interface/api/requests/service-task.request.ts +80 -80
  208. package/src/types/interface/api/requests/service-version.request.ts +24 -24
  209. package/src/types/interface/api/requests/service.request.ts +46 -46
  210. package/src/types/interface/api/response.ts +4 -4
  211. package/src/types/interface/api/responses/alert-rule.response.ts +24 -0
  212. package/src/types/interface/api/responses/application-insights.response.ts +11 -0
  213. package/src/types/interface/api/responses/application-run-settings.response.ts +8 -0
  214. package/src/types/interface/api/responses/function-access.response.ts +17 -17
  215. package/src/types/interface/api/responses/function-run.response.ts +18 -18
  216. package/src/types/interface/api/responses/function-settings.response.ts +42 -36
  217. package/src/types/interface/api/responses/function-test.response.ts +12 -12
  218. package/src/types/interface/api/responses/function-version.response.ts +31 -31
  219. package/src/types/interface/api/responses/function.response.ts +25 -25
  220. package/src/types/interface/api/responses/index.ts +19 -15
  221. package/src/types/interface/api/responses/route-stats.response.ts +15 -0
  222. package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
  223. package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
  224. package/src/types/interface/api/responses/service-discord-event.response.ts +24 -24
  225. package/src/types/interface/api/responses/service-discord.response.ts +122 -122
  226. package/src/types/interface/api/responses/service-insights.response.ts +11 -11
  227. package/src/types/interface/api/responses/service-route.response.ts +31 -31
  228. package/src/types/interface/api/responses/service-task.response.ts +57 -57
  229. package/src/types/interface/api/responses/service-version.response.ts +106 -106
  230. package/src/types/interface/api/responses/service.response.ts +31 -31
  231. package/src/types/interface/health.response.ts +7 -7
  232. package/src/types/interface/index.ts +3 -3
  233. package/src/types/interface/models/index.ts +21 -19
  234. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  235. package/src/types/interface/models/reflex-alert-rule.model.ts +56 -0
  236. package/src/types/interface/models/reflex-bot-limits.model.ts +92 -92
  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-execution-settings.model.ts +50 -50
  241. package/src/types/interface/models/reflex-function-version.model.ts +14 -14
  242. package/src/types/interface/models/reflex-function.model.ts +16 -16
  243. package/src/types/interface/models/reflex-insights.model.ts +215 -120
  244. package/src/types/interface/models/reflex-price-list.model.ts +20 -20
  245. package/src/types/interface/models/reflex-route.model.ts +19 -19
  246. package/src/types/interface/models/reflex-run-settings.model.ts +28 -0
  247. package/src/types/interface/models/reflex-run.model.ts +253 -186
  248. package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
  249. package/src/types/interface/models/reflex-service-deployment.model.ts +46 -46
  250. package/src/types/interface/models/reflex-service-version.model.ts +61 -61
  251. package/src/types/interface/models/reflex-service.model.ts +45 -45
  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
@@ -1,249 +1,249 @@
1
- import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
- import {
3
- AbyssReflexCore,
4
- DEFAULT_REFLEX_EXECUTION_SETTINGS,
5
- EXECUTION_PROFILE_MEMORY_MB,
6
- ExecutionMode,
7
- ExecutionProfile,
8
- REFLEX_EXECUTION_SETTINGS_LIMITS,
9
- RESPOND_STATUS_MAX,
10
- RESPOND_STATUS_MIN,
11
- } from '..';
12
-
13
- const APP = 'app-1';
14
- const FN = 'fn-1';
15
- const BASE = `api/function/${APP}/${FN}`;
16
- const SETTINGS = {
17
- profile: ExecutionProfile.L,
18
- responseTimeoutMs: 10_000,
19
- maxDurationMs: 600_000,
20
- mode: ExecutionMode.ASYNC,
21
- };
22
-
23
- interface Call {
24
- label: string;
25
- method: string;
26
- url: string;
27
- body?: unknown;
28
- params?: unknown;
29
- run: () => Promise<unknown>;
30
- }
31
-
32
- const sdk = () => AbyssReflexCore.sdk.function;
33
-
34
- const calls: Call[] = [
35
- {
36
- label: 'list',
37
- method: 'get',
38
- url: `api/function/${APP}`,
39
- run: () => sdk().list({ applicationId: APP }),
40
- },
41
- {
42
- label: 'create',
43
- method: 'post',
44
- url: `api/function/${APP}`,
45
- body: { name: 'hello', serviceId: 's-1' },
46
- run: () => sdk().create({ applicationId: APP }, { name: 'hello', serviceId: 's-1' }),
47
- },
48
- {
49
- label: 'get',
50
- method: 'get',
51
- url: BASE,
52
- run: () => sdk().get({ applicationId: APP, functionId: FN }),
53
- },
54
- {
55
- label: 'update',
56
- method: 'put',
57
- url: BASE,
58
- body: { name: 'renamed' },
59
- run: () => sdk().update({ applicationId: APP, functionId: FN }, { name: 'renamed' }),
60
- },
61
- {
62
- label: 'delete',
63
- method: 'delete',
64
- url: BASE,
65
- run: () => sdk().delete({ applicationId: APP, functionId: FN }),
66
- },
67
- {
68
- label: 'access.list',
69
- method: 'get',
70
- url: `${BASE}/access`,
71
- run: () => sdk().access.list({ applicationId: APP, functionId: FN }),
72
- },
73
- {
74
- label: 'access.grant',
75
- method: 'post',
76
- url: `${BASE}/access`,
77
- body: { declaration: { kind: 'HOST_ACTION', action: 'store.get' } },
78
- run: () =>
79
- sdk().access.grant(
80
- { applicationId: APP, functionId: FN },
81
- { declaration: { kind: 'HOST_ACTION', action: 'store.get' } as never },
82
- ),
83
- },
84
- {
85
- label: 'access.revoke',
86
- method: 'delete',
87
- url: `${BASE}/access/g-1`,
88
- run: () => sdk().access.revoke({ applicationId: APP, functionId: FN, grantId: 'g-1' }),
89
- },
90
- {
91
- label: 'test.simulate',
92
- method: 'post',
93
- url: `${BASE}/test/simulate`,
94
- body: { environmentId: 'e-1', input: { a: 1 } },
95
- run: () =>
96
- sdk().test.simulate(
97
- { applicationId: APP, functionId: FN },
98
- { environmentId: 'e-1', input: { a: 1 } },
99
- ),
100
- },
101
- {
102
- label: 'test.dryRun',
103
- method: 'post',
104
- url: `${BASE}/test/dry-run`,
105
- body: { environmentId: 'e-1' },
106
- run: () => sdk().test.dryRun({ applicationId: APP, functionId: FN }, { environmentId: 'e-1' }),
107
- },
108
- {
109
- label: 'version.list',
110
- method: 'get',
111
- url: `${BASE}/version`,
112
- run: () => sdk().version.list({ applicationId: APP, functionId: FN }),
113
- },
114
- {
115
- label: 'version.get',
116
- method: 'get',
117
- url: `${BASE}/version/v-1`,
118
- run: () => sdk().version.get({ applicationId: APP, functionId: FN, versionId: 'v-1' }),
119
- },
120
- {
121
- label: 'run.list',
122
- method: 'get',
123
- url: `${BASE}/run`,
124
- params: { limit: 5 },
125
- run: () => sdk().run.list({ applicationId: APP, functionId: FN }, { limit: 5 }),
126
- },
127
- {
128
- label: 'run.get',
129
- method: 'get',
130
- url: `${BASE}/run/r-1`,
131
- run: () => sdk().run.get({ applicationId: APP, functionId: FN, runId: 'r-1' }),
132
- },
133
- {
134
- label: 'run.state',
135
- method: 'get',
136
- url: `${BASE}/run/r-1/state`,
137
- run: () => sdk().run.state({ applicationId: APP, functionId: FN, runId: 'r-1' }),
138
- },
139
- {
140
- label: 'version.stepStats',
141
- method: 'get',
142
- url: `${BASE}/version/v-1/step-stats`,
143
- params: { environmentId: 'e-1' },
144
- run: () =>
145
- sdk().version.stepStats(
146
- { applicationId: APP, functionId: FN, versionId: 'v-1' },
147
- { environmentId: 'e-1' },
148
- ),
149
- },
150
- {
151
- label: 'settings.get',
152
- method: 'get',
153
- url: `${BASE}/settings`,
154
- run: () => sdk().settings.get({ applicationId: APP, functionId: FN }),
155
- },
156
- {
157
- label: 'settings.setDefault',
158
- method: 'put',
159
- url: `${BASE}/settings`,
160
- body: SETTINGS,
161
- run: () => sdk().settings.setDefault({ applicationId: APP, functionId: FN }, SETTINGS),
162
- },
163
- {
164
- label: 'settings.setEnvironment',
165
- method: 'put',
166
- url: `${BASE}/settings/e-1`,
167
- body: SETTINGS,
168
- run: () =>
169
- sdk().settings.setEnvironment(
170
- { applicationId: APP, functionId: FN, environmentId: 'e-1' },
171
- SETTINGS,
172
- ),
173
- },
174
- {
175
- label: 'settings.removeEnvironment',
176
- method: 'delete',
177
- url: `${BASE}/settings/e-1`,
178
- run: () =>
179
- sdk().settings.removeEnvironment({
180
- applicationId: APP,
181
- functionId: FN,
182
- environmentId: 'e-1',
183
- }),
184
- },
185
- ];
186
-
187
- describe('AbyssReflexCore function routes', () => {
188
- const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
189
- async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
190
- );
191
-
192
- beforeAll(() => {
193
- AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
194
- AbyssReflexCore.axios.defaults.adapter = adapter;
195
- });
196
-
197
- beforeEach(() => adapter.mockClear());
198
-
199
- it.each(calls)('$label calls $method $url', async (call) => {
200
- await call.run();
201
-
202
- const config = adapter.mock.calls[0][0];
203
- expect(config.method).toBe(call.method);
204
- expect(config.url).toBe(call.url);
205
- expect(config.baseURL).toBe('http://reflex.test/');
206
- expect(config.params).toEqual(call.params);
207
- if (call.body !== undefined) {
208
- expect(JSON.parse(config.data)).toEqual(call.body);
209
- }
210
- });
211
-
212
- it('sends the session token of the member as a bearer token', async () => {
213
- await calls[0].run();
214
-
215
- expect(adapter.mock.calls[0][0].headers.get('Authorization')).toBe('Bearer session-token');
216
- });
217
-
218
- it('exposes no route twice', () => {
219
- expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
220
- });
221
- });
222
-
223
- describe('execution settings constants', () => {
224
- it('give each profile its memory, S to XXL doubling from 128 MB', () => {
225
- expect(Object.values(ExecutionProfile)).toEqual(['S', 'M', 'L', 'XL', 'XXL']);
226
- expect(Object.values(ExecutionProfile).map((p) => EXECUTION_PROFILE_MEMORY_MB[p])).toEqual([
227
- 128, 256, 512, 1024, 2048,
228
- ]);
229
- });
230
-
231
- it('default to S, 30 s, 30 s and SYNC, within the bounds', () => {
232
- expect(DEFAULT_REFLEX_EXECUTION_SETTINGS).toEqual({
233
- profile: ExecutionProfile.S,
234
- responseTimeoutMs: 30_000,
235
- maxDurationMs: 30_000,
236
- mode: ExecutionMode.SYNC,
237
- });
238
- expect(REFLEX_EXECUTION_SETTINGS_LIMITS).toEqual({
239
- responseTimeoutMs: { min: 1_000, max: 100_000 },
240
- maxDurationMs: { min: 1_000, max: 3_600_000 },
241
- });
242
- });
243
- });
244
-
245
- describe('respond status bounds', () => {
246
- it('are 200 to 599, the bounds of the runtime', () => {
247
- expect([RESPOND_STATUS_MIN, RESPOND_STATUS_MAX]).toEqual([200, 599]);
248
- });
249
- });
1
+ import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
+ import {
3
+ AbyssReflexCore,
4
+ DEFAULT_REFLEX_EXECUTION_SETTINGS,
5
+ EXECUTION_PROFILE_MEMORY_MB,
6
+ ExecutionMode,
7
+ ExecutionProfile,
8
+ REFLEX_EXECUTION_SETTINGS_LIMITS,
9
+ RESPOND_STATUS_MAX,
10
+ RESPOND_STATUS_MIN,
11
+ } from '..';
12
+
13
+ const APP = 'app-1';
14
+ const FN = 'fn-1';
15
+ const BASE = `api/function/${APP}/${FN}`;
16
+ const SETTINGS = {
17
+ profile: ExecutionProfile.L,
18
+ responseTimeoutMs: 10_000,
19
+ maxDurationMs: 600_000,
20
+ mode: ExecutionMode.ASYNC,
21
+ };
22
+
23
+ interface Call {
24
+ label: string;
25
+ method: string;
26
+ url: string;
27
+ body?: unknown;
28
+ params?: unknown;
29
+ run: () => Promise<unknown>;
30
+ }
31
+
32
+ const sdk = () => AbyssReflexCore.sdk.function;
33
+
34
+ const calls: Call[] = [
35
+ {
36
+ label: 'list',
37
+ method: 'get',
38
+ url: `api/function/${APP}`,
39
+ run: () => sdk().list({ applicationId: APP }),
40
+ },
41
+ {
42
+ label: 'create',
43
+ method: 'post',
44
+ url: `api/function/${APP}`,
45
+ body: { name: 'hello', serviceId: 's-1' },
46
+ run: () => sdk().create({ applicationId: APP }, { name: 'hello', serviceId: 's-1' }),
47
+ },
48
+ {
49
+ label: 'get',
50
+ method: 'get',
51
+ url: BASE,
52
+ run: () => sdk().get({ applicationId: APP, functionId: FN }),
53
+ },
54
+ {
55
+ label: 'update',
56
+ method: 'put',
57
+ url: BASE,
58
+ body: { name: 'renamed' },
59
+ run: () => sdk().update({ applicationId: APP, functionId: FN }, { name: 'renamed' }),
60
+ },
61
+ {
62
+ label: 'delete',
63
+ method: 'delete',
64
+ url: BASE,
65
+ run: () => sdk().delete({ applicationId: APP, functionId: FN }),
66
+ },
67
+ {
68
+ label: 'access.list',
69
+ method: 'get',
70
+ url: `${BASE}/access`,
71
+ run: () => sdk().access.list({ applicationId: APP, functionId: FN }),
72
+ },
73
+ {
74
+ label: 'access.grant',
75
+ method: 'post',
76
+ url: `${BASE}/access`,
77
+ body: { declaration: { kind: 'HOST_ACTION', action: 'store.get' } },
78
+ run: () =>
79
+ sdk().access.grant(
80
+ { applicationId: APP, functionId: FN },
81
+ { declaration: { kind: 'HOST_ACTION', action: 'store.get' } as never },
82
+ ),
83
+ },
84
+ {
85
+ label: 'access.revoke',
86
+ method: 'delete',
87
+ url: `${BASE}/access/g-1`,
88
+ run: () => sdk().access.revoke({ applicationId: APP, functionId: FN, grantId: 'g-1' }),
89
+ },
90
+ {
91
+ label: 'test.simulate',
92
+ method: 'post',
93
+ url: `${BASE}/test/simulate`,
94
+ body: { environmentId: 'e-1', input: { a: 1 } },
95
+ run: () =>
96
+ sdk().test.simulate(
97
+ { applicationId: APP, functionId: FN },
98
+ { environmentId: 'e-1', input: { a: 1 } },
99
+ ),
100
+ },
101
+ {
102
+ label: 'test.dryRun',
103
+ method: 'post',
104
+ url: `${BASE}/test/dry-run`,
105
+ body: { environmentId: 'e-1' },
106
+ run: () => sdk().test.dryRun({ applicationId: APP, functionId: FN }, { environmentId: 'e-1' }),
107
+ },
108
+ {
109
+ label: 'version.list',
110
+ method: 'get',
111
+ url: `${BASE}/version`,
112
+ run: () => sdk().version.list({ applicationId: APP, functionId: FN }),
113
+ },
114
+ {
115
+ label: 'version.get',
116
+ method: 'get',
117
+ url: `${BASE}/version/v-1`,
118
+ run: () => sdk().version.get({ applicationId: APP, functionId: FN, versionId: 'v-1' }),
119
+ },
120
+ {
121
+ label: 'run.list',
122
+ method: 'get',
123
+ url: `${BASE}/run`,
124
+ params: { limit: 5 },
125
+ run: () => sdk().run.list({ applicationId: APP, functionId: FN }, { limit: 5 }),
126
+ },
127
+ {
128
+ label: 'run.get',
129
+ method: 'get',
130
+ url: `${BASE}/run/r-1`,
131
+ run: () => sdk().run.get({ applicationId: APP, functionId: FN, runId: 'r-1' }),
132
+ },
133
+ {
134
+ label: 'run.state',
135
+ method: 'get',
136
+ url: `${BASE}/run/r-1/state`,
137
+ run: () => sdk().run.state({ applicationId: APP, functionId: FN, runId: 'r-1' }),
138
+ },
139
+ {
140
+ label: 'version.stepStats',
141
+ method: 'get',
142
+ url: `${BASE}/version/v-1/step-stats`,
143
+ params: { environmentId: 'e-1' },
144
+ run: () =>
145
+ sdk().version.stepStats(
146
+ { applicationId: APP, functionId: FN, versionId: 'v-1' },
147
+ { environmentId: 'e-1' },
148
+ ),
149
+ },
150
+ {
151
+ label: 'settings.get',
152
+ method: 'get',
153
+ url: `${BASE}/settings`,
154
+ run: () => sdk().settings.get({ applicationId: APP, functionId: FN }),
155
+ },
156
+ {
157
+ label: 'settings.setDefault',
158
+ method: 'put',
159
+ url: `${BASE}/settings`,
160
+ body: SETTINGS,
161
+ run: () => sdk().settings.setDefault({ applicationId: APP, functionId: FN }, SETTINGS),
162
+ },
163
+ {
164
+ label: 'settings.setEnvironment',
165
+ method: 'put',
166
+ url: `${BASE}/settings/e-1`,
167
+ body: SETTINGS,
168
+ run: () =>
169
+ sdk().settings.setEnvironment(
170
+ { applicationId: APP, functionId: FN, environmentId: 'e-1' },
171
+ SETTINGS,
172
+ ),
173
+ },
174
+ {
175
+ label: 'settings.removeEnvironment',
176
+ method: 'delete',
177
+ url: `${BASE}/settings/e-1`,
178
+ run: () =>
179
+ sdk().settings.removeEnvironment({
180
+ applicationId: APP,
181
+ functionId: FN,
182
+ environmentId: 'e-1',
183
+ }),
184
+ },
185
+ ];
186
+
187
+ describe('AbyssReflexCore function routes', () => {
188
+ const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
189
+ async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
190
+ );
191
+
192
+ beforeAll(() => {
193
+ AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
194
+ AbyssReflexCore.axios.defaults.adapter = adapter;
195
+ });
196
+
197
+ beforeEach(() => adapter.mockClear());
198
+
199
+ it.each(calls)('$label calls $method $url', async (call) => {
200
+ await call.run();
201
+
202
+ const config = adapter.mock.calls[0][0];
203
+ expect(config.method).toBe(call.method);
204
+ expect(config.url).toBe(call.url);
205
+ expect(config.baseURL).toBe('http://reflex.test/');
206
+ expect(config.params).toEqual(call.params);
207
+ if (call.body !== undefined) {
208
+ expect(JSON.parse(config.data)).toEqual(call.body);
209
+ }
210
+ });
211
+
212
+ it('sends the session token of the member as a bearer token', async () => {
213
+ await calls[0].run();
214
+
215
+ expect(adapter.mock.calls[0][0].headers.get('Authorization')).toBe('Bearer session-token');
216
+ });
217
+
218
+ it('exposes no route twice', () => {
219
+ expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
220
+ });
221
+ });
222
+
223
+ describe('execution settings constants', () => {
224
+ it('give each profile its memory, S to XXL doubling from 128 MB', () => {
225
+ expect(Object.values(ExecutionProfile)).toEqual(['S', 'M', 'L', 'XL', 'XXL']);
226
+ expect(Object.values(ExecutionProfile).map((p) => EXECUTION_PROFILE_MEMORY_MB[p])).toEqual([
227
+ 128, 256, 512, 1024, 2048,
228
+ ]);
229
+ });
230
+
231
+ it('default to S, 30 s, 30 s and SYNC, within the bounds', () => {
232
+ expect(DEFAULT_REFLEX_EXECUTION_SETTINGS).toEqual({
233
+ profile: ExecutionProfile.S,
234
+ responseTimeoutMs: 30_000,
235
+ maxDurationMs: 30_000,
236
+ mode: ExecutionMode.SYNC,
237
+ });
238
+ expect(REFLEX_EXECUTION_SETTINGS_LIMITS).toEqual({
239
+ responseTimeoutMs: { min: 1_000, max: 100_000 },
240
+ maxDurationMs: { min: 1_000, max: 3_600_000 },
241
+ });
242
+ });
243
+ });
244
+
245
+ describe('respond status bounds', () => {
246
+ it('are 200 to 599, the bounds of the runtime', () => {
247
+ expect([RESPOND_STATUS_MIN, RESPOND_STATUS_MAX]).toEqual([200, 599]);
248
+ });
249
+ });
@@ -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;