@rimori/client 1.1.9 → 1.1.10

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,15 +1,6 @@
1
1
  import { SupabaseClient } from '@supabase/supabase-js';
2
2
  import { RimoriClient } from "../plugin/RimoriClient";
3
3
  import { ObjectRequest } from "./ObjectController";
4
- export interface BasicAssignment<T> {
5
- id: string;
6
- createdAt: Date;
7
- topic: string;
8
- createdBy: string;
9
- verified: boolean;
10
- keywords: any;
11
- data: T;
12
- }
13
4
  export interface SharedContentObjectRequest extends ObjectRequest {
14
5
  fixedProperties?: Record<string, string | number | boolean>;
15
6
  }
@@ -26,10 +17,10 @@ export declare class SharedContentController {
26
17
  * @param privateTopic - An optional flag to indicate if the topic should be private and only be visible to the user.
27
18
  * @returns The new shared content.
28
19
  */
29
- getNewSharedContent<T>(contentType: string, generatorInstructions: SharedContentObjectRequest, filter?: SharedContentFilter, privateTopic?: boolean): Promise<BasicAssignment<T>>;
20
+ getNewSharedContent<T>(contentType: string, generatorInstructions: SharedContentObjectRequest, filter?: SharedContentFilter, privateTopic?: boolean): Promise<SharedContent<T>>;
30
21
  private getGeneratorInstructions;
31
22
  private getCompletedTopics;
32
- getSharedContent<T>(contentType: string, id: string): Promise<BasicAssignment<T>>;
23
+ getSharedContent<T>(contentType: string, id: string): Promise<SharedContent<T>>;
33
24
  completeSharedContent(contentType: string, assignmentId: string): Promise<void>;
34
25
  /**
35
26
  * Fetch shared content from the database based on optional filters.
@@ -38,19 +29,19 @@ export declare class SharedContentController {
38
29
  * @param limit - Optional limit for the number of results.
39
30
  * @returns Array of shared content matching the criteria.
40
31
  */
41
- getSharedContentList<T>(contentType: string, filter?: SharedContentFilter, limit?: number): Promise<BasicAssignment<T>[]>;
32
+ getSharedContentList<T>(contentType: string, filter?: SharedContentFilter, limit?: number): Promise<SharedContent<T>[]>;
42
33
  /**
43
34
  * Insert new shared content into the database.
44
35
  * @param param
45
36
  * @param param.contentType - The type of content to insert.
46
- * @param param.topic - The topic of the content.
37
+ * @param param.title - The title of the content.
47
38
  * @param param.keywords - Keywords associated with the content.
48
39
  * @param param.data - The content data to store.
49
40
  * @param param.privateTopic - Optional flag to indicate if the topic should be private.
50
41
  * @returns The inserted shared content.
51
42
  * @throws {Error} if insertion fails.
52
43
  */
53
- createSharedContent<T>({ contentType, topic, keywords, data, privateTopic }: Omit<SharedContent<T>, 'id'>): Promise<BasicAssignment<T>>;
44
+ createSharedContent<T>({ contentType, title, keywords, data, privateTopic }: Omit<SharedContent<T>, 'id'>): Promise<SharedContent<T>>;
54
45
  /**
55
46
  * Update existing shared content in the database.
56
47
  * @param id - The ID of the content to update.
@@ -58,14 +49,14 @@ export declare class SharedContentController {
58
49
  * @returns The updated shared content.
59
50
  * @throws {Error} if update fails.
60
51
  */
61
- updateSharedContent<T>(id: string, updates: Partial<SharedContent<T>>): Promise<BasicAssignment<T>>;
52
+ updateSharedContent<T>(id: string, updates: Partial<SharedContent<T>>): Promise<SharedContent<T>>;
62
53
  /**
63
54
  * Soft delete shared content by setting the deleted_at timestamp.
64
55
  * @param id - The ID of the content to delete.
65
56
  * @returns The deleted shared content record.
66
57
  * @throws {Error} if deletion fails or content not found.
67
58
  */
68
- removeSharedContent(id: string): Promise<BasicAssignment<any>>;
59
+ removeSharedContent(id: string): Promise<SharedContent<any>>;
69
60
  }
70
61
  /**
71
62
  * Interface representing shared content in the system.
@@ -76,8 +67,8 @@ export interface SharedContent<T> {
76
67
  id: string;
77
68
  /** The type/category of the content (e.g. 'grammar_exercises', 'flashcards', etc.) */
78
69
  contentType: string;
79
- /** The human readable title/topic of the content */
80
- topic: string;
70
+ /** The human readable title of the content */
71
+ title: string;
81
72
  /** Array of keywords/tags associated with the content for search and categorization */
82
73
  keywords: string[];
83
74
  /** The actual content data of type T */
@@ -81,7 +81,7 @@ export class SharedContentController {
81
81
  getCompletedTopics(contentType, filter) {
82
82
  return __awaiter(this, void 0, void 0, function* () {
83
83
  const query = this.supabase.from("shared_content")
84
- .select("topic, keywords, scc:shared_content_completed(id)")
84
+ .select("title, keywords, scc:shared_content_completed(id)")
85
85
  .eq('content_type', contentType)
86
86
  .not('scc.id', 'is', null)
87
87
  .is('deleted_at', null);
@@ -93,7 +93,7 @@ export class SharedContentController {
93
93
  console.error('error fetching old assignments:', error);
94
94
  return [];
95
95
  }
96
- return oldAssignments.map(({ topic, keywords }) => `${topic}(${keywords.join(',')})`);
96
+ return oldAssignments.map(({ title, keywords }) => `${title}(${keywords.join(',')})`);
97
97
  });
98
98
  }
99
99
  getSharedContent(contentType, id) {
@@ -136,7 +136,7 @@ export class SharedContentController {
136
136
  * Insert new shared content into the database.
137
137
  * @param param
138
138
  * @param param.contentType - The type of content to insert.
139
- * @param param.topic - The topic of the content.
139
+ * @param param.title - The title of the content.
140
140
  * @param param.keywords - Keywords associated with the content.
141
141
  * @param param.data - The content data to store.
142
142
  * @param param.privateTopic - Optional flag to indicate if the topic should be private.
@@ -144,11 +144,11 @@ export class SharedContentController {
144
144
  * @throws {Error} if insertion fails.
145
145
  */
146
146
  createSharedContent(_a) {
147
- return __awaiter(this, arguments, void 0, function* ({ contentType, topic, keywords, data, privateTopic }) {
147
+ return __awaiter(this, arguments, void 0, function* ({ contentType, title, keywords, data, privateTopic }) {
148
148
  const { data: newContent, error } = yield this.supabase.from("shared_content").insert({
149
149
  private: privateTopic,
150
150
  content_type: contentType,
151
- topic,
151
+ title,
152
152
  keywords,
153
153
  data,
154
154
  }).select();
@@ -171,8 +171,8 @@ export class SharedContentController {
171
171
  const updateData = {};
172
172
  if (updates.contentType)
173
173
  updateData.content_type = updates.contentType;
174
- if (updates.topic)
175
- updateData.topic = updates.topic;
174
+ if (updates.title)
175
+ updateData.title = updates.title;
176
176
  if (updates.keywords)
177
177
  updateData.keywords = updates.keywords;
178
178
  if (updates.data)
package/dist/core.d.ts CHANGED
@@ -4,4 +4,4 @@ export * from "./utils/difficultyConverter";
4
4
  export * from "./utils/PluginUtils";
5
5
  export * from "./worker/WorkerSetup";
6
6
  export * from "./utils/Language";
7
- export { SharedContent, BasicAssignment } from "./controller/SharedContentController";
7
+ export { SharedContent } from "./controller/SharedContentController";
@@ -4,7 +4,7 @@ import { GenericSchema } from "@supabase/supabase-js/dist/module/lib/types";
4
4
  import { Message, OnLLMResponse, Tool } from "../controller/AIController";
5
5
  import { ObjectRequest } from "../controller/ObjectController";
6
6
  import { UserInfo } from "../controller/SettingsController";
7
- import { BasicAssignment, SharedContent, SharedContentFilter, SharedContentObjectRequest } from "../controller/SharedContentController";
7
+ import { SharedContent, SharedContentFilter, SharedContentObjectRequest } from "../controller/SharedContentController";
8
8
  import { AccomplishmentPayload } from "./AccomplishmentHandler";
9
9
  import { EventBusMessage, EventHandler, EventPayload } from "./fromRimori/EventBus";
10
10
  import { Plugin } from "./fromRimori/PluginTypes";
@@ -135,7 +135,7 @@ export declare class RimoriClient {
135
135
  * @param id The id of the shared content item.
136
136
  * @returns The shared content item.
137
137
  */
138
- get: <T = any>(contentType: string, id: string) => Promise<BasicAssignment<T>>;
138
+ get: <T = any>(contentType: string, id: string) => Promise<SharedContent<T>>;
139
139
  /**
140
140
  * Get a list of shared content items.
141
141
  * @param contentType The type of shared content to get. E.g. assignments, exercises, etc.
@@ -143,7 +143,7 @@ export declare class RimoriClient {
143
143
  * @param limit The optional limit for the number of results.
144
144
  * @returns The list of shared content items.
145
145
  */
146
- getList: <T = any>(contentType: string, filter?: SharedContentFilter, limit?: number) => Promise<BasicAssignment<T>[]>;
146
+ getList: <T = any>(contentType: string, filter?: SharedContentFilter, limit?: number) => Promise<SharedContent<T>[]>;
147
147
  /**
148
148
  * Get new shared content.
149
149
  * @param contentType The type of shared content to fetch. E.g. assignments, exercises, etc.
@@ -152,20 +152,20 @@ export declare class RimoriClient {
152
152
  * @param privateTopic An optional flag to indicate if the topic should be private and only be visible to the user. This is useful if the topic is not meant to be shared with other users. Like for personal topics or if the content is based on the personal study goal.
153
153
  * @returns The new shared content.
154
154
  */
155
- getNew: <T = any>(contentType: string, generatorInstructions: SharedContentObjectRequest, filter?: SharedContentFilter, privateTopic?: boolean) => Promise<BasicAssignment<T>>;
155
+ getNew: <T = any>(contentType: string, generatorInstructions: SharedContentObjectRequest, filter?: SharedContentFilter, privateTopic?: boolean) => Promise<SharedContent<T>>;
156
156
  /**
157
157
  * Create a new shared content item.
158
158
  * @param content The content to create.
159
159
  * @returns The new shared content item.
160
160
  */
161
- create: <T = any>(content: Omit<SharedContent<T>, "id">) => Promise<BasicAssignment<T>>;
161
+ create: <T = any>(content: Omit<SharedContent<T>, "id">) => Promise<SharedContent<T>>;
162
162
  /**
163
163
  * Update a shared content item.
164
164
  * @param id The id of the shared content item to update.
165
165
  * @param content The content to update.
166
166
  * @returns The updated shared content item.
167
167
  */
168
- update: <T = any>(id: string, content: Partial<SharedContent<T>>) => Promise<BasicAssignment<T>>;
168
+ update: <T = any>(id: string, content: Partial<SharedContent<T>>) => Promise<SharedContent<T>>;
169
169
  /**
170
170
  * Complete a shared content item.
171
171
  * @param contentType The type of shared content to complete. E.g. assignments, exercises, etc.
@@ -177,7 +177,7 @@ export declare class RimoriClient {
177
177
  * @param id The id of the shared content item to remove.
178
178
  * @returns The removed shared content item.
179
179
  */
180
- remove: (id: string) => Promise<BasicAssignment<any>>;
180
+ remove: (id: string) => Promise<SharedContent<any>>;
181
181
  };
182
182
  };
183
183
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimori/client",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -2,16 +2,6 @@ import { SupabaseClient } from '@supabase/supabase-js';
2
2
  import { RimoriClient } from "../plugin/RimoriClient";
3
3
  import { ObjectRequest } from "./ObjectController";
4
4
 
5
- export interface BasicAssignment<T> {
6
- id: string;
7
- createdAt: Date;
8
- topic: string;
9
- createdBy: string;
10
- verified: boolean;
11
- keywords: any;
12
- data: T;
13
- }
14
-
15
5
  export interface SharedContentObjectRequest extends ObjectRequest {
16
6
  fixedProperties?: Record<string, string | number | boolean>
17
7
  }
@@ -41,7 +31,7 @@ export class SharedContentController {
41
31
  //this filter is there if the content should be filtered additionally by a column and value
42
32
  filter?: SharedContentFilter,
43
33
  privateTopic?: boolean,
44
- ): Promise<BasicAssignment<T>> {
34
+ ): Promise<SharedContent<T>> {
45
35
  const query = this.supabase.from("shared_content")
46
36
  .select("*, scc:shared_content_completed(id)")
47
37
  .eq('content_type', contentType)
@@ -111,7 +101,7 @@ export class SharedContentController {
111
101
 
112
102
  private async getCompletedTopics(contentType: string, filter?: SharedContentFilter): Promise<string[]> {
113
103
  const query = this.supabase.from("shared_content")
114
- .select("topic, keywords, scc:shared_content_completed(id)")
104
+ .select("title, keywords, scc:shared_content_completed(id)")
115
105
  .eq('content_type', contentType)
116
106
  .not('scc.id', 'is', null)
117
107
  .is('deleted_at', null)
@@ -126,10 +116,10 @@ export class SharedContentController {
126
116
  console.error('error fetching old assignments:', error);
127
117
  return [];
128
118
  }
129
- return oldAssignments.map(({ topic, keywords }) => `${topic}(${keywords.join(',')})`);
119
+ return oldAssignments.map(({ title, keywords }) => `${title}(${keywords.join(',')})`);
130
120
  }
131
121
 
132
- public async getSharedContent<T>(contentType: string, id: string): Promise<BasicAssignment<T>> {
122
+ public async getSharedContent<T>(contentType: string, id: string): Promise<SharedContent<T>> {
133
123
  const { data, error } = await this.supabase.from("shared_content").select().eq('content_type', contentType).eq('id', id).is('deleted_at', null).single();
134
124
  if (error) {
135
125
  console.error('error fetching shared content:', error);
@@ -149,7 +139,7 @@ export class SharedContentController {
149
139
  * @param limit - Optional limit for the number of results.
150
140
  * @returns Array of shared content matching the criteria.
151
141
  */
152
- public async getSharedContentList<T>(contentType: string, filter?: SharedContentFilter, limit?: number): Promise<BasicAssignment<T>[]> {
142
+ public async getSharedContentList<T>(contentType: string, filter?: SharedContentFilter, limit?: number): Promise<SharedContent<T>[]> {
153
143
  const query = this.supabase.from("shared_content").select("*").eq('content_type', contentType).is('deleted_at', null).limit(limit ?? 30);
154
144
 
155
145
  if (filter) {
@@ -170,18 +160,18 @@ export class SharedContentController {
170
160
  * Insert new shared content into the database.
171
161
  * @param param
172
162
  * @param param.contentType - The type of content to insert.
173
- * @param param.topic - The topic of the content.
163
+ * @param param.title - The title of the content.
174
164
  * @param param.keywords - Keywords associated with the content.
175
165
  * @param param.data - The content data to store.
176
166
  * @param param.privateTopic - Optional flag to indicate if the topic should be private.
177
167
  * @returns The inserted shared content.
178
168
  * @throws {Error} if insertion fails.
179
169
  */
180
- public async createSharedContent<T>({ contentType, topic, keywords, data, privateTopic }: Omit<SharedContent<T>, 'id'>): Promise<BasicAssignment<T>> {
170
+ public async createSharedContent<T>({ contentType, title, keywords, data, privateTopic }: Omit<SharedContent<T>, 'id'>): Promise<SharedContent<T>> {
181
171
  const { data: newContent, error } = await this.supabase.from("shared_content").insert({
182
172
  private: privateTopic,
183
173
  content_type: contentType,
184
- topic,
174
+ title,
185
175
  keywords,
186
176
  data,
187
177
  }).select();
@@ -201,11 +191,11 @@ export class SharedContentController {
201
191
  * @returns The updated shared content.
202
192
  * @throws {Error} if update fails.
203
193
  */
204
- public async updateSharedContent<T>(id: string, updates: Partial<SharedContent<T>>): Promise<BasicAssignment<T>> {
194
+ public async updateSharedContent<T>(id: string, updates: Partial<SharedContent<T>>): Promise<SharedContent<T>> {
205
195
  const updateData: any = {};
206
196
 
207
197
  if (updates.contentType) updateData.content_type = updates.contentType;
208
- if (updates.topic) updateData.topic = updates.topic;
198
+ if (updates.title) updateData.title = updates.title;
209
199
  if (updates.keywords) updateData.keywords = updates.keywords;
210
200
  if (updates.data) updateData.data = updates.data;
211
201
  if (updates.privateTopic !== undefined) updateData.private = updates.privateTopic;
@@ -230,7 +220,7 @@ export class SharedContentController {
230
220
  * @returns The deleted shared content record.
231
221
  * @throws {Error} if deletion fails or content not found.
232
222
  */
233
- public async removeSharedContent(id: string): Promise<BasicAssignment<any>> {
223
+ public async removeSharedContent(id: string): Promise<SharedContent<any>> {
234
224
  const { data: deletedContent, error } = await this.supabase
235
225
  .from("shared_content")
236
226
  .update({ deleted_at: new Date().toISOString() })
@@ -261,8 +251,8 @@ export interface SharedContent<T> {
261
251
  /** The type/category of the content (e.g. 'grammar_exercises', 'flashcards', etc.) */
262
252
  contentType: string;
263
253
 
264
- /** The human readable title/topic of the content */
265
- topic: string;
254
+ /** The human readable title of the content */
255
+ title: string;
266
256
 
267
257
  /** Array of keywords/tags associated with the content for search and categorization */
268
258
  keywords: string[];
package/src/core.ts CHANGED
@@ -5,4 +5,4 @@ export * from "./utils/difficultyConverter";
5
5
  export * from "./utils/PluginUtils";
6
6
  export * from "./worker/WorkerSetup";
7
7
  export * from "./utils/Language";
8
- export { SharedContent, BasicAssignment } from "./controller/SharedContentController";
8
+ export { SharedContent } from "./controller/SharedContentController";
@@ -4,7 +4,7 @@ import { GenericSchema } from "@supabase/supabase-js/dist/module/lib/types";
4
4
  import { generateText, Message, OnLLMResponse, streamChatGPT, Tool } from "../controller/AIController";
5
5
  import { generateObject as generateObjectFunction, ObjectRequest } from "../controller/ObjectController";
6
6
  import { SettingsController, UserInfo } from "../controller/SettingsController";
7
- import { BasicAssignment, SharedContent, SharedContentController, SharedContentFilter, SharedContentObjectRequest } from "../controller/SharedContentController";
7
+ import { SharedContent, SharedContentController, SharedContentFilter, SharedContentObjectRequest } from "../controller/SharedContentController";
8
8
  import { getPlugins } from "../controller/SidePluginController";
9
9
  import { getSTTResponse, getTTSResponse } from "../controller/VoiceController";
10
10
  import { AccomplishmentHandler, AccomplishmentPayload } from "./AccomplishmentHandler";
@@ -240,7 +240,7 @@ export class RimoriClient {
240
240
  * @param id The id of the shared content item.
241
241
  * @returns The shared content item.
242
242
  */
243
- get: async <T = any>(contentType: string, id: string): Promise<BasicAssignment<T>> => {
243
+ get: async <T = any>(contentType: string, id: string): Promise<SharedContent<T>> => {
244
244
  return await this.sharedContentController.getSharedContent(contentType, id);
245
245
  },
246
246
  /**
@@ -250,7 +250,7 @@ export class RimoriClient {
250
250
  * @param limit The optional limit for the number of results.
251
251
  * @returns The list of shared content items.
252
252
  */
253
- getList: async <T = any>(contentType: string, filter?: SharedContentFilter, limit?: number): Promise<BasicAssignment<T>[]> => {
253
+ getList: async <T = any>(contentType: string, filter?: SharedContentFilter, limit?: number): Promise<SharedContent<T>[]> => {
254
254
  return await this.sharedContentController.getSharedContentList(contentType, filter, limit);
255
255
  },
256
256
  /**
@@ -266,7 +266,7 @@ export class RimoriClient {
266
266
  generatorInstructions: SharedContentObjectRequest,
267
267
  filter?: SharedContentFilter,
268
268
  privateTopic?: boolean,
269
- ): Promise<BasicAssignment<T>> => {
269
+ ): Promise<SharedContent<T>> => {
270
270
  return await this.sharedContentController.getNewSharedContent(contentType, generatorInstructions, filter, privateTopic);
271
271
  },
272
272
  /**
@@ -274,7 +274,7 @@ export class RimoriClient {
274
274
  * @param content The content to create.
275
275
  * @returns The new shared content item.
276
276
  */
277
- create: async <T = any>(content: Omit<SharedContent<T>, 'id'>): Promise<BasicAssignment<T>> => {
277
+ create: async <T = any>(content: Omit<SharedContent<T>, 'id'>): Promise<SharedContent<T>> => {
278
278
  return await this.sharedContentController.createSharedContent(content);
279
279
  },
280
280
  /**
@@ -283,7 +283,7 @@ export class RimoriClient {
283
283
  * @param content The content to update.
284
284
  * @returns The updated shared content item.
285
285
  */
286
- update: async <T = any>(id: string, content: Partial<SharedContent<T>>): Promise<BasicAssignment<T>> => {
286
+ update: async <T = any>(id: string, content: Partial<SharedContent<T>>): Promise<SharedContent<T>> => {
287
287
  return await this.sharedContentController.updateSharedContent(id, content);
288
288
  },
289
289
  /**
@@ -299,7 +299,7 @@ export class RimoriClient {
299
299
  * @param id The id of the shared content item to remove.
300
300
  * @returns The removed shared content item.
301
301
  */
302
- remove: async (id: string): Promise<BasicAssignment<any>> => {
302
+ remove: async (id: string): Promise<SharedContent<any>> => {
303
303
  return await this.sharedContentController.removeSharedContent(id);
304
304
  }
305
305
  }