@rimori/client 2.5.37-next.2 → 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.
@@ -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.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {