prisma-generator-express 1.26.1 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -418,6 +418,7 @@ const projectConfig = {
418
418
  ```
419
419
 
420
420
  A request with `{ where: { title: { contains: 'demo' } } }` produces:
421
+
421
422
  ```
422
423
  WHERE status = 'published'
423
424
  AND isDeleted = false
@@ -484,7 +485,7 @@ const userConfig = {
484
485
 
485
486
  The client can filter by `title` inside the relation, but `published = true` is always enforced.
486
487
 
487
- ### Select, include, and omit in shapes
488
+ ### Select and include in shapes
488
489
 
489
490
  Shapes can restrict which response fields and relations the client may request:
490
491
  ```ts
@@ -513,6 +514,10 @@ The client can only select from the whitelisted fields and relations. Attempting
513
514
 
514
515
  `select` and `include` are mutually exclusive at the same level in both the shape and the client request.
515
516
 
517
+ For read operations, the shape's `select` or `include` serves two roles: it whitelists what the client is allowed to request, and it provides the default projection when the client omits `select`/`include` from the request. If the client sends a request without `select` or `include`, the shape's projection is automatically applied — the client does not need to duplicate the field list. If the client does send `select` or `include`, it is validated against the shape as a whitelist.
518
+
519
+ This means a single shape declaration like the example above defines both the security boundary (which fields are allowed) and the default API response shape (which fields are returned when the client doesn't specify).
520
+
516
521
  ### Nested include with forced where and pagination
517
522
 
518
523
  Nested includes on to-many relations support `where`, `orderBy`, `cursor`, `take`, and `skip`:
@@ -573,6 +578,8 @@ const userConfig = {
573
578
 
574
579
  The client can include `include` or `select` in the request body. If the shape does not define projection, the client cannot request one. Batch methods (`createMany`, `updateMany`, `deleteMany`) do not support projection.
575
580
 
581
+ For mutations, projection shapes only validate and constrain client-requested projections by default — if the client omits `select`/`include`, Prisma returns the full record. This differs from read operations, where the shape's projection is automatically applied as default. Enable `enforceProjection` in the prisma-guard generator config to always apply mutation projection shapes.
582
+
576
583
  ### Upsert
577
584
 
578
585
  Upsert uses `create` and `update` shape keys instead of `data`:
@@ -796,7 +803,7 @@ app.listen(3000)
796
803
  In this setup:
797
804
 
798
805
  - Admins can filter by any allowed field, include relations, and take up to 200 rows
799
- - Viewers can only see published, non-deleted projects with a restricted field set
806
+ - Viewers can only see published, non-deleted projects with a restricted field set — the `select` shape automatically applies as the default projection, so viewer clients don't need to send `select` in the request
800
807
  - Create: admins set any allowed field; viewers always create drafts with priority 1
801
808
  - Delete: only admins can delete; viewers hitting the delete endpoint get a `CallerError` because there is no `viewer` shape for delete
802
809
  - Tenant isolation is automatic — every query is scoped to the tenant from `x-tenant-id`
@@ -855,6 +862,8 @@ Read and single-record write operations support three response shaping parameter
855
862
 
856
863
  The `omit` parameter requires Prisma 6.2.0+. On versions 6.0.x–6.1.x, requests using `omit` return 400.
857
864
 
865
+ When using guard shapes, the shape's `select` or `include` defines both the whitelist and the default projection for read operations. See [Select and include in shapes](#select-and-include-in-shapes).
866
+
858
867
  ## BigInt and Decimal handling
859
868
 
860
869
  BigInt and Decimal values are serialized as strings in JSON responses. Buffer and Uint8Array values are serialized as base64 strings. The OpenAPI spec documents BigInt and Decimal fields as `type: string`.
@@ -127,7 +127,7 @@ export function ${routerFunctionName}(config: RouteConfig = {}) {
127
127
  if (qbEnabled) {
128
128
  const qbConfig = getQueryBuilderConfig(config)
129
129
  if (qbConfig) {
130
- import('../queryBuilder.js').then(mod => mod.startQueryBuilder(qbConfig)).catch((err) => { if (_env.NODE_ENV !== 'production') console.warn('[query-builder]', err) })
130
+ try { require('../queryBuilder').startQueryBuilder(qbConfig) } catch (err) { if (_env.NODE_ENV !== 'production') console.warn('[query-builder]', err) }
131
131
  }
132
132
  }
133
133
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prisma-generator-express",
3
3
  "description": "Prisma generator for Hono CRUD API with OpenAPI documentation",
4
- "version": "1.26.1",
4
+ "version": "1.28.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "MIT",
@@ -140,7 +140,7 @@ export function ${routerFunctionName}(config: RouteConfig = {}) {
140
140
  if (qbEnabled) {
141
141
  const qbConfig = getQueryBuilderConfig(config)
142
142
  if (qbConfig) {
143
- import('../queryBuilder.js').then(mod => mod.startQueryBuilder(qbConfig)).catch((err) => { if (_env.NODE_ENV !== 'production') console.warn('[query-builder]', err) })
143
+ try { require('../queryBuilder').startQueryBuilder(qbConfig) } catch (err) { if (_env.NODE_ENV !== 'production') console.warn('[query-builder]', err) }
144
144
  }
145
145
  }
146
146