@rimori/client 2.4.0 → 2.5.0-next.1
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/dist/cli/scripts/init/dev-registration.js +4 -2
- package/dist/cli/scripts/init/main.js +1 -0
- package/dist/cli/scripts/release/release.js +0 -0
- package/dist/controller/SettingsController.d.ts +1 -1
- package/dist/controller/SharedContentController.d.ts +1 -1
- package/dist/fromRimori/EventBus.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/plugin/CommunicationHandler.d.ts +13 -8
- package/dist/plugin/CommunicationHandler.js +44 -59
- package/dist/plugin/RimoriClient.d.ts +11 -195
- package/dist/plugin/RimoriClient.js +16 -298
- package/dist/plugin/StandaloneClient.d.ts +1 -1
- package/dist/plugin/StandaloneClient.js +3 -2
- package/dist/plugin/module/AIModule.d.ts +49 -0
- package/dist/plugin/module/AIModule.js +81 -0
- package/dist/plugin/module/DbModule.d.ts +30 -0
- package/dist/plugin/module/DbModule.js +51 -0
- package/dist/plugin/module/EventModule.d.ts +99 -0
- package/dist/plugin/module/EventModule.js +162 -0
- package/dist/{controller/ExerciseController.d.ts → plugin/module/ExerciseModule.d.ts} +20 -16
- package/dist/{controller/ExerciseController.js → plugin/module/ExerciseModule.js} +27 -20
- package/dist/plugin/module/PluginModule.d.ts +76 -0
- package/dist/plugin/module/PluginModule.js +88 -0
- package/package.json +8 -3
- package/.github/workflows/pre-release.yml +0 -126
- package/.prettierignore +0 -35
- package/eslint.config.js +0 -53
- package/example/docs/devdocs.md +0 -241
- package/example/docs/overview.md +0 -29
- package/example/docs/userdocs.md +0 -126
- package/example/rimori.config.ts +0 -91
- package/example/worker/vite.config.ts +0 -26
- package/example/worker/worker.ts +0 -11
- package/prettier.config.js +0 -8
- package/src/cli/scripts/init/dev-registration.ts +0 -189
- package/src/cli/scripts/init/env-setup.ts +0 -44
- package/src/cli/scripts/init/file-operations.ts +0 -58
- package/src/cli/scripts/init/html-cleaner.ts +0 -45
- package/src/cli/scripts/init/main.ts +0 -175
- package/src/cli/scripts/init/package-setup.ts +0 -113
- package/src/cli/scripts/init/router-transformer.ts +0 -332
- package/src/cli/scripts/init/tailwind-config.ts +0 -66
- package/src/cli/scripts/init/vite-config.ts +0 -73
- package/src/cli/scripts/release/detect-translation-languages.ts +0 -37
- package/src/cli/scripts/release/release-config-upload.ts +0 -119
- package/src/cli/scripts/release/release-db-update.ts +0 -97
- package/src/cli/scripts/release/release-file-upload.ts +0 -138
- package/src/cli/scripts/release/release.ts +0 -85
- package/src/cli/types/DatabaseTypes.ts +0 -125
- package/src/controller/AIController.ts +0 -295
- package/src/controller/AccomplishmentController.ts +0 -188
- package/src/controller/AudioController.ts +0 -64
- package/src/controller/ExerciseController.ts +0 -117
- package/src/controller/ObjectController.ts +0 -120
- package/src/controller/SettingsController.ts +0 -186
- package/src/controller/SharedContentController.ts +0 -365
- package/src/controller/TranslationController.ts +0 -136
- package/src/controller/VoiceController.ts +0 -33
- package/src/fromRimori/EventBus.ts +0 -382
- package/src/fromRimori/PluginTypes.ts +0 -214
- package/src/fromRimori/readme.md +0 -2
- package/src/index.ts +0 -19
- package/src/plugin/CommunicationHandler.ts +0 -310
- package/src/plugin/Logger.ts +0 -394
- package/src/plugin/RimoriClient.ts +0 -530
- package/src/plugin/StandaloneClient.ts +0 -125
- package/src/utils/difficultyConverter.ts +0 -15
- package/src/utils/endpoint.ts +0 -3
- package/src/worker/WorkerSetup.ts +0 -35
- package/tsconfig.json +0 -17
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { createClient } from '@supabase/supabase-js';
|
|
10
|
+
// import { createClient } from '@supabase/supabase-js';
|
|
11
11
|
import path from 'path';
|
|
12
12
|
import * as readline from 'readline';
|
|
13
13
|
import { DEFAULT_ANON_KEY, DEFAULT_ENDPOINT } from '../../../utils/endpoint.js';
|
|
@@ -112,7 +112,9 @@ export function authenticateWithSupabase(_a) {
|
|
|
112
112
|
// Initialize Supabase client (you may need to adjust the URL and key)
|
|
113
113
|
const supabaseUrl = process.env.SUPABASE_URL || DEFAULT_ENDPOINT;
|
|
114
114
|
const supabaseKey = process.env.SUPABASE_ANON_KEY || DEFAULT_ANON_KEY;
|
|
115
|
-
|
|
115
|
+
throw new Error('Authentication is disabled until new developer platform is released.');
|
|
116
|
+
// const supabase = createClient(supabaseUrl, supabaseKey);
|
|
117
|
+
const supabase = {};
|
|
116
118
|
try {
|
|
117
119
|
const { data, error } = yield supabase.auth.signInWithPassword({
|
|
118
120
|
email,
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SupabaseClient } from '
|
|
1
|
+
import { SupabaseClient } from '../plugin/CommunicationHandler';
|
|
2
2
|
import { RimoriClient } from '../plugin/RimoriClient';
|
|
3
3
|
import { ObjectRequest } from './ObjectController';
|
|
4
4
|
export interface SharedContentObjectRequest extends ObjectRequest {
|
|
@@ -106,7 +106,7 @@ export class EventBusHandler {
|
|
|
106
106
|
const blackListedEventIds = [];
|
|
107
107
|
const eventHandler = (data) => {
|
|
108
108
|
if (blackListedEventIds.some((item) => item.eventId === data.eventId && item.sender === data.sender)) {
|
|
109
|
-
console.log('BLACKLISTED EVENT ID', data.eventId, data);
|
|
109
|
+
// console.log('BLACKLISTED EVENT ID', data.eventId, data);
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
blackListedEventIds.push({
|
package/dist/index.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ export { AudioController } from './controller/AudioController';
|
|
|
10
10
|
export { Translator } from './controller/TranslationController';
|
|
11
11
|
export type { TOptions } from 'i18next';
|
|
12
12
|
export type { SharedContent, SharedContentObjectRequest } from './controller/SharedContentController';
|
|
13
|
-
export type { Exercise } from './
|
|
13
|
+
export type { Exercise } from './plugin/module/ExerciseModule';
|
|
14
14
|
export type { UserInfo, Language, UserRole } from './controller/SettingsController';
|
|
15
15
|
export type { Message, ToolInvocation } from './controller/AIController';
|
|
16
|
-
export type { TriggerAction } from './
|
|
16
|
+
export type { TriggerAction } from './plugin/module/ExerciseModule';
|
|
17
17
|
export type { MacroAccomplishmentPayload, MicroAccomplishmentPayload } from './controller/AccomplishmentController';
|
|
18
18
|
export type { EventBusMessage } from './fromRimori/EventBus';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
1
|
import { UserInfo } from '../controller/SettingsController';
|
|
3
2
|
import { ActivePlugin, Plugin } from '../fromRimori/PluginTypes';
|
|
3
|
+
import { PostgrestClient } from '@supabase/postgrest-js';
|
|
4
|
+
export type SupabaseClient = PostgrestClient;
|
|
4
5
|
export interface Guild {
|
|
5
6
|
allowUserPluginSettings: boolean;
|
|
6
7
|
city: string | null;
|
|
@@ -47,22 +48,26 @@ export declare class RimoriCommunicationHandler {
|
|
|
47
48
|
private pluginId;
|
|
48
49
|
private isMessageChannelReady;
|
|
49
50
|
private pendingRequests;
|
|
51
|
+
private updateCallbacks;
|
|
50
52
|
constructor(pluginId: string, standalone: boolean);
|
|
51
53
|
private initMessageChannel;
|
|
52
54
|
private sendHello;
|
|
53
55
|
private sendFinishedInit;
|
|
54
56
|
getQueryParam(key: string): string | null;
|
|
57
|
+
private getSupabase;
|
|
55
58
|
getClient(): Promise<{
|
|
56
59
|
supabase: SupabaseClient;
|
|
57
60
|
info: RimoriInfo;
|
|
58
61
|
}>;
|
|
59
|
-
getToken(): Promise<string>;
|
|
60
62
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* @deprecated All endpoints should use the backend URL instead.
|
|
63
|
+
* Handles updates to RimoriInfo from rimori-main.
|
|
64
|
+
* Updates the cached info and Supabase client, then notifies all registered callbacks.
|
|
64
65
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
private handleRimoriInfoUpdate;
|
|
67
|
+
/**
|
|
68
|
+
* Registers a callback to be called when RimoriInfo is updated.
|
|
69
|
+
* @param callback - Function to call with the new RimoriInfo
|
|
70
|
+
* @returns Cleanup function to unregister the callback
|
|
71
|
+
*/
|
|
72
|
+
onUpdate(callback: (info: RimoriInfo) => void): () => void;
|
|
68
73
|
}
|
|
@@ -7,8 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { createClient } from '@supabase/supabase-js';
|
|
11
10
|
import { EventBus } from '../fromRimori/EventBus';
|
|
11
|
+
import { PostgrestClient } from '@supabase/postgrest-js';
|
|
12
12
|
export class RimoriCommunicationHandler {
|
|
13
13
|
constructor(pluginId, standalone) {
|
|
14
14
|
this.port = null;
|
|
@@ -17,6 +17,7 @@ export class RimoriCommunicationHandler {
|
|
|
17
17
|
this.rimoriInfo = null;
|
|
18
18
|
this.isMessageChannelReady = false;
|
|
19
19
|
this.pendingRequests = [];
|
|
20
|
+
this.updateCallbacks = new Set();
|
|
20
21
|
this.pluginId = pluginId;
|
|
21
22
|
this.getClient = this.getClient.bind(this);
|
|
22
23
|
//no need to forward messages to parent in standalone mode or worker context
|
|
@@ -44,9 +45,7 @@ export class RimoriCommunicationHandler {
|
|
|
44
45
|
// Initialize Supabase client immediately with provided info
|
|
45
46
|
if (rimoriInfo) {
|
|
46
47
|
this.rimoriInfo = rimoriInfo;
|
|
47
|
-
this.supabase =
|
|
48
|
-
accessToken: () => Promise.resolve(rimoriInfo.token),
|
|
49
|
-
});
|
|
48
|
+
this.supabase = this.getSupabase(rimoriInfo.url, rimoriInfo.key, rimoriInfo.token);
|
|
50
49
|
}
|
|
51
50
|
// Handle messages from parent
|
|
52
51
|
this.port.onmessage = ({ data }) => {
|
|
@@ -78,6 +77,12 @@ export class RimoriCommunicationHandler {
|
|
|
78
77
|
(_a = this.port) === null || _a === void 0 ? void 0 : _a.postMessage({ event: ev });
|
|
79
78
|
}
|
|
80
79
|
});
|
|
80
|
+
// Listen for updates from rimori-main (data changes, token refresh, etc.)
|
|
81
|
+
// Topic format: {pluginId}.supabase.triggerUpdate
|
|
82
|
+
EventBus.on(`${this.pluginId}.supabase.triggerUpdate`, (ev) => {
|
|
83
|
+
console.log('[RimoriCommunicationHandler] Received update from rimori-main');
|
|
84
|
+
this.handleRimoriInfoUpdate(ev.data);
|
|
85
|
+
});
|
|
81
86
|
// Mark MessageChannel as ready and process pending requests
|
|
82
87
|
this.isMessageChannelReady = true;
|
|
83
88
|
// Process any pending requests
|
|
@@ -126,6 +131,16 @@ export class RimoriCommunicationHandler {
|
|
|
126
131
|
getQueryParam(key) {
|
|
127
132
|
return this.queryParams[key] || null;
|
|
128
133
|
}
|
|
134
|
+
getSupabase(url, key, token) {
|
|
135
|
+
var _a;
|
|
136
|
+
return new PostgrestClient(`${url}/rest/v1`, {
|
|
137
|
+
schema: (_a = this.rimoriInfo) === null || _a === void 0 ? void 0 : _a.dbSchema,
|
|
138
|
+
headers: {
|
|
139
|
+
apikey: key,
|
|
140
|
+
Authorization: `Bearer ${token}`,
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
}
|
|
129
144
|
getClient() {
|
|
130
145
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
146
|
// Return cached client if valid
|
|
@@ -167,9 +182,7 @@ export class RimoriCommunicationHandler {
|
|
|
167
182
|
var _a, _b;
|
|
168
183
|
if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.topic) === 'global.supabase.requestAccess' && ((_b = event.data) === null || _b === void 0 ? void 0 : _b.eventId) === eventId) {
|
|
169
184
|
this.rimoriInfo = event.data.data;
|
|
170
|
-
this.supabase =
|
|
171
|
-
accessToken: () => Promise.resolve(this.getToken()),
|
|
172
|
-
});
|
|
185
|
+
this.supabase = this.getSupabase(this.rimoriInfo.url, this.rimoriInfo.key, this.rimoriInfo.token);
|
|
173
186
|
self.onmessage = originalOnMessage; // Restore original handler
|
|
174
187
|
resolve({ supabase: this.supabase, info: this.rimoriInfo });
|
|
175
188
|
}
|
|
@@ -186,68 +199,40 @@ export class RimoriCommunicationHandler {
|
|
|
186
199
|
const { data } = yield EventBus.request(this.pluginId, 'global.supabase.requestAccess');
|
|
187
200
|
// console.log({ data });
|
|
188
201
|
this.rimoriInfo = data;
|
|
189
|
-
this.supabase =
|
|
190
|
-
accessToken: () => Promise.resolve(this.getToken()),
|
|
191
|
-
});
|
|
202
|
+
this.supabase = this.getSupabase(this.rimoriInfo.url, this.rimoriInfo.key, this.rimoriInfo.token);
|
|
192
203
|
}
|
|
193
204
|
}
|
|
194
205
|
return { supabase: this.supabase, info: this.rimoriInfo };
|
|
195
206
|
});
|
|
196
207
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
208
|
+
/**
|
|
209
|
+
* Handles updates to RimoriInfo from rimori-main.
|
|
210
|
+
* Updates the cached info and Supabase client, then notifies all registered callbacks.
|
|
211
|
+
*/
|
|
212
|
+
handleRimoriInfoUpdate(newInfo) {
|
|
213
|
+
// Update cached rimoriInfo
|
|
214
|
+
this.rimoriInfo = newInfo;
|
|
215
|
+
// Update Supabase client with new token
|
|
216
|
+
this.supabase = this.getSupabase(newInfo.url, newInfo.key, newInfo.token);
|
|
217
|
+
// Notify all registered callbacks
|
|
218
|
+
this.updateCallbacks.forEach((callback) => {
|
|
219
|
+
try {
|
|
220
|
+
callback(newInfo);
|
|
201
221
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const { data } = yield EventBus.request(this.pluginId, 'global.supabase.requestAccess');
|
|
205
|
-
this.rimoriInfo = data;
|
|
206
|
-
return this.rimoriInfo.token;
|
|
222
|
+
catch (error) {
|
|
223
|
+
console.error('[RimoriCommunicationHandler] Error in update callback:', error);
|
|
207
224
|
}
|
|
208
|
-
// If token is expired, request fresh access
|
|
209
|
-
const { data } = yield EventBus.request(this.pluginId, 'global.supabase.requestAccess');
|
|
210
|
-
this.rimoriInfo.token = data.token;
|
|
211
|
-
this.rimoriInfo.expiration = data.expiration;
|
|
212
|
-
return this.rimoriInfo.token;
|
|
213
225
|
});
|
|
214
226
|
}
|
|
215
227
|
/**
|
|
216
|
-
*
|
|
217
|
-
* @
|
|
218
|
-
* @
|
|
228
|
+
* Registers a callback to be called when RimoriInfo is updated.
|
|
229
|
+
* @param callback - Function to call with the new RimoriInfo
|
|
230
|
+
* @returns Cleanup function to unregister the callback
|
|
219
231
|
*/
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
getBackendUrl() {
|
|
227
|
-
if (!this.rimoriInfo) {
|
|
228
|
-
throw new Error('Rimori info not found');
|
|
229
|
-
}
|
|
230
|
-
return this.rimoriInfo.backendUrl;
|
|
231
|
-
}
|
|
232
|
-
getGlobalEventTopic(preliminaryTopic) {
|
|
233
|
-
var _a, _b;
|
|
234
|
-
if (preliminaryTopic.startsWith('global.')) {
|
|
235
|
-
return preliminaryTopic;
|
|
236
|
-
}
|
|
237
|
-
if (preliminaryTopic.startsWith('self.')) {
|
|
238
|
-
return preliminaryTopic;
|
|
239
|
-
}
|
|
240
|
-
const topicParts = preliminaryTopic.split('.');
|
|
241
|
-
if (topicParts.length === 3) {
|
|
242
|
-
if (!topicParts[0].startsWith('pl') && topicParts[0] !== 'global') {
|
|
243
|
-
throw new Error("The event topic must start with the plugin id or 'global'.");
|
|
244
|
-
}
|
|
245
|
-
return preliminaryTopic;
|
|
246
|
-
}
|
|
247
|
-
else if (topicParts.length > 3) {
|
|
248
|
-
throw new Error(`The event topic must consist of 3 parts. <pluginId>.<topic area>.<action>. Received: ${preliminaryTopic}`);
|
|
249
|
-
}
|
|
250
|
-
const topicRoot = (_b = (_a = this.rimoriInfo) === null || _a === void 0 ? void 0 : _a.pluginId) !== null && _b !== void 0 ? _b : 'global';
|
|
251
|
-
return `${topicRoot}.${preliminaryTopic}`;
|
|
232
|
+
onUpdate(callback) {
|
|
233
|
+
this.updateCallbacks.add(callback);
|
|
234
|
+
return () => {
|
|
235
|
+
this.updateCallbacks.delete(callback);
|
|
236
|
+
};
|
|
252
237
|
}
|
|
253
238
|
}
|
|
@@ -1,191 +1,31 @@
|
|
|
1
|
-
import { PostgrestQueryBuilder } from '@supabase/postgrest-js';
|
|
2
|
-
import { GenericSchema } from '@supabase/supabase-js/dist/module/lib/types';
|
|
3
|
-
import { Message, OnLLMResponse } from '../controller/AIController';
|
|
4
|
-
import { ObjectRequest } from '../controller/ObjectController';
|
|
5
|
-
import { UserInfo } from '../controller/SettingsController';
|
|
6
1
|
import { SharedContent, SharedContentFilter, SharedContentObjectRequest } from '../controller/SharedContentController';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
2
|
+
import { PluginModule } from './module/PluginModule';
|
|
3
|
+
import { DbModule } from './module/DbModule';
|
|
4
|
+
import { EventModule } from './module/EventModule';
|
|
5
|
+
import { AIModule } from './module/AIModule';
|
|
6
|
+
import { ExerciseModule } from './module/ExerciseModule';
|
|
12
7
|
export declare class RimoriClient {
|
|
13
8
|
private static instance;
|
|
14
|
-
private superbase;
|
|
15
9
|
private pluginController;
|
|
16
|
-
private settingsController;
|
|
17
10
|
private sharedContentController;
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
db: DbModule;
|
|
12
|
+
event: EventModule;
|
|
13
|
+
plugin: PluginModule;
|
|
14
|
+
ai: AIModule;
|
|
15
|
+
exercise: ExerciseModule;
|
|
20
16
|
private rimoriInfo;
|
|
21
|
-
private translator;
|
|
22
17
|
private constructor();
|
|
23
|
-
get plugin(): {
|
|
24
|
-
pluginId: string;
|
|
25
|
-
/**
|
|
26
|
-
* The release channel of this plugin installation.
|
|
27
|
-
* Determines which database schema is used for plugin tables.
|
|
28
|
-
*/
|
|
29
|
-
releaseChannel: "alpha" | "beta" | "stable";
|
|
30
|
-
/**
|
|
31
|
-
* Set the settings for the plugin.
|
|
32
|
-
* @param settings The settings to set.
|
|
33
|
-
*/
|
|
34
|
-
setSettings: (settings: any) => Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Get the settings for the plugin. T can be any type of settings, UserSettings or SystemSettings.
|
|
37
|
-
* @param defaultSettings The default settings to use if no settings are found.
|
|
38
|
-
* @param genericSettings The type of settings to get.
|
|
39
|
-
* @returns The settings for the plugin.
|
|
40
|
-
*/
|
|
41
|
-
getSettings: <T extends object>(defaultSettings: T) => Promise<T>;
|
|
42
|
-
getUserInfo: () => UserInfo;
|
|
43
|
-
/**
|
|
44
|
-
* Retrieves information about plugins, including:
|
|
45
|
-
* - All installed plugins
|
|
46
|
-
* - The currently active plugin in the main panel
|
|
47
|
-
* - The currently active plugin in the side panel
|
|
48
|
-
*/
|
|
49
|
-
getPluginInfo: () => {
|
|
50
|
-
/**
|
|
51
|
-
* All installed plugins.
|
|
52
|
-
*/
|
|
53
|
-
installedPlugins: Plugin[];
|
|
54
|
-
/**
|
|
55
|
-
* The plugin that is loaded in the main panel.
|
|
56
|
-
*/
|
|
57
|
-
mainPanelPlugin?: ActivePlugin;
|
|
58
|
-
/**
|
|
59
|
-
* The plugin that is loaded in the side panel.
|
|
60
|
-
*/
|
|
61
|
-
sidePanelPlugin?: ActivePlugin;
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Get the translator for the plugin.
|
|
65
|
-
* @returns The translator for the plugin.
|
|
66
|
-
*/
|
|
67
|
-
getTranslator: () => Promise<Translator>;
|
|
68
|
-
};
|
|
69
|
-
get db(): {
|
|
70
|
-
from: <ViewName extends string & keyof GenericSchema["Views"], View extends GenericSchema["Views"][ViewName]>(relation: string) => PostgrestQueryBuilder<GenericSchema, View, ViewName>;
|
|
71
|
-
/**
|
|
72
|
-
* The table prefix for of database tables of the plugin.
|
|
73
|
-
*/
|
|
74
|
-
tablePrefix: string;
|
|
75
|
-
/**
|
|
76
|
-
* The database schema used for plugin tables.
|
|
77
|
-
* Determined by rimori-main based on release channel:
|
|
78
|
-
* - 'plugins_alpha' for alpha release channel
|
|
79
|
-
* - 'plugins' for beta and stable release channels
|
|
80
|
-
*/
|
|
81
|
-
schema: "plugins" | "plugins_alpha";
|
|
82
|
-
/**
|
|
83
|
-
* Get the table name for a given plugin table.
|
|
84
|
-
* Internally all tables are prefixed with the plugin id. This function is used to get the correct table name for a given public table.
|
|
85
|
-
* @param table The plugin table name to get the full table name for.
|
|
86
|
-
* @returns The full table name.
|
|
87
|
-
*/
|
|
88
|
-
getTableName: (table: string) => string;
|
|
89
|
-
};
|
|
90
|
-
event: {
|
|
91
|
-
/**
|
|
92
|
-
* Emit an event to Rimori or a plugin.
|
|
93
|
-
* The topic schema is:
|
|
94
|
-
* {pluginId}.{eventId}
|
|
95
|
-
* Check out the event bus documentation for more information.
|
|
96
|
-
* For triggering events from Rimori like context menu actions use the "global" keyword.
|
|
97
|
-
* @param topic The topic to emit the event on.
|
|
98
|
-
* @param data The data to emit.
|
|
99
|
-
* @param eventId The event id.
|
|
100
|
-
*/
|
|
101
|
-
emit: (topic: string, data?: any, eventId?: number) => void;
|
|
102
|
-
/**
|
|
103
|
-
* Request an event.
|
|
104
|
-
* @param topic The topic to request the event on.
|
|
105
|
-
* @param data The data to request.
|
|
106
|
-
* @returns The response from the event.
|
|
107
|
-
*/
|
|
108
|
-
request: <T>(topic: string, data?: any) => Promise<EventBusMessage<T>>;
|
|
109
|
-
/**
|
|
110
|
-
* Subscribe to an event.
|
|
111
|
-
* @param topic The topic to subscribe to.
|
|
112
|
-
* @param callback The callback to call when the event is emitted.
|
|
113
|
-
* @returns An EventListener object containing an off() method to unsubscribe the listeners.
|
|
114
|
-
*/
|
|
115
|
-
on: <T = EventPayload>(topic: string | string[], callback: EventHandler<T>) => EventListener;
|
|
116
|
-
/**
|
|
117
|
-
* Subscribe to an event once.
|
|
118
|
-
* @param topic The topic to subscribe to.
|
|
119
|
-
* @param callback The callback to call when the event is emitted.
|
|
120
|
-
*/
|
|
121
|
-
once: <T = EventPayload>(topic: string, callback: EventHandler<T>) => void;
|
|
122
|
-
/**
|
|
123
|
-
* Respond to an event.
|
|
124
|
-
* @param topic The topic to respond to.
|
|
125
|
-
* @param data The data to respond with.
|
|
126
|
-
*/
|
|
127
|
-
respond: <T = EventPayload>(topic: string | string[], data: EventPayload | ((data: EventBusMessage<T>) => EventPayload | Promise<EventPayload>)) => void;
|
|
128
|
-
/**
|
|
129
|
-
* Emit an accomplishment.
|
|
130
|
-
* @param payload The payload to emit.
|
|
131
|
-
*/
|
|
132
|
-
emitAccomplishment: (payload: AccomplishmentPayload) => void;
|
|
133
|
-
/**
|
|
134
|
-
* Subscribe to an accomplishment.
|
|
135
|
-
* @param accomplishmentTopic The topic to subscribe to.
|
|
136
|
-
* @param callback The callback to call when the accomplishment is emitted.
|
|
137
|
-
*/
|
|
138
|
-
onAccomplishment: (accomplishmentTopic: string, callback: (payload: EventBusMessage<AccomplishmentPayload>) => void) => void;
|
|
139
|
-
/**
|
|
140
|
-
* Trigger an action that opens the sidebar and triggers an action in the designated plugin.
|
|
141
|
-
* @param pluginId The id of the plugin to trigger the action for.
|
|
142
|
-
* @param actionKey The key of the action to trigger.
|
|
143
|
-
* @param text Optional text to be used for the action like for example text that the translator would look up.
|
|
144
|
-
*/
|
|
145
|
-
emitSidebarAction: (pluginId: string, actionKey: string, text?: string) => void;
|
|
146
|
-
/**
|
|
147
|
-
* Subscribe to main panel actions triggered by the user from the dashboard.
|
|
148
|
-
* @param callback Handler function that receives the action data when a matching action is triggered.
|
|
149
|
-
* @param actionsToListen Optional filter to listen only to specific action keys. If empty or not provided, all actions will trigger the callback.
|
|
150
|
-
* @returns An EventListener object with an `off()` method for cleanup.
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* ```ts
|
|
154
|
-
* const listener = client.event.onMainPanelAction((data) => {
|
|
155
|
-
* console.log('Action received:', data.action_key);
|
|
156
|
-
* }, ['startSession', 'pauseSession']);
|
|
157
|
-
*
|
|
158
|
-
* // Clean up when component unmounts to prevent events from firing
|
|
159
|
-
* // when navigating away or returning to the page
|
|
160
|
-
* useEffect(() => {
|
|
161
|
-
* return () => listener.off();
|
|
162
|
-
* }, []);
|
|
163
|
-
* ```
|
|
164
|
-
*
|
|
165
|
-
* **Important:** Always call `listener.off()` when your component unmounts or when you no longer need to listen.
|
|
166
|
-
* This prevents the event handler from firing when navigating away from or returning to the page, which could
|
|
167
|
-
* cause unexpected behavior or duplicate event handling.
|
|
168
|
-
*/
|
|
169
|
-
onMainPanelAction: (callback: (data: MainPanelAction) => void, actionsToListen?: string | string[]) => EventListener;
|
|
170
|
-
onSidePanelAction: (callback: (data: MainPanelAction) => void, actionsToListen?: string | string[]) => EventListener;
|
|
171
|
-
};
|
|
172
18
|
navigation: {
|
|
173
19
|
toDashboard: () => void;
|
|
174
20
|
};
|
|
175
21
|
/**
|
|
176
22
|
* Get a query parameter value that was passed via MessageChannel
|
|
177
23
|
* @param key The query parameter key
|
|
24
|
+
* @deprecated Use the plugin.applicationMode and plugin.theme properties instead
|
|
178
25
|
* @returns The query parameter value or null if not found
|
|
179
26
|
*/
|
|
180
27
|
getQueryParam(key: string): string | null;
|
|
181
28
|
static getInstance(pluginId?: string): Promise<RimoriClient>;
|
|
182
|
-
ai: {
|
|
183
|
-
getText: (messages: Message[], tools?: Tool[]) => Promise<string>;
|
|
184
|
-
getSteamedText: (messages: Message[], onMessage: OnLLMResponse, tools?: Tool[]) => Promise<void>;
|
|
185
|
-
getVoice: (text: string, voice?: string, speed?: number, language?: string) => Promise<Blob>;
|
|
186
|
-
getTextFromVoice: (file: Blob) => Promise<string>;
|
|
187
|
-
getObject: <T = any>(request: ObjectRequest) => Promise<T>;
|
|
188
|
-
};
|
|
189
29
|
runtime: {
|
|
190
30
|
fetchBackend: (url: string, options: RequestInit) => Promise<Response>;
|
|
191
31
|
};
|
|
@@ -268,28 +108,4 @@ export declare class RimoriClient {
|
|
|
268
108
|
remove: (id: string) => Promise<SharedContent<any>>;
|
|
269
109
|
};
|
|
270
110
|
};
|
|
271
|
-
exercise: {
|
|
272
|
-
/**
|
|
273
|
-
* Fetches weekly exercises from the weekly_exercises view.
|
|
274
|
-
* Shows exercises for the current week that haven't expired.
|
|
275
|
-
* @returns Array of exercise objects.
|
|
276
|
-
*/
|
|
277
|
-
view: () => Promise<import("../controller/ExerciseController").Exercise[]>;
|
|
278
|
-
/**
|
|
279
|
-
* Creates a new exercise or multiple exercises via the backend API.
|
|
280
|
-
* When creating multiple exercises, all requests are made in parallel but only one event is emitted.
|
|
281
|
-
* @param params Exercise creation parameters (single or array).
|
|
282
|
-
* @returns Created exercise objects.
|
|
283
|
-
*/
|
|
284
|
-
add: (params: CreateExerciseParams | CreateExerciseParams[]) => Promise<import("../controller/ExerciseController").Exercise[]>;
|
|
285
|
-
/**
|
|
286
|
-
* Deletes an exercise via the backend API.
|
|
287
|
-
* @param id The exercise ID to delete.
|
|
288
|
-
* @returns Success status.
|
|
289
|
-
*/
|
|
290
|
-
delete: (id: string) => Promise<{
|
|
291
|
-
success: boolean;
|
|
292
|
-
message: string;
|
|
293
|
-
}>;
|
|
294
|
-
};
|
|
295
111
|
}
|