@abyss-project/reflex 6.0.5 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +32 -32
- package/.prettierrc +5 -5
- package/README.md +15 -15
- package/dist/api/function-run.api.d.ts +2 -1
- package/dist/api/function-run.api.js +3 -1
- package/dist/api/function-run.api.js.map +1 -1
- package/dist/api/function-settings.api.d.ts +3 -1
- package/dist/api/function-settings.api.js +7 -1
- package/dist/api/function-settings.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/storage-surplus.admin.api.d.ts +5 -0
- package/dist/api/storage-surplus.admin.api.js +17 -0
- package/dist/api/storage-surplus.admin.api.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +19 -1
- package/dist/index.js.map +1 -1
- package/dist/types/enum/reflex-error-code.enum.d.ts +4 -1
- package/dist/types/enum/reflex-error-code.enum.js +3 -0
- package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
- package/dist/types/interface/api/requests/application-run-settings.request.d.ts +1 -0
- package/dist/types/interface/api/requests/function-run.request.d.ts +8 -0
- package/dist/types/interface/api/requests/function-settings.request.d.ts +12 -0
- 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/service.request.d.ts +1 -0
- package/dist/types/interface/api/requests/storage-surplus.admin.request.d.ts +8 -0
- package/dist/types/interface/api/requests/storage-surplus.admin.request.js +3 -0
- package/dist/types/interface/api/requests/storage-surplus.admin.request.js.map +1 -0
- package/dist/types/interface/api/responses/function-run.response.d.ts +4 -0
- package/dist/types/interface/api/responses/function-settings.response.d.ts +5 -1
- 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/storage-surplus.admin.response.d.ts +8 -0
- package/dist/types/interface/api/responses/storage-surplus.admin.response.js +3 -0
- package/dist/types/interface/api/responses/storage-surplus.admin.response.js.map +1 -0
- package/dist/types/interface/models/index.d.ts +2 -0
- package/dist/types/interface/models/index.js +2 -0
- package/dist/types/interface/models/index.js.map +1 -1
- package/dist/types/interface/models/reflex-run-retention.model.d.ts +13 -0
- package/dist/types/interface/models/reflex-run-retention.model.js +8 -0
- package/dist/types/interface/models/reflex-run-retention.model.js.map +1 -0
- package/dist/types/interface/models/reflex-run-settings.model.d.ts +4 -0
- package/dist/types/interface/models/reflex-run.model.d.ts +5 -0
- package/dist/types/interface/models/reflex-service-deployment.model.d.ts +2 -2
- package/dist/types/interface/models/reflex-service.model.d.ts +1 -0
- package/dist/types/interface/models/reflex-storage-surplus.model.d.ts +11 -0
- package/dist/types/interface/models/reflex-storage-surplus.model.js +3 -0
- package/dist/types/interface/models/reflex-storage-surplus.model.js.map +1 -0
- package/jest.config.ts +11 -11
- package/package.json +10 -15
- 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.test.ts +11 -0
- 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 +15 -0
- package/src/api/function-settings.api.ts +22 -0
- 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.test.ts +55 -0
- package/src/api/function.api.ts +62 -62
- package/src/api/health.api.ts +10 -10
- package/src/api/index.ts +27 -26
- 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.test.ts +6 -1
- package/src/api/service.api.ts +55 -55
- package/src/api/storage-surplus.admin.api.test.ts +66 -0
- package/src/api/storage-surplus.admin.api.ts +45 -0
- package/src/discord/discord-event-filter-cases.ts +261 -261
- package/src/discord/discord-event-filters.test.ts +91 -91
- package/src/discord/discord-event-filters.ts +95 -95
- package/src/discord/discord-event-intents.test.ts +112 -112
- package/src/discord/discord-event-intents.ts +55 -55
- package/src/discord/index.ts +3 -3
- package/src/index.test.ts +104 -104
- package/src/index.ts +42 -0
- 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/reflex-error-code.enum.ts +16 -0
- package/src/types/interface/api/requests/application-run-settings.request.ts +2 -0
- package/src/types/interface/api/requests/function-run.request.ts +10 -0
- package/src/types/interface/api/requests/function-settings.request.ts +16 -0
- package/src/types/interface/api/requests/index.ts +1 -0
- package/src/types/interface/api/requests/service.request.ts +2 -0
- package/src/types/interface/api/requests/storage-surplus.admin.request.ts +12 -0
- package/src/types/interface/api/responses/function-run.response.ts +5 -0
- package/src/types/interface/api/responses/function-settings.response.ts +7 -0
- package/src/types/interface/api/responses/index.ts +1 -0
- package/src/types/interface/api/responses/storage-surplus.admin.response.ts +10 -0
- package/src/types/interface/models/index.ts +2 -0
- package/src/types/interface/models/reflex-run-retention.model.ts +24 -0
- package/src/types/interface/models/reflex-run-settings.model.ts +11 -0
- package/src/types/interface/models/reflex-run.model.ts +10 -0
- package/src/types/interface/models/reflex-service-deployment.model.ts +4 -2
- package/src/types/interface/models/reflex-service.model.ts +2 -0
- package/src/types/interface/models/reflex-storage-surplus.model.ts +23 -0
- package/tsconfig.check.json +15 -15
- package/tsconfig.json +35 -35
|
@@ -11,6 +11,10 @@ export interface IReflexApplicationRunSettings {
|
|
|
11
11
|
applicationId: string;
|
|
12
12
|
maxLogLinesPerRun: number | null;
|
|
13
13
|
retentionDays: number | null;
|
|
14
|
+
runRetentionDays: number | null;
|
|
15
|
+
historyMinimal: boolean;
|
|
16
|
+
storedBytesOnline: number;
|
|
17
|
+
storedBytesArchive: number;
|
|
14
18
|
monitorActivated: boolean;
|
|
15
19
|
}
|
|
16
20
|
export interface IReflexFunctionLogCap {
|
|
@@ -97,6 +97,11 @@ export interface IReflexRun {
|
|
|
97
97
|
delivery?: IReflexCompletionDelivery;
|
|
98
98
|
createdByUserId: string | null;
|
|
99
99
|
createdAt: Date;
|
|
100
|
+
expiresAt: string | null;
|
|
101
|
+
isFavorite: boolean;
|
|
102
|
+
historyMinimal: boolean;
|
|
103
|
+
storedBytes: number | null;
|
|
104
|
+
detailArchivedAt: string | null;
|
|
100
105
|
}
|
|
101
106
|
export interface IReflexRunConsumer {
|
|
102
107
|
id: string;
|
|
@@ -9,8 +9,8 @@ export interface IReflexServiceDeployment {
|
|
|
9
9
|
serviceId: string;
|
|
10
10
|
environmentId: string;
|
|
11
11
|
environmentSlug: string;
|
|
12
|
-
serviceVersionId: string;
|
|
13
|
-
serviceVersionNumber: number;
|
|
12
|
+
serviceVersionId: string | null;
|
|
13
|
+
serviceVersionNumber: number | null;
|
|
14
14
|
action: ServiceDeploymentAction;
|
|
15
15
|
status: ServiceDeploymentStatus;
|
|
16
16
|
grants: IReflexServiceDeploymentGrant[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface IReflexStorageSurplusOwner {
|
|
2
|
+
organizationId?: string | null;
|
|
3
|
+
userId?: string | null;
|
|
4
|
+
}
|
|
5
|
+
export interface IReflexStorageSurplusItem {
|
|
6
|
+
id: string;
|
|
7
|
+
sizeBytes: number;
|
|
8
|
+
createdAt: Date | string;
|
|
9
|
+
isFavorite: boolean;
|
|
10
|
+
label: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflex-storage-surplus.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/reflex-storage-surplus.model.ts"],"names":[],"mappings":""}
|
package/jest.config.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Config } from '@jest/types';
|
|
2
|
-
|
|
3
|
-
const config: Config.InitialOptions = {
|
|
4
|
-
testEnvironment: 'node',
|
|
5
|
-
transform: {
|
|
6
|
-
'^.+\\.tsx?$': ['ts-jest', { isolatedModules: true }],
|
|
7
|
-
},
|
|
8
|
-
modulePathIgnorePatterns: ['dist'],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default config;
|
|
1
|
+
import type { Config } from '@jest/types';
|
|
2
|
+
|
|
3
|
+
const config: Config.InitialOptions = {
|
|
4
|
+
testEnvironment: 'node',
|
|
5
|
+
transform: {
|
|
6
|
+
'^.+\\.tsx?$': ['ts-jest', { isolatedModules: true }],
|
|
7
|
+
},
|
|
8
|
+
modulePathIgnorePatterns: ['dist'],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default config;
|
package/package.json
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abyss-project/reflex",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Core package to interact with AbyssReflex",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"main": "dist/index.js",
|
|
9
|
-
"types": "dist/index.d.ts"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"lint": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --fix",
|
|
13
|
-
"lint:check": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --max-warnings 0",
|
|
14
|
-
"tsc": "tsc",
|
|
15
|
-
"build": "tsc",
|
|
16
|
-
"test": "jest",
|
|
17
|
-
"prepublishOnly": "tsc && node ../../scripts/check-sdk-surface.cjs",
|
|
18
|
-
"dev": "tsc --watch"
|
|
19
|
-
},
|
|
20
7
|
"repository": {
|
|
21
8
|
"type": "git",
|
|
22
9
|
"url": "https://gitlab.com/abyss-group/abyss-reflex.git"
|
|
@@ -45,5 +32,13 @@
|
|
|
45
32
|
"ts-jest": "^29.1.0",
|
|
46
33
|
"ts-node": "^10.4.0",
|
|
47
34
|
"typescript": "5.9.3"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"lint": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --fix",
|
|
38
|
+
"lint:check": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --max-warnings 0",
|
|
39
|
+
"tsc": "tsc",
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"test": "jest",
|
|
42
|
+
"dev": "tsc --watch"
|
|
48
43
|
}
|
|
49
|
-
}
|
|
44
|
+
}
|
|
@@ -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;
|
|
@@ -37,6 +37,17 @@ describe('AbyssReflexCore application run settings routes', () => {
|
|
|
37
37
|
expect(JSON.parse(config.data)).toEqual({ maxLogLinesPerRun: 500 });
|
|
38
38
|
});
|
|
39
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
|
+
|
|
40
51
|
it('logCap.set calls PUT .../log-cap of the function', async () => {
|
|
41
52
|
await AbyssReflexCore.sdk.function.logCap.set(
|
|
42
53
|
{ applicationId: 'app-1', functionId: 'fn-1' },
|
|
@@ -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;
|