Skip to content

Commit

Permalink
Merge pull request #43 from pantharshit00/degueba/master
Browse files Browse the repository at this point in the history
  • Loading branch information
pantharshit00 authored Sep 24, 2021
2 parents fb5b099 + c48d6f6 commit 09722e6
Show file tree
Hide file tree
Showing 5 changed files with 1,209 additions and 1,276 deletions.
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,29 @@
"url": "https://github.com/pantharshit00/prisma-docs-generator/issues"
},
"dependencies": {
"@prisma/generator-helper": "^2.21.0",
"@prisma/sdk": "^2.21.0",
"@prisma/generator-helper": "^3.1.1",
"@prisma/sdk": "^3.1.1",
"express": "^4.17.1",
"indent-string": "^4.0.0",
"kleur": "^4.1.4",
"meow": "^9.0.0",
"pluralize": "^8.0.0",
"prismjs": "^1.23.0"
"prismjs": "^1.25.0"
},
"devDependencies": {
"@prisma/client": "^2.21.0",
"@types/express": "4.17.11",
"@types/jest": "^26.0.22",
"@types/node": "^14.14.37",
"@types/prismjs": "^1.16.5",
"@prisma/client": "^3.1.1",
"@types/express": "4.17.10",
"@types/jest": "^27.0.2",
"@types/node": "^16.9.6",
"@types/prismjs": "^1.16.6",
"cpy-cli": "^3.1.1",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"prisma": "^2.21.0",
"jest": "^27.2.1",
"prettier": "^2.4.1",
"prisma": "^3.1.1",
"rimraf": "^3.0.2",
"ts-jest": "^26.5.4",
"ts-node": "^9.1.1",
"typescript": "^4.2.4"
"ts-jest": "^27.0.5",
"ts-node": "^10.2.1",
"typescript": "^4.4.3"
},
"scripts": {
"start": "ts-node main.ts",
Expand Down
10 changes: 5 additions & 5 deletions src/generator/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type MGModel = {

type MGModelDirective = {
name: string;
values: string[];
values: any[];
};

type MGModelField = {
Expand Down Expand Up @@ -69,7 +69,8 @@ let fieldDirectiveMap = new Map<string, string>([
]);

export default class ModelGenerator
implements Generatable<ModelGeneratorStructure> {
implements Generatable<ModelGeneratorStructure>
{
data: ModelGeneratorStructure;

constructor(d: DMMFDocument) {
Expand Down Expand Up @@ -271,9 +272,8 @@ export default class ModelGenerator
getModelDirective(model: DMMF.Model): MGModelDirective[] {
let directiveValue: MGModelDirective[] = [];

if (model.idFields.length > 0) {
directiveValue.push({ name: '@@id', values: model.idFields });
}
if (model.primaryKey)
directiveValue.push({ name: '@@id', values: model.primaryKey.fields });

if (model.uniqueFields.length > 0) {
model.uniqueFields.forEach((uniqueField) => {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/__snapshots__/toc.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ exports[`TOC renders on toHTML 1`] = `
<a href=\\"#input-types\\">Input Types</a>
</div>
<ul class=\\"pl-3 ml-1 border-l-2 border-gray-400\\">
<li><a href=\\"#type-inputType-PostWhereInput\\">PostWhereInput</a></li><li><a href=\\"#type-inputType-PostOrderByInput\\">PostOrderByInput</a></li><li><a href=\\"#type-inputType-PostWhereUniqueInput\\">PostWhereUniqueInput</a></li><li><a href=\\"#type-inputType-PostScalarWhereWithAggregatesInput\\">PostScalarWhereWithAggregatesInput</a></li><li><a href=\\"#type-inputType-UserWhereInput\\">UserWhereInput</a></li><li><a href=\\"#type-inputType-UserOrderByInput\\">UserOrderByInput</a></li><li><a href=\\"#type-inputType-UserWhereUniqueInput\\">UserWhereUniqueInput</a></li><li><a href=\\"#type-inputType-UserScalarWhereWithAggregatesInput\\">UserScalarWhereWithAggregatesInput</a></li><li><a href=\\"#type-inputType-PostCreateInput\\">PostCreateInput</a></li><li><a href=\\"#type-inputType-PostUncheckedCreateInput\\">PostUncheckedCreateInput</a></li><li><a href=\\"#type-inputType-PostUpdateInput\\">PostUpdateInput</a></li><li><a href=\\"#type-inputType-PostUncheckedUpdateInput\\">PostUncheckedUpdateInput</a></li><li><a href=\\"#type-inputType-PostUpdateManyMutationInput\\">PostUpdateManyMutationInput</a></li><li><a href=\\"#type-inputType-PostUncheckedUpdateManyInput\\">PostUncheckedUpdateManyInput</a></li><li><a href=\\"#type-inputType-UserCreateInput\\">UserCreateInput</a></li><li><a href=\\"#type-inputType-UserUncheckedCreateInput\\">UserUncheckedCreateInput</a></li><li><a href=\\"#type-inputType-UserUpdateInput\\">UserUpdateInput</a></li><li><a href=\\"#type-inputType-UserUncheckedUpdateInput\\">UserUncheckedUpdateInput</a></li><li><a href=\\"#type-inputType-UserUpdateManyMutationInput\\">UserUpdateManyMutationInput</a></li><li><a href=\\"#type-inputType-UserUncheckedUpdateManyInput\\">UserUncheckedUpdateManyInput</a></li><li><a href=\\"#type-inputType-StringFilter\\">StringFilter</a></li><li><a href=\\"#type-inputType-StringWithAggregatesFilter\\">StringWithAggregatesFilter</a></li><li><a href=\\"#type-inputType-StringFieldUpdateOperationsInput\\">StringFieldUpdateOperationsInput</a></li><li><a href=\\"#type-inputType-NestedStringFilter\\">NestedStringFilter</a></li><li><a href=\\"#type-inputType-NestedStringWithAggregatesFilter\\">NestedStringWithAggregatesFilter</a></li><li><a href=\\"#type-inputType-NestedIntFilter\\">NestedIntFilter</a></li>
<li><a href=\\"#type-inputType-PostWhereInput\\">PostWhereInput</a></li><li><a href=\\"#type-inputType-PostOrderByWithRelationInput\\">PostOrderByWithRelationInput</a></li><li><a href=\\"#type-inputType-PostWhereUniqueInput\\">PostWhereUniqueInput</a></li><li><a href=\\"#type-inputType-PostOrderByWithAggregationInput\\">PostOrderByWithAggregationInput</a></li><li><a href=\\"#type-inputType-PostScalarWhereWithAggregatesInput\\">PostScalarWhereWithAggregatesInput</a></li><li><a href=\\"#type-inputType-UserWhereInput\\">UserWhereInput</a></li><li><a href=\\"#type-inputType-UserOrderByWithRelationInput\\">UserOrderByWithRelationInput</a></li><li><a href=\\"#type-inputType-UserWhereUniqueInput\\">UserWhereUniqueInput</a></li><li><a href=\\"#type-inputType-UserOrderByWithAggregationInput\\">UserOrderByWithAggregationInput</a></li><li><a href=\\"#type-inputType-UserScalarWhereWithAggregatesInput\\">UserScalarWhereWithAggregatesInput</a></li><li><a href=\\"#type-inputType-PostCreateInput\\">PostCreateInput</a></li><li><a href=\\"#type-inputType-PostUncheckedCreateInput\\">PostUncheckedCreateInput</a></li><li><a href=\\"#type-inputType-PostUpdateInput\\">PostUpdateInput</a></li><li><a href=\\"#type-inputType-PostUncheckedUpdateInput\\">PostUncheckedUpdateInput</a></li><li><a href=\\"#type-inputType-PostUpdateManyMutationInput\\">PostUpdateManyMutationInput</a></li><li><a href=\\"#type-inputType-PostUncheckedUpdateManyInput\\">PostUncheckedUpdateManyInput</a></li><li><a href=\\"#type-inputType-UserCreateInput\\">UserCreateInput</a></li><li><a href=\\"#type-inputType-UserUncheckedCreateInput\\">UserUncheckedCreateInput</a></li><li><a href=\\"#type-inputType-UserUpdateInput\\">UserUpdateInput</a></li><li><a href=\\"#type-inputType-UserUncheckedUpdateInput\\">UserUncheckedUpdateInput</a></li><li><a href=\\"#type-inputType-UserUpdateManyMutationInput\\">UserUpdateManyMutationInput</a></li><li><a href=\\"#type-inputType-UserUncheckedUpdateManyInput\\">UserUncheckedUpdateManyInput</a></li><li><a href=\\"#type-inputType-StringFilter\\">StringFilter</a></li><li><a href=\\"#type-inputType-PostCountOrderByAggregateInput\\">PostCountOrderByAggregateInput</a></li><li><a href=\\"#type-inputType-PostMaxOrderByAggregateInput\\">PostMaxOrderByAggregateInput</a></li><li><a href=\\"#type-inputType-PostMinOrderByAggregateInput\\">PostMinOrderByAggregateInput</a></li><li><a href=\\"#type-inputType-StringWithAggregatesFilter\\">StringWithAggregatesFilter</a></li><li><a href=\\"#type-inputType-UserCountOrderByAggregateInput\\">UserCountOrderByAggregateInput</a></li><li><a href=\\"#type-inputType-UserMaxOrderByAggregateInput\\">UserMaxOrderByAggregateInput</a></li><li><a href=\\"#type-inputType-UserMinOrderByAggregateInput\\">UserMinOrderByAggregateInput</a></li><li><a href=\\"#type-inputType-StringFieldUpdateOperationsInput\\">StringFieldUpdateOperationsInput</a></li><li><a href=\\"#type-inputType-NestedStringFilter\\">NestedStringFilter</a></li><li><a href=\\"#type-inputType-NestedStringWithAggregatesFilter\\">NestedStringWithAggregatesFilter</a></li><li><a href=\\"#type-inputType-NestedIntFilter\\">NestedIntFilter</a></li>
</ul>
</li>
<li class=\\"mb-4\\">
Expand Down
1 change: 1 addition & 0 deletions src/tests/model.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ModelGenerator from '../generator/model';
import transformDMMF from '../generator/transformDMMF';
//@ts-ignore
import { getDMMF } from '@prisma/sdk';

describe('model generator', () => {
Expand Down
Loading

0 comments on commit 09722e6

Please sign in to comment.