@xk2800/nextjs-template 0.7.2-beta.0 → 0.7.2-beta.2

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 (63) hide show
  1. package/dist/activity/logger.js +0 -1
  2. package/dist/activity/logger.js.map +1 -1
  3. package/dist/activity/logger.mjs +3 -3
  4. package/dist/activity/queries.js +0 -1
  5. package/dist/activity/queries.js.map +1 -1
  6. package/dist/activity/queries.mjs +2 -2
  7. package/dist/admin/queries.js +0 -1
  8. package/dist/admin/queries.js.map +1 -1
  9. package/dist/admin/queries.mjs +2 -2
  10. package/dist/api/feedback.js +12 -1
  11. package/dist/api/feedback.js.map +1 -1
  12. package/dist/api/feedback.mjs +6 -6
  13. package/dist/api/marketing.js +12 -1
  14. package/dist/api/marketing.js.map +1 -1
  15. package/dist/api/marketing.mjs +7 -7
  16. package/dist/auth/helpers.d.mts +3 -3
  17. package/dist/auth/helpers.d.ts +3 -3
  18. package/dist/auth/helpers.js +12 -1
  19. package/dist/auth/helpers.js.map +1 -1
  20. package/dist/auth/helpers.mjs +6 -6
  21. package/dist/auth/index.d.mts +18 -0
  22. package/dist/auth/index.d.ts +18 -0
  23. package/dist/auth/index.js +12 -1
  24. package/dist/auth/index.js.map +1 -1
  25. package/dist/auth/index.mjs +5 -5
  26. package/dist/auth-client/index.d.mts +16 -16
  27. package/dist/auth-client/index.d.ts +16 -16
  28. package/dist/{chunk-A6JXMHOQ.mjs → chunk-2BJ3B4FR.mjs} +4 -4
  29. package/dist/{chunk-A6JXMHOQ.mjs.map → chunk-2BJ3B4FR.mjs.map} +1 -1
  30. package/dist/{chunk-YH53UPUW.mjs → chunk-653GF7OT.mjs} +4 -4
  31. package/dist/{chunk-YH53UPUW.mjs.map → chunk-653GF7OT.mjs.map} +1 -1
  32. package/dist/{chunk-VHNGYAIG.mjs → chunk-K2GCSLRJ.mjs} +18 -6
  33. package/dist/chunk-K2GCSLRJ.mjs.map +1 -0
  34. package/dist/{chunk-4C7JHGT5.mjs → chunk-K62JYJRR.mjs} +3 -3
  35. package/dist/{chunk-4C7JHGT5.mjs.map → chunk-K62JYJRR.mjs.map} +1 -1
  36. package/dist/{chunk-4F6KE47S.mjs → chunk-O5EQYHNC.mjs} +4 -4
  37. package/dist/{chunk-4F6KE47S.mjs.map → chunk-O5EQYHNC.mjs.map} +1 -1
  38. package/dist/{chunk-KA2KMGPY.mjs → chunk-TE5BEAQB.mjs} +2 -3
  39. package/dist/chunk-TE5BEAQB.mjs.map +1 -0
  40. package/dist/{chunk-JUSU6UZA.mjs → chunk-VVXYKVFJ.mjs} +5 -5
  41. package/dist/{chunk-JUSU6UZA.mjs.map → chunk-VVXYKVFJ.mjs.map} +1 -1
  42. package/dist/db/index.js +0 -1
  43. package/dist/db/index.js.map +1 -1
  44. package/dist/db/index.mjs +2 -2
  45. package/dist/db/schema.js +0 -1
  46. package/dist/db/schema.js.map +1 -1
  47. package/dist/db/schema.mjs +1 -1
  48. package/dist/errors.js +0 -1
  49. package/dist/errors.js.map +1 -1
  50. package/dist/errors.mjs +3 -3
  51. package/dist/sessions/queries.js +0 -1
  52. package/dist/sessions/queries.js.map +1 -1
  53. package/dist/sessions/queries.mjs +2 -2
  54. package/dist/settings/queries.js +0 -1
  55. package/dist/settings/queries.js.map +1 -1
  56. package/dist/settings/queries.mjs +3 -3
  57. package/dist/users/queries.js +0 -1
  58. package/dist/users/queries.js.map +1 -1
  59. package/dist/users/queries.mjs +2 -2
  60. package/lib/maintenance.ts +0 -1
  61. package/package.json +1 -1
  62. package/dist/chunk-KA2KMGPY.mjs.map +0 -1
  63. package/dist/chunk-VHNGYAIG.mjs.map +0 -1
@@ -1,13 +1,13 @@
1
- import { unexpectedErrorMessage } from '../chunk-YH53UPUW.mjs';
1
+ import { unexpectedErrorMessage } from '../chunk-653GF7OT.mjs';
2
2
  import { MARKETING_SEGMENT_ID, setSubscribed } from '../chunk-NQELV53D.mjs';
3
- import { hasRole } from '../chunk-JUSU6UZA.mjs';
4
- import { auth } from '../chunk-VHNGYAIG.mjs';
5
- import '../chunk-4F6KE47S.mjs';
3
+ import { hasRole } from '../chunk-VVXYKVFJ.mjs';
4
+ import { auth } from '../chunk-K2GCSLRJ.mjs';
5
+ import '../chunk-O5EQYHNC.mjs';
6
6
  import '../chunk-6OAHCEDJ.mjs';
7
- import '../chunk-A6JXMHOQ.mjs';
7
+ import '../chunk-2BJ3B4FR.mjs';
8
8
  import { getBroadcastResend, EMAIL_FROM } from '../chunk-L242CZ64.mjs';
9
- import '../chunk-4C7JHGT5.mjs';
10
- import '../chunk-KA2KMGPY.mjs';
9
+ import '../chunk-K62JYJRR.mjs';
10
+ import '../chunk-TE5BEAQB.mjs';
11
11
  import '../chunk-HUEDEAY3.mjs';
12
12
  import '../chunk-3465SI5N.mjs';
13
13
  import 'server-only';
@@ -27,8 +27,8 @@ declare const getCurrentSession: () => Promise<{
27
27
  image?: string | null | undefined | undefined;
28
28
  role: string | null | undefined;
29
29
  banned: boolean | null | undefined;
30
- banReason?: string | null | undefined;
31
30
  banExpires?: Date | null | undefined;
31
+ banReason?: string | null | undefined;
32
32
  twoFactorEnabled: boolean | null | undefined;
33
33
  };
34
34
  } | null>;
@@ -61,8 +61,8 @@ declare const requireAuth: () => Promise<{
61
61
  image?: string | null | undefined | undefined;
62
62
  role: string | null | undefined;
63
63
  banned: boolean | null | undefined;
64
- banReason?: string | null | undefined;
65
64
  banExpires?: Date | null | undefined;
65
+ banReason?: string | null | undefined;
66
66
  twoFactorEnabled: boolean | null | undefined;
67
67
  };
68
68
  }>;
@@ -95,8 +95,8 @@ declare function requireRole(requiredRole: 'user' | 'admin'): Promise<{
95
95
  image?: string | null | undefined | undefined;
96
96
  role: string | null | undefined;
97
97
  banned: boolean | null | undefined;
98
- banReason?: string | null | undefined;
99
98
  banExpires?: Date | null | undefined;
99
+ banReason?: string | null | undefined;
100
100
  twoFactorEnabled: boolean | null | undefined;
101
101
  };
102
102
  }>;
@@ -27,8 +27,8 @@ declare const getCurrentSession: () => Promise<{
27
27
  image?: string | null | undefined | undefined;
28
28
  role: string | null | undefined;
29
29
  banned: boolean | null | undefined;
30
- banReason?: string | null | undefined;
31
30
  banExpires?: Date | null | undefined;
31
+ banReason?: string | null | undefined;
32
32
  twoFactorEnabled: boolean | null | undefined;
33
33
  };
34
34
  } | null>;
@@ -61,8 +61,8 @@ declare const requireAuth: () => Promise<{
61
61
  image?: string | null | undefined | undefined;
62
62
  role: string | null | undefined;
63
63
  banned: boolean | null | undefined;
64
- banReason?: string | null | undefined;
65
64
  banExpires?: Date | null | undefined;
65
+ banReason?: string | null | undefined;
66
66
  twoFactorEnabled: boolean | null | undefined;
67
67
  };
68
68
  }>;
@@ -95,8 +95,8 @@ declare function requireRole(requiredRole: 'user' | 'admin'): Promise<{
95
95
  image?: string | null | undefined | undefined;
96
96
  role: string | null | undefined;
97
97
  banned: boolean | null | undefined;
98
- banReason?: string | null | undefined;
99
98
  banExpires?: Date | null | undefined;
99
+ banReason?: string | null | undefined;
100
100
  twoFactorEnabled: boolean | null | undefined;
101
101
  };
102
102
  }>;
@@ -228,7 +228,6 @@ var DEFAULT_MAINTENANCE_EXEMPT_PATHS = [
228
228
  "/",
229
229
  "/features",
230
230
  "/changelog",
231
- "/changelog-template",
232
231
  "/privacy",
233
232
  "/terms"
234
233
  ];
@@ -1240,6 +1239,14 @@ async function packageSessionCreated(log, ...[session, context]) {
1240
1239
  console.error("Failed to log login activity", error);
1241
1240
  }
1242
1241
  }
1242
+ async function promoteFirstAdmin(user) {
1243
+ var _a;
1244
+ const adminEmail = (_a = process.env.ADMIN_EMAIL) == null ? void 0 : _a.trim().toLowerCase();
1245
+ if (!adminEmail || !user.emailVerified || user.email.toLowerCase() !== adminEmail) return;
1246
+ const [existing] = await db.select({ id: users.id }).from(users).where(drizzleOrm.eq(users.role, "admin")).limit(1);
1247
+ if (existing) return;
1248
+ await db.update(users).set({ role: "admin" }).where(drizzleOrm.eq(users.id, user.id));
1249
+ }
1243
1250
  function createAuth(overrides = {}) {
1244
1251
  var _a, _b, _c, _d, _e, _f, _g;
1245
1252
  const socialProviders = __spreadValues(__spreadValues({}, config.AUTH_ENABLE_GOOGLE ? {
@@ -1319,6 +1326,9 @@ function createAuth(overrides = {}) {
1319
1326
  // callback that flips users.emailVerified on click.
1320
1327
  emailVerification: {
1321
1328
  autoSignInAfterVerification: true,
1329
+ async afterEmailVerification(user) {
1330
+ await promoteFirstAdmin(user);
1331
+ },
1322
1332
  async sendVerificationEmail({ user, url }) {
1323
1333
  const { EmailTemplateVerifyEmail: EmailTemplateVerifyEmail2 } = await Promise.resolve().then(() => (init_email_template_verify_email(), email_template_verify_email_exports));
1324
1334
  await (await getResend()).emails.send({
@@ -1362,6 +1372,7 @@ function createAuth(overrides = {}) {
1362
1372
  create: {
1363
1373
  async after(user, context) {
1364
1374
  var _a2, _b2, _c2, _d2;
1375
+ await promoteFirstAdmin(user);
1365
1376
  await ((_d2 = (_c2 = (_b2 = (_a2 = overrides.databaseHooks) == null ? void 0 : _a2.user) == null ? void 0 : _b2.create) == null ? void 0 : _c2.after) == null ? void 0 : _d2.call(_c2, user, context));
1366
1377
  }
1367
1378
  }