@abyss-project/reflex 5.10.0 → 5.12.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 (73) hide show
  1. package/dist/api/function-access.api.d.ts +5 -1
  2. package/dist/api/function-access.api.js +9 -1
  3. package/dist/api/function-access.api.js.map +1 -1
  4. package/dist/api/function-template.api.d.ts +5 -0
  5. package/dist/api/function-template.api.js +15 -0
  6. package/dist/api/function-template.api.js.map +1 -0
  7. package/dist/api/function-version.api.d.ts +3 -2
  8. package/dist/api/function-version.api.js +6 -2
  9. package/dist/api/function-version.api.js.map +1 -1
  10. package/dist/api/index.d.ts +1 -0
  11. package/dist/api/index.js +1 -0
  12. package/dist/api/index.js.map +1 -1
  13. package/dist/index.d.ts +12 -0
  14. package/dist/index.js +12 -0
  15. package/dist/index.js.map +1 -1
  16. package/dist/types/enum/access-request-status.enum.d.ts +5 -0
  17. package/dist/types/enum/access-request-status.enum.js +10 -0
  18. package/dist/types/enum/access-request-status.enum.js.map +1 -0
  19. package/dist/types/enum/index.d.ts +1 -0
  20. package/dist/types/enum/index.js +1 -0
  21. package/dist/types/enum/index.js.map +1 -1
  22. package/dist/types/interface/api/requests/function-access.request.d.ts +21 -0
  23. package/dist/types/interface/api/requests/function-template.request.d.ts +23 -0
  24. package/dist/types/interface/api/requests/function-template.request.js +3 -0
  25. package/dist/types/interface/api/requests/function-template.request.js.map +1 -0
  26. package/dist/types/interface/api/requests/function-version.request.d.ts +12 -0
  27. package/dist/types/interface/api/requests/index.d.ts +1 -0
  28. package/dist/types/interface/api/requests/index.js +1 -0
  29. package/dist/types/interface/api/requests/index.js.map +1 -1
  30. package/dist/types/interface/api/responses/function-access.response.d.ts +21 -1
  31. package/dist/types/interface/api/responses/function-template.response.d.ts +16 -0
  32. package/dist/types/interface/api/responses/function-template.response.js +3 -0
  33. package/dist/types/interface/api/responses/function-template.response.js.map +1 -0
  34. package/dist/types/interface/api/responses/function-version.response.d.ts +7 -2
  35. package/dist/types/interface/api/responses/index.d.ts +1 -0
  36. package/dist/types/interface/api/responses/index.js +1 -0
  37. package/dist/types/interface/api/responses/index.js.map +1 -1
  38. package/dist/types/interface/api/responses/service-version.response.d.ts +1 -0
  39. package/dist/types/interface/models/index.d.ts +2 -0
  40. package/dist/types/interface/models/index.js +2 -0
  41. package/dist/types/interface/models/index.js.map +1 -1
  42. package/dist/types/interface/models/reflex-access-request.model.d.ts +13 -0
  43. package/dist/types/interface/models/reflex-access-request.model.js +3 -0
  44. package/dist/types/interface/models/reflex-access-request.model.js.map +1 -0
  45. package/dist/types/interface/models/reflex-function-template.model.d.ts +13 -0
  46. package/dist/types/interface/models/reflex-function-template.model.js +3 -0
  47. package/dist/types/interface/models/reflex-function-template.model.js.map +1 -0
  48. package/dist/types/interface/models/reflex-function-version.model.d.ts +3 -0
  49. package/dist/types/interface/models/reflex-function.model.d.ts +9 -0
  50. package/package.json +1 -1
  51. package/src/api/function-access.api.ts +52 -1
  52. package/src/api/function-template.api.test.ts +72 -0
  53. package/src/api/function-template.api.ts +52 -0
  54. package/src/api/function-version.api.ts +20 -2
  55. package/src/api/function.api.test.ts +47 -6
  56. package/src/api/index.ts +1 -0
  57. package/src/index.ts +24 -0
  58. package/src/types/enum/access-request-status.enum.ts +11 -0
  59. package/src/types/enum/index.ts +1 -0
  60. package/src/types/interface/api/requests/function-access.request.ts +26 -0
  61. package/src/types/interface/api/requests/function-template.request.ts +29 -0
  62. package/src/types/interface/api/requests/function-version.request.ts +18 -0
  63. package/src/types/interface/api/requests/index.ts +1 -0
  64. package/src/types/interface/api/responses/function-access.response.ts +29 -1
  65. package/src/types/interface/api/responses/function-template.response.ts +21 -0
  66. package/src/types/interface/api/responses/function-version.response.ts +12 -1
  67. package/src/types/interface/api/responses/index.ts +1 -0
  68. package/src/types/interface/api/responses/service-version.response.ts +6 -0
  69. package/src/types/interface/models/index.ts +2 -0
  70. package/src/types/interface/models/reflex-access-request.model.ts +15 -0
  71. package/src/types/interface/models/reflex-function-template.model.ts +18 -0
  72. package/src/types/interface/models/reflex-function-version.model.ts +5 -0
  73. package/src/types/interface/models/reflex-function.model.ts +14 -0
@@ -1,5 +1,14 @@
1
1
  import { AbyssReflexCore } from '..';
2
2
  import type {
3
+ IDismissFunctionAccessRequestParams,
4
+ IDismissFunctionAccessRequestResponse,
5
+ IGrantAllFunctionAccessParams,
6
+ IGrantAllFunctionAccessResponse,
7
+ IGrantFunctionAccessRequestParams,
8
+ IGrantFunctionAccessRequestResponse,
9
+ IRequestFunctionAccessBody,
10
+ IRequestFunctionAccessParams,
11
+ IRequestFunctionAccessResponse,
3
12
  IGrantFunctionAccessBody,
4
13
  IGrantFunctionAccessParams,
5
14
  IGrantFunctionAccessResponse,
@@ -12,7 +21,7 @@ import type {
12
21
  const accessUrl = (params: { applicationId: string; functionId: string }): string =>
13
22
  `api/function/${params.applicationId}/${params.functionId}/access`;
14
23
 
15
- /** `GET .../access`: every access granted to the function, revoked ones included (the journal). Needs REFLEX_READ. */
24
+ /** `GET .../access`: every access granted to the function, revoked ones included (the journal), its requests and the declaration keys the caller may grant. Needs REFLEX_READ. */
16
25
  export const listFunctionAccess = async (
17
26
  params: IListFunctionAccessParams,
18
27
  ): Promise<IListFunctionAccessResponse> =>
@@ -34,3 +43,45 @@ export const revokeFunctionAccess = async (
34
43
  `${accessUrl(params)}/${params.grantId}`,
35
44
  )
36
45
  ).data;
46
+
47
+ /** `POST .../access/grant-all`: grants every declaration of the saved draft the caller may grant and files a pending request for the rest. Needs REFLEX_READ; each grant needs the right of its declaration. */
48
+ export const grantAllFunctionAccess = async (
49
+ params: IGrantAllFunctionAccessParams,
50
+ ): Promise<IGrantAllFunctionAccessResponse> =>
51
+ (
52
+ await AbyssReflexCore.axios.post<IGrantAllFunctionAccessResponse>(
53
+ `${accessUrl(params)}/grant-all`,
54
+ )
55
+ ).data;
56
+
57
+ /** `POST .../access/request`: asks for an access the saved draft declares (`409 ACCESS_NOT_DECLARED` otherwise). Needs REFLEX_READ. */
58
+ export const requestFunctionAccess = async (
59
+ params: IRequestFunctionAccessParams,
60
+ body: IRequestFunctionAccessBody,
61
+ ): Promise<IRequestFunctionAccessResponse> =>
62
+ (
63
+ await AbyssReflexCore.axios.post<IRequestFunctionAccessResponse>(
64
+ `${accessUrl(params)}/request`,
65
+ body,
66
+ )
67
+ ).data;
68
+
69
+ /** `POST .../access/request/:requestId/grant`: grants the access of a pending request. The caller must hold the right the access needs. */
70
+ export const grantFunctionAccessRequest = async (
71
+ params: IGrantFunctionAccessRequestParams,
72
+ ): Promise<IGrantFunctionAccessRequestResponse> =>
73
+ (
74
+ await AbyssReflexCore.axios.post<IGrantFunctionAccessRequestResponse>(
75
+ `${accessUrl(params)}/request/${params.requestId}/grant`,
76
+ )
77
+ ).data;
78
+
79
+ /** `POST .../access/request/:requestId/dismiss`: sets a pending request aside. The caller must hold the right the access needs. */
80
+ export const dismissFunctionAccessRequest = async (
81
+ params: IDismissFunctionAccessRequestParams,
82
+ ): Promise<IDismissFunctionAccessRequestResponse> =>
83
+ (
84
+ await AbyssReflexCore.axios.post<IDismissFunctionAccessRequestResponse>(
85
+ `${accessUrl(params)}/request/${params.requestId}/dismiss`,
86
+ )
87
+ ).data;
@@ -0,0 +1,72 @@
1
+ import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
+ import { AbyssReflexCore } from '..';
3
+
4
+ const APP = 'app-1';
5
+ const BASE = `api/function-template/${APP}`;
6
+
7
+ interface Call {
8
+ label: string;
9
+ method: string;
10
+ url: string;
11
+ body?: unknown;
12
+ run: () => Promise<unknown>;
13
+ }
14
+
15
+ const sdk = () => AbyssReflexCore.sdk.functionTemplate;
16
+
17
+ const calls: Call[] = [
18
+ { label: 'list', method: 'get', url: BASE, run: () => sdk().list({ applicationId: APP }) },
19
+ {
20
+ label: 'create',
21
+ method: 'post',
22
+ url: BASE,
23
+ body: { name: 'Hook', description: 'A webhook', functionId: 'fn-1' },
24
+ run: () =>
25
+ sdk().create(
26
+ { applicationId: APP },
27
+ { name: 'Hook', description: 'A webhook', functionId: 'fn-1' },
28
+ ),
29
+ },
30
+ {
31
+ label: 'update',
32
+ method: 'patch',
33
+ url: `${BASE}/t-1`,
34
+ body: { name: 'Renamed' },
35
+ run: () => sdk().update({ applicationId: APP, templateId: 't-1' }, { name: 'Renamed' }),
36
+ },
37
+ {
38
+ label: 'delete',
39
+ method: 'delete',
40
+ url: `${BASE}/t-1`,
41
+ run: () => sdk().delete({ applicationId: APP, templateId: 't-1' }),
42
+ },
43
+ ];
44
+
45
+ describe('AbyssReflexCore function template routes', () => {
46
+ const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
47
+ async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
48
+ );
49
+
50
+ beforeAll(() => {
51
+ AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
52
+ AbyssReflexCore.axios.defaults.adapter = adapter;
53
+ });
54
+
55
+ beforeEach(() => adapter.mockClear());
56
+
57
+ it.each(calls)('$label calls $method $url', async (call) => {
58
+ await call.run();
59
+
60
+ const config = adapter.mock.calls[0][0];
61
+ expect(config.method).toBe(call.method);
62
+ expect(config.url).toBe(call.url);
63
+ expect(config.baseURL).toBe('http://reflex.test/');
64
+ if (call.body !== undefined) {
65
+ expect(JSON.parse(config.data)).toEqual(call.body);
66
+ }
67
+ });
68
+
69
+ it('exposes no route twice', () => {
70
+ expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
71
+ });
72
+ });
@@ -0,0 +1,52 @@
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ ICreateFunctionTemplateBody,
4
+ ICreateFunctionTemplateParams,
5
+ ICreateFunctionTemplateResponse,
6
+ IDeleteFunctionTemplateParams,
7
+ IDeleteFunctionTemplateResponse,
8
+ IListFunctionTemplateParams,
9
+ IListFunctionTemplateResponse,
10
+ IUpdateFunctionTemplateBody,
11
+ IUpdateFunctionTemplateParams,
12
+ IUpdateFunctionTemplateResponse,
13
+ } from '../types';
14
+
15
+ const templateUrl = (params: { applicationId: string }): string =>
16
+ `api/function-template/${params.applicationId}`;
17
+
18
+ /** `GET /api/function-template/:applicationId`: the templates of the application, sorted by name. Needs REFLEX_READ. */
19
+ export const listFunctionTemplate = async (
20
+ params: IListFunctionTemplateParams,
21
+ ): Promise<IListFunctionTemplateResponse> =>
22
+ (await AbyssReflexCore.axios.get<IListFunctionTemplateResponse>(templateUrl(params))).data;
23
+
24
+ /** `POST /api/function-template/:applicationId`: saves the saved draft of a function as a template (`409` when the name is taken). Needs REFLEX_FUNCTION_CREATE. */
25
+ export const createFunctionTemplate = async (
26
+ params: ICreateFunctionTemplateParams,
27
+ body: ICreateFunctionTemplateBody,
28
+ ): Promise<ICreateFunctionTemplateResponse> =>
29
+ (await AbyssReflexCore.axios.post<ICreateFunctionTemplateResponse>(templateUrl(params), body))
30
+ .data;
31
+
32
+ /** `PATCH /api/function-template/:applicationId/:templateId`: renames or re-describes the template. Needs REFLEX_FUNCTION_UPDATE. */
33
+ export const updateFunctionTemplate = async (
34
+ params: IUpdateFunctionTemplateParams,
35
+ body: IUpdateFunctionTemplateBody,
36
+ ): Promise<IUpdateFunctionTemplateResponse> =>
37
+ (
38
+ await AbyssReflexCore.axios.patch<IUpdateFunctionTemplateResponse>(
39
+ `${templateUrl(params)}/${params.templateId}`,
40
+ body,
41
+ )
42
+ ).data;
43
+
44
+ /** `DELETE /api/function-template/:applicationId/:templateId`. Needs REFLEX_FUNCTION_UPDATE. */
45
+ export const deleteFunctionTemplate = async (
46
+ params: IDeleteFunctionTemplateParams,
47
+ ): Promise<IDeleteFunctionTemplateResponse> =>
48
+ (
49
+ await AbyssReflexCore.axios.delete<IDeleteFunctionTemplateResponse>(
50
+ `${templateUrl(params)}/${params.templateId}`,
51
+ )
52
+ ).data;
@@ -6,6 +6,9 @@ import type {
6
6
  IGetFunctionVersionStepStatsQuery,
7
7
  IGetFunctionVersionStepStatsResponse,
8
8
  IListFunctionVersionParams,
9
+ IListFunctionVersionQuery,
10
+ IOpenFunctionVersionParams,
11
+ IOpenFunctionVersionResponse,
9
12
  IListFunctionVersionResponse,
10
13
  } from '../types';
11
14
 
@@ -13,13 +16,18 @@ const versionUrl = (params: { applicationId: string; functionId: string }): stri
13
16
  `api/function/${params.applicationId}/${params.functionId}/version`;
14
17
 
15
18
  /**
16
- * `GET .../version`: the frozen versions, newest first. Needs REFLEX_READ. A version of the function's
19
+ * `GET .../version`: the frozen versions, newest first, one page of those matching the filters. Needs REFLEX_READ. A version of the function's
17
20
  * Service publishes its draft when it changed (`service.version.create`).
18
21
  */
19
22
  export const listFunctionVersion = async (
20
23
  params: IListFunctionVersionParams,
24
+ query: IListFunctionVersionQuery = {},
21
25
  ): Promise<IListFunctionVersionResponse> =>
22
- (await AbyssReflexCore.axios.get<IListFunctionVersionResponse>(versionUrl(params))).data;
26
+ (
27
+ await AbyssReflexCore.axios.get<IListFunctionVersionResponse>(versionUrl(params), {
28
+ params: query,
29
+ })
30
+ ).data;
23
31
 
24
32
  /** `GET .../version/:versionId`. Needs REFLEX_READ. */
25
33
  export const getFunctionVersion = async (
@@ -46,3 +54,13 @@ export const getFunctionVersionStepStats = async (
46
54
  { params: query },
47
55
  )
48
56
  ).data;
57
+
58
+ /** `POST .../version/:versionId/open`: replaces the draft with the definition of the version and records it as the base of the draft. Needs REFLEX_FUNCTION_UPDATE. */
59
+ export const openFunctionVersion = async (
60
+ params: IOpenFunctionVersionParams,
61
+ ): Promise<IOpenFunctionVersionResponse> =>
62
+ (
63
+ await AbyssReflexCore.axios.post<IOpenFunctionVersionResponse>(
64
+ `${versionUrl(params)}/${params.versionId}/open`,
65
+ )
66
+ ).data;
@@ -87,6 +87,53 @@ const calls: Call[] = [
87
87
  url: `${BASE}/access/g-1`,
88
88
  run: () => sdk().access.revoke({ applicationId: APP, functionId: FN, grantId: 'g-1' }),
89
89
  },
90
+ {
91
+ label: 'access.grantAll',
92
+ method: 'post',
93
+ url: `${BASE}/access/grant-all`,
94
+ run: () => sdk().access.grantAll({ applicationId: APP, functionId: FN }),
95
+ },
96
+ {
97
+ label: 'access.request',
98
+ method: 'post',
99
+ url: `${BASE}/access/request`,
100
+ body: { declaration: { kind: 'HOST_ACTION', action: 'store.get' } },
101
+ run: () =>
102
+ sdk().access.request(
103
+ { applicationId: APP, functionId: FN },
104
+ { declaration: { kind: 'HOST_ACTION', action: 'store.get' } as never },
105
+ ),
106
+ },
107
+ {
108
+ label: 'access.grantRequest',
109
+ method: 'post',
110
+ url: `${BASE}/access/request/q-1/grant`,
111
+ run: () => sdk().access.grantRequest({ applicationId: APP, functionId: FN, requestId: 'q-1' }),
112
+ },
113
+ {
114
+ label: 'access.dismissRequest',
115
+ method: 'post',
116
+ url: `${BASE}/access/request/q-1/dismiss`,
117
+ run: () =>
118
+ sdk().access.dismissRequest({ applicationId: APP, functionId: FN, requestId: 'q-1' }),
119
+ },
120
+ {
121
+ label: 'version.list',
122
+ method: 'get',
123
+ url: `${BASE}/version`,
124
+ params: { page: 2, limit: 20, number: 3, publishedByUserId: 'u-1', deployed: true },
125
+ run: () =>
126
+ sdk().version.list(
127
+ { applicationId: APP, functionId: FN },
128
+ { page: 2, limit: 20, number: 3, publishedByUserId: 'u-1', deployed: true },
129
+ ),
130
+ },
131
+ {
132
+ label: 'version.open',
133
+ method: 'post',
134
+ url: `${BASE}/version/v-1/open`,
135
+ run: () => sdk().version.open({ applicationId: APP, functionId: FN, versionId: 'v-1' }),
136
+ },
90
137
  {
91
138
  label: 'test.simulate',
92
139
  method: 'post',
@@ -105,12 +152,6 @@ const calls: Call[] = [
105
152
  body: { environmentId: 'e-1' },
106
153
  run: () => sdk().test.dryRun({ applicationId: APP, functionId: FN }, { environmentId: 'e-1' }),
107
154
  },
108
- {
109
- label: 'version.list',
110
- method: 'get',
111
- url: `${BASE}/version`,
112
- run: () => sdk().version.list({ applicationId: APP, functionId: FN }),
113
- },
114
155
  {
115
156
  label: 'version.get',
116
157
  method: 'get',
package/src/api/index.ts CHANGED
@@ -19,3 +19,4 @@ export * from './application-run-settings.api';
19
19
  export * from './application-insights.api';
20
20
  export * from './alert-rule.api';
21
21
  export * from './route-stats.api';
22
+ export * from './function-template.api';
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ import axios from 'axios';
2
2
  import * as healthApi from './api/health.api';
3
3
  import * as functionApi from './api/function.api';
4
4
  import * as functionAccessApi from './api/function-access.api';
5
+ import * as functionTemplateApi from './api/function-template.api';
5
6
  import * as functionTestApi from './api/function-test.api';
6
7
  import * as functionVersionApi from './api/function-version.api';
7
8
  import * as functionRunApi from './api/function-run.api';
@@ -47,6 +48,10 @@ type AbyssReflexCoreSDK = {
47
48
  list: typeof functionAccessApi.listFunctionAccess;
48
49
  grant: typeof functionAccessApi.grantFunctionAccess;
49
50
  revoke: typeof functionAccessApi.revokeFunctionAccess;
51
+ grantAll: typeof functionAccessApi.grantAllFunctionAccess;
52
+ request: typeof functionAccessApi.requestFunctionAccess;
53
+ grantRequest: typeof functionAccessApi.grantFunctionAccessRequest;
54
+ dismissRequest: typeof functionAccessApi.dismissFunctionAccessRequest;
50
55
  };
51
56
  test: {
52
57
  simulate: typeof functionTestApi.simulateFunction;
@@ -56,6 +61,7 @@ type AbyssReflexCoreSDK = {
56
61
  list: typeof functionVersionApi.listFunctionVersion;
57
62
  get: typeof functionVersionApi.getFunctionVersion;
58
63
  stepStats: typeof functionVersionApi.getFunctionVersionStepStats;
64
+ open: typeof functionVersionApi.openFunctionVersion;
59
65
  };
60
66
  run: {
61
67
  list: typeof functionRunApi.listFunctionRun;
@@ -77,6 +83,13 @@ type AbyssReflexCoreSDK = {
77
83
  set: typeof functionSettingsApi.setFunctionLogCap;
78
84
  };
79
85
  };
86
+ /** Function templates of an application (`/api/function-template/:applicationId`). */
87
+ functionTemplate: {
88
+ list: typeof functionTemplateApi.listFunctionTemplate;
89
+ create: typeof functionTemplateApi.createFunctionTemplate;
90
+ update: typeof functionTemplateApi.updateFunctionTemplate;
91
+ delete: typeof functionTemplateApi.deleteFunctionTemplate;
92
+ };
80
93
  /** Applications: run settings, overview, calendar and alert rules (`/api/application/:applicationId/...`). */
81
94
  application: {
82
95
  runSettings: {
@@ -217,6 +230,10 @@ export class AbyssReflexCore {
217
230
  list: functionAccessApi.listFunctionAccess,
218
231
  grant: functionAccessApi.grantFunctionAccess,
219
232
  revoke: functionAccessApi.revokeFunctionAccess,
233
+ grantAll: functionAccessApi.grantAllFunctionAccess,
234
+ request: functionAccessApi.requestFunctionAccess,
235
+ grantRequest: functionAccessApi.grantFunctionAccessRequest,
236
+ dismissRequest: functionAccessApi.dismissFunctionAccessRequest,
220
237
  },
221
238
  test: {
222
239
  simulate: functionTestApi.simulateFunction,
@@ -226,6 +243,7 @@ export class AbyssReflexCore {
226
243
  list: functionVersionApi.listFunctionVersion,
227
244
  get: functionVersionApi.getFunctionVersion,
228
245
  stepStats: functionVersionApi.getFunctionVersionStepStats,
246
+ open: functionVersionApi.openFunctionVersion,
229
247
  },
230
248
  run: {
231
249
  list: functionRunApi.listFunctionRun,
@@ -245,6 +263,12 @@ export class AbyssReflexCore {
245
263
  set: functionSettingsApi.setFunctionLogCap,
246
264
  },
247
265
  },
266
+ functionTemplate: {
267
+ list: functionTemplateApi.listFunctionTemplate,
268
+ create: functionTemplateApi.createFunctionTemplate,
269
+ update: functionTemplateApi.updateFunctionTemplate,
270
+ delete: functionTemplateApi.deleteFunctionTemplate,
271
+ },
248
272
  application: {
249
273
  runSettings: {
250
274
  get: applicationRunSettingsApi.getApplicationRunSettings,
@@ -0,0 +1,11 @@
1
+ /**
2
+ * State of a request to grant an access a function declares.
3
+ * - PENDING: waiting for a member who holds the right the access needs.
4
+ * - GRANTED: the access was granted (by the request or by another gesture).
5
+ * - DISMISSED: set aside by a member with the right, or because the draft no longer declares the access.
6
+ */
7
+ export enum AccessRequestStatus {
8
+ PENDING = 'PENDING',
9
+ GRANTED = 'GRANTED',
10
+ DISMISSED = 'DISMISSED',
11
+ }
@@ -46,3 +46,4 @@ export * from './log-drop-cause.enum';
46
46
  export * from './reflex-alert-scope.enum';
47
47
  export * from './reflex-alert-metric.enum';
48
48
  export * from './reflex-alert-notification-state.enum';
49
+ export * from './access-request-status.enum';
@@ -23,3 +23,29 @@ export interface IRevokeFunctionAccessParams {
23
23
  functionId: string;
24
24
  grantId: string;
25
25
  }
26
+
27
+ export interface IGrantAllFunctionAccessParams {
28
+ applicationId: string;
29
+ functionId: string;
30
+ }
31
+
32
+ export interface IRequestFunctionAccessParams {
33
+ applicationId: string;
34
+ functionId: string;
35
+ }
36
+ /** The declaration must be one the saved draft makes (`409 ACCESS_NOT_DECLARED` otherwise). */
37
+ export interface IRequestFunctionAccessBody {
38
+ declaration: IReflexAccessDeclaration;
39
+ }
40
+
41
+ export interface IGrantFunctionAccessRequestParams {
42
+ applicationId: string;
43
+ functionId: string;
44
+ requestId: string;
45
+ }
46
+
47
+ export interface IDismissFunctionAccessRequestParams {
48
+ applicationId: string;
49
+ functionId: string;
50
+ requestId: string;
51
+ }
@@ -0,0 +1,29 @@
1
+ export interface IListFunctionTemplateParams {
2
+ applicationId: string;
3
+ }
4
+
5
+ export interface ICreateFunctionTemplateParams {
6
+ applicationId: string;
7
+ }
8
+ export interface ICreateFunctionTemplateBody {
9
+ /** Unique within the application, 1 to 100 characters. */
10
+ name: string;
11
+ /** 500 characters at most. */
12
+ description?: string;
13
+ /** The function whose saved draft becomes the template. */
14
+ functionId: string;
15
+ }
16
+
17
+ export interface IUpdateFunctionTemplateParams {
18
+ applicationId: string;
19
+ templateId: string;
20
+ }
21
+ export interface IUpdateFunctionTemplateBody {
22
+ name?: string;
23
+ description?: string;
24
+ }
25
+
26
+ export interface IDeleteFunctionTemplateParams {
27
+ applicationId: string;
28
+ templateId: string;
29
+ }
@@ -2,6 +2,18 @@ export interface IListFunctionVersionParams {
2
2
  applicationId: string;
3
3
  functionId: string;
4
4
  }
5
+ export interface IListFunctionVersionQuery {
6
+ /** 1 by default. */
7
+ page?: number;
8
+ /** 1 to 50. */
9
+ limit?: number;
10
+ /** Only the version of this number. */
11
+ number?: number;
12
+ /** Only the versions published by this user. */
13
+ publishedByUserId?: string;
14
+ /** true: only versions a Service version put in service; false: only the others. */
15
+ deployed?: boolean;
16
+ }
5
17
 
6
18
  export interface IGetFunctionVersionParams {
7
19
  applicationId: string;
@@ -18,3 +30,9 @@ export interface IGetFunctionVersionStepStatsQuery {
18
30
  /** Only the executions of this environment; every environment when absent. */
19
31
  environmentId?: string;
20
32
  }
33
+
34
+ export interface IOpenFunctionVersionParams {
35
+ applicationId: string;
36
+ functionId: string;
37
+ versionId: string;
38
+ }
@@ -17,3 +17,4 @@ export * from './application-run-settings.request';
17
17
  export * from './application-insights.request';
18
18
  export * from './alert-rule.request';
19
19
  export * from './route-stats.request';
20
+ export * from './function-template.request';
@@ -1,8 +1,12 @@
1
- import type { IReflexAccessGrant } from '../../models';
1
+ import type { IReflexAccessGrant, IReflexAccessRequest } from '../../models';
2
2
  import type { IResponse } from '../response';
3
3
 
4
4
  export interface IListFunctionAccessData {
5
5
  grants: IReflexAccessGrant[];
6
+ /** The requests of the function, every status, newest first. */
7
+ requests: IReflexAccessRequest[];
8
+ /** The declaration keys of the saved draft the caller may grant. */
9
+ grantable: string[];
6
10
  }
7
11
  export type IListFunctionAccessResponse = IResponse<IListFunctionAccessData>;
8
12
 
@@ -15,3 +19,27 @@ export interface IRevokeFunctionAccessData {
15
19
  grant: IReflexAccessGrant;
16
20
  }
17
21
  export type IRevokeFunctionAccessResponse = IResponse<IRevokeFunctionAccessData>;
22
+
23
+ export interface IGrantAllFunctionAccessData {
24
+ /** What the caller could grant, now granted. */
25
+ granted: IReflexAccessGrant[];
26
+ /** The pending requests for the rest (an existing pending request is reused). */
27
+ requested: IReflexAccessRequest[];
28
+ }
29
+ export type IGrantAllFunctionAccessResponse = IResponse<IGrantAllFunctionAccessData>;
30
+
31
+ export interface IRequestFunctionAccessData {
32
+ request: IReflexAccessRequest;
33
+ }
34
+ export type IRequestFunctionAccessResponse = IResponse<IRequestFunctionAccessData>;
35
+
36
+ export interface IGrantFunctionAccessRequestData {
37
+ request: IReflexAccessRequest;
38
+ grant: IReflexAccessGrant;
39
+ }
40
+ export type IGrantFunctionAccessRequestResponse = IResponse<IGrantFunctionAccessRequestData>;
41
+
42
+ export interface IDismissFunctionAccessRequestData {
43
+ request: IReflexAccessRequest;
44
+ }
45
+ export type IDismissFunctionAccessRequestResponse = IResponse<IDismissFunctionAccessRequestData>;
@@ -0,0 +1,21 @@
1
+ import type { IReflexFunctionTemplate } from '../../models';
2
+ import type { IResponse } from '../response';
3
+
4
+ export interface IListFunctionTemplateData {
5
+ /** Sorted by name. */
6
+ templates: IReflexFunctionTemplate[];
7
+ }
8
+ export type IListFunctionTemplateResponse = IResponse<IListFunctionTemplateData>;
9
+
10
+ export interface ICreateFunctionTemplateData {
11
+ template: IReflexFunctionTemplate;
12
+ }
13
+ export type ICreateFunctionTemplateResponse = IResponse<ICreateFunctionTemplateData>;
14
+
15
+ export interface IUpdateFunctionTemplateData {
16
+ template: IReflexFunctionTemplate;
17
+ }
18
+ export type IUpdateFunctionTemplateResponse = IResponse<IUpdateFunctionTemplateData>;
19
+
20
+ export type IDeleteFunctionTemplateData = Record<string, never>;
21
+ export type IDeleteFunctionTemplateResponse = IResponse<IDeleteFunctionTemplateData>;
@@ -1,12 +1,17 @@
1
1
  import type {
2
+ IReflexFunction,
2
3
  IReflexFunctionVersion,
4
+ IReflexFunctionVersionRow,
3
5
  IReflexRunningVersionHeapPeaks,
4
6
  IReflexStepStats,
5
7
  } from '../../models';
6
8
  import type { IResponse } from '../response';
7
9
 
8
10
  export interface IListFunctionVersionData {
9
- versions: IReflexFunctionVersion[];
11
+ /** The page, newest first. */
12
+ rows: IReflexFunctionVersionRow[];
13
+ /** Versions matching the filters, every page. */
14
+ total: number;
10
15
  }
11
16
  export type IListFunctionVersionResponse = IResponse<IListFunctionVersionData>;
12
17
 
@@ -29,3 +34,9 @@ export interface IGetFunctionVersionStepStatsData {
29
34
  runningVersion: IReflexRunningVersionHeapPeaks | null;
30
35
  }
31
36
  export type IGetFunctionVersionStepStatsResponse = IResponse<IGetFunctionVersionStepStatsData>;
37
+
38
+ export interface IOpenFunctionVersionData {
39
+ /** The function, its draft now the definition of the version. */
40
+ function: IReflexFunction;
41
+ }
42
+ export type IOpenFunctionVersionResponse = IResponse<IOpenFunctionVersionData>;
@@ -17,3 +17,4 @@ export * from './application-run-settings.response';
17
17
  export * from './application-insights.response';
18
18
  export * from './alert-rule.response';
19
19
  export * from './route-stats.response';
20
+ export * from './function-template.response';
@@ -85,6 +85,12 @@ export interface IGetServiceVersionDraftStatusData {
85
85
  changedTasks: number;
86
86
  /** How many event triggers of the draft differ from the last Service version: added, modified or removed. 0 for a Service that is not a Discord bot. */
87
87
  changedEvents: number;
88
+ /**
89
+ * True exactly when `POST .../version` now would be refused with `VERSION_UNCHANGED`: no function
90
+ * changed and the whole snapshot (routes, CORS, rate limit, Discord commands and components, tasks)
91
+ * is the one of the last version. False for a Service without a version.
92
+ */
93
+ unchanged: boolean;
88
94
  }
89
95
  export type IGetServiceVersionDraftStatusResponse = IResponse<IGetServiceVersionDraftStatusData>;
90
96
 
@@ -19,3 +19,5 @@ export * from './reflex-insights.model';
19
19
  export * from './reflex-discord-event-log.model';
20
20
  export * from './reflex-run-settings.model';
21
21
  export * from './reflex-alert-rule.model';
22
+ export * from './reflex-access-request.model';
23
+ export * from './reflex-function-template.model';
@@ -0,0 +1,15 @@
1
+ import type { AccessRequestStatus } from '../../enum';
2
+ import type { IReflexAccessDeclaration } from './reflex-definition.model';
3
+
4
+ export interface IReflexAccessRequest {
5
+ id: string;
6
+ functionId: string;
7
+ declaration: IReflexAccessDeclaration;
8
+ /** Stable key of the declaration; one pending request per function and key. */
9
+ declarationKey: string;
10
+ status: AccessRequestStatus;
11
+ requestedByUserId: string;
12
+ requestedAt: Date;
13
+ resolvedByUserId: string | null;
14
+ resolvedAt: Date | null;
15
+ }
@@ -0,0 +1,18 @@
1
+ import type { ServiceType } from '../../enum';
2
+ import type { IReflexDefinition } from './reflex-definition.model';
3
+
4
+ /** A function saved by a member to start other functions of the application from it. */
5
+ export interface IReflexFunctionTemplate {
6
+ id: string;
7
+ applicationId: string;
8
+ /** Unique within the application, 100 characters at most. */
9
+ name: string;
10
+ /** 500 characters at most. */
11
+ description: string | null;
12
+ /** The type of Service the template suits; null for any. */
13
+ serviceType: ServiceType | null;
14
+ definition: IReflexDefinition;
15
+ createdByUserId: string;
16
+ createdAt: Date;
17
+ updatedAt: Date;
18
+ }
@@ -12,3 +12,8 @@ export interface IReflexFunctionVersion {
12
12
  publishedByUserId: string;
13
13
  publishedAt: Date;
14
14
  }
15
+
16
+ /** A row of the version list: the version and whether a Service version running it was ever put in service. */
17
+ export interface IReflexFunctionVersionRow extends IReflexFunctionVersion {
18
+ deployed: boolean;
19
+ }