@supabase/postgrest-js 2.100.0 → 2.100.1
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/dist/index.cjs +4 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -17
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +7 -17
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/PostgrestBuilder.ts +3 -10
- package/src/PostgrestClient.ts +1 -1
- package/src/PostgrestFilterBuilder.ts +20 -11
- package/src/PostgrestQueryBuilder.ts +1 -11
- package/src/PostgrestTransformBuilder.ts +2 -7
- package/src/select-query-parser/utils.ts +9 -7
- package/src/version.ts +1 -1
package/package.json
CHANGED
package/src/PostgrestBuilder.ts
CHANGED
|
@@ -44,7 +44,7 @@ export default abstract class PostgrestBuilder<
|
|
|
44
44
|
*
|
|
45
45
|
* @category Database
|
|
46
46
|
*
|
|
47
|
-
* @example
|
|
47
|
+
* @example Creating a Postgrest query builder
|
|
48
48
|
* ```ts
|
|
49
49
|
* import { PostgrestQueryBuilder } from '@supabase/postgrest-js'
|
|
50
50
|
*
|
|
@@ -176,9 +176,8 @@ export default abstract class PostgrestBuilder<
|
|
|
176
176
|
count = parseInt(contentRange[1])
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
if (this.isMaybeSingle && this.method === 'GET' && Array.isArray(data)) {
|
|
179
|
+
// Fix for https://github.com/supabase/postgrest-js/issues/361 — applies to all methods.
|
|
180
|
+
if (this.isMaybeSingle && Array.isArray(data)) {
|
|
182
181
|
if (data.length > 1) {
|
|
183
182
|
error = {
|
|
184
183
|
// https://github.com/PostgREST/postgrest/blob/a867d79c42419af16c18c3fb019eba8df992626f/src/PostgREST/Error.hs#L553
|
|
@@ -222,12 +221,6 @@ export default abstract class PostgrestBuilder<
|
|
|
222
221
|
}
|
|
223
222
|
}
|
|
224
223
|
|
|
225
|
-
if (error && this.isMaybeSingle && error?.details?.includes('0 rows')) {
|
|
226
|
-
error = null
|
|
227
|
-
status = 200
|
|
228
|
-
statusText = 'OK'
|
|
229
|
-
}
|
|
230
|
-
|
|
231
224
|
if (error && this.shouldThrowOnError) {
|
|
232
225
|
throw new PostgrestError(error)
|
|
233
226
|
}
|
package/src/PostgrestClient.ts
CHANGED
|
@@ -68,7 +68,7 @@ export default class PostgrestClient<
|
|
|
68
68
|
* - A `timeout` option (in milliseconds) can be set to automatically abort requests that take too long.
|
|
69
69
|
* - A `urlLengthLimit` option (default: 8000) can be set to control when URL length warnings are included in error messages for aborted requests.
|
|
70
70
|
*
|
|
71
|
-
* @example
|
|
71
|
+
* @example Creating a Postgrest client
|
|
72
72
|
* ```ts
|
|
73
73
|
* import { PostgrestClient } from '@supabase/postgrest-js'
|
|
74
74
|
*
|
|
@@ -139,17 +139,20 @@ export default class PostgrestFilterBuilder<
|
|
|
139
139
|
* ```
|
|
140
140
|
*/
|
|
141
141
|
eq<ColumnName extends string>(
|
|
142
|
-
column: ColumnName
|
|
142
|
+
column: ColumnName extends keyof Row
|
|
143
|
+
? ColumnName
|
|
144
|
+
: ColumnName extends `${string}.${string}` | `${string}->${string}`
|
|
145
|
+
? ColumnName
|
|
146
|
+
: string extends ColumnName
|
|
147
|
+
? string
|
|
148
|
+
: keyof Row,
|
|
143
149
|
value: ResolveFilterValue<Schema, Row, ColumnName> extends never
|
|
144
150
|
? NonNullable<unknown>
|
|
145
|
-
:
|
|
146
|
-
// type resolution error
|
|
147
|
-
ResolveFilterValue<Schema, Row, ColumnName> extends infer ResolvedFilterValue
|
|
151
|
+
: ResolveFilterValue<Schema, Row, ColumnName> extends infer ResolvedFilterValue
|
|
148
152
|
? NonNullable<ResolvedFilterValue>
|
|
149
|
-
:
|
|
150
|
-
never
|
|
153
|
+
: never
|
|
151
154
|
): this {
|
|
152
|
-
this.url.searchParams.append(column, `eq.${value}`)
|
|
155
|
+
this.url.searchParams.append(column as string, `eq.${value}`)
|
|
153
156
|
return this
|
|
154
157
|
}
|
|
155
158
|
|
|
@@ -201,14 +204,20 @@ export default class PostgrestFilterBuilder<
|
|
|
201
204
|
* ```
|
|
202
205
|
*/
|
|
203
206
|
neq<ColumnName extends string>(
|
|
204
|
-
column: ColumnName
|
|
207
|
+
column: ColumnName extends keyof Row
|
|
208
|
+
? ColumnName
|
|
209
|
+
: ColumnName extends `${string}.${string}` | `${string}->${string}`
|
|
210
|
+
? ColumnName
|
|
211
|
+
: string extends ColumnName
|
|
212
|
+
? string
|
|
213
|
+
: keyof Row,
|
|
205
214
|
value: ResolveFilterValue<Schema, Row, ColumnName> extends never
|
|
206
215
|
? unknown
|
|
207
|
-
: ResolveFilterValue<Schema, Row, ColumnName> extends infer
|
|
208
|
-
?
|
|
216
|
+
: ResolveFilterValue<Schema, Row, ColumnName> extends infer Resolved
|
|
217
|
+
? Resolved
|
|
209
218
|
: never
|
|
210
219
|
): this {
|
|
211
|
-
this.url.searchParams.append(column, `neq.${value}`)
|
|
220
|
+
this.url.searchParams.append(column as string, `neq.${value}`)
|
|
212
221
|
return this
|
|
213
222
|
}
|
|
214
223
|
|
|
@@ -25,19 +25,9 @@ export default class PostgrestQueryBuilder<
|
|
|
25
25
|
/**
|
|
26
26
|
* Creates a query builder scoped to a Postgres table or view.
|
|
27
27
|
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* import { PostgrestQueryBuilder } from '@supabase/postgrest-js'
|
|
31
|
-
*
|
|
32
|
-
* const query = new PostgrestQueryBuilder(
|
|
33
|
-
* new URL('https://xyzcompany.supabase.co/rest/v1/users'),
|
|
34
|
-
* { headers: { apikey: 'public-anon-key' } }
|
|
35
|
-
* )
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
28
|
* @category Database
|
|
39
29
|
*
|
|
40
|
-
* @example
|
|
30
|
+
* @example Creating a Postgrest query builder
|
|
41
31
|
* ```ts
|
|
42
32
|
* import { PostgrestQueryBuilder } from '@supabase/postgrest-js'
|
|
43
33
|
*
|
|
@@ -685,13 +685,8 @@ export default class PostgrestTransformBuilder<
|
|
|
685
685
|
maybeSingle<
|
|
686
686
|
ResultOne = Result extends (infer ResultOne)[] ? ResultOne : never,
|
|
687
687
|
>(): PostgrestBuilder<ClientOptions, ResultOne | null> {
|
|
688
|
-
//
|
|
689
|
-
//
|
|
690
|
-
if (this.method === 'GET') {
|
|
691
|
-
this.headers.set('Accept', 'application/json')
|
|
692
|
-
} else {
|
|
693
|
-
this.headers.set('Accept', 'application/vnd.pgrst.object+json')
|
|
694
|
-
}
|
|
688
|
+
// No Accept header override — we fetch as a list and enforce cardinality client-side.
|
|
689
|
+
// Fixes https://github.com/supabase/postgrest-js/issues/361 for all request methods.
|
|
695
690
|
this.isMaybeSingle = true
|
|
696
691
|
return this as unknown as PostgrestBuilder<ClientOptions, ResultOne | null>
|
|
697
692
|
}
|
|
@@ -498,7 +498,7 @@ export type ResolveForwardRelationship<
|
|
|
498
498
|
* Given a CurrentTableOrView, finds all join tables to this relation.
|
|
499
499
|
* For example, if products and categories are linked via product_categories table:
|
|
500
500
|
*
|
|
501
|
-
* @example
|
|
501
|
+
* @example Find join table relationship
|
|
502
502
|
* Given:
|
|
503
503
|
* - CurrentTableView = 'products'
|
|
504
504
|
* - FieldName = "categories"
|
|
@@ -656,12 +656,14 @@ type ComputedField<
|
|
|
656
656
|
RelationName extends keyof TablesAndViews<Schema>,
|
|
657
657
|
FieldName extends keyof TablesAndViews<Schema>[RelationName]['Row'],
|
|
658
658
|
> = FieldName extends keyof Schema['Functions']
|
|
659
|
-
? Schema['Functions'][FieldName] extends
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
659
|
+
? [Schema['Functions'][FieldName]['Args']] extends [never]
|
|
660
|
+
? never
|
|
661
|
+
: Schema['Functions'][FieldName] extends {
|
|
662
|
+
Args: { '': TablesAndViews<Schema>[RelationName]['Row'] }
|
|
663
|
+
Returns: any
|
|
664
|
+
}
|
|
665
|
+
? FieldName
|
|
666
|
+
: never
|
|
665
667
|
: never
|
|
666
668
|
|
|
667
669
|
// Given a relation name (Table or View) extract all the "computed fields" based on the Row
|
package/src/version.ts
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
// - Debugging and support (identifying which version is running)
|
|
5
5
|
// - Telemetry and logging (version reporting in errors/analytics)
|
|
6
6
|
// - Ensuring build artifacts match the published package version
|
|
7
|
-
export const version = '2.100.
|
|
7
|
+
export const version = '2.100.1'
|