-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(typegen): add swift template (#779)
* feat(typegen): add swift template * test: add test case for table with identity other than id * update test snapshots * test: add public access control test case for swift generator * feat: generate materializedviews, views and composite types for swift * refactor swift typegen
- Loading branch information
Showing
9 changed files
with
1,283 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { FastifyInstance } from 'fastify' | ||
import { PostgresMeta } from '../../../lib/index.js' | ||
import { DEFAULT_POOL_CONFIG } from '../../constants.js' | ||
import { extractRequestForLogging } from '../../utils.js' | ||
import { apply as applySwiftTemplate, AccessControl } from '../../templates/swift.js' | ||
import { getGeneratorMetadata } from '../../../lib/generators.js' | ||
|
||
export default async (fastify: FastifyInstance) => { | ||
fastify.get<{ | ||
Headers: { pg: string } | ||
Querystring: { | ||
excluded_schemas?: string | ||
included_schemas?: string | ||
access_control?: AccessControl | ||
} | ||
}>('/', async (request, reply) => { | ||
const connectionString = request.headers.pg | ||
const excludedSchemas = | ||
request.query.excluded_schemas?.split(',').map((schema) => schema.trim()) ?? [] | ||
const includedSchemas = | ||
request.query.included_schemas?.split(',').map((schema) => schema.trim()) ?? [] | ||
const accessControl = request.query.access_control ?? 'internal' | ||
|
||
const pgMeta: PostgresMeta = new PostgresMeta({ ...DEFAULT_POOL_CONFIG, connectionString }) | ||
const { data: generatorMeta, error: generatorMetaError } = await getGeneratorMetadata(pgMeta, { | ||
includedSchemas, | ||
excludedSchemas, | ||
}) | ||
if (generatorMetaError) { | ||
request.log.error({ error: generatorMetaError, request: extractRequestForLogging(request) }) | ||
reply.code(500) | ||
return { error: generatorMetaError.message } | ||
} | ||
|
||
return applySwiftTemplate({ | ||
...generatorMeta, | ||
accessControl, | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.