@insforge/sdk 0.0.14 → 0.0.16
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.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -385,14 +385,14 @@ declare class StorageBucket {
|
|
|
385
385
|
/**
|
|
386
386
|
* Upload a file with a specific key
|
|
387
387
|
* @param path - The object key/path
|
|
388
|
-
* @param file - File
|
|
388
|
+
* @param file - File or Blob to upload
|
|
389
389
|
*/
|
|
390
|
-
upload(path: string, file: File | Blob
|
|
390
|
+
upload(path: string, file: File | Blob): Promise<StorageResponse<StorageFileSchema>>;
|
|
391
391
|
/**
|
|
392
392
|
* Upload a file with auto-generated key
|
|
393
|
-
* @param file - File
|
|
393
|
+
* @param file - File or Blob to upload
|
|
394
394
|
*/
|
|
395
|
-
uploadAuto(file: File | Blob
|
|
395
|
+
uploadAuto(file: File | Blob): Promise<StorageResponse<StorageFileSchema>>;
|
|
396
396
|
/**
|
|
397
397
|
* Download a file
|
|
398
398
|
* @param path - The object key/path
|
package/dist/index.d.ts
CHANGED
|
@@ -385,14 +385,14 @@ declare class StorageBucket {
|
|
|
385
385
|
/**
|
|
386
386
|
* Upload a file with a specific key
|
|
387
387
|
* @param path - The object key/path
|
|
388
|
-
* @param file - File
|
|
388
|
+
* @param file - File or Blob to upload
|
|
389
389
|
*/
|
|
390
|
-
upload(path: string, file: File | Blob
|
|
390
|
+
upload(path: string, file: File | Blob): Promise<StorageResponse<StorageFileSchema>>;
|
|
391
391
|
/**
|
|
392
392
|
* Upload a file with auto-generated key
|
|
393
|
-
* @param file - File
|
|
393
|
+
* @param file - File or Blob to upload
|
|
394
394
|
*/
|
|
395
|
-
uploadAuto(file: File | Blob
|
|
395
|
+
uploadAuto(file: File | Blob): Promise<StorageResponse<StorageFileSchema>>;
|
|
396
396
|
/**
|
|
397
397
|
* Download a file
|
|
398
398
|
* @param path - The object key/path
|
package/dist/index.js
CHANGED
|
@@ -763,14 +763,12 @@ var StorageBucket = class {
|
|
|
763
763
|
/**
|
|
764
764
|
* Upload a file with a specific key
|
|
765
765
|
* @param path - The object key/path
|
|
766
|
-
* @param file - File
|
|
766
|
+
* @param file - File or Blob to upload
|
|
767
767
|
*/
|
|
768
768
|
async upload(path, file) {
|
|
769
769
|
try {
|
|
770
|
-
const formData =
|
|
771
|
-
|
|
772
|
-
formData.append("file", file);
|
|
773
|
-
}
|
|
770
|
+
const formData = new FormData();
|
|
771
|
+
formData.append("file", file);
|
|
774
772
|
const response = await this.http.request(
|
|
775
773
|
"PUT",
|
|
776
774
|
`/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`,
|
|
@@ -795,14 +793,12 @@ var StorageBucket = class {
|
|
|
795
793
|
}
|
|
796
794
|
/**
|
|
797
795
|
* Upload a file with auto-generated key
|
|
798
|
-
* @param file - File
|
|
796
|
+
* @param file - File or Blob to upload
|
|
799
797
|
*/
|
|
800
798
|
async uploadAuto(file) {
|
|
801
799
|
try {
|
|
802
|
-
const formData =
|
|
803
|
-
|
|
804
|
-
formData.append("file", file);
|
|
805
|
-
}
|
|
800
|
+
const formData = new FormData();
|
|
801
|
+
formData.append("file", file);
|
|
806
802
|
const response = await this.http.request(
|
|
807
803
|
"POST",
|
|
808
804
|
`/api/storage/buckets/${this.bucketName}/objects`,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/types.ts","../src/lib/http-client.ts","../src/lib/token-manager.ts","../src/modules/database.ts","../src/modules/auth.ts","../src/modules/storage.ts","../src/client.ts"],"sourcesContent":["/**\n * @insforge/sdk - TypeScript SDK for InsForge Backend-as-a-Service\n * \n * @packageDocumentation\n */\n\n// Main client\nexport { InsForgeClient } from './client';\n\n// Types\nexport type {\n InsForgeConfig,\n InsForgeConfig as ClientOptions, // Alias for compatibility\n TokenStorage,\n AuthSession,\n ApiError,\n} from './types';\n\nexport { InsForgeError } from './types';\n\n// Re-export shared schemas that SDK users will need\nexport type {\n UserSchema,\n CreateUserRequest,\n CreateSessionRequest,\n AuthErrorResponse,\n} from '@insforge/shared-schemas';\n\n// Re-export auth module for advanced usage\nexport { Auth } from './modules/auth';\n\n// Re-export database module and types\nexport { Database, QueryBuilder } from './modules/database';\nexport type { DatabaseResponse } from './modules/database';\n\n// Re-export storage module and types\nexport { Storage, StorageBucket } from './modules/storage';\nexport type { StorageResponse } from './modules/storage';\n\n// Re-export utilities for advanced usage\nexport { HttpClient } from './lib/http-client';\nexport { TokenManager } from './lib/token-manager';\n\n// Factory function for creating clients (Supabase-style)\nimport { InsForgeClient } from './client';\nimport { InsForgeConfig } from './types';\n\nexport function createClient(config: InsForgeConfig): InsForgeClient {\n return new InsForgeClient(config);\n}\n\n// Default export for convenience\nexport default InsForgeClient;","/**\n * InsForge SDK Types - only SDK-specific types here\n * Use @insforge/shared-schemas directly for API types\n */\n\nimport type { UserSchema } from '@insforge/shared-schemas';\n\nexport interface InsForgeConfig {\n /**\n * The URL of the InsForge backend API\n * @default \"http://localhost:7130\"\n */\n url?: string;\n\n /**\n * API key (optional)\n * Can be used for server-side operations or specific use cases\n */\n apiKey?: string;\n\n /**\n * Custom fetch implementation (useful for Node.js environments)\n */\n fetch?: typeof fetch;\n\n /**\n * Storage adapter for persisting tokens\n */\n storage?: TokenStorage;\n\n /**\n * Whether to automatically refresh tokens before they expire\n * @default true\n */\n autoRefreshToken?: boolean;\n\n /**\n * Whether to persist session in storage\n * @default true\n */\n persistSession?: boolean;\n\n /**\n * Custom headers to include with every request\n */\n headers?: Record<string, string>;\n}\n\nexport interface TokenStorage {\n getItem(key: string): string | null | Promise<string | null>;\n setItem(key: string, value: string): void | Promise<void>;\n removeItem(key: string): void | Promise<void>;\n}\n\nexport interface AuthSession {\n user: UserSchema;\n accessToken: string;\n expiresAt?: Date;\n}\n\nexport interface ApiError {\n error: string;\n message: string;\n statusCode: number;\n nextActions?: string;\n}\n\nexport class InsForgeError extends Error {\n public statusCode: number;\n public error: string;\n public nextActions?: string;\n\n constructor(message: string, statusCode: number, error: string, nextActions?: string) {\n super(message);\n this.name = 'InsForgeError';\n this.statusCode = statusCode;\n this.error = error;\n this.nextActions = nextActions;\n }\n\n static fromApiError(apiError: ApiError): InsForgeError {\n return new InsForgeError(\n apiError.message,\n apiError.statusCode,\n apiError.error,\n apiError.nextActions\n );\n }\n}","import { InsForgeConfig, ApiError, InsForgeError } from '../types';\n\nexport interface RequestOptions extends RequestInit {\n params?: Record<string, string>;\n}\n\nexport class HttpClient {\n public readonly baseUrl: string;\n public readonly fetch: typeof fetch;\n private defaultHeaders: Record<string, string>;\n\n constructor(config: InsForgeConfig) {\n this.baseUrl = config.url || 'http://localhost:7130';\n // Properly bind fetch to maintain its context\n this.fetch = config.fetch || (globalThis.fetch ? globalThis.fetch.bind(globalThis) : undefined as any);\n this.defaultHeaders = {\n ...config.headers,\n };\n \n // Add API key if provided\n if (config.apiKey) {\n this.defaultHeaders['Authorization'] = `Bearer ${config.apiKey}`;\n }\n\n if (!this.fetch) {\n throw new Error(\n 'Fetch is not available. Please provide a fetch implementation in the config.'\n );\n }\n }\n\n private buildUrl(path: string, params?: Record<string, string>): string {\n const url = new URL(path, this.baseUrl);\n if (params) {\n Object.entries(params).forEach(([key, value]) => {\n url.searchParams.append(key, value);\n });\n }\n return url.toString();\n }\n\n async request<T>(\n method: string,\n path: string,\n options: RequestOptions = {}\n ): Promise<T> {\n const { params, headers = {}, body, ...fetchOptions } = options;\n \n const url = this.buildUrl(path, params);\n \n const requestHeaders: Record<string, string> = {\n ...this.defaultHeaders,\n };\n \n // Handle body serialization\n let processedBody: any;\n if (body !== undefined) {\n // Check if body is FormData (for file uploads)\n if (typeof FormData !== 'undefined' && body instanceof FormData) {\n // Don't set Content-Type for FormData, let browser set it with boundary\n processedBody = body;\n } else {\n // JSON body\n if (method !== 'GET') {\n requestHeaders['Content-Type'] = 'application/json;charset=UTF-8';\n }\n processedBody = JSON.stringify(body);\n }\n }\n \n Object.assign(requestHeaders, headers);\n \n const response = await this.fetch(url, {\n method,\n headers: requestHeaders,\n body: processedBody,\n ...fetchOptions,\n });\n\n // Handle 204 No Content\n if (response.status === 204) {\n return undefined as T;\n }\n\n // Try to parse JSON response\n let data: any;\n const contentType = response.headers.get('content-type');\n // Check for any JSON content type (including PostgREST's vnd.pgrst.object+json)\n if (contentType?.includes('json')) {\n data = await response.json();\n } else {\n // For non-JSON responses, return text\n data = await response.text();\n }\n\n // Handle errors\n if (!response.ok) {\n if (data && typeof data === 'object' && 'error' in data) {\n throw InsForgeError.fromApiError(data as ApiError);\n }\n throw new InsForgeError(\n `Request failed: ${response.statusText}`,\n response.status,\n 'REQUEST_FAILED'\n );\n }\n\n return data as T;\n }\n\n get<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('GET', path, options);\n }\n\n post<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('POST', path, { ...options, body });\n }\n\n put<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('PUT', path, { ...options, body });\n }\n\n patch<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('PATCH', path, { ...options, body });\n }\n\n delete<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('DELETE', path, options);\n }\n\n setAuthToken(token: string | null) {\n if (token) {\n this.defaultHeaders['Authorization'] = `Bearer ${token}`;\n } else {\n delete this.defaultHeaders['Authorization'];\n }\n }\n\n getHeaders(): Record<string, string> {\n return { ...this.defaultHeaders };\n }\n}","import { TokenStorage, AuthSession } from '../types';\n\nconst TOKEN_KEY = 'insforge-auth-token';\nconst USER_KEY = 'insforge-auth-user';\n\nexport class TokenManager {\n private storage: TokenStorage;\n\n constructor(storage?: TokenStorage) {\n if (storage) {\n // Use provided storage\n this.storage = storage;\n } else if (typeof window !== 'undefined' && window.localStorage) {\n // Browser: use localStorage\n this.storage = window.localStorage;\n } else {\n // Node.js: use in-memory storage\n const store = new Map<string, string>();\n this.storage = {\n getItem: (key: string) => store.get(key) || null,\n setItem: (key: string, value: string) => { store.set(key, value); },\n removeItem: (key: string) => { store.delete(key); }\n };\n }\n }\n\n saveSession(session: AuthSession): void {\n this.storage.setItem(TOKEN_KEY, session.accessToken);\n this.storage.setItem(USER_KEY, JSON.stringify(session.user));\n }\n\n getSession(): AuthSession | null {\n const token = this.storage.getItem(TOKEN_KEY);\n const userStr = this.storage.getItem(USER_KEY);\n\n if (!token || !userStr) {\n return null;\n }\n\n try {\n const user = JSON.parse(userStr as string);\n return { accessToken: token as string, user };\n } catch {\n this.clearSession();\n return null;\n }\n }\n\n getAccessToken(): string | null {\n const token = this.storage.getItem(TOKEN_KEY);\n return typeof token === 'string' ? token : null;\n }\n\n clearSession(): void {\n this.storage.removeItem(TOKEN_KEY);\n this.storage.removeItem(USER_KEY);\n }\n}","/**\n * Database module for InsForge SDK\n * Supabase-style query builder for PostgREST operations\n */\n\nimport { HttpClient } from '../lib/http-client';\nimport { InsForgeError } from '../types';\n\nexport interface DatabaseResponse<T> {\n data: T | null;\n error: InsForgeError | null;\n count?: number;\n}\n\n/**\n * Query builder for database operations\n * Uses method chaining like Supabase\n */\nexport class QueryBuilder<T = any> {\n private method: 'GET' | 'POST' | 'PATCH' | 'DELETE' = 'GET';\n private headers: Record<string, string> = {};\n private queryParams: Record<string, string> = {};\n private body?: any;\n\n constructor(\n private table: string,\n private http: HttpClient\n ) {}\n\n /**\n * Perform a SELECT query\n * For mutations (insert/update/delete), this enables returning data\n * @param columns - Columns to select (default: '*')\n * @example\n * .select('*')\n * .select('id, title, content')\n * .select('*, users!inner(*)') // Join with users table\n * .select('*, profile:profiles(*)') // Join with alias\n * .insert({ title: 'New' }).select() // Returns inserted data\n */\n select(columns: string = '*'): this {\n // For mutations, add return=representation header\n if (this.method !== 'GET') {\n const existingPrefer = this.headers['Prefer'] || '';\n const preferParts = existingPrefer ? [existingPrefer] : [];\n if (!preferParts.some(p => p.includes('return='))) {\n preferParts.push('return=representation');\n }\n this.headers['Prefer'] = preferParts.join(',');\n }\n \n // Always set the select parameter for GET requests\n // This enables PostgREST joins and nested queries\n if (this.method === 'GET' && columns) {\n this.queryParams.select = columns;\n } else if (columns !== '*') {\n // For mutations, only set if not default\n this.queryParams.select = columns;\n }\n return this;\n }\n\n /**\n * Perform an INSERT\n * @param values - Single object or array of objects\n * @param options - { upsert: true } for upsert behavior\n * @example\n * .insert({ title: 'Hello', content: 'World' }).select()\n * .insert([{ title: 'Post 1' }, { title: 'Post 2' }]).select()\n */\n insert(values: Partial<T> | Partial<T>[], options?: { upsert?: boolean }): this {\n this.method = 'POST';\n this.body = Array.isArray(values) ? values : [values];\n \n if (options?.upsert) {\n this.headers['Prefer'] = 'resolution=merge-duplicates';\n }\n \n return this;\n }\n\n /**\n * Perform an UPDATE\n * @param values - Object with fields to update\n * @example\n * .update({ title: 'Updated Title' }).select()\n */\n update(values: Partial<T>): this {\n this.method = 'PATCH';\n this.body = values;\n return this;\n }\n\n /**\n * Perform a DELETE\n * @example\n * .delete().select()\n */\n delete(): this {\n this.method = 'DELETE';\n return this;\n }\n\n /**\n * Perform an UPSERT\n * @param values - Single object or array of objects\n * @example\n * .upsert({ id: 1, title: 'Hello' })\n */\n upsert(values: Partial<T> | Partial<T>[]): this {\n return this.insert(values, { upsert: true });\n }\n\n // FILTERS\n\n /**\n * Filter by column equal to value\n * @example .eq('id', 123)\n */\n eq(column: string, value: any): this {\n this.queryParams[column] = `eq.${value}`;\n return this;\n }\n\n /**\n * Filter by column not equal to value\n * @example .neq('status', 'draft')\n */\n neq(column: string, value: any): this {\n this.queryParams[column] = `neq.${value}`;\n return this;\n }\n\n /**\n * Filter by column greater than value\n * @example .gt('age', 18)\n */\n gt(column: string, value: any): this {\n this.queryParams[column] = `gt.${value}`;\n return this;\n }\n\n /**\n * Filter by column greater than or equal to value\n * @example .gte('price', 100)\n */\n gte(column: string, value: any): this {\n this.queryParams[column] = `gte.${value}`;\n return this;\n }\n\n /**\n * Filter by column less than value\n * @example .lt('stock', 10)\n */\n lt(column: string, value: any): this {\n this.queryParams[column] = `lt.${value}`;\n return this;\n }\n\n /**\n * Filter by column less than or equal to value\n * @example .lte('discount', 50)\n */\n lte(column: string, value: any): this {\n this.queryParams[column] = `lte.${value}`;\n return this;\n }\n\n /**\n * Filter by pattern matching (case-sensitive)\n * @example .like('email', '%@gmail.com')\n */\n like(column: string, pattern: string): this {\n this.queryParams[column] = `like.${pattern}`;\n return this;\n }\n\n /**\n * Filter by pattern matching (case-insensitive)\n * @example .ilike('name', '%john%')\n */\n ilike(column: string, pattern: string): this {\n this.queryParams[column] = `ilike.${pattern}`;\n return this;\n }\n\n /**\n * Filter by checking if column is a value\n * @example .is('deleted_at', null)\n */\n is(column: string, value: null | boolean): this {\n if (value === null) {\n this.queryParams[column] = 'is.null';\n } else {\n this.queryParams[column] = `is.${value}`;\n }\n return this;\n }\n\n /**\n * Filter by checking if value is in array\n * @example .in('status', ['active', 'pending'])\n */\n in(column: string, values: any[]): this {\n this.queryParams[column] = `in.(${values.join(',')})`;\n return this;\n }\n\n // MODIFIERS\n\n /**\n * Order by column\n * @example \n * .order('created_at') // ascending\n * .order('created_at', { ascending: false }) // descending\n */\n order(column: string, options?: { ascending?: boolean }): this {\n const ascending = options?.ascending !== false;\n this.queryParams.order = ascending ? column : `${column}.desc`;\n return this;\n }\n\n /**\n * Limit the number of rows returned\n * @example .limit(10)\n */\n limit(count: number): this {\n this.queryParams.limit = count.toString();\n return this;\n }\n\n /**\n * Return results from an offset\n * @example .offset(20)\n */\n offset(count: number): this {\n this.queryParams.offset = count.toString();\n return this;\n }\n\n /**\n * Set a range of rows to return\n * @example .range(0, 9) // First 10 rows\n */\n range(from: number, to: number): this {\n this.headers['Range'] = `${from}-${to}`;\n return this;\n }\n\n /**\n * Return a single object instead of array\n * @example .single()\n */\n single(): this {\n this.headers['Accept'] = 'application/vnd.pgrst.object+json';\n return this;\n }\n\n /**\n * Get the total count (use with select)\n * @example .select('*', { count: 'exact' })\n */\n count(algorithm: 'exact' | 'planned' | 'estimated' = 'exact'): this {\n const prefer = this.headers['Prefer'] || '';\n this.headers['Prefer'] = prefer ? `${prefer},count=${algorithm}` : `count=${algorithm}`;\n return this;\n }\n\n /**\n * Execute the query and return results\n */\n async execute(): Promise<DatabaseResponse<T>> {\n try {\n const path = `/api/database/records/${this.table}`;\n let response: any;\n\n switch (this.method) {\n case 'GET':\n response = await this.http.get<T>(path, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n \n case 'POST':\n response = await this.http.post<T>(path, this.body, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n \n case 'PATCH':\n response = await this.http.patch<T>(path, this.body, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n \n case 'DELETE':\n response = await this.http.delete<T>(path, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n }\n\n return { data: response, error: null };\n } catch (error) {\n return {\n data: null,\n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Database operation failed',\n 500,\n 'DATABASE_ERROR'\n )\n };\n }\n }\n\n /**\n * Make QueryBuilder thenable for async/await\n */\n then<TResult1 = DatabaseResponse<T>, TResult2 = never>(\n onfulfilled?: ((value: DatabaseResponse<T>) => TResult1 | PromiseLike<TResult1>) | undefined | null,\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null\n ): Promise<TResult1 | TResult2> {\n return this.execute().then(onfulfilled, onrejected);\n }\n}\n\n/**\n * Database client for InsForge SDK\n * Provides Supabase-style interface\n */\nexport class Database {\n constructor(private http: HttpClient) {}\n\n /**\n * Create a query builder for a table\n * @param table - The table name\n * @example\n * const { data, error } = await client.database\n * .from('posts')\n * .select('*')\n * .eq('user_id', userId)\n * .order('created_at', { ascending: false })\n * .limit(10);\n */\n from<T = any>(table: string): QueryBuilder<T> {\n return new QueryBuilder<T>(table, this.http);\n }\n}","/**\n * Auth module for InsForge SDK\n * Uses shared schemas for type safety\n */\n\nimport { HttpClient } from '../lib/http-client';\nimport { TokenManager } from '../lib/token-manager';\nimport { AuthSession, InsForgeError } from '../types';\nimport { Database } from './database';\n\nimport type {\n CreateUserRequest,\n CreateUserResponse,\n CreateSessionRequest,\n CreateSessionResponse,\n GetCurrentSessionResponse,\n GetOauthUrlResponse,\n} from '@insforge/shared-schemas';\n\nexport class Auth {\n private database: Database;\n \n constructor(\n private http: HttpClient,\n private tokenManager: TokenManager\n ) {\n this.database = new Database(http);\n \n // Auto-detect OAuth callback parameters in the URL\n this.detectOAuthCallback();\n }\n\n /**\n * Automatically detect and handle OAuth callback parameters in the URL\n * This runs on initialization to seamlessly complete the OAuth flow\n * Matches the backend's OAuth callback response (backend/src/api/routes/auth.ts:540-544)\n */\n private detectOAuthCallback(): void {\n // Only run in browser environment\n if (typeof window === 'undefined') return;\n \n try {\n const params = new URLSearchParams(window.location.search);\n \n // Backend returns: access_token, user_id, email, name (optional)\n const accessToken = params.get('access_token');\n const userId = params.get('user_id');\n const email = params.get('email');\n const name = params.get('name');\n \n // Check if we have OAuth callback parameters\n if (accessToken && userId && email) {\n // Create session with the data from backend\n const session: AuthSession = {\n accessToken,\n user: {\n id: userId,\n email: email,\n name: name || '',\n // These fields are not provided by backend OAuth callback\n // They'll be populated when calling getCurrentUser()\n emailVerified: false,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n } as any,\n };\n \n // Save session and set auth token\n this.tokenManager.saveSession(session);\n this.http.setAuthToken(accessToken);\n \n // Clean up the URL to remove sensitive parameters\n const url = new URL(window.location.href);\n url.searchParams.delete('access_token');\n url.searchParams.delete('user_id');\n url.searchParams.delete('email');\n url.searchParams.delete('name');\n \n // Also handle error case from backend (line 581)\n if (params.has('error')) {\n url.searchParams.delete('error');\n }\n \n // Replace URL without adding to browser history\n window.history.replaceState({}, document.title, url.toString());\n }\n } catch (error) {\n // Silently continue - don't break initialization\n console.debug('OAuth callback detection skipped:', error);\n }\n }\n\n /**\n * Sign up a new user\n */\n async signUp(request: CreateUserRequest): Promise<{\n data: CreateUserResponse | null;\n error: InsForgeError | null;\n }> {\n try {\n const response = await this.http.post<CreateUserResponse>('/api/auth/users', request);\n \n // Save session internally\n const session: AuthSession = {\n accessToken: response.accessToken,\n user: response.user,\n };\n this.tokenManager.saveSession(session);\n this.http.setAuthToken(response.accessToken);\n\n return { \n data: response,\n error: null \n };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: null, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: null, \n error: new InsForgeError(\n error instanceof Error ? error.message : 'An unexpected error occurred during sign up',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Sign in with email and password\n */\n async signInWithPassword(request: CreateSessionRequest): Promise<{\n data: CreateSessionResponse | null;\n error: InsForgeError | null;\n }> {\n try {\n const response = await this.http.post<CreateSessionResponse>('/api/auth/sessions', request);\n \n // Save session internally\n const session: AuthSession = {\n accessToken: response.accessToken,\n user: response.user,\n };\n this.tokenManager.saveSession(session);\n this.http.setAuthToken(response.accessToken);\n\n return { \n data: response,\n error: null \n };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: null, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: null, \n error: new InsForgeError(\n 'An unexpected error occurred during sign in',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Sign in with OAuth provider\n */\n async signInWithOAuth(options: {\n provider: 'google' | 'github';\n redirectTo?: string;\n skipBrowserRedirect?: boolean;\n }): Promise<{\n data: { url?: string; provider?: string };\n error: InsForgeError | null;\n }> {\n try {\n const { provider, redirectTo, skipBrowserRedirect } = options;\n \n const params = redirectTo \n ? { redirect_uri: redirectTo } \n : undefined;\n \n const endpoint = `/api/auth/oauth/${provider}`;\n const response = await this.http.get<GetOauthUrlResponse>(endpoint, { params });\n \n // Automatically redirect in browser unless told not to\n if (typeof window !== 'undefined' && !skipBrowserRedirect) {\n window.location.href = response.authUrl;\n return { data: {}, error: null };\n }\n\n return { \n data: { \n url: response.authUrl,\n provider \n }, \n error: null \n };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: {}, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: {}, \n error: new InsForgeError(\n 'An unexpected error occurred during OAuth initialization',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Sign out the current user\n */\n async signOut(): Promise<{ error: InsForgeError | null }> {\n try {\n this.tokenManager.clearSession();\n this.http.setAuthToken(null);\n return { error: null };\n } catch (error) {\n return { \n error: new InsForgeError(\n 'Failed to sign out',\n 500,\n 'SIGNOUT_ERROR'\n )\n };\n }\n }\n\n /**\n * Get the current user with full profile information\n * Returns both auth info (id, email, role) and profile data (nickname, avatar_url, bio, etc.)\n */\n async getCurrentUser(): Promise<{\n data: { user: any; profile: any } | null;\n error: InsForgeError | null;\n }> {\n try {\n // Check if we have a token\n const session = this.tokenManager.getSession();\n if (!session?.accessToken) {\n return { data: null, error: null };\n }\n\n // Call the API for auth info\n this.http.setAuthToken(session.accessToken);\n const authResponse = await this.http.get<GetCurrentSessionResponse>('/api/auth/sessions/current');\n \n // Get the user's profile using query builder\n const { data: profile, error: profileError } = await this.database\n .from('users')\n .select('*')\n .eq('id', authResponse.user.id)\n .single();\n \n if (profileError && profileError.statusCode !== 406) { // 406 = not found\n return { data: null, error: profileError };\n }\n \n return {\n data: {\n user: authResponse.user,\n profile: profile\n },\n error: null\n };\n } catch (error) {\n // If unauthorized, clear session\n if (error instanceof InsForgeError && error.statusCode === 401) {\n await this.signOut();\n return { data: null, error: null };\n }\n \n // Pass through all other errors unchanged\n if (error instanceof InsForgeError) {\n return { data: null, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: null, \n error: new InsForgeError(\n 'An unexpected error occurred while fetching user',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Get any user's profile by ID\n * Returns profile information from the users table (nickname, avatar_url, bio, etc.)\n */\n async getProfile(userId: string): Promise<{\n data: any | null;\n error: InsForgeError | null;\n }> {\n const { data, error } = await this.database\n .from('users')\n .select('*')\n .eq('id', userId)\n .single();\n \n // Handle not found as null, not error\n if (error && error.statusCode === 406) {\n return { data: null, error: null };\n }\n \n return { data, error };\n }\n\n /**\n * Get the current session (only session data, no API call)\n * Returns the stored JWT token and basic user info from local storage\n */\n async getCurrentSession(): Promise<{\n data: { session: AuthSession | null };\n error: InsForgeError | null;\n }> {\n try {\n const session = this.tokenManager.getSession();\n \n if (session?.accessToken) {\n this.http.setAuthToken(session.accessToken);\n return { data: { session }, error: null };\n }\n\n return { data: { session: null }, error: null };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: { session: null }, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: { session: null }, \n error: new InsForgeError(\n 'An unexpected error occurred while getting session',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Set/Update the current user's profile\n * Updates profile information in the users table (nickname, avatar_url, bio, etc.)\n */\n async setProfile(profile: {\n nickname?: string;\n avatar_url?: string;\n bio?: string;\n birthday?: string;\n [key: string]: any;\n }): Promise<{\n data: any | null;\n error: InsForgeError | null;\n }> {\n // Get current session to get user ID\n const session = this.tokenManager.getSession();\n if (!session?.user?.id) {\n return { \n data: null, \n error: new InsForgeError(\n 'No authenticated user found',\n 401,\n 'UNAUTHENTICATED'\n )\n };\n }\n\n // Update the profile using query builder\n return await this.database\n .from('users')\n .update(profile)\n .eq('id', session.user.id)\n .select()\n .single();\n }\n\n\n}","/**\n * Storage module for InsForge SDK\n * Handles file uploads, downloads, and bucket management\n */\n\nimport { HttpClient } from '../lib/http-client';\nimport { InsForgeError } from '../types';\nimport type { \n StorageFileSchema,\n ListObjectsResponseSchema\n} from '@insforge/shared-schemas';\n\nexport interface StorageResponse<T> {\n data: T | null;\n error: InsForgeError | null;\n}\n\n/**\n * Storage bucket operations\n */\nexport class StorageBucket {\n constructor(\n private bucketName: string,\n private http: HttpClient\n ) {}\n\n /**\n * Upload a file with a specific key\n * @param path - The object key/path\n * @param file - File, Blob, or FormData to upload\n */\n async upload(\n path: string,\n file: File | Blob | FormData\n ): Promise<StorageResponse<StorageFileSchema>> {\n try {\n const formData = file instanceof FormData ? file : new FormData();\n \n if (!(file instanceof FormData)) {\n formData.append('file', file);\n }\n\n // Use PUT for specific path\n const response = await this.http.request<StorageFileSchema>(\n 'PUT',\n `/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`,\n {\n body: formData as any,\n headers: {\n // Don't set Content-Type, let browser set multipart boundary\n }\n }\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Upload failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Upload a file with auto-generated key\n * @param file - File, Blob, or FormData to upload\n */\n async uploadAuto(\n file: File | Blob | FormData\n ): Promise<StorageResponse<StorageFileSchema>> {\n try {\n const formData = file instanceof FormData ? file : new FormData();\n \n if (!(file instanceof FormData)) {\n formData.append('file', file);\n }\n\n // Use POST for auto-generated key\n const response = await this.http.request<StorageFileSchema>(\n 'POST',\n `/api/storage/buckets/${this.bucketName}/objects`,\n {\n body: formData as any,\n headers: {\n // Don't set Content-Type, let browser set multipart boundary\n }\n }\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Upload failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Download a file\n * @param path - The object key/path\n * Returns the file as a Blob\n */\n async download(path: string): Promise<{ data: Blob | null; error: InsForgeError | null }> {\n try {\n // For binary data, we need to use fetch directly with proper response handling\n // The http.request method expects JSON responses, so we can't use it for blobs\n const url = `${this.http.baseUrl}/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`;\n \n const response = await this.http.fetch(url, {\n method: 'GET',\n headers: this.http.getHeaders()\n });\n\n if (!response.ok) {\n try {\n const error = await response.json();\n throw InsForgeError.fromApiError(error);\n } catch {\n throw new InsForgeError(\n `Download failed: ${response.statusText}`,\n response.status,\n 'STORAGE_ERROR'\n );\n }\n }\n\n const blob = await response.blob();\n return { data: blob, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Download failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Get public URL for a file\n * @param path - The object key/path\n */\n getPublicUrl(path: string): string {\n return `${this.http.baseUrl}/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`;\n }\n\n /**\n * List objects in the bucket\n * @param prefix - Filter by key prefix\n * @param search - Search in file names\n * @param limit - Maximum number of results (default: 100, max: 1000)\n * @param offset - Number of results to skip\n */\n async list(options?: {\n prefix?: string;\n search?: string;\n limit?: number;\n offset?: number;\n }): Promise<StorageResponse<ListObjectsResponseSchema>> {\n try {\n const params: Record<string, string> = {};\n \n if (options?.prefix) params.prefix = options.prefix;\n if (options?.search) params.search = options.search;\n if (options?.limit) params.limit = options.limit.toString();\n if (options?.offset) params.offset = options.offset.toString();\n\n const response = await this.http.get<ListObjectsResponseSchema>(\n `/api/storage/buckets/${this.bucketName}/objects`,\n { params }\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'List failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Delete a file\n * @param path - The object key/path\n */\n async remove(path: string): Promise<StorageResponse<{ message: string }>> {\n try {\n const response = await this.http.delete<{ message: string }>(\n `/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Delete failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n}\n\n/**\n * Storage module for file operations\n */\nexport class Storage {\n constructor(private http: HttpClient) {}\n\n /**\n * Get a bucket instance for operations\n * @param bucketName - Name of the bucket\n */\n from(bucketName: string): StorageBucket {\n return new StorageBucket(bucketName, this.http);\n }\n}","import { InsForgeConfig } from './types';\nimport { HttpClient } from './lib/http-client';\nimport { TokenManager } from './lib/token-manager';\nimport { Auth } from './modules/auth';\nimport { Database } from './modules/database';\nimport { Storage } from './modules/storage';\n\n/**\n * Main InsForge SDK Client\n * \n * @example\n * ```typescript\n * import { InsForgeClient } from '@insforge/sdk';\n * \n * const client = new InsForgeClient({\n * baseUrl: 'http://localhost:7130'\n * });\n * \n * // Authentication\n * const session = await client.auth.register({\n * email: 'user@example.com',\n * password: 'password123',\n * name: 'John Doe'\n * });\n * \n * // Database operations\n * const { data, error } = await client.database\n * .from('posts')\n * .select('*')\n * .eq('user_id', session.user.id)\n * .order('created_at', { ascending: false })\n * .limit(10);\n * \n * // Insert data\n * const { data: newPost } = await client.database\n * .from('posts')\n * .insert({ title: 'Hello', content: 'World' })\n * .single();\n * ```\n */\nexport class InsForgeClient {\n private http: HttpClient;\n private tokenManager: TokenManager;\n \n public readonly auth: Auth;\n public readonly database: Database;\n public readonly storage: Storage;\n\n constructor(config: InsForgeConfig = {}) {\n this.http = new HttpClient(config);\n this.tokenManager = new TokenManager(config.storage);\n \n this.auth = new Auth(\n this.http,\n this.tokenManager\n );\n \n this.database = new Database(this.http);\n this.storage = new Storage(this.http);\n }\n\n\n /**\n * Set a custom API key for authentication\n * This is useful for server-to-server communication\n * \n * @param apiKey - The API key (should start with 'ik_')\n * \n * @example\n * ```typescript\n * client.setApiKey('ik_your_api_key_here');\n * ```\n */\n setApiKey(apiKey: string): void {\n // API keys can be used as Bearer tokens\n this.http.setAuthToken(apiKey);\n }\n\n /**\n * Get the underlying HTTP client for custom requests\n * \n * @example\n * ```typescript\n * const httpClient = client.getHttpClient();\n * const customData = await httpClient.get('/api/custom-endpoint');\n * ```\n */\n getHttpClient(): HttpClient {\n return this.http;\n }\n\n /**\n * Future modules will be added here:\n * - database: Database operations\n * - storage: File storage operations\n * - functions: Serverless functions\n * - tables: Table management\n * - metadata: Backend metadata\n */\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmEO,IAAM,gBAAN,MAAM,uBAAsB,MAAM;AAAA,EAKvC,YAAY,SAAiB,YAAoB,OAAe,aAAsB;AACpF,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,QAAQ;AACb,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,OAAO,aAAa,UAAmC;AACrD,WAAO,IAAI;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAAA,EACF;AACF;;;AClFO,IAAM,aAAN,MAAiB;AAAA,EAKtB,YAAY,QAAwB;AAClC,SAAK,UAAU,OAAO,OAAO;AAE7B,SAAK,QAAQ,OAAO,UAAU,WAAW,QAAQ,WAAW,MAAM,KAAK,UAAU,IAAI;AACrF,SAAK,iBAAiB;AAAA,MACpB,GAAG,OAAO;AAAA,IACZ;AAGA,QAAI,OAAO,QAAQ;AACjB,WAAK,eAAe,eAAe,IAAI,UAAU,OAAO,MAAM;AAAA,IAChE;AAEA,QAAI,CAAC,KAAK,OAAO;AACf,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEQ,SAAS,MAAc,QAAyC;AACtE,UAAM,MAAM,IAAI,IAAI,MAAM,KAAK,OAAO;AACtC,QAAI,QAAQ;AACV,aAAO,QAAQ,MAAM,EAAE,QAAQ,CAAC,CAAC,K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C/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,gBAA4B;AAC1B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUF;;;APpDO,SAAS,aAAa,QAAwC;AACnE,SAAO,IAAI,eAAe,MAAM;AAClC;AAGA,IAAO,gBAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/types.ts","../src/lib/http-client.ts","../src/lib/token-manager.ts","../src/modules/database.ts","../src/modules/auth.ts","../src/modules/storage.ts","../src/client.ts"],"sourcesContent":["/**\n * @insforge/sdk - TypeScript SDK for InsForge Backend-as-a-Service\n * \n * @packageDocumentation\n */\n\n// Main client\nexport { InsForgeClient } from './client';\n\n// Types\nexport type {\n InsForgeConfig,\n InsForgeConfig as ClientOptions, // Alias for compatibility\n TokenStorage,\n AuthSession,\n ApiError,\n} from './types';\n\nexport { InsForgeError } from './types';\n\n// Re-export shared schemas that SDK users will need\nexport type {\n UserSchema,\n CreateUserRequest,\n CreateSessionRequest,\n AuthErrorResponse,\n} from '@insforge/shared-schemas';\n\n// Re-export auth module for advanced usage\nexport { Auth } from './modules/auth';\n\n// Re-export database module and types\nexport { Database, QueryBuilder } from './modules/database';\nexport type { DatabaseResponse } from './modules/database';\n\n// Re-export storage module and types\nexport { Storage, StorageBucket } from './modules/storage';\nexport type { StorageResponse } from './modules/storage';\n\n// Re-export utilities for advanced usage\nexport { HttpClient } from './lib/http-client';\nexport { TokenManager } from './lib/token-manager';\n\n// Factory function for creating clients (Supabase-style)\nimport { InsForgeClient } from './client';\nimport { InsForgeConfig } from './types';\n\nexport function createClient(config: InsForgeConfig): InsForgeClient {\n return new InsForgeClient(config);\n}\n\n// Default export for convenience\nexport default InsForgeClient;","/**\n * InsForge SDK Types - only SDK-specific types here\n * Use @insforge/shared-schemas directly for API types\n */\n\nimport type { UserSchema } from '@insforge/shared-schemas';\n\nexport interface InsForgeConfig {\n /**\n * The URL of the InsForge backend API\n * @default \"http://localhost:7130\"\n */\n url?: string;\n\n /**\n * API key (optional)\n * Can be used for server-side operations or specific use cases\n */\n apiKey?: string;\n\n /**\n * Custom fetch implementation (useful for Node.js environments)\n */\n fetch?: typeof fetch;\n\n /**\n * Storage adapter for persisting tokens\n */\n storage?: TokenStorage;\n\n /**\n * Whether to automatically refresh tokens before they expire\n * @default true\n */\n autoRefreshToken?: boolean;\n\n /**\n * Whether to persist session in storage\n * @default true\n */\n persistSession?: boolean;\n\n /**\n * Custom headers to include with every request\n */\n headers?: Record<string, string>;\n}\n\nexport interface TokenStorage {\n getItem(key: string): string | null | Promise<string | null>;\n setItem(key: string, value: string): void | Promise<void>;\n removeItem(key: string): void | Promise<void>;\n}\n\nexport interface AuthSession {\n user: UserSchema;\n accessToken: string;\n expiresAt?: Date;\n}\n\nexport interface ApiError {\n error: string;\n message: string;\n statusCode: number;\n nextActions?: string;\n}\n\nexport class InsForgeError extends Error {\n public statusCode: number;\n public error: string;\n public nextActions?: string;\n\n constructor(message: string, statusCode: number, error: string, nextActions?: string) {\n super(message);\n this.name = 'InsForgeError';\n this.statusCode = statusCode;\n this.error = error;\n this.nextActions = nextActions;\n }\n\n static fromApiError(apiError: ApiError): InsForgeError {\n return new InsForgeError(\n apiError.message,\n apiError.statusCode,\n apiError.error,\n apiError.nextActions\n );\n }\n}","import { InsForgeConfig, ApiError, InsForgeError } from '../types';\n\nexport interface RequestOptions extends RequestInit {\n params?: Record<string, string>;\n}\n\nexport class HttpClient {\n public readonly baseUrl: string;\n public readonly fetch: typeof fetch;\n private defaultHeaders: Record<string, string>;\n\n constructor(config: InsForgeConfig) {\n this.baseUrl = config.url || 'http://localhost:7130';\n // Properly bind fetch to maintain its context\n this.fetch = config.fetch || (globalThis.fetch ? globalThis.fetch.bind(globalThis) : undefined as any);\n this.defaultHeaders = {\n ...config.headers,\n };\n \n // Add API key if provided\n if (config.apiKey) {\n this.defaultHeaders['Authorization'] = `Bearer ${config.apiKey}`;\n }\n\n if (!this.fetch) {\n throw new Error(\n 'Fetch is not available. Please provide a fetch implementation in the config.'\n );\n }\n }\n\n private buildUrl(path: string, params?: Record<string, string>): string {\n const url = new URL(path, this.baseUrl);\n if (params) {\n Object.entries(params).forEach(([key, value]) => {\n url.searchParams.append(key, value);\n });\n }\n return url.toString();\n }\n\n async request<T>(\n method: string,\n path: string,\n options: RequestOptions = {}\n ): Promise<T> {\n const { params, headers = {}, body, ...fetchOptions } = options;\n \n const url = this.buildUrl(path, params);\n \n const requestHeaders: Record<string, string> = {\n ...this.defaultHeaders,\n };\n \n // Handle body serialization\n let processedBody: any;\n if (body !== undefined) {\n // Check if body is FormData (for file uploads)\n if (typeof FormData !== 'undefined' && body instanceof FormData) {\n // Don't set Content-Type for FormData, let browser set it with boundary\n processedBody = body;\n } else {\n // JSON body\n if (method !== 'GET') {\n requestHeaders['Content-Type'] = 'application/json;charset=UTF-8';\n }\n processedBody = JSON.stringify(body);\n }\n }\n \n Object.assign(requestHeaders, headers);\n \n const response = await this.fetch(url, {\n method,\n headers: requestHeaders,\n body: processedBody,\n ...fetchOptions,\n });\n\n // Handle 204 No Content\n if (response.status === 204) {\n return undefined as T;\n }\n\n // Try to parse JSON response\n let data: any;\n const contentType = response.headers.get('content-type');\n // Check for any JSON content type (including PostgREST's vnd.pgrst.object+json)\n if (contentType?.includes('json')) {\n data = await response.json();\n } else {\n // For non-JSON responses, return text\n data = await response.text();\n }\n\n // Handle errors\n if (!response.ok) {\n if (data && typeof data === 'object' && 'error' in data) {\n throw InsForgeError.fromApiError(data as ApiError);\n }\n throw new InsForgeError(\n `Request failed: ${response.statusText}`,\n response.status,\n 'REQUEST_FAILED'\n );\n }\n\n return data as T;\n }\n\n get<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('GET', path, options);\n }\n\n post<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('POST', path, { ...options, body });\n }\n\n put<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('PUT', path, { ...options, body });\n }\n\n patch<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('PATCH', path, { ...options, body });\n }\n\n delete<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('DELETE', path, options);\n }\n\n setAuthToken(token: string | null) {\n if (token) {\n this.defaultHeaders['Authorization'] = `Bearer ${token}`;\n } else {\n delete this.defaultHeaders['Authorization'];\n }\n }\n\n getHeaders(): Record<string, string> {\n return { ...this.defaultHeaders };\n }\n}","import { TokenStorage, AuthSession } from '../types';\n\nconst TOKEN_KEY = 'insforge-auth-token';\nconst USER_KEY = 'insforge-auth-user';\n\nexport class TokenManager {\n private storage: TokenStorage;\n\n constructor(storage?: TokenStorage) {\n if (storage) {\n // Use provided storage\n this.storage = storage;\n } else if (typeof window !== 'undefined' && window.localStorage) {\n // Browser: use localStorage\n this.storage = window.localStorage;\n } else {\n // Node.js: use in-memory storage\n const store = new Map<string, string>();\n this.storage = {\n getItem: (key: string) => store.get(key) || null,\n setItem: (key: string, value: string) => { store.set(key, value); },\n removeItem: (key: string) => { store.delete(key); }\n };\n }\n }\n\n saveSession(session: AuthSession): void {\n this.storage.setItem(TOKEN_KEY, session.accessToken);\n this.storage.setItem(USER_KEY, JSON.stringify(session.user));\n }\n\n getSession(): AuthSession | null {\n const token = this.storage.getItem(TOKEN_KEY);\n const userStr = this.storage.getItem(USER_KEY);\n\n if (!token || !userStr) {\n return null;\n }\n\n try {\n const user = JSON.parse(userStr as string);\n return { accessToken: token as string, user };\n } catch {\n this.clearSession();\n return null;\n }\n }\n\n getAccessToken(): string | null {\n const token = this.storage.getItem(TOKEN_KEY);\n return typeof token === 'string' ? token : null;\n }\n\n clearSession(): void {\n this.storage.removeItem(TOKEN_KEY);\n this.storage.removeItem(USER_KEY);\n }\n}","/**\n * Database module for InsForge SDK\n * Supabase-style query builder for PostgREST operations\n */\n\nimport { HttpClient } from '../lib/http-client';\nimport { InsForgeError } from '../types';\n\nexport interface DatabaseResponse<T> {\n data: T | null;\n error: InsForgeError | null;\n count?: number;\n}\n\n/**\n * Query builder for database operations\n * Uses method chaining like Supabase\n */\nexport class QueryBuilder<T = any> {\n private method: 'GET' | 'POST' | 'PATCH' | 'DELETE' = 'GET';\n private headers: Record<string, string> = {};\n private queryParams: Record<string, string> = {};\n private body?: any;\n\n constructor(\n private table: string,\n private http: HttpClient\n ) {}\n\n /**\n * Perform a SELECT query\n * For mutations (insert/update/delete), this enables returning data\n * @param columns - Columns to select (default: '*')\n * @example\n * .select('*')\n * .select('id, title, content')\n * .select('*, users!inner(*)') // Join with users table\n * .select('*, profile:profiles(*)') // Join with alias\n * .insert({ title: 'New' }).select() // Returns inserted data\n */\n select(columns: string = '*'): this {\n // For mutations, add return=representation header\n if (this.method !== 'GET') {\n const existingPrefer = this.headers['Prefer'] || '';\n const preferParts = existingPrefer ? [existingPrefer] : [];\n if (!preferParts.some(p => p.includes('return='))) {\n preferParts.push('return=representation');\n }\n this.headers['Prefer'] = preferParts.join(',');\n }\n \n // Always set the select parameter for GET requests\n // This enables PostgREST joins and nested queries\n if (this.method === 'GET' && columns) {\n this.queryParams.select = columns;\n } else if (columns !== '*') {\n // For mutations, only set if not default\n this.queryParams.select = columns;\n }\n return this;\n }\n\n /**\n * Perform an INSERT\n * @param values - Single object or array of objects\n * @param options - { upsert: true } for upsert behavior\n * @example\n * .insert({ title: 'Hello', content: 'World' }).select()\n * .insert([{ title: 'Post 1' }, { title: 'Post 2' }]).select()\n */\n insert(values: Partial<T> | Partial<T>[], options?: { upsert?: boolean }): this {\n this.method = 'POST';\n this.body = Array.isArray(values) ? values : [values];\n \n if (options?.upsert) {\n this.headers['Prefer'] = 'resolution=merge-duplicates';\n }\n \n return this;\n }\n\n /**\n * Perform an UPDATE\n * @param values - Object with fields to update\n * @example\n * .update({ title: 'Updated Title' }).select()\n */\n update(values: Partial<T>): this {\n this.method = 'PATCH';\n this.body = values;\n return this;\n }\n\n /**\n * Perform a DELETE\n * @example\n * .delete().select()\n */\n delete(): this {\n this.method = 'DELETE';\n return this;\n }\n\n /**\n * Perform an UPSERT\n * @param values - Single object or array of objects\n * @example\n * .upsert({ id: 1, title: 'Hello' })\n */\n upsert(values: Partial<T> | Partial<T>[]): this {\n return this.insert(values, { upsert: true });\n }\n\n // FILTERS\n\n /**\n * Filter by column equal to value\n * @example .eq('id', 123)\n */\n eq(column: string, value: any): this {\n this.queryParams[column] = `eq.${value}`;\n return this;\n }\n\n /**\n * Filter by column not equal to value\n * @example .neq('status', 'draft')\n */\n neq(column: string, value: any): this {\n this.queryParams[column] = `neq.${value}`;\n return this;\n }\n\n /**\n * Filter by column greater than value\n * @example .gt('age', 18)\n */\n gt(column: string, value: any): this {\n this.queryParams[column] = `gt.${value}`;\n return this;\n }\n\n /**\n * Filter by column greater than or equal to value\n * @example .gte('price', 100)\n */\n gte(column: string, value: any): this {\n this.queryParams[column] = `gte.${value}`;\n return this;\n }\n\n /**\n * Filter by column less than value\n * @example .lt('stock', 10)\n */\n lt(column: string, value: any): this {\n this.queryParams[column] = `lt.${value}`;\n return this;\n }\n\n /**\n * Filter by column less than or equal to value\n * @example .lte('discount', 50)\n */\n lte(column: string, value: any): this {\n this.queryParams[column] = `lte.${value}`;\n return this;\n }\n\n /**\n * Filter by pattern matching (case-sensitive)\n * @example .like('email', '%@gmail.com')\n */\n like(column: string, pattern: string): this {\n this.queryParams[column] = `like.${pattern}`;\n return this;\n }\n\n /**\n * Filter by pattern matching (case-insensitive)\n * @example .ilike('name', '%john%')\n */\n ilike(column: string, pattern: string): this {\n this.queryParams[column] = `ilike.${pattern}`;\n return this;\n }\n\n /**\n * Filter by checking if column is a value\n * @example .is('deleted_at', null)\n */\n is(column: string, value: null | boolean): this {\n if (value === null) {\n this.queryParams[column] = 'is.null';\n } else {\n this.queryParams[column] = `is.${value}`;\n }\n return this;\n }\n\n /**\n * Filter by checking if value is in array\n * @example .in('status', ['active', 'pending'])\n */\n in(column: string, values: any[]): this {\n this.queryParams[column] = `in.(${values.join(',')})`;\n return this;\n }\n\n // MODIFIERS\n\n /**\n * Order by column\n * @example \n * .order('created_at') // ascending\n * .order('created_at', { ascending: false }) // descending\n */\n order(column: string, options?: { ascending?: boolean }): this {\n const ascending = options?.ascending !== false;\n this.queryParams.order = ascending ? column : `${column}.desc`;\n return this;\n }\n\n /**\n * Limit the number of rows returned\n * @example .limit(10)\n */\n limit(count: number): this {\n this.queryParams.limit = count.toString();\n return this;\n }\n\n /**\n * Return results from an offset\n * @example .offset(20)\n */\n offset(count: number): this {\n this.queryParams.offset = count.toString();\n return this;\n }\n\n /**\n * Set a range of rows to return\n * @example .range(0, 9) // First 10 rows\n */\n range(from: number, to: number): this {\n this.headers['Range'] = `${from}-${to}`;\n return this;\n }\n\n /**\n * Return a single object instead of array\n * @example .single()\n */\n single(): this {\n this.headers['Accept'] = 'application/vnd.pgrst.object+json';\n return this;\n }\n\n /**\n * Get the total count (use with select)\n * @example .select('*', { count: 'exact' })\n */\n count(algorithm: 'exact' | 'planned' | 'estimated' = 'exact'): this {\n const prefer = this.headers['Prefer'] || '';\n this.headers['Prefer'] = prefer ? `${prefer},count=${algorithm}` : `count=${algorithm}`;\n return this;\n }\n\n /**\n * Execute the query and return results\n */\n async execute(): Promise<DatabaseResponse<T>> {\n try {\n const path = `/api/database/records/${this.table}`;\n let response: any;\n\n switch (this.method) {\n case 'GET':\n response = await this.http.get<T>(path, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n \n case 'POST':\n response = await this.http.post<T>(path, this.body, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n \n case 'PATCH':\n response = await this.http.patch<T>(path, this.body, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n \n case 'DELETE':\n response = await this.http.delete<T>(path, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n }\n\n return { data: response, error: null };\n } catch (error) {\n return {\n data: null,\n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Database operation failed',\n 500,\n 'DATABASE_ERROR'\n )\n };\n }\n }\n\n /**\n * Make QueryBuilder thenable for async/await\n */\n then<TResult1 = DatabaseResponse<T>, TResult2 = never>(\n onfulfilled?: ((value: DatabaseResponse<T>) => TResult1 | PromiseLike<TResult1>) | undefined | null,\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null\n ): Promise<TResult1 | TResult2> {\n return this.execute().then(onfulfilled, onrejected);\n }\n}\n\n/**\n * Database client for InsForge SDK\n * Provides Supabase-style interface\n */\nexport class Database {\n constructor(private http: HttpClient) {}\n\n /**\n * Create a query builder for a table\n * @param table - The table name\n * @example\n * const { data, error } = await client.database\n * .from('posts')\n * .select('*')\n * .eq('user_id', userId)\n * .order('created_at', { ascending: false })\n * .limit(10);\n */\n from<T = any>(table: string): QueryBuilder<T> {\n return new QueryBuilder<T>(table, this.http);\n }\n}","/**\n * Auth module for InsForge SDK\n * Uses shared schemas for type safety\n */\n\nimport { HttpClient } from '../lib/http-client';\nimport { TokenManager } from '../lib/token-manager';\nimport { AuthSession, InsForgeError } from '../types';\nimport { Database } from './database';\n\nimport type {\n CreateUserRequest,\n CreateUserResponse,\n CreateSessionRequest,\n CreateSessionResponse,\n GetCurrentSessionResponse,\n GetOauthUrlResponse,\n} from '@insforge/shared-schemas';\n\nexport class Auth {\n private database: Database;\n \n constructor(\n private http: HttpClient,\n private tokenManager: TokenManager\n ) {\n this.database = new Database(http);\n \n // Auto-detect OAuth callback parameters in the URL\n this.detectOAuthCallback();\n }\n\n /**\n * Automatically detect and handle OAuth callback parameters in the URL\n * This runs on initialization to seamlessly complete the OAuth flow\n * Matches the backend's OAuth callback response (backend/src/api/routes/auth.ts:540-544)\n */\n private detectOAuthCallback(): void {\n // Only run in browser environment\n if (typeof window === 'undefined') return;\n \n try {\n const params = new URLSearchParams(window.location.search);\n \n // Backend returns: access_token, user_id, email, name (optional)\n const accessToken = params.get('access_token');\n const userId = params.get('user_id');\n const email = params.get('email');\n const name = params.get('name');\n \n // Check if we have OAuth callback parameters\n if (accessToken && userId && email) {\n // Create session with the data from backend\n const session: AuthSession = {\n accessToken,\n user: {\n id: userId,\n email: email,\n name: name || '',\n // These fields are not provided by backend OAuth callback\n // They'll be populated when calling getCurrentUser()\n emailVerified: false,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n } as any,\n };\n \n // Save session and set auth token\n this.tokenManager.saveSession(session);\n this.http.setAuthToken(accessToken);\n \n // Clean up the URL to remove sensitive parameters\n const url = new URL(window.location.href);\n url.searchParams.delete('access_token');\n url.searchParams.delete('user_id');\n url.searchParams.delete('email');\n url.searchParams.delete('name');\n \n // Also handle error case from backend (line 581)\n if (params.has('error')) {\n url.searchParams.delete('error');\n }\n \n // Replace URL without adding to browser history\n window.history.replaceState({}, document.title, url.toString());\n }\n } catch (error) {\n // Silently continue - don't break initialization\n console.debug('OAuth callback detection skipped:', error);\n }\n }\n\n /**\n * Sign up a new user\n */\n async signUp(request: CreateUserRequest): Promise<{\n data: CreateUserResponse | null;\n error: InsForgeError | null;\n }> {\n try {\n const response = await this.http.post<CreateUserResponse>('/api/auth/users', request);\n \n // Save session internally\n const session: AuthSession = {\n accessToken: response.accessToken,\n user: response.user,\n };\n this.tokenManager.saveSession(session);\n this.http.setAuthToken(response.accessToken);\n\n return { \n data: response,\n error: null \n };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: null, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: null, \n error: new InsForgeError(\n error instanceof Error ? error.message : 'An unexpected error occurred during sign up',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Sign in with email and password\n */\n async signInWithPassword(request: CreateSessionRequest): Promise<{\n data: CreateSessionResponse | null;\n error: InsForgeError | null;\n }> {\n try {\n const response = await this.http.post<CreateSessionResponse>('/api/auth/sessions', request);\n \n // Save session internally\n const session: AuthSession = {\n accessToken: response.accessToken,\n user: response.user,\n };\n this.tokenManager.saveSession(session);\n this.http.setAuthToken(response.accessToken);\n\n return { \n data: response,\n error: null \n };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: null, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: null, \n error: new InsForgeError(\n 'An unexpected error occurred during sign in',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Sign in with OAuth provider\n */\n async signInWithOAuth(options: {\n provider: 'google' | 'github';\n redirectTo?: string;\n skipBrowserRedirect?: boolean;\n }): Promise<{\n data: { url?: string; provider?: string };\n error: InsForgeError | null;\n }> {\n try {\n const { provider, redirectTo, skipBrowserRedirect } = options;\n \n const params = redirectTo \n ? { redirect_uri: redirectTo } \n : undefined;\n \n const endpoint = `/api/auth/oauth/${provider}`;\n const response = await this.http.get<GetOauthUrlResponse>(endpoint, { params });\n \n // Automatically redirect in browser unless told not to\n if (typeof window !== 'undefined' && !skipBrowserRedirect) {\n window.location.href = response.authUrl;\n return { data: {}, error: null };\n }\n\n return { \n data: { \n url: response.authUrl,\n provider \n }, \n error: null \n };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: {}, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: {}, \n error: new InsForgeError(\n 'An unexpected error occurred during OAuth initialization',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Sign out the current user\n */\n async signOut(): Promise<{ error: InsForgeError | null }> {\n try {\n this.tokenManager.clearSession();\n this.http.setAuthToken(null);\n return { error: null };\n } catch (error) {\n return { \n error: new InsForgeError(\n 'Failed to sign out',\n 500,\n 'SIGNOUT_ERROR'\n )\n };\n }\n }\n\n /**\n * Get the current user with full profile information\n * Returns both auth info (id, email, role) and profile data (nickname, avatar_url, bio, etc.)\n */\n async getCurrentUser(): Promise<{\n data: { user: any; profile: any } | null;\n error: InsForgeError | null;\n }> {\n try {\n // Check if we have a token\n const session = this.tokenManager.getSession();\n if (!session?.accessToken) {\n return { data: null, error: null };\n }\n\n // Call the API for auth info\n this.http.setAuthToken(session.accessToken);\n const authResponse = await this.http.get<GetCurrentSessionResponse>('/api/auth/sessions/current');\n \n // Get the user's profile using query builder\n const { data: profile, error: profileError } = await this.database\n .from('users')\n .select('*')\n .eq('id', authResponse.user.id)\n .single();\n \n if (profileError && profileError.statusCode !== 406) { // 406 = not found\n return { data: null, error: profileError };\n }\n \n return {\n data: {\n user: authResponse.user,\n profile: profile\n },\n error: null\n };\n } catch (error) {\n // If unauthorized, clear session\n if (error instanceof InsForgeError && error.statusCode === 401) {\n await this.signOut();\n return { data: null, error: null };\n }\n \n // Pass through all other errors unchanged\n if (error instanceof InsForgeError) {\n return { data: null, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: null, \n error: new InsForgeError(\n 'An unexpected error occurred while fetching user',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Get any user's profile by ID\n * Returns profile information from the users table (nickname, avatar_url, bio, etc.)\n */\n async getProfile(userId: string): Promise<{\n data: any | null;\n error: InsForgeError | null;\n }> {\n const { data, error } = await this.database\n .from('users')\n .select('*')\n .eq('id', userId)\n .single();\n \n // Handle not found as null, not error\n if (error && error.statusCode === 406) {\n return { data: null, error: null };\n }\n \n return { data, error };\n }\n\n /**\n * Get the current session (only session data, no API call)\n * Returns the stored JWT token and basic user info from local storage\n */\n async getCurrentSession(): Promise<{\n data: { session: AuthSession | null };\n error: InsForgeError | null;\n }> {\n try {\n const session = this.tokenManager.getSession();\n \n if (session?.accessToken) {\n this.http.setAuthToken(session.accessToken);\n return { data: { session }, error: null };\n }\n\n return { data: { session: null }, error: null };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: { session: null }, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: { session: null }, \n error: new InsForgeError(\n 'An unexpected error occurred while getting session',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Set/Update the current user's profile\n * Updates profile information in the users table (nickname, avatar_url, bio, etc.)\n */\n async setProfile(profile: {\n nickname?: string;\n avatar_url?: string;\n bio?: string;\n birthday?: string;\n [key: string]: any;\n }): Promise<{\n data: any | null;\n error: InsForgeError | null;\n }> {\n // Get current session to get user ID\n const session = this.tokenManager.getSession();\n if (!session?.user?.id) {\n return { \n data: null, \n error: new InsForgeError(\n 'No authenticated user found',\n 401,\n 'UNAUTHENTICATED'\n )\n };\n }\n\n // Update the profile using query builder\n return await this.database\n .from('users')\n .update(profile)\n .eq('id', session.user.id)\n .select()\n .single();\n }\n\n\n}","/**\n * Storage module for InsForge SDK\n * Handles file uploads, downloads, and bucket management\n */\n\nimport { HttpClient } from '../lib/http-client';\nimport { InsForgeError } from '../types';\nimport type { \n StorageFileSchema,\n ListObjectsResponseSchema\n} from '@insforge/shared-schemas';\n\nexport interface StorageResponse<T> {\n data: T | null;\n error: InsForgeError | null;\n}\n\n/**\n * Storage bucket operations\n */\nexport class StorageBucket {\n constructor(\n private bucketName: string,\n private http: HttpClient\n ) {}\n\n /**\n * Upload a file with a specific key\n * @param path - The object key/path\n * @param file - File or Blob to upload\n */\n async upload(\n path: string,\n file: File | Blob\n ): Promise<StorageResponse<StorageFileSchema>> {\n try {\n const formData = new FormData();\n formData.append('file', file);\n\n // Use PUT for specific path\n const response = await this.http.request<StorageFileSchema>(\n 'PUT',\n `/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`,\n {\n body: formData as any,\n headers: {\n // Don't set Content-Type, let browser set multipart boundary\n }\n }\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Upload failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Upload a file with auto-generated key\n * @param file - File or Blob to upload\n */\n async uploadAuto(\n file: File | Blob\n ): Promise<StorageResponse<StorageFileSchema>> {\n try {\n const formData = new FormData();\n formData.append('file', file);\n\n // Use POST for auto-generated key\n const response = await this.http.request<StorageFileSchema>(\n 'POST',\n `/api/storage/buckets/${this.bucketName}/objects`,\n {\n body: formData as any,\n headers: {\n // Don't set Content-Type, let browser set multipart boundary\n }\n }\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Upload failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Download a file\n * @param path - The object key/path\n * Returns the file as a Blob\n */\n async download(path: string): Promise<{ data: Blob | null; error: InsForgeError | null }> {\n try {\n // For binary data, we need to use fetch directly with proper response handling\n // The http.request method expects JSON responses, so we can't use it for blobs\n const url = `${this.http.baseUrl}/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`;\n \n const response = await this.http.fetch(url, {\n method: 'GET',\n headers: this.http.getHeaders()\n });\n\n if (!response.ok) {\n try {\n const error = await response.json();\n throw InsForgeError.fromApiError(error);\n } catch {\n throw new InsForgeError(\n `Download failed: ${response.statusText}`,\n response.status,\n 'STORAGE_ERROR'\n );\n }\n }\n\n const blob = await response.blob();\n return { data: blob, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Download failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Get public URL for a file\n * @param path - The object key/path\n */\n getPublicUrl(path: string): string {\n return `${this.http.baseUrl}/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`;\n }\n\n /**\n * List objects in the bucket\n * @param prefix - Filter by key prefix\n * @param search - Search in file names\n * @param limit - Maximum number of results (default: 100, max: 1000)\n * @param offset - Number of results to skip\n */\n async list(options?: {\n prefix?: string;\n search?: string;\n limit?: number;\n offset?: number;\n }): Promise<StorageResponse<ListObjectsResponseSchema>> {\n try {\n const params: Record<string, string> = {};\n \n if (options?.prefix) params.prefix = options.prefix;\n if (options?.search) params.search = options.search;\n if (options?.limit) params.limit = options.limit.toString();\n if (options?.offset) params.offset = options.offset.toString();\n\n const response = await this.http.get<ListObjectsResponseSchema>(\n `/api/storage/buckets/${this.bucketName}/objects`,\n { params }\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'List failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Delete a file\n * @param path - The object key/path\n */\n async remove(path: string): Promise<StorageResponse<{ message: string }>> {\n try {\n const response = await this.http.delete<{ message: string }>(\n `/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Delete failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n}\n\n/**\n * Storage module for file operations\n */\nexport class Storage {\n constructor(private http: HttpClient) {}\n\n /**\n * Get a bucket instance for operations\n * @param bucketName - Name of the bucket\n */\n from(bucketName: string): StorageBucket {\n return new StorageBucket(bucketName, this.http);\n }\n}","import { InsForgeConfig } from './types';\nimport { HttpClient } from './lib/http-client';\nimport { TokenManager } from './lib/token-manager';\nimport { Auth } from './modules/auth';\nimport { Database } from './modules/database';\nimport { Storage } from './modules/storage';\n\n/**\n * Main InsForge SDK Client\n * \n * @example\n * ```typescript\n * import { InsForgeClient } from '@insforge/sdk';\n * \n * const client = new InsForgeClient({\n * baseUrl: 'http://localhost:7130'\n * });\n * \n * // Authentication\n * const session = await client.auth.register({\n * email: 'user@example.com',\n * password: 'password123',\n * name: 'John Doe'\n * });\n * \n * // Database operations\n * const { data, error } = await client.database\n * .from('posts')\n * .select('*')\n * .eq('user_id', session.user.id)\n * .order('created_at', { ascending: false })\n * .limit(10);\n * \n * // Insert data\n * const { data: newPost } = await client.database\n * .from('posts')\n * .insert({ title: 'Hello', content: 'World' })\n * .single();\n * ```\n */\nexport class InsForgeClient {\n private http: HttpClient;\n private tokenManager: TokenManager;\n \n public readonly auth: Auth;\n public readonly database: Database;\n public readonly storage: Storage;\n\n constructor(config: InsForgeConfig = {}) {\n this.http = new HttpClient(config);\n this.tokenManager = new TokenManager(config.storage);\n \n this.auth = new Auth(\n this.http,\n this.tokenManager\n );\n \n this.database = new Database(this.http);\n this.storage = new Storage(this.http);\n }\n\n\n /**\n * Set a custom API key for authentication\n * This is useful for server-to-server communication\n * \n * @param apiKey - The API key (should start with 'ik_')\n * \n * @example\n * ```typescript\n * client.setApiKey('ik_your_api_key_here');\n * ```\n */\n setApiKey(apiKey: string): void {\n // API keys can be used as Bearer tokens\n this.http.setAuthToken(apiKey);\n }\n\n /**\n * Get the underlying HTTP client for custom requests\n * \n * @example\n * ```typescript\n * const httpClient = client.getHttpClient();\n * const customData = await httpClient.get('/api/custom-endpoint');\n * ```\n */\n getHttpClient(): HttpClient {\n return this.http;\n }\n\n /**\n * Future modules will be added here:\n * - database: Database operations\n * - storage: File storage operations\n * - functions: Serverless functions\n * - tables: Table management\n * - metadata: Backend metadata\n */\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmEO,IAAM,gBAAN,MAAM,uBAAsB,MAAM;AAAA,EAKvC,YAAY,SAAiB,YAAoB,OAAe,aAAsB;AACpF,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,QAAQ;AACb,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,OAAO,aAAa,UAAmC;AACrD,WAAO,IAAI;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAAA,EACF;AACF;;;AClFO,IAAM,aAAN,MAAiB;AAAA,EAKtB,YAAY,QAAwB;AAClC,SAAK,UAAU,OAAO,OAAO;AAE7B,SAAK,QAAQ,OAAO,UAAU,WAAW,QAAQ,WAAW,MAAM,KAAK,UAA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AAAA,MACL,KAAK;AAAA,IACP;AAEA,SAAK,WAAW,IAAI,SAAS,KAAK,IAAI;AACtC,SAAK,UAAU,IAAI,QAAQ,KAAK,IAAI;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,UAAU,QAAsB;AAE9B,SAAK,KAAK,aAAa,MAAM;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,gBAA4B;AAC1B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUF;;;APpDO,SAAS,aAAa,QAAwC;AACnE,SAAO,IAAI,eAAe,MAAM;AAClC;AAGA,IAAO,gBAAQ;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -727,14 +727,12 @@ var StorageBucket = class {
|
|
|
727
727
|
/**
|
|
728
728
|
* Upload a file with a specific key
|
|
729
729
|
* @param path - The object key/path
|
|
730
|
-
* @param file - File
|
|
730
|
+
* @param file - File or Blob to upload
|
|
731
731
|
*/
|
|
732
732
|
async upload(path, file) {
|
|
733
733
|
try {
|
|
734
|
-
const formData =
|
|
735
|
-
|
|
736
|
-
formData.append("file", file);
|
|
737
|
-
}
|
|
734
|
+
const formData = new FormData();
|
|
735
|
+
formData.append("file", file);
|
|
738
736
|
const response = await this.http.request(
|
|
739
737
|
"PUT",
|
|
740
738
|
`/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`,
|
|
@@ -759,14 +757,12 @@ var StorageBucket = class {
|
|
|
759
757
|
}
|
|
760
758
|
/**
|
|
761
759
|
* Upload a file with auto-generated key
|
|
762
|
-
* @param file - File
|
|
760
|
+
* @param file - File or Blob to upload
|
|
763
761
|
*/
|
|
764
762
|
async uploadAuto(file) {
|
|
765
763
|
try {
|
|
766
|
-
const formData =
|
|
767
|
-
|
|
768
|
-
formData.append("file", file);
|
|
769
|
-
}
|
|
764
|
+
const formData = new FormData();
|
|
765
|
+
formData.append("file", file);
|
|
770
766
|
const response = await this.http.request(
|
|
771
767
|
"POST",
|
|
772
768
|
`/api/storage/buckets/${this.bucketName}/objects`,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts","../src/lib/http-client.ts","../src/lib/token-manager.ts","../src/modules/database.ts","../src/modules/auth.ts","../src/modules/storage.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["/**\n * InsForge SDK Types - only SDK-specific types here\n * Use @insforge/shared-schemas directly for API types\n */\n\nimport type { UserSchema } from '@insforge/shared-schemas';\n\nexport interface InsForgeConfig {\n /**\n * The URL of the InsForge backend API\n * @default \"http://localhost:7130\"\n */\n url?: string;\n\n /**\n * API key (optional)\n * Can be used for server-side operations or specific use cases\n */\n apiKey?: string;\n\n /**\n * Custom fetch implementation (useful for Node.js environments)\n */\n fetch?: typeof fetch;\n\n /**\n * Storage adapter for persisting tokens\n */\n storage?: TokenStorage;\n\n /**\n * Whether to automatically refresh tokens before they expire\n * @default true\n */\n autoRefreshToken?: boolean;\n\n /**\n * Whether to persist session in storage\n * @default true\n */\n persistSession?: boolean;\n\n /**\n * Custom headers to include with every request\n */\n headers?: Record<string, string>;\n}\n\nexport interface TokenStorage {\n getItem(key: string): string | null | Promise<string | null>;\n setItem(key: string, value: string): void | Promise<void>;\n removeItem(key: string): void | Promise<void>;\n}\n\nexport interface AuthSession {\n user: UserSchema;\n accessToken: string;\n expiresAt?: Date;\n}\n\nexport interface ApiError {\n error: string;\n message: string;\n statusCode: number;\n nextActions?: string;\n}\n\nexport class InsForgeError extends Error {\n public statusCode: number;\n public error: string;\n public nextActions?: string;\n\n constructor(message: string, statusCode: number, error: string, nextActions?: string) {\n super(message);\n this.name = 'InsForgeError';\n this.statusCode = statusCode;\n this.error = error;\n this.nextActions = nextActions;\n }\n\n static fromApiError(apiError: ApiError): InsForgeError {\n return new InsForgeError(\n apiError.message,\n apiError.statusCode,\n apiError.error,\n apiError.nextActions\n );\n }\n}","import { InsForgeConfig, ApiError, InsForgeError } from '../types';\n\nexport interface RequestOptions extends RequestInit {\n params?: Record<string, string>;\n}\n\nexport class HttpClient {\n public readonly baseUrl: string;\n public readonly fetch: typeof fetch;\n private defaultHeaders: Record<string, string>;\n\n constructor(config: InsForgeConfig) {\n this.baseUrl = config.url || 'http://localhost:7130';\n // Properly bind fetch to maintain its context\n this.fetch = config.fetch || (globalThis.fetch ? globalThis.fetch.bind(globalThis) : undefined as any);\n this.defaultHeaders = {\n ...config.headers,\n };\n \n // Add API key if provided\n if (config.apiKey) {\n this.defaultHeaders['Authorization'] = `Bearer ${config.apiKey}`;\n }\n\n if (!this.fetch) {\n throw new Error(\n 'Fetch is not available. Please provide a fetch implementation in the config.'\n );\n }\n }\n\n private buildUrl(path: string, params?: Record<string, string>): string {\n const url = new URL(path, this.baseUrl);\n if (params) {\n Object.entries(params).forEach(([key, value]) => {\n url.searchParams.append(key, value);\n });\n }\n return url.toString();\n }\n\n async request<T>(\n method: string,\n path: string,\n options: RequestOptions = {}\n ): Promise<T> {\n const { params, headers = {}, body, ...fetchOptions } = options;\n \n const url = this.buildUrl(path, params);\n \n const requestHeaders: Record<string, string> = {\n ...this.defaultHeaders,\n };\n \n // Handle body serialization\n let processedBody: any;\n if (body !== undefined) {\n // Check if body is FormData (for file uploads)\n if (typeof FormData !== 'undefined' && body instanceof FormData) {\n // Don't set Content-Type for FormData, let browser set it with boundary\n processedBody = body;\n } else {\n // JSON body\n if (method !== 'GET') {\n requestHeaders['Content-Type'] = 'application/json;charset=UTF-8';\n }\n processedBody = JSON.stringify(body);\n }\n }\n \n Object.assign(requestHeaders, headers);\n \n const response = await this.fetch(url, {\n method,\n headers: requestHeaders,\n body: processedBody,\n ...fetchOptions,\n });\n\n // Handle 204 No Content\n if (response.status === 204) {\n return undefined as T;\n }\n\n // Try to parse JSON response\n let data: any;\n const contentType = response.headers.get('content-type');\n // Check for any JSON content type (including PostgREST's vnd.pgrst.object+json)\n if (contentType?.includes('json')) {\n data = await response.json();\n } else {\n // For non-JSON responses, return text\n data = await response.text();\n }\n\n // Handle errors\n if (!response.ok) {\n if (data && typeof data === 'object' && 'error' in data) {\n throw InsForgeError.fromApiError(data as ApiError);\n }\n throw new InsForgeError(\n `Request failed: ${response.statusText}`,\n response.status,\n 'REQUEST_FAILED'\n );\n }\n\n return data as T;\n }\n\n get<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('GET', path, options);\n }\n\n post<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('POST', path, { ...options, body });\n }\n\n put<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('PUT', path, { ...options, body });\n }\n\n patch<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('PATCH', path, { ...options, body });\n }\n\n delete<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('DELETE', path, options);\n }\n\n setAuthToken(token: string | null) {\n if (token) {\n this.defaultHeaders['Authorization'] = `Bearer ${token}`;\n } else {\n delete this.defaultHeaders['Authorization'];\n }\n }\n\n getHeaders(): Record<string, string> {\n return { ...this.defaultHeaders };\n }\n}","import { TokenStorage, AuthSession } from '../types';\n\nconst TOKEN_KEY = 'insforge-auth-token';\nconst USER_KEY = 'insforge-auth-user';\n\nexport class TokenManager {\n private storage: TokenStorage;\n\n constructor(storage?: TokenStorage) {\n if (storage) {\n // Use provided storage\n this.storage = storage;\n } else if (typeof window !== 'undefined' && window.localStorage) {\n // Browser: use localStorage\n this.storage = window.localStorage;\n } else {\n // Node.js: use in-memory storage\n const store = new Map<string, string>();\n this.storage = {\n getItem: (key: string) => store.get(key) || null,\n setItem: (key: string, value: string) => { store.set(key, value); },\n removeItem: (key: string) => { store.delete(key); }\n };\n }\n }\n\n saveSession(session: AuthSession): void {\n this.storage.setItem(TOKEN_KEY, session.accessToken);\n this.storage.setItem(USER_KEY, JSON.stringify(session.user));\n }\n\n getSession(): AuthSession | null {\n const token = this.storage.getItem(TOKEN_KEY);\n const userStr = this.storage.getItem(USER_KEY);\n\n if (!token || !userStr) {\n return null;\n }\n\n try {\n const user = JSON.parse(userStr as string);\n return { accessToken: token as string, user };\n } catch {\n this.clearSession();\n return null;\n }\n }\n\n getAccessToken(): string | null {\n const token = this.storage.getItem(TOKEN_KEY);\n return typeof token === 'string' ? token : null;\n }\n\n clearSession(): void {\n this.storage.removeItem(TOKEN_KEY);\n this.storage.removeItem(USER_KEY);\n }\n}","/**\n * Database module for InsForge SDK\n * Supabase-style query builder for PostgREST operations\n */\n\nimport { HttpClient } from '../lib/http-client';\nimport { InsForgeError } from '../types';\n\nexport interface DatabaseResponse<T> {\n data: T | null;\n error: InsForgeError | null;\n count?: number;\n}\n\n/**\n * Query builder for database operations\n * Uses method chaining like Supabase\n */\nexport class QueryBuilder<T = any> {\n private method: 'GET' | 'POST' | 'PATCH' | 'DELETE' = 'GET';\n private headers: Record<string, string> = {};\n private queryParams: Record<string, string> = {};\n private body?: any;\n\n constructor(\n private table: string,\n private http: HttpClient\n ) {}\n\n /**\n * Perform a SELECT query\n * For mutations (insert/update/delete), this enables returning data\n * @param columns - Columns to select (default: '*')\n * @example\n * .select('*')\n * .select('id, title, content')\n * .select('*, users!inner(*)') // Join with users table\n * .select('*, profile:profiles(*)') // Join with alias\n * .insert({ title: 'New' }).select() // Returns inserted data\n */\n select(columns: string = '*'): this {\n // For mutations, add return=representation header\n if (this.method !== 'GET') {\n const existingPrefer = this.headers['Prefer'] || '';\n const preferParts = existingPrefer ? [existingPrefer] : [];\n if (!preferParts.some(p => p.includes('return='))) {\n preferParts.push('return=representation');\n }\n this.headers['Prefer'] = preferParts.join(',');\n }\n \n // Always set the select parameter for GET requests\n // This enables PostgREST joins and nested queries\n if (this.method === 'GET' && columns) {\n this.queryParams.select = columns;\n } else if (columns !== '*') {\n // For mutations, only set if not default\n this.queryParams.select = columns;\n }\n return this;\n }\n\n /**\n * Perform an INSERT\n * @param values - Single object or array of objects\n * @param options - { upsert: true } for upsert behavior\n * @example\n * .insert({ title: 'Hello', content: 'World' }).select()\n * .insert([{ title: 'Post 1' }, { title: 'Post 2' }]).select()\n */\n insert(values: Partial<T> | Partial<T>[], options?: { upsert?: boolean }): this {\n this.method = 'POST';\n this.body = Array.isArray(values) ? values : [values];\n \n if (options?.upsert) {\n this.headers['Prefer'] = 'resolution=merge-duplicates';\n }\n \n return this;\n }\n\n /**\n * Perform an UPDATE\n * @param values - Object with fields to update\n * @example\n * .update({ title: 'Updated Title' }).select()\n */\n update(values: Partial<T>): this {\n this.method = 'PATCH';\n this.body = values;\n return this;\n }\n\n /**\n * Perform a DELETE\n * @example\n * .delete().select()\n */\n delete(): this {\n this.method = 'DELETE';\n return this;\n }\n\n /**\n * Perform an UPSERT\n * @param values - Single object or array of objects\n * @example\n * .upsert({ id: 1, title: 'Hello' })\n */\n upsert(values: Partial<T> | Partial<T>[]): this {\n return this.insert(values, { upsert: true });\n }\n\n // FILTERS\n\n /**\n * Filter by column equal to value\n * @example .eq('id', 123)\n */\n eq(column: string, value: any): this {\n this.queryParams[column] = `eq.${value}`;\n return this;\n }\n\n /**\n * Filter by column not equal to value\n * @example .neq('status', 'draft')\n */\n neq(column: string, value: any): this {\n this.queryParams[column] = `neq.${value}`;\n return this;\n }\n\n /**\n * Filter by column greater than value\n * @example .gt('age', 18)\n */\n gt(column: string, value: any): this {\n this.queryParams[column] = `gt.${value}`;\n return this;\n }\n\n /**\n * Filter by column greater than or equal to value\n * @example .gte('price', 100)\n */\n gte(column: string, value: any): this {\n this.queryParams[column] = `gte.${value}`;\n return this;\n }\n\n /**\n * Filter by column less than value\n * @example .lt('stock', 10)\n */\n lt(column: string, value: any): this {\n this.queryParams[column] = `lt.${value}`;\n return this;\n }\n\n /**\n * Filter by column less than or equal to value\n * @example .lte('discount', 50)\n */\n lte(column: string, value: any): this {\n this.queryParams[column] = `lte.${value}`;\n return this;\n }\n\n /**\n * Filter by pattern matching (case-sensitive)\n * @example .like('email', '%@gmail.com')\n */\n like(column: string, pattern: string): this {\n this.queryParams[column] = `like.${pattern}`;\n return this;\n }\n\n /**\n * Filter by pattern matching (case-insensitive)\n * @example .ilike('name', '%john%')\n */\n ilike(column: string, pattern: string): this {\n this.queryParams[column] = `ilike.${pattern}`;\n return this;\n }\n\n /**\n * Filter by checking if column is a value\n * @example .is('deleted_at', null)\n */\n is(column: string, value: null | boolean): this {\n if (value === null) {\n this.queryParams[column] = 'is.null';\n } else {\n this.queryParams[column] = `is.${value}`;\n }\n return this;\n }\n\n /**\n * Filter by checking if value is in array\n * @example .in('status', ['active', 'pending'])\n */\n in(column: string, values: any[]): this {\n this.queryParams[column] = `in.(${values.join(',')})`;\n return this;\n }\n\n // MODIFIERS\n\n /**\n * Order by column\n * @example \n * .order('created_at') // ascending\n * .order('created_at', { ascending: false }) // descending\n */\n order(column: string, options?: { ascending?: boolean }): this {\n const ascending = options?.ascending !== false;\n this.queryParams.order = ascending ? column : `${column}.desc`;\n return this;\n }\n\n /**\n * Limit the number of rows returned\n * @example .limit(10)\n */\n limit(count: number): this {\n this.queryParams.limit = count.toString();\n return this;\n }\n\n /**\n * Return results from an offset\n * @example .offset(20)\n */\n offset(count: number): this {\n this.queryParams.offset = count.toString();\n return this;\n }\n\n /**\n * Set a range of rows to return\n * @example .range(0, 9) // First 10 rows\n */\n range(from: number, to: number): this {\n this.headers['Range'] = `${from}-${to}`;\n return this;\n }\n\n /**\n * Return a single object instead of array\n * @example .single()\n */\n single(): this {\n this.headers['Accept'] = 'application/vnd.pgrst.object+json';\n return this;\n }\n\n /**\n * Get the total count (use with select)\n * @example .select('*', { count: 'exact' })\n */\n count(algorithm: 'exact' | 'planned' | 'estimated' = 'exact'): this {\n const prefer = this.headers['Prefer'] || '';\n this.headers['Prefer'] = prefer ? `${prefer},count=${algorithm}` : `count=${algorithm}`;\n return this;\n }\n\n /**\n * Execute the query and return results\n */\n async execute(): Promise<DatabaseResponse<T>> {\n try {\n const path = `/api/database/records/${this.table}`;\n let response: any;\n\n switch (this.method) {\n case 'GET':\n response = await this.http.get<T>(path, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n \n case 'POST':\n response = await this.http.post<T>(path, this.body, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n \n case 'PATCH':\n response = await this.http.patch<T>(path, this.body, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n \n case 'DELETE':\n response = await this.http.delete<T>(path, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n }\n\n return { data: response, error: null };\n } catch (error) {\n return {\n data: null,\n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Database operation failed',\n 500,\n 'DATABASE_ERROR'\n )\n };\n }\n }\n\n /**\n * Make QueryBuilder thenable for async/await\n */\n then<TResult1 = DatabaseResponse<T>, TResult2 = never>(\n onfulfilled?: ((value: DatabaseResponse<T>) => TResult1 | PromiseLike<TResult1>) | undefined | null,\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null\n ): Promise<TResult1 | TResult2> {\n return this.execute().then(onfulfilled, onrejected);\n }\n}\n\n/**\n * Database client for InsForge SDK\n * Provides Supabase-style interface\n */\nexport class Database {\n constructor(private http: HttpClient) {}\n\n /**\n * Create a query builder for a table\n * @param table - The table name\n * @example\n * const { data, error } = await client.database\n * .from('posts')\n * .select('*')\n * .eq('user_id', userId)\n * .order('created_at', { ascending: false })\n * .limit(10);\n */\n from<T = any>(table: string): QueryBuilder<T> {\n return new QueryBuilder<T>(table, this.http);\n }\n}","/**\n * Auth module for InsForge SDK\n * Uses shared schemas for type safety\n */\n\nimport { HttpClient } from '../lib/http-client';\nimport { TokenManager } from '../lib/token-manager';\nimport { AuthSession, InsForgeError } from '../types';\nimport { Database } from './database';\n\nimport type {\n CreateUserRequest,\n CreateUserResponse,\n CreateSessionRequest,\n CreateSessionResponse,\n GetCurrentSessionResponse,\n GetOauthUrlResponse,\n} from '@insforge/shared-schemas';\n\nexport class Auth {\n private database: Database;\n \n constructor(\n private http: HttpClient,\n private tokenManager: TokenManager\n ) {\n this.database = new Database(http);\n \n // Auto-detect OAuth callback parameters in the URL\n this.detectOAuthCallback();\n }\n\n /**\n * Automatically detect and handle OAuth callback parameters in the URL\n * This runs on initialization to seamlessly complete the OAuth flow\n * Matches the backend's OAuth callback response (backend/src/api/routes/auth.ts:540-544)\n */\n private detectOAuthCallback(): void {\n // Only run in browser environment\n if (typeof window === 'undefined') return;\n \n try {\n const params = new URLSearchParams(window.location.search);\n \n // Backend returns: access_token, user_id, email, name (optional)\n const accessToken = params.get('access_token');\n const userId = params.get('user_id');\n const email = params.get('email');\n const name = params.get('name');\n \n // Check if we have OAuth callback parameters\n if (accessToken && userId && email) {\n // Create session with the data from backend\n const session: AuthSession = {\n accessToken,\n user: {\n id: userId,\n email: email,\n name: name || '',\n // These fields are not provided by backend OAuth callback\n // They'll be populated when calling getCurrentUser()\n emailVerified: false,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n } as any,\n };\n \n // Save session and set auth token\n this.tokenManager.saveSession(session);\n this.http.setAuthToken(accessToken);\n \n // Clean up the URL to remove sensitive parameters\n const url = new URL(window.location.href);\n url.searchParams.delete('access_token');\n url.searchParams.delete('user_id');\n url.searchParams.delete('email');\n url.searchParams.delete('name');\n \n // Also handle error case from backend (line 581)\n if (params.has('error')) {\n url.searchParams.delete('error');\n }\n \n // Replace URL without adding to browser history\n window.history.replaceState({}, document.title, url.toString());\n }\n } catch (error) {\n // Silently continue - don't break initialization\n console.debug('OAuth callback detection skipped:', error);\n }\n }\n\n /**\n * Sign up a new user\n */\n async signUp(request: CreateUserRequest): Promise<{\n data: CreateUserResponse | null;\n error: InsForgeError | null;\n }> {\n try {\n const response = await this.http.post<CreateUserResponse>('/api/auth/users', request);\n \n // Save session internally\n const session: AuthSession = {\n accessToken: response.accessToken,\n user: response.user,\n };\n this.tokenManager.saveSession(session);\n this.http.setAuthToken(response.accessToken);\n\n return { \n data: response,\n error: null \n };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: null, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: null, \n error: new InsForgeError(\n error instanceof Error ? error.message : 'An unexpected error occurred during sign up',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Sign in with email and password\n */\n async signInWithPassword(request: CreateSessionRequest): Promise<{\n data: CreateSessionResponse | null;\n error: InsForgeError | null;\n }> {\n try {\n const response = await this.http.post<CreateSessionResponse>('/api/auth/sessions', request);\n \n // Save session internally\n const session: AuthSession = {\n accessToken: response.accessToken,\n user: response.user,\n };\n this.tokenManager.saveSession(session);\n this.http.setAuthToken(response.accessToken);\n\n return { \n data: response,\n error: null \n };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: null, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: null, \n error: new InsForgeError(\n 'An unexpected error occurred during sign in',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Sign in with OAuth provider\n */\n async signInWithOAuth(options: {\n provider: 'google' | 'github';\n redirectTo?: string;\n skipBrowserRedirect?: boolean;\n }): Promise<{\n data: { url?: string; provider?: string };\n error: InsForgeError | null;\n }> {\n try {\n const { provider, redirectTo, skipBrowserRedirect } = options;\n \n const params = redirectTo \n ? { redirect_uri: redirectTo } \n : undefined;\n \n const endpoint = `/api/auth/oauth/${provider}`;\n const response = await this.http.get<GetOauthUrlResponse>(endpoint, { params });\n \n // Automatically redirect in browser unless told not to\n if (typeof window !== 'undefined' && !skipBrowserRedirect) {\n window.location.href = response.authUrl;\n return { data: {}, error: null };\n }\n\n return { \n data: { \n url: response.authUrl,\n provider \n }, \n error: null \n };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: {}, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: {}, \n error: new InsForgeError(\n 'An unexpected error occurred during OAuth initialization',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Sign out the current user\n */\n async signOut(): Promise<{ error: InsForgeError | null }> {\n try {\n this.tokenManager.clearSession();\n this.http.setAuthToken(null);\n return { error: null };\n } catch (error) {\n return { \n error: new InsForgeError(\n 'Failed to sign out',\n 500,\n 'SIGNOUT_ERROR'\n )\n };\n }\n }\n\n /**\n * Get the current user with full profile information\n * Returns both auth info (id, email, role) and profile data (nickname, avatar_url, bio, etc.)\n */\n async getCurrentUser(): Promise<{\n data: { user: any; profile: any } | null;\n error: InsForgeError | null;\n }> {\n try {\n // Check if we have a token\n const session = this.tokenManager.getSession();\n if (!session?.accessToken) {\n return { data: null, error: null };\n }\n\n // Call the API for auth info\n this.http.setAuthToken(session.accessToken);\n const authResponse = await this.http.get<GetCurrentSessionResponse>('/api/auth/sessions/current');\n \n // Get the user's profile using query builder\n const { data: profile, error: profileError } = await this.database\n .from('users')\n .select('*')\n .eq('id', authResponse.user.id)\n .single();\n \n if (profileError && profileError.statusCode !== 406) { // 406 = not found\n return { data: null, error: profileError };\n }\n \n return {\n data: {\n user: authResponse.user,\n profile: profile\n },\n error: null\n };\n } catch (error) {\n // If unauthorized, clear session\n if (error instanceof InsForgeError && error.statusCode === 401) {\n await this.signOut();\n return { data: null, error: null };\n }\n \n // Pass through all other errors unchanged\n if (error instanceof InsForgeError) {\n return { data: null, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: null, \n error: new InsForgeError(\n 'An unexpected error occurred while fetching user',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Get any user's profile by ID\n * Returns profile information from the users table (nickname, avatar_url, bio, etc.)\n */\n async getProfile(userId: string): Promise<{\n data: any | null;\n error: InsForgeError | null;\n }> {\n const { data, error } = await this.database\n .from('users')\n .select('*')\n .eq('id', userId)\n .single();\n \n // Handle not found as null, not error\n if (error && error.statusCode === 406) {\n return { data: null, error: null };\n }\n \n return { data, error };\n }\n\n /**\n * Get the current session (only session data, no API call)\n * Returns the stored JWT token and basic user info from local storage\n */\n async getCurrentSession(): Promise<{\n data: { session: AuthSession | null };\n error: InsForgeError | null;\n }> {\n try {\n const session = this.tokenManager.getSession();\n \n if (session?.accessToken) {\n this.http.setAuthToken(session.accessToken);\n return { data: { session }, error: null };\n }\n\n return { data: { session: null }, error: null };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: { session: null }, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: { session: null }, \n error: new InsForgeError(\n 'An unexpected error occurred while getting session',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Set/Update the current user's profile\n * Updates profile information in the users table (nickname, avatar_url, bio, etc.)\n */\n async setProfile(profile: {\n nickname?: string;\n avatar_url?: string;\n bio?: string;\n birthday?: string;\n [key: string]: any;\n }): Promise<{\n data: any | null;\n error: InsForgeError | null;\n }> {\n // Get current session to get user ID\n const session = this.tokenManager.getSession();\n if (!session?.user?.id) {\n return { \n data: null, \n error: new InsForgeError(\n 'No authenticated user found',\n 401,\n 'UNAUTHENTICATED'\n )\n };\n }\n\n // Update the profile using query builder\n return await this.database\n .from('users')\n .update(profile)\n .eq('id', session.user.id)\n .select()\n .single();\n }\n\n\n}","/**\n * Storage module for InsForge SDK\n * Handles file uploads, downloads, and bucket management\n */\n\nimport { HttpClient } from '../lib/http-client';\nimport { InsForgeError } from '../types';\nimport type { \n StorageFileSchema,\n ListObjectsResponseSchema\n} from '@insforge/shared-schemas';\n\nexport interface StorageResponse<T> {\n data: T | null;\n error: InsForgeError | null;\n}\n\n/**\n * Storage bucket operations\n */\nexport class StorageBucket {\n constructor(\n private bucketName: string,\n private http: HttpClient\n ) {}\n\n /**\n * Upload a file with a specific key\n * @param path - The object key/path\n * @param file - File, Blob, or FormData to upload\n */\n async upload(\n path: string,\n file: File | Blob | FormData\n ): Promise<StorageResponse<StorageFileSchema>> {\n try {\n const formData = file instanceof FormData ? file : new FormData();\n \n if (!(file instanceof FormData)) {\n formData.append('file', file);\n }\n\n // Use PUT for specific path\n const response = await this.http.request<StorageFileSchema>(\n 'PUT',\n `/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`,\n {\n body: formData as any,\n headers: {\n // Don't set Content-Type, let browser set multipart boundary\n }\n }\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Upload failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Upload a file with auto-generated key\n * @param file - File, Blob, or FormData to upload\n */\n async uploadAuto(\n file: File | Blob | FormData\n ): Promise<StorageResponse<StorageFileSchema>> {\n try {\n const formData = file instanceof FormData ? file : new FormData();\n \n if (!(file instanceof FormData)) {\n formData.append('file', file);\n }\n\n // Use POST for auto-generated key\n const response = await this.http.request<StorageFileSchema>(\n 'POST',\n `/api/storage/buckets/${this.bucketName}/objects`,\n {\n body: formData as any,\n headers: {\n // Don't set Content-Type, let browser set multipart boundary\n }\n }\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Upload failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Download a file\n * @param path - The object key/path\n * Returns the file as a Blob\n */\n async download(path: string): Promise<{ data: Blob | null; error: InsForgeError | null }> {\n try {\n // For binary data, we need to use fetch directly with proper response handling\n // The http.request method expects JSON responses, so we can't use it for blobs\n const url = `${this.http.baseUrl}/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`;\n \n const response = await this.http.fetch(url, {\n method: 'GET',\n headers: this.http.getHeaders()\n });\n\n if (!response.ok) {\n try {\n const error = await response.json();\n throw InsForgeError.fromApiError(error);\n } catch {\n throw new InsForgeError(\n `Download failed: ${response.statusText}`,\n response.status,\n 'STORAGE_ERROR'\n );\n }\n }\n\n const blob = await response.blob();\n return { data: blob, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Download failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Get public URL for a file\n * @param path - The object key/path\n */\n getPublicUrl(path: string): string {\n return `${this.http.baseUrl}/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`;\n }\n\n /**\n * List objects in the bucket\n * @param prefix - Filter by key prefix\n * @param search - Search in file names\n * @param limit - Maximum number of results (default: 100, max: 1000)\n * @param offset - Number of results to skip\n */\n async list(options?: {\n prefix?: string;\n search?: string;\n limit?: number;\n offset?: number;\n }): Promise<StorageResponse<ListObjectsResponseSchema>> {\n try {\n const params: Record<string, string> = {};\n \n if (options?.prefix) params.prefix = options.prefix;\n if (options?.search) params.search = options.search;\n if (options?.limit) params.limit = options.limit.toString();\n if (options?.offset) params.offset = options.offset.toString();\n\n const response = await this.http.get<ListObjectsResponseSchema>(\n `/api/storage/buckets/${this.bucketName}/objects`,\n { params }\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'List failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Delete a file\n * @param path - The object key/path\n */\n async remove(path: string): Promise<StorageResponse<{ message: string }>> {\n try {\n const response = await this.http.delete<{ message: string }>(\n `/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Delete failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n}\n\n/**\n * Storage module for file operations\n */\nexport class Storage {\n constructor(private http: HttpClient) {}\n\n /**\n * Get a bucket instance for operations\n * @param bucketName - Name of the bucket\n */\n from(bucketName: string): StorageBucket {\n return new StorageBucket(bucketName, this.http);\n }\n}","import { InsForgeConfig } from './types';\nimport { HttpClient } from './lib/http-client';\nimport { TokenManager } from './lib/token-manager';\nimport { Auth } from './modules/auth';\nimport { Database } from './modules/database';\nimport { Storage } from './modules/storage';\n\n/**\n * Main InsForge SDK Client\n * \n * @example\n * ```typescript\n * import { InsForgeClient } from '@insforge/sdk';\n * \n * const client = new InsForgeClient({\n * baseUrl: 'http://localhost:7130'\n * });\n * \n * // Authentication\n * const session = await client.auth.register({\n * email: 'user@example.com',\n * password: 'password123',\n * name: 'John Doe'\n * });\n * \n * // Database operations\n * const { data, error } = await client.database\n * .from('posts')\n * .select('*')\n * .eq('user_id', session.user.id)\n * .order('created_at', { ascending: false })\n * .limit(10);\n * \n * // Insert data\n * const { data: newPost } = await client.database\n * .from('posts')\n * .insert({ title: 'Hello', content: 'World' })\n * .single();\n * ```\n */\nexport class InsForgeClient {\n private http: HttpClient;\n private tokenManager: TokenManager;\n \n public readonly auth: Auth;\n public readonly database: Database;\n public readonly storage: Storage;\n\n constructor(config: InsForgeConfig = {}) {\n this.http = new HttpClient(config);\n this.tokenManager = new TokenManager(config.storage);\n \n this.auth = new Auth(\n this.http,\n this.tokenManager\n );\n \n this.database = new Database(this.http);\n this.storage = new Storage(this.http);\n }\n\n\n /**\n * Set a custom API key for authentication\n * This is useful for server-to-server communication\n * \n * @param apiKey - The API key (should start with 'ik_')\n * \n * @example\n * ```typescript\n * client.setApiKey('ik_your_api_key_here');\n * ```\n */\n setApiKey(apiKey: string): void {\n // API keys can be used as Bearer tokens\n this.http.setAuthToken(apiKey);\n }\n\n /**\n * Get the underlying HTTP client for custom requests\n * \n * @example\n * ```typescript\n * const httpClient = client.getHttpClient();\n * const customData = await httpClient.get('/api/custom-endpoint');\n * ```\n */\n getHttpClient(): HttpClient {\n return this.http;\n }\n\n /**\n * Future modules will be added here:\n * - database: Database operations\n * - storage: File storage operations\n * - functions: Serverless functions\n * - tables: Table management\n * - metadata: Backend metadata\n */\n}","/**\n * @insforge/sdk - TypeScript SDK for InsForge Backend-as-a-Service\n * \n * @packageDocumentation\n */\n\n// Main client\nexport { InsForgeClient } from './client';\n\n// Types\nexport type {\n InsForgeConfig,\n InsForgeConfig as ClientOptions, // Alias for compatibility\n TokenStorage,\n AuthSession,\n ApiError,\n} from './types';\n\nexport { InsForgeError } from './types';\n\n// Re-export shared schemas that SDK users will need\nexport type {\n UserSchema,\n CreateUserRequest,\n CreateSessionRequest,\n AuthErrorResponse,\n} from '@insforge/shared-schemas';\n\n// Re-export auth module for advanced usage\nexport { Auth } from './modules/auth';\n\n// Re-export database module and types\nexport { Database, QueryBuilder } from './modules/database';\nexport type { DatabaseResponse } from './modules/database';\n\n// Re-export storage module and types\nexport { Storage, StorageBucket } from './modules/storage';\nexport type { StorageResponse } from './modules/storage';\n\n// Re-export utilities for advanced usage\nexport { HttpClient } from './lib/http-client';\nexport { TokenManager } from './lib/token-manager';\n\n// Factory function for creating clients (Supabase-style)\nimport { InsForgeClient } from './client';\nimport { InsForgeConfig } from './types';\n\nexport function createClient(config: InsForgeConfig): InsForgeClient {\n return new InsForgeClient(config);\n}\n\n// Default export for convenience\nexport default InsForgeClient;"],"mappings":";AAmEO,IAAM,gBAAN,MAAM,uBAAsB,MAAM;AAAA,EAKvC,YAAY,SAAiB,YAAoB,OAAe,aAAsB;AACpF,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,QAAQ;AACb,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,OAAO,aAAa,UAAmC;AACrD,WAAO,IAAI;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAAA,EACF;AACF;;;AClFO,IAAM,aAAN,MAAiB;AAAA,EAKtB,YAAY,QAAwB;AAClC,SAAK,UAAU,OAAO,OAAO;AAE7B,SAAK,QAAQ,OAAO,UAAU,WAAW,QAAQ,WAAW,MAAM,KAAK,UAAU,IAAI;AACrF,SAAK,iBAAiB;AAAA,MACpB,GAAG,OAAO;AAAA,IACZ;AAGA,QAAI,OAAO,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AO,OAAO;AAEnD,SAAK,OAAO,IAAI;AAAA,MACd,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AAEA,SAAK,WAAW,IAAI,SAAS,KAAK,IAAI;AACtC,SAAK,UAAU,IAAI,QAAQ,KAAK,IAAI;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,UAAU,QAAsB;AAE9B,SAAK,KAAK,aAAa,MAAM;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,gBAA4B;AAC1B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUF;;;ACpDO,SAAS,aAAa,QAAwC;AACnE,SAAO,IAAI,eAAe,MAAM;AAClC;AAGA,IAAO,gBAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts","../src/lib/http-client.ts","../src/lib/token-manager.ts","../src/modules/database.ts","../src/modules/auth.ts","../src/modules/storage.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["/**\n * InsForge SDK Types - only SDK-specific types here\n * Use @insforge/shared-schemas directly for API types\n */\n\nimport type { UserSchema } from '@insforge/shared-schemas';\n\nexport interface InsForgeConfig {\n /**\n * The URL of the InsForge backend API\n * @default \"http://localhost:7130\"\n */\n url?: string;\n\n /**\n * API key (optional)\n * Can be used for server-side operations or specific use cases\n */\n apiKey?: string;\n\n /**\n * Custom fetch implementation (useful for Node.js environments)\n */\n fetch?: typeof fetch;\n\n /**\n * Storage adapter for persisting tokens\n */\n storage?: TokenStorage;\n\n /**\n * Whether to automatically refresh tokens before they expire\n * @default true\n */\n autoRefreshToken?: boolean;\n\n /**\n * Whether to persist session in storage\n * @default true\n */\n persistSession?: boolean;\n\n /**\n * Custom headers to include with every request\n */\n headers?: Record<string, string>;\n}\n\nexport interface TokenStorage {\n getItem(key: string): string | null | Promise<string | null>;\n setItem(key: string, value: string): void | Promise<void>;\n removeItem(key: string): void | Promise<void>;\n}\n\nexport interface AuthSession {\n user: UserSchema;\n accessToken: string;\n expiresAt?: Date;\n}\n\nexport interface ApiError {\n error: string;\n message: string;\n statusCode: number;\n nextActions?: string;\n}\n\nexport class InsForgeError extends Error {\n public statusCode: number;\n public error: string;\n public nextActions?: string;\n\n constructor(message: string, statusCode: number, error: string, nextActions?: string) {\n super(message);\n this.name = 'InsForgeError';\n this.statusCode = statusCode;\n this.error = error;\n this.nextActions = nextActions;\n }\n\n static fromApiError(apiError: ApiError): InsForgeError {\n return new InsForgeError(\n apiError.message,\n apiError.statusCode,\n apiError.error,\n apiError.nextActions\n );\n }\n}","import { InsForgeConfig, ApiError, InsForgeError } from '../types';\n\nexport interface RequestOptions extends RequestInit {\n params?: Record<string, string>;\n}\n\nexport class HttpClient {\n public readonly baseUrl: string;\n public readonly fetch: typeof fetch;\n private defaultHeaders: Record<string, string>;\n\n constructor(config: InsForgeConfig) {\n this.baseUrl = config.url || 'http://localhost:7130';\n // Properly bind fetch to maintain its context\n this.fetch = config.fetch || (globalThis.fetch ? globalThis.fetch.bind(globalThis) : undefined as any);\n this.defaultHeaders = {\n ...config.headers,\n };\n \n // Add API key if provided\n if (config.apiKey) {\n this.defaultHeaders['Authorization'] = `Bearer ${config.apiKey}`;\n }\n\n if (!this.fetch) {\n throw new Error(\n 'Fetch is not available. Please provide a fetch implementation in the config.'\n );\n }\n }\n\n private buildUrl(path: string, params?: Record<string, string>): string {\n const url = new URL(path, this.baseUrl);\n if (params) {\n Object.entries(params).forEach(([key, value]) => {\n url.searchParams.append(key, value);\n });\n }\n return url.toString();\n }\n\n async request<T>(\n method: string,\n path: string,\n options: RequestOptions = {}\n ): Promise<T> {\n const { params, headers = {}, body, ...fetchOptions } = options;\n \n const url = this.buildUrl(path, params);\n \n const requestHeaders: Record<string, string> = {\n ...this.defaultHeaders,\n };\n \n // Handle body serialization\n let processedBody: any;\n if (body !== undefined) {\n // Check if body is FormData (for file uploads)\n if (typeof FormData !== 'undefined' && body instanceof FormData) {\n // Don't set Content-Type for FormData, let browser set it with boundary\n processedBody = body;\n } else {\n // JSON body\n if (method !== 'GET') {\n requestHeaders['Content-Type'] = 'application/json;charset=UTF-8';\n }\n processedBody = JSON.stringify(body);\n }\n }\n \n Object.assign(requestHeaders, headers);\n \n const response = await this.fetch(url, {\n method,\n headers: requestHeaders,\n body: processedBody,\n ...fetchOptions,\n });\n\n // Handle 204 No Content\n if (response.status === 204) {\n return undefined as T;\n }\n\n // Try to parse JSON response\n let data: any;\n const contentType = response.headers.get('content-type');\n // Check for any JSON content type (including PostgREST's vnd.pgrst.object+json)\n if (contentType?.includes('json')) {\n data = await response.json();\n } else {\n // For non-JSON responses, return text\n data = await response.text();\n }\n\n // Handle errors\n if (!response.ok) {\n if (data && typeof data === 'object' && 'error' in data) {\n throw InsForgeError.fromApiError(data as ApiError);\n }\n throw new InsForgeError(\n `Request failed: ${response.statusText}`,\n response.status,\n 'REQUEST_FAILED'\n );\n }\n\n return data as T;\n }\n\n get<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('GET', path, options);\n }\n\n post<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('POST', path, { ...options, body });\n }\n\n put<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('PUT', path, { ...options, body });\n }\n\n patch<T>(path: string, body?: any, options?: RequestOptions): Promise<T> {\n return this.request<T>('PATCH', path, { ...options, body });\n }\n\n delete<T>(path: string, options?: RequestOptions): Promise<T> {\n return this.request<T>('DELETE', path, options);\n }\n\n setAuthToken(token: string | null) {\n if (token) {\n this.defaultHeaders['Authorization'] = `Bearer ${token}`;\n } else {\n delete this.defaultHeaders['Authorization'];\n }\n }\n\n getHeaders(): Record<string, string> {\n return { ...this.defaultHeaders };\n }\n}","import { TokenStorage, AuthSession } from '../types';\n\nconst TOKEN_KEY = 'insforge-auth-token';\nconst USER_KEY = 'insforge-auth-user';\n\nexport class TokenManager {\n private storage: TokenStorage;\n\n constructor(storage?: TokenStorage) {\n if (storage) {\n // Use provided storage\n this.storage = storage;\n } else if (typeof window !== 'undefined' && window.localStorage) {\n // Browser: use localStorage\n this.storage = window.localStorage;\n } else {\n // Node.js: use in-memory storage\n const store = new Map<string, string>();\n this.storage = {\n getItem: (key: string) => store.get(key) || null,\n setItem: (key: string, value: string) => { store.set(key, value); },\n removeItem: (key: string) => { store.delete(key); }\n };\n }\n }\n\n saveSession(session: AuthSession): void {\n this.storage.setItem(TOKEN_KEY, session.accessToken);\n this.storage.setItem(USER_KEY, JSON.stringify(session.user));\n }\n\n getSession(): AuthSession | null {\n const token = this.storage.getItem(TOKEN_KEY);\n const userStr = this.storage.getItem(USER_KEY);\n\n if (!token || !userStr) {\n return null;\n }\n\n try {\n const user = JSON.parse(userStr as string);\n return { accessToken: token as string, user };\n } catch {\n this.clearSession();\n return null;\n }\n }\n\n getAccessToken(): string | null {\n const token = this.storage.getItem(TOKEN_KEY);\n return typeof token === 'string' ? token : null;\n }\n\n clearSession(): void {\n this.storage.removeItem(TOKEN_KEY);\n this.storage.removeItem(USER_KEY);\n }\n}","/**\n * Database module for InsForge SDK\n * Supabase-style query builder for PostgREST operations\n */\n\nimport { HttpClient } from '../lib/http-client';\nimport { InsForgeError } from '../types';\n\nexport interface DatabaseResponse<T> {\n data: T | null;\n error: InsForgeError | null;\n count?: number;\n}\n\n/**\n * Query builder for database operations\n * Uses method chaining like Supabase\n */\nexport class QueryBuilder<T = any> {\n private method: 'GET' | 'POST' | 'PATCH' | 'DELETE' = 'GET';\n private headers: Record<string, string> = {};\n private queryParams: Record<string, string> = {};\n private body?: any;\n\n constructor(\n private table: string,\n private http: HttpClient\n ) {}\n\n /**\n * Perform a SELECT query\n * For mutations (insert/update/delete), this enables returning data\n * @param columns - Columns to select (default: '*')\n * @example\n * .select('*')\n * .select('id, title, content')\n * .select('*, users!inner(*)') // Join with users table\n * .select('*, profile:profiles(*)') // Join with alias\n * .insert({ title: 'New' }).select() // Returns inserted data\n */\n select(columns: string = '*'): this {\n // For mutations, add return=representation header\n if (this.method !== 'GET') {\n const existingPrefer = this.headers['Prefer'] || '';\n const preferParts = existingPrefer ? [existingPrefer] : [];\n if (!preferParts.some(p => p.includes('return='))) {\n preferParts.push('return=representation');\n }\n this.headers['Prefer'] = preferParts.join(',');\n }\n \n // Always set the select parameter for GET requests\n // This enables PostgREST joins and nested queries\n if (this.method === 'GET' && columns) {\n this.queryParams.select = columns;\n } else if (columns !== '*') {\n // For mutations, only set if not default\n this.queryParams.select = columns;\n }\n return this;\n }\n\n /**\n * Perform an INSERT\n * @param values - Single object or array of objects\n * @param options - { upsert: true } for upsert behavior\n * @example\n * .insert({ title: 'Hello', content: 'World' }).select()\n * .insert([{ title: 'Post 1' }, { title: 'Post 2' }]).select()\n */\n insert(values: Partial<T> | Partial<T>[], options?: { upsert?: boolean }): this {\n this.method = 'POST';\n this.body = Array.isArray(values) ? values : [values];\n \n if (options?.upsert) {\n this.headers['Prefer'] = 'resolution=merge-duplicates';\n }\n \n return this;\n }\n\n /**\n * Perform an UPDATE\n * @param values - Object with fields to update\n * @example\n * .update({ title: 'Updated Title' }).select()\n */\n update(values: Partial<T>): this {\n this.method = 'PATCH';\n this.body = values;\n return this;\n }\n\n /**\n * Perform a DELETE\n * @example\n * .delete().select()\n */\n delete(): this {\n this.method = 'DELETE';\n return this;\n }\n\n /**\n * Perform an UPSERT\n * @param values - Single object or array of objects\n * @example\n * .upsert({ id: 1, title: 'Hello' })\n */\n upsert(values: Partial<T> | Partial<T>[]): this {\n return this.insert(values, { upsert: true });\n }\n\n // FILTERS\n\n /**\n * Filter by column equal to value\n * @example .eq('id', 123)\n */\n eq(column: string, value: any): this {\n this.queryParams[column] = `eq.${value}`;\n return this;\n }\n\n /**\n * Filter by column not equal to value\n * @example .neq('status', 'draft')\n */\n neq(column: string, value: any): this {\n this.queryParams[column] = `neq.${value}`;\n return this;\n }\n\n /**\n * Filter by column greater than value\n * @example .gt('age', 18)\n */\n gt(column: string, value: any): this {\n this.queryParams[column] = `gt.${value}`;\n return this;\n }\n\n /**\n * Filter by column greater than or equal to value\n * @example .gte('price', 100)\n */\n gte(column: string, value: any): this {\n this.queryParams[column] = `gte.${value}`;\n return this;\n }\n\n /**\n * Filter by column less than value\n * @example .lt('stock', 10)\n */\n lt(column: string, value: any): this {\n this.queryParams[column] = `lt.${value}`;\n return this;\n }\n\n /**\n * Filter by column less than or equal to value\n * @example .lte('discount', 50)\n */\n lte(column: string, value: any): this {\n this.queryParams[column] = `lte.${value}`;\n return this;\n }\n\n /**\n * Filter by pattern matching (case-sensitive)\n * @example .like('email', '%@gmail.com')\n */\n like(column: string, pattern: string): this {\n this.queryParams[column] = `like.${pattern}`;\n return this;\n }\n\n /**\n * Filter by pattern matching (case-insensitive)\n * @example .ilike('name', '%john%')\n */\n ilike(column: string, pattern: string): this {\n this.queryParams[column] = `ilike.${pattern}`;\n return this;\n }\n\n /**\n * Filter by checking if column is a value\n * @example .is('deleted_at', null)\n */\n is(column: string, value: null | boolean): this {\n if (value === null) {\n this.queryParams[column] = 'is.null';\n } else {\n this.queryParams[column] = `is.${value}`;\n }\n return this;\n }\n\n /**\n * Filter by checking if value is in array\n * @example .in('status', ['active', 'pending'])\n */\n in(column: string, values: any[]): this {\n this.queryParams[column] = `in.(${values.join(',')})`;\n return this;\n }\n\n // MODIFIERS\n\n /**\n * Order by column\n * @example \n * .order('created_at') // ascending\n * .order('created_at', { ascending: false }) // descending\n */\n order(column: string, options?: { ascending?: boolean }): this {\n const ascending = options?.ascending !== false;\n this.queryParams.order = ascending ? column : `${column}.desc`;\n return this;\n }\n\n /**\n * Limit the number of rows returned\n * @example .limit(10)\n */\n limit(count: number): this {\n this.queryParams.limit = count.toString();\n return this;\n }\n\n /**\n * Return results from an offset\n * @example .offset(20)\n */\n offset(count: number): this {\n this.queryParams.offset = count.toString();\n return this;\n }\n\n /**\n * Set a range of rows to return\n * @example .range(0, 9) // First 10 rows\n */\n range(from: number, to: number): this {\n this.headers['Range'] = `${from}-${to}`;\n return this;\n }\n\n /**\n * Return a single object instead of array\n * @example .single()\n */\n single(): this {\n this.headers['Accept'] = 'application/vnd.pgrst.object+json';\n return this;\n }\n\n /**\n * Get the total count (use with select)\n * @example .select('*', { count: 'exact' })\n */\n count(algorithm: 'exact' | 'planned' | 'estimated' = 'exact'): this {\n const prefer = this.headers['Prefer'] || '';\n this.headers['Prefer'] = prefer ? `${prefer},count=${algorithm}` : `count=${algorithm}`;\n return this;\n }\n\n /**\n * Execute the query and return results\n */\n async execute(): Promise<DatabaseResponse<T>> {\n try {\n const path = `/api/database/records/${this.table}`;\n let response: any;\n\n switch (this.method) {\n case 'GET':\n response = await this.http.get<T>(path, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n \n case 'POST':\n response = await this.http.post<T>(path, this.body, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n \n case 'PATCH':\n response = await this.http.patch<T>(path, this.body, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n \n case 'DELETE':\n response = await this.http.delete<T>(path, {\n params: this.queryParams,\n headers: this.headers\n });\n break;\n }\n\n return { data: response, error: null };\n } catch (error) {\n return {\n data: null,\n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Database operation failed',\n 500,\n 'DATABASE_ERROR'\n )\n };\n }\n }\n\n /**\n * Make QueryBuilder thenable for async/await\n */\n then<TResult1 = DatabaseResponse<T>, TResult2 = never>(\n onfulfilled?: ((value: DatabaseResponse<T>) => TResult1 | PromiseLike<TResult1>) | undefined | null,\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null\n ): Promise<TResult1 | TResult2> {\n return this.execute().then(onfulfilled, onrejected);\n }\n}\n\n/**\n * Database client for InsForge SDK\n * Provides Supabase-style interface\n */\nexport class Database {\n constructor(private http: HttpClient) {}\n\n /**\n * Create a query builder for a table\n * @param table - The table name\n * @example\n * const { data, error } = await client.database\n * .from('posts')\n * .select('*')\n * .eq('user_id', userId)\n * .order('created_at', { ascending: false })\n * .limit(10);\n */\n from<T = any>(table: string): QueryBuilder<T> {\n return new QueryBuilder<T>(table, this.http);\n }\n}","/**\n * Auth module for InsForge SDK\n * Uses shared schemas for type safety\n */\n\nimport { HttpClient } from '../lib/http-client';\nimport { TokenManager } from '../lib/token-manager';\nimport { AuthSession, InsForgeError } from '../types';\nimport { Database } from './database';\n\nimport type {\n CreateUserRequest,\n CreateUserResponse,\n CreateSessionRequest,\n CreateSessionResponse,\n GetCurrentSessionResponse,\n GetOauthUrlResponse,\n} from '@insforge/shared-schemas';\n\nexport class Auth {\n private database: Database;\n \n constructor(\n private http: HttpClient,\n private tokenManager: TokenManager\n ) {\n this.database = new Database(http);\n \n // Auto-detect OAuth callback parameters in the URL\n this.detectOAuthCallback();\n }\n\n /**\n * Automatically detect and handle OAuth callback parameters in the URL\n * This runs on initialization to seamlessly complete the OAuth flow\n * Matches the backend's OAuth callback response (backend/src/api/routes/auth.ts:540-544)\n */\n private detectOAuthCallback(): void {\n // Only run in browser environment\n if (typeof window === 'undefined') return;\n \n try {\n const params = new URLSearchParams(window.location.search);\n \n // Backend returns: access_token, user_id, email, name (optional)\n const accessToken = params.get('access_token');\n const userId = params.get('user_id');\n const email = params.get('email');\n const name = params.get('name');\n \n // Check if we have OAuth callback parameters\n if (accessToken && userId && email) {\n // Create session with the data from backend\n const session: AuthSession = {\n accessToken,\n user: {\n id: userId,\n email: email,\n name: name || '',\n // These fields are not provided by backend OAuth callback\n // They'll be populated when calling getCurrentUser()\n emailVerified: false,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n } as any,\n };\n \n // Save session and set auth token\n this.tokenManager.saveSession(session);\n this.http.setAuthToken(accessToken);\n \n // Clean up the URL to remove sensitive parameters\n const url = new URL(window.location.href);\n url.searchParams.delete('access_token');\n url.searchParams.delete('user_id');\n url.searchParams.delete('email');\n url.searchParams.delete('name');\n \n // Also handle error case from backend (line 581)\n if (params.has('error')) {\n url.searchParams.delete('error');\n }\n \n // Replace URL without adding to browser history\n window.history.replaceState({}, document.title, url.toString());\n }\n } catch (error) {\n // Silently continue - don't break initialization\n console.debug('OAuth callback detection skipped:', error);\n }\n }\n\n /**\n * Sign up a new user\n */\n async signUp(request: CreateUserRequest): Promise<{\n data: CreateUserResponse | null;\n error: InsForgeError | null;\n }> {\n try {\n const response = await this.http.post<CreateUserResponse>('/api/auth/users', request);\n \n // Save session internally\n const session: AuthSession = {\n accessToken: response.accessToken,\n user: response.user,\n };\n this.tokenManager.saveSession(session);\n this.http.setAuthToken(response.accessToken);\n\n return { \n data: response,\n error: null \n };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: null, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: null, \n error: new InsForgeError(\n error instanceof Error ? error.message : 'An unexpected error occurred during sign up',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Sign in with email and password\n */\n async signInWithPassword(request: CreateSessionRequest): Promise<{\n data: CreateSessionResponse | null;\n error: InsForgeError | null;\n }> {\n try {\n const response = await this.http.post<CreateSessionResponse>('/api/auth/sessions', request);\n \n // Save session internally\n const session: AuthSession = {\n accessToken: response.accessToken,\n user: response.user,\n };\n this.tokenManager.saveSession(session);\n this.http.setAuthToken(response.accessToken);\n\n return { \n data: response,\n error: null \n };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: null, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: null, \n error: new InsForgeError(\n 'An unexpected error occurred during sign in',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Sign in with OAuth provider\n */\n async signInWithOAuth(options: {\n provider: 'google' | 'github';\n redirectTo?: string;\n skipBrowserRedirect?: boolean;\n }): Promise<{\n data: { url?: string; provider?: string };\n error: InsForgeError | null;\n }> {\n try {\n const { provider, redirectTo, skipBrowserRedirect } = options;\n \n const params = redirectTo \n ? { redirect_uri: redirectTo } \n : undefined;\n \n const endpoint = `/api/auth/oauth/${provider}`;\n const response = await this.http.get<GetOauthUrlResponse>(endpoint, { params });\n \n // Automatically redirect in browser unless told not to\n if (typeof window !== 'undefined' && !skipBrowserRedirect) {\n window.location.href = response.authUrl;\n return { data: {}, error: null };\n }\n\n return { \n data: { \n url: response.authUrl,\n provider \n }, \n error: null \n };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: {}, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: {}, \n error: new InsForgeError(\n 'An unexpected error occurred during OAuth initialization',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Sign out the current user\n */\n async signOut(): Promise<{ error: InsForgeError | null }> {\n try {\n this.tokenManager.clearSession();\n this.http.setAuthToken(null);\n return { error: null };\n } catch (error) {\n return { \n error: new InsForgeError(\n 'Failed to sign out',\n 500,\n 'SIGNOUT_ERROR'\n )\n };\n }\n }\n\n /**\n * Get the current user with full profile information\n * Returns both auth info (id, email, role) and profile data (nickname, avatar_url, bio, etc.)\n */\n async getCurrentUser(): Promise<{\n data: { user: any; profile: any } | null;\n error: InsForgeError | null;\n }> {\n try {\n // Check if we have a token\n const session = this.tokenManager.getSession();\n if (!session?.accessToken) {\n return { data: null, error: null };\n }\n\n // Call the API for auth info\n this.http.setAuthToken(session.accessToken);\n const authResponse = await this.http.get<GetCurrentSessionResponse>('/api/auth/sessions/current');\n \n // Get the user's profile using query builder\n const { data: profile, error: profileError } = await this.database\n .from('users')\n .select('*')\n .eq('id', authResponse.user.id)\n .single();\n \n if (profileError && profileError.statusCode !== 406) { // 406 = not found\n return { data: null, error: profileError };\n }\n \n return {\n data: {\n user: authResponse.user,\n profile: profile\n },\n error: null\n };\n } catch (error) {\n // If unauthorized, clear session\n if (error instanceof InsForgeError && error.statusCode === 401) {\n await this.signOut();\n return { data: null, error: null };\n }\n \n // Pass through all other errors unchanged\n if (error instanceof InsForgeError) {\n return { data: null, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: null, \n error: new InsForgeError(\n 'An unexpected error occurred while fetching user',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Get any user's profile by ID\n * Returns profile information from the users table (nickname, avatar_url, bio, etc.)\n */\n async getProfile(userId: string): Promise<{\n data: any | null;\n error: InsForgeError | null;\n }> {\n const { data, error } = await this.database\n .from('users')\n .select('*')\n .eq('id', userId)\n .single();\n \n // Handle not found as null, not error\n if (error && error.statusCode === 406) {\n return { data: null, error: null };\n }\n \n return { data, error };\n }\n\n /**\n * Get the current session (only session data, no API call)\n * Returns the stored JWT token and basic user info from local storage\n */\n async getCurrentSession(): Promise<{\n data: { session: AuthSession | null };\n error: InsForgeError | null;\n }> {\n try {\n const session = this.tokenManager.getSession();\n \n if (session?.accessToken) {\n this.http.setAuthToken(session.accessToken);\n return { data: { session }, error: null };\n }\n\n return { data: { session: null }, error: null };\n } catch (error) {\n // Pass through API errors unchanged\n if (error instanceof InsForgeError) {\n return { data: { session: null }, error };\n }\n \n // Generic fallback for unexpected errors\n return { \n data: { session: null }, \n error: new InsForgeError(\n 'An unexpected error occurred while getting session',\n 500,\n 'UNEXPECTED_ERROR'\n )\n };\n }\n }\n\n /**\n * Set/Update the current user's profile\n * Updates profile information in the users table (nickname, avatar_url, bio, etc.)\n */\n async setProfile(profile: {\n nickname?: string;\n avatar_url?: string;\n bio?: string;\n birthday?: string;\n [key: string]: any;\n }): Promise<{\n data: any | null;\n error: InsForgeError | null;\n }> {\n // Get current session to get user ID\n const session = this.tokenManager.getSession();\n if (!session?.user?.id) {\n return { \n data: null, \n error: new InsForgeError(\n 'No authenticated user found',\n 401,\n 'UNAUTHENTICATED'\n )\n };\n }\n\n // Update the profile using query builder\n return await this.database\n .from('users')\n .update(profile)\n .eq('id', session.user.id)\n .select()\n .single();\n }\n\n\n}","/**\n * Storage module for InsForge SDK\n * Handles file uploads, downloads, and bucket management\n */\n\nimport { HttpClient } from '../lib/http-client';\nimport { InsForgeError } from '../types';\nimport type { \n StorageFileSchema,\n ListObjectsResponseSchema\n} from '@insforge/shared-schemas';\n\nexport interface StorageResponse<T> {\n data: T | null;\n error: InsForgeError | null;\n}\n\n/**\n * Storage bucket operations\n */\nexport class StorageBucket {\n constructor(\n private bucketName: string,\n private http: HttpClient\n ) {}\n\n /**\n * Upload a file with a specific key\n * @param path - The object key/path\n * @param file - File or Blob to upload\n */\n async upload(\n path: string,\n file: File | Blob\n ): Promise<StorageResponse<StorageFileSchema>> {\n try {\n const formData = new FormData();\n formData.append('file', file);\n\n // Use PUT for specific path\n const response = await this.http.request<StorageFileSchema>(\n 'PUT',\n `/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`,\n {\n body: formData as any,\n headers: {\n // Don't set Content-Type, let browser set multipart boundary\n }\n }\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Upload failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Upload a file with auto-generated key\n * @param file - File or Blob to upload\n */\n async uploadAuto(\n file: File | Blob\n ): Promise<StorageResponse<StorageFileSchema>> {\n try {\n const formData = new FormData();\n formData.append('file', file);\n\n // Use POST for auto-generated key\n const response = await this.http.request<StorageFileSchema>(\n 'POST',\n `/api/storage/buckets/${this.bucketName}/objects`,\n {\n body: formData as any,\n headers: {\n // Don't set Content-Type, let browser set multipart boundary\n }\n }\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Upload failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Download a file\n * @param path - The object key/path\n * Returns the file as a Blob\n */\n async download(path: string): Promise<{ data: Blob | null; error: InsForgeError | null }> {\n try {\n // For binary data, we need to use fetch directly with proper response handling\n // The http.request method expects JSON responses, so we can't use it for blobs\n const url = `${this.http.baseUrl}/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`;\n \n const response = await this.http.fetch(url, {\n method: 'GET',\n headers: this.http.getHeaders()\n });\n\n if (!response.ok) {\n try {\n const error = await response.json();\n throw InsForgeError.fromApiError(error);\n } catch {\n throw new InsForgeError(\n `Download failed: ${response.statusText}`,\n response.status,\n 'STORAGE_ERROR'\n );\n }\n }\n\n const blob = await response.blob();\n return { data: blob, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Download failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Get public URL for a file\n * @param path - The object key/path\n */\n getPublicUrl(path: string): string {\n return `${this.http.baseUrl}/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`;\n }\n\n /**\n * List objects in the bucket\n * @param prefix - Filter by key prefix\n * @param search - Search in file names\n * @param limit - Maximum number of results (default: 100, max: 1000)\n * @param offset - Number of results to skip\n */\n async list(options?: {\n prefix?: string;\n search?: string;\n limit?: number;\n offset?: number;\n }): Promise<StorageResponse<ListObjectsResponseSchema>> {\n try {\n const params: Record<string, string> = {};\n \n if (options?.prefix) params.prefix = options.prefix;\n if (options?.search) params.search = options.search;\n if (options?.limit) params.limit = options.limit.toString();\n if (options?.offset) params.offset = options.offset.toString();\n\n const response = await this.http.get<ListObjectsResponseSchema>(\n `/api/storage/buckets/${this.bucketName}/objects`,\n { params }\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'List failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n\n /**\n * Delete a file\n * @param path - The object key/path\n */\n async remove(path: string): Promise<StorageResponse<{ message: string }>> {\n try {\n const response = await this.http.delete<{ message: string }>(\n `/api/storage/buckets/${this.bucketName}/objects/${encodeURIComponent(path)}`\n );\n\n return { data: response, error: null };\n } catch (error) {\n return { \n data: null, \n error: error instanceof InsForgeError ? error : new InsForgeError(\n 'Delete failed',\n 500,\n 'STORAGE_ERROR'\n )\n };\n }\n }\n}\n\n/**\n * Storage module for file operations\n */\nexport class Storage {\n constructor(private http: HttpClient) {}\n\n /**\n * Get a bucket instance for operations\n * @param bucketName - Name of the bucket\n */\n from(bucketName: string): StorageBucket {\n return new StorageBucket(bucketName, this.http);\n }\n}","import { InsForgeConfig } from './types';\nimport { HttpClient } from './lib/http-client';\nimport { TokenManager } from './lib/token-manager';\nimport { Auth } from './modules/auth';\nimport { Database } from './modules/database';\nimport { Storage } from './modules/storage';\n\n/**\n * Main InsForge SDK Client\n * \n * @example\n * ```typescript\n * import { InsForgeClient } from '@insforge/sdk';\n * \n * const client = new InsForgeClient({\n * baseUrl: 'http://localhost:7130'\n * });\n * \n * // Authentication\n * const session = await client.auth.register({\n * email: 'user@example.com',\n * password: 'password123',\n * name: 'John Doe'\n * });\n * \n * // Database operations\n * const { data, error } = await client.database\n * .from('posts')\n * .select('*')\n * .eq('user_id', session.user.id)\n * .order('created_at', { ascending: false })\n * .limit(10);\n * \n * // Insert data\n * const { data: newPost } = await client.database\n * .from('posts')\n * .insert({ title: 'Hello', content: 'World' })\n * .single();\n * ```\n */\nexport class InsForgeClient {\n private http: HttpClient;\n private tokenManager: TokenManager;\n \n public readonly auth: Auth;\n public readonly database: Database;\n public readonly storage: Storage;\n\n constructor(config: InsForgeConfig = {}) {\n this.http = new HttpClient(config);\n this.tokenManager = new TokenManager(config.storage);\n \n this.auth = new Auth(\n this.http,\n this.tokenManager\n );\n \n this.database = new Database(this.http);\n this.storage = new Storage(this.http);\n }\n\n\n /**\n * Set a custom API key for authentication\n * This is useful for server-to-server communication\n * \n * @param apiKey - The API key (should start with 'ik_')\n * \n * @example\n * ```typescript\n * client.setApiKey('ik_your_api_key_here');\n * ```\n */\n setApiKey(apiKey: string): void {\n // API keys can be used as Bearer tokens\n this.http.setAuthToken(apiKey);\n }\n\n /**\n * Get the underlying HTTP client for custom requests\n * \n * @example\n * ```typescript\n * const httpClient = client.getHttpClient();\n * const customData = await httpClient.get('/api/custom-endpoint');\n * ```\n */\n getHttpClient(): HttpClient {\n return this.http;\n }\n\n /**\n * Future modules will be added here:\n * - database: Database operations\n * - storage: File storage operations\n * - functions: Serverless functions\n * - tables: Table management\n * - metadata: Backend metadata\n */\n}","/**\n * @insforge/sdk - TypeScript SDK for InsForge Backend-as-a-Service\n * \n * @packageDocumentation\n */\n\n// Main client\nexport { InsForgeClient } from './client';\n\n// Types\nexport type {\n InsForgeConfig,\n InsForgeConfig as ClientOptions, // Alias for compatibility\n TokenStorage,\n AuthSession,\n ApiError,\n} from './types';\n\nexport { InsForgeError } from './types';\n\n// Re-export shared schemas that SDK users will need\nexport type {\n UserSchema,\n CreateUserRequest,\n CreateSessionRequest,\n AuthErrorResponse,\n} from '@insforge/shared-schemas';\n\n// Re-export auth module for advanced usage\nexport { Auth } from './modules/auth';\n\n// Re-export database module and types\nexport { Database, QueryBuilder } from './modules/database';\nexport type { DatabaseResponse } from './modules/database';\n\n// Re-export storage module and types\nexport { Storage, StorageBucket } from './modules/storage';\nexport type { StorageResponse } from './modules/storage';\n\n// Re-export utilities for advanced usage\nexport { HttpClient } from './lib/http-client';\nexport { TokenManager } from './lib/token-manager';\n\n// Factory function for creating clients (Supabase-style)\nimport { InsForgeClient } from './client';\nimport { InsForgeConfig } from './types';\n\nexport function createClient(config: InsForgeConfig): InsForgeClient {\n return new InsForgeClient(config);\n}\n\n// Default export for convenience\nexport default InsForgeClient;"],"mappings":";AAmEO,IAAM,gBAAN,MAAM,uBAAsB,MAAM;AAAA,EAKvC,YAAY,SAAiB,YAAoB,OAAe,aAAsB;AACpF,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,QAAQ;AACb,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,OAAO,aAAa,UAAmC;AACrD,WAAO,IAAI;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;A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ACF;;;AC3LO,IAAM,iBAAN,MAAqB;AAAA,EAQ1B,YAAY,SAAyB,CAAC,GAAG;AACvC,SAAK,OAAO,IAAI,WAAW,MAAM;AACjC,SAAK,eAAe,IAAI,aAAa,OAAO,OAAO;AAEnD,SAAK,OAAO,IAAI;AAAA,MACd,KAAK;AAAA,MACL,KAAK;AAAA,IACP;AAEA,SAAK,WAAW,IAAI,SAAS,KAAK,IAAI;AACtC,SAAK,UAAU,IAAI,QAAQ,KAAK,IAAI;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,UAAU,QAAsB;AAE9B,SAAK,KAAK,aAAa,MAAM;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,gBAA4B;AAC1B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUF;;;ACpDO,SAAS,aAAa,QAAwC;AACnE,SAAO,IAAI,eAAe,MAAM;AAClC;AAGA,IAAO,gBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@insforge/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "TypeScript SDK for InsForge Backend-as-a-Service platform",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"author": "InsForge",
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@insforge/shared-schemas": "
|
|
39
|
+
"@insforge/shared-schemas": "file:../InsForge/shared-schemas/insforge-shared-schemas-1.0.5.tgz"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^20.11.24",
|