@rimori/client 2.5.37-next.2 → 2.5.37-next.4

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.
@@ -18,14 +18,8 @@
18
18
  */
19
19
  /**
20
20
  * 'image', 'audio', 'video' and 'file' are stored as `text` (URL) in the database.
21
- * Marking a column with one of these types causes the migration system to:
22
- * 1. Add an `updated_at` timestamp + trigger to the table.
23
- * 2. Register the column for the asset-refs cron, which links rows to bucket
24
- * files (in the `plugin-assets` Supabase bucket) and deletes orphans when
25
- * the row is deleted, the column is replaced, or the value is cleared.
26
- *
27
- * Use these types instead of `text` for any column whose value is a URL into the
28
- * `plugin-assets` bucket — that way the file is automatically cleaned up.
21
+ * The migration system adds an `updated_at` trigger and registers the column for
22
+ * the asset-refs cron, which links rows to bucket files and deletes orphans.
29
23
  */
30
24
  type DbColumnType = 'decimal' | 'integer' | 'text' | 'boolean' | 'json' | 'timestamp' | 'uuid' | 'markdown' | 'vector' | 'image' | 'audio' | 'video' | 'file';
31
25
  /**
@@ -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.2",
3
+ "version": "2.5.37-next.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {