een-api-toolkit 0.0.5

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.
@@ -0,0 +1,947 @@
1
+ import { ComputedRef } from 'vue';
2
+ import { Ref } from 'vue';
3
+ import { StoreDefinition } from 'pinia';
4
+
5
+ /**
6
+ * Error object returned when an operation fails.
7
+ *
8
+ * @remarks
9
+ * Contains structured error information including a machine-readable code,
10
+ * human-readable message, and optional HTTP status code.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const { error } = await getUsers()
15
+ * if (error) {
16
+ * console.error(`${error.code}: ${error.message}`)
17
+ * if (error.status === 401) {
18
+ * redirectToLogin()
19
+ * }
20
+ * }
21
+ * ```
22
+ *
23
+ * @category Types
24
+ */
25
+ export declare interface EenError {
26
+ /** Machine-readable error code for programmatic handling */
27
+ code: ErrorCode;
28
+ /** Human-readable error message */
29
+ message: string;
30
+ /** HTTP status code if the error came from an API response */
31
+ status?: number;
32
+ /** Additional error details (varies by error type) */
33
+ details?: unknown;
34
+ }
35
+
36
+ /**
37
+ * Configuration for initializing the toolkit.
38
+ *
39
+ * @remarks
40
+ * Pass this to {@link initEenToolkit} to configure the library. All options
41
+ * can also be set via environment variables (VITE_PROXY_URL, VITE_EEN_CLIENT_ID,
42
+ * VITE_REDIRECT_URI, VITE_DEBUG).
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * import { initEenToolkit } from 'een-api-toolkit'
47
+ *
48
+ * initEenToolkit({
49
+ * proxyUrl: 'https://your-proxy.workers.dev',
50
+ * clientId: 'your-een-client-id',
51
+ * redirectUri: 'http://localhost:5173/callback',
52
+ * debug: true
53
+ * })
54
+ * ```
55
+ *
56
+ * @category Configuration
57
+ */
58
+ export declare interface EenToolkitConfig {
59
+ /** URL of the OAuth proxy server (required for API calls) */
60
+ proxyUrl?: string;
61
+ /** EEN OAuth client ID (required for authentication) */
62
+ clientId?: string;
63
+ /** OAuth redirect URI (default: http://127.0.0.1:3333) */
64
+ redirectUri?: string;
65
+ /** Enable debug logging to console */
66
+ debug?: boolean;
67
+ }
68
+
69
+ /**
70
+ * Error codes returned by the toolkit.
71
+ *
72
+ * @remarks
73
+ * All API functions return a {@link Result} type that contains either data or an error.
74
+ * The error code helps you determine how to handle the failure.
75
+ *
76
+ * @category Types
77
+ */
78
+ export declare type ErrorCode = 'AUTH_REQUIRED' | 'AUTH_FAILED' | 'TOKEN_EXPIRED' | 'API_ERROR' | 'NETWORK_ERROR' | 'VALIDATION_ERROR' | 'NOT_FOUND' | 'FORBIDDEN' | 'RATE_LIMITED' | 'UNKNOWN_ERROR';
79
+
80
+ /* Excluded from this release type: failure */
81
+
82
+ /**
83
+ * Exchange authorization code for access token
84
+ */
85
+ export declare function getAccessToken(code: string): Promise<Result<TokenResponse>>;
86
+
87
+ /**
88
+ * Generate the OAuth authorization URL
89
+ */
90
+ export declare function getAuthUrl(): string;
91
+
92
+ /**
93
+ * Get the client ID
94
+ */
95
+ export declare function getClientId(): string | undefined;
96
+
97
+ /**
98
+ * Get the current configuration
99
+ */
100
+ export declare function getConfig(): EenToolkitConfig;
101
+
102
+ /**
103
+ * Get the current authenticated user's profile.
104
+ *
105
+ * @remarks
106
+ * Fetches the profile of the currently authenticated user from `/api/v3.0/users/self`.
107
+ * The result is also stored in the auth store for easy access via `useAuthStore().userProfile`.
108
+ *
109
+ * @returns A Result containing the user profile or an error
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * import { getCurrentUser } from 'een-api-toolkit'
114
+ *
115
+ * const { data, error } = await getCurrentUser()
116
+ *
117
+ * if (error) {
118
+ * if (error.code === 'AUTH_REQUIRED') {
119
+ * router.push('/login')
120
+ * }
121
+ * return
122
+ * }
123
+ *
124
+ * console.log(`Welcome, ${data.firstName} ${data.lastName}`)
125
+ * ```
126
+ *
127
+ * @category Users
128
+ */
129
+ export declare function getCurrentUser(): Promise<Result<UserProfile>>;
130
+
131
+ /**
132
+ * Get the proxy URL
133
+ */
134
+ export declare function getProxyUrl(): string | undefined;
135
+
136
+ /**
137
+ * Get the redirect URI
138
+ */
139
+ export declare function getRedirectUri(): string;
140
+
141
+ /**
142
+ * Get a specific user by ID.
143
+ *
144
+ * @remarks
145
+ * Fetches a single user from `/api/v3.0/users/{userId}`. Use the `include`
146
+ * parameter to request additional fields like permissions.
147
+ *
148
+ * For more details, see the
149
+ * [EEN API Documentation](https://developer.eagleeyenetworks.com/reference/getuser).
150
+ *
151
+ * @param userId - The unique identifier of the user to fetch
152
+ * @param params - Optional parameters (e.g., include additional fields)
153
+ * @returns A Result containing the user or an error
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * import { getUser } from 'een-api-toolkit'
158
+ *
159
+ * const { data, error } = await getUser('user-123')
160
+ *
161
+ * if (error) {
162
+ * if (error.code === 'NOT_FOUND') {
163
+ * console.log('User not found')
164
+ * }
165
+ * return
166
+ * }
167
+ *
168
+ * console.log(`User: ${data.firstName} ${data.lastName}`)
169
+ *
170
+ * // With permissions
171
+ * const { data: userWithPerms } = await getUser('user-123', {
172
+ * include: ['permissions']
173
+ * })
174
+ * console.log('Permissions:', userWithPerms?.permissions)
175
+ * ```
176
+ *
177
+ * @category Users
178
+ */
179
+ export declare function getUser(userId: string, params?: GetUserParams): Promise<Result<User>>;
180
+
181
+ /**
182
+ * Parameters for getting a single user.
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * const { data } = await getUser('user-id', {
187
+ * include: ['permissions']
188
+ * })
189
+ * ```
190
+ *
191
+ * @category Users
192
+ */
193
+ export declare interface GetUserParams {
194
+ /** Additional fields to include in the response */
195
+ include?: string[];
196
+ }
197
+
198
+ /**
199
+ * List users with optional pagination and filtering.
200
+ *
201
+ * @remarks
202
+ * Fetches a paginated list of users from `/api/v3.0/users`. Use the `pageSize`
203
+ * parameter to control how many results are returned per page, and `pageToken`
204
+ * to navigate to subsequent pages.
205
+ *
206
+ * For more details, see the
207
+ * [EEN API Documentation](https://developer.eagleeyenetworks.com/reference/listusers).
208
+ *
209
+ * @param params - Optional pagination and filtering parameters
210
+ * @returns A Result containing a paginated list of users or an error
211
+ *
212
+ * @example
213
+ * ```typescript
214
+ * import { getUsers } from 'een-api-toolkit'
215
+ *
216
+ * // Basic usage
217
+ * const { data, error } = await getUsers()
218
+ * if (data) {
219
+ * console.log(`Found ${data.results.length} users`)
220
+ * }
221
+ *
222
+ * // With pagination
223
+ * const { data } = await getUsers({ pageSize: 50 })
224
+ * if (data?.nextPageToken) {
225
+ * const { data: page2 } = await getUsers({
226
+ * pageSize: 50,
227
+ * pageToken: data.nextPageToken
228
+ * })
229
+ * }
230
+ *
231
+ * // Fetch all users
232
+ * let allUsers: User[] = []
233
+ * let pageToken: string | undefined
234
+ * do {
235
+ * const { data, error } = await getUsers({ pageSize: 100, pageToken })
236
+ * if (error) break
237
+ * allUsers.push(...data.results)
238
+ * pageToken = data.nextPageToken
239
+ * } while (pageToken)
240
+ * ```
241
+ *
242
+ * @category Users
243
+ */
244
+ export declare function getUsers(params?: ListUsersParams): Promise<Result<PaginatedResult<User>>>;
245
+
246
+ /**
247
+ * Handle OAuth callback - validates state and exchanges code for token
248
+ */
249
+ export declare function handleAuthCallback(code: string, state: string): Promise<Result<TokenResponse>>;
250
+
251
+ /**
252
+ * Initialize the EEN API Toolkit
253
+ */
254
+ export declare function initEenToolkit(options?: EenToolkitConfig): void;
255
+
256
+ /**
257
+ * Parameters for listing users.
258
+ *
259
+ * @remarks
260
+ * Extends basic pagination with user-specific options like the `include`
261
+ * parameter for requesting additional user data.
262
+ *
263
+ * @example
264
+ * ```typescript
265
+ * // Get users with permissions included
266
+ * const { data } = await getUsers({
267
+ * pageSize: 50,
268
+ * include: ['permissions']
269
+ * })
270
+ * ```
271
+ *
272
+ * @category Users
273
+ */
274
+ export declare interface ListUsersParams {
275
+ /** Number of results per page (default: 100, max: 1000) */
276
+ pageSize?: number;
277
+ /** Token for fetching a specific page */
278
+ pageToken?: string;
279
+ /** Additional fields to include in the response (e.g., ['permissions']) */
280
+ include?: string[];
281
+ }
282
+
283
+ /**
284
+ * Paginated response from list operations.
285
+ *
286
+ * @remarks
287
+ * Contains the results array and optional pagination tokens for navigating
288
+ * through large result sets.
289
+ *
290
+ * @typeParam T - The type of items in the results array
291
+ * @category Types
292
+ */
293
+ export declare interface PaginatedResult<T> {
294
+ /** Array of items for this page */
295
+ results: T[];
296
+ /** Token to fetch the next page (undefined if no more pages) */
297
+ nextPageToken?: string;
298
+ /** Token to fetch the previous page (undefined if on first page) */
299
+ prevPageToken?: string;
300
+ /** Total number of items across all pages (may not be provided by all endpoints) */
301
+ totalSize?: number;
302
+ }
303
+
304
+ /**
305
+ * Pagination parameters for list operations.
306
+ *
307
+ * @remarks
308
+ * Most list APIs in the EEN platform support pagination. Use `pageSize` to
309
+ * control how many results are returned, and `pageToken` to fetch subsequent pages.
310
+ *
311
+ * @example
312
+ * ```typescript
313
+ * // First page
314
+ * const { data } = await getUsers({ pageSize: 50 })
315
+ *
316
+ * // Next page (if available)
317
+ * if (data.nextPageToken) {
318
+ * const { data: page2 } = await getUsers({
319
+ * pageSize: 50,
320
+ * pageToken: data.nextPageToken
321
+ * })
322
+ * }
323
+ * ```
324
+ *
325
+ * @category Types
326
+ */
327
+ export declare interface PaginationParams {
328
+ /** Number of results per page (default varies by endpoint, typically 100) */
329
+ pageSize?: number;
330
+ /** Token for fetching a specific page (from previous response's nextPageToken) */
331
+ pageToken?: string;
332
+ }
333
+
334
+ /**
335
+ * Refresh the access token using stored refresh token
336
+ */
337
+ export declare function refreshToken(): Promise<Result<{
338
+ accessToken: string;
339
+ expiresIn: number;
340
+ }>>;
341
+
342
+ /**
343
+ * Result type for all API operations - functions never throw exceptions.
344
+ *
345
+ * @remarks
346
+ * This is a discriminated union type. When `error` is `null`, `data` contains
347
+ * the successful result. When `error` is not `null`, `data` is `null`.
348
+ * TypeScript will narrow the type correctly after checking for errors.
349
+ *
350
+ * @example
351
+ * ```typescript
352
+ * const { data, error } = await getUsers()
353
+ *
354
+ * if (error) {
355
+ * // TypeScript knows: data is null, error is EenError
356
+ * console.error(error.message)
357
+ * return
358
+ * }
359
+ *
360
+ * // TypeScript knows: data is not null, error is null
361
+ * console.log(data.results)
362
+ * ```
363
+ *
364
+ * @typeParam T - The type of the data on success
365
+ * @category Types
366
+ */
367
+ export declare type Result<T> = {
368
+ data: T;
369
+ error: null;
370
+ } | {
371
+ data: null;
372
+ error: EenError;
373
+ };
374
+
375
+ /**
376
+ * Revoke the current token and logout
377
+ */
378
+ export declare function revokeToken(): Promise<Result<void>>;
379
+
380
+ /* Excluded from this release type: success */
381
+
382
+ /**
383
+ * Token response from the OAuth proxy.
384
+ *
385
+ * @remarks
386
+ * This is the response returned by the proxy's `/proxy/getAccessToken` endpoint
387
+ * after successfully exchanging an authorization code for an access token.
388
+ *
389
+ * @category Authentication
390
+ */
391
+ export declare interface TokenResponse {
392
+ accessToken: string;
393
+ expiresIn: number;
394
+ httpsBaseUrl: string | {
395
+ hostname: string;
396
+ port?: number;
397
+ };
398
+ userEmail: string;
399
+ sessionId: string;
400
+ }
401
+
402
+ /**
403
+ * Pinia store for authentication state management
404
+ */
405
+ export declare const useAuthStore: StoreDefinition<"een-auth", Pick<{
406
+ token: Ref<string | null, string | null>;
407
+ tokenExpiration: Ref<number | null, number | null>;
408
+ refreshTokenMarker: Ref<string | null, string | null>;
409
+ sessionId: Ref<string | null, string | null>;
410
+ hostname: Ref<string | null, string | null>;
411
+ port: Ref<number, number>;
412
+ userProfile: Ref< {
413
+ id: string;
414
+ email: string;
415
+ firstName: string;
416
+ lastName: string;
417
+ accountId?: string | undefined;
418
+ timeZone?: string | undefined;
419
+ language?: string | undefined;
420
+ } | null, UserProfile | {
421
+ id: string;
422
+ email: string;
423
+ firstName: string;
424
+ lastName: string;
425
+ accountId?: string | undefined;
426
+ timeZone?: string | undefined;
427
+ language?: string | undefined;
428
+ } | null>;
429
+ isRefreshing: Ref<boolean, boolean>;
430
+ refreshFailed: Ref<boolean, boolean>;
431
+ refreshFailedMessage: Ref<string | null, string | null>;
432
+ isAuthenticated: ComputedRef<boolean>;
433
+ baseUrl: ComputedRef<string | null>;
434
+ isTokenExpired: ComputedRef<boolean>;
435
+ tokenExpiresIn: ComputedRef<number>;
436
+ setToken: (newToken: string, expiresIn: number) => void;
437
+ setRefreshTokenMarker: (marker: string) => void;
438
+ setSessionId: (newSessionId: string) => void;
439
+ setBaseUrl: (data: string | {
440
+ hostname: string;
441
+ port?: number;
442
+ }) => void;
443
+ setUserProfile: (profile: UserProfile) => void;
444
+ setupAutoRefresh: () => void;
445
+ clearRefreshFailed: () => void;
446
+ logout: () => void;
447
+ initialize: () => void;
448
+ }, "token" | "tokenExpiration" | "refreshTokenMarker" | "sessionId" | "hostname" | "port" | "userProfile" | "isRefreshing" | "refreshFailed" | "refreshFailedMessage">, Pick<{
449
+ token: Ref<string | null, string | null>;
450
+ tokenExpiration: Ref<number | null, number | null>;
451
+ refreshTokenMarker: Ref<string | null, string | null>;
452
+ sessionId: Ref<string | null, string | null>;
453
+ hostname: Ref<string | null, string | null>;
454
+ port: Ref<number, number>;
455
+ userProfile: Ref< {
456
+ id: string;
457
+ email: string;
458
+ firstName: string;
459
+ lastName: string;
460
+ accountId?: string | undefined;
461
+ timeZone?: string | undefined;
462
+ language?: string | undefined;
463
+ } | null, UserProfile | {
464
+ id: string;
465
+ email: string;
466
+ firstName: string;
467
+ lastName: string;
468
+ accountId?: string | undefined;
469
+ timeZone?: string | undefined;
470
+ language?: string | undefined;
471
+ } | null>;
472
+ isRefreshing: Ref<boolean, boolean>;
473
+ refreshFailed: Ref<boolean, boolean>;
474
+ refreshFailedMessage: Ref<string | null, string | null>;
475
+ isAuthenticated: ComputedRef<boolean>;
476
+ baseUrl: ComputedRef<string | null>;
477
+ isTokenExpired: ComputedRef<boolean>;
478
+ tokenExpiresIn: ComputedRef<number>;
479
+ setToken: (newToken: string, expiresIn: number) => void;
480
+ setRefreshTokenMarker: (marker: string) => void;
481
+ setSessionId: (newSessionId: string) => void;
482
+ setBaseUrl: (data: string | {
483
+ hostname: string;
484
+ port?: number;
485
+ }) => void;
486
+ setUserProfile: (profile: UserProfile) => void;
487
+ setupAutoRefresh: () => void;
488
+ clearRefreshFailed: () => void;
489
+ logout: () => void;
490
+ initialize: () => void;
491
+ }, "isAuthenticated" | "baseUrl" | "isTokenExpired" | "tokenExpiresIn">, Pick<{
492
+ token: Ref<string | null, string | null>;
493
+ tokenExpiration: Ref<number | null, number | null>;
494
+ refreshTokenMarker: Ref<string | null, string | null>;
495
+ sessionId: Ref<string | null, string | null>;
496
+ hostname: Ref<string | null, string | null>;
497
+ port: Ref<number, number>;
498
+ userProfile: Ref< {
499
+ id: string;
500
+ email: string;
501
+ firstName: string;
502
+ lastName: string;
503
+ accountId?: string | undefined;
504
+ timeZone?: string | undefined;
505
+ language?: string | undefined;
506
+ } | null, UserProfile | {
507
+ id: string;
508
+ email: string;
509
+ firstName: string;
510
+ lastName: string;
511
+ accountId?: string | undefined;
512
+ timeZone?: string | undefined;
513
+ language?: string | undefined;
514
+ } | null>;
515
+ isRefreshing: Ref<boolean, boolean>;
516
+ refreshFailed: Ref<boolean, boolean>;
517
+ refreshFailedMessage: Ref<string | null, string | null>;
518
+ isAuthenticated: ComputedRef<boolean>;
519
+ baseUrl: ComputedRef<string | null>;
520
+ isTokenExpired: ComputedRef<boolean>;
521
+ tokenExpiresIn: ComputedRef<number>;
522
+ setToken: (newToken: string, expiresIn: number) => void;
523
+ setRefreshTokenMarker: (marker: string) => void;
524
+ setSessionId: (newSessionId: string) => void;
525
+ setBaseUrl: (data: string | {
526
+ hostname: string;
527
+ port?: number;
528
+ }) => void;
529
+ setUserProfile: (profile: UserProfile) => void;
530
+ setupAutoRefresh: () => void;
531
+ clearRefreshFailed: () => void;
532
+ logout: () => void;
533
+ initialize: () => void;
534
+ }, "setToken" | "setRefreshTokenMarker" | "setSessionId" | "setBaseUrl" | "setUserProfile" | "setupAutoRefresh" | "clearRefreshFailed" | "logout" | "initialize">>;
535
+
536
+ /**
537
+ * Vue 3 composable for getting the current authenticated user.
538
+ *
539
+ * @remarks
540
+ * Provides reactive access to the current user's profile with automatic
541
+ * fetching on component mount (configurable via options).
542
+ *
543
+ * @param options - Configuration options
544
+ * @returns Reactive user state and control functions
545
+ *
546
+ * @example
547
+ * ```vue
548
+ * <script setup>
549
+ * import { useCurrentUser } from 'een-api-toolkit'
550
+ *
551
+ * const { user, loading, error, refresh } = useCurrentUser()
552
+ * </script>
553
+ *
554
+ * <template>
555
+ * <div v-if="loading">Loading...</div>
556
+ * <div v-else-if="error">Error: {{ error.message }}</div>
557
+ * <div v-else-if="user">
558
+ * <h1>Welcome, {{ user.firstName }}!</h1>
559
+ * <p>Email: {{ user.email }}</p>
560
+ * <button @click="refresh">Refresh</button>
561
+ * </div>
562
+ * </template>
563
+ * ```
564
+ *
565
+ * @example
566
+ * ```typescript
567
+ * // Manual fetch (don't fetch on mount)
568
+ * const { user, fetch } = useCurrentUser({ immediate: false })
569
+ *
570
+ * onMounted(async () => {
571
+ * if (someCondition) {
572
+ * await fetch()
573
+ * }
574
+ * })
575
+ * ```
576
+ *
577
+ * @category Users
578
+ */
579
+ export declare function useCurrentUser(options?: UseCurrentUserOptions): {
580
+ user: Ref< {
581
+ id: string;
582
+ email: string;
583
+ firstName: string;
584
+ lastName: string;
585
+ accountId?: string | undefined;
586
+ timeZone?: string | undefined;
587
+ language?: string | undefined;
588
+ } | null, UserProfile | {
589
+ id: string;
590
+ email: string;
591
+ firstName: string;
592
+ lastName: string;
593
+ accountId?: string | undefined;
594
+ timeZone?: string | undefined;
595
+ language?: string | undefined;
596
+ } | null>;
597
+ loading: Ref<boolean, boolean>;
598
+ error: Ref< {
599
+ code: ErrorCode;
600
+ message: string;
601
+ status?: number | undefined;
602
+ details?: unknown;
603
+ } | null, EenError | {
604
+ code: ErrorCode;
605
+ message: string;
606
+ status?: number | undefined;
607
+ details?: unknown;
608
+ } | null>;
609
+ fetch: () => Promise<Result<UserProfile>>;
610
+ refresh: () => Promise<Result<UserProfile>>;
611
+ };
612
+
613
+ /**
614
+ * Options for the useCurrentUser composable.
615
+ *
616
+ * @category Users
617
+ */
618
+ export declare interface UseCurrentUserOptions {
619
+ /**
620
+ * Whether to fetch the user immediately on mount.
621
+ * @defaultValue true
622
+ */
623
+ immediate?: boolean;
624
+ }
625
+
626
+ /**
627
+ * User entity from EEN API v3.0.
628
+ *
629
+ * @remarks
630
+ * Represents a user in the Eagle Eye Networks platform. Users belong to accounts
631
+ * and have various permissions that control their access to cameras and features.
632
+ *
633
+ * For more details on user management, see the
634
+ * [EEN API Documentation](https://developer.eagleeyenetworks.com/reference/listusers).
635
+ *
636
+ * @category Users
637
+ */
638
+ export declare interface User {
639
+ /** Unique identifier for the user */
640
+ id: string;
641
+ /** User's email address (used for login) */
642
+ email: string;
643
+ /** User's first name */
644
+ firstName: string;
645
+ /** User's last name */
646
+ lastName: string;
647
+ /** ID of the account this user belongs to */
648
+ accountId?: string;
649
+ /** User's timezone (IANA timezone name, e.g., "America/Los_Angeles") */
650
+ timeZone?: string;
651
+ /** User's preferred language (ISO 639-1 code, e.g., "en") */
652
+ language?: string;
653
+ /** User's phone number */
654
+ phone?: string;
655
+ /** User's mobile phone number */
656
+ mobilePhone?: string;
657
+ /** List of permission strings assigned to this user */
658
+ permissions?: string[];
659
+ /** ISO 8601 timestamp of the user's last login */
660
+ lastLogin?: string;
661
+ /** Whether the user account is active */
662
+ isActive?: boolean;
663
+ /** ISO 8601 timestamp when the user was created */
664
+ createdAt?: string;
665
+ /** ISO 8601 timestamp when the user was last updated */
666
+ updatedAt?: string;
667
+ }
668
+
669
+ /**
670
+ * Current authenticated user profile.
671
+ *
672
+ * @remarks
673
+ * A subset of user information returned for the currently authenticated user.
674
+ * This is returned by {@link getCurrentUser} and stored in the auth store.
675
+ *
676
+ * @category Users
677
+ */
678
+ export declare interface UserProfile {
679
+ /** Unique identifier for the user */
680
+ id: string;
681
+ /** User's email address */
682
+ email: string;
683
+ /** User's first name */
684
+ firstName: string;
685
+ /** User's last name */
686
+ lastName: string;
687
+ /** ID of the account this user belongs to */
688
+ accountId?: string;
689
+ /** User's timezone */
690
+ timeZone?: string;
691
+ /** User's preferred language */
692
+ language?: string;
693
+ }
694
+
695
+ /**
696
+ * Vue 3 composable for getting a single user by ID.
697
+ *
698
+ * @remarks
699
+ * Provides reactive access to a specific user. The user ID can be provided
700
+ * as a string or a getter function (useful for reactive route params).
701
+ *
702
+ * @param userId - The user ID (string or getter function)
703
+ * @param options - Configuration options
704
+ * @returns Reactive user state and control functions
705
+ *
706
+ * @example
707
+ * ```vue
708
+ * <script setup>
709
+ * import { useUser } from 'een-api-toolkit'
710
+ * import { useRoute } from 'vue-router'
711
+ *
712
+ * const route = useRoute()
713
+ *
714
+ * // Static ID
715
+ * const { user, loading, error } = useUser('user-123')
716
+ *
717
+ * // Or reactive ID from route
718
+ * const { user: routeUser } = useUser(() => route.params.id as string)
719
+ * </script>
720
+ *
721
+ * <template>
722
+ * <div v-if="loading">Loading...</div>
723
+ * <div v-else-if="error">Error: {{ error.message }}</div>
724
+ * <div v-else-if="user">
725
+ * <h1>{{ user.firstName }} {{ user.lastName }}</h1>
726
+ * <p>Email: {{ user.email }}</p>
727
+ * </div>
728
+ * </template>
729
+ * ```
730
+ *
731
+ * @example
732
+ * ```typescript
733
+ * // With additional fields
734
+ * const { user } = useUser('user-123', {
735
+ * include: ['permissions']
736
+ * })
737
+ *
738
+ * // Access permissions when loaded
739
+ * watchEffect(() => {
740
+ * if (user.value?.permissions) {
741
+ * console.log('User permissions:', user.value.permissions)
742
+ * }
743
+ * })
744
+ * ```
745
+ *
746
+ * @category Users
747
+ */
748
+ export declare function useUser(userId: string | (() => string), options?: UseUserOptions): {
749
+ user: Ref< {
750
+ id: string;
751
+ email: string;
752
+ firstName: string;
753
+ lastName: string;
754
+ accountId?: string | undefined;
755
+ timeZone?: string | undefined;
756
+ language?: string | undefined;
757
+ phone?: string | undefined;
758
+ mobilePhone?: string | undefined;
759
+ permissions?: string[] | undefined;
760
+ lastLogin?: string | undefined;
761
+ isActive?: boolean | undefined;
762
+ createdAt?: string | undefined;
763
+ updatedAt?: string | undefined;
764
+ } | null, User | {
765
+ id: string;
766
+ email: string;
767
+ firstName: string;
768
+ lastName: string;
769
+ accountId?: string | undefined;
770
+ timeZone?: string | undefined;
771
+ language?: string | undefined;
772
+ phone?: string | undefined;
773
+ mobilePhone?: string | undefined;
774
+ permissions?: string[] | undefined;
775
+ lastLogin?: string | undefined;
776
+ isActive?: boolean | undefined;
777
+ createdAt?: string | undefined;
778
+ updatedAt?: string | undefined;
779
+ } | null>;
780
+ loading: Ref<boolean, boolean>;
781
+ error: Ref< {
782
+ code: ErrorCode;
783
+ message: string;
784
+ status?: number | undefined;
785
+ details?: unknown;
786
+ } | null, EenError | {
787
+ code: ErrorCode;
788
+ message: string;
789
+ status?: number | undefined;
790
+ details?: unknown;
791
+ } | null>;
792
+ fetch: (params?: GetUserParams) => Promise<Result<User>>;
793
+ refresh: () => Promise<Result<User>>;
794
+ };
795
+
796
+ /**
797
+ * Options for the useUser composable.
798
+ *
799
+ * @category Users
800
+ */
801
+ export declare interface UseUserOptions {
802
+ /**
803
+ * Whether to fetch the user immediately on mount.
804
+ * @defaultValue true
805
+ */
806
+ immediate?: boolean;
807
+ /**
808
+ * Additional fields to include in the response.
809
+ */
810
+ include?: string[];
811
+ }
812
+
813
+ /**
814
+ * Vue 3 composable for listing users with pagination.
815
+ *
816
+ * @remarks
817
+ * Provides reactive access to a paginated list of users with built-in
818
+ * pagination controls. Automatically fetches on mount unless disabled.
819
+ *
820
+ * @param initialParams - Initial pagination/filter parameters
821
+ * @param options - Configuration options
822
+ * @returns Reactive users state and pagination controls
823
+ *
824
+ * @example
825
+ * ```vue
826
+ * <script setup>
827
+ * import { useUsers } from 'een-api-toolkit'
828
+ *
829
+ * const {
830
+ * users,
831
+ * loading,
832
+ * error,
833
+ * hasNextPage,
834
+ * fetchNextPage,
835
+ * refresh
836
+ * } = useUsers({ pageSize: 20 })
837
+ * </script>
838
+ *
839
+ * <template>
840
+ * <div v-if="loading">Loading...</div>
841
+ * <div v-else-if="error">Error: {{ error.message }}</div>
842
+ * <div v-else>
843
+ * <ul>
844
+ * <li v-for="user in users" :key="user.id">
845
+ * {{ user.firstName }} {{ user.lastName }} ({{ user.email }})
846
+ * </li>
847
+ * </ul>
848
+ * <button v-if="hasNextPage" @click="fetchNextPage">
849
+ * Load More
850
+ * </button>
851
+ * <button @click="refresh">Refresh</button>
852
+ * </div>
853
+ * </template>
854
+ * ```
855
+ *
856
+ * @example
857
+ * ```typescript
858
+ * // Change parameters dynamically
859
+ * const { users, setParams, fetch } = useUsers()
860
+ *
861
+ * async function searchUsers(query: string) {
862
+ * setParams({ pageSize: 50 })
863
+ * await fetch()
864
+ * }
865
+ * ```
866
+ *
867
+ * @category Users
868
+ */
869
+ export declare function useUsers(initialParams?: ListUsersParams, options?: UseUsersOptions): {
870
+ users: Ref< {
871
+ id: string;
872
+ email: string;
873
+ firstName: string;
874
+ lastName: string;
875
+ accountId?: string | undefined;
876
+ timeZone?: string | undefined;
877
+ language?: string | undefined;
878
+ phone?: string | undefined;
879
+ mobilePhone?: string | undefined;
880
+ permissions?: string[] | undefined;
881
+ lastLogin?: string | undefined;
882
+ isActive?: boolean | undefined;
883
+ createdAt?: string | undefined;
884
+ updatedAt?: string | undefined;
885
+ }[], User[] | {
886
+ id: string;
887
+ email: string;
888
+ firstName: string;
889
+ lastName: string;
890
+ accountId?: string | undefined;
891
+ timeZone?: string | undefined;
892
+ language?: string | undefined;
893
+ phone?: string | undefined;
894
+ mobilePhone?: string | undefined;
895
+ permissions?: string[] | undefined;
896
+ lastLogin?: string | undefined;
897
+ isActive?: boolean | undefined;
898
+ createdAt?: string | undefined;
899
+ updatedAt?: string | undefined;
900
+ }[]>;
901
+ loading: Ref<boolean, boolean>;
902
+ error: Ref< {
903
+ code: ErrorCode;
904
+ message: string;
905
+ status?: number | undefined;
906
+ details?: unknown;
907
+ } | null, EenError | {
908
+ code: ErrorCode;
909
+ message: string;
910
+ status?: number | undefined;
911
+ details?: unknown;
912
+ } | null>;
913
+ nextPageToken: Ref<string | undefined, string | undefined>;
914
+ prevPageToken: Ref<string | undefined, string | undefined>;
915
+ totalSize: Ref<number | undefined, number | undefined>;
916
+ hasNextPage: ComputedRef<boolean>;
917
+ hasPrevPage: ComputedRef<boolean>;
918
+ params: Ref< {
919
+ pageSize?: number | undefined;
920
+ pageToken?: string | undefined;
921
+ include?: string[] | undefined;
922
+ }, ListUsersParams | {
923
+ pageSize?: number | undefined;
924
+ pageToken?: string | undefined;
925
+ include?: string[] | undefined;
926
+ }>;
927
+ fetch: (fetchParams?: ListUsersParams) => Promise<Result<PaginatedResult<User>>>;
928
+ refresh: () => Promise<Result<PaginatedResult<User>>>;
929
+ fetchNextPage: () => Promise<Result<PaginatedResult<User>> | undefined>;
930
+ fetchPrevPage: () => Promise<Result<PaginatedResult<User>> | undefined>;
931
+ setParams: (newParams: ListUsersParams) => void;
932
+ };
933
+
934
+ /**
935
+ * Options for the useUsers composable.
936
+ *
937
+ * @category Users
938
+ */
939
+ export declare interface UseUsersOptions {
940
+ /**
941
+ * Whether to fetch users immediately on mount.
942
+ * @defaultValue true
943
+ */
944
+ immediate?: boolean;
945
+ }
946
+
947
+ export { }