@@ -118,6 +118,9 @@ type EatWhitespace<Input extends string> = string extends Input
118
118
? EatWhitespace < Remainder >
119
119
: Input
120
120
121
+ /**
122
+ * Returns a boolean representing whether there is a foreign key with the given name.
123
+ */
121
124
type HasFKey < FKeyName , Relationships > = Relationships extends [ infer R ]
122
125
? R extends { foreignKeyName : FKeyName }
123
126
? true
@@ -128,6 +131,9 @@ type HasFKey<FKeyName, Relationships> = Relationships extends [infer R]
128
131
: HasFKey < FKeyName , Rest >
129
132
: false
130
133
134
+ /**
135
+ * Returns a boolean representing whether there the foreign key has a unique constraint.
136
+ */
131
137
type HasUniqueFKey < FKeyName , Relationships > = Relationships extends [ infer R ]
132
138
? R extends { foreignKeyName : FKeyName ; isOneToOne : true }
133
139
? true
@@ -138,6 +144,10 @@ type HasUniqueFKey<FKeyName, Relationships> = Relationships extends [infer R]
138
144
: HasUniqueFKey < FKeyName , Rest >
139
145
: false
140
146
147
+ /**
148
+ * Returns a boolean representing whether there is a foreign key referencing
149
+ * a given relation.
150
+ */
141
151
type HasFKeyToFRel < FRelName , Relationships > = Relationships extends [ infer R ]
142
152
? R extends { referencedRelation : FRelName }
143
153
? true
@@ -161,8 +171,9 @@ type HasUniqueFKeyToFRel<FRelName, Relationships> = Relationships extends [infer
161
171
/**
162
172
* Constructs a type definition for a single field of an object.
163
173
*
164
- * @param Definitions Record of definitions, possibly generated from PostgREST's OpenAPI spec.
165
- * @param Name Name of the table being queried.
174
+ * @param Schema Database schema.
175
+ * @param Row Type of a row in the given table.
176
+ * @param Relationships Relationships between different tables in the database.
166
177
* @param Field Single field parsed by `ParseQuery`.
167
178
*/
168
179
type ConstructFieldDefinition <
@@ -246,8 +257,7 @@ type ConstructFieldDefinition<
246
257
*/
247
258
248
259
/**
249
- * Reads a consecutive sequence of more than 1 letter,
250
- * where letters are `[0-9a-zA-Z_]`.
260
+ * Reads a consecutive sequence of 1 or more letter, where letters are `[0-9a-zA-Z_]`.
251
261
*/
252
262
type ReadLetters < Input extends string > = string extends Input
253
263
? GenericStringError
@@ -266,7 +276,7 @@ type ReadLettersHelper<Input extends string, Acc extends string> = string extend
266
276
: [ Acc , '' ]
267
277
268
278
/**
269
- * Reads a consecutive sequence of more than 1 double-quoted letters,
279
+ * Reads a consecutive sequence of 1 or more double-quoted letters,
270
280
* where letters are `[^"]`.
271
281
*/
272
282
type ReadQuotedLetters < Input extends string > = string extends Input
@@ -289,7 +299,7 @@ type ReadQuotedLettersHelper<Input extends string, Acc extends string> = string
289
299
290
300
/**
291
301
* Parses a (possibly double-quoted) identifier.
292
- * For now, identifiers are just sequences of more than 1 letter .
302
+ * Identifiers are sequences of 1 or more letters .
293
303
*/
294
304
type ParseIdentifier < Input extends string > = ReadLetters < Input > extends [
295
305
infer Name ,
@@ -560,7 +570,9 @@ type GetResultHelper<
560
570
/**
561
571
* Constructs a type definition for an object based on a given PostgREST query.
562
572
*
563
- * @param Row Record<string, unknown>.
573
+ * @param Schema Database schema.
574
+ * @param Row Type of a row in the given table.
575
+ * @param Relationships Relationships between different tables in the database.
564
576
* @param Query Select query string literal to parse.
565
577
*/
566
578
export type GetResult <
0 commit comments