@abyss-project/reflex 6.0.4 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/dist/api/function-run.api.d.ts +2 -1
  2. package/dist/api/function-run.api.js +3 -1
  3. package/dist/api/function-run.api.js.map +1 -1
  4. package/dist/api/function-settings.api.d.ts +3 -1
  5. package/dist/api/function-settings.api.js +7 -1
  6. package/dist/api/function-settings.api.js.map +1 -1
  7. package/dist/index.d.ts +5 -0
  8. package/dist/index.js +5 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/types/enum/reflex-error-code.enum.d.ts +2 -1
  11. package/dist/types/enum/reflex-error-code.enum.js +1 -0
  12. package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
  13. package/dist/types/interface/api/requests/application-run-settings.request.d.ts +1 -0
  14. package/dist/types/interface/api/requests/function-run.request.d.ts +8 -0
  15. package/dist/types/interface/api/requests/function-settings.request.d.ts +12 -0
  16. package/dist/types/interface/api/requests/service.request.d.ts +1 -0
  17. package/dist/types/interface/api/responses/function-run.response.d.ts +4 -0
  18. package/dist/types/interface/api/responses/function-settings.response.d.ts +5 -1
  19. package/dist/types/interface/models/index.d.ts +2 -0
  20. package/dist/types/interface/models/index.js +2 -0
  21. package/dist/types/interface/models/index.js.map +1 -1
  22. package/dist/types/interface/models/reflex-run-retention.model.d.ts +13 -0
  23. package/dist/types/interface/models/reflex-run-retention.model.js +8 -0
  24. package/dist/types/interface/models/reflex-run-retention.model.js.map +1 -0
  25. package/dist/types/interface/models/reflex-run-settings.model.d.ts +4 -0
  26. package/dist/types/interface/models/reflex-run.model.d.ts +5 -0
  27. package/dist/types/interface/models/reflex-service-deployment.model.d.ts +2 -2
  28. package/dist/types/interface/models/reflex-service-limits.model.d.ts +5 -2
  29. package/dist/types/interface/models/reflex-service.model.d.ts +1 -0
  30. package/dist/types/interface/models/reflex-storage-surplus.model.d.ts +11 -0
  31. package/dist/types/interface/models/reflex-storage-surplus.model.js +3 -0
  32. package/dist/types/interface/models/reflex-storage-surplus.model.js.map +1 -0
  33. package/package.json +10 -15
  34. package/src/api/application-run-settings.api.test.ts +62 -51
  35. package/src/api/function-run.api.ts +53 -38
  36. package/src/api/function-settings.api.ts +96 -74
  37. package/src/api/function.api.test.ts +55 -0
  38. package/src/api/index.ts +26 -26
  39. package/src/api/service-completion-webhook.api.test.ts +97 -97
  40. package/src/api/service-completion-webhook.api.ts +39 -39
  41. package/src/api/service-consumer.api.test.ts +104 -104
  42. package/src/api/service-consumer.api.ts +90 -90
  43. package/src/api/service-discord.api.test.ts +178 -178
  44. package/src/api/service-discord.api.ts +222 -222
  45. package/src/api/service-limits.api.test.ts +100 -100
  46. package/src/api/service-limits.api.ts +37 -37
  47. package/src/api/service-openapi.api.test.ts +52 -52
  48. package/src/api/service-openapi.api.ts +21 -21
  49. package/src/api/service-route.api.ts +74 -74
  50. package/src/api/service.api.test.ts +220 -215
  51. package/src/index.test.ts +104 -104
  52. package/src/index.ts +12 -0
  53. package/src/types/enum/access-grant-status.enum.ts +12 -12
  54. package/src/types/enum/access-kind.enum.ts +7 -7
  55. package/src/types/enum/access-request-status.enum.ts +11 -11
  56. package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
  57. package/src/types/enum/configuration-read-as.enum.ts +5 -5
  58. package/src/types/enum/discord-activity-type.enum.ts +9 -9
  59. package/src/types/enum/discord-channel-type.enum.ts +11 -11
  60. package/src/types/enum/discord-component-kind.enum.ts +7 -7
  61. package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
  62. package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
  63. package/src/types/enum/discord-event-status.enum.ts +13 -13
  64. package/src/types/enum/discord-event-type.enum.ts +7 -7
  65. package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
  66. package/src/types/enum/discord-gateway-state.enum.ts +11 -11
  67. package/src/types/enum/discord-host-action.enum.ts +35 -35
  68. package/src/types/enum/discord-locale.enum.ts +35 -35
  69. package/src/types/enum/discord-option-type.enum.ts +12 -12
  70. package/src/types/enum/discord-presence-status.enum.ts +8 -8
  71. package/src/types/enum/discord-sync-status.enum.ts +6 -6
  72. package/src/types/enum/discord-token-state.enum.ts +11 -11
  73. package/src/types/enum/execution-mode.enum.ts +9 -9
  74. package/src/types/enum/execution-profile.enum.ts +20 -20
  75. package/src/types/enum/execution-settings-source.enum.ts +9 -9
  76. package/src/types/enum/health-status.enum.ts +4 -4
  77. package/src/types/enum/insights-period.enum.ts +8 -8
  78. package/src/types/enum/log-cap-mode.enum.ts +6 -6
  79. package/src/types/enum/log-drop-cause.enum.ts +8 -8
  80. package/src/types/enum/reflex-alert-metric.enum.ts +5 -5
  81. package/src/types/enum/reflex-alert-notification-state.enum.ts +6 -6
  82. package/src/types/enum/reflex-alert-scope.enum.ts +6 -6
  83. package/src/types/enum/reflex-error-code.enum.ts +5 -0
  84. package/src/types/enum/route-method.enum.ts +9 -9
  85. package/src/types/enum/run-log-level.enum.ts +6 -6
  86. package/src/types/enum/run-mode.enum.ts +11 -11
  87. package/src/types/enum/run-step-status.enum.ts +7 -7
  88. package/src/types/enum/schedule-sync-status.enum.ts +6 -6
  89. package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
  90. package/src/types/enum/scheduled-run-status.enum.ts +17 -17
  91. package/src/types/enum/service-deployment-action.enum.ts +11 -11
  92. package/src/types/enum/service-deployment-status.enum.ts +5 -5
  93. package/src/types/enum/service-type.enum.ts +9 -9
  94. package/src/types/enum/service-version-change-kind.enum.ts +6 -6
  95. package/src/types/enum/trace-effect-type.enum.ts +12 -12
  96. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  97. package/src/types/enum/trigger-kind.enum.ts +8 -8
  98. package/src/types/enum/vault-value-source.enum.ts +12 -12
  99. package/src/types/enum/vault-visibility.enum.ts +5 -5
  100. package/src/types/index.ts +2 -2
  101. package/src/types/interface/api/index.ts +3 -3
  102. package/src/types/interface/api/requests/alert-rule.request.ts +53 -53
  103. package/src/types/interface/api/requests/application-insights.request.ts +18 -18
  104. package/src/types/interface/api/requests/application-run-settings.request.ts +13 -11
  105. package/src/types/interface/api/requests/function-access.request.ts +51 -51
  106. package/src/types/interface/api/requests/function-run.request.ts +10 -0
  107. package/src/types/interface/api/requests/function-settings.request.ts +50 -34
  108. package/src/types/interface/api/requests/function-template.request.ts +29 -29
  109. package/src/types/interface/api/requests/function-version.request.ts +38 -38
  110. package/src/types/interface/api/requests/function.request.ts +36 -36
  111. package/src/types/interface/api/requests/route-stats.request.ts +22 -22
  112. package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
  113. package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
  114. package/src/types/interface/api/requests/service-discord-event.request.ts +68 -68
  115. package/src/types/interface/api/requests/service-insights.request.ts +31 -31
  116. package/src/types/interface/api/requests/service-task.request.ts +80 -80
  117. package/src/types/interface/api/requests/service-version.request.ts +24 -24
  118. package/src/types/interface/api/requests/service.request.ts +48 -46
  119. package/src/types/interface/api/response.ts +4 -4
  120. package/src/types/interface/api/responses/alert-rule.response.ts +24 -24
  121. package/src/types/interface/api/responses/application-insights.response.ts +11 -11
  122. package/src/types/interface/api/responses/application-run-settings.response.ts +8 -8
  123. package/src/types/interface/api/responses/function-access.response.ts +45 -45
  124. package/src/types/interface/api/responses/function-run.response.ts +23 -18
  125. package/src/types/interface/api/responses/function-settings.response.ts +7 -0
  126. package/src/types/interface/api/responses/function-template.response.ts +21 -21
  127. package/src/types/interface/api/responses/function-version.response.ts +42 -42
  128. package/src/types/interface/api/responses/function.response.ts +25 -25
  129. package/src/types/interface/api/responses/route-stats.response.ts +15 -15
  130. package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
  131. package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
  132. package/src/types/interface/api/responses/service-discord-event.response.ts +24 -24
  133. package/src/types/interface/api/responses/service-insights.response.ts +11 -11
  134. package/src/types/interface/api/responses/service-task.response.ts +57 -57
  135. package/src/types/interface/api/responses/service-version.response.ts +112 -112
  136. package/src/types/interface/api/responses/service.response.ts +31 -31
  137. package/src/types/interface/health.response.ts +7 -7
  138. package/src/types/interface/index.ts +3 -3
  139. package/src/types/interface/models/index.ts +2 -0
  140. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  141. package/src/types/interface/models/reflex-access-request.model.ts +15 -15
  142. package/src/types/interface/models/reflex-alert-rule.model.ts +56 -56
  143. package/src/types/interface/models/reflex-definition.model.ts +31 -31
  144. package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -58
  145. package/src/types/interface/models/reflex-discord-event.model.ts +79 -79
  146. package/src/types/interface/models/reflex-discord.model.ts +196 -196
  147. package/src/types/interface/models/reflex-function-template.model.ts +18 -18
  148. package/src/types/interface/models/reflex-function-version.model.ts +19 -19
  149. package/src/types/interface/models/reflex-function.model.ts +30 -30
  150. package/src/types/interface/models/reflex-insights.model.ts +215 -215
  151. package/src/types/interface/models/reflex-price-list.model.ts +20 -20
  152. package/src/types/interface/models/reflex-run-retention.model.ts +24 -0
  153. package/src/types/interface/models/reflex-run-settings.model.ts +39 -28
  154. package/src/types/interface/models/reflex-run.model.ts +10 -0
  155. package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
  156. package/src/types/interface/models/reflex-service-deployment.model.ts +48 -46
  157. package/src/types/interface/models/reflex-service-limits.model.ts +17 -8
  158. package/src/types/interface/models/reflex-service.model.ts +47 -45
  159. package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
  160. package/src/types/interface/models/reflex-storage-surplus.model.ts +23 -0
  161. package/src/types/interface/models/reflex-task.model.ts +97 -97
@@ -1,74 +1,96 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IGetFunctionSettingsParams,
4
- IGetFunctionSettingsResponse,
5
- IRemoveFunctionEnvironmentSettingsParams,
6
- IRemoveFunctionEnvironmentSettingsResponse,
7
- ISetFunctionDefaultSettingsBody,
8
- ISetFunctionDefaultSettingsParams,
9
- ISetFunctionDefaultSettingsResponse,
10
- ISetFunctionEnvironmentSettingsBody,
11
- ISetFunctionEnvironmentSettingsParams,
12
- ISetFunctionEnvironmentSettingsResponse,
13
- ISetFunctionLogCapBody,
14
- ISetFunctionLogCapParams,
15
- ISetFunctionLogCapResponse,
16
- } from '../types';
17
-
18
- const settingsUrl = (params: { applicationId: string; functionId: string }): string =>
19
- `api/function/${params.applicationId}/${params.functionId}/settings`;
20
-
21
- /** `GET .../settings`: the default, the overrides, and what each environment runs with. Needs REFLEX_READ. */
22
- export const getFunctionSettings = async (
23
- params: IGetFunctionSettingsParams,
24
- ): Promise<IGetFunctionSettingsResponse> =>
25
- (await AbyssReflexCore.axios.get<IGetFunctionSettingsResponse>(settingsUrl(params))).data;
26
-
27
- /**
28
- * `PUT .../settings`: sets the default of every environment without an override, applied at once where the
29
- * function runs. Needs REFLEX_FUNCTION_UPDATE, and REFLEX_PUBLISH_PRODUCTION when the default applies to a
30
- * production environment where the function runs.
31
- */
32
- export const setFunctionDefaultSettings = async (
33
- params: ISetFunctionDefaultSettingsParams,
34
- body: ISetFunctionDefaultSettingsBody,
35
- ): Promise<ISetFunctionDefaultSettingsResponse> =>
36
- (await AbyssReflexCore.axios.put<ISetFunctionDefaultSettingsResponse>(settingsUrl(params), body))
37
- .data;
38
-
39
- /**
40
- * `PUT .../settings/:environmentId`: sets the override of one environment. Needs REFLEX_FUNCTION_UPDATE, and
41
- * REFLEX_PUBLISH_PRODUCTION for a production environment.
42
- */
43
- export const setFunctionEnvironmentSettings = async (
44
- params: ISetFunctionEnvironmentSettingsParams,
45
- body: ISetFunctionEnvironmentSettingsBody,
46
- ): Promise<ISetFunctionEnvironmentSettingsResponse> =>
47
- (
48
- await AbyssReflexCore.axios.put<ISetFunctionEnvironmentSettingsResponse>(
49
- `${settingsUrl(params)}/${params.environmentId}`,
50
- body,
51
- )
52
- ).data;
53
-
54
- /** `DELETE .../settings/:environmentId`: the environment falls back on the default. Same rights as setting it. */
55
- export const removeFunctionEnvironmentSettings = async (
56
- params: IRemoveFunctionEnvironmentSettingsParams,
57
- ): Promise<IRemoveFunctionEnvironmentSettingsResponse> =>
58
- (
59
- await AbyssReflexCore.axios.delete<IRemoveFunctionEnvironmentSettingsResponse>(
60
- `${settingsUrl(params)}/${params.environmentId}`,
61
- )
62
- ).data;
63
-
64
- /** `PUT .../log-cap`: sets the log cap of the function (inherit, none, or a number of lines). Needs REFLEX_FUNCTION_UPDATE. */
65
- export const setFunctionLogCap = async (
66
- params: ISetFunctionLogCapParams,
67
- body: ISetFunctionLogCapBody,
68
- ): Promise<ISetFunctionLogCapResponse> =>
69
- (
70
- await AbyssReflexCore.axios.put<ISetFunctionLogCapResponse>(
71
- `api/function/${params.applicationId}/${params.functionId}/log-cap`,
72
- body,
73
- )
74
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IGetFunctionRunRetentionParams,
4
+ IGetFunctionRunRetentionResponse,
5
+ IGetFunctionSettingsParams,
6
+ IGetFunctionSettingsResponse,
7
+ IRemoveFunctionEnvironmentSettingsParams,
8
+ IRemoveFunctionEnvironmentSettingsResponse,
9
+ ISetFunctionDefaultSettingsBody,
10
+ ISetFunctionDefaultSettingsParams,
11
+ ISetFunctionDefaultSettingsResponse,
12
+ ISetFunctionEnvironmentSettingsBody,
13
+ ISetFunctionEnvironmentSettingsParams,
14
+ ISetFunctionEnvironmentSettingsResponse,
15
+ ISetFunctionLogCapBody,
16
+ ISetFunctionLogCapParams,
17
+ ISetFunctionLogCapResponse,
18
+ ISetFunctionRunRetentionBody,
19
+ ISetFunctionRunRetentionParams,
20
+ ISetFunctionRunRetentionResponse,
21
+ } from '../types';
22
+
23
+ const settingsUrl = (params: { applicationId: string; functionId: string }): string =>
24
+ `api/function/${params.applicationId}/${params.functionId}/settings`;
25
+
26
+ /** `GET .../settings`: the default, the overrides, and what each environment runs with. Needs REFLEX_READ. */
27
+ export const getFunctionSettings = async (
28
+ params: IGetFunctionSettingsParams,
29
+ ): Promise<IGetFunctionSettingsResponse> =>
30
+ (await AbyssReflexCore.axios.get<IGetFunctionSettingsResponse>(settingsUrl(params))).data;
31
+
32
+ /**
33
+ * `PUT .../settings`: sets the default of every environment without an override, applied at once where the
34
+ * function runs. Needs REFLEX_FUNCTION_UPDATE, and REFLEX_PUBLISH_PRODUCTION when the default applies to a
35
+ * production environment where the function runs.
36
+ */
37
+ export const setFunctionDefaultSettings = async (
38
+ params: ISetFunctionDefaultSettingsParams,
39
+ body: ISetFunctionDefaultSettingsBody,
40
+ ): Promise<ISetFunctionDefaultSettingsResponse> =>
41
+ (await AbyssReflexCore.axios.put<ISetFunctionDefaultSettingsResponse>(settingsUrl(params), body))
42
+ .data;
43
+
44
+ /**
45
+ * `PUT .../settings/:environmentId`: sets the override of one environment. Needs REFLEX_FUNCTION_UPDATE, and
46
+ * REFLEX_PUBLISH_PRODUCTION for a production environment.
47
+ */
48
+ export const setFunctionEnvironmentSettings = async (
49
+ params: ISetFunctionEnvironmentSettingsParams,
50
+ body: ISetFunctionEnvironmentSettingsBody,
51
+ ): Promise<ISetFunctionEnvironmentSettingsResponse> =>
52
+ (
53
+ await AbyssReflexCore.axios.put<ISetFunctionEnvironmentSettingsResponse>(
54
+ `${settingsUrl(params)}/${params.environmentId}`,
55
+ body,
56
+ )
57
+ ).data;
58
+
59
+ /** `DELETE .../settings/:environmentId`: the environment falls back on the default. Same rights as setting it. */
60
+ export const removeFunctionEnvironmentSettings = async (
61
+ params: IRemoveFunctionEnvironmentSettingsParams,
62
+ ): Promise<IRemoveFunctionEnvironmentSettingsResponse> =>
63
+ (
64
+ await AbyssReflexCore.axios.delete<IRemoveFunctionEnvironmentSettingsResponse>(
65
+ `${settingsUrl(params)}/${params.environmentId}`,
66
+ )
67
+ ).data;
68
+
69
+ /** `PUT .../log-cap`: sets the log cap of the function (inherit, none, or a number of lines). Needs REFLEX_FUNCTION_UPDATE. */
70
+ export const setFunctionLogCap = async (
71
+ params: ISetFunctionLogCapParams,
72
+ body: ISetFunctionLogCapBody,
73
+ ): Promise<ISetFunctionLogCapResponse> =>
74
+ (
75
+ await AbyssReflexCore.axios.put<ISetFunctionLogCapResponse>(
76
+ `api/function/${params.applicationId}/${params.functionId}/log-cap`,
77
+ body,
78
+ )
79
+ ).data;
80
+
81
+ const runRetentionUrl = (params: { applicationId: string; functionId: string }): string =>
82
+ `api/function/${params.applicationId}/${params.functionId}/run-retention`;
83
+
84
+ /** `GET .../run-retention`: the retention tier of the function, the one it inherits and the versions kept. Needs REFLEX_READ. */
85
+ export const getFunctionRunRetention = async (
86
+ params: IGetFunctionRunRetentionParams,
87
+ ): Promise<IGetFunctionRunRetentionResponse> =>
88
+ (await AbyssReflexCore.axios.get<IGetFunctionRunRetentionResponse>(runRetentionUrl(params))).data;
89
+
90
+ /** `PUT .../run-retention`: sets the retention tier and the versions kept of the function. Needs REFLEX_FUNCTION_UPDATE. */
91
+ export const setFunctionRunRetention = async (
92
+ params: ISetFunctionRunRetentionParams,
93
+ body: ISetFunctionRunRetentionBody,
94
+ ): Promise<ISetFunctionRunRetentionResponse> =>
95
+ (await AbyssReflexCore.axios.put<ISetFunctionRunRetentionResponse>(runRetentionUrl(params), body))
96
+ .data;
@@ -8,6 +8,11 @@ import {
8
8
  REFLEX_EXECUTION_SETTINGS_LIMITS,
9
9
  RESPOND_STATUS_MAX,
10
10
  RESPOND_STATUS_MIN,
11
+ REFLEX_RUN_ARCHIVE_AFTER_DAYS,
12
+ REFLEX_RUN_ARCHIVE_MIN_TIER_DAYS,
13
+ REFLEX_RUN_RETENTION_TIER_DAYS,
14
+ REFLEX_VERSIONS_KEPT,
15
+ ReflexErrorCode,
11
16
  } from '..';
12
17
 
13
18
  const APP = 'app-1';
@@ -177,6 +182,34 @@ const calls: Call[] = [
177
182
  url: `${BASE}/run/r-1/state`,
178
183
  run: () => sdk().run.state({ applicationId: APP, functionId: FN, runId: 'r-1' }),
179
184
  },
185
+ {
186
+ label: 'run.favorite',
187
+ method: 'put',
188
+ url: `${BASE}/run/r-1/favorite`,
189
+ body: { isFavorite: true },
190
+ run: () =>
191
+ sdk().run.favorite(
192
+ { applicationId: APP, functionId: FN, runId: 'r-1' },
193
+ { isFavorite: true },
194
+ ),
195
+ },
196
+ {
197
+ label: 'runRetention.get',
198
+ method: 'get',
199
+ url: `${BASE}/run-retention`,
200
+ run: () => sdk().runRetention.get({ applicationId: APP, functionId: FN }),
201
+ },
202
+ {
203
+ label: 'runRetention.set',
204
+ method: 'put',
205
+ url: `${BASE}/run-retention`,
206
+ body: { runRetentionDays: 90, versionsKept: 30 },
207
+ run: () =>
208
+ sdk().runRetention.set(
209
+ { applicationId: APP, functionId: FN },
210
+ { runRetentionDays: 90, versionsKept: 30 },
211
+ ),
212
+ },
180
213
  {
181
214
  label: 'version.stepStats',
182
215
  method: 'get',
@@ -289,3 +322,25 @@ describe('respond status bounds', () => {
289
322
  expect([RESPOND_STATUS_MIN, RESPOND_STATUS_MAX]).toEqual([200, 599]);
290
323
  });
291
324
  });
325
+
326
+ describe('run retention constants (L3a)', () => {
327
+ it('list the seven tiers the database accepts', () => {
328
+ expect(REFLEX_RUN_RETENTION_TIER_DAYS).toEqual([3, 7, 15, 30, 90, 180, 365]);
329
+ });
330
+
331
+ it('bound the versions kept to 5 to 100, 20 by default', () => {
332
+ expect(REFLEX_VERSIONS_KEPT).toEqual({ default: 20, min: 5, max: 100 });
333
+ });
334
+
335
+ it('archive the detail past 30 days, for the tiers of 90 days and more', () => {
336
+ expect(REFLEX_RUN_ARCHIVE_AFTER_DAYS).toBe(30);
337
+ expect(REFLEX_RUN_ARCHIVE_MIN_TIER_DAYS).toBe(90);
338
+ expect(
339
+ REFLEX_RUN_RETENTION_TIER_DAYS.filter((d) => d >= REFLEX_RUN_ARCHIVE_MIN_TIER_DAYS),
340
+ ).toEqual([90, 180, 365]);
341
+ });
342
+
343
+ it('name the error of an archive that cannot be read', () => {
344
+ expect(ReflexErrorCode.ARCHIVE_UNAVAILABLE).toBe('ARCHIVE_UNAVAILABLE');
345
+ });
346
+ });
package/src/api/index.ts CHANGED
@@ -1,26 +1,26 @@
1
- export * from './health.api';
2
- export * from './function.api';
3
- export * from './function-access.api';
4
- export * from './function-test.api';
5
- export * from './function-version.api';
6
- export * from './function-run.api';
7
- export * from './function-settings.api';
8
- export * from './service.api';
9
- export * from './service-route.api';
10
- export * from './service-version.api';
11
- export * from './service-deployment.api';
12
- export * from './service-configuration.api';
13
- export * from './service-discord.api';
14
- export * from './service-discord-event.api';
15
- export * from './service-insights.api';
16
- export * from './function-insights.api';
17
- export * from './service-task.api';
18
- export * from './application-run-settings.api';
19
- export * from './application-insights.api';
20
- export * from './alert-rule.api';
21
- export * from './route-stats.api';
22
- export * from './function-template.api';
23
- export * from './service-consumer.api';
24
- export * from './service-openapi.api';
25
- export * from './service-limits.api';
26
- export * from './service-completion-webhook.api';
1
+ export * from './health.api';
2
+ export * from './function.api';
3
+ export * from './function-access.api';
4
+ export * from './function-test.api';
5
+ export * from './function-version.api';
6
+ export * from './function-run.api';
7
+ export * from './function-settings.api';
8
+ export * from './service.api';
9
+ export * from './service-route.api';
10
+ export * from './service-version.api';
11
+ export * from './service-deployment.api';
12
+ export * from './service-configuration.api';
13
+ export * from './service-discord.api';
14
+ export * from './service-discord-event.api';
15
+ export * from './service-insights.api';
16
+ export * from './function-insights.api';
17
+ export * from './service-task.api';
18
+ export * from './application-run-settings.api';
19
+ export * from './application-insights.api';
20
+ export * from './alert-rule.api';
21
+ export * from './route-stats.api';
22
+ export * from './function-template.api';
23
+ export * from './service-consumer.api';
24
+ export * from './service-openapi.api';
25
+ export * from './service-limits.api';
26
+ export * from './service-completion-webhook.api';
@@ -1,97 +1,97 @@
1
- import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
- import {
3
- AbyssReflexCore,
4
- COMPLETION_DELIVERY_ID_HEADER,
5
- CompletionDeliveryStatus,
6
- DEFAULT_REFLEX_EXECUTION_SETTINGS,
7
- REFLEX_COMPLETION_DELIVERY_ERRORS,
8
- REFLEX_COMPLETION_WEBHOOK_LIMITS,
9
- RESERVED_EXECUTIONS_SEGMENT,
10
- RunStatus,
11
- } from '..';
12
-
13
- const APP = 'app-1';
14
- const SVC = 'svc-1';
15
- const BASE = `api/service/${APP}/${SVC}`;
16
- const SERVICE = { applicationId: APP, serviceId: SVC };
17
-
18
- interface Call {
19
- label: string;
20
- method: string;
21
- url: string;
22
- body?: unknown;
23
- run: () => Promise<unknown>;
24
- }
25
-
26
- const webhook = () => AbyssReflexCore.sdk.service.completionWebhook;
27
-
28
- const calls: Call[] = [
29
- {
30
- label: 'get',
31
- method: 'get',
32
- url: `${BASE}/completion-webhook`,
33
- run: () => webhook().get(SERVICE),
34
- },
35
- {
36
- label: 'rotateSecret',
37
- method: 'post',
38
- url: `${BASE}/completion-webhook/e-1/secret`,
39
- body: {},
40
- run: () => webhook().rotateSecret({ ...SERVICE, environmentId: 'e-1' }),
41
- },
42
- ];
43
-
44
- describe('AbyssReflexCore completion webhook routes', () => {
45
- const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
46
- async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
47
- );
48
-
49
- beforeAll(() => {
50
- AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
51
- AbyssReflexCore.axios.defaults.adapter = adapter;
52
- });
53
-
54
- beforeEach(() => adapter.mockClear());
55
-
56
- it.each(calls)('$label calls $method $url', async (call) => {
57
- await call.run();
58
-
59
- const config = adapter.mock.calls[0][0];
60
- expect(config.method).toBe(call.method);
61
- expect(config.url).toBe(call.url);
62
- expect(config.baseURL).toBe('http://reflex.test/');
63
- if (call.body !== undefined) {
64
- expect(JSON.parse(config.data)).toEqual(call.body);
65
- }
66
- });
67
-
68
- it('exposes no route twice', () => {
69
- expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
70
- });
71
-
72
- it('carries the bounds and the names of the completion webhook', () => {
73
- expect(REFLEX_COMPLETION_WEBHOOK_LIMITS).toEqual({
74
- urlMaxLength: 2048,
75
- retryDelaysMinutes: [1, 5, 15, 30, 60],
76
- sendTimeoutMs: 10_000,
77
- outputMaxBytes: 65_536,
78
- });
79
- expect(COMPLETION_DELIVERY_ID_HEADER).toBe('x-abyss-delivery-id');
80
- expect(REFLEX_COMPLETION_DELIVERY_ERRORS).toEqual({
81
- refusedAddress: 'The URL is not https, or reaches an address the edge may not reach',
82
- noSigningSecret: 'No signing secret for the Service in the environment',
83
- invalidUrl: 'The URL is not valid',
84
- receiverTimeoutPrefix: 'The receiver did not answer within',
85
- requestFailedPrefix: 'The request failed',
86
- httpPrefix: 'HTTP',
87
- redirectsNotFollowed: 'redirects are not followed',
88
- });
89
- expect(RESERVED_EXECUTIONS_SEGMENT).toBe('_executions');
90
- expect(Object.values(CompletionDeliveryStatus)).toEqual(['PENDING', 'DELIVERED', 'FAILED']);
91
- expect(RunStatus.REFUSED).toBe('REFUSED');
92
- });
93
-
94
- it('sets no completion webhook by default', () => {
95
- expect(DEFAULT_REFLEX_EXECUTION_SETTINGS.completionWebhookUrl).toBeNull();
96
- });
97
- });
1
+ import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
2
+ import {
3
+ AbyssReflexCore,
4
+ COMPLETION_DELIVERY_ID_HEADER,
5
+ CompletionDeliveryStatus,
6
+ DEFAULT_REFLEX_EXECUTION_SETTINGS,
7
+ REFLEX_COMPLETION_DELIVERY_ERRORS,
8
+ REFLEX_COMPLETION_WEBHOOK_LIMITS,
9
+ RESERVED_EXECUTIONS_SEGMENT,
10
+ RunStatus,
11
+ } from '..';
12
+
13
+ const APP = 'app-1';
14
+ const SVC = 'svc-1';
15
+ const BASE = `api/service/${APP}/${SVC}`;
16
+ const SERVICE = { applicationId: APP, serviceId: SVC };
17
+
18
+ interface Call {
19
+ label: string;
20
+ method: string;
21
+ url: string;
22
+ body?: unknown;
23
+ run: () => Promise<unknown>;
24
+ }
25
+
26
+ const webhook = () => AbyssReflexCore.sdk.service.completionWebhook;
27
+
28
+ const calls: Call[] = [
29
+ {
30
+ label: 'get',
31
+ method: 'get',
32
+ url: `${BASE}/completion-webhook`,
33
+ run: () => webhook().get(SERVICE),
34
+ },
35
+ {
36
+ label: 'rotateSecret',
37
+ method: 'post',
38
+ url: `${BASE}/completion-webhook/e-1/secret`,
39
+ body: {},
40
+ run: () => webhook().rotateSecret({ ...SERVICE, environmentId: 'e-1' }),
41
+ },
42
+ ];
43
+
44
+ describe('AbyssReflexCore completion webhook routes', () => {
45
+ const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
46
+ async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
47
+ );
48
+
49
+ beforeAll(() => {
50
+ AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
51
+ AbyssReflexCore.axios.defaults.adapter = adapter;
52
+ });
53
+
54
+ beforeEach(() => adapter.mockClear());
55
+
56
+ it.each(calls)('$label calls $method $url', async (call) => {
57
+ await call.run();
58
+
59
+ const config = adapter.mock.calls[0][0];
60
+ expect(config.method).toBe(call.method);
61
+ expect(config.url).toBe(call.url);
62
+ expect(config.baseURL).toBe('http://reflex.test/');
63
+ if (call.body !== undefined) {
64
+ expect(JSON.parse(config.data)).toEqual(call.body);
65
+ }
66
+ });
67
+
68
+ it('exposes no route twice', () => {
69
+ expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
70
+ });
71
+
72
+ it('carries the bounds and the names of the completion webhook', () => {
73
+ expect(REFLEX_COMPLETION_WEBHOOK_LIMITS).toEqual({
74
+ urlMaxLength: 2048,
75
+ retryDelaysMinutes: [1, 5, 15, 30, 60],
76
+ sendTimeoutMs: 10_000,
77
+ outputMaxBytes: 65_536,
78
+ });
79
+ expect(COMPLETION_DELIVERY_ID_HEADER).toBe('x-abyss-delivery-id');
80
+ expect(REFLEX_COMPLETION_DELIVERY_ERRORS).toEqual({
81
+ refusedAddress: 'The URL is not https, or reaches an address the edge may not reach',
82
+ noSigningSecret: 'No signing secret for the Service in the environment',
83
+ invalidUrl: 'The URL is not valid',
84
+ receiverTimeoutPrefix: 'The receiver did not answer within',
85
+ requestFailedPrefix: 'The request failed',
86
+ httpPrefix: 'HTTP',
87
+ redirectsNotFollowed: 'redirects are not followed',
88
+ });
89
+ expect(RESERVED_EXECUTIONS_SEGMENT).toBe('_executions');
90
+ expect(Object.values(CompletionDeliveryStatus)).toEqual(['PENDING', 'DELIVERED', 'FAILED']);
91
+ expect(RunStatus.REFUSED).toBe('REFUSED');
92
+ });
93
+
94
+ it('sets no completion webhook by default', () => {
95
+ expect(DEFAULT_REFLEX_EXECUTION_SETTINGS.completionWebhookUrl).toBeNull();
96
+ });
97
+ });
@@ -1,39 +1,39 @@
1
- import { AbyssReflexCore } from '..';
2
- import type {
3
- IGetServiceCompletionWebhookParams,
4
- IGetServiceCompletionWebhookResponse,
5
- IRotateServiceCompletionWebhookSecretParams,
6
- IRotateServiceCompletionWebhookSecretResponse,
7
- } from '../types';
8
-
9
- const completionWebhookUrl = (params: { applicationId: string; serviceId: string }): string =>
10
- `api/service/${params.applicationId}/${params.serviceId}/completion-webhook`;
11
-
12
- /**
13
- * `GET .../completion-webhook`: the environments where the completion webhook of the Service has a signing
14
- * secret, never the secret itself. Needs REFLEX_READ.
15
- */
16
- export const getServiceCompletionWebhook = async (
17
- params: IGetServiceCompletionWebhookParams,
18
- ): Promise<IGetServiceCompletionWebhookResponse> =>
19
- (
20
- await AbyssReflexCore.axios.get<IGetServiceCompletionWebhookResponse>(
21
- completionWebhookUrl(params),
22
- )
23
- ).data;
24
-
25
- /**
26
- * `POST .../completion-webhook/:environmentId/secret`: creates or renews the signing secret of the completion webhook
27
- * in the environment, in clear ONCE; the next deliveries are signed with it. Needs REFLEX_PUBLISH, and
28
- * REFLEX_PUBLISH_PRODUCTION for a production environment (`403 PUBLISH_PRODUCTION_REQUIRED`); `404
29
- * ENVIRONMENT_NOT_FOUND` for an environment outside the application.
30
- */
31
- export const rotateServiceCompletionWebhookSecret = async (
32
- params: IRotateServiceCompletionWebhookSecretParams,
33
- ): Promise<IRotateServiceCompletionWebhookSecretResponse> =>
34
- (
35
- await AbyssReflexCore.axios.post<IRotateServiceCompletionWebhookSecretResponse>(
36
- `${completionWebhookUrl(params)}/${params.environmentId}/secret`,
37
- {},
38
- )
39
- ).data;
1
+ import { AbyssReflexCore } from '..';
2
+ import type {
3
+ IGetServiceCompletionWebhookParams,
4
+ IGetServiceCompletionWebhookResponse,
5
+ IRotateServiceCompletionWebhookSecretParams,
6
+ IRotateServiceCompletionWebhookSecretResponse,
7
+ } from '../types';
8
+
9
+ const completionWebhookUrl = (params: { applicationId: string; serviceId: string }): string =>
10
+ `api/service/${params.applicationId}/${params.serviceId}/completion-webhook`;
11
+
12
+ /**
13
+ * `GET .../completion-webhook`: the environments where the completion webhook of the Service has a signing
14
+ * secret, never the secret itself. Needs REFLEX_READ.
15
+ */
16
+ export const getServiceCompletionWebhook = async (
17
+ params: IGetServiceCompletionWebhookParams,
18
+ ): Promise<IGetServiceCompletionWebhookResponse> =>
19
+ (
20
+ await AbyssReflexCore.axios.get<IGetServiceCompletionWebhookResponse>(
21
+ completionWebhookUrl(params),
22
+ )
23
+ ).data;
24
+
25
+ /**
26
+ * `POST .../completion-webhook/:environmentId/secret`: creates or renews the signing secret of the completion webhook
27
+ * in the environment, in clear ONCE; the next deliveries are signed with it. Needs REFLEX_PUBLISH, and
28
+ * REFLEX_PUBLISH_PRODUCTION for a production environment (`403 PUBLISH_PRODUCTION_REQUIRED`); `404
29
+ * ENVIRONMENT_NOT_FOUND` for an environment outside the application.
30
+ */
31
+ export const rotateServiceCompletionWebhookSecret = async (
32
+ params: IRotateServiceCompletionWebhookSecretParams,
33
+ ): Promise<IRotateServiceCompletionWebhookSecretResponse> =>
34
+ (
35
+ await AbyssReflexCore.axios.post<IRotateServiceCompletionWebhookSecretResponse>(
36
+ `${completionWebhookUrl(params)}/${params.environmentId}/secret`,
37
+ {},
38
+ )
39
+ ).data;