@k0lyan/nestjs-prisma-graphql-generator 0.1.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/LICENSE +21 -0
- package/README.md +210 -0
- package/dist/cli/generator.d.ts +3 -0
- package/dist/cli/generator.d.ts.map +1 -0
- package/dist/cli/generator.js +24 -0
- package/dist/cli/generator.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +18 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/options-parser.d.ts +48 -0
- package/dist/cli/options-parser.d.ts.map +1 -0
- package/dist/cli/options-parser.js +61 -0
- package/dist/cli/options-parser.js.map +1 -0
- package/dist/cli/prisma-generator.d.ts +4 -0
- package/dist/cli/prisma-generator.d.ts.map +1 -0
- package/dist/cli/prisma-generator.js +27 -0
- package/dist/cli/prisma-generator.js.map +1 -0
- package/dist/generator/common.d.ts +7 -0
- package/dist/generator/common.d.ts.map +1 -0
- package/dist/generator/common.js +87 -0
- package/dist/generator/common.js.map +1 -0
- package/dist/generator/dmmf/document.d.ts +96 -0
- package/dist/generator/dmmf/document.d.ts.map +1 -0
- package/dist/generator/dmmf/document.js +223 -0
- package/dist/generator/dmmf/document.js.map +1 -0
- package/dist/generator/dmmf/index.d.ts +4 -0
- package/dist/generator/dmmf/index.d.ts.map +1 -0
- package/dist/generator/dmmf/index.js +20 -0
- package/dist/generator/dmmf/index.js.map +1 -0
- package/dist/generator/dmmf/transformer.d.ts +59 -0
- package/dist/generator/dmmf/transformer.d.ts.map +1 -0
- package/dist/generator/dmmf/transformer.js +247 -0
- package/dist/generator/dmmf/transformer.js.map +1 -0
- package/dist/generator/dmmf/types.d.ts +169 -0
- package/dist/generator/dmmf/types.d.ts.map +1 -0
- package/dist/generator/dmmf/types.js +32 -0
- package/dist/generator/dmmf/types.js.map +1 -0
- package/dist/generator/generate.d.ts +10 -0
- package/dist/generator/generate.d.ts.map +1 -0
- package/dist/generator/generate.js +131 -0
- package/dist/generator/generate.js.map +1 -0
- package/dist/generator/helpers-generator.d.ts +7 -0
- package/dist/generator/helpers-generator.d.ts.map +1 -0
- package/dist/generator/helpers-generator.js +216 -0
- package/dist/generator/helpers-generator.js.map +1 -0
- package/dist/generator/index.d.ts +7 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +23 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/templates/args.d.ts +8 -0
- package/dist/generator/templates/args.d.ts.map +1 -0
- package/dist/generator/templates/args.js +650 -0
- package/dist/generator/templates/args.js.map +1 -0
- package/dist/generator/templates/enum.d.ts +8 -0
- package/dist/generator/templates/enum.d.ts.map +1 -0
- package/dist/generator/templates/enum.js +66 -0
- package/dist/generator/templates/enum.js.map +1 -0
- package/dist/generator/templates/index.d.ts +6 -0
- package/dist/generator/templates/index.d.ts.map +1 -0
- package/dist/generator/templates/index.js +22 -0
- package/dist/generator/templates/index.js.map +1 -0
- package/dist/generator/templates/input.d.ts +8 -0
- package/dist/generator/templates/input.d.ts.map +1 -0
- package/dist/generator/templates/input.js +248 -0
- package/dist/generator/templates/input.js.map +1 -0
- package/dist/generator/templates/model.d.ts +8 -0
- package/dist/generator/templates/model.d.ts.map +1 -0
- package/dist/generator/templates/model.js +184 -0
- package/dist/generator/templates/model.js.map +1 -0
- package/dist/generator/templates/resolver.d.ts +8 -0
- package/dist/generator/templates/resolver.d.ts.map +1 -0
- package/dist/generator/templates/resolver.js +456 -0
- package/dist/generator/templates/resolver.js.map +1 -0
- package/dist/generator/writers/file-writer.d.ts +10 -0
- package/dist/generator/writers/file-writer.d.ts.map +1 -0
- package/dist/generator/writers/file-writer.js +40 -0
- package/dist/generator/writers/file-writer.js.map +1 -0
- package/dist/generator/writers/index.d.ts +2 -0
- package/dist/generator/writers/index.d.ts.map +1 -0
- package/dist/generator/writers/index.js +18 -0
- package/dist/generator/writers/index.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/helpers.d.ts +102 -0
- package/dist/runtime/helpers.d.ts.map +1 -0
- package/dist/runtime/helpers.js +210 -0
- package/dist/runtime/helpers.js.map +1 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +18 -0
- package/dist/runtime/index.js.map +1 -0
- package/package.json +79 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# NestJS Prisma GraphQL Generator
|
|
2
|
+
|
|
3
|
+
A Prisma generator that produces **optimized** NestJS 11 GraphQL resolvers, object types, input types, and args from Prisma models.
|
|
4
|
+
|
|
5
|
+
## Key Features
|
|
6
|
+
|
|
7
|
+
- 🚀 **Optimized Queries** - No N+1 problems! Uses GraphQL selection analysis to build minimal Prisma queries
|
|
8
|
+
- 📦 **Full CRUD** - Generates complete CRUD resolvers (findMany, findUnique, create, update, delete, etc.)
|
|
9
|
+
- 🎯 **NestJS Native** - Uses `@nestjs/graphql` decorators (`@ObjectType`, `@Resolver`, `@Query`, `@Mutation`)
|
|
10
|
+
- 🔧 **Configurable** - Customize output directories, select specific blocks to generate
|
|
11
|
+
- 📝 **Type-Safe** - Full TypeScript support with proper type inference
|
|
12
|
+
|
|
13
|
+
## Why This Generator?
|
|
14
|
+
|
|
15
|
+
Traditional GraphQL resolvers use `@ResolveField()` for relations, causing N+1 queries:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// ❌ SLOW - Causes N+1 queries on large lists
|
|
19
|
+
@ResolveField(() => [Post])
|
|
20
|
+
async posts(@Parent() user: User) {
|
|
21
|
+
return this.prisma.post.findMany({ where: { authorId: user.id } });
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This generator produces resolvers that analyze the GraphQL query and build a **single optimized Prisma query**:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
// ✅ FAST - Single query with all needed data
|
|
29
|
+
@Query(() => [User])
|
|
30
|
+
async users(@Info() info: GraphQLResolveInfo, @Args() args: FindManyUserArgs) {
|
|
31
|
+
const select = transformInfoIntoPrismaArgs(info);
|
|
32
|
+
return this.prisma.user.findMany({ ...args, ...select });
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install nestjs-prisma-graphql-generator
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
Add the generator to your `schema.prisma`:
|
|
45
|
+
|
|
46
|
+
```prisma
|
|
47
|
+
generator client {
|
|
48
|
+
provider = "prisma-client-js"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
generator nestjsGraphql {
|
|
52
|
+
provider = "nestjs-prisma-graphql-generator"
|
|
53
|
+
output = "../src/generated/graphql"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
model User {
|
|
57
|
+
id String @id @default(cuid())
|
|
58
|
+
email String @unique
|
|
59
|
+
name String?
|
|
60
|
+
posts Post[]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
model Post {
|
|
64
|
+
id String @id @default(cuid())
|
|
65
|
+
title String
|
|
66
|
+
author User @relation(fields: [authorId], references: [id])
|
|
67
|
+
authorId String
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Run Prisma generate:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx prisma generate
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Generated Output
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
src/generated/graphql/
|
|
81
|
+
├── enums/ # GraphQL enums
|
|
82
|
+
├── models/ # @ObjectType classes
|
|
83
|
+
├── inputs/ # @InputType classes
|
|
84
|
+
├── args/ # @ArgsType classes
|
|
85
|
+
├── resolvers/ # CRUD resolvers
|
|
86
|
+
├── common/ # Shared types
|
|
87
|
+
├── helpers.ts # Runtime helpers
|
|
88
|
+
└── index.ts
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Using Generated Code
|
|
92
|
+
|
|
93
|
+
### 1. Setup GraphQL Module
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { Module } from '@nestjs/common';
|
|
97
|
+
import { GraphQLModule } from '@nestjs/graphql';
|
|
98
|
+
import { ApolloDriver } from '@nestjs/apollo';
|
|
99
|
+
import { PrismaService } from './prisma.service';
|
|
100
|
+
import { UserResolver, PostResolver } from './generated/graphql';
|
|
101
|
+
|
|
102
|
+
@Module({
|
|
103
|
+
imports: [
|
|
104
|
+
GraphQLModule.forRoot({
|
|
105
|
+
driver: ApolloDriver,
|
|
106
|
+
autoSchemaFile: true,
|
|
107
|
+
context: ({ req }) => ({
|
|
108
|
+
prisma: new PrismaService(), // Or inject via DI
|
|
109
|
+
}),
|
|
110
|
+
}),
|
|
111
|
+
],
|
|
112
|
+
providers: [PrismaService, UserResolver, PostResolver],
|
|
113
|
+
})
|
|
114
|
+
export class AppModule {}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 2. Query with Relations
|
|
118
|
+
|
|
119
|
+
```graphql
|
|
120
|
+
query {
|
|
121
|
+
users {
|
|
122
|
+
id
|
|
123
|
+
name
|
|
124
|
+
posts {
|
|
125
|
+
id
|
|
126
|
+
title
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
This generates a **single** Prisma query:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
prisma.user.findMany({
|
|
136
|
+
select: {
|
|
137
|
+
id: true,
|
|
138
|
+
name: true,
|
|
139
|
+
posts: {
|
|
140
|
+
select: {
|
|
141
|
+
id: true,
|
|
142
|
+
title: true,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Configuration Options
|
|
150
|
+
|
|
151
|
+
```prisma
|
|
152
|
+
generator nestjsGraphql {
|
|
153
|
+
provider = "nestjs-prisma-graphql-generator"
|
|
154
|
+
output = "../src/generated/graphql"
|
|
155
|
+
|
|
156
|
+
// Generate only specific blocks
|
|
157
|
+
emitOnly = "models,resolvers"
|
|
158
|
+
|
|
159
|
+
// Disable resolver generation
|
|
160
|
+
generateResolvers = "true"
|
|
161
|
+
|
|
162
|
+
// Custom Prisma client import path
|
|
163
|
+
prismaClientPath = "@prisma/client"
|
|
164
|
+
|
|
165
|
+
// Add prefix/suffix to type names
|
|
166
|
+
typePrefix = ""
|
|
167
|
+
typeSuffix = ""
|
|
168
|
+
|
|
169
|
+
// Custom output directories
|
|
170
|
+
modelsOutput = "models"
|
|
171
|
+
inputsOutput = "inputs"
|
|
172
|
+
argsOutput = "args"
|
|
173
|
+
enumsOutput = "enums"
|
|
174
|
+
resolversOutput = "resolvers"
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Generated Operations
|
|
179
|
+
|
|
180
|
+
For each model, the following operations are generated:
|
|
181
|
+
|
|
182
|
+
### Queries
|
|
183
|
+
|
|
184
|
+
- `findMany{Model}` - List with filtering, sorting, pagination
|
|
185
|
+
- `findUnique{Model}` - Get single by unique field
|
|
186
|
+
- `findFirst{Model}` - Get first matching record
|
|
187
|
+
- `aggregate{Model}` - Aggregations
|
|
188
|
+
- `groupBy{Model}` - Group by fields
|
|
189
|
+
- `{model}Count` - Count records
|
|
190
|
+
|
|
191
|
+
### Mutations
|
|
192
|
+
|
|
193
|
+
- `createOne{Model}` - Create single
|
|
194
|
+
- `createMany{Model}` - Create multiple
|
|
195
|
+
- `updateOne{Model}` - Update single
|
|
196
|
+
- `updateMany{Model}` - Update multiple
|
|
197
|
+
- `upsertOne{Model}` - Create or update
|
|
198
|
+
- `deleteOne{Model}` - Delete single
|
|
199
|
+
- `deleteMany{Model}` - Delete multiple
|
|
200
|
+
|
|
201
|
+
## Requirements
|
|
202
|
+
|
|
203
|
+
- Node.js >= 18
|
|
204
|
+
- Prisma >= 7.0
|
|
205
|
+
- NestJS >= 10
|
|
206
|
+
- `@nestjs/graphql` >= 12
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/cli/generator.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const prisma_generator_1 = require("./prisma-generator");
|
|
5
|
+
const generator_helper_1 = require("@prisma/generator-helper");
|
|
6
|
+
const options_parser_1 = require("./options-parser");
|
|
7
|
+
(0, generator_helper_1.generatorHandler)({
|
|
8
|
+
onManifest: () => ({
|
|
9
|
+
defaultOutput: 'node_modules/@generated/nestjs-graphql',
|
|
10
|
+
prettyName: 'NestJS GraphQL Generator',
|
|
11
|
+
requiresGenerators: ['prisma-client-js'],
|
|
12
|
+
}),
|
|
13
|
+
onGenerate: async (options) => {
|
|
14
|
+
const rawConfig = {};
|
|
15
|
+
for (const [key, value] of Object.entries(options.generator.config)) {
|
|
16
|
+
if (typeof value === 'string') {
|
|
17
|
+
rawConfig[key] = value;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const config = (0, options_parser_1.parseGeneratorConfig)(rawConfig);
|
|
21
|
+
await (0, prisma_generator_1.generate)(options, config);
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/cli/generator.ts"],"names":[],"mappings":";;;AAEA,yDAA8C;AAC9C,+DAA4D;AAC5D,qDAAwD;AAExD,IAAA,mCAAgB,EAAC;IACf,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;QACjB,aAAa,EAAE,wCAAwC;QACvD,UAAU,EAAE,0BAA0B;QACtC,kBAAkB,EAAE,CAAC,kBAAkB,CAAC;KACzC,CAAC;IACF,UAAU,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE;QAC1B,MAAM,SAAS,GAA2B,EAAE,CAAC;QAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YACpE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACzB,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,IAAA,qCAAoB,EAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,IAAA,2BAAQ,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./generator"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface GeneratorConfig {
|
|
2
|
+
/**
|
|
3
|
+
* Whether to emit only specific blocks (models, resolvers, etc.)
|
|
4
|
+
* Default: emit all
|
|
5
|
+
*/
|
|
6
|
+
emitOnly?: EmitBlock[];
|
|
7
|
+
/**
|
|
8
|
+
* Custom output subdirectories
|
|
9
|
+
*/
|
|
10
|
+
outputDirs?: {
|
|
11
|
+
models?: string;
|
|
12
|
+
inputs?: string;
|
|
13
|
+
args?: string;
|
|
14
|
+
enums?: string;
|
|
15
|
+
resolvers?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Whether to generate CRUD resolvers
|
|
19
|
+
* Default: true
|
|
20
|
+
*/
|
|
21
|
+
generateResolvers?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to use input validation decorators (class-validator)
|
|
24
|
+
* Default: false
|
|
25
|
+
*/
|
|
26
|
+
useValidation?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Custom Prisma client import path
|
|
29
|
+
* Default: @prisma/client
|
|
30
|
+
*/
|
|
31
|
+
prismaClientPath?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether to emit compiled JS alongside .d.ts
|
|
34
|
+
* Default: false (emit only .ts source)
|
|
35
|
+
*/
|
|
36
|
+
emitCompiled?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Prefix for generated type names
|
|
39
|
+
*/
|
|
40
|
+
typePrefix?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Suffix for generated type names
|
|
43
|
+
*/
|
|
44
|
+
typeSuffix?: string;
|
|
45
|
+
}
|
|
46
|
+
export type EmitBlock = 'models' | 'inputs' | 'args' | 'enums' | 'resolvers' | 'helpers';
|
|
47
|
+
export declare function parseGeneratorConfig(config: Record<string, string>): GeneratorConfig;
|
|
48
|
+
//# sourceMappingURL=options-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-parser.d.ts","sourceRoot":"","sources":["../../src/cli/options-parser.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;IAEvB;;OAEG;IACH,UAAU,CAAC,EAAE;QACX,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IAEF;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,CAAC;AAmBzF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,eAAe,CAiDpF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseGeneratorConfig = parseGeneratorConfig;
|
|
4
|
+
const DEFAULT_CONFIG = {
|
|
5
|
+
emitOnly: undefined,
|
|
6
|
+
outputDirs: {
|
|
7
|
+
models: 'models',
|
|
8
|
+
inputs: 'inputs',
|
|
9
|
+
args: 'args',
|
|
10
|
+
enums: 'enums',
|
|
11
|
+
resolvers: 'resolvers',
|
|
12
|
+
},
|
|
13
|
+
generateResolvers: true,
|
|
14
|
+
useValidation: false,
|
|
15
|
+
prismaClientPath: '@prisma/client',
|
|
16
|
+
emitCompiled: false,
|
|
17
|
+
typePrefix: '',
|
|
18
|
+
typeSuffix: '',
|
|
19
|
+
};
|
|
20
|
+
function parseGeneratorConfig(config) {
|
|
21
|
+
const result = { ...DEFAULT_CONFIG };
|
|
22
|
+
if (config['emitOnly']) {
|
|
23
|
+
result.emitOnly = config['emitOnly'].split(',').map(s => s.trim());
|
|
24
|
+
}
|
|
25
|
+
if (config['generateResolvers']) {
|
|
26
|
+
result.generateResolvers = config['generateResolvers'] === 'true';
|
|
27
|
+
}
|
|
28
|
+
if (config['useValidation']) {
|
|
29
|
+
result.useValidation = config['useValidation'] === 'true';
|
|
30
|
+
}
|
|
31
|
+
if (config['prismaClientPath']) {
|
|
32
|
+
result.prismaClientPath = config['prismaClientPath'];
|
|
33
|
+
}
|
|
34
|
+
if (config['emitCompiled']) {
|
|
35
|
+
result.emitCompiled = config['emitCompiled'] === 'true';
|
|
36
|
+
}
|
|
37
|
+
if (config['typePrefix']) {
|
|
38
|
+
result.typePrefix = config['typePrefix'];
|
|
39
|
+
}
|
|
40
|
+
if (config['typeSuffix']) {
|
|
41
|
+
result.typeSuffix = config['typeSuffix'];
|
|
42
|
+
}
|
|
43
|
+
// Parse custom output dirs
|
|
44
|
+
if (config['modelsOutput']) {
|
|
45
|
+
result.outputDirs = { ...result.outputDirs, models: config['modelsOutput'] };
|
|
46
|
+
}
|
|
47
|
+
if (config['inputsOutput']) {
|
|
48
|
+
result.outputDirs = { ...result.outputDirs, inputs: config['inputsOutput'] };
|
|
49
|
+
}
|
|
50
|
+
if (config['argsOutput']) {
|
|
51
|
+
result.outputDirs = { ...result.outputDirs, args: config['argsOutput'] };
|
|
52
|
+
}
|
|
53
|
+
if (config['enumsOutput']) {
|
|
54
|
+
result.outputDirs = { ...result.outputDirs, enums: config['enumsOutput'] };
|
|
55
|
+
}
|
|
56
|
+
if (config['resolversOutput']) {
|
|
57
|
+
result.outputDirs = { ...result.outputDirs, resolvers: config['resolversOutput'] };
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=options-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-parser.js","sourceRoot":"","sources":["../../src/cli/options-parser.ts"],"names":[],"mappings":";;AAwEA,oDAiDC;AAlED,MAAM,cAAc,GAAoB;IACtC,QAAQ,EAAE,SAAS;IACnB,UAAU,EAAE;QACV,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,OAAO;QACd,SAAS,EAAE,WAAW;KACvB;IACD,iBAAiB,EAAE,IAAI;IACvB,aAAa,EAAE,KAAK;IACpB,gBAAgB,EAAE,gBAAgB;IAClC,YAAY,EAAE,KAAK;IACnB,UAAU,EAAE,EAAE;IACd,UAAU,EAAE,EAAE;CACf,CAAC;AAEF,SAAgB,oBAAoB,CAAC,MAA8B;IACjE,MAAM,MAAM,GAAoB,EAAE,GAAG,cAAc,EAAE,CAAC;IAEtD,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QACvB,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAe,CAAC,CAAC;IAClF,CAAC;IAED,IAAI,MAAM,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAChC,MAAM,CAAC,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,KAAK,MAAM,CAAC;IACpE,CAAC;IAED,IAAI,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC;QAC5B,MAAM,CAAC,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,KAAK,MAAM,CAAC;IAC5D,CAAC;IAED,IAAI,MAA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iB,CAAC,EAAE,CAAC;QAC9B,MAAM,CAAC,UAAU,GAAG,EAAE,GAAG,MAAM,CAAC,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC;IACrF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-generator.d.ts","sourceRoot":"","sources":["../../src/cli/prisma-generator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAKjE,wBAAsB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBhG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generate = generate;
|
|
7
|
+
const document_1 = require("../generator/dmmf/document");
|
|
8
|
+
const generate_1 = require("../generator/generate");
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const file_writer_1 = require("../generator/writers/file-writer");
|
|
11
|
+
async function generate(options, config) {
|
|
12
|
+
const outputDir = options.generator.output?.value;
|
|
13
|
+
if (!outputDir) {
|
|
14
|
+
throw new Error('Output directory is required');
|
|
15
|
+
}
|
|
16
|
+
const absoluteOutputDir = path_1.default.isAbsolute(outputDir)
|
|
17
|
+
? outputDir
|
|
18
|
+
: path_1.default.join(options.schemaPath, '..', outputDir);
|
|
19
|
+
// Parse DMMF into our internal document structure
|
|
20
|
+
const dmmfDocument = new document_1.DMMFDocument(options.dmmf, config);
|
|
21
|
+
// Generate all code files
|
|
22
|
+
const generatedFiles = await (0, generate_1.generateCode)(dmmfDocument, config);
|
|
23
|
+
// Write files to output directory
|
|
24
|
+
await (0, file_writer_1.writeFiles)(absoluteOutputDir, generatedFiles);
|
|
25
|
+
console.log(`✅ NestJS GraphQL types generated to ${absoluteOutputDir}`);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=prisma-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-generator.js","sourceRoot":"","sources":["../../src/cli/prisma-generator.ts"],"names":[],"mappings":";;;;;AAOA,4BAqBC;AA5BD,yDAA0D;AAG1D,oDAAqD;AACrD,gDAAwB;AACxB,kEAA8D;AAEvD,KAAK,UAAU,QAAQ,CAAC,OAAyB,EAAE,MAAuB;IAC/E,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC;IAElD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,iBAAiB,GAAG,cAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QAClD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAEnD,kDAAkD;IAClD,MAAM,YAAY,GAAG,IAAI,uBAAY,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAE5D,0BAA0B;IAC1B,MAAM,cAAc,GAAG,MAAM,IAAA,uBAAY,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAEhE,kCAAkC;IAClC,MAAM,IAAA,wBAAU,EAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;IAEpD,OAAO,CAAC,GAAG,CAAC,uCAAuC,iBAAiB,EAAE,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Project, SourceFile } from 'ts-morph';
|
|
2
|
+
import type { GeneratorConfig } from '../cli/options-parser';
|
|
3
|
+
/**
|
|
4
|
+
* Generate common types shared across the generated code
|
|
5
|
+
*/
|
|
6
|
+
export declare function generateCommonTypes(project: Project, _config: GeneratorConfig): Map<string, SourceFile>;
|
|
7
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/generator/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,eAAe,GACvB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAsBzB"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateCommonTypes = generateCommonTypes;
|
|
4
|
+
/**
|
|
5
|
+
* Generate common types shared across the generated code
|
|
6
|
+
*/
|
|
7
|
+
function generateCommonTypes(project, _config) {
|
|
8
|
+
const files = new Map();
|
|
9
|
+
// Generate AffectedRows type
|
|
10
|
+
const affectedRowsPath = 'common/AffectedRows.ts';
|
|
11
|
+
const affectedRowsFile = project.createSourceFile(affectedRowsPath, '', { overwrite: true });
|
|
12
|
+
generateAffectedRows(affectedRowsFile);
|
|
13
|
+
files.set(affectedRowsPath, affectedRowsFile);
|
|
14
|
+
// Generate BatchPayload type (alias for AffectedRows)
|
|
15
|
+
const batchPayloadPath = 'common/BatchPayload.ts';
|
|
16
|
+
const batchPayloadFile = project.createSourceFile(batchPayloadPath, '', { overwrite: true });
|
|
17
|
+
generateBatchPayload(batchPayloadFile);
|
|
18
|
+
files.set(batchPayloadPath, batchPayloadFile);
|
|
19
|
+
// Generate index file
|
|
20
|
+
const indexPath = 'common/index.ts';
|
|
21
|
+
const indexFile = project.createSourceFile(indexPath, '', { overwrite: true });
|
|
22
|
+
generateCommonIndex(indexFile);
|
|
23
|
+
files.set(indexPath, indexFile);
|
|
24
|
+
return files;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Generate AffectedRows type
|
|
28
|
+
*/
|
|
29
|
+
function generateAffectedRows(sourceFile) {
|
|
30
|
+
sourceFile.addImportDeclaration({
|
|
31
|
+
moduleSpecifier: '@nestjs/graphql',
|
|
32
|
+
namedImports: ['ObjectType', 'Field', 'Int'],
|
|
33
|
+
});
|
|
34
|
+
sourceFile.addClass({
|
|
35
|
+
name: 'AffectedRows',
|
|
36
|
+
isExported: true,
|
|
37
|
+
decorators: [
|
|
38
|
+
{
|
|
39
|
+
name: 'ObjectType',
|
|
40
|
+
arguments: [`{ description: 'Affected rows result' }`],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
properties: [
|
|
44
|
+
{
|
|
45
|
+
name: 'count',
|
|
46
|
+
type: 'number',
|
|
47
|
+
hasExclamationToken: true,
|
|
48
|
+
decorators: [
|
|
49
|
+
{
|
|
50
|
+
name: 'Field',
|
|
51
|
+
arguments: ['() => Int', `{ description: 'Number of affected rows' }`],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Generate BatchPayload type (alias for backwards compatibility)
|
|
60
|
+
*/
|
|
61
|
+
function generateBatchPayload(sourceFile) {
|
|
62
|
+
sourceFile.addImportDeclaration({
|
|
63
|
+
moduleSpecifier: './AffectedRows',
|
|
64
|
+
namedImports: ['AffectedRows'],
|
|
65
|
+
});
|
|
66
|
+
sourceFile.addTypeAlias({
|
|
67
|
+
name: 'BatchPayload',
|
|
68
|
+
isExported: true,
|
|
69
|
+
type: 'AffectedRows',
|
|
70
|
+
});
|
|
71
|
+
sourceFile.addStatements(`
|
|
72
|
+
/** @deprecated Use AffectedRows instead */
|
|
73
|
+
export { AffectedRows as BatchPayload };
|
|
74
|
+
`);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Generate common index file
|
|
78
|
+
*/
|
|
79
|
+
function generateCommonIndex(sourceFile) {
|
|
80
|
+
sourceFile.addExportDeclaration({
|
|
81
|
+
moduleSpecifier: './AffectedRows',
|
|
82
|
+
});
|
|
83
|
+
sourceFile.addExportDeclaration({
|
|
84
|
+
moduleSpecifier: './BatchPayload',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/generator/common.ts"],"names":[],"mappings":";;AAOA,kDAyBC;AA5BD;;GAEG;AACH,SAAgB,mBAAmB,CACjC,OAAgB,EAChB,OAAwB;IAExB,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;IAE5C,6BAA6B;IAC7B,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;IAClD,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7F,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IACvC,KAAK,CAAC,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IAE9C,sDAAsD;IACtD,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;IAClD,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7F,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IACvC,KAAK,CAAC,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IAE9C,sBAAsB;IACtB,MAAM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;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,UAAsB;IACjD,UAAU,CAAC,oBAAoB,CAAC;QAC9B,eAAe,EAAE,gBAAgB;KAClC,CAAC,CAAC;IACH,UAAU,CAAC,oBAAoB,CAAC;QAC9B,eAAe,EAAE,gBAAgB;KAClC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Enum, InputType, Model, ModelMapping, OutputType, Relation } from './types';
|
|
2
|
+
import type { DMMF } from '@prisma/generator-helper';
|
|
3
|
+
import type { GeneratorConfig } from '../../cli/options-parser';
|
|
4
|
+
/**
|
|
5
|
+
* Processed DMMF Document that provides easy access to transformed schema data
|
|
6
|
+
*/
|
|
7
|
+
export declare class DMMFDocument {
|
|
8
|
+
private readonly _dmmf;
|
|
9
|
+
private readonly _config;
|
|
10
|
+
private _models;
|
|
11
|
+
private _enums;
|
|
12
|
+
private _relations;
|
|
13
|
+
private _modelMappings;
|
|
14
|
+
private _inputTypes;
|
|
15
|
+
private _outputTypes;
|
|
16
|
+
constructor(dmmf: DMMF.Document, config: GeneratorConfig);
|
|
17
|
+
/**
|
|
18
|
+
* Get raw DMMF document
|
|
19
|
+
*/
|
|
20
|
+
get raw(): DMMF.Document;
|
|
21
|
+
/**
|
|
22
|
+
* Get generator config
|
|
23
|
+
*/
|
|
24
|
+
get config(): GeneratorConfig;
|
|
25
|
+
/**
|
|
26
|
+
* Get all transformed models
|
|
27
|
+
*/
|
|
28
|
+
get models(): Model[];
|
|
29
|
+
/**
|
|
30
|
+
* Get all transformed enums
|
|
31
|
+
*/
|
|
32
|
+
get enums(): Enum[];
|
|
33
|
+
/**
|
|
34
|
+
* Get all relations between models
|
|
35
|
+
*/
|
|
36
|
+
get relations(): Relation[];
|
|
37
|
+
/**
|
|
38
|
+
* Get CRUD operation mappings for all models
|
|
39
|
+
*/
|
|
40
|
+
get modelMappings(): ModelMapping[];
|
|
41
|
+
/**
|
|
42
|
+
* Get input types map
|
|
43
|
+
*/
|
|
44
|
+
get inputTypes(): Map<string, InputType>;
|
|
45
|
+
/**
|
|
46
|
+
* Get output types map
|
|
47
|
+
*/
|
|
48
|
+
get outputTypes(): Map<string, OutputType>;
|
|
49
|
+
/**
|
|
50
|
+
* Get a model by name
|
|
51
|
+
*/
|
|
52
|
+
getModel(name: string): Model | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Get an enum by name
|
|
55
|
+
*/
|
|
56
|
+
getEnum(name: string): Enum | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Get model mapping by model name
|
|
59
|
+
*/
|
|
60
|
+
getModelMapping(modelName: string): ModelMapping | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Get relations for a specific model
|
|
63
|
+
*/
|
|
64
|
+
getRelationsForModel(modelName: string): Relation[];
|
|
65
|
+
/**
|
|
66
|
+
* Get input type by name
|
|
67
|
+
*/
|
|
68
|
+
getInputType(name: string): InputType | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Get output type by name
|
|
71
|
+
*/
|
|
72
|
+
getOutputType(name: string): OutputType | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Check if a type is an enum
|
|
75
|
+
*/
|
|
76
|
+
isEnum(typeName: string): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Check if a type is a model
|
|
79
|
+
*/
|
|
80
|
+
isModel(typeName: string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Get all input types that match a pattern
|
|
83
|
+
*/
|
|
84
|
+
getInputTypesByPattern(pattern: RegExp): InputType[];
|
|
85
|
+
/**
|
|
86
|
+
* Get input types for a specific model
|
|
87
|
+
*/
|
|
88
|
+
getModelInputTypes(modelName: string): {
|
|
89
|
+
whereInput?: InputType;
|
|
90
|
+
whereUniqueInput?: InputType;
|
|
91
|
+
createInput?: InputType;
|
|
92
|
+
updateInput?: InputType;
|
|
93
|
+
orderByInput?: InputType;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=document.d.ts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