@supabase/postgrest-js 1.8.5 → 1.9.0
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/main/PostgrestClient.d.ts +3 -3
- package/dist/main/PostgrestClient.d.ts.map +1 -1
- package/dist/main/PostgrestClient.js.map +1 -1
- package/dist/main/PostgrestFilterBuilder.d.ts +7 -4
- package/dist/main/PostgrestFilterBuilder.d.ts.map +1 -1
- package/dist/main/PostgrestFilterBuilder.js +6 -4
- package/dist/main/PostgrestFilterBuilder.js.map +1 -1
- package/dist/main/PostgrestQueryBuilder.d.ts +9 -9
- package/dist/main/PostgrestQueryBuilder.d.ts.map +1 -1
- package/dist/main/PostgrestQueryBuilder.js.map +1 -1
- package/dist/main/PostgrestTransformBuilder.d.ts +31 -9
- package/dist/main/PostgrestTransformBuilder.d.ts.map +1 -1
- package/dist/main/PostgrestTransformBuilder.js +23 -16
- package/dist/main/PostgrestTransformBuilder.js.map +1 -1
- package/dist/main/select-query-parser.d.ts +20 -8
- package/dist/main/select-query-parser.d.ts.map +1 -1
- package/dist/main/version.d.ts +1 -1
- package/dist/main/version.js +1 -1
- package/dist/module/PostgrestClient.d.ts +3 -3
- package/dist/module/PostgrestClient.d.ts.map +1 -1
- package/dist/module/PostgrestClient.js.map +1 -1
- package/dist/module/PostgrestFilterBuilder.d.ts +7 -4
- package/dist/module/PostgrestFilterBuilder.d.ts.map +1 -1
- package/dist/module/PostgrestFilterBuilder.js +6 -4
- package/dist/module/PostgrestFilterBuilder.js.map +1 -1
- package/dist/module/PostgrestQueryBuilder.d.ts +9 -9
- package/dist/module/PostgrestQueryBuilder.d.ts.map +1 -1
- package/dist/module/PostgrestQueryBuilder.js.map +1 -1
- package/dist/module/PostgrestTransformBuilder.d.ts +31 -9
- package/dist/module/PostgrestTransformBuilder.d.ts.map +1 -1
- package/dist/module/PostgrestTransformBuilder.js +23 -16
- package/dist/module/PostgrestTransformBuilder.js.map +1 -1
- package/dist/module/select-query-parser.d.ts +20 -8
- package/dist/module/select-query-parser.d.ts.map +1 -1
- package/dist/module/version.d.ts +1 -1
- package/dist/module/version.js +1 -1
- package/package.json +1 -1
- package/src/PostgrestClient.ts +6 -10
- package/src/PostgrestFilterBuilder.ts +14 -5
- package/src/PostgrestQueryBuilder.ts +11 -10
- package/src/PostgrestTransformBuilder.ts +83 -21
- package/src/select-query-parser.ts +58 -17
- package/src/version.ts +1 -1
|
@@ -40,16 +40,6 @@ type Letter = Alphabet | Digit | '_'
|
|
|
40
40
|
|
|
41
41
|
type Json = string | number | boolean | null | { [key: string]: Json } | Json[]
|
|
42
42
|
|
|
43
|
-
// /**
|
|
44
|
-
// * Parsed node types.
|
|
45
|
-
// * Currently only `*` and all other fields.
|
|
46
|
-
// */
|
|
47
|
-
// type ParsedNode =
|
|
48
|
-
// | { star: true }
|
|
49
|
-
// | { name: string; original: string }
|
|
50
|
-
// | { name: string; foreignTable: true }
|
|
51
|
-
// | { name: string; type: T };
|
|
52
|
-
|
|
53
43
|
/**
|
|
54
44
|
* Parser errors.
|
|
55
45
|
*/
|
|
@@ -76,6 +66,16 @@ type HasFKey<FKeyName, Relationships> = Relationships extends [infer R]
|
|
|
76
66
|
: HasFKey<FKeyName, Rest>
|
|
77
67
|
: false
|
|
78
68
|
|
|
69
|
+
type HasUniqueFKey<FKeyName, Relationships> = Relationships extends [infer R]
|
|
70
|
+
? R extends { foreignKeyName: FKeyName; isOneToOne: true }
|
|
71
|
+
? true
|
|
72
|
+
: false
|
|
73
|
+
: Relationships extends [infer R, ...infer Rest]
|
|
74
|
+
? HasUniqueFKey<FKeyName, [R]> extends true
|
|
75
|
+
? true
|
|
76
|
+
: HasUniqueFKey<FKeyName, Rest>
|
|
77
|
+
: false
|
|
78
|
+
|
|
79
79
|
type HasFKeyToFRel<FRelName, Relationships> = Relationships extends [infer R]
|
|
80
80
|
? R extends { referencedRelation: FRelName }
|
|
81
81
|
? true
|
|
@@ -86,6 +86,16 @@ type HasFKeyToFRel<FRelName, Relationships> = Relationships extends [infer R]
|
|
|
86
86
|
: HasFKeyToFRel<FRelName, Rest>
|
|
87
87
|
: false
|
|
88
88
|
|
|
89
|
+
type HasUniqueFKeyToFRel<FRelName, Relationships> = Relationships extends [infer R]
|
|
90
|
+
? R extends { referencedRelation: FRelName; isOneToOne: true }
|
|
91
|
+
? true
|
|
92
|
+
: false
|
|
93
|
+
: Relationships extends [infer R, ...infer Rest]
|
|
94
|
+
? HasUniqueFKeyToFRel<FRelName, [R]> extends true
|
|
95
|
+
? true
|
|
96
|
+
: HasUniqueFKeyToFRel<FRelName, Rest>
|
|
97
|
+
: false
|
|
98
|
+
|
|
89
99
|
/**
|
|
90
100
|
* Constructs a type definition for a single field of an object.
|
|
91
101
|
*
|
|
@@ -96,6 +106,7 @@ type HasFKeyToFRel<FRelName, Relationships> = Relationships extends [infer R]
|
|
|
96
106
|
type ConstructFieldDefinition<
|
|
97
107
|
Schema extends GenericSchema,
|
|
98
108
|
Row extends Record<string, unknown>,
|
|
109
|
+
RelationName,
|
|
99
110
|
Relationships,
|
|
100
111
|
Field
|
|
101
112
|
> = Field extends { star: true }
|
|
@@ -105,13 +116,24 @@ type ConstructFieldDefinition<
|
|
|
105
116
|
[_ in Field['name']]: GetResultHelper<
|
|
106
117
|
Schema,
|
|
107
118
|
(Schema['Tables'] & Schema['Views'])[Field['original']]['Row'],
|
|
119
|
+
Field['original'],
|
|
108
120
|
(Schema['Tables'] & Schema['Views'])[Field['original']] extends { Relationships: infer R }
|
|
109
121
|
? R
|
|
110
122
|
: unknown,
|
|
111
123
|
Field['children'],
|
|
112
124
|
unknown
|
|
113
125
|
> extends infer Child
|
|
114
|
-
?
|
|
126
|
+
? // One-to-one relationship - referencing column(s) has unique/pkey constraint.
|
|
127
|
+
HasUniqueFKey<
|
|
128
|
+
Field['hint'],
|
|
129
|
+
(Schema['Tables'] & Schema['Views'])[Field['original']] extends {
|
|
130
|
+
Relationships: infer R
|
|
131
|
+
}
|
|
132
|
+
? R
|
|
133
|
+
: unknown
|
|
134
|
+
> extends true
|
|
135
|
+
? Child | null
|
|
136
|
+
: Relationships extends unknown[]
|
|
115
137
|
? HasFKey<Field['hint'], Relationships> extends true
|
|
116
138
|
? Child | null
|
|
117
139
|
: Child[]
|
|
@@ -123,13 +145,24 @@ type ConstructFieldDefinition<
|
|
|
123
145
|
[_ in Field['name']]: GetResultHelper<
|
|
124
146
|
Schema,
|
|
125
147
|
(Schema['Tables'] & Schema['Views'])[Field['original']]['Row'],
|
|
148
|
+
Field['original'],
|
|
126
149
|
(Schema['Tables'] & Schema['Views'])[Field['original']] extends { Relationships: infer R }
|
|
127
150
|
? R
|
|
128
151
|
: unknown,
|
|
129
152
|
Field['children'],
|
|
130
153
|
unknown
|
|
131
154
|
> extends infer Child
|
|
132
|
-
?
|
|
155
|
+
? // One-to-one relationship - referencing column(s) has unique/pkey constraint.
|
|
156
|
+
HasUniqueFKeyToFRel<
|
|
157
|
+
RelationName,
|
|
158
|
+
(Schema['Tables'] & Schema['Views'])[Field['original']] extends {
|
|
159
|
+
Relationships: infer R
|
|
160
|
+
}
|
|
161
|
+
? R
|
|
162
|
+
: unknown
|
|
163
|
+
> extends true
|
|
164
|
+
? Child | null
|
|
165
|
+
: Relationships extends unknown[]
|
|
133
166
|
? HasFKeyToFRel<Field['original'], Relationships> extends true
|
|
134
167
|
? Child | null
|
|
135
168
|
: Child[]
|
|
@@ -414,28 +447,35 @@ type ParseQuery<Query extends string> = string extends Query
|
|
|
414
447
|
type GetResultHelper<
|
|
415
448
|
Schema extends GenericSchema,
|
|
416
449
|
Row extends Record<string, unknown>,
|
|
450
|
+
RelationName,
|
|
417
451
|
Relationships,
|
|
418
452
|
Fields extends unknown[],
|
|
419
453
|
Acc
|
|
420
454
|
> = Fields extends [infer R]
|
|
421
|
-
? ConstructFieldDefinition<Schema, Row, Relationships, R> extends SelectQueryError<
|
|
455
|
+
? ConstructFieldDefinition<Schema, Row, RelationName, Relationships, R> extends SelectQueryError<
|
|
456
|
+
infer E
|
|
457
|
+
>
|
|
422
458
|
? SelectQueryError<E>
|
|
423
459
|
: GetResultHelper<
|
|
424
460
|
Schema,
|
|
425
461
|
Row,
|
|
462
|
+
RelationName,
|
|
426
463
|
Relationships,
|
|
427
464
|
[],
|
|
428
|
-
ConstructFieldDefinition<Schema, Row, Relationships, R> & Acc
|
|
465
|
+
ConstructFieldDefinition<Schema, Row, RelationName, Relationships, R> & Acc
|
|
429
466
|
>
|
|
430
467
|
: Fields extends [infer R, ...infer Rest]
|
|
431
|
-
? ConstructFieldDefinition<Schema, Row, Relationships, R> extends SelectQueryError<
|
|
468
|
+
? ConstructFieldDefinition<Schema, Row, RelationName, Relationships, R> extends SelectQueryError<
|
|
469
|
+
infer E
|
|
470
|
+
>
|
|
432
471
|
? SelectQueryError<E>
|
|
433
472
|
: GetResultHelper<
|
|
434
473
|
Schema,
|
|
435
474
|
Row,
|
|
475
|
+
RelationName,
|
|
436
476
|
Relationships,
|
|
437
477
|
Rest,
|
|
438
|
-
ConstructFieldDefinition<Schema, Row, Relationships, R> & Acc
|
|
478
|
+
ConstructFieldDefinition<Schema, Row, RelationName, Relationships, R> & Acc
|
|
439
479
|
>
|
|
440
480
|
: Prettify<Acc>
|
|
441
481
|
|
|
@@ -448,8 +488,9 @@ type GetResultHelper<
|
|
|
448
488
|
export type GetResult<
|
|
449
489
|
Schema extends GenericSchema,
|
|
450
490
|
Row extends Record<string, unknown>,
|
|
491
|
+
RelationName,
|
|
451
492
|
Relationships,
|
|
452
493
|
Query extends string
|
|
453
494
|
> = ParseQuery<Query> extends unknown[]
|
|
454
|
-
? GetResultHelper<Schema, Row, Relationships, ParseQuery<Query>, unknown>
|
|
495
|
+
? GetResultHelper<Schema, Row, RelationName, Relationships, ParseQuery<Query>, unknown>
|
|
455
496
|
: ParseQuery<Query>
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.
|
|
1
|
+
export const version = '1.9.0'
|