Skip to content

Commit edd4283

Browse files
authored
fix: Mark DMMF as deep readonly (#98)
* chore: Update dependencies * chore: Add types for `debug` dependency * fix: Mark DMMF as deep readonly Closes #97. * chore: Bump node version to LTS
1 parent 057efba commit edd4283

File tree

5 files changed

+501
-1136
lines changed

5 files changed

+501
-1136
lines changed

.github/workflows/cd.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
1818
- uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8
1919
with:
20-
node-version: 16.x
20+
node-version: lts/*
2121
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
2222
name: Load Yarn cache
2323
with:

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
2424
- uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8
2525
with:
26-
node-version: 16.x
26+
node-version: lts/*
2727
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
2828
name: Load Yarn cache
2929
with:

package.json

+18-17
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,34 @@
4646
},
4747
"dependencies": {
4848
"@47ng/cloak": "^1.1.0",
49-
"@prisma/generator-helper": "^5.0.0",
49+
"@prisma/generator-helper": "^5.9.1",
5050
"debug": "^4.3.4",
51-
"immer": "^10.0.2",
51+
"immer": "^10.0.3",
5252
"object-path": "^0.11.8",
53-
"zod": "^3.21.4"
53+
"zod": "^3.22.4"
5454
},
5555
"peerDependencies": {
5656
"@prisma/client": ">= 4.7"
5757
},
5858
"devDependencies": {
59-
"@commitlint/config-conventional": "^17.6.6",
60-
"@prisma/client": "5.0.0",
61-
"@prisma/internals": "^5.0.0",
62-
"@types/jest": "^29.5.3",
63-
"@types/node": "^20.4.2",
64-
"@types/object-path": "^0.11.1",
65-
"commitlint": "^17.6.6",
66-
"husky": "^8.0.3",
59+
"@commitlint/config-conventional": "^17.8.1",
60+
"@prisma/client": "5.9.1",
61+
"@prisma/internals": "^5.9.1",
62+
"@types/debug": "^4.1.12",
63+
"@types/jest": "^29.5.12",
64+
"@types/node": "^20.11.16",
65+
"@types/object-path": "^0.11.4",
66+
"commitlint": "^17.8.1",
67+
"husky": "^9.0.10",
6768
"jest": "^29",
6869
"npm-run-all": "^4.1.5",
6970
"nyc": "^15.1.0",
70-
"prisma": "^5.0.0",
71-
"sqlite": "^5.0.1",
72-
"sqlite3": "^5.1.6",
73-
"ts-jest": "^29.1.1",
74-
"ts-node": "^10.9.1",
75-
"typescript": "^5.1.6"
71+
"prisma": "^5.9.1",
72+
"sqlite": "^5.1.1",
73+
"sqlite3": "^5.1.7",
74+
"ts-jest": "^29.1.2",
75+
"ts-node": "^10.9.2",
76+
"typescript": "^5.3.3"
7677
},
7778
"jest": {
7879
"verbose": true,

src/types.ts

+25-17
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,33 @@ export type Middleware<
3232
next: (params: MiddlewareParams<Models, Actions>) => Promise<Result>
3333
) => Promise<Result>
3434

35-
const dmmfFieldParser = z.object({
36-
name: z.string(),
37-
isList: z.boolean(),
38-
isUnique: z.boolean(),
39-
isId: z.boolean(),
40-
type: z.any(),
41-
documentation: z.string().optional()
42-
})
35+
const dmmfFieldParser = z
36+
.object({
37+
name: z.string(),
38+
isList: z.boolean(),
39+
isUnique: z.boolean(),
40+
isId: z.boolean(),
41+
type: z.any(),
42+
documentation: z.string().optional()
43+
})
44+
.readonly()
4345

44-
const dmmfModelParser = z.object({
45-
name: z.string(),
46-
fields: z.array(dmmfFieldParser)
47-
})
46+
const dmmfModelParser = z
47+
.object({
48+
name: z.string(),
49+
fields: z.array(dmmfFieldParser).readonly()
50+
})
51+
.readonly()
4852

49-
export const dmmfDocumentParser = z.object({
50-
datamodel: z.object({
51-
models: z.array(dmmfModelParser)
53+
export const dmmfDocumentParser = z
54+
.object({
55+
datamodel: z
56+
.object({
57+
models: z.array(dmmfModelParser).readonly()
58+
})
59+
.readonly()
5260
})
53-
})
61+
.readonly()
5462

5563
export type DMMFModel = z.TypeOf<typeof dmmfModelParser>
5664
export type DMMFField = z.TypeOf<typeof dmmfFieldParser>
@@ -61,7 +69,7 @@ export type DMMFDocument = z.TypeOf<typeof dmmfDocumentParser>
6169
export interface Configuration {
6270
encryptionKey?: string
6371
decryptionKeys?: string[]
64-
dmmf?: DMMFDocument
72+
dmmf?: Readonly<DMMFDocument>
6573
}
6674

6775
export type HashFieldConfiguration = {

0 commit comments

Comments
 (0)