@supabase/supabase-js 2.118.0-canary.2 → 2.119.0-canary.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supabase/supabase-js",
3
- "version": "2.118.0-canary.2",
3
+ "version": "2.119.0-canary.0",
4
4
  "description": "Isomorphic Javascript SDK for Supabase",
5
5
  "keywords": [
6
6
  "javascript",
@@ -77,11 +77,11 @@
77
77
  "directory": "packages/core/supabase-js"
78
78
  },
79
79
  "dependencies": {
80
- "@supabase/auth-js": "2.118.0-canary.2",
81
- "@supabase/realtime-js": "2.118.0-canary.2",
82
- "@supabase/functions-js": "2.118.0-canary.2",
83
- "@supabase/postgrest-js": "2.118.0-canary.2",
84
- "@supabase/storage-js": "2.118.0-canary.2"
80
+ "@supabase/auth-js": "2.119.0-canary.0",
81
+ "@supabase/functions-js": "2.119.0-canary.0",
82
+ "@supabase/realtime-js": "2.119.0-canary.0",
83
+ "@supabase/storage-js": "2.119.0-canary.0",
84
+ "@supabase/postgrest-js": "2.119.0-canary.0"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "@opentelemetry/api": ">=1.0.0"
@@ -5,6 +5,7 @@ import {
5
5
  type PostgrestFilterBuilder,
6
6
  type PostgrestOpenApiSpec,
7
7
  type PostgrestQueryBuilder,
8
+ type PostgrestQueryBuilderOptions,
8
9
  type PostgrestSingleResponse,
9
10
  } from '@supabase/postgrest-js'
10
11
  import {
@@ -22,7 +23,7 @@ import {
22
23
  DEFAULT_REALTIME_OPTIONS,
23
24
  DEFAULT_TRACE_PROPAGATION_OPTIONS,
24
25
  } from './lib/constants'
25
- import { checkApiKeyFormat, fetchWithAuth } from './lib/fetch'
26
+ import { checkApiKeyFormat, fetchWithAuth, resolveFetch } from './lib/fetch'
26
27
  import {
27
28
  applySettingDefaults,
28
29
  checkTopLevelSchemaOption,
@@ -398,10 +399,20 @@ export default class SupabaseClient<
398
399
  .catch((e) => console.warn('Failed to set initial Realtime auth token:', e))
399
400
  }
400
401
 
402
+ // The PostgREST client applies the auth wrapper itself, so a per-request fetch
403
+ // passed to `from()` carries the same headers as the client-level fetch.
401
404
  this.rest = new PostgrestClient(new URL('rest/v1', baseUrl).href, {
402
405
  headers: this.headers,
403
406
  schema: settings.db.schema,
404
- fetch: this.fetch,
407
+ fetch: resolveFetch(settings.global.fetch),
408
+ wrapFetch: (fetch) =>
409
+ fetchWithAuth(
410
+ supabaseKey,
411
+ supabaseUrl,
412
+ this._getSessionToken.bind(this),
413
+ fetch,
414
+ settings.tracePropagation
415
+ ),
405
416
  timeout: settings.db.timeout,
406
417
  urlLengthLimit: settings.db.urlLengthLimit,
407
418
  retry: settings.db.retry,
@@ -433,17 +444,38 @@ export default class SupabaseClient<
433
444
  from<
434
445
  TableName extends string & keyof Schema['Tables'],
435
446
  Table extends Schema['Tables'][TableName],
436
- >(relation: TableName): PostgrestQueryBuilder<ClientOptions, Schema, Table, TableName>
447
+ >(
448
+ relation: TableName,
449
+ options?: PostgrestQueryBuilderOptions
450
+ ): PostgrestQueryBuilder<ClientOptions, Schema, Table, TableName>
437
451
  from<ViewName extends string & keyof Schema['Views'], View extends Schema['Views'][ViewName]>(
438
- relation: ViewName
452
+ relation: ViewName,
453
+ options?: PostgrestQueryBuilderOptions
439
454
  ): PostgrestQueryBuilder<ClientOptions, Schema, View, ViewName>
440
455
  /**
441
456
  * Perform a query on a table or a view.
442
457
  *
458
+ * A per-request `fetch` is wrapped the same way as the client-level fetch: the
459
+ * `apikey`, `Authorization` and trace headers are added before it is called.
460
+ * The same applies to clients returned by `.schema()`.
461
+ *
443
462
  * @param relation - The table or view name to query
463
+ * @param options - Per-request options that override client-level defaults
464
+ *
465
+ * @example Per-request fetch options
466
+ * ```ts
467
+ * const { data } = await supabase
468
+ * .from('countries', {
469
+ * fetch: (input, init) => fetch(input, { ...init, cache: 'force-cache' }),
470
+ * })
471
+ * .select('*')
472
+ * ```
444
473
  */
445
- from(relation: string): PostgrestQueryBuilder<ClientOptions, Schema, any> {
446
- return this.rest.from(relation)
474
+ from(
475
+ relation: string,
476
+ options?: PostgrestQueryBuilderOptions
477
+ ): PostgrestQueryBuilder<ClientOptions, Schema, any> {
478
+ return this.rest.from(relation, options)
447
479
  }
448
480
 
449
481
  // NOTE: signatures must be kept in sync with PostgrestClient.schema
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ export type {
8
8
  PostgrestSingleResponse,
9
9
  PostgrestMaybeSingleResponse,
10
10
  PostgrestOpenApiSpec,
11
+ PostgrestQueryBuilderOptions,
11
12
  PostgrestBuilder,
12
13
  PostgrestFilterBuilder,
13
14
  PostgrestTransformBuilder,
@@ -4,4 +4,4 @@
4
4
  // - Debugging and support (identifying which version is running)
5
5
  // - Telemetry and logging (version reporting in errors/analytics)
6
6
  // - Ensuring build artifacts match the published package version
7
- export const version = '2.118.0-canary.2'
7
+ export const version = '2.119.0-canary.0'