11import type { AuthPluginSchema } from "better-auth" ;
2- import type { FieldAttribute , FieldType } from "better-auth/db" ;
2+ import type { FieldAttribute } from "better-auth/db" ;
33import type { CloudflarePluginOptions } from "./types" ;
44
5- /**
6- * Type for geolocation database fields
7- */
8- type GeolocationFields = {
9- [ x : string ] : FieldAttribute < FieldType > ;
10- } ;
11-
12- /**
13- * Type for file tracking database fields
14- */
15- type FileFields = {
16- [ x : string ] : FieldAttribute < FieldType > ;
17- } ;
18-
195/**
206 * Database fields for Cloudflare geolocation
217 */
22- const geolocationFields : GeolocationFields = {
8+ const geolocationFields = {
239 timezone : {
2410 type : "string" ,
2511 required : false ,
2612 input : false ,
27- } ,
13+ } as FieldAttribute ,
2814 city : {
2915 type : "string" ,
3016 required : false ,
3117 input : false ,
32- } ,
18+ } as FieldAttribute ,
3319 country : {
3420 type : "string" ,
3521 required : false ,
3622 input : false ,
37- } ,
23+ } as FieldAttribute ,
3824 region : {
3925 type : "string" ,
4026 required : false ,
4127 input : false ,
42- } ,
28+ } as FieldAttribute ,
4329 regionCode : {
4430 type : "string" ,
4531 required : false ,
4632 input : false ,
47- } ,
33+ } as FieldAttribute ,
4834 colo : {
4935 type : "string" ,
5036 required : false ,
5137 input : false ,
52- } ,
38+ } as FieldAttribute ,
5339 latitude : {
5440 type : "string" ,
5541 required : false ,
5642 input : false ,
57- } ,
43+ } as FieldAttribute ,
5844 longitude : {
5945 type : "string" ,
6046 required : false ,
6147 input : false ,
62- } ,
48+ } as FieldAttribute ,
6349} ;
6450
6551/**
6652 * Core database fields for file tracking
6753 */
68- const coreFileFields : FileFields = {
54+ const coreFileFields = {
6955 userId : {
7056 type : "string" ,
7157 required : true ,
@@ -74,49 +60,49 @@ const coreFileFields: FileFields = {
7460 model : "user" ,
7561 field : "id" ,
7662 } ,
77- } ,
63+ } as FieldAttribute ,
7864 filename : {
7965 type : "string" ,
8066 required : true ,
8167 input : false ,
82- } ,
68+ } as FieldAttribute ,
8369 originalName : {
8470 type : "string" ,
8571 required : true ,
8672 input : false ,
87- } ,
73+ } as FieldAttribute ,
8874 contentType : {
8975 type : "string" ,
9076 required : true ,
9177 input : false ,
92- } ,
78+ } as FieldAttribute ,
9379 size : {
9480 type : "number" ,
9581 required : true ,
9682 input : false ,
97- } ,
83+ } as FieldAttribute ,
9884 r2Key : {
9985 type : "string" ,
10086 required : true ,
10187 input : false ,
102- } ,
88+ } as FieldAttribute ,
10389 uploadedAt : {
10490 type : "date" ,
10591 required : true ,
10692 input : false ,
107- } ,
93+ } as FieldAttribute ,
10894} ;
10995
11096/**
11197 * Generates file tracking fields including custom fields
11298 */
113- function generateFileFields ( additionalFields ?: Record < string , FieldAttribute > ) : FileFields {
99+ function generateFileFields ( additionalFields ?: Record < string , FieldAttribute > ) {
114100 const fields = { ...coreFileFields } ;
115101
116102 if ( additionalFields ) {
117103 for ( const [ fieldName , fieldConfig ] of Object . entries ( additionalFields ) ) {
118104 // Use FieldAttribute directly - no conversion needed!
119- fields [ fieldName ] = fieldConfig ;
105+ fields [ fieldName as keyof typeof fields ] = fieldConfig ;
120106 }
121107 }
122108
0 commit comments