@abyss-project/reflex 1.2.0 → 2.0.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 (39) hide show
  1. package/dist/api/function-test.api.d.ts +2 -2
  2. package/dist/api/function-test.api.js +2 -2
  3. package/dist/api/function-test.api.js.map +1 -1
  4. package/dist/types/interface/api/requests/function-test.request.d.ts +1 -0
  5. package/package.json +1 -1
  6. package/src/api/function-promotion.api.ts +42 -42
  7. package/src/api/function-run.api.ts +38 -38
  8. package/src/api/function-settings.api.ts +59 -59
  9. package/src/api/function-test.api.ts +34 -33
  10. package/src/api/function-version.api.ts +56 -56
  11. package/src/api/function.api.test.ts +8 -4
  12. package/src/api/index.ts +9 -9
  13. package/src/index.ts +152 -152
  14. package/src/types/enum/execution-mode.enum.ts +9 -9
  15. package/src/types/enum/execution-profile.enum.ts +20 -20
  16. package/src/types/enum/execution-settings-source.enum.ts +9 -9
  17. package/src/types/enum/index.ts +14 -14
  18. package/src/types/enum/reflex-error-code.enum.ts +19 -19
  19. package/src/types/enum/run-log-level.enum.ts +6 -6
  20. package/src/types/enum/run-status.enum.ts +11 -11
  21. package/src/types/enum/run-step-status.enum.ts +7 -7
  22. package/src/types/enum/trace-effect-type.enum.ts +12 -12
  23. package/src/types/interface/api/requests/function-promotion.request.ts +25 -25
  24. package/src/types/interface/api/requests/function-run.request.ts +26 -26
  25. package/src/types/interface/api/requests/function-settings.request.ts +1 -1
  26. package/src/types/interface/api/requests/function-test.request.ts +24 -19
  27. package/src/types/interface/api/requests/function-version.request.ts +1 -1
  28. package/src/types/interface/api/requests/index.ts +8 -8
  29. package/src/types/interface/api/responses/function-run.response.ts +18 -18
  30. package/src/types/interface/api/responses/function-settings.response.ts +1 -1
  31. package/src/types/interface/api/responses/function-version.response.ts +36 -36
  32. package/src/types/interface/api/responses/index.ts +8 -8
  33. package/src/types/interface/models/index.ts +10 -10
  34. package/src/types/interface/models/reflex-definition.model.ts +31 -31
  35. package/src/types/interface/models/reflex-environment-pointer.model.ts +18 -18
  36. package/src/types/interface/models/reflex-execution-settings.model.ts +3 -3
  37. package/src/types/interface/models/reflex-price-list.model.ts +20 -20
  38. package/src/types/interface/models/reflex-run.model.ts +6 -2
  39. package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
@@ -1,19 +1,24 @@
1
- export interface IFunctionTestParams {
2
- applicationId: string;
3
- functionId: string;
4
- }
5
-
6
- /** The answer an HTTP step gets in a test; nothing is sent. Defaults to `200` with no body. */
7
- export interface IReflexHttpStub {
8
- status: number;
9
- headers?: Record<string, string>;
10
- body?: unknown;
11
- }
12
-
13
- export interface ISimulateFunctionBody {
14
- /** The event the function receives, as the edge builds it: `{method, path, query, headers, body}`. */
15
- input?: unknown;
16
- /** Simulated responses of HTTP steps, by step id. */
17
- httpStubs?: Record<string, IReflexHttpStub>;
18
- }
19
- export type IDryRunFunctionBody = ISimulateFunctionBody;
1
+ export interface IFunctionTestParams {
2
+ applicationId: string;
3
+ functionId: string;
4
+ }
5
+
6
+ /** The answer an HTTP step gets in a test; nothing is sent. Defaults to `200` with no body. */
7
+ export interface IReflexHttpStub {
8
+ status: number;
9
+ headers?: Record<string, string>;
10
+ body?: unknown;
11
+ }
12
+
13
+ export interface ISimulateFunctionBody {
14
+ /**
15
+ * The environment of the application the run takes place in (abyss-main's id): a dry run reads its
16
+ * Store, the run is measured with its effective settings and recorded with it.
17
+ */
18
+ environmentId: string;
19
+ /** The event the function receives, as the edge builds it: `{method, path, query, headers, body}`. */
20
+ input?: unknown;
21
+ /** Simulated responses of HTTP steps, by step id. */
22
+ httpStubs?: Record<string, IReflexHttpStub>;
23
+ }
24
+ export type IDryRunFunctionBody = ISimulateFunctionBody;
@@ -20,6 +20,6 @@ export interface IGetFunctionVersionStepStatsParams {
20
20
  versionId: string;
21
21
  }
22
22
  export interface IGetFunctionVersionStepStatsQuery {
23
- /** Only the executions of this Monitor environment; every environment when absent. */
23
+ /** Only the executions of this environment; every environment when absent. */
24
24
  environmentId?: string;
25
25
  }
@@ -1,8 +1,8 @@
1
- export * from './function.request';
2
- export * from './function-access.request';
3
- export * from './function-test.request';
4
- export * from './function-version.request';
5
- export * from './function-promotion.request';
6
- export * from './function-trigger.request';
7
- export * from './function-run.request';
8
- export * from './function-settings.request';
1
+ export * from './function.request';
2
+ export * from './function-access.request';
3
+ export * from './function-test.request';
4
+ export * from './function-version.request';
5
+ export * from './function-promotion.request';
6
+ export * from './function-trigger.request';
7
+ export * from './function-run.request';
8
+ export * from './function-settings.request';
@@ -1,18 +1,18 @@
1
- import type { IReflexExecutionState, IReflexRun, IReflexRunDetail } from '../../models';
2
- import type { IResponse } from '../response';
3
-
4
- export interface IListFunctionRunData {
5
- /** Newest first. */
6
- runs: IReflexRun[];
7
- }
8
- export type IListFunctionRunResponse = IResponse<IListFunctionRunData>;
9
-
10
- export interface IGetFunctionRunData {
11
- run: IReflexRunDetail;
12
- }
13
- export type IGetFunctionRunResponse = IResponse<IGetFunctionRunData>;
14
-
15
- export interface IGetFunctionRunStateData {
16
- state: IReflexExecutionState;
17
- }
18
- export type IGetFunctionRunStateResponse = IResponse<IGetFunctionRunStateData>;
1
+ import type { IReflexExecutionState, IReflexRun, IReflexRunDetail } from '../../models';
2
+ import type { IResponse } from '../response';
3
+
4
+ export interface IListFunctionRunData {
5
+ /** Newest first. */
6
+ runs: IReflexRun[];
7
+ }
8
+ export type IListFunctionRunResponse = IResponse<IListFunctionRunData>;
9
+
10
+ export interface IGetFunctionRunData {
11
+ run: IReflexRunDetail;
12
+ }
13
+ export type IGetFunctionRunResponse = IResponse<IGetFunctionRunData>;
14
+
15
+ export interface IGetFunctionRunStateData {
16
+ state: IReflexExecutionState;
17
+ }
18
+ export type IGetFunctionRunStateResponse = IResponse<IGetFunctionRunStateData>;
@@ -11,7 +11,7 @@ export interface IGetFunctionSettingsData {
11
11
  default: IReflexExecutionSettings | null;
12
12
  /** The override of each environment that has one. */
13
13
  environments: IReflexExecutionSettings[];
14
- /** What each Monitor environment of the application runs with. */
14
+ /** What each environment of the application runs with. */
15
15
  effective: IReflexEffectiveExecutionSettings[];
16
16
  /** What applies when neither the environment nor the function sets anything. */
17
17
  builtIn: IReflexExecutionSettingsValues;
@@ -1,36 +1,36 @@
1
- import type {
2
- IReflexFunctionVersion,
3
- IReflexRunningVersionHeapPeaks,
4
- IReflexStepStats,
5
- } from '../../models';
6
- import type { IResponse } from '../response';
7
-
8
- export interface IListFunctionVersionData {
9
- versions: IReflexFunctionVersion[];
10
- }
11
- export type IListFunctionVersionResponse = IResponse<IListFunctionVersionData>;
12
-
13
- export interface IPublishFunctionVersionData {
14
- version: IReflexFunctionVersion;
15
- }
16
- export type IPublishFunctionVersionResponse = IResponse<IPublishFunctionVersionData>;
17
-
18
- export interface IGetFunctionVersionData {
19
- version: IReflexFunctionVersion;
20
- }
21
- export type IGetFunctionVersionResponse = IResponse<IGetFunctionVersionData>;
22
-
23
- export interface IGetFunctionVersionStepStatsData {
24
- versionId: string;
25
- /** The environment asked for; null for every environment. */
26
- environmentId: string | null;
27
- /** The window the statistics cover: the retention of the live runs. */
28
- windowDays: number;
29
- /** Executions of the version in the window, interrupted and running ones left out. */
30
- executions: number;
31
- /** One entry per step that ran, most costly first. */
32
- steps: IReflexStepStats[];
33
- /** The p99 heap peak per step of the version running in `environmentId`; null without an environment or when nothing runs there. */
34
- runningVersion: IReflexRunningVersionHeapPeaks | null;
35
- }
36
- export type IGetFunctionVersionStepStatsResponse = IResponse<IGetFunctionVersionStepStatsData>;
1
+ import type {
2
+ IReflexFunctionVersion,
3
+ IReflexRunningVersionHeapPeaks,
4
+ IReflexStepStats,
5
+ } from '../../models';
6
+ import type { IResponse } from '../response';
7
+
8
+ export interface IListFunctionVersionData {
9
+ versions: IReflexFunctionVersion[];
10
+ }
11
+ export type IListFunctionVersionResponse = IResponse<IListFunctionVersionData>;
12
+
13
+ export interface IPublishFunctionVersionData {
14
+ version: IReflexFunctionVersion;
15
+ }
16
+ export type IPublishFunctionVersionResponse = IResponse<IPublishFunctionVersionData>;
17
+
18
+ export interface IGetFunctionVersionData {
19
+ version: IReflexFunctionVersion;
20
+ }
21
+ export type IGetFunctionVersionResponse = IResponse<IGetFunctionVersionData>;
22
+
23
+ export interface IGetFunctionVersionStepStatsData {
24
+ versionId: string;
25
+ /** The environment asked for; null for every environment. */
26
+ environmentId: string | null;
27
+ /** The window the statistics cover: the retention of the live runs. */
28
+ windowDays: number;
29
+ /** Executions of the version in the window, interrupted and running ones left out. */
30
+ executions: number;
31
+ /** One entry per step that ran, most costly first. */
32
+ steps: IReflexStepStats[];
33
+ /** The p99 heap peak per step of the version running in `environmentId`; null without an environment or when nothing runs there. */
34
+ runningVersion: IReflexRunningVersionHeapPeaks | null;
35
+ }
36
+ export type IGetFunctionVersionStepStatsResponse = IResponse<IGetFunctionVersionStepStatsData>;
@@ -1,8 +1,8 @@
1
- export * from './function.response';
2
- export * from './function-access.response';
3
- export * from './function-test.response';
4
- export * from './function-version.response';
5
- export * from './function-promotion.response';
6
- export * from './function-trigger.response';
7
- export * from './function-run.response';
8
- export * from './function-settings.response';
1
+ export * from './function.response';
2
+ export * from './function-access.response';
3
+ export * from './function-test.response';
4
+ export * from './function-version.response';
5
+ export * from './function-promotion.response';
6
+ export * from './function-trigger.response';
7
+ export * from './function-run.response';
8
+ export * from './function-settings.response';
@@ -1,10 +1,10 @@
1
- export * from './reflex-definition.model';
2
- export * from './reflex-function.model';
3
- export * from './reflex-function-version.model';
4
- export * from './reflex-environment-pointer.model';
5
- export * from './reflex-trigger.model';
6
- export * from './reflex-access-grant.model';
7
- export * from './reflex-run.model';
8
- export * from './reflex-execution-settings.model';
9
- export * from './reflex-step-stats.model';
10
- export * from './reflex-price-list.model';
1
+ export * from './reflex-definition.model';
2
+ export * from './reflex-function.model';
3
+ export * from './reflex-function-version.model';
4
+ export * from './reflex-environment-pointer.model';
5
+ export * from './reflex-trigger.model';
6
+ export * from './reflex-access-grant.model';
7
+ export * from './reflex-run.model';
8
+ export * from './reflex-execution-settings.model';
9
+ export * from './reflex-step-stats.model';
10
+ export * from './reflex-price-list.model';
@@ -1,31 +1,31 @@
1
- import type { ReflexAccessKind } from '../../enum';
2
-
3
- export interface IReflexHttpAccess {
4
- kind: ReflexAccessKind.HTTP;
5
- hosts: string[];
6
- }
7
-
8
- export interface IReflexHostActionAccess {
9
- kind: ReflexAccessKind.HOST_ACTION;
10
- action: string;
11
- }
12
-
13
- export type IReflexAccessDeclaration = IReflexHttpAccess | IReflexHostActionAccess;
14
-
15
- /**
16
- * A function's definition, in the format of @abyss-project/runtime (`formatVersion` 1). The steps are
17
- * the core's own and validated by the API; the SDK only carries them.
18
- */
19
- export interface IReflexDefinition {
20
- formatVersion: number;
21
- accesses: IReflexAccessDeclaration[];
22
- steps: Array<Record<string, unknown>>;
23
- }
24
-
25
- /**
26
- * Bounds of the status a RESPOND step (or `abyss.respond`) may answer with, both included: the
27
- * runtime's `MIN_RESPONSE_STATUS` and `MAX_RESPONSE_STATUS`, which publication and the edge apply.
28
- * The API's tests check that they are equal.
29
- */
30
- export const RESPOND_STATUS_MIN = 200;
31
- export const RESPOND_STATUS_MAX = 599;
1
+ import type { ReflexAccessKind } from '../../enum';
2
+
3
+ export interface IReflexHttpAccess {
4
+ kind: ReflexAccessKind.HTTP;
5
+ hosts: string[];
6
+ }
7
+
8
+ export interface IReflexHostActionAccess {
9
+ kind: ReflexAccessKind.HOST_ACTION;
10
+ action: string;
11
+ }
12
+
13
+ export type IReflexAccessDeclaration = IReflexHttpAccess | IReflexHostActionAccess;
14
+
15
+ /**
16
+ * A function's definition, in the format of @abyss-project/runtime (`formatVersion` 1). The steps are
17
+ * the core's own and validated by the API; the SDK only carries them.
18
+ */
19
+ export interface IReflexDefinition {
20
+ formatVersion: number;
21
+ accesses: IReflexAccessDeclaration[];
22
+ steps: Array<Record<string, unknown>>;
23
+ }
24
+
25
+ /**
26
+ * Bounds of the status a RESPOND step (or `abyss.respond`) may answer with, both included: the
27
+ * runtime's `MIN_RESPONSE_STATUS` and `MAX_RESPONSE_STATUS`, which publication and the edge apply.
28
+ * The API's tests check that they are equal.
29
+ */
30
+ export const RESPOND_STATUS_MIN = 200;
31
+ export const RESPOND_STATUS_MAX = 599;
@@ -1,18 +1,18 @@
1
- import type { IReflexAccessDeclaration } from './reflex-definition.model';
2
-
3
- /** One promotion of a version into a Monitor environment. The `isCurrent` one is what runs. */
4
- export interface IReflexEnvironmentPointer {
5
- id: string;
6
- functionId: string;
7
- /** The Monitor environment of the application. */
8
- environmentId: string;
9
- /** The name of that environment, which the trigger's address carries. */
10
- environmentSlug: string;
11
- versionId: string;
12
- versionNumber: number;
13
- /** The accesses that were granted when the version was promoted. */
14
- grants: IReflexAccessDeclaration[];
15
- isCurrent: boolean;
16
- promotedByUserId: string;
17
- promotedAt: Date;
18
- }
1
+ import type { IReflexAccessDeclaration } from './reflex-definition.model';
2
+
3
+ /** One promotion of a version into an environment of the application. The `isCurrent` one is what runs. */
4
+ export interface IReflexEnvironmentPointer {
5
+ id: string;
6
+ functionId: string;
7
+ /** The environment of the application (abyss-main's id). */
8
+ environmentId: string;
9
+ /** The name of that environment, which the trigger's address carries. */
10
+ environmentSlug: string;
11
+ versionId: string;
12
+ versionNumber: number;
13
+ /** The accesses that were granted when the version was promoted. */
14
+ grants: IReflexAccessDeclaration[];
15
+ isCurrent: boolean;
16
+ promotedByUserId: string;
17
+ promotedAt: Date;
18
+ }
@@ -29,17 +29,17 @@ export const DEFAULT_REFLEX_EXECUTION_SETTINGS: Readonly<IReflexExecutionSetting
29
29
  export interface IReflexExecutionSettings extends IReflexExecutionSettingsValues {
30
30
  id: string;
31
31
  functionId: string;
32
- /** A Monitor environment of the application; null for the default of every environment. */
32
+ /** An environment of the application (abyss-main's id); null for the default of every environment. */
33
33
  environmentId: string | null;
34
34
  updatedByUserId: string;
35
35
  createdAt: Date;
36
36
  updatedAt: Date;
37
37
  }
38
38
 
39
- /** What one Monitor environment of the application runs with. */
39
+ /** What one environment of the application runs with. */
40
40
  export interface IReflexEffectiveExecutionSettings {
41
41
  environmentId: string;
42
- /** The name of the environment in Monitor. */
42
+ /** The name of the environment (abyss-main), immutable. */
43
43
  environmentSlug: string;
44
44
  /** Changing what a production environment runs with needs REFLEX_PUBLISH_PRODUCTION. */
45
45
  isProduction: boolean;
@@ -1,20 +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
+ 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
+ }
@@ -54,6 +54,10 @@ export interface IReflexRun {
54
54
  id: string;
55
55
  functionId: string;
56
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
+ */
57
61
  environmentId: string | null;
58
62
  mode: RunMode;
59
63
  status: RunStatus;
@@ -72,7 +76,7 @@ export interface IReflexRun {
72
76
  responseSentAt: Date | null;
73
77
  /**
74
78
  * 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
79
+ * function's effective settings in the run's environment, and the network of its stubs); null for a running execution, or a run
76
80
  * recorded before the measures.
77
81
  */
78
82
  metrics: IReflexRunMetrics | null;
@@ -80,7 +84,7 @@ export interface IReflexRun {
80
84
  createdAt: Date;
81
85
  }
82
86
 
83
- /** What a live execution consumed, and what it costs (ADR-0240). */
87
+ /** What a live execution consumed, and what it costs (ADR-0244). */
84
88
  export interface IReflexRunMetrics {
85
89
  /** The profile it ran with, and the memory that profile allocates. */
86
90
  profile: ExecutionProfile;
@@ -1,35 +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
+ /** 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
+ }