@ragable/sdk 0.6.16 → 0.6.18
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.
- package/dist/index.d.mts +37 -23
- package/dist/index.d.ts +37 -23
- package/dist/index.js +19 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -22,11 +22,9 @@ type RagableTableDefinition<Row extends Record<string, unknown> = Record<string,
|
|
|
22
22
|
*/
|
|
23
23
|
interface RagableDatabase {
|
|
24
24
|
public: {
|
|
25
|
-
Tables:
|
|
26
|
-
Views?:
|
|
27
|
-
|
|
28
|
-
}>;
|
|
29
|
-
Enums?: Record<string, string>;
|
|
25
|
+
Tables: object;
|
|
26
|
+
Views?: object;
|
|
27
|
+
Enums?: object;
|
|
30
28
|
};
|
|
31
29
|
}
|
|
32
30
|
/**
|
|
@@ -798,10 +796,10 @@ declare function normalizeBrowserApiBase(): string;
|
|
|
798
796
|
type BrowserDataAuthMode = "user" | "publicAnon" | "admin";
|
|
799
797
|
/**
|
|
800
798
|
* Resolves how database requests are authorized. If `dataAuth` is omitted and a
|
|
801
|
-
* static browser
|
|
802
|
-
* defaults to **`publicAnon`** so
|
|
803
|
-
* Use explicit **`dataAuth: "user"`** when you need JWT sessions; use
|
|
804
|
-
* when the static key is a data-admin key
|
|
799
|
+
* static browser data key is configured (`dataStaticKey` / `getDataStaticKey`),
|
|
800
|
+
* defaults to **`publicAnon`** so public apps can use shared collections without
|
|
801
|
+
* sign-in. Use explicit **`dataAuth: "user"`** when you need JWT sessions; use
|
|
802
|
+
* **`"admin"`** when the static key is a data-admin key.
|
|
805
803
|
*/
|
|
806
804
|
declare function effectiveDataAuth(options: RagableBrowserClientOptions): BrowserDataAuthMode;
|
|
807
805
|
interface RagableBrowserClientOptions {
|
|
@@ -810,7 +808,7 @@ interface RagableBrowserClientOptions {
|
|
|
810
808
|
databaseInstanceId?: string;
|
|
811
809
|
/** When omitted, inferred from static keys — see {@link effectiveDataAuth}. */
|
|
812
810
|
dataAuth?: BrowserDataAuthMode;
|
|
813
|
-
/** Public anon or data-admin key from the dashboard (Browser
|
|
811
|
+
/** Public anon or data-admin key from the dashboard (Browser Data API keys). */
|
|
814
812
|
dataStaticKey?: string;
|
|
815
813
|
getDataStaticKey?: () => string | null | Promise<string | null>;
|
|
816
814
|
getAccessToken?: () => string | null | Promise<string | null>;
|
|
@@ -940,40 +938,57 @@ interface BrowserCollectionDefinition {
|
|
|
940
938
|
createdAt: string;
|
|
941
939
|
updatedAt: string;
|
|
942
940
|
}
|
|
943
|
-
|
|
944
|
-
|
|
941
|
+
type CollectionWhere<Row extends Record<string, unknown>> = Partial<Row> & Record<string, unknown>;
|
|
942
|
+
type CollectionFilter<Row extends Record<string, unknown>> = {
|
|
943
|
+
[Field in Extract<keyof Row, string>]: {
|
|
944
|
+
field: Field;
|
|
945
|
+
op?: "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "contains";
|
|
946
|
+
value: Row[Field];
|
|
947
|
+
};
|
|
948
|
+
}[Extract<keyof Row, string>];
|
|
949
|
+
type BrowserCollectionFindParams<Row extends Record<string, unknown> = Record<string, unknown>> = {
|
|
950
|
+
where?: CollectionWhere<Row>;
|
|
945
951
|
filters?: Array<{
|
|
946
|
-
field: string;
|
|
952
|
+
field: Extract<keyof Row, string> | (string & {});
|
|
947
953
|
op?: "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "contains";
|
|
948
954
|
value: unknown;
|
|
949
|
-
}
|
|
955
|
+
} | CollectionFilter<Row>>;
|
|
950
956
|
limit?: number;
|
|
951
957
|
offset?: number;
|
|
952
|
-
orderBy?: string;
|
|
958
|
+
orderBy?: Extract<keyof Row, string> | (string & {});
|
|
953
959
|
orderDirection?: "asc" | "desc";
|
|
954
|
-
}
|
|
955
|
-
declare class BrowserCollectionApi<Row extends Record<string, unknown> = Record<string, unknown>> {
|
|
960
|
+
};
|
|
961
|
+
declare class BrowserCollectionApi<Row extends Record<string, unknown> = Record<string, unknown>, Insert extends Record<string, unknown> = Row, Update extends Record<string, unknown> = Partial<Row>> {
|
|
956
962
|
private readonly database;
|
|
957
963
|
private readonly name;
|
|
958
964
|
private readonly databaseInstanceId?;
|
|
959
965
|
constructor(database: RagableBrowserDatabaseClient<any>, name: string, databaseInstanceId?: string | undefined);
|
|
960
|
-
find: (whereOrParams?:
|
|
961
|
-
insert: (data:
|
|
962
|
-
update: (where:
|
|
966
|
+
find: (whereOrParams?: CollectionWhere<Row> | BrowserCollectionFindParams<Row>) => Promise<PostgrestResult<BrowserCollectionRecord<Row>[]>>;
|
|
967
|
+
insert: (data: Insert) => Promise<PostgrestResult<BrowserCollectionRecord<Row>>>;
|
|
968
|
+
update: (where: CollectionWhere<Row>, patch: Update, options?: {
|
|
963
969
|
limit?: number;
|
|
964
970
|
}) => Promise<PostgrestResult<BrowserCollectionRecord<Row>[]>>;
|
|
965
|
-
delete: (where:
|
|
971
|
+
delete: (where: CollectionWhere<Row>, options?: {
|
|
966
972
|
limit?: number;
|
|
967
973
|
}) => Promise<PostgrestResult<{
|
|
968
974
|
deleted: number;
|
|
969
975
|
records: BrowserCollectionRecord<Row>[];
|
|
970
976
|
}>>;
|
|
971
977
|
}
|
|
978
|
+
type BrowserCollections<Database extends RagableDatabase = DefaultRagableDatabase> = [keyof Database["public"]["Tables"]] extends [never] ? Record<string, BrowserCollectionApi<Record<string, unknown>>> : {
|
|
979
|
+
readonly [Name in RagableTableNames<Database>]: BrowserCollectionApi<TableRow<Database, Name>, TableInsertRow<Database, Name>, TableUpdatePatch<Database, Name>>;
|
|
980
|
+
};
|
|
981
|
+
type BrowserCollectionFactory<Database extends RagableDatabase = DefaultRagableDatabase> = {
|
|
982
|
+
<Name extends RagableTableNames<Database>>(name: Name, databaseInstanceId?: string): BrowserCollectionApi<TableRow<Database, Name>, TableInsertRow<Database, Name>, TableUpdatePatch<Database, Name>>;
|
|
983
|
+
<Row extends Record<string, unknown>>(name: string, databaseInstanceId?: string): BrowserCollectionApi<Row>;
|
|
984
|
+
};
|
|
972
985
|
declare class RagableBrowserDatabaseClient<Database extends RagableDatabase = DefaultRagableDatabase> {
|
|
973
986
|
private readonly options;
|
|
974
987
|
private readonly ragableAuth;
|
|
975
988
|
private readonly fetchImpl;
|
|
976
989
|
private _transport;
|
|
990
|
+
readonly collections: BrowserCollections<Database>;
|
|
991
|
+
readonly collection: BrowserCollectionFactory<Database>;
|
|
977
992
|
constructor(options: RagableBrowserClientOptions, ragableAuth?: RagableAuth | null);
|
|
978
993
|
/** @internal Called by RagableBrowser to share the Transport instance. */
|
|
979
994
|
_setTransport(transport: Transport): void;
|
|
@@ -983,7 +998,6 @@ declare class RagableBrowserDatabaseClient<Database extends RagableDatabase = De
|
|
|
983
998
|
*/
|
|
984
999
|
from: <TableName extends RagableTableNames<Database>>(table: TableName, databaseInstanceId?: string) => PostgrestTableApi<Database, TableName>;
|
|
985
1000
|
private toUrl;
|
|
986
|
-
collection: <Row extends Record<string, unknown> = Record<string, unknown>>(name: string, databaseInstanceId?: string) => BrowserCollectionApi<Row>;
|
|
987
1001
|
defineCollection: (name: string, schema?: Record<string, unknown>, databaseInstanceId?: string) => Promise<PostgrestResult<BrowserCollectionDefinition>>;
|
|
988
1002
|
listCollections: (databaseInstanceId?: string) => Promise<PostgrestResult<BrowserCollectionDefinition[]>>;
|
|
989
1003
|
_requestCollection<T>(method: "GET" | "POST" | "PATCH" | "DELETE", path: string, body?: unknown, databaseInstanceId?: string): Promise<T>;
|
|
@@ -1175,4 +1189,4 @@ declare function createClient(options: RagableClientOptions): Ragable;
|
|
|
1175
1189
|
declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
|
|
1176
1190
|
declare function createRagableServerClient(options: RagableClientOptions): Ragable;
|
|
1177
1191
|
|
|
1178
|
-
export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentPublicChatParams, type AgentStreamEvent, type AgentSummary, AgentsClient, AuthBroadcastChannel, type AuthBroadcastMessage, type AuthChangeEvent, type AuthOptions, type AuthSession, type BrowserAuthSession, type BrowserAuthTokens, type BrowserDataAuthMode, type BrowserRealtimeNotification, type BrowserRealtimeStatus, type BrowserRealtimeSubscribeParams, type BrowserRealtimeSubscription, type BrowserSqlExecParams, type BrowserSqlExecResult, type BrowserSqlQueryParams, type BrowserSqlQueryResult, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultRagableDatabase, type FormatContextOptions, type HttpMethod, type Json, LocalStorageAdapter, MemoryStorageAdapter, type PostgRESTFetch, type PostgRESTFetchParams, PostgrestDeleteReturningBuilder, PostgrestDeleteRootBuilder, PostgrestInsertReturningBuilder, PostgrestInsertRootBuilder, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateReturningBuilder, PostgrestUpdateRootBuilder, type PostgrestUpsertOptions, PostgrestUpsertReturningBuilder, PostgrestUpsertRootBuilder, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableAbortError, RagableAuth, type RagableAuthConfig, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableNetworkError, RagableRequestClient, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetrieveParams, type RetryOptions, type RunQuery, type SessionStorage, SessionStorageAdapter, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, type SseJsonEvent, type SupabaseCompatSession, type TableInsertRow, type TableRow, type TableUpdatePatch, type Tables, type TablesInsert, type TablesUpdate, Transport, type TransportOptions, type TransportRequest, asPostgrestResponse, bindFetch, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, detectStorage, effectiveDataAuth, extractErrorMessage, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, normalizeBrowserApiBase, parseSseDataLine, parseTransportResponse, readSseStream };
|
|
1192
|
+
export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentPublicChatParams, type AgentStreamEvent, type AgentSummary, AgentsClient, AuthBroadcastChannel, type AuthBroadcastMessage, type AuthChangeEvent, type AuthOptions, type AuthSession, type BrowserAuthSession, type BrowserAuthTokens, BrowserCollectionApi, type BrowserCollectionDefinition, type BrowserCollectionFactory, type BrowserCollectionFindParams, type BrowserCollectionRecord, type BrowserCollections, type BrowserDataAuthMode, type BrowserRealtimeNotification, type BrowserRealtimeStatus, type BrowserRealtimeSubscribeParams, type BrowserRealtimeSubscription, type BrowserSqlExecParams, type BrowserSqlExecResult, type BrowserSqlQueryParams, type BrowserSqlQueryResult, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultRagableDatabase, type FormatContextOptions, type HttpMethod, type Json, LocalStorageAdapter, MemoryStorageAdapter, type PostgRESTFetch, type PostgRESTFetchParams, PostgrestDeleteReturningBuilder, PostgrestDeleteRootBuilder, PostgrestInsertReturningBuilder, PostgrestInsertRootBuilder, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateReturningBuilder, PostgrestUpdateRootBuilder, type PostgrestUpsertOptions, PostgrestUpsertReturningBuilder, PostgrestUpsertRootBuilder, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableAbortError, RagableAuth, type RagableAuthConfig, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableNetworkError, RagableRequestClient, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetrieveParams, type RetryOptions, type RunQuery, type SessionStorage, SessionStorageAdapter, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, type SseJsonEvent, type SupabaseCompatSession, type TableInsertRow, type TableRow, type TableUpdatePatch, type Tables, type TablesInsert, type TablesUpdate, Transport, type TransportOptions, type TransportRequest, asPostgrestResponse, bindFetch, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, detectStorage, effectiveDataAuth, extractErrorMessage, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, normalizeBrowserApiBase, parseSseDataLine, parseTransportResponse, readSseStream };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,11 +22,9 @@ type RagableTableDefinition<Row extends Record<string, unknown> = Record<string,
|
|
|
22
22
|
*/
|
|
23
23
|
interface RagableDatabase {
|
|
24
24
|
public: {
|
|
25
|
-
Tables:
|
|
26
|
-
Views?:
|
|
27
|
-
|
|
28
|
-
}>;
|
|
29
|
-
Enums?: Record<string, string>;
|
|
25
|
+
Tables: object;
|
|
26
|
+
Views?: object;
|
|
27
|
+
Enums?: object;
|
|
30
28
|
};
|
|
31
29
|
}
|
|
32
30
|
/**
|
|
@@ -798,10 +796,10 @@ declare function normalizeBrowserApiBase(): string;
|
|
|
798
796
|
type BrowserDataAuthMode = "user" | "publicAnon" | "admin";
|
|
799
797
|
/**
|
|
800
798
|
* Resolves how database requests are authorized. If `dataAuth` is omitted and a
|
|
801
|
-
* static browser
|
|
802
|
-
* defaults to **`publicAnon`** so
|
|
803
|
-
* Use explicit **`dataAuth: "user"`** when you need JWT sessions; use
|
|
804
|
-
* when the static key is a data-admin key
|
|
799
|
+
* static browser data key is configured (`dataStaticKey` / `getDataStaticKey`),
|
|
800
|
+
* defaults to **`publicAnon`** so public apps can use shared collections without
|
|
801
|
+
* sign-in. Use explicit **`dataAuth: "user"`** when you need JWT sessions; use
|
|
802
|
+
* **`"admin"`** when the static key is a data-admin key.
|
|
805
803
|
*/
|
|
806
804
|
declare function effectiveDataAuth(options: RagableBrowserClientOptions): BrowserDataAuthMode;
|
|
807
805
|
interface RagableBrowserClientOptions {
|
|
@@ -810,7 +808,7 @@ interface RagableBrowserClientOptions {
|
|
|
810
808
|
databaseInstanceId?: string;
|
|
811
809
|
/** When omitted, inferred from static keys — see {@link effectiveDataAuth}. */
|
|
812
810
|
dataAuth?: BrowserDataAuthMode;
|
|
813
|
-
/** Public anon or data-admin key from the dashboard (Browser
|
|
811
|
+
/** Public anon or data-admin key from the dashboard (Browser Data API keys). */
|
|
814
812
|
dataStaticKey?: string;
|
|
815
813
|
getDataStaticKey?: () => string | null | Promise<string | null>;
|
|
816
814
|
getAccessToken?: () => string | null | Promise<string | null>;
|
|
@@ -940,40 +938,57 @@ interface BrowserCollectionDefinition {
|
|
|
940
938
|
createdAt: string;
|
|
941
939
|
updatedAt: string;
|
|
942
940
|
}
|
|
943
|
-
|
|
944
|
-
|
|
941
|
+
type CollectionWhere<Row extends Record<string, unknown>> = Partial<Row> & Record<string, unknown>;
|
|
942
|
+
type CollectionFilter<Row extends Record<string, unknown>> = {
|
|
943
|
+
[Field in Extract<keyof Row, string>]: {
|
|
944
|
+
field: Field;
|
|
945
|
+
op?: "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "contains";
|
|
946
|
+
value: Row[Field];
|
|
947
|
+
};
|
|
948
|
+
}[Extract<keyof Row, string>];
|
|
949
|
+
type BrowserCollectionFindParams<Row extends Record<string, unknown> = Record<string, unknown>> = {
|
|
950
|
+
where?: CollectionWhere<Row>;
|
|
945
951
|
filters?: Array<{
|
|
946
|
-
field: string;
|
|
952
|
+
field: Extract<keyof Row, string> | (string & {});
|
|
947
953
|
op?: "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "contains";
|
|
948
954
|
value: unknown;
|
|
949
|
-
}
|
|
955
|
+
} | CollectionFilter<Row>>;
|
|
950
956
|
limit?: number;
|
|
951
957
|
offset?: number;
|
|
952
|
-
orderBy?: string;
|
|
958
|
+
orderBy?: Extract<keyof Row, string> | (string & {});
|
|
953
959
|
orderDirection?: "asc" | "desc";
|
|
954
|
-
}
|
|
955
|
-
declare class BrowserCollectionApi<Row extends Record<string, unknown> = Record<string, unknown>> {
|
|
960
|
+
};
|
|
961
|
+
declare class BrowserCollectionApi<Row extends Record<string, unknown> = Record<string, unknown>, Insert extends Record<string, unknown> = Row, Update extends Record<string, unknown> = Partial<Row>> {
|
|
956
962
|
private readonly database;
|
|
957
963
|
private readonly name;
|
|
958
964
|
private readonly databaseInstanceId?;
|
|
959
965
|
constructor(database: RagableBrowserDatabaseClient<any>, name: string, databaseInstanceId?: string | undefined);
|
|
960
|
-
find: (whereOrParams?:
|
|
961
|
-
insert: (data:
|
|
962
|
-
update: (where:
|
|
966
|
+
find: (whereOrParams?: CollectionWhere<Row> | BrowserCollectionFindParams<Row>) => Promise<PostgrestResult<BrowserCollectionRecord<Row>[]>>;
|
|
967
|
+
insert: (data: Insert) => Promise<PostgrestResult<BrowserCollectionRecord<Row>>>;
|
|
968
|
+
update: (where: CollectionWhere<Row>, patch: Update, options?: {
|
|
963
969
|
limit?: number;
|
|
964
970
|
}) => Promise<PostgrestResult<BrowserCollectionRecord<Row>[]>>;
|
|
965
|
-
delete: (where:
|
|
971
|
+
delete: (where: CollectionWhere<Row>, options?: {
|
|
966
972
|
limit?: number;
|
|
967
973
|
}) => Promise<PostgrestResult<{
|
|
968
974
|
deleted: number;
|
|
969
975
|
records: BrowserCollectionRecord<Row>[];
|
|
970
976
|
}>>;
|
|
971
977
|
}
|
|
978
|
+
type BrowserCollections<Database extends RagableDatabase = DefaultRagableDatabase> = [keyof Database["public"]["Tables"]] extends [never] ? Record<string, BrowserCollectionApi<Record<string, unknown>>> : {
|
|
979
|
+
readonly [Name in RagableTableNames<Database>]: BrowserCollectionApi<TableRow<Database, Name>, TableInsertRow<Database, Name>, TableUpdatePatch<Database, Name>>;
|
|
980
|
+
};
|
|
981
|
+
type BrowserCollectionFactory<Database extends RagableDatabase = DefaultRagableDatabase> = {
|
|
982
|
+
<Name extends RagableTableNames<Database>>(name: Name, databaseInstanceId?: string): BrowserCollectionApi<TableRow<Database, Name>, TableInsertRow<Database, Name>, TableUpdatePatch<Database, Name>>;
|
|
983
|
+
<Row extends Record<string, unknown>>(name: string, databaseInstanceId?: string): BrowserCollectionApi<Row>;
|
|
984
|
+
};
|
|
972
985
|
declare class RagableBrowserDatabaseClient<Database extends RagableDatabase = DefaultRagableDatabase> {
|
|
973
986
|
private readonly options;
|
|
974
987
|
private readonly ragableAuth;
|
|
975
988
|
private readonly fetchImpl;
|
|
976
989
|
private _transport;
|
|
990
|
+
readonly collections: BrowserCollections<Database>;
|
|
991
|
+
readonly collection: BrowserCollectionFactory<Database>;
|
|
977
992
|
constructor(options: RagableBrowserClientOptions, ragableAuth?: RagableAuth | null);
|
|
978
993
|
/** @internal Called by RagableBrowser to share the Transport instance. */
|
|
979
994
|
_setTransport(transport: Transport): void;
|
|
@@ -983,7 +998,6 @@ declare class RagableBrowserDatabaseClient<Database extends RagableDatabase = De
|
|
|
983
998
|
*/
|
|
984
999
|
from: <TableName extends RagableTableNames<Database>>(table: TableName, databaseInstanceId?: string) => PostgrestTableApi<Database, TableName>;
|
|
985
1000
|
private toUrl;
|
|
986
|
-
collection: <Row extends Record<string, unknown> = Record<string, unknown>>(name: string, databaseInstanceId?: string) => BrowserCollectionApi<Row>;
|
|
987
1001
|
defineCollection: (name: string, schema?: Record<string, unknown>, databaseInstanceId?: string) => Promise<PostgrestResult<BrowserCollectionDefinition>>;
|
|
988
1002
|
listCollections: (databaseInstanceId?: string) => Promise<PostgrestResult<BrowserCollectionDefinition[]>>;
|
|
989
1003
|
_requestCollection<T>(method: "GET" | "POST" | "PATCH" | "DELETE", path: string, body?: unknown, databaseInstanceId?: string): Promise<T>;
|
|
@@ -1175,4 +1189,4 @@ declare function createClient(options: RagableClientOptions): Ragable;
|
|
|
1175
1189
|
declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends Record<string, unknown> = Record<string, unknown>>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
|
|
1176
1190
|
declare function createRagableServerClient(options: RagableClientOptions): Ragable;
|
|
1177
1191
|
|
|
1178
|
-
export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentPublicChatParams, type AgentStreamEvent, type AgentSummary, AgentsClient, AuthBroadcastChannel, type AuthBroadcastMessage, type AuthChangeEvent, type AuthOptions, type AuthSession, type BrowserAuthSession, type BrowserAuthTokens, type BrowserDataAuthMode, type BrowserRealtimeNotification, type BrowserRealtimeStatus, type BrowserRealtimeSubscribeParams, type BrowserRealtimeSubscription, type BrowserSqlExecParams, type BrowserSqlExecResult, type BrowserSqlQueryParams, type BrowserSqlQueryResult, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultRagableDatabase, type FormatContextOptions, type HttpMethod, type Json, LocalStorageAdapter, MemoryStorageAdapter, type PostgRESTFetch, type PostgRESTFetchParams, PostgrestDeleteReturningBuilder, PostgrestDeleteRootBuilder, PostgrestInsertReturningBuilder, PostgrestInsertRootBuilder, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateReturningBuilder, PostgrestUpdateRootBuilder, type PostgrestUpsertOptions, PostgrestUpsertReturningBuilder, PostgrestUpsertRootBuilder, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableAbortError, RagableAuth, type RagableAuthConfig, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableNetworkError, RagableRequestClient, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetrieveParams, type RetryOptions, type RunQuery, type SessionStorage, SessionStorageAdapter, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, type SseJsonEvent, type SupabaseCompatSession, type TableInsertRow, type TableRow, type TableUpdatePatch, type Tables, type TablesInsert, type TablesUpdate, Transport, type TransportOptions, type TransportRequest, asPostgrestResponse, bindFetch, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, detectStorage, effectiveDataAuth, extractErrorMessage, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, normalizeBrowserApiBase, parseSseDataLine, parseTransportResponse, readSseStream };
|
|
1192
|
+
export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, type AgentPublicChatParams, type AgentStreamEvent, type AgentSummary, AgentsClient, AuthBroadcastChannel, type AuthBroadcastMessage, type AuthChangeEvent, type AuthOptions, type AuthSession, type BrowserAuthSession, type BrowserAuthTokens, BrowserCollectionApi, type BrowserCollectionDefinition, type BrowserCollectionFactory, type BrowserCollectionFindParams, type BrowserCollectionRecord, type BrowserCollections, type BrowserDataAuthMode, type BrowserRealtimeNotification, type BrowserRealtimeStatus, type BrowserRealtimeSubscribeParams, type BrowserRealtimeSubscription, type BrowserSqlExecParams, type BrowserSqlExecResult, type BrowserSqlQueryParams, type BrowserSqlQueryResult, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultRagableDatabase, type FormatContextOptions, type HttpMethod, type Json, LocalStorageAdapter, MemoryStorageAdapter, type PostgRESTFetch, type PostgRESTFetchParams, PostgrestDeleteReturningBuilder, PostgrestDeleteRootBuilder, PostgrestInsertReturningBuilder, PostgrestInsertRootBuilder, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateReturningBuilder, PostgrestUpdateRootBuilder, type PostgrestUpsertOptions, PostgrestUpsertReturningBuilder, PostgrestUpsertRootBuilder, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableAbortError, RagableAuth, type RagableAuthConfig, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableNetworkError, RagableRequestClient, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetrieveParams, type RetryOptions, type RunQuery, type SessionStorage, SessionStorageAdapter, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, type SseJsonEvent, type SupabaseCompatSession, type TableInsertRow, type TableRow, type TableUpdatePatch, type Tables, type TablesInsert, type TablesUpdate, Transport, type TransportOptions, type TransportRequest, asPostgrestResponse, bindFetch, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, detectStorage, effectiveDataAuth, extractErrorMessage, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, normalizeBrowserApiBase, parseSseDataLine, parseTransportResponse, readSseStream };
|
package/dist/index.js
CHANGED
|
@@ -2321,6 +2321,8 @@ var RagableBrowserDatabaseClient = class {
|
|
|
2321
2321
|
this.ragableAuth = ragableAuth;
|
|
2322
2322
|
__publicField(this, "fetchImpl");
|
|
2323
2323
|
__publicField(this, "_transport", null);
|
|
2324
|
+
__publicField(this, "collections");
|
|
2325
|
+
__publicField(this, "collection");
|
|
2324
2326
|
/**
|
|
2325
2327
|
* PostgREST table access. Instance field so `client.database.from` is always an own,
|
|
2326
2328
|
* enumerable function (avoids rare prototype/bundler issues).
|
|
@@ -2374,9 +2376,6 @@ var RagableBrowserDatabaseClient = class {
|
|
|
2374
2376
|
};
|
|
2375
2377
|
return new PostgrestTableApi(pgFetch, id, table);
|
|
2376
2378
|
});
|
|
2377
|
-
__publicField(this, "collection", (name, databaseInstanceId) => {
|
|
2378
|
-
return new BrowserCollectionApi(this, name, databaseInstanceId);
|
|
2379
|
-
});
|
|
2380
2379
|
__publicField(this, "defineCollection", (name, schema, databaseInstanceId) => asPostgrestResponse(
|
|
2381
2380
|
() => this._requestCollection(
|
|
2382
2381
|
"POST",
|
|
@@ -2459,6 +2458,21 @@ var RagableBrowserDatabaseClient = class {
|
|
|
2459
2458
|
)
|
|
2460
2459
|
});
|
|
2461
2460
|
this.fetchImpl = bindFetch(options.fetch);
|
|
2461
|
+
this.collections = new Proxy(
|
|
2462
|
+
{},
|
|
2463
|
+
{
|
|
2464
|
+
get: (_target, prop) => {
|
|
2465
|
+
if (typeof prop !== "string") return void 0;
|
|
2466
|
+
if (prop === "then") return void 0;
|
|
2467
|
+
return this.collection(prop);
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
);
|
|
2471
|
+
this.collection = ((name, databaseInstanceId) => new BrowserCollectionApi(
|
|
2472
|
+
this,
|
|
2473
|
+
name,
|
|
2474
|
+
databaseInstanceId
|
|
2475
|
+
));
|
|
2462
2476
|
}
|
|
2463
2477
|
/** @internal Called by RagableBrowser to share the Transport instance. */
|
|
2464
2478
|
_setTransport(transport) {
|
|
@@ -2473,7 +2487,7 @@ var RagableBrowserDatabaseClient = class {
|
|
|
2473
2487
|
const id = databaseInstanceId?.trim() || this.options.databaseInstanceId?.trim();
|
|
2474
2488
|
if (!id) {
|
|
2475
2489
|
throw new RagableError(
|
|
2476
|
-
"db.
|
|
2490
|
+
"db.collections requires databaseInstanceId in client options. For dynamic collection() calls, you can also pass databaseInstanceId as the second argument.",
|
|
2477
2491
|
400,
|
|
2478
2492
|
{ code: "SDK_MISSING_DATABASE_INSTANCE_ID" }
|
|
2479
2493
|
);
|
|
@@ -2843,7 +2857,7 @@ function createClient(options) {
|
|
|
2843
2857
|
if (isServerClientOptions(options)) {
|
|
2844
2858
|
if (typeof options === "object" && options !== null && "organizationId" in options && typeof options.organizationId === "string") {
|
|
2845
2859
|
console.warn(
|
|
2846
|
-
"[@ragable/sdk] createClient: `apiKey` is set, so the server client is returned. It has no `database` or `auth` \u2014 only `agents` and `shift`. For `db.
|
|
2860
|
+
"[@ragable/sdk] createClient: `apiKey` is set, so the server client is returned. It has no `database` or `auth` \u2014 only `agents` and `shift`. For `db.collections.<name>` / `database.from()` / `auth.*`, use the browser client without `apiKey` (e.g. createClient({ organizationId, authGroupId, databaseInstanceId, ... }))."
|
|
2847
2861
|
);
|
|
2848
2862
|
}
|
|
2849
2863
|
return new Ragable(options);
|