@@ -12,12 +12,6 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '
12
12
import { captureException } from '../exports' ;
13
13
import { SPAN_STATUS_ERROR , SPAN_STATUS_OK } from '../tracing' ;
14
14
15
- export interface SupabaseClientConstructor {
16
- prototype : {
17
- from : ( table : string ) => PostgrestQueryBuilder ;
18
- } ;
19
- }
20
-
21
15
const AUTH_OPERATIONS_TO_INSTRUMENT = [
22
16
'reauthenticate' ,
23
17
'signInAnonymously' ,
@@ -40,9 +34,43 @@ const AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT = [
40
34
'inviteUserByEmail' ,
41
35
] ;
42
36
37
+ export const FILTER_MAPPINGS = {
38
+ eq : 'eq' ,
39
+ neq : 'neq' ,
40
+ gt : 'gt' ,
41
+ gte : 'gte' ,
42
+ lt : 'lt' ,
43
+ lte : 'lte' ,
44
+ like : 'like' ,
45
+ 'like(all)' : 'likeAllOf' ,
46
+ 'like(any)' : 'likeAnyOf' ,
47
+ ilike : 'ilike' ,
48
+ 'ilike(all)' : 'ilikeAllOf' ,
49
+ 'ilike(any)' : 'ilikeAnyOf' ,
50
+ is : 'is' ,
51
+ in : 'in' ,
52
+ cs : 'contains' ,
53
+ cd : 'containedBy' ,
54
+ sr : 'rangeGt' ,
55
+ nxl : 'rangeGte' ,
56
+ sl : 'rangeLt' ,
57
+ nxr : 'rangeLte' ,
58
+ adj : 'rangeAdjacent' ,
59
+ ov : 'overlaps' ,
60
+ fts : '' ,
61
+ plfts : 'plain' ,
62
+ phfts : 'phrase' ,
63
+ wfts : 'websearch' ,
64
+ not : 'not' ,
65
+ } ;
66
+
67
+ export const AVAILABLE_OPERATIONS = [ 'select' , 'insert' , 'upsert' , 'update' , 'delete' ] ;
68
+
43
69
type AuthOperationFn = ( ...args : unknown [ ] ) => Promise < unknown > ;
44
70
type AuthOperationName = ( typeof AUTH_OPERATIONS_TO_INSTRUMENT ) [ number ] ;
45
71
type AuthAdminOperationName = ( typeof AUTH_ADMIN_OPERATIONS_TO_INSTRUMENT ) [ number ] ;
72
+ type PostgrestQueryOperationName = ( typeof AVAILABLE_OPERATIONS ) [ number ] ;
73
+ type PostgrestQueryOperationFn = ( ...args : unknown [ ] ) => PostgrestFilterBuilder ;
46
74
47
75
export interface SupabaseClientInstance {
48
76
auth : {
@@ -51,11 +79,7 @@ export interface SupabaseClientInstance {
51
79
}
52
80
53
81
export interface PostgrestQueryBuilder {
54
- select : ( ...args : unknown [ ] ) => PostgrestFilterBuilder ;
55
- insert : ( ...args : unknown [ ] ) => PostgrestFilterBuilder ;
56
- upsert : ( ...args : unknown [ ] ) => PostgrestFilterBuilder ;
57
- update : ( ...args : unknown [ ] ) => PostgrestFilterBuilder ;
58
- delete : ( ...args : unknown [ ] ) => PostgrestFilterBuilder ;
82
+ [ key : PostgrestQueryOperationName ] : PostgrestQueryOperationFn ;
59
83
}
60
84
61
85
export interface PostgrestFilterBuilder {
@@ -90,37 +114,18 @@ export interface SupabaseBreadcrumb {
90
114
} ;
91
115
}
92
116
93
- export const AVAILABLE_OPERATIONS = [ 'select' , 'insert' , 'upsert' , 'update' , 'delete' ] ;
117
+ export interface SupabaseClientConstructor {
118
+ prototype : {
119
+ from : ( table : string ) => PostgrestQueryBuilder ;
120
+ } ;
121
+ }
94
122
95
- export const FILTER_MAPPINGS = {
96
- eq : 'eq' ,
97
- neq : 'neq' ,
98
- gt : 'gt' ,
99
- gte : 'gte' ,
100
- lt : 'lt' ,
101
- lte : 'lte' ,
102
- like : 'like' ,
103
- 'like(all)' : 'likeAllOf' ,
104
- 'like(any)' : 'likeAnyOf' ,
105
- ilike : 'ilike' ,
106
- 'ilike(all)' : 'ilikeAllOf' ,
107
- 'ilike(any)' : 'ilikeAnyOf' ,
108
- is : 'is' ,
109
- in : 'in' ,
110
- cs : 'contains' ,
111
- cd : 'containedBy' ,
112
- sr : 'rangeGt' ,
113
- nxl : 'rangeGte' ,
114
- sl : 'rangeLt' ,
115
- nxr : 'rangeLte' ,
116
- adj : 'rangeAdjacent' ,
117
- ov : 'overlaps' ,
118
- fts : '' ,
119
- plfts : 'plain' ,
120
- phfts : 'phrase' ,
121
- wfts : 'websearch' ,
122
- not : 'not' ,
123
- } ;
123
+ export interface PostgrestProtoThenable {
124
+ then : < T > (
125
+ onfulfilled ?: ( ( value : T ) => T | PromiseLike < T > ) | null ,
126
+ onrejected ?: ( ( reason : any ) => T | PromiseLike < T > ) | null ,
127
+ ) => Promise < T > ;
128
+ }
124
129
125
130
const instrumented = new Map ( ) ;
126
131
@@ -289,32 +294,11 @@ function instrumentPostgrestFilterBuilder(PostgrestFilterBuilder: PostgrestFilte
289
294
}
290
295
291
296
instrumented . set ( PostgrestFilterBuilder , {
292
- then : (
293
- PostgrestFilterBuilder . prototype as unknown as {
294
- then : < T > (
295
- onfulfilled ?: ( ( value : T ) => T | PromiseLike < T > ) | null ,
296
- onrejected ?: ( ( reason : any ) => T | PromiseLike < T > ) | null ,
297
- ) => Promise < T > ;
298
- }
299
- ) . then ,
297
+ then : ( PostgrestFilterBuilder . prototype as unknown as PostgrestProtoThenable ) . then ,
300
298
} ) ;
301
299
302
- (
303
- PostgrestFilterBuilder . prototype as unknown as {
304
- then : < T > (
305
- onfulfilled ?: ( ( value : T ) => T | PromiseLike < T > ) | null ,
306
- onrejected ?: ( ( reason : any ) => T | PromiseLike < T > ) | null ,
307
- ) => Promise < T > ;
308
- }
309
- ) . then = new Proxy (
310
- (
311
- PostgrestFilterBuilder . prototype as unknown as {
312
- then : < T > (
313
- onfulfilled ?: ( ( value : T ) => T | PromiseLike < T > ) | null ,
314
- onrejected ?: ( ( reason : any ) => T | PromiseLike < T > ) | null ,
315
- ) => Promise < T > ;
316
- }
317
- ) . then ,
300
+ ( PostgrestFilterBuilder . prototype as unknown as PostgrestProtoThenable ) . then = new Proxy (
301
+ ( PostgrestFilterBuilder . prototype as unknown as PostgrestProtoThenable ) . then ,
318
302
{
319
303
apply ( target , thisArg , argumentsList ) {
320
304
const operations = AVAILABLE_OPERATIONS ;
0 commit comments