@cicord/sdk 0.0.0-bootstrap.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +59 -0
- package/dist/index.d.ts +734 -0
- package/dist/index.mjs +34 -0
- package/dist/index.mjs.map +1 -0
- package/dist/testing.d.ts +304 -0
- package/dist/testing.mjs +982 -0
- package/dist/testing.mjs.map +1 -0
- package/package.json +57 -1
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
const CAPABILITY_IN_MESSAGE = /capability "?([a-z]+(?:\.[a-z]+)+)"?/;
|
|
3
|
+
/** Thrown when a call needs a capability that is not granted in bot.yaml. */
|
|
4
|
+
var CapabilityError = class extends Error {
|
|
5
|
+
capability;
|
|
6
|
+
/**
|
|
7
|
+
* The spec declares no constructor (it inherits `Error`'s), so the capability is taken from
|
|
8
|
+
* `options.capability` or parsed from a message like `missing capability "storage.kv"`.
|
|
9
|
+
* Use `capabilityError()` from "@cicord/sdk/testing" to build one in tests.
|
|
10
|
+
*/
|
|
11
|
+
constructor(message, options) {
|
|
12
|
+
super(message, options);
|
|
13
|
+
this.name = "CapabilityError";
|
|
14
|
+
this.capability = options?.capability ?? CAPABILITY_IN_MESSAGE.exec(message ?? "")?.[1] ?? "";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/** Entry point of a plugin: `export default definePlugin({ ... })`. Identity at run time. */
|
|
18
|
+
function definePlugin(definition) {
|
|
19
|
+
return definition;
|
|
20
|
+
}
|
|
21
|
+
function command(definition) {
|
|
22
|
+
return definition;
|
|
23
|
+
}
|
|
24
|
+
/** Helper that infers option types for a subcommand. Identity at run time. */
|
|
25
|
+
function subcommand(definition) {
|
|
26
|
+
return definition;
|
|
27
|
+
}
|
|
28
|
+
/** Routes checked against a declared contract (`defineRoutes<Routes>({...})`). Identity at run time. */
|
|
29
|
+
function defineRoutes(routes) {
|
|
30
|
+
return routes;
|
|
31
|
+
}
|
|
32
|
+
export { CapabilityError, command, definePlugin, defineRoutes, subcommand };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @cicord/sdk runtime for authoring and unit tests.\n *\n * Inside Cicord the Go plugin host provides the \"@cicord/sdk\" module; this implementation only\n * exists so that plugins can be imported and tested in Node. The public *types* of this\n * package are spec/sdk/cicord-sdk.d.ts, copied verbatim into dist/index.d.ts at build time.\n * The conformance block at the bottom of this file fails type-checking if this runtime ever\n * drifts from the spec.\n */\nimport type * as Spec from \"@cicord/sdk\";\n\nconst CAPABILITY_IN_MESSAGE = /capability \"?([a-z]+(?:\\.[a-z]+)+)\"?/;\n\n/** Thrown when a call needs a capability that is not granted in bot.yaml. */\nexport class CapabilityError extends Error {\n readonly capability: string;\n\n /**\n * The spec declares no constructor (it inherits `Error`'s), so the capability is taken from\n * `options.capability` or parsed from a message like `missing capability \"storage.kv\"`.\n * Use `capabilityError()` from \"@cicord/sdk/testing\" to build one in tests.\n */\n constructor(message?: string, options?: ErrorOptions & { capability?: string }) {\n super(message, options);\n this.name = \"CapabilityError\";\n this.capability = options?.capability ?? CAPABILITY_IN_MESSAGE.exec(message ?? \"\")?.[1] ?? \"\";\n }\n}\n\n/** Entry point of a plugin: `export default definePlugin({ ... })`. Identity at run time. */\nexport function definePlugin(definition: Spec.PluginDefinition): Spec.PluginDefinition {\n return definition;\n}\n\n/** Helper that infers option types for `interaction.options`. Identity at run time. */\nexport function command<const O extends Record<string, Spec.CommandOption> = {}>(\n definition: Spec.CommandDefinition<O>,\n): Spec.CommandDefinition<O>;\n/** A command made of subcommands (and groups). Identity at run time. */\nexport function command(\n definition: Spec.CommandWithSubcommandsDefinition,\n): Spec.CommandWithSubcommandsDefinition;\nexport function command(\n definition: Spec.CommandDefinition<any> | Spec.CommandWithSubcommandsDefinition,\n): Spec.CommandDefinition<any> | Spec.CommandWithSubcommandsDefinition {\n return definition;\n}\n\n/** Helper that infers option types for a subcommand. Identity at run time. */\nexport function subcommand<const O extends Record<string, Spec.CommandOption> = {}>(\n definition: Spec.SubcommandDefinition<O>,\n): Spec.SubcommandDefinition<O> {\n return definition;\n}\n\n/** Routes checked against a declared contract (`defineRoutes<Routes>({...})`). Identity at run time. */\nexport function defineRoutes<Routes extends { [K in keyof Routes]: Spec.RouteTypes }>(routes: {\n [K in keyof Routes & Spec.RouteKey]: Spec.TypedRouteDefinition<K, Routes[K]>;\n}): { [K in Spec.RouteKey]?: Spec.RouteDefinition } {\n return routes;\n}\n\n// ───────────────────────────────────────────────────────────── conformance with the spec\n// Type-level only: these assignments break `tsc` when the runtime and the spec disagree.\ntype Assert<T extends true> = T;\ntype SameConstructor = typeof CapabilityError extends typeof Spec.CapabilityError\n ? InstanceType<typeof CapabilityError> extends Spec.CapabilityError\n ? true\n : false\n : false;\nexport type __SpecConformance = [\n Assert<typeof definePlugin extends typeof Spec.definePlugin ? true : false>,\n Assert<typeof command extends typeof Spec.command ? true : false>,\n Assert<typeof subcommand extends typeof Spec.subcommand ? true : false>,\n Assert<typeof defineRoutes extends typeof Spec.defineRoutes ? true : false>,\n Assert<SameConstructor>,\n];\n"],"mappings":";AAWA,MAAM,wBAAwB;;AAG9B,IAAa,kBAAb,cAAqC,MAAM;CACzC;;;;;;CAOA,YAAY,SAAkB,SAAkD;EAC9E,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;EACZ,KAAK,aAAa,SAAS,cAAc,sBAAsB,KAAK,WAAW,EAAE,CAAC,GAAG,MAAM;CAC7F;AACF;;AAGA,SAAgB,aAAa,YAA0D;CACrF,OAAO;AACT;AAUA,SAAgB,QACd,YACqE;CACrE,OAAO;AACT;;AAGA,SAAgB,WACd,YAC8B;CAC9B,OAAO;AACT;;AAGA,SAAgB,aAAsE,QAElC;CAClD,OAAO;AACT"}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @cicord/sdk/testing — in-memory fakes to unit-test Cicord plugins in Node (Vitest, node:test…).
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import plugin from "../src/index.ts";
|
|
6
|
+
* import { createTestContext, callRoute } from "@cicord/sdk/testing";
|
|
7
|
+
*
|
|
8
|
+
* const t = createTestContext({ config: {...}, roles: { pc: { name: "PC" } }, members: [{ id: "1" }] });
|
|
9
|
+
* const res = await callRoute(plugin, t, "GET /steps", { viewer: "1" });
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* The fakes follow spec/sdk/cicord-sdk.d.ts. Capabilities are enforced only when `grants` is
|
|
13
|
+
* given; then a call without its grant throws `CapabilityError`, like the real host. Pass the
|
|
14
|
+
* plugin's `schema` (config.schema.json) to get the config defaults the runtime applies.
|
|
15
|
+
*
|
|
16
|
+
* Interactions: `runCommand` (a command or a subcommand path such as `"polls close"`),
|
|
17
|
+
* `runComponent` and `submitModal` call the handler with a recording fake interaction that
|
|
18
|
+
* follows the reply/defer/update/followUp/showModal rules of the runtime; `runAutocomplete`
|
|
19
|
+
* returns the choices of an option's autocomplete handler. Other handlers (events, tasks, schedules, subscriptions) are plain functions:
|
|
20
|
+
* call them with `harness.ctx`, e.g. `await plugin.tasks!.close!(t.ctx, { id: "1" })`.
|
|
21
|
+
*/
|
|
22
|
+
import type { AutocompleteChoice, Channel, Context, CreateChannelOptions, Json, Member, Message, MessageInput, Modal, Permission, PluginDefinition, ReplyInput, RouteResponse, TextChannel } from "@cicord/sdk";
|
|
23
|
+
import { CapabilityError } from "./index.js";
|
|
24
|
+
export interface TestRoleInit {
|
|
25
|
+
name: string;
|
|
26
|
+
color?: string;
|
|
27
|
+
id?: string;
|
|
28
|
+
/** Hierarchy position (higher is higher). Default: 1, 2, 3… in declaration order. */
|
|
29
|
+
position?: number;
|
|
30
|
+
/** Default false. */
|
|
31
|
+
mentionable?: boolean;
|
|
32
|
+
/** Server-level permissions the role grants (`member.permissions`). Default none. */
|
|
33
|
+
permissions?: Permission[];
|
|
34
|
+
}
|
|
35
|
+
/** Who holds an access level (servers/<server>.yaml spec.access): user ids and role keys. */
|
|
36
|
+
export interface TestPrincipals {
|
|
37
|
+
users?: string[];
|
|
38
|
+
roles?: string[];
|
|
39
|
+
}
|
|
40
|
+
export interface TestChannelInit {
|
|
41
|
+
name: string;
|
|
42
|
+
type?: Channel["type"];
|
|
43
|
+
id?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface TestMemberInit {
|
|
46
|
+
id: string;
|
|
47
|
+
username?: string;
|
|
48
|
+
displayName?: string;
|
|
49
|
+
nickname?: string;
|
|
50
|
+
avatarUrl?: string;
|
|
51
|
+
bot?: boolean;
|
|
52
|
+
/** Role keys (as in `roles`). */
|
|
53
|
+
roles?: string[];
|
|
54
|
+
joinedAt?: Date;
|
|
55
|
+
}
|
|
56
|
+
export interface TestFetchResponse {
|
|
57
|
+
status?: number;
|
|
58
|
+
headers?: Record<string, string>;
|
|
59
|
+
/** Response body (string, or a JSON value that is serialized). */
|
|
60
|
+
body?: string | Json;
|
|
61
|
+
}
|
|
62
|
+
export interface TestContextOptions {
|
|
63
|
+
/**
|
|
64
|
+
* Plugin config. Defaults are applied only when `schema` is given (like the runtime does
|
|
65
|
+
* with config.schema.json); otherwise pass every field the plugin reads.
|
|
66
|
+
*/
|
|
67
|
+
config?: Record<string, unknown>;
|
|
68
|
+
/** The plugin's config.schema.json: its `default`s are applied to `config` (see `applyDefaults`). */
|
|
69
|
+
schema?: object;
|
|
70
|
+
/** Fake `ctx.http.fetch`. Without it, fetch throws. Requests are recorded in `requests`. */
|
|
71
|
+
fetch?: (url: string, init: Parameters<Context["http"]["fetch"]>[1]) => TestFetchResponse | Promise<TestFetchResponse>;
|
|
72
|
+
/** Granted capabilities. Omit to allow everything. */
|
|
73
|
+
grants?: string[];
|
|
74
|
+
plugin?: {
|
|
75
|
+
name?: string;
|
|
76
|
+
version?: string;
|
|
77
|
+
instance?: string;
|
|
78
|
+
};
|
|
79
|
+
bot?: {
|
|
80
|
+
key?: string;
|
|
81
|
+
username?: string;
|
|
82
|
+
};
|
|
83
|
+
server?: {
|
|
84
|
+
id?: string;
|
|
85
|
+
key?: string;
|
|
86
|
+
name?: string;
|
|
87
|
+
iconUrl?: string;
|
|
88
|
+
/** `ctx.server.ownerId`; the owner has every permission and the admin access level. */
|
|
89
|
+
ownerId?: string;
|
|
90
|
+
/** Permissions of `@everyone` (part of every `member.permissions`). Default none. */
|
|
91
|
+
everyonePermissions?: Permission[];
|
|
92
|
+
};
|
|
93
|
+
/** spec.access of the server: `member.access` is "admin" / "moderator" for these. */
|
|
94
|
+
access?: {
|
|
95
|
+
admins?: TestPrincipals;
|
|
96
|
+
moderators?: TestPrincipals;
|
|
97
|
+
};
|
|
98
|
+
/** Managed roles keyed by role key. */
|
|
99
|
+
roles?: Record<string, TestRoleInit>;
|
|
100
|
+
/** Managed channels keyed by channel key. */
|
|
101
|
+
channels?: Record<string, TestChannelInit>;
|
|
102
|
+
members?: TestMemberInit[];
|
|
103
|
+
/** Base URL used by the fake `ctx.portal.link()`. */
|
|
104
|
+
portalUrl?: string;
|
|
105
|
+
}
|
|
106
|
+
export interface LogEntry {
|
|
107
|
+
level: "debug" | "info" | "warn" | "error";
|
|
108
|
+
message: string;
|
|
109
|
+
fields?: Record<string, Json>;
|
|
110
|
+
}
|
|
111
|
+
/** `allowedMentions` as the host sends it: lists are ids (objects replaced by their id). */
|
|
112
|
+
export interface NormalizedAllowedMentions {
|
|
113
|
+
users?: boolean | string[];
|
|
114
|
+
roles?: boolean | string[];
|
|
115
|
+
everyone?: boolean;
|
|
116
|
+
repliedUser?: boolean;
|
|
117
|
+
}
|
|
118
|
+
export interface SentMessage {
|
|
119
|
+
/** Channel key/id, or `dm:<userId>` for direct messages. */
|
|
120
|
+
to: string;
|
|
121
|
+
message: MessageInput;
|
|
122
|
+
/** The message's `allowedMentions`, normalized; absent when the message has none. */
|
|
123
|
+
allowedMentions?: NormalizedAllowedMentions;
|
|
124
|
+
/** Id of the created message (see `harness.message(id)`). */
|
|
125
|
+
id: string;
|
|
126
|
+
}
|
|
127
|
+
export interface ModerationAction {
|
|
128
|
+
member: string;
|
|
129
|
+
action: "timeout" | "kick" | "ban" | "nickname";
|
|
130
|
+
durationMs?: number;
|
|
131
|
+
reason?: string;
|
|
132
|
+
deleteMessagesSeconds?: number;
|
|
133
|
+
nickname?: string | null;
|
|
134
|
+
}
|
|
135
|
+
export interface RoleChange {
|
|
136
|
+
member: string;
|
|
137
|
+
role: string;
|
|
138
|
+
action: "add" | "remove";
|
|
139
|
+
reason?: string;
|
|
140
|
+
}
|
|
141
|
+
export interface TestHarness {
|
|
142
|
+
readonly ctx: Context;
|
|
143
|
+
readonly logs: LogEntry[];
|
|
144
|
+
readonly sent: SentMessage[];
|
|
145
|
+
readonly roleChanges: RoleChange[];
|
|
146
|
+
readonly links: {
|
|
147
|
+
path: string;
|
|
148
|
+
member?: string;
|
|
149
|
+
url: string;
|
|
150
|
+
}[];
|
|
151
|
+
readonly published: {
|
|
152
|
+
topic: string;
|
|
153
|
+
payload: Json;
|
|
154
|
+
}[];
|
|
155
|
+
readonly scheduled: {
|
|
156
|
+
id: string;
|
|
157
|
+
delayMs: number;
|
|
158
|
+
task: string;
|
|
159
|
+
payload?: Json;
|
|
160
|
+
}[];
|
|
161
|
+
/** Message edits (`message.edit()`), in order. */
|
|
162
|
+
readonly edits: {
|
|
163
|
+
id: string;
|
|
164
|
+
message: MessageInput;
|
|
165
|
+
}[];
|
|
166
|
+
/** Deleted message ids (`message.delete()`). */
|
|
167
|
+
readonly deletedMessages: {
|
|
168
|
+
id: string;
|
|
169
|
+
reason?: string;
|
|
170
|
+
}[];
|
|
171
|
+
readonly reactions: {
|
|
172
|
+
message: string;
|
|
173
|
+
emoji: string;
|
|
174
|
+
}[];
|
|
175
|
+
readonly moderation: ModerationAction[];
|
|
176
|
+
/** Channels created with `ctx.server.createChannel()` (resolvable by `{ id }`). */
|
|
177
|
+
readonly createdChannels: {
|
|
178
|
+
channel: TextChannel;
|
|
179
|
+
options: CreateChannelOptions;
|
|
180
|
+
}[];
|
|
181
|
+
readonly deletedChannels: {
|
|
182
|
+
id: string;
|
|
183
|
+
reason?: string;
|
|
184
|
+
}[];
|
|
185
|
+
readonly threads: {
|
|
186
|
+
parent: string;
|
|
187
|
+
name: string;
|
|
188
|
+
private: boolean;
|
|
189
|
+
fromMessage?: string;
|
|
190
|
+
}[];
|
|
191
|
+
/** `ctx.http.fetch()` requests. */
|
|
192
|
+
readonly requests: {
|
|
193
|
+
url: string;
|
|
194
|
+
init: Parameters<Context["http"]["fetch"]>[1];
|
|
195
|
+
}[];
|
|
196
|
+
/** Raw KV contents (values are JSON clones; expired keys are dropped on access). */
|
|
197
|
+
readonly kv: Map<string, Json>;
|
|
198
|
+
/** Live member (roles reflect role changes). */
|
|
199
|
+
member(userId: string): Member | undefined;
|
|
200
|
+
addMember(init: TestMemberInit): Member;
|
|
201
|
+
/** A message sent through the fakes (channel.send, reply, member.send, followUp). */
|
|
202
|
+
message(id: string): Message | undefined;
|
|
203
|
+
/** A channel by key or id (managed, created or DM). */
|
|
204
|
+
channel(ref: string): TextChannel | undefined;
|
|
205
|
+
/** Removes a member (e.g. before calling a memberLeave handler). */
|
|
206
|
+
removeMember(userId: string): void;
|
|
207
|
+
}
|
|
208
|
+
/** Builds the error the host throws when `capability` is not granted. */
|
|
209
|
+
export declare function capabilityError(capability: string): CapabilityError;
|
|
210
|
+
/**
|
|
211
|
+
* Validates and normalizes `allowedMentions` like the host: `users` / `roles` are a boolean
|
|
212
|
+
* or at most 100 ids (or objects with an id). Ids must be snowflakes, or ids known to the
|
|
213
|
+
* fakes (`known`), since test ids such as `role-staff` are not snowflakes. Throws a
|
|
214
|
+
* TypeError like the host.
|
|
215
|
+
*/
|
|
216
|
+
export declare function normalizeAllowedMentions(input: MessageInput | ReplyInput, known?: (id: string) => boolean): NormalizedAllowedMentions | undefined;
|
|
217
|
+
/**
|
|
218
|
+
* Returns a copy of `config` with the `default`s of a JSON Schema applied, with the runtime's
|
|
219
|
+
* rules (config.ApplyDefaults): nested objects, object elements of arrays and local `$ref`s;
|
|
220
|
+
* not `additionalProperties` values nor `oneOf`/`anyOf` alternatives.
|
|
221
|
+
*/
|
|
222
|
+
export declare function applyDefaults<T extends Record<string, unknown>>(schema: object, config: T): T;
|
|
223
|
+
export declare function createTestContext(options?: TestContextOptions): TestHarness;
|
|
224
|
+
export interface RouteCall {
|
|
225
|
+
/** User id of the viewer (must be a member of the test context), or undefined (anonymous). */
|
|
226
|
+
viewer?: string;
|
|
227
|
+
body?: Json;
|
|
228
|
+
query?: Record<string, string>;
|
|
229
|
+
}
|
|
230
|
+
export interface RouteResult {
|
|
231
|
+
status: number;
|
|
232
|
+
body: Json | undefined;
|
|
233
|
+
headers: Record<string, string>;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* The runtime's reading of `RouteResponse`: an object whose only keys are `status` (number),
|
|
237
|
+
* `body` and `headers` is a response envelope; anything else is a 200 JSON body.
|
|
238
|
+
*/
|
|
239
|
+
export declare function normalizeRouteResponse(response: RouteResponse): RouteResult;
|
|
240
|
+
/**
|
|
241
|
+
* Calls a plugin route like the runtime does. `route` is `"<METHOD> <path>"`; the path may
|
|
242
|
+
* be concrete (`"POST /answers/42"`) and is matched against declared patterns (`/answers/:id`).
|
|
243
|
+
* Route `access` is checked: anonymous viewers get 401 unless the route is public.
|
|
244
|
+
*/
|
|
245
|
+
export declare function callRoute(plugin: PluginDefinition, harness: TestHarness, route: string, call?: RouteCall): Promise<RouteResult>;
|
|
246
|
+
export interface InteractionCall {
|
|
247
|
+
/** Invoking user id. When it is a member of the test context, `interaction.member` is set. */
|
|
248
|
+
user: string;
|
|
249
|
+
/** Channel key or id of `interaction.channel` (a managed or created channel). */
|
|
250
|
+
channel?: string;
|
|
251
|
+
}
|
|
252
|
+
export interface CommandCall extends InteractionCall {
|
|
253
|
+
options?: Record<string, unknown>;
|
|
254
|
+
}
|
|
255
|
+
export interface ComponentCall extends InteractionCall {
|
|
256
|
+
/** Selected values (select menus). */
|
|
257
|
+
values?: string[];
|
|
258
|
+
/** The message carrying the component: a message sent through the fakes, or its id. */
|
|
259
|
+
message?: Message | string;
|
|
260
|
+
}
|
|
261
|
+
export interface ModalCall extends InteractionCall {
|
|
262
|
+
fields?: Record<string, string>;
|
|
263
|
+
}
|
|
264
|
+
export interface InteractionResult {
|
|
265
|
+
/** `reply()` calls (initial reply, or the edit of a deferred reply). */
|
|
266
|
+
replies: ReplyInput[];
|
|
267
|
+
followUps: ReplyInput[];
|
|
268
|
+
/** `update()` calls (components only). */
|
|
269
|
+
updates: MessageInput[];
|
|
270
|
+
deferred: {
|
|
271
|
+
ephemeral?: boolean;
|
|
272
|
+
} | undefined;
|
|
273
|
+
/** The modal opened with `showModal()`. */
|
|
274
|
+
modal: Modal | undefined;
|
|
275
|
+
}
|
|
276
|
+
/** Result of `runCommand` (same shape as the other interaction helpers). */
|
|
277
|
+
export type CommandResult = InteractionResult;
|
|
278
|
+
/**
|
|
279
|
+
* Runs a slash command handler with a recording fake interaction. `path` is the command
|
|
280
|
+
* name, or the subcommand path for commands with subcommands: `"polls close"`,
|
|
281
|
+
* `"polls admin purge"` (`interaction.subcommand` / `interaction.group` are set).
|
|
282
|
+
*/
|
|
283
|
+
export declare function runCommand(plugin: PluginDefinition, harness: TestHarness, path: string, call: CommandCall): Promise<CommandResult>;
|
|
284
|
+
export interface AutocompleteCall extends InteractionCall {
|
|
285
|
+
/** Name of the option being typed (it must have `autocomplete`). */
|
|
286
|
+
focused: string;
|
|
287
|
+
/** Text typed so far (default ""). */
|
|
288
|
+
value?: string;
|
|
289
|
+
/** Other options already filled in (raw values: ids for users, roles, channels). */
|
|
290
|
+
options?: Record<string, string | number | boolean>;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Runs the `autocomplete` handler of an option like the runtime does and returns the
|
|
294
|
+
* choices. The result is checked like the runtime checks it (at most 25 choices, names of
|
|
295
|
+
* 1–100 characters, values of the option's type): an invalid result throws.
|
|
296
|
+
*/
|
|
297
|
+
export declare function runAutocomplete(plugin: PluginDefinition, harness: TestHarness, path: string, call: AutocompleteCall): Promise<AutocompleteChoice[]>;
|
|
298
|
+
/**
|
|
299
|
+
* Runs the component handler for a local component id (`"vote:42"` is routed to
|
|
300
|
+
* `components.vote`, `componentId` stays `"vote:42"`).
|
|
301
|
+
*/
|
|
302
|
+
export declare function runComponent(plugin: PluginDefinition, harness: TestHarness, componentId: string, call: ComponentCall): Promise<InteractionResult>;
|
|
303
|
+
/** Runs the modal submit handler for a modal id (same id fallback as components). */
|
|
304
|
+
export declare function submitModal(plugin: PluginDefinition, harness: TestHarness, modalId: string, call: ModalCall): Promise<InteractionResult>;
|