@safercity/sdk 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2,36 +2,524 @@ import * as _safercity_sdk_core from '@safercity/sdk-core';
2
2
  import { SaferCityConfig, StreamAdapter, BaseClient, EventSourceOptions, ServerSentEvent, OAuthCredentials, TokenStorage } from '@safercity/sdk-core';
3
3
  export { ApiError, ApiResponse, AuthMode, AuthTokens, ClientModeConfig, CookieModeConfig, DirectModeConfig, EventSourceOptions, FetchStreamAdapter, MemoryTokenStorage, OAuthCredentials, ProxyModeConfig, RequestOptions, SaferCityApiError, SaferCityConfig, SaferCityJwtPayload, ServerSentEvent, StreamAdapter, TokenManager, TokenManagerConfig, TokenStorage, WebStreamAdapter, createAuthHeader, createStreamAdapter, getJwtExpiration, isTokenExpired, parseJwtPayload } from '@safercity/sdk-core';
4
4
 
5
+ interface PanicInformationRecord {
6
+ id: string;
7
+ tenantId: string;
8
+ userId: string;
9
+ phoneNumber: string;
10
+ firstName: string;
11
+ lastName: string;
12
+ idNumber: string;
13
+ duressCode?: string;
14
+ emergencyContacts: Array<{
15
+ name: string;
16
+ phoneNumber: string;
17
+ relationship?: string;
18
+ }> | null;
19
+ scaExternalId?: string | null;
20
+ scbExternalId?: string | null;
21
+ sccExternalId?: string | null;
22
+ createdAt: string;
23
+ updatedAt: string;
24
+ }
5
25
  interface SaferCityClientOptions extends SaferCityConfig {
6
26
  /**
7
- * Custom stream adapter for SSE (auto-detected if not provided)
27
+ * User ID for user-scoped operations
28
+ */
29
+ userId?: string;
30
+ /**
31
+ * Custom stream adapter for SSE (auto-detected if not provided)
32
+ */
33
+ streamAdapter?: StreamAdapter;
34
+ }
35
+ /**
36
+ * Create a SaferCity API client
37
+ *
38
+ * This client exposes user-scoped endpoints only.
39
+ * For admin/server operations, use `createServerClient` instead.
40
+ */
41
+ declare function createSaferCityClient(options: SaferCityClientOptions): {
42
+ /**
43
+ * Access the underlying base client for custom requests
44
+ */
45
+ _client: BaseClient;
46
+ /**
47
+ * Update authentication token
48
+ */
49
+ setToken: (token: string | undefined) => void;
50
+ /**
51
+ * Update tenant ID
52
+ */
53
+ setTenantId: (tenantId: string | undefined) => void;
54
+ /**
55
+ * Update user ID
56
+ */
57
+ setUserId: (nextUserId: string | undefined) => void;
58
+ /**
59
+ * Get current user ID
60
+ */
61
+ getUserId: () => string | undefined;
62
+ /**
63
+ * Get current configuration
64
+ */
65
+ getConfig: () => Readonly<SaferCityConfig>;
66
+ health: {
67
+ /**
68
+ * Check API health status
69
+ */
70
+ check: () => Promise<_safercity_sdk_core.ApiResponse<{
71
+ status: string;
72
+ timestamp: string;
73
+ panicProviders?: {
74
+ healthy: boolean;
75
+ stats?: unknown;
76
+ providers?: unknown;
77
+ };
78
+ }>>;
79
+ };
80
+ auth: {
81
+ /**
82
+ * Get current authentication context
83
+ */
84
+ whoami: () => Promise<_safercity_sdk_core.ApiResponse<{
85
+ tenantId: string | null;
86
+ environment: string;
87
+ scopes: string[];
88
+ sessionId: string;
89
+ }>>;
90
+ /**
91
+ * Check if authenticated (optional auth)
92
+ */
93
+ check: () => Promise<_safercity_sdk_core.ApiResponse<{
94
+ authenticated: boolean;
95
+ tenantId: string | null;
96
+ }>>;
97
+ };
98
+ users: {
99
+ /**
100
+ * Create user (used by tenant apps to register users)
101
+ */
102
+ create: (body: {
103
+ email?: string;
104
+ phone?: string;
105
+ firstName?: string;
106
+ lastName?: string;
107
+ metadata?: Record<string, unknown>;
108
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
109
+ id: string;
110
+ email?: string;
111
+ phone?: string;
112
+ }>>;
113
+ /**
114
+ * Get user by ID
115
+ */
116
+ get: (userId?: string) => Promise<_safercity_sdk_core.ApiResponse<{
117
+ id: string;
118
+ email?: string;
119
+ phone?: string;
120
+ firstName?: string;
121
+ lastName?: string;
122
+ status: string;
123
+ metadata?: Record<string, unknown>;
124
+ }>>;
125
+ /**
126
+ * Update user (user can update self)
127
+ */
128
+ update: (userId: string | undefined, body: {
129
+ email?: string;
130
+ phone?: string;
131
+ firstName?: string;
132
+ lastName?: string;
133
+ metadata?: Record<string, unknown>;
134
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
135
+ id: string;
136
+ }>>;
137
+ };
138
+ panics: {
139
+ /**
140
+ * Create panic
141
+ */
142
+ create: (body: {
143
+ userId?: string;
144
+ panicTypeId?: string;
145
+ latitude: number;
146
+ longitude: number;
147
+ accuracy?: number;
148
+ metadata?: Record<string, unknown>;
149
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
150
+ id: string;
151
+ status: string;
152
+ createdAt: string;
153
+ }>>;
154
+ /**
155
+ * Get panic by ID
156
+ */
157
+ get: (panicId: string, query?: {
158
+ userId?: string;
159
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
160
+ id: string;
161
+ userId: string;
162
+ status: string;
163
+ latitude: number;
164
+ longitude: number;
165
+ createdAt: string;
166
+ updatedAt?: string;
167
+ }>>;
168
+ /**
169
+ * Update panic location
170
+ */
171
+ updateLocation: (panicId: string, body: {
172
+ userId?: string;
173
+ latitude: number;
174
+ longitude: number;
175
+ accuracy?: number;
176
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
177
+ id: string;
178
+ latitude: number;
179
+ longitude: number;
180
+ }>>;
181
+ /**
182
+ * Cancel panic
183
+ */
184
+ cancel: (panicId: string, body: {
185
+ userId?: string;
186
+ reason?: string;
187
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
188
+ id: string;
189
+ status: string;
190
+ cancelledAt: string;
191
+ }>>;
192
+ /**
193
+ * Get available panic types for a user
194
+ */
195
+ types: (userId?: string) => Promise<_safercity_sdk_core.ApiResponse<{
196
+ types: Array<{
197
+ id: string;
198
+ name: string;
199
+ description?: string;
200
+ }>;
201
+ }>>;
202
+ /**
203
+ * Stream panic updates (SSE)
204
+ */
205
+ streamUpdates: (panicId: string, options?: EventSourceOptions) => AsyncIterable<ServerSentEvent>;
206
+ };
207
+ panicInformation: {
208
+ /**
209
+ * Create panic information profile
210
+ */
211
+ create: (body: {
212
+ userId?: string;
213
+ phoneNumber: string;
214
+ firstName: string;
215
+ lastName: string;
216
+ idNumber: string;
217
+ duressCode?: string;
218
+ emergencyContacts?: Array<{
219
+ name: string;
220
+ phoneNumber: string;
221
+ relationship?: string;
222
+ }>;
223
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
224
+ success: boolean;
225
+ data: PanicInformationRecord;
226
+ message: string;
227
+ }>>;
228
+ /**
229
+ * Get panic information by ID
230
+ */
231
+ get: (id: string) => Promise<_safercity_sdk_core.ApiResponse<{
232
+ success: boolean;
233
+ data: PanicInformationRecord;
234
+ }>>;
235
+ /**
236
+ * Get panic information by user ID
237
+ */
238
+ getByUser: (userId?: string) => Promise<_safercity_sdk_core.ApiResponse<{
239
+ success: boolean;
240
+ data: PanicInformationRecord;
241
+ }>>;
242
+ /**
243
+ * Update panic information
244
+ */
245
+ update: (id: string, body: {
246
+ phoneNumber?: string;
247
+ firstName?: string;
248
+ lastName?: string;
249
+ idNumber?: string;
250
+ duressCode?: string;
251
+ emergencyContacts?: Array<{
252
+ name: string;
253
+ phoneNumber: string;
254
+ relationship?: string;
255
+ }>;
256
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
257
+ success: boolean;
258
+ data: PanicInformationRecord;
259
+ message: string;
260
+ }>>;
261
+ /**
262
+ * Delete panic information
263
+ */
264
+ delete: (id: string) => Promise<_safercity_sdk_core.ApiResponse<{
265
+ success: boolean;
266
+ message: string;
267
+ }>>;
268
+ /**
269
+ * Validate user eligibility for panic services
270
+ */
271
+ validateEligibility: (userId?: string) => Promise<_safercity_sdk_core.ApiResponse<{
272
+ success: boolean;
273
+ data: {
274
+ eligible: boolean;
275
+ subscriptionActive: boolean;
276
+ profileComplete: boolean;
277
+ reasons: string[];
278
+ panicInformation: PanicInformationRecord | null;
279
+ subscriptionDetails: {
280
+ usedSeats: number;
281
+ userHasActiveSubscription: boolean;
282
+ } | null;
283
+ };
284
+ }>>;
285
+ };
286
+ subscriptions: {
287
+ /**
288
+ * List subscription types
289
+ */
290
+ listTypes: () => Promise<_safercity_sdk_core.ApiResponse<{
291
+ types: Array<{
292
+ id: string;
293
+ name: string;
294
+ description?: string;
295
+ price?: number;
296
+ }>;
297
+ }>>;
298
+ /**
299
+ * Create subscription
300
+ */
301
+ create: (body: {
302
+ userId?: string;
303
+ subscriptionTypeId: string;
304
+ status?: string;
305
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
306
+ id: string;
307
+ userId: string;
308
+ subscriptionTypeId: string;
309
+ status: string;
310
+ }>>;
311
+ /**
312
+ * List subscriptions
313
+ */
314
+ list: (query?: {
315
+ userId?: string;
316
+ status?: string;
317
+ limit?: number;
318
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
319
+ subscriptions: Array<{
320
+ id: string;
321
+ userId: string;
322
+ subscriptionTypeId: string;
323
+ status: string;
324
+ }>;
325
+ }>>;
326
+ /**
327
+ * Subscribe a user to a subscription type
328
+ */
329
+ subscribeUser: (body: {
330
+ userId?: string;
331
+ subscriptionTypeId: string;
332
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
333
+ id: string;
334
+ userId: string;
335
+ subscriptionTypeId: string;
336
+ status: string;
337
+ }>>;
338
+ };
339
+ notifications: {
340
+ /**
341
+ * Create subscriber
342
+ */
343
+ createSubscriber: (body: {
344
+ userId?: string;
345
+ email?: string;
346
+ phone?: string;
347
+ data?: Record<string, unknown>;
348
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
349
+ subscriberId: string;
350
+ }>>;
351
+ /**
352
+ * Trigger notification
353
+ */
354
+ trigger: (body: {
355
+ userId?: string;
356
+ workflowId: string;
357
+ payload?: Record<string, unknown>;
358
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
359
+ transactionId: string;
360
+ status: string;
361
+ }>>;
362
+ /**
363
+ * Bulk trigger notifications
364
+ */
365
+ bulkTrigger: (body: {
366
+ userIds: string[];
367
+ workflowId: string;
368
+ payload?: Record<string, unknown>;
369
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
370
+ transactionIds: string[];
371
+ status: string;
372
+ }>>;
373
+ /**
374
+ * Get user preferences
375
+ */
376
+ getPreferences: (userId?: string) => Promise<_safercity_sdk_core.ApiResponse<{
377
+ preferences: Record<string, unknown>;
378
+ }>>;
379
+ /**
380
+ * Update user preferences
381
+ */
382
+ updatePreferences: (userId: string | undefined, body: {
383
+ preferences: Record<string, unknown>;
384
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
385
+ success: boolean;
386
+ }>>;
387
+ };
388
+ locationSafety: {
389
+ /**
390
+ * Check location safety
391
+ */
392
+ check: (body: {
393
+ latitude: number;
394
+ longitude: number;
395
+ radius?: number;
396
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
397
+ safetyScore: number;
398
+ riskLevel: string;
399
+ factors: Array<{
400
+ type: string;
401
+ impact: number;
402
+ }>;
403
+ }>>;
404
+ };
405
+ banner: {
406
+ /**
407
+ * Get crime banner data for a location
408
+ */
409
+ get: (body: {
410
+ latitude: number;
411
+ longitude: number;
412
+ radius?: number;
413
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
414
+ success: boolean;
415
+ data: {
416
+ totalCrimes: number;
417
+ categories: Array<{
418
+ name: string;
419
+ count: number;
420
+ }>;
421
+ period: string;
422
+ };
423
+ }>>;
424
+ };
425
+ crimes: {
426
+ /**
427
+ * List crimes
428
+ */
429
+ list: (query?: {
430
+ latitude?: number;
431
+ longitude?: number;
432
+ radius?: number;
433
+ type?: string;
434
+ from?: string;
435
+ to?: string;
436
+ limit?: number;
437
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
438
+ crimes: Array<{
439
+ id: string;
440
+ type: string;
441
+ latitude: number;
442
+ longitude: number;
443
+ occurredAt: string;
444
+ }>;
445
+ }>>;
446
+ /**
447
+ * Get crime categories
448
+ */
449
+ categories: () => Promise<_safercity_sdk_core.ApiResponse<{
450
+ categories: Array<{
451
+ id: string;
452
+ name: string;
453
+ }>;
454
+ }>>;
455
+ /**
456
+ * Get crime types
457
+ */
458
+ types: () => Promise<_safercity_sdk_core.ApiResponse<{
459
+ types: Array<{
460
+ id: string;
461
+ name: string;
462
+ categoryId: string;
463
+ }>;
464
+ }>>;
465
+ /**
466
+ * Get crime categories with their types
467
+ */
468
+ categoriesWithTypes: () => Promise<_safercity_sdk_core.ApiResponse<{
469
+ categories: Array<{
470
+ id: string;
471
+ name: string;
472
+ types: Array<{
473
+ id: string;
474
+ name: string;
475
+ }>;
476
+ }>;
477
+ }>>;
478
+ };
479
+ };
480
+ type SaferCityClient = ReturnType<typeof createSaferCityClient>;
481
+
482
+ interface ServerClientConfig extends Pick<SaferCityConfig, 'baseUrl' | 'timeout' | 'fetch'> {
483
+ /**
484
+ * OAuth credentials for authentication
8
485
  */
9
- streamAdapter?: StreamAdapter;
486
+ auth: OAuthCredentials;
487
+ /**
488
+ * Custom token storage (defaults to in-memory)
489
+ */
490
+ tokenStore?: TokenStorage;
10
491
  }
11
492
  /**
12
- * Create a SaferCity API client
493
+ * Server client that wraps the base client with automatic OAuth token management
13
494
  */
14
- declare function createSaferCityClient(options: SaferCityClientOptions): {
495
+ declare class ServerClient extends BaseClient {
496
+ private tokenManager;
497
+ constructor(config: ServerClientConfig);
15
498
  /**
16
- * Access the underlying base client for custom requests
499
+ * Get a valid access token
17
500
  */
18
- _client: BaseClient;
501
+ getAccessToken(): Promise<string>;
19
502
  /**
20
- * Update authentication token
503
+ * Force refresh the token
21
504
  */
22
- setToken: (token: string | undefined) => void;
505
+ refreshToken(): Promise<string>;
23
506
  /**
24
- * Update tenant ID
507
+ * Clear stored tokens
25
508
  */
26
- setTenantId: (tenantId: string | undefined) => void;
509
+ clearTokens(): void;
27
510
  /**
28
- * Get current configuration
511
+ * Make an authenticated request
512
+ * Automatically adds the Authorization header with a valid token
29
513
  */
30
- getConfig: () => Readonly<SaferCityConfig>;
31
- health: {
32
- /**
33
- * Check API health status
34
- */
514
+ protected request<T>(method: string, path: string, options?: Parameters<BaseClient['request']>[2]): Promise<{
515
+ data: T;
516
+ status: number;
517
+ headers: Headers;
518
+ }>;
519
+ /**
520
+ * Check API health status
521
+ */
522
+ get health(): {
35
523
  check: () => Promise<_safercity_sdk_core.ApiResponse<{
36
524
  status: string;
37
525
  timestamp: string;
@@ -42,7 +530,10 @@ declare function createSaferCityClient(options: SaferCityClientOptions): {
42
530
  };
43
531
  }>>;
44
532
  };
45
- auth: {
533
+ /**
534
+ * Authentication helpers
535
+ */
536
+ get auth(): {
46
537
  /**
47
538
  * Get current authentication context
48
539
  */
@@ -60,7 +551,10 @@ declare function createSaferCityClient(options: SaferCityClientOptions): {
60
551
  tenantId: string | null;
61
552
  }>>;
62
553
  };
63
- oauth: {
554
+ /**
555
+ * OAuth helpers
556
+ */
557
+ get oauth(): {
64
558
  /**
65
559
  * Get access token
66
560
  */
@@ -107,7 +601,10 @@ declare function createSaferCityClient(options: SaferCityClientOptions): {
107
601
  success: boolean;
108
602
  }>>;
109
603
  };
110
- tenants: {
604
+ /**
605
+ * Tenant helpers
606
+ */
607
+ get tenants(): {
111
608
  /**
112
609
  * Create a new tenant
113
610
  */
@@ -134,7 +631,10 @@ declare function createSaferCityClient(options: SaferCityClientOptions): {
134
631
  cursor?: string;
135
632
  }>>;
136
633
  };
137
- credentials: {
634
+ /**
635
+ * Credential helpers
636
+ */
637
+ get credentials(): {
138
638
  /**
139
639
  * Exchange setup token for credentials
140
640
  */
@@ -163,7 +663,10 @@ declare function createSaferCityClient(options: SaferCityClientOptions): {
163
663
  success: boolean;
164
664
  }>>;
165
665
  };
166
- users: {
666
+ /**
667
+ * User helpers
668
+ */
669
+ get users(): {
167
670
  /**
168
671
  * Create user
169
672
  */
@@ -235,7 +738,10 @@ declare function createSaferCityClient(options: SaferCityClientOptions): {
235
738
  success: boolean;
236
739
  }>>;
237
740
  };
238
- panics: {
741
+ /**
742
+ * Panic helpers (streaming not available in server client)
743
+ */
744
+ get panics(): {
239
745
  /**
240
746
  * Create panic
241
747
  */
@@ -308,11 +814,20 @@ declare function createSaferCityClient(options: SaferCityClientOptions): {
308
814
  cancelledAt: string;
309
815
  }>>;
310
816
  /**
311
- * Stream panic updates (SSE)
817
+ * Get available panic types for a user
312
818
  */
313
- streamUpdates: (panicId: string, options?: EventSourceOptions) => AsyncIterable<ServerSentEvent>;
819
+ types: (userId: string) => Promise<_safercity_sdk_core.ApiResponse<{
820
+ types: Array<{
821
+ id: string;
822
+ name: string;
823
+ description?: string;
824
+ }>;
825
+ }>>;
314
826
  };
315
- subscriptions: {
827
+ /**
828
+ * Subscription helpers
829
+ */
830
+ get subscriptions(): {
316
831
  /**
317
832
  * List subscription types
318
833
  */
@@ -360,8 +875,23 @@ declare function createSaferCityClient(options: SaferCityClientOptions): {
360
875
  active: number;
361
876
  byType: Record<string, number>;
362
877
  }>>;
878
+ /**
879
+ * Subscribe a user to a subscription type
880
+ */
881
+ subscribeUser: (body: {
882
+ userId: string;
883
+ subscriptionTypeId: string;
884
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
885
+ id: string;
886
+ userId: string;
887
+ subscriptionTypeId: string;
888
+ status: string;
889
+ }>>;
363
890
  };
364
- notifications: {
891
+ /**
892
+ * Notification helpers
893
+ */
894
+ get notifications(): {
365
895
  /**
366
896
  * Create subscriber
367
897
  */
@@ -384,6 +914,17 @@ declare function createSaferCityClient(options: SaferCityClientOptions): {
384
914
  transactionId: string;
385
915
  status: string;
386
916
  }>>;
917
+ /**
918
+ * Bulk trigger notifications
919
+ */
920
+ bulkTrigger: (body: {
921
+ userIds: string[];
922
+ workflowId: string;
923
+ payload?: Record<string, unknown>;
924
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
925
+ transactionIds: string[];
926
+ status: string;
927
+ }>>;
387
928
  /**
388
929
  * Get user preferences
389
930
  */
@@ -399,11 +940,113 @@ declare function createSaferCityClient(options: SaferCityClientOptions): {
399
940
  success: boolean;
400
941
  }>>;
401
942
  };
402
- locationSafety: {
943
+ /**
944
+ * Panic information helpers
945
+ */
946
+ get panicInformation(): {
947
+ /**
948
+ * Create panic information profile
949
+ */
950
+ create: (body: {
951
+ userId: string;
952
+ phoneNumber: string;
953
+ firstName: string;
954
+ lastName: string;
955
+ idNumber: string;
956
+ duressCode?: string;
957
+ emergencyContacts?: Array<{
958
+ name: string;
959
+ phoneNumber: string;
960
+ relationship?: string;
961
+ }>;
962
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
963
+ success: boolean;
964
+ data: PanicInformationRecord;
965
+ message: string;
966
+ }>>;
967
+ /**
968
+ * List panic information records
969
+ */
970
+ list: (query?: {
971
+ limit?: number;
972
+ offset?: number;
973
+ userId?: string;
974
+ idNumber?: string;
975
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
976
+ success: boolean;
977
+ data: PanicInformationRecord[];
978
+ pagination: {
979
+ limit: number;
980
+ offset: number;
981
+ hasMore: boolean;
982
+ };
983
+ }>>;
984
+ /**
985
+ * Get panic information by ID
986
+ */
987
+ get: (id: string) => Promise<_safercity_sdk_core.ApiResponse<{
988
+ success: boolean;
989
+ data: PanicInformationRecord;
990
+ }>>;
991
+ /**
992
+ * Get panic information by user ID
993
+ */
994
+ getByUser: (userId: string) => Promise<_safercity_sdk_core.ApiResponse<{
995
+ success: boolean;
996
+ data: PanicInformationRecord;
997
+ }>>;
998
+ /**
999
+ * Update panic information
1000
+ */
1001
+ update: (id: string, body: {
1002
+ phoneNumber?: string;
1003
+ firstName?: string;
1004
+ lastName?: string;
1005
+ idNumber?: string;
1006
+ duressCode?: string;
1007
+ emergencyContacts?: Array<{
1008
+ name: string;
1009
+ phoneNumber: string;
1010
+ relationship?: string;
1011
+ }>;
1012
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
1013
+ success: boolean;
1014
+ data: PanicInformationRecord;
1015
+ message: string;
1016
+ }>>;
1017
+ /**
1018
+ * Delete panic information
1019
+ */
1020
+ delete: (id: string) => Promise<_safercity_sdk_core.ApiResponse<{
1021
+ success: boolean;
1022
+ message: string;
1023
+ }>>;
1024
+ /**
1025
+ * Validate user eligibility for panic services
1026
+ */
1027
+ validateEligibility: (userId: string) => Promise<_safercity_sdk_core.ApiResponse<{
1028
+ success: boolean;
1029
+ data: {
1030
+ eligible: boolean;
1031
+ subscriptionActive: boolean;
1032
+ profileComplete: boolean;
1033
+ reasons: string[];
1034
+ panicInformation: PanicInformationRecord | null;
1035
+ subscriptionDetails: {
1036
+ usedSeats: number;
1037
+ userHasActiveSubscription: boolean;
1038
+ } | null;
1039
+ };
1040
+ }>>;
1041
+ };
1042
+ /**
1043
+ * Location safety helpers
1044
+ */
1045
+ get locationSafety(): {
403
1046
  /**
404
1047
  * Check location safety
405
1048
  */
406
- check: (query: {
1049
+ check: (body: {
407
1050
  latitude: number;
408
1051
  longitude: number;
409
1052
  radius?: number;
@@ -416,7 +1059,33 @@ declare function createSaferCityClient(options: SaferCityClientOptions): {
416
1059
  }>;
417
1060
  }>>;
418
1061
  };
419
- crimes: {
1062
+ /**
1063
+ * Banner helpers
1064
+ */
1065
+ get banner(): {
1066
+ /**
1067
+ * Get crime banner data for a location
1068
+ */
1069
+ get: (body: {
1070
+ latitude: number;
1071
+ longitude: number;
1072
+ radius?: number;
1073
+ }) => Promise<_safercity_sdk_core.ApiResponse<{
1074
+ success: boolean;
1075
+ data: {
1076
+ totalCrimes: number;
1077
+ categories: Array<{
1078
+ name: string;
1079
+ count: number;
1080
+ }>;
1081
+ period: string;
1082
+ };
1083
+ }>>;
1084
+ };
1085
+ /**
1086
+ * Crime helpers
1087
+ */
1088
+ get crimes(): {
420
1089
  /**
421
1090
  * List crimes
422
1091
  */
@@ -456,68 +1125,20 @@ declare function createSaferCityClient(options: SaferCityClientOptions): {
456
1125
  categoryId: string;
457
1126
  }>;
458
1127
  }>>;
1128
+ /**
1129
+ * Get crime categories with their types
1130
+ */
1131
+ categoriesWithTypes: () => Promise<_safercity_sdk_core.ApiResponse<{
1132
+ categories: Array<{
1133
+ id: string;
1134
+ name: string;
1135
+ types: Array<{
1136
+ id: string;
1137
+ name: string;
1138
+ }>;
1139
+ }>;
1140
+ }>>;
459
1141
  };
460
- };
461
- type SaferCityClient = ReturnType<typeof createSaferCityClient>;
462
-
463
- /**
464
- * Server-side SaferCity Client
465
- *
466
- * For backend applications that need to authenticate with OAuth client credentials.
467
- * Handles automatic token management and refresh.
468
- */
469
-
470
- interface ServerClientConfig {
471
- /**
472
- * SaferCity API base URL
473
- * @default "https://api.safercity.com"
474
- */
475
- baseUrl?: string;
476
- /**
477
- * OAuth credentials for authentication
478
- */
479
- auth: OAuthCredentials;
480
- /**
481
- * Custom token storage (defaults to in-memory)
482
- */
483
- tokenStore?: TokenStorage;
484
- /**
485
- * Request timeout in milliseconds
486
- * @default 30000
487
- */
488
- timeout?: number;
489
- /**
490
- * Custom fetch implementation
491
- */
492
- fetch?: typeof fetch;
493
- }
494
- /**
495
- * Server client that wraps the base client with automatic OAuth token management
496
- */
497
- declare class ServerClient extends BaseClient {
498
- private tokenManager;
499
- constructor(config: ServerClientConfig);
500
- /**
501
- * Get a valid access token
502
- */
503
- getAccessToken(): Promise<string>;
504
- /**
505
- * Force refresh the token
506
- */
507
- refreshToken(): Promise<string>;
508
- /**
509
- * Clear stored tokens
510
- */
511
- clearTokens(): void;
512
- /**
513
- * Make an authenticated request
514
- * Automatically adds the Authorization header with a valid token
515
- */
516
- protected request<T>(method: string, path: string, options?: Parameters<BaseClient['request']>[2]): Promise<{
517
- data: T;
518
- status: number;
519
- headers: Headers;
520
- }>;
521
1142
  }
522
1143
  /**
523
1144
  * Create a server-side SaferCity client with automatic OAuth token management
@@ -544,6 +1165,10 @@ declare function createServerClient(config: ServerClientConfig): ServerClient;
544
1165
  * with automatic tenant authentication.
545
1166
  */
546
1167
 
1168
+ type EndpointPattern = string | {
1169
+ method?: string;
1170
+ path: string;
1171
+ };
547
1172
  interface ProxyConfig {
548
1173
  /**
549
1174
  * OAuth client ID
@@ -580,6 +1205,14 @@ interface ProxyConfig {
580
1205
  * Custom fetch implementation
581
1206
  */
582
1207
  fetch?: typeof fetch;
1208
+ /**
1209
+ * Explicitly allowed endpoints for proxy forwarding
1210
+ */
1211
+ allowedEndpoints?: EndpointPattern[];
1212
+ /**
1213
+ * Explicitly blocked endpoints for proxy forwarding
1214
+ */
1215
+ blockedEndpoints?: EndpointPattern[];
583
1216
  }
584
1217
  /**
585
1218
  * Create a Next.js App Router handler for proxying SaferCity API requests
@@ -674,4 +1307,4 @@ declare function createProxyHandler(config: ProxyConfig): (request: {
674
1307
  body: unknown;
675
1308
  }>;
676
1309
 
677
- export { type ProxyConfig, type SaferCityClient, type SaferCityClientOptions, ServerClient, type ServerClientConfig, createExpressMiddleware, createNextHandler, createProxyHandler, createSaferCityClient, createServerClient };
1310
+ export { type EndpointPattern, type PanicInformationRecord, type ProxyConfig, type SaferCityClient, type SaferCityClientOptions, ServerClient, type ServerClientConfig, createExpressMiddleware, createNextHandler, createProxyHandler, createSaferCityClient, createServerClient };