@crowbartools/firebot-types 5.67.0-alpha13 → 5.67.0-alpha15
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/backend/scripts/executors/plugin-executor.d.ts +2 -1
- package/backend/scripts/executors/script-executor.interface.d.ts +2 -1
- package/backend/webhooks/webhook-config-manager.d.ts +12 -1
- package/package.json +1 -1
- package/types/plugins.d.ts +28 -6
- package/types/script-api.d.ts +0 -8
- package/types/webhooks.d.ts +5 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ScriptBase, LegacyCustomScript, Plugin, InstalledPluginConfig, ScriptDetails } from "../../../types";
|
|
2
2
|
import { IPluginExecutor, PluginRegistrations, PluginExecutionResult } from "./script-executor.interface";
|
|
3
|
+
import { ScriptApiContext } from "../script-api";
|
|
3
4
|
/**
|
|
4
5
|
* Executor for new-spec Plugins (manifest.type === "plugin")
|
|
5
6
|
*/
|
|
@@ -7,7 +8,7 @@ export declare class PluginExecutor extends IPluginExecutor {
|
|
|
7
8
|
constructor();
|
|
8
9
|
canHandle(script: ScriptBase | LegacyCustomScript): script is Plugin<import("../../../types").FirebotParams>;
|
|
9
10
|
getScriptDetails(script: ScriptBase | LegacyCustomScript): ScriptDetails | null;
|
|
10
|
-
executePlugin(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig, isInstalling?: boolean): Promise<PluginExecutionResult>;
|
|
11
|
+
executePlugin(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig, isInstalling?: boolean, ctx?: ScriptApiContext): Promise<PluginExecutionResult>;
|
|
11
12
|
unloadPlugin(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig, registrations?: PluginRegistrations, isUninstalling?: boolean): Promise<void>;
|
|
12
13
|
updateParameters(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig): Promise<void>;
|
|
13
14
|
private registerAll;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InstalledPluginConfig, LegacyCustomScript, ScriptBase, ScriptContext, Awaitable, ScriptDetails } from "../../../types";
|
|
2
|
+
import type { ScriptApiContext } from "../script-api";
|
|
2
3
|
declare abstract class IBaseScriptExecutor {
|
|
3
4
|
abstract canHandle(script: ScriptBase | LegacyCustomScript): Awaitable<boolean>;
|
|
4
5
|
abstract getScriptDetails(script: ScriptBase | LegacyCustomScript): Awaitable<ScriptDetails | null>;
|
|
@@ -25,7 +26,7 @@ export type PluginExecutionResult = {
|
|
|
25
26
|
error: string;
|
|
26
27
|
};
|
|
27
28
|
export declare abstract class IPluginExecutor extends IBaseScriptExecutor {
|
|
28
|
-
abstract executePlugin(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig, isInstalling?: boolean): Awaitable<PluginExecutionResult>;
|
|
29
|
+
abstract executePlugin(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig, isInstalling?: boolean, ctx?: ScriptApiContext): Awaitable<PluginExecutionResult>;
|
|
29
30
|
abstract unloadPlugin(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig, registrations?: PluginRegistrations, isUninstalling?: boolean): Awaitable<void>;
|
|
30
31
|
updateParameters?(script: ScriptBase | LegacyCustomScript, config: InstalledPluginConfig): Awaitable<void>;
|
|
31
32
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { WebhookConfig } from "../../types";
|
|
1
|
+
import type { ScriptWebhook, WebhookConfig } from "../../types";
|
|
2
|
+
import type { ScriptWebhookEventHandler } from "../../types/script-api";
|
|
2
3
|
import JsonDbManager from "../database/json-db-manager";
|
|
3
4
|
type ExtraEvents = {
|
|
4
5
|
"webhook-received": (data: {
|
|
@@ -9,8 +10,18 @@ type ExtraEvents = {
|
|
|
9
10
|
}) => void;
|
|
10
11
|
};
|
|
11
12
|
declare class WebhookConfigManager extends JsonDbManager<WebhookConfig, ExtraEvents> {
|
|
13
|
+
private _registeredPlugins;
|
|
12
14
|
constructor();
|
|
13
15
|
getWebhookUrlById(webhookId: string): string;
|
|
16
|
+
private toPublic;
|
|
17
|
+
findPluginWebhookByName(pluginId: string, webhookName: string): WebhookConfig;
|
|
18
|
+
getPluginWebhook(pluginId: string, webhookName: string): ScriptWebhook;
|
|
19
|
+
getAllPluginWebhooks(pluginId: string): ScriptWebhook[];
|
|
20
|
+
savePluginWebhook(pluginId: string, webhookName: string): ScriptWebhook;
|
|
21
|
+
deletePluginWebhook(pluginId: string, webhookName: string): boolean;
|
|
22
|
+
getPluginWebhookUrl(pluginId: string, webhookName: string): string;
|
|
23
|
+
registerPluginHandler(pluginId: string, handler: ScriptWebhookEventHandler): boolean;
|
|
24
|
+
unregisterPluginHandler(pluginId: string): boolean;
|
|
14
25
|
}
|
|
15
26
|
declare const webhookConfigManager: WebhookConfigManager;
|
|
16
27
|
export = webhookConfigManager;
|
package/package.json
CHANGED
package/types/plugins.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { UIExtension } from "./ui-extensions";
|
|
|
12
12
|
import type { OverlayWidgetType } from "./overlay-widgets";
|
|
13
13
|
import type { PluginHttpRouteDefinition } from "./http-server";
|
|
14
14
|
import type { CustomWebSocketHandler } from "./websocket";
|
|
15
|
+
import type { PluginWebhooks } from "./webhooks";
|
|
15
16
|
type NoResult = Awaitable<void>;
|
|
16
17
|
type GenericParameters = Record<string, unknown>;
|
|
17
18
|
export type InstalledPluginConfig<Params extends GenericParameters = GenericParameters> = {
|
|
@@ -37,11 +38,35 @@ interface ManifestFirebotVersion {
|
|
|
37
38
|
minor?: number;
|
|
38
39
|
patch?: number;
|
|
39
40
|
}
|
|
41
|
+
type FontAwesomeIcon = {
|
|
42
|
+
type: "font-awesome";
|
|
43
|
+
/**
|
|
44
|
+
* A FontAwesome icon name shown in the UI (eg. "fa-cogs").
|
|
45
|
+
*/
|
|
46
|
+
name: `fa-${string}`;
|
|
47
|
+
/**
|
|
48
|
+
* A css color value (eg. "#FF0000") used for the icon.
|
|
49
|
+
*/
|
|
50
|
+
color?: string;
|
|
51
|
+
};
|
|
52
|
+
type CustomIcon = {
|
|
53
|
+
type: "custom";
|
|
54
|
+
url: string;
|
|
55
|
+
/**
|
|
56
|
+
* A css color value (eg. "#FF0000") used for the background of the icon.
|
|
57
|
+
*/
|
|
58
|
+
backgroundColor?: string;
|
|
59
|
+
};
|
|
60
|
+
export type PluginIcon = FontAwesomeIcon | CustomIcon;
|
|
40
61
|
export interface Manifest {
|
|
41
62
|
name: string;
|
|
42
63
|
version: string;
|
|
43
64
|
author: string;
|
|
44
65
|
description: string | ManifestDescription;
|
|
66
|
+
/**
|
|
67
|
+
* An array of strings that describe or categorize your plugin
|
|
68
|
+
*/
|
|
69
|
+
tags?: string[];
|
|
45
70
|
/**
|
|
46
71
|
* A link to the plugin's source code repository
|
|
47
72
|
*/
|
|
@@ -59,13 +84,9 @@ export interface Manifest {
|
|
|
59
84
|
minimumFirebotVersion?: ManifestFirebotVersion;
|
|
60
85
|
maximumFirebotVersion?: ManifestFirebotVersion;
|
|
61
86
|
/**
|
|
62
|
-
*
|
|
63
|
-
*/
|
|
64
|
-
icon?: `fa-${string}`;
|
|
65
|
-
/**
|
|
66
|
-
* A hex color code (eg. "#FF0000") used for the icon.
|
|
87
|
+
* The icon to be displayed for the plugin.
|
|
67
88
|
*/
|
|
68
|
-
|
|
89
|
+
icon?: PluginIcon;
|
|
69
90
|
/**
|
|
70
91
|
* If true, the plugin will be initialized before parameters are shown to the user,
|
|
71
92
|
* allowing the plugin to provide custom parameter types that can be used in its own parametersSchema.
|
|
@@ -107,6 +128,7 @@ export interface Plugin<Params extends FirebotParams = FirebotParams> extends Sc
|
|
|
107
128
|
overlayWidgets?: DynamicArray<OverlayWidgetType<any, any>>;
|
|
108
129
|
httpRoutes?: DynamicObject<PluginHttpRouteDefinition>;
|
|
109
130
|
websocketListener?: DynamicObject<CustomWebSocketHandler>;
|
|
131
|
+
webhooks?: DynamicObject<PluginWebhooks>;
|
|
110
132
|
};
|
|
111
133
|
/** Called when the plugin is loaded */
|
|
112
134
|
onLoad?: (context: ScriptContext<Params>, isInstalling?: boolean) => NoResult;
|
package/types/script-api.d.ts
CHANGED
|
@@ -24,20 +24,12 @@ export interface ScriptWebhookEvent {
|
|
|
24
24
|
}
|
|
25
25
|
export type ScriptWebhookEventHandler = (event: ScriptWebhookEvent) => void;
|
|
26
26
|
export interface ScriptWebhooksApi {
|
|
27
|
-
/** Create a new webhook (or return the existing one with the same name). */
|
|
28
|
-
save(name: string): ScriptWebhook | null;
|
|
29
27
|
/** Look up a webhook by name. */
|
|
30
28
|
get(name: string): ScriptWebhook | null;
|
|
31
|
-
/** Delete a webhook by name. Returns true if one was removed. */
|
|
32
|
-
delete(name: string): boolean;
|
|
33
29
|
/** All webhooks owned by this script. */
|
|
34
30
|
list(): ScriptWebhook[];
|
|
35
31
|
/** Public URL for a webhook by name, or null if not found. */
|
|
36
32
|
getUrl(name: string): string | null;
|
|
37
|
-
/**
|
|
38
|
-
* Subscribe to webhook events for this script. Returns an `unsubscribe` func
|
|
39
|
-
*/
|
|
40
|
-
onReceived(handler: ScriptWebhookEventHandler): () => void;
|
|
41
33
|
}
|
|
42
34
|
/**
|
|
43
35
|
* Simple per-script storage scoped to the script's data directory.
|
package/types/webhooks.d.ts
CHANGED