@abyss-project/reflex 5.2.0 → 5.4.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 +10 -0
- package/dist/api/service-task.api.js +26 -0
- package/dist/api/service-task.api.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/types/enum/index.d.ts +4 -0
- package/dist/types/enum/index.js +4 -0
- package/dist/types/enum/index.js.map +1 -1
- package/dist/types/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-failure-code.enum.d.ts +4 -0
- package/dist/types/enum/scheduled-run-failure-code.enum.js +9 -0
- package/dist/types/enum/scheduled-run-failure-code.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/enum/scheduled-run-status.enum.d.ts +9 -0
- package/dist/types/enum/scheduled-run-status.enum.js +14 -0
- package/dist/types/enum/scheduled-run-status.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 +64 -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/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 +36 -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 +9 -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 +48 -0
- package/dist/types/interface/models/reflex-task.model.js +16 -0
- package/dist/types/interface/models/reflex-task.model.js.map +1 -0
- package/package.json +1 -1
- package/src/api/function-access.api.ts +36 -36
- package/src/api/function-run.api.ts +38 -38
- package/src/api/function-settings.api.ts +59 -59
- package/src/api/function-test.api.ts +34 -34
- package/src/api/function-version.api.ts +48 -48
- package/src/api/function.api.test.ts +249 -249
- package/src/api/function.api.ts +62 -62
- package/src/api/health.api.ts +10 -10
- package/src/api/index.ts +14 -13
- package/src/api/service-configuration.api.ts +16 -16
- package/src/api/service-deployment.api.ts +79 -79
- package/src/api/service-discord.api.test.ts +170 -170
- package/src/api/service-discord.api.ts +203 -203
- package/src/api/service-route.api.ts +72 -72
- package/src/api/service-task.api.test.ts +140 -0
- package/src/api/service-task.api.ts +141 -0
- 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/index.ts +34 -0
- package/src/types/enum/index.ts +33 -29
- package/src/types/enum/reflex-error-code.enum.ts +2 -0
- package/src/types/enum/schedule-sync-status.enum.ts +6 -0
- package/src/types/enum/scheduled-run-failure-code.enum.ts +10 -0
- package/src/types/enum/scheduled-run-origin.enum.ts +5 -0
- package/src/types/enum/scheduled-run-status.enum.ts +17 -0
- package/src/types/interface/api/requests/function-run.request.ts +4 -0
- package/src/types/interface/api/requests/function-test.request.ts +16 -1
- package/src/types/interface/api/requests/index.ts +1 -0
- package/src/types/interface/api/requests/service-task.request.ts +80 -0
- package/src/types/interface/api/requests/service-version.request.ts +24 -24
- package/src/types/interface/api/responses/index.ts +1 -0
- package/src/types/interface/api/responses/service-task.response.ts +57 -0
- package/src/types/interface/api/responses/service-version.response.ts +91 -73
- package/src/types/interface/models/index.ts +1 -0
- package/src/types/interface/models/reflex-run.model.ts +7 -1
- package/src/types/interface/models/reflex-service-deployment.model.ts +6 -0
- package/src/types/interface/models/reflex-service-version.model.ts +3 -0
- package/src/types/interface/models/reflex-task.model.ts +97 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `failureCode` of a FAILED scheduled run the execution plane writes itself. Any other `failureCode` is the
|
|
3
|
+
* error code of the live run that failed (`FUNCTION_FAILED`, `FUNCTION_TIMEOUT`, `INTERNAL_ERROR`...).
|
|
4
|
+
*/
|
|
5
|
+
export enum ScheduledRunFailureCode {
|
|
6
|
+
/** The task left the version in service before the run was due: nothing ran, nothing is billed. */
|
|
7
|
+
TASK_REMOVED = 'TASK_REMOVED',
|
|
8
|
+
/** Every attempt was interrupted by the end of its edge. */
|
|
9
|
+
ATTEMPTS_EXHAUSTED = 'ATTEMPTS_EXHAUSTED',
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Where a scheduled run of a task stands (`scheduled_runs.status` of the execution plane). */
|
|
2
|
+
export enum ScheduledRunStatus {
|
|
3
|
+
/** Waiting for its due date, or due and not yet taken by an edge. */
|
|
4
|
+
PENDING = 'PENDING',
|
|
5
|
+
/** An edge runs it. */
|
|
6
|
+
CLAIMED = 'CLAIMED',
|
|
7
|
+
/** Ran to its end. */
|
|
8
|
+
DONE = 'DONE',
|
|
9
|
+
/** Did not run to its end: `failureCode` says why. */
|
|
10
|
+
FAILED = 'FAILED',
|
|
11
|
+
/** Cancelled before it ran (`abyss.schedule.cancel` or the screen). */
|
|
12
|
+
CANCELLED = 'CANCELLED',
|
|
13
|
+
/** Taken too late, past the tolerance (after a pause or an outage): ran nothing, cost nothing. */
|
|
14
|
+
EXPIRED = 'EXPIRED',
|
|
15
|
+
/** A tick of a cron that came while the previous one still ran: ran nothing, cost nothing. */
|
|
16
|
+
SKIPPED = 'SKIPPED',
|
|
17
|
+
}
|
|
@@ -10,6 +10,10 @@ export interface IListFunctionRunQuery {
|
|
|
10
10
|
limit?: number;
|
|
11
11
|
/** Runs skipped, newest first; 0 by default. */
|
|
12
12
|
offset?: number;
|
|
13
|
+
/** Only the live runs this task started (a tick of its cron or a delayed run); test runs have no task. */
|
|
14
|
+
taskId?: string;
|
|
15
|
+
/** Only the runs of this environment of the application (abyss-main's id). */
|
|
16
|
+
environmentId?: string;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
export interface IGetFunctionRunParams {
|
|
@@ -10,15 +10,30 @@ export interface IReflexHttpStub {
|
|
|
10
10
|
body?: unknown;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* The answer a `discord.*` call of a step gets in a test; nothing reaches Discord. Without a stub the
|
|
15
|
+
* call gets a simulated answer of the shape the edge returns (`{ id }` of a message, a member, a channel...).
|
|
16
|
+
*/
|
|
17
|
+
export interface IReflexDiscordStub {
|
|
18
|
+
/** What the call returns: `null` for `getMember` reads as a user who is not a member. */
|
|
19
|
+
response: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
export interface ISimulateFunctionBody {
|
|
14
23
|
/**
|
|
15
24
|
* The environment of the application the run takes place in (abyss-main's id): a dry run reads its
|
|
16
25
|
* Store, the run is measured with its effective settings and recorded with it.
|
|
17
26
|
*/
|
|
18
27
|
environmentId: string;
|
|
19
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* The event the function receives, as the edge builds it: `{method, path, query, headers, body}`, or the
|
|
30
|
+
* input of a run of a task (`ScheduledRunInput` of `@abyss-project/runtime`, `kind` SCHEDULE or DELAYED),
|
|
31
|
+
* which no interaction started: `discord.reply`, `update`, `showModal` and `followUp` then reject with `NO_INTERACTION`.
|
|
32
|
+
*/
|
|
20
33
|
input?: unknown;
|
|
21
34
|
/** Simulated responses of HTTP steps, by step id. */
|
|
22
35
|
httpStubs?: Record<string, IReflexHttpStub>;
|
|
36
|
+
/** Answers of the `discord.*` calls of a step, by step id (a Discord bot Service only). */
|
|
37
|
+
discordStubs?: Record<string, IReflexDiscordStub>;
|
|
23
38
|
}
|
|
24
39
|
export type IDryRunFunctionBody = ISimulateFunctionBody;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export interface IListServiceTaskParams {
|
|
2
|
+
applicationId: string;
|
|
3
|
+
serviceId: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface ICreateServiceTaskParams {
|
|
7
|
+
applicationId: string;
|
|
8
|
+
serviceId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ICreateServiceTaskBody {
|
|
11
|
+
/** `^[-_a-z0-9]{1,32}$`, unique within the Service. */
|
|
12
|
+
name: string;
|
|
13
|
+
/** A function of the same Service. */
|
|
14
|
+
functionId: string;
|
|
15
|
+
/** A cron of 5 fields, at most one tick a minute; null (default) for a task only delayed runs start. */
|
|
16
|
+
schedule?: string | null;
|
|
17
|
+
/** IANA time zone the cron is read in; `Etc/UTC` by default. */
|
|
18
|
+
timezone?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface IUpdateServiceTaskParams {
|
|
22
|
+
applicationId: string;
|
|
23
|
+
serviceId: string;
|
|
24
|
+
taskId: string;
|
|
25
|
+
}
|
|
26
|
+
export interface IUpdateServiceTaskBody {
|
|
27
|
+
name?: string;
|
|
28
|
+
functionId?: string;
|
|
29
|
+
schedule?: string | null;
|
|
30
|
+
timezone?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface IDeleteServiceTaskParams {
|
|
34
|
+
applicationId: string;
|
|
35
|
+
serviceId: string;
|
|
36
|
+
taskId: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ITestRunServiceTaskParams {
|
|
40
|
+
applicationId: string;
|
|
41
|
+
serviceId: string;
|
|
42
|
+
taskId: string;
|
|
43
|
+
}
|
|
44
|
+
export interface ITestRunServiceTaskBody {
|
|
45
|
+
/** The environment of the application the test run takes place in (abyss-main's id). */
|
|
46
|
+
environmentId: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface IListServiceDelayedRunParams {
|
|
50
|
+
applicationId: string;
|
|
51
|
+
serviceId: string;
|
|
52
|
+
environmentId: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ICancelServiceDelayedRunParams {
|
|
56
|
+
applicationId: string;
|
|
57
|
+
serviceId: string;
|
|
58
|
+
environmentId: string;
|
|
59
|
+
delayedRunId: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface IRetryServiceScheduleSyncParams {
|
|
63
|
+
applicationId: string;
|
|
64
|
+
serviceId: string;
|
|
65
|
+
environmentId: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface IListServiceTaskScheduledRunParams {
|
|
69
|
+
applicationId: string;
|
|
70
|
+
serviceId: string;
|
|
71
|
+
taskId: string;
|
|
72
|
+
/** The environment of the application whose runs are read (abyss-main's id). */
|
|
73
|
+
environmentId: string;
|
|
74
|
+
}
|
|
75
|
+
export interface IListServiceTaskScheduledRunQuery {
|
|
76
|
+
/** 1 to `REFLEX_TASK_LIMITS.scheduledRunPageMax` (50), 50 by default. */
|
|
77
|
+
limit?: number;
|
|
78
|
+
/** Runs skipped, newest first; 0 by default. */
|
|
79
|
+
offset?: number;
|
|
80
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export interface IListServiceVersionParams {
|
|
2
|
-
applicationId: string;
|
|
3
|
-
serviceId: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface ICreateServiceVersionParams {
|
|
7
|
-
applicationId: string;
|
|
8
|
-
serviceId: string;
|
|
9
|
-
}
|
|
10
|
-
export interface ICreateServiceVersionBody {
|
|
11
|
-
/** 500 characters at most. */
|
|
12
|
-
message?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface IGetServiceVersionDraftStatusParams {
|
|
16
|
-
applicationId: string;
|
|
17
|
-
serviceId: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface IGetServiceVersionParams {
|
|
21
|
-
applicationId: string;
|
|
22
|
-
serviceId: string;
|
|
23
|
-
versionId: string;
|
|
24
|
-
}
|
|
1
|
+
export interface IListServiceVersionParams {
|
|
2
|
+
applicationId: string;
|
|
3
|
+
serviceId: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface ICreateServiceVersionParams {
|
|
7
|
+
applicationId: string;
|
|
8
|
+
serviceId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ICreateServiceVersionBody {
|
|
11
|
+
/** 500 characters at most. */
|
|
12
|
+
message?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IGetServiceVersionDraftStatusParams {
|
|
16
|
+
applicationId: string;
|
|
17
|
+
serviceId: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface IGetServiceVersionParams {
|
|
21
|
+
applicationId: string;
|
|
22
|
+
serviceId: string;
|
|
23
|
+
versionId: string;
|
|
24
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
IReflexDelayedRun,
|
|
3
|
+
IReflexRun,
|
|
4
|
+
IReflexScheduledRun,
|
|
5
|
+
IReflexServiceDeployment,
|
|
6
|
+
IReflexTask,
|
|
7
|
+
} from '../../models';
|
|
8
|
+
import type { IResponse } from '../response';
|
|
9
|
+
|
|
10
|
+
export interface IListServiceTaskData {
|
|
11
|
+
/** By name. */
|
|
12
|
+
tasks: IReflexTask[];
|
|
13
|
+
}
|
|
14
|
+
export type IListServiceTaskResponse = IResponse<IListServiceTaskData>;
|
|
15
|
+
|
|
16
|
+
export interface ICreateServiceTaskData {
|
|
17
|
+
task: IReflexTask;
|
|
18
|
+
}
|
|
19
|
+
export type ICreateServiceTaskResponse = IResponse<ICreateServiceTaskData>;
|
|
20
|
+
|
|
21
|
+
export interface IUpdateServiceTaskData {
|
|
22
|
+
task: IReflexTask;
|
|
23
|
+
}
|
|
24
|
+
export type IUpdateServiceTaskResponse = IResponse<IUpdateServiceTaskData>;
|
|
25
|
+
|
|
26
|
+
export type IDeleteServiceTaskData = Record<string, never>;
|
|
27
|
+
export type IDeleteServiceTaskResponse = IResponse<IDeleteServiceTaskData>;
|
|
28
|
+
|
|
29
|
+
export interface ITestRunServiceTaskData {
|
|
30
|
+
run: IReflexRun;
|
|
31
|
+
}
|
|
32
|
+
export type ITestRunServiceTaskResponse = IResponse<ITestRunServiceTaskData>;
|
|
33
|
+
|
|
34
|
+
export interface IListServiceDelayedRunData {
|
|
35
|
+
/** The first 100 pending delayed runs of the environment, soonest due first. */
|
|
36
|
+
delayedRuns: IReflexDelayedRun[];
|
|
37
|
+
/** Pending delayed runs of the environment, all of them. */
|
|
38
|
+
total: number;
|
|
39
|
+
}
|
|
40
|
+
export type IListServiceDelayedRunResponse = IResponse<IListServiceDelayedRunData>;
|
|
41
|
+
|
|
42
|
+
export type ICancelServiceDelayedRunData = Record<string, never>;
|
|
43
|
+
export type ICancelServiceDelayedRunResponse = IResponse<ICancelServiceDelayedRunData>;
|
|
44
|
+
|
|
45
|
+
export interface IRetryServiceScheduleSyncData {
|
|
46
|
+
/** The current deployment of the environment, with the new state of the synchronization. */
|
|
47
|
+
deployment: IReflexServiceDeployment;
|
|
48
|
+
}
|
|
49
|
+
export type IRetryServiceScheduleSyncResponse = IResponse<IRetryServiceScheduleSyncData>;
|
|
50
|
+
|
|
51
|
+
export interface IListServiceTaskScheduledRunData {
|
|
52
|
+
/** The runs of the task in the environment, every status, newest due first, paged by `limit`/`offset`. */
|
|
53
|
+
scheduledRuns: IReflexScheduledRun[];
|
|
54
|
+
/** Runs of the task in the environment, all of them (kept 7 days after their end). */
|
|
55
|
+
total: number;
|
|
56
|
+
}
|
|
57
|
+
export type IListServiceTaskScheduledRunResponse = IResponse<IListServiceTaskScheduledRunData>;
|
|
@@ -1,73 +1,91 @@
|
|
|
1
|
-
import type { ServiceVersionChangeKind } from '../../../enum';
|
|
2
|
-
import type {
|
|
3
|
-
IReflexDiscordCommandSnapshot,
|
|
4
|
-
IReflexDiscordComponentSnapshot,
|
|
5
|
-
IReflexServiceVersion,
|
|
6
|
-
IReflexServiceVersionRoute,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
version
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export interface
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
export type
|
|
61
|
-
|
|
62
|
-
export interface
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
1
|
+
import type { ServiceVersionChangeKind } from '../../../enum';
|
|
2
|
+
import type {
|
|
3
|
+
IReflexDiscordCommandSnapshot,
|
|
4
|
+
IReflexDiscordComponentSnapshot,
|
|
5
|
+
IReflexServiceVersion,
|
|
6
|
+
IReflexServiceVersionRoute,
|
|
7
|
+
IReflexTaskSnapshot,
|
|
8
|
+
} from '../../models';
|
|
9
|
+
import type { IResponse } from '../response';
|
|
10
|
+
|
|
11
|
+
/** How one route differs from the previous version, matched by route id. */
|
|
12
|
+
export interface IReflexServiceVersionRouteChange {
|
|
13
|
+
routeId: string;
|
|
14
|
+
kind: ServiceVersionChangeKind;
|
|
15
|
+
/** The route in the previous version; null when ADDED. */
|
|
16
|
+
before: IReflexServiceVersionRoute | null;
|
|
17
|
+
/** The route in this version; null when REMOVED. */
|
|
18
|
+
after: IReflexServiceVersionRoute | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** How one command of a Discord bot differs from the previous version, matched by command id. */
|
|
22
|
+
export interface IReflexServiceVersionCommandChange {
|
|
23
|
+
commandId: string;
|
|
24
|
+
kind: ServiceVersionChangeKind;
|
|
25
|
+
/** The command in the previous version; null when ADDED. */
|
|
26
|
+
before: IReflexDiscordCommandSnapshot | null;
|
|
27
|
+
/** The command in this version; null when REMOVED. */
|
|
28
|
+
after: IReflexDiscordCommandSnapshot | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** How one component of a Discord bot differs from the previous version, matched by component id. */
|
|
32
|
+
export interface IReflexServiceVersionComponentChange {
|
|
33
|
+
componentId: string;
|
|
34
|
+
kind: ServiceVersionChangeKind;
|
|
35
|
+
/** The component in the previous version; null when ADDED. */
|
|
36
|
+
before: IReflexDiscordComponentSnapshot | null;
|
|
37
|
+
/** The component in this version; null when REMOVED. */
|
|
38
|
+
after: IReflexDiscordComponentSnapshot | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** How one task of the Service differs from the previous version, matched by task id. */
|
|
42
|
+
export interface IReflexServiceVersionTaskChange {
|
|
43
|
+
taskId: string;
|
|
44
|
+
kind: ServiceVersionChangeKind;
|
|
45
|
+
/** The task in the previous version; null when ADDED. */
|
|
46
|
+
before: IReflexTaskSnapshot | null;
|
|
47
|
+
/** The task in this version; null when REMOVED. */
|
|
48
|
+
after: IReflexTaskSnapshot | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface IListServiceVersionData {
|
|
52
|
+
/** Newest first. */
|
|
53
|
+
versions: IReflexServiceVersion[];
|
|
54
|
+
}
|
|
55
|
+
export type IListServiceVersionResponse = IResponse<IListServiceVersionData>;
|
|
56
|
+
|
|
57
|
+
export interface ICreateServiceVersionData {
|
|
58
|
+
version: IReflexServiceVersion;
|
|
59
|
+
}
|
|
60
|
+
export type ICreateServiceVersionResponse = IResponse<ICreateServiceVersionData>;
|
|
61
|
+
|
|
62
|
+
export interface IGetServiceVersionDraftStatusData {
|
|
63
|
+
/**
|
|
64
|
+
* How many functions of the Service a version created now would freeze at a version other than the one
|
|
65
|
+
* the last Service version froze: a function new to the Service, a draft that differs from its last
|
|
66
|
+
* version (an invalid draft counts), or a function version published since. Same rule as
|
|
67
|
+
* `POST .../version`; 0 for a Service without functions.
|
|
68
|
+
*/
|
|
69
|
+
changedFunctions: number;
|
|
70
|
+
/**
|
|
71
|
+
* How many tasks of the draft differ from the last Service version: added, modified (function, name,
|
|
72
|
+
* cron or time zone) or removed. 0 for a Service without tasks.
|
|
73
|
+
*/
|
|
74
|
+
changedTasks: number;
|
|
75
|
+
}
|
|
76
|
+
export type IGetServiceVersionDraftStatusResponse = IResponse<IGetServiceVersionDraftStatusData>;
|
|
77
|
+
|
|
78
|
+
export interface IGetServiceVersionData {
|
|
79
|
+
version: IReflexServiceVersion;
|
|
80
|
+
/** The version just before; null for the first one. */
|
|
81
|
+
previousVersion: IReflexServiceVersion | null;
|
|
82
|
+
/** The routes added, removed or modified since `previousVersion` (every route is ADDED for the first one). */
|
|
83
|
+
routeChanges: IReflexServiceVersionRouteChange[];
|
|
84
|
+
/** The commands added, removed or modified since `previousVersion`; empty for a Service that is not a Discord bot. */
|
|
85
|
+
commandChanges: IReflexServiceVersionCommandChange[];
|
|
86
|
+
/** The components added, removed or modified since `previousVersion`; empty for a Service that is not a Discord bot. */
|
|
87
|
+
componentChanges: IReflexServiceVersionComponentChange[];
|
|
88
|
+
/** The tasks added, removed or modified since `previousVersion` (every task is ADDED for the first one). */
|
|
89
|
+
taskChanges: IReflexServiceVersionTaskChange[];
|
|
90
|
+
}
|
|
91
|
+
export type IGetServiceVersionResponse = IResponse<IGetServiceVersionData>;
|
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
RunMode,
|
|
6
6
|
RunStatus,
|
|
7
7
|
RunStepStatus,
|
|
8
|
+
ScheduledRunOrigin,
|
|
8
9
|
TraceEffectType,
|
|
9
10
|
} from '../../enum';
|
|
10
11
|
|
|
@@ -70,9 +71,14 @@ export interface IReflexRun {
|
|
|
70
71
|
commandId: string | null;
|
|
71
72
|
/** The Discord component that started a LIVE run; null otherwise. */
|
|
72
73
|
componentId: string | null;
|
|
74
|
+
/** The task that started a LIVE run, by a tick of its cron or a delayed run; null otherwise. */
|
|
75
|
+
taskId: string | null;
|
|
76
|
+
/** How the task started the run: RECURRING for a tick of its cron, DELAYED for a delayed run; null when no task did. */
|
|
77
|
+
scheduledRunOrigin: ScheduledRunOrigin | null;
|
|
73
78
|
/**
|
|
74
79
|
* What started the run, for a screen: `METHOD path` for a route, `/name` for a command, the custom id
|
|
75
|
-
* prefix for a component. Null for a test run, and when the route, command
|
|
80
|
+
* prefix for a component, the name for a task. Null for a test run, and when the route, command,
|
|
81
|
+
* component or task was deleted.
|
|
76
82
|
*/
|
|
77
83
|
originLabel: string | null;
|
|
78
84
|
/** The HTTP status the caller of a LIVE run got; null for a test run. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
DiscordSyncStatus,
|
|
3
|
+
ScheduleSyncStatus,
|
|
3
4
|
ServiceDeploymentAction,
|
|
4
5
|
ServiceDeploymentStatus,
|
|
5
6
|
} from '../../enum';
|
|
@@ -32,6 +33,11 @@ export interface IReflexServiceDeployment {
|
|
|
32
33
|
/** Code and message of the Discord refusal when `discordSync` is FAILED (500 characters at most). */
|
|
33
34
|
discordSyncError: string | null;
|
|
34
35
|
discordSyncedAt: Date | null;
|
|
36
|
+
/** Synchronization of the cron tasks of the version with Flow; null when the version has no cron task. */
|
|
37
|
+
scheduleSync: ScheduleSyncStatus | null;
|
|
38
|
+
/** Code and message of the failure when `scheduleSync` is FAILED (500 characters at most). */
|
|
39
|
+
scheduleSyncError: string | null;
|
|
40
|
+
scheduleSyncedAt: Date | null;
|
|
35
41
|
/** The bot was paused by the plan quota (ADR-0277), not by a member: only those resume with the plan. */
|
|
36
42
|
pausedForQuota: boolean;
|
|
37
43
|
isCurrent: boolean;
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
IReflexDiscordComponentSnapshot,
|
|
5
5
|
} from './reflex-discord.model';
|
|
6
6
|
import type { IReflexServiceCors } from './reflex-service.model';
|
|
7
|
+
import type { IReflexTaskSnapshot } from './reflex-task.model';
|
|
7
8
|
|
|
8
9
|
/** A route as a version of the Service froze it. */
|
|
9
10
|
export interface IReflexServiceVersionRoute {
|
|
@@ -38,6 +39,8 @@ export interface IReflexServiceVersionSnapshot {
|
|
|
38
39
|
rateLimitPerIpPerMinute: number;
|
|
39
40
|
/** Only a `DISCORD_BOT` Service has it (its `routes` are then empty); absent otherwise, so the hash of other versions is unchanged. */
|
|
40
41
|
discord?: IReflexServiceVersionDiscord;
|
|
42
|
+
/** The tasks of the Service, by name; absent when it has none, so the hash of other versions is unchanged. */
|
|
43
|
+
tasks?: IReflexTaskSnapshot[];
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
export interface IReflexServiceVersion {
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ScheduledRunOrigin, ScheduledRunStatus } from '../../enum';
|
|
2
|
+
|
|
3
|
+
/** Bounds of the tasks of a Service and of their delayed runs; the API, the edge and their databases apply the same ones. */
|
|
4
|
+
export const REFLEX_TASK_LIMITS = {
|
|
5
|
+
/** `^[-_a-z0-9]{1,32}$`: the name `abyss.schedule.*` targets. */
|
|
6
|
+
namePattern: /^[-_a-z0-9]{1,32}$/,
|
|
7
|
+
maxTasksPerService: 20,
|
|
8
|
+
nameMaxLength: 32,
|
|
9
|
+
/** Characters of the payload of a delayed run, serialized to JSON. */
|
|
10
|
+
payloadMaxLength: 4096,
|
|
11
|
+
/** Shortest delay of a delayed run. */
|
|
12
|
+
delayMinSeconds: 1,
|
|
13
|
+
/** Furthest due date of a delayed run. */
|
|
14
|
+
delayMaxDays: 30,
|
|
15
|
+
/** Lateness past which a tick of a cron is EXPIRED instead of run (after a pause or an outage). */
|
|
16
|
+
recurringToleranceMinutes: 5,
|
|
17
|
+
/** Lateness past which a delayed run is EXPIRED instead of run. */
|
|
18
|
+
delayedToleranceMinutes: 60,
|
|
19
|
+
/** Attempts of a scheduled run interrupted before its end (at least once). */
|
|
20
|
+
maxAttempts: 3,
|
|
21
|
+
/** Runs of a task one page of its history holds at most (and by default). */
|
|
22
|
+
scheduledRunPageMax: 50,
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
/** A task of the draft of a Service: a named target of a cron and of `abyss.schedule.*`. */
|
|
26
|
+
export interface IReflexTask {
|
|
27
|
+
id: string;
|
|
28
|
+
serviceId: string;
|
|
29
|
+
/** A function of the same Service. */
|
|
30
|
+
functionId: string;
|
|
31
|
+
/** Unique within the Service. */
|
|
32
|
+
name: string;
|
|
33
|
+
/** A cron of 5 fields, read in `timezone`, at most one tick a minute; null for a task only delayed runs start. */
|
|
34
|
+
schedule: string | null;
|
|
35
|
+
/** IANA time zone of the cron; `Etc/UTC` by default. */
|
|
36
|
+
timezone: string;
|
|
37
|
+
createdAt: Date;
|
|
38
|
+
updatedAt: Date;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** A task as a version of the Service froze it. */
|
|
42
|
+
export type IReflexTaskSnapshot = Pick<
|
|
43
|
+
IReflexTask,
|
|
44
|
+
'id' | 'functionId' | 'name' | 'schedule' | 'timezone'
|
|
45
|
+
>;
|
|
46
|
+
|
|
47
|
+
/** A delayed run waiting for its due date in one environment. */
|
|
48
|
+
export interface IReflexDelayedRun {
|
|
49
|
+
id: string;
|
|
50
|
+
serviceId: string;
|
|
51
|
+
environmentId: string;
|
|
52
|
+
taskId: string;
|
|
53
|
+
/** The name of the task in the version in service; null when that version no longer has it. */
|
|
54
|
+
taskName: string | null;
|
|
55
|
+
dueAt: Date;
|
|
56
|
+
/**
|
|
57
|
+
* The deduplication key it was scheduled with; null without one. A key deduplicates per task: a task holds one
|
|
58
|
+
* pending run of a key at a time, and another task of the Service may hold a run of the same key.
|
|
59
|
+
* `abyss.schedule.cancel(key)` cancels the pending runs of that key in every task of the Service in the
|
|
60
|
+
* environment.
|
|
61
|
+
*/
|
|
62
|
+
key: string | null;
|
|
63
|
+
/** The payload handed to the run; null without one. */
|
|
64
|
+
payload: unknown;
|
|
65
|
+
/** Attempts already made (interrupted runs taken again). */
|
|
66
|
+
attempts: number;
|
|
67
|
+
/** The live run that scheduled it. */
|
|
68
|
+
scheduledByRunId: string | null;
|
|
69
|
+
createdAt: Date;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A run of a task in one environment, as the execution plane holds it, whatever its status: a tick of its cron or a
|
|
74
|
+
* delayed run, due, running or ended (kept 7 days after its end). The runs that ran nothing (EXPIRED, SKIPPED,
|
|
75
|
+
* CANCELLED, FAILED with TASK_REMOVED) are only seen here: the run journal holds what was executed.
|
|
76
|
+
*/
|
|
77
|
+
export interface IReflexScheduledRun {
|
|
78
|
+
id: string;
|
|
79
|
+
/** A tick of the cron, or a delayed run the code scheduled. */
|
|
80
|
+
kind: ScheduledRunOrigin;
|
|
81
|
+
status: ScheduledRunStatus;
|
|
82
|
+
/**
|
|
83
|
+
* Why FAILED, null otherwise: a `ScheduledRunFailureCode` the plane wrote itself, or the error code of the live
|
|
84
|
+
* run that failed.
|
|
85
|
+
*/
|
|
86
|
+
failureCode: string | null;
|
|
87
|
+
/** When the run was due. */
|
|
88
|
+
scheduledFor: Date;
|
|
89
|
+
/** When its last attempt began, from the live run; null when nothing ran (or the live run is purged). */
|
|
90
|
+
startedAt: Date | null;
|
|
91
|
+
/** When it ended; null while PENDING or CLAIMED. */
|
|
92
|
+
finishedAt: Date | null;
|
|
93
|
+
/** Attempts begun, 3 at most. */
|
|
94
|
+
attempts: number;
|
|
95
|
+
/** The live run of its last attempt, to open in the run journal; null when nothing ran (or it is purged). */
|
|
96
|
+
liveRunId: string | null;
|
|
97
|
+
}
|