@abyss-project/reflex 1.0.0 → 1.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 (120) 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 +19 -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 +2 -0
  55. package/dist/types/interface/models/index.js +2 -0
  56. package/dist/types/interface/models/index.js.map +1 -1
  57. package/dist/types/interface/models/reflex-execution-settings.model.d.ts +36 -0
  58. package/dist/types/interface/models/reflex-execution-settings.model.js +16 -0
  59. package/dist/types/interface/models/reflex-execution-settings.model.js.map +1 -0
  60. package/dist/types/interface/models/reflex-run.model.d.ts +52 -1
  61. package/dist/types/interface/models/reflex-step-stats.model.d.ts +22 -0
  62. package/dist/types/interface/models/reflex-step-stats.model.js +3 -0
  63. package/dist/types/interface/models/reflex-step-stats.model.js.map +1 -0
  64. package/package.json +1 -1
  65. package/src/api/function-access.api.ts +36 -36
  66. package/src/api/function-promotion.api.ts +42 -42
  67. package/src/api/function-run.api.ts +13 -1
  68. package/src/api/function-settings.api.ts +59 -0
  69. package/src/api/function-test.api.ts +33 -33
  70. package/src/api/function-trigger.api.ts +52 -52
  71. package/src/api/function-version.api.ts +19 -0
  72. package/src/api/function.api.test.ts +90 -1
  73. package/src/api/function.api.ts +62 -62
  74. package/src/api/index.ts +1 -0
  75. package/src/index.ts +17 -0
  76. package/src/types/enum/access-grant-status.enum.ts +12 -12
  77. package/src/types/enum/access-kind.enum.ts +7 -7
  78. package/src/types/enum/execution-mode.enum.ts +9 -0
  79. package/src/types/enum/execution-profile.enum.ts +20 -0
  80. package/src/types/enum/execution-settings-source.enum.ts +9 -0
  81. package/src/types/enum/index.ts +5 -0
  82. package/src/types/enum/reflex-error-code.enum.ts +19 -19
  83. package/src/types/enum/run-log-level.enum.ts +6 -0
  84. package/src/types/enum/run-mode.enum.ts +11 -11
  85. package/src/types/enum/run-status.enum.ts +7 -0
  86. package/src/types/enum/run-step-status.enum.ts +7 -0
  87. package/src/types/enum/trace-effect-type.enum.ts +6 -0
  88. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  89. package/src/types/enum/trigger-type.enum.ts +4 -4
  90. package/src/types/interface/api/index.ts +3 -3
  91. package/src/types/interface/api/requests/function-access.request.ts +25 -25
  92. package/src/types/interface/api/requests/function-promotion.request.ts +25 -25
  93. package/src/types/interface/api/requests/function-run.request.ts +7 -0
  94. package/src/types/interface/api/requests/function-settings.request.ts +27 -0
  95. package/src/types/interface/api/requests/function-test.request.ts +19 -19
  96. package/src/types/interface/api/requests/function-trigger.request.ts +28 -28
  97. package/src/types/interface/api/requests/function-version.request.ts +10 -0
  98. package/src/types/interface/api/requests/function.request.ts +34 -34
  99. package/src/types/interface/api/requests/index.ts +1 -0
  100. package/src/types/interface/api/response.ts +4 -4
  101. package/src/types/interface/api/responses/function-access.response.ts +17 -17
  102. package/src/types/interface/api/responses/function-promotion.response.ts +18 -18
  103. package/src/types/interface/api/responses/function-run.response.ts +7 -2
  104. package/src/types/interface/api/responses/function-settings.response.ts +33 -0
  105. package/src/types/interface/api/responses/function-test.response.ts +12 -12
  106. package/src/types/interface/api/responses/function-trigger.response.ts +24 -24
  107. package/src/types/interface/api/responses/function-version.response.ts +20 -1
  108. package/src/types/interface/api/responses/function.response.ts +25 -25
  109. package/src/types/interface/api/responses/index.ts +1 -0
  110. package/src/types/interface/index.ts +3 -3
  111. package/src/types/interface/models/index.ts +2 -0
  112. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  113. package/src/types/interface/models/reflex-definition.model.ts +23 -23
  114. package/src/types/interface/models/reflex-environment-pointer.model.ts +18 -18
  115. package/src/types/interface/models/reflex-execution-settings.model.ts +53 -0
  116. package/src/types/interface/models/reflex-function-version.model.ts +14 -14
  117. package/src/types/interface/models/reflex-function.model.ts +14 -14
  118. package/src/types/interface/models/reflex-run.model.ts +107 -5
  119. package/src/types/interface/models/reflex-step-stats.model.ts +35 -0
  120. package/src/types/interface/models/reflex-trigger.model.ts +17 -17
@@ -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
+ }
@@ -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,96 @@ 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-0239). */
84
+ export interface IReflexRunMetrics {
85
+ /** The settings it ran with. */
86
+ profile: ExecutionProfile;
87
+ memoryLimitMb: number;
88
+ guaranteedCpu: boolean;
89
+ /** Measured by the runner in the isolate. */
90
+ cpuMs: number;
91
+ heapPeakBytes: number;
92
+ /** Measured by the host: bytes sent and received by `fetch`, plus the answer sent to the caller. */
93
+ netOutBytes: number;
94
+ netInBytes: number;
95
+ httpCalls: number;
96
+ storeWrites: number;
97
+ /** In thousandths of a credit; 0 for an interrupted execution, which is offered. */
98
+ costMillicredits: number;
99
+ }
100
+
101
+ /** What one step of a run consumed; its cost is its share of the run's, the fixed price aside. */
102
+ export interface IReflexRunStep {
103
+ /** 0 for the first step that ran. */
104
+ position: number;
105
+ stepId: string;
106
+ status: RunStepStatus;
107
+ durationMs: number;
108
+ cpuMs: number;
109
+ heapPeakBytes: number;
110
+ netOutBytes: number;
111
+ netInBytes: number;
112
+ httpCalls: number;
113
+ storeWrites: number;
114
+ costMillicredits: number;
115
+ }
116
+
117
+ /**
118
+ * One log line a run wrote: a LOG step, `abyss.log.*` or `console.*`. Secrets masked (`***`); a message
119
+ * is cut at 2048 characters, and data whose JSON is longer becomes `{ truncated: true, preview }`. At most
120
+ * 100 lines per run, then one last `warn` line says how many were left out.
121
+ */
122
+ export interface IReflexRunLog {
123
+ /** 0 for the first line. */
124
+ position: number;
125
+ /** The step that wrote it. */
126
+ stepId: string;
127
+ level: RunLogLevel;
128
+ message: string;
129
+ /** The value given with the message; null when none was. */
130
+ data: unknown;
131
+ loggedAt: Date;
132
+ }
133
+
134
+ /**
135
+ * One run with the steps it ran and the lines it logged, in order. Both are empty for a run recorded
136
+ * before the measures (and the steps for a running execution).
137
+ */
138
+ export interface IReflexRunDetail extends IReflexRun {
139
+ steps: IReflexRunStep[];
140
+ logs: IReflexRunLog[];
141
+ }
142
+
143
+ /** The state of a live execution, read by its id (the `executionId` an async trigger answers with). */
144
+ export interface IReflexExecutionState {
145
+ id: string;
146
+ status: RunStatus;
147
+ executionMode: ExecutionMode;
148
+ startedAt: Date;
149
+ /** When the caller got its answer; for an async execution, the 202. */
150
+ responseSentAt: Date | null;
151
+ /** Null while it runs. */
152
+ finishedAt: Date | null;
153
+ /** The status the caller got. */
154
+ httpStatus: number;
155
+ /** Set when the execution failed. */
156
+ errorCode: string | null;
157
+ /** Null while it runs, or for an execution recorded before the measures. */
158
+ costMillicredits: number | null;
159
+ }
@@ -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
+ }