@abyss-project/reflex 5.0.0 → 5.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 (91) hide show
  1. package/dist/types/enum/discord-activity-type.enum.d.ts +7 -0
  2. package/dist/types/enum/discord-activity-type.enum.js +12 -0
  3. package/dist/types/enum/discord-activity-type.enum.js.map +1 -0
  4. package/dist/types/enum/discord-gateway-failure-code.enum.d.ts +5 -0
  5. package/dist/types/enum/discord-gateway-failure-code.enum.js +10 -0
  6. package/dist/types/enum/discord-gateway-failure-code.enum.js.map +1 -0
  7. package/dist/types/enum/discord-gateway-state.enum.d.ts +6 -0
  8. package/dist/types/enum/discord-gateway-state.enum.js +11 -0
  9. package/dist/types/enum/discord-gateway-state.enum.js.map +1 -0
  10. package/dist/types/enum/discord-presence-status.enum.d.ts +5 -0
  11. package/dist/types/enum/discord-presence-status.enum.js +10 -0
  12. package/dist/types/enum/discord-presence-status.enum.js.map +1 -0
  13. package/dist/types/enum/index.d.ts +4 -0
  14. package/dist/types/enum/index.js +4 -0
  15. package/dist/types/enum/index.js.map +1 -1
  16. package/dist/types/interface/api/requests/service-discord.request.d.ts +4 -1
  17. package/dist/types/interface/models/reflex-discord.model.d.ts +14 -1
  18. package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
  19. package/package.json +15 -10
  20. package/src/api/service-discord.api.test.ts +170 -170
  21. package/src/api/service-discord.api.ts +203 -203
  22. package/src/index.ts +235 -235
  23. package/src/types/enum/access-grant-status.enum.ts +12 -12
  24. package/src/types/enum/access-kind.enum.ts +7 -7
  25. package/src/types/enum/configuration-read-as.enum.ts +5 -5
  26. package/src/types/enum/discord-activity-type.enum.ts +9 -0
  27. package/src/types/enum/discord-gateway-failure-code.enum.ts +9 -0
  28. package/src/types/enum/discord-gateway-state.enum.ts +11 -0
  29. package/src/types/enum/discord-presence-status.enum.ts +8 -0
  30. package/src/types/enum/execution-mode.enum.ts +9 -9
  31. package/src/types/enum/execution-profile.enum.ts +20 -20
  32. package/src/types/enum/execution-settings-source.enum.ts +9 -9
  33. package/src/types/enum/health-status.enum.ts +4 -4
  34. package/src/types/enum/index.ts +29 -25
  35. package/src/types/enum/reflex-error-code.enum.ts +37 -37
  36. package/src/types/enum/route-method.enum.ts +9 -9
  37. package/src/types/enum/run-log-level.enum.ts +6 -6
  38. package/src/types/enum/run-mode.enum.ts +11 -11
  39. package/src/types/enum/run-status.enum.ts +11 -11
  40. package/src/types/enum/run-step-status.enum.ts +7 -7
  41. package/src/types/enum/service-deployment-action.enum.ts +11 -11
  42. package/src/types/enum/service-deployment-status.enum.ts +5 -5
  43. package/src/types/enum/service-type.enum.ts +9 -9
  44. package/src/types/enum/service-version-change-kind.enum.ts +6 -6
  45. package/src/types/enum/trace-effect-type.enum.ts +12 -12
  46. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  47. package/src/types/enum/vault-value-source.enum.ts +12 -12
  48. package/src/types/enum/vault-visibility.enum.ts +5 -5
  49. package/src/types/index.ts +2 -2
  50. package/src/types/interface/api/index.ts +3 -3
  51. package/src/types/interface/api/requests/function-access.request.ts +25 -25
  52. package/src/types/interface/api/requests/function-run.request.ts +26 -26
  53. package/src/types/interface/api/requests/function-settings.request.ts +27 -27
  54. package/src/types/interface/api/requests/function-test.request.ts +24 -24
  55. package/src/types/interface/api/requests/function-version.request.ts +20 -20
  56. package/src/types/interface/api/requests/function.request.ts +36 -36
  57. package/src/types/interface/api/requests/index.ts +12 -12
  58. package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
  59. package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
  60. package/src/types/interface/api/requests/service-discord.request.ts +11 -1
  61. package/src/types/interface/api/requests/service-route.request.ts +44 -44
  62. package/src/types/interface/api/requests/service-version.request.ts +19 -19
  63. package/src/types/interface/api/requests/service.request.ts +46 -46
  64. package/src/types/interface/api/response.ts +4 -4
  65. package/src/types/interface/api/responses/function-access.response.ts +17 -17
  66. package/src/types/interface/api/responses/function-run.response.ts +18 -18
  67. package/src/types/interface/api/responses/function-settings.response.ts +36 -36
  68. package/src/types/interface/api/responses/function-test.response.ts +12 -12
  69. package/src/types/interface/api/responses/function-version.response.ts +31 -31
  70. package/src/types/interface/api/responses/function.response.ts +25 -25
  71. package/src/types/interface/api/responses/index.ts +12 -12
  72. package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
  73. package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
  74. package/src/types/interface/api/responses/service-route.response.ts +31 -31
  75. package/src/types/interface/api/responses/service.response.ts +31 -31
  76. package/src/types/interface/health.response.ts +7 -7
  77. package/src/types/interface/index.ts +3 -3
  78. package/src/types/interface/models/index.ts +14 -14
  79. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  80. package/src/types/interface/models/reflex-definition.model.ts +31 -31
  81. package/src/types/interface/models/reflex-discord.model.ts +30 -1
  82. package/src/types/interface/models/reflex-execution-settings.model.ts +50 -50
  83. package/src/types/interface/models/reflex-function-version.model.ts +14 -14
  84. package/src/types/interface/models/reflex-function.model.ts +16 -16
  85. package/src/types/interface/models/reflex-price-list.model.ts +20 -20
  86. package/src/types/interface/models/reflex-route.model.ts +19 -19
  87. package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
  88. package/src/types/interface/models/reflex-service-deployment.model.ts +40 -40
  89. package/src/types/interface/models/reflex-service-version.model.ts +55 -55
  90. package/src/types/interface/models/reflex-service.model.ts +45 -45
  91. package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
@@ -1,50 +1,50 @@
1
- import { ExecutionMode, ExecutionProfile } from '../../enum';
2
- import type { ExecutionSettingsSource } from '../../enum';
3
-
4
- /** The execution settings of a function in an environment. */
5
- export interface IReflexExecutionSettingsValues {
6
- profile: ExecutionProfile;
7
- /** Past this, a synchronous caller that got no answer receives 504 and the execution goes on. */
8
- responseTimeoutMs: number;
9
- /** Past this, the execution is stopped with TIMEOUT. */
10
- maxDurationMs: number;
11
- mode: ExecutionMode;
12
- }
13
-
14
- /** Bounds of the settings, in milliseconds. */
15
- export const REFLEX_EXECUTION_SETTINGS_LIMITS = {
16
- responseTimeoutMs: { min: 1_000, max: 100_000 },
17
- maxDurationMs: { min: 1_000, max: 3_600_000 },
18
- } as const;
19
-
20
- /** What a function runs with when nothing is set. */
21
- export const DEFAULT_REFLEX_EXECUTION_SETTINGS: Readonly<IReflexExecutionSettingsValues> = {
22
- profile: ExecutionProfile.S,
23
- responseTimeoutMs: 30_000,
24
- maxDurationMs: 30_000,
25
- mode: ExecutionMode.SYNC,
26
- };
27
-
28
- /** A row of settings: the default of the function (`environmentId` null) or the override of one environment. */
29
- export interface IReflexExecutionSettings extends IReflexExecutionSettingsValues {
30
- id: string;
31
- functionId: string;
32
- /** An environment of the application (abyss-main's id); null for the default of every environment. */
33
- environmentId: string | null;
34
- updatedByUserId: string;
35
- createdAt: Date;
36
- updatedAt: Date;
37
- }
38
-
39
- /** What one environment of the application runs with. */
40
- export interface IReflexEffectiveExecutionSettings {
41
- environmentId: string;
42
- /** The name of the environment (abyss-main), immutable. */
43
- environmentSlug: string;
44
- /** Changing what a production environment runs with needs REFLEX_PUBLISH_PRODUCTION. */
45
- isProduction: boolean;
46
- source: ExecutionSettingsSource;
47
- settings: IReflexExecutionSettingsValues;
48
- /** The version promoted in this environment, whose step statistics drive the profile warning; null when none. */
49
- runningVersionId: string | null;
50
- }
1
+ import { ExecutionMode, ExecutionProfile } from '../../enum';
2
+ import type { ExecutionSettingsSource } from '../../enum';
3
+
4
+ /** The execution settings of a function in an environment. */
5
+ export interface IReflexExecutionSettingsValues {
6
+ profile: ExecutionProfile;
7
+ /** Past this, a synchronous caller that got no answer receives 504 and the execution goes on. */
8
+ responseTimeoutMs: number;
9
+ /** Past this, the execution is stopped with TIMEOUT. */
10
+ maxDurationMs: number;
11
+ mode: ExecutionMode;
12
+ }
13
+
14
+ /** Bounds of the settings, in milliseconds. */
15
+ export const REFLEX_EXECUTION_SETTINGS_LIMITS = {
16
+ responseTimeoutMs: { min: 1_000, max: 100_000 },
17
+ maxDurationMs: { min: 1_000, max: 3_600_000 },
18
+ } as const;
19
+
20
+ /** What a function runs with when nothing is set. */
21
+ export const DEFAULT_REFLEX_EXECUTION_SETTINGS: Readonly<IReflexExecutionSettingsValues> = {
22
+ profile: ExecutionProfile.S,
23
+ responseTimeoutMs: 30_000,
24
+ maxDurationMs: 30_000,
25
+ mode: ExecutionMode.SYNC,
26
+ };
27
+
28
+ /** A row of settings: the default of the function (`environmentId` null) or the override of one environment. */
29
+ export interface IReflexExecutionSettings extends IReflexExecutionSettingsValues {
30
+ id: string;
31
+ functionId: string;
32
+ /** An environment of the application (abyss-main's id); null for the default of every environment. */
33
+ environmentId: string | null;
34
+ updatedByUserId: string;
35
+ createdAt: Date;
36
+ updatedAt: Date;
37
+ }
38
+
39
+ /** What one environment of the application runs with. */
40
+ export interface IReflexEffectiveExecutionSettings {
41
+ environmentId: string;
42
+ /** The name of the environment (abyss-main), immutable. */
43
+ environmentSlug: string;
44
+ /** Changing what a production environment runs with needs REFLEX_PUBLISH_PRODUCTION. */
45
+ isProduction: boolean;
46
+ source: ExecutionSettingsSource;
47
+ settings: IReflexExecutionSettingsValues;
48
+ /** The version promoted in this environment, whose step statistics drive the profile warning; null when none. */
49
+ runningVersionId: string | null;
50
+ }
@@ -1,14 +1,14 @@
1
- import type { IReflexDefinition } from './reflex-definition.model';
2
-
3
- export interface IReflexFunctionVersion {
4
- id: string;
5
- functionId: string;
6
- /** 1, 2, 3...: counted per function. */
7
- number: number;
8
- /** The frozen definition. */
9
- definition: IReflexDefinition;
10
- /** SHA-256 of the definition, lowercase hex. */
11
- hash: string;
12
- publishedByUserId: string;
13
- publishedAt: Date;
14
- }
1
+ import type { IReflexDefinition } from './reflex-definition.model';
2
+
3
+ export interface IReflexFunctionVersion {
4
+ id: string;
5
+ functionId: string;
6
+ /** 1, 2, 3...: counted per function. */
7
+ number: number;
8
+ /** The frozen definition. */
9
+ definition: IReflexDefinition;
10
+ /** SHA-256 of the definition, lowercase hex. */
11
+ hash: string;
12
+ publishedByUserId: string;
13
+ publishedAt: Date;
14
+ }
@@ -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
+ }
@@ -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,40 +1,40 @@
1
- import type {
2
- DiscordSyncStatus,
3
- ServiceDeploymentAction,
4
- ServiceDeploymentStatus,
5
- } from '../../enum';
6
- import type { IReflexAccessDeclaration } from './reflex-definition.model';
7
-
8
- /** The accesses granted to one member function when the gesture was made: what the execution plane holds. */
9
- export interface IReflexServiceDeploymentGrant {
10
- functionId: string;
11
- grants: IReflexAccessDeclaration[];
12
- }
13
-
14
- /**
15
- * One gesture on the Service in an environment of the application. The `isCurrent` row is what runs (or
16
- * is paused) there; the others are the history a rollback reads.
17
- */
18
- export interface IReflexServiceDeployment {
19
- id: string;
20
- serviceId: string;
21
- /** The environment of the application (abyss-main's id). */
22
- environmentId: string;
23
- /** The name of that environment, second segment of the address. */
24
- environmentSlug: string;
25
- serviceVersionId: string;
26
- serviceVersionNumber: number;
27
- action: ServiceDeploymentAction;
28
- status: ServiceDeploymentStatus;
29
- grants: IReflexServiceDeploymentGrant[];
30
- /** Push of the interactions address and the commands to Discord; null for a Service that is not a Discord bot. */
31
- discordSync: DiscordSyncStatus | null;
32
- /** Code and message of the Discord refusal when `discordSync` is FAILED (500 characters at most). */
33
- discordSyncError: string | null;
34
- discordSyncedAt: Date | null;
35
- /** The bot was paused by the plan quota (ADR-0277), not by a member: only those resume with the plan. */
36
- pausedForQuota: boolean;
37
- isCurrent: boolean;
38
- byUserId: string;
39
- at: Date;
40
- }
1
+ import type {
2
+ DiscordSyncStatus,
3
+ ServiceDeploymentAction,
4
+ ServiceDeploymentStatus,
5
+ } from '../../enum';
6
+ import type { IReflexAccessDeclaration } from './reflex-definition.model';
7
+
8
+ /** The accesses granted to one member function when the gesture was made: what the execution plane holds. */
9
+ export interface IReflexServiceDeploymentGrant {
10
+ functionId: string;
11
+ grants: IReflexAccessDeclaration[];
12
+ }
13
+
14
+ /**
15
+ * One gesture on the Service in an environment of the application. The `isCurrent` row is what runs (or
16
+ * is paused) there; the others are the history a rollback reads.
17
+ */
18
+ export interface IReflexServiceDeployment {
19
+ id: string;
20
+ serviceId: string;
21
+ /** The environment of the application (abyss-main's id). */
22
+ environmentId: string;
23
+ /** The name of that environment, second segment of the address. */
24
+ environmentSlug: string;
25
+ serviceVersionId: string;
26
+ serviceVersionNumber: number;
27
+ action: ServiceDeploymentAction;
28
+ status: ServiceDeploymentStatus;
29
+ grants: IReflexServiceDeploymentGrant[];
30
+ /** Push of the interactions address and the commands to Discord; null for a Service that is not a Discord bot. */
31
+ discordSync: DiscordSyncStatus | null;
32
+ /** Code and message of the Discord refusal when `discordSync` is FAILED (500 characters at most). */
33
+ discordSyncError: string | null;
34
+ discordSyncedAt: Date | null;
35
+ /** The bot was paused by the plan quota (ADR-0277), not by a member: only those resume with the plan. */
36
+ pausedForQuota: boolean;
37
+ isCurrent: boolean;
38
+ byUserId: string;
39
+ at: Date;
40
+ }
@@ -1,55 +1,55 @@
1
- import type { RouteMethod, TriggerAccessMode } from '../../enum';
2
- import type {
3
- IReflexDiscordCommandSnapshot,
4
- IReflexDiscordComponentSnapshot,
5
- } from './reflex-discord.model';
6
- import type { IReflexServiceCors } from './reflex-service.model';
7
-
8
- /** A route as a version of the Service froze it. */
9
- export interface IReflexServiceVersionRoute {
10
- routeId: string;
11
- method: RouteMethod;
12
- path: string;
13
- functionId: string;
14
- accessMode: TriggerAccessMode;
15
- }
16
-
17
- /** The version of a member function a version of the Service runs. */
18
- export interface IReflexServiceVersionFunction {
19
- functionId: string;
20
- functionVersionId: string;
21
- functionVersionNumber: number;
22
- }
23
-
24
- /** What a version of a Discord bot freezes: its commands and components, identifiers included. */
25
- export interface IReflexServiceVersionDiscord {
26
- commands: IReflexDiscordCommandSnapshot[];
27
- components: IReflexDiscordComponentSnapshot[];
28
- }
29
-
30
- /**
31
- * What a version of the Service freezes. Routes sorted by path then method, functions by id: the same
32
- * Service always gives the same snapshot, and the same `hash`.
33
- */
34
- export interface IReflexServiceVersionSnapshot {
35
- routes: IReflexServiceVersionRoute[];
36
- functions: IReflexServiceVersionFunction[];
37
- cors: IReflexServiceCors;
38
- rateLimitPerIpPerMinute: number;
39
- /** Only a `DISCORD_BOT` Service has it (its `routes` are then empty); absent otherwise, so the hash of other versions is unchanged. */
40
- discord?: IReflexServiceVersionDiscord;
41
- }
42
-
43
- export interface IReflexServiceVersion {
44
- id: string;
45
- serviceId: string;
46
- /** 1, 2, 3...: counted per Service. */
47
- number: number;
48
- /** 500 characters at most. */
49
- message: string | null;
50
- snapshot: IReflexServiceVersionSnapshot;
51
- /** SHA-256 of the snapshot as canonical JSON (keys sorted), lowercase hex. */
52
- hash: string;
53
- publishedByUserId: string;
54
- publishedAt: Date;
55
- }
1
+ import type { RouteMethod, TriggerAccessMode } from '../../enum';
2
+ import type {
3
+ IReflexDiscordCommandSnapshot,
4
+ IReflexDiscordComponentSnapshot,
5
+ } from './reflex-discord.model';
6
+ import type { IReflexServiceCors } from './reflex-service.model';
7
+
8
+ /** A route as a version of the Service froze it. */
9
+ export interface IReflexServiceVersionRoute {
10
+ routeId: string;
11
+ method: RouteMethod;
12
+ path: string;
13
+ functionId: string;
14
+ accessMode: TriggerAccessMode;
15
+ }
16
+
17
+ /** The version of a member function a version of the Service runs. */
18
+ export interface IReflexServiceVersionFunction {
19
+ functionId: string;
20
+ functionVersionId: string;
21
+ functionVersionNumber: number;
22
+ }
23
+
24
+ /** What a version of a Discord bot freezes: its commands and components, identifiers included. */
25
+ export interface IReflexServiceVersionDiscord {
26
+ commands: IReflexDiscordCommandSnapshot[];
27
+ components: IReflexDiscordComponentSnapshot[];
28
+ }
29
+
30
+ /**
31
+ * What a version of the Service freezes. Routes sorted by path then method, functions by id: the same
32
+ * Service always gives the same snapshot, and the same `hash`.
33
+ */
34
+ export interface IReflexServiceVersionSnapshot {
35
+ routes: IReflexServiceVersionRoute[];
36
+ functions: IReflexServiceVersionFunction[];
37
+ cors: IReflexServiceCors;
38
+ rateLimitPerIpPerMinute: number;
39
+ /** Only a `DISCORD_BOT` Service has it (its `routes` are then empty); absent otherwise, so the hash of other versions is unchanged. */
40
+ discord?: IReflexServiceVersionDiscord;
41
+ }
42
+
43
+ export interface IReflexServiceVersion {
44
+ id: string;
45
+ serviceId: string;
46
+ /** 1, 2, 3...: counted per Service. */
47
+ number: number;
48
+ /** 500 characters at most. */
49
+ message: string | null;
50
+ snapshot: IReflexServiceVersionSnapshot;
51
+ /** SHA-256 of the snapshot as canonical JSON (keys sorted), lowercase hex. */
52
+ hash: string;
53
+ publishedByUserId: string;
54
+ publishedAt: Date;
55
+ }
@@ -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
+ }