@abyss-project/reflex 4.0.0 → 5.1.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 (142) hide show
  1. package/dist/api/index.d.ts +1 -0
  2. package/dist/api/index.js +1 -0
  3. package/dist/api/index.js.map +1 -1
  4. package/dist/api/service-discord.api.d.ts +14 -0
  5. package/dist/api/service-discord.api.js +38 -0
  6. package/dist/api/service-discord.api.js.map +1 -0
  7. package/dist/index.d.ts +22 -0
  8. package/dist/index.js +22 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/types/enum/discord-activity-type.enum.d.ts +7 -0
  11. package/dist/types/enum/discord-activity-type.enum.js +12 -0
  12. package/dist/types/enum/discord-activity-type.enum.js.map +1 -0
  13. package/dist/types/enum/discord-component-kind.enum.d.ts +4 -0
  14. package/dist/types/enum/discord-component-kind.enum.js +9 -0
  15. package/dist/types/enum/discord-component-kind.enum.js.map +1 -0
  16. package/dist/types/enum/discord-gateway-failure-code.enum.d.ts +5 -0
  17. package/dist/types/enum/discord-gateway-failure-code.enum.js +10 -0
  18. package/dist/types/enum/discord-gateway-failure-code.enum.js.map +1 -0
  19. package/dist/types/enum/discord-gateway-state.enum.d.ts +6 -0
  20. package/dist/types/enum/discord-gateway-state.enum.js +11 -0
  21. package/dist/types/enum/discord-gateway-state.enum.js.map +1 -0
  22. package/dist/types/enum/discord-option-type.enum.d.ts +11 -0
  23. package/dist/types/enum/discord-option-type.enum.js +16 -0
  24. package/dist/types/enum/discord-option-type.enum.js.map +1 -0
  25. package/dist/types/enum/discord-presence-status.enum.d.ts +5 -0
  26. package/dist/types/enum/discord-presence-status.enum.js +10 -0
  27. package/dist/types/enum/discord-presence-status.enum.js.map +1 -0
  28. package/dist/types/enum/discord-sync-status.enum.d.ts +5 -0
  29. package/dist/types/enum/discord-sync-status.enum.js +10 -0
  30. package/dist/types/enum/discord-sync-status.enum.js.map +1 -0
  31. package/dist/types/enum/discord-token-state.enum.d.ts +6 -0
  32. package/dist/types/enum/discord-token-state.enum.js +11 -0
  33. package/dist/types/enum/discord-token-state.enum.js.map +1 -0
  34. package/dist/types/enum/index.d.ts +8 -0
  35. package/dist/types/enum/index.js +8 -0
  36. package/dist/types/enum/index.js.map +1 -1
  37. package/dist/types/enum/reflex-error-code.enum.d.ts +7 -1
  38. package/dist/types/enum/reflex-error-code.enum.js +6 -0
  39. package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
  40. package/dist/types/enum/service-type.enum.d.ts +2 -1
  41. package/dist/types/enum/service-type.enum.js +1 -0
  42. package/dist/types/enum/service-type.enum.js.map +1 -1
  43. package/dist/types/interface/api/requests/index.d.ts +1 -0
  44. package/dist/types/interface/api/requests/index.js +1 -0
  45. package/dist/types/interface/api/requests/index.js.map +1 -1
  46. package/dist/types/interface/api/requests/service-discord.request.d.ts +97 -0
  47. package/dist/types/interface/api/requests/service-discord.request.js +3 -0
  48. package/dist/types/interface/api/requests/service-discord.request.js.map +1 -0
  49. package/dist/types/interface/api/requests/service.request.d.ts +2 -0
  50. package/dist/types/interface/api/responses/index.d.ts +1 -0
  51. package/dist/types/interface/api/responses/index.js +1 -0
  52. package/dist/types/interface/api/responses/index.js.map +1 -1
  53. package/dist/types/interface/api/responses/service-discord.response.d.ts +50 -0
  54. package/dist/types/interface/api/responses/service-discord.response.js +3 -0
  55. package/dist/types/interface/api/responses/service-discord.response.js.map +1 -0
  56. package/dist/types/interface/api/responses/service-version.response.d.ts +15 -1
  57. package/dist/types/interface/models/index.d.ts +1 -0
  58. package/dist/types/interface/models/index.js +1 -0
  59. package/dist/types/interface/models/index.js.map +1 -1
  60. package/dist/types/interface/models/reflex-discord.model.d.ts +82 -0
  61. package/dist/types/interface/models/reflex-discord.model.js +13 -0
  62. package/dist/types/interface/models/reflex-discord.model.js.map +1 -0
  63. package/dist/types/interface/models/reflex-run.model.d.ts +3 -0
  64. package/dist/types/interface/models/reflex-service-deployment.model.d.ts +5 -1
  65. package/dist/types/interface/models/reflex-service-version.model.d.ts +6 -0
  66. package/dist/types/interface/models/reflex-service.model.d.ts +1 -0
  67. package/package.json +15 -10
  68. package/src/api/index.ts +13 -12
  69. package/src/api/service-configuration.api.ts +16 -16
  70. package/src/api/service-discord.api.test.ts +170 -0
  71. package/src/api/service-discord.api.ts +203 -0
  72. package/src/index.ts +45 -0
  73. package/src/types/enum/access-grant-status.enum.ts +12 -12
  74. package/src/types/enum/access-kind.enum.ts +7 -7
  75. package/src/types/enum/discord-activity-type.enum.ts +9 -0
  76. package/src/types/enum/discord-component-kind.enum.ts +7 -0
  77. package/src/types/enum/discord-gateway-failure-code.enum.ts +9 -0
  78. package/src/types/enum/discord-gateway-state.enum.ts +11 -0
  79. package/src/types/enum/discord-option-type.enum.ts +12 -0
  80. package/src/types/enum/discord-presence-status.enum.ts +8 -0
  81. package/src/types/enum/discord-sync-status.enum.ts +6 -0
  82. package/src/types/enum/discord-token-state.enum.ts +11 -0
  83. package/src/types/enum/execution-mode.enum.ts +9 -9
  84. package/src/types/enum/execution-profile.enum.ts +20 -20
  85. package/src/types/enum/execution-settings-source.enum.ts +9 -9
  86. package/src/types/enum/health-status.enum.ts +4 -4
  87. package/src/types/enum/index.ts +8 -0
  88. package/src/types/enum/reflex-error-code.enum.ts +37 -25
  89. package/src/types/enum/route-method.enum.ts +9 -9
  90. package/src/types/enum/run-log-level.enum.ts +6 -6
  91. package/src/types/enum/run-mode.enum.ts +11 -11
  92. package/src/types/enum/run-status.enum.ts +11 -11
  93. package/src/types/enum/run-step-status.enum.ts +7 -7
  94. package/src/types/enum/service-deployment-action.enum.ts +11 -11
  95. package/src/types/enum/service-deployment-status.enum.ts +5 -5
  96. package/src/types/enum/service-type.enum.ts +9 -7
  97. package/src/types/enum/service-version-change-kind.enum.ts +6 -6
  98. package/src/types/enum/trace-effect-type.enum.ts +12 -12
  99. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  100. package/src/types/index.ts +2 -2
  101. package/src/types/interface/api/index.ts +3 -3
  102. package/src/types/interface/api/requests/function-access.request.ts +25 -25
  103. package/src/types/interface/api/requests/function-run.request.ts +26 -26
  104. package/src/types/interface/api/requests/function-settings.request.ts +27 -27
  105. package/src/types/interface/api/requests/function-test.request.ts +24 -24
  106. package/src/types/interface/api/requests/function-version.request.ts +20 -20
  107. package/src/types/interface/api/requests/function.request.ts +36 -36
  108. package/src/types/interface/api/requests/index.ts +1 -0
  109. package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
  110. package/src/types/interface/api/requests/service-discord.request.ts +128 -0
  111. package/src/types/interface/api/requests/service-route.request.ts +44 -44
  112. package/src/types/interface/api/requests/service-version.request.ts +19 -19
  113. package/src/types/interface/api/requests/service.request.ts +46 -39
  114. package/src/types/interface/api/response.ts +4 -4
  115. package/src/types/interface/api/responses/function-access.response.ts +17 -17
  116. package/src/types/interface/api/responses/function-run.response.ts +18 -18
  117. package/src/types/interface/api/responses/function-settings.response.ts +36 -36
  118. package/src/types/interface/api/responses/function-test.response.ts +12 -12
  119. package/src/types/interface/api/responses/function-version.response.ts +31 -31
  120. package/src/types/interface/api/responses/function.response.ts +25 -25
  121. package/src/types/interface/api/responses/index.ts +1 -0
  122. package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
  123. package/src/types/interface/api/responses/service-discord.response.ts +72 -0
  124. package/src/types/interface/api/responses/service-route.response.ts +31 -31
  125. package/src/types/interface/api/responses/service-version.response.ts +62 -33
  126. package/src/types/interface/api/responses/service.response.ts +31 -31
  127. package/src/types/interface/health.response.ts +7 -7
  128. package/src/types/interface/index.ts +3 -3
  129. package/src/types/interface/models/index.ts +1 -0
  130. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  131. package/src/types/interface/models/reflex-definition.model.ts +31 -31
  132. package/src/types/interface/models/reflex-discord.model.ts +146 -0
  133. package/src/types/interface/models/reflex-execution-settings.model.ts +50 -50
  134. package/src/types/interface/models/reflex-function-version.model.ts +14 -14
  135. package/src/types/interface/models/reflex-function.model.ts +16 -16
  136. package/src/types/interface/models/reflex-price-list.model.ts +20 -20
  137. package/src/types/interface/models/reflex-route.model.ts +19 -19
  138. package/src/types/interface/models/reflex-run.model.ts +173 -164
  139. package/src/types/interface/models/reflex-service-deployment.model.ts +40 -29
  140. package/src/types/interface/models/reflex-service-version.model.ts +55 -43
  141. package/src/types/interface/models/reflex-service.model.ts +45 -43
  142. package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
@@ -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
+ }
@@ -1,16 +1,16 @@
1
- import type { IReflexDefinition } from './reflex-definition.model';
2
-
3
- export interface IReflexFunction {
4
- id: string;
5
- applicationId: string;
6
- /** The Service the function belongs to; deleting the Service deletes it. */
7
- serviceId: string;
8
- projectId: string;
9
- name: string;
10
- /** The definition being edited; a publication freezes a copy of it. */
11
- draftDefinition: IReflexDefinition;
12
- createdByUserId: string;
13
- updatedByUserId: string;
14
- createdAt: Date;
15
- updatedAt: Date;
16
- }
1
+ import type { IReflexDefinition } from './reflex-definition.model';
2
+
3
+ export interface IReflexFunction {
4
+ id: string;
5
+ applicationId: string;
6
+ /** The Service the function belongs to; deleting the Service deletes it. */
7
+ serviceId: string;
8
+ projectId: string;
9
+ name: string;
10
+ /** The definition being edited; a publication freezes a copy of it. */
11
+ draftDefinition: IReflexDefinition;
12
+ createdByUserId: string;
13
+ updatedByUserId: string;
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ }
@@ -1,20 +1,20 @@
1
- import type { ExecutionProfile } from '../../enum';
2
-
3
- /**
4
- * The price list an execution is billed with (ADR-0244), served by the API from the runtime's
5
- * `COST_RATES` and `RESOURCE_PROFILES`, so that a screen that estimates a cost never holds a copy of it.
6
- * Prices are in millicredits (thousandths of a credit).
7
- */
8
- export interface IReflexPriceList {
9
- /** Once per execution; 0 for an interrupted or refused execution. */
10
- executionMillicredits: number;
11
- cpuMillicreditsPerSecond: number;
12
- /** Per GB-second of the memory the profile allocates, GB = 1024 MB. */
13
- memoryMillicreditsPerGbSecond: number;
14
- /** Per MB sent out, MB = 1024 x 1024 bytes. */
15
- networkOutMillicreditsPerMb: number;
16
- httpCallMillicredits: number;
17
- storeWriteMillicredits: number;
18
- /** The memory of each profile, and the coefficient its CPU part is multiplied by. */
19
- profiles: Record<ExecutionProfile, { memoryMb: number; cpuCoefficient: number }>;
20
- }
1
+ import type { ExecutionProfile } from '../../enum';
2
+
3
+ /**
4
+ * The price list an execution is billed with (ADR-0244), served by the API from the runtime's
5
+ * `COST_RATES` and `RESOURCE_PROFILES`, so that a screen that estimates a cost never holds a copy of it.
6
+ * Prices are in millicredits (thousandths of a credit).
7
+ */
8
+ export interface IReflexPriceList {
9
+ /** Once per execution; 0 for an interrupted or refused execution. */
10
+ executionMillicredits: number;
11
+ cpuMillicreditsPerSecond: number;
12
+ /** Per GB-second of the memory the profile allocates, GB = 1024 MB. */
13
+ memoryMillicreditsPerGbSecond: number;
14
+ /** Per MB sent out, MB = 1024 x 1024 bytes. */
15
+ networkOutMillicreditsPerMb: number;
16
+ httpCallMillicredits: number;
17
+ storeWriteMillicredits: number;
18
+ /** The memory of each profile, and the coefficient its CPU part is multiplied by. */
19
+ profiles: Record<ExecutionProfile, { memoryMb: number; cpuCoefficient: number }>;
20
+ }
@@ -1,19 +1,19 @@
1
- import type { RouteMethod, TriggerAccessMode } from '../../enum';
2
-
3
- /**
4
- * A route of the draft of a Service: callable only once a version that holds it is in service in the
5
- * environment. Never carries the key or the signing secret: they are shown once, when created or rotated.
6
- */
7
- export interface IReflexRoute {
8
- id: string;
9
- serviceId: string;
10
- /** A function of the same Service. */
11
- functionId: string;
12
- method: RouteMethod;
13
- /** Segments of `[a-z0-9._~-]` or `:param` joined by `/`, without leading or trailing slash; 20 at most. */
14
- path: string;
15
- accessMode: TriggerAccessMode;
16
- createdByUserId: string;
17
- createdAt: Date;
18
- updatedAt: Date;
19
- }
1
+ import type { RouteMethod, TriggerAccessMode } from '../../enum';
2
+
3
+ /**
4
+ * A route of the draft of a Service: callable only once a version that holds it is in service in the
5
+ * environment. Never carries the key or the signing secret: they are shown once, when created or rotated.
6
+ */
7
+ export interface IReflexRoute {
8
+ id: string;
9
+ serviceId: string;
10
+ /** A function of the same Service. */
11
+ functionId: string;
12
+ method: RouteMethod;
13
+ /** Segments of `[a-z0-9._~-]` or `:param` joined by `/`, without leading or trailing slash; 20 at most. */
14
+ path: string;
15
+ accessMode: TriggerAccessMode;
16
+ createdByUserId: string;
17
+ createdAt: Date;
18
+ updatedAt: Date;
19
+ }
@@ -1,164 +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. */
68
- routeId: string | null;
69
- /** The HTTP status the caller of a LIVE run got; null for a test run. */
70
- httpStatus: number | null;
71
- /** 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. */
72
- errorCode: string | null;
73
- /** The execution mode of the function when a LIVE run started; null for a test run. */
74
- executionMode: ExecutionMode | null;
75
- /** When the caller of a LIVE run got its answer; null for a test run, or before any answer. */
76
- responseSentAt: Date | null;
77
- /**
78
- * What the run consumed and cost: measured by the runner for a live run and for a test run (with the
79
- * function's effective settings in the run's environment, and the network of its stubs); null for a running execution, or a run
80
- * recorded before the measures.
81
- */
82
- metrics: IReflexRunMetrics | null;
83
- createdByUserId: string | null;
84
- createdAt: Date;
85
- }
86
-
87
- /** What a live execution consumed, and what it costs (ADR-0244). */
88
- export interface IReflexRunMetrics {
89
- /** The profile it ran with, and the memory that profile allocates. */
90
- profile: ExecutionProfile;
91
- memoryLimitMb: number;
92
- /** Measured by the runner in the isolate. */
93
- cpuMs: number;
94
- heapPeakBytes: number;
95
- /** Measured by the host: bytes sent and received by `fetch`, plus the answer sent to the caller. */
96
- netOutBytes: number;
97
- netInBytes: number;
98
- httpCalls: number;
99
- storeWrites: number;
100
- /** In thousandths of a credit; 0 for an interrupted execution, which is offered. */
101
- costMillicredits: number;
102
- }
103
-
104
- /** What one step of a run consumed; its cost is its share of the run's, the fixed price aside. */
105
- export interface IReflexRunStep {
106
- /** 0 for the first step that ran. */
107
- position: number;
108
- stepId: string;
109
- status: RunStepStatus;
110
- durationMs: number;
111
- cpuMs: number;
112
- heapPeakBytes: number;
113
- netOutBytes: number;
114
- netInBytes: number;
115
- httpCalls: number;
116
- storeWrites: number;
117
- costMillicredits: number;
118
- }
119
-
120
- /**
121
- * One log line a run wrote: a LOG step, `abyss.log.*` or `console.*`. Secrets masked (`***`); a message
122
- * is cut at 2048 characters, and data whose JSON is longer becomes `{ truncated: true, preview }`. At most
123
- * 100 lines per run are kept; `IReflexRunDetail.droppedLogLines` counts the others.
124
- */
125
- export interface IReflexRunLog {
126
- /** 0 for the first line. */
127
- position: number;
128
- /** The step that wrote it. */
129
- stepId: string;
130
- level: RunLogLevel;
131
- message: string;
132
- /** The value given with the message; null when none was. */
133
- data: unknown;
134
- loggedAt: Date;
135
- }
136
-
137
- /**
138
- * One run with the steps it ran and the lines it logged, in order. Both are empty for a run recorded
139
- * before the measures (and the steps for a running execution).
140
- */
141
- export interface IReflexRunDetail extends IReflexRun {
142
- steps: IReflexRunStep[];
143
- logs: IReflexRunLog[];
144
- /** The log lines written past the 100 kept in `logs`; 0 when none was dropped. */
145
- droppedLogLines: number;
146
- }
147
-
148
- /** The state of a live execution, read by its id (the `executionId` an async route answers with). */
149
- export interface IReflexExecutionState {
150
- id: string;
151
- status: RunStatus;
152
- executionMode: ExecutionMode;
153
- startedAt: Date;
154
- /** When the caller got its answer; for an async execution, the 202. */
155
- responseSentAt: Date | null;
156
- /** Null while it runs. */
157
- finishedAt: Date | null;
158
- /** The status the caller got. */
159
- httpStatus: number;
160
- /** Set when the execution failed. */
161
- errorCode: string | null;
162
- /** Null while it runs, or for an execution recorded before the measures. */
163
- costMillicredits: number | null;
164
- }
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
+ }