Skip to content

Commit 23e3c98

Browse files
committed
Improve comments
1 parent 7eabd65 commit 23e3c98

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/select-query-parser.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ type EatWhitespace<Input extends string> = string extends Input
5656
? EatWhitespace<Remainder>
5757
: Input
5858

59+
/**
60+
* Returns a boolean representing whether there is a foreign key with the given name.
61+
*/
5962
type HasFKey<FKeyName, Relationships> = Relationships extends [infer R]
6063
? R extends { foreignKeyName: FKeyName }
6164
? true
@@ -66,6 +69,10 @@ type HasFKey<FKeyName, Relationships> = Relationships extends [infer R]
6669
: HasFKey<FKeyName, Rest>
6770
: false
6871

72+
/**
73+
* Returns a boolean representing whether there is a foreign key referencing
74+
* a given relation.
75+
*/
6976
type HasFKeyToFRel<FRelName, Relationships> = Relationships extends [infer R]
7077
? R extends { referencedRelation: FRelName }
7178
? true
@@ -79,8 +86,9 @@ type HasFKeyToFRel<FRelName, Relationships> = Relationships extends [infer R]
7986
/**
8087
* Constructs a type definition for a single field of an object.
8188
*
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.
8492
* @param Field Single field parsed by `ParseQuery`.
8593
*/
8694
type ConstructFieldDefinition<
@@ -141,8 +149,7 @@ type ConstructFieldDefinition<
141149
*/
142150

143151
/**
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_]`.
146153
*/
147154
type ReadLetters<Input extends string> = string extends Input
148155
? GenericStringError
@@ -161,7 +168,7 @@ type ReadLettersHelper<Input extends string, Acc extends string> = string extend
161168
: [Acc, '']
162169

163170
/**
164-
* Reads a consecutive sequence of more than 1 double-quoted letters,
171+
* Reads a consecutive sequence of 1 or more double-quoted letters,
165172
* where letters are `[^"]`.
166173
*/
167174
type ReadQuotedLetters<Input extends string> = string extends Input
@@ -184,7 +191,7 @@ type ReadQuotedLettersHelper<Input extends string, Acc extends string> = string
184191

185192
/**
186193
* 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.
188195
*/
189196
type ParseIdentifier<Input extends string> = ReadLetters<Input> extends [
190197
infer Name,
@@ -432,7 +439,9 @@ type GetResultHelper<
432439
/**
433440
* Constructs a type definition for an object based on a given PostgREST query.
434441
*
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.
436445
* @param Query Select query string literal to parse.
437446
*/
438447
export type GetResult<

0 commit comments

Comments
 (0)