@fayz-ai/saas 0.1.6
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/app/AdminShell.d.ts +31 -0
- package/dist/app/AdminShell.d.ts.map +1 -0
- package/dist/app/LoginPage.d.ts +17 -0
- package/dist/app/LoginPage.d.ts.map +1 -0
- package/dist/app/config.d.ts +83 -0
- package/dist/app/config.d.ts.map +1 -0
- package/dist/app/createFayzApp.d.ts +11 -0
- package/dist/app/createFayzApp.d.ts.map +1 -0
- package/dist/app/routing.d.ts +10 -0
- package/dist/app/routing.d.ts.map +1 -0
- package/dist/app/scaffold.d.ts +17 -0
- package/dist/app/scaffold.d.ts.map +1 -0
- package/dist/archetype-lookup.d.ts +30 -0
- package/dist/archetype-lookup.d.ts.map +1 -0
- package/dist/billing/index.cjs +12 -0
- package/dist/billing/index.cjs.map +1 -0
- package/dist/billing/index.d.ts +3 -0
- package/dist/billing/index.d.ts.map +1 -0
- package/dist/billing/index.js +3 -0
- package/dist/billing/index.js.map +1 -0
- package/dist/billing/store.d.ts +35 -0
- package/dist/billing/store.d.ts.map +1 -0
- package/dist/chunk-4XTQ4V5L.cjs +124 -0
- package/dist/chunk-4XTQ4V5L.cjs.map +1 -0
- package/dist/chunk-5GYQK5IW.js +21 -0
- package/dist/chunk-5GYQK5IW.js.map +1 -0
- package/dist/chunk-DJW67TCY.js +781 -0
- package/dist/chunk-DJW67TCY.js.map +1 -0
- package/dist/chunk-KYID2MR6.cjs +23 -0
- package/dist/chunk-KYID2MR6.cjs.map +1 -0
- package/dist/chunk-QGMDVLLW.cjs +816 -0
- package/dist/chunk-QGMDVLLW.cjs.map +1 -0
- package/dist/chunk-XNWCGJYH.js +97 -0
- package/dist/chunk-XNWCGJYH.js.map +1 -0
- package/dist/components/shared/PersonLink.d.ts +18 -0
- package/dist/components/shared/PersonLink.d.ts.map +1 -0
- package/dist/crud/CrudCardGrid.d.ts +13 -0
- package/dist/crud/CrudCardGrid.d.ts.map +1 -0
- package/dist/crud/CrudDetailPage.d.ts +18 -0
- package/dist/crud/CrudDetailPage.d.ts.map +1 -0
- package/dist/crud/CrudFormPage.d.ts +18 -0
- package/dist/crud/CrudFormPage.d.ts.map +1 -0
- package/dist/crud/CrudListView.d.ts +51 -0
- package/dist/crud/CrudListView.d.ts.map +1 -0
- package/dist/crud/CrudPage.d.ts +20 -0
- package/dist/crud/CrudPage.d.ts.map +1 -0
- package/dist/crud/DeleteConfirmDialog.d.ts +11 -0
- package/dist/crud/DeleteConfirmDialog.d.ts.map +1 -0
- package/dist/crud/EntityOverview.d.ts +14 -0
- package/dist/crud/EntityOverview.d.ts.map +1 -0
- package/dist/crud/ImportWizard.d.ts +18 -0
- package/dist/crud/ImportWizard.d.ts.map +1 -0
- package/dist/crud/archetypes/ActiveToggle.d.ts +8 -0
- package/dist/crud/archetypes/ActiveToggle.d.ts.map +1 -0
- package/dist/crud/archetypes/ArchetypeStatusBar.d.ts +11 -0
- package/dist/crud/archetypes/ArchetypeStatusBar.d.ts.map +1 -0
- package/dist/crud/archetypes/BlockSettingsPopover.d.ts +15 -0
- package/dist/crud/archetypes/BlockSettingsPopover.d.ts.map +1 -0
- package/dist/crud/archetypes/EntityLink.d.ts +32 -0
- package/dist/crud/archetypes/EntityLink.d.ts.map +1 -0
- package/dist/crud/archetypes/LocationDetailTabs.d.ts +11 -0
- package/dist/crud/archetypes/LocationDetailTabs.d.ts.map +1 -0
- package/dist/crud/archetypes/LocationFormLayout.d.ts +12 -0
- package/dist/crud/archetypes/LocationFormLayout.d.ts.map +1 -0
- package/dist/crud/archetypes/PersonDetailTabs.d.ts +22 -0
- package/dist/crud/archetypes/PersonDetailTabs.d.ts.map +1 -0
- package/dist/crud/archetypes/PersonFormLayout.d.ts +13 -0
- package/dist/crud/archetypes/PersonFormLayout.d.ts.map +1 -0
- package/dist/crud/archetypes/PersonPicker.d.ts +23 -0
- package/dist/crud/archetypes/PersonPicker.d.ts.map +1 -0
- package/dist/crud/archetypes/ProductDetailTabs.d.ts +11 -0
- package/dist/crud/archetypes/ProductDetailTabs.d.ts.map +1 -0
- package/dist/crud/archetypes/ProductFormLayout.d.ts +12 -0
- package/dist/crud/archetypes/ProductFormLayout.d.ts.map +1 -0
- package/dist/crud/archetypes/ScheduleEditor.d.ts +7 -0
- package/dist/crud/archetypes/ScheduleEditor.d.ts.map +1 -0
- package/dist/crud/archetypes/ServiceDetailTabs.d.ts +10 -0
- package/dist/crud/archetypes/ServiceDetailTabs.d.ts.map +1 -0
- package/dist/crud/archetypes/ServiceFormLayout.d.ts +12 -0
- package/dist/crud/archetypes/ServiceFormLayout.d.ts.map +1 -0
- package/dist/crud/archetypes/SubjectDetailTabs.d.ts +12 -0
- package/dist/crud/archetypes/SubjectDetailTabs.d.ts.map +1 -0
- package/dist/crud/archetypes/SubjectFormLayout.d.ts +14 -0
- package/dist/crud/archetypes/SubjectFormLayout.d.ts.map +1 -0
- package/dist/crud/createCrudPage.d.ts +20 -0
- package/dist/crud/createCrudPage.d.ts.map +1 -0
- package/dist/crud/csv-export.d.ts +3 -0
- package/dist/crud/csv-export.d.ts.map +1 -0
- package/dist/crud/fieldToColumn.d.ts +14 -0
- package/dist/crud/fieldToColumn.d.ts.map +1 -0
- package/dist/crud/index.d.ts +12 -0
- package/dist/crud/index.d.ts.map +1 -0
- package/dist/hooks/useFieldRules.d.ts +5 -0
- package/dist/hooks/useFieldRules.d.ts.map +1 -0
- package/dist/hooks/useModuleNavigation.d.ts +25 -0
- package/dist/hooks/useModuleNavigation.d.ts.map +1 -0
- package/dist/hooks/usePluginPrefs.d.ts +23 -0
- package/dist/hooks/usePluginPrefs.d.ts.map +1 -0
- package/dist/index.cjs +13880 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13730 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/currency.d.ts +13 -0
- package/dist/lib/currency.d.ts.map +1 -0
- package/dist/lib/entity-routes.d.ts +24 -0
- package/dist/lib/entity-routes.d.ts.map +1 -0
- package/dist/lib/schedule-config.d.ts +32 -0
- package/dist/lib/schedule-config.d.ts.map +1 -0
- package/dist/lib/schedule-service.d.ts +76 -0
- package/dist/lib/schedule-service.d.ts.map +1 -0
- package/dist/org/adapters/mock.d.ts +4 -0
- package/dist/org/adapters/mock.d.ts.map +1 -0
- package/dist/org/adapters/supabase.d.ts +7 -0
- package/dist/org/adapters/supabase.d.ts.map +1 -0
- package/dist/org/context.d.ts +29 -0
- package/dist/org/context.d.ts.map +1 -0
- package/dist/org/index.cjs +44 -0
- package/dist/org/index.cjs.map +1 -0
- package/dist/org/index.d.ts +8 -0
- package/dist/org/index.d.ts.map +1 -0
- package/dist/org/index.js +3 -0
- package/dist/org/index.js.map +1 -0
- package/dist/org/store.d.ts +16 -0
- package/dist/org/store.d.ts.map +1 -0
- package/dist/permissions/PermissionGate.d.ts +12 -0
- package/dist/permissions/PermissionGate.d.ts.map +1 -0
- package/dist/permissions/context.d.ts +37 -0
- package/dist/permissions/context.d.ts.map +1 -0
- package/dist/permissions/index.cjs +32 -0
- package/dist/permissions/index.cjs.map +1 -0
- package/dist/permissions/index.d.ts +5 -0
- package/dist/permissions/index.d.ts.map +1 -0
- package/dist/permissions/index.js +3 -0
- package/dist/permissions/index.js.map +1 -0
- package/dist/permissions/store.d.ts +21 -0
- package/dist/permissions/store.d.ts.map +1 -0
- package/dist/placeholder.d.ts +7 -0
- package/dist/placeholder.d.ts.map +1 -0
- package/dist/plugins/ModuleActionBar.d.ts +27 -0
- package/dist/plugins/ModuleActionBar.d.ts.map +1 -0
- package/dist/plugins/PluginRegistryManager.d.ts +13 -0
- package/dist/plugins/PluginRegistryManager.d.ts.map +1 -0
- package/dist/plugins/QuickActionsButton.d.ts +12 -0
- package/dist/plugins/QuickActionsButton.d.ts.map +1 -0
- package/dist/plugins/SettingsGroup.d.ts +25 -0
- package/dist/plugins/SettingsGroup.d.ts.map +1 -0
- package/dist/plugins/WidgetSlot.d.ts +8 -0
- package/dist/plugins/WidgetSlot.d.ts.map +1 -0
- package/dist/plugins/createPluginContext.d.ts +28 -0
- package/dist/plugins/createPluginContext.d.ts.map +1 -0
- package/dist/plugins/createViewRouter.d.ts +38 -0
- package/dist/plugins/createViewRouter.d.ts.map +1 -0
- package/dist/shell/components/auth/CenteredLogin.d.ts +13 -0
- package/dist/shell/components/auth/CenteredLogin.d.ts.map +1 -0
- package/dist/shell/components/auth/LoginForm.d.ts +12 -0
- package/dist/shell/components/auth/LoginForm.d.ts.map +1 -0
- package/dist/shell/components/auth/LoginPage.d.ts +15 -0
- package/dist/shell/components/auth/LoginPage.d.ts.map +1 -0
- package/dist/shell/components/auth/OAuthButtons.d.ts +10 -0
- package/dist/shell/components/auth/OAuthButtons.d.ts.map +1 -0
- package/dist/shell/components/auth/ProtectedRoute.d.ts +11 -0
- package/dist/shell/components/auth/ProtectedRoute.d.ts.map +1 -0
- package/dist/shell/components/auth/RecoveryForm.d.ts +9 -0
- package/dist/shell/components/auth/RecoveryForm.d.ts.map +1 -0
- package/dist/shell/components/auth/SignupForm.d.ts +10 -0
- package/dist/shell/components/auth/SignupForm.d.ts.map +1 -0
- package/dist/shell/components/auth/SplitLogin.d.ts +14 -0
- package/dist/shell/components/auth/SplitLogin.d.ts.map +1 -0
- package/dist/shell/components/auth/index.d.ts +7 -0
- package/dist/shell/components/auth/index.d.ts.map +1 -0
- package/dist/shell/components/billing/BillingPage.d.ts +7 -0
- package/dist/shell/components/billing/BillingPage.d.ts.map +1 -0
- package/dist/shell/components/billing/InvoiceList.d.ts +9 -0
- package/dist/shell/components/billing/InvoiceList.d.ts.map +1 -0
- package/dist/shell/components/billing/PaywallGate.d.ts +11 -0
- package/dist/shell/components/billing/PaywallGate.d.ts.map +1 -0
- package/dist/shell/components/billing/PlanSelector.d.ts +13 -0
- package/dist/shell/components/billing/PlanSelector.d.ts.map +1 -0
- package/dist/shell/components/billing/SubscriptionCard.d.ts +12 -0
- package/dist/shell/components/billing/SubscriptionCard.d.ts.map +1 -0
- package/dist/shell/components/billing/index.d.ts +6 -0
- package/dist/shell/components/billing/index.d.ts.map +1 -0
- package/dist/shell/components/chat/ChatFab.d.ts +9 -0
- package/dist/shell/components/chat/ChatFab.d.ts.map +1 -0
- package/dist/shell/components/chat/ChatPanel.d.ts +10 -0
- package/dist/shell/components/chat/ChatPanel.d.ts.map +1 -0
- package/dist/shell/components/chat/ChatSuggestions.d.ts +14 -0
- package/dist/shell/components/chat/ChatSuggestions.d.ts.map +1 -0
- package/dist/shell/components/chat/index.d.ts +3 -0
- package/dist/shell/components/chat/index.d.ts.map +1 -0
- package/dist/shell/components/crud/archetypes/ClientOrdersTab.d.ts +16 -0
- package/dist/shell/components/crud/archetypes/ClientOrdersTab.d.ts.map +1 -0
- package/dist/shell/components/layout/BottomNav.d.ts +24 -0
- package/dist/shell/components/layout/BottomNav.d.ts.map +1 -0
- package/dist/shell/components/layout/CommandPalette.d.ts +29 -0
- package/dist/shell/components/layout/CommandPalette.d.ts.map +1 -0
- package/dist/shell/components/layout/LocationSwitchOverlay.d.ts +3 -0
- package/dist/shell/components/layout/LocationSwitchOverlay.d.ts.map +1 -0
- package/dist/shell/components/layout/MockModeBanner.d.ts +3 -0
- package/dist/shell/components/layout/MockModeBanner.d.ts.map +1 -0
- package/dist/shell/components/layout/PrintChrome.d.ts +10 -0
- package/dist/shell/components/layout/PrintChrome.d.ts.map +1 -0
- package/dist/shell/components/layout/index.d.ts +6 -0
- package/dist/shell/components/layout/index.d.ts.map +1 -0
- package/dist/shell/components/notifications/ChangelogFeed.d.ts +8 -0
- package/dist/shell/components/notifications/ChangelogFeed.d.ts.map +1 -0
- package/dist/shell/components/notifications/NotificationBell.d.ts +9 -0
- package/dist/shell/components/notifications/NotificationBell.d.ts.map +1 -0
- package/dist/shell/components/notifications/NotificationInbox.d.ts +13 -0
- package/dist/shell/components/notifications/NotificationInbox.d.ts.map +1 -0
- package/dist/shell/components/notifications/ToastProvider.d.ts +2 -0
- package/dist/shell/components/notifications/ToastProvider.d.ts.map +1 -0
- package/dist/shell/components/notifications/index.d.ts +5 -0
- package/dist/shell/components/notifications/index.d.ts.map +1 -0
- package/dist/shell/components/organization/ImpersonationBanner.d.ts +3 -0
- package/dist/shell/components/organization/ImpersonationBanner.d.ts.map +1 -0
- package/dist/shell/components/organization/InviteMemberDialog.d.ts +10 -0
- package/dist/shell/components/organization/InviteMemberDialog.d.ts.map +1 -0
- package/dist/shell/components/organization/OrgInitializer.d.ts +7 -0
- package/dist/shell/components/organization/OrgInitializer.d.ts.map +1 -0
- package/dist/shell/components/organization/OrgSwitcher.d.ts +7 -0
- package/dist/shell/components/organization/OrgSwitcher.d.ts.map +1 -0
- package/dist/shell/components/organization/PermissionGate.d.ts +11 -0
- package/dist/shell/components/organization/PermissionGate.d.ts.map +1 -0
- package/dist/shell/components/organization/PermissionMatrixEditor.d.ts +17 -0
- package/dist/shell/components/organization/PermissionMatrixEditor.d.ts.map +1 -0
- package/dist/shell/components/organization/PermissionProfilesTab.d.ts +3 -0
- package/dist/shell/components/organization/PermissionProfilesTab.d.ts.map +1 -0
- package/dist/shell/components/organization/TeamTab.d.ts +3 -0
- package/dist/shell/components/organization/TeamTab.d.ts.map +1 -0
- package/dist/shell/components/organization/TenantOnboarding.d.ts +9 -0
- package/dist/shell/components/organization/TenantOnboarding.d.ts.map +1 -0
- package/dist/shell/components/organization/index.d.ts +8 -0
- package/dist/shell/components/organization/index.d.ts.map +1 -0
- package/dist/shell/components/plugins/PluginSettingsPanel.d.ts +23 -0
- package/dist/shell/components/plugins/PluginSettingsPanel.d.ts.map +1 -0
- package/dist/shell/components/settings/BrandingSettings.d.ts +12 -0
- package/dist/shell/components/settings/BrandingSettings.d.ts.map +1 -0
- package/dist/shell/components/settings/CompanySettings.d.ts +13 -0
- package/dist/shell/components/settings/CompanySettings.d.ts.map +1 -0
- package/dist/shell/components/settings/ConnectedBrandingSettings.d.ts +2 -0
- package/dist/shell/components/settings/ConnectedBrandingSettings.d.ts.map +1 -0
- package/dist/shell/components/settings/ConnectedCompanySettings.d.ts +2 -0
- package/dist/shell/components/settings/ConnectedCompanySettings.d.ts.map +1 -0
- package/dist/shell/components/settings/ConnectedFieldRulesSettings.d.ts +2 -0
- package/dist/shell/components/settings/ConnectedFieldRulesSettings.d.ts.map +1 -0
- package/dist/shell/components/settings/ConnectedHolidaysSettings.d.ts +3 -0
- package/dist/shell/components/settings/ConnectedHolidaysSettings.d.ts.map +1 -0
- package/dist/shell/components/settings/ConnectedLocationsOverview.d.ts +3 -0
- package/dist/shell/components/settings/ConnectedLocationsOverview.d.ts.map +1 -0
- package/dist/shell/components/settings/ConnectedSecuritySettings.d.ts +2 -0
- package/dist/shell/components/settings/ConnectedSecuritySettings.d.ts.map +1 -0
- package/dist/shell/components/settings/ConnectedUserProfile.d.ts +2 -0
- package/dist/shell/components/settings/ConnectedUserProfile.d.ts.map +1 -0
- package/dist/shell/components/settings/FieldRulesSettings.d.ts +11 -0
- package/dist/shell/components/settings/FieldRulesSettings.d.ts.map +1 -0
- package/dist/shell/components/settings/HolidaysSettings.d.ts +21 -0
- package/dist/shell/components/settings/HolidaysSettings.d.ts.map +1 -0
- package/dist/shell/components/settings/LocationsCrudPage.d.ts +6 -0
- package/dist/shell/components/settings/LocationsCrudPage.d.ts.map +1 -0
- package/dist/shell/components/settings/LocationsOverview.d.ts +19 -0
- package/dist/shell/components/settings/LocationsOverview.d.ts.map +1 -0
- package/dist/shell/components/settings/SecuritySettings.d.ts +17 -0
- package/dist/shell/components/settings/SecuritySettings.d.ts.map +1 -0
- package/dist/shell/components/settings/SettingsPage.d.ts +18 -0
- package/dist/shell/components/settings/SettingsPage.d.ts.map +1 -0
- package/dist/shell/components/settings/UserProfile.d.ts +12 -0
- package/dist/shell/components/settings/UserProfile.d.ts.map +1 -0
- package/dist/shell/components/settings/index.d.ts +11 -0
- package/dist/shell/components/settings/index.d.ts.map +1 -0
- package/dist/shell/config/index.d.ts +7 -0
- package/dist/shell/config/index.d.ts.map +1 -0
- package/dist/shell/config/permissions.d.ts +7 -0
- package/dist/shell/config/permissions.d.ts.map +1 -0
- package/dist/shell/config/tailwind-preset.d.ts +4 -0
- package/dist/shell/config/tailwind-preset.d.ts.map +1 -0
- package/dist/shell/config/theme/dark.d.ts +3 -0
- package/dist/shell/config/theme/dark.d.ts.map +1 -0
- package/dist/shell/config/theme/index.d.ts +6 -0
- package/dist/shell/config/theme/index.d.ts.map +1 -0
- package/dist/shell/config/theme/light.d.ts +3 -0
- package/dist/shell/config/theme/light.d.ts.map +1 -0
- package/dist/shell/config/theme/tokens.d.ts +97 -0
- package/dist/shell/config/theme/tokens.d.ts.map +1 -0
- package/dist/shell/config/theme/utils.d.ts +23 -0
- package/dist/shell/config/theme/utils.d.ts.map +1 -0
- package/dist/shell/createSaasApp.d.ts +145 -0
- package/dist/shell/createSaasApp.d.ts.map +1 -0
- package/dist/shell/hooks/index.d.ts +19 -0
- package/dist/shell/hooks/index.d.ts.map +1 -0
- package/dist/shell/hooks/useAITools.d.ts +21 -0
- package/dist/shell/hooks/useAITools.d.ts.map +1 -0
- package/dist/shell/hooks/useAuth.d.ts +16 -0
- package/dist/shell/hooks/useAuth.d.ts.map +1 -0
- package/dist/shell/hooks/useBilling.d.ts +14 -0
- package/dist/shell/hooks/useBilling.d.ts.map +1 -0
- package/dist/shell/hooks/useChat.d.ts +16 -0
- package/dist/shell/hooks/useChat.d.ts.map +1 -0
- package/dist/shell/hooks/useFieldRules.d.ts +6 -0
- package/dist/shell/hooks/useFieldRules.d.ts.map +1 -0
- package/dist/shell/hooks/useFormatters.d.ts +7 -0
- package/dist/shell/hooks/useFormatters.d.ts.map +1 -0
- package/dist/shell/hooks/useLayout.d.ts +16 -0
- package/dist/shell/hooks/useLayout.d.ts.map +1 -0
- package/dist/shell/hooks/useModuleNavigation.d.ts +25 -0
- package/dist/shell/hooks/useModuleNavigation.d.ts.map +1 -0
- package/dist/shell/hooks/useNotifications.d.ts +11 -0
- package/dist/shell/hooks/useNotifications.d.ts.map +1 -0
- package/dist/shell/hooks/usePermission.d.ts +16 -0
- package/dist/shell/hooks/usePermission.d.ts.map +1 -0
- package/dist/shell/hooks/usePluginPrefs.d.ts +23 -0
- package/dist/shell/hooks/usePluginPrefs.d.ts.map +1 -0
- package/dist/shell/hooks/usePlugins.d.ts +5 -0
- package/dist/shell/hooks/usePlugins.d.ts.map +1 -0
- package/dist/shell/hooks/useTenant.d.ts +23 -0
- package/dist/shell/hooks/useTenant.d.ts.map +1 -0
- package/dist/shell/hooks/useTenantPlugins.d.ts +10 -0
- package/dist/shell/hooks/useTenantPlugins.d.ts.map +1 -0
- package/dist/shell/hooks/useTranslation.d.ts +5 -0
- package/dist/shell/hooks/useTranslation.d.ts.map +1 -0
- package/dist/shell/lib/api.d.ts +28 -0
- package/dist/shell/lib/api.d.ts.map +1 -0
- package/dist/shell/lib/apply-field-rules.d.ts +4 -0
- package/dist/shell/lib/apply-field-rules.d.ts.map +1 -0
- package/dist/shell/lib/auth-adapters/mock.d.ts +3 -0
- package/dist/shell/lib/auth-adapters/mock.d.ts.map +1 -0
- package/dist/shell/lib/auth-adapters/supabase.d.ts +3 -0
- package/dist/shell/lib/auth-adapters/supabase.d.ts.map +1 -0
- package/dist/shell/lib/auth-context.d.ts +5 -0
- package/dist/shell/lib/auth-context.d.ts.map +1 -0
- package/dist/shell/lib/cache.d.ts +18 -0
- package/dist/shell/lib/cache.d.ts.map +1 -0
- package/dist/shell/lib/cn.d.ts +2 -0
- package/dist/shell/lib/cn.d.ts.map +1 -0
- package/dist/shell/lib/core-ai-tools.d.ts +15 -0
- package/dist/shell/lib/core-ai-tools.d.ts.map +1 -0
- package/dist/shell/lib/create-client-orders-provider.d.ts +3 -0
- package/dist/shell/lib/create-client-orders-provider.d.ts.map +1 -0
- package/dist/shell/lib/csv.d.ts +14 -0
- package/dist/shell/lib/csv.d.ts.map +1 -0
- package/dist/shell/lib/dedup.d.ts +2 -0
- package/dist/shell/lib/dedup.d.ts.map +1 -0
- package/dist/shell/lib/entity-registry.d.ts +19 -0
- package/dist/shell/lib/entity-registry.d.ts.map +1 -0
- package/dist/shell/lib/entity-routes.d.ts +24 -0
- package/dist/shell/lib/entity-routes.d.ts.map +1 -0
- package/dist/shell/lib/format.d.ts +7 -0
- package/dist/shell/lib/format.d.ts.map +1 -0
- package/dist/shell/lib/i18n.d.ts +4 -0
- package/dist/shell/lib/i18n.d.ts.map +1 -0
- package/dist/shell/lib/locale-config.d.ts +8 -0
- package/dist/shell/lib/locale-config.d.ts.map +1 -0
- package/dist/shell/lib/org-adapters/mock.d.ts +4 -0
- package/dist/shell/lib/org-adapters/mock.d.ts.map +1 -0
- package/dist/shell/lib/org-adapters/supabase.d.ts +3 -0
- package/dist/shell/lib/org-adapters/supabase.d.ts.map +1 -0
- package/dist/shell/lib/org-context.d.ts +5 -0
- package/dist/shell/lib/org-context.d.ts.map +1 -0
- package/dist/shell/lib/plugins.d.ts +2 -0
- package/dist/shell/lib/plugins.d.ts.map +1 -0
- package/dist/shell/lib/router.d.ts +15 -0
- package/dist/shell/lib/router.d.ts.map +1 -0
- package/dist/shell/lib/schedule-config.d.ts +32 -0
- package/dist/shell/lib/schedule-config.d.ts.map +1 -0
- package/dist/shell/lib/schedule-service.d.ts +76 -0
- package/dist/shell/lib/schedule-service.d.ts.map +1 -0
- package/dist/shell/lib/supabase.d.ts +9 -0
- package/dist/shell/lib/supabase.d.ts.map +1 -0
- package/dist/shell/stores/auth.store.d.ts +12 -0
- package/dist/shell/stores/auth.store.d.ts.map +1 -0
- package/dist/shell/stores/billing.store.d.ts +2 -0
- package/dist/shell/stores/billing.store.d.ts.map +1 -0
- package/dist/shell/stores/chat.store.d.ts +20 -0
- package/dist/shell/stores/chat.store.d.ts.map +1 -0
- package/dist/shell/stores/index.d.ts +13 -0
- package/dist/shell/stores/index.d.ts.map +1 -0
- package/dist/shell/stores/invite.store.d.ts +11 -0
- package/dist/shell/stores/invite.store.d.ts.map +1 -0
- package/dist/shell/stores/layout.store.d.ts +2 -0
- package/dist/shell/stores/layout.store.d.ts.map +1 -0
- package/dist/shell/stores/locale.store.d.ts +7 -0
- package/dist/shell/stores/locale.store.d.ts.map +1 -0
- package/dist/shell/stores/location.store.d.ts +20 -0
- package/dist/shell/stores/location.store.d.ts.map +1 -0
- package/dist/shell/stores/notifications.store.d.ts +12 -0
- package/dist/shell/stores/notifications.store.d.ts.map +1 -0
- package/dist/shell/stores/organization.store.d.ts +2 -0
- package/dist/shell/stores/organization.store.d.ts.map +1 -0
- package/dist/shell/stores/permissions.store.d.ts +2 -0
- package/dist/shell/stores/permissions.store.d.ts.map +1 -0
- package/dist/shell/stores/plugin.store.d.ts +24 -0
- package/dist/shell/stores/plugin.store.d.ts.map +1 -0
- package/dist/shell/stores/tenant.store.d.ts +11 -0
- package/dist/shell/stores/tenant.store.d.ts.map +1 -0
- package/dist/shell/stores/theme.store.d.ts +17 -0
- package/dist/shell/stores/theme.store.d.ts.map +1 -0
- package/dist/shell/test-setup.d.ts +2 -0
- package/dist/shell/test-setup.d.ts.map +1 -0
- package/dist/shell/types/auth-adapter.d.ts +14 -0
- package/dist/shell/types/auth-adapter.d.ts.map +1 -0
- package/dist/shell/types/auth.d.ts +34 -0
- package/dist/shell/types/auth.d.ts.map +1 -0
- package/dist/shell/types/billing.d.ts +74 -0
- package/dist/shell/types/billing.d.ts.map +1 -0
- package/dist/shell/types/client-orders.d.ts +43 -0
- package/dist/shell/types/client-orders.d.ts.map +1 -0
- package/dist/shell/types/crud.d.ts +122 -0
- package/dist/shell/types/crud.d.ts.map +1 -0
- package/dist/shell/types/entities.d.ts +150 -0
- package/dist/shell/types/entities.d.ts.map +1 -0
- package/dist/shell/types/entity-lookup.d.ts +18 -0
- package/dist/shell/types/entity-lookup.d.ts.map +1 -0
- package/dist/shell/types/index.d.ts +17 -0
- package/dist/shell/types/index.d.ts.map +1 -0
- package/dist/shell/types/integrations.d.ts +48 -0
- package/dist/shell/types/integrations.d.ts.map +1 -0
- package/dist/shell/types/invite.d.ts +23 -0
- package/dist/shell/types/invite.d.ts.map +1 -0
- package/dist/shell/types/layout.d.ts +26 -0
- package/dist/shell/types/layout.d.ts.map +1 -0
- package/dist/shell/types/notifications.d.ts +31 -0
- package/dist/shell/types/notifications.d.ts.map +1 -0
- package/dist/shell/types/org-adapter.d.ts +72 -0
- package/dist/shell/types/org-adapter.d.ts.map +1 -0
- package/dist/shell/types/permissions.d.ts +39 -0
- package/dist/shell/types/permissions.d.ts.map +1 -0
- package/dist/shell/types/platform.d.ts +25 -0
- package/dist/shell/types/platform.d.ts.map +1 -0
- package/dist/shell/types/plugins.d.ts +308 -0
- package/dist/shell/types/plugins.d.ts.map +1 -0
- package/dist/shell/types/tenant.d.ts +74 -0
- package/dist/shell/types/tenant.d.ts.map +1 -0
- package/dist/stores/createCrudStore.d.ts +32 -0
- package/dist/stores/createCrudStore.d.ts.map +1 -0
- package/dist/supabase/client.d.ts +18 -0
- package/dist/supabase/client.d.ts.map +1 -0
- package/package.json +72 -0
- package/src/app/AdminShell.tsx +449 -0
- package/src/app/LoginPage.tsx +264 -0
- package/src/app/config.ts +146 -0
- package/src/app/createFayzApp.tsx +254 -0
- package/src/app/routing.tsx +65 -0
- package/src/app/scaffold.tsx +175 -0
- package/src/archetype-lookup.ts +160 -0
- package/src/billing/index.ts +7 -0
- package/src/billing/store.ts +62 -0
- package/src/components/shared/PersonLink.tsx +199 -0
- package/src/crud/CrudCardGrid.tsx +92 -0
- package/src/crud/CrudDetailPage.tsx +366 -0
- package/src/crud/CrudFormPage.tsx +467 -0
- package/src/crud/CrudListView.tsx +223 -0
- package/src/crud/CrudPage.tsx +491 -0
- package/src/crud/DeleteConfirmDialog.tsx +41 -0
- package/src/crud/EntityOverview.tsx +230 -0
- package/src/crud/ImportWizard.tsx +690 -0
- package/src/crud/archetypes/ActiveToggle.tsx +23 -0
- package/src/crud/archetypes/ArchetypeStatusBar.tsx +58 -0
- package/src/crud/archetypes/BlockSettingsPopover.tsx +322 -0
- package/src/crud/archetypes/EntityLink.tsx +74 -0
- package/src/crud/archetypes/LocationDetailTabs.tsx +72 -0
- package/src/crud/archetypes/LocationFormLayout.tsx +173 -0
- package/src/crud/archetypes/PersonDetailTabs.tsx +87 -0
- package/src/crud/archetypes/PersonFormLayout.tsx +184 -0
- package/src/crud/archetypes/PersonPicker.tsx +299 -0
- package/src/crud/archetypes/ProductDetailTabs.tsx +72 -0
- package/src/crud/archetypes/ProductFormLayout.tsx +197 -0
- package/src/crud/archetypes/ScheduleEditor.tsx +796 -0
- package/src/crud/archetypes/ServiceDetailTabs.tsx +60 -0
- package/src/crud/archetypes/ServiceFormLayout.tsx +155 -0
- package/src/crud/archetypes/SubjectDetailTabs.tsx +142 -0
- package/src/crud/archetypes/SubjectFormLayout.tsx +164 -0
- package/src/crud/createCrudPage.tsx +65 -0
- package/src/crud/csv-export.ts +17 -0
- package/src/crud/fieldToColumn.tsx +109 -0
- package/src/crud/index.ts +11 -0
- package/src/hooks/useFieldRules.ts +10 -0
- package/src/hooks/useModuleNavigation.ts +124 -0
- package/src/hooks/usePluginPrefs.ts +113 -0
- package/src/index.ts +168 -0
- package/src/lib/currency.ts +19 -0
- package/src/lib/entity-routes.ts +53 -0
- package/src/lib/schedule-config.ts +42 -0
- package/src/lib/schedule-service.ts +307 -0
- package/src/org/adapters/mock.ts +353 -0
- package/src/org/adapters/supabase.ts +509 -0
- package/src/org/context.tsx +174 -0
- package/src/org/index.ts +19 -0
- package/src/org/store.ts +70 -0
- package/src/permissions/PermissionGate.tsx +17 -0
- package/src/permissions/context.tsx +126 -0
- package/src/permissions/index.ts +13 -0
- package/src/permissions/store.ts +68 -0
- package/src/placeholder.ts +32 -0
- package/src/plugins/ModuleActionBar.tsx +57 -0
- package/src/plugins/PluginRegistryManager.tsx +110 -0
- package/src/plugins/QuickActionsButton.tsx +73 -0
- package/src/plugins/SettingsGroup.tsx +100 -0
- package/src/plugins/WidgetSlot.tsx +38 -0
- package/src/plugins/createPluginContext.tsx +68 -0
- package/src/plugins/createViewRouter.tsx +45 -0
- package/src/shell/components/auth/CenteredLogin.tsx +86 -0
- package/src/shell/components/auth/LoginForm.tsx +129 -0
- package/src/shell/components/auth/LoginPage.tsx +22 -0
- package/src/shell/components/auth/OAuthButtons.tsx +66 -0
- package/src/shell/components/auth/ProtectedRoute.tsx +52 -0
- package/src/shell/components/auth/RecoveryForm.tsx +110 -0
- package/src/shell/components/auth/SignupForm.tsx +170 -0
- package/src/shell/components/auth/SplitLogin.tsx +124 -0
- package/src/shell/components/auth/index.ts +6 -0
- package/src/shell/components/billing/BillingPage.tsx +56 -0
- package/src/shell/components/billing/InvoiceList.tsx +123 -0
- package/src/shell/components/billing/PaywallGate.tsx +80 -0
- package/src/shell/components/billing/PlanSelector.tsx +125 -0
- package/src/shell/components/billing/SubscriptionCard.tsx +108 -0
- package/src/shell/components/billing/index.ts +5 -0
- package/src/shell/components/chat/ChatFab.tsx +195 -0
- package/src/shell/components/chat/ChatPanel.tsx +170 -0
- package/src/shell/components/chat/ChatSuggestions.tsx +102 -0
- package/src/shell/components/chat/index.ts +2 -0
- package/src/shell/components/crud/archetypes/ClientOrdersTab.tsx +212 -0
- package/src/shell/components/layout/BottomNav.tsx +131 -0
- package/src/shell/components/layout/CommandPalette.tsx +257 -0
- package/src/shell/components/layout/LocationSwitchOverlay.tsx +64 -0
- package/src/shell/components/layout/MockModeBanner.tsx +17 -0
- package/src/shell/components/layout/PrintChrome.tsx +200 -0
- package/src/shell/components/layout/index.ts +5 -0
- package/src/shell/components/notifications/ChangelogFeed.tsx +85 -0
- package/src/shell/components/notifications/NotificationBell.tsx +44 -0
- package/src/shell/components/notifications/NotificationInbox.tsx +175 -0
- package/src/shell/components/notifications/ToastProvider.tsx +2 -0
- package/src/shell/components/notifications/index.ts +4 -0
- package/src/shell/components/organization/ImpersonationBanner.tsx +29 -0
- package/src/shell/components/organization/InviteMemberDialog.tsx +161 -0
- package/src/shell/components/organization/OrgInitializer.tsx +179 -0
- package/src/shell/components/organization/OrgSwitcher.tsx +177 -0
- package/src/shell/components/organization/PermissionGate.tsx +16 -0
- package/src/shell/components/organization/PermissionMatrixEditor.tsx +206 -0
- package/src/shell/components/organization/PermissionProfilesTab.tsx +148 -0
- package/src/shell/components/organization/TeamTab.tsx +243 -0
- package/src/shell/components/organization/TenantOnboarding.tsx +179 -0
- package/src/shell/components/organization/index.ts +7 -0
- package/src/shell/components/plugins/PluginSettingsPanel.tsx +189 -0
- package/src/shell/components/settings/BrandingSettings.tsx +255 -0
- package/src/shell/components/settings/CompanySettings.tsx +188 -0
- package/src/shell/components/settings/ConnectedBrandingSettings.tsx +82 -0
- package/src/shell/components/settings/ConnectedCompanySettings.tsx +63 -0
- package/src/shell/components/settings/ConnectedFieldRulesSettings.tsx +47 -0
- package/src/shell/components/settings/ConnectedHolidaysSettings.tsx +99 -0
- package/src/shell/components/settings/ConnectedLocationsOverview.tsx +57 -0
- package/src/shell/components/settings/ConnectedSecuritySettings.tsx +59 -0
- package/src/shell/components/settings/ConnectedUserProfile.tsx +59 -0
- package/src/shell/components/settings/FieldRulesSettings.tsx +511 -0
- package/src/shell/components/settings/HolidaysSettings.tsx +141 -0
- package/src/shell/components/settings/LocationsCrudPage.ts +36 -0
- package/src/shell/components/settings/LocationsOverview.tsx +171 -0
- package/src/shell/components/settings/SecuritySettings.tsx +208 -0
- package/src/shell/components/settings/SettingsPage.tsx +162 -0
- package/src/shell/components/settings/UserProfile.tsx +151 -0
- package/src/shell/components/settings/index.ts +10 -0
- package/src/shell/config/index.ts +6 -0
- package/src/shell/config/permissions.ts +31 -0
- package/src/shell/config/tailwind-preset.ts +164 -0
- package/src/shell/config/theme/dark.ts +63 -0
- package/src/shell/config/theme/index.ts +5 -0
- package/src/shell/config/theme/light.ts +63 -0
- package/src/shell/config/theme/tokens.ts +105 -0
- package/src/shell/config/theme/utils.ts +249 -0
- package/src/shell/createSaasApp.tsx +922 -0
- package/src/shell/hooks/index.ts +18 -0
- package/src/shell/hooks/useAITools.ts +139 -0
- package/src/shell/hooks/useAuth.ts +109 -0
- package/src/shell/hooks/useBilling.ts +151 -0
- package/src/shell/hooks/useChat.ts +84 -0
- package/src/shell/hooks/useFieldRules.ts +19 -0
- package/src/shell/hooks/useFormatters.ts +56 -0
- package/src/shell/hooks/useLayout.ts +76 -0
- package/src/shell/hooks/useModuleNavigation.ts +124 -0
- package/src/shell/hooks/useNotifications.ts +114 -0
- package/src/shell/hooks/usePermission.ts +101 -0
- package/src/shell/hooks/usePluginPrefs.ts +113 -0
- package/src/shell/hooks/usePlugins.ts +18 -0
- package/src/shell/hooks/useTenant.ts +106 -0
- package/src/shell/hooks/useTenantPlugins.ts +103 -0
- package/src/shell/hooks/useTranslation.ts +10 -0
- package/src/shell/lib/api.ts +67 -0
- package/src/shell/lib/apply-field-rules.ts +14 -0
- package/src/shell/lib/auth-adapters/mock.ts +97 -0
- package/src/shell/lib/auth-adapters/supabase.ts +96 -0
- package/src/shell/lib/auth-context.ts +18 -0
- package/src/shell/lib/cache.ts +124 -0
- package/src/shell/lib/cn.ts +1 -0
- package/src/shell/lib/core-ai-tools.ts +90 -0
- package/src/shell/lib/create-client-orders-provider.ts +105 -0
- package/src/shell/lib/csv.ts +54 -0
- package/src/shell/lib/dedup.ts +17 -0
- package/src/shell/lib/entity-registry.ts +39 -0
- package/src/shell/lib/entity-routes.ts +53 -0
- package/src/shell/lib/format.ts +58 -0
- package/src/shell/lib/i18n.ts +3723 -0
- package/src/shell/lib/locale-config.ts +14 -0
- package/src/shell/lib/org-adapters/mock.ts +318 -0
- package/src/shell/lib/org-adapters/supabase.ts +533 -0
- package/src/shell/lib/org-context.ts +18 -0
- package/src/shell/lib/plugins.ts +11 -0
- package/src/shell/lib/router.ts +86 -0
- package/src/shell/lib/schedule-config.ts +42 -0
- package/src/shell/lib/schedule-service.ts +307 -0
- package/src/shell/lib/supabase.ts +19 -0
- package/src/shell/stores/auth.store.ts +29 -0
- package/src/shell/stores/billing.store.ts +1 -0
- package/src/shell/stores/chat.store.ts +45 -0
- package/src/shell/stores/index.ts +12 -0
- package/src/shell/stores/invite.store.ts +18 -0
- package/src/shell/stores/layout.store.ts +1 -0
- package/src/shell/stores/locale.store.ts +24 -0
- package/src/shell/stores/location.store.ts +89 -0
- package/src/shell/stores/notifications.store.ts +48 -0
- package/src/shell/stores/organization.store.ts +3 -0
- package/src/shell/stores/permissions.store.ts +1 -0
- package/src/shell/stores/plugin.store.ts +50 -0
- package/src/shell/stores/tenant.store.ts +26 -0
- package/src/shell/stores/theme.store.ts +162 -0
- package/src/shell/styles.css +433 -0
- package/src/shell/test-setup.ts +1 -0
- package/src/shell/types/auth-adapter.ts +11 -0
- package/src/shell/types/auth.ts +38 -0
- package/src/shell/types/billing.ts +90 -0
- package/src/shell/types/client-orders.ts +58 -0
- package/src/shell/types/crud.ts +134 -0
- package/src/shell/types/entities.ts +169 -0
- package/src/shell/types/entity-lookup.ts +25 -0
- package/src/shell/types/index.ts +16 -0
- package/src/shell/types/integrations.ts +51 -0
- package/src/shell/types/invite.ts +23 -0
- package/src/shell/types/layout.ts +29 -0
- package/src/shell/types/notifications.ts +33 -0
- package/src/shell/types/org-adapter.ts +72 -0
- package/src/shell/types/permissions.ts +64 -0
- package/src/shell/types/platform.ts +25 -0
- package/src/shell/types/plugins.ts +359 -0
- package/src/shell/types/tenant.ts +79 -0
- package/src/stores/createCrudStore.ts +138 -0
- package/src/supabase/client.ts +54 -0
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
import type { OrgAdapter, Organization, OrgMember, OrgMembership, CreateOrgOptions } from '../../types/org-adapter'
|
|
2
|
+
import type { Location } from '../../types/tenant'
|
|
3
|
+
import type { PermissionProfile, SystemPermission, PermissionAction } from '../../types/permissions'
|
|
4
|
+
import type { Invite } from '../../types/invite'
|
|
5
|
+
import { getSupabaseClient, getCoreClient, CORE_SCHEMA } from '../supabase'
|
|
6
|
+
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// Request dedup — prevents duplicate in-flight requests (React StrictMode, etc.)
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
const inflightRequests = new Map<string, Promise<any>>()
|
|
11
|
+
|
|
12
|
+
function dedup<T>(key: string, fn: () => Promise<T>): Promise<T> {
|
|
13
|
+
const existing = inflightRequests.get(key)
|
|
14
|
+
if (existing) return existing as Promise<T>
|
|
15
|
+
|
|
16
|
+
const promise = fn().finally(() => {
|
|
17
|
+
inflightRequests.delete(key)
|
|
18
|
+
})
|
|
19
|
+
inflightRequests.set(key, promise)
|
|
20
|
+
return promise
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Helpers
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
function slugify(name: string): string {
|
|
28
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function mapTenantToOrg(row: any): Organization {
|
|
32
|
+
return {
|
|
33
|
+
id: row.id,
|
|
34
|
+
name: row.name,
|
|
35
|
+
slug: row.slug,
|
|
36
|
+
logoUrl: row.logo_url ?? undefined,
|
|
37
|
+
verticalId: row.vertical_id ?? undefined,
|
|
38
|
+
plan: row.plan ?? undefined,
|
|
39
|
+
settings: row.settings ?? undefined,
|
|
40
|
+
createdAt: row.created_at,
|
|
41
|
+
updatedAt: row.updated_at,
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function mapMemberRow(row: any): OrgMember {
|
|
46
|
+
const profile = row.profile ?? {}
|
|
47
|
+
return {
|
|
48
|
+
id: row.id,
|
|
49
|
+
userId: row.user_id,
|
|
50
|
+
orgId: row.tenant_id,
|
|
51
|
+
profileId: row.role,
|
|
52
|
+
profileName: capitalize(row.role),
|
|
53
|
+
user: {
|
|
54
|
+
id: row.user_id,
|
|
55
|
+
email: profile.email ?? '',
|
|
56
|
+
fullName: profile.full_name ?? '',
|
|
57
|
+
avatarUrl: profile.avatar_url ?? undefined,
|
|
58
|
+
},
|
|
59
|
+
joinedAt: row.joined_at,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function mapLocationRow(row: any): Location {
|
|
64
|
+
return {
|
|
65
|
+
id: row.id,
|
|
66
|
+
tenantId: row.tenant_id,
|
|
67
|
+
kind: row.kind ?? 'branch',
|
|
68
|
+
name: row.name,
|
|
69
|
+
email: row.email ?? undefined,
|
|
70
|
+
phone: row.phone ?? undefined,
|
|
71
|
+
address: row.address ?? undefined,
|
|
72
|
+
city: row.city ?? undefined,
|
|
73
|
+
state: row.state ?? undefined,
|
|
74
|
+
country: row.country ?? 'BR',
|
|
75
|
+
postalCode: row.postal_code ?? undefined,
|
|
76
|
+
isHeadquarters: row.is_headquarters ?? false,
|
|
77
|
+
isActive: row.is_active ?? true,
|
|
78
|
+
tags: row.tags ?? [],
|
|
79
|
+
notes: row.notes ?? undefined,
|
|
80
|
+
metadata: row.metadata ?? row.settings ?? {},
|
|
81
|
+
createdAt: row.created_at,
|
|
82
|
+
updatedAt: row.updated_at,
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function mapInviteRow(row: any): Invite {
|
|
87
|
+
return {
|
|
88
|
+
id: row.id,
|
|
89
|
+
tenantId: row.tenant_id,
|
|
90
|
+
email: row.email,
|
|
91
|
+
role: row.role,
|
|
92
|
+
locationIds: row.location_ids ?? undefined,
|
|
93
|
+
invitedBy: row.invited_by,
|
|
94
|
+
token: row.token,
|
|
95
|
+
status: row.status ?? 'pending',
|
|
96
|
+
expiresAt: row.expires_at,
|
|
97
|
+
acceptedAt: row.accepted_at ?? undefined,
|
|
98
|
+
createdAt: row.created_at,
|
|
99
|
+
orgId: row.tenant_id,
|
|
100
|
+
profileId: row.role,
|
|
101
|
+
profileName: capitalize(row.role),
|
|
102
|
+
invitedByName: '',
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function capitalize(s: string): string {
|
|
107
|
+
return s.charAt(0).toUpperCase() + s.slice(1)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const SYSTEM_ROLES = ['owner', 'admin', 'manager', 'staff', 'viewer'] as const
|
|
111
|
+
|
|
112
|
+
const SYSTEM_PERMISSION_MAP: Record<string, SystemPermission> = {
|
|
113
|
+
'team.read': 'manage_team',
|
|
114
|
+
'team.invite': 'manage_team',
|
|
115
|
+
'team.manage': 'manage_team',
|
|
116
|
+
'team.manage_roles': 'manage_team',
|
|
117
|
+
'billing.read': 'manage_billing',
|
|
118
|
+
'billing.manage': 'manage_billing',
|
|
119
|
+
'settings.read': 'manage_settings',
|
|
120
|
+
'settings.update': 'manage_settings',
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const SYSTEM_CATEGORIES = new Set(['team', 'billing', 'settings'])
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Build PermissionProfile[] from DB permission data.
|
|
127
|
+
* Owner gets all permissions implicitly (matches the authorize() RPC).
|
|
128
|
+
*/
|
|
129
|
+
function buildPermissionProfiles(
|
|
130
|
+
permissions: { id: string; category: string }[],
|
|
131
|
+
rolePerms: { role: string; permission_id: string }[],
|
|
132
|
+
overrides: { role: string; permission_id: string; granted: boolean }[],
|
|
133
|
+
): PermissionProfile[] {
|
|
134
|
+
// Build override lookup: `role:permissionId` → granted
|
|
135
|
+
const overrideMap = new Map<string, boolean>()
|
|
136
|
+
for (const o of overrides) {
|
|
137
|
+
overrideMap.set(`${o.role}:${o.permission_id}`, o.granted)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Build role → permission set (from defaults)
|
|
141
|
+
const rolePermMap = new Map<string, Set<string>>()
|
|
142
|
+
for (const role of SYSTEM_ROLES) {
|
|
143
|
+
rolePermMap.set(role, new Set())
|
|
144
|
+
}
|
|
145
|
+
// Owner gets everything
|
|
146
|
+
for (const p of permissions) {
|
|
147
|
+
rolePermMap.get('owner')!.add(p.id)
|
|
148
|
+
}
|
|
149
|
+
for (const rp of rolePerms) {
|
|
150
|
+
rolePermMap.get(rp.role)?.add(rp.permission_id)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Apply overrides
|
|
154
|
+
for (const [key, granted] of overrideMap) {
|
|
155
|
+
const [role, permId] = key.split(':')
|
|
156
|
+
const perms = rolePermMap.get(role)
|
|
157
|
+
if (!perms) continue
|
|
158
|
+
if (granted) {
|
|
159
|
+
perms.add(permId)
|
|
160
|
+
} else {
|
|
161
|
+
perms.delete(permId)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return SYSTEM_ROLES.map((role) => {
|
|
166
|
+
const permIds = rolePermMap.get(role)!
|
|
167
|
+
|
|
168
|
+
// System permissions (team/billing/settings management)
|
|
169
|
+
const systemPermissions: SystemPermission[] = []
|
|
170
|
+
const seenSystem = new Set<SystemPermission>()
|
|
171
|
+
for (const permId of permIds) {
|
|
172
|
+
const sp = SYSTEM_PERMISSION_MAP[permId]
|
|
173
|
+
if (sp && !seenSystem.has(sp)) {
|
|
174
|
+
seenSystem.add(sp)
|
|
175
|
+
systemPermissions.push(sp)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Owner always gets all system permissions
|
|
179
|
+
if (role === 'owner') {
|
|
180
|
+
const allSystem: SystemPermission[] = ['manage_team', 'manage_billing', 'manage_settings', 'manage_permissions']
|
|
181
|
+
for (const sp of allSystem) {
|
|
182
|
+
if (!seenSystem.has(sp)) {
|
|
183
|
+
seenSystem.add(sp)
|
|
184
|
+
systemPermissions.push(sp)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Grants: group non-system permissions by category → actions
|
|
190
|
+
const grants: Record<string, PermissionAction[]> = {}
|
|
191
|
+
for (const permId of permIds) {
|
|
192
|
+
const perm = permissions.find((p) => p.id === permId)
|
|
193
|
+
if (!perm || SYSTEM_CATEGORIES.has(perm.category)) continue
|
|
194
|
+
|
|
195
|
+
// permId format: "category.action" e.g. "locations.read"
|
|
196
|
+
const dotIdx = permId.indexOf('.')
|
|
197
|
+
if (dotIdx === -1) continue
|
|
198
|
+
const category = permId.slice(0, dotIdx)
|
|
199
|
+
const action = permId.slice(dotIdx + 1)
|
|
200
|
+
|
|
201
|
+
// Map DB actions to PermissionAction
|
|
202
|
+
const actionMap: Record<string, PermissionAction> = {
|
|
203
|
+
read: 'read',
|
|
204
|
+
create: 'create',
|
|
205
|
+
update: 'edit',
|
|
206
|
+
manage: 'edit',
|
|
207
|
+
delete: 'delete',
|
|
208
|
+
configure: 'edit',
|
|
209
|
+
invite: 'create',
|
|
210
|
+
}
|
|
211
|
+
const mappedAction = actionMap[action]
|
|
212
|
+
if (!mappedAction) continue
|
|
213
|
+
|
|
214
|
+
if (!grants[category]) grants[category] = []
|
|
215
|
+
if (!grants[category].includes(mappedAction)) {
|
|
216
|
+
grants[category].push(mappedAction)
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return {
|
|
221
|
+
id: role,
|
|
222
|
+
name: capitalize(role),
|
|
223
|
+
isSystem: true,
|
|
224
|
+
systemPermissions,
|
|
225
|
+
grants,
|
|
226
|
+
}
|
|
227
|
+
})
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// ---------------------------------------------------------------------------
|
|
231
|
+
// Adapter factory
|
|
232
|
+
// ---------------------------------------------------------------------------
|
|
233
|
+
|
|
234
|
+
export function createSupabaseOrgAdapter(): OrgAdapter {
|
|
235
|
+
const supabase = getSupabaseClient()
|
|
236
|
+
/** Core-schema scoped queries */
|
|
237
|
+
const core = () => supabase.schema(CORE_SCHEMA)
|
|
238
|
+
|
|
239
|
+
return {
|
|
240
|
+
async listUserOrgs(userId: string): Promise<OrgMembership[]> {
|
|
241
|
+
return dedup(`listUserOrgs:${userId}`, async () => {
|
|
242
|
+
const { data, error } = await core()
|
|
243
|
+
.from('tenant_members')
|
|
244
|
+
.select('tenant_id, role, tenant:tenants(id, name, slug, logo_url)')
|
|
245
|
+
.eq('user_id', userId)
|
|
246
|
+
|
|
247
|
+
if (error) throw error
|
|
248
|
+
|
|
249
|
+
return (data ?? []).map((row: any) => ({
|
|
250
|
+
orgId: row.tenant_id,
|
|
251
|
+
orgName: row.tenant?.name ?? '',
|
|
252
|
+
orgSlug: row.tenant?.slug ?? '',
|
|
253
|
+
orgLogoUrl: row.tenant?.logo_url ?? undefined,
|
|
254
|
+
profileId: row.role,
|
|
255
|
+
profileName: capitalize(row.role),
|
|
256
|
+
}))
|
|
257
|
+
})
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
async getOrg(orgId: string): Promise<Organization> {
|
|
261
|
+
const { data, error } = await core()
|
|
262
|
+
.from('tenants')
|
|
263
|
+
.select('*')
|
|
264
|
+
.eq('id', orgId)
|
|
265
|
+
.single()
|
|
266
|
+
|
|
267
|
+
if (error) throw error
|
|
268
|
+
return mapTenantToOrg(data)
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
async createOrg(name: string, userId: string, options?: CreateOrgOptions): Promise<Organization> {
|
|
272
|
+
// Use SECURITY DEFINER RPC to create tenant + owner in one atomic operation
|
|
273
|
+
// This bypasses RLS chicken-and-egg: can't SELECT tenant without membership, can't add membership without tenant ID
|
|
274
|
+
const { data: tenant, error } = await supabase
|
|
275
|
+
.rpc('create_tenant_with_owner', {
|
|
276
|
+
p_name: name,
|
|
277
|
+
p_slug: slugify(name),
|
|
278
|
+
p_user_id: userId,
|
|
279
|
+
p_vertical_id: options?.verticalId ?? null,
|
|
280
|
+
p_plan: 'free',
|
|
281
|
+
p_settings: {
|
|
282
|
+
timezone: options?.timezone ?? 'America/Sao_Paulo',
|
|
283
|
+
currency: options?.currency ?? 'BRL',
|
|
284
|
+
locale: options?.locale ?? 'pt-BR',
|
|
285
|
+
teamSize: options?.teamSize ?? undefined,
|
|
286
|
+
branding: {},
|
|
287
|
+
},
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
if (error) throw error
|
|
291
|
+
|
|
292
|
+
// Plugin provisioning handled by Fayz platform — not per-SaaS
|
|
293
|
+
|
|
294
|
+
return mapTenantToOrg(tenant)
|
|
295
|
+
},
|
|
296
|
+
|
|
297
|
+
async updateOrg(orgId: string, updates: Partial<Organization>): Promise<Organization> {
|
|
298
|
+
const row: Record<string, unknown> = {}
|
|
299
|
+
if (updates.name !== undefined) row.name = updates.name
|
|
300
|
+
if (updates.slug !== undefined) row.slug = updates.slug
|
|
301
|
+
if (updates.logoUrl !== undefined) row.logo_url = updates.logoUrl
|
|
302
|
+
if (updates.verticalId !== undefined) row.vertical_id = updates.verticalId
|
|
303
|
+
if (updates.plan !== undefined) row.plan = updates.plan
|
|
304
|
+
if (updates.settings !== undefined) row.settings = updates.settings
|
|
305
|
+
|
|
306
|
+
const { data, error } = await core()
|
|
307
|
+
.from('tenants')
|
|
308
|
+
.update(row)
|
|
309
|
+
.eq('id', orgId)
|
|
310
|
+
.select()
|
|
311
|
+
.single()
|
|
312
|
+
|
|
313
|
+
if (error) throw error
|
|
314
|
+
return mapTenantToOrg(data)
|
|
315
|
+
},
|
|
316
|
+
|
|
317
|
+
async listMembers(orgId: string): Promise<OrgMember[]> {
|
|
318
|
+
const { data, error } = await core()
|
|
319
|
+
.from('tenant_members')
|
|
320
|
+
.select('*')
|
|
321
|
+
.eq('tenant_id', orgId)
|
|
322
|
+
|
|
323
|
+
if (error) throw error
|
|
324
|
+
|
|
325
|
+
// Fetch profiles separately (no direct FK between tenant_members and profiles)
|
|
326
|
+
const userIds = (data ?? []).map((m: any) => m.user_id)
|
|
327
|
+
const { data: profiles } = userIds.length > 0
|
|
328
|
+
? await core().from('profiles').select('id, full_name, avatar_url, email').in('id', userIds)
|
|
329
|
+
: { data: [] }
|
|
330
|
+
|
|
331
|
+
const profileMap = new Map((profiles ?? []).map((p: any) => [p.id, p]))
|
|
332
|
+
|
|
333
|
+
return (data ?? []).map((row: any) => {
|
|
334
|
+
const profile = profileMap.get(row.user_id) ?? {}
|
|
335
|
+
return mapMemberRow({ ...row, profile })
|
|
336
|
+
})
|
|
337
|
+
},
|
|
338
|
+
|
|
339
|
+
async updateMemberProfile(orgId: string, memberId: string, profileId: string): Promise<void> {
|
|
340
|
+
const { error } = await core()
|
|
341
|
+
.from('tenant_members')
|
|
342
|
+
.update({ role: profileId })
|
|
343
|
+
.eq('id', memberId)
|
|
344
|
+
.eq('tenant_id', orgId)
|
|
345
|
+
|
|
346
|
+
if (error) throw error
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
async removeMember(orgId: string, memberId: string): Promise<void> {
|
|
350
|
+
const { error } = await core()
|
|
351
|
+
.from('tenant_members')
|
|
352
|
+
.delete()
|
|
353
|
+
.eq('id', memberId)
|
|
354
|
+
.eq('tenant_id', orgId)
|
|
355
|
+
|
|
356
|
+
if (error) throw error
|
|
357
|
+
},
|
|
358
|
+
|
|
359
|
+
async listProfiles(orgId: string): Promise<PermissionProfile[]> {
|
|
360
|
+
// Fetch all permissions, default role mappings, and tenant overrides in parallel
|
|
361
|
+
const [permsResult, rolePermsResult, overridesResult] = await Promise.all([
|
|
362
|
+
core().from('permissions').select('id, category'),
|
|
363
|
+
core().from('role_permissions').select('role, permission_id'),
|
|
364
|
+
core().from('tenant_role_overrides').select('role, permission_id, granted').eq('tenant_id', orgId),
|
|
365
|
+
])
|
|
366
|
+
|
|
367
|
+
if (permsResult.error) throw permsResult.error
|
|
368
|
+
if (rolePermsResult.error) throw rolePermsResult.error
|
|
369
|
+
if (overridesResult.error) throw overridesResult.error
|
|
370
|
+
|
|
371
|
+
return buildPermissionProfiles(
|
|
372
|
+
permsResult.data ?? [],
|
|
373
|
+
rolePermsResult.data ?? [],
|
|
374
|
+
overridesResult.data ?? [],
|
|
375
|
+
)
|
|
376
|
+
},
|
|
377
|
+
|
|
378
|
+
async createProfile(_orgId: string, _profile: Omit<PermissionProfile, 'id' | 'isSystem'>): Promise<PermissionProfile> {
|
|
379
|
+
throw new Error('Custom roles are not supported. Roles are system-defined (owner, admin, manager, staff, viewer).')
|
|
380
|
+
},
|
|
381
|
+
|
|
382
|
+
async updateProfile(orgId: string, profileId: string, data: Partial<PermissionProfile>): Promise<PermissionProfile> {
|
|
383
|
+
// profileId is a role name — update overrides for this role
|
|
384
|
+
if (data.grants) {
|
|
385
|
+
// Delete existing overrides for this role, then re-insert
|
|
386
|
+
await core()
|
|
387
|
+
.from('tenant_role_overrides')
|
|
388
|
+
.delete()
|
|
389
|
+
.eq('tenant_id', orgId)
|
|
390
|
+
.eq('role', profileId)
|
|
391
|
+
|
|
392
|
+
const overrides: { tenant_id: string; role: string; permission_id: string; granted: boolean }[] = []
|
|
393
|
+
for (const [category, actions] of Object.entries(data.grants)) {
|
|
394
|
+
for (const action of actions) {
|
|
395
|
+
const actionMap: Record<string, string> = {
|
|
396
|
+
read: 'read',
|
|
397
|
+
create: 'create',
|
|
398
|
+
edit: 'update',
|
|
399
|
+
delete: 'delete',
|
|
400
|
+
}
|
|
401
|
+
const dbAction = actionMap[action] ?? action
|
|
402
|
+
overrides.push({
|
|
403
|
+
tenant_id: orgId,
|
|
404
|
+
role: profileId,
|
|
405
|
+
permission_id: `${category}.${dbAction}`,
|
|
406
|
+
granted: true,
|
|
407
|
+
})
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if (overrides.length > 0) {
|
|
412
|
+
const { error } = await core()
|
|
413
|
+
.from('tenant_role_overrides')
|
|
414
|
+
.insert(overrides)
|
|
415
|
+
|
|
416
|
+
if (error) throw error
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// Re-fetch the updated profile
|
|
421
|
+
const profiles = await this.listProfiles(orgId)
|
|
422
|
+
const updated = profiles.find((p) => p.id === profileId)
|
|
423
|
+
if (!updated) throw new Error(`Profile not found: ${profileId}`)
|
|
424
|
+
return updated
|
|
425
|
+
},
|
|
426
|
+
|
|
427
|
+
async deleteProfile(_orgId: string, _profileId: string): Promise<void> {
|
|
428
|
+
throw new Error('System roles cannot be deleted.')
|
|
429
|
+
},
|
|
430
|
+
|
|
431
|
+
async listInvites(orgId: string): Promise<Invite[]> {
|
|
432
|
+
const { data, error } = await core()
|
|
433
|
+
.from('invitations')
|
|
434
|
+
.select('*')
|
|
435
|
+
.eq('tenant_id', orgId)
|
|
436
|
+
.order('created_at', { ascending: false })
|
|
437
|
+
|
|
438
|
+
if (error) throw error
|
|
439
|
+
return (data ?? []).map(mapInviteRow)
|
|
440
|
+
},
|
|
441
|
+
|
|
442
|
+
async createInvite(orgId: string, email: string, profileId: string, invitedBy: string): Promise<Invite> {
|
|
443
|
+
const { data, error } = await core()
|
|
444
|
+
.from('invitations')
|
|
445
|
+
.insert({
|
|
446
|
+
tenant_id: orgId,
|
|
447
|
+
email,
|
|
448
|
+
role: profileId,
|
|
449
|
+
invited_by: invitedBy,
|
|
450
|
+
})
|
|
451
|
+
.select()
|
|
452
|
+
.single()
|
|
453
|
+
|
|
454
|
+
if (error) throw error
|
|
455
|
+
return mapInviteRow(data)
|
|
456
|
+
},
|
|
457
|
+
|
|
458
|
+
async bulkInvite(orgId: string, emails: string[], profileId: string, invitedBy: string): Promise<Invite[]> {
|
|
459
|
+
const rows = emails.map((email) => ({
|
|
460
|
+
tenant_id: orgId,
|
|
461
|
+
email,
|
|
462
|
+
role: profileId,
|
|
463
|
+
invited_by: invitedBy,
|
|
464
|
+
}))
|
|
465
|
+
|
|
466
|
+
const { data, error } = await core()
|
|
467
|
+
.from('invitations')
|
|
468
|
+
.insert(rows)
|
|
469
|
+
.select()
|
|
470
|
+
|
|
471
|
+
if (error) throw error
|
|
472
|
+
return (data ?? []).map(mapInviteRow)
|
|
473
|
+
},
|
|
474
|
+
|
|
475
|
+
async revokeInvite(orgId: string, inviteId: string): Promise<void> {
|
|
476
|
+
const { error } = await core()
|
|
477
|
+
.from('invitations')
|
|
478
|
+
.update({ status: 'revoked' })
|
|
479
|
+
.eq('id', inviteId)
|
|
480
|
+
.eq('tenant_id', orgId)
|
|
481
|
+
|
|
482
|
+
if (error) throw error
|
|
483
|
+
},
|
|
484
|
+
|
|
485
|
+
async resendInvite(orgId: string, inviteId: string): Promise<Invite> {
|
|
486
|
+
const { data, error } = await core()
|
|
487
|
+
.from('invitations')
|
|
488
|
+
.update({
|
|
489
|
+
status: 'pending',
|
|
490
|
+
expires_at: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString(),
|
|
491
|
+
})
|
|
492
|
+
.eq('id', inviteId)
|
|
493
|
+
.eq('tenant_id', orgId)
|
|
494
|
+
.select()
|
|
495
|
+
.single()
|
|
496
|
+
|
|
497
|
+
if (error) throw error
|
|
498
|
+
return mapInviteRow(data)
|
|
499
|
+
},
|
|
500
|
+
|
|
501
|
+
async listLocations(orgId: string): Promise<Location[]> {
|
|
502
|
+
const { data, error } = await core()
|
|
503
|
+
.from('locations')
|
|
504
|
+
.select('*')
|
|
505
|
+
.eq('tenant_id', orgId)
|
|
506
|
+
.order('is_headquarters', { ascending: false })
|
|
507
|
+
.order('name')
|
|
508
|
+
|
|
509
|
+
if (error) throw error
|
|
510
|
+
return (data ?? []).map(mapLocationRow)
|
|
511
|
+
},
|
|
512
|
+
|
|
513
|
+
async createLocation(orgId: string, input: { name: string; address?: string; city?: string; state?: string; country?: string; phone?: string; isHeadquarters?: boolean }): Promise<Location> {
|
|
514
|
+
const { data, error } = await core()
|
|
515
|
+
.from('locations')
|
|
516
|
+
.insert({
|
|
517
|
+
tenant_id: orgId,
|
|
518
|
+
name: input.name,
|
|
519
|
+
address: input.address || null,
|
|
520
|
+
city: input.city || null,
|
|
521
|
+
state: input.state || null,
|
|
522
|
+
country: input.country || 'BR',
|
|
523
|
+
phone: input.phone || null,
|
|
524
|
+
is_headquarters: input.isHeadquarters ?? false,
|
|
525
|
+
})
|
|
526
|
+
.select()
|
|
527
|
+
.single()
|
|
528
|
+
|
|
529
|
+
if (error) throw error
|
|
530
|
+
return mapLocationRow(data)
|
|
531
|
+
},
|
|
532
|
+
}
|
|
533
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react'
|
|
2
|
+
import type { OrgAdapter } from '../types/org-adapter'
|
|
3
|
+
|
|
4
|
+
const OrgAdapterContext = createContext<OrgAdapter | null>(null)
|
|
5
|
+
|
|
6
|
+
export const OrgAdapterProvider = OrgAdapterContext.Provider
|
|
7
|
+
|
|
8
|
+
export function useOrgAdapter(): OrgAdapter {
|
|
9
|
+
const adapter = useContext(OrgAdapterContext)
|
|
10
|
+
if (!adapter) {
|
|
11
|
+
throw new Error('useOrgAdapter must be used within an OrgAdapterProvider')
|
|
12
|
+
}
|
|
13
|
+
return adapter
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function useOrgAdapterOptional(): OrgAdapter | null {
|
|
17
|
+
return useContext(OrgAdapterContext)
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Shim → native plugin runtime (@fayz-ai/core), so the shell + native WidgetSlot
|
|
2
|
+
// share one PluginRuntime context.
|
|
3
|
+
export {
|
|
4
|
+
resolvePluginRuntime,
|
|
5
|
+
getWidgetsForZone,
|
|
6
|
+
usePluginRuntime,
|
|
7
|
+
usePluginRuntimeOptional,
|
|
8
|
+
PluginRuntimeProvider,
|
|
9
|
+
definePlugin,
|
|
10
|
+
resolvePluginComponent,
|
|
11
|
+
} from '@fayz-ai/core'
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
export interface RouterAdapter {
|
|
4
|
+
navigate: (path: string) => void
|
|
5
|
+
usePathname: () => string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function windowRouterAdapter(): RouterAdapter {
|
|
9
|
+
return {
|
|
10
|
+
navigate: (path) => {
|
|
11
|
+
window.location.href = path
|
|
12
|
+
},
|
|
13
|
+
usePathname: () => {
|
|
14
|
+
const [pathname, setPathname] = React.useState(
|
|
15
|
+
typeof window !== 'undefined' ? window.location.pathname : '/'
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
const handler = () => setPathname(window.location.pathname)
|
|
20
|
+
window.addEventListener('popstate', handler)
|
|
21
|
+
return () => window.removeEventListener('popstate', handler)
|
|
22
|
+
}, [])
|
|
23
|
+
|
|
24
|
+
return pathname
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function hashRouterAdapter(): RouterAdapter {
|
|
30
|
+
return {
|
|
31
|
+
navigate: (path) => {
|
|
32
|
+
window.location.hash = path
|
|
33
|
+
},
|
|
34
|
+
usePathname: () => {
|
|
35
|
+
const [pathname, setPathname] = React.useState(
|
|
36
|
+
typeof window !== 'undefined' ? window.location.hash.slice(1) || '/' : '/'
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
const handler = () => setPathname(window.location.hash.slice(1) || '/')
|
|
41
|
+
window.addEventListener('hashchange', handler)
|
|
42
|
+
return () => window.removeEventListener('hashchange', handler)
|
|
43
|
+
}, [])
|
|
44
|
+
|
|
45
|
+
return pathname
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function reactRouterAdapter(
|
|
51
|
+
navigateFn: (path: string) => void,
|
|
52
|
+
useLocationHook: () => { pathname: string }
|
|
53
|
+
): RouterAdapter {
|
|
54
|
+
return {
|
|
55
|
+
navigate: navigateFn,
|
|
56
|
+
usePathname: () => useLocationHook().pathname,
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// --- Module-level singleton (avoids React context issues with linked packages) ---
|
|
61
|
+
|
|
62
|
+
let _globalRouter: RouterAdapter | null = null
|
|
63
|
+
|
|
64
|
+
export function setGlobalRouter(adapter: RouterAdapter): void {
|
|
65
|
+
_globalRouter = adapter
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function getGlobalRouter(): RouterAdapter {
|
|
69
|
+
return _globalRouter ?? windowRouterAdapter()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// --- React Context (still available, but useRouter prefers singleton) ---
|
|
73
|
+
|
|
74
|
+
const RouterContext = React.createContext<RouterAdapter | null>(null)
|
|
75
|
+
|
|
76
|
+
export const RouterProvider = RouterContext.Provider
|
|
77
|
+
|
|
78
|
+
export function useRouter(): RouterAdapter {
|
|
79
|
+
// Prefer context if available
|
|
80
|
+
const ctx = React.useContext(RouterContext)
|
|
81
|
+
if (ctx) return ctx
|
|
82
|
+
// Fall back to module singleton
|
|
83
|
+
if (_globalRouter) return _globalRouter
|
|
84
|
+
// Last resort
|
|
85
|
+
return windowRouterAdapter()
|
|
86
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Schedule Block Config Registry
|
|
3
|
+
// Lightweight global config — set by the agenda plugin, read by ScheduleEditor.
|
|
4
|
+
// No React context needed. Graceful degradation when not configured.
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
export interface ScheduleBlockConfig {
|
|
8
|
+
defaults: {
|
|
9
|
+
bufferMinutes: number
|
|
10
|
+
maxConcurrent: number
|
|
11
|
+
minAdvanceHours: number
|
|
12
|
+
maxAdvanceDays: number
|
|
13
|
+
}
|
|
14
|
+
/** Available services for the multi-select filter. */
|
|
15
|
+
services?: { id: string; name: string }[]
|
|
16
|
+
showServices?: boolean
|
|
17
|
+
showConcurrent?: boolean
|
|
18
|
+
showBookingWindow?: boolean
|
|
19
|
+
/** Available locations for per-block assignment. */
|
|
20
|
+
locations?: { id: string; name: string }[]
|
|
21
|
+
showLocations?: boolean
|
|
22
|
+
/** Lazy fetcher — called when locations are needed but not yet loaded. */
|
|
23
|
+
fetchLocations?: () => Promise<{ id: string; name: string }[]>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let globalConfig: ScheduleBlockConfig | null = null
|
|
27
|
+
const listeners = new Set<() => void>()
|
|
28
|
+
|
|
29
|
+
export function setScheduleBlockConfig(config: ScheduleBlockConfig): void {
|
|
30
|
+
globalConfig = config
|
|
31
|
+
listeners.forEach((fn) => fn())
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getScheduleBlockConfig(): ScheduleBlockConfig | null {
|
|
35
|
+
return globalConfig
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Subscribe to config changes. Returns unsubscribe function. */
|
|
39
|
+
export function subscribeScheduleBlockConfig(listener: () => void): () => void {
|
|
40
|
+
listeners.add(listener)
|
|
41
|
+
return () => { listeners.delete(listener) }
|
|
42
|
+
}
|