{"_id":"@abcx3/prisma-generator-nestjs","_rev":"2-e8881babf48fcff4d32a42c26761feeb","name":"@abcx3/prisma-generator-nestjs","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.1":{"name":"@abcx3/prisma-generator-nestjs","version":"1.0.1","keywords":["prisma","generator","nestjs","typescript","orm"],"author":{"url":"https://github.com/FredrikBorgstrom","name":"Fredrik Borgström","email":"fredrik@abcx3.com"},"license":"ISC","_id":"@abcx3/prisma-generator-nestjs@1.0.1","maintainers":[{"name":"fredrik_borgstrom","email":"fredrik@mp1.se"}],"homepage":"https://github.com/FredrikBorgstrom/abcx3","bugs":{"url":"https://github.com/FredrikBorgstrom/abcx3/issues"},"bin":{"prisma-generator-nestjs":"index.js"},"dist":{"shasum":"bbe75739b3f8cf9068a659ee21ab788884db2dbe","tarball":"https://registry.npmjs.org/@abcx3/prisma-generator-nestjs/-/prisma-generator-nestjs-1.0.1.tgz","fileCount":4,"integrity":"sha512-3P8NVVLUO2V9vfbPmH11pu0Icd4izZCyFf9z2lWr86BVfJn4i+GnpfIcKnqsU26k1VZN/TIdbma8vKwzikdQmg==","signatures":[{"sig":"MEYCIQDccA44GNBRN+tjRUXfneY2sarwMynTp9xIuzeso0NzeQIhAJwpw4LqIFFCfhmCJu3Lx48HNxcw17G23G4kZQ0oYp+p","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":64324},"main":"./index.js","gitHead":"78997021c04d628614c32dd44a506f32c21c8a93","_npmUser":{"name":"fredrik_borgstrom","email":"fredrik@mp1.se"},"repository":{"url":"git+https://github.com/FredrikBorgstrom/abcx3.git","type":"git","directory":"libs/prisma-generator-nestjs"},"_npmVersion":"11.6.0","description":"Automatically creates Nestjs controllers, services and modules from your Prisma Schema","directories":{},"_nodeVersion":"24.9.0","dependencies":{"dotenv":"^17.2.1","prettier":"^3.6.2","@prisma/generator-helper":"^6.15.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/prisma-generator-nestjs_1.0.1_1761163031451_0.2587091113684066","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@abcx3/prisma-generator-nestjs","description":"Automatically creates Nestjs controllers, services and modules from your Prisma Schema","version":"2.0.0","main":"./index.js","bin":{"prisma-generator-nestjs":"index.js"},"keywords":["prisma","generator","nestjs","typescript","orm"],"author":{"name":"Fredrik Borgström","email":"fredrik@abcx3.com","url":"https://github.com/FredrikBorgstrom"},"repository":{"type":"git","url":"git+https://github.com/FredrikBorgstrom/abcx3.git","directory":"libs/prisma-generator-nestjs"},"homepage":"https://github.com/FredrikBorgstrom/abcx3","license":"ISC","dependencies":{"prettier":"^3.6.2","@prisma/generator-helper":"^7.0.0","@prisma/internals":"^7.0.0","dotenv":"^17.2.1"},"gitHead":"592308df27fe2e68aa462c408770d58666c4e911","_id":"@abcx3/prisma-generator-nestjs@2.0.0","bugs":{"url":"https://github.com/FredrikBorgstrom/abcx3/issues"},"_nodeVersion":"25.2.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-r48m/Ntk/U7qnxcFR8dXTmnASlMPEF+gz6WAT2D78bZkv/F5EywIrE9fZRpVvB/DL6zongI/ivGEJ4iRSMT48g==","shasum":"bf09463d56f3030f02991ae48f6d5ef849e155d0","tarball":"https://registry.npmjs.org/@abcx3/prisma-generator-nestjs/-/prisma-generator-nestjs-2.0.0.tgz","fileCount":4,"unpackedSize":67339,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDYSJ5AHN4k0Xw8IAT+tOYIdvacJDzSA1LYslhIoo8sNAiEA1WjfxvsoRLTWF9sPSlpJ9XXNdyoUdPfxZvW7xHC3b60="}]},"_npmUser":{"name":"fredrik_borgstrom","email":"fredrik@mp1.se"},"directories":{},"maintainers":[{"name":"fredrik_borgstrom","email":"fredrik@mp1.se"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/prisma-generator-nestjs_2.0.0_1764679543971_0.661806432564916"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-22T19:57:11.400Z","modified":"2025-12-02T12:45:44.392Z","1.0.1":"2025-10-22T19:57:11.679Z","2.0.0":"2025-12-02T12:45:44.170Z"},"bugs":{"url":"https://github.com/FredrikBorgstrom/abcx3/issues"},"author":{"name":"Fredrik Borgström","email":"fredrik@abcx3.com","url":"https://github.com/FredrikBorgstrom"},"license":"ISC","homepage":"https://github.com/FredrikBorgstrom/abcx3","keywords":["prisma","generator","nestjs","typescript","orm"],"repository":{"type":"git","url":"git+https://github.com/FredrikBorgstrom/abcx3.git","directory":"libs/prisma-generator-nestjs"},"description":"Automatically creates Nestjs controllers, services and modules from your Prisma Schema","maintainers":[{"name":"fredrik_borgstrom","email":"fredrik@mp1.se"}],"readme":"@abcx3/prisma-generator-nestjs\n\nGenerate NestJS modules, controllers and services for every Prisma model in your schema. It’s designed to work great on its own, and it’s the companion backend generator for @abcx3/prisma-generator-dart client “stores”.\n\nWhen used together:\n- The NestJS generator creates predictable routes per model (POST-only for data fetch so model filters can be sent in the request body).\n- The Dart generator embeds matching route metadata into each generated Store (<Model>Endpoints enum) so Dart stores can call the backend themselves, including passing complex Prisma-like filters.\n\n\nInstallation\n\n- Add the generator to your backend project:\n\n  bash\n  npm i -D @abcx3/prisma-generator-nestjs\n\n- Add a generator block to your prisma schema (backend):\n\n  prisma\n  // schema.prisma (backend)\n  generator nestjs {\n    provider                         = \"node ./node_modules/@abcx3/prisma-generator-nestjs/index.js\"\n    output                           = \"./src/gen\"       // where to emit modules/controllers/services\n    GenerateControllers               = true              // enable controllers so routes are created\n    GenerateModule                    = true\n    GenerateServices                  = true\n    WrapWithNeverthrow                = true              // make service methods return Result<..., Error>\n    PrismaServiceImportPath           = \"prisma/prisma.service\"\n    PrismaModuleName                  = \"PrismaModule\"\n    PrismaModuleImportPath            = \"src/prisma/prisma.module\"\n    PrismaClientImportPath            = \"@prisma/client\"\n    // Optional extras\n    // prefix                          = \"gen\"            // file name prefix (default)\n    // secondaryOutputPath             = \"./src/routes\"   // also emit a copy without auto-gen banner\n    // GenerateEmptyControllersAndServices = true         // emit empty classes if you want to hand-roll logic\n    // GuardClass                      = \"JwtAuthGuard\"   // add a Nest guard decorator to all routes\n    // GuardImportPath                 = \"src/auth/jwt.guard\"\n  }\n\n- Generate files:\n\n  bash\n  npx prisma generate\n\n\nWhat gets generated\n\n- Per Prisma model (e.g. User):\n  - `src/gen/user/user.module.ts` – imports `PrismaModule`, exports the service, optionally registers controller\n  - `src/gen/user/user.service.ts` – typed data access over PrismaService with helpers for filtering\n  - `src/gen/user/user.controller.ts` – REST endpoints matching the Dart Stores’ expectations\n- Shared helper:\n  - `src/gen/store_common.ts` – filter types and reusable helpers used by all services\n\n\nGenerated routes (used by Dart Stores)\n\n- Controllers use POST so the request body can carry a Prisma-style filter.\n- For a model `User`, routes look like:\n  - `POST /user` → `getAll(req.body?.modelFilter)`\n  - For scalar/id/unique fields (e.g. `email`):\n    - `POST /user/byEmail/:email` → `getByFieldValues({ email }, req.body?.modelFilter)` or `getManyByFieldValues` for non-unique fields\n  - For list/object relation fields (many-to-many):\n    - `POST /user/byPostsIds/:postsIds` with `postsIds` as comma-separated `id`s\n\nRequest body modelFilter shape\n\n- The body may contain a `modelFilter` compatible with Prisma WhereInput logical operators:\n\n  json\n  {\n    \"modelFilter\": {\n      \"AND\": [\n        { \"email\": { \"contains\": \"@gmail.com\" } },\n        { \"age\": { \"gte\": 18 } }\n      ],\n      \"OR\": [\n        { \"firstName\": { \"startsWith\": \"A\" } }\n      ]\n    }\n  }\n\n- Supported operators mirror Prisma: `equals, not, gt, gte, lt, lte, inList, notInList, contains, startsWith, endsWith, notContains, notStartsWith, notEndsWith, isNull, isNotNull`.\n\n\nUsing guards\n\n- If you configure `GuardClass` and `GuardImportPath`, the generator adds `@UseGuards(YourGuard)` to all routes and imports the guard where needed.\n\nNeverthrow wrapping\n\n- With `WrapWithNeverthrow = true` (default), service method return types are converted from `Promise<T | Error>` into `Promise<Result<T, Error>>` and error throws become `err(...)` values.\n\n\nWorking with @abcx3/prisma-generator-dart\n\n- The Dart generator emits, for every model, a `<Model>Endpoints` enum that matches the routes this generator produces:\n  - `getAll` → `POST /model`\n  - `getBy<Field>` / `getManyBy<Field>` → `POST /model/by<Field>/:field`\n  - relation list id queries → `POST /model/by<FieldName>Ids/:fieldNameIds`\n- The generated Dart Stores (e.g. `UserStore`) call these endpoints through an `AuthHttpService` and attach `modelFilter` into the POST body when provided.\n\nExample\n\n- Given a Prisma model:\n\n  prisma\n  model User {\n    id      Int     @id @default(autoincrement())\n    email   String  @unique\n    name    String?\n    age     Int?\n  }\n\n- This generator creates `src/gen/user/user.controller.ts` with routes:\n\n  ts\n  @Controller('user')\n  export class UserController {\n    constructor(private readonly service: UserService) {}\n\n    @Post()\n    getAll(@Req() req?) {\n      return this.service.getAll(req?.body?.modelFilter);\n    }\n\n    @Post('byEmail/:email')\n    getByEmail(@Req() req, @Param('email') email: string) {\n      return this.service.getByFieldValues({ email }, req?.body?.modelFilter);\n    }\n  }\n\n- And a `user.service.ts` using Prisma and helpers from `store_common.ts` to apply logical filters.\n\n\nAdvanced options\n\n- `output`: directory where files are written. Combined with an internal base path for model folders.\n- `prefix`: string prefixed to generated file names (default: `gen_...`).\n- `secondaryOutputPath`: also emit a second copy without the auto-generated banner and with an empty prefix. Useful for publishing a transformed set (e.g. move into `src/routes`).\n- `GenerateEmptyControllersAndServices`: when true, emits empty classes so you can fill methods yourself while still keeping generated modules and structure.\n\n\nTroubleshooting\n\n- Ensure `PrismaServiceImportPath`, `PrismaModuleName` and `PrismaModuleImportPath` match your app.\n- Routes are POST by design to allow `modelFilter` in the request body; if your HTTP client expects GET for listing, either keep POST for filtering or add your own GET routes alongside the generated ones.\n","readmeFilename":"README.md"}