@abyss-project/reflex 5.6.0 → 5.7.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/types/interface/models/reflex-discord-event.model.d.ts +1 -1
- package/dist/types/interface/models/reflex-discord-event.model.js +1 -1
- package/dist/types/interface/models/reflex-discord-event.model.js.map +1 -1
- package/jest.config.ts +11 -11
- 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/service-configuration.api.ts +16 -16
- package/src/api/service-deployment.api.ts +79 -79
- package/src/api/service-route.api.ts +72 -72
- package/src/api/service-task.api.test.ts +140 -140
- package/src/api/service-task.api.ts +141 -141
- package/src/api/service-version.api.ts +54 -54
- package/src/api/service.api.test.ts +215 -215
- package/src/api/service.api.ts +55 -55
- package/src/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-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/route-method.enum.ts +9 -9
- package/src/types/enum/run-log-level.enum.ts +6 -6
- package/src/types/enum/run-mode.enum.ts +11 -11
- package/src/types/enum/run-status.enum.ts +11 -11
- package/src/types/enum/run-step-status.enum.ts +7 -7
- package/src/types/enum/schedule-sync-status.enum.ts +6 -6
- package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
- package/src/types/enum/scheduled-run-status.enum.ts +17 -17
- package/src/types/enum/service-deployment-action.enum.ts +11 -11
- package/src/types/enum/service-deployment-status.enum.ts +5 -5
- package/src/types/enum/service-type.enum.ts +9 -9
- package/src/types/enum/service-version-change-kind.enum.ts +6 -6
- package/src/types/enum/trace-effect-type.enum.ts +12 -12
- package/src/types/enum/trigger-access-mode.enum.ts +12 -12
- package/src/types/enum/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 -30
- package/src/types/interface/api/requests/function-settings.request.ts +27 -27
- package/src/types/interface/api/requests/function-test.request.ts +39 -39
- 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/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-route.request.ts +44 -44
- package/src/types/interface/api/requests/service-task.request.ts +80 -80
- package/src/types/interface/api/requests/service-version.request.ts +24 -24
- 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/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-route.response.ts +31 -31
- package/src/types/interface/api/responses/service-task.response.ts +57 -57
- 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/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-event.model.ts +7 -6
- 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 +4 -1
- package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
- package/src/types/interface/models/reflex-service-deployment.model.ts +46 -46
- 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 +97 -97
- package/tsconfig.check.json +15 -15
- package/tsconfig.json +35 -35
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import type { IReflexService, IReflexServiceDeployment } from '../../models';
|
|
2
|
-
import type { IResponse } from '../response';
|
|
3
|
-
|
|
4
|
-
/** A Service with what runs in each environment of the application. */
|
|
5
|
-
export interface IReflexServiceListItem extends IReflexService {
|
|
6
|
-
/** The current deployment of each environment where the Service was ever put in service. */
|
|
7
|
-
currentDeployments: IReflexServiceDeployment[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface IListServiceData {
|
|
11
|
-
services: IReflexServiceListItem[];
|
|
12
|
-
}
|
|
13
|
-
export type IListServiceResponse = IResponse<IListServiceData>;
|
|
14
|
-
|
|
15
|
-
export interface ICreateServiceData {
|
|
16
|
-
service: IReflexService;
|
|
17
|
-
}
|
|
18
|
-
export type ICreateServiceResponse = IResponse<ICreateServiceData>;
|
|
19
|
-
|
|
20
|
-
export interface IGetServiceData {
|
|
21
|
-
service: IReflexService;
|
|
22
|
-
}
|
|
23
|
-
export type IGetServiceResponse = IResponse<IGetServiceData>;
|
|
24
|
-
|
|
25
|
-
export interface IUpdateServiceData {
|
|
26
|
-
service: IReflexService;
|
|
27
|
-
}
|
|
28
|
-
export type IUpdateServiceResponse = IResponse<IUpdateServiceData>;
|
|
29
|
-
|
|
30
|
-
export type IDeleteServiceData = Record<string, never>;
|
|
31
|
-
export type IDeleteServiceResponse = IResponse<IDeleteServiceData>;
|
|
1
|
+
import type { IReflexService, IReflexServiceDeployment } from '../../models';
|
|
2
|
+
import type { IResponse } from '../response';
|
|
3
|
+
|
|
4
|
+
/** A Service with what runs in each environment of the application. */
|
|
5
|
+
export interface IReflexServiceListItem extends IReflexService {
|
|
6
|
+
/** The current deployment of each environment where the Service was ever put in service. */
|
|
7
|
+
currentDeployments: IReflexServiceDeployment[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface IListServiceData {
|
|
11
|
+
services: IReflexServiceListItem[];
|
|
12
|
+
}
|
|
13
|
+
export type IListServiceResponse = IResponse<IListServiceData>;
|
|
14
|
+
|
|
15
|
+
export interface ICreateServiceData {
|
|
16
|
+
service: IReflexService;
|
|
17
|
+
}
|
|
18
|
+
export type ICreateServiceResponse = IResponse<ICreateServiceData>;
|
|
19
|
+
|
|
20
|
+
export interface IGetServiceData {
|
|
21
|
+
service: IReflexService;
|
|
22
|
+
}
|
|
23
|
+
export type IGetServiceResponse = IResponse<IGetServiceData>;
|
|
24
|
+
|
|
25
|
+
export interface IUpdateServiceData {
|
|
26
|
+
service: IReflexService;
|
|
27
|
+
}
|
|
28
|
+
export type IUpdateServiceResponse = IResponse<IUpdateServiceData>;
|
|
29
|
+
|
|
30
|
+
export type IDeleteServiceData = Record<string, never>;
|
|
31
|
+
export type IDeleteServiceResponse = IResponse<IDeleteServiceData>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { HealthStatus } from '../enum';
|
|
2
|
-
|
|
3
|
-
/** Body of `GET /health`: `200` when both components are up, `503` with the same shape otherwise. */
|
|
4
|
-
export interface IHealthResponse {
|
|
5
|
-
database: HealthStatus;
|
|
6
|
-
redis: HealthStatus;
|
|
7
|
-
}
|
|
1
|
+
import type { HealthStatus } from '../enum';
|
|
2
|
+
|
|
3
|
+
/** Body of `GET /health`: `200` when both components are up, `503` with the same shape otherwise. */
|
|
4
|
+
export interface IHealthResponse {
|
|
5
|
+
database: HealthStatus;
|
|
6
|
+
redis: HealthStatus;
|
|
7
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './health.response';
|
|
2
|
-
export * from './models';
|
|
3
|
-
export * from './api';
|
|
1
|
+
export * from './health.response';
|
|
2
|
+
export * from './models';
|
|
3
|
+
export * from './api';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { AccessGrantStatus } from '../../enum';
|
|
2
|
-
import type { IReflexAccessDeclaration } from './reflex-definition.model';
|
|
3
|
-
|
|
4
|
-
export interface IReflexAccessGrant {
|
|
5
|
-
id: string;
|
|
6
|
-
functionId: string;
|
|
7
|
-
declaration: IReflexAccessDeclaration;
|
|
8
|
-
status: AccessGrantStatus;
|
|
9
|
-
grantedByUserId: string;
|
|
10
|
-
grantedAt: Date;
|
|
11
|
-
suspendedAt: Date | null;
|
|
12
|
-
revokedByUserId: string | null;
|
|
13
|
-
revokedAt: Date | null;
|
|
14
|
-
}
|
|
1
|
+
import type { AccessGrantStatus } from '../../enum';
|
|
2
|
+
import type { IReflexAccessDeclaration } from './reflex-definition.model';
|
|
3
|
+
|
|
4
|
+
export interface IReflexAccessGrant {
|
|
5
|
+
id: string;
|
|
6
|
+
functionId: string;
|
|
7
|
+
declaration: IReflexAccessDeclaration;
|
|
8
|
+
status: AccessGrantStatus;
|
|
9
|
+
grantedByUserId: string;
|
|
10
|
+
grantedAt: Date;
|
|
11
|
+
suspendedAt: Date | null;
|
|
12
|
+
revokedByUserId: string | null;
|
|
13
|
+
revokedAt: Date | null;
|
|
14
|
+
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import type { ReflexAccessKind } from '../../enum';
|
|
2
|
-
|
|
3
|
-
export interface IReflexHttpAccess {
|
|
4
|
-
kind: ReflexAccessKind.HTTP;
|
|
5
|
-
hosts: string[];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface IReflexHostActionAccess {
|
|
9
|
-
kind: ReflexAccessKind.HOST_ACTION;
|
|
10
|
-
action: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type IReflexAccessDeclaration = IReflexHttpAccess | IReflexHostActionAccess;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A function's definition, in the format of @abyss-project/runtime (`formatVersion` 1). The steps are
|
|
17
|
-
* the core's own and validated by the API; the SDK only carries them.
|
|
18
|
-
*/
|
|
19
|
-
export interface IReflexDefinition {
|
|
20
|
-
formatVersion: number;
|
|
21
|
-
accesses: IReflexAccessDeclaration[];
|
|
22
|
-
steps: Array<Record<string, unknown>>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Bounds of the status a RESPOND step (or `abyss.respond`) may answer with, both included: the
|
|
27
|
-
* runtime's `MIN_RESPONSE_STATUS` and `MAX_RESPONSE_STATUS`, which publication and the edge apply.
|
|
28
|
-
* The API's tests check that they are equal.
|
|
29
|
-
*/
|
|
30
|
-
export const RESPOND_STATUS_MIN = 200;
|
|
31
|
-
export const RESPOND_STATUS_MAX = 599;
|
|
1
|
+
import type { ReflexAccessKind } from '../../enum';
|
|
2
|
+
|
|
3
|
+
export interface IReflexHttpAccess {
|
|
4
|
+
kind: ReflexAccessKind.HTTP;
|
|
5
|
+
hosts: string[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IReflexHostActionAccess {
|
|
9
|
+
kind: ReflexAccessKind.HOST_ACTION;
|
|
10
|
+
action: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type IReflexAccessDeclaration = IReflexHttpAccess | IReflexHostActionAccess;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A function's definition, in the format of @abyss-project/runtime (`formatVersion` 1). The steps are
|
|
17
|
+
* the core's own and validated by the API; the SDK only carries them.
|
|
18
|
+
*/
|
|
19
|
+
export interface IReflexDefinition {
|
|
20
|
+
formatVersion: number;
|
|
21
|
+
accesses: IReflexAccessDeclaration[];
|
|
22
|
+
steps: Array<Record<string, unknown>>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Bounds of the status a RESPOND step (or `abyss.respond`) may answer with, both included: the
|
|
27
|
+
* runtime's `MIN_RESPONSE_STATUS` and `MAX_RESPONSE_STATUS`, which publication and the edge apply.
|
|
28
|
+
* The API's tests check that they are equal.
|
|
29
|
+
*/
|
|
30
|
+
export const RESPOND_STATUS_MIN = 200;
|
|
31
|
+
export const RESPOND_STATUS_MAX = 599;
|
|
@@ -21,19 +21,20 @@ export const REFLEX_DISCORD_EVENT_LIMITS = {
|
|
|
21
21
|
} as const;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* What one bot can take in (decision 6 of the J2 spec).
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* What one bot can take in (decision 6 of the J2 spec, ADR-0302). Measured on staging (C1, run 2, 24/11/2026, after
|
|
25
|
+
* the per-bot claim and the sharded rollups): a bot sustains about 3 000 events per minute, bounded by the database
|
|
26
|
+
* (WAL and the `execution_counters` row), not by its slots. `lotsMax` is
|
|
27
|
+
* `min(lotsMaxCeiling, floor((maxConcurrencyPerBot * runsPerSlotPerMinute - base) / 500))` for the largest base.
|
|
27
28
|
*/
|
|
28
29
|
export const REFLEX_BOT_EVENT_CAPACITY = {
|
|
29
|
-
/** Events per minute one execution slot
|
|
30
|
+
/** Events per minute one execution slot sustains: the measured 3 000 per bot spread over its 30 slots. */
|
|
30
31
|
runsPerSlotPerMinute: 100,
|
|
31
32
|
/** `maxReplicas` (3) times the ceiling per pod (10) of the edge fleet. */
|
|
32
33
|
maxConcurrencyPerBot: 30,
|
|
33
34
|
/** The most lots of 500 events per minute a bot can be allocated, whatever the measure says. */
|
|
34
35
|
lotsMaxCeiling: 40,
|
|
35
|
-
/**
|
|
36
|
-
lotsMax:
|
|
36
|
+
/** The most lots a bot can be allocated: floor((30 × 100 − 500) / 500) = 5. */
|
|
37
|
+
lotsMax: 5,
|
|
37
38
|
} as const;
|
|
38
39
|
|
|
39
40
|
/** Optional filters of a trigger, combined with AND. An absent or empty list is no filter. */
|
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DiscordActivityType,
|
|
3
|
-
DiscordComponentKind,
|
|
4
|
-
DiscordGatewayFailureCode,
|
|
5
|
-
DiscordGatewayState,
|
|
6
|
-
DiscordOptionType,
|
|
7
|
-
DiscordPresenceStatus,
|
|
8
|
-
DiscordTokenState,
|
|
9
|
-
} from '../../enum';
|
|
10
|
-
|
|
11
|
-
/** Bounds of the commands and components of a Discord bot; the API and its database apply the same ones. */
|
|
12
|
-
export const REFLEX_DISCORD_LIMITS = {
|
|
13
|
-
/** `^[-_a-z0-9]{1,32}$`: the name typed after the slash. */
|
|
14
|
-
commandNamePattern: /^[-_a-z0-9]{1,32}$/,
|
|
15
|
-
commandDescriptionMaxLength: 100,
|
|
16
|
-
commandsPerServiceMax: 100,
|
|
17
|
-
optionsPerCommandMax: 25,
|
|
18
|
-
choicesPerOptionMax: 25,
|
|
19
|
-
/** `^[a-z0-9_-]{1,40}$`: the start of the `custom_id` of a button, a menu or a form. */
|
|
20
|
-
componentPrefixPattern: /^[a-z0-9_-]{1,40}$/,
|
|
21
|
-
syncErrorMaxLength: 500,
|
|
22
|
-
} as const;
|
|
23
|
-
|
|
24
|
-
/** A fixed answer a user picks for a STRING, INTEGER or NUMBER option. */
|
|
25
|
-
export interface IReflexDiscordOptionChoice {
|
|
26
|
-
name: string;
|
|
27
|
-
value: string | number;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** An option of a command. Required options come first. */
|
|
31
|
-
export interface IReflexDiscordCommandOption {
|
|
32
|
-
type: DiscordOptionType;
|
|
33
|
-
/** Same pattern as the command name. */
|
|
34
|
-
name: string;
|
|
35
|
-
/** 1 to 100 characters. */
|
|
36
|
-
description: string;
|
|
37
|
-
required: boolean;
|
|
38
|
-
/** 25 at most, only for STRING, INTEGER and NUMBER. */
|
|
39
|
-
choices?: IReflexDiscordOptionChoice[];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** A slash command of the draft of a Discord bot Service. */
|
|
43
|
-
export interface IReflexDiscordCommand {
|
|
44
|
-
id: string;
|
|
45
|
-
serviceId: string;
|
|
46
|
-
/** A function of the same Service. */
|
|
47
|
-
functionId: string;
|
|
48
|
-
/** Unique within the Service. */
|
|
49
|
-
name: string;
|
|
50
|
-
description: string;
|
|
51
|
-
options: IReflexDiscordCommandOption[];
|
|
52
|
-
/** Discord permission bits as a decimal string, or null for everyone. */
|
|
53
|
-
defaultMemberPermissions: string | null;
|
|
54
|
-
allowedInDirectMessages: boolean;
|
|
55
|
-
createdAt: Date;
|
|
56
|
-
updatedAt: Date;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** A button, select menu or form of the draft of a Discord bot Service, routed by the start of its `custom_id`. */
|
|
60
|
-
export interface IReflexDiscordComponent {
|
|
61
|
-
id: string;
|
|
62
|
-
serviceId: string;
|
|
63
|
-
/** A function of the same Service. */
|
|
64
|
-
functionId: string;
|
|
65
|
-
/** Unique within the Service; no prefix starts another one. An interaction matches the prefix followed by `:`, or equal to its `custom_id`. */
|
|
66
|
-
customIdPrefix: string;
|
|
67
|
-
kind: DiscordComponentKind;
|
|
68
|
-
createdAt: Date;
|
|
69
|
-
updatedAt: Date;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** A command as a version of the Service froze it. */
|
|
73
|
-
export type IReflexDiscordCommandSnapshot = Pick<
|
|
74
|
-
IReflexDiscordCommand,
|
|
75
|
-
| 'id'
|
|
76
|
-
| 'functionId'
|
|
77
|
-
| 'name'
|
|
78
|
-
| 'description'
|
|
79
|
-
| 'options'
|
|
80
|
-
| 'defaultMemberPermissions'
|
|
81
|
-
| 'allowedInDirectMessages'
|
|
82
|
-
>;
|
|
83
|
-
|
|
84
|
-
/** A component as a version of the Service froze it. */
|
|
85
|
-
export type IReflexDiscordComponentSnapshot = Pick<
|
|
86
|
-
IReflexDiscordComponent,
|
|
87
|
-
'id' | 'functionId' | 'customIdPrefix' | 'kind'
|
|
88
|
-
>;
|
|
89
|
-
|
|
90
|
-
/** Settings of a Discord bot Service in one environment, kept outside the versions. */
|
|
91
|
-
export interface IReflexDiscordEnvironmentSettings {
|
|
92
|
-
id: string;
|
|
93
|
-
serviceId: string;
|
|
94
|
-
environmentId: string;
|
|
95
|
-
/** Discord server (snowflake) the commands are pushed to outside production; required there. */
|
|
96
|
-
testGuildId: string | null;
|
|
97
|
-
/** Discord permission bits as a decimal string, put in the invitation link. */
|
|
98
|
-
invitePermissions: string;
|
|
99
|
-
/** What the bot shows while connected. */
|
|
100
|
-
presenceStatus: DiscordPresenceStatus;
|
|
101
|
-
/** Null for no activity. */
|
|
102
|
-
activityType: DiscordActivityType | null;
|
|
103
|
-
/** 1 to 128 characters with an `activityType`, null without. */
|
|
104
|
-
activityText: string | null;
|
|
105
|
-
createdAt: Date;
|
|
106
|
-
updatedAt: Date;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** The Gateway connection of the bot of one environment, as its row in the execution plane says. */
|
|
110
|
-
export interface IReflexDiscordPresence {
|
|
111
|
-
state: DiscordGatewayState;
|
|
112
|
-
/** Set if and only if `state` is `FAILED`. */
|
|
113
|
-
failureCode: DiscordGatewayFailureCode | null;
|
|
114
|
-
stateChangedAt: Date;
|
|
115
|
-
/** Null until the bot connected once. */
|
|
116
|
-
lastConnectedAt: Date | null;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** What the Connection screen shows of the bot of one environment. Never carries the token. */
|
|
120
|
-
export interface IReflexDiscordEnvironmentConnection {
|
|
121
|
-
environmentId: string;
|
|
122
|
-
/** The Discord application read from the token; null while the token is missing, rejected or unchecked. */
|
|
123
|
-
applicationId: string | null;
|
|
124
|
-
publicKey: string | null;
|
|
125
|
-
botName: string | null;
|
|
126
|
-
botAvatarUrl: string | null;
|
|
127
|
-
tokenState: DiscordTokenState;
|
|
128
|
-
testGuildId: string | null;
|
|
129
|
-
invitePermissions: string;
|
|
130
|
-
presenceStatus: DiscordPresenceStatus;
|
|
131
|
-
activityType: DiscordActivityType | null;
|
|
132
|
-
activityText: string | null;
|
|
133
|
-
/** The Gateway connection; null while the bot is not in service in this environment. */
|
|
134
|
-
presence: IReflexDiscordPresence | null;
|
|
135
|
-
/** Address to give Discord for interactions in this environment. */
|
|
136
|
-
interactionsUrl: string;
|
|
137
|
-
/** Link that adds the bot to a Discord server; null while the application is unknown. */
|
|
138
|
-
inviteUrl: string | null;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/** The Vault entry holding the token, and the bot of each environment of the application. */
|
|
142
|
-
export interface IReflexDiscordConnection {
|
|
143
|
-
/** Vault entry (secret) that holds the bot token, one value per environment; null until chosen. */
|
|
144
|
-
discordTokenSecretId: string | null;
|
|
145
|
-
environments: IReflexDiscordEnvironmentConnection[];
|
|
146
|
-
}
|
|
1
|
+
import type {
|
|
2
|
+
DiscordActivityType,
|
|
3
|
+
DiscordComponentKind,
|
|
4
|
+
DiscordGatewayFailureCode,
|
|
5
|
+
DiscordGatewayState,
|
|
6
|
+
DiscordOptionType,
|
|
7
|
+
DiscordPresenceStatus,
|
|
8
|
+
DiscordTokenState,
|
|
9
|
+
} from '../../enum';
|
|
10
|
+
|
|
11
|
+
/** Bounds of the commands and components of a Discord bot; the API and its database apply the same ones. */
|
|
12
|
+
export const REFLEX_DISCORD_LIMITS = {
|
|
13
|
+
/** `^[-_a-z0-9]{1,32}$`: the name typed after the slash. */
|
|
14
|
+
commandNamePattern: /^[-_a-z0-9]{1,32}$/,
|
|
15
|
+
commandDescriptionMaxLength: 100,
|
|
16
|
+
commandsPerServiceMax: 100,
|
|
17
|
+
optionsPerCommandMax: 25,
|
|
18
|
+
choicesPerOptionMax: 25,
|
|
19
|
+
/** `^[a-z0-9_-]{1,40}$`: the start of the `custom_id` of a button, a menu or a form. */
|
|
20
|
+
componentPrefixPattern: /^[a-z0-9_-]{1,40}$/,
|
|
21
|
+
syncErrorMaxLength: 500,
|
|
22
|
+
} as const;
|
|
23
|
+
|
|
24
|
+
/** A fixed answer a user picks for a STRING, INTEGER or NUMBER option. */
|
|
25
|
+
export interface IReflexDiscordOptionChoice {
|
|
26
|
+
name: string;
|
|
27
|
+
value: string | number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** An option of a command. Required options come first. */
|
|
31
|
+
export interface IReflexDiscordCommandOption {
|
|
32
|
+
type: DiscordOptionType;
|
|
33
|
+
/** Same pattern as the command name. */
|
|
34
|
+
name: string;
|
|
35
|
+
/** 1 to 100 characters. */
|
|
36
|
+
description: string;
|
|
37
|
+
required: boolean;
|
|
38
|
+
/** 25 at most, only for STRING, INTEGER and NUMBER. */
|
|
39
|
+
choices?: IReflexDiscordOptionChoice[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A slash command of the draft of a Discord bot Service. */
|
|
43
|
+
export interface IReflexDiscordCommand {
|
|
44
|
+
id: string;
|
|
45
|
+
serviceId: string;
|
|
46
|
+
/** A function of the same Service. */
|
|
47
|
+
functionId: string;
|
|
48
|
+
/** Unique within the Service. */
|
|
49
|
+
name: string;
|
|
50
|
+
description: string;
|
|
51
|
+
options: IReflexDiscordCommandOption[];
|
|
52
|
+
/** Discord permission bits as a decimal string, or null for everyone. */
|
|
53
|
+
defaultMemberPermissions: string | null;
|
|
54
|
+
allowedInDirectMessages: boolean;
|
|
55
|
+
createdAt: Date;
|
|
56
|
+
updatedAt: Date;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A button, select menu or form of the draft of a Discord bot Service, routed by the start of its `custom_id`. */
|
|
60
|
+
export interface IReflexDiscordComponent {
|
|
61
|
+
id: string;
|
|
62
|
+
serviceId: string;
|
|
63
|
+
/** A function of the same Service. */
|
|
64
|
+
functionId: string;
|
|
65
|
+
/** Unique within the Service; no prefix starts another one. An interaction matches the prefix followed by `:`, or equal to its `custom_id`. */
|
|
66
|
+
customIdPrefix: string;
|
|
67
|
+
kind: DiscordComponentKind;
|
|
68
|
+
createdAt: Date;
|
|
69
|
+
updatedAt: Date;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** A command as a version of the Service froze it. */
|
|
73
|
+
export type IReflexDiscordCommandSnapshot = Pick<
|
|
74
|
+
IReflexDiscordCommand,
|
|
75
|
+
| 'id'
|
|
76
|
+
| 'functionId'
|
|
77
|
+
| 'name'
|
|
78
|
+
| 'description'
|
|
79
|
+
| 'options'
|
|
80
|
+
| 'defaultMemberPermissions'
|
|
81
|
+
| 'allowedInDirectMessages'
|
|
82
|
+
>;
|
|
83
|
+
|
|
84
|
+
/** A component as a version of the Service froze it. */
|
|
85
|
+
export type IReflexDiscordComponentSnapshot = Pick<
|
|
86
|
+
IReflexDiscordComponent,
|
|
87
|
+
'id' | 'functionId' | 'customIdPrefix' | 'kind'
|
|
88
|
+
>;
|
|
89
|
+
|
|
90
|
+
/** Settings of a Discord bot Service in one environment, kept outside the versions. */
|
|
91
|
+
export interface IReflexDiscordEnvironmentSettings {
|
|
92
|
+
id: string;
|
|
93
|
+
serviceId: string;
|
|
94
|
+
environmentId: string;
|
|
95
|
+
/** Discord server (snowflake) the commands are pushed to outside production; required there. */
|
|
96
|
+
testGuildId: string | null;
|
|
97
|
+
/** Discord permission bits as a decimal string, put in the invitation link. */
|
|
98
|
+
invitePermissions: string;
|
|
99
|
+
/** What the bot shows while connected. */
|
|
100
|
+
presenceStatus: DiscordPresenceStatus;
|
|
101
|
+
/** Null for no activity. */
|
|
102
|
+
activityType: DiscordActivityType | null;
|
|
103
|
+
/** 1 to 128 characters with an `activityType`, null without. */
|
|
104
|
+
activityText: string | null;
|
|
105
|
+
createdAt: Date;
|
|
106
|
+
updatedAt: Date;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The Gateway connection of the bot of one environment, as its row in the execution plane says. */
|
|
110
|
+
export interface IReflexDiscordPresence {
|
|
111
|
+
state: DiscordGatewayState;
|
|
112
|
+
/** Set if and only if `state` is `FAILED`. */
|
|
113
|
+
failureCode: DiscordGatewayFailureCode | null;
|
|
114
|
+
stateChangedAt: Date;
|
|
115
|
+
/** Null until the bot connected once. */
|
|
116
|
+
lastConnectedAt: Date | null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** What the Connection screen shows of the bot of one environment. Never carries the token. */
|
|
120
|
+
export interface IReflexDiscordEnvironmentConnection {
|
|
121
|
+
environmentId: string;
|
|
122
|
+
/** The Discord application read from the token; null while the token is missing, rejected or unchecked. */
|
|
123
|
+
applicationId: string | null;
|
|
124
|
+
publicKey: string | null;
|
|
125
|
+
botName: string | null;
|
|
126
|
+
botAvatarUrl: string | null;
|
|
127
|
+
tokenState: DiscordTokenState;
|
|
128
|
+
testGuildId: string | null;
|
|
129
|
+
invitePermissions: string;
|
|
130
|
+
presenceStatus: DiscordPresenceStatus;
|
|
131
|
+
activityType: DiscordActivityType | null;
|
|
132
|
+
activityText: string | null;
|
|
133
|
+
/** The Gateway connection; null while the bot is not in service in this environment. */
|
|
134
|
+
presence: IReflexDiscordPresence | null;
|
|
135
|
+
/** Address to give Discord for interactions in this environment. */
|
|
136
|
+
interactionsUrl: string;
|
|
137
|
+
/** Link that adds the bot to a Discord server; null while the application is unknown. */
|
|
138
|
+
inviteUrl: string | null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** The Vault entry holding the token, and the bot of each environment of the application. */
|
|
142
|
+
export interface IReflexDiscordConnection {
|
|
143
|
+
/** Vault entry (secret) that holds the bot token, one value per environment; null until chosen. */
|
|
144
|
+
discordTokenSecretId: string | null;
|
|
145
|
+
environments: IReflexDiscordEnvironmentConnection[];
|
|
146
|
+
}
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { ExecutionMode, ExecutionProfile } from '../../enum';
|
|
2
|
-
import type { ExecutionSettingsSource } from '../../enum';
|
|
3
|
-
|
|
4
|
-
/** The execution settings of a function in an environment. */
|
|
5
|
-
export interface IReflexExecutionSettingsValues {
|
|
6
|
-
profile: ExecutionProfile;
|
|
7
|
-
/** Past this, a synchronous caller that got no answer receives 504 and the execution goes on. */
|
|
8
|
-
responseTimeoutMs: number;
|
|
9
|
-
/** Past this, the execution is stopped with TIMEOUT. */
|
|
10
|
-
maxDurationMs: number;
|
|
11
|
-
mode: ExecutionMode;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** Bounds of the settings, in milliseconds. */
|
|
15
|
-
export const REFLEX_EXECUTION_SETTINGS_LIMITS = {
|
|
16
|
-
responseTimeoutMs: { min: 1_000, max: 100_000 },
|
|
17
|
-
maxDurationMs: { min: 1_000, max: 3_600_000 },
|
|
18
|
-
} as const;
|
|
19
|
-
|
|
20
|
-
/** What a function runs with when nothing is set. */
|
|
21
|
-
export const DEFAULT_REFLEX_EXECUTION_SETTINGS: Readonly<IReflexExecutionSettingsValues> = {
|
|
22
|
-
profile: ExecutionProfile.S,
|
|
23
|
-
responseTimeoutMs: 30_000,
|
|
24
|
-
maxDurationMs: 30_000,
|
|
25
|
-
mode: ExecutionMode.SYNC,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/** A row of settings: the default of the function (`environmentId` null) or the override of one environment. */
|
|
29
|
-
export interface IReflexExecutionSettings extends IReflexExecutionSettingsValues {
|
|
30
|
-
id: string;
|
|
31
|
-
functionId: string;
|
|
32
|
-
/** An environment of the application (abyss-main's id); null for the default of every environment. */
|
|
33
|
-
environmentId: string | null;
|
|
34
|
-
updatedByUserId: string;
|
|
35
|
-
createdAt: Date;
|
|
36
|
-
updatedAt: Date;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** What one environment of the application runs with. */
|
|
40
|
-
export interface IReflexEffectiveExecutionSettings {
|
|
41
|
-
environmentId: string;
|
|
42
|
-
/** The name of the environment (abyss-main), immutable. */
|
|
43
|
-
environmentSlug: string;
|
|
44
|
-
/** Changing what a production environment runs with needs REFLEX_PUBLISH_PRODUCTION. */
|
|
45
|
-
isProduction: boolean;
|
|
46
|
-
source: ExecutionSettingsSource;
|
|
47
|
-
settings: IReflexExecutionSettingsValues;
|
|
48
|
-
/** The version promoted in this environment, whose step statistics drive the profile warning; null when none. */
|
|
49
|
-
runningVersionId: string | null;
|
|
50
|
-
}
|
|
1
|
+
import { ExecutionMode, ExecutionProfile } from '../../enum';
|
|
2
|
+
import type { ExecutionSettingsSource } from '../../enum';
|
|
3
|
+
|
|
4
|
+
/** The execution settings of a function in an environment. */
|
|
5
|
+
export interface IReflexExecutionSettingsValues {
|
|
6
|
+
profile: ExecutionProfile;
|
|
7
|
+
/** Past this, a synchronous caller that got no answer receives 504 and the execution goes on. */
|
|
8
|
+
responseTimeoutMs: number;
|
|
9
|
+
/** Past this, the execution is stopped with TIMEOUT. */
|
|
10
|
+
maxDurationMs: number;
|
|
11
|
+
mode: ExecutionMode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Bounds of the settings, in milliseconds. */
|
|
15
|
+
export const REFLEX_EXECUTION_SETTINGS_LIMITS = {
|
|
16
|
+
responseTimeoutMs: { min: 1_000, max: 100_000 },
|
|
17
|
+
maxDurationMs: { min: 1_000, max: 3_600_000 },
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
/** What a function runs with when nothing is set. */
|
|
21
|
+
export const DEFAULT_REFLEX_EXECUTION_SETTINGS: Readonly<IReflexExecutionSettingsValues> = {
|
|
22
|
+
profile: ExecutionProfile.S,
|
|
23
|
+
responseTimeoutMs: 30_000,
|
|
24
|
+
maxDurationMs: 30_000,
|
|
25
|
+
mode: ExecutionMode.SYNC,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** A row of settings: the default of the function (`environmentId` null) or the override of one environment. */
|
|
29
|
+
export interface IReflexExecutionSettings extends IReflexExecutionSettingsValues {
|
|
30
|
+
id: string;
|
|
31
|
+
functionId: string;
|
|
32
|
+
/** An environment of the application (abyss-main's id); null for the default of every environment. */
|
|
33
|
+
environmentId: string | null;
|
|
34
|
+
updatedByUserId: string;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** What one environment of the application runs with. */
|
|
40
|
+
export interface IReflexEffectiveExecutionSettings {
|
|
41
|
+
environmentId: string;
|
|
42
|
+
/** The name of the environment (abyss-main), immutable. */
|
|
43
|
+
environmentSlug: string;
|
|
44
|
+
/** Changing what a production environment runs with needs REFLEX_PUBLISH_PRODUCTION. */
|
|
45
|
+
isProduction: boolean;
|
|
46
|
+
source: ExecutionSettingsSource;
|
|
47
|
+
settings: IReflexExecutionSettingsValues;
|
|
48
|
+
/** The version promoted in this environment, whose step statistics drive the profile warning; null when none. */
|
|
49
|
+
runningVersionId: string | null;
|
|
50
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { IReflexDefinition } from './reflex-definition.model';
|
|
2
|
-
|
|
3
|
-
export interface IReflexFunctionVersion {
|
|
4
|
-
id: string;
|
|
5
|
-
functionId: string;
|
|
6
|
-
/** 1, 2, 3...: counted per function. */
|
|
7
|
-
number: number;
|
|
8
|
-
/** The frozen definition. */
|
|
9
|
-
definition: IReflexDefinition;
|
|
10
|
-
/** SHA-256 of the definition, lowercase hex. */
|
|
11
|
-
hash: string;
|
|
12
|
-
publishedByUserId: string;
|
|
13
|
-
publishedAt: Date;
|
|
14
|
-
}
|
|
1
|
+
import type { IReflexDefinition } from './reflex-definition.model';
|
|
2
|
+
|
|
3
|
+
export interface IReflexFunctionVersion {
|
|
4
|
+
id: string;
|
|
5
|
+
functionId: string;
|
|
6
|
+
/** 1, 2, 3...: counted per function. */
|
|
7
|
+
number: number;
|
|
8
|
+
/** The frozen definition. */
|
|
9
|
+
definition: IReflexDefinition;
|
|
10
|
+
/** SHA-256 of the definition, lowercase hex. */
|
|
11
|
+
hash: string;
|
|
12
|
+
publishedByUserId: string;
|
|
13
|
+
publishedAt: Date;
|
|
14
|
+
}
|