@@ -8,6 +8,7 @@ import type {
8
8
PostgresView ,
9
9
} from '../../lib/index.js'
10
10
import type { GeneratorMetadata } from '../../lib/generators.js'
11
+ import { GENERATE_TYPES_DEFAULT_SCHEMA } from '../constants.js'
11
12
12
13
export const apply = async ( {
13
14
schemas,
@@ -390,98 +391,110 @@ export type Database = {
390
391
} ) }
391
392
}
392
393
393
- type PublicSchema = Database[Extract<keyof Database, "public" >]
394
+ type DefaultSchema = Database[Extract<keyof Database, ${ JSON . stringify ( GENERATE_TYPES_DEFAULT_SCHEMA ) } >]
394
395
395
396
export type Tables<
396
- PublicTableNameOrOptions extends
397
- | keyof (PublicSchema ["Tables"] & PublicSchema ["Views"])
397
+ DefaultSchemaTableNameOrOptions extends
398
+ | keyof (DefaultSchema ["Tables"] & DefaultSchema ["Views"])
398
399
| { schema: keyof Database },
399
- TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
400
- ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
401
- Database[PublicTableNameOrOptions["schema"]]["Views"])
402
- : never = never
403
- > = PublicTableNameOrOptions extends { schema: keyof Database }
404
- ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
405
- Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends {
400
+ TableName extends DefaultSchemaTableNameOrOptions extends {
401
+ schema: keyof Database
402
+ }
403
+ ? keyof (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
404
+ Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"])
405
+ : never = never,
406
+ > = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
407
+ ? (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
408
+ Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
406
409
Row: infer R
407
410
}
408
411
? R
409
412
: never
410
- : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] & PublicSchema["Views"])
411
- ? (PublicSchema["Tables"] & PublicSchema["Views"])[PublicTableNameOrOptions] extends {
413
+ : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] &
414
+ DefaultSchema["Views"])
415
+ ? (DefaultSchema["Tables"] &
416
+ DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends {
412
417
Row: infer R
413
418
}
414
419
? R
415
420
: never
416
421
: never
417
422
418
423
export type TablesInsert<
419
- PublicTableNameOrOptions extends
420
- | keyof PublicSchema ["Tables"]
424
+ DefaultSchemaTableNameOrOptions extends
425
+ | keyof DefaultSchema ["Tables"]
421
426
| { schema: keyof Database },
422
- TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
423
- ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
424
- : never = never
425
- > = PublicTableNameOrOptions extends { schema: keyof Database }
426
- ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
427
+ TableName extends DefaultSchemaTableNameOrOptions extends {
428
+ schema: keyof Database
429
+ }
430
+ ? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
431
+ : never = never,
432
+ > = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
433
+ ? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
427
434
Insert: infer I
428
435
}
429
436
? I
430
437
: never
431
- : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
432
- ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
433
- Insert: infer I
434
- }
435
- ? I
438
+ : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
439
+ ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
440
+ Insert: infer I
441
+ }
442
+ ? I
443
+ : never
436
444
: never
437
- : never
438
445
439
446
export type TablesUpdate<
440
- PublicTableNameOrOptions extends
441
- | keyof PublicSchema ["Tables"]
447
+ DefaultSchemaTableNameOrOptions extends
448
+ | keyof DefaultSchema ["Tables"]
442
449
| { schema: keyof Database },
443
- TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
444
- ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
445
- : never = never
446
- > = PublicTableNameOrOptions extends { schema: keyof Database }
447
- ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
450
+ TableName extends DefaultSchemaTableNameOrOptions extends {
451
+ schema: keyof Database
452
+ }
453
+ ? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
454
+ : never = never,
455
+ > = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
456
+ ? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
448
457
Update: infer U
449
458
}
450
459
? U
451
460
: never
452
- : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
453
- ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
454
- Update: infer U
455
- }
456
- ? U
461
+ : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
462
+ ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
463
+ Update: infer U
464
+ }
465
+ ? U
466
+ : never
457
467
: never
458
- : never
459
468
460
469
export type Enums<
461
- PublicEnumNameOrOptions extends
462
- | keyof PublicSchema ["Enums"]
470
+ DefaultSchemaEnumNameOrOptions extends
471
+ | keyof DefaultSchema ["Enums"]
463
472
| { schema: keyof Database },
464
- EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database }
465
- ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"]
466
- : never = never
467
- > = PublicEnumNameOrOptions extends { schema: keyof Database }
468
- ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName]
469
- : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"]
470
- ? PublicSchema["Enums"][PublicEnumNameOrOptions]
471
- : never
473
+ EnumName extends DefaultSchemaEnumNameOrOptions extends {
474
+ schema: keyof Database
475
+ }
476
+ ? keyof Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"]
477
+ : never = never,
478
+ > = DefaultSchemaEnumNameOrOptions extends { schema: keyof Database }
479
+ ? Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName]
480
+ : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"]
481
+ ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions]
482
+ : never
472
483
473
484
export type CompositeTypes<
474
485
PublicCompositeTypeNameOrOptions extends
475
- | keyof PublicSchema[' CompositeTypes' ]
486
+ | keyof DefaultSchema[" CompositeTypes" ]
476
487
| { schema: keyof Database },
477
- CompositeTypeName extends PublicCompositeTypeNameOrOptions extends { schema: keyof Database }
478
- ? keyof Database[PublicCompositeTypeNameOrOptions['schema']]['CompositeTypes']
479
- : never = never
488
+ CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
489
+ schema: keyof Database
490
+ }
491
+ ? keyof Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
492
+ : never = never,
480
493
> = PublicCompositeTypeNameOrOptions extends { schema: keyof Database }
481
- ? Database[PublicCompositeTypeNameOrOptions[' schema' ]][' CompositeTypes' ][CompositeTypeName]
482
- : PublicCompositeTypeNameOrOptions extends keyof PublicSchema[' CompositeTypes' ]
483
- ? PublicSchema[' CompositeTypes' ][PublicCompositeTypeNameOrOptions]
484
- : never;
494
+ ? Database[PublicCompositeTypeNameOrOptions[" schema" ]][" CompositeTypes" ][CompositeTypeName]
495
+ : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema[" CompositeTypes" ]
496
+ ? DefaultSchema[" CompositeTypes" ][PublicCompositeTypeNameOrOptions]
497
+ : never
485
498
`
486
499
487
500
output = await prettier . format ( output , {
0 commit comments