generated from ubiquity-os/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin-inputs.ts
31 lines (27 loc) · 1.01 KB
/
plugin-inputs.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { SupportedEvents, SupportedEventsU } from "./context";
import { StaticDecode, Type as T } from "@sinclair/typebox";
import { StandardValidator } from "typebox-validators";
export interface PluginInputs<T extends SupportedEventsU = SupportedEventsU, TU extends SupportedEvents[T] = SupportedEvents[T]> {
stateId: string;
eventName: T;
eventPayload: TU["payload"];
settings: PluginSettings;
authToken: string;
ref: string;
}
/**
* This should contain the properties of the bot config
* that are required for the plugin to function.
*
* The kernel will extract those and pass them to the plugin,
* which are built into the context object from setup().
*/
export const pluginSettingsSchema = T.Object(
{
configurableResponse: T.String(),
customStringsUrl: T.Optional(T.String()),
},
{ default: { configurableResponse: "Hello, world!" } }
);
export const pluginSettingsValidator = new StandardValidator(pluginSettingsSchema);
export type PluginSettings = StaticDecode<typeof pluginSettingsSchema>;