@abyss-project/reflex 6.3.0 → 6.6.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.
- package/.prettierrc +5 -5
- package/dist/api/function-run.api.d.ts +3 -1
- package/dist/api/function-run.api.js +5 -1
- package/dist/api/function-run.api.js.map +1 -1
- package/dist/api/function-settings.api.d.ts +3 -1
- package/dist/api/function-settings.api.js +7 -1
- package/dist/api/function-settings.api.js.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/storage-surplus.admin.api.d.ts +5 -0
- package/dist/api/storage-surplus.admin.api.js +17 -0
- package/dist/api/storage-surplus.admin.api.js.map +1 -0
- package/dist/discord/discord-command-tree.d.ts +5 -0
- package/dist/discord/discord-command-tree.js +38 -0
- package/dist/discord/discord-command-tree.js.map +1 -0
- package/dist/discord/discord-event-filter-cases.js +27 -11
- package/dist/discord/discord-event-filter-cases.js.map +1 -1
- package/dist/discord/discord-event-filters.js +7 -3
- package/dist/discord/discord-event-filters.js.map +1 -1
- package/dist/discord/discord-event-intents.d.ts +8 -2
- package/dist/discord/discord-event-intents.js +13 -2
- package/dist/discord/discord-event-intents.js.map +1 -1
- package/dist/discord/index.d.ts +1 -0
- package/dist/discord/index.js +1 -0
- package/dist/discord/index.js.map +1 -1
- package/dist/index.d.ts +17 -0
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/dist/types/enum/discord-command-node-type.enum.d.ts +5 -0
- package/dist/types/enum/discord-command-node-type.enum.js +10 -0
- package/dist/types/enum/discord-command-node-type.enum.js.map +1 -0
- package/dist/types/enum/discord-command-type.enum.d.ts +5 -0
- package/dist/types/enum/discord-command-type.enum.js +10 -0
- package/dist/types/enum/discord-command-type.enum.js.map +1 -0
- package/dist/types/enum/discord-event-type.enum.d.ts +3 -1
- package/dist/types/enum/discord-event-type.enum.js +2 -0
- package/dist/types/enum/discord-event-type.enum.js.map +1 -1
- package/dist/types/enum/index.d.ts +2 -0
- package/dist/types/enum/index.js +2 -0
- package/dist/types/enum/index.js.map +1 -1
- package/dist/types/enum/reflex-error-code.enum.d.ts +14 -1
- package/dist/types/enum/reflex-error-code.enum.js +13 -0
- package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
- package/dist/types/interface/api/requests/application-run-settings.request.d.ts +1 -0
- package/dist/types/interface/api/requests/function-run.request.d.ts +16 -0
- package/dist/types/interface/api/requests/function-settings.request.d.ts +12 -0
- package/dist/types/interface/api/requests/index.d.ts +1 -0
- package/dist/types/interface/api/requests/index.js +1 -0
- package/dist/types/interface/api/requests/index.js.map +1 -1
- package/dist/types/interface/api/requests/service-discord.request.d.ts +7 -3
- package/dist/types/interface/api/requests/service.request.d.ts +1 -0
- package/dist/types/interface/api/requests/storage-surplus.admin.request.d.ts +8 -0
- package/dist/types/interface/api/requests/storage-surplus.admin.request.js +3 -0
- package/dist/types/interface/api/requests/storage-surplus.admin.request.js.map +1 -0
- package/dist/types/interface/api/responses/function-run.response.d.ts +12 -0
- package/dist/types/interface/api/responses/function-settings.response.d.ts +5 -1
- package/dist/types/interface/api/responses/index.d.ts +1 -0
- package/dist/types/interface/api/responses/index.js +1 -0
- package/dist/types/interface/api/responses/index.js.map +1 -1
- package/dist/types/interface/api/responses/storage-surplus.admin.response.d.ts +8 -0
- package/dist/types/interface/api/responses/storage-surplus.admin.response.js +3 -0
- package/dist/types/interface/api/responses/storage-surplus.admin.response.js.map +1 -0
- package/dist/types/interface/models/index.d.ts +2 -0
- package/dist/types/interface/models/index.js +2 -0
- package/dist/types/interface/models/index.js.map +1 -1
- package/dist/types/interface/models/reflex-discord.model.d.ts +18 -2
- package/dist/types/interface/models/reflex-discord.model.js +4 -0
- package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
- package/dist/types/interface/models/reflex-run-retention.model.d.ts +13 -0
- package/dist/types/interface/models/reflex-run-retention.model.js +8 -0
- package/dist/types/interface/models/reflex-run-retention.model.js.map +1 -0
- package/dist/types/interface/models/reflex-run-settings.model.d.ts +4 -0
- package/dist/types/interface/models/reflex-run.model.d.ts +9 -0
- package/dist/types/interface/models/reflex-run.model.js +4 -1
- package/dist/types/interface/models/reflex-run.model.js.map +1 -1
- package/dist/types/interface/models/reflex-service-deployment.model.d.ts +2 -2
- package/dist/types/interface/models/reflex-service.model.d.ts +1 -0
- package/dist/types/interface/models/reflex-storage-surplus.model.d.ts +11 -0
- package/dist/types/interface/models/reflex-storage-surplus.model.js +3 -0
- package/dist/types/interface/models/reflex-storage-surplus.model.js.map +1 -0
- package/package.json +1 -1
- package/src/api/application-run-settings.api.test.ts +62 -51
- package/src/api/function-run.api.ts +34 -0
- package/src/api/function-settings.api.ts +96 -74
- package/src/api/function.api.test.ts +346 -291
- package/src/api/index.ts +27 -26
- package/src/api/service.api.test.ts +220 -215
- package/src/api/storage-surplus.admin.api.test.ts +66 -0
- package/src/api/storage-surplus.admin.api.ts +45 -0
- package/src/discord/discord-command-tree.test.ts +47 -0
- package/src/discord/discord-command-tree.ts +60 -0
- package/src/discord/discord-event-filter-cases.ts +54 -16
- package/src/discord/discord-event-filters.test.ts +33 -4
- package/src/discord/discord-event-filters.ts +13 -5
- package/src/discord/discord-event-intents.test.ts +27 -0
- package/src/discord/discord-event-intents.ts +31 -6
- package/src/discord/index.ts +1 -0
- package/src/index.ts +44 -0
- package/src/types/enum/discord-command-node-type.enum.ts +10 -0
- package/src/types/enum/discord-command-type.enum.ts +9 -0
- package/src/types/enum/discord-event-type.enum.ts +4 -0
- package/src/types/enum/index.ts +2 -0
- package/src/types/enum/reflex-error-code.enum.ts +112 -73
- package/src/types/interface/api/requests/application-run-settings.request.ts +13 -11
- package/src/types/interface/api/requests/function-run.request.ts +53 -32
- package/src/types/interface/api/requests/function-settings.request.ts +50 -34
- package/src/types/interface/api/requests/index.ts +25 -24
- package/src/types/interface/api/requests/service-discord.request.ts +19 -6
- package/src/types/interface/api/requests/service.request.ts +48 -46
- package/src/types/interface/api/requests/storage-surplus.admin.request.ts +12 -0
- package/src/types/interface/api/responses/function-run.response.ts +35 -18
- package/src/types/interface/api/responses/function-settings.response.ts +57 -50
- package/src/types/interface/api/responses/index.ts +25 -24
- package/src/types/interface/api/responses/storage-surplus.admin.response.ts +10 -0
- package/src/types/interface/models/index.ts +29 -27
- package/src/types/interface/models/reflex-discord.model.ts +45 -4
- package/src/types/interface/models/reflex-run-retention.model.ts +24 -0
- package/src/types/interface/models/reflex-run-settings.model.ts +39 -28
- package/src/types/interface/models/reflex-run.model.ts +317 -299
- package/src/types/interface/models/reflex-service-deployment.model.ts +48 -46
- package/src/types/interface/models/reflex-service.model.ts +47 -45
- package/src/types/interface/models/reflex-storage-surplus.model.ts +23 -0
|
@@ -1,291 +1,346 @@
|
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
expect(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
expect([
|
|
290
|
-
});
|
|
291
|
-
|
|
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
|
+
REFLEX_RUN_ARCHIVE_AFTER_DAYS,
|
|
12
|
+
REFLEX_RUN_ARCHIVE_MIN_TIER_DAYS,
|
|
13
|
+
REFLEX_RUN_RETENTION_TIER_DAYS,
|
|
14
|
+
REFLEX_VERSIONS_KEPT,
|
|
15
|
+
ReflexErrorCode,
|
|
16
|
+
} from '..';
|
|
17
|
+
|
|
18
|
+
const APP = 'app-1';
|
|
19
|
+
const FN = 'fn-1';
|
|
20
|
+
const BASE = `api/function/${APP}/${FN}`;
|
|
21
|
+
const SETTINGS = {
|
|
22
|
+
profile: ExecutionProfile.L,
|
|
23
|
+
responseTimeoutMs: 10_000,
|
|
24
|
+
maxDurationMs: 600_000,
|
|
25
|
+
mode: ExecutionMode.ASYNC,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
interface Call {
|
|
29
|
+
label: string;
|
|
30
|
+
method: string;
|
|
31
|
+
url: string;
|
|
32
|
+
body?: unknown;
|
|
33
|
+
params?: unknown;
|
|
34
|
+
run: () => Promise<unknown>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const sdk = () => AbyssReflexCore.sdk.function;
|
|
38
|
+
|
|
39
|
+
const calls: Call[] = [
|
|
40
|
+
{
|
|
41
|
+
label: 'list',
|
|
42
|
+
method: 'get',
|
|
43
|
+
url: `api/function/${APP}`,
|
|
44
|
+
run: () => sdk().list({ applicationId: APP }),
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: 'create',
|
|
48
|
+
method: 'post',
|
|
49
|
+
url: `api/function/${APP}`,
|
|
50
|
+
body: { name: 'hello', serviceId: 's-1' },
|
|
51
|
+
run: () => sdk().create({ applicationId: APP }, { name: 'hello', serviceId: 's-1' }),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label: 'get',
|
|
55
|
+
method: 'get',
|
|
56
|
+
url: BASE,
|
|
57
|
+
run: () => sdk().get({ applicationId: APP, functionId: FN }),
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: 'update',
|
|
61
|
+
method: 'put',
|
|
62
|
+
url: BASE,
|
|
63
|
+
body: { name: 'renamed' },
|
|
64
|
+
run: () => sdk().update({ applicationId: APP, functionId: FN }, { name: 'renamed' }),
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
label: 'delete',
|
|
68
|
+
method: 'delete',
|
|
69
|
+
url: BASE,
|
|
70
|
+
run: () => sdk().delete({ applicationId: APP, functionId: FN }),
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
label: 'access.list',
|
|
74
|
+
method: 'get',
|
|
75
|
+
url: `${BASE}/access`,
|
|
76
|
+
run: () => sdk().access.list({ applicationId: APP, functionId: FN }),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
label: 'access.grant',
|
|
80
|
+
method: 'post',
|
|
81
|
+
url: `${BASE}/access`,
|
|
82
|
+
body: { declaration: { kind: 'HOST_ACTION', action: 'store.get' } },
|
|
83
|
+
run: () =>
|
|
84
|
+
sdk().access.grant(
|
|
85
|
+
{ applicationId: APP, functionId: FN },
|
|
86
|
+
{ declaration: { kind: 'HOST_ACTION', action: 'store.get' } as never },
|
|
87
|
+
),
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
label: 'access.revoke',
|
|
91
|
+
method: 'delete',
|
|
92
|
+
url: `${BASE}/access/g-1`,
|
|
93
|
+
run: () => sdk().access.revoke({ applicationId: APP, functionId: FN, grantId: 'g-1' }),
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
label: 'access.grantAll',
|
|
97
|
+
method: 'post',
|
|
98
|
+
url: `${BASE}/access/grant-all`,
|
|
99
|
+
run: () => sdk().access.grantAll({ applicationId: APP, functionId: FN }),
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
label: 'access.request',
|
|
103
|
+
method: 'post',
|
|
104
|
+
url: `${BASE}/access/request`,
|
|
105
|
+
body: { declaration: { kind: 'HOST_ACTION', action: 'store.get' } },
|
|
106
|
+
run: () =>
|
|
107
|
+
sdk().access.request(
|
|
108
|
+
{ applicationId: APP, functionId: FN },
|
|
109
|
+
{ declaration: { kind: 'HOST_ACTION', action: 'store.get' } as never },
|
|
110
|
+
),
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
label: 'access.grantRequest',
|
|
114
|
+
method: 'post',
|
|
115
|
+
url: `${BASE}/access/request/q-1/grant`,
|
|
116
|
+
run: () => sdk().access.grantRequest({ applicationId: APP, functionId: FN, requestId: 'q-1' }),
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
label: 'access.dismissRequest',
|
|
120
|
+
method: 'post',
|
|
121
|
+
url: `${BASE}/access/request/q-1/dismiss`,
|
|
122
|
+
run: () =>
|
|
123
|
+
sdk().access.dismissRequest({ applicationId: APP, functionId: FN, requestId: 'q-1' }),
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
label: 'version.list',
|
|
127
|
+
method: 'get',
|
|
128
|
+
url: `${BASE}/version`,
|
|
129
|
+
params: { page: 2, limit: 20, number: 3, publishedByUserId: 'u-1', deployed: true },
|
|
130
|
+
run: () =>
|
|
131
|
+
sdk().version.list(
|
|
132
|
+
{ applicationId: APP, functionId: FN },
|
|
133
|
+
{ page: 2, limit: 20, number: 3, publishedByUserId: 'u-1', deployed: true },
|
|
134
|
+
),
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
label: 'version.open',
|
|
138
|
+
method: 'post',
|
|
139
|
+
url: `${BASE}/version/v-1/open`,
|
|
140
|
+
run: () => sdk().version.open({ applicationId: APP, functionId: FN, versionId: 'v-1' }),
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
label: 'test.simulate',
|
|
144
|
+
method: 'post',
|
|
145
|
+
url: `${BASE}/test/simulate`,
|
|
146
|
+
body: { environmentId: 'e-1', input: { a: 1 } },
|
|
147
|
+
run: () =>
|
|
148
|
+
sdk().test.simulate(
|
|
149
|
+
{ applicationId: APP, functionId: FN },
|
|
150
|
+
{ environmentId: 'e-1', input: { a: 1 } },
|
|
151
|
+
),
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
label: 'test.dryRun',
|
|
155
|
+
method: 'post',
|
|
156
|
+
url: `${BASE}/test/dry-run`,
|
|
157
|
+
body: { environmentId: 'e-1' },
|
|
158
|
+
run: () => sdk().test.dryRun({ applicationId: APP, functionId: FN }, { environmentId: 'e-1' }),
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
label: 'version.get',
|
|
162
|
+
method: 'get',
|
|
163
|
+
url: `${BASE}/version/v-1`,
|
|
164
|
+
run: () => sdk().version.get({ applicationId: APP, functionId: FN, versionId: 'v-1' }),
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
label: 'run.list',
|
|
168
|
+
method: 'get',
|
|
169
|
+
url: `${BASE}/run`,
|
|
170
|
+
params: { limit: 5 },
|
|
171
|
+
run: () => sdk().run.list({ applicationId: APP, functionId: FN }, { limit: 5 }),
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
label: 'run.get',
|
|
175
|
+
method: 'get',
|
|
176
|
+
url: `${BASE}/run/r-1`,
|
|
177
|
+
run: () => sdk().run.get({ applicationId: APP, functionId: FN, runId: 'r-1' }),
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
label: 'run.state',
|
|
181
|
+
method: 'get',
|
|
182
|
+
url: `${BASE}/run/r-1/state`,
|
|
183
|
+
run: () => sdk().run.state({ applicationId: APP, functionId: FN, runId: 'r-1' }),
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
label: 'run.favorite',
|
|
187
|
+
method: 'put',
|
|
188
|
+
url: `${BASE}/run/r-1/favorite`,
|
|
189
|
+
body: { isFavorite: true },
|
|
190
|
+
run: () =>
|
|
191
|
+
sdk().run.favorite(
|
|
192
|
+
{ applicationId: APP, functionId: FN, runId: 'r-1' },
|
|
193
|
+
{ isFavorite: true },
|
|
194
|
+
),
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
label: 'runRetention.get',
|
|
198
|
+
method: 'get',
|
|
199
|
+
url: `${BASE}/run-retention`,
|
|
200
|
+
run: () => sdk().runRetention.get({ applicationId: APP, functionId: FN }),
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
label: 'runRetention.set',
|
|
204
|
+
method: 'put',
|
|
205
|
+
url: `${BASE}/run-retention`,
|
|
206
|
+
body: { runRetentionDays: 90, versionsKept: 30 },
|
|
207
|
+
run: () =>
|
|
208
|
+
sdk().runRetention.set(
|
|
209
|
+
{ applicationId: APP, functionId: FN },
|
|
210
|
+
{ runRetentionDays: 90, versionsKept: 30 },
|
|
211
|
+
),
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
label: 'version.stepStats',
|
|
215
|
+
method: 'get',
|
|
216
|
+
url: `${BASE}/version/v-1/step-stats`,
|
|
217
|
+
params: { environmentId: 'e-1' },
|
|
218
|
+
run: () =>
|
|
219
|
+
sdk().version.stepStats(
|
|
220
|
+
{ applicationId: APP, functionId: FN, versionId: 'v-1' },
|
|
221
|
+
{ environmentId: 'e-1' },
|
|
222
|
+
),
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
label: 'settings.get',
|
|
226
|
+
method: 'get',
|
|
227
|
+
url: `${BASE}/settings`,
|
|
228
|
+
run: () => sdk().settings.get({ applicationId: APP, functionId: FN }),
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
label: 'settings.setDefault',
|
|
232
|
+
method: 'put',
|
|
233
|
+
url: `${BASE}/settings`,
|
|
234
|
+
body: SETTINGS,
|
|
235
|
+
run: () => sdk().settings.setDefault({ applicationId: APP, functionId: FN }, SETTINGS),
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
label: 'settings.setEnvironment',
|
|
239
|
+
method: 'put',
|
|
240
|
+
url: `${BASE}/settings/e-1`,
|
|
241
|
+
body: SETTINGS,
|
|
242
|
+
run: () =>
|
|
243
|
+
sdk().settings.setEnvironment(
|
|
244
|
+
{ applicationId: APP, functionId: FN, environmentId: 'e-1' },
|
|
245
|
+
SETTINGS,
|
|
246
|
+
),
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
label: 'settings.removeEnvironment',
|
|
250
|
+
method: 'delete',
|
|
251
|
+
url: `${BASE}/settings/e-1`,
|
|
252
|
+
run: () =>
|
|
253
|
+
sdk().settings.removeEnvironment({
|
|
254
|
+
applicationId: APP,
|
|
255
|
+
functionId: FN,
|
|
256
|
+
environmentId: 'e-1',
|
|
257
|
+
}),
|
|
258
|
+
},
|
|
259
|
+
];
|
|
260
|
+
|
|
261
|
+
describe('AbyssReflexCore function routes', () => {
|
|
262
|
+
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
263
|
+
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
beforeAll(() => {
|
|
267
|
+
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
268
|
+
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
beforeEach(() => adapter.mockClear());
|
|
272
|
+
|
|
273
|
+
it.each(calls)('$label calls $method $url', async (call) => {
|
|
274
|
+
await call.run();
|
|
275
|
+
|
|
276
|
+
const config = adapter.mock.calls[0][0];
|
|
277
|
+
expect(config.method).toBe(call.method);
|
|
278
|
+
expect(config.url).toBe(call.url);
|
|
279
|
+
expect(config.baseURL).toBe('http://reflex.test/');
|
|
280
|
+
expect(config.params).toEqual(call.params);
|
|
281
|
+
if (call.body !== undefined) {
|
|
282
|
+
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('sends the session token of the member as a bearer token', async () => {
|
|
287
|
+
await calls[0].run();
|
|
288
|
+
|
|
289
|
+
expect(adapter.mock.calls[0][0].headers.get('Authorization')).toBe('Bearer session-token');
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('exposes no route twice', () => {
|
|
293
|
+
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
describe('execution settings constants', () => {
|
|
298
|
+
it('give each profile its memory, S to XXL doubling from 128 MB', () => {
|
|
299
|
+
expect(Object.values(ExecutionProfile)).toEqual(['S', 'M', 'L', 'XL', 'XXL']);
|
|
300
|
+
expect(Object.values(ExecutionProfile).map((p) => EXECUTION_PROFILE_MEMORY_MB[p])).toEqual([
|
|
301
|
+
128, 256, 512, 1024, 2048,
|
|
302
|
+
]);
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
it('default to S, 30 s, 30 s, SYNC and no completion webhook, within the bounds', () => {
|
|
306
|
+
expect(DEFAULT_REFLEX_EXECUTION_SETTINGS).toEqual({
|
|
307
|
+
profile: ExecutionProfile.S,
|
|
308
|
+
responseTimeoutMs: 30_000,
|
|
309
|
+
maxDurationMs: 30_000,
|
|
310
|
+
mode: ExecutionMode.SYNC,
|
|
311
|
+
completionWebhookUrl: null,
|
|
312
|
+
});
|
|
313
|
+
expect(REFLEX_EXECUTION_SETTINGS_LIMITS).toEqual({
|
|
314
|
+
responseTimeoutMs: { min: 1_000, max: 100_000 },
|
|
315
|
+
maxDurationMs: { min: 1_000, max: 3_600_000 },
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
describe('respond status bounds', () => {
|
|
321
|
+
it('are 200 to 599, the bounds of the runtime', () => {
|
|
322
|
+
expect([RESPOND_STATUS_MIN, RESPOND_STATUS_MAX]).toEqual([200, 599]);
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
describe('run retention constants (L3a)', () => {
|
|
327
|
+
it('list the seven tiers the database accepts', () => {
|
|
328
|
+
expect(REFLEX_RUN_RETENTION_TIER_DAYS).toEqual([3, 7, 15, 30, 90, 180, 365]);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('bound the versions kept to 5 to 100, 20 by default', () => {
|
|
332
|
+
expect(REFLEX_VERSIONS_KEPT).toEqual({ default: 20, min: 5, max: 100 });
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it('archive the detail past 30 days, for the tiers of 90 days and more', () => {
|
|
336
|
+
expect(REFLEX_RUN_ARCHIVE_AFTER_DAYS).toBe(30);
|
|
337
|
+
expect(REFLEX_RUN_ARCHIVE_MIN_TIER_DAYS).toBe(90);
|
|
338
|
+
expect(
|
|
339
|
+
REFLEX_RUN_RETENTION_TIER_DAYS.filter((d) => d >= REFLEX_RUN_ARCHIVE_MIN_TIER_DAYS),
|
|
340
|
+
).toEqual([90, 180, 365]);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it('name the error of an archive that cannot be read', () => {
|
|
344
|
+
expect(ReflexErrorCode.ARCHIVE_UNAVAILABLE).toBe('ARCHIVE_UNAVAILABLE');
|
|
345
|
+
});
|
|
346
|
+
});
|