prisma-generator-express 1.67.0 → 1.68.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 (68) hide show
  1. package/README.md +223 -28
  2. package/dist/copy/operationDefinitions.d.ts +4 -1
  3. package/dist/copy/operationDefinitions.js +64 -3
  4. package/dist/copy/operationDefinitions.js.map +1 -1
  5. package/dist/generators/generateFastifyHandler.js +55 -9
  6. package/dist/generators/generateFastifyHandler.js.map +1 -1
  7. package/dist/generators/generateHonoHandler.js +44 -4
  8. package/dist/generators/generateHonoHandler.js.map +1 -1
  9. package/dist/generators/generateHonoOpenApi.d.ts +13 -0
  10. package/dist/generators/generateHonoOpenApi.js +70 -0
  11. package/dist/generators/generateHonoOpenApi.js.map +1 -0
  12. package/dist/generators/generateMcpApp.d.ts +10 -0
  13. package/dist/generators/generateMcpApp.js +113 -0
  14. package/dist/generators/generateMcpApp.js.map +1 -0
  15. package/dist/generators/generateModelMcp.d.ts +9 -0
  16. package/dist/generators/generateModelMcp.js +145 -0
  17. package/dist/generators/generateModelMcp.js.map +1 -0
  18. package/dist/generators/generateModelMetadata.js +9 -5
  19. package/dist/generators/generateModelMetadata.js.map +1 -1
  20. package/dist/generators/generateRouter.js +62 -56
  21. package/dist/generators/generateRouter.js.map +1 -1
  22. package/dist/generators/generateRouterFastify.js +56 -64
  23. package/dist/generators/generateRouterFastify.js.map +1 -1
  24. package/dist/generators/generateRouterHono.js +43 -411
  25. package/dist/generators/generateRouterHono.js.map +1 -1
  26. package/dist/generators/generateRouterPartsHono.d.ts +14 -0
  27. package/dist/generators/generateRouterPartsHono.js +180 -0
  28. package/dist/generators/generateRouterPartsHono.js.map +1 -0
  29. package/dist/generators/generateUnifiedHandler.js +36 -20
  30. package/dist/generators/generateUnifiedHandler.js.map +1 -1
  31. package/dist/index.d.ts +2 -0
  32. package/dist/index.js +101 -3
  33. package/dist/index.js.map +1 -1
  34. package/dist/utils/copyFiles.d.ts +1 -1
  35. package/dist/utils/copyFiles.js +20 -1
  36. package/dist/utils/copyFiles.js.map +1 -1
  37. package/dist/utils/mcpGate.d.ts +10 -0
  38. package/dist/utils/mcpGate.js +118 -0
  39. package/dist/utils/mcpGate.js.map +1 -0
  40. package/dist/utils/writeFileSafely.js +6 -0
  41. package/dist/utils/writeFileSafely.js.map +1 -1
  42. package/package.json +18 -3
  43. package/src/copy/buildModelOpenApi.ts +76 -126
  44. package/src/copy/docsRenderer.ts +14 -15
  45. package/src/copy/mcpRuntime.ts +1017 -0
  46. package/src/copy/operationDefinitions.ts +78 -4
  47. package/src/copy/operationPipeline.ts +267 -0
  48. package/src/copy/operationRuntime.ts +24 -14
  49. package/src/copy/operationSchemas.ts +2773 -0
  50. package/src/copy/pagination.ts +10 -2
  51. package/src/copy/routeConfig.hono.ts +34 -5
  52. package/src/copy/routeConfig.ts +1 -1
  53. package/src/copy/routerParts.ts +524 -0
  54. package/src/generators/generateFastifyHandler.ts +55 -9
  55. package/src/generators/generateHonoHandler.ts +44 -4
  56. package/src/generators/generateHonoOpenApi.ts +93 -0
  57. package/src/generators/generateMcpApp.ts +133 -0
  58. package/src/generators/generateModelMcp.ts +208 -0
  59. package/src/generators/generateModelMetadata.ts +16 -10
  60. package/src/generators/generateRouter.ts +62 -56
  61. package/src/generators/generateRouterFastify.ts +56 -64
  62. package/src/generators/generateRouterHono.ts +49 -459
  63. package/src/generators/generateRouterPartsHono.ts +220 -0
  64. package/src/generators/generateUnifiedHandler.ts +36 -21
  65. package/src/index.ts +116 -3
  66. package/src/utils/copyFiles.ts +36 -0
  67. package/src/utils/mcpGate.ts +157 -0
  68. package/src/utils/writeFileSafely.ts +6 -0
@@ -127,7 +127,7 @@ function exampleValue(ctx: DocsModelContext, fieldName: string): unknown {
127
127
 
128
128
  function compoundWhereExample(
129
129
  ctx: DocsModelContext,
130
- ): Record<string, any> | null {
130
+ ): Record<string, unknown> | null {
131
131
  if (ctx.compoundId) {
132
132
  const keyName = ctx.compoundId.fields.join('_')
133
133
  const val: Record<string, unknown> = {}
@@ -426,7 +426,7 @@ export function renderDocs(
426
426
  const singleRelations = relationFields.filter((f) => !f.isList)
427
427
 
428
428
  const getOps = OPERATION_METADATA.filter((meta) =>
429
- isOperationEnabled(config as Record<string, any>, meta),
429
+ isOperationEnabled(config, meta),
430
430
  )
431
431
  .filter((meta) => !isOpHiddenByStrategy(meta.name, writeStrategy))
432
432
  .map((meta) => {
@@ -453,9 +453,7 @@ export function renderDocs(
453
453
 
454
454
  const postReadOps = postReadsEnabled
455
455
  ? OPERATION_METADATA.filter((meta) => READ_OPERATION_NAMES.has(meta.name))
456
- .filter((meta) =>
457
- isOperationEnabled(config as Record<string, any>, meta),
458
- )
456
+ .filter((meta) => isOperationEnabled(config, meta))
459
457
  .map((meta) => {
460
458
  const detail = detailForOp(meta.name)
461
459
  const postPath =
@@ -499,8 +497,8 @@ export function renderDocs(
499
497
  const firstStringField = scalarFields.find((f) => f.type === 'String')
500
498
  const firstBooleanField = scalarFields.find((f) => f.type === 'Boolean')
501
499
 
502
- const whereExample: Record<string, any> = {}
503
- const andClauses: Record<string, any>[] = []
500
+ const whereExample: Record<string, unknown> = {}
501
+ const andClauses: Record<string, unknown>[] = []
504
502
  if (firstFilterFieldName) {
505
503
  andClauses.push({
506
504
  [firstFilterFieldName]: {
@@ -517,19 +515,19 @@ export function renderDocs(
517
515
  if (firstBooleanField)
518
516
  whereExample.OR = [{ [firstBooleanField.name]: { equals: true } }]
519
517
 
520
- const selectExample: any = {}
518
+ const selectExample: Record<string, unknown> = {}
521
519
  for (const f of scalarFields.slice(0, 10)) selectExample[f.name] = true
522
520
 
523
- const includeExample: any = {}
521
+ const includeExample: Record<string, unknown> = {}
524
522
  for (const f of relationFields.slice(0, 6)) includeExample[f.name] = true
525
523
 
526
- const omitExample: any = {}
524
+ const omitExample: Record<string, unknown> = {}
527
525
  const omitCandidates = scalarFields.filter((f) => !f.isId && !f.isUnique)
528
526
  for (const f of omitCandidates.slice(0, 3)) omitExample[f.name] = true
529
527
 
530
528
  const orderByField = firstUnique ? firstUnique.name : firstFilterFieldName
531
529
 
532
- const findManyQueryArgs: any = {
530
+ const findManyQueryArgs: Record<string, unknown> = {
533
531
  where: whereExample,
534
532
  select: selectExample,
535
533
  orderBy: orderByField ? { [orderByField]: 'asc' } : undefined,
@@ -575,7 +573,7 @@ export function renderDocs(
575
573
  'const data = await res.json()'
576
574
  : null
577
575
 
578
- const createBodyExample: any = { data: {} }
576
+ const createBodyExample: { data: Record<string, unknown> } = { data: {} }
579
577
  for (const f of requiredCreateFields.slice(0, 5)) {
580
578
  createBodyExample.data[f.name] = exampleValue(ctx, f.name)
581
579
  }
@@ -592,9 +590,10 @@ export function renderDocs(
592
590
  '})\n' +
593
591
  'const created = await res.json()'
594
592
 
595
- const updateBodyExample: any = uniqueWhereExample
596
- ? { where: uniqueWhereExample, data: {} }
597
- : null
593
+ const updateBodyExample: {
594
+ where: Record<string, unknown>
595
+ data: Record<string, unknown>
596
+ } | null = uniqueWhereExample ? { where: uniqueWhereExample, data: {} } : null
598
597
  if (updateBodyExample) {
599
598
  const firstEditableString = scalarFields.find(
600
599
  (sf) => sf.type === 'String' && !sf.isId,