@safercity/sdk-react 0.1.3 → 0.2.0

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/provider.tsx","../src/hooks.ts","../src/use-stream.ts"],"names":["createContext","useMemo","useState","createSaferCityClient","useEffect","useCallback","QueryClient","jsx","QueryClientProvider","useContext","useQuery","useQueryClient","useMutation","useRef"],"mappings":";;;;;;;AAsCA,IAAM,gBAAA,GAAmBA,oBAA4C,IAAI,CAAA;AA+CzE,SAAS,YAAY,KAAA,EAAgE;AACnF,EAAA,OAAO,EAAE,MAAA,IAAU,KAAA,CAAA,IAAU,MAAM,IAAA,KAAS,OAAA,IAAW,MAAM,IAAA,KAAS,MAAA;AACxE;AAEA,SAAS,aAAa,KAAA,EAAiE;AACrF,EAAA,OAAO,MAAA,IAAU,KAAA,IAAS,KAAA,CAAM,IAAA,KAAS,QAAA;AAC3C;AAEA,SAAS,aAAa,KAAA,EAAiE;AACrF,EAAA,OAAO,MAAA,IAAU,KAAA,IAAS,KAAA,CAAM,IAAA,KAAS,QAAA;AAC3C;AAEA,SAAS,aAAa,KAAA,EAA6D;AACjF,EAAA,OAAO,SAAA,IAAa,KAAA,IAAS,OAAA,IAAW,KAAA,IAAS,EAAE,MAAA,IAAU,KAAA,CAAA;AAC/D;AAqCO,SAAS,kBAAkB,KAAA,EAA+B;AAC/D,EAAA,MAAM,EAAE,QAAA,EAAU,WAAA,EAAa,mBAAA,EAAoB,GAAI,KAAA;AAGvD,EAAA,MAAM,IAAA,GAAiBC,cAAQ,MAAM;AACnC,IAAA,IAAI,YAAA,CAAa,KAAK,CAAA,EAAG,OAAO,QAAA;AAChC,IAAA,IAAI,YAAA,CAAa,KAAK,CAAA,EAAG,OAAO,QAAA;AAChC,IAAA,OAAO,OAAA;AAAA,EACT,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AAGV,EAAA,MAAM,CAAC,OAAA,EAAS,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AU,KAAA;AACtB,MAAA,QAAA,CAAS,CAAC,IAAA,MAAU;AAAA,QAClB,GAAG,IAAA;AAAA,QACH,WAAA,EAAa,KAAA;AAAA,QACb,YAAA,EAAc;AAAA,OAChB,CAAE,CAAA;AACF,MAAA,OAAA,IAAU;AAAA,IACZ;AAAA,EACF,CAAA,EAAG,CAAC,SAAA,EAAW,WAAA,EAAa,YAAY,MAAA,EAAQ,OAAA,EAAS,OAAA,EAAS,OAAO,CAAC,CAAA;AAE1E,EAAA,MAAM,UAAA,GAAaA,kBAAY,MAAM;AACnC,IAAA,WAAA,CAAY,OAAA,GAAU,KAAA;AAAA,EACxB,CAAA,EAAG,EAAE,CAAA;AAEL,EAAAD,gBAAU,MAAM;AACd,IAAA,IAAI,WAAA,EAAa;AACf,MAAA,OAAA,EAAQ;AAAA,IACV;AAEA,IAAA,OAAO,MAAM;AACX,MAAA,UAAA,EAAW;AAAA,IACb,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,WAAA,EAAa,OAAA,EAAS,UAAU,CAAC,CAAA;AAErC,EAAA,OAAO;AAAA,IACL,GAAG,KAAA;AAAA,IACH,OAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["'use client';\n\nimport { createContext, useContext, useMemo, useCallback, useState, useEffect, type ReactNode } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { createSaferCityClient, type SaferCityClient, type SaferCityClientOptions } from '@safercity/sdk';\nimport type { AuthMode, ProxyModeConfig, DirectModeConfig, CookieModeConfig } from '@safercity/sdk';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Session state for cookie-based auth\n */\nexport interface SessionState {\n isAuthenticated: boolean;\n isLoading: boolean;\n userId?: string;\n tenantId?: string;\n expiresAt?: number;\n error?: Error;\n}\n\n/**\n * Context value for SaferCity provider\n */\ninterface SaferCityContextValue {\n client: SaferCityClient;\n mode: AuthMode;\n session: SessionState;\n /** Create session from external JWT (cookie mode only) */\n createSession: (token: string, tenantId?: string) => Promise<void>;\n /** Clear current session (cookie mode only) */\n clearSession: () => Promise<void>;\n /** Refresh CSRF token (cookie mode only) */\n refreshCsrf: () => Promise<string | undefined>;\n}\n\nconst SaferCityContext = createContext<SaferCityContextValue | null>(null);\n\n// ============================================================================\n// Provider Props\n// ============================================================================\n\n/**\n * Base props for all modes\n */\ninterface BaseProviderProps {\n children: ReactNode;\n queryClient?: QueryClient;\n}\n\n/**\n * Props for proxy mode (DEFAULT)\n */\nexport interface ProxyModeProviderProps extends BaseProviderProps, ProxyModeConfig {}\n\n/**\n * Props for direct mode\n */\nexport interface DirectModeProviderProps extends BaseProviderProps, DirectModeConfig {}\n\n/**\n * Props for cookie mode\n */\nexport interface CookieModeProviderProps extends BaseProviderProps, CookieModeConfig {}\n\n/**\n * Legacy props (for backward compatibility)\n */\nexport interface LegacyProviderProps extends BaseProviderProps, SaferCityClientOptions {}\n\n/**\n * Combined props type\n */\nexport type SaferCityProviderProps = \n | ProxyModeProviderProps \n | DirectModeProviderProps \n | CookieModeProviderProps\n | LegacyProviderProps;\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\nfunction isProxyMode(props: SaferCityProviderProps): props is ProxyModeProviderProps {\n return !('mode' in props) || props.mode === 'proxy' || props.mode === undefined;\n}\n\nfunction isDirectMode(props: SaferCityProviderProps): props is DirectModeProviderProps {\n return 'mode' in props && props.mode === 'direct';\n}\n\nfunction isCookieMode(props: SaferCityProviderProps): props is CookieModeProviderProps {\n return 'mode' in props && props.mode === 'cookie';\n}\n\nfunction isLegacyMode(props: SaferCityProviderProps): props is LegacyProviderProps {\n return 'baseUrl' in props && 'token' in props && !('mode' in props);\n}\n\n// ============================================================================\n// Provider Component\n// ============================================================================\n\n/**\n * Provider component for SaferCity SDK\n * \n * Supports three authentication modes:\n * \n * **Proxy Mode (Default)** - Most secure, recommended for production\n * ```tsx\n * <SaferCityProvider mode=\"proxy\" proxyBaseUrl=\"/api/safercity\">\n * <App />\n * </SaferCityProvider>\n * ```\n * \n * **Direct Mode** - For white-label apps with external auth\n * ```tsx\n * <SaferCityProvider\n * mode=\"direct\"\n * baseUrl=\"https://api.safercity.com\"\n * tenantId=\"tenant-123\"\n * getAccessToken={() => session?.accessToken}\n * >\n * <App />\n * </SaferCityProvider>\n * ```\n * \n * **Cookie Mode** - For first-party web apps\n * ```tsx\n * <SaferCityProvider mode=\"cookie\" baseUrl=\"https://api.safercity.com\">\n * <App />\n * </SaferCityProvider>\n * ```\n */\nexport function SaferCityProvider(props: SaferCityProviderProps) {\n const { children, queryClient: externalQueryClient } = props;\n \n // Determine mode\n const mode: AuthMode = useMemo(() => {\n if (isDirectMode(props)) return 'direct';\n if (isCookieMode(props)) return 'cookie';\n return 'proxy';\n }, [props]);\n\n // Session state for cookie mode\n const [session, setSession] = useState<SessionState>({\n isAuthenticated: false,\n isLoading: mode === 'cookie',\n });\n\n // Create client based on mode\n const client = useMemo(() => {\n if (isLegacyMode(props)) {\n // Legacy mode - direct token\n return createSaferCityClient({\n baseUrl: props.baseUrl,\n token: props.token,\n tenantId: props.tenantId,\n fetch: props.fetch,\n timeout: props.timeout,\n headers: props.headers,\n });\n }\n\n if (isProxyMode(props)) {\n // Proxy mode - requests go through local proxy\n const proxyBaseUrl = props.proxyBaseUrl ?? '/api/safercity';\n return createSaferCityClient({\n baseUrl: proxyBaseUrl,\n });\n }\n\n if (isDirectMode(props)) {\n // Direct mode - use external token\n return createSaferCityClient({\n baseUrl: props.baseUrl,\n tenantId: props.tenantId,\n });\n }\n\n if (isCookieMode(props)) {\n // Cookie mode - credentials included automatically\n return createSaferCityClient({\n baseUrl: props.baseUrl,\n tenantId: props.tenantId,\n headers: {\n // Note: cookies are sent automatically with fetch credentials: 'include'\n },\n });\n }\n\n throw new Error('Invalid SaferCityProvider configuration');\n }, [props]);\n\n // Token getter for direct mode\n const directModeTokenGetter = isDirectMode(props) ? props.getAccessToken : null;\n\n // Update token for direct mode\n useEffect(() => {\n if (!directModeTokenGetter) return;\n\n let isMounted = true;\n \n const updateToken = async () => {\n const token = await directModeTokenGetter();\n if (isMounted) {\n client.setToken(token);\n }\n };\n\n updateToken();\n\n // Re-check token periodically\n const interval = setInterval(updateToken, 30000);\n return () => {\n isMounted = false;\n clearInterval(interval);\n };\n }, [client, directModeTokenGetter]);\n\n // Check session status for cookie mode\n useEffect(() => {\n if (mode !== 'cookie') return;\n if (!isCookieMode(props)) return;\n\n let isMounted = true;\n\n const checkSession = async () => {\n try {\n const response = await fetch(`${props.baseUrl}/v1/auth/session/status`, {\n credentials: 'include',\n });\n \n if (!isMounted) return;\n\n if (response.ok) {\n const data = await response.json();\n setSession({\n isAuthenticated: data.authenticated,\n isLoading: false,\n userId: data.userId,\n tenantId: data.tenantId,\n expiresAt: data.expiresAt,\n });\n } else {\n setSession({\n isAuthenticated: false,\n isLoading: false,\n });\n }\n } catch (error) {\n if (!isMounted) return;\n setSession({\n isAuthenticated: false,\n isLoading: false,\n error: error instanceof Error ? error : new Error('Session check failed'),\n });\n }\n };\n\n checkSession();\n\n return () => {\n isMounted = false;\n };\n }, [mode, props]);\n\n // Create session (cookie mode)\n const createSession = useCallback(async (token: string, tenantId?: string) => {\n if (mode !== 'cookie' || !isCookieMode(props)) {\n throw new Error('createSession is only available in cookie mode');\n }\n\n setSession(prev => ({ ...prev, isLoading: true, error: undefined }));\n\n try {\n const response = await fetch(`${props.baseUrl}/v1/auth/session`, {\n method: 'POST',\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n ...(tenantId && { 'X-Tenant-ID': tenantId }),\n },\n body: JSON.stringify({ token, tenantId }),\n });\n\n if (!response.ok) {\n const error = await response.json();\n throw new Error(error.message || 'Failed to create session');\n }\n\n const data = await response.json();\n \n setSession({\n isAuthenticated: true,\n isLoading: false,\n expiresAt: data.expiresAt,\n tenantId,\n });\n } catch (error) {\n setSession({\n isAuthenticated: false,\n isLoading: false,\n error: error instanceof Error ? error : new Error('Failed to create session'),\n });\n throw error;\n }\n }, [mode, props]);\n\n // Clear session (cookie mode)\n const clearSession = useCallback(async () => {\n if (mode !== 'cookie' || !isCookieMode(props)) {\n throw new Error('clearSession is only available in cookie mode');\n }\n\n try {\n await fetch(`${props.baseUrl}/v1/auth/session/logout`, {\n method: 'POST',\n credentials: 'include',\n });\n } finally {\n setSession({\n isAuthenticated: false,\n isLoading: false,\n });\n }\n }, [mode, props]);\n\n // Refresh CSRF token (cookie mode)\n const refreshCsrf = useCallback(async (): Promise<string | undefined> => {\n if (mode !== 'cookie' || !isCookieMode(props)) {\n throw new Error('refreshCsrf is only available in cookie mode');\n }\n\n try {\n const response = await fetch(`${props.baseUrl}/v1/auth/session/refresh`, {\n method: 'POST',\n credentials: 'include',\n });\n\n if (response.ok) {\n const data = await response.json();\n return data.csrfToken;\n }\n } catch {\n // Ignore errors\n }\n \n return undefined;\n }, [mode, props]);\n\n // Create QueryClient\n const queryClient = useMemo(\n () => externalQueryClient ?? new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 1000 * 60, // 1 minute\n gcTime: 1000 * 60 * 5, // 5 minutes\n retry: 1,\n refetchOnWindowFocus: false,\n },\n mutations: {\n retry: 0,\n },\n },\n }),\n [externalQueryClient]\n );\n\n const contextValue = useMemo(() => ({\n client,\n mode,\n session,\n createSession,\n clearSession,\n refreshCsrf,\n }), [client, mode, session, createSession, clearSession, refreshCsrf]);\n\n return (\n <QueryClientProvider client={queryClient}>\n <SaferCityContext.Provider value={contextValue}>\n {children}\n </SaferCityContext.Provider>\n </QueryClientProvider>\n );\n}\n\n// ============================================================================\n// Hooks\n// ============================================================================\n\n/**\n * Hook to access the full SaferCity context\n */\nexport function useSaferCity(): SaferCityContextValue {\n const context = useContext(SaferCityContext);\n \n if (!context) {\n throw new Error(\n 'useSaferCity must be used within a SaferCityProvider. ' +\n 'Make sure your component is wrapped with <SaferCityProvider>.'\n );\n }\n \n return context;\n}\n\n/**\n * Hook to access the SaferCity client\n */\nexport function useSaferCityClient(): SaferCityClient {\n return useSaferCity().client;\n}\n\n/**\n * Hook to access session state (cookie mode)\n */\nexport function useSession(): SessionState {\n return useSaferCity().session;\n}\n\n/**\n * Hook to get the current auth mode\n */\nexport function useAuthMode(): AuthMode {\n return useSaferCity().mode;\n}\n\n/**\n * Hook to manage session (cookie mode)\n */\nexport function useSessionManager() {\n const { createSession, clearSession, refreshCsrf, session } = useSaferCity();\n \n return {\n session,\n createSession,\n clearSession,\n refreshCsrf,\n isAuthenticated: session.isAuthenticated,\n isLoading: session.isLoading,\n };\n}\n","'use client';\n\nimport { useQuery, useMutation, useQueryClient, type UseQueryOptions, type UseMutationOptions } from '@tanstack/react-query';\nimport { useSaferCityClient } from './provider';\nimport type { ApiResponse, SaferCityApiError } from '@safercity/sdk';\n\n// ==================\n// Query Keys Factory\n// ==================\n\nexport const saferCityKeys = {\n all: ['safercity'] as const,\n \n // Health\n health: () => [...saferCityKeys.all, 'health'] as const,\n \n // Auth\n auth: () => [...saferCityKeys.all, 'auth'] as const,\n authWhoami: () => [...saferCityKeys.auth(), 'whoami'] as const,\n \n // Users\n users: () => [...saferCityKeys.all, 'users'] as const,\n usersList: (filters?: Record<string, unknown>) => [...saferCityKeys.users(), 'list', filters] as const,\n usersDetail: (userId: string) => [...saferCityKeys.users(), 'detail', userId] as const,\n \n // Panics\n panics: () => [...saferCityKeys.all, 'panics'] as const,\n panicsList: (filters?: Record<string, unknown>) => [...saferCityKeys.panics(), 'list', filters] as const,\n panicsDetail: (panicId: string) => [...saferCityKeys.panics(), 'detail', panicId] as const,\n \n // Subscriptions\n subscriptions: () => [...saferCityKeys.all, 'subscriptions'] as const,\n subscriptionsList: (filters?: Record<string, unknown>) => [...saferCityKeys.subscriptions(), 'list', filters] as const,\n subscriptionsTypes: () => [...saferCityKeys.subscriptions(), 'types'] as const,\n subscriptionsStats: () => [...saferCityKeys.subscriptions(), 'stats'] as const,\n \n // Location Safety\n locationSafety: (lat: number, lng: number) => [...saferCityKeys.all, 'location-safety', lat, lng] as const,\n \n // Crimes\n crimes: () => [...saferCityKeys.all, 'crimes'] as const,\n crimesList: (filters?: Record<string, unknown>) => [...saferCityKeys.crimes(), 'list', filters] as const,\n crimesCategories: () => [...saferCityKeys.crimes(), 'categories'] as const,\n crimesTypes: () => [...saferCityKeys.crimes(), 'types'] as const,\n};\n\n// ==================\n// Health Hooks\n// ==================\n\nexport function useHealthCheck(\n options?: Omit<UseQueryOptions<ApiResponse<{ status: string; timestamp: string }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.health(),\n queryFn: () => client.health.check(),\n ...options,\n });\n}\n\n// ==================\n// Auth Hooks\n// ==================\n\nexport function useWhoAmI(\n options?: Omit<UseQueryOptions<ApiResponse<{ tenantId: string | null; environment: string; scopes: string[]; sessionId: string }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.authWhoami(),\n queryFn: () => client.auth.whoami(),\n ...options,\n });\n}\n\n// ==================\n// User Hooks\n// ==================\n\nexport function useUsers(\n filters?: { limit?: number; cursor?: string; status?: string },\n options?: Omit<UseQueryOptions<ApiResponse<{ users: Array<{ id: string; email?: string; phone?: string; status: string }>; hasNext: boolean; cursor?: string }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.usersList(filters),\n queryFn: () => client.users.list(filters),\n ...options,\n });\n}\n\nexport function useUser(\n userId: string,\n options?: Omit<UseQueryOptions<ApiResponse<{ id: string; email?: string; phone?: string; firstName?: string; lastName?: string; status: string; metadata?: Record<string, unknown> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.usersDetail(userId),\n queryFn: () => client.users.get(userId),\n enabled: !!userId,\n ...options,\n });\n}\n\nexport function useCreateUser(\n options?: UseMutationOptions<\n ApiResponse<{ id: string; email?: string; phone?: string }>,\n SaferCityApiError,\n { email?: string; phone?: string; firstName?: string; lastName?: string; metadata?: Record<string, unknown> }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: (data) => client.users.create(data),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.users() });\n },\n ...options,\n });\n}\n\nexport function useUpdateUser(\n options?: UseMutationOptions<\n ApiResponse<{ id: string }>,\n SaferCityApiError,\n { userId: string; data: { email?: string; phone?: string; firstName?: string; lastName?: string; metadata?: Record<string, unknown> } }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: ({ userId, data }) => client.users.update(userId, data),\n onSuccess: (_, { userId }) => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.usersDetail(userId) });\n queryClient.invalidateQueries({ queryKey: saferCityKeys.usersList() });\n },\n ...options,\n });\n}\n\nexport function useDeleteUser(\n options?: UseMutationOptions<ApiResponse<{ success: boolean }>, SaferCityApiError, string>\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: (userId) => client.users.delete(userId),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.users() });\n },\n ...options,\n });\n}\n\n// ==================\n// Panic Hooks\n// ==================\n\nexport function usePanic(\n panicId: string,\n query?: { userId?: string },\n options?: Omit<UseQueryOptions<ApiResponse<{ id: string; userId: string; status: string; latitude: number; longitude: number; createdAt: string; updatedAt?: string }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.panicsDetail(panicId),\n queryFn: () => client.panics.get(panicId, query),\n enabled: !!panicId,\n ...options,\n });\n}\n\nexport function useCreatePanic(\n options?: UseMutationOptions<\n ApiResponse<{ id: string; status: string; createdAt: string }>,\n SaferCityApiError,\n { userId: string; panicTypeId?: string; latitude: number; longitude: number; accuracy?: number; metadata?: Record<string, unknown> }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: (data) => client.panics.create(data),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.panics() });\n },\n ...options,\n });\n}\n\nexport function useUpdatePanicLocation(\n options?: UseMutationOptions<\n ApiResponse<{ id: string; latitude: number; longitude: number }>,\n SaferCityApiError,\n { panicId: string; data: { userId: string; latitude: number; longitude: number; accuracy?: number } }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: ({ panicId, data }) => client.panics.updateLocation(panicId, data),\n onSuccess: (_, { panicId }) => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.panicsDetail(panicId) });\n },\n ...options,\n });\n}\n\nexport function useCancelPanic(\n options?: UseMutationOptions<\n ApiResponse<{ id: string; status: string; cancelledAt: string }>,\n SaferCityApiError,\n { panicId: string; data: { userId: string; reason?: string } }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: ({ panicId, data }) => client.panics.cancel(panicId, data),\n onSuccess: (_, { panicId }) => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.panicsDetail(panicId) });\n queryClient.invalidateQueries({ queryKey: saferCityKeys.panicsList() });\n },\n ...options,\n });\n}\n\n// ==================\n// Subscription Hooks\n// ==================\n\nexport function useSubscriptionTypes(\n options?: Omit<UseQueryOptions<ApiResponse<{ types: Array<{ id: string; name: string; description?: string; price?: number }> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.subscriptionsTypes(),\n queryFn: () => client.subscriptions.listTypes(),\n staleTime: 1000 * 60 * 10, // 10 minutes - types don't change often\n ...options,\n });\n}\n\nexport function useSubscriptions(\n filters?: { userId?: string; status?: string; limit?: number },\n options?: Omit<UseQueryOptions<ApiResponse<{ subscriptions: Array<{ id: string; userId: string; subscriptionTypeId: string; status: string }> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.subscriptionsList(filters),\n queryFn: () => client.subscriptions.list(filters),\n ...options,\n });\n}\n\nexport function useCreateSubscription(\n options?: UseMutationOptions<\n ApiResponse<{ id: string; userId: string; subscriptionTypeId: string; status: string }>,\n SaferCityApiError,\n { userId: string; subscriptionTypeId: string; status?: string }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: (data) => client.subscriptions.create(data),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.subscriptions() });\n },\n ...options,\n });\n}\n\n// ==================\n// Location Safety Hooks\n// ==================\n\nexport function useLocationSafety(\n latitude: number,\n longitude: number,\n radius?: number,\n options?: Omit<UseQueryOptions<ApiResponse<{ safetyScore: number; riskLevel: string; factors: Array<{ type: string; impact: number }> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.locationSafety(latitude, longitude),\n queryFn: () => client.locationSafety.check({ latitude, longitude, radius }),\n enabled: latitude !== undefined && longitude !== undefined,\n staleTime: 1000 * 60 * 5, // 5 minutes\n ...options,\n });\n}\n\n// ==================\n// Crime Hooks\n// ==================\n\nexport function useCrimes(\n filters?: { latitude?: number; longitude?: number; radius?: number; type?: string; from?: string; to?: string; limit?: number },\n options?: Omit<UseQueryOptions<ApiResponse<{ crimes: Array<{ id: string; type: string; latitude: number; longitude: number; occurredAt: string }> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.crimesList(filters),\n queryFn: () => client.crimes.list(filters),\n ...options,\n });\n}\n\nexport function useCrimeCategories(\n options?: Omit<UseQueryOptions<ApiResponse<{ categories: Array<{ id: string; name: string }> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.crimesCategories(),\n queryFn: () => client.crimes.categories(),\n staleTime: 1000 * 60 * 30, // 30 minutes - categories rarely change\n ...options,\n });\n}\n\nexport function useCrimeTypes(\n options?: Omit<UseQueryOptions<ApiResponse<{ types: Array<{ id: string; name: string; categoryId: string }> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.crimesTypes(),\n queryFn: () => client.crimes.types(),\n staleTime: 1000 * 60 * 30, // 30 minutes\n ...options,\n });\n}\n","'use client';\n\nimport { useEffect, useRef, useState, useCallback } from 'react';\nimport { useSaferCityClient } from './provider';\nimport type { ServerSentEvent, EventSourceOptions } from '@safercity/sdk';\n\n/**\n * State for streaming hooks\n */\nexport interface StreamState<T = ServerSentEvent> {\n /**\n * Latest event received\n */\n data: T | null;\n \n /**\n * All events received (if keepHistory is true)\n */\n events: T[];\n \n /**\n * Whether the stream is currently connected\n */\n isConnected: boolean;\n \n /**\n * Whether the stream is connecting\n */\n isConnecting: boolean;\n \n /**\n * Error if connection failed\n */\n error: Error | null;\n}\n\nexport interface UseStreamOptions<T = ServerSentEvent> {\n /**\n * Whether to automatically connect on mount\n * @default true\n */\n autoConnect?: boolean;\n \n /**\n * Keep history of all events\n * @default false\n */\n keepHistory?: boolean;\n \n /**\n * Maximum number of events to keep in history\n * @default 100\n */\n maxHistory?: number;\n \n /**\n * Transform raw SSE event to custom type\n */\n transform?: (event: ServerSentEvent) => T;\n \n /**\n * Callback when connected\n */\n onOpen?: () => void;\n \n /**\n * Callback on each event\n */\n onEvent?: (event: T) => void;\n \n /**\n * Callback on error\n */\n onError?: (error: Error) => void;\n \n /**\n * Callback when disconnected\n */\n onClose?: () => void;\n}\n\n/**\n * Hook for streaming panic updates\n * \n * @example\n * ```tsx\n * function PanicTracker({ panicId }: { panicId: string }) {\n * const { data, isConnected, error } = usePanicStream(panicId, {\n * onEvent: (event) => console.log('Update:', event),\n * });\n * \n * if (error) return <div>Error: {error.message}</div>;\n * if (!isConnected) return <div>Connecting...</div>;\n * \n * return <div>Latest: {data?.data}</div>;\n * }\n * ```\n */\nexport function usePanicStream<T = ServerSentEvent>(\n panicId: string | null | undefined,\n options: UseStreamOptions<T> = {}\n) {\n const client = useSaferCityClient();\n const {\n autoConnect = true,\n keepHistory = false,\n maxHistory = 100,\n transform,\n onOpen,\n onEvent,\n onError,\n onClose,\n } = options;\n\n const [state, setState] = useState<StreamState<T>>({\n data: null,\n events: [],\n isConnected: false,\n isConnecting: false,\n error: null,\n });\n\n const abortControllerRef = useRef<AbortController | null>(null);\n const isActiveRef = useRef(false);\n\n const connect = useCallback(async () => {\n if (!panicId || isActiveRef.current) return;\n\n isActiveRef.current = true;\n abortControllerRef.current = new AbortController();\n\n setState((prev) => ({\n ...prev,\n isConnecting: true,\n error: null,\n }));\n\n try {\n const eventSourceOptions: EventSourceOptions = {\n signal: abortControllerRef.current.signal,\n onOpen: () => {\n setState((prev) => ({\n ...prev,\n isConnected: true,\n isConnecting: false,\n }));\n onOpen?.();\n },\n onError: (err) => {\n setState((prev) => ({\n ...prev,\n isConnected: false,\n isConnecting: false,\n error: err,\n }));\n onError?.(err);\n },\n };\n\n const stream = client.panics.streamUpdates(panicId, eventSourceOptions);\n\n for await (const event of stream) {\n if (!isActiveRef.current) break;\n\n const transformedEvent = transform ? transform(event) : (event as unknown as T);\n\n setState((prev) => {\n const newEvents = keepHistory\n ? [...prev.events, transformedEvent].slice(-maxHistory)\n : [];\n\n return {\n ...prev,\n data: transformedEvent,\n events: newEvents,\n };\n });\n\n onEvent?.(transformedEvent);\n }\n } catch (err) {\n if (isActiveRef.current) {\n const error = err instanceof Error ? err : new Error(String(err));\n setState((prev) => ({\n ...prev,\n isConnected: false,\n isConnecting: false,\n error,\n }));\n onError?.(error);\n }\n } finally {\n isActiveRef.current = false;\n setState((prev) => ({\n ...prev,\n isConnected: false,\n isConnecting: false,\n }));\n onClose?.();\n }\n }, [panicId, client, transform, keepHistory, maxHistory, onOpen, onEvent, onError, onClose]);\n\n const disconnect = useCallback(() => {\n isActiveRef.current = false;\n abortControllerRef.current?.abort();\n abortControllerRef.current = null;\n }, []);\n\n // Auto-connect when panicId changes\n useEffect(() => {\n if (autoConnect && panicId) {\n connect();\n }\n\n return () => {\n disconnect();\n };\n }, [autoConnect, panicId, connect, disconnect]);\n\n return {\n ...state,\n connect,\n disconnect,\n };\n}\n\n/**\n * Generic hook for any SSE stream\n */\nexport function useStream<T = ServerSentEvent>(\n createStream: () => AsyncIterable<ServerSentEvent>,\n options: UseStreamOptions<T> = {}\n) {\n const {\n autoConnect = true,\n keepHistory = false,\n maxHistory = 100,\n transform,\n onOpen,\n onEvent,\n onError,\n onClose,\n } = options;\n\n const [state, setState] = useState<StreamState<T>>({\n data: null,\n events: [],\n isConnected: false,\n isConnecting: false,\n error: null,\n });\n\n const isActiveRef = useRef(false);\n const createStreamRef = useRef(createStream);\n createStreamRef.current = createStream;\n\n const connect = useCallback(async () => {\n if (isActiveRef.current) return;\n\n isActiveRef.current = true;\n\n setState((prev) => ({\n ...prev,\n isConnecting: true,\n error: null,\n }));\n\n try {\n const stream = createStreamRef.current();\n\n setState((prev) => ({\n ...prev,\n isConnected: true,\n isConnecting: false,\n }));\n onOpen?.();\n\n for await (const event of stream) {\n if (!isActiveRef.current) break;\n\n const transformedEvent = transform ? transform(event) : (event as unknown as T);\n\n setState((prev) => {\n const newEvents = keepHistory\n ? [...prev.events, transformedEvent].slice(-maxHistory)\n : [];\n\n return {\n ...prev,\n data: transformedEvent,\n events: newEvents,\n };\n });\n\n onEvent?.(transformedEvent);\n }\n } catch (err) {\n if (isActiveRef.current) {\n const error = err instanceof Error ? err : new Error(String(err));\n setState((prev) => ({\n ...prev,\n isConnected: false,\n isConnecting: false,\n error,\n }));\n onError?.(error);\n }\n } finally {\n isActiveRef.current = false;\n setState((prev) => ({\n ...prev,\n isConnected: false,\n isConnecting: false,\n }));\n onClose?.();\n }\n }, [transform, keepHistory, maxHistory, onOpen, onEvent, onError, onClose]);\n\n const disconnect = useCallback(() => {\n isActiveRef.current = false;\n }, []);\n\n useEffect(() => {\n if (autoConnect) {\n connect();\n }\n\n return () => {\n disconnect();\n };\n }, [autoConnect, connect, disconnect]);\n\n return {\n ...state,\n connect,\n disconnect,\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/provider.tsx","../src/hooks.ts","../src/use-stream.ts"],"names":["createContext","useMemo","useState","createSaferCityClient","useEffect","useCallback","QueryClient","jsx","QueryClientProvider","useContext","useQuery","useQueryClient","useMutation","useRef"],"mappings":";;;;;;;AAsCA,IAAM,gBAAA,GAAmBA,oBAA4C,IAAI,CAAA;AAmDzE,SAAS,YAAY,KAAA,EAAgE;AACnF,EAAA,OAAO,EAAE,MAAA,IAAU,KAAA,CAAA,IAAU,MAAM,IAAA,KAAS,OAAA,IAAW,MAAM,IAAA,KAAS,MAAA;AACxE;AAEA,SAAS,aAAa,KAAA,EAAiE;AACrF,EAAA,OAAO,MAAA,IAAU,KAAA,IAAS,KAAA,CAAM,IAAA,KAAS,QAAA;AAC3C;AAEA,SAAS,aAAa,KAAA,EAAiE;AACrF,EAAA,OAAO,MAAA,IAAU,KAAA,IAAS,KAAA,CAAM,IAAA,KAAS,QAAA;AAC3C;AAEA,SAAS,aAAa,KAAA,EAA6D;AACjF,EAAA,OAAO,SAAA,IAAa,KAAA,IAAS,OAAA,IAAW,KAAA,IAAS,EAAE,MAAA,IAAU,KAAA,CAAA;AAC/D;AAqCO,SAAS,kBAAkB,KAAA,EAA+B;AAC/D,EAAA,MAAM,EAAE,QAAA,EAAU,WAAA,EAAa,mBAAA,EAAoB,GAAI,KAAA;AAGvD,EAAA,MAAM,IAAA,GAAiBC,cAAQ,MAAM;AACnC,IAAA,IAAI,YAAA,CAAa,KAAK,CAAA,EAAG,OAAO,QAAA;AAChC,IAAA,IAAI,YAAA,CAAa,KAAK,CAAA,EAAG,OAAO,QAAA;AACh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,KAAA,CAAM,MAAA,CAAO,GAAG,CAAC,CAAA;AAChE,QAAA,QAAA,CAAS,CAAC,IAAA,MAAU;AAAA,UAClB,GAAG,IAAA;AAAA,UACH,WAAA,EAAa,KAAA;AAAA,UACb,YAAA,EAAc,KAAA;AAAA,UACd;AAAA,SACF,CAAE,CAAA;AACF,QAAA,OAAA,GAAU,KAAK,CAAA;AAAA,MACjB;AAAA,IACF,CAAA,SAAE;AACA,MAAA,WAAA,CAAY,OAAA,GAAU,KAAA;AACtB,MAAA,QAAA,CAAS,CAAC,IAAA,MAAU;AAAA,QAClB,GAAG,IAAA;AAAA,QACH,WAAA,EAAa,KAAA;AAAA,QACb,YAAA,EAAc;AAAA,OAChB,CAAE,CAAA;AACF,MAAA,OAAA,IAAU;AAAA,IACZ;AAAA,EACF,CAAA,EAAG,CAAC,SAAA,EAAW,WAAA,EAAa,YAAY,MAAA,EAAQ,OAAA,EAAS,OAAA,EAAS,OAAO,CAAC,CAAA;AAE1E,EAAA,MAAM,UAAA,GAAaA,kBAAY,MAAM;AACnC,IAAA,WAAA,CAAY,OAAA,GAAU,KAAA;AAAA,EACxB,CAAA,EAAG,EAAE,CAAA;AAEL,EAAAD,gBAAU,MAAM;AACd,IAAA,IAAI,WAAA,EAAa;AACf,MAAA,OAAA,EAAQ;AAAA,IACV;AAEA,IAAA,OAAO,MAAM;AACX,MAAA,UAAA,EAAW;AAAA,IACb,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,WAAA,EAAa,OAAA,EAAS,UAAU,CAAC,CAAA;AAErC,EAAA,OAAO;AAAA,IACL,GAAG,KAAA;AAAA,IACH,OAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["'use client';\n\nimport { createContext, useContext, useMemo, useCallback, useState, useEffect, type ReactNode } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { createSaferCityClient, type SaferCityClient, type SaferCityClientOptions } from '@safercity/sdk';\nimport type { AuthMode, ProxyModeConfig, DirectModeConfig, CookieModeConfig } from '@safercity/sdk';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Session state for cookie-based auth\n */\nexport interface SessionState {\n isAuthenticated: boolean;\n isLoading: boolean;\n userId?: string;\n tenantId?: string;\n expiresAt?: number;\n error?: Error;\n}\n\n/**\n * Context value for SaferCity provider\n */\ninterface SaferCityContextValue {\n client: SaferCityClient;\n mode: AuthMode;\n session: SessionState;\n /** Create session from external JWT (cookie mode only) */\n createSession: (token: string, tenantId?: string) => Promise<void>;\n /** Clear current session (cookie mode only) */\n clearSession: () => Promise<void>;\n /** Refresh CSRF token (cookie mode only) */\n refreshCsrf: () => Promise<string | undefined>;\n}\n\nconst SaferCityContext = createContext<SaferCityContextValue | null>(null);\n\n// ============================================================================\n// Provider Props\n// ============================================================================\n\n/**\n * Base props for all modes\n */\ninterface BaseProviderProps {\n children: ReactNode;\n queryClient?: QueryClient;\n}\n\n/**\n * Props for proxy mode (DEFAULT)\n */\nexport interface ProxyModeProviderProps extends BaseProviderProps, ProxyModeConfig {}\n\n/**\n * Props for direct mode\n */\nexport interface DirectModeProviderProps extends BaseProviderProps, DirectModeConfig {\n userId?: string;\n}\n\n/**\n * Props for cookie mode\n */\nexport interface CookieModeProviderProps extends BaseProviderProps, CookieModeConfig {\n userId?: string;\n}\n\n/**\n * Legacy props (for backward compatibility)\n */\nexport interface LegacyProviderProps extends BaseProviderProps, SaferCityClientOptions {}\n\n/**\n * Combined props type\n */\nexport type SaferCityProviderProps = \n | ProxyModeProviderProps \n | DirectModeProviderProps \n | CookieModeProviderProps\n | LegacyProviderProps;\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\nfunction isProxyMode(props: SaferCityProviderProps): props is ProxyModeProviderProps {\n return !('mode' in props) || props.mode === 'proxy' || props.mode === undefined;\n}\n\nfunction isDirectMode(props: SaferCityProviderProps): props is DirectModeProviderProps {\n return 'mode' in props && props.mode === 'direct';\n}\n\nfunction isCookieMode(props: SaferCityProviderProps): props is CookieModeProviderProps {\n return 'mode' in props && props.mode === 'cookie';\n}\n\nfunction isLegacyMode(props: SaferCityProviderProps): props is LegacyProviderProps {\n return 'baseUrl' in props && 'token' in props && !('mode' in props);\n}\n\n// ============================================================================\n// Provider Component\n// ============================================================================\n\n/**\n * Provider component for SaferCity SDK\n * \n * Supports three authentication modes:\n * \n * **Proxy Mode (Default)** - Most secure, recommended for production\n * ```tsx\n * <SaferCityProvider mode=\"proxy\" proxyBaseUrl=\"/api/safercity\">\n * <App />\n * </SaferCityProvider>\n * ```\n * \n * **Direct Mode** - For white-label apps with external auth\n * ```tsx\n * <SaferCityProvider\n * mode=\"direct\"\n * baseUrl=\"https://api.safercity.com\"\n * tenantId=\"tenant-123\"\n * getAccessToken={() => session?.accessToken}\n * >\n * <App />\n * </SaferCityProvider>\n * ```\n * \n * **Cookie Mode** - For first-party web apps\n * ```tsx\n * <SaferCityProvider mode=\"cookie\" baseUrl=\"https://api.safercity.com\">\n * <App />\n * </SaferCityProvider>\n * ```\n */\nexport function SaferCityProvider(props: SaferCityProviderProps) {\n const { children, queryClient: externalQueryClient } = props;\n \n // Determine mode\n const mode: AuthMode = useMemo(() => {\n if (isDirectMode(props)) return 'direct';\n if (isCookieMode(props)) return 'cookie';\n return 'proxy';\n }, [props]);\n\n // Session state for cookie mode\n const [session, setSession] = useState<SessionState>({\n isAuthenticated: false,\n isLoading: mode === 'cookie',\n });\n\n // Create client based on mode\n const client = useMemo(() => {\n if (isLegacyMode(props)) {\n // Legacy mode - direct token\n return createSaferCityClient({\n baseUrl: props.baseUrl,\n token: props.token,\n tenantId: props.tenantId,\n fetch: props.fetch,\n timeout: props.timeout,\n headers: props.headers,\n });\n }\n\n if (isProxyMode(props)) {\n // Proxy mode - requests go through local proxy\n const proxyBaseUrl = props.proxyBaseUrl ?? '/api/safercity';\n return createSaferCityClient({\n baseUrl: proxyBaseUrl,\n });\n }\n\n if (isDirectMode(props)) {\n // Direct mode - use external token\n return createSaferCityClient({\n baseUrl: props.baseUrl,\n tenantId: props.tenantId,\n userId: props.userId,\n });\n }\n\n if (isCookieMode(props)) {\n // Cookie mode - credentials included automatically\n return createSaferCityClient({\n baseUrl: props.baseUrl,\n tenantId: props.tenantId,\n userId: props.userId,\n headers: {\n // Note: cookies are sent automatically with fetch credentials: 'include'\n },\n });\n }\n\n throw new Error('Invalid SaferCityProvider configuration');\n }, [props]);\n\n // Token getter for direct mode\n const directModeTokenGetter = isDirectMode(props) ? props.getAccessToken : null;\n\n // Update token for direct mode\n useEffect(() => {\n if (!directModeTokenGetter) return;\n\n let isMounted = true;\n \n const updateToken = async () => {\n const token = await directModeTokenGetter();\n if (isMounted) {\n client.setToken(token);\n }\n };\n\n updateToken();\n\n // Re-check token periodically\n const interval = setInterval(updateToken, 30000);\n return () => {\n isMounted = false;\n clearInterval(interval);\n };\n }, [client, directModeTokenGetter]);\n\n // Check session status for cookie mode\n useEffect(() => {\n if (mode !== 'cookie') return;\n if (!isCookieMode(props)) return;\n\n let isMounted = true;\n\n const checkSession = async () => {\n try {\n const response = await fetch(`${props.baseUrl}/v1/auth/session/status`, {\n credentials: 'include',\n });\n \n if (!isMounted) return;\n\n if (response.ok) {\n const data = await response.json();\n client.setUserId(data.userId);\n setSession({\n isAuthenticated: data.authenticated,\n isLoading: false,\n userId: data.userId,\n tenantId: data.tenantId,\n expiresAt: data.expiresAt,\n });\n } else {\n setSession({\n isAuthenticated: false,\n isLoading: false,\n });\n }\n } catch (error) {\n if (!isMounted) return;\n setSession({\n isAuthenticated: false,\n isLoading: false,\n error: error instanceof Error ? error : new Error('Session check failed'),\n });\n }\n };\n\n checkSession();\n\n return () => {\n isMounted = false;\n };\n }, [mode, props, client]);\n\n // Create session (cookie mode)\n const createSession = useCallback(async (token: string, tenantId?: string) => {\n if (mode !== 'cookie' || !isCookieMode(props)) {\n throw new Error('createSession is only available in cookie mode');\n }\n\n setSession(prev => ({ ...prev, isLoading: true, error: undefined }));\n\n try {\n const response = await fetch(`${props.baseUrl}/v1/auth/session`, {\n method: 'POST',\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n ...(tenantId && { 'X-Tenant-ID': tenantId }),\n },\n body: JSON.stringify({ token, tenantId }),\n });\n\n if (!response.ok) {\n const error = await response.json();\n throw new Error(error.message || 'Failed to create session');\n }\n\n const data = await response.json();\n \n setSession({\n isAuthenticated: true,\n isLoading: false,\n expiresAt: data.expiresAt,\n tenantId,\n });\n } catch (error) {\n setSession({\n isAuthenticated: false,\n isLoading: false,\n error: error instanceof Error ? error : new Error('Failed to create session'),\n });\n throw error;\n }\n }, [mode, props]);\n\n // Clear session (cookie mode)\n const clearSession = useCallback(async () => {\n if (mode !== 'cookie' || !isCookieMode(props)) {\n throw new Error('clearSession is only available in cookie mode');\n }\n\n try {\n await fetch(`${props.baseUrl}/v1/auth/session/logout`, {\n method: 'POST',\n credentials: 'include',\n });\n } finally {\n setSession({\n isAuthenticated: false,\n isLoading: false,\n });\n }\n }, [mode, props]);\n\n // Refresh CSRF token (cookie mode)\n const refreshCsrf = useCallback(async (): Promise<string | undefined> => {\n if (mode !== 'cookie' || !isCookieMode(props)) {\n throw new Error('refreshCsrf is only available in cookie mode');\n }\n\n try {\n const response = await fetch(`${props.baseUrl}/v1/auth/session/refresh`, {\n method: 'POST',\n credentials: 'include',\n });\n\n if (response.ok) {\n const data = await response.json();\n return data.csrfToken;\n }\n } catch {\n // Ignore errors\n }\n \n return undefined;\n }, [mode, props]);\n\n // Create QueryClient\n const queryClient = useMemo(\n () => externalQueryClient ?? new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 1000 * 60, // 1 minute\n gcTime: 1000 * 60 * 5, // 5 minutes\n retry: 1,\n refetchOnWindowFocus: false,\n },\n mutations: {\n retry: 0,\n },\n },\n }),\n [externalQueryClient]\n );\n\n const contextValue = useMemo(() => ({\n client,\n mode,\n session,\n createSession,\n clearSession,\n refreshCsrf,\n }), [client, mode, session, createSession, clearSession, refreshCsrf]);\n\n return (\n <QueryClientProvider client={queryClient}>\n <SaferCityContext.Provider value={contextValue}>\n {children}\n </SaferCityContext.Provider>\n </QueryClientProvider>\n );\n}\n\n// ============================================================================\n// Hooks\n// ============================================================================\n\n/**\n * Hook to access the full SaferCity context\n */\nexport function useSaferCity(): SaferCityContextValue {\n const context = useContext(SaferCityContext);\n \n if (!context) {\n throw new Error(\n 'useSaferCity must be used within a SaferCityProvider. ' +\n 'Make sure your component is wrapped with <SaferCityProvider>.'\n );\n }\n \n return context;\n}\n\n/**\n * Hook to access the SaferCity client\n */\nexport function useSaferCityClient(): SaferCityClient {\n return useSaferCity().client;\n}\n\n/**\n * Hook to access session state (cookie mode)\n */\nexport function useSession(): SessionState {\n return useSaferCity().session;\n}\n\n/**\n * Hook to get the current auth mode\n */\nexport function useAuthMode(): AuthMode {\n return useSaferCity().mode;\n}\n\n/**\n * Hook to manage session (cookie mode)\n */\nexport function useSessionManager() {\n const { createSession, clearSession, refreshCsrf, session } = useSaferCity();\n \n return {\n session,\n createSession,\n clearSession,\n refreshCsrf,\n isAuthenticated: session.isAuthenticated,\n isLoading: session.isLoading,\n };\n}\n","'use client';\n\nimport { useQuery, useMutation, useQueryClient, type UseQueryOptions, type UseMutationOptions } from '@tanstack/react-query';\nimport { useSaferCityClient } from './provider';\nimport type { ApiResponse, SaferCityApiError, PanicInformationRecord } from '@safercity/sdk';\n\n// ==================\n// Query Keys Factory\n// ==================\n\nexport const saferCityKeys = {\n all: ['safercity'] as const,\n \n // Health\n health: () => [...saferCityKeys.all, 'health'] as const,\n \n // Auth\n auth: () => [...saferCityKeys.all, 'auth'] as const,\n authWhoami: () => [...saferCityKeys.auth(), 'whoami'] as const,\n \n // Users\n users: () => [...saferCityKeys.all, 'users'] as const,\n usersDetail: (userId: string) => [...saferCityKeys.users(), 'detail', userId] as const,\n \n // Panics\n panics: () => [...saferCityKeys.all, 'panics'] as const,\n panicsList: (filters?: Record<string, unknown>) => [...saferCityKeys.panics(), 'list', filters] as const,\n panicsDetail: (panicId: string) => [...saferCityKeys.panics(), 'detail', panicId] as const,\n panicTypes: (userId: string) => [...saferCityKeys.panics(), 'types', userId] as const,\n \n // Panic Information\n panicInformation: () => [...saferCityKeys.all, 'panicInformation'] as const,\n panicInformationDetail: (id: string) => [...saferCityKeys.panicInformation(), 'detail', id] as const,\n panicInformationByUser: (userId: string) => [...saferCityKeys.panicInformation(), 'byUser', userId] as const,\n panicEligibility: (userId: string) => [...saferCityKeys.panicInformation(), 'eligibility', userId] as const,\n \n // Subscriptions\n subscriptions: () => [...saferCityKeys.all, 'subscriptions'] as const,\n subscriptionsList: (filters?: Record<string, unknown>) => [...saferCityKeys.subscriptions(), 'list', filters] as const,\n subscriptionsTypes: () => [...saferCityKeys.subscriptions(), 'types'] as const,\n subscriptionsStats: () => [...saferCityKeys.subscriptions(), 'stats'] as const,\n \n // Location Safety\n locationSafety: (lat: number, lng: number) => [...saferCityKeys.all, 'location-safety', lat, lng] as const,\n \n // Banner\n banner: (body: { latitude: number; longitude: number; radius?: number }) => [...saferCityKeys.all, 'banner', body] as const,\n \n // Crimes\n crimes: () => [...saferCityKeys.all, 'crimes'] as const,\n crimesList: (filters?: Record<string, unknown>) => [...saferCityKeys.crimes(), 'list', filters] as const,\n crimesCategories: () => [...saferCityKeys.crimes(), 'categories'] as const,\n crimesTypes: () => [...saferCityKeys.crimes(), 'types'] as const,\n crimeCategoriesWithTypes: () => [...saferCityKeys.crimes(), 'categoriesWithTypes'] as const,\n};\n\n// ==================\n// Health Hooks\n// ==================\n\nexport function useHealthCheck(\n options?: Omit<UseQueryOptions<ApiResponse<{ status: string; timestamp: string }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.health(),\n queryFn: () => client.health.check(),\n ...options,\n });\n}\n\n// ==================\n// Auth Hooks\n// ==================\n\nexport function useWhoAmI(\n options?: Omit<UseQueryOptions<ApiResponse<{ tenantId: string | null; environment: string; scopes: string[]; sessionId: string }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.authWhoami(),\n queryFn: () => client.auth.whoami(),\n ...options,\n });\n}\n\n// ==================\n// User Hooks\n// ==================\n\nexport function useUser(\n userId: string,\n options?: Omit<UseQueryOptions<ApiResponse<{ id: string; email?: string; phone?: string; firstName?: string; lastName?: string; status: string; metadata?: Record<string, unknown> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.usersDetail(userId),\n queryFn: () => client.users.get(userId),\n enabled: !!userId,\n ...options,\n });\n}\n\nexport function useCreateUser(\n options?: UseMutationOptions<\n ApiResponse<{ id: string; email?: string; phone?: string }>,\n SaferCityApiError,\n { email?: string; phone?: string; firstName?: string; lastName?: string; metadata?: Record<string, unknown> }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: (data) => client.users.create(data),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.users() });\n },\n ...options,\n });\n}\n\nexport function useUpdateUser(\n options?: UseMutationOptions<\n ApiResponse<{ id: string }>,\n SaferCityApiError,\n { userId: string; data: { email?: string; phone?: string; firstName?: string; lastName?: string; metadata?: Record<string, unknown> } }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: ({ userId, data }) => client.users.update(userId, data),\n onSuccess: (_, { userId }) => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.usersDetail(userId) });\n },\n ...options,\n });\n}\n\n// ==================\n// Panic Hooks\n// ==================\n\nexport function usePanic(\n panicId: string,\n query?: { userId?: string },\n options?: Omit<UseQueryOptions<ApiResponse<{ id: string; userId: string; status: string; latitude: number; longitude: number; createdAt: string; updatedAt?: string }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.panicsDetail(panicId),\n queryFn: () => client.panics.get(panicId, query),\n enabled: !!panicId,\n ...options,\n });\n}\n\nexport function useCreatePanic(\n options?: UseMutationOptions<\n ApiResponse<{ id: string; status: string; createdAt: string }>,\n SaferCityApiError,\n { userId: string; panicTypeId?: string; latitude: number; longitude: number; accuracy?: number; metadata?: Record<string, unknown> }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: (data) => client.panics.create(data),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.panics() });\n },\n ...options,\n });\n}\n\nexport function useUpdatePanicLocation(\n options?: UseMutationOptions<\n ApiResponse<{ id: string; latitude: number; longitude: number }>,\n SaferCityApiError,\n { panicId: string; data: { userId: string; latitude: number; longitude: number; accuracy?: number } }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: ({ panicId, data }) => client.panics.updateLocation(panicId, data),\n onSuccess: (_, { panicId }) => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.panicsDetail(panicId) });\n },\n ...options,\n });\n}\n\nexport function useCancelPanic(\n options?: UseMutationOptions<\n ApiResponse<{ id: string; status: string; cancelledAt: string }>,\n SaferCityApiError,\n { panicId: string; data: { userId: string; reason?: string } }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: ({ panicId, data }) => client.panics.cancel(panicId, data),\n onSuccess: (_, { panicId }) => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.panicsDetail(panicId) });\n queryClient.invalidateQueries({ queryKey: saferCityKeys.panicsList() });\n },\n ...options,\n });\n}\n\nexport function usePanicTypes(\n userId: string,\n options?: Omit<UseQueryOptions<ApiResponse<{ types: Array<{ id: string; name: string; description?: string }> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.panicTypes(userId),\n queryFn: () => client.panics.types(userId),\n enabled: !!userId,\n staleTime: 1000 * 60 * 10, // 10 minutes - types don't change often\n ...options,\n });\n}\n\n// ==================\n// Panic Information Hooks\n// ==================\n\nexport function usePanicInformation(\n id: string,\n options?: Omit<UseQueryOptions<ApiResponse<{ success: boolean; data: PanicInformationRecord }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.panicInformationDetail(id),\n queryFn: () => client.panicInformation.get(id),\n enabled: !!id,\n ...options,\n });\n}\n\nexport function usePanicInformationByUser(\n userId: string,\n options?: Omit<UseQueryOptions<ApiResponse<{ success: boolean; data: PanicInformationRecord }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.panicInformationByUser(userId),\n queryFn: () => client.panicInformation.getByUser(userId),\n enabled: !!userId,\n ...options,\n });\n}\n\nexport function usePanicEligibility(\n userId: string,\n options?: Omit<UseQueryOptions<ApiResponse<{\n success: boolean;\n data: {\n eligible: boolean;\n subscriptionActive: boolean;\n profileComplete: boolean;\n reasons: string[];\n panicInformation: PanicInformationRecord | null;\n subscriptionDetails: {\n usedSeats: number;\n userHasActiveSubscription: boolean;\n } | null;\n };\n }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.panicEligibility(userId),\n queryFn: () => client.panicInformation.validateEligibility(userId),\n enabled: !!userId,\n ...options,\n });\n}\n\nexport function useCreatePanicInformation(\n options?: UseMutationOptions<\n ApiResponse<{ success: boolean; data: PanicInformationRecord; message: string }>,\n SaferCityApiError,\n {\n userId: string;\n phoneNumber: string;\n firstName: string;\n lastName: string;\n idNumber: string;\n duressCode?: string;\n emergencyContacts?: Array<{ name: string; phoneNumber: string; relationship?: string }>;\n }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: (data) => client.panicInformation.create(data),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.panicInformation() });\n },\n ...options,\n });\n}\n\nexport function useUpdatePanicInformation(\n options?: UseMutationOptions<\n ApiResponse<{ success: boolean; data: PanicInformationRecord; message: string }>,\n SaferCityApiError,\n {\n id: string;\n data: {\n phoneNumber?: string;\n firstName?: string;\n lastName?: string;\n idNumber?: string;\n duressCode?: string;\n emergencyContacts?: Array<{ name: string; phoneNumber: string; relationship?: string }>;\n };\n }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: ({ id, data }) => client.panicInformation.update(id, data),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.panicInformation() });\n },\n ...options,\n });\n}\n\nexport function useDeletePanicInformation(\n options?: UseMutationOptions<\n ApiResponse<{ success: boolean; message: string }>,\n SaferCityApiError,\n string\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: (id) => client.panicInformation.delete(id),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.panicInformation() });\n },\n ...options,\n });\n}\n\n// ==================\n// Subscription Hooks\n// ==================\n\nexport function useSubscriptionTypes(\n options?: Omit<UseQueryOptions<ApiResponse<{ types: Array<{ id: string; name: string; description?: string; price?: number }> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.subscriptionsTypes(),\n queryFn: () => client.subscriptions.listTypes(),\n staleTime: 1000 * 60 * 10, // 10 minutes - types don't change often\n ...options,\n });\n}\n\nexport function useSubscriptions(\n filters?: { userId?: string; status?: string; limit?: number },\n options?: Omit<UseQueryOptions<ApiResponse<{ subscriptions: Array<{ id: string; userId: string; subscriptionTypeId: string; status: string }> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.subscriptionsList(filters),\n queryFn: () => client.subscriptions.list(filters),\n ...options,\n });\n}\n\nexport function useCreateSubscription(\n options?: UseMutationOptions<\n ApiResponse<{ id: string; userId: string; subscriptionTypeId: string; status: string }>,\n SaferCityApiError,\n { userId: string; subscriptionTypeId: string; status?: string }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: (data) => client.subscriptions.create(data),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.subscriptions() });\n },\n ...options,\n });\n}\n\nexport function useSubscribeUser(\n options?: UseMutationOptions<\n ApiResponse<{ id: string; userId: string; subscriptionTypeId: string; status: string }>,\n SaferCityApiError,\n { userId: string; subscriptionTypeId: string }\n >\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: (body) => client.subscriptions.subscribeUser(body),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.subscriptions() });\n },\n ...options,\n });\n}\n\n// ==================\n// Notification Hooks\n// ==================\n\nexport function useBulkTriggerNotifications(\n options?: UseMutationOptions<\n ApiResponse<{ transactionIds: string[]; status: string }>,\n SaferCityApiError,\n { userIds: string[]; workflowId: string; payload?: Record<string, unknown> }\n >\n) {\n const client = useSaferCityClient();\n \n return useMutation({\n mutationFn: (body) => client.notifications.bulkTrigger(body),\n ...options,\n });\n}\n\n// ==================\n// Location Safety Hooks\n// ==================\n\nexport function useLocationSafety(\n latitude: number,\n longitude: number,\n radius?: number,\n options?: Omit<UseQueryOptions<ApiResponse<{ safetyScore: number; riskLevel: string; factors: Array<{ type: string; impact: number }> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.locationSafety(latitude, longitude),\n queryFn: () => client.locationSafety.check({ latitude, longitude, radius }),\n enabled: latitude !== undefined && longitude !== undefined,\n staleTime: 1000 * 60 * 5, // 5 minutes\n ...options,\n });\n}\n\n// ==================\n// Banner Hooks\n// ==================\n\nexport function useBanner(\n body: { latitude: number; longitude: number; radius?: number },\n options?: Omit<UseQueryOptions<ApiResponse<{\n success: boolean;\n data: {\n totalCrimes: number;\n categories: Array<{ name: string; count: number }>;\n period: string;\n };\n }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.banner(body),\n queryFn: () => client.banner.get(body),\n enabled: body.latitude !== undefined && body.longitude !== undefined,\n staleTime: 1000 * 60 * 5, // 5 minutes - location-based, changes moderately\n ...options,\n });\n}\n\n// ==================\n// Crime Hooks\n// ==================\n\nexport function useCrimes(\n filters?: { latitude?: number; longitude?: number; radius?: number; type?: string; from?: string; to?: string; limit?: number },\n options?: Omit<UseQueryOptions<ApiResponse<{ crimes: Array<{ id: string; type: string; latitude: number; longitude: number; occurredAt: string }> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.crimesList(filters),\n queryFn: () => client.crimes.list(filters),\n ...options,\n });\n}\n\nexport function useCrimeCategories(\n options?: Omit<UseQueryOptions<ApiResponse<{ categories: Array<{ id: string; name: string }> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.crimesCategories(),\n queryFn: () => client.crimes.categories(),\n staleTime: 1000 * 60 * 30, // 30 minutes - categories rarely change\n ...options,\n });\n}\n\nexport function useCrimeTypes(\n options?: Omit<UseQueryOptions<ApiResponse<{ types: Array<{ id: string; name: string; categoryId: string }> }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.crimesTypes(),\n queryFn: () => client.crimes.types(),\n staleTime: 1000 * 60 * 30, // 30 minutes\n ...options,\n });\n}\n\nexport function useCrimeCategoriesWithTypes(\n options?: Omit<UseQueryOptions<ApiResponse<{\n categories: Array<{\n id: string;\n name: string;\n types: Array<{ id: string; name: string }>;\n }>;\n }>, SaferCityApiError>, 'queryKey' | 'queryFn'>\n) {\n const client = useSaferCityClient();\n \n return useQuery({\n queryKey: saferCityKeys.crimeCategoriesWithTypes(),\n queryFn: () => client.crimes.categoriesWithTypes(),\n staleTime: 1000 * 60 * 30, // 30 minutes - categories rarely change\n ...options,\n });\n}\n","'use client';\n\nimport { useEffect, useRef, useState, useCallback } from 'react';\nimport { useSaferCityClient } from './provider';\nimport type { ServerSentEvent, EventSourceOptions } from '@safercity/sdk';\n\n/**\n * State for streaming hooks\n */\nexport interface StreamState<T = ServerSentEvent> {\n /**\n * Latest event received\n */\n data: T | null;\n \n /**\n * All events received (if keepHistory is true)\n */\n events: T[];\n \n /**\n * Whether the stream is currently connected\n */\n isConnected: boolean;\n \n /**\n * Whether the stream is connecting\n */\n isConnecting: boolean;\n \n /**\n * Error if connection failed\n */\n error: Error | null;\n}\n\nexport interface UseStreamOptions<T = ServerSentEvent> {\n /**\n * Whether to automatically connect on mount\n * @default true\n */\n autoConnect?: boolean;\n \n /**\n * Keep history of all events\n * @default false\n */\n keepHistory?: boolean;\n \n /**\n * Maximum number of events to keep in history\n * @default 100\n */\n maxHistory?: number;\n \n /**\n * Transform raw SSE event to custom type\n */\n transform?: (event: ServerSentEvent) => T;\n \n /**\n * Callback when connected\n */\n onOpen?: () => void;\n \n /**\n * Callback on each event\n */\n onEvent?: (event: T) => void;\n \n /**\n * Callback on error\n */\n onError?: (error: Error) => void;\n \n /**\n * Callback when disconnected\n */\n onClose?: () => void;\n}\n\n/**\n * Hook for streaming panic updates\n * \n * @example\n * ```tsx\n * function PanicTracker({ panicId }: { panicId: string }) {\n * const { data, isConnected, error } = usePanicStream(panicId, {\n * onEvent: (event) => console.log('Update:', event),\n * });\n * \n * if (error) return <div>Error: {error.message}</div>;\n * if (!isConnected) return <div>Connecting...</div>;\n * \n * return <div>Latest: {data?.data}</div>;\n * }\n * ```\n */\nexport function usePanicStream<T = ServerSentEvent>(\n panicId: string | null | undefined,\n options: UseStreamOptions<T> = {}\n) {\n const client = useSaferCityClient();\n const {\n autoConnect = true,\n keepHistory = false,\n maxHistory = 100,\n transform,\n onOpen,\n onEvent,\n onError,\n onClose,\n } = options;\n\n const [state, setState] = useState<StreamState<T>>({\n data: null,\n events: [],\n isConnected: false,\n isConnecting: false,\n error: null,\n });\n\n const abortControllerRef = useRef<AbortController | null>(null);\n const isActiveRef = useRef(false);\n\n const connect = useCallback(async () => {\n if (!panicId || isActiveRef.current) return;\n\n isActiveRef.current = true;\n abortControllerRef.current = new AbortController();\n\n setState((prev) => ({\n ...prev,\n isConnecting: true,\n error: null,\n }));\n\n try {\n const eventSourceOptions: EventSourceOptions = {\n signal: abortControllerRef.current.signal,\n onOpen: () => {\n setState((prev) => ({\n ...prev,\n isConnected: true,\n isConnecting: false,\n }));\n onOpen?.();\n },\n onError: (err) => {\n setState((prev) => ({\n ...prev,\n isConnected: false,\n isConnecting: false,\n error: err,\n }));\n onError?.(err);\n },\n };\n\n const stream = client.panics.streamUpdates(panicId, eventSourceOptions);\n\n for await (const event of stream) {\n if (!isActiveRef.current) break;\n\n const transformedEvent = transform ? transform(event) : (event as unknown as T);\n\n setState((prev) => {\n const newEvents = keepHistory\n ? [...prev.events, transformedEvent].slice(-maxHistory)\n : [];\n\n return {\n ...prev,\n data: transformedEvent,\n events: newEvents,\n };\n });\n\n onEvent?.(transformedEvent);\n }\n } catch (err) {\n if (isActiveRef.current) {\n const error = err instanceof Error ? err : new Error(String(err));\n setState((prev) => ({\n ...prev,\n isConnected: false,\n isConnecting: false,\n error,\n }));\n onError?.(error);\n }\n } finally {\n isActiveRef.current = false;\n setState((prev) => ({\n ...prev,\n isConnected: false,\n isConnecting: false,\n }));\n onClose?.();\n }\n }, [panicId, client, transform, keepHistory, maxHistory, onOpen, onEvent, onError, onClose]);\n\n const disconnect = useCallback(() => {\n isActiveRef.current = false;\n abortControllerRef.current?.abort();\n abortControllerRef.current = null;\n }, []);\n\n // Auto-connect when panicId changes\n useEffect(() => {\n if (autoConnect && panicId) {\n connect();\n }\n\n return () => {\n disconnect();\n };\n }, [autoConnect, panicId, connect, disconnect]);\n\n return {\n ...state,\n connect,\n disconnect,\n };\n}\n\n/**\n * Generic hook for any SSE stream\n */\nexport function useStream<T = ServerSentEvent>(\n createStream: () => AsyncIterable<ServerSentEvent>,\n options: UseStreamOptions<T> = {}\n) {\n const {\n autoConnect = true,\n keepHistory = false,\n maxHistory = 100,\n transform,\n onOpen,\n onEvent,\n onError,\n onClose,\n } = options;\n\n const [state, setState] = useState<StreamState<T>>({\n data: null,\n events: [],\n isConnected: false,\n isConnecting: false,\n error: null,\n });\n\n const isActiveRef = useRef(false);\n const createStreamRef = useRef(createStream);\n createStreamRef.current = createStream;\n\n const connect = useCallback(async () => {\n if (isActiveRef.current) return;\n\n isActiveRef.current = true;\n\n setState((prev) => ({\n ...prev,\n isConnecting: true,\n error: null,\n }));\n\n try {\n const stream = createStreamRef.current();\n\n setState((prev) => ({\n ...prev,\n isConnected: true,\n isConnecting: false,\n }));\n onOpen?.();\n\n for await (const event of stream) {\n if (!isActiveRef.current) break;\n\n const transformedEvent = transform ? transform(event) : (event as unknown as T);\n\n setState((prev) => {\n const newEvents = keepHistory\n ? [...prev.events, transformedEvent].slice(-maxHistory)\n : [];\n\n return {\n ...prev,\n data: transformedEvent,\n events: newEvents,\n };\n });\n\n onEvent?.(transformedEvent);\n }\n } catch (err) {\n if (isActiveRef.current) {\n const error = err instanceof Error ? err : new Error(String(err));\n setState((prev) => ({\n ...prev,\n isConnected: false,\n isConnecting: false,\n error,\n }));\n onError?.(error);\n }\n } finally {\n isActiveRef.current = false;\n setState((prev) => ({\n ...prev,\n isConnected: false,\n isConnecting: false,\n }));\n onClose?.();\n }\n }, [transform, keepHistory, maxHistory, onOpen, onEvent, onError, onClose]);\n\n const disconnect = useCallback(() => {\n isActiveRef.current = false;\n }, []);\n\n useEffect(() => {\n if (autoConnect) {\n connect();\n }\n\n return () => {\n disconnect();\n };\n }, [autoConnect, connect, disconnect]);\n\n return {\n ...state,\n connect,\n disconnect,\n };\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ProxyModeConfig, DirectModeConfig, CookieModeConfig, SaferCityClientOptions, SaferCityClient, AuthMode, ApiResponse, SaferCityApiError, ServerSentEvent } from '@safercity/sdk';
1
+ import { ProxyModeConfig, DirectModeConfig, CookieModeConfig, SaferCityClientOptions, SaferCityClient, AuthMode, ApiResponse, SaferCityApiError, PanicInformationRecord, ServerSentEvent } from '@safercity/sdk';
2
2
  export * from '@safercity/sdk';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { ReactNode } from 'react';
@@ -46,11 +46,13 @@ interface ProxyModeProviderProps extends BaseProviderProps, ProxyModeConfig {
46
46
  * Props for direct mode
47
47
  */
48
48
  interface DirectModeProviderProps extends BaseProviderProps, DirectModeConfig {
49
+ userId?: string;
49
50
  }
50
51
  /**
51
52
  * Props for cookie mode
52
53
  */
53
54
  interface CookieModeProviderProps extends BaseProviderProps, CookieModeConfig {
55
+ userId?: string;
54
56
  }
55
57
  /**
56
58
  * Legacy props (for backward compatibility)
@@ -127,20 +129,34 @@ declare const saferCityKeys: {
127
129
  auth: () => readonly ["safercity", "auth"];
128
130
  authWhoami: () => readonly ["safercity", "auth", "whoami"];
129
131
  users: () => readonly ["safercity", "users"];
130
- usersList: (filters?: Record<string, unknown>) => readonly ["safercity", "users", "list", Record<string, unknown> | undefined];
131
132
  usersDetail: (userId: string) => readonly ["safercity", "users", "detail", string];
132
133
  panics: () => readonly ["safercity", "panics"];
133
134
  panicsList: (filters?: Record<string, unknown>) => readonly ["safercity", "panics", "list", Record<string, unknown> | undefined];
134
135
  panicsDetail: (panicId: string) => readonly ["safercity", "panics", "detail", string];
136
+ panicTypes: (userId: string) => readonly ["safercity", "panics", "types", string];
137
+ panicInformation: () => readonly ["safercity", "panicInformation"];
138
+ panicInformationDetail: (id: string) => readonly ["safercity", "panicInformation", "detail", string];
139
+ panicInformationByUser: (userId: string) => readonly ["safercity", "panicInformation", "byUser", string];
140
+ panicEligibility: (userId: string) => readonly ["safercity", "panicInformation", "eligibility", string];
135
141
  subscriptions: () => readonly ["safercity", "subscriptions"];
136
142
  subscriptionsList: (filters?: Record<string, unknown>) => readonly ["safercity", "subscriptions", "list", Record<string, unknown> | undefined];
137
143
  subscriptionsTypes: () => readonly ["safercity", "subscriptions", "types"];
138
144
  subscriptionsStats: () => readonly ["safercity", "subscriptions", "stats"];
139
145
  locationSafety: (lat: number, lng: number) => readonly ["safercity", "location-safety", number, number];
146
+ banner: (body: {
147
+ latitude: number;
148
+ longitude: number;
149
+ radius?: number;
150
+ }) => readonly ["safercity", "banner", {
151
+ latitude: number;
152
+ longitude: number;
153
+ radius?: number;
154
+ }];
140
155
  crimes: () => readonly ["safercity", "crimes"];
141
156
  crimesList: (filters?: Record<string, unknown>) => readonly ["safercity", "crimes", "list", Record<string, unknown> | undefined];
142
157
  crimesCategories: () => readonly ["safercity", "crimes", "categories"];
143
158
  crimesTypes: () => readonly ["safercity", "crimes", "types"];
159
+ crimeCategoriesWithTypes: () => readonly ["safercity", "crimes", "categoriesWithTypes"];
144
160
  };
145
161
  declare function useHealthCheck(options?: Omit<UseQueryOptions<ApiResponse<{
146
162
  status: string;
@@ -160,29 +176,6 @@ declare function useWhoAmI(options?: Omit<UseQueryOptions<ApiResponse<{
160
176
  scopes: string[];
161
177
  sessionId: string;
162
178
  }>, SaferCityApiError>;
163
- declare function useUsers(filters?: {
164
- limit?: number;
165
- cursor?: string;
166
- status?: string;
167
- }, options?: Omit<UseQueryOptions<ApiResponse<{
168
- users: Array<{
169
- id: string;
170
- email?: string;
171
- phone?: string;
172
- status: string;
173
- }>;
174
- hasNext: boolean;
175
- cursor?: string;
176
- }>, SaferCityApiError>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ApiResponse<{
177
- users: Array<{
178
- id: string;
179
- email?: string;
180
- phone?: string;
181
- status: string;
182
- }>;
183
- hasNext: boolean;
184
- cursor?: string;
185
- }>, SaferCityApiError>;
186
179
  declare function useUser(userId: string, options?: Omit<UseQueryOptions<ApiResponse<{
187
180
  id: string;
188
181
  email?: string;
@@ -244,11 +237,6 @@ declare function useUpdateUser(options?: UseMutationOptions<ApiResponse<{
244
237
  metadata?: Record<string, unknown>;
245
238
  };
246
239
  }, unknown>;
247
- declare function useDeleteUser(options?: UseMutationOptions<ApiResponse<{
248
- success: boolean;
249
- }>, SaferCityApiError, string>): _tanstack_react_query.UseMutationResult<ApiResponse<{
250
- success: boolean;
251
- }>, SaferCityApiError, string, unknown>;
252
240
  declare function usePanic(panicId: string, query?: {
253
241
  userId?: string;
254
242
  }, options?: Omit<UseQueryOptions<ApiResponse<{
@@ -337,6 +325,137 @@ declare function useCancelPanic(options?: UseMutationOptions<ApiResponse<{
337
325
  reason?: string;
338
326
  };
339
327
  }, unknown>;
328
+ declare function usePanicTypes(userId: string, options?: Omit<UseQueryOptions<ApiResponse<{
329
+ types: Array<{
330
+ id: string;
331
+ name: string;
332
+ description?: string;
333
+ }>;
334
+ }>, SaferCityApiError>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ApiResponse<{
335
+ types: Array<{
336
+ id: string;
337
+ name: string;
338
+ description?: string;
339
+ }>;
340
+ }>, SaferCityApiError>;
341
+ declare function usePanicInformation(id: string, options?: Omit<UseQueryOptions<ApiResponse<{
342
+ success: boolean;
343
+ data: PanicInformationRecord;
344
+ }>, SaferCityApiError>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ApiResponse<{
345
+ success: boolean;
346
+ data: PanicInformationRecord;
347
+ }>, SaferCityApiError>;
348
+ declare function usePanicInformationByUser(userId: string, options?: Omit<UseQueryOptions<ApiResponse<{
349
+ success: boolean;
350
+ data: PanicInformationRecord;
351
+ }>, SaferCityApiError>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ApiResponse<{
352
+ success: boolean;
353
+ data: PanicInformationRecord;
354
+ }>, SaferCityApiError>;
355
+ declare function usePanicEligibility(userId: string, options?: Omit<UseQueryOptions<ApiResponse<{
356
+ success: boolean;
357
+ data: {
358
+ eligible: boolean;
359
+ subscriptionActive: boolean;
360
+ profileComplete: boolean;
361
+ reasons: string[];
362
+ panicInformation: PanicInformationRecord | null;
363
+ subscriptionDetails: {
364
+ usedSeats: number;
365
+ userHasActiveSubscription: boolean;
366
+ } | null;
367
+ };
368
+ }>, SaferCityApiError>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ApiResponse<{
369
+ success: boolean;
370
+ data: {
371
+ eligible: boolean;
372
+ subscriptionActive: boolean;
373
+ profileComplete: boolean;
374
+ reasons: string[];
375
+ panicInformation: PanicInformationRecord | null;
376
+ subscriptionDetails: {
377
+ usedSeats: number;
378
+ userHasActiveSubscription: boolean;
379
+ } | null;
380
+ };
381
+ }>, SaferCityApiError>;
382
+ declare function useCreatePanicInformation(options?: UseMutationOptions<ApiResponse<{
383
+ success: boolean;
384
+ data: PanicInformationRecord;
385
+ message: string;
386
+ }>, SaferCityApiError, {
387
+ userId: string;
388
+ phoneNumber: string;
389
+ firstName: string;
390
+ lastName: string;
391
+ idNumber: string;
392
+ duressCode?: string;
393
+ emergencyContacts?: Array<{
394
+ name: string;
395
+ phoneNumber: string;
396
+ relationship?: string;
397
+ }>;
398
+ }>): _tanstack_react_query.UseMutationResult<ApiResponse<{
399
+ success: boolean;
400
+ data: PanicInformationRecord;
401
+ message: string;
402
+ }>, SaferCityApiError, {
403
+ userId: string;
404
+ phoneNumber: string;
405
+ firstName: string;
406
+ lastName: string;
407
+ idNumber: string;
408
+ duressCode?: string;
409
+ emergencyContacts?: Array<{
410
+ name: string;
411
+ phoneNumber: string;
412
+ relationship?: string;
413
+ }>;
414
+ }, unknown>;
415
+ declare function useUpdatePanicInformation(options?: UseMutationOptions<ApiResponse<{
416
+ success: boolean;
417
+ data: PanicInformationRecord;
418
+ message: string;
419
+ }>, SaferCityApiError, {
420
+ id: string;
421
+ data: {
422
+ phoneNumber?: string;
423
+ firstName?: string;
424
+ lastName?: string;
425
+ idNumber?: string;
426
+ duressCode?: string;
427
+ emergencyContacts?: Array<{
428
+ name: string;
429
+ phoneNumber: string;
430
+ relationship?: string;
431
+ }>;
432
+ };
433
+ }>): _tanstack_react_query.UseMutationResult<ApiResponse<{
434
+ success: boolean;
435
+ data: PanicInformationRecord;
436
+ message: string;
437
+ }>, SaferCityApiError, {
438
+ id: string;
439
+ data: {
440
+ phoneNumber?: string;
441
+ firstName?: string;
442
+ lastName?: string;
443
+ idNumber?: string;
444
+ duressCode?: string;
445
+ emergencyContacts?: Array<{
446
+ name: string;
447
+ phoneNumber: string;
448
+ relationship?: string;
449
+ }>;
450
+ };
451
+ }, unknown>;
452
+ declare function useDeletePanicInformation(options?: UseMutationOptions<ApiResponse<{
453
+ success: boolean;
454
+ message: string;
455
+ }>, SaferCityApiError, string>): _tanstack_react_query.UseMutationResult<ApiResponse<{
456
+ success: boolean;
457
+ message: string;
458
+ }>, SaferCityApiError, string, unknown>;
340
459
  declare function useSubscriptionTypes(options?: Omit<UseQueryOptions<ApiResponse<{
341
460
  types: Array<{
342
461
  id: string;
@@ -390,6 +509,38 @@ declare function useCreateSubscription(options?: UseMutationOptions<ApiResponse<
390
509
  subscriptionTypeId: string;
391
510
  status?: string;
392
511
  }, unknown>;
512
+ declare function useSubscribeUser(options?: UseMutationOptions<ApiResponse<{
513
+ id: string;
514
+ userId: string;
515
+ subscriptionTypeId: string;
516
+ status: string;
517
+ }>, SaferCityApiError, {
518
+ userId: string;
519
+ subscriptionTypeId: string;
520
+ }>): _tanstack_react_query.UseMutationResult<ApiResponse<{
521
+ id: string;
522
+ userId: string;
523
+ subscriptionTypeId: string;
524
+ status: string;
525
+ }>, SaferCityApiError, {
526
+ userId: string;
527
+ subscriptionTypeId: string;
528
+ }, unknown>;
529
+ declare function useBulkTriggerNotifications(options?: UseMutationOptions<ApiResponse<{
530
+ transactionIds: string[];
531
+ status: string;
532
+ }>, SaferCityApiError, {
533
+ userIds: string[];
534
+ workflowId: string;
535
+ payload?: Record<string, unknown>;
536
+ }>): _tanstack_react_query.UseMutationResult<ApiResponse<{
537
+ transactionIds: string[];
538
+ status: string;
539
+ }>, SaferCityApiError, {
540
+ userIds: string[];
541
+ workflowId: string;
542
+ payload?: Record<string, unknown>;
543
+ }, unknown>;
393
544
  declare function useLocationSafety(latitude: number, longitude: number, radius?: number, options?: Omit<UseQueryOptions<ApiResponse<{
394
545
  safetyScore: number;
395
546
  riskLevel: string;
@@ -405,6 +556,31 @@ declare function useLocationSafety(latitude: number, longitude: number, radius?:
405
556
  impact: number;
406
557
  }>;
407
558
  }>, SaferCityApiError>;
559
+ declare function useBanner(body: {
560
+ latitude: number;
561
+ longitude: number;
562
+ radius?: number;
563
+ }, options?: Omit<UseQueryOptions<ApiResponse<{
564
+ success: boolean;
565
+ data: {
566
+ totalCrimes: number;
567
+ categories: Array<{
568
+ name: string;
569
+ count: number;
570
+ }>;
571
+ period: string;
572
+ };
573
+ }>, SaferCityApiError>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ApiResponse<{
574
+ success: boolean;
575
+ data: {
576
+ totalCrimes: number;
577
+ categories: Array<{
578
+ name: string;
579
+ count: number;
580
+ }>;
581
+ period: string;
582
+ };
583
+ }>, SaferCityApiError>;
408
584
  declare function useCrimes(filters?: {
409
585
  latitude?: number;
410
586
  longitude?: number;
@@ -454,6 +630,25 @@ declare function useCrimeTypes(options?: Omit<UseQueryOptions<ApiResponse<{
454
630
  categoryId: string;
455
631
  }>;
456
632
  }>, SaferCityApiError>;
633
+ declare function useCrimeCategoriesWithTypes(options?: Omit<UseQueryOptions<ApiResponse<{
634
+ categories: Array<{
635
+ id: string;
636
+ name: string;
637
+ types: Array<{
638
+ id: string;
639
+ name: string;
640
+ }>;
641
+ }>;
642
+ }>, SaferCityApiError>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ApiResponse<{
643
+ categories: Array<{
644
+ id: string;
645
+ name: string;
646
+ types: Array<{
647
+ id: string;
648
+ name: string;
649
+ }>;
650
+ }>;
651
+ }>, SaferCityApiError>;
457
652
 
458
653
  /**
459
654
  * State for streaming hooks
@@ -586,4 +781,4 @@ declare function useStream<T = ServerSentEvent>(createStream: () => AsyncIterabl
586
781
  error: Error | null;
587
782
  };
588
783
 
589
- export { type CookieModeProviderProps, type DirectModeProviderProps, type ProxyModeProviderProps, SaferCityProvider, type SaferCityProviderProps, type SessionState, type StreamState, type UseStreamOptions, saferCityKeys, useAuthMode, useCancelPanic, useCreatePanic, useCreateSubscription, useCreateUser, useCrimeCategories, useCrimeTypes, useCrimes, useDeleteUser, useHealthCheck, useLocationSafety, usePanic, usePanicStream, useSaferCity, useSaferCityClient, useSession, useSessionManager, useStream, useSubscriptionTypes, useSubscriptions, useUpdatePanicLocation, useUpdateUser, useUser, useUsers, useWhoAmI };
784
+ export { type CookieModeProviderProps, type DirectModeProviderProps, type ProxyModeProviderProps, SaferCityProvider, type SaferCityProviderProps, type SessionState, type StreamState, type UseStreamOptions, saferCityKeys, useAuthMode, useBanner, useBulkTriggerNotifications, useCancelPanic, useCreatePanic, useCreatePanicInformation, useCreateSubscription, useCreateUser, useCrimeCategories, useCrimeCategoriesWithTypes, useCrimeTypes, useCrimes, useDeletePanicInformation, useHealthCheck, useLocationSafety, usePanic, usePanicEligibility, usePanicInformation, usePanicInformationByUser, usePanicStream, usePanicTypes, useSaferCity, useSaferCityClient, useSession, useSessionManager, useStream, useSubscribeUser, useSubscriptionTypes, useSubscriptions, useUpdatePanicInformation, useUpdatePanicLocation, useUpdateUser, useUser, useWhoAmI };