@rimori/client 1.0.4 → 1.1.0

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.
Files changed (95) hide show
  1. package/README.md +13 -0
  2. package/dist/components/MarkdownEditor.js +6 -4
  3. package/dist/components/PluginController.d.ts +21 -0
  4. package/dist/components/PluginController.js +116 -0
  5. package/dist/components/ai/Assistant.js +1 -1
  6. package/dist/components/ai/Avatar.d.ts +5 -3
  7. package/dist/components/ai/Avatar.js +14 -6
  8. package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.d.ts +2 -1
  9. package/dist/components/ai/EmbeddedAssistent/CircleAudioAvatar.js +35 -14
  10. package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.d.ts +1 -0
  11. package/dist/components/ai/EmbeddedAssistent/TTS/MessageSender.js +3 -0
  12. package/dist/components/ai/EmbeddedAssistent/TTS/Player.d.ts +2 -0
  13. package/dist/components/ai/EmbeddedAssistent/TTS/Player.js +5 -0
  14. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.d.ts +3 -0
  15. package/dist/components/ai/EmbeddedAssistent/VoiceRecoder.js +41 -5
  16. package/dist/components/ai/utils.d.ts +1 -1
  17. package/dist/components.d.ts +1 -0
  18. package/dist/components.js +1 -0
  19. package/dist/controller/AIController.js +2 -1
  20. package/dist/controller/SettingsController.d.ts +18 -10
  21. package/dist/controller/SettingsController.js +28 -31
  22. package/dist/controller/SharedContentController.d.ts +58 -11
  23. package/dist/controller/SharedContentController.js +161 -26
  24. package/dist/controller/SidePluginController.d.ts +1 -12
  25. package/dist/core/components/ContextMenu.d.ts +10 -0
  26. package/dist/core/components/ContextMenu.js +93 -0
  27. package/dist/core.d.ts +2 -0
  28. package/dist/core.js +2 -0
  29. package/dist/hooks/UseChatHook.d.ts +1 -1
  30. package/dist/plugin/AccomplishmentHandler.d.ts +38 -0
  31. package/dist/plugin/AccomplishmentHandler.js +108 -0
  32. package/dist/plugin/ContextMenu.d.ts +17 -0
  33. package/dist/plugin/ContextMenu.js +45 -0
  34. package/dist/plugin/PluginController.js +9 -4
  35. package/dist/plugin/RimoriClient.d.ts +92 -65
  36. package/dist/plugin/RimoriClient.js +105 -75
  37. package/dist/plugin/ThemeSetter.js +4 -4
  38. package/dist/plugin/fromRimori/EventBus.d.ts +6 -3
  39. package/dist/plugin/fromRimori/EventBus.js +15 -9
  40. package/dist/plugin/fromRimori/PluginTypes.d.ts +51 -0
  41. package/dist/plugin/fromRimori/PluginTypes.js +1 -0
  42. package/dist/providers/PluginController.d.ts +21 -0
  43. package/dist/providers/PluginController.js +116 -0
  44. package/dist/providers/PluginProvider.js +26 -73
  45. package/dist/types/Actions.d.ts +4 -0
  46. package/dist/types/Actions.js +1 -0
  47. package/dist/utils/Language.d.ts +66 -0
  48. package/dist/utils/Language.js +67 -0
  49. package/dist/utils/difficultyConverter.d.ts +1 -0
  50. package/dist/utils/difficultyConverter.js +3 -0
  51. package/dist/worker/WorkerSetup.js +5 -4
  52. package/package.json +3 -3
  53. package/src/components/MarkdownEditor.tsx +78 -76
  54. package/src/components/ai/Assistant.tsx +1 -1
  55. package/src/components/ai/Avatar.tsx +65 -48
  56. package/src/components/ai/EmbeddedAssistent/CircleAudioAvatar.tsx +81 -58
  57. package/src/components/ai/EmbeddedAssistent/TTS/MessageSender.ts +4 -0
  58. package/src/components/ai/EmbeddedAssistent/TTS/Player.ts +6 -0
  59. package/src/components/ai/EmbeddedAssistent/VoiceRecoder.tsx +51 -8
  60. package/src/components/ai/utils.ts +1 -1
  61. package/src/components.ts +2 -1
  62. package/src/controller/AIController.ts +2 -1
  63. package/src/controller/SettingsController.ts +80 -75
  64. package/src/controller/SharedContentController.ts +214 -53
  65. package/src/controller/SidePluginController.ts +1 -13
  66. package/src/core/components/ContextMenu.tsx +123 -0
  67. package/src/core.ts +3 -1
  68. package/src/hooks/UseChatHook.ts +17 -17
  69. package/src/plugin/AccomplishmentHandler.ts +165 -0
  70. package/src/plugin/PluginController.ts +107 -100
  71. package/src/plugin/RimoriClient.ts +267 -250
  72. package/src/plugin/ThemeSetter.ts +4 -5
  73. package/src/plugin/fromRimori/EventBus.ts +23 -12
  74. package/src/plugin/fromRimori/PluginTypes.ts +67 -0
  75. package/src/providers/PluginProvider.tsx +63 -110
  76. package/src/types/Actions.ts +6 -0
  77. package/src/utils/Language.ts +70 -0
  78. package/src/utils/difficultyConverter.ts +4 -0
  79. package/src/worker/WorkerSetup.ts +5 -4
  80. package/dist/components/avatar/Assistant.d.ts +0 -9
  81. package/dist/components/avatar/Assistant.js +0 -59
  82. package/dist/components/avatar/Avatar.d.ts +0 -12
  83. package/dist/components/avatar/Avatar.js +0 -42
  84. package/dist/components/avatar/EmbeddedAssistent/AudioInputField.d.ts +0 -7
  85. package/dist/components/avatar/EmbeddedAssistent/AudioInputField.js +0 -38
  86. package/dist/components/avatar/EmbeddedAssistent/CircleAudioAvatar.d.ts +0 -7
  87. package/dist/components/avatar/EmbeddedAssistent/CircleAudioAvatar.js +0 -59
  88. package/dist/components/avatar/EmbeddedAssistent/TTS/MessageSender.d.ts +0 -19
  89. package/dist/components/avatar/EmbeddedAssistent/TTS/MessageSender.js +0 -84
  90. package/dist/components/avatar/EmbeddedAssistent/TTS/Player.d.ts +0 -25
  91. package/dist/components/avatar/EmbeddedAssistent/TTS/Player.js +0 -180
  92. package/dist/components/avatar/EmbeddedAssistent/VoiceRecoder.d.ts +0 -7
  93. package/dist/components/avatar/EmbeddedAssistent/VoiceRecoder.js +0 -45
  94. package/dist/components/avatar/utils.d.ts +0 -6
  95. package/dist/components/avatar/utils.js +0 -14
@@ -0,0 +1,108 @@
1
+ import { EventBus } from "./fromRimori/EventBus";
2
+ export const skillCategories = ["reading", "listening", "speaking", "writing", "learning", "community"];
3
+ export class AccomplishmentHandler {
4
+ constructor(pluginId) {
5
+ this.pluginId = pluginId;
6
+ }
7
+ emitAccomplishment(payload) {
8
+ const accomplishmentPayload = Object.assign(Object.assign({}, payload), { type: "durationMinutes" in payload ? "macro" : "micro" });
9
+ this.validateAccomplishment(accomplishmentPayload);
10
+ const sanitizedPayload = this.sanitizeAccomplishment(accomplishmentPayload);
11
+ const topic = "global.accomplishment.trigger" + (accomplishmentPayload.type === "macro" ? "Macro" : "Micro");
12
+ EventBus.emit(this.pluginId, topic, sanitizedPayload);
13
+ }
14
+ validateAccomplishment(payload) {
15
+ if (!skillCategories.includes(payload.skillCategory)) {
16
+ throw new Error(`Invalid skill category: ${payload.skillCategory}`);
17
+ }
18
+ //regex validate accomplishmentKeyword
19
+ if (!/^[a-z_-]+$/.test(payload.accomplishmentKeyword)) {
20
+ throw new Error(`The accomplishment keyword: ${payload.accomplishmentKeyword} is invalid. Only lowercase letters, minuses and underscores are allowed`);
21
+ }
22
+ //description is required
23
+ if (payload.description.length < 10) {
24
+ throw new Error("Description is too short");
25
+ }
26
+ //check that the type is valid
27
+ if (!["micro", "macro"].includes(payload.type)) {
28
+ throw new Error("Invalid accomplishment type " + payload.type);
29
+ }
30
+ //durationMinutes is required
31
+ if (payload.type === "macro" && payload.durationMinutes < 4) {
32
+ throw new Error("The duration must be at least 4 minutes");
33
+ }
34
+ //errorRatio is required
35
+ if (payload.type === "macro" && (payload.errorRatio < 0 || payload.errorRatio > 1)) {
36
+ throw new Error("The error ratio must be between 0 and 1");
37
+ }
38
+ //regex check meta data key
39
+ if (payload.meta) {
40
+ payload.meta.forEach(meta => {
41
+ if (!/^[a-z_]+$/.test(meta.key)) {
42
+ throw new Error("Invalid meta data key " + meta.key + ", only lowercase letters and underscores are allowed");
43
+ }
44
+ });
45
+ }
46
+ }
47
+ sanitizeAccomplishment(payload) {
48
+ var _a;
49
+ payload.description = payload.description.replace(/[^\x20-\x7E]/g, "");
50
+ (_a = payload.meta) === null || _a === void 0 ? void 0 : _a.forEach((meta) => {
51
+ meta.description = meta.description.replace(/[^\x20-\x7E]/g, "");
52
+ });
53
+ return payload;
54
+ }
55
+ getDecoupledTopic(topic) {
56
+ const [plugin, skillCategory, accomplishmentKeyword] = topic.split(".");
57
+ return { plugin: plugin || "*", skillCategory: skillCategory || "*", accomplishmentKeyword: accomplishmentKeyword || "*" };
58
+ }
59
+ /**
60
+ * Subscribe to accomplishment events
61
+ * @param accomplishmentTopic - The topic of the accomplishment event. The pattern can be any pattern of plugin.skillCategory.accomplishmentKeyword or an * as wildcard for any plugin, skill category or accomplishment keyword
62
+ * @param callback - The callback function to be called when the accomplishment event is triggered
63
+ */
64
+ subscribe(accomplishmentTopics = "*", callback) {
65
+ if (typeof accomplishmentTopics === "string") {
66
+ accomplishmentTopics = [accomplishmentTopics];
67
+ }
68
+ accomplishmentTopics.forEach((accomplishmentTopic) => {
69
+ const topicLength = accomplishmentTopic.split(".").length;
70
+ if (topicLength === 1) {
71
+ accomplishmentTopic += ".*.*";
72
+ }
73
+ else if (topicLength === 2) {
74
+ accomplishmentTopic += ".*";
75
+ }
76
+ else if (topicLength !== 3) {
77
+ throw new Error("Invalid accomplishment topic pattern. The pattern must be plugin.skillCategory.accomplishmentKeyword or an * as wildcard for any plugin, skill category or accomplishment keyword");
78
+ }
79
+ EventBus.on(["global.accomplishment.triggerMicro", "global.accomplishment.triggerMacro"], (event) => {
80
+ const { plugin, skillCategory, accomplishmentKeyword } = this.getDecoupledTopic(accomplishmentTopic);
81
+ if (plugin !== "*" && event.sender !== plugin)
82
+ return;
83
+ if (skillCategory !== "*" && event.data.skillCategory !== skillCategory)
84
+ return;
85
+ if (accomplishmentKeyword !== "*" && event.data.accomplishmentKeyword !== accomplishmentKeyword)
86
+ return;
87
+ callback(event);
88
+ }, [this.pluginId]);
89
+ });
90
+ }
91
+ }
92
+ // const accomplishmentHandler = AccomplishmentHandler.getInstance("my-plugin");
93
+ // accomplishmentHandler.subscribe("*", (payload) => {
94
+ // console.log(payload);
95
+ // });
96
+ // accomplishmentHandler.emitAccomplishment({
97
+ // skillCategory: "reading",
98
+ // accomplishmentKeyword: "chapter",
99
+ // description: "Read chapter 1 of the book",
100
+ // durationMinutes: 10,
101
+ // meta: [
102
+ // {
103
+ // key: "book",
104
+ // value: "The Great Gatsby",
105
+ // description: "The book I read",
106
+ // },
107
+ // ],
108
+ // });
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ interface Props {
3
+ iframeRef: React.RefObject<HTMLIFrameElement | null>;
4
+ }
5
+ export interface ContextMenuInfo {
6
+ x: number;
7
+ y: number;
8
+ text: string;
9
+ open: boolean;
10
+ }
11
+ export interface ContextMenuAction {
12
+ text: string;
13
+ pluginId: string;
14
+ actionKey: string;
15
+ }
16
+ declare const ContextMenu: ({ iframeRef }: Props) => import("react/jsx-runtime").JSX.Element | null;
17
+ export default ContextMenu;
@@ -0,0 +1,45 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { EventBus } from "@/lib/handler/EventBus";
3
+ import { useState, useEffect } from "react";
4
+ import { SupabaseClient } from "@/integrations/supabase/client";
5
+ const ContextMenu = ({ iframeRef }) => {
6
+ const [showMenu, setMenuVisibility] = useState(false);
7
+ const [constextActions, setContextMenuActions] = useState([]);
8
+ const [contextMenu, setContextMenu] = useState({ x: 0, y: 0, open: false, text: "" });
9
+ useEffect(() => {
10
+ SupabaseClient.getPlugins().then(plugins => {
11
+ setContextMenuActions(plugins.flatMap(p => p.context_menu_actions));
12
+ });
13
+ }, []);
14
+ useEffect(() => {
15
+ // Hide the menu on click outside
16
+ const handleClick = () => setMenuVisibility(false);
17
+ document.addEventListener("click", handleClick);
18
+ return () => document.removeEventListener("click", handleClick);
19
+ }, []);
20
+ useEffect(() => {
21
+ EventBus.on("global.contextMenu.createActions", ({ data }) => {
22
+ console.log("addContextMenuActions", data.actions);
23
+ setContextMenuActions([...data.actions, ...constextActions]);
24
+ });
25
+ EventBus.on("global.contextMenu.trigger", ({ data }) => {
26
+ if (!iframeRef.current)
27
+ return;
28
+ const { x, y, open, text } = data;
29
+ const rect = iframeRef.current.getBoundingClientRect();
30
+ setContextMenu({ x: x + rect.left, y: y + rect.top, open, text });
31
+ setMenuVisibility(open);
32
+ });
33
+ }, []);
34
+ if (!showMenu) {
35
+ return null;
36
+ }
37
+ return (_jsx("div", { className: "fixed bg-gray-400 dark:bg-gray-700 shadow-lg border border-gray-400 rounded-md overflow-hidden dark:text-white", style: { top: contextMenu.y, left: contextMenu.x }, children: constextActions.map((action, index) => (_jsx(MenuEntryItem, { icon: action.icon, text: action.text, onClick: () => {
38
+ setMenuVisibility(false);
39
+ EventBus.emit("global.contextMenu", "global.sidebar.triggerAction", Object.assign(Object.assign({}, action), { text: contextMenu.text }));
40
+ } }, index))) }));
41
+ };
42
+ function MenuEntryItem(props) {
43
+ return _jsxs("button", { onClick: props.onClick, className: "px-4 py-2 text-left hover:bg-gray-500 dark:hover:bg-gray-600 w-full flex flex-row", children: [_jsx("span", { className: "flex-grow", children: props.icon }), _jsx("span", { className: "flex-grow", children: props.text })] });
44
+ }
45
+ export default ContextMenu;
@@ -11,7 +11,6 @@ import { createClient } from '@supabase/supabase-js';
11
11
  import { RimoriClient } from "./RimoriClient";
12
12
  import { EventBus } from './fromRimori/EventBus';
13
13
  import { setTheme } from './ThemeSetter';
14
- setTheme();
15
14
  export class PluginController {
16
15
  constructor(pluginId) {
17
16
  this.communicationSecret = null;
@@ -19,6 +18,9 @@ export class PluginController {
19
18
  this.supabaseInfo = null;
20
19
  this.pluginId = pluginId;
21
20
  this.getClient = this.getClient.bind(this);
21
+ if (typeof WorkerGlobalScope === 'undefined') {
22
+ setTheme();
23
+ }
22
24
  window.addEventListener("message", (event) => {
23
25
  // console.log("client: message received", event);
24
26
  const { topic, sender, data, eventId } = event.data.event;
@@ -91,7 +93,7 @@ export class PluginController {
91
93
  return this.supabaseInfo.url;
92
94
  }
93
95
  getGlobalEventTopic(preliminaryTopic) {
94
- var _a, _b, _c;
96
+ var _a, _b;
95
97
  if (preliminaryTopic.startsWith("global.")) {
96
98
  return preliminaryTopic;
97
99
  }
@@ -100,12 +102,15 @@ export class PluginController {
100
102
  }
101
103
  const topicParts = preliminaryTopic.split(".");
102
104
  if (topicParts.length === 3) {
103
- if (![(_a = this.supabaseInfo) === null || _a === void 0 ? void 0 : _a.pluginId, "global"].includes(topicParts[0])) {
105
+ if (!topicParts[0].startsWith("pl") && topicParts[0] !== "global") {
104
106
  throw new Error("The event topic must start with the plugin id or 'global'.");
105
107
  }
106
108
  return preliminaryTopic;
107
109
  }
108
- const topicRoot = (_c = (_b = this.supabaseInfo) === null || _b === void 0 ? void 0 : _b.pluginId) !== null && _c !== void 0 ? _c : "global";
110
+ else if (topicParts.length > 3) {
111
+ throw new Error(`The event topic must consist of 3 parts. <pluginId>.<topic area>.<action>. Received: ${preliminaryTopic}`);
112
+ }
113
+ const topicRoot = (_b = (_a = this.supabaseInfo) === null || _a === void 0 ? void 0 : _a.pluginId) !== null && _b !== void 0 ? _b : "global";
109
114
  return `${topicRoot}.${preliminaryTopic}`;
110
115
  }
111
116
  }
@@ -1,30 +1,34 @@
1
- import { PluginController } from "./PluginController";
1
+ import { PostgrestQueryBuilder } from "@supabase/postgrest-js";
2
2
  import { SupabaseClient } from "@supabase/supabase-js";
3
- import { EventBusMessage, EventPayload } from "./fromRimori/EventBus";
4
3
  import { GenericSchema } from "@supabase/supabase-js/dist/module/lib/types";
5
- import { PostgrestQueryBuilder, PostgrestFilterBuilder } from "@supabase/postgrest-js";
6
- import { BasicAssignment } from "../controller/SharedContentController";
7
- import { Message, Tool, OnLLMResponse } from "../controller/AIController";
4
+ import { Message, OnLLMResponse, Tool } from "../controller/AIController";
8
5
  import { ObjectRequest } from "../controller/ObjectController";
9
- import { Plugin } from "../controller/SidePluginController";
10
6
  import { UserInfo } from "../controller/SettingsController";
11
- import { EventHandler } from "./fromRimori/EventBus";
7
+ import { BasicAssignment, SharedContent, SharedContentFilter, SharedContentObjectRequest } from "../controller/SharedContentController";
8
+ import { AccomplishmentPayload } from "./AccomplishmentHandler";
9
+ import { EventBusMessage, EventHandler, EventPayload } from "./fromRimori/EventBus";
10
+ import { Plugin } from "./fromRimori/PluginTypes";
11
+ import { PluginController } from "./PluginController";
12
12
  interface Db {
13
13
  from: {
14
14
  <TableName extends string & keyof GenericSchema['Tables'], Table extends GenericSchema['Tables'][TableName]>(relation: TableName): PostgrestQueryBuilder<GenericSchema, Table, TableName>;
15
15
  <ViewName extends string & keyof GenericSchema['Views'], View extends GenericSchema['Views'][ViewName]>(relation: ViewName): PostgrestQueryBuilder<GenericSchema, View, ViewName>;
16
16
  };
17
- rpc: <Fn extends GenericSchema['Functions'][string], FnName extends string & keyof GenericSchema['Functions']>(functionName: FnName, args?: Fn["Args"], options?: {
18
- head?: boolean;
19
- get?: boolean;
20
- count?: "exact" | "planned" | "estimated";
21
- }) => PostgrestFilterBuilder<GenericSchema, Fn["Returns"] extends any[] ? Fn["Returns"][number] extends Record<string, unknown> ? Fn["Returns"][number] : never : never, Fn["Returns"], string, null>;
22
- functions: SupabaseClient["functions"];
23
17
  storage: SupabaseClient["storage"];
18
+ /**
19
+ * The table prefix for of database tables of the plugin.
20
+ */
21
+ tablePrefix: string;
22
+ /**
23
+ * Get the table name for a given plugin table.
24
+ * Internally all tables are prefixed with the plugin id. This function is used to get the correct table name for a given public table.
25
+ * @param table The plugin table name to get the full table name for.
26
+ * @returns The full table name.
27
+ */
28
+ getTableName: (table: string) => string;
24
29
  }
25
30
  interface PluginInterface {
26
31
  pluginId: string;
27
- tablePrefix: string;
28
32
  setSettings: (settings: any) => Promise<void>;
29
33
  /**
30
34
  * Get the settings for the plugin. T can be any type of settings, UserSettings or SystemSettings.
@@ -46,6 +50,7 @@ export declare class RimoriClient {
46
50
  private pluginController;
47
51
  private settingsController;
48
52
  private sharedContentController;
53
+ private accomplishmentHandler;
49
54
  private supabaseUrl;
50
55
  db: Db;
51
56
  plugin: PluginInterface;
@@ -61,7 +66,7 @@ export declare class RimoriClient {
61
66
  * @param data The data to emit.
62
67
  * @param eventId The event id.
63
68
  */
64
- emit: (topic: string, data: any, eventId?: number) => void;
69
+ emit: (topic: string, data?: any, eventId?: number) => void;
65
70
  /**
66
71
  * Request an event.
67
72
  * @param topic The topic to request the event on.
@@ -73,8 +78,9 @@ export declare class RimoriClient {
73
78
  * Subscribe to an event.
74
79
  * @param topic The topic to subscribe to.
75
80
  * @param callback The callback to call when the event is emitted.
81
+ * @returns The unsubscribe ids.
76
82
  */
77
- on: <T = EventPayload>(topic: string, callback: EventHandler<T>) => void;
83
+ on: <T = EventPayload>(topic: string | string[], callback: EventHandler<T>) => import("./fromRimori/EventBus").EventListener[];
78
84
  /**
79
85
  * Subscribe to an event once.
80
86
  * @param topic The topic to subscribe to.
@@ -87,33 +93,27 @@ export declare class RimoriClient {
87
93
  * @param data The data to respond with.
88
94
  */
89
95
  respond: <T = EventPayload>(topic: string, data: EventPayload | ((data: EventBusMessage<T>) => EventPayload | Promise<EventPayload>)) => void;
96
+ /**
97
+ * Emit an accomplishment.
98
+ * @param payload The payload to emit.
99
+ */
100
+ emitAccomplishment: (payload: AccomplishmentPayload) => void;
101
+ /**
102
+ * Subscribe to an accomplishment.
103
+ * @param accomplishmentTopic The topic to subscribe to.
104
+ * @param callback The callback to call when the accomplishment is emitted.
105
+ */
106
+ onAccomplishment: (accomplishmentTopic: string, callback: (payload: EventBusMessage<AccomplishmentPayload>) => void) => void;
107
+ /**
108
+ * Trigger an action that opens the sidebar and triggers an action in the designated plugin.
109
+ * @param pluginId The id of the plugin to trigger the action for.
110
+ * @param actionKey The key of the action to trigger.
111
+ * @param text Optional text to be used for the action like for example text that the translator would look up.
112
+ */
113
+ emitSidebarAction: (pluginId: string, actionKey: string, text?: string) => void;
90
114
  };
91
115
  static getInstance(pluginController: PluginController): Promise<RimoriClient>;
92
116
  private from;
93
- /**
94
- * Perform a function call.
95
- *
96
- * @param functionName - The function name to call
97
- * @param args - The arguments to pass to the function call
98
- * @param options - Named parameters
99
- * @param options.head - When set to `true`, `data` will not be returned.
100
- * Useful if you only need the count.
101
- * @param options.get - When set to `true`, the function will be called with
102
- * read-only access mode.
103
- * @param options.count - Count algorithm to use to count rows returned by the
104
- * function. Only applicable for [set-returning
105
- * functions](https://www.postgresql.org/docs/current/functions-srf.html).
106
- *
107
- * `"exact"`: Exact but slow count algorithm. Performs a `COUNT(*)` under the
108
- * hood.
109
- *
110
- * `"planned"`: Approximated but fast count algorithm. Uses the Postgres
111
- * statistics under the hood.
112
- *
113
- * `"estimated"`: Uses exact count for low numbers and planned count for high
114
- * numbers.
115
- */
116
- private rpc;
117
117
  private getTableName;
118
118
  llm: {
119
119
  getText: (messages: Message[], tools?: Tool[]) => Promise<string>;
@@ -122,30 +122,57 @@ export declare class RimoriClient {
122
122
  getTextFromVoice: (file: Blob) => Promise<string>;
123
123
  getObject: (request: ObjectRequest) => Promise<any>;
124
124
  };
125
- /**
126
- * Fetch new shared content.
127
- * @param type The type of shared content to fetch. E.g. assignments, exercises, etc.
128
- * @param generatorInstructions The instructions for the generator.
129
- * @param filter The filter for the shared content.
130
- * @returns The new shared content.
131
- */
132
- fetchNewSharedContent<T, R = T & BasicAssignment>(type: string, generatorInstructions: (reservedTopics: string[]) => Promise<ObjectRequest> | ObjectRequest, filter?: {
133
- column: string;
134
- value: string | number | boolean;
135
- }): Promise<R[]>;
136
- /**
137
- * Get a shared content item by id.
138
- * @param type The type of shared content to get. E.g. assignments, exercises, etc.
139
- * @param id The id of the shared content item.
140
- * @returns The shared content item.
141
- */
142
- getSharedContent<T extends BasicAssignment>(type: string, id: string): Promise<T>;
143
- /**
144
- * Complete a shared content item.
145
- * @param type The type of shared content to complete. E.g. assignments, exercises, etc.
146
- * @param assignmentId The id of the shared content item to complete.
147
- */
148
- completeSharedContent(type: string, assignmentId: string): Promise<void>;
149
- triggerSidebarAction(pluginId: string, actionKey: string, text?: string): void;
125
+ community: {
126
+ /**
127
+ * Shared content is a way to share completable content with other users using this plugin.
128
+ * Typical examples are assignments, exercises, stories, etc.
129
+ * Users generate new shared content items and others can complete the content too.
130
+ */
131
+ sharedContent: {
132
+ /**
133
+ * Get one dedicated shared content item by id. It does not matter if it is completed or not.
134
+ * @param contentType The type of shared content to get. E.g. assignments, exercises, etc.
135
+ * @param id The id of the shared content item.
136
+ * @returns The shared content item.
137
+ */
138
+ get: <T = any>(contentType: string, id: string) => Promise<BasicAssignment<T>>;
139
+ /**
140
+ * Get a list of shared content items.
141
+ * @param contentType The type of shared content to get. E.g. assignments, exercises, etc.
142
+ * @param filter The optional additional filter for checking new shared content based on a column and value. This is useful if the aditional information stored on the shared content is used to further narrow down the kind of shared content wanted to be received. E.g. only adjective grammar exercises.
143
+ * @param limit The optional limit for the number of results.
144
+ * @returns The list of shared content items.
145
+ */
146
+ getList: <T = any>(contentType: string, filter?: SharedContentFilter, limit?: number) => Promise<BasicAssignment<T>[]>;
147
+ /**
148
+ * Get new shared content.
149
+ * @param contentType The type of shared content to fetch. E.g. assignments, exercises, etc.
150
+ * @param generatorInstructions The instructions for the creation of new shared content. The object will automatically be extended with a tool property with a topic and keywords property to let a new unique topic be generated.
151
+ * @param filter The optional additional filter for checking new shared content based on a column and value. This is useful if the aditional information stored on the shared content is used to further narrow down the kind of shared content wanted to be received. E.g. only adjective grammar exercises.
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
+ * @returns The new shared content.
154
+ */
155
+ getNew: <T = any>(contentType: string, generatorInstructions: SharedContentObjectRequest, filter?: SharedContentFilter, privateTopic?: boolean) => Promise<BasicAssignment<T>>;
156
+ /**
157
+ * Create a new shared content item.
158
+ * @param content The content to create.
159
+ * @returns The new shared content item.
160
+ */
161
+ create: <T = any>(content: SharedContent<T>) => Promise<BasicAssignment<T>>;
162
+ /**
163
+ * Update a shared content item.
164
+ * @param id The id of the shared content item to update.
165
+ * @param content The content to update.
166
+ * @returns The updated shared content item.
167
+ */
168
+ update: <T = any>(id: string, content: Partial<SharedContent<T>>) => Promise<BasicAssignment<T>>;
169
+ /**
170
+ * Complete a shared content item.
171
+ * @param contentType The type of shared content to complete. E.g. assignments, exercises, etc.
172
+ * @param assignmentId The id of the shared content item to complete.
173
+ */
174
+ complete: (contentType: string, assignmentId: string) => Promise<void>;
175
+ };
176
+ };
150
177
  }
151
178
  export {};