@abyss-project/reflex 6.4.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/.eslintrc.js +32 -32
- package/.prettierrc +5 -5
- package/README.md +15 -15
- package/dist/api/function-run.api.d.ts +2 -1
- package/dist/api/function-run.api.js +3 -1
- package/dist/api/function-run.api.js.map +1 -1
- 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 +1 -0
- package/dist/index.js +1 -0
- 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 +10 -0
- package/dist/types/enum/reflex-error-code.enum.js +10 -0
- package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
- package/dist/types/interface/api/requests/function-run.request.d.ts +8 -0
- package/dist/types/interface/api/requests/service-discord.request.d.ts +7 -3
- package/dist/types/interface/api/responses/function-run.response.d.ts +8 -0
- 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.model.d.ts +4 -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/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 +62 -62
- 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 +19 -0
- package/src/api/function-settings.api.ts +96 -96
- 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 +346 -346
- package/src/api/function.api.ts +62 -62
- package/src/api/health.api.ts +10 -10
- 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 +220 -220
- package/src/api/service.api.ts +55 -55
- package/src/api/storage-surplus.admin.api.test.ts +66 -66
- package/src/api/storage-surplus.admin.api.ts +45 -45
- 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 +299 -261
- package/src/discord/discord-event-filters.test.ts +120 -91
- package/src/discord/discord-event-filters.ts +103 -95
- package/src/discord/discord-event-intents.test.ts +139 -112
- package/src/discord/discord-event-intents.ts +80 -55
- package/src/discord/index.ts +4 -3
- package/src/index.test.ts +104 -104
- package/src/index.ts +2 -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/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/discord-host-action.enum.ts +37 -37
- package/src/types/enum/index.ts +2 -0
- package/src/types/enum/reflex-error-code.enum.ts +112 -89
- package/src/types/interface/api/requests/application-run-settings.request.ts +13 -13
- package/src/types/interface/api/requests/function-run.request.ts +53 -42
- package/src/types/interface/api/requests/function-settings.request.ts +50 -50
- package/src/types/interface/api/requests/index.ts +25 -25
- package/src/types/interface/api/requests/service-discord.request.ts +168 -155
- package/src/types/interface/api/requests/service.request.ts +48 -48
- package/src/types/interface/api/requests/storage-surplus.admin.request.ts +12 -12
- package/src/types/interface/api/responses/function-run.response.ts +35 -23
- package/src/types/interface/api/responses/function-settings.response.ts +57 -57
- package/src/types/interface/api/responses/index.ts +25 -25
- package/src/types/interface/api/responses/storage-surplus.admin.response.ts +10 -10
- package/src/types/interface/models/index.ts +29 -29
- package/src/types/interface/models/reflex-discord.model.ts +249 -208
- package/src/types/interface/models/reflex-price-list.model.ts +22 -22
- package/src/types/interface/models/reflex-run-retention.model.ts +24 -24
- package/src/types/interface/models/reflex-run-settings.model.ts +39 -39
- package/src/types/interface/models/reflex-run.model.ts +317 -309
- package/src/types/interface/models/reflex-service-deployment.model.ts +48 -48
- package/src/types/interface/models/reflex-service.model.ts +47 -47
- package/src/types/interface/models/reflex-storage-surplus.model.ts +23 -23
- package/tsconfig.check.json +15 -15
- package/tsconfig.json +35 -35
|
@@ -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
|
+
});
|
|
@@ -1,141 +1,141 @@
|
|
|
1
|
-
import { AbyssReflexCore } from '..';
|
|
2
|
-
import type {
|
|
3
|
-
ICancelServiceDelayedRunParams,
|
|
4
|
-
ICancelServiceDelayedRunResponse,
|
|
5
|
-
ICreateServiceTaskBody,
|
|
6
|
-
ICreateServiceTaskParams,
|
|
7
|
-
ICreateServiceTaskResponse,
|
|
8
|
-
IDeleteServiceTaskParams,
|
|
9
|
-
IDeleteServiceTaskResponse,
|
|
10
|
-
IListServiceDelayedRunParams,
|
|
11
|
-
IListServiceDelayedRunResponse,
|
|
12
|
-
IListServiceTaskParams,
|
|
13
|
-
IListServiceTaskResponse,
|
|
14
|
-
IListServiceTaskScheduledRunParams,
|
|
15
|
-
IListServiceTaskScheduledRunQuery,
|
|
16
|
-
IListServiceTaskScheduledRunResponse,
|
|
17
|
-
IRetryServiceScheduleSyncParams,
|
|
18
|
-
IRetryServiceScheduleSyncResponse,
|
|
19
|
-
ITestRunServiceTaskBody,
|
|
20
|
-
ITestRunServiceTaskParams,
|
|
21
|
-
ITestRunServiceTaskResponse,
|
|
22
|
-
IUpdateServiceTaskBody,
|
|
23
|
-
IUpdateServiceTaskParams,
|
|
24
|
-
IUpdateServiceTaskResponse,
|
|
25
|
-
} from '../types';
|
|
26
|
-
|
|
27
|
-
const serviceUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
28
|
-
`api/service/${params.applicationId}/${params.serviceId}`;
|
|
29
|
-
|
|
30
|
-
const taskUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
31
|
-
`${serviceUrl(params)}/task`;
|
|
32
|
-
|
|
33
|
-
const delayedRunUrl = (params: {
|
|
34
|
-
applicationId: string;
|
|
35
|
-
serviceId: string;
|
|
36
|
-
environmentId: string;
|
|
37
|
-
}): string => `${serviceUrl(params)}/environment/${params.environmentId}/delayed-run`;
|
|
38
|
-
|
|
39
|
-
/** `GET .../task`: the tasks of the draft of the Service, by name. Needs REFLEX_READ. */
|
|
40
|
-
export const listServiceTask = async (
|
|
41
|
-
params: IListServiceTaskParams,
|
|
42
|
-
): Promise<IListServiceTaskResponse> =>
|
|
43
|
-
(await AbyssReflexCore.axios.get<IListServiceTaskResponse>(taskUrl(params))).data;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* `POST .../task`: a task of the draft, scheduled with Flow once a version holding it is in service.
|
|
47
|
-
* Refused when the name is taken, the cron ticks more than once a minute, the time zone is unknown or
|
|
48
|
-
* the Service already has `REFLEX_TASK_LIMITS.maxTasksPerService` tasks. Needs REFLEX_FUNCTION_UPDATE.
|
|
49
|
-
*/
|
|
50
|
-
export const createServiceTask = async (
|
|
51
|
-
params: ICreateServiceTaskParams,
|
|
52
|
-
body: ICreateServiceTaskBody,
|
|
53
|
-
): Promise<ICreateServiceTaskResponse> =>
|
|
54
|
-
(await AbyssReflexCore.axios.post<ICreateServiceTaskResponse>(taskUrl(params), body)).data;
|
|
55
|
-
|
|
56
|
-
/** `PATCH .../task/:taskId`: changes the task in the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
57
|
-
export const updateServiceTask = async (
|
|
58
|
-
params: IUpdateServiceTaskParams,
|
|
59
|
-
body: IUpdateServiceTaskBody,
|
|
60
|
-
): Promise<IUpdateServiceTaskResponse> =>
|
|
61
|
-
(
|
|
62
|
-
await AbyssReflexCore.axios.patch<IUpdateServiceTaskResponse>(
|
|
63
|
-
`${taskUrl(params)}/${params.taskId}`,
|
|
64
|
-
body,
|
|
65
|
-
)
|
|
66
|
-
).data;
|
|
67
|
-
|
|
68
|
-
/** `DELETE .../task/:taskId`: takes the task out of the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
69
|
-
export const deleteServiceTask = async (
|
|
70
|
-
params: IDeleteServiceTaskParams,
|
|
71
|
-
): Promise<IDeleteServiceTaskResponse> =>
|
|
72
|
-
(
|
|
73
|
-
await AbyssReflexCore.axios.delete<IDeleteServiceTaskResponse>(
|
|
74
|
-
`${taskUrl(params)}/${params.taskId}`,
|
|
75
|
-
)
|
|
76
|
-
).data;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* `POST .../task/:taskId/test-run`: runs the task now as a test run of its function in the environment
|
|
80
|
-
* `body.environmentId`, with a `SCHEDULE` input; nothing is queued. Needs REFLEX_TEST_RUN.
|
|
81
|
-
*/
|
|
82
|
-
export const testRunServiceTask = async (
|
|
83
|
-
params: ITestRunServiceTaskParams,
|
|
84
|
-
body: ITestRunServiceTaskBody,
|
|
85
|
-
): Promise<ITestRunServiceTaskResponse> =>
|
|
86
|
-
(
|
|
87
|
-
await AbyssReflexCore.axios.post<ITestRunServiceTaskResponse>(
|
|
88
|
-
`${taskUrl(params)}/${params.taskId}/test-run`,
|
|
89
|
-
body,
|
|
90
|
-
)
|
|
91
|
-
).data;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* `GET .../task/:taskId/environment/:environmentId/scheduled-run`: the runs of the task in the environment, every
|
|
95
|
-
* status (EXPIRED, SKIPPED, CANCELLED and FAILED with their `failureCode` included), newest due first, paged by
|
|
96
|
-
* `limit` (50 at most) and `offset`. Needs REFLEX_READ.
|
|
97
|
-
*/
|
|
98
|
-
export const listServiceTaskScheduledRun = async (
|
|
99
|
-
params: IListServiceTaskScheduledRunParams,
|
|
100
|
-
query: IListServiceTaskScheduledRunQuery = {},
|
|
101
|
-
): Promise<IListServiceTaskScheduledRunResponse> =>
|
|
102
|
-
(
|
|
103
|
-
await AbyssReflexCore.axios.get<IListServiceTaskScheduledRunResponse>(
|
|
104
|
-
`${taskUrl(params)}/${params.taskId}/environment/${params.environmentId}/scheduled-run`,
|
|
105
|
-
{ params: query },
|
|
106
|
-
)
|
|
107
|
-
).data;
|
|
108
|
-
|
|
109
|
-
/** `GET .../environment/:environmentId/delayed-run`: the first 100 pending delayed runs of the environment. Needs REFLEX_READ. */
|
|
110
|
-
export const listServiceDelayedRun = async (
|
|
111
|
-
params: IListServiceDelayedRunParams,
|
|
112
|
-
): Promise<IListServiceDelayedRunResponse> =>
|
|
113
|
-
(await AbyssReflexCore.axios.get<IListServiceDelayedRunResponse>(delayedRunUrl(params))).data;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* `DELETE .../environment/:environmentId/delayed-run/:delayedRunId`: cancels a pending delayed run.
|
|
117
|
-
* Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION in a production environment.
|
|
118
|
-
*/
|
|
119
|
-
export const cancelServiceDelayedRun = async (
|
|
120
|
-
params: ICancelServiceDelayedRunParams,
|
|
121
|
-
): Promise<ICancelServiceDelayedRunResponse> =>
|
|
122
|
-
(
|
|
123
|
-
await AbyssReflexCore.axios.delete<ICancelServiceDelayedRunResponse>(
|
|
124
|
-
`${delayedRunUrl(params)}/${params.delayedRunId}`,
|
|
125
|
-
)
|
|
126
|
-
).data;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* `POST .../deployment/:environmentId/schedule-sync`: synchronizes the cron tasks of the version in
|
|
130
|
-
* service with Flow again, without a new version. Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION
|
|
131
|
-
* in a production environment.
|
|
132
|
-
*/
|
|
133
|
-
export const retryServiceScheduleSync = async (
|
|
134
|
-
params: IRetryServiceScheduleSyncParams,
|
|
135
|
-
): Promise<IRetryServiceScheduleSyncResponse> =>
|
|
136
|
-
(
|
|
137
|
-
await AbyssReflexCore.axios.post<IRetryServiceScheduleSyncResponse>(
|
|
138
|
-
`${serviceUrl(params)}/deployment/${params.environmentId}/schedule-sync`,
|
|
139
|
-
{},
|
|
140
|
-
)
|
|
141
|
-
).data;
|
|
1
|
+
import { AbyssReflexCore } from '..';
|
|
2
|
+
import type {
|
|
3
|
+
ICancelServiceDelayedRunParams,
|
|
4
|
+
ICancelServiceDelayedRunResponse,
|
|
5
|
+
ICreateServiceTaskBody,
|
|
6
|
+
ICreateServiceTaskParams,
|
|
7
|
+
ICreateServiceTaskResponse,
|
|
8
|
+
IDeleteServiceTaskParams,
|
|
9
|
+
IDeleteServiceTaskResponse,
|
|
10
|
+
IListServiceDelayedRunParams,
|
|
11
|
+
IListServiceDelayedRunResponse,
|
|
12
|
+
IListServiceTaskParams,
|
|
13
|
+
IListServiceTaskResponse,
|
|
14
|
+
IListServiceTaskScheduledRunParams,
|
|
15
|
+
IListServiceTaskScheduledRunQuery,
|
|
16
|
+
IListServiceTaskScheduledRunResponse,
|
|
17
|
+
IRetryServiceScheduleSyncParams,
|
|
18
|
+
IRetryServiceScheduleSyncResponse,
|
|
19
|
+
ITestRunServiceTaskBody,
|
|
20
|
+
ITestRunServiceTaskParams,
|
|
21
|
+
ITestRunServiceTaskResponse,
|
|
22
|
+
IUpdateServiceTaskBody,
|
|
23
|
+
IUpdateServiceTaskParams,
|
|
24
|
+
IUpdateServiceTaskResponse,
|
|
25
|
+
} from '../types';
|
|
26
|
+
|
|
27
|
+
const serviceUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
28
|
+
`api/service/${params.applicationId}/${params.serviceId}`;
|
|
29
|
+
|
|
30
|
+
const taskUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
31
|
+
`${serviceUrl(params)}/task`;
|
|
32
|
+
|
|
33
|
+
const delayedRunUrl = (params: {
|
|
34
|
+
applicationId: string;
|
|
35
|
+
serviceId: string;
|
|
36
|
+
environmentId: string;
|
|
37
|
+
}): string => `${serviceUrl(params)}/environment/${params.environmentId}/delayed-run`;
|
|
38
|
+
|
|
39
|
+
/** `GET .../task`: the tasks of the draft of the Service, by name. Needs REFLEX_READ. */
|
|
40
|
+
export const listServiceTask = async (
|
|
41
|
+
params: IListServiceTaskParams,
|
|
42
|
+
): Promise<IListServiceTaskResponse> =>
|
|
43
|
+
(await AbyssReflexCore.axios.get<IListServiceTaskResponse>(taskUrl(params))).data;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* `POST .../task`: a task of the draft, scheduled with Flow once a version holding it is in service.
|
|
47
|
+
* Refused when the name is taken, the cron ticks more than once a minute, the time zone is unknown or
|
|
48
|
+
* the Service already has `REFLEX_TASK_LIMITS.maxTasksPerService` tasks. Needs REFLEX_FUNCTION_UPDATE.
|
|
49
|
+
*/
|
|
50
|
+
export const createServiceTask = async (
|
|
51
|
+
params: ICreateServiceTaskParams,
|
|
52
|
+
body: ICreateServiceTaskBody,
|
|
53
|
+
): Promise<ICreateServiceTaskResponse> =>
|
|
54
|
+
(await AbyssReflexCore.axios.post<ICreateServiceTaskResponse>(taskUrl(params), body)).data;
|
|
55
|
+
|
|
56
|
+
/** `PATCH .../task/:taskId`: changes the task in the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
57
|
+
export const updateServiceTask = async (
|
|
58
|
+
params: IUpdateServiceTaskParams,
|
|
59
|
+
body: IUpdateServiceTaskBody,
|
|
60
|
+
): Promise<IUpdateServiceTaskResponse> =>
|
|
61
|
+
(
|
|
62
|
+
await AbyssReflexCore.axios.patch<IUpdateServiceTaskResponse>(
|
|
63
|
+
`${taskUrl(params)}/${params.taskId}`,
|
|
64
|
+
body,
|
|
65
|
+
)
|
|
66
|
+
).data;
|
|
67
|
+
|
|
68
|
+
/** `DELETE .../task/:taskId`: takes the task out of the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
69
|
+
export const deleteServiceTask = async (
|
|
70
|
+
params: IDeleteServiceTaskParams,
|
|
71
|
+
): Promise<IDeleteServiceTaskResponse> =>
|
|
72
|
+
(
|
|
73
|
+
await AbyssReflexCore.axios.delete<IDeleteServiceTaskResponse>(
|
|
74
|
+
`${taskUrl(params)}/${params.taskId}`,
|
|
75
|
+
)
|
|
76
|
+
).data;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* `POST .../task/:taskId/test-run`: runs the task now as a test run of its function in the environment
|
|
80
|
+
* `body.environmentId`, with a `SCHEDULE` input; nothing is queued. Needs REFLEX_TEST_RUN.
|
|
81
|
+
*/
|
|
82
|
+
export const testRunServiceTask = async (
|
|
83
|
+
params: ITestRunServiceTaskParams,
|
|
84
|
+
body: ITestRunServiceTaskBody,
|
|
85
|
+
): Promise<ITestRunServiceTaskResponse> =>
|
|
86
|
+
(
|
|
87
|
+
await AbyssReflexCore.axios.post<ITestRunServiceTaskResponse>(
|
|
88
|
+
`${taskUrl(params)}/${params.taskId}/test-run`,
|
|
89
|
+
body,
|
|
90
|
+
)
|
|
91
|
+
).data;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* `GET .../task/:taskId/environment/:environmentId/scheduled-run`: the runs of the task in the environment, every
|
|
95
|
+
* status (EXPIRED, SKIPPED, CANCELLED and FAILED with their `failureCode` included), newest due first, paged by
|
|
96
|
+
* `limit` (50 at most) and `offset`. Needs REFLEX_READ.
|
|
97
|
+
*/
|
|
98
|
+
export const listServiceTaskScheduledRun = async (
|
|
99
|
+
params: IListServiceTaskScheduledRunParams,
|
|
100
|
+
query: IListServiceTaskScheduledRunQuery = {},
|
|
101
|
+
): Promise<IListServiceTaskScheduledRunResponse> =>
|
|
102
|
+
(
|
|
103
|
+
await AbyssReflexCore.axios.get<IListServiceTaskScheduledRunResponse>(
|
|
104
|
+
`${taskUrl(params)}/${params.taskId}/environment/${params.environmentId}/scheduled-run`,
|
|
105
|
+
{ params: query },
|
|
106
|
+
)
|
|
107
|
+
).data;
|
|
108
|
+
|
|
109
|
+
/** `GET .../environment/:environmentId/delayed-run`: the first 100 pending delayed runs of the environment. Needs REFLEX_READ. */
|
|
110
|
+
export const listServiceDelayedRun = async (
|
|
111
|
+
params: IListServiceDelayedRunParams,
|
|
112
|
+
): Promise<IListServiceDelayedRunResponse> =>
|
|
113
|
+
(await AbyssReflexCore.axios.get<IListServiceDelayedRunResponse>(delayedRunUrl(params))).data;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* `DELETE .../environment/:environmentId/delayed-run/:delayedRunId`: cancels a pending delayed run.
|
|
117
|
+
* Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION in a production environment.
|
|
118
|
+
*/
|
|
119
|
+
export const cancelServiceDelayedRun = async (
|
|
120
|
+
params: ICancelServiceDelayedRunParams,
|
|
121
|
+
): Promise<ICancelServiceDelayedRunResponse> =>
|
|
122
|
+
(
|
|
123
|
+
await AbyssReflexCore.axios.delete<ICancelServiceDelayedRunResponse>(
|
|
124
|
+
`${delayedRunUrl(params)}/${params.delayedRunId}`,
|
|
125
|
+
)
|
|
126
|
+
).data;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* `POST .../deployment/:environmentId/schedule-sync`: synchronizes the cron tasks of the version in
|
|
130
|
+
* service with Flow again, without a new version. Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION
|
|
131
|
+
* in a production environment.
|
|
132
|
+
*/
|
|
133
|
+
export const retryServiceScheduleSync = async (
|
|
134
|
+
params: IRetryServiceScheduleSyncParams,
|
|
135
|
+
): Promise<IRetryServiceScheduleSyncResponse> =>
|
|
136
|
+
(
|
|
137
|
+
await AbyssReflexCore.axios.post<IRetryServiceScheduleSyncResponse>(
|
|
138
|
+
`${serviceUrl(params)}/deployment/${params.environmentId}/schedule-sync`,
|
|
139
|
+
{},
|
|
140
|
+
)
|
|
141
|
+
).data;
|