@abyss-project/reflex 6.0.3 → 6.0.5
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.
- package/.eslintrc.js +32 -32
- package/.prettierrc +5 -5
- package/README.md +15 -15
- package/dist/types/interface/models/reflex-completion-webhook.model.d.ts +9 -0
- package/dist/types/interface/models/reflex-completion-webhook.model.js +10 -1
- package/dist/types/interface/models/reflex-completion-webhook.model.js.map +1 -1
- package/dist/types/interface/models/reflex-service-limits.model.d.ts +5 -2
- package/jest.config.ts +11 -11
- package/package.json +1 -1
- package/src/api/alert-rule.api.test.ts +72 -72
- package/src/api/alert-rule.api.ts +57 -57
- package/src/api/application-insights.api.test.ts +42 -42
- package/src/api/application-insights.api.ts +38 -38
- package/src/api/application-run-settings.api.test.ts +51 -51
- package/src/api/application-run-settings.api.ts +30 -30
- package/src/api/function-access.api.ts +87 -87
- package/src/api/function-insights.api.test.ts +27 -27
- package/src/api/function-insights.api.ts +18 -18
- package/src/api/function-run.api.ts +38 -38
- package/src/api/function-settings.api.ts +74 -74
- package/src/api/function-template.api.test.ts +72 -72
- package/src/api/function-template.api.ts +52 -52
- package/src/api/function-test.api.ts +34 -34
- package/src/api/function-version.api.ts +66 -66
- package/src/api/function.api.ts +62 -62
- package/src/api/health.api.ts +10 -10
- package/src/api/route-stats.api.test.ts +45 -45
- package/src/api/route-stats.api.ts +36 -36
- package/src/api/service-completion-webhook.api.test.ts +10 -0
- package/src/api/service-configuration.api.ts +16 -16
- package/src/api/service-deployment.api.ts +79 -79
- package/src/api/service-discord-event.api.test.ts +106 -106
- package/src/api/service-discord-event.api.ts +78 -78
- package/src/api/service-insights.api.test.ts +36 -36
- package/src/api/service-insights.api.ts +42 -42
- package/src/api/service-task.api.test.ts +140 -140
- package/src/api/service-task.api.ts +141 -141
- package/src/api/service-version.api.ts +54 -54
- package/src/api/service.api.test.ts +215 -215
- package/src/api/service.api.ts +55 -55
- package/src/discord/discord-event-filter-cases.ts +261 -261
- package/src/discord/discord-event-filters.test.ts +91 -91
- package/src/discord/discord-event-filters.ts +95 -95
- package/src/discord/discord-event-intents.test.ts +112 -112
- package/src/discord/discord-event-intents.ts +55 -55
- package/src/discord/index.ts +3 -3
- package/src/insights/index.ts +1 -1
- package/src/insights/percentiles.test.ts +75 -75
- package/src/insights/percentiles.ts +37 -37
- package/src/types/enum/access-grant-status.enum.ts +12 -12
- package/src/types/enum/access-kind.enum.ts +7 -7
- package/src/types/enum/access-request-status.enum.ts +11 -11
- package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
- package/src/types/enum/configuration-read-as.enum.ts +5 -5
- package/src/types/enum/discord-activity-type.enum.ts +9 -9
- package/src/types/enum/discord-channel-type.enum.ts +11 -11
- package/src/types/enum/discord-component-kind.enum.ts +7 -7
- package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
- package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
- package/src/types/enum/discord-event-status.enum.ts +13 -13
- package/src/types/enum/discord-event-type.enum.ts +7 -7
- package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
- package/src/types/enum/discord-gateway-state.enum.ts +11 -11
- package/src/types/enum/discord-host-action.enum.ts +35 -35
- package/src/types/enum/discord-locale.enum.ts +35 -35
- package/src/types/enum/discord-option-type.enum.ts +12 -12
- package/src/types/enum/discord-presence-status.enum.ts +8 -8
- package/src/types/enum/discord-sync-status.enum.ts +6 -6
- package/src/types/enum/discord-token-state.enum.ts +11 -11
- package/src/types/enum/execution-mode.enum.ts +9 -9
- package/src/types/enum/execution-profile.enum.ts +20 -20
- package/src/types/enum/execution-settings-source.enum.ts +9 -9
- package/src/types/enum/health-status.enum.ts +4 -4
- package/src/types/enum/insights-period.enum.ts +8 -8
- package/src/types/enum/log-cap-mode.enum.ts +6 -6
- package/src/types/enum/log-drop-cause.enum.ts +8 -8
- package/src/types/enum/reflex-alert-metric.enum.ts +5 -5
- package/src/types/enum/reflex-alert-notification-state.enum.ts +6 -6
- package/src/types/enum/reflex-alert-scope.enum.ts +6 -6
- package/src/types/enum/route-method.enum.ts +9 -9
- package/src/types/enum/run-log-level.enum.ts +6 -6
- package/src/types/enum/run-mode.enum.ts +11 -11
- package/src/types/enum/run-step-status.enum.ts +7 -7
- package/src/types/enum/schedule-sync-status.enum.ts +6 -6
- package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
- package/src/types/enum/scheduled-run-status.enum.ts +17 -17
- package/src/types/enum/service-deployment-action.enum.ts +11 -11
- package/src/types/enum/service-deployment-status.enum.ts +5 -5
- package/src/types/enum/service-type.enum.ts +9 -9
- package/src/types/enum/service-version-change-kind.enum.ts +6 -6
- package/src/types/enum/trace-effect-type.enum.ts +12 -12
- package/src/types/enum/trigger-access-mode.enum.ts +12 -12
- package/src/types/enum/trigger-kind.enum.ts +8 -8
- package/src/types/enum/vault-value-source.enum.ts +12 -12
- package/src/types/enum/vault-visibility.enum.ts +5 -5
- package/src/types/index.ts +2 -2
- package/src/types/interface/api/index.ts +3 -3
- package/src/types/interface/api/requests/alert-rule.request.ts +53 -53
- package/src/types/interface/api/requests/application-insights.request.ts +18 -18
- package/src/types/interface/api/requests/application-run-settings.request.ts +11 -11
- package/src/types/interface/api/requests/function-access.request.ts +51 -51
- package/src/types/interface/api/requests/function-settings.request.ts +34 -34
- package/src/types/interface/api/requests/function-template.request.ts +29 -29
- package/src/types/interface/api/requests/function-version.request.ts +38 -38
- package/src/types/interface/api/requests/function.request.ts +36 -36
- package/src/types/interface/api/requests/route-stats.request.ts +22 -22
- package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
- package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
- package/src/types/interface/api/requests/service-discord-event.request.ts +68 -68
- package/src/types/interface/api/requests/service-insights.request.ts +31 -31
- package/src/types/interface/api/requests/service-task.request.ts +80 -80
- package/src/types/interface/api/requests/service-version.request.ts +24 -24
- package/src/types/interface/api/requests/service.request.ts +46 -46
- package/src/types/interface/api/response.ts +4 -4
- package/src/types/interface/api/responses/alert-rule.response.ts +24 -24
- package/src/types/interface/api/responses/application-insights.response.ts +11 -11
- package/src/types/interface/api/responses/application-run-settings.response.ts +8 -8
- package/src/types/interface/api/responses/function-access.response.ts +45 -45
- package/src/types/interface/api/responses/function-run.response.ts +18 -18
- package/src/types/interface/api/responses/function-template.response.ts +21 -21
- package/src/types/interface/api/responses/function-version.response.ts +42 -42
- package/src/types/interface/api/responses/function.response.ts +25 -25
- package/src/types/interface/api/responses/route-stats.response.ts +15 -15
- package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
- package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
- package/src/types/interface/api/responses/service-discord-event.response.ts +24 -24
- package/src/types/interface/api/responses/service-insights.response.ts +11 -11
- package/src/types/interface/api/responses/service-task.response.ts +57 -57
- package/src/types/interface/api/responses/service-version.response.ts +112 -112
- package/src/types/interface/api/responses/service.response.ts +31 -31
- package/src/types/interface/health.response.ts +7 -7
- package/src/types/interface/index.ts +3 -3
- package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
- package/src/types/interface/models/reflex-access-request.model.ts +15 -15
- package/src/types/interface/models/reflex-alert-rule.model.ts +56 -56
- package/src/types/interface/models/reflex-completion-webhook.model.ts +26 -0
- package/src/types/interface/models/reflex-definition.model.ts +31 -31
- package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -58
- package/src/types/interface/models/reflex-discord-event.model.ts +79 -79
- package/src/types/interface/models/reflex-discord.model.ts +196 -196
- package/src/types/interface/models/reflex-function-template.model.ts +18 -18
- package/src/types/interface/models/reflex-function-version.model.ts +19 -19
- package/src/types/interface/models/reflex-function.model.ts +30 -30
- package/src/types/interface/models/reflex-insights.model.ts +215 -215
- package/src/types/interface/models/reflex-price-list.model.ts +20 -20
- package/src/types/interface/models/reflex-run-settings.model.ts +28 -28
- package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
- package/src/types/interface/models/reflex-service-deployment.model.ts +46 -46
- package/src/types/interface/models/reflex-service-limits.model.ts +17 -8
- package/src/types/interface/models/reflex-service.model.ts +45 -45
- package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
- package/src/types/interface/models/reflex-task.model.ts +97 -97
- package/tsconfig.check.json +15 -15
- package/tsconfig.json +35 -35
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import { ReflexAlertMetric } from '../../enum';
|
|
2
|
-
import type { ReflexAlertNotificationState, ReflexAlertScope } from '../../enum';
|
|
3
|
-
|
|
4
|
-
/** Bounds of the alert rules. */
|
|
5
|
-
export const REFLEX_ALERT_RULE_LIMITS = {
|
|
6
|
-
/** Active rules per application. */
|
|
7
|
-
maxActivePerApplication: 20,
|
|
8
|
-
/** Evaluation windows, in minutes. */
|
|
9
|
-
windowMinutes: [5, 15, 30, 60],
|
|
10
|
-
/** Bounds of the threshold by metric: a percentage for the error rate, milliseconds for the latency. */
|
|
11
|
-
threshold: {
|
|
12
|
-
[ReflexAlertMetric.ERROR_RATE]: { min: 1, max: 100 },
|
|
13
|
-
[ReflexAlertMetric.LATENCY_P95]: { min: 1, max: 3_600_000 },
|
|
14
|
-
},
|
|
15
|
-
/** Runs a window needs before the rule is evaluated. */
|
|
16
|
-
minRuns: { default: 20, min: 1, max: 10_000 },
|
|
17
|
-
name: { minLength: 1, maxLength: 64 },
|
|
18
|
-
} as const;
|
|
19
|
-
|
|
20
|
-
export interface IReflexAlertRule {
|
|
21
|
-
id: string;
|
|
22
|
-
applicationId: string;
|
|
23
|
-
environmentId: string;
|
|
24
|
-
scope: ReflexAlertScope;
|
|
25
|
-
/** The Service watched (scope SERVICE or ROUTE); null for a FUNCTION. */
|
|
26
|
-
serviceId: string | null;
|
|
27
|
-
/** The route watched (scope ROUTE); null otherwise. */
|
|
28
|
-
routeId: string | null;
|
|
29
|
-
/** The function watched (scope FUNCTION); null otherwise. */
|
|
30
|
-
functionId: string | null;
|
|
31
|
-
metric: ReflexAlertMetric;
|
|
32
|
-
threshold: number;
|
|
33
|
-
windowMinutes: number;
|
|
34
|
-
minRuns: number;
|
|
35
|
-
enabled: boolean;
|
|
36
|
-
name: string;
|
|
37
|
-
createdByUserId: string;
|
|
38
|
-
createdAt: Date;
|
|
39
|
-
updatedAt: Date;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** What the last evaluation of a rule found. */
|
|
43
|
-
export interface IReflexAlertRuleState {
|
|
44
|
-
ruleId: string;
|
|
45
|
-
environmentId: string;
|
|
46
|
-
evaluatedAt: Date;
|
|
47
|
-
/** Null when the window held fewer runs than `minRuns`. */
|
|
48
|
-
value: number | null;
|
|
49
|
-
runs: number;
|
|
50
|
-
firing: boolean;
|
|
51
|
-
firingSince: Date | null;
|
|
52
|
-
lastReportedAt: Date | null;
|
|
53
|
-
/** The Monitor incident the rule opened; null when none. */
|
|
54
|
-
incidentId: string | null;
|
|
55
|
-
notificationState: ReflexAlertNotificationState | null;
|
|
56
|
-
}
|
|
1
|
+
import { ReflexAlertMetric } from '../../enum';
|
|
2
|
+
import type { ReflexAlertNotificationState, ReflexAlertScope } from '../../enum';
|
|
3
|
+
|
|
4
|
+
/** Bounds of the alert rules. */
|
|
5
|
+
export const REFLEX_ALERT_RULE_LIMITS = {
|
|
6
|
+
/** Active rules per application. */
|
|
7
|
+
maxActivePerApplication: 20,
|
|
8
|
+
/** Evaluation windows, in minutes. */
|
|
9
|
+
windowMinutes: [5, 15, 30, 60],
|
|
10
|
+
/** Bounds of the threshold by metric: a percentage for the error rate, milliseconds for the latency. */
|
|
11
|
+
threshold: {
|
|
12
|
+
[ReflexAlertMetric.ERROR_RATE]: { min: 1, max: 100 },
|
|
13
|
+
[ReflexAlertMetric.LATENCY_P95]: { min: 1, max: 3_600_000 },
|
|
14
|
+
},
|
|
15
|
+
/** Runs a window needs before the rule is evaluated. */
|
|
16
|
+
minRuns: { default: 20, min: 1, max: 10_000 },
|
|
17
|
+
name: { minLength: 1, maxLength: 64 },
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
export interface IReflexAlertRule {
|
|
21
|
+
id: string;
|
|
22
|
+
applicationId: string;
|
|
23
|
+
environmentId: string;
|
|
24
|
+
scope: ReflexAlertScope;
|
|
25
|
+
/** The Service watched (scope SERVICE or ROUTE); null for a FUNCTION. */
|
|
26
|
+
serviceId: string | null;
|
|
27
|
+
/** The route watched (scope ROUTE); null otherwise. */
|
|
28
|
+
routeId: string | null;
|
|
29
|
+
/** The function watched (scope FUNCTION); null otherwise. */
|
|
30
|
+
functionId: string | null;
|
|
31
|
+
metric: ReflexAlertMetric;
|
|
32
|
+
threshold: number;
|
|
33
|
+
windowMinutes: number;
|
|
34
|
+
minRuns: number;
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
name: string;
|
|
37
|
+
createdByUserId: string;
|
|
38
|
+
createdAt: Date;
|
|
39
|
+
updatedAt: Date;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** What the last evaluation of a rule found. */
|
|
43
|
+
export interface IReflexAlertRuleState {
|
|
44
|
+
ruleId: string;
|
|
45
|
+
environmentId: string;
|
|
46
|
+
evaluatedAt: Date;
|
|
47
|
+
/** Null when the window held fewer runs than `minRuns`. */
|
|
48
|
+
value: number | null;
|
|
49
|
+
runs: number;
|
|
50
|
+
firing: boolean;
|
|
51
|
+
firingSince: Date | null;
|
|
52
|
+
lastReportedAt: Date | null;
|
|
53
|
+
/** The Monitor incident the rule opened; null when none. */
|
|
54
|
+
incidentId: string | null;
|
|
55
|
+
notificationState: ReflexAlertNotificationState | null;
|
|
56
|
+
}
|
|
@@ -21,6 +21,32 @@ export const REFLEX_COMPLETION_WEBHOOK_LIMITS = {
|
|
|
21
21
|
outputMaxBytes: 65_536,
|
|
22
22
|
} as const;
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* The sentences the edge writes into the `error` of a delivery attempt (`IReflexCompletionDeliveryAttempt.error`)
|
|
26
|
+
* when it is not a bare receiver answer, for a reader that has to recognise them. They are English and fixed; the
|
|
27
|
+
* edge builds the rest of an `error` around the prefixes:
|
|
28
|
+
* - `HTTP <status>` or `HTTP <status>: redirects are not followed` (`httpPrefix`, `redirectsNotFollowed`);
|
|
29
|
+
* - `The receiver did not answer within <sendTimeoutMs> ms` (`receiverTimeoutPrefix`);
|
|
30
|
+
* - `The request failed (<code>)` where `<code>` is the undici or Node error code (`requestFailedPrefix`).
|
|
31
|
+
* The edge keeps a local copy (it does not depend on this SDK); `edge-contract-parity.spec.ts` fails when they differ.
|
|
32
|
+
*/
|
|
33
|
+
export const REFLEX_COMPLETION_DELIVERY_ERRORS = {
|
|
34
|
+
/** The URL is not https, or it (or the address it resolves to) is one the edge may not reach: the SSRF guard refused it. */
|
|
35
|
+
refusedAddress: 'The URL is not https, or reaches an address the edge may not reach',
|
|
36
|
+
/** The Service has no signing secret in the environment (or it does not unseal): nothing was posted. */
|
|
37
|
+
noSigningSecret: 'No signing secret for the Service in the environment',
|
|
38
|
+
/** The URL does not parse: nothing was posted. */
|
|
39
|
+
invalidUrl: 'The URL is not valid',
|
|
40
|
+
/** Start of the sentence written when the receiver did not answer in time; followed by ` <ms> ms`. */
|
|
41
|
+
receiverTimeoutPrefix: 'The receiver did not answer within',
|
|
42
|
+
/** Start of the sentence written for a network failure; followed by ` (<error code>)`. */
|
|
43
|
+
requestFailedPrefix: 'The request failed',
|
|
44
|
+
/** Start of the sentence written for an HTTP status that ended the attempt; followed by ` <status>`. */
|
|
45
|
+
httpPrefix: 'HTTP',
|
|
46
|
+
/** The reason that follows `HTTP <status>: ` for a 3xx answer. */
|
|
47
|
+
redirectsNotFollowed: 'redirects are not followed',
|
|
48
|
+
} as const;
|
|
49
|
+
|
|
24
50
|
/**
|
|
25
51
|
* The JSON body the edge `POST`s to the completion webhook URL once an async execution finished, signed
|
|
26
52
|
* `x-abyss-signature: t=<seconds>,v1=<hmac>` (ADR-0257) with the secret of the Service and the environment, and
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import type { ReflexAccessKind } from '../../enum';
|
|
2
|
-
|
|
3
|
-
export interface IReflexHttpAccess {
|
|
4
|
-
kind: ReflexAccessKind.HTTP;
|
|
5
|
-
hosts: string[];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface IReflexHostActionAccess {
|
|
9
|
-
kind: ReflexAccessKind.HOST_ACTION;
|
|
10
|
-
action: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type IReflexAccessDeclaration = IReflexHttpAccess | IReflexHostActionAccess;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A function's definition, in the format of @abyss-project/runtime (`formatVersion` 1). The steps are
|
|
17
|
-
* the core's own and validated by the API; the SDK only carries them.
|
|
18
|
-
*/
|
|
19
|
-
export interface IReflexDefinition {
|
|
20
|
-
formatVersion: number;
|
|
21
|
-
accesses: IReflexAccessDeclaration[];
|
|
22
|
-
steps: Array<Record<string, unknown>>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Bounds of the status a RESPOND step (or `abyss.respond`) may answer with, both included: the
|
|
27
|
-
* runtime's `MIN_RESPONSE_STATUS` and `MAX_RESPONSE_STATUS`, which publication and the edge apply.
|
|
28
|
-
* The API's tests check that they are equal.
|
|
29
|
-
*/
|
|
30
|
-
export const RESPOND_STATUS_MIN = 200;
|
|
31
|
-
export const RESPOND_STATUS_MAX = 599;
|
|
1
|
+
import type { ReflexAccessKind } from '../../enum';
|
|
2
|
+
|
|
3
|
+
export interface IReflexHttpAccess {
|
|
4
|
+
kind: ReflexAccessKind.HTTP;
|
|
5
|
+
hosts: string[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IReflexHostActionAccess {
|
|
9
|
+
kind: ReflexAccessKind.HOST_ACTION;
|
|
10
|
+
action: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type IReflexAccessDeclaration = IReflexHttpAccess | IReflexHostActionAccess;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A function's definition, in the format of @abyss-project/runtime (`formatVersion` 1). The steps are
|
|
17
|
+
* the core's own and validated by the API; the SDK only carries them.
|
|
18
|
+
*/
|
|
19
|
+
export interface IReflexDefinition {
|
|
20
|
+
formatVersion: number;
|
|
21
|
+
accesses: IReflexAccessDeclaration[];
|
|
22
|
+
steps: Array<Record<string, unknown>>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Bounds of the status a RESPOND step (or `abyss.respond`) may answer with, both included: the
|
|
27
|
+
* runtime's `MIN_RESPONSE_STATUS` and `MAX_RESPONSE_STATUS`, which publication and the edge apply.
|
|
28
|
+
* The API's tests check that they are equal.
|
|
29
|
+
*/
|
|
30
|
+
export const RESPOND_STATUS_MIN = 200;
|
|
31
|
+
export const RESPOND_STATUS_MAX = 599;
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DiscordEventDropReason,
|
|
3
|
-
DiscordEventFilterName,
|
|
4
|
-
DiscordEventStatus,
|
|
5
|
-
DiscordEventType,
|
|
6
|
-
} from '../../enum';
|
|
7
|
-
|
|
8
|
-
/** A retained event, from the inbox of the execution plane. */
|
|
9
|
-
export interface IReflexDiscordEventLogRetained {
|
|
10
|
-
id: string;
|
|
11
|
-
eventType: DiscordEventType;
|
|
12
|
-
guildId: string | null;
|
|
13
|
-
channelId: string | null;
|
|
14
|
-
authorId: string | null;
|
|
15
|
-
receivedAt: Date;
|
|
16
|
-
status: DiscordEventStatus;
|
|
17
|
-
triggerId: string;
|
|
18
|
-
/** The name of the trigger in the version in service; null when that version no longer has it. */
|
|
19
|
-
triggerName: string | null;
|
|
20
|
-
functionId: string | null;
|
|
21
|
-
/** The execution it started; null before it ran. */
|
|
22
|
-
liveRunId: string | null;
|
|
23
|
-
durationMs: number | null;
|
|
24
|
-
costMillicredits: number | null;
|
|
25
|
-
/** Failure code of a FAILED event: `EVENT_TRIGGER_REMOVED` or the error code of the run; null otherwise. */
|
|
26
|
-
failureCode: string | null;
|
|
27
|
-
/** The id of its inbox row without dashes. */
|
|
28
|
-
traceId: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** A dropped event, from the sample kept per bot and per reason. */
|
|
32
|
-
export interface IReflexDiscordEventLogDropped {
|
|
33
|
-
id: string;
|
|
34
|
-
eventType: DiscordEventType;
|
|
35
|
-
guildId: string | null;
|
|
36
|
-
channelId: string | null;
|
|
37
|
-
authorId: string | null;
|
|
38
|
-
receivedAt: Date;
|
|
39
|
-
reason: DiscordEventDropReason;
|
|
40
|
-
/** The filter that rejected it, when `reason` is FILTERED; null otherwise. */
|
|
41
|
-
filterName: DiscordEventFilterName | null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** Shown instead of the events when Discord refused the intents (close code 4014): it sends none, so none can be listed. */
|
|
45
|
-
export interface IReflexDiscordEventLogIntentsRefused {
|
|
46
|
-
since: Date;
|
|
47
|
-
/** The privileged intents the version in service asks for, as Discord intent bits. */
|
|
48
|
-
privilegedIntents: number[];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** One page of the event log of a bot in one environment. */
|
|
52
|
-
export interface IReflexDiscordEventLogPage {
|
|
53
|
-
retained: IReflexDiscordEventLogRetained[];
|
|
54
|
-
dropped: IReflexDiscordEventLogDropped[];
|
|
55
|
-
/** Null unless the bot is refused its intents. */
|
|
56
|
-
intentsRefused: IReflexDiscordEventLogIntentsRefused | null;
|
|
57
|
-
nextCursor: string | null;
|
|
58
|
-
}
|
|
1
|
+
import type {
|
|
2
|
+
DiscordEventDropReason,
|
|
3
|
+
DiscordEventFilterName,
|
|
4
|
+
DiscordEventStatus,
|
|
5
|
+
DiscordEventType,
|
|
6
|
+
} from '../../enum';
|
|
7
|
+
|
|
8
|
+
/** A retained event, from the inbox of the execution plane. */
|
|
9
|
+
export interface IReflexDiscordEventLogRetained {
|
|
10
|
+
id: string;
|
|
11
|
+
eventType: DiscordEventType;
|
|
12
|
+
guildId: string | null;
|
|
13
|
+
channelId: string | null;
|
|
14
|
+
authorId: string | null;
|
|
15
|
+
receivedAt: Date;
|
|
16
|
+
status: DiscordEventStatus;
|
|
17
|
+
triggerId: string;
|
|
18
|
+
/** The name of the trigger in the version in service; null when that version no longer has it. */
|
|
19
|
+
triggerName: string | null;
|
|
20
|
+
functionId: string | null;
|
|
21
|
+
/** The execution it started; null before it ran. */
|
|
22
|
+
liveRunId: string | null;
|
|
23
|
+
durationMs: number | null;
|
|
24
|
+
costMillicredits: number | null;
|
|
25
|
+
/** Failure code of a FAILED event: `EVENT_TRIGGER_REMOVED` or the error code of the run; null otherwise. */
|
|
26
|
+
failureCode: string | null;
|
|
27
|
+
/** The id of its inbox row without dashes. */
|
|
28
|
+
traceId: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** A dropped event, from the sample kept per bot and per reason. */
|
|
32
|
+
export interface IReflexDiscordEventLogDropped {
|
|
33
|
+
id: string;
|
|
34
|
+
eventType: DiscordEventType;
|
|
35
|
+
guildId: string | null;
|
|
36
|
+
channelId: string | null;
|
|
37
|
+
authorId: string | null;
|
|
38
|
+
receivedAt: Date;
|
|
39
|
+
reason: DiscordEventDropReason;
|
|
40
|
+
/** The filter that rejected it, when `reason` is FILTERED; null otherwise. */
|
|
41
|
+
filterName: DiscordEventFilterName | null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Shown instead of the events when Discord refused the intents (close code 4014): it sends none, so none can be listed. */
|
|
45
|
+
export interface IReflexDiscordEventLogIntentsRefused {
|
|
46
|
+
since: Date;
|
|
47
|
+
/** The privileged intents the version in service asks for, as Discord intent bits. */
|
|
48
|
+
privilegedIntents: number[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** One page of the event log of a bot in one environment. */
|
|
52
|
+
export interface IReflexDiscordEventLogPage {
|
|
53
|
+
retained: IReflexDiscordEventLogRetained[];
|
|
54
|
+
dropped: IReflexDiscordEventLogDropped[];
|
|
55
|
+
/** Null unless the bot is refused its intents. */
|
|
56
|
+
intentsRefused: IReflexDiscordEventLogIntentsRefused | null;
|
|
57
|
+
nextCursor: string | null;
|
|
58
|
+
}
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import type { DiscordEventType } from '../../enum';
|
|
2
|
-
|
|
3
|
-
/** Bounds of the Discord event triggers of a bot; the API, the Gateway and their databases apply the same ones. */
|
|
4
|
-
export const REFLEX_DISCORD_EVENT_LIMITS = {
|
|
5
|
-
/** `^[-_a-z0-9]{1,32}$`: the name of a trigger, unique within the Service. */
|
|
6
|
-
namePattern: /^[-_a-z0-9]{1,32}$/,
|
|
7
|
-
nameMaxLength: 32,
|
|
8
|
-
maxTriggersPerService: 25,
|
|
9
|
-
guildIdsMax: 25,
|
|
10
|
-
channelIdsMax: 50,
|
|
11
|
-
roleIdsMax: 25,
|
|
12
|
-
contentPrefixMaxLength: 32,
|
|
13
|
-
/** Characters of the payload of a retained event, serialized to JSON. */
|
|
14
|
-
payloadMaxLength: 8192,
|
|
15
|
-
/** Characters of the summary kept with an event, retained or dropped. */
|
|
16
|
-
summaryMaxLength: 512,
|
|
17
|
-
/** Dropped events kept as a sample, per bot and per reason. */
|
|
18
|
-
dropSamplesPerReason: 200,
|
|
19
|
-
/** Lateness past which a retained event is EXPIRED instead of run. */
|
|
20
|
-
toleranceMinutes: 15,
|
|
21
|
-
} as const;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* What one bot can take in (decision 6 of the J2 spec, ADR-0307). Measured on staging (C1, run 2, 24/11/2026, after
|
|
25
|
-
* the per-bot claim and the sharded rollups): a bot sustains about 3 000 events per minute, bounded by the database
|
|
26
|
-
* (WAL and the `execution_counters` row) more than by its slots: 20 usable slots at 150 each on staging. The formula
|
|
27
|
-
* `min(lotsMaxCeiling, floor((maxConcurrencyPerBot * runsPerSlotPerMinute - base) / 500))` is kept, with
|
|
28
|
-
* `maxConcurrencyPerBot × runsPerSlotPerMinute` = 30 × 100 = the measured 3 000; `lotsMax` is its value for the largest base.
|
|
29
|
-
*/
|
|
30
|
-
export const REFLEX_BOT_EVENT_CAPACITY = {
|
|
31
|
-
/** With `maxConcurrencyPerBot` (the configuration ceiling 30), keeps the product at the measured 3 000 per bot. */
|
|
32
|
-
runsPerSlotPerMinute: 100,
|
|
33
|
-
/** `maxReplicas` (3) times the ceiling per pod (10) of the edge fleet. */
|
|
34
|
-
maxConcurrencyPerBot: 30,
|
|
35
|
-
/** The most lots of 500 events per minute a bot can be allocated, whatever the measure says. */
|
|
36
|
-
lotsMaxCeiling: 40,
|
|
37
|
-
/** The most lots a bot can be allocated: floor((30 × 100 − 500) / 500) = 5. */
|
|
38
|
-
lotsMax: 5,
|
|
39
|
-
} as const;
|
|
40
|
-
|
|
41
|
-
/** Optional filters of a trigger, combined with AND. An absent or empty list is no filter. */
|
|
42
|
-
export interface IReflexDiscordEventFilters {
|
|
43
|
-
/** 25 at most, every type. */
|
|
44
|
-
guildIds?: string[];
|
|
45
|
-
/** 50 at most, message and reaction. */
|
|
46
|
-
channelIds?: string[];
|
|
47
|
-
/** 25 at most, member arrival, message and reaction: the member has one of these roles. */
|
|
48
|
-
roleIds?: string[];
|
|
49
|
-
/** 32 characters at most, message: the content starts with it; needs the MESSAGE_CONTENT intent. */
|
|
50
|
-
contentPrefix?: string;
|
|
51
|
-
/** True when absent: an author or member that is a bot is ignored. */
|
|
52
|
-
ignoreBots?: boolean;
|
|
53
|
-
/** True when absent, message and reaction: the bot itself is ignored. */
|
|
54
|
-
ignoreSelf?: boolean;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** A Discord event trigger of the draft of a bot Service: a named target of one event type. */
|
|
58
|
-
export interface IReflexDiscordEvent {
|
|
59
|
-
id: string;
|
|
60
|
-
serviceId: string;
|
|
61
|
-
/** A function of the same Service. */
|
|
62
|
-
functionId: string;
|
|
63
|
-
/** Unique within the Service. */
|
|
64
|
-
name: string;
|
|
65
|
-
eventType: DiscordEventType;
|
|
66
|
-
filters: IReflexDiscordEventFilters;
|
|
67
|
-
/** True by default: events of one channel (or one server for member events) run one after the other. */
|
|
68
|
-
ordered: boolean;
|
|
69
|
-
/** False by default, MESSAGE_CREATE only: the function receives the message content. */
|
|
70
|
-
includeContent: boolean;
|
|
71
|
-
createdAt: Date;
|
|
72
|
-
updatedAt: Date;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** A Discord event trigger as a version of the Service froze it. */
|
|
76
|
-
export type IReflexDiscordEventSnapshot = Pick<
|
|
77
|
-
IReflexDiscordEvent,
|
|
78
|
-
'id' | 'functionId' | 'name' | 'eventType' | 'filters' | 'ordered' | 'includeContent'
|
|
79
|
-
>;
|
|
1
|
+
import type { DiscordEventType } from '../../enum';
|
|
2
|
+
|
|
3
|
+
/** Bounds of the Discord event triggers of a bot; the API, the Gateway and their databases apply the same ones. */
|
|
4
|
+
export const REFLEX_DISCORD_EVENT_LIMITS = {
|
|
5
|
+
/** `^[-_a-z0-9]{1,32}$`: the name of a trigger, unique within the Service. */
|
|
6
|
+
namePattern: /^[-_a-z0-9]{1,32}$/,
|
|
7
|
+
nameMaxLength: 32,
|
|
8
|
+
maxTriggersPerService: 25,
|
|
9
|
+
guildIdsMax: 25,
|
|
10
|
+
channelIdsMax: 50,
|
|
11
|
+
roleIdsMax: 25,
|
|
12
|
+
contentPrefixMaxLength: 32,
|
|
13
|
+
/** Characters of the payload of a retained event, serialized to JSON. */
|
|
14
|
+
payloadMaxLength: 8192,
|
|
15
|
+
/** Characters of the summary kept with an event, retained or dropped. */
|
|
16
|
+
summaryMaxLength: 512,
|
|
17
|
+
/** Dropped events kept as a sample, per bot and per reason. */
|
|
18
|
+
dropSamplesPerReason: 200,
|
|
19
|
+
/** Lateness past which a retained event is EXPIRED instead of run. */
|
|
20
|
+
toleranceMinutes: 15,
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* What one bot can take in (decision 6 of the J2 spec, ADR-0307). Measured on staging (C1, run 2, 24/11/2026, after
|
|
25
|
+
* the per-bot claim and the sharded rollups): a bot sustains about 3 000 events per minute, bounded by the database
|
|
26
|
+
* (WAL and the `execution_counters` row) more than by its slots: 20 usable slots at 150 each on staging. The formula
|
|
27
|
+
* `min(lotsMaxCeiling, floor((maxConcurrencyPerBot * runsPerSlotPerMinute - base) / 500))` is kept, with
|
|
28
|
+
* `maxConcurrencyPerBot × runsPerSlotPerMinute` = 30 × 100 = the measured 3 000; `lotsMax` is its value for the largest base.
|
|
29
|
+
*/
|
|
30
|
+
export const REFLEX_BOT_EVENT_CAPACITY = {
|
|
31
|
+
/** With `maxConcurrencyPerBot` (the configuration ceiling 30), keeps the product at the measured 3 000 per bot. */
|
|
32
|
+
runsPerSlotPerMinute: 100,
|
|
33
|
+
/** `maxReplicas` (3) times the ceiling per pod (10) of the edge fleet. */
|
|
34
|
+
maxConcurrencyPerBot: 30,
|
|
35
|
+
/** The most lots of 500 events per minute a bot can be allocated, whatever the measure says. */
|
|
36
|
+
lotsMaxCeiling: 40,
|
|
37
|
+
/** The most lots a bot can be allocated: floor((30 × 100 − 500) / 500) = 5. */
|
|
38
|
+
lotsMax: 5,
|
|
39
|
+
} as const;
|
|
40
|
+
|
|
41
|
+
/** Optional filters of a trigger, combined with AND. An absent or empty list is no filter. */
|
|
42
|
+
export interface IReflexDiscordEventFilters {
|
|
43
|
+
/** 25 at most, every type. */
|
|
44
|
+
guildIds?: string[];
|
|
45
|
+
/** 50 at most, message and reaction. */
|
|
46
|
+
channelIds?: string[];
|
|
47
|
+
/** 25 at most, member arrival, message and reaction: the member has one of these roles. */
|
|
48
|
+
roleIds?: string[];
|
|
49
|
+
/** 32 characters at most, message: the content starts with it; needs the MESSAGE_CONTENT intent. */
|
|
50
|
+
contentPrefix?: string;
|
|
51
|
+
/** True when absent: an author or member that is a bot is ignored. */
|
|
52
|
+
ignoreBots?: boolean;
|
|
53
|
+
/** True when absent, message and reaction: the bot itself is ignored. */
|
|
54
|
+
ignoreSelf?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A Discord event trigger of the draft of a bot Service: a named target of one event type. */
|
|
58
|
+
export interface IReflexDiscordEvent {
|
|
59
|
+
id: string;
|
|
60
|
+
serviceId: string;
|
|
61
|
+
/** A function of the same Service. */
|
|
62
|
+
functionId: string;
|
|
63
|
+
/** Unique within the Service. */
|
|
64
|
+
name: string;
|
|
65
|
+
eventType: DiscordEventType;
|
|
66
|
+
filters: IReflexDiscordEventFilters;
|
|
67
|
+
/** True by default: events of one channel (or one server for member events) run one after the other. */
|
|
68
|
+
ordered: boolean;
|
|
69
|
+
/** False by default, MESSAGE_CREATE only: the function receives the message content. */
|
|
70
|
+
includeContent: boolean;
|
|
71
|
+
createdAt: Date;
|
|
72
|
+
updatedAt: Date;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** A Discord event trigger as a version of the Service froze it. */
|
|
76
|
+
export type IReflexDiscordEventSnapshot = Pick<
|
|
77
|
+
IReflexDiscordEvent,
|
|
78
|
+
'id' | 'functionId' | 'name' | 'eventType' | 'filters' | 'ordered' | 'includeContent'
|
|
79
|
+
>;
|