prisma-generator-express 1.28.0 → 1.30.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.
Files changed (49) hide show
  1. package/README.md +244 -14
  2. package/dist/constants.d.ts +1 -0
  3. package/dist/generators/generateFastifyHandler.d.ts +4 -0
  4. package/dist/generators/generateFastifyHandler.js +78 -0
  5. package/dist/generators/generateFastifyHandler.js.map +1 -0
  6. package/dist/generators/generateOperationCore.d.ts +6 -0
  7. package/dist/generators/generateOperationCore.js +534 -0
  8. package/dist/generators/generateOperationCore.js.map +1 -0
  9. package/dist/generators/generateQueryBuilderHelper.js +85 -69
  10. package/dist/generators/generateQueryBuilderHelper.js.map +1 -1
  11. package/dist/generators/generateRouter.js +1 -25
  12. package/dist/generators/generateRouter.js.map +1 -1
  13. package/dist/generators/generateRouterFastify.d.ts +5 -0
  14. package/dist/generators/generateRouterFastify.js +512 -0
  15. package/dist/generators/generateRouterFastify.js.map +1 -0
  16. package/dist/generators/generateUnifiedDocs.d.ts +2 -1
  17. package/dist/generators/generateUnifiedDocs.js +147 -82
  18. package/dist/generators/generateUnifiedDocs.js.map +1 -1
  19. package/dist/generators/generateUnifiedHandler.d.ts +0 -1
  20. package/dist/generators/generateUnifiedHandler.js +47 -516
  21. package/dist/generators/generateUnifiedHandler.js.map +1 -1
  22. package/dist/generators/generateUnifiedScalarUI.d.ts +2 -0
  23. package/dist/generators/generateUnifiedScalarUI.js +127 -1324
  24. package/dist/generators/generateUnifiedScalarUI.js.map +1 -1
  25. package/dist/index.js +33 -8
  26. package/dist/index.js.map +1 -1
  27. package/dist/utils/copyFiles.d.ts +2 -1
  28. package/dist/utils/copyFiles.js +73 -39
  29. package/dist/utils/copyFiles.js.map +1 -1
  30. package/dist/utils/writeFileSafely.js +3 -0
  31. package/dist/utils/writeFileSafely.js.map +1 -1
  32. package/package.json +4 -1
  33. package/src/client/encodeQueryParams.ts +1 -1
  34. package/src/constants.ts +2 -0
  35. package/src/copy/createOutputValidatorMiddleware.ts +9 -12
  36. package/src/copy/docsRenderer.ts +1285 -0
  37. package/src/copy/parseQueryParams.ts +4 -8
  38. package/src/copy/routeConfig.ts +10 -4
  39. package/src/generators/generateFastifyHandler.ts +86 -0
  40. package/src/generators/generateOperationCore.ts +545 -0
  41. package/src/generators/generateQueryBuilderHelper.ts +86 -70
  42. package/src/generators/generateRouter.ts +1 -25
  43. package/src/generators/generateRouterFastify.ts +522 -0
  44. package/src/generators/generateUnifiedDocs.ts +164 -81
  45. package/src/generators/generateUnifiedHandler.ts +45 -533
  46. package/src/generators/generateUnifiedScalarUI.ts +134 -1323
  47. package/src/index.ts +45 -9
  48. package/src/utils/copyFiles.ts +88 -44
  49. package/src/utils/writeFileSafely.ts +4 -0
@@ -1,530 +1,61 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateUnifiedHandler = generateUnifiedHandler;
4
+ const ALL_OPS = [
5
+ 'findMany',
6
+ 'findFirst',
7
+ 'findFirstOrThrow',
8
+ 'findUnique',
9
+ 'findUniqueOrThrow',
10
+ 'findManyPaginated',
11
+ 'create',
12
+ 'createMany',
13
+ 'createManyAndReturn',
14
+ 'update',
15
+ 'updateMany',
16
+ 'updateManyAndReturn',
17
+ 'upsert',
18
+ 'delete',
19
+ 'deleteMany',
20
+ 'aggregate',
21
+ 'count',
22
+ 'groupBy',
23
+ ];
4
24
  function generateUnifiedHandler(options) {
5
- const { model, prismaImportStatement } = options;
6
- const modelName = model.name;
7
- const modelNameLower = modelName.charAt(0).toLowerCase() + modelName.slice(1);
8
- const importPath = prismaImportStatement.match(/from ['"](.+?)['"]/)?.[1] || '';
9
- return `
10
- import { PrismaClient } from '${importPath}'
11
- import { Request, Response, NextFunction } from 'express'
12
- import { sanitizeKeys } from '../misc'
13
-
14
- let _speedExtension: ((opts: any) => any) | null = null
15
-
16
- const _prismasqlModule = 'prisma-' + 'sql'
17
- const _prismasqlReady = (async () => {
18
- try {
19
- const mod = await import(_prismasqlModule)
20
- _speedExtension = mod.speedExtension ?? mod.default?.speedExtension ?? null
21
- } catch (err: any) {
22
- const code = err?.code
23
- if (code !== 'MODULE_NOT_FOUND' && code !== 'ERR_MODULE_NOT_FOUND') {
24
- console.warn('[prisma-generator-express] prisma-sql initialization failed:', err)
25
- }
26
- }
27
- })()
28
-
29
- const _extendedClients = new WeakMap<object, WeakMap<object, PrismaClient>>()
30
-
31
- const DISTINCT_COUNT_LIMIT = 100000
32
-
33
- export class HttpError extends Error {
34
- status: number
35
- constructor(status: number, message: string) {
36
- super(message)
37
- this.name = 'HttpError'
38
- this.status = status
39
- }
40
- }
41
-
42
- const PRISMA_ERROR_MAP: Record<string, { status: number; message: string }> = {
43
- P2000: { status: 400, message: 'Value too long for column' },
44
- P2001: { status: 404, message: 'Record not found' },
45
- P2002: { status: 409, message: 'Unique constraint violation' },
46
- P2003: { status: 400, message: 'Foreign key constraint failed' },
47
- P2004: { status: 400, message: 'Constraint failed on the database' },
48
- P2005: { status: 400, message: 'Invalid field value' },
49
- P2006: { status: 400, message: 'Invalid value provided' },
50
- P2007: { status: 400, message: 'Data validation error' },
51
- P2008: { status: 400, message: 'Failed to parse the query' },
52
- P2009: { status: 400, message: 'Failed to validate the query' },
53
- P2010: { status: 500, message: 'Raw query failed' },
54
- P2011: { status: 400, message: 'Null constraint violation' },
55
- P2012: { status: 400, message: 'Missing required value' },
56
- P2013: { status: 400, message: 'Missing required argument' },
57
- P2014: { status: 400, message: 'Required relation violation' },
58
- P2015: { status: 404, message: 'Related record not found' },
59
- P2016: { status: 400, message: 'Query interpretation error' },
60
- P2017: { status: 400, message: 'Records not connected' },
61
- P2018: { status: 404, message: 'Required connected record not found' },
62
- P2019: { status: 400, message: 'Input error' },
63
- P2020: { status: 400, message: 'Value out of range for the field type' },
64
- P2021: { status: 500, message: 'Table does not exist in the database' },
65
- P2022: { status: 500, message: 'Column does not exist in the database' },
66
- P2023: { status: 500, message: 'Inconsistent column data' },
67
- P2024: { status: 503, message: 'Connection pool timeout' },
68
- P2025: { status: 404, message: 'Record not found' },
69
- P2026: { status: 501, message: 'Feature not supported by the current database provider' },
70
- P2028: { status: 500, message: 'Transaction API error' },
71
- P2030: { status: 400, message: 'Cannot find a fulltext index for the search' },
72
- P2033: { status: 400, message: 'Number out of range for the field type' },
73
- P2034: { status: 409, message: 'Transaction conflict, please retry' },
74
- }
75
-
76
- async function getExtendedClient(req: Request): Promise<PrismaClient> {
77
- const base = (req as any).prisma as PrismaClient
78
- if (!base) {
79
- throw new HttpError(500, 'PrismaClient not found on request. Set req.prisma in middleware.')
80
- }
81
-
82
- await _prismasqlReady
83
-
84
- if (!_speedExtension) return base
85
-
86
- const connector = (req as any).postgres || (req as any).sqlite
87
- if (!connector) return base
88
-
89
- if (typeof connector === 'object' && connector !== null) {
90
- const innerMap = _extendedClients.get(connector)
91
- if (innerMap) {
92
- const cached = innerMap.get(base)
93
- if (cached) return cached
94
- }
95
- }
96
-
97
- try {
98
- const extended = base.$extends(_speedExtension({
99
- postgres: (req as any).postgres,
100
- sqlite: (req as any).sqlite,
101
- debug: process.env.DEBUG === 'true'
102
- })) as unknown as PrismaClient
103
-
104
- if (typeof connector === 'object' && connector !== null) {
105
- let innerMap = _extendedClients.get(connector)
106
- if (!innerMap) {
107
- innerMap = new WeakMap<object, PrismaClient>()
108
- _extendedClients.set(connector, innerMap)
109
- }
110
- innerMap.set(base, extended)
111
- }
112
-
113
- return extended
114
- } catch (error) {
115
- console.warn('[speedExtension] Failed to initialize, using base client:', error)
116
- return base
117
- }
118
- }
119
-
120
- function handleError(error: unknown, next: NextFunction): void {
121
- if (error instanceof HttpError) {
122
- next(error);
123
- return;
124
- }
125
-
126
- if (
127
- error &&
128
- typeof error === "object" &&
129
- "name" in error &&
130
- error.name === "ShapeError"
131
- ) {
132
- next(new HttpError(400, (error as any).message));
133
- return;
134
- }
135
-
136
- if (
137
- error &&
138
- typeof error === "object" &&
139
- "name" in error &&
140
- error.name === "CallerError"
141
- ) {
142
- next(new HttpError(400, (error as any).message));
143
- return;
144
- }
145
-
146
- if (
147
- error &&
148
- typeof error === "object" &&
149
- "name" in error &&
150
- error.name === "PolicyError"
151
- ) {
152
- next(new HttpError(403, (error as any).message));
153
- return;
154
- }
155
-
156
- if (
157
- error &&
158
- typeof error === "object" &&
159
- "issues" in error &&
160
- "name" in error &&
161
- (error as any).name === "ZodError"
162
- ) {
163
- const issues = (error as any).issues;
164
- const message = Array.isArray(issues)
165
- ? issues.map((i: any) => i.message).join("; ")
166
- : (error as any).message;
167
- next(new HttpError(400, message));
168
- return;
169
- }
170
-
171
- if (error && typeof error === "object" && "code" in error) {
172
- const code = (error as any).code as string;
173
- const mapped = PRISMA_ERROR_MAP[code];
174
- if (mapped) {
175
- next(new HttpError(mapped.status, mapped.message));
176
- return;
177
- }
178
- if (typeof code === "string" && code.startsWith("P")) {
179
- console.warn(
180
- "[prisma-generator-express] Unmapped Prisma error code:",
181
- code,
182
- (error as any).message || "",
183
- );
184
- next(new HttpError(500, "Database operation failed"));
185
- return;
186
- }
187
- }
188
-
189
- if (error && typeof error === "object" && "name" in error) {
190
- const name = (error as any).name;
191
- if (name === "PrismaClientValidationError") {
192
- next(new HttpError(400, "Invalid query parameters"));
193
- return;
194
- }
195
- }
196
-
197
- console.error("[prisma-generator-express] Unhandled error:", error);
198
- next(new HttpError(500, "Internal server error"));
199
- }
200
-
201
- function safeParseBody(req: Request): Record<string, any> {
202
- const body = req.body
203
- if (!body || typeof body !== 'object' || Array.isArray(body)) {
204
- throw new HttpError(400, 'Request body must be a JSON object')
205
- }
206
- return sanitizeKeys(body as Record<string, any>)
207
- }
208
-
209
- function requireBodyField(body: Record<string, any>, field: string): void {
210
- if (!(field in body) || body[field] === undefined) {
211
- throw new HttpError(400, 'Missing required field: ' + field)
212
- }
213
- }
214
-
215
- function applyPaginationLimits(query: Record<string, any>, res: Response): Record<string, any> {
216
- const routeConfig = res.locals.routeConfig
217
- const pagination = routeConfig?.pagination
218
- if (!pagination) return query
219
-
220
- const result = { ...query }
221
-
222
- if (result.take === undefined && pagination.defaultLimit !== undefined) {
223
- result.take = pagination.defaultLimit
224
- }
225
-
226
- if (pagination.maxLimit !== undefined && result.take !== undefined) {
227
- const takeNum = Number(result.take)
228
- if (Math.abs(takeNum) > pagination.maxLimit) {
229
- result.take = takeNum < 0 ? -pagination.maxLimit : pagination.maxLimit
230
- }
231
- }
232
-
233
- return result
234
- }
235
-
236
- function normalizeDistinct(value: unknown): string[] {
237
- if (typeof value === 'string') return [value]
238
- if (Array.isArray(value)) return value.filter((v): v is string => typeof v === 'string')
239
- return []
240
- }
241
-
242
- function assertGuard(delegate: any): void {
243
- if (typeof delegate.guard !== 'function') {
244
- throw new HttpError(500, 'Guard shapes require prisma-guard extension on PrismaClient. Install: npm install prisma-guard, then extend your client with guardExtension().')
245
- }
246
- }
247
-
248
- const GUARD_SHAPE_CONFIG_KEYS = new Set([
249
- 'data', 'create', 'update', 'where', 'include', 'select', 'orderBy',
250
- 'cursor', 'take', 'skip', 'distinct', 'having', '_count', '_avg',
251
- '_sum', '_min', '_max', 'by',
252
- ])
253
-
254
- function keepWhereOnly(obj: Record<string, any>): Record<string, any> {
255
- const result: Record<string, any> = {}
256
- if ('where' in obj) result.where = obj.where
257
- return result
258
- }
259
-
260
- function buildCountShape(shape: Record<string, any>): Record<string, any> {
261
- if (typeof shape === 'function') {
262
- return (...args: any[]) => keepWhereOnly((shape as Function)(...args))
263
- }
264
-
265
- const keys = Object.keys(shape)
266
- const isSingleShape = keys.length === 0 || keys.every(k => GUARD_SHAPE_CONFIG_KEYS.has(k))
267
-
268
- if (isSingleShape) {
269
- return keepWhereOnly(shape)
270
- }
271
-
272
- const result: Record<string, any> = {}
273
- for (const [key, variant] of Object.entries(shape)) {
274
- if (typeof variant === 'function') {
275
- result[key] = (...args: any[]) => keepWhereOnly(variant(...args))
276
- } else if (typeof variant === 'object' && variant !== null) {
277
- result[key] = keepWhereOnly(variant)
278
- } else {
279
- result[key] = variant
280
- }
281
- }
282
- return result
283
- }
284
-
285
- ${generateReadHandlers(modelName, modelNameLower)}
286
-
287
- ${generateWriteHandlers(modelName, modelNameLower)}
288
- `;
289
- }
290
- function generateReadHandlers(modelName, modelNameLower) {
291
- const standardReadOps = [
292
- 'findFirst',
293
- 'findUnique',
294
- 'findUniqueOrThrow',
295
- 'findFirstOrThrow',
296
- 'count',
297
- 'aggregate',
298
- 'groupBy',
299
- ];
300
- const standardHandlers = standardReadOps
301
- .map((op) => {
302
- const functionName = `${modelName}${op.charAt(0).toUpperCase() + op.slice(1)}`;
25
+ const modelName = options.model.name;
26
+ const handlers = ALL_OPS.map((op) => {
27
+ const exportName = `${modelName}${op.charAt(0).toUpperCase() + op.slice(1)}`;
303
28
  return `
304
- export async function ${functionName}(
305
- req: Request,
306
- res: Response,
307
- next: NextFunction
308
- ) {
309
- try {
310
- const query = res.locals.parsedQuery || {}
311
- const extended = await getExtendedClient(req)
312
- const shape = res.locals.guardShape
313
-
314
- let data
315
- if (shape) {
316
- assertGuard((extended as any).${modelNameLower})
317
- const caller = res.locals.guardCaller
318
- data = await (extended as any).${modelNameLower}.guard(shape, caller).${op}(query)
319
- } else {
320
- data = await (extended as any).${modelNameLower}.${op}(query)
321
- }
322
-
323
- res.locals.data = data
324
- next()
325
- } catch (error: unknown) {
326
- handleError(error, next)
327
- }
328
- }
329
- `;
330
- })
331
- .join('\n');
332
- const findManyHandler = `
333
- export async function ${modelName}FindMany(
29
+ export async function ${exportName}(
334
30
  req: Request,
335
31
  res: Response,
336
- next: NextFunction
32
+ next: NextFunction,
337
33
  ) {
338
34
  try {
339
- const rawQuery = res.locals.parsedQuery || {}
340
- const query = applyPaginationLimits(rawQuery, res)
341
- const extended = await getExtendedClient(req)
342
- const shape = res.locals.guardShape
343
-
344
- let data
345
- if (shape) {
346
- assertGuard((extended as any).${modelNameLower})
347
- const caller = res.locals.guardCaller
348
- data = await (extended as any).${modelNameLower}.guard(shape, caller).findMany(query)
349
- } else {
350
- data = await (extended as any).${modelNameLower}.findMany(query)
351
- }
352
-
353
- res.locals.data = data
354
- next()
355
- } catch (error: unknown) {
356
- handleError(error, next)
357
- }
358
- }
359
- `;
360
- return findManyHandler + '\n' + standardHandlers;
361
- }
362
- function generateWriteHandlers(modelName, modelNameLower) {
363
- const writeOps = [
364
- { name: 'Create', method: 'create', requiredFields: ['data'] },
365
- { name: 'CreateMany', method: 'createMany', requiredFields: ['data'] },
366
- {
367
- name: 'CreateManyAndReturn',
368
- method: 'createManyAndReturn',
369
- requiredFields: ['data'],
370
- },
371
- { name: 'Update', method: 'update', requiredFields: ['where', 'data'] },
372
- {
373
- name: 'UpdateMany',
374
- method: 'updateMany',
375
- requiredFields: ['where', 'data'],
376
- },
377
- {
378
- name: 'UpdateManyAndReturn',
379
- method: 'updateManyAndReturn',
380
- requiredFields: ['where', 'data'],
381
- },
382
- { name: 'Delete', method: 'delete', requiredFields: ['where'] },
383
- { name: 'DeleteMany', method: 'deleteMany', requiredFields: ['where'] },
384
- {
385
- name: 'Upsert',
386
- method: 'upsert',
387
- requiredFields: ['where', 'create', 'update'],
388
- },
389
- ];
390
- return (writeOps
391
- .map((op) => {
392
- const functionName = `${modelName}${op.name}`;
393
- const validationLines = (op.requiredFields || [])
394
- .map((field) => ` requireBodyField(body, '${field}')`)
395
- .join('\n');
396
- return `
397
- export async function ${functionName}(req: Request, res: Response, next: NextFunction) {
398
- try {
399
- const body = safeParseBody(req)
400
- ${validationLines ? validationLines + '\n' : ''} const extended = await getExtendedClient(req)
401
- const shape = res.locals.guardShape
402
-
403
- let data
404
- if (shape) {
405
- assertGuard((extended as any).${modelNameLower})
406
- const caller = res.locals.guardCaller
407
- data = await (extended as any).${modelNameLower}.guard(shape, caller).${op.method}(body)
408
- } else {
409
- data = await (extended as any).${modelNameLower}.${op.method}(body)
410
- }
411
-
412
- res.locals.data = data
35
+ res.locals.data = await core.${op}(buildContext(req, res))
413
36
  next()
414
37
  } catch (error: unknown) {
415
- handleError(error, next)
416
- }
417
- }
38
+ next(mapError(error))
39
+ }
40
+ }`;
41
+ }).join('\n');
42
+ return `import { Request, Response, NextFunction } from 'express'
43
+ import * as core from './${modelName}Core.js'
44
+ import { OperationContext, mapError } from '../operationRuntime.js'
45
+
46
+ function buildContext(req: Request, res: Response): OperationContext {
47
+ return {
48
+ prisma: (req as any).prisma,
49
+ postgres: (req as any).postgres,
50
+ sqlite: (req as any).sqlite,
51
+ parsedQuery: res.locals.parsedQuery,
52
+ body: req.body,
53
+ guardShape: res.locals.guardShape,
54
+ guardCaller: res.locals.guardCaller,
55
+ paginationConfig: res.locals.routeConfig?.pagination,
56
+ }
57
+ }
58
+ ${handlers}
418
59
  `;
419
- })
420
- .join('\n') +
421
- `
422
-
423
- async function countForPagination(
424
- delegate: any,
425
- query: Record<string, any>,
426
- shape: Record<string, any> | undefined,
427
- caller: string | undefined,
428
- ): Promise<number> {
429
- const distinctFields = normalizeDistinct(query.distinct)
430
- const hasDistinct = distinctFields.length > 0
431
-
432
- const countShape = shape ? buildCountShape(shape) : undefined
433
-
434
- if (hasDistinct) {
435
- if (shape) {
436
- const countArgs: Record<string, any> = {}
437
- if (query.where) countArgs.where = query.where
438
- return countShape
439
- ? await delegate.guard(countShape, caller).count(countArgs)
440
- : await delegate.count(countArgs)
441
- }
442
-
443
- const selectField = distinctFields[0]
444
- const distinctArgs: Record<string, any> = {
445
- where: query.where,
446
- distinct: distinctFields,
447
- select: { [selectField]: true },
448
- take: DISTINCT_COUNT_LIMIT + 1,
449
- }
450
-
451
- const results = await delegate.findMany(distinctArgs)
452
-
453
- if (results.length > DISTINCT_COUNT_LIMIT) {
454
- console.warn('[prisma-generator-express] Distinct count exceeds ' + DISTINCT_COUNT_LIMIT + ', falling back to approximate total')
455
- const countArgs: Record<string, any> = {}
456
- if (query.where) countArgs.where = query.where
457
- return await delegate.count(countArgs)
458
- }
459
-
460
- return results.length
461
- }
462
-
463
- const countArgs: Record<string, any> = {}
464
- if (query.where) countArgs.where = query.where
465
-
466
- return countShape
467
- ? await delegate.guard(countShape, caller).count(countArgs)
468
- : await delegate.count(countArgs)
469
- }
470
-
471
- export async function ${modelName}FindManyPaginated(req: Request, res: Response, next: NextFunction) {
472
- try {
473
- const rawQuery = res.locals.parsedQuery || {}
474
- const query = applyPaginationLimits(rawQuery, res)
475
- const extended = await getExtendedClient(req)
476
- const shape = res.locals.guardShape
477
- const caller = res.locals.guardCaller
478
-
479
- if (shape) {
480
- assertGuard((extended as any).${modelNameLower})
481
- }
482
-
483
- let items: any[]
484
- let total: number
485
-
486
- if (typeof extended.$transaction === 'function') {
487
- try {
488
- const txResult = await extended.$transaction(async (tx: any) => {
489
- const d = shape
490
- ? await tx.${modelNameLower}.guard(shape, caller).findMany(query)
491
- : await tx.${modelNameLower}.findMany(query)
492
- const t = await countForPagination(tx.${modelNameLower}, query, shape, caller)
493
- return { d, t }
494
- })
495
- items = txResult.d
496
- total = txResult.t
497
- } catch (txError: any) {
498
- if (
499
- txError?.message?.includes?.('interactive transactions') ||
500
- txError?.code === 'P2028'
501
- ) {
502
- console.warn('[prisma-generator-express] Interactive transactions not available, pagination queries are non-atomic')
503
- items = shape
504
- ? await (extended as any).${modelNameLower}.guard(shape, caller).findMany(query)
505
- : await (extended as any).${modelNameLower}.findMany(query)
506
- total = await countForPagination((extended as any).${modelNameLower}, query, shape, caller)
507
- } else {
508
- throw txError
509
- }
510
- }
511
- } else {
512
- items = shape
513
- ? await (extended as any).${modelNameLower}.guard(shape, caller).findMany(query)
514
- : await (extended as any).${modelNameLower}.findMany(query)
515
- total = await countForPagination((extended as any).${modelNameLower}, query, shape, caller)
516
- }
517
-
518
- const skip = (query.skip as number) ?? 0
519
- const absTake = Math.abs((query.take as number) ?? items.length)
520
- const hasMore = items.length >= absTake && skip + items.length < total
521
-
522
- res.locals.data = { data: items, total, hasMore }
523
- next()
524
- } catch (error: unknown) {
525
- handleError(error, next)
526
- }
527
- }
528
- `);
529
60
  }
530
61
  //# sourceMappingURL=generateUnifiedHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateUnifiedHandler.js","sourceRoot":"","sources":["../../src/generators/generateUnifiedHandler.ts"],"names":[],"mappings":";;AAOA,wDA+RC;AA/RD,SAAgB,sBAAsB,CAAC,OAA8B;IACnE,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC7E,MAAM,UAAU,GACd,qBAAqB,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IAE9D,OAAO;gCACuB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmRxC,oBAAoB,CAAC,SAAS,EAAE,cAAc,CAAC;;EAE/C,qBAAqB,CAAC,SAAS,EAAE,cAAc,CAAC;CACjD,CAAA;AACD,CAAC;AAED,SAAS,oBAAoB,CAC3B,SAAiB,EACjB,cAAsB;IAEtB,MAAM,eAAe,GAAG;QACtB,WAAW;QACX,YAAY;QACZ,mBAAmB;QACnB,kBAAkB;QAClB,OAAO;QACP,WAAW;QACX,SAAS;KACV,CAAA;IAED,MAAM,gBAAgB,GAAG,eAAe;SACrC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;QACV,MAAM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nifiedHandler.ts"],"names":[],"mappings":";;AA2BA,wDAuCC;AA5DD,MAAM,OAAO,GAAG;IACd,UAAU;IACV,WAAW;IACX,kBAAkB;IAClB,YAAY;IACZ,mBAAmB;IACnB,mBAAmB;IACnB,QAAQ;IACR,YAAY;IACZ,qBAAqB;IACrB,QAAQ;IACR,YAAY;IACZ,qBAAqB;IACrB,QAAQ;IACR,QAAQ;IACR,YAAY;IACZ,WAAW;IACX,OAAO;IACP,SAAS;CACV,CAAA;AAED,SAAgB,sBAAsB,CAAC,OAA8B;IACnE,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAA;IAEpC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;QAClC,MAAM,UAAU,GAAG,GAAG,SAAS,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;QAE5E,OAAO;wBACa,UAAU;;;;;;mCAMC,EAAE;;;;;EAKnC,CAAA;IACA,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEb,OAAO;2BACkB,SAAS;;;;;;;;;;;;;;;EAelC,QAAQ;CACT,CAAA;AACD,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import { DMMF } from '@prisma/generator-helper';
2
+ import { Target } from '../constants.js';
2
3
  export declare function generateScalarUIHandler(options: {
3
4
  model: DMMF.Model;
4
5
  enums: DMMF.DatamodelEnum[];
6
+ target?: Target;
5
7
  }): string;