@nextsparkjs/mobile 0.1.0-beta.97 → 0.1.0-beta.98
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/LICENSE +21 -0
- package/dist/api/client.d.ts +102 -0
- package/dist/api/client.js +6 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/client.types.d.ts +39 -0
- package/dist/api/client.types.js +4 -0
- package/dist/api/client.types.js.map +1 -0
- package/dist/api/core/auth.d.ts +26 -0
- package/dist/api/core/auth.js +7 -0
- package/dist/api/core/auth.js.map +1 -0
- package/dist/api/core/index.d.ts +4 -0
- package/dist/api/core/index.js +11 -0
- package/dist/api/core/index.js.map +1 -0
- package/dist/api/core/teams.d.ts +20 -0
- package/dist/api/core/teams.js +7 -0
- package/dist/api/core/teams.js.map +1 -0
- package/dist/api/core/types.d.ts +58 -0
- package/dist/api/core/types.js +3 -0
- package/dist/api/core/types.js.map +1 -0
- package/dist/api/core/users.d.ts +43 -0
- package/dist/api/core/users.js +7 -0
- package/dist/api/core/users.js.map +1 -0
- package/dist/api/entities/factory.d.ts +43 -0
- package/dist/api/entities/factory.js +7 -0
- package/dist/api/entities/factory.js.map +1 -0
- package/dist/api/entities/index.d.ts +3 -0
- package/dist/api/entities/index.js +8 -0
- package/dist/api/entities/index.js.map +1 -0
- package/dist/api/entities/types.d.ts +35 -0
- package/dist/api/entities/types.js +3 -0
- package/dist/api/entities/types.js.map +1 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.js +9 -0
- package/dist/api/index.js.map +1 -0
- package/dist/chunk-2AOTIYMA.js +36 -0
- package/dist/chunk-2AOTIYMA.js.map +1 -0
- package/dist/chunk-6XVSHTH3.js +46 -0
- package/dist/chunk-6XVSHTH3.js.map +1 -0
- package/dist/chunk-7Z3WHASJ.js +3 -0
- package/dist/chunk-7Z3WHASJ.js.map +1 -0
- package/dist/chunk-AIFXBGAN.js +54 -0
- package/dist/chunk-AIFXBGAN.js.map +1 -0
- package/dist/chunk-BIOJEN3Q.js +109 -0
- package/dist/chunk-BIOJEN3Q.js.map +1 -0
- package/dist/chunk-BYG6S2A7.js +3 -0
- package/dist/chunk-BYG6S2A7.js.map +1 -0
- package/dist/chunk-G7EWPNN6.js +43 -0
- package/dist/chunk-G7EWPNN6.js.map +1 -0
- package/dist/chunk-GFBFLLO3.js +24 -0
- package/dist/chunk-GFBFLLO3.js.map +1 -0
- package/dist/chunk-HVM4NDB3.js +72 -0
- package/dist/chunk-HVM4NDB3.js.map +1 -0
- package/dist/chunk-NCID7OSO.js +21 -0
- package/dist/chunk-NCID7OSO.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +9 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-RAGKK3PD.js +13 -0
- package/dist/chunk-RAGKK3PD.js.map +1 -0
- package/dist/chunk-TZTDARZ6.js +184 -0
- package/dist/chunk-TZTDARZ6.js.map +1 -0
- package/dist/chunk-UWZCGMZE.js +3 -0
- package/dist/chunk-UWZCGMZE.js.map +1 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +12 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/alert.d.ts +34 -0
- package/dist/lib/alert.js +4 -0
- package/dist/lib/alert.js.map +1 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +5 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/storage.d.ts +1 -0
- package/dist/lib/storage.js +4 -0
- package/dist/lib/storage.js.map +1 -0
- package/dist/providers/AuthProvider.d.ts +21 -0
- package/dist/providers/AuthProvider.js +12 -0
- package/dist/providers/AuthProvider.js.map +1 -0
- package/dist/providers/QueryProvider.d.ts +11 -0
- package/dist/providers/QueryProvider.js +4 -0
- package/dist/providers/QueryProvider.js.map +1 -0
- package/dist/providers/index.d.ts +6 -0
- package/dist/providers/index.js +13 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/storage-BaRppHUz.d.ts +22 -0
- package/package.json +11 -11
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 NextSpark
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { RequestConfig } from './client.types.js';
|
|
2
|
+
export { ApiError } from './client.types.js';
|
|
3
|
+
import { User } from './core/types.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* API Client for NextSpark Backend
|
|
7
|
+
*
|
|
8
|
+
* Configurable HTTP client with authentication and team context.
|
|
9
|
+
* API_URL is resolved from (in order):
|
|
10
|
+
* 1. app.config.ts extra.apiUrl
|
|
11
|
+
* 2. EXPO_PUBLIC_API_URL environment variable
|
|
12
|
+
* 3. Auto-detect from Expo dev server
|
|
13
|
+
* 4. Fallback to localhost:3000
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resolve API URL from configuration
|
|
18
|
+
*
|
|
19
|
+
* Priority order:
|
|
20
|
+
* 1. app.config.ts > extra > apiUrl (explicit configuration)
|
|
21
|
+
* 2. EXPO_PUBLIC_API_URL environment variable
|
|
22
|
+
* 3. Auto-detect from Expo dev server hostUri (development)
|
|
23
|
+
* 4. Fallback to http://localhost:3000
|
|
24
|
+
*
|
|
25
|
+
* @returns The resolved API URL
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* // In app.config.ts:
|
|
29
|
+
* export default {
|
|
30
|
+
* extra: {
|
|
31
|
+
* apiUrl: 'https://api.myapp.com'
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function getApiUrl(): string;
|
|
37
|
+
declare class ApiClient {
|
|
38
|
+
private token;
|
|
39
|
+
private teamId;
|
|
40
|
+
private storedUser;
|
|
41
|
+
/**
|
|
42
|
+
* Initialize client by loading stored credentials
|
|
43
|
+
*/
|
|
44
|
+
init(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Get stored token
|
|
47
|
+
*/
|
|
48
|
+
getToken(): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Set authentication token
|
|
51
|
+
*/
|
|
52
|
+
setToken(token: string): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Get stored team ID
|
|
55
|
+
*/
|
|
56
|
+
getTeamId(): string | null;
|
|
57
|
+
/**
|
|
58
|
+
* Set team ID
|
|
59
|
+
*/
|
|
60
|
+
setTeamId(teamId: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Get stored user info
|
|
63
|
+
*/
|
|
64
|
+
getStoredUser(): User | null;
|
|
65
|
+
/**
|
|
66
|
+
* Set user info
|
|
67
|
+
*/
|
|
68
|
+
setUser(user: User): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Clear authentication
|
|
71
|
+
*/
|
|
72
|
+
clearAuth(): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Build URL with query parameters
|
|
75
|
+
*/
|
|
76
|
+
private buildUrl;
|
|
77
|
+
/**
|
|
78
|
+
* Make authenticated request
|
|
79
|
+
* Uses credentials: 'include' to support cookie-based auth alongside Bearer token
|
|
80
|
+
*/
|
|
81
|
+
request<T>(endpoint: string, options?: RequestConfig): Promise<T>;
|
|
82
|
+
/**
|
|
83
|
+
* GET request with optional query parameters
|
|
84
|
+
*/
|
|
85
|
+
get<T>(endpoint: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
86
|
+
/**
|
|
87
|
+
* POST request with JSON body
|
|
88
|
+
*/
|
|
89
|
+
post<T>(endpoint: string, data?: unknown): Promise<T>;
|
|
90
|
+
/**
|
|
91
|
+
* PATCH request with JSON body
|
|
92
|
+
*/
|
|
93
|
+
patch<T>(endpoint: string, data?: unknown): Promise<T>;
|
|
94
|
+
/**
|
|
95
|
+
* DELETE request
|
|
96
|
+
* Returns void for delete operations (most common case)
|
|
97
|
+
*/
|
|
98
|
+
delete<T = void>(endpoint: string): Promise<T>;
|
|
99
|
+
}
|
|
100
|
+
declare const apiClient: ApiClient;
|
|
101
|
+
|
|
102
|
+
export { ApiClient, apiClient, getApiUrl };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"client.js"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Client Types
|
|
3
|
+
*
|
|
4
|
+
* Base types for API responses and error handling.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Paginated API response
|
|
8
|
+
*/
|
|
9
|
+
interface PaginatedResponse<T> {
|
|
10
|
+
data: T[];
|
|
11
|
+
meta: {
|
|
12
|
+
total: number;
|
|
13
|
+
page: number;
|
|
14
|
+
limit: number;
|
|
15
|
+
totalPages: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Single item API response
|
|
20
|
+
*/
|
|
21
|
+
interface SingleResponse<T> {
|
|
22
|
+
data: T;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Request configuration extending fetch options
|
|
26
|
+
*/
|
|
27
|
+
interface RequestConfig extends RequestInit {
|
|
28
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Custom API Error class
|
|
32
|
+
*/
|
|
33
|
+
declare class ApiError extends Error {
|
|
34
|
+
status: number;
|
|
35
|
+
data: unknown;
|
|
36
|
+
constructor(message: string, status: number, data?: unknown);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { ApiError, type PaginatedResponse, type RequestConfig, type SingleResponse };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"client.types.js"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { LoginResponse, SessionResponse } from './types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Auth API Service
|
|
5
|
+
*
|
|
6
|
+
* Authentication operations: login, logout, session management.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
declare const authApi: {
|
|
10
|
+
/**
|
|
11
|
+
* Login with email and password
|
|
12
|
+
* Better Auth returns user and session info
|
|
13
|
+
*/
|
|
14
|
+
login(email: string, password: string): Promise<LoginResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Logout - clear local auth and call server signout
|
|
17
|
+
*/
|
|
18
|
+
logout(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Get current session from server
|
|
21
|
+
* Used to validate stored credentials and get fresh user data
|
|
22
|
+
*/
|
|
23
|
+
getSession(): Promise<SessionResponse | null>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { authApi };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"auth.js"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import '../../chunk-BYG6S2A7.js';
|
|
2
|
+
import '../../chunk-7Z3WHASJ.js';
|
|
3
|
+
export { usersApi } from '../../chunk-G7EWPNN6.js';
|
|
4
|
+
export { authApi } from '../../chunk-AIFXBGAN.js';
|
|
5
|
+
export { teamsApi } from '../../chunk-NCID7OSO.js';
|
|
6
|
+
import '../../chunk-TZTDARZ6.js';
|
|
7
|
+
import '../../chunk-RAGKK3PD.js';
|
|
8
|
+
import '../../chunk-2AOTIYMA.js';
|
|
9
|
+
import '../../chunk-PZ5AY32C.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TeamsResponse } from './types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Teams API Service
|
|
5
|
+
*
|
|
6
|
+
* Team management operations.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
declare const teamsApi: {
|
|
10
|
+
/**
|
|
11
|
+
* Get user's teams
|
|
12
|
+
*/
|
|
13
|
+
getTeams(): Promise<TeamsResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Switch to a different team
|
|
16
|
+
*/
|
|
17
|
+
switchTeam(teamId: string): Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { teamsApi };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"teams.js"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core API Types
|
|
3
|
+
*
|
|
4
|
+
* Types for authentication, users, and teams.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* User entity
|
|
8
|
+
*/
|
|
9
|
+
interface User {
|
|
10
|
+
id: string;
|
|
11
|
+
email: string;
|
|
12
|
+
name?: string | null;
|
|
13
|
+
image?: string | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Team entity (from /api/v1/teams)
|
|
17
|
+
*/
|
|
18
|
+
interface Team {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
slug?: string;
|
|
22
|
+
logo?: string | null;
|
|
23
|
+
role: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Auth session info
|
|
27
|
+
*/
|
|
28
|
+
interface AuthSession {
|
|
29
|
+
token: string;
|
|
30
|
+
user: User;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Login response from Better Auth
|
|
34
|
+
*/
|
|
35
|
+
interface LoginResponse {
|
|
36
|
+
user: User;
|
|
37
|
+
session: {
|
|
38
|
+
token: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Session response from Better Auth
|
|
43
|
+
*/
|
|
44
|
+
interface SessionResponse {
|
|
45
|
+
user: User | null;
|
|
46
|
+
session: {
|
|
47
|
+
id: string;
|
|
48
|
+
expiresAt: string;
|
|
49
|
+
} | null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Teams list response
|
|
53
|
+
*/
|
|
54
|
+
interface TeamsResponse {
|
|
55
|
+
data: Team[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type { AuthSession, LoginResponse, SessionResponse, Team, TeamsResponse, User };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { User } from './types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Users API Service
|
|
5
|
+
*
|
|
6
|
+
* User profile and preferences operations.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Profile update input
|
|
11
|
+
*/
|
|
12
|
+
interface UpdateProfileInput {
|
|
13
|
+
name?: string;
|
|
14
|
+
image?: string | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* User preferences
|
|
18
|
+
*/
|
|
19
|
+
interface UserPreferences {
|
|
20
|
+
theme?: 'light' | 'dark' | 'system';
|
|
21
|
+
notifications?: boolean;
|
|
22
|
+
language?: string;
|
|
23
|
+
}
|
|
24
|
+
declare const usersApi: {
|
|
25
|
+
/**
|
|
26
|
+
* Get current authenticated user
|
|
27
|
+
*/
|
|
28
|
+
getCurrentUser(): Promise<User>;
|
|
29
|
+
/**
|
|
30
|
+
* Update user profile
|
|
31
|
+
*/
|
|
32
|
+
updateProfile(data: UpdateProfileInput): Promise<User>;
|
|
33
|
+
/**
|
|
34
|
+
* Update user preferences
|
|
35
|
+
*/
|
|
36
|
+
updatePreferences(preferences: UserPreferences): Promise<UserPreferences>;
|
|
37
|
+
/**
|
|
38
|
+
* Get user preferences
|
|
39
|
+
*/
|
|
40
|
+
getPreferences(): Promise<UserPreferences>;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { type UpdateProfileInput, type UserPreferences, usersApi };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"users.js"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { EntityApi } from './types.js';
|
|
2
|
+
import '../client.types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Entity API Factory
|
|
6
|
+
*
|
|
7
|
+
* Factory function to create typed API clients for any entity.
|
|
8
|
+
* Follows the same pattern as BaseEntityService in NextSpark web.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Create an API client for an entity
|
|
13
|
+
*
|
|
14
|
+
* @param entityPath - The entity path (e.g., 'tasks', 'customers')
|
|
15
|
+
* @returns Typed API client with CRUD operations
|
|
16
|
+
*
|
|
17
|
+
* Note: This factory assumes entities have an `id: string` field for get/update/delete operations.
|
|
18
|
+
* We intentionally don't enforce this via generic constraints to maintain flexibility for
|
|
19
|
+
* entities with different ID field names or types.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const tasksApi = createEntityApi<Task, CreateTaskInput, UpdateTaskInput>('tasks')
|
|
24
|
+
*
|
|
25
|
+
* // List tasks (returns PaginatedResponse)
|
|
26
|
+
* const { data, meta } = await tasksApi.list({ page: 1, limit: 10 })
|
|
27
|
+
*
|
|
28
|
+
* // Get single task (returns entity directly)
|
|
29
|
+
* const task = await tasksApi.get('task-id')
|
|
30
|
+
*
|
|
31
|
+
* // Create task (returns entity directly)
|
|
32
|
+
* const newTask = await tasksApi.create({ title: 'New Task' })
|
|
33
|
+
*
|
|
34
|
+
* // Update task (returns entity directly)
|
|
35
|
+
* const updated = await tasksApi.update('task-id', { status: 'done' })
|
|
36
|
+
*
|
|
37
|
+
* // Delete task
|
|
38
|
+
* await tasksApi.delete('task-id')
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare function createEntityApi<T, CreateInput = Partial<T>, UpdateInput = Partial<T>>(entityPath: string): EntityApi<T, CreateInput, UpdateInput>;
|
|
42
|
+
|
|
43
|
+
export { createEntityApi };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createEntityApi } from '../../chunk-6XVSHTH3.js';
|
|
2
|
+
import '../../chunk-TZTDARZ6.js';
|
|
3
|
+
import '../../chunk-RAGKK3PD.js';
|
|
4
|
+
import '../../chunk-2AOTIYMA.js';
|
|
5
|
+
import '../../chunk-PZ5AY32C.js';
|
|
6
|
+
//# sourceMappingURL=factory.js.map
|
|
7
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"factory.js"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import '../../chunk-UWZCGMZE.js';
|
|
2
|
+
export { createEntityApi } from '../../chunk-6XVSHTH3.js';
|
|
3
|
+
import '../../chunk-TZTDARZ6.js';
|
|
4
|
+
import '../../chunk-RAGKK3PD.js';
|
|
5
|
+
import '../../chunk-2AOTIYMA.js';
|
|
6
|
+
import '../../chunk-PZ5AY32C.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PaginatedResponse } from '../client.types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Entity API Types
|
|
5
|
+
*
|
|
6
|
+
* Generic types for entity CRUD operations.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Parameters for listing entities
|
|
11
|
+
*/
|
|
12
|
+
interface EntityListParams {
|
|
13
|
+
page?: number;
|
|
14
|
+
limit?: number;
|
|
15
|
+
search?: string;
|
|
16
|
+
sort?: string;
|
|
17
|
+
order?: 'asc' | 'desc';
|
|
18
|
+
[key: string]: string | number | boolean | undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Generic entity API interface
|
|
22
|
+
* Matches NextSpark web BaseEntityService pattern
|
|
23
|
+
*
|
|
24
|
+
* Note: get, create, and update return the entity directly (T),
|
|
25
|
+
* not wrapped in SingleResponse<T>. This provides a cleaner API.
|
|
26
|
+
*/
|
|
27
|
+
interface EntityApi<T, CreateInput, UpdateInput> {
|
|
28
|
+
list: (params?: EntityListParams) => Promise<PaginatedResponse<T>>;
|
|
29
|
+
get: (id: string) => Promise<T>;
|
|
30
|
+
create: (data: CreateInput) => Promise<T>;
|
|
31
|
+
update: (id: string, data: UpdateInput) => Promise<T>;
|
|
32
|
+
delete: (id: string) => Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type { EntityApi, EntityListParams };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ApiClient, apiClient, getApiUrl } from './client.js';
|
|
2
|
+
export { ApiError, PaginatedResponse, RequestConfig, SingleResponse } from './client.types.js';
|
|
3
|
+
export { authApi } from './core/auth.js';
|
|
4
|
+
export { teamsApi } from './core/teams.js';
|
|
5
|
+
export { AuthSession, LoginResponse, SessionResponse, Team, TeamsResponse, User } from './core/types.js';
|
|
6
|
+
export { createEntityApi } from './entities/factory.js';
|
|
7
|
+
export { EntityApi, EntityListParams } from './entities/types.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { createEntityApi } from '../chunk-6XVSHTH3.js';
|
|
2
|
+
export { authApi } from '../chunk-AIFXBGAN.js';
|
|
3
|
+
export { teamsApi } from '../chunk-NCID7OSO.js';
|
|
4
|
+
export { ApiClient, apiClient, getApiUrl } from '../chunk-TZTDARZ6.js';
|
|
5
|
+
export { ApiError } from '../chunk-RAGKK3PD.js';
|
|
6
|
+
import '../chunk-2AOTIYMA.js';
|
|
7
|
+
import '../chunk-PZ5AY32C.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { __export } from './chunk-PZ5AY32C.js';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import * as SecureStore from 'expo-secure-store';
|
|
4
|
+
|
|
5
|
+
// src/lib/storage.ts
|
|
6
|
+
var storage_exports = {};
|
|
7
|
+
__export(storage_exports, {
|
|
8
|
+
deleteItemAsync: () => deleteItemAsync2,
|
|
9
|
+
getItemAsync: () => getItemAsync2,
|
|
10
|
+
setItemAsync: () => setItemAsync2
|
|
11
|
+
});
|
|
12
|
+
var isWeb = Platform.OS === "web";
|
|
13
|
+
async function getItemAsync2(key) {
|
|
14
|
+
if (isWeb) {
|
|
15
|
+
return localStorage.getItem(key);
|
|
16
|
+
}
|
|
17
|
+
return SecureStore.getItemAsync(key);
|
|
18
|
+
}
|
|
19
|
+
async function setItemAsync2(key, value) {
|
|
20
|
+
if (isWeb) {
|
|
21
|
+
localStorage.setItem(key, value);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
return SecureStore.setItemAsync(key, value);
|
|
25
|
+
}
|
|
26
|
+
async function deleteItemAsync2(key) {
|
|
27
|
+
if (isWeb) {
|
|
28
|
+
localStorage.removeItem(key);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
return SecureStore.deleteItemAsync(key);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { deleteItemAsync2 as deleteItemAsync, getItemAsync2 as getItemAsync, setItemAsync2 as setItemAsync, storage_exports };
|
|
35
|
+
//# sourceMappingURL=chunk-2AOTIYMA.js.map
|
|
36
|
+
//# sourceMappingURL=chunk-2AOTIYMA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/storage.ts"],"names":["deleteItemAsync","getItemAsync","setItemAsync"],"mappings":";;;;;AAAA,IAAA,eAAA,GAAA;AAAA,QAAA,CAAA,eAAA,EAAA;AAAA,EAAA,eAAA,EAAA,MAAAA,gBAAAA;AAAA,EAAA,YAAA,EAAA,MAAAC,aAAAA;AAAA,EAAA,YAAA,EAAA,MAAAC;AAAA,CAAA,CAAA;AAcA,IAAM,KAAA,GAAQ,SAAS,EAAA,KAAO,KAAA;AAE9B,eAAsBD,cAAa,GAAA,EAAqC;AACtE,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,OAAO,YAAA,CAAa,QAAQ,GAAG,CAAA;AAAA,EACjC;AACA,EAAA,OAAmB,yBAAa,GAAG,CAAA;AACrC;AAEA,eAAsBC,aAAAA,CAAa,KAAa,KAAA,EAA8B;AAC5E,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,YAAA,CAAa,OAAA,CAAQ,KAAK,KAAK,CAAA;AAC/B,IAAA;AAAA,EACF;AACA,EAAA,OAAmB,WAAA,CAAA,YAAA,CAAa,KAAK,KAAK,CAAA;AAC5C;AAEA,eAAsBF,iBAAgB,GAAA,EAA4B;AAChE,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,YAAA,CAAa,WAAW,GAAG,CAAA;AAC3B,IAAA;AAAA,EACF;AACA,EAAA,OAAmB,4BAAgB,GAAG,CAAA;AACxC","file":"chunk-2AOTIYMA.js","sourcesContent":["/**\n * Cross-platform secure storage\n * Uses expo-secure-store on native, localStorage on web\n *\n * ⚠️ SECURITY NOTE: Web storage uses localStorage which is vulnerable to XSS attacks.\n * For production web deployments, consider:\n * - Using httpOnly cookies for session management (requires backend changes)\n * - Implementing Content Security Policy (CSP)\n * - This is acceptable for development/testing and native mobile apps\n */\n\nimport { Platform } from 'react-native'\nimport * as SecureStore from 'expo-secure-store'\n\nconst isWeb = Platform.OS === 'web'\n\nexport async function getItemAsync(key: string): Promise<string | null> {\n if (isWeb) {\n return localStorage.getItem(key)\n }\n return SecureStore.getItemAsync(key)\n}\n\nexport async function setItemAsync(key: string, value: string): Promise<void> {\n if (isWeb) {\n localStorage.setItem(key, value)\n return\n }\n return SecureStore.setItemAsync(key, value)\n}\n\nexport async function deleteItemAsync(key: string): Promise<void> {\n if (isWeb) {\n localStorage.removeItem(key)\n return\n }\n return SecureStore.deleteItemAsync(key)\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { apiClient } from './chunk-TZTDARZ6.js';
|
|
2
|
+
|
|
3
|
+
// src/api/entities/factory.ts
|
|
4
|
+
function createEntityApi(entityPath) {
|
|
5
|
+
const basePath = `/api/v1/${entityPath}`;
|
|
6
|
+
return {
|
|
7
|
+
/**
|
|
8
|
+
* List entities with pagination and filters
|
|
9
|
+
* Returns PaginatedResponse with data array and meta
|
|
10
|
+
*/
|
|
11
|
+
list: (params) => apiClient.get(basePath, params),
|
|
12
|
+
/**
|
|
13
|
+
* Get a single entity by ID
|
|
14
|
+
* Returns the entity directly (unwrapped from SingleResponse)
|
|
15
|
+
*/
|
|
16
|
+
get: async (id) => {
|
|
17
|
+
const response = await apiClient.get(`${basePath}/${id}`);
|
|
18
|
+
return response.data;
|
|
19
|
+
},
|
|
20
|
+
/**
|
|
21
|
+
* Create a new entity
|
|
22
|
+
* Returns the created entity directly (unwrapped from SingleResponse)
|
|
23
|
+
*/
|
|
24
|
+
create: async (data) => {
|
|
25
|
+
const response = await apiClient.post(basePath, data);
|
|
26
|
+
return response.data;
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* Update an existing entity
|
|
30
|
+
* Returns the updated entity directly (unwrapped from SingleResponse)
|
|
31
|
+
*/
|
|
32
|
+
update: async (id, data) => {
|
|
33
|
+
const response = await apiClient.patch(`${basePath}/${id}`, data);
|
|
34
|
+
return response.data;
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* Delete an entity
|
|
38
|
+
* Returns void (no content expected from DELETE operations)
|
|
39
|
+
*/
|
|
40
|
+
delete: (id) => apiClient.delete(`${basePath}/${id}`)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { createEntityApi };
|
|
45
|
+
//# sourceMappingURL=chunk-6XVSHTH3.js.map
|
|
46
|
+
//# sourceMappingURL=chunk-6XVSHTH3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api/entities/factory.ts"],"names":[],"mappings":";;;AAyCO,SAAS,gBACd,UAAA,EACwC;AACxC,EAAA,MAAM,QAAA,GAAW,WAAW,UAAU,CAAA,CAAA;AAEtC,EAAA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,MAAM,CAAC,MAAA,KACL,SAAA,CAAU,GAAA,CAA0B,UAAU,MAAM,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMtD,GAAA,EAAK,OAAO,EAAA,KAA2B;AACrC,MAAA,MAAM,QAAA,GAAW,MAAM,SAAA,CAAU,GAAA,CAAuB,GAAG,QAAQ,CAAA,CAAA,EAAI,EAAE,CAAA,CAAE,CAAA;AAC3E,MAAA,OAAO,QAAA,CAAS,IAAA;AAAA,IAClB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,MAAA,EAAQ,OAAO,IAAA,KAAkC;AAC/C,MAAA,MAAM,QAAA,GAAW,MAAM,SAAA,CAAU,IAAA,CAAwB,UAAU,IAAI,CAAA;AACvE,MAAA,OAAO,QAAA,CAAS,IAAA;AAAA,IAClB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,MAAA,EAAQ,OAAO,EAAA,EAAY,IAAA,KAAkC;AAC3D,MAAA,MAAM,QAAA,GAAW,MAAM,SAAA,CAAU,KAAA,CAAyB,GAAG,QAAQ,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,EAAI,IAAI,CAAA;AACnF,MAAA,OAAO,QAAA,CAAS,IAAA;AAAA,IAClB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,MAAA,EAAQ,CAAC,EAAA,KACP,SAAA,CAAU,OAAa,CAAA,EAAG,QAAQ,CAAA,CAAA,EAAI,EAAE,CAAA,CAAE;AAAA,GAC9C;AACF","file":"chunk-6XVSHTH3.js","sourcesContent":["/**\n * Entity API Factory\n *\n * Factory function to create typed API clients for any entity.\n * Follows the same pattern as BaseEntityService in NextSpark web.\n */\n\nimport { apiClient } from '../client'\nimport type { PaginatedResponse, SingleResponse } from '../client.types'\nimport type { EntityApi, EntityListParams } from './types'\n\n/**\n * Create an API client for an entity\n *\n * @param entityPath - The entity path (e.g., 'tasks', 'customers')\n * @returns Typed API client with CRUD operations\n *\n * Note: This factory assumes entities have an `id: string` field for get/update/delete operations.\n * We intentionally don't enforce this via generic constraints to maintain flexibility for\n * entities with different ID field names or types.\n *\n * @example\n * ```typescript\n * const tasksApi = createEntityApi<Task, CreateTaskInput, UpdateTaskInput>('tasks')\n *\n * // List tasks (returns PaginatedResponse)\n * const { data, meta } = await tasksApi.list({ page: 1, limit: 10 })\n *\n * // Get single task (returns entity directly)\n * const task = await tasksApi.get('task-id')\n *\n * // Create task (returns entity directly)\n * const newTask = await tasksApi.create({ title: 'New Task' })\n *\n * // Update task (returns entity directly)\n * const updated = await tasksApi.update('task-id', { status: 'done' })\n *\n * // Delete task\n * await tasksApi.delete('task-id')\n * ```\n */\nexport function createEntityApi<T, CreateInput = Partial<T>, UpdateInput = Partial<T>>(\n entityPath: string\n): EntityApi<T, CreateInput, UpdateInput> {\n const basePath = `/api/v1/${entityPath}`\n\n return {\n /**\n * List entities with pagination and filters\n * Returns PaginatedResponse with data array and meta\n */\n list: (params?: EntityListParams) =>\n apiClient.get<PaginatedResponse<T>>(basePath, params),\n\n /**\n * Get a single entity by ID\n * Returns the entity directly (unwrapped from SingleResponse)\n */\n get: async (id: string): Promise<T> => {\n const response = await apiClient.get<SingleResponse<T>>(`${basePath}/${id}`)\n return response.data\n },\n\n /**\n * Create a new entity\n * Returns the created entity directly (unwrapped from SingleResponse)\n */\n create: async (data: CreateInput): Promise<T> => {\n const response = await apiClient.post<SingleResponse<T>>(basePath, data)\n return response.data\n },\n\n /**\n * Update an existing entity\n * Returns the updated entity directly (unwrapped from SingleResponse)\n */\n update: async (id: string, data: UpdateInput): Promise<T> => {\n const response = await apiClient.patch<SingleResponse<T>>(`${basePath}/${id}`, data)\n return response.data\n },\n\n /**\n * Delete an entity\n * Returns void (no content expected from DELETE operations)\n */\n delete: (id: string): Promise<void> =>\n apiClient.delete<void>(`${basePath}/${id}`),\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-7Z3WHASJ.js"}
|