Skip to content

Commit 0cbadf6

Browse files
chore(typegen): format
1 parent 5e5f558 commit 0cbadf6

File tree

3 files changed

+317
-299
lines changed

3 files changed

+317
-299
lines changed

src/lib/generators.ts

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
1-
import PostgresMeta from "./PostgresMeta.js";
2-
import { PostgresColumn, PostgresFunction, PostgresMaterializedView, PostgresRelationship, PostgresSchema, PostgresTable, PostgresType, PostgresView } from "./types.js";
3-
import { PostgresMetaResult } from "./types.js";
1+
import PostgresMeta from './PostgresMeta.js'
2+
import {
3+
PostgresColumn,
4+
PostgresFunction,
5+
PostgresMaterializedView,
6+
PostgresRelationship,
7+
PostgresSchema,
8+
PostgresTable,
9+
PostgresType,
10+
PostgresView,
11+
} from './types.js'
12+
import { PostgresMetaResult } from './types.js'
413

514
export type GeneratorMetadata = {
6-
schemas: PostgresSchema[];
7-
tables: Omit<PostgresTable, 'columns'>[];
8-
views: Omit<PostgresView, 'columns'>[];
9-
materializedViews: Omit<PostgresMaterializedView, 'columns'>[];
10-
columns: PostgresColumn[];
11-
relationships: PostgresRelationship[];
12-
functions: PostgresFunction[];
13-
types: PostgresType[];
14-
arrayTypes: PostgresType[];
15+
schemas: PostgresSchema[]
16+
tables: Omit<PostgresTable, 'columns'>[]
17+
views: Omit<PostgresView, 'columns'>[]
18+
materializedViews: Omit<PostgresMaterializedView, 'columns'>[]
19+
columns: PostgresColumn[]
20+
relationships: PostgresRelationship[]
21+
functions: PostgresFunction[]
22+
types: PostgresType[]
23+
arrayTypes: PostgresType[]
1524
}
1625

17-
export async function getGeneratorMetadata(pgMeta: PostgresMeta, filters: { includedSchemas?: string[]; excludedSchemas?: string[] } = { includedSchemas: [], excludedSchemas: [] }): Promise<PostgresMetaResult<GeneratorMetadata>> {
26+
export async function getGeneratorMetadata(
27+
pgMeta: PostgresMeta,
28+
filters: { includedSchemas?: string[]; excludedSchemas?: string[] } = {
29+
includedSchemas: [],
30+
excludedSchemas: [],
31+
}
32+
): Promise<PostgresMetaResult<GeneratorMetadata>> {
1833
const includedSchemas = filters.includedSchemas ?? []
1934
const excludedSchemas = filters.excludedSchemas ?? []
2035

@@ -90,8 +105,7 @@ export async function getGeneratorMetadata(pgMeta: PostgresMeta, filters: { incl
90105
schemas: schemas.filter(
91106
({ name }) =>
92107
!excludedSchemas.includes(name) &&
93-
(includedSchemas.length === 0 || includedSchemas.includes(name)
94-
)
108+
(includedSchemas.length === 0 || includedSchemas.includes(name))
95109
),
96110
tables,
97111
views,

src/server/routes/generators/typescript.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@ export default async (fastify: FastifyInstance) => {
2222
const detectOneToOneRelationships = request.query.detect_one_to_one_relationships === 'true'
2323

2424
const pgMeta: PostgresMeta = new PostgresMeta({ ...DEFAULT_POOL_CONFIG, connectionString })
25-
const { data: generatorMeta, error: generatorMetaError } = await getGeneratorMetadata(
26-
pgMeta,
27-
{
28-
includedSchemas,
29-
excludedSchemas
30-
},
31-
)
25+
const { data: generatorMeta, error: generatorMetaError } = await getGeneratorMetadata(pgMeta, {
26+
includedSchemas,
27+
excludedSchemas,
28+
})
3229
if (generatorMetaError) {
3330
request.log.error({ error: generatorMetaError, request: extractRequestForLogging(request) })
3431
reply.code(500)

0 commit comments

Comments
 (0)