@rimori/client 2.5.26-next.0 → 2.5.26-next.2
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.
|
@@ -8,7 +8,15 @@
|
|
|
8
8
|
* 2. Add an `updated_at` trigger so the image-sync cron can detect recently
|
|
9
9
|
* modified entries. The cron derives which columns to scan from release.db_schema.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* 'vector' is stored as `vector(1536)` in the database (pgvector).
|
|
13
|
+
* Marking a column as 'vector' causes the migration system to:
|
|
14
|
+
* 1. Create the column as `vector(1536)` with nullable constraint.
|
|
15
|
+
* 2. Create an IVFFlat index for cosine similarity search.
|
|
16
|
+
* 3. The column MUST be named 'embedding' and only one per table is allowed.
|
|
17
|
+
* 4. Requires `source_column` — the column whose content is embedded async on insert.
|
|
18
|
+
*/
|
|
19
|
+
type DbColumnType = 'decimal' | 'integer' | 'text' | 'boolean' | 'json' | 'timestamp' | 'uuid' | 'markdown' | 'vector';
|
|
12
20
|
/**
|
|
13
21
|
* Foreign key relationship configuration with cascade delete support.
|
|
14
22
|
* Defines a relationship where the source record is deleted when the destination record is deleted.
|
|
@@ -22,11 +30,11 @@ interface ForeignKeyRelation {
|
|
|
22
30
|
on_delete_cascade: boolean;
|
|
23
31
|
}
|
|
24
32
|
/**
|
|
25
|
-
*
|
|
33
|
+
* Regular (non-vector) database column definition with support for types, constraints, and relationships.
|
|
26
34
|
*/
|
|
27
|
-
|
|
35
|
+
interface DbRegularColumnDefinition {
|
|
28
36
|
/** The data type of the column */
|
|
29
|
-
type: DbColumnType
|
|
37
|
+
type: Exclude<DbColumnType, 'vector'>;
|
|
30
38
|
/** Human-readable description of the column's purpose */
|
|
31
39
|
description: string;
|
|
32
40
|
/** Whether the column can contain null values */
|
|
@@ -36,6 +44,8 @@ export interface DbColumnDefinition {
|
|
|
36
44
|
/** Default value for the column. can also use sql functions like now(), auth.uid() or gen_random_uuid() */
|
|
37
45
|
default_value?: string | number | boolean;
|
|
38
46
|
/** Array of allowed values for enumerated columns */
|
|
47
|
+
/** Not allowed on non-vector columns */
|
|
48
|
+
source_column?: never;
|
|
39
49
|
/** Foreign key relationship configuration */
|
|
40
50
|
foreign_key?: ForeignKeyRelation;
|
|
41
51
|
/** The name of the column before it was renamed. */
|
|
@@ -55,6 +65,39 @@ export interface DbColumnDefinition {
|
|
|
55
65
|
lang_moderator?: Partial<Omit<DbPermissionDefinition, 'delete'>>;
|
|
56
66
|
};
|
|
57
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Vector column definition for semantic search via pgvector.
|
|
70
|
+
* The column MUST be named 'embedding' and only one per table is allowed.
|
|
71
|
+
* The backend generates embeddings asynchronously from the source_column content.
|
|
72
|
+
*/
|
|
73
|
+
interface DbVectorColumnDefinition {
|
|
74
|
+
/** Must be 'vector' */
|
|
75
|
+
type: 'vector';
|
|
76
|
+
/** Human-readable description of the column's purpose */
|
|
77
|
+
description: string;
|
|
78
|
+
/** Vector columns must be nullable (embeddings are generated asynchronously) */
|
|
79
|
+
nullable: true;
|
|
80
|
+
/** The column whose content is embedded. Must reference an existing column in the same table. */
|
|
81
|
+
source_column: string;
|
|
82
|
+
/** Not applicable to vector columns */
|
|
83
|
+
unique?: never;
|
|
84
|
+
/** Not applicable to vector columns */
|
|
85
|
+
default_value?: never;
|
|
86
|
+
/** Not applicable to vector columns */
|
|
87
|
+
foreign_key?: never;
|
|
88
|
+
/** Not applicable to vector columns */
|
|
89
|
+
old_name?: never;
|
|
90
|
+
/** Not applicable to vector columns */
|
|
91
|
+
deprecated?: never;
|
|
92
|
+
/** Not applicable to vector columns */
|
|
93
|
+
restrict?: never;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Database column definition — discriminated union on `type`.
|
|
97
|
+
* Use `type: 'vector'` for embedding columns (enforces `nullable: true` and requires `source_column`).
|
|
98
|
+
* All other types forbid `source_column`.
|
|
99
|
+
*/
|
|
100
|
+
export type DbColumnDefinition = DbRegularColumnDefinition | DbVectorColumnDefinition;
|
|
58
101
|
/**
|
|
59
102
|
* Base table structure that all database tables inherit.
|
|
60
103
|
* Includes standard audit fields for tracking creation and ownership.
|
|
@@ -25,6 +25,21 @@ export type PublicityLevel = 'own' | 'guild' | 'lang';
|
|
|
25
25
|
* Database module for plugin database operations.
|
|
26
26
|
* Provides access to plugin tables with automatic prefixing and schema management.
|
|
27
27
|
*/
|
|
28
|
+
export interface VectorSearchParams {
|
|
29
|
+
/** Table name without plugin prefix (e.g. 'pages') */
|
|
30
|
+
tableName: string;
|
|
31
|
+
/** The text query to search for */
|
|
32
|
+
query: string;
|
|
33
|
+
/** Maximum number of results (default: 5) */
|
|
34
|
+
limit?: number;
|
|
35
|
+
/** Similarity threshold 0-1 (default: 0.5) */
|
|
36
|
+
threshold?: number;
|
|
37
|
+
/** Which columns to return (default: all) */
|
|
38
|
+
selectColumns?: string[];
|
|
39
|
+
}
|
|
40
|
+
export type VectorSearchResult<T = Record<string, unknown>> = Array<T & {
|
|
41
|
+
similarity: number;
|
|
42
|
+
}>;
|
|
28
43
|
export declare class DbModule {
|
|
29
44
|
private supabase;
|
|
30
45
|
private rimoriInfo;
|
|
@@ -63,5 +78,12 @@ export declare class DbModule {
|
|
|
63
78
|
* @param publicity The desired publicity level
|
|
64
79
|
*/
|
|
65
80
|
setPublicity(table: string, entryId: string, publicity: PublicityLevel): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Search a plugin table using vector similarity (cosine distance).
|
|
83
|
+
* The table must have a vector column named 'embedding' defined in db.config.ts.
|
|
84
|
+
* @param params Search parameters
|
|
85
|
+
* @returns Matching rows sorted by similarity
|
|
86
|
+
*/
|
|
87
|
+
vectorSearch<T = Record<string, unknown>>(params: VectorSearchParams): Promise<VectorSearchResult<T>>;
|
|
66
88
|
}
|
|
67
89
|
export {};
|
|
@@ -7,10 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
/**
|
|
11
|
-
* Database module for plugin database operations.
|
|
12
|
-
* Provides access to plugin tables with automatic prefixing and schema management.
|
|
13
|
-
*/
|
|
14
10
|
export class DbModule {
|
|
15
11
|
constructor(supabase, communicationHandler, info) {
|
|
16
12
|
this.supabase = supabase;
|
|
@@ -86,4 +82,26 @@ export class DbModule {
|
|
|
86
82
|
});
|
|
87
83
|
});
|
|
88
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Search a plugin table using vector similarity (cosine distance).
|
|
87
|
+
* The table must have a vector column named 'embedding' defined in db.config.ts.
|
|
88
|
+
* @param params Search parameters
|
|
89
|
+
* @returns Matching rows sorted by similarity
|
|
90
|
+
*/
|
|
91
|
+
vectorSearch(params) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
const response = yield fetch(`${this.rimoriInfo.backendUrl}/plugin-search/vector-search`, {
|
|
94
|
+
method: 'POST',
|
|
95
|
+
headers: {
|
|
96
|
+
'Content-Type': 'application/json',
|
|
97
|
+
Authorization: `Bearer ${this.rimoriInfo.token}`,
|
|
98
|
+
},
|
|
99
|
+
body: JSON.stringify(params),
|
|
100
|
+
});
|
|
101
|
+
if (!response.ok) {
|
|
102
|
+
throw new Error(`Vector search failed: ${response.statusText}`);
|
|
103
|
+
}
|
|
104
|
+
return yield response.json();
|
|
105
|
+
});
|
|
106
|
+
}
|
|
89
107
|
}
|
|
@@ -69,6 +69,13 @@ export declare class EventModule {
|
|
|
69
69
|
* @param text Optional text to be used for the action like for example text that the translator would look up.
|
|
70
70
|
*/
|
|
71
71
|
emitSidebarAction(pluginId: string, actionKey: string, text?: string, args?: Record<string, unknown>): void;
|
|
72
|
+
/**
|
|
73
|
+
* Trigger an action that opens a plugin in the main panel and triggers an action.
|
|
74
|
+
* @param pluginId The id of the plugin to trigger the action for.
|
|
75
|
+
* @param actionKey The key of the action to trigger.
|
|
76
|
+
* @param params Optional additional parameters to pass to the action.
|
|
77
|
+
*/
|
|
78
|
+
emitMainPanelAction(pluginId: string, actionKey: string, params?: Record<string, string>): void;
|
|
72
79
|
/**
|
|
73
80
|
* Subscribe to main panel actions triggered by the user from the dashboard.
|
|
74
81
|
* @param callback Handler function that receives the action data when a matching action is triggered.
|
|
@@ -167,6 +167,15 @@ export class EventModule {
|
|
|
167
167
|
emitSidebarAction(pluginId, actionKey, text, args) {
|
|
168
168
|
this.emit('global.sidebar.triggerAction', { plugin_id: pluginId, action_key: actionKey, text, args });
|
|
169
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Trigger an action that opens a plugin in the main panel and triggers an action.
|
|
172
|
+
* @param pluginId The id of the plugin to trigger the action for.
|
|
173
|
+
* @param actionKey The key of the action to trigger.
|
|
174
|
+
* @param params Optional additional parameters to pass to the action.
|
|
175
|
+
*/
|
|
176
|
+
emitMainPanelAction(pluginId, actionKey, params) {
|
|
177
|
+
this.emit('global.mainPanel.triggerAction', Object.assign({ plugin_id: pluginId, action_key: actionKey }, params));
|
|
178
|
+
}
|
|
170
179
|
/**
|
|
171
180
|
* Subscribe to main panel actions triggered by the user from the dashboard.
|
|
172
181
|
* @param callback Handler function that receives the action data when a matching action is triggered.
|