@abyss-project/runtime 3.4.0 → 3.6.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/.eslintrc.js +32 -32
- package/.prettierrc +5 -5
- package/dist/discord/discord.types.d.ts +167 -4
- package/dist/discord/discord.types.js +48 -1
- package/dist/discord/discord.types.js.map +1 -1
- package/dist/engine/engine-source.js +1 -1
- package/dist/interpreter/interpreter.js +18 -4
- package/dist/interpreter/interpreter.js.map +1 -1
- package/dist/interpreter/interpreter.types.d.ts +2 -0
- package/dist/interpreter/interpreter.types.js.map +1 -1
- package/dist/runner-protocol/execution-protocol.types.d.ts +11 -0
- package/dist/runner-protocol/execution-protocol.types.js +2 -1
- package/dist/runner-protocol/execution-protocol.types.js.map +1 -1
- package/jest.config.ts +11 -11
- package/package.json +15 -10
- package/scripts/build-engine.cjs +70 -70
- package/src/__tests__/engine-bundle.test.ts +121 -121
- package/src/__tests__/surface.test.ts +5 -1
- package/src/access/__tests__/host-match.test.ts +24 -24
- package/src/access/access.types.ts +25 -25
- package/src/access/host-match.ts +13 -13
- package/src/cost/__tests__/execution-cost.test.ts +196 -196
- package/src/cost/execution-cost.ts +186 -186
- package/src/definition/__tests__/validate-definition.test.ts +354 -354
- package/src/definition/definition.limits.ts +9 -9
- package/src/definition/definition.schema.ts +172 -172
- package/src/definition/definition.types.ts +171 -171
- package/src/definition/validate-definition.ts +206 -206
- package/src/definition/walk-steps.ts +44 -44
- package/src/discord/discord.types.ts +264 -5
- package/src/engine/__tests__/run-in-isolate.test.ts +468 -468
- package/src/engine/engine-entry.ts +3 -3
- package/src/engine/engine-global.ts +2 -2
- package/src/engine/run-in-isolate.ts +404 -404
- package/src/errors/runtime-error-code.enum.ts +37 -37
- package/src/index.ts +32 -32
- package/src/interpreter/__tests__/interpreter.test.ts +854 -854
- package/src/interpreter/__tests__/log-respond-resume.test.ts +270 -223
- package/src/interpreter/interpreter-error.ts +12 -12
- package/src/interpreter/interpreter.ts +482 -461
- package/src/interpreter/interpreter.types.ts +202 -192
- package/src/interpreter/sequence-path.ts +67 -67
- package/src/interpreter/test-host.ts +85 -85
- package/src/runner-protocol/evaluation.types.ts +21 -21
- package/src/runner-protocol/execution-protocol.types.ts +254 -231
- package/src/schedule/schedule.types.ts +100 -100
- package/src/server/__tests__/code-runner-session.test.ts +311 -311
- package/src/server/code-runner-error.ts +12 -12
- package/src/server/code-runner-session.ts +310 -310
- package/src/server/index.ts +11 -11
- package/src/steps/__tests__/global-references.test.ts +133 -133
- package/src/steps/execute-step.ts +186 -186
- package/src/steps/global-references.ts +48 -48
- package/src/steps/step-access.ts +56 -56
- package/src/steps/step-fields.ts +87 -87
- package/src/steps/value-source.ts +69 -69
- package/tsconfig.check.json +15 -15
- package/tsconfig.json +35 -35
|
@@ -34,8 +34,67 @@ export enum DiscordCapability {
|
|
|
34
34
|
GET_CHANNEL = 'discord.getChannel',
|
|
35
35
|
/** Reads a server. Arguments: `DiscordGetGuildArgs`; result: `DiscordGuild`. */
|
|
36
36
|
GET_GUILD = 'discord.getGuild',
|
|
37
|
+
/** Removes a member from a server. Arguments: `DiscordKickMemberArgs`. */
|
|
38
|
+
KICK_MEMBER = 'discord.kickMember',
|
|
39
|
+
/** Bans a user from a server. Arguments: `DiscordBanMemberArgs`. */
|
|
40
|
+
BAN_MEMBER = 'discord.banMember',
|
|
41
|
+
/** Lifts the ban of a user. Arguments: `DiscordUnbanMemberArgs`. */
|
|
42
|
+
UNBAN_MEMBER = 'discord.unbanMember',
|
|
43
|
+
/** Times a member out, or lifts the timeout. Arguments: `DiscordTimeoutMemberArgs`. */
|
|
44
|
+
TIMEOUT_MEMBER = 'discord.timeoutMember',
|
|
45
|
+
/** Deletes 2 to 100 messages of a channel in one call. Arguments: `DiscordBulkDeleteMessagesArgs`. */
|
|
46
|
+
BULK_DELETE_MESSAGES = 'discord.bulkDeleteMessages',
|
|
47
|
+
/** Adds the bot's reaction to a message. Arguments: `DiscordReactionArgs`. */
|
|
48
|
+
ADD_REACTION = 'discord.addReaction',
|
|
49
|
+
/** Removes the bot's reaction, or a user's. Arguments: `DiscordRemoveReactionArgs`. */
|
|
50
|
+
REMOVE_REACTION = 'discord.removeReaction',
|
|
51
|
+
/** Creates a channel in a server. Arguments: `DiscordCreateChannelArgs`; result: `DiscordChannel`. */
|
|
52
|
+
CREATE_CHANNEL = 'discord.createChannel',
|
|
53
|
+
/** Deletes a channel or a thread. Arguments: `DiscordDeleteChannelArgs`. */
|
|
54
|
+
DELETE_CHANNEL = 'discord.deleteChannel',
|
|
55
|
+
/** Sets what a role or a member may do in a channel. Arguments: `DiscordSetChannelPermissionArgs`. */
|
|
56
|
+
SET_CHANNEL_PERMISSION = 'discord.setChannelPermission',
|
|
57
|
+
/** Removes what a channel sets for a role or a member. Arguments: `DiscordRemoveChannelPermissionArgs`. */
|
|
58
|
+
REMOVE_CHANNEL_PERMISSION = 'discord.removeChannelPermission',
|
|
59
|
+
/** Creates a role in a server. Arguments: `DiscordCreateRoleArgs`; result: `DiscordRole`. */
|
|
60
|
+
CREATE_ROLE = 'discord.createRole',
|
|
61
|
+
/** Deletes a role of a server. Arguments: `DiscordDeleteRoleArgs`. */
|
|
62
|
+
DELETE_ROLE = 'discord.deleteRole',
|
|
63
|
+
/** Starts a thread, from a message or not. Arguments: `DiscordCreateThreadArgs`; result: `DiscordChannel`. */
|
|
64
|
+
CREATE_THREAD = 'discord.createThread',
|
|
65
|
+
/** Ends a poll of the bot before its time. Arguments: `DiscordEndPollArgs`. */
|
|
66
|
+
END_POLL = 'discord.endPoll',
|
|
37
67
|
}
|
|
38
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Bounds the host applies to the arguments of `abyss.discord.*` before any call to Discord: a call
|
|
71
|
+
* outside them fails with an argument error, without any call to Discord (it is still billed as one call).
|
|
72
|
+
*/
|
|
73
|
+
export const DISCORD_CAPABILITY_LIMITS = {
|
|
74
|
+
/** `reason` of an action, sent as Discord's audit log reason. */
|
|
75
|
+
auditReasonMaxLength: 512,
|
|
76
|
+
/** Longest timeout Discord allows, from now. */
|
|
77
|
+
timeoutMaxDays: 28,
|
|
78
|
+
/** Messages a ban may delete, in seconds back from now (7 days). */
|
|
79
|
+
banDeleteMessageSecondsMax: 604_800,
|
|
80
|
+
bulkDeleteMin: 2,
|
|
81
|
+
bulkDeleteMax: 100,
|
|
82
|
+
channelNameMaxLength: 100,
|
|
83
|
+
channelTopicMaxLength: 1024,
|
|
84
|
+
permissionOverwritesMax: 100,
|
|
85
|
+
roleNameMaxLength: 100,
|
|
86
|
+
roleColorMax: 0xffffff,
|
|
87
|
+
threadNameMaxLength: 100,
|
|
88
|
+
/** Auto-archive durations Discord accepts, in minutes. */
|
|
89
|
+
threadAutoArchiveMinutes: [60, 1440, 4320, 10080],
|
|
90
|
+
pollQuestionMaxLength: 300,
|
|
91
|
+
pollAnswersMax: 10,
|
|
92
|
+
pollAnswerTextMaxLength: 55,
|
|
93
|
+
/** 32 days. */
|
|
94
|
+
pollDurationHoursMax: 768,
|
|
95
|
+
pollDurationHoursDefault: 24,
|
|
96
|
+
} as const;
|
|
97
|
+
|
|
39
98
|
/**
|
|
40
99
|
* Codes of the errors `abyss.discord.*` throws. The host fails the call with the message
|
|
41
100
|
* `<code>: <detail>` (or the bare code); the helper rethrows an `Error` named `DiscordError`
|
|
@@ -86,6 +145,26 @@ export interface DiscordAllowedMentions {
|
|
|
86
145
|
repliedUser?: boolean;
|
|
87
146
|
}
|
|
88
147
|
|
|
148
|
+
/** An answer of a poll. `emoji` is a unicode emoji or a server emoji `name:id`. */
|
|
149
|
+
export interface DiscordPollAnswer {
|
|
150
|
+
text: string;
|
|
151
|
+
emoji?: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* A native Discord poll attached to a new message. Discord never edits a poll: `editMessage` and
|
|
156
|
+
* `update` refuse a message that carries one.
|
|
157
|
+
*/
|
|
158
|
+
export interface DiscordPoll {
|
|
159
|
+
/** 1 to 300 characters. */
|
|
160
|
+
question: string;
|
|
161
|
+
/** 1 to 10 answers. */
|
|
162
|
+
answers: DiscordPollAnswer[];
|
|
163
|
+
/** 1 to 768 hours (32 days), 24 by default. */
|
|
164
|
+
durationHours?: number;
|
|
165
|
+
allowMultiselect?: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
89
168
|
export interface DiscordMessage {
|
|
90
169
|
content?: string;
|
|
91
170
|
embeds?: DiscordJsonObject[];
|
|
@@ -94,6 +173,8 @@ export interface DiscordMessage {
|
|
|
94
173
|
ephemeral?: boolean;
|
|
95
174
|
/** Who the message may notify; by default the mentioned users only (see `DiscordAllowedMentions`). */
|
|
96
175
|
allowedMentions?: DiscordAllowedMentions;
|
|
176
|
+
/** A poll; only on a new message (`sendMessage`, `sendDirectMessage`, `reply`, `followUp`). */
|
|
177
|
+
poll?: DiscordPoll;
|
|
97
178
|
}
|
|
98
179
|
|
|
99
180
|
/** Text input style of a modal field. */
|
|
@@ -130,17 +211,157 @@ export interface DiscordEditMessageArgs {
|
|
|
130
211
|
message: DiscordMessage;
|
|
131
212
|
}
|
|
132
213
|
|
|
133
|
-
|
|
214
|
+
/**
|
|
215
|
+
* The audit log reason an action may carry: 1 to 512 characters, shown in the server's audit log
|
|
216
|
+
* (Discord's `X-Audit-Log-Reason`).
|
|
217
|
+
*/
|
|
218
|
+
export interface DiscordAuditReason {
|
|
219
|
+
reason?: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface DiscordDeleteMessageArgs extends DiscordAuditReason {
|
|
134
223
|
channelId: string;
|
|
135
224
|
messageId: string;
|
|
136
225
|
}
|
|
137
226
|
|
|
138
|
-
export interface DiscordRoleArgs {
|
|
227
|
+
export interface DiscordRoleArgs extends DiscordAuditReason {
|
|
228
|
+
guildId: string;
|
|
229
|
+
userId: string;
|
|
230
|
+
roleId: string;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface DiscordKickMemberArgs extends DiscordAuditReason {
|
|
234
|
+
guildId: string;
|
|
235
|
+
userId: string;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface DiscordBanMemberArgs extends DiscordAuditReason {
|
|
139
239
|
guildId: string;
|
|
140
240
|
userId: string;
|
|
241
|
+
/** Deletes the user's messages of that many seconds back, 0 to 604 800 (7 days); 0 by default. */
|
|
242
|
+
deleteMessageSeconds?: number;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface DiscordUnbanMemberArgs extends DiscordAuditReason {
|
|
246
|
+
guildId: string;
|
|
247
|
+
userId: string;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface DiscordTimeoutMemberArgs extends DiscordAuditReason {
|
|
251
|
+
guildId: string;
|
|
252
|
+
userId: string;
|
|
253
|
+
/** End of the timeout, ISO 8601, in the future and at most 28 days away; null lifts it. */
|
|
254
|
+
until: string | null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export interface DiscordBulkDeleteMessagesArgs extends DiscordAuditReason {
|
|
258
|
+
channelId: string;
|
|
259
|
+
/** 2 to 100 distinct ids; Discord refuses a message older than 14 days. */
|
|
260
|
+
messageIds: string[];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** `emoji` is a unicode emoji or a server emoji `name:id`. */
|
|
264
|
+
export interface DiscordReactionArgs {
|
|
265
|
+
channelId: string;
|
|
266
|
+
messageId: string;
|
|
267
|
+
emoji: string;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface DiscordRemoveReactionArgs extends DiscordReactionArgs {
|
|
271
|
+
/** Whose reaction to remove; the bot's own without it. */
|
|
272
|
+
userId?: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** Discord's channel types a bot can create (`type` of `DiscordChannel` holds Discord's number). */
|
|
276
|
+
export enum DiscordChannelType {
|
|
277
|
+
TEXT = 0,
|
|
278
|
+
VOICE = 2,
|
|
279
|
+
CATEGORY = 4,
|
|
280
|
+
ANNOUNCEMENT = 5,
|
|
281
|
+
FORUM = 15,
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** What a channel permission applies to. */
|
|
285
|
+
export enum DiscordPermissionTargetType {
|
|
286
|
+
ROLE = 'ROLE',
|
|
287
|
+
MEMBER = 'MEMBER',
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** Permissions a channel allows or denies to one role or member; bits as decimal strings. */
|
|
291
|
+
export interface DiscordPermissionOverwrite {
|
|
292
|
+
/** The role or member id. */
|
|
293
|
+
id: string;
|
|
294
|
+
type: DiscordPermissionTargetType;
|
|
295
|
+
allow?: string;
|
|
296
|
+
deny?: string;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export interface DiscordCreateChannelArgs extends DiscordAuditReason {
|
|
300
|
+
guildId: string;
|
|
301
|
+
/** 1 to 100 characters. */
|
|
302
|
+
name: string;
|
|
303
|
+
type: DiscordChannelType;
|
|
304
|
+
/** The category the channel goes in. */
|
|
305
|
+
parentId?: string;
|
|
306
|
+
/** Up to 1024 characters. */
|
|
307
|
+
topic?: string;
|
|
308
|
+
nsfw?: boolean;
|
|
309
|
+
/** 100 at most. */
|
|
310
|
+
permissionOverwrites?: DiscordPermissionOverwrite[];
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export interface DiscordDeleteChannelArgs extends DiscordAuditReason {
|
|
314
|
+
channelId: string;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export interface DiscordSetChannelPermissionArgs extends DiscordAuditReason {
|
|
318
|
+
channelId: string;
|
|
319
|
+
targetId: string;
|
|
320
|
+
targetType: DiscordPermissionTargetType;
|
|
321
|
+
/** Permission bits as a decimal string; none by default. */
|
|
322
|
+
allow?: string;
|
|
323
|
+
deny?: string;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export interface DiscordRemoveChannelPermissionArgs extends DiscordAuditReason {
|
|
327
|
+
channelId: string;
|
|
328
|
+
targetId: string;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export interface DiscordCreateRoleArgs extends DiscordAuditReason {
|
|
332
|
+
guildId: string;
|
|
333
|
+
/** 1 to 100 characters. */
|
|
334
|
+
name: string;
|
|
335
|
+
/** Permission bits as a decimal string; Discord's default without it. */
|
|
336
|
+
permissions?: string;
|
|
337
|
+
/** RGB color as an integer, 0 to 0xFFFFFF. */
|
|
338
|
+
color?: number;
|
|
339
|
+
hoist?: boolean;
|
|
340
|
+
mentionable?: boolean;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export interface DiscordDeleteRoleArgs extends DiscordAuditReason {
|
|
344
|
+
guildId: string;
|
|
141
345
|
roleId: string;
|
|
142
346
|
}
|
|
143
347
|
|
|
348
|
+
export interface DiscordCreateThreadArgs extends DiscordAuditReason {
|
|
349
|
+
channelId: string;
|
|
350
|
+
/** 1 to 100 characters. */
|
|
351
|
+
name: string;
|
|
352
|
+
/** Starts the thread from this message; without it the thread stands alone. */
|
|
353
|
+
messageId?: string;
|
|
354
|
+
/** A private thread; only without `messageId`. */
|
|
355
|
+
private?: boolean;
|
|
356
|
+
/** 60, 1440, 4320 or 10080. */
|
|
357
|
+
autoArchiveMinutes?: number;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export interface DiscordEndPollArgs {
|
|
361
|
+
channelId: string;
|
|
362
|
+
messageId: string;
|
|
363
|
+
}
|
|
364
|
+
|
|
144
365
|
export interface DiscordSendDirectMessageArgs {
|
|
145
366
|
userId: string;
|
|
146
367
|
message: DiscordMessage;
|
|
@@ -259,15 +480,53 @@ export enum DiscordCallbackType {
|
|
|
259
480
|
/** Discord's message flag that makes a message visible to its recipient only. */
|
|
260
481
|
export const EPHEMERAL_FLAG = 64;
|
|
261
482
|
|
|
483
|
+
/** A member as an interaction resolves it: partial, without its user (see `DiscordResolved.users`). */
|
|
484
|
+
export interface DiscordResolvedMember {
|
|
485
|
+
nick: string | null;
|
|
486
|
+
/** Role ids. */
|
|
487
|
+
roles: string[];
|
|
488
|
+
joinedAt: string | null;
|
|
489
|
+
/** The member's permissions in the channel, decimal string; null when Discord does not give them. */
|
|
490
|
+
permissions: string | null;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/** A file a user attached to an ATTACHMENT option. */
|
|
494
|
+
export interface DiscordAttachment {
|
|
495
|
+
id: string;
|
|
496
|
+
filename: string;
|
|
497
|
+
/** Bytes. */
|
|
498
|
+
size: number;
|
|
499
|
+
url: string;
|
|
500
|
+
contentType: string | null;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* The users, members, roles, channels and files an interaction names, by id, as Discord resolves
|
|
505
|
+
* them for its options and typed select menus. A key is absent when Discord resolved none of its kind.
|
|
506
|
+
*/
|
|
507
|
+
export interface DiscordResolved {
|
|
508
|
+
users?: Record<string, DiscordUser>;
|
|
509
|
+
members?: Record<string, DiscordResolvedMember>;
|
|
510
|
+
roles?: Record<string, DiscordRole>;
|
|
511
|
+
/** Partial channels: what Discord gives in an interaction. */
|
|
512
|
+
channels?: Record<string, DiscordChannel>;
|
|
513
|
+
attachments?: Record<string, DiscordAttachment>;
|
|
514
|
+
}
|
|
515
|
+
|
|
262
516
|
/**
|
|
263
517
|
* The `input` of a function triggered by a Discord interaction. The interaction token never
|
|
264
518
|
* appears here: it stays in the edge.
|
|
265
519
|
*/
|
|
266
520
|
export interface DiscordInteractionInput {
|
|
267
521
|
kind: DiscordInteractionKind;
|
|
268
|
-
/** Resolved option values, by option name. */
|
|
269
|
-
command?: {
|
|
270
|
-
|
|
522
|
+
/** Resolved option values, by option name; `resolved` details the ids they hold, when there are some. */
|
|
523
|
+
command?: {
|
|
524
|
+
name: string;
|
|
525
|
+
options: Record<string, string | number | boolean>;
|
|
526
|
+
resolved?: DiscordResolved;
|
|
527
|
+
};
|
|
528
|
+
/** `values` of a select menu; `resolved` details them for a user, role, channel or mentionable menu. */
|
|
529
|
+
component?: { customId: string; values?: string[]; resolved?: DiscordResolved };
|
|
271
530
|
modal?: { customId: string; fields: Record<string, string> };
|
|
272
531
|
user: { id: string; username: string; globalName: string | null };
|
|
273
532
|
member?: { roles: string[]; permissions: string };
|