@abyss-project/reflex 6.2.0 → 6.3.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/.eslintrc.js +32 -32
- package/README.md +15 -15
- package/dist/api/function-run.api.d.ts +1 -2
- package/dist/api/function-run.api.js +1 -3
- package/dist/api/function-run.api.js.map +1 -1
- package/dist/api/function-settings.api.d.ts +1 -3
- package/dist/api/function-settings.api.js +1 -7
- package/dist/api/function-settings.api.js.map +1 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.js +0 -1
- package/dist/api/index.js.map +1 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.js +1 -19
- package/dist/index.js.map +1 -1
- package/dist/types/enum/discord-host-action.enum.d.ts +3 -1
- package/dist/types/enum/discord-host-action.enum.js +2 -0
- package/dist/types/enum/discord-host-action.enum.js.map +1 -1
- package/dist/types/enum/reflex-error-code.enum.d.ts +1 -4
- package/dist/types/enum/reflex-error-code.enum.js +0 -3
- package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
- package/dist/types/interface/api/requests/application-run-settings.request.d.ts +0 -1
- package/dist/types/interface/api/requests/function-run.request.d.ts +0 -8
- package/dist/types/interface/api/requests/function-settings.request.d.ts +0 -12
- package/dist/types/interface/api/requests/index.d.ts +0 -1
- package/dist/types/interface/api/requests/index.js +0 -1
- package/dist/types/interface/api/requests/index.js.map +1 -1
- package/dist/types/interface/api/requests/service-discord.request.d.ts +1 -0
- package/dist/types/interface/api/requests/service.request.d.ts +0 -1
- package/dist/types/interface/api/responses/function-run.response.d.ts +0 -4
- package/dist/types/interface/api/responses/function-settings.response.d.ts +1 -5
- package/dist/types/interface/api/responses/index.d.ts +0 -1
- package/dist/types/interface/api/responses/index.js +0 -1
- package/dist/types/interface/api/responses/index.js.map +1 -1
- package/dist/types/interface/models/index.d.ts +0 -2
- package/dist/types/interface/models/index.js +0 -2
- package/dist/types/interface/models/index.js.map +1 -1
- package/dist/types/interface/models/reflex-discord.model.d.ts +5 -0
- package/dist/types/interface/models/reflex-discord.model.js +2 -0
- package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
- package/dist/types/interface/models/reflex-price-list.model.d.ts +1 -0
- package/dist/types/interface/models/reflex-run-settings.model.d.ts +0 -4
- package/dist/types/interface/models/reflex-run.model.d.ts +0 -5
- package/dist/types/interface/models/reflex-service-deployment.model.d.ts +2 -2
- package/dist/types/interface/models/reflex-service.model.d.ts +0 -1
- package/jest.config.ts +11 -11
- package/package.json +1 -1
- package/src/api/alert-rule.api.test.ts +72 -72
- package/src/api/alert-rule.api.ts +57 -57
- package/src/api/application-insights.api.test.ts +42 -42
- package/src/api/application-insights.api.ts +38 -38
- package/src/api/application-run-settings.api.test.ts +0 -11
- package/src/api/application-run-settings.api.ts +30 -30
- package/src/api/function-access.api.ts +87 -87
- package/src/api/function-insights.api.test.ts +27 -27
- package/src/api/function-insights.api.ts +18 -18
- package/src/api/function-run.api.ts +0 -15
- package/src/api/function-settings.api.ts +0 -22
- package/src/api/function-template.api.test.ts +72 -72
- package/src/api/function-template.api.ts +52 -52
- package/src/api/function-test.api.ts +34 -34
- package/src/api/function-version.api.ts +66 -66
- package/src/api/function.api.test.ts +0 -55
- package/src/api/function.api.ts +62 -62
- package/src/api/health.api.ts +10 -10
- package/src/api/index.ts +26 -27
- package/src/api/route-stats.api.test.ts +45 -45
- package/src/api/route-stats.api.ts +36 -36
- package/src/api/service-completion-webhook.api.test.ts +97 -97
- package/src/api/service-completion-webhook.api.ts +39 -39
- package/src/api/service-configuration.api.ts +16 -16
- package/src/api/service-consumer.api.test.ts +104 -104
- package/src/api/service-consumer.api.ts +90 -90
- package/src/api/service-deployment.api.ts +79 -79
- package/src/api/service-discord-event.api.test.ts +106 -106
- package/src/api/service-discord-event.api.ts +78 -78
- package/src/api/service-discord.api.test.ts +178 -178
- package/src/api/service-discord.api.ts +222 -222
- package/src/api/service-insights.api.test.ts +36 -36
- package/src/api/service-insights.api.ts +42 -42
- package/src/api/service-limits.api.test.ts +100 -100
- package/src/api/service-limits.api.ts +37 -37
- package/src/api/service-openapi.api.test.ts +52 -52
- package/src/api/service-openapi.api.ts +21 -21
- package/src/api/service-route.api.ts +74 -74
- package/src/api/service-task.api.test.ts +140 -140
- package/src/api/service-task.api.ts +141 -141
- package/src/api/service-version.api.ts +54 -54
- package/src/api/service.api.test.ts +1 -6
- package/src/api/service.api.ts +55 -55
- package/src/discord/discord-event-filter-cases.ts +261 -261
- package/src/discord/discord-event-filters.test.ts +91 -91
- package/src/discord/discord-event-filters.ts +95 -95
- package/src/discord/discord-event-intents.test.ts +112 -112
- package/src/discord/discord-event-intents.ts +55 -55
- package/src/discord/index.ts +3 -3
- package/src/index.test.ts +104 -104
- package/src/index.ts +0 -42
- package/src/insights/index.ts +1 -1
- package/src/insights/percentiles.test.ts +75 -75
- package/src/insights/percentiles.ts +37 -37
- package/src/types/enum/discord-host-action.enum.ts +2 -0
- package/src/types/enum/reflex-error-code.enum.ts +0 -16
- package/src/types/interface/api/requests/application-run-settings.request.ts +0 -2
- package/src/types/interface/api/requests/function-run.request.ts +0 -10
- package/src/types/interface/api/requests/function-settings.request.ts +0 -16
- package/src/types/interface/api/requests/index.ts +0 -1
- package/src/types/interface/api/requests/service-discord.request.ts +6 -0
- package/src/types/interface/api/requests/service.request.ts +0 -2
- package/src/types/interface/api/responses/function-run.response.ts +0 -5
- package/src/types/interface/api/responses/function-settings.response.ts +0 -7
- package/src/types/interface/api/responses/index.ts +0 -1
- package/src/types/interface/models/index.ts +0 -2
- package/src/types/interface/models/reflex-discord.model.ts +12 -0
- package/src/types/interface/models/reflex-price-list.model.ts +2 -0
- package/src/types/interface/models/reflex-run-settings.model.ts +0 -11
- package/src/types/interface/models/reflex-run.model.ts +0 -10
- package/src/types/interface/models/reflex-service-deployment.model.ts +2 -4
- package/src/types/interface/models/reflex-service.model.ts +0 -2
- package/tsconfig.check.json +15 -15
- package/tsconfig.json +35 -35
- package/dist/api/storage-surplus.admin.api.d.ts +0 -5
- package/dist/api/storage-surplus.admin.api.js +0 -17
- package/dist/api/storage-surplus.admin.api.js.map +0 -1
- package/dist/types/interface/api/requests/storage-surplus.admin.request.d.ts +0 -8
- package/dist/types/interface/api/requests/storage-surplus.admin.request.js +0 -3
- package/dist/types/interface/api/requests/storage-surplus.admin.request.js.map +0 -1
- package/dist/types/interface/api/responses/storage-surplus.admin.response.d.ts +0 -8
- package/dist/types/interface/api/responses/storage-surplus.admin.response.js +0 -3
- package/dist/types/interface/api/responses/storage-surplus.admin.response.js.map +0 -1
- package/dist/types/interface/models/reflex-run-retention.model.d.ts +0 -13
- package/dist/types/interface/models/reflex-run-retention.model.js +0 -8
- package/dist/types/interface/models/reflex-run-retention.model.js.map +0 -1
- package/dist/types/interface/models/reflex-storage-surplus.model.d.ts +0 -11
- package/dist/types/interface/models/reflex-storage-surplus.model.js +0 -3
- package/dist/types/interface/models/reflex-storage-surplus.model.js.map +0 -1
- package/src/api/storage-surplus.admin.api.test.ts +0 -66
- package/src/api/storage-surplus.admin.api.ts +0 -45
- package/src/types/interface/api/requests/storage-surplus.admin.request.ts +0 -12
- package/src/types/interface/api/responses/storage-surplus.admin.response.ts +0 -10
- package/src/types/interface/models/reflex-run-retention.model.ts +0 -24
- package/src/types/interface/models/reflex-storage-surplus.model.ts +0 -23
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { AbyssReflexCore } from '..';
|
|
2
|
-
import type {
|
|
3
|
-
ICreateServiceDiscordEventBody,
|
|
4
|
-
ICreateServiceDiscordEventParams,
|
|
5
|
-
ICreateServiceDiscordEventResponse,
|
|
6
|
-
IDeleteServiceDiscordEventParams,
|
|
7
|
-
IDeleteServiceDiscordEventResponse,
|
|
8
|
-
IListServiceDiscordEventLogParams,
|
|
9
|
-
IListServiceDiscordEventLogQuery,
|
|
10
|
-
IListServiceDiscordEventLogResponse,
|
|
11
|
-
IListServiceDiscordEventParams,
|
|
12
|
-
IListServiceDiscordEventResponse,
|
|
13
|
-
IUpdateServiceDiscordEventBody,
|
|
14
|
-
IUpdateServiceDiscordEventParams,
|
|
15
|
-
IUpdateServiceDiscordEventResponse,
|
|
16
|
-
} from '../types';
|
|
17
|
-
|
|
18
|
-
const serviceUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
19
|
-
`api/service/${params.applicationId}/${params.serviceId}`;
|
|
20
|
-
|
|
21
|
-
const eventUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
22
|
-
`${serviceUrl(params)}/discord-event`;
|
|
23
|
-
|
|
24
|
-
/** `GET .../discord-event`: the event triggers of the draft of a Discord bot, by name. Needs REFLEX_READ. */
|
|
25
|
-
export const listServiceDiscordEvent = async (
|
|
26
|
-
params: IListServiceDiscordEventParams,
|
|
27
|
-
): Promise<IListServiceDiscordEventResponse> =>
|
|
28
|
-
(await AbyssReflexCore.axios.get<IListServiceDiscordEventResponse>(eventUrl(params))).data;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* `POST .../discord-event`: an event trigger of the draft (25 at most per Service), live once a version
|
|
32
|
-
* holding it is in service. `409 DISCORD_EVENT_CONFLICT` when the name is taken. Needs
|
|
33
|
-
* REFLEX_FUNCTION_UPDATE.
|
|
34
|
-
*/
|
|
35
|
-
export const createServiceDiscordEvent = async (
|
|
36
|
-
params: ICreateServiceDiscordEventParams,
|
|
37
|
-
body: ICreateServiceDiscordEventBody,
|
|
38
|
-
): Promise<ICreateServiceDiscordEventResponse> =>
|
|
39
|
-
(await AbyssReflexCore.axios.post<ICreateServiceDiscordEventResponse>(eventUrl(params), body))
|
|
40
|
-
.data;
|
|
41
|
-
|
|
42
|
-
/** `PATCH .../discord-event/:eventId`: changes the trigger in the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
43
|
-
export const updateServiceDiscordEvent = async (
|
|
44
|
-
params: IUpdateServiceDiscordEventParams,
|
|
45
|
-
body: IUpdateServiceDiscordEventBody,
|
|
46
|
-
): Promise<IUpdateServiceDiscordEventResponse> =>
|
|
47
|
-
(
|
|
48
|
-
await AbyssReflexCore.axios.patch<IUpdateServiceDiscordEventResponse>(
|
|
49
|
-
`${eventUrl(params)}/${params.eventId}`,
|
|
50
|
-
body,
|
|
51
|
-
)
|
|
52
|
-
).data;
|
|
53
|
-
|
|
54
|
-
/** `DELETE .../discord-event/:eventId`: takes the trigger out of the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
55
|
-
export const deleteServiceDiscordEvent = async (
|
|
56
|
-
params: IDeleteServiceDiscordEventParams,
|
|
57
|
-
): Promise<IDeleteServiceDiscordEventResponse> =>
|
|
58
|
-
(
|
|
59
|
-
await AbyssReflexCore.axios.delete<IDeleteServiceDiscordEventResponse>(
|
|
60
|
-
`${eventUrl(params)}/${params.eventId}`,
|
|
61
|
-
)
|
|
62
|
-
).data;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* `GET .../discord-event-log`: the events of the bot in one environment, newest first, paged by cursor: the
|
|
66
|
-
* retained ones (inbox) and a sample of the dropped ones with their reason. Carries `intentsRefused` instead
|
|
67
|
-
* of events while Discord refuses the intents. Needs REFLEX_LOG_READ.
|
|
68
|
-
*/
|
|
69
|
-
export const listServiceDiscordEventLog = async (
|
|
70
|
-
params: IListServiceDiscordEventLogParams,
|
|
71
|
-
query: IListServiceDiscordEventLogQuery,
|
|
72
|
-
): Promise<IListServiceDiscordEventLogResponse> =>
|
|
73
|
-
(
|
|
74
|
-
await AbyssReflexCore.axios.get<IListServiceDiscordEventLogResponse>(
|
|
75
|
-
`${serviceUrl(params)}/discord-event-log`,
|
|
76
|
-
{ params: query },
|
|
77
|
-
)
|
|
78
|
-
).data;
|
|
1
|
+
import { AbyssReflexCore } from '..';
|
|
2
|
+
import type {
|
|
3
|
+
ICreateServiceDiscordEventBody,
|
|
4
|
+
ICreateServiceDiscordEventParams,
|
|
5
|
+
ICreateServiceDiscordEventResponse,
|
|
6
|
+
IDeleteServiceDiscordEventParams,
|
|
7
|
+
IDeleteServiceDiscordEventResponse,
|
|
8
|
+
IListServiceDiscordEventLogParams,
|
|
9
|
+
IListServiceDiscordEventLogQuery,
|
|
10
|
+
IListServiceDiscordEventLogResponse,
|
|
11
|
+
IListServiceDiscordEventParams,
|
|
12
|
+
IListServiceDiscordEventResponse,
|
|
13
|
+
IUpdateServiceDiscordEventBody,
|
|
14
|
+
IUpdateServiceDiscordEventParams,
|
|
15
|
+
IUpdateServiceDiscordEventResponse,
|
|
16
|
+
} from '../types';
|
|
17
|
+
|
|
18
|
+
const serviceUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
19
|
+
`api/service/${params.applicationId}/${params.serviceId}`;
|
|
20
|
+
|
|
21
|
+
const eventUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
22
|
+
`${serviceUrl(params)}/discord-event`;
|
|
23
|
+
|
|
24
|
+
/** `GET .../discord-event`: the event triggers of the draft of a Discord bot, by name. Needs REFLEX_READ. */
|
|
25
|
+
export const listServiceDiscordEvent = async (
|
|
26
|
+
params: IListServiceDiscordEventParams,
|
|
27
|
+
): Promise<IListServiceDiscordEventResponse> =>
|
|
28
|
+
(await AbyssReflexCore.axios.get<IListServiceDiscordEventResponse>(eventUrl(params))).data;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* `POST .../discord-event`: an event trigger of the draft (25 at most per Service), live once a version
|
|
32
|
+
* holding it is in service. `409 DISCORD_EVENT_CONFLICT` when the name is taken. Needs
|
|
33
|
+
* REFLEX_FUNCTION_UPDATE.
|
|
34
|
+
*/
|
|
35
|
+
export const createServiceDiscordEvent = async (
|
|
36
|
+
params: ICreateServiceDiscordEventParams,
|
|
37
|
+
body: ICreateServiceDiscordEventBody,
|
|
38
|
+
): Promise<ICreateServiceDiscordEventResponse> =>
|
|
39
|
+
(await AbyssReflexCore.axios.post<ICreateServiceDiscordEventResponse>(eventUrl(params), body))
|
|
40
|
+
.data;
|
|
41
|
+
|
|
42
|
+
/** `PATCH .../discord-event/:eventId`: changes the trigger in the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
43
|
+
export const updateServiceDiscordEvent = async (
|
|
44
|
+
params: IUpdateServiceDiscordEventParams,
|
|
45
|
+
body: IUpdateServiceDiscordEventBody,
|
|
46
|
+
): Promise<IUpdateServiceDiscordEventResponse> =>
|
|
47
|
+
(
|
|
48
|
+
await AbyssReflexCore.axios.patch<IUpdateServiceDiscordEventResponse>(
|
|
49
|
+
`${eventUrl(params)}/${params.eventId}`,
|
|
50
|
+
body,
|
|
51
|
+
)
|
|
52
|
+
).data;
|
|
53
|
+
|
|
54
|
+
/** `DELETE .../discord-event/:eventId`: takes the trigger out of the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
55
|
+
export const deleteServiceDiscordEvent = async (
|
|
56
|
+
params: IDeleteServiceDiscordEventParams,
|
|
57
|
+
): Promise<IDeleteServiceDiscordEventResponse> =>
|
|
58
|
+
(
|
|
59
|
+
await AbyssReflexCore.axios.delete<IDeleteServiceDiscordEventResponse>(
|
|
60
|
+
`${eventUrl(params)}/${params.eventId}`,
|
|
61
|
+
)
|
|
62
|
+
).data;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* `GET .../discord-event-log`: the events of the bot in one environment, newest first, paged by cursor: the
|
|
66
|
+
* retained ones (inbox) and a sample of the dropped ones with their reason. Carries `intentsRefused` instead
|
|
67
|
+
* of events while Discord refuses the intents. Needs REFLEX_LOG_READ.
|
|
68
|
+
*/
|
|
69
|
+
export const listServiceDiscordEventLog = async (
|
|
70
|
+
params: IListServiceDiscordEventLogParams,
|
|
71
|
+
query: IListServiceDiscordEventLogQuery,
|
|
72
|
+
): Promise<IListServiceDiscordEventLogResponse> =>
|
|
73
|
+
(
|
|
74
|
+
await AbyssReflexCore.axios.get<IListServiceDiscordEventLogResponse>(
|
|
75
|
+
`${serviceUrl(params)}/discord-event-log`,
|
|
76
|
+
{ params: query },
|
|
77
|
+
)
|
|
78
|
+
).data;
|
|
@@ -1,178 +1,178 @@
|
|
|
1
|
-
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
import { AbyssReflexCore, DiscordComponentKind, DiscordOptionType } from '..';
|
|
3
|
-
|
|
4
|
-
const APP = 'app-1';
|
|
5
|
-
const SVC = 'svc-1';
|
|
6
|
-
const BASE = `api/service/${APP}/${SVC}`;
|
|
7
|
-
const SERVICE = { applicationId: APP, serviceId: SVC };
|
|
8
|
-
|
|
9
|
-
interface Call {
|
|
10
|
-
label: string;
|
|
11
|
-
method: string;
|
|
12
|
-
url: string;
|
|
13
|
-
body?: unknown;
|
|
14
|
-
run: () => Promise<unknown>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const discord = () => AbyssReflexCore.sdk.service.discord;
|
|
18
|
-
|
|
19
|
-
const command = {
|
|
20
|
-
name: 'ping',
|
|
21
|
-
description: 'Answers pong',
|
|
22
|
-
options: [
|
|
23
|
-
{
|
|
24
|
-
type: DiscordOptionType.STRING,
|
|
25
|
-
name: 'word',
|
|
26
|
-
description: 'A word',
|
|
27
|
-
required: true,
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
functionId: 'fn-1',
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const calls: Call[] = [
|
|
34
|
-
{
|
|
35
|
-
label: 'command.list',
|
|
36
|
-
method: 'get',
|
|
37
|
-
url: `${BASE}/discord/command`,
|
|
38
|
-
run: () => discord().command.list(SERVICE),
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
label: 'command.create',
|
|
42
|
-
method: 'post',
|
|
43
|
-
url: `${BASE}/discord/command`,
|
|
44
|
-
body: command,
|
|
45
|
-
run: () => discord().command.create(SERVICE, command),
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
label: 'command.update',
|
|
49
|
-
method: 'patch',
|
|
50
|
-
url: `${BASE}/discord/command/c-1`,
|
|
51
|
-
body: { description: 'Answers pong again' },
|
|
52
|
-
run: () =>
|
|
53
|
-
discord().command.update(
|
|
54
|
-
{ ...SERVICE, commandId: 'c-1' },
|
|
55
|
-
{ description: 'Answers pong again' },
|
|
56
|
-
),
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
label: 'command.delete',
|
|
60
|
-
method: 'delete',
|
|
61
|
-
url: `${BASE}/discord/command/c-1`,
|
|
62
|
-
run: () => discord().command.delete({ ...SERVICE, commandId: 'c-1' }),
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
label: 'component.list',
|
|
66
|
-
method: 'get',
|
|
67
|
-
url: `${BASE}/discord/component`,
|
|
68
|
-
run: () => discord().component.list(SERVICE),
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
label: 'component.create',
|
|
72
|
-
method: 'post',
|
|
73
|
-
url: `${BASE}/discord/component`,
|
|
74
|
-
body: {
|
|
75
|
-
customIdPrefix: 'confirm',
|
|
76
|
-
kind: DiscordComponentKind.BUTTON_OR_SELECT,
|
|
77
|
-
functionId: 'fn-1',
|
|
78
|
-
},
|
|
79
|
-
run: () =>
|
|
80
|
-
discord().component.create(SERVICE, {
|
|
81
|
-
customIdPrefix: 'confirm',
|
|
82
|
-
kind: DiscordComponentKind.BUTTON_OR_SELECT,
|
|
83
|
-
functionId: 'fn-1',
|
|
84
|
-
}),
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
label: 'component.update',
|
|
88
|
-
method: 'patch',
|
|
89
|
-
url: `${BASE}/discord/component/k-1`,
|
|
90
|
-
body: { kind: DiscordComponentKind.MODAL },
|
|
91
|
-
run: () =>
|
|
92
|
-
discord().component.update(
|
|
93
|
-
{ ...SERVICE, componentId: 'k-1' },
|
|
94
|
-
{ kind: DiscordComponentKind.MODAL },
|
|
95
|
-
),
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
label: 'component.delete',
|
|
99
|
-
method: 'delete',
|
|
100
|
-
url: `${BASE}/discord/component/k-1`,
|
|
101
|
-
run: () => discord().component.delete({ ...SERVICE, componentId: 'k-1' }),
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
label: 'connection.get',
|
|
105
|
-
method: 'get',
|
|
106
|
-
url: `${BASE}/discord/connection`,
|
|
107
|
-
run: () => discord().connection.get(SERVICE),
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
label: 'connection.setTokenSecret',
|
|
111
|
-
method: 'put',
|
|
112
|
-
url: `${BASE}/discord/connection`,
|
|
113
|
-
body: { discordTokenSecretId: 'secret-1' },
|
|
114
|
-
run: () => discord().connection.setTokenSecret(SERVICE, { discordTokenSecretId: 'secret-1' }),
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
label: 'connection.setEnvironment',
|
|
118
|
-
method: 'put',
|
|
119
|
-
url: `${BASE}/discord/connection/e-1`,
|
|
120
|
-
body: { testGuildId: '123456789012345678', invitePermissions: '2048' },
|
|
121
|
-
run: () =>
|
|
122
|
-
discord().connection.setEnvironment(
|
|
123
|
-
{ ...SERVICE, environmentId: 'e-1' },
|
|
124
|
-
{ testGuildId: '123456789012345678', invitePermissions: '2048' },
|
|
125
|
-
),
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
label: 'connection.setAllocation',
|
|
129
|
-
method: 'put',
|
|
130
|
-
url: `${BASE}/discord/connection/e-1/allocation`,
|
|
131
|
-
body: { lots: 3 },
|
|
132
|
-
run: () =>
|
|
133
|
-
discord().connection.setAllocation({ ...SERVICE, environmentId: 'e-1' }, { lots: 3 }),
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
label: 'connection.check',
|
|
137
|
-
method: 'post',
|
|
138
|
-
url: `${BASE}/discord/connection/e-1/check`,
|
|
139
|
-
body: {},
|
|
140
|
-
run: () => discord().connection.check({ ...SERVICE, environmentId: 'e-1' }),
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
label: 'sync',
|
|
144
|
-
method: 'post',
|
|
145
|
-
url: `${BASE}/deployment/e-1/discord-sync`,
|
|
146
|
-
body: {},
|
|
147
|
-
run: () => discord().sync({ ...SERVICE, environmentId: 'e-1' }),
|
|
148
|
-
},
|
|
149
|
-
];
|
|
150
|
-
|
|
151
|
-
describe('AbyssReflexCore Discord bot routes', () => {
|
|
152
|
-
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
153
|
-
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
beforeAll(() => {
|
|
157
|
-
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
158
|
-
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
beforeEach(() => adapter.mockClear());
|
|
162
|
-
|
|
163
|
-
it.each(calls)('$label calls $method $url', async (call) => {
|
|
164
|
-
await call.run();
|
|
165
|
-
|
|
166
|
-
const config = adapter.mock.calls[0][0];
|
|
167
|
-
expect(config.method).toBe(call.method);
|
|
168
|
-
expect(config.url).toBe(call.url);
|
|
169
|
-
expect(config.baseURL).toBe('http://reflex.test/');
|
|
170
|
-
if (call.body !== undefined) {
|
|
171
|
-
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it('exposes no route twice', () => {
|
|
176
|
-
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
177
|
-
});
|
|
178
|
-
});
|
|
1
|
+
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
+
import { AbyssReflexCore, DiscordComponentKind, DiscordOptionType } from '..';
|
|
3
|
+
|
|
4
|
+
const APP = 'app-1';
|
|
5
|
+
const SVC = 'svc-1';
|
|
6
|
+
const BASE = `api/service/${APP}/${SVC}`;
|
|
7
|
+
const SERVICE = { applicationId: APP, serviceId: SVC };
|
|
8
|
+
|
|
9
|
+
interface Call {
|
|
10
|
+
label: string;
|
|
11
|
+
method: string;
|
|
12
|
+
url: string;
|
|
13
|
+
body?: unknown;
|
|
14
|
+
run: () => Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const discord = () => AbyssReflexCore.sdk.service.discord;
|
|
18
|
+
|
|
19
|
+
const command = {
|
|
20
|
+
name: 'ping',
|
|
21
|
+
description: 'Answers pong',
|
|
22
|
+
options: [
|
|
23
|
+
{
|
|
24
|
+
type: DiscordOptionType.STRING,
|
|
25
|
+
name: 'word',
|
|
26
|
+
description: 'A word',
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
functionId: 'fn-1',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const calls: Call[] = [
|
|
34
|
+
{
|
|
35
|
+
label: 'command.list',
|
|
36
|
+
method: 'get',
|
|
37
|
+
url: `${BASE}/discord/command`,
|
|
38
|
+
run: () => discord().command.list(SERVICE),
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: 'command.create',
|
|
42
|
+
method: 'post',
|
|
43
|
+
url: `${BASE}/discord/command`,
|
|
44
|
+
body: command,
|
|
45
|
+
run: () => discord().command.create(SERVICE, command),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: 'command.update',
|
|
49
|
+
method: 'patch',
|
|
50
|
+
url: `${BASE}/discord/command/c-1`,
|
|
51
|
+
body: { description: 'Answers pong again' },
|
|
52
|
+
run: () =>
|
|
53
|
+
discord().command.update(
|
|
54
|
+
{ ...SERVICE, commandId: 'c-1' },
|
|
55
|
+
{ description: 'Answers pong again' },
|
|
56
|
+
),
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
label: 'command.delete',
|
|
60
|
+
method: 'delete',
|
|
61
|
+
url: `${BASE}/discord/command/c-1`,
|
|
62
|
+
run: () => discord().command.delete({ ...SERVICE, commandId: 'c-1' }),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: 'component.list',
|
|
66
|
+
method: 'get',
|
|
67
|
+
url: `${BASE}/discord/component`,
|
|
68
|
+
run: () => discord().component.list(SERVICE),
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
label: 'component.create',
|
|
72
|
+
method: 'post',
|
|
73
|
+
url: `${BASE}/discord/component`,
|
|
74
|
+
body: {
|
|
75
|
+
customIdPrefix: 'confirm',
|
|
76
|
+
kind: DiscordComponentKind.BUTTON_OR_SELECT,
|
|
77
|
+
functionId: 'fn-1',
|
|
78
|
+
},
|
|
79
|
+
run: () =>
|
|
80
|
+
discord().component.create(SERVICE, {
|
|
81
|
+
customIdPrefix: 'confirm',
|
|
82
|
+
kind: DiscordComponentKind.BUTTON_OR_SELECT,
|
|
83
|
+
functionId: 'fn-1',
|
|
84
|
+
}),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
label: 'component.update',
|
|
88
|
+
method: 'patch',
|
|
89
|
+
url: `${BASE}/discord/component/k-1`,
|
|
90
|
+
body: { kind: DiscordComponentKind.MODAL },
|
|
91
|
+
run: () =>
|
|
92
|
+
discord().component.update(
|
|
93
|
+
{ ...SERVICE, componentId: 'k-1' },
|
|
94
|
+
{ kind: DiscordComponentKind.MODAL },
|
|
95
|
+
),
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
label: 'component.delete',
|
|
99
|
+
method: 'delete',
|
|
100
|
+
url: `${BASE}/discord/component/k-1`,
|
|
101
|
+
run: () => discord().component.delete({ ...SERVICE, componentId: 'k-1' }),
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
label: 'connection.get',
|
|
105
|
+
method: 'get',
|
|
106
|
+
url: `${BASE}/discord/connection`,
|
|
107
|
+
run: () => discord().connection.get(SERVICE),
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
label: 'connection.setTokenSecret',
|
|
111
|
+
method: 'put',
|
|
112
|
+
url: `${BASE}/discord/connection`,
|
|
113
|
+
body: { discordTokenSecretId: 'secret-1' },
|
|
114
|
+
run: () => discord().connection.setTokenSecret(SERVICE, { discordTokenSecretId: 'secret-1' }),
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
label: 'connection.setEnvironment',
|
|
118
|
+
method: 'put',
|
|
119
|
+
url: `${BASE}/discord/connection/e-1`,
|
|
120
|
+
body: { testGuildId: '123456789012345678', invitePermissions: '2048' },
|
|
121
|
+
run: () =>
|
|
122
|
+
discord().connection.setEnvironment(
|
|
123
|
+
{ ...SERVICE, environmentId: 'e-1' },
|
|
124
|
+
{ testGuildId: '123456789012345678', invitePermissions: '2048' },
|
|
125
|
+
),
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
label: 'connection.setAllocation',
|
|
129
|
+
method: 'put',
|
|
130
|
+
url: `${BASE}/discord/connection/e-1/allocation`,
|
|
131
|
+
body: { lots: 3 },
|
|
132
|
+
run: () =>
|
|
133
|
+
discord().connection.setAllocation({ ...SERVICE, environmentId: 'e-1' }, { lots: 3 }),
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
label: 'connection.check',
|
|
137
|
+
method: 'post',
|
|
138
|
+
url: `${BASE}/discord/connection/e-1/check`,
|
|
139
|
+
body: {},
|
|
140
|
+
run: () => discord().connection.check({ ...SERVICE, environmentId: 'e-1' }),
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
label: 'sync',
|
|
144
|
+
method: 'post',
|
|
145
|
+
url: `${BASE}/deployment/e-1/discord-sync`,
|
|
146
|
+
body: {},
|
|
147
|
+
run: () => discord().sync({ ...SERVICE, environmentId: 'e-1' }),
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
describe('AbyssReflexCore Discord bot routes', () => {
|
|
152
|
+
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
153
|
+
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
beforeAll(() => {
|
|
157
|
+
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
158
|
+
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
beforeEach(() => adapter.mockClear());
|
|
162
|
+
|
|
163
|
+
it.each(calls)('$label calls $method $url', async (call) => {
|
|
164
|
+
await call.run();
|
|
165
|
+
|
|
166
|
+
const config = adapter.mock.calls[0][0];
|
|
167
|
+
expect(config.method).toBe(call.method);
|
|
168
|
+
expect(config.url).toBe(call.url);
|
|
169
|
+
expect(config.baseURL).toBe('http://reflex.test/');
|
|
170
|
+
if (call.body !== undefined) {
|
|
171
|
+
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('exposes no route twice', () => {
|
|
176
|
+
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
177
|
+
});
|
|
178
|
+
});
|