npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

venom-generator

v1.5.2

Published

In the way of code generation, complete the storage model->computation model (business API) transformation to achieve the goal of design and implementation

Downloads

11

Readme

venom-generator

以代码生成的方式,完成存储模型->计算模型(业务 API)转换,实现设计即实现的目标

参数

  • server:服务名称[可省略] 默认为 pservice 项目名

  • output:文件输出地址[可省略] 默认输出到./src/generated 文件夹下

  • yml:prisma.yml 文件路径[可省略] 默认从./prisma 读取文件 如果指定 'yml' 参数,未找到文件时再次从./prisma 读取文件

  • dev:开发调试 默认为 false ,true 可查看模型指令相关参数值

形式

  • 配置文件

    • 存放根目录[src 同级]

    • 文件名[.vgeneratorrc]:开发所需配置文件名必须与文件名一致,否则不读取

  • 命令行

使用

  • 无'.vgeneratorrc'文件使用方法
npx venom-generator --server account --output ./src/generated  --yml ./prisma
  • 有'.vgeneratorrc'文件使用方法
npx venom-generator

模型文件指令说明

@Include(value: "poclicy")

  • 是否需要依赖公共服务 poclicy 指令

    • value:公共服务名称

@Mutation/QueryResolve(description: "方法描述", type: "类型", args: "参数",list:true/false)

  • 用于公开的自定义方法指令

    • description:方法描述(所有指令参数都是如此)

    • type:方法返回类型

    • args:方法参数(所有指令参数都是如此)

      • 格式:key:value

      • '!':参数类型若有'!'符号,则表示该参数必传(如:"id:String!"表示 id 必传)

      • 可以为 prisma 基本数据类型[Boolean,DateTime,Float,ID,Int,String],也可以为 prisma 复杂对象

    • list:是否返回为数组。默认 false

    • @QueryResolve 指令用法

      • 若参数为 prisma 基本数据类型[Boolean,DateTime,Float,ID,Int,String],则 key 可定义,value 定义为[Boolean,DateTime,Float,ID,Int,String]

      • 若参数为复杂对象,需查询唯一则 key 定义为 where,value 定义为需查询的复杂对象

      • 若参数为复杂对象,需查询列表则 key 定义为 wheres,value 定义为需查询的复杂对象

      • 若参数为复杂对象,需分组或排序查询则 key 定义为 orderBy,value 定义为需查询的复杂对象

    • @MutationResolve 指令用法

      • 若参数为 prisma 基本数据类型[Boolean,DateTime,Float,ID,Int,String],则 key 可定义,value 定义为[Boolean,DateTime,Float,ID,Int,String]

      • 若参数为复杂对象且为新增,key 定义为 data,value 定义为需新增的复杂对象拼接 Create

      • 若参数为复杂对象且为更新,修改数据 key 定义为 data,value 定义为需更新的复杂对象拼接 Update,若条件也为复杂对象且根据唯一条件更新则 key 定义为 where,value 定义为需更新条件的复杂对象,若条件也为复杂对象且根据任意条件更新则 key 定义为 wheres,value 定义为需更新条件的复杂对象

      • 若参数为复杂对象且为删除,若条件也为复杂对象且根据唯一条件删除则 key 定义为 where,value 定义为需更新条件的复杂对象,若条件也为复杂对象且根据任意条件删除则 key 定义为 wheres,value 定义为需更新条件的复杂对象

@QueryUnique(description: "方法描述", args: "参数")

  • 查询单条数据方法指令

    • args:默认"id:String!"

@Query(description: "方法描述", args: "参数")

  • 查询多条数据方法指令

@Mutation(description: "方法描述", create: true, update: true, delete: true, args: "参数")

  • 增删改方法指令

    • create: ture/false 是否需要新增数据方法。 默认 false

    • update: ture/false 是否需要修改数据方法。 默认 false

    • delete: ture/false 是否需要删除数据方法。 默认 false

@CalcAuthorization(aud: "数据拥有者")

  • 当前方法是否需要检查相关权限指令

    • aud:当前方法是否检查数据拥有者

@Filter(Query: true, Mutation: true)

  • 暴露 api 字段过滤

    • Query:true/false 数据查询是否需要过滤该字段。 默认 false

    • Mutation:true/false 数据增删改是否需要过滤该字段。 默认 false

例子

  • 需要依赖公共服务
enum Test @Include(value: "poclicy") {
  Version @Version(value: "1.0.0")
  Description @Description(value: "测试")
}
  • 用于公开的自定义字段[Mutationxxx]
enum Test @MutationResolve(description: "测试方法", type: "String", args: "userName:String!,password:String!") {
  Test
}
enum Test @MutationResolve(description: "新增数据", type: "Test", args: "data:TestCreate!") {
  Test
}
enum Test @MutationResolve(description: "根据唯一条件更新数据", type: "Test", args: "data:TestUpdate!,where:Test!") {
  Test
}
enum Test @MutationResolve(description: "根据任意条件更新数据", type: "Test", args: "data:TestUpdate!,wheres:Test!") {
  Test
}

```graphql
enum Test @MutationResolve(description: "根据任意条件删除数据", type: "Test", args: "wheres:Test!") {
  Test
}
  • 单条数据查询且需要检查权限
type Test @QueryUnique(description: "测试方法", args: "id:String!") @CalcAuthorization(aud: "id") {
  id: Id! @id
}
  • 多条数据查询且无需检查权限
type Test @Query(description: "测试方法", args: "where:Test,orderBy:Test") {
  id: Id! @id
}
  • 增删改且需要检查权限
type Test @Mutation(description: "测试方法", create: true, update: true, delete: true, args: "where:Test!") @CalcAuthorization {
  id: Id! @id
}
  • 字段过滤
type Test {
  id: ID @id
  userName: String
  passWord: String @Filter(Query: true, Mutation: true)
}