@payez/next-mvp 4.0.1 → 4.0.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.
- package/dist/api/auth-handler.d.ts +66 -0
- package/dist/api/auth-handler.js +397 -0
- package/dist/api/index.d.ts +10 -0
- package/dist/api/index.js +19 -0
- package/dist/api-handlers/account/change-password.d.ts +9 -0
- package/dist/api-handlers/account/change-password.js +110 -0
- package/dist/api-handlers/account/masked-info.d.ts +2 -0
- package/dist/api-handlers/account/masked-info.js +41 -0
- package/dist/api-handlers/account/profile.d.ts +3 -0
- package/dist/api-handlers/account/profile.js +63 -0
- package/dist/api-handlers/account/recovery/initiate.d.ts +2 -0
- package/dist/api-handlers/account/recovery/initiate.js +26 -0
- package/dist/api-handlers/account/recovery/send-code.d.ts +2 -0
- package/dist/api-handlers/account/recovery/send-code.js +28 -0
- package/dist/api-handlers/account/recovery/verify-code.d.ts +2 -0
- package/dist/api-handlers/account/recovery/verify-code.js +28 -0
- package/dist/api-handlers/account/reset-password.d.ts +2 -0
- package/dist/api-handlers/account/reset-password.js +26 -0
- package/dist/api-handlers/account/send-code.d.ts +24 -0
- package/dist/api-handlers/account/send-code.js +60 -0
- package/dist/api-handlers/account/update-phone.d.ts +27 -0
- package/dist/api-handlers/account/update-phone.js +64 -0
- package/dist/api-handlers/account/validate-password.d.ts +17 -0
- package/dist/api-handlers/account/validate-password.js +81 -0
- package/dist/api-handlers/account/verify-email.d.ts +26 -0
- package/dist/api-handlers/account/verify-email.js +106 -0
- package/dist/api-handlers/account/verify-sms.d.ts +26 -0
- package/dist/api-handlers/account/verify-sms.js +106 -0
- package/dist/api-handlers/admin/analytics.d.ts +19 -0
- package/dist/api-handlers/admin/analytics.js +378 -0
- package/dist/api-handlers/admin/audit.d.ts +19 -0
- package/dist/api-handlers/admin/audit.js +213 -0
- package/dist/api-handlers/admin/index.d.ts +21 -0
- package/dist/api-handlers/admin/index.js +42 -0
- package/dist/api-handlers/admin/redis-sessions.d.ts +35 -0
- package/dist/api-handlers/admin/redis-sessions.js +203 -0
- package/dist/api-handlers/admin/sessions.d.ts +20 -0
- package/dist/api-handlers/admin/sessions.js +283 -0
- package/dist/api-handlers/admin/site-logs.d.ts +45 -0
- package/dist/api-handlers/admin/site-logs.js +317 -0
- package/dist/api-handlers/admin/stats.d.ts +20 -0
- package/dist/api-handlers/admin/stats.js +239 -0
- package/dist/api-handlers/admin/users.d.ts +19 -0
- package/dist/api-handlers/admin/users.js +221 -0
- package/dist/api-handlers/admin/vibe-data.d.ts +79 -0
- package/dist/api-handlers/admin/vibe-data.js +267 -0
- package/dist/api-handlers/anon/preferences.d.ts +37 -0
- package/dist/api-handlers/anon/preferences.js +96 -0
- package/dist/api-handlers/auth/jwks.d.ts +2 -0
- package/dist/api-handlers/auth/jwks.js +24 -0
- package/dist/api-handlers/auth/login.d.ts +42 -0
- package/dist/api-handlers/auth/login.js +178 -0
- package/dist/api-handlers/auth/refresh.d.ts +74 -0
- package/dist/api-handlers/auth/refresh.js +633 -0
- package/dist/api-handlers/auth/signout.d.ts +37 -0
- package/dist/api-handlers/auth/signout.js +186 -0
- package/dist/api-handlers/auth/status.d.ts +8 -0
- package/dist/api-handlers/auth/status.js +23 -0
- package/dist/api-handlers/auth/update-session.d.ts +37 -0
- package/dist/api-handlers/auth/update-session.js +93 -0
- package/dist/api-handlers/auth/validate.d.ts +6 -0
- package/dist/api-handlers/auth/validate.js +43 -0
- package/dist/api-handlers/auth/verify-code.d.ts +43 -0
- package/dist/api-handlers/auth/verify-code.js +90 -0
- package/dist/api-handlers/session/refresh-viability.d.ts +14 -0
- package/dist/api-handlers/session/refresh-viability.js +39 -0
- package/dist/api-handlers/session/viability.d.ts +13 -0
- package/dist/api-handlers/session/viability.js +114 -0
- package/dist/api-handlers/test/force-expire.d.ts +23 -0
- package/dist/api-handlers/test/force-expire.js +59 -0
- package/dist/auth/auth-decision.d.ts +39 -0
- package/dist/auth/auth-decision.js +182 -0
- package/dist/auth/better-auth.d.ts +79 -0
- package/dist/auth/better-auth.js +119 -0
- package/dist/auth/route-config.d.ts +66 -0
- package/dist/auth/route-config.js +190 -0
- package/dist/auth/types/auth-types.d.ts +417 -0
- package/dist/auth/types/auth-types.js +53 -0
- package/dist/auth/types/index.d.ts +6 -0
- package/dist/auth/types/index.js +22 -0
- package/dist/auth/unauthenticated-routes.d.ts +1 -0
- package/dist/auth/unauthenticated-routes.js +19 -0
- package/dist/auth/utils/idp-client.d.ts +94 -0
- package/dist/auth/utils/idp-client.js +384 -0
- package/dist/auth/utils/index.d.ts +5 -0
- package/dist/auth/utils/index.js +21 -0
- package/dist/auth/utils/token-utils.d.ts +83 -0
- package/dist/auth/utils/token-utils.js +218 -0
- package/dist/client/AuthContext.d.ts +19 -0
- package/dist/client/AuthContext.js +115 -0
- package/dist/client/better-auth-client.d.ts +1020 -0
- package/dist/client/better-auth-client.js +68 -0
- package/dist/client/fetch-with-auth.d.ts +11 -0
- package/dist/client/fetch-with-auth.js +44 -0
- package/dist/client/fetchWithSession.d.ts +3 -0
- package/dist/client/fetchWithSession.js +24 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.js +20 -0
- package/dist/client/useAnonSession.d.ts +36 -0
- package/dist/client/useAnonSession.js +99 -0
- package/dist/components/SessionSync.d.ts +13 -0
- package/dist/components/SessionSync.js +121 -0
- package/dist/components/SignalRHealthCheck.d.ts +10 -0
- package/dist/components/SignalRHealthCheck.js +97 -0
- package/dist/components/account/MobileNavDrawer.d.ts +32 -0
- package/dist/components/account/MobileNavDrawer.js +81 -0
- package/dist/components/account/UserAvatarMenu.d.ts +20 -0
- package/dist/components/account/UserAvatarMenu.js +91 -0
- package/dist/components/account/index.d.ts +9 -0
- package/dist/components/account/index.js +13 -0
- package/dist/components/admin/AlertSettingsTab.d.ts +48 -0
- package/dist/components/admin/AlertSettingsTab.js +351 -0
- package/dist/components/admin/AnalyticsTab.d.ts +22 -0
- package/dist/components/admin/AnalyticsTab.js +167 -0
- package/dist/components/admin/DataBrowserTab.d.ts +19 -0
- package/dist/components/admin/DataBrowserTab.js +252 -0
- package/dist/components/admin/LoggingSettingsTab.d.ts +73 -0
- package/dist/components/admin/LoggingSettingsTab.js +339 -0
- package/dist/components/admin/SessionsTab.d.ts +37 -0
- package/dist/components/admin/SessionsTab.js +165 -0
- package/dist/components/admin/StatsTab.d.ts +53 -0
- package/dist/components/admin/StatsTab.js +161 -0
- package/dist/components/admin/VibeAdminContext.d.ts +32 -0
- package/dist/components/admin/VibeAdminContext.js +38 -0
- package/dist/components/admin/VibeAdminLayout.d.ts +11 -0
- package/dist/components/admin/VibeAdminLayout.js +71 -0
- package/dist/components/admin/index.d.ts +29 -0
- package/dist/components/admin/index.js +44 -0
- package/dist/components/auth/FederatedAuthSection.d.ts +8 -0
- package/dist/components/auth/FederatedAuthSection.js +45 -0
- package/dist/components/auth/ModeAwareLoginPage.d.ts +10 -0
- package/dist/components/auth/ModeAwareLoginPage.js +42 -0
- package/dist/components/auth/ModeAwareSignupPage.d.ts +9 -0
- package/dist/components/auth/ModeAwareSignupPage.js +78 -0
- package/dist/components/auth/TraditionalAuthSection.d.ts +14 -0
- package/dist/components/auth/TraditionalAuthSection.js +20 -0
- package/dist/components/recovery/CompleteStep.d.ts +5 -0
- package/dist/components/recovery/CompleteStep.js +8 -0
- package/dist/components/recovery/InitiateRecoveryStep.d.ts +8 -0
- package/dist/components/recovery/InitiateRecoveryStep.js +20 -0
- package/dist/components/recovery/SelectMethodStep.d.ts +8 -0
- package/dist/components/recovery/SelectMethodStep.js +8 -0
- package/dist/components/recovery/SetPasswordStep.d.ts +6 -0
- package/dist/components/recovery/SetPasswordStep.js +20 -0
- package/dist/components/recovery/VerifyCodeStep.d.ts +10 -0
- package/dist/components/recovery/VerifyCodeStep.js +24 -0
- package/dist/components/reserved/ReservedRecoveryWarning.d.ts +38 -0
- package/dist/components/reserved/ReservedRecoveryWarning.js +92 -0
- package/dist/components/reserved/ReservedStatusBox.d.ts +30 -0
- package/dist/components/reserved/ReservedStatusBox.js +71 -0
- package/dist/components/ui/BetaBadge.d.ts +29 -0
- package/dist/components/ui/BetaBadge.js +38 -0
- package/dist/components/ui/Footer.d.ts +37 -0
- package/dist/components/ui/Footer.js +41 -0
- package/dist/config/env.d.ts +66 -0
- package/dist/config/env.js +57 -0
- package/dist/config/logger.d.ts +57 -0
- package/dist/config/logger.js +73 -0
- package/dist/config/logging-config.d.ts +30 -0
- package/dist/config/logging-config.js +122 -0
- package/dist/config/unauthenticated-routes.d.ts +17 -0
- package/dist/config/unauthenticated-routes.js +24 -0
- package/dist/config/vibe-log-transport.d.ts +81 -0
- package/dist/config/vibe-log-transport.js +212 -0
- package/dist/edge/internal-api-url.d.ts +53 -0
- package/dist/edge/internal-api-url.js +63 -0
- package/dist/edge/middleware.d.ts +14 -0
- package/dist/edge/middleware.js +32 -0
- package/dist/hooks/useAuth.d.ts +23 -0
- package/dist/hooks/useAuth.js +83 -0
- package/dist/hooks/useAuthSettings.d.ts +59 -0
- package/dist/hooks/useAuthSettings.js +93 -0
- package/dist/hooks/useAvailableProviders.d.ts +43 -0
- package/dist/hooks/useAvailableProviders.js +112 -0
- package/dist/hooks/usePasswordValidation.d.ts +27 -0
- package/dist/hooks/usePasswordValidation.js +102 -0
- package/dist/hooks/useProfile.d.ts +15 -0
- package/dist/hooks/useProfile.js +59 -0
- package/dist/hooks/usePublicAuthSettings.d.ts +56 -0
- package/dist/hooks/usePublicAuthSettings.js +131 -0
- package/dist/hooks/useSessionExpiration.d.ts +56 -0
- package/dist/hooks/useSessionExpiration.js +72 -0
- package/dist/hooks/useViabilitySession.d.ts +75 -0
- package/dist/hooks/useViabilitySession.js +269 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +53 -0
- package/dist/lib/anon-session.d.ts +74 -0
- package/dist/lib/anon-session.js +169 -0
- package/dist/lib/api-handler.d.ts +123 -0
- package/dist/lib/api-handler.js +478 -0
- package/dist/lib/app-slug.d.ts +95 -0
- package/dist/lib/app-slug.js +172 -0
- package/dist/lib/demo-mode.d.ts +6 -0
- package/dist/lib/demo-mode.js +16 -0
- package/dist/lib/geolocation.d.ts +64 -0
- package/dist/lib/geolocation.js +235 -0
- package/dist/lib/idp-client-config.d.ts +75 -0
- package/dist/lib/idp-client-config.js +425 -0
- package/dist/lib/idp-fetch.d.ts +14 -0
- package/dist/lib/idp-fetch.js +91 -0
- package/dist/lib/internal-api.d.ts +87 -0
- package/dist/lib/internal-api.js +122 -0
- package/dist/lib/jwt-decode-client.d.ts +10 -0
- package/dist/lib/jwt-decode-client.js +46 -0
- package/dist/lib/jwt-decode.d.ts +48 -0
- package/dist/lib/jwt-decode.js +57 -0
- package/dist/lib/rate-limit-service.d.ts +23 -0
- package/dist/lib/rate-limit-service.js +6 -0
- package/dist/lib/redis.d.ts +5 -0
- package/dist/lib/redis.js +28 -0
- package/dist/lib/refresh-token-validator.d.ts +13 -0
- package/dist/lib/refresh-token-validator.js +117 -0
- package/dist/lib/roles.d.ts +145 -0
- package/dist/lib/roles.js +168 -0
- package/dist/lib/secret-validation.d.ts +4 -0
- package/dist/lib/secret-validation.js +14 -0
- package/dist/lib/session-store.d.ts +170 -0
- package/dist/lib/session-store.js +545 -0
- package/dist/lib/session.d.ts +21 -0
- package/dist/lib/session.js +26 -0
- package/dist/lib/site-logger.d.ts +214 -0
- package/dist/lib/site-logger.js +210 -0
- package/dist/lib/standardized-client-api.d.ts +161 -0
- package/dist/lib/standardized-client-api.js +791 -0
- package/dist/lib/startup-init.d.ts +40 -0
- package/dist/lib/startup-init.js +257 -0
- package/dist/lib/test-aware-get-token.d.ts +2 -0
- package/dist/lib/test-aware-get-token.js +86 -0
- package/dist/lib/token-expiry.d.ts +14 -0
- package/dist/lib/token-expiry.js +39 -0
- package/dist/lib/token-lifecycle.d.ts +78 -0
- package/dist/lib/token-lifecycle.js +360 -0
- package/dist/lib/types/api-responses.d.ts +128 -0
- package/dist/lib/types/api-responses.js +171 -0
- package/dist/lib/user-agent-parser.d.ts +50 -0
- package/dist/lib/user-agent-parser.js +220 -0
- package/dist/logging/api/admin-analytics.d.ts +3 -0
- package/dist/logging/api/admin-analytics.js +45 -0
- package/dist/logging/api/audit-log.d.ts +3 -0
- package/dist/logging/api/audit-log.js +52 -0
- package/dist/logging/components/AdminAnalyticsLayout.d.ts +10 -0
- package/dist/logging/components/AdminAnalyticsLayout.js +11 -0
- package/dist/logging/components/AuditLogViewer.d.ts +7 -0
- package/dist/logging/components/AuditLogViewer.js +51 -0
- package/dist/logging/components/ErrorMetricsCard.d.ts +7 -0
- package/dist/logging/components/ErrorMetricsCard.js +16 -0
- package/dist/logging/components/HealthMetricsCard.d.ts +7 -0
- package/dist/logging/components/HealthMetricsCard.js +19 -0
- package/dist/logging/hooks/useAdminAnalytics.d.ts +24 -0
- package/dist/logging/hooks/useAdminAnalytics.js +22 -0
- package/dist/logging/hooks/useAuditLog.d.ts +6 -0
- package/dist/logging/hooks/useAuditLog.js +25 -0
- package/dist/logging/hooks/useErrorMetrics.d.ts +6 -0
- package/dist/logging/hooks/useErrorMetrics.js +38 -0
- package/dist/logging/hooks/useHealthMetrics.d.ts +6 -0
- package/dist/logging/hooks/useHealthMetrics.js +41 -0
- package/dist/logging/index.d.ts +11 -0
- package/dist/logging/index.js +40 -0
- package/dist/logging/types/analytics.d.ts +68 -0
- package/dist/logging/types/analytics.js +3 -0
- package/dist/logging/types/audit.d.ts +29 -0
- package/dist/logging/types/audit.js +2 -0
- package/dist/logging/types/index.d.ts +2 -0
- package/dist/logging/types/index.js +19 -0
- package/dist/middleware/auth-decision.d.ts +33 -0
- package/dist/middleware/auth-decision.js +65 -0
- package/dist/middleware/create-middleware.d.ts +102 -0
- package/dist/middleware/create-middleware.js +469 -0
- package/dist/middleware/rbac-check.d.ts +51 -0
- package/dist/middleware/rbac-check.js +219 -0
- package/dist/middleware/twofa-presets.d.ts +134 -0
- package/dist/middleware/twofa-presets.js +175 -0
- package/dist/models/DecodedAccessToken.d.ts +17 -0
- package/dist/models/DecodedAccessToken.js +2 -0
- package/dist/models/SessionModel.d.ts +122 -0
- package/dist/models/SessionModel.js +136 -0
- package/dist/pages/admin-login/page.d.ts +31 -0
- package/dist/pages/admin-login/page.js +73 -0
- package/dist/pages/admin-page-permissions/PagePermissionsAdminPage.d.ts +18 -0
- package/dist/pages/admin-page-permissions/PagePermissionsAdminPage.js +276 -0
- package/dist/pages/admin-page-permissions/index.d.ts +6 -0
- package/dist/pages/admin-page-permissions/index.js +13 -0
- package/dist/pages/admin-roles/RolesAdminPage.d.ts +16 -0
- package/dist/pages/admin-roles/RolesAdminPage.js +261 -0
- package/dist/pages/admin-roles/index.d.ts +8 -0
- package/dist/pages/admin-roles/index.js +15 -0
- package/dist/pages/admin-roles/modals.d.ts +72 -0
- package/dist/pages/admin-roles/modals.js +154 -0
- package/dist/pages/client-admin/ClientSiteAdminPage.d.ts +79 -0
- package/dist/pages/client-admin/ClientSiteAdminPage.js +179 -0
- package/dist/pages/client-admin/index.d.ts +32 -0
- package/dist/pages/client-admin/index.js +37 -0
- package/dist/pages/coming-soon/page.d.ts +8 -0
- package/dist/pages/coming-soon/page.js +28 -0
- package/dist/pages/login/page.d.ts +22 -0
- package/dist/pages/login/page.js +230 -0
- package/dist/pages/profile/EnhancedProfilePage.d.ts +13 -0
- package/dist/pages/profile/EnhancedProfilePage.js +150 -0
- package/dist/pages/profile/index.d.ts +8 -0
- package/dist/pages/profile/index.js +16 -0
- package/dist/pages/profile/page.d.ts +19 -0
- package/dist/pages/profile/page.js +47 -0
- package/dist/pages/recovery/page.d.ts +1 -0
- package/dist/pages/recovery/page.js +142 -0
- package/dist/pages/roles/MyRolesPage.d.ts +24 -0
- package/dist/pages/roles/MyRolesPage.js +71 -0
- package/dist/pages/roles/components.d.ts +63 -0
- package/dist/pages/roles/components.js +108 -0
- package/dist/pages/roles/index.d.ts +8 -0
- package/dist/pages/roles/index.js +19 -0
- package/dist/pages/security/EnhancedSecurityPage.d.ts +14 -0
- package/dist/pages/security/EnhancedSecurityPage.js +248 -0
- package/dist/pages/security/index.d.ts +8 -0
- package/dist/pages/security/index.js +16 -0
- package/dist/pages/security/page.d.ts +21 -0
- package/dist/pages/security/page.js +212 -0
- package/dist/pages/settings/EnhancedSettingsPage.d.ts +46 -0
- package/dist/pages/settings/EnhancedSettingsPage.js +231 -0
- package/dist/pages/settings/index.d.ts +8 -0
- package/dist/pages/settings/index.js +16 -0
- package/dist/pages/settings/page.d.ts +7 -0
- package/dist/pages/settings/page.js +26 -0
- package/dist/pages/showcase/ShowcasePage.d.ts +13 -0
- package/dist/pages/showcase/ShowcasePage.js +142 -0
- package/dist/pages/showcase/index.d.ts +12 -0
- package/dist/pages/showcase/index.js +17 -0
- package/dist/pages/test-env/EmergencyLogoutPage.d.ts +14 -0
- package/dist/pages/test-env/EmergencyLogoutPage.js +99 -0
- package/dist/pages/test-env/JwtInspectPage.d.ts +14 -0
- package/dist/pages/test-env/JwtInspectPage.js +116 -0
- package/dist/pages/test-env/RefreshTokenPage.d.ts +15 -0
- package/dist/pages/test-env/RefreshTokenPage.js +93 -0
- package/dist/pages/test-env/TestEnvPage.d.ts +13 -0
- package/dist/pages/test-env/TestEnvPage.js +51 -0
- package/dist/pages/test-env/index.d.ts +24 -0
- package/dist/pages/test-env/index.js +32 -0
- package/dist/pages/verify-code/page.d.ts +30 -0
- package/dist/pages/verify-code/page.js +412 -0
- package/dist/routes/account/index.d.ts +28 -0
- package/dist/routes/account/index.js +71 -0
- package/dist/routes/account/masked-info.d.ts +33 -0
- package/dist/routes/account/masked-info.js +39 -0
- package/dist/routes/account/send-code.d.ts +37 -0
- package/dist/routes/account/send-code.js +42 -0
- package/dist/routes/account/update-phone.d.ts +13 -0
- package/dist/routes/account/update-phone.js +17 -0
- package/dist/routes/account/verify-email.d.ts +38 -0
- package/dist/routes/account/verify-email.js +43 -0
- package/dist/routes/account/verify-sms.d.ts +38 -0
- package/dist/routes/account/verify-sms.js +43 -0
- package/dist/routes/auth/index.d.ts +19 -0
- package/dist/routes/auth/index.js +64 -0
- package/dist/routes/auth/logout.d.ts +31 -0
- package/dist/routes/auth/logout.js +98 -0
- package/dist/routes/auth/nextauth.d.ts +22 -0
- package/dist/routes/auth/nextauth.js +40 -0
- package/dist/routes/auth/refresh.d.ts +30 -0
- package/dist/routes/auth/refresh.js +51 -0
- package/dist/routes/auth/session.d.ts +43 -0
- package/dist/routes/auth/session.js +157 -0
- package/dist/routes/auth/settings.d.ts +25 -0
- package/dist/routes/auth/settings.js +55 -0
- package/dist/routes/auth/viability.d.ts +52 -0
- package/dist/routes/auth/viability.js +190 -0
- package/dist/routes/index.d.ts +12 -0
- package/dist/routes/index.js +54 -0
- package/dist/routes/session/index.d.ts +6 -0
- package/dist/routes/session/index.js +10 -0
- package/dist/routes/session/refresh-viability.d.ts +16 -0
- package/dist/routes/session/refresh-viability.js +20 -0
- package/dist/server/auth-guard.d.ts +46 -0
- package/dist/server/auth-guard.js +128 -0
- package/dist/server/auth.d.ts +50 -0
- package/dist/server/auth.js +62 -0
- package/dist/server/decode-session.d.ts +30 -0
- package/dist/server/decode-session.js +78 -0
- package/dist/server/slim-middleware.d.ts +23 -0
- package/dist/server/slim-middleware.js +89 -0
- package/dist/server/with-auth.d.ts +33 -0
- package/dist/server/with-auth.js +59 -0
- package/dist/services/signalrActivityService.d.ts +44 -0
- package/dist/services/signalrActivityService.js +257 -0
- package/dist/stores/authStore.d.ts +154 -0
- package/dist/stores/authStore.js +1527 -0
- package/dist/theme/ThemeProvider.d.ts +14 -0
- package/dist/theme/ThemeProvider.js +28 -0
- package/dist/theme/default.d.ts +8 -0
- package/dist/theme/default.js +33 -0
- package/dist/theme/index.d.ts +15 -0
- package/dist/theme/index.js +25 -0
- package/dist/theme/types.d.ts +56 -0
- package/dist/theme/types.js +8 -0
- package/dist/theme/useTheme.d.ts +60 -0
- package/dist/theme/useTheme.js +63 -0
- package/dist/theme/utils.d.ts +13 -0
- package/dist/theme/utils.js +39 -0
- package/dist/types/api.d.ts +134 -0
- package/dist/types/api.js +44 -0
- package/dist/types/auth.d.ts +19 -0
- package/dist/types/auth.js +2 -0
- package/dist/types/logging.d.ts +42 -0
- package/dist/types/logging.js +2 -0
- package/dist/types/recovery.d.ts +48 -0
- package/dist/types/recovery.js +2 -0
- package/dist/types/security.d.ts +1 -0
- package/dist/types/security.js +2 -0
- package/dist/utils/api.d.ts +85 -0
- package/dist/utils/api.js +287 -0
- package/dist/utils/circuitBreaker.d.ts +43 -0
- package/dist/utils/circuitBreaker.js +91 -0
- package/dist/utils/error-message.d.ts +1 -0
- package/dist/utils/error-message.js +103 -0
- package/dist/utils/layout/reservedSpace.d.ts +59 -0
- package/dist/utils/layout/reservedSpace.js +102 -0
- package/dist/utils/logout.d.ts +14 -0
- package/dist/utils/logout.js +32 -0
- package/dist/vibe/client.d.ts +261 -0
- package/dist/vibe/client.js +445 -0
- package/dist/vibe/enterprise-auth.d.ts +106 -0
- package/dist/vibe/enterprise-auth.js +173 -0
- package/dist/vibe/errors.d.ts +83 -0
- package/dist/vibe/errors.js +146 -0
- package/dist/vibe/generic.d.ts +234 -0
- package/dist/vibe/generic.js +369 -0
- package/dist/vibe/hooks/index.d.ts +169 -0
- package/dist/vibe/hooks/index.js +252 -0
- package/dist/vibe/index.d.ts +25 -0
- package/dist/vibe/index.js +72 -0
- package/dist/vibe/sessions.d.ts +161 -0
- package/dist/vibe/sessions.js +391 -0
- package/dist/vibe/types.d.ts +353 -0
- package/dist/vibe/types.js +315 -0
- package/package.json +1 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* =============================================================================
|
|
4
|
+
* VIBE ENTERPRISE AUTHENTICATION
|
|
5
|
+
* =============================================================================
|
|
6
|
+
*
|
|
7
|
+
* Server-side HMAC authentication for enterprise/service account requests.
|
|
8
|
+
* Validates incoming requests with X-Vibe-Client-Id, X-Vibe-Timestamp, and
|
|
9
|
+
* X-Vibe-Signature headers.
|
|
10
|
+
*
|
|
11
|
+
* Usage in Next.js API routes:
|
|
12
|
+
* import { validateEnterpriseAuth, hasEnterpriseAuthHeaders } from '@payez/next-mvp/vibe/enterprise-auth'
|
|
13
|
+
*
|
|
14
|
+
* export async function GET(request: NextRequest) {
|
|
15
|
+
* if (hasEnterpriseAuthHeaders(request)) {
|
|
16
|
+
* const auth = await validateEnterpriseAuth(request, ENTERPRISE_CLIENTS);
|
|
17
|
+
* if (!auth.success) {
|
|
18
|
+
* return NextResponse.json({ error: auth.error }, { status: 401 });
|
|
19
|
+
* }
|
|
20
|
+
* // Use auth.clientId for authenticated requests
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* =============================================================================
|
|
25
|
+
*/
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.validateEnterpriseAuth = validateEnterpriseAuth;
|
|
31
|
+
exports.hasEnterpriseAuthHeaders = hasEnterpriseAuthHeaders;
|
|
32
|
+
exports.generateBackendHmacSignature = generateBackendHmacSignature;
|
|
33
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
34
|
+
/**
|
|
35
|
+
* Validates enterprise HMAC authentication headers on incoming requests.
|
|
36
|
+
*
|
|
37
|
+
* Expected headers:
|
|
38
|
+
* - X-Vibe-Client-Id: The client identifier
|
|
39
|
+
* - X-Vibe-Timestamp: Unix timestamp in seconds
|
|
40
|
+
* - X-Vibe-Signature: HMAC-SHA256 signature of "{timestamp}|{method}|{path}"
|
|
41
|
+
*
|
|
42
|
+
* Security features:
|
|
43
|
+
* - Constant-time signature comparison (prevents timing attacks)
|
|
44
|
+
* - Timestamp validation with 5-minute window (prevents replay attacks)
|
|
45
|
+
* - Base64-encoded secret keys
|
|
46
|
+
*
|
|
47
|
+
* @param request - The Next.js request object
|
|
48
|
+
* @param enterpriseClients - Map of client IDs to secret keys
|
|
49
|
+
* @returns Authentication result with success status and client ID
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* const CLIENTS = {
|
|
53
|
+
* 'vibe_abc123': 'base64SecretKey=='
|
|
54
|
+
* };
|
|
55
|
+
* const result = await validateEnterpriseAuth(request, CLIENTS);
|
|
56
|
+
* if (result.success) {
|
|
57
|
+
* console.log(`Authenticated client: ${result.clientId}`);
|
|
58
|
+
* }
|
|
59
|
+
*/
|
|
60
|
+
async function validateEnterpriseAuth(request, enterpriseClients) {
|
|
61
|
+
// Check for required headers
|
|
62
|
+
const clientId = request.headers.get('X-Vibe-Client-Id');
|
|
63
|
+
const timestamp = request.headers.get('X-Vibe-Timestamp');
|
|
64
|
+
const signature = request.headers.get('X-Vibe-Signature');
|
|
65
|
+
// If any header is missing, this is not an enterprise auth request
|
|
66
|
+
if (!clientId || !timestamp || !signature) {
|
|
67
|
+
return {
|
|
68
|
+
success: false,
|
|
69
|
+
error: 'MISSING_ENTERPRISE_HEADERS'
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// Validate client ID exists in configuration
|
|
73
|
+
const secretKey = enterpriseClients[clientId];
|
|
74
|
+
if (!secretKey) {
|
|
75
|
+
return {
|
|
76
|
+
success: false,
|
|
77
|
+
error: 'INVALID_CLIENT_ID'
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// Validate timestamp is recent (within 5 minutes)
|
|
81
|
+
const now = Math.floor(Date.now() / 1000);
|
|
82
|
+
const requestTime = parseInt(timestamp, 10);
|
|
83
|
+
if (isNaN(requestTime)) {
|
|
84
|
+
return {
|
|
85
|
+
success: false,
|
|
86
|
+
error: 'INVALID_TIMESTAMP'
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const timeDiff = Math.abs(now - requestTime);
|
|
90
|
+
if (timeDiff > 300) { // 5 minutes
|
|
91
|
+
return {
|
|
92
|
+
success: false,
|
|
93
|
+
error: 'TIMESTAMP_EXPIRED'
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// Compute expected signature
|
|
97
|
+
// Format: "{timestamp}|{method}|{path}"
|
|
98
|
+
const method = request.method;
|
|
99
|
+
const url = new URL(request.url);
|
|
100
|
+
const path = url.pathname;
|
|
101
|
+
const message = `${timestamp}|${method}|${path}`;
|
|
102
|
+
const expectedSignature = crypto_1.default
|
|
103
|
+
.createHmac('sha256', Buffer.from(secretKey, 'base64'))
|
|
104
|
+
.update(message)
|
|
105
|
+
.digest('base64');
|
|
106
|
+
// Compare signatures (constant-time comparison to prevent timing attacks)
|
|
107
|
+
if (!crypto_1.default.timingSafeEqual(Buffer.from(signature), Buffer.from(expectedSignature))) {
|
|
108
|
+
return {
|
|
109
|
+
success: false,
|
|
110
|
+
error: 'INVALID_SIGNATURE'
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
// Enterprise auth successful
|
|
114
|
+
return {
|
|
115
|
+
success: true,
|
|
116
|
+
clientId
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Checks if request has enterprise authentication headers.
|
|
121
|
+
* Does not validate - just checks if all required headers are present.
|
|
122
|
+
*
|
|
123
|
+
* @param request - The Next.js request object
|
|
124
|
+
* @returns True if all enterprise auth headers are present
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* if (hasEnterpriseAuthHeaders(request)) {
|
|
128
|
+
* // Validate the headers
|
|
129
|
+
* const auth = await validateEnterpriseAuth(request, clients);
|
|
130
|
+
* } else {
|
|
131
|
+
* // Fall back to user session auth
|
|
132
|
+
* const token = await ensureFreshToken(request);
|
|
133
|
+
* }
|
|
134
|
+
*/
|
|
135
|
+
function hasEnterpriseAuthHeaders(request) {
|
|
136
|
+
return !!(request.headers.get('X-Vibe-Client-Id') &&
|
|
137
|
+
request.headers.get('X-Vibe-Timestamp') &&
|
|
138
|
+
request.headers.get('X-Vibe-Signature'));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Generates HMAC signature for backend API requests.
|
|
142
|
+
* Used when frontend needs to proxy enterprise auth requests to backend
|
|
143
|
+
* with a different path (e.g., /api/vibe/* -> /v1/collections/*).
|
|
144
|
+
*
|
|
145
|
+
* @param clientId - The Vibe client ID
|
|
146
|
+
* @param secretKey - Base64-encoded HMAC secret key
|
|
147
|
+
* @param timestamp - Unix timestamp (seconds) as string
|
|
148
|
+
* @param method - HTTP method (GET, POST, etc)
|
|
149
|
+
* @param backendPath - The backend API path (e.g., "/v1/collections/agent_mail/tables")
|
|
150
|
+
* @returns HMAC signature for the backend request
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* // Frontend received request for /api/vibe/agent_mail/tables
|
|
154
|
+
* // Need to call backend at /v1/collections/agent_mail/tables
|
|
155
|
+
* const signature = generateBackendHmacSignature(
|
|
156
|
+
* 'vibe_abc123',
|
|
157
|
+
* 'base64SecretKey==',
|
|
158
|
+
* '1234567890',
|
|
159
|
+
* 'GET',
|
|
160
|
+
* '/v1/collections/agent_mail/tables'
|
|
161
|
+
* );
|
|
162
|
+
* // Use signature in backend request headers
|
|
163
|
+
*/
|
|
164
|
+
function generateBackendHmacSignature(clientId, secretKey, timestamp, method, backendPath) {
|
|
165
|
+
if (!secretKey) {
|
|
166
|
+
throw new Error(`No secret key provided for client ID: ${clientId}`);
|
|
167
|
+
}
|
|
168
|
+
const message = `${timestamp}|${method}|${backendPath}`;
|
|
169
|
+
return crypto_1.default
|
|
170
|
+
.createHmac('sha256', Buffer.from(secretKey, 'base64'))
|
|
171
|
+
.update(message)
|
|
172
|
+
.digest('base64');
|
|
173
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* =============================================================================
|
|
3
|
+
* VIBE API ERROR CLASSES
|
|
4
|
+
* =============================================================================
|
|
5
|
+
*
|
|
6
|
+
* Typed error classes for Vibe API operations.
|
|
7
|
+
* These provide specific error handling for different failure scenarios.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* try {
|
|
11
|
+
* await vibe.users.findUnique({ where: { id: 123 } })
|
|
12
|
+
* } catch (error) {
|
|
13
|
+
* if (error instanceof VibeNotFoundError) {
|
|
14
|
+
* // Handle 404
|
|
15
|
+
* } else if (error instanceof VibeValidationError) {
|
|
16
|
+
* // Handle validation errors
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* =============================================================================
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Base error class for all Vibe API errors
|
|
24
|
+
*/
|
|
25
|
+
export declare class VibeError extends Error {
|
|
26
|
+
readonly code: string;
|
|
27
|
+
readonly status: number;
|
|
28
|
+
readonly details?: Record<string, unknown>;
|
|
29
|
+
constructor(message: string, code: string, status: number, details?: Record<string, unknown>);
|
|
30
|
+
toJSON(): {
|
|
31
|
+
name: string;
|
|
32
|
+
message: string;
|
|
33
|
+
code: string;
|
|
34
|
+
status: number;
|
|
35
|
+
details: Record<string, unknown> | undefined;
|
|
36
|
+
};
|
|
37
|
+
static fromResponse(response: {
|
|
38
|
+
success: false;
|
|
39
|
+
error: {
|
|
40
|
+
code: string;
|
|
41
|
+
message: string;
|
|
42
|
+
details?: Record<string, unknown>;
|
|
43
|
+
};
|
|
44
|
+
}, status: number): VibeError;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Thrown when a requested resource is not found (404)
|
|
48
|
+
*/
|
|
49
|
+
export declare class VibeNotFoundError extends VibeError {
|
|
50
|
+
constructor(message?: string, code?: string, details?: Record<string, unknown>);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Thrown when input validation fails (400)
|
|
54
|
+
*/
|
|
55
|
+
export declare class VibeValidationError extends VibeError {
|
|
56
|
+
readonly fieldErrors?: Record<string, string[]>;
|
|
57
|
+
constructor(message?: string, details?: Record<string, unknown>);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Thrown when authentication/authorization fails (401/403)
|
|
61
|
+
*/
|
|
62
|
+
export declare class VibeAuthError extends VibeError {
|
|
63
|
+
constructor(message?: string, code?: string, details?: Record<string, unknown>);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Thrown when rate limit is exceeded (429)
|
|
67
|
+
*/
|
|
68
|
+
export declare class VibeRateLimitError extends VibeError {
|
|
69
|
+
readonly retryAfter?: number;
|
|
70
|
+
constructor(message?: string, details?: Record<string, unknown>);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Thrown when there's a conflict (e.g., duplicate entry) (409)
|
|
74
|
+
*/
|
|
75
|
+
export declare class VibeConflictError extends VibeError {
|
|
76
|
+
constructor(message?: string, details?: Record<string, unknown>);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Thrown when the Vibe API is unavailable (503)
|
|
80
|
+
*/
|
|
81
|
+
export declare class VibeServiceError extends VibeError {
|
|
82
|
+
constructor(message?: string, details?: Record<string, unknown>);
|
|
83
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* =============================================================================
|
|
4
|
+
* VIBE API ERROR CLASSES
|
|
5
|
+
* =============================================================================
|
|
6
|
+
*
|
|
7
|
+
* Typed error classes for Vibe API operations.
|
|
8
|
+
* These provide specific error handling for different failure scenarios.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* try {
|
|
12
|
+
* await vibe.users.findUnique({ where: { id: 123 } })
|
|
13
|
+
* } catch (error) {
|
|
14
|
+
* if (error instanceof VibeNotFoundError) {
|
|
15
|
+
* // Handle 404
|
|
16
|
+
* } else if (error instanceof VibeValidationError) {
|
|
17
|
+
* // Handle validation errors
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* =============================================================================
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.VibeServiceError = exports.VibeConflictError = exports.VibeRateLimitError = exports.VibeAuthError = exports.VibeValidationError = exports.VibeNotFoundError = exports.VibeError = void 0;
|
|
25
|
+
/**
|
|
26
|
+
* Base error class for all Vibe API errors
|
|
27
|
+
*/
|
|
28
|
+
class VibeError extends Error {
|
|
29
|
+
code;
|
|
30
|
+
status;
|
|
31
|
+
details;
|
|
32
|
+
constructor(message, code, status, details) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.name = 'VibeError';
|
|
35
|
+
this.code = code;
|
|
36
|
+
this.status = status;
|
|
37
|
+
this.details = details;
|
|
38
|
+
// Maintains proper stack trace for where our error was thrown
|
|
39
|
+
if (Error.captureStackTrace) {
|
|
40
|
+
Error.captureStackTrace(this, VibeError);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
toJSON() {
|
|
44
|
+
return {
|
|
45
|
+
name: this.name,
|
|
46
|
+
message: this.message,
|
|
47
|
+
code: this.code,
|
|
48
|
+
status: this.status,
|
|
49
|
+
details: this.details,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
static fromResponse(response, status) {
|
|
53
|
+
const { code, message, details } = response.error;
|
|
54
|
+
switch (code) {
|
|
55
|
+
case 'NOT_FOUND':
|
|
56
|
+
case 'DOCUMENT_NOT_FOUND':
|
|
57
|
+
case 'TABLE_NOT_FOUND':
|
|
58
|
+
return new VibeNotFoundError(message, code, details);
|
|
59
|
+
case 'VALIDATION_ERROR':
|
|
60
|
+
case 'INVALID_INPUT':
|
|
61
|
+
return new VibeValidationError(message, details);
|
|
62
|
+
case 'UNAUTHORIZED':
|
|
63
|
+
case 'INVALID_CREDENTIALS':
|
|
64
|
+
case 'INVALID_CLIENT_ID':
|
|
65
|
+
return new VibeAuthError(message, code, details);
|
|
66
|
+
case 'RATE_LIMITED':
|
|
67
|
+
return new VibeRateLimitError(message, details);
|
|
68
|
+
case 'CONFLICT':
|
|
69
|
+
case 'DUPLICATE_ENTRY':
|
|
70
|
+
return new VibeConflictError(message, details);
|
|
71
|
+
default:
|
|
72
|
+
return new VibeError(message, code, status, details);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.VibeError = VibeError;
|
|
77
|
+
/**
|
|
78
|
+
* Thrown when a requested resource is not found (404)
|
|
79
|
+
*/
|
|
80
|
+
class VibeNotFoundError extends VibeError {
|
|
81
|
+
constructor(message = 'Resource not found', code = 'NOT_FOUND', details) {
|
|
82
|
+
super(message, code, 404, details);
|
|
83
|
+
this.name = 'VibeNotFoundError';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.VibeNotFoundError = VibeNotFoundError;
|
|
87
|
+
/**
|
|
88
|
+
* Thrown when input validation fails (400)
|
|
89
|
+
*/
|
|
90
|
+
class VibeValidationError extends VibeError {
|
|
91
|
+
fieldErrors;
|
|
92
|
+
constructor(message = 'Validation failed', details) {
|
|
93
|
+
super(message, 'VALIDATION_ERROR', 400, details);
|
|
94
|
+
this.name = 'VibeValidationError';
|
|
95
|
+
// Extract field-level errors if present
|
|
96
|
+
if (details?.fieldErrors) {
|
|
97
|
+
this.fieldErrors = details.fieldErrors;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.VibeValidationError = VibeValidationError;
|
|
102
|
+
/**
|
|
103
|
+
* Thrown when authentication/authorization fails (401/403)
|
|
104
|
+
*/
|
|
105
|
+
class VibeAuthError extends VibeError {
|
|
106
|
+
constructor(message = 'Authentication required', code = 'UNAUTHORIZED', details) {
|
|
107
|
+
super(message, code, 401, details);
|
|
108
|
+
this.name = 'VibeAuthError';
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.VibeAuthError = VibeAuthError;
|
|
112
|
+
/**
|
|
113
|
+
* Thrown when rate limit is exceeded (429)
|
|
114
|
+
*/
|
|
115
|
+
class VibeRateLimitError extends VibeError {
|
|
116
|
+
retryAfter;
|
|
117
|
+
constructor(message = 'Rate limit exceeded', details) {
|
|
118
|
+
super(message, 'RATE_LIMITED', 429, details);
|
|
119
|
+
this.name = 'VibeRateLimitError';
|
|
120
|
+
// Extract retry-after if present
|
|
121
|
+
if (details?.retryAfter) {
|
|
122
|
+
this.retryAfter = details.retryAfter;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.VibeRateLimitError = VibeRateLimitError;
|
|
127
|
+
/**
|
|
128
|
+
* Thrown when there's a conflict (e.g., duplicate entry) (409)
|
|
129
|
+
*/
|
|
130
|
+
class VibeConflictError extends VibeError {
|
|
131
|
+
constructor(message = 'Resource conflict', details) {
|
|
132
|
+
super(message, 'CONFLICT', 409, details);
|
|
133
|
+
this.name = 'VibeConflictError';
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.VibeConflictError = VibeConflictError;
|
|
137
|
+
/**
|
|
138
|
+
* Thrown when the Vibe API is unavailable (503)
|
|
139
|
+
*/
|
|
140
|
+
class VibeServiceError extends VibeError {
|
|
141
|
+
constructor(message = 'Vibe service unavailable', details) {
|
|
142
|
+
super(message, 'SERVICE_UNAVAILABLE', 503, details);
|
|
143
|
+
this.name = 'VibeServiceError';
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.VibeServiceError = VibeServiceError;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* =============================================================================
|
|
3
|
+
* VIBE GENERIC CLIENT - DYNAMIC COLLECTION/TABLE ACCESS
|
|
4
|
+
* =============================================================================
|
|
5
|
+
*
|
|
6
|
+
* Provides dynamic access to any Vibe collection and table.
|
|
7
|
+
* Use this when you need to work with tables not predefined in the typed client.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* import { vibeCollection, vibeTablePath, unwrapVibeDocument } from '@payez/next-mvp/vibe'
|
|
11
|
+
*
|
|
12
|
+
* // Dynamic collection access
|
|
13
|
+
* const idealResume = vibeCollection('ideal_resume');
|
|
14
|
+
* const resumes = await idealResume.table('resumes').findMany();
|
|
15
|
+
*
|
|
16
|
+
* // Path builders for custom fetch calls
|
|
17
|
+
* const path = vibeTablePath('ideal_resume', 'resumes', 123);
|
|
18
|
+
* // => '/v1/collections/ideal_resume/tables/resumes/123'
|
|
19
|
+
*
|
|
20
|
+
* // Document unwrapping (Vibe stores data as JSON string in 'data' field)
|
|
21
|
+
* const unwrapped = unwrapVibeDocument(rawDoc);
|
|
22
|
+
*
|
|
23
|
+
* =============================================================================
|
|
24
|
+
*/
|
|
25
|
+
import { VibeClient, VibeClientConfig, FindManyOptions, FindManyResult } from './client';
|
|
26
|
+
/**
|
|
27
|
+
* Build path for collection table operations.
|
|
28
|
+
* @param collection - Collection name (e.g., 'ideal_resume', 'vibe_app')
|
|
29
|
+
* @param table - Table name (e.g., 'resumes', 'users')
|
|
30
|
+
* @param id - Optional document ID
|
|
31
|
+
* @returns API path string
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* vibeTablePath('ideal_resume', 'resumes')
|
|
35
|
+
* // => '/v1/collections/ideal_resume/tables/resumes'
|
|
36
|
+
*
|
|
37
|
+
* vibeTablePath('ideal_resume', 'resumes', 123)
|
|
38
|
+
* // => '/v1/collections/ideal_resume/tables/resumes/123'
|
|
39
|
+
*/
|
|
40
|
+
export declare function vibeTablePath(collection: string, table: string, id?: number): string;
|
|
41
|
+
/**
|
|
42
|
+
* Build path for collection table query endpoint.
|
|
43
|
+
* @param collection - Collection name
|
|
44
|
+
* @param table - Table name
|
|
45
|
+
* @returns Query API path string
|
|
46
|
+
*/
|
|
47
|
+
export declare function vibeQueryPath(collection: string, table: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Build path for collection table grid endpoint.
|
|
50
|
+
* @param collection - Collection name
|
|
51
|
+
* @param table - Table name
|
|
52
|
+
* @returns Grid API path string
|
|
53
|
+
*/
|
|
54
|
+
export declare function vibeGridPath(collection: string, table: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Vibe document wrapper structure.
|
|
57
|
+
* Vibe stores actual table data as JSON string in the 'data' field.
|
|
58
|
+
*/
|
|
59
|
+
export interface VibeDocumentWrapper {
|
|
60
|
+
document_id: number;
|
|
61
|
+
client_id?: number;
|
|
62
|
+
user_id?: number;
|
|
63
|
+
collection?: string;
|
|
64
|
+
table_name?: string;
|
|
65
|
+
data: string | Record<string, unknown>;
|
|
66
|
+
collection_schema_id?: number;
|
|
67
|
+
created_at?: string;
|
|
68
|
+
created_by?: number;
|
|
69
|
+
updated_at?: string | null;
|
|
70
|
+
updated_by?: number | null;
|
|
71
|
+
deleted_at?: string | null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Unwrap a Vibe document response.
|
|
75
|
+
* Vibe returns documents with a wrapper where actual data is a JSON string.
|
|
76
|
+
*
|
|
77
|
+
* @param doc - Raw Vibe document (wrapper format)
|
|
78
|
+
* @returns Unwrapped document with id from document_id, or null if invalid
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* const raw = { document_id: 123, data: '{"name":"John","email":"john@example.com"}' };
|
|
82
|
+
* const unwrapped = unwrapVibeDocument(raw);
|
|
83
|
+
* // => { id: 123, name: 'John', email: 'john@example.com' }
|
|
84
|
+
*/
|
|
85
|
+
export declare function unwrapVibeDocument<T extends Record<string, unknown> = Record<string, unknown>>(doc: VibeDocumentWrapper | Record<string, unknown> | null | undefined): (T & {
|
|
86
|
+
id: number;
|
|
87
|
+
document_id: number;
|
|
88
|
+
}) | null;
|
|
89
|
+
/**
|
|
90
|
+
* Extract and unwrap array of documents from Vibe response.
|
|
91
|
+
*
|
|
92
|
+
* @param responseData - Raw Vibe API response
|
|
93
|
+
* @returns Array of unwrapped documents
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* const response = await fetch('/api/vibe/data/ideal_resume/resumes');
|
|
97
|
+
* const data = await response.json();
|
|
98
|
+
* const resumes = extractVibeDocuments(data);
|
|
99
|
+
*/
|
|
100
|
+
export declare function extractVibeDocuments<T extends Record<string, unknown> = Record<string, unknown>>(responseData: unknown): Array<T & {
|
|
101
|
+
id: number;
|
|
102
|
+
document_id: number;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Generic table delegate for dynamic collection/table access.
|
|
106
|
+
* Provides Prisma-like methods for any table.
|
|
107
|
+
*/
|
|
108
|
+
export declare class GenericTableDelegate<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
109
|
+
private collection;
|
|
110
|
+
private tableName;
|
|
111
|
+
private client;
|
|
112
|
+
constructor(collection: string, tableName: string, client: VibeClient);
|
|
113
|
+
/**
|
|
114
|
+
* Find multiple records with optional filtering and pagination.
|
|
115
|
+
*/
|
|
116
|
+
findMany(options?: FindManyOptions<T>): Promise<FindManyResult<T & {
|
|
117
|
+
id: number;
|
|
118
|
+
document_id: number;
|
|
119
|
+
}>>;
|
|
120
|
+
/**
|
|
121
|
+
* Find a single record by ID.
|
|
122
|
+
* Throws VibeNotFoundError if not found.
|
|
123
|
+
*/
|
|
124
|
+
findUnique(options: {
|
|
125
|
+
where: {
|
|
126
|
+
id: number;
|
|
127
|
+
};
|
|
128
|
+
}): Promise<T & {
|
|
129
|
+
id: number;
|
|
130
|
+
document_id: number;
|
|
131
|
+
}>;
|
|
132
|
+
/**
|
|
133
|
+
* Find a single record by ID, returns null if not found.
|
|
134
|
+
*/
|
|
135
|
+
findUniqueOrNull(options: {
|
|
136
|
+
where: {
|
|
137
|
+
id: number;
|
|
138
|
+
};
|
|
139
|
+
}): Promise<(T & {
|
|
140
|
+
id: number;
|
|
141
|
+
document_id: number;
|
|
142
|
+
}) | null>;
|
|
143
|
+
/**
|
|
144
|
+
* Find the first record matching the filter.
|
|
145
|
+
*/
|
|
146
|
+
findFirst(options?: FindManyOptions<T>): Promise<(T & {
|
|
147
|
+
id: number;
|
|
148
|
+
document_id: number;
|
|
149
|
+
}) | null>;
|
|
150
|
+
/**
|
|
151
|
+
* Create a new record.
|
|
152
|
+
*/
|
|
153
|
+
create(options: {
|
|
154
|
+
data: Partial<T>;
|
|
155
|
+
}): Promise<T & {
|
|
156
|
+
id: number;
|
|
157
|
+
document_id: number;
|
|
158
|
+
}>;
|
|
159
|
+
/**
|
|
160
|
+
* Update an existing record by ID.
|
|
161
|
+
*/
|
|
162
|
+
update(options: {
|
|
163
|
+
where: {
|
|
164
|
+
id: number;
|
|
165
|
+
};
|
|
166
|
+
data: Partial<T>;
|
|
167
|
+
}): Promise<T & {
|
|
168
|
+
id: number;
|
|
169
|
+
document_id: number;
|
|
170
|
+
}>;
|
|
171
|
+
/**
|
|
172
|
+
* Delete a record by ID (soft delete).
|
|
173
|
+
*/
|
|
174
|
+
delete(options: {
|
|
175
|
+
where: {
|
|
176
|
+
id: number;
|
|
177
|
+
};
|
|
178
|
+
}): Promise<T & {
|
|
179
|
+
id: number;
|
|
180
|
+
document_id: number;
|
|
181
|
+
}>;
|
|
182
|
+
/**
|
|
183
|
+
* Count records matching the filter.
|
|
184
|
+
*/
|
|
185
|
+
count(options?: {
|
|
186
|
+
where?: FindManyOptions<T>['where'];
|
|
187
|
+
}): Promise<number>;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Generic collection accessor for dynamic table access.
|
|
191
|
+
*/
|
|
192
|
+
export declare class GenericCollection {
|
|
193
|
+
private collectionName;
|
|
194
|
+
private client;
|
|
195
|
+
constructor(collectionName: string, client: VibeClient);
|
|
196
|
+
/**
|
|
197
|
+
* Get a table delegate for the specified table.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* const idealResume = vibeCollection('ideal_resume');
|
|
201
|
+
* const resumes = await idealResume.table('resumes').findMany();
|
|
202
|
+
*/
|
|
203
|
+
table<T extends Record<string, unknown> = Record<string, unknown>>(tableName: string): GenericTableDelegate<T>;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get a generic collection accessor for dynamic table access.
|
|
207
|
+
*
|
|
208
|
+
* @param collectionName - Name of the collection (e.g., 'ideal_resume', 'vibe_app')
|
|
209
|
+
* @param config - Optional client configuration
|
|
210
|
+
* @returns GenericCollection instance
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* import { vibeCollection } from '@payez/next-mvp/vibe';
|
|
214
|
+
*
|
|
215
|
+
* const idealResume = vibeCollection('ideal_resume');
|
|
216
|
+
* const resumes = await idealResume.table('resumes').findMany({ take: 10 });
|
|
217
|
+
* const resume = await idealResume.table('resumes').findUnique({ where: { id: 123 } });
|
|
218
|
+
*/
|
|
219
|
+
export declare function vibeCollection(collectionName: string, config?: VibeClientConfig): GenericCollection;
|
|
220
|
+
/**
|
|
221
|
+
* Create a generic table delegate directly.
|
|
222
|
+
*
|
|
223
|
+
* @param collection - Collection name
|
|
224
|
+
* @param table - Table name
|
|
225
|
+
* @param config - Optional client configuration
|
|
226
|
+
* @returns GenericTableDelegate instance
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* import { vibeTable } from '@payez/next-mvp/vibe';
|
|
230
|
+
*
|
|
231
|
+
* const resumes = vibeTable('ideal_resume', 'resumes');
|
|
232
|
+
* const allResumes = await resumes.findMany();
|
|
233
|
+
*/
|
|
234
|
+
export declare function vibeTable<T extends Record<string, unknown> = Record<string, unknown>>(collection: string, table: string, config?: VibeClientConfig): GenericTableDelegate<T>;
|