@@ -37,36 +37,46 @@ if (EXPORT_DOCS) {
37
37
...DEFAULT_POOL_CONFIG ,
38
38
connectionString : PG_CONNECTION ,
39
39
} )
40
- const { data : schemas , error : schemasError } = await pgMeta . schemas . list ( )
41
- const { data : tables , error : tablesError } = await pgMeta . tables . list ( {
42
- includedSchemas :
43
- GENERATE_TYPES_INCLUDED_SCHEMAS . length > 0 ? GENERATE_TYPES_INCLUDED_SCHEMAS : undefined ,
44
- includeColumns : false ,
45
- } )
46
- const { data : views , error : viewsError } = await pgMeta . views . list ( {
47
- includedSchemas :
48
- GENERATE_TYPES_INCLUDED_SCHEMAS . length > 0 ? GENERATE_TYPES_INCLUDED_SCHEMAS : undefined ,
49
- includeColumns : false ,
50
- } )
51
- const { data : materializedViews , error : materializedViewsError } =
52
- await pgMeta . materializedViews . list ( {
40
+ const [
41
+ { data : schemas , error : schemasError } ,
42
+ { data : tables , error : tablesError } ,
43
+ { data : views , error : viewsError } ,
44
+ { data : materializedViews , error : materializedViewsError } ,
45
+ { data : columns , error : columnsError } ,
46
+ { data : relationships , error : relationshipsError } ,
47
+ { data : functions , error : functionsError } ,
48
+ { data : types , error : typesError } ,
49
+ ] = await Promise . all ( [
50
+ pgMeta . schemas . list ( ) ,
51
+ pgMeta . tables . list ( {
53
52
includedSchemas :
54
53
GENERATE_TYPES_INCLUDED_SCHEMAS . length > 0 ? GENERATE_TYPES_INCLUDED_SCHEMAS : undefined ,
55
54
includeColumns : false ,
56
- } )
57
- const { data : columns , error : columnsError } = await pgMeta . columns . list ( {
58
- includedSchemas :
59
- GENERATE_TYPES_INCLUDED_SCHEMAS . length > 0 ? GENERATE_TYPES_INCLUDED_SCHEMAS : undefined ,
60
- } )
61
- const { data : relationships , error : relationshipsError } = await pgMeta . relationships . list ( )
62
- const { data : functions , error : functionsError } = await pgMeta . functions . list ( {
63
- includedSchemas :
64
- GENERATE_TYPES_INCLUDED_SCHEMAS . length > 0 ? GENERATE_TYPES_INCLUDED_SCHEMAS : undefined ,
65
- } )
66
- const { data : types , error : typesError } = await pgMeta . types . list ( {
67
- includeArrayTypes : true ,
68
- includeSystemSchemas : true ,
69
- } )
55
+ } ) ,
56
+ pgMeta . views . list ( {
57
+ includedSchemas :
58
+ GENERATE_TYPES_INCLUDED_SCHEMAS . length > 0 ? GENERATE_TYPES_INCLUDED_SCHEMAS : undefined ,
59
+ includeColumns : false ,
60
+ } ) ,
61
+ pgMeta . materializedViews . list ( {
62
+ includedSchemas :
63
+ GENERATE_TYPES_INCLUDED_SCHEMAS . length > 0 ? GENERATE_TYPES_INCLUDED_SCHEMAS : undefined ,
64
+ includeColumns : false ,
65
+ } ) ,
66
+ pgMeta . columns . list ( {
67
+ includedSchemas :
68
+ GENERATE_TYPES_INCLUDED_SCHEMAS . length > 0 ? GENERATE_TYPES_INCLUDED_SCHEMAS : undefined ,
69
+ } ) ,
70
+ pgMeta . relationships . list ( ) ,
71
+ pgMeta . functions . list ( {
72
+ includedSchemas :
73
+ GENERATE_TYPES_INCLUDED_SCHEMAS . length > 0 ? GENERATE_TYPES_INCLUDED_SCHEMAS : undefined ,
74
+ } ) ,
75
+ pgMeta . types . list ( {
76
+ includeArrayTypes : true ,
77
+ includeSystemSchemas : true ,
78
+ } ) ,
79
+ ] )
70
80
await pgMeta . end ( )
71
81
72
82
if ( schemasError ) {
@@ -96,21 +106,21 @@ if (EXPORT_DOCS) {
96
106
97
107
console . log (
98
108
applyTypescriptTemplate ( {
99
- schemas : schemas . filter (
109
+ schemas : schemas ! . filter (
100
110
( { name } ) =>
101
111
GENERATE_TYPES_INCLUDED_SCHEMAS . length === 0 ||
102
112
GENERATE_TYPES_INCLUDED_SCHEMAS . includes ( name )
103
113
) ,
104
- tables,
105
- views,
106
- materializedViews,
107
- columns,
108
- relationships,
109
- functions : functions . filter (
114
+ tables : tables ! ,
115
+ views : views ! ,
116
+ materializedViews : materializedViews ! ,
117
+ columns : columns ! ,
118
+ relationships : relationships ! ,
119
+ functions : functions ! . filter (
110
120
( { return_type } ) => ! [ 'trigger' , 'event_trigger' ] . includes ( return_type )
111
121
) ,
112
- types : types . filter ( ( { name } ) => name [ 0 ] !== '_' ) ,
113
- arrayTypes : types . filter ( ( { name } ) => name [ 0 ] === '_' ) ,
122
+ types : types ! . filter ( ( { name } ) => name [ 0 ] !== '_' ) ,
123
+ arrayTypes : types ! . filter ( ( { name } ) => name [ 0 ] === '_' ) ,
114
124
detectOneToOneRelationships : GENERATE_TYPES_DETECT_ONE_TO_ONE_RELATIONSHIPS ,
115
125
} )
116
126
)
0 commit comments