@rimori/client 2.2.0-next.1 → 2.2.0-next.3
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/.github/workflows/pre-release.yml +21 -0
- package/README.md +9 -13
- package/dist/controller/TranslationController.d.ts +2 -1
- package/dist/controller/TranslationController.js +3 -2
- package/dist/plugin/CommunicationHandler.d.ts +11 -0
- package/dist/plugin/RimoriClient.d.ts +12 -0
- package/dist/plugin/RimoriClient.js +18 -5
- package/package.json +1 -1
- package/src/controller/TranslationController.ts +4 -2
- package/src/plugin/CommunicationHandler.ts +11 -0
- package/src/plugin/RimoriClient.ts +18 -6
|
@@ -103,3 +103,24 @@ jobs:
|
|
|
103
103
|
- name: Output published version
|
|
104
104
|
run: |
|
|
105
105
|
echo "✅ Published @rimori/client@${{ steps.version.outputs.new_version }} to npm with @next tag"
|
|
106
|
+
|
|
107
|
+
- name: Notify Slack
|
|
108
|
+
if: always()
|
|
109
|
+
uses: slackapi/slack-github-action@v1.24.0
|
|
110
|
+
with:
|
|
111
|
+
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
|
|
112
|
+
payload: |
|
|
113
|
+
{
|
|
114
|
+
"text": "Pre-Release Pipeline Status",
|
|
115
|
+
"blocks": [
|
|
116
|
+
{
|
|
117
|
+
"type": "section",
|
|
118
|
+
"text": {
|
|
119
|
+
"type": "mrkdwn",
|
|
120
|
+
"text": "📦 *@rimori/client Pre-Release*\n\n*Branch:* ${{ github.ref_name }}\n*Version:* ${{ steps.version.outputs.new_version }}\n*Author:* ${{ github.actor }}\n*Pipeline:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run>\n\n${{ job.status == 'success' && '✅ Successfully published to npm with @next tag!' || '❌ Pipeline failed. Check the logs for details.' }}"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
env:
|
|
126
|
+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
|
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
The `@rimori/client` package is the framework-agnostic runtime and CLI that powers Rimori plugins. Use it inside plugin iframes, workers, and build scripts to access Rimori platform features such as database access, AI, shared content, and the event bus. All React-specific helpers and UI components are now published separately in `@rimori/react-client`.
|
|
4
4
|
|
|
5
5
|
## Table of Contents
|
|
6
|
+
|
|
6
7
|
- [Overview](#overview)
|
|
7
8
|
- [Installation](#installation)
|
|
8
9
|
- [Relationship to @rimori/react-client](#relationship-to-rimori-react-client)
|
|
@@ -24,6 +25,7 @@ The `@rimori/client` package is the framework-agnostic runtime and CLI that powe
|
|
|
24
25
|
## Overview
|
|
25
26
|
|
|
26
27
|
`@rimori/client` gives you direct, typed access to the Rimori platform:
|
|
28
|
+
|
|
27
29
|
- Bootstrap authenticated plugin sessions and fetch Rimori context.
|
|
28
30
|
- Run Supabase queries against your plugin's dedicated schema.
|
|
29
31
|
- Call AI services for text, structured data, or voice.
|
|
@@ -54,18 +56,15 @@ npm install @rimori/react-client
|
|
|
54
56
|
Instantiate the client once in your application entry point and reuse it everywhere:
|
|
55
57
|
|
|
56
58
|
```ts
|
|
57
|
-
import { RimoriClient } from
|
|
59
|
+
import { RimoriClient } from '@rimori/client';
|
|
58
60
|
|
|
59
61
|
async function bootstrap() {
|
|
60
|
-
const client = await RimoriClient.getInstance(
|
|
62
|
+
const client = await RimoriClient.getInstance('your-plugin-id');
|
|
61
63
|
|
|
62
64
|
const user = client.plugin.getUserInfo();
|
|
63
|
-
const { data } = await client.db
|
|
64
|
-
.from("notes")
|
|
65
|
-
.select("*")
|
|
66
|
-
.eq("user_id", user.profile_id);
|
|
65
|
+
const { data } = await client.db.from('notes').select('*').eq('user_id', user.profile_id);
|
|
67
66
|
|
|
68
|
-
console.log(
|
|
67
|
+
console.log('Loaded notes', data);
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
bootstrap().catch(console.error);
|
|
@@ -127,10 +126,7 @@ Access metadata and settings through `client.plugin`:
|
|
|
127
126
|
`client.db` wraps the Supabase client that is scoped to your plugin tables:
|
|
128
127
|
|
|
129
128
|
```ts
|
|
130
|
-
const { data, error } = await client.db
|
|
131
|
-
.from("study_sessions")
|
|
132
|
-
.select("*")
|
|
133
|
-
.order("completed_at", { ascending: false });
|
|
129
|
+
const { data, error } = await client.db.from('study_sessions').select('*').order('completed_at', { ascending: false });
|
|
134
130
|
```
|
|
135
131
|
|
|
136
132
|
Helpers:
|
|
@@ -196,7 +192,7 @@ Import additional helpers as needed:
|
|
|
196
192
|
All exports are fully typed. You can import the type definitions directly:
|
|
197
193
|
|
|
198
194
|
```ts
|
|
199
|
-
import type { Message, Tool, SharedContent, MacroAccomplishmentPayload } from
|
|
195
|
+
import type { Message, Tool, SharedContent, MacroAccomplishmentPayload } from '@rimori/client';
|
|
200
196
|
```
|
|
201
197
|
|
|
202
198
|
The generated declaration files cover every controller and helper to keep plugins strictly typed.
|
|
@@ -206,7 +202,7 @@ The generated declaration files cover every controller and helper to keep plugin
|
|
|
206
202
|
React users should install `@rimori/react-client` and wrap their app:
|
|
207
203
|
|
|
208
204
|
```tsx
|
|
209
|
-
import { PluginProvider, useRimori, useChat } from
|
|
205
|
+
import { PluginProvider, useRimori, useChat } from '@rimori/react-client';
|
|
210
206
|
|
|
211
207
|
function Dashboard() {
|
|
212
208
|
const client = useRimori();
|
|
@@ -7,7 +7,8 @@ export declare class Translator {
|
|
|
7
7
|
private initializationState;
|
|
8
8
|
private initializationPromise;
|
|
9
9
|
private i18n;
|
|
10
|
-
|
|
10
|
+
private translationUrl;
|
|
11
|
+
constructor(initialLanguage: string, translationUrl: string);
|
|
11
12
|
/**
|
|
12
13
|
* Initialize translator with user's language
|
|
13
14
|
* @param userLanguage - Language code from user info
|
|
@@ -12,10 +12,11 @@ import { createInstance } from 'i18next';
|
|
|
12
12
|
* Translator class for handling internationalization
|
|
13
13
|
*/
|
|
14
14
|
export class Translator {
|
|
15
|
-
constructor(initialLanguage) {
|
|
15
|
+
constructor(initialLanguage, translationUrl) {
|
|
16
16
|
this.currentLanguage = initialLanguage;
|
|
17
17
|
this.initializationState = 'not-inited';
|
|
18
18
|
this.initializationPromise = null;
|
|
19
|
+
this.translationUrl = translationUrl;
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
* Initialize translator with user's language
|
|
@@ -66,7 +67,7 @@ export class Translator {
|
|
|
66
67
|
const filename = language !== 'en' ? `local-${language}` : language;
|
|
67
68
|
return `${window.location.origin}/locales/${filename}.json`;
|
|
68
69
|
}
|
|
69
|
-
return
|
|
70
|
+
return `${this.translationUrl}/locales/${language}.json`;
|
|
70
71
|
}
|
|
71
72
|
usePlugin(plugin) {
|
|
72
73
|
if (!this.i18n) {
|
|
@@ -27,6 +27,17 @@ export interface RimoriInfo {
|
|
|
27
27
|
mainPanelPlugin?: ActivePlugin;
|
|
28
28
|
sidePanelPlugin?: ActivePlugin;
|
|
29
29
|
interfaceLanguage: string;
|
|
30
|
+
/**
|
|
31
|
+
* The release channel of the plugin installation.
|
|
32
|
+
*/
|
|
33
|
+
releaseChannel: 'alpha' | 'beta' | 'stable';
|
|
34
|
+
/**
|
|
35
|
+
* The database schema to use for plugin tables.
|
|
36
|
+
* Determined by rimori-main based on release channel:
|
|
37
|
+
* - 'plugins_alpha' for alpha release channel
|
|
38
|
+
* - 'plugins' for beta and stable release channels
|
|
39
|
+
*/
|
|
40
|
+
dbSchema: 'plugins' | 'plugins_alpha';
|
|
30
41
|
}
|
|
31
42
|
export declare class RimoriCommunicationHandler {
|
|
32
43
|
private port;
|
|
@@ -22,6 +22,11 @@ export declare class RimoriClient {
|
|
|
22
22
|
private constructor();
|
|
23
23
|
get plugin(): {
|
|
24
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";
|
|
25
30
|
/**
|
|
26
31
|
* Set the settings for the plugin.
|
|
27
32
|
* @param settings The settings to set.
|
|
@@ -67,6 +72,13 @@ export declare class RimoriClient {
|
|
|
67
72
|
* The table prefix for of database tables of the plugin.
|
|
68
73
|
*/
|
|
69
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";
|
|
70
82
|
/**
|
|
71
83
|
* Get the table name for a given plugin table.
|
|
72
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.
|
|
@@ -277,7 +277,8 @@ export class RimoriClient {
|
|
|
277
277
|
this.accomplishmentHandler = new AccomplishmentController(info.pluginId);
|
|
278
278
|
this.settingsController = new SettingsController(supabase, info.pluginId, info.guild);
|
|
279
279
|
this.sharedContentController = new SharedContentController(supabase, this);
|
|
280
|
-
|
|
280
|
+
const currentPlugin = info.installedPlugins.find((plugin) => plugin.id === info.pluginId);
|
|
281
|
+
this.translator = new Translator(info.interfaceLanguage, (currentPlugin === null || currentPlugin === void 0 ? void 0 : currentPlugin.endpoint) || '');
|
|
281
282
|
//only init logger in workers and on main plugin pages
|
|
282
283
|
if (this.getQueryParam('applicationMode') !== 'sidebar') {
|
|
283
284
|
Logger.getInstance(this);
|
|
@@ -286,6 +287,11 @@ export class RimoriClient {
|
|
|
286
287
|
get plugin() {
|
|
287
288
|
return {
|
|
288
289
|
pluginId: this.rimoriInfo.pluginId,
|
|
290
|
+
/**
|
|
291
|
+
* The release channel of this plugin installation.
|
|
292
|
+
* Determines which database schema is used for plugin tables.
|
|
293
|
+
*/
|
|
294
|
+
releaseChannel: this.rimoriInfo.releaseChannel,
|
|
289
295
|
/**
|
|
290
296
|
* Set the settings for the plugin.
|
|
291
297
|
* @param settings The settings to set.
|
|
@@ -339,15 +345,15 @@ export class RimoriClient {
|
|
|
339
345
|
// ): PostgrestQueryBuilder<GenericSchema, View, ViewName>;
|
|
340
346
|
from: (relation) => {
|
|
341
347
|
const tableName = this.db.getTableName(relation);
|
|
342
|
-
// Use
|
|
348
|
+
// Use the schema determined by rimori-main based on release channel
|
|
343
349
|
// Global tables (starting with 'global_') remain in public schema
|
|
344
|
-
// Plugin tables
|
|
350
|
+
// Plugin tables use the schema provided by rimori-main (plugins or plugins_alpha)
|
|
345
351
|
if (relation.startsWith('global_')) {
|
|
346
352
|
// Global tables stay in public schema
|
|
347
353
|
return this.superbase.from(tableName);
|
|
348
354
|
}
|
|
349
|
-
//
|
|
350
|
-
return this.superbase.schema(
|
|
355
|
+
// Plugin tables go to the schema provided by rimori-main
|
|
356
|
+
return this.superbase.schema(this.rimoriInfo.dbSchema).from(tableName);
|
|
351
357
|
},
|
|
352
358
|
// storage: this.superbase.storage,
|
|
353
359
|
// functions: this.superbase.functions,
|
|
@@ -355,6 +361,13 @@ export class RimoriClient {
|
|
|
355
361
|
* The table prefix for of database tables of the plugin.
|
|
356
362
|
*/
|
|
357
363
|
tablePrefix: this.rimoriInfo.tablePrefix,
|
|
364
|
+
/**
|
|
365
|
+
* The database schema used for plugin tables.
|
|
366
|
+
* Determined by rimori-main based on release channel:
|
|
367
|
+
* - 'plugins_alpha' for alpha release channel
|
|
368
|
+
* - 'plugins' for beta and stable release channels
|
|
369
|
+
*/
|
|
370
|
+
schema: this.rimoriInfo.dbSchema,
|
|
358
371
|
/**
|
|
359
372
|
* Get the table name for a given plugin table.
|
|
360
373
|
* Internally all tables are prefixed with the plugin id. This function is used to get the correct table name for a given public table.
|
package/package.json
CHANGED
|
@@ -10,11 +10,13 @@ export class Translator {
|
|
|
10
10
|
private initializationState: InitializationState;
|
|
11
11
|
private initializationPromise: Promise<void> | null;
|
|
12
12
|
private i18n: i18nType | undefined;
|
|
13
|
+
private translationUrl: string;
|
|
13
14
|
|
|
14
|
-
constructor(initialLanguage: string) {
|
|
15
|
+
constructor(initialLanguage: string, translationUrl: string) {
|
|
15
16
|
this.currentLanguage = initialLanguage;
|
|
16
17
|
this.initializationState = 'not-inited';
|
|
17
18
|
this.initializationPromise = null;
|
|
19
|
+
this.translationUrl = translationUrl;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
/**
|
|
@@ -72,7 +74,7 @@ export class Translator {
|
|
|
72
74
|
return `${window.location.origin}/locales/${filename}.json`;
|
|
73
75
|
}
|
|
74
76
|
|
|
75
|
-
return
|
|
77
|
+
return `${this.translationUrl}/locales/${language}.json`;
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
public usePlugin(plugin: ThirdPartyModule): void {
|
|
@@ -33,6 +33,17 @@ export interface RimoriInfo {
|
|
|
33
33
|
mainPanelPlugin?: ActivePlugin;
|
|
34
34
|
sidePanelPlugin?: ActivePlugin;
|
|
35
35
|
interfaceLanguage: string;
|
|
36
|
+
/**
|
|
37
|
+
* The release channel of the plugin installation.
|
|
38
|
+
*/
|
|
39
|
+
releaseChannel: 'alpha' | 'beta' | 'stable';
|
|
40
|
+
/**
|
|
41
|
+
* The database schema to use for plugin tables.
|
|
42
|
+
* Determined by rimori-main based on release channel:
|
|
43
|
+
* - 'plugins_alpha' for alpha release channel
|
|
44
|
+
* - 'plugins' for beta and stable release channels
|
|
45
|
+
*/
|
|
46
|
+
dbSchema: 'plugins' | 'plugins_alpha';
|
|
36
47
|
}
|
|
37
48
|
|
|
38
49
|
export class RimoriCommunicationHandler {
|
|
@@ -43,7 +43,8 @@ export class RimoriClient {
|
|
|
43
43
|
this.accomplishmentHandler = new AccomplishmentController(info.pluginId);
|
|
44
44
|
this.settingsController = new SettingsController(supabase, info.pluginId, info.guild);
|
|
45
45
|
this.sharedContentController = new SharedContentController(supabase, this);
|
|
46
|
-
|
|
46
|
+
const currentPlugin = info.installedPlugins.find((plugin) => plugin.id === info.pluginId);
|
|
47
|
+
this.translator = new Translator(info.interfaceLanguage, currentPlugin?.endpoint || '');
|
|
47
48
|
|
|
48
49
|
//only init logger in workers and on main plugin pages
|
|
49
50
|
if (this.getQueryParam('applicationMode') !== 'sidebar') {
|
|
@@ -54,6 +55,11 @@ export class RimoriClient {
|
|
|
54
55
|
public get plugin() {
|
|
55
56
|
return {
|
|
56
57
|
pluginId: this.rimoriInfo.pluginId,
|
|
58
|
+
/**
|
|
59
|
+
* The release channel of this plugin installation.
|
|
60
|
+
* Determines which database schema is used for plugin tables.
|
|
61
|
+
*/
|
|
62
|
+
releaseChannel: this.rimoriInfo.releaseChannel,
|
|
57
63
|
/**
|
|
58
64
|
* Set the settings for the plugin.
|
|
59
65
|
* @param settings The settings to set.
|
|
@@ -123,15 +129,15 @@ export class RimoriClient {
|
|
|
123
129
|
relation: string,
|
|
124
130
|
): PostgrestQueryBuilder<GenericSchema, View, ViewName> => {
|
|
125
131
|
const tableName = this.db.getTableName(relation);
|
|
126
|
-
// Use
|
|
132
|
+
// Use the schema determined by rimori-main based on release channel
|
|
127
133
|
// Global tables (starting with 'global_') remain in public schema
|
|
128
|
-
// Plugin tables
|
|
134
|
+
// Plugin tables use the schema provided by rimori-main (plugins or plugins_alpha)
|
|
129
135
|
if (relation.startsWith('global_')) {
|
|
130
136
|
// Global tables stay in public schema
|
|
131
137
|
return this.superbase.from(tableName);
|
|
132
138
|
}
|
|
133
|
-
//
|
|
134
|
-
return this.superbase.schema(
|
|
139
|
+
// Plugin tables go to the schema provided by rimori-main
|
|
140
|
+
return this.superbase.schema(this.rimoriInfo.dbSchema).from(tableName);
|
|
135
141
|
},
|
|
136
142
|
// storage: this.superbase.storage,
|
|
137
143
|
// functions: this.superbase.functions,
|
|
@@ -139,6 +145,13 @@ export class RimoriClient {
|
|
|
139
145
|
* The table prefix for of database tables of the plugin.
|
|
140
146
|
*/
|
|
141
147
|
tablePrefix: this.rimoriInfo.tablePrefix,
|
|
148
|
+
/**
|
|
149
|
+
* The database schema used for plugin tables.
|
|
150
|
+
* Determined by rimori-main based on release channel:
|
|
151
|
+
* - 'plugins_alpha' for alpha release channel
|
|
152
|
+
* - 'plugins' for beta and stable release channels
|
|
153
|
+
*/
|
|
154
|
+
schema: this.rimoriInfo.dbSchema,
|
|
142
155
|
/**
|
|
143
156
|
* Get the table name for a given plugin table.
|
|
144
157
|
* Internally all tables are prefixed with the plugin id. This function is used to get the correct table name for a given public table.
|
|
@@ -484,4 +497,3 @@ export class RimoriClient {
|
|
|
484
497
|
},
|
|
485
498
|
};
|
|
486
499
|
}
|
|
487
|
-
|