@nest-extended/cli 0.0.2-beta-13 → 0.0.2-beta-15

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.
Files changed (56) hide show
  1. package/README.md +73 -9
  2. package/package.json +1 -1
  3. package/src/commands/generate-app.js +145 -30
  4. package/src/commands/generate-app.js.map +1 -1
  5. package/src/commands/generate-service.js +211 -13
  6. package/src/commands/generate-service.js.map +1 -1
  7. package/src/lib/generate-prisma-auth-services.d.ts +1 -0
  8. package/src/lib/generate-prisma-auth-services.js +38 -0
  9. package/src/lib/generate-prisma-auth-services.js.map +1 -0
  10. package/src/lib/update-app-module.d.ts +1 -1
  11. package/src/lib/update-app-module.js +3 -3
  12. package/src/lib/update-app-module.js.map +1 -1
  13. package/src/templates/controller.template.d.ts +1 -1
  14. package/src/templates/controller.template.js +2 -2
  15. package/src/templates/controller.template.js.map +1 -1
  16. package/src/templates/dto-class-validator.template.d.ts +1 -0
  17. package/src/templates/dto-class-validator.template.js +93 -0
  18. package/src/templates/dto-class-validator.template.js.map +1 -0
  19. package/src/templates/dto.template.js +19 -0
  20. package/src/templates/dto.template.js.map +1 -1
  21. package/src/templates/module.template.d.ts +1 -1
  22. package/src/templates/module.template.js +2 -2
  23. package/src/templates/module.template.js.map +1 -1
  24. package/src/templates/prisma-auth.template.d.ts +9 -0
  25. package/src/templates/prisma-auth.template.js +190 -0
  26. package/src/templates/prisma-auth.template.js.map +1 -0
  27. package/src/templates/prisma-controller.template.d.ts +1 -0
  28. package/src/templates/prisma-controller.template.js +53 -0
  29. package/src/templates/prisma-controller.template.js.map +1 -0
  30. package/src/templates/prisma-dto-class-validator.template.d.ts +1 -0
  31. package/src/templates/prisma-dto-class-validator.template.js +93 -0
  32. package/src/templates/prisma-dto-class-validator.template.js.map +1 -0
  33. package/src/templates/prisma-dto.template.d.ts +1 -0
  34. package/src/templates/prisma-dto.template.js +55 -0
  35. package/src/templates/prisma-dto.template.js.map +1 -0
  36. package/src/templates/prisma-model.template.d.ts +7 -0
  37. package/src/templates/prisma-model.template.js +27 -0
  38. package/src/templates/prisma-model.template.js.map +1 -0
  39. package/src/templates/prisma-module.template.d.ts +1 -0
  40. package/src/templates/prisma-module.template.js +18 -0
  41. package/src/templates/prisma-module.template.js.map +1 -0
  42. package/src/templates/prisma-service.template.d.ts +1 -0
  43. package/src/templates/prisma-service.template.js +15 -0
  44. package/src/templates/prisma-service.template.js.map +1 -0
  45. package/src/templates/prisma-setup.template.d.ts +6 -0
  46. package/src/templates/prisma-setup.template.js +34 -0
  47. package/src/templates/prisma-setup.template.js.map +1 -0
  48. package/src/templates/prisma-users.template.d.ts +8 -0
  49. package/src/templates/prisma-users.template.js +135 -0
  50. package/src/templates/prisma-users.template.js.map +1 -0
  51. package/src/templates/schema.template.d.ts +1 -1
  52. package/src/templates/schema.template.js +14 -6
  53. package/src/templates/schema.template.js.map +1 -1
  54. package/src/templates/service.template.d.ts +1 -1
  55. package/src/templates/service.template.js +2 -2
  56. package/src/templates/service.template.js.map +1 -1
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ /**
3
+ * Prisma-compatible auth templates.
4
+ * Same functionality as the Mongoose auth templates but using Prisma.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getPrismaJwtConstants = exports.getPrismaAuthGuard = exports.getPrismaAuthModule = exports.getPrismaAuthService = exports.getPrismaAuthController = void 0;
8
+ const getPrismaAuthController = () => `import {
9
+ Body,
10
+ Controller,
11
+ Post,
12
+ HttpCode,
13
+ HttpStatus,
14
+ Get,
15
+ Request,
16
+ BadRequestException,
17
+ } from '@nestjs/common';
18
+ import { AuthService } from './auth.service';
19
+ import { Public } from '@nest-extended/decorators';
20
+ import { UsersService } from '../users/users.service';
21
+
22
+ @Controller('authentication')
23
+ export class AuthController {
24
+ constructor(
25
+ private authService: AuthService,
26
+ private usersService: UsersService,
27
+ ) {}
28
+
29
+ @Public()
30
+ @HttpCode(HttpStatus.OK)
31
+ @Post('')
32
+ signIn(@Body() signInDto: Record<string, string>) {
33
+ if (signInDto.strategy === 'local') {
34
+ return this.authService.signInLocal(signInDto.email, signInDto.password);
35
+ }
36
+ throw new BadRequestException('Invalid Strategy');
37
+ }
38
+
39
+ @Get('verify')
40
+ getProfile(@Request() req: Record<string, any>) {
41
+ const user = req.user as Record<string, any>;
42
+ return {
43
+ user: this.usersService.sanitizeUser(user),
44
+ };
45
+ }
46
+ }
47
+ `;
48
+ exports.getPrismaAuthController = getPrismaAuthController;
49
+ const getPrismaAuthService = () => `import { Injectable, UnauthorizedException } from '@nestjs/common';
50
+ import { JwtService } from '@nestjs/jwt';
51
+ import * as bcrypt from 'bcrypt';
52
+ import { UsersService } from '../users/users.service';
53
+
54
+ @Injectable()
55
+ export class AuthService {
56
+ constructor(
57
+ private usersService: UsersService,
58
+ private jwtService: JwtService,
59
+ ) { }
60
+
61
+ async signInLocal(
62
+ email: string,
63
+ pass: string,
64
+ ): Promise<Record<string, unknown>> {
65
+ const users = await this.usersService._find(
66
+ {
67
+ email,
68
+ $limit: 1,
69
+ $select: ['id', 'firstName', 'lastName', 'email', 'password', 'createdAt', 'updatedAt'],
70
+ },
71
+ { pagination: false },
72
+ );
73
+
74
+ const user = users[0] as Record<string, any>;
75
+ if (!user) throw new UnauthorizedException();
76
+
77
+ const passwordValid = await bcrypt.compare(pass, user.password);
78
+ if (!passwordValid) {
79
+ throw new UnauthorizedException();
80
+ }
81
+
82
+ const sanitizedUser = this.usersService.sanitizeUser(user);
83
+ const payload = { sub: { id: user.id }, user };
84
+ return {
85
+ accessToken: await this.jwtService.signAsync(payload),
86
+ user: sanitizedUser,
87
+ };
88
+ }
89
+ }
90
+ `;
91
+ exports.getPrismaAuthService = getPrismaAuthService;
92
+ const getPrismaAuthModule = () => `import { Module } from '@nestjs/common';
93
+ import { AuthService } from './auth.service';
94
+ import { JwtModule } from '@nestjs/jwt';
95
+ import { AuthController } from './auth.controller';
96
+ import { APP_GUARD } from '@nestjs/core';
97
+ import { AuthGuard } from './auth.guard';
98
+ import { UsersModule } from '../users/users.module';
99
+ import { jwtConstants } from './constants/jwt-constants';
100
+
101
+ @Module({
102
+ imports: [
103
+ UsersModule,
104
+ JwtModule.register({
105
+ global: true,
106
+ secret: jwtConstants.secret,
107
+ signOptions: { expiresIn: '365d' },
108
+ }),
109
+ ],
110
+ providers: [
111
+ AuthService,
112
+ {
113
+ provide: APP_GUARD,
114
+ useClass: AuthGuard,
115
+ },
116
+ ],
117
+ controllers: [AuthController],
118
+ exports: [AuthService],
119
+ })
120
+ export class AuthModule {}
121
+ `;
122
+ exports.getPrismaAuthModule = getPrismaAuthModule;
123
+ const getPrismaAuthGuard = () => `import {
124
+ CanActivate,
125
+ ExecutionContext,
126
+ Injectable,
127
+ UnauthorizedException,
128
+ } from '@nestjs/common';
129
+ import { Reflector } from '@nestjs/core';
130
+ import { JwtService } from '@nestjs/jwt';
131
+ import { IS_PUBLIC_KEY } from '@nest-extended/decorators';
132
+ import { UsersService } from '../users/users.service';
133
+ import { jwtConstants } from './constants/jwt-constants';
134
+ import { ClsService } from 'nestjs-cls';
135
+
136
+ @Injectable()
137
+ export class AuthGuard implements CanActivate {
138
+ constructor(
139
+ private usersService: UsersService,
140
+ private jwtService: JwtService,
141
+ private reflector: Reflector,
142
+ private cls: ClsService,
143
+ ) {}
144
+
145
+ async canActivate(context: ExecutionContext): Promise<boolean> {
146
+ const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
147
+ context.getHandler(),
148
+ context.getClass(),
149
+ ]);
150
+ if (isPublic) {
151
+ return true;
152
+ }
153
+ const request = context.switchToHttp().getRequest<{ user?: Record<string, unknown>, headers: Record<string, string | undefined> }>();
154
+ const token = this.extractTokenFromHeader(request);
155
+ if (!token) {
156
+ throw new UnauthorizedException();
157
+ }
158
+ try {
159
+ const payload = await this.jwtService.verifyAsync<{ sub: { id: string } }>(token, {
160
+ secret: jwtConstants.secret,
161
+ });
162
+ const user = (await this.usersService._get(
163
+ payload.sub.id,
164
+ )) as unknown as Record<string, unknown>;
165
+ if (user) {
166
+ request.user = user;
167
+ this.cls.set('user', user);
168
+ return true;
169
+ }
170
+ } catch {
171
+ throw new UnauthorizedException();
172
+ }
173
+ throw new UnauthorizedException();
174
+ }
175
+
176
+ private extractTokenFromHeader(request: { headers: Record<string, string | undefined> }): string | undefined {
177
+ const [type, token] = request.headers.authorization?.split(' ') ?? [];
178
+ return type === 'Bearer' ? token : undefined;
179
+ }
180
+ }
181
+ `;
182
+ exports.getPrismaAuthGuard = getPrismaAuthGuard;
183
+ const getPrismaJwtConstants = () => `import { randomBytes } from 'crypto';
184
+ // NOTE: For a real application, consider using a more secure way to inject the secret (like ConfigService)
185
+ export const jwtConstants = {
186
+ secret: process.env.JWT_SECRET || randomBytes(32).toString('hex'),
187
+ };
188
+ `;
189
+ exports.getPrismaJwtConstants = getPrismaJwtConstants;
190
+ //# sourceMappingURL=prisma-auth.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-auth.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/prisma-auth.template.ts"],"names":[],"mappings":";AACA;;;GAGG;;;AAEI,MAAM,uBAAuB,GAAG,GAAW,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCpD,CAAC;AAvCW,QAAA,uBAAuB,2BAuClC;AAEK,MAAM,oBAAoB,GAAG,GAAW,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCjD,CAAC;AAzCW,QAAA,oBAAoB,wBAyC/B;AAEK,MAAM,mBAAmB,GAAG,GAAW,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BhD,CAAC;AA7BW,QAAA,mBAAmB,uBA6B9B;AAEK,MAAM,kBAAkB,GAAG,GAAW,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0D/C,CAAC;AA1DW,QAAA,kBAAkB,sBA0D7B;AAEK,MAAM,qBAAqB,GAAG,GAAW,EAAE,CAAC;;;;;CAKlD,CAAC;AALW,QAAA,qBAAqB,yBAKhC"}
@@ -0,0 +1 @@
1
+ export declare const getPrismaController: (Name: string, name: string, url: string) => string;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPrismaController = void 0;
4
+ const getPrismaController = (Name, name, url) => `import {
5
+ Controller,
6
+ Delete,
7
+ Get,
8
+ Param,
9
+ Patch,
10
+ Post,
11
+ Query,
12
+ } from '@nestjs/common';
13
+ import { ${Name}Service } from './${name}.service';
14
+ import { User, ModifyBody, setCreatedBy } from '@nest-extended/decorators';
15
+
16
+ @Controller('${url}')
17
+ export class ${Name}Controller {
18
+ constructor(private readonly ${name}Service: ${Name}Service) { }
19
+
20
+ @Get()
21
+ async find(@Query() query: Record<string, any>) {
22
+ return await this.${name}Service._find(query);
23
+ }
24
+
25
+ @Get('/:id')
26
+ async get(@Query() query: Record<string, any>, @Param('id') id: string) {
27
+ return await this.${name}Service._get(id, query);
28
+ }
29
+
30
+ @Post()
31
+ async create(
32
+ @ModifyBody(setCreatedBy()) create${Name}Dto: any
33
+ ) {
34
+ return await this.${name}Service._create(create${Name}Dto);
35
+ }
36
+
37
+ @Patch('/:id')
38
+ async patch(
39
+ @Query() query: Record<string, any>,
40
+ @ModifyBody(setCreatedBy('updatedBy')) patch${Name}Dto: any,
41
+ @Param('id') id: string,
42
+ ) {
43
+ return await this.${name}Service._patch(id, patch${Name}Dto, query);
44
+ }
45
+
46
+ @Delete('/:id')
47
+ async delete(@Param('id') id: string, @Query() query: Record<string, any>, @User() user: Record<string, unknown>) {
48
+ return await this.${name}Service._remove(id, query, user);
49
+ }
50
+ }
51
+ `;
52
+ exports.getPrismaController = getPrismaController;
53
+ //# sourceMappingURL=prisma-controller.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-controller.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/prisma-controller.template.ts"],"names":[],"mappings":";;;AACO,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,GAAW,EAAU,EAAE,CAAC;;;;;;;;;WAS7E,IAAI,qBAAqB,IAAI;;;eAGzB,GAAG;eACH,IAAI;iCACc,IAAI,YAAY,IAAI;;;;wBAI7B,IAAI;;;;;wBAKJ,IAAI;;;;;wCAKY,IAAI;;wBAEpB,IAAI,yBAAyB,IAAI;;;;;;kDAMP,IAAI;;;wBAG9B,IAAI,2BAA2B,IAAI;;;;;wBAKnC,IAAI;;;CAG3B,CAAC;AA/CW,QAAA,mBAAmB,uBA+C9B"}
@@ -0,0 +1 @@
1
+ export declare const getPrismaDtoClassValidator: (Name: string) => string;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPrismaDtoClassValidator = void 0;
4
+ const getPrismaDtoClassValidator = (Name) => `import { IsString, IsOptional, IsBoolean, IsDate } from 'class-validator';
5
+ import { Type } from 'class-transformer';
6
+
7
+ /**
8
+ * Usage: To enable class-validator validation, add the following to your main.ts:
9
+ *
10
+ * import { ValidationPipe } from '@nestjs/common';
11
+ * app.useGlobalPipes(new ValidationPipe({ transform: true, whitelist: true }));
12
+ *
13
+ * Or apply per-route using @UsePipes(new ValidationPipe({ transform: true }))
14
+ */
15
+
16
+ export class Create${Name}Dto {
17
+ @IsString()
18
+ @IsOptional()
19
+ name?: string;
20
+
21
+ @IsString()
22
+ @IsOptional()
23
+ createdBy?: string;
24
+
25
+ @IsDate()
26
+ @IsOptional()
27
+ @Type(() => Date)
28
+ createdAt?: Date;
29
+
30
+ @IsDate()
31
+ @IsOptional()
32
+ @Type(() => Date)
33
+ updatedAt?: Date;
34
+
35
+ @IsBoolean()
36
+ @IsOptional()
37
+ deleted?: boolean;
38
+
39
+ @IsString()
40
+ @IsOptional()
41
+ deletedBy?: string;
42
+
43
+ @IsDate()
44
+ @IsOptional()
45
+ @Type(() => Date)
46
+ deletedAt?: Date;
47
+ }
48
+
49
+ export class Patch${Name}Dto {
50
+ @IsString()
51
+ @IsOptional()
52
+ name?: string;
53
+
54
+ @IsDate()
55
+ @IsOptional()
56
+ @Type(() => Date)
57
+ updatedAt?: Date;
58
+
59
+ @IsDate()
60
+ @IsOptional()
61
+ @Type(() => Date)
62
+ createdAt?: Date;
63
+
64
+ @IsBoolean()
65
+ @IsOptional()
66
+ deleted?: boolean;
67
+
68
+ @IsString()
69
+ @IsOptional()
70
+ deletedBy?: string;
71
+
72
+ @IsDate()
73
+ @IsOptional()
74
+ @Type(() => Date)
75
+ deletedAt?: Date;
76
+ }
77
+
78
+ export class Remove${Name}Dto {
79
+ @IsString()
80
+ id: string;
81
+
82
+ @IsString()
83
+ @IsOptional()
84
+ deletedBy?: string;
85
+
86
+ @IsDate()
87
+ @IsOptional()
88
+ @Type(() => Date)
89
+ deletedAt?: Date;
90
+ }
91
+ `;
92
+ exports.getPrismaDtoClassValidator = getPrismaDtoClassValidator;
93
+ //# sourceMappingURL=prisma-dto-class-validator.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-dto-class-validator.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/prisma-dto-class-validator.template.ts"],"names":[],"mappings":";;;AACO,MAAM,0BAA0B,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC;;;;;;;;;;;;qBAY/C,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAiCL,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA6BH,IAAI;;;;;;;;;;;;;CAaxB,CAAC;AAvFW,QAAA,0BAA0B,8BAuFrC"}
@@ -0,0 +1 @@
1
+ export declare const getPrismaDto: (Name: string) => string;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPrismaDto = void 0;
4
+ const getPrismaDto = (Name) => `import { z } from 'zod';
5
+
6
+ /**
7
+ * Usage: To enable Zod validation, create a ZodValidationPipe and apply it globally or per-route.
8
+ *
9
+ * // zod-validation.pipe.ts
10
+ * import { PipeTransform, BadRequestException } from '@nestjs/common';
11
+ * import { ZodSchema } from 'zod';
12
+ * export class ZodValidationPipe implements PipeTransform {
13
+ * constructor(private schema: ZodSchema) {}
14
+ * transform(value: unknown) {
15
+ * const result = this.schema.safeParse(value);
16
+ * if (!result.success) throw new BadRequestException(result.error);
17
+ * return result.data;
18
+ * }
19
+ * }
20
+ *
21
+ * // Then in your controller:
22
+ * @UsePipes(new ZodValidationPipe(Create${Name}Validation))
23
+ */
24
+
25
+ export const Create${Name}Validation = z.object({
26
+ name: z.string().optional(),
27
+ createdBy: z.string().optional(),
28
+ createdAt: z.date().optional(),
29
+ updatedAt: z.date().optional(),
30
+ deleted: z.boolean().optional().default(false),
31
+ deletedBy: z.string().optional(),
32
+ deletedAt: z.date().optional(),
33
+ });
34
+
35
+ export const Patch${Name}Validation = z.object({
36
+ name: z.string().optional(),
37
+ updatedAt: z.date().optional(),
38
+ createdAt: z.date().optional(),
39
+ deleted: z.boolean().optional(),
40
+ deletedBy: z.string().optional(),
41
+ deletedAt: z.date().optional(),
42
+ });
43
+
44
+ export const Remove${Name}Validation = z.object({
45
+ id: z.string(),
46
+ deletedBy: z.string().optional(),
47
+ deletedAt: z.date().optional(),
48
+ });
49
+
50
+ export type Create${Name}DTO = z.infer<typeof Create${Name}Validation>;
51
+ export type Patch${Name}DTO = z.infer<typeof Patch${Name}Validation>;
52
+ export type Remove${Name}DTO = z.infer<typeof Remove${Name}Validation>;
53
+ `;
54
+ exports.getPrismaDto = getPrismaDto;
55
+ //# sourceMappingURL=prisma-dto.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-dto.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/prisma-dto.template.ts"],"names":[],"mappings":";;;AACO,MAAM,YAAY,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC;;;;;;;;;;;;;;;;;;6CAkBT,IAAI;;;qBAG5B,IAAI;;;;;;;;;;oBAUL,IAAI;;;;;;;;;qBASH,IAAI;;;;;;oBAML,IAAI,8BAA8B,IAAI;mBACvC,IAAI,6BAA6B,IAAI;oBACpC,IAAI,8BAA8B,IAAI;CACzD,CAAC;AAjDW,QAAA,YAAY,gBAiDvB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generates a Prisma model block to append to schema.prisma.
3
+ *
4
+ * @param Name - PascalCase model name
5
+ * @param isAuthGenerated - Whether auth module exists (adds createdBy/updatedBy/deletedBy)
6
+ */
7
+ export declare const getPrismaModel: (Name: string, isAuthGenerated?: boolean) => string;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPrismaModel = void 0;
4
+ /**
5
+ * Generates a Prisma model block to append to schema.prisma.
6
+ *
7
+ * @param Name - PascalCase model name
8
+ * @param isAuthGenerated - Whether auth module exists (adds createdBy/updatedBy/deletedBy)
9
+ */
10
+ const getPrismaModel = (Name, isAuthGenerated = true) => {
11
+ const authFields = isAuthGenerated ? `
12
+ createdBy String?
13
+ updatedBy String?
14
+ deletedBy String?` : '';
15
+ return `
16
+ model ${Name} {
17
+ id String @id @default(cuid())
18
+ name String?
19
+ deleted Boolean? @default(false)
20
+ deletedAt DateTime?${authFields}
21
+ createdAt DateTime @default(now())
22
+ updatedAt DateTime @updatedAt
23
+ }
24
+ `;
25
+ };
26
+ exports.getPrismaModel = getPrismaModel;
27
+ //# sourceMappingURL=prisma-model.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-model.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/prisma-model.template.ts"],"names":[],"mappings":";;;AACA;;;;;GAKG;AACI,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,kBAA2B,IAAI,EAAU,EAAE;IACpF,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC;;;oBAGrB,CAAC,CAAC,CAAC,EAAE,CAAC;IAEtB,OAAO;QACH,IAAI;;;;uBAIW,UAAU;;;;CAIhC,CAAC;AACF,CAAC,CAAC;AAhBW,QAAA,cAAc,kBAgBzB"}
@@ -0,0 +1 @@
1
+ export declare const getPrismaModule: (Name: string, name: string) => string;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPrismaModule = void 0;
4
+ const getPrismaModule = (Name, name) => `import { Module } from '@nestjs/common';
5
+ import { ${Name}Controller } from './${name}.controller';
6
+ import { ${Name}Service } from './${name}.service';
7
+
8
+ @Module({
9
+ controllers: [${Name}Controller],
10
+ providers: [
11
+ ${Name}Service,
12
+ ],
13
+ exports: [${Name}Service],
14
+ })
15
+ export class ${Name}Module {}
16
+ `;
17
+ exports.getPrismaModule = getPrismaModule;
18
+ //# sourceMappingURL=prisma-module.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-module.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/prisma-module.template.ts"],"names":[],"mappings":";;;AACO,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,IAAY,EAAU,EAAE,CAAC;WAC5D,IAAI,wBAAwB,IAAI;WAChC,IAAI,qBAAqB,IAAI;;;kBAGtB,IAAI;;MAEhB,IAAI;;cAEI,IAAI;;eAEH,IAAI;CAClB,CAAC;AAZW,QAAA,eAAe,mBAY1B"}
@@ -0,0 +1 @@
1
+ export declare const getPrismaService: (Name: string, name: string) => string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPrismaService = void 0;
4
+ const getPrismaService = (Name, name) => `import { Injectable } from '@nestjs/common';
5
+ import { PrismaService } from 'src/prisma/prisma.service';
6
+ import { NestService } from '@nest-extended/prisma';
7
+
8
+ @Injectable()
9
+ export class ${Name}Service extends NestService<any> {
10
+ constructor(private readonly prisma: PrismaService) {
11
+ super(prisma.${name});
12
+ }
13
+ }`;
14
+ exports.getPrismaService = getPrismaService;
15
+ //# sourceMappingURL=prisma-service.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-service.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/prisma-service.template.ts"],"names":[],"mappings":";;;AACO,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAE,IAAY,EAAU,EAAE,CAAC;;;;;eAKzD,IAAI;;mBAEA,IAAI;;EAErB,CAAC;AATU,QAAA,gBAAgB,oBAS1B"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generates PrismaService (extends PrismaClient) and PrismaModule.
3
+ * Created once per project — shared across all Prisma-based services.
4
+ */
5
+ export declare const getPrismaServiceFile: () => string;
6
+ export declare const getPrismaModuleFile: () => string;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /**
3
+ * Generates PrismaService (extends PrismaClient) and PrismaModule.
4
+ * Created once per project — shared across all Prisma-based services.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getPrismaModuleFile = exports.getPrismaServiceFile = void 0;
8
+ const getPrismaServiceFile = () => `import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
9
+ import { PrismaClient } from '@prisma/client';
10
+
11
+ @Injectable()
12
+ export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
13
+ async onModuleInit() {
14
+ await this.$connect();
15
+ }
16
+
17
+ async onModuleDestroy() {
18
+ await this.$disconnect();
19
+ }
20
+ }
21
+ `;
22
+ exports.getPrismaServiceFile = getPrismaServiceFile;
23
+ const getPrismaModuleFile = () => `import { Global, Module } from '@nestjs/common';
24
+ import { PrismaService } from './prisma.service';
25
+
26
+ @Global()
27
+ @Module({
28
+ providers: [PrismaService],
29
+ exports: [PrismaService],
30
+ })
31
+ export class PrismaModule {}
32
+ `;
33
+ exports.getPrismaModuleFile = getPrismaModuleFile;
34
+ //# sourceMappingURL=prisma-setup.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-setup.template.js","sourceRoot":"","sources":["../../../../../packages/cli/src/templates/prisma-setup.template.ts"],"names":[],"mappings":";AACA;;;GAGG;;;AAEI,MAAM,oBAAoB,GAAG,GAAW,EAAE,CAAC;;;;;;;;;;;;;CAajD,CAAC;AAbW,QAAA,oBAAoB,wBAa/B;AAEK,MAAM,mBAAmB,GAAG,GAAW,EAAE,CAAC;;;;;;;;;CAShD,CAAC;AATW,QAAA,mBAAmB,uBAS9B"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Prisma-compatible Users templates.
3
+ * Same functionality as the Mongoose users templates but using Prisma.
4
+ */
5
+ export declare const getPrismaUsersModel: () => string;
6
+ export declare const getPrismaUsersService: () => string;
7
+ export declare const getPrismaUsersController: () => string;
8
+ export declare const getPrismaUsersModule: () => string;