@ragable/sdk 0.6.1 → 0.6.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.
package/dist/index.d.mts CHANGED
@@ -863,11 +863,17 @@ interface BrowserSqlQueryResult<Row extends Record<string, unknown> = Record<str
863
863
  truncated: boolean;
864
864
  rows: Row[];
865
865
  }
866
- declare class RagableBrowserDatabaseClient<_Schema extends RagableDatabase = DefaultRagableDatabase> {
866
+ declare class RagableBrowserDatabaseClient<Database extends RagableDatabase = DefaultRagableDatabase> {
867
867
  private readonly options;
868
868
  private readonly ragableAuth;
869
+ private readonly postgrestFrom?;
869
870
  private readonly fetchImpl;
870
- constructor(options: RagableBrowserClientOptions, ragableAuth?: RagableAuth | null);
871
+ constructor(options: RagableBrowserClientOptions, ragableAuth?: RagableAuth | null, postgrestFrom?: (<T extends RagableTableNames<Database>>(table: T, databaseInstanceId?: string) => PostgrestTableApi<Database, T>) | undefined);
872
+ /**
873
+ * PostgREST fluent API — same as `client.from('table')`.
874
+ * Use either the root client or `database` for Supabase-style table access; `database.query()` is raw SQL only.
875
+ */
876
+ from<TableName extends RagableTableNames<Database>>(table: TableName, databaseInstanceId?: string): PostgrestTableApi<Database, TableName>;
871
877
  private toUrl;
872
878
  query<Row extends Record<string, unknown> = Record<string, unknown>>(params: BrowserSqlQueryParams): Promise<BrowserSqlQueryResult<Row>>;
873
879
  private baseHeaders;
package/dist/index.d.ts CHANGED
@@ -863,11 +863,17 @@ interface BrowserSqlQueryResult<Row extends Record<string, unknown> = Record<str
863
863
  truncated: boolean;
864
864
  rows: Row[];
865
865
  }
866
- declare class RagableBrowserDatabaseClient<_Schema extends RagableDatabase = DefaultRagableDatabase> {
866
+ declare class RagableBrowserDatabaseClient<Database extends RagableDatabase = DefaultRagableDatabase> {
867
867
  private readonly options;
868
868
  private readonly ragableAuth;
869
+ private readonly postgrestFrom?;
869
870
  private readonly fetchImpl;
870
- constructor(options: RagableBrowserClientOptions, ragableAuth?: RagableAuth | null);
871
+ constructor(options: RagableBrowserClientOptions, ragableAuth?: RagableAuth | null, postgrestFrom?: (<T extends RagableTableNames<Database>>(table: T, databaseInstanceId?: string) => PostgrestTableApi<Database, T>) | undefined);
872
+ /**
873
+ * PostgREST fluent API — same as `client.from('table')`.
874
+ * Use either the root client or `database` for Supabase-style table access; `database.query()` is raw SQL only.
875
+ */
876
+ from<TableName extends RagableTableNames<Database>>(table: TableName, databaseInstanceId?: string): PostgrestTableApi<Database, TableName>;
871
877
  private toUrl;
872
878
  query<Row extends Record<string, unknown> = Record<string, unknown>>(params: BrowserSqlQueryParams): Promise<BrowserSqlQueryResult<Row>>;
873
879
  private baseHeaders;
package/dist/index.js CHANGED
@@ -2163,12 +2163,27 @@ var RagableBrowserAuthClient = class {
2163
2163
  }
2164
2164
  };
2165
2165
  var RagableBrowserDatabaseClient = class {
2166
- constructor(options, ragableAuth = null) {
2166
+ constructor(options, ragableAuth = null, postgrestFrom) {
2167
2167
  this.options = options;
2168
2168
  this.ragableAuth = ragableAuth;
2169
+ this.postgrestFrom = postgrestFrom;
2169
2170
  __publicField(this, "fetchImpl");
2170
2171
  this.fetchImpl = bindFetch(options.fetch);
2171
2172
  }
2173
+ /**
2174
+ * PostgREST fluent API — same as `client.from('table')`.
2175
+ * Use either the root client or `database` for Supabase-style table access; `database.query()` is raw SQL only.
2176
+ */
2177
+ from(table, databaseInstanceId) {
2178
+ if (!this.postgrestFrom) {
2179
+ throw new RagableError(
2180
+ "database.from() is only available on the client from createBrowserClient().",
2181
+ 500,
2182
+ { code: "SDK_DATABASE_FROM_UNAVAILABLE" }
2183
+ );
2184
+ }
2185
+ return this.postgrestFrom(table, databaseInstanceId);
2186
+ }
2172
2187
  toUrl(path) {
2173
2188
  return `${normalizeBrowserApiBase(this.options.baseUrl)}${path.startsWith("/") ? path : `/${path}`}`;
2174
2189
  }
@@ -2282,7 +2297,11 @@ var RagableBrowser = class {
2282
2297
  }
2283
2298
  this.agents = new RagableBrowserAgentsClient(options);
2284
2299
  this.auth = new RagableBrowserAuthClient(options, this._ragableAuth);
2285
- this.database = new RagableBrowserDatabaseClient(options, this._ragableAuth);
2300
+ this.database = new RagableBrowserDatabaseClient(
2301
+ options,
2302
+ this._ragableAuth,
2303
+ (table, databaseInstanceId) => this.from(table, databaseInstanceId)
2304
+ );
2286
2305
  }
2287
2306
  from(table, databaseInstanceId) {
2288
2307
  const id = databaseInstanceId?.trim() || this.options.databaseInstanceId?.trim();