@abyss-project/reflex 5.0.0 → 5.2.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/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 +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/enum/discord-activity-type.enum.d.ts +7 -0
- package/dist/types/enum/discord-activity-type.enum.js +12 -0
- package/dist/types/enum/discord-activity-type.enum.js.map +1 -0
- package/dist/types/enum/discord-gateway-failure-code.enum.d.ts +5 -0
- package/dist/types/enum/discord-gateway-failure-code.enum.js +10 -0
- package/dist/types/enum/discord-gateway-failure-code.enum.js.map +1 -0
- package/dist/types/enum/discord-gateway-state.enum.d.ts +6 -0
- package/dist/types/enum/discord-gateway-state.enum.js +11 -0
- package/dist/types/enum/discord-gateway-state.enum.js.map +1 -0
- package/dist/types/enum/discord-presence-status.enum.d.ts +5 -0
- package/dist/types/enum/discord-presence-status.enum.js +10 -0
- package/dist/types/enum/discord-presence-status.enum.js.map +1 -0
- 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/interface/api/requests/service-discord.request.d.ts +4 -1
- package/dist/types/interface/api/requests/service-version.request.d.ts +4 -0
- package/dist/types/interface/api/responses/service-version.response.d.ts +4 -0
- package/dist/types/interface/models/reflex-discord.model.d.ts +14 -1
- package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
- 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 +13 -13
- 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-version.api.ts +54 -39
- package/src/api/service.api.test.ts +215 -209
- package/src/api/service.api.ts +55 -55
- package/src/index.ts +2 -0
- package/src/types/enum/discord-activity-type.enum.ts +9 -0
- package/src/types/enum/discord-component-kind.enum.ts +7 -7
- package/src/types/enum/discord-gateway-failure-code.enum.ts +9 -0
- package/src/types/enum/discord-gateway-state.enum.ts +11 -0
- package/src/types/enum/discord-option-type.enum.ts +12 -12
- package/src/types/enum/discord-presence-status.enum.ts +8 -0
- 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/index.ts +4 -0
- package/src/types/interface/api/requests/service-discord.request.ts +128 -118
- package/src/types/interface/api/requests/service-version.request.ts +24 -19
- package/src/types/interface/api/responses/service-discord.response.ts +72 -72
- package/src/types/interface/api/responses/service-version.response.ts +11 -0
- package/src/types/interface/models/reflex-discord.model.ts +146 -117
- package/src/types/interface/models/reflex-run.model.ts +173 -173
|
@@ -1,117 +1,146 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
name: string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
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,173 +1,173 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ExecutionMode,
|
|
3
|
-
ExecutionProfile,
|
|
4
|
-
RunLogLevel,
|
|
5
|
-
RunMode,
|
|
6
|
-
RunStatus,
|
|
7
|
-
RunStepStatus,
|
|
8
|
-
TraceEffectType,
|
|
9
|
-
} from '../../enum';
|
|
10
|
-
|
|
11
|
-
export interface IReflexTraceError {
|
|
12
|
-
code: string;
|
|
13
|
-
message: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* One call the run made to the host, in the order they were served. `recorded` is true when the effect
|
|
18
|
-
* was recorded instead of executed (a stubbed HTTP call, a Store write kept aside, a wait not waited).
|
|
19
|
-
*/
|
|
20
|
-
export interface IReflexTraceEntry {
|
|
21
|
-
stepId: string;
|
|
22
|
-
type: TraceEffectType;
|
|
23
|
-
/** The host action, for a HOST effect. */
|
|
24
|
-
action?: string;
|
|
25
|
-
request?: unknown;
|
|
26
|
-
response?: unknown;
|
|
27
|
-
error?: IReflexTraceError;
|
|
28
|
-
recorded: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** What the RESPOND step (or `abyss.respond`) built: the response the caller of the route would get. */
|
|
32
|
-
export interface IReflexTraceResponse {
|
|
33
|
-
status: number;
|
|
34
|
-
headers: Record<string, string>;
|
|
35
|
-
body: unknown;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Bounded: past 100 entries, or a value of more than 4 KB, the trace is cut and says so (`truncated`).
|
|
40
|
-
* Every secret value the run was given or read is masked (`***`).
|
|
41
|
-
*/
|
|
42
|
-
export interface IReflexRunTrace {
|
|
43
|
-
entries: IReflexTraceEntry[];
|
|
44
|
-
outcome: {
|
|
45
|
-
status: RunStatus;
|
|
46
|
-
output?: unknown;
|
|
47
|
-
error?: IReflexTraceError & { stepId?: string };
|
|
48
|
-
};
|
|
49
|
-
response?: IReflexTraceResponse;
|
|
50
|
-
truncated: boolean;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface IReflexRun {
|
|
54
|
-
id: string;
|
|
55
|
-
functionId: string;
|
|
56
|
-
versionId: string | null;
|
|
57
|
-
/**
|
|
58
|
-
* The environment the run took place in: the promoted version's for a LIVE run, the one named in the
|
|
59
|
-
* request for a test run. Null only for a test run recorded before test runs named an environment.
|
|
60
|
-
*/
|
|
61
|
-
environmentId: string | null;
|
|
62
|
-
mode: RunMode;
|
|
63
|
-
status: RunStatus;
|
|
64
|
-
durationMs: number;
|
|
65
|
-
/** The effects of a test run; null for a LIVE run, which records no trace (nothing of the caller is kept). */
|
|
66
|
-
trace: IReflexRunTrace | null;
|
|
67
|
-
/** The route that started a LIVE run; null for a test run and for a run a Discord command or component started. */
|
|
68
|
-
routeId: string | null;
|
|
69
|
-
/** The Discord command that started a LIVE run; null otherwise. */
|
|
70
|
-
commandId: string | null;
|
|
71
|
-
/** The Discord component that started a LIVE run; null otherwise. */
|
|
72
|
-
componentId: string | null;
|
|
73
|
-
/**
|
|
74
|
-
* 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 or component was deleted.
|
|
76
|
-
*/
|
|
77
|
-
originLabel: string | null;
|
|
78
|
-
/** The HTTP status the caller of a LIVE run got; null for a test run. */
|
|
79
|
-
httpStatus: number | null;
|
|
80
|
-
/** The code of the error a failed LIVE run answered (FUNCTION_FAILED, FUNCTION_TIMEOUT, RUNNER_UNAVAILABLE, RUNNER_SATURATED, INTERNAL_ERROR); null otherwise, an interrupted run included. */
|
|
81
|
-
errorCode: string | null;
|
|
82
|
-
/** The execution mode of the function when a LIVE run started; null for a test run. */
|
|
83
|
-
executionMode: ExecutionMode | null;
|
|
84
|
-
/** When the caller of a LIVE run got its answer; null for a test run, or before any answer. */
|
|
85
|
-
responseSentAt: Date | null;
|
|
86
|
-
/**
|
|
87
|
-
* What the run consumed and cost: measured by the runner for a live run and for a test run (with the
|
|
88
|
-
* function's effective settings in the run's environment, and the network of its stubs); null for a running execution, or a run
|
|
89
|
-
* recorded before the measures.
|
|
90
|
-
*/
|
|
91
|
-
metrics: IReflexRunMetrics | null;
|
|
92
|
-
createdByUserId: string | null;
|
|
93
|
-
createdAt: Date;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/** What a live execution consumed, and what it costs (ADR-0244). */
|
|
97
|
-
export interface IReflexRunMetrics {
|
|
98
|
-
/** The profile it ran with, and the memory that profile allocates. */
|
|
99
|
-
profile: ExecutionProfile;
|
|
100
|
-
memoryLimitMb: number;
|
|
101
|
-
/** Measured by the runner in the isolate. */
|
|
102
|
-
cpuMs: number;
|
|
103
|
-
heapPeakBytes: number;
|
|
104
|
-
/** Measured by the host: bytes sent and received by `fetch`, plus the answer sent to the caller. */
|
|
105
|
-
netOutBytes: number;
|
|
106
|
-
netInBytes: number;
|
|
107
|
-
httpCalls: number;
|
|
108
|
-
storeWrites: number;
|
|
109
|
-
/** In thousandths of a credit; 0 for an interrupted execution, which is offered. */
|
|
110
|
-
costMillicredits: number;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** What one step of a run consumed; its cost is its share of the run's, the fixed price aside. */
|
|
114
|
-
export interface IReflexRunStep {
|
|
115
|
-
/** 0 for the first step that ran. */
|
|
116
|
-
position: number;
|
|
117
|
-
stepId: string;
|
|
118
|
-
status: RunStepStatus;
|
|
119
|
-
durationMs: number;
|
|
120
|
-
cpuMs: number;
|
|
121
|
-
heapPeakBytes: number;
|
|
122
|
-
netOutBytes: number;
|
|
123
|
-
netInBytes: number;
|
|
124
|
-
httpCalls: number;
|
|
125
|
-
storeWrites: number;
|
|
126
|
-
costMillicredits: number;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* One log line a run wrote: a LOG step, `abyss.log.*` or `console.*`. Secrets masked (`***`); a message
|
|
131
|
-
* is cut at 2048 characters, and data whose JSON is longer becomes `{ truncated: true, preview }`. At most
|
|
132
|
-
* 100 lines per run are kept; `IReflexRunDetail.droppedLogLines` counts the others.
|
|
133
|
-
*/
|
|
134
|
-
export interface IReflexRunLog {
|
|
135
|
-
/** 0 for the first line. */
|
|
136
|
-
position: number;
|
|
137
|
-
/** The step that wrote it. */
|
|
138
|
-
stepId: string;
|
|
139
|
-
level: RunLogLevel;
|
|
140
|
-
message: string;
|
|
141
|
-
/** The value given with the message; null when none was. */
|
|
142
|
-
data: unknown;
|
|
143
|
-
loggedAt: Date;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* One run with the steps it ran and the lines it logged, in order. Both are empty for a run recorded
|
|
148
|
-
* before the measures (and the steps for a running execution).
|
|
149
|
-
*/
|
|
150
|
-
export interface IReflexRunDetail extends IReflexRun {
|
|
151
|
-
steps: IReflexRunStep[];
|
|
152
|
-
logs: IReflexRunLog[];
|
|
153
|
-
/** The log lines written past the 100 kept in `logs`; 0 when none was dropped. */
|
|
154
|
-
droppedLogLines: number;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/** The state of a live execution, read by its id (the `executionId` an async route answers with). */
|
|
158
|
-
export interface IReflexExecutionState {
|
|
159
|
-
id: string;
|
|
160
|
-
status: RunStatus;
|
|
161
|
-
executionMode: ExecutionMode;
|
|
162
|
-
startedAt: Date;
|
|
163
|
-
/** When the caller got its answer; for an async execution, the 202. */
|
|
164
|
-
responseSentAt: Date | null;
|
|
165
|
-
/** Null while it runs. */
|
|
166
|
-
finishedAt: Date | null;
|
|
167
|
-
/** The status the caller got. */
|
|
168
|
-
httpStatus: number;
|
|
169
|
-
/** Set when the execution failed. */
|
|
170
|
-
errorCode: string | null;
|
|
171
|
-
/** Null while it runs, or for an execution recorded before the measures. */
|
|
172
|
-
costMillicredits: number | null;
|
|
173
|
-
}
|
|
1
|
+
import type {
|
|
2
|
+
ExecutionMode,
|
|
3
|
+
ExecutionProfile,
|
|
4
|
+
RunLogLevel,
|
|
5
|
+
RunMode,
|
|
6
|
+
RunStatus,
|
|
7
|
+
RunStepStatus,
|
|
8
|
+
TraceEffectType,
|
|
9
|
+
} from '../../enum';
|
|
10
|
+
|
|
11
|
+
export interface IReflexTraceError {
|
|
12
|
+
code: string;
|
|
13
|
+
message: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* One call the run made to the host, in the order they were served. `recorded` is true when the effect
|
|
18
|
+
* was recorded instead of executed (a stubbed HTTP call, a Store write kept aside, a wait not waited).
|
|
19
|
+
*/
|
|
20
|
+
export interface IReflexTraceEntry {
|
|
21
|
+
stepId: string;
|
|
22
|
+
type: TraceEffectType;
|
|
23
|
+
/** The host action, for a HOST effect. */
|
|
24
|
+
action?: string;
|
|
25
|
+
request?: unknown;
|
|
26
|
+
response?: unknown;
|
|
27
|
+
error?: IReflexTraceError;
|
|
28
|
+
recorded: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** What the RESPOND step (or `abyss.respond`) built: the response the caller of the route would get. */
|
|
32
|
+
export interface IReflexTraceResponse {
|
|
33
|
+
status: number;
|
|
34
|
+
headers: Record<string, string>;
|
|
35
|
+
body: unknown;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Bounded: past 100 entries, or a value of more than 4 KB, the trace is cut and says so (`truncated`).
|
|
40
|
+
* Every secret value the run was given or read is masked (`***`).
|
|
41
|
+
*/
|
|
42
|
+
export interface IReflexRunTrace {
|
|
43
|
+
entries: IReflexTraceEntry[];
|
|
44
|
+
outcome: {
|
|
45
|
+
status: RunStatus;
|
|
46
|
+
output?: unknown;
|
|
47
|
+
error?: IReflexTraceError & { stepId?: string };
|
|
48
|
+
};
|
|
49
|
+
response?: IReflexTraceResponse;
|
|
50
|
+
truncated: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface IReflexRun {
|
|
54
|
+
id: string;
|
|
55
|
+
functionId: string;
|
|
56
|
+
versionId: string | null;
|
|
57
|
+
/**
|
|
58
|
+
* The environment the run took place in: the promoted version's for a LIVE run, the one named in the
|
|
59
|
+
* request for a test run. Null only for a test run recorded before test runs named an environment.
|
|
60
|
+
*/
|
|
61
|
+
environmentId: string | null;
|
|
62
|
+
mode: RunMode;
|
|
63
|
+
status: RunStatus;
|
|
64
|
+
durationMs: number;
|
|
65
|
+
/** The effects of a test run; null for a LIVE run, which records no trace (nothing of the caller is kept). */
|
|
66
|
+
trace: IReflexRunTrace | null;
|
|
67
|
+
/** The route that started a LIVE run; null for a test run and for a run a Discord command or component started. */
|
|
68
|
+
routeId: string | null;
|
|
69
|
+
/** The Discord command that started a LIVE run; null otherwise. */
|
|
70
|
+
commandId: string | null;
|
|
71
|
+
/** The Discord component that started a LIVE run; null otherwise. */
|
|
72
|
+
componentId: string | null;
|
|
73
|
+
/**
|
|
74
|
+
* 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 or component was deleted.
|
|
76
|
+
*/
|
|
77
|
+
originLabel: string | null;
|
|
78
|
+
/** The HTTP status the caller of a LIVE run got; null for a test run. */
|
|
79
|
+
httpStatus: number | null;
|
|
80
|
+
/** The code of the error a failed LIVE run answered (FUNCTION_FAILED, FUNCTION_TIMEOUT, RUNNER_UNAVAILABLE, RUNNER_SATURATED, INTERNAL_ERROR); null otherwise, an interrupted run included. */
|
|
81
|
+
errorCode: string | null;
|
|
82
|
+
/** The execution mode of the function when a LIVE run started; null for a test run. */
|
|
83
|
+
executionMode: ExecutionMode | null;
|
|
84
|
+
/** When the caller of a LIVE run got its answer; null for a test run, or before any answer. */
|
|
85
|
+
responseSentAt: Date | null;
|
|
86
|
+
/**
|
|
87
|
+
* What the run consumed and cost: measured by the runner for a live run and for a test run (with the
|
|
88
|
+
* function's effective settings in the run's environment, and the network of its stubs); null for a running execution, or a run
|
|
89
|
+
* recorded before the measures.
|
|
90
|
+
*/
|
|
91
|
+
metrics: IReflexRunMetrics | null;
|
|
92
|
+
createdByUserId: string | null;
|
|
93
|
+
createdAt: Date;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** What a live execution consumed, and what it costs (ADR-0244). */
|
|
97
|
+
export interface IReflexRunMetrics {
|
|
98
|
+
/** The profile it ran with, and the memory that profile allocates. */
|
|
99
|
+
profile: ExecutionProfile;
|
|
100
|
+
memoryLimitMb: number;
|
|
101
|
+
/** Measured by the runner in the isolate. */
|
|
102
|
+
cpuMs: number;
|
|
103
|
+
heapPeakBytes: number;
|
|
104
|
+
/** Measured by the host: bytes sent and received by `fetch`, plus the answer sent to the caller. */
|
|
105
|
+
netOutBytes: number;
|
|
106
|
+
netInBytes: number;
|
|
107
|
+
httpCalls: number;
|
|
108
|
+
storeWrites: number;
|
|
109
|
+
/** In thousandths of a credit; 0 for an interrupted execution, which is offered. */
|
|
110
|
+
costMillicredits: number;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** What one step of a run consumed; its cost is its share of the run's, the fixed price aside. */
|
|
114
|
+
export interface IReflexRunStep {
|
|
115
|
+
/** 0 for the first step that ran. */
|
|
116
|
+
position: number;
|
|
117
|
+
stepId: string;
|
|
118
|
+
status: RunStepStatus;
|
|
119
|
+
durationMs: number;
|
|
120
|
+
cpuMs: number;
|
|
121
|
+
heapPeakBytes: number;
|
|
122
|
+
netOutBytes: number;
|
|
123
|
+
netInBytes: number;
|
|
124
|
+
httpCalls: number;
|
|
125
|
+
storeWrites: number;
|
|
126
|
+
costMillicredits: number;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* One log line a run wrote: a LOG step, `abyss.log.*` or `console.*`. Secrets masked (`***`); a message
|
|
131
|
+
* is cut at 2048 characters, and data whose JSON is longer becomes `{ truncated: true, preview }`. At most
|
|
132
|
+
* 100 lines per run are kept; `IReflexRunDetail.droppedLogLines` counts the others.
|
|
133
|
+
*/
|
|
134
|
+
export interface IReflexRunLog {
|
|
135
|
+
/** 0 for the first line. */
|
|
136
|
+
position: number;
|
|
137
|
+
/** The step that wrote it. */
|
|
138
|
+
stepId: string;
|
|
139
|
+
level: RunLogLevel;
|
|
140
|
+
message: string;
|
|
141
|
+
/** The value given with the message; null when none was. */
|
|
142
|
+
data: unknown;
|
|
143
|
+
loggedAt: Date;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* One run with the steps it ran and the lines it logged, in order. Both are empty for a run recorded
|
|
148
|
+
* before the measures (and the steps for a running execution).
|
|
149
|
+
*/
|
|
150
|
+
export interface IReflexRunDetail extends IReflexRun {
|
|
151
|
+
steps: IReflexRunStep[];
|
|
152
|
+
logs: IReflexRunLog[];
|
|
153
|
+
/** The log lines written past the 100 kept in `logs`; 0 when none was dropped. */
|
|
154
|
+
droppedLogLines: number;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** The state of a live execution, read by its id (the `executionId` an async route answers with). */
|
|
158
|
+
export interface IReflexExecutionState {
|
|
159
|
+
id: string;
|
|
160
|
+
status: RunStatus;
|
|
161
|
+
executionMode: ExecutionMode;
|
|
162
|
+
startedAt: Date;
|
|
163
|
+
/** When the caller got its answer; for an async execution, the 202. */
|
|
164
|
+
responseSentAt: Date | null;
|
|
165
|
+
/** Null while it runs. */
|
|
166
|
+
finishedAt: Date | null;
|
|
167
|
+
/** The status the caller got. */
|
|
168
|
+
httpStatus: number;
|
|
169
|
+
/** Set when the execution failed. */
|
|
170
|
+
errorCode: string | null;
|
|
171
|
+
/** Null while it runs, or for an execution recorded before the measures. */
|
|
172
|
+
costMillicredits: number | null;
|
|
173
|
+
}
|