@nextsparkjs/core 0.1.0-beta.188 → 0.1.0-beta.189
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/components/api/keys/ApiKeyDisplay.js +19 -19
- package/dist/components/api/keys/CreateApiKeyDialog.js +21 -21
- package/dist/components/app/layouts/PublicNavbar.d.ts.map +1 -1
- package/dist/components/app/layouts/PublicNavbar.js +34 -16
- package/dist/components/app/misc/ThemeToggle.d.ts.map +1 -1
- package/dist/components/app/misc/ThemeToggle.js +3 -4
- package/dist/components/auth/SessionCookieRefresher.d.ts +5 -0
- package/dist/components/auth/SessionCookieRefresher.d.ts.map +1 -1
- package/dist/components/auth/SessionCookieRefresher.js +7 -1
- package/dist/components/auth/forms/LoginForm.d.ts.map +1 -1
- package/dist/components/auth/forms/LoginForm.js +49 -12
- package/dist/components/auth/forms/SignupForm.d.ts.map +1 -1
- package/dist/components/auth/forms/SignupForm.js +4 -3
- package/dist/components/dashboard/block-editor/block-settings-panel.js +1 -1
- package/dist/components/dashboard/block-editor/floating-block-toolbar.js +1 -1
- package/dist/components/dashboard/block-editor/sortable-block.js +1 -1
- package/dist/components/dashboard/layouts/Sidebar.d.ts.map +1 -1
- package/dist/components/dashboard/layouts/Sidebar.js +8 -6
- package/dist/components/dashboard/layouts/TopNavbar.d.ts.map +1 -1
- package/dist/components/dashboard/layouts/TopNavbar.js +51 -54
- package/dist/components/dashboard/misc/NotificationsDropdown.d.ts.map +1 -1
- package/dist/components/dashboard/misc/NotificationsDropdown.js +17 -15
- package/dist/components/dashboard/misc/SearchDropdown.d.ts.map +1 -1
- package/dist/components/dashboard/misc/SearchDropdown.js +19 -22
- package/dist/components/dashboard/mobile/MobileBottomNav.js +1 -1
- package/dist/components/dashboard/mobile/MobileTopBar.js +2 -2
- package/dist/components/dashboard/navigation/DynamicNavigation.js +5 -5
- package/dist/components/devtools/BlockDetailViewer.js +1 -1
- package/dist/components/devtools/BlocksViewer.js +1 -1
- package/dist/components/entities/EntityChildManager.js +5 -5
- package/dist/components/entities/EntityDetailPage.d.ts.map +1 -1
- package/dist/components/entities/EntityDetailPage.js +16 -15
- package/dist/components/entities/EntityFieldRenderer.d.ts.map +1 -1
- package/dist/components/entities/EntityFieldRenderer.js +12 -7
- package/dist/components/entities/EntityPageHeader.js +5 -5
- package/dist/components/entities/ErrorBoundary.d.ts.map +1 -1
- package/dist/components/entities/ErrorBoundary.js +20 -21
- package/dist/components/entities/wrappers/EntityDetailWrapper.js +5 -5
- package/dist/components/entities/wrappers/EntityFormWrapper.js +2 -2
- package/dist/components/entities/wrappers/EntityListWrapper.js +3 -3
- package/dist/components/permissions/NoPermission.js +10 -10
- package/dist/components/public/pageBuilder/PageRenderer.d.ts.map +1 -1
- package/dist/components/public/pageBuilder/PageRenderer.js +2 -1
- package/dist/components/settings/SettingsPageSkeleton.js +4 -4
- package/dist/components/settings/layouts/SettingsSidebar.js +6 -6
- package/dist/components/shared/MultiSelectFilter.d.ts +3 -1
- package/dist/components/shared/MultiSelectFilter.d.ts.map +1 -1
- package/dist/components/shared/MultiSelectFilter.js +7 -3
- package/dist/components/shared/SearchInput.d.ts +2 -0
- package/dist/components/shared/SearchInput.d.ts.map +1 -1
- package/dist/components/shared/SearchInput.js +64 -6
- package/dist/components/ui/address-input.js +18 -18
- package/dist/components/ui/audio-upload.js +9 -9
- package/dist/components/ui/combobox.d.ts.map +1 -1
- package/dist/components/ui/combobox.js +4 -4
- package/dist/components/ui/country-select.d.ts.map +1 -1
- package/dist/components/ui/country-select.js +3 -3
- package/dist/components/ui/currency-select.d.ts.map +1 -1
- package/dist/components/ui/currency-select.js +3 -3
- package/dist/components/ui/dynamic-icon.d.ts.map +1 -1
- package/dist/components/ui/dynamic-icon.js +3 -2
- package/dist/components/ui/file-upload.js +7 -7
- package/dist/components/ui/image-upload.js +8 -8
- package/dist/components/ui/multi-select.d.ts +2 -1
- package/dist/components/ui/multi-select.d.ts.map +1 -1
- package/dist/components/ui/multi-select.js +4 -3
- package/dist/components/ui/phone-input.d.ts.map +1 -1
- package/dist/components/ui/phone-input.js +3 -3
- package/dist/components/ui/relation-display.js +1 -1
- package/dist/components/ui/simple-relation-select.d.ts +2 -1
- package/dist/components/ui/simple-relation-select.d.ts.map +1 -1
- package/dist/components/ui/simple-relation-select.js +7 -6
- package/dist/components/ui/tags-input.d.ts.map +1 -1
- package/dist/components/ui/tags-input.js +1 -1
- package/dist/components/ui/timezone-select.d.ts.map +1 -1
- package/dist/components/ui/timezone-select.js +3 -3
- package/dist/components/ui/user-display.js +4 -4
- package/dist/components/ui/user-select.d.ts.map +1 -1
- package/dist/components/ui/user-select.js +9 -9
- package/dist/components/ui/video-upload.js +9 -9
- package/dist/contexts/SubscriptionContext.d.ts.map +1 -1
- package/dist/contexts/SubscriptionContext.js +5 -1
- package/dist/contexts/TeamContext.d.ts.map +1 -1
- package/dist/contexts/TeamContext.js +83 -26
- package/dist/emails/otp-verification.d.ts.map +1 -1
- package/dist/emails/otp-verification.js +3 -2
- package/dist/hooks/useAccountPreferencesSync.d.ts +13 -0
- package/dist/hooks/useAccountPreferencesSync.d.ts.map +1 -0
- package/dist/hooks/useAccountPreferencesSync.js +95 -0
- package/dist/hooks/useAuth.d.ts +202 -15
- package/dist/hooks/useAuth.d.ts.map +1 -1
- package/dist/hooks/useAuth.js +49 -13
- package/dist/hooks/useEntityConfig.js +2 -2
- package/dist/hooks/useEntitySearch.js +10 -10
- package/dist/hooks/useNotifications.js +12 -12
- package/dist/hooks/usePrefetch.d.ts.map +1 -1
- package/dist/hooks/usePrefetch.js +6 -2
- package/dist/hooks/useSearch.js +15 -15
- package/dist/hooks/useSessionCookieRefresh.d.ts +18 -1
- package/dist/hooks/useSessionCookieRefresh.d.ts.map +1 -1
- package/dist/hooks/useSessionCookieRefresh.js +17 -4
- package/dist/hooks/useSessionHint.d.ts +12 -0
- package/dist/hooks/useSessionHint.d.ts.map +1 -0
- package/dist/hooks/useSessionHint.js +15 -0
- package/dist/hooks/useTranslationPreload.js +6 -6
- package/dist/i18n.d.ts +13 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +2 -27
- package/dist/lib/actions/entity.actions.d.ts.map +1 -1
- package/dist/lib/actions/entity.actions.js +3 -2
- package/dist/lib/api/auth/dual-auth.d.ts +4 -1
- package/dist/lib/api/auth/dual-auth.d.ts.map +1 -1
- package/dist/lib/api/auth/dual-auth.js +5 -16
- package/dist/lib/api/entities.js +33 -33
- package/dist/lib/api/keys.d.ts +27 -27
- package/dist/lib/api/keys.js +27 -27
- package/dist/lib/auth/callback-url.d.ts +11 -0
- package/dist/lib/auth/callback-url.d.ts.map +1 -0
- package/dist/lib/auth/callback-url.js +14 -0
- package/dist/lib/auth/otp-config.d.ts +55 -0
- package/dist/lib/auth/otp-config.d.ts.map +1 -0
- package/dist/lib/auth/otp-config.js +48 -0
- package/dist/lib/auth/registration-helpers.d.ts.map +1 -1
- package/dist/lib/auth/registration-helpers.js +3 -1
- package/dist/lib/auth/session-hint.d.ts +31 -0
- package/dist/lib/auth/session-hint.d.ts.map +1 -0
- package/dist/lib/auth/session-hint.js +37 -0
- package/dist/lib/auth.d.ts.map +1 -1
- package/dist/lib/auth.js +6 -4
- package/dist/lib/blocks/loader.d.ts +3 -11
- package/dist/lib/blocks/loader.d.ts.map +1 -1
- package/dist/lib/blocks/loader.js +1 -9
- package/dist/lib/blocks/loader.server.d.ts +18 -0
- package/dist/lib/blocks/loader.server.d.ts.map +1 -0
- package/dist/lib/blocks/loader.server.js +11 -0
- package/dist/lib/blocks/sanitize-html.d.ts +31 -0
- package/dist/lib/blocks/sanitize-html.d.ts.map +1 -0
- package/dist/lib/blocks/sanitize-html.js +60 -0
- package/dist/lib/config/config-sync.d.ts +1 -0
- package/dist/lib/config/config-sync.d.ts.map +1 -1
- package/dist/lib/config/config-sync.js +4 -1
- package/dist/lib/config/types.d.ts +48 -0
- package/dist/lib/config/types.d.ts.map +1 -1
- package/dist/lib/email/types.d.ts +6 -0
- package/dist/lib/email/types.d.ts.map +1 -1
- package/dist/lib/entities/serialization.d.ts.map +1 -1
- package/dist/lib/entities/serialization.js +3 -6
- package/dist/lib/icons.d.ts +12 -0
- package/dist/lib/icons.d.ts.map +1 -0
- package/dist/lib/icons.js +30 -0
- package/dist/lib/locale.d.ts +25 -1
- package/dist/lib/locale.d.ts.map +1 -1
- package/dist/lib/locale.js +49 -35
- package/dist/lib/mcp/engine.js +1 -1
- package/dist/lib/mcp/errors.js +17 -17
- package/dist/lib/mcp/schema-builder.js +16 -16
- package/dist/lib/mcp/tool-generator.js +18 -18
- package/dist/lib/search-highlighting.d.ts +7 -0
- package/dist/lib/search-highlighting.d.ts.map +1 -1
- package/dist/lib/search-highlighting.js +6 -2
- package/dist/lib/selectors/core-selectors.d.ts +2 -0
- package/dist/lib/selectors/core-selectors.d.ts.map +1 -1
- package/dist/lib/selectors/domains/auth.selectors.d.ts +1 -0
- package/dist/lib/selectors/domains/auth.selectors.d.ts.map +1 -1
- package/dist/lib/selectors/domains/auth.selectors.js +1 -0
- package/dist/lib/selectors/domains/entities.selectors.d.ts +2 -0
- package/dist/lib/selectors/domains/entities.selectors.d.ts.map +1 -1
- package/dist/lib/selectors/domains/entities.selectors.js +2 -0
- package/dist/lib/selectors/selectors.d.ts +4 -0
- package/dist/lib/selectors/selectors.d.ts.map +1 -1
- package/dist/lib/services/block.service.js +1 -1
- package/dist/lib/teams/active-team-cookie.d.ts +24 -0
- package/dist/lib/teams/active-team-cookie.d.ts.map +1 -0
- package/dist/lib/teams/active-team-cookie.js +17 -0
- package/dist/lib/teams/dashboard-team.d.ts +20 -0
- package/dist/lib/teams/dashboard-team.d.ts.map +1 -0
- package/dist/lib/teams/dashboard-team.js +38 -0
- package/dist/lib/teams/schema.d.ts.map +1 -1
- package/dist/lib/teams/schema.js +1 -1
- package/dist/lib/template-resolver.d.ts.map +1 -1
- package/dist/lib/template-resolver.js +0 -1
- package/dist/lib/theme/get-default-theme-mode.d.ts +7 -4
- package/dist/lib/theme/get-default-theme-mode.d.ts.map +1 -1
- package/dist/lib/theme/get-default-theme-mode.js +2 -44
- package/dist/messages/de/auth.json +4 -2
- package/dist/messages/de/common.json +83 -3
- package/dist/messages/de/email.json +1 -1
- package/dist/messages/de/index.d.ts +87 -0
- package/dist/messages/de/index.d.ts.map +1 -1
- package/dist/messages/de/settings.json +5 -0
- package/dist/messages/en/auth.json +4 -2
- package/dist/messages/en/common.json +83 -3
- package/dist/messages/en/email.json +1 -1
- package/dist/messages/en/index.d.ts +86 -0
- package/dist/messages/en/index.d.ts.map +1 -1
- package/dist/messages/en/settings.json +4 -0
- package/dist/messages/es/auth.json +4 -2
- package/dist/messages/es/common.json +83 -3
- package/dist/messages/es/email.json +1 -1
- package/dist/messages/es/index.d.ts +86 -0
- package/dist/messages/es/index.d.ts.map +1 -1
- package/dist/messages/es/settings.json +4 -0
- package/dist/messages/fr/auth.json +4 -2
- package/dist/messages/fr/common.json +83 -3
- package/dist/messages/fr/email.json +1 -1
- package/dist/messages/fr/index.d.ts +87 -0
- package/dist/messages/fr/index.d.ts.map +1 -1
- package/dist/messages/fr/settings.json +5 -0
- package/dist/messages/it/auth.json +4 -2
- package/dist/messages/it/common.json +83 -3
- package/dist/messages/it/email.json +1 -1
- package/dist/messages/it/index.d.ts +87 -0
- package/dist/messages/it/index.d.ts.map +1 -1
- package/dist/messages/it/settings.json +5 -0
- package/dist/messages/pt/auth.json +4 -2
- package/dist/messages/pt/common.json +83 -3
- package/dist/messages/pt/email.json +1 -1
- package/dist/messages/pt/index.d.ts +87 -0
- package/dist/messages/pt/index.d.ts.map +1 -1
- package/dist/messages/pt/settings.json +5 -0
- package/dist/nextspark-registries.d.ts +54 -0
- package/dist/providers/DashboardProviders.d.ts +13 -10
- package/dist/providers/DashboardProviders.d.ts.map +1 -1
- package/dist/providers/DashboardProviders.js +7 -1
- package/dist/templates/app/(auth)/forgot-password/page.tsx +2 -2
- package/dist/templates/app/(auth)/reset-password/page.tsx +6 -6
- package/dist/templates/app/403/page.tsx +6 -6
- package/dist/templates/app/api/v1/teams/switch/route.ts +24 -5
- package/dist/templates/app/dashboard/(main)/[entity]/layout.tsx +9 -7
- package/dist/templates/app/dashboard/(main)/layout.tsx +4 -3
- package/dist/templates/app/dashboard/settings/api-keys/page.tsx +36 -34
- package/dist/templates/app/dashboard/settings/profile/page.tsx +7 -6
- package/dist/templates/app/dashboard/settings/security/page.tsx +5 -4
- package/dist/templates/app/layout.ppr.tsx +8 -8
- package/dist/templates/app/layout.tsx +12 -17
- package/dist/templates/blocks/cta-section/component.tsx +5 -2
- package/dist/templates/blocks/cta-section/config.ts +3 -2
- package/dist/templates/blocks/cta-section/fields.ts +2 -2
- package/dist/templates/blocks/cta-section/schema.ts +2 -2
- package/dist/templates/blocks/features-grid/component.tsx +10 -2
- package/dist/templates/blocks/features-grid/config.ts +3 -2
- package/dist/templates/blocks/features-grid/fields.ts +2 -2
- package/dist/templates/blocks/features-grid/schema.ts +2 -2
- package/dist/templates/blocks/hero/component.tsx +6 -3
- package/dist/templates/blocks/hero/config.ts +3 -2
- package/dist/templates/blocks/hero/fields.ts +2 -2
- package/dist/templates/blocks/hero/schema.ts +2 -2
- package/dist/templates/blocks/testimonials/component.tsx +6 -3
- package/dist/templates/blocks/testimonials/config.ts +3 -2
- package/dist/templates/blocks/testimonials/fields.ts +2 -2
- package/dist/templates/blocks/testimonials/schema.ts +2 -2
- package/dist/templates/blocks/text-content/component.tsx +7 -3
- package/dist/templates/blocks/text-content/config.ts +3 -2
- package/dist/templates/blocks/text-content/fields.ts +2 -2
- package/dist/templates/blocks/text-content/schema.ts +2 -2
- package/dist/templates/contents/themes/starter/blocks/cta-section/component.tsx +102 -0
- package/dist/templates/contents/themes/starter/blocks/cta-section/config.ts +11 -0
- package/dist/templates/contents/themes/starter/blocks/cta-section/fields.ts +89 -0
- package/dist/templates/contents/themes/starter/blocks/cta-section/index.ts +6 -0
- package/dist/templates/contents/themes/starter/blocks/cta-section/schema.ts +32 -0
- package/dist/templates/contents/themes/starter/blocks/cta-section/thumbnail.png +0 -0
- package/dist/templates/contents/themes/starter/blocks/features-grid/component.tsx +119 -0
- package/dist/templates/contents/themes/starter/blocks/features-grid/config.ts +11 -0
- package/dist/templates/contents/themes/starter/blocks/features-grid/fields.ts +97 -0
- package/dist/templates/contents/themes/starter/blocks/features-grid/index.ts +6 -0
- package/dist/templates/contents/themes/starter/blocks/features-grid/schema.ts +40 -0
- package/dist/templates/contents/themes/starter/blocks/features-grid/thumbnail.png +0 -0
- package/dist/templates/contents/themes/starter/blocks/hero/component.tsx +105 -0
- package/dist/templates/contents/themes/starter/blocks/hero/config.ts +11 -0
- package/dist/templates/contents/themes/starter/blocks/hero/fields.ts +60 -0
- package/dist/templates/contents/themes/starter/blocks/hero/index.ts +6 -0
- package/dist/templates/contents/themes/starter/blocks/hero/schema.ts +33 -0
- package/dist/templates/contents/themes/starter/blocks/hero/thumbnail.png +0 -0
- package/dist/templates/contents/themes/starter/blocks/testimonials/component.tsx +116 -0
- package/dist/templates/contents/themes/starter/blocks/testimonials/config.ts +11 -0
- package/dist/templates/contents/themes/starter/blocks/testimonials/fields.ts +105 -0
- package/dist/templates/contents/themes/starter/blocks/testimonials/index.ts +6 -0
- package/dist/templates/contents/themes/starter/blocks/testimonials/schema.ts +41 -0
- package/dist/templates/contents/themes/starter/blocks/testimonials/thumbnail.png +0 -0
- package/dist/templates/contents/themes/starter/blocks/text-content/component.tsx +100 -0
- package/dist/templates/contents/themes/starter/blocks/text-content/config.ts +11 -0
- package/dist/templates/contents/themes/starter/blocks/text-content/fields.ts +88 -0
- package/dist/templates/contents/themes/starter/blocks/text-content/index.ts +6 -0
- package/dist/templates/contents/themes/starter/blocks/text-content/schema.ts +30 -0
- package/dist/templates/contents/themes/starter/blocks/text-content/thumbnail.png +0 -0
- package/dist/templates/contents/themes/starter/config/app.config.ts +8 -0
- package/dist/templates/contents/themes/starter/entities/tasks/tasks.config.ts +7 -0
- package/dist/templates/contents/themes/starter/tests/cypress/e2e/_utils/devtools/access.cy.ts +9 -1
- package/dist/templates/contents/themes/starter/tests/cypress/e2e/api/entities/tasks/TaskAPIController.js +2 -2
- package/dist/templates/contents/themes/starter/tests/cypress/e2e/uat/entities/tasks/tasks-crud.cy.ts +45 -38
- package/dist/templates/contents/themes/starter/tests/cypress/fixtures/entities.json +16 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/components/DevKeyringPOM.ts +3 -1
- package/dist/templates/contents/themes/starter/tests/cypress/src/core/BlockEditorBasePOM.ts +3 -3
- package/dist/templates/contents/themes/starter/tests/cypress/src/entities/PagesPOM.ts +137 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/entities/index.ts +2 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/index.ts +1 -0
- package/dist/templates/contents/themes/starter/tests/cypress/src/session-helpers.ts +42 -11
- package/dist/templates/contents/themes/starter/tests/cypress/support/commands.ts +29 -18
- package/dist/templates/features/blog/blocks/post-content/component.tsx +5 -1
- package/dist/templates/features/blog/blocks/post-content/schema.ts +1 -1
- package/dist/templates/features/pages/blocks/hero/component.tsx +3 -0
- package/dist/templates/features/pages/blocks/hero/schema.ts +1 -1
- package/dist/templates/proxy.ts +138 -53
- package/dist/types/blocks.d.ts.map +1 -1
- package/dist/types/blocks.js +1 -1
- package/dist/types/task.types.d.ts +1 -1
- package/dist/types/task.types.js +7 -7
- package/dist/utils/dev/TranslationDebugger.js +2 -2
- package/package.json +14 -5
- package/scripts/build/registry/__tests__/block-registry.test.mjs +73 -0
- package/scripts/build/registry/__tests__/icons-discovery.test.mjs +130 -0
- package/scripts/build/registry/__tests__/identifier.test.mjs +65 -0
- package/scripts/build/registry/__tests__/page-generator.test.mjs +430 -0
- package/scripts/build/registry/__tests__/scheduled-actions-registry.test.mjs +41 -0
- package/scripts/build/registry/__tests__/template-registry.test.mjs +89 -0
- package/scripts/build/registry/discovery/icons.mjs +275 -0
- package/scripts/build/registry/discovery/index.mjs +1 -0
- package/scripts/build/registry/generators/block-registry.mjs +203 -55
- package/scripts/build/registry/generators/feature-registry.mjs +9 -2
- package/scripts/build/registry/generators/icon-registry.mjs +56 -0
- package/scripts/build/registry/generators/identifier.mjs +28 -0
- package/scripts/build/registry/generators/index.mjs +1 -0
- package/scripts/build/registry/generators/plugin-registry.mjs +4 -3
- package/scripts/build/registry/generators/scheduled-actions-registry.mjs +4 -2
- package/scripts/build/registry/generators/template-registry.mjs +49 -41
- package/scripts/build/registry/generators/theme-registry.mjs +6 -7
- package/scripts/build/registry/post-build/page-generator.mjs +380 -59
- package/scripts/build/registry.mjs +9 -1
- package/templates/app/(auth)/forgot-password/page.tsx +2 -2
- package/templates/app/(auth)/reset-password/page.tsx +6 -6
- package/templates/app/403/page.tsx +6 -6
- package/templates/app/api/v1/teams/switch/route.ts +24 -5
- package/templates/app/dashboard/(main)/[entity]/layout.tsx +9 -7
- package/templates/app/dashboard/(main)/layout.tsx +4 -3
- package/templates/app/dashboard/settings/api-keys/page.tsx +36 -34
- package/templates/app/dashboard/settings/profile/page.tsx +7 -6
- package/templates/app/dashboard/settings/security/page.tsx +5 -4
- package/templates/app/layout.ppr.tsx +8 -8
- package/templates/app/layout.tsx +12 -17
- package/templates/blocks/cta-section/component.tsx +5 -2
- package/templates/blocks/cta-section/config.ts +3 -2
- package/templates/blocks/cta-section/fields.ts +2 -2
- package/templates/blocks/cta-section/schema.ts +2 -2
- package/templates/blocks/features-grid/component.tsx +10 -2
- package/templates/blocks/features-grid/config.ts +3 -2
- package/templates/blocks/features-grid/fields.ts +2 -2
- package/templates/blocks/features-grid/schema.ts +2 -2
- package/templates/blocks/hero/component.tsx +6 -3
- package/templates/blocks/hero/config.ts +3 -2
- package/templates/blocks/hero/fields.ts +2 -2
- package/templates/blocks/hero/schema.ts +2 -2
- package/templates/blocks/testimonials/component.tsx +6 -3
- package/templates/blocks/testimonials/config.ts +3 -2
- package/templates/blocks/testimonials/fields.ts +2 -2
- package/templates/blocks/testimonials/schema.ts +2 -2
- package/templates/blocks/text-content/component.tsx +7 -3
- package/templates/blocks/text-content/config.ts +3 -2
- package/templates/blocks/text-content/fields.ts +2 -2
- package/templates/blocks/text-content/schema.ts +2 -2
- package/templates/contents/themes/starter/blocks/cta-section/component.tsx +102 -0
- package/templates/contents/themes/starter/blocks/cta-section/config.ts +11 -0
- package/templates/contents/themes/starter/blocks/cta-section/fields.ts +89 -0
- package/templates/contents/themes/starter/blocks/cta-section/index.ts +6 -0
- package/templates/contents/themes/starter/blocks/cta-section/schema.ts +32 -0
- package/templates/contents/themes/starter/blocks/cta-section/thumbnail.png +0 -0
- package/templates/contents/themes/starter/blocks/features-grid/component.tsx +119 -0
- package/templates/contents/themes/starter/blocks/features-grid/config.ts +11 -0
- package/templates/contents/themes/starter/blocks/features-grid/fields.ts +97 -0
- package/templates/contents/themes/starter/blocks/features-grid/index.ts +6 -0
- package/templates/contents/themes/starter/blocks/features-grid/schema.ts +40 -0
- package/templates/contents/themes/starter/blocks/features-grid/thumbnail.png +0 -0
- package/templates/contents/themes/starter/blocks/hero/component.tsx +105 -0
- package/templates/contents/themes/starter/blocks/hero/config.ts +11 -0
- package/templates/contents/themes/starter/blocks/hero/fields.ts +60 -0
- package/templates/contents/themes/starter/blocks/hero/index.ts +6 -0
- package/templates/contents/themes/starter/blocks/hero/schema.ts +33 -0
- package/templates/contents/themes/starter/blocks/hero/thumbnail.png +0 -0
- package/templates/contents/themes/starter/blocks/testimonials/component.tsx +116 -0
- package/templates/contents/themes/starter/blocks/testimonials/config.ts +11 -0
- package/templates/contents/themes/starter/blocks/testimonials/fields.ts +105 -0
- package/templates/contents/themes/starter/blocks/testimonials/index.ts +6 -0
- package/templates/contents/themes/starter/blocks/testimonials/schema.ts +41 -0
- package/templates/contents/themes/starter/blocks/testimonials/thumbnail.png +0 -0
- package/templates/contents/themes/starter/blocks/text-content/component.tsx +100 -0
- package/templates/contents/themes/starter/blocks/text-content/config.ts +11 -0
- package/templates/contents/themes/starter/blocks/text-content/fields.ts +88 -0
- package/templates/contents/themes/starter/blocks/text-content/index.ts +6 -0
- package/templates/contents/themes/starter/blocks/text-content/schema.ts +30 -0
- package/templates/contents/themes/starter/blocks/text-content/thumbnail.png +0 -0
- package/templates/contents/themes/starter/config/app.config.ts +8 -0
- package/templates/contents/themes/starter/entities/tasks/tasks.config.ts +7 -0
- package/templates/contents/themes/starter/tests/cypress/e2e/_utils/devtools/access.cy.ts +9 -1
- package/templates/contents/themes/starter/tests/cypress/e2e/api/entities/tasks/TaskAPIController.js +2 -2
- package/templates/contents/themes/starter/tests/cypress/e2e/uat/entities/tasks/tasks-crud.cy.ts +45 -38
- package/templates/contents/themes/starter/tests/cypress/fixtures/entities.json +16 -0
- package/templates/contents/themes/starter/tests/cypress/src/components/DevKeyringPOM.ts +3 -1
- package/templates/contents/themes/starter/tests/cypress/src/core/BlockEditorBasePOM.ts +3 -3
- package/templates/contents/themes/starter/tests/cypress/src/entities/PagesPOM.ts +137 -0
- package/templates/contents/themes/starter/tests/cypress/src/entities/index.ts +2 -0
- package/templates/contents/themes/starter/tests/cypress/src/index.ts +1 -0
- package/templates/contents/themes/starter/tests/cypress/src/session-helpers.ts +42 -11
- package/templates/contents/themes/starter/tests/cypress/support/commands.ts +29 -18
- package/templates/features/blog/blocks/post-content/component.tsx +5 -1
- package/templates/features/blog/blocks/post-content/schema.ts +1 -1
- package/templates/features/pages/blocks/hero/component.tsx +3 -0
- package/templates/features/pages/blocks/hero/schema.ts +1 -1
- package/templates/proxy.ts +138 -53
- package/tests/jest/__mocks__/@nextsparkjs/registries/block-registry.client.ts +9 -0
- package/tests/jest/__mocks__/@nextsparkjs/registries/block-registry.lazy.ts +5 -0
- package/tests/jest/__mocks__/@nextsparkjs/registries/icon-registry.ts +42 -0
- package/tests/jest/__mocks__/next-intl-server.js +85 -5
- package/tests/jest/__mocks__/next-server.js +32 -0
|
@@ -9,13 +9,69 @@ import { APP_CONFIG_MERGED } from "../lib/config/config-sync.js";
|
|
|
9
9
|
import { canUserCreateTeam } from "../lib/teams/helpers.js";
|
|
10
10
|
const TeamContext = createContext(void 0);
|
|
11
11
|
const TEAMS_QUERY_KEY = ["user-teams"];
|
|
12
|
+
const activeTeamCookieWrites = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
const activeTeamCookieRequests = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
const ACTIVE_TEAM_COOKIE_RETRIES = 3;
|
|
15
|
+
const ACTIVE_TEAM_REQUEST_TIMEOUT_MS = 1e4;
|
|
16
|
+
function postActiveTeam(teamId) {
|
|
17
|
+
const controller = new AbortController();
|
|
18
|
+
const timeout = setTimeout(() => controller.abort(), ACTIVE_TEAM_REQUEST_TIMEOUT_MS);
|
|
19
|
+
return fetch("/api/v1/teams/switch", {
|
|
20
|
+
method: "POST",
|
|
21
|
+
headers: { "Content-Type": "application/json" },
|
|
22
|
+
body: JSON.stringify({ teamId }),
|
|
23
|
+
signal: controller.signal
|
|
24
|
+
}).then((response) => response.ok, (error) => {
|
|
25
|
+
console.error("Failed to sync team cookie:", error);
|
|
26
|
+
return false;
|
|
27
|
+
}).finally(() => clearTimeout(timeout));
|
|
28
|
+
}
|
|
29
|
+
function writeActiveTeamCookie(queryClient, sessionKey, teamId) {
|
|
30
|
+
const key = `${sessionKey}:${teamId}`;
|
|
31
|
+
const previous = activeTeamCookieWrites.get(queryClient);
|
|
32
|
+
if ((previous == null ? void 0 : previous.key) === key && !previous.failed) return previous.result;
|
|
33
|
+
clearTimeout(previous == null ? void 0 : previous.retryTimer);
|
|
34
|
+
const write = { key, failed: false, result: Promise.resolve(false) };
|
|
35
|
+
const isCurrent = () => activeTeamCookieWrites.get(queryClient) === write;
|
|
36
|
+
const attempt = (retry) => {
|
|
37
|
+
const request = (activeTeamCookieRequests.get(queryClient) ?? Promise.resolve()).then(() => isCurrent() ? postActiveTeam(teamId) : false);
|
|
38
|
+
activeTeamCookieRequests.set(queryClient, request);
|
|
39
|
+
return request.then((ok) => {
|
|
40
|
+
if (ok || !isCurrent()) return ok;
|
|
41
|
+
if (retry >= ACTIVE_TEAM_COOKIE_RETRIES) {
|
|
42
|
+
write.failed = true;
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return new Promise((resolve) => {
|
|
46
|
+
write.retryTimer = setTimeout(() => resolve(attempt(retry + 1)), 1e3 * (retry + 1));
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
activeTeamCookieWrites.set(queryClient, write);
|
|
51
|
+
write.result = attempt(0);
|
|
52
|
+
return write.result;
|
|
53
|
+
}
|
|
54
|
+
function forgetActiveTeamCookieWrite(queryClient) {
|
|
55
|
+
var _a;
|
|
56
|
+
clearTimeout((_a = activeTeamCookieWrites.get(queryClient)) == null ? void 0 : _a.retryTimer);
|
|
57
|
+
activeTeamCookieWrites.delete(queryClient);
|
|
58
|
+
}
|
|
59
|
+
const MAX_TEAM_PAGES = 50;
|
|
12
60
|
async function fetchUserTeams() {
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
61
|
+
var _a;
|
|
62
|
+
const rows = [];
|
|
63
|
+
for (let page = 1; page <= MAX_TEAM_PAGES; page++) {
|
|
64
|
+
const response = await fetch(page === 1 ? "/api/v1/teams" : `/api/v1/teams?page=${page}`);
|
|
65
|
+
const data = await response.json();
|
|
66
|
+
if (!response.ok || !data.data) {
|
|
67
|
+
throw new Error("Failed to fetch teams");
|
|
68
|
+
}
|
|
69
|
+
rows.push(...data.data);
|
|
70
|
+
if (!((_a = data.info) == null ? void 0 : _a.hasNextPage) || data.data.length === 0) break;
|
|
17
71
|
}
|
|
18
|
-
|
|
72
|
+
const seen = /* @__PURE__ */ new Set();
|
|
73
|
+
const uniqueRows = rows.filter((t) => !seen.has(t.id) && Boolean(seen.add(t.id)));
|
|
74
|
+
return uniqueRows.map((t) => ({
|
|
19
75
|
team: {
|
|
20
76
|
id: t.id,
|
|
21
77
|
name: t.name,
|
|
@@ -32,7 +88,9 @@ async function fetchUserTeams() {
|
|
|
32
88
|
}));
|
|
33
89
|
}
|
|
34
90
|
function TeamProvider({ children }) {
|
|
35
|
-
|
|
91
|
+
var _a;
|
|
92
|
+
const { user, session, isLoading: authLoading } = useAuth();
|
|
93
|
+
const sessionKey = ((_a = session == null ? void 0 : session.session) == null ? void 0 : _a.id) ?? (user == null ? void 0 : user.id) ?? "";
|
|
36
94
|
const router = useRouter();
|
|
37
95
|
const queryClient = useQueryClient();
|
|
38
96
|
const [currentTeam, setCurrentTeam] = useState(null);
|
|
@@ -45,7 +103,9 @@ function TeamProvider({ children }) {
|
|
|
45
103
|
isLoading: teamsLoading,
|
|
46
104
|
refetch: refetchTeams
|
|
47
105
|
} = useQuery({
|
|
48
|
-
|
|
106
|
+
// Per user: the root layout's query client outlives a sign-out that happens
|
|
107
|
+
// while no TeamProvider is mounted, and one user's teams must not reach the next.
|
|
108
|
+
queryKey: [...TEAMS_QUERY_KEY, (user == null ? void 0 : user.id) ?? null],
|
|
49
109
|
queryFn: fetchUserTeams,
|
|
50
110
|
enabled: !!user && !authLoading,
|
|
51
111
|
staleTime: 1e3 * 60 * 5,
|
|
@@ -69,6 +129,9 @@ function TeamProvider({ children }) {
|
|
|
69
129
|
}, [userTeams, user]);
|
|
70
130
|
useEffect(() => {
|
|
71
131
|
if (!user) return;
|
|
132
|
+
const syncCookie = (teamId) => {
|
|
133
|
+
if (typeof window !== "undefined") void writeActiveTeamCookie(queryClient, sessionKey, teamId);
|
|
134
|
+
};
|
|
72
135
|
if (!teamsLoading && userTeams.length === 0) {
|
|
73
136
|
if (currentTeam) {
|
|
74
137
|
setCurrentTeam(null);
|
|
@@ -79,7 +142,10 @@ function TeamProvider({ children }) {
|
|
|
79
142
|
return;
|
|
80
143
|
}
|
|
81
144
|
if (!userTeams.length) return;
|
|
82
|
-
if (currentTeam && userTeams.some((t) => t.team.id === currentTeam.id))
|
|
145
|
+
if (currentTeam && userTeams.some((t) => t.team.id === currentTeam.id)) {
|
|
146
|
+
syncCookie(currentTeam.id);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
83
149
|
const storedTeamId = typeof window !== "undefined" ? localStorage.getItem("activeTeamId") : null;
|
|
84
150
|
const storedTeam = storedTeamId ? userTeams.find((t) => t.team.id === storedTeamId) : null;
|
|
85
151
|
const defaultTeam = storedTeam ? void 0 : [...userTeams].sort(
|
|
@@ -91,27 +157,24 @@ function TeamProvider({ children }) {
|
|
|
91
157
|
if (typeof window !== "undefined") {
|
|
92
158
|
localStorage.setItem("activeTeamId", activeTeam.team.id);
|
|
93
159
|
}
|
|
94
|
-
|
|
95
|
-
fetch("/api/v1/teams/switch", {
|
|
96
|
-
method: "POST",
|
|
97
|
-
headers: { "Content-Type": "application/json" },
|
|
98
|
-
body: JSON.stringify({ teamId: activeTeam.team.id })
|
|
99
|
-
}).catch((err) => console.error("Failed to sync team cookie:", err));
|
|
100
|
-
}
|
|
160
|
+
syncCookie(activeTeam.team.id);
|
|
101
161
|
}
|
|
102
|
-
}, [user, userTeams, currentTeam, teamsLoading]);
|
|
162
|
+
}, [user, userTeams, currentTeam, teamsLoading, queryClient, sessionKey]);
|
|
103
163
|
useEffect(() => {
|
|
104
164
|
if (!user && !authLoading) {
|
|
105
165
|
setCurrentTeam(null);
|
|
106
166
|
if (typeof window !== "undefined") {
|
|
107
167
|
localStorage.removeItem("activeTeamId");
|
|
108
168
|
}
|
|
169
|
+
forgetActiveTeamCookieWrite(queryClient);
|
|
109
170
|
queryClient.clear();
|
|
110
171
|
}
|
|
111
172
|
}, [user, authLoading, queryClient]);
|
|
112
|
-
const handleSwitchComplete = useCallback(() => {
|
|
173
|
+
const handleSwitchComplete = useCallback(async () => {
|
|
174
|
+
var _a2;
|
|
113
175
|
setSwitchModalOpen(false);
|
|
114
176
|
setIsSwitching(false);
|
|
177
|
+
await ((_a2 = activeTeamCookieWrites.get(queryClient)) == null ? void 0 : _a2.result);
|
|
115
178
|
queryClient.clear();
|
|
116
179
|
if (typeof window !== "undefined") {
|
|
117
180
|
window.dispatchEvent(new CustomEvent("team-switched", { detail: { teamId: targetTeam == null ? void 0 : targetTeam.id } }));
|
|
@@ -136,16 +199,10 @@ function TeamProvider({ children }) {
|
|
|
136
199
|
if (typeof window !== "undefined") {
|
|
137
200
|
localStorage.setItem("activeTeamId", teamId);
|
|
138
201
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
method: "POST",
|
|
142
|
-
headers: { "Content-Type": "application/json" },
|
|
143
|
-
body: JSON.stringify({ teamId })
|
|
144
|
-
});
|
|
145
|
-
} catch (error) {
|
|
146
|
-
console.error("Failed to update team context on server:", error);
|
|
202
|
+
if (!await writeActiveTeamCookie(queryClient, sessionKey, teamId)) {
|
|
203
|
+
console.error("Failed to update team context on server");
|
|
147
204
|
}
|
|
148
|
-
}, [userTeams, currentTeam]);
|
|
205
|
+
}, [userTeams, currentTeam, queryClient, sessionKey]);
|
|
149
206
|
const refreshTeams = useCallback(async () => {
|
|
150
207
|
await queryClient.invalidateQueries({ queryKey: TEAMS_QUERY_KEY });
|
|
151
208
|
await refetchTeams();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp-verification.d.ts","sourceRoot":"","sources":["../../src/emails/otp-verification.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAKjF,wBAA8B,eAAe,CAC3C,IAAI,EAAE,wBAAwB,EAC9B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"otp-verification.d.ts","sourceRoot":"","sources":["../../src/emails/otp-verification.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAKjF,wBAA8B,eAAe,CAC3C,IAAI,EAAE,wBAAwB,EAC9B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,YAAY,CAAC,CAsEvB"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { getTranslations } from "next-intl/server";
|
|
2
|
+
import { DEFAULT_OTP_CONFIG } from "../lib/auth/otp-config.js";
|
|
2
3
|
const APP_NAME_FALLBACK = process.env.NEXT_PUBLIC_APP_NAME || "Your App";
|
|
3
|
-
const OTP_EXPIRES_MINUTES = 5;
|
|
4
4
|
async function otpVerification(data, locale) {
|
|
5
5
|
const t = await getTranslations({ locale, namespace: "email.otpVerification" });
|
|
6
6
|
const appName = data.appName || APP_NAME_FALLBACK;
|
|
7
7
|
const year = (/* @__PURE__ */ new Date()).getFullYear();
|
|
8
|
+
const expiresInMinutes = Math.floor((data.expiresIn ?? DEFAULT_OTP_CONFIG.expiresIn) / 60);
|
|
8
9
|
return {
|
|
9
10
|
subject: t("subject", { otp: data.otp, appName }),
|
|
10
11
|
html: `
|
|
@@ -41,7 +42,7 @@ async function otpVerification(data, locale) {
|
|
|
41
42
|
</div>
|
|
42
43
|
|
|
43
44
|
<p style="color: #999999; font-size: 14px; line-height: 1.6; margin: 0;">
|
|
44
|
-
${t("expiresNotice", { minutes:
|
|
45
|
+
${t("expiresNotice", { minutes: expiresInMinutes })}<br>
|
|
45
46
|
${t("ignoreNotice")}
|
|
46
47
|
</p>
|
|
47
48
|
</td>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SessionRefreshContext, SessionRefreshResult } from './useSessionCookieRefresh';
|
|
2
|
+
/**
|
|
3
|
+
* What to do with each session SessionCookieRefresher reads. Rendering takes
|
|
4
|
+
* the locale and the theme from the request and configuration alone, so the
|
|
5
|
+
* account's own choices are applied here:
|
|
6
|
+
*
|
|
7
|
+
* - No session: forget the session hint, so public pages stop asking for one.
|
|
8
|
+
* - A user: keep the hint; make the locale cookie name the account's language,
|
|
9
|
+
* refreshing the page when it was rendered in another one; and, in a browser
|
|
10
|
+
* where the visitor never chose a theme, apply the one saved to the account.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useAccountPreferencesSync(): (result: SessionRefreshResult, session?: SessionRefreshContext) => void;
|
|
13
|
+
//# sourceMappingURL=useAccountPreferencesSync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAccountPreferencesSync.d.ts","sourceRoot":"","sources":["../../src/hooks/useAccountPreferencesSync.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAoE5F;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,aAIX,oBAAoB,YAAY,qBAAqB,UA4ClF"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { useRouter } from "next/navigation";
|
|
4
|
+
import { useTheme } from "next-themes";
|
|
5
|
+
import { I18N_CONFIG } from "../lib/config/index.js";
|
|
6
|
+
import { setUserLocaleClient } from "../lib/locale-client.js";
|
|
7
|
+
import { setSessionHint } from "../lib/auth/session-hint.js";
|
|
8
|
+
const THEME_STORAGE_KEY = "theme";
|
|
9
|
+
const THEME_MODES = ["light", "dark", "system"];
|
|
10
|
+
const ACCOUNT_THEME_CHECKED_KEY = "nextspark.account_theme_checked";
|
|
11
|
+
function readCookie(name) {
|
|
12
|
+
var _a;
|
|
13
|
+
const prefix = `${name}=`;
|
|
14
|
+
return (_a = document.cookie.split(";").map((part) => part.trim()).find((part) => part.startsWith(prefix))) == null ? void 0 : _a.slice(prefix.length);
|
|
15
|
+
}
|
|
16
|
+
function hasStoredTheme() {
|
|
17
|
+
try {
|
|
18
|
+
return localStorage.getItem(THEME_STORAGE_KEY) !== null;
|
|
19
|
+
} catch {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function claimAccountThemeCheck(userId) {
|
|
24
|
+
try {
|
|
25
|
+
if (sessionStorage.getItem(ACCOUNT_THEME_CHECKED_KEY) === userId) return false;
|
|
26
|
+
sessionStorage.setItem(ACCOUNT_THEME_CHECKED_KEY, userId);
|
|
27
|
+
return true;
|
|
28
|
+
} catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const LOCALE_REFRESHED_KEY = "nextspark.locale_refreshed";
|
|
33
|
+
function claimLocaleRefresh(language) {
|
|
34
|
+
try {
|
|
35
|
+
if (sessionStorage.getItem(LOCALE_REFRESHED_KEY) === language) return false;
|
|
36
|
+
sessionStorage.setItem(LOCALE_REFRESHED_KEY, language);
|
|
37
|
+
return true;
|
|
38
|
+
} catch {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function releaseLocaleRefresh() {
|
|
43
|
+
try {
|
|
44
|
+
sessionStorage.removeItem(LOCALE_REFRESHED_KEY);
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function releaseAccountThemeCheck(userId) {
|
|
49
|
+
try {
|
|
50
|
+
if (sessionStorage.getItem(ACCOUNT_THEME_CHECKED_KEY) === userId) sessionStorage.removeItem(ACCOUNT_THEME_CHECKED_KEY);
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function useAccountPreferencesSync() {
|
|
55
|
+
const router = useRouter();
|
|
56
|
+
const { setTheme, forcedTheme } = useTheme();
|
|
57
|
+
return useCallback((result, session) => {
|
|
58
|
+
var _a;
|
|
59
|
+
if (!result || result.error) return;
|
|
60
|
+
const user = (_a = result.data) == null ? void 0 : _a.user;
|
|
61
|
+
if (!user) {
|
|
62
|
+
setSessionHint(false);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
setSessionHint(true);
|
|
66
|
+
const language = user.language;
|
|
67
|
+
const localeDetected = I18N_CONFIG.supportedLocales.length > 1 && I18N_CONFIG.localeDetection !== false;
|
|
68
|
+
if (localeDetected && typeof language === "string" && I18N_CONFIG.supportedLocales.includes(language)) {
|
|
69
|
+
if (readCookie(I18N_CONFIG.cookie.name) !== language) setUserLocaleClient(language);
|
|
70
|
+
if (document.documentElement.lang === language) {
|
|
71
|
+
releaseLocaleRefresh();
|
|
72
|
+
} else if (readCookie(I18N_CONFIG.cookie.name) === language && claimLocaleRefresh(language)) {
|
|
73
|
+
router.refresh();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const userId = typeof user.id === "string" ? user.id : "signed-in";
|
|
77
|
+
if (!forcedTheme && !hasStoredTheme() && claimAccountThemeCheck(userId)) {
|
|
78
|
+
fetch("/api/user/profile?includeMeta=true").then((response) => {
|
|
79
|
+
if (!response.ok) throw new Error(`Profile request failed with status ${response.status}`);
|
|
80
|
+
return response.json();
|
|
81
|
+
}).then((profile) => {
|
|
82
|
+
var _a2, _b;
|
|
83
|
+
if (session && !session.isCurrent()) {
|
|
84
|
+
releaseAccountThemeCheck(userId);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const theme = (_b = (_a2 = profile == null ? void 0 : profile.meta) == null ? void 0 : _a2.uiPreferences) == null ? void 0 : _b.theme;
|
|
88
|
+
if (THEME_MODES.includes(theme)) setTheme(theme);
|
|
89
|
+
}).catch(() => releaseAccountThemeCheck(userId));
|
|
90
|
+
}
|
|
91
|
+
}, [router, setTheme, forcedTheme]);
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
useAccountPreferencesSync
|
|
95
|
+
};
|
package/dist/hooks/useAuth.d.ts
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
import type { SessionUser } from '../lib/auth';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Sign-in, sign-up and account actions, without subscribing to the session: a
|
|
4
|
+
* page that only acts, like the login and signup forms, makes no session request.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useAuthActions(): {
|
|
7
|
+
signIn: ({ email, password, redirectTo }: {
|
|
8
|
+
email: string;
|
|
9
|
+
password: string;
|
|
10
|
+
redirectTo?: string;
|
|
11
|
+
}) => Promise<Omit<{
|
|
12
|
+
redirect: boolean;
|
|
13
|
+
token: string;
|
|
14
|
+
url?: string | undefined;
|
|
15
|
+
user: {
|
|
16
|
+
id: string;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
updatedAt: Date;
|
|
19
|
+
email: string;
|
|
20
|
+
emailVerified: boolean;
|
|
21
|
+
name: string;
|
|
22
|
+
image?: string | null | undefined;
|
|
23
|
+
};
|
|
24
|
+
}, "user"> & {
|
|
5
25
|
user: import("better-auth").StripEmptyObjects<{
|
|
6
26
|
id: string;
|
|
7
27
|
createdAt: Date;
|
|
@@ -11,18 +31,166 @@ export declare function useAuth(): {
|
|
|
11
31
|
email?: string;
|
|
12
32
|
image?: string;
|
|
13
33
|
} & {} & {}>;
|
|
14
|
-
|
|
34
|
+
}>;
|
|
35
|
+
signUp: ({ email, password, firstName, lastName, intent }: {
|
|
36
|
+
email: string;
|
|
37
|
+
password: string;
|
|
38
|
+
firstName?: string;
|
|
39
|
+
lastName?: string;
|
|
40
|
+
intent?: string;
|
|
41
|
+
}) => Promise<(Omit<{
|
|
42
|
+
token: null;
|
|
43
|
+
user: {
|
|
15
44
|
id: string;
|
|
16
45
|
createdAt: Date;
|
|
17
46
|
updatedAt: Date;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
47
|
+
email: string;
|
|
48
|
+
emailVerified: boolean;
|
|
49
|
+
name: string;
|
|
50
|
+
image?: string | null | undefined;
|
|
51
|
+
};
|
|
52
|
+
}, "user"> & {
|
|
53
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
54
|
+
id: string;
|
|
55
|
+
createdAt: Date;
|
|
56
|
+
updatedAt: Date;
|
|
57
|
+
emailVerified: boolean;
|
|
58
|
+
name: string;
|
|
59
|
+
email?: string;
|
|
60
|
+
image?: string;
|
|
23
61
|
} & {} & {}>;
|
|
24
|
-
}
|
|
25
|
-
|
|
62
|
+
}) | (Omit<{
|
|
63
|
+
token: string;
|
|
64
|
+
user: {
|
|
65
|
+
id: string;
|
|
66
|
+
createdAt: Date;
|
|
67
|
+
updatedAt: Date;
|
|
68
|
+
email: string;
|
|
69
|
+
emailVerified: boolean;
|
|
70
|
+
name: string;
|
|
71
|
+
image?: string | null | undefined;
|
|
72
|
+
};
|
|
73
|
+
}, "user"> & {
|
|
74
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
75
|
+
id: string;
|
|
76
|
+
createdAt: Date;
|
|
77
|
+
updatedAt: Date;
|
|
78
|
+
emailVerified: boolean;
|
|
79
|
+
name: string;
|
|
80
|
+
email?: string;
|
|
81
|
+
image?: string;
|
|
82
|
+
} & {} & {}>;
|
|
83
|
+
})>;
|
|
84
|
+
signOut: () => Promise<void>;
|
|
85
|
+
googleSignIn: (redirectTo?: string) => Promise<void>;
|
|
86
|
+
sendOtp: (email: string) => Promise<{
|
|
87
|
+
success: boolean;
|
|
88
|
+
}>;
|
|
89
|
+
signInWithOtp: ({ email, otp, redirectTo }: {
|
|
90
|
+
email: string;
|
|
91
|
+
otp: string;
|
|
92
|
+
redirectTo?: string;
|
|
93
|
+
}) => Promise<Omit<{
|
|
94
|
+
token: string;
|
|
95
|
+
user: {
|
|
96
|
+
id: string;
|
|
97
|
+
createdAt: Date;
|
|
98
|
+
updatedAt: Date;
|
|
99
|
+
email: string;
|
|
100
|
+
emailVerified: boolean;
|
|
101
|
+
name: string;
|
|
102
|
+
image?: string | null | undefined;
|
|
103
|
+
};
|
|
104
|
+
}, "user"> & {
|
|
105
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
106
|
+
id: string;
|
|
107
|
+
createdAt: Date;
|
|
108
|
+
updatedAt: Date;
|
|
109
|
+
emailVerified: boolean;
|
|
110
|
+
name: string;
|
|
111
|
+
email?: string;
|
|
112
|
+
image?: string;
|
|
113
|
+
} & {} & {}>;
|
|
114
|
+
}>;
|
|
115
|
+
resetPassword: (email: string) => Promise<{
|
|
116
|
+
success: boolean;
|
|
117
|
+
data: any;
|
|
118
|
+
error: string;
|
|
119
|
+
} | {
|
|
120
|
+
success: boolean;
|
|
121
|
+
data: {
|
|
122
|
+
status: boolean;
|
|
123
|
+
message: string;
|
|
124
|
+
};
|
|
125
|
+
error: any;
|
|
126
|
+
}>;
|
|
127
|
+
updatePassword: (newPassword: string, token?: string) => Promise<{
|
|
128
|
+
success: boolean;
|
|
129
|
+
data: any;
|
|
130
|
+
error: string;
|
|
131
|
+
} | {
|
|
132
|
+
success: boolean;
|
|
133
|
+
data: {
|
|
134
|
+
status: boolean;
|
|
135
|
+
};
|
|
136
|
+
error: any;
|
|
137
|
+
}>;
|
|
138
|
+
changePassword: (currentPassword: string, newPassword: string, revokeOtherSessions?: boolean) => Promise<{
|
|
139
|
+
success: boolean;
|
|
140
|
+
data: any;
|
|
141
|
+
error: string;
|
|
142
|
+
} | {
|
|
143
|
+
success: boolean;
|
|
144
|
+
data: Omit<{
|
|
145
|
+
token: string | null;
|
|
146
|
+
user: {
|
|
147
|
+
id: string;
|
|
148
|
+
createdAt: Date;
|
|
149
|
+
updatedAt: Date;
|
|
150
|
+
email: string;
|
|
151
|
+
emailVerified: boolean;
|
|
152
|
+
name: string;
|
|
153
|
+
image?: string | null | undefined;
|
|
154
|
+
} & Record<string, any> & {
|
|
155
|
+
id: string;
|
|
156
|
+
createdAt: Date;
|
|
157
|
+
updatedAt: Date;
|
|
158
|
+
email: string;
|
|
159
|
+
emailVerified: boolean;
|
|
160
|
+
name: string;
|
|
161
|
+
image?: string | null | undefined;
|
|
162
|
+
};
|
|
163
|
+
}, "user"> & {
|
|
164
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
165
|
+
id: string;
|
|
166
|
+
createdAt: Date;
|
|
167
|
+
updatedAt: Date;
|
|
168
|
+
emailVerified: boolean;
|
|
169
|
+
name: string;
|
|
170
|
+
email?: string;
|
|
171
|
+
image?: string;
|
|
172
|
+
} & {} & {}>;
|
|
173
|
+
};
|
|
174
|
+
error: any;
|
|
175
|
+
}>;
|
|
176
|
+
resendVerificationEmail: (email: string) => Promise<{
|
|
177
|
+
success: boolean;
|
|
178
|
+
data: any;
|
|
179
|
+
error: string;
|
|
180
|
+
} | {
|
|
181
|
+
success: boolean;
|
|
182
|
+
data: {
|
|
183
|
+
status: boolean;
|
|
184
|
+
};
|
|
185
|
+
error: any;
|
|
186
|
+
}>;
|
|
187
|
+
};
|
|
188
|
+
/** The session (user, loading state) and the auth actions. */
|
|
189
|
+
export declare function useAuth(): {
|
|
190
|
+
isSigningIn: boolean;
|
|
191
|
+
isSigningUp: boolean;
|
|
192
|
+
signInError: any;
|
|
193
|
+
signUpError: any;
|
|
26
194
|
signIn: ({ email, password, redirectTo }: {
|
|
27
195
|
email: string;
|
|
28
196
|
password: string;
|
|
@@ -203,9 +371,28 @@ export declare function useAuth(): {
|
|
|
203
371
|
};
|
|
204
372
|
error: any;
|
|
205
373
|
}>;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
374
|
+
user: SessionUser | null;
|
|
375
|
+
session: {
|
|
376
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
377
|
+
id: string;
|
|
378
|
+
createdAt: Date;
|
|
379
|
+
updatedAt: Date;
|
|
380
|
+
emailVerified: boolean;
|
|
381
|
+
name: string;
|
|
382
|
+
email?: string;
|
|
383
|
+
image?: string;
|
|
384
|
+
} & {} & {}>;
|
|
385
|
+
session: import("better-auth").StripEmptyObjects<{
|
|
386
|
+
id: string;
|
|
387
|
+
createdAt: Date;
|
|
388
|
+
updatedAt: Date;
|
|
389
|
+
userId: string;
|
|
390
|
+
expiresAt: Date;
|
|
391
|
+
token: string;
|
|
392
|
+
ipAddress?: string;
|
|
393
|
+
userAgent?: string;
|
|
394
|
+
} & {} & {}>;
|
|
395
|
+
};
|
|
396
|
+
isLoading: boolean;
|
|
210
397
|
};
|
|
211
398
|
//# sourceMappingURL=useAuth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AA0C9C;;;GAGG;AACH,wBAAgB,cAAc;8CAYiC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;;;+DAqBvC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA2E1H,MAAM;qBAlCjB,MAAM;;;gDAgBiB;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;iBA4G3D,CAAC;;;;;;;;;;;;;2BAjFV,MAAM;;;;;;;;;;;;kCA6BC,MAAM,UAAU,MAAM;;;;;;;;;;;sCAwClB,MAAM,eAAe,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCA8B5B,MAAM;;;;;;;;;;;EAwC3D;AAED,8DAA8D;AAC9D,wBAAgB,OAAO;;;;;8CAvPwC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;;;+DAqBvC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA2E1H,MAAM;qBAlCjB,MAAM;;;gDAgBiB;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;iBA4G3D,CAAC;;;;;;;;;;;;;2BAjFV,MAAM;;;;;;;;;;;;kCA6BC,MAAM,UAAU,MAAM;;;;;;;;;;;sCAwClB,MAAM,eAAe,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCA8B5B,MAAM;;;;;;;;;;;UAqD5B,WAAW,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;EASjD"}
|
package/dist/hooks/useAuth.js
CHANGED
|
@@ -1,25 +1,46 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useContext, useEffect } from "react";
|
|
2
3
|
import { useRouter } from "next/navigation";
|
|
4
|
+
import { QueryClientContext } from "@tanstack/react-query";
|
|
3
5
|
import { authClient } from "../lib/auth-client.js";
|
|
4
6
|
import { useOrigin } from "./useOrigin.js";
|
|
5
7
|
import { useLastAuthMethod } from "./useLastAuthMethod.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
import { safeCallbackPath } from "../lib/auth/callback-url.js";
|
|
9
|
+
import { setSessionHint } from "../lib/auth/session-hint.js";
|
|
10
|
+
import { setUserLocaleClient } from "../lib/locale-client.js";
|
|
11
|
+
import { I18N_CONFIG } from "../lib/config/index.js";
|
|
12
|
+
function googleCallbackURL(redirectTo) {
|
|
13
|
+
const url = new URL(safeCallbackPath(redirectTo) ?? "/dashboard", "http://callback.invalid");
|
|
14
|
+
url.searchParams.set("auth_method", "google");
|
|
15
|
+
return `${url.pathname}${url.search.replace(/\*/g, "%2A")}`;
|
|
16
|
+
}
|
|
17
|
+
function rememberSignedIn(user) {
|
|
18
|
+
setSessionHint(true);
|
|
19
|
+
const language = user == null ? void 0 : user.language;
|
|
20
|
+
const localeDetected = I18N_CONFIG.supportedLocales.length > 1 && I18N_CONFIG.localeDetection !== false;
|
|
21
|
+
if (localeDetected && typeof language === "string" && I18N_CONFIG.supportedLocales.includes(language)) {
|
|
22
|
+
setUserLocaleClient(language);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function useAuthActions() {
|
|
8
26
|
const router = useRouter();
|
|
9
|
-
const session = authClient.useSession();
|
|
10
27
|
const origin = useOrigin();
|
|
11
28
|
const { saveAuthMethod } = useLastAuthMethod();
|
|
29
|
+
const queryClient = useContext(QueryClientContext);
|
|
30
|
+
const forgetSignedInData = () => queryClient == null ? void 0 : queryClient.clear();
|
|
12
31
|
const handleSignIn = async ({ email, password, redirectTo }) => {
|
|
13
32
|
const { data, error } = await authClient.signIn.email({
|
|
14
33
|
email,
|
|
15
34
|
password
|
|
16
35
|
});
|
|
17
36
|
if (error) {
|
|
18
|
-
throw new Error(error.message || "
|
|
37
|
+
throw new Error(error.message || "Failed to sign in");
|
|
19
38
|
}
|
|
20
39
|
if (data) {
|
|
21
40
|
saveAuthMethod("email");
|
|
22
|
-
|
|
41
|
+
forgetSignedInData();
|
|
42
|
+
rememberSignedIn(data.user);
|
|
43
|
+
router.push(safeCallbackPath(redirectTo) ?? "/dashboard");
|
|
23
44
|
}
|
|
24
45
|
return data;
|
|
25
46
|
};
|
|
@@ -47,6 +68,8 @@ function useAuth() {
|
|
|
47
68
|
localStorage.removeItem("activeTeamId");
|
|
48
69
|
}
|
|
49
70
|
await authClient.signOut();
|
|
71
|
+
setSessionHint(false);
|
|
72
|
+
forgetSignedInData();
|
|
50
73
|
router.push("/login");
|
|
51
74
|
};
|
|
52
75
|
const handleSendOtp = async (email) => {
|
|
@@ -66,15 +89,16 @@ function useAuth() {
|
|
|
66
89
|
}
|
|
67
90
|
if (data) {
|
|
68
91
|
saveAuthMethod("email");
|
|
69
|
-
|
|
92
|
+
forgetSignedInData();
|
|
93
|
+
rememberSignedIn(data.user);
|
|
94
|
+
router.push(safeCallbackPath(redirectTo) ?? "/dashboard");
|
|
70
95
|
}
|
|
71
96
|
return data;
|
|
72
97
|
};
|
|
73
98
|
const handleGoogleSignIn = async (redirectTo) => {
|
|
74
|
-
const callbackURL = redirectTo ? `${redirectTo}${redirectTo.includes("?") ? "&" : "?"}auth_method=google` : "/dashboard?auth_method=google";
|
|
75
99
|
await authClient.signIn.social({
|
|
76
100
|
provider: "google",
|
|
77
|
-
callbackURL
|
|
101
|
+
callbackURL: googleCallbackURL(redirectTo)
|
|
78
102
|
});
|
|
79
103
|
};
|
|
80
104
|
const handleResetPassword = async (email) => {
|
|
@@ -189,9 +213,6 @@ function useAuth() {
|
|
|
189
213
|
}
|
|
190
214
|
};
|
|
191
215
|
return {
|
|
192
|
-
user: (_a = session.data) == null ? void 0 : _a.user,
|
|
193
|
-
session: session.data,
|
|
194
|
-
isLoading: session.isPending,
|
|
195
216
|
signIn: handleSignIn,
|
|
196
217
|
signUp: handleSignUp,
|
|
197
218
|
signOut: handleSignOut,
|
|
@@ -201,7 +222,21 @@ function useAuth() {
|
|
|
201
222
|
resetPassword: handleResetPassword,
|
|
202
223
|
updatePassword: handleUpdatePassword,
|
|
203
224
|
changePassword: handleChangePassword,
|
|
204
|
-
resendVerificationEmail: handleResendVerificationEmail
|
|
225
|
+
resendVerificationEmail: handleResendVerificationEmail
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function useAuth() {
|
|
229
|
+
var _a;
|
|
230
|
+
const session = authClient.useSession();
|
|
231
|
+
const actions = useAuthActions();
|
|
232
|
+
useEffect(() => {
|
|
233
|
+
if (!session.isPending && !session.error) setSessionHint(Boolean(session.data));
|
|
234
|
+
}, [session.isPending, session.error, session.data]);
|
|
235
|
+
return {
|
|
236
|
+
user: (_a = session.data) == null ? void 0 : _a.user,
|
|
237
|
+
session: session.data,
|
|
238
|
+
isLoading: session.isPending,
|
|
239
|
+
...actions,
|
|
205
240
|
isSigningIn: false,
|
|
206
241
|
// BetterAuth doesn't provide this directly
|
|
207
242
|
isSigningUp: false,
|
|
@@ -211,5 +246,6 @@ function useAuth() {
|
|
|
211
246
|
};
|
|
212
247
|
}
|
|
213
248
|
export {
|
|
214
|
-
useAuth
|
|
249
|
+
useAuth,
|
|
250
|
+
useAuthActions
|
|
215
251
|
};
|