@abyss-project/reflex 5.2.0 → 5.4.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 (91) hide show
  1. package/dist/api/index.d.ts +1 -0
  2. package/dist/api/index.js +1 -0
  3. package/dist/api/index.js.map +1 -1
  4. package/dist/api/service-task.api.d.ts +10 -0
  5. package/dist/api/service-task.api.js +26 -0
  6. package/dist/api/service-task.api.js.map +1 -0
  7. package/dist/index.d.ts +16 -0
  8. package/dist/index.js +16 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/types/enum/index.d.ts +4 -0
  11. package/dist/types/enum/index.js +4 -0
  12. package/dist/types/enum/index.js.map +1 -1
  13. package/dist/types/enum/reflex-error-code.enum.d.ts +2 -1
  14. package/dist/types/enum/reflex-error-code.enum.js +1 -0
  15. package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
  16. package/dist/types/enum/schedule-sync-status.enum.d.ts +5 -0
  17. package/dist/types/enum/schedule-sync-status.enum.js +10 -0
  18. package/dist/types/enum/schedule-sync-status.enum.js.map +1 -0
  19. package/dist/types/enum/scheduled-run-failure-code.enum.d.ts +4 -0
  20. package/dist/types/enum/scheduled-run-failure-code.enum.js +9 -0
  21. package/dist/types/enum/scheduled-run-failure-code.enum.js.map +1 -0
  22. package/dist/types/enum/scheduled-run-origin.enum.d.ts +4 -0
  23. package/dist/types/enum/scheduled-run-origin.enum.js +9 -0
  24. package/dist/types/enum/scheduled-run-origin.enum.js.map +1 -0
  25. package/dist/types/enum/scheduled-run-status.enum.d.ts +9 -0
  26. package/dist/types/enum/scheduled-run-status.enum.js +14 -0
  27. package/dist/types/enum/scheduled-run-status.enum.js.map +1 -0
  28. package/dist/types/interface/api/requests/function-run.request.d.ts +2 -0
  29. package/dist/types/interface/api/requests/function-test.request.d.ts +4 -0
  30. package/dist/types/interface/api/requests/index.d.ts +1 -0
  31. package/dist/types/interface/api/requests/index.js +1 -0
  32. package/dist/types/interface/api/requests/index.js.map +1 -1
  33. package/dist/types/interface/api/requests/service-task.request.d.ts +64 -0
  34. package/dist/types/interface/api/requests/service-task.request.js +3 -0
  35. package/dist/types/interface/api/requests/service-task.request.js.map +1 -0
  36. package/dist/types/interface/api/responses/index.d.ts +1 -0
  37. package/dist/types/interface/api/responses/index.js +1 -0
  38. package/dist/types/interface/api/responses/index.js.map +1 -1
  39. package/dist/types/interface/api/responses/service-task.response.d.ts +36 -0
  40. package/dist/types/interface/api/responses/service-task.response.js +3 -0
  41. package/dist/types/interface/api/responses/service-task.response.js.map +1 -0
  42. package/dist/types/interface/api/responses/service-version.response.d.ts +9 -1
  43. package/dist/types/interface/models/index.d.ts +1 -0
  44. package/dist/types/interface/models/index.js +1 -0
  45. package/dist/types/interface/models/index.js.map +1 -1
  46. package/dist/types/interface/models/reflex-run.model.d.ts +3 -1
  47. package/dist/types/interface/models/reflex-service-deployment.model.d.ts +4 -1
  48. package/dist/types/interface/models/reflex-service-version.model.d.ts +2 -0
  49. package/dist/types/interface/models/reflex-task.model.d.ts +48 -0
  50. package/dist/types/interface/models/reflex-task.model.js +16 -0
  51. package/dist/types/interface/models/reflex-task.model.js.map +1 -0
  52. package/package.json +1 -1
  53. package/src/api/function-access.api.ts +36 -36
  54. package/src/api/function-run.api.ts +38 -38
  55. package/src/api/function-settings.api.ts +59 -59
  56. package/src/api/function-test.api.ts +34 -34
  57. package/src/api/function-version.api.ts +48 -48
  58. package/src/api/function.api.test.ts +249 -249
  59. package/src/api/function.api.ts +62 -62
  60. package/src/api/health.api.ts +10 -10
  61. package/src/api/index.ts +14 -13
  62. package/src/api/service-configuration.api.ts +16 -16
  63. package/src/api/service-deployment.api.ts +79 -79
  64. package/src/api/service-discord.api.test.ts +170 -170
  65. package/src/api/service-discord.api.ts +203 -203
  66. package/src/api/service-route.api.ts +72 -72
  67. package/src/api/service-task.api.test.ts +140 -0
  68. package/src/api/service-task.api.ts +141 -0
  69. package/src/api/service-version.api.ts +54 -54
  70. package/src/api/service.api.test.ts +215 -215
  71. package/src/api/service.api.ts +55 -55
  72. package/src/index.ts +34 -0
  73. package/src/types/enum/index.ts +33 -29
  74. package/src/types/enum/reflex-error-code.enum.ts +2 -0
  75. package/src/types/enum/schedule-sync-status.enum.ts +6 -0
  76. package/src/types/enum/scheduled-run-failure-code.enum.ts +10 -0
  77. package/src/types/enum/scheduled-run-origin.enum.ts +5 -0
  78. package/src/types/enum/scheduled-run-status.enum.ts +17 -0
  79. package/src/types/interface/api/requests/function-run.request.ts +4 -0
  80. package/src/types/interface/api/requests/function-test.request.ts +16 -1
  81. package/src/types/interface/api/requests/index.ts +1 -0
  82. package/src/types/interface/api/requests/service-task.request.ts +80 -0
  83. package/src/types/interface/api/requests/service-version.request.ts +24 -24
  84. package/src/types/interface/api/responses/index.ts +1 -0
  85. package/src/types/interface/api/responses/service-task.response.ts +57 -0
  86. package/src/types/interface/api/responses/service-version.response.ts +91 -73
  87. package/src/types/interface/models/index.ts +1 -0
  88. package/src/types/interface/models/reflex-run.model.ts +7 -1
  89. package/src/types/interface/models/reflex-service-deployment.model.ts +6 -0
  90. package/src/types/interface/models/reflex-service-version.model.ts +3 -0
  91. package/src/types/interface/models/reflex-task.model.ts +97 -0
@@ -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;
package/src/api/index.ts CHANGED
@@ -1,13 +1,14 @@
1
- export * from './health.api';
2
- export * from './function.api';
3
- export * from './function-access.api';
4
- export * from './function-test.api';
5
- export * from './function-version.api';
6
- export * from './function-run.api';
7
- export * from './function-settings.api';
8
- export * from './service.api';
9
- export * from './service-route.api';
10
- export * from './service-version.api';
11
- export * from './service-deployment.api';
12
- export * from './service-configuration.api';
13
- export * from './service-discord.api';
1
+ export * from './health.api';
2
+ export * from './function.api';
3
+ export * from './function-access.api';
4
+ export * from './function-test.api';
5
+ export * from './function-version.api';
6
+ export * from './function-run.api';
7
+ export * from './function-settings.api';
8
+ export * from './service.api';
9
+ export * from './service-route.api';
10
+ export * from './service-version.api';
11
+ export * from './service-deployment.api';
12
+ export * from './service-configuration.api';
13
+ export * from './service-discord.api';
14
+ export * from './service-task.api';