@abyss-project/reflex 5.1.0 → 5.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/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/service-task.api.d.ts +9 -0
- package/dist/api/service-task.api.js +24 -0
- package/dist/api/service-task.api.js.map +1 -0
- 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 +14 -0
- package/dist/index.js +14 -0
- package/dist/index.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 +2 -1
- package/dist/types/enum/reflex-error-code.enum.js +1 -0
- package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
- package/dist/types/enum/schedule-sync-status.enum.d.ts +5 -0
- package/dist/types/enum/schedule-sync-status.enum.js +10 -0
- package/dist/types/enum/schedule-sync-status.enum.js.map +1 -0
- package/dist/types/enum/scheduled-run-origin.enum.d.ts +4 -0
- package/dist/types/enum/scheduled-run-origin.enum.js +9 -0
- package/dist/types/enum/scheduled-run-origin.enum.js.map +1 -0
- package/dist/types/interface/api/requests/function-run.request.d.ts +2 -0
- package/dist/types/interface/api/requests/function-test.request.d.ts +4 -0
- package/dist/types/interface/api/requests/index.d.ts +1 -0
- package/dist/types/interface/api/requests/index.js +1 -0
- package/dist/types/interface/api/requests/index.js.map +1 -1
- package/dist/types/interface/api/requests/service-task.request.d.ts +54 -0
- package/dist/types/interface/api/requests/service-task.request.js +3 -0
- package/dist/types/interface/api/requests/service-task.request.js.map +1 -0
- package/dist/types/interface/api/requests/service-version.request.d.ts +4 -0
- package/dist/types/interface/api/responses/index.d.ts +1 -0
- package/dist/types/interface/api/responses/index.js +1 -0
- package/dist/types/interface/api/responses/index.js.map +1 -1
- package/dist/types/interface/api/responses/service-task.response.d.ts +31 -0
- package/dist/types/interface/api/responses/service-task.response.js +3 -0
- package/dist/types/interface/api/responses/service-task.response.js.map +1 -0
- package/dist/types/interface/api/responses/service-version.response.d.ts +13 -1
- package/dist/types/interface/models/index.d.ts +1 -0
- package/dist/types/interface/models/index.js +1 -0
- package/dist/types/interface/models/index.js.map +1 -1
- package/dist/types/interface/models/reflex-run.model.d.ts +3 -1
- package/dist/types/interface/models/reflex-service-deployment.model.d.ts +4 -1
- package/dist/types/interface/models/reflex-service-version.model.d.ts +2 -0
- package/dist/types/interface/models/reflex-task.model.d.ts +35 -0
- package/dist/types/interface/models/reflex-task.model.js +15 -0
- package/dist/types/interface/models/reflex-task.model.js.map +1 -0
- package/package.json +10 -15
- package/src/api/index.ts +1 -0
- package/src/api/service-task.api.test.ts +124 -0
- package/src/api/service-task.api.ts +122 -0
- package/src/api/service-version.api.ts +15 -0
- package/src/api/service.api.test.ts +6 -0
- package/src/index.ts +29 -0
- 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/configuration-read-as.enum.ts +5 -5
- package/src/types/enum/discord-activity-type.enum.ts +9 -9
- package/src/types/enum/discord-component-kind.enum.ts +7 -7
- package/src/types/enum/discord-gateway-failure-code.enum.ts +9 -9
- package/src/types/enum/discord-gateway-state.enum.ts +11 -11
- 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 +31 -29
- package/src/types/enum/reflex-error-code.enum.ts +39 -37
- 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 -0
- package/src/types/enum/scheduled-run-origin.enum.ts +5 -0
- 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/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 +25 -25
- package/src/types/interface/api/requests/function-run.request.ts +30 -26
- package/src/types/interface/api/requests/function-settings.request.ts +27 -27
- package/src/types/interface/api/requests/function-test.request.ts +39 -24
- package/src/types/interface/api/requests/function-version.request.ts +20 -20
- package/src/types/interface/api/requests/function.request.ts +36 -36
- package/src/types/interface/api/requests/index.ts +13 -12
- package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
- package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
- package/src/types/interface/api/requests/service-discord.request.ts +128 -128
- package/src/types/interface/api/requests/service-route.request.ts +44 -44
- package/src/types/interface/api/requests/service-task.request.ts +66 -0
- package/src/types/interface/api/requests/service-version.request.ts +24 -19
- package/src/types/interface/api/requests/service.request.ts +46 -46
- package/src/types/interface/api/response.ts +4 -4
- package/src/types/interface/api/responses/function-access.response.ts +17 -17
- package/src/types/interface/api/responses/function-run.response.ts +18 -18
- package/src/types/interface/api/responses/function-settings.response.ts +36 -36
- package/src/types/interface/api/responses/function-test.response.ts +12 -12
- package/src/types/interface/api/responses/function-version.response.ts +31 -31
- package/src/types/interface/api/responses/function.response.ts +25 -25
- package/src/types/interface/api/responses/index.ts +13 -12
- package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
- package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
- package/src/types/interface/api/responses/service-discord.response.ts +72 -72
- package/src/types/interface/api/responses/service-route.response.ts +31 -31
- package/src/types/interface/api/responses/service-task.response.ts +48 -0
- package/src/types/interface/api/responses/service-version.response.ts +91 -62
- package/src/types/interface/api/responses/service.response.ts +31 -31
- package/src/types/interface/health.response.ts +7 -7
- package/src/types/interface/index.ts +3 -3
- package/src/types/interface/models/index.ts +15 -14
- package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
- package/src/types/interface/models/reflex-definition.model.ts +31 -31
- package/src/types/interface/models/reflex-discord.model.ts +146 -146
- package/src/types/interface/models/reflex-execution-settings.model.ts +50 -50
- package/src/types/interface/models/reflex-function-version.model.ts +14 -14
- package/src/types/interface/models/reflex-function.model.ts +16 -16
- package/src/types/interface/models/reflex-price-list.model.ts +20 -20
- package/src/types/interface/models/reflex-route.model.ts +19 -19
- package/src/types/interface/models/reflex-run.model.ts +179 -173
- package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
- package/src/types/interface/models/reflex-service-deployment.model.ts +46 -40
- package/src/types/interface/models/reflex-service-version.model.ts +58 -55
- package/src/types/interface/models/reflex-service.model.ts +45 -45
- package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
- package/src/types/interface/models/reflex-task.model.ts +61 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflex-task.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/reflex-task.model.ts"],"names":[],"mappings":";;;AACa,QAAA,kBAAkB,GAAG;IAEhC,WAAW,EAAE,oBAAoB;IACjC,kBAAkB,EAAE,EAAE;IACtB,aAAa,EAAE,EAAE;IAEjB,gBAAgB,EAAE,IAAI;IAEtB,eAAe,EAAE,CAAC;IAElB,YAAY,EAAE,EAAE;IAEhB,yBAAyB,EAAE,CAAC;IAE5B,uBAAuB,EAAE,EAAE;IAE3B,WAAW,EAAE,CAAC;CACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abyss-project/reflex",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "Core package to interact with AbyssReflex",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"main": "dist/index.js",
|
|
9
|
-
"types": "dist/index.d.ts"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"lint": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --fix",
|
|
13
|
-
"lint:check": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --max-warnings 0",
|
|
14
|
-
"tsc": "tsc",
|
|
15
|
-
"build": "tsc",
|
|
16
|
-
"test": "jest",
|
|
17
|
-
"prepublishOnly": "tsc && node ../../scripts/check-sdk-surface.cjs",
|
|
18
|
-
"dev": "tsc --watch"
|
|
19
|
-
},
|
|
20
7
|
"repository": {
|
|
21
8
|
"type": "git",
|
|
22
9
|
"url": "https://gitlab.com/abyss-group/abyss-reflex.git"
|
|
@@ -45,5 +32,13 @@
|
|
|
45
32
|
"ts-jest": "^29.1.0",
|
|
46
33
|
"ts-node": "^10.4.0",
|
|
47
34
|
"typescript": "5.9.3"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"lint": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --fix",
|
|
38
|
+
"lint:check": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --max-warnings 0",
|
|
39
|
+
"tsc": "tsc",
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"test": "jest",
|
|
42
|
+
"dev": "tsc --watch"
|
|
48
43
|
}
|
|
49
|
-
}
|
|
44
|
+
}
|
package/src/api/index.ts
CHANGED
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
run: () => Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const task = () => AbyssReflexCore.sdk.service.task;
|
|
18
|
+
|
|
19
|
+
const created = {
|
|
20
|
+
name: 'daily-report',
|
|
21
|
+
functionId: 'fn-1',
|
|
22
|
+
schedule: '0 9 * * *',
|
|
23
|
+
timezone: 'Europe/Paris',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const calls: Call[] = [
|
|
27
|
+
{
|
|
28
|
+
label: 'list',
|
|
29
|
+
method: 'get',
|
|
30
|
+
url: `${BASE}/task`,
|
|
31
|
+
run: () => task().list(SERVICE),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: 'create',
|
|
35
|
+
method: 'post',
|
|
36
|
+
url: `${BASE}/task`,
|
|
37
|
+
body: created,
|
|
38
|
+
run: () => task().create(SERVICE, created),
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: 'update',
|
|
42
|
+
method: 'patch',
|
|
43
|
+
url: `${BASE}/task/t-1`,
|
|
44
|
+
body: { schedule: null },
|
|
45
|
+
run: () => task().update({ ...SERVICE, taskId: 't-1' }, { schedule: null }),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: 'delete',
|
|
49
|
+
method: 'delete',
|
|
50
|
+
url: `${BASE}/task/t-1`,
|
|
51
|
+
run: () => task().delete({ ...SERVICE, taskId: 't-1' }),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label: 'testRun',
|
|
55
|
+
method: 'post',
|
|
56
|
+
url: `${BASE}/task/t-1/test-run`,
|
|
57
|
+
body: { environmentId: 'e-1' },
|
|
58
|
+
run: () => task().testRun({ ...SERVICE, taskId: 't-1' }, { environmentId: 'e-1' }),
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: 'delayedRun.list',
|
|
62
|
+
method: 'get',
|
|
63
|
+
url: `${BASE}/environment/e-1/delayed-run`,
|
|
64
|
+
run: () => task().delayedRun.list({ ...SERVICE, environmentId: 'e-1' }),
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
label: 'delayedRun.cancel',
|
|
68
|
+
method: 'delete',
|
|
69
|
+
url: `${BASE}/environment/e-1/delayed-run/d-1`,
|
|
70
|
+
run: () => task().delayedRun.cancel({ ...SERVICE, environmentId: 'e-1', delayedRunId: 'd-1' }),
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
label: 'sync',
|
|
74
|
+
method: 'post',
|
|
75
|
+
url: `${BASE}/deployment/e-1/schedule-sync`,
|
|
76
|
+
body: {},
|
|
77
|
+
run: () => task().sync({ ...SERVICE, environmentId: 'e-1' }),
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
describe('AbyssReflexCore task routes', () => {
|
|
82
|
+
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
83
|
+
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
beforeAll(() => {
|
|
87
|
+
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
88
|
+
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
beforeEach(() => adapter.mockClear());
|
|
92
|
+
|
|
93
|
+
it.each(calls)('$label calls $method $url', async (call) => {
|
|
94
|
+
await call.run();
|
|
95
|
+
|
|
96
|
+
const config = adapter.mock.calls[0][0];
|
|
97
|
+
expect(config.method).toBe(call.method);
|
|
98
|
+
expect(config.url).toBe(call.url);
|
|
99
|
+
expect(config.baseURL).toBe('http://reflex.test/');
|
|
100
|
+
if (call.body !== undefined) {
|
|
101
|
+
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('exposes no route twice', () => {
|
|
106
|
+
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('carries the bounds of the tasks and of their delayed runs', () => {
|
|
110
|
+
expect(REFLEX_TASK_LIMITS).toMatchObject({
|
|
111
|
+
maxTasksPerService: 20,
|
|
112
|
+
nameMaxLength: 32,
|
|
113
|
+
payloadMaxLength: 4096,
|
|
114
|
+
delayMinSeconds: 1,
|
|
115
|
+
delayMaxDays: 30,
|
|
116
|
+
recurringToleranceMinutes: 5,
|
|
117
|
+
delayedToleranceMinutes: 60,
|
|
118
|
+
maxAttempts: 3,
|
|
119
|
+
});
|
|
120
|
+
expect(REFLEX_TASK_LIMITS.namePattern.test('daily-report_2')).toBe(true);
|
|
121
|
+
expect(REFLEX_TASK_LIMITS.namePattern.test('Daily')).toBe(false);
|
|
122
|
+
expect(REFLEX_TASK_LIMITS.namePattern.test('a'.repeat(33))).toBe(false);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
IRetryServiceScheduleSyncParams,
|
|
15
|
+
IRetryServiceScheduleSyncResponse,
|
|
16
|
+
ITestRunServiceTaskBody,
|
|
17
|
+
ITestRunServiceTaskParams,
|
|
18
|
+
ITestRunServiceTaskResponse,
|
|
19
|
+
IUpdateServiceTaskBody,
|
|
20
|
+
IUpdateServiceTaskParams,
|
|
21
|
+
IUpdateServiceTaskResponse,
|
|
22
|
+
} from '../types';
|
|
23
|
+
|
|
24
|
+
const serviceUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
25
|
+
`api/service/${params.applicationId}/${params.serviceId}`;
|
|
26
|
+
|
|
27
|
+
const taskUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
28
|
+
`${serviceUrl(params)}/task`;
|
|
29
|
+
|
|
30
|
+
const delayedRunUrl = (params: {
|
|
31
|
+
applicationId: string;
|
|
32
|
+
serviceId: string;
|
|
33
|
+
environmentId: string;
|
|
34
|
+
}): string => `${serviceUrl(params)}/environment/${params.environmentId}/delayed-run`;
|
|
35
|
+
|
|
36
|
+
/** `GET .../task`: the tasks of the draft of the Service, by name. Needs REFLEX_READ. */
|
|
37
|
+
export const listServiceTask = async (
|
|
38
|
+
params: IListServiceTaskParams,
|
|
39
|
+
): Promise<IListServiceTaskResponse> =>
|
|
40
|
+
(await AbyssReflexCore.axios.get<IListServiceTaskResponse>(taskUrl(params))).data;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* `POST .../task`: a task of the draft, scheduled with Flow once a version holding it is in service.
|
|
44
|
+
* Refused when the name is taken, the cron ticks more than once a minute, the time zone is unknown or
|
|
45
|
+
* the Service already has `REFLEX_TASK_LIMITS.maxTasksPerService` tasks. Needs REFLEX_FUNCTION_UPDATE.
|
|
46
|
+
*/
|
|
47
|
+
export const createServiceTask = async (
|
|
48
|
+
params: ICreateServiceTaskParams,
|
|
49
|
+
body: ICreateServiceTaskBody,
|
|
50
|
+
): Promise<ICreateServiceTaskResponse> =>
|
|
51
|
+
(await AbyssReflexCore.axios.post<ICreateServiceTaskResponse>(taskUrl(params), body)).data;
|
|
52
|
+
|
|
53
|
+
/** `PATCH .../task/:taskId`: changes the task in the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
54
|
+
export const updateServiceTask = async (
|
|
55
|
+
params: IUpdateServiceTaskParams,
|
|
56
|
+
body: IUpdateServiceTaskBody,
|
|
57
|
+
): Promise<IUpdateServiceTaskResponse> =>
|
|
58
|
+
(
|
|
59
|
+
await AbyssReflexCore.axios.patch<IUpdateServiceTaskResponse>(
|
|
60
|
+
`${taskUrl(params)}/${params.taskId}`,
|
|
61
|
+
body,
|
|
62
|
+
)
|
|
63
|
+
).data;
|
|
64
|
+
|
|
65
|
+
/** `DELETE .../task/:taskId`: takes the task out of the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
66
|
+
export const deleteServiceTask = async (
|
|
67
|
+
params: IDeleteServiceTaskParams,
|
|
68
|
+
): Promise<IDeleteServiceTaskResponse> =>
|
|
69
|
+
(
|
|
70
|
+
await AbyssReflexCore.axios.delete<IDeleteServiceTaskResponse>(
|
|
71
|
+
`${taskUrl(params)}/${params.taskId}`,
|
|
72
|
+
)
|
|
73
|
+
).data;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* `POST .../task/:taskId/test-run`: runs the task now as a test run of its function in the environment
|
|
77
|
+
* `body.environmentId`, with a `SCHEDULE` input; nothing is queued. Needs REFLEX_TEST_RUN.
|
|
78
|
+
*/
|
|
79
|
+
export const testRunServiceTask = async (
|
|
80
|
+
params: ITestRunServiceTaskParams,
|
|
81
|
+
body: ITestRunServiceTaskBody,
|
|
82
|
+
): Promise<ITestRunServiceTaskResponse> =>
|
|
83
|
+
(
|
|
84
|
+
await AbyssReflexCore.axios.post<ITestRunServiceTaskResponse>(
|
|
85
|
+
`${taskUrl(params)}/${params.taskId}/test-run`,
|
|
86
|
+
body,
|
|
87
|
+
)
|
|
88
|
+
).data;
|
|
89
|
+
|
|
90
|
+
/** `GET .../environment/:environmentId/delayed-run`: the first 100 pending delayed runs of the environment. Needs REFLEX_READ. */
|
|
91
|
+
export const listServiceDelayedRun = async (
|
|
92
|
+
params: IListServiceDelayedRunParams,
|
|
93
|
+
): Promise<IListServiceDelayedRunResponse> =>
|
|
94
|
+
(await AbyssReflexCore.axios.get<IListServiceDelayedRunResponse>(delayedRunUrl(params))).data;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* `DELETE .../environment/:environmentId/delayed-run/:delayedRunId`: cancels a pending delayed run.
|
|
98
|
+
* Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION in a production environment.
|
|
99
|
+
*/
|
|
100
|
+
export const cancelServiceDelayedRun = async (
|
|
101
|
+
params: ICancelServiceDelayedRunParams,
|
|
102
|
+
): Promise<ICancelServiceDelayedRunResponse> =>
|
|
103
|
+
(
|
|
104
|
+
await AbyssReflexCore.axios.delete<ICancelServiceDelayedRunResponse>(
|
|
105
|
+
`${delayedRunUrl(params)}/${params.delayedRunId}`,
|
|
106
|
+
)
|
|
107
|
+
).data;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* `POST .../deployment/:environmentId/schedule-sync`: synchronizes the cron tasks of the version in
|
|
111
|
+
* service with Flow again, without a new version. Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION
|
|
112
|
+
* in a production environment.
|
|
113
|
+
*/
|
|
114
|
+
export const retryServiceScheduleSync = async (
|
|
115
|
+
params: IRetryServiceScheduleSyncParams,
|
|
116
|
+
): Promise<IRetryServiceScheduleSyncResponse> =>
|
|
117
|
+
(
|
|
118
|
+
await AbyssReflexCore.axios.post<IRetryServiceScheduleSyncResponse>(
|
|
119
|
+
`${serviceUrl(params)}/deployment/${params.environmentId}/schedule-sync`,
|
|
120
|
+
{},
|
|
121
|
+
)
|
|
122
|
+
).data;
|
|
@@ -3,6 +3,8 @@ import type {
|
|
|
3
3
|
ICreateServiceVersionBody,
|
|
4
4
|
ICreateServiceVersionParams,
|
|
5
5
|
ICreateServiceVersionResponse,
|
|
6
|
+
IGetServiceVersionDraftStatusParams,
|
|
7
|
+
IGetServiceVersionDraftStatusResponse,
|
|
6
8
|
IGetServiceVersionParams,
|
|
7
9
|
IGetServiceVersionResponse,
|
|
8
10
|
IListServiceVersionParams,
|
|
@@ -28,6 +30,19 @@ export const createServiceVersion = async (
|
|
|
28
30
|
): Promise<ICreateServiceVersionResponse> =>
|
|
29
31
|
(await AbyssReflexCore.axios.post<ICreateServiceVersionResponse>(versionUrl(params), body)).data;
|
|
30
32
|
|
|
33
|
+
/**
|
|
34
|
+
* `GET .../version/draft-status`: how many functions of the Service a version created now would freeze
|
|
35
|
+
* differently from the last Service version (`changedFunctions`). Needs REFLEX_READ.
|
|
36
|
+
*/
|
|
37
|
+
export const getServiceVersionDraftStatus = async (
|
|
38
|
+
params: IGetServiceVersionDraftStatusParams,
|
|
39
|
+
): Promise<IGetServiceVersionDraftStatusResponse> =>
|
|
40
|
+
(
|
|
41
|
+
await AbyssReflexCore.axios.get<IGetServiceVersionDraftStatusResponse>(
|
|
42
|
+
`${versionUrl(params)}/draft-status`,
|
|
43
|
+
)
|
|
44
|
+
).data;
|
|
45
|
+
|
|
31
46
|
/** `GET .../version/:versionId`: the snapshot and the route changes since the version before. Needs REFLEX_READ. */
|
|
32
47
|
export const getServiceVersion = async (
|
|
33
48
|
params: IGetServiceVersionParams,
|
|
@@ -111,6 +111,12 @@ const calls: Call[] = [
|
|
|
111
111
|
body: { message: 'orders by id' },
|
|
112
112
|
run: () => sdk().version.create(SERVICE, { message: 'orders by id' }),
|
|
113
113
|
},
|
|
114
|
+
{
|
|
115
|
+
label: 'version.draftStatus',
|
|
116
|
+
method: 'get',
|
|
117
|
+
url: `${BASE}/version/draft-status`,
|
|
118
|
+
run: () => sdk().version.draftStatus(SERVICE),
|
|
119
|
+
},
|
|
114
120
|
{
|
|
115
121
|
label: 'version.get',
|
|
116
122
|
method: 'get',
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import * as serviceVersionApi from './api/service-version.api';
|
|
|
12
12
|
import * as serviceDeploymentApi from './api/service-deployment.api';
|
|
13
13
|
import * as serviceConfigurationApi from './api/service-configuration.api';
|
|
14
14
|
import * as serviceDiscordApi from './api/service-discord.api';
|
|
15
|
+
import * as serviceTaskApi from './api/service-task.api';
|
|
15
16
|
|
|
16
17
|
export * from './api';
|
|
17
18
|
export * from './types';
|
|
@@ -77,6 +78,7 @@ type AbyssReflexCoreSDK = {
|
|
|
77
78
|
list: typeof serviceVersionApi.listServiceVersion;
|
|
78
79
|
create: typeof serviceVersionApi.createServiceVersion;
|
|
79
80
|
get: typeof serviceVersionApi.getServiceVersion;
|
|
81
|
+
draftStatus: typeof serviceVersionApi.getServiceVersionDraftStatus;
|
|
80
82
|
};
|
|
81
83
|
deployment: {
|
|
82
84
|
list: typeof serviceDeploymentApi.listServiceDeployment;
|
|
@@ -111,6 +113,20 @@ type AbyssReflexCoreSDK = {
|
|
|
111
113
|
/** Pushes the interactions address and the commands to Discord again. */
|
|
112
114
|
sync: typeof serviceDiscordApi.retryServiceDiscordSync;
|
|
113
115
|
};
|
|
116
|
+
/** The tasks of the Service (cron and delayed runs), their delayed runs, the synchronization with Flow. */
|
|
117
|
+
task: {
|
|
118
|
+
list: typeof serviceTaskApi.listServiceTask;
|
|
119
|
+
create: typeof serviceTaskApi.createServiceTask;
|
|
120
|
+
update: typeof serviceTaskApi.updateServiceTask;
|
|
121
|
+
delete: typeof serviceTaskApi.deleteServiceTask;
|
|
122
|
+
testRun: typeof serviceTaskApi.testRunServiceTask;
|
|
123
|
+
delayedRun: {
|
|
124
|
+
list: typeof serviceTaskApi.listServiceDelayedRun;
|
|
125
|
+
cancel: typeof serviceTaskApi.cancelServiceDelayedRun;
|
|
126
|
+
};
|
|
127
|
+
/** Synchronizes the cron tasks of the version in service with Flow again. */
|
|
128
|
+
sync: typeof serviceTaskApi.retryServiceScheduleSync;
|
|
129
|
+
};
|
|
114
130
|
};
|
|
115
131
|
};
|
|
116
132
|
|
|
@@ -177,6 +193,7 @@ export class AbyssReflexCore {
|
|
|
177
193
|
list: serviceVersionApi.listServiceVersion,
|
|
178
194
|
create: serviceVersionApi.createServiceVersion,
|
|
179
195
|
get: serviceVersionApi.getServiceVersion,
|
|
196
|
+
draftStatus: serviceVersionApi.getServiceVersionDraftStatus,
|
|
180
197
|
},
|
|
181
198
|
deployment: {
|
|
182
199
|
list: serviceDeploymentApi.listServiceDeployment,
|
|
@@ -209,6 +226,18 @@ export class AbyssReflexCore {
|
|
|
209
226
|
},
|
|
210
227
|
sync: serviceDiscordApi.retryServiceDiscordSync,
|
|
211
228
|
},
|
|
229
|
+
task: {
|
|
230
|
+
list: serviceTaskApi.listServiceTask,
|
|
231
|
+
create: serviceTaskApi.createServiceTask,
|
|
232
|
+
update: serviceTaskApi.updateServiceTask,
|
|
233
|
+
delete: serviceTaskApi.deleteServiceTask,
|
|
234
|
+
testRun: serviceTaskApi.testRunServiceTask,
|
|
235
|
+
delayedRun: {
|
|
236
|
+
list: serviceTaskApi.listServiceDelayedRun,
|
|
237
|
+
cancel: serviceTaskApi.cancelServiceDelayedRun,
|
|
238
|
+
},
|
|
239
|
+
sync: serviceTaskApi.retryServiceScheduleSync,
|
|
240
|
+
},
|
|
212
241
|
},
|
|
213
242
|
};
|
|
214
243
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* State of an access granted to a function.
|
|
3
|
-
* - ACTIVE: the grantor still holds the right the access needs.
|
|
4
|
-
* - SUSPENDED: a publication found the grantor without that right. Publishing is refused
|
|
5
|
-
* (`GRANT_SUSPENDED`) until the access is revoked and granted again; what is already promoted keeps running.
|
|
6
|
-
* - REVOKED: withdrawn on purpose; the row stays as the journal.
|
|
7
|
-
*/
|
|
8
|
-
export enum AccessGrantStatus {
|
|
9
|
-
ACTIVE = 'ACTIVE',
|
|
10
|
-
SUSPENDED = 'SUSPENDED',
|
|
11
|
-
REVOKED = 'REVOKED',
|
|
12
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* State of an access granted to a function.
|
|
3
|
+
* - ACTIVE: the grantor still holds the right the access needs.
|
|
4
|
+
* - SUSPENDED: a publication found the grantor without that right. Publishing is refused
|
|
5
|
+
* (`GRANT_SUSPENDED`) until the access is revoked and granted again; what is already promoted keeps running.
|
|
6
|
+
* - REVOKED: withdrawn on purpose; the row stays as the journal.
|
|
7
|
+
*/
|
|
8
|
+
export enum AccessGrantStatus {
|
|
9
|
+
ACTIVE = 'ACTIVE',
|
|
10
|
+
SUSPENDED = 'SUSPENDED',
|
|
11
|
+
REVOKED = 'REVOKED',
|
|
12
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** The kinds of access a definition declares and a member grants (the format of @abyss-project/runtime). */
|
|
2
|
-
export enum ReflexAccessKind {
|
|
3
|
-
/** Outbound HTTP to a list of host names (exact, or `*.domain` for any sub-domain). */
|
|
4
|
-
HTTP = 'HTTP',
|
|
5
|
-
/** One action of the host catalog (`store.get`, `store.set`, `store.increment`, `secret.get`, `http.respond`). */
|
|
6
|
-
HOST_ACTION = 'HOST_ACTION',
|
|
7
|
-
}
|
|
1
|
+
/** The kinds of access a definition declares and a member grants (the format of @abyss-project/runtime). */
|
|
2
|
+
export enum ReflexAccessKind {
|
|
3
|
+
/** Outbound HTTP to a list of host names (exact, or `*.domain` for any sub-domain). */
|
|
4
|
+
HTTP = 'HTTP',
|
|
5
|
+
/** One action of the host catalog (`store.get`, `store.set`, `store.increment`, `secret.get`, `http.respond`). */
|
|
6
|
+
HOST_ACTION = 'HOST_ACTION',
|
|
7
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** How a function reads a vault key: `config.NAME` (a VISIBLE entry) or `secrets.NAME` (a SECRET entry). */
|
|
2
|
-
export enum ConfigurationReadAs {
|
|
3
|
-
CONFIG = 'config',
|
|
4
|
-
SECRETS = 'secrets',
|
|
5
|
-
}
|
|
1
|
+
/** How a function reads a vault key: `config.NAME` (a VISIBLE entry) or `secrets.NAME` (a SECRET entry). */
|
|
2
|
+
export enum ConfigurationReadAs {
|
|
3
|
+
CONFIG = 'config',
|
|
4
|
+
SECRETS = 'secrets',
|
|
5
|
+
}
|
|
@@ -1,9 +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
|
+
/** 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
|
+
}
|
|
@@ -1,9 +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
|
-
}
|
|
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
|
+
}
|
|
@@ -1,11 +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
|
+
/** 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,8 +1,8 @@
|
|
|
1
|
-
/** The status a Discord bot shows while connected to the Gateway. */
|
|
2
|
-
export enum DiscordPresenceStatus {
|
|
3
|
-
ONLINE = 'ONLINE',
|
|
4
|
-
/** Away. */
|
|
5
|
-
IDLE = 'IDLE',
|
|
6
|
-
/** Do not disturb. */
|
|
7
|
-
DND = 'DND',
|
|
8
|
-
}
|
|
1
|
+
/** The status a Discord bot shows while connected to the Gateway. */
|
|
2
|
+
export enum DiscordPresenceStatus {
|
|
3
|
+
ONLINE = 'ONLINE',
|
|
4
|
+
/** Away. */
|
|
5
|
+
IDLE = 'IDLE',
|
|
6
|
+
/** Do not disturb. */
|
|
7
|
+
DND = 'DND',
|
|
8
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/** What Reflex knows of the bot token of an environment. */
|
|
2
|
-
export enum DiscordTokenState {
|
|
3
|
-
/** Discord accepted the token at the last check. */
|
|
4
|
-
VALID = 'VALID',
|
|
5
|
-
/** Discord answered 401 to the token. */
|
|
6
|
-
REJECTED = 'REJECTED',
|
|
7
|
-
/** The Vault entry has no value in this environment. */
|
|
8
|
-
MISSING = 'MISSING',
|
|
9
|
-
/** The token has not been checked yet. */
|
|
10
|
-
UNCHECKED = 'UNCHECKED',
|
|
11
|
-
}
|
|
1
|
+
/** What Reflex knows of the bot token of an environment. */
|
|
2
|
+
export enum DiscordTokenState {
|
|
3
|
+
/** Discord accepted the token at the last check. */
|
|
4
|
+
VALID = 'VALID',
|
|
5
|
+
/** Discord answered 401 to the token. */
|
|
6
|
+
REJECTED = 'REJECTED',
|
|
7
|
+
/** The Vault entry has no value in this environment. */
|
|
8
|
+
MISSING = 'MISSING',
|
|
9
|
+
/** The token has not been checked yet. */
|
|
10
|
+
UNCHECKED = 'UNCHECKED',
|
|
11
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How a route answers its caller.
|
|
3
|
-
* - SYNC: the caller waits for the Respond step, or gets 504 past the response timeout.
|
|
4
|
-
* - ASYNC: the caller gets `202 {executionId}` before the execution starts, and reads its state.
|
|
5
|
-
*/
|
|
6
|
-
export enum ExecutionMode {
|
|
7
|
-
SYNC = 'SYNC',
|
|
8
|
-
ASYNC = 'ASYNC',
|
|
9
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* How a route answers its caller.
|
|
3
|
+
* - SYNC: the caller waits for the Respond step, or gets 504 past the response timeout.
|
|
4
|
+
* - ASYNC: the caller gets `202 {executionId}` before the execution starts, and reads its state.
|
|
5
|
+
*/
|
|
6
|
+
export enum ExecutionMode {
|
|
7
|
+
SYNC = 'SYNC',
|
|
8
|
+
ASYNC = 'ASYNC',
|
|
9
|
+
}
|