@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
package/src/api/index.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
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-discord-event.api';
|
|
15
|
-
export * from './service-insights.api';
|
|
16
|
-
export * from './function-insights.api';
|
|
17
|
-
export * from './service-task.api';
|
|
18
|
-
export * from './application-run-settings.api';
|
|
19
|
-
export * from './application-insights.api';
|
|
20
|
-
export * from './alert-rule.api';
|
|
21
|
-
export * from './route-stats.api';
|
|
22
|
-
export * from './function-template.api';
|
|
23
|
-
export * from './service-consumer.api';
|
|
24
|
-
export * from './service-openapi.api';
|
|
25
|
-
export * from './service-limits.api';
|
|
26
|
-
export * from './service-completion-webhook.api';
|
|
1
|
+
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-discord-event.api';
|
|
15
|
+
export * from './service-insights.api';
|
|
16
|
+
export * from './function-insights.api';
|
|
17
|
+
export * from './service-task.api';
|
|
18
|
+
export * from './application-run-settings.api';
|
|
19
|
+
export * from './application-insights.api';
|
|
20
|
+
export * from './alert-rule.api';
|
|
21
|
+
export * from './route-stats.api';
|
|
22
|
+
export * from './function-template.api';
|
|
23
|
+
export * from './service-consumer.api';
|
|
24
|
+
export * from './service-openapi.api';
|
|
25
|
+
export * from './service-limits.api';
|
|
26
|
+
export * from './service-completion-webhook.api';
|
|
27
|
+
export * from './storage-surplus.admin.api';
|
|
@@ -1,215 +1,220 @@
|
|
|
1
|
-
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
import {
|
|
3
|
-
AbyssReflexCore,
|
|
4
|
-
REFLEX_SERVICE_LIMITS,
|
|
5
|
-
RouteMethod,
|
|
6
|
-
ServiceType,
|
|
7
|
-
TriggerAccessMode,
|
|
8
|
-
} from '..';
|
|
9
|
-
|
|
10
|
-
const APP = 'app-1';
|
|
11
|
-
const SVC = 'svc-1';
|
|
12
|
-
const BASE = `api/service/${APP}/${SVC}`;
|
|
13
|
-
const SERVICE = { applicationId: APP, serviceId: SVC };
|
|
14
|
-
|
|
15
|
-
interface Call {
|
|
16
|
-
label: string;
|
|
17
|
-
method: string;
|
|
18
|
-
url: string;
|
|
19
|
-
body?: unknown;
|
|
20
|
-
params?: unknown;
|
|
21
|
-
run: () => Promise<unknown>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const sdk = () => AbyssReflexCore.sdk.service;
|
|
25
|
-
|
|
26
|
-
const calls: Call[] = [
|
|
27
|
-
{
|
|
28
|
-
label: 'list',
|
|
29
|
-
method: 'get',
|
|
30
|
-
url: `api/service/${APP}`,
|
|
31
|
-
run: () => sdk().list({ applicationId: APP }),
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
label: 'create',
|
|
35
|
-
method: 'post',
|
|
36
|
-
url: `api/service/${APP}`,
|
|
37
|
-
body: { name: 'Shop', slug: 'shop', type: ServiceType.HTTP_API },
|
|
38
|
-
run: () =>
|
|
39
|
-
sdk().create(
|
|
40
|
-
{ applicationId: APP },
|
|
41
|
-
{ name: 'Shop', slug: 'shop', type: ServiceType.HTTP_API },
|
|
42
|
-
),
|
|
43
|
-
},
|
|
44
|
-
{ label: 'get', method: 'get', url: BASE, run: () => sdk().get(SERVICE) },
|
|
45
|
-
{
|
|
46
|
-
label: 'update',
|
|
47
|
-
method: 'patch',
|
|
48
|
-
url: BASE,
|
|
49
|
-
body: {
|
|
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
|
-
|
|
1
|
+
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
+
import {
|
|
3
|
+
AbyssReflexCore,
|
|
4
|
+
REFLEX_SERVICE_LIMITS,
|
|
5
|
+
RouteMethod,
|
|
6
|
+
ServiceType,
|
|
7
|
+
TriggerAccessMode,
|
|
8
|
+
} from '..';
|
|
9
|
+
|
|
10
|
+
const APP = 'app-1';
|
|
11
|
+
const SVC = 'svc-1';
|
|
12
|
+
const BASE = `api/service/${APP}/${SVC}`;
|
|
13
|
+
const SERVICE = { applicationId: APP, serviceId: SVC };
|
|
14
|
+
|
|
15
|
+
interface Call {
|
|
16
|
+
label: string;
|
|
17
|
+
method: string;
|
|
18
|
+
url: string;
|
|
19
|
+
body?: unknown;
|
|
20
|
+
params?: unknown;
|
|
21
|
+
run: () => Promise<unknown>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const sdk = () => AbyssReflexCore.sdk.service;
|
|
25
|
+
|
|
26
|
+
const calls: Call[] = [
|
|
27
|
+
{
|
|
28
|
+
label: 'list',
|
|
29
|
+
method: 'get',
|
|
30
|
+
url: `api/service/${APP}`,
|
|
31
|
+
run: () => sdk().list({ applicationId: APP }),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: 'create',
|
|
35
|
+
method: 'post',
|
|
36
|
+
url: `api/service/${APP}`,
|
|
37
|
+
body: { name: 'Shop', slug: 'shop', type: ServiceType.HTTP_API },
|
|
38
|
+
run: () =>
|
|
39
|
+
sdk().create(
|
|
40
|
+
{ applicationId: APP },
|
|
41
|
+
{ name: 'Shop', slug: 'shop', type: ServiceType.HTTP_API },
|
|
42
|
+
),
|
|
43
|
+
},
|
|
44
|
+
{ label: 'get', method: 'get', url: BASE, run: () => sdk().get(SERVICE) },
|
|
45
|
+
{
|
|
46
|
+
label: 'update',
|
|
47
|
+
method: 'patch',
|
|
48
|
+
url: BASE,
|
|
49
|
+
body: {
|
|
50
|
+
cors: { allowedOrigins: ['https://shop.example'] },
|
|
51
|
+
rateLimitPerIpPerMinute: 120,
|
|
52
|
+
versionsKept: 40,
|
|
53
|
+
},
|
|
54
|
+
run: () =>
|
|
55
|
+
sdk().update(SERVICE, {
|
|
56
|
+
cors: { allowedOrigins: ['https://shop.example'] },
|
|
57
|
+
rateLimitPerIpPerMinute: 120,
|
|
58
|
+
versionsKept: 40,
|
|
59
|
+
}),
|
|
60
|
+
},
|
|
61
|
+
{ label: 'delete', method: 'delete', url: BASE, run: () => sdk().delete(SERVICE) },
|
|
62
|
+
{
|
|
63
|
+
label: 'route.list',
|
|
64
|
+
method: 'get',
|
|
65
|
+
url: `${BASE}/route`,
|
|
66
|
+
run: () => sdk().route.list(SERVICE),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
label: 'route.create',
|
|
70
|
+
method: 'post',
|
|
71
|
+
url: `${BASE}/route`,
|
|
72
|
+
body: {
|
|
73
|
+
method: RouteMethod.GET,
|
|
74
|
+
path: 'orders/:id',
|
|
75
|
+
functionId: 'fn-1',
|
|
76
|
+
accessMode: TriggerAccessMode.API_KEY,
|
|
77
|
+
},
|
|
78
|
+
run: () =>
|
|
79
|
+
sdk().route.create(SERVICE, {
|
|
80
|
+
method: RouteMethod.GET,
|
|
81
|
+
path: 'orders/:id',
|
|
82
|
+
functionId: 'fn-1',
|
|
83
|
+
accessMode: TriggerAccessMode.API_KEY,
|
|
84
|
+
}),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
label: 'route.update',
|
|
88
|
+
method: 'patch',
|
|
89
|
+
url: `${BASE}/route/r-1`,
|
|
90
|
+
body: { path: 'orders/:ref' },
|
|
91
|
+
run: () => sdk().route.update({ ...SERVICE, routeId: 'r-1' }, { path: 'orders/:ref' }),
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
label: 'route.delete',
|
|
95
|
+
method: 'delete',
|
|
96
|
+
url: `${BASE}/route/r-1`,
|
|
97
|
+
run: () => sdk().route.delete({ ...SERVICE, routeId: 'r-1' }),
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
label: 'route.rotate',
|
|
101
|
+
method: 'post',
|
|
102
|
+
url: `${BASE}/route/r-1/rotate`,
|
|
103
|
+
body: {},
|
|
104
|
+
run: () => sdk().route.rotate({ ...SERVICE, routeId: 'r-1' }),
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
label: 'version.list',
|
|
108
|
+
method: 'get',
|
|
109
|
+
url: `${BASE}/version`,
|
|
110
|
+
run: () => sdk().version.list(SERVICE),
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
label: 'version.create',
|
|
114
|
+
method: 'post',
|
|
115
|
+
url: `${BASE}/version`,
|
|
116
|
+
body: { message: 'orders by id' },
|
|
117
|
+
run: () => sdk().version.create(SERVICE, { message: 'orders by id' }),
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
label: 'version.draftStatus',
|
|
121
|
+
method: 'get',
|
|
122
|
+
url: `${BASE}/version/draft-status`,
|
|
123
|
+
run: () => sdk().version.draftStatus(SERVICE),
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
label: 'version.get',
|
|
127
|
+
method: 'get',
|
|
128
|
+
url: `${BASE}/version/v-1`,
|
|
129
|
+
run: () => sdk().version.get({ ...SERVICE, versionId: 'v-1' }),
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
label: 'deployment.list',
|
|
133
|
+
method: 'get',
|
|
134
|
+
url: `${BASE}/deployment`,
|
|
135
|
+
params: { environmentId: 'e-1', limit: 10, offset: 20 },
|
|
136
|
+
run: () => sdk().deployment.list(SERVICE, { environmentId: 'e-1', limit: 10, offset: 20 }),
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
label: 'deployment.goLive',
|
|
140
|
+
method: 'post',
|
|
141
|
+
url: `${BASE}/deployment/go-live`,
|
|
142
|
+
body: { environmentId: 'e-1', serviceVersionId: 'v-1' },
|
|
143
|
+
run: () => sdk().deployment.goLive(SERVICE, { environmentId: 'e-1', serviceVersionId: 'v-1' }),
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
label: 'deployment.rollback',
|
|
147
|
+
method: 'post',
|
|
148
|
+
url: `${BASE}/deployment/rollback`,
|
|
149
|
+
body: { environmentId: 'e-1', deploymentId: 'd-1' },
|
|
150
|
+
run: () => sdk().deployment.rollback(SERVICE, { environmentId: 'e-1', deploymentId: 'd-1' }),
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
label: 'deployment.pause',
|
|
154
|
+
method: 'post',
|
|
155
|
+
url: `${BASE}/deployment/pause`,
|
|
156
|
+
body: { environmentId: 'e-1' },
|
|
157
|
+
run: () => sdk().deployment.pause(SERVICE, { environmentId: 'e-1' }),
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
label: 'deployment.resume',
|
|
161
|
+
method: 'post',
|
|
162
|
+
url: `${BASE}/deployment/resume`,
|
|
163
|
+
body: { environmentId: 'e-1' },
|
|
164
|
+
run: () => sdk().deployment.resume(SERVICE, { environmentId: 'e-1' }),
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
label: 'configuration.list',
|
|
168
|
+
method: 'get',
|
|
169
|
+
url: `${BASE}/configuration`,
|
|
170
|
+
run: () => sdk().configuration.list(SERVICE),
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
describe('AbyssReflexCore service routes', () => {
|
|
175
|
+
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
176
|
+
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
beforeAll(() => {
|
|
180
|
+
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
181
|
+
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
beforeEach(() => adapter.mockClear());
|
|
185
|
+
|
|
186
|
+
it.each(calls)('$label calls $method $url', async (call) => {
|
|
187
|
+
await call.run();
|
|
188
|
+
|
|
189
|
+
const config = adapter.mock.calls[0][0];
|
|
190
|
+
expect(config.method).toBe(call.method);
|
|
191
|
+
expect(config.url).toBe(call.url);
|
|
192
|
+
expect(config.baseURL).toBe('http://reflex.test/');
|
|
193
|
+
expect(config.params).toEqual(call.params);
|
|
194
|
+
if (call.body !== undefined) {
|
|
195
|
+
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('exposes no route twice', () => {
|
|
200
|
+
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('sends an empty body for a version without a message', async () => {
|
|
204
|
+
await sdk().version.create(SERVICE);
|
|
205
|
+
|
|
206
|
+
expect(JSON.parse(adapter.mock.calls[0][0].data)).toEqual({});
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
describe('service limits', () => {
|
|
211
|
+
it('match the bounds of the database', () => {
|
|
212
|
+
expect(REFLEX_SERVICE_LIMITS.slugPattern.test('shop-2')).toBe(true);
|
|
213
|
+
expect(REFLEX_SERVICE_LIMITS.slugPattern.test('-shop')).toBe(false);
|
|
214
|
+
expect(REFLEX_SERVICE_LIMITS.rateLimitPerIpPerMinute).toEqual({
|
|
215
|
+
min: 1,
|
|
216
|
+
max: 6000,
|
|
217
|
+
default: 60,
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
+
import { ADMIN_TOKEN_HEADER, AbyssReflexCore, ReflexErrorCode } from '..';
|
|
3
|
+
|
|
4
|
+
const OWNER = { organizationId: 'org-1' };
|
|
5
|
+
const BODY = { owner: OWNER, itemIds: ['day-1'] };
|
|
6
|
+
const BASE = 'storage-surplus/admin';
|
|
7
|
+
|
|
8
|
+
const surplus = () => AbyssReflexCore.sdk.storageSurplus.admin;
|
|
9
|
+
|
|
10
|
+
describe('AbyssReflexCore storage surplus routes (day 90 of abyss-main)', () => {
|
|
11
|
+
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
12
|
+
async (config) => ({
|
|
13
|
+
data: { data: { items: [] } },
|
|
14
|
+
status: 200,
|
|
15
|
+
statusText: '',
|
|
16
|
+
headers: {},
|
|
17
|
+
config,
|
|
18
|
+
}),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
beforeAll(() => {
|
|
22
|
+
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', adminToken: 'mesh-admin-token' });
|
|
23
|
+
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
beforeEach(() => adapter.mockClear());
|
|
27
|
+
|
|
28
|
+
it.each([
|
|
29
|
+
[
|
|
30
|
+
'listArchivable',
|
|
31
|
+
`${BASE}/archivable`,
|
|
32
|
+
{ owner: OWNER },
|
|
33
|
+
() => surplus().listArchivable({ owner: OWNER }),
|
|
34
|
+
],
|
|
35
|
+
['archive', `${BASE}/archive`, BODY, () => surplus().archive(BODY)],
|
|
36
|
+
[
|
|
37
|
+
'listArchives',
|
|
38
|
+
`${BASE}/archives`,
|
|
39
|
+
{ owner: OWNER },
|
|
40
|
+
() => surplus().listArchives({ owner: OWNER }),
|
|
41
|
+
],
|
|
42
|
+
['deleteArchives', `${BASE}/delete-archives`, BODY, () => surplus().deleteArchives(BODY)],
|
|
43
|
+
])('%s posts to %s with the body and the admin token', async (_label, url, body, run) => {
|
|
44
|
+
const answer = await run();
|
|
45
|
+
|
|
46
|
+
const config = adapter.mock.calls[0][0];
|
|
47
|
+
expect(config.method).toBe('post');
|
|
48
|
+
expect(config.url).toBe(url);
|
|
49
|
+
expect(config.baseURL).toBe('http://reflex.test/');
|
|
50
|
+
expect(JSON.parse(config.data)).toEqual(body);
|
|
51
|
+
expect(config.headers.get(ADMIN_TOKEN_HEADER)).toBe('mesh-admin-token');
|
|
52
|
+
expect(answer).toEqual({ data: { items: [] } });
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('names the header of the mesh admin token', () => {
|
|
56
|
+
expect(ADMIN_TOKEN_HEADER).toBe('abyss-admin-token');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('names the refusal of a publication past the storage quota', () => {
|
|
60
|
+
expect(ReflexErrorCode.STORAGE_PUBLISH_REFUSED).toBe('STORAGE_PUBLISH_REFUSED');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('names the 404 of a run whose archive was deleted', () => {
|
|
64
|
+
expect(ReflexErrorCode.ARCHIVE_DELETED).toBe('ARCHIVE_DELETED');
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AbyssReflexCore } from '..';
|
|
2
|
+
import type {
|
|
3
|
+
IApplyStorageSurplusAdminBody,
|
|
4
|
+
IApplyStorageSurplusAdminResponse,
|
|
5
|
+
IListStorageSurplusAdminBody,
|
|
6
|
+
IListStorageSurplusAdminResponse,
|
|
7
|
+
} from '../types';
|
|
8
|
+
|
|
9
|
+
const BASE = 'storage-surplus/admin';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* `POST /storage-surplus/admin/archivable`: the days of runs of an organization that can move to the archive now. For
|
|
13
|
+
* abyss-main only: behind the admin token (`setConfig({ adminToken })`). AbyssReflex lists nothing for the surplus of
|
|
14
|
+
* the ONLINE quota (its runs are not in it): the answer is always empty.
|
|
15
|
+
*/
|
|
16
|
+
export const listArchivableStorageSurplusAdmin = async (
|
|
17
|
+
body: IListStorageSurplusAdminBody,
|
|
18
|
+
): Promise<IListStorageSurplusAdminResponse> =>
|
|
19
|
+
(await AbyssReflexCore.axios.post<IListStorageSurplusAdminResponse>(`${BASE}/archivable`, body))
|
|
20
|
+
.data;
|
|
21
|
+
|
|
22
|
+
/** `POST /storage-surplus/admin/archive`: moves the given days to the archive; idempotent. Admin token. */
|
|
23
|
+
export const archiveStorageSurplusAdmin = async (
|
|
24
|
+
body: IApplyStorageSurplusAdminBody,
|
|
25
|
+
): Promise<IApplyStorageSurplusAdminResponse> =>
|
|
26
|
+
(await AbyssReflexCore.axios.post<IApplyStorageSurplusAdminResponse>(`${BASE}/archive`, body))
|
|
27
|
+
.data;
|
|
28
|
+
|
|
29
|
+
/** `POST /storage-surplus/admin/archives`: the archived days of the organization, the oldest first. Admin token. */
|
|
30
|
+
export const listArchivesStorageSurplusAdmin = async (
|
|
31
|
+
body: IListStorageSurplusAdminBody,
|
|
32
|
+
): Promise<IListStorageSurplusAdminResponse> =>
|
|
33
|
+
(await AbyssReflexCore.axios.post<IListStorageSurplusAdminResponse>(`${BASE}/archives`, body))
|
|
34
|
+
.data;
|
|
35
|
+
|
|
36
|
+
/** `POST /storage-surplus/admin/delete-archives`: deletes the given archived days for good; idempotent. Admin token. */
|
|
37
|
+
export const deleteArchivesStorageSurplusAdmin = async (
|
|
38
|
+
body: IApplyStorageSurplusAdminBody,
|
|
39
|
+
): Promise<IApplyStorageSurplusAdminResponse> =>
|
|
40
|
+
(
|
|
41
|
+
await AbyssReflexCore.axios.post<IApplyStorageSurplusAdminResponse>(
|
|
42
|
+
`${BASE}/delete-archives`,
|
|
43
|
+
body,
|
|
44
|
+
)
|
|
45
|
+
).data;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { buildDiscordCommandTree, discordCommandPathOf } from './discord-command-tree';
|
|
2
|
+
|
|
3
|
+
const node = (id: string, name: string, parentId: string | null = null) => ({ id, name, parentId });
|
|
4
|
+
|
|
5
|
+
const COMMANDS = [
|
|
6
|
+
node('c', 'config'),
|
|
7
|
+
node('t', 'ticket'),
|
|
8
|
+
node('tc', 'close', 't'),
|
|
9
|
+
node('to', 'open', 't'),
|
|
10
|
+
node('cr', 'role', 'c'),
|
|
11
|
+
node('cra', 'add', 'cr'),
|
|
12
|
+
node('crr', 'remove', 'cr'),
|
|
13
|
+
node('p', 'ping'),
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
describe('buildDiscordCommandTree', () => {
|
|
17
|
+
it('nests groups and subcommands under their command, sorted by name at every level', () => {
|
|
18
|
+
const tree = buildDiscordCommandTree(COMMANDS);
|
|
19
|
+
|
|
20
|
+
expect(tree.map((root) => root.command.name)).toEqual(['config', 'ping', 'ticket']);
|
|
21
|
+
expect(tree[2].children.map((child) => child.command.name)).toEqual(['close', 'open']);
|
|
22
|
+
expect(tree[0].children[0].command.name).toBe('role');
|
|
23
|
+
expect(tree[0].children[0].children.map((child) => child.command.name)).toEqual([
|
|
24
|
+
'add',
|
|
25
|
+
'remove',
|
|
26
|
+
]);
|
|
27
|
+
expect(tree[1].children).toEqual([]);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('leaves out a node whose parent is not in the list', () => {
|
|
31
|
+
const tree = buildDiscordCommandTree([node('x', 'orphan', 'missing'), node('p', 'ping')]);
|
|
32
|
+
|
|
33
|
+
expect(tree.map((root) => root.command.name)).toEqual(['ping']);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('discordCommandPathOf', () => {
|
|
38
|
+
it('gives the names from the root down', () => {
|
|
39
|
+
expect(discordCommandPathOf(COMMANDS[5], COMMANDS)).toEqual(['config', 'role', 'add']);
|
|
40
|
+
expect(discordCommandPathOf(COMMANDS[3], COMMANDS)).toEqual(['ticket', 'open']);
|
|
41
|
+
expect(discordCommandPathOf(COMMANDS[7], COMMANDS)).toEqual(['ping']);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('is empty when an ancestor is missing', () => {
|
|
45
|
+
expect(discordCommandPathOf(node('x', 'add', 'gone'), COMMANDS)).toEqual([]);
|
|
46
|
+
});
|
|
47
|
+
});
|