Skip to content

Commit 0f84728

Browse files
committed
chore: Fix types
1 parent 35da088 commit 0f84728

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
"temp-dir": "2.X",
145145
"ts-node": "^10.9.2",
146146
"tslib": "^2.6.2",
147+
"type-fest": "^4.18.2",
147148
"typescript": "^5.4.5",
148149
"watchexec-bin": "^1.0.0"
149150
}

src/generate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { createConfig } from './helpers/create-config';
2222
import { factoryGetSourceFile } from './helpers/factory-get-source-file';
2323
import { createGetModelName } from './helpers/get-model-name';
2424
import {
25-
DMMF,
25+
Document,
2626
EventArguments,
2727
Field,
2828
Model,
@@ -107,7 +107,7 @@ export async function generate(
107107
outputFilePattern: config.outputFilePattern,
108108
eventEmitter,
109109
});
110-
const { datamodel, schema } = JSON.parse(JSON.stringify(dmmf)) as DMMF.Document;
110+
const { datamodel, schema } = JSON.parse(JSON.stringify(dmmf)) as Document;
111111
const removeTypes = new Set<string>();
112112
const eventArguments: EventArguments = {
113113
schema,

src/handlers/combine-scalar-filters.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import AwaitEventEmitter from 'await-event-emitter';
22
import { cloneDeep, keyBy, remove } from 'lodash';
33

44
import { BeforeGenerateField } from '../event-names';
5-
import { DMMF, EventArguments, InputType } from '../types';
5+
import { EventArguments, InputType, SchemaArg } from '../types';
66

77
/**
88
* Subscribes on 'BeforeInputType'
@@ -28,7 +28,7 @@ function beforeInputType(
2828
}
2929
}
3030

31-
function beforeGenerateField(field: DMMF.SchemaArg): void {
31+
function beforeGenerateField(field: SchemaArg): void {
3232
for (const fieldInput of field.inputTypes) {
3333
if (fieldInput.location !== 'inputObjectTypes') {
3434
continue;

src/handlers/model-data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createObjectSettings, ObjectSettings } from '../helpers/object-settings';
2-
import { DMMF, EventArguments, Field } from '../types';
2+
import { EventArguments, Field, Model } from '../types';
33

4-
export function modelData(model: DMMF.Model, args: EventArguments) {
4+
export function modelData(model: Model, args: EventArguments) {
55
const {
66
config,
77
modelNames,

src/helpers/get-where-unique-at-least-keys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function getWhereUniqueAtLeastKeys(model: DMMF.Model) {
1616
return names;
1717
}
1818

19-
function createFieldName(args: { name?: string | null; fields: string[] }) {
19+
function createFieldName(args: { name?: string | null; fields: Readonly<string[]> }) {
2020
const { name, fields } = args;
2121

2222
return name || fields.join('_');

src/types.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import { DMMF } from '@prisma/client/runtime/library';
22
import AwaitEventEmitter from 'await-event-emitter';
33
import { Project, SourceFile } from 'ts-morph';
4+
import type { WritableDeep } from 'type-fest';
45

56
import { createConfig } from './helpers/create-config';
67
import { ObjectSettings } from './helpers/object-settings';
78

8-
export type InputType = DMMF.InputType;
9+
export type InputType = WritableDeep<DMMF.InputType>;
910
export type FieldLocation = DMMF.FieldLocation;
10-
export type OutputType = DMMF.OutputType;
11-
export type SchemaField = DMMF.SchemaField;
11+
export type OutputType = WritableDeep<DMMF.OutputType>;
12+
export type SchemaField = WritableDeep<DMMF.SchemaField>;
1213
export type SchemaEnum = DMMF.SchemaEnum;
13-
export type Model = DMMF.Model;
14+
export type Model = WritableDeep<DMMF.Model>;
15+
export type SchemaArg = WritableDeep<DMMF.SchemaArg>;
16+
export type Schema = WritableDeep<DMMF.Schema>;
17+
export type Document = WritableDeep<DMMF.Document>;
1418

1519
export type FieldOutputType = SchemaField['outputType'];
1620

@@ -28,7 +32,7 @@ export type TypeRecord = Partial<{
2832
export type GeneratorConfiguration = ReturnType<typeof createConfig>;
2933

3034
export type EventArguments = {
31-
schema: DMMF.Schema;
35+
schema: Schema;
3236
models: Map<string, Model>;
3337
modelNames: string[];
3438
modelFields: Map<string, Map<string, Field>>;

0 commit comments

Comments
 (0)