@abyss-project/reflex 5.4.0 → 5.6.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 (154) hide show
  1. package/dist/api/function-insights.api.d.ts +2 -0
  2. package/dist/api/function-insights.api.js +7 -0
  3. package/dist/api/function-insights.api.js.map +1 -0
  4. package/dist/api/index.d.ts +3 -0
  5. package/dist/api/index.js +3 -0
  6. package/dist/api/index.js.map +1 -1
  7. package/dist/api/service-discord-event.api.d.ts +6 -0
  8. package/dist/api/service-discord-event.api.js +18 -0
  9. package/dist/api/service-discord-event.api.js.map +1 -0
  10. package/dist/api/service-discord.api.d.ts +3 -1
  11. package/dist/api/service-discord.api.js +5 -1
  12. package/dist/api/service-discord.api.js.map +1 -1
  13. package/dist/api/service-insights.api.d.ts +3 -0
  14. package/dist/api/service-insights.api.js +12 -0
  15. package/dist/api/service-insights.api.js.map +1 -0
  16. package/dist/discord/discord-event-filter-cases.d.ts +15 -0
  17. package/dist/discord/discord-event-filter-cases.js +77 -0
  18. package/dist/discord/discord-event-filter-cases.js.map +1 -0
  19. package/dist/discord/discord-event-filters.d.ts +20 -0
  20. package/dist/discord/discord-event-filters.js +50 -0
  21. package/dist/discord/discord-event-filters.js.map +1 -0
  22. package/dist/discord/discord-event-intents.d.ts +14 -0
  23. package/dist/discord/discord-event-intents.js +38 -0
  24. package/dist/discord/discord-event-intents.js.map +1 -0
  25. package/dist/discord/index.d.ts +3 -0
  26. package/dist/discord/index.js +20 -0
  27. package/dist/discord/index.js.map +1 -0
  28. package/dist/index.d.ts +22 -0
  29. package/dist/index.js +22 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/types/enum/bot-event-block-reason.enum.d.ts +4 -0
  32. package/dist/types/enum/bot-event-block-reason.enum.js +9 -0
  33. package/dist/types/enum/bot-event-block-reason.enum.js.map +1 -0
  34. package/dist/types/enum/discord-event-drop-reason.enum.d.ts +7 -0
  35. package/dist/types/enum/discord-event-drop-reason.enum.js +12 -0
  36. package/dist/types/enum/discord-event-drop-reason.enum.js.map +1 -0
  37. package/dist/types/enum/discord-event-filter-name.enum.d.ts +9 -0
  38. package/dist/types/enum/discord-event-filter-name.enum.js +14 -0
  39. package/dist/types/enum/discord-event-filter-name.enum.js.map +1 -0
  40. package/dist/types/enum/discord-event-status.enum.d.ts +7 -0
  41. package/dist/types/enum/discord-event-status.enum.js +12 -0
  42. package/dist/types/enum/discord-event-status.enum.js.map +1 -0
  43. package/dist/types/enum/discord-event-type.enum.d.ts +6 -0
  44. package/dist/types/enum/discord-event-type.enum.js +11 -0
  45. package/dist/types/enum/discord-event-type.enum.js.map +1 -0
  46. package/dist/types/enum/discord-gateway-failure-code.enum.d.ts +2 -1
  47. package/dist/types/enum/discord-gateway-failure-code.enum.js +1 -0
  48. package/dist/types/enum/discord-gateway-failure-code.enum.js.map +1 -1
  49. package/dist/types/enum/index.d.ts +7 -0
  50. package/dist/types/enum/index.js +7 -0
  51. package/dist/types/enum/index.js.map +1 -1
  52. package/dist/types/enum/insights-period.enum.d.ts +7 -0
  53. package/dist/types/enum/insights-period.enum.js +12 -0
  54. package/dist/types/enum/insights-period.enum.js.map +1 -0
  55. package/dist/types/enum/reflex-error-code.enum.d.ts +3 -1
  56. package/dist/types/enum/reflex-error-code.enum.js +2 -0
  57. package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
  58. package/dist/types/enum/scheduled-run-failure-code.enum.d.ts +2 -1
  59. package/dist/types/enum/scheduled-run-failure-code.enum.js +1 -0
  60. package/dist/types/enum/scheduled-run-failure-code.enum.js.map +1 -1
  61. package/dist/types/enum/trigger-kind.enum.d.ts +7 -0
  62. package/dist/types/enum/trigger-kind.enum.js +12 -0
  63. package/dist/types/enum/trigger-kind.enum.js.map +1 -0
  64. package/dist/types/interface/api/requests/index.d.ts +2 -0
  65. package/dist/types/interface/api/requests/index.js +2 -0
  66. package/dist/types/interface/api/requests/index.js.map +1 -1
  67. package/dist/types/interface/api/requests/service-discord-event.request.d.ts +51 -0
  68. package/dist/types/interface/api/requests/service-discord-event.request.js +3 -0
  69. package/dist/types/interface/api/requests/service-discord-event.request.js.map +1 -0
  70. package/dist/types/interface/api/requests/service-discord.request.d.ts +22 -1
  71. package/dist/types/interface/api/requests/service-insights.request.d.ts +25 -0
  72. package/dist/types/interface/api/requests/service-insights.request.js +3 -0
  73. package/dist/types/interface/api/requests/service-insights.request.js.map +1 -0
  74. package/dist/types/interface/api/responses/index.d.ts +2 -0
  75. package/dist/types/interface/api/responses/index.js +2 -0
  76. package/dist/types/interface/api/responses/index.js.map +1 -1
  77. package/dist/types/interface/api/responses/service-discord-event.response.d.ts +18 -0
  78. package/dist/types/interface/api/responses/service-discord-event.response.js +3 -0
  79. package/dist/types/interface/api/responses/service-discord-event.response.js.map +1 -0
  80. package/dist/types/interface/api/responses/service-discord.response.d.ts +30 -5
  81. package/dist/types/interface/api/responses/service-insights.response.d.ts +8 -0
  82. package/dist/types/interface/api/responses/service-insights.response.js +3 -0
  83. package/dist/types/interface/api/responses/service-insights.response.js.map +1 -0
  84. package/dist/types/interface/api/responses/service-version.response.d.ts +9 -1
  85. package/dist/types/interface/models/index.d.ts +4 -0
  86. package/dist/types/interface/models/index.js +4 -0
  87. package/dist/types/interface/models/index.js.map +1 -1
  88. package/dist/types/interface/models/reflex-bot-limits.model.d.ts +56 -0
  89. package/dist/types/interface/models/reflex-bot-limits.model.js +16 -0
  90. package/dist/types/interface/models/reflex-bot-limits.model.js.map +1 -0
  91. package/dist/types/interface/models/reflex-discord-event-log.model.d.ts +38 -0
  92. package/dist/types/interface/models/reflex-discord-event-log.model.js +3 -0
  93. package/dist/types/interface/models/reflex-discord-event-log.model.js.map +1 -0
  94. package/dist/types/interface/models/reflex-discord-event.model.d.ts +41 -0
  95. package/dist/types/interface/models/reflex-discord-event.model.js +23 -0
  96. package/dist/types/interface/models/reflex-discord-event.model.js.map +1 -0
  97. package/dist/types/interface/models/reflex-insights.model.d.ts +83 -0
  98. package/dist/types/interface/models/reflex-insights.model.js +16 -0
  99. package/dist/types/interface/models/reflex-insights.model.js.map +1 -0
  100. package/dist/types/interface/models/reflex-run.model.d.ts +2 -0
  101. package/dist/types/interface/models/reflex-service-version.model.d.ts +2 -0
  102. package/package.json +1 -1
  103. package/src/api/function-insights.api.test.ts +27 -0
  104. package/src/api/function-insights.api.ts +18 -0
  105. package/src/api/index.ts +17 -14
  106. package/src/api/service-discord-event.api.test.ts +106 -0
  107. package/src/api/service-discord-event.api.ts +78 -0
  108. package/src/api/service-discord.api.test.ts +197 -170
  109. package/src/api/service-discord.api.ts +241 -203
  110. package/src/api/service-insights.api.test.ts +36 -0
  111. package/src/api/service-insights.api.ts +42 -0
  112. package/src/api/service-task.api.test.ts +140 -140
  113. package/src/api/service-task.api.ts +141 -141
  114. package/src/discord/discord-event-filter-cases.ts +261 -0
  115. package/src/discord/discord-event-filters.test.ts +91 -0
  116. package/src/discord/discord-event-filters.ts +95 -0
  117. package/src/discord/discord-event-intents.test.ts +112 -0
  118. package/src/discord/discord-event-intents.ts +55 -0
  119. package/src/discord/index.ts +3 -0
  120. package/src/index.test.ts +75 -50
  121. package/src/index.ts +46 -0
  122. package/src/types/enum/bot-event-block-reason.enum.ts +7 -0
  123. package/src/types/enum/discord-event-drop-reason.enum.ts +13 -0
  124. package/src/types/enum/discord-event-filter-name.enum.ts +11 -0
  125. package/src/types/enum/discord-event-status.enum.ts +13 -0
  126. package/src/types/enum/discord-event-type.enum.ts +7 -0
  127. package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -9
  128. package/src/types/enum/index.ts +7 -0
  129. package/src/types/enum/insights-period.enum.ts +8 -0
  130. package/src/types/enum/reflex-error-code.enum.ts +43 -39
  131. package/src/types/enum/schedule-sync-status.enum.ts +6 -6
  132. package/src/types/enum/scheduled-run-failure-code.enum.ts +2 -0
  133. package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
  134. package/src/types/enum/scheduled-run-status.enum.ts +17 -17
  135. package/src/types/enum/trigger-kind.enum.ts +8 -0
  136. package/src/types/interface/api/requests/index.ts +15 -13
  137. package/src/types/interface/api/requests/service-discord-event.request.ts +68 -0
  138. package/src/types/interface/api/requests/service-discord.request.ts +161 -128
  139. package/src/types/interface/api/requests/service-insights.request.ts +31 -0
  140. package/src/types/interface/api/requests/service-task.request.ts +80 -80
  141. package/src/types/interface/api/responses/index.ts +15 -13
  142. package/src/types/interface/api/responses/service-discord-event.response.ts +24 -0
  143. package/src/types/interface/api/responses/service-discord.response.ts +122 -72
  144. package/src/types/interface/api/responses/service-insights.response.ts +11 -0
  145. package/src/types/interface/api/responses/service-task.response.ts +57 -57
  146. package/src/types/interface/api/responses/service-version.response.ts +106 -91
  147. package/src/types/interface/models/index.ts +19 -15
  148. package/src/types/interface/models/reflex-bot-limits.model.ts +92 -0
  149. package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -0
  150. package/src/types/interface/models/reflex-discord-event.model.ts +77 -0
  151. package/src/types/interface/models/reflex-insights.model.ts +120 -0
  152. package/src/types/interface/models/reflex-run.model.ts +183 -179
  153. package/src/types/interface/models/reflex-service-version.model.ts +61 -58
  154. package/src/types/interface/models/reflex-task.model.ts +97 -97
@@ -1,179 +1,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
- /** 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;
78
- /**
79
- * What started the run, for a screen: `METHOD path` for a route, `/name` for a command, the custom id
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.
82
- */
83
- originLabel: string | null;
84
- /** The HTTP status the caller of a LIVE run got; null for a test run. */
85
- httpStatus: number | null;
86
- /** 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. */
87
- errorCode: string | null;
88
- /** The execution mode of the function when a LIVE run started; null for a test run. */
89
- executionMode: ExecutionMode | null;
90
- /** When the caller of a LIVE run got its answer; null for a test run, or before any answer. */
91
- responseSentAt: Date | null;
92
- /**
93
- * What the run consumed and cost: measured by the runner for a live run and for a test run (with the
94
- * function's effective settings in the run's environment, and the network of its stubs); null for a running execution, or a run
95
- * recorded before the measures.
96
- */
97
- metrics: IReflexRunMetrics | null;
98
- createdByUserId: string | null;
99
- createdAt: Date;
100
- }
101
-
102
- /** What a live execution consumed, and what it costs (ADR-0244). */
103
- export interface IReflexRunMetrics {
104
- /** The profile it ran with, and the memory that profile allocates. */
105
- profile: ExecutionProfile;
106
- memoryLimitMb: number;
107
- /** Measured by the runner in the isolate. */
108
- cpuMs: number;
109
- heapPeakBytes: number;
110
- /** Measured by the host: bytes sent and received by `fetch`, plus the answer sent to the caller. */
111
- netOutBytes: number;
112
- netInBytes: number;
113
- httpCalls: number;
114
- storeWrites: number;
115
- /** In thousandths of a credit; 0 for an interrupted execution, which is offered. */
116
- costMillicredits: number;
117
- }
118
-
119
- /** What one step of a run consumed; its cost is its share of the run's, the fixed price aside. */
120
- export interface IReflexRunStep {
121
- /** 0 for the first step that ran. */
122
- position: number;
123
- stepId: string;
124
- status: RunStepStatus;
125
- durationMs: number;
126
- cpuMs: number;
127
- heapPeakBytes: number;
128
- netOutBytes: number;
129
- netInBytes: number;
130
- httpCalls: number;
131
- storeWrites: number;
132
- costMillicredits: number;
133
- }
134
-
135
- /**
136
- * One log line a run wrote: a LOG step, `abyss.log.*` or `console.*`. Secrets masked (`***`); a message
137
- * is cut at 2048 characters, and data whose JSON is longer becomes `{ truncated: true, preview }`. At most
138
- * 100 lines per run are kept; `IReflexRunDetail.droppedLogLines` counts the others.
139
- */
140
- export interface IReflexRunLog {
141
- /** 0 for the first line. */
142
- position: number;
143
- /** The step that wrote it. */
144
- stepId: string;
145
- level: RunLogLevel;
146
- message: string;
147
- /** The value given with the message; null when none was. */
148
- data: unknown;
149
- loggedAt: Date;
150
- }
151
-
152
- /**
153
- * One run with the steps it ran and the lines it logged, in order. Both are empty for a run recorded
154
- * before the measures (and the steps for a running execution).
155
- */
156
- export interface IReflexRunDetail extends IReflexRun {
157
- steps: IReflexRunStep[];
158
- logs: IReflexRunLog[];
159
- /** The log lines written past the 100 kept in `logs`; 0 when none was dropped. */
160
- droppedLogLines: number;
161
- }
162
-
163
- /** The state of a live execution, read by its id (the `executionId` an async route answers with). */
164
- export interface IReflexExecutionState {
165
- id: string;
166
- status: RunStatus;
167
- executionMode: ExecutionMode;
168
- startedAt: Date;
169
- /** When the caller got its answer; for an async execution, the 202. */
170
- responseSentAt: Date | null;
171
- /** Null while it runs. */
172
- finishedAt: Date | null;
173
- /** The status the caller got. */
174
- httpStatus: number;
175
- /** Set when the execution failed. */
176
- errorCode: string | null;
177
- /** Null while it runs, or for an execution recorded before the measures. */
178
- costMillicredits: number | null;
179
- }
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,58 +1,61 @@
1
- import type { RouteMethod, TriggerAccessMode } from '../../enum';
2
- import type {
3
- IReflexDiscordCommandSnapshot,
4
- IReflexDiscordComponentSnapshot,
5
- } from './reflex-discord.model';
6
- import type { IReflexServiceCors } from './reflex-service.model';
7
- import type { IReflexTaskSnapshot } from './reflex-task.model';
8
-
9
- /** A route as a version of the Service froze it. */
10
- export interface IReflexServiceVersionRoute {
11
- routeId: string;
12
- method: RouteMethod;
13
- path: string;
14
- functionId: string;
15
- accessMode: TriggerAccessMode;
16
- }
17
-
18
- /** The version of a member function a version of the Service runs. */
19
- export interface IReflexServiceVersionFunction {
20
- functionId: string;
21
- functionVersionId: string;
22
- functionVersionNumber: number;
23
- }
24
-
25
- /** What a version of a Discord bot freezes: its commands and components, identifiers included. */
26
- export interface IReflexServiceVersionDiscord {
27
- commands: IReflexDiscordCommandSnapshot[];
28
- components: IReflexDiscordComponentSnapshot[];
29
- }
30
-
31
- /**
32
- * What a version of the Service freezes. Routes sorted by path then method, functions by id: the same
33
- * Service always gives the same snapshot, and the same `hash`.
34
- */
35
- export interface IReflexServiceVersionSnapshot {
36
- routes: IReflexServiceVersionRoute[];
37
- functions: IReflexServiceVersionFunction[];
38
- cors: IReflexServiceCors;
39
- rateLimitPerIpPerMinute: number;
40
- /** Only a `DISCORD_BOT` Service has it (its `routes` are then empty); absent otherwise, so the hash of other versions is unchanged. */
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[];
44
- }
45
-
46
- export interface IReflexServiceVersion {
47
- id: string;
48
- serviceId: string;
49
- /** 1, 2, 3...: counted per Service. */
50
- number: number;
51
- /** 500 characters at most. */
52
- message: string | null;
53
- snapshot: IReflexServiceVersionSnapshot;
54
- /** SHA-256 of the snapshot as canonical JSON (keys sorted), lowercase hex. */
55
- hash: string;
56
- publishedByUserId: string;
57
- publishedAt: Date;
58
- }
1
+ import type { RouteMethod, TriggerAccessMode } from '../../enum';
2
+ import type {
3
+ IReflexDiscordCommandSnapshot,
4
+ IReflexDiscordComponentSnapshot,
5
+ } from './reflex-discord.model';
6
+ import type { IReflexDiscordEventSnapshot } from './reflex-discord-event.model';
7
+ import type { IReflexServiceCors } from './reflex-service.model';
8
+ import type { IReflexTaskSnapshot } from './reflex-task.model';
9
+
10
+ /** A route as a version of the Service froze it. */
11
+ export interface IReflexServiceVersionRoute {
12
+ routeId: string;
13
+ method: RouteMethod;
14
+ path: string;
15
+ functionId: string;
16
+ accessMode: TriggerAccessMode;
17
+ }
18
+
19
+ /** The version of a member function a version of the Service runs. */
20
+ export interface IReflexServiceVersionFunction {
21
+ functionId: string;
22
+ functionVersionId: string;
23
+ functionVersionNumber: number;
24
+ }
25
+
26
+ /** What a version of a Discord bot freezes: its commands and components, identifiers included. */
27
+ export interface IReflexServiceVersionDiscord {
28
+ commands: IReflexDiscordCommandSnapshot[];
29
+ components: IReflexDiscordComponentSnapshot[];
30
+ /** The event triggers; absent when the bot has none, so the hash of other versions is unchanged. */
31
+ events?: IReflexDiscordEventSnapshot[];
32
+ }
33
+
34
+ /**
35
+ * What a version of the Service freezes. Routes sorted by path then method, functions by id: the same
36
+ * Service always gives the same snapshot, and the same `hash`.
37
+ */
38
+ export interface IReflexServiceVersionSnapshot {
39
+ routes: IReflexServiceVersionRoute[];
40
+ functions: IReflexServiceVersionFunction[];
41
+ cors: IReflexServiceCors;
42
+ rateLimitPerIpPerMinute: number;
43
+ /** Only a `DISCORD_BOT` Service has it (its `routes` are then empty); absent otherwise, so the hash of other versions is unchanged. */
44
+ discord?: IReflexServiceVersionDiscord;
45
+ /** The tasks of the Service, by name; absent when it has none, so the hash of other versions is unchanged. */
46
+ tasks?: IReflexTaskSnapshot[];
47
+ }
48
+
49
+ export interface IReflexServiceVersion {
50
+ id: string;
51
+ serviceId: string;
52
+ /** 1, 2, 3...: counted per Service. */
53
+ number: number;
54
+ /** 500 characters at most. */
55
+ message: string | null;
56
+ snapshot: IReflexServiceVersionSnapshot;
57
+ /** SHA-256 of the snapshot as canonical JSON (keys sorted), lowercase hex. */
58
+ hash: string;
59
+ publishedByUserId: string;
60
+ publishedAt: Date;
61
+ }