@insforge/sdk 0.0.4 → 0.0.6
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 +191 -12
- package/dist/index.d.ts +191 -12
- package/dist/index.js +327 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +325 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -153,6 +153,182 @@ declare class Auth {
|
|
|
153
153
|
}>;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Database module for InsForge SDK
|
|
158
|
+
* Supabase-style query builder for PostgREST operations
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
interface DatabaseResponse<T> {
|
|
162
|
+
data: T | null;
|
|
163
|
+
error: InsForgeError | null;
|
|
164
|
+
count?: number;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Query builder for database operations
|
|
168
|
+
* Uses method chaining like Supabase
|
|
169
|
+
*/
|
|
170
|
+
declare class QueryBuilder<T = any> {
|
|
171
|
+
private table;
|
|
172
|
+
private http;
|
|
173
|
+
private method;
|
|
174
|
+
private headers;
|
|
175
|
+
private queryParams;
|
|
176
|
+
private body?;
|
|
177
|
+
constructor(table: string, http: HttpClient);
|
|
178
|
+
/**
|
|
179
|
+
* Perform a SELECT query
|
|
180
|
+
* @param columns - Columns to select (default: '*')
|
|
181
|
+
* @example
|
|
182
|
+
* .select('*')
|
|
183
|
+
* .select('id, title, content')
|
|
184
|
+
* .select('*, user:user_id(name, email)') // Foreign key expansion
|
|
185
|
+
*/
|
|
186
|
+
select(columns?: string): this;
|
|
187
|
+
/**
|
|
188
|
+
* Perform an INSERT
|
|
189
|
+
* @param values - Single object or array of objects
|
|
190
|
+
* @param options - { upsert: true } for upsert behavior
|
|
191
|
+
* @example
|
|
192
|
+
* .insert({ title: 'Hello', content: 'World' })
|
|
193
|
+
* .insert([{ title: 'Post 1' }, { title: 'Post 2' }])
|
|
194
|
+
*/
|
|
195
|
+
insert(values: Partial<T> | Partial<T>[], options?: {
|
|
196
|
+
upsert?: boolean;
|
|
197
|
+
}): this;
|
|
198
|
+
/**
|
|
199
|
+
* Perform an UPDATE
|
|
200
|
+
* @param values - Object with fields to update
|
|
201
|
+
* @example
|
|
202
|
+
* .update({ title: 'Updated Title' })
|
|
203
|
+
*/
|
|
204
|
+
update(values: Partial<T>): this;
|
|
205
|
+
/**
|
|
206
|
+
* Perform a DELETE
|
|
207
|
+
* @example
|
|
208
|
+
* .delete()
|
|
209
|
+
*/
|
|
210
|
+
delete(): this;
|
|
211
|
+
/**
|
|
212
|
+
* Perform an UPSERT
|
|
213
|
+
* @param values - Single object or array of objects
|
|
214
|
+
* @example
|
|
215
|
+
* .upsert({ id: 1, title: 'Hello' })
|
|
216
|
+
*/
|
|
217
|
+
upsert(values: Partial<T> | Partial<T>[]): this;
|
|
218
|
+
/**
|
|
219
|
+
* Filter by column equal to value
|
|
220
|
+
* @example .eq('id', 123)
|
|
221
|
+
*/
|
|
222
|
+
eq(column: string, value: any): this;
|
|
223
|
+
/**
|
|
224
|
+
* Filter by column not equal to value
|
|
225
|
+
* @example .neq('status', 'draft')
|
|
226
|
+
*/
|
|
227
|
+
neq(column: string, value: any): this;
|
|
228
|
+
/**
|
|
229
|
+
* Filter by column greater than value
|
|
230
|
+
* @example .gt('age', 18)
|
|
231
|
+
*/
|
|
232
|
+
gt(column: string, value: any): this;
|
|
233
|
+
/**
|
|
234
|
+
* Filter by column greater than or equal to value
|
|
235
|
+
* @example .gte('price', 100)
|
|
236
|
+
*/
|
|
237
|
+
gte(column: string, value: any): this;
|
|
238
|
+
/**
|
|
239
|
+
* Filter by column less than value
|
|
240
|
+
* @example .lt('stock', 10)
|
|
241
|
+
*/
|
|
242
|
+
lt(column: string, value: any): this;
|
|
243
|
+
/**
|
|
244
|
+
* Filter by column less than or equal to value
|
|
245
|
+
* @example .lte('discount', 50)
|
|
246
|
+
*/
|
|
247
|
+
lte(column: string, value: any): this;
|
|
248
|
+
/**
|
|
249
|
+
* Filter by pattern matching (case-sensitive)
|
|
250
|
+
* @example .like('email', '%@gmail.com')
|
|
251
|
+
*/
|
|
252
|
+
like(column: string, pattern: string): this;
|
|
253
|
+
/**
|
|
254
|
+
* Filter by pattern matching (case-insensitive)
|
|
255
|
+
* @example .ilike('name', '%john%')
|
|
256
|
+
*/
|
|
257
|
+
ilike(column: string, pattern: string): this;
|
|
258
|
+
/**
|
|
259
|
+
* Filter by checking if column is a value
|
|
260
|
+
* @example .is('deleted_at', null)
|
|
261
|
+
*/
|
|
262
|
+
is(column: string, value: null | boolean): this;
|
|
263
|
+
/**
|
|
264
|
+
* Filter by checking if value is in array
|
|
265
|
+
* @example .in('status', ['active', 'pending'])
|
|
266
|
+
*/
|
|
267
|
+
in(column: string, values: any[]): this;
|
|
268
|
+
/**
|
|
269
|
+
* Order by column
|
|
270
|
+
* @example
|
|
271
|
+
* .order('created_at') // ascending
|
|
272
|
+
* .order('created_at', { ascending: false }) // descending
|
|
273
|
+
*/
|
|
274
|
+
order(column: string, options?: {
|
|
275
|
+
ascending?: boolean;
|
|
276
|
+
}): this;
|
|
277
|
+
/**
|
|
278
|
+
* Limit the number of rows returned
|
|
279
|
+
* @example .limit(10)
|
|
280
|
+
*/
|
|
281
|
+
limit(count: number): this;
|
|
282
|
+
/**
|
|
283
|
+
* Return results from an offset
|
|
284
|
+
* @example .offset(20)
|
|
285
|
+
*/
|
|
286
|
+
offset(count: number): this;
|
|
287
|
+
/**
|
|
288
|
+
* Set a range of rows to return
|
|
289
|
+
* @example .range(0, 9) // First 10 rows
|
|
290
|
+
*/
|
|
291
|
+
range(from: number, to: number): this;
|
|
292
|
+
/**
|
|
293
|
+
* Return a single object instead of array
|
|
294
|
+
* @example .single()
|
|
295
|
+
*/
|
|
296
|
+
single(): this;
|
|
297
|
+
/**
|
|
298
|
+
* Get the total count (use with select)
|
|
299
|
+
* @example .select('*', { count: 'exact' })
|
|
300
|
+
*/
|
|
301
|
+
count(algorithm?: 'exact' | 'planned' | 'estimated'): this;
|
|
302
|
+
/**
|
|
303
|
+
* Execute the query and return results
|
|
304
|
+
*/
|
|
305
|
+
execute(): Promise<DatabaseResponse<T>>;
|
|
306
|
+
/**
|
|
307
|
+
* Make QueryBuilder thenable for async/await
|
|
308
|
+
*/
|
|
309
|
+
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>;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Database client for InsForge SDK
|
|
313
|
+
* Provides Supabase-style interface
|
|
314
|
+
*/
|
|
315
|
+
declare class Database {
|
|
316
|
+
private http;
|
|
317
|
+
constructor(http: HttpClient);
|
|
318
|
+
/**
|
|
319
|
+
* Create a query builder for a table
|
|
320
|
+
* @param table - The table name
|
|
321
|
+
* @example
|
|
322
|
+
* const { data, error } = await client.database
|
|
323
|
+
* .from('posts')
|
|
324
|
+
* .select('*')
|
|
325
|
+
* .eq('user_id', userId)
|
|
326
|
+
* .order('created_at', { ascending: false })
|
|
327
|
+
* .limit(10);
|
|
328
|
+
*/
|
|
329
|
+
from<T = any>(table: string): QueryBuilder<T>;
|
|
330
|
+
}
|
|
331
|
+
|
|
156
332
|
/**
|
|
157
333
|
* Main InsForge SDK Client
|
|
158
334
|
*
|
|
@@ -164,30 +340,33 @@ declare class Auth {
|
|
|
164
340
|
* baseUrl: 'http://localhost:7130'
|
|
165
341
|
* });
|
|
166
342
|
*
|
|
167
|
-
* //
|
|
343
|
+
* // Authentication
|
|
168
344
|
* const session = await client.auth.register({
|
|
169
345
|
* email: 'user@example.com',
|
|
170
346
|
* password: 'password123',
|
|
171
347
|
* name: 'John Doe'
|
|
172
348
|
* });
|
|
173
349
|
*
|
|
174
|
-
* //
|
|
175
|
-
* const
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
350
|
+
* // Database operations
|
|
351
|
+
* const { data, error } = await client.database
|
|
352
|
+
* .from('posts')
|
|
353
|
+
* .select('*')
|
|
354
|
+
* .eq('user_id', session.user.id)
|
|
355
|
+
* .order('created_at', { ascending: false })
|
|
356
|
+
* .limit(10);
|
|
179
357
|
*
|
|
180
|
-
* //
|
|
181
|
-
* const
|
|
358
|
+
* // Insert data
|
|
359
|
+
* const { data: newPost } = await client.database
|
|
360
|
+
* .from('posts')
|
|
361
|
+
* .insert({ title: 'Hello', content: 'World' })
|
|
362
|
+
* .single();
|
|
182
363
|
* ```
|
|
183
364
|
*/
|
|
184
365
|
declare class InsForgeClient {
|
|
185
366
|
private http;
|
|
186
367
|
private tokenManager;
|
|
187
|
-
/**
|
|
188
|
-
* Authentication module
|
|
189
|
-
*/
|
|
190
368
|
readonly auth: Auth;
|
|
369
|
+
readonly database: Database;
|
|
191
370
|
constructor(config?: InsForgeConfig);
|
|
192
371
|
/**
|
|
193
372
|
* Set a custom API key for authentication
|
|
@@ -221,4 +400,4 @@ declare class InsForgeClient {
|
|
|
221
400
|
|
|
222
401
|
declare function createClient(config: InsForgeConfig): InsForgeClient;
|
|
223
402
|
|
|
224
|
-
export { type ApiError, Auth, type AuthSession, type InsForgeConfig as ClientOptions, HttpClient, InsForgeClient, type InsForgeConfig, InsForgeError, TokenManager, type TokenStorage, createClient, InsForgeClient as default };
|
|
403
|
+
export { type ApiError, Auth, type AuthSession, type InsForgeConfig as ClientOptions, Database, type DatabaseResponse, HttpClient, InsForgeClient, type InsForgeConfig, InsForgeError, QueryBuilder, TokenManager, type TokenStorage, createClient, InsForgeClient as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -153,6 +153,182 @@ declare class Auth {
|
|
|
153
153
|
}>;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Database module for InsForge SDK
|
|
158
|
+
* Supabase-style query builder for PostgREST operations
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
interface DatabaseResponse<T> {
|
|
162
|
+
data: T | null;
|
|
163
|
+
error: InsForgeError | null;
|
|
164
|
+
count?: number;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Query builder for database operations
|
|
168
|
+
* Uses method chaining like Supabase
|
|
169
|
+
*/
|
|
170
|
+
declare class QueryBuilder<T = any> {
|
|
171
|
+
private table;
|
|
172
|
+
private http;
|
|
173
|
+
private method;
|
|
174
|
+
private headers;
|
|
175
|
+
private queryParams;
|
|
176
|
+
private body?;
|
|
177
|
+
constructor(table: string, http: HttpClient);
|
|
178
|
+
/**
|
|
179
|
+
* Perform a SELECT query
|
|
180
|
+
* @param columns - Columns to select (default: '*')
|
|
181
|
+
* @example
|
|
182
|
+
* .select('*')
|
|
183
|
+
* .select('id, title, content')
|
|
184
|
+
* .select('*, user:user_id(name, email)') // Foreign key expansion
|
|
185
|
+
*/
|
|
186
|
+
select(columns?: string): this;
|
|
187
|
+
/**
|
|
188
|
+
* Perform an INSERT
|
|
189
|
+
* @param values - Single object or array of objects
|
|
190
|
+
* @param options - { upsert: true } for upsert behavior
|
|
191
|
+
* @example
|
|
192
|
+
* .insert({ title: 'Hello', content: 'World' })
|
|
193
|
+
* .insert([{ title: 'Post 1' }, { title: 'Post 2' }])
|
|
194
|
+
*/
|
|
195
|
+
insert(values: Partial<T> | Partial<T>[], options?: {
|
|
196
|
+
upsert?: boolean;
|
|
197
|
+
}): this;
|
|
198
|
+
/**
|
|
199
|
+
* Perform an UPDATE
|
|
200
|
+
* @param values - Object with fields to update
|
|
201
|
+
* @example
|
|
202
|
+
* .update({ title: 'Updated Title' })
|
|
203
|
+
*/
|
|
204
|
+
update(values: Partial<T>): this;
|
|
205
|
+
/**
|
|
206
|
+
* Perform a DELETE
|
|
207
|
+
* @example
|
|
208
|
+
* .delete()
|
|
209
|
+
*/
|
|
210
|
+
delete(): this;
|
|
211
|
+
/**
|
|
212
|
+
* Perform an UPSERT
|
|
213
|
+
* @param values - Single object or array of objects
|
|
214
|
+
* @example
|
|
215
|
+
* .upsert({ id: 1, title: 'Hello' })
|
|
216
|
+
*/
|
|
217
|
+
upsert(values: Partial<T> | Partial<T>[]): this;
|
|
218
|
+
/**
|
|
219
|
+
* Filter by column equal to value
|
|
220
|
+
* @example .eq('id', 123)
|
|
221
|
+
*/
|
|
222
|
+
eq(column: string, value: any): this;
|
|
223
|
+
/**
|
|
224
|
+
* Filter by column not equal to value
|
|
225
|
+
* @example .neq('status', 'draft')
|
|
226
|
+
*/
|
|
227
|
+
neq(column: string, value: any): this;
|
|
228
|
+
/**
|
|
229
|
+
* Filter by column greater than value
|
|
230
|
+
* @example .gt('age', 18)
|
|
231
|
+
*/
|
|
232
|
+
gt(column: string, value: any): this;
|
|
233
|
+
/**
|
|
234
|
+
* Filter by column greater than or equal to value
|
|
235
|
+
* @example .gte('price', 100)
|
|
236
|
+
*/
|
|
237
|
+
gte(column: string, value: any): this;
|
|
238
|
+
/**
|
|
239
|
+
* Filter by column less than value
|
|
240
|
+
* @example .lt('stock', 10)
|
|
241
|
+
*/
|
|
242
|
+
lt(column: string, value: any): this;
|
|
243
|
+
/**
|
|
244
|
+
* Filter by column less than or equal to value
|
|
245
|
+
* @example .lte('discount', 50)
|
|
246
|
+
*/
|
|
247
|
+
lte(column: string, value: any): this;
|
|
248
|
+
/**
|
|
249
|
+
* Filter by pattern matching (case-sensitive)
|
|
250
|
+
* @example .like('email', '%@gmail.com')
|
|
251
|
+
*/
|
|
252
|
+
like(column: string, pattern: string): this;
|
|
253
|
+
/**
|
|
254
|
+
* Filter by pattern matching (case-insensitive)
|
|
255
|
+
* @example .ilike('name', '%john%')
|
|
256
|
+
*/
|
|
257
|
+
ilike(column: string, pattern: string): this;
|
|
258
|
+
/**
|
|
259
|
+
* Filter by checking if column is a value
|
|
260
|
+
* @example .is('deleted_at', null)
|
|
261
|
+
*/
|
|
262
|
+
is(column: string, value: null | boolean): this;
|
|
263
|
+
/**
|
|
264
|
+
* Filter by checking if value is in array
|
|
265
|
+
* @example .in('status', ['active', 'pending'])
|
|
266
|
+
*/
|
|
267
|
+
in(column: string, values: any[]): this;
|
|
268
|
+
/**
|
|
269
|
+
* Order by column
|
|
270
|
+
* @example
|
|
271
|
+
* .order('created_at') // ascending
|
|
272
|
+
* .order('created_at', { ascending: false }) // descending
|
|
273
|
+
*/
|
|
274
|
+
order(column: string, options?: {
|
|
275
|
+
ascending?: boolean;
|
|
276
|
+
}): this;
|
|
277
|
+
/**
|
|
278
|
+
* Limit the number of rows returned
|
|
279
|
+
* @example .limit(10)
|
|
280
|
+
*/
|
|
281
|
+
limit(count: number): this;
|
|
282
|
+
/**
|
|
283
|
+
* Return results from an offset
|
|
284
|
+
* @example .offset(20)
|
|
285
|
+
*/
|
|
286
|
+
offset(count: number): this;
|
|
287
|
+
/**
|
|
288
|
+
* Set a range of rows to return
|
|
289
|
+
* @example .range(0, 9) // First 10 rows
|
|
290
|
+
*/
|
|
291
|
+
range(from: number, to: number): this;
|
|
292
|
+
/**
|
|
293
|
+
* Return a single object instead of array
|
|
294
|
+
* @example .single()
|
|
295
|
+
*/
|
|
296
|
+
single(): this;
|
|
297
|
+
/**
|
|
298
|
+
* Get the total count (use with select)
|
|
299
|
+
* @example .select('*', { count: 'exact' })
|
|
300
|
+
*/
|
|
301
|
+
count(algorithm?: 'exact' | 'planned' | 'estimated'): this;
|
|
302
|
+
/**
|
|
303
|
+
* Execute the query and return results
|
|
304
|
+
*/
|
|
305
|
+
execute(): Promise<DatabaseResponse<T>>;
|
|
306
|
+
/**
|
|
307
|
+
* Make QueryBuilder thenable for async/await
|
|
308
|
+
*/
|
|
309
|
+
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>;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Database client for InsForge SDK
|
|
313
|
+
* Provides Supabase-style interface
|
|
314
|
+
*/
|
|
315
|
+
declare class Database {
|
|
316
|
+
private http;
|
|
317
|
+
constructor(http: HttpClient);
|
|
318
|
+
/**
|
|
319
|
+
* Create a query builder for a table
|
|
320
|
+
* @param table - The table name
|
|
321
|
+
* @example
|
|
322
|
+
* const { data, error } = await client.database
|
|
323
|
+
* .from('posts')
|
|
324
|
+
* .select('*')
|
|
325
|
+
* .eq('user_id', userId)
|
|
326
|
+
* .order('created_at', { ascending: false })
|
|
327
|
+
* .limit(10);
|
|
328
|
+
*/
|
|
329
|
+
from<T = any>(table: string): QueryBuilder<T>;
|
|
330
|
+
}
|
|
331
|
+
|
|
156
332
|
/**
|
|
157
333
|
* Main InsForge SDK Client
|
|
158
334
|
*
|
|
@@ -164,30 +340,33 @@ declare class Auth {
|
|
|
164
340
|
* baseUrl: 'http://localhost:7130'
|
|
165
341
|
* });
|
|
166
342
|
*
|
|
167
|
-
* //
|
|
343
|
+
* // Authentication
|
|
168
344
|
* const session = await client.auth.register({
|
|
169
345
|
* email: 'user@example.com',
|
|
170
346
|
* password: 'password123',
|
|
171
347
|
* name: 'John Doe'
|
|
172
348
|
* });
|
|
173
349
|
*
|
|
174
|
-
* //
|
|
175
|
-
* const
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
350
|
+
* // Database operations
|
|
351
|
+
* const { data, error } = await client.database
|
|
352
|
+
* .from('posts')
|
|
353
|
+
* .select('*')
|
|
354
|
+
* .eq('user_id', session.user.id)
|
|
355
|
+
* .order('created_at', { ascending: false })
|
|
356
|
+
* .limit(10);
|
|
179
357
|
*
|
|
180
|
-
* //
|
|
181
|
-
* const
|
|
358
|
+
* // Insert data
|
|
359
|
+
* const { data: newPost } = await client.database
|
|
360
|
+
* .from('posts')
|
|
361
|
+
* .insert({ title: 'Hello', content: 'World' })
|
|
362
|
+
* .single();
|
|
182
363
|
* ```
|
|
183
364
|
*/
|
|
184
365
|
declare class InsForgeClient {
|
|
185
366
|
private http;
|
|
186
367
|
private tokenManager;
|
|
187
|
-
/**
|
|
188
|
-
* Authentication module
|
|
189
|
-
*/
|
|
190
368
|
readonly auth: Auth;
|
|
369
|
+
readonly database: Database;
|
|
191
370
|
constructor(config?: InsForgeConfig);
|
|
192
371
|
/**
|
|
193
372
|
* Set a custom API key for authentication
|
|
@@ -221,4 +400,4 @@ declare class InsForgeClient {
|
|
|
221
400
|
|
|
222
401
|
declare function createClient(config: InsForgeConfig): InsForgeClient;
|
|
223
402
|
|
|
224
|
-
export { type ApiError, Auth, type AuthSession, type InsForgeConfig as ClientOptions, HttpClient, InsForgeClient, type InsForgeConfig, InsForgeError, TokenManager, type TokenStorage, createClient, InsForgeClient as default };
|
|
403
|
+
export { type ApiError, Auth, type AuthSession, type InsForgeConfig as ClientOptions, Database, type DatabaseResponse, HttpClient, InsForgeClient, type InsForgeConfig, InsForgeError, QueryBuilder, TokenManager, type TokenStorage, createClient, InsForgeClient as default };
|