@neondatabase/neon-js 0.1.0-alpha.4 → 0.1.0-alpha.5
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/README.md +13 -16
- package/dist/index.d.mts +137 -67
- package/dist/index.mjs +1 -4
- package/dist/package.json +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ import { createClient, SupabaseAuthAdapter } from '@neondatabase/neon-js';
|
|
|
32
32
|
|
|
33
33
|
const client = createClient<Database>({
|
|
34
34
|
auth: {
|
|
35
|
-
adapter: SupabaseAuthAdapter,
|
|
35
|
+
adapter: SupabaseAuthAdapter(),
|
|
36
36
|
url: import.meta.env.VITE_NEON_AUTH_URL,
|
|
37
37
|
},
|
|
38
38
|
dataApi: {
|
|
@@ -60,7 +60,7 @@ import { createClient, BetterAuthVanillaAdapter } from '@neondatabase/neon-js';
|
|
|
60
60
|
|
|
61
61
|
const client = createClient<Database>({
|
|
62
62
|
auth: {
|
|
63
|
-
adapter: BetterAuthVanillaAdapter,
|
|
63
|
+
adapter: BetterAuthVanillaAdapter(),
|
|
64
64
|
url: import.meta.env.VITE_NEON_AUTH_URL,
|
|
65
65
|
},
|
|
66
66
|
dataApi: {
|
|
@@ -87,7 +87,7 @@ import { createClient, BetterAuthReactAdapter } from '@neondatabase/neon-js';
|
|
|
87
87
|
|
|
88
88
|
const client = createClient<Database>({
|
|
89
89
|
auth: {
|
|
90
|
-
adapter: BetterAuthReactAdapter,
|
|
90
|
+
adapter: BetterAuthReactAdapter(),
|
|
91
91
|
url: import.meta.env.VITE_NEON_AUTH_URL,
|
|
92
92
|
},
|
|
93
93
|
dataApi: {
|
|
@@ -301,11 +301,8 @@ import { createClient, SupabaseAuthAdapter } from '@neondatabase/neon-js';
|
|
|
301
301
|
const client = createClient({
|
|
302
302
|
// Auth configuration
|
|
303
303
|
auth: {
|
|
304
|
-
adapter: SupabaseAuthAdapter,
|
|
304
|
+
adapter: SupabaseAuthAdapter(),
|
|
305
305
|
url: 'https://your-auth-server.neon.tech/auth',
|
|
306
|
-
options: {
|
|
307
|
-
// Additional adapter-specific options
|
|
308
|
-
},
|
|
309
306
|
},
|
|
310
307
|
|
|
311
308
|
// Data API configuration
|
|
@@ -340,7 +337,7 @@ import { createClient, SupabaseAuthAdapter } from '@neondatabase/neon-js';
|
|
|
340
337
|
|
|
341
338
|
const client = createClient({
|
|
342
339
|
auth: {
|
|
343
|
-
adapter: SupabaseAuthAdapter,
|
|
340
|
+
adapter: SupabaseAuthAdapter(),
|
|
344
341
|
url: process.env.NEON_AUTH_URL!,
|
|
345
342
|
},
|
|
346
343
|
dataApi: {
|
|
@@ -354,7 +351,7 @@ const client = createClient({
|
|
|
354
351
|
Generate TypeScript types from your database schema:
|
|
355
352
|
|
|
356
353
|
```bash
|
|
357
|
-
npx neon-js gen-types --
|
|
354
|
+
npx neon-js gen-types --db-url "postgresql://user:pass@host/db"
|
|
358
355
|
```
|
|
359
356
|
|
|
360
357
|
Use generated types for full type safety:
|
|
@@ -365,7 +362,7 @@ import { createClient, SupabaseAuthAdapter } from '@neondatabase/neon-js';
|
|
|
365
362
|
|
|
366
363
|
const client = createClient<Database>({
|
|
367
364
|
auth: {
|
|
368
|
-
adapter: SupabaseAuthAdapter,
|
|
365
|
+
adapter: SupabaseAuthAdapter(),
|
|
369
366
|
url: process.env.NEON_AUTH_URL!,
|
|
370
367
|
},
|
|
371
368
|
dataApi: {
|
|
@@ -387,18 +384,18 @@ Generate TypeScript types from your database:
|
|
|
387
384
|
```bash
|
|
388
385
|
# Generate types
|
|
389
386
|
npx neon-js gen-types \
|
|
390
|
-
--
|
|
387
|
+
--db-url "postgresql://user:pass@host/db" \
|
|
391
388
|
--output ./types/database.ts
|
|
392
389
|
|
|
393
390
|
# With schema filtering
|
|
394
391
|
npx neon-js gen-types \
|
|
395
|
-
--
|
|
392
|
+
--db-url "postgresql://user:pass@host/db" \
|
|
396
393
|
--schemas public,auth \
|
|
397
394
|
--output ./types/database.ts
|
|
398
395
|
```
|
|
399
396
|
|
|
400
397
|
**Options:**
|
|
401
|
-
- `--
|
|
398
|
+
- `--db-url`, `-c` - PostgreSQL connection string (required)
|
|
402
399
|
- `--output`, `-o` - Output file path (default: `./types/database.ts`)
|
|
403
400
|
- `--schemas`, `-s` - Comma-separated list of schemas (default: `public`)
|
|
404
401
|
|
|
@@ -457,7 +454,7 @@ import { createClient, SupabaseAuthAdapter } from '@neondatabase/neon-js';
|
|
|
457
454
|
|
|
458
455
|
export const neon = createClient({
|
|
459
456
|
auth: {
|
|
460
|
-
adapter: SupabaseAuthAdapter,
|
|
457
|
+
adapter: SupabaseAuthAdapter(),
|
|
461
458
|
url: process.env.NEON_AUTH_URL!,
|
|
462
459
|
},
|
|
463
460
|
dataApi: {
|
|
@@ -481,7 +478,7 @@ import { createClient, BetterAuthReactAdapter } from '@neondatabase/neon-js';
|
|
|
481
478
|
|
|
482
479
|
const client = createClient({
|
|
483
480
|
auth: {
|
|
484
|
-
adapter: BetterAuthReactAdapter,
|
|
481
|
+
adapter: BetterAuthReactAdapter(),
|
|
485
482
|
url: process.env.NEXT_PUBLIC_NEON_AUTH_URL!,
|
|
486
483
|
},
|
|
487
484
|
dataApi: {
|
|
@@ -525,7 +522,7 @@ import { createClient, SupabaseAuthAdapter } from '@neondatabase/neon-js';
|
|
|
525
522
|
|
|
526
523
|
const client = createClient({
|
|
527
524
|
auth: {
|
|
528
|
-
adapter: SupabaseAuthAdapter,
|
|
525
|
+
adapter: SupabaseAuthAdapter(),
|
|
529
526
|
url: 'https://auth.example.com',
|
|
530
527
|
},
|
|
531
528
|
dataApi: {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as better_auth_react0 from "better-auth/react";
|
|
2
|
-
import { createAuthClient, useStore as useBetterAuthStore } from "better-auth/react";
|
|
3
|
-
import { AuthClient, BetterAuthClientOptions, createAuthClient as createAuthClient$
|
|
2
|
+
import { createAuthClient as createAuthClient$1, useStore as useBetterAuthStore } from "better-auth/react";
|
|
3
|
+
import { AuthClient, BetterAuthClientOptions, createAuthClient as createAuthClient$2 } from "better-auth/client";
|
|
4
4
|
import * as better_auth0 from "better-auth";
|
|
5
5
|
import * as _better_fetch_fetch0 from "@better-fetch/fetch";
|
|
6
6
|
import * as nanostores0 from "nanostores";
|
|
@@ -17,15 +17,18 @@ declare abstract class NeonAuthAdapterCore {
|
|
|
17
17
|
* See CLAUDE.md for architecture details and API mappings.
|
|
18
18
|
*/
|
|
19
19
|
constructor(betterAuthClientOptions: NeonAuthAdapterCoreAuthOptions);
|
|
20
|
-
abstract getBetterAuthInstance?(): AuthClient<BetterAuthClientOptions> | ReturnType<typeof createAuthClient>;
|
|
20
|
+
abstract getBetterAuthInstance?(): AuthClient<BetterAuthClientOptions> | ReturnType<typeof createAuthClient$1>;
|
|
21
21
|
abstract getJWTToken(): Promise<string | null>;
|
|
22
22
|
}
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region ../neon-auth/src/adapters/better-auth-react/better-auth-react-adapter.d.ts
|
|
25
|
-
type BetterAuthReactAdapterOptions = NeonAuthAdapterCoreAuthOptions
|
|
26
|
-
|
|
25
|
+
type BetterAuthReactAdapterOptions = Omit<NeonAuthAdapterCoreAuthOptions, 'baseURL'>;
|
|
26
|
+
/**
|
|
27
|
+
* Internal implementation class - use BetterAuthReactAdapter factory function instead
|
|
28
|
+
*/
|
|
29
|
+
declare class BetterAuthReactAdapterImpl extends NeonAuthAdapterCore {
|
|
27
30
|
private _betterAuth;
|
|
28
|
-
constructor(betterAuthClientOptions:
|
|
31
|
+
constructor(betterAuthClientOptions: NeonAuthAdapterCoreAuthOptions);
|
|
29
32
|
getBetterAuthInstance(): {
|
|
30
33
|
signIn: {
|
|
31
34
|
social: <FetchOptions extends better_auth0.ClientFetchOption<Partial<{
|
|
@@ -716,15 +719,64 @@ declare class BetterAuthReactAdapter extends NeonAuthAdapterCore {
|
|
|
716
719
|
};
|
|
717
720
|
getJWTToken(): Promise<string | null>;
|
|
718
721
|
}
|
|
722
|
+
/** Instance type for BetterAuthReactAdapter */
|
|
723
|
+
type BetterAuthReactAdapterInstance = BetterAuthReactAdapterImpl;
|
|
724
|
+
/** Builder type that creates adapter instances */
|
|
725
|
+
type BetterAuthReactAdapterBuilder = (url: string) => BetterAuthReactAdapterInstance;
|
|
726
|
+
/**
|
|
727
|
+
* Factory function that returns an adapter builder.
|
|
728
|
+
* The builder is called by createClient/createAuthClient with the URL.
|
|
729
|
+
*
|
|
730
|
+
* @param options - Optional adapter configuration (baseURL is injected separately)
|
|
731
|
+
* @returns A builder function that creates the adapter instance
|
|
732
|
+
*
|
|
733
|
+
* @example
|
|
734
|
+
* ```typescript
|
|
735
|
+
* const client = createClient({
|
|
736
|
+
* auth: {
|
|
737
|
+
* url: 'https://auth.example.com',
|
|
738
|
+
* adapter: BetterAuthReactAdapter(),
|
|
739
|
+
* },
|
|
740
|
+
* dataApi: { url: 'https://data-api.example.com' },
|
|
741
|
+
* });
|
|
742
|
+
* ```
|
|
743
|
+
*/
|
|
744
|
+
declare function BetterAuthReactAdapter(options?: BetterAuthReactAdapterOptions): BetterAuthReactAdapterBuilder;
|
|
719
745
|
//#endregion
|
|
720
746
|
//#region ../neon-auth/src/adapters/better-auth-vanilla/better-auth-vanilla-adapter.d.ts
|
|
721
|
-
type BetterAuthVanillaAdapterOptions = NeonAuthAdapterCoreAuthOptions
|
|
722
|
-
|
|
747
|
+
type BetterAuthVanillaAdapterOptions = Omit<NeonAuthAdapterCoreAuthOptions, 'baseURL'>;
|
|
748
|
+
/**
|
|
749
|
+
* Internal implementation class - use BetterAuthVanillaAdapter factory function instead
|
|
750
|
+
*/
|
|
751
|
+
declare class BetterAuthVanillaAdapterImpl extends NeonAuthAdapterCore {
|
|
723
752
|
private _betterAuth;
|
|
724
|
-
constructor(betterAuthClientOptions:
|
|
753
|
+
constructor(betterAuthClientOptions: NeonAuthAdapterCoreAuthOptions);
|
|
725
754
|
getBetterAuthInstance(): AuthClient<BetterAuthClientOptions>;
|
|
726
755
|
getJWTToken(): Promise<string | null>;
|
|
727
756
|
}
|
|
757
|
+
/** Instance type for BetterAuthVanillaAdapter */
|
|
758
|
+
type BetterAuthVanillaAdapterInstance = BetterAuthVanillaAdapterImpl;
|
|
759
|
+
/** Builder type that creates adapter instances */
|
|
760
|
+
type BetterAuthVanillaAdapterBuilder = (url: string) => BetterAuthVanillaAdapterInstance;
|
|
761
|
+
/**
|
|
762
|
+
* Factory function that returns an adapter builder.
|
|
763
|
+
* The builder is called by createClient/createAuthClient with the URL.
|
|
764
|
+
*
|
|
765
|
+
* @param options - Optional adapter configuration (baseURL is injected separately)
|
|
766
|
+
* @returns A builder function that creates the adapter instance
|
|
767
|
+
*
|
|
768
|
+
* @example
|
|
769
|
+
* ```typescript
|
|
770
|
+
* const client = createClient({
|
|
771
|
+
* auth: {
|
|
772
|
+
* url: 'https://auth.example.com',
|
|
773
|
+
* adapter: BetterAuthVanillaAdapter(),
|
|
774
|
+
* },
|
|
775
|
+
* dataApi: { url: 'https://data-api.example.com' },
|
|
776
|
+
* });
|
|
777
|
+
* ```
|
|
778
|
+
*/
|
|
779
|
+
declare function BetterAuthVanillaAdapter(options?: BetterAuthVanillaAdapterOptions): BetterAuthVanillaAdapterBuilder;
|
|
728
780
|
//#endregion
|
|
729
781
|
//#region ../neon-auth/src/adapters/supabase/auth-interface.d.ts
|
|
730
782
|
type _UpstreamAuthClientInstance = InstanceType<typeof AuthClient$1>;
|
|
@@ -732,14 +784,17 @@ type _AuthClientBase = { [K in keyof _UpstreamAuthClientInstance as _UpstreamAut
|
|
|
732
784
|
type SupabaseAuthClientInterface = _AuthClientBase;
|
|
733
785
|
//#endregion
|
|
734
786
|
//#region ../neon-auth/src/adapters/supabase/supabase-adapter.d.ts
|
|
735
|
-
type SupabaseAuthAdapterOptions = NeonAuthAdapterCoreAuthOptions
|
|
736
|
-
|
|
787
|
+
type SupabaseAuthAdapterOptions = Omit<NeonAuthAdapterCoreAuthOptions, 'baseURL'>;
|
|
788
|
+
/**
|
|
789
|
+
* Internal implementation class - use SupabaseAuthAdapter factory function instead
|
|
790
|
+
*/
|
|
791
|
+
declare class SupabaseAuthAdapterImpl extends NeonAuthAdapterCore implements SupabaseAuthClientInterface {
|
|
737
792
|
admin: SupabaseAuthClientInterface['admin'];
|
|
738
793
|
mfa: SupabaseAuthClientInterface['mfa'];
|
|
739
794
|
oauth: SupabaseAuthClientInterface['oauth'];
|
|
740
795
|
private _betterAuth;
|
|
741
796
|
private _stateChangeEmitters;
|
|
742
|
-
constructor(betterAuthClientOptions:
|
|
797
|
+
constructor(betterAuthClientOptions: NeonAuthAdapterCoreAuthOptions);
|
|
743
798
|
getBetterAuthInstance(): AuthClient<BetterAuthClientOptions>;
|
|
744
799
|
getJWTToken(): Promise<string | null>;
|
|
745
800
|
initialize: SupabaseAuthClientInterface['initialize'];
|
|
@@ -786,44 +841,59 @@ declare class SupabaseAuthAdapter extends NeonAuthAdapterCore implements Supabas
|
|
|
786
841
|
private verifyPhoneOtp;
|
|
787
842
|
private emitInitialSession;
|
|
788
843
|
}
|
|
844
|
+
/** Instance type for SupabaseAuthAdapter */
|
|
845
|
+
type SupabaseAuthAdapterInstance = SupabaseAuthAdapterImpl;
|
|
846
|
+
/** Builder type that creates adapter instances */
|
|
847
|
+
type SupabaseAuthAdapterBuilder = (url: string) => SupabaseAuthAdapterInstance;
|
|
848
|
+
/**
|
|
849
|
+
* Factory function that returns an adapter builder.
|
|
850
|
+
* The builder is called by createClient/createAuthClient with the URL.
|
|
851
|
+
*
|
|
852
|
+
* @param options - Optional adapter configuration (baseURL is injected separately)
|
|
853
|
+
* @returns A builder function that creates the adapter instance
|
|
854
|
+
*
|
|
855
|
+
* @example
|
|
856
|
+
* ```typescript
|
|
857
|
+
* const client = createClient({
|
|
858
|
+
* auth: {
|
|
859
|
+
* url: 'https://auth.example.com',
|
|
860
|
+
* adapter: SupabaseAuthAdapter(),
|
|
861
|
+
* },
|
|
862
|
+
* dataApi: { url: 'https://data-api.example.com' },
|
|
863
|
+
* });
|
|
864
|
+
* ```
|
|
865
|
+
*/
|
|
866
|
+
declare function SupabaseAuthAdapter(options?: SupabaseAuthAdapterOptions): SupabaseAuthAdapterBuilder;
|
|
789
867
|
//#endregion
|
|
790
868
|
//#region ../neon-auth/src/neon-auth.d.ts
|
|
791
869
|
/**
|
|
792
870
|
* Type representing the Better Auth React client
|
|
793
871
|
*/
|
|
794
|
-
type ReactBetterAuthClient = ReturnType<typeof createAuthClient>;
|
|
872
|
+
type ReactBetterAuthClient = ReturnType<typeof createAuthClient$1>;
|
|
795
873
|
/**
|
|
796
874
|
* Type representing the Better Auth Vanilla client
|
|
797
875
|
*/
|
|
798
|
-
type VanillaBetterAuthClient = ReturnType<typeof createAuthClient$
|
|
799
|
-
/**
|
|
800
|
-
* Union type of all supported auth adapter CLASSES (not instances)
|
|
801
|
-
* Use this when you need to pass an adapter class as a parameter
|
|
802
|
-
*/
|
|
803
|
-
type NeonAuthAdapterClass = typeof BetterAuthVanillaAdapter | typeof BetterAuthReactAdapter | typeof SupabaseAuthAdapter;
|
|
876
|
+
type VanillaBetterAuthClient = ReturnType<typeof createAuthClient$2>;
|
|
804
877
|
/**
|
|
805
878
|
* Union type of all supported auth adapter instances
|
|
806
879
|
*/
|
|
807
|
-
type NeonAuthAdapter =
|
|
880
|
+
type NeonAuthAdapter = BetterAuthVanillaAdapterInstance | BetterAuthReactAdapterInstance | SupabaseAuthAdapterInstance;
|
|
808
881
|
/**
|
|
809
|
-
* Configuration for
|
|
810
|
-
* T is the adapter CLASS type (typeof SupabaseAuthAdapter), not the instance type
|
|
882
|
+
* Configuration for createAuthClient
|
|
811
883
|
*/
|
|
812
|
-
interface NeonAuthConfig<T extends
|
|
813
|
-
/** The adapter
|
|
814
|
-
adapter: T;
|
|
815
|
-
/** Additional options to pass to the adapter (baseURL is auto-injected) */
|
|
816
|
-
options?: Omit<ConstructorParameters<T>[0], 'baseURL'>;
|
|
884
|
+
interface NeonAuthConfig<T extends NeonAuthAdapter> {
|
|
885
|
+
/** The adapter builder to use. Defaults to BetterAuthVanillaAdapter() if not specified. */
|
|
886
|
+
adapter?: (url: string) => T;
|
|
817
887
|
}
|
|
818
888
|
/**
|
|
819
889
|
* Resolves the public API type for an adapter.
|
|
820
890
|
* - SupabaseAuthAdapter: exposes its own methods directly (Supabase-compatible API)
|
|
821
891
|
* - BetterAuth adapters: expose the Better Auth client directly
|
|
822
892
|
*/
|
|
823
|
-
type NeonAuthPublicApi<T extends NeonAuthAdapter> = T extends
|
|
893
|
+
type NeonAuthPublicApi<T extends NeonAuthAdapter> = T extends BetterAuthVanillaAdapterInstance ? VanillaBetterAuthClient : T extends BetterAuthReactAdapterInstance ? ReactBetterAuthClient : T;
|
|
824
894
|
/**
|
|
825
895
|
* NeonAuth type - combines base functionality with the appropriate public API
|
|
826
|
-
* This is the return type of
|
|
896
|
+
* This is the return type of createAuthClient()
|
|
827
897
|
*
|
|
828
898
|
* For SupabaseAuthAdapter: exposes Supabase-compatible methods (signInWithPassword, getSession, etc.)
|
|
829
899
|
* For BetterAuth adapters: exposes the Better Auth client directly (signIn.email, signUp.email, etc.)
|
|
@@ -836,15 +906,15 @@ type NeonAuth<T extends NeonAuthAdapter> = {
|
|
|
836
906
|
* Create a NeonAuth instance that exposes the appropriate API based on the adapter.
|
|
837
907
|
*
|
|
838
908
|
* @param url - The auth service URL (e.g., 'https://auth.example.com')
|
|
839
|
-
* @param config - Configuration with adapter
|
|
909
|
+
* @param config - Configuration with adapter builder
|
|
840
910
|
* @returns NeonAuth instance with the adapter's API exposed directly
|
|
841
911
|
*
|
|
842
912
|
* @example SupabaseAuthAdapter - Supabase-compatible API
|
|
843
913
|
* ```typescript
|
|
844
|
-
* import {
|
|
914
|
+
* import { createAuthClient, SupabaseAuthAdapter } from '@neondatabase/neon-auth';
|
|
845
915
|
*
|
|
846
|
-
* const auth =
|
|
847
|
-
* adapter: SupabaseAuthAdapter,
|
|
916
|
+
* const auth = createAuthClient('https://auth.example.com', {
|
|
917
|
+
* adapter: SupabaseAuthAdapter(),
|
|
848
918
|
* });
|
|
849
919
|
*
|
|
850
920
|
* // Supabase-compatible methods
|
|
@@ -854,10 +924,10 @@ type NeonAuth<T extends NeonAuthAdapter> = {
|
|
|
854
924
|
*
|
|
855
925
|
* @example BetterAuthVanillaAdapter - Direct Better Auth API
|
|
856
926
|
* ```typescript
|
|
857
|
-
* import {
|
|
927
|
+
* import { createAuthClient, BetterAuthVanillaAdapter } from '@neondatabase/neon-auth';
|
|
858
928
|
*
|
|
859
|
-
* const auth =
|
|
860
|
-
* adapter: BetterAuthVanillaAdapter,
|
|
929
|
+
* const auth = createAuthClient('https://auth.example.com', {
|
|
930
|
+
* adapter: BetterAuthVanillaAdapter(),
|
|
861
931
|
* });
|
|
862
932
|
*
|
|
863
933
|
* // Direct Better Auth API access
|
|
@@ -868,10 +938,10 @@ type NeonAuth<T extends NeonAuthAdapter> = {
|
|
|
868
938
|
*
|
|
869
939
|
* @example BetterAuthReactAdapter - Better Auth with React hooks
|
|
870
940
|
* ```typescript
|
|
871
|
-
* import {
|
|
941
|
+
* import { createAuthClient, BetterAuthReactAdapter } from '@neondatabase/neon-auth';
|
|
872
942
|
*
|
|
873
|
-
* const auth =
|
|
874
|
-
* adapter: BetterAuthReactAdapter,
|
|
943
|
+
* const auth = createAuthClient('https://auth.example.com', {
|
|
944
|
+
* adapter: BetterAuthReactAdapter(),
|
|
875
945
|
* });
|
|
876
946
|
*
|
|
877
947
|
* // Direct Better Auth API with React hooks
|
|
@@ -879,8 +949,8 @@ type NeonAuth<T extends NeonAuthAdapter> = {
|
|
|
879
949
|
* const session = auth.useSession(); // React hook
|
|
880
950
|
* ```
|
|
881
951
|
*/
|
|
882
|
-
declare function createInternalNeonAuth<T extends
|
|
883
|
-
declare function
|
|
952
|
+
declare function createInternalNeonAuth<T extends NeonAuthAdapter = BetterAuthVanillaAdapterInstance>(url: string, config?: NeonAuthConfig<T>): NeonAuth<T>;
|
|
953
|
+
declare function createAuthClient<T extends NeonAuthAdapter = BetterAuthVanillaAdapterInstance>(url: string, config?: NeonAuthConfig<T>): NeonAuthPublicApi<T>;
|
|
884
954
|
//#endregion
|
|
885
955
|
//#region ../neon-auth/src/utils/jwt.d.ts
|
|
886
956
|
/**
|
|
@@ -950,13 +1020,11 @@ declare class NeonClient<Database = any, SchemaName extends string & keyof Datab
|
|
|
950
1020
|
/**
|
|
951
1021
|
* Auth configuration for createClient
|
|
952
1022
|
*/
|
|
953
|
-
type CreateClientAuthConfig<T extends
|
|
954
|
-
/** The adapter
|
|
955
|
-
adapter: T;
|
|
1023
|
+
type CreateClientAuthConfig<T extends NeonAuthAdapter> = {
|
|
1024
|
+
/** The adapter builder to use. Defaults to BetterAuthVanillaAdapter() if not specified. */
|
|
1025
|
+
adapter?: (url: string) => T;
|
|
956
1026
|
/** The auth service URL */
|
|
957
1027
|
url: string;
|
|
958
|
-
/** Additional auth options (baseURL is set from url above) */
|
|
959
|
-
options?: Omit<ConstructorParameters<T>[0], 'baseURL'>;
|
|
960
1028
|
};
|
|
961
1029
|
/**
|
|
962
1030
|
* Data API configuration for createClient
|
|
@@ -970,11 +1038,11 @@ type CreateClientDataApiConfig<SchemaName, TAuth extends NeonAuthAdapter> = {
|
|
|
970
1038
|
/**
|
|
971
1039
|
* Configuration for createClient
|
|
972
1040
|
*/
|
|
973
|
-
type CreateClientConfig<SchemaName, T extends
|
|
1041
|
+
type CreateClientConfig<SchemaName, T extends NeonAuthAdapter> = {
|
|
974
1042
|
/** Auth service configuration */
|
|
975
1043
|
auth: CreateClientAuthConfig<T>;
|
|
976
1044
|
/** Data API configuration */
|
|
977
|
-
dataApi: CreateClientDataApiConfig<SchemaName,
|
|
1045
|
+
dataApi: CreateClientDataApiConfig<SchemaName, T>;
|
|
978
1046
|
};
|
|
979
1047
|
/**
|
|
980
1048
|
* Factory function to create NeonClient with seamless auth integration.
|
|
@@ -985,20 +1053,16 @@ type CreateClientConfig<SchemaName, T extends NeonAuthAdapterClass> = {
|
|
|
985
1053
|
*
|
|
986
1054
|
* @example
|
|
987
1055
|
* ```typescript
|
|
988
|
-
*
|
|
1056
|
+
* // Simple usage with default BetterAuthVanillaAdapter
|
|
1057
|
+
* import { createClient } from '@neondatabase/neon-js';
|
|
989
1058
|
*
|
|
990
1059
|
* const client = createClient({
|
|
991
|
-
* auth: {
|
|
992
|
-
*
|
|
993
|
-
* url: 'https://auth.example.com',
|
|
994
|
-
* },
|
|
995
|
-
* dataApi: {
|
|
996
|
-
* url: 'https://data-api.example.com/rest/v1',
|
|
997
|
-
* },
|
|
1060
|
+
* auth: { url: 'https://auth.example.com' },
|
|
1061
|
+
* dataApi: { url: 'https://data-api.example.com/rest/v1' },
|
|
998
1062
|
* });
|
|
999
1063
|
*
|
|
1000
|
-
* // Auth
|
|
1001
|
-
* await client.auth.
|
|
1064
|
+
* // Better Auth API
|
|
1065
|
+
* await client.auth.signIn.email({ email, password });
|
|
1002
1066
|
*
|
|
1003
1067
|
* // Database queries (automatic token injection)
|
|
1004
1068
|
* const { data: items } = await client.from('items').select();
|
|
@@ -1006,11 +1070,12 @@ type CreateClientConfig<SchemaName, T extends NeonAuthAdapterClass> = {
|
|
|
1006
1070
|
*
|
|
1007
1071
|
* @example
|
|
1008
1072
|
* ```typescript
|
|
1009
|
-
*
|
|
1073
|
+
* // With SupabaseAuthAdapter for Supabase-compatible API
|
|
1074
|
+
* import { createClient, SupabaseAuthAdapter } from '@neondatabase/neon-js';
|
|
1010
1075
|
*
|
|
1011
1076
|
* const client = createClient({
|
|
1012
1077
|
* auth: {
|
|
1013
|
-
* adapter:
|
|
1078
|
+
* adapter: SupabaseAuthAdapter,
|
|
1014
1079
|
* url: 'https://auth.example.com',
|
|
1015
1080
|
* },
|
|
1016
1081
|
* dataApi: {
|
|
@@ -1018,9 +1083,8 @@ type CreateClientConfig<SchemaName, T extends NeonAuthAdapterClass> = {
|
|
|
1018
1083
|
* },
|
|
1019
1084
|
* });
|
|
1020
1085
|
*
|
|
1021
|
-
* //
|
|
1022
|
-
*
|
|
1023
|
-
* await betterAuth.signIn.email({ email, password });
|
|
1086
|
+
* // Supabase-compatible auth methods
|
|
1087
|
+
* await client.auth.signInWithPassword({ email, password });
|
|
1024
1088
|
* ```
|
|
1025
1089
|
*/
|
|
1026
1090
|
/**
|
|
@@ -1028,8 +1092,14 @@ type CreateClientConfig<SchemaName, T extends NeonAuthAdapterClass> = {
|
|
|
1028
1092
|
* Uses 'public' as the default schema since it's the most common case.
|
|
1029
1093
|
*/
|
|
1030
1094
|
type CreateClientResult<Database, TAdapter extends NeonAuthAdapter> = NeonClient<Database, DefaultSchemaName<Database>, TAdapter>;
|
|
1031
|
-
declare function createClient<Database = any>(config:
|
|
1032
|
-
|
|
1033
|
-
|
|
1095
|
+
declare function createClient<Database = any>(config: {
|
|
1096
|
+
auth: {
|
|
1097
|
+
url: string;
|
|
1098
|
+
};
|
|
1099
|
+
dataApi: CreateClientDataApiConfig<DefaultSchemaName<Database>, BetterAuthVanillaAdapterInstance>;
|
|
1100
|
+
}): CreateClientResult<Database, BetterAuthVanillaAdapterInstance>;
|
|
1101
|
+
declare function createClient<Database = any>(config: CreateClientConfig<DefaultSchemaName<Database>, SupabaseAuthAdapterInstance>): CreateClientResult<Database, SupabaseAuthAdapterInstance>;
|
|
1102
|
+
declare function createClient<Database = any>(config: CreateClientConfig<DefaultSchemaName<Database>, BetterAuthVanillaAdapterInstance>): CreateClientResult<Database, BetterAuthVanillaAdapterInstance>;
|
|
1103
|
+
declare function createClient<Database = any>(config: CreateClientConfig<DefaultSchemaName<Database>, BetterAuthReactAdapterInstance>): CreateClientResult<Database, BetterAuthReactAdapterInstance>;
|
|
1034
1104
|
//#endregion
|
|
1035
|
-
export { AuthApiError, AuthError, BetterAuthReactAdapter, BetterAuthVanillaAdapter, type
|
|
1105
|
+
export { AuthApiError, AuthError, BetterAuthReactAdapter, type BetterAuthReactAdapterInstance, type BetterAuthReactAdapterOptions, BetterAuthVanillaAdapter, type BetterAuthVanillaAdapterInstance, type BetterAuthVanillaAdapterOptions, type NeonAuth, type NeonAuthAdapter, type NeonAuthConfig, type NeonAuthPublicApi, type ReactBetterAuthClient, type Session, SupabaseAuthAdapter, type SupabaseAuthAdapterInstance, type SupabaseAuthAdapterOptions, type User, type VanillaBetterAuthClient, createAuthClient, createClient, createInternalNeonAuth, getJwtExpiration, getJwtExpirationMs, isAuthError, useBetterAuthStore };
|
package/dist/index.mjs
CHANGED
|
@@ -25,10 +25,7 @@ var NeonClient = class extends NeonPostgrestClient {
|
|
|
25
25
|
//#region src/client/client-factory.ts
|
|
26
26
|
function createClient(config) {
|
|
27
27
|
const { auth: authConfig, dataApi: dataApiConfig } = config;
|
|
28
|
-
const auth = createInternalNeonAuth(authConfig.url, {
|
|
29
|
-
adapter: authConfig.adapter,
|
|
30
|
-
options: authConfig.options
|
|
31
|
-
});
|
|
28
|
+
const auth = createInternalNeonAuth(authConfig.url, { adapter: authConfig.adapter });
|
|
32
29
|
const getAccessToken = async () => {
|
|
33
30
|
return await auth.getJWTToken();
|
|
34
31
|
};
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neondatabase/neon-js",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"description": "A TypeScript SDK for Neon services",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@neondatabase/postgrest-js": "^0.1.0-alpha.1",
|
|
56
|
-
"@neondatabase/neon-auth": "^0.1.0-alpha.
|
|
56
|
+
"@neondatabase/neon-auth": "^0.1.0-alpha.2",
|
|
57
57
|
"@supabase/postgres-meta": "0.93.1",
|
|
58
58
|
"meow": "14.0.0",
|
|
59
59
|
"zod": "4.1.12"
|