@@ -24,31 +24,41 @@ export const apply = ({
24
24
export type Json = string | number | boolean | null | { [key: string]: Json } | Json[]
25
25
26
26
export interface Database {
27
- ${ schemas . map ( ( schema ) => {
28
- const schemaTables = tables . filter ( ( table ) => table . schema === schema . name )
29
- const schemaViews = views . filter ( ( view ) => view . schema === schema . name )
30
- const schemaFunctions = functions . filter ( ( func ) => {
31
- if ( func . schema !== schema . name ) {
32
- return false
33
- }
27
+ ${ schemas
28
+ . sort ( ( { name : a } , { name : b } ) => a . localeCompare ( b ) )
29
+ . map ( ( schema ) => {
30
+ const schemaTables = tables
31
+ . filter ( ( table ) => table . schema === schema . name )
32
+ . sort ( ( { name : a } , { name : b } ) => a . localeCompare ( b ) )
33
+ const schemaViews = views
34
+ . filter ( ( view ) => view . schema === schema . name )
35
+ . sort ( ( { name : a } , { name : b } ) => a . localeCompare ( b ) )
36
+ const schemaFunctions = functions
37
+ . filter ( ( func ) => {
38
+ if ( func . schema !== schema . name ) {
39
+ return false
40
+ }
34
41
35
- // Either:
36
- // 1. All input args are be named, or
37
- // 2. There is only one input arg which is unnamed
38
- const inArgs = func . args . filter ( ( { mode } ) => [ 'in' , 'inout' , 'variadic' ] . includes ( mode ) )
42
+ // Either:
43
+ // 1. All input args are be named, or
44
+ // 2. There is only one input arg which is unnamed
45
+ const inArgs = func . args . filter ( ( { mode } ) => [ 'in' , 'inout' , 'variadic' ] . includes ( mode ) )
39
46
40
- if ( ! inArgs . some ( ( { name } ) => name === '' ) ) {
41
- return true
42
- }
47
+ if ( ! inArgs . some ( ( { name } ) => name === '' ) ) {
48
+ return true
49
+ }
43
50
44
- if ( inArgs . length === 1 ) {
45
- return true
46
- }
51
+ if ( inArgs . length === 1 ) {
52
+ return true
53
+ }
47
54
48
- return false
49
- } )
50
- const schemaEnums = types . filter ( ( type ) => type . schema === schema . name && type . enums . length > 0 )
51
- return `${ JSON . stringify ( schema . name ) } : {
55
+ return false
56
+ } )
57
+ . sort ( ( { name : a } , { name : b } ) => a . localeCompare ( b ) )
58
+ const schemaEnums = types
59
+ . filter ( ( type ) => type . schema === schema . name && type . enums . length > 0 )
60
+ . sort ( ( { name : a } , { name : b } ) => a . localeCompare ( b ) )
61
+ return `${ JSON . stringify ( schema . name ) } : {
52
62
Tables: {
53
63
${
54
64
schemaTables . length === 0
@@ -235,7 +245,7 @@ export interface Database {
235
245
}
236
246
}
237
247
}`
238
- } ) }
248
+ } ) }
239
249
}`
240
250
241
251
output = prettier . format ( output , {
0 commit comments