@safercity/sdk-react 0.1.3 → 0.2.1
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/README.md +53 -8
- package/dist/index.cjs +136 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +226 -31
- package/dist/index.d.ts +226 -31
- package/dist/index.js +126 -25
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProxyModeConfig, DirectModeConfig, CookieModeConfig, SaferCityClientOptions, SaferCityClient, AuthMode, ApiResponse, SaferCityApiError, ServerSentEvent } from '@safercity/sdk';
|
|
1
|
+
import { ProxyModeConfig, DirectModeConfig, CookieModeConfig, SaferCityClientOptions, SaferCityClient, AuthMode, ApiResponse, SaferCityApiError, PanicInformationRecord, ServerSentEvent } from '@safercity/sdk';
|
|
2
2
|
export * from '@safercity/sdk';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
@@ -46,11 +46,13 @@ interface ProxyModeProviderProps extends BaseProviderProps, ProxyModeConfig {
|
|
|
46
46
|
* Props for direct mode
|
|
47
47
|
*/
|
|
48
48
|
interface DirectModeProviderProps extends BaseProviderProps, DirectModeConfig {
|
|
49
|
+
userId?: string;
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
52
|
* Props for cookie mode
|
|
52
53
|
*/
|
|
53
54
|
interface CookieModeProviderProps extends BaseProviderProps, CookieModeConfig {
|
|
55
|
+
userId?: string;
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
56
58
|
* Legacy props (for backward compatibility)
|
|
@@ -127,20 +129,34 @@ declare const saferCityKeys: {
|
|
|
127
129
|
auth: () => readonly ["safercity", "auth"];
|
|
128
130
|
authWhoami: () => readonly ["safercity", "auth", "whoami"];
|
|
129
131
|
users: () => readonly ["safercity", "users"];
|
|
130
|
-
usersList: (filters?: Record<string, unknown>) => readonly ["safercity", "users", "list", Record<string, unknown> | undefined];
|
|
131
132
|
usersDetail: (userId: string) => readonly ["safercity", "users", "detail", string];
|
|
132
133
|
panics: () => readonly ["safercity", "panics"];
|
|
133
134
|
panicsList: (filters?: Record<string, unknown>) => readonly ["safercity", "panics", "list", Record<string, unknown> | undefined];
|
|
134
135
|
panicsDetail: (panicId: string) => readonly ["safercity", "panics", "detail", string];
|
|
136
|
+
panicTypes: (userId: string) => readonly ["safercity", "panics", "types", string];
|
|
137
|
+
panicInformation: () => readonly ["safercity", "panicInformation"];
|
|
138
|
+
panicInformationDetail: (id: string) => readonly ["safercity", "panicInformation", "detail", string];
|
|
139
|
+
panicInformationByUser: (userId: string) => readonly ["safercity", "panicInformation", "byUser", string];
|
|
140
|
+
panicEligibility: (userId: string) => readonly ["safercity", "panicInformation", "eligibility", string];
|
|
135
141
|
subscriptions: () => readonly ["safercity", "subscriptions"];
|
|
136
142
|
subscriptionsList: (filters?: Record<string, unknown>) => readonly ["safercity", "subscriptions", "list", Record<string, unknown> | undefined];
|
|
137
143
|
subscriptionsTypes: () => readonly ["safercity", "subscriptions", "types"];
|
|
138
144
|
subscriptionsStats: () => readonly ["safercity", "subscriptions", "stats"];
|
|
139
145
|
locationSafety: (lat: number, lng: number) => readonly ["safercity", "location-safety", number, number];
|
|
146
|
+
banner: (body: {
|
|
147
|
+
latitude: number;
|
|
148
|
+
longitude: number;
|
|
149
|
+
radius?: number;
|
|
150
|
+
}) => readonly ["safercity", "banner", {
|
|
151
|
+
latitude: number;
|
|
152
|
+
longitude: number;
|
|
153
|
+
radius?: number;
|
|
154
|
+
}];
|
|
140
155
|
crimes: () => readonly ["safercity", "crimes"];
|
|
141
156
|
crimesList: (filters?: Record<string, unknown>) => readonly ["safercity", "crimes", "list", Record<string, unknown> | undefined];
|
|
142
157
|
crimesCategories: () => readonly ["safercity", "crimes", "categories"];
|
|
143
158
|
crimesTypes: () => readonly ["safercity", "crimes", "types"];
|
|
159
|
+
crimeCategoriesWithTypes: () => readonly ["safercity", "crimes", "categoriesWithTypes"];
|
|
144
160
|
};
|
|
145
161
|
declare function useHealthCheck(options?: Omit<UseQueryOptions<ApiResponse<{
|
|
146
162
|
status: string;
|
|
@@ -160,29 +176,6 @@ declare function useWhoAmI(options?: Omit<UseQueryOptions<ApiResponse<{
|
|
|
160
176
|
scopes: string[];
|
|
161
177
|
sessionId: string;
|
|
162
178
|
}>, SaferCityApiError>;
|
|
163
|
-
declare function useUsers(filters?: {
|
|
164
|
-
limit?: number;
|
|
165
|
-
cursor?: string;
|
|
166
|
-
status?: string;
|
|
167
|
-
}, options?: Omit<UseQueryOptions<ApiResponse<{
|
|
168
|
-
users: Array<{
|
|
169
|
-
id: string;
|
|
170
|
-
email?: string;
|
|
171
|
-
phone?: string;
|
|
172
|
-
status: string;
|
|
173
|
-
}>;
|
|
174
|
-
hasNext: boolean;
|
|
175
|
-
cursor?: string;
|
|
176
|
-
}>, SaferCityApiError>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ApiResponse<{
|
|
177
|
-
users: Array<{
|
|
178
|
-
id: string;
|
|
179
|
-
email?: string;
|
|
180
|
-
phone?: string;
|
|
181
|
-
status: string;
|
|
182
|
-
}>;
|
|
183
|
-
hasNext: boolean;
|
|
184
|
-
cursor?: string;
|
|
185
|
-
}>, SaferCityApiError>;
|
|
186
179
|
declare function useUser(userId: string, options?: Omit<UseQueryOptions<ApiResponse<{
|
|
187
180
|
id: string;
|
|
188
181
|
email?: string;
|
|
@@ -244,11 +237,6 @@ declare function useUpdateUser(options?: UseMutationOptions<ApiResponse<{
|
|
|
244
237
|
metadata?: Record<string, unknown>;
|
|
245
238
|
};
|
|
246
239
|
}, unknown>;
|
|
247
|
-
declare function useDeleteUser(options?: UseMutationOptions<ApiResponse<{
|
|
248
|
-
success: boolean;
|
|
249
|
-
}>, SaferCityApiError, string>): _tanstack_react_query.UseMutationResult<ApiResponse<{
|
|
250
|
-
success: boolean;
|
|
251
|
-
}>, SaferCityApiError, string, unknown>;
|
|
252
240
|
declare function usePanic(panicId: string, query?: {
|
|
253
241
|
userId?: string;
|
|
254
242
|
}, options?: Omit<UseQueryOptions<ApiResponse<{
|
|
@@ -337,6 +325,137 @@ declare function useCancelPanic(options?: UseMutationOptions<ApiResponse<{
|
|
|
337
325
|
reason?: string;
|
|
338
326
|
};
|
|
339
327
|
}, unknown>;
|
|
328
|
+
declare function usePanicTypes(userId: string, options?: Omit<UseQueryOptions<ApiResponse<{
|
|
329
|
+
types: Array<{
|
|
330
|
+
id: string;
|
|
331
|
+
name: string;
|
|
332
|
+
description?: string;
|
|
333
|
+
}>;
|
|
334
|
+
}>, SaferCityApiError>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ApiResponse<{
|
|
335
|
+
types: Array<{
|
|
336
|
+
id: string;
|
|
337
|
+
name: string;
|
|
338
|
+
description?: string;
|
|
339
|
+
}>;
|
|
340
|
+
}>, SaferCityApiError>;
|
|
341
|
+
declare function usePanicInformation(id: string, options?: Omit<UseQueryOptions<ApiResponse<{
|
|
342
|
+
success: boolean;
|
|
343
|
+
data: PanicInformationRecord;
|
|
344
|
+
}>, SaferCityApiError>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ApiResponse<{
|
|
345
|
+
success: boolean;
|
|
346
|
+
data: PanicInformationRecord;
|
|
347
|
+
}>, SaferCityApiError>;
|
|
348
|
+
declare function usePanicInformationByUser(userId: string, options?: Omit<UseQueryOptions<ApiResponse<{
|
|
349
|
+
success: boolean;
|
|
350
|
+
data: PanicInformationRecord;
|
|
351
|
+
}>, SaferCityApiError>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ApiResponse<{
|
|
352
|
+
success: boolean;
|
|
353
|
+
data: PanicInformationRecord;
|
|
354
|
+
}>, SaferCityApiError>;
|
|
355
|
+
declare function usePanicEligibility(userId: string, options?: Omit<UseQueryOptions<ApiResponse<{
|
|
356
|
+
success: boolean;
|
|
357
|
+
data: {
|
|
358
|
+
eligible: boolean;
|
|
359
|
+
subscriptionActive: boolean;
|
|
360
|
+
profileComplete: boolean;
|
|
361
|
+
reasons: string[];
|
|
362
|
+
panicInformation: PanicInformationRecord | null;
|
|
363
|
+
subscriptionDetails: {
|
|
364
|
+
usedSeats: number;
|
|
365
|
+
userHasActiveSubscription: boolean;
|
|
366
|
+
} | null;
|
|
367
|
+
};
|
|
368
|
+
}>, SaferCityApiError>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ApiResponse<{
|
|
369
|
+
success: boolean;
|
|
370
|
+
data: {
|
|
371
|
+
eligible: boolean;
|
|
372
|
+
subscriptionActive: boolean;
|
|
373
|
+
profileComplete: boolean;
|
|
374
|
+
reasons: string[];
|
|
375
|
+
panicInformation: PanicInformationRecord | null;
|
|
376
|
+
subscriptionDetails: {
|
|
377
|
+
usedSeats: number;
|
|
378
|
+
userHasActiveSubscription: boolean;
|
|
379
|
+
} | null;
|
|
380
|
+
};
|
|
381
|
+
}>, SaferCityApiError>;
|
|
382
|
+
declare function useCreatePanicInformation(options?: UseMutationOptions<ApiResponse<{
|
|
383
|
+
success: boolean;
|
|
384
|
+
data: PanicInformationRecord;
|
|
385
|
+
message: string;
|
|
386
|
+
}>, SaferCityApiError, {
|
|
387
|
+
userId: string;
|
|
388
|
+
phoneNumber: string;
|
|
389
|
+
firstName: string;
|
|
390
|
+
lastName: string;
|
|
391
|
+
idNumber: string;
|
|
392
|
+
duressCode?: string;
|
|
393
|
+
emergencyContacts?: Array<{
|
|
394
|
+
name: string;
|
|
395
|
+
phoneNumber: string;
|
|
396
|
+
relationship?: string;
|
|
397
|
+
}>;
|
|
398
|
+
}>): _tanstack_react_query.UseMutationResult<ApiResponse<{
|
|
399
|
+
success: boolean;
|
|
400
|
+
data: PanicInformationRecord;
|
|
401
|
+
message: string;
|
|
402
|
+
}>, SaferCityApiError, {
|
|
403
|
+
userId: string;
|
|
404
|
+
phoneNumber: string;
|
|
405
|
+
firstName: string;
|
|
406
|
+
lastName: string;
|
|
407
|
+
idNumber: string;
|
|
408
|
+
duressCode?: string;
|
|
409
|
+
emergencyContacts?: Array<{
|
|
410
|
+
name: string;
|
|
411
|
+
phoneNumber: string;
|
|
412
|
+
relationship?: string;
|
|
413
|
+
}>;
|
|
414
|
+
}, unknown>;
|
|
415
|
+
declare function useUpdatePanicInformation(options?: UseMutationOptions<ApiResponse<{
|
|
416
|
+
success: boolean;
|
|
417
|
+
data: PanicInformationRecord;
|
|
418
|
+
message: string;
|
|
419
|
+
}>, SaferCityApiError, {
|
|
420
|
+
id: string;
|
|
421
|
+
data: {
|
|
422
|
+
phoneNumber?: string;
|
|
423
|
+
firstName?: string;
|
|
424
|
+
lastName?: string;
|
|
425
|
+
idNumber?: string;
|
|
426
|
+
duressCode?: string;
|
|
427
|
+
emergencyContacts?: Array<{
|
|
428
|
+
name: string;
|
|
429
|
+
phoneNumber: string;
|
|
430
|
+
relationship?: string;
|
|
431
|
+
}>;
|
|
432
|
+
};
|
|
433
|
+
}>): _tanstack_react_query.UseMutationResult<ApiResponse<{
|
|
434
|
+
success: boolean;
|
|
435
|
+
data: PanicInformationRecord;
|
|
436
|
+
message: string;
|
|
437
|
+
}>, SaferCityApiError, {
|
|
438
|
+
id: string;
|
|
439
|
+
data: {
|
|
440
|
+
phoneNumber?: string;
|
|
441
|
+
firstName?: string;
|
|
442
|
+
lastName?: string;
|
|
443
|
+
idNumber?: string;
|
|
444
|
+
duressCode?: string;
|
|
445
|
+
emergencyContacts?: Array<{
|
|
446
|
+
name: string;
|
|
447
|
+
phoneNumber: string;
|
|
448
|
+
relationship?: string;
|
|
449
|
+
}>;
|
|
450
|
+
};
|
|
451
|
+
}, unknown>;
|
|
452
|
+
declare function useDeletePanicInformation(options?: UseMutationOptions<ApiResponse<{
|
|
453
|
+
success: boolean;
|
|
454
|
+
message: string;
|
|
455
|
+
}>, SaferCityApiError, string>): _tanstack_react_query.UseMutationResult<ApiResponse<{
|
|
456
|
+
success: boolean;
|
|
457
|
+
message: string;
|
|
458
|
+
}>, SaferCityApiError, string, unknown>;
|
|
340
459
|
declare function useSubscriptionTypes(options?: Omit<UseQueryOptions<ApiResponse<{
|
|
341
460
|
types: Array<{
|
|
342
461
|
id: string;
|
|
@@ -390,6 +509,38 @@ declare function useCreateSubscription(options?: UseMutationOptions<ApiResponse<
|
|
|
390
509
|
subscriptionTypeId: string;
|
|
391
510
|
status?: string;
|
|
392
511
|
}, unknown>;
|
|
512
|
+
declare function useSubscribeUser(options?: UseMutationOptions<ApiResponse<{
|
|
513
|
+
id: string;
|
|
514
|
+
userId: string;
|
|
515
|
+
subscriptionTypeId: string;
|
|
516
|
+
status: string;
|
|
517
|
+
}>, SaferCityApiError, {
|
|
518
|
+
userId: string;
|
|
519
|
+
subscriptionTypeId: string;
|
|
520
|
+
}>): _tanstack_react_query.UseMutationResult<ApiResponse<{
|
|
521
|
+
id: string;
|
|
522
|
+
userId: string;
|
|
523
|
+
subscriptionTypeId: string;
|
|
524
|
+
status: string;
|
|
525
|
+
}>, SaferCityApiError, {
|
|
526
|
+
userId: string;
|
|
527
|
+
subscriptionTypeId: string;
|
|
528
|
+
}, unknown>;
|
|
529
|
+
declare function useBulkTriggerNotifications(options?: UseMutationOptions<ApiResponse<{
|
|
530
|
+
transactionIds: string[];
|
|
531
|
+
status: string;
|
|
532
|
+
}>, SaferCityApiError, {
|
|
533
|
+
userIds: string[];
|
|
534
|
+
workflowId: string;
|
|
535
|
+
payload?: Record<string, unknown>;
|
|
536
|
+
}>): _tanstack_react_query.UseMutationResult<ApiResponse<{
|
|
537
|
+
transactionIds: string[];
|
|
538
|
+
status: string;
|
|
539
|
+
}>, SaferCityApiError, {
|
|
540
|
+
userIds: string[];
|
|
541
|
+
workflowId: string;
|
|
542
|
+
payload?: Record<string, unknown>;
|
|
543
|
+
}, unknown>;
|
|
393
544
|
declare function useLocationSafety(latitude: number, longitude: number, radius?: number, options?: Omit<UseQueryOptions<ApiResponse<{
|
|
394
545
|
safetyScore: number;
|
|
395
546
|
riskLevel: string;
|
|
@@ -405,6 +556,31 @@ declare function useLocationSafety(latitude: number, longitude: number, radius?:
|
|
|
405
556
|
impact: number;
|
|
406
557
|
}>;
|
|
407
558
|
}>, SaferCityApiError>;
|
|
559
|
+
declare function useBanner(body: {
|
|
560
|
+
latitude: number;
|
|
561
|
+
longitude: number;
|
|
562
|
+
radius?: number;
|
|
563
|
+
}, options?: Omit<UseQueryOptions<ApiResponse<{
|
|
564
|
+
success: boolean;
|
|
565
|
+
data: {
|
|
566
|
+
totalCrimes: number;
|
|
567
|
+
categories: Array<{
|
|
568
|
+
name: string;
|
|
569
|
+
count: number;
|
|
570
|
+
}>;
|
|
571
|
+
period: string;
|
|
572
|
+
};
|
|
573
|
+
}>, SaferCityApiError>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ApiResponse<{
|
|
574
|
+
success: boolean;
|
|
575
|
+
data: {
|
|
576
|
+
totalCrimes: number;
|
|
577
|
+
categories: Array<{
|
|
578
|
+
name: string;
|
|
579
|
+
count: number;
|
|
580
|
+
}>;
|
|
581
|
+
period: string;
|
|
582
|
+
};
|
|
583
|
+
}>, SaferCityApiError>;
|
|
408
584
|
declare function useCrimes(filters?: {
|
|
409
585
|
latitude?: number;
|
|
410
586
|
longitude?: number;
|
|
@@ -454,6 +630,25 @@ declare function useCrimeTypes(options?: Omit<UseQueryOptions<ApiResponse<{
|
|
|
454
630
|
categoryId: string;
|
|
455
631
|
}>;
|
|
456
632
|
}>, SaferCityApiError>;
|
|
633
|
+
declare function useCrimeCategoriesWithTypes(options?: Omit<UseQueryOptions<ApiResponse<{
|
|
634
|
+
categories: Array<{
|
|
635
|
+
id: string;
|
|
636
|
+
name: string;
|
|
637
|
+
types: Array<{
|
|
638
|
+
id: string;
|
|
639
|
+
name: string;
|
|
640
|
+
}>;
|
|
641
|
+
}>;
|
|
642
|
+
}>, SaferCityApiError>, 'queryKey' | 'queryFn'>): _tanstack_react_query.UseQueryResult<ApiResponse<{
|
|
643
|
+
categories: Array<{
|
|
644
|
+
id: string;
|
|
645
|
+
name: string;
|
|
646
|
+
types: Array<{
|
|
647
|
+
id: string;
|
|
648
|
+
name: string;
|
|
649
|
+
}>;
|
|
650
|
+
}>;
|
|
651
|
+
}>, SaferCityApiError>;
|
|
457
652
|
|
|
458
653
|
/**
|
|
459
654
|
* State for streaming hooks
|
|
@@ -586,4 +781,4 @@ declare function useStream<T = ServerSentEvent>(createStream: () => AsyncIterabl
|
|
|
586
781
|
error: Error | null;
|
|
587
782
|
};
|
|
588
783
|
|
|
589
|
-
export { type CookieModeProviderProps, type DirectModeProviderProps, type ProxyModeProviderProps, SaferCityProvider, type SaferCityProviderProps, type SessionState, type StreamState, type UseStreamOptions, saferCityKeys, useAuthMode, useCancelPanic, useCreatePanic, useCreateSubscription, useCreateUser, useCrimeCategories, useCrimeTypes, useCrimes,
|
|
784
|
+
export { type CookieModeProviderProps, type DirectModeProviderProps, type ProxyModeProviderProps, SaferCityProvider, type SaferCityProviderProps, type SessionState, type StreamState, type UseStreamOptions, saferCityKeys, useAuthMode, useBanner, useBulkTriggerNotifications, useCancelPanic, useCreatePanic, useCreatePanicInformation, useCreateSubscription, useCreateUser, useCrimeCategories, useCrimeCategoriesWithTypes, useCrimeTypes, useCrimes, useDeletePanicInformation, useHealthCheck, useLocationSafety, usePanic, usePanicEligibility, usePanicInformation, usePanicInformationByUser, usePanicStream, usePanicTypes, useSaferCity, useSaferCityClient, useSession, useSessionManager, useStream, useSubscribeUser, useSubscriptionTypes, useSubscriptions, useUpdatePanicInformation, useUpdatePanicLocation, useUpdateUser, useUser, useWhoAmI };
|
package/dist/index.js
CHANGED
|
@@ -48,13 +48,15 @@ function SaferCityProvider(props) {
|
|
|
48
48
|
if (isDirectMode(props)) {
|
|
49
49
|
return createSaferCityClient({
|
|
50
50
|
baseUrl: props.baseUrl,
|
|
51
|
-
tenantId: props.tenantId
|
|
51
|
+
tenantId: props.tenantId,
|
|
52
|
+
userId: props.userId
|
|
52
53
|
});
|
|
53
54
|
}
|
|
54
55
|
if (isCookieMode(props)) {
|
|
55
56
|
return createSaferCityClient({
|
|
56
57
|
baseUrl: props.baseUrl,
|
|
57
58
|
tenantId: props.tenantId,
|
|
59
|
+
userId: props.userId,
|
|
58
60
|
headers: {
|
|
59
61
|
// Note: cookies are sent automatically with fetch credentials: 'include'
|
|
60
62
|
}
|
|
@@ -91,6 +93,7 @@ function SaferCityProvider(props) {
|
|
|
91
93
|
if (!isMounted) return;
|
|
92
94
|
if (response.ok) {
|
|
93
95
|
const data = await response.json();
|
|
96
|
+
client.setUserId(data.userId);
|
|
94
97
|
setSession({
|
|
95
98
|
isAuthenticated: data.authenticated,
|
|
96
99
|
isLoading: false,
|
|
@@ -117,7 +120,7 @@ function SaferCityProvider(props) {
|
|
|
117
120
|
return () => {
|
|
118
121
|
isMounted = false;
|
|
119
122
|
};
|
|
120
|
-
}, [mode, props]);
|
|
123
|
+
}, [mode, props, client]);
|
|
121
124
|
const createSession = useCallback(async (token, tenantId) => {
|
|
122
125
|
if (mode !== "cookie" || !isCookieMode(props)) {
|
|
123
126
|
throw new Error("createSession is only available in cookie mode");
|
|
@@ -252,12 +255,17 @@ var saferCityKeys = {
|
|
|
252
255
|
authWhoami: () => [...saferCityKeys.auth(), "whoami"],
|
|
253
256
|
// Users
|
|
254
257
|
users: () => [...saferCityKeys.all, "users"],
|
|
255
|
-
usersList: (filters) => [...saferCityKeys.users(), "list", filters],
|
|
256
258
|
usersDetail: (userId) => [...saferCityKeys.users(), "detail", userId],
|
|
257
259
|
// Panics
|
|
258
260
|
panics: () => [...saferCityKeys.all, "panics"],
|
|
259
261
|
panicsList: (filters) => [...saferCityKeys.panics(), "list", filters],
|
|
260
262
|
panicsDetail: (panicId) => [...saferCityKeys.panics(), "detail", panicId],
|
|
263
|
+
panicTypes: (userId) => [...saferCityKeys.panics(), "types", userId],
|
|
264
|
+
// Panic Information
|
|
265
|
+
panicInformation: () => [...saferCityKeys.all, "panicInformation"],
|
|
266
|
+
panicInformationDetail: (id) => [...saferCityKeys.panicInformation(), "detail", id],
|
|
267
|
+
panicInformationByUser: (userId) => [...saferCityKeys.panicInformation(), "byUser", userId],
|
|
268
|
+
panicEligibility: (userId) => [...saferCityKeys.panicInformation(), "eligibility", userId],
|
|
261
269
|
// Subscriptions
|
|
262
270
|
subscriptions: () => [...saferCityKeys.all, "subscriptions"],
|
|
263
271
|
subscriptionsList: (filters) => [...saferCityKeys.subscriptions(), "list", filters],
|
|
@@ -265,11 +273,14 @@ var saferCityKeys = {
|
|
|
265
273
|
subscriptionsStats: () => [...saferCityKeys.subscriptions(), "stats"],
|
|
266
274
|
// Location Safety
|
|
267
275
|
locationSafety: (lat, lng) => [...saferCityKeys.all, "location-safety", lat, lng],
|
|
276
|
+
// Banner
|
|
277
|
+
banner: (body) => [...saferCityKeys.all, "banner", body],
|
|
268
278
|
// Crimes
|
|
269
279
|
crimes: () => [...saferCityKeys.all, "crimes"],
|
|
270
280
|
crimesList: (filters) => [...saferCityKeys.crimes(), "list", filters],
|
|
271
281
|
crimesCategories: () => [...saferCityKeys.crimes(), "categories"],
|
|
272
|
-
crimesTypes: () => [...saferCityKeys.crimes(), "types"]
|
|
282
|
+
crimesTypes: () => [...saferCityKeys.crimes(), "types"],
|
|
283
|
+
crimeCategoriesWithTypes: () => [...saferCityKeys.crimes(), "categoriesWithTypes"]
|
|
273
284
|
};
|
|
274
285
|
function useHealthCheck(options) {
|
|
275
286
|
const client = useSaferCityClient();
|
|
@@ -287,14 +298,6 @@ function useWhoAmI(options) {
|
|
|
287
298
|
...options
|
|
288
299
|
});
|
|
289
300
|
}
|
|
290
|
-
function useUsers(filters, options) {
|
|
291
|
-
const client = useSaferCityClient();
|
|
292
|
-
return useQuery({
|
|
293
|
-
queryKey: saferCityKeys.usersList(filters),
|
|
294
|
-
queryFn: () => client.users.list(filters),
|
|
295
|
-
...options
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
301
|
function useUser(userId, options) {
|
|
299
302
|
const client = useSaferCityClient();
|
|
300
303
|
return useQuery({
|
|
@@ -322,18 +325,6 @@ function useUpdateUser(options) {
|
|
|
322
325
|
mutationFn: ({ userId, data }) => client.users.update(userId, data),
|
|
323
326
|
onSuccess: (_, { userId }) => {
|
|
324
327
|
queryClient.invalidateQueries({ queryKey: saferCityKeys.usersDetail(userId) });
|
|
325
|
-
queryClient.invalidateQueries({ queryKey: saferCityKeys.usersList() });
|
|
326
|
-
},
|
|
327
|
-
...options
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
function useDeleteUser(options) {
|
|
331
|
-
const client = useSaferCityClient();
|
|
332
|
-
const queryClient = useQueryClient();
|
|
333
|
-
return useMutation({
|
|
334
|
-
mutationFn: (userId) => client.users.delete(userId),
|
|
335
|
-
onSuccess: () => {
|
|
336
|
-
queryClient.invalidateQueries({ queryKey: saferCityKeys.users() });
|
|
337
328
|
},
|
|
338
329
|
...options
|
|
339
330
|
});
|
|
@@ -381,6 +372,77 @@ function useCancelPanic(options) {
|
|
|
381
372
|
...options
|
|
382
373
|
});
|
|
383
374
|
}
|
|
375
|
+
function usePanicTypes(userId, options) {
|
|
376
|
+
const client = useSaferCityClient();
|
|
377
|
+
return useQuery({
|
|
378
|
+
queryKey: saferCityKeys.panicTypes(userId),
|
|
379
|
+
queryFn: () => client.panics.types(userId),
|
|
380
|
+
enabled: !!userId,
|
|
381
|
+
staleTime: 1e3 * 60 * 10,
|
|
382
|
+
// 10 minutes - types don't change often
|
|
383
|
+
...options
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
function usePanicInformation(id, options) {
|
|
387
|
+
const client = useSaferCityClient();
|
|
388
|
+
return useQuery({
|
|
389
|
+
queryKey: saferCityKeys.panicInformationDetail(id),
|
|
390
|
+
queryFn: () => client.panicInformation.get(id),
|
|
391
|
+
enabled: !!id,
|
|
392
|
+
...options
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
function usePanicInformationByUser(userId, options) {
|
|
396
|
+
const client = useSaferCityClient();
|
|
397
|
+
return useQuery({
|
|
398
|
+
queryKey: saferCityKeys.panicInformationByUser(userId),
|
|
399
|
+
queryFn: () => client.panicInformation.getByUser(userId),
|
|
400
|
+
enabled: !!userId,
|
|
401
|
+
...options
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
function usePanicEligibility(userId, options) {
|
|
405
|
+
const client = useSaferCityClient();
|
|
406
|
+
return useQuery({
|
|
407
|
+
queryKey: saferCityKeys.panicEligibility(userId),
|
|
408
|
+
queryFn: () => client.panicInformation.validateEligibility(userId),
|
|
409
|
+
enabled: !!userId,
|
|
410
|
+
...options
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
function useCreatePanicInformation(options) {
|
|
414
|
+
const client = useSaferCityClient();
|
|
415
|
+
const queryClient = useQueryClient();
|
|
416
|
+
return useMutation({
|
|
417
|
+
mutationFn: (data) => client.panicInformation.create(data),
|
|
418
|
+
onSuccess: () => {
|
|
419
|
+
queryClient.invalidateQueries({ queryKey: saferCityKeys.panicInformation() });
|
|
420
|
+
},
|
|
421
|
+
...options
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
function useUpdatePanicInformation(options) {
|
|
425
|
+
const client = useSaferCityClient();
|
|
426
|
+
const queryClient = useQueryClient();
|
|
427
|
+
return useMutation({
|
|
428
|
+
mutationFn: ({ id, data }) => client.panicInformation.update(id, data),
|
|
429
|
+
onSuccess: () => {
|
|
430
|
+
queryClient.invalidateQueries({ queryKey: saferCityKeys.panicInformation() });
|
|
431
|
+
},
|
|
432
|
+
...options
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
function useDeletePanicInformation(options) {
|
|
436
|
+
const client = useSaferCityClient();
|
|
437
|
+
const queryClient = useQueryClient();
|
|
438
|
+
return useMutation({
|
|
439
|
+
mutationFn: (id) => client.panicInformation.delete(id),
|
|
440
|
+
onSuccess: () => {
|
|
441
|
+
queryClient.invalidateQueries({ queryKey: saferCityKeys.panicInformation() });
|
|
442
|
+
},
|
|
443
|
+
...options
|
|
444
|
+
});
|
|
445
|
+
}
|
|
384
446
|
function useSubscriptionTypes(options) {
|
|
385
447
|
const client = useSaferCityClient();
|
|
386
448
|
return useQuery({
|
|
@@ -410,6 +472,24 @@ function useCreateSubscription(options) {
|
|
|
410
472
|
...options
|
|
411
473
|
});
|
|
412
474
|
}
|
|
475
|
+
function useSubscribeUser(options) {
|
|
476
|
+
const client = useSaferCityClient();
|
|
477
|
+
const queryClient = useQueryClient();
|
|
478
|
+
return useMutation({
|
|
479
|
+
mutationFn: (body) => client.subscriptions.subscribeUser(body),
|
|
480
|
+
onSuccess: () => {
|
|
481
|
+
queryClient.invalidateQueries({ queryKey: saferCityKeys.subscriptions() });
|
|
482
|
+
},
|
|
483
|
+
...options
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
function useBulkTriggerNotifications(options) {
|
|
487
|
+
const client = useSaferCityClient();
|
|
488
|
+
return useMutation({
|
|
489
|
+
mutationFn: (body) => client.notifications.bulkTrigger(body),
|
|
490
|
+
...options
|
|
491
|
+
});
|
|
492
|
+
}
|
|
413
493
|
function useLocationSafety(latitude, longitude, radius, options) {
|
|
414
494
|
const client = useSaferCityClient();
|
|
415
495
|
return useQuery({
|
|
@@ -421,6 +501,17 @@ function useLocationSafety(latitude, longitude, radius, options) {
|
|
|
421
501
|
...options
|
|
422
502
|
});
|
|
423
503
|
}
|
|
504
|
+
function useBanner(body, options) {
|
|
505
|
+
const client = useSaferCityClient();
|
|
506
|
+
return useQuery({
|
|
507
|
+
queryKey: saferCityKeys.banner(body),
|
|
508
|
+
queryFn: () => client.banner.get(body),
|
|
509
|
+
enabled: body.latitude !== void 0 && body.longitude !== void 0,
|
|
510
|
+
staleTime: 1e3 * 60 * 5,
|
|
511
|
+
// 5 minutes - location-based, changes moderately
|
|
512
|
+
...options
|
|
513
|
+
});
|
|
514
|
+
}
|
|
424
515
|
function useCrimes(filters, options) {
|
|
425
516
|
const client = useSaferCityClient();
|
|
426
517
|
return useQuery({
|
|
@@ -449,6 +540,16 @@ function useCrimeTypes(options) {
|
|
|
449
540
|
...options
|
|
450
541
|
});
|
|
451
542
|
}
|
|
543
|
+
function useCrimeCategoriesWithTypes(options) {
|
|
544
|
+
const client = useSaferCityClient();
|
|
545
|
+
return useQuery({
|
|
546
|
+
queryKey: saferCityKeys.crimeCategoriesWithTypes(),
|
|
547
|
+
queryFn: () => client.crimes.categoriesWithTypes(),
|
|
548
|
+
staleTime: 1e3 * 60 * 30,
|
|
549
|
+
// 30 minutes - categories rarely change
|
|
550
|
+
...options
|
|
551
|
+
});
|
|
552
|
+
}
|
|
452
553
|
function usePanicStream(panicId, options = {}) {
|
|
453
554
|
const client = useSaferCityClient();
|
|
454
555
|
const {
|
|
@@ -643,6 +744,6 @@ function useStream(createStream, options = {}) {
|
|
|
643
744
|
};
|
|
644
745
|
}
|
|
645
746
|
|
|
646
|
-
export { SaferCityProvider, saferCityKeys, useAuthMode, useCancelPanic, useCreatePanic, useCreateSubscription, useCreateUser, useCrimeCategories, useCrimeTypes, useCrimes,
|
|
747
|
+
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, useSubscribeUser, useSubscriptionTypes, useSubscriptions, useUpdatePanicInformation, useUpdatePanicLocation, useUpdateUser, useUser, useWhoAmI };
|
|
647
748
|
//# sourceMappingURL=index.js.map
|
|
648
749
|
//# sourceMappingURL=index.js.map
|