@abyss-project/reflex 5.9.0 → 5.11.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/.prettierrc +5 -5
- package/README.md +15 -15
- package/dist/api/function-access.api.d.ts +5 -1
- package/dist/api/function-access.api.js +9 -1
- package/dist/api/function-access.api.js.map +1 -1
- package/dist/api/function-template.api.d.ts +5 -0
- package/dist/api/function-template.api.js +15 -0
- package/dist/api/function-template.api.js.map +1 -0
- package/dist/api/function-version.api.d.ts +3 -2
- package/dist/api/function-version.api.js +6 -2
- package/dist/api/function-version.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/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/types/enum/access-request-status.enum.d.ts +5 -0
- package/dist/types/enum/access-request-status.enum.js +10 -0
- package/dist/types/enum/access-request-status.enum.js.map +1 -0
- 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/log-drop-cause.enum.d.ts +4 -0
- package/dist/types/enum/log-drop-cause.enum.js +9 -0
- package/dist/types/enum/log-drop-cause.enum.js.map +1 -0
- package/dist/types/interface/api/requests/function-access.request.d.ts +21 -0
- package/dist/types/interface/api/requests/function-template.request.d.ts +23 -0
- package/dist/types/interface/api/requests/function-template.request.js +3 -0
- package/dist/types/interface/api/requests/function-template.request.js.map +1 -0
- package/dist/types/interface/api/requests/function-version.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/responses/function-access.response.d.ts +21 -1
- package/dist/types/interface/api/responses/function-settings.response.d.ts +1 -0
- package/dist/types/interface/api/responses/function-template.response.d.ts +16 -0
- package/dist/types/interface/api/responses/function-template.response.js +3 -0
- package/dist/types/interface/api/responses/function-template.response.js.map +1 -0
- package/dist/types/interface/api/responses/function-version.response.d.ts +7 -2
- 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/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-access-request.model.d.ts +13 -0
- package/dist/types/interface/models/reflex-access-request.model.js +3 -0
- package/dist/types/interface/models/reflex-access-request.model.js.map +1 -0
- package/dist/types/interface/models/reflex-function-template.model.d.ts +13 -0
- package/dist/types/interface/models/reflex-function-template.model.js +3 -0
- package/dist/types/interface/models/reflex-function-template.model.js.map +1 -0
- package/dist/types/interface/models/reflex-function-version.model.d.ts +3 -0
- package/dist/types/interface/models/reflex-function.model.d.ts +9 -0
- package/dist/types/interface/models/reflex-run.model.d.ts +2 -1
- package/dist/types/interface/models/reflex-run.model.js.map +1 -1
- package/jest.config.ts +11 -11
- package/package.json +10 -15
- 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 +51 -51
- package/src/api/application-run-settings.api.ts +30 -30
- package/src/api/function-access.api.ts +52 -1
- 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 +38 -38
- package/src/api/function-settings.api.ts +74 -74
- package/src/api/function-template.api.test.ts +72 -0
- package/src/api/function-template.api.ts +52 -0
- package/src/api/function-test.api.ts +34 -34
- package/src/api/function-version.api.ts +20 -2
- package/src/api/function.api.test.ts +47 -6
- package/src/api/function.api.ts +62 -62
- package/src/api/health.api.ts +10 -10
- package/src/api/index.ts +1 -0
- package/src/api/route-stats.api.test.ts +45 -45
- package/src/api/route-stats.api.ts +36 -36
- package/src/api/service-configuration.api.ts +16 -16
- 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 +197 -197
- package/src/api/service-discord.api.ts +241 -241
- package/src/api/service-insights.api.test.ts +36 -36
- package/src/api/service-insights.api.ts +42 -42
- package/src/api/service-route.api.ts +72 -72
- 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 +215 -215
- 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 +87 -87
- package/src/index.ts +24 -0
- 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/access-grant-status.enum.ts +12 -12
- package/src/types/enum/access-kind.enum.ts +7 -7
- package/src/types/enum/access-request-status.enum.ts +11 -0
- package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
- package/src/types/enum/configuration-read-as.enum.ts +5 -5
- package/src/types/enum/discord-activity-type.enum.ts +9 -9
- package/src/types/enum/discord-channel-type.enum.ts +11 -11
- package/src/types/enum/discord-component-kind.enum.ts +7 -7
- package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
- package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
- package/src/types/enum/discord-event-status.enum.ts +13 -13
- package/src/types/enum/discord-event-type.enum.ts +7 -7
- package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
- package/src/types/enum/discord-gateway-state.enum.ts +11 -11
- package/src/types/enum/discord-host-action.enum.ts +35 -35
- package/src/types/enum/discord-locale.enum.ts +35 -35
- package/src/types/enum/discord-option-type.enum.ts +12 -12
- package/src/types/enum/discord-presence-status.enum.ts +8 -8
- 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/execution-mode.enum.ts +9 -9
- package/src/types/enum/execution-profile.enum.ts +20 -20
- package/src/types/enum/execution-settings-source.enum.ts +9 -9
- package/src/types/enum/health-status.enum.ts +4 -4
- package/src/types/enum/index.ts +2 -0
- package/src/types/enum/insights-period.enum.ts +8 -8
- package/src/types/enum/log-cap-mode.enum.ts +6 -6
- package/src/types/enum/log-drop-cause.enum.ts +8 -0
- package/src/types/enum/reflex-alert-metric.enum.ts +5 -5
- package/src/types/enum/reflex-alert-notification-state.enum.ts +6 -6
- package/src/types/enum/reflex-alert-scope.enum.ts +6 -6
- package/src/types/enum/reflex-error-code.enum.ts +43 -43
- package/src/types/enum/route-method.enum.ts +9 -9
- package/src/types/enum/run-log-level.enum.ts +6 -6
- package/src/types/enum/run-mode.enum.ts +11 -11
- package/src/types/enum/run-status.enum.ts +11 -11
- package/src/types/enum/run-step-status.enum.ts +7 -7
- package/src/types/enum/schedule-sync-status.enum.ts +6 -6
- package/src/types/enum/scheduled-run-failure-code.enum.ts +12 -12
- package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
- package/src/types/enum/scheduled-run-status.enum.ts +17 -17
- package/src/types/enum/service-deployment-action.enum.ts +11 -11
- package/src/types/enum/service-deployment-status.enum.ts +5 -5
- package/src/types/enum/service-type.enum.ts +9 -9
- package/src/types/enum/service-version-change-kind.enum.ts +6 -6
- package/src/types/enum/trace-effect-type.enum.ts +12 -12
- package/src/types/enum/trigger-access-mode.enum.ts +12 -12
- package/src/types/enum/trigger-kind.enum.ts +8 -8
- package/src/types/enum/vault-value-source.enum.ts +12 -12
- package/src/types/enum/vault-visibility.enum.ts +5 -5
- package/src/types/index.ts +2 -2
- package/src/types/interface/api/index.ts +3 -3
- package/src/types/interface/api/requests/function-access.request.ts +26 -0
- package/src/types/interface/api/requests/function-template.request.ts +29 -0
- package/src/types/interface/api/requests/function-version.request.ts +18 -0
- package/src/types/interface/api/requests/index.ts +1 -0
- package/src/types/interface/api/response.ts +4 -4
- package/src/types/interface/api/responses/function-access.response.ts +29 -1
- package/src/types/interface/api/responses/function-settings.response.ts +2 -0
- package/src/types/interface/api/responses/function-template.response.ts +21 -0
- package/src/types/interface/api/responses/function-version.response.ts +12 -1
- package/src/types/interface/api/responses/index.ts +1 -0
- package/src/types/interface/health.response.ts +7 -7
- package/src/types/interface/index.ts +3 -3
- package/src/types/interface/models/index.ts +2 -0
- package/src/types/interface/models/reflex-access-request.model.ts +15 -0
- package/src/types/interface/models/reflex-function-template.model.ts +18 -0
- package/src/types/interface/models/reflex-function-version.model.ts +5 -0
- package/src/types/interface/models/reflex-function.model.ts +14 -0
- package/src/types/interface/models/reflex-run.model.ts +6 -3
- package/tsconfig.check.json +15 -15
- package/tsconfig.json +35 -35
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { AbyssReflexCore } from '..';
|
|
2
|
-
import type {
|
|
3
|
-
ICreateServiceRouteBody,
|
|
4
|
-
ICreateServiceRouteParams,
|
|
5
|
-
ICreateServiceRouteResponse,
|
|
6
|
-
IDeleteServiceRouteParams,
|
|
7
|
-
IDeleteServiceRouteResponse,
|
|
8
|
-
IListServiceRouteParams,
|
|
9
|
-
IListServiceRouteResponse,
|
|
10
|
-
IRotateServiceRouteParams,
|
|
11
|
-
IRotateServiceRouteResponse,
|
|
12
|
-
IUpdateServiceRouteBody,
|
|
13
|
-
IUpdateServiceRouteParams,
|
|
14
|
-
IUpdateServiceRouteResponse,
|
|
15
|
-
} from '../types';
|
|
16
|
-
|
|
17
|
-
const routeUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
18
|
-
`api/service/${params.applicationId}/${params.serviceId}/route`;
|
|
19
|
-
|
|
20
|
-
/** `GET .../route`: the routes of the draft, by path then method. Needs REFLEX_READ. */
|
|
21
|
-
export const listServiceRoute = async (
|
|
22
|
-
params: IListServiceRouteParams,
|
|
23
|
-
): Promise<IListServiceRouteResponse> =>
|
|
24
|
-
(await AbyssReflexCore.axios.get<IListServiceRouteResponse>(routeUrl(params))).data;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* `POST .../route`: a route of the draft, served once a version holding it is in service. The key or
|
|
28
|
-
* signing secret comes back once. `409 ROUTE_CONFLICT` when it would hide another route. Needs
|
|
29
|
-
* REFLEX_FUNCTION_UPDATE.
|
|
30
|
-
*/
|
|
31
|
-
export const createServiceRoute = async (
|
|
32
|
-
params: ICreateServiceRouteParams,
|
|
33
|
-
body: ICreateServiceRouteBody,
|
|
34
|
-
): Promise<ICreateServiceRouteResponse> =>
|
|
35
|
-
(await AbyssReflexCore.axios.post<ICreateServiceRouteResponse>(routeUrl(params), body)).data;
|
|
36
|
-
|
|
37
|
-
/** `PATCH .../route/:routeId`: changes the route in the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
38
|
-
export const updateServiceRoute = async (
|
|
39
|
-
params: IUpdateServiceRouteParams,
|
|
40
|
-
body: IUpdateServiceRouteBody,
|
|
41
|
-
): Promise<IUpdateServiceRouteResponse> =>
|
|
42
|
-
(
|
|
43
|
-
await AbyssReflexCore.axios.patch<IUpdateServiceRouteResponse>(
|
|
44
|
-
`${routeUrl(params)}/${params.routeId}`,
|
|
45
|
-
body,
|
|
46
|
-
)
|
|
47
|
-
).data;
|
|
48
|
-
|
|
49
|
-
/** `DELETE .../route/:routeId`: takes the route out of the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
50
|
-
export const deleteServiceRoute = async (
|
|
51
|
-
params: IDeleteServiceRouteParams,
|
|
52
|
-
): Promise<IDeleteServiceRouteResponse> =>
|
|
53
|
-
(
|
|
54
|
-
await AbyssReflexCore.axios.delete<IDeleteServiceRouteResponse>(
|
|
55
|
-
`${routeUrl(params)}/${params.routeId}`,
|
|
56
|
-
)
|
|
57
|
-
).data;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* `POST .../route/:routeId/rotate`: a new key or signing secret, shown once, served at once wherever the
|
|
61
|
-
* route is in service. Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION when a production
|
|
62
|
-
* environment serves the route.
|
|
63
|
-
*/
|
|
64
|
-
export const rotateServiceRoute = async (
|
|
65
|
-
params: IRotateServiceRouteParams,
|
|
66
|
-
): Promise<IRotateServiceRouteResponse> =>
|
|
67
|
-
(
|
|
68
|
-
await AbyssReflexCore.axios.post<IRotateServiceRouteResponse>(
|
|
69
|
-
`${routeUrl(params)}/${params.routeId}/rotate`,
|
|
70
|
-
{},
|
|
71
|
-
)
|
|
72
|
-
).data;
|
|
1
|
+
import { AbyssReflexCore } from '..';
|
|
2
|
+
import type {
|
|
3
|
+
ICreateServiceRouteBody,
|
|
4
|
+
ICreateServiceRouteParams,
|
|
5
|
+
ICreateServiceRouteResponse,
|
|
6
|
+
IDeleteServiceRouteParams,
|
|
7
|
+
IDeleteServiceRouteResponse,
|
|
8
|
+
IListServiceRouteParams,
|
|
9
|
+
IListServiceRouteResponse,
|
|
10
|
+
IRotateServiceRouteParams,
|
|
11
|
+
IRotateServiceRouteResponse,
|
|
12
|
+
IUpdateServiceRouteBody,
|
|
13
|
+
IUpdateServiceRouteParams,
|
|
14
|
+
IUpdateServiceRouteResponse,
|
|
15
|
+
} from '../types';
|
|
16
|
+
|
|
17
|
+
const routeUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
18
|
+
`api/service/${params.applicationId}/${params.serviceId}/route`;
|
|
19
|
+
|
|
20
|
+
/** `GET .../route`: the routes of the draft, by path then method. Needs REFLEX_READ. */
|
|
21
|
+
export const listServiceRoute = async (
|
|
22
|
+
params: IListServiceRouteParams,
|
|
23
|
+
): Promise<IListServiceRouteResponse> =>
|
|
24
|
+
(await AbyssReflexCore.axios.get<IListServiceRouteResponse>(routeUrl(params))).data;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* `POST .../route`: a route of the draft, served once a version holding it is in service. The key or
|
|
28
|
+
* signing secret comes back once. `409 ROUTE_CONFLICT` when it would hide another route. Needs
|
|
29
|
+
* REFLEX_FUNCTION_UPDATE.
|
|
30
|
+
*/
|
|
31
|
+
export const createServiceRoute = async (
|
|
32
|
+
params: ICreateServiceRouteParams,
|
|
33
|
+
body: ICreateServiceRouteBody,
|
|
34
|
+
): Promise<ICreateServiceRouteResponse> =>
|
|
35
|
+
(await AbyssReflexCore.axios.post<ICreateServiceRouteResponse>(routeUrl(params), body)).data;
|
|
36
|
+
|
|
37
|
+
/** `PATCH .../route/:routeId`: changes the route in the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
38
|
+
export const updateServiceRoute = async (
|
|
39
|
+
params: IUpdateServiceRouteParams,
|
|
40
|
+
body: IUpdateServiceRouteBody,
|
|
41
|
+
): Promise<IUpdateServiceRouteResponse> =>
|
|
42
|
+
(
|
|
43
|
+
await AbyssReflexCore.axios.patch<IUpdateServiceRouteResponse>(
|
|
44
|
+
`${routeUrl(params)}/${params.routeId}`,
|
|
45
|
+
body,
|
|
46
|
+
)
|
|
47
|
+
).data;
|
|
48
|
+
|
|
49
|
+
/** `DELETE .../route/:routeId`: takes the route out of the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
50
|
+
export const deleteServiceRoute = async (
|
|
51
|
+
params: IDeleteServiceRouteParams,
|
|
52
|
+
): Promise<IDeleteServiceRouteResponse> =>
|
|
53
|
+
(
|
|
54
|
+
await AbyssReflexCore.axios.delete<IDeleteServiceRouteResponse>(
|
|
55
|
+
`${routeUrl(params)}/${params.routeId}`,
|
|
56
|
+
)
|
|
57
|
+
).data;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* `POST .../route/:routeId/rotate`: a new key or signing secret, shown once, served at once wherever the
|
|
61
|
+
* route is in service. Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION when a production
|
|
62
|
+
* environment serves the route.
|
|
63
|
+
*/
|
|
64
|
+
export const rotateServiceRoute = async (
|
|
65
|
+
params: IRotateServiceRouteParams,
|
|
66
|
+
): Promise<IRotateServiceRouteResponse> =>
|
|
67
|
+
(
|
|
68
|
+
await AbyssReflexCore.axios.post<IRotateServiceRouteResponse>(
|
|
69
|
+
`${routeUrl(params)}/${params.routeId}/rotate`,
|
|
70
|
+
{},
|
|
71
|
+
)
|
|
72
|
+
).data;
|
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
import { AbyssReflexCore, REFLEX_TASK_LIMITS } 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
|
-
params?: unknown;
|
|
15
|
-
run: () => Promise<unknown>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const task = () => AbyssReflexCore.sdk.service.task;
|
|
19
|
-
|
|
20
|
-
const created = {
|
|
21
|
-
name: 'daily-report',
|
|
22
|
-
functionId: 'fn-1',
|
|
23
|
-
schedule: '0 9 * * *',
|
|
24
|
-
timezone: 'Europe/Paris',
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const calls: Call[] = [
|
|
28
|
-
{
|
|
29
|
-
label: 'list',
|
|
30
|
-
method: 'get',
|
|
31
|
-
url: `${BASE}/task`,
|
|
32
|
-
run: () => task().list(SERVICE),
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
label: 'create',
|
|
36
|
-
method: 'post',
|
|
37
|
-
url: `${BASE}/task`,
|
|
38
|
-
body: created,
|
|
39
|
-
run: () => task().create(SERVICE, created),
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
label: 'update',
|
|
43
|
-
method: 'patch',
|
|
44
|
-
url: `${BASE}/task/t-1`,
|
|
45
|
-
body: { schedule: null },
|
|
46
|
-
run: () => task().update({ ...SERVICE, taskId: 't-1' }, { schedule: null }),
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
label: 'delete',
|
|
50
|
-
method: 'delete',
|
|
51
|
-
url: `${BASE}/task/t-1`,
|
|
52
|
-
run: () => task().delete({ ...SERVICE, taskId: 't-1' }),
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
label: 'testRun',
|
|
56
|
-
method: 'post',
|
|
57
|
-
url: `${BASE}/task/t-1/test-run`,
|
|
58
|
-
body: { environmentId: 'e-1' },
|
|
59
|
-
run: () => task().testRun({ ...SERVICE, taskId: 't-1' }, { environmentId: 'e-1' }),
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
label: 'scheduledRun.list',
|
|
63
|
-
method: 'get',
|
|
64
|
-
url: `${BASE}/task/t-1/environment/e-1/scheduled-run`,
|
|
65
|
-
params: { limit: 20, offset: 40 },
|
|
66
|
-
run: () =>
|
|
67
|
-
task().scheduledRun.list(
|
|
68
|
-
{ ...SERVICE, taskId: 't-1', environmentId: 'e-1' },
|
|
69
|
-
{ limit: 20, offset: 40 },
|
|
70
|
-
),
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
label: 'delayedRun.list',
|
|
74
|
-
method: 'get',
|
|
75
|
-
url: `${BASE}/environment/e-1/delayed-run`,
|
|
76
|
-
run: () => task().delayedRun.list({ ...SERVICE, environmentId: 'e-1' }),
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
label: 'delayedRun.cancel',
|
|
80
|
-
method: 'delete',
|
|
81
|
-
url: `${BASE}/environment/e-1/delayed-run/d-1`,
|
|
82
|
-
run: () => task().delayedRun.cancel({ ...SERVICE, environmentId: 'e-1', delayedRunId: 'd-1' }),
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
label: 'sync',
|
|
86
|
-
method: 'post',
|
|
87
|
-
url: `${BASE}/deployment/e-1/schedule-sync`,
|
|
88
|
-
body: {},
|
|
89
|
-
run: () => task().sync({ ...SERVICE, environmentId: 'e-1' }),
|
|
90
|
-
},
|
|
91
|
-
];
|
|
92
|
-
|
|
93
|
-
describe('AbyssReflexCore task routes', () => {
|
|
94
|
-
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
95
|
-
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
beforeAll(() => {
|
|
99
|
-
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
100
|
-
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
beforeEach(() => adapter.mockClear());
|
|
104
|
-
|
|
105
|
-
it.each(calls)('$label calls $method $url', async (call) => {
|
|
106
|
-
await call.run();
|
|
107
|
-
|
|
108
|
-
const config = adapter.mock.calls[0][0];
|
|
109
|
-
expect(config.method).toBe(call.method);
|
|
110
|
-
expect(config.url).toBe(call.url);
|
|
111
|
-
expect(config.baseURL).toBe('http://reflex.test/');
|
|
112
|
-
if (call.body !== undefined) {
|
|
113
|
-
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
114
|
-
}
|
|
115
|
-
if (call.params !== undefined) {
|
|
116
|
-
expect(config.params).toEqual(call.params);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('exposes no route twice', () => {
|
|
121
|
-
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('carries the bounds of the tasks and of their delayed runs', () => {
|
|
125
|
-
expect(REFLEX_TASK_LIMITS).toMatchObject({
|
|
126
|
-
maxTasksPerService: 20,
|
|
127
|
-
nameMaxLength: 32,
|
|
128
|
-
payloadMaxLength: 4096,
|
|
129
|
-
delayMinSeconds: 1,
|
|
130
|
-
delayMaxDays: 30,
|
|
131
|
-
recurringToleranceMinutes: 5,
|
|
132
|
-
delayedToleranceMinutes: 60,
|
|
133
|
-
maxAttempts: 3,
|
|
134
|
-
scheduledRunPageMax: 50,
|
|
135
|
-
});
|
|
136
|
-
expect(REFLEX_TASK_LIMITS.namePattern.test('daily-report_2')).toBe(true);
|
|
137
|
-
expect(REFLEX_TASK_LIMITS.namePattern.test('Daily')).toBe(false);
|
|
138
|
-
expect(REFLEX_TASK_LIMITS.namePattern.test('a'.repeat(33))).toBe(false);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
1
|
+
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
+
import { AbyssReflexCore, REFLEX_TASK_LIMITS } 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
|
+
params?: unknown;
|
|
15
|
+
run: () => Promise<unknown>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const task = () => AbyssReflexCore.sdk.service.task;
|
|
19
|
+
|
|
20
|
+
const created = {
|
|
21
|
+
name: 'daily-report',
|
|
22
|
+
functionId: 'fn-1',
|
|
23
|
+
schedule: '0 9 * * *',
|
|
24
|
+
timezone: 'Europe/Paris',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const calls: Call[] = [
|
|
28
|
+
{
|
|
29
|
+
label: 'list',
|
|
30
|
+
method: 'get',
|
|
31
|
+
url: `${BASE}/task`,
|
|
32
|
+
run: () => task().list(SERVICE),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: 'create',
|
|
36
|
+
method: 'post',
|
|
37
|
+
url: `${BASE}/task`,
|
|
38
|
+
body: created,
|
|
39
|
+
run: () => task().create(SERVICE, created),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
label: 'update',
|
|
43
|
+
method: 'patch',
|
|
44
|
+
url: `${BASE}/task/t-1`,
|
|
45
|
+
body: { schedule: null },
|
|
46
|
+
run: () => task().update({ ...SERVICE, taskId: 't-1' }, { schedule: null }),
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
label: 'delete',
|
|
50
|
+
method: 'delete',
|
|
51
|
+
url: `${BASE}/task/t-1`,
|
|
52
|
+
run: () => task().delete({ ...SERVICE, taskId: 't-1' }),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: 'testRun',
|
|
56
|
+
method: 'post',
|
|
57
|
+
url: `${BASE}/task/t-1/test-run`,
|
|
58
|
+
body: { environmentId: 'e-1' },
|
|
59
|
+
run: () => task().testRun({ ...SERVICE, taskId: 't-1' }, { environmentId: 'e-1' }),
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: 'scheduledRun.list',
|
|
63
|
+
method: 'get',
|
|
64
|
+
url: `${BASE}/task/t-1/environment/e-1/scheduled-run`,
|
|
65
|
+
params: { limit: 20, offset: 40 },
|
|
66
|
+
run: () =>
|
|
67
|
+
task().scheduledRun.list(
|
|
68
|
+
{ ...SERVICE, taskId: 't-1', environmentId: 'e-1' },
|
|
69
|
+
{ limit: 20, offset: 40 },
|
|
70
|
+
),
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
label: 'delayedRun.list',
|
|
74
|
+
method: 'get',
|
|
75
|
+
url: `${BASE}/environment/e-1/delayed-run`,
|
|
76
|
+
run: () => task().delayedRun.list({ ...SERVICE, environmentId: 'e-1' }),
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
label: 'delayedRun.cancel',
|
|
80
|
+
method: 'delete',
|
|
81
|
+
url: `${BASE}/environment/e-1/delayed-run/d-1`,
|
|
82
|
+
run: () => task().delayedRun.cancel({ ...SERVICE, environmentId: 'e-1', delayedRunId: 'd-1' }),
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
label: 'sync',
|
|
86
|
+
method: 'post',
|
|
87
|
+
url: `${BASE}/deployment/e-1/schedule-sync`,
|
|
88
|
+
body: {},
|
|
89
|
+
run: () => task().sync({ ...SERVICE, environmentId: 'e-1' }),
|
|
90
|
+
},
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
describe('AbyssReflexCore task routes', () => {
|
|
94
|
+
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
95
|
+
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
beforeAll(() => {
|
|
99
|
+
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
100
|
+
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
beforeEach(() => adapter.mockClear());
|
|
104
|
+
|
|
105
|
+
it.each(calls)('$label calls $method $url', async (call) => {
|
|
106
|
+
await call.run();
|
|
107
|
+
|
|
108
|
+
const config = adapter.mock.calls[0][0];
|
|
109
|
+
expect(config.method).toBe(call.method);
|
|
110
|
+
expect(config.url).toBe(call.url);
|
|
111
|
+
expect(config.baseURL).toBe('http://reflex.test/');
|
|
112
|
+
if (call.body !== undefined) {
|
|
113
|
+
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
114
|
+
}
|
|
115
|
+
if (call.params !== undefined) {
|
|
116
|
+
expect(config.params).toEqual(call.params);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('exposes no route twice', () => {
|
|
121
|
+
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('carries the bounds of the tasks and of their delayed runs', () => {
|
|
125
|
+
expect(REFLEX_TASK_LIMITS).toMatchObject({
|
|
126
|
+
maxTasksPerService: 20,
|
|
127
|
+
nameMaxLength: 32,
|
|
128
|
+
payloadMaxLength: 4096,
|
|
129
|
+
delayMinSeconds: 1,
|
|
130
|
+
delayMaxDays: 30,
|
|
131
|
+
recurringToleranceMinutes: 5,
|
|
132
|
+
delayedToleranceMinutes: 60,
|
|
133
|
+
maxAttempts: 3,
|
|
134
|
+
scheduledRunPageMax: 50,
|
|
135
|
+
});
|
|
136
|
+
expect(REFLEX_TASK_LIMITS.namePattern.test('daily-report_2')).toBe(true);
|
|
137
|
+
expect(REFLEX_TASK_LIMITS.namePattern.test('Daily')).toBe(false);
|
|
138
|
+
expect(REFLEX_TASK_LIMITS.namePattern.test('a'.repeat(33))).toBe(false);
|
|
139
|
+
});
|
|
140
|
+
});
|