vintasend 0.2.3 → 0.4.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.
Files changed (133) hide show
  1. package/README.md +227 -12
  2. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/next.config.d.ts +1 -1
  3. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/next.config.js +9 -4
  4. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/forgot-password/forgot-password-notification-context.d.ts +6 -6
  5. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/forgot-password/forgot-password-notification-context.js +16 -17
  6. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/forgot-password/route.d.ts +7 -5
  7. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/forgot-password/route.js +105 -79
  8. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/login/route.d.ts +4 -5
  9. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/login/route.js +96 -66
  10. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/reset-password/route.d.ts +7 -5
  11. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/reset-password/route.js +95 -71
  12. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/email-verification-notification-context.d.ts +6 -6
  13. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/email-verification-notification-context.js +18 -18
  14. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/route.d.ts +4 -5
  15. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/signup/route.js +124 -96
  16. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/verify-email/route.d.ts +7 -5
  17. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/api/auth/verify-email/route.js +94 -70
  18. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/login/page.d.ts +1 -1
  19. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/login/page.js +67 -55
  20. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/reset-password/[token]/page.d.ts +1 -1
  21. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/reset-password/[token]/page.js +76 -63
  22. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/signup/page.d.ts +1 -1
  23. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/signup/page.js +87 -63
  24. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/verify-email/[token]/page.d.ts +1 -1
  25. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/verify-email/[token]/page.js +50 -35
  26. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/verify-email-sent/page.d.ts +1 -1
  27. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/auth/verify-email-sent/page.js +12 -12
  28. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/layout.d.ts +7 -5
  29. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/layout.js +15 -16
  30. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/page.d.ts +1 -1
  31. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/app/page.js +65 -21
  32. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/AuthLayout.d.ts +7 -4
  33. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/AuthLayout.js +7 -8
  34. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/accordion.d.ts +18 -6
  35. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/accordion.js +86 -48
  36. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/alert-dialog.d.ts +58 -14
  37. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/alert-dialog.js +135 -53
  38. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/alert.d.ts +21 -7
  39. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/alert.js +85 -49
  40. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/avatar.d.ts +14 -5
  41. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/avatar.js +77 -40
  42. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/button.d.ts +25 -9
  43. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/button.js +80 -58
  44. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/card.d.ts +19 -7
  45. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/card.js +98 -48
  46. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/checkbox.d.ts +6 -3
  47. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/checkbox.js +66 -42
  48. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/collapsible.d.ts +10 -4
  49. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/collapsible.js +48 -35
  50. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/dialog.d.ts +40 -13
  51. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/dialog.js +116 -50
  52. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/dropdown-menu.d.ts +83 -19
  53. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/dropdown-menu.js +170 -68
  54. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/form.d.ts +53 -21
  55. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/form.js +137 -83
  56. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/input.d.ts +8 -2
  57. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/input.js +60 -37
  58. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/label.d.ts +10 -4
  59. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/label.js +61 -40
  60. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/menubar.d.ts +77 -23
  61. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/menubar.js +188 -64
  62. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/select.d.ts +48 -12
  63. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/select.js +148 -66
  64. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/textarea.d.ts +8 -2
  65. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/components/ui/textarea.js +59 -37
  66. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/api-clients/auth.d.ts +10 -10
  67. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/api-clients/auth.js +54 -55
  68. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/api-clients/core.d.ts +14 -11
  69. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/api-clients/core.js +1 -2
  70. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/email.js +0 -1
  71. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/logger.d.ts +3 -3
  72. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/logger.js +9 -10
  73. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/schemas/auth.d.ts +66 -32
  74. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/schemas/auth.js +74 -54
  75. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/auth.js +7 -8
  76. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/notifications-with-queue.d.ts +14 -4
  77. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/notifications-with-queue.js +14 -10
  78. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/notifications.d.ts +11 -7
  79. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/notifications.js +39 -26
  80. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/temporal-queue-service.d.ts +11 -8
  81. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/services/temporal-queue-service.js +14 -15
  82. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/temporal.d.ts +1 -1
  83. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/temporal.js +9 -10
  84. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/utils.d.ts +1 -1
  85. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/lib/utils.js +4 -5
  86. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/activities.d.ts +6 -5
  87. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/activities.js +14 -14
  88. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/config.d.ts +1 -1
  89. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/config.js +2 -3
  90. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/constants.d.ts +1 -1
  91. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/constants.js +1 -2
  92. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/worker.js +20 -22
  93. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/workflows.d.ts +3 -2
  94. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/src/workers/notifications/workflows.js +10 -9
  95. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/tailwind.config.d.ts +74 -74
  96. package/dist/examples/nextjs-prisma-nodemailer-pug-temporal/tailwind.config.js +80 -81
  97. package/dist/implementations/vintasend-nodemailer/src/index.js +6 -4
  98. package/dist/implementations/vintasend-nodemailer/src/nodemailer-notification-adapter.d.ts +36 -14
  99. package/dist/implementations/vintasend-nodemailer/src/nodemailer-notification-adapter.js +26 -28
  100. package/dist/implementations/vintasend-prisma/src/index.js +6 -4
  101. package/dist/implementations/vintasend-prisma/src/prisma-notification-backend.d.ts +232 -138
  102. package/dist/implementations/vintasend-prisma/src/prisma-notification-backend.js +275 -262
  103. package/dist/implementations/vintasend-pug/src/index.js +6 -4
  104. package/dist/implementations/vintasend-pug/src/pug-email-template-renderer.d.ts +18 -7
  105. package/dist/implementations/vintasend-pug/src/pug-email-template-renderer.js +19 -21
  106. package/dist/implementations/vintasend-winston/src/index.js +6 -4
  107. package/dist/implementations/vintasend-winston/src/winston-logger.d.ts +6 -6
  108. package/dist/implementations/vintasend-winston/src/winston-logger.js +65 -50
  109. package/dist/index.d.ts +13 -5
  110. package/dist/index.js +13 -1
  111. package/dist/services/attachment-manager/base-attachment-manager.d.ts +42 -0
  112. package/dist/services/attachment-manager/base-attachment-manager.js +115 -0
  113. package/dist/services/attachment-manager/local-file-attachment-manager.d.ts +58 -0
  114. package/dist/services/attachment-manager/local-file-attachment-manager.js +192 -0
  115. package/dist/services/notification-adapters/base-notification-adapter.d.ts +36 -4
  116. package/dist/services/notification-adapters/base-notification-adapter.js +73 -4
  117. package/dist/services/notification-backends/base-notification-backend.d.ts +54 -11
  118. package/dist/services/notification-backends/base-notification-backend.js +12 -0
  119. package/dist/services/notification-context-generators-map.d.ts +1 -1
  120. package/dist/services/notification-context-registry.d.ts +14 -9
  121. package/dist/services/notification-context-registry.js +30 -31
  122. package/dist/services/notification-queue-service/base-notification-queue-service.d.ts +1 -1
  123. package/dist/services/notification-service.d.ts +73 -13
  124. package/dist/services/notification-service.js +125 -8
  125. package/dist/services/notification-template-renderers/base-email-template-renderer.d.ts +3 -3
  126. package/dist/services/notification-template-renderers/base-notification-template-renderer.d.ts +2 -2
  127. package/dist/types/attachment.d.ts +42 -0
  128. package/dist/types/attachment.js +7 -0
  129. package/dist/types/notification-type-config.d.ts +2 -2
  130. package/dist/types/notification.d.ts +21 -0
  131. package/dist/types/one-off-notification.d.ts +72 -0
  132. package/dist/types/one-off-notification.js +2 -0
  133. package/package.json +13 -11
@@ -1,103 +1,131 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
1
+ var __createBinding =
2
+ (this && this.__createBinding) ||
3
+ (Object.create
4
+ ? (o, m, k, k2) => {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: () => m[k] };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }
12
+ : (o, m, k, k2) => {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ });
16
+ var __setModuleDefault =
17
+ (this && this.__setModuleDefault) ||
18
+ (Object.create
19
+ ? (o, v) => {
20
+ Object.defineProperty(o, 'default', { enumerable: true, value: v });
21
+ }
22
+ : (o, v) => {
23
+ o['default'] = v;
24
+ });
25
+ var __importStar =
26
+ (this && this.__importStar) ||
27
+ (() => {
28
+ var ownKeys = (o) => {
29
+ ownKeys =
30
+ Object.getOwnPropertyNames ||
31
+ ((o) => {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ });
36
+ return ownKeys(o);
26
37
  };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
38
+ return (mod) => {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null)
42
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++)
43
+ if (k[i] !== 'default') __createBinding(result, mod, k[i]);
44
+ __setModuleDefault(result, mod);
45
+ return result;
33
46
  };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
47
+ })();
48
+ Object.defineProperty(exports, '__esModule', { value: true });
36
49
  exports.POST = POST;
37
- const client_1 = require("@prisma/client");
38
- const auth_1 = require("../../../../lib/services/auth");
39
- const auth_2 = require("../../../../lib/schemas/auth");
40
- const server_1 = require("next/server");
41
- const auth_3 = require("../../../../lib/services/auth");
42
- const library_1 = require("@prisma/client/runtime/library");
43
- const z = __importStar(require("zod"));
44
- const notifications_with_queue_1 = require("../../../../lib/services/notifications-with-queue");
45
- const logger_1 = require("../../../../lib/logger");
50
+ const client_1 = require('@prisma/client');
51
+ const auth_1 = require('../../../../lib/services/auth');
52
+ const auth_2 = require('../../../../lib/schemas/auth');
53
+ const server_1 = require('next/server');
54
+ const auth_3 = require('../../../../lib/services/auth');
55
+ const library_1 = require('@prisma/client/runtime/library');
56
+ const z = __importStar(require('zod'));
57
+ const notifications_with_queue_1 = require('../../../../lib/services/notifications-with-queue');
58
+ const logger_1 = require('../../../../lib/logger');
46
59
  async function POST(req) {
47
- try {
48
- const body = await req.json();
49
- const { email, password, firstName, lastName } = auth_2.signupSchema.parse(body);
50
- const prisma = new client_1.PrismaClient();
51
- const existingUser = await prisma.user.findUnique({ where: { email } });
52
- if (existingUser) {
53
- return server_1.NextResponse.json({ success: false, error: 'Email already exists' }, { status: 400 });
54
- }
55
- const hashedPassword = await (0, auth_1.hashPassword)(password);
56
- const user = await prisma.user.create({
57
- data: {
58
- email,
59
- password: hashedPassword,
60
- firstName,
61
- lastName,
62
- },
63
- });
64
- const verificationToken = (0, auth_3.generateToken)({ userId: user.id }, '24h');
65
- await prisma.token.create({
66
- data: {
67
- token: verificationToken,
68
- type: 'EMAIL_VERIFICATION',
69
- userId: user.id,
70
- expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000),
71
- },
72
- });
73
- const notificationService = await (0, notifications_with_queue_1.getNotificationServiceWithQueue)();
74
- logger_1.logger.info('Sending email verification notification', { userId: user.id });
75
- await notificationService.createNotification({
76
- userId: user.id,
77
- notificationType: 'EMAIL',
78
- title: 'Email Verification',
79
- contextName: 'emailVerification',
80
- contextParameters: { token: verificationToken },
81
- sendAfter: new Date(),
82
- bodyTemplate: './src/email-templates/auth/verify-email/verify-email-body.html.pug',
83
- subjectTemplate: './src/email-templates/auth/verify-email/verify-email-subject.txt.pug',
84
- extraParams: {},
85
- });
86
- return server_1.NextResponse.json({ success: true, message: 'User created successfully' }, { status: 201 });
60
+ try {
61
+ const body = await req.json();
62
+ const { email, password, firstName, lastName } = auth_2.signupSchema.parse(body);
63
+ const prisma = new client_1.PrismaClient();
64
+ const existingUser = await prisma.user.findUnique({ where: { email } });
65
+ if (existingUser) {
66
+ return server_1.NextResponse.json(
67
+ { success: false, error: 'Email already exists' },
68
+ { status: 400 },
69
+ );
87
70
  }
88
- catch (error) {
89
- if (error instanceof z.ZodError) {
90
- const validationError = error;
91
- return server_1.NextResponse.json({
92
- success: false,
93
- error: 'Validation error',
94
- details: validationError.flatten(),
95
- }, { status: 400 });
96
- }
97
- if (error instanceof library_1.PrismaClientKnownRequestError) {
98
- return server_1.NextResponse.json({ success: false, error: 'Database error occurred' }, { status: 500 });
99
- }
100
- console.error('Signup error:', error);
101
- return server_1.NextResponse.json({ success: false, error: 'Internal server error' }, { status: 500 });
71
+ const hashedPassword = await (0, auth_1.hashPassword)(password);
72
+ const user = await prisma.user.create({
73
+ data: {
74
+ email,
75
+ password: hashedPassword,
76
+ firstName,
77
+ lastName,
78
+ },
79
+ });
80
+ const verificationToken = (0, auth_3.generateToken)({ userId: user.id }, '24h');
81
+ await prisma.token.create({
82
+ data: {
83
+ token: verificationToken,
84
+ type: 'EMAIL_VERIFICATION',
85
+ userId: user.id,
86
+ expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000),
87
+ },
88
+ });
89
+ const notificationService = await (0,
90
+ notifications_with_queue_1.getNotificationServiceWithQueue)();
91
+ logger_1.logger.info('Sending email verification notification', { userId: user.id });
92
+ await notificationService.createNotification({
93
+ userId: user.id,
94
+ notificationType: 'EMAIL',
95
+ title: 'Email Verification',
96
+ contextName: 'emailVerification',
97
+ contextParameters: { token: verificationToken },
98
+ sendAfter: new Date(),
99
+ bodyTemplate: './src/email-templates/auth/verify-email/verify-email-body.html.pug',
100
+ subjectTemplate: './src/email-templates/auth/verify-email/verify-email-subject.txt.pug',
101
+ extraParams: {},
102
+ });
103
+ return server_1.NextResponse.json(
104
+ { success: true, message: 'User created successfully' },
105
+ { status: 201 },
106
+ );
107
+ } catch (error) {
108
+ if (error instanceof z.ZodError) {
109
+ const validationError = error;
110
+ return server_1.NextResponse.json(
111
+ {
112
+ success: false,
113
+ error: 'Validation error',
114
+ details: validationError.flatten(),
115
+ },
116
+ { status: 400 },
117
+ );
118
+ }
119
+ if (error instanceof library_1.PrismaClientKnownRequestError) {
120
+ return server_1.NextResponse.json(
121
+ { success: false, error: 'Database error occurred' },
122
+ { status: 500 },
123
+ );
102
124
  }
125
+ console.error('Signup error:', error);
126
+ return server_1.NextResponse.json(
127
+ { success: false, error: 'Internal server error' },
128
+ { status: 500 },
129
+ );
130
+ }
103
131
  }
@@ -1,10 +1,12 @@
1
- import { NextResponse } from 'next/server';
2
- import * as z from 'zod';
1
+ import type { NextResponse } from 'next/server';
2
+ import type * as z from 'zod';
3
3
  import type { WriteApiResponse } from '../../../../lib/api-clients/core';
4
- import { type VerifyEmailValues } from '../../../../lib/schemas/auth';
4
+ import type { VerifyEmailValues } from '../../../../lib/schemas/auth';
5
5
  type VerifyEmailSuccess = null;
6
6
  type VerifyEmailValidationError = z.typeToFlattenedError<VerifyEmailValues>;
7
- export type VerifyEmailApiResponse = WriteApiResponse<VerifyEmailSuccess, VerifyEmailValidationError>;
7
+ export type VerifyEmailApiResponse = WriteApiResponse<
8
+ VerifyEmailSuccess,
9
+ VerifyEmailValidationError
10
+ >;
8
11
  type VerifyEmailNextResponse = NextResponse<VerifyEmailApiResponse>;
9
12
  export declare function POST(req: Request): Promise<VerifyEmailNextResponse>;
10
- export {};
@@ -1,77 +1,101 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
1
+ var __createBinding =
2
+ (this && this.__createBinding) ||
3
+ (Object.create
4
+ ? (o, m, k, k2) => {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: () => m[k] };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }
12
+ : (o, m, k, k2) => {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ });
16
+ var __setModuleDefault =
17
+ (this && this.__setModuleDefault) ||
18
+ (Object.create
19
+ ? (o, v) => {
20
+ Object.defineProperty(o, 'default', { enumerable: true, value: v });
21
+ }
22
+ : (o, v) => {
23
+ o['default'] = v;
24
+ });
25
+ var __importStar =
26
+ (this && this.__importStar) ||
27
+ (() => {
28
+ var ownKeys = (o) => {
29
+ ownKeys =
30
+ Object.getOwnPropertyNames ||
31
+ ((o) => {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ });
36
+ return ownKeys(o);
26
37
  };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
38
+ return (mod) => {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null)
42
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++)
43
+ if (k[i] !== 'default') __createBinding(result, mod, k[i]);
44
+ __setModuleDefault(result, mod);
45
+ return result;
33
46
  };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
47
+ })();
48
+ Object.defineProperty(exports, '__esModule', { value: true });
36
49
  exports.POST = POST;
37
- const client_1 = require("@prisma/client");
38
- const auth_1 = require("../../../../lib/services/auth");
39
- const server_1 = require("next/server");
40
- const z = __importStar(require("zod"));
41
- const auth_2 = require("../../../../lib/schemas/auth");
42
- const library_1 = require("@prisma/client/runtime/library");
50
+ const client_1 = require('@prisma/client');
51
+ const auth_1 = require('../../../../lib/services/auth');
52
+ const server_1 = require('next/server');
53
+ const z = __importStar(require('zod'));
54
+ const auth_2 = require('../../../../lib/schemas/auth');
55
+ const library_1 = require('@prisma/client/runtime/library');
43
56
  async function POST(req) {
44
- try {
45
- const body = await req.json();
46
- const { token } = auth_2.verifyEmailSchema.parse(body);
47
- const prisma = new client_1.PrismaClient();
48
- const decoded = (0, auth_1.verifyToken)(token);
49
- const tokenRecord = await prisma.token.findFirst({
50
- where: {
51
- token,
52
- type: 'EMAIL_VERIFICATION',
53
- expiresAt: { gt: new Date() },
54
- },
55
- });
56
- if (!tokenRecord) {
57
- return server_1.NextResponse.json({ success: false, error: 'Invalid or expired token' }, { status: 400 });
58
- }
59
- await prisma.user.update({
60
- where: { id: Number.parseInt(decoded.userId) },
61
- data: { isEmailVerified: true },
62
- });
63
- await prisma.token.delete({ where: { id: tokenRecord.id } });
64
- return server_1.NextResponse.json({ success: true, message: 'Email verified successfully' });
57
+ try {
58
+ const body = await req.json();
59
+ const { token } = auth_2.verifyEmailSchema.parse(body);
60
+ const prisma = new client_1.PrismaClient();
61
+ const decoded = (0, auth_1.verifyToken)(token);
62
+ const tokenRecord = await prisma.token.findFirst({
63
+ where: {
64
+ token,
65
+ type: 'EMAIL_VERIFICATION',
66
+ expiresAt: { gt: new Date() },
67
+ },
68
+ });
69
+ if (!tokenRecord) {
70
+ return server_1.NextResponse.json(
71
+ { success: false, error: 'Invalid or expired token' },
72
+ { status: 400 },
73
+ );
65
74
  }
66
- catch (error) {
67
- if (error instanceof z.ZodError) {
68
- const validationError = error;
69
- return server_1.NextResponse.json({ success: false, error: 'Validation error', details: validationError.flatten() }, { status: 400 });
70
- }
71
- if (error instanceof library_1.PrismaClientKnownRequestError) {
72
- return server_1.NextResponse.json({ success: false, error: 'Database error occurred' }, { status: 500 });
73
- }
74
- console.error('Email verification error:', error);
75
- return server_1.NextResponse.json({ success: false, error: 'Internal server error' }, { status: 500 });
75
+ await prisma.user.update({
76
+ where: { id: Number.parseInt(decoded.userId) },
77
+ data: { isEmailVerified: true },
78
+ });
79
+ await prisma.token.delete({ where: { id: tokenRecord.id } });
80
+ return server_1.NextResponse.json({ success: true, message: 'Email verified successfully' });
81
+ } catch (error) {
82
+ if (error instanceof z.ZodError) {
83
+ const validationError = error;
84
+ return server_1.NextResponse.json(
85
+ { success: false, error: 'Validation error', details: validationError.flatten() },
86
+ { status: 400 },
87
+ );
88
+ }
89
+ if (error instanceof library_1.PrismaClientKnownRequestError) {
90
+ return server_1.NextResponse.json(
91
+ { success: false, error: 'Database error occurred' },
92
+ { status: 500 },
93
+ );
76
94
  }
95
+ console.error('Email verification error:', error);
96
+ return server_1.NextResponse.json(
97
+ { success: false, error: 'Internal server error' },
98
+ { status: 500 },
99
+ );
100
+ }
77
101
  }
@@ -1 +1 @@
1
- export default function LoginPage(): import("react").JSX.Element;
1
+ export default function LoginPage(): import('react').JSX.Element;
@@ -1,72 +1,83 @@
1
- "use strict";
2
1
  'use client';
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ var __importDefault =
3
+ (this && this.__importDefault) || ((mod) => (mod && mod.__esModule ? mod : { default: mod }));
4
+ Object.defineProperty(exports, '__esModule', { value: true });
7
5
  exports.default = LoginPage;
8
- const react_1 = require("react");
9
- const navigation_1 = require("next/navigation");
10
- const link_1 = __importDefault(require("next/link"));
11
- const zod_1 = require("@hookform/resolvers/zod");
12
- const react_hook_form_1 = require("react-hook-form");
13
- const button_1 = require("../../../components/ui/button");
14
- const input_1 = require("../../../components/ui/input");
15
- const alert_1 = require("../../../components/ui/alert");
16
- const form_1 = require("../../../components/ui/form");
17
- const auth_1 = require("../../../lib/schemas/auth");
18
- const auth_2 = require("../../../lib/api-clients/auth");
19
- const AuthLayout_1 = require("../../../components/AuthLayout");
6
+ const react_1 = require('react');
7
+ const navigation_1 = require('next/navigation');
8
+ const link_1 = __importDefault(require('next/link'));
9
+ const zod_1 = require('@hookform/resolvers/zod');
10
+ const react_hook_form_1 = require('react-hook-form');
11
+ const button_1 = require('../../../components/ui/button');
12
+ const input_1 = require('../../../components/ui/input');
13
+ const alert_1 = require('../../../components/ui/alert');
14
+ const form_1 = require('../../../components/ui/form');
15
+ const auth_1 = require('../../../lib/schemas/auth');
16
+ const auth_2 = require('../../../lib/api-clients/auth');
17
+ const AuthLayout_1 = require('../../../components/AuthLayout');
20
18
  function LoginPage() {
21
- const router = (0, navigation_1.useRouter)();
22
- const [error, setError] = (0, react_1.useState)('');
23
- const [loading, setLoading] = (0, react_1.useState)(false);
24
- const form = (0, react_hook_form_1.useForm)({
25
- resolver: (0, zod_1.zodResolver)(auth_1.loginSchema),
26
- defaultValues: {
27
- email: "",
28
- password: "",
29
- },
30
- });
31
- async function onSubmit(data) {
32
- setError('');
33
- setLoading(true);
34
- try {
35
- const response = await auth_2.authApi.login(data);
36
- if (!response.success) {
37
- throw new Error(response.error || 'Login failed');
38
- }
39
- router.push('/dashboard');
40
- }
41
- catch (err) {
42
- setError(err instanceof Error ? err.message : 'Login failed');
43
- }
44
- finally {
45
- setLoading(false);
46
- }
19
+ const router = (0, navigation_1.useRouter)();
20
+ const [error, setError] = (0, react_1.useState)('');
21
+ const [loading, setLoading] = (0, react_1.useState)(false);
22
+ const form = (0, react_hook_form_1.useForm)({
23
+ resolver: (0, zod_1.zodResolver)(auth_1.loginSchema),
24
+ defaultValues: {
25
+ email: '',
26
+ password: '',
27
+ },
28
+ });
29
+ async function onSubmit(data) {
30
+ setError('');
31
+ setLoading(true);
32
+ try {
33
+ const response = await auth_2.authApi.login(data);
34
+ if (!response.success) {
35
+ throw new Error(response.error || 'Login failed');
36
+ }
37
+ router.push('/dashboard');
38
+ } catch (err) {
39
+ setError(err instanceof Error ? err.message : 'Login failed');
40
+ } finally {
41
+ setLoading(false);
47
42
  }
48
- return (<AuthLayout_1.AuthLayout title="Login">
49
- {error && (<alert_1.Alert variant="destructive" className="mb-4">
50
- <alert_1.AlertDescription>{error}</alert_1.AlertDescription>
51
- </alert_1.Alert>)}
52
-
43
+ }
44
+ return (
45
+ <AuthLayout_1.AuthLayout title="Login">
46
+ {error && (
47
+ <alert_1.Alert variant="destructive" className="mb-4">
48
+ <alert_1.AlertDescription>{error}</alert_1.AlertDescription>
49
+ </alert_1.Alert>
50
+ )}
51
+
53
52
  <form_1.Form {...form}>
54
53
  <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
55
- <form_1.FormField control={form.control} name="email" render={({ field }) => (<form_1.FormItem>
54
+ <form_1.FormField
55
+ control={form.control}
56
+ name="email"
57
+ render={({ field }) => (
58
+ <form_1.FormItem>
56
59
  <form_1.FormLabel>Email</form_1.FormLabel>
57
60
  <form_1.FormControl>
58
- <input_1.Input type="email" {...field}/>
61
+ <input_1.Input type="email" {...field} />
59
62
  </form_1.FormControl>
60
63
  <form_1.FormMessage />
61
- </form_1.FormItem>)}/>
64
+ </form_1.FormItem>
65
+ )}
66
+ />
62
67
 
63
- <form_1.FormField control={form.control} name="password" render={({ field }) => (<form_1.FormItem>
68
+ <form_1.FormField
69
+ control={form.control}
70
+ name="password"
71
+ render={({ field }) => (
72
+ <form_1.FormItem>
64
73
  <form_1.FormLabel>Password</form_1.FormLabel>
65
74
  <form_1.FormControl>
66
- <input_1.Input type="password" {...field}/>
75
+ <input_1.Input type="password" {...field} />
67
76
  </form_1.FormControl>
68
77
  <form_1.FormMessage />
69
- </form_1.FormItem>)}/>
78
+ </form_1.FormItem>
79
+ )}
80
+ />
70
81
 
71
82
  <button_1.Button type="submit" className="w-full" disabled={loading}>
72
83
  {loading ? 'Submitting...' : 'Login'}
@@ -80,5 +91,6 @@ function LoginPage() {
80
91
  Sign up
81
92
  </link_1.default>
82
93
  </p>
83
- </AuthLayout_1.AuthLayout>);
94
+ </AuthLayout_1.AuthLayout>
95
+ );
84
96
  }
@@ -1 +1 @@
1
- export default function ResetPassword(): import("react").JSX.Element;
1
+ export default function ResetPassword(): import('react').JSX.Element;