@rimori/client 2.5.19-next.4 → 2.5.19-next.5
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,39 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PostgrestFilterBuilder, PostgrestQueryBuilder } from '@supabase/postgrest-js';
|
|
2
2
|
import { SupabaseClient } from '../CommunicationHandler';
|
|
3
3
|
import { RimoriCommunicationHandler, RimoriInfo } from '../CommunicationHandler';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
isSetofReturn?: boolean;
|
|
23
|
-
isOneToOne?: boolean;
|
|
24
|
-
isNotNullable?: boolean;
|
|
25
|
-
to: string;
|
|
26
|
-
from: string;
|
|
27
|
-
};
|
|
28
|
-
type GenericFunction = {
|
|
29
|
-
Args: Record<string, unknown> | never;
|
|
30
|
-
Returns: unknown;
|
|
31
|
-
SetofOptions?: GenericSetofOption;
|
|
32
|
-
};
|
|
33
|
-
type GenericSchema = {
|
|
34
|
-
Tables: Record<string, GenericTable>;
|
|
35
|
-
Views: Record<string, GenericView>;
|
|
36
|
-
Functions: Record<string, GenericFunction>;
|
|
4
|
+
/**
|
|
5
|
+
* Wraps PostgrestQueryBuilder and overrides select() to always return Row[].
|
|
6
|
+
*
|
|
7
|
+
* postgrest-js's GetResult type can only infer row types from string literals.
|
|
8
|
+
* Dynamic select strings (e.g. `'col:' + getTableName('other') + '(id)'`) produce
|
|
9
|
+
* GenericStringError. This wrapper forces select() to return Row[] regardless of
|
|
10
|
+
* the query string, so callers using from<Row>() always get typed results.
|
|
11
|
+
*/
|
|
12
|
+
type DbQueryBuilder<Row extends Record<string, unknown>> = Omit<PostgrestQueryBuilder<any, any, {
|
|
13
|
+
Row: Row;
|
|
14
|
+
Insert: Partial<Row>;
|
|
15
|
+
Update: Partial<Row>;
|
|
16
|
+
Relationships: [];
|
|
17
|
+
}, string>, 'select'> & {
|
|
18
|
+
select(columns?: string, options?: {
|
|
19
|
+
head?: boolean;
|
|
20
|
+
count?: 'exact' | 'planned' | 'estimated';
|
|
21
|
+
}): PostgrestFilterBuilder<any, any, Row, Row[], string, any, 'GET'>;
|
|
37
22
|
};
|
|
38
23
|
/**
|
|
39
24
|
* Database module for plugin database operations.
|
|
@@ -49,10 +34,16 @@ export declare class DbModule {
|
|
|
49
34
|
* Query a database table.
|
|
50
35
|
* Global tables (starting with 'global_') remain in public schema.
|
|
51
36
|
* Plugin tables use the schema provided by rimori-main (plugins or plugins_alpha).
|
|
37
|
+
*
|
|
38
|
+
* The generic parameter `Row` lets callers opt-in to typed row access:
|
|
39
|
+
* client.db.from<{ id: string; name: string }>('decks')
|
|
40
|
+
* When omitted, row fields are inferred from the select() string (each field typed as `any`).
|
|
41
|
+
* Works with both literal and dynamic select strings.
|
|
42
|
+
*
|
|
52
43
|
* @param relation The table name (without prefix for plugin tables, with 'global_' for global tables).
|
|
53
44
|
* @returns A Postgrest query builder for the table.
|
|
54
45
|
*/
|
|
55
|
-
from<
|
|
46
|
+
from<Row extends Record<string, unknown> = any>(relation: string): DbQueryBuilder<Row>;
|
|
56
47
|
/**
|
|
57
48
|
* Get the table name for a given plugin table.
|
|
58
49
|
* Internally all tables are prefixed with the plugin id. This function is used to get the correct table name for a given public table.
|
|
@@ -18,6 +18,12 @@ export class DbModule {
|
|
|
18
18
|
* Query a database table.
|
|
19
19
|
* Global tables (starting with 'global_') remain in public schema.
|
|
20
20
|
* Plugin tables use the schema provided by rimori-main (plugins or plugins_alpha).
|
|
21
|
+
*
|
|
22
|
+
* The generic parameter `Row` lets callers opt-in to typed row access:
|
|
23
|
+
* client.db.from<{ id: string; name: string }>('decks')
|
|
24
|
+
* When omitted, row fields are inferred from the select() string (each field typed as `any`).
|
|
25
|
+
* Works with both literal and dynamic select strings.
|
|
26
|
+
*
|
|
21
27
|
* @param relation The table name (without prefix for plugin tables, with 'global_' for global tables).
|
|
22
28
|
* @returns A Postgrest query builder for the table.
|
|
23
29
|
*/
|