@abyss-project/reflex 6.0.5 → 6.1.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/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/types/enum/reflex-error-code.enum.d.ts +2 -1
- package/dist/types/enum/reflex-error-code.enum.js +1 -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/service.request.d.ts +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/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 +26 -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/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 +12 -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 +5 -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/service.request.ts +2 -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/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
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
import { AbyssReflexCore } from '..';
|
|
2
|
-
import type {
|
|
3
|
-
ICreateServiceConsumerBody,
|
|
4
|
-
ICreateServiceConsumerKeyParams,
|
|
5
|
-
ICreateServiceConsumerKeyResponse,
|
|
6
|
-
ICreateServiceConsumerParams,
|
|
7
|
-
ICreateServiceConsumerResponse,
|
|
8
|
-
IDeleteServiceConsumerParams,
|
|
9
|
-
IDeleteServiceConsumerResponse,
|
|
10
|
-
IListServiceConsumerParams,
|
|
11
|
-
IListServiceConsumerResponse,
|
|
12
|
-
IRevokeServiceConsumerKeyParams,
|
|
13
|
-
IRevokeServiceConsumerKeyResponse,
|
|
14
|
-
IUpdateServiceConsumerBody,
|
|
15
|
-
IUpdateServiceConsumerParams,
|
|
16
|
-
IUpdateServiceConsumerResponse,
|
|
17
|
-
} from '../types';
|
|
18
|
-
|
|
19
|
-
const consumerUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
20
|
-
`api/service/${params.applicationId}/${params.serviceId}/consumer`;
|
|
21
|
-
|
|
22
|
-
/** `GET .../consumer`: the consumers of the Service with their keys, by name. Needs REFLEX_READ. */
|
|
23
|
-
export const listServiceConsumer = async (
|
|
24
|
-
params: IListServiceConsumerParams,
|
|
25
|
-
): Promise<IListServiceConsumerResponse> =>
|
|
26
|
-
(await AbyssReflexCore.axios.get<IListServiceConsumerResponse>(consumerUrl(params))).data;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* `POST .../consumer`: a consumer of the `API_KEY` routes of the Service, without key yet.
|
|
30
|
-
* `409 ALREADY_EXISTS` for a name taken whatever the case, `409 CONSUMER_LIMIT_REACHED` past
|
|
31
|
-
* `REFLEX_CONSUMER_LIMITS.perService`, `400 SERVICE_TYPE_FIELD_REFUSED` for a DISCORD_BOT Service. Needs REFLEX_PUBLISH.
|
|
32
|
-
*/
|
|
33
|
-
export const createServiceConsumer = async (
|
|
34
|
-
params: ICreateServiceConsumerParams,
|
|
35
|
-
body: ICreateServiceConsumerBody,
|
|
36
|
-
): Promise<ICreateServiceConsumerResponse> =>
|
|
37
|
-
(await AbyssReflexCore.axios.post<ICreateServiceConsumerResponse>(consumerUrl(params), body))
|
|
38
|
-
.data;
|
|
39
|
-
|
|
40
|
-
/** `PATCH .../consumer/:consumerId`: renames the consumer or changes its routes or its rate, at once. Needs REFLEX_PUBLISH. */
|
|
41
|
-
export const updateServiceConsumer = async (
|
|
42
|
-
params: IUpdateServiceConsumerParams,
|
|
43
|
-
body: IUpdateServiceConsumerBody,
|
|
44
|
-
): Promise<IUpdateServiceConsumerResponse> =>
|
|
45
|
-
(
|
|
46
|
-
await AbyssReflexCore.axios.patch<IUpdateServiceConsumerResponse>(
|
|
47
|
-
`${consumerUrl(params)}/${params.consumerId}`,
|
|
48
|
-
body,
|
|
49
|
-
)
|
|
50
|
-
).data;
|
|
51
|
-
|
|
52
|
-
/** `DELETE .../consumer/:consumerId`: the consumer and its keys, refused at once by the edge. Needs REFLEX_PUBLISH. */
|
|
53
|
-
export const deleteServiceConsumer = async (
|
|
54
|
-
params: IDeleteServiceConsumerParams,
|
|
55
|
-
): Promise<IDeleteServiceConsumerResponse> =>
|
|
56
|
-
(
|
|
57
|
-
await AbyssReflexCore.axios.delete<IDeleteServiceConsumerResponse>(
|
|
58
|
-
`${consumerUrl(params)}/${params.consumerId}`,
|
|
59
|
-
)
|
|
60
|
-
).data;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* `POST .../consumer/:consumerId/key`: a new key of the consumer, in clear ONCE in `secret`.
|
|
64
|
-
* `409 CONSUMER_KEY_LIMIT_REACHED` past `REFLEX_CONSUMER_LIMITS.activeKeysPerConsumer` active keys. Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION when a production environment serves
|
|
65
|
-
* the Service (`403 PUBLISH_PRODUCTION_REQUIRED`).
|
|
66
|
-
*/
|
|
67
|
-
export const createServiceConsumerKey = async (
|
|
68
|
-
params: ICreateServiceConsumerKeyParams,
|
|
69
|
-
): Promise<ICreateServiceConsumerKeyResponse> =>
|
|
70
|
-
(
|
|
71
|
-
await AbyssReflexCore.axios.post<ICreateServiceConsumerKeyResponse>(
|
|
72
|
-
`${consumerUrl(params)}/${params.consumerId}/key`,
|
|
73
|
-
{},
|
|
74
|
-
)
|
|
75
|
-
).data;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* `POST .../consumer/:consumerId/key/:keyId/revoke`: revokes the key; the edge refuses it (`401`) as soon as
|
|
79
|
-
* this answers. Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION when a production environment serves the
|
|
80
|
-
* Service (`403 PUBLISH_PRODUCTION_REQUIRED`).
|
|
81
|
-
*/
|
|
82
|
-
export const revokeServiceConsumerKey = async (
|
|
83
|
-
params: IRevokeServiceConsumerKeyParams,
|
|
84
|
-
): Promise<IRevokeServiceConsumerKeyResponse> =>
|
|
85
|
-
(
|
|
86
|
-
await AbyssReflexCore.axios.post<IRevokeServiceConsumerKeyResponse>(
|
|
87
|
-
`${consumerUrl(params)}/${params.consumerId}/key/${params.keyId}/revoke`,
|
|
88
|
-
{},
|
|
89
|
-
)
|
|
90
|
-
).data;
|
|
1
|
+
import { AbyssReflexCore } from '..';
|
|
2
|
+
import type {
|
|
3
|
+
ICreateServiceConsumerBody,
|
|
4
|
+
ICreateServiceConsumerKeyParams,
|
|
5
|
+
ICreateServiceConsumerKeyResponse,
|
|
6
|
+
ICreateServiceConsumerParams,
|
|
7
|
+
ICreateServiceConsumerResponse,
|
|
8
|
+
IDeleteServiceConsumerParams,
|
|
9
|
+
IDeleteServiceConsumerResponse,
|
|
10
|
+
IListServiceConsumerParams,
|
|
11
|
+
IListServiceConsumerResponse,
|
|
12
|
+
IRevokeServiceConsumerKeyParams,
|
|
13
|
+
IRevokeServiceConsumerKeyResponse,
|
|
14
|
+
IUpdateServiceConsumerBody,
|
|
15
|
+
IUpdateServiceConsumerParams,
|
|
16
|
+
IUpdateServiceConsumerResponse,
|
|
17
|
+
} from '../types';
|
|
18
|
+
|
|
19
|
+
const consumerUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
20
|
+
`api/service/${params.applicationId}/${params.serviceId}/consumer`;
|
|
21
|
+
|
|
22
|
+
/** `GET .../consumer`: the consumers of the Service with their keys, by name. Needs REFLEX_READ. */
|
|
23
|
+
export const listServiceConsumer = async (
|
|
24
|
+
params: IListServiceConsumerParams,
|
|
25
|
+
): Promise<IListServiceConsumerResponse> =>
|
|
26
|
+
(await AbyssReflexCore.axios.get<IListServiceConsumerResponse>(consumerUrl(params))).data;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* `POST .../consumer`: a consumer of the `API_KEY` routes of the Service, without key yet.
|
|
30
|
+
* `409 ALREADY_EXISTS` for a name taken whatever the case, `409 CONSUMER_LIMIT_REACHED` past
|
|
31
|
+
* `REFLEX_CONSUMER_LIMITS.perService`, `400 SERVICE_TYPE_FIELD_REFUSED` for a DISCORD_BOT Service. Needs REFLEX_PUBLISH.
|
|
32
|
+
*/
|
|
33
|
+
export const createServiceConsumer = async (
|
|
34
|
+
params: ICreateServiceConsumerParams,
|
|
35
|
+
body: ICreateServiceConsumerBody,
|
|
36
|
+
): Promise<ICreateServiceConsumerResponse> =>
|
|
37
|
+
(await AbyssReflexCore.axios.post<ICreateServiceConsumerResponse>(consumerUrl(params), body))
|
|
38
|
+
.data;
|
|
39
|
+
|
|
40
|
+
/** `PATCH .../consumer/:consumerId`: renames the consumer or changes its routes or its rate, at once. Needs REFLEX_PUBLISH. */
|
|
41
|
+
export const updateServiceConsumer = async (
|
|
42
|
+
params: IUpdateServiceConsumerParams,
|
|
43
|
+
body: IUpdateServiceConsumerBody,
|
|
44
|
+
): Promise<IUpdateServiceConsumerResponse> =>
|
|
45
|
+
(
|
|
46
|
+
await AbyssReflexCore.axios.patch<IUpdateServiceConsumerResponse>(
|
|
47
|
+
`${consumerUrl(params)}/${params.consumerId}`,
|
|
48
|
+
body,
|
|
49
|
+
)
|
|
50
|
+
).data;
|
|
51
|
+
|
|
52
|
+
/** `DELETE .../consumer/:consumerId`: the consumer and its keys, refused at once by the edge. Needs REFLEX_PUBLISH. */
|
|
53
|
+
export const deleteServiceConsumer = async (
|
|
54
|
+
params: IDeleteServiceConsumerParams,
|
|
55
|
+
): Promise<IDeleteServiceConsumerResponse> =>
|
|
56
|
+
(
|
|
57
|
+
await AbyssReflexCore.axios.delete<IDeleteServiceConsumerResponse>(
|
|
58
|
+
`${consumerUrl(params)}/${params.consumerId}`,
|
|
59
|
+
)
|
|
60
|
+
).data;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* `POST .../consumer/:consumerId/key`: a new key of the consumer, in clear ONCE in `secret`.
|
|
64
|
+
* `409 CONSUMER_KEY_LIMIT_REACHED` past `REFLEX_CONSUMER_LIMITS.activeKeysPerConsumer` active keys. Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION when a production environment serves
|
|
65
|
+
* the Service (`403 PUBLISH_PRODUCTION_REQUIRED`).
|
|
66
|
+
*/
|
|
67
|
+
export const createServiceConsumerKey = async (
|
|
68
|
+
params: ICreateServiceConsumerKeyParams,
|
|
69
|
+
): Promise<ICreateServiceConsumerKeyResponse> =>
|
|
70
|
+
(
|
|
71
|
+
await AbyssReflexCore.axios.post<ICreateServiceConsumerKeyResponse>(
|
|
72
|
+
`${consumerUrl(params)}/${params.consumerId}/key`,
|
|
73
|
+
{},
|
|
74
|
+
)
|
|
75
|
+
).data;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* `POST .../consumer/:consumerId/key/:keyId/revoke`: revokes the key; the edge refuses it (`401`) as soon as
|
|
79
|
+
* this answers. Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION when a production environment serves the
|
|
80
|
+
* Service (`403 PUBLISH_PRODUCTION_REQUIRED`).
|
|
81
|
+
*/
|
|
82
|
+
export const revokeServiceConsumerKey = async (
|
|
83
|
+
params: IRevokeServiceConsumerKeyParams,
|
|
84
|
+
): Promise<IRevokeServiceConsumerKeyResponse> =>
|
|
85
|
+
(
|
|
86
|
+
await AbyssReflexCore.axios.post<IRevokeServiceConsumerKeyResponse>(
|
|
87
|
+
`${consumerUrl(params)}/${params.consumerId}/key/${params.keyId}/revoke`,
|
|
88
|
+
{},
|
|
89
|
+
)
|
|
90
|
+
).data;
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import { AbyssReflexCore } from '..';
|
|
2
|
-
import type {
|
|
3
|
-
IGoLiveServiceBody,
|
|
4
|
-
IGoLiveServiceParams,
|
|
5
|
-
IGoLiveServiceResponse,
|
|
6
|
-
IListServiceDeploymentParams,
|
|
7
|
-
IListServiceDeploymentQuery,
|
|
8
|
-
IListServiceDeploymentResponse,
|
|
9
|
-
IPauseServiceBody,
|
|
10
|
-
IPauseServiceParams,
|
|
11
|
-
IPauseServiceResponse,
|
|
12
|
-
IResumeServiceBody,
|
|
13
|
-
IResumeServiceParams,
|
|
14
|
-
IResumeServiceResponse,
|
|
15
|
-
IRollbackServiceBody,
|
|
16
|
-
IRollbackServiceParams,
|
|
17
|
-
IRollbackServiceResponse,
|
|
18
|
-
} from '../types';
|
|
19
|
-
|
|
20
|
-
const deploymentUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
21
|
-
`api/service/${params.applicationId}/${params.serviceId}/deployment`;
|
|
22
|
-
|
|
23
|
-
/** `GET .../deployment`: the current deployment per environment and a page of the history. Needs REFLEX_READ. */
|
|
24
|
-
export const listServiceDeployment = async (
|
|
25
|
-
params: IListServiceDeploymentParams,
|
|
26
|
-
query: IListServiceDeploymentQuery = {},
|
|
27
|
-
): Promise<IListServiceDeploymentResponse> =>
|
|
28
|
-
(
|
|
29
|
-
await AbyssReflexCore.axios.get<IListServiceDeploymentResponse>(deploymentUrl(params), {
|
|
30
|
-
params: query,
|
|
31
|
-
})
|
|
32
|
-
).data;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* `POST .../deployment/go-live`: puts a version in service in an environment, in one transaction. Needs
|
|
36
|
-
* REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION in a production environment.
|
|
37
|
-
*/
|
|
38
|
-
export const goLiveService = async (
|
|
39
|
-
params: IGoLiveServiceParams,
|
|
40
|
-
body: IGoLiveServiceBody,
|
|
41
|
-
): Promise<IGoLiveServiceResponse> =>
|
|
42
|
-
(
|
|
43
|
-
await AbyssReflexCore.axios.post<IGoLiveServiceResponse>(
|
|
44
|
-
`${deploymentUrl(params)}/go-live`,
|
|
45
|
-
body,
|
|
46
|
-
)
|
|
47
|
-
).data;
|
|
48
|
-
|
|
49
|
-
/** `POST .../deployment/rollback`: puts back the version of a deployment of the history. Rights as go-live. */
|
|
50
|
-
export const rollbackService = async (
|
|
51
|
-
params: IRollbackServiceParams,
|
|
52
|
-
body: IRollbackServiceBody,
|
|
53
|
-
): Promise<IRollbackServiceResponse> =>
|
|
54
|
-
(
|
|
55
|
-
await AbyssReflexCore.axios.post<IRollbackServiceResponse>(
|
|
56
|
-
`${deploymentUrl(params)}/rollback`,
|
|
57
|
-
body,
|
|
58
|
-
)
|
|
59
|
-
).data;
|
|
60
|
-
|
|
61
|
-
/** `POST .../deployment/pause`: every call answers `503 SERVICE_PAUSED`. Rights as go-live. */
|
|
62
|
-
export const pauseService = async (
|
|
63
|
-
params: IPauseServiceParams,
|
|
64
|
-
body: IPauseServiceBody,
|
|
65
|
-
): Promise<IPauseServiceResponse> =>
|
|
66
|
-
(await AbyssReflexCore.axios.post<IPauseServiceResponse>(`${deploymentUrl(params)}/pause`, body))
|
|
67
|
-
.data;
|
|
68
|
-
|
|
69
|
-
/** `POST .../deployment/resume`: the paused version answers again. Rights as go-live. */
|
|
70
|
-
export const resumeService = async (
|
|
71
|
-
params: IResumeServiceParams,
|
|
72
|
-
body: IResumeServiceBody,
|
|
73
|
-
): Promise<IResumeServiceResponse> =>
|
|
74
|
-
(
|
|
75
|
-
await AbyssReflexCore.axios.post<IResumeServiceResponse>(
|
|
76
|
-
`${deploymentUrl(params)}/resume`,
|
|
77
|
-
body,
|
|
78
|
-
)
|
|
79
|
-
).data;
|
|
1
|
+
import { AbyssReflexCore } from '..';
|
|
2
|
+
import type {
|
|
3
|
+
IGoLiveServiceBody,
|
|
4
|
+
IGoLiveServiceParams,
|
|
5
|
+
IGoLiveServiceResponse,
|
|
6
|
+
IListServiceDeploymentParams,
|
|
7
|
+
IListServiceDeploymentQuery,
|
|
8
|
+
IListServiceDeploymentResponse,
|
|
9
|
+
IPauseServiceBody,
|
|
10
|
+
IPauseServiceParams,
|
|
11
|
+
IPauseServiceResponse,
|
|
12
|
+
IResumeServiceBody,
|
|
13
|
+
IResumeServiceParams,
|
|
14
|
+
IResumeServiceResponse,
|
|
15
|
+
IRollbackServiceBody,
|
|
16
|
+
IRollbackServiceParams,
|
|
17
|
+
IRollbackServiceResponse,
|
|
18
|
+
} from '../types';
|
|
19
|
+
|
|
20
|
+
const deploymentUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
21
|
+
`api/service/${params.applicationId}/${params.serviceId}/deployment`;
|
|
22
|
+
|
|
23
|
+
/** `GET .../deployment`: the current deployment per environment and a page of the history. Needs REFLEX_READ. */
|
|
24
|
+
export const listServiceDeployment = async (
|
|
25
|
+
params: IListServiceDeploymentParams,
|
|
26
|
+
query: IListServiceDeploymentQuery = {},
|
|
27
|
+
): Promise<IListServiceDeploymentResponse> =>
|
|
28
|
+
(
|
|
29
|
+
await AbyssReflexCore.axios.get<IListServiceDeploymentResponse>(deploymentUrl(params), {
|
|
30
|
+
params: query,
|
|
31
|
+
})
|
|
32
|
+
).data;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* `POST .../deployment/go-live`: puts a version in service in an environment, in one transaction. Needs
|
|
36
|
+
* REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION in a production environment.
|
|
37
|
+
*/
|
|
38
|
+
export const goLiveService = async (
|
|
39
|
+
params: IGoLiveServiceParams,
|
|
40
|
+
body: IGoLiveServiceBody,
|
|
41
|
+
): Promise<IGoLiveServiceResponse> =>
|
|
42
|
+
(
|
|
43
|
+
await AbyssReflexCore.axios.post<IGoLiveServiceResponse>(
|
|
44
|
+
`${deploymentUrl(params)}/go-live`,
|
|
45
|
+
body,
|
|
46
|
+
)
|
|
47
|
+
).data;
|
|
48
|
+
|
|
49
|
+
/** `POST .../deployment/rollback`: puts back the version of a deployment of the history. Rights as go-live. */
|
|
50
|
+
export const rollbackService = async (
|
|
51
|
+
params: IRollbackServiceParams,
|
|
52
|
+
body: IRollbackServiceBody,
|
|
53
|
+
): Promise<IRollbackServiceResponse> =>
|
|
54
|
+
(
|
|
55
|
+
await AbyssReflexCore.axios.post<IRollbackServiceResponse>(
|
|
56
|
+
`${deploymentUrl(params)}/rollback`,
|
|
57
|
+
body,
|
|
58
|
+
)
|
|
59
|
+
).data;
|
|
60
|
+
|
|
61
|
+
/** `POST .../deployment/pause`: every call answers `503 SERVICE_PAUSED`. Rights as go-live. */
|
|
62
|
+
export const pauseService = async (
|
|
63
|
+
params: IPauseServiceParams,
|
|
64
|
+
body: IPauseServiceBody,
|
|
65
|
+
): Promise<IPauseServiceResponse> =>
|
|
66
|
+
(await AbyssReflexCore.axios.post<IPauseServiceResponse>(`${deploymentUrl(params)}/pause`, body))
|
|
67
|
+
.data;
|
|
68
|
+
|
|
69
|
+
/** `POST .../deployment/resume`: the paused version answers again. Rights as go-live. */
|
|
70
|
+
export const resumeService = async (
|
|
71
|
+
params: IResumeServiceParams,
|
|
72
|
+
body: IResumeServiceBody,
|
|
73
|
+
): Promise<IResumeServiceResponse> =>
|
|
74
|
+
(
|
|
75
|
+
await AbyssReflexCore.axios.post<IResumeServiceResponse>(
|
|
76
|
+
`${deploymentUrl(params)}/resume`,
|
|
77
|
+
body,
|
|
78
|
+
)
|
|
79
|
+
).data;
|
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
import { AbyssReflexCore, DiscordEventDropReason, DiscordEventStatus, DiscordEventType } 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
|
-
query?: unknown;
|
|
15
|
-
run: () => Promise<unknown>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const discord = () => AbyssReflexCore.sdk.service.discord;
|
|
19
|
-
|
|
20
|
-
const event = {
|
|
21
|
-
name: 'welcome',
|
|
22
|
-
eventType: DiscordEventType.GUILD_MEMBER_ADD,
|
|
23
|
-
functionId: 'fn-1',
|
|
24
|
-
filters: { guildIds: ['123456789012345678'], ignoreBots: true },
|
|
25
|
-
ordered: true,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const logQuery = {
|
|
29
|
-
environmentId: 'e-1',
|
|
30
|
-
status: DiscordEventStatus.DONE,
|
|
31
|
-
reason: DiscordEventDropReason.RATE,
|
|
32
|
-
type: DiscordEventType.MESSAGE_CREATE,
|
|
33
|
-
triggerId: 't-1',
|
|
34
|
-
from: '2026-11-20T00:00:00.000Z',
|
|
35
|
-
to: '2026-11-21T00:00:00.000Z',
|
|
36
|
-
cursor: 'c-1',
|
|
37
|
-
limit: 20,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const calls: Call[] = [
|
|
41
|
-
{
|
|
42
|
-
label: 'event.list',
|
|
43
|
-
method: 'get',
|
|
44
|
-
url: `${BASE}/discord-event`,
|
|
45
|
-
run: () => discord().event.list(SERVICE),
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
label: 'event.create',
|
|
49
|
-
method: 'post',
|
|
50
|
-
url: `${BASE}/discord-event`,
|
|
51
|
-
body: event,
|
|
52
|
-
run: () => discord().event.create(SERVICE, event),
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
label: 'event.update',
|
|
56
|
-
method: 'patch',
|
|
57
|
-
url: `${BASE}/discord-event/ev-1`,
|
|
58
|
-
body: { ordered: false },
|
|
59
|
-
run: () => discord().event.update({ ...SERVICE, eventId: 'ev-1' }, { ordered: false }),
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
label: 'event.delete',
|
|
63
|
-
method: 'delete',
|
|
64
|
-
url: `${BASE}/discord-event/ev-1`,
|
|
65
|
-
run: () => discord().event.delete({ ...SERVICE, eventId: 'ev-1' }),
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
label: 'eventLog.list',
|
|
69
|
-
method: 'get',
|
|
70
|
-
url: `${BASE}/discord-event-log`,
|
|
71
|
-
query: logQuery,
|
|
72
|
-
run: () => discord().eventLog.list(SERVICE, logQuery),
|
|
73
|
-
},
|
|
74
|
-
];
|
|
75
|
-
|
|
76
|
-
describe('AbyssReflexCore Discord event routes', () => {
|
|
77
|
-
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
78
|
-
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
beforeAll(() => {
|
|
82
|
-
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
83
|
-
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
beforeEach(() => adapter.mockClear());
|
|
87
|
-
|
|
88
|
-
it.each(calls)('$label calls $method $url', async (call) => {
|
|
89
|
-
await call.run();
|
|
90
|
-
|
|
91
|
-
const config = adapter.mock.calls[0][0];
|
|
92
|
-
expect(config.method).toBe(call.method);
|
|
93
|
-
expect(config.url).toBe(call.url);
|
|
94
|
-
expect(config.baseURL).toBe('http://reflex.test/');
|
|
95
|
-
if (call.body !== undefined) {
|
|
96
|
-
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
97
|
-
}
|
|
98
|
-
if (call.query !== undefined) {
|
|
99
|
-
expect(config.params).toEqual(call.query);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('exposes no route twice', () => {
|
|
104
|
-
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
1
|
+
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
+
import { AbyssReflexCore, DiscordEventDropReason, DiscordEventStatus, DiscordEventType } 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
|
+
query?: unknown;
|
|
15
|
+
run: () => Promise<unknown>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const discord = () => AbyssReflexCore.sdk.service.discord;
|
|
19
|
+
|
|
20
|
+
const event = {
|
|
21
|
+
name: 'welcome',
|
|
22
|
+
eventType: DiscordEventType.GUILD_MEMBER_ADD,
|
|
23
|
+
functionId: 'fn-1',
|
|
24
|
+
filters: { guildIds: ['123456789012345678'], ignoreBots: true },
|
|
25
|
+
ordered: true,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const logQuery = {
|
|
29
|
+
environmentId: 'e-1',
|
|
30
|
+
status: DiscordEventStatus.DONE,
|
|
31
|
+
reason: DiscordEventDropReason.RATE,
|
|
32
|
+
type: DiscordEventType.MESSAGE_CREATE,
|
|
33
|
+
triggerId: 't-1',
|
|
34
|
+
from: '2026-11-20T00:00:00.000Z',
|
|
35
|
+
to: '2026-11-21T00:00:00.000Z',
|
|
36
|
+
cursor: 'c-1',
|
|
37
|
+
limit: 20,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const calls: Call[] = [
|
|
41
|
+
{
|
|
42
|
+
label: 'event.list',
|
|
43
|
+
method: 'get',
|
|
44
|
+
url: `${BASE}/discord-event`,
|
|
45
|
+
run: () => discord().event.list(SERVICE),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: 'event.create',
|
|
49
|
+
method: 'post',
|
|
50
|
+
url: `${BASE}/discord-event`,
|
|
51
|
+
body: event,
|
|
52
|
+
run: () => discord().event.create(SERVICE, event),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: 'event.update',
|
|
56
|
+
method: 'patch',
|
|
57
|
+
url: `${BASE}/discord-event/ev-1`,
|
|
58
|
+
body: { ordered: false },
|
|
59
|
+
run: () => discord().event.update({ ...SERVICE, eventId: 'ev-1' }, { ordered: false }),
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: 'event.delete',
|
|
63
|
+
method: 'delete',
|
|
64
|
+
url: `${BASE}/discord-event/ev-1`,
|
|
65
|
+
run: () => discord().event.delete({ ...SERVICE, eventId: 'ev-1' }),
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
label: 'eventLog.list',
|
|
69
|
+
method: 'get',
|
|
70
|
+
url: `${BASE}/discord-event-log`,
|
|
71
|
+
query: logQuery,
|
|
72
|
+
run: () => discord().eventLog.list(SERVICE, logQuery),
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
describe('AbyssReflexCore Discord event routes', () => {
|
|
77
|
+
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
78
|
+
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
beforeAll(() => {
|
|
82
|
+
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
83
|
+
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
beforeEach(() => adapter.mockClear());
|
|
87
|
+
|
|
88
|
+
it.each(calls)('$label calls $method $url', async (call) => {
|
|
89
|
+
await call.run();
|
|
90
|
+
|
|
91
|
+
const config = adapter.mock.calls[0][0];
|
|
92
|
+
expect(config.method).toBe(call.method);
|
|
93
|
+
expect(config.url).toBe(call.url);
|
|
94
|
+
expect(config.baseURL).toBe('http://reflex.test/');
|
|
95
|
+
if (call.body !== undefined) {
|
|
96
|
+
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
97
|
+
}
|
|
98
|
+
if (call.query !== undefined) {
|
|
99
|
+
expect(config.params).toEqual(call.query);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('exposes no route twice', () => {
|
|
104
|
+
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
105
|
+
});
|
|
106
|
+
});
|