@abyss-project/reflex 1.1.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 (23) hide show
  1. package/dist/types/interface/api/responses/function-settings.response.d.ts +2 -1
  2. package/dist/types/interface/models/index.d.ts +1 -0
  3. package/dist/types/interface/models/index.js +1 -0
  4. package/dist/types/interface/models/index.js.map +1 -1
  5. package/dist/types/interface/models/reflex-definition.model.d.ts +2 -0
  6. package/dist/types/interface/models/reflex-definition.model.js +3 -0
  7. package/dist/types/interface/models/reflex-definition.model.js.map +1 -1
  8. package/dist/types/interface/models/reflex-execution-settings.model.d.ts +0 -1
  9. package/dist/types/interface/models/reflex-execution-settings.model.js +0 -1
  10. package/dist/types/interface/models/reflex-execution-settings.model.js.map +1 -1
  11. package/dist/types/interface/models/reflex-price-list.model.d.ts +13 -0
  12. package/dist/types/interface/models/reflex-price-list.model.js +3 -0
  13. package/dist/types/interface/models/reflex-price-list.model.js.map +1 -0
  14. package/dist/types/interface/models/reflex-run.model.d.ts +1 -1
  15. package/package.json +1 -1
  16. package/src/api/function.api.test.ts +9 -3
  17. package/src/types/enum/execution-profile.enum.ts +1 -1
  18. package/src/types/interface/api/responses/function-settings.response.ts +3 -0
  19. package/src/types/interface/models/index.ts +1 -0
  20. package/src/types/interface/models/reflex-definition.model.ts +31 -23
  21. package/src/types/interface/models/reflex-execution-settings.model.ts +0 -3
  22. package/src/types/interface/models/reflex-price-list.model.ts +20 -0
  23. package/src/types/interface/models/reflex-run.model.ts +5 -4
@@ -1,10 +1,11 @@
1
- import type { IReflexEffectiveExecutionSettings, IReflexExecutionSettings, IReflexExecutionSettingsValues } from '../../models';
1
+ import type { IReflexEffectiveExecutionSettings, IReflexExecutionSettings, IReflexExecutionSettingsValues, IReflexPriceList } from '../../models';
2
2
  import type { IResponse } from '../response';
3
3
  export interface IGetFunctionSettingsData {
4
4
  default: IReflexExecutionSettings | null;
5
5
  environments: IReflexExecutionSettings[];
6
6
  effective: IReflexEffectiveExecutionSettings[];
7
7
  builtIn: IReflexExecutionSettingsValues;
8
+ priceList: IReflexPriceList;
8
9
  }
9
10
  export type IGetFunctionSettingsResponse = IResponse<IGetFunctionSettingsData>;
10
11
  export interface ISetFunctionDefaultSettingsData {
@@ -7,3 +7,4 @@ export * from './reflex-access-grant.model';
7
7
  export * from './reflex-run.model';
8
8
  export * from './reflex-execution-settings.model';
9
9
  export * from './reflex-step-stats.model';
10
+ export * from './reflex-price-list.model';
@@ -23,4 +23,5 @@ __exportStar(require("./reflex-access-grant.model"), exports);
23
23
  __exportStar(require("./reflex-run.model"), exports);
24
24
  __exportStar(require("./reflex-execution-settings.model"), exports);
25
25
  __exportStar(require("./reflex-step-stats.model"), exports);
26
+ __exportStar(require("./reflex-price-list.model"), exports);
26
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/interface/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,0DAAwC;AACxC,kEAAgD;AAChD,qEAAmD;AACnD,yDAAuC;AACvC,8DAA4C;AAC5C,qDAAmC;AACnC,oEAAkD;AAClD,4DAA0C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/interface/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,0DAAwC;AACxC,kEAAgD;AAChD,qEAAmD;AACnD,yDAAuC;AACvC,8DAA4C;AAC5C,qDAAmC;AACnC,oEAAkD;AAClD,4DAA0C;AAC1C,4DAA0C"}
@@ -13,3 +13,5 @@ export interface IReflexDefinition {
13
13
  accesses: IReflexAccessDeclaration[];
14
14
  steps: Array<Record<string, unknown>>;
15
15
  }
16
+ export declare const RESPOND_STATUS_MIN = 200;
17
+ export declare const RESPOND_STATUS_MAX = 599;
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RESPOND_STATUS_MAX = exports.RESPOND_STATUS_MIN = void 0;
4
+ exports.RESPOND_STATUS_MIN = 200;
5
+ exports.RESPOND_STATUS_MAX = 599;
3
6
  //# sourceMappingURL=reflex-definition.model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reflex-definition.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/reflex-definition.model.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"reflex-definition.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/reflex-definition.model.ts"],"names":[],"mappings":";;;AA6Ba,QAAA,kBAAkB,GAAG,GAAG,CAAC;AACzB,QAAA,kBAAkB,GAAG,GAAG,CAAC"}
@@ -2,7 +2,6 @@ import { ExecutionMode, ExecutionProfile } from '../../enum';
2
2
  import type { ExecutionSettingsSource } from '../../enum';
3
3
  export interface IReflexExecutionSettingsValues {
4
4
  profile: ExecutionProfile;
5
- guaranteedCpu: boolean;
6
5
  responseTimeoutMs: number;
7
6
  maxDurationMs: number;
8
7
  mode: ExecutionMode;
@@ -8,7 +8,6 @@ exports.REFLEX_EXECUTION_SETTINGS_LIMITS = {
8
8
  };
9
9
  exports.DEFAULT_REFLEX_EXECUTION_SETTINGS = {
10
10
  profile: enum_1.ExecutionProfile.S,
11
- guaranteedCpu: false,
12
11
  responseTimeoutMs: 30_000,
13
12
  maxDurationMs: 30_000,
14
13
  mode: enum_1.ExecutionMode.SYNC,
@@ -1 +1 @@
1
- {"version":3,"file":"reflex-execution-settings.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/reflex-execution-settings.model.ts"],"names":[],"mappings":";;;AAAA,qCAA6D;AAgBhD,QAAA,gCAAgC,GAAG;IAC9C,iBAAiB,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE;IAC/C,aAAa,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE;CACrC,CAAC;AAGE,QAAA,iCAAiC,GAA6C;IACzF,OAAO,EAAE,uBAAgB,CAAC,CAAC;IAC3B,aAAa,EAAE,KAAK;IACpB,iBAAiB,EAAE,MAAM;IACzB,aAAa,EAAE,MAAM;IACrB,IAAI,EAAE,oBAAa,CAAC,IAAI;CACzB,CAAC"}
1
+ {"version":3,"file":"reflex-execution-settings.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/reflex-execution-settings.model.ts"],"names":[],"mappings":";;;AAAA,qCAA6D;AAchD,QAAA,gCAAgC,GAAG;IAC9C,iBAAiB,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE;IAC/C,aAAa,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE;CACrC,CAAC;AAGE,QAAA,iCAAiC,GAA6C;IACzF,OAAO,EAAE,uBAAgB,CAAC,CAAC;IAC3B,iBAAiB,EAAE,MAAM;IACzB,aAAa,EAAE,MAAM;IACrB,IAAI,EAAE,oBAAa,CAAC,IAAI;CACzB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { ExecutionProfile } from '../../enum';
2
+ export interface IReflexPriceList {
3
+ executionMillicredits: number;
4
+ cpuMillicreditsPerSecond: number;
5
+ memoryMillicreditsPerGbSecond: number;
6
+ networkOutMillicreditsPerMb: number;
7
+ httpCallMillicredits: number;
8
+ storeWriteMillicredits: number;
9
+ profiles: Record<ExecutionProfile, {
10
+ memoryMb: number;
11
+ cpuCoefficient: number;
12
+ }>;
13
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=reflex-price-list.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reflex-price-list.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/reflex-price-list.model.ts"],"names":[],"mappings":""}
@@ -50,7 +50,6 @@ export interface IReflexRun {
50
50
  export interface IReflexRunMetrics {
51
51
  profile: ExecutionProfile;
52
52
  memoryLimitMb: number;
53
- guaranteedCpu: boolean;
54
53
  cpuMs: number;
55
54
  heapPeakBytes: number;
56
55
  netOutBytes: number;
@@ -83,6 +82,7 @@ export interface IReflexRunLog {
83
82
  export interface IReflexRunDetail extends IReflexRun {
84
83
  steps: IReflexRunStep[];
85
84
  logs: IReflexRunLog[];
85
+ droppedLogLines: number;
86
86
  }
87
87
  export interface IReflexExecutionState {
88
88
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyss-project/reflex",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Core package to interact with AbyssReflex",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -6,6 +6,8 @@ import {
6
6
  ExecutionMode,
7
7
  ExecutionProfile,
8
8
  REFLEX_EXECUTION_SETTINGS_LIMITS,
9
+ RESPOND_STATUS_MAX,
10
+ RESPOND_STATUS_MIN,
9
11
  } from '..';
10
12
 
11
13
  const APP = 'app-1';
@@ -13,7 +15,6 @@ const FN = 'fn-1';
13
15
  const BASE = `api/function/${APP}/${FN}`;
14
16
  const SETTINGS = {
15
17
  profile: ExecutionProfile.L,
16
- guaranteedCpu: true,
17
18
  responseTimeoutMs: 10_000,
18
19
  maxDurationMs: 600_000,
19
20
  mode: ExecutionMode.ASYNC,
@@ -285,10 +286,9 @@ describe('execution settings constants', () => {
285
286
  ]);
286
287
  });
287
288
 
288
- it('default to S, shared CPU, 30 s, 30 s and SYNC, within the bounds', () => {
289
+ it('default to S, 30 s, 30 s and SYNC, within the bounds', () => {
289
290
  expect(DEFAULT_REFLEX_EXECUTION_SETTINGS).toEqual({
290
291
  profile: ExecutionProfile.S,
291
- guaranteedCpu: false,
292
292
  responseTimeoutMs: 30_000,
293
293
  maxDurationMs: 30_000,
294
294
  mode: ExecutionMode.SYNC,
@@ -299,3 +299,9 @@ describe('execution settings constants', () => {
299
299
  });
300
300
  });
301
301
  });
302
+
303
+ describe('respond status bounds', () => {
304
+ it('are 200 to 599, the bounds of the runtime', () => {
305
+ expect([RESPOND_STATUS_MIN, RESPOND_STATUS_MAX]).toEqual([200, 599]);
306
+ });
307
+ });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Memory of the isolate an execution runs in (ADR-0239). The CPU part of the cost grows with the
2
+ * Memory of the isolate an execution runs in (ADR-0240). The CPU part of the cost grows with the
3
3
  * profile: S x1, M x1.05, L x1.10, XL x1.20, XXL x1.35.
4
4
  */
5
5
  export enum ExecutionProfile {
@@ -2,6 +2,7 @@ import type {
2
2
  IReflexEffectiveExecutionSettings,
3
3
  IReflexExecutionSettings,
4
4
  IReflexExecutionSettingsValues,
5
+ IReflexPriceList,
5
6
  } from '../../models';
6
7
  import type { IResponse } from '../response';
7
8
 
@@ -14,6 +15,8 @@ export interface IGetFunctionSettingsData {
14
15
  effective: IReflexEffectiveExecutionSettings[];
15
16
  /** What applies when neither the environment nor the function sets anything. */
16
17
  builtIn: IReflexExecutionSettingsValues;
18
+ /** The price list an execution is billed with, to estimate the cost of a setting. */
19
+ priceList: IReflexPriceList;
17
20
  }
18
21
  export type IGetFunctionSettingsResponse = IResponse<IGetFunctionSettingsData>;
19
22
 
@@ -7,3 +7,4 @@ export * from './reflex-access-grant.model';
7
7
  export * from './reflex-run.model';
8
8
  export * from './reflex-execution-settings.model';
9
9
  export * from './reflex-step-stats.model';
10
+ export * from './reflex-price-list.model';
@@ -1,23 +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
- }
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;
@@ -4,8 +4,6 @@ import type { ExecutionSettingsSource } from '../../enum';
4
4
  /** The execution settings of a function in an environment. */
5
5
  export interface IReflexExecutionSettingsValues {
6
6
  profile: ExecutionProfile;
7
- /** One core reserved for the execution; the CPU part of the cost is multiplied by 1.5. */
8
- guaranteedCpu: boolean;
9
7
  /** Past this, a synchronous caller that got no answer receives 504 and the execution goes on. */
10
8
  responseTimeoutMs: number;
11
9
  /** Past this, the execution is stopped with TIMEOUT. */
@@ -22,7 +20,6 @@ export const REFLEX_EXECUTION_SETTINGS_LIMITS = {
22
20
  /** What a function runs with when nothing is set. */
23
21
  export const DEFAULT_REFLEX_EXECUTION_SETTINGS: Readonly<IReflexExecutionSettingsValues> = {
24
22
  profile: ExecutionProfile.S,
25
- guaranteedCpu: false,
26
23
  responseTimeoutMs: 30_000,
27
24
  maxDurationMs: 30_000,
28
25
  mode: ExecutionMode.SYNC,
@@ -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
+ }
@@ -80,12 +80,11 @@ export interface IReflexRun {
80
80
  createdAt: Date;
81
81
  }
82
82
 
83
- /** What a live execution consumed, and what it costs (ADR-0239). */
83
+ /** What a live execution consumed, and what it costs (ADR-0240). */
84
84
  export interface IReflexRunMetrics {
85
- /** The settings it ran with. */
85
+ /** The profile it ran with, and the memory that profile allocates. */
86
86
  profile: ExecutionProfile;
87
87
  memoryLimitMb: number;
88
- guaranteedCpu: boolean;
89
88
  /** Measured by the runner in the isolate. */
90
89
  cpuMs: number;
91
90
  heapPeakBytes: number;
@@ -117,7 +116,7 @@ export interface IReflexRunStep {
117
116
  /**
118
117
  * One log line a run wrote: a LOG step, `abyss.log.*` or `console.*`. Secrets masked (`***`); a message
119
118
  * 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.
119
+ * 100 lines per run are kept; `IReflexRunDetail.droppedLogLines` counts the others.
121
120
  */
122
121
  export interface IReflexRunLog {
123
122
  /** 0 for the first line. */
@@ -138,6 +137,8 @@ export interface IReflexRunLog {
138
137
  export interface IReflexRunDetail extends IReflexRun {
139
138
  steps: IReflexRunStep[];
140
139
  logs: IReflexRunLog[];
140
+ /** The log lines written past the 100 kept in `logs`; 0 when none was dropped. */
141
+ droppedLogLines: number;
141
142
  }
142
143
 
143
144
  /** The state of a live execution, read by its id (the `executionId` an async trigger answers with). */