@zenstackhq/openapi 1.0.0-alpha.60
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 +5 -0
- package/generator.d.ts +34 -0
- package/generator.js +555 -0
- package/generator.js.map +1 -0
- package/index.d.ts +5 -0
- package/index.js +21 -0
- package/index.js.map +1 -0
- package/package.json +49 -0
- package/plugin.zmodel +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 ZenStack
|
|
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
package/generator.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DMMF } from '@prisma/generator-helper';
|
|
2
|
+
import { PluginOptions } from '@zenstackhq/sdk';
|
|
3
|
+
import { type Model } from '@zenstackhq/sdk/ast';
|
|
4
|
+
export declare class OpenAPIGenerator {
|
|
5
|
+
private model;
|
|
6
|
+
private options;
|
|
7
|
+
private dmmf;
|
|
8
|
+
private inputObjectTypes;
|
|
9
|
+
private outputObjectTypes;
|
|
10
|
+
private usedComponents;
|
|
11
|
+
private aggregateOperationSupport;
|
|
12
|
+
constructor(model: Model, options: PluginOptions, dmmf: DMMF.Document);
|
|
13
|
+
generate(): void;
|
|
14
|
+
private pruneComponents;
|
|
15
|
+
private collectUsedComponents;
|
|
16
|
+
private generatePaths;
|
|
17
|
+
private generatePathsForModel;
|
|
18
|
+
private aggregateFields;
|
|
19
|
+
private component;
|
|
20
|
+
private getOption;
|
|
21
|
+
private generateComponents;
|
|
22
|
+
private generateEnumComponent;
|
|
23
|
+
private generateEntityComponent;
|
|
24
|
+
private generateField;
|
|
25
|
+
private generateInputComponent;
|
|
26
|
+
private generateOutputComponent;
|
|
27
|
+
private setInputRequired;
|
|
28
|
+
private setOutputRequired;
|
|
29
|
+
private prismaTypeToOpenAPIType;
|
|
30
|
+
private wrapArray;
|
|
31
|
+
private ref;
|
|
32
|
+
private array;
|
|
33
|
+
private oneOf;
|
|
34
|
+
}
|
package/generator.js
ADDED
|
@@ -0,0 +1,555 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.OpenAPIGenerator = void 0;
|
|
30
|
+
const sdk_1 = require("@zenstackhq/sdk");
|
|
31
|
+
const ast_1 = require("@zenstackhq/sdk/ast");
|
|
32
|
+
const change_case_1 = require("change-case");
|
|
33
|
+
const fs = __importStar(require("fs"));
|
|
34
|
+
const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
|
35
|
+
// TODO: move these to SDK
|
|
36
|
+
const dmmf_helpers_1 = require("@zenstackhq/sdk/dmmf-helpers");
|
|
37
|
+
class OpenAPIGenerator {
|
|
38
|
+
constructor(model, options, dmmf) {
|
|
39
|
+
this.model = model;
|
|
40
|
+
this.options = options;
|
|
41
|
+
this.dmmf = dmmf;
|
|
42
|
+
this.inputObjectTypes = [];
|
|
43
|
+
this.outputObjectTypes = [];
|
|
44
|
+
this.usedComponents = new Set();
|
|
45
|
+
}
|
|
46
|
+
generate() {
|
|
47
|
+
const output = this.getOption('output', '');
|
|
48
|
+
if (!output) {
|
|
49
|
+
throw new sdk_1.PluginError('"output" option is required');
|
|
50
|
+
}
|
|
51
|
+
// input types
|
|
52
|
+
this.inputObjectTypes.push(...this.dmmf.schema.inputObjectTypes.prisma);
|
|
53
|
+
this.outputObjectTypes.push(...this.dmmf.schema.outputObjectTypes.prisma);
|
|
54
|
+
(0, dmmf_helpers_1.addMissingInputObjectTypesForModelArgs)(this.inputObjectTypes, this.dmmf.datamodel.models);
|
|
55
|
+
(0, dmmf_helpers_1.addMissingInputObjectTypesForInclude)(this.inputObjectTypes, this.dmmf.datamodel.models);
|
|
56
|
+
(0, dmmf_helpers_1.addMissingInputObjectTypesForSelect)(this.inputObjectTypes, this.outputObjectTypes, this.dmmf.datamodel.models);
|
|
57
|
+
(0, dmmf_helpers_1.addMissingInputObjectTypesForAggregate)(this.inputObjectTypes, this.outputObjectTypes);
|
|
58
|
+
this.aggregateOperationSupport = (0, dmmf_helpers_1.resolveAggregateOperationSupport)(this.inputObjectTypes);
|
|
59
|
+
const components = this.generateComponents();
|
|
60
|
+
const paths = this.generatePaths(components);
|
|
61
|
+
// prune unused component schemas
|
|
62
|
+
this.pruneComponents(components);
|
|
63
|
+
const openapi = {
|
|
64
|
+
openapi: '3.0.0',
|
|
65
|
+
info: {
|
|
66
|
+
title: this.getOption('title', 'ZenStack Generated API'),
|
|
67
|
+
version: this.getOption('version', '1.0.0'),
|
|
68
|
+
},
|
|
69
|
+
components,
|
|
70
|
+
paths,
|
|
71
|
+
};
|
|
72
|
+
fs.writeFileSync(output, JSON.stringify(openapi, undefined, 2));
|
|
73
|
+
}
|
|
74
|
+
pruneComponents(components) {
|
|
75
|
+
const schemas = components.schemas;
|
|
76
|
+
if (schemas) {
|
|
77
|
+
// build a transitive closure for all reachable schemas from roots
|
|
78
|
+
const allUsed = new Set(this.usedComponents);
|
|
79
|
+
let todo = [...allUsed];
|
|
80
|
+
while (todo.length > 0) {
|
|
81
|
+
const curr = new Set(allUsed);
|
|
82
|
+
Object.entries(schemas)
|
|
83
|
+
.filter(([key]) => todo.includes(key))
|
|
84
|
+
.forEach(([, value]) => {
|
|
85
|
+
this.collectUsedComponents(value, allUsed);
|
|
86
|
+
});
|
|
87
|
+
todo = [...allUsed].filter((e) => !curr.has(e));
|
|
88
|
+
}
|
|
89
|
+
// prune unused schemas
|
|
90
|
+
Object.keys(schemas).forEach((key) => {
|
|
91
|
+
if (!allUsed.has(key)) {
|
|
92
|
+
delete schemas[key];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
collectUsedComponents(value, allUsed) {
|
|
98
|
+
if (!value) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (Array.isArray(value)) {
|
|
102
|
+
value.forEach((item) => {
|
|
103
|
+
this.collectUsedComponents(item, allUsed);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
else if (typeof value === 'object') {
|
|
107
|
+
Object.entries(value).forEach(([subKey, subValue]) => {
|
|
108
|
+
if (subKey === '$ref') {
|
|
109
|
+
const ref = subValue;
|
|
110
|
+
const name = ref.split('/').pop();
|
|
111
|
+
if (name && !allUsed.has(name)) {
|
|
112
|
+
allUsed.add(name);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this.collectUsedComponents(subValue, allUsed);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
generatePaths(components) {
|
|
122
|
+
let result = {};
|
|
123
|
+
const includeModels = this.model.declarations
|
|
124
|
+
.filter((d) => (0, ast_1.isDataModel)(d) && !(0, sdk_1.hasAttribute)(d, '@@openapi.ignore'))
|
|
125
|
+
.map((d) => d.name);
|
|
126
|
+
for (const model of this.dmmf.datamodel.models) {
|
|
127
|
+
if (includeModels.includes(model.name)) {
|
|
128
|
+
result = Object.assign(Object.assign({}, result), this.generatePathsForModel(model, components));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
generatePathsForModel(model, components) {
|
|
134
|
+
const result = {};
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
136
|
+
const ops = this.dmmf.mappings.modelOperations.find((ops) => ops.model === model.name);
|
|
137
|
+
if (!ops) {
|
|
138
|
+
throw new sdk_1.PluginError(`No operations found for model ${model.name}`);
|
|
139
|
+
}
|
|
140
|
+
const definitions = [
|
|
141
|
+
{
|
|
142
|
+
key: 'createOne',
|
|
143
|
+
method: 'post',
|
|
144
|
+
operation: 'create',
|
|
145
|
+
inputType: this.component(`${model.name}CreateArgs`, {
|
|
146
|
+
type: 'object',
|
|
147
|
+
properties: {
|
|
148
|
+
select: this.ref(`${model.name}Select`),
|
|
149
|
+
include: this.ref(`${model.name}Include`),
|
|
150
|
+
data: this.ref(`${model.name}CreateInput`),
|
|
151
|
+
},
|
|
152
|
+
}, components),
|
|
153
|
+
outputType: this.ref(model.name),
|
|
154
|
+
description: `Create a new ${model.name}`,
|
|
155
|
+
successCode: 201,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
key: 'createMany',
|
|
159
|
+
method: 'post',
|
|
160
|
+
inputType: this.component(`${model.name}CreateManyArgs`, {
|
|
161
|
+
type: 'object',
|
|
162
|
+
properties: {
|
|
163
|
+
data: this.ref(`${model.name}CreateManyInput`),
|
|
164
|
+
},
|
|
165
|
+
}, components),
|
|
166
|
+
outputType: this.ref('BatchPayload'),
|
|
167
|
+
description: `Create several ${model.name}`,
|
|
168
|
+
successCode: 201,
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
key: 'findUnique',
|
|
172
|
+
method: 'get',
|
|
173
|
+
inputType: this.component(`${model.name}FindUniqueArgs`, {
|
|
174
|
+
type: 'object',
|
|
175
|
+
properties: {
|
|
176
|
+
select: this.ref(`${model.name}Select`),
|
|
177
|
+
include: this.ref(`${model.name}Include`),
|
|
178
|
+
where: this.ref(`${model.name}WhereUniqueInput`),
|
|
179
|
+
},
|
|
180
|
+
}, components),
|
|
181
|
+
outputType: this.ref(model.name),
|
|
182
|
+
description: `Find one unique ${model.name}`,
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
key: 'findFirst',
|
|
186
|
+
method: 'get',
|
|
187
|
+
inputType: this.component(`${model.name}FindFirstArgs`, {
|
|
188
|
+
type: 'object',
|
|
189
|
+
properties: {
|
|
190
|
+
select: this.ref(`${model.name}Select`),
|
|
191
|
+
include: this.ref(`${model.name}Include`),
|
|
192
|
+
where: this.ref(`${model.name}WhereInput`),
|
|
193
|
+
},
|
|
194
|
+
}, components),
|
|
195
|
+
outputType: this.ref(model.name),
|
|
196
|
+
description: `Find the first ${model.name} matching the given condition`,
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
key: 'findMany',
|
|
200
|
+
method: 'get',
|
|
201
|
+
inputType: this.component(`${model.name}FindManyArgs`, {
|
|
202
|
+
type: 'object',
|
|
203
|
+
properties: {
|
|
204
|
+
select: this.ref(`${model.name}Select`),
|
|
205
|
+
include: this.ref(`${model.name}Include`),
|
|
206
|
+
where: this.ref(`${model.name}WhereInput`),
|
|
207
|
+
},
|
|
208
|
+
}, components),
|
|
209
|
+
outputType: this.array(this.ref(model.name)),
|
|
210
|
+
description: `Find a list of ${model.name}`,
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
key: 'updateOne',
|
|
214
|
+
method: 'patch',
|
|
215
|
+
operation: 'update',
|
|
216
|
+
inputType: this.component(`${model.name}UpdateArgs`, {
|
|
217
|
+
type: 'object',
|
|
218
|
+
properties: {
|
|
219
|
+
select: this.ref(`${model.name}Select`),
|
|
220
|
+
include: this.ref(`${model.name}Include`),
|
|
221
|
+
where: this.ref(`${model.name}WhereUniqueInput`),
|
|
222
|
+
data: this.ref(`${model.name}UpdateInput`),
|
|
223
|
+
},
|
|
224
|
+
}, components),
|
|
225
|
+
outputType: this.ref(model.name),
|
|
226
|
+
description: `Update a ${model.name}`,
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
key: 'updateMany',
|
|
230
|
+
method: 'patch',
|
|
231
|
+
inputType: this.component(`${model.name}UpdateManyArgs`, {
|
|
232
|
+
type: 'object',
|
|
233
|
+
properties: {
|
|
234
|
+
where: this.ref(`${model.name}WhereInput`),
|
|
235
|
+
data: this.ref(`${model.name}UpdateManyMutationInput`),
|
|
236
|
+
},
|
|
237
|
+
}, components),
|
|
238
|
+
outputType: this.ref('BatchPayload'),
|
|
239
|
+
description: `Update ${model.name}s matching the given condition`,
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
key: 'upsertOne',
|
|
243
|
+
method: 'post',
|
|
244
|
+
operation: 'upsert',
|
|
245
|
+
inputType: this.component(`${model.name}UpsertArgs`, {
|
|
246
|
+
type: 'object',
|
|
247
|
+
properties: {
|
|
248
|
+
select: this.ref(`${model.name}Select`),
|
|
249
|
+
include: this.ref(`${model.name}Include`),
|
|
250
|
+
where: this.ref(`${model.name}WhereUniqueInput`),
|
|
251
|
+
create: this.ref(`${model.name}CreateInput`),
|
|
252
|
+
update: this.ref(`${model.name}UpdateInput`),
|
|
253
|
+
},
|
|
254
|
+
}, components),
|
|
255
|
+
outputType: this.ref(model.name),
|
|
256
|
+
description: `Upsert a ${model.name}`,
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
key: 'deleteOne',
|
|
260
|
+
method: 'delete',
|
|
261
|
+
inputType: this.component(`${model.name}DeleteUniqueArgs`, {
|
|
262
|
+
type: 'object',
|
|
263
|
+
properties: {
|
|
264
|
+
select: this.ref(`${model.name}Select`),
|
|
265
|
+
include: this.ref(`${model.name}Include`),
|
|
266
|
+
where: this.ref(`${model.name}WhereUniqueInput`),
|
|
267
|
+
},
|
|
268
|
+
}, components),
|
|
269
|
+
outputType: this.ref(model.name),
|
|
270
|
+
description: `Delete one unique ${model.name}`,
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
key: 'deleteMany',
|
|
274
|
+
method: 'delete',
|
|
275
|
+
inputType: this.component(`${model.name}DeleteManyArgs`, {
|
|
276
|
+
type: 'object',
|
|
277
|
+
properties: {
|
|
278
|
+
where: this.ref(`${model.name}WhereInput`),
|
|
279
|
+
},
|
|
280
|
+
}, components),
|
|
281
|
+
outputType: this.ref('BatchPayload'),
|
|
282
|
+
description: `Delete ${model.name}s matching the given condition`,
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
key: 'count',
|
|
286
|
+
method: 'get',
|
|
287
|
+
inputType: this.component(`${model.name}CountArgs`, {
|
|
288
|
+
type: 'object',
|
|
289
|
+
properties: {
|
|
290
|
+
select: this.ref(`${model.name}Select`),
|
|
291
|
+
where: this.ref(`${model.name}WhereInput`),
|
|
292
|
+
},
|
|
293
|
+
}, components),
|
|
294
|
+
outputType: this.oneOf({ type: 'integer' }, this.ref(`${model.name}CountAggregateOutputType`)),
|
|
295
|
+
description: `Find a list of ${model.name}`,
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
key: 'aggregate',
|
|
299
|
+
method: 'get',
|
|
300
|
+
inputType: this.component(`${model.name}AggregateArgs`, {
|
|
301
|
+
type: 'object',
|
|
302
|
+
properties: Object.assign({ where: this.ref(`${model.name}WhereInput`), orderBy: this.ref(`${model.name}OrderByWithRelationInput`), cursor: this.ref(`${model.name}WhereUniqueInput`), take: { type: 'integer' }, skip: { type: 'integer' } }, this.aggregateFields(model)),
|
|
303
|
+
}, components),
|
|
304
|
+
outputType: this.ref(`Aggregate${model.name}`),
|
|
305
|
+
description: `Aggregate ${model.name}s`,
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
key: 'groupBy',
|
|
309
|
+
method: 'get',
|
|
310
|
+
inputType: this.component(`${model.name}GroupByArgs`, {
|
|
311
|
+
type: 'object',
|
|
312
|
+
properties: Object.assign({ where: this.ref(`${model.name}WhereInput`), orderBy: this.ref(`${model.name}OrderByWithRelationInput`), by: this.ref(`${model.name}ScalarFieldEnum`), having: this.ref(`${model.name}ScalarWhereWithAggregatesInput`), take: { type: 'integer' }, skip: { type: 'integer' } }, this.aggregateFields(model)),
|
|
313
|
+
}, components),
|
|
314
|
+
outputType: this.array(this.ref(`${model.name}GroupByOutputType`)),
|
|
315
|
+
description: `Group ${model.name}s by fields`,
|
|
316
|
+
},
|
|
317
|
+
];
|
|
318
|
+
for (const { key, method, operation, description, inputType, outputType, successCode } of definitions) {
|
|
319
|
+
if (ops[key] || key === 'count' /* prisma operation list doesn't contain 'count' */) {
|
|
320
|
+
const op = operation !== null && operation !== void 0 ? operation : key;
|
|
321
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
322
|
+
const def = {
|
|
323
|
+
operationId: `${op}${model.name}`,
|
|
324
|
+
responses: {
|
|
325
|
+
[successCode !== undefined ? successCode : '200']: {
|
|
326
|
+
description: 'Successful operation',
|
|
327
|
+
content: {
|
|
328
|
+
'application/json': {
|
|
329
|
+
schema: outputType,
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
'400': {
|
|
334
|
+
description: 'Invalid request',
|
|
335
|
+
},
|
|
336
|
+
'403': {
|
|
337
|
+
description: 'Forbidden',
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
};
|
|
341
|
+
if (inputType) {
|
|
342
|
+
if (['post', 'put', 'patch'].includes(method)) {
|
|
343
|
+
def.requestBody = {
|
|
344
|
+
description,
|
|
345
|
+
content: {
|
|
346
|
+
'application/json': {
|
|
347
|
+
schema: inputType,
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
def.parameters = [
|
|
354
|
+
{
|
|
355
|
+
name: 'q',
|
|
356
|
+
in: 'query',
|
|
357
|
+
required: true,
|
|
358
|
+
schema: inputType,
|
|
359
|
+
},
|
|
360
|
+
];
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
result[`/${(0, change_case_1.camelCase)(model.name)}/${op}`] = {
|
|
364
|
+
[method]: def,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return result;
|
|
369
|
+
}
|
|
370
|
+
aggregateFields(model) {
|
|
371
|
+
const result = {};
|
|
372
|
+
const supportedOps = this.aggregateOperationSupport[model.name];
|
|
373
|
+
if (supportedOps) {
|
|
374
|
+
if (supportedOps.count) {
|
|
375
|
+
result._count = this.oneOf({ type: 'boolean' }, this.ref(`${model.name}CountAggregateInput`));
|
|
376
|
+
}
|
|
377
|
+
if (supportedOps.min) {
|
|
378
|
+
result._min = this.ref(`${model.name}MinAggregateInput`);
|
|
379
|
+
}
|
|
380
|
+
if (supportedOps.max) {
|
|
381
|
+
result._max = this.ref(`${model.name}MaxAggregateInput`);
|
|
382
|
+
}
|
|
383
|
+
if (supportedOps.sum) {
|
|
384
|
+
result._sum = this.ref(`${model.name}SumAggregateInput`);
|
|
385
|
+
}
|
|
386
|
+
if (supportedOps.avg) {
|
|
387
|
+
result._avg = this.ref(`${model.name}AvgAggregateInput`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return result;
|
|
391
|
+
}
|
|
392
|
+
component(name, def, components) {
|
|
393
|
+
(0, tiny_invariant_1.default)(components.schemas);
|
|
394
|
+
components.schemas[name] = def;
|
|
395
|
+
return this.ref(name);
|
|
396
|
+
}
|
|
397
|
+
getOption(name, defaultValue) {
|
|
398
|
+
return this.options[name] ? this.options[name] : defaultValue;
|
|
399
|
+
}
|
|
400
|
+
generateComponents() {
|
|
401
|
+
var _a;
|
|
402
|
+
const schemas = {};
|
|
403
|
+
const components = {
|
|
404
|
+
schemas,
|
|
405
|
+
};
|
|
406
|
+
// user-defined and built-in enums
|
|
407
|
+
for (const _enum of [...((_a = this.dmmf.schema.enumTypes.model) !== null && _a !== void 0 ? _a : []), ...this.dmmf.schema.enumTypes.prisma]) {
|
|
408
|
+
schemas[_enum.name] = this.generateEnumComponent(_enum);
|
|
409
|
+
}
|
|
410
|
+
// data models
|
|
411
|
+
for (const model of this.dmmf.datamodel.models) {
|
|
412
|
+
schemas[model.name] = this.generateEntityComponent(model);
|
|
413
|
+
}
|
|
414
|
+
for (const input of this.inputObjectTypes) {
|
|
415
|
+
schemas[input.name] = this.generateInputComponent(input);
|
|
416
|
+
}
|
|
417
|
+
for (const output of this.outputObjectTypes.filter((t) => !['Query', 'Mutation'].includes(t.name))) {
|
|
418
|
+
schemas[output.name] = this.generateOutputComponent(output);
|
|
419
|
+
}
|
|
420
|
+
// misc types
|
|
421
|
+
schemas['BatchPayload'] = {
|
|
422
|
+
type: 'object',
|
|
423
|
+
properties: {
|
|
424
|
+
count: { type: 'integer' },
|
|
425
|
+
},
|
|
426
|
+
};
|
|
427
|
+
return components;
|
|
428
|
+
}
|
|
429
|
+
generateEnumComponent(_enum) {
|
|
430
|
+
const schema = {
|
|
431
|
+
type: 'string',
|
|
432
|
+
enum: _enum.values.filter((f) => !sdk_1.AUXILIARY_FIELDS.includes(f)),
|
|
433
|
+
};
|
|
434
|
+
return schema;
|
|
435
|
+
}
|
|
436
|
+
generateEntityComponent(model) {
|
|
437
|
+
const properties = {};
|
|
438
|
+
const fields = model.fields.filter((f) => !sdk_1.AUXILIARY_FIELDS.includes(f.name));
|
|
439
|
+
const required = [];
|
|
440
|
+
for (const field of fields) {
|
|
441
|
+
properties[field.name] = this.generateField(field);
|
|
442
|
+
if (field.isRequired && !(field.relationName && field.isList)) {
|
|
443
|
+
required.push(field.name);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
const result = { type: 'object', properties };
|
|
447
|
+
if (required.length > 0) {
|
|
448
|
+
result.required = required;
|
|
449
|
+
}
|
|
450
|
+
return result;
|
|
451
|
+
}
|
|
452
|
+
generateField(def) {
|
|
453
|
+
switch (def.kind) {
|
|
454
|
+
case 'scalar':
|
|
455
|
+
return this.wrapArray(this.prismaTypeToOpenAPIType(def.type), def.isList);
|
|
456
|
+
case 'enum':
|
|
457
|
+
case 'object':
|
|
458
|
+
return this.wrapArray(this.ref(def.type, false), def.isList);
|
|
459
|
+
default:
|
|
460
|
+
throw new sdk_1.PluginError(`Unsupported field kind: ${def.kind}`);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
generateInputComponent(input) {
|
|
464
|
+
const properties = {};
|
|
465
|
+
const fields = input.fields.filter((f) => !sdk_1.AUXILIARY_FIELDS.includes(f.name));
|
|
466
|
+
for (const field of fields) {
|
|
467
|
+
const options = field.inputTypes
|
|
468
|
+
.filter((f) => f.type !== 'Null')
|
|
469
|
+
.map((f) => {
|
|
470
|
+
return this.wrapArray(this.prismaTypeToOpenAPIType(f.type), f.isList);
|
|
471
|
+
});
|
|
472
|
+
properties[field.name] = options.length > 1 ? { oneOf: options } : options[0];
|
|
473
|
+
}
|
|
474
|
+
const result = { type: 'object', properties };
|
|
475
|
+
this.setInputRequired(fields, result);
|
|
476
|
+
return result;
|
|
477
|
+
}
|
|
478
|
+
generateOutputComponent(output) {
|
|
479
|
+
const properties = {};
|
|
480
|
+
const fields = output.fields.filter((f) => !sdk_1.AUXILIARY_FIELDS.includes(f.name));
|
|
481
|
+
for (const field of fields) {
|
|
482
|
+
let outputType;
|
|
483
|
+
switch (field.outputType.location) {
|
|
484
|
+
case 'scalar':
|
|
485
|
+
case 'enumTypes':
|
|
486
|
+
outputType = this.prismaTypeToOpenAPIType(field.outputType.type);
|
|
487
|
+
break;
|
|
488
|
+
case 'outputObjectTypes':
|
|
489
|
+
outputType = this.prismaTypeToOpenAPIType(typeof field.outputType.type === 'string' ? field.outputType.type : field.outputType.type.name);
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
field.outputType;
|
|
493
|
+
properties[field.name] = this.wrapArray(outputType, field.outputType.isList);
|
|
494
|
+
}
|
|
495
|
+
const result = { type: 'object', properties };
|
|
496
|
+
this.setOutputRequired(fields, result);
|
|
497
|
+
return result;
|
|
498
|
+
}
|
|
499
|
+
setInputRequired(fields, result) {
|
|
500
|
+
const required = fields.filter((f) => f.isRequired).map((f) => f.name);
|
|
501
|
+
if (required.length > 0) {
|
|
502
|
+
result.required = required;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
setOutputRequired(fields, result) {
|
|
506
|
+
const required = fields.filter((f) => f.isNullable !== true).map((f) => f.name);
|
|
507
|
+
if (required.length > 0) {
|
|
508
|
+
result.required = required;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
prismaTypeToOpenAPIType(type) {
|
|
512
|
+
switch (type) {
|
|
513
|
+
case 'String':
|
|
514
|
+
return { type: 'string' };
|
|
515
|
+
case 'Int':
|
|
516
|
+
case 'BigInt':
|
|
517
|
+
return { type: 'integer' };
|
|
518
|
+
case 'Float':
|
|
519
|
+
case 'Decimal':
|
|
520
|
+
return { type: 'number' };
|
|
521
|
+
case 'Boolean':
|
|
522
|
+
case 'True':
|
|
523
|
+
return { type: 'boolean' };
|
|
524
|
+
case 'DateTime':
|
|
525
|
+
return { type: 'string', format: 'date-time' };
|
|
526
|
+
case 'JSON':
|
|
527
|
+
case 'Json':
|
|
528
|
+
return {};
|
|
529
|
+
default:
|
|
530
|
+
return this.ref(type.toString(), false);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
wrapArray(schema, isArray) {
|
|
534
|
+
if (isArray) {
|
|
535
|
+
return { type: 'array', items: schema };
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
return schema;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
ref(type, rooted = true) {
|
|
542
|
+
if (rooted) {
|
|
543
|
+
this.usedComponents.add(type);
|
|
544
|
+
}
|
|
545
|
+
return { $ref: `#/components/schemas/${type}` };
|
|
546
|
+
}
|
|
547
|
+
array(itemType) {
|
|
548
|
+
return { type: 'array', items: itemType };
|
|
549
|
+
}
|
|
550
|
+
oneOf(...schemas) {
|
|
551
|
+
return { oneOf: schemas };
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
exports.OpenAPIGenerator = OpenAPIGenerator;
|
|
555
|
+
//# sourceMappingURL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AO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC9C,CAAC;IAEO,KAAK,CAAC,GAAG,OAAkB;QAC/B,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAC9B,CAAC;CACJ;AAroBD,4CAqoBC"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DMMF } from '@prisma/generator-helper';
|
|
2
|
+
import { PluginOptions } from '@zenstackhq/sdk';
|
|
3
|
+
import { Model } from '@zenstackhq/sdk/ast';
|
|
4
|
+
export declare const name = "OpenAPI";
|
|
5
|
+
export default function run(model: Model, options: PluginOptions, dmmf: DMMF.Document): Promise<void>;
|
package/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.name = void 0;
|
|
13
|
+
const generator_1 = require("./generator");
|
|
14
|
+
exports.name = 'OpenAPI';
|
|
15
|
+
function run(model, options, dmmf) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
return new generator_1.OpenAPIGenerator(model, options, dmmf).generate();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.default = run;
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,2CAA+C;AAElC,QAAA,IAAI,GAAG,SAAS,CAAC;AAE9B,SAA8B,GAAG,CAAC,KAAY,EAAE,OAAsB,EAAE,IAAmB;;QACvF,OAAO,IAAI,4BAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IACjE,CAAC;CAAA;AAFD,sBAEC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zenstackhq/openapi",
|
|
3
|
+
"displayName": "ZenStack Plugin and Runtime for OpenAPI",
|
|
4
|
+
"version": "1.0.0-alpha.60",
|
|
5
|
+
"description": "ZenStack plugin and runtime supporting OpenAPI",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/zenstackhq/zenstack"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"directory": "dist",
|
|
13
|
+
"linkDirectory": true
|
|
14
|
+
},
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"author": "ZenStack Team",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@prisma/generator-helper": "^4.7.1",
|
|
20
|
+
"change-case": "^4.1.2",
|
|
21
|
+
"openapi-types": "^12.1.0",
|
|
22
|
+
"tiny-invariant": "^1.3.1",
|
|
23
|
+
"@zenstackhq/sdk": "1.0.0-alpha.70",
|
|
24
|
+
"@zenstackhq/runtime": "1.0.0-alpha.70"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@prisma/internals": "^4.7.1",
|
|
28
|
+
"@types/jest": "^29.4.0",
|
|
29
|
+
"@types/tmp": "^0.2.3",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
|
31
|
+
"@typescript-eslint/parser": "^5.54.0",
|
|
32
|
+
"copyfiles": "^2.4.1",
|
|
33
|
+
"eslint": "^8.35.0",
|
|
34
|
+
"jest": "^29.4.3",
|
|
35
|
+
"rimraf": "^3.0.2",
|
|
36
|
+
"tmp": "^0.2.1",
|
|
37
|
+
"ts-jest": "^29.0.5",
|
|
38
|
+
"typescript": "^4.9.5",
|
|
39
|
+
"@zenstackhq/testtools": "1.0.0-alpha.70",
|
|
40
|
+
"zenstack": "1.0.0-alpha.70"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"clean": "rimraf dist",
|
|
44
|
+
"build": "pnpm lint && pnpm clean && tsc && copyfiles ./package.json ./README.md ./LICENSE dist && copyfiles -u 1 ./src/plugin.zmodel dist",
|
|
45
|
+
"watch": "tsc --watch",
|
|
46
|
+
"lint": "eslint src --ext ts",
|
|
47
|
+
"test": "jest"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/plugin.zmodel
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
attribute @@openapi.ignore()
|