@xk2800/nextjs-template 0.7.2-beta.0 → 0.7.2-beta.10
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 +1 -0
- package/components/auth/{loginErrorRecovery.tsx → forms/login-error-recovery.tsx} +1 -1
- package/components/auth/{emailPasswordLogin.tsx → forms/login-form.tsx} +8 -8
- package/components/auth/{emailPasswordSignup.tsx → forms/signup-form.tsx} +11 -8
- package/components/auth/{authCard.tsx → layout/auth-card.tsx} +5 -5
- package/components/auth/{authShell.tsx → layout/auth-shell.tsx} +17 -5
- package/components/auth/{oneTap.tsx → methods/one-tap.tsx} +2 -2
- package/components/auth/{passkeyLogin.tsx → methods/passkey-login.tsx} +2 -2
- package/components/auth/{socialLogin.tsx → methods/social-login.tsx} +3 -3
- package/components/auth/{twoFactorVerifyForm.tsx → mfa/two-factor-verify-form.tsx} +5 -5
- package/components/auth/{forgotPasswordForm.tsx → recovery/forgot-password-form.tsx} +4 -4
- package/components/auth/{resetPasswordForm.tsx → recovery/reset-password-form.tsx} +4 -4
- package/components/auth/{deviceCheck.tsx → session/device-check.tsx} +3 -3
- package/components/auth/{logoutButtons.tsx → session/logout-buttons.tsx} +2 -2
- package/components/dashboard/admin/{activityLogsSection.tsx → activity-logs/activity-logs-section.tsx} +1 -1
- package/components/dashboard/admin/activity-logs/admin-activity-logs-table.tsx +375 -0
- package/components/dashboard/admin/activity-logs/audit-severity-badge.tsx +50 -0
- package/components/dashboard/admin/activity-logs/security-highlights-collapsible.tsx +129 -0
- package/components/dashboard/admin/{adminActivityLogsSkeleton.tsx → activity-logs/skeletons/activity-logs-skeleton.tsx} +2 -2
- package/components/dashboard/admin/{adminStatsGrid.tsx → home/admin-stats-grid.tsx} +1 -1
- package/components/dashboard/admin/{deviceThrottleCard.tsx → home/device-throttle-card.tsx} +8 -5
- package/components/dashboard/admin/{deviceThrottleTable.tsx → home/device-throttle-table.tsx} +3 -3
- package/components/dashboard/admin/{newDeviceCard.tsx → home/new-device-card.tsx} +6 -2
- package/components/dashboard/admin/{newDeviceTable.tsx → home/new-device-table.tsx} +4 -4
- package/components/dashboard/admin/{sharedDeviceCard.tsx → home/shared-device-card.tsx} +3 -3
- package/components/dashboard/admin/{sharedDeviceTable.tsx → home/shared-device-table.tsx} +3 -3
- package/components/dashboard/admin/{adminStatsGridSkeleton.tsx → home/skeletons/admin-stats-skeleton.tsx} +2 -2
- package/components/dashboard/admin/{broadcastActions.tsx → marketing/broadcast-actions.tsx} +3 -3
- package/components/dashboard/admin/{confirmSendDialog.tsx → marketing/confirm-send-dialog.tsx} +1 -1
- package/components/dashboard/admin/{marketingEmailForm.tsx → marketing/marketing-email-form.tsx} +7 -7
- package/components/dashboard/admin/{marketingSection.tsx → marketing/marketing-section.tsx} +6 -6
- package/components/dashboard/admin/{subscribersCard.tsx → marketing/subscribers-card.tsx} +3 -3
- package/components/dashboard/admin/{feedbackTestForm.tsx → system-settings/feedback-test-form.tsx} +4 -4
- package/components/dashboard/admin/{systemSettingsSkeleton.tsx → system-settings/skeletons/system-settings-skeleton.tsx} +2 -2
- package/components/dashboard/admin/system-settings/system-settings-form.tsx +362 -0
- package/components/dashboard/admin/{systemSettingsSection.tsx → system-settings/system-settings-section.tsx} +3 -2
- package/components/dashboard/admin/users/admin-user-actions.tsx +238 -0
- package/components/dashboard/admin/users/admin-user-profile-card.tsx +70 -0
- package/components/dashboard/admin/users/admin-user-security-card.tsx +47 -0
- package/components/dashboard/admin/users/admin-user-status-card.tsx +89 -0
- package/components/dashboard/admin/{adminUsersTable.tsx → users/admin-users-table.tsx} +129 -132
- package/components/dashboard/admin/{adminUserActivityLogCard.tsx → users/detail/admin-user-activity-log-card.tsx} +3 -3
- package/components/dashboard/admin/{adminUserActivityLogTable.tsx → users/detail/admin-user-activity-log-table.tsx} +3 -3
- package/components/dashboard/admin/{adminUserConsentCard.tsx → users/detail/admin-user-consent-card.tsx} +4 -4
- package/components/dashboard/admin/{adminUserDevicesCard.tsx → users/detail/admin-user-devices-card.tsx} +2 -2
- package/components/dashboard/admin/{adminUserLoginInfoCard.tsx → users/detail/admin-user-login-info-card.tsx} +3 -3
- package/components/dashboard/admin/{adminUserLoginInfoTable.tsx → users/detail/admin-user-login-info-table.tsx} +3 -3
- package/components/dashboard/admin/{adminUserSessionsCard.tsx → users/detail/admin-user-sessions-card.tsx} +5 -5
- package/components/dashboard/admin/{impersonationLogCard.tsx → users/impersonation-log-card.tsx} +10 -5
- package/components/dashboard/admin/users/impersonation-tab.tsx +255 -0
- package/components/dashboard/admin/users/invite-user-dialog.tsx +80 -0
- package/components/dashboard/admin/{revokeAllSessionsButton.tsx → users/revoke-all-sessions.tsx} +5 -3
- package/components/dashboard/admin/{adminUsersSkeleton.tsx → users/skeletons/admin-users-skeleton.tsx} +2 -2
- package/components/dashboard/admin/{usersSection.tsx → users/users-section.tsx} +1 -1
- package/components/dashboard/{errorFeedback.tsx → common/error-feedback.tsx} +1 -1
- package/components/dashboard/{feedbackDialog.tsx → common/feedback-dialog.tsx} +4 -4
- package/components/dashboard/{sectionErrorFallback.tsx → common/section-error-fallback.tsx} +1 -1
- package/components/dashboard/{verifyEmailButton.tsx → common/verify-email-button.tsx} +2 -2
- package/components/dashboard/{appSidebar.tsx → layout/app-sidebar.tsx} +11 -8
- package/components/dashboard/{dashboardHeader.tsx → layout/dashboard-header.tsx} +1 -1
- package/components/dashboard/{impersonationBanner.tsx → layout/impersonation-banner.tsx} +2 -2
- package/components/dashboard/layout/mobile-nav.tsx +95 -0
- package/components/dashboard/{navStyleToggle.tsx → layout/nav-style-toggle.tsx} +1 -1
- package/components/dashboard/{topNav.tsx → layout/top-nav.tsx} +19 -38
- package/components/dashboard/{installAppCard.tsx → overview/install-app-card.tsx} +2 -2
- package/components/dashboard/{accountDetailsCard.tsx → settings/account-details-card.tsx} +5 -5
- package/components/dashboard/{activityLogsCard.tsx → settings/activity-logs-card.tsx} +6 -6
- package/components/dashboard/{activityLogsSection.tsx → settings/activity-logs-section.tsx} +1 -1
- package/components/dashboard/{adminSection.tsx → settings/admin-section.tsx} +2 -2
- package/components/dashboard/{deleteAccountCard.tsx → settings/delete-account-card.tsx} +7 -7
- package/components/dashboard/{marketingUpdatesCard.tsx → settings/marketing-updates-card.tsx} +3 -3
- package/components/dashboard/{marketingUpdatesSection.tsx → settings/marketing-updates-section.tsx} +1 -1
- package/components/dashboard/{passkeysCard.tsx → settings/passkeys-card.tsx} +8 -8
- package/components/dashboard/{profileCard.tsx → settings/profile-card.tsx} +4 -4
- package/components/dashboard/{sessionsCard.tsx → settings/sessions/sessions-card.tsx} +6 -6
- package/components/dashboard/{sessionsSection.tsx → settings/sessions/sessions-section.tsx} +1 -1
- package/components/dashboard/{sessionsCardSkeleton.tsx → settings/sessions/skeletons/sessions-card-skeleton.tsx} +2 -2
- package/components/dashboard/{activityLogsCardSkeleton.tsx → settings/skeletons/activity-logs-card-skeleton.tsx} +2 -2
- package/components/dashboard/{twoFactorCard.tsx → settings/two-factor-card.tsx} +8 -8
- package/components/email/team/workspace-invite.tsx +51 -0
- package/components/email/{send-email-button.tsx → ui/send-email-button.tsx} +1 -1
- package/components/error-boundary.tsx +32 -0
- package/components/settings/appearance/appearance-section.tsx +64 -0
- package/components/settings/index.ts +5 -0
- package/components/settings/notifications/notifications-section.tsx +31 -0
- package/components/settings/profile/profile-section.tsx +38 -0
- package/components/settings/security/security-section.tsx +24 -0
- package/components/settings/settings-nav.tsx +35 -0
- package/components/site/{cookie-banner.tsx → compliance/cookie-banner.tsx} +6 -6
- package/components/site/push/push-notifications-card.tsx +117 -0
- package/components/ui/collapsible.tsx +9 -0
- package/components/ui/column-picker.tsx +1 -1
- package/components/ui/data-table.tsx +1 -1
- package/components/ui/dialog.tsx +46 -13
- package/components/ui/drawer.tsx +88 -0
- package/components/ui/tabs.tsx +52 -0
- package/dist/activity/logger.d.mts +2 -1
- package/dist/activity/logger.d.ts +2 -1
- package/dist/activity/logger.js +66 -16
- package/dist/activity/logger.js.map +1 -1
- package/dist/activity/logger.mjs +4 -4
- package/dist/activity/queries.d.mts +32 -21
- package/dist/activity/queries.d.ts +32 -21
- package/dist/activity/queries.js +86 -23
- package/dist/activity/queries.js.map +1 -1
- package/dist/activity/queries.mjs +27 -14
- package/dist/activity/queries.mjs.map +1 -1
- package/dist/admin/queries.d.mts +2 -1
- package/dist/admin/queries.d.ts +2 -1
- package/dist/admin/queries.js +48 -18
- package/dist/admin/queries.js.map +1 -1
- package/dist/admin/queries.mjs +9 -9
- package/dist/admin/queries.mjs.map +1 -1
- package/dist/api/feedback.js +284 -249
- package/dist/api/feedback.js.map +1 -1
- package/dist/api/feedback.mjs +14 -12
- package/dist/api/feedback.mjs.map +1 -1
- package/dist/api/marketing.js +302 -267
- package/dist/api/marketing.js.map +1 -1
- package/dist/api/marketing.mjs +16 -25
- package/dist/api/marketing.mjs.map +1 -1
- package/dist/auth/helpers.d.mts +63 -21
- package/dist/auth/helpers.d.ts +63 -21
- package/dist/auth/helpers.js +314 -268
- package/dist/auth/helpers.js.map +1 -1
- package/dist/auth/helpers.mjs +9 -9
- package/dist/auth/index.d.mts +86 -47
- package/dist/auth/index.d.ts +86 -47
- package/dist/auth/index.js +278 -245
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/index.mjs +8 -8
- package/dist/auth-client/index.d.mts +1214 -2526
- package/dist/auth-client/index.d.ts +1214 -2526
- package/dist/auth-client/index.js +37 -3
- package/dist/auth-client/index.js.map +1 -1
- package/dist/auth-client/index.mjs +19 -3
- package/dist/auth-client/index.mjs.map +1 -1
- package/dist/{chunk-KA2KMGPY.mjs → chunk-3BH6BVBQ.mjs} +17 -8
- package/dist/chunk-3BH6BVBQ.mjs.map +1 -0
- package/dist/chunk-D56ENLSX.mjs +6 -0
- package/dist/chunk-D56ENLSX.mjs.map +1 -0
- package/dist/{chunk-HUEDEAY3.mjs → chunk-DCPVEZS7.mjs} +14 -4
- package/dist/chunk-DCPVEZS7.mjs.map +1 -0
- package/dist/{chunk-NQELV53D.mjs → chunk-DWLMCMXF.mjs} +4 -4
- package/dist/chunk-DWLMCMXF.mjs.map +1 -0
- package/dist/{chunk-YH53UPUW.mjs → chunk-EXMUANQ3.mjs} +4 -4
- package/dist/chunk-EXMUANQ3.mjs.map +1 -0
- package/dist/{chunk-VHNGYAIG.mjs → chunk-IH6CMZIN.mjs} +213 -220
- package/dist/chunk-IH6CMZIN.mjs.map +1 -0
- package/dist/chunk-LADVCLEQ.mjs +43 -0
- package/dist/chunk-LADVCLEQ.mjs.map +1 -0
- package/dist/{chunk-A6JXMHOQ.mjs → chunk-NJBRKKLK.mjs} +46 -7
- package/dist/chunk-NJBRKKLK.mjs.map +1 -0
- package/dist/{chunk-6OAHCEDJ.mjs → chunk-QDUPSU5O.mjs} +5 -5
- package/dist/chunk-QDUPSU5O.mjs.map +1 -0
- package/dist/{chunk-JUSU6UZA.mjs → chunk-S23GC776.mjs} +41 -29
- package/dist/chunk-S23GC776.mjs.map +1 -0
- package/dist/{chunk-L242CZ64.mjs → chunk-TIR7KHXL.mjs} +3 -3
- package/dist/chunk-TIR7KHXL.mjs.map +1 -0
- package/dist/{chunk-4F6KE47S.mjs → chunk-ZOQHHFYA.mjs} +7 -4
- package/dist/chunk-ZOQHHFYA.mjs.map +1 -0
- package/dist/config/env.d.mts +3 -0
- package/dist/config/env.d.ts +3 -0
- package/dist/config/env.js +12 -2
- package/dist/config/env.js.map +1 -1
- package/dist/config/env.mjs +1 -1
- package/dist/db/index.d.mts +3 -7
- package/dist/db/index.d.ts +3 -7
- package/dist/db/index.js +61 -13
- package/dist/db/index.js.map +1 -1
- package/dist/db/index.mjs +3 -3
- package/dist/db/schema.d.mts +1 -1
- package/dist/db/schema.d.ts +1 -1
- package/dist/db/schema.js +14 -5
- package/dist/db/schema.js.map +1 -1
- package/dist/db/schema.mjs +1 -1
- package/dist/errors.d.mts +2 -1
- package/dist/errors.d.ts +2 -1
- package/dist/errors.js +62 -14
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +4 -4
- package/dist/marketing/index.d.mts +4 -3
- package/dist/marketing/index.d.ts +4 -3
- package/dist/marketing/index.js +14 -4
- package/dist/marketing/index.js.map +1 -1
- package/dist/marketing/index.mjs +3 -3
- package/dist/{email-template-passkey-change-F5Q2SXHD.mjs → passkey-changed-KEGNTIPE.mjs} +2 -2
- package/dist/passkey-changed-KEGNTIPE.mjs.map +1 -0
- package/dist/{email-template-reset-password-QTCQNXOD.mjs → reset-password-64VQEXBW.mjs} +2 -2
- package/dist/reset-password-64VQEXBW.mjs.map +1 -0
- package/dist/{schema-DzC5zdOq.d.mts → schema-BujGgvAy.d.mts} +35 -2
- package/dist/{schema-DzC5zdOq.d.ts → schema-BujGgvAy.d.ts} +35 -2
- package/dist/sessions/queries.js +61 -13
- package/dist/sessions/queries.js.map +1 -1
- package/dist/sessions/queries.mjs +3 -3
- package/dist/sessions/queries.mjs.map +1 -1
- package/dist/settings/queries.d.mts +11 -2
- package/dist/settings/queries.d.ts +11 -2
- package/dist/settings/queries.js +84 -14
- package/dist/settings/queries.js.map +1 -1
- package/dist/settings/queries.mjs +4 -4
- package/dist/users/queries.d.mts +41 -21
- package/dist/users/queries.d.ts +41 -21
- package/dist/users/queries.js +117 -24
- package/dist/users/queries.js.map +1 -1
- package/dist/users/queries.mjs +57 -17
- package/dist/users/queries.mjs.map +1 -1
- package/dist/{email-template-verify-email-WZDCCAKK.mjs → verify-email-4KMNGDKN.mjs} +2 -2
- package/dist/verify-email-4KMNGDKN.mjs.map +1 -0
- package/lib/{auth-client.ts → auth/client.ts} +22 -2
- package/lib/{maintenance.ts → config/maintenance.ts} +0 -1
- package/lib/push/client.ts +39 -0
- package/lib/security/activity-severity.ts +57 -0
- package/lib/{request-info.ts → utils/request-info.ts} +7 -3
- package/package.json +177 -75
- package/scripts/check-deps.mjs +68 -0
- package/components/dashboard/admin/adminActivityLogsTable.tsx +0 -323
- package/components/dashboard/admin/adminUserStatusCard.tsx +0 -57
- package/components/dashboard/admin/systemSettingsForm.tsx +0 -289
- package/dist/chunk-4C7JHGT5.mjs +0 -30
- package/dist/chunk-4C7JHGT5.mjs.map +0 -1
- package/dist/chunk-4F6KE47S.mjs.map +0 -1
- package/dist/chunk-6OAHCEDJ.mjs.map +0 -1
- package/dist/chunk-A6JXMHOQ.mjs.map +0 -1
- package/dist/chunk-HUEDEAY3.mjs.map +0 -1
- package/dist/chunk-JUSU6UZA.mjs.map +0 -1
- package/dist/chunk-KA2KMGPY.mjs.map +0 -1
- package/dist/chunk-L242CZ64.mjs.map +0 -1
- package/dist/chunk-NQELV53D.mjs.map +0 -1
- package/dist/chunk-VHNGYAIG.mjs.map +0 -1
- package/dist/chunk-YH53UPUW.mjs.map +0 -1
- package/dist/email-template-passkey-change-F5Q2SXHD.mjs.map +0 -1
- package/dist/email-template-reset-password-QTCQNXOD.mjs.map +0 -1
- package/dist/email-template-verify-email-WZDCCAKK.mjs.map +0 -1
- /package/components/dashboard/{heartbeat.tsx → common/heartbeat.tsx} +0 -0
- /package/components/email/{email-template-reset-password.tsx → auth/reset-password.tsx} +0 -0
- /package/components/email/{email-template-verify-email.tsx → auth/verify-email.tsx} +0 -0
- /package/components/email/{email-template-welcome.tsx → auth/welcome.tsx} +0 -0
- /package/components/email/{email-template.tsx → layout/base-layout.tsx} +0 -0
- /package/components/email/{email-template-2.tsx → marketing/general-announcement.tsx} +0 -0
- /package/components/email/{email-template-banned.tsx → security/account-banned.tsx} +0 -0
- /package/components/email/{email-template-new-device.tsx → security/new-device-alert.tsx} +0 -0
- /package/components/email/{email-template-passkey-change.tsx → security/passkey-changed.tsx} +0 -0
- /package/lib/{cookie-consent.ts → security/cookie-consent.ts} +0 -0
- /package/lib/{cookie-names.ts → security/cookie-names.ts} +0 -0
- /package/lib/{device-fingerprint.ts → security/device-fingerprint.ts} +0 -0
- /package/lib/{formatters.ts → utils/formatters.ts} +0 -0
- /package/lib/{recalculate-columns.ts → utils/recalculate-columns.ts} +0 -0
|
@@ -5,18 +5,18 @@ import { useEffect, useState } from "react"
|
|
|
5
5
|
|
|
6
6
|
// Relative imports: this file ships raw in the npm package, where `@/` would
|
|
7
7
|
// resolve against the consuming project instead.
|
|
8
|
-
import { Button } from "
|
|
9
|
-
import { Checkbox } from "
|
|
10
|
-
import { Label } from "
|
|
8
|
+
import { Button } from "../../ui/button"
|
|
9
|
+
import { Checkbox } from "../../ui/checkbox"
|
|
10
|
+
import { Label } from "../../ui/label"
|
|
11
11
|
import {
|
|
12
12
|
readConsent,
|
|
13
13
|
setCookieConsent,
|
|
14
14
|
useConsentRequired,
|
|
15
15
|
useCookieConsent,
|
|
16
16
|
type ConsentPurpose,
|
|
17
|
-
} from "
|
|
18
|
-
import { CONSENT_VERSION } from "
|
|
19
|
-
import { useSession } from "
|
|
17
|
+
} from "../../../lib/security/cookie-consent"
|
|
18
|
+
import { CONSENT_VERSION } from "../../../lib/security/cookie-names"
|
|
19
|
+
import { useSession } from "../../../lib/auth/client"
|
|
20
20
|
|
|
21
21
|
// Last choice sent to app/api/consent from this browser, as
|
|
22
22
|
// "userId|choice|version", so each choice is recorded once, not on every load.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from 'react'
|
|
4
|
+
import { toast } from 'sonner'
|
|
5
|
+
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '../../ui/card'
|
|
6
|
+
import { Switch } from '../../ui/switch'
|
|
7
|
+
import { Label } from '../../ui/label'
|
|
8
|
+
import { Button } from '../../ui/button'
|
|
9
|
+
import {
|
|
10
|
+
PUSH_FLAG,
|
|
11
|
+
getRegistration,
|
|
12
|
+
pushSupported,
|
|
13
|
+
saveSubscription,
|
|
14
|
+
subscribe,
|
|
15
|
+
} from '../../../lib/push/client'
|
|
16
|
+
|
|
17
|
+
type State = 'loading' | 'unsupported' | 'no-worker' | 'denied' | 'off' | 'on'
|
|
18
|
+
|
|
19
|
+
// Example: turn push notifications on or off for this device and send a test.
|
|
20
|
+
// Hidden unless the VAPID keys are set (see .env.development.example).
|
|
21
|
+
export default function PushNotificationsCard() {
|
|
22
|
+
const [publicKey, setPublicKey] = useState('')
|
|
23
|
+
const [state, setState] = useState<State>('loading')
|
|
24
|
+
const [busy, setBusy] = useState(false)
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
; (async () => {
|
|
28
|
+
const res = await fetch('/api/push')
|
|
29
|
+
if (res.ok) setPublicKey((await res.json()).publicKey ?? '')
|
|
30
|
+
if (!pushSupported()) return setState('unsupported')
|
|
31
|
+
const reg = await getRegistration()
|
|
32
|
+
if (!reg) return setState('no-worker')
|
|
33
|
+
if (Notification.permission === 'denied') return setState('denied')
|
|
34
|
+
setState((await reg.pushManager.getSubscription()) ? 'on' : 'off')
|
|
35
|
+
})().catch(() => setState('unsupported'))
|
|
36
|
+
}, [])
|
|
37
|
+
|
|
38
|
+
if (!publicKey) return null
|
|
39
|
+
|
|
40
|
+
async function toggle(next: boolean) {
|
|
41
|
+
setBusy(true)
|
|
42
|
+
try {
|
|
43
|
+
const reg = await getRegistration()
|
|
44
|
+
if (!reg) throw new Error('Service worker not registered')
|
|
45
|
+
if (next) {
|
|
46
|
+
if ((await Notification.requestPermission()) !== 'granted') return setState('denied')
|
|
47
|
+
const res = await saveSubscription(await subscribe(reg, publicKey))
|
|
48
|
+
if (!res.ok) throw new Error((await res.json()).error || 'Failed to save subscription')
|
|
49
|
+
localStorage.setItem(PUSH_FLAG, '1')
|
|
50
|
+
setState('on')
|
|
51
|
+
} else {
|
|
52
|
+
localStorage.removeItem(PUSH_FLAG)
|
|
53
|
+
const sub = await reg.pushManager.getSubscription()
|
|
54
|
+
if (sub) {
|
|
55
|
+
await fetch('/api/push', {
|
|
56
|
+
method: 'DELETE',
|
|
57
|
+
headers: { 'Content-Type': 'application/json' },
|
|
58
|
+
body: JSON.stringify({ endpoint: sub.endpoint }),
|
|
59
|
+
})
|
|
60
|
+
await sub.unsubscribe()
|
|
61
|
+
}
|
|
62
|
+
setState('off')
|
|
63
|
+
}
|
|
64
|
+
} catch (e) {
|
|
65
|
+
toast.error(e instanceof Error ? e.message : 'Something went wrong')
|
|
66
|
+
} finally {
|
|
67
|
+
setBusy(false)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function sendTest() {
|
|
72
|
+
setBusy(true)
|
|
73
|
+
try {
|
|
74
|
+
const res = await fetch('/api/push/test', { method: 'POST' })
|
|
75
|
+
const data = await res.json()
|
|
76
|
+
if (!res.ok) throw new Error(data.error || 'Failed to send')
|
|
77
|
+
if (!data.sent) toast.error('No active device found. Turn notifications off and on again.')
|
|
78
|
+
} catch (e) {
|
|
79
|
+
toast.error(e instanceof Error ? e.message : 'Failed to send')
|
|
80
|
+
} finally {
|
|
81
|
+
setBusy(false)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const note: Partial<Record<State, string>> = {
|
|
86
|
+
unsupported:
|
|
87
|
+
"This browser can't receive push notifications. On iPhone and iPad, install the app to your Home Screen first (see below), then open it from there.",
|
|
88
|
+
'no-worker': 'Notifications are only available in production builds (bun run build && bun run start).',
|
|
89
|
+
denied: 'Notifications are blocked for this site. Allow them in your browser or system settings, then reload.',
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<Card>
|
|
94
|
+
<CardHeader>
|
|
95
|
+
<CardTitle>Push notifications</CardTitle>
|
|
96
|
+
<CardDescription>Get notified on this device, even when the app is closed.</CardDescription>
|
|
97
|
+
</CardHeader>
|
|
98
|
+
<CardContent className="space-y-3">
|
|
99
|
+
<div className="flex items-center justify-between gap-4">
|
|
100
|
+
<Label htmlFor="push-notifications">Notify me on this device</Label>
|
|
101
|
+
<Switch
|
|
102
|
+
id="push-notifications"
|
|
103
|
+
checked={state === 'on'}
|
|
104
|
+
disabled={busy || (state !== 'on' && state !== 'off')}
|
|
105
|
+
onCheckedChange={toggle}
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
{note[state] && <p className="text-sm text-muted-foreground">{note[state]}</p>}
|
|
109
|
+
{state === 'on' && (
|
|
110
|
+
<Button variant="outline" size="sm" disabled={busy} onClick={sendTest}>
|
|
111
|
+
Send test notification
|
|
112
|
+
</Button>
|
|
113
|
+
)}
|
|
114
|
+
</CardContent>
|
|
115
|
+
</Card>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { Collapsible as CollapsiblePrimitive } from "radix-ui"
|
|
4
|
+
|
|
5
|
+
const Collapsible = CollapsiblePrimitive.Root
|
|
6
|
+
const CollapsibleTrigger = CollapsiblePrimitive.Trigger
|
|
7
|
+
const CollapsibleContent = CollapsiblePrimitive.Content
|
|
8
|
+
|
|
9
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent }
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
DropdownMenuSeparator,
|
|
14
14
|
DropdownMenuTrigger,
|
|
15
15
|
} from "./dropdown-menu"
|
|
16
|
-
import type { Column } from "../../lib/recalculate-columns"
|
|
16
|
+
import type { Column } from "../../lib/utils/recalculate-columns"
|
|
17
17
|
|
|
18
18
|
// Lets an app switch every table's "Columns" menu on/off in one place (e.g. from a feature flag).
|
|
19
19
|
const ColumnPickerContext = React.createContext(true)
|
package/components/ui/dialog.tsx
CHANGED
|
@@ -3,39 +3,57 @@
|
|
|
3
3
|
import * as React from "react"
|
|
4
4
|
import { Dialog as DialogPrimitive } from "radix-ui"
|
|
5
5
|
import { XIcon } from "lucide-react"
|
|
6
|
+
import { Drawer } from "vaul"
|
|
6
7
|
|
|
8
|
+
import { useIsMobile } from "../../hooks/use-mobile"
|
|
7
9
|
import { cn } from "../../lib/utils"
|
|
8
10
|
|
|
11
|
+
// Below 768px (useIsMobile) the dialog renders as a vaul drawer: bottom sheet with a
|
|
12
|
+
// grab handle and swipe-down-to-dismiss. vaul has its own Radix instance, so every
|
|
13
|
+
// part must come from the same primitive set; the root picks it and shares it via context.
|
|
14
|
+
const MobileContext = React.createContext(false)
|
|
15
|
+
const usePrimitive = () => (React.useContext(MobileContext) ? Drawer : DialogPrimitive)
|
|
16
|
+
|
|
9
17
|
function Dialog({
|
|
10
18
|
...props
|
|
11
19
|
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
12
|
-
|
|
20
|
+
const isMobile = useIsMobile()
|
|
21
|
+
const Root = isMobile ? Drawer.Root : DialogPrimitive.Root
|
|
22
|
+
return (
|
|
23
|
+
<MobileContext.Provider value={isMobile}>
|
|
24
|
+
<Root data-slot="dialog" {...props} />
|
|
25
|
+
</MobileContext.Provider>
|
|
26
|
+
)
|
|
13
27
|
}
|
|
14
28
|
|
|
15
29
|
function DialogTrigger({
|
|
16
30
|
...props
|
|
17
31
|
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
18
|
-
|
|
32
|
+
const P = usePrimitive()
|
|
33
|
+
return <P.Trigger data-slot="dialog-trigger" {...props} />
|
|
19
34
|
}
|
|
20
35
|
|
|
21
36
|
function DialogPortal({
|
|
22
37
|
...props
|
|
23
38
|
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
24
|
-
|
|
39
|
+
const P = usePrimitive()
|
|
40
|
+
return <P.Portal data-slot="dialog-portal" {...props} />
|
|
25
41
|
}
|
|
26
42
|
|
|
27
43
|
function DialogClose({
|
|
28
44
|
...props
|
|
29
45
|
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
30
|
-
|
|
46
|
+
const P = usePrimitive()
|
|
47
|
+
return <P.Close data-slot="dialog-close" {...props} />
|
|
31
48
|
}
|
|
32
49
|
|
|
33
50
|
function DialogOverlay({
|
|
34
51
|
className,
|
|
35
52
|
...props
|
|
36
53
|
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
54
|
+
const P = usePrimitive()
|
|
37
55
|
return (
|
|
38
|
-
<
|
|
56
|
+
<P.Overlay
|
|
39
57
|
data-slot="dialog-overlay"
|
|
40
58
|
className={cn(
|
|
41
59
|
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
@@ -54,28 +72,41 @@ function DialogContent({
|
|
|
54
72
|
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
55
73
|
showCloseButton?: boolean
|
|
56
74
|
}) {
|
|
75
|
+
const isMobile = React.useContext(MobileContext)
|
|
76
|
+
const P = usePrimitive()
|
|
57
77
|
return (
|
|
58
78
|
<DialogPortal data-slot="dialog-portal">
|
|
59
79
|
<DialogOverlay />
|
|
60
|
-
<
|
|
80
|
+
<P.Content
|
|
61
81
|
data-slot="dialog-content"
|
|
62
82
|
className={cn(
|
|
63
|
-
"bg-background
|
|
83
|
+
"bg-background fixed z-50 grid gap-4 border-(length:--surface-border-width) border-(--surface-border-color) p-6 shadow-(--dialog-shadow)",
|
|
84
|
+
isMobile
|
|
85
|
+
? "flex flex-col inset-x-0 bottom-0 max-h-[90dvh] rounded-t-xl pb-[max(1.5rem,env(safe-area-inset-bottom))]"
|
|
86
|
+
: "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 top-[50%] left-[50%] max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] overflow-y-auto translate-x-[-50%] translate-y-[-50%] rounded-lg duration-200 sm:max-w-lg",
|
|
64
87
|
className
|
|
65
88
|
)}
|
|
66
89
|
{...props}
|
|
67
90
|
>
|
|
68
|
-
{
|
|
91
|
+
{isMobile && (
|
|
92
|
+
<div aria-hidden className="bg-muted-foreground/30 mx-auto -mt-2 h-1.5 w-12 shrink-0 rounded-full" />
|
|
93
|
+
)}
|
|
94
|
+
{isMobile ? (
|
|
95
|
+
// Only this wrapper scrolls, and only when the content is taller than the drawer.
|
|
96
|
+
<div className="grid min-h-0 gap-4 overflow-y-auto overscroll-contain">{children}</div>
|
|
97
|
+
) : (
|
|
98
|
+
children
|
|
99
|
+
)}
|
|
69
100
|
{showCloseButton && (
|
|
70
|
-
<
|
|
101
|
+
<P.Close
|
|
71
102
|
data-slot="dialog-close"
|
|
72
103
|
className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
|
73
104
|
>
|
|
74
105
|
<XIcon />
|
|
75
106
|
<span className="sr-only">Close</span>
|
|
76
|
-
</
|
|
107
|
+
</P.Close>
|
|
77
108
|
)}
|
|
78
|
-
</
|
|
109
|
+
</P.Content>
|
|
79
110
|
</DialogPortal>
|
|
80
111
|
)
|
|
81
112
|
}
|
|
@@ -107,8 +138,9 @@ function DialogTitle({
|
|
|
107
138
|
className,
|
|
108
139
|
...props
|
|
109
140
|
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
141
|
+
const P = usePrimitive()
|
|
110
142
|
return (
|
|
111
|
-
<
|
|
143
|
+
<P.Title
|
|
112
144
|
data-slot="dialog-title"
|
|
113
145
|
className={cn("text-lg leading-none font-semibold", className)}
|
|
114
146
|
{...props}
|
|
@@ -120,8 +152,9 @@ function DialogDescription({
|
|
|
120
152
|
className,
|
|
121
153
|
...props
|
|
122
154
|
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
|
155
|
+
const P = usePrimitive()
|
|
123
156
|
return (
|
|
124
|
-
<
|
|
157
|
+
<P.Description
|
|
125
158
|
data-slot="dialog-description"
|
|
126
159
|
className={cn("text-muted-foreground text-sm", className)}
|
|
127
160
|
{...props}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Drawer as DrawerPrimitive } from "vaul"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../lib/utils"
|
|
7
|
+
|
|
8
|
+
function Drawer({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) {
|
|
9
|
+
return <DrawerPrimitive.Root data-slot="drawer" {...props} />
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function DrawerTrigger({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Trigger>) {
|
|
13
|
+
return <DrawerPrimitive.Trigger data-slot="drawer-trigger" {...props} />
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function DrawerPortal({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Portal>) {
|
|
17
|
+
return <DrawerPrimitive.Portal data-slot="drawer-portal" {...props} />
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function DrawerClose({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Close>) {
|
|
21
|
+
return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function DrawerOverlay({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Overlay>) {
|
|
25
|
+
return (
|
|
26
|
+
<DrawerPrimitive.Overlay
|
|
27
|
+
data-slot="drawer-overlay"
|
|
28
|
+
className={cn("fixed inset-0 z-50 bg-black/50", className)}
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Bottom sheet by default; pass direction="top|left|right" on <Drawer> for other edges.
|
|
35
|
+
function DrawerContent({ className, children, ...props }: React.ComponentProps<typeof DrawerPrimitive.Content>) {
|
|
36
|
+
return (
|
|
37
|
+
<DrawerPortal>
|
|
38
|
+
<DrawerOverlay />
|
|
39
|
+
<DrawerPrimitive.Content
|
|
40
|
+
data-slot="drawer-content"
|
|
41
|
+
className={cn(
|
|
42
|
+
"group/drawer-content bg-background fixed z-50 flex h-auto flex-col border-(length:--surface-border-width) border-(--surface-border-color)",
|
|
43
|
+
"data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[90dvh] data-[vaul-drawer-direction=bottom]:rounded-t-xl data-[vaul-drawer-direction=bottom]:pb-[env(safe-area-inset-bottom)]",
|
|
44
|
+
"data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[90dvh] data-[vaul-drawer-direction=top]:rounded-b-xl",
|
|
45
|
+
"data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:sm:max-w-sm",
|
|
46
|
+
"data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:sm:max-w-sm",
|
|
47
|
+
className
|
|
48
|
+
)}
|
|
49
|
+
{...props}
|
|
50
|
+
>
|
|
51
|
+
<div
|
|
52
|
+
aria-hidden
|
|
53
|
+
className="bg-muted-foreground/30 mx-auto mt-4 hidden h-1.5 w-12 shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block"
|
|
54
|
+
/>
|
|
55
|
+
{children}
|
|
56
|
+
</DrawerPrimitive.Content>
|
|
57
|
+
</DrawerPortal>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function DrawerHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
62
|
+
return <div data-slot="drawer-header" className={cn("flex flex-col gap-1.5 p-4", className)} {...props} />
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function DrawerFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
66
|
+
return <div data-slot="drawer-footer" className={cn("mt-auto flex flex-col gap-2 p-4", className)} {...props} />
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function DrawerTitle({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Title>) {
|
|
70
|
+
return <DrawerPrimitive.Title data-slot="drawer-title" className={cn("text-foreground font-semibold", className)} {...props} />
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function DrawerDescription({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Description>) {
|
|
74
|
+
return <DrawerPrimitive.Description data-slot="drawer-description" className={cn("text-muted-foreground text-sm", className)} {...props} />
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
Drawer,
|
|
79
|
+
DrawerClose,
|
|
80
|
+
DrawerContent,
|
|
81
|
+
DrawerDescription,
|
|
82
|
+
DrawerFooter,
|
|
83
|
+
DrawerHeader,
|
|
84
|
+
DrawerOverlay,
|
|
85
|
+
DrawerPortal,
|
|
86
|
+
DrawerTitle,
|
|
87
|
+
DrawerTrigger,
|
|
88
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Tabs as TabsPrimitive } from "radix-ui"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../lib/utils"
|
|
7
|
+
|
|
8
|
+
const Tabs = TabsPrimitive.Root
|
|
9
|
+
|
|
10
|
+
const TabsList = React.forwardRef<
|
|
11
|
+
React.ElementRef<typeof TabsPrimitive.List>,
|
|
12
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
|
13
|
+
>(({ className, ...props }, ref) => (
|
|
14
|
+
<TabsPrimitive.List
|
|
15
|
+
ref={ref}
|
|
16
|
+
className={cn(
|
|
17
|
+
"inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
))
|
|
23
|
+
TabsList.displayName = TabsPrimitive.List.displayName
|
|
24
|
+
|
|
25
|
+
const TabsTrigger = React.forwardRef<
|
|
26
|
+
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
|
27
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
|
28
|
+
>(({ className, ...props }, ref) => (
|
|
29
|
+
<TabsPrimitive.Trigger
|
|
30
|
+
ref={ref}
|
|
31
|
+
className={cn(
|
|
32
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
|
|
33
|
+
className
|
|
34
|
+
)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
))
|
|
38
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
|
|
39
|
+
|
|
40
|
+
const TabsContent = React.forwardRef<
|
|
41
|
+
React.ElementRef<typeof TabsPrimitive.Content>,
|
|
42
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
|
43
|
+
>(({ className, ...props }, ref) => (
|
|
44
|
+
<TabsPrimitive.Content
|
|
45
|
+
ref={ref}
|
|
46
|
+
className={cn("mt-4 focus-visible:outline-none", className)}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
))
|
|
50
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName
|
|
51
|
+
|
|
52
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
|
@@ -17,4 +17,5 @@ interface LogActivityParams {
|
|
|
17
17
|
type ActivityLogger = (entry: LogActivityParams) => Promise<void>;
|
|
18
18
|
declare function logActivity({ userId, action, description, ipAddress, userAgent, metadata, referrerUrl, os, browser, deviceType, country, city, }: LogActivityParams): Promise<void>;
|
|
19
19
|
|
|
20
|
-
export {
|
|
20
|
+
export { logActivity };
|
|
21
|
+
export type { ActivityAction, ActivityLogger, LogActivityParams };
|
|
@@ -17,4 +17,5 @@ interface LogActivityParams {
|
|
|
17
17
|
type ActivityLogger = (entry: LogActivityParams) => Promise<void>;
|
|
18
18
|
declare function logActivity({ userId, action, description, ipAddress, userAgent, metadata, referrerUrl, os, browser, deviceType, country, city, }: LogActivityParams): Promise<void>;
|
|
19
19
|
|
|
20
|
-
export {
|
|
20
|
+
export { logActivity };
|
|
21
|
+
export type { ActivityAction, ActivityLogger, LogActivityParams };
|
package/dist/activity/logger.js
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('server-only');
|
|
4
|
+
var drizzleOrm = require('drizzle-orm');
|
|
4
5
|
var serverless = require('@neondatabase/serverless');
|
|
5
6
|
var neonHttp = require('drizzle-orm/neon-http');
|
|
6
7
|
var nodePostgres = require('drizzle-orm/node-postgres');
|
|
7
8
|
var pg = require('pg');
|
|
8
9
|
var pgCore = require('drizzle-orm/pg-core');
|
|
9
|
-
var drizzleOrm = require('drizzle-orm');
|
|
10
10
|
var cuid2 = require('@paralleldrive/cuid2');
|
|
11
11
|
var zod = require('zod');
|
|
12
12
|
|
|
13
13
|
var __defProp = Object.defineProperty;
|
|
14
|
+
var __defProps = Object.defineProperties;
|
|
15
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
16
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
17
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
19
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
20
|
+
var __spreadValues = (a, b) => {
|
|
21
|
+
for (var prop in b || (b = {}))
|
|
22
|
+
if (__hasOwnProp.call(b, prop))
|
|
23
|
+
__defNormalProp(a, prop, b[prop]);
|
|
24
|
+
if (__getOwnPropSymbols)
|
|
25
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
26
|
+
if (__propIsEnum.call(b, prop))
|
|
27
|
+
__defNormalProp(a, prop, b[prop]);
|
|
28
|
+
}
|
|
29
|
+
return a;
|
|
30
|
+
};
|
|
31
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
14
32
|
var __export = (target, all) => {
|
|
15
33
|
for (var name in all)
|
|
16
34
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -36,12 +54,11 @@ __export(schema_exports, {
|
|
|
36
54
|
verifications: () => verifications
|
|
37
55
|
});
|
|
38
56
|
|
|
39
|
-
// lib/maintenance.ts
|
|
57
|
+
// lib/config/maintenance.ts
|
|
40
58
|
var DEFAULT_MAINTENANCE_EXEMPT_PATHS = [
|
|
41
59
|
"/",
|
|
42
60
|
"/features",
|
|
43
61
|
"/changelog",
|
|
44
|
-
"/changelog-template",
|
|
45
62
|
"/privacy",
|
|
46
63
|
"/terms"
|
|
47
64
|
];
|
|
@@ -104,7 +121,10 @@ var sessions = pgCore.pgTable("session", {
|
|
|
104
121
|
// Set by better-auth's admin plugin while this session is an admin
|
|
105
122
|
// impersonating another user; holds the impersonating admin's user id.
|
|
106
123
|
impersonatedBy: pgCore.text("impersonatedBy")
|
|
107
|
-
})
|
|
124
|
+
}, (table) => [
|
|
125
|
+
// Read by userId on every login (session count), ban/delete and the admin sessions view.
|
|
126
|
+
pgCore.index("session_user_idx").on(table.userId)
|
|
127
|
+
]);
|
|
108
128
|
var accounts = pgCore.pgTable("account", {
|
|
109
129
|
id: pgCore.text("id").notNull().primaryKey().$defaultFn(() => cuid2.createId()),
|
|
110
130
|
accountId: pgCore.text("accountId").notNull(),
|
|
@@ -153,7 +173,10 @@ var verifications = pgCore.pgTable("verification", {
|
|
|
153
173
|
});
|
|
154
174
|
var activityLogs = pgCore.pgTable("activity_log", {
|
|
155
175
|
id: pgCore.text("id").notNull().primaryKey().$defaultFn(() => cuid2.createId()),
|
|
156
|
-
|
|
176
|
+
// SET NULL, not cascade: deleting an admin must not erase the audit trail of
|
|
177
|
+
// what they did. actorEmail keeps who it was once the user row is gone.
|
|
178
|
+
userId: pgCore.text("userId").references(() => users.id, { onDelete: "set null" }),
|
|
179
|
+
actorEmail: pgCore.text("actorEmail"),
|
|
157
180
|
action: ActivityActionEnum("action").notNull(),
|
|
158
181
|
description: pgCore.text("description").notNull(),
|
|
159
182
|
ipAddress: pgCore.text("ipAddress"),
|
|
@@ -169,7 +192,11 @@ var activityLogs = pgCore.pgTable("activity_log", {
|
|
|
169
192
|
country: pgCore.text("country"),
|
|
170
193
|
city: pgCore.text("city"),
|
|
171
194
|
createdAt: pgCore.timestamp("createdAt").notNull().defaultNow()
|
|
172
|
-
})
|
|
195
|
+
}, (table) => [
|
|
196
|
+
// Per-user history, and the admin log's newest-first ordering.
|
|
197
|
+
pgCore.index("activity_log_user_created_idx").on(table.userId, table.createdAt),
|
|
198
|
+
pgCore.index("activity_log_created_idx").on(table.createdAt)
|
|
199
|
+
]);
|
|
173
200
|
var deviceFingerprints = pgCore.pgTable("device_fingerprint", {
|
|
174
201
|
id: pgCore.text("id").notNull().primaryKey().$defaultFn(() => cuid2.createId()),
|
|
175
202
|
userId: pgCore.text("userId").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
@@ -284,7 +311,9 @@ var envSchema = zod.z.object({
|
|
|
284
311
|
RESEND_MARKETING_SEGMENT_ID: zod.z.string().default(""),
|
|
285
312
|
// Sender for every transactional email. Must be on a domain verified in
|
|
286
313
|
// your Resend account.
|
|
287
|
-
|
|
314
|
+
// Resend's shared sandbox sender: works without a verified domain but only
|
|
315
|
+
// delivers to your own Resend account email. Set your verified domain for real use.
|
|
316
|
+
EMAIL_FROM: zod.z.string().default("Acme <onboarding@resend.dev>"),
|
|
288
317
|
// Display name for this deployment — shown as the authenticator-app label
|
|
289
318
|
// (2FA issuer) and the passkey relying-party name. Consuming projects set
|
|
290
319
|
// this in their own .env; defaults to the template name.
|
|
@@ -294,6 +323,9 @@ var envSchema = zod.z.object({
|
|
|
294
323
|
// a comma-separated list and sends through Resend (needs RESEND_API_KEY).
|
|
295
324
|
FEEDBACK_DISCORD_WEBHOOK_URL: zod.z.string().default(""),
|
|
296
325
|
FEEDBACK_EMAIL: zod.z.string().default(""),
|
|
326
|
+
// Seconds between feedback messages per user (default 30, 0 = off). Read
|
|
327
|
+
// straight from process.env in lib/feedback/route.ts; listed here for docs.
|
|
328
|
+
FEEDBACK_COOLDOWN_SECONDS: zod.z.string().default("30"),
|
|
297
329
|
// Web Push (example, see lib/push.ts). Generate keys with
|
|
298
330
|
// `bunx web-push generate-vapid-keys`. Blank = the notifications card is hidden.
|
|
299
331
|
// The public key is also read in the browser as NEXT_PUBLIC_VAPID_PUBLIC_KEY.
|
|
@@ -310,7 +342,12 @@ var envSchema = zod.z.object({
|
|
|
310
342
|
DB_DRIVER: zod.z.enum(["pg", "neon"]).default("pg"),
|
|
311
343
|
// Only relevant when DB_DRIVER=pg — whether the target Postgres server has SSL
|
|
312
344
|
// enabled. Self-hosted Postgres (e.g. via Docker/Dokploy) typically does not.
|
|
313
|
-
DATABASE_SSL: zod.z.string().default("false").transform((val) => val === "true")
|
|
345
|
+
DATABASE_SSL: zod.z.string().default("false").transform((val) => val === "true"),
|
|
346
|
+
// With DATABASE_SSL=true the server certificate is verified. Set the CA (PEM,
|
|
347
|
+
// "\n" for newlines) for a self-signed or private CA; DATABASE_SSL_INSECURE=true
|
|
348
|
+
// skips verification (encrypts only). Both are read in config/pg-ssl.ts.
|
|
349
|
+
DATABASE_SSL_CA: zod.z.string().default(""),
|
|
350
|
+
DATABASE_SSL_INSECURE: zod.z.string().default("false")
|
|
314
351
|
});
|
|
315
352
|
|
|
316
353
|
// config/env.ts
|
|
@@ -324,27 +361,38 @@ if (!results.success) {
|
|
|
324
361
|
}
|
|
325
362
|
var config = results.data;
|
|
326
363
|
|
|
364
|
+
// config/pg-ssl.ts
|
|
365
|
+
function pgSslOptions() {
|
|
366
|
+
var _a;
|
|
367
|
+
if (process.env.DATABASE_SSL_INSECURE === "true") return { rejectUnauthorized: false };
|
|
368
|
+
const ca = (_a = process.env.DATABASE_SSL_CA) == null ? void 0 : _a.replace(/\\n/g, "\n");
|
|
369
|
+
return __spreadValues({ rejectUnauthorized: true }, ca ? { ca } : {});
|
|
370
|
+
}
|
|
371
|
+
|
|
327
372
|
// server/db/index.ts
|
|
328
373
|
var db;
|
|
329
374
|
if (config.DB_DRIVER === "pg") {
|
|
330
375
|
const pool = new pg.Pool({
|
|
331
376
|
connectionString: config.DATABASE_URL,
|
|
332
|
-
ssl: config.DATABASE_SSL ?
|
|
377
|
+
ssl: config.DATABASE_SSL ? pgSslOptions() : void 0,
|
|
378
|
+
// pg waits forever by default; a hung DB would otherwise freeze every request (proxy reads settings).
|
|
379
|
+
connectionTimeoutMillis: 5e3,
|
|
380
|
+
query_timeout: 15e3
|
|
381
|
+
// roomy enough for the 10k-row exports
|
|
333
382
|
});
|
|
334
383
|
db = nodePostgres.drizzle(pool, {
|
|
335
384
|
schema: schema_exports,
|
|
336
|
-
logger:
|
|
385
|
+
logger: process.env.NODE_ENV === "development"
|
|
337
386
|
});
|
|
338
387
|
console.log("\u{1F7E1} Using PostgreSQL (pg) driver");
|
|
339
|
-
} else if (config.DB_DRIVER === "neon") {
|
|
340
|
-
const sql2 = serverless.neon(config.DATABASE_URL);
|
|
341
|
-
db = neonHttp.drizzle(sql2, { schema: schema_exports, logger: true });
|
|
342
|
-
console.log("\u{1F7E2} Using Neon (HTTP) driver");
|
|
343
388
|
} else {
|
|
344
|
-
|
|
389
|
+
serverless.neonConfig.fetchFunction = (url, init) => fetch(url, __spreadProps(__spreadValues({}, init), { signal: AbortSignal.timeout(15e3) }));
|
|
390
|
+
const sql3 = serverless.neon(config.DATABASE_URL);
|
|
391
|
+
db = neonHttp.drizzle(sql3, { schema: schema_exports, logger: process.env.NODE_ENV === "development" });
|
|
392
|
+
console.log("\u{1F7E2} Using Neon (HTTP) driver");
|
|
345
393
|
}
|
|
346
394
|
|
|
347
|
-
// lib/activity-logger.ts
|
|
395
|
+
// lib/security/activity-logger.ts
|
|
348
396
|
async function logActivity({
|
|
349
397
|
userId,
|
|
350
398
|
action,
|
|
@@ -362,6 +410,8 @@ async function logActivity({
|
|
|
362
410
|
try {
|
|
363
411
|
await db.insert(activityLogs).values({
|
|
364
412
|
userId,
|
|
413
|
+
// Snapshot the email at write time; survives deletion of the user row.
|
|
414
|
+
actorEmail: drizzleOrm.sql`(select "email" from "user" where "id" = ${userId})`,
|
|
365
415
|
action,
|
|
366
416
|
description,
|
|
367
417
|
ipAddress: ipAddress || null,
|