@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,816 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var supabaseJs = require('@supabase/supabase-js');
|
|
4
|
+
var core = require('@fayz-ai/core');
|
|
5
|
+
var zustand = require('zustand');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var auth = require('@fayz-ai/auth');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
function _interopNamespace(e) {
|
|
11
|
+
if (e && e.__esModule) return e;
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
Object.keys(e).forEach(function (k) {
|
|
15
|
+
if (k !== 'default') {
|
|
16
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return e[k]; }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
|
+
|
|
30
|
+
// src/supabase/client.ts
|
|
31
|
+
var CORE_SCHEMA = "saas_core";
|
|
32
|
+
var _client = null;
|
|
33
|
+
function createFayzSupabaseClient(url, anonKey) {
|
|
34
|
+
if (_client) return _client;
|
|
35
|
+
if (!url || !anonKey) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
"[@fayz-ai/saas] Supabase URL and anon key are required. Pass supabaseUrl and supabaseAnonKey to createFayzApp."
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
_client = supabaseJs.createClient(url, anonKey, {
|
|
41
|
+
auth: { autoRefreshToken: true, persistSession: true }
|
|
42
|
+
});
|
|
43
|
+
core.setGlobalSupabaseClient(_client);
|
|
44
|
+
return _client;
|
|
45
|
+
}
|
|
46
|
+
function getFayzSupabaseClient() {
|
|
47
|
+
if (!_client) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
"[@fayz-ai/saas] Supabase client not initialised. Call createFayzApp with supabaseUrl and supabaseAnonKey first."
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
return _client;
|
|
53
|
+
}
|
|
54
|
+
function getFayzSupabaseClientOptional() {
|
|
55
|
+
return _client;
|
|
56
|
+
}
|
|
57
|
+
function getCoreSchemaClient() {
|
|
58
|
+
return getFayzSupabaseClient().schema(CORE_SCHEMA);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/org/adapters/supabase.ts
|
|
62
|
+
var inflightRequests = /* @__PURE__ */ new Map();
|
|
63
|
+
function dedup(key, fn) {
|
|
64
|
+
const existing = inflightRequests.get(key);
|
|
65
|
+
if (existing) return existing;
|
|
66
|
+
const promise = fn().finally(() => {
|
|
67
|
+
inflightRequests.delete(key);
|
|
68
|
+
});
|
|
69
|
+
inflightRequests.set(key, promise);
|
|
70
|
+
return promise;
|
|
71
|
+
}
|
|
72
|
+
function slugify(name) {
|
|
73
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
74
|
+
}
|
|
75
|
+
function capitalize(s) {
|
|
76
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
77
|
+
}
|
|
78
|
+
function mapTenantToOrg(row) {
|
|
79
|
+
return {
|
|
80
|
+
id: row["id"],
|
|
81
|
+
name: row["name"],
|
|
82
|
+
slug: row["slug"],
|
|
83
|
+
logoUrl: row["logo_url"] ?? void 0,
|
|
84
|
+
verticalId: row["vertical_id"] ?? void 0,
|
|
85
|
+
plan: row["plan"] ?? void 0,
|
|
86
|
+
settings: row["settings"] ?? void 0,
|
|
87
|
+
createdAt: row["created_at"],
|
|
88
|
+
updatedAt: row["updated_at"]
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function mapMemberRow(row) {
|
|
92
|
+
const profile = row["profile"] ?? {};
|
|
93
|
+
return {
|
|
94
|
+
id: row["id"],
|
|
95
|
+
userId: row["user_id"],
|
|
96
|
+
orgId: row["tenant_id"],
|
|
97
|
+
profileId: row["role"],
|
|
98
|
+
profileName: capitalize(row["role"]),
|
|
99
|
+
user: {
|
|
100
|
+
id: row["user_id"],
|
|
101
|
+
email: profile["email"] ?? "",
|
|
102
|
+
fullName: profile["full_name"] ?? "",
|
|
103
|
+
avatarUrl: profile["avatar_url"] ?? void 0
|
|
104
|
+
},
|
|
105
|
+
joinedAt: row["joined_at"]
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function mapLocationRow(row) {
|
|
109
|
+
return {
|
|
110
|
+
id: row["id"],
|
|
111
|
+
tenantId: row["tenant_id"],
|
|
112
|
+
name: row["name"],
|
|
113
|
+
address: row["address"] ?? void 0,
|
|
114
|
+
city: row["city"] ?? void 0,
|
|
115
|
+
state: row["state"] ?? void 0,
|
|
116
|
+
country: row["country"] ?? void 0,
|
|
117
|
+
phone: row["phone"] ?? void 0,
|
|
118
|
+
isHeadquarters: row["is_headquarters"] ?? false,
|
|
119
|
+
isActive: row["is_active"] ?? true,
|
|
120
|
+
createdAt: row["created_at"],
|
|
121
|
+
updatedAt: row["updated_at"]
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function mapInviteRow(row) {
|
|
125
|
+
return {
|
|
126
|
+
id: row["id"],
|
|
127
|
+
orgId: row["tenant_id"],
|
|
128
|
+
email: row["email"],
|
|
129
|
+
profileId: row["role"],
|
|
130
|
+
profileName: capitalize(row["role"]),
|
|
131
|
+
invitedBy: row["invited_by"],
|
|
132
|
+
token: row["token"],
|
|
133
|
+
status: row["status"] ?? "pending",
|
|
134
|
+
createdAt: row["created_at"],
|
|
135
|
+
expiresAt: row["expires_at"]
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
var SYSTEM_ROLES = ["owner", "admin", "manager", "staff", "viewer"];
|
|
139
|
+
function buildPermissionProfiles(permissions, rolePerms, overrides) {
|
|
140
|
+
const overrideMap = /* @__PURE__ */ new Map();
|
|
141
|
+
for (const o of overrides) {
|
|
142
|
+
overrideMap.set(`${o.role}:${o.permission_id}`, o.granted);
|
|
143
|
+
}
|
|
144
|
+
const rolePermMap = /* @__PURE__ */ new Map();
|
|
145
|
+
for (const role of SYSTEM_ROLES) {
|
|
146
|
+
rolePermMap.set(role, /* @__PURE__ */ new Set());
|
|
147
|
+
}
|
|
148
|
+
for (const p of permissions) {
|
|
149
|
+
rolePermMap.get("owner").add(p.id);
|
|
150
|
+
}
|
|
151
|
+
for (const rp of rolePerms) {
|
|
152
|
+
rolePermMap.get(rp.role)?.add(rp.permission_id);
|
|
153
|
+
}
|
|
154
|
+
for (const [key, granted] of overrideMap) {
|
|
155
|
+
const colonIdx = key.indexOf(":");
|
|
156
|
+
const role = key.slice(0, colonIdx);
|
|
157
|
+
const permId = key.slice(colonIdx + 1);
|
|
158
|
+
const perms = rolePermMap.get(role);
|
|
159
|
+
if (!perms) continue;
|
|
160
|
+
if (granted) {
|
|
161
|
+
perms.add(permId);
|
|
162
|
+
} else {
|
|
163
|
+
perms.delete(permId);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const actionMap = {
|
|
167
|
+
read: "read",
|
|
168
|
+
create: "write",
|
|
169
|
+
update: "write",
|
|
170
|
+
manage: "manage",
|
|
171
|
+
delete: "delete",
|
|
172
|
+
configure: "manage",
|
|
173
|
+
invite: "write"
|
|
174
|
+
};
|
|
175
|
+
return SYSTEM_ROLES.map((role) => {
|
|
176
|
+
const permIds = rolePermMap.get(role);
|
|
177
|
+
const features = {};
|
|
178
|
+
for (const permId of permIds) {
|
|
179
|
+
const dotIdx = permId.indexOf(".");
|
|
180
|
+
if (dotIdx === -1) continue;
|
|
181
|
+
const category = permId.slice(0, dotIdx);
|
|
182
|
+
const action = permId.slice(dotIdx + 1);
|
|
183
|
+
const mappedAction = actionMap[action];
|
|
184
|
+
if (!mappedAction) continue;
|
|
185
|
+
if (!features[category]) features[category] = [];
|
|
186
|
+
if (!features[category].includes(mappedAction)) {
|
|
187
|
+
features[category].push(mappedAction);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
id: role,
|
|
192
|
+
name: capitalize(role),
|
|
193
|
+
isSystem: true,
|
|
194
|
+
grants: features
|
|
195
|
+
};
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function createSupabaseOrgAdapter(config) {
|
|
199
|
+
const schema = config?.coreSchema ?? CORE_SCHEMA;
|
|
200
|
+
function supabase() {
|
|
201
|
+
return getFayzSupabaseClient();
|
|
202
|
+
}
|
|
203
|
+
function core() {
|
|
204
|
+
return supabase().schema(schema);
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
async listUserOrgs(userId) {
|
|
208
|
+
return dedup(`listUserOrgs:${userId}`, async () => {
|
|
209
|
+
const { data, error } = await core().from("tenant_members").select("tenant_id, role, tenant:tenants(id, name, slug, logo_url)").eq("user_id", userId);
|
|
210
|
+
if (error) throw error;
|
|
211
|
+
return (data ?? []).map((row) => ({
|
|
212
|
+
orgId: row["tenant_id"],
|
|
213
|
+
orgName: row["tenant"]?.["name"] ?? "",
|
|
214
|
+
orgSlug: row["tenant"]?.["slug"] ?? "",
|
|
215
|
+
orgLogoUrl: row["tenant"]?.["logo_url"] ?? void 0,
|
|
216
|
+
profileId: row["role"],
|
|
217
|
+
profileName: capitalize(row["role"])
|
|
218
|
+
}));
|
|
219
|
+
});
|
|
220
|
+
},
|
|
221
|
+
async getOrg(orgId) {
|
|
222
|
+
const { data, error } = await core().from("tenants").select("*").eq("id", orgId).single();
|
|
223
|
+
if (error) throw error;
|
|
224
|
+
return mapTenantToOrg(data);
|
|
225
|
+
},
|
|
226
|
+
async createOrg(name, userId, options) {
|
|
227
|
+
const { data: tenant, error } = await supabase().rpc("create_tenant_with_owner", {
|
|
228
|
+
p_name: name,
|
|
229
|
+
p_slug: slugify(name),
|
|
230
|
+
p_user_id: userId,
|
|
231
|
+
p_vertical_id: options?.verticalId ?? null,
|
|
232
|
+
p_plan: "free",
|
|
233
|
+
p_settings: {
|
|
234
|
+
timezone: options?.timezone ?? "America/Sao_Paulo",
|
|
235
|
+
currency: options?.currency ?? "BRL",
|
|
236
|
+
locale: options?.locale ?? "pt-BR",
|
|
237
|
+
teamSize: options?.teamSize ?? void 0,
|
|
238
|
+
branding: {}
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
if (error) throw error;
|
|
242
|
+
return mapTenantToOrg(tenant);
|
|
243
|
+
},
|
|
244
|
+
async updateOrg(orgId, updates) {
|
|
245
|
+
const row = {};
|
|
246
|
+
if (updates.name !== void 0) row["name"] = updates.name;
|
|
247
|
+
if (updates.slug !== void 0) row["slug"] = updates.slug;
|
|
248
|
+
if (updates.logoUrl !== void 0) row["logo_url"] = updates.logoUrl;
|
|
249
|
+
if (updates.verticalId !== void 0) row["vertical_id"] = updates.verticalId;
|
|
250
|
+
if (updates.plan !== void 0) row["plan"] = updates.plan;
|
|
251
|
+
if (updates.settings !== void 0) row["settings"] = updates.settings;
|
|
252
|
+
const { data, error } = await core().from("tenants").update(row).eq("id", orgId).select().single();
|
|
253
|
+
if (error) throw error;
|
|
254
|
+
return mapTenantToOrg(data);
|
|
255
|
+
},
|
|
256
|
+
async listMembers(orgId) {
|
|
257
|
+
const { data, error } = await core().from("tenant_members").select("*").eq("tenant_id", orgId);
|
|
258
|
+
if (error) throw error;
|
|
259
|
+
const userIds = (data ?? []).map((m) => m["user_id"]);
|
|
260
|
+
const { data: profiles } = userIds.length > 0 ? await core().from("profiles").select("id, full_name, avatar_url, email").in("id", userIds) : { data: [] };
|
|
261
|
+
const profileMap = new Map(
|
|
262
|
+
(profiles ?? []).map((p) => [p["id"], p])
|
|
263
|
+
);
|
|
264
|
+
return (data ?? []).map((row) => {
|
|
265
|
+
const profile = profileMap.get(row["user_id"]) ?? {};
|
|
266
|
+
return mapMemberRow({ ...row, profile });
|
|
267
|
+
});
|
|
268
|
+
},
|
|
269
|
+
async updateMemberProfile(orgId, memberId, profileId) {
|
|
270
|
+
const { error } = await core().from("tenant_members").update({ role: profileId }).eq("id", memberId).eq("tenant_id", orgId);
|
|
271
|
+
if (error) throw error;
|
|
272
|
+
},
|
|
273
|
+
async removeMember(orgId, memberId) {
|
|
274
|
+
const { error } = await core().from("tenant_members").delete().eq("id", memberId).eq("tenant_id", orgId);
|
|
275
|
+
if (error) throw error;
|
|
276
|
+
},
|
|
277
|
+
async listProfiles(orgId) {
|
|
278
|
+
const [permsResult, rolePermsResult, overridesResult] = await Promise.all([
|
|
279
|
+
core().from("permissions").select("id, category"),
|
|
280
|
+
core().from("role_permissions").select("role, permission_id"),
|
|
281
|
+
core().from("tenant_role_overrides").select("role, permission_id, granted").eq("tenant_id", orgId)
|
|
282
|
+
]);
|
|
283
|
+
if (permsResult.error) throw permsResult.error;
|
|
284
|
+
if (rolePermsResult.error) throw rolePermsResult.error;
|
|
285
|
+
if (overridesResult.error) throw overridesResult.error;
|
|
286
|
+
return buildPermissionProfiles(
|
|
287
|
+
permsResult.data ?? [],
|
|
288
|
+
rolePermsResult.data ?? [],
|
|
289
|
+
overridesResult.data ?? []
|
|
290
|
+
);
|
|
291
|
+
},
|
|
292
|
+
async createProfile(_orgId, _profile) {
|
|
293
|
+
throw new Error(
|
|
294
|
+
"Custom roles are not supported. Roles are system-defined (owner, admin, manager, staff, viewer)."
|
|
295
|
+
);
|
|
296
|
+
},
|
|
297
|
+
async updateProfile(orgId, profileId, data) {
|
|
298
|
+
if (data.grants) {
|
|
299
|
+
await core().from("tenant_role_overrides").delete().eq("tenant_id", orgId).eq("role", profileId);
|
|
300
|
+
const overrides = [];
|
|
301
|
+
for (const [category, actions] of Object.entries(data.grants)) {
|
|
302
|
+
for (const action of actions) {
|
|
303
|
+
const dbActionMap = {
|
|
304
|
+
read: "read",
|
|
305
|
+
write: "create",
|
|
306
|
+
manage: "manage",
|
|
307
|
+
delete: "delete"
|
|
308
|
+
};
|
|
309
|
+
const dbAction = dbActionMap[action] ?? action;
|
|
310
|
+
overrides.push({
|
|
311
|
+
tenant_id: orgId,
|
|
312
|
+
role: profileId,
|
|
313
|
+
permission_id: `${category}.${dbAction}`,
|
|
314
|
+
granted: true
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (overrides.length > 0) {
|
|
319
|
+
const { error } = await core().from("tenant_role_overrides").insert(overrides);
|
|
320
|
+
if (error) throw error;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const profiles = await this.listProfiles(orgId);
|
|
324
|
+
const updated = profiles.find((p) => p.id === profileId);
|
|
325
|
+
if (!updated) throw new Error(`Profile not found: ${profileId}`);
|
|
326
|
+
return updated;
|
|
327
|
+
},
|
|
328
|
+
async deleteProfile(_orgId, _profileId) {
|
|
329
|
+
throw new Error("System roles cannot be deleted.");
|
|
330
|
+
},
|
|
331
|
+
async listInvites(orgId) {
|
|
332
|
+
const { data, error } = await core().from("invitations").select("*").eq("tenant_id", orgId).order("created_at", { ascending: false });
|
|
333
|
+
if (error) throw error;
|
|
334
|
+
return (data ?? []).map(mapInviteRow);
|
|
335
|
+
},
|
|
336
|
+
async createInvite(orgId, email, profileId, invitedBy) {
|
|
337
|
+
const { data, error } = await core().from("invitations").insert({
|
|
338
|
+
tenant_id: orgId,
|
|
339
|
+
email,
|
|
340
|
+
role: profileId,
|
|
341
|
+
invited_by: invitedBy
|
|
342
|
+
}).select().single();
|
|
343
|
+
if (error) throw error;
|
|
344
|
+
return mapInviteRow(data);
|
|
345
|
+
},
|
|
346
|
+
async bulkInvite(orgId, emails, profileId, invitedBy) {
|
|
347
|
+
const rows = emails.map((email) => ({
|
|
348
|
+
tenant_id: orgId,
|
|
349
|
+
email,
|
|
350
|
+
role: profileId,
|
|
351
|
+
invited_by: invitedBy
|
|
352
|
+
}));
|
|
353
|
+
const { data, error } = await core().from("invitations").insert(rows).select();
|
|
354
|
+
if (error) throw error;
|
|
355
|
+
return (data ?? []).map(mapInviteRow);
|
|
356
|
+
},
|
|
357
|
+
async revokeInvite(orgId, inviteId) {
|
|
358
|
+
const { error } = await core().from("invitations").update({ status: "revoked" }).eq("id", inviteId).eq("tenant_id", orgId);
|
|
359
|
+
if (error) throw error;
|
|
360
|
+
},
|
|
361
|
+
async resendInvite(orgId, inviteId) {
|
|
362
|
+
const { data, error } = await core().from("invitations").update({
|
|
363
|
+
status: "pending",
|
|
364
|
+
expires_at: new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3).toISOString()
|
|
365
|
+
}).eq("id", inviteId).eq("tenant_id", orgId).select().single();
|
|
366
|
+
if (error) throw error;
|
|
367
|
+
return mapInviteRow(data);
|
|
368
|
+
},
|
|
369
|
+
async listLocations(orgId) {
|
|
370
|
+
const { data, error } = await core().from("locations").select("*").eq("tenant_id", orgId).order("is_headquarters", { ascending: false }).order("name");
|
|
371
|
+
if (error) throw error;
|
|
372
|
+
return (data ?? []).map(mapLocationRow);
|
|
373
|
+
},
|
|
374
|
+
async createLocation(orgId, input) {
|
|
375
|
+
const { data, error } = await core().from("locations").insert({
|
|
376
|
+
tenant_id: orgId,
|
|
377
|
+
name: input.name,
|
|
378
|
+
address: input.address ?? null,
|
|
379
|
+
city: input.city ?? null,
|
|
380
|
+
state: input.state ?? null,
|
|
381
|
+
country: input.country ?? "BR",
|
|
382
|
+
phone: input.phone ?? null,
|
|
383
|
+
is_headquarters: input.isHeadquarters ?? false
|
|
384
|
+
}).select().single();
|
|
385
|
+
if (error) throw error;
|
|
386
|
+
return mapLocationRow(data);
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// src/org/adapters/mock.ts
|
|
392
|
+
var STORAGE_KEY = "fayz:mock-orgs";
|
|
393
|
+
function getStored() {
|
|
394
|
+
try {
|
|
395
|
+
if (typeof localStorage === "undefined") return empty();
|
|
396
|
+
const raw = localStorage.getItem(STORAGE_KEY);
|
|
397
|
+
if (raw) return JSON.parse(raw);
|
|
398
|
+
} catch {
|
|
399
|
+
}
|
|
400
|
+
return empty();
|
|
401
|
+
}
|
|
402
|
+
function empty() {
|
|
403
|
+
return { orgs: [], members: [], profiles: {}, invites: {}, userOrgMap: {} };
|
|
404
|
+
}
|
|
405
|
+
function setStored(data) {
|
|
406
|
+
try {
|
|
407
|
+
if (typeof localStorage === "undefined") return;
|
|
408
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(data));
|
|
409
|
+
} catch {
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
function slugify2(name) {
|
|
413
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
414
|
+
}
|
|
415
|
+
function createMockOrgAdapter(defaultProfiles) {
|
|
416
|
+
function seedOrgForUser(userId, userName) {
|
|
417
|
+
const data = getStored();
|
|
418
|
+
if (data.userOrgMap[userId]?.length) return data;
|
|
419
|
+
const orgId = crypto.randomUUID();
|
|
420
|
+
const memberId = crypto.randomUUID();
|
|
421
|
+
const firstProfile = defaultProfiles?.[0];
|
|
422
|
+
const org = {
|
|
423
|
+
id: orgId,
|
|
424
|
+
name: "My Organization",
|
|
425
|
+
slug: "my-organization",
|
|
426
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
427
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
428
|
+
};
|
|
429
|
+
const member = {
|
|
430
|
+
id: memberId,
|
|
431
|
+
userId,
|
|
432
|
+
orgId,
|
|
433
|
+
profileId: firstProfile?.id ?? "owner",
|
|
434
|
+
profileName: firstProfile?.name ?? "Owner",
|
|
435
|
+
user: {
|
|
436
|
+
id: userId,
|
|
437
|
+
email: "user@example.com",
|
|
438
|
+
fullName: "Current User"
|
|
439
|
+
},
|
|
440
|
+
joinedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
441
|
+
};
|
|
442
|
+
data.orgs.push(org);
|
|
443
|
+
data.members.push(member);
|
|
444
|
+
data.userOrgMap[userId] = [orgId];
|
|
445
|
+
if (defaultProfiles) {
|
|
446
|
+
data.profiles[orgId] = [...defaultProfiles];
|
|
447
|
+
}
|
|
448
|
+
data.invites[orgId] = [];
|
|
449
|
+
setStored(data);
|
|
450
|
+
return data;
|
|
451
|
+
}
|
|
452
|
+
return {
|
|
453
|
+
async listUserOrgs(userId) {
|
|
454
|
+
const data = seedOrgForUser(userId);
|
|
455
|
+
const orgIds = data.userOrgMap[userId] ?? [];
|
|
456
|
+
return orgIds.map((orgId) => {
|
|
457
|
+
const org = data.orgs.find((o) => o.id === orgId);
|
|
458
|
+
const member = data.members.find((m) => m.orgId === orgId && m.userId === userId);
|
|
459
|
+
return {
|
|
460
|
+
orgId,
|
|
461
|
+
orgName: org.name,
|
|
462
|
+
orgSlug: org.slug,
|
|
463
|
+
orgLogoUrl: org.logoUrl,
|
|
464
|
+
profileId: member?.profileId ?? "owner",
|
|
465
|
+
profileName: member?.profileName ?? "Owner"
|
|
466
|
+
};
|
|
467
|
+
});
|
|
468
|
+
},
|
|
469
|
+
async getOrg(orgId) {
|
|
470
|
+
const data = getStored();
|
|
471
|
+
const org = data.orgs.find((o) => o.id === orgId);
|
|
472
|
+
if (!org) throw new Error(`Org not found: ${orgId}`);
|
|
473
|
+
return org;
|
|
474
|
+
},
|
|
475
|
+
async createOrg(name, userId, options) {
|
|
476
|
+
const data = getStored();
|
|
477
|
+
const orgId = crypto.randomUUID();
|
|
478
|
+
const firstProfile = defaultProfiles?.[0];
|
|
479
|
+
const org = {
|
|
480
|
+
id: orgId,
|
|
481
|
+
name,
|
|
482
|
+
slug: slugify2(name),
|
|
483
|
+
verticalId: options?.verticalId,
|
|
484
|
+
plan: "free",
|
|
485
|
+
settings: {
|
|
486
|
+
timezone: options?.timezone ?? "America/Sao_Paulo",
|
|
487
|
+
currency: options?.currency ?? "BRL",
|
|
488
|
+
locale: options?.locale ?? "pt-BR"
|
|
489
|
+
},
|
|
490
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
491
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
492
|
+
};
|
|
493
|
+
const member = {
|
|
494
|
+
id: crypto.randomUUID(),
|
|
495
|
+
userId,
|
|
496
|
+
orgId,
|
|
497
|
+
profileId: firstProfile?.id ?? "owner",
|
|
498
|
+
profileName: firstProfile?.name ?? "Owner",
|
|
499
|
+
user: {
|
|
500
|
+
id: userId,
|
|
501
|
+
email: "user@example.com",
|
|
502
|
+
fullName: "Current User"
|
|
503
|
+
},
|
|
504
|
+
joinedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
505
|
+
};
|
|
506
|
+
data.orgs.push(org);
|
|
507
|
+
data.members.push(member);
|
|
508
|
+
if (!data.userOrgMap[userId]) data.userOrgMap[userId] = [];
|
|
509
|
+
data.userOrgMap[userId].push(orgId);
|
|
510
|
+
if (defaultProfiles) {
|
|
511
|
+
data.profiles[orgId] = [...defaultProfiles];
|
|
512
|
+
}
|
|
513
|
+
data.invites[orgId] = [];
|
|
514
|
+
setStored(data);
|
|
515
|
+
return org;
|
|
516
|
+
},
|
|
517
|
+
async updateOrg(orgId, updates) {
|
|
518
|
+
const data = getStored();
|
|
519
|
+
const idx = data.orgs.findIndex((o) => o.id === orgId);
|
|
520
|
+
if (idx === -1) throw new Error(`Org not found: ${orgId}`);
|
|
521
|
+
data.orgs[idx] = { ...data.orgs[idx], ...updates, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
522
|
+
setStored(data);
|
|
523
|
+
return data.orgs[idx];
|
|
524
|
+
},
|
|
525
|
+
async listMembers(orgId) {
|
|
526
|
+
const data = getStored();
|
|
527
|
+
return data.members.filter((m) => m.orgId === orgId);
|
|
528
|
+
},
|
|
529
|
+
async updateMemberProfile(orgId, memberId, profileId) {
|
|
530
|
+
const data = getStored();
|
|
531
|
+
const member = data.members.find((m) => m.id === memberId && m.orgId === orgId);
|
|
532
|
+
if (!member) throw new Error(`Member not found: ${memberId}`);
|
|
533
|
+
const profiles = data.profiles[orgId] ?? [];
|
|
534
|
+
const profile = profiles.find((p) => p.id === profileId);
|
|
535
|
+
member.profileId = profileId;
|
|
536
|
+
member.profileName = profile?.name ?? profileId;
|
|
537
|
+
setStored(data);
|
|
538
|
+
},
|
|
539
|
+
async removeMember(orgId, memberId) {
|
|
540
|
+
const data = getStored();
|
|
541
|
+
const memberIdx = data.members.findIndex((m) => m.id === memberId && m.orgId === orgId);
|
|
542
|
+
if (memberIdx === -1) return;
|
|
543
|
+
const member = data.members[memberIdx];
|
|
544
|
+
data.members.splice(memberIdx, 1);
|
|
545
|
+
const userOrgs = data.userOrgMap[member.userId];
|
|
546
|
+
if (userOrgs) {
|
|
547
|
+
const orgIdx = userOrgs.indexOf(orgId);
|
|
548
|
+
if (orgIdx !== -1) userOrgs.splice(orgIdx, 1);
|
|
549
|
+
}
|
|
550
|
+
setStored(data);
|
|
551
|
+
},
|
|
552
|
+
async listProfiles(orgId) {
|
|
553
|
+
const data = getStored();
|
|
554
|
+
return data.profiles[orgId] ?? defaultProfiles ?? [];
|
|
555
|
+
},
|
|
556
|
+
async createProfile(orgId, profile) {
|
|
557
|
+
const data = getStored();
|
|
558
|
+
const newProfile = {
|
|
559
|
+
...profile,
|
|
560
|
+
id: crypto.randomUUID(),
|
|
561
|
+
isSystem: false
|
|
562
|
+
};
|
|
563
|
+
if (!data.profiles[orgId]) {
|
|
564
|
+
data.profiles[orgId] = defaultProfiles ? [...defaultProfiles] : [];
|
|
565
|
+
}
|
|
566
|
+
data.profiles[orgId].push(newProfile);
|
|
567
|
+
setStored(data);
|
|
568
|
+
return newProfile;
|
|
569
|
+
},
|
|
570
|
+
async updateProfile(orgId, profileId, updates) {
|
|
571
|
+
const data = getStored();
|
|
572
|
+
const profiles = data.profiles[orgId] ?? [];
|
|
573
|
+
const idx = profiles.findIndex((p) => p.id === profileId);
|
|
574
|
+
if (idx === -1) throw new Error(`Profile not found: ${profileId}`);
|
|
575
|
+
profiles[idx] = { ...profiles[idx], ...updates };
|
|
576
|
+
data.profiles[orgId] = profiles;
|
|
577
|
+
setStored(data);
|
|
578
|
+
return profiles[idx];
|
|
579
|
+
},
|
|
580
|
+
async deleteProfile(orgId, profileId) {
|
|
581
|
+
const data = getStored();
|
|
582
|
+
const profiles = data.profiles[orgId] ?? [];
|
|
583
|
+
const profile = profiles.find((p) => p.id === profileId);
|
|
584
|
+
if (profile?.isSystem) throw new Error("Cannot delete system profile");
|
|
585
|
+
data.profiles[orgId] = profiles.filter((p) => p.id !== profileId);
|
|
586
|
+
setStored(data);
|
|
587
|
+
},
|
|
588
|
+
async listInvites(orgId) {
|
|
589
|
+
const data = getStored();
|
|
590
|
+
return data.invites[orgId] ?? [];
|
|
591
|
+
},
|
|
592
|
+
async createInvite(orgId, email, profileId, invitedBy) {
|
|
593
|
+
const data = getStored();
|
|
594
|
+
const profiles = data.profiles[orgId] ?? defaultProfiles ?? [];
|
|
595
|
+
const profile = profiles.find((p) => p.id === profileId);
|
|
596
|
+
const invite = {
|
|
597
|
+
id: crypto.randomUUID(),
|
|
598
|
+
orgId,
|
|
599
|
+
email,
|
|
600
|
+
profileId,
|
|
601
|
+
profileName: profile?.name ?? profileId,
|
|
602
|
+
invitedBy,
|
|
603
|
+
token: crypto.randomUUID(),
|
|
604
|
+
status: "pending",
|
|
605
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
606
|
+
expiresAt: new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3).toISOString()
|
|
607
|
+
};
|
|
608
|
+
if (!data.invites[orgId]) data.invites[orgId] = [];
|
|
609
|
+
data.invites[orgId].push(invite);
|
|
610
|
+
setStored(data);
|
|
611
|
+
return invite;
|
|
612
|
+
},
|
|
613
|
+
async bulkInvite(orgId, emails, profileId, invitedBy) {
|
|
614
|
+
const results = [];
|
|
615
|
+
for (const email of emails) {
|
|
616
|
+
results.push(await this.createInvite(orgId, email, profileId, invitedBy));
|
|
617
|
+
}
|
|
618
|
+
return results;
|
|
619
|
+
},
|
|
620
|
+
async revokeInvite(orgId, inviteId) {
|
|
621
|
+
const data = getStored();
|
|
622
|
+
const invites = data.invites[orgId] ?? [];
|
|
623
|
+
const invite = invites.find((i) => i.id === inviteId);
|
|
624
|
+
if (invite) {
|
|
625
|
+
invite.status = "expired";
|
|
626
|
+
setStored(data);
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
async resendInvite(orgId, inviteId) {
|
|
630
|
+
const data = getStored();
|
|
631
|
+
const invites = data.invites[orgId] ?? [];
|
|
632
|
+
const invite = invites.find((i) => i.id === inviteId);
|
|
633
|
+
if (!invite) throw new Error(`Invite not found: ${inviteId}`);
|
|
634
|
+
invite.expiresAt = new Date(Date.now() + 7 * 24 * 60 * 60 * 1e3).toISOString();
|
|
635
|
+
invite.status = "pending";
|
|
636
|
+
setStored(data);
|
|
637
|
+
return invite;
|
|
638
|
+
},
|
|
639
|
+
async listLocations(_orgId) {
|
|
640
|
+
return [];
|
|
641
|
+
},
|
|
642
|
+
async createLocation(orgId, input) {
|
|
643
|
+
return {
|
|
644
|
+
id: crypto.randomUUID(),
|
|
645
|
+
tenantId: orgId,
|
|
646
|
+
name: input.name,
|
|
647
|
+
address: input.address,
|
|
648
|
+
city: input.city,
|
|
649
|
+
state: input.state,
|
|
650
|
+
country: input.country ?? "BR",
|
|
651
|
+
phone: input.phone,
|
|
652
|
+
isHeadquarters: input.isHeadquarters ?? false,
|
|
653
|
+
isActive: true,
|
|
654
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
655
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
var STORAGE_KEY2 = "fayz:current-org";
|
|
661
|
+
function getPersistedOrgId() {
|
|
662
|
+
try {
|
|
663
|
+
if (typeof localStorage === "undefined") return null;
|
|
664
|
+
return localStorage.getItem(STORAGE_KEY2);
|
|
665
|
+
} catch {
|
|
666
|
+
return null;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
function persistOrgId(orgId) {
|
|
670
|
+
try {
|
|
671
|
+
if (typeof localStorage === "undefined") return;
|
|
672
|
+
if (orgId) {
|
|
673
|
+
localStorage.setItem(STORAGE_KEY2, orgId);
|
|
674
|
+
} else {
|
|
675
|
+
localStorage.removeItem(STORAGE_KEY2);
|
|
676
|
+
}
|
|
677
|
+
} catch {
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
var useOrganizationStore = zustand.create((set) => ({
|
|
681
|
+
currentOrg: null,
|
|
682
|
+
userOrgs: [],
|
|
683
|
+
members: [],
|
|
684
|
+
loading: false,
|
|
685
|
+
setCurrentOrg: (org) => {
|
|
686
|
+
core.setActiveTenantId(org?.id);
|
|
687
|
+
persistOrgId(org?.id ?? null);
|
|
688
|
+
set({ currentOrg: org });
|
|
689
|
+
},
|
|
690
|
+
setUserOrgs: (orgs) => set({ userOrgs: orgs }),
|
|
691
|
+
setMembers: (members) => set({ members }),
|
|
692
|
+
setLoading: (loading) => set({ loading }),
|
|
693
|
+
reset: () => {
|
|
694
|
+
core.setActiveTenantId(void 0);
|
|
695
|
+
persistOrgId(null);
|
|
696
|
+
set({ currentOrg: null, userOrgs: [], members: [], loading: false });
|
|
697
|
+
}
|
|
698
|
+
}));
|
|
699
|
+
var OrgAdapterContext = React__namespace.createContext(null);
|
|
700
|
+
function useOrgAdapter() {
|
|
701
|
+
const adapter = React__namespace.useContext(OrgAdapterContext);
|
|
702
|
+
if (!adapter) {
|
|
703
|
+
throw new Error("useOrgAdapter must be used within an <OrgProvider>");
|
|
704
|
+
}
|
|
705
|
+
return adapter;
|
|
706
|
+
}
|
|
707
|
+
function useOrgAdapterOptional() {
|
|
708
|
+
return React__namespace.useContext(OrgAdapterContext);
|
|
709
|
+
}
|
|
710
|
+
var TenantContext = React__namespace.createContext(null);
|
|
711
|
+
function useTenant() {
|
|
712
|
+
const ctx = React__namespace.useContext(TenantContext);
|
|
713
|
+
if (!ctx) {
|
|
714
|
+
throw new Error("useTenant must be used inside <OrgProvider>");
|
|
715
|
+
}
|
|
716
|
+
return ctx;
|
|
717
|
+
}
|
|
718
|
+
function useTenantOptional() {
|
|
719
|
+
return React__namespace.useContext(TenantContext);
|
|
720
|
+
}
|
|
721
|
+
function OrgProvider({ adapter, autoCreate = false, children }) {
|
|
722
|
+
const { user } = auth.useAuthStore();
|
|
723
|
+
const { currentOrg, userOrgs, loading, setCurrentOrg, setUserOrgs, setLoading, reset } = useOrganizationStore();
|
|
724
|
+
const adapterRef = React__namespace.useRef(adapter);
|
|
725
|
+
adapterRef.current = adapter;
|
|
726
|
+
React__namespace.useEffect(() => {
|
|
727
|
+
if (!user) {
|
|
728
|
+
reset();
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
let cancelled = false;
|
|
732
|
+
async function loadOrgs() {
|
|
733
|
+
setLoading(true);
|
|
734
|
+
try {
|
|
735
|
+
const memberships = await adapterRef.current.listUserOrgs(user.id);
|
|
736
|
+
if (cancelled) return;
|
|
737
|
+
setUserOrgs(memberships);
|
|
738
|
+
if (memberships.length === 0 && autoCreate) {
|
|
739
|
+
const newOrg = await adapterRef.current.createOrg(
|
|
740
|
+
user.fullName ? `${user.fullName}'s Organization` : "My Organization",
|
|
741
|
+
user.id
|
|
742
|
+
);
|
|
743
|
+
if (!cancelled) {
|
|
744
|
+
setUserOrgs([
|
|
745
|
+
{
|
|
746
|
+
orgId: newOrg.id,
|
|
747
|
+
orgName: newOrg.name,
|
|
748
|
+
orgSlug: newOrg.slug,
|
|
749
|
+
profileId: "owner",
|
|
750
|
+
profileName: "Owner"
|
|
751
|
+
}
|
|
752
|
+
]);
|
|
753
|
+
setCurrentOrg(newOrg);
|
|
754
|
+
}
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
const persistedId = getPersistedOrgId();
|
|
758
|
+
const target = memberships.find((m) => m.orgId === persistedId) ?? memberships[0];
|
|
759
|
+
if (target && !cancelled) {
|
|
760
|
+
const org = await adapterRef.current.getOrg(target.orgId);
|
|
761
|
+
if (!cancelled) setCurrentOrg(org);
|
|
762
|
+
}
|
|
763
|
+
} finally {
|
|
764
|
+
if (!cancelled) setLoading(false);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
void loadOrgs();
|
|
768
|
+
return () => {
|
|
769
|
+
cancelled = true;
|
|
770
|
+
};
|
|
771
|
+
}, [user?.id]);
|
|
772
|
+
async function switchOrg(orgId) {
|
|
773
|
+
setLoading(true);
|
|
774
|
+
try {
|
|
775
|
+
const org = await adapterRef.current.getOrg(orgId);
|
|
776
|
+
setCurrentOrg(org);
|
|
777
|
+
} finally {
|
|
778
|
+
setLoading(false);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
async function refreshOrg() {
|
|
782
|
+
if (!currentOrg) return;
|
|
783
|
+
setLoading(true);
|
|
784
|
+
try {
|
|
785
|
+
const org = await adapterRef.current.getOrg(currentOrg.id);
|
|
786
|
+
setCurrentOrg(org);
|
|
787
|
+
} finally {
|
|
788
|
+
setLoading(false);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
const tenantValue = {
|
|
792
|
+
org: currentOrg,
|
|
793
|
+
userOrgs,
|
|
794
|
+
loading,
|
|
795
|
+
switchOrg,
|
|
796
|
+
refreshOrg
|
|
797
|
+
};
|
|
798
|
+
return /* @__PURE__ */ jsxRuntime.jsx(OrgAdapterContext.Provider, { value: adapter, children: /* @__PURE__ */ jsxRuntime.jsx(TenantContext.Provider, { value: tenantValue, children }) });
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
exports.CORE_SCHEMA = CORE_SCHEMA;
|
|
802
|
+
exports.OrgProvider = OrgProvider;
|
|
803
|
+
exports.createFayzSupabaseClient = createFayzSupabaseClient;
|
|
804
|
+
exports.createMockOrgAdapter = createMockOrgAdapter;
|
|
805
|
+
exports.createSupabaseOrgAdapter = createSupabaseOrgAdapter;
|
|
806
|
+
exports.getCoreSchemaClient = getCoreSchemaClient;
|
|
807
|
+
exports.getFayzSupabaseClient = getFayzSupabaseClient;
|
|
808
|
+
exports.getFayzSupabaseClientOptional = getFayzSupabaseClientOptional;
|
|
809
|
+
exports.getPersistedOrgId = getPersistedOrgId;
|
|
810
|
+
exports.useOrgAdapter = useOrgAdapter;
|
|
811
|
+
exports.useOrgAdapterOptional = useOrgAdapterOptional;
|
|
812
|
+
exports.useOrganizationStore = useOrganizationStore;
|
|
813
|
+
exports.useTenant = useTenant;
|
|
814
|
+
exports.useTenantOptional = useTenantOptional;
|
|
815
|
+
//# sourceMappingURL=chunk-QGMDVLLW.cjs.map
|
|
816
|
+
//# sourceMappingURL=chunk-QGMDVLLW.cjs.map
|