@abyss-project/reflex 5.6.0 → 5.8.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.
Files changed (68) hide show
  1. package/dist/types/enum/discord-channel-type.enum.d.ts +7 -0
  2. package/dist/types/enum/discord-channel-type.enum.js +12 -0
  3. package/dist/types/enum/discord-channel-type.enum.js.map +1 -0
  4. package/dist/types/enum/discord-host-action.enum.d.ts +31 -0
  5. package/dist/types/enum/discord-host-action.enum.js +36 -0
  6. package/dist/types/enum/discord-host-action.enum.js.map +1 -0
  7. package/dist/types/enum/discord-locale.enum.d.ts +34 -0
  8. package/dist/types/enum/discord-locale.enum.js +39 -0
  9. package/dist/types/enum/discord-locale.enum.js.map +1 -0
  10. package/dist/types/enum/index.d.ts +3 -0
  11. package/dist/types/enum/index.js +3 -0
  12. package/dist/types/enum/index.js.map +1 -1
  13. package/dist/types/interface/api/requests/service-discord.request.d.ts +7 -1
  14. package/dist/types/interface/models/reflex-discord-event.model.d.ts +1 -1
  15. package/dist/types/interface/models/reflex-discord-event.model.js +1 -1
  16. package/dist/types/interface/models/reflex-discord-event.model.js.map +1 -1
  17. package/dist/types/interface/models/reflex-discord.model.d.ts +20 -2
  18. package/dist/types/interface/models/reflex-discord.model.js +2 -0
  19. package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
  20. package/package.json +1 -1
  21. package/src/api/function-insights.api.test.ts +27 -27
  22. package/src/api/function-insights.api.ts +18 -18
  23. package/src/api/index.ts +17 -17
  24. package/src/api/service-discord-event.api.test.ts +106 -106
  25. package/src/api/service-discord-event.api.ts +78 -78
  26. package/src/api/service-discord.api.test.ts +197 -197
  27. package/src/api/service-discord.api.ts +241 -241
  28. package/src/api/service-insights.api.test.ts +36 -36
  29. package/src/api/service-insights.api.ts +42 -42
  30. package/src/discord/discord-event-filter-cases.ts +261 -261
  31. package/src/discord/discord-event-filters.test.ts +91 -91
  32. package/src/discord/discord-event-filters.ts +95 -95
  33. package/src/discord/discord-event-intents.test.ts +112 -112
  34. package/src/discord/discord-event-intents.ts +55 -55
  35. package/src/discord/index.ts +3 -3
  36. package/src/index.test.ts +75 -75
  37. package/src/index.ts +317 -317
  38. package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
  39. package/src/types/enum/discord-channel-type.enum.ts +11 -0
  40. package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
  41. package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
  42. package/src/types/enum/discord-event-status.enum.ts +13 -13
  43. package/src/types/enum/discord-event-type.enum.ts +7 -7
  44. package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
  45. package/src/types/enum/discord-host-action.enum.ts +35 -0
  46. package/src/types/enum/discord-locale.enum.ts +35 -0
  47. package/src/types/enum/index.ts +43 -40
  48. package/src/types/enum/insights-period.enum.ts +8 -8
  49. package/src/types/enum/reflex-error-code.enum.ts +43 -43
  50. package/src/types/enum/scheduled-run-failure-code.enum.ts +12 -12
  51. package/src/types/enum/trigger-kind.enum.ts +8 -8
  52. package/src/types/interface/api/requests/index.ts +15 -15
  53. package/src/types/interface/api/requests/service-discord-event.request.ts +68 -68
  54. package/src/types/interface/api/requests/service-discord.request.ts +173 -161
  55. package/src/types/interface/api/requests/service-insights.request.ts +31 -31
  56. package/src/types/interface/api/responses/index.ts +15 -15
  57. package/src/types/interface/api/responses/service-discord-event.response.ts +24 -24
  58. package/src/types/interface/api/responses/service-discord.response.ts +122 -122
  59. package/src/types/interface/api/responses/service-insights.response.ts +11 -11
  60. package/src/types/interface/api/responses/service-version.response.ts +106 -106
  61. package/src/types/interface/models/index.ts +19 -19
  62. package/src/types/interface/models/reflex-bot-limits.model.ts +92 -92
  63. package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -58
  64. package/src/types/interface/models/reflex-discord-event.model.ts +79 -77
  65. package/src/types/interface/models/reflex-discord.model.ts +45 -4
  66. package/src/types/interface/models/reflex-insights.model.ts +120 -120
  67. package/src/types/interface/models/reflex-run.model.ts +186 -183
  68. package/src/types/interface/models/reflex-service-version.model.ts +61 -61
@@ -1,120 +1,120 @@
1
- import { InsightsPeriod } from '../../enum';
2
- import type { TriggerKind } from '../../enum';
3
-
4
- /** The width of one point of a dashboard, by period. */
5
- export const REFLEX_INSIGHTS_PERIOD_STEP_SECONDS: Record<InsightsPeriod, number> = {
6
- [InsightsPeriod.HOUR_1]: 60,
7
- [InsightsPeriod.HOURS_24]: 300,
8
- [InsightsPeriod.DAYS_7]: 3600,
9
- [InsightsPeriod.DAYS_30]: 21600,
10
- [InsightsPeriod.DAYS_90]: 86400,
11
- };
12
-
13
- /** Upper bounds, in thousandths of a credit, of the cost histogram buckets; one open bucket follows (10 in all). */
14
- export const REFLEX_COST_HISTOGRAM_UPPER_BOUNDS = [
15
- 10, 25, 50, 100, 250, 500, 1000, 2500, 5000,
16
- ] as const;
17
-
18
- /** A trigger is labeled heavy past this multiple of the median cost per run of the Service. */
19
- export const REFLEX_HEAVY_TRIGGER_FACTOR = 5;
20
-
21
- /** A value over the period and over the one just before it; `previous` is null without data before. */
22
- export interface IReflexInsightsTile {
23
- value: number;
24
- previous: number | null;
25
- }
26
-
27
- export interface IReflexInsightsTiles {
28
- runs: IReflexInsightsTile;
29
- failed: IReflexInsightsTile;
30
- cpuMs: IReflexInsightsTile;
31
- heapPeakBytesMax: IReflexInsightsTile;
32
- netBytes: IReflexInsightsTile;
33
- costMillicredits: IReflexInsightsTile;
34
- }
35
-
36
- /** One point of the series; `at` is the start of its step. */
37
- export interface IReflexInsightsPoint {
38
- at: Date;
39
- runs: number;
40
- failed: number;
41
- durationMsSum: number;
42
- cpuMsSum: number;
43
- netInBytes: number;
44
- netOutBytes: number;
45
- costMillicredits: number;
46
- /** Mean cost of a run, in thousandths of a credit; null when no run. */
47
- costMeanMillicredits: number | null;
48
- /** 95th percentile of the cost of a run: upper bound of the histogram bucket holding it; null when no run. */
49
- costP95Millicredits: number | null;
50
- }
51
-
52
- /** Runs of one kind of trigger, over the period. */
53
- export interface IReflexInsightsKindShare {
54
- kind: TriggerKind;
55
- runs: number;
56
- failed: number;
57
- }
58
-
59
- /** One row of the ranking of the triggers. */
60
- export interface IReflexInsightsRankingRow {
61
- kind: TriggerKind;
62
- triggerId: string;
63
- /** `/name`, `METHOD path`, a prefix or a name; null when the trigger was deleted. */
64
- label: string | null;
65
- runs: number;
66
- failed: number;
67
- costMillicreditsTotal: number;
68
- costMillicreditsPerRun: number;
69
- cpuMsMean: number;
70
- durationMsMean: number;
71
- /** Cost per run past `REFLEX_HEAVY_TRIGGER_FACTOR` times the median of the Service. */
72
- heavy: boolean;
73
- }
74
-
75
- /** The dashboard of a Service or of a function. */
76
- export interface IReflexInsights {
77
- period: InsightsPeriod;
78
- from: Date;
79
- to: Date;
80
- stepSeconds: number;
81
- tiles: IReflexInsightsTiles;
82
- series: IReflexInsightsPoint[];
83
- byKind: IReflexInsightsKindShare[];
84
- /** Top 10 of the triggers, by total credits; the screen sorts the rows it holds. */
85
- ranking: IReflexInsightsRankingRow[];
86
- }
87
-
88
- /** Events received by the Gateway in one step, with the reason of each one it did not keep. */
89
- export interface IReflexEventInsightsPoint {
90
- at: Date;
91
- received: number;
92
- queued: number;
93
- executed: number;
94
- failed: number;
95
- duplicates: number;
96
- filtered: number;
97
- droppedRate: number;
98
- droppedMonthlyCap: number;
99
- droppedCredits: number;
100
- expired: number;
101
- /** Events rejected by each filter, by filter name. */
102
- filteredBy: Record<string, number>;
103
- }
104
-
105
- /** The dashboard of the events of a bot. */
106
- export interface IReflexEventInsights {
107
- period: InsightsPeriod;
108
- from: Date;
109
- to: Date;
110
- stepSeconds: number;
111
- series: IReflexEventInsightsPoint[];
112
- /** The rate of the bot, for the rate line. */
113
- eventsPerMinute: number;
114
- peakPerMinute: number;
115
- minutesAtCap: number;
116
- /** Credits of the month and the spend of the month against the cap. */
117
- creditsMonthMillicredits: number;
118
- spendCents: number;
119
- monthlySpendCapCents: number;
120
- }
1
+ import { InsightsPeriod } from '../../enum';
2
+ import type { TriggerKind } from '../../enum';
3
+
4
+ /** The width of one point of a dashboard, by period. */
5
+ export const REFLEX_INSIGHTS_PERIOD_STEP_SECONDS: Record<InsightsPeriod, number> = {
6
+ [InsightsPeriod.HOUR_1]: 60,
7
+ [InsightsPeriod.HOURS_24]: 300,
8
+ [InsightsPeriod.DAYS_7]: 3600,
9
+ [InsightsPeriod.DAYS_30]: 21600,
10
+ [InsightsPeriod.DAYS_90]: 86400,
11
+ };
12
+
13
+ /** Upper bounds, in thousandths of a credit, of the cost histogram buckets; one open bucket follows (10 in all). */
14
+ export const REFLEX_COST_HISTOGRAM_UPPER_BOUNDS = [
15
+ 10, 25, 50, 100, 250, 500, 1000, 2500, 5000,
16
+ ] as const;
17
+
18
+ /** A trigger is labeled heavy past this multiple of the median cost per run of the Service. */
19
+ export const REFLEX_HEAVY_TRIGGER_FACTOR = 5;
20
+
21
+ /** A value over the period and over the one just before it; `previous` is null without data before. */
22
+ export interface IReflexInsightsTile {
23
+ value: number;
24
+ previous: number | null;
25
+ }
26
+
27
+ export interface IReflexInsightsTiles {
28
+ runs: IReflexInsightsTile;
29
+ failed: IReflexInsightsTile;
30
+ cpuMs: IReflexInsightsTile;
31
+ heapPeakBytesMax: IReflexInsightsTile;
32
+ netBytes: IReflexInsightsTile;
33
+ costMillicredits: IReflexInsightsTile;
34
+ }
35
+
36
+ /** One point of the series; `at` is the start of its step. */
37
+ export interface IReflexInsightsPoint {
38
+ at: Date;
39
+ runs: number;
40
+ failed: number;
41
+ durationMsSum: number;
42
+ cpuMsSum: number;
43
+ netInBytes: number;
44
+ netOutBytes: number;
45
+ costMillicredits: number;
46
+ /** Mean cost of a run, in thousandths of a credit; null when no run. */
47
+ costMeanMillicredits: number | null;
48
+ /** 95th percentile of the cost of a run: upper bound of the histogram bucket holding it; null when no run. */
49
+ costP95Millicredits: number | null;
50
+ }
51
+
52
+ /** Runs of one kind of trigger, over the period. */
53
+ export interface IReflexInsightsKindShare {
54
+ kind: TriggerKind;
55
+ runs: number;
56
+ failed: number;
57
+ }
58
+
59
+ /** One row of the ranking of the triggers. */
60
+ export interface IReflexInsightsRankingRow {
61
+ kind: TriggerKind;
62
+ triggerId: string;
63
+ /** `/name`, `METHOD path`, a prefix or a name; null when the trigger was deleted. */
64
+ label: string | null;
65
+ runs: number;
66
+ failed: number;
67
+ costMillicreditsTotal: number;
68
+ costMillicreditsPerRun: number;
69
+ cpuMsMean: number;
70
+ durationMsMean: number;
71
+ /** Cost per run past `REFLEX_HEAVY_TRIGGER_FACTOR` times the median of the Service. */
72
+ heavy: boolean;
73
+ }
74
+
75
+ /** The dashboard of a Service or of a function. */
76
+ export interface IReflexInsights {
77
+ period: InsightsPeriod;
78
+ from: Date;
79
+ to: Date;
80
+ stepSeconds: number;
81
+ tiles: IReflexInsightsTiles;
82
+ series: IReflexInsightsPoint[];
83
+ byKind: IReflexInsightsKindShare[];
84
+ /** Top 10 of the triggers, by total credits; the screen sorts the rows it holds. */
85
+ ranking: IReflexInsightsRankingRow[];
86
+ }
87
+
88
+ /** Events received by the Gateway in one step, with the reason of each one it did not keep. */
89
+ export interface IReflexEventInsightsPoint {
90
+ at: Date;
91
+ received: number;
92
+ queued: number;
93
+ executed: number;
94
+ failed: number;
95
+ duplicates: number;
96
+ filtered: number;
97
+ droppedRate: number;
98
+ droppedMonthlyCap: number;
99
+ droppedCredits: number;
100
+ expired: number;
101
+ /** Events rejected by each filter, by filter name. */
102
+ filteredBy: Record<string, number>;
103
+ }
104
+
105
+ /** The dashboard of the events of a bot. */
106
+ export interface IReflexEventInsights {
107
+ period: InsightsPeriod;
108
+ from: Date;
109
+ to: Date;
110
+ stepSeconds: number;
111
+ series: IReflexEventInsightsPoint[];
112
+ /** The rate of the bot, for the rate line. */
113
+ eventsPerMinute: number;
114
+ peakPerMinute: number;
115
+ minutesAtCap: number;
116
+ /** Credits of the month and the spend of the month against the cap. */
117
+ creditsMonthMillicredits: number;
118
+ spendCents: number;
119
+ monthlySpendCapCents: number;
120
+ }
@@ -1,183 +1,186 @@
1
- import type {
2
- ExecutionMode,
3
- ExecutionProfile,
4
- RunLogLevel,
5
- RunMode,
6
- RunStatus,
7
- RunStepStatus,
8
- ScheduledRunOrigin,
9
- TraceEffectType,
10
- } from '../../enum';
11
-
12
- export interface IReflexTraceError {
13
- code: string;
14
- message: string;
15
- }
16
-
17
- /**
18
- * One call the run made to the host, in the order they were served. `recorded` is true when the effect
19
- * was recorded instead of executed (a stubbed HTTP call, a Store write kept aside, a wait not waited).
20
- */
21
- export interface IReflexTraceEntry {
22
- stepId: string;
23
- type: TraceEffectType;
24
- /** The host action, for a HOST effect. */
25
- action?: string;
26
- request?: unknown;
27
- response?: unknown;
28
- error?: IReflexTraceError;
29
- recorded: boolean;
30
- }
31
-
32
- /** What the RESPOND step (or `abyss.respond`) built: the response the caller of the route would get. */
33
- export interface IReflexTraceResponse {
34
- status: number;
35
- headers: Record<string, string>;
36
- body: unknown;
37
- }
38
-
39
- /**
40
- * Bounded: past 100 entries, or a value of more than 4 KB, the trace is cut and says so (`truncated`).
41
- * Every secret value the run was given or read is masked (`***`).
42
- */
43
- export interface IReflexRunTrace {
44
- entries: IReflexTraceEntry[];
45
- outcome: {
46
- status: RunStatus;
47
- output?: unknown;
48
- error?: IReflexTraceError & { stepId?: string };
49
- };
50
- response?: IReflexTraceResponse;
51
- truncated: boolean;
52
- }
53
-
54
- export interface IReflexRun {
55
- id: string;
56
- functionId: string;
57
- versionId: string | null;
58
- /**
59
- * The environment the run took place in: the promoted version's for a LIVE run, the one named in the
60
- * request for a test run. Null only for a test run recorded before test runs named an environment.
61
- */
62
- environmentId: string | null;
63
- mode: RunMode;
64
- status: RunStatus;
65
- durationMs: number;
66
- /** The effects of a test run; null for a LIVE run, which records no trace (nothing of the caller is kept). */
67
- trace: IReflexRunTrace | null;
68
- /** The route that started a LIVE run; null for a test run and for a run a Discord command or component started. */
69
- routeId: string | null;
70
- /** The Discord command that started a LIVE run; null otherwise. */
71
- commandId: string | null;
72
- /** The Discord component that started a LIVE run; null otherwise. */
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
- /** The event trigger that started a LIVE run; null otherwise. */
77
- eventTriggerId: string | null;
78
- /** Trace id of an execution of an event: the id of its inbox row without dashes, the same at every attempt; null for the other origins. */
79
- traceId: string | null;
80
- /** How the task started the run: RECURRING for a tick of its cron, DELAYED for a delayed run; null when no task did. */
81
- scheduledRunOrigin: ScheduledRunOrigin | null;
82
- /**
83
- * What started the run, for a screen: `METHOD path` for a route, `/name` for a command, the custom id
84
- * prefix for a component, the name for a task or an event trigger. Null for a test run, and when the route, command,
85
- * component, task or event trigger was deleted.
86
- */
87
- originLabel: string | null;
88
- /** The HTTP status the caller of a LIVE run got; null for a test run. */
89
- httpStatus: number | null;
90
- /** 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. */
91
- errorCode: string | null;
92
- /** The execution mode of the function when a LIVE run started; null for a test run. */
93
- executionMode: ExecutionMode | null;
94
- /** When the caller of a LIVE run got its answer; null for a test run, or before any answer. */
95
- responseSentAt: Date | null;
96
- /**
97
- * What the run consumed and cost: measured by the runner for a live run and for a test run (with the
98
- * function's effective settings in the run's environment, and the network of its stubs); null for a running execution, or a run
99
- * recorded before the measures.
100
- */
101
- metrics: IReflexRunMetrics | null;
102
- createdByUserId: string | null;
103
- createdAt: Date;
104
- }
105
-
106
- /** What a live execution consumed, and what it costs (ADR-0244). */
107
- export interface IReflexRunMetrics {
108
- /** The profile it ran with, and the memory that profile allocates. */
109
- profile: ExecutionProfile;
110
- memoryLimitMb: number;
111
- /** Measured by the runner in the isolate. */
112
- cpuMs: number;
113
- heapPeakBytes: number;
114
- /** Measured by the host: bytes sent and received by `fetch`, plus the answer sent to the caller. */
115
- netOutBytes: number;
116
- netInBytes: number;
117
- httpCalls: number;
118
- storeWrites: number;
119
- /** In thousandths of a credit; 0 for an interrupted execution, which is offered. */
120
- costMillicredits: number;
121
- }
122
-
123
- /** What one step of a run consumed; its cost is its share of the run's, the fixed price aside. */
124
- export interface IReflexRunStep {
125
- /** 0 for the first step that ran. */
126
- position: number;
127
- stepId: string;
128
- status: RunStepStatus;
129
- durationMs: number;
130
- cpuMs: number;
131
- heapPeakBytes: number;
132
- netOutBytes: number;
133
- netInBytes: number;
134
- httpCalls: number;
135
- storeWrites: number;
136
- costMillicredits: number;
137
- }
138
-
139
- /**
140
- * One log line a run wrote: a LOG step, `abyss.log.*` or `console.*`. Secrets masked (`***`); a message
141
- * is cut at 2048 characters, and data whose JSON is longer becomes `{ truncated: true, preview }`. At most
142
- * 100 lines per run are kept; `IReflexRunDetail.droppedLogLines` counts the others.
143
- */
144
- export interface IReflexRunLog {
145
- /** 0 for the first line. */
146
- position: number;
147
- /** The step that wrote it. */
148
- stepId: string;
149
- level: RunLogLevel;
150
- message: string;
151
- /** The value given with the message; null when none was. */
152
- data: unknown;
153
- loggedAt: Date;
154
- }
155
-
156
- /**
157
- * One run with the steps it ran and the lines it logged, in order. Both are empty for a run recorded
158
- * before the measures (and the steps for a running execution).
159
- */
160
- export interface IReflexRunDetail extends IReflexRun {
161
- steps: IReflexRunStep[];
162
- logs: IReflexRunLog[];
163
- /** The log lines written past the 100 kept in `logs`; 0 when none was dropped. */
164
- droppedLogLines: number;
165
- }
166
-
167
- /** The state of a live execution, read by its id (the `executionId` an async route answers with). */
168
- export interface IReflexExecutionState {
169
- id: string;
170
- status: RunStatus;
171
- executionMode: ExecutionMode;
172
- startedAt: Date;
173
- /** When the caller got its answer; for an async execution, the 202. */
174
- responseSentAt: Date | null;
175
- /** Null while it runs. */
176
- finishedAt: Date | null;
177
- /** The status the caller got. */
178
- httpStatus: number;
179
- /** Set when the execution failed. */
180
- errorCode: string | null;
181
- /** Null while it runs, or for an execution recorded before the measures. */
182
- costMillicredits: number | null;
183
- }
1
+ import type {
2
+ ExecutionMode,
3
+ ExecutionProfile,
4
+ RunLogLevel,
5
+ RunMode,
6
+ RunStatus,
7
+ RunStepStatus,
8
+ ScheduledRunOrigin,
9
+ TraceEffectType,
10
+ } from '../../enum';
11
+
12
+ export interface IReflexTraceError {
13
+ code: string;
14
+ message: string;
15
+ }
16
+
17
+ /**
18
+ * One call the run made to the host, in the order they were served. `recorded` is true when the effect
19
+ * was recorded instead of executed (a stubbed HTTP call, a Store write kept aside, a wait not waited).
20
+ */
21
+ export interface IReflexTraceEntry {
22
+ stepId: string;
23
+ type: TraceEffectType;
24
+ /** The host action, for a HOST effect. */
25
+ action?: string;
26
+ request?: unknown;
27
+ response?: unknown;
28
+ error?: IReflexTraceError;
29
+ recorded: boolean;
30
+ }
31
+
32
+ /** What the RESPOND step (or `abyss.respond`) built: the response the caller of the route would get. */
33
+ export interface IReflexTraceResponse {
34
+ status: number;
35
+ headers: Record<string, string>;
36
+ body: unknown;
37
+ }
38
+
39
+ /**
40
+ * Bounded: past 100 entries, or a value of more than 4 KB, the trace is cut and says so (`truncated`).
41
+ * Every secret value the run was given or read is masked (`***`).
42
+ */
43
+ export interface IReflexRunTrace {
44
+ entries: IReflexTraceEntry[];
45
+ outcome: {
46
+ status: RunStatus;
47
+ output?: unknown;
48
+ error?: IReflexTraceError & { stepId?: string };
49
+ };
50
+ response?: IReflexTraceResponse;
51
+ truncated: boolean;
52
+ }
53
+
54
+ export interface IReflexRun {
55
+ id: string;
56
+ functionId: string;
57
+ versionId: string | null;
58
+ /**
59
+ * The environment the run took place in: the promoted version's for a LIVE run, the one named in the
60
+ * request for a test run. Null only for a test run recorded before test runs named an environment.
61
+ */
62
+ environmentId: string | null;
63
+ mode: RunMode;
64
+ status: RunStatus;
65
+ durationMs: number;
66
+ /** The effects of a test run; null for a LIVE run, which records no trace (nothing of the caller is kept). */
67
+ trace: IReflexRunTrace | null;
68
+ /** The route that started a LIVE run; null for a test run and for a run a Discord command or component started. */
69
+ routeId: string | null;
70
+ /** The Discord command that started a LIVE run; null otherwise. */
71
+ commandId: string | null;
72
+ /** The Discord component that started a LIVE run; null otherwise. */
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
+ /** The event trigger that started a LIVE run; null otherwise. */
77
+ eventTriggerId: string | null;
78
+ /**
79
+ * Monitor trace id of the run (32 hex characters; for an event, the id of its inbox row without dashes, the same
80
+ * at every attempt); null when the run was not sent to Monitor (non-bot Service, HTTP route).
81
+ */
82
+ traceId: string | null;
83
+ /** How the task started the run: RECURRING for a tick of its cron, DELAYED for a delayed run; null when no task did. */
84
+ scheduledRunOrigin: ScheduledRunOrigin | null;
85
+ /**
86
+ * What started the run, for a screen: `METHOD path` for a route, `/name` for a command, the custom id
87
+ * prefix for a component, the name for a task or an event trigger. Null for a test run, and when the route, command,
88
+ * component, task or event trigger was deleted.
89
+ */
90
+ originLabel: string | null;
91
+ /** The HTTP status the caller of a LIVE run got; null for a test run. */
92
+ httpStatus: number | null;
93
+ /** 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. */
94
+ errorCode: string | null;
95
+ /** The execution mode of the function when a LIVE run started; null for a test run. */
96
+ executionMode: ExecutionMode | null;
97
+ /** When the caller of a LIVE run got its answer; null for a test run, or before any answer. */
98
+ responseSentAt: Date | null;
99
+ /**
100
+ * What the run consumed and cost: measured by the runner for a live run and for a test run (with the
101
+ * function's effective settings in the run's environment, and the network of its stubs); null for a running execution, or a run
102
+ * recorded before the measures.
103
+ */
104
+ metrics: IReflexRunMetrics | null;
105
+ createdByUserId: string | null;
106
+ createdAt: Date;
107
+ }
108
+
109
+ /** What a live execution consumed, and what it costs (ADR-0244). */
110
+ export interface IReflexRunMetrics {
111
+ /** The profile it ran with, and the memory that profile allocates. */
112
+ profile: ExecutionProfile;
113
+ memoryLimitMb: number;
114
+ /** Measured by the runner in the isolate. */
115
+ cpuMs: number;
116
+ heapPeakBytes: number;
117
+ /** Measured by the host: bytes sent and received by `fetch`, plus the answer sent to the caller. */
118
+ netOutBytes: number;
119
+ netInBytes: number;
120
+ httpCalls: number;
121
+ storeWrites: number;
122
+ /** In thousandths of a credit; 0 for an interrupted execution, which is offered. */
123
+ costMillicredits: number;
124
+ }
125
+
126
+ /** What one step of a run consumed; its cost is its share of the run's, the fixed price aside. */
127
+ export interface IReflexRunStep {
128
+ /** 0 for the first step that ran. */
129
+ position: number;
130
+ stepId: string;
131
+ status: RunStepStatus;
132
+ durationMs: number;
133
+ cpuMs: number;
134
+ heapPeakBytes: number;
135
+ netOutBytes: number;
136
+ netInBytes: number;
137
+ httpCalls: number;
138
+ storeWrites: number;
139
+ costMillicredits: number;
140
+ }
141
+
142
+ /**
143
+ * One log line a run wrote: a LOG step, `abyss.log.*` or `console.*`. Secrets masked (`***`); a message
144
+ * is cut at 2048 characters, and data whose JSON is longer becomes `{ truncated: true, preview }`. At most
145
+ * 100 lines per run are kept; `IReflexRunDetail.droppedLogLines` counts the others.
146
+ */
147
+ export interface IReflexRunLog {
148
+ /** 0 for the first line. */
149
+ position: number;
150
+ /** The step that wrote it. */
151
+ stepId: string;
152
+ level: RunLogLevel;
153
+ message: string;
154
+ /** The value given with the message; null when none was. */
155
+ data: unknown;
156
+ loggedAt: Date;
157
+ }
158
+
159
+ /**
160
+ * One run with the steps it ran and the lines it logged, in order. Both are empty for a run recorded
161
+ * before the measures (and the steps for a running execution).
162
+ */
163
+ export interface IReflexRunDetail extends IReflexRun {
164
+ steps: IReflexRunStep[];
165
+ logs: IReflexRunLog[];
166
+ /** The log lines written past the 100 kept in `logs`; 0 when none was dropped. */
167
+ droppedLogLines: number;
168
+ }
169
+
170
+ /** The state of a live execution, read by its id (the `executionId` an async route answers with). */
171
+ export interface IReflexExecutionState {
172
+ id: string;
173
+ status: RunStatus;
174
+ executionMode: ExecutionMode;
175
+ startedAt: Date;
176
+ /** When the caller got its answer; for an async execution, the 202. */
177
+ responseSentAt: Date | null;
178
+ /** Null while it runs. */
179
+ finishedAt: Date | null;
180
+ /** The status the caller got. */
181
+ httpStatus: number;
182
+ /** Set when the execution failed. */
183
+ errorCode: string | null;
184
+ /** Null while it runs, or for an execution recorded before the measures. */
185
+ costMillicredits: number | null;
186
+ }