prisma-generator-express 1.44.0 → 1.45.1
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
|
@@ -12,7 +12,7 @@ Running `npx prisma generate` produces:
|
|
|
12
12
|
- Handler functions for all Prisma operations (findMany, create, update, delete, etc.)
|
|
13
13
|
- Router generator with middleware support (before/after hooks per operation)
|
|
14
14
|
- POST read endpoints for all read operations (for complex queries exceeding URL length limits)
|
|
15
|
-
- Express-only progressive read streaming over Server-Sent Events (SSE)
|
|
15
|
+
- Express-only progressive read streaming over Server-Sent Events (SSE), using manual stages or auto-include splitting for single-record relation reads
|
|
16
16
|
- OpenAPI 3.1 spec (JSON and YAML endpoints registered automatically per router)
|
|
17
17
|
- Documentation helpers for contract view and Scalar UI (require manual mounting)
|
|
18
18
|
- Client-side query parameter encoder
|
|
@@ -72,7 +72,7 @@ Some operations require newer versions:
|
|
|
72
72
|
|
|
73
73
|
The Hono target v1 is tested on Node.js runtimes only. See [Cloudflare Workers and edge runtimes](#cloudflare-workers-and-edge-runtimes).
|
|
74
74
|
|
|
75
|
-
Progressive Endpoint Composition over Server-Sent Events is currently supported by the Express target only. Fastify and Hono continue to support normal JSON read and write routes.
|
|
75
|
+
Progressive Endpoint Composition over Server-Sent Events is currently supported by the Express target only. Express supports both manual staged streaming and auto-include streaming for single-record relation reads. Fastify and Hono continue to support normal JSON read and write routes.
|
|
76
76
|
|
|
77
77
|
### Database provider support
|
|
78
78
|
|
|
@@ -1331,15 +1331,22 @@ app.use('/', UserRouter({
|
|
|
1331
1331
|
|
|
1332
1332
|
Progressive Endpoint Composition lets an Express read endpoint stream partial response fields over Server-Sent Events while still ending with a final result event.
|
|
1333
1333
|
|
|
1334
|
-
This is useful for page-level endpoints where different UI sections need different slices of data. For example, a dashboard can render profile basics first, then saved jobs, applications, invitations, and activity as each
|
|
1334
|
+
This is useful for page-level endpoints where different UI sections need different slices of data. For example, a dashboard can render profile basics first, then saved jobs, applications, invitations, and activity as each part finishes.
|
|
1335
1335
|
|
|
1336
1336
|
This feature is **Express-only** in v1.
|
|
1337
1337
|
|
|
1338
1338
|
### Mental model
|
|
1339
1339
|
|
|
1340
|
-
Progressive
|
|
1340
|
+
Progressive SSE has two modes:
|
|
1341
1341
|
|
|
1342
|
-
|
|
1342
|
+
| Mode | Config | Best for |
|
|
1343
|
+
| ---- | ------ | -------- |
|
|
1344
|
+
| Manual stages | `{ stages: [...] }` or `{ mode: 'manual', stages: [...] }` | Custom page-level composition where each stage runs its own query and returns patches |
|
|
1345
|
+
| Auto include | `{ mode: 'autoInclude' }` | Single-record reads where the client already sends a Prisma `include` or relation `select` tree and you want relation fields streamed progressively |
|
|
1346
|
+
|
|
1347
|
+
Manual mode is explicit staged data loading. You define stages yourself and each stage decides what query to run and which field path to patch.
|
|
1348
|
+
|
|
1349
|
+
Auto-include mode is generated relation loading. The router keeps the normal GET endpoint, runs the root single-record query first, streams root fields, then loads supported included relations as separate follow-up queries and streams each relation path as it resolves.
|
|
1343
1350
|
|
|
1344
1351
|
### Request format
|
|
1345
1352
|
|
|
@@ -1359,7 +1366,7 @@ POST read endpoints remain JSON-only.
|
|
|
1359
1366
|
|
|
1360
1367
|
### Supported operations
|
|
1361
1368
|
|
|
1362
|
-
|
|
1369
|
+
Manual progressive SSE can be configured on Express GET read operations only:
|
|
1363
1370
|
|
|
1364
1371
|
- `findMany`
|
|
1365
1372
|
- `findUnique`
|
|
@@ -1371,6 +1378,15 @@ Progressive SSE can be configured on Express GET read operations only:
|
|
|
1371
1378
|
- `aggregate`
|
|
1372
1379
|
- `groupBy`
|
|
1373
1380
|
|
|
1381
|
+
Auto-include progressive SSE only supports single-record read operations:
|
|
1382
|
+
|
|
1383
|
+
- `findUnique`
|
|
1384
|
+
- `findUniqueOrThrow`
|
|
1385
|
+
- `findFirst`
|
|
1386
|
+
- `findFirstOrThrow`
|
|
1387
|
+
|
|
1388
|
+
If auto-include is configured on another operation, the router either falls back to single-result SSE or sends an SSE error depending on `fallback`.
|
|
1389
|
+
|
|
1374
1390
|
Write operations do not support progressive SSE.
|
|
1375
1391
|
|
|
1376
1392
|
### Event protocol
|
|
@@ -1407,9 +1423,11 @@ Error event:
|
|
|
1407
1423
|
{ "type": "error", "message": "Could not load progressive response" }
|
|
1408
1424
|
```
|
|
1409
1425
|
|
|
1410
|
-
The final `result.data` is the accumulated object built from all applied patches, unless a stage returns a stop result.
|
|
1426
|
+
The final `result.data` is the accumulated object built from all applied patches, unless a manual stage returns a stop result.
|
|
1411
1427
|
|
|
1412
|
-
###
|
|
1428
|
+
### Manual staged mode
|
|
1429
|
+
|
|
1430
|
+
Manual mode is selected when a progressive variant has a `stages` array. `mode: 'manual'` is optional.
|
|
1413
1431
|
|
|
1414
1432
|
Progressive config lives on an Express read operation. It is keyed by the resolved variant.
|
|
1415
1433
|
|
|
@@ -1453,17 +1471,6 @@ const dashboardProfileBasics: ProgressiveStage<{ userId: string }> = async ({
|
|
|
1453
1471
|
location: true,
|
|
1454
1472
|
skills: true,
|
|
1455
1473
|
isAvailableForHire: true,
|
|
1456
|
-
_count: {
|
|
1457
|
-
select: {
|
|
1458
|
-
profileViews: true,
|
|
1459
|
-
savedAt: true,
|
|
1460
|
-
},
|
|
1461
|
-
},
|
|
1462
|
-
boost: {
|
|
1463
|
-
select: {
|
|
1464
|
-
boostedUntil: true,
|
|
1465
|
-
},
|
|
1466
|
-
},
|
|
1467
1474
|
},
|
|
1468
1475
|
},
|
|
1469
1476
|
},
|
|
@@ -1477,10 +1484,6 @@ const dashboardProfileBasics: ProgressiveStage<{ userId: string }> = async ({
|
|
|
1477
1484
|
...user.profile,
|
|
1478
1485
|
appliedTo: [],
|
|
1479
1486
|
invitationsFor: [],
|
|
1480
|
-
jobAdViews: [],
|
|
1481
|
-
campaign_clicks: [],
|
|
1482
|
-
jobAssignments: [],
|
|
1483
|
-
resourceOfCompanyTalentRoster: [],
|
|
1484
1487
|
}
|
|
1485
1488
|
: null,
|
|
1486
1489
|
}
|
|
@@ -1503,8 +1506,6 @@ const dashboardApplications: ProgressiveStage<{ userId: string }> = async ({
|
|
|
1503
1506
|
id: true,
|
|
1504
1507
|
createdAt: true,
|
|
1505
1508
|
viewedAt: true,
|
|
1506
|
-
details: true,
|
|
1507
|
-
jobAd: true,
|
|
1508
1509
|
},
|
|
1509
1510
|
},
|
|
1510
1511
|
},
|
|
@@ -1552,7 +1553,7 @@ const userConfig = {
|
|
|
1552
1553
|
app.use('/', UserRouter(userConfig))
|
|
1553
1554
|
```
|
|
1554
1555
|
|
|
1555
|
-
`resolveContext` is required for a variant with `progressive.enabled !== false`. It is not required for ordinary JSON requests or
|
|
1556
|
+
`resolveContext` is required for a manual progressive variant with `progressive.enabled !== false`. It is not required for ordinary JSON requests, auto-include mode, or single-result SSE fallback.
|
|
1556
1557
|
|
|
1557
1558
|
### Stage function API
|
|
1558
1559
|
|
|
@@ -1616,16 +1617,129 @@ return {
|
|
|
1616
1617
|
|
|
1617
1618
|
Patch path segments `__proto__`, `constructor`, `prototype`, and empty path segments are rejected.
|
|
1618
1619
|
|
|
1620
|
+
### Auto-include mode
|
|
1621
|
+
|
|
1622
|
+
Auto-include mode is selected with `mode: 'autoInclude'`.
|
|
1623
|
+
|
|
1624
|
+
```ts
|
|
1625
|
+
const userConfig = {
|
|
1626
|
+
guard: {
|
|
1627
|
+
variantHeader: 'x-api-variant',
|
|
1628
|
+
},
|
|
1629
|
+
|
|
1630
|
+
findUnique: {
|
|
1631
|
+
progressive: {
|
|
1632
|
+
detail: {
|
|
1633
|
+
enabled: true,
|
|
1634
|
+
mode: 'autoInclude',
|
|
1635
|
+
fallback: 'singleResult',
|
|
1636
|
+
},
|
|
1637
|
+
},
|
|
1638
|
+
},
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
app.use('/', UserRouter(userConfig))
|
|
1642
|
+
```
|
|
1643
|
+
|
|
1644
|
+
Client request:
|
|
1645
|
+
|
|
1646
|
+
```ts
|
|
1647
|
+
import { encodeQueryParams } from './generated/client/encodeQueryParams'
|
|
1648
|
+
|
|
1649
|
+
const params = encodeQueryParams({
|
|
1650
|
+
where: { id: 'user-id' },
|
|
1651
|
+
include: {
|
|
1652
|
+
profile: {
|
|
1653
|
+
select: {
|
|
1654
|
+
id: true,
|
|
1655
|
+
displayName: true,
|
|
1656
|
+
},
|
|
1657
|
+
},
|
|
1658
|
+
posts: {
|
|
1659
|
+
orderBy: { createdAt: 'desc' },
|
|
1660
|
+
take: 10,
|
|
1661
|
+
select: {
|
|
1662
|
+
id: true,
|
|
1663
|
+
title: true,
|
|
1664
|
+
},
|
|
1665
|
+
},
|
|
1666
|
+
},
|
|
1667
|
+
})
|
|
1668
|
+
|
|
1669
|
+
const response = await fetch(`/user/unique?${params}`, {
|
|
1670
|
+
headers: {
|
|
1671
|
+
Accept: 'text/event-stream',
|
|
1672
|
+
'x-api-variant': 'detail',
|
|
1673
|
+
},
|
|
1674
|
+
})
|
|
1675
|
+
```
|
|
1676
|
+
|
|
1677
|
+
Auto-include sends root scalar fields first, then sends relation field events as separate relation queries finish:
|
|
1678
|
+
|
|
1679
|
+
```json
|
|
1680
|
+
{ "type": "field", "key": "id", "value": "user-id" }
|
|
1681
|
+
```
|
|
1682
|
+
|
|
1683
|
+
```json
|
|
1684
|
+
{ "type": "field", "key": "profile", "value": { "id": "profile-id", "displayName": "Alice" } }
|
|
1685
|
+
```
|
|
1686
|
+
|
|
1687
|
+
```json
|
|
1688
|
+
{ "type": "field", "key": "posts", "value": [{ "id": "post-id", "title": "Hello" }] }
|
|
1689
|
+
```
|
|
1690
|
+
|
|
1691
|
+
The final `result` event contains the assembled object.
|
|
1692
|
+
|
|
1693
|
+
### Auto-include behavior and limits
|
|
1694
|
+
|
|
1695
|
+
Auto-include is designed for supported Prisma `include` and relation `select` trees on single-record reads.
|
|
1696
|
+
|
|
1697
|
+
Supported root operations:
|
|
1698
|
+
|
|
1699
|
+
- `findUnique`
|
|
1700
|
+
- `findUniqueOrThrow`
|
|
1701
|
+
- `findFirst`
|
|
1702
|
+
- `findFirstOrThrow`
|
|
1703
|
+
|
|
1704
|
+
Supported relation shapes:
|
|
1705
|
+
|
|
1706
|
+
- direct to-one relation includes/selects
|
|
1707
|
+
- direct to-many relation includes/selects
|
|
1708
|
+
- to-many relation args such as `where`, `orderBy`, `take`, `skip`, `cursor`, and `distinct`
|
|
1709
|
+
- nested to-one relation loading through to-one parents
|
|
1710
|
+
|
|
1711
|
+
Current MVP fallback cases include:
|
|
1712
|
+
|
|
1713
|
+
- `_count` in `select` or `include`
|
|
1714
|
+
- implicit many-to-many relations
|
|
1715
|
+
- `select` and `include` at the same level
|
|
1716
|
+
- `select` and `omit` at the same level
|
|
1717
|
+
- relation filters/order/cursor in the root query
|
|
1718
|
+
- relation filters/order/cursor inside staged relation queries when unsupported
|
|
1719
|
+
- nested relation loading through a to-many parent
|
|
1720
|
+
- omitted required link fields needed to stitch parent and child records
|
|
1721
|
+
- planner limits for maximum depth or stage count
|
|
1722
|
+
|
|
1723
|
+
When fallback happens:
|
|
1724
|
+
|
|
1725
|
+
- `fallback: 'singleResult'` runs the normal Prisma read and returns one SSE `result` event
|
|
1726
|
+
- `fallback: 'error'` sends an SSE `error` event instead
|
|
1727
|
+
|
|
1728
|
+
If `fallback` is omitted, the default behavior is equivalent to `'singleResult'`.
|
|
1729
|
+
|
|
1730
|
+
Auto-include does not require `resolveContext` or `progressiveStages`.
|
|
1731
|
+
|
|
1619
1732
|
### Hooks and guard behavior
|
|
1620
1733
|
|
|
1621
1734
|
For SSE requests:
|
|
1622
1735
|
|
|
1623
1736
|
- `before` hooks run before streaming starts
|
|
1624
1737
|
- `after` hooks do not run, because the SSE middleware handles the response and does not continue to the normal handler
|
|
1625
|
-
- progressive stages receive `req.prisma` directly
|
|
1626
|
-
-
|
|
1738
|
+
- manual progressive stages receive `req.prisma` directly
|
|
1739
|
+
- manual progressive stages do not automatically use guard shapes
|
|
1740
|
+
- auto-include mode does not run when an operation has a guard `shape`; it falls back to single-result SSE or emits an SSE error depending on `fallback`
|
|
1627
1741
|
|
|
1628
|
-
|
|
1742
|
+
Manual stage authors are responsible for using the resolved context and enforcing ownership or tenant constraints in their stage queries.
|
|
1629
1743
|
|
|
1630
1744
|
For variants without progressive config, the single-result SSE fallback uses the normal generated core read handler, so guard shape behavior matches the JSON endpoint.
|
|
1631
1745
|
|
|
@@ -2134,11 +2248,22 @@ interface ReadOperationConfig<TCtx = unknown> extends OperationConfig {
|
|
|
2134
2248
|
progressiveStages?: Record<string, ProgressiveStage<TCtx>>
|
|
2135
2249
|
}
|
|
2136
2250
|
|
|
2137
|
-
type
|
|
2251
|
+
type ManualProgressiveVariantConfig = {
|
|
2138
2252
|
enabled?: boolean
|
|
2253
|
+
mode?: 'manual'
|
|
2139
2254
|
stages: string[]
|
|
2140
2255
|
}
|
|
2141
2256
|
|
|
2257
|
+
type AutoIncludeProgressiveVariantConfig = {
|
|
2258
|
+
enabled?: boolean
|
|
2259
|
+
mode: 'autoInclude'
|
|
2260
|
+
fallback?: 'singleResult' | 'error'
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
type ProgressiveVariantConfig =
|
|
2264
|
+
| ManualProgressiveVariantConfig
|
|
2265
|
+
| AutoIncludeProgressiveVariantConfig
|
|
2266
|
+
|
|
2142
2267
|
type ProgressiveStageContext<TContext = unknown, TPrisma = any> = {
|
|
2143
2268
|
ctx: TContext
|
|
2144
2269
|
req: Request
|
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
${prefix}GroupBy,
|
|
54
54
|
} from './${modelName}Handlers${ext}'
|
|
55
55
|
import * as core from './${modelName}Core${ext}'
|
|
56
|
-
import type { RouteConfig } from '../routeConfig.target${ext}'
|
|
56
|
+
import type { RouteConfig, QueryBuilderConfig } from '../routeConfig.target${ext}'
|
|
57
57
|
import { parseQueryParams } from '../parseQueryParams${ext}'
|
|
58
58
|
import { sanitizeKeys } from '../misc${ext}'
|
|
59
59
|
import { buildModelOpenApi } from '../buildModelOpenApi${ext}'
|
|
@@ -113,14 +113,14 @@ function normalizePrefix(p: string): string {
|
|
|
113
113
|
return result
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
function isQueryBuilderEnabled(config:
|
|
116
|
+
function isQueryBuilderEnabled(config: { queryBuilder?: QueryBuilderConfig | false }): boolean {
|
|
117
117
|
if (config.queryBuilder === false) return false
|
|
118
118
|
if (typeof config.queryBuilder === 'object' && config.queryBuilder.enabled === false) return false
|
|
119
119
|
if (_env.NODE_ENV === 'production') return false
|
|
120
120
|
return true
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
function getQueryBuilderConfig(config:
|
|
123
|
+
function getQueryBuilderConfig(config: { queryBuilder?: QueryBuilderConfig | false }) {
|
|
124
124
|
if (config.queryBuilder === false) return null
|
|
125
125
|
if (typeof config.queryBuilder === 'object') return config.queryBuilder
|
|
126
126
|
return {}
|
|
@@ -325,11 +325,11 @@ const maybeProgressiveSSE = (
|
|
|
325
325
|
const openapiJsonPath = basePath ? \`\${basePath}/openapi.json\` : '/openapi.json'
|
|
326
326
|
const openapiYamlPath = basePath ? \`\${basePath}/openapi.yaml\` : '/openapi.yaml'
|
|
327
327
|
router.get(openapiJsonPath, (_req, res) => {
|
|
328
|
-
const spec = buildModelOpenApi('${modelName}', MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1], MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2], config, { format: 'json' })
|
|
328
|
+
const spec = buildModelOpenApi('${modelName}', MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1], MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2], config as unknown as Parameters<typeof buildModelOpenApi>[3], { format: 'json' })
|
|
329
329
|
res.json(spec)
|
|
330
330
|
})
|
|
331
331
|
router.get(openapiYamlPath, (_req, res) => {
|
|
332
|
-
const spec = buildModelOpenApi('${modelName}', MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1], MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2], config, { format: 'yaml' })
|
|
332
|
+
const spec = buildModelOpenApi('${modelName}', MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1], MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2], config as unknown as Parameters<typeof buildModelOpenApi>[3], { format: 'yaml' })
|
|
333
333
|
res.type('application/yaml').send(spec as string)
|
|
334
334
|
})
|
|
335
335
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateRouter.js","sourceRoot":"","sources":["../../src/generators/generateRouter.ts"],"names":[],"mappings":";;AAMA,wDAseC;AA3eD,8CAA8C;AAC9C,uEAAmE;AAEnE,kDAA8C;AAE9C,SAAgB,sBAAsB,CAAC,EACrC,KAAK,EACL,KAAK,EACL,iBAAiB,EACjB,WAAW,GAOZ;IACC,MAAM,GAAG,GAAG,IAAA,qBAAS,EAAC,WAAW,CAAC,CAAA;IAClC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,MAAM,GAAG,IAAA,qBAAW,EAAC,SAAS,CAAC,CAAA;IACrC,MAAM,cAAc,GAAG,SAAS,CAAC,WAAW,EAAE,CAAA;IAC9C,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC1E,MAAM,kBAAkB,GAAG,GAAG,MAAM,QAAQ,CAAA;IAE5C,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,eAAe,EAAE,CAAC,CAAC,eAAe;QAClC,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,KAAK;QACnC,aAAa,EAAE,CAAC,CAAC,aAAa;QAC9B,kBAAkB,EAAE,CAAC,CAAC,kBAAkB;KACzC,CAAC,CAAC,CAAA;IAEH,MAAM,mBAAmB,GAAG,IAAI,GAAG,CACjC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CACjE,CAAA;IAED,MAAM,SAAS,GAAG,KAAK;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SAC9C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACX,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;KAChD,CAAC,CAAC,CAAA;IAEL,OAAO;;oDAE2C,GAAG;;IAEnD,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;YACE,SAAS,WAAW,GAAG;2BACR,SAAS,OAAO,GAAG;
|
|
1
|
+
{"version":3,"file":"generateRouter.js","sourceRoot":"","sources":["../../src/generators/generateRouter.ts"],"names":[],"mappings":";;AAMA,wDAseC;AA3eD,8CAA8C;AAC9C,uEAAmE;AAEnE,kDAA8C;AAE9C,SAAgB,sB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WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAoED,SAAS;;;;wCAIT,SAAS;;;;;;;;;8HAS6E,MAAM;+FACrC,MAAM;;;;;;4IAMuC,MAAM;+FACnD,MAAM;;;;;;8IAMyC,MAAM;+FACrD,MAAM;;;;;;8HAMyB,MAAM;+FACrC,MAAM;;;;;;sHAMiB,MAAM;+FAC7B,MAAM;;;;;;0HAMqB,MAAM;+FACjC,MAAM;;;;;;8IAMyC,MAAM;+FACrD,MAAM;;;;;;gIAM2B,MAAM;+FACvC,MAAM;;;;;;4HAMuB,MAAM;;;+EAGnD,MAAM;;;;;;;;uDAQ9B,MAAM;;;;;;uDAMN,MAAM;;;;;;uDAMN,MAAM;;;;;;sDAMP,MAAM;;;;;;sDAMN,MAAM;;;;;;sDAMN,MAAM;;;;;;wDAMJ,MAAM;;;;;;yDAML,MAAM;;;;;;yDAMN,MAAM;;;;;;;;;;;;;;;;;;;CAmB9D,CAAA;AACD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-generator-express",
|
|
3
3
|
"description": "Prisma generator for Express, Fastify, and Hono CRUD APIs with OpenAPI documentation",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.45.1",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
${prefix}GroupBy,
|
|
71
71
|
} from './${modelName}Handlers${ext}'
|
|
72
72
|
import * as core from './${modelName}Core${ext}'
|
|
73
|
-
import type { RouteConfig } from '../routeConfig.target${ext}'
|
|
73
|
+
import type { RouteConfig, QueryBuilderConfig } from '../routeConfig.target${ext}'
|
|
74
74
|
import { parseQueryParams } from '../parseQueryParams${ext}'
|
|
75
75
|
import { sanitizeKeys } from '../misc${ext}'
|
|
76
76
|
import { buildModelOpenApi } from '../buildModelOpenApi${ext}'
|
|
@@ -130,14 +130,14 @@ function normalizePrefix(p: string): string {
|
|
|
130
130
|
return result
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
function isQueryBuilderEnabled(config:
|
|
133
|
+
function isQueryBuilderEnabled(config: { queryBuilder?: QueryBuilderConfig | false }): boolean {
|
|
134
134
|
if (config.queryBuilder === false) return false
|
|
135
135
|
if (typeof config.queryBuilder === 'object' && config.queryBuilder.enabled === false) return false
|
|
136
136
|
if (_env.NODE_ENV === 'production') return false
|
|
137
137
|
return true
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
function getQueryBuilderConfig(config:
|
|
140
|
+
function getQueryBuilderConfig(config: { queryBuilder?: QueryBuilderConfig | false }) {
|
|
141
141
|
if (config.queryBuilder === false) return null
|
|
142
142
|
if (typeof config.queryBuilder === 'object') return config.queryBuilder
|
|
143
143
|
return {}
|
|
@@ -342,11 +342,11 @@ const maybeProgressiveSSE = (
|
|
|
342
342
|
const openapiJsonPath = basePath ? \`\${basePath}/openapi.json\` : '/openapi.json'
|
|
343
343
|
const openapiYamlPath = basePath ? \`\${basePath}/openapi.yaml\` : '/openapi.yaml'
|
|
344
344
|
router.get(openapiJsonPath, (_req, res) => {
|
|
345
|
-
const spec = buildModelOpenApi('${modelName}', MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1], MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2], config, { format: 'json' })
|
|
345
|
+
const spec = buildModelOpenApi('${modelName}', MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1], MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2], config as unknown as Parameters<typeof buildModelOpenApi>[3], { format: 'json' })
|
|
346
346
|
res.json(spec)
|
|
347
347
|
})
|
|
348
348
|
router.get(openapiYamlPath, (_req, res) => {
|
|
349
|
-
const spec = buildModelOpenApi('${modelName}', MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1], MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2], config, { format: 'yaml' })
|
|
349
|
+
const spec = buildModelOpenApi('${modelName}', MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1], MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2], config as unknown as Parameters<typeof buildModelOpenApi>[3], { format: 'yaml' })
|
|
350
350
|
res.type('application/yaml').send(spec as string)
|
|
351
351
|
})
|
|
352
352
|
}
|