Skip to content

Commit a6b9015

Browse files
committed
fix(typegen): exclude event trigger functions
1 parent 4f24341 commit a6b9015

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/server/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ if (EXPORT_DOCS) {
9292
GENERATE_TYPES_INCLUDED_SCHEMAS.includes(name)
9393
),
9494
tables,
95-
functions,
95+
functions: functions.filter((f) => !['trigger', 'event_trigger'].includes(f.return_type)),
9696
types,
9797
})
9898
)

src/server/routes/generators/typescript.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default async (fastify: FastifyInstance) => {
5555
(includedSchemas.length === 0 || includedSchemas.includes(name))
5656
),
5757
tables,
58-
functions,
58+
functions: functions.filter((f) => !['trigger', 'event_trigger'].includes(f.return_type)),
5959
types,
6060
})
6161
})

src/server/templates/typescript.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,15 @@ export interface Database {
8181
}
8282
Functions: {
8383
${functions
84-
.filter(
85-
(function_) =>
86-
function_.schema === schema.name && function_.return_type !== 'trigger'
87-
)
84+
.filter((func) => func.schema === schema.name)
8885
.map(
89-
(function_) => `${JSON.stringify(function_.name)}: {
86+
(func) => `${JSON.stringify(func.name)}: {
9087
Args: ${(() => {
91-
if (function_.argument_types === '') {
88+
if (func.argument_types === '') {
9289
return 'Record<PropertyKey, never>'
9390
}
9491
95-
const splitArgs = function_.argument_types.split(',').map((arg) => arg.trim())
92+
const splitArgs = func.argument_types.split(',').map((arg) => arg.trim())
9693
if (splitArgs.some((arg) => arg.includes('"') || !arg.includes(' '))) {
9794
return 'Record<string, unknown>'
9895
}
@@ -110,7 +107,7 @@ export interface Database {
110107
({ name, type }) => `${JSON.stringify(name)}: ${type}`
111108
)} }`
112109
})()}
113-
Returns: ${pgTypeToTsType(function_.return_type, types)}
110+
Returns: ${pgTypeToTsType(func.return_type, types)}
114111
}`
115112
)}
116113
}

0 commit comments

Comments
 (0)