@insforge/sdk 1.4.2 → 1.4.3

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/ssr.mjs CHANGED
@@ -1002,10 +1002,16 @@ var Auth = class {
1002
1002
  async signOut() {
1003
1003
  try {
1004
1004
  try {
1005
+ const serverMode = this.isServerMode();
1006
+ const csrfToken = !serverMode ? getCsrfToken() : null;
1005
1007
  await this.http.post(
1006
- this.isServerMode() ? "/api/auth/logout?client_type=mobile" : "/api/auth/logout",
1008
+ serverMode ? "/api/auth/logout?client_type=mobile" : "/api/auth/logout",
1007
1009
  void 0,
1008
- { credentials: "include", skipAuthRefresh: true }
1010
+ {
1011
+ credentials: "include",
1012
+ skipAuthRefresh: true,
1013
+ ...csrfToken ? { headers: { "X-CSRF-Token": csrfToken } } : {}
1014
+ }
1009
1015
  );
1010
1016
  } catch {
1011
1017
  }
@@ -1411,12 +1417,30 @@ function createInsForgePostgrestFetch(httpClient) {
1411
1417
  };
1412
1418
  }
1413
1419
  var Database = class {
1414
- constructor(httpClient) {
1420
+ constructor(httpClient, defaultSchema) {
1415
1421
  this.postgrest = new PostgrestClient("http://dummy", {
1416
1422
  fetch: createInsForgePostgrestFetch(httpClient),
1417
- headers: {}
1423
+ headers: {},
1424
+ ...defaultSchema ? { schema: defaultSchema } : {}
1418
1425
  });
1419
1426
  }
1427
+ /**
1428
+ * Select a non-default Postgres schema for the chained query. Maps to
1429
+ * PostgREST's `Accept-Profile` (reads) / `Content-Profile` (writes) header.
1430
+ * The schema must be exposed by the backend.
1431
+ *
1432
+ * @example
1433
+ * const { data } = await client.database
1434
+ * .schema('analytics')
1435
+ * .from('events')
1436
+ * .select('*');
1437
+ *
1438
+ * @example
1439
+ * await client.database.schema('analytics').rpc('rollup', { day: '2026-01-01' });
1440
+ */
1441
+ schema(schemaName) {
1442
+ return this.postgrest.schema(schemaName);
1443
+ }
1420
1444
  /**
1421
1445
  * Create a query builder for a table
1422
1446
  *
@@ -2776,7 +2800,7 @@ var InsForgeClient = class {
2776
2800
  isServerMode: config.isServerMode ?? !!accessToken,
2777
2801
  detectOAuthCallback: config.auth?.detectOAuthCallback
2778
2802
  });
2779
- this.database = new Database(this.http);
2803
+ this.database = new Database(this.http, config.db?.schema);
2780
2804
  this.storage = new Storage(this.http);
2781
2805
  this.ai = new AI(this.http);
2782
2806
  this.functions = new Functions(this.http, config.functionsUrl);