prismadoc 1.0.29
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/README.md +425 -0
- package/dist/config.type.js +38 -0
- package/dist/entities/dto-generator.js +69 -0
- package/dist/entities/enum.js +40 -0
- package/dist/entities/field.js +192 -0
- package/dist/entities/generic.js +24 -0
- package/dist/entities/model.js +83 -0
- package/dist/entities/response-generator.js +30 -0
- package/dist/entities/validator.js +16 -0
- package/dist/field.type.js +22 -0
- package/dist/fields.ts +138 -0
- package/dist/file.js +27 -0
- package/dist/generic.dto.ts +13 -0
- package/dist/index.js +1 -0
- package/dist/index.ts +40 -0
- package/dist/main.js +155 -0
- package/dist/rules.js +35 -0
- package/dist/schemas/config.schema.json +136 -0
- package/dist/static.js +3 -0
- package/dist/types/account-agenda.ts +68 -0
- package/dist/types/account-two-factor-auth-log.ts +127 -0
- package/dist/types/account-two-factor-auth.ts +145 -0
- package/dist/types/account.ts +126 -0
- package/dist/types/admin.ts +68 -0
- package/dist/types/agenda-day-time-config.ts +113 -0
- package/dist/types/agenda-week-day-config.ts +68 -0
- package/dist/types/customer.ts +99 -0
- package/dist/types/dummy-many.ts +71 -0
- package/dist/types/dummy-unique.ts +68 -0
- package/dist/types/dummy.ts +68 -0
- package/dist/types/email-auth-code.ts +136 -0
- package/dist/types/file.ts +299 -0
- package/dist/types/firebase-config.ts +140 -0
- package/dist/types/knowledge-base-category.ts +91 -0
- package/dist/types/knowledge-base-post.ts +262 -0
- package/dist/types/kyc-attempt-details.ts +273 -0
- package/dist/types/kyc-attempt.ts +365 -0
- package/dist/types/kyc-config.ts +199 -0
- package/dist/types/kyc-document.ts +260 -0
- package/dist/types/meeting-guest.ts +185 -0
- package/dist/types/meeting.ts +205 -0
- package/dist/types/member.ts +99 -0
- package/dist/types/notification.ts +193 -0
- package/dist/types/otp-auth-code-request-log.ts +116 -0
- package/dist/types/otp-auth-code.ts +136 -0
- package/dist/types/owner.ts +68 -0
- package/dist/types/policy.ts +169 -0
- package/dist/types/push-notification.ts +77 -0
- package/dist/types/smtp-config.ts +188 -0
- package/dist/types/staff-role.ts +121 -0
- package/dist/types/staff.ts +99 -0
- package/dist/types/tenant-plan.ts +177 -0
- package/dist/types/tenant-role.ts +152 -0
- package/dist/types/tenant.ts +149 -0
- package/dist/types/ticket-message.ts +177 -0
- package/dist/types/ticket.ts +177 -0
- package/dist/types/user.ts +281 -0
- package/dist/types.js +1 -0
- package/dist/utils/helpers.js +146 -0
- package/dist/utils/loader.js +81 -0
- package/dist/utils/prisma-utils.js +73 -0
- package/dist/utils/propeties.static.js +2 -0
- package/package.json +45 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// AUTO-GERADO: NÃO EDITAR MANUALMENTE. SUJEITO A PAULADAS!
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
3
|
+
import { ApiProperty, IntersectionType } from "@nestjs/swagger";
|
|
4
|
+
import { EnumTicketStatus } from "@prisma/client";
|
|
5
|
+
import { IsString, IsNotEmpty, IsEnum, IsOptional } from "src/_nest/validators";
|
|
6
|
+
|
|
7
|
+
class StatusDto {
|
|
8
|
+
@ApiProperty({
|
|
9
|
+
enum: EnumTicketStatus,
|
|
10
|
+
example: Object.values(EnumTicketStatus)[0],
|
|
11
|
+
required: true,
|
|
12
|
+
})
|
|
13
|
+
@IsEnum(EnumTicketStatus)
|
|
14
|
+
status!: EnumTicketStatus;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
class TitleDto {
|
|
18
|
+
@ApiProperty({ type: "string", example: "ordinary string", required: true })
|
|
19
|
+
@IsString()
|
|
20
|
+
@IsNotEmpty()
|
|
21
|
+
title!: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class TenantIdDto {
|
|
25
|
+
@ApiProperty({
|
|
26
|
+
type: "string",
|
|
27
|
+
example: "cmfxu4njg000008l52v7t8qze",
|
|
28
|
+
required: false,
|
|
29
|
+
})
|
|
30
|
+
@IsString()
|
|
31
|
+
@IsOptional()
|
|
32
|
+
tenantId?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
class ApplicantAccountIdDto {
|
|
36
|
+
@ApiProperty({
|
|
37
|
+
type: "string",
|
|
38
|
+
example: "cmfxu4njg000008l52v7t8qze",
|
|
39
|
+
required: true,
|
|
40
|
+
})
|
|
41
|
+
@IsString()
|
|
42
|
+
@IsNotEmpty()
|
|
43
|
+
applicantAccountId!: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
class TicketDto extends IntersectionType(
|
|
47
|
+
StatusDto,
|
|
48
|
+
TitleDto,
|
|
49
|
+
TenantIdDto,
|
|
50
|
+
ApplicantAccountIdDto,
|
|
51
|
+
) {}
|
|
52
|
+
|
|
53
|
+
class TicketId {
|
|
54
|
+
@ApiProperty({
|
|
55
|
+
type: "string",
|
|
56
|
+
example: "cmfxu4njg000008l52v7t8qze",
|
|
57
|
+
required: true,
|
|
58
|
+
})
|
|
59
|
+
@IsString()
|
|
60
|
+
@IsNotEmpty()
|
|
61
|
+
ticketId!: string;
|
|
62
|
+
}
|
|
63
|
+
class IdRes {
|
|
64
|
+
@ApiProperty({
|
|
65
|
+
type: "string",
|
|
66
|
+
example: "cmfxu4njg000008l52v7t8qze",
|
|
67
|
+
required: true,
|
|
68
|
+
})
|
|
69
|
+
id!: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
class StatusRes {
|
|
73
|
+
@ApiProperty({
|
|
74
|
+
enum: EnumTicketStatus,
|
|
75
|
+
example: Object.values(EnumTicketStatus)[0],
|
|
76
|
+
required: true,
|
|
77
|
+
})
|
|
78
|
+
status!: EnumTicketStatus;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
class TitleRes {
|
|
82
|
+
@ApiProperty({ type: "string", example: "ordinary string", required: true })
|
|
83
|
+
title!: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
class TenantIdRes {
|
|
87
|
+
@ApiProperty({
|
|
88
|
+
type: "string",
|
|
89
|
+
example: "cmfxu4njg000008l52v7t8qze",
|
|
90
|
+
required: false,
|
|
91
|
+
})
|
|
92
|
+
tenantId?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
class ApplicantAccountIdRes {
|
|
96
|
+
@ApiProperty({
|
|
97
|
+
type: "string",
|
|
98
|
+
example: "cmfxu4njg000008l52v7t8qze",
|
|
99
|
+
required: true,
|
|
100
|
+
})
|
|
101
|
+
applicantAccountId!: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
class CreatedAtRes {
|
|
105
|
+
@ApiProperty({
|
|
106
|
+
type: "string",
|
|
107
|
+
example: "2025-09-03T03:00:00.000Z",
|
|
108
|
+
required: true,
|
|
109
|
+
})
|
|
110
|
+
createdAt!: Date;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
class UpdatedAtRes {
|
|
114
|
+
@ApiProperty({
|
|
115
|
+
type: "string",
|
|
116
|
+
example: "2025-09-03T03:00:00.000Z",
|
|
117
|
+
required: true,
|
|
118
|
+
})
|
|
119
|
+
updatedAt!: Date;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
class TicketRes extends IntersectionType(
|
|
123
|
+
IdRes,
|
|
124
|
+
StatusRes,
|
|
125
|
+
TitleRes,
|
|
126
|
+
TenantIdRes,
|
|
127
|
+
ApplicantAccountIdRes,
|
|
128
|
+
CreatedAtRes,
|
|
129
|
+
UpdatedAtRes,
|
|
130
|
+
) {}
|
|
131
|
+
export namespace Ticket {
|
|
132
|
+
export const Dto = TicketDto;
|
|
133
|
+
export type Dto = TicketDto;
|
|
134
|
+
export const Res = TicketRes;
|
|
135
|
+
export type Res = TicketRes;
|
|
136
|
+
export const Id = TicketId;
|
|
137
|
+
export type Id = TicketId;
|
|
138
|
+
|
|
139
|
+
export namespace Input {
|
|
140
|
+
export namespace Status {
|
|
141
|
+
export type Dto = StatusDto;
|
|
142
|
+
export const Dto = StatusDto;
|
|
143
|
+
export type Res = StatusRes;
|
|
144
|
+
export const Res = StatusRes;
|
|
145
|
+
}
|
|
146
|
+
export namespace Title {
|
|
147
|
+
export type Dto = TitleDto;
|
|
148
|
+
export const Dto = TitleDto;
|
|
149
|
+
export type Res = TitleRes;
|
|
150
|
+
export const Res = TitleRes;
|
|
151
|
+
}
|
|
152
|
+
export namespace TenantId {
|
|
153
|
+
export type Dto = TenantIdDto;
|
|
154
|
+
export const Dto = TenantIdDto;
|
|
155
|
+
export type Res = TenantIdRes;
|
|
156
|
+
export const Res = TenantIdRes;
|
|
157
|
+
}
|
|
158
|
+
export namespace ApplicantAccountId {
|
|
159
|
+
export type Dto = ApplicantAccountIdDto;
|
|
160
|
+
export const Dto = ApplicantAccountIdDto;
|
|
161
|
+
export type Res = ApplicantAccountIdRes;
|
|
162
|
+
export const Res = ApplicantAccountIdRes;
|
|
163
|
+
}
|
|
164
|
+
export namespace Id {
|
|
165
|
+
export type Res = IdRes;
|
|
166
|
+
export const Res = IdRes;
|
|
167
|
+
}
|
|
168
|
+
export namespace CreatedAt {
|
|
169
|
+
export type Res = CreatedAtRes;
|
|
170
|
+
export const Res = CreatedAtRes;
|
|
171
|
+
}
|
|
172
|
+
export namespace UpdatedAt {
|
|
173
|
+
export type Res = UpdatedAtRes;
|
|
174
|
+
export const Res = UpdatedAtRes;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
// AUTO-GERADO: NÃO EDITAR MANUALMENTE. SUJEITO A PAULADAS!
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
3
|
+
import { ApiProperty, IntersectionType } from "@nestjs/swagger";
|
|
4
|
+
import { EnumUserRole, EnumUserStatus } from "@prisma/client";
|
|
5
|
+
import {
|
|
6
|
+
IsString,
|
|
7
|
+
IsNotEmpty,
|
|
8
|
+
IsEmail,
|
|
9
|
+
IsStrongPassword,
|
|
10
|
+
IsEnum,
|
|
11
|
+
IsOptional,
|
|
12
|
+
} from "src/_nest/validators";
|
|
13
|
+
|
|
14
|
+
class EmailDto {
|
|
15
|
+
@ApiProperty({
|
|
16
|
+
type: "string",
|
|
17
|
+
example: "email@pinaculodigital.com.br",
|
|
18
|
+
required: true,
|
|
19
|
+
})
|
|
20
|
+
@IsString()
|
|
21
|
+
@IsNotEmpty()
|
|
22
|
+
@IsEmail()
|
|
23
|
+
email!: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class PasswordDto {
|
|
27
|
+
@ApiProperty({ type: "string", example: "Senha123!@#", required: true })
|
|
28
|
+
@IsString()
|
|
29
|
+
@IsNotEmpty()
|
|
30
|
+
@IsStrongPassword()
|
|
31
|
+
password!: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class NameDto {
|
|
35
|
+
@ApiProperty({ type: "string", example: "Fulano", required: true })
|
|
36
|
+
@IsString()
|
|
37
|
+
@IsNotEmpty()
|
|
38
|
+
name!: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
class RoleDto {
|
|
42
|
+
@ApiProperty({
|
|
43
|
+
enum: EnumUserRole,
|
|
44
|
+
example: Object.values(EnumUserRole)[0],
|
|
45
|
+
required: true,
|
|
46
|
+
})
|
|
47
|
+
@IsEnum(EnumUserRole)
|
|
48
|
+
role!: EnumUserRole;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
class StatusDto {
|
|
52
|
+
@ApiProperty({
|
|
53
|
+
enum: EnumUserStatus,
|
|
54
|
+
example: Object.values(EnumUserStatus)[0],
|
|
55
|
+
required: true,
|
|
56
|
+
})
|
|
57
|
+
@IsEnum(EnumUserStatus)
|
|
58
|
+
status!: EnumUserStatus;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
class TenantIdDto {
|
|
62
|
+
@ApiProperty({
|
|
63
|
+
type: "string",
|
|
64
|
+
example: "cmfxu4njg000008l52v7t8qze",
|
|
65
|
+
required: false,
|
|
66
|
+
})
|
|
67
|
+
@IsString()
|
|
68
|
+
@IsOptional()
|
|
69
|
+
tenantId?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
class SystemEmailDto {
|
|
73
|
+
@ApiProperty({ type: "string", example: "ordinary string", required: false })
|
|
74
|
+
@IsString()
|
|
75
|
+
@IsOptional()
|
|
76
|
+
systemEmail?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
class InactivatedAtDto {
|
|
80
|
+
@ApiProperty({
|
|
81
|
+
type: "string",
|
|
82
|
+
example: "2025-09-03T03:00:00.000Z",
|
|
83
|
+
required: false,
|
|
84
|
+
})
|
|
85
|
+
@IsString()
|
|
86
|
+
@IsOptional()
|
|
87
|
+
inactivatedAt?: Date;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
class UserDto extends IntersectionType(
|
|
91
|
+
EmailDto,
|
|
92
|
+
PasswordDto,
|
|
93
|
+
NameDto,
|
|
94
|
+
RoleDto,
|
|
95
|
+
StatusDto,
|
|
96
|
+
TenantIdDto,
|
|
97
|
+
SystemEmailDto,
|
|
98
|
+
InactivatedAtDto,
|
|
99
|
+
) {}
|
|
100
|
+
|
|
101
|
+
class UserId {
|
|
102
|
+
@ApiProperty({
|
|
103
|
+
type: "string",
|
|
104
|
+
example: "cmfxu4njg000008l52v7t8qze",
|
|
105
|
+
required: true,
|
|
106
|
+
})
|
|
107
|
+
@IsString()
|
|
108
|
+
@IsNotEmpty()
|
|
109
|
+
userId!: string;
|
|
110
|
+
}
|
|
111
|
+
class IdRes {
|
|
112
|
+
@ApiProperty({
|
|
113
|
+
type: "string",
|
|
114
|
+
example: "cmfxu4njg000008l52v7t8qze",
|
|
115
|
+
required: true,
|
|
116
|
+
})
|
|
117
|
+
id!: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
class EmailRes {
|
|
121
|
+
@ApiProperty({
|
|
122
|
+
type: "string",
|
|
123
|
+
example: "email@pinaculodigital.com.br",
|
|
124
|
+
required: true,
|
|
125
|
+
})
|
|
126
|
+
email!: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
class PasswordRes {
|
|
130
|
+
@ApiProperty({ type: "string", example: "Senha123!@#", required: true })
|
|
131
|
+
password!: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
class NameRes {
|
|
135
|
+
@ApiProperty({ type: "string", example: "Fulano", required: true })
|
|
136
|
+
name!: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
class RoleRes {
|
|
140
|
+
@ApiProperty({
|
|
141
|
+
enum: EnumUserRole,
|
|
142
|
+
example: Object.values(EnumUserRole)[0],
|
|
143
|
+
required: true,
|
|
144
|
+
})
|
|
145
|
+
role!: EnumUserRole;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
class StatusRes {
|
|
149
|
+
@ApiProperty({
|
|
150
|
+
enum: EnumUserStatus,
|
|
151
|
+
example: Object.values(EnumUserStatus)[0],
|
|
152
|
+
required: true,
|
|
153
|
+
})
|
|
154
|
+
status!: EnumUserStatus;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
class TenantIdRes {
|
|
158
|
+
@ApiProperty({
|
|
159
|
+
type: "string",
|
|
160
|
+
example: "cmfxu4njg000008l52v7t8qze",
|
|
161
|
+
required: false,
|
|
162
|
+
})
|
|
163
|
+
tenantId?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
class SystemEmailRes {
|
|
167
|
+
@ApiProperty({ type: "string", example: "ordinary string", required: false })
|
|
168
|
+
systemEmail?: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
class CreatedAtRes {
|
|
172
|
+
@ApiProperty({
|
|
173
|
+
type: "string",
|
|
174
|
+
example: "2025-09-03T03:00:00.000Z",
|
|
175
|
+
required: true,
|
|
176
|
+
})
|
|
177
|
+
createdAt!: Date;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
class UpdatedAtRes {
|
|
181
|
+
@ApiProperty({
|
|
182
|
+
type: "string",
|
|
183
|
+
example: "2025-09-03T03:00:00.000Z",
|
|
184
|
+
required: true,
|
|
185
|
+
})
|
|
186
|
+
updatedAt!: Date;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
class InactivatedAtRes {
|
|
190
|
+
@ApiProperty({
|
|
191
|
+
type: "string",
|
|
192
|
+
example: "2025-09-03T03:00:00.000Z",
|
|
193
|
+
required: false,
|
|
194
|
+
})
|
|
195
|
+
inactivatedAt?: Date;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
class UserRes extends IntersectionType(
|
|
199
|
+
IdRes,
|
|
200
|
+
EmailRes,
|
|
201
|
+
PasswordRes,
|
|
202
|
+
NameRes,
|
|
203
|
+
RoleRes,
|
|
204
|
+
StatusRes,
|
|
205
|
+
TenantIdRes,
|
|
206
|
+
SystemEmailRes,
|
|
207
|
+
CreatedAtRes,
|
|
208
|
+
UpdatedAtRes,
|
|
209
|
+
InactivatedAtRes,
|
|
210
|
+
) {}
|
|
211
|
+
export namespace User {
|
|
212
|
+
export const Dto = UserDto;
|
|
213
|
+
export type Dto = UserDto;
|
|
214
|
+
export const Res = UserRes;
|
|
215
|
+
export type Res = UserRes;
|
|
216
|
+
export const Id = UserId;
|
|
217
|
+
export type Id = UserId;
|
|
218
|
+
|
|
219
|
+
export namespace Input {
|
|
220
|
+
export namespace Email {
|
|
221
|
+
export type Dto = EmailDto;
|
|
222
|
+
export const Dto = EmailDto;
|
|
223
|
+
export type Res = EmailRes;
|
|
224
|
+
export const Res = EmailRes;
|
|
225
|
+
}
|
|
226
|
+
export namespace Password {
|
|
227
|
+
export type Dto = PasswordDto;
|
|
228
|
+
export const Dto = PasswordDto;
|
|
229
|
+
export type Res = PasswordRes;
|
|
230
|
+
export const Res = PasswordRes;
|
|
231
|
+
}
|
|
232
|
+
export namespace Name {
|
|
233
|
+
export type Dto = NameDto;
|
|
234
|
+
export const Dto = NameDto;
|
|
235
|
+
export type Res = NameRes;
|
|
236
|
+
export const Res = NameRes;
|
|
237
|
+
}
|
|
238
|
+
export namespace Role {
|
|
239
|
+
export type Dto = RoleDto;
|
|
240
|
+
export const Dto = RoleDto;
|
|
241
|
+
export type Res = RoleRes;
|
|
242
|
+
export const Res = RoleRes;
|
|
243
|
+
}
|
|
244
|
+
export namespace Status {
|
|
245
|
+
export type Dto = StatusDto;
|
|
246
|
+
export const Dto = StatusDto;
|
|
247
|
+
export type Res = StatusRes;
|
|
248
|
+
export const Res = StatusRes;
|
|
249
|
+
}
|
|
250
|
+
export namespace TenantId {
|
|
251
|
+
export type Dto = TenantIdDto;
|
|
252
|
+
export const Dto = TenantIdDto;
|
|
253
|
+
export type Res = TenantIdRes;
|
|
254
|
+
export const Res = TenantIdRes;
|
|
255
|
+
}
|
|
256
|
+
export namespace SystemEmail {
|
|
257
|
+
export type Dto = SystemEmailDto;
|
|
258
|
+
export const Dto = SystemEmailDto;
|
|
259
|
+
export type Res = SystemEmailRes;
|
|
260
|
+
export const Res = SystemEmailRes;
|
|
261
|
+
}
|
|
262
|
+
export namespace InactivatedAt {
|
|
263
|
+
export type Dto = InactivatedAtDto;
|
|
264
|
+
export const Dto = InactivatedAtDto;
|
|
265
|
+
export type Res = InactivatedAtRes;
|
|
266
|
+
export const Res = InactivatedAtRes;
|
|
267
|
+
}
|
|
268
|
+
export namespace Id {
|
|
269
|
+
export type Res = IdRes;
|
|
270
|
+
export const Res = IdRes;
|
|
271
|
+
}
|
|
272
|
+
export namespace CreatedAt {
|
|
273
|
+
export type Res = CreatedAtRes;
|
|
274
|
+
export const Res = CreatedAtRes;
|
|
275
|
+
}
|
|
276
|
+
export namespace UpdatedAt {
|
|
277
|
+
export type Res = UpdatedAtRes;
|
|
278
|
+
export const Res = UpdatedAtRes;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
export class Helper {
|
|
2
|
+
static prismaScalarToTs(s) {
|
|
3
|
+
switch (s) {
|
|
4
|
+
case "String":
|
|
5
|
+
return "string";
|
|
6
|
+
case "Int":
|
|
7
|
+
return "number";
|
|
8
|
+
case "BigInt":
|
|
9
|
+
return "bigint";
|
|
10
|
+
case "Float":
|
|
11
|
+
case "Decimal":
|
|
12
|
+
return "number";
|
|
13
|
+
case "Boolean":
|
|
14
|
+
return "boolean";
|
|
15
|
+
case "DateTime":
|
|
16
|
+
return "Date";
|
|
17
|
+
case "Json":
|
|
18
|
+
return "object";
|
|
19
|
+
case "Bytes":
|
|
20
|
+
return "Buffer";
|
|
21
|
+
default: {
|
|
22
|
+
return "any";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
static validatorForScalar(s) {
|
|
27
|
+
switch (s) {
|
|
28
|
+
case "String":
|
|
29
|
+
return "IsString";
|
|
30
|
+
case "Int":
|
|
31
|
+
return "IsInt";
|
|
32
|
+
case "BigInt":
|
|
33
|
+
return "IsNumber"; // class-validator não tem IsBigInt
|
|
34
|
+
case "Float":
|
|
35
|
+
case "Decimal":
|
|
36
|
+
return "IsNumber";
|
|
37
|
+
case "Boolean":
|
|
38
|
+
return "IsBoolean";
|
|
39
|
+
case "DateTime":
|
|
40
|
+
return "IsDate";
|
|
41
|
+
case "Json":
|
|
42
|
+
return ""; // costuma ser livre
|
|
43
|
+
case "Bytes":
|
|
44
|
+
return ""; // Buffer não tem decorador nativo
|
|
45
|
+
default:
|
|
46
|
+
return "";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
static swaggerType(field) {
|
|
50
|
+
// mapeia para Swagger 'type' básico quando possível
|
|
51
|
+
if (field.kind === "scalar") {
|
|
52
|
+
const t = field.type;
|
|
53
|
+
switch (t) {
|
|
54
|
+
case "String":
|
|
55
|
+
return "string";
|
|
56
|
+
case "Int":
|
|
57
|
+
case "Float":
|
|
58
|
+
case "Decimal":
|
|
59
|
+
return "number";
|
|
60
|
+
case "BigInt":
|
|
61
|
+
return "integer";
|
|
62
|
+
case "Boolean":
|
|
63
|
+
return "boolean";
|
|
64
|
+
case "DateTime":
|
|
65
|
+
return "string"; // format date-time
|
|
66
|
+
case "Json":
|
|
67
|
+
return "object";
|
|
68
|
+
case "Bytes":
|
|
69
|
+
return "string"; // base64
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
static toKebab(s) {
|
|
75
|
+
return s.replaceAll(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
76
|
+
}
|
|
77
|
+
importsForModel(model) {
|
|
78
|
+
const needsEnum = model.fields.some((field) => field.kind === "enum");
|
|
79
|
+
return {
|
|
80
|
+
enums: needsEnum,
|
|
81
|
+
hasDate: model.fields.some((field) => field.kind === "scalar" && field.type === "DateTime"),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// static async readPrismaFolderDatamodel(dir: string): Promise<string> {
|
|
85
|
+
// const files: string[] = [];
|
|
86
|
+
// const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
87
|
+
// const mainSchemaPath = path.join(dir, "schema.prisma");
|
|
88
|
+
// try {
|
|
89
|
+
// const mainStat = await fs.stat(mainSchemaPath);
|
|
90
|
+
// if (mainStat.isFile()) files.push(mainSchemaPath);
|
|
91
|
+
// } catch {}
|
|
92
|
+
// // varrer demais itens (exceto migrations e o schema.prisma já incluído)
|
|
93
|
+
// for (const entry of entries) {
|
|
94
|
+
// if (entry.name === "migrations") continue;
|
|
95
|
+
// const full = path.join(dir, entry.name);
|
|
96
|
+
// if (entry.isDirectory()) {
|
|
97
|
+
// const nested = await this.readPrismaFolderDatamodel(full);
|
|
98
|
+
// if (nested.trim()) files.push(`\n// ---- ${full} ----\n${nested}`);
|
|
99
|
+
// } else if (entry.isFile() && entry.name.endsWith(".prisma") && full !== mainSchemaPath) {
|
|
100
|
+
// const content = await fs.readFile(full, "utf-8");
|
|
101
|
+
// files.push(`\n// ---- ${full} ----\n${content}`);
|
|
102
|
+
// }
|
|
103
|
+
// }
|
|
104
|
+
// // se não houver nada além de subpastas, retorna o que juntou nelas
|
|
105
|
+
// if (!files.length) return "";
|
|
106
|
+
// // quando schema.prisma existe, ele já está no topo do array
|
|
107
|
+
// if (files[0] === mainSchemaPath) {
|
|
108
|
+
// const head = await fs.readFile(mainSchemaPath, "utf-8");
|
|
109
|
+
// const tail = files.slice(1).join("\n");
|
|
110
|
+
// return `${head}\n${tail}`;
|
|
111
|
+
// }
|
|
112
|
+
// // caso não exista schema.prisma, apenas concatena
|
|
113
|
+
// const contents = await Promise.all(files.map(async (f) => (f.startsWith("\n// ---- ") ? f : fs.readFile(f, "utf-8"))));
|
|
114
|
+
// return contents.join("\n");
|
|
115
|
+
// }
|
|
116
|
+
findTypeForField(field) {
|
|
117
|
+
if (field.kind === "scalar") {
|
|
118
|
+
const base = Helper.prismaScalarToTs(field.type);
|
|
119
|
+
return field.isList ? `${base}[]` : base;
|
|
120
|
+
}
|
|
121
|
+
else if (field.kind === "enum") {
|
|
122
|
+
const base = field.type;
|
|
123
|
+
return field.isList ? `${base}[]` : base;
|
|
124
|
+
}
|
|
125
|
+
else if (field.kind === "object") {
|
|
126
|
+
const base = "any";
|
|
127
|
+
return field.isList ? `${base}[]` : base;
|
|
128
|
+
}
|
|
129
|
+
else
|
|
130
|
+
return "any";
|
|
131
|
+
}
|
|
132
|
+
static splitByUpperCase(str) {
|
|
133
|
+
return str.split(/(?=[A-Z])/);
|
|
134
|
+
}
|
|
135
|
+
isDate(field) {
|
|
136
|
+
return field.kind === "scalar" && field.type === "DateTime";
|
|
137
|
+
}
|
|
138
|
+
// Mais segura (remove espaços do começo e lida melhor com alguns caracteres)
|
|
139
|
+
static capitalizeFirstSafe(str) {
|
|
140
|
+
const s = str.trimStart();
|
|
141
|
+
if (!s)
|
|
142
|
+
return s;
|
|
143
|
+
const [first, ...rest] = Array.from(s); // lida melhor com unicode
|
|
144
|
+
return first.toUpperCase() + rest.join("");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { DocGenRules } from "../rules.js";
|
|
5
|
+
import Ajv from "ajv";
|
|
6
|
+
import addFormats from "ajv-formats";
|
|
7
|
+
// Caminho absoluto do diretório da lib (onde este arquivo está)
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
// Caminho para o schema dentro da lib
|
|
11
|
+
const SCHEMA_PATH = path.join(__dirname, "../schemas/config.schema.json");
|
|
12
|
+
const CONFIG_PATH = path.join(process.cwd(), "doc-gen.config.json");
|
|
13
|
+
export class DocGenConfig {
|
|
14
|
+
ignore;
|
|
15
|
+
examples;
|
|
16
|
+
validators;
|
|
17
|
+
validatorPath;
|
|
18
|
+
prismaPath;
|
|
19
|
+
outputPath;
|
|
20
|
+
externalPrismaSchemas;
|
|
21
|
+
constructor(configs) {
|
|
22
|
+
const { examples, ignore, validators, validatorPath, prismaPath, outputPath, externalPrismaSchemas } = configs;
|
|
23
|
+
this.ignore = ignore;
|
|
24
|
+
this.examples = examples;
|
|
25
|
+
this.validators = validators;
|
|
26
|
+
this.validatorPath = validatorPath;
|
|
27
|
+
this.prismaPath = prismaPath;
|
|
28
|
+
this.outputPath = outputPath;
|
|
29
|
+
this.externalPrismaSchemas = externalPrismaSchemas;
|
|
30
|
+
}
|
|
31
|
+
static async readJson(filePath) {
|
|
32
|
+
const content = await fs.readFile(filePath, "utf8");
|
|
33
|
+
return JSON.parse(content);
|
|
34
|
+
}
|
|
35
|
+
/** Carrega variáveis do .env do projeto para process.env (sem sobrescrever) */
|
|
36
|
+
static async loadEnvFile() {
|
|
37
|
+
const envPath = path.join(process.cwd(), ".env");
|
|
38
|
+
try {
|
|
39
|
+
const content = await fs.readFile(envPath, "utf-8");
|
|
40
|
+
for (const line of content.split("\n")) {
|
|
41
|
+
const trimmed = line.trim();
|
|
42
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
43
|
+
continue;
|
|
44
|
+
const eqIndex = trimmed.indexOf("=");
|
|
45
|
+
if (eqIndex === -1)
|
|
46
|
+
continue;
|
|
47
|
+
const key = trimmed.slice(0, eqIndex).trim();
|
|
48
|
+
const rawValue = trimmed.slice(eqIndex + 1).trim();
|
|
49
|
+
// Remove aspas e comentários inline
|
|
50
|
+
const value = rawValue.replaceAll(/^["']|["']$/g, "").split("#")[0].trim();
|
|
51
|
+
if (!process.env[key]) {
|
|
52
|
+
process.env[key] = value;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// .env não encontrado, ignorar
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
static async load() {
|
|
61
|
+
// Carrega .env antes de tudo
|
|
62
|
+
await this.loadEnvFile();
|
|
63
|
+
// Lê os dois arquivos
|
|
64
|
+
const [schema, config] = (await Promise.all([this.readJson(SCHEMA_PATH), this.readJson(CONFIG_PATH)]));
|
|
65
|
+
// Configura o validador
|
|
66
|
+
const ajv = new Ajv.Ajv({ allErrors: true, strict: false });
|
|
67
|
+
addFormats.default(ajv);
|
|
68
|
+
const validate = ajv.compile(schema);
|
|
69
|
+
const valid = validate(config);
|
|
70
|
+
if (!valid) {
|
|
71
|
+
const errors = (validate.errors ?? []).map((e) => `${e.instancePath || "(root)"} ${e.message}`).join("\n - ");
|
|
72
|
+
throw new Error(`❌ Config inválida em ${path.basename(CONFIG_PATH)}:\n - ${errors}`);
|
|
73
|
+
}
|
|
74
|
+
return DocGenConfig.newWithConfigs(config);
|
|
75
|
+
}
|
|
76
|
+
/** Cria uma instância a partir de configurações */
|
|
77
|
+
static newWithConfigs(params) {
|
|
78
|
+
return new DocGenConfig(new DocGenRules(params));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export const config = await DocGenConfig.load();
|