Skip to content

feat: bump storage version, and expose StorageClientOptions #1500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/SupabaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
*/
auth: SupabaseAuthClient
realtime: RealtimeClient
/**
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
*/
storage: SupabaseStorageClient

protected realtimeUrl: URL
protected authUrl: URL
Expand All @@ -64,6 +68,7 @@
* @param options.auth.persistSession Set to "true" if you want to automatically save the user session into local storage.
* @param options.auth.detectSessionInUrl Set to "true" if you want to automatically detects OAuth grants in the URL and signs in the user.
* @param options.realtime Options passed along to realtime-js constructor.
* @param options.storage Options passed along to the storage-js constructor.
* @param options.global.fetch A custom fetch implementation.
* @param options.global.headers Any additional headers to send with each network request.
*/
Expand Down Expand Up @@ -130,6 +135,13 @@
fetch: this.fetch,
})

this.storage = new SupabaseStorageClient(
this.storageUrl.href,
this.headers,
this.fetch,
options?.storage

Check failure on line 142 in src/SupabaseClient.ts

View workflow job for this annotation

GitHub Actions / Unit + Type Check / Node.js 20 / OS windows-latest

Expected 1-3 arguments, but got 4.

Check failure on line 142 in src/SupabaseClient.ts

View workflow job for this annotation

GitHub Actions / Build supabase-js package

Expected 1-3 arguments, but got 4.

Check failure on line 142 in src/SupabaseClient.ts

View workflow job for this annotation

GitHub Actions / Unit + Type Check / Node.js 20 / OS macos-latest

Expected 1-3 arguments, but got 4.

Check failure on line 142 in src/SupabaseClient.ts

View workflow job for this annotation

GitHub Actions / Unit + Type Check / Node.js 20 / OS ubuntu-latest

Expected 1-3 arguments, but got 4.
)

if (!settings.accessToken) {
this._listenForAuthEvents()
}
Expand All @@ -145,13 +157,6 @@
})
}

/**
* Supabase Storage allows you to manage user-generated content, such as photos or videos.
*/
get storage(): SupabaseStorageClient {
return new SupabaseStorageClient(this.storageUrl.href, this.headers, this.fetch)
}

// NOTE: signatures must be kept in sync with PostgrestClient.from
from<
TableName extends string & keyof Schema['Tables'],
Expand Down
1 change: 1 addition & 0 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function applySettingDefaults<
...DEFAULT_REALTIME_OPTIONS,
...realtimeOptions,
},
storage: {},
global: {
...DEFAULT_GLOBAL_OPTIONS,
...globalOptions,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AuthClient } from '@supabase/auth-js'
import { RealtimeClientOptions } from '@supabase/realtime-js'
import { PostgrestError } from '@supabase/postgrest-js'
import { StorageClientOptions } from '@supabase/storage-js/dist/module/StorageClient'

Check failure on line 4 in src/lib/types.ts

View workflow job for this annotation

GitHub Actions / Unit + Type Check / Node.js 20 / OS windows-latest

Module '"@supabase/storage-js/dist/module/StorageClient"' has no exported member 'StorageClientOptions'.

Check failure on line 4 in src/lib/types.ts

View workflow job for this annotation

GitHub Actions / Build supabase-js package

Module '"@supabase/storage-js/dist/module/StorageClient"' has no exported member 'StorageClientOptions'.

Check failure on line 4 in src/lib/types.ts

View workflow job for this annotation

GitHub Actions / Unit + Type Check / Node.js 20 / OS macos-latest

Module '"@supabase/storage-js/dist/module/StorageClient"' has no exported member 'StorageClientOptions'.

Check failure on line 4 in src/lib/types.ts

View workflow job for this annotation

GitHub Actions / Unit + Type Check / Node.js 20 / OS ubuntu-latest

Module '"@supabase/storage-js/dist/module/StorageClient"' has no exported member 'StorageClientOptions'.

type AuthClientOptions = ConstructorParameters<typeof AuthClient>[0]

Expand Down Expand Up @@ -56,6 +57,7 @@
* Options passed to the realtime-js instance
*/
realtime?: RealtimeClientOptions
storage?: StorageClientOptions
global?: {
/**
* A custom `fetch` implementation.
Expand Down
Loading