@abyss-project/reflex 5.6.0 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/README.md +15 -15
  4. package/dist/types/interface/models/reflex-discord-event.model.d.ts +1 -1
  5. package/dist/types/interface/models/reflex-discord-event.model.js +1 -1
  6. package/dist/types/interface/models/reflex-discord-event.model.js.map +1 -1
  7. package/jest.config.ts +11 -11
  8. package/package.json +1 -1
  9. package/src/api/function-access.api.ts +36 -36
  10. package/src/api/function-run.api.ts +38 -38
  11. package/src/api/function-settings.api.ts +59 -59
  12. package/src/api/function-test.api.ts +34 -34
  13. package/src/api/function-version.api.ts +48 -48
  14. package/src/api/function.api.test.ts +249 -249
  15. package/src/api/function.api.ts +62 -62
  16. package/src/api/health.api.ts +10 -10
  17. package/src/api/service-configuration.api.ts +16 -16
  18. package/src/api/service-deployment.api.ts +79 -79
  19. package/src/api/service-route.api.ts +72 -72
  20. package/src/api/service-task.api.test.ts +140 -140
  21. package/src/api/service-task.api.ts +141 -141
  22. package/src/api/service-version.api.ts +54 -54
  23. package/src/api/service.api.test.ts +215 -215
  24. package/src/api/service.api.ts +55 -55
  25. package/src/types/enum/access-grant-status.enum.ts +12 -12
  26. package/src/types/enum/access-kind.enum.ts +7 -7
  27. package/src/types/enum/configuration-read-as.enum.ts +5 -5
  28. package/src/types/enum/discord-activity-type.enum.ts +9 -9
  29. package/src/types/enum/discord-component-kind.enum.ts +7 -7
  30. package/src/types/enum/discord-gateway-state.enum.ts +11 -11
  31. package/src/types/enum/discord-option-type.enum.ts +12 -12
  32. package/src/types/enum/discord-presence-status.enum.ts +8 -8
  33. package/src/types/enum/discord-sync-status.enum.ts +6 -6
  34. package/src/types/enum/discord-token-state.enum.ts +11 -11
  35. package/src/types/enum/execution-mode.enum.ts +9 -9
  36. package/src/types/enum/execution-profile.enum.ts +20 -20
  37. package/src/types/enum/execution-settings-source.enum.ts +9 -9
  38. package/src/types/enum/health-status.enum.ts +4 -4
  39. package/src/types/enum/route-method.enum.ts +9 -9
  40. package/src/types/enum/run-log-level.enum.ts +6 -6
  41. package/src/types/enum/run-mode.enum.ts +11 -11
  42. package/src/types/enum/run-status.enum.ts +11 -11
  43. package/src/types/enum/run-step-status.enum.ts +7 -7
  44. package/src/types/enum/schedule-sync-status.enum.ts +6 -6
  45. package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
  46. package/src/types/enum/scheduled-run-status.enum.ts +17 -17
  47. package/src/types/enum/service-deployment-action.enum.ts +11 -11
  48. package/src/types/enum/service-deployment-status.enum.ts +5 -5
  49. package/src/types/enum/service-type.enum.ts +9 -9
  50. package/src/types/enum/service-version-change-kind.enum.ts +6 -6
  51. package/src/types/enum/trace-effect-type.enum.ts +12 -12
  52. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  53. package/src/types/enum/vault-value-source.enum.ts +12 -12
  54. package/src/types/enum/vault-visibility.enum.ts +5 -5
  55. package/src/types/index.ts +2 -2
  56. package/src/types/interface/api/index.ts +3 -3
  57. package/src/types/interface/api/requests/function-access.request.ts +25 -25
  58. package/src/types/interface/api/requests/function-run.request.ts +30 -30
  59. package/src/types/interface/api/requests/function-settings.request.ts +27 -27
  60. package/src/types/interface/api/requests/function-test.request.ts +39 -39
  61. package/src/types/interface/api/requests/function-version.request.ts +20 -20
  62. package/src/types/interface/api/requests/function.request.ts +36 -36
  63. package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
  64. package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
  65. package/src/types/interface/api/requests/service-route.request.ts +44 -44
  66. package/src/types/interface/api/requests/service-task.request.ts +80 -80
  67. package/src/types/interface/api/requests/service-version.request.ts +24 -24
  68. package/src/types/interface/api/requests/service.request.ts +46 -46
  69. package/src/types/interface/api/response.ts +4 -4
  70. package/src/types/interface/api/responses/function-access.response.ts +17 -17
  71. package/src/types/interface/api/responses/function-run.response.ts +18 -18
  72. package/src/types/interface/api/responses/function-settings.response.ts +36 -36
  73. package/src/types/interface/api/responses/function-test.response.ts +12 -12
  74. package/src/types/interface/api/responses/function-version.response.ts +31 -31
  75. package/src/types/interface/api/responses/function.response.ts +25 -25
  76. package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
  77. package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
  78. package/src/types/interface/api/responses/service-route.response.ts +31 -31
  79. package/src/types/interface/api/responses/service-task.response.ts +57 -57
  80. package/src/types/interface/api/responses/service.response.ts +31 -31
  81. package/src/types/interface/health.response.ts +7 -7
  82. package/src/types/interface/index.ts +3 -3
  83. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  84. package/src/types/interface/models/reflex-definition.model.ts +31 -31
  85. package/src/types/interface/models/reflex-discord-event.model.ts +7 -6
  86. package/src/types/interface/models/reflex-discord.model.ts +146 -146
  87. package/src/types/interface/models/reflex-execution-settings.model.ts +50 -50
  88. package/src/types/interface/models/reflex-function-version.model.ts +14 -14
  89. package/src/types/interface/models/reflex-function.model.ts +16 -16
  90. package/src/types/interface/models/reflex-price-list.model.ts +20 -20
  91. package/src/types/interface/models/reflex-route.model.ts +19 -19
  92. package/src/types/interface/models/reflex-run.model.ts +4 -1
  93. package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
  94. package/src/types/interface/models/reflex-service-deployment.model.ts +46 -46
  95. package/src/types/interface/models/reflex-service.model.ts +45 -45
  96. package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
  97. package/src/types/interface/models/reflex-task.model.ts +97 -97
  98. package/tsconfig.check.json +15 -15
  99. package/tsconfig.json +35 -35
@@ -1,16 +1,16 @@
1
- import type { IReflexDefinition } from './reflex-definition.model';
2
-
3
- export interface IReflexFunction {
4
- id: string;
5
- applicationId: string;
6
- /** The Service the function belongs to; deleting the Service deletes it. */
7
- serviceId: string;
8
- projectId: string;
9
- name: string;
10
- /** The definition being edited; a publication freezes a copy of it. */
11
- draftDefinition: IReflexDefinition;
12
- createdByUserId: string;
13
- updatedByUserId: string;
14
- createdAt: Date;
15
- updatedAt: Date;
16
- }
1
+ import type { IReflexDefinition } from './reflex-definition.model';
2
+
3
+ export interface IReflexFunction {
4
+ id: string;
5
+ applicationId: string;
6
+ /** The Service the function belongs to; deleting the Service deletes it. */
7
+ serviceId: string;
8
+ projectId: string;
9
+ name: string;
10
+ /** The definition being edited; a publication freezes a copy of it. */
11
+ draftDefinition: IReflexDefinition;
12
+ createdByUserId: string;
13
+ updatedByUserId: string;
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ }
@@ -1,20 +1,20 @@
1
- import type { ExecutionProfile } from '../../enum';
2
-
3
- /**
4
- * The price list an execution is billed with (ADR-0244), served by the API from the runtime's
5
- * `COST_RATES` and `RESOURCE_PROFILES`, so that a screen that estimates a cost never holds a copy of it.
6
- * Prices are in millicredits (thousandths of a credit).
7
- */
8
- export interface IReflexPriceList {
9
- /** Once per execution; 0 for an interrupted or refused execution. */
10
- executionMillicredits: number;
11
- cpuMillicreditsPerSecond: number;
12
- /** Per GB-second of the memory the profile allocates, GB = 1024 MB. */
13
- memoryMillicreditsPerGbSecond: number;
14
- /** Per MB sent out, MB = 1024 x 1024 bytes. */
15
- networkOutMillicreditsPerMb: number;
16
- httpCallMillicredits: number;
17
- storeWriteMillicredits: number;
18
- /** The memory of each profile, and the coefficient its CPU part is multiplied by. */
19
- profiles: Record<ExecutionProfile, { memoryMb: number; cpuCoefficient: number }>;
20
- }
1
+ import type { ExecutionProfile } from '../../enum';
2
+
3
+ /**
4
+ * The price list an execution is billed with (ADR-0244), served by the API from the runtime's
5
+ * `COST_RATES` and `RESOURCE_PROFILES`, so that a screen that estimates a cost never holds a copy of it.
6
+ * Prices are in millicredits (thousandths of a credit).
7
+ */
8
+ export interface IReflexPriceList {
9
+ /** Once per execution; 0 for an interrupted or refused execution. */
10
+ executionMillicredits: number;
11
+ cpuMillicreditsPerSecond: number;
12
+ /** Per GB-second of the memory the profile allocates, GB = 1024 MB. */
13
+ memoryMillicreditsPerGbSecond: number;
14
+ /** Per MB sent out, MB = 1024 x 1024 bytes. */
15
+ networkOutMillicreditsPerMb: number;
16
+ httpCallMillicredits: number;
17
+ storeWriteMillicredits: number;
18
+ /** The memory of each profile, and the coefficient its CPU part is multiplied by. */
19
+ profiles: Record<ExecutionProfile, { memoryMb: number; cpuCoefficient: number }>;
20
+ }
@@ -1,19 +1,19 @@
1
- import type { RouteMethod, TriggerAccessMode } from '../../enum';
2
-
3
- /**
4
- * A route of the draft of a Service: callable only once a version that holds it is in service in the
5
- * environment. Never carries the key or the signing secret: they are shown once, when created or rotated.
6
- */
7
- export interface IReflexRoute {
8
- id: string;
9
- serviceId: string;
10
- /** A function of the same Service. */
11
- functionId: string;
12
- method: RouteMethod;
13
- /** Segments of `[a-z0-9._~-]` or `:param` joined by `/`, without leading or trailing slash; 20 at most. */
14
- path: string;
15
- accessMode: TriggerAccessMode;
16
- createdByUserId: string;
17
- createdAt: Date;
18
- updatedAt: Date;
19
- }
1
+ import type { RouteMethod, TriggerAccessMode } from '../../enum';
2
+
3
+ /**
4
+ * A route of the draft of a Service: callable only once a version that holds it is in service in the
5
+ * environment. Never carries the key or the signing secret: they are shown once, when created or rotated.
6
+ */
7
+ export interface IReflexRoute {
8
+ id: string;
9
+ serviceId: string;
10
+ /** A function of the same Service. */
11
+ functionId: string;
12
+ method: RouteMethod;
13
+ /** Segments of `[a-z0-9._~-]` or `:param` joined by `/`, without leading or trailing slash; 20 at most. */
14
+ path: string;
15
+ accessMode: TriggerAccessMode;
16
+ createdByUserId: string;
17
+ createdAt: Date;
18
+ updatedAt: Date;
19
+ }
@@ -75,7 +75,10 @@ export interface IReflexRun {
75
75
  taskId: string | null;
76
76
  /** The event trigger that started a LIVE run; null otherwise. */
77
77
  eventTriggerId: string | null;
78
- /** Trace id of an execution of an event: the id of its inbox row without dashes, the same at every attempt; null for the other origins. */
78
+ /**
79
+ * Monitor trace id of the run (32 hex characters; for an event, the id of its inbox row without dashes, the same
80
+ * at every attempt); null when the run was not sent to Monitor (non-bot Service, HTTP route).
81
+ */
79
82
  traceId: string | null;
80
83
  /** How the task started the run: RECURRING for a tick of its cron, DELAYED for a delayed run; null when no task did. */
81
84
  scheduledRunOrigin: ScheduledRunOrigin | null;
@@ -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,46 +1,46 @@
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
- serviceVersionId: string;
27
- serviceVersionNumber: number;
28
- action: ServiceDeploymentAction;
29
- status: ServiceDeploymentStatus;
30
- grants: IReflexServiceDeploymentGrant[];
31
- /** Push of the interactions address and the commands to Discord; null for a Service that is not a Discord bot. */
32
- discordSync: DiscordSyncStatus | null;
33
- /** Code and message of the Discord refusal when `discordSync` is FAILED (500 characters at most). */
34
- discordSyncError: string | null;
35
- discordSyncedAt: Date | null;
36
- /** Synchronization of the cron tasks of the version with Flow; null when the version has no cron task. */
37
- scheduleSync: ScheduleSyncStatus | null;
38
- /** Code and message of the failure when `scheduleSync` is FAILED (500 characters at most). */
39
- scheduleSyncError: string | null;
40
- scheduleSyncedAt: Date | null;
41
- /** The bot was paused by the plan quota (ADR-0277), not by a member: only those resume with the plan. */
42
- pausedForQuota: boolean;
43
- isCurrent: boolean;
44
- byUserId: string;
45
- at: Date;
46
- }
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
+ serviceVersionId: string;
27
+ serviceVersionNumber: number;
28
+ action: ServiceDeploymentAction;
29
+ status: ServiceDeploymentStatus;
30
+ grants: IReflexServiceDeploymentGrant[];
31
+ /** Push of the interactions address and the commands to Discord; null for a Service that is not a Discord bot. */
32
+ discordSync: DiscordSyncStatus | null;
33
+ /** Code and message of the Discord refusal when `discordSync` is FAILED (500 characters at most). */
34
+ discordSyncError: string | null;
35
+ discordSyncedAt: Date | null;
36
+ /** Synchronization of the cron tasks of the version with Flow; null when the version has no cron task. */
37
+ scheduleSync: ScheduleSyncStatus | null;
38
+ /** Code and message of the failure when `scheduleSync` is FAILED (500 characters at most). */
39
+ scheduleSyncError: string | null;
40
+ scheduleSyncedAt: Date | null;
41
+ /** The bot was paused by the plan quota (ADR-0277), not by a member: only those resume with the plan. */
42
+ pausedForQuota: boolean;
43
+ isCurrent: boolean;
44
+ byUserId: string;
45
+ at: Date;
46
+ }
@@ -1,45 +1,45 @@
1
- import type { ServiceType } from '../../enum';
2
-
3
- /** Bounds of a Service, its routes and versions; the API and its database apply the same ones. */
4
- export const REFLEX_SERVICE_LIMITS = {
5
- /** `^[a-z0-9][a-z0-9-]{0,39}$`: the third segment of the address, immutable. */
6
- slugPattern: /^[a-z0-9][a-z0-9-]{0,39}$/,
7
- nameMaxLength: 100,
8
- corsAllowedOriginsMax: 20,
9
- rateLimitPerIpPerMinute: { min: 1, max: 6000, default: 60 },
10
- /** Segments of `[a-z0-9._~-]` or `:param`, joined by `/`, without leading or trailing slash. */
11
- routePathMaxSegments: 20,
12
- routePathMaxLength: 255,
13
- versionMessageMaxLength: 500,
14
- } as const;
15
-
16
- /**
17
- * Origins a browser may call the Service from. Each is `https://host` or `https://*.domain`; `*` (any
18
- * origin) is refused when a route of the Service is not PUBLIC.
19
- */
20
- export interface IReflexServiceCors {
21
- allowedOrigins: string[];
22
- }
23
-
24
- /** A group of functions versioned, put in service and paused as one, in an application. */
25
- export interface IReflexService {
26
- id: string;
27
- applicationId: string;
28
- /** First segment of the address, `app-<8 hex>`, fixed for the application. */
29
- applicationSlug: string;
30
- /** Unique within the application. */
31
- name: string;
32
- /** Unique within the application, immutable: `/<application>/<environment>/<slug>/<route path>`. */
33
- slug: string;
34
- type: ServiceType;
35
- /** Vault entry (secret) holding the Discord bot token, one value per environment; null for other types and until chosen. */
36
- discordTokenSecretId: string | null;
37
- /** Draft: frozen by the next version. */
38
- cors: IReflexServiceCors;
39
- /** Draft: frozen by the next version. Calls per minute and per client IP, in each environment. */
40
- rateLimitPerIpPerMinute: number;
41
- createdByUserId: string;
42
- updatedByUserId: string;
43
- createdAt: Date;
44
- updatedAt: Date;
45
- }
1
+ import type { ServiceType } from '../../enum';
2
+
3
+ /** Bounds of a Service, its routes and versions; the API and its database apply the same ones. */
4
+ export const REFLEX_SERVICE_LIMITS = {
5
+ /** `^[a-z0-9][a-z0-9-]{0,39}$`: the third segment of the address, immutable. */
6
+ slugPattern: /^[a-z0-9][a-z0-9-]{0,39}$/,
7
+ nameMaxLength: 100,
8
+ corsAllowedOriginsMax: 20,
9
+ rateLimitPerIpPerMinute: { min: 1, max: 6000, default: 60 },
10
+ /** Segments of `[a-z0-9._~-]` or `:param`, joined by `/`, without leading or trailing slash. */
11
+ routePathMaxSegments: 20,
12
+ routePathMaxLength: 255,
13
+ versionMessageMaxLength: 500,
14
+ } as const;
15
+
16
+ /**
17
+ * Origins a browser may call the Service from. Each is `https://host` or `https://*.domain`; `*` (any
18
+ * origin) is refused when a route of the Service is not PUBLIC.
19
+ */
20
+ export interface IReflexServiceCors {
21
+ allowedOrigins: string[];
22
+ }
23
+
24
+ /** A group of functions versioned, put in service and paused as one, in an application. */
25
+ export interface IReflexService {
26
+ id: string;
27
+ applicationId: string;
28
+ /** First segment of the address, `app-<8 hex>`, fixed for the application. */
29
+ applicationSlug: string;
30
+ /** Unique within the application. */
31
+ name: string;
32
+ /** Unique within the application, immutable: `/<application>/<environment>/<slug>/<route path>`. */
33
+ slug: string;
34
+ type: ServiceType;
35
+ /** Vault entry (secret) holding the Discord bot token, one value per environment; null for other types and until chosen. */
36
+ discordTokenSecretId: string | null;
37
+ /** Draft: frozen by the next version. */
38
+ cors: IReflexServiceCors;
39
+ /** Draft: frozen by the next version. Calls per minute and per client IP, in each environment. */
40
+ rateLimitPerIpPerMinute: number;
41
+ createdByUserId: string;
42
+ updatedByUserId: string;
43
+ createdAt: Date;
44
+ updatedAt: Date;
45
+ }
@@ -1,35 +1,35 @@
1
- /** Median and 95th percentile of a measure, over the executions of the window. */
2
- export interface IReflexPercentiles {
3
- median: number;
4
- p95: number;
5
- }
6
-
7
- /**
8
- * The measured consumption of one step of a version, over the retention window. Interrupted and running
9
- * executions are left out.
10
- */
11
- export interface IReflexStepStats {
12
- stepId: string;
13
- /** Executions in which the step ran. */
14
- executions: number;
15
- durationMs: IReflexPercentiles;
16
- cpuMs: IReflexPercentiles;
17
- heapPeakBytes: IReflexPercentiles;
18
- costMillicredits: IReflexPercentiles;
19
- /** 99th percentile of the heap peak: what a smaller profile is compared to. */
20
- heapPeakP99Bytes: number;
21
- /** Share of the cost of the executions that this step makes, from 0 to 1; null when they cost nothing. */
22
- costShare: number | null;
23
- }
24
-
25
- /** The p99 heap peak of one step of the version running in an environment. */
26
- export interface IReflexStepHeapPeak {
27
- stepId: string;
28
- heapPeakP99Bytes: number;
29
- }
30
-
31
- /** What the settings screen compares a smaller profile to: the version running in the environment. */
32
- export interface IReflexRunningVersionHeapPeaks {
33
- versionId: string;
34
- steps: IReflexStepHeapPeak[];
35
- }
1
+ /** Median and 95th percentile of a measure, over the executions of the window. */
2
+ export interface IReflexPercentiles {
3
+ median: number;
4
+ p95: number;
5
+ }
6
+
7
+ /**
8
+ * The measured consumption of one step of a version, over the retention window. Interrupted and running
9
+ * executions are left out.
10
+ */
11
+ export interface IReflexStepStats {
12
+ stepId: string;
13
+ /** Executions in which the step ran. */
14
+ executions: number;
15
+ durationMs: IReflexPercentiles;
16
+ cpuMs: IReflexPercentiles;
17
+ heapPeakBytes: IReflexPercentiles;
18
+ costMillicredits: IReflexPercentiles;
19
+ /** 99th percentile of the heap peak: what a smaller profile is compared to. */
20
+ heapPeakP99Bytes: number;
21
+ /** Share of the cost of the executions that this step makes, from 0 to 1; null when they cost nothing. */
22
+ costShare: number | null;
23
+ }
24
+
25
+ /** The p99 heap peak of one step of the version running in an environment. */
26
+ export interface IReflexStepHeapPeak {
27
+ stepId: string;
28
+ heapPeakP99Bytes: number;
29
+ }
30
+
31
+ /** What the settings screen compares a smaller profile to: the version running in the environment. */
32
+ export interface IReflexRunningVersionHeapPeaks {
33
+ versionId: string;
34
+ steps: IReflexStepHeapPeak[];
35
+ }
@@ -1,97 +1,97 @@
1
- import type { ScheduledRunOrigin, ScheduledRunStatus } from '../../enum';
2
-
3
- /** Bounds of the tasks of a Service and of their delayed runs; the API, the edge and their databases apply the same ones. */
4
- export const REFLEX_TASK_LIMITS = {
5
- /** `^[-_a-z0-9]{1,32}$`: the name `abyss.schedule.*` targets. */
6
- namePattern: /^[-_a-z0-9]{1,32}$/,
7
- maxTasksPerService: 20,
8
- nameMaxLength: 32,
9
- /** Characters of the payload of a delayed run, serialized to JSON. */
10
- payloadMaxLength: 4096,
11
- /** Shortest delay of a delayed run. */
12
- delayMinSeconds: 1,
13
- /** Furthest due date of a delayed run. */
14
- delayMaxDays: 30,
15
- /** Lateness past which a tick of a cron is EXPIRED instead of run (after a pause or an outage). */
16
- recurringToleranceMinutes: 5,
17
- /** Lateness past which a delayed run is EXPIRED instead of run. */
18
- delayedToleranceMinutes: 60,
19
- /** Attempts of a scheduled run interrupted before its end (at least once). */
20
- maxAttempts: 3,
21
- /** Runs of a task one page of its history holds at most (and by default). */
22
- scheduledRunPageMax: 50,
23
- } as const;
24
-
25
- /** A task of the draft of a Service: a named target of a cron and of `abyss.schedule.*`. */
26
- export interface IReflexTask {
27
- id: string;
28
- serviceId: string;
29
- /** A function of the same Service. */
30
- functionId: string;
31
- /** Unique within the Service. */
32
- name: string;
33
- /** A cron of 5 fields, read in `timezone`, at most one tick a minute; null for a task only delayed runs start. */
34
- schedule: string | null;
35
- /** IANA time zone of the cron; `Etc/UTC` by default. */
36
- timezone: string;
37
- createdAt: Date;
38
- updatedAt: Date;
39
- }
40
-
41
- /** A task as a version of the Service froze it. */
42
- export type IReflexTaskSnapshot = Pick<
43
- IReflexTask,
44
- 'id' | 'functionId' | 'name' | 'schedule' | 'timezone'
45
- >;
46
-
47
- /** A delayed run waiting for its due date in one environment. */
48
- export interface IReflexDelayedRun {
49
- id: string;
50
- serviceId: string;
51
- environmentId: string;
52
- taskId: string;
53
- /** The name of the task in the version in service; null when that version no longer has it. */
54
- taskName: string | null;
55
- dueAt: Date;
56
- /**
57
- * The deduplication key it was scheduled with; null without one. A key deduplicates per task: a task holds one
58
- * pending run of a key at a time, and another task of the Service may hold a run of the same key.
59
- * `abyss.schedule.cancel(key)` cancels the pending runs of that key in every task of the Service in the
60
- * environment.
61
- */
62
- key: string | null;
63
- /** The payload handed to the run; null without one. */
64
- payload: unknown;
65
- /** Attempts already made (interrupted runs taken again). */
66
- attempts: number;
67
- /** The live run that scheduled it. */
68
- scheduledByRunId: string | null;
69
- createdAt: Date;
70
- }
71
-
72
- /**
73
- * A run of a task in one environment, as the execution plane holds it, whatever its status: a tick of its cron or a
74
- * delayed run, due, running or ended (kept 7 days after its end). The runs that ran nothing (EXPIRED, SKIPPED,
75
- * CANCELLED, FAILED with TASK_REMOVED) are only seen here: the run journal holds what was executed.
76
- */
77
- export interface IReflexScheduledRun {
78
- id: string;
79
- /** A tick of the cron, or a delayed run the code scheduled. */
80
- kind: ScheduledRunOrigin;
81
- status: ScheduledRunStatus;
82
- /**
83
- * Why FAILED, null otherwise: a `ScheduledRunFailureCode` the plane wrote itself, or the error code of the live
84
- * run that failed.
85
- */
86
- failureCode: string | null;
87
- /** When the run was due. */
88
- scheduledFor: Date;
89
- /** When its last attempt began, from the live run; null when nothing ran (or the live run is purged). */
90
- startedAt: Date | null;
91
- /** When it ended; null while PENDING or CLAIMED. */
92
- finishedAt: Date | null;
93
- /** Attempts begun, 3 at most. */
94
- attempts: number;
95
- /** The live run of its last attempt, to open in the run journal; null when nothing ran (or it is purged). */
96
- liveRunId: string | null;
97
- }
1
+ import type { ScheduledRunOrigin, ScheduledRunStatus } from '../../enum';
2
+
3
+ /** Bounds of the tasks of a Service and of their delayed runs; the API, the edge and their databases apply the same ones. */
4
+ export const REFLEX_TASK_LIMITS = {
5
+ /** `^[-_a-z0-9]{1,32}$`: the name `abyss.schedule.*` targets. */
6
+ namePattern: /^[-_a-z0-9]{1,32}$/,
7
+ maxTasksPerService: 20,
8
+ nameMaxLength: 32,
9
+ /** Characters of the payload of a delayed run, serialized to JSON. */
10
+ payloadMaxLength: 4096,
11
+ /** Shortest delay of a delayed run. */
12
+ delayMinSeconds: 1,
13
+ /** Furthest due date of a delayed run. */
14
+ delayMaxDays: 30,
15
+ /** Lateness past which a tick of a cron is EXPIRED instead of run (after a pause or an outage). */
16
+ recurringToleranceMinutes: 5,
17
+ /** Lateness past which a delayed run is EXPIRED instead of run. */
18
+ delayedToleranceMinutes: 60,
19
+ /** Attempts of a scheduled run interrupted before its end (at least once). */
20
+ maxAttempts: 3,
21
+ /** Runs of a task one page of its history holds at most (and by default). */
22
+ scheduledRunPageMax: 50,
23
+ } as const;
24
+
25
+ /** A task of the draft of a Service: a named target of a cron and of `abyss.schedule.*`. */
26
+ export interface IReflexTask {
27
+ id: string;
28
+ serviceId: string;
29
+ /** A function of the same Service. */
30
+ functionId: string;
31
+ /** Unique within the Service. */
32
+ name: string;
33
+ /** A cron of 5 fields, read in `timezone`, at most one tick a minute; null for a task only delayed runs start. */
34
+ schedule: string | null;
35
+ /** IANA time zone of the cron; `Etc/UTC` by default. */
36
+ timezone: string;
37
+ createdAt: Date;
38
+ updatedAt: Date;
39
+ }
40
+
41
+ /** A task as a version of the Service froze it. */
42
+ export type IReflexTaskSnapshot = Pick<
43
+ IReflexTask,
44
+ 'id' | 'functionId' | 'name' | 'schedule' | 'timezone'
45
+ >;
46
+
47
+ /** A delayed run waiting for its due date in one environment. */
48
+ export interface IReflexDelayedRun {
49
+ id: string;
50
+ serviceId: string;
51
+ environmentId: string;
52
+ taskId: string;
53
+ /** The name of the task in the version in service; null when that version no longer has it. */
54
+ taskName: string | null;
55
+ dueAt: Date;
56
+ /**
57
+ * The deduplication key it was scheduled with; null without one. A key deduplicates per task: a task holds one
58
+ * pending run of a key at a time, and another task of the Service may hold a run of the same key.
59
+ * `abyss.schedule.cancel(key)` cancels the pending runs of that key in every task of the Service in the
60
+ * environment.
61
+ */
62
+ key: string | null;
63
+ /** The payload handed to the run; null without one. */
64
+ payload: unknown;
65
+ /** Attempts already made (interrupted runs taken again). */
66
+ attempts: number;
67
+ /** The live run that scheduled it. */
68
+ scheduledByRunId: string | null;
69
+ createdAt: Date;
70
+ }
71
+
72
+ /**
73
+ * A run of a task in one environment, as the execution plane holds it, whatever its status: a tick of its cron or a
74
+ * delayed run, due, running or ended (kept 7 days after its end). The runs that ran nothing (EXPIRED, SKIPPED,
75
+ * CANCELLED, FAILED with TASK_REMOVED) are only seen here: the run journal holds what was executed.
76
+ */
77
+ export interface IReflexScheduledRun {
78
+ id: string;
79
+ /** A tick of the cron, or a delayed run the code scheduled. */
80
+ kind: ScheduledRunOrigin;
81
+ status: ScheduledRunStatus;
82
+ /**
83
+ * Why FAILED, null otherwise: a `ScheduledRunFailureCode` the plane wrote itself, or the error code of the live
84
+ * run that failed.
85
+ */
86
+ failureCode: string | null;
87
+ /** When the run was due. */
88
+ scheduledFor: Date;
89
+ /** When its last attempt began, from the live run; null when nothing ran (or the live run is purged). */
90
+ startedAt: Date | null;
91
+ /** When it ended; null while PENDING or CLAIMED. */
92
+ finishedAt: Date | null;
93
+ /** Attempts begun, 3 at most. */
94
+ attempts: number;
95
+ /** The live run of its last attempt, to open in the run journal; null when nothing ran (or it is purged). */
96
+ liveRunId: string | null;
97
+ }