@vaiftechnologies/vaif-client 0.1.0
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 +2508 -0
- package/dist/index.d.ts +2508 -0
- package/dist/index.js +2428 -0
- package/dist/index.mjs +2391 -0
- package/package.json +64 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,2508 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for creating a VAIF client
|
|
3
|
+
*/
|
|
4
|
+
interface VaifClientOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Your VAIF Studio project ID
|
|
7
|
+
*/
|
|
8
|
+
projectId: string;
|
|
9
|
+
/**
|
|
10
|
+
* API key for authentication (use anon key for client-side)
|
|
11
|
+
*/
|
|
12
|
+
apiKey: string;
|
|
13
|
+
/**
|
|
14
|
+
* Custom API endpoint (defaults to https://api.vaif.studio)
|
|
15
|
+
*/
|
|
16
|
+
apiUrl?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Custom realtime endpoint (defaults to wss://realtime.vaif.studio)
|
|
19
|
+
*/
|
|
20
|
+
realtimeUrl?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Request timeout in milliseconds (default: 30000)
|
|
23
|
+
*/
|
|
24
|
+
timeout?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Custom headers to include with every request
|
|
27
|
+
*/
|
|
28
|
+
headers?: Record<string, string>;
|
|
29
|
+
/**
|
|
30
|
+
* Enable debug logging
|
|
31
|
+
*/
|
|
32
|
+
debug?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Auto-refresh authentication tokens
|
|
35
|
+
*/
|
|
36
|
+
autoRefreshToken?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Persist session to storage (localStorage in browser, memory in Node)
|
|
39
|
+
*/
|
|
40
|
+
persistSession?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Custom storage implementation for session persistence
|
|
43
|
+
*/
|
|
44
|
+
storage?: StorageAdapter;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Internal configuration after processing options
|
|
48
|
+
*/
|
|
49
|
+
interface VaifConfig {
|
|
50
|
+
projectId: string;
|
|
51
|
+
apiKey: string;
|
|
52
|
+
apiUrl: string;
|
|
53
|
+
realtimeUrl: string;
|
|
54
|
+
timeout: number;
|
|
55
|
+
headers: Record<string, string>;
|
|
56
|
+
debug: boolean;
|
|
57
|
+
autoRefreshToken: boolean;
|
|
58
|
+
persistSession: boolean;
|
|
59
|
+
storage: StorageAdapter;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Storage adapter interface for session persistence
|
|
63
|
+
*/
|
|
64
|
+
interface StorageAdapter {
|
|
65
|
+
getItem(key: string): string | null | Promise<string | null>;
|
|
66
|
+
setItem(key: string, value: string): void | Promise<void>;
|
|
67
|
+
removeItem(key: string): void | Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Options for individual API requests
|
|
71
|
+
*/
|
|
72
|
+
interface RequestOptions {
|
|
73
|
+
/**
|
|
74
|
+
* HTTP method
|
|
75
|
+
*/
|
|
76
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
77
|
+
/**
|
|
78
|
+
* Request headers
|
|
79
|
+
*/
|
|
80
|
+
headers?: Record<string, string>;
|
|
81
|
+
/**
|
|
82
|
+
* Request body
|
|
83
|
+
*/
|
|
84
|
+
body?: unknown;
|
|
85
|
+
/**
|
|
86
|
+
* Query parameters
|
|
87
|
+
*/
|
|
88
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
89
|
+
/**
|
|
90
|
+
* Request timeout override
|
|
91
|
+
*/
|
|
92
|
+
timeout?: number;
|
|
93
|
+
/**
|
|
94
|
+
* AbortSignal for request cancellation
|
|
95
|
+
*/
|
|
96
|
+
signal?: AbortSignal;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Standard API response wrapper
|
|
100
|
+
*/
|
|
101
|
+
interface ApiResponse<T = unknown> {
|
|
102
|
+
/**
|
|
103
|
+
* Response data
|
|
104
|
+
*/
|
|
105
|
+
data: T | null;
|
|
106
|
+
/**
|
|
107
|
+
* Error information if request failed
|
|
108
|
+
*/
|
|
109
|
+
error: ApiError | null;
|
|
110
|
+
/**
|
|
111
|
+
* HTTP status code
|
|
112
|
+
*/
|
|
113
|
+
status: number;
|
|
114
|
+
/**
|
|
115
|
+
* Response headers
|
|
116
|
+
*/
|
|
117
|
+
headers: Record<string, string>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* API error structure
|
|
121
|
+
*/
|
|
122
|
+
interface ApiError {
|
|
123
|
+
/**
|
|
124
|
+
* Error message
|
|
125
|
+
*/
|
|
126
|
+
message: string;
|
|
127
|
+
/**
|
|
128
|
+
* Error code for programmatic handling
|
|
129
|
+
*/
|
|
130
|
+
code?: string;
|
|
131
|
+
/**
|
|
132
|
+
* HTTP status code
|
|
133
|
+
*/
|
|
134
|
+
status?: number;
|
|
135
|
+
/**
|
|
136
|
+
* Additional error details
|
|
137
|
+
*/
|
|
138
|
+
details?: Record<string, unknown>;
|
|
139
|
+
/**
|
|
140
|
+
* Request ID for support
|
|
141
|
+
*/
|
|
142
|
+
requestId?: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Database query types for VAIF Studio
|
|
147
|
+
*/
|
|
148
|
+
/**
|
|
149
|
+
* Filter operators for query conditions
|
|
150
|
+
*/
|
|
151
|
+
type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'contains' | 'containedBy' | 'overlaps' | 'match' | 'not';
|
|
152
|
+
/**
|
|
153
|
+
* Order direction for sorting
|
|
154
|
+
*/
|
|
155
|
+
type OrderDirection = 'asc' | 'desc';
|
|
156
|
+
/**
|
|
157
|
+
* Base query builder interface
|
|
158
|
+
*/
|
|
159
|
+
interface QueryBuilder$1<T = Record<string, unknown>> {
|
|
160
|
+
/**
|
|
161
|
+
* Filter by equality
|
|
162
|
+
*/
|
|
163
|
+
eq(column: keyof T | string, value: unknown): this;
|
|
164
|
+
/**
|
|
165
|
+
* Filter by inequality
|
|
166
|
+
*/
|
|
167
|
+
neq(column: keyof T | string, value: unknown): this;
|
|
168
|
+
/**
|
|
169
|
+
* Filter by greater than
|
|
170
|
+
*/
|
|
171
|
+
gt(column: keyof T | string, value: unknown): this;
|
|
172
|
+
/**
|
|
173
|
+
* Filter by greater than or equal
|
|
174
|
+
*/
|
|
175
|
+
gte(column: keyof T | string, value: unknown): this;
|
|
176
|
+
/**
|
|
177
|
+
* Filter by less than
|
|
178
|
+
*/
|
|
179
|
+
lt(column: keyof T | string, value: unknown): this;
|
|
180
|
+
/**
|
|
181
|
+
* Filter by less than or equal
|
|
182
|
+
*/
|
|
183
|
+
lte(column: keyof T | string, value: unknown): this;
|
|
184
|
+
/**
|
|
185
|
+
* Filter by pattern (case-sensitive)
|
|
186
|
+
*/
|
|
187
|
+
like(column: keyof T | string, pattern: string): this;
|
|
188
|
+
/**
|
|
189
|
+
* Filter by pattern (case-insensitive)
|
|
190
|
+
*/
|
|
191
|
+
ilike(column: keyof T | string, pattern: string): this;
|
|
192
|
+
/**
|
|
193
|
+
* Filter by null/not null
|
|
194
|
+
*/
|
|
195
|
+
is(column: keyof T | string, value: null | boolean): this;
|
|
196
|
+
/**
|
|
197
|
+
* Filter by array of values
|
|
198
|
+
*/
|
|
199
|
+
in(column: keyof T | string, values: unknown[]): this;
|
|
200
|
+
/**
|
|
201
|
+
* Filter by array containment
|
|
202
|
+
*/
|
|
203
|
+
contains(column: keyof T | string, value: unknown[]): this;
|
|
204
|
+
/**
|
|
205
|
+
* Filter by array being contained
|
|
206
|
+
*/
|
|
207
|
+
containedBy(column: keyof T | string, value: unknown[]): this;
|
|
208
|
+
/**
|
|
209
|
+
* Filter by array overlap
|
|
210
|
+
*/
|
|
211
|
+
overlaps(column: keyof T | string, value: unknown[]): this;
|
|
212
|
+
/**
|
|
213
|
+
* Full-text search
|
|
214
|
+
*/
|
|
215
|
+
textSearch(column: keyof T | string, query: string, options?: TextSearchOptions): this;
|
|
216
|
+
/**
|
|
217
|
+
* Negate the next filter
|
|
218
|
+
*/
|
|
219
|
+
not: this;
|
|
220
|
+
/**
|
|
221
|
+
* Combine filters with OR
|
|
222
|
+
*/
|
|
223
|
+
or(filters: string): this;
|
|
224
|
+
/**
|
|
225
|
+
* Order results
|
|
226
|
+
*/
|
|
227
|
+
order(column: keyof T | string, options?: {
|
|
228
|
+
ascending?: boolean;
|
|
229
|
+
nullsFirst?: boolean;
|
|
230
|
+
}): this;
|
|
231
|
+
/**
|
|
232
|
+
* Limit number of results
|
|
233
|
+
*/
|
|
234
|
+
limit(count: number): this;
|
|
235
|
+
/**
|
|
236
|
+
* Offset results
|
|
237
|
+
*/
|
|
238
|
+
offset(count: number): this;
|
|
239
|
+
/**
|
|
240
|
+
* Paginate results
|
|
241
|
+
*/
|
|
242
|
+
range(from: number, to: number): this;
|
|
243
|
+
/**
|
|
244
|
+
* Return single result
|
|
245
|
+
*/
|
|
246
|
+
single(): Promise<QueryResult<T>>;
|
|
247
|
+
/**
|
|
248
|
+
* Return first result or null
|
|
249
|
+
*/
|
|
250
|
+
maybeSingle(): Promise<QueryResult<T | null>>;
|
|
251
|
+
/**
|
|
252
|
+
* Execute query and return results
|
|
253
|
+
*/
|
|
254
|
+
execute(): Promise<QueryResult<T[]>>;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Text search options
|
|
258
|
+
*/
|
|
259
|
+
interface TextSearchOptions {
|
|
260
|
+
/**
|
|
261
|
+
* Search configuration (language)
|
|
262
|
+
*/
|
|
263
|
+
config?: string;
|
|
264
|
+
/**
|
|
265
|
+
* Search type
|
|
266
|
+
*/
|
|
267
|
+
type?: 'plain' | 'phrase' | 'websearch';
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Select query builder
|
|
271
|
+
*/
|
|
272
|
+
interface SelectQuery<T = Record<string, unknown>> extends QueryBuilder$1<T> {
|
|
273
|
+
/**
|
|
274
|
+
* Select specific columns
|
|
275
|
+
*/
|
|
276
|
+
select(columns?: string | string[]): this;
|
|
277
|
+
/**
|
|
278
|
+
* Include count of total rows
|
|
279
|
+
*/
|
|
280
|
+
count(options?: {
|
|
281
|
+
exact?: boolean;
|
|
282
|
+
head?: boolean;
|
|
283
|
+
}): this;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Insert query builder
|
|
287
|
+
*/
|
|
288
|
+
interface InsertQuery<T = Record<string, unknown>> {
|
|
289
|
+
/**
|
|
290
|
+
* Insert single row
|
|
291
|
+
*/
|
|
292
|
+
insert(data: Partial<T>): InsertBuilder<T>;
|
|
293
|
+
/**
|
|
294
|
+
* Insert multiple rows
|
|
295
|
+
*/
|
|
296
|
+
insert(data: Partial<T>[]): InsertBuilder<T>;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Insert builder for chaining
|
|
300
|
+
*/
|
|
301
|
+
interface InsertBuilder<T = Record<string, unknown>> {
|
|
302
|
+
/**
|
|
303
|
+
* Return inserted rows
|
|
304
|
+
*/
|
|
305
|
+
select(columns?: string | string[]): Promise<QueryResult<T[]>>;
|
|
306
|
+
/**
|
|
307
|
+
* Execute without returning
|
|
308
|
+
*/
|
|
309
|
+
execute(): Promise<QueryResult<null>>;
|
|
310
|
+
/**
|
|
311
|
+
* Handle conflicts (upsert)
|
|
312
|
+
*/
|
|
313
|
+
onConflict(columns: string | string[]): ConflictBuilder<T>;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Conflict handling builder
|
|
317
|
+
*/
|
|
318
|
+
interface ConflictBuilder<T = Record<string, unknown>> {
|
|
319
|
+
/**
|
|
320
|
+
* Do nothing on conflict
|
|
321
|
+
*/
|
|
322
|
+
doNothing(): InsertBuilder<T>;
|
|
323
|
+
/**
|
|
324
|
+
* Update on conflict
|
|
325
|
+
*/
|
|
326
|
+
doUpdate(data: Partial<T>): InsertBuilder<T>;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Update query builder
|
|
330
|
+
*/
|
|
331
|
+
interface UpdateQuery<T = Record<string, unknown>> extends Omit<QueryBuilder$1<T>, 'execute'> {
|
|
332
|
+
/**
|
|
333
|
+
* Update with data
|
|
334
|
+
*/
|
|
335
|
+
update(data: Partial<T>): this;
|
|
336
|
+
/**
|
|
337
|
+
* Return updated rows
|
|
338
|
+
*/
|
|
339
|
+
select(columns?: string | string[]): Promise<QueryResult<T[]>>;
|
|
340
|
+
/**
|
|
341
|
+
* Execute without returning
|
|
342
|
+
*/
|
|
343
|
+
execute(): Promise<QueryResult<{
|
|
344
|
+
count: number;
|
|
345
|
+
}>>;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Delete query builder
|
|
349
|
+
*/
|
|
350
|
+
interface DeleteQuery<T = Record<string, unknown>> extends Omit<QueryBuilder$1<T>, 'execute'> {
|
|
351
|
+
/**
|
|
352
|
+
* Return deleted rows
|
|
353
|
+
*/
|
|
354
|
+
select(columns?: string | string[]): Promise<QueryResult<T[]>>;
|
|
355
|
+
/**
|
|
356
|
+
* Execute without returning
|
|
357
|
+
*/
|
|
358
|
+
execute(): Promise<QueryResult<{
|
|
359
|
+
count: number;
|
|
360
|
+
}>>;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Query result
|
|
364
|
+
*/
|
|
365
|
+
interface QueryResult<T> {
|
|
366
|
+
/**
|
|
367
|
+
* Query data
|
|
368
|
+
*/
|
|
369
|
+
data: T;
|
|
370
|
+
/**
|
|
371
|
+
* Error if query failed
|
|
372
|
+
*/
|
|
373
|
+
error: QueryError | null;
|
|
374
|
+
/**
|
|
375
|
+
* Total count (if requested)
|
|
376
|
+
*/
|
|
377
|
+
count?: number;
|
|
378
|
+
/**
|
|
379
|
+
* HTTP status code
|
|
380
|
+
*/
|
|
381
|
+
status: number;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Query error
|
|
385
|
+
*/
|
|
386
|
+
interface QueryError {
|
|
387
|
+
/**
|
|
388
|
+
* Error message
|
|
389
|
+
*/
|
|
390
|
+
message: string;
|
|
391
|
+
/**
|
|
392
|
+
* Error code
|
|
393
|
+
*/
|
|
394
|
+
code: string;
|
|
395
|
+
/**
|
|
396
|
+
* Additional details
|
|
397
|
+
*/
|
|
398
|
+
details?: string;
|
|
399
|
+
/**
|
|
400
|
+
* Hint for fixing the error
|
|
401
|
+
*/
|
|
402
|
+
hint?: string;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* VAIF Database Client
|
|
407
|
+
*
|
|
408
|
+
* Provides type-safe database operations with a fluent query builder
|
|
409
|
+
*/
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Database client for VAIF Studio
|
|
413
|
+
*/
|
|
414
|
+
declare class VaifDatabase {
|
|
415
|
+
private client;
|
|
416
|
+
constructor(client: VaifClient);
|
|
417
|
+
/**
|
|
418
|
+
* Start a query on a table
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```typescript
|
|
422
|
+
* const users = await vaif.db.from('users').select('*').execute();
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
425
|
+
from<T = Record<string, unknown>>(table: string): QueryBuilder<T>;
|
|
426
|
+
/**
|
|
427
|
+
* Execute raw SQL query (admin only)
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```typescript
|
|
431
|
+
* const result = await vaif.db.raw('SELECT * FROM users WHERE id = $1', [userId]);
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
434
|
+
raw<T = unknown>(sql: string, params?: unknown[]): Promise<QueryResult<T[]>>;
|
|
435
|
+
/**
|
|
436
|
+
* Execute a function (stored procedure)
|
|
437
|
+
*/
|
|
438
|
+
rpc<T = unknown>(functionName: string, params?: Record<string, unknown>): Promise<QueryResult<T>>;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Query builder for constructing database queries
|
|
442
|
+
*/
|
|
443
|
+
declare class QueryBuilder<T = Record<string, unknown>> {
|
|
444
|
+
private table;
|
|
445
|
+
private client;
|
|
446
|
+
private queryType;
|
|
447
|
+
private selectColumns;
|
|
448
|
+
private insertData;
|
|
449
|
+
private updateData;
|
|
450
|
+
private filters;
|
|
451
|
+
private orderSpecs;
|
|
452
|
+
private limitCount;
|
|
453
|
+
private offsetCount;
|
|
454
|
+
private returning;
|
|
455
|
+
private countOption;
|
|
456
|
+
private negateNext;
|
|
457
|
+
private onConflictColumns;
|
|
458
|
+
private onConflictAction;
|
|
459
|
+
private onConflictUpdate;
|
|
460
|
+
constructor(client: VaifClient, table: string);
|
|
461
|
+
/**
|
|
462
|
+
* Select columns
|
|
463
|
+
*/
|
|
464
|
+
select(columns?: string | string[]): this;
|
|
465
|
+
/**
|
|
466
|
+
* Insert data
|
|
467
|
+
*/
|
|
468
|
+
insert(data: Partial<T> | Partial<T>[]): this;
|
|
469
|
+
/**
|
|
470
|
+
* Update data
|
|
471
|
+
*/
|
|
472
|
+
update(data: Partial<T>): this;
|
|
473
|
+
/**
|
|
474
|
+
* Delete rows
|
|
475
|
+
*/
|
|
476
|
+
delete(): this;
|
|
477
|
+
/**
|
|
478
|
+
* Handle insert conflicts (upsert)
|
|
479
|
+
*/
|
|
480
|
+
onConflict(columns: string | string[]): this;
|
|
481
|
+
/**
|
|
482
|
+
* Do nothing on conflict
|
|
483
|
+
*/
|
|
484
|
+
doNothing(): this;
|
|
485
|
+
/**
|
|
486
|
+
* Update on conflict
|
|
487
|
+
*/
|
|
488
|
+
doUpdate(data: Partial<T>): this;
|
|
489
|
+
eq(column: keyof T | string, value: unknown): this;
|
|
490
|
+
neq(column: keyof T | string, value: unknown): this;
|
|
491
|
+
gt(column: keyof T | string, value: unknown): this;
|
|
492
|
+
gte(column: keyof T | string, value: unknown): this;
|
|
493
|
+
lt(column: keyof T | string, value: unknown): this;
|
|
494
|
+
lte(column: keyof T | string, value: unknown): this;
|
|
495
|
+
like(column: keyof T | string, pattern: string): this;
|
|
496
|
+
ilike(column: keyof T | string, pattern: string): this;
|
|
497
|
+
is(column: keyof T | string, value: null | boolean): this;
|
|
498
|
+
in(column: keyof T | string, values: unknown[]): this;
|
|
499
|
+
contains(column: keyof T | string, value: unknown[]): this;
|
|
500
|
+
containedBy(column: keyof T | string, value: unknown[]): this;
|
|
501
|
+
overlaps(column: keyof T | string, value: unknown[]): this;
|
|
502
|
+
textSearch(column: keyof T | string, query: string, options?: {
|
|
503
|
+
config?: string;
|
|
504
|
+
}): this;
|
|
505
|
+
/**
|
|
506
|
+
* Negate the next filter
|
|
507
|
+
*/
|
|
508
|
+
get not(): this;
|
|
509
|
+
/**
|
|
510
|
+
* Combine filters with OR
|
|
511
|
+
*/
|
|
512
|
+
or(filters: string): this;
|
|
513
|
+
/**
|
|
514
|
+
* Order results
|
|
515
|
+
*/
|
|
516
|
+
order(column: keyof T | string, options?: {
|
|
517
|
+
ascending?: boolean;
|
|
518
|
+
nullsFirst?: boolean;
|
|
519
|
+
}): this;
|
|
520
|
+
/**
|
|
521
|
+
* Limit results
|
|
522
|
+
*/
|
|
523
|
+
limit(count: number): this;
|
|
524
|
+
/**
|
|
525
|
+
* Offset results
|
|
526
|
+
*/
|
|
527
|
+
offset(count: number): this;
|
|
528
|
+
/**
|
|
529
|
+
* Range of results
|
|
530
|
+
*/
|
|
531
|
+
range(from: number, to: number): this;
|
|
532
|
+
/**
|
|
533
|
+
* Include count
|
|
534
|
+
*/
|
|
535
|
+
count(type?: 'exact' | 'planned' | 'estimated'): this;
|
|
536
|
+
/**
|
|
537
|
+
* Return single result
|
|
538
|
+
*/
|
|
539
|
+
single(): Promise<QueryResult<T>>;
|
|
540
|
+
/**
|
|
541
|
+
* Return first result or null
|
|
542
|
+
*/
|
|
543
|
+
maybeSingle(): Promise<QueryResult<T | null>>;
|
|
544
|
+
/**
|
|
545
|
+
* Execute the query
|
|
546
|
+
*/
|
|
547
|
+
execute(): Promise<QueryResult<T[]>>;
|
|
548
|
+
private addFilter;
|
|
549
|
+
private getHttpMethod;
|
|
550
|
+
private buildQuery;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Realtime types for VAIF Studio
|
|
555
|
+
*/
|
|
556
|
+
/**
|
|
557
|
+
* Realtime connection options
|
|
558
|
+
*/
|
|
559
|
+
interface RealtimeOptions {
|
|
560
|
+
/**
|
|
561
|
+
* Enable heartbeat
|
|
562
|
+
*/
|
|
563
|
+
heartbeat?: boolean;
|
|
564
|
+
/**
|
|
565
|
+
* Heartbeat interval in milliseconds
|
|
566
|
+
*/
|
|
567
|
+
heartbeatInterval?: number;
|
|
568
|
+
/**
|
|
569
|
+
* Reconnect on disconnect
|
|
570
|
+
*/
|
|
571
|
+
autoReconnect?: boolean;
|
|
572
|
+
/**
|
|
573
|
+
* Maximum reconnect attempts
|
|
574
|
+
*/
|
|
575
|
+
maxReconnectAttempts?: number;
|
|
576
|
+
/**
|
|
577
|
+
* Reconnect interval in milliseconds
|
|
578
|
+
*/
|
|
579
|
+
reconnectInterval?: number;
|
|
580
|
+
/**
|
|
581
|
+
* Connection timeout in milliseconds
|
|
582
|
+
*/
|
|
583
|
+
timeout?: number;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Realtime event types
|
|
587
|
+
*/
|
|
588
|
+
type RealtimeEvent = 'INSERT' | 'UPDATE' | 'DELETE' | '*' | 'postgres_changes' | 'broadcast' | 'presence';
|
|
589
|
+
/**
|
|
590
|
+
* Database change event
|
|
591
|
+
*/
|
|
592
|
+
interface PostgresChangeEvent<T = Record<string, unknown>> {
|
|
593
|
+
/**
|
|
594
|
+
* Event type
|
|
595
|
+
*/
|
|
596
|
+
eventType: 'INSERT' | 'UPDATE' | 'DELETE';
|
|
597
|
+
/**
|
|
598
|
+
* Schema name
|
|
599
|
+
*/
|
|
600
|
+
schema: string;
|
|
601
|
+
/**
|
|
602
|
+
* Table name
|
|
603
|
+
*/
|
|
604
|
+
table: string;
|
|
605
|
+
/**
|
|
606
|
+
* Commit timestamp
|
|
607
|
+
*/
|
|
608
|
+
commitTimestamp: string;
|
|
609
|
+
/**
|
|
610
|
+
* New row data (for INSERT/UPDATE)
|
|
611
|
+
*/
|
|
612
|
+
new: T | null;
|
|
613
|
+
/**
|
|
614
|
+
* Old row data (for UPDATE/DELETE)
|
|
615
|
+
*/
|
|
616
|
+
old: Partial<T> | null;
|
|
617
|
+
/**
|
|
618
|
+
* Errors if any
|
|
619
|
+
*/
|
|
620
|
+
errors: string[] | null;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Broadcast message
|
|
624
|
+
*/
|
|
625
|
+
interface BroadcastMessage<T = unknown> {
|
|
626
|
+
/**
|
|
627
|
+
* Event name
|
|
628
|
+
*/
|
|
629
|
+
event: string;
|
|
630
|
+
/**
|
|
631
|
+
* Message payload
|
|
632
|
+
*/
|
|
633
|
+
payload: T;
|
|
634
|
+
/**
|
|
635
|
+
* Message type
|
|
636
|
+
*/
|
|
637
|
+
type: 'broadcast';
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Presence state
|
|
641
|
+
*/
|
|
642
|
+
interface PresenceState<T = Record<string, unknown>> {
|
|
643
|
+
/**
|
|
644
|
+
* Presence key (user identifier)
|
|
645
|
+
*/
|
|
646
|
+
key: string;
|
|
647
|
+
/**
|
|
648
|
+
* Presence payload
|
|
649
|
+
*/
|
|
650
|
+
payload: T;
|
|
651
|
+
/**
|
|
652
|
+
* Join timestamp
|
|
653
|
+
*/
|
|
654
|
+
joinedAt: string;
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Presence sync event
|
|
658
|
+
*/
|
|
659
|
+
interface PresenceSyncEvent<T = Record<string, unknown>> {
|
|
660
|
+
/**
|
|
661
|
+
* Current presence state
|
|
662
|
+
*/
|
|
663
|
+
state: Record<string, PresenceState<T>[]>;
|
|
664
|
+
/**
|
|
665
|
+
* Users who joined
|
|
666
|
+
*/
|
|
667
|
+
joins: Record<string, PresenceState<T>[]>;
|
|
668
|
+
/**
|
|
669
|
+
* Users who left
|
|
670
|
+
*/
|
|
671
|
+
leaves: Record<string, PresenceState<T>[]>;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Generic realtime message
|
|
675
|
+
*/
|
|
676
|
+
interface RealtimeMessage<T = unknown> {
|
|
677
|
+
/**
|
|
678
|
+
* Message topic
|
|
679
|
+
*/
|
|
680
|
+
topic: string;
|
|
681
|
+
/**
|
|
682
|
+
* Event type
|
|
683
|
+
*/
|
|
684
|
+
event: string;
|
|
685
|
+
/**
|
|
686
|
+
* Message payload
|
|
687
|
+
*/
|
|
688
|
+
payload: T;
|
|
689
|
+
/**
|
|
690
|
+
* Reference ID
|
|
691
|
+
*/
|
|
692
|
+
ref?: string;
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Subscription callback type
|
|
696
|
+
*/
|
|
697
|
+
type SubscriptionCallback<T = unknown> = (payload: T) => void;
|
|
698
|
+
/**
|
|
699
|
+
* Realtime channel status
|
|
700
|
+
*/
|
|
701
|
+
type ChannelStatus = 'SUBSCRIBED' | 'TIMED_OUT' | 'CLOSED' | 'CHANNEL_ERROR';
|
|
702
|
+
/**
|
|
703
|
+
* Postgres changes filter
|
|
704
|
+
*/
|
|
705
|
+
interface PostgresChangesFilter {
|
|
706
|
+
/**
|
|
707
|
+
* Event type to listen for
|
|
708
|
+
*/
|
|
709
|
+
event: 'INSERT' | 'UPDATE' | 'DELETE' | '*';
|
|
710
|
+
/**
|
|
711
|
+
* Schema name (defaults to 'public')
|
|
712
|
+
*/
|
|
713
|
+
schema?: string;
|
|
714
|
+
/**
|
|
715
|
+
* Table name
|
|
716
|
+
*/
|
|
717
|
+
table: string;
|
|
718
|
+
/**
|
|
719
|
+
* Filter expression (e.g., 'id=eq.123')
|
|
720
|
+
*/
|
|
721
|
+
filter?: string;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* VAIF Realtime Client
|
|
726
|
+
*
|
|
727
|
+
* WebSocket-based realtime subscriptions for database changes, broadcasts, and presence
|
|
728
|
+
*/
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Realtime client for VAIF Studio
|
|
732
|
+
*/
|
|
733
|
+
declare class VaifRealtime {
|
|
734
|
+
private client;
|
|
735
|
+
private socket;
|
|
736
|
+
private channels;
|
|
737
|
+
private reconnectAttempts;
|
|
738
|
+
private maxReconnectAttempts;
|
|
739
|
+
private reconnectInterval;
|
|
740
|
+
private heartbeatInterval;
|
|
741
|
+
constructor(client: VaifClient);
|
|
742
|
+
/**
|
|
743
|
+
* Connect to realtime server
|
|
744
|
+
*/
|
|
745
|
+
connect(options?: RealtimeOptions): void;
|
|
746
|
+
/**
|
|
747
|
+
* Disconnect from realtime server
|
|
748
|
+
*/
|
|
749
|
+
disconnect(): void;
|
|
750
|
+
/**
|
|
751
|
+
* Create or get a channel
|
|
752
|
+
*/
|
|
753
|
+
channel(name: string): RealtimeChannel;
|
|
754
|
+
/**
|
|
755
|
+
* Remove a channel
|
|
756
|
+
*/
|
|
757
|
+
removeChannel(name: string): void;
|
|
758
|
+
/**
|
|
759
|
+
* Send message to server
|
|
760
|
+
*/
|
|
761
|
+
send(message: unknown): void;
|
|
762
|
+
/**
|
|
763
|
+
* Get WebSocket instance
|
|
764
|
+
*/
|
|
765
|
+
getSocket(): WebSocket | null;
|
|
766
|
+
private handleMessage;
|
|
767
|
+
private startHeartbeat;
|
|
768
|
+
private stopHeartbeat;
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Realtime channel for subscriptions
|
|
772
|
+
*/
|
|
773
|
+
declare class RealtimeChannel {
|
|
774
|
+
private realtime;
|
|
775
|
+
private name;
|
|
776
|
+
private subscriptions;
|
|
777
|
+
private status;
|
|
778
|
+
private presenceState;
|
|
779
|
+
constructor(realtime: VaifRealtime, name: string);
|
|
780
|
+
/**
|
|
781
|
+
* Subscribe to postgres changes
|
|
782
|
+
*/
|
|
783
|
+
on<T = Record<string, unknown>>(event: 'postgres_changes', filter: PostgresChangesFilter, callback: SubscriptionCallback<PostgresChangeEvent<T>>): this;
|
|
784
|
+
on<T = unknown>(event: 'broadcast', filter: {
|
|
785
|
+
event: string;
|
|
786
|
+
}, callback: SubscriptionCallback<BroadcastMessage<T>>): this;
|
|
787
|
+
on<T = Record<string, unknown>>(event: 'presence', filter: {
|
|
788
|
+
event: 'sync' | 'join' | 'leave';
|
|
789
|
+
}, callback: SubscriptionCallback<PresenceSyncEvent<T>>): this;
|
|
790
|
+
/**
|
|
791
|
+
* Subscribe to channel
|
|
792
|
+
*/
|
|
793
|
+
subscribe(callback?: (status: ChannelStatus, error?: Error) => void): this;
|
|
794
|
+
/**
|
|
795
|
+
* Unsubscribe from channel
|
|
796
|
+
*/
|
|
797
|
+
unsubscribe(): void;
|
|
798
|
+
/**
|
|
799
|
+
* Broadcast message to channel
|
|
800
|
+
*/
|
|
801
|
+
broadcast<T = unknown>(event: string, payload: T): void;
|
|
802
|
+
/**
|
|
803
|
+
* Track presence
|
|
804
|
+
*/
|
|
805
|
+
track<T = Record<string, unknown>>(payload: T): void;
|
|
806
|
+
/**
|
|
807
|
+
* Untrack presence
|
|
808
|
+
*/
|
|
809
|
+
untrack(): void;
|
|
810
|
+
/**
|
|
811
|
+
* Get current presence state
|
|
812
|
+
*/
|
|
813
|
+
getPresenceState<T = Record<string, unknown>>(): Map<string, PresenceState<T>[]>;
|
|
814
|
+
/**
|
|
815
|
+
* Handle incoming message
|
|
816
|
+
*/
|
|
817
|
+
handleMessage(message: {
|
|
818
|
+
event: string;
|
|
819
|
+
payload: unknown;
|
|
820
|
+
}): void;
|
|
821
|
+
/**
|
|
822
|
+
* Resubscribe after reconnect
|
|
823
|
+
*/
|
|
824
|
+
resubscribe(): void;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* Storage types for VAIF Studio
|
|
829
|
+
*/
|
|
830
|
+
/**
|
|
831
|
+
* Storage client options
|
|
832
|
+
*/
|
|
833
|
+
interface StorageOptions {
|
|
834
|
+
/**
|
|
835
|
+
* Default bucket to use
|
|
836
|
+
*/
|
|
837
|
+
defaultBucket?: string;
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* File upload options
|
|
841
|
+
*/
|
|
842
|
+
interface UploadOptions {
|
|
843
|
+
/**
|
|
844
|
+
* Content type (MIME type)
|
|
845
|
+
*/
|
|
846
|
+
contentType?: string;
|
|
847
|
+
/**
|
|
848
|
+
* Cache control header
|
|
849
|
+
*/
|
|
850
|
+
cacheControl?: string;
|
|
851
|
+
/**
|
|
852
|
+
* Upsert if file exists
|
|
853
|
+
*/
|
|
854
|
+
upsert?: boolean;
|
|
855
|
+
/**
|
|
856
|
+
* Custom metadata
|
|
857
|
+
*/
|
|
858
|
+
metadata?: Record<string, string>;
|
|
859
|
+
/**
|
|
860
|
+
* Upload progress callback
|
|
861
|
+
*/
|
|
862
|
+
onUploadProgress?: (progress: UploadProgress) => void;
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Upload progress information
|
|
866
|
+
*/
|
|
867
|
+
interface UploadProgress {
|
|
868
|
+
/**
|
|
869
|
+
* Bytes uploaded
|
|
870
|
+
*/
|
|
871
|
+
loaded: number;
|
|
872
|
+
/**
|
|
873
|
+
* Total bytes
|
|
874
|
+
*/
|
|
875
|
+
total: number;
|
|
876
|
+
/**
|
|
877
|
+
* Progress percentage (0-100)
|
|
878
|
+
*/
|
|
879
|
+
progress: number;
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* File download options
|
|
883
|
+
*/
|
|
884
|
+
interface DownloadOptions {
|
|
885
|
+
/**
|
|
886
|
+
* Transform image on download
|
|
887
|
+
*/
|
|
888
|
+
transform?: ImageTransformOptions;
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Image transformation options
|
|
892
|
+
*/
|
|
893
|
+
interface ImageTransformOptions {
|
|
894
|
+
/**
|
|
895
|
+
* Resize width
|
|
896
|
+
*/
|
|
897
|
+
width?: number;
|
|
898
|
+
/**
|
|
899
|
+
* Resize height
|
|
900
|
+
*/
|
|
901
|
+
height?: number;
|
|
902
|
+
/**
|
|
903
|
+
* Resize mode
|
|
904
|
+
*/
|
|
905
|
+
resize?: 'cover' | 'contain' | 'fill';
|
|
906
|
+
/**
|
|
907
|
+
* Output format
|
|
908
|
+
*/
|
|
909
|
+
format?: 'origin' | 'webp' | 'avif' | 'jpeg' | 'png';
|
|
910
|
+
/**
|
|
911
|
+
* Quality (1-100)
|
|
912
|
+
*/
|
|
913
|
+
quality?: number;
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Signed URL options
|
|
917
|
+
*/
|
|
918
|
+
interface SignedUrlOptions {
|
|
919
|
+
/**
|
|
920
|
+
* URL expiration in seconds
|
|
921
|
+
*/
|
|
922
|
+
expiresIn: number;
|
|
923
|
+
/**
|
|
924
|
+
* Image transformations
|
|
925
|
+
*/
|
|
926
|
+
transform?: ImageTransformOptions;
|
|
927
|
+
/**
|
|
928
|
+
* Download instead of inline
|
|
929
|
+
*/
|
|
930
|
+
download?: boolean | string;
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* File object metadata
|
|
934
|
+
*/
|
|
935
|
+
interface FileObject {
|
|
936
|
+
/**
|
|
937
|
+
* File ID
|
|
938
|
+
*/
|
|
939
|
+
id: string;
|
|
940
|
+
/**
|
|
941
|
+
* File name
|
|
942
|
+
*/
|
|
943
|
+
name: string;
|
|
944
|
+
/**
|
|
945
|
+
* Bucket ID
|
|
946
|
+
*/
|
|
947
|
+
bucketId: string;
|
|
948
|
+
/**
|
|
949
|
+
* File path within bucket
|
|
950
|
+
*/
|
|
951
|
+
path: string;
|
|
952
|
+
/**
|
|
953
|
+
* File size in bytes
|
|
954
|
+
*/
|
|
955
|
+
size: number;
|
|
956
|
+
/**
|
|
957
|
+
* Content type (MIME type)
|
|
958
|
+
*/
|
|
959
|
+
contentType: string;
|
|
960
|
+
/**
|
|
961
|
+
* ETag for caching
|
|
962
|
+
*/
|
|
963
|
+
etag: string;
|
|
964
|
+
/**
|
|
965
|
+
* Cache control header
|
|
966
|
+
*/
|
|
967
|
+
cacheControl: string;
|
|
968
|
+
/**
|
|
969
|
+
* Custom metadata
|
|
970
|
+
*/
|
|
971
|
+
metadata: Record<string, string>;
|
|
972
|
+
/**
|
|
973
|
+
* Created timestamp
|
|
974
|
+
*/
|
|
975
|
+
createdAt: string;
|
|
976
|
+
/**
|
|
977
|
+
* Last modified timestamp
|
|
978
|
+
*/
|
|
979
|
+
updatedAt: string;
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* Bucket metadata
|
|
983
|
+
*/
|
|
984
|
+
interface Bucket {
|
|
985
|
+
/**
|
|
986
|
+
* Bucket ID
|
|
987
|
+
*/
|
|
988
|
+
id: string;
|
|
989
|
+
/**
|
|
990
|
+
* Bucket name
|
|
991
|
+
*/
|
|
992
|
+
name: string;
|
|
993
|
+
/**
|
|
994
|
+
* Owner ID
|
|
995
|
+
*/
|
|
996
|
+
ownerId: string;
|
|
997
|
+
/**
|
|
998
|
+
* Public access enabled
|
|
999
|
+
*/
|
|
1000
|
+
public: boolean;
|
|
1001
|
+
/**
|
|
1002
|
+
* File size limit in bytes
|
|
1003
|
+
*/
|
|
1004
|
+
fileSizeLimit: number | null;
|
|
1005
|
+
/**
|
|
1006
|
+
* Allowed MIME types
|
|
1007
|
+
*/
|
|
1008
|
+
allowedMimeTypes: string[] | null;
|
|
1009
|
+
/**
|
|
1010
|
+
* Created timestamp
|
|
1011
|
+
*/
|
|
1012
|
+
createdAt: string;
|
|
1013
|
+
/**
|
|
1014
|
+
* Last updated timestamp
|
|
1015
|
+
*/
|
|
1016
|
+
updatedAt: string;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* List files options
|
|
1020
|
+
*/
|
|
1021
|
+
interface ListFilesOptions {
|
|
1022
|
+
/**
|
|
1023
|
+
* Number of files to return
|
|
1024
|
+
*/
|
|
1025
|
+
limit?: number;
|
|
1026
|
+
/**
|
|
1027
|
+
* Offset for pagination
|
|
1028
|
+
*/
|
|
1029
|
+
offset?: number;
|
|
1030
|
+
/**
|
|
1031
|
+
* Search query
|
|
1032
|
+
*/
|
|
1033
|
+
search?: string;
|
|
1034
|
+
/**
|
|
1035
|
+
* Sort by column
|
|
1036
|
+
*/
|
|
1037
|
+
sortBy?: {
|
|
1038
|
+
column: 'name' | 'createdAt' | 'updatedAt' | 'size';
|
|
1039
|
+
order: 'asc' | 'desc';
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Upload result
|
|
1044
|
+
*/
|
|
1045
|
+
interface UploadResult {
|
|
1046
|
+
/**
|
|
1047
|
+
* Uploaded file path
|
|
1048
|
+
*/
|
|
1049
|
+
path: string;
|
|
1050
|
+
/**
|
|
1051
|
+
* File ID
|
|
1052
|
+
*/
|
|
1053
|
+
id: string;
|
|
1054
|
+
/**
|
|
1055
|
+
* Full URL (if public)
|
|
1056
|
+
*/
|
|
1057
|
+
fullPath: string;
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Storage error
|
|
1061
|
+
*/
|
|
1062
|
+
interface StorageError {
|
|
1063
|
+
/**
|
|
1064
|
+
* Error message
|
|
1065
|
+
*/
|
|
1066
|
+
message: string;
|
|
1067
|
+
/**
|
|
1068
|
+
* Error code
|
|
1069
|
+
*/
|
|
1070
|
+
statusCode: string;
|
|
1071
|
+
/**
|
|
1072
|
+
* Error name
|
|
1073
|
+
*/
|
|
1074
|
+
error: string;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* VAIF Storage Client
|
|
1079
|
+
*
|
|
1080
|
+
* File storage operations with CDN and image transformations
|
|
1081
|
+
*/
|
|
1082
|
+
|
|
1083
|
+
/**
|
|
1084
|
+
* Storage client for VAIF Studio
|
|
1085
|
+
*/
|
|
1086
|
+
declare class VaifStorage {
|
|
1087
|
+
private client;
|
|
1088
|
+
constructor(client: VaifClient);
|
|
1089
|
+
/**
|
|
1090
|
+
* Get a storage bucket
|
|
1091
|
+
*/
|
|
1092
|
+
from(bucket: string): StorageBucket;
|
|
1093
|
+
/**
|
|
1094
|
+
* List all buckets
|
|
1095
|
+
*/
|
|
1096
|
+
listBuckets(): Promise<{
|
|
1097
|
+
data: Bucket[] | null;
|
|
1098
|
+
error: StorageError | null;
|
|
1099
|
+
}>;
|
|
1100
|
+
/**
|
|
1101
|
+
* Create a bucket
|
|
1102
|
+
*/
|
|
1103
|
+
createBucket(name: string, options?: {
|
|
1104
|
+
public?: boolean;
|
|
1105
|
+
fileSizeLimit?: number;
|
|
1106
|
+
allowedMimeTypes?: string[];
|
|
1107
|
+
}): Promise<{
|
|
1108
|
+
data: Bucket | null;
|
|
1109
|
+
error: StorageError | null;
|
|
1110
|
+
}>;
|
|
1111
|
+
/**
|
|
1112
|
+
* Delete a bucket
|
|
1113
|
+
*/
|
|
1114
|
+
deleteBucket(name: string): Promise<{
|
|
1115
|
+
error: StorageError | null;
|
|
1116
|
+
}>;
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Storage bucket operations
|
|
1120
|
+
*/
|
|
1121
|
+
declare class StorageBucket {
|
|
1122
|
+
private client;
|
|
1123
|
+
private bucket;
|
|
1124
|
+
constructor(client: VaifClient, bucket: string);
|
|
1125
|
+
/**
|
|
1126
|
+
* Upload a file
|
|
1127
|
+
*/
|
|
1128
|
+
upload(path: string, file: File | Blob | ArrayBuffer | string, options?: UploadOptions): Promise<{
|
|
1129
|
+
data: UploadResult | null;
|
|
1130
|
+
error: StorageError | null;
|
|
1131
|
+
}>;
|
|
1132
|
+
/**
|
|
1133
|
+
* Download a file
|
|
1134
|
+
*/
|
|
1135
|
+
download(path: string, options?: DownloadOptions): Promise<{
|
|
1136
|
+
data: Blob | null;
|
|
1137
|
+
error: StorageError | null;
|
|
1138
|
+
}>;
|
|
1139
|
+
/**
|
|
1140
|
+
* Get public URL for a file
|
|
1141
|
+
*/
|
|
1142
|
+
getPublicUrl(path: string): {
|
|
1143
|
+
data: {
|
|
1144
|
+
publicUrl: string;
|
|
1145
|
+
};
|
|
1146
|
+
};
|
|
1147
|
+
/**
|
|
1148
|
+
* Create signed URL
|
|
1149
|
+
*/
|
|
1150
|
+
createSignedUrl(path: string, options: SignedUrlOptions): Promise<{
|
|
1151
|
+
data: {
|
|
1152
|
+
signedUrl: string;
|
|
1153
|
+
} | null;
|
|
1154
|
+
error: StorageError | null;
|
|
1155
|
+
}>;
|
|
1156
|
+
/**
|
|
1157
|
+
* List files in a path
|
|
1158
|
+
*/
|
|
1159
|
+
list(path?: string, options?: ListFilesOptions): Promise<{
|
|
1160
|
+
data: FileObject[] | null;
|
|
1161
|
+
error: StorageError | null;
|
|
1162
|
+
}>;
|
|
1163
|
+
/**
|
|
1164
|
+
* Move/rename a file
|
|
1165
|
+
*/
|
|
1166
|
+
move(fromPath: string, toPath: string): Promise<{
|
|
1167
|
+
error: StorageError | null;
|
|
1168
|
+
}>;
|
|
1169
|
+
/**
|
|
1170
|
+
* Copy a file
|
|
1171
|
+
*/
|
|
1172
|
+
copy(fromPath: string, toPath: string): Promise<{
|
|
1173
|
+
error: StorageError | null;
|
|
1174
|
+
}>;
|
|
1175
|
+
/**
|
|
1176
|
+
* Delete a file
|
|
1177
|
+
*/
|
|
1178
|
+
remove(paths: string | string[]): Promise<{
|
|
1179
|
+
error: StorageError | null;
|
|
1180
|
+
}>;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Functions types for VAIF Studio
|
|
1185
|
+
*/
|
|
1186
|
+
/**
|
|
1187
|
+
* Function invocation options
|
|
1188
|
+
*/
|
|
1189
|
+
interface FunctionInvokeOptions<T = unknown> {
|
|
1190
|
+
/**
|
|
1191
|
+
* Request body
|
|
1192
|
+
*/
|
|
1193
|
+
body?: T;
|
|
1194
|
+
/**
|
|
1195
|
+
* HTTP method (defaults to POST)
|
|
1196
|
+
*/
|
|
1197
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
1198
|
+
/**
|
|
1199
|
+
* Custom headers
|
|
1200
|
+
*/
|
|
1201
|
+
headers?: Record<string, string>;
|
|
1202
|
+
/**
|
|
1203
|
+
* Request timeout in milliseconds
|
|
1204
|
+
*/
|
|
1205
|
+
timeout?: number;
|
|
1206
|
+
/**
|
|
1207
|
+
* Region to invoke function in
|
|
1208
|
+
*/
|
|
1209
|
+
region?: string;
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Function response
|
|
1213
|
+
*/
|
|
1214
|
+
interface FunctionResponse<T = unknown> {
|
|
1215
|
+
/**
|
|
1216
|
+
* Response data
|
|
1217
|
+
*/
|
|
1218
|
+
data: T | null;
|
|
1219
|
+
/**
|
|
1220
|
+
* Error if invocation failed
|
|
1221
|
+
*/
|
|
1222
|
+
error: FunctionError | null;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Function error
|
|
1226
|
+
*/
|
|
1227
|
+
interface FunctionError {
|
|
1228
|
+
/**
|
|
1229
|
+
* Error message
|
|
1230
|
+
*/
|
|
1231
|
+
message: string;
|
|
1232
|
+
/**
|
|
1233
|
+
* HTTP status code
|
|
1234
|
+
*/
|
|
1235
|
+
status?: number;
|
|
1236
|
+
/**
|
|
1237
|
+
* Error name/type
|
|
1238
|
+
*/
|
|
1239
|
+
name?: string;
|
|
1240
|
+
/**
|
|
1241
|
+
* Stack trace (development only)
|
|
1242
|
+
*/
|
|
1243
|
+
stack?: string;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* VAIF Functions Client
|
|
1248
|
+
*
|
|
1249
|
+
* Invoke edge functions deployed on VAIF Studio
|
|
1250
|
+
*/
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
* Functions client for VAIF Studio
|
|
1254
|
+
*/
|
|
1255
|
+
declare class VaifFunctions {
|
|
1256
|
+
private client;
|
|
1257
|
+
constructor(client: VaifClient);
|
|
1258
|
+
/**
|
|
1259
|
+
* Invoke an edge function
|
|
1260
|
+
*
|
|
1261
|
+
* @example
|
|
1262
|
+
* ```typescript
|
|
1263
|
+
* const { data, error } = await vaif.functions.invoke('send-email', {
|
|
1264
|
+
* body: { to: 'user@example.com', subject: 'Hello' }
|
|
1265
|
+
* });
|
|
1266
|
+
* ```
|
|
1267
|
+
*/
|
|
1268
|
+
invoke<T = unknown>(functionName: string, options?: FunctionInvokeOptions): Promise<FunctionResponse<T>>;
|
|
1269
|
+
/**
|
|
1270
|
+
* Create a function URL for direct invocation
|
|
1271
|
+
*/
|
|
1272
|
+
createUrl(functionName: string): string;
|
|
1273
|
+
/**
|
|
1274
|
+
* Get list of deployed functions
|
|
1275
|
+
*/
|
|
1276
|
+
list(): Promise<{
|
|
1277
|
+
data: Array<{
|
|
1278
|
+
name: string;
|
|
1279
|
+
slug: string;
|
|
1280
|
+
version: string;
|
|
1281
|
+
status: 'active' | 'inactive' | 'deploying';
|
|
1282
|
+
createdAt: string;
|
|
1283
|
+
updatedAt: string;
|
|
1284
|
+
}> | null;
|
|
1285
|
+
error: FunctionError | null;
|
|
1286
|
+
}>;
|
|
1287
|
+
/**
|
|
1288
|
+
* Get function details
|
|
1289
|
+
*/
|
|
1290
|
+
get(functionName: string): Promise<{
|
|
1291
|
+
data: {
|
|
1292
|
+
name: string;
|
|
1293
|
+
slug: string;
|
|
1294
|
+
version: string;
|
|
1295
|
+
status: 'active' | 'inactive' | 'deploying';
|
|
1296
|
+
runtime: string;
|
|
1297
|
+
memoryMb: number;
|
|
1298
|
+
timeoutMs: number;
|
|
1299
|
+
envVars: string[];
|
|
1300
|
+
createdAt: string;
|
|
1301
|
+
updatedAt: string;
|
|
1302
|
+
} | null;
|
|
1303
|
+
error: FunctionError | null;
|
|
1304
|
+
}>;
|
|
1305
|
+
private serializeBody;
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
/**
|
|
1309
|
+
* Authentication types for VAIF Studio
|
|
1310
|
+
*/
|
|
1311
|
+
/**
|
|
1312
|
+
* Auth client options
|
|
1313
|
+
*/
|
|
1314
|
+
interface AuthOptions {
|
|
1315
|
+
/**
|
|
1316
|
+
* Auto-refresh token before expiry
|
|
1317
|
+
*/
|
|
1318
|
+
autoRefreshToken?: boolean;
|
|
1319
|
+
/**
|
|
1320
|
+
* Persist session to storage
|
|
1321
|
+
*/
|
|
1322
|
+
persistSession?: boolean;
|
|
1323
|
+
/**
|
|
1324
|
+
* Detect session from URL (for OAuth)
|
|
1325
|
+
*/
|
|
1326
|
+
detectSessionInUrl?: boolean;
|
|
1327
|
+
/**
|
|
1328
|
+
* Flow type for OAuth
|
|
1329
|
+
*/
|
|
1330
|
+
flowType?: 'implicit' | 'pkce';
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* User object
|
|
1334
|
+
*/
|
|
1335
|
+
interface User {
|
|
1336
|
+
/**
|
|
1337
|
+
* User ID
|
|
1338
|
+
*/
|
|
1339
|
+
id: string;
|
|
1340
|
+
/**
|
|
1341
|
+
* Email address
|
|
1342
|
+
*/
|
|
1343
|
+
email?: string;
|
|
1344
|
+
/**
|
|
1345
|
+
* Phone number
|
|
1346
|
+
*/
|
|
1347
|
+
phone?: string;
|
|
1348
|
+
/**
|
|
1349
|
+
* Email confirmed timestamp
|
|
1350
|
+
*/
|
|
1351
|
+
emailConfirmedAt?: string;
|
|
1352
|
+
/**
|
|
1353
|
+
* Phone confirmed timestamp
|
|
1354
|
+
*/
|
|
1355
|
+
phoneConfirmedAt?: string;
|
|
1356
|
+
/**
|
|
1357
|
+
* Last sign in timestamp
|
|
1358
|
+
*/
|
|
1359
|
+
lastSignInAt?: string;
|
|
1360
|
+
/**
|
|
1361
|
+
* Auth provider
|
|
1362
|
+
*/
|
|
1363
|
+
appMetadata: {
|
|
1364
|
+
provider?: string;
|
|
1365
|
+
providers?: string[];
|
|
1366
|
+
[key: string]: unknown;
|
|
1367
|
+
};
|
|
1368
|
+
/**
|
|
1369
|
+
* User metadata
|
|
1370
|
+
*/
|
|
1371
|
+
userMetadata: Record<string, unknown>;
|
|
1372
|
+
/**
|
|
1373
|
+
* Created timestamp
|
|
1374
|
+
*/
|
|
1375
|
+
createdAt: string;
|
|
1376
|
+
/**
|
|
1377
|
+
* Updated timestamp
|
|
1378
|
+
*/
|
|
1379
|
+
updatedAt: string;
|
|
1380
|
+
/**
|
|
1381
|
+
* User role
|
|
1382
|
+
*/
|
|
1383
|
+
role?: string;
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Session object
|
|
1387
|
+
*/
|
|
1388
|
+
interface Session {
|
|
1389
|
+
/**
|
|
1390
|
+
* Access token (JWT)
|
|
1391
|
+
*/
|
|
1392
|
+
accessToken: string;
|
|
1393
|
+
/**
|
|
1394
|
+
* Refresh token
|
|
1395
|
+
*/
|
|
1396
|
+
refreshToken: string;
|
|
1397
|
+
/**
|
|
1398
|
+
* Token type (usually 'bearer')
|
|
1399
|
+
*/
|
|
1400
|
+
tokenType: string;
|
|
1401
|
+
/**
|
|
1402
|
+
* Expires in (seconds)
|
|
1403
|
+
*/
|
|
1404
|
+
expiresIn: number;
|
|
1405
|
+
/**
|
|
1406
|
+
* Expiry timestamp
|
|
1407
|
+
*/
|
|
1408
|
+
expiresAt: number;
|
|
1409
|
+
/**
|
|
1410
|
+
* User object
|
|
1411
|
+
*/
|
|
1412
|
+
user: User;
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Auth response
|
|
1416
|
+
*/
|
|
1417
|
+
interface AuthResponse {
|
|
1418
|
+
/**
|
|
1419
|
+
* Session data
|
|
1420
|
+
*/
|
|
1421
|
+
data: {
|
|
1422
|
+
user: User | null;
|
|
1423
|
+
session: Session | null;
|
|
1424
|
+
};
|
|
1425
|
+
/**
|
|
1426
|
+
* Error if auth failed
|
|
1427
|
+
*/
|
|
1428
|
+
error: AuthError | null;
|
|
1429
|
+
}
|
|
1430
|
+
/**
|
|
1431
|
+
* Auth error
|
|
1432
|
+
*/
|
|
1433
|
+
interface AuthError {
|
|
1434
|
+
/**
|
|
1435
|
+
* Error message
|
|
1436
|
+
*/
|
|
1437
|
+
message: string;
|
|
1438
|
+
/**
|
|
1439
|
+
* Error status code
|
|
1440
|
+
*/
|
|
1441
|
+
status?: number;
|
|
1442
|
+
/**
|
|
1443
|
+
* Error code
|
|
1444
|
+
*/
|
|
1445
|
+
code?: string;
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Sign up credentials
|
|
1449
|
+
*/
|
|
1450
|
+
interface SignUpCredentials {
|
|
1451
|
+
/**
|
|
1452
|
+
* Email address
|
|
1453
|
+
*/
|
|
1454
|
+
email?: string;
|
|
1455
|
+
/**
|
|
1456
|
+
* Phone number
|
|
1457
|
+
*/
|
|
1458
|
+
phone?: string;
|
|
1459
|
+
/**
|
|
1460
|
+
* Password
|
|
1461
|
+
*/
|
|
1462
|
+
password: string;
|
|
1463
|
+
/**
|
|
1464
|
+
* Additional user data
|
|
1465
|
+
*/
|
|
1466
|
+
data?: Record<string, unknown>;
|
|
1467
|
+
/**
|
|
1468
|
+
* Redirect URL after confirmation
|
|
1469
|
+
*/
|
|
1470
|
+
redirectTo?: string;
|
|
1471
|
+
/**
|
|
1472
|
+
* Captcha token
|
|
1473
|
+
*/
|
|
1474
|
+
captchaToken?: string;
|
|
1475
|
+
}
|
|
1476
|
+
/**
|
|
1477
|
+
* Sign in credentials
|
|
1478
|
+
*/
|
|
1479
|
+
interface SignInCredentials {
|
|
1480
|
+
/**
|
|
1481
|
+
* Email address
|
|
1482
|
+
*/
|
|
1483
|
+
email?: string;
|
|
1484
|
+
/**
|
|
1485
|
+
* Phone number
|
|
1486
|
+
*/
|
|
1487
|
+
phone?: string;
|
|
1488
|
+
/**
|
|
1489
|
+
* Password
|
|
1490
|
+
*/
|
|
1491
|
+
password?: string;
|
|
1492
|
+
/**
|
|
1493
|
+
* Refresh token (for token refresh)
|
|
1494
|
+
*/
|
|
1495
|
+
refreshToken?: string;
|
|
1496
|
+
/**
|
|
1497
|
+
* Redirect URL for OAuth
|
|
1498
|
+
*/
|
|
1499
|
+
redirectTo?: string;
|
|
1500
|
+
/**
|
|
1501
|
+
* OAuth scopes
|
|
1502
|
+
*/
|
|
1503
|
+
scopes?: string;
|
|
1504
|
+
/**
|
|
1505
|
+
* Captcha token
|
|
1506
|
+
*/
|
|
1507
|
+
captchaToken?: string;
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* OAuth provider
|
|
1511
|
+
*/
|
|
1512
|
+
type OAuthProvider = 'google' | 'github' | 'gitlab' | 'bitbucket' | 'azure' | 'facebook' | 'twitter' | 'discord' | 'slack' | 'spotify' | 'twitch' | 'apple' | 'linkedin';
|
|
1513
|
+
/**
|
|
1514
|
+
* OAuth sign in options
|
|
1515
|
+
*/
|
|
1516
|
+
interface OAuthSignInOptions {
|
|
1517
|
+
/**
|
|
1518
|
+
* OAuth provider
|
|
1519
|
+
*/
|
|
1520
|
+
provider: OAuthProvider;
|
|
1521
|
+
/**
|
|
1522
|
+
* Redirect URL after auth
|
|
1523
|
+
*/
|
|
1524
|
+
redirectTo?: string;
|
|
1525
|
+
/**
|
|
1526
|
+
* OAuth scopes
|
|
1527
|
+
*/
|
|
1528
|
+
scopes?: string;
|
|
1529
|
+
/**
|
|
1530
|
+
* Additional query params
|
|
1531
|
+
*/
|
|
1532
|
+
queryParams?: Record<string, string>;
|
|
1533
|
+
/**
|
|
1534
|
+
* Skip browser redirect (return URL only)
|
|
1535
|
+
*/
|
|
1536
|
+
skipBrowserRedirect?: boolean;
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Password reset options
|
|
1540
|
+
*/
|
|
1541
|
+
interface ResetPasswordOptions {
|
|
1542
|
+
/**
|
|
1543
|
+
* Email address
|
|
1544
|
+
*/
|
|
1545
|
+
email: string;
|
|
1546
|
+
/**
|
|
1547
|
+
* Redirect URL after reset
|
|
1548
|
+
*/
|
|
1549
|
+
redirectTo?: string;
|
|
1550
|
+
/**
|
|
1551
|
+
* Captcha token
|
|
1552
|
+
*/
|
|
1553
|
+
captchaToken?: string;
|
|
1554
|
+
}
|
|
1555
|
+
/**
|
|
1556
|
+
* Update user options
|
|
1557
|
+
*/
|
|
1558
|
+
interface UpdateUserOptions {
|
|
1559
|
+
/**
|
|
1560
|
+
* New email
|
|
1561
|
+
*/
|
|
1562
|
+
email?: string;
|
|
1563
|
+
/**
|
|
1564
|
+
* New phone
|
|
1565
|
+
*/
|
|
1566
|
+
phone?: string;
|
|
1567
|
+
/**
|
|
1568
|
+
* New password
|
|
1569
|
+
*/
|
|
1570
|
+
password?: string;
|
|
1571
|
+
/**
|
|
1572
|
+
* User metadata
|
|
1573
|
+
*/
|
|
1574
|
+
data?: Record<string, unknown>;
|
|
1575
|
+
/**
|
|
1576
|
+
* Email change nonce
|
|
1577
|
+
*/
|
|
1578
|
+
nonce?: string;
|
|
1579
|
+
}
|
|
1580
|
+
/**
|
|
1581
|
+
* Auth state change event
|
|
1582
|
+
*/
|
|
1583
|
+
type AuthChangeEvent = 'INITIAL_SESSION' | 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED' | 'USER_UPDATED' | 'PASSWORD_RECOVERY' | 'MFA_CHALLENGE_VERIFIED';
|
|
1584
|
+
/**
|
|
1585
|
+
* Auth state change callback
|
|
1586
|
+
*/
|
|
1587
|
+
type AuthStateChangeCallback = (event: AuthChangeEvent, session: Session | null) => void;
|
|
1588
|
+
/**
|
|
1589
|
+
* Sign up options (alias for SignUpCredentials)
|
|
1590
|
+
*/
|
|
1591
|
+
type SignUpOptions = SignUpCredentials;
|
|
1592
|
+
/**
|
|
1593
|
+
* Sign in options (alias for SignInCredentials)
|
|
1594
|
+
*/
|
|
1595
|
+
type SignInOptions = SignInCredentials;
|
|
1596
|
+
/**
|
|
1597
|
+
* OAuth sign in response
|
|
1598
|
+
*/
|
|
1599
|
+
interface OAuthResponse {
|
|
1600
|
+
/**
|
|
1601
|
+
* OAuth provider
|
|
1602
|
+
*/
|
|
1603
|
+
provider: OAuthProvider;
|
|
1604
|
+
/**
|
|
1605
|
+
* Auth URL to redirect to
|
|
1606
|
+
*/
|
|
1607
|
+
url: string;
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
/**
|
|
1611
|
+
* VAIF Auth Client
|
|
1612
|
+
*
|
|
1613
|
+
* Authentication and user management for VAIF Studio projects
|
|
1614
|
+
*/
|
|
1615
|
+
|
|
1616
|
+
/**
|
|
1617
|
+
* Auth client for VAIF Studio
|
|
1618
|
+
*/
|
|
1619
|
+
declare class VaifAuth {
|
|
1620
|
+
private client;
|
|
1621
|
+
private currentSession;
|
|
1622
|
+
private currentUser;
|
|
1623
|
+
private stateChangeCallbacks;
|
|
1624
|
+
private refreshTimeout;
|
|
1625
|
+
constructor(client: VaifClient);
|
|
1626
|
+
/**
|
|
1627
|
+
* Get current session
|
|
1628
|
+
*/
|
|
1629
|
+
getSession(): Promise<{
|
|
1630
|
+
data: {
|
|
1631
|
+
session: Session | null;
|
|
1632
|
+
};
|
|
1633
|
+
error: AuthError | null;
|
|
1634
|
+
}>;
|
|
1635
|
+
/**
|
|
1636
|
+
* Get current user synchronously from cache
|
|
1637
|
+
*/
|
|
1638
|
+
get user(): User | null;
|
|
1639
|
+
/**
|
|
1640
|
+
* Get current user (fetches fresh data)
|
|
1641
|
+
*/
|
|
1642
|
+
getUser(): Promise<{
|
|
1643
|
+
data: {
|
|
1644
|
+
user: User | null;
|
|
1645
|
+
};
|
|
1646
|
+
error: AuthError | null;
|
|
1647
|
+
}>;
|
|
1648
|
+
/**
|
|
1649
|
+
* Sign up with email and password
|
|
1650
|
+
*/
|
|
1651
|
+
signUp(options: SignUpOptions): Promise<AuthResponse>;
|
|
1652
|
+
/**
|
|
1653
|
+
* Sign in with email and password
|
|
1654
|
+
*/
|
|
1655
|
+
signInWithPassword(options: SignInOptions): Promise<AuthResponse>;
|
|
1656
|
+
/**
|
|
1657
|
+
* Sign in with OAuth provider
|
|
1658
|
+
*/
|
|
1659
|
+
signInWithOAuth(options: OAuthSignInOptions): Promise<{
|
|
1660
|
+
data: OAuthResponse;
|
|
1661
|
+
error: null;
|
|
1662
|
+
}>;
|
|
1663
|
+
/**
|
|
1664
|
+
* Sign in with magic link (passwordless)
|
|
1665
|
+
*/
|
|
1666
|
+
signInWithOtp(options: {
|
|
1667
|
+
email?: string;
|
|
1668
|
+
phone?: string;
|
|
1669
|
+
createUser?: boolean;
|
|
1670
|
+
redirectTo?: string;
|
|
1671
|
+
}): Promise<{
|
|
1672
|
+
data: {
|
|
1673
|
+
messageId?: string;
|
|
1674
|
+
};
|
|
1675
|
+
error: AuthError | null;
|
|
1676
|
+
}>;
|
|
1677
|
+
/**
|
|
1678
|
+
* Verify OTP code
|
|
1679
|
+
*/
|
|
1680
|
+
verifyOtp(options: {
|
|
1681
|
+
email?: string;
|
|
1682
|
+
phone?: string;
|
|
1683
|
+
token: string;
|
|
1684
|
+
type: 'sms' | 'email' | 'magiclink';
|
|
1685
|
+
}): Promise<AuthResponse>;
|
|
1686
|
+
/**
|
|
1687
|
+
* Sign out
|
|
1688
|
+
*/
|
|
1689
|
+
signOut(options?: {
|
|
1690
|
+
scope?: 'global' | 'local' | 'others';
|
|
1691
|
+
}): Promise<{
|
|
1692
|
+
error: AuthError | null;
|
|
1693
|
+
}>;
|
|
1694
|
+
/**
|
|
1695
|
+
* Reset password
|
|
1696
|
+
*/
|
|
1697
|
+
resetPasswordForEmail(options: ResetPasswordOptions): Promise<{
|
|
1698
|
+
error: AuthError | null;
|
|
1699
|
+
}>;
|
|
1700
|
+
/**
|
|
1701
|
+
* Update user
|
|
1702
|
+
*/
|
|
1703
|
+
updateUser(options: UpdateUserOptions): Promise<{
|
|
1704
|
+
data: {
|
|
1705
|
+
user: User | null;
|
|
1706
|
+
};
|
|
1707
|
+
error: AuthError | null;
|
|
1708
|
+
}>;
|
|
1709
|
+
/**
|
|
1710
|
+
* Refresh session
|
|
1711
|
+
*/
|
|
1712
|
+
refreshSession(): Promise<AuthResponse>;
|
|
1713
|
+
/**
|
|
1714
|
+
* Set session from URL (after OAuth redirect)
|
|
1715
|
+
*/
|
|
1716
|
+
setSessionFromUrl(): Promise<AuthResponse>;
|
|
1717
|
+
/**
|
|
1718
|
+
* Subscribe to auth state changes
|
|
1719
|
+
*/
|
|
1720
|
+
onAuthStateChange(callback: AuthStateChangeCallback): {
|
|
1721
|
+
data: {
|
|
1722
|
+
subscription: {
|
|
1723
|
+
unsubscribe: () => void;
|
|
1724
|
+
};
|
|
1725
|
+
};
|
|
1726
|
+
};
|
|
1727
|
+
/**
|
|
1728
|
+
* Exchange code for session (PKCE flow)
|
|
1729
|
+
*/
|
|
1730
|
+
exchangeCodeForSession(code: string): Promise<AuthResponse>;
|
|
1731
|
+
/**
|
|
1732
|
+
* Resend confirmation email
|
|
1733
|
+
*/
|
|
1734
|
+
resend(options: {
|
|
1735
|
+
type: 'signup' | 'email_change';
|
|
1736
|
+
email: string;
|
|
1737
|
+
redirectTo?: string;
|
|
1738
|
+
}): Promise<{
|
|
1739
|
+
error: AuthError | null;
|
|
1740
|
+
}>;
|
|
1741
|
+
private setSession;
|
|
1742
|
+
private clearSession;
|
|
1743
|
+
private restoreSession;
|
|
1744
|
+
private scheduleRefresh;
|
|
1745
|
+
private notifyStateChange;
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
/**
|
|
1749
|
+
* AI types for VAIF Studio
|
|
1750
|
+
*/
|
|
1751
|
+
/**
|
|
1752
|
+
* Copilot model tiers
|
|
1753
|
+
*/
|
|
1754
|
+
type CopilotModel = 'copilot-quick' | 'copilot-balanced' | 'copilot-power' | 'copilot-enterprise';
|
|
1755
|
+
/**
|
|
1756
|
+
* AI generation options
|
|
1757
|
+
*/
|
|
1758
|
+
interface AIGenerateOptions {
|
|
1759
|
+
/**
|
|
1760
|
+
* Copilot model tier to use
|
|
1761
|
+
*/
|
|
1762
|
+
model?: CopilotModel;
|
|
1763
|
+
/**
|
|
1764
|
+
* Temperature (0-1)
|
|
1765
|
+
*/
|
|
1766
|
+
temperature?: number;
|
|
1767
|
+
/**
|
|
1768
|
+
* Maximum tokens
|
|
1769
|
+
*/
|
|
1770
|
+
maxTokens?: number;
|
|
1771
|
+
/**
|
|
1772
|
+
* Stream response
|
|
1773
|
+
*/
|
|
1774
|
+
stream?: boolean;
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* Schema generation request
|
|
1778
|
+
*/
|
|
1779
|
+
interface SchemaGenerationRequest {
|
|
1780
|
+
/**
|
|
1781
|
+
* Natural language description
|
|
1782
|
+
*/
|
|
1783
|
+
prompt: string;
|
|
1784
|
+
/**
|
|
1785
|
+
* Target schema format
|
|
1786
|
+
*/
|
|
1787
|
+
format?: 'drizzle' | 'prisma' | 'sql' | 'json';
|
|
1788
|
+
/**
|
|
1789
|
+
* Include relationships
|
|
1790
|
+
*/
|
|
1791
|
+
includeRelations?: boolean;
|
|
1792
|
+
/**
|
|
1793
|
+
* Include indexes
|
|
1794
|
+
*/
|
|
1795
|
+
includeIndexes?: boolean;
|
|
1796
|
+
/**
|
|
1797
|
+
* Database type
|
|
1798
|
+
*/
|
|
1799
|
+
database?: 'postgresql' | 'mysql' | 'sqlite';
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Schema generation result
|
|
1803
|
+
*/
|
|
1804
|
+
interface SchemaGenerationResult {
|
|
1805
|
+
/**
|
|
1806
|
+
* Generated schema code
|
|
1807
|
+
*/
|
|
1808
|
+
schema: string;
|
|
1809
|
+
/**
|
|
1810
|
+
* Schema format
|
|
1811
|
+
*/
|
|
1812
|
+
format: string;
|
|
1813
|
+
/**
|
|
1814
|
+
* Extracted tables
|
|
1815
|
+
*/
|
|
1816
|
+
tables: GeneratedTable[];
|
|
1817
|
+
/**
|
|
1818
|
+
* Generated TypeScript types
|
|
1819
|
+
*/
|
|
1820
|
+
types?: string;
|
|
1821
|
+
/**
|
|
1822
|
+
* Explanation of the schema
|
|
1823
|
+
*/
|
|
1824
|
+
explanation?: string;
|
|
1825
|
+
/**
|
|
1826
|
+
* Credits used
|
|
1827
|
+
*/
|
|
1828
|
+
creditsUsed: number;
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* Generated table information
|
|
1832
|
+
*/
|
|
1833
|
+
interface GeneratedTable {
|
|
1834
|
+
/**
|
|
1835
|
+
* Table name
|
|
1836
|
+
*/
|
|
1837
|
+
name: string;
|
|
1838
|
+
/**
|
|
1839
|
+
* Table columns
|
|
1840
|
+
*/
|
|
1841
|
+
columns: GeneratedColumn[];
|
|
1842
|
+
/**
|
|
1843
|
+
* Table indexes
|
|
1844
|
+
*/
|
|
1845
|
+
indexes?: GeneratedIndex[];
|
|
1846
|
+
/**
|
|
1847
|
+
* Foreign key relationships
|
|
1848
|
+
*/
|
|
1849
|
+
relations?: GeneratedRelation[];
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Generated column
|
|
1853
|
+
*/
|
|
1854
|
+
interface GeneratedColumn {
|
|
1855
|
+
/**
|
|
1856
|
+
* Column name
|
|
1857
|
+
*/
|
|
1858
|
+
name: string;
|
|
1859
|
+
/**
|
|
1860
|
+
* Column type
|
|
1861
|
+
*/
|
|
1862
|
+
type: string;
|
|
1863
|
+
/**
|
|
1864
|
+
* Is nullable
|
|
1865
|
+
*/
|
|
1866
|
+
nullable: boolean;
|
|
1867
|
+
/**
|
|
1868
|
+
* Is primary key
|
|
1869
|
+
*/
|
|
1870
|
+
primaryKey: boolean;
|
|
1871
|
+
/**
|
|
1872
|
+
* Is unique
|
|
1873
|
+
*/
|
|
1874
|
+
unique: boolean;
|
|
1875
|
+
/**
|
|
1876
|
+
* Default value
|
|
1877
|
+
*/
|
|
1878
|
+
defaultValue?: string;
|
|
1879
|
+
}
|
|
1880
|
+
/**
|
|
1881
|
+
* Generated index
|
|
1882
|
+
*/
|
|
1883
|
+
interface GeneratedIndex {
|
|
1884
|
+
/**
|
|
1885
|
+
* Index name
|
|
1886
|
+
*/
|
|
1887
|
+
name: string;
|
|
1888
|
+
/**
|
|
1889
|
+
* Index columns
|
|
1890
|
+
*/
|
|
1891
|
+
columns: string[];
|
|
1892
|
+
/**
|
|
1893
|
+
* Is unique index
|
|
1894
|
+
*/
|
|
1895
|
+
unique: boolean;
|
|
1896
|
+
}
|
|
1897
|
+
/**
|
|
1898
|
+
* Generated relation
|
|
1899
|
+
*/
|
|
1900
|
+
interface GeneratedRelation {
|
|
1901
|
+
/**
|
|
1902
|
+
* Relation name
|
|
1903
|
+
*/
|
|
1904
|
+
name: string;
|
|
1905
|
+
/**
|
|
1906
|
+
* Target table
|
|
1907
|
+
*/
|
|
1908
|
+
targetTable: string;
|
|
1909
|
+
/**
|
|
1910
|
+
* Source columns
|
|
1911
|
+
*/
|
|
1912
|
+
sourceColumns: string[];
|
|
1913
|
+
/**
|
|
1914
|
+
* Target columns
|
|
1915
|
+
*/
|
|
1916
|
+
targetColumns: string[];
|
|
1917
|
+
/**
|
|
1918
|
+
* Relation type
|
|
1919
|
+
*/
|
|
1920
|
+
type: 'one-to-one' | 'one-to-many' | 'many-to-many';
|
|
1921
|
+
}
|
|
1922
|
+
/**
|
|
1923
|
+
* Function generation request
|
|
1924
|
+
*/
|
|
1925
|
+
interface FunctionGenerationRequest {
|
|
1926
|
+
/**
|
|
1927
|
+
* Natural language description
|
|
1928
|
+
*/
|
|
1929
|
+
prompt: string;
|
|
1930
|
+
/**
|
|
1931
|
+
* Function name
|
|
1932
|
+
*/
|
|
1933
|
+
name?: string;
|
|
1934
|
+
/**
|
|
1935
|
+
* Runtime environment
|
|
1936
|
+
*/
|
|
1937
|
+
runtime?: 'edge' | 'node';
|
|
1938
|
+
/**
|
|
1939
|
+
* Include types
|
|
1940
|
+
*/
|
|
1941
|
+
includeTypes?: boolean;
|
|
1942
|
+
}
|
|
1943
|
+
/**
|
|
1944
|
+
* Function generation result
|
|
1945
|
+
*/
|
|
1946
|
+
interface FunctionGenerationResult {
|
|
1947
|
+
/**
|
|
1948
|
+
* Generated function code
|
|
1949
|
+
*/
|
|
1950
|
+
code: string;
|
|
1951
|
+
/**
|
|
1952
|
+
* Function name
|
|
1953
|
+
*/
|
|
1954
|
+
name: string;
|
|
1955
|
+
/**
|
|
1956
|
+
* TypeScript types
|
|
1957
|
+
*/
|
|
1958
|
+
types?: string;
|
|
1959
|
+
/**
|
|
1960
|
+
* Input schema
|
|
1961
|
+
*/
|
|
1962
|
+
inputSchema?: Record<string, unknown>;
|
|
1963
|
+
/**
|
|
1964
|
+
* Output schema
|
|
1965
|
+
*/
|
|
1966
|
+
outputSchema?: Record<string, unknown>;
|
|
1967
|
+
/**
|
|
1968
|
+
* Explanation
|
|
1969
|
+
*/
|
|
1970
|
+
explanation?: string;
|
|
1971
|
+
/**
|
|
1972
|
+
* Credits used
|
|
1973
|
+
*/
|
|
1974
|
+
creditsUsed: number;
|
|
1975
|
+
}
|
|
1976
|
+
/**
|
|
1977
|
+
* Endpoint generation request
|
|
1978
|
+
*/
|
|
1979
|
+
interface EndpointGenerationRequest {
|
|
1980
|
+
/**
|
|
1981
|
+
* Natural language description
|
|
1982
|
+
*/
|
|
1983
|
+
prompt: string;
|
|
1984
|
+
/**
|
|
1985
|
+
* HTTP method
|
|
1986
|
+
*/
|
|
1987
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
1988
|
+
/**
|
|
1989
|
+
* Endpoint path
|
|
1990
|
+
*/
|
|
1991
|
+
path?: string;
|
|
1992
|
+
/**
|
|
1993
|
+
* Include authentication
|
|
1994
|
+
*/
|
|
1995
|
+
requiresAuth?: boolean;
|
|
1996
|
+
/**
|
|
1997
|
+
* Include validation
|
|
1998
|
+
*/
|
|
1999
|
+
includeValidation?: boolean;
|
|
2000
|
+
}
|
|
2001
|
+
/**
|
|
2002
|
+
* Endpoint generation result
|
|
2003
|
+
*/
|
|
2004
|
+
interface EndpointGenerationResult {
|
|
2005
|
+
/**
|
|
2006
|
+
* Generated endpoint code
|
|
2007
|
+
*/
|
|
2008
|
+
code: string;
|
|
2009
|
+
/**
|
|
2010
|
+
* HTTP method
|
|
2011
|
+
*/
|
|
2012
|
+
method: string;
|
|
2013
|
+
/**
|
|
2014
|
+
* Endpoint path
|
|
2015
|
+
*/
|
|
2016
|
+
path: string;
|
|
2017
|
+
/**
|
|
2018
|
+
* Request schema
|
|
2019
|
+
*/
|
|
2020
|
+
requestSchema?: Record<string, unknown>;
|
|
2021
|
+
/**
|
|
2022
|
+
* Response schema
|
|
2023
|
+
*/
|
|
2024
|
+
responseSchema?: Record<string, unknown>;
|
|
2025
|
+
/**
|
|
2026
|
+
* OpenAPI spec
|
|
2027
|
+
*/
|
|
2028
|
+
openApiSpec?: Record<string, unknown>;
|
|
2029
|
+
/**
|
|
2030
|
+
* Explanation
|
|
2031
|
+
*/
|
|
2032
|
+
explanation?: string;
|
|
2033
|
+
/**
|
|
2034
|
+
* Credits used
|
|
2035
|
+
*/
|
|
2036
|
+
creditsUsed: number;
|
|
2037
|
+
}
|
|
2038
|
+
/**
|
|
2039
|
+
* AI chat message
|
|
2040
|
+
*/
|
|
2041
|
+
interface AIChatMessage {
|
|
2042
|
+
/**
|
|
2043
|
+
* Message role
|
|
2044
|
+
*/
|
|
2045
|
+
role: 'user' | 'assistant' | 'system';
|
|
2046
|
+
/**
|
|
2047
|
+
* Message content
|
|
2048
|
+
*/
|
|
2049
|
+
content: string;
|
|
2050
|
+
}
|
|
2051
|
+
/**
|
|
2052
|
+
* AI chat request
|
|
2053
|
+
*/
|
|
2054
|
+
interface AIChatRequest {
|
|
2055
|
+
/**
|
|
2056
|
+
* Chat messages
|
|
2057
|
+
*/
|
|
2058
|
+
messages: AIChatMessage[];
|
|
2059
|
+
/**
|
|
2060
|
+
* Context about the project
|
|
2061
|
+
*/
|
|
2062
|
+
context?: {
|
|
2063
|
+
/**
|
|
2064
|
+
* Schema context
|
|
2065
|
+
*/
|
|
2066
|
+
schema?: string;
|
|
2067
|
+
/**
|
|
2068
|
+
* Functions context
|
|
2069
|
+
*/
|
|
2070
|
+
functions?: string[];
|
|
2071
|
+
/**
|
|
2072
|
+
* Endpoints context
|
|
2073
|
+
*/
|
|
2074
|
+
endpoints?: string[];
|
|
2075
|
+
};
|
|
2076
|
+
}
|
|
2077
|
+
/**
|
|
2078
|
+
* AI chat response
|
|
2079
|
+
*/
|
|
2080
|
+
interface AIChatResponse {
|
|
2081
|
+
/**
|
|
2082
|
+
* Response message
|
|
2083
|
+
*/
|
|
2084
|
+
message: AIChatMessage;
|
|
2085
|
+
/**
|
|
2086
|
+
* Suggested actions
|
|
2087
|
+
*/
|
|
2088
|
+
suggestions?: AISuggestion[];
|
|
2089
|
+
/**
|
|
2090
|
+
* Credits used
|
|
2091
|
+
*/
|
|
2092
|
+
creditsUsed: number;
|
|
2093
|
+
}
|
|
2094
|
+
/**
|
|
2095
|
+
* AI suggestion
|
|
2096
|
+
*/
|
|
2097
|
+
interface AISuggestion {
|
|
2098
|
+
/**
|
|
2099
|
+
* Suggestion type
|
|
2100
|
+
*/
|
|
2101
|
+
type: 'schema' | 'function' | 'endpoint' | 'query';
|
|
2102
|
+
/**
|
|
2103
|
+
* Suggestion title
|
|
2104
|
+
*/
|
|
2105
|
+
title: string;
|
|
2106
|
+
/**
|
|
2107
|
+
* Suggestion description
|
|
2108
|
+
*/
|
|
2109
|
+
description: string;
|
|
2110
|
+
/**
|
|
2111
|
+
* Prompt to execute suggestion
|
|
2112
|
+
*/
|
|
2113
|
+
prompt: string;
|
|
2114
|
+
}
|
|
2115
|
+
/**
|
|
2116
|
+
* AI credits info
|
|
2117
|
+
*/
|
|
2118
|
+
interface AICreditsInfo {
|
|
2119
|
+
/**
|
|
2120
|
+
* Current credits balance
|
|
2121
|
+
*/
|
|
2122
|
+
balance: number;
|
|
2123
|
+
/**
|
|
2124
|
+
* Monthly allocation
|
|
2125
|
+
*/
|
|
2126
|
+
monthlyAllocation: number;
|
|
2127
|
+
/**
|
|
2128
|
+
* Credits used this month
|
|
2129
|
+
*/
|
|
2130
|
+
usedThisMonth: number;
|
|
2131
|
+
/**
|
|
2132
|
+
* Reset date
|
|
2133
|
+
*/
|
|
2134
|
+
resetDate: string;
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
/**
|
|
2138
|
+
* VAIF AI Client
|
|
2139
|
+
*
|
|
2140
|
+
* AI-powered code generation for schemas, functions, and endpoints
|
|
2141
|
+
*/
|
|
2142
|
+
|
|
2143
|
+
/**
|
|
2144
|
+
* AI error
|
|
2145
|
+
*/
|
|
2146
|
+
interface AIError {
|
|
2147
|
+
message: string;
|
|
2148
|
+
code?: string;
|
|
2149
|
+
status?: number;
|
|
2150
|
+
}
|
|
2151
|
+
/**
|
|
2152
|
+
* AI client for VAIF Studio
|
|
2153
|
+
*/
|
|
2154
|
+
declare class VaifAI {
|
|
2155
|
+
private client;
|
|
2156
|
+
constructor(client: VaifClient);
|
|
2157
|
+
/**
|
|
2158
|
+
* Generate database schema from natural language
|
|
2159
|
+
*
|
|
2160
|
+
* @example
|
|
2161
|
+
* ```typescript
|
|
2162
|
+
* const { data, error } = await vaif.ai.generateSchema({
|
|
2163
|
+
* prompt: 'Create a blog with posts, authors, and comments',
|
|
2164
|
+
* format: 'drizzle',
|
|
2165
|
+
* includeRelations: true
|
|
2166
|
+
* });
|
|
2167
|
+
* ```
|
|
2168
|
+
*/
|
|
2169
|
+
generateSchema(request: SchemaGenerationRequest, options?: AIGenerateOptions): Promise<{
|
|
2170
|
+
data: SchemaGenerationResult | null;
|
|
2171
|
+
error: AIError | null;
|
|
2172
|
+
}>;
|
|
2173
|
+
/**
|
|
2174
|
+
* Generate edge function from natural language
|
|
2175
|
+
*
|
|
2176
|
+
* @example
|
|
2177
|
+
* ```typescript
|
|
2178
|
+
* const { data, error } = await vaif.ai.generateFunction({
|
|
2179
|
+
* prompt: 'Create a function that sends welcome emails to new users',
|
|
2180
|
+
* name: 'send-welcome-email',
|
|
2181
|
+
* runtime: 'edge'
|
|
2182
|
+
* });
|
|
2183
|
+
* ```
|
|
2184
|
+
*/
|
|
2185
|
+
generateFunction(request: FunctionGenerationRequest, options?: AIGenerateOptions): Promise<{
|
|
2186
|
+
data: FunctionGenerationResult | null;
|
|
2187
|
+
error: AIError | null;
|
|
2188
|
+
}>;
|
|
2189
|
+
/**
|
|
2190
|
+
* Generate API endpoint from natural language
|
|
2191
|
+
*
|
|
2192
|
+
* @example
|
|
2193
|
+
* ```typescript
|
|
2194
|
+
* const { data, error } = await vaif.ai.generateEndpoint({
|
|
2195
|
+
* prompt: 'Create an endpoint to get user profile with their recent posts',
|
|
2196
|
+
* method: 'GET',
|
|
2197
|
+
* path: '/users/:id/profile',
|
|
2198
|
+
* requiresAuth: true
|
|
2199
|
+
* });
|
|
2200
|
+
* ```
|
|
2201
|
+
*/
|
|
2202
|
+
generateEndpoint(request: EndpointGenerationRequest, options?: AIGenerateOptions): Promise<{
|
|
2203
|
+
data: EndpointGenerationResult | null;
|
|
2204
|
+
error: AIError | null;
|
|
2205
|
+
}>;
|
|
2206
|
+
/**
|
|
2207
|
+
* Chat with AI assistant for project help
|
|
2208
|
+
*
|
|
2209
|
+
* @example
|
|
2210
|
+
* ```typescript
|
|
2211
|
+
* const { data, error } = await vaif.ai.chat({
|
|
2212
|
+
* messages: [
|
|
2213
|
+
* { role: 'user', content: 'How do I add pagination to my posts query?' }
|
|
2214
|
+
* ],
|
|
2215
|
+
* context: {
|
|
2216
|
+
* schema: mySchemaString
|
|
2217
|
+
* }
|
|
2218
|
+
* });
|
|
2219
|
+
* ```
|
|
2220
|
+
*/
|
|
2221
|
+
chat(request: AIChatRequest, options?: AIGenerateOptions): Promise<{
|
|
2222
|
+
data: AIChatResponse | null;
|
|
2223
|
+
error: AIError | null;
|
|
2224
|
+
}>;
|
|
2225
|
+
/**
|
|
2226
|
+
* Stream chat response
|
|
2227
|
+
*
|
|
2228
|
+
* @example
|
|
2229
|
+
* ```typescript
|
|
2230
|
+
* for await (const chunk of vaif.ai.chatStream({
|
|
2231
|
+
* messages: [{ role: 'user', content: 'Explain this schema' }]
|
|
2232
|
+
* })) {
|
|
2233
|
+
* process.stdout.write(chunk);
|
|
2234
|
+
* }
|
|
2235
|
+
* ```
|
|
2236
|
+
*/
|
|
2237
|
+
chatStream(request: AIChatRequest, options?: AIGenerateOptions): AsyncGenerator<string, void, unknown>;
|
|
2238
|
+
/**
|
|
2239
|
+
* Get AI credits information
|
|
2240
|
+
*
|
|
2241
|
+
* @example
|
|
2242
|
+
* ```typescript
|
|
2243
|
+
* const { data, error } = await vaif.ai.getCredits();
|
|
2244
|
+
* console.log(`Balance: ${data.balance} credits`);
|
|
2245
|
+
* ```
|
|
2246
|
+
*/
|
|
2247
|
+
getCredits(): Promise<{
|
|
2248
|
+
data: AICreditsInfo | null;
|
|
2249
|
+
error: AIError | null;
|
|
2250
|
+
}>;
|
|
2251
|
+
/**
|
|
2252
|
+
* Explain code or schema
|
|
2253
|
+
*/
|
|
2254
|
+
explain(code: string, options?: {
|
|
2255
|
+
language?: string;
|
|
2256
|
+
context?: string;
|
|
2257
|
+
} & AIGenerateOptions): Promise<{
|
|
2258
|
+
data: {
|
|
2259
|
+
explanation: string;
|
|
2260
|
+
creditsUsed: number;
|
|
2261
|
+
} | null;
|
|
2262
|
+
error: AIError | null;
|
|
2263
|
+
}>;
|
|
2264
|
+
/**
|
|
2265
|
+
* Review code for issues and improvements
|
|
2266
|
+
*/
|
|
2267
|
+
review(code: string, options?: {
|
|
2268
|
+
language?: string;
|
|
2269
|
+
focus?: ('security' | 'performance' | 'style')[];
|
|
2270
|
+
} & AIGenerateOptions): Promise<{
|
|
2271
|
+
data: {
|
|
2272
|
+
issues: Array<{
|
|
2273
|
+
severity: 'error' | 'warning' | 'info';
|
|
2274
|
+
message: string;
|
|
2275
|
+
line?: number;
|
|
2276
|
+
suggestion?: string;
|
|
2277
|
+
}>;
|
|
2278
|
+
summary: string;
|
|
2279
|
+
creditsUsed: number;
|
|
2280
|
+
} | null;
|
|
2281
|
+
error: AIError | null;
|
|
2282
|
+
}>;
|
|
2283
|
+
/**
|
|
2284
|
+
* Generate TypeScript types from schema
|
|
2285
|
+
*/
|
|
2286
|
+
generateTypes(schema: string, options?: {
|
|
2287
|
+
format?: 'typescript' | 'zod' | 'io-ts';
|
|
2288
|
+
} & AIGenerateOptions): Promise<{
|
|
2289
|
+
data: {
|
|
2290
|
+
types: string;
|
|
2291
|
+
creditsUsed: number;
|
|
2292
|
+
} | null;
|
|
2293
|
+
error: AIError | null;
|
|
2294
|
+
}>;
|
|
2295
|
+
/**
|
|
2296
|
+
* Generate SQL migration from schema diff
|
|
2297
|
+
*/
|
|
2298
|
+
generateMigration(options: {
|
|
2299
|
+
currentSchema: string;
|
|
2300
|
+
targetSchema: string;
|
|
2301
|
+
database?: 'postgresql' | 'mysql' | 'sqlite';
|
|
2302
|
+
} & AIGenerateOptions): Promise<{
|
|
2303
|
+
data: {
|
|
2304
|
+
upMigration: string;
|
|
2305
|
+
downMigration: string;
|
|
2306
|
+
changes: string[];
|
|
2307
|
+
creditsUsed: number;
|
|
2308
|
+
} | null;
|
|
2309
|
+
error: AIError | null;
|
|
2310
|
+
}>;
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
/**
|
|
2314
|
+
* VAIF Type Generator
|
|
2315
|
+
*
|
|
2316
|
+
* Generate TypeScript types from database schema.
|
|
2317
|
+
*/
|
|
2318
|
+
|
|
2319
|
+
interface ColumnSchema {
|
|
2320
|
+
name: string;
|
|
2321
|
+
type: string;
|
|
2322
|
+
nullable: boolean;
|
|
2323
|
+
defaultValue?: string;
|
|
2324
|
+
isPrimaryKey: boolean;
|
|
2325
|
+
isForeignKey: boolean;
|
|
2326
|
+
foreignTable?: string;
|
|
2327
|
+
foreignColumn?: string;
|
|
2328
|
+
isUnique: boolean;
|
|
2329
|
+
comment?: string;
|
|
2330
|
+
}
|
|
2331
|
+
interface TableSchema {
|
|
2332
|
+
name: string;
|
|
2333
|
+
schema: string;
|
|
2334
|
+
columns: ColumnSchema[];
|
|
2335
|
+
primaryKey: string[];
|
|
2336
|
+
foreignKeys: ForeignKeySchema[];
|
|
2337
|
+
indexes: IndexSchema[];
|
|
2338
|
+
comment?: string;
|
|
2339
|
+
}
|
|
2340
|
+
interface ForeignKeySchema {
|
|
2341
|
+
name: string;
|
|
2342
|
+
columns: string[];
|
|
2343
|
+
foreignTable: string;
|
|
2344
|
+
foreignColumns: string[];
|
|
2345
|
+
onDelete: string;
|
|
2346
|
+
onUpdate: string;
|
|
2347
|
+
}
|
|
2348
|
+
interface IndexSchema {
|
|
2349
|
+
name: string;
|
|
2350
|
+
columns: string[];
|
|
2351
|
+
unique: boolean;
|
|
2352
|
+
type: string;
|
|
2353
|
+
}
|
|
2354
|
+
interface DatabaseSchema {
|
|
2355
|
+
tables: TableSchema[];
|
|
2356
|
+
enums: EnumSchema[];
|
|
2357
|
+
views: ViewSchema[];
|
|
2358
|
+
}
|
|
2359
|
+
interface EnumSchema {
|
|
2360
|
+
name: string;
|
|
2361
|
+
schema: string;
|
|
2362
|
+
values: string[];
|
|
2363
|
+
}
|
|
2364
|
+
interface ViewSchema {
|
|
2365
|
+
name: string;
|
|
2366
|
+
schema: string;
|
|
2367
|
+
columns: ColumnSchema[];
|
|
2368
|
+
}
|
|
2369
|
+
interface TypeGenOptions {
|
|
2370
|
+
/** Include Row types (for SELECT) */
|
|
2371
|
+
includeRow?: boolean;
|
|
2372
|
+
/** Include Insert types (for INSERT) */
|
|
2373
|
+
includeInsert?: boolean;
|
|
2374
|
+
/** Include Update types (for UPDATE) */
|
|
2375
|
+
includeUpdate?: boolean;
|
|
2376
|
+
/** Include relationships */
|
|
2377
|
+
includeRelationships?: boolean;
|
|
2378
|
+
/** Schema to generate types for */
|
|
2379
|
+
schema?: string;
|
|
2380
|
+
/** Tables to include (all if empty) */
|
|
2381
|
+
tables?: string[];
|
|
2382
|
+
/** Tables to exclude */
|
|
2383
|
+
excludeTables?: string[];
|
|
2384
|
+
/** Add JSDoc comments */
|
|
2385
|
+
includeComments?: boolean;
|
|
2386
|
+
/** Export format */
|
|
2387
|
+
exportFormat?: 'named' | 'default' | 'namespace';
|
|
2388
|
+
/** Namespace name (if exportFormat is 'namespace') */
|
|
2389
|
+
namespace?: string;
|
|
2390
|
+
}
|
|
2391
|
+
/**
|
|
2392
|
+
* VAIF Type Generator class
|
|
2393
|
+
*/
|
|
2394
|
+
declare class VaifTypeGen {
|
|
2395
|
+
private client;
|
|
2396
|
+
constructor(client: VaifClient);
|
|
2397
|
+
/**
|
|
2398
|
+
* Fetch database schema from the API.
|
|
2399
|
+
*/
|
|
2400
|
+
fetchSchema(schema?: string): Promise<DatabaseSchema>;
|
|
2401
|
+
/**
|
|
2402
|
+
* Generate TypeScript types from schema.
|
|
2403
|
+
*/
|
|
2404
|
+
generate(options?: TypeGenOptions): Promise<string>;
|
|
2405
|
+
/**
|
|
2406
|
+
* Generate TypeScript from schema JSON directly.
|
|
2407
|
+
*/
|
|
2408
|
+
generateFromSchema(schema: DatabaseSchema, options?: TypeGenOptions): string;
|
|
2409
|
+
private generateEnum;
|
|
2410
|
+
private generateTableTypes;
|
|
2411
|
+
private generateViewTypes;
|
|
2412
|
+
private pgTypeToTs;
|
|
2413
|
+
private toPascalCase;
|
|
2414
|
+
private indent;
|
|
2415
|
+
}
|
|
2416
|
+
/**
|
|
2417
|
+
* Create a type generator instance.
|
|
2418
|
+
*/
|
|
2419
|
+
declare function createTypeGen(client: VaifClient): VaifTypeGen;
|
|
2420
|
+
|
|
2421
|
+
/**
|
|
2422
|
+
* VAIF Studio Client
|
|
2423
|
+
*
|
|
2424
|
+
* Main entry point for the VAIF SDK
|
|
2425
|
+
*/
|
|
2426
|
+
|
|
2427
|
+
/**
|
|
2428
|
+
* Create a VAIF Studio client instance
|
|
2429
|
+
*
|
|
2430
|
+
* @example
|
|
2431
|
+
* ```typescript
|
|
2432
|
+
* const vaif = createClient({
|
|
2433
|
+
* projectId: 'your-project-id',
|
|
2434
|
+
* apiKey: 'your-api-key',
|
|
2435
|
+
* });
|
|
2436
|
+
* ```
|
|
2437
|
+
*/
|
|
2438
|
+
declare function createClient(options: VaifClientOptions): VaifClient;
|
|
2439
|
+
/**
|
|
2440
|
+
* VAIF Studio Client
|
|
2441
|
+
*
|
|
2442
|
+
* Provides access to all VAIF services:
|
|
2443
|
+
* - Database (db)
|
|
2444
|
+
* - Realtime subscriptions (realtime)
|
|
2445
|
+
* - Storage (storage)
|
|
2446
|
+
* - Edge Functions (functions)
|
|
2447
|
+
* - Authentication (auth)
|
|
2448
|
+
* - AI Generation (ai)
|
|
2449
|
+
*/
|
|
2450
|
+
declare class VaifClient {
|
|
2451
|
+
private config;
|
|
2452
|
+
private accessToken;
|
|
2453
|
+
/**
|
|
2454
|
+
* Database client for CRUD operations
|
|
2455
|
+
*/
|
|
2456
|
+
readonly db: VaifDatabase;
|
|
2457
|
+
/**
|
|
2458
|
+
* Realtime client for subscriptions
|
|
2459
|
+
*/
|
|
2460
|
+
readonly realtime: VaifRealtime;
|
|
2461
|
+
/**
|
|
2462
|
+
* Storage client for file operations
|
|
2463
|
+
*/
|
|
2464
|
+
readonly storage: VaifStorage;
|
|
2465
|
+
/**
|
|
2466
|
+
* Functions client for edge function invocation
|
|
2467
|
+
*/
|
|
2468
|
+
readonly functions: VaifFunctions;
|
|
2469
|
+
/**
|
|
2470
|
+
* Auth client for authentication
|
|
2471
|
+
*/
|
|
2472
|
+
readonly auth: VaifAuth;
|
|
2473
|
+
/**
|
|
2474
|
+
* AI client for generation features
|
|
2475
|
+
*/
|
|
2476
|
+
readonly ai: VaifAI;
|
|
2477
|
+
/**
|
|
2478
|
+
* Type generator for generating TypeScript types from database schema
|
|
2479
|
+
*/
|
|
2480
|
+
readonly typegen: VaifTypeGen;
|
|
2481
|
+
constructor(options: VaifClientOptions);
|
|
2482
|
+
/**
|
|
2483
|
+
* Get current configuration
|
|
2484
|
+
*/
|
|
2485
|
+
getConfig(): VaifConfig;
|
|
2486
|
+
/**
|
|
2487
|
+
* Set access token for authenticated requests
|
|
2488
|
+
*/
|
|
2489
|
+
setAccessToken(token: string | null): void;
|
|
2490
|
+
/**
|
|
2491
|
+
* Get current access token
|
|
2492
|
+
*/
|
|
2493
|
+
getAccessToken(): string | null;
|
|
2494
|
+
/**
|
|
2495
|
+
* Make an authenticated API request
|
|
2496
|
+
*/
|
|
2497
|
+
request<T = unknown>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
2498
|
+
/**
|
|
2499
|
+
* Restore session from storage
|
|
2500
|
+
*/
|
|
2501
|
+
private restoreSession;
|
|
2502
|
+
/**
|
|
2503
|
+
* Log debug messages
|
|
2504
|
+
*/
|
|
2505
|
+
debug(...args: unknown[]): void;
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
export { type AIGenerateOptions, type ApiError, type ApiResponse, type AuthOptions, type AuthResponse, type Bucket, type ColumnSchema, type DatabaseSchema, type DeleteQuery, type DownloadOptions, type EndpointGenerationResult, type EnumSchema, type FileObject, type FilterOperator, type ForeignKeySchema, type FunctionGenerationResult, type FunctionInvokeOptions, type FunctionResponse, type IndexSchema, type InsertQuery, type OrderDirection, type QueryBuilder$1 as QueryBuilder, RealtimeChannel, type RealtimeEvent, type RealtimeMessage, type RealtimeOptions, type RequestOptions, type SchemaGenerationResult, type SelectQuery, type Session, type SignInCredentials, type SignUpCredentials, type StorageOptions, type SubscriptionCallback, type TableSchema, type TypeGenOptions, type UpdateQuery, type UploadOptions, type User, VaifAI, VaifAuth, VaifClient, type VaifClientOptions, type VaifConfig, VaifDatabase, VaifFunctions, VaifRealtime, VaifStorage, VaifTypeGen, type ViewSchema, createClient, createTypeGen };
|