@abyss-project/reflex 6.6.0 → 6.9.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.
- package/.eslintrc.js +32 -32
- package/.prettierrc +5 -5
- package/README.md +15 -15
- package/dist/api/function-run.api.d.ts +1 -2
- package/dist/api/function-run.api.js +1 -3
- package/dist/api/function-run.api.js.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/reflex-admin.admin.api.d.ts +5 -0
- package/dist/api/reflex-admin.admin.api.js +18 -0
- package/dist/api/reflex-admin.admin.api.js.map +1 -0
- package/dist/discord/discord-event-filter-cases.js +11 -27
- package/dist/discord/discord-event-filter-cases.js.map +1 -1
- package/dist/discord/discord-event-filters.js +3 -7
- package/dist/discord/discord-event-filters.js.map +1 -1
- package/dist/discord/discord-event-intents.d.ts +2 -8
- package/dist/discord/discord-event-intents.js +2 -13
- package/dist/discord/discord-event-intents.js.map +1 -1
- package/dist/discord/index.d.ts +0 -1
- package/dist/discord/index.js +0 -1
- package/dist/discord/index.js.map +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/types/enum/discord-event-type.enum.d.ts +1 -3
- package/dist/types/enum/discord-event-type.enum.js +0 -2
- package/dist/types/enum/discord-event-type.enum.js.map +1 -1
- package/dist/types/enum/index.d.ts +2 -2
- package/dist/types/enum/index.js +2 -2
- package/dist/types/enum/index.js.map +1 -1
- package/dist/types/enum/reflex-abuse-rule.enum.d.ts +5 -0
- package/dist/types/enum/reflex-abuse-rule.enum.js +10 -0
- package/dist/types/enum/reflex-abuse-rule.enum.js.map +1 -0
- package/dist/types/enum/reflex-admin-hold-kind.enum.d.ts +4 -0
- package/dist/types/enum/reflex-admin-hold-kind.enum.js +9 -0
- package/dist/types/enum/reflex-admin-hold-kind.enum.js.map +1 -0
- package/dist/types/enum/reflex-error-code.enum.d.ts +3 -11
- package/dist/types/enum/reflex-error-code.enum.js +2 -10
- package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
- package/dist/types/interface/api/requests/function-run.request.d.ts +0 -8
- package/dist/types/interface/api/requests/index.d.ts +1 -0
- package/dist/types/interface/api/requests/index.js +1 -0
- package/dist/types/interface/api/requests/index.js.map +1 -1
- package/dist/types/interface/api/requests/reflex-admin.admin.request.d.ts +21 -0
- package/dist/types/interface/api/requests/reflex-admin.admin.request.js +3 -0
- package/dist/types/interface/api/requests/reflex-admin.admin.request.js.map +1 -0
- package/dist/types/interface/api/requests/service-discord.request.d.ts +3 -7
- package/dist/types/interface/api/responses/function-run.response.d.ts +0 -8
- package/dist/types/interface/api/responses/index.d.ts +1 -0
- package/dist/types/interface/api/responses/index.js +1 -0
- package/dist/types/interface/api/responses/index.js.map +1 -1
- package/dist/types/interface/api/responses/reflex-admin.admin.response.d.ts +19 -0
- package/dist/types/interface/api/responses/reflex-admin.admin.response.js +3 -0
- package/dist/types/interface/api/responses/reflex-admin.admin.response.js.map +1 -0
- package/dist/types/interface/models/index.d.ts +1 -0
- package/dist/types/interface/models/index.js +1 -0
- package/dist/types/interface/models/index.js.map +1 -1
- package/dist/types/interface/models/reflex-admin-hold.model.d.ts +44 -0
- package/dist/types/interface/models/reflex-admin-hold.model.js +11 -0
- package/dist/types/interface/models/reflex-admin-hold.model.js.map +1 -0
- package/dist/types/interface/models/reflex-discord.model.d.ts +2 -18
- package/dist/types/interface/models/reflex-discord.model.js +0 -4
- package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
- package/dist/types/interface/models/reflex-run.model.d.ts +0 -4
- package/dist/types/interface/models/reflex-run.model.js +1 -4
- package/dist/types/interface/models/reflex-run.model.js.map +1 -1
- package/dist/types/interface/models/reflex-service-deployment.model.d.ts +2 -1
- package/dist/types/interface/models/reflex-service.model.d.ts +2 -0
- package/dist/types/interface/models/reflex-service.model.js.map +1 -1
- package/jest.config.ts +11 -11
- package/package.json +1 -1
- package/src/api/alert-rule.api.test.ts +72 -72
- package/src/api/alert-rule.api.ts +57 -57
- package/src/api/application-insights.api.test.ts +42 -42
- package/src/api/application-insights.api.ts +38 -38
- package/src/api/application-run-settings.api.ts +30 -30
- package/src/api/function-access.api.ts +87 -87
- package/src/api/function-insights.api.test.ts +27 -27
- package/src/api/function-insights.api.ts +18 -18
- package/src/api/function-run.api.ts +53 -72
- package/src/api/function-template.api.test.ts +72 -72
- package/src/api/function-template.api.ts +52 -52
- package/src/api/function-test.api.ts +34 -34
- package/src/api/function-version.api.ts +66 -66
- package/src/api/function.api.ts +62 -62
- package/src/api/health.api.ts +10 -10
- package/src/api/index.ts +1 -0
- package/src/api/reflex-admin.admin.api.test.ts +52 -0
- package/src/api/reflex-admin.admin.api.ts +53 -0
- package/src/api/route-stats.api.test.ts +45 -45
- package/src/api/route-stats.api.ts +36 -36
- package/src/api/service-completion-webhook.api.test.ts +97 -97
- package/src/api/service-completion-webhook.api.ts +39 -39
- package/src/api/service-configuration.api.ts +16 -16
- package/src/api/service-consumer.api.test.ts +104 -104
- package/src/api/service-consumer.api.ts +90 -90
- package/src/api/service-deployment.api.ts +79 -79
- package/src/api/service-discord-event.api.test.ts +106 -106
- package/src/api/service-discord-event.api.ts +78 -78
- package/src/api/service-discord.api.test.ts +178 -178
- package/src/api/service-discord.api.ts +222 -222
- package/src/api/service-insights.api.test.ts +36 -36
- package/src/api/service-insights.api.ts +42 -42
- package/src/api/service-limits.api.test.ts +100 -100
- package/src/api/service-limits.api.ts +37 -37
- package/src/api/service-openapi.api.test.ts +52 -52
- package/src/api/service-openapi.api.ts +21 -21
- package/src/api/service-route.api.ts +74 -74
- package/src/api/service-task.api.test.ts +140 -140
- package/src/api/service-task.api.ts +141 -141
- package/src/api/service-version.api.ts +54 -54
- package/src/api/service.api.ts +55 -55
- package/src/discord/discord-event-filter-cases.ts +261 -299
- package/src/discord/discord-event-filters.test.ts +91 -120
- package/src/discord/discord-event-filters.ts +95 -103
- package/src/discord/discord-event-intents.test.ts +112 -139
- package/src/discord/discord-event-intents.ts +55 -80
- package/src/discord/index.ts +3 -4
- package/src/index.test.ts +104 -104
- package/src/index.ts +26 -2
- package/src/insights/index.ts +1 -1
- package/src/insights/percentiles.test.ts +75 -75
- package/src/insights/percentiles.ts +37 -37
- package/src/types/enum/access-grant-status.enum.ts +12 -12
- package/src/types/enum/access-kind.enum.ts +7 -7
- package/src/types/enum/access-request-status.enum.ts +11 -11
- package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
- package/src/types/enum/completion-delivery-status.enum.ts +9 -9
- package/src/types/enum/configuration-read-as.enum.ts +5 -5
- package/src/types/enum/discord-activity-type.enum.ts +9 -9
- package/src/types/enum/discord-channel-type.enum.ts +11 -11
- package/src/types/enum/discord-component-kind.enum.ts +7 -7
- package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
- package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
- package/src/types/enum/discord-event-status.enum.ts +13 -13
- package/src/types/enum/discord-event-type.enum.ts +7 -11
- package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
- package/src/types/enum/discord-gateway-state.enum.ts +11 -11
- package/src/types/enum/discord-host-action.enum.ts +37 -37
- package/src/types/enum/discord-locale.enum.ts +35 -35
- package/src/types/enum/discord-option-type.enum.ts +12 -12
- package/src/types/enum/discord-presence-status.enum.ts +8 -8
- package/src/types/enum/discord-sync-status.enum.ts +6 -6
- package/src/types/enum/discord-token-state.enum.ts +11 -11
- package/src/types/enum/execution-mode.enum.ts +9 -9
- package/src/types/enum/execution-profile.enum.ts +20 -20
- package/src/types/enum/execution-settings-source.enum.ts +9 -9
- package/src/types/enum/health-status.enum.ts +4 -4
- package/src/types/enum/index.ts +53 -53
- package/src/types/enum/insights-period.enum.ts +8 -8
- package/src/types/enum/log-cap-mode.enum.ts +6 -6
- package/src/types/enum/log-drop-cause.enum.ts +8 -8
- package/src/types/enum/reflex-abuse-rule.enum.ts +9 -0
- package/src/types/enum/reflex-admin-hold-kind.enum.ts +7 -0
- package/src/types/enum/reflex-error-code.enum.ts +7 -23
- package/src/types/enum/route-method.enum.ts +9 -9
- package/src/types/enum/run-log-level.enum.ts +6 -6
- package/src/types/enum/run-mode.enum.ts +11 -11
- package/src/types/enum/run-status.enum.ts +16 -16
- package/src/types/enum/run-step-status.enum.ts +7 -7
- package/src/types/enum/schedule-sync-status.enum.ts +6 -6
- package/src/types/enum/scheduled-run-failure-code.enum.ts +14 -14
- package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
- package/src/types/enum/scheduled-run-status.enum.ts +17 -17
- package/src/types/enum/service-block-reason.enum.ts +13 -13
- package/src/types/enum/service-deployment-action.enum.ts +11 -11
- package/src/types/enum/service-deployment-status.enum.ts +5 -5
- package/src/types/enum/service-type.enum.ts +9 -9
- package/src/types/enum/service-version-change-kind.enum.ts +6 -6
- package/src/types/enum/trace-effect-type.enum.ts +12 -12
- package/src/types/enum/trigger-access-mode.enum.ts +12 -12
- package/src/types/enum/trigger-kind.enum.ts +8 -8
- package/src/types/enum/vault-value-source.enum.ts +12 -12
- package/src/types/enum/vault-visibility.enum.ts +5 -5
- package/src/types/index.ts +2 -2
- package/src/types/interface/api/index.ts +3 -3
- package/src/types/interface/api/requests/alert-rule.request.ts +53 -53
- package/src/types/interface/api/requests/application-insights.request.ts +18 -18
- package/src/types/interface/api/requests/function-access.request.ts +51 -51
- package/src/types/interface/api/requests/function-run.request.ts +0 -11
- package/src/types/interface/api/requests/function-template.request.ts +29 -29
- package/src/types/interface/api/requests/function-test.request.ts +44 -44
- package/src/types/interface/api/requests/function-version.request.ts +38 -38
- package/src/types/interface/api/requests/function.request.ts +36 -36
- package/src/types/interface/api/requests/index.ts +1 -0
- package/src/types/interface/api/requests/reflex-admin.admin.request.ts +26 -0
- package/src/types/interface/api/requests/route-stats.request.ts +22 -22
- package/src/types/interface/api/requests/service-completion-webhook.request.ts +11 -11
- package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
- package/src/types/interface/api/requests/service-consumer.request.ts +51 -51
- package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
- package/src/types/interface/api/requests/service-discord-event.request.ts +68 -68
- package/src/types/interface/api/requests/service-discord.request.ts +155 -168
- package/src/types/interface/api/requests/service-insights.request.ts +31 -31
- package/src/types/interface/api/requests/service-limits.request.ts +28 -28
- package/src/types/interface/api/requests/service-openapi.request.ts +10 -10
- package/src/types/interface/api/requests/service-route.request.ts +52 -52
- package/src/types/interface/api/requests/service-task.request.ts +80 -80
- package/src/types/interface/api/requests/service-version.request.ts +24 -24
- package/src/types/interface/api/response.ts +4 -4
- package/src/types/interface/api/responses/alert-rule.response.ts +24 -24
- package/src/types/interface/api/responses/application-insights.response.ts +11 -11
- package/src/types/interface/api/responses/application-run-settings.response.ts +8 -8
- package/src/types/interface/api/responses/function-access.response.ts +45 -45
- package/src/types/interface/api/responses/function-run.response.ts +0 -12
- package/src/types/interface/api/responses/function-template.response.ts +21 -21
- package/src/types/interface/api/responses/function-test.response.ts +19 -19
- package/src/types/interface/api/responses/function-version.response.ts +42 -42
- package/src/types/interface/api/responses/function.response.ts +25 -25
- package/src/types/interface/api/responses/index.ts +1 -0
- package/src/types/interface/api/responses/reflex-admin.admin.response.ts +25 -0
- package/src/types/interface/api/responses/route-stats.response.ts +15 -15
- package/src/types/interface/api/responses/service-completion-webhook.response.ts +13 -13
- package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
- package/src/types/interface/api/responses/service-consumer.response.ts +33 -33
- package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
- package/src/types/interface/api/responses/service-discord-event.response.ts +24 -24
- package/src/types/interface/api/responses/service-discord.response.ts +110 -110
- package/src/types/interface/api/responses/service-insights.response.ts +11 -11
- package/src/types/interface/api/responses/service-limits.response.ts +13 -13
- package/src/types/interface/api/responses/service-openapi.response.ts +7 -7
- package/src/types/interface/api/responses/service-route.response.ts +31 -31
- package/src/types/interface/api/responses/service-task.response.ts +57 -57
- package/src/types/interface/api/responses/service-version.response.ts +112 -112
- package/src/types/interface/api/responses/service.response.ts +31 -31
- package/src/types/interface/health.response.ts +7 -7
- package/src/types/interface/index.ts +3 -3
- package/src/types/interface/models/index.ts +1 -0
- package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
- package/src/types/interface/models/reflex-access-request.model.ts +15 -15
- package/src/types/interface/models/reflex-admin-hold.model.ts +55 -0
- package/src/types/interface/models/reflex-alert-rule.model.ts +56 -56
- package/src/types/interface/models/reflex-bot-limits.model.ts +53 -53
- package/src/types/interface/models/reflex-completion-webhook.model.ts +111 -111
- package/src/types/interface/models/reflex-consumer.model.ts +50 -50
- package/src/types/interface/models/reflex-definition.model.ts +31 -31
- package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -58
- package/src/types/interface/models/reflex-discord-event.model.ts +79 -79
- package/src/types/interface/models/reflex-discord.model.ts +208 -249
- package/src/types/interface/models/reflex-execution-settings.model.ts +57 -57
- package/src/types/interface/models/reflex-function-template.model.ts +18 -18
- package/src/types/interface/models/reflex-function-version.model.ts +19 -19
- package/src/types/interface/models/reflex-function.model.ts +30 -30
- package/src/types/interface/models/reflex-insights.model.ts +215 -215
- package/src/types/interface/models/reflex-price-list.model.ts +22 -22
- package/src/types/interface/models/reflex-route-contract.model.ts +46 -46
- package/src/types/interface/models/reflex-route.model.ts +23 -23
- package/src/types/interface/models/reflex-run.model.ts +0 -8
- package/src/types/interface/models/reflex-service-deployment.model.ts +51 -48
- package/src/types/interface/models/reflex-service.model.ts +50 -47
- package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
- package/src/types/interface/models/reflex-task.model.ts +97 -97
- package/tsconfig.check.json +15 -15
- package/tsconfig.json +35 -35
- package/dist/discord/discord-command-tree.d.ts +0 -5
- package/dist/discord/discord-command-tree.js +0 -38
- package/dist/discord/discord-command-tree.js.map +0 -1
- package/dist/types/enum/discord-command-node-type.enum.d.ts +0 -5
- package/dist/types/enum/discord-command-node-type.enum.js +0 -10
- package/dist/types/enum/discord-command-node-type.enum.js.map +0 -1
- package/dist/types/enum/discord-command-type.enum.d.ts +0 -5
- package/dist/types/enum/discord-command-type.enum.js +0 -10
- package/dist/types/enum/discord-command-type.enum.js.map +0 -1
- package/src/discord/discord-command-tree.test.ts +0 -47
- package/src/discord/discord-command-tree.ts +0 -60
- package/src/types/enum/discord-command-node-type.enum.ts +0 -10
- package/src/types/enum/discord-command-type.enum.ts +0 -9
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
import { AbyssReflexCore, ReflexAlertMetric, ReflexAlertScope } 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
|
-
const APP = { applicationId: 'app-1' };
|
|
20
|
-
|
|
21
|
-
describe('AbyssReflexCore alert rule routes', () => {
|
|
22
|
-
it('alertRule.list calls GET .../alert-rule, filtered by environment when given', async () => {
|
|
23
|
-
await AbyssReflexCore.sdk.application.alertRule.list(APP, { environmentId: 'e-1' });
|
|
24
|
-
|
|
25
|
-
const config = adapter.mock.calls[0][0];
|
|
26
|
-
expect(config.method).toBe('get');
|
|
27
|
-
expect(config.url).toBe('api/application/app-1/alert-rule');
|
|
28
|
-
expect(config.params).toEqual({ environmentId: 'e-1' });
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('alertRule.list works without a query', async () => {
|
|
32
|
-
await AbyssReflexCore.sdk.application.alertRule.list(APP);
|
|
33
|
-
|
|
34
|
-
expect(adapter.mock.calls[0][0].params).toEqual({});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('alertRule.create calls POST .../alert-rule with the rule', async () => {
|
|
38
|
-
const body = {
|
|
39
|
-
environmentId: 'e-1',
|
|
40
|
-
scope: ReflexAlertScope.SERVICE,
|
|
41
|
-
serviceId: 'svc-1',
|
|
42
|
-
metric: ReflexAlertMetric.ERROR_RATE,
|
|
43
|
-
threshold: 5,
|
|
44
|
-
windowMinutes: 15,
|
|
45
|
-
name: 'Errors',
|
|
46
|
-
};
|
|
47
|
-
await AbyssReflexCore.sdk.application.alertRule.create(APP, body);
|
|
48
|
-
|
|
49
|
-
const config = adapter.mock.calls[0][0];
|
|
50
|
-
expect(config.method).toBe('post');
|
|
51
|
-
expect(config.url).toBe('api/application/app-1/alert-rule');
|
|
52
|
-
expect(JSON.parse(config.data)).toEqual(body);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('alertRule.update calls PUT .../alert-rule/:ruleId with the editable values', async () => {
|
|
56
|
-
const body = { threshold: 10, windowMinutes: 30, minRuns: 20, enabled: false, name: 'Errors' };
|
|
57
|
-
await AbyssReflexCore.sdk.application.alertRule.update({ ...APP, ruleId: 'rule-1' }, body);
|
|
58
|
-
|
|
59
|
-
const config = adapter.mock.calls[0][0];
|
|
60
|
-
expect(config.method).toBe('put');
|
|
61
|
-
expect(config.url).toBe('api/application/app-1/alert-rule/rule-1');
|
|
62
|
-
expect(JSON.parse(config.data)).toEqual(body);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('alertRule.delete calls DELETE .../alert-rule/:ruleId', async () => {
|
|
66
|
-
await AbyssReflexCore.sdk.application.alertRule.delete({ ...APP, ruleId: 'rule-1' });
|
|
67
|
-
|
|
68
|
-
const config = adapter.mock.calls[0][0];
|
|
69
|
-
expect(config.method).toBe('delete');
|
|
70
|
-
expect(config.url).toBe('api/application/app-1/alert-rule/rule-1');
|
|
71
|
-
});
|
|
72
|
-
});
|
|
1
|
+
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
+
import { AbyssReflexCore, ReflexAlertMetric, ReflexAlertScope } 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
|
+
const APP = { applicationId: 'app-1' };
|
|
20
|
+
|
|
21
|
+
describe('AbyssReflexCore alert rule routes', () => {
|
|
22
|
+
it('alertRule.list calls GET .../alert-rule, filtered by environment when given', async () => {
|
|
23
|
+
await AbyssReflexCore.sdk.application.alertRule.list(APP, { environmentId: 'e-1' });
|
|
24
|
+
|
|
25
|
+
const config = adapter.mock.calls[0][0];
|
|
26
|
+
expect(config.method).toBe('get');
|
|
27
|
+
expect(config.url).toBe('api/application/app-1/alert-rule');
|
|
28
|
+
expect(config.params).toEqual({ environmentId: 'e-1' });
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('alertRule.list works without a query', async () => {
|
|
32
|
+
await AbyssReflexCore.sdk.application.alertRule.list(APP);
|
|
33
|
+
|
|
34
|
+
expect(adapter.mock.calls[0][0].params).toEqual({});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('alertRule.create calls POST .../alert-rule with the rule', async () => {
|
|
38
|
+
const body = {
|
|
39
|
+
environmentId: 'e-1',
|
|
40
|
+
scope: ReflexAlertScope.SERVICE,
|
|
41
|
+
serviceId: 'svc-1',
|
|
42
|
+
metric: ReflexAlertMetric.ERROR_RATE,
|
|
43
|
+
threshold: 5,
|
|
44
|
+
windowMinutes: 15,
|
|
45
|
+
name: 'Errors',
|
|
46
|
+
};
|
|
47
|
+
await AbyssReflexCore.sdk.application.alertRule.create(APP, body);
|
|
48
|
+
|
|
49
|
+
const config = adapter.mock.calls[0][0];
|
|
50
|
+
expect(config.method).toBe('post');
|
|
51
|
+
expect(config.url).toBe('api/application/app-1/alert-rule');
|
|
52
|
+
expect(JSON.parse(config.data)).toEqual(body);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('alertRule.update calls PUT .../alert-rule/:ruleId with the editable values', async () => {
|
|
56
|
+
const body = { threshold: 10, windowMinutes: 30, minRuns: 20, enabled: false, name: 'Errors' };
|
|
57
|
+
await AbyssReflexCore.sdk.application.alertRule.update({ ...APP, ruleId: 'rule-1' }, body);
|
|
58
|
+
|
|
59
|
+
const config = adapter.mock.calls[0][0];
|
|
60
|
+
expect(config.method).toBe('put');
|
|
61
|
+
expect(config.url).toBe('api/application/app-1/alert-rule/rule-1');
|
|
62
|
+
expect(JSON.parse(config.data)).toEqual(body);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('alertRule.delete calls DELETE .../alert-rule/:ruleId', async () => {
|
|
66
|
+
await AbyssReflexCore.sdk.application.alertRule.delete({ ...APP, ruleId: 'rule-1' });
|
|
67
|
+
|
|
68
|
+
const config = adapter.mock.calls[0][0];
|
|
69
|
+
expect(config.method).toBe('delete');
|
|
70
|
+
expect(config.url).toBe('api/application/app-1/alert-rule/rule-1');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { AbyssReflexCore } from '..';
|
|
2
|
-
import type {
|
|
3
|
-
ICreateAlertRuleBody,
|
|
4
|
-
ICreateAlertRuleParams,
|
|
5
|
-
ICreateAlertRuleResponse,
|
|
6
|
-
IDeleteAlertRuleParams,
|
|
7
|
-
IDeleteAlertRuleResponse,
|
|
8
|
-
IListAlertRuleParams,
|
|
9
|
-
IListAlertRuleQuery,
|
|
10
|
-
IListAlertRuleResponse,
|
|
11
|
-
IUpdateAlertRuleBody,
|
|
12
|
-
IUpdateAlertRuleParams,
|
|
13
|
-
IUpdateAlertRuleResponse,
|
|
14
|
-
} from '../types';
|
|
15
|
-
|
|
16
|
-
const alertRuleUrl = (params: { applicationId: string }): string =>
|
|
17
|
-
`api/application/${params.applicationId}/alert-rule`;
|
|
18
|
-
|
|
19
|
-
/** `GET .../alert-rule`: the rules of the application and the state of their last evaluation. Needs REFLEX_READ. */
|
|
20
|
-
export const listAlertRule = async (
|
|
21
|
-
params: IListAlertRuleParams,
|
|
22
|
-
query: IListAlertRuleQuery = {},
|
|
23
|
-
): Promise<IListAlertRuleResponse> =>
|
|
24
|
-
(
|
|
25
|
-
await AbyssReflexCore.axios.get<IListAlertRuleResponse>(alertRuleUrl(params), {
|
|
26
|
-
params: query,
|
|
27
|
-
})
|
|
28
|
-
).data;
|
|
29
|
-
|
|
30
|
-
/** `POST .../alert-rule`: creates a rule. Needs REFLEX_FUNCTION_UPDATE. */
|
|
31
|
-
export const createAlertRule = async (
|
|
32
|
-
params: ICreateAlertRuleParams,
|
|
33
|
-
body: ICreateAlertRuleBody,
|
|
34
|
-
): Promise<ICreateAlertRuleResponse> =>
|
|
35
|
-
(await AbyssReflexCore.axios.post<ICreateAlertRuleResponse>(alertRuleUrl(params), body)).data;
|
|
36
|
-
|
|
37
|
-
/** `PUT .../alert-rule/:ruleId`: changes the threshold, window, minimum of runs, name and switch of a rule. Needs REFLEX_FUNCTION_UPDATE. */
|
|
38
|
-
export const updateAlertRule = async (
|
|
39
|
-
params: IUpdateAlertRuleParams,
|
|
40
|
-
body: IUpdateAlertRuleBody,
|
|
41
|
-
): Promise<IUpdateAlertRuleResponse> =>
|
|
42
|
-
(
|
|
43
|
-
await AbyssReflexCore.axios.put<IUpdateAlertRuleResponse>(
|
|
44
|
-
`${alertRuleUrl(params)}/${params.ruleId}`,
|
|
45
|
-
body,
|
|
46
|
-
)
|
|
47
|
-
).data;
|
|
48
|
-
|
|
49
|
-
/** `DELETE .../alert-rule/:ruleId`: deletes a rule and its state. Needs REFLEX_FUNCTION_UPDATE. */
|
|
50
|
-
export const deleteAlertRule = async (
|
|
51
|
-
params: IDeleteAlertRuleParams,
|
|
52
|
-
): Promise<IDeleteAlertRuleResponse> =>
|
|
53
|
-
(
|
|
54
|
-
await AbyssReflexCore.axios.delete<IDeleteAlertRuleResponse>(
|
|
55
|
-
`${alertRuleUrl(params)}/${params.ruleId}`,
|
|
56
|
-
)
|
|
57
|
-
).data;
|
|
1
|
+
import { AbyssReflexCore } from '..';
|
|
2
|
+
import type {
|
|
3
|
+
ICreateAlertRuleBody,
|
|
4
|
+
ICreateAlertRuleParams,
|
|
5
|
+
ICreateAlertRuleResponse,
|
|
6
|
+
IDeleteAlertRuleParams,
|
|
7
|
+
IDeleteAlertRuleResponse,
|
|
8
|
+
IListAlertRuleParams,
|
|
9
|
+
IListAlertRuleQuery,
|
|
10
|
+
IListAlertRuleResponse,
|
|
11
|
+
IUpdateAlertRuleBody,
|
|
12
|
+
IUpdateAlertRuleParams,
|
|
13
|
+
IUpdateAlertRuleResponse,
|
|
14
|
+
} from '../types';
|
|
15
|
+
|
|
16
|
+
const alertRuleUrl = (params: { applicationId: string }): string =>
|
|
17
|
+
`api/application/${params.applicationId}/alert-rule`;
|
|
18
|
+
|
|
19
|
+
/** `GET .../alert-rule`: the rules of the application and the state of their last evaluation. Needs REFLEX_READ. */
|
|
20
|
+
export const listAlertRule = async (
|
|
21
|
+
params: IListAlertRuleParams,
|
|
22
|
+
query: IListAlertRuleQuery = {},
|
|
23
|
+
): Promise<IListAlertRuleResponse> =>
|
|
24
|
+
(
|
|
25
|
+
await AbyssReflexCore.axios.get<IListAlertRuleResponse>(alertRuleUrl(params), {
|
|
26
|
+
params: query,
|
|
27
|
+
})
|
|
28
|
+
).data;
|
|
29
|
+
|
|
30
|
+
/** `POST .../alert-rule`: creates a rule. Needs REFLEX_FUNCTION_UPDATE. */
|
|
31
|
+
export const createAlertRule = async (
|
|
32
|
+
params: ICreateAlertRuleParams,
|
|
33
|
+
body: ICreateAlertRuleBody,
|
|
34
|
+
): Promise<ICreateAlertRuleResponse> =>
|
|
35
|
+
(await AbyssReflexCore.axios.post<ICreateAlertRuleResponse>(alertRuleUrl(params), body)).data;
|
|
36
|
+
|
|
37
|
+
/** `PUT .../alert-rule/:ruleId`: changes the threshold, window, minimum of runs, name and switch of a rule. Needs REFLEX_FUNCTION_UPDATE. */
|
|
38
|
+
export const updateAlertRule = async (
|
|
39
|
+
params: IUpdateAlertRuleParams,
|
|
40
|
+
body: IUpdateAlertRuleBody,
|
|
41
|
+
): Promise<IUpdateAlertRuleResponse> =>
|
|
42
|
+
(
|
|
43
|
+
await AbyssReflexCore.axios.put<IUpdateAlertRuleResponse>(
|
|
44
|
+
`${alertRuleUrl(params)}/${params.ruleId}`,
|
|
45
|
+
body,
|
|
46
|
+
)
|
|
47
|
+
).data;
|
|
48
|
+
|
|
49
|
+
/** `DELETE .../alert-rule/:ruleId`: deletes a rule and its state. Needs REFLEX_FUNCTION_UPDATE. */
|
|
50
|
+
export const deleteAlertRule = async (
|
|
51
|
+
params: IDeleteAlertRuleParams,
|
|
52
|
+
): Promise<IDeleteAlertRuleResponse> =>
|
|
53
|
+
(
|
|
54
|
+
await AbyssReflexCore.axios.delete<IDeleteAlertRuleResponse>(
|
|
55
|
+
`${alertRuleUrl(params)}/${params.ruleId}`,
|
|
56
|
+
)
|
|
57
|
+
).data;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
import { AbyssReflexCore, InsightsPeriod } 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
|
-
const QUERY = { environmentId: 'e-1', period: InsightsPeriod.DAYS_7 };
|
|
20
|
-
|
|
21
|
-
describe('AbyssReflexCore application insights routes', () => {
|
|
22
|
-
it('insights.get calls GET .../insights with the environment and the period', async () => {
|
|
23
|
-
await AbyssReflexCore.sdk.application.insights.get({ applicationId: 'app-1' }, QUERY);
|
|
24
|
-
|
|
25
|
-
const config = adapter.mock.calls[0][0];
|
|
26
|
-
expect(config.method).toBe('get');
|
|
27
|
-
expect(config.url).toBe('api/application/app-1/insights');
|
|
28
|
-
expect(config.params).toEqual({ environmentId: 'e-1', period: '7d' });
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('insights.calendar calls GET .../insights/calendar with the environment only', async () => {
|
|
32
|
-
await AbyssReflexCore.sdk.application.insights.calendar(
|
|
33
|
-
{ applicationId: 'app-1' },
|
|
34
|
-
{ environmentId: 'e-1' },
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const config = adapter.mock.calls[0][0];
|
|
38
|
-
expect(config.method).toBe('get');
|
|
39
|
-
expect(config.url).toBe('api/application/app-1/insights/calendar');
|
|
40
|
-
expect(config.params).toEqual({ environmentId: 'e-1' });
|
|
41
|
-
});
|
|
42
|
-
});
|
|
1
|
+
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
+
import { AbyssReflexCore, InsightsPeriod } 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
|
+
const QUERY = { environmentId: 'e-1', period: InsightsPeriod.DAYS_7 };
|
|
20
|
+
|
|
21
|
+
describe('AbyssReflexCore application insights routes', () => {
|
|
22
|
+
it('insights.get calls GET .../insights with the environment and the period', async () => {
|
|
23
|
+
await AbyssReflexCore.sdk.application.insights.get({ applicationId: 'app-1' }, QUERY);
|
|
24
|
+
|
|
25
|
+
const config = adapter.mock.calls[0][0];
|
|
26
|
+
expect(config.method).toBe('get');
|
|
27
|
+
expect(config.url).toBe('api/application/app-1/insights');
|
|
28
|
+
expect(config.params).toEqual({ environmentId: 'e-1', period: '7d' });
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('insights.calendar calls GET .../insights/calendar with the environment only', async () => {
|
|
32
|
+
await AbyssReflexCore.sdk.application.insights.calendar(
|
|
33
|
+
{ applicationId: 'app-1' },
|
|
34
|
+
{ environmentId: 'e-1' },
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const config = adapter.mock.calls[0][0];
|
|
38
|
+
expect(config.method).toBe('get');
|
|
39
|
+
expect(config.url).toBe('api/application/app-1/insights/calendar');
|
|
40
|
+
expect(config.params).toEqual({ environmentId: 'e-1' });
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -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,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;
|