Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Mark DMMF as deep readonly #98

Merged
merged 4 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading