@rimori/client 2.5.5-next.0 → 2.5.5-next.1
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.
|
@@ -28,34 +28,36 @@ export class SharedContentController {
|
|
|
28
28
|
//this filter is there if the content should be filtered additionally by a column and value
|
|
29
29
|
filter, options) {
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
var _a, _b, _c, _d, _e;
|
|
31
32
|
// The db cache of the shared content is temporary disabled until the new shared content implementation is completed
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
33
|
+
if (true) {
|
|
34
|
+
let query = this.supabase
|
|
35
|
+
.schema('public')
|
|
36
|
+
.from('shared_content')
|
|
37
|
+
.select('*, scc:shared_content_completed(id, state)')
|
|
38
|
+
.eq('content_type', contentType)
|
|
39
|
+
.not('scc.state', 'in', '("completed","ongoing","hidden")')
|
|
40
|
+
.is('deleted_at', null);
|
|
41
|
+
if ((_b = (_a = options === null || options === void 0 ? void 0 : options.excludeIds) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 > 0) {
|
|
42
|
+
const excludeIds = (_d = (_c = options === null || options === void 0 ? void 0 : options.excludeIds) === null || _c === void 0 ? void 0 : _c.filter((id) => !id.startsWith('internal-temp-id-'))) !== null && _d !== void 0 ? _d : [];
|
|
43
|
+
// Supabase expects raw PostgREST syntax like '("id1","id2")'.
|
|
44
|
+
const excludeList = `(${(_e = excludeIds === null || excludeIds === void 0 ? void 0 : excludeIds.map((id) => `"${id}"`).join(',')) !== null && _e !== void 0 ? _e : ''})`;
|
|
45
|
+
query = query.not('id', 'in', excludeList);
|
|
46
|
+
}
|
|
47
|
+
if (filter) {
|
|
48
|
+
query.contains('data', filter);
|
|
49
|
+
}
|
|
50
|
+
const { data: newAssignments, error } = yield query.limit(30);
|
|
51
|
+
if (error) {
|
|
52
|
+
console.error('error fetching new assignments:', error);
|
|
53
|
+
throw new Error('error fetching new assignments');
|
|
54
|
+
}
|
|
55
|
+
// console.log('newAssignments:', newAssignments);
|
|
56
|
+
if (!(options === null || options === void 0 ? void 0 : options.alwaysGenerateNew) && newAssignments.length > 0) {
|
|
57
|
+
const index = Math.floor(Math.random() * newAssignments.length);
|
|
58
|
+
return newAssignments[index];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
59
61
|
const instructions = yield this.generateNewAssignment(contentType, generatorInstructions, filter);
|
|
60
62
|
console.log('instructions:', instructions);
|
|
61
63
|
//create the shared content object
|
|
@@ -99,6 +101,7 @@ export class SharedContentController {
|
|
|
99
101
|
getCompletedTopics(contentType, filter) {
|
|
100
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
103
|
const query = this.supabase
|
|
104
|
+
.schema('public')
|
|
102
105
|
.from('shared_content')
|
|
103
106
|
.select('title, keywords, scc:shared_content_completed(id)')
|
|
104
107
|
.eq('content_type', contentType)
|
|
@@ -118,6 +121,7 @@ export class SharedContentController {
|
|
|
118
121
|
getSharedContent(contentType, id) {
|
|
119
122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
123
|
const { data, error } = yield this.supabase
|
|
124
|
+
.schema('public')
|
|
121
125
|
.from('shared_content')
|
|
122
126
|
.select()
|
|
123
127
|
.eq('content_type', contentType)
|
|
@@ -135,6 +139,7 @@ export class SharedContentController {
|
|
|
135
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
140
|
// Idempotent completion: upsert on (id, user_id) so repeated calls don't fail
|
|
137
141
|
const { error } = yield this.supabase
|
|
142
|
+
.schema('public')
|
|
138
143
|
.from('shared_content_completed')
|
|
139
144
|
.upsert({ content_type: contentType, id: assignmentId }, { onConflict: 'id' });
|
|
140
145
|
if (error) {
|
|
@@ -164,7 +169,10 @@ export class SharedContentController {
|
|
|
164
169
|
if (bookmarked !== undefined)
|
|
165
170
|
payload.bookmarked = bookmarked;
|
|
166
171
|
// Prefer upsert, fall back to insert/update if upsert not allowed
|
|
167
|
-
const { error } = yield this.supabase
|
|
172
|
+
const { error } = yield this.supabase
|
|
173
|
+
.schema('public')
|
|
174
|
+
.from('shared_content_completed')
|
|
175
|
+
.upsert(payload, { onConflict: 'id' });
|
|
168
176
|
if (error) {
|
|
169
177
|
console.error('error updating shared content state:', error);
|
|
170
178
|
throw new Error('error updating shared content state');
|
|
@@ -181,6 +189,7 @@ export class SharedContentController {
|
|
|
181
189
|
getSharedContentList(contentType, filter, limit) {
|
|
182
190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
183
191
|
const query = this.supabase
|
|
192
|
+
.schema('public')
|
|
184
193
|
.from('shared_content')
|
|
185
194
|
.select('*')
|
|
186
195
|
.eq('content_type', contentType)
|
|
@@ -211,6 +220,7 @@ export class SharedContentController {
|
|
|
211
220
|
createSharedContent(_a) {
|
|
212
221
|
return __awaiter(this, arguments, void 0, function* ({ contentType, title, keywords, data, privateTopic, }) {
|
|
213
222
|
const { data: newContent, error } = yield this.supabase
|
|
223
|
+
.schema('public')
|
|
214
224
|
.from('shared_content')
|
|
215
225
|
.insert({
|
|
216
226
|
private: privateTopic,
|
|
@@ -248,6 +258,7 @@ export class SharedContentController {
|
|
|
248
258
|
if (updates.privateTopic !== undefined)
|
|
249
259
|
updateData.private = updates.privateTopic;
|
|
250
260
|
const { data: updatedContent, error } = yield this.supabase
|
|
261
|
+
.schema('public')
|
|
251
262
|
.from('shared_content')
|
|
252
263
|
.update(updateData)
|
|
253
264
|
.eq('id', id)
|
|
@@ -271,6 +282,7 @@ export class SharedContentController {
|
|
|
271
282
|
removeSharedContent(id) {
|
|
272
283
|
return __awaiter(this, void 0, void 0, function* () {
|
|
273
284
|
const { data: deletedContent, error } = yield this.supabase
|
|
285
|
+
.schema('public')
|
|
274
286
|
.from('shared_content')
|
|
275
287
|
.update({ deleted_at: new Date().toISOString() })
|
|
276
288
|
.eq('id', id)
|
|
@@ -32,6 +32,7 @@ export interface MenuEntry {
|
|
|
32
32
|
action_key: string;
|
|
33
33
|
text: string;
|
|
34
34
|
iconUrl?: string;
|
|
35
|
+
args?: Record<string, unknown>;
|
|
35
36
|
}
|
|
36
37
|
export type MainPanelAction = {
|
|
37
38
|
plugin_id: string;
|
|
@@ -41,6 +42,7 @@ export interface ContextMenuAction {
|
|
|
41
42
|
text: string;
|
|
42
43
|
plugin_id: string;
|
|
43
44
|
action_key: string;
|
|
45
|
+
args?: Record<string, unknown>;
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
46
48
|
* Rimori plugin structure representing the complete configuration
|
|
@@ -79,7 +81,7 @@ export interface RimoriPluginConfig<T extends object = object> {
|
|
|
79
81
|
/**
|
|
80
82
|
* Context menu actions that the plugin registers to appear in right-click menus throughout the application.
|
|
81
83
|
*/
|
|
82
|
-
context_menu_actions: Omit<MenuEntry, 'plugin_id'>[];
|
|
84
|
+
context_menu_actions: Omit<MenuEntry, 'plugin_id' | 'args'>[];
|
|
83
85
|
/**
|
|
84
86
|
* Documentation paths for different types of plugin documentation.
|
|
85
87
|
*/
|
|
@@ -64,7 +64,7 @@ export declare class EventModule {
|
|
|
64
64
|
* @param actionKey The key of the action to trigger.
|
|
65
65
|
* @param text Optional text to be used for the action like for example text that the translator would look up.
|
|
66
66
|
*/
|
|
67
|
-
emitSidebarAction(pluginId: string, actionKey: string, text?: string): void;
|
|
67
|
+
emitSidebarAction(pluginId: string, actionKey: string, text?: string, args?: Record<string, unknown>): void;
|
|
68
68
|
/**
|
|
69
69
|
* Subscribe to main panel actions triggered by the user from the dashboard.
|
|
70
70
|
* @param callback Handler function that receives the action data when a matching action is triggered.
|
|
@@ -102,8 +102,8 @@ export class EventModule {
|
|
|
102
102
|
* @param actionKey The key of the action to trigger.
|
|
103
103
|
* @param text Optional text to be used for the action like for example text that the translator would look up.
|
|
104
104
|
*/
|
|
105
|
-
emitSidebarAction(pluginId, actionKey, text) {
|
|
106
|
-
this.emit('global.sidebar.triggerAction', { plugin_id: pluginId, action_key: actionKey, text });
|
|
105
|
+
emitSidebarAction(pluginId, actionKey, text, args) {
|
|
106
|
+
this.emit('global.sidebar.triggerAction', { plugin_id: pluginId, action_key: actionKey, text, args });
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
109
|
* Subscribe to main panel actions triggered by the user from the dashboard.
|