@abyss-project/reflex 5.4.0 → 5.5.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.
- package/dist/api/function-insights.api.d.ts +2 -0
- package/dist/api/function-insights.api.js +7 -0
- package/dist/api/function-insights.api.js.map +1 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +3 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/service-discord-event.api.d.ts +6 -0
- package/dist/api/service-discord-event.api.js +18 -0
- package/dist/api/service-discord-event.api.js.map +1 -0
- package/dist/api/service-discord.api.d.ts +3 -1
- package/dist/api/service-discord.api.js +5 -1
- package/dist/api/service-discord.api.js.map +1 -1
- package/dist/api/service-insights.api.d.ts +3 -0
- package/dist/api/service-insights.api.js +12 -0
- package/dist/api/service-insights.api.js.map +1 -0
- package/dist/discord/discord-event-filter-cases.d.ts +15 -0
- package/dist/discord/discord-event-filter-cases.js +77 -0
- package/dist/discord/discord-event-filter-cases.js.map +1 -0
- package/dist/discord/discord-event-filters.d.ts +20 -0
- package/dist/discord/discord-event-filters.js +50 -0
- package/dist/discord/discord-event-filters.js.map +1 -0
- package/dist/discord/discord-event-intents.d.ts +14 -0
- package/dist/discord/discord-event-intents.js +38 -0
- package/dist/discord/discord-event-intents.js.map +1 -0
- package/dist/discord/index.d.ts +3 -0
- package/dist/discord/index.js +20 -0
- package/dist/discord/index.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/dist/types/enum/bot-event-block-reason.enum.d.ts +4 -0
- package/dist/types/enum/bot-event-block-reason.enum.js +9 -0
- package/dist/types/enum/bot-event-block-reason.enum.js.map +1 -0
- package/dist/types/enum/discord-event-drop-reason.enum.d.ts +7 -0
- package/dist/types/enum/discord-event-drop-reason.enum.js +12 -0
- package/dist/types/enum/discord-event-drop-reason.enum.js.map +1 -0
- package/dist/types/enum/discord-event-filter-name.enum.d.ts +9 -0
- package/dist/types/enum/discord-event-filter-name.enum.js +14 -0
- package/dist/types/enum/discord-event-filter-name.enum.js.map +1 -0
- package/dist/types/enum/discord-event-status.enum.d.ts +7 -0
- package/dist/types/enum/discord-event-status.enum.js +12 -0
- package/dist/types/enum/discord-event-status.enum.js.map +1 -0
- package/dist/types/enum/discord-event-type.enum.d.ts +6 -0
- package/dist/types/enum/discord-event-type.enum.js +11 -0
- package/dist/types/enum/discord-event-type.enum.js.map +1 -0
- package/dist/types/enum/discord-gateway-failure-code.enum.d.ts +2 -1
- package/dist/types/enum/discord-gateway-failure-code.enum.js +1 -0
- package/dist/types/enum/discord-gateway-failure-code.enum.js.map +1 -1
- package/dist/types/enum/index.d.ts +7 -0
- package/dist/types/enum/index.js +7 -0
- package/dist/types/enum/index.js.map +1 -1
- package/dist/types/enum/insights-period.enum.d.ts +7 -0
- package/dist/types/enum/insights-period.enum.js +12 -0
- package/dist/types/enum/insights-period.enum.js.map +1 -0
- package/dist/types/enum/scheduled-run-failure-code.enum.d.ts +2 -1
- package/dist/types/enum/scheduled-run-failure-code.enum.js +1 -0
- package/dist/types/enum/scheduled-run-failure-code.enum.js.map +1 -1
- package/dist/types/enum/trigger-kind.enum.d.ts +7 -0
- package/dist/types/enum/trigger-kind.enum.js +12 -0
- package/dist/types/enum/trigger-kind.enum.js.map +1 -0
- package/dist/types/interface/api/requests/index.d.ts +2 -0
- package/dist/types/interface/api/requests/index.js +2 -0
- package/dist/types/interface/api/requests/index.js.map +1 -1
- package/dist/types/interface/api/requests/service-discord-event.request.d.ts +51 -0
- package/dist/types/interface/api/requests/service-discord-event.request.js +3 -0
- package/dist/types/interface/api/requests/service-discord-event.request.js.map +1 -0
- package/dist/types/interface/api/requests/service-discord.request.d.ts +22 -1
- package/dist/types/interface/api/requests/service-insights.request.d.ts +25 -0
- package/dist/types/interface/api/requests/service-insights.request.js +3 -0
- package/dist/types/interface/api/requests/service-insights.request.js.map +1 -0
- package/dist/types/interface/api/responses/index.d.ts +2 -0
- package/dist/types/interface/api/responses/index.js +2 -0
- package/dist/types/interface/api/responses/index.js.map +1 -1
- package/dist/types/interface/api/responses/service-discord-event.response.d.ts +18 -0
- package/dist/types/interface/api/responses/service-discord-event.response.js +3 -0
- package/dist/types/interface/api/responses/service-discord-event.response.js.map +1 -0
- package/dist/types/interface/api/responses/service-discord.response.d.ts +30 -5
- package/dist/types/interface/api/responses/service-insights.response.d.ts +8 -0
- package/dist/types/interface/api/responses/service-insights.response.js +3 -0
- package/dist/types/interface/api/responses/service-insights.response.js.map +1 -0
- package/dist/types/interface/api/responses/service-version.response.d.ts +9 -1
- package/dist/types/interface/models/index.d.ts +4 -0
- package/dist/types/interface/models/index.js +4 -0
- package/dist/types/interface/models/index.js.map +1 -1
- package/dist/types/interface/models/reflex-bot-limits.model.d.ts +56 -0
- package/dist/types/interface/models/reflex-bot-limits.model.js +16 -0
- package/dist/types/interface/models/reflex-bot-limits.model.js.map +1 -0
- package/dist/types/interface/models/reflex-discord-event-log.model.d.ts +38 -0
- package/dist/types/interface/models/reflex-discord-event-log.model.js +3 -0
- package/dist/types/interface/models/reflex-discord-event-log.model.js.map +1 -0
- package/dist/types/interface/models/reflex-discord-event.model.d.ts +41 -0
- package/dist/types/interface/models/reflex-discord-event.model.js +23 -0
- package/dist/types/interface/models/reflex-discord-event.model.js.map +1 -0
- package/dist/types/interface/models/reflex-insights.model.d.ts +83 -0
- package/dist/types/interface/models/reflex-insights.model.js +16 -0
- package/dist/types/interface/models/reflex-insights.model.js.map +1 -0
- package/dist/types/interface/models/reflex-run.model.d.ts +2 -0
- package/dist/types/interface/models/reflex-service-version.model.d.ts +2 -0
- package/package.json +1 -1
- package/src/api/function-insights.api.test.ts +27 -0
- package/src/api/function-insights.api.ts +18 -0
- package/src/api/index.ts +17 -14
- package/src/api/service-discord-event.api.test.ts +106 -0
- package/src/api/service-discord-event.api.ts +78 -0
- package/src/api/service-discord.api.test.ts +197 -170
- package/src/api/service-discord.api.ts +241 -203
- package/src/api/service-insights.api.test.ts +36 -0
- package/src/api/service-insights.api.ts +42 -0
- package/src/api/service-task.api.test.ts +140 -140
- package/src/api/service-task.api.ts +141 -141
- package/src/discord/discord-event-filter-cases.ts +261 -0
- package/src/discord/discord-event-filters.test.ts +91 -0
- package/src/discord/discord-event-filters.ts +95 -0
- package/src/discord/discord-event-intents.test.ts +112 -0
- package/src/discord/discord-event-intents.ts +55 -0
- package/src/discord/index.ts +3 -0
- package/src/index.test.ts +75 -50
- package/src/index.ts +46 -0
- package/src/types/enum/bot-event-block-reason.enum.ts +7 -0
- package/src/types/enum/discord-event-drop-reason.enum.ts +13 -0
- package/src/types/enum/discord-event-filter-name.enum.ts +11 -0
- package/src/types/enum/discord-event-status.enum.ts +13 -0
- package/src/types/enum/discord-event-type.enum.ts +7 -0
- package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -9
- package/src/types/enum/index.ts +7 -0
- package/src/types/enum/insights-period.enum.ts +8 -0
- package/src/types/enum/schedule-sync-status.enum.ts +6 -6
- package/src/types/enum/scheduled-run-failure-code.enum.ts +2 -0
- 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/trigger-kind.enum.ts +8 -0
- package/src/types/interface/api/requests/index.ts +15 -13
- package/src/types/interface/api/requests/service-discord-event.request.ts +68 -0
- package/src/types/interface/api/requests/service-discord.request.ts +161 -128
- package/src/types/interface/api/requests/service-insights.request.ts +31 -0
- package/src/types/interface/api/requests/service-task.request.ts +80 -80
- package/src/types/interface/api/responses/index.ts +15 -13
- package/src/types/interface/api/responses/service-discord-event.response.ts +24 -0
- package/src/types/interface/api/responses/service-discord.response.ts +119 -72
- package/src/types/interface/api/responses/service-insights.response.ts +11 -0
- package/src/types/interface/api/responses/service-task.response.ts +57 -57
- package/src/types/interface/api/responses/service-version.response.ts +106 -91
- package/src/types/interface/models/index.ts +19 -15
- package/src/types/interface/models/reflex-bot-limits.model.ts +92 -0
- package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -0
- package/src/types/interface/models/reflex-discord-event.model.ts +77 -0
- package/src/types/interface/models/reflex-insights.model.ts +120 -0
- package/src/types/interface/models/reflex-run.model.ts +183 -179
- package/src/types/interface/models/reflex-service-version.model.ts +61 -58
- package/src/types/interface/models/reflex-task.model.ts +97 -97
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REFLEX_BOT_LIMITS = void 0;
|
|
4
|
+
exports.REFLEX_BOT_LIMITS = {
|
|
5
|
+
eventsPerMinutePerLot: 500,
|
|
6
|
+
monthlySpendCapDefaultCents: 1000,
|
|
7
|
+
monthlySpendCapMinCents: 100,
|
|
8
|
+
monthlySpendCapMaxCents: 50000,
|
|
9
|
+
alertThresholdsMax: 5,
|
|
10
|
+
alertThresholdMin: 1,
|
|
11
|
+
alertThresholdMax: 100,
|
|
12
|
+
spendCapDefaultThresholds: [80, 100],
|
|
13
|
+
rateAlertDefaultMinutes: 5,
|
|
14
|
+
rateAlertDefaultPercent: 80,
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=reflex-bot-limits.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflex-bot-limits.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/reflex-bot-limits.model.ts"],"names":[],"mappings":";;;AAGa,QAAA,iBAAiB,GAAG;IAE/B,qBAAqB,EAAE,GAAG;IAE1B,2BAA2B,EAAE,IAAI;IACjC,uBAAuB,EAAE,GAAG;IAC5B,uBAAuB,EAAE,KAAK;IAE9B,kBAAkB,EAAE,CAAC;IACrB,iBAAiB,EAAE,CAAC;IACpB,iBAAiB,EAAE,GAAG;IAEtB,yBAAyB,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC;IAEpC,uBAAuB,EAAE,CAAC;IAC1B,uBAAuB,EAAE,EAAE;CACnB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { DiscordEventDropReason, DiscordEventFilterName, DiscordEventStatus, DiscordEventType } from '../../enum';
|
|
2
|
+
export interface IReflexDiscordEventLogRetained {
|
|
3
|
+
id: string;
|
|
4
|
+
eventType: DiscordEventType;
|
|
5
|
+
guildId: string | null;
|
|
6
|
+
channelId: string | null;
|
|
7
|
+
authorId: string | null;
|
|
8
|
+
receivedAt: Date;
|
|
9
|
+
status: DiscordEventStatus;
|
|
10
|
+
triggerId: string;
|
|
11
|
+
triggerName: string | null;
|
|
12
|
+
functionId: string | null;
|
|
13
|
+
liveRunId: string | null;
|
|
14
|
+
durationMs: number | null;
|
|
15
|
+
costMillicredits: number | null;
|
|
16
|
+
failureCode: string | null;
|
|
17
|
+
traceId: string;
|
|
18
|
+
}
|
|
19
|
+
export interface IReflexDiscordEventLogDropped {
|
|
20
|
+
id: string;
|
|
21
|
+
eventType: DiscordEventType;
|
|
22
|
+
guildId: string | null;
|
|
23
|
+
channelId: string | null;
|
|
24
|
+
authorId: string | null;
|
|
25
|
+
receivedAt: Date;
|
|
26
|
+
reason: DiscordEventDropReason;
|
|
27
|
+
filterName: DiscordEventFilterName | null;
|
|
28
|
+
}
|
|
29
|
+
export interface IReflexDiscordEventLogIntentsRefused {
|
|
30
|
+
since: Date;
|
|
31
|
+
privilegedIntents: number[];
|
|
32
|
+
}
|
|
33
|
+
export interface IReflexDiscordEventLogPage {
|
|
34
|
+
retained: IReflexDiscordEventLogRetained[];
|
|
35
|
+
dropped: IReflexDiscordEventLogDropped[];
|
|
36
|
+
intentsRefused: IReflexDiscordEventLogIntentsRefused | null;
|
|
37
|
+
nextCursor: string | null;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflex-discord-event-log.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/reflex-discord-event-log.model.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { DiscordEventType } from '../../enum';
|
|
2
|
+
export declare const REFLEX_DISCORD_EVENT_LIMITS: {
|
|
3
|
+
readonly namePattern: RegExp;
|
|
4
|
+
readonly nameMaxLength: 32;
|
|
5
|
+
readonly maxTriggersPerService: 25;
|
|
6
|
+
readonly guildIdsMax: 25;
|
|
7
|
+
readonly channelIdsMax: 50;
|
|
8
|
+
readonly roleIdsMax: 25;
|
|
9
|
+
readonly contentPrefixMaxLength: 32;
|
|
10
|
+
readonly payloadMaxLength: 8192;
|
|
11
|
+
readonly summaryMaxLength: 512;
|
|
12
|
+
readonly dropSamplesPerReason: 200;
|
|
13
|
+
readonly toleranceMinutes: 15;
|
|
14
|
+
};
|
|
15
|
+
export declare const REFLEX_BOT_EVENT_CAPACITY: {
|
|
16
|
+
readonly runsPerSlotPerMinute: 100;
|
|
17
|
+
readonly maxConcurrencyPerBot: 30;
|
|
18
|
+
readonly lotsMaxCeiling: 40;
|
|
19
|
+
readonly lotsMax: 40;
|
|
20
|
+
};
|
|
21
|
+
export interface IReflexDiscordEventFilters {
|
|
22
|
+
guildIds?: string[];
|
|
23
|
+
channelIds?: string[];
|
|
24
|
+
roleIds?: string[];
|
|
25
|
+
contentPrefix?: string;
|
|
26
|
+
ignoreBots?: boolean;
|
|
27
|
+
ignoreSelf?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface IReflexDiscordEvent {
|
|
30
|
+
id: string;
|
|
31
|
+
serviceId: string;
|
|
32
|
+
functionId: string;
|
|
33
|
+
name: string;
|
|
34
|
+
eventType: DiscordEventType;
|
|
35
|
+
filters: IReflexDiscordEventFilters;
|
|
36
|
+
ordered: boolean;
|
|
37
|
+
includeContent: boolean;
|
|
38
|
+
createdAt: Date;
|
|
39
|
+
updatedAt: Date;
|
|
40
|
+
}
|
|
41
|
+
export type IReflexDiscordEventSnapshot = Pick<IReflexDiscordEvent, 'id' | 'functionId' | 'name' | 'eventType' | 'filters' | 'ordered' | 'includeContent'>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REFLEX_BOT_EVENT_CAPACITY = exports.REFLEX_DISCORD_EVENT_LIMITS = void 0;
|
|
4
|
+
exports.REFLEX_DISCORD_EVENT_LIMITS = {
|
|
5
|
+
namePattern: /^[-_a-z0-9]{1,32}$/,
|
|
6
|
+
nameMaxLength: 32,
|
|
7
|
+
maxTriggersPerService: 25,
|
|
8
|
+
guildIdsMax: 25,
|
|
9
|
+
channelIdsMax: 50,
|
|
10
|
+
roleIdsMax: 25,
|
|
11
|
+
contentPrefixMaxLength: 32,
|
|
12
|
+
payloadMaxLength: 8192,
|
|
13
|
+
summaryMaxLength: 512,
|
|
14
|
+
dropSamplesPerReason: 200,
|
|
15
|
+
toleranceMinutes: 15,
|
|
16
|
+
};
|
|
17
|
+
exports.REFLEX_BOT_EVENT_CAPACITY = {
|
|
18
|
+
runsPerSlotPerMinute: 100,
|
|
19
|
+
maxConcurrencyPerBot: 30,
|
|
20
|
+
lotsMaxCeiling: 40,
|
|
21
|
+
lotsMax: 40,
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=reflex-discord-event.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflex-discord-event.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/reflex-discord-event.model.ts"],"names":[],"mappings":";;;AAGa,QAAA,2BAA2B,GAAG;IAEzC,WAAW,EAAE,oBAAoB;IACjC,aAAa,EAAE,EAAE;IACjB,qBAAqB,EAAE,EAAE;IACzB,WAAW,EAAE,EAAE;IACf,aAAa,EAAE,EAAE;IACjB,UAAU,EAAE,EAAE;IACd,sBAAsB,EAAE,EAAE;IAE1B,gBAAgB,EAAE,IAAI;IAEtB,gBAAgB,EAAE,GAAG;IAErB,oBAAoB,EAAE,GAAG;IAEzB,gBAAgB,EAAE,EAAE;CACZ,CAAC;AAOE,QAAA,yBAAyB,GAAG;IAEvC,oBAAoB,EAAE,GAAG;IAEzB,oBAAoB,EAAE,EAAE;IAExB,cAAc,EAAE,EAAE;IAElB,OAAO,EAAE,EAAE;CACH,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { InsightsPeriod } from '../../enum';
|
|
2
|
+
import type { TriggerKind } from '../../enum';
|
|
3
|
+
export declare const REFLEX_INSIGHTS_PERIOD_STEP_SECONDS: Record<InsightsPeriod, number>;
|
|
4
|
+
export declare const REFLEX_COST_HISTOGRAM_UPPER_BOUNDS: readonly [10, 25, 50, 100, 250, 500, 1000, 2500, 5000];
|
|
5
|
+
export declare const REFLEX_HEAVY_TRIGGER_FACTOR = 5;
|
|
6
|
+
export interface IReflexInsightsTile {
|
|
7
|
+
value: number;
|
|
8
|
+
previous: number | null;
|
|
9
|
+
}
|
|
10
|
+
export interface IReflexInsightsTiles {
|
|
11
|
+
runs: IReflexInsightsTile;
|
|
12
|
+
failed: IReflexInsightsTile;
|
|
13
|
+
cpuMs: IReflexInsightsTile;
|
|
14
|
+
heapPeakBytesMax: IReflexInsightsTile;
|
|
15
|
+
netBytes: IReflexInsightsTile;
|
|
16
|
+
costMillicredits: IReflexInsightsTile;
|
|
17
|
+
}
|
|
18
|
+
export interface IReflexInsightsPoint {
|
|
19
|
+
at: Date;
|
|
20
|
+
runs: number;
|
|
21
|
+
failed: number;
|
|
22
|
+
durationMsSum: number;
|
|
23
|
+
cpuMsSum: number;
|
|
24
|
+
netInBytes: number;
|
|
25
|
+
netOutBytes: number;
|
|
26
|
+
costMillicredits: number;
|
|
27
|
+
costMeanMillicredits: number | null;
|
|
28
|
+
costP95Millicredits: number | null;
|
|
29
|
+
}
|
|
30
|
+
export interface IReflexInsightsKindShare {
|
|
31
|
+
kind: TriggerKind;
|
|
32
|
+
runs: number;
|
|
33
|
+
failed: number;
|
|
34
|
+
}
|
|
35
|
+
export interface IReflexInsightsRankingRow {
|
|
36
|
+
kind: TriggerKind;
|
|
37
|
+
triggerId: string;
|
|
38
|
+
label: string | null;
|
|
39
|
+
runs: number;
|
|
40
|
+
failed: number;
|
|
41
|
+
costMillicreditsTotal: number;
|
|
42
|
+
costMillicreditsPerRun: number;
|
|
43
|
+
cpuMsMean: number;
|
|
44
|
+
durationMsMean: number;
|
|
45
|
+
heavy: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface IReflexInsights {
|
|
48
|
+
period: InsightsPeriod;
|
|
49
|
+
from: Date;
|
|
50
|
+
to: Date;
|
|
51
|
+
stepSeconds: number;
|
|
52
|
+
tiles: IReflexInsightsTiles;
|
|
53
|
+
series: IReflexInsightsPoint[];
|
|
54
|
+
byKind: IReflexInsightsKindShare[];
|
|
55
|
+
ranking: IReflexInsightsRankingRow[];
|
|
56
|
+
}
|
|
57
|
+
export interface IReflexEventInsightsPoint {
|
|
58
|
+
at: Date;
|
|
59
|
+
received: number;
|
|
60
|
+
queued: number;
|
|
61
|
+
executed: number;
|
|
62
|
+
failed: number;
|
|
63
|
+
duplicates: number;
|
|
64
|
+
filtered: number;
|
|
65
|
+
droppedRate: number;
|
|
66
|
+
droppedMonthlyCap: number;
|
|
67
|
+
droppedCredits: number;
|
|
68
|
+
expired: number;
|
|
69
|
+
filteredBy: Record<string, number>;
|
|
70
|
+
}
|
|
71
|
+
export interface IReflexEventInsights {
|
|
72
|
+
period: InsightsPeriod;
|
|
73
|
+
from: Date;
|
|
74
|
+
to: Date;
|
|
75
|
+
stepSeconds: number;
|
|
76
|
+
series: IReflexEventInsightsPoint[];
|
|
77
|
+
eventsPerMinute: number;
|
|
78
|
+
peakPerMinute: number;
|
|
79
|
+
minutesAtCap: number;
|
|
80
|
+
creditsMonthMillicredits: number;
|
|
81
|
+
spendCents: number;
|
|
82
|
+
monthlySpendCapCents: number;
|
|
83
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REFLEX_HEAVY_TRIGGER_FACTOR = exports.REFLEX_COST_HISTOGRAM_UPPER_BOUNDS = exports.REFLEX_INSIGHTS_PERIOD_STEP_SECONDS = void 0;
|
|
4
|
+
const enum_1 = require("../../enum");
|
|
5
|
+
exports.REFLEX_INSIGHTS_PERIOD_STEP_SECONDS = {
|
|
6
|
+
[enum_1.InsightsPeriod.HOUR_1]: 60,
|
|
7
|
+
[enum_1.InsightsPeriod.HOURS_24]: 300,
|
|
8
|
+
[enum_1.InsightsPeriod.DAYS_7]: 3600,
|
|
9
|
+
[enum_1.InsightsPeriod.DAYS_30]: 21600,
|
|
10
|
+
[enum_1.InsightsPeriod.DAYS_90]: 86400,
|
|
11
|
+
};
|
|
12
|
+
exports.REFLEX_COST_HISTOGRAM_UPPER_BOUNDS = [
|
|
13
|
+
10, 25, 50, 100, 250, 500, 1000, 2500, 5000,
|
|
14
|
+
];
|
|
15
|
+
exports.REFLEX_HEAVY_TRIGGER_FACTOR = 5;
|
|
16
|
+
//# sourceMappingURL=reflex-insights.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflex-insights.model.js","sourceRoot":"","sources":["../../../../src/types/interface/models/reflex-insights.model.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAI/B,QAAA,mCAAmC,GAAmC;IACjF,CAAC,qBAAc,CAAC,MAAM,CAAC,EAAE,EAAE;IAC3B,CAAC,qBAAc,CAAC,QAAQ,CAAC,EAAE,GAAG;IAC9B,CAAC,qBAAc,CAAC,MAAM,CAAC,EAAE,IAAI;IAC7B,CAAC,qBAAc,CAAC,OAAO,CAAC,EAAE,KAAK;IAC/B,CAAC,qBAAc,CAAC,OAAO,CAAC,EAAE,KAAK;CAChC,CAAC;AAGW,QAAA,kCAAkC,GAAG;IAChD,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;CACnC,CAAC;AAGE,QAAA,2BAA2B,GAAG,CAAC,CAAC"}
|
|
@@ -42,6 +42,8 @@ export interface IReflexRun {
|
|
|
42
42
|
commandId: string | null;
|
|
43
43
|
componentId: string | null;
|
|
44
44
|
taskId: string | null;
|
|
45
|
+
eventTriggerId: string | null;
|
|
46
|
+
traceId: string | null;
|
|
45
47
|
scheduledRunOrigin: ScheduledRunOrigin | null;
|
|
46
48
|
originLabel: string | null;
|
|
47
49
|
httpStatus: number | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RouteMethod, TriggerAccessMode } from '../../enum';
|
|
2
2
|
import type { IReflexDiscordCommandSnapshot, IReflexDiscordComponentSnapshot } from './reflex-discord.model';
|
|
3
|
+
import type { IReflexDiscordEventSnapshot } from './reflex-discord-event.model';
|
|
3
4
|
import type { IReflexServiceCors } from './reflex-service.model';
|
|
4
5
|
import type { IReflexTaskSnapshot } from './reflex-task.model';
|
|
5
6
|
export interface IReflexServiceVersionRoute {
|
|
@@ -17,6 +18,7 @@ export interface IReflexServiceVersionFunction {
|
|
|
17
18
|
export interface IReflexServiceVersionDiscord {
|
|
18
19
|
commands: IReflexDiscordCommandSnapshot[];
|
|
19
20
|
components: IReflexDiscordComponentSnapshot[];
|
|
21
|
+
events?: IReflexDiscordEventSnapshot[];
|
|
20
22
|
}
|
|
21
23
|
export interface IReflexServiceVersionSnapshot {
|
|
22
24
|
routes: IReflexServiceVersionRoute[];
|
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
+
import { AbyssReflexCore, InsightsPeriod } from '..';
|
|
3
|
+
|
|
4
|
+
describe('AbyssReflexCore function insights route', () => {
|
|
5
|
+
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
6
|
+
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
beforeAll(() => {
|
|
10
|
+
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
11
|
+
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
beforeEach(() => adapter.mockClear());
|
|
15
|
+
|
|
16
|
+
it('insights.get calls GET /api/function/:applicationId/:functionId/insights', async () => {
|
|
17
|
+
await AbyssReflexCore.sdk.function.insights.get(
|
|
18
|
+
{ applicationId: 'app-1', functionId: 'fn-1' },
|
|
19
|
+
{ environmentId: 'e-1', period: InsightsPeriod.HOURS_24 },
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const config = adapter.mock.calls[0][0];
|
|
23
|
+
expect(config.method).toBe('get');
|
|
24
|
+
expect(config.url).toBe('api/function/app-1/fn-1/insights');
|
|
25
|
+
expect(config.params).toEqual({ environmentId: 'e-1', period: '24h' });
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AbyssReflexCore } from '..';
|
|
2
|
+
import type {
|
|
3
|
+
IGetFunctionInsightsParams,
|
|
4
|
+
IGetFunctionInsightsQuery,
|
|
5
|
+
IGetFunctionInsightsResponse,
|
|
6
|
+
} from '../types';
|
|
7
|
+
|
|
8
|
+
/** `GET .../function/:applicationId/:functionId/insights`: the dashboard of a function, same shape as a Service's. Needs REFLEX_LOG_READ. */
|
|
9
|
+
export const getFunctionInsights = async (
|
|
10
|
+
params: IGetFunctionInsightsParams,
|
|
11
|
+
query: IGetFunctionInsightsQuery,
|
|
12
|
+
): Promise<IGetFunctionInsightsResponse> =>
|
|
13
|
+
(
|
|
14
|
+
await AbyssReflexCore.axios.get<IGetFunctionInsightsResponse>(
|
|
15
|
+
`api/function/${params.applicationId}/${params.functionId}/insights`,
|
|
16
|
+
{ params: query },
|
|
17
|
+
)
|
|
18
|
+
).data;
|
package/src/api/index.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
export * from './health.api';
|
|
2
|
-
export * from './function.api';
|
|
3
|
-
export * from './function-access.api';
|
|
4
|
-
export * from './function-test.api';
|
|
5
|
-
export * from './function-version.api';
|
|
6
|
-
export * from './function-run.api';
|
|
7
|
-
export * from './function-settings.api';
|
|
8
|
-
export * from './service.api';
|
|
9
|
-
export * from './service-route.api';
|
|
10
|
-
export * from './service-version.api';
|
|
11
|
-
export * from './service-deployment.api';
|
|
12
|
-
export * from './service-configuration.api';
|
|
13
|
-
export * from './service-discord.api';
|
|
14
|
-
export * from './service-
|
|
1
|
+
export * from './health.api';
|
|
2
|
+
export * from './function.api';
|
|
3
|
+
export * from './function-access.api';
|
|
4
|
+
export * from './function-test.api';
|
|
5
|
+
export * from './function-version.api';
|
|
6
|
+
export * from './function-run.api';
|
|
7
|
+
export * from './function-settings.api';
|
|
8
|
+
export * from './service.api';
|
|
9
|
+
export * from './service-route.api';
|
|
10
|
+
export * from './service-version.api';
|
|
11
|
+
export * from './service-deployment.api';
|
|
12
|
+
export * from './service-configuration.api';
|
|
13
|
+
export * from './service-discord.api';
|
|
14
|
+
export * from './service-discord-event.api';
|
|
15
|
+
export * from './service-insights.api';
|
|
16
|
+
export * from './function-insights.api';
|
|
17
|
+
export * from './service-task.api';
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { AxiosAdapter, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
+
import { AbyssReflexCore, DiscordEventDropReason, DiscordEventStatus, DiscordEventType } from '..';
|
|
3
|
+
|
|
4
|
+
const APP = 'app-1';
|
|
5
|
+
const SVC = 'svc-1';
|
|
6
|
+
const BASE = `api/service/${APP}/${SVC}`;
|
|
7
|
+
const SERVICE = { applicationId: APP, serviceId: SVC };
|
|
8
|
+
|
|
9
|
+
interface Call {
|
|
10
|
+
label: string;
|
|
11
|
+
method: string;
|
|
12
|
+
url: string;
|
|
13
|
+
body?: unknown;
|
|
14
|
+
query?: unknown;
|
|
15
|
+
run: () => Promise<unknown>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const discord = () => AbyssReflexCore.sdk.service.discord;
|
|
19
|
+
|
|
20
|
+
const event = {
|
|
21
|
+
name: 'welcome',
|
|
22
|
+
eventType: DiscordEventType.GUILD_MEMBER_ADD,
|
|
23
|
+
functionId: 'fn-1',
|
|
24
|
+
filters: { guildIds: ['123456789012345678'], ignoreBots: true },
|
|
25
|
+
ordered: true,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const logQuery = {
|
|
29
|
+
environmentId: 'e-1',
|
|
30
|
+
status: DiscordEventStatus.DONE,
|
|
31
|
+
reason: DiscordEventDropReason.RATE,
|
|
32
|
+
type: DiscordEventType.MESSAGE_CREATE,
|
|
33
|
+
triggerId: 't-1',
|
|
34
|
+
from: '2026-11-20T00:00:00.000Z',
|
|
35
|
+
to: '2026-11-21T00:00:00.000Z',
|
|
36
|
+
cursor: 'c-1',
|
|
37
|
+
limit: 20,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const calls: Call[] = [
|
|
41
|
+
{
|
|
42
|
+
label: 'event.list',
|
|
43
|
+
method: 'get',
|
|
44
|
+
url: `${BASE}/discord-event`,
|
|
45
|
+
run: () => discord().event.list(SERVICE),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: 'event.create',
|
|
49
|
+
method: 'post',
|
|
50
|
+
url: `${BASE}/discord-event`,
|
|
51
|
+
body: event,
|
|
52
|
+
run: () => discord().event.create(SERVICE, event),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: 'event.update',
|
|
56
|
+
method: 'patch',
|
|
57
|
+
url: `${BASE}/discord-event/ev-1`,
|
|
58
|
+
body: { ordered: false },
|
|
59
|
+
run: () => discord().event.update({ ...SERVICE, eventId: 'ev-1' }, { ordered: false }),
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: 'event.delete',
|
|
63
|
+
method: 'delete',
|
|
64
|
+
url: `${BASE}/discord-event/ev-1`,
|
|
65
|
+
run: () => discord().event.delete({ ...SERVICE, eventId: 'ev-1' }),
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
label: 'eventLog.list',
|
|
69
|
+
method: 'get',
|
|
70
|
+
url: `${BASE}/discord-event-log`,
|
|
71
|
+
query: logQuery,
|
|
72
|
+
run: () => discord().eventLog.list(SERVICE, logQuery),
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
describe('AbyssReflexCore Discord event routes', () => {
|
|
77
|
+
const adapter = jest.fn<ReturnType<AxiosAdapter>, [InternalAxiosRequestConfig]>(
|
|
78
|
+
async (config) => ({ data: { data: {} }, status: 200, statusText: '', headers: {}, config }),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
beforeAll(() => {
|
|
82
|
+
AbyssReflexCore.setConfig({ baseURL: 'http://reflex.test/', token: 'session-token' });
|
|
83
|
+
AbyssReflexCore.axios.defaults.adapter = adapter;
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
beforeEach(() => adapter.mockClear());
|
|
87
|
+
|
|
88
|
+
it.each(calls)('$label calls $method $url', async (call) => {
|
|
89
|
+
await call.run();
|
|
90
|
+
|
|
91
|
+
const config = adapter.mock.calls[0][0];
|
|
92
|
+
expect(config.method).toBe(call.method);
|
|
93
|
+
expect(config.url).toBe(call.url);
|
|
94
|
+
expect(config.baseURL).toBe('http://reflex.test/');
|
|
95
|
+
if (call.body !== undefined) {
|
|
96
|
+
expect(JSON.parse(config.data)).toEqual(call.body);
|
|
97
|
+
}
|
|
98
|
+
if (call.query !== undefined) {
|
|
99
|
+
expect(config.params).toEqual(call.query);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('exposes no route twice', () => {
|
|
104
|
+
expect(new Set(calls.map((call) => `${call.method} ${call.url}`)).size).toBe(calls.length);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { AbyssReflexCore } from '..';
|
|
2
|
+
import type {
|
|
3
|
+
ICreateServiceDiscordEventBody,
|
|
4
|
+
ICreateServiceDiscordEventParams,
|
|
5
|
+
ICreateServiceDiscordEventResponse,
|
|
6
|
+
IDeleteServiceDiscordEventParams,
|
|
7
|
+
IDeleteServiceDiscordEventResponse,
|
|
8
|
+
IListServiceDiscordEventLogParams,
|
|
9
|
+
IListServiceDiscordEventLogQuery,
|
|
10
|
+
IListServiceDiscordEventLogResponse,
|
|
11
|
+
IListServiceDiscordEventParams,
|
|
12
|
+
IListServiceDiscordEventResponse,
|
|
13
|
+
IUpdateServiceDiscordEventBody,
|
|
14
|
+
IUpdateServiceDiscordEventParams,
|
|
15
|
+
IUpdateServiceDiscordEventResponse,
|
|
16
|
+
} from '../types';
|
|
17
|
+
|
|
18
|
+
const serviceUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
19
|
+
`api/service/${params.applicationId}/${params.serviceId}`;
|
|
20
|
+
|
|
21
|
+
const eventUrl = (params: { applicationId: string; serviceId: string }): string =>
|
|
22
|
+
`${serviceUrl(params)}/discord-event`;
|
|
23
|
+
|
|
24
|
+
/** `GET .../discord-event`: the event triggers of the draft of a Discord bot, by name. Needs REFLEX_READ. */
|
|
25
|
+
export const listServiceDiscordEvent = async (
|
|
26
|
+
params: IListServiceDiscordEventParams,
|
|
27
|
+
): Promise<IListServiceDiscordEventResponse> =>
|
|
28
|
+
(await AbyssReflexCore.axios.get<IListServiceDiscordEventResponse>(eventUrl(params))).data;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* `POST .../discord-event`: an event trigger of the draft (25 at most per Service), live once a version
|
|
32
|
+
* holding it is in service. `409 DISCORD_EVENT_CONFLICT` when the name is taken. Needs
|
|
33
|
+
* REFLEX_FUNCTION_UPDATE.
|
|
34
|
+
*/
|
|
35
|
+
export const createServiceDiscordEvent = async (
|
|
36
|
+
params: ICreateServiceDiscordEventParams,
|
|
37
|
+
body: ICreateServiceDiscordEventBody,
|
|
38
|
+
): Promise<ICreateServiceDiscordEventResponse> =>
|
|
39
|
+
(await AbyssReflexCore.axios.post<ICreateServiceDiscordEventResponse>(eventUrl(params), body))
|
|
40
|
+
.data;
|
|
41
|
+
|
|
42
|
+
/** `PATCH .../discord-event/:eventId`: changes the trigger in the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
43
|
+
export const updateServiceDiscordEvent = async (
|
|
44
|
+
params: IUpdateServiceDiscordEventParams,
|
|
45
|
+
body: IUpdateServiceDiscordEventBody,
|
|
46
|
+
): Promise<IUpdateServiceDiscordEventResponse> =>
|
|
47
|
+
(
|
|
48
|
+
await AbyssReflexCore.axios.patch<IUpdateServiceDiscordEventResponse>(
|
|
49
|
+
`${eventUrl(params)}/${params.eventId}`,
|
|
50
|
+
body,
|
|
51
|
+
)
|
|
52
|
+
).data;
|
|
53
|
+
|
|
54
|
+
/** `DELETE .../discord-event/:eventId`: takes the trigger out of the draft. Needs REFLEX_FUNCTION_UPDATE. */
|
|
55
|
+
export const deleteServiceDiscordEvent = async (
|
|
56
|
+
params: IDeleteServiceDiscordEventParams,
|
|
57
|
+
): Promise<IDeleteServiceDiscordEventResponse> =>
|
|
58
|
+
(
|
|
59
|
+
await AbyssReflexCore.axios.delete<IDeleteServiceDiscordEventResponse>(
|
|
60
|
+
`${eventUrl(params)}/${params.eventId}`,
|
|
61
|
+
)
|
|
62
|
+
).data;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* `GET .../discord-event-log`: the events of the bot in one environment, newest first, paged by cursor: the
|
|
66
|
+
* retained ones (inbox) and a sample of the dropped ones with their reason. Carries `intentsRefused` instead
|
|
67
|
+
* of events while Discord refuses the intents. Needs REFLEX_LOG_READ.
|
|
68
|
+
*/
|
|
69
|
+
export const listServiceDiscordEventLog = async (
|
|
70
|
+
params: IListServiceDiscordEventLogParams,
|
|
71
|
+
query: IListServiceDiscordEventLogQuery,
|
|
72
|
+
): Promise<IListServiceDiscordEventLogResponse> =>
|
|
73
|
+
(
|
|
74
|
+
await AbyssReflexCore.axios.get<IListServiceDiscordEventLogResponse>(
|
|
75
|
+
`${serviceUrl(params)}/discord-event-log`,
|
|
76
|
+
{ params: query },
|
|
77
|
+
)
|
|
78
|
+
).data;
|