@nextsparkjs/mobile 0.1.0-beta.92 → 0.1.0-beta.95

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.
Files changed (60) hide show
  1. package/package.json +11 -11
  2. package/LICENSE +0 -21
  3. package/dist/api/client.d.ts +0 -102
  4. package/dist/api/client.js +0 -189
  5. package/dist/api/client.js.map +0 -1
  6. package/dist/api/client.types.d.ts +0 -39
  7. package/dist/api/client.types.js +0 -12
  8. package/dist/api/client.types.js.map +0 -1
  9. package/dist/api/core/auth.d.ts +0 -26
  10. package/dist/api/core/auth.js +0 -52
  11. package/dist/api/core/auth.js.map +0 -1
  12. package/dist/api/core/index.d.ts +0 -4
  13. package/dist/api/core/index.js +0 -5
  14. package/dist/api/core/index.js.map +0 -1
  15. package/dist/api/core/teams.d.ts +0 -20
  16. package/dist/api/core/teams.js +0 -19
  17. package/dist/api/core/teams.js.map +0 -1
  18. package/dist/api/core/types.d.ts +0 -58
  19. package/dist/api/core/types.js +0 -1
  20. package/dist/api/core/types.js.map +0 -1
  21. package/dist/api/core/users.d.ts +0 -43
  22. package/dist/api/core/users.js +0 -41
  23. package/dist/api/core/users.js.map +0 -1
  24. package/dist/api/entities/factory.d.ts +0 -43
  25. package/dist/api/entities/factory.js +0 -44
  26. package/dist/api/entities/factory.js.map +0 -1
  27. package/dist/api/entities/index.d.ts +0 -3
  28. package/dist/api/entities/index.js +0 -3
  29. package/dist/api/entities/index.js.map +0 -1
  30. package/dist/api/entities/types.d.ts +0 -35
  31. package/dist/api/entities/types.js +0 -1
  32. package/dist/api/entities/types.js.map +0 -1
  33. package/dist/api/index.d.ts +0 -7
  34. package/dist/api/index.js +0 -15
  35. package/dist/api/index.js.map +0 -1
  36. package/dist/hooks/index.d.ts +0 -4
  37. package/dist/hooks/index.js +0 -5
  38. package/dist/hooks/index.js.map +0 -1
  39. package/dist/index.d.ts +0 -14
  40. package/dist/index.js +0 -28
  41. package/dist/index.js.map +0 -1
  42. package/dist/lib/alert.d.ts +0 -34
  43. package/dist/lib/alert.js +0 -73
  44. package/dist/lib/alert.js.map +0 -1
  45. package/dist/lib/index.d.ts +0 -2
  46. package/dist/lib/index.js +0 -10
  47. package/dist/lib/index.js.map +0 -1
  48. package/dist/lib/storage.d.ts +0 -1
  49. package/dist/lib/storage.js +0 -29
  50. package/dist/lib/storage.js.map +0 -1
  51. package/dist/providers/AuthProvider.d.ts +0 -21
  52. package/dist/providers/AuthProvider.js +0 -113
  53. package/dist/providers/AuthProvider.js.map +0 -1
  54. package/dist/providers/QueryProvider.d.ts +0 -11
  55. package/dist/providers/QueryProvider.js +0 -23
  56. package/dist/providers/QueryProvider.js.map +0 -1
  57. package/dist/providers/index.d.ts +0 -6
  58. package/dist/providers/index.js +0 -9
  59. package/dist/providers/index.js.map +0 -1
  60. package/dist/storage-BaRppHUz.d.ts +0 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextsparkjs/mobile",
3
- "version": "0.1.0-beta.92",
3
+ "version": "0.1.0-beta.95",
4
4
  "description": "Mobile app infrastructure for NextSpark - API client, providers, and utilities for Expo apps",
5
5
  "license": "MIT",
6
6
  "author": "NextSpark <hello@nextspark.dev>",
@@ -49,6 +49,15 @@
49
49
  "templates",
50
50
  "README.md"
51
51
  ],
52
+ "scripts": {
53
+ "build": "tsup",
54
+ "build:watch": "tsup --watch",
55
+ "test": "jest",
56
+ "test:watch": "jest --watch",
57
+ "test:coverage": "jest --coverage",
58
+ "typecheck": "tsc --noEmit",
59
+ "clean": "rm -rf dist"
60
+ },
52
61
  "peerDependencies": {
53
62
  "@tanstack/react-query": "^5.0.0",
54
63
  "expo": ">=54.0.0",
@@ -86,14 +95,5 @@
86
95
  ],
87
96
  "nextspark": {
88
97
  "type": "mobile"
89
- },
90
- "scripts": {
91
- "build": "tsup",
92
- "build:watch": "tsup --watch",
93
- "test": "jest",
94
- "test:watch": "jest --watch",
95
- "test:coverage": "jest --coverage",
96
- "typecheck": "tsc --noEmit",
97
- "clean": "rm -rf dist"
98
98
  }
99
- }
99
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
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.
@@ -1,102 +0,0 @@
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 };
@@ -1,189 +0,0 @@
1
- import Constants from "expo-constants";
2
- import * as Storage from '../lib/storage.js';
3
- import { ApiError } from './client.types.js';
4
- function getApiUrl() {
5
- const configUrl = Constants.expoConfig?.extra?.apiUrl;
6
- if (configUrl) return configUrl;
7
- const envUrl = process.env.EXPO_PUBLIC_API_URL;
8
- if (envUrl) return envUrl;
9
- if (Constants.expoConfig?.hostUri) {
10
- const host = Constants.expoConfig.hostUri.split(":")[0];
11
- return `http://${host}:3000`;
12
- }
13
- return "http://localhost:3000";
14
- }
15
- const API_URL = getApiUrl();
16
- const TOKEN_KEY = "nextspark.auth.token";
17
- const TEAM_ID_KEY = "nextspark.auth.teamId";
18
- const USER_KEY = "nextspark.auth.user";
19
- class ApiClient {
20
- constructor() {
21
- this.token = null;
22
- this.teamId = null;
23
- this.storedUser = null;
24
- }
25
- /**
26
- * Initialize client by loading stored credentials
27
- */
28
- async init() {
29
- this.token = await Storage.getItemAsync(TOKEN_KEY);
30
- this.teamId = await Storage.getItemAsync(TEAM_ID_KEY);
31
- const userJson = await Storage.getItemAsync(USER_KEY);
32
- if (userJson) {
33
- try {
34
- this.storedUser = JSON.parse(userJson);
35
- } catch {
36
- this.storedUser = null;
37
- }
38
- }
39
- }
40
- // ==========================================
41
- // Token & Team Management
42
- // ==========================================
43
- /**
44
- * Get stored token
45
- */
46
- getToken() {
47
- return this.token;
48
- }
49
- /**
50
- * Set authentication token
51
- */
52
- async setToken(token) {
53
- this.token = token;
54
- await Storage.setItemAsync(TOKEN_KEY, token);
55
- }
56
- /**
57
- * Get stored team ID
58
- */
59
- getTeamId() {
60
- return this.teamId;
61
- }
62
- /**
63
- * Set team ID
64
- */
65
- async setTeamId(teamId) {
66
- this.teamId = teamId;
67
- await Storage.setItemAsync(TEAM_ID_KEY, teamId);
68
- }
69
- /**
70
- * Get stored user info
71
- */
72
- getStoredUser() {
73
- return this.storedUser;
74
- }
75
- /**
76
- * Set user info
77
- */
78
- async setUser(user) {
79
- this.storedUser = user;
80
- await Storage.setItemAsync(USER_KEY, JSON.stringify(user));
81
- }
82
- /**
83
- * Clear authentication
84
- */
85
- async clearAuth() {
86
- this.token = null;
87
- this.teamId = null;
88
- this.storedUser = null;
89
- await Storage.deleteItemAsync(TOKEN_KEY);
90
- await Storage.deleteItemAsync(TEAM_ID_KEY);
91
- await Storage.deleteItemAsync(USER_KEY);
92
- }
93
- // ==========================================
94
- // HTTP Methods
95
- // ==========================================
96
- /**
97
- * Build URL with query parameters
98
- */
99
- buildUrl(endpoint, params) {
100
- const url = `${API_URL}${endpoint}`;
101
- if (!params) return url;
102
- const searchParams = new URLSearchParams();
103
- Object.entries(params).forEach(([key, value]) => {
104
- if (value !== void 0) {
105
- searchParams.set(key, String(value));
106
- }
107
- });
108
- const queryString = searchParams.toString();
109
- return queryString ? `${url}?${queryString}` : url;
110
- }
111
- /**
112
- * Make authenticated request
113
- * Uses credentials: 'include' to support cookie-based auth alongside Bearer token
114
- */
115
- async request(endpoint, options = {}) {
116
- const { params, ...fetchOptions } = options;
117
- const url = this.buildUrl(endpoint, params);
118
- const headers = {
119
- "Content-Type": "application/json",
120
- ...fetchOptions.headers
121
- };
122
- if (this.token) {
123
- ;
124
- headers["Authorization"] = `Bearer ${this.token}`;
125
- }
126
- if (this.teamId) {
127
- ;
128
- headers["x-team-id"] = this.teamId;
129
- }
130
- const response = await fetch(url, {
131
- ...fetchOptions,
132
- headers,
133
- credentials: "include"
134
- // Support cookie-based sessions
135
- });
136
- if (!response.ok) {
137
- const errorData = await response.json().catch(() => ({}));
138
- throw new ApiError(
139
- errorData.message || `Request failed with status ${response.status}`,
140
- response.status,
141
- errorData
142
- );
143
- }
144
- if (response.status === 204) {
145
- return {};
146
- }
147
- return response.json().catch(() => ({}));
148
- }
149
- /**
150
- * GET request with optional query parameters
151
- */
152
- async get(endpoint, params) {
153
- return this.request(endpoint, { method: "GET", params });
154
- }
155
- /**
156
- * POST request with JSON body
157
- */
158
- async post(endpoint, data) {
159
- return this.request(endpoint, {
160
- method: "POST",
161
- body: data ? JSON.stringify(data) : void 0
162
- });
163
- }
164
- /**
165
- * PATCH request with JSON body
166
- */
167
- async patch(endpoint, data) {
168
- return this.request(endpoint, {
169
- method: "PATCH",
170
- body: data ? JSON.stringify(data) : void 0
171
- });
172
- }
173
- /**
174
- * DELETE request
175
- * Returns void for delete operations (most common case)
176
- */
177
- async delete(endpoint) {
178
- return this.request(endpoint, { method: "DELETE" });
179
- }
180
- }
181
- const apiClient = new ApiClient();
182
- import { ApiError as ApiError2 } from './client.types.js';
183
- export {
184
- ApiClient,
185
- ApiError2 as ApiError,
186
- apiClient,
187
- getApiUrl
188
- };
189
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/client.ts"],"sourcesContent":["/**\n * API Client for NextSpark Backend\n *\n * Configurable HTTP client with authentication and team context.\n * API_URL is resolved from (in order):\n * 1. app.config.ts extra.apiUrl\n * 2. EXPO_PUBLIC_API_URL environment variable\n * 3. Auto-detect from Expo dev server\n * 4. Fallback to localhost:3000\n */\n\nimport Constants from 'expo-constants'\nimport * as Storage from '../lib/storage'\nimport { ApiError, type RequestConfig } from './client.types'\nimport type { User } from './core/types'\n\n/**\n * Resolve API URL from configuration\n *\n * Priority order:\n * 1. app.config.ts > extra > apiUrl (explicit configuration)\n * 2. EXPO_PUBLIC_API_URL environment variable\n * 3. Auto-detect from Expo dev server hostUri (development)\n * 4. Fallback to http://localhost:3000\n *\n * @returns The resolved API URL\n * @example\n * ```ts\n * // In app.config.ts:\n * export default {\n * extra: {\n * apiUrl: 'https://api.myapp.com'\n * }\n * }\n * ```\n */\nexport function getApiUrl(): string {\n // 1. From Expo config (app.config.ts > extra > apiUrl)\n const configUrl = Constants.expoConfig?.extra?.apiUrl\n if (configUrl) return configUrl\n\n // 2. From environment variable (EXPO_PUBLIC_API_URL)\n const envUrl = process.env.EXPO_PUBLIC_API_URL\n if (envUrl) return envUrl\n\n // 3. Auto-detect from Expo dev server (development mode)\n if (Constants.expoConfig?.hostUri) {\n const host = Constants.expoConfig.hostUri.split(':')[0]\n return `http://${host}:3000`\n }\n\n // 4. Fallback for local development\n return 'http://localhost:3000'\n}\n\nconst API_URL = getApiUrl()\n\n// Storage keys (namespaced to avoid conflicts)\n// SecureStore only allows alphanumeric, \".\", \"-\", and \"_\"\nconst TOKEN_KEY = 'nextspark.auth.token'\nconst TEAM_ID_KEY = 'nextspark.auth.teamId'\nconst USER_KEY = 'nextspark.auth.user'\n\nexport class ApiClient {\n private token: string | null = null\n private teamId: string | null = null\n private storedUser: User | null = null\n\n /**\n * Initialize client by loading stored credentials\n */\n async init(): Promise<void> {\n this.token = await Storage.getItemAsync(TOKEN_KEY)\n this.teamId = await Storage.getItemAsync(TEAM_ID_KEY)\n const userJson = await Storage.getItemAsync(USER_KEY)\n if (userJson) {\n try {\n this.storedUser = JSON.parse(userJson)\n } catch {\n this.storedUser = null\n }\n }\n }\n\n // ==========================================\n // Token & Team Management\n // ==========================================\n\n /**\n * Get stored token\n */\n getToken(): string | null {\n return this.token\n }\n\n /**\n * Set authentication token\n */\n async setToken(token: string): Promise<void> {\n this.token = token\n await Storage.setItemAsync(TOKEN_KEY, token)\n }\n\n /**\n * Get stored team ID\n */\n getTeamId(): string | null {\n return this.teamId\n }\n\n /**\n * Set team ID\n */\n async setTeamId(teamId: string): Promise<void> {\n this.teamId = teamId\n await Storage.setItemAsync(TEAM_ID_KEY, teamId)\n }\n\n /**\n * Get stored user info\n */\n getStoredUser(): User | null {\n return this.storedUser\n }\n\n /**\n * Set user info\n */\n async setUser(user: User): Promise<void> {\n this.storedUser = user\n await Storage.setItemAsync(USER_KEY, JSON.stringify(user))\n }\n\n /**\n * Clear authentication\n */\n async clearAuth(): Promise<void> {\n this.token = null\n this.teamId = null\n this.storedUser = null\n await Storage.deleteItemAsync(TOKEN_KEY)\n await Storage.deleteItemAsync(TEAM_ID_KEY)\n await Storage.deleteItemAsync(USER_KEY)\n }\n\n // ==========================================\n // HTTP Methods\n // ==========================================\n\n /**\n * Build URL with query parameters\n */\n private buildUrl(endpoint: string, params?: Record<string, string | number | boolean | undefined>): string {\n const url = `${API_URL}${endpoint}`\n if (!params) return url\n\n const searchParams = new URLSearchParams()\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n searchParams.set(key, String(value))\n }\n })\n\n const queryString = searchParams.toString()\n return queryString ? `${url}?${queryString}` : url\n }\n\n /**\n * Make authenticated request\n * Uses credentials: 'include' to support cookie-based auth alongside Bearer token\n */\n async request<T>(endpoint: string, options: RequestConfig = {}): Promise<T> {\n const { params, ...fetchOptions } = options\n const url = this.buildUrl(endpoint, params)\n\n const headers: HeadersInit = {\n 'Content-Type': 'application/json',\n ...fetchOptions.headers,\n }\n\n // Add Bearer token if available (Better Auth mobile flow)\n if (this.token) {\n ;(headers as Record<string, string>)['Authorization'] = `Bearer ${this.token}`\n }\n\n // Add team context header\n if (this.teamId) {\n ;(headers as Record<string, string>)['x-team-id'] = this.teamId\n }\n\n const response = await fetch(url, {\n ...fetchOptions,\n headers,\n credentials: 'include', // Support cookie-based sessions\n })\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}))\n throw new ApiError(\n errorData.message || `Request failed with status ${response.status}`,\n response.status,\n errorData\n )\n }\n\n // Handle 204 No Content\n if (response.status === 204) {\n return {} as T\n }\n\n // Defensive JSON parsing - handle malformed responses\n return response.json().catch(() => ({} as T))\n }\n\n /**\n * GET request with optional query parameters\n */\n async get<T>(endpoint: string, params?: Record<string, string | number | boolean | undefined>): Promise<T> {\n return this.request<T>(endpoint, { method: 'GET', params })\n }\n\n /**\n * POST request with JSON body\n */\n async post<T>(endpoint: string, data?: unknown): Promise<T> {\n return this.request<T>(endpoint, {\n method: 'POST',\n body: data ? JSON.stringify(data) : undefined,\n })\n }\n\n /**\n * PATCH request with JSON body\n */\n async patch<T>(endpoint: string, data?: unknown): Promise<T> {\n return this.request<T>(endpoint, {\n method: 'PATCH',\n body: data ? JSON.stringify(data) : undefined,\n })\n }\n\n /**\n * DELETE request\n * Returns void for delete operations (most common case)\n */\n async delete<T = void>(endpoint: string): Promise<T> {\n return this.request<T>(endpoint, { method: 'DELETE' })\n }\n}\n\n// Export singleton instance\nexport const apiClient = new ApiClient()\n\n// Re-export ApiError for convenience\nexport { ApiError } from './client.types'\n"],"mappings":"AAWA,OAAO,eAAe;AACtB,YAAY,aAAa;AACzB,SAAS,gBAAoC;AAuBtC,SAAS,YAAoB;AAElC,QAAM,YAAY,UAAU,YAAY,OAAO;AAC/C,MAAI,UAAW,QAAO;AAGtB,QAAM,SAAS,QAAQ,IAAI;AAC3B,MAAI,OAAQ,QAAO;AAGnB,MAAI,UAAU,YAAY,SAAS;AACjC,UAAM,OAAO,UAAU,WAAW,QAAQ,MAAM,GAAG,EAAE,CAAC;AACtD,WAAO,UAAU,IAAI;AAAA,EACvB;AAGA,SAAO;AACT;AAEA,MAAM,UAAU,UAAU;AAI1B,MAAM,YAAY;AAClB,MAAM,cAAc;AACpB,MAAM,WAAW;AAEV,MAAM,UAAU;AAAA,EAAhB;AACL,SAAQ,QAAuB;AAC/B,SAAQ,SAAwB;AAChC,SAAQ,aAA0B;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlC,MAAM,OAAsB;AAC1B,SAAK,QAAQ,MAAM,QAAQ,aAAa,SAAS;AACjD,SAAK,SAAS,MAAM,QAAQ,aAAa,WAAW;AACpD,UAAM,WAAW,MAAM,QAAQ,aAAa,QAAQ;AACpD,QAAI,UAAU;AACZ,UAAI;AACF,aAAK,aAAa,KAAK,MAAM,QAAQ;AAAA,MACvC,QAAQ;AACN,aAAK,aAAa;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,WAA0B;AACxB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,SAAS,OAA8B;AAC3C,SAAK,QAAQ;AACb,UAAM,QAAQ,aAAa,WAAW,KAAK;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA,EAKA,YAA2B;AACzB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAU,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","names":["ApiError"]}
@@ -1,39 +0,0 @@
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 };
@@ -1,12 +0,0 @@
1
- class ApiError extends Error {
2
- constructor(message, status, data) {
3
- super(message);
4
- this.name = "ApiError";
5
- this.status = status;
6
- this.data = data;
7
- }
8
- }
9
- export {
10
- ApiError
11
- };
12
- //# sourceMappingURL=client.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/client.types.ts"],"sourcesContent":["/**\n * API Client Types\n *\n * Base types for API responses and error handling.\n */\n\n/**\n * Paginated API response\n */\nexport interface PaginatedResponse<T> {\n data: T[]\n meta: {\n total: number\n page: number\n limit: number\n totalPages: number\n }\n}\n\n/**\n * Single item API response\n */\nexport interface SingleResponse<T> {\n data: T\n}\n\n/**\n * Request configuration extending fetch options\n */\nexport interface RequestConfig extends RequestInit {\n params?: Record<string, string | number | boolean | undefined>\n}\n\n/**\n * Custom API Error class\n */\nexport class ApiError extends Error {\n status: number\n data: unknown\n\n constructor(message: string, status: number, data?: unknown) {\n super(message)\n this.name = 'ApiError'\n this.status = status\n this.data = data\n }\n}\n"],"mappings":"AAoCO,MAAM,iBAAiB,MAAM;AAAA,EAIlC,YAAY,SAAiB,QAAgB,MAAgB;AAC3D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
@@ -1,26 +0,0 @@
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 };
@@ -1,52 +0,0 @@
1
- import { apiClient } from '../client.js';
2
- import { ApiError } from '../client.types.js';
3
- const authApi = {
4
- /**
5
- * Login with email and password
6
- * Better Auth returns user and session info
7
- */
8
- async login(email, password) {
9
- const response = await apiClient.post("/api/auth/sign-in/email", {
10
- email,
11
- password
12
- });
13
- await apiClient.setUser(response.user);
14
- if (response.session?.token) {
15
- await apiClient.setToken(response.session.token);
16
- }
17
- return response;
18
- },
19
- /**
20
- * Logout - clear local auth and call server signout
21
- */
22
- async logout() {
23
- try {
24
- await apiClient.post("/api/auth/sign-out");
25
- } catch (error) {
26
- console.warn("[AuthApi] Failed to sign out from server:", error);
27
- }
28
- await apiClient.clearAuth();
29
- },
30
- /**
31
- * Get current session from server
32
- * Used to validate stored credentials and get fresh user data
33
- */
34
- async getSession() {
35
- try {
36
- const response = await apiClient.get("/api/auth/get-session");
37
- if (response.user) {
38
- await apiClient.setUser(response.user);
39
- }
40
- return response;
41
- } catch (error) {
42
- if (error instanceof ApiError && error.status === 401) {
43
- return null;
44
- }
45
- throw error;
46
- }
47
- }
48
- };
49
- export {
50
- authApi
51
- };
52
- //# sourceMappingURL=auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/api/core/auth.ts"],"sourcesContent":["/**\n * Auth API Service\n *\n * Authentication operations: login, logout, session management.\n */\n\nimport { apiClient } from '../client'\nimport { ApiError } from '../client.types'\nimport type { LoginResponse, SessionResponse } from './types'\n\nexport const authApi = {\n /**\n * Login with email and password\n * Better Auth returns user and session info\n */\n async login(email: string, password: string): Promise<LoginResponse> {\n const response = await apiClient.post<LoginResponse>('/api/auth/sign-in/email', {\n email,\n password,\n })\n\n // Store user info for session restoration\n await apiClient.setUser(response.user)\n\n // Store token if provided (Better Auth may return it for mobile clients)\n if (response.session?.token) {\n await apiClient.setToken(response.session.token)\n }\n\n return response\n },\n\n /**\n * Logout - clear local auth and call server signout\n */\n async logout(): Promise<void> {\n try {\n // Call server signout endpoint to invalidate session\n await apiClient.post('/api/auth/sign-out')\n } catch (error) {\n // Log error for debugging but continue with local cleanup\n // Server session may remain active if this fails (network issues)\n console.warn('[AuthApi] Failed to sign out from server:', error)\n }\n await apiClient.clearAuth()\n },\n\n /**\n * Get current session from server\n * Used to validate stored credentials and get fresh user data\n */\n async getSession(): Promise<SessionResponse | null> {\n try {\n const response = await apiClient.get<SessionResponse>('/api/auth/get-session')\n\n // Update stored user with fresh data\n if (response.user) {\n await apiClient.setUser(response.user)\n }\n\n return response\n } catch (error) {\n // Session invalid or expired\n if (error instanceof ApiError && error.status === 401) {\n return null\n }\n throw error\n }\n },\n}\n"],"mappings":"AAMA,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AAGlB,MAAM,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrB,MAAM,MAAM,OAAe,UAA0C;AACnE,UAAM,WAAW,MAAM,UAAU,KAAoB,2BAA2B;AAAA,MAC9E;AAAA,MACA;AAAA,IACF,CAAC;AAGD,UAAM,UAAU,QAAQ,SAAS,IAAI;AAGrC,QAAI,SAAS,SAAS,OAAO;AAC3B,YAAM,UAAU,SAAS,SAAS,QAAQ,KAAK;AAAA,IACjD;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,SAAwB;AAC5B,QAAI;AAEF,YAAM,UAAU,KAAK,oBAAoB;AAAA,IAC3C,SAAS,OAAO;AAGd,cAAQ,KAAK,6CAA6C,KAAK;AAAA,IACjE;AACA,UAAM,UAAU,UAAU;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,aAA8C;AAClD,QAAI;AACF,YAAM,WAAW,MAAM,UAAU,IAAqB,uBAAuB;AAG7E,UAAI,SAAS,MAAM;AACjB,cAAM,UAAU,QAAQ,SAAS,IAAI;AAAA,MACvC;AAEA,aAAO;AAAA,IACT,SAAS,OAAO;AAEd,UAAI,iBAAiB,YAAY,MAAM,WAAW,KAAK;AACrD,eAAO;AAAA,MACT;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
@@ -1,4 +0,0 @@
1
- export { authApi } from './auth.js';
2
- export { teamsApi } from './teams.js';
3
- export { UpdateProfileInput, UserPreferences, usersApi } from './users.js';
4
- export { AuthSession, LoginResponse, SessionResponse, Team, TeamsResponse, User } from './types.js';
@@ -1,5 +0,0 @@
1
- export * from './auth.js';
2
- export * from './teams.js';
3
- export * from './users.js';
4
- export * from './types.js';
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/api/core/index.ts"],"sourcesContent":["/**\n * Core API Services\n *\n * Authentication, teams, and user management.\n */\n\nexport * from './auth'\nexport * from './teams'\nexport * from './users'\nexport * from './types'\n"],"mappings":"AAMA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -1,20 +0,0 @@
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 };
@@ -1,19 +0,0 @@
1
- import { apiClient } from '../client.js';
2
- const teamsApi = {
3
- /**
4
- * Get user's teams
5
- */
6
- async getTeams() {
7
- return apiClient.get("/api/v1/teams");
8
- },
9
- /**
10
- * Switch to a different team
11
- */
12
- async switchTeam(teamId) {
13
- await apiClient.setTeamId(teamId);
14
- }
15
- };
16
- export {
17
- teamsApi
18
- };
19
- //# sourceMappingURL=teams.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/api/core/teams.ts"],"sourcesContent":["/**\n * Teams API Service\n *\n * Team management operations.\n */\n\nimport { apiClient } from '../client'\nimport type { TeamsResponse } from './types'\n\nexport const teamsApi = {\n /**\n * Get user's teams\n */\n async getTeams(): Promise<TeamsResponse> {\n return apiClient.get<TeamsResponse>('/api/v1/teams')\n },\n\n /**\n * Switch to a different team\n */\n async switchTeam(teamId: string): Promise<void> {\n await apiClient.setTeamId(teamId)\n },\n}\n"],"mappings":"AAMA,SAAS,iBAAiB;AAGnB,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA,EAItB,MAAM,WAAmC;AACvC,WAAO,UAAU,IAAmB,eAAe;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW,QAA+B;AAC9C,UAAM,UAAU,UAAU,MAAM;AAAA,EAClC;AACF;","names":[]}
@@ -1,58 +0,0 @@
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 };
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}