@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.
- package/dist/api/service-version.api.d.ts +2 -1
- package/dist/api/service-version.api.js +3 -1
- package/dist/api/service-version.api.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/enum/discord-activity-type.enum.d.ts +7 -0
- package/dist/types/enum/discord-activity-type.enum.js +12 -0
- package/dist/types/enum/discord-activity-type.enum.js.map +1 -0
- package/dist/types/enum/discord-gateway-failure-code.enum.d.ts +5 -0
- package/dist/types/enum/discord-gateway-failure-code.enum.js +10 -0
- package/dist/types/enum/discord-gateway-failure-code.enum.js.map +1 -0
- package/dist/types/enum/discord-gateway-state.enum.d.ts +6 -0
- package/dist/types/enum/discord-gateway-state.enum.js +11 -0
- package/dist/types/enum/discord-gateway-state.enum.js.map +1 -0
- package/dist/types/enum/discord-presence-status.enum.d.ts +5 -0
- package/dist/types/enum/discord-presence-status.enum.js +10 -0
- package/dist/types/enum/discord-presence-status.enum.js.map +1 -0
- package/dist/types/enum/index.d.ts +4 -0
- package/dist/types/enum/index.js +4 -0
- package/dist/types/enum/index.js.map +1 -1
- package/dist/types/interface/api/requests/service-discord.request.d.ts +4 -1
- package/dist/types/interface/api/requests/service-version.request.d.ts +4 -0
- package/dist/types/interface/api/responses/service-version.response.d.ts +4 -0
- package/dist/types/interface/models/reflex-discord.model.d.ts +14 -1
- package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
- package/package.json +1 -1
- package/src/api/function-access.api.ts +36 -36
- package/src/api/function-run.api.ts +38 -38
- package/src/api/function-settings.api.ts +59 -59
- package/src/api/function-test.api.ts +34 -34
- package/src/api/function-version.api.ts +48 -48
- package/src/api/function.api.test.ts +249 -249
- package/src/api/function.api.ts +62 -62
- package/src/api/health.api.ts +10 -10
- package/src/api/index.ts +13 -13
- package/src/api/service-configuration.api.ts +16 -16
- package/src/api/service-deployment.api.ts +79 -79
- package/src/api/service-route.api.ts +72 -72
- package/src/api/service-version.api.ts +54 -39
- package/src/api/service.api.test.ts +215 -209
- package/src/api/service.api.ts +55 -55
- package/src/index.ts +2 -0
- package/src/types/enum/discord-activity-type.enum.ts +9 -0
- package/src/types/enum/discord-component-kind.enum.ts +7 -7
- package/src/types/enum/discord-gateway-failure-code.enum.ts +9 -0
- package/src/types/enum/discord-gateway-state.enum.ts +11 -0
- package/src/types/enum/discord-option-type.enum.ts +12 -12
- package/src/types/enum/discord-presence-status.enum.ts +8 -0
- package/src/types/enum/discord-sync-status.enum.ts +6 -6
- package/src/types/enum/discord-token-state.enum.ts +11 -11
- package/src/types/enum/index.ts +4 -0
- package/src/types/interface/api/requests/service-discord.request.ts +128 -118
- package/src/types/interface/api/requests/service-version.request.ts +24 -19
- package/src/types/interface/api/responses/service-discord.response.ts +72 -72
- package/src/types/interface/api/responses/service-version.response.ts +11 -0
- package/src/types/interface/models/reflex-discord.model.ts +146 -117
- package/src/types/interface/models/reflex-run.model.ts +173 -173
|
@@ -1,209 +1,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: { cors: { allowedOrigins: ['https://shop.example'] }, rateLimitPerIpPerMinute: 120 },
|
|
50
|
-
run: () =>
|
|
51
|
-
sdk().update(SERVICE, {
|
|
52
|
-
cors: { allowedOrigins: ['https://shop.example'] },
|
|
53
|
-
rateLimitPerIpPerMinute: 120,
|
|
54
|
-
}),
|
|
55
|
-
},
|
|
56
|
-
{ label: 'delete', method: 'delete', url: BASE, run: () => sdk().delete(SERVICE) },
|
|
57
|
-
{
|
|
58
|
-
label: 'route.list',
|
|
59
|
-
method: 'get',
|
|
60
|
-
url: `${BASE}/route`,
|
|
61
|
-
run: () => sdk().route.list(SERVICE),
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
label: 'route.create',
|
|
65
|
-
method: 'post',
|
|
66
|
-
url: `${BASE}/route`,
|
|
67
|
-
body: {
|
|
68
|
-
method: RouteMethod.GET,
|
|
69
|
-
path: 'orders/:id',
|
|
70
|
-
functionId: 'fn-1',
|
|
71
|
-
accessMode: TriggerAccessMode.API_KEY,
|
|
72
|
-
},
|
|
73
|
-
run: () =>
|
|
74
|
-
sdk().route.create(SERVICE, {
|
|
75
|
-
method: RouteMethod.GET,
|
|
76
|
-
path: 'orders/:id',
|
|
77
|
-
functionId: 'fn-1',
|
|
78
|
-
accessMode: TriggerAccessMode.API_KEY,
|
|
79
|
-
}),
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
label: 'route.update',
|
|
83
|
-
method: 'patch',
|
|
84
|
-
url: `${BASE}/route/r-1`,
|
|
85
|
-
body: { path: 'orders/:ref' },
|
|
86
|
-
run: () => sdk().route.update({ ...SERVICE, routeId: 'r-1' }, { path: 'orders/:ref' }),
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
label: 'route.delete',
|
|
90
|
-
method: 'delete',
|
|
91
|
-
url: `${BASE}/route/r-1`,
|
|
92
|
-
run: () => sdk().route.delete({ ...SERVICE, routeId: 'r-1' }),
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
label: 'route.rotate',
|
|
96
|
-
method: 'post',
|
|
97
|
-
url: `${BASE}/route/r-1/rotate`,
|
|
98
|
-
body: {},
|
|
99
|
-
run: () => sdk().route.rotate({ ...SERVICE, routeId: 'r-1' }),
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
label: 'version.list',
|
|
103
|
-
method: 'get',
|
|
104
|
-
url: `${BASE}/version`,
|
|
105
|
-
run: () => sdk().version.list(SERVICE),
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
label: 'version.create',
|
|
109
|
-
method: 'post',
|
|
110
|
-
url: `${BASE}/version`,
|
|
111
|
-
body: { message: 'orders by id' },
|
|
112
|
-
run: () => sdk().version.create(SERVICE, { message: 'orders by id' }),
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
label: 'version.
|
|
116
|
-
method: 'get',
|
|
117
|
-
url: `${BASE}/version/
|
|
118
|
-
run: () => sdk().version.
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
label: '
|
|
122
|
-
method: 'get',
|
|
123
|
-
url: `${BASE}/
|
|
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
|
-
run: () => sdk().
|
|
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
|
-
expect(
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
expect(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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: { cors: { allowedOrigins: ['https://shop.example'] }, rateLimitPerIpPerMinute: 120 },
|
|
50
|
+
run: () =>
|
|
51
|
+
sdk().update(SERVICE, {
|
|
52
|
+
cors: { allowedOrigins: ['https://shop.example'] },
|
|
53
|
+
rateLimitPerIpPerMinute: 120,
|
|
54
|
+
}),
|
|
55
|
+
},
|
|
56
|
+
{ label: 'delete', method: 'delete', url: BASE, run: () => sdk().delete(SERVICE) },
|
|
57
|
+
{
|
|
58
|
+
label: 'route.list',
|
|
59
|
+
method: 'get',
|
|
60
|
+
url: `${BASE}/route`,
|
|
61
|
+
run: () => sdk().route.list(SERVICE),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
label: 'route.create',
|
|
65
|
+
method: 'post',
|
|
66
|
+
url: `${BASE}/route`,
|
|
67
|
+
body: {
|
|
68
|
+
method: RouteMethod.GET,
|
|
69
|
+
path: 'orders/:id',
|
|
70
|
+
functionId: 'fn-1',
|
|
71
|
+
accessMode: TriggerAccessMode.API_KEY,
|
|
72
|
+
},
|
|
73
|
+
run: () =>
|
|
74
|
+
sdk().route.create(SERVICE, {
|
|
75
|
+
method: RouteMethod.GET,
|
|
76
|
+
path: 'orders/:id',
|
|
77
|
+
functionId: 'fn-1',
|
|
78
|
+
accessMode: TriggerAccessMode.API_KEY,
|
|
79
|
+
}),
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
label: 'route.update',
|
|
83
|
+
method: 'patch',
|
|
84
|
+
url: `${BASE}/route/r-1`,
|
|
85
|
+
body: { path: 'orders/:ref' },
|
|
86
|
+
run: () => sdk().route.update({ ...SERVICE, routeId: 'r-1' }, { path: 'orders/:ref' }),
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
label: 'route.delete',
|
|
90
|
+
method: 'delete',
|
|
91
|
+
url: `${BASE}/route/r-1`,
|
|
92
|
+
run: () => sdk().route.delete({ ...SERVICE, routeId: 'r-1' }),
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
label: 'route.rotate',
|
|
96
|
+
method: 'post',
|
|
97
|
+
url: `${BASE}/route/r-1/rotate`,
|
|
98
|
+
body: {},
|
|
99
|
+
run: () => sdk().route.rotate({ ...SERVICE, routeId: 'r-1' }),
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
label: 'version.list',
|
|
103
|
+
method: 'get',
|
|
104
|
+
url: `${BASE}/version`,
|
|
105
|
+
run: () => sdk().version.list(SERVICE),
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
label: 'version.create',
|
|
109
|
+
method: 'post',
|
|
110
|
+
url: `${BASE}/version`,
|
|
111
|
+
body: { message: 'orders by id' },
|
|
112
|
+
run: () => sdk().version.create(SERVICE, { message: 'orders by id' }),
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
label: 'version.draftStatus',
|
|
116
|
+
method: 'get',
|
|
117
|
+
url: `${BASE}/version/draft-status`,
|
|
118
|
+
run: () => sdk().version.draftStatus(SERVICE),
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
label: 'version.get',
|
|
122
|
+
method: 'get',
|
|
123
|
+
url: `${BASE}/version/v-1`,
|
|
124
|
+
run: () => sdk().version.get({ ...SERVICE, versionId: 'v-1' }),
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
label: 'deployment.list',
|
|
128
|
+
method: 'get',
|
|
129
|
+
url: `${BASE}/deployment`,
|
|
130
|
+
params: { environmentId: 'e-1', limit: 10, offset: 20 },
|
|
131
|
+
run: () => sdk().deployment.list(SERVICE, { environmentId: 'e-1', limit: 10, offset: 20 }),
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
label: 'deployment.goLive',
|
|
135
|
+
method: 'post',
|
|
136
|
+
url: `${BASE}/deployment/go-live`,
|
|
137
|
+
body: { environmentId: 'e-1', serviceVersionId: 'v-1' },
|
|
138
|
+
run: () => sdk().deployment.goLive(SERVICE, { environmentId: 'e-1', serviceVersionId: 'v-1' }),
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
label: 'deployment.rollback',
|
|
142
|
+
method: 'post',
|
|
143
|
+
url: `${BASE}/deployment/rollback`,
|
|
144
|
+
body: { environmentId: 'e-1', deploymentId: 'd-1' },
|
|
145
|
+
run: () => sdk().deployment.rollback(SERVICE, { environmentId: 'e-1', deploymentId: 'd-1' }),
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
label: 'deployment.pause',
|
|
149
|
+
method: 'post',
|
|
150
|
+
url: `${BASE}/deployment/pause`,
|
|
151
|
+
body: { environmentId: 'e-1' },
|
|
152
|
+
run: () => sdk().deployment.pause(SERVICE, { environmentId: 'e-1' }),
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
label: 'deployment.resume',
|
|
156
|
+
method: 'post',
|
|
157
|
+
url: `${BASE}/deployment/resume`,
|
|
158
|
+
body: { environmentId: 'e-1' },
|
|
159
|
+
run: () => sdk().deployment.resume(SERVICE, { environmentId: 'e-1' }),
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
label: 'configuration.list',
|
|
163
|
+
method: 'get',
|
|
164
|
+
url: `${BASE}/configuration`,
|
|
165
|
+
run: () => sdk().configuration.list(SERVICE),
|
|
166
|
+
},
|
|
167
|
+
];
|
|
168
|
+
|
|
169
|
+
describe('AbyssReflexCore service routes', () => {
|
|
170
|
+
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
171
|
+
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
beforeAll(() => {
|
|
175
|
+
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
176
|
+
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
beforeEach(() => adapter.mockClear());
|
|
180
|
+
|
|
181
|
+
it.each(calls)('$label calls $method $url', async (call) => {
|
|
182
|
+
await call.run();
|
|
183
|
+
|
|
184
|
+
const config = adapter.mock.calls[0][0];
|
|
185
|
+
expect(config.method).toBe(call.method);
|
|
186
|
+
expect(config.url).toBe(call.url);
|
|
187
|
+
expect(config.baseURL).toBe('http://reflex.test/');
|
|
188
|
+
expect(config.params).toEqual(call.params);
|
|
189
|
+
if (call.body !== undefined) {
|
|
190
|
+
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('exposes no route twice', () => {
|
|
195
|
+
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('sends an empty body for a version without a message', async () => {
|
|
199
|
+
await sdk().version.create(SERVICE);
|
|
200
|
+
|
|
201
|
+
expect(JSON.parse(adapter.mock.calls[0][0].data)).toEqual({});
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
describe('service limits', () => {
|
|
206
|
+
it('match the bounds of the database', () => {
|
|
207
|
+
expect(REFLEX_SERVICE_LIMITS.slugPattern.test('shop-2')).toBe(true);
|
|
208
|
+
expect(REFLEX_SERVICE_LIMITS.slugPattern.test('-shop')).toBe(false);
|
|
209
|
+
expect(REFLEX_SERVICE_LIMITS.rateLimitPerIpPerMinute).toEqual({
|
|
210
|
+
min: 1,
|
|
211
|
+
max: 6000,
|
|
212
|
+
default: 60,
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
});
|
package/src/api/service.api.ts
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { AbyssReflexCore } from '..';
|
|
2
|
-
import type {
|
|
3
|
-
ICreateServiceBody,
|
|
4
|
-
ICreateServiceParams,
|
|
5
|
-
ICreateServiceResponse,
|
|
6
|
-
IDeleteServiceParams,
|
|
7
|
-
IDeleteServiceResponse,
|
|
8
|
-
IGetServiceParams,
|
|
9
|
-
IGetServiceResponse,
|
|
10
|
-
IListServiceParams,
|
|
11
|
-
IListServiceResponse,
|
|
12
|
-
IUpdateServiceBody,
|
|
13
|
-
IUpdateServiceParams,
|
|
14
|
-
IUpdateServiceResponse,
|
|
15
|
-
} from '../types';
|
|
16
|
-
|
|
17
|
-
const serviceListUrl = (params: { applicationId: string }): string =>
|
|
18
|
-
`api/service/${params.applicationId}`;
|
|
19
|
-
|
|
20
|
-
const serviceUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
21
|
-
`${serviceListUrl(params)}/${params.serviceId}`;
|
|
22
|
-
|
|
23
|
-
/** `GET /service/:applicationId`: the Services, each with its current deployment per environment. Needs REFLEX_READ. */
|
|
24
|
-
export const listService = async (params: IListServiceParams): Promise<IListServiceResponse> =>
|
|
25
|
-
(await AbyssReflexCore.axios.get<IListServiceResponse>(serviceListUrl(params))).data;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* `POST /service/:applicationId`: a Service of a name, a slug (immutable, third segment of the address)
|
|
29
|
-
* and a type. `409 ALREADY_EXISTS` when the name or the slug is taken. Needs REFLEX_FUNCTION_CREATE.
|
|
30
|
-
*/
|
|
31
|
-
export const createService = async (
|
|
32
|
-
params: ICreateServiceParams,
|
|
33
|
-
body: ICreateServiceBody,
|
|
34
|
-
): Promise<ICreateServiceResponse> =>
|
|
35
|
-
(await AbyssReflexCore.axios.post<ICreateServiceResponse>(serviceListUrl(params), body)).data;
|
|
36
|
-
|
|
37
|
-
/** `GET .../:serviceId`. Needs REFLEX_READ. */
|
|
38
|
-
export const getService = async (params: IGetServiceParams): Promise<IGetServiceResponse> =>
|
|
39
|
-
(await AbyssReflexCore.axios.get<IGetServiceResponse>(serviceUrl(params))).data;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* `PATCH .../:serviceId`: the name, and the draft of the CORS and of the rate limit, frozen by the next
|
|
43
|
-
* version. Needs REFLEX_FUNCTION_UPDATE.
|
|
44
|
-
*/
|
|
45
|
-
export const updateService = async (
|
|
46
|
-
params: IUpdateServiceParams,
|
|
47
|
-
body: IUpdateServiceBody,
|
|
48
|
-
): Promise<IUpdateServiceResponse> =>
|
|
49
|
-
(await AbyssReflexCore.axios.patch<IUpdateServiceResponse>(serviceUrl(params), body)).data;
|
|
50
|
-
|
|
51
|
-
/** `DELETE .../:serviceId`: the Service, its functions, routes, versions and deployments. Needs REFLEX_FUNCTION_DELETE. */
|
|
52
|
-
export const deleteService = async (
|
|
53
|
-
params: IDeleteServiceParams,
|
|
54
|
-
): Promise<IDeleteServiceResponse> =>
|
|
55
|
-
(await AbyssReflexCore.axios.delete<IDeleteServiceResponse>(serviceUrl(params))).data;
|
|
1
|
+
import { AbyssReflexCore } from '..';
|
|
2
|
+
import type {
|
|
3
|
+
ICreateServiceBody,
|
|
4
|
+
ICreateServiceParams,
|
|
5
|
+
ICreateServiceResponse,
|
|
6
|
+
IDeleteServiceParams,
|
|
7
|
+
IDeleteServiceResponse,
|
|
8
|
+
IGetServiceParams,
|
|
9
|
+
IGetServiceResponse,
|
|
10
|
+
IListServiceParams,
|
|
11
|
+
IListServiceResponse,
|
|
12
|
+
IUpdateServiceBody,
|
|
13
|
+
IUpdateServiceParams,
|
|
14
|
+
IUpdateServiceResponse,
|
|
15
|
+
} from '../types';
|
|
16
|
+
|
|
17
|
+
const serviceListUrl = (params: { applicationId: string }): string =>
|
|
18
|
+
`api/service/${params.applicationId}`;
|
|
19
|
+
|
|
20
|
+
const serviceUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
21
|
+
`${serviceListUrl(params)}/${params.serviceId}`;
|
|
22
|
+
|
|
23
|
+
/** `GET /service/:applicationId`: the Services, each with its current deployment per environment. Needs REFLEX_READ. */
|
|
24
|
+
export const listService = async (params: IListServiceParams): Promise<IListServiceResponse> =>
|
|
25
|
+
(await AbyssReflexCore.axios.get<IListServiceResponse>(serviceListUrl(params))).data;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* `POST /service/:applicationId`: a Service of a name, a slug (immutable, third segment of the address)
|
|
29
|
+
* and a type. `409 ALREADY_EXISTS` when the name or the slug is taken. Needs REFLEX_FUNCTION_CREATE.
|
|
30
|
+
*/
|
|
31
|
+
export const createService = async (
|
|
32
|
+
params: ICreateServiceParams,
|
|
33
|
+
body: ICreateServiceBody,
|
|
34
|
+
): Promise<ICreateServiceResponse> =>
|
|
35
|
+
(await AbyssReflexCore.axios.post<ICreateServiceResponse>(serviceListUrl(params), body)).data;
|
|
36
|
+
|
|
37
|
+
/** `GET .../:serviceId`. Needs REFLEX_READ. */
|
|
38
|
+
export const getService = async (params: IGetServiceParams): Promise<IGetServiceResponse> =>
|
|
39
|
+
(await AbyssReflexCore.axios.get<IGetServiceResponse>(serviceUrl(params))).data;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* `PATCH .../:serviceId`: the name, and the draft of the CORS and of the rate limit, frozen by the next
|
|
43
|
+
* version. Needs REFLEX_FUNCTION_UPDATE.
|
|
44
|
+
*/
|
|
45
|
+
export const updateService = async (
|
|
46
|
+
params: IUpdateServiceParams,
|
|
47
|
+
body: IUpdateServiceBody,
|
|
48
|
+
): Promise<IUpdateServiceResponse> =>
|
|
49
|
+
(await AbyssReflexCore.axios.patch<IUpdateServiceResponse>(serviceUrl(params), body)).data;
|
|
50
|
+
|
|
51
|
+
/** `DELETE .../:serviceId`: the Service, its functions, routes, versions and deployments. Needs REFLEX_FUNCTION_DELETE. */
|
|
52
|
+
export const deleteService = async (
|
|
53
|
+
params: IDeleteServiceParams,
|
|
54
|
+
): Promise<IDeleteServiceResponse> =>
|
|
55
|
+
(await AbyssReflexCore.axios.delete<IDeleteServiceResponse>(serviceUrl(params))).data;
|
package/src/index.ts
CHANGED
|
@@ -77,6 +77,7 @@ type AbyssReflexCoreSDK = {
|
|
|
77
77
|
list: typeof serviceVersionApi.listServiceVersion;
|
|
78
78
|
create: typeof serviceVersionApi.createServiceVersion;
|
|
79
79
|
get: typeof serviceVersionApi.getServiceVersion;
|
|
80
|
+
draftStatus: typeof serviceVersionApi.getServiceVersionDraftStatus;
|
|
80
81
|
};
|
|
81
82
|
deployment: {
|
|
82
83
|
list: typeof serviceDeploymentApi.listServiceDeployment;
|
|
@@ -177,6 +178,7 @@ export class AbyssReflexCore {
|
|
|
177
178
|
list: serviceVersionApi.listServiceVersion,
|
|
178
179
|
create: serviceVersionApi.createServiceVersion,
|
|
179
180
|
get: serviceVersionApi.getServiceVersion,
|
|
181
|
+
draftStatus: serviceVersionApi.getServiceVersionDraftStatus,
|
|
180
182
|
},
|
|
181
183
|
deployment: {
|
|
182
184
|
list: serviceDeploymentApi.listServiceDeployment,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** What the activity of a Discord bot says it does ("Playing", "Listening to", "Watching", "Competing in", or a free text). */
|
|
2
|
+
export enum DiscordActivityType {
|
|
3
|
+
PLAYING = 'PLAYING',
|
|
4
|
+
LISTENING = 'LISTENING',
|
|
5
|
+
WATCHING = 'WATCHING',
|
|
6
|
+
COMPETING = 'COMPETING',
|
|
7
|
+
/** The text alone, shown as it is written. */
|
|
8
|
+
CUSTOM = 'CUSTOM',
|
|
9
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** What a component prefix of a Discord bot routes. */
|
|
2
|
-
export enum DiscordComponentKind {
|
|
3
|
-
/** A button or a select menu: interactions of type MESSAGE_COMPONENT. */
|
|
4
|
-
BUTTON_OR_SELECT = 'BUTTON_OR_SELECT',
|
|
5
|
-
/** A form: interactions of type MODAL_SUBMIT. */
|
|
6
|
-
MODAL = 'MODAL',
|
|
7
|
-
}
|
|
1
|
+
/** What a component prefix of a Discord bot routes. */
|
|
2
|
+
export enum DiscordComponentKind {
|
|
3
|
+
/** A button or a select menu: interactions of type MESSAGE_COMPONENT. */
|
|
4
|
+
BUTTON_OR_SELECT = 'BUTTON_OR_SELECT',
|
|
5
|
+
/** A form: interactions of type MODAL_SUBMIT. */
|
|
6
|
+
MODAL = 'MODAL',
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Why a Gateway connection is `FAILED`. */
|
|
2
|
+
export enum DiscordGatewayFailureCode {
|
|
3
|
+
/** Discord rejected the token (close code 4004). */
|
|
4
|
+
TOKEN_REJECTED = 'TOKEN_REJECTED',
|
|
5
|
+
/** The bot spent its identifications of the UTC day. */
|
|
6
|
+
IDENTIFY_BUDGET = 'IDENTIFY_BUDGET',
|
|
7
|
+
/** Discord refused the connection (close codes 4010 to 4014: invalid shard, sharding required, invalid or disallowed intents). */
|
|
8
|
+
DISCORD_REFUSED = 'DISCORD_REFUSED',
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The state of the Gateway connection that keeps a Discord bot online in one environment. */
|
|
2
|
+
export enum DiscordGatewayState {
|
|
3
|
+
/** Connecting, identifying or resuming. */
|
|
4
|
+
CONNECTING = 'CONNECTING',
|
|
5
|
+
/** Connected: the bot is online. */
|
|
6
|
+
CONNECTED = 'CONNECTED',
|
|
7
|
+
/** No connection: the bot is paused or out of service, or the connection is between two owners. */
|
|
8
|
+
DISCONNECTED = 'DISCONNECTED',
|
|
9
|
+
/** The connection cannot be kept; `DiscordGatewayFailureCode` says why. */
|
|
10
|
+
FAILED = 'FAILED',
|
|
11
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/** Type of an option of a Discord command (same names as the options Discord documents). */
|
|
2
|
-
export enum DiscordOptionType {
|
|
3
|
-
STRING = 'STRING',
|
|
4
|
-
INTEGER = 'INTEGER',
|
|
5
|
-
NUMBER = 'NUMBER',
|
|
6
|
-
BOOLEAN = 'BOOLEAN',
|
|
7
|
-
USER = 'USER',
|
|
8
|
-
CHANNEL = 'CHANNEL',
|
|
9
|
-
ROLE = 'ROLE',
|
|
10
|
-
MENTIONABLE = 'MENTIONABLE',
|
|
11
|
-
ATTACHMENT = 'ATTACHMENT',
|
|
12
|
-
}
|
|
1
|
+
/** Type of an option of a Discord command (same names as the options Discord documents). */
|
|
2
|
+
export enum DiscordOptionType {
|
|
3
|
+
STRING = 'STRING',
|
|
4
|
+
INTEGER = 'INTEGER',
|
|
5
|
+
NUMBER = 'NUMBER',
|
|
6
|
+
BOOLEAN = 'BOOLEAN',
|
|
7
|
+
USER = 'USER',
|
|
8
|
+
CHANNEL = 'CHANNEL',
|
|
9
|
+
ROLE = 'ROLE',
|
|
10
|
+
MENTIONABLE = 'MENTIONABLE',
|
|
11
|
+
ATTACHMENT = 'ATTACHMENT',
|
|
12
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/** State of the push of the interactions address and the commands to Discord, per environment. */
|
|
2
|
-
export enum DiscordSyncStatus {
|
|
3
|
-
PENDING = 'PENDING',
|
|
4
|
-
SYNCED = 'SYNCED',
|
|
5
|
-
FAILED = 'FAILED',
|
|
6
|
-
}
|
|
1
|
+
/** State of the push of the interactions address and the commands to Discord, per environment. */
|
|
2
|
+
export enum DiscordSyncStatus {
|
|
3
|
+
PENDING = 'PENDING',
|
|
4
|
+
SYNCED = 'SYNCED',
|
|
5
|
+
FAILED = 'FAILED',
|
|
6
|
+
}
|