@safercity/sdk-react 0.3.1 → 0.4.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.
- package/CHANGELOG.md +54 -0
- package/README.md +24 -1
- package/dist/index.cjs +16 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -44
- package/dist/index.d.ts +48 -44
- package/dist/index.js +16 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# @safercity/sdk-react
|
|
2
|
+
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- **100% Codegen Types** - All hook parameter and return types flow from generated OpenAPI types. Type changes propagate automatically after `bun run generate:all`.
|
|
8
|
+
- **New Panic Hooks** - Added `useCreatePremiumPanic()` for CellFind provider integration.
|
|
9
|
+
- **Subscription Realignment** - Removed `useSubscribeUser()` hook. `useCreateSubscription()` body updated to use `isPremium` flag.
|
|
10
|
+
- **Enhanced Filtering** - `useSubscriptions()` now supports expanded query parameters (`status`, `subscriptionTypeId`, `sortBy`, `search`).
|
|
11
|
+
|
|
12
|
+
### Breaking Changes
|
|
13
|
+
|
|
14
|
+
- `useSubscribeUser()` removed — use `useCreateSubscription()` instead.
|
|
15
|
+
|
|
16
|
+
## 0.3.2
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- **Proxy Mode Enhanced** - `SaferCityProvider` supports `tenantId`, `userId`, and custom `headers` in proxy mode.
|
|
21
|
+
- **useBanner Fix** - Fixed hook parameter from `radius` to `days`.
|
|
22
|
+
|
|
23
|
+
## 0.3.1
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- **Simplified Hook Data** - Hook `data` reflects API response body directly.
|
|
28
|
+
- **Typed Hook Errors** - All hooks use `SaferCityApiError` as the error type.
|
|
29
|
+
|
|
30
|
+
## 0.3.0
|
|
31
|
+
|
|
32
|
+
### Minor Changes
|
|
33
|
+
|
|
34
|
+
- **Typed SDK Alignment** - Hooks use auto-generated types from `@safercity/sdk`.
|
|
35
|
+
|
|
36
|
+
## 0.2.0
|
|
37
|
+
|
|
38
|
+
### Minor Changes
|
|
39
|
+
|
|
40
|
+
- **Panic Information Hooks** - New hooks for managing panic profiles.
|
|
41
|
+
- **User Scoping** - `SaferCityProvider` supports `userId`.
|
|
42
|
+
- **Enhanced Crime Hooks** - Added `useBanner` and `useCrimeCategoriesWithTypes`.
|
|
43
|
+
|
|
44
|
+
## 0.1.3
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- **Security hardening** - Removed `usePanics` and `useSubscriptionStats` hooks.
|
|
49
|
+
|
|
50
|
+
## 0.1.0
|
|
51
|
+
|
|
52
|
+
### Minor Changes
|
|
53
|
+
|
|
54
|
+
- Initial release with React hooks, SaferCityProvider, and TanStack Query integration.
|
package/README.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
React hooks and components for SaferCity SDK with TanStack Query integration.
|
|
4
4
|
|
|
5
|
+
## What's New in v0.4.0
|
|
6
|
+
|
|
7
|
+
- **100% Codegen Types** - All hook parameter and return types flow from the generated OpenAPI types. Type changes propagate automatically after `bun run generate:all`.
|
|
8
|
+
- **New Panic Hooks** - Added `useCreatePremiumPanic()` for CellFind provider integration.
|
|
9
|
+
- **Subscription Realignment** - Removed `useSubscribeUser()` hook (dead route). `useCreateSubscription()` body shape updated to use `isPremium` flag.
|
|
10
|
+
- **Enhanced Filtering** - `useSubscriptions()` now supports expanded query parameters (`status`, `subscriptionTypeId`, `sortBy`, `search`).
|
|
11
|
+
|
|
12
|
+
## What's New in v0.3.2
|
|
13
|
+
|
|
14
|
+
- **Proxy Mode Enhanced** - `SaferCityProvider` in proxy mode now supports `tenantId`, `userId`, and custom `headers`. Perfect for white-label React Native apps that need to pass tenant context through a proxy.
|
|
15
|
+
- **useBanner Fix** - Fixed `useBanner` hook parameter from `radius` to `days` to match API schema.
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
// White-label app with proxy mode
|
|
19
|
+
<SaferCityProvider
|
|
20
|
+
mode="proxy"
|
|
21
|
+
proxyBaseUrl={`${API_URL}/api/safercity`}
|
|
22
|
+
tenantId={TENANT_ID}
|
|
23
|
+
>
|
|
24
|
+
<App />
|
|
25
|
+
</SaferCityProvider>
|
|
26
|
+
```
|
|
27
|
+
|
|
5
28
|
## What's New in v0.3.1
|
|
6
29
|
|
|
7
30
|
- **Simplified Hook Data** - Hook `data` now reflects the API response body directly (no `ApiResponse` wrapper). Access `data.status` for health, `data.data.firstName` for user responses with API envelopes.
|
|
@@ -203,6 +226,7 @@ function PanicButton({ userId }: { userId: string }) {
|
|
|
203
226
|
### Panics
|
|
204
227
|
- `usePanic(panicId, query?)` - Get panic by ID
|
|
205
228
|
- `useCreatePanic()` - Create panic mutation
|
|
229
|
+
- `useCreatePremiumPanic()` - Create premium panic mutation
|
|
206
230
|
- `useUpdatePanicLocation()` - Update location mutation
|
|
207
231
|
- `useCancelPanic()` - Cancel panic mutation
|
|
208
232
|
- `usePanicTypes(userId?)` - Get available panic types for a user
|
|
@@ -220,7 +244,6 @@ function PanicButton({ userId }: { userId: string }) {
|
|
|
220
244
|
- `useSubscriptionTypes()` - List subscription types
|
|
221
245
|
- `useSubscriptions(filters?)` - List subscriptions for a user
|
|
222
246
|
- `useCreateSubscription()` - Create subscription mutation
|
|
223
|
-
- `useSubscribeUser()` - Subscribe user mutation
|
|
224
247
|
|
|
225
248
|
### Notifications
|
|
226
249
|
- `useBulkTriggerNotifications()` - Bulk trigger notifications mutation
|
package/dist/index.cjs
CHANGED
|
@@ -43,7 +43,10 @@ function SaferCityProvider(props) {
|
|
|
43
43
|
if (isProxyMode(props)) {
|
|
44
44
|
const proxyBaseUrl = props.proxyBaseUrl ?? "/api/safercity";
|
|
45
45
|
return sdk.createSaferCityClient({
|
|
46
|
-
baseUrl: proxyBaseUrl
|
|
46
|
+
baseUrl: proxyBaseUrl,
|
|
47
|
+
tenantId: props.tenantId,
|
|
48
|
+
userId: props.userId,
|
|
49
|
+
headers: props.headers
|
|
47
50
|
});
|
|
48
51
|
}
|
|
49
52
|
if (isDirectMode(props)) {
|
|
@@ -271,7 +274,6 @@ var saferCityKeys = {
|
|
|
271
274
|
subscriptions: () => [...saferCityKeys.all, "subscriptions"],
|
|
272
275
|
subscriptionsList: (filters) => [...saferCityKeys.subscriptions(), "list", filters],
|
|
273
276
|
subscriptionsTypes: () => [...saferCityKeys.subscriptions(), "types"],
|
|
274
|
-
subscriptionsStats: () => [...saferCityKeys.subscriptions(), "stats"],
|
|
275
277
|
// Location Safety
|
|
276
278
|
locationSafety: (lat, lng) => [...saferCityKeys.all, "location-safety", lat, lng],
|
|
277
279
|
// Banner
|
|
@@ -352,6 +354,17 @@ function useCreatePanic(options) {
|
|
|
352
354
|
...options
|
|
353
355
|
});
|
|
354
356
|
}
|
|
357
|
+
function useCreatePremiumPanic(options) {
|
|
358
|
+
const client = useSaferCityClient();
|
|
359
|
+
const queryClient = reactQuery.useQueryClient();
|
|
360
|
+
return reactQuery.useMutation({
|
|
361
|
+
mutationFn: (data) => client.panics.createPremium(data),
|
|
362
|
+
onSuccess: () => {
|
|
363
|
+
queryClient.invalidateQueries({ queryKey: saferCityKeys.panics() });
|
|
364
|
+
},
|
|
365
|
+
...options
|
|
366
|
+
});
|
|
367
|
+
}
|
|
355
368
|
function useUpdatePanicLocation(options) {
|
|
356
369
|
const client = useSaferCityClient();
|
|
357
370
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -475,17 +488,6 @@ function useCreateSubscription(options) {
|
|
|
475
488
|
...options
|
|
476
489
|
});
|
|
477
490
|
}
|
|
478
|
-
function useSubscribeUser(options) {
|
|
479
|
-
const client = useSaferCityClient();
|
|
480
|
-
const queryClient = reactQuery.useQueryClient();
|
|
481
|
-
return reactQuery.useMutation({
|
|
482
|
-
mutationFn: (body) => client.subscriptions.subscribeUser(body),
|
|
483
|
-
onSuccess: () => {
|
|
484
|
-
queryClient.invalidateQueries({ queryKey: saferCityKeys.subscriptions() });
|
|
485
|
-
},
|
|
486
|
-
...options
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
491
|
function useBulkTriggerNotifications(options) {
|
|
490
492
|
const client = useSaferCityClient();
|
|
491
493
|
return reactQuery.useMutation({
|
|
@@ -755,6 +757,7 @@ exports.useBulkTriggerNotifications = useBulkTriggerNotifications;
|
|
|
755
757
|
exports.useCancelPanic = useCancelPanic;
|
|
756
758
|
exports.useCreatePanic = useCreatePanic;
|
|
757
759
|
exports.useCreatePanicInformation = useCreatePanicInformation;
|
|
760
|
+
exports.useCreatePremiumPanic = useCreatePremiumPanic;
|
|
758
761
|
exports.useCreateSubscription = useCreateSubscription;
|
|
759
762
|
exports.useCreateUser = useCreateUser;
|
|
760
763
|
exports.useCrimeCategories = useCrimeCategories;
|
|
@@ -775,7 +778,6 @@ exports.useSaferCityClient = useSaferCityClient;
|
|
|
775
778
|
exports.useSession = useSession;
|
|
776
779
|
exports.useSessionManager = useSessionManager;
|
|
777
780
|
exports.useStream = useStream;
|
|
778
|
-
exports.useSubscribeUser = useSubscribeUser;
|
|
779
781
|
exports.useSubscriptionTypes = useSubscriptionTypes;
|
|
780
782
|
exports.useSubscriptions = useSubscriptions;
|
|
781
783
|
exports.useUpdatePanicInformation = useUpdatePanicInformation;
|
package/dist/index.cjs.map
CHANGED
|
@@ -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;AAmDzE,SAAS,YAAY,KAAA,EAAgE;A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AA;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 { SaferCityApiError } from '@safercity/sdk';\n\ntype SaferCityClient = ReturnType<typeof useSaferCityClient>;\ntype QueryOptionsFor<T extends (...args: any) => any> = Omit<\n UseQueryOptions<Awaited<ReturnType<T>>, SaferCityApiError>,\n 'queryKey' | 'queryFn'\n>;\ntype MutationOptionsFor<T extends (...args: any) => any, TVariables = Parameters<T>[0]> =\n UseMutationOptions<Awaited<ReturnType<T>>, SaferCityApiError, TVariables>;\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?: QueryOptionsFor<SaferCityClient['health']['check']>\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?: QueryOptionsFor<SaferCityClient['auth']['whoami']>\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?: QueryOptionsFor<SaferCityClient['users']['get']>\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?: MutationOptionsFor<SaferCityClient['users']['create']>\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?: MutationOptionsFor<\n SaferCityClient['users']['update'],\n {\n userId: Parameters<SaferCityClient['users']['update']>[0];\n data: Parameters<SaferCityClient['users']['update']>[1];\n }\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 if (userId) {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.usersDetail(userId) });\n }\n },\n ...options,\n });\n}\n\n// ==================\n// Panic Hooks\n// ==================\n\nexport function usePanic(\n panicId: string,\n query?: { userId?: string },\n options?: QueryOptionsFor<SaferCityClient['panics']['get']>\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?: MutationOptionsFor<SaferCityClient['panics']['create']>\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?: MutationOptionsFor<\n SaferCityClient['panics']['updateLocation'],\n {\n panicId: Parameters<SaferCityClient['panics']['updateLocation']>[0];\n data: Parameters<SaferCityClient['panics']['updateLocation']>[1];\n }\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?: MutationOptionsFor<\n SaferCityClient['panics']['cancel'],\n {\n panicId: Parameters<SaferCityClient['panics']['cancel']>[0];\n data: Parameters<SaferCityClient['panics']['cancel']>[1];\n }\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?: QueryOptionsFor<SaferCityClient['panics']['types']>\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?: QueryOptionsFor<SaferCityClient['panicInformation']['get']>\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?: QueryOptionsFor<SaferCityClient['panicInformation']['getByUser']>\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?: QueryOptionsFor<SaferCityClient['panicInformation']['validateEligibility']>\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?: MutationOptionsFor<SaferCityClient['panicInformation']['create']>\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?: MutationOptionsFor<\n SaferCityClient['panicInformation']['update'],\n {\n id: Parameters<SaferCityClient['panicInformation']['update']>[0];\n data: Parameters<SaferCityClient['panicInformation']['update']>[1];\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?: MutationOptionsFor<SaferCityClient['panicInformation']['delete']>\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?: QueryOptionsFor<SaferCityClient['subscriptions']['listTypes']>\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?: QueryOptionsFor<SaferCityClient['subscriptions']['list']>\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?: MutationOptionsFor<SaferCityClient['subscriptions']['create']>\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?: MutationOptionsFor<SaferCityClient['subscriptions']['subscribeUser']>\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?: MutationOptionsFor<SaferCityClient['notifications']['bulkTrigger']>\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?: QueryOptionsFor<SaferCityClient['locationSafety']['check']>\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?: QueryOptionsFor<SaferCityClient['banner']['get']>\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?: QueryOptionsFor<SaferCityClient['crimes']['list']>\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?: QueryOptionsFor<SaferCityClient['crimes']['categories']>\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?: QueryOptionsFor<SaferCityClient['crimes']['types']>\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?: QueryOptionsFor<SaferCityClient['crimes']['categoriesWithTypes']>\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"]}
|
|
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;A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AAA,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 tenantId: props.tenantId,\n userId: props.userId,\n headers: props.headers,\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 { SaferCityApiError } from '@safercity/sdk';\n\ntype SaferCityClient = ReturnType<typeof useSaferCityClient>;\ntype QueryOptionsFor<T extends (...args: any) => any> = Omit<\n UseQueryOptions<Awaited<ReturnType<T>>, SaferCityApiError>,\n 'queryKey' | 'queryFn'\n>;\ntype MutationOptionsFor<T extends (...args: any) => any, TVariables = Parameters<T>[0]> =\n UseMutationOptions<Awaited<ReturnType<T>>, SaferCityApiError, TVariables>;\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 \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; days?: 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?: QueryOptionsFor<SaferCityClient['health']['check']>\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?: QueryOptionsFor<SaferCityClient['auth']['whoami']>\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?: QueryOptionsFor<SaferCityClient['users']['get']>\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?: MutationOptionsFor<SaferCityClient['users']['create']>\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?: MutationOptionsFor<\n SaferCityClient['users']['update'],\n {\n userId: Parameters<SaferCityClient['users']['update']>[0];\n data: Parameters<SaferCityClient['users']['update']>[1];\n }\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 if (userId) {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.usersDetail(userId) });\n }\n },\n ...options,\n });\n}\n\n// ==================\n// Panic Hooks\n// ==================\n\nexport function usePanic(\n panicId: string,\n query?: { userId?: string },\n options?: QueryOptionsFor<SaferCityClient['panics']['get']>\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?: MutationOptionsFor<SaferCityClient['panics']['create']>\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 useCreatePremiumPanic(\n options?: MutationOptionsFor<SaferCityClient['panics']['createPremium']>\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: (data) => client.panics.createPremium(data),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.panics() });\n },\n ...options,\n });\n}\n\nexport function useUpdatePanicLocation(\n options?: MutationOptionsFor<\n SaferCityClient['panics']['updateLocation'],\n {\n panicId: Parameters<SaferCityClient['panics']['updateLocation']>[0];\n data: Parameters<SaferCityClient['panics']['updateLocation']>[1];\n }\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?: MutationOptionsFor<\n SaferCityClient['panics']['cancel'],\n {\n panicId: Parameters<SaferCityClient['panics']['cancel']>[0];\n data: Parameters<SaferCityClient['panics']['cancel']>[1];\n }\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?: QueryOptionsFor<SaferCityClient['panics']['types']>\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?: QueryOptionsFor<SaferCityClient['panicInformation']['get']>\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?: QueryOptionsFor<SaferCityClient['panicInformation']['getByUser']>\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?: QueryOptionsFor<SaferCityClient['panicInformation']['validateEligibility']>\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?: MutationOptionsFor<SaferCityClient['panicInformation']['create']>\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?: MutationOptionsFor<\n SaferCityClient['panicInformation']['update'],\n {\n id: Parameters<SaferCityClient['panicInformation']['update']>[0];\n data: Parameters<SaferCityClient['panicInformation']['update']>[1];\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?: MutationOptionsFor<SaferCityClient['panicInformation']['delete']>\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?: QueryOptionsFor<SaferCityClient['subscriptions']['listTypes']>\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?: {\n userId?: string;\n status?: string;\n limit?: number;\n cursor?: string;\n subscriptionTypeId?: string;\n sortBy?: 'createdAt' | 'updatedAt' | 'status';\n sortOrder?: 'asc' | 'desc';\n search?: string;\n },\n options?: QueryOptionsFor<SaferCityClient['subscriptions']['list']>\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?: MutationOptionsFor<SaferCityClient['subscriptions']['create']>\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// Notification Hooks\n// ==================\n\nexport function useBulkTriggerNotifications(\n options?: MutationOptionsFor<SaferCityClient['notifications']['bulkTrigger']>\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?: QueryOptionsFor<SaferCityClient['locationSafety']['check']>\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; days?: number },\n options?: QueryOptionsFor<SaferCityClient['banner']['get']>\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?: QueryOptionsFor<SaferCityClient['crimes']['list']>\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?: QueryOptionsFor<SaferCityClient['crimes']['categories']>\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?: QueryOptionsFor<SaferCityClient['crimes']['types']>\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?: QueryOptionsFor<SaferCityClient['crimes']['categoriesWithTypes']>\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
|
@@ -145,16 +145,15 @@ declare const saferCityKeys: {
|
|
|
145
145
|
subscriptions: () => readonly ["safercity", "subscriptions"];
|
|
146
146
|
subscriptionsList: (filters?: Record<string, unknown>) => readonly ["safercity", "subscriptions", "list", Record<string, unknown> | undefined];
|
|
147
147
|
subscriptionsTypes: () => readonly ["safercity", "subscriptions", "types"];
|
|
148
|
-
subscriptionsStats: () => readonly ["safercity", "subscriptions", "stats"];
|
|
149
148
|
locationSafety: (lat: number, lng: number) => readonly ["safercity", "location-safety", number, number];
|
|
150
149
|
banner: (body: {
|
|
151
150
|
latitude: number;
|
|
152
151
|
longitude: number;
|
|
153
|
-
|
|
152
|
+
days?: number;
|
|
154
153
|
}) => readonly ["safercity", "banner", {
|
|
155
154
|
latitude: number;
|
|
156
155
|
longitude: number;
|
|
157
|
-
|
|
156
|
+
days?: number;
|
|
158
157
|
}];
|
|
159
158
|
crimes: () => readonly ["safercity", "crimes"];
|
|
160
159
|
crimesList: (filters?: Record<string, unknown>) => readonly ["safercity", "crimes", "list", Record<string, unknown> | undefined];
|
|
@@ -224,6 +223,17 @@ declare function usePanic(panicId: string, query?: {
|
|
|
224
223
|
declare function useCreatePanic(options?: MutationOptionsFor<SaferCityClient['panics']['create']>): _tanstack_react_query.UseMutationResult<_safercity_sdk.PanicCreatedResponse, SaferCityApiError, Omit<_safercity_sdk.CreatePanicBody, "userId"> & {
|
|
225
224
|
userId?: string;
|
|
226
225
|
}, unknown>;
|
|
226
|
+
declare function useCreatePremiumPanic(options?: MutationOptionsFor<SaferCityClient['panics']['createPremium']>): _tanstack_react_query.UseMutationResult<_safercity_sdk.PanicCreatedResponse, SaferCityApiError, Omit<{
|
|
227
|
+
userId: string;
|
|
228
|
+
panicType: string;
|
|
229
|
+
latitude: number;
|
|
230
|
+
longitude: number;
|
|
231
|
+
accuracy?: number;
|
|
232
|
+
address?: string;
|
|
233
|
+
message?: string;
|
|
234
|
+
}, "userId"> & {
|
|
235
|
+
userId?: string;
|
|
236
|
+
}, unknown>;
|
|
227
237
|
declare function useUpdatePanicLocation(options?: MutationOptionsFor<SaferCityClient['panics']['updateLocation'], {
|
|
228
238
|
panicId: Parameters<SaferCityClient['panics']['updateLocation']>[0];
|
|
229
239
|
data: Parameters<SaferCityClient['panics']['updateLocation']>[1];
|
|
@@ -238,13 +248,7 @@ declare function useCancelPanic(options?: MutationOptionsFor<SaferCityClient['pa
|
|
|
238
248
|
panicId: Parameters<SaferCityClient["panics"]["cancel"]>[0];
|
|
239
249
|
data: Parameters<SaferCityClient["panics"]["cancel"]>[1];
|
|
240
250
|
}, unknown>;
|
|
241
|
-
declare function usePanicTypes(userId: string, options?: QueryOptionsFor<SaferCityClient['panics']['types']>): _tanstack_react_query.UseQueryResult<
|
|
242
|
-
types: Array<{
|
|
243
|
-
id: string;
|
|
244
|
-
name: string;
|
|
245
|
-
description?: string;
|
|
246
|
-
}>;
|
|
247
|
-
}, SaferCityApiError>;
|
|
251
|
+
declare function usePanicTypes(userId: string, options?: QueryOptionsFor<SaferCityClient['panics']['types']>): _tanstack_react_query.UseQueryResult<unknown, SaferCityApiError>;
|
|
248
252
|
declare function usePanicInformation(id: string, options?: QueryOptionsFor<SaferCityClient['panicInformation']['get']>): _tanstack_react_query.UseQueryResult<_safercity_sdk.PanicInformationResponse, SaferCityApiError>;
|
|
249
253
|
declare function usePanicInformationByUser(userId: string, options?: QueryOptionsFor<SaferCityClient['panicInformation']['getByUser']>): _tanstack_react_query.UseQueryResult<_safercity_sdk.PanicInformationResponse, SaferCityApiError>;
|
|
250
254
|
declare function usePanicEligibility(userId: string, options?: QueryOptionsFor<SaferCityClient['panicInformation']['validateEligibility']>): _tanstack_react_query.UseQueryResult<{
|
|
@@ -308,6 +312,11 @@ declare function useSubscriptions(filters?: {
|
|
|
308
312
|
userId?: string;
|
|
309
313
|
status?: string;
|
|
310
314
|
limit?: number;
|
|
315
|
+
cursor?: string;
|
|
316
|
+
subscriptionTypeId?: string;
|
|
317
|
+
sortBy?: 'createdAt' | 'updatedAt' | 'status';
|
|
318
|
+
sortOrder?: 'asc' | 'desc';
|
|
319
|
+
search?: string;
|
|
311
320
|
}, options?: QueryOptionsFor<SaferCityClient['subscriptions']['list']>): _tanstack_react_query.UseQueryResult<{
|
|
312
321
|
data: Array<{
|
|
313
322
|
tenantId: string;
|
|
@@ -316,6 +325,7 @@ declare function useSubscriptions(filters?: {
|
|
|
316
325
|
tenantSubscriptionId: string;
|
|
317
326
|
tenantSubscriptionName?: string;
|
|
318
327
|
globalSubscriptionTypeName?: string;
|
|
328
|
+
isPremium: boolean;
|
|
319
329
|
status: string;
|
|
320
330
|
createdAt: string;
|
|
321
331
|
updatedAt: string;
|
|
@@ -325,32 +335,12 @@ declare function useSubscriptions(filters?: {
|
|
|
325
335
|
billingCycle?: string;
|
|
326
336
|
}>;
|
|
327
337
|
pagination: {
|
|
328
|
-
nextCursor
|
|
338
|
+
nextCursor?: string | unknown;
|
|
329
339
|
hasNextPage: boolean;
|
|
330
|
-
total
|
|
340
|
+
total?: number | unknown;
|
|
331
341
|
};
|
|
332
342
|
}, SaferCityApiError>;
|
|
333
343
|
declare function useCreateSubscription(options?: MutationOptionsFor<SaferCityClient['subscriptions']['create']>): _tanstack_react_query.UseMutationResult<{
|
|
334
|
-
tenantId: string;
|
|
335
|
-
id: string;
|
|
336
|
-
userId: string;
|
|
337
|
-
tenantSubscriptionId: string;
|
|
338
|
-
status: string;
|
|
339
|
-
createdAt: string;
|
|
340
|
-
updatedAt: string;
|
|
341
|
-
member?: {
|
|
342
|
-
id: string;
|
|
343
|
-
userId: string;
|
|
344
|
-
role: string;
|
|
345
|
-
status: string;
|
|
346
|
-
joinedAt: string;
|
|
347
|
-
};
|
|
348
|
-
}, SaferCityApiError, {
|
|
349
|
-
userId?: string;
|
|
350
|
-
subscriptionTypeId: string;
|
|
351
|
-
status?: string;
|
|
352
|
-
}, unknown>;
|
|
353
|
-
declare function useSubscribeUser(options?: MutationOptionsFor<SaferCityClient['subscriptions']['subscribeUser']>): _tanstack_react_query.UseMutationResult<{
|
|
354
344
|
tenantId: string;
|
|
355
345
|
id: string;
|
|
356
346
|
userId: string;
|
|
@@ -358,10 +348,13 @@ declare function useSubscribeUser(options?: MutationOptionsFor<SaferCityClient['
|
|
|
358
348
|
tenantSubscriptionName?: string;
|
|
359
349
|
globalSubscriptionTypeName?: string;
|
|
360
350
|
isPremium: boolean;
|
|
351
|
+
status: string;
|
|
361
352
|
createdAt: string;
|
|
362
353
|
updatedAt: string;
|
|
363
354
|
startDate?: string;
|
|
364
355
|
endDate?: string;
|
|
356
|
+
amount?: string;
|
|
357
|
+
billingCycle?: string;
|
|
365
358
|
}, SaferCityApiError, Omit<{
|
|
366
359
|
userId: string;
|
|
367
360
|
isPremium: boolean;
|
|
@@ -375,9 +368,20 @@ declare function useBulkTriggerNotifications(options?: MutationOptionsFor<SaferC
|
|
|
375
368
|
success: boolean;
|
|
376
369
|
errors?: Array<string>;
|
|
377
370
|
}, SaferCityApiError, {
|
|
378
|
-
userIds: string[];
|
|
379
371
|
workflowId: string;
|
|
380
|
-
|
|
372
|
+
userIds: Array<string>;
|
|
373
|
+
payload?: {
|
|
374
|
+
[key: string]: unknown;
|
|
375
|
+
};
|
|
376
|
+
tenant?: {
|
|
377
|
+
id: string;
|
|
378
|
+
name?: string;
|
|
379
|
+
logo?: string;
|
|
380
|
+
primaryColor?: string;
|
|
381
|
+
data?: {
|
|
382
|
+
[key: string]: unknown;
|
|
383
|
+
};
|
|
384
|
+
};
|
|
381
385
|
}, unknown>;
|
|
382
386
|
declare function useLocationSafety(latitude: number, longitude: number, radius?: number, options?: QueryOptionsFor<SaferCityClient['locationSafety']['check']>): _tanstack_react_query.UseQueryResult<{
|
|
383
387
|
status: string;
|
|
@@ -404,7 +408,7 @@ declare function useLocationSafety(latitude: number, longitude: number, radius?:
|
|
|
404
408
|
declare function useBanner(body: {
|
|
405
409
|
latitude: number;
|
|
406
410
|
longitude: number;
|
|
407
|
-
|
|
411
|
+
days?: number;
|
|
408
412
|
}, options?: QueryOptionsFor<SaferCityClient['banner']['get']>): _tanstack_react_query.UseQueryResult<{
|
|
409
413
|
location: {
|
|
410
414
|
latitude: number;
|
|
@@ -516,15 +520,15 @@ declare function useCrimeTypes(options?: QueryOptionsFor<SaferCityClient['crimes
|
|
|
516
520
|
total: number;
|
|
517
521
|
}, SaferCityApiError>;
|
|
518
522
|
declare function useCrimeCategoriesWithTypes(options?: QueryOptionsFor<SaferCityClient['crimes']['categoriesWithTypes']>): _tanstack_react_query.UseQueryResult<{
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
523
|
+
categoryId: string;
|
|
524
|
+
categoryName: string;
|
|
525
|
+
categorySeverity: string;
|
|
526
|
+
types: Array<{
|
|
527
|
+
typeId: string;
|
|
528
|
+
typeName: string;
|
|
529
|
+
typeSeverity: string;
|
|
526
530
|
}>;
|
|
527
|
-
}, SaferCityApiError>;
|
|
531
|
+
}[], SaferCityApiError>;
|
|
528
532
|
|
|
529
533
|
/**
|
|
530
534
|
* State for streaming hooks
|
|
@@ -657,4 +661,4 @@ declare function useStream<T = ServerSentEvent>(createStream: () => AsyncIterabl
|
|
|
657
661
|
error: Error | null;
|
|
658
662
|
};
|
|
659
663
|
|
|
660
|
-
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,
|
|
664
|
+
export { type CookieModeProviderProps, type DirectModeProviderProps, type ProxyModeProviderProps, SaferCityProvider, type SaferCityProviderProps, type SessionState, type StreamState, type UseStreamOptions, saferCityKeys, useAuthMode, useBanner, useBulkTriggerNotifications, useCancelPanic, useCreatePanic, useCreatePanicInformation, useCreatePremiumPanic, useCreateSubscription, useCreateUser, useCrimeCategories, useCrimeCategoriesWithTypes, useCrimeTypes, useCrimes, useDeletePanicInformation, useHealthCheck, useLocationSafety, usePanic, usePanicEligibility, usePanicInformation, usePanicInformationByUser, usePanicStream, usePanicTypes, useSaferCity, useSaferCityClient, useSession, useSessionManager, useStream, useSubscriptionTypes, useSubscriptions, useUpdatePanicInformation, useUpdatePanicLocation, useUpdateUser, useUser, useWhoAmI };
|
package/dist/index.d.ts
CHANGED
|
@@ -145,16 +145,15 @@ declare const saferCityKeys: {
|
|
|
145
145
|
subscriptions: () => readonly ["safercity", "subscriptions"];
|
|
146
146
|
subscriptionsList: (filters?: Record<string, unknown>) => readonly ["safercity", "subscriptions", "list", Record<string, unknown> | undefined];
|
|
147
147
|
subscriptionsTypes: () => readonly ["safercity", "subscriptions", "types"];
|
|
148
|
-
subscriptionsStats: () => readonly ["safercity", "subscriptions", "stats"];
|
|
149
148
|
locationSafety: (lat: number, lng: number) => readonly ["safercity", "location-safety", number, number];
|
|
150
149
|
banner: (body: {
|
|
151
150
|
latitude: number;
|
|
152
151
|
longitude: number;
|
|
153
|
-
|
|
152
|
+
days?: number;
|
|
154
153
|
}) => readonly ["safercity", "banner", {
|
|
155
154
|
latitude: number;
|
|
156
155
|
longitude: number;
|
|
157
|
-
|
|
156
|
+
days?: number;
|
|
158
157
|
}];
|
|
159
158
|
crimes: () => readonly ["safercity", "crimes"];
|
|
160
159
|
crimesList: (filters?: Record<string, unknown>) => readonly ["safercity", "crimes", "list", Record<string, unknown> | undefined];
|
|
@@ -224,6 +223,17 @@ declare function usePanic(panicId: string, query?: {
|
|
|
224
223
|
declare function useCreatePanic(options?: MutationOptionsFor<SaferCityClient['panics']['create']>): _tanstack_react_query.UseMutationResult<_safercity_sdk.PanicCreatedResponse, SaferCityApiError, Omit<_safercity_sdk.CreatePanicBody, "userId"> & {
|
|
225
224
|
userId?: string;
|
|
226
225
|
}, unknown>;
|
|
226
|
+
declare function useCreatePremiumPanic(options?: MutationOptionsFor<SaferCityClient['panics']['createPremium']>): _tanstack_react_query.UseMutationResult<_safercity_sdk.PanicCreatedResponse, SaferCityApiError, Omit<{
|
|
227
|
+
userId: string;
|
|
228
|
+
panicType: string;
|
|
229
|
+
latitude: number;
|
|
230
|
+
longitude: number;
|
|
231
|
+
accuracy?: number;
|
|
232
|
+
address?: string;
|
|
233
|
+
message?: string;
|
|
234
|
+
}, "userId"> & {
|
|
235
|
+
userId?: string;
|
|
236
|
+
}, unknown>;
|
|
227
237
|
declare function useUpdatePanicLocation(options?: MutationOptionsFor<SaferCityClient['panics']['updateLocation'], {
|
|
228
238
|
panicId: Parameters<SaferCityClient['panics']['updateLocation']>[0];
|
|
229
239
|
data: Parameters<SaferCityClient['panics']['updateLocation']>[1];
|
|
@@ -238,13 +248,7 @@ declare function useCancelPanic(options?: MutationOptionsFor<SaferCityClient['pa
|
|
|
238
248
|
panicId: Parameters<SaferCityClient["panics"]["cancel"]>[0];
|
|
239
249
|
data: Parameters<SaferCityClient["panics"]["cancel"]>[1];
|
|
240
250
|
}, unknown>;
|
|
241
|
-
declare function usePanicTypes(userId: string, options?: QueryOptionsFor<SaferCityClient['panics']['types']>): _tanstack_react_query.UseQueryResult<
|
|
242
|
-
types: Array<{
|
|
243
|
-
id: string;
|
|
244
|
-
name: string;
|
|
245
|
-
description?: string;
|
|
246
|
-
}>;
|
|
247
|
-
}, SaferCityApiError>;
|
|
251
|
+
declare function usePanicTypes(userId: string, options?: QueryOptionsFor<SaferCityClient['panics']['types']>): _tanstack_react_query.UseQueryResult<unknown, SaferCityApiError>;
|
|
248
252
|
declare function usePanicInformation(id: string, options?: QueryOptionsFor<SaferCityClient['panicInformation']['get']>): _tanstack_react_query.UseQueryResult<_safercity_sdk.PanicInformationResponse, SaferCityApiError>;
|
|
249
253
|
declare function usePanicInformationByUser(userId: string, options?: QueryOptionsFor<SaferCityClient['panicInformation']['getByUser']>): _tanstack_react_query.UseQueryResult<_safercity_sdk.PanicInformationResponse, SaferCityApiError>;
|
|
250
254
|
declare function usePanicEligibility(userId: string, options?: QueryOptionsFor<SaferCityClient['panicInformation']['validateEligibility']>): _tanstack_react_query.UseQueryResult<{
|
|
@@ -308,6 +312,11 @@ declare function useSubscriptions(filters?: {
|
|
|
308
312
|
userId?: string;
|
|
309
313
|
status?: string;
|
|
310
314
|
limit?: number;
|
|
315
|
+
cursor?: string;
|
|
316
|
+
subscriptionTypeId?: string;
|
|
317
|
+
sortBy?: 'createdAt' | 'updatedAt' | 'status';
|
|
318
|
+
sortOrder?: 'asc' | 'desc';
|
|
319
|
+
search?: string;
|
|
311
320
|
}, options?: QueryOptionsFor<SaferCityClient['subscriptions']['list']>): _tanstack_react_query.UseQueryResult<{
|
|
312
321
|
data: Array<{
|
|
313
322
|
tenantId: string;
|
|
@@ -316,6 +325,7 @@ declare function useSubscriptions(filters?: {
|
|
|
316
325
|
tenantSubscriptionId: string;
|
|
317
326
|
tenantSubscriptionName?: string;
|
|
318
327
|
globalSubscriptionTypeName?: string;
|
|
328
|
+
isPremium: boolean;
|
|
319
329
|
status: string;
|
|
320
330
|
createdAt: string;
|
|
321
331
|
updatedAt: string;
|
|
@@ -325,32 +335,12 @@ declare function useSubscriptions(filters?: {
|
|
|
325
335
|
billingCycle?: string;
|
|
326
336
|
}>;
|
|
327
337
|
pagination: {
|
|
328
|
-
nextCursor
|
|
338
|
+
nextCursor?: string | unknown;
|
|
329
339
|
hasNextPage: boolean;
|
|
330
|
-
total
|
|
340
|
+
total?: number | unknown;
|
|
331
341
|
};
|
|
332
342
|
}, SaferCityApiError>;
|
|
333
343
|
declare function useCreateSubscription(options?: MutationOptionsFor<SaferCityClient['subscriptions']['create']>): _tanstack_react_query.UseMutationResult<{
|
|
334
|
-
tenantId: string;
|
|
335
|
-
id: string;
|
|
336
|
-
userId: string;
|
|
337
|
-
tenantSubscriptionId: string;
|
|
338
|
-
status: string;
|
|
339
|
-
createdAt: string;
|
|
340
|
-
updatedAt: string;
|
|
341
|
-
member?: {
|
|
342
|
-
id: string;
|
|
343
|
-
userId: string;
|
|
344
|
-
role: string;
|
|
345
|
-
status: string;
|
|
346
|
-
joinedAt: string;
|
|
347
|
-
};
|
|
348
|
-
}, SaferCityApiError, {
|
|
349
|
-
userId?: string;
|
|
350
|
-
subscriptionTypeId: string;
|
|
351
|
-
status?: string;
|
|
352
|
-
}, unknown>;
|
|
353
|
-
declare function useSubscribeUser(options?: MutationOptionsFor<SaferCityClient['subscriptions']['subscribeUser']>): _tanstack_react_query.UseMutationResult<{
|
|
354
344
|
tenantId: string;
|
|
355
345
|
id: string;
|
|
356
346
|
userId: string;
|
|
@@ -358,10 +348,13 @@ declare function useSubscribeUser(options?: MutationOptionsFor<SaferCityClient['
|
|
|
358
348
|
tenantSubscriptionName?: string;
|
|
359
349
|
globalSubscriptionTypeName?: string;
|
|
360
350
|
isPremium: boolean;
|
|
351
|
+
status: string;
|
|
361
352
|
createdAt: string;
|
|
362
353
|
updatedAt: string;
|
|
363
354
|
startDate?: string;
|
|
364
355
|
endDate?: string;
|
|
356
|
+
amount?: string;
|
|
357
|
+
billingCycle?: string;
|
|
365
358
|
}, SaferCityApiError, Omit<{
|
|
366
359
|
userId: string;
|
|
367
360
|
isPremium: boolean;
|
|
@@ -375,9 +368,20 @@ declare function useBulkTriggerNotifications(options?: MutationOptionsFor<SaferC
|
|
|
375
368
|
success: boolean;
|
|
376
369
|
errors?: Array<string>;
|
|
377
370
|
}, SaferCityApiError, {
|
|
378
|
-
userIds: string[];
|
|
379
371
|
workflowId: string;
|
|
380
|
-
|
|
372
|
+
userIds: Array<string>;
|
|
373
|
+
payload?: {
|
|
374
|
+
[key: string]: unknown;
|
|
375
|
+
};
|
|
376
|
+
tenant?: {
|
|
377
|
+
id: string;
|
|
378
|
+
name?: string;
|
|
379
|
+
logo?: string;
|
|
380
|
+
primaryColor?: string;
|
|
381
|
+
data?: {
|
|
382
|
+
[key: string]: unknown;
|
|
383
|
+
};
|
|
384
|
+
};
|
|
381
385
|
}, unknown>;
|
|
382
386
|
declare function useLocationSafety(latitude: number, longitude: number, radius?: number, options?: QueryOptionsFor<SaferCityClient['locationSafety']['check']>): _tanstack_react_query.UseQueryResult<{
|
|
383
387
|
status: string;
|
|
@@ -404,7 +408,7 @@ declare function useLocationSafety(latitude: number, longitude: number, radius?:
|
|
|
404
408
|
declare function useBanner(body: {
|
|
405
409
|
latitude: number;
|
|
406
410
|
longitude: number;
|
|
407
|
-
|
|
411
|
+
days?: number;
|
|
408
412
|
}, options?: QueryOptionsFor<SaferCityClient['banner']['get']>): _tanstack_react_query.UseQueryResult<{
|
|
409
413
|
location: {
|
|
410
414
|
latitude: number;
|
|
@@ -516,15 +520,15 @@ declare function useCrimeTypes(options?: QueryOptionsFor<SaferCityClient['crimes
|
|
|
516
520
|
total: number;
|
|
517
521
|
}, SaferCityApiError>;
|
|
518
522
|
declare function useCrimeCategoriesWithTypes(options?: QueryOptionsFor<SaferCityClient['crimes']['categoriesWithTypes']>): _tanstack_react_query.UseQueryResult<{
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
523
|
+
categoryId: string;
|
|
524
|
+
categoryName: string;
|
|
525
|
+
categorySeverity: string;
|
|
526
|
+
types: Array<{
|
|
527
|
+
typeId: string;
|
|
528
|
+
typeName: string;
|
|
529
|
+
typeSeverity: string;
|
|
526
530
|
}>;
|
|
527
|
-
}, SaferCityApiError>;
|
|
531
|
+
}[], SaferCityApiError>;
|
|
528
532
|
|
|
529
533
|
/**
|
|
530
534
|
* State for streaming hooks
|
|
@@ -657,4 +661,4 @@ declare function useStream<T = ServerSentEvent>(createStream: () => AsyncIterabl
|
|
|
657
661
|
error: Error | null;
|
|
658
662
|
};
|
|
659
663
|
|
|
660
|
-
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,
|
|
664
|
+
export { type CookieModeProviderProps, type DirectModeProviderProps, type ProxyModeProviderProps, SaferCityProvider, type SaferCityProviderProps, type SessionState, type StreamState, type UseStreamOptions, saferCityKeys, useAuthMode, useBanner, useBulkTriggerNotifications, useCancelPanic, useCreatePanic, useCreatePanicInformation, useCreatePremiumPanic, useCreateSubscription, useCreateUser, useCrimeCategories, useCrimeCategoriesWithTypes, useCrimeTypes, useCrimes, useDeletePanicInformation, useHealthCheck, useLocationSafety, usePanic, usePanicEligibility, usePanicInformation, usePanicInformationByUser, usePanicStream, usePanicTypes, useSaferCity, useSaferCityClient, useSession, useSessionManager, useStream, useSubscriptionTypes, useSubscriptions, useUpdatePanicInformation, useUpdatePanicLocation, useUpdateUser, useUser, useWhoAmI };
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,10 @@ function SaferCityProvider(props) {
|
|
|
42
42
|
if (isProxyMode(props)) {
|
|
43
43
|
const proxyBaseUrl = props.proxyBaseUrl ?? "/api/safercity";
|
|
44
44
|
return createSaferCityClient({
|
|
45
|
-
baseUrl: proxyBaseUrl
|
|
45
|
+
baseUrl: proxyBaseUrl,
|
|
46
|
+
tenantId: props.tenantId,
|
|
47
|
+
userId: props.userId,
|
|
48
|
+
headers: props.headers
|
|
46
49
|
});
|
|
47
50
|
}
|
|
48
51
|
if (isDirectMode(props)) {
|
|
@@ -270,7 +273,6 @@ var saferCityKeys = {
|
|
|
270
273
|
subscriptions: () => [...saferCityKeys.all, "subscriptions"],
|
|
271
274
|
subscriptionsList: (filters) => [...saferCityKeys.subscriptions(), "list", filters],
|
|
272
275
|
subscriptionsTypes: () => [...saferCityKeys.subscriptions(), "types"],
|
|
273
|
-
subscriptionsStats: () => [...saferCityKeys.subscriptions(), "stats"],
|
|
274
276
|
// Location Safety
|
|
275
277
|
locationSafety: (lat, lng) => [...saferCityKeys.all, "location-safety", lat, lng],
|
|
276
278
|
// Banner
|
|
@@ -351,6 +353,17 @@ function useCreatePanic(options) {
|
|
|
351
353
|
...options
|
|
352
354
|
});
|
|
353
355
|
}
|
|
356
|
+
function useCreatePremiumPanic(options) {
|
|
357
|
+
const client = useSaferCityClient();
|
|
358
|
+
const queryClient = useQueryClient();
|
|
359
|
+
return useMutation({
|
|
360
|
+
mutationFn: (data) => client.panics.createPremium(data),
|
|
361
|
+
onSuccess: () => {
|
|
362
|
+
queryClient.invalidateQueries({ queryKey: saferCityKeys.panics() });
|
|
363
|
+
},
|
|
364
|
+
...options
|
|
365
|
+
});
|
|
366
|
+
}
|
|
354
367
|
function useUpdatePanicLocation(options) {
|
|
355
368
|
const client = useSaferCityClient();
|
|
356
369
|
const queryClient = useQueryClient();
|
|
@@ -474,17 +487,6 @@ function useCreateSubscription(options) {
|
|
|
474
487
|
...options
|
|
475
488
|
});
|
|
476
489
|
}
|
|
477
|
-
function useSubscribeUser(options) {
|
|
478
|
-
const client = useSaferCityClient();
|
|
479
|
-
const queryClient = useQueryClient();
|
|
480
|
-
return useMutation({
|
|
481
|
-
mutationFn: (body) => client.subscriptions.subscribeUser(body),
|
|
482
|
-
onSuccess: () => {
|
|
483
|
-
queryClient.invalidateQueries({ queryKey: saferCityKeys.subscriptions() });
|
|
484
|
-
},
|
|
485
|
-
...options
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
490
|
function useBulkTriggerNotifications(options) {
|
|
489
491
|
const client = useSaferCityClient();
|
|
490
492
|
return useMutation({
|
|
@@ -746,6 +748,6 @@ function useStream(createStream, options = {}) {
|
|
|
746
748
|
};
|
|
747
749
|
}
|
|
748
750
|
|
|
749
|
-
export { SaferCityProvider, 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,
|
|
751
|
+
export { SaferCityProvider, saferCityKeys, useAuthMode, useBanner, useBulkTriggerNotifications, useCancelPanic, useCreatePanic, useCreatePanicInformation, useCreatePremiumPanic, useCreateSubscription, useCreateUser, useCrimeCategories, useCrimeCategoriesWithTypes, useCrimeTypes, useCrimes, useDeletePanicInformation, useHealthCheck, useLocationSafety, usePanic, usePanicEligibility, usePanicInformation, usePanicInformationByUser, usePanicStream, usePanicTypes, useSaferCity, useSaferCityClient, useSession, useSessionManager, useStream, useSubscriptionTypes, useSubscriptions, useUpdatePanicInformation, useUpdatePanicLocation, useUpdateUser, useUser, useWhoAmI };
|
|
750
752
|
//# sourceMappingURL=index.js.map
|
|
751
753
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider.tsx","../src/hooks.ts","../src/use-stream.ts"],"names":["useState","useCallback","useEffect"],"mappings":";;;;;;AAsCA,IAAM,gBAAA,GAAmB,cAA4C,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,GAAiB,QAAQ,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,UAAU,CAAA,GAAI,QAAA,CAAuB;AAAA,IACnD,eAAA,EAAiB,KAAA;AAAA,IACjB,WAAW,IAAA,KAAS;AAAA,GACrB,CAAA;AAGD,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAM;A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;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,YAAY,MAAM;AACnC,IAAA,WAAA,CAAY,OAAA,GAAU,KAAA;AAAA,EACxB,CAAA,EAAG,EAAE,CAAA;AAEL,EAAAC,UAAU,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.js","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 { SaferCityApiError } from '@safercity/sdk';\n\ntype SaferCityClient = ReturnType<typeof useSaferCityClient>;\ntype QueryOptionsFor<T extends (...args: any) => any> = Omit<\n UseQueryOptions<Awaited<ReturnType<T>>, SaferCityApiError>,\n 'queryKey' | 'queryFn'\n>;\ntype MutationOptionsFor<T extends (...args: any) => any, TVariables = Parameters<T>[0]> =\n UseMutationOptions<Awaited<ReturnType<T>>, SaferCityApiError, TVariables>;\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?: QueryOptionsFor<SaferCityClient['health']['check']>\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?: QueryOptionsFor<SaferCityClient['auth']['whoami']>\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?: QueryOptionsFor<SaferCityClient['users']['get']>\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?: MutationOptionsFor<SaferCityClient['users']['create']>\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?: MutationOptionsFor<\n SaferCityClient['users']['update'],\n {\n userId: Parameters<SaferCityClient['users']['update']>[0];\n data: Parameters<SaferCityClient['users']['update']>[1];\n }\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 if (userId) {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.usersDetail(userId) });\n }\n },\n ...options,\n });\n}\n\n// ==================\n// Panic Hooks\n// ==================\n\nexport function usePanic(\n panicId: string,\n query?: { userId?: string },\n options?: QueryOptionsFor<SaferCityClient['panics']['get']>\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?: MutationOptionsFor<SaferCityClient['panics']['create']>\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?: MutationOptionsFor<\n SaferCityClient['panics']['updateLocation'],\n {\n panicId: Parameters<SaferCityClient['panics']['updateLocation']>[0];\n data: Parameters<SaferCityClient['panics']['updateLocation']>[1];\n }\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?: MutationOptionsFor<\n SaferCityClient['panics']['cancel'],\n {\n panicId: Parameters<SaferCityClient['panics']['cancel']>[0];\n data: Parameters<SaferCityClient['panics']['cancel']>[1];\n }\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?: QueryOptionsFor<SaferCityClient['panics']['types']>\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?: QueryOptionsFor<SaferCityClient['panicInformation']['get']>\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?: QueryOptionsFor<SaferCityClient['panicInformation']['getByUser']>\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?: QueryOptionsFor<SaferCityClient['panicInformation']['validateEligibility']>\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?: MutationOptionsFor<SaferCityClient['panicInformation']['create']>\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?: MutationOptionsFor<\n SaferCityClient['panicInformation']['update'],\n {\n id: Parameters<SaferCityClient['panicInformation']['update']>[0];\n data: Parameters<SaferCityClient['panicInformation']['update']>[1];\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?: MutationOptionsFor<SaferCityClient['panicInformation']['delete']>\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?: QueryOptionsFor<SaferCityClient['subscriptions']['listTypes']>\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?: QueryOptionsFor<SaferCityClient['subscriptions']['list']>\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?: MutationOptionsFor<SaferCityClient['subscriptions']['create']>\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?: MutationOptionsFor<SaferCityClient['subscriptions']['subscribeUser']>\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?: MutationOptionsFor<SaferCityClient['notifications']['bulkTrigger']>\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?: QueryOptionsFor<SaferCityClient['locationSafety']['check']>\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?: QueryOptionsFor<SaferCityClient['banner']['get']>\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?: QueryOptionsFor<SaferCityClient['crimes']['list']>\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?: QueryOptionsFor<SaferCityClient['crimes']['categories']>\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?: QueryOptionsFor<SaferCityClient['crimes']['types']>\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?: QueryOptionsFor<SaferCityClient['crimes']['categoriesWithTypes']>\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"]}
|
|
1
|
+
{"version":3,"sources":["../src/provider.tsx","../src/hooks.ts","../src/use-stream.ts"],"names":["useState","useCallback","useEffect"],"mappings":";;;;;;AAsCA,IAAM,gBAAA,GAAmB,cAA4C,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,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,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.js","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 tenantId: props.tenantId,\n userId: props.userId,\n headers: props.headers,\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 { SaferCityApiError } from '@safercity/sdk';\n\ntype SaferCityClient = ReturnType<typeof useSaferCityClient>;\ntype QueryOptionsFor<T extends (...args: any) => any> = Omit<\n UseQueryOptions<Awaited<ReturnType<T>>, SaferCityApiError>,\n 'queryKey' | 'queryFn'\n>;\ntype MutationOptionsFor<T extends (...args: any) => any, TVariables = Parameters<T>[0]> =\n UseMutationOptions<Awaited<ReturnType<T>>, SaferCityApiError, TVariables>;\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 \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; days?: 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?: QueryOptionsFor<SaferCityClient['health']['check']>\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?: QueryOptionsFor<SaferCityClient['auth']['whoami']>\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?: QueryOptionsFor<SaferCityClient['users']['get']>\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?: MutationOptionsFor<SaferCityClient['users']['create']>\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?: MutationOptionsFor<\n SaferCityClient['users']['update'],\n {\n userId: Parameters<SaferCityClient['users']['update']>[0];\n data: Parameters<SaferCityClient['users']['update']>[1];\n }\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 if (userId) {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.usersDetail(userId) });\n }\n },\n ...options,\n });\n}\n\n// ==================\n// Panic Hooks\n// ==================\n\nexport function usePanic(\n panicId: string,\n query?: { userId?: string },\n options?: QueryOptionsFor<SaferCityClient['panics']['get']>\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?: MutationOptionsFor<SaferCityClient['panics']['create']>\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 useCreatePremiumPanic(\n options?: MutationOptionsFor<SaferCityClient['panics']['createPremium']>\n) {\n const client = useSaferCityClient();\n const queryClient = useQueryClient();\n \n return useMutation({\n mutationFn: (data) => client.panics.createPremium(data),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: saferCityKeys.panics() });\n },\n ...options,\n });\n}\n\nexport function useUpdatePanicLocation(\n options?: MutationOptionsFor<\n SaferCityClient['panics']['updateLocation'],\n {\n panicId: Parameters<SaferCityClient['panics']['updateLocation']>[0];\n data: Parameters<SaferCityClient['panics']['updateLocation']>[1];\n }\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?: MutationOptionsFor<\n SaferCityClient['panics']['cancel'],\n {\n panicId: Parameters<SaferCityClient['panics']['cancel']>[0];\n data: Parameters<SaferCityClient['panics']['cancel']>[1];\n }\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?: QueryOptionsFor<SaferCityClient['panics']['types']>\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?: QueryOptionsFor<SaferCityClient['panicInformation']['get']>\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?: QueryOptionsFor<SaferCityClient['panicInformation']['getByUser']>\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?: QueryOptionsFor<SaferCityClient['panicInformation']['validateEligibility']>\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?: MutationOptionsFor<SaferCityClient['panicInformation']['create']>\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?: MutationOptionsFor<\n SaferCityClient['panicInformation']['update'],\n {\n id: Parameters<SaferCityClient['panicInformation']['update']>[0];\n data: Parameters<SaferCityClient['panicInformation']['update']>[1];\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?: MutationOptionsFor<SaferCityClient['panicInformation']['delete']>\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?: QueryOptionsFor<SaferCityClient['subscriptions']['listTypes']>\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?: {\n userId?: string;\n status?: string;\n limit?: number;\n cursor?: string;\n subscriptionTypeId?: string;\n sortBy?: 'createdAt' | 'updatedAt' | 'status';\n sortOrder?: 'asc' | 'desc';\n search?: string;\n },\n options?: QueryOptionsFor<SaferCityClient['subscriptions']['list']>\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?: MutationOptionsFor<SaferCityClient['subscriptions']['create']>\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// Notification Hooks\n// ==================\n\nexport function useBulkTriggerNotifications(\n options?: MutationOptionsFor<SaferCityClient['notifications']['bulkTrigger']>\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?: QueryOptionsFor<SaferCityClient['locationSafety']['check']>\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; days?: number },\n options?: QueryOptionsFor<SaferCityClient['banner']['get']>\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?: QueryOptionsFor<SaferCityClient['crimes']['list']>\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?: QueryOptionsFor<SaferCityClient['crimes']['categories']>\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?: QueryOptionsFor<SaferCityClient['crimes']['types']>\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?: QueryOptionsFor<SaferCityClient['crimes']['categoriesWithTypes']>\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"]}
|