Skip to content

Commit

Permalink
fix: Mark DMMF as deep readonly (#98)
Browse files Browse the repository at this point in the history
* chore: Update dependencies

* chore: Add types for `debug` dependency

* fix: Mark DMMF as deep readonly

Closes #97.

* chore: Bump node version to LTS
  • Loading branch information
franky47 committed Feb 6, 2024
1 parent 057efba commit edd4283
Show file tree
Hide file tree
Showing 5 changed files with 501 additions and 1,136 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8
with:
node-version: 16.x
node-version: lts/*
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
name: Load Yarn cache
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8
with:
node-version: 16.x
node-version: lts/*
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
name: Load Yarn cache
with:
Expand Down
35 changes: 18 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,34 @@
},
"dependencies": {
"@47ng/cloak": "^1.1.0",
"@prisma/generator-helper": "^5.0.0",
"@prisma/generator-helper": "^5.9.1",
"debug": "^4.3.4",
"immer": "^10.0.2",
"immer": "^10.0.3",
"object-path": "^0.11.8",
"zod": "^3.21.4"
"zod": "^3.22.4"
},
"peerDependencies": {
"@prisma/client": ">= 4.7"
},
"devDependencies": {
"@commitlint/config-conventional": "^17.6.6",
"@prisma/client": "5.0.0",
"@prisma/internals": "^5.0.0",
"@types/jest": "^29.5.3",
"@types/node": "^20.4.2",
"@types/object-path": "^0.11.1",
"commitlint": "^17.6.6",
"husky": "^8.0.3",
"@commitlint/config-conventional": "^17.8.1",
"@prisma/client": "5.9.1",
"@prisma/internals": "^5.9.1",
"@types/debug": "^4.1.12",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.16",
"@types/object-path": "^0.11.4",
"commitlint": "^17.8.1",
"husky": "^9.0.10",
"jest": "^29",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"prisma": "^5.0.0",
"sqlite": "^5.0.1",
"sqlite3": "^5.1.6",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
"prisma": "^5.9.1",
"sqlite": "^5.1.1",
"sqlite3": "^5.1.7",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
"jest": {
"verbose": true,
Expand Down
42 changes: 25 additions & 17 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,33 @@ export type Middleware<
next: (params: MiddlewareParams<Models, Actions>) => Promise<Result>
) => Promise<Result>

const dmmfFieldParser = z.object({
name: z.string(),
isList: z.boolean(),
isUnique: z.boolean(),
isId: z.boolean(),
type: z.any(),
documentation: z.string().optional()
})
const dmmfFieldParser = z
.object({
name: z.string(),
isList: z.boolean(),
isUnique: z.boolean(),
isId: z.boolean(),
type: z.any(),
documentation: z.string().optional()
})
.readonly()

const dmmfModelParser = z.object({
name: z.string(),
fields: z.array(dmmfFieldParser)
})
const dmmfModelParser = z
.object({
name: z.string(),
fields: z.array(dmmfFieldParser).readonly()
})
.readonly()

export const dmmfDocumentParser = z.object({
datamodel: z.object({
models: z.array(dmmfModelParser)
export const dmmfDocumentParser = z
.object({
datamodel: z
.object({
models: z.array(dmmfModelParser).readonly()
})
.readonly()
})
})
.readonly()

export type DMMFModel = z.TypeOf<typeof dmmfModelParser>
export type DMMFField = z.TypeOf<typeof dmmfFieldParser>
Expand All @@ -61,7 +69,7 @@ export type DMMFDocument = z.TypeOf<typeof dmmfDocumentParser>
export interface Configuration {
encryptionKey?: string
decryptionKeys?: string[]
dmmf?: DMMFDocument
dmmf?: Readonly<DMMFDocument>
}

export type HashFieldConfiguration = {
Expand Down
Loading

0 comments on commit edd4283

Please sign in to comment.