@abyss-project/reflex 6.3.0 → 6.4.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/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 +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.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/discord-host-action.enum.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-discord.request.ts +155 -155
- 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-discord.model.ts +208 -208
- package/src/types/interface/models/reflex-price-list.model.ts +22 -22
- 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
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
import {
|
|
3
|
-
AbyssReflexCore,
|
|
4
|
-
COMPLETION_DELIVERY_ID_HEADER,
|
|
5
|
-
CompletionDeliveryStatus,
|
|
6
|
-
DEFAULT_REFLEX_EXECUTION_SETTINGS,
|
|
7
|
-
REFLEX_COMPLETION_DELIVERY_ERRORS,
|
|
8
|
-
REFLEX_COMPLETION_WEBHOOK_LIMITS,
|
|
9
|
-
RESERVED_EXECUTIONS_SEGMENT,
|
|
10
|
-
RunStatus,
|
|
11
|
-
} from '..';
|
|
12
|
-
|
|
13
|
-
const APP = 'app-1';
|
|
14
|
-
const SVC = 'svc-1';
|
|
15
|
-
const BASE = `api/service/${APP}/${SVC}`;
|
|
16
|
-
const SERVICE = { applicationId: APP, serviceId: SVC };
|
|
17
|
-
|
|
18
|
-
interface Call {
|
|
19
|
-
label: string;
|
|
20
|
-
method: string;
|
|
21
|
-
url: string;
|
|
22
|
-
body?: unknown;
|
|
23
|
-
run: () => Promise<unknown>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const webhook = () => AbyssReflexCore.sdk.service.completionWebhook;
|
|
27
|
-
|
|
28
|
-
const calls: Call[] = [
|
|
29
|
-
{
|
|
30
|
-
label: 'get',
|
|
31
|
-
method: 'get',
|
|
32
|
-
url: `${BASE}/completion-webhook`,
|
|
33
|
-
run: () => webhook().get(SERVICE),
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
label: 'rotateSecret',
|
|
37
|
-
method: 'post',
|
|
38
|
-
url: `${BASE}/completion-webhook/e-1/secret`,
|
|
39
|
-
body: {},
|
|
40
|
-
run: () => webhook().rotateSecret({ ...SERVICE, environmentId: 'e-1' }),
|
|
41
|
-
},
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
describe('AbyssReflexCore completion webhook routes', () => {
|
|
45
|
-
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
46
|
-
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
beforeAll(() => {
|
|
50
|
-
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
51
|
-
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
beforeEach(() => adapter.mockClear());
|
|
55
|
-
|
|
56
|
-
it.each(calls)('$label calls $method $url', async (call) => {
|
|
57
|
-
await call.run();
|
|
58
|
-
|
|
59
|
-
const config = adapter.mock.calls[0][0];
|
|
60
|
-
expect(config.method).toBe(call.method);
|
|
61
|
-
expect(config.url).toBe(call.url);
|
|
62
|
-
expect(config.baseURL).toBe('http://reflex.test/');
|
|
63
|
-
if (call.body !== undefined) {
|
|
64
|
-
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('exposes no route twice', () => {
|
|
69
|
-
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('carries the bounds and the names of the completion webhook', () => {
|
|
73
|
-
expect(REFLEX_COMPLETION_WEBHOOK_LIMITS).toEqual({
|
|
74
|
-
urlMaxLength: 2048,
|
|
75
|
-
retryDelaysMinutes: [1, 5, 15, 30, 60],
|
|
76
|
-
sendTimeoutMs: 10_000,
|
|
77
|
-
outputMaxBytes: 65_536,
|
|
78
|
-
});
|
|
79
|
-
expect(COMPLETION_DELIVERY_ID_HEADER).toBe('x-abyss-delivery-id');
|
|
80
|
-
expect(REFLEX_COMPLETION_DELIVERY_ERRORS).toEqual({
|
|
81
|
-
refusedAddress: 'The URL is not https, or reaches an address the edge may not reach',
|
|
82
|
-
noSigningSecret: 'No signing secret for the Service in the environment',
|
|
83
|
-
invalidUrl: 'The URL is not valid',
|
|
84
|
-
receiverTimeoutPrefix: 'The receiver did not answer within',
|
|
85
|
-
requestFailedPrefix: 'The request failed',
|
|
86
|
-
httpPrefix: 'HTTP',
|
|
87
|
-
redirectsNotFollowed: 'redirects are not followed',
|
|
88
|
-
});
|
|
89
|
-
expect(RESERVED_EXECUTIONS_SEGMENT).toBe('_executions');
|
|
90
|
-
expect(Object.values(CompletionDeliveryStatus)).toEqual(['PENDING', 'DELIVERED', 'FAILED']);
|
|
91
|
-
expect(RunStatus.REFUSED).toBe('REFUSED');
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('sets no completion webhook by default', () => {
|
|
95
|
-
expect(DEFAULT_REFLEX_EXECUTION_SETTINGS.completionWebhookUrl).toBeNull();
|
|
96
|
-
});
|
|
97
|
-
});
|
|
1
|
+
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
+
import {
|
|
3
|
+
AbyssReflexCore,
|
|
4
|
+
COMPLETION_DELIVERY_ID_HEADER,
|
|
5
|
+
CompletionDeliveryStatus,
|
|
6
|
+
DEFAULT_REFLEX_EXECUTION_SETTINGS,
|
|
7
|
+
REFLEX_COMPLETION_DELIVERY_ERRORS,
|
|
8
|
+
REFLEX_COMPLETION_WEBHOOK_LIMITS,
|
|
9
|
+
RESERVED_EXECUTIONS_SEGMENT,
|
|
10
|
+
RunStatus,
|
|
11
|
+
} from '..';
|
|
12
|
+
|
|
13
|
+
const APP = 'app-1';
|
|
14
|
+
const SVC = 'svc-1';
|
|
15
|
+
const BASE = `api/service/${APP}/${SVC}`;
|
|
16
|
+
const SERVICE = { applicationId: APP, serviceId: SVC };
|
|
17
|
+
|
|
18
|
+
interface Call {
|
|
19
|
+
label: string;
|
|
20
|
+
method: string;
|
|
21
|
+
url: string;
|
|
22
|
+
body?: unknown;
|
|
23
|
+
run: () => Promise<unknown>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const webhook = () => AbyssReflexCore.sdk.service.completionWebhook;
|
|
27
|
+
|
|
28
|
+
const calls: Call[] = [
|
|
29
|
+
{
|
|
30
|
+
label: 'get',
|
|
31
|
+
method: 'get',
|
|
32
|
+
url: `${BASE}/completion-webhook`,
|
|
33
|
+
run: () => webhook().get(SERVICE),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: 'rotateSecret',
|
|
37
|
+
method: 'post',
|
|
38
|
+
url: `${BASE}/completion-webhook/e-1/secret`,
|
|
39
|
+
body: {},
|
|
40
|
+
run: () => webhook().rotateSecret({ ...SERVICE, environmentId: 'e-1' }),
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
describe('AbyssReflexCore completion webhook routes', () => {
|
|
45
|
+
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
46
|
+
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
beforeAll(() => {
|
|
50
|
+
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
51
|
+
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
beforeEach(() => adapter.mockClear());
|
|
55
|
+
|
|
56
|
+
it.each(calls)('$label calls $method $url', async (call) => {
|
|
57
|
+
await call.run();
|
|
58
|
+
|
|
59
|
+
const config = adapter.mock.calls[0][0];
|
|
60
|
+
expect(config.method).toBe(call.method);
|
|
61
|
+
expect(config.url).toBe(call.url);
|
|
62
|
+
expect(config.baseURL).toBe('http://reflex.test/');
|
|
63
|
+
if (call.body !== undefined) {
|
|
64
|
+
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('exposes no route twice', () => {
|
|
69
|
+
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('carries the bounds and the names of the completion webhook', () => {
|
|
73
|
+
expect(REFLEX_COMPLETION_WEBHOOK_LIMITS).toEqual({
|
|
74
|
+
urlMaxLength: 2048,
|
|
75
|
+
retryDelaysMinutes: [1, 5, 15, 30, 60],
|
|
76
|
+
sendTimeoutMs: 10_000,
|
|
77
|
+
outputMaxBytes: 65_536,
|
|
78
|
+
});
|
|
79
|
+
expect(COMPLETION_DELIVERY_ID_HEADER).toBe('x-abyss-delivery-id');
|
|
80
|
+
expect(REFLEX_COMPLETION_DELIVERY_ERRORS).toEqual({
|
|
81
|
+
refusedAddress: 'The URL is not https, or reaches an address the edge may not reach',
|
|
82
|
+
noSigningSecret: 'No signing secret for the Service in the environment',
|
|
83
|
+
invalidUrl: 'The URL is not valid',
|
|
84
|
+
receiverTimeoutPrefix: 'The receiver did not answer within',
|
|
85
|
+
requestFailedPrefix: 'The request failed',
|
|
86
|
+
httpPrefix: 'HTTP',
|
|
87
|
+
redirectsNotFollowed: 'redirects are not followed',
|
|
88
|
+
});
|
|
89
|
+
expect(RESERVED_EXECUTIONS_SEGMENT).toBe('_executions');
|
|
90
|
+
expect(Object.values(CompletionDeliveryStatus)).toEqual(['PENDING', 'DELIVERED', 'FAILED']);
|
|
91
|
+
expect(RunStatus.REFUSED).toBe('REFUSED');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('sets no completion webhook by default', () => {
|
|
95
|
+
expect(DEFAULT_REFLEX_EXECUTION_SETTINGS.completionWebhookUrl).toBeNull();
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { AbyssReflexCore } from '..';
|
|
2
|
-
import type {
|
|
3
|
-
IGetServiceCompletionWebhookParams,
|
|
4
|
-
IGetServiceCompletionWebhookResponse,
|
|
5
|
-
IRotateServiceCompletionWebhookSecretParams,
|
|
6
|
-
IRotateServiceCompletionWebhookSecretResponse,
|
|
7
|
-
} from '../types';
|
|
8
|
-
|
|
9
|
-
const completionWebhookUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
10
|
-
`api/service/${params.applicationId}/${params.serviceId}/completion-webhook`;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* `GET .../completion-webhook`: the environments where the completion webhook of the Service has a signing
|
|
14
|
-
* secret, never the secret itself. Needs REFLEX_READ.
|
|
15
|
-
*/
|
|
16
|
-
export const getServiceCompletionWebhook = async (
|
|
17
|
-
params: IGetServiceCompletionWebhookParams,
|
|
18
|
-
): Promise<IGetServiceCompletionWebhookResponse> =>
|
|
19
|
-
(
|
|
20
|
-
await AbyssReflexCore.axios.get<IGetServiceCompletionWebhookResponse>(
|
|
21
|
-
completionWebhookUrl(params),
|
|
22
|
-
)
|
|
23
|
-
).data;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* `POST .../completion-webhook/:environmentId/secret`: creates or renews the signing secret of the completion webhook
|
|
27
|
-
* in the environment, in clear ONCE; the next deliveries are signed with it. Needs REFLEX_PUBLISH, and
|
|
28
|
-
* REFLEX_PUBLISH_PRODUCTION for a production environment (`403 PUBLISH_PRODUCTION_REQUIRED`); `404
|
|
29
|
-
* ENVIRONMENT_NOT_FOUND` for an environment outside the application.
|
|
30
|
-
*/
|
|
31
|
-
export const rotateServiceCompletionWebhookSecret = async (
|
|
32
|
-
params: IRotateServiceCompletionWebhookSecretParams,
|
|
33
|
-
): Promise<IRotateServiceCompletionWebhookSecretResponse> =>
|
|
34
|
-
(
|
|
35
|
-
await AbyssReflexCore.axios.post<IRotateServiceCompletionWebhookSecretResponse>(
|
|
36
|
-
`${completionWebhookUrl(params)}/${params.environmentId}/secret`,
|
|
37
|
-
{},
|
|
38
|
-
)
|
|
39
|
-
).data;
|
|
1
|
+
import { AbyssReflexCore } from '..';
|
|
2
|
+
import type {
|
|
3
|
+
IGetServiceCompletionWebhookParams,
|
|
4
|
+
IGetServiceCompletionWebhookResponse,
|
|
5
|
+
IRotateServiceCompletionWebhookSecretParams,
|
|
6
|
+
IRotateServiceCompletionWebhookSecretResponse,
|
|
7
|
+
} from '../types';
|
|
8
|
+
|
|
9
|
+
const completionWebhookUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
10
|
+
`api/service/${params.applicationId}/${params.serviceId}/completion-webhook`;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* `GET .../completion-webhook`: the environments where the completion webhook of the Service has a signing
|
|
14
|
+
* secret, never the secret itself. Needs REFLEX_READ.
|
|
15
|
+
*/
|
|
16
|
+
export const getServiceCompletionWebhook = async (
|
|
17
|
+
params: IGetServiceCompletionWebhookParams,
|
|
18
|
+
): Promise<IGetServiceCompletionWebhookResponse> =>
|
|
19
|
+
(
|
|
20
|
+
await AbyssReflexCore.axios.get<IGetServiceCompletionWebhookResponse>(
|
|
21
|
+
completionWebhookUrl(params),
|
|
22
|
+
)
|
|
23
|
+
).data;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* `POST .../completion-webhook/:environmentId/secret`: creates or renews the signing secret of the completion webhook
|
|
27
|
+
* in the environment, in clear ONCE; the next deliveries are signed with it. Needs REFLEX_PUBLISH, and
|
|
28
|
+
* REFLEX_PUBLISH_PRODUCTION for a production environment (`403 PUBLISH_PRODUCTION_REQUIRED`); `404
|
|
29
|
+
* ENVIRONMENT_NOT_FOUND` for an environment outside the application.
|
|
30
|
+
*/
|
|
31
|
+
export const rotateServiceCompletionWebhookSecret = async (
|
|
32
|
+
params: IRotateServiceCompletionWebhookSecretParams,
|
|
33
|
+
): Promise<IRotateServiceCompletionWebhookSecretResponse> =>
|
|
34
|
+
(
|
|
35
|
+
await AbyssReflexCore.axios.post<IRotateServiceCompletionWebhookSecretResponse>(
|
|
36
|
+
`${completionWebhookUrl(params)}/${params.environmentId}/secret`,
|
|
37
|
+
{},
|
|
38
|
+
)
|
|
39
|
+
).data;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { AbyssReflexCore } from '..';
|
|
2
|
-
import type { IListServiceConfigurationParams, IListServiceConfigurationResponse } from '../types';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* `GET .../configuration`: per key the functions of the Service read (draft and versions in service),
|
|
6
|
-
* and per environment of the application, where the Console vault gets its value from; never a value.
|
|
7
|
-
* Needs REFLEX_READ, and SECRET_READ on the project (Console re-checks it).
|
|
8
|
-
*/
|
|
9
|
-
export const listServiceConfiguration = async (
|
|
10
|
-
params: IListServiceConfigurationParams,
|
|
11
|
-
): Promise<IListServiceConfigurationResponse> =>
|
|
12
|
-
(
|
|
13
|
-
await AbyssReflexCore.axios.get<IListServiceConfigurationResponse>(
|
|
14
|
-
`api/service/${params.applicationId}/${params.serviceId}/configuration`,
|
|
15
|
-
)
|
|
16
|
-
).data;
|
|
1
|
+
import { AbyssReflexCore } from '..';
|
|
2
|
+
import type { IListServiceConfigurationParams, IListServiceConfigurationResponse } from '../types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `GET .../configuration`: per key the functions of the Service read (draft and versions in service),
|
|
6
|
+
* and per environment of the application, where the Console vault gets its value from; never a value.
|
|
7
|
+
* Needs REFLEX_READ, and SECRET_READ on the project (Console re-checks it).
|
|
8
|
+
*/
|
|
9
|
+
export const listServiceConfiguration = async (
|
|
10
|
+
params: IListServiceConfigurationParams,
|
|
11
|
+
): Promise<IListServiceConfigurationResponse> =>
|
|
12
|
+
(
|
|
13
|
+
await AbyssReflexCore.axios.get<IListServiceConfigurationResponse>(
|
|
14
|
+
`api/service/${params.applicationId}/${params.serviceId}/configuration`,
|
|
15
|
+
)
|
|
16
|
+
).data;
|
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
import { AbyssReflexCore, REFLEX_CONSUMER_LIMITS, ReflexErrorCode } from '..';
|
|
3
|
-
|
|
4
|
-
const APP = 'app-1';
|
|
5
|
-
const SVC = 'svc-1';
|
|
6
|
-
const BASE = `api/service/${APP}/${SVC}`;
|
|
7
|
-
const SERVICE = { applicationId: APP, serviceId: SVC };
|
|
8
|
-
|
|
9
|
-
interface Call {
|
|
10
|
-
label: string;
|
|
11
|
-
method: string;
|
|
12
|
-
url: string;
|
|
13
|
-
body?: unknown;
|
|
14
|
-
run: () => Promise<unknown>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const consumer = () => AbyssReflexCore.sdk.service.consumer;
|
|
18
|
-
|
|
19
|
-
const created = { name: 'Billing partner', routeIds: ['r-1'], rateLimitPerMinute: 120 };
|
|
20
|
-
|
|
21
|
-
const calls: Call[] = [
|
|
22
|
-
{
|
|
23
|
-
label: 'list',
|
|
24
|
-
method: 'get',
|
|
25
|
-
url: `${BASE}/consumer`,
|
|
26
|
-
run: () => consumer().list(SERVICE),
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
label: 'create',
|
|
30
|
-
method: 'post',
|
|
31
|
-
url: `${BASE}/consumer`,
|
|
32
|
-
body: created,
|
|
33
|
-
run: () => consumer().create(SERVICE, created),
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
label: 'update',
|
|
37
|
-
method: 'patch',
|
|
38
|
-
url: `${BASE}/consumer/c-1`,
|
|
39
|
-
body: { name: 'Partner', routeIds: null },
|
|
40
|
-
run: () =>
|
|
41
|
-
consumer().update({ ...SERVICE, consumerId: 'c-1' }, { name: 'Partner', routeIds: null }),
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
label: 'delete',
|
|
45
|
-
method: 'delete',
|
|
46
|
-
url: `${BASE}/consumer/c-1`,
|
|
47
|
-
run: () => consumer().delete({ ...SERVICE, consumerId: 'c-1' }),
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
label: 'createKey',
|
|
51
|
-
method: 'post',
|
|
52
|
-
url: `${BASE}/consumer/c-1/key`,
|
|
53
|
-
body: {},
|
|
54
|
-
run: () => consumer().createKey({ ...SERVICE, consumerId: 'c-1' }),
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
label: 'revokeKey',
|
|
58
|
-
method: 'post',
|
|
59
|
-
url: `${BASE}/consumer/c-1/key/k-1/revoke`,
|
|
60
|
-
body: {},
|
|
61
|
-
run: () => consumer().revokeKey({ ...SERVICE, consumerId: 'c-1', keyId: 'k-1' }),
|
|
62
|
-
},
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
describe('AbyssReflexCore consumer routes', () => {
|
|
66
|
-
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
67
|
-
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
beforeAll(() => {
|
|
71
|
-
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
72
|
-
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
beforeEach(() => adapter.mockClear());
|
|
76
|
-
|
|
77
|
-
it.each(calls)('$label calls $method $url', async (call) => {
|
|
78
|
-
await call.run();
|
|
79
|
-
|
|
80
|
-
const config = adapter.mock.calls[0][0];
|
|
81
|
-
expect(config.method).toBe(call.method);
|
|
82
|
-
expect(config.url).toBe(call.url);
|
|
83
|
-
expect(config.baseURL).toBe('http://reflex.test/');
|
|
84
|
-
if (call.body !== undefined) {
|
|
85
|
-
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('exposes no route twice', () => {
|
|
90
|
-
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('carries the bounds of the consumers and their refusal codes', () => {
|
|
94
|
-
expect(REFLEX_CONSUMER_LIMITS).toEqual({
|
|
95
|
-
perService: 100,
|
|
96
|
-
activeKeysPerConsumer: 5,
|
|
97
|
-
nameMaxLength: 64,
|
|
98
|
-
descriptionMaxLength: 500,
|
|
99
|
-
rateLimitPerMinute: { min: 1, max: 100_000 },
|
|
100
|
-
});
|
|
101
|
-
expect(ReflexErrorCode.CONSUMER_LIMIT_REACHED).toBe('CONSUMER_LIMIT_REACHED');
|
|
102
|
-
expect(ReflexErrorCode.CONSUMER_KEY_LIMIT_REACHED).toBe('CONSUMER_KEY_LIMIT_REACHED');
|
|
103
|
-
});
|
|
104
|
-
});
|
|
1
|
+
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
+
import { AbyssReflexCore, REFLEX_CONSUMER_LIMITS, ReflexErrorCode } from '..';
|
|
3
|
+
|
|
4
|
+
const APP = 'app-1';
|
|
5
|
+
const SVC = 'svc-1';
|
|
6
|
+
const BASE = `api/service/${APP}/${SVC}`;
|
|
7
|
+
const SERVICE = { applicationId: APP, serviceId: SVC };
|
|
8
|
+
|
|
9
|
+
interface Call {
|
|
10
|
+
label: string;
|
|
11
|
+
method: string;
|
|
12
|
+
url: string;
|
|
13
|
+
body?: unknown;
|
|
14
|
+
run: () => Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const consumer = () => AbyssReflexCore.sdk.service.consumer;
|
|
18
|
+
|
|
19
|
+
const created = { name: 'Billing partner', routeIds: ['r-1'], rateLimitPerMinute: 120 };
|
|
20
|
+
|
|
21
|
+
const calls: Call[] = [
|
|
22
|
+
{
|
|
23
|
+
label: 'list',
|
|
24
|
+
method: 'get',
|
|
25
|
+
url: `${BASE}/consumer`,
|
|
26
|
+
run: () => consumer().list(SERVICE),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: 'create',
|
|
30
|
+
method: 'post',
|
|
31
|
+
url: `${BASE}/consumer`,
|
|
32
|
+
body: created,
|
|
33
|
+
run: () => consumer().create(SERVICE, created),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: 'update',
|
|
37
|
+
method: 'patch',
|
|
38
|
+
url: `${BASE}/consumer/c-1`,
|
|
39
|
+
body: { name: 'Partner', routeIds: null },
|
|
40
|
+
run: () =>
|
|
41
|
+
consumer().update({ ...SERVICE, consumerId: 'c-1' }, { name: 'Partner', routeIds: null }),
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: 'delete',
|
|
45
|
+
method: 'delete',
|
|
46
|
+
url: `${BASE}/consumer/c-1`,
|
|
47
|
+
run: () => consumer().delete({ ...SERVICE, consumerId: 'c-1' }),
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: 'createKey',
|
|
51
|
+
method: 'post',
|
|
52
|
+
url: `${BASE}/consumer/c-1/key`,
|
|
53
|
+
body: {},
|
|
54
|
+
run: () => consumer().createKey({ ...SERVICE, consumerId: 'c-1' }),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: 'revokeKey',
|
|
58
|
+
method: 'post',
|
|
59
|
+
url: `${BASE}/consumer/c-1/key/k-1/revoke`,
|
|
60
|
+
body: {},
|
|
61
|
+
run: () => consumer().revokeKey({ ...SERVICE, consumerId: 'c-1', keyId: 'k-1' }),
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
describe('AbyssReflexCore consumer routes', () => {
|
|
66
|
+
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
67
|
+
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
beforeAll(() => {
|
|
71
|
+
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
72
|
+
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
beforeEach(() => adapter.mockClear());
|
|
76
|
+
|
|
77
|
+
it.each(calls)('$label calls $method $url', async (call) => {
|
|
78
|
+
await call.run();
|
|
79
|
+
|
|
80
|
+
const config = adapter.mock.calls[0][0];
|
|
81
|
+
expect(config.method).toBe(call.method);
|
|
82
|
+
expect(config.url).toBe(call.url);
|
|
83
|
+
expect(config.baseURL).toBe('http://reflex.test/');
|
|
84
|
+
if (call.body !== undefined) {
|
|
85
|
+
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('exposes no route twice', () => {
|
|
90
|
+
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('carries the bounds of the consumers and their refusal codes', () => {
|
|
94
|
+
expect(REFLEX_CONSUMER_LIMITS).toEqual({
|
|
95
|
+
perService: 100,
|
|
96
|
+
activeKeysPerConsumer: 5,
|
|
97
|
+
nameMaxLength: 64,
|
|
98
|
+
descriptionMaxLength: 500,
|
|
99
|
+
rateLimitPerMinute: { min: 1, max: 100_000 },
|
|
100
|
+
});
|
|
101
|
+
expect(ReflexErrorCode.CONSUMER_LIMIT_REACHED).toBe('CONSUMER_LIMIT_REACHED');
|
|
102
|
+
expect(ReflexErrorCode.CONSUMER_KEY_LIMIT_REACHED).toBe('CONSUMER_KEY_LIMIT_REACHED');
|
|
103
|
+
});
|
|
104
|
+
});
|