
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
@kalissaac/prisma-typegen
Advanced tools
Generates full types (including relations) for TypeScript from a Prisma schema
Generates full types (including relations) for TypeScript from a Prisma schema
$ npx @kalissaac/prisma-typegen <output path> [prisma schema file] [--onlyDeclarations] [--generateInsertionTypes]
$ npx @kalissaac/prisma-typegen ./interfaces ./schema.prisma
$ npx @kalissaac/prisma-typegen ./interfaces/prismaTypes.ts ./schema.prisma
If using JavaScript instead of TypeScript, pass --onlyDeclarations
to allow the types to be used with JSDoc.
If using this package to generate types that will be assigned to data to be inserted into a database, use the --generateInsertionTypes
flag. Using this option will result in a few differences:
DateTime
fields are mapped to Date | string
insead of just Date
. This is because most database clients support inserting date fields using either the native Date
type or an ISO 8601 compliant string
.@default
value are made optional because they are populated automatically if not provided when inserting a new data row.@relation
) are omitted because they do not exist at the database level and therefore can't be inserted. Read more about this heretype
instead of interface
By default, types are generated as an interface
. If your use case requires using type
instead, use the --useType
flag.
datasource db {
url = env("DATABASE_URL")
provider = "postgresql"
}
generator client {
provider = "prisma-client-js"
}
model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
email String @unique
name String?
role Role @default(USER)
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
published Boolean @default(false)
title String @db.VarChar(255)
author User? @relation(fields: [authorId], references: [id])
authorId Int?
}
enum Role {
USER
ADMIN
}
index.ts
(or index.d.ts
)export enum Role {
USER = 'USER',
ADMIN = 'ADMIN',
}
export interface User {
id: number
createdAt: Date
email: string
name?: string
role: Role
posts: Post[]
}
export interface Post {
id: number,
createdAt: Date,
updatedAt: Date,
published: boolean,
title: string,
author?: User,
authorId?: number,
}
index.ts
(or index.d.ts
) in insertion mode (with --generateInsertionTypes
)export enum Role {
USER = 'USER',
ADMIN = 'ADMIN',
}
export interface User {
id?: number,
createdAt?: (Date | string),
email: string,
name?: string | null,
role?: Role,
}
export interface Post {
id?: number,
createdAt?: (Date | string),
updatedAt: (Date | string),
published?: boolean,
title: string,
authorId?: number | null,
}
index.ts
(or index.d.ts
) with --useType
optionexport enum Role {
USER = 'USER',
ADMIN = 'ADMIN',
}
export type User = {
id: number,
createdAt: Date,
email: string,
name?: string,
role: Role,
posts: Post[],
}
export type Post = {
id: number,
createdAt: Date,
updatedAt: Date,
published: boolean,
title: string,
author?: User,
authorId?: number,
}
FAQs
Generates full types (including relations) for TypeScript from a Prisma schema
The npm package @kalissaac/prisma-typegen receives a total of 956 weekly downloads. As such, @kalissaac/prisma-typegen popularity was classified as not popular.
We found that @kalissaac/prisma-typegen demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.