@rimori/client 2.5.37-next.1 → 2.5.37-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.
@@ -110,6 +110,19 @@ export declare class AIModule {
110
110
  * A warning is logged to the console in this case.
111
111
  */
112
112
  getVoice(text: string, voice?: string, speed?: number, language?: string, cache?: boolean, instructions?: string): Promise<Blob>;
113
+ /**
114
+ * Generate an image from a text prompt using AI.
115
+ * @param params.prompt The prompt describing the image to generate.
116
+ * @param params.cache Whether to cache the result by prompt hash (default: true).
117
+ * @returns `{ url, cached }` where `url` is either a data URL or a stored CDN URL.
118
+ */
119
+ getImage(params: {
120
+ prompt: string;
121
+ cache?: boolean;
122
+ }): Promise<{
123
+ url: string;
124
+ cached: boolean;
125
+ }>;
113
126
  /**
114
127
  * Convert voice audio to text using AI.
115
128
  * @param file The audio file to convert.
@@ -115,6 +115,27 @@ export class AIModule {
115
115
  }),
116
116
  }).then((r) => r.blob());
117
117
  }
118
+ /**
119
+ * Generate an image from a text prompt using AI.
120
+ * @param params.prompt The prompt describing the image to generate.
121
+ * @param params.cache Whether to cache the result by prompt hash (default: true).
122
+ * @returns `{ url, cached }` where `url` is either a data URL or a stored CDN URL.
123
+ */
124
+ async getImage(params) {
125
+ const { prompt, cache = true } = params;
126
+ const response = await this.controller.fetchBackend('/ai/image', {
127
+ method: 'POST',
128
+ body: JSON.stringify({
129
+ prompt,
130
+ cache,
131
+ session_token_id: this.sessionTokenId ?? undefined,
132
+ }),
133
+ });
134
+ if (!response.ok) {
135
+ throw new Error(`Failed to generate image: ${response.status} ${response.statusText}`);
136
+ }
137
+ return response.json();
138
+ }
118
139
  /**
119
140
  * Convert voice audio to text using AI.
120
141
  * @param file The audio file to convert.
@@ -1,8 +1,10 @@
1
1
  import { ObjectTool } from '../../fromRimori/PluginTypes';
2
2
  import { SupabaseClient } from '../CommunicationHandler';
3
3
  import { RimoriClient } from '../RimoriClient';
4
+ import { LanguageLevel } from '../../utils/difficultyConverter';
4
5
  export type SharedContent<T> = BasicSharedContent & T;
5
6
  export type ContentStatus = 'featured' | 'community' | 'unverified';
7
+ export type SharedContentSkillType = 'grammar' | 'reading' | 'writing' | 'speaking' | 'listening' | 'understanding';
6
8
  export interface BasicSharedContent {
7
9
  id: string;
8
10
  title: string;
@@ -12,6 +14,7 @@ export interface BasicSharedContent {
12
14
  created_at: string;
13
15
  guild_id: string | null;
14
16
  lang_id: string | null;
17
+ skill_level: LanguageLevel;
15
18
  }
16
19
  export interface SharedContentCompletionState {
17
20
  content_id: string;
@@ -44,7 +47,7 @@ export declare class SharedContentController {
44
47
  */
45
48
  getNew<T>(params: {
46
49
  table: string;
47
- skillType: 'grammar' | 'reading' | 'writing' | 'speaking' | 'listening' | 'understanding';
50
+ skillType: SharedContentSkillType;
48
51
  placeholders?: Record<string, string>;
49
52
  filter?: Record<string, {
50
53
  filterType: 'rag' | 'exact' | 'exclude';
@@ -129,11 +132,15 @@ export declare class SharedContentController {
129
132
  getAll<T = any>(tableName: string, limit?: number): Promise<SharedContent<T>[]>;
130
133
  /**
131
134
  * Create new shared content manually.
135
+ * Auto-fills `skill_level` from the user's current `skill_level_{skillType}` setting
136
+ * so callers don't have to wire it up themselves (the column is NOT NULL on every
137
+ * shared-content table).
132
138
  * @param tableName - Name of the shared content table
139
+ * @param skillType - Skill this content trains; selects which user skill level to record
133
140
  * @param content - Content to create
134
141
  * @returns Created content
135
142
  */
136
- create<T = any>(tableName: string, content: Omit<SharedContent<T>, 'id' | 'created_at' | 'created_by'>): Promise<SharedContent<T>>;
143
+ create<T = any>(tableName: string, skillType: SharedContentSkillType, content: Omit<SharedContent<T>, 'id' | 'created_at' | 'created_by' | 'skill_level'>): Promise<SharedContent<T>>;
137
144
  /**
138
145
  * Update existing shared content via backend.
139
146
  * If content was already validated (community/featured) and user is not a moderator,
@@ -226,13 +226,23 @@ export class SharedContentController {
226
226
  }
227
227
  /**
228
228
  * Create new shared content manually.
229
+ * Auto-fills `skill_level` from the user's current `skill_level_{skillType}` setting
230
+ * so callers don't have to wire it up themselves (the column is NOT NULL on every
231
+ * shared-content table).
229
232
  * @param tableName - Name of the shared content table
233
+ * @param skillType - Skill this content trains; selects which user skill level to record
230
234
  * @param content - Content to create
231
235
  * @returns Created content
232
236
  */
233
- async create(tableName, content) {
237
+ async create(tableName, skillType, content) {
234
238
  const fullTableName = this.getTableName(tableName);
235
- const { data, error } = await this.supabase.from(fullTableName).insert(content).select().single();
239
+ const userInfo = this.rimoriClient.plugin.getUserInfo();
240
+ const skillLevel = userInfo[`skill_level_${skillType}`];
241
+ const { data, error } = await this.supabase
242
+ .from(fullTableName)
243
+ .insert({ ...content, skill_level: skillLevel })
244
+ .select()
245
+ .single();
236
246
  if (error) {
237
247
  console.error('Error creating shared content:', error);
238
248
  throw new Error('Error creating shared content');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimori/client",
3
- "version": "2.5.37-next.1",
3
+ "version": "2.5.37-next.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {