@abyss-project/reflex 1.0.0 → 1.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.
Files changed (127) hide show
  1. package/dist/api/function-run.api.d.ts +2 -1
  2. package/dist/api/function-run.api.js +3 -1
  3. package/dist/api/function-run.api.js.map +1 -1
  4. package/dist/api/function-settings.api.d.ts +5 -0
  5. package/dist/api/function-settings.api.js +15 -0
  6. package/dist/api/function-settings.api.js.map +1 -0
  7. package/dist/api/function-version.api.d.ts +2 -1
  8. package/dist/api/function-version.api.js +3 -1
  9. package/dist/api/function-version.api.js.map +1 -1
  10. package/dist/api/index.d.ts +1 -0
  11. package/dist/api/index.js +1 -0
  12. package/dist/api/index.js.map +1 -1
  13. package/dist/index.d.ts +9 -0
  14. package/dist/index.js +9 -0
  15. package/dist/index.js.map +1 -1
  16. package/dist/types/enum/execution-mode.enum.d.ts +4 -0
  17. package/dist/types/enum/execution-mode.enum.js +9 -0
  18. package/dist/types/enum/execution-mode.enum.js.map +1 -0
  19. package/dist/types/enum/execution-profile.enum.d.ts +8 -0
  20. package/dist/types/enum/execution-profile.enum.js +19 -0
  21. package/dist/types/enum/execution-profile.enum.js.map +1 -0
  22. package/dist/types/enum/execution-settings-source.enum.d.ts +5 -0
  23. package/dist/types/enum/execution-settings-source.enum.js +10 -0
  24. package/dist/types/enum/execution-settings-source.enum.js.map +1 -0
  25. package/dist/types/enum/index.d.ts +5 -0
  26. package/dist/types/enum/index.js +5 -0
  27. package/dist/types/enum/index.js.map +1 -1
  28. package/dist/types/enum/run-log-level.enum.d.ts +5 -0
  29. package/dist/types/enum/run-log-level.enum.js +10 -0
  30. package/dist/types/enum/run-log-level.enum.js.map +1 -0
  31. package/dist/types/enum/run-status.enum.d.ts +3 -1
  32. package/dist/types/enum/run-status.enum.js +2 -0
  33. package/dist/types/enum/run-status.enum.js.map +1 -1
  34. package/dist/types/enum/run-step-status.enum.d.ts +5 -0
  35. package/dist/types/enum/run-step-status.enum.js +10 -0
  36. package/dist/types/enum/run-step-status.enum.js.map +1 -0
  37. package/dist/types/enum/trace-effect-type.enum.js.map +1 -1
  38. package/dist/types/interface/api/requests/function-run.request.d.ts +5 -0
  39. package/dist/types/interface/api/requests/function-settings.request.d.ts +21 -0
  40. package/dist/types/interface/api/requests/function-settings.request.js +3 -0
  41. package/dist/types/interface/api/requests/function-settings.request.js.map +1 -0
  42. package/dist/types/interface/api/requests/function-version.request.d.ts +8 -0
  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/responses/function-run.response.d.ts +6 -2
  47. package/dist/types/interface/api/responses/function-settings.response.d.ts +20 -0
  48. package/dist/types/interface/api/responses/function-settings.response.js +3 -0
  49. package/dist/types/interface/api/responses/function-settings.response.js.map +1 -0
  50. package/dist/types/interface/api/responses/function-version.response.d.ts +10 -1
  51. package/dist/types/interface/api/responses/index.d.ts +1 -0
  52. package/dist/types/interface/api/responses/index.js +1 -0
  53. package/dist/types/interface/api/responses/index.js.map +1 -1
  54. package/dist/types/interface/models/index.d.ts +3 -0
  55. package/dist/types/interface/models/index.js +3 -0
  56. package/dist/types/interface/models/index.js.map +1 -1
  57. package/dist/types/interface/models/reflex-definition.model.d.ts +2 -0
  58. package/dist/types/interface/models/reflex-definition.model.js +3 -0
  59. package/dist/types/interface/models/reflex-definition.model.js.map +1 -1
  60. package/dist/types/interface/models/reflex-execution-settings.model.d.ts +35 -0
  61. package/dist/types/interface/models/reflex-execution-settings.model.js +15 -0
  62. package/dist/types/interface/models/reflex-execution-settings.model.js.map +1 -0
  63. package/dist/types/interface/models/reflex-price-list.model.d.ts +13 -0
  64. package/dist/types/interface/models/reflex-price-list.model.js +3 -0
  65. package/dist/types/interface/models/reflex-price-list.model.js.map +1 -0
  66. package/dist/types/interface/models/reflex-run.model.d.ts +52 -1
  67. package/dist/types/interface/models/reflex-step-stats.model.d.ts +22 -0
  68. package/dist/types/interface/models/reflex-step-stats.model.js +3 -0
  69. package/dist/types/interface/models/reflex-step-stats.model.js.map +1 -0
  70. package/package.json +1 -1
  71. package/src/api/function-access.api.ts +36 -36
  72. package/src/api/function-promotion.api.ts +42 -42
  73. package/src/api/function-run.api.ts +13 -1
  74. package/src/api/function-settings.api.ts +59 -0
  75. package/src/api/function-test.api.ts +33 -33
  76. package/src/api/function-trigger.api.ts +52 -52
  77. package/src/api/function-version.api.ts +19 -0
  78. package/src/api/function.api.test.ts +96 -1
  79. package/src/api/function.api.ts +62 -62
  80. package/src/api/index.ts +1 -0
  81. package/src/index.ts +17 -0
  82. package/src/types/enum/access-grant-status.enum.ts +12 -12
  83. package/src/types/enum/access-kind.enum.ts +7 -7
  84. package/src/types/enum/execution-mode.enum.ts +9 -0
  85. package/src/types/enum/execution-profile.enum.ts +20 -0
  86. package/src/types/enum/execution-settings-source.enum.ts +9 -0
  87. package/src/types/enum/index.ts +5 -0
  88. package/src/types/enum/reflex-error-code.enum.ts +19 -19
  89. package/src/types/enum/run-log-level.enum.ts +6 -0
  90. package/src/types/enum/run-mode.enum.ts +11 -11
  91. package/src/types/enum/run-status.enum.ts +7 -0
  92. package/src/types/enum/run-step-status.enum.ts +7 -0
  93. package/src/types/enum/trace-effect-type.enum.ts +6 -0
  94. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  95. package/src/types/enum/trigger-type.enum.ts +4 -4
  96. package/src/types/interface/api/index.ts +3 -3
  97. package/src/types/interface/api/requests/function-access.request.ts +25 -25
  98. package/src/types/interface/api/requests/function-promotion.request.ts +25 -25
  99. package/src/types/interface/api/requests/function-run.request.ts +7 -0
  100. package/src/types/interface/api/requests/function-settings.request.ts +27 -0
  101. package/src/types/interface/api/requests/function-test.request.ts +19 -19
  102. package/src/types/interface/api/requests/function-trigger.request.ts +28 -28
  103. package/src/types/interface/api/requests/function-version.request.ts +10 -0
  104. package/src/types/interface/api/requests/function.request.ts +34 -34
  105. package/src/types/interface/api/requests/index.ts +1 -0
  106. package/src/types/interface/api/response.ts +4 -4
  107. package/src/types/interface/api/responses/function-access.response.ts +17 -17
  108. package/src/types/interface/api/responses/function-promotion.response.ts +18 -18
  109. package/src/types/interface/api/responses/function-run.response.ts +7 -2
  110. package/src/types/interface/api/responses/function-settings.response.ts +36 -0
  111. package/src/types/interface/api/responses/function-test.response.ts +12 -12
  112. package/src/types/interface/api/responses/function-trigger.response.ts +24 -24
  113. package/src/types/interface/api/responses/function-version.response.ts +20 -1
  114. package/src/types/interface/api/responses/function.response.ts +25 -25
  115. package/src/types/interface/api/responses/index.ts +1 -0
  116. package/src/types/interface/index.ts +3 -3
  117. package/src/types/interface/models/index.ts +3 -0
  118. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  119. package/src/types/interface/models/reflex-definition.model.ts +8 -0
  120. package/src/types/interface/models/reflex-environment-pointer.model.ts +18 -18
  121. package/src/types/interface/models/reflex-execution-settings.model.ts +50 -0
  122. package/src/types/interface/models/reflex-function-version.model.ts +14 -14
  123. package/src/types/interface/models/reflex-function.model.ts +14 -14
  124. package/src/types/interface/models/reflex-price-list.model.ts +20 -0
  125. package/src/types/interface/models/reflex-run.model.ts +108 -5
  126. package/src/types/interface/models/reflex-step-stats.model.ts +35 -0
  127. package/src/types/interface/models/reflex-trigger.model.ts +17 -17
@@ -0,0 +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
+ /** A Monitor environment of the application; 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 Monitor environment of the application runs with. */
40
+ export interface IReflexEffectiveExecutionSettings {
41
+ environmentId: string;
42
+ /** The name of the environment in Monitor. */
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,14 +1,14 @@
1
- import type { IReflexDefinition } from './reflex-definition.model';
2
-
3
- export interface IReflexFunction {
4
- id: string;
5
- applicationId: string;
6
- projectId: string;
7
- name: string;
8
- /** The definition being edited; a publication freezes a copy of it. */
9
- draftDefinition: IReflexDefinition;
10
- createdByUserId: string;
11
- updatedByUserId: string;
12
- createdAt: Date;
13
- updatedAt: Date;
14
- }
1
+ import type { IReflexDefinition } from './reflex-definition.model';
2
+
3
+ export interface IReflexFunction {
4
+ id: string;
5
+ applicationId: string;
6
+ projectId: string;
7
+ name: string;
8
+ /** The definition being edited; a publication freezes a copy of it. */
9
+ draftDefinition: IReflexDefinition;
10
+ createdByUserId: string;
11
+ updatedByUserId: string;
12
+ createdAt: Date;
13
+ updatedAt: Date;
14
+ }
@@ -0,0 +1,20 @@
1
+ import type { ExecutionProfile } from '../../enum';
2
+
3
+ /**
4
+ * The price list an execution is billed with (ADR-0240), 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,11 +1,22 @@
1
- import type { RunMode, RunStatus, TraceEffectType } from '../../enum';
1
+ import type {
2
+ ExecutionMode,
3
+ ExecutionProfile,
4
+ RunLogLevel,
5
+ RunMode,
6
+ RunStatus,
7
+ RunStepStatus,
8
+ TraceEffectType,
9
+ } from '../../enum';
2
10
 
3
11
  export interface IReflexTraceError {
4
12
  code: string;
5
13
  message: string;
6
14
  }
7
15
 
8
- /** One effect of the run. `recorded` is true when the effect was recorded instead of executed. */
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
+ */
9
20
  export interface IReflexTraceEntry {
10
21
  stepId: string;
11
22
  type: TraceEffectType;
@@ -17,14 +28,17 @@ export interface IReflexTraceEntry {
17
28
  recorded: boolean;
18
29
  }
19
30
 
20
- /** What `http.respond` built: the response the caller of the trigger would get. */
31
+ /** What the RESPOND step (or `abyss.respond`) built: the response the caller of the trigger would get. */
21
32
  export interface IReflexTraceResponse {
22
33
  status: number;
23
34
  headers: Record<string, string>;
24
35
  body: unknown;
25
36
  }
26
37
 
27
- /** Bounded: past 100 entries, or a value of more than 4 KB, the trace is cut and says so (`truncated`). */
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
+ */
28
42
  export interface IReflexRunTrace {
29
43
  entries: IReflexTraceEntry[];
30
44
  outcome: {
@@ -50,8 +64,97 @@ export interface IReflexRun {
50
64
  triggerId: string | null;
51
65
  /** The HTTP status the caller of a LIVE run got; null for a test run. */
52
66
  httpStatus: number | null;
53
- /** The code of the error a failed LIVE run answered (FUNCTION_FAILED, FUNCTION_TIMEOUT, RUNNER_UNAVAILABLE, RUNNER_SATURATED, INTERNAL_ERROR); null otherwise. */
67
+ /** 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. */
54
68
  errorCode: string | null;
69
+ /** The mode of the trigger that started a LIVE run; null for a test run. */
70
+ executionMode: ExecutionMode | null;
71
+ /** When the caller of a LIVE run got its answer; null for a test run, or before any answer. */
72
+ responseSentAt: Date | null;
73
+ /**
74
+ * What the run consumed and cost: measured by the runner for a live run and for a test run (with the
75
+ * function's default settings, and the network of its stubs); null for a running execution, or a run
76
+ * recorded before the measures.
77
+ */
78
+ metrics: IReflexRunMetrics | null;
55
79
  createdByUserId: string | null;
56
80
  createdAt: Date;
57
81
  }
82
+
83
+ /** What a live execution consumed, and what it costs (ADR-0240). */
84
+ export interface IReflexRunMetrics {
85
+ /** The profile it ran with, and the memory that profile allocates. */
86
+ profile: ExecutionProfile;
87
+ memoryLimitMb: number;
88
+ /** Measured by the runner in the isolate. */
89
+ cpuMs: number;
90
+ heapPeakBytes: number;
91
+ /** Measured by the host: bytes sent and received by `fetch`, plus the answer sent to the caller. */
92
+ netOutBytes: number;
93
+ netInBytes: number;
94
+ httpCalls: number;
95
+ storeWrites: number;
96
+ /** In thousandths of a credit; 0 for an interrupted execution, which is offered. */
97
+ costMillicredits: number;
98
+ }
99
+
100
+ /** What one step of a run consumed; its cost is its share of the run's, the fixed price aside. */
101
+ export interface IReflexRunStep {
102
+ /** 0 for the first step that ran. */
103
+ position: number;
104
+ stepId: string;
105
+ status: RunStepStatus;
106
+ durationMs: number;
107
+ cpuMs: number;
108
+ heapPeakBytes: number;
109
+ netOutBytes: number;
110
+ netInBytes: number;
111
+ httpCalls: number;
112
+ storeWrites: number;
113
+ costMillicredits: number;
114
+ }
115
+
116
+ /**
117
+ * One log line a run wrote: a LOG step, `abyss.log.*` or `console.*`. Secrets masked (`***`); a message
118
+ * is cut at 2048 characters, and data whose JSON is longer becomes `{ truncated: true, preview }`. At most
119
+ * 100 lines per run are kept; `IReflexRunDetail.droppedLogLines` counts the others.
120
+ */
121
+ export interface IReflexRunLog {
122
+ /** 0 for the first line. */
123
+ position: number;
124
+ /** The step that wrote it. */
125
+ stepId: string;
126
+ level: RunLogLevel;
127
+ message: string;
128
+ /** The value given with the message; null when none was. */
129
+ data: unknown;
130
+ loggedAt: Date;
131
+ }
132
+
133
+ /**
134
+ * One run with the steps it ran and the lines it logged, in order. Both are empty for a run recorded
135
+ * before the measures (and the steps for a running execution).
136
+ */
137
+ export interface IReflexRunDetail extends IReflexRun {
138
+ steps: IReflexRunStep[];
139
+ logs: IReflexRunLog[];
140
+ /** The log lines written past the 100 kept in `logs`; 0 when none was dropped. */
141
+ droppedLogLines: number;
142
+ }
143
+
144
+ /** The state of a live execution, read by its id (the `executionId` an async trigger answers with). */
145
+ export interface IReflexExecutionState {
146
+ id: string;
147
+ status: RunStatus;
148
+ executionMode: ExecutionMode;
149
+ startedAt: Date;
150
+ /** When the caller got its answer; for an async execution, the 202. */
151
+ responseSentAt: Date | null;
152
+ /** Null while it runs. */
153
+ finishedAt: Date | null;
154
+ /** The status the caller got. */
155
+ httpStatus: number;
156
+ /** Set when the execution failed. */
157
+ errorCode: string | null;
158
+ /** Null while it runs, or for an execution recorded before the measures. */
159
+ costMillicredits: number | null;
160
+ }
@@ -0,0 +1,35 @@
1
+ /** Median and 95th percentile of a measure, over the executions of the window. */
2
+ export interface IReflexPercentiles {
3
+ median: number;
4
+ p95: number;
5
+ }
6
+
7
+ /**
8
+ * The measured consumption of one step of a version, over the retention window. Interrupted and running
9
+ * executions are left out.
10
+ */
11
+ export interface IReflexStepStats {
12
+ stepId: string;
13
+ /** Executions in which the step ran. */
14
+ executions: number;
15
+ durationMs: IReflexPercentiles;
16
+ cpuMs: IReflexPercentiles;
17
+ heapPeakBytes: IReflexPercentiles;
18
+ costMillicredits: IReflexPercentiles;
19
+ /** 99th percentile of the heap peak: what a smaller profile is compared to. */
20
+ heapPeakP99Bytes: number;
21
+ /** Share of the cost of the executions that this step makes, from 0 to 1; null when they cost nothing. */
22
+ costShare: number | null;
23
+ }
24
+
25
+ /** The p99 heap peak of one step of the version running in an environment. */
26
+ export interface IReflexStepHeapPeak {
27
+ stepId: string;
28
+ heapPeakP99Bytes: number;
29
+ }
30
+
31
+ /** What the settings screen compares a smaller profile to: the version running in the environment. */
32
+ export interface IReflexRunningVersionHeapPeaks {
33
+ versionId: string;
34
+ steps: IReflexStepHeapPeak[];
35
+ }
@@ -1,17 +1,17 @@
1
- import type { TriggerAccessMode, TriggerType } from '../../enum';
2
-
3
- /** Never carries the key or the signing secret: they are shown once, when created or rotated. */
4
- export interface IReflexTrigger {
5
- id: string;
6
- functionId: string;
7
- applicationId: string;
8
- /** The application's slug, first segment of the address (`/<applicationSlug>/<environmentSlug>/<path>`). */
9
- applicationSlug: string;
10
- type: TriggerType;
11
- /** Segments of `[A-Za-z0-9._~-]` joined by `/`, without leading or trailing slash. */
12
- path: string;
13
- accessMode: TriggerAccessMode;
14
- createdByUserId: string;
15
- createdAt: Date;
16
- updatedAt: Date;
17
- }
1
+ import type { TriggerAccessMode, TriggerType } from '../../enum';
2
+
3
+ /** Never carries the key or the signing secret: they are shown once, when created or rotated. */
4
+ export interface IReflexTrigger {
5
+ id: string;
6
+ functionId: string;
7
+ applicationId: string;
8
+ /** The application's slug, first segment of the address (`/<applicationSlug>/<environmentSlug>/<path>`). */
9
+ applicationSlug: string;
10
+ type: TriggerType;
11
+ /** Segments of `[A-Za-z0-9._~-]` joined by `/`, without leading or trailing slash. */
12
+ path: string;
13
+ accessMode: TriggerAccessMode;
14
+ createdByUserId: string;
15
+ createdAt: Date;
16
+ updatedAt: Date;
17
+ }