@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,3 +1,3 @@
1
1
  import type { IDryRunFunctionBody, IDryRunFunctionResponse, IFunctionTestParams, ISimulateFunctionBody, ISimulateFunctionResponse } from '../types';
2
- export declare const simulateFunction: (params: IFunctionTestParams, body?: ISimulateFunctionBody) => Promise<ISimulateFunctionResponse>;
3
- export declare const dryRunFunction: (params: IFunctionTestParams, body?: IDryRunFunctionBody) => Promise<IDryRunFunctionResponse>;
2
+ export declare const simulateFunction: (params: IFunctionTestParams, body: ISimulateFunctionBody) => Promise<ISimulateFunctionResponse>;
3
+ export declare const dryRunFunction: (params: IFunctionTestParams, body: IDryRunFunctionBody) => Promise<IDryRunFunctionResponse>;
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dryRunFunction = exports.simulateFunction = void 0;
4
4
  const __1 = require("..");
5
5
  const testUrl = (params) => `api/function/${params.applicationId}/${params.functionId}/test`;
6
- const simulateFunction = async (params, body = {}) => (await __1.AbyssReflexCore.axios.post(`${testUrl(params)}/simulate`, body))
6
+ const simulateFunction = async (params, body) => (await __1.AbyssReflexCore.axios.post(`${testUrl(params)}/simulate`, body))
7
7
  .data;
8
8
  exports.simulateFunction = simulateFunction;
9
- const dryRunFunction = async (params, body = {}) => (await __1.AbyssReflexCore.axios.post(`${testUrl(params)}/dry-run`, body))
9
+ const dryRunFunction = async (params, body) => (await __1.AbyssReflexCore.axios.post(`${testUrl(params)}/dry-run`, body))
10
10
  .data;
11
11
  exports.dryRunFunction = dryRunFunction;
12
12
  //# sourceMappingURL=function-test.api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"function-test.api.js","sourceRoot":"","sources":["../../src/api/function-test.api.ts"],"names":[],"mappings":";;;AAAA,0BAAqC;AASrC,MAAM,OAAO,GAAG,CAAC,MAA2B,EAAU,EAAE,CACtD,gBAAgB,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,UAAU,OAAO,CAAC;AAM5D,MAAM,gBAAgB,GAAG,KAAK,EACnC,MAA2B,EAC3B,OAA8B,EAAE,EACI,EAAE,CACtC,CAAC,MAAM,mBAAe,CAAC,KAAK,CAAC,IAAI,CAA4B,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;KAC/F,IAAI,CAAC;AALG,QAAA,gBAAgB,oBAKnB;AAMH,MAAM,cAAc,GAAG,KAAK,EACjC,MAA2B,EAC3B,OAA4B,EAAE,EACI,EAAE,CACpC,CAAC,MAAM,mBAAe,CAAC,KAAK,CAAC,IAAI,CAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;KAC5F,IAAI,CAAC;AALG,QAAA,cAAc,kBAKjB"}
1
+ {"version":3,"file":"function-test.api.js","sourceRoot":"","sources":["../../src/api/function-test.api.ts"],"names":[],"mappings":";;;AAAA,0BAAqC;AASrC,MAAM,OAAO,GAAG,CAAC,MAA2B,EAAU,EAAE,CACtD,gBAAgB,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,UAAU,OAAO,CAAC;AAO5D,MAAM,gBAAgB,GAAG,KAAK,EACnC,MAA2B,EAC3B,IAA2B,EACS,EAAE,CACtC,CAAC,MAAM,mBAAe,CAAC,KAAK,CAAC,IAAI,CAA4B,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;KAC/F,IAAI,CAAC;AALG,QAAA,gBAAgB,oBAKnB;AAMH,MAAM,cAAc,GAAG,KAAK,EACjC,MAA2B,EAC3B,IAAyB,EACS,EAAE,CACpC,CAAC,MAAM,mBAAe,CAAC,KAAK,CAAC,IAAI,CAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;KAC5F,IAAI,CAAC;AALG,QAAA,cAAc,kBAKjB"}
@@ -8,6 +8,7 @@ export interface IReflexHttpStub {
8
8
  body?: unknown;
9
9
  }
10
10
  export interface ISimulateFunctionBody {
11
+ environmentId: string;
11
12
  input?: unknown;
12
13
  httpStubs?: Record<string, IReflexHttpStub>;
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyss-project/reflex",
3
- "version": "1.2.0",
3
+ "version": "2.0.0",
4
4
  "description": "Core package to interact with AbyssReflex",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,42 +1,42 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IListFunctionPromotionParams,
4
- IListFunctionPromotionResponse,
5
- IPromoteFunctionBody,
6
- IPromoteFunctionParams,
7
- IPromoteFunctionResponse,
8
- IRollbackFunctionBody,
9
- IRollbackFunctionParams,
10
- IRollbackFunctionResponse,
11
- } from '../types';
12
-
13
- const promotionUrl = (params: { applicationId: string; functionId: string }): string =>
14
- `api/function/${params.applicationId}/${params.functionId}/promotion`;
15
-
16
- /** `GET .../promotion`: where each version runs, and the history a rollback reads. Needs REFLEX_READ. */
17
- export const listFunctionPromotion = async (
18
- params: IListFunctionPromotionParams,
19
- ): Promise<IListFunctionPromotionResponse> =>
20
- (await AbyssReflexCore.axios.get<IListFunctionPromotionResponse>(promotionUrl(params))).data;
21
-
22
- /**
23
- * `POST .../promotion`: runs a version in a Monitor environment (copies it, its accesses and its secrets to
24
- * the execution plane). Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION for a PRODUCTION environment.
25
- */
26
- export const promoteFunction = async (
27
- params: IPromoteFunctionParams,
28
- body: IPromoteFunctionBody,
29
- ): Promise<IPromoteFunctionResponse> =>
30
- (await AbyssReflexCore.axios.post<IPromoteFunctionResponse>(promotionUrl(params), body)).data;
31
-
32
- /** `POST .../promotion/rollback`: moves the environment back to a version it ran before. Same rights as a promotion. */
33
- export const rollbackFunction = async (
34
- params: IRollbackFunctionParams,
35
- body: IRollbackFunctionBody,
36
- ): Promise<IRollbackFunctionResponse> =>
37
- (
38
- await AbyssReflexCore.axios.post<IRollbackFunctionResponse>(
39
- `${promotionUrl(params)}/rollback`,
40
- body,
41
- )
42
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IListFunctionPromotionParams,
4
+ IListFunctionPromotionResponse,
5
+ IPromoteFunctionBody,
6
+ IPromoteFunctionParams,
7
+ IPromoteFunctionResponse,
8
+ IRollbackFunctionBody,
9
+ IRollbackFunctionParams,
10
+ IRollbackFunctionResponse,
11
+ } from '../types';
12
+
13
+ const promotionUrl = (params: { applicationId: string; functionId: string }): string =>
14
+ `api/function/${params.applicationId}/${params.functionId}/promotion`;
15
+
16
+ /** `GET .../promotion`: where each version runs, and the history a rollback reads. Needs REFLEX_READ. */
17
+ export const listFunctionPromotion = async (
18
+ params: IListFunctionPromotionParams,
19
+ ): Promise<IListFunctionPromotionResponse> =>
20
+ (await AbyssReflexCore.axios.get<IListFunctionPromotionResponse>(promotionUrl(params))).data;
21
+
22
+ /**
23
+ * `POST .../promotion`: runs a version in an environment of the application (copies it, its accesses and its secrets to
24
+ * the execution plane). Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION for a PRODUCTION environment.
25
+ */
26
+ export const promoteFunction = async (
27
+ params: IPromoteFunctionParams,
28
+ body: IPromoteFunctionBody,
29
+ ): Promise<IPromoteFunctionResponse> =>
30
+ (await AbyssReflexCore.axios.post<IPromoteFunctionResponse>(promotionUrl(params), body)).data;
31
+
32
+ /** `POST .../promotion/rollback`: moves the environment back to a version it ran before. Same rights as a promotion. */
33
+ export const rollbackFunction = async (
34
+ params: IRollbackFunctionParams,
35
+ body: IRollbackFunctionBody,
36
+ ): Promise<IRollbackFunctionResponse> =>
37
+ (
38
+ await AbyssReflexCore.axios.post<IRollbackFunctionResponse>(
39
+ `${promotionUrl(params)}/rollback`,
40
+ body,
41
+ )
42
+ ).data;
@@ -1,38 +1,38 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IGetFunctionRunParams,
4
- IGetFunctionRunResponse,
5
- IGetFunctionRunStateParams,
6
- IGetFunctionRunStateResponse,
7
- IListFunctionRunParams,
8
- IListFunctionRunQuery,
9
- IListFunctionRunResponse,
10
- } from '../types';
11
-
12
- const runUrl = (params: { applicationId: string; functionId: string }): string =>
13
- `api/function/${params.applicationId}/${params.functionId}/run`;
14
-
15
- /** `GET .../run`: the test runs (kept: the last 10, then 7 days) and the live executions of the edge (7 days), merged, newest first, paged by `limit`/`offset`. Needs REFLEX_LOG_READ. */
16
- export const listFunctionRun = async (
17
- params: IListFunctionRunParams,
18
- query: IListFunctionRunQuery = {},
19
- ): Promise<IListFunctionRunResponse> =>
20
- (await AbyssReflexCore.axios.get<IListFunctionRunResponse>(runUrl(params), { params: query }))
21
- .data;
22
-
23
- /** `GET .../run/:runId`: one run; a live one with its measures and its steps. Needs REFLEX_LOG_READ. */
24
- export const getFunctionRun = async (
25
- params: IGetFunctionRunParams,
26
- ): Promise<IGetFunctionRunResponse> =>
27
- (await AbyssReflexCore.axios.get<IGetFunctionRunResponse>(`${runUrl(params)}/${params.runId}`))
28
- .data;
29
-
30
- /** `GET .../run/:runId/state`: the state of a live execution, the one an async trigger answered with. Needs REFLEX_LOG_READ. */
31
- export const getFunctionRunState = async (
32
- params: IGetFunctionRunStateParams,
33
- ): Promise<IGetFunctionRunStateResponse> =>
34
- (
35
- await AbyssReflexCore.axios.get<IGetFunctionRunStateResponse>(
36
- `${runUrl(params)}/${params.runId}/state`,
37
- )
38
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IGetFunctionRunParams,
4
+ IGetFunctionRunResponse,
5
+ IGetFunctionRunStateParams,
6
+ IGetFunctionRunStateResponse,
7
+ IListFunctionRunParams,
8
+ IListFunctionRunQuery,
9
+ IListFunctionRunResponse,
10
+ } from '../types';
11
+
12
+ const runUrl = (params: { applicationId: string; functionId: string }): string =>
13
+ `api/function/${params.applicationId}/${params.functionId}/run`;
14
+
15
+ /** `GET .../run`: the test runs (kept: the last 10, then 7 days) and the live executions of the edge (7 days), merged, newest first, paged by `limit`/`offset`. Needs REFLEX_LOG_READ. */
16
+ export const listFunctionRun = async (
17
+ params: IListFunctionRunParams,
18
+ query: IListFunctionRunQuery = {},
19
+ ): Promise<IListFunctionRunResponse> =>
20
+ (await AbyssReflexCore.axios.get<IListFunctionRunResponse>(runUrl(params), { params: query }))
21
+ .data;
22
+
23
+ /** `GET .../run/:runId`: one run; a live one with its measures and its steps. Needs REFLEX_LOG_READ. */
24
+ export const getFunctionRun = async (
25
+ params: IGetFunctionRunParams,
26
+ ): Promise<IGetFunctionRunResponse> =>
27
+ (await AbyssReflexCore.axios.get<IGetFunctionRunResponse>(`${runUrl(params)}/${params.runId}`))
28
+ .data;
29
+
30
+ /** `GET .../run/:runId/state`: the state of a live execution, the one an async trigger answered with. Needs REFLEX_LOG_READ. */
31
+ export const getFunctionRunState = async (
32
+ params: IGetFunctionRunStateParams,
33
+ ): Promise<IGetFunctionRunStateResponse> =>
34
+ (
35
+ await AbyssReflexCore.axios.get<IGetFunctionRunStateResponse>(
36
+ `${runUrl(params)}/${params.runId}/state`,
37
+ )
38
+ ).data;
@@ -1,59 +1,59 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IGetFunctionSettingsParams,
4
- IGetFunctionSettingsResponse,
5
- IRemoveFunctionEnvironmentSettingsParams,
6
- IRemoveFunctionEnvironmentSettingsResponse,
7
- ISetFunctionDefaultSettingsBody,
8
- ISetFunctionDefaultSettingsParams,
9
- ISetFunctionDefaultSettingsResponse,
10
- ISetFunctionEnvironmentSettingsBody,
11
- ISetFunctionEnvironmentSettingsParams,
12
- ISetFunctionEnvironmentSettingsResponse,
13
- } from '../types';
14
-
15
- const settingsUrl = (params: { applicationId: string; functionId: string }): string =>
16
- `api/function/${params.applicationId}/${params.functionId}/settings`;
17
-
18
- /** `GET .../settings`: the default, the overrides, and what each environment runs with. Needs REFLEX_READ. */
19
- export const getFunctionSettings = async (
20
- params: IGetFunctionSettingsParams,
21
- ): Promise<IGetFunctionSettingsResponse> =>
22
- (await AbyssReflexCore.axios.get<IGetFunctionSettingsResponse>(settingsUrl(params))).data;
23
-
24
- /**
25
- * `PUT .../settings`: sets the default of every environment without an override, applied at once where the
26
- * function runs. Needs REFLEX_FUNCTION_UPDATE, and REFLEX_PUBLISH_PRODUCTION when the default applies to a
27
- * production environment where the function runs.
28
- */
29
- export const setFunctionDefaultSettings = async (
30
- params: ISetFunctionDefaultSettingsParams,
31
- body: ISetFunctionDefaultSettingsBody,
32
- ): Promise<ISetFunctionDefaultSettingsResponse> =>
33
- (await AbyssReflexCore.axios.put<ISetFunctionDefaultSettingsResponse>(settingsUrl(params), body))
34
- .data;
35
-
36
- /**
37
- * `PUT .../settings/:environmentId`: sets the override of one environment. Needs REFLEX_FUNCTION_UPDATE, and
38
- * REFLEX_PUBLISH_PRODUCTION for a production environment.
39
- */
40
- export const setFunctionEnvironmentSettings = async (
41
- params: ISetFunctionEnvironmentSettingsParams,
42
- body: ISetFunctionEnvironmentSettingsBody,
43
- ): Promise<ISetFunctionEnvironmentSettingsResponse> =>
44
- (
45
- await AbyssReflexCore.axios.put<ISetFunctionEnvironmentSettingsResponse>(
46
- `${settingsUrl(params)}/${params.environmentId}`,
47
- body,
48
- )
49
- ).data;
50
-
51
- /** `DELETE .../settings/:environmentId`: the environment falls back on the default. Same rights as setting it. */
52
- export const removeFunctionEnvironmentSettings = async (
53
- params: IRemoveFunctionEnvironmentSettingsParams,
54
- ): Promise<IRemoveFunctionEnvironmentSettingsResponse> =>
55
- (
56
- await AbyssReflexCore.axios.delete<IRemoveFunctionEnvironmentSettingsResponse>(
57
- `${settingsUrl(params)}/${params.environmentId}`,
58
- )
59
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IGetFunctionSettingsParams,
4
+ IGetFunctionSettingsResponse,
5
+ IRemoveFunctionEnvironmentSettingsParams,
6
+ IRemoveFunctionEnvironmentSettingsResponse,
7
+ ISetFunctionDefaultSettingsBody,
8
+ ISetFunctionDefaultSettingsParams,
9
+ ISetFunctionDefaultSettingsResponse,
10
+ ISetFunctionEnvironmentSettingsBody,
11
+ ISetFunctionEnvironmentSettingsParams,
12
+ ISetFunctionEnvironmentSettingsResponse,
13
+ } from '../types';
14
+
15
+ const settingsUrl = (params: { applicationId: string; functionId: string }): string =>
16
+ `api/function/${params.applicationId}/${params.functionId}/settings`;
17
+
18
+ /** `GET .../settings`: the default, the overrides, and what each environment runs with. Needs REFLEX_READ. */
19
+ export const getFunctionSettings = async (
20
+ params: IGetFunctionSettingsParams,
21
+ ): Promise<IGetFunctionSettingsResponse> =>
22
+ (await AbyssReflexCore.axios.get<IGetFunctionSettingsResponse>(settingsUrl(params))).data;
23
+
24
+ /**
25
+ * `PUT .../settings`: sets the default of every environment without an override, applied at once where the
26
+ * function runs. Needs REFLEX_FUNCTION_UPDATE, and REFLEX_PUBLISH_PRODUCTION when the default applies to a
27
+ * production environment where the function runs.
28
+ */
29
+ export const setFunctionDefaultSettings = async (
30
+ params: ISetFunctionDefaultSettingsParams,
31
+ body: ISetFunctionDefaultSettingsBody,
32
+ ): Promise<ISetFunctionDefaultSettingsResponse> =>
33
+ (await AbyssReflexCore.axios.put<ISetFunctionDefaultSettingsResponse>(settingsUrl(params), body))
34
+ .data;
35
+
36
+ /**
37
+ * `PUT .../settings/:environmentId`: sets the override of one environment. Needs REFLEX_FUNCTION_UPDATE, and
38
+ * REFLEX_PUBLISH_PRODUCTION for a production environment.
39
+ */
40
+ export const setFunctionEnvironmentSettings = async (
41
+ params: ISetFunctionEnvironmentSettingsParams,
42
+ body: ISetFunctionEnvironmentSettingsBody,
43
+ ): Promise<ISetFunctionEnvironmentSettingsResponse> =>
44
+ (
45
+ await AbyssReflexCore.axios.put<ISetFunctionEnvironmentSettingsResponse>(
46
+ `${settingsUrl(params)}/${params.environmentId}`,
47
+ body,
48
+ )
49
+ ).data;
50
+
51
+ /** `DELETE .../settings/:environmentId`: the environment falls back on the default. Same rights as setting it. */
52
+ export const removeFunctionEnvironmentSettings = async (
53
+ params: IRemoveFunctionEnvironmentSettingsParams,
54
+ ): Promise<IRemoveFunctionEnvironmentSettingsResponse> =>
55
+ (
56
+ await AbyssReflexCore.axios.delete<IRemoveFunctionEnvironmentSettingsResponse>(
57
+ `${settingsUrl(params)}/${params.environmentId}`,
58
+ )
59
+ ).data;
@@ -1,33 +1,34 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IDryRunFunctionBody,
4
- IDryRunFunctionResponse,
5
- IFunctionTestParams,
6
- ISimulateFunctionBody,
7
- ISimulateFunctionResponse,
8
- } from '../types';
9
-
10
- const testUrl = (params: IFunctionTestParams): string =>
11
- `api/function/${params.applicationId}/${params.functionId}/test`;
12
-
13
- /**
14
- * `POST .../test/simulate`: runs the draft on a made-up event. Nothing is executed: HTTP steps get the
15
- * stub they are given, the Store is a scratch copy thrown away. Needs REFLEX_TEST_RUN.
16
- */
17
- export const simulateFunction = async (
18
- params: IFunctionTestParams,
19
- body: ISimulateFunctionBody = {},
20
- ): Promise<ISimulateFunctionResponse> =>
21
- (await AbyssReflexCore.axios.post<ISimulateFunctionResponse>(`${testUrl(params)}/simulate`, body))
22
- .data;
23
-
24
- /**
25
- * `POST .../test/dry-run`: like a simulation, but the Store is read for real; writes are recorded and not
26
- * done. Needs REFLEX_TEST_RUN.
27
- */
28
- export const dryRunFunction = async (
29
- params: IFunctionTestParams,
30
- body: IDryRunFunctionBody = {},
31
- ): Promise<IDryRunFunctionResponse> =>
32
- (await AbyssReflexCore.axios.post<IDryRunFunctionResponse>(`${testUrl(params)}/dry-run`, body))
33
- .data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IDryRunFunctionBody,
4
+ IDryRunFunctionResponse,
5
+ IFunctionTestParams,
6
+ ISimulateFunctionBody,
7
+ ISimulateFunctionResponse,
8
+ } from '../types';
9
+
10
+ const testUrl = (params: IFunctionTestParams): string =>
11
+ `api/function/${params.applicationId}/${params.functionId}/test`;
12
+
13
+ /**
14
+ * `POST .../test/simulate`: runs the draft on a made-up event, in the environment `body.environmentId`.
15
+ * Nothing is executed: HTTP steps get the stub they are given, the Store is a scratch copy thrown away.
16
+ * Needs REFLEX_TEST_RUN.
17
+ */
18
+ export const simulateFunction = async (
19
+ params: IFunctionTestParams,
20
+ body: ISimulateFunctionBody,
21
+ ): Promise<ISimulateFunctionResponse> =>
22
+ (await AbyssReflexCore.axios.post<ISimulateFunctionResponse>(`${testUrl(params)}/simulate`, body))
23
+ .data;
24
+
25
+ /**
26
+ * `POST .../test/dry-run`: like a simulation, but the Store of the environment `body.environmentId` is
27
+ * read for real; writes are recorded and not done. Needs REFLEX_TEST_RUN.
28
+ */
29
+ export const dryRunFunction = async (
30
+ params: IFunctionTestParams,
31
+ body: IDryRunFunctionBody,
32
+ ): Promise<IDryRunFunctionResponse> =>
33
+ (await AbyssReflexCore.axios.post<IDryRunFunctionResponse>(`${testUrl(params)}/dry-run`, body))
34
+ .data;
@@ -1,56 +1,56 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IGetFunctionVersionParams,
4
- IGetFunctionVersionResponse,
5
- IGetFunctionVersionStepStatsParams,
6
- IGetFunctionVersionStepStatsQuery,
7
- IGetFunctionVersionStepStatsResponse,
8
- IListFunctionVersionParams,
9
- IListFunctionVersionResponse,
10
- IPublishFunctionVersionParams,
11
- IPublishFunctionVersionResponse,
12
- } from '../types';
13
-
14
- const versionUrl = (params: { applicationId: string; functionId: string }): string =>
15
- `api/function/${params.applicationId}/${params.functionId}/version`;
16
-
17
- /** `GET .../version`: the frozen versions, newest first. Needs REFLEX_READ. */
18
- export const listFunctionVersion = async (
19
- params: IListFunctionVersionParams,
20
- ): Promise<IListFunctionVersionResponse> =>
21
- (await AbyssReflexCore.axios.get<IListFunctionVersionResponse>(versionUrl(params))).data;
22
-
23
- /**
24
- * `POST .../version`: freezes the draft as the next version (SHA-256 of the definition). Refused with
25
- * `409 GRANT_SUSPENDED` when an access was granted by a member who lost the right since. Needs REFLEX_PUBLISH.
26
- */
27
- export const publishFunctionVersion = async (
28
- params: IPublishFunctionVersionParams,
29
- ): Promise<IPublishFunctionVersionResponse> =>
30
- (await AbyssReflexCore.axios.post<IPublishFunctionVersionResponse>(versionUrl(params), {})).data;
31
-
32
- /** `GET .../version/:versionId`. Needs REFLEX_READ. */
33
- export const getFunctionVersion = async (
34
- params: IGetFunctionVersionParams,
35
- ): Promise<IGetFunctionVersionResponse> =>
36
- (
37
- await AbyssReflexCore.axios.get<IGetFunctionVersionResponse>(
38
- `${versionUrl(params)}/${params.versionId}`,
39
- )
40
- ).data;
41
-
42
- /**
43
- * `GET .../version/:versionId/step-stats`: per step, over the retention window, the executions, the median
44
- * and p95 of duration, CPU, heap peak and cost, and the share of the cost; interrupted executions left
45
- * out. With `environmentId`, also the p99 heap peak per step of the version running there. Needs REFLEX_LOG_READ.
46
- */
47
- export const getFunctionVersionStepStats = async (
48
- params: IGetFunctionVersionStepStatsParams,
49
- query: IGetFunctionVersionStepStatsQuery = {},
50
- ): Promise<IGetFunctionVersionStepStatsResponse> =>
51
- (
52
- await AbyssReflexCore.axios.get<IGetFunctionVersionStepStatsResponse>(
53
- `${versionUrl(params)}/${params.versionId}/step-stats`,
54
- { params: query },
55
- )
56
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IGetFunctionVersionParams,
4
+ IGetFunctionVersionResponse,
5
+ IGetFunctionVersionStepStatsParams,
6
+ IGetFunctionVersionStepStatsQuery,
7
+ IGetFunctionVersionStepStatsResponse,
8
+ IListFunctionVersionParams,
9
+ IListFunctionVersionResponse,
10
+ IPublishFunctionVersionParams,
11
+ IPublishFunctionVersionResponse,
12
+ } from '../types';
13
+
14
+ const versionUrl = (params: { applicationId: string; functionId: string }): string =>
15
+ `api/function/${params.applicationId}/${params.functionId}/version`;
16
+
17
+ /** `GET .../version`: the frozen versions, newest first. Needs REFLEX_READ. */
18
+ export const listFunctionVersion = async (
19
+ params: IListFunctionVersionParams,
20
+ ): Promise<IListFunctionVersionResponse> =>
21
+ (await AbyssReflexCore.axios.get<IListFunctionVersionResponse>(versionUrl(params))).data;
22
+
23
+ /**
24
+ * `POST .../version`: freezes the draft as the next version (SHA-256 of the definition). Refused with
25
+ * `409 GRANT_SUSPENDED` when an access was granted by a member who lost the right since. Needs REFLEX_PUBLISH.
26
+ */
27
+ export const publishFunctionVersion = async (
28
+ params: IPublishFunctionVersionParams,
29
+ ): Promise<IPublishFunctionVersionResponse> =>
30
+ (await AbyssReflexCore.axios.post<IPublishFunctionVersionResponse>(versionUrl(params), {})).data;
31
+
32
+ /** `GET .../version/:versionId`. Needs REFLEX_READ. */
33
+ export const getFunctionVersion = async (
34
+ params: IGetFunctionVersionParams,
35
+ ): Promise<IGetFunctionVersionResponse> =>
36
+ (
37
+ await AbyssReflexCore.axios.get<IGetFunctionVersionResponse>(
38
+ `${versionUrl(params)}/${params.versionId}`,
39
+ )
40
+ ).data;
41
+
42
+ /**
43
+ * `GET .../version/:versionId/step-stats`: per step, over the retention window, the executions, the median
44
+ * and p95 of duration, CPU, heap peak and cost, and the share of the cost; interrupted executions left
45
+ * out. With `environmentId`, also the p99 heap peak per step of the version running there. Needs REFLEX_LOG_READ.
46
+ */
47
+ export const getFunctionVersionStepStats = async (
48
+ params: IGetFunctionVersionStepStatsParams,
49
+ query: IGetFunctionVersionStepStatsQuery = {},
50
+ ): Promise<IGetFunctionVersionStepStatsResponse> =>
51
+ (
52
+ await AbyssReflexCore.axios.get<IGetFunctionVersionStepStatsResponse>(
53
+ `${versionUrl(params)}/${params.versionId}/step-stats`,
54
+ { params: query },
55
+ )
56
+ ).data;
@@ -91,15 +91,19 @@ const calls: Call[] = [
91
91
  label: 'test.simulate',
92
92
  method: 'post',
93
93
  url: `${BASE}/test/simulate`,
94
- body: { input: { a: 1 } },
95
- run: () => sdk().test.simulate({ applicationId: APP, functionId: FN }, { input: { a: 1 } }),
94
+ body: { environmentId: 'e-1', input: { a: 1 } },
95
+ run: () =>
96
+ sdk().test.simulate(
97
+ { applicationId: APP, functionId: FN },
98
+ { environmentId: 'e-1', input: { a: 1 } },
99
+ ),
96
100
  },
97
101
  {
98
102
  label: 'test.dryRun',
99
103
  method: 'post',
100
104
  url: `${BASE}/test/dry-run`,
101
- body: {},
102
- run: () => sdk().test.dryRun({ applicationId: APP, functionId: FN }),
105
+ body: { environmentId: 'e-1' },
106
+ run: () => sdk().test.dryRun({ applicationId: APP, functionId: FN }, { environmentId: 'e-1' }),
103
107
  },
104
108
  {
105
109
  label: 'version.list',
package/src/api/index.ts CHANGED
@@ -1,9 +1,9 @@
1
- export * from './health.api';
2
- export * from './function.api';
3
- export * from './function-access.api';
4
- export * from './function-test.api';
5
- export * from './function-version.api';
6
- export * from './function-promotion.api';
7
- export * from './function-trigger.api';
8
- export * from './function-run.api';
9
- export * from './function-settings.api';
1
+ export * from './health.api';
2
+ export * from './function.api';
3
+ export * from './function-access.api';
4
+ export * from './function-test.api';
5
+ export * from './function-version.api';
6
+ export * from './function-promotion.api';
7
+ export * from './function-trigger.api';
8
+ export * from './function-run.api';
9
+ export * from './function-settings.api';