@abyss-project/reflex 5.6.0 → 5.7.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.
Files changed (99) 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-discord-event.model.d.ts +1 -1
  5. package/dist/types/interface/models/reflex-discord-event.model.js +1 -1
  6. package/dist/types/interface/models/reflex-discord-event.model.js.map +1 -1
  7. package/jest.config.ts +11 -11
  8. package/package.json +1 -1
  9. package/src/api/function-access.api.ts +36 -36
  10. package/src/api/function-run.api.ts +38 -38
  11. package/src/api/function-settings.api.ts +59 -59
  12. package/src/api/function-test.api.ts +34 -34
  13. package/src/api/function-version.api.ts +48 -48
  14. package/src/api/function.api.test.ts +249 -249
  15. package/src/api/function.api.ts +62 -62
  16. package/src/api/health.api.ts +10 -10
  17. package/src/api/service-configuration.api.ts +16 -16
  18. package/src/api/service-deployment.api.ts +79 -79
  19. package/src/api/service-route.api.ts +72 -72
  20. package/src/api/service-task.api.test.ts +140 -140
  21. package/src/api/service-task.api.ts +141 -141
  22. package/src/api/service-version.api.ts +54 -54
  23. package/src/api/service.api.test.ts +215 -215
  24. package/src/api/service.api.ts +55 -55
  25. package/src/types/enum/access-grant-status.enum.ts +12 -12
  26. package/src/types/enum/access-kind.enum.ts +7 -7
  27. package/src/types/enum/configuration-read-as.enum.ts +5 -5
  28. package/src/types/enum/discord-activity-type.enum.ts +9 -9
  29. package/src/types/enum/discord-component-kind.enum.ts +7 -7
  30. package/src/types/enum/discord-gateway-state.enum.ts +11 -11
  31. package/src/types/enum/discord-option-type.enum.ts +12 -12
  32. package/src/types/enum/discord-presence-status.enum.ts +8 -8
  33. package/src/types/enum/discord-sync-status.enum.ts +6 -6
  34. package/src/types/enum/discord-token-state.enum.ts +11 -11
  35. package/src/types/enum/execution-mode.enum.ts +9 -9
  36. package/src/types/enum/execution-profile.enum.ts +20 -20
  37. package/src/types/enum/execution-settings-source.enum.ts +9 -9
  38. package/src/types/enum/health-status.enum.ts +4 -4
  39. package/src/types/enum/route-method.enum.ts +9 -9
  40. package/src/types/enum/run-log-level.enum.ts +6 -6
  41. package/src/types/enum/run-mode.enum.ts +11 -11
  42. package/src/types/enum/run-status.enum.ts +11 -11
  43. package/src/types/enum/run-step-status.enum.ts +7 -7
  44. package/src/types/enum/schedule-sync-status.enum.ts +6 -6
  45. package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
  46. package/src/types/enum/scheduled-run-status.enum.ts +17 -17
  47. package/src/types/enum/service-deployment-action.enum.ts +11 -11
  48. package/src/types/enum/service-deployment-status.enum.ts +5 -5
  49. package/src/types/enum/service-type.enum.ts +9 -9
  50. package/src/types/enum/service-version-change-kind.enum.ts +6 -6
  51. package/src/types/enum/trace-effect-type.enum.ts +12 -12
  52. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  53. package/src/types/enum/vault-value-source.enum.ts +12 -12
  54. package/src/types/enum/vault-visibility.enum.ts +5 -5
  55. package/src/types/index.ts +2 -2
  56. package/src/types/interface/api/index.ts +3 -3
  57. package/src/types/interface/api/requests/function-access.request.ts +25 -25
  58. package/src/types/interface/api/requests/function-run.request.ts +30 -30
  59. package/src/types/interface/api/requests/function-settings.request.ts +27 -27
  60. package/src/types/interface/api/requests/function-test.request.ts +39 -39
  61. package/src/types/interface/api/requests/function-version.request.ts +20 -20
  62. package/src/types/interface/api/requests/function.request.ts +36 -36
  63. package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
  64. package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
  65. package/src/types/interface/api/requests/service-route.request.ts +44 -44
  66. package/src/types/interface/api/requests/service-task.request.ts +80 -80
  67. package/src/types/interface/api/requests/service-version.request.ts +24 -24
  68. package/src/types/interface/api/requests/service.request.ts +46 -46
  69. package/src/types/interface/api/response.ts +4 -4
  70. package/src/types/interface/api/responses/function-access.response.ts +17 -17
  71. package/src/types/interface/api/responses/function-run.response.ts +18 -18
  72. package/src/types/interface/api/responses/function-settings.response.ts +36 -36
  73. package/src/types/interface/api/responses/function-test.response.ts +12 -12
  74. package/src/types/interface/api/responses/function-version.response.ts +31 -31
  75. package/src/types/interface/api/responses/function.response.ts +25 -25
  76. package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
  77. package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
  78. package/src/types/interface/api/responses/service-route.response.ts +31 -31
  79. package/src/types/interface/api/responses/service-task.response.ts +57 -57
  80. package/src/types/interface/api/responses/service.response.ts +31 -31
  81. package/src/types/interface/health.response.ts +7 -7
  82. package/src/types/interface/index.ts +3 -3
  83. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  84. package/src/types/interface/models/reflex-definition.model.ts +31 -31
  85. package/src/types/interface/models/reflex-discord-event.model.ts +7 -6
  86. package/src/types/interface/models/reflex-discord.model.ts +146 -146
  87. package/src/types/interface/models/reflex-execution-settings.model.ts +50 -50
  88. package/src/types/interface/models/reflex-function-version.model.ts +14 -14
  89. package/src/types/interface/models/reflex-function.model.ts +16 -16
  90. package/src/types/interface/models/reflex-price-list.model.ts +20 -20
  91. package/src/types/interface/models/reflex-route.model.ts +19 -19
  92. package/src/types/interface/models/reflex-run.model.ts +4 -1
  93. package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
  94. package/src/types/interface/models/reflex-service-deployment.model.ts +46 -46
  95. package/src/types/interface/models/reflex-service.model.ts +45 -45
  96. package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
  97. package/src/types/interface/models/reflex-task.model.ts +97 -97
  98. package/tsconfig.check.json +15 -15
  99. package/tsconfig.json +35 -35
@@ -1,215 +1,215 @@
1
- import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
- import {
3
- AbyssReflexCore,
4
- REFLEX_SERVICE_LIMITS,
5
- RouteMethod,
6
- ServiceType,
7
- TriggerAccessMode,
8
- } from '..';
9
-
10
- const APP = 'app-1';
11
- const SVC = 'svc-1';
12
- const BASE = `api/service/${APP}/${SVC}`;
13
- const SERVICE = { applicationId: APP, serviceId: SVC };
14
-
15
- interface Call {
16
- label: string;
17
- method: string;
18
- url: string;
19
- body?: unknown;
20
- params?: unknown;
21
- run: () => Promise<unknown>;
22
- }
23
-
24
- const sdk = () => AbyssReflexCore.sdk.service;
25
-
26
- const calls: Call[] = [
27
- {
28
- label: 'list',
29
- method: 'get',
30
- url: `api/service/${APP}`,
31
- run: () => sdk().list({ applicationId: APP }),
32
- },
33
- {
34
- label: 'create',
35
- method: 'post',
36
- url: `api/service/${APP}`,
37
- body: { name: 'Shop', slug: 'shop', type: ServiceType.HTTP_API },
38
- run: () =>
39
- sdk().create(
40
- { applicationId: APP },
41
- { name: 'Shop', slug: 'shop', type: ServiceType.HTTP_API },
42
- ),
43
- },
44
- { label: 'get', method: 'get', url: BASE, run: () => sdk().get(SERVICE) },
45
- {
46
- label: 'update',
47
- method: 'patch',
48
- url: BASE,
49
- body: { cors: { allowedOrigins: ['https://shop.example'] }, rateLimitPerIpPerMinute: 120 },
50
- run: () =>
51
- sdk().update(SERVICE, {
52
- cors: { allowedOrigins: ['https://shop.example'] },
53
- rateLimitPerIpPerMinute: 120,
54
- }),
55
- },
56
- { label: 'delete', method: 'delete', url: BASE, run: () => sdk().delete(SERVICE) },
57
- {
58
- label: 'route.list',
59
- method: 'get',
60
- url: `${BASE}/route`,
61
- run: () => sdk().route.list(SERVICE),
62
- },
63
- {
64
- label: 'route.create',
65
- method: 'post',
66
- url: `${BASE}/route`,
67
- body: {
68
- method: RouteMethod.GET,
69
- path: 'orders/:id',
70
- functionId: 'fn-1',
71
- accessMode: TriggerAccessMode.API_KEY,
72
- },
73
- run: () =>
74
- sdk().route.create(SERVICE, {
75
- method: RouteMethod.GET,
76
- path: 'orders/:id',
77
- functionId: 'fn-1',
78
- accessMode: TriggerAccessMode.API_KEY,
79
- }),
80
- },
81
- {
82
- label: 'route.update',
83
- method: 'patch',
84
- url: `${BASE}/route/r-1`,
85
- body: { path: 'orders/:ref' },
86
- run: () => sdk().route.update({ ...SERVICE, routeId: 'r-1' }, { path: 'orders/:ref' }),
87
- },
88
- {
89
- label: 'route.delete',
90
- method: 'delete',
91
- url: `${BASE}/route/r-1`,
92
- run: () => sdk().route.delete({ ...SERVICE, routeId: 'r-1' }),
93
- },
94
- {
95
- label: 'route.rotate',
96
- method: 'post',
97
- url: `${BASE}/route/r-1/rotate`,
98
- body: {},
99
- run: () => sdk().route.rotate({ ...SERVICE, routeId: 'r-1' }),
100
- },
101
- {
102
- label: 'version.list',
103
- method: 'get',
104
- url: `${BASE}/version`,
105
- run: () => sdk().version.list(SERVICE),
106
- },
107
- {
108
- label: 'version.create',
109
- method: 'post',
110
- url: `${BASE}/version`,
111
- body: { message: 'orders by id' },
112
- run: () => sdk().version.create(SERVICE, { message: 'orders by id' }),
113
- },
114
- {
115
- label: 'version.draftStatus',
116
- method: 'get',
117
- url: `${BASE}/version/draft-status`,
118
- run: () => sdk().version.draftStatus(SERVICE),
119
- },
120
- {
121
- label: 'version.get',
122
- method: 'get',
123
- url: `${BASE}/version/v-1`,
124
- run: () => sdk().version.get({ ...SERVICE, versionId: 'v-1' }),
125
- },
126
- {
127
- label: 'deployment.list',
128
- method: 'get',
129
- url: `${BASE}/deployment`,
130
- params: { environmentId: 'e-1', limit: 10, offset: 20 },
131
- run: () => sdk().deployment.list(SERVICE, { environmentId: 'e-1', limit: 10, offset: 20 }),
132
- },
133
- {
134
- label: 'deployment.goLive',
135
- method: 'post',
136
- url: `${BASE}/deployment/go-live`,
137
- body: { environmentId: 'e-1', serviceVersionId: 'v-1' },
138
- run: () => sdk().deployment.goLive(SERVICE, { environmentId: 'e-1', serviceVersionId: 'v-1' }),
139
- },
140
- {
141
- label: 'deployment.rollback',
142
- method: 'post',
143
- url: `${BASE}/deployment/rollback`,
144
- body: { environmentId: 'e-1', deploymentId: 'd-1' },
145
- run: () => sdk().deployment.rollback(SERVICE, { environmentId: 'e-1', deploymentId: 'd-1' }),
146
- },
147
- {
148
- label: 'deployment.pause',
149
- method: 'post',
150
- url: `${BASE}/deployment/pause`,
151
- body: { environmentId: 'e-1' },
152
- run: () => sdk().deployment.pause(SERVICE, { environmentId: 'e-1' }),
153
- },
154
- {
155
- label: 'deployment.resume',
156
- method: 'post',
157
- url: `${BASE}/deployment/resume`,
158
- body: { environmentId: 'e-1' },
159
- run: () => sdk().deployment.resume(SERVICE, { environmentId: 'e-1' }),
160
- },
161
- {
162
- label: 'configuration.list',
163
- method: 'get',
164
- url: `${BASE}/configuration`,
165
- run: () => sdk().configuration.list(SERVICE),
166
- },
167
- ];
168
-
169
- describe('AbyssReflexCore service routes', () => {
170
- const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
171
- async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
172
- );
173
-
174
- beforeAll(() => {
175
- AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
176
- AbyssReflexCore.axios.defaults.adapter = adapter;
177
- });
178
-
179
- beforeEach(() => adapter.mockClear());
180
-
181
- it.each(calls)('$label calls $method $url', async (call) => {
182
- await call.run();
183
-
184
- const config = adapter.mock.calls[0][0];
185
- expect(config.method).toBe(call.method);
186
- expect(config.url).toBe(call.url);
187
- expect(config.baseURL).toBe('http://reflex.test/');
188
- expect(config.params).toEqual(call.params);
189
- if (call.body !== undefined) {
190
- expect(JSON.parse(config.data)).toEqual(call.body);
191
- }
192
- });
193
-
194
- it('exposes no route twice', () => {
195
- expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
196
- });
197
-
198
- it('sends an empty body for a version without a message', async () => {
199
- await sdk().version.create(SERVICE);
200
-
201
- expect(JSON.parse(adapter.mock.calls[0][0].data)).toEqual({});
202
- });
203
- });
204
-
205
- describe('service limits', () => {
206
- it('match the bounds of the database', () => {
207
- expect(REFLEX_SERVICE_LIMITS.slugPattern.test('shop-2')).toBe(true);
208
- expect(REFLEX_SERVICE_LIMITS.slugPattern.test('-shop')).toBe(false);
209
- expect(REFLEX_SERVICE_LIMITS.rateLimitPerIpPerMinute).toEqual({
210
- min: 1,
211
- max: 6000,
212
- default: 60,
213
- });
214
- });
215
- });
1
+ import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
+ import {
3
+ AbyssReflexCore,
4
+ REFLEX_SERVICE_LIMITS,
5
+ RouteMethod,
6
+ ServiceType,
7
+ TriggerAccessMode,
8
+ } from '..';
9
+
10
+ const APP = 'app-1';
11
+ const SVC = 'svc-1';
12
+ const BASE = `api/service/${APP}/${SVC}`;
13
+ const SERVICE = { applicationId: APP, serviceId: SVC };
14
+
15
+ interface Call {
16
+ label: string;
17
+ method: string;
18
+ url: string;
19
+ body?: unknown;
20
+ params?: unknown;
21
+ run: () => Promise<unknown>;
22
+ }
23
+
24
+ const sdk = () => AbyssReflexCore.sdk.service;
25
+
26
+ const calls: Call[] = [
27
+ {
28
+ label: 'list',
29
+ method: 'get',
30
+ url: `api/service/${APP}`,
31
+ run: () => sdk().list({ applicationId: APP }),
32
+ },
33
+ {
34
+ label: 'create',
35
+ method: 'post',
36
+ url: `api/service/${APP}`,
37
+ body: { name: 'Shop', slug: 'shop', type: ServiceType.HTTP_API },
38
+ run: () =>
39
+ sdk().create(
40
+ { applicationId: APP },
41
+ { name: 'Shop', slug: 'shop', type: ServiceType.HTTP_API },
42
+ ),
43
+ },
44
+ { label: 'get', method: 'get', url: BASE, run: () => sdk().get(SERVICE) },
45
+ {
46
+ label: 'update',
47
+ method: 'patch',
48
+ url: BASE,
49
+ body: { cors: { allowedOrigins: ['https://shop.example'] }, rateLimitPerIpPerMinute: 120 },
50
+ run: () =>
51
+ sdk().update(SERVICE, {
52
+ cors: { allowedOrigins: ['https://shop.example'] },
53
+ rateLimitPerIpPerMinute: 120,
54
+ }),
55
+ },
56
+ { label: 'delete', method: 'delete', url: BASE, run: () => sdk().delete(SERVICE) },
57
+ {
58
+ label: 'route.list',
59
+ method: 'get',
60
+ url: `${BASE}/route`,
61
+ run: () => sdk().route.list(SERVICE),
62
+ },
63
+ {
64
+ label: 'route.create',
65
+ method: 'post',
66
+ url: `${BASE}/route`,
67
+ body: {
68
+ method: RouteMethod.GET,
69
+ path: 'orders/:id',
70
+ functionId: 'fn-1',
71
+ accessMode: TriggerAccessMode.API_KEY,
72
+ },
73
+ run: () =>
74
+ sdk().route.create(SERVICE, {
75
+ method: RouteMethod.GET,
76
+ path: 'orders/:id',
77
+ functionId: 'fn-1',
78
+ accessMode: TriggerAccessMode.API_KEY,
79
+ }),
80
+ },
81
+ {
82
+ label: 'route.update',
83
+ method: 'patch',
84
+ url: `${BASE}/route/r-1`,
85
+ body: { path: 'orders/:ref' },
86
+ run: () => sdk().route.update({ ...SERVICE, routeId: 'r-1' }, { path: 'orders/:ref' }),
87
+ },
88
+ {
89
+ label: 'route.delete',
90
+ method: 'delete',
91
+ url: `${BASE}/route/r-1`,
92
+ run: () => sdk().route.delete({ ...SERVICE, routeId: 'r-1' }),
93
+ },
94
+ {
95
+ label: 'route.rotate',
96
+ method: 'post',
97
+ url: `${BASE}/route/r-1/rotate`,
98
+ body: {},
99
+ run: () => sdk().route.rotate({ ...SERVICE, routeId: 'r-1' }),
100
+ },
101
+ {
102
+ label: 'version.list',
103
+ method: 'get',
104
+ url: `${BASE}/version`,
105
+ run: () => sdk().version.list(SERVICE),
106
+ },
107
+ {
108
+ label: 'version.create',
109
+ method: 'post',
110
+ url: `${BASE}/version`,
111
+ body: { message: 'orders by id' },
112
+ run: () => sdk().version.create(SERVICE, { message: 'orders by id' }),
113
+ },
114
+ {
115
+ label: 'version.draftStatus',
116
+ method: 'get',
117
+ url: `${BASE}/version/draft-status`,
118
+ run: () => sdk().version.draftStatus(SERVICE),
119
+ },
120
+ {
121
+ label: 'version.get',
122
+ method: 'get',
123
+ url: `${BASE}/version/v-1`,
124
+ run: () => sdk().version.get({ ...SERVICE, versionId: 'v-1' }),
125
+ },
126
+ {
127
+ label: 'deployment.list',
128
+ method: 'get',
129
+ url: `${BASE}/deployment`,
130
+ params: { environmentId: 'e-1', limit: 10, offset: 20 },
131
+ run: () => sdk().deployment.list(SERVICE, { environmentId: 'e-1', limit: 10, offset: 20 }),
132
+ },
133
+ {
134
+ label: 'deployment.goLive',
135
+ method: 'post',
136
+ url: `${BASE}/deployment/go-live`,
137
+ body: { environmentId: 'e-1', serviceVersionId: 'v-1' },
138
+ run: () => sdk().deployment.goLive(SERVICE, { environmentId: 'e-1', serviceVersionId: 'v-1' }),
139
+ },
140
+ {
141
+ label: 'deployment.rollback',
142
+ method: 'post',
143
+ url: `${BASE}/deployment/rollback`,
144
+ body: { environmentId: 'e-1', deploymentId: 'd-1' },
145
+ run: () => sdk().deployment.rollback(SERVICE, { environmentId: 'e-1', deploymentId: 'd-1' }),
146
+ },
147
+ {
148
+ label: 'deployment.pause',
149
+ method: 'post',
150
+ url: `${BASE}/deployment/pause`,
151
+ body: { environmentId: 'e-1' },
152
+ run: () => sdk().deployment.pause(SERVICE, { environmentId: 'e-1' }),
153
+ },
154
+ {
155
+ label: 'deployment.resume',
156
+ method: 'post',
157
+ url: `${BASE}/deployment/resume`,
158
+ body: { environmentId: 'e-1' },
159
+ run: () => sdk().deployment.resume(SERVICE, { environmentId: 'e-1' }),
160
+ },
161
+ {
162
+ label: 'configuration.list',
163
+ method: 'get',
164
+ url: `${BASE}/configuration`,
165
+ run: () => sdk().configuration.list(SERVICE),
166
+ },
167
+ ];
168
+
169
+ describe('AbyssReflexCore service routes', () => {
170
+ const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
171
+ async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
172
+ );
173
+
174
+ beforeAll(() => {
175
+ AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
176
+ AbyssReflexCore.axios.defaults.adapter = adapter;
177
+ });
178
+
179
+ beforeEach(() => adapter.mockClear());
180
+
181
+ it.each(calls)('$label calls $method $url', async (call) => {
182
+ await call.run();
183
+
184
+ const config = adapter.mock.calls[0][0];
185
+ expect(config.method).toBe(call.method);
186
+ expect(config.url).toBe(call.url);
187
+ expect(config.baseURL).toBe('http://reflex.test/');
188
+ expect(config.params).toEqual(call.params);
189
+ if (call.body !== undefined) {
190
+ expect(JSON.parse(config.data)).toEqual(call.body);
191
+ }
192
+ });
193
+
194
+ it('exposes no route twice', () => {
195
+ expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
196
+ });
197
+
198
+ it('sends an empty body for a version without a message', async () => {
199
+ await sdk().version.create(SERVICE);
200
+
201
+ expect(JSON.parse(adapter.mock.calls[0][0].data)).toEqual({});
202
+ });
203
+ });
204
+
205
+ describe('service limits', () => {
206
+ it('match the bounds of the database', () => {
207
+ expect(REFLEX_SERVICE_LIMITS.slugPattern.test('shop-2')).toBe(true);
208
+ expect(REFLEX_SERVICE_LIMITS.slugPattern.test('-shop')).toBe(false);
209
+ expect(REFLEX_SERVICE_LIMITS.rateLimitPerIpPerMinute).toEqual({
210
+ min: 1,
211
+ max: 6000,
212
+ default: 60,
213
+ });
214
+ });
215
+ });
@@ -1,55 +1,55 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- ICreateServiceBody,
4
- ICreateServiceParams,
5
- ICreateServiceResponse,
6
- IDeleteServiceParams,
7
- IDeleteServiceResponse,
8
- IGetServiceParams,
9
- IGetServiceResponse,
10
- IListServiceParams,
11
- IListServiceResponse,
12
- IUpdateServiceBody,
13
- IUpdateServiceParams,
14
- IUpdateServiceResponse,
15
- } from '../types';
16
-
17
- const serviceListUrl = (params: { applicationId: string }): string =>
18
- `api/service/${params.applicationId}`;
19
-
20
- const serviceUrl = (params: { applicationId: string; serviceId: string }): string =>
21
- `${serviceListUrl(params)}/${params.serviceId}`;
22
-
23
- /** `GET /service/:applicationId`: the Services, each with its current deployment per environment. Needs REFLEX_READ. */
24
- export const listService = async (params: IListServiceParams): Promise<IListServiceResponse> =>
25
- (await AbyssReflexCore.axios.get<IListServiceResponse>(serviceListUrl(params))).data;
26
-
27
- /**
28
- * `POST /service/:applicationId`: a Service of a name, a slug (immutable, third segment of the address)
29
- * and a type. `409 ALREADY_EXISTS` when the name or the slug is taken. Needs REFLEX_FUNCTION_CREATE.
30
- */
31
- export const createService = async (
32
- params: ICreateServiceParams,
33
- body: ICreateServiceBody,
34
- ): Promise<ICreateServiceResponse> =>
35
- (await AbyssReflexCore.axios.post<ICreateServiceResponse>(serviceListUrl(params), body)).data;
36
-
37
- /** `GET .../:serviceId`. Needs REFLEX_READ. */
38
- export const getService = async (params: IGetServiceParams): Promise<IGetServiceResponse> =>
39
- (await AbyssReflexCore.axios.get<IGetServiceResponse>(serviceUrl(params))).data;
40
-
41
- /**
42
- * `PATCH .../:serviceId`: the name, and the draft of the CORS and of the rate limit, frozen by the next
43
- * version. Needs REFLEX_FUNCTION_UPDATE.
44
- */
45
- export const updateService = async (
46
- params: IUpdateServiceParams,
47
- body: IUpdateServiceBody,
48
- ): Promise<IUpdateServiceResponse> =>
49
- (await AbyssReflexCore.axios.patch<IUpdateServiceResponse>(serviceUrl(params), body)).data;
50
-
51
- /** `DELETE .../:serviceId`: the Service, its functions, routes, versions and deployments. Needs REFLEX_FUNCTION_DELETE. */
52
- export const deleteService = async (
53
- params: IDeleteServiceParams,
54
- ): Promise<IDeleteServiceResponse> =>
55
- (await AbyssReflexCore.axios.delete<IDeleteServiceResponse>(serviceUrl(params))).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ ICreateServiceBody,
4
+ ICreateServiceParams,
5
+ ICreateServiceResponse,
6
+ IDeleteServiceParams,
7
+ IDeleteServiceResponse,
8
+ IGetServiceParams,
9
+ IGetServiceResponse,
10
+ IListServiceParams,
11
+ IListServiceResponse,
12
+ IUpdateServiceBody,
13
+ IUpdateServiceParams,
14
+ IUpdateServiceResponse,
15
+ } from '../types';
16
+
17
+ const serviceListUrl = (params: { applicationId: string }): string =>
18
+ `api/service/${params.applicationId}`;
19
+
20
+ const serviceUrl = (params: { applicationId: string; serviceId: string }): string =>
21
+ `${serviceListUrl(params)}/${params.serviceId}`;
22
+
23
+ /** `GET /service/:applicationId`: the Services, each with its current deployment per environment. Needs REFLEX_READ. */
24
+ export const listService = async (params: IListServiceParams): Promise<IListServiceResponse> =>
25
+ (await AbyssReflexCore.axios.get<IListServiceResponse>(serviceListUrl(params))).data;
26
+
27
+ /**
28
+ * `POST /service/:applicationId`: a Service of a name, a slug (immutable, third segment of the address)
29
+ * and a type. `409 ALREADY_EXISTS` when the name or the slug is taken. Needs REFLEX_FUNCTION_CREATE.
30
+ */
31
+ export const createService = async (
32
+ params: ICreateServiceParams,
33
+ body: ICreateServiceBody,
34
+ ): Promise<ICreateServiceResponse> =>
35
+ (await AbyssReflexCore.axios.post<ICreateServiceResponse>(serviceListUrl(params), body)).data;
36
+
37
+ /** `GET .../:serviceId`. Needs REFLEX_READ. */
38
+ export const getService = async (params: IGetServiceParams): Promise<IGetServiceResponse> =>
39
+ (await AbyssReflexCore.axios.get<IGetServiceResponse>(serviceUrl(params))).data;
40
+
41
+ /**
42
+ * `PATCH .../:serviceId`: the name, and the draft of the CORS and of the rate limit, frozen by the next
43
+ * version. Needs REFLEX_FUNCTION_UPDATE.
44
+ */
45
+ export const updateService = async (
46
+ params: IUpdateServiceParams,
47
+ body: IUpdateServiceBody,
48
+ ): Promise<IUpdateServiceResponse> =>
49
+ (await AbyssReflexCore.axios.patch<IUpdateServiceResponse>(serviceUrl(params), body)).data;
50
+
51
+ /** `DELETE .../:serviceId`: the Service, its functions, routes, versions and deployments. Needs REFLEX_FUNCTION_DELETE. */
52
+ export const deleteService = async (
53
+ params: IDeleteServiceParams,
54
+ ): Promise<IDeleteServiceResponse> =>
55
+ (await AbyssReflexCore.axios.delete<IDeleteServiceResponse>(serviceUrl(params))).data;
@@ -1,12 +1,12 @@
1
- /**
2
- * State of an access granted to a function.
3
- * - ACTIVE: the grantor still holds the right the access needs.
4
- * - SUSPENDED: a publication found the grantor without that right. Publishing is refused
5
- * (`GRANT_SUSPENDED`) until the access is revoked and granted again; what is already promoted keeps running.
6
- * - REVOKED: withdrawn on purpose; the row stays as the journal.
7
- */
8
- export enum AccessGrantStatus {
9
- ACTIVE = 'ACTIVE',
10
- SUSPENDED = 'SUSPENDED',
11
- REVOKED = 'REVOKED',
12
- }
1
+ /**
2
+ * State of an access granted to a function.
3
+ * - ACTIVE: the grantor still holds the right the access needs.
4
+ * - SUSPENDED: a publication found the grantor without that right. Publishing is refused
5
+ * (`GRANT_SUSPENDED`) until the access is revoked and granted again; what is already promoted keeps running.
6
+ * - REVOKED: withdrawn on purpose; the row stays as the journal.
7
+ */
8
+ export enum AccessGrantStatus {
9
+ ACTIVE = 'ACTIVE',
10
+ SUSPENDED = 'SUSPENDED',
11
+ REVOKED = 'REVOKED',
12
+ }
@@ -1,7 +1,7 @@
1
- /** The kinds of access a definition declares and a member grants (the format of @abyss-project/runtime). */
2
- export enum ReflexAccessKind {
3
- /** Outbound HTTP to a list of host names (exact, or `*.domain` for any sub-domain). */
4
- HTTP = 'HTTP',
5
- /** One action of the host catalog (`store.get`, `store.set`, `store.increment`, `secret.get`, `http.respond`). */
6
- HOST_ACTION = 'HOST_ACTION',
7
- }
1
+ /** The kinds of access a definition declares and a member grants (the format of @abyss-project/runtime). */
2
+ export enum ReflexAccessKind {
3
+ /** Outbound HTTP to a list of host names (exact, or `*.domain` for any sub-domain). */
4
+ HTTP = 'HTTP',
5
+ /** One action of the host catalog (`store.get`, `store.set`, `store.increment`, `secret.get`, `http.respond`). */
6
+ HOST_ACTION = 'HOST_ACTION',
7
+ }
@@ -1,5 +1,5 @@
1
- /** How a function reads a vault key: `config.NAME` (a VISIBLE entry) or `secrets.NAME` (a SECRET entry). */
2
- export enum ConfigurationReadAs {
3
- CONFIG = 'config',
4
- SECRETS = 'secrets',
5
- }
1
+ /** How a function reads a vault key: `config.NAME` (a VISIBLE entry) or `secrets.NAME` (a SECRET entry). */
2
+ export enum ConfigurationReadAs {
3
+ CONFIG = 'config',
4
+ SECRETS = 'secrets',
5
+ }
@@ -1,9 +1,9 @@
1
- /** What the activity of a Discord bot says it does ("Playing", "Listening to", "Watching", "Competing in", or a free text). */
2
- export enum DiscordActivityType {
3
- PLAYING = 'PLAYING',
4
- LISTENING = 'LISTENING',
5
- WATCHING = 'WATCHING',
6
- COMPETING = 'COMPETING',
7
- /** The text alone, shown as it is written. */
8
- CUSTOM = 'CUSTOM',
9
- }
1
+ /** What the activity of a Discord bot says it does ("Playing", "Listening to", "Watching", "Competing in", or a free text). */
2
+ export enum DiscordActivityType {
3
+ PLAYING = 'PLAYING',
4
+ LISTENING = 'LISTENING',
5
+ WATCHING = 'WATCHING',
6
+ COMPETING = 'COMPETING',
7
+ /** The text alone, shown as it is written. */
8
+ CUSTOM = 'CUSTOM',
9
+ }
@@ -1,7 +1,7 @@
1
- /** What a component prefix of a Discord bot routes. */
2
- export enum DiscordComponentKind {
3
- /** A button or a select menu: interactions of type MESSAGE_COMPONENT. */
4
- BUTTON_OR_SELECT = 'BUTTON_OR_SELECT',
5
- /** A form: interactions of type MODAL_SUBMIT. */
6
- MODAL = 'MODAL',
7
- }
1
+ /** What a component prefix of a Discord bot routes. */
2
+ export enum DiscordComponentKind {
3
+ /** A button or a select menu: interactions of type MESSAGE_COMPONENT. */
4
+ BUTTON_OR_SELECT = 'BUTTON_OR_SELECT',
5
+ /** A form: interactions of type MODAL_SUBMIT. */
6
+ MODAL = 'MODAL',
7
+ }
@@ -1,11 +1,11 @@
1
- /** The state of the Gateway connection that keeps a Discord bot online in one environment. */
2
- export enum DiscordGatewayState {
3
- /** Connecting, identifying or resuming. */
4
- CONNECTING = 'CONNECTING',
5
- /** Connected: the bot is online. */
6
- CONNECTED = 'CONNECTED',
7
- /** No connection: the bot is paused or out of service, or the connection is between two owners. */
8
- DISCONNECTED = 'DISCONNECTED',
9
- /** The connection cannot be kept; `DiscordGatewayFailureCode` says why. */
10
- FAILED = 'FAILED',
11
- }
1
+ /** The state of the Gateway connection that keeps a Discord bot online in one environment. */
2
+ export enum DiscordGatewayState {
3
+ /** Connecting, identifying or resuming. */
4
+ CONNECTING = 'CONNECTING',
5
+ /** Connected: the bot is online. */
6
+ CONNECTED = 'CONNECTED',
7
+ /** No connection: the bot is paused or out of service, or the connection is between two owners. */
8
+ DISCONNECTED = 'DISCONNECTED',
9
+ /** The connection cannot be kept; `DiscordGatewayFailureCode` says why. */
10
+ FAILED = 'FAILED',
11
+ }