
Research
/Security News
npm Author Qix Compromised via Phishing Email in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
zenstack-crudzod
Advanced tools
ZenStack CRUD Zod Plugin is a standard plugin for ZenStack that generate Zod schemas for all CRUD operations (Prisma Client API) for each model in your ZModel schema.
This is particularly useful for building AI agent, where you want LLM to be able to operate on your database safely per user's request using Prisma Client API like findMany
, create
, and update
.
For models like:
model User {
id String @id @default(cuid())
name String
todo Todo[]
list List[]
}
model Todo {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
ownerId String
title String
completed Boolean @default(false)
}
model List {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
ownerId String
title String
private Boolean @default(false)
todos Todo[]
}
Here are the generated object in the schema file that you will use in your AI agent:
3 Zod schemas for each model. For example, for the User
model, it generates:
export const UserFindManyArgsSchema = z
.object({
where: UserWhereInput.optional(),
include: UserInclude.optional(),
})
.describe('Prisma client API `findMany` function args for User model');
export const UserCreateArgsSchema = z
.object({
data: UserCreateInput,
})
.describe('Prisma client API `create` function args for User model');
export const UserUpdateArgsSchema = z
.object({
data: UserUpdateInputSchema,
where: UserWhereInput,
})
.describe('Prisma client API `update` function args for User model');
A complete allSchemas
object that contains all the generated schemas for all models:
export const allSchemas = {
list: {
findMany: ListFindManyArgsSchema,
update: ListUpdateArgsSchema,
create: ListCreateArgsSchema,
},
todo: {
findMany: TodoFindManyArgsSchema,
update: TodoUpdateArgsSchema,
create: TodoCreateArgsSchema,
},
user: {
findMany: UserFindManyArgsSchema,
update: UserUpdateArgsSchema,
create: UserCreateArgsSchema,
},
};
A GetSystemPrompt
function that returns a system prompt for the AI agent to use:
export const GetSystemPrompt = (userId: string):string
npm install -D zenstack-crudzod
plugin zenstack_crud_zod {
provider = 'zenstack-crudzod'
// optional: specify output path
output = '.'
}
npx zenstack generate
After running the command, you'll see a crud-zod.ts
file generated in the specified output directory (or the current directory if not specified).
Name | Type | Description | Required | Default |
---|---|---|---|---|
output | String | Output directory path (relative to the path of ZModel) | No | current directory |
npm install
npm run build
After building, the plugin will be generated in the dist
folder. Then you can use it in your existing ZModel schema by setting the provider
to this dist
folder:
plugin zenstack_crud_zod {
provider = '../path/to/zenstack-crudzod/dist'
}
MIT
FAQs
Generate CRUD Zod schemas from Zenstack models
The npm package zenstack-crudzod receives a total of 0 weekly downloads. As such, zenstack-crudzod popularity was classified as not popular.
We found that zenstack-crudzod demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.