@abyss-project/reflex 5.7.0 → 5.8.1

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 (158) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/README.md +15 -15
  4. package/dist/types/enum/discord-channel-type.enum.d.ts +7 -0
  5. package/dist/types/enum/discord-channel-type.enum.js +12 -0
  6. package/dist/types/enum/discord-channel-type.enum.js.map +1 -0
  7. package/dist/types/enum/discord-host-action.enum.d.ts +31 -0
  8. package/dist/types/enum/discord-host-action.enum.js +36 -0
  9. package/dist/types/enum/discord-host-action.enum.js.map +1 -0
  10. package/dist/types/enum/discord-locale.enum.d.ts +34 -0
  11. package/dist/types/enum/discord-locale.enum.js +39 -0
  12. package/dist/types/enum/discord-locale.enum.js.map +1 -0
  13. package/dist/types/enum/index.d.ts +3 -0
  14. package/dist/types/enum/index.js +3 -0
  15. package/dist/types/enum/index.js.map +1 -1
  16. package/dist/types/interface/api/requests/service-discord.request.d.ts +7 -1
  17. package/dist/types/interface/models/reflex-discord-event.model.js.map +1 -1
  18. package/dist/types/interface/models/reflex-discord.model.d.ts +22 -2
  19. package/dist/types/interface/models/reflex-discord.model.js +6 -1
  20. package/dist/types/interface/models/reflex-discord.model.js.map +1 -1
  21. package/jest.config.ts +11 -11
  22. package/package.json +1 -1
  23. package/src/api/function-access.api.ts +36 -36
  24. package/src/api/function-insights.api.test.ts +27 -27
  25. package/src/api/function-insights.api.ts +18 -18
  26. package/src/api/function-run.api.ts +38 -38
  27. package/src/api/function-settings.api.ts +59 -59
  28. package/src/api/function-test.api.ts +34 -34
  29. package/src/api/function-version.api.ts +48 -48
  30. package/src/api/function.api.test.ts +249 -249
  31. package/src/api/function.api.ts +62 -62
  32. package/src/api/health.api.ts +10 -10
  33. package/src/api/index.ts +17 -17
  34. package/src/api/service-configuration.api.ts +16 -16
  35. package/src/api/service-deployment.api.ts +79 -79
  36. package/src/api/service-discord-event.api.test.ts +106 -106
  37. package/src/api/service-discord-event.api.ts +78 -78
  38. package/src/api/service-discord.api.test.ts +197 -197
  39. package/src/api/service-discord.api.ts +241 -241
  40. package/src/api/service-insights.api.test.ts +36 -36
  41. package/src/api/service-insights.api.ts +42 -42
  42. package/src/api/service-route.api.ts +72 -72
  43. package/src/api/service-task.api.test.ts +140 -140
  44. package/src/api/service-task.api.ts +141 -141
  45. package/src/api/service-version.api.ts +54 -54
  46. package/src/api/service.api.test.ts +215 -215
  47. package/src/api/service.api.ts +55 -55
  48. package/src/discord/discord-event-filter-cases.ts +261 -261
  49. package/src/discord/discord-event-filters.test.ts +91 -91
  50. package/src/discord/discord-event-filters.ts +95 -95
  51. package/src/discord/discord-event-intents.test.ts +112 -112
  52. package/src/discord/discord-event-intents.ts +55 -55
  53. package/src/discord/index.ts +3 -3
  54. package/src/index.test.ts +75 -75
  55. package/src/index.ts +317 -317
  56. package/src/types/enum/access-grant-status.enum.ts +12 -12
  57. package/src/types/enum/access-kind.enum.ts +7 -7
  58. package/src/types/enum/bot-event-block-reason.enum.ts +7 -7
  59. package/src/types/enum/configuration-read-as.enum.ts +5 -5
  60. package/src/types/enum/discord-activity-type.enum.ts +9 -9
  61. package/src/types/enum/discord-channel-type.enum.ts +11 -0
  62. package/src/types/enum/discord-component-kind.enum.ts +7 -7
  63. package/src/types/enum/discord-event-drop-reason.enum.ts +13 -13
  64. package/src/types/enum/discord-event-filter-name.enum.ts +11 -11
  65. package/src/types/enum/discord-event-status.enum.ts +13 -13
  66. package/src/types/enum/discord-event-type.enum.ts +7 -7
  67. package/src/types/enum/discord-gateway-failure-code.enum.ts +11 -11
  68. package/src/types/enum/discord-gateway-state.enum.ts +11 -11
  69. package/src/types/enum/discord-host-action.enum.ts +35 -0
  70. package/src/types/enum/discord-locale.enum.ts +35 -0
  71. package/src/types/enum/discord-option-type.enum.ts +12 -12
  72. package/src/types/enum/discord-presence-status.enum.ts +8 -8
  73. package/src/types/enum/discord-sync-status.enum.ts +6 -6
  74. package/src/types/enum/discord-token-state.enum.ts +11 -11
  75. package/src/types/enum/execution-mode.enum.ts +9 -9
  76. package/src/types/enum/execution-profile.enum.ts +20 -20
  77. package/src/types/enum/execution-settings-source.enum.ts +9 -9
  78. package/src/types/enum/health-status.enum.ts +4 -4
  79. package/src/types/enum/index.ts +43 -40
  80. package/src/types/enum/insights-period.enum.ts +8 -8
  81. package/src/types/enum/reflex-error-code.enum.ts +43 -43
  82. package/src/types/enum/route-method.enum.ts +9 -9
  83. package/src/types/enum/run-log-level.enum.ts +6 -6
  84. package/src/types/enum/run-mode.enum.ts +11 -11
  85. package/src/types/enum/run-status.enum.ts +11 -11
  86. package/src/types/enum/run-step-status.enum.ts +7 -7
  87. package/src/types/enum/schedule-sync-status.enum.ts +6 -6
  88. package/src/types/enum/scheduled-run-failure-code.enum.ts +12 -12
  89. package/src/types/enum/scheduled-run-origin.enum.ts +5 -5
  90. package/src/types/enum/scheduled-run-status.enum.ts +17 -17
  91. package/src/types/enum/service-deployment-action.enum.ts +11 -11
  92. package/src/types/enum/service-deployment-status.enum.ts +5 -5
  93. package/src/types/enum/service-type.enum.ts +9 -9
  94. package/src/types/enum/service-version-change-kind.enum.ts +6 -6
  95. package/src/types/enum/trace-effect-type.enum.ts +12 -12
  96. package/src/types/enum/trigger-access-mode.enum.ts +12 -12
  97. package/src/types/enum/trigger-kind.enum.ts +8 -8
  98. package/src/types/enum/vault-value-source.enum.ts +12 -12
  99. package/src/types/enum/vault-visibility.enum.ts +5 -5
  100. package/src/types/index.ts +2 -2
  101. package/src/types/interface/api/index.ts +3 -3
  102. package/src/types/interface/api/requests/function-access.request.ts +25 -25
  103. package/src/types/interface/api/requests/function-run.request.ts +30 -30
  104. package/src/types/interface/api/requests/function-settings.request.ts +27 -27
  105. package/src/types/interface/api/requests/function-test.request.ts +39 -39
  106. package/src/types/interface/api/requests/function-version.request.ts +20 -20
  107. package/src/types/interface/api/requests/function.request.ts +36 -36
  108. package/src/types/interface/api/requests/index.ts +15 -15
  109. package/src/types/interface/api/requests/service-configuration.request.ts +4 -4
  110. package/src/types/interface/api/requests/service-deployment.request.ts +49 -49
  111. package/src/types/interface/api/requests/service-discord-event.request.ts +68 -68
  112. package/src/types/interface/api/requests/service-discord.request.ts +173 -161
  113. package/src/types/interface/api/requests/service-insights.request.ts +31 -31
  114. package/src/types/interface/api/requests/service-route.request.ts +44 -44
  115. package/src/types/interface/api/requests/service-task.request.ts +80 -80
  116. package/src/types/interface/api/requests/service-version.request.ts +24 -24
  117. package/src/types/interface/api/requests/service.request.ts +46 -46
  118. package/src/types/interface/api/response.ts +4 -4
  119. package/src/types/interface/api/responses/function-access.response.ts +17 -17
  120. package/src/types/interface/api/responses/function-run.response.ts +18 -18
  121. package/src/types/interface/api/responses/function-settings.response.ts +36 -36
  122. package/src/types/interface/api/responses/function-test.response.ts +12 -12
  123. package/src/types/interface/api/responses/function-version.response.ts +31 -31
  124. package/src/types/interface/api/responses/function.response.ts +25 -25
  125. package/src/types/interface/api/responses/index.ts +15 -15
  126. package/src/types/interface/api/responses/service-configuration.response.ts +8 -8
  127. package/src/types/interface/api/responses/service-deployment.response.ts +32 -32
  128. package/src/types/interface/api/responses/service-discord-event.response.ts +24 -24
  129. package/src/types/interface/api/responses/service-discord.response.ts +122 -122
  130. package/src/types/interface/api/responses/service-insights.response.ts +11 -11
  131. package/src/types/interface/api/responses/service-route.response.ts +31 -31
  132. package/src/types/interface/api/responses/service-task.response.ts +57 -57
  133. package/src/types/interface/api/responses/service-version.response.ts +106 -106
  134. package/src/types/interface/api/responses/service.response.ts +31 -31
  135. package/src/types/interface/health.response.ts +7 -7
  136. package/src/types/interface/index.ts +3 -3
  137. package/src/types/interface/models/index.ts +19 -19
  138. package/src/types/interface/models/reflex-access-grant.model.ts +14 -14
  139. package/src/types/interface/models/reflex-bot-limits.model.ts +92 -92
  140. package/src/types/interface/models/reflex-definition.model.ts +31 -31
  141. package/src/types/interface/models/reflex-discord-event-log.model.ts +58 -58
  142. package/src/types/interface/models/reflex-discord-event.model.ts +79 -78
  143. package/src/types/interface/models/reflex-discord.model.ts +54 -4
  144. package/src/types/interface/models/reflex-execution-settings.model.ts +50 -50
  145. package/src/types/interface/models/reflex-function-version.model.ts +14 -14
  146. package/src/types/interface/models/reflex-function.model.ts +16 -16
  147. package/src/types/interface/models/reflex-insights.model.ts +120 -120
  148. package/src/types/interface/models/reflex-price-list.model.ts +20 -20
  149. package/src/types/interface/models/reflex-route.model.ts +19 -19
  150. package/src/types/interface/models/reflex-run.model.ts +186 -186
  151. package/src/types/interface/models/reflex-service-configuration.model.ts +22 -22
  152. package/src/types/interface/models/reflex-service-deployment.model.ts +46 -46
  153. package/src/types/interface/models/reflex-service-version.model.ts +61 -61
  154. package/src/types/interface/models/reflex-service.model.ts +45 -45
  155. package/src/types/interface/models/reflex-step-stats.model.ts +35 -35
  156. package/src/types/interface/models/reflex-task.model.ts +97 -97
  157. package/tsconfig.check.json +15 -15
  158. package/tsconfig.json +35 -35
@@ -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,78 +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-0302). 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), not by its slots. `lotsMax` is
27
- * `min(lotsMaxCeiling, floor((maxConcurrencyPerBot * runsPerSlotPerMinute - base) / 500))` for the largest base.
28
- */
29
- export const REFLEX_BOT_EVENT_CAPACITY = {
30
- /** Events per minute one execution slot sustains: the measured 3 000 per bot spread over its 30 slots. */
31
- runsPerSlotPerMinute: 100,
32
- /** `maxReplicas` (3) times the ceiling per pod (10) of the edge fleet. */
33
- maxConcurrencyPerBot: 30,
34
- /** The most lots of 500 events per minute a bot can be allocated, whatever the measure says. */
35
- lotsMaxCeiling: 40,
36
- /** The most lots a bot can be allocated: floor((30 × 100 − 500) / 500) = 5. */
37
- lotsMax: 5,
38
- } as const;
39
-
40
- /** Optional filters of a trigger, combined with AND. An absent or empty list is no filter. */
41
- export interface IReflexDiscordEventFilters {
42
- /** 25 at most, every type. */
43
- guildIds?: string[];
44
- /** 50 at most, message and reaction. */
45
- channelIds?: string[];
46
- /** 25 at most, member arrival, message and reaction: the member has one of these roles. */
47
- roleIds?: string[];
48
- /** 32 characters at most, message: the content starts with it; needs the MESSAGE_CONTENT intent. */
49
- contentPrefix?: string;
50
- /** True when absent: an author or member that is a bot is ignored. */
51
- ignoreBots?: boolean;
52
- /** True when absent, message and reaction: the bot itself is ignored. */
53
- ignoreSelf?: boolean;
54
- }
55
-
56
- /** A Discord event trigger of the draft of a bot Service: a named target of one event type. */
57
- export interface IReflexDiscordEvent {
58
- id: string;
59
- serviceId: string;
60
- /** A function of the same Service. */
61
- functionId: string;
62
- /** Unique within the Service. */
63
- name: string;
64
- eventType: DiscordEventType;
65
- filters: IReflexDiscordEventFilters;
66
- /** True by default: events of one channel (or one server for member events) run one after the other. */
67
- ordered: boolean;
68
- /** False by default, MESSAGE_CREATE only: the function receives the message content. */
69
- includeContent: boolean;
70
- createdAt: Date;
71
- updatedAt: Date;
72
- }
73
-
74
- /** A Discord event trigger as a version of the Service froze it. */
75
- export type IReflexDiscordEventSnapshot = Pick<
76
- IReflexDiscordEvent,
77
- 'id' | 'functionId' | 'name' | 'eventType' | 'filters' | 'ordered' | 'includeContent'
78
- >;
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,6 +1,8 @@
1
1
  import type {
2
2
  DiscordActivityType,
3
+ DiscordChannelType,
3
4
  DiscordComponentKind,
5
+ DiscordLocale,
4
6
  DiscordGatewayFailureCode,
5
7
  DiscordGatewayState,
6
8
  DiscordOptionType,
@@ -12,6 +14,11 @@ import type {
12
14
  export const REFLEX_DISCORD_LIMITS = {
13
15
  /** `^[-_a-z0-9]{1,32}$`: the name typed after the slash. */
14
16
  commandNamePattern: /^[-_a-z0-9]{1,32}$/,
17
+ /**
18
+ * Discord's pattern of a translated command or option name: letters and digits of any script, `-`, `_` and
19
+ * `'`, 1 to 32 characters. It must also be lower case where the script has one (see `isValidLocalizedName`).
20
+ */
21
+ localizedNamePattern: /^[-_'\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$/u,
15
22
  commandDescriptionMaxLength: 100,
16
23
  commandsPerServiceMax: 100,
17
24
  optionsPerCommandMax: 25,
@@ -19,15 +26,33 @@ export const REFLEX_DISCORD_LIMITS = {
19
26
  /** `^[a-z0-9_-]{1,40}$`: the start of the `custom_id` of a button, a menu or a form. */
20
27
  componentPrefixPattern: /^[a-z0-9_-]{1,40}$/,
21
28
  syncErrorMaxLength: 500,
29
+ /** Bounds of `minLength` and `maxLength` of a STRING option (`maxLength` is 1 at least). */
30
+ optionLengthMax: 6000,
31
+ /** Length of the name of a choice, localized or not. */
32
+ choiceNameMaxLength: 100,
22
33
  } as const;
23
34
 
35
+ /** A translated command or option name Discord accepts: its pattern, and lower case where the script has one. */
36
+ export const isValidLocalizedName = (name: string): boolean =>
37
+ REFLEX_DISCORD_LIMITS.localizedNamePattern.test(name) && name === name.toLowerCase();
38
+
39
+ /**
40
+ * Translations of a name or a description, by Discord locale. A localized command or option name
41
+ * passes `isValidLocalizedName`, a description 1 to 100 characters, a choice name 1 to 100.
42
+ */
43
+ export type ReflexDiscordLocalizations = Partial<Record<DiscordLocale, string>>;
44
+
24
45
  /** A fixed answer a user picks for a STRING, INTEGER or NUMBER option. */
25
46
  export interface IReflexDiscordOptionChoice {
26
47
  name: string;
27
48
  value: string | number;
49
+ nameLocalizations?: ReflexDiscordLocalizations;
28
50
  }
29
51
 
30
- /** An option of a command. Required options come first. */
52
+ /**
53
+ * An option of a command. Required options come first. A bound only exists on the types it applies
54
+ * to: the API refuses it on another one.
55
+ */
31
56
  export interface IReflexDiscordCommandOption {
32
57
  type: DiscordOptionType;
33
58
  /** Same pattern as the command name. */
@@ -35,8 +60,18 @@ export interface IReflexDiscordCommandOption {
35
60
  /** 1 to 100 characters. */
36
61
  description: string;
37
62
  required: boolean;
38
- /** 25 at most, only for STRING, INTEGER and NUMBER. */
63
+ /** 25 at most, only for STRING, INTEGER and NUMBER; within `minValue`/`maxValue` and `minLength`/`maxLength`. */
39
64
  choices?: IReflexDiscordOptionChoice[];
65
+ /** INTEGER and NUMBER: safe numbers, `minValue` <= `maxValue`. */
66
+ minValue?: number;
67
+ maxValue?: number;
68
+ /** STRING: 0 to 6000 (`maxLength` 1 at least), `minLength` <= `maxLength`. */
69
+ minLength?: number;
70
+ maxLength?: number;
71
+ /** CHANNEL: the channel types a user may pick, not empty, no duplicate. */
72
+ channelTypes?: DiscordChannelType[];
73
+ nameLocalizations?: ReflexDiscordLocalizations;
74
+ descriptionLocalizations?: ReflexDiscordLocalizations;
40
75
  }
41
76
 
42
77
  /** A slash command of the draft of a Discord bot Service. */
@@ -52,6 +87,14 @@ export interface IReflexDiscordCommand {
52
87
  /** Discord permission bits as a decimal string, or null for everyone. */
53
88
  defaultMemberPermissions: string | null;
54
89
  allowedInDirectMessages: boolean;
90
+ /** Null without translations. */
91
+ nameLocalizations: ReflexDiscordLocalizations | null;
92
+ descriptionLocalizations: ReflexDiscordLocalizations | null;
93
+ /**
94
+ * Users may install the bot on their account and use the command outside the servers it is in (in
95
+ * group messages too). It can then act on no server in the bot's name.
96
+ */
97
+ userInstallable: boolean;
55
98
  createdAt: Date;
56
99
  updatedAt: Date;
57
100
  }
@@ -69,7 +112,10 @@ export interface IReflexDiscordComponent {
69
112
  updatedAt: Date;
70
113
  }
71
114
 
72
- /** A command as a version of the Service froze it. */
115
+ /**
116
+ * A command as a version of the Service froze it. The fields of card 846 are only there when set (a
117
+ * translation, `userInstallable` true): a command without them keeps the fingerprint it had.
118
+ */
73
119
  export type IReflexDiscordCommandSnapshot = Pick<
74
120
  IReflexDiscordCommand,
75
121
  | 'id'
@@ -79,7 +125,11 @@ export type IReflexDiscordCommandSnapshot = Pick<
79
125
  | 'options'
80
126
  | 'defaultMemberPermissions'
81
127
  | 'allowedInDirectMessages'
82
- >;
128
+ > & {
129
+ nameLocalizations?: ReflexDiscordLocalizations;
130
+ descriptionLocalizations?: ReflexDiscordLocalizations;
131
+ userInstallable?: true;
132
+ };
83
133
 
84
134
  /** A component as a version of the Service froze it. */
85
135
  export type IReflexDiscordComponentSnapshot = Pick<
@@ -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
+ }