@rimori/client 2.4.0-next.6 → 2.4.0-next.7

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.
Files changed (53) hide show
  1. package/package.json +5 -1
  2. package/.github/workflows/create-release-branch.yml +0 -226
  3. package/.github/workflows/pre-release.yml +0 -126
  4. package/.github/workflows/release-on-merge.yml +0 -195
  5. package/.prettierignore +0 -35
  6. package/eslint.config.js +0 -53
  7. package/example/docs/devdocs.md +0 -241
  8. package/example/docs/overview.md +0 -29
  9. package/example/docs/userdocs.md +0 -126
  10. package/example/rimori.config.ts +0 -91
  11. package/example/worker/vite.config.ts +0 -26
  12. package/example/worker/worker.ts +0 -11
  13. package/prettier.config.js +0 -8
  14. package/src/cli/scripts/init/dev-registration.ts +0 -191
  15. package/src/cli/scripts/init/env-setup.ts +0 -44
  16. package/src/cli/scripts/init/file-operations.ts +0 -58
  17. package/src/cli/scripts/init/html-cleaner.ts +0 -45
  18. package/src/cli/scripts/init/main.ts +0 -176
  19. package/src/cli/scripts/init/package-setup.ts +0 -113
  20. package/src/cli/scripts/init/router-transformer.ts +0 -332
  21. package/src/cli/scripts/init/tailwind-config.ts +0 -66
  22. package/src/cli/scripts/init/vite-config.ts +0 -73
  23. package/src/cli/scripts/release/detect-translation-languages.ts +0 -37
  24. package/src/cli/scripts/release/release-config-upload.ts +0 -119
  25. package/src/cli/scripts/release/release-db-update.ts +0 -97
  26. package/src/cli/scripts/release/release-file-upload.ts +0 -138
  27. package/src/cli/scripts/release/release.ts +0 -85
  28. package/src/cli/types/DatabaseTypes.ts +0 -125
  29. package/src/controller/AIController.ts +0 -295
  30. package/src/controller/AccomplishmentController.ts +0 -188
  31. package/src/controller/AudioController.ts +0 -64
  32. package/src/controller/ObjectController.ts +0 -120
  33. package/src/controller/SettingsController.ts +0 -186
  34. package/src/controller/SharedContentController.ts +0 -365
  35. package/src/controller/TranslationController.ts +0 -136
  36. package/src/controller/VoiceController.ts +0 -33
  37. package/src/fromRimori/EventBus.ts +0 -382
  38. package/src/fromRimori/PluginTypes.ts +0 -214
  39. package/src/fromRimori/readme.md +0 -2
  40. package/src/index.ts +0 -19
  41. package/src/plugin/CommunicationHandler.ts +0 -291
  42. package/src/plugin/Logger.ts +0 -394
  43. package/src/plugin/RimoriClient.ts +0 -199
  44. package/src/plugin/StandaloneClient.ts +0 -127
  45. package/src/plugin/module/AIModule.ts +0 -77
  46. package/src/plugin/module/DbModule.ts +0 -67
  47. package/src/plugin/module/EventModule.ts +0 -192
  48. package/src/plugin/module/ExerciseModule.ts +0 -131
  49. package/src/plugin/module/PluginModule.ts +0 -114
  50. package/src/utils/difficultyConverter.ts +0 -15
  51. package/src/utils/endpoint.ts +0 -3
  52. package/src/worker/WorkerSetup.ts +0 -35
  53. package/tsconfig.json +0 -17
@@ -1,131 +0,0 @@
1
- import { SupabaseClient } from '../CommunicationHandler';
2
- import { RimoriCommunicationHandler, RimoriInfo } from '../CommunicationHandler';
3
- import { EventModule } from './EventModule';
4
-
5
- export type TriggerAction = { action_key: string } & Record<string, string | number | boolean>;
6
-
7
- export interface CreateExerciseParams {
8
- plugin_id: string;
9
- start_date: string;
10
- end_date: string;
11
- trigger_action: TriggerAction;
12
- name: string;
13
- description: string;
14
- estimated_duration: number;
15
- achievement_topic: string; // Required: Topic in format "skillCategory.accomplishmentKeyword" for matching accomplishments
16
- }
17
-
18
- export interface Exercise {
19
- id: string;
20
- plugin_id: string;
21
- start_date: string;
22
- end_date: string;
23
- trigger_action: TriggerAction;
24
- achievement_topic: string;
25
- name: string;
26
- description: string;
27
- estimated_duration: number;
28
- created_at?: string;
29
- updated_at?: string;
30
- }
31
-
32
- /**
33
- * Controller for exercise-related operations.
34
- * Provides access to weekly exercises and exercise management.
35
- */
36
- export class ExerciseModule {
37
- private supabase: SupabaseClient;
38
- private communicationHandler: RimoriCommunicationHandler;
39
- private eventModule: EventModule;
40
- private backendUrl: string;
41
- private token: string;
42
-
43
- constructor(
44
- supabase: SupabaseClient,
45
- communicationHandler: RimoriCommunicationHandler,
46
- info: RimoriInfo,
47
- eventModule: EventModule,
48
- ) {
49
- this.supabase = supabase;
50
- this.communicationHandler = communicationHandler;
51
- this.eventModule = eventModule;
52
- this.token = info.token;
53
- this.backendUrl = info.backendUrl;
54
-
55
- this.communicationHandler.onUpdate((updatedInfo) => {
56
- this.token = updatedInfo.token;
57
- });
58
- }
59
-
60
- /**
61
- * Fetches weekly exercises from the weekly_exercises view.
62
- * Shows exercises for the current week that haven't expired.
63
- * @returns Array of exercise objects.
64
- */
65
- async view(): Promise<Exercise[]> {
66
- const { data, error } = await this.supabase.from('weekly_exercises').select('*');
67
-
68
- if (error) {
69
- throw new Error(`Failed to fetch weekly exercises: ${error.message}`);
70
- }
71
-
72
- return data || [];
73
- }
74
-
75
- /**
76
- * Creates a new exercise or multiple exercises via the backend API.
77
- * When creating multiple exercises, all requests are made in parallel but only one event is emitted.
78
- * @param params Exercise creation parameters (single or array).
79
- * @returns Created exercise objects.
80
- */
81
- async add(params: CreateExerciseParams | CreateExerciseParams[]): Promise<Exercise[]> {
82
- const exercises = Array.isArray(params) ? params : [params];
83
-
84
- const responses = await Promise.all(
85
- exercises.map(async (exercise) => {
86
- const response = await fetch(`${this.backendUrl}/exercises`, {
87
- method: 'POST',
88
- headers: {
89
- 'Content-Type': 'application/json',
90
- Authorization: `Bearer ${this.token}`,
91
- },
92
- body: JSON.stringify(exercise),
93
- });
94
-
95
- if (!response.ok) {
96
- const errorText = await response.text();
97
- throw new Error(`Failed to create exercise: ${errorText}`);
98
- }
99
-
100
- return await response.json();
101
- }),
102
- );
103
-
104
- this.eventModule.emit('global.exercises.triggerChange');
105
-
106
- return responses;
107
- }
108
-
109
- /**
110
- * Deletes an exercise via the backend API.
111
- * @param id The exercise ID to delete.
112
- * @returns Success status.
113
- */
114
- async delete(id: string): Promise<{ success: boolean; message: string }> {
115
- const response = await fetch(`${this.backendUrl}/exercises/${id}`, {
116
- method: 'DELETE',
117
- headers: {
118
- Authorization: `Bearer ${this.token}`,
119
- },
120
- });
121
-
122
- if (!response.ok) {
123
- const errorText = await response.text();
124
- throw new Error(`Failed to delete exercise: ${errorText}`);
125
- }
126
-
127
- this.eventModule.emit('global.exercises.triggerChange');
128
-
129
- return await response.json();
130
- }
131
- }
@@ -1,114 +0,0 @@
1
- import { SettingsController, UserInfo } from '../../controller/SettingsController';
2
- import { RimoriCommunicationHandler, RimoriInfo } from '../CommunicationHandler';
3
- import { Translator } from '../../controller/TranslationController';
4
- import { ActivePlugin, Plugin } from '../../fromRimori/PluginTypes';
5
- import { SupabaseClient } from '../CommunicationHandler';
6
-
7
- type Theme = 'light' | 'dark';
8
- type ApplicationMode = 'main' | 'sidebar' | 'settings';
9
- /**
10
- * Controller for plugin-related operations.
11
- * Provides access to plugin settings, user info, and plugin information.
12
- */
13
- export class PluginModule {
14
- private settingsController: SettingsController;
15
- private communicationHandler: RimoriCommunicationHandler;
16
- private translator: Translator;
17
- private rimoriInfo: RimoriInfo;
18
- public pluginId: string;
19
- /**
20
- * The release channel of this plugin installation.
21
- * Determines which database schema is used for plugin tables.
22
- */
23
- public releaseChannel: string;
24
- public applicationMode: ApplicationMode;
25
- public theme: Theme;
26
-
27
- constructor(supabase: SupabaseClient, communicationHandler: RimoriCommunicationHandler, info: RimoriInfo) {
28
- this.rimoriInfo = info;
29
- this.communicationHandler = communicationHandler;
30
- this.pluginId = info.pluginId;
31
- this.releaseChannel = info.releaseChannel;
32
-
33
- this.settingsController = new SettingsController(supabase, info.pluginId, info.guild);
34
-
35
- const currentPlugin = info.installedPlugins.find((plugin) => plugin.id === info.pluginId);
36
- this.translator = new Translator(info.interfaceLanguage, currentPlugin?.endpoint || '');
37
-
38
- this.communicationHandler.onUpdate((updatedInfo) => (this.rimoriInfo = updatedInfo));
39
- this.applicationMode = this.communicationHandler.getQueryParam('applicationMode') as ApplicationMode;
40
- this.theme = (this.communicationHandler.getQueryParam('rm_theme') as Theme) || 'light';
41
- }
42
-
43
- /**
44
- * Set the settings for the plugin.
45
- * @param settings The settings to set.
46
- */
47
- async setSettings(settings: any): Promise<void> {
48
- await this.settingsController.setSettings(settings);
49
- }
50
-
51
- /**
52
- * Get the settings for the plugin. T can be any type of settings, UserSettings or SystemSettings.
53
- * @param defaultSettings The default settings to use if no settings are found.
54
- * @returns The settings for the plugin.
55
- */
56
- async getSettings<T extends object>(defaultSettings: T): Promise<T> {
57
- return await this.settingsController.getSettings<T>(defaultSettings);
58
- }
59
-
60
- /**
61
- * Get the current user info.
62
- * Note: For reactive updates in React components, use the userInfo from useRimori() hook instead.
63
- * @returns The user info.
64
- */
65
- getUserInfo(): UserInfo {
66
- return this.rimoriInfo.profile;
67
- }
68
-
69
- /**
70
- * Register a callback to be notified when RimoriInfo is updated.
71
- * This is useful for reacting to changes in user info, tokens, or other rimori data.
72
- * @param callback - Function to call with the new RimoriInfo
73
- * @returns Cleanup function to unregister the callback
74
- */
75
- onRimoriInfoUpdate(callback: (info: RimoriInfo) => void): () => void {
76
- return this.communicationHandler.onUpdate(callback);
77
- }
78
-
79
- /**
80
- * Retrieves information about plugins, including:
81
- * - All installed plugins
82
- * - The currently active plugin in the main panel
83
- * - The currently active plugin in the side panel
84
- */
85
- getPluginInfo(): {
86
- /**
87
- * All installed plugins.
88
- */
89
- installedPlugins: Plugin[];
90
- /**
91
- * The plugin that is loaded in the main panel.
92
- */
93
- mainPanelPlugin?: ActivePlugin;
94
- /**
95
- * The plugin that is loaded in the side panel.
96
- */
97
- sidePanelPlugin?: ActivePlugin;
98
- } {
99
- return {
100
- installedPlugins: this.rimoriInfo.installedPlugins,
101
- mainPanelPlugin: this.rimoriInfo.mainPanelPlugin,
102
- sidePanelPlugin: this.rimoriInfo.sidePanelPlugin,
103
- };
104
- }
105
-
106
- /**
107
- * Get the translator for the plugin.
108
- * @returns The translator for the plugin.
109
- */
110
- async getTranslator(): Promise<Translator> {
111
- await this.translator.initialize();
112
- return this.translator;
113
- }
114
- }
@@ -1,15 +0,0 @@
1
- const codes = ['Pre-A1', 'A1', 'A2', 'B1', 'B2', 'C1', 'C2', 'Post-C2'];
2
-
3
- export type LanguageLevel = 'Pre-A1' | 'A1' | 'A2' | 'B1' | 'B2' | 'C1' | 'C2' | 'Post-C2';
4
-
5
- export function getDifficultyLevel(difficulty: LanguageLevel): number {
6
- return codes.indexOf(difficulty) + 1;
7
- }
8
-
9
- export function getDifficultyLabel(difficulty: number): LanguageLevel {
10
- return codes[difficulty] as LanguageLevel;
11
- }
12
-
13
- export function getNeighborDifficultyLevel(difficulty: LanguageLevel, difficultyAdjustment: number): LanguageLevel {
14
- return getDifficultyLabel(getDifficultyLevel(difficulty) + difficultyAdjustment - 1);
15
- }
@@ -1,3 +0,0 @@
1
- export const DEFAULT_ENDPOINT = 'https://pheptqdoqsdnadgoihvr.supabase.co';
2
- export const DEFAULT_ANON_KEY =
3
- 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBoZXB0cWRvcXNkbmFkZ29paHZyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzE2OTY2ODcsImV4cCI6MjA0NzI3MjY4N30.4GPFAXTF8685FaXISdAPNCIM-H3RGLo8GbyhQpu1mP0';
@@ -1,35 +0,0 @@
1
- import { RimoriClient } from '../plugin/RimoriClient';
2
- import { EventBusHandler } from '../fromRimori/EventBus';
3
-
4
- /**
5
- * Sets up the web worker for the plugin to be able receive and send messages to Rimori.
6
- * @param pluginId - The id of the plugin to setup the worker for.
7
- * @param init - The function containing the initialization logic.
8
- */
9
- export async function setupWorker(
10
- pluginId: string,
11
- init: (client: RimoriClient) => void | Promise<void>,
12
- ): Promise<void> {
13
- // Mock of the window object for the worker context to be able to use the PluginController.
14
- const mockWindow = {
15
- isWorker: true,
16
- location: {},
17
- parent: {
18
- postMessage: () => {},
19
- },
20
- addEventListener: () => {},
21
- };
22
-
23
- // Assign the mock to globalThis.
24
- Object.assign(globalThis, { window: mockWindow });
25
-
26
- EventBusHandler.getInstance('Worker EventBus');
27
-
28
- const rimoriClient = await RimoriClient.getInstance(pluginId);
29
- console.debug('[Worker] RimoriClient initialized.');
30
-
31
- await init(rimoriClient);
32
- console.debug('[Worker] Worker initialized.');
33
-
34
- rimoriClient.event.emit('self.rimori.triggerInitFinished');
35
- }
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "outDir": "dist",
4
- "rootDir": "src",
5
- "module": "ESNext",
6
- "target": "ES6",
7
- "declaration": true,
8
- "jsx": "react-jsx",
9
- "moduleResolution": "node",
10
- "esModuleInterop": true,
11
- "skipLibCheck": true,
12
- "strict": true
13
- },
14
- "include": [
15
- "src/**/*",
16
- ]
17
- }