@rimori/client 2.4.0-next.3 → 2.4.0-next.5

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.
@@ -1,320 +1,52 @@
1
- import { PostgrestQueryBuilder } from '@supabase/postgrest-js';
2
1
  import { SupabaseClient } from '@supabase/supabase-js';
3
- import { GenericSchema } from '@supabase/supabase-js/dist/module/lib/types';
4
- import { generateText, Message, OnLLMResponse, streamChatGPT } from '../controller/AIController';
5
- import { generateObject, ObjectRequest } from '../controller/ObjectController';
6
- import { SettingsController, UserInfo } from '../controller/SettingsController';
7
2
  import {
8
3
  SharedContent,
9
4
  SharedContentController,
10
5
  SharedContentFilter,
11
6
  SharedContentObjectRequest,
12
7
  } from '../controller/SharedContentController';
13
- import { getSTTResponse, getTTSResponse } from '../controller/VoiceController';
14
- import { ExerciseController, CreateExerciseParams } from '../controller/ExerciseController';
15
- import { EventBus, EventBusMessage, EventHandler, EventPayload, EventListener } from '../fromRimori/EventBus';
16
- import { ActivePlugin, MainPanelAction, Plugin, Tool } from '../fromRimori/PluginTypes';
17
- import { AccomplishmentController, AccomplishmentPayload } from '../controller/AccomplishmentController';
18
8
  import { RimoriCommunicationHandler, RimoriInfo } from './CommunicationHandler';
19
- import { Translator } from '../controller/TranslationController';
20
9
  import { Logger } from './Logger';
10
+ import { PluginModule } from './module/PluginModule';
11
+ import { DbModule } from './module/DbModule';
12
+ import { EventModule } from './module/EventModule';
13
+ import { AIModule } from './module/AIModule';
14
+ import { ExerciseModule } from './module/ExerciseModule';
21
15
 
22
16
  // Add declaration for WorkerGlobalScope
23
17
  declare const WorkerGlobalScope: any;
24
18
 
25
19
  export class RimoriClient {
26
20
  private static instance: RimoriClient;
27
- private superbase: SupabaseClient;
28
21
  private pluginController: RimoriCommunicationHandler;
29
- private settingsController: SettingsController;
30
22
  private sharedContentController: SharedContentController;
31
- private exerciseController: ExerciseController;
32
- private accomplishmentHandler: AccomplishmentController;
23
+ public db: DbModule;
24
+ public event: EventModule;
25
+ public plugin: PluginModule;
26
+ public ai: AIModule;
27
+ public exercise: ExerciseModule;
33
28
  private rimoriInfo: RimoriInfo;
34
- private translator: Translator;
35
29
 
36
30
  private constructor(controller: RimoriCommunicationHandler, supabase: SupabaseClient, info: RimoriInfo) {
37
31
  this.rimoriInfo = info;
38
- this.superbase = supabase;
39
32
  this.pluginController = controller;
40
- this.exerciseController = new ExerciseController(supabase, this);
41
- this.accomplishmentHandler = new AccomplishmentController(info.pluginId);
42
- this.settingsController = new SettingsController(supabase, info.pluginId, info.guild);
43
33
  this.sharedContentController = new SharedContentController(supabase, this);
44
- const currentPlugin = info.installedPlugins.find((plugin) => plugin.id === info.pluginId);
45
- this.translator = new Translator(info.interfaceLanguage, currentPlugin?.endpoint || '');
34
+ this.ai = new AIModule(controller, info);
35
+ this.event = new EventModule(info.pluginId);
36
+ this.db = new DbModule(supabase, controller, info);
37
+ this.plugin = new PluginModule(supabase, controller, info);
38
+ this.exercise = new ExerciseModule(supabase, controller, info, this.event);
39
+
40
+ controller.onUpdate((updatedInfo) => {
41
+ this.rimoriInfo = updatedInfo;
42
+ });
46
43
 
47
44
  //only init logger in workers and on main plugin pages
48
- if (this.getQueryParam('applicationMode') !== 'sidebar') {
45
+ if (this.plugin.applicationMode !== 'sidebar') {
49
46
  Logger.getInstance(this);
50
47
  }
51
48
  }
52
49
 
53
- public get plugin() {
54
- return {
55
- pluginId: this.rimoriInfo.pluginId,
56
- /**
57
- * The release channel of this plugin installation.
58
- * Determines which database schema is used for plugin tables.
59
- */
60
- releaseChannel: this.rimoriInfo.releaseChannel,
61
- /**
62
- * Set the settings for the plugin.
63
- * @param settings The settings to set.
64
- */
65
- setSettings: async (settings: any): Promise<void> => {
66
- await this.settingsController.setSettings(settings);
67
- },
68
- /**
69
- * Get the settings for the plugin. T can be any type of settings, UserSettings or SystemSettings.
70
- * @param defaultSettings The default settings to use if no settings are found.
71
- * @param genericSettings The type of settings to get.
72
- * @returns The settings for the plugin.
73
- */
74
- getSettings: async <T extends object>(defaultSettings: T): Promise<T> => {
75
- return await this.settingsController.getSettings<T>(defaultSettings);
76
- },
77
- getUserInfo: (): UserInfo => {
78
- return this.rimoriInfo.profile;
79
- },
80
- /**
81
- * Retrieves information about plugins, including:
82
- * - All installed plugins
83
- * - The currently active plugin in the main panel
84
- * - The currently active plugin in the side panel
85
- */
86
- getPluginInfo: (): {
87
- /**
88
- * All installed plugins.
89
- */
90
- installedPlugins: Plugin[];
91
- /**
92
- * The plugin that is loaded in the main panel.
93
- */
94
- mainPanelPlugin?: ActivePlugin;
95
- /**
96
- * The plugin that is loaded in the side panel.
97
- */
98
- sidePanelPlugin?: ActivePlugin;
99
- } => {
100
- return {
101
- installedPlugins: this.rimoriInfo.installedPlugins,
102
- mainPanelPlugin: this.rimoriInfo.mainPanelPlugin,
103
- sidePanelPlugin: this.rimoriInfo.sidePanelPlugin,
104
- };
105
- },
106
- /**
107
- * Get the translator for the plugin.
108
- * @returns The translator for the plugin.
109
- */
110
- getTranslator: async (): Promise<Translator> => {
111
- await this.translator.initialize();
112
- return this.translator;
113
- },
114
- };
115
- }
116
-
117
- public get db() {
118
- return {
119
- // private from<
120
- // TableName extends string & keyof GenericSchema['Tables'],
121
- // Table extends GenericSchema['Tables'][TableName],
122
- // >(relation: TableName): PostgrestQueryBuilder<GenericSchema, Table, TableName>;
123
- // private from<ViewName extends string & keyof GenericSchema['Views'], View extends GenericSchema['Views'][ViewName]>(
124
- // relation: ViewName,
125
- // ): PostgrestQueryBuilder<GenericSchema, View, ViewName>;
126
- from: <ViewName extends string & keyof GenericSchema['Views'], View extends GenericSchema['Views'][ViewName]>(
127
- relation: string,
128
- ): PostgrestQueryBuilder<GenericSchema, View, ViewName> => {
129
- const tableName = this.db.getTableName(relation);
130
- // Use the schema determined by rimori-main based on release channel
131
- // Global tables (starting with 'global_') remain in public schema
132
- // Plugin tables use the schema provided by rimori-main (plugins or plugins_alpha)
133
- if (relation.startsWith('global_')) {
134
- // Global tables stay in public schema
135
- return this.superbase.from(tableName);
136
- }
137
- // Plugin tables go to the schema provided by rimori-main
138
- return this.superbase.schema(this.rimoriInfo.dbSchema).from(tableName);
139
- },
140
- // storage: this.superbase.storage,
141
- // functions: this.superbase.functions,
142
- /**
143
- * The table prefix for of database tables of the plugin.
144
- */
145
- tablePrefix: this.rimoriInfo.tablePrefix,
146
- /**
147
- * The database schema used for plugin tables.
148
- * Determined by rimori-main based on release channel:
149
- * - 'plugins_alpha' for alpha release channel
150
- * - 'plugins' for beta and stable release channels
151
- */
152
- schema: this.rimoriInfo.dbSchema,
153
- /**
154
- * Get the table name for a given plugin table.
155
- * Internally all tables are prefixed with the plugin id. This function is used to get the correct table name for a given public table.
156
- * @param table The plugin table name to get the full table name for.
157
- * @returns The full table name.
158
- */
159
- getTableName: (table: string): string => {
160
- if (/[A-Z]/.test(table)) {
161
- throw new Error('Table name cannot include uppercase letters. Please use snake_case for table names.');
162
- }
163
- if (table.startsWith('global_')) {
164
- return table.replace('global_', '');
165
- }
166
- return this.db.tablePrefix + '_' + table;
167
- },
168
- };
169
- }
170
-
171
- public event = {
172
- /**
173
- * Emit an event to Rimori or a plugin.
174
- * The topic schema is:
175
- * {pluginId}.{eventId}
176
- * Check out the event bus documentation for more information.
177
- * For triggering events from Rimori like context menu actions use the "global" keyword.
178
- * @param topic The topic to emit the event on.
179
- * @param data The data to emit.
180
- * @param eventId The event id.
181
- */
182
- emit: (topic: string, data?: any, eventId?: number) => {
183
- const globalTopic = this.pluginController.getGlobalEventTopic(topic);
184
- EventBus.emit(this.plugin.pluginId, globalTopic, data, eventId);
185
- },
186
- /**
187
- * Request an event.
188
- * @param topic The topic to request the event on.
189
- * @param data The data to request.
190
- * @returns The response from the event.
191
- */
192
- request: <T>(topic: string, data?: any): Promise<EventBusMessage<T>> => {
193
- const globalTopic = this.pluginController.getGlobalEventTopic(topic);
194
- return EventBus.request<T>(this.plugin.pluginId, globalTopic, data);
195
- },
196
- /**
197
- * Subscribe to an event.
198
- * @param topic The topic to subscribe to.
199
- * @param callback The callback to call when the event is emitted.
200
- * @returns An EventListener object containing an off() method to unsubscribe the listeners.
201
- */
202
- on: <T = EventPayload>(topic: string | string[], callback: EventHandler<T>): EventListener => {
203
- const topics = Array.isArray(topic) ? topic : [topic];
204
- return EventBus.on<T>(
205
- topics.map((t) => this.pluginController.getGlobalEventTopic(t)),
206
- callback,
207
- );
208
- },
209
- /**
210
- * Subscribe to an event once.
211
- * @param topic The topic to subscribe to.
212
- * @param callback The callback to call when the event is emitted.
213
- */
214
- once: <T = EventPayload>(topic: string, callback: EventHandler<T>) => {
215
- EventBus.once<T>(this.pluginController.getGlobalEventTopic(topic), callback);
216
- },
217
- /**
218
- * Respond to an event.
219
- * @param topic The topic to respond to.
220
- * @param data The data to respond with.
221
- */
222
- respond: <T = EventPayload>(
223
- topic: string | string[],
224
- data: EventPayload | ((data: EventBusMessage<T>) => EventPayload | Promise<EventPayload>),
225
- ) => {
226
- const topics = Array.isArray(topic) ? topic : [topic];
227
- EventBus.respond(
228
- this.plugin.pluginId,
229
- topics.map((t) => this.pluginController.getGlobalEventTopic(t)),
230
- data,
231
- );
232
- },
233
- /**
234
- * Emit an accomplishment.
235
- * @param payload The payload to emit.
236
- */
237
- emitAccomplishment: (payload: AccomplishmentPayload) => {
238
- this.accomplishmentHandler.emitAccomplishment(payload);
239
- },
240
- /**
241
- * Subscribe to an accomplishment.
242
- * @param accomplishmentTopic The topic to subscribe to.
243
- * @param callback The callback to call when the accomplishment is emitted.
244
- */
245
- onAccomplishment: (
246
- accomplishmentTopic: string,
247
- callback: (payload: EventBusMessage<AccomplishmentPayload>) => void,
248
- ) => {
249
- this.accomplishmentHandler.subscribe(accomplishmentTopic, callback);
250
- },
251
- /**
252
- * Trigger an action that opens the sidebar and triggers an action in the designated plugin.
253
- * @param pluginId The id of the plugin to trigger the action for.
254
- * @param actionKey The key of the action to trigger.
255
- * @param text Optional text to be used for the action like for example text that the translator would look up.
256
- */
257
- emitSidebarAction: (pluginId: string, actionKey: string, text?: string) => {
258
- this.event.emit('global.sidebar.triggerAction', { plugin_id: pluginId, action_key: actionKey, text });
259
- },
260
-
261
- /**
262
- * Subscribe to main panel actions triggered by the user from the dashboard.
263
- * @param callback Handler function that receives the action data when a matching action is triggered.
264
- * @param actionsToListen Optional filter to listen only to specific action keys. If empty or not provided, all actions will trigger the callback.
265
- * @returns An EventListener object with an `off()` method for cleanup.
266
- *
267
- * @example
268
- * ```ts
269
- * const listener = client.event.onMainPanelAction((data) => {
270
- * console.log('Action received:', data.action_key);
271
- * }, ['startSession', 'pauseSession']);
272
- *
273
- * // Clean up when component unmounts to prevent events from firing
274
- * // when navigating away or returning to the page
275
- * useEffect(() => {
276
- * return () => listener.off();
277
- * }, []);
278
- * ```
279
- *
280
- * **Important:** Always call `listener.off()` when your component unmounts or when you no longer need to listen.
281
- * This prevents the event handler from firing when navigating away from or returning to the page, which could
282
- * cause unexpected behavior or duplicate event handling.
283
- */
284
- onMainPanelAction: (
285
- callback: (data: MainPanelAction) => void,
286
- actionsToListen: string | string[] = [],
287
- ): EventListener => {
288
- const listeningActions = Array.isArray(actionsToListen) ? actionsToListen : [actionsToListen];
289
- // this needs to be a emit and on because the main panel action is triggered by the user and not by the plugin
290
- this.event.emit('action.requestMain');
291
- return this.event.on<MainPanelAction>('action.requestMain', ({ data }) => {
292
- // console.log('Received action for main panel ' + data.action_key);
293
- // console.log('Listening to actions', listeningActions);
294
- if (listeningActions.length === 0 || listeningActions.includes(data.action_key)) {
295
- callback(data);
296
- }
297
- });
298
- },
299
-
300
- onSidePanelAction: (
301
- callback: (data: MainPanelAction) => void,
302
- actionsToListen: string | string[] = [],
303
- ): EventListener => {
304
- const listeningActions = Array.isArray(actionsToListen) ? actionsToListen : [actionsToListen];
305
- // this needs to be a emit and on because the main panel action is triggered by the user and not by the plugin
306
- this.event.emit('action.requestSidebar');
307
- return this.event.on<MainPanelAction>('action.requestSidebar', ({ data }) => {
308
- // console.log("eventHandler .onSidePanelAction", data);
309
- // console.log('Received action for sidebar ' + data.action);
310
- // console.log('Listening to actions', listeningActions);
311
- if (listeningActions.length === 0 || listeningActions.includes(data.action)) {
312
- callback(data);
313
- }
314
- });
315
- },
316
- };
317
-
318
50
  public navigation = {
319
51
  toDashboard: (): void => {
320
52
  this.event.emit('global.navigation.triggerToDashboard');
@@ -324,6 +56,7 @@ export class RimoriClient {
324
56
  /**
325
57
  * Get a query parameter value that was passed via MessageChannel
326
58
  * @param key The query parameter key
59
+ * @deprecated Use the plugin.applicationMode and plugin.theme properties instead
327
60
  * @returns The query parameter value or null if not found
328
61
  */
329
62
  public getQueryParam(key: string): string | null {
@@ -347,40 +80,13 @@ export class RimoriClient {
347
80
  return RimoriClient.instance;
348
81
  }
349
82
 
350
- public ai = {
351
- getText: async (messages: Message[], tools?: Tool[]): Promise<string> => {
352
- const token = await this.pluginController.getToken();
353
- return generateText(this.pluginController.getBackendUrl(), messages, tools || [], token).then(
354
- ({ messages }) => messages[0].content[0].text,
355
- );
356
- },
357
- getSteamedText: async (messages: Message[], onMessage: OnLLMResponse, tools?: Tool[]) => {
358
- const token = await this.pluginController.getToken();
359
- streamChatGPT(this.pluginController.getBackendUrl(), messages, tools || [], onMessage, token);
360
- },
361
- getVoice: async (text: string, voice = 'alloy', speed = 1, language?: string): Promise<Blob> => {
362
- const token = await this.pluginController.getToken();
363
- return getTTSResponse(this.pluginController.getBackendUrl(), { input: text, voice, speed, language }, token);
364
- },
365
- getTextFromVoice: async (file: Blob): Promise<string> => {
366
- const token = await this.pluginController.getToken();
367
- return getSTTResponse(this.pluginController.getBackendUrl(), file, token);
368
- },
369
- getObject: async <T = any>(request: ObjectRequest): Promise<T> => {
370
- const token = await this.pluginController.getToken();
371
- return generateObject<T>(this.pluginController.getBackendUrl(), request, token);
372
- },
373
- // getSteamedObject: this.generateObjectStream,
374
- };
375
-
376
83
  public runtime = {
377
84
  fetchBackend: async (url: string, options: RequestInit) => {
378
- const token = await this.pluginController.getToken();
379
- return fetch(this.pluginController.getBackendUrl() + url, {
85
+ return fetch(this.rimoriInfo.backendUrl + url, {
380
86
  ...options,
381
87
  headers: {
382
88
  ...options.headers,
383
- Authorization: `Bearer ${token}`,
89
+ Authorization: `Bearer ${this.rimoriInfo.token}`,
384
90
  },
385
91
  });
386
92
  },
@@ -490,39 +196,4 @@ export class RimoriClient {
490
196
  },
491
197
  },
492
198
  };
493
-
494
- public exercise = {
495
- /**
496
- * Fetches weekly exercises from the weekly_exercises view.
497
- * Shows exercises for the current week that haven't expired.
498
- * @returns Array of exercise objects.
499
- */
500
- view: async () => {
501
- return this.exerciseController.viewWeeklyExercises();
502
- },
503
-
504
- /**
505
- * Creates a new exercise or multiple exercises via the backend API.
506
- * When creating multiple exercises, all requests are made in parallel but only one event is emitted.
507
- * @param params Exercise creation parameters (single or array).
508
- * @returns Created exercise objects.
509
- */
510
- add: async (params: CreateExerciseParams | CreateExerciseParams[]) => {
511
- const token = await this.pluginController.getToken();
512
- const backendUrl = this.pluginController.getBackendUrl();
513
- const exercises = Array.isArray(params) ? params : [params];
514
- return this.exerciseController.addExercise(token, backendUrl, exercises);
515
- },
516
-
517
- /**
518
- * Deletes an exercise via the backend API.
519
- * @param id The exercise ID to delete.
520
- * @returns Success status.
521
- */
522
- delete: async (id: string) => {
523
- const token = await this.pluginController.getToken();
524
- const backendUrl = this.pluginController.getBackendUrl();
525
- return this.exerciseController.deleteExercise(token, backendUrl, id);
526
- },
527
- };
528
199
  }
@@ -0,0 +1,77 @@
1
+ import { RimoriCommunicationHandler, RimoriInfo } from '../CommunicationHandler';
2
+ import { generateText, Message, OnLLMResponse, streamChatGPT } from '../../controller/AIController';
3
+ import { generateObject, ObjectRequest } from '../../controller/ObjectController';
4
+ import { getSTTResponse, getTTSResponse } from '../../controller/VoiceController';
5
+ import { Tool } from '../../fromRimori/PluginTypes';
6
+
7
+ /**
8
+ * Controller for AI-related operations.
9
+ * Provides access to text generation, voice synthesis, and object generation.
10
+ */
11
+ export class AIModule {
12
+ private communicationHandler: RimoriCommunicationHandler;
13
+ private backendUrl: string;
14
+ private token: string;
15
+
16
+ constructor(communicationHandler: RimoriCommunicationHandler, info: RimoriInfo) {
17
+ this.token = info.token;
18
+ this.backendUrl = info.backendUrl;
19
+ this.communicationHandler = communicationHandler;
20
+
21
+ this.communicationHandler.onUpdate((updatedInfo) => {
22
+ this.token = updatedInfo.token;
23
+ });
24
+ }
25
+
26
+ /**
27
+ * Generate text from messages using AI.
28
+ * @param messages The messages to generate text from.
29
+ * @param tools Optional tools to use for generation.
30
+ * @returns The generated text.
31
+ */
32
+ async getText(messages: Message[], tools?: Tool[]): Promise<string> {
33
+ return generateText(this.backendUrl, messages, tools || [], this.token).then(
34
+ ({ messages }) => messages[0].content[0].text,
35
+ );
36
+ }
37
+
38
+ /**
39
+ * Stream text generation from messages using AI.
40
+ * @param messages The messages to generate text from.
41
+ * @param onMessage Callback for each message chunk.
42
+ * @param tools Optional tools to use for generation.
43
+ */
44
+ async getSteamedText(messages: Message[], onMessage: OnLLMResponse, tools?: Tool[]): Promise<void> {
45
+ streamChatGPT(this.backendUrl, messages, tools || [], onMessage, this.token);
46
+ }
47
+
48
+ /**
49
+ * Generate voice audio from text using AI.
50
+ * @param text The text to convert to voice.
51
+ * @param voice The voice to use (default: 'alloy').
52
+ * @param speed The speed of the voice (default: 1).
53
+ * @param language Optional language for the voice.
54
+ * @returns The generated audio as a Blob.
55
+ */
56
+ async getVoice(text: string, voice = 'alloy', speed = 1, language?: string): Promise<Blob> {
57
+ return getTTSResponse(this.backendUrl, { input: text, voice, speed, language }, this.token);
58
+ }
59
+
60
+ /**
61
+ * Convert voice audio to text using AI.
62
+ * @param file The audio file to convert.
63
+ * @returns The transcribed text.
64
+ */
65
+ async getTextFromVoice(file: Blob): Promise<string> {
66
+ return getSTTResponse(this.backendUrl, file, this.token);
67
+ }
68
+
69
+ /**
70
+ * Generate a structured object from a request using AI.
71
+ * @param request The object generation request.
72
+ * @returns The generated object.
73
+ */
74
+ async getObject<T = any>(request: ObjectRequest): Promise<T> {
75
+ return generateObject<T>(this.backendUrl, request, this.token);
76
+ }
77
+ }
@@ -0,0 +1,66 @@
1
+ import { PostgrestQueryBuilder } from '@supabase/postgrest-js';
2
+ import { SupabaseClient } from '@supabase/supabase-js';
3
+ import { GenericSchema } from '@supabase/supabase-js/dist/module/lib/types';
4
+ import { RimoriCommunicationHandler, RimoriInfo } from '../CommunicationHandler';
5
+
6
+ /**
7
+ * Database module for plugin database operations.
8
+ * Provides access to plugin tables with automatic prefixing and schema management.
9
+ */
10
+ export class DbModule {
11
+ private supabase: SupabaseClient;
12
+ private rimoriInfo: RimoriInfo;
13
+ public tablePrefix: string;
14
+ public schema: string;
15
+
16
+ constructor(supabase: SupabaseClient, communicationHandler: RimoriCommunicationHandler, info: RimoriInfo) {
17
+ this.supabase = supabase;
18
+ this.rimoriInfo = info;
19
+ this.tablePrefix = info.tablePrefix;
20
+ this.schema = info.dbSchema;
21
+
22
+ communicationHandler.onUpdate((updatedInfo) => {
23
+ this.rimoriInfo = updatedInfo;
24
+ this.tablePrefix = updatedInfo.tablePrefix;
25
+ this.schema = updatedInfo.dbSchema;
26
+ });
27
+ }
28
+
29
+ /**
30
+ * Query a database table.
31
+ * Global tables (starting with 'global_') remain in public schema.
32
+ * Plugin tables use the schema provided by rimori-main (plugins or plugins_alpha).
33
+ * @param relation The table name (without prefix for plugin tables, with 'global_' for global tables).
34
+ * @returns A Postgrest query builder for the table.
35
+ */
36
+ from<ViewName extends string & keyof GenericSchema['Views'], View extends GenericSchema['Views'][ViewName]>(
37
+ relation: string,
38
+ ): PostgrestQueryBuilder<GenericSchema, View, ViewName> {
39
+ const tableName = this.getTableName(relation);
40
+ // Use the schema determined by rimori-main based on release channel
41
+ // Global tables (starting with 'global_') remain in public schema
42
+ // Plugin tables use the schema provided by rimori-main (plugins or plugins_alpha)
43
+ if (relation.startsWith('global_')) {
44
+ // Global tables stay in public schema
45
+ return this.supabase.from(tableName);
46
+ }
47
+ // Plugin tables go to the schema provided by rimori-main
48
+ return this.supabase.schema(this.rimoriInfo.dbSchema).from(tableName);
49
+ }
50
+
51
+ /**
52
+ * Get the table name for a given plugin table.
53
+ * Internally all tables are prefixed with the plugin id. This function is used to get the correct table name for a given public table.
54
+ * @param table The plugin table name to get the full table name for.
55
+ * @returns The full table name.
56
+ */
57
+ getTableName(table: string): string {
58
+ if (/[A-Z]/.test(table)) {
59
+ throw new Error('Table name cannot include uppercase letters. Please use snake_case for table names.');
60
+ }
61
+ if (table.startsWith('global_')) {
62
+ return table.replace('global_', '');
63
+ }
64
+ return this.tablePrefix + '_' + table;
65
+ }
66
+ }