@abyss-project/reflex 5.11.0 → 5.12.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 (101) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/README.md +15 -15
  4. package/dist/types/interface/api/responses/service-version.response.d.ts +1 -0
  5. package/jest.config.ts +11 -11
  6. package/package.json +15 -10
  7. package/src/api/alert-rule.api.test.ts +72 -72
  8. package/src/api/alert-rule.api.ts +57 -57
  9. package/src/api/application-insights.api.test.ts +42 -42
  10. package/src/api/application-insights.api.ts +38 -38
  11. package/src/api/application-run-settings.api.test.ts +51 -51
  12. package/src/api/application-run-settings.api.ts +30 -30
  13. package/src/api/function-insights.api.test.ts +27 -27
  14. package/src/api/function-insights.api.ts +18 -18
  15. package/src/api/function-run.api.ts +38 -38
  16. package/src/api/function-settings.api.ts +74 -74
  17. package/src/api/function-test.api.ts +34 -34
  18. package/src/api/function.api.ts +62 -62
  19. package/src/api/health.api.ts +10 -10
  20. package/src/api/route-stats.api.test.ts +45 -45
  21. package/src/api/route-stats.api.ts +36 -36
  22. package/src/api/service-configuration.api.ts +16 -16
  23. package/src/api/service-deployment.api.ts +79 -79
  24. package/src/api/service-discord-event.api.test.ts +106 -106
  25. package/src/api/service-discord-event.api.ts +78 -78
  26. package/src/api/service-discord.api.test.ts +197 -197
  27. package/src/api/service-discord.api.ts +241 -241
  28. package/src/api/service-insights.api.test.ts +36 -36
  29. package/src/api/service-insights.api.ts +42 -42
  30. package/src/api/service-route.api.ts +72 -72
  31. package/src/api/service-task.api.test.ts +140 -140
  32. package/src/api/service-task.api.ts +141 -141
  33. package/src/api/service-version.api.ts +54 -54
  34. package/src/api/service.api.test.ts +215 -215
  35. package/src/api/service.api.ts +55 -55
  36. package/src/discord/discord-event-filter-cases.ts +261 -261
  37. package/src/discord/discord-event-filters.test.ts +91 -91
  38. package/src/discord/discord-event-filters.ts +95 -95
  39. package/src/discord/discord-event-intents.test.ts +112 -112
  40. package/src/discord/discord-event-intents.ts +55 -55
  41. package/src/discord/index.ts +3 -3
  42. package/src/index.test.ts +87 -87
  43. package/src/insights/index.ts +1 -1
  44. package/src/insights/percentiles.test.ts +75 -75
  45. package/src/insights/percentiles.ts +37 -37
  46. package/src/types/enum/access-grant-status.enum.ts +12 -12
  47. package/src/types/enum/access-kind.enum.ts +7 -7
  48. package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
  49. package/src/types/enum/configuration-read-as.enum.ts +5 -5
  50. package/src/types/enum/discord-activity-type.enum.ts +9 -9
  51. package/src/types/enum/discord-channel-type.enum.ts +11 -11
  52. package/src/types/enum/discord-component-kind.enum.ts +7 -7
  53. package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
  54. package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
  55. package/src/types/enum/discord-event-status.enum.ts +13 -13
  56. package/src/types/enum/discord-event-type.enum.ts +7 -7
  57. package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
  58. package/src/types/enum/discord-gateway-state.enum.ts +11 -11
  59. package/src/types/enum/discord-host-action.enum.ts +35 -35
  60. package/src/types/enum/discord-locale.enum.ts +35 -35
  61. package/src/types/enum/discord-option-type.enum.ts +12 -12
  62. package/src/types/enum/discord-presence-status.enum.ts +8 -8
  63. package/src/types/enum/discord-sync-status.enum.ts +6 -6
  64. package/src/types/enum/discord-token-state.enum.ts +11 -11
  65. package/src/types/enum/execution-mode.enum.ts +9 -9
  66. package/src/types/enum/execution-profile.enum.ts +20 -20
  67. package/src/types/enum/execution-settings-source.enum.ts +9 -9
  68. package/src/types/enum/health-status.enum.ts +4 -4
  69. package/src/types/enum/insights-period.enum.ts +8 -8
  70. package/src/types/enum/log-cap-mode.enum.ts +6 -6
  71. package/src/types/enum/log-drop-cause.enum.ts +8 -8
  72. package/src/types/enum/reflex-alert-metric.enum.ts +5 -5
  73. package/src/types/enum/reflex-alert-notification-state.enum.ts +6 -6
  74. package/src/types/enum/reflex-alert-scope.enum.ts +6 -6
  75. package/src/types/enum/reflex-error-code.enum.ts +43 -43
  76. package/src/types/enum/route-method.enum.ts +9 -9
  77. package/src/types/enum/run-log-level.enum.ts +6 -6
  78. package/src/types/enum/run-mode.enum.ts +11 -11
  79. package/src/types/enum/run-status.enum.ts +11 -11
  80. package/src/types/enum/run-step-status.enum.ts +7 -7
  81. package/src/types/enum/schedule-sync-status.enum.ts +6 -6
  82. package/src/types/enum/scheduled-run-failure-code.enum.ts +12 -12
  83. package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
  84. package/src/types/enum/scheduled-run-status.enum.ts +17 -17
  85. package/src/types/enum/service-deployment-action.enum.ts +11 -11
  86. package/src/types/enum/service-deployment-status.enum.ts +5 -5
  87. package/src/types/enum/service-type.enum.ts +9 -9
  88. package/src/types/enum/service-version-change-kind.enum.ts +6 -6
  89. package/src/types/enum/trace-effect-type.enum.ts +12 -12
  90. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  91. package/src/types/enum/trigger-kind.enum.ts +8 -8
  92. package/src/types/enum/vault-value-source.enum.ts +12 -12
  93. package/src/types/enum/vault-visibility.enum.ts +5 -5
  94. package/src/types/index.ts +2 -2
  95. package/src/types/interface/api/index.ts +3 -3
  96. package/src/types/interface/api/response.ts +4 -4
  97. package/src/types/interface/api/responses/service-version.response.ts +6 -0
  98. package/src/types/interface/health.response.ts +7 -7
  99. package/src/types/interface/index.ts +3 -3
  100. package/tsconfig.check.json +15 -15
  101. package/tsconfig.json +35 -35
@@ -1,51 +1,51 @@
1
- import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
- import { AbyssReflexCore, LogCapMode } from '..';
3
-
4
- const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(async (config) => ({
5
- data: { data: {} },
6
- status: 200,
7
- statusText: '',
8
- headers: {},
9
- config,
10
- }));
11
-
12
- beforeAll(() => {
13
- AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
14
- AbyssReflexCore.axios.defaults.adapter = adapter;
15
- });
16
-
17
- beforeEach(() => adapter.mockClear());
18
-
19
- describe('AbyssReflexCore application run settings routes', () => {
20
- it('runSettings.get calls GET .../run-settings', async () => {
21
- await AbyssReflexCore.sdk.application.runSettings.get({ applicationId: 'app-1' });
22
-
23
- const config = adapter.mock.calls[0][0];
24
- expect(config.method).toBe('get');
25
- expect(config.url).toBe('api/application/app-1/run-settings');
26
- });
27
-
28
- it('runSettings.set calls PUT .../run-settings with the cap', async () => {
29
- await AbyssReflexCore.sdk.application.runSettings.set(
30
- { applicationId: 'app-1' },
31
- { maxLogLinesPerRun: 500 },
32
- );
33
-
34
- const config = adapter.mock.calls[0][0];
35
- expect(config.method).toBe('put');
36
- expect(config.url).toBe('api/application/app-1/run-settings');
37
- expect(JSON.parse(config.data)).toEqual({ maxLogLinesPerRun: 500 });
38
- });
39
-
40
- it('logCap.set calls PUT .../log-cap of the function', async () => {
41
- await AbyssReflexCore.sdk.function.logCap.set(
42
- { applicationId: 'app-1', functionId: 'fn-1' },
43
- { mode: LogCapMode.LIMIT, lines: 50 },
44
- );
45
-
46
- const config = adapter.mock.calls[0][0];
47
- expect(config.method).toBe('put');
48
- expect(config.url).toBe('api/function/app-1/fn-1/log-cap');
49
- expect(JSON.parse(config.data)).toEqual({ mode: 'LIMIT', lines: 50 });
50
- });
51
- });
1
+ import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
+ import { AbyssReflexCore, LogCapMode } from '..';
3
+
4
+ const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(async (config) => ({
5
+ data: { data: {} },
6
+ status: 200,
7
+ statusText: '',
8
+ headers: {},
9
+ config,
10
+ }));
11
+
12
+ beforeAll(() => {
13
+ AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
14
+ AbyssReflexCore.axios.defaults.adapter = adapter;
15
+ });
16
+
17
+ beforeEach(() => adapter.mockClear());
18
+
19
+ describe('AbyssReflexCore application run settings routes', () => {
20
+ it('runSettings.get calls GET .../run-settings', async () => {
21
+ await AbyssReflexCore.sdk.application.runSettings.get({ applicationId: 'app-1' });
22
+
23
+ const config = adapter.mock.calls[0][0];
24
+ expect(config.method).toBe('get');
25
+ expect(config.url).toBe('api/application/app-1/run-settings');
26
+ });
27
+
28
+ it('runSettings.set calls PUT .../run-settings with the cap', async () => {
29
+ await AbyssReflexCore.sdk.application.runSettings.set(
30
+ { applicationId: 'app-1' },
31
+ { maxLogLinesPerRun: 500 },
32
+ );
33
+
34
+ const config = adapter.mock.calls[0][0];
35
+ expect(config.method).toBe('put');
36
+ expect(config.url).toBe('api/application/app-1/run-settings');
37
+ expect(JSON.parse(config.data)).toEqual({ maxLogLinesPerRun: 500 });
38
+ });
39
+
40
+ it('logCap.set calls PUT .../log-cap of the function', async () => {
41
+ await AbyssReflexCore.sdk.function.logCap.set(
42
+ { applicationId: 'app-1', functionId: 'fn-1' },
43
+ { mode: LogCapMode.LIMIT, lines: 50 },
44
+ );
45
+
46
+ const config = adapter.mock.calls[0][0];
47
+ expect(config.method).toBe('put');
48
+ expect(config.url).toBe('api/function/app-1/fn-1/log-cap');
49
+ expect(JSON.parse(config.data)).toEqual({ mode: 'LIMIT', lines: 50 });
50
+ });
51
+ });
@@ -1,30 +1,30 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IGetApplicationRunSettingsParams,
4
- IGetApplicationRunSettingsResponse,
5
- ISetApplicationRunSettingsBody,
6
- ISetApplicationRunSettingsParams,
7
- ISetApplicationRunSettingsResponse,
8
- } from '../types';
9
-
10
- const runSettingsUrl = (params: { applicationId: string }): string =>
11
- `api/application/${params.applicationId}/run-settings`;
12
-
13
- /** `GET .../run-settings`: the log cap, the effective retention and whether Monitor is activated. Needs REFLEX_READ. */
14
- export const getApplicationRunSettings = async (
15
- params: IGetApplicationRunSettingsParams,
16
- ): Promise<IGetApplicationRunSettingsResponse> =>
17
- (await AbyssReflexCore.axios.get<IGetApplicationRunSettingsResponse>(runSettingsUrl(params)))
18
- .data;
19
-
20
- /** `PUT .../run-settings`: sets the log cap of the application. Needs REFLEX_FUNCTION_UPDATE. */
21
- export const setApplicationRunSettings = async (
22
- params: ISetApplicationRunSettingsParams,
23
- body: ISetApplicationRunSettingsBody,
24
- ): Promise<ISetApplicationRunSettingsResponse> =>
25
- (
26
- await AbyssReflexCore.axios.put<ISetApplicationRunSettingsResponse>(
27
- runSettingsUrl(params),
28
- body,
29
- )
30
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IGetApplicationRunSettingsParams,
4
+ IGetApplicationRunSettingsResponse,
5
+ ISetApplicationRunSettingsBody,
6
+ ISetApplicationRunSettingsParams,
7
+ ISetApplicationRunSettingsResponse,
8
+ } from '../types';
9
+
10
+ const runSettingsUrl = (params: { applicationId: string }): string =>
11
+ `api/application/${params.applicationId}/run-settings`;
12
+
13
+ /** `GET .../run-settings`: the log cap, the effective retention and whether Monitor is activated. Needs REFLEX_READ. */
14
+ export const getApplicationRunSettings = async (
15
+ params: IGetApplicationRunSettingsParams,
16
+ ): Promise<IGetApplicationRunSettingsResponse> =>
17
+ (await AbyssReflexCore.axios.get<IGetApplicationRunSettingsResponse>(runSettingsUrl(params)))
18
+ .data;
19
+
20
+ /** `PUT .../run-settings`: sets the log cap of the application. Needs REFLEX_FUNCTION_UPDATE. */
21
+ export const setApplicationRunSettings = async (
22
+ params: ISetApplicationRunSettingsParams,
23
+ body: ISetApplicationRunSettingsBody,
24
+ ): Promise<ISetApplicationRunSettingsResponse> =>
25
+ (
26
+ await AbyssReflexCore.axios.put<ISetApplicationRunSettingsResponse>(
27
+ runSettingsUrl(params),
28
+ body,
29
+ )
30
+ ).data;
@@ -1,27 +1,27 @@
1
- import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
- import { AbyssReflexCore, InsightsPeriod } from '..';
3
-
4
- describe('AbyssReflexCore function insights route', () => {
5
- const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
6
- async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
7
- );
8
-
9
- beforeAll(() => {
10
- AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
11
- AbyssReflexCore.axios.defaults.adapter = adapter;
12
- });
13
-
14
- beforeEach(() => adapter.mockClear());
15
-
16
- it('insights.get calls GET /api/function/:applicationId/:functionId/insights', async () => {
17
- await AbyssReflexCore.sdk.function.insights.get(
18
- { applicationId: 'app-1', functionId: 'fn-1' },
19
- { environmentId: 'e-1', period: InsightsPeriod.HOURS_24 },
20
- );
21
-
22
- const config = adapter.mock.calls[0][0];
23
- expect(config.method).toBe('get');
24
- expect(config.url).toBe('api/function/app-1/fn-1/insights');
25
- expect(config.params).toEqual({ environmentId: 'e-1', period: '24h' });
26
- });
27
- });
1
+ import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
+ import { AbyssReflexCore, InsightsPeriod } from '..';
3
+
4
+ describe('AbyssReflexCore function insights route', () => {
5
+ const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
6
+ async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
7
+ );
8
+
9
+ beforeAll(() => {
10
+ AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
11
+ AbyssReflexCore.axios.defaults.adapter = adapter;
12
+ });
13
+
14
+ beforeEach(() => adapter.mockClear());
15
+
16
+ it('insights.get calls GET /api/function/:applicationId/:functionId/insights', async () => {
17
+ await AbyssReflexCore.sdk.function.insights.get(
18
+ { applicationId: 'app-1', functionId: 'fn-1' },
19
+ { environmentId: 'e-1', period: InsightsPeriod.HOURS_24 },
20
+ );
21
+
22
+ const config = adapter.mock.calls[0][0];
23
+ expect(config.method).toBe('get');
24
+ expect(config.url).toBe('api/function/app-1/fn-1/insights');
25
+ expect(config.params).toEqual({ environmentId: 'e-1', period: '24h' });
26
+ });
27
+ });
@@ -1,18 +1,18 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IGetFunctionInsightsParams,
4
- IGetFunctionInsightsQuery,
5
- IGetFunctionInsightsResponse,
6
- } from '../types';
7
-
8
- /** `GET .../function/:applicationId/:functionId/insights`: the dashboard of a function, same shape as a Service's. Needs REFLEX_LOG_READ. */
9
- export const getFunctionInsights = async (
10
- params: IGetFunctionInsightsParams,
11
- query: IGetFunctionInsightsQuery,
12
- ): Promise<IGetFunctionInsightsResponse> =>
13
- (
14
- await AbyssReflexCore.axios.get<IGetFunctionInsightsResponse>(
15
- `api/function/${params.applicationId}/${params.functionId}/insights`,
16
- { params: query },
17
- )
18
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IGetFunctionInsightsParams,
4
+ IGetFunctionInsightsQuery,
5
+ IGetFunctionInsightsResponse,
6
+ } from '../types';
7
+
8
+ /** `GET .../function/:applicationId/:functionId/insights`: the dashboard of a function, same shape as a Service's. Needs REFLEX_LOG_READ. */
9
+ export const getFunctionInsights = async (
10
+ params: IGetFunctionInsightsParams,
11
+ query: IGetFunctionInsightsQuery,
12
+ ): Promise<IGetFunctionInsightsResponse> =>
13
+ (
14
+ await AbyssReflexCore.axios.get<IGetFunctionInsightsResponse>(
15
+ `api/function/${params.applicationId}/${params.functionId}/insights`,
16
+ { params: query },
17
+ )
18
+ ).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 route 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 route 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,74 +1,74 @@
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
- ISetFunctionLogCapBody,
14
- ISetFunctionLogCapParams,
15
- ISetFunctionLogCapResponse,
16
- } from '../types';
17
-
18
- const settingsUrl = (params: { applicationId: string; functionId: string }): string =>
19
- `api/function/${params.applicationId}/${params.functionId}/settings`;
20
-
21
- /** `GET .../settings`: the default, the overrides, and what each environment runs with. Needs REFLEX_READ. */
22
- export const getFunctionSettings = async (
23
- params: IGetFunctionSettingsParams,
24
- ): Promise<IGetFunctionSettingsResponse> =>
25
- (await AbyssReflexCore.axios.get<IGetFunctionSettingsResponse>(settingsUrl(params))).data;
26
-
27
- /**
28
- * `PUT .../settings`: sets the default of every environment without an override, applied at once where the
29
- * function runs. Needs REFLEX_FUNCTION_UPDATE, and REFLEX_PUBLISH_PRODUCTION when the default applies to a
30
- * production environment where the function runs.
31
- */
32
- export const setFunctionDefaultSettings = async (
33
- params: ISetFunctionDefaultSettingsParams,
34
- body: ISetFunctionDefaultSettingsBody,
35
- ): Promise<ISetFunctionDefaultSettingsResponse> =>
36
- (await AbyssReflexCore.axios.put<ISetFunctionDefaultSettingsResponse>(settingsUrl(params), body))
37
- .data;
38
-
39
- /**
40
- * `PUT .../settings/:environmentId`: sets the override of one environment. Needs REFLEX_FUNCTION_UPDATE, and
41
- * REFLEX_PUBLISH_PRODUCTION for a production environment.
42
- */
43
- export const setFunctionEnvironmentSettings = async (
44
- params: ISetFunctionEnvironmentSettingsParams,
45
- body: ISetFunctionEnvironmentSettingsBody,
46
- ): Promise<ISetFunctionEnvironmentSettingsResponse> =>
47
- (
48
- await AbyssReflexCore.axios.put<ISetFunctionEnvironmentSettingsResponse>(
49
- `${settingsUrl(params)}/${params.environmentId}`,
50
- body,
51
- )
52
- ).data;
53
-
54
- /** `DELETE .../settings/:environmentId`: the environment falls back on the default. Same rights as setting it. */
55
- export const removeFunctionEnvironmentSettings = async (
56
- params: IRemoveFunctionEnvironmentSettingsParams,
57
- ): Promise<IRemoveFunctionEnvironmentSettingsResponse> =>
58
- (
59
- await AbyssReflexCore.axios.delete<IRemoveFunctionEnvironmentSettingsResponse>(
60
- `${settingsUrl(params)}/${params.environmentId}`,
61
- )
62
- ).data;
63
-
64
- /** `PUT .../log-cap`: sets the log cap of the function (inherit, none, or a number of lines). Needs REFLEX_FUNCTION_UPDATE. */
65
- export const setFunctionLogCap = async (
66
- params: ISetFunctionLogCapParams,
67
- body: ISetFunctionLogCapBody,
68
- ): Promise<ISetFunctionLogCapResponse> =>
69
- (
70
- await AbyssReflexCore.axios.put<ISetFunctionLogCapResponse>(
71
- `api/function/${params.applicationId}/${params.functionId}/log-cap`,
72
- body,
73
- )
74
- ).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
+ ISetFunctionLogCapBody,
14
+ ISetFunctionLogCapParams,
15
+ ISetFunctionLogCapResponse,
16
+ } from '../types';
17
+
18
+ const settingsUrl = (params: { applicationId: string; functionId: string }): string =>
19
+ `api/function/${params.applicationId}/${params.functionId}/settings`;
20
+
21
+ /** `GET .../settings`: the default, the overrides, and what each environment runs with. Needs REFLEX_READ. */
22
+ export const getFunctionSettings = async (
23
+ params: IGetFunctionSettingsParams,
24
+ ): Promise<IGetFunctionSettingsResponse> =>
25
+ (await AbyssReflexCore.axios.get<IGetFunctionSettingsResponse>(settingsUrl(params))).data;
26
+
27
+ /**
28
+ * `PUT .../settings`: sets the default of every environment without an override, applied at once where the
29
+ * function runs. Needs REFLEX_FUNCTION_UPDATE, and REFLEX_PUBLISH_PRODUCTION when the default applies to a
30
+ * production environment where the function runs.
31
+ */
32
+ export const setFunctionDefaultSettings = async (
33
+ params: ISetFunctionDefaultSettingsParams,
34
+ body: ISetFunctionDefaultSettingsBody,
35
+ ): Promise<ISetFunctionDefaultSettingsResponse> =>
36
+ (await AbyssReflexCore.axios.put<ISetFunctionDefaultSettingsResponse>(settingsUrl(params), body))
37
+ .data;
38
+
39
+ /**
40
+ * `PUT .../settings/:environmentId`: sets the override of one environment. Needs REFLEX_FUNCTION_UPDATE, and
41
+ * REFLEX_PUBLISH_PRODUCTION for a production environment.
42
+ */
43
+ export const setFunctionEnvironmentSettings = async (
44
+ params: ISetFunctionEnvironmentSettingsParams,
45
+ body: ISetFunctionEnvironmentSettingsBody,
46
+ ): Promise<ISetFunctionEnvironmentSettingsResponse> =>
47
+ (
48
+ await AbyssReflexCore.axios.put<ISetFunctionEnvironmentSettingsResponse>(
49
+ `${settingsUrl(params)}/${params.environmentId}`,
50
+ body,
51
+ )
52
+ ).data;
53
+
54
+ /** `DELETE .../settings/:environmentId`: the environment falls back on the default. Same rights as setting it. */
55
+ export const removeFunctionEnvironmentSettings = async (
56
+ params: IRemoveFunctionEnvironmentSettingsParams,
57
+ ): Promise<IRemoveFunctionEnvironmentSettingsResponse> =>
58
+ (
59
+ await AbyssReflexCore.axios.delete<IRemoveFunctionEnvironmentSettingsResponse>(
60
+ `${settingsUrl(params)}/${params.environmentId}`,
61
+ )
62
+ ).data;
63
+
64
+ /** `PUT .../log-cap`: sets the log cap of the function (inherit, none, or a number of lines). Needs REFLEX_FUNCTION_UPDATE. */
65
+ export const setFunctionLogCap = async (
66
+ params: ISetFunctionLogCapParams,
67
+ body: ISetFunctionLogCapBody,
68
+ ): Promise<ISetFunctionLogCapResponse> =>
69
+ (
70
+ await AbyssReflexCore.axios.put<ISetFunctionLogCapResponse>(
71
+ `api/function/${params.applicationId}/${params.functionId}/log-cap`,
72
+ body,
73
+ )
74
+ ).data;
@@ -1,34 +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, 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
+ 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;