Skip to content

Commit 2e73a11

Browse files
caseybaggzmandarini
authored andcommitted
chore: improve types for functions and cookies
1 parent 64ff6b3 commit 2e73a11

File tree

5 files changed

+82
-138
lines changed

5 files changed

+82
-138
lines changed

package-lock.json

Lines changed: 45 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"homepage": "https://github.com/supabase/ssr#readme",
3434
"devDependencies": {
3535
"@eslint/js": "^9.3.0",
36-
"@supabase/supabase-js": "^2.76.1",
36+
"@supabase/supabase-js": "^2.85.0",
3737
"@types/node": "^24.3.0",
3838
"@vitest/coverage-v8": "^1.6.0",
3939
"eslint": "^8.57.0",

src/createBrowserClient.ts

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ import {
77
import { VERSION } from "./version";
88
import { isBrowser } from "./utils";
99

10-
import type {
11-
CookieMethodsBrowser,
12-
CookieMethodsBrowserDeprecated,
13-
CookieOptionsWithName,
14-
} from "./types";
10+
import type { CookieMethodsBrowser, CookieOptionsWithName } from "./types";
1511

1612
import { createStorageFromOptions } from "./cookies";
1713

@@ -47,36 +43,11 @@ export function createBrowserClient<
4743
supabaseUrl: string,
4844
supabaseKey: string,
4945
options?: SupabaseClientOptions<SchemaName> & {
50-
cookies?: CookieMethodsBrowser;
51-
cookieOptions?: CookieOptionsWithName;
52-
cookieEncoding?: "raw" | "base64url";
53-
isSingleton?: boolean;
54-
},
55-
): SupabaseClient<Database, SchemaName>;
56-
57-
/**
58-
* @deprecated Please specify `getAll` and `setAll` cookie methods instead of
59-
* the `get`, `set` and `remove`. These will not be supported in the next major
60-
* version.
61-
*/
62-
export function createBrowserClient<
63-
Database = any,
64-
SchemaName extends string &
65-
keyof Omit<Database, "__InternalSupabase"> = "public" extends keyof Omit<
66-
Database,
67-
"__InternalSupabase"
68-
>
69-
? "public"
70-
: string & keyof Omit<Database, "__InternalSupabase">,
71-
>(
72-
supabaseUrl: string,
73-
supabaseKey: string,
74-
options?: SupabaseClientOptions<SchemaName> & {
75-
cookies: CookieMethodsBrowserDeprecated;
46+
cookies: CookieMethodsBrowser;
7647
cookieOptions?: CookieOptionsWithName;
7748
cookieEncoding?: "raw" | "base64url";
7849
isSingleton?: boolean;
79-
},
50+
}
8051
): SupabaseClient<Database, SchemaName>;
8152

8253
export function createBrowserClient<
@@ -92,11 +63,11 @@ export function createBrowserClient<
9263
supabaseUrl: string,
9364
supabaseKey: string,
9465
options?: SupabaseClientOptions<SchemaName> & {
95-
cookies?: CookieMethodsBrowser | CookieMethodsBrowserDeprecated;
66+
cookies?: CookieMethodsBrowser;
9667
cookieOptions?: CookieOptionsWithName;
9768
cookieEncoding?: "raw" | "base64url";
9869
isSingleton?: boolean;
99-
},
70+
}
10071
): SupabaseClient<Database, SchemaName> {
10172
// singleton client is created only if isSingleton is set to true, or if isSingleton is not defined and we detect a browser
10273
const shouldUseSingleton =
@@ -109,7 +80,7 @@ export function createBrowserClient<
10980

11081
if (!supabaseUrl || !supabaseKey) {
11182
throw new Error(
112-
`@supabase/ssr: Your project's URL and API key are required to create a Supabase client!\n\nCheck your Supabase project's API settings to find these values\n\nhttps://supabase.com/dashboard/project/_/settings/api`,
83+
`@supabase/ssr: Your project's URL and API key are required to create a Supabase client!\n\nCheck your Supabase project's API settings to find these values\n\nhttps://supabase.com/dashboard/project/_/settings/api`
11384
);
11485
}
11586

@@ -118,7 +89,7 @@ export function createBrowserClient<
11889
...options,
11990
cookieEncoding: options?.cookieEncoding ?? "base64url",
12091
},
121-
false,
92+
false
12293
);
12394

12495
const client = createClient<Database, SchemaName>(supabaseUrl, supabaseKey, {

src/createServerClient.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,9 @@ import { createStorageFromOptions, applyServerStorage } from "./cookies";
1010
import type {
1111
CookieOptionsWithName,
1212
CookieMethodsServer,
13-
CookieMethodsServerDeprecated,
1413
} from "./types";
1514
import { memoryLocalStorageAdapter } from "./utils/helpers";
1615

17-
/**
18-
* @deprecated Please specify `getAll` and `setAll` cookie methods instead of
19-
* the `get`, `set` and `remove`. These will not be supported in the next major
20-
* version.
21-
*/
22-
export function createServerClient<
23-
Database = any,
24-
SchemaName extends string &
25-
keyof Omit<Database, "__InternalSupabase"> = "public" extends keyof Omit<
26-
Database,
27-
"__InternalSupabase"
28-
>
29-
? "public"
30-
: string & keyof Omit<Database, "__InternalSupabase">,
31-
>(
32-
supabaseUrl: string,
33-
supabaseKey: string,
34-
options: SupabaseClientOptions<SchemaName> & {
35-
cookieOptions?: CookieOptionsWithName;
36-
cookies: CookieMethodsServerDeprecated;
37-
cookieEncoding?: "raw" | "base64url";
38-
},
39-
): SupabaseClient<Database, SchemaName>;
40-
4116
/**
4217
* Creates a Supabase Client for use on the server-side of a server-side
4318
* rendering (SSR) framework.
@@ -132,7 +107,7 @@ export function createServerClient<
132107
supabaseKey: string,
133108
options: SupabaseClientOptions<SchemaName> & {
134109
cookieOptions?: CookieOptionsWithName;
135-
cookies: CookieMethodsServer | CookieMethodsServerDeprecated;
110+
cookies: CookieMethodsServer;
136111
cookieEncoding?: "raw" | "base64url";
137112
},
138113
): SupabaseClient<Database, SchemaName> {

0 commit comments

Comments
 (0)