@@ -56,6 +56,9 @@ type EatWhitespace<Input extends string> = string extends Input
56
56
? EatWhitespace < Remainder >
57
57
: Input
58
58
59
+ /**
60
+ * Returns a boolean representing whether there is a foreign key with the given name.
61
+ */
59
62
type HasFKey < FKeyName , Relationships > = Relationships extends [ infer R ]
60
63
? R extends { foreignKeyName : FKeyName }
61
64
? true
@@ -66,6 +69,10 @@ type HasFKey<FKeyName, Relationships> = Relationships extends [infer R]
66
69
: HasFKey < FKeyName , Rest >
67
70
: false
68
71
72
+ /**
73
+ * Returns a boolean representing whether there is a foreign key referencing
74
+ * a given relation.
75
+ */
69
76
type HasFKeyToFRel < FRelName , Relationships > = Relationships extends [ infer R ]
70
77
? R extends { referencedRelation : FRelName }
71
78
? true
@@ -79,8 +86,9 @@ type HasFKeyToFRel<FRelName, Relationships> = Relationships extends [infer R]
79
86
/**
80
87
* Constructs a type definition for a single field of an object.
81
88
*
82
- * @param Definitions Record of definitions, possibly generated from PostgREST's OpenAPI spec.
83
- * @param Name Name of the table being queried.
89
+ * @param Schema Database schema.
90
+ * @param Row Type of a row in the given table.
91
+ * @param Relationships Relationships between different tables in the database.
84
92
* @param Field Single field parsed by `ParseQuery`.
85
93
*/
86
94
type ConstructFieldDefinition <
@@ -141,8 +149,7 @@ type ConstructFieldDefinition<
141
149
*/
142
150
143
151
/**
144
- * Reads a consecutive sequence of more than 1 letter,
145
- * where letters are `[0-9a-zA-Z_]`.
152
+ * Reads a consecutive sequence of 1 or more letter, where letters are `[0-9a-zA-Z_]`.
146
153
*/
147
154
type ReadLetters < Input extends string > = string extends Input
148
155
? GenericStringError
@@ -161,7 +168,7 @@ type ReadLettersHelper<Input extends string, Acc extends string> = string extend
161
168
: [ Acc , '' ]
162
169
163
170
/**
164
- * Reads a consecutive sequence of more than 1 double-quoted letters,
171
+ * Reads a consecutive sequence of 1 or more double-quoted letters,
165
172
* where letters are `[^"]`.
166
173
*/
167
174
type ReadQuotedLetters < Input extends string > = string extends Input
@@ -184,7 +191,7 @@ type ReadQuotedLettersHelper<Input extends string, Acc extends string> = string
184
191
185
192
/**
186
193
* Parses a (possibly double-quoted) identifier.
187
- * For now, identifiers are just sequences of more than 1 letter .
194
+ * Identifiers are sequences of 1 or more letters .
188
195
*/
189
196
type ParseIdentifier < Input extends string > = ReadLetters < Input > extends [
190
197
infer Name ,
@@ -432,7 +439,9 @@ type GetResultHelper<
432
439
/**
433
440
* Constructs a type definition for an object based on a given PostgREST query.
434
441
*
435
- * @param Row Record<string, unknown>.
442
+ * @param Schema Database schema.
443
+ * @param Row Type of a row in the given table.
444
+ * @param Relationships Relationships between different tables in the database.
436
445
* @param Query Select query string literal to parse.
437
446
*/
438
447
export type GetResult <
0 commit comments