@insforge/sdk 0.0.21 → 0.0.22

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 CHANGED
@@ -1,5 +1,6 @@
1
1
  import { UserSchema, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, StorageFileSchema, ListObjectsResponseSchema } from '@insforge/shared-schemas';
2
2
  export { AuthErrorResponse, CreateSessionRequest, CreateUserRequest, UserSchema } from '@insforge/shared-schemas';
3
+ import * as _supabase_postgrest_js from '@supabase/postgrest-js';
3
4
 
4
5
  /**
5
6
  * InsForge SDK Types - only SDK-specific types here
@@ -151,7 +152,7 @@ declare class Auth {
151
152
  user: any;
152
153
  profile: any;
153
154
  } | null;
154
- error: InsForgeError | null;
155
+ error: any | null;
155
156
  }>;
156
157
  /**
157
158
  * Get any user's profile by ID
@@ -159,7 +160,7 @@ declare class Auth {
159
160
  */
160
161
  getProfile(userId: string): Promise<{
161
162
  data: any | null;
162
- error: InsForgeError | null;
163
+ error: any | null;
163
164
  }>;
164
165
  /**
165
166
  * Get the current session (only session data, no API call)
@@ -183,187 +184,53 @@ declare class Auth {
183
184
  [key: string]: any;
184
185
  }): Promise<{
185
186
  data: any | null;
186
- error: InsForgeError | null;
187
+ error: any | null;
187
188
  }>;
188
189
  }
189
190
 
190
191
  /**
191
- * Database module for InsForge SDK
192
- * Supabase-style query builder for PostgREST operations
193
- */
194
-
195
- interface DatabaseResponse<T> {
196
- data: T | null;
197
- error: InsForgeError | null;
198
- count?: number;
199
- }
200
- /**
201
- * Query builder for database operations
202
- * Uses method chaining like Supabase
203
- */
204
- declare class QueryBuilder<T = any> {
205
- private table;
206
- private http;
207
- private method;
208
- private headers;
209
- private queryParams;
210
- private body?;
211
- constructor(table: string, http: HttpClient);
212
- /**
213
- * Perform a SELECT query
214
- * For mutations (insert/update/delete), this enables returning data
215
- * @param columns - Columns to select (default: '*')
216
- * @example
217
- * .select('*')
218
- * .select('id, title, content')
219
- * .select('*, users!inner(*)') // Join with users table
220
- * .select('*, profile:profiles(*)') // Join with alias
221
- * .insert({ title: 'New' }).select() // Returns inserted data
222
- */
223
- select(columns?: string): this;
224
- /**
225
- * Perform an INSERT
226
- * @param values - Single object or array of objects
227
- * @param options - { upsert: true } for upsert behavior
228
- * @example
229
- * .insert({ title: 'Hello', content: 'World' }).select()
230
- * .insert([{ title: 'Post 1' }, { title: 'Post 2' }]).select()
231
- */
232
- insert(values: Partial<T> | Partial<T>[], options?: {
233
- upsert?: boolean;
234
- }): this;
235
- /**
236
- * Perform an UPDATE
237
- * @param values - Object with fields to update
238
- * @example
239
- * .update({ title: 'Updated Title' }).select()
240
- */
241
- update(values: Partial<T>): this;
242
- /**
243
- * Perform a DELETE
244
- * @example
245
- * .delete().select()
246
- */
247
- delete(): this;
248
- /**
249
- * Perform an UPSERT
250
- * @param values - Single object or array of objects
251
- * @example
252
- * .upsert({ id: 1, title: 'Hello' })
253
- */
254
- upsert(values: Partial<T> | Partial<T>[]): this;
255
- /**
256
- * Filter by column equal to value
257
- * @example .eq('id', 123)
258
- */
259
- eq(column: string, value: any): this;
260
- /**
261
- * Filter by column not equal to value
262
- * @example .neq('status', 'draft')
263
- */
264
- neq(column: string, value: any): this;
265
- /**
266
- * Filter by column greater than value
267
- * @example .gt('age', 18)
268
- */
269
- gt(column: string, value: any): this;
270
- /**
271
- * Filter by column greater than or equal to value
272
- * @example .gte('price', 100)
273
- */
274
- gte(column: string, value: any): this;
275
- /**
276
- * Filter by column less than value
277
- * @example .lt('stock', 10)
278
- */
279
- lt(column: string, value: any): this;
280
- /**
281
- * Filter by column less than or equal to value
282
- * @example .lte('discount', 50)
283
- */
284
- lte(column: string, value: any): this;
285
- /**
286
- * Filter by pattern matching (case-sensitive)
287
- * @example .like('email', '%@gmail.com')
288
- */
289
- like(column: string, pattern: string): this;
290
- /**
291
- * Filter by pattern matching (case-insensitive)
292
- * @example .ilike('name', '%john%')
293
- */
294
- ilike(column: string, pattern: string): this;
295
- /**
296
- * Filter by checking if column is a value
297
- * @example .is('deleted_at', null)
298
- */
299
- is(column: string, value: null | boolean): this;
300
- /**
301
- * Filter by checking if value is in array
302
- * @example .in('status', ['active', 'pending'])
303
- */
304
- in(column: string, values: any[]): this;
305
- /**
306
- * Order by column
307
- * @example
308
- * .order('created_at') // ascending
309
- * .order('created_at', { ascending: false }) // descending
310
- */
311
- order(column: string, options?: {
312
- ascending?: boolean;
313
- }): this;
314
- /**
315
- * Limit the number of rows returned
316
- * @example .limit(10)
317
- */
318
- limit(count: number): this;
319
- /**
320
- * Return results from an offset
321
- * @example .offset(20)
322
- */
323
- offset(count: number): this;
324
- /**
325
- * Set a range of rows to return
326
- * @example .range(0, 9) // First 10 rows
327
- */
328
- range(from: number, to: number): this;
329
- /**
330
- * Return a single object instead of array
331
- * @example .single()
332
- */
333
- single(): this;
334
- /**
335
- * Get the total count (use with select)
336
- * @example .select('*', { count: 'exact' })
337
- */
338
- count(algorithm?: 'exact' | 'planned' | 'estimated'): this;
339
- /**
340
- * Execute the query and return results
341
- */
342
- execute(): Promise<DatabaseResponse<T>>;
343
- /**
344
- * Make QueryBuilder thenable for async/await
345
- */
346
- then<TResult1 = DatabaseResponse<T>, TResult2 = never>(onfulfilled?: ((value: DatabaseResponse<T>) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
347
- }
348
- /**
349
- * Database client for InsForge SDK
350
- * Provides Supabase-style interface
192
+ * Database client using postgrest-js
193
+ * Drop-in replacement with FULL PostgREST capabilities
351
194
  */
352
195
  declare class Database {
353
- private http;
354
- constructor(http: HttpClient);
196
+ private postgrest;
197
+ constructor(httpClient: HttpClient, tokenManager: TokenManager);
355
198
  /**
356
199
  * Create a query builder for a table
357
- * @param table - The table name
200
+ *
358
201
  * @example
202
+ * // Basic query
359
203
  * const { data, error } = await client.database
360
204
  * .from('posts')
361
205
  * .select('*')
362
- * .eq('user_id', userId)
363
- * .order('created_at', { ascending: false })
364
- * .limit(10);
365
- */
366
- from<T = any>(table: string): QueryBuilder<T>;
206
+ * .eq('user_id', userId);
207
+ *
208
+ * // With count (Supabase style!)
209
+ * const { data, error, count } = await client.database
210
+ * .from('posts')
211
+ * .select('*', { count: 'exact' })
212
+ * .range(0, 9);
213
+ *
214
+ * // Just get count, no data
215
+ * const { count } = await client.database
216
+ * .from('posts')
217
+ * .select('*', { count: 'exact', head: true });
218
+ *
219
+ * // Complex queries with OR
220
+ * const { data } = await client.database
221
+ * .from('posts')
222
+ * .select('*, users!inner(*)')
223
+ * .or('status.eq.active,status.eq.pending');
224
+ *
225
+ * // All features work:
226
+ * - Nested selects
227
+ * - Foreign key expansion
228
+ * - OR/AND/NOT conditions
229
+ * - Count with head
230
+ * - Range pagination
231
+ * - Upserts
232
+ */
233
+ from(table: string): _supabase_postgrest_js.PostgrestQueryBuilder<any, any, any, string, unknown>;
367
234
  }
368
235
 
369
236
  /**
@@ -582,18 +449,6 @@ declare class InsForgeClient {
582
449
  readonly storage: Storage;
583
450
  readonly ai: AI;
584
451
  constructor(config?: InsForgeConfig);
585
- /**
586
- * Set a custom API key for authentication
587
- * This is useful for server-to-server communication
588
- *
589
- * @param apiKey - The API key (should start with 'ik_')
590
- *
591
- * @example
592
- * ```typescript
593
- * client.setApiKey('ik_your_api_key_here');
594
- * ```
595
- */
596
- setApiKey(apiKey: string): void;
597
452
  /**
598
453
  * Get the underlying HTTP client for custom requests
599
454
  *
@@ -614,4 +469,4 @@ declare class InsForgeClient {
614
469
 
615
470
  declare function createClient(config: InsForgeConfig): InsForgeClient;
616
471
 
617
- export { AI, type ApiError, Auth, type AuthSession, type InsForgeConfig as ClientOptions, Database, type DatabaseResponse, HttpClient, InsForgeClient, type InsForgeConfig, InsForgeError, QueryBuilder, Storage, StorageBucket, type StorageResponse, TokenManager, type TokenStorage, createClient, InsForgeClient as default };
472
+ export { AI, type ApiError, Auth, type AuthSession, type InsForgeConfig as ClientOptions, Database, HttpClient, InsForgeClient, type InsForgeConfig, InsForgeError, Storage, StorageBucket, type StorageResponse, TokenManager, type TokenStorage, createClient, InsForgeClient as default };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { UserSchema, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, StorageFileSchema, ListObjectsResponseSchema } from '@insforge/shared-schemas';
2
2
  export { AuthErrorResponse, CreateSessionRequest, CreateUserRequest, UserSchema } from '@insforge/shared-schemas';
3
+ import * as _supabase_postgrest_js from '@supabase/postgrest-js';
3
4
 
4
5
  /**
5
6
  * InsForge SDK Types - only SDK-specific types here
@@ -151,7 +152,7 @@ declare class Auth {
151
152
  user: any;
152
153
  profile: any;
153
154
  } | null;
154
- error: InsForgeError | null;
155
+ error: any | null;
155
156
  }>;
156
157
  /**
157
158
  * Get any user's profile by ID
@@ -159,7 +160,7 @@ declare class Auth {
159
160
  */
160
161
  getProfile(userId: string): Promise<{
161
162
  data: any | null;
162
- error: InsForgeError | null;
163
+ error: any | null;
163
164
  }>;
164
165
  /**
165
166
  * Get the current session (only session data, no API call)
@@ -183,187 +184,53 @@ declare class Auth {
183
184
  [key: string]: any;
184
185
  }): Promise<{
185
186
  data: any | null;
186
- error: InsForgeError | null;
187
+ error: any | null;
187
188
  }>;
188
189
  }
189
190
 
190
191
  /**
191
- * Database module for InsForge SDK
192
- * Supabase-style query builder for PostgREST operations
193
- */
194
-
195
- interface DatabaseResponse<T> {
196
- data: T | null;
197
- error: InsForgeError | null;
198
- count?: number;
199
- }
200
- /**
201
- * Query builder for database operations
202
- * Uses method chaining like Supabase
203
- */
204
- declare class QueryBuilder<T = any> {
205
- private table;
206
- private http;
207
- private method;
208
- private headers;
209
- private queryParams;
210
- private body?;
211
- constructor(table: string, http: HttpClient);
212
- /**
213
- * Perform a SELECT query
214
- * For mutations (insert/update/delete), this enables returning data
215
- * @param columns - Columns to select (default: '*')
216
- * @example
217
- * .select('*')
218
- * .select('id, title, content')
219
- * .select('*, users!inner(*)') // Join with users table
220
- * .select('*, profile:profiles(*)') // Join with alias
221
- * .insert({ title: 'New' }).select() // Returns inserted data
222
- */
223
- select(columns?: string): this;
224
- /**
225
- * Perform an INSERT
226
- * @param values - Single object or array of objects
227
- * @param options - { upsert: true } for upsert behavior
228
- * @example
229
- * .insert({ title: 'Hello', content: 'World' }).select()
230
- * .insert([{ title: 'Post 1' }, { title: 'Post 2' }]).select()
231
- */
232
- insert(values: Partial<T> | Partial<T>[], options?: {
233
- upsert?: boolean;
234
- }): this;
235
- /**
236
- * Perform an UPDATE
237
- * @param values - Object with fields to update
238
- * @example
239
- * .update({ title: 'Updated Title' }).select()
240
- */
241
- update(values: Partial<T>): this;
242
- /**
243
- * Perform a DELETE
244
- * @example
245
- * .delete().select()
246
- */
247
- delete(): this;
248
- /**
249
- * Perform an UPSERT
250
- * @param values - Single object or array of objects
251
- * @example
252
- * .upsert({ id: 1, title: 'Hello' })
253
- */
254
- upsert(values: Partial<T> | Partial<T>[]): this;
255
- /**
256
- * Filter by column equal to value
257
- * @example .eq('id', 123)
258
- */
259
- eq(column: string, value: any): this;
260
- /**
261
- * Filter by column not equal to value
262
- * @example .neq('status', 'draft')
263
- */
264
- neq(column: string, value: any): this;
265
- /**
266
- * Filter by column greater than value
267
- * @example .gt('age', 18)
268
- */
269
- gt(column: string, value: any): this;
270
- /**
271
- * Filter by column greater than or equal to value
272
- * @example .gte('price', 100)
273
- */
274
- gte(column: string, value: any): this;
275
- /**
276
- * Filter by column less than value
277
- * @example .lt('stock', 10)
278
- */
279
- lt(column: string, value: any): this;
280
- /**
281
- * Filter by column less than or equal to value
282
- * @example .lte('discount', 50)
283
- */
284
- lte(column: string, value: any): this;
285
- /**
286
- * Filter by pattern matching (case-sensitive)
287
- * @example .like('email', '%@gmail.com')
288
- */
289
- like(column: string, pattern: string): this;
290
- /**
291
- * Filter by pattern matching (case-insensitive)
292
- * @example .ilike('name', '%john%')
293
- */
294
- ilike(column: string, pattern: string): this;
295
- /**
296
- * Filter by checking if column is a value
297
- * @example .is('deleted_at', null)
298
- */
299
- is(column: string, value: null | boolean): this;
300
- /**
301
- * Filter by checking if value is in array
302
- * @example .in('status', ['active', 'pending'])
303
- */
304
- in(column: string, values: any[]): this;
305
- /**
306
- * Order by column
307
- * @example
308
- * .order('created_at') // ascending
309
- * .order('created_at', { ascending: false }) // descending
310
- */
311
- order(column: string, options?: {
312
- ascending?: boolean;
313
- }): this;
314
- /**
315
- * Limit the number of rows returned
316
- * @example .limit(10)
317
- */
318
- limit(count: number): this;
319
- /**
320
- * Return results from an offset
321
- * @example .offset(20)
322
- */
323
- offset(count: number): this;
324
- /**
325
- * Set a range of rows to return
326
- * @example .range(0, 9) // First 10 rows
327
- */
328
- range(from: number, to: number): this;
329
- /**
330
- * Return a single object instead of array
331
- * @example .single()
332
- */
333
- single(): this;
334
- /**
335
- * Get the total count (use with select)
336
- * @example .select('*', { count: 'exact' })
337
- */
338
- count(algorithm?: 'exact' | 'planned' | 'estimated'): this;
339
- /**
340
- * Execute the query and return results
341
- */
342
- execute(): Promise<DatabaseResponse<T>>;
343
- /**
344
- * Make QueryBuilder thenable for async/await
345
- */
346
- then<TResult1 = DatabaseResponse<T>, TResult2 = never>(onfulfilled?: ((value: DatabaseResponse<T>) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
347
- }
348
- /**
349
- * Database client for InsForge SDK
350
- * Provides Supabase-style interface
192
+ * Database client using postgrest-js
193
+ * Drop-in replacement with FULL PostgREST capabilities
351
194
  */
352
195
  declare class Database {
353
- private http;
354
- constructor(http: HttpClient);
196
+ private postgrest;
197
+ constructor(httpClient: HttpClient, tokenManager: TokenManager);
355
198
  /**
356
199
  * Create a query builder for a table
357
- * @param table - The table name
200
+ *
358
201
  * @example
202
+ * // Basic query
359
203
  * const { data, error } = await client.database
360
204
  * .from('posts')
361
205
  * .select('*')
362
- * .eq('user_id', userId)
363
- * .order('created_at', { ascending: false })
364
- * .limit(10);
365
- */
366
- from<T = any>(table: string): QueryBuilder<T>;
206
+ * .eq('user_id', userId);
207
+ *
208
+ * // With count (Supabase style!)
209
+ * const { data, error, count } = await client.database
210
+ * .from('posts')
211
+ * .select('*', { count: 'exact' })
212
+ * .range(0, 9);
213
+ *
214
+ * // Just get count, no data
215
+ * const { count } = await client.database
216
+ * .from('posts')
217
+ * .select('*', { count: 'exact', head: true });
218
+ *
219
+ * // Complex queries with OR
220
+ * const { data } = await client.database
221
+ * .from('posts')
222
+ * .select('*, users!inner(*)')
223
+ * .or('status.eq.active,status.eq.pending');
224
+ *
225
+ * // All features work:
226
+ * - Nested selects
227
+ * - Foreign key expansion
228
+ * - OR/AND/NOT conditions
229
+ * - Count with head
230
+ * - Range pagination
231
+ * - Upserts
232
+ */
233
+ from(table: string): _supabase_postgrest_js.PostgrestQueryBuilder<any, any, any, string, unknown>;
367
234
  }
368
235
 
369
236
  /**
@@ -582,18 +449,6 @@ declare class InsForgeClient {
582
449
  readonly storage: Storage;
583
450
  readonly ai: AI;
584
451
  constructor(config?: InsForgeConfig);
585
- /**
586
- * Set a custom API key for authentication
587
- * This is useful for server-to-server communication
588
- *
589
- * @param apiKey - The API key (should start with 'ik_')
590
- *
591
- * @example
592
- * ```typescript
593
- * client.setApiKey('ik_your_api_key_here');
594
- * ```
595
- */
596
- setApiKey(apiKey: string): void;
597
452
  /**
598
453
  * Get the underlying HTTP client for custom requests
599
454
  *
@@ -614,4 +469,4 @@ declare class InsForgeClient {
614
469
 
615
470
  declare function createClient(config: InsForgeConfig): InsForgeClient;
616
471
 
617
- export { AI, type ApiError, Auth, type AuthSession, type InsForgeConfig as ClientOptions, Database, type DatabaseResponse, HttpClient, InsForgeClient, type InsForgeConfig, InsForgeError, QueryBuilder, Storage, StorageBucket, type StorageResponse, TokenManager, type TokenStorage, createClient, InsForgeClient as default };
472
+ export { AI, type ApiError, Auth, type AuthSession, type InsForgeConfig as ClientOptions, Database, HttpClient, InsForgeClient, type InsForgeConfig, InsForgeError, Storage, StorageBucket, type StorageResponse, TokenManager, type TokenStorage, createClient, InsForgeClient as default };