@crowbartools/firebot-types 5.67.0-alpha24 → 5.67.0-alpha26

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.
@@ -0,0 +1,28 @@
1
+ import { type Database } from "@tursodatabase/database";
2
+ /**
3
+ * Registry for Turso databases
4
+ *
5
+ * Each named database lives in its own file under the
6
+ * profile's databases/ dir (ie databases/quotes.db)
7
+ */
8
+ declare class TursoConnectionRegistry {
9
+ private logger;
10
+ private connections;
11
+ constructor();
12
+ private getDatabasePath;
13
+ /**
14
+ * Returns a cached connection for the named database,
15
+ * creating the db file if it doesn't exist
16
+ */
17
+ getConnection(name: string): Promise<Database>;
18
+ private open;
19
+ /**
20
+ * Attaches another registered database to the given connection so queries
21
+ * can join across files, ie:
22
+ * "SELECT ... FROM quotes q JOIN viewers.viewers v ON ..."
23
+ */
24
+ attach(db: Database, name: string, alias: string): Promise<void>;
25
+ private closeAll;
26
+ }
27
+ declare const registry: TursoConnectionRegistry;
28
+ export { registry as TursoConnectionRegistry };
@@ -10,6 +10,7 @@ export interface PluginRegistrations {
10
10
  eventSourceIds?: string[];
11
11
  filterIds?: string[];
12
12
  systemCommandIds?: string[];
13
+ conditionIds?: string[];
13
14
  restrictionIds?: string[];
14
15
  integrationIds?: string[];
15
16
  gameIds?: string[];
@@ -0,0 +1,20 @@
1
+ import type { Logger } from "winston";
2
+ import type { ScopedIpc } from "../../../../types/plugin-api";
3
+ export interface MessagingScope {
4
+ ipc: ScopedIpc;
5
+ dispose: () => void;
6
+ }
7
+ declare class PluginMessageBroker {
8
+ private readonly bus;
9
+ private readonly pendingRequests;
10
+ constructor();
11
+ /**
12
+ * Deep-clone a payload to:
13
+ * - Isolate senders/receivers from shared mutable references
14
+ * - Reject non-serializable payloads (ie functions)
15
+ */
16
+ private enforceSerialization;
17
+ createScope(pluginId: string, logger: Logger): MessagingScope;
18
+ }
19
+ export declare const pluginMessageBroker: PluginMessageBroker;
20
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { ScopedIpc } from "../../../../types/plugin-api";
2
+ export declare const createMessagingApi: import("../internal/define-namespace").PluginApiNamespaceFactory<ScopedIpc>;
@@ -18,7 +18,13 @@ declare class QuoteManager {
18
18
  }>;
19
19
  constructor();
20
20
  private regExpEscape;
21
+ private buildSearchPattern;
22
+ private rowToQuote;
21
23
  loadQuoteDatabase(): Promise<void>;
24
+ private createSchema;
25
+ private migrateFromNeDb;
26
+ private insertQuoteRow;
27
+ private getQuoteCount;
22
28
  getCurrentQuoteId(): Promise<number>;
23
29
  getNextQuoteId(): Promise<number>;
24
30
  setQuoteIdIncrementer(number: number): Promise<number>;
@@ -27,13 +33,13 @@ declare class QuoteManager {
27
33
  updateQuote(quote: Quote, dontSendUiUpdateEvent?: boolean): Promise<Quote>;
28
34
  removeQuote(quoteId: number, dontSendUiUpdateEvent?: boolean): Promise<void>;
29
35
  getQuote(quoteId: number): Promise<Quote>;
36
+ private getRandomQuoteWhere;
30
37
  getRandomQuoteByDate(dateConfig: DateConfig): Promise<Quote>;
31
38
  getRandomQuoteByAuthor(author: string): Promise<Quote>;
32
39
  getRandomQuoteByGame(gameSearch: string): Promise<Quote>;
33
40
  getRandomQuoteContainingText(text: string): Promise<Quote>;
34
41
  getRandomQuote(): Promise<Quote>;
35
42
  getAllQuotes(): Promise<Quote[]>;
36
- private updateQuoteId;
37
43
  recalculateQuoteIds(): Promise<void>;
38
44
  exportQuotesToFile(filepath: string): Promise<boolean>;
39
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowbartools/firebot-types",
3
- "version": "5.67.0-alpha24",
3
+ "version": "5.67.0-alpha26",
4
4
  "description": "Type definitions and plugin API for Firebot plugins.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -0,0 +1,36 @@
1
+ import type EventEmitter from "events";
2
+ import { Trigger, TriggersObject, TriggerType } from "./triggers";
3
+ type PresetValue = {
4
+ value: string;
5
+ display: string;
6
+ };
7
+ type ConditionValueType = "text" | "number" | "preset" | "none";
8
+ export type ConditionSettings<ComparisonTypes extends string, LeftSideValueType extends ConditionValueType, RightSideValueType extends ConditionValueType> = {
9
+ type: string;
10
+ comparisonType: ComparisonTypes;
11
+ leftSideValue: LeftSideValueType extends "number" ? number : LeftSideValueType extends "none" ? undefined : string;
12
+ rightSideValue: RightSideValueType extends "number" ? number : string;
13
+ };
14
+ export type ConditionType<ComparisonTypes extends string, LeftSideValueType extends ConditionValueType, RightSideValueType extends ConditionValueType> = {
15
+ id: string;
16
+ name: string;
17
+ description: string;
18
+ comparisonTypes: ComparisonTypes[];
19
+ rightSideValueType: RightSideValueType;
20
+ leftSideValueType?: LeftSideValueType;
21
+ triggers?: TriggerType[] | TriggersObject;
22
+ leftSideTextPlaceholder?: string;
23
+ rightSideTextPlaceholder?: string;
24
+ getRightSidePresetValues?: (...args: unknown[]) => PresetValue[];
25
+ getLeftSidePresetValues?: (...args: unknown[]) => PresetValue[];
26
+ getRightSideValueDisplay?(condition: ConditionSettings<ComparisonTypes, LeftSideValueType, RightSideValueType>, ...args: unknown[]): string;
27
+ getLeftSideValueDisplay?(condition: ConditionSettings<ComparisonTypes, LeftSideValueType, RightSideValueType>, ...args: unknown[]): string;
28
+ valueIsStillValid?(condition: ConditionSettings<ComparisonTypes, LeftSideValueType, RightSideValueType>, ...args: unknown[]): boolean;
29
+ predicate(conditionSettings: ConditionSettings<ComparisonTypes, LeftSideValueType, RightSideValueType>, trigger: Trigger): boolean | Promise<boolean>;
30
+ };
31
+ export type ConditionManager = EventEmitter & {
32
+ registerConditionType(conditionType: ConditionType<any, any, any>): void;
33
+ getConditionTypeById(conditionTypeId: string): ConditionType<any, any, any>;
34
+ getAllConditionTypes(): ConditionType<any, any, any>[];
35
+ };
36
+ export {};
package/types/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from "./auth";
3
3
  export * from "./channel-rewards";
4
4
  export * from "./chat";
5
5
  export * from "./commands";
6
+ export * from "./conditions";
6
7
  export * from "./control-deck";
7
8
  export * from "./counters";
8
9
  export * from "./currency";
@@ -106,6 +106,37 @@ export interface PluginFrontendCommunicatorApi {
106
106
  */
107
107
  fireEventAsync<ReturnPayload = void, ExpectedArg = unknown>(eventName: string, data?: ExpectedArg): Promise<ReturnPayload>;
108
108
  }
109
+ export interface PluginMessageEvent<TPayload = unknown> {
110
+ /** The pluginId of the plugin that sent the message. */
111
+ sender: string;
112
+ /** The provided payload. */
113
+ payload: TPayload;
114
+ }
115
+ /**
116
+ * Plugin-to-plugin messaging. Supports both fire-and-forget (`emit`/`on`/`off`)
117
+ * and request/response (`invoke`/`handle`) messaging over a shared event bus,
118
+ * based on Electron's IPC
119
+ */
120
+ export interface ScopedIpc {
121
+ /** Broadcast a message on a channel. */
122
+ emit(channel: string, data: unknown): void;
123
+ /**
124
+ * Listen for messages on a channel.
125
+ * Returns an `unsubscribe` function.
126
+ */
127
+ on<TPayload = unknown>(channel: string, callback: (event: PluginMessageEvent<TPayload>) => void): () => void;
128
+ /** Remove a previously registered `on` listener. */
129
+ off(channel: string, callback: (...args: never[]) => void): void;
130
+ /**
131
+ * Send a request on a channel and await a response. Rejects if
132
+ * no handler responds within a 10s timeout or if the handler throws.
133
+ */
134
+ invoke<TRequestPayload = unknown, TResponseData = unknown>(channel: string, data?: TRequestPayload): Promise<TResponseData>;
135
+ /**
136
+ * Register the handler for a request channel.
137
+ */
138
+ handle<TRequestPayload = unknown, TResponseData = unknown>(channel: string, handlerFn: (payload: TRequestPayload, sender: string) => Promise<TResponseData> | TResponseData): void;
139
+ }
109
140
  export interface PluginSettingsApi {
110
141
  /**
111
142
  * Get a Firebot setting value or its default
@@ -165,6 +196,8 @@ export interface FirebotPluginApi {
165
196
  parameters: PluginParametersApi;
166
197
  /** Two-way messaging between the plugin and the frontend. */
167
198
  frontendCommunicator: PluginFrontendCommunicatorApi;
199
+ /** Plugin-to-plugin messaging */
200
+ messaging: ScopedIpc;
168
201
  /** Notifications owned by this plugin. */
169
202
  notifications: PluginNotificationsApi;
170
203
  /** Access to installed plugins. */
@@ -13,6 +13,7 @@ import type { OverlayWidgetType } from "./overlay-widgets";
13
13
  import type { PluginHttpRouteDefinition } from "./http-server";
14
14
  import type { CustomWebSocketHandler } from "./websocket";
15
15
  import type { PluginWebhooks } from "./webhooks";
16
+ import { ConditionType } from "./conditions";
16
17
  type NoResult = Awaitable<void>;
17
18
  type GenericParameters = Record<string, unknown>;
18
19
  export type ManagedPluginManifest = {
@@ -43,17 +44,7 @@ export type ManagedPluginWithManifest = ManagedPlugin & {
43
44
  manifest: ManagedPluginManifest;
44
45
  };
45
46
  export type ManagedPluginUpdateRequest = {
46
- author: string;
47
- name: string;
48
- version: string;
49
- firebotVersion: ManifestFirebotVersion;
50
- };
51
- export type ManagedPluginBatchUpdateRequest = {
52
- plugins: Array<{
53
- author: string;
54
- name: string;
55
- version: string;
56
- }>;
47
+ plugins: Array<ManagedPlugin>;
57
48
  firebotVersion: ManifestFirebotVersion;
58
49
  };
59
50
  export type InstalledPluginConfig<Params extends GenericParameters = GenericParameters> = {
@@ -154,6 +145,7 @@ export interface Plugin<Params extends FirebotParams = FirebotParams> extends Pl
154
145
  integrations?: DynamicArray<Integration<any>>;
155
146
  filters?: DynamicArray<EventFilter>;
156
147
  restrictions?: DynamicArray<RestrictionType<any>>;
148
+ conditions?: DynamicArray<ConditionType<any, any, any>>;
157
149
  systemCommands?: DynamicArray<SystemCommand<any>>;
158
150
  games?: DynamicArray<FirebotGame>;
159
151
  frontendListeners?: DynamicArray<FrontendListener>;