@abyss-project/reflex 6.0.4 → 6.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/README.md +15 -15
  4. package/dist/types/interface/models/reflex-service-limits.model.d.ts +5 -2
  5. package/jest.config.ts +11 -11
  6. package/package.json +1 -1
  7. package/src/api/alert-rule.api.test.ts +72 -72
  8. package/src/api/alert-rule.api.ts +57 -57
  9. package/src/api/application-insights.api.test.ts +42 -42
  10. package/src/api/application-insights.api.ts +38 -38
  11. package/src/api/application-run-settings.api.test.ts +51 -51
  12. package/src/api/application-run-settings.api.ts +30 -30
  13. package/src/api/function-access.api.ts +87 -87
  14. package/src/api/function-insights.api.test.ts +27 -27
  15. package/src/api/function-insights.api.ts +18 -18
  16. package/src/api/function-run.api.ts +38 -38
  17. package/src/api/function-settings.api.ts +74 -74
  18. package/src/api/function-template.api.test.ts +72 -72
  19. package/src/api/function-template.api.ts +52 -52
  20. package/src/api/function-test.api.ts +34 -34
  21. package/src/api/function-version.api.ts +66 -66
  22. package/src/api/function.api.ts +62 -62
  23. package/src/api/health.api.ts +10 -10
  24. package/src/api/route-stats.api.test.ts +45 -45
  25. package/src/api/route-stats.api.ts +36 -36
  26. package/src/api/service-configuration.api.ts +16 -16
  27. package/src/api/service-deployment.api.ts +79 -79
  28. package/src/api/service-discord-event.api.test.ts +106 -106
  29. package/src/api/service-discord-event.api.ts +78 -78
  30. package/src/api/service-insights.api.test.ts +36 -36
  31. package/src/api/service-insights.api.ts +42 -42
  32. package/src/api/service-task.api.test.ts +140 -140
  33. package/src/api/service-task.api.ts +141 -141
  34. package/src/api/service-version.api.ts +54 -54
  35. package/src/api/service.api.test.ts +215 -215
  36. package/src/api/service.api.ts +55 -55
  37. package/src/discord/discord-event-filter-cases.ts +261 -261
  38. package/src/discord/discord-event-filters.test.ts +91 -91
  39. package/src/discord/discord-event-filters.ts +95 -95
  40. package/src/discord/discord-event-intents.test.ts +112 -112
  41. package/src/discord/discord-event-intents.ts +55 -55
  42. package/src/discord/index.ts +3 -3
  43. package/src/insights/index.ts +1 -1
  44. package/src/insights/percentiles.test.ts +75 -75
  45. package/src/insights/percentiles.ts +37 -37
  46. package/src/types/enum/access-grant-status.enum.ts +12 -12
  47. package/src/types/enum/access-kind.enum.ts +7 -7
  48. package/src/types/enum/access-request-status.enum.ts +11 -11
  49. package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
  50. package/src/types/enum/configuration-read-as.enum.ts +5 -5
  51. package/src/types/enum/discord-activity-type.enum.ts +9 -9
  52. package/src/types/enum/discord-channel-type.enum.ts +11 -11
  53. package/src/types/enum/discord-component-kind.enum.ts +7 -7
  54. package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
  55. package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
  56. package/src/types/enum/discord-event-status.enum.ts +13 -13
  57. package/src/types/enum/discord-event-type.enum.ts +7 -7
  58. package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
  59. package/src/types/enum/discord-gateway-state.enum.ts +11 -11
  60. package/src/types/enum/discord-host-action.enum.ts +35 -35
  61. package/src/types/enum/discord-locale.enum.ts +35 -35
  62. package/src/types/enum/discord-option-type.enum.ts +12 -12
  63. package/src/types/enum/discord-presence-status.enum.ts +8 -8
  64. package/src/types/enum/discord-sync-status.enum.ts +6 -6
  65. package/src/types/enum/discord-token-state.enum.ts +11 -11
  66. package/src/types/enum/execution-mode.enum.ts +9 -9
  67. package/src/types/enum/execution-profile.enum.ts +20 -20
  68. package/src/types/enum/execution-settings-source.enum.ts +9 -9
  69. package/src/types/enum/health-status.enum.ts +4 -4
  70. package/src/types/enum/insights-period.enum.ts +8 -8
  71. package/src/types/enum/log-cap-mode.enum.ts +6 -6
  72. package/src/types/enum/log-drop-cause.enum.ts +8 -8
  73. package/src/types/enum/reflex-alert-metric.enum.ts +5 -5
  74. package/src/types/enum/reflex-alert-notification-state.enum.ts +6 -6
  75. package/src/types/enum/reflex-alert-scope.enum.ts +6 -6
  76. package/src/types/enum/route-method.enum.ts +9 -9
  77. package/src/types/enum/run-log-level.enum.ts +6 -6
  78. package/src/types/enum/run-mode.enum.ts +11 -11
  79. package/src/types/enum/run-step-status.enum.ts +7 -7
  80. package/src/types/enum/schedule-sync-status.enum.ts +6 -6
  81. package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
  82. package/src/types/enum/scheduled-run-status.enum.ts +17 -17
  83. package/src/types/enum/service-deployment-action.enum.ts +11 -11
  84. package/src/types/enum/service-deployment-status.enum.ts +5 -5
  85. package/src/types/enum/service-type.enum.ts +9 -9
  86. package/src/types/enum/service-version-change-kind.enum.ts +6 -6
  87. package/src/types/enum/trace-effect-type.enum.ts +12 -12
  88. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  89. package/src/types/enum/trigger-kind.enum.ts +8 -8
  90. package/src/types/enum/vault-value-source.enum.ts +12 -12
  91. package/src/types/enum/vault-visibility.enum.ts +5 -5
  92. package/src/types/index.ts +2 -2
  93. package/src/types/interface/api/index.ts +3 -3
  94. package/src/types/interface/api/requests/alert-rule.request.ts +53 -53
  95. package/src/types/interface/api/requests/application-insights.request.ts +18 -18
  96. package/src/types/interface/api/requests/application-run-settings.request.ts +11 -11
  97. package/src/types/interface/api/requests/function-access.request.ts +51 -51
  98. package/src/types/interface/api/requests/function-settings.request.ts +34 -34
  99. package/src/types/interface/api/requests/function-template.request.ts +29 -29
  100. package/src/types/interface/api/requests/function-version.request.ts +38 -38
  101. package/src/types/interface/api/requests/function.request.ts +36 -36
  102. package/src/types/interface/api/requests/route-stats.request.ts +22 -22
  103. package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
  104. package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
  105. package/src/types/interface/api/requests/service-discord-event.request.ts +68 -68
  106. package/src/types/interface/api/requests/service-insights.request.ts +31 -31
  107. package/src/types/interface/api/requests/service-task.request.ts +80 -80
  108. package/src/types/interface/api/requests/service-version.request.ts +24 -24
  109. package/src/types/interface/api/requests/service.request.ts +46 -46
  110. package/src/types/interface/api/response.ts +4 -4
  111. package/src/types/interface/api/responses/alert-rule.response.ts +24 -24
  112. package/src/types/interface/api/responses/application-insights.response.ts +11 -11
  113. package/src/types/interface/api/responses/application-run-settings.response.ts +8 -8
  114. package/src/types/interface/api/responses/function-access.response.ts +45 -45
  115. package/src/types/interface/api/responses/function-run.response.ts +18 -18
  116. package/src/types/interface/api/responses/function-template.response.ts +21 -21
  117. package/src/types/interface/api/responses/function-version.response.ts +42 -42
  118. package/src/types/interface/api/responses/function.response.ts +25 -25
  119. package/src/types/interface/api/responses/route-stats.response.ts +15 -15
  120. package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
  121. package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
  122. package/src/types/interface/api/responses/service-discord-event.response.ts +24 -24
  123. package/src/types/interface/api/responses/service-insights.response.ts +11 -11
  124. package/src/types/interface/api/responses/service-task.response.ts +57 -57
  125. package/src/types/interface/api/responses/service-version.response.ts +112 -112
  126. package/src/types/interface/api/responses/service.response.ts +31 -31
  127. package/src/types/interface/health.response.ts +7 -7
  128. package/src/types/interface/index.ts +3 -3
  129. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  130. package/src/types/interface/models/reflex-access-request.model.ts +15 -15
  131. package/src/types/interface/models/reflex-alert-rule.model.ts +56 -56
  132. package/src/types/interface/models/reflex-definition.model.ts +31 -31
  133. package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -58
  134. package/src/types/interface/models/reflex-discord-event.model.ts +79 -79
  135. package/src/types/interface/models/reflex-discord.model.ts +196 -196
  136. package/src/types/interface/models/reflex-function-template.model.ts +18 -18
  137. package/src/types/interface/models/reflex-function-version.model.ts +19 -19
  138. package/src/types/interface/models/reflex-function.model.ts +30 -30
  139. package/src/types/interface/models/reflex-insights.model.ts +215 -215
  140. package/src/types/interface/models/reflex-price-list.model.ts +20 -20
  141. package/src/types/interface/models/reflex-run-settings.model.ts +28 -28
  142. package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
  143. package/src/types/interface/models/reflex-service-deployment.model.ts +46 -46
  144. package/src/types/interface/models/reflex-service-limits.model.ts +17 -8
  145. package/src/types/interface/models/reflex-service.model.ts +45 -45
  146. package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
  147. package/src/types/interface/models/reflex-task.model.ts +97 -97
  148. package/tsconfig.check.json +15 -15
  149. package/tsconfig.json +35 -35
@@ -1,140 +1,140 @@
1
- import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
- import { AbyssReflexCore, REFLEX_TASK_LIMITS } 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
- params?: unknown;
15
- run: () => Promise<unknown>;
16
- }
17
-
18
- const task = () => AbyssReflexCore.sdk.service.task;
19
-
20
- const created = {
21
- name: 'daily-report',
22
- functionId: 'fn-1',
23
- schedule: '0 9 * * *',
24
- timezone: 'Europe/Paris',
25
- };
26
-
27
- const calls: Call[] = [
28
- {
29
- label: 'list',
30
- method: 'get',
31
- url: `${BASE}/task`,
32
- run: () => task().list(SERVICE),
33
- },
34
- {
35
- label: 'create',
36
- method: 'post',
37
- url: `${BASE}/task`,
38
- body: created,
39
- run: () => task().create(SERVICE, created),
40
- },
41
- {
42
- label: 'update',
43
- method: 'patch',
44
- url: `${BASE}/task/t-1`,
45
- body: { schedule: null },
46
- run: () => task().update({ ...SERVICE, taskId: 't-1' }, { schedule: null }),
47
- },
48
- {
49
- label: 'delete',
50
- method: 'delete',
51
- url: `${BASE}/task/t-1`,
52
- run: () => task().delete({ ...SERVICE, taskId: 't-1' }),
53
- },
54
- {
55
- label: 'testRun',
56
- method: 'post',
57
- url: `${BASE}/task/t-1/test-run`,
58
- body: { environmentId: 'e-1' },
59
- run: () => task().testRun({ ...SERVICE, taskId: 't-1' }, { environmentId: 'e-1' }),
60
- },
61
- {
62
- label: 'scheduledRun.list',
63
- method: 'get',
64
- url: `${BASE}/task/t-1/environment/e-1/scheduled-run`,
65
- params: { limit: 20, offset: 40 },
66
- run: () =>
67
- task().scheduledRun.list(
68
- { ...SERVICE, taskId: 't-1', environmentId: 'e-1' },
69
- { limit: 20, offset: 40 },
70
- ),
71
- },
72
- {
73
- label: 'delayedRun.list',
74
- method: 'get',
75
- url: `${BASE}/environment/e-1/delayed-run`,
76
- run: () => task().delayedRun.list({ ...SERVICE, environmentId: 'e-1' }),
77
- },
78
- {
79
- label: 'delayedRun.cancel',
80
- method: 'delete',
81
- url: `${BASE}/environment/e-1/delayed-run/d-1`,
82
- run: () => task().delayedRun.cancel({ ...SERVICE, environmentId: 'e-1', delayedRunId: 'd-1' }),
83
- },
84
- {
85
- label: 'sync',
86
- method: 'post',
87
- url: `${BASE}/deployment/e-1/schedule-sync`,
88
- body: {},
89
- run: () => task().sync({ ...SERVICE, environmentId: 'e-1' }),
90
- },
91
- ];
92
-
93
- describe('AbyssReflexCore task routes', () => {
94
- const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
95
- async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
96
- );
97
-
98
- beforeAll(() => {
99
- AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
100
- AbyssReflexCore.axios.defaults.adapter = adapter;
101
- });
102
-
103
- beforeEach(() => adapter.mockClear());
104
-
105
- it.each(calls)('$label calls $method $url', async (call) => {
106
- await call.run();
107
-
108
- const config = adapter.mock.calls[0][0];
109
- expect(config.method).toBe(call.method);
110
- expect(config.url).toBe(call.url);
111
- expect(config.baseURL).toBe('http://reflex.test/');
112
- if (call.body !== undefined) {
113
- expect(JSON.parse(config.data)).toEqual(call.body);
114
- }
115
- if (call.params !== undefined) {
116
- expect(config.params).toEqual(call.params);
117
- }
118
- });
119
-
120
- it('exposes no route twice', () => {
121
- expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
122
- });
123
-
124
- it('carries the bounds of the tasks and of their delayed runs', () => {
125
- expect(REFLEX_TASK_LIMITS).toMatchObject({
126
- maxTasksPerService: 20,
127
- nameMaxLength: 32,
128
- payloadMaxLength: 4096,
129
- delayMinSeconds: 1,
130
- delayMaxDays: 30,
131
- recurringToleranceMinutes: 5,
132
- delayedToleranceMinutes: 60,
133
- maxAttempts: 3,
134
- scheduledRunPageMax: 50,
135
- });
136
- expect(REFLEX_TASK_LIMITS.namePattern.test('daily-report_2')).toBe(true);
137
- expect(REFLEX_TASK_LIMITS.namePattern.test('Daily')).toBe(false);
138
- expect(REFLEX_TASK_LIMITS.namePattern.test('a'.repeat(33))).toBe(false);
139
- });
140
- });
1
+ import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
+ import { AbyssReflexCore, REFLEX_TASK_LIMITS } 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
+ params?: unknown;
15
+ run: () => Promise<unknown>;
16
+ }
17
+
18
+ const task = () => AbyssReflexCore.sdk.service.task;
19
+
20
+ const created = {
21
+ name: 'daily-report',
22
+ functionId: 'fn-1',
23
+ schedule: '0 9 * * *',
24
+ timezone: 'Europe/Paris',
25
+ };
26
+
27
+ const calls: Call[] = [
28
+ {
29
+ label: 'list',
30
+ method: 'get',
31
+ url: `${BASE}/task`,
32
+ run: () => task().list(SERVICE),
33
+ },
34
+ {
35
+ label: 'create',
36
+ method: 'post',
37
+ url: `${BASE}/task`,
38
+ body: created,
39
+ run: () => task().create(SERVICE, created),
40
+ },
41
+ {
42
+ label: 'update',
43
+ method: 'patch',
44
+ url: `${BASE}/task/t-1`,
45
+ body: { schedule: null },
46
+ run: () => task().update({ ...SERVICE, taskId: 't-1' }, { schedule: null }),
47
+ },
48
+ {
49
+ label: 'delete',
50
+ method: 'delete',
51
+ url: `${BASE}/task/t-1`,
52
+ run: () => task().delete({ ...SERVICE, taskId: 't-1' }),
53
+ },
54
+ {
55
+ label: 'testRun',
56
+ method: 'post',
57
+ url: `${BASE}/task/t-1/test-run`,
58
+ body: { environmentId: 'e-1' },
59
+ run: () => task().testRun({ ...SERVICE, taskId: 't-1' }, { environmentId: 'e-1' }),
60
+ },
61
+ {
62
+ label: 'scheduledRun.list',
63
+ method: 'get',
64
+ url: `${BASE}/task/t-1/environment/e-1/scheduled-run`,
65
+ params: { limit: 20, offset: 40 },
66
+ run: () =>
67
+ task().scheduledRun.list(
68
+ { ...SERVICE, taskId: 't-1', environmentId: 'e-1' },
69
+ { limit: 20, offset: 40 },
70
+ ),
71
+ },
72
+ {
73
+ label: 'delayedRun.list',
74
+ method: 'get',
75
+ url: `${BASE}/environment/e-1/delayed-run`,
76
+ run: () => task().delayedRun.list({ ...SERVICE, environmentId: 'e-1' }),
77
+ },
78
+ {
79
+ label: 'delayedRun.cancel',
80
+ method: 'delete',
81
+ url: `${BASE}/environment/e-1/delayed-run/d-1`,
82
+ run: () => task().delayedRun.cancel({ ...SERVICE, environmentId: 'e-1', delayedRunId: 'd-1' }),
83
+ },
84
+ {
85
+ label: 'sync',
86
+ method: 'post',
87
+ url: `${BASE}/deployment/e-1/schedule-sync`,
88
+ body: {},
89
+ run: () => task().sync({ ...SERVICE, environmentId: 'e-1' }),
90
+ },
91
+ ];
92
+
93
+ describe('AbyssReflexCore task routes', () => {
94
+ const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
95
+ async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
96
+ );
97
+
98
+ beforeAll(() => {
99
+ AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
100
+ AbyssReflexCore.axios.defaults.adapter = adapter;
101
+ });
102
+
103
+ beforeEach(() => adapter.mockClear());
104
+
105
+ it.each(calls)('$label calls $method $url', async (call) => {
106
+ await call.run();
107
+
108
+ const config = adapter.mock.calls[0][0];
109
+ expect(config.method).toBe(call.method);
110
+ expect(config.url).toBe(call.url);
111
+ expect(config.baseURL).toBe('http://reflex.test/');
112
+ if (call.body !== undefined) {
113
+ expect(JSON.parse(config.data)).toEqual(call.body);
114
+ }
115
+ if (call.params !== undefined) {
116
+ expect(config.params).toEqual(call.params);
117
+ }
118
+ });
119
+
120
+ it('exposes no route twice', () => {
121
+ expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
122
+ });
123
+
124
+ it('carries the bounds of the tasks and of their delayed runs', () => {
125
+ expect(REFLEX_TASK_LIMITS).toMatchObject({
126
+ maxTasksPerService: 20,
127
+ nameMaxLength: 32,
128
+ payloadMaxLength: 4096,
129
+ delayMinSeconds: 1,
130
+ delayMaxDays: 30,
131
+ recurringToleranceMinutes: 5,
132
+ delayedToleranceMinutes: 60,
133
+ maxAttempts: 3,
134
+ scheduledRunPageMax: 50,
135
+ });
136
+ expect(REFLEX_TASK_LIMITS.namePattern.test('daily-report_2')).toBe(true);
137
+ expect(REFLEX_TASK_LIMITS.namePattern.test('Daily')).toBe(false);
138
+ expect(REFLEX_TASK_LIMITS.namePattern.test('a'.repeat(33))).toBe(false);
139
+ });
140
+ });
@@ -1,141 +1,141 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- ICancelServiceDelayedRunParams,
4
- ICancelServiceDelayedRunResponse,
5
- ICreateServiceTaskBody,
6
- ICreateServiceTaskParams,
7
- ICreateServiceTaskResponse,
8
- IDeleteServiceTaskParams,
9
- IDeleteServiceTaskResponse,
10
- IListServiceDelayedRunParams,
11
- IListServiceDelayedRunResponse,
12
- IListServiceTaskParams,
13
- IListServiceTaskResponse,
14
- IListServiceTaskScheduledRunParams,
15
- IListServiceTaskScheduledRunQuery,
16
- IListServiceTaskScheduledRunResponse,
17
- IRetryServiceScheduleSyncParams,
18
- IRetryServiceScheduleSyncResponse,
19
- ITestRunServiceTaskBody,
20
- ITestRunServiceTaskParams,
21
- ITestRunServiceTaskResponse,
22
- IUpdateServiceTaskBody,
23
- IUpdateServiceTaskParams,
24
- IUpdateServiceTaskResponse,
25
- } from '../types';
26
-
27
- const serviceUrl = (params: { applicationId: string; serviceId: string }): string =>
28
- `api/service/${params.applicationId}/${params.serviceId}`;
29
-
30
- const taskUrl = (params: { applicationId: string; serviceId: string }): string =>
31
- `${serviceUrl(params)}/task`;
32
-
33
- const delayedRunUrl = (params: {
34
- applicationId: string;
35
- serviceId: string;
36
- environmentId: string;
37
- }): string => `${serviceUrl(params)}/environment/${params.environmentId}/delayed-run`;
38
-
39
- /** `GET .../task`: the tasks of the draft of the Service, by name. Needs REFLEX_READ. */
40
- export const listServiceTask = async (
41
- params: IListServiceTaskParams,
42
- ): Promise<IListServiceTaskResponse> =>
43
- (await AbyssReflexCore.axios.get<IListServiceTaskResponse>(taskUrl(params))).data;
44
-
45
- /**
46
- * `POST .../task`: a task of the draft, scheduled with Flow once a version holding it is in service.
47
- * Refused when the name is taken, the cron ticks more than once a minute, the time zone is unknown or
48
- * the Service already has `REFLEX_TASK_LIMITS.maxTasksPerService` tasks. Needs REFLEX_FUNCTION_UPDATE.
49
- */
50
- export const createServiceTask = async (
51
- params: ICreateServiceTaskParams,
52
- body: ICreateServiceTaskBody,
53
- ): Promise<ICreateServiceTaskResponse> =>
54
- (await AbyssReflexCore.axios.post<ICreateServiceTaskResponse>(taskUrl(params), body)).data;
55
-
56
- /** `PATCH .../task/:taskId`: changes the task in the draft. Needs REFLEX_FUNCTION_UPDATE. */
57
- export const updateServiceTask = async (
58
- params: IUpdateServiceTaskParams,
59
- body: IUpdateServiceTaskBody,
60
- ): Promise<IUpdateServiceTaskResponse> =>
61
- (
62
- await AbyssReflexCore.axios.patch<IUpdateServiceTaskResponse>(
63
- `${taskUrl(params)}/${params.taskId}`,
64
- body,
65
- )
66
- ).data;
67
-
68
- /** `DELETE .../task/:taskId`: takes the task out of the draft. Needs REFLEX_FUNCTION_UPDATE. */
69
- export const deleteServiceTask = async (
70
- params: IDeleteServiceTaskParams,
71
- ): Promise<IDeleteServiceTaskResponse> =>
72
- (
73
- await AbyssReflexCore.axios.delete<IDeleteServiceTaskResponse>(
74
- `${taskUrl(params)}/${params.taskId}`,
75
- )
76
- ).data;
77
-
78
- /**
79
- * `POST .../task/:taskId/test-run`: runs the task now as a test run of its function in the environment
80
- * `body.environmentId`, with a `SCHEDULE` input; nothing is queued. Needs REFLEX_TEST_RUN.
81
- */
82
- export const testRunServiceTask = async (
83
- params: ITestRunServiceTaskParams,
84
- body: ITestRunServiceTaskBody,
85
- ): Promise<ITestRunServiceTaskResponse> =>
86
- (
87
- await AbyssReflexCore.axios.post<ITestRunServiceTaskResponse>(
88
- `${taskUrl(params)}/${params.taskId}/test-run`,
89
- body,
90
- )
91
- ).data;
92
-
93
- /**
94
- * `GET .../task/:taskId/environment/:environmentId/scheduled-run`: the runs of the task in the environment, every
95
- * status (EXPIRED, SKIPPED, CANCELLED and FAILED with their `failureCode` included), newest due first, paged by
96
- * `limit` (50 at most) and `offset`. Needs REFLEX_READ.
97
- */
98
- export const listServiceTaskScheduledRun = async (
99
- params: IListServiceTaskScheduledRunParams,
100
- query: IListServiceTaskScheduledRunQuery = {},
101
- ): Promise<IListServiceTaskScheduledRunResponse> =>
102
- (
103
- await AbyssReflexCore.axios.get<IListServiceTaskScheduledRunResponse>(
104
- `${taskUrl(params)}/${params.taskId}/environment/${params.environmentId}/scheduled-run`,
105
- { params: query },
106
- )
107
- ).data;
108
-
109
- /** `GET .../environment/:environmentId/delayed-run`: the first 100 pending delayed runs of the environment. Needs REFLEX_READ. */
110
- export const listServiceDelayedRun = async (
111
- params: IListServiceDelayedRunParams,
112
- ): Promise<IListServiceDelayedRunResponse> =>
113
- (await AbyssReflexCore.axios.get<IListServiceDelayedRunResponse>(delayedRunUrl(params))).data;
114
-
115
- /**
116
- * `DELETE .../environment/:environmentId/delayed-run/:delayedRunId`: cancels a pending delayed run.
117
- * Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION in a production environment.
118
- */
119
- export const cancelServiceDelayedRun = async (
120
- params: ICancelServiceDelayedRunParams,
121
- ): Promise<ICancelServiceDelayedRunResponse> =>
122
- (
123
- await AbyssReflexCore.axios.delete<ICancelServiceDelayedRunResponse>(
124
- `${delayedRunUrl(params)}/${params.delayedRunId}`,
125
- )
126
- ).data;
127
-
128
- /**
129
- * `POST .../deployment/:environmentId/schedule-sync`: synchronizes the cron tasks of the version in
130
- * service with Flow again, without a new version. Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION
131
- * in a production environment.
132
- */
133
- export const retryServiceScheduleSync = async (
134
- params: IRetryServiceScheduleSyncParams,
135
- ): Promise<IRetryServiceScheduleSyncResponse> =>
136
- (
137
- await AbyssReflexCore.axios.post<IRetryServiceScheduleSyncResponse>(
138
- `${serviceUrl(params)}/deployment/${params.environmentId}/schedule-sync`,
139
- {},
140
- )
141
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ ICancelServiceDelayedRunParams,
4
+ ICancelServiceDelayedRunResponse,
5
+ ICreateServiceTaskBody,
6
+ ICreateServiceTaskParams,
7
+ ICreateServiceTaskResponse,
8
+ IDeleteServiceTaskParams,
9
+ IDeleteServiceTaskResponse,
10
+ IListServiceDelayedRunParams,
11
+ IListServiceDelayedRunResponse,
12
+ IListServiceTaskParams,
13
+ IListServiceTaskResponse,
14
+ IListServiceTaskScheduledRunParams,
15
+ IListServiceTaskScheduledRunQuery,
16
+ IListServiceTaskScheduledRunResponse,
17
+ IRetryServiceScheduleSyncParams,
18
+ IRetryServiceScheduleSyncResponse,
19
+ ITestRunServiceTaskBody,
20
+ ITestRunServiceTaskParams,
21
+ ITestRunServiceTaskResponse,
22
+ IUpdateServiceTaskBody,
23
+ IUpdateServiceTaskParams,
24
+ IUpdateServiceTaskResponse,
25
+ } from '../types';
26
+
27
+ const serviceUrl = (params: { applicationId: string; serviceId: string }): string =>
28
+ `api/service/${params.applicationId}/${params.serviceId}`;
29
+
30
+ const taskUrl = (params: { applicationId: string; serviceId: string }): string =>
31
+ `${serviceUrl(params)}/task`;
32
+
33
+ const delayedRunUrl = (params: {
34
+ applicationId: string;
35
+ serviceId: string;
36
+ environmentId: string;
37
+ }): string => `${serviceUrl(params)}/environment/${params.environmentId}/delayed-run`;
38
+
39
+ /** `GET .../task`: the tasks of the draft of the Service, by name. Needs REFLEX_READ. */
40
+ export const listServiceTask = async (
41
+ params: IListServiceTaskParams,
42
+ ): Promise<IListServiceTaskResponse> =>
43
+ (await AbyssReflexCore.axios.get<IListServiceTaskResponse>(taskUrl(params))).data;
44
+
45
+ /**
46
+ * `POST .../task`: a task of the draft, scheduled with Flow once a version holding it is in service.
47
+ * Refused when the name is taken, the cron ticks more than once a minute, the time zone is unknown or
48
+ * the Service already has `REFLEX_TASK_LIMITS.maxTasksPerService` tasks. Needs REFLEX_FUNCTION_UPDATE.
49
+ */
50
+ export const createServiceTask = async (
51
+ params: ICreateServiceTaskParams,
52
+ body: ICreateServiceTaskBody,
53
+ ): Promise<ICreateServiceTaskResponse> =>
54
+ (await AbyssReflexCore.axios.post<ICreateServiceTaskResponse>(taskUrl(params), body)).data;
55
+
56
+ /** `PATCH .../task/:taskId`: changes the task in the draft. Needs REFLEX_FUNCTION_UPDATE. */
57
+ export const updateServiceTask = async (
58
+ params: IUpdateServiceTaskParams,
59
+ body: IUpdateServiceTaskBody,
60
+ ): Promise<IUpdateServiceTaskResponse> =>
61
+ (
62
+ await AbyssReflexCore.axios.patch<IUpdateServiceTaskResponse>(
63
+ `${taskUrl(params)}/${params.taskId}`,
64
+ body,
65
+ )
66
+ ).data;
67
+
68
+ /** `DELETE .../task/:taskId`: takes the task out of the draft. Needs REFLEX_FUNCTION_UPDATE. */
69
+ export const deleteServiceTask = async (
70
+ params: IDeleteServiceTaskParams,
71
+ ): Promise<IDeleteServiceTaskResponse> =>
72
+ (
73
+ await AbyssReflexCore.axios.delete<IDeleteServiceTaskResponse>(
74
+ `${taskUrl(params)}/${params.taskId}`,
75
+ )
76
+ ).data;
77
+
78
+ /**
79
+ * `POST .../task/:taskId/test-run`: runs the task now as a test run of its function in the environment
80
+ * `body.environmentId`, with a `SCHEDULE` input; nothing is queued. Needs REFLEX_TEST_RUN.
81
+ */
82
+ export const testRunServiceTask = async (
83
+ params: ITestRunServiceTaskParams,
84
+ body: ITestRunServiceTaskBody,
85
+ ): Promise<ITestRunServiceTaskResponse> =>
86
+ (
87
+ await AbyssReflexCore.axios.post<ITestRunServiceTaskResponse>(
88
+ `${taskUrl(params)}/${params.taskId}/test-run`,
89
+ body,
90
+ )
91
+ ).data;
92
+
93
+ /**
94
+ * `GET .../task/:taskId/environment/:environmentId/scheduled-run`: the runs of the task in the environment, every
95
+ * status (EXPIRED, SKIPPED, CANCELLED and FAILED with their `failureCode` included), newest due first, paged by
96
+ * `limit` (50 at most) and `offset`. Needs REFLEX_READ.
97
+ */
98
+ export const listServiceTaskScheduledRun = async (
99
+ params: IListServiceTaskScheduledRunParams,
100
+ query: IListServiceTaskScheduledRunQuery = {},
101
+ ): Promise<IListServiceTaskScheduledRunResponse> =>
102
+ (
103
+ await AbyssReflexCore.axios.get<IListServiceTaskScheduledRunResponse>(
104
+ `${taskUrl(params)}/${params.taskId}/environment/${params.environmentId}/scheduled-run`,
105
+ { params: query },
106
+ )
107
+ ).data;
108
+
109
+ /** `GET .../environment/:environmentId/delayed-run`: the first 100 pending delayed runs of the environment. Needs REFLEX_READ. */
110
+ export const listServiceDelayedRun = async (
111
+ params: IListServiceDelayedRunParams,
112
+ ): Promise<IListServiceDelayedRunResponse> =>
113
+ (await AbyssReflexCore.axios.get<IListServiceDelayedRunResponse>(delayedRunUrl(params))).data;
114
+
115
+ /**
116
+ * `DELETE .../environment/:environmentId/delayed-run/:delayedRunId`: cancels a pending delayed run.
117
+ * Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION in a production environment.
118
+ */
119
+ export const cancelServiceDelayedRun = async (
120
+ params: ICancelServiceDelayedRunParams,
121
+ ): Promise<ICancelServiceDelayedRunResponse> =>
122
+ (
123
+ await AbyssReflexCore.axios.delete<ICancelServiceDelayedRunResponse>(
124
+ `${delayedRunUrl(params)}/${params.delayedRunId}`,
125
+ )
126
+ ).data;
127
+
128
+ /**
129
+ * `POST .../deployment/:environmentId/schedule-sync`: synchronizes the cron tasks of the version in
130
+ * service with Flow again, without a new version. Needs REFLEX_PUBLISH, and REFLEX_PUBLISH_PRODUCTION
131
+ * in a production environment.
132
+ */
133
+ export const retryServiceScheduleSync = async (
134
+ params: IRetryServiceScheduleSyncParams,
135
+ ): Promise<IRetryServiceScheduleSyncResponse> =>
136
+ (
137
+ await AbyssReflexCore.axios.post<IRetryServiceScheduleSyncResponse>(
138
+ `${serviceUrl(params)}/deployment/${params.environmentId}/schedule-sync`,
139
+ {},
140
+ )
141
+ ).data;