@abyss-project/reflex 5.0.0 → 5.2.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 (58) hide show
  1. package/dist/api/service-version.api.d.ts +2 -1
  2. package/dist/api/service-version.api.js +3 -1
  3. package/dist/api/service-version.api.js.map +1 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +1 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/types/enum/discord-activity-type.enum.d.ts +7 -0
  8. package/dist/types/enum/discord-activity-type.enum.js +12 -0
  9. package/dist/types/enum/discord-activity-type.enum.js.map +1 -0
  10. package/dist/types/enum/discord-gateway-failure-code.enum.d.ts +5 -0
  11. package/dist/types/enum/discord-gateway-failure-code.enum.js +10 -0
  12. package/dist/types/enum/discord-gateway-failure-code.enum.js.map +1 -0
  13. package/dist/types/enum/discord-gateway-state.enum.d.ts +6 -0
  14. package/dist/types/enum/discord-gateway-state.enum.js +11 -0
  15. package/dist/types/enum/discord-gateway-state.enum.js.map +1 -0
  16. package/dist/types/enum/discord-presence-status.enum.d.ts +5 -0
  17. package/dist/types/enum/discord-presence-status.enum.js +10 -0
  18. package/dist/types/enum/discord-presence-status.enum.js.map +1 -0
  19. package/dist/types/enum/index.d.ts +4 -0
  20. package/dist/types/enum/index.js +4 -0
  21. package/dist/types/enum/index.js.map +1 -1
  22. package/dist/types/interface/api/requests/service-discord.request.d.ts +4 -1
  23. package/dist/types/interface/api/requests/service-version.request.d.ts +4 -0
  24. package/dist/types/interface/api/responses/service-version.response.d.ts +4 -0
  25. package/dist/types/interface/models/reflex-discord.model.d.ts +14 -1
  26. package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/api/function-access.api.ts +36 -36
  29. package/src/api/function-run.api.ts +38 -38
  30. package/src/api/function-settings.api.ts +59 -59
  31. package/src/api/function-test.api.ts +34 -34
  32. package/src/api/function-version.api.ts +48 -48
  33. package/src/api/function.api.test.ts +249 -249
  34. package/src/api/function.api.ts +62 -62
  35. package/src/api/health.api.ts +10 -10
  36. package/src/api/index.ts +13 -13
  37. package/src/api/service-configuration.api.ts +16 -16
  38. package/src/api/service-deployment.api.ts +79 -79
  39. package/src/api/service-route.api.ts +72 -72
  40. package/src/api/service-version.api.ts +54 -39
  41. package/src/api/service.api.test.ts +215 -209
  42. package/src/api/service.api.ts +55 -55
  43. package/src/index.ts +2 -0
  44. package/src/types/enum/discord-activity-type.enum.ts +9 -0
  45. package/src/types/enum/discord-component-kind.enum.ts +7 -7
  46. package/src/types/enum/discord-gateway-failure-code.enum.ts +9 -0
  47. package/src/types/enum/discord-gateway-state.enum.ts +11 -0
  48. package/src/types/enum/discord-option-type.enum.ts +12 -12
  49. package/src/types/enum/discord-presence-status.enum.ts +8 -0
  50. package/src/types/enum/discord-sync-status.enum.ts +6 -6
  51. package/src/types/enum/discord-token-state.enum.ts +11 -11
  52. package/src/types/enum/index.ts +4 -0
  53. package/src/types/interface/api/requests/service-discord.request.ts +128 -118
  54. package/src/types/interface/api/requests/service-version.request.ts +24 -19
  55. package/src/types/interface/api/responses/service-discord.response.ts +72 -72
  56. package/src/types/interface/api/responses/service-version.response.ts +11 -0
  57. package/src/types/interface/models/reflex-discord.model.ts +146 -117
  58. package/src/types/interface/models/reflex-run.model.ts +173 -173
@@ -1,48 +1,48 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IGetFunctionVersionParams,
4
- IGetFunctionVersionResponse,
5
- IGetFunctionVersionStepStatsParams,
6
- IGetFunctionVersionStepStatsQuery,
7
- IGetFunctionVersionStepStatsResponse,
8
- IListFunctionVersionParams,
9
- IListFunctionVersionResponse,
10
- } from '../types';
11
-
12
- const versionUrl = (params: { applicationId: string; functionId: string }): string =>
13
- `api/function/${params.applicationId}/${params.functionId}/version`;
14
-
15
- /**
16
- * `GET .../version`: the frozen versions, newest first. Needs REFLEX_READ. A version of the function's
17
- * Service publishes its draft when it changed (`service.version.create`).
18
- */
19
- export const listFunctionVersion = async (
20
- params: IListFunctionVersionParams,
21
- ): Promise<IListFunctionVersionResponse> =>
22
- (await AbyssReflexCore.axios.get<IListFunctionVersionResponse>(versionUrl(params))).data;
23
-
24
- /** `GET .../version/:versionId`. Needs REFLEX_READ. */
25
- export const getFunctionVersion = async (
26
- params: IGetFunctionVersionParams,
27
- ): Promise<IGetFunctionVersionResponse> =>
28
- (
29
- await AbyssReflexCore.axios.get<IGetFunctionVersionResponse>(
30
- `${versionUrl(params)}/${params.versionId}`,
31
- )
32
- ).data;
33
-
34
- /**
35
- * `GET .../version/:versionId/step-stats`: per step, over the retention window, the executions, the median
36
- * and p95 of duration, CPU, heap peak and cost, and the share of the cost; interrupted executions left
37
- * out. With `environmentId`, also the p99 heap peak per step of the version running there. Needs REFLEX_LOG_READ.
38
- */
39
- export const getFunctionVersionStepStats = async (
40
- params: IGetFunctionVersionStepStatsParams,
41
- query: IGetFunctionVersionStepStatsQuery = {},
42
- ): Promise<IGetFunctionVersionStepStatsResponse> =>
43
- (
44
- await AbyssReflexCore.axios.get<IGetFunctionVersionStepStatsResponse>(
45
- `${versionUrl(params)}/${params.versionId}/step-stats`,
46
- { params: query },
47
- )
48
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IGetFunctionVersionParams,
4
+ IGetFunctionVersionResponse,
5
+ IGetFunctionVersionStepStatsParams,
6
+ IGetFunctionVersionStepStatsQuery,
7
+ IGetFunctionVersionStepStatsResponse,
8
+ IListFunctionVersionParams,
9
+ IListFunctionVersionResponse,
10
+ } from '../types';
11
+
12
+ const versionUrl = (params: { applicationId: string; functionId: string }): string =>
13
+ `api/function/${params.applicationId}/${params.functionId}/version`;
14
+
15
+ /**
16
+ * `GET .../version`: the frozen versions, newest first. Needs REFLEX_READ. A version of the function's
17
+ * Service publishes its draft when it changed (`service.version.create`).
18
+ */
19
+ export const listFunctionVersion = async (
20
+ params: IListFunctionVersionParams,
21
+ ): Promise<IListFunctionVersionResponse> =>
22
+ (await AbyssReflexCore.axios.get<IListFunctionVersionResponse>(versionUrl(params))).data;
23
+
24
+ /** `GET .../version/:versionId`. Needs REFLEX_READ. */
25
+ export const getFunctionVersion = async (
26
+ params: IGetFunctionVersionParams,
27
+ ): Promise<IGetFunctionVersionResponse> =>
28
+ (
29
+ await AbyssReflexCore.axios.get<IGetFunctionVersionResponse>(
30
+ `${versionUrl(params)}/${params.versionId}`,
31
+ )
32
+ ).data;
33
+
34
+ /**
35
+ * `GET .../version/:versionId/step-stats`: per step, over the retention window, the executions, the median
36
+ * and p95 of duration, CPU, heap peak and cost, and the share of the cost; interrupted executions left
37
+ * out. With `environmentId`, also the p99 heap peak per step of the version running there. Needs REFLEX_LOG_READ.
38
+ */
39
+ export const getFunctionVersionStepStats = async (
40
+ params: IGetFunctionVersionStepStatsParams,
41
+ query: IGetFunctionVersionStepStatsQuery = {},
42
+ ): Promise<IGetFunctionVersionStepStatsResponse> =>
43
+ (
44
+ await AbyssReflexCore.axios.get<IGetFunctionVersionStepStatsResponse>(
45
+ `${versionUrl(params)}/${params.versionId}/step-stats`,
46
+ { params: query },
47
+ )
48
+ ).data;
@@ -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
+ });