@abyss-project/reflex 6.4.0 → 6.6.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 (133) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/README.md +15 -15
  4. package/dist/api/function-run.api.d.ts +2 -1
  5. package/dist/api/function-run.api.js +3 -1
  6. package/dist/api/function-run.api.js.map +1 -1
  7. package/dist/discord/discord-command-tree.d.ts +5 -0
  8. package/dist/discord/discord-command-tree.js +38 -0
  9. package/dist/discord/discord-command-tree.js.map +1 -0
  10. package/dist/discord/discord-event-filter-cases.js +27 -11
  11. package/dist/discord/discord-event-filter-cases.js.map +1 -1
  12. package/dist/discord/discord-event-filters.js +7 -3
  13. package/dist/discord/discord-event-filters.js.map +1 -1
  14. package/dist/discord/discord-event-intents.d.ts +8 -2
  15. package/dist/discord/discord-event-intents.js +13 -2
  16. package/dist/discord/discord-event-intents.js.map +1 -1
  17. package/dist/discord/index.d.ts +1 -0
  18. package/dist/discord/index.js +1 -0
  19. package/dist/discord/index.js.map +1 -1
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.js +1 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/types/enum/discord-command-node-type.enum.d.ts +5 -0
  24. package/dist/types/enum/discord-command-node-type.enum.js +10 -0
  25. package/dist/types/enum/discord-command-node-type.enum.js.map +1 -0
  26. package/dist/types/enum/discord-command-type.enum.d.ts +5 -0
  27. package/dist/types/enum/discord-command-type.enum.js +10 -0
  28. package/dist/types/enum/discord-command-type.enum.js.map +1 -0
  29. package/dist/types/enum/discord-event-type.enum.d.ts +3 -1
  30. package/dist/types/enum/discord-event-type.enum.js +2 -0
  31. package/dist/types/enum/discord-event-type.enum.js.map +1 -1
  32. package/dist/types/enum/index.d.ts +2 -0
  33. package/dist/types/enum/index.js +2 -0
  34. package/dist/types/enum/index.js.map +1 -1
  35. package/dist/types/enum/reflex-error-code.enum.d.ts +10 -0
  36. package/dist/types/enum/reflex-error-code.enum.js +10 -0
  37. package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
  38. package/dist/types/interface/api/requests/function-run.request.d.ts +8 -0
  39. package/dist/types/interface/api/requests/service-discord.request.d.ts +7 -3
  40. package/dist/types/interface/api/responses/function-run.response.d.ts +8 -0
  41. package/dist/types/interface/models/reflex-discord.model.d.ts +18 -2
  42. package/dist/types/interface/models/reflex-discord.model.js +4 -0
  43. package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
  44. package/dist/types/interface/models/reflex-run.model.d.ts +4 -0
  45. package/dist/types/interface/models/reflex-run.model.js +4 -1
  46. package/dist/types/interface/models/reflex-run.model.js.map +1 -1
  47. package/jest.config.ts +11 -11
  48. package/package.json +1 -1
  49. package/src/api/alert-rule.api.test.ts +72 -72
  50. package/src/api/alert-rule.api.ts +57 -57
  51. package/src/api/application-insights.api.test.ts +42 -42
  52. package/src/api/application-insights.api.ts +38 -38
  53. package/src/api/application-run-settings.api.test.ts +62 -62
  54. package/src/api/application-run-settings.api.ts +30 -30
  55. package/src/api/function-access.api.ts +87 -87
  56. package/src/api/function-insights.api.test.ts +27 -27
  57. package/src/api/function-insights.api.ts +18 -18
  58. package/src/api/function-run.api.ts +19 -0
  59. package/src/api/function-settings.api.ts +96 -96
  60. package/src/api/function-template.api.test.ts +72 -72
  61. package/src/api/function-template.api.ts +52 -52
  62. package/src/api/function-test.api.ts +34 -34
  63. package/src/api/function-version.api.ts +66 -66
  64. package/src/api/function.api.test.ts +346 -346
  65. package/src/api/function.api.ts +62 -62
  66. package/src/api/health.api.ts +10 -10
  67. package/src/api/route-stats.api.test.ts +45 -45
  68. package/src/api/route-stats.api.ts +36 -36
  69. package/src/api/service-completion-webhook.api.test.ts +97 -97
  70. package/src/api/service-completion-webhook.api.ts +39 -39
  71. package/src/api/service-configuration.api.ts +16 -16
  72. package/src/api/service-consumer.api.test.ts +104 -104
  73. package/src/api/service-consumer.api.ts +90 -90
  74. package/src/api/service-deployment.api.ts +79 -79
  75. package/src/api/service-discord-event.api.test.ts +106 -106
  76. package/src/api/service-discord-event.api.ts +78 -78
  77. package/src/api/service-discord.api.test.ts +178 -178
  78. package/src/api/service-discord.api.ts +222 -222
  79. package/src/api/service-insights.api.test.ts +36 -36
  80. package/src/api/service-insights.api.ts +42 -42
  81. package/src/api/service-limits.api.test.ts +100 -100
  82. package/src/api/service-limits.api.ts +37 -37
  83. package/src/api/service-openapi.api.test.ts +52 -52
  84. package/src/api/service-openapi.api.ts +21 -21
  85. package/src/api/service-route.api.ts +74 -74
  86. package/src/api/service-task.api.test.ts +140 -140
  87. package/src/api/service-task.api.ts +141 -141
  88. package/src/api/service-version.api.ts +54 -54
  89. package/src/api/service.api.test.ts +220 -220
  90. package/src/api/service.api.ts +55 -55
  91. package/src/api/storage-surplus.admin.api.test.ts +66 -66
  92. package/src/api/storage-surplus.admin.api.ts +45 -45
  93. package/src/discord/discord-command-tree.test.ts +47 -0
  94. package/src/discord/discord-command-tree.ts +60 -0
  95. package/src/discord/discord-event-filter-cases.ts +299 -261
  96. package/src/discord/discord-event-filters.test.ts +120 -91
  97. package/src/discord/discord-event-filters.ts +103 -95
  98. package/src/discord/discord-event-intents.test.ts +139 -112
  99. package/src/discord/discord-event-intents.ts +80 -55
  100. package/src/discord/index.ts +4 -3
  101. package/src/index.test.ts +104 -104
  102. package/src/index.ts +2 -0
  103. package/src/insights/index.ts +1 -1
  104. package/src/insights/percentiles.test.ts +75 -75
  105. package/src/insights/percentiles.ts +37 -37
  106. package/src/types/enum/discord-command-node-type.enum.ts +10 -0
  107. package/src/types/enum/discord-command-type.enum.ts +9 -0
  108. package/src/types/enum/discord-event-type.enum.ts +4 -0
  109. package/src/types/enum/discord-host-action.enum.ts +37 -37
  110. package/src/types/enum/index.ts +2 -0
  111. package/src/types/enum/reflex-error-code.enum.ts +112 -89
  112. package/src/types/interface/api/requests/application-run-settings.request.ts +13 -13
  113. package/src/types/interface/api/requests/function-run.request.ts +53 -42
  114. package/src/types/interface/api/requests/function-settings.request.ts +50 -50
  115. package/src/types/interface/api/requests/index.ts +25 -25
  116. package/src/types/interface/api/requests/service-discord.request.ts +168 -155
  117. package/src/types/interface/api/requests/service.request.ts +48 -48
  118. package/src/types/interface/api/requests/storage-surplus.admin.request.ts +12 -12
  119. package/src/types/interface/api/responses/function-run.response.ts +35 -23
  120. package/src/types/interface/api/responses/function-settings.response.ts +57 -57
  121. package/src/types/interface/api/responses/index.ts +25 -25
  122. package/src/types/interface/api/responses/storage-surplus.admin.response.ts +10 -10
  123. package/src/types/interface/models/index.ts +29 -29
  124. package/src/types/interface/models/reflex-discord.model.ts +249 -208
  125. package/src/types/interface/models/reflex-price-list.model.ts +22 -22
  126. package/src/types/interface/models/reflex-run-retention.model.ts +24 -24
  127. package/src/types/interface/models/reflex-run-settings.model.ts +39 -39
  128. package/src/types/interface/models/reflex-run.model.ts +317 -309
  129. package/src/types/interface/models/reflex-service-deployment.model.ts +48 -48
  130. package/src/types/interface/models/reflex-service.model.ts +47 -47
  131. package/src/types/interface/models/reflex-storage-surplus.model.ts +23 -23
  132. package/tsconfig.check.json +15 -15
  133. package/tsconfig.json +35 -35
@@ -1,38 +1,38 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IGetApplicationCalendarParams,
4
- IGetApplicationCalendarQuery,
5
- IGetApplicationCalendarResponse,
6
- IGetApplicationInsightsParams,
7
- IGetApplicationInsightsQuery,
8
- IGetApplicationInsightsResponse,
9
- } from '../types';
10
-
11
- const insightsUrl = (params: { applicationId: string }): string =>
12
- `api/application/${params.applicationId}/insights`;
13
-
14
- /**
15
- * `GET .../insights`: the overview of an application in one environment over a period: tiles, series, share by
16
- * Service, ranking of the triggers. Needs REFLEX_READ.
17
- */
18
- export const getApplicationInsights = async (
19
- params: IGetApplicationInsightsParams,
20
- query: IGetApplicationInsightsQuery,
21
- ): Promise<IGetApplicationInsightsResponse> =>
22
- (
23
- await AbyssReflexCore.axios.get<IGetApplicationInsightsResponse>(insightsUrl(params), {
24
- params: query,
25
- })
26
- ).data;
27
-
28
- /** `GET .../insights/calendar`: runs, failures and credits of each of the last 365 days. Needs REFLEX_READ. */
29
- export const getApplicationCalendar = async (
30
- params: IGetApplicationCalendarParams,
31
- query: IGetApplicationCalendarQuery,
32
- ): Promise<IGetApplicationCalendarResponse> =>
33
- (
34
- await AbyssReflexCore.axios.get<IGetApplicationCalendarResponse>(
35
- `${insightsUrl(params)}/calendar`,
36
- { params: query },
37
- )
38
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IGetApplicationCalendarParams,
4
+ IGetApplicationCalendarQuery,
5
+ IGetApplicationCalendarResponse,
6
+ IGetApplicationInsightsParams,
7
+ IGetApplicationInsightsQuery,
8
+ IGetApplicationInsightsResponse,
9
+ } from '../types';
10
+
11
+ const insightsUrl = (params: { applicationId: string }): string =>
12
+ `api/application/${params.applicationId}/insights`;
13
+
14
+ /**
15
+ * `GET .../insights`: the overview of an application in one environment over a period: tiles, series, share by
16
+ * Service, ranking of the triggers. Needs REFLEX_READ.
17
+ */
18
+ export const getApplicationInsights = async (
19
+ params: IGetApplicationInsightsParams,
20
+ query: IGetApplicationInsightsQuery,
21
+ ): Promise<IGetApplicationInsightsResponse> =>
22
+ (
23
+ await AbyssReflexCore.axios.get<IGetApplicationInsightsResponse>(insightsUrl(params), {
24
+ params: query,
25
+ })
26
+ ).data;
27
+
28
+ /** `GET .../insights/calendar`: runs, failures and credits of each of the last 365 days. Needs REFLEX_READ. */
29
+ export const getApplicationCalendar = async (
30
+ params: IGetApplicationCalendarParams,
31
+ query: IGetApplicationCalendarQuery,
32
+ ): Promise<IGetApplicationCalendarResponse> =>
33
+ (
34
+ await AbyssReflexCore.axios.get<IGetApplicationCalendarResponse>(
35
+ `${insightsUrl(params)}/calendar`,
36
+ { params: query },
37
+ )
38
+ ).data;
@@ -1,62 +1,62 @@
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('runSettings.set carries the retention tier of the runs', async () => {
41
- await AbyssReflexCore.sdk.application.runSettings.set(
42
- { applicationId: 'app-1' },
43
- { maxLogLinesPerRun: null, runRetentionDays: 90 },
44
- );
45
-
46
- const config = adapter.mock.calls[0][0];
47
- expect(config.method).toBe('put');
48
- expect(JSON.parse(config.data)).toEqual({ maxLogLinesPerRun: null, runRetentionDays: 90 });
49
- });
50
-
51
- it('logCap.set calls PUT .../log-cap of the function', async () => {
52
- await AbyssReflexCore.sdk.function.logCap.set(
53
- { applicationId: 'app-1', functionId: 'fn-1' },
54
- { mode: LogCapMode.LIMIT, lines: 50 },
55
- );
56
-
57
- const config = adapter.mock.calls[0][0];
58
- expect(config.method).toBe('put');
59
- expect(config.url).toBe('api/function/app-1/fn-1/log-cap');
60
- expect(JSON.parse(config.data)).toEqual({ mode: 'LIMIT', lines: 50 });
61
- });
62
- });
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('runSettings.set carries the retention tier of the runs', async () => {
41
+ await AbyssReflexCore.sdk.application.runSettings.set(
42
+ { applicationId: 'app-1' },
43
+ { maxLogLinesPerRun: null, runRetentionDays: 90 },
44
+ );
45
+
46
+ const config = adapter.mock.calls[0][0];
47
+ expect(config.method).toBe('put');
48
+ expect(JSON.parse(config.data)).toEqual({ maxLogLinesPerRun: null, runRetentionDays: 90 });
49
+ });
50
+
51
+ it('logCap.set calls PUT .../log-cap of the function', async () => {
52
+ await AbyssReflexCore.sdk.function.logCap.set(
53
+ { applicationId: 'app-1', functionId: 'fn-1' },
54
+ { mode: LogCapMode.LIMIT, lines: 50 },
55
+ );
56
+
57
+ const config = adapter.mock.calls[0][0];
58
+ expect(config.method).toBe('put');
59
+ expect(config.url).toBe('api/function/app-1/fn-1/log-cap');
60
+ expect(JSON.parse(config.data)).toEqual({ mode: 'LIMIT', lines: 50 });
61
+ });
62
+ });
@@ -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,87 +1,87 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IDismissFunctionAccessRequestParams,
4
- IDismissFunctionAccessRequestResponse,
5
- IGrantAllFunctionAccessParams,
6
- IGrantAllFunctionAccessResponse,
7
- IGrantFunctionAccessRequestParams,
8
- IGrantFunctionAccessRequestResponse,
9
- IRequestFunctionAccessBody,
10
- IRequestFunctionAccessParams,
11
- IRequestFunctionAccessResponse,
12
- IGrantFunctionAccessBody,
13
- IGrantFunctionAccessParams,
14
- IGrantFunctionAccessResponse,
15
- IListFunctionAccessParams,
16
- IListFunctionAccessResponse,
17
- IRevokeFunctionAccessParams,
18
- IRevokeFunctionAccessResponse,
19
- } from '../types';
20
-
21
- const accessUrl = (params: { applicationId: string; functionId: string }): string =>
22
- `api/function/${params.applicationId}/${params.functionId}/access`;
23
-
24
- /** `GET .../access`: every access granted to the function, revoked ones included (the journal), its requests and the declaration keys the caller may grant. Needs REFLEX_READ. */
25
- export const listFunctionAccess = async (
26
- params: IListFunctionAccessParams,
27
- ): Promise<IListFunctionAccessResponse> =>
28
- (await AbyssReflexCore.axios.get<IListFunctionAccessResponse>(accessUrl(params))).data;
29
-
30
- /** `POST .../access`: grants an access the draft declares. The caller must hold the right it needs (`403` otherwise). */
31
- export const grantFunctionAccess = async (
32
- params: IGrantFunctionAccessParams,
33
- body: IGrantFunctionAccessBody,
34
- ): Promise<IGrantFunctionAccessResponse> =>
35
- (await AbyssReflexCore.axios.post<IGrantFunctionAccessResponse>(accessUrl(params), body)).data;
36
-
37
- /** `DELETE .../access/:grantId`: withdraws the access, at once, from what is already promoted. Needs REFLEX_FUNCTION_UPDATE. */
38
- export const revokeFunctionAccess = async (
39
- params: IRevokeFunctionAccessParams,
40
- ): Promise<IRevokeFunctionAccessResponse> =>
41
- (
42
- await AbyssReflexCore.axios.delete<IRevokeFunctionAccessResponse>(
43
- `${accessUrl(params)}/${params.grantId}`,
44
- )
45
- ).data;
46
-
47
- /** `POST .../access/grant-all`: grants every declaration of the saved draft the caller may grant and files a pending request for the rest. Needs REFLEX_READ; each grant needs the right of its declaration. */
48
- export const grantAllFunctionAccess = async (
49
- params: IGrantAllFunctionAccessParams,
50
- ): Promise<IGrantAllFunctionAccessResponse> =>
51
- (
52
- await AbyssReflexCore.axios.post<IGrantAllFunctionAccessResponse>(
53
- `${accessUrl(params)}/grant-all`,
54
- )
55
- ).data;
56
-
57
- /** `POST .../access/request`: asks for an access the saved draft declares (`409 ACCESS_NOT_DECLARED` otherwise). Needs REFLEX_READ. */
58
- export const requestFunctionAccess = async (
59
- params: IRequestFunctionAccessParams,
60
- body: IRequestFunctionAccessBody,
61
- ): Promise<IRequestFunctionAccessResponse> =>
62
- (
63
- await AbyssReflexCore.axios.post<IRequestFunctionAccessResponse>(
64
- `${accessUrl(params)}/request`,
65
- body,
66
- )
67
- ).data;
68
-
69
- /** `POST .../access/request/:requestId/grant`: grants the access of a pending request. The caller must hold the right the access needs. */
70
- export const grantFunctionAccessRequest = async (
71
- params: IGrantFunctionAccessRequestParams,
72
- ): Promise<IGrantFunctionAccessRequestResponse> =>
73
- (
74
- await AbyssReflexCore.axios.post<IGrantFunctionAccessRequestResponse>(
75
- `${accessUrl(params)}/request/${params.requestId}/grant`,
76
- )
77
- ).data;
78
-
79
- /** `POST .../access/request/:requestId/dismiss`: sets a pending request aside. The caller must hold the right the access needs. */
80
- export const dismissFunctionAccessRequest = async (
81
- params: IDismissFunctionAccessRequestParams,
82
- ): Promise<IDismissFunctionAccessRequestResponse> =>
83
- (
84
- await AbyssReflexCore.axios.post<IDismissFunctionAccessRequestResponse>(
85
- `${accessUrl(params)}/request/${params.requestId}/dismiss`,
86
- )
87
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IDismissFunctionAccessRequestParams,
4
+ IDismissFunctionAccessRequestResponse,
5
+ IGrantAllFunctionAccessParams,
6
+ IGrantAllFunctionAccessResponse,
7
+ IGrantFunctionAccessRequestParams,
8
+ IGrantFunctionAccessRequestResponse,
9
+ IRequestFunctionAccessBody,
10
+ IRequestFunctionAccessParams,
11
+ IRequestFunctionAccessResponse,
12
+ IGrantFunctionAccessBody,
13
+ IGrantFunctionAccessParams,
14
+ IGrantFunctionAccessResponse,
15
+ IListFunctionAccessParams,
16
+ IListFunctionAccessResponse,
17
+ IRevokeFunctionAccessParams,
18
+ IRevokeFunctionAccessResponse,
19
+ } from '../types';
20
+
21
+ const accessUrl = (params: { applicationId: string; functionId: string }): string =>
22
+ `api/function/${params.applicationId}/${params.functionId}/access`;
23
+
24
+ /** `GET .../access`: every access granted to the function, revoked ones included (the journal), its requests and the declaration keys the caller may grant. Needs REFLEX_READ. */
25
+ export const listFunctionAccess = async (
26
+ params: IListFunctionAccessParams,
27
+ ): Promise<IListFunctionAccessResponse> =>
28
+ (await AbyssReflexCore.axios.get<IListFunctionAccessResponse>(accessUrl(params))).data;
29
+
30
+ /** `POST .../access`: grants an access the draft declares. The caller must hold the right it needs (`403` otherwise). */
31
+ export const grantFunctionAccess = async (
32
+ params: IGrantFunctionAccessParams,
33
+ body: IGrantFunctionAccessBody,
34
+ ): Promise<IGrantFunctionAccessResponse> =>
35
+ (await AbyssReflexCore.axios.post<IGrantFunctionAccessResponse>(accessUrl(params), body)).data;
36
+
37
+ /** `DELETE .../access/:grantId`: withdraws the access, at once, from what is already promoted. Needs REFLEX_FUNCTION_UPDATE. */
38
+ export const revokeFunctionAccess = async (
39
+ params: IRevokeFunctionAccessParams,
40
+ ): Promise<IRevokeFunctionAccessResponse> =>
41
+ (
42
+ await AbyssReflexCore.axios.delete<IRevokeFunctionAccessResponse>(
43
+ `${accessUrl(params)}/${params.grantId}`,
44
+ )
45
+ ).data;
46
+
47
+ /** `POST .../access/grant-all`: grants every declaration of the saved draft the caller may grant and files a pending request for the rest. Needs REFLEX_READ; each grant needs the right of its declaration. */
48
+ export const grantAllFunctionAccess = async (
49
+ params: IGrantAllFunctionAccessParams,
50
+ ): Promise<IGrantAllFunctionAccessResponse> =>
51
+ (
52
+ await AbyssReflexCore.axios.post<IGrantAllFunctionAccessResponse>(
53
+ `${accessUrl(params)}/grant-all`,
54
+ )
55
+ ).data;
56
+
57
+ /** `POST .../access/request`: asks for an access the saved draft declares (`409 ACCESS_NOT_DECLARED` otherwise). Needs REFLEX_READ. */
58
+ export const requestFunctionAccess = async (
59
+ params: IRequestFunctionAccessParams,
60
+ body: IRequestFunctionAccessBody,
61
+ ): Promise<IRequestFunctionAccessResponse> =>
62
+ (
63
+ await AbyssReflexCore.axios.post<IRequestFunctionAccessResponse>(
64
+ `${accessUrl(params)}/request`,
65
+ body,
66
+ )
67
+ ).data;
68
+
69
+ /** `POST .../access/request/:requestId/grant`: grants the access of a pending request. The caller must hold the right the access needs. */
70
+ export const grantFunctionAccessRequest = async (
71
+ params: IGrantFunctionAccessRequestParams,
72
+ ): Promise<IGrantFunctionAccessRequestResponse> =>
73
+ (
74
+ await AbyssReflexCore.axios.post<IGrantFunctionAccessRequestResponse>(
75
+ `${accessUrl(params)}/request/${params.requestId}/grant`,
76
+ )
77
+ ).data;
78
+
79
+ /** `POST .../access/request/:requestId/dismiss`: sets a pending request aside. The caller must hold the right the access needs. */
80
+ export const dismissFunctionAccessRequest = async (
81
+ params: IDismissFunctionAccessRequestParams,
82
+ ): Promise<IDismissFunctionAccessRequestResponse> =>
83
+ (
84
+ await AbyssReflexCore.axios.post<IDismissFunctionAccessRequestResponse>(
85
+ `${accessUrl(params)}/request/${params.requestId}/dismiss`,
86
+ )
87
+ ).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;
@@ -7,6 +7,9 @@ import type {
7
7
  IListFunctionRunParams,
8
8
  IListFunctionRunQuery,
9
9
  IListFunctionRunResponse,
10
+ IReplayFunctionRunBody,
11
+ IReplayFunctionRunParams,
12
+ IReplayFunctionRunResponse,
10
13
  ISetFunctionRunFavoriteBody,
11
14
  ISetFunctionRunFavoriteParams,
12
15
  ISetFunctionRunFavoriteResponse,
@@ -30,6 +33,22 @@ export const getFunctionRun = async (
30
33
  (await AbyssReflexCore.axios.get<IGetFunctionRunResponse>(`${runUrl(params)}/${params.runId}`))
31
34
  .data;
32
35
 
36
+ /**
37
+ * `POST .../run/:runId/replay`: replays a live run of a Discord event trigger from its kept input. `DRY_RUN` needs
38
+ * REFLEX_LOG_READ and REFLEX_TEST_RUN; `LIVE` needs REFLEX_LOG_READ and REFLEX_PUBLISH (REFLEX_PUBLISH_PRODUCTION in
39
+ * production), at most `REFLEX_REPLAY_LIMITS.liveReplaysPerMinute` per bot and environment.
40
+ */
41
+ export const replayFunctionRun = async (
42
+ params: IReplayFunctionRunParams,
43
+ body: IReplayFunctionRunBody,
44
+ ): Promise<IReplayFunctionRunResponse> =>
45
+ (
46
+ await AbyssReflexCore.axios.post<IReplayFunctionRunResponse>(
47
+ `${runUrl(params)}/${params.runId}/replay`,
48
+ body,
49
+ )
50
+ ).data;
51
+
33
52
  /** `GET .../run/:runId/state`: the state of a live execution, the one an async route answered with. Needs REFLEX_LOG_READ. */
34
53
  export const getFunctionRunState = async (
35
54
  params: IGetFunctionRunStateParams,