@abyss-project/reflex 6.5.0 → 6.9.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 (132) hide show
  1. package/dist/api/index.d.ts +1 -2
  2. package/dist/api/index.js +1 -2
  3. package/dist/api/index.js.map +1 -1
  4. package/dist/api/reflex-admin.admin.api.d.ts +5 -0
  5. package/dist/api/reflex-admin.admin.api.js +18 -0
  6. package/dist/api/reflex-admin.admin.api.js.map +1 -0
  7. package/dist/index.d.ts +13 -9
  8. package/dist/index.js +13 -9
  9. package/dist/index.js.map +1 -1
  10. package/dist/types/enum/index.d.ts +2 -4
  11. package/dist/types/enum/index.js +2 -4
  12. package/dist/types/enum/index.js.map +1 -1
  13. package/dist/types/enum/reflex-abuse-rule.enum.d.ts +5 -0
  14. package/dist/types/enum/reflex-abuse-rule.enum.js +10 -0
  15. package/dist/types/enum/reflex-abuse-rule.enum.js.map +1 -0
  16. package/dist/types/enum/reflex-admin-hold-kind.enum.d.ts +4 -0
  17. package/dist/types/enum/reflex-admin-hold-kind.enum.js +9 -0
  18. package/dist/types/enum/reflex-admin-hold-kind.enum.js.map +1 -0
  19. package/dist/types/enum/reflex-error-code.enum.d.ts +3 -2
  20. package/dist/types/enum/reflex-error-code.enum.js +2 -1
  21. package/dist/types/enum/reflex-error-code.enum.js.map +1 -1
  22. package/dist/types/enum/trigger-access-mode.enum.d.ts +1 -2
  23. package/dist/types/enum/trigger-access-mode.enum.js +0 -1
  24. package/dist/types/enum/trigger-access-mode.enum.js.map +1 -1
  25. package/dist/types/interface/api/requests/index.d.ts +1 -2
  26. package/dist/types/interface/api/requests/index.js +1 -2
  27. package/dist/types/interface/api/requests/index.js.map +1 -1
  28. package/dist/types/interface/api/requests/reflex-admin.admin.request.d.ts +21 -0
  29. package/dist/types/interface/api/requests/{code-environment.request.js → reflex-admin.admin.request.js} +1 -1
  30. package/dist/types/interface/api/requests/reflex-admin.admin.request.js.map +1 -0
  31. package/dist/types/interface/api/requests/service.request.d.ts +1 -2
  32. package/dist/types/interface/api/responses/index.d.ts +1 -2
  33. package/dist/types/interface/api/responses/index.js +1 -2
  34. package/dist/types/interface/api/responses/index.js.map +1 -1
  35. package/dist/types/interface/api/responses/reflex-admin.admin.response.d.ts +19 -0
  36. package/dist/types/interface/api/{requests/service-template.request.js → responses/reflex-admin.admin.response.js} +1 -1
  37. package/dist/types/interface/api/responses/reflex-admin.admin.response.js.map +1 -0
  38. package/dist/types/interface/models/index.d.ts +1 -3
  39. package/dist/types/interface/models/index.js +1 -3
  40. package/dist/types/interface/models/index.js.map +1 -1
  41. package/dist/types/interface/models/reflex-admin-hold.model.d.ts +44 -0
  42. package/dist/types/interface/models/reflex-admin-hold.model.js +11 -0
  43. package/dist/types/interface/models/reflex-admin-hold.model.js.map +1 -0
  44. package/dist/types/interface/models/reflex-service-deployment.model.d.ts +2 -1
  45. package/dist/types/interface/models/reflex-service.model.d.ts +2 -0
  46. package/dist/types/interface/models/reflex-service.model.js.map +1 -1
  47. package/package.json +1 -1
  48. package/src/api/index.ts +1 -2
  49. package/src/api/reflex-admin.admin.api.test.ts +52 -0
  50. package/src/api/reflex-admin.admin.api.ts +53 -0
  51. package/src/api/service-route.api.ts +74 -74
  52. package/src/index.ts +506 -497
  53. package/src/types/enum/index.ts +2 -4
  54. package/src/types/enum/reflex-abuse-rule.enum.ts +9 -0
  55. package/src/types/enum/reflex-admin-hold-kind.enum.ts +7 -0
  56. package/src/types/enum/reflex-alert-metric.enum.ts +5 -5
  57. package/src/types/enum/reflex-alert-notification-state.enum.ts +6 -6
  58. package/src/types/enum/reflex-alert-scope.enum.ts +6 -6
  59. package/src/types/enum/reflex-error-code.enum.ts +7 -5
  60. package/src/types/enum/trigger-access-mode.enum.ts +12 -16
  61. package/src/types/interface/api/requests/index.ts +1 -2
  62. package/src/types/interface/api/requests/reflex-admin.admin.request.ts +26 -0
  63. package/src/types/interface/api/requests/service.request.ts +1 -7
  64. package/src/types/interface/api/responses/index.ts +1 -2
  65. package/src/types/interface/api/responses/reflex-admin.admin.response.ts +25 -0
  66. package/src/types/interface/api/responses/service-route.response.ts +31 -31
  67. package/src/types/interface/models/index.ts +1 -3
  68. package/src/types/interface/models/reflex-admin-hold.model.ts +55 -0
  69. package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
  70. package/src/types/interface/models/reflex-service-deployment.model.ts +51 -48
  71. package/src/types/interface/models/reflex-service-limits.model.ts +92 -92
  72. package/src/types/interface/models/reflex-service-version.model.ts +64 -64
  73. package/src/types/interface/models/reflex-service.model.ts +50 -47
  74. package/dist/api/code-environment.api.d.ts +0 -2
  75. package/dist/api/code-environment.api.js +0 -7
  76. package/dist/api/code-environment.api.js.map +0 -1
  77. package/dist/api/service-template.api.d.ts +0 -2
  78. package/dist/api/service-template.api.js +0 -7
  79. package/dist/api/service-template.api.js.map +0 -1
  80. package/dist/code/index.d.ts +0 -1
  81. package/dist/code/index.js +0 -18
  82. package/dist/code/index.js.map +0 -1
  83. package/dist/code/reflex-code-declarations.d.ts +0 -1
  84. package/dist/code/reflex-code-declarations.js +0 -644
  85. package/dist/code/reflex-code-declarations.js.map +0 -1
  86. package/dist/types/enum/reflex-code-diagnostic-category.enum.d.ts +0 -6
  87. package/dist/types/enum/reflex-code-diagnostic-category.enum.js +0 -11
  88. package/dist/types/enum/reflex-code-diagnostic-category.enum.js.map +0 -1
  89. package/dist/types/enum/service-template-follow-up-kind.enum.d.ts +0 -10
  90. package/dist/types/enum/service-template-follow-up-kind.enum.js +0 -15
  91. package/dist/types/enum/service-template-follow-up-kind.enum.js.map +0 -1
  92. package/dist/types/enum/service-template-id.enum.d.ts +0 -10
  93. package/dist/types/enum/service-template-id.enum.js +0 -15
  94. package/dist/types/enum/service-template-id.enum.js.map +0 -1
  95. package/dist/types/enum/service-template-parameter-kind.enum.d.ts +0 -4
  96. package/dist/types/enum/service-template-parameter-kind.enum.js +0 -9
  97. package/dist/types/enum/service-template-parameter-kind.enum.js.map +0 -1
  98. package/dist/types/interface/api/requests/code-environment.request.d.ts +0 -3
  99. package/dist/types/interface/api/requests/code-environment.request.js.map +0 -1
  100. package/dist/types/interface/api/requests/service-template.request.d.ts +0 -3
  101. package/dist/types/interface/api/requests/service-template.request.js.map +0 -1
  102. package/dist/types/interface/api/responses/code-environment.response.d.ts +0 -6
  103. package/dist/types/interface/api/responses/code-environment.response.js +0 -3
  104. package/dist/types/interface/api/responses/code-environment.response.js.map +0 -1
  105. package/dist/types/interface/api/responses/service-template.response.d.ts +0 -6
  106. package/dist/types/interface/api/responses/service-template.response.js +0 -3
  107. package/dist/types/interface/api/responses/service-template.response.js.map +0 -1
  108. package/dist/types/interface/models/reflex-code-diagnostic.model.d.ts +0 -10
  109. package/dist/types/interface/models/reflex-code-diagnostic.model.js +0 -5
  110. package/dist/types/interface/models/reflex-code-diagnostic.model.js.map +0 -1
  111. package/dist/types/interface/models/reflex-code-environment.model.d.ts +0 -9
  112. package/dist/types/interface/models/reflex-code-environment.model.js +0 -3
  113. package/dist/types/interface/models/reflex-code-environment.model.js.map +0 -1
  114. package/dist/types/interface/models/reflex-service-template.model.d.ts +0 -33
  115. package/dist/types/interface/models/reflex-service-template.model.js +0 -3
  116. package/dist/types/interface/models/reflex-service-template.model.js.map +0 -1
  117. package/src/api/code-environment.api.ts +0 -15
  118. package/src/api/service-template.api.test.ts +0 -41
  119. package/src/api/service-template.api.ts +0 -12
  120. package/src/code/index.ts +0 -1
  121. package/src/code/reflex-code-declarations.ts +0 -646
  122. package/src/types/enum/reflex-code-diagnostic-category.enum.ts +0 -11
  123. package/src/types/enum/service-template-follow-up-kind.enum.ts +0 -19
  124. package/src/types/enum/service-template-id.enum.ts +0 -19
  125. package/src/types/enum/service-template-parameter-kind.enum.ts +0 -7
  126. package/src/types/interface/api/requests/code-environment.request.ts +0 -3
  127. package/src/types/interface/api/requests/service-template.request.ts +0 -3
  128. package/src/types/interface/api/responses/code-environment.response.ts +0 -7
  129. package/src/types/interface/api/responses/service-template.response.ts +0 -8
  130. package/src/types/interface/models/reflex-code-diagnostic.model.ts +0 -15
  131. package/src/types/interface/models/reflex-code-environment.model.ts +0 -17
  132. package/src/types/interface/models/reflex-service-template.model.ts +0 -55
@@ -49,7 +49,5 @@ export * from './reflex-alert-notification-state.enum';
49
49
  export * from './access-request-status.enum';
50
50
  export * from './service-block-reason.enum';
51
51
  export * from './completion-delivery-status.enum';
52
- export * from './service-template-id.enum';
53
- export * from './service-template-follow-up-kind.enum';
54
- export * from './service-template-parameter-kind.enum';
55
- export * from './reflex-code-diagnostic-category.enum';
52
+ export * from './reflex-admin-hold-kind.enum';
53
+ export * from './reflex-abuse-rule.enum';
@@ -0,0 +1,9 @@
1
+ /** The rule of the abuse detector a Service crossed (`REFLEX_ABUSE_THRESHOLDS`). */
2
+ export enum ReflexAbuseRule {
3
+ /** At least `failureRate.minRuns` runs in the window and a failed share of `failureRate.minRatio` or more. */
4
+ FAILURE_RATE = 'FAILURE_RATE',
5
+ /** The cost of the window is `costSpike.factor` times the daily baseline or more, and at least `costSpike.minMillicredits`. */
6
+ COST_SPIKE = 'COST_SPIKE',
7
+ /** The network sent out in the window reaches `netOut.minBytes`. */
8
+ NET_OUT = 'NET_OUT',
9
+ }
@@ -0,0 +1,7 @@
1
+ /** How Abyss holds a Service in an environment (back-office gesture, outside the member's reach). */
2
+ export enum ReflexAdminHoldKind {
3
+ /** The Service is paused: it answers `503 SERVICE_PAUSED`; the member cannot resume it (`409 ADMIN_HOLD`). */
4
+ PAUSE = 'PAUSE',
5
+ /** The Service is suspended: it answers `503 SERVICE_SUSPENDED` and its writes are refused (`409 SERVICE_SUSPENDED`). */
6
+ SUSPEND = 'SUSPEND',
7
+ }
@@ -1,5 +1,5 @@
1
- /** What an alert rule measures over its window: the error rate in percent, or the 95th percentile of the duration in ms. */
2
- export enum ReflexAlertMetric {
3
- ERROR_RATE = 'ERROR_RATE',
4
- LATENCY_P95 = 'LATENCY_P95',
5
- }
1
+ /** What an alert rule measures over its window: the error rate in percent, or the 95th percentile of the duration in ms. */
2
+ export enum ReflexAlertMetric {
3
+ ERROR_RATE = 'ERROR_RATE',
4
+ LATENCY_P95 = 'LATENCY_P95',
5
+ }
@@ -1,6 +1,6 @@
1
- /** What became of the last incident report of an alert rule. */
2
- export enum ReflexAlertNotificationState {
3
- SENT = 'SENT',
4
- MONITOR_NOT_ACTIVATED = 'MONITOR_NOT_ACTIVATED',
5
- FAILED = 'FAILED',
6
- }
1
+ /** What became of the last incident report of an alert rule. */
2
+ export enum ReflexAlertNotificationState {
3
+ SENT = 'SENT',
4
+ MONITOR_NOT_ACTIVATED = 'MONITOR_NOT_ACTIVATED',
5
+ FAILED = 'FAILED',
6
+ }
@@ -1,6 +1,6 @@
1
- /** What an alert rule watches: a whole Service, one route of a Service, or one function. */
2
- export enum ReflexAlertScope {
3
- SERVICE = 'SERVICE',
4
- ROUTE = 'ROUTE',
5
- FUNCTION = 'FUNCTION',
6
- }
1
+ /** What an alert rule watches: a whole Service, one route of a Service, or one function. */
2
+ export enum ReflexAlertScope {
3
+ SERVICE = 'SERVICE',
4
+ ROUTE = 'ROUTE',
5
+ FUNCTION = 'FUNCTION',
6
+ }
@@ -71,11 +71,6 @@ export enum ReflexErrorCode {
71
71
  */
72
72
  COMPLETION_WEBHOOK_URL_REFUSED = 'COMPLETION_WEBHOOK_URL_REFUSED',
73
73
  /**
74
- * 422: a CODE step of a function has a fault that blocks the publication of the Service (syntax, library, size or
75
- * types); `error.details` holds the `IReflexCodeDiagnostic` of each. Nothing was published.
76
- */
77
- CODE_CHECK_FAILED = 'CODE_CHECK_FAILED',
78
- /**
79
74
  * 503: the run detail is in the customer's archive and the archive cannot be read now (Storage unreachable, key
80
75
  * unavailable, object failing its check). The run itself is untouched; asking again later may succeed.
81
76
  */
@@ -91,4 +86,11 @@ export enum ReflexErrorCode {
91
86
  * versions that exist and the executions go on. Delete versions, or raise the quota or the threshold.
92
87
  */
93
88
  STORAGE_PUBLISH_REFUSED = 'STORAGE_PUBLISH_REFUSED',
89
+ /** 409: Abyss holds the Service (pause) in this environment; the member cannot resume it. */
90
+ ADMIN_HOLD = 'ADMIN_HOLD',
91
+ /**
92
+ * 503 (edge): Abyss suspended the Service in this environment; nothing ran, nothing is billed. 409 on an API call:
93
+ * a write on the Service or its functions, or a go-live or rollback, while an environment of the Service is suspended.
94
+ */
95
+ SERVICE_SUSPENDED = 'SERVICE_SUSPENDED',
94
96
  }
@@ -1,16 +1,12 @@
1
- /**
2
- * Who may call a route of a Service.
3
- * - PUBLIC: anyone.
4
- * - API_KEY: the caller sends the key in `x-api-key`.
5
- * - SIGNATURE: the caller signs the raw body: `x-reflex-signature: sha256=<hex HMAC-SHA256(secret,
6
- * "<timestamp>." + body)>` with `x-reflex-timestamp` in Unix seconds, within 300 s of the edge's clock.
7
- * - GITHUB_SIGNATURE: the caller is GitHub (or signs like it): `X-Hub-Signature-256: sha256=<hex
8
- * HMAC-SHA256(secret, raw body)>`. There is no timestamp, so no replay window: a function that must not
9
- * process a delivery twice deduplicates with the `X-GitHub-Delivery` header.
10
- */
11
- export enum TriggerAccessMode {
12
- PUBLIC = 'PUBLIC',
13
- API_KEY = 'API_KEY',
14
- SIGNATURE = 'SIGNATURE',
15
- GITHUB_SIGNATURE = 'GITHUB_SIGNATURE',
16
- }
1
+ /**
2
+ * Who may call a route of a Service.
3
+ * - PUBLIC: anyone.
4
+ * - API_KEY: the caller sends the key in `x-api-key`.
5
+ * - SIGNATURE: the caller signs the raw body: `x-reflex-signature: sha256=<hex HMAC-SHA256(secret,
6
+ * "<timestamp>." + body)>` with `x-reflex-timestamp` in Unix seconds, within 300 s of the edge's clock.
7
+ */
8
+ export enum TriggerAccessMode {
9
+ PUBLIC = 'PUBLIC',
10
+ API_KEY = 'API_KEY',
11
+ SIGNATURE = 'SIGNATURE',
12
+ }
@@ -22,6 +22,5 @@ export * from './service-consumer.request';
22
22
  export * from './service-openapi.request';
23
23
  export * from './service-limits.request';
24
24
  export * from './service-completion-webhook.request';
25
- export * from './service-template.request';
26
- export * from './code-environment.request';
27
25
  export * from './storage-surplus.admin.request';
26
+ export * from './reflex-admin.admin.request';
@@ -0,0 +1,26 @@
1
+ import type { ReflexAdminHoldKind } from '../../../enum';
2
+
3
+ export interface ISetServiceHoldAdminParams {
4
+ serviceId: string;
5
+ environmentId: string;
6
+ }
7
+ export interface ISetServiceHoldAdminBody {
8
+ kind: ReflexAdminHoldKind;
9
+ }
10
+
11
+ export interface ILiftServiceHoldAdminParams {
12
+ serviceId: string;
13
+ environmentId: string;
14
+ }
15
+
16
+ export interface IWithdrawServiceHoldAdminParams {
17
+ serviceId: string;
18
+ environmentId: string;
19
+ }
20
+
21
+ export interface IListUsageAdminQuery {
22
+ window: '24h' | '7d';
23
+ sort: 'cost' | 'runs' | 'failed' | 'netOut';
24
+ /** 1 by default; 50 rows per page. */
25
+ page?: number;
26
+ }
@@ -1,5 +1,5 @@
1
1
  import type { ServiceType } from '../../../enum';
2
- import type { IReflexServiceCors, IReflexServiceTemplateChoice } from '../../models';
2
+ import type { IReflexServiceCors } from '../../models';
3
3
 
4
4
  export interface IListServiceParams {
5
5
  applicationId: string;
@@ -18,12 +18,6 @@ export interface ICreateServiceBody {
18
18
  cors?: IReflexServiceCors;
19
19
  /** 1 to 6000. Not for a `DISCORD_BOT` Service: `400 SERVICE_TYPE_FIELD_REFUSED`. */
20
20
  rateLimitPerIpPerMinute?: number;
21
- /**
22
- * Creates the Service, its functions and its triggers from a starter template, in one transaction. Nothing
23
- * is published, put in service or granted. `400` when `template.id` is of another Service type than `type`,
24
- * or a parameter is missing, unknown or invalid.
25
- */
26
- template?: IReflexServiceTemplateChoice;
27
21
  }
28
22
 
29
23
  export interface IGetServiceParams {
@@ -22,6 +22,5 @@ export * from './service-consumer.response';
22
22
  export * from './service-openapi.response';
23
23
  export * from './service-limits.response';
24
24
  export * from './service-completion-webhook.response';
25
- export * from './service-template.response';
26
- export * from './code-environment.response';
27
25
  export * from './storage-surplus.admin.response';
26
+ export * from './reflex-admin.admin.response';
@@ -0,0 +1,25 @@
1
+ import type { IReflexAdminUsageRow, IReflexServiceDeployment } from '../../models';
2
+ import type { IResponse } from '../response';
3
+
4
+ export interface ISetServiceHoldAdminData {
5
+ deployment: IReflexServiceDeployment;
6
+ }
7
+ export type ISetServiceHoldAdminResponse = IResponse<ISetServiceHoldAdminData>;
8
+
9
+ export interface ILiftServiceHoldAdminData {
10
+ deployment: IReflexServiceDeployment;
11
+ }
12
+ export type ILiftServiceHoldAdminResponse = IResponse<ILiftServiceHoldAdminData>;
13
+
14
+ export interface IWithdrawServiceHoldAdminData {
15
+ withdrawn: true;
16
+ }
17
+ export type IWithdrawServiceHoldAdminResponse = IResponse<IWithdrawServiceHoldAdminData>;
18
+
19
+ export interface IListUsageAdminData {
20
+ /** The page, 50 rows. */
21
+ rows: IReflexAdminUsageRow[];
22
+ /** Lines matching, every page. */
23
+ total: number;
24
+ }
25
+ export type IListUsageAdminResponse = IResponse<IListUsageAdminData>;
@@ -1,31 +1,31 @@
1
- import type { IReflexRoute } from '../../models';
2
- import type { IResponse } from '../response';
3
-
4
- export interface IListServiceRouteData {
5
- routes: IReflexRoute[];
6
- }
7
- export type IListServiceRouteResponse = IResponse<IListServiceRouteData>;
8
-
9
- export interface ICreateServiceRouteData {
10
- route: IReflexRoute;
11
- /** The signing secret of a signed route (SIGNATURE or GITHUB_SIGNATURE), in clear, ONCE; null for PUBLIC and API_KEY (keys belong to consumers). */
12
- secret: string | null;
13
- }
14
- export type ICreateServiceRouteResponse = IResponse<ICreateServiceRouteData>;
15
-
16
- export interface IUpdateServiceRouteData {
17
- route: IReflexRoute;
18
- /** A new signing secret, in clear, ONCE, when the route becomes signed (SIGNATURE or GITHUB_SIGNATURE); null otherwise. */
19
- secret: string | null;
20
- }
21
- export type IUpdateServiceRouteResponse = IResponse<IUpdateServiceRouteData>;
22
-
23
- export type IDeleteServiceRouteData = Record<string, never>;
24
- export type IDeleteServiceRouteResponse = IResponse<IDeleteServiceRouteData>;
25
-
26
- export interface IRotateServiceRouteData {
27
- route: IReflexRoute;
28
- /** The new signing secret, in clear, ONCE; the previous one stops working at once. */
29
- secret: string;
30
- }
31
- export type IRotateServiceRouteResponse = IResponse<IRotateServiceRouteData>;
1
+ import type { IReflexRoute } from '../../models';
2
+ import type { IResponse } from '../response';
3
+
4
+ export interface IListServiceRouteData {
5
+ routes: IReflexRoute[];
6
+ }
7
+ export type IListServiceRouteResponse = IResponse<IListServiceRouteData>;
8
+
9
+ export interface ICreateServiceRouteData {
10
+ route: IReflexRoute;
11
+ /** The signing secret of a SIGNATURE route, in clear, ONCE; null for PUBLIC and API_KEY (keys belong to consumers). */
12
+ secret: string | null;
13
+ }
14
+ export type ICreateServiceRouteResponse = IResponse<ICreateServiceRouteData>;
15
+
16
+ export interface IUpdateServiceRouteData {
17
+ route: IReflexRoute;
18
+ /** A new signing secret, in clear, ONCE, when the route becomes SIGNATURE; null otherwise. */
19
+ secret: string | null;
20
+ }
21
+ export type IUpdateServiceRouteResponse = IResponse<IUpdateServiceRouteData>;
22
+
23
+ export type IDeleteServiceRouteData = Record<string, never>;
24
+ export type IDeleteServiceRouteResponse = IResponse<IDeleteServiceRouteData>;
25
+
26
+ export interface IRotateServiceRouteData {
27
+ route: IReflexRoute;
28
+ /** The new signing secret, in clear, ONCE; the previous one stops working at once. */
29
+ secret: string;
30
+ }
31
+ export type IRotateServiceRouteResponse = IResponse<IRotateServiceRouteData>;
@@ -25,8 +25,6 @@ export * from './reflex-route-contract.model';
25
25
  export * from './reflex-consumer.model';
26
26
  export * from './reflex-service-limits.model';
27
27
  export * from './reflex-completion-webhook.model';
28
- export * from './reflex-service-template.model';
29
- export * from './reflex-code-diagnostic.model';
30
- export * from './reflex-code-environment.model';
31
28
  export * from './reflex-run-retention.model';
32
29
  export * from './reflex-storage-surplus.model';
30
+ export * from './reflex-admin-hold.model';
@@ -0,0 +1,55 @@
1
+ import type {
2
+ ReflexAbuseRule,
3
+ ReflexAdminHoldKind,
4
+ ServiceBlockReason,
5
+ ServiceDeploymentStatus,
6
+ ServiceType,
7
+ } from '../../enum';
8
+
9
+ /** A hold Abyss put on a Service in one environment. The reason is not stored here: it lives in the audit log of abyss-main. */
10
+ export interface IReflexAdminHold {
11
+ kind: ReflexAdminHoldKind;
12
+ /** The environment of the application (abyss-main's id). */
13
+ environmentId: string;
14
+ createdAt: Date;
15
+ }
16
+
17
+ /**
18
+ * Thresholds of the abuse detector, over a sliding window. Money is in millicredits: 1 credit = 1000 millicredits
19
+ * (as the price list), so `minMillicredits: 100_000` is 100 credits.
20
+ */
21
+ export const REFLEX_ABUSE_THRESHOLDS = {
22
+ windowMinutes: 60,
23
+ failureRate: { minRuns: 200, minRatio: 0.5 },
24
+ costSpike: { baselineDays: 7, factor: 10, minMillicredits: 100_000 },
25
+ netOut: { minBytes: 1_000_000_000 },
26
+ alertCooldownHours: 24,
27
+ } as const;
28
+
29
+ /** The last alert the detector raised for a Service in an environment. */
30
+ export interface IReflexAdminUsageAbuseAlert {
31
+ rule: ReflexAbuseRule;
32
+ /** ISO date of the alert. */
33
+ at: string;
34
+ }
35
+
36
+ /** One line of the admin usage view: a Service in an environment over the asked window. */
37
+ export interface IReflexAdminUsageRow {
38
+ serviceId: string;
39
+ serviceName: string;
40
+ serviceType: ServiceType;
41
+ applicationId: string;
42
+ applicationName: string;
43
+ projectId: string;
44
+ environmentId: string;
45
+ environmentSlug: string;
46
+ runs: number;
47
+ failed: number;
48
+ costMillicredits: number;
49
+ netOutBytes: number;
50
+ /** Status of the current deployment; null when nothing was put in service there. */
51
+ status: ServiceDeploymentStatus | null;
52
+ blockReason: ServiceBlockReason | null;
53
+ adminHold: ReflexAdminHoldKind | null;
54
+ lastAbuseAlert: IReflexAdminUsageAbuseAlert | null;
55
+ }
@@ -1,22 +1,22 @@
1
- import type { ConfigurationReadAs, VaultValueSource, VaultVisibility } from '../../enum';
2
-
3
- /**
4
- * A key the functions of a Service read (its draft and its versions in service), and what the Console
5
- * vault gives it in each environment of the application. Never a value.
6
- */
7
- export interface IReflexServiceConfigurationEntry {
8
- key: string;
9
- /** `config` for `config.KEY` / `{{ config.KEY }}`, `secrets` for `secrets.KEY` / `{{ secrets.KEY }}`. */
10
- readAs: ConfigurationReadAs;
11
- /** The Console vault entry of that key in the project; null when there is none. */
12
- secretId: string | null;
13
- /** The visibility of that entry; null when there is none. */
14
- visibility: VaultVisibility | null;
15
- /**
16
- * True when the entry cannot answer this read: a `config` key bound to a SECRET entry, or a `secrets`
17
- * key bound to a VISIBLE one. Every source is then ABSENT, the key never resolves.
18
- */
19
- mismatch: boolean;
20
- /** By environment id of the application. */
21
- sources: Record<string, VaultValueSource>;
22
- }
1
+ import type { ConfigurationReadAs, VaultValueSource, VaultVisibility } from '../../enum';
2
+
3
+ /**
4
+ * A key the functions of a Service read (its draft and its versions in service), and what the Console
5
+ * vault gives it in each environment of the application. Never a value.
6
+ */
7
+ export interface IReflexServiceConfigurationEntry {
8
+ key: string;
9
+ /** `config` for `config.KEY` / `{{ config.KEY }}`, `secrets` for `secrets.KEY` / `{{ secrets.KEY }}`. */
10
+ readAs: ConfigurationReadAs;
11
+ /** The Console vault entry of that key in the project; null when there is none. */
12
+ secretId: string | null;
13
+ /** The visibility of that entry; null when there is none. */
14
+ visibility: VaultVisibility | null;
15
+ /**
16
+ * True when the entry cannot answer this read: a `config` key bound to a SECRET entry, or a `secrets`
17
+ * key bound to a VISIBLE one. Every source is then ABSENT, the key never resolves.
18
+ */
19
+ mismatch: boolean;
20
+ /** By environment id of the application. */
21
+ sources: Record<string, VaultValueSource>;
22
+ }
@@ -1,48 +1,51 @@
1
- import type {
2
- DiscordSyncStatus,
3
- ScheduleSyncStatus,
4
- ServiceDeploymentAction,
5
- ServiceDeploymentStatus,
6
- } from '../../enum';
7
- import type { IReflexAccessDeclaration } from './reflex-definition.model';
8
-
9
- /** The accesses granted to one member function when the gesture was made: what the execution plane holds. */
10
- export interface IReflexServiceDeploymentGrant {
11
- functionId: string;
12
- grants: IReflexAccessDeclaration[];
13
- }
14
-
15
- /**
16
- * One gesture on the Service in an environment of the application. The `isCurrent` row is what runs (or
17
- * is paused) there; the others are the history a rollback reads.
18
- */
19
- export interface IReflexServiceDeployment {
20
- id: string;
21
- serviceId: string;
22
- /** The environment of the application (abyss-main's id). */
23
- environmentId: string;
24
- /** The name of that environment, second segment of the address. */
25
- environmentSlug: string;
26
- /** The version this gesture put in service; null once the purge deleted it (the row stays in the history, no way back to it). */
27
- serviceVersionId: string | null;
28
- /** Number of that version; null with `serviceVersionId`. */
29
- serviceVersionNumber: number | null;
30
- action: ServiceDeploymentAction;
31
- status: ServiceDeploymentStatus;
32
- grants: IReflexServiceDeploymentGrant[];
33
- /** Push of the interactions address and the commands to Discord; null for a Service that is not a Discord bot. */
34
- discordSync: DiscordSyncStatus | null;
35
- /** Code and message of the Discord refusal when `discordSync` is FAILED (500 characters at most). */
36
- discordSyncError: string | null;
37
- discordSyncedAt: Date | null;
38
- /** Synchronization of the cron tasks of the version with Flow; null when the version has no cron task. */
39
- scheduleSync: ScheduleSyncStatus | null;
40
- /** Code and message of the failure when `scheduleSync` is FAILED (500 characters at most). */
41
- scheduleSyncError: string | null;
42
- scheduleSyncedAt: Date | null;
43
- /** The bot was paused by the plan quota (ADR-0277), not by a member: only those resume with the plan. */
44
- pausedForQuota: boolean;
45
- isCurrent: boolean;
46
- byUserId: string;
47
- at: Date;
48
- }
1
+ import type {
2
+ DiscordSyncStatus,
3
+ ReflexAdminHoldKind,
4
+ ScheduleSyncStatus,
5
+ ServiceDeploymentAction,
6
+ ServiceDeploymentStatus,
7
+ } from '../../enum';
8
+ import type { IReflexAccessDeclaration } from './reflex-definition.model';
9
+
10
+ /** The accesses granted to one member function when the gesture was made: what the execution plane holds. */
11
+ export interface IReflexServiceDeploymentGrant {
12
+ functionId: string;
13
+ grants: IReflexAccessDeclaration[];
14
+ }
15
+
16
+ /**
17
+ * One gesture on the Service in an environment of the application. The `isCurrent` row is what runs (or
18
+ * is paused) there; the others are the history a rollback reads.
19
+ */
20
+ export interface IReflexServiceDeployment {
21
+ id: string;
22
+ serviceId: string;
23
+ /** The environment of the application (abyss-main's id). */
24
+ environmentId: string;
25
+ /** The name of that environment, second segment of the address. */
26
+ environmentSlug: string;
27
+ /** The version this gesture put in service; null once the purge deleted it (the row stays in the history, no way back to it). */
28
+ serviceVersionId: string | null;
29
+ /** Number of that version; null with `serviceVersionId`. */
30
+ serviceVersionNumber: number | null;
31
+ action: ServiceDeploymentAction;
32
+ status: ServiceDeploymentStatus;
33
+ grants: IReflexServiceDeploymentGrant[];
34
+ /** Push of the interactions address and the commands to Discord; null for a Service that is not a Discord bot. */
35
+ discordSync: DiscordSyncStatus | null;
36
+ /** Code and message of the Discord refusal when `discordSync` is FAILED (500 characters at most). */
37
+ discordSyncError: string | null;
38
+ discordSyncedAt: Date | null;
39
+ /** Synchronization of the cron tasks of the version with Flow; null when the version has no cron task. */
40
+ scheduleSync: ScheduleSyncStatus | null;
41
+ /** Code and message of the failure when `scheduleSync` is FAILED (500 characters at most). */
42
+ scheduleSyncError: string | null;
43
+ scheduleSyncedAt: Date | null;
44
+ /** The bot was paused by the plan quota (ADR-0277), not by a member: only those resume with the plan. */
45
+ pausedForQuota: boolean;
46
+ /** The hold Abyss put on the Service in this environment; null when none. */
47
+ adminHold: ReflexAdminHoldKind | null;
48
+ isCurrent: boolean;
49
+ byUserId: string;
50
+ at: Date;
51
+ }