nest-prisma_doc-gen 1.0.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/dist/entities/dto-generator.d.ts +13 -0
- package/dist/entities/dto-generator.js +51 -0
- package/dist/entities/entity-generator.d.ts +12 -0
- package/dist/entities/entity-generator.js +47 -0
- package/dist/entities/enum.d.ts +22 -0
- package/dist/entities/enum.js +37 -0
- package/dist/entities/field.d.ts +24 -0
- package/dist/entities/field.js +169 -0
- package/dist/entities/model.d.ts +11 -0
- package/dist/entities/model.js +18 -0
- package/dist/entities/validator.js +12 -0
- package/dist/field.type.d.ts +7 -0
- package/dist/field.type.js +22 -0
- package/dist/file.d.ts +11 -0
- package/dist/file.js +26 -0
- package/dist/helpers/helpers.d.ts +14 -0
- package/dist/helpers/helpers.js +143 -0
- package/dist/helpers/loader.d.ts +4 -0
- package/dist/helpers/loader.js +50 -0
- package/dist/helpers/propeties.static.d.ts +2 -0
- package/dist/helpers/propeties.static.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/main.d.ts +13 -0
- package/dist/main.js +53 -0
- package/dist/rules.d.ts +11 -0
- package/dist/rules.js +19 -0
- package/dist/static.d.ts +6 -0
- package/dist/static.js +25 -0
- package/dist/types.d.ts +79 -0
- package/dist/types.js +17 -0
- package/package.json +40 -0
- package/src/entities/dto-generator.ts +61 -0
- package/src/entities/entity-generator.ts +55 -0
- package/src/entities/enum.ts +47 -0
- package/src/entities/field.ts +188 -0
- package/src/entities/model.ts +23 -0
- package/src/entities/validator.ts +17 -0
- package/src/field.type.ts +27 -0
- package/src/file.ts +34 -0
- package/src/helpers/helpers.ts +152 -0
- package/src/helpers/loader.ts +60 -0
- package/src/helpers/propeties.static.ts +3 -0
- package/src/index.ts +2 -0
- package/src/main.ts +69 -0
- package/src/rules.ts +31 -0
- package/src/static.ts +28 -0
- package/src/types/global.d.ts +1 -0
- package/src/types.ts +109 -0
- package/tsconfig.json +15 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export type FieldKind = "scalar" | "object" | "enum";
|
|
2
|
+
type FieldDefaultName = "now" | "autoincrement" | "cuid";
|
|
3
|
+
|
|
4
|
+
export type FieldType = "entity" | "dto";
|
|
5
|
+
|
|
6
|
+
export type DbName = string | null;
|
|
7
|
+
|
|
8
|
+
export type Scalar = "String" | "Int" | "BigInt" | "Float" | "Decimal" | "Boolean" | "DateTime" | "Json" | "Bytes";
|
|
9
|
+
|
|
10
|
+
export type Field = {
|
|
11
|
+
name: string;
|
|
12
|
+
dbName: string;
|
|
13
|
+
kind: FieldKind;
|
|
14
|
+
isList: boolean;
|
|
15
|
+
isRequired: boolean;
|
|
16
|
+
isUnique: boolean;
|
|
17
|
+
isId: boolean;
|
|
18
|
+
isReadOnly: boolean;
|
|
19
|
+
hasDefaultValue: boolean;
|
|
20
|
+
type: Scalar;
|
|
21
|
+
|
|
22
|
+
isGenerated: boolean;
|
|
23
|
+
isUpdatedAt: boolean;
|
|
24
|
+
|
|
25
|
+
nativeType: any;
|
|
26
|
+
default?: FieldDefault | string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export interface FieldDefault {
|
|
30
|
+
name: FieldDefaultName;
|
|
31
|
+
args: number[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type DocGenModel = {
|
|
35
|
+
name: string | null;
|
|
36
|
+
dbName: string | null;
|
|
37
|
+
schema: string | null;
|
|
38
|
+
readonly fields: Field[];
|
|
39
|
+
|
|
40
|
+
uniqueFields: string[][];
|
|
41
|
+
uniqueIndexes: ModelUniqueIndexes[];
|
|
42
|
+
primaryKey: null;
|
|
43
|
+
|
|
44
|
+
documentation?: string;
|
|
45
|
+
isGenerated?: boolean;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type ModelUniqueIndexes = {
|
|
49
|
+
name: string | null;
|
|
50
|
+
fields: any[];
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export class ValidatorBuilder {
|
|
54
|
+
decorator: ValidatorFactory | PropertyDecorator;
|
|
55
|
+
fields: string[];
|
|
56
|
+
|
|
57
|
+
constructor(decorator: PropertyDecorator, fields: string[]) {
|
|
58
|
+
this.decorator = decorator;
|
|
59
|
+
this.fields = fields;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class ApiExampleBuilder {
|
|
64
|
+
fields: string[];
|
|
65
|
+
example: string | boolean | number;
|
|
66
|
+
|
|
67
|
+
constructor(fields: string[], example: string | boolean | number) {
|
|
68
|
+
this.fields = fields;
|
|
69
|
+
this.example = example;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type Rules = {
|
|
74
|
+
ignore: string[];
|
|
75
|
+
examples: ApiExampleBuilder[];
|
|
76
|
+
validators: ValidatorBuilder[];
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
type ValidatorFactory = (...args: any[]) => PropertyDecorator;
|
|
80
|
+
|
|
81
|
+
export type Model = {
|
|
82
|
+
name: string;
|
|
83
|
+
dbName: string | null;
|
|
84
|
+
schema: string | null;
|
|
85
|
+
readonly fields: Field[];
|
|
86
|
+
|
|
87
|
+
uniqueFields: string[][];
|
|
88
|
+
uniqueIndexes: ModelUniqueIndexes[];
|
|
89
|
+
primaryKey: null;
|
|
90
|
+
|
|
91
|
+
documentation?: string;
|
|
92
|
+
isGenerated?: boolean;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type ModelParams = { model: Model; examples: Map<string, ApiExampleBuilder>; validators: Map<string, string[]> };
|
|
96
|
+
export type FieldParams = {
|
|
97
|
+
examples: Map<string, ApiExampleBuilder>;
|
|
98
|
+
validators: Map<string, string[]>;
|
|
99
|
+
field: Field;
|
|
100
|
+
fieldType: FieldType;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export type DocGenParams = {
|
|
104
|
+
ignore: string[];
|
|
105
|
+
examples: ApiExampleBuilder[];
|
|
106
|
+
validators: ValidatorBuilder[];
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// field: Field, fieldType: FieldType
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"rootDir": "src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"skipLibCheck": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*.ts", "src/types/**/*.d.ts"],
|
|
14
|
+
"exclude": ["node_modules", "dist"]
|
|
15
|
+
}
|