prisma-generator-express 1.54.0 → 1.55.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 +59 -3
- package/dist/constants.d.ts +1 -0
- package/dist/generators/generateOperationCore.d.ts +2 -0
- package/dist/generators/generateOperationCore.js +30 -3
- package/dist/generators/generateOperationCore.js.map +1 -1
- package/dist/generators/generateRouter.d.ts +3 -1
- package/dist/generators/generateRouter.js +6 -4
- package/dist/generators/generateRouter.js.map +1 -1
- package/dist/generators/generateRouterFastify.d.ts +3 -1
- package/dist/generators/generateRouterFastify.js +6 -4
- package/dist/generators/generateRouterFastify.js.map +1 -1
- package/dist/generators/generateRouterHono.d.ts +3 -1
- package/dist/generators/generateRouterHono.js +6 -3
- package/dist/generators/generateRouterHono.js.map +1 -1
- package/dist/generators/generateUnifiedScalarUI.d.ts +2 -1
- package/dist/generators/generateUnifiedScalarUI.js +13 -10
- package/dist/generators/generateUnifiedScalarUI.js.map +1 -1
- package/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +3 -1
- package/src/copy/buildModelOpenApi.ts +144 -23
- package/src/copy/docsRenderer.ts +121 -95
- package/src/copy/routeConfig.express.ts +2 -0
- package/src/copy/routeConfig.fastify.ts +2 -0
- package/src/copy/routeConfig.hono.ts +2 -0
- package/src/copy/routeConfig.ts +2 -0
- package/src/generators/generateOperationCore.ts +43 -3
- package/src/generators/generateRouter.ts +8 -3
- package/src/generators/generateRouterFastify.ts +8 -3
- package/src/generators/generateRouterHono.ts +8 -2
- package/src/generators/generateUnifiedScalarUI.ts +15 -11
- package/src/index.ts +27 -7
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@ Supports **Express**, **Fastify**, and **Hono** targets via the `target` configu
|
|
|
26
26
|
- [Compatibility](#compatibility)
|
|
27
27
|
- [Installation](#installation)
|
|
28
28
|
- [Setup](#setup)
|
|
29
|
+
- [Write strategy](#write-strategy)
|
|
29
30
|
- [Path casing in generated endpoints](#path-casing-in-generated-endpoints)
|
|
30
31
|
- [Usage (Express)](#usage-express)
|
|
31
32
|
- [Usage (Fastify)](#usage-fastify)
|
|
@@ -62,6 +63,7 @@ Some operations require newer versions:
|
|
|
62
63
|
| Operation | Minimum Prisma version | Notes |
|
|
63
64
|
| --------------------- | ---------------------- | ------------------------------------ |
|
|
64
65
|
| `omit` parameter | 6.2.0 | Returns 400 on versions 6.0.x–6.1.x |
|
|
66
|
+
| `createManyAndReturn` | 5.14.0 | PostgreSQL, CockroachDB, SQLite only |
|
|
65
67
|
| `updateManyAndReturn` | 6.2.0 | PostgreSQL, CockroachDB, SQLite only |
|
|
66
68
|
|
|
67
69
|
### Framework support
|
|
@@ -160,6 +162,37 @@ Generate:
|
|
|
160
162
|
npx prisma generate
|
|
161
163
|
```
|
|
162
164
|
|
|
165
|
+
## Write strategy
|
|
166
|
+
|
|
167
|
+
`writeStrategy` is a schema-wide generator option. It controls only non-returning bulk data writes that have Prisma returning counterparts: `createMany` and `updateMany`. It does not affect `deleteMany`.
|
|
168
|
+
|
|
169
|
+
```prisma
|
|
170
|
+
generator express {
|
|
171
|
+
provider = "prisma-generator-express"
|
|
172
|
+
writeStrategy = "regular"
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Valid values:
|
|
177
|
+
|
|
178
|
+
| Value | Behavior |
|
|
179
|
+
| ----- | -------- |
|
|
180
|
+
| `regular` | Default. `createMany` and `updateMany` call the normal Prisma methods and return `{ count }`. |
|
|
181
|
+
| `throwOnNonReturning` | Disables the generated `createMany` and `updateMany` endpoints (`POST /{modelname}/many` and `PUT /{modelname}/many`). Direct calls return `501`. Use `createManyAndReturn` and `updateManyAndReturn` endpoints instead. |
|
|
182
|
+
| `forceReturn` | `createMany` silently invokes `createManyAndReturn`, and `updateMany` silently invokes `updateManyAndReturn`. These endpoints return arrays of records instead of `{ count }` and support `select`, `include`, and `omit`. |
|
|
183
|
+
|
|
184
|
+
`forceReturn` still follows Prisma provider support. If the current provider does not support `createManyAndReturn` or `updateManyAndReturn`, the generated endpoint returns `501 Not Implemented` at runtime.
|
|
185
|
+
|
|
186
|
+
Example:
|
|
187
|
+
|
|
188
|
+
```prisma
|
|
189
|
+
generator express {
|
|
190
|
+
provider = "prisma-generator-express"
|
|
191
|
+
target = "express"
|
|
192
|
+
writeStrategy = "forceReturn"
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
163
196
|
## Path casing in generated endpoints
|
|
164
197
|
|
|
165
198
|
Model names are converted to **flat lowercase** in URL paths. There is no kebab-case or snake_case conversion — the model name is lowercased character by character.
|
|
@@ -961,7 +994,7 @@ const userConfig = {
|
|
|
961
994
|
}
|
|
962
995
|
```
|
|
963
996
|
|
|
964
|
-
The client can include `include` or `select` in the request body. If the shape does not define projection, the client cannot request one.
|
|
997
|
+
The client can include `include` or `select` in the request body. If the shape does not define projection, the client cannot request one. Non-returning batch methods (`createMany`, `updateMany`, `deleteMany`) do not support projection. When `writeStrategy = "forceReturn"`, the generated `createMany` and `updateMany` endpoints invoke returning methods and can use `select`, `include`, and `omit` like `createManyAndReturn` and `updateManyAndReturn`.
|
|
965
998
|
|
|
966
999
|
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.
|
|
967
1000
|
|
|
@@ -1230,7 +1263,7 @@ All write operations accept the full Prisma args object as the JSON request body
|
|
|
1230
1263
|
{ "where": { "id": 1 }, "create": { "name": "Alice" }, "update": { "name": "Bob" } }
|
|
1231
1264
|
```
|
|
1232
1265
|
|
|
1233
|
-
Write operations that return records (create
|
|
1266
|
+
Write operations that return records (`create`, `update`, `delete`, `upsert`, `createManyAndReturn`, `updateManyAndReturn`) support `select`, `include`, and `omit` in the request body to control the response shape. When `writeStrategy = "forceReturn"`, the generated `createMany` and `updateMany` endpoints are rewritten to returning methods and also support `select`, `include`, and `omit`.
|
|
1234
1267
|
|
|
1235
1268
|
For Express, mount `express.json()` before the router so request bodies are parsed. For Hono, malformed JSON bodies are rejected with 400 (`{ "message": "Invalid JSON in request body" }`) before reaching the handler.
|
|
1236
1269
|
|
|
@@ -1238,6 +1271,8 @@ For Express, mount `express.json()` before the router so request bodies are pars
|
|
|
1238
1271
|
|
|
1239
1272
|
`createMany`, `createManyAndReturn`, `updateMany`, and `updateManyAndReturn` accept scalar-only data inputs. Nested relation writes are not supported in bulk operations.
|
|
1240
1273
|
|
|
1274
|
+
By default, `createMany` and `updateMany` return `{ count }`, while `createManyAndReturn` and `updateManyAndReturn` return arrays of records. With `writeStrategy = "forceReturn"`, the generated `createMany` and `updateMany` endpoints return arrays of records because they invoke the returning Prisma methods internally.
|
|
1275
|
+
|
|
1241
1276
|
### Batch operation safety
|
|
1242
1277
|
|
|
1243
1278
|
`deleteMany`, `updateMany`, and `updateManyAndReturn` require a `where` field in the request body. Requests without `where` are rejected with 400 to prevent accidental mass operations. Sending `{ "where": {} }` is valid and matches all records — this protection catches accidental omission, not intentional broad operations.
|
|
@@ -2605,6 +2640,8 @@ Paths shown are relative suffixes. Actual paths include the model prefix (e.g.,
|
|
|
2605
2640
|
|
|
2606
2641
|
POST read endpoints are enabled by default. Set `disablePostReads: true` to remove them.
|
|
2607
2642
|
|
|
2643
|
+
The schema-wide `writeStrategy` option can change the behavior of `POST /{modelname}/many` and `PUT /{modelname}/many`. It does not change `DELETE /{modelname}/many`.
|
|
2644
|
+
|
|
2608
2645
|
For the Express target, GET read endpoints can also stream SSE events when the request sends `Accept: text/event-stream`. SSE uses the same GET paths shown above; no additional routes are generated. See [Progressive Endpoint Composition](#progressive-endpoint-composition-express-sse).
|
|
2609
2646
|
|
|
2610
2647
|
## Skipping models
|
|
@@ -2620,6 +2657,23 @@ model InternalLog {
|
|
|
2620
2657
|
|
|
2621
2658
|
## Configuration
|
|
2622
2659
|
|
|
2660
|
+
### Generator options
|
|
2661
|
+
|
|
2662
|
+
Generator options are configured in `schema.prisma` and apply schema-wide.
|
|
2663
|
+
|
|
2664
|
+
```prisma
|
|
2665
|
+
generator express {
|
|
2666
|
+
provider = "prisma-generator-express"
|
|
2667
|
+
target = "express"
|
|
2668
|
+
writeStrategy = "regular"
|
|
2669
|
+
}
|
|
2670
|
+
```
|
|
2671
|
+
|
|
2672
|
+
| Option | Values | Default | Description |
|
|
2673
|
+
| ------ | ------ | ------- | ----------- |
|
|
2674
|
+
| `target` | `"express"`, `"fastify"`, `"hono"` | `"express"` | Selects the generated router target. |
|
|
2675
|
+
| `writeStrategy` | `"regular"`, `"throwOnNonReturning"`, `"forceReturn"` | `"regular"` | Controls only `createMany` and `updateMany`. See [Write strategy](#write-strategy). |
|
|
2676
|
+
|
|
2623
2677
|
### Express
|
|
2624
2678
|
|
|
2625
2679
|
```ts
|
|
@@ -2783,7 +2837,9 @@ The `guard.resolveVariant` callback receives Hono's `Context`. Hooks are native
|
|
|
2783
2837
|
|
|
2784
2838
|
The Hono router does not auto-start the Query Builder. Set `queryBuilder: false` to make the playground route return 404, or run `prisma-query-builder-ui` manually for development.
|
|
2785
2839
|
|
|
2786
|
-
### Shared options
|
|
2840
|
+
### Shared route options
|
|
2841
|
+
|
|
2842
|
+
These options are passed to the generated router at runtime. They are separate from schema-wide generator options such as `target` and `writeStrategy`.
|
|
2787
2843
|
|
|
2788
2844
|
`customUrlPrefix` is normalized to ensure a leading slash and strip trailing slashes.
|
|
2789
2845
|
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { DMMF } from '@prisma/generator-helper';
|
|
2
2
|
import { ImportStyle } from '../utils/resolveImportStyle';
|
|
3
|
+
import { WriteStrategy } from '../constants';
|
|
3
4
|
export interface ModelCoreOptions {
|
|
4
5
|
model: DMMF.Model;
|
|
5
6
|
importStyle: ImportStyle;
|
|
7
|
+
writeStrategy: WriteStrategy;
|
|
6
8
|
}
|
|
7
9
|
export declare function generateModelCore(options: ModelCoreOptions): string;
|
|
@@ -2,10 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateModelCore = generateModelCore;
|
|
4
4
|
const importExt_1 = require("../utils/importExt");
|
|
5
|
+
function decideWriteOp(name, defaultMethod, strategy) {
|
|
6
|
+
if (strategy === 'regular') {
|
|
7
|
+
return { mode: 'normal', method: defaultMethod };
|
|
8
|
+
}
|
|
9
|
+
if (strategy === 'throwOnNonReturning') {
|
|
10
|
+
if (name === 'createMany' || name === 'updateMany') {
|
|
11
|
+
return { mode: 'throw' };
|
|
12
|
+
}
|
|
13
|
+
return { mode: 'normal', method: defaultMethod };
|
|
14
|
+
}
|
|
15
|
+
if (name === 'createMany')
|
|
16
|
+
return { mode: 'redirect', method: 'createManyAndReturn' };
|
|
17
|
+
if (name === 'updateMany')
|
|
18
|
+
return { mode: 'redirect', method: 'updateManyAndReturn' };
|
|
19
|
+
return { mode: 'normal', method: defaultMethod };
|
|
20
|
+
}
|
|
5
21
|
function generateModelCore(options) {
|
|
6
22
|
const ext = (0, importExt_1.importExt)(options.importStyle);
|
|
7
23
|
const modelName = options.model.name;
|
|
8
24
|
const modelNameLower = modelName.charAt(0).toLowerCase() + modelName.slice(1);
|
|
25
|
+
const writeStrategy = options.writeStrategy;
|
|
9
26
|
const standardReadOps = [
|
|
10
27
|
'findFirst', 'findUnique', 'findUniqueOrThrow', 'findFirstOrThrow',
|
|
11
28
|
'count', 'aggregate', 'groupBy',
|
|
@@ -35,7 +52,17 @@ export async function ${op}(ctx: OperationContext): Promise<unknown> {
|
|
|
35
52
|
{ name: 'upsert', method: 'upsert', requiredFields: ['where', 'create', 'update'] },
|
|
36
53
|
];
|
|
37
54
|
const writeHandlers = writeOps.map((op) => {
|
|
38
|
-
const
|
|
55
|
+
const decision = decideWriteOp(op.name, op.method, writeStrategy);
|
|
56
|
+
if (decision.mode === 'throw') {
|
|
57
|
+
return `
|
|
58
|
+
export async function ${op.name}(_ctx: OperationContext): Promise<unknown> {
|
|
59
|
+
throw new HttpError(501, '${op.name} is disabled by writeStrategy="${writeStrategy}"')
|
|
60
|
+
}`;
|
|
61
|
+
}
|
|
62
|
+
const method = decision.method;
|
|
63
|
+
const validationLines = op.requiredFields
|
|
64
|
+
.map((field) => ` requireBodyField(body, '${field}')`)
|
|
65
|
+
.join('\n');
|
|
39
66
|
return `
|
|
40
67
|
export async function ${op.name}(ctx: OperationContext): Promise<unknown> {
|
|
41
68
|
const body = validateBody(ctx.body)
|
|
@@ -44,9 +71,9 @@ ${validationLines}
|
|
|
44
71
|
const delegate = getDelegate(extended, '${modelNameLower}')
|
|
45
72
|
if (ctx.guardShape) {
|
|
46
73
|
assertGuard(delegate)
|
|
47
|
-
return delegate.guard(ctx.guardShape, ctx.guardCaller).${
|
|
74
|
+
return delegate.guard(ctx.guardShape, ctx.guardCaller).${method}(body)
|
|
48
75
|
}
|
|
49
|
-
return delegate.${
|
|
76
|
+
return delegate.${method}(body)
|
|
50
77
|
}`;
|
|
51
78
|
}).join('\n');
|
|
52
79
|
return `import {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateOperationCore.js","sourceRoot":"","sources":["../../src/generators/generateOperationCore.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"generateOperationCore.js","sourceRoot":"","sources":["../../src/generators/generateOperationCore.ts"],"names":[],"mappings":";;AAmCA,8CAwLC;AAzND,kDAA8C;AAc9C,SAAS,aAAa,CACpB,IAAY,EACZ,aAAqB,EACrB,QAAuB;IAEvB,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,CAAA;IAClD,CAAC;IACD,IAAI,QAAQ,KAAK,qBAAqB,EAAE,CAAC;QACvC,IAAI,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC;YACnD,OAAO,EAAE,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AG,EAAE,CAAC,cAAc;aACtC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,6BAA6B,KAAK,IAAI,CAAC;aACtD,IAAI,CAAC,IAAI,CAAC,CAAA;QAEb,OAAO;wBACa,EAAE,CAAC,IAAI;;EAE7B,eAAe;;4CAE2B,cAAc;;;6DAGG,MAAM;;oBAE/C,MAAM;EACxB,CAAA;IACA,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEb,OAAO;;;;;;;;;;;;6BAYoB,GAAG;;;;;;4CAMY,cAAc;;;;;;;EAOxD,oBAAoB;EACpB,aAAa;;;;;;;;;;;4CAW6B,cAAc;;;;;;;;;;;;;;;;;;;;;8CAqBZ,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0CAqClB,cAAc;;;;;;;;;;;;;;;;;;;;;;CAsBvD,CAAA;AACD,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { DMMF } from '@prisma/generator-helper';
|
|
2
2
|
import { ImportStyle } from '../utils/resolveImportStyle';
|
|
3
|
-
|
|
3
|
+
import { WriteStrategy } from '../constants';
|
|
4
|
+
export declare function generateRouterFunction({ model, enums, guardShapesImport, importStyle, writeStrategy, }: {
|
|
4
5
|
model: DMMF.Model;
|
|
5
6
|
enums: DMMF.DatamodelEnum[];
|
|
6
7
|
guardShapesImport: string | null;
|
|
7
8
|
importStyle: ImportStyle;
|
|
9
|
+
writeStrategy: WriteStrategy;
|
|
8
10
|
}): string;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generateRouterFunction = generateRouterFunction;
|
|
4
4
|
const generateRouteConfigType_1 = require("./generateRouteConfigType");
|
|
5
5
|
const importExt_1 = require("../utils/importExt");
|
|
6
|
-
function generateRouterFunction({ model, enums, guardShapesImport, importStyle, }) {
|
|
6
|
+
function generateRouterFunction({ model, enums, guardShapesImport, importStyle, writeStrategy, }) {
|
|
7
7
|
const ext = (0, importExt_1.importExt)(importStyle);
|
|
8
8
|
const modelName = model.name;
|
|
9
9
|
const modelNameLower = modelName.toLowerCase();
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
${modelName}GroupBy,
|
|
52
52
|
} from './${modelName}Handlers${ext}'
|
|
53
53
|
import * as core from './${modelName}Core${ext}'
|
|
54
|
-
import type { RouteConfig, QueryBuilderConfig } from '../routeConfig.target${ext}'
|
|
54
|
+
import type { RouteConfig, QueryBuilderConfig, WriteStrategy } from '../routeConfig.target${ext}'
|
|
55
55
|
import { parseQueryParams } from '../parseQueryParams${ext}'
|
|
56
56
|
import { sanitizeKeys, normalizePrefix, getEnv } from '../misc${ext}'
|
|
57
57
|
import { buildModelOpenApi } from '../buildModelOpenApi${ext}'
|
|
@@ -72,6 +72,8 @@ import { runAutoIncludeProgressive } from '../autoIncludeRuntime${ext}'
|
|
|
72
72
|
${(0, generateRouteConfigType_1.generateRouteConfigType)(modelName, 'RequestHandler', guardShapesImport, importStyle, 'express')}
|
|
73
73
|
const _env = getEnv()
|
|
74
74
|
|
|
75
|
+
const WRITE_STRATEGY: WriteStrategy = '${writeStrategy}'
|
|
76
|
+
|
|
75
77
|
const MODEL_FIELDS = ${JSON.stringify(fieldsMeta, null, 2)} as const
|
|
76
78
|
const MODEL_ENUMS = ${JSON.stringify(enumsMeta, null, 2)} as const
|
|
77
79
|
|
|
@@ -138,7 +140,7 @@ export function ${routerFunctionName}<TCtx = unknown, TPrisma = any>(config: ${m
|
|
|
138
140
|
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
139
141
|
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
140
142
|
config as unknown as Parameters<typeof buildModelOpenApi>[3],
|
|
141
|
-
{ format: 'json' },
|
|
143
|
+
{ format: 'json', writeStrategy: WRITE_STRATEGY },
|
|
142
144
|
)
|
|
143
145
|
const openApiYamlSpec = openApiDisabled
|
|
144
146
|
? null
|
|
@@ -147,7 +149,7 @@ export function ${routerFunctionName}<TCtx = unknown, TPrisma = any>(config: ${m
|
|
|
147
149
|
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
148
150
|
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
149
151
|
config as unknown as Parameters<typeof buildModelOpenApi>[3],
|
|
150
|
-
{ format: 'yaml' },
|
|
152
|
+
{ format: 'yaml', writeStrategy: WRITE_STRATEGY },
|
|
151
153
|
)
|
|
152
154
|
|
|
153
155
|
const qbEnabled = isQueryBuilderEnabled(config)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateRouter.js","sourceRoot":"","sources":["../../src/generators/generateRouter.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"generateRouter.js","sourceRoot":"","sources":["../../src/generators/generateRouter.ts"],"names":[],"mappings":";;AAMA,wDAqgBC;AA1gBD,uEAAmE;AAEnE,kDAA8C;AAG9C,SAAgB,sBAAsB,CAAC,EACrC,KAAK,EACL,KAAK,EACL,iBAAiB,EACjB,WAAW,EACX,aAAa,GAOd;IACC,MAAM,GAAG,GAAG,IAAA,qBAAS,EAAC,WAAW,CAAC,CAAA;IAClC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,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,SAAS,QAAQ,CAAA;IAE/C,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,IA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;;;;;;;;;;;;;;;;;;;CAwCjE,CAAA;AACD,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { DMMF } from '@prisma/generator-helper';
|
|
2
2
|
import { ImportStyle } from '../utils/resolveImportStyle';
|
|
3
|
-
|
|
3
|
+
import { WriteStrategy } from '../constants';
|
|
4
|
+
export declare function generateFastifyRouterFunction({ model, enums, guardShapesImport, importStyle, writeStrategy, }: {
|
|
4
5
|
model: DMMF.Model;
|
|
5
6
|
enums: DMMF.DatamodelEnum[];
|
|
6
7
|
guardShapesImport: string | null;
|
|
7
8
|
importStyle: ImportStyle;
|
|
9
|
+
writeStrategy: WriteStrategy;
|
|
8
10
|
}): string;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generateFastifyRouterFunction = generateFastifyRouterFunction;
|
|
4
4
|
const generateRouteConfigType_1 = require("./generateRouteConfigType");
|
|
5
5
|
const importExt_1 = require("../utils/importExt");
|
|
6
|
-
function generateFastifyRouterFunction({ model, enums, guardShapesImport, importStyle, }) {
|
|
6
|
+
function generateFastifyRouterFunction({ model, enums, guardShapesImport, importStyle, writeStrategy, }) {
|
|
7
7
|
const ext = (0, importExt_1.importExt)(importStyle);
|
|
8
8
|
const modelName = model.name;
|
|
9
9
|
const modelNameLower = modelName.toLowerCase();
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
${modelName}Count,
|
|
49
49
|
${modelName}GroupBy,
|
|
50
50
|
} from './${modelName}Handlers${ext}'
|
|
51
|
-
import type { RouteConfig, FastifyHookHandler } from '../routeConfig.target${ext}'
|
|
51
|
+
import type { RouteConfig, FastifyHookHandler, WriteStrategy } from '../routeConfig.target${ext}'
|
|
52
52
|
import { parseQueryParams } from '../parseQueryParams${ext}'
|
|
53
53
|
import { sanitizeKeys, normalizePrefix, getEnv } from '../misc${ext}'
|
|
54
54
|
import { buildModelOpenApi } from '../buildModelOpenApi${ext}'
|
|
@@ -57,6 +57,8 @@ import { mapError, transformResult, HttpError, type OperationContext } from '../
|
|
|
57
57
|
${(0, generateRouteConfigType_1.generateRouteConfigType)(modelName, 'FastifyHookHandler', guardShapesImport, importStyle, 'fastify')}
|
|
58
58
|
const _env = getEnv()
|
|
59
59
|
|
|
60
|
+
const WRITE_STRATEGY: WriteStrategy = '${writeStrategy}'
|
|
61
|
+
|
|
60
62
|
const MODEL_FIELDS = ${JSON.stringify(fieldsMeta, null, 2)} as const
|
|
61
63
|
|
|
62
64
|
const MODEL_ENUMS = ${JSON.stringify(enumsMeta, null, 2)} as const
|
|
@@ -187,7 +189,7 @@ export async function ${routerFunctionName}<TCtx = unknown, TPrisma = any>(
|
|
|
187
189
|
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
188
190
|
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
189
191
|
config,
|
|
190
|
-
{ format: 'json' },
|
|
192
|
+
{ format: 'json', writeStrategy: WRITE_STRATEGY },
|
|
191
193
|
)
|
|
192
194
|
const openApiYamlSpec = openApiDisabled
|
|
193
195
|
? null
|
|
@@ -196,7 +198,7 @@ export async function ${routerFunctionName}<TCtx = unknown, TPrisma = any>(
|
|
|
196
198
|
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
197
199
|
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
198
200
|
config,
|
|
199
|
-
{ format: 'yaml' },
|
|
201
|
+
{ format: 'yaml', writeStrategy: WRITE_STRATEGY },
|
|
200
202
|
)
|
|
201
203
|
|
|
202
204
|
const qbEnabled = isQueryBuilderEnabled(config)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateRouterFastify.js","sourceRoot":"","sources":["../../src/generators/generateRouterFastify.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"generateRouterFastify.js","sourceRoot":"","sources":["../../src/generators/generateRouterFastify.ts"],"names":[],"mappings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AS;;;;;;4CAMhC,SAAS;mEACc,SAAS;;;;;;4CAMhC,SAAS;mEACc,SAAS;;;;;;4CAMhC,SAAS;mEACc,SAAS;;;;;;4CAMhC,SAAS;mEACc,SAAS;;;;;;4CAMhC,SAAS;;;mDAGF,SAAS;;;;;;;+CAOb,SAAS;;;;;;+CAMT,SAAS;;;;;;+CAMT,SAAS;;;;;;8CAMV,SAAS;;;;;;8CAMT,SAAS;;;;;;8CAMT,SAAS;;;;;;gDAMP,SAAS;;;;;;iDAMR,SAAS;;;;;;iDAMT,SAAS;;;CAGzD,CAAA;AACD,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { DMMF } from '@prisma/generator-helper';
|
|
2
2
|
import { ImportStyle } from '../utils/resolveImportStyle';
|
|
3
|
-
|
|
3
|
+
import { WriteStrategy } from '../constants';
|
|
4
|
+
export declare function generateHonoRouterFunction({ model, enums, guardShapesImport, importStyle, writeStrategy, }: {
|
|
4
5
|
model: DMMF.Model;
|
|
5
6
|
enums: DMMF.DatamodelEnum[];
|
|
6
7
|
guardShapesImport: string | null;
|
|
7
8
|
importStyle: ImportStyle;
|
|
9
|
+
writeStrategy: WriteStrategy;
|
|
8
10
|
}): string;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generateHonoRouterFunction = generateHonoRouterFunction;
|
|
4
4
|
const generateRouteConfigType_1 = require("./generateRouteConfigType");
|
|
5
5
|
const importExt_1 = require("../utils/importExt");
|
|
6
|
-
function generateHonoRouterFunction({ model, enums, guardShapesImport, importStyle, }) {
|
|
6
|
+
function generateHonoRouterFunction({ model, enums, guardShapesImport, importStyle, writeStrategy, }) {
|
|
7
7
|
const ext = (0, importExt_1.importExt)(importStyle);
|
|
8
8
|
const modelName = model.name;
|
|
9
9
|
const modelNameLower = modelName.toLowerCase();
|
|
@@ -57,6 +57,7 @@ import type {
|
|
|
57
57
|
HonoEnvBase,
|
|
58
58
|
HonoInternalVariables,
|
|
59
59
|
GeneratedHonoEnv,
|
|
60
|
+
WriteStrategy,
|
|
60
61
|
} from '../routeConfig.target${ext}'
|
|
61
62
|
import { parseQueryParams } from '../parseQueryParams${ext}'
|
|
62
63
|
import { sanitizeKeys, normalizePrefix, getEnv } from '../misc${ext}'
|
|
@@ -66,6 +67,8 @@ import { mapError, transformResult, type OperationContext } from '../operationRu
|
|
|
66
67
|
${(0, generateRouteConfigType_1.generateRouteConfigType)(modelName, 'HonoHookHandler', guardShapesImport, importStyle, 'hono')}
|
|
67
68
|
const _env = getEnv()
|
|
68
69
|
|
|
70
|
+
const WRITE_STRATEGY: WriteStrategy = '${writeStrategy}'
|
|
71
|
+
|
|
69
72
|
const MODEL_FIELDS = ${JSON.stringify(fieldsMeta, null, 2)} as const
|
|
70
73
|
|
|
71
74
|
const MODEL_ENUMS = ${JSON.stringify(enumsMeta, null, 2)} as const
|
|
@@ -208,7 +211,7 @@ export function ${routerFunctionName}<TCtx = unknown, TPrisma = any, TEnv extend
|
|
|
208
211
|
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
209
212
|
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
210
213
|
config as RouteConfig,
|
|
211
|
-
{ format: 'json' },
|
|
214
|
+
{ format: 'json', writeStrategy: WRITE_STRATEGY },
|
|
212
215
|
)
|
|
213
216
|
const openApiYamlSpec = openApiDisabled
|
|
214
217
|
? null
|
|
@@ -217,7 +220,7 @@ export function ${routerFunctionName}<TCtx = unknown, TPrisma = any, TEnv extend
|
|
|
217
220
|
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
218
221
|
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
219
222
|
config as RouteConfig,
|
|
220
|
-
{ format: 'yaml' },
|
|
223
|
+
{ format: 'yaml', writeStrategy: WRITE_STRATEGY },
|
|
221
224
|
)
|
|
222
225
|
|
|
223
226
|
if (isQueryBuilderEnabled(config as RouteConfig)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateRouterHono.js","sourceRoot":"","sources":["../../src/generators/generateRouterHono.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"generateRouterHono.js","sourceRoot":"","sources":["../../src/generators/generateRouterHono.ts"],"names":[],"mappings":";;AAMA,gEAiaC;AAtaD,uEAAmE;AAEnE,kDAA8C;AAG9C,SAAgB,0BAA0B,CAAC,EACzC,KAAK,EACL,KAAK,EACL,iBAAiB,EACjB,WAAW,EACX,aAAa,GAOd;IACC,MAAM,GAAG,GAAG,IAAA,qBAAS,EAAC,WAAW,CAAC,CAAA;IAClC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,cAAc,GAAG,SAAS,CAAC,WAAW,EAAE,CAAA;IAC9C,MAAM,kBAAkB,GAAG,GAAG,SAAS,QAAQ,CAAA;IAE/C,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,EAA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Ac/D,SAAS;;;;;;;;;WAST,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCA0Ee,SAAS;;;;;;;;yCAQH,SAAS;gEACc,SAAS;;;;;yCAKhC,SAAS;gEACc,SAAS;;;;;yCAKhC,SAAS;gEACc,SAAS;;;;;yCAKhC,SAAS;gEACc,SAAS;;;;;yCAKhC,SAAS;gEACc,SAAS;;;;;yCAKhC,SAAS;gEACc,SAAS;;;;;yCAKhC,SAAS;gEACc,SAAS;;;;;yCAKhC,SAAS;gEACc,SAAS;;;;;yCAKhC,SAAS;;;gDAGF,SAAS;;;;;;;2CAOd,SAAS;;;;;2CAKT,SAAS;;;;;2CAKT,SAAS;;;;;0CAKV,SAAS;;;;;0CAKT,SAAS;;;;;0CAKT,SAAS;;;;;4CAKP,SAAS;;;;;6CAKR,SAAS;;;;;6CAKT,SAAS;;;;;CAKrD,CAAA;AACD,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { DMMF } from '@prisma/generator-helper';
|
|
2
|
-
import { Target } from '../constants';
|
|
2
|
+
import { Target, WriteStrategy } from '../constants';
|
|
3
3
|
import { ImportStyle } from '../utils/resolveImportStyle';
|
|
4
4
|
export declare function generateScalarUIHandler(options: {
|
|
5
5
|
model: DMMF.Model;
|
|
6
6
|
enums: DMMF.DatamodelEnum[];
|
|
7
7
|
target?: Target;
|
|
8
8
|
importStyle: ImportStyle;
|
|
9
|
+
writeStrategy: WriteStrategy;
|
|
9
10
|
}): string;
|
|
@@ -49,7 +49,7 @@ function generateExpressDocsExport(modelName) {
|
|
|
49
49
|
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
50
50
|
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
51
51
|
config,
|
|
52
|
-
{ format: 'yaml' }
|
|
52
|
+
{ format: 'yaml', writeStrategy: WRITE_STRATEGY }
|
|
53
53
|
)
|
|
54
54
|
return res.type('application/yaml').send(yaml as string)
|
|
55
55
|
}
|
|
@@ -59,7 +59,7 @@ function generateExpressDocsExport(modelName) {
|
|
|
59
59
|
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
60
60
|
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
61
61
|
config,
|
|
62
|
-
{ format: 'json' }
|
|
62
|
+
{ format: 'json', writeStrategy: WRITE_STRATEGY }
|
|
63
63
|
)
|
|
64
64
|
|
|
65
65
|
if (ui === 'json') return res.json(spec)
|
|
@@ -70,7 +70,7 @@ function generateExpressDocsExport(modelName) {
|
|
|
70
70
|
return res.type('html').send(renderScalar('${modelName}', spec, pageTitle, config.scalarCdnUrl))
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
const html = renderDocs('${modelName}', config, MODEL_CONTEXT)
|
|
73
|
+
const html = renderDocs('${modelName}', config, MODEL_CONTEXT, WRITE_STRATEGY)
|
|
74
74
|
return res.type('html').send(html)
|
|
75
75
|
}
|
|
76
76
|
}`;
|
|
@@ -99,7 +99,7 @@ function generateFastifyDocsExport(modelName) {
|
|
|
99
99
|
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
100
100
|
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
101
101
|
config,
|
|
102
|
-
{ format: 'yaml' }
|
|
102
|
+
{ format: 'yaml', writeStrategy: WRITE_STRATEGY }
|
|
103
103
|
)
|
|
104
104
|
reply.type('application/yaml').send(yaml as string); return
|
|
105
105
|
}
|
|
@@ -109,7 +109,7 @@ function generateFastifyDocsExport(modelName) {
|
|
|
109
109
|
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
110
110
|
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
111
111
|
config,
|
|
112
|
-
{ format: 'json' }
|
|
112
|
+
{ format: 'json', writeStrategy: WRITE_STRATEGY }
|
|
113
113
|
)
|
|
114
114
|
|
|
115
115
|
if (ui === 'json') { reply.send(spec); return }
|
|
@@ -120,7 +120,7 @@ function generateFastifyDocsExport(modelName) {
|
|
|
120
120
|
reply.type('text/html').send(renderScalar('${modelName}', spec, pageTitle, config.scalarCdnUrl)); return
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
const html = renderDocs('${modelName}', config, MODEL_CONTEXT)
|
|
123
|
+
const html = renderDocs('${modelName}', config, MODEL_CONTEXT, WRITE_STRATEGY)
|
|
124
124
|
reply.type('text/html').send(html)
|
|
125
125
|
}
|
|
126
126
|
}`;
|
|
@@ -148,7 +148,7 @@ function generateHonoDocsExport(modelName) {
|
|
|
148
148
|
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
149
149
|
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
150
150
|
config,
|
|
151
|
-
{ format: 'yaml' }
|
|
151
|
+
{ format: 'yaml', writeStrategy: WRITE_STRATEGY }
|
|
152
152
|
) as string
|
|
153
153
|
return c.body(yaml, 200, { 'Content-Type': 'application/yaml' })
|
|
154
154
|
}
|
|
@@ -158,7 +158,7 @@ function generateHonoDocsExport(modelName) {
|
|
|
158
158
|
MODEL_FIELDS as unknown as Parameters<typeof buildModelOpenApi>[1],
|
|
159
159
|
MODEL_ENUMS as unknown as Parameters<typeof buildModelOpenApi>[2],
|
|
160
160
|
config,
|
|
161
|
-
{ format: 'json' }
|
|
161
|
+
{ format: 'json', writeStrategy: WRITE_STRATEGY }
|
|
162
162
|
)
|
|
163
163
|
|
|
164
164
|
if (ui === 'json') return c.json(spec as Record<string, unknown>)
|
|
@@ -169,13 +169,13 @@ function generateHonoDocsExport(modelName) {
|
|
|
169
169
|
return c.html(renderScalar('${modelName}', spec, pageTitle, config.scalarCdnUrl))
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
const html = renderDocs('${modelName}', config, MODEL_CONTEXT)
|
|
172
|
+
const html = renderDocs('${modelName}', config, MODEL_CONTEXT, WRITE_STRATEGY)
|
|
173
173
|
return c.html(html)
|
|
174
174
|
}
|
|
175
175
|
}`;
|
|
176
176
|
}
|
|
177
177
|
function generateScalarUIHandler(options) {
|
|
178
|
-
const { model, enums } = options;
|
|
178
|
+
const { model, enums, writeStrategy } = options;
|
|
179
179
|
const target = options.target || 'express';
|
|
180
180
|
const ext = (0, importExt_1.importExt)(options.importStyle);
|
|
181
181
|
const modelName = model.name;
|
|
@@ -229,6 +229,7 @@ function generateScalarUIHandler(options) {
|
|
|
229
229
|
: generateExpressDocsExport(modelName);
|
|
230
230
|
return `${frameworkImport}
|
|
231
231
|
import { buildModelOpenApi } from '../buildModelOpenApi${ext}'
|
|
232
|
+
import type { WriteStrategy } from '../routeConfig${ext}'
|
|
232
233
|
import {
|
|
233
234
|
renderDocs,
|
|
234
235
|
renderScalar,
|
|
@@ -242,6 +243,8 @@ import {
|
|
|
242
243
|
type DocsModelContext,
|
|
243
244
|
} from '../docsRenderer${ext}'
|
|
244
245
|
|
|
246
|
+
const WRITE_STRATEGY: WriteStrategy = '${writeStrategy}'
|
|
247
|
+
|
|
245
248
|
export const MODEL_FIELDS: FieldMeta[] = ${JSON.stringify(fieldsMeta, null, 2)}
|
|
246
249
|
|
|
247
250
|
export const MODEL_ENUMS: EnumMeta[] = ${JSON.stringify(enumsMeta, null, 2)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateUnifiedScalarUI.js","sourceRoot":"","sources":["../../src/generators/generateUnifiedScalarUI.ts"],"names":[],"mappings":";;AAqLA,
|
|
1
|
+
{"version":3,"file":"generateUnifiedScalarUI.js","sourceRoot":"","sources":["../../src/generators/generateUnifiedScalarUI.ts"],"names":[],"mappings":";;AAqLA,0DAsHC;AAxSD,kDAA8C;AAE9C,SAAS,mBAAmB,CAAC,SAAiB;IAC5C,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO,SAAS,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