Skip to content

Commit

Permalink
perf(generator): Rewrote most of the functionalities of the plugin.
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Removed the capacity to allow single schema file generation, removed relation fields entirely as they have no use in fastify.
  • Loading branch information
gelanderosh committed Jan 31, 2024
1 parent 25e6849 commit 23602c3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/generator/transformDMMF.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { DMMF } from '@prisma/generator-helper'
import type { JSONSchema7 } from 'json-schema'
import { DefinitionMap, TransformOptions } from './types'

import { DefinitionMap, ModelMetaData, TransformOptions } from './types'
import { getInitialJSON } from './jsonSchema'
import { getJSONSchemaModel } from './model'

Expand All @@ -10,14 +9,20 @@ export function transformDMMF(
transformOptions: TransformOptions = {},
): Array<[string, JSONSchema7]> {
// TODO: Remove default values as soon as prisma version < 3.10.0 doesn't have to be supported anymore
const { models = [], enums = [], types = [] } = dmmf.datamodel
const {
models = [],
enums = [],
types = [],
}: DMMF.Datamodel = dmmf.datamodel
const initialJSON = getInitialJSON()

const modelMetadata: {} = { enums }

const modelDefinitionsMap: DefinitionMap[] = models.map(
getJSONSchemaModel({ enums }, transformOptions),
getJSONSchemaModel(modelMetadata as ModelMetaData, transformOptions),
)
const typeDefinitionsMap: DefinitionMap[] = types.map(
getJSONSchemaModel({ enums }, transformOptions),
getJSONSchemaModel(modelMetadata as ModelMetaData, transformOptions),
)

const definitions: DefinitionMap[] = [
Expand Down

0 comments on commit 23602c3

Please sign in to comment.