@omnikit-ai/sdk 2.0.3
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/auth-utils.d.mts +68 -0
- package/dist/auth-utils.d.ts +68 -0
- package/dist/auth-utils.js +124 -0
- package/dist/auth-utils.js.map +1 -0
- package/dist/auth-utils.mjs +115 -0
- package/dist/auth-utils.mjs.map +1 -0
- package/dist/index.d.mts +1471 -0
- package/dist/index.d.ts +1471 -0
- package/dist/index.js +2096 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2085 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +43 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1471 @@
|
|
|
1
|
+
export { cleanTokenFromUrl, getAccessToken, isTokenInUrl, removeAccessToken, saveAccessToken, setAccessToken } from './auth-utils.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Omnikit SDK Type Definitions v2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for creating an Omnikit client
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Initial app metadata for instant display (no API call, no flicker).
|
|
11
|
+
* Pass build-time values here for immediate rendering.
|
|
12
|
+
*/
|
|
13
|
+
interface InitialMetadata {
|
|
14
|
+
name?: string;
|
|
15
|
+
logoUrl?: string;
|
|
16
|
+
thumbnailUrl?: string;
|
|
17
|
+
}
|
|
18
|
+
interface OmnikitConfig {
|
|
19
|
+
/** App ID (required) */
|
|
20
|
+
appId: string;
|
|
21
|
+
/**
|
|
22
|
+
* API base URL
|
|
23
|
+
* @default 'https://api.omnikit.ai/api'
|
|
24
|
+
*/
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Alias for baseUrl
|
|
28
|
+
* @default 'https://api.omnikit.ai/api'
|
|
29
|
+
*/
|
|
30
|
+
serverUrl?: string;
|
|
31
|
+
/**
|
|
32
|
+
* User access token (optional)
|
|
33
|
+
* If not provided, will auto-detect from URL or localStorage
|
|
34
|
+
*/
|
|
35
|
+
token?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Service role token for elevated admin operations (optional)
|
|
38
|
+
* When provided, enables asServiceRole operations
|
|
39
|
+
*/
|
|
40
|
+
serviceToken?: string;
|
|
41
|
+
/**
|
|
42
|
+
* API key for server-to-server authentication (optional)
|
|
43
|
+
* Used in backend functions (Deno Edge Functions) where user auth isn't needed.
|
|
44
|
+
* Takes precedence over serviceToken if both are provided.
|
|
45
|
+
*/
|
|
46
|
+
apiKey?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Auto-detect and load token from URL params or localStorage
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
autoInitAuth?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Initial app metadata for instant display (no flicker).
|
|
54
|
+
* Values are cached in localStorage and auto-refreshed from server.
|
|
55
|
+
*/
|
|
56
|
+
initialMetadata?: InitialMetadata;
|
|
57
|
+
}
|
|
58
|
+
interface CollectionField {
|
|
59
|
+
name: string;
|
|
60
|
+
display_name?: string;
|
|
61
|
+
type: 'string' | 'number' | 'boolean' | 'date' | 'email' | 'enum' | 'reference' | 'reference_array';
|
|
62
|
+
required?: boolean;
|
|
63
|
+
unique?: boolean;
|
|
64
|
+
default?: any;
|
|
65
|
+
reference_collection?: string;
|
|
66
|
+
/** @deprecated Use reference_collection instead */
|
|
67
|
+
reference_entity?: string;
|
|
68
|
+
enum_values?: string[];
|
|
69
|
+
is_display?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/** @deprecated Use CollectionField instead */
|
|
72
|
+
type EntityField = CollectionField;
|
|
73
|
+
interface CollectionDefinition {
|
|
74
|
+
name: string;
|
|
75
|
+
display_name?: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
fields: CollectionField[];
|
|
78
|
+
rls?: {
|
|
79
|
+
read?: string;
|
|
80
|
+
write?: string;
|
|
81
|
+
update?: string;
|
|
82
|
+
delete?: string;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** @deprecated Use CollectionDefinition instead */
|
|
86
|
+
type EntityDefinition = CollectionDefinition;
|
|
87
|
+
interface AppMetadata {
|
|
88
|
+
id: string;
|
|
89
|
+
name: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
created_date?: string;
|
|
92
|
+
updated_date?: string;
|
|
93
|
+
logo_url?: string;
|
|
94
|
+
logo_file_id?: string;
|
|
95
|
+
thumbnail_url?: string;
|
|
96
|
+
slug?: string;
|
|
97
|
+
domain?: string;
|
|
98
|
+
visibility?: string;
|
|
99
|
+
auth_settings?: {
|
|
100
|
+
platform_auth_providers?: string[];
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
interface AppSchema {
|
|
104
|
+
app: AppMetadata;
|
|
105
|
+
entities: CollectionDefinition[] | Record<string, CollectionDefinition>;
|
|
106
|
+
integrations?: Record<string, any>;
|
|
107
|
+
visibility?: 'public' | 'private';
|
|
108
|
+
data_access_mode?: 'public' | 'user_private';
|
|
109
|
+
status?: string;
|
|
110
|
+
app_stage?: string;
|
|
111
|
+
public_settings?: string;
|
|
112
|
+
main_page?: string;
|
|
113
|
+
platform_version?: number;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* MongoDB-style list options (Mongoose-compatible)
|
|
117
|
+
* Used in the second parameter of list(filter, options)
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* // Sort ascending by name
|
|
122
|
+
* await Entity.list({}, { sort: { name: 1 } })
|
|
123
|
+
*
|
|
124
|
+
* // Sort descending by timestamp
|
|
125
|
+
* await Entity.list({}, { sort: { timestamp: -1 } })
|
|
126
|
+
*
|
|
127
|
+
* // With pagination
|
|
128
|
+
* await Entity.list({}, { sort: { created_at: -1 }, limit: 20, offset: 10 })
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
interface ListOptions {
|
|
132
|
+
/** Sort order: { field: 1 } for ascending, { field: -1 } for descending. Also accepts string format: 'field' or '-field' */
|
|
133
|
+
sort?: Record<string, 1 | -1> | string;
|
|
134
|
+
/** Maximum number of results to return */
|
|
135
|
+
limit?: number;
|
|
136
|
+
/** Number of results to skip (for pagination) */
|
|
137
|
+
offset?: number;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated Use separate filter and ListOptions parameters instead
|
|
141
|
+
* This interface is kept for backward compatibility
|
|
142
|
+
*
|
|
143
|
+
* @example Old style (still works):
|
|
144
|
+
* ```typescript
|
|
145
|
+
* await Entity.list({ q: { status: 'active' }, sort: '-created_at' })
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @example New style (recommended):
|
|
149
|
+
* ```typescript
|
|
150
|
+
* await Entity.list({ status: 'active' }, { sort: { created_at: -1 } })
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
interface QueryOptions {
|
|
154
|
+
q?: Record<string, any>;
|
|
155
|
+
sort?: string;
|
|
156
|
+
limit?: number;
|
|
157
|
+
offset?: number;
|
|
158
|
+
_count?: boolean;
|
|
159
|
+
[key: string]: any;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Base collection record type
|
|
163
|
+
* Extend this in your app for type-safe collections
|
|
164
|
+
*/
|
|
165
|
+
interface CollectionRecord {
|
|
166
|
+
id: string;
|
|
167
|
+
_id?: string;
|
|
168
|
+
created_at?: string;
|
|
169
|
+
updated_at?: string;
|
|
170
|
+
created_by?: string;
|
|
171
|
+
created_by_id?: string;
|
|
172
|
+
[key: string]: any;
|
|
173
|
+
}
|
|
174
|
+
/** @deprecated Use CollectionRecord instead */
|
|
175
|
+
type Entity = CollectionRecord;
|
|
176
|
+
/** @deprecated Use CollectionRecord instead */
|
|
177
|
+
type EntityRecord = CollectionRecord;
|
|
178
|
+
interface AuthResponse {
|
|
179
|
+
token?: string;
|
|
180
|
+
user?: UserInfo;
|
|
181
|
+
access_token?: string;
|
|
182
|
+
refresh_token?: string;
|
|
183
|
+
token_type?: string;
|
|
184
|
+
}
|
|
185
|
+
interface OAuthProvider {
|
|
186
|
+
provider_id: string;
|
|
187
|
+
provider_type: 'platform' | 'custom';
|
|
188
|
+
display_name: string;
|
|
189
|
+
icon_data: string;
|
|
190
|
+
brand_color: string;
|
|
191
|
+
login_endpoint: string;
|
|
192
|
+
enabled: boolean;
|
|
193
|
+
}
|
|
194
|
+
interface OAuthProvidersResponse {
|
|
195
|
+
providers: OAuthProvider[];
|
|
196
|
+
email_enabled: boolean;
|
|
197
|
+
app_id?: string;
|
|
198
|
+
app_name?: string;
|
|
199
|
+
}
|
|
200
|
+
interface UserInfo {
|
|
201
|
+
id: string;
|
|
202
|
+
platform_user_id?: string;
|
|
203
|
+
app_id?: string;
|
|
204
|
+
email: string;
|
|
205
|
+
full_name?: string;
|
|
206
|
+
role?: string;
|
|
207
|
+
profile_image_url?: string;
|
|
208
|
+
bio?: string;
|
|
209
|
+
is_verified?: boolean;
|
|
210
|
+
disabled?: boolean;
|
|
211
|
+
is_service?: boolean;
|
|
212
|
+
created_date?: string;
|
|
213
|
+
updated_date?: string;
|
|
214
|
+
[key: string]: any;
|
|
215
|
+
}
|
|
216
|
+
interface EmailParams {
|
|
217
|
+
to: string;
|
|
218
|
+
subject: string;
|
|
219
|
+
body: string;
|
|
220
|
+
from_name?: string;
|
|
221
|
+
}
|
|
222
|
+
interface LLMMessage {
|
|
223
|
+
role: 'system' | 'user' | 'assistant';
|
|
224
|
+
content: string | Array<{
|
|
225
|
+
type: string;
|
|
226
|
+
text?: string;
|
|
227
|
+
file?: any;
|
|
228
|
+
image_url?: any;
|
|
229
|
+
}>;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Available LLM models for InvokeLLM
|
|
233
|
+
* - 'gemini-flash': Fast and cost-effective (default)
|
|
234
|
+
* - 'gemini-pro': Smarter with extended thinking (128 token thinking budget)
|
|
235
|
+
*/
|
|
236
|
+
type LLMModel = 'gemini-flash' | 'gemini-pro';
|
|
237
|
+
interface LLMParams {
|
|
238
|
+
/** Message-based format for advanced use */
|
|
239
|
+
messages?: LLMMessage[];
|
|
240
|
+
/** Simple text prompt (alternative to messages) */
|
|
241
|
+
prompt?: string;
|
|
242
|
+
/** File URLs to include (images, PDFs, audio, videos, etc.) - supports YouTube URLs and uploaded video files */
|
|
243
|
+
file_urls?: string[];
|
|
244
|
+
/** Enable Google Search grounding */
|
|
245
|
+
google_search?: boolean;
|
|
246
|
+
/** Enable URL context grounding */
|
|
247
|
+
url_context?: boolean;
|
|
248
|
+
/**
|
|
249
|
+
* Force JSON output format. Specify the JSON schema in your prompt text.
|
|
250
|
+
* @example { type: "json_object" }
|
|
251
|
+
*/
|
|
252
|
+
response_format?: {
|
|
253
|
+
type: 'json_object';
|
|
254
|
+
} | Record<string, any>;
|
|
255
|
+
/**
|
|
256
|
+
* Model to use for LLM processing
|
|
257
|
+
* - 'gemini-flash': Fast and cost-effective (default)
|
|
258
|
+
* - 'gemini-pro': Smarter with extended thinking for complex reasoning
|
|
259
|
+
*/
|
|
260
|
+
model?: LLMModel | string;
|
|
261
|
+
/**
|
|
262
|
+
* @deprecated All integrations are now async by default. This parameter is ignored.
|
|
263
|
+
* The SDK automatically polls for completion and returns the result.
|
|
264
|
+
*/
|
|
265
|
+
async_mode?: boolean;
|
|
266
|
+
/** @deprecated Use google_search instead */
|
|
267
|
+
web_search?: boolean;
|
|
268
|
+
/** @deprecated No longer used */
|
|
269
|
+
web_search_options?: {
|
|
270
|
+
search_context_size?: 'small' | 'medium' | 'large';
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Stream tokens via SSE instead of returning complete response.
|
|
274
|
+
* When true, tokens are streamed in real-time via onToken callback.
|
|
275
|
+
* @default false
|
|
276
|
+
*/
|
|
277
|
+
stream?: boolean;
|
|
278
|
+
/**
|
|
279
|
+
* Callback for each token when streaming (requires stream: true)
|
|
280
|
+
* @param token - The streamed token
|
|
281
|
+
*/
|
|
282
|
+
onToken?: (token: string) => void;
|
|
283
|
+
/**
|
|
284
|
+
* Callback when streaming completes (requires stream: true)
|
|
285
|
+
* @param result - Complete result with metadata
|
|
286
|
+
*/
|
|
287
|
+
onComplete?: (result: LLMStreamResult) => void;
|
|
288
|
+
/**
|
|
289
|
+
* Callback when streaming encounters an error (requires stream: true)
|
|
290
|
+
* @param error - The error that occurred
|
|
291
|
+
*/
|
|
292
|
+
onError?: (error: Error) => void;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Result from streaming LLM completion
|
|
296
|
+
*/
|
|
297
|
+
interface LLMStreamResult {
|
|
298
|
+
/** Complete response text */
|
|
299
|
+
result: string;
|
|
300
|
+
/** Model that was used */
|
|
301
|
+
model_used: string;
|
|
302
|
+
/** Token usage statistics */
|
|
303
|
+
usage?: {
|
|
304
|
+
prompt_tokens: number;
|
|
305
|
+
completion_tokens: number;
|
|
306
|
+
total_tokens: number;
|
|
307
|
+
};
|
|
308
|
+
/** Whether images were in the input */
|
|
309
|
+
has_images?: boolean;
|
|
310
|
+
/** Whether files were in the input */
|
|
311
|
+
has_files?: boolean;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* SSE event types for LLM streaming
|
|
315
|
+
*/
|
|
316
|
+
interface LLMStreamEvent {
|
|
317
|
+
/** Event type */
|
|
318
|
+
type: 'token' | 'done' | 'error';
|
|
319
|
+
/** Token content (for type: 'token') */
|
|
320
|
+
content?: string;
|
|
321
|
+
/** Complete result (for type: 'done') */
|
|
322
|
+
result?: string;
|
|
323
|
+
/** Model used (for type: 'done') */
|
|
324
|
+
model_used?: string;
|
|
325
|
+
/** Usage stats (for type: 'done') */
|
|
326
|
+
usage?: {
|
|
327
|
+
prompt_tokens: number;
|
|
328
|
+
completion_tokens: number;
|
|
329
|
+
total_tokens: number;
|
|
330
|
+
};
|
|
331
|
+
/** Error message (for type: 'error') */
|
|
332
|
+
message?: string;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Async job status types
|
|
336
|
+
*/
|
|
337
|
+
type AsyncJobStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled';
|
|
338
|
+
/**
|
|
339
|
+
* Async job types
|
|
340
|
+
*/
|
|
341
|
+
type AsyncJobType = 'llm' | 'image' | 'speech' | 'video' | 'extract' | 'email' | 'sms';
|
|
342
|
+
/**
|
|
343
|
+
* Response when async_mode is enabled
|
|
344
|
+
*/
|
|
345
|
+
interface AsyncJobCreatedResponse {
|
|
346
|
+
/** Whether this is an async response */
|
|
347
|
+
async: true;
|
|
348
|
+
/** Job ID for polling status */
|
|
349
|
+
job_id: string;
|
|
350
|
+
/** Initial job status */
|
|
351
|
+
status: AsyncJobStatus;
|
|
352
|
+
/** Human-readable message */
|
|
353
|
+
message: string;
|
|
354
|
+
/** URL to poll for status */
|
|
355
|
+
poll_url: string;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Job status response from CheckJobStatus
|
|
359
|
+
*/
|
|
360
|
+
interface AsyncJobStatusResponse {
|
|
361
|
+
/** Job ID */
|
|
362
|
+
job_id: string;
|
|
363
|
+
/** Current status */
|
|
364
|
+
status: AsyncJobStatus;
|
|
365
|
+
/** Progress (0.0 to 1.0) */
|
|
366
|
+
progress: number;
|
|
367
|
+
/** Human-readable status message */
|
|
368
|
+
status_message?: string;
|
|
369
|
+
/** Result data (when status is 'completed') */
|
|
370
|
+
result?: any;
|
|
371
|
+
/** Error message (when status is 'failed') */
|
|
372
|
+
error?: string;
|
|
373
|
+
/** Job creation timestamp */
|
|
374
|
+
created_at?: string;
|
|
375
|
+
/** Processing start timestamp */
|
|
376
|
+
started_at?: string;
|
|
377
|
+
/** Completion timestamp */
|
|
378
|
+
completed_at?: string;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Parameters for checking job status
|
|
382
|
+
*/
|
|
383
|
+
interface CheckJobStatusParams {
|
|
384
|
+
/** Job ID to check */
|
|
385
|
+
job_id: string;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Options for async operations with built-in polling
|
|
389
|
+
*/
|
|
390
|
+
interface AsyncOptions {
|
|
391
|
+
/**
|
|
392
|
+
* Called on status changes during polling.
|
|
393
|
+
* Note: For most operations (image/speech/video), status is simply 'pending' → 'processing' → 'completed'.
|
|
394
|
+
* Real progress tracking is only available for multi-file operations like ExtractData.
|
|
395
|
+
* @param status - Current job status ('pending' | 'processing' | 'completed' | 'failed')
|
|
396
|
+
* @param message - Human-readable status message (e.g., "Generating image with AI...")
|
|
397
|
+
*/
|
|
398
|
+
onStatusChange?: (status: string, message?: string) => void;
|
|
399
|
+
/**
|
|
400
|
+
* Polling interval in milliseconds
|
|
401
|
+
* @default 2000
|
|
402
|
+
*/
|
|
403
|
+
pollInterval?: number;
|
|
404
|
+
/**
|
|
405
|
+
* Maximum time to wait in milliseconds
|
|
406
|
+
* @default 300000 (5 minutes)
|
|
407
|
+
*/
|
|
408
|
+
timeout?: number;
|
|
409
|
+
/**
|
|
410
|
+
* Return immediately with job_id instead of waiting for completion
|
|
411
|
+
* When true, returns AsyncJobCreatedResponse
|
|
412
|
+
* @default false
|
|
413
|
+
*/
|
|
414
|
+
returnJobId?: boolean;
|
|
415
|
+
}
|
|
416
|
+
interface ImageParams {
|
|
417
|
+
/** Text prompt describing the desired image or transformation */
|
|
418
|
+
prompt: string;
|
|
419
|
+
/** Optional: URL of an existing image to edit/transform (for image editing) */
|
|
420
|
+
image_url?: string;
|
|
421
|
+
}
|
|
422
|
+
interface SpeechParams {
|
|
423
|
+
input: string;
|
|
424
|
+
model?: string;
|
|
425
|
+
voice?: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
|
|
426
|
+
response_format?: 'mp3' | 'opus' | 'aac' | 'flac';
|
|
427
|
+
speed?: number;
|
|
428
|
+
}
|
|
429
|
+
interface VideoParams {
|
|
430
|
+
prompt: string;
|
|
431
|
+
model?: string;
|
|
432
|
+
negative_prompt?: string;
|
|
433
|
+
aspect_ratio?: '16:9' | '9:16';
|
|
434
|
+
resolution?: '720p' | '1080p';
|
|
435
|
+
duration_seconds?: '4' | '6' | '8';
|
|
436
|
+
person_generation?: 'allow_all' | 'allow_adult' | 'dont_allow';
|
|
437
|
+
image_url?: string;
|
|
438
|
+
last_frame_url?: string;
|
|
439
|
+
reference_image_urls?: string[];
|
|
440
|
+
video_url?: string;
|
|
441
|
+
}
|
|
442
|
+
interface VideoStatusParams {
|
|
443
|
+
operation_name: string;
|
|
444
|
+
}
|
|
445
|
+
interface ExtractParams {
|
|
446
|
+
file_urls: string[];
|
|
447
|
+
}
|
|
448
|
+
interface SMSParams {
|
|
449
|
+
/** Recipient phone number in E.164 format (+1234567890) */
|
|
450
|
+
to: string;
|
|
451
|
+
/** SMS message content (max 1600 characters) */
|
|
452
|
+
message: string;
|
|
453
|
+
/** Optional: Sender ID (alphanumeric, max 11 chars, supported in some countries) */
|
|
454
|
+
from_name?: string;
|
|
455
|
+
}
|
|
456
|
+
interface ServiceResponse {
|
|
457
|
+
success: boolean;
|
|
458
|
+
[key: string]: any;
|
|
459
|
+
}
|
|
460
|
+
interface BulkResult {
|
|
461
|
+
success: boolean;
|
|
462
|
+
inserted_count?: number;
|
|
463
|
+
deleted_count?: number;
|
|
464
|
+
ids?: string[];
|
|
465
|
+
}
|
|
466
|
+
interface ImportResult {
|
|
467
|
+
success: boolean;
|
|
468
|
+
imported_count?: number;
|
|
469
|
+
errors?: any[];
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Collection class with type-safe CRUD operations
|
|
473
|
+
* @template T - Record type extending CollectionRecord base interface
|
|
474
|
+
*/
|
|
475
|
+
interface CollectionClass<T = CollectionRecord> {
|
|
476
|
+
/**
|
|
477
|
+
* Get a single record by ID
|
|
478
|
+
* @param id - Record ID
|
|
479
|
+
* @returns The record
|
|
480
|
+
*/
|
|
481
|
+
get(id: string): Promise<T>;
|
|
482
|
+
/**
|
|
483
|
+
* List records with MongoDB/Mongoose-style filtering
|
|
484
|
+
*
|
|
485
|
+
* @example Simple filter
|
|
486
|
+
* ```typescript
|
|
487
|
+
* await Collection.list({ status: 'active' })
|
|
488
|
+
* ```
|
|
489
|
+
*
|
|
490
|
+
* @example With sort and pagination
|
|
491
|
+
* ```typescript
|
|
492
|
+
* await Collection.list(
|
|
493
|
+
* { project_id: projectId },
|
|
494
|
+
* { sort: { timestamp: -1 }, limit: 10 }
|
|
495
|
+
* )
|
|
496
|
+
* ```
|
|
497
|
+
*
|
|
498
|
+
* @example Complex MongoDB operators
|
|
499
|
+
* ```typescript
|
|
500
|
+
* await Collection.list({
|
|
501
|
+
* $and: [
|
|
502
|
+
* { priority: { $gte: 5 } },
|
|
503
|
+
* { status: 'active' }
|
|
504
|
+
* ]
|
|
505
|
+
* })
|
|
506
|
+
* ```
|
|
507
|
+
*
|
|
508
|
+
* @example Old style (still supported)
|
|
509
|
+
* ```typescript
|
|
510
|
+
* await Collection.list({ q: { status: 'active' }, sort: '-created_at' })
|
|
511
|
+
* ```
|
|
512
|
+
*
|
|
513
|
+
* @param filter - MongoDB query filter
|
|
514
|
+
* @param options - Sort, limit, offset options
|
|
515
|
+
* @returns Array of records
|
|
516
|
+
*/
|
|
517
|
+
list(filter?: Record<string, any>, options?: ListOptions): Promise<T[]>;
|
|
518
|
+
list(options?: QueryOptions): Promise<T[]>;
|
|
519
|
+
/**
|
|
520
|
+
* Filter records by query (alias for list)
|
|
521
|
+
* @param filter - MongoDB query filter
|
|
522
|
+
* @param options - Sort, limit, offset options
|
|
523
|
+
* @returns Array of matching records
|
|
524
|
+
*/
|
|
525
|
+
filter(filter?: Record<string, any>, options?: ListOptions): Promise<T[]>;
|
|
526
|
+
filter(options?: QueryOptions): Promise<T[]>;
|
|
527
|
+
/**
|
|
528
|
+
* Find a single record matching the query
|
|
529
|
+
*
|
|
530
|
+
* @example MongoDB/Mongoose style
|
|
531
|
+
* ```typescript
|
|
532
|
+
* await Collection.findOne({ email: 'user@example.com' })
|
|
533
|
+
* ```
|
|
534
|
+
*
|
|
535
|
+
* @param filter - MongoDB query filter
|
|
536
|
+
* @param options - Optional sort/limit options
|
|
537
|
+
* @returns Single record or null
|
|
538
|
+
*/
|
|
539
|
+
findOne(filter?: Record<string, any>, options?: ListOptions): Promise<T | null>;
|
|
540
|
+
findOne(filters?: QueryOptions): Promise<T | null>;
|
|
541
|
+
/**
|
|
542
|
+
* Create a new record
|
|
543
|
+
* @param data - Record data
|
|
544
|
+
* @returns Created record
|
|
545
|
+
*/
|
|
546
|
+
create(data: Partial<T>): Promise<T>;
|
|
547
|
+
/**
|
|
548
|
+
* Update an existing record
|
|
549
|
+
* @param id - Record ID
|
|
550
|
+
* @param data - Updated data
|
|
551
|
+
* @returns Updated record
|
|
552
|
+
*/
|
|
553
|
+
update(id: string, data: Partial<T>): Promise<T>;
|
|
554
|
+
/**
|
|
555
|
+
* Delete a record by ID
|
|
556
|
+
* @param id - Record ID
|
|
557
|
+
* @returns Success boolean
|
|
558
|
+
*/
|
|
559
|
+
delete(id: string): Promise<boolean>;
|
|
560
|
+
/**
|
|
561
|
+
* Count records matching the query
|
|
562
|
+
*
|
|
563
|
+
* @example MongoDB/Mongoose style
|
|
564
|
+
* ```typescript
|
|
565
|
+
* const activeCount = await Collection.count({ status: 'active' })
|
|
566
|
+
* ```
|
|
567
|
+
*
|
|
568
|
+
* @param filter - MongoDB query filter
|
|
569
|
+
* @returns Count
|
|
570
|
+
*/
|
|
571
|
+
count(filter?: Record<string, any>): Promise<number>;
|
|
572
|
+
count(filters?: QueryOptions): Promise<number>;
|
|
573
|
+
/**
|
|
574
|
+
* Create multiple records at once
|
|
575
|
+
* @param items - Array of record data
|
|
576
|
+
* @returns Bulk operation result
|
|
577
|
+
*/
|
|
578
|
+
bulkCreate(items: Partial<T>[]): Promise<BulkResult>;
|
|
579
|
+
/**
|
|
580
|
+
* Delete multiple records by ID
|
|
581
|
+
* @param ids - Array of record IDs
|
|
582
|
+
* @returns Bulk operation result
|
|
583
|
+
*/
|
|
584
|
+
bulkDelete(ids: string[]): Promise<BulkResult>;
|
|
585
|
+
/**
|
|
586
|
+
* Import records from CSV or JSON file
|
|
587
|
+
* @param file - File to import
|
|
588
|
+
* @param format - File format ('csv' or 'json')
|
|
589
|
+
* @returns Import result
|
|
590
|
+
*/
|
|
591
|
+
import(file: File, format: 'csv' | 'json'): Promise<ImportResult>;
|
|
592
|
+
/**
|
|
593
|
+
* Delete all records (requires explicit confirmation)
|
|
594
|
+
* @param confirm - Must be true to proceed
|
|
595
|
+
* @returns Bulk operation result
|
|
596
|
+
*/
|
|
597
|
+
deleteAll(confirm: boolean): Promise<BulkResult>;
|
|
598
|
+
/** @deprecated Use get() instead */
|
|
599
|
+
findById(id: string): Promise<T>;
|
|
600
|
+
}
|
|
601
|
+
/** @deprecated Use CollectionClass instead */
|
|
602
|
+
type EntityClass<T = CollectionRecord> = CollectionClass<T>;
|
|
603
|
+
/**
|
|
604
|
+
* Enhanced User collection class with convenience methods
|
|
605
|
+
* Automatically available for User collections - no wrapper needed!
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* // Update current user (single argument)
|
|
609
|
+
* await User.update({ bio: "Software developer" });
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* // Update specific user by ID (two arguments, admin)
|
|
613
|
+
* await User.update("user-id-123", { role: "editor" });
|
|
614
|
+
*
|
|
615
|
+
* @example
|
|
616
|
+
* // Get current user
|
|
617
|
+
* const me = await User.me();
|
|
618
|
+
*/
|
|
619
|
+
interface UserCollectionClass<T = UserInfo> extends Omit<CollectionClass<T>, 'update'> {
|
|
620
|
+
/**
|
|
621
|
+
* Smart update method with two signatures:
|
|
622
|
+
* - update(data) - Updates current logged-in user
|
|
623
|
+
* - update(id, data) - Updates specific user by ID (admin)
|
|
624
|
+
*/
|
|
625
|
+
update(data: Partial<T>): Promise<T>;
|
|
626
|
+
update(id: string, data: Partial<T>): Promise<T>;
|
|
627
|
+
/**
|
|
628
|
+
* Get current logged-in user
|
|
629
|
+
* Same as auth.me()
|
|
630
|
+
* @returns Current user information
|
|
631
|
+
*/
|
|
632
|
+
me(): Promise<T>;
|
|
633
|
+
/**
|
|
634
|
+
* Update current logged-in user
|
|
635
|
+
* Same as auth.updateMe()
|
|
636
|
+
* @param data - Fields to update
|
|
637
|
+
* @returns Updated user information
|
|
638
|
+
*/
|
|
639
|
+
updateMe(data: Partial<T>): Promise<T>;
|
|
640
|
+
}
|
|
641
|
+
/** @deprecated Use UserCollectionClass instead */
|
|
642
|
+
type UserEntityClass<T = UserInfo> = UserCollectionClass<T>;
|
|
643
|
+
/**
|
|
644
|
+
* Integration method signature
|
|
645
|
+
*/
|
|
646
|
+
type IntegrationMethod = (params?: Record<string, any>, useServiceToken?: boolean) => Promise<any>;
|
|
647
|
+
/**
|
|
648
|
+
* BuiltIn integration methods
|
|
649
|
+
*/
|
|
650
|
+
interface BuiltInIntegration {
|
|
651
|
+
SendEmail(params: EmailParams): Promise<ServiceResponse>;
|
|
652
|
+
SendSMS(params: SMSParams): Promise<ServiceResponse>;
|
|
653
|
+
/**
|
|
654
|
+
* Invoke LLM for text/vision/file processing
|
|
655
|
+
* @param params - LLM parameters
|
|
656
|
+
* @param options - Async options for handling long-running operations
|
|
657
|
+
* @returns Result or AsyncJobCreatedResponse (if async_mode or returnJobId)
|
|
658
|
+
*/
|
|
659
|
+
InvokeLLM(params: LLMParams, options?: AsyncOptions): Promise<ServiceResponse | AsyncJobCreatedResponse>;
|
|
660
|
+
UploadFile(params: {
|
|
661
|
+
file: File;
|
|
662
|
+
metadata?: Record<string, any>;
|
|
663
|
+
}): Promise<ServiceResponse>;
|
|
664
|
+
/**
|
|
665
|
+
* Upload a private file (only uploader can access via signed URLs)
|
|
666
|
+
* @param params - File to upload
|
|
667
|
+
* @returns Response with file_uri (use CreateFileSignedUrl to get displayable URL)
|
|
668
|
+
*/
|
|
669
|
+
UploadPrivateFile(params: {
|
|
670
|
+
file: File;
|
|
671
|
+
}): Promise<{
|
|
672
|
+
file_uri: string;
|
|
673
|
+
file_id: string;
|
|
674
|
+
filename: string;
|
|
675
|
+
size: number;
|
|
676
|
+
content_type: string;
|
|
677
|
+
}>;
|
|
678
|
+
/**
|
|
679
|
+
* Create a temporary signed URL for a private file
|
|
680
|
+
* @param params - file_uri from UploadPrivateFile and optional expiry time
|
|
681
|
+
* @returns Signed URL that can be used in <img> tags
|
|
682
|
+
*/
|
|
683
|
+
CreateFileSignedUrl(params: {
|
|
684
|
+
file_uri: string;
|
|
685
|
+
expires_in?: number;
|
|
686
|
+
}): Promise<{
|
|
687
|
+
signed_url: string;
|
|
688
|
+
expires_in: number;
|
|
689
|
+
}>;
|
|
690
|
+
/**
|
|
691
|
+
* Download a private file (triggers browser download)
|
|
692
|
+
* Uses backend proxy to avoid CORS issues with R2 presigned URLs
|
|
693
|
+
* @param params - file_uri from UploadPrivateFile and optional filename for download
|
|
694
|
+
*/
|
|
695
|
+
DownloadPrivateFile(params: {
|
|
696
|
+
file_uri: string;
|
|
697
|
+
filename?: string;
|
|
698
|
+
}): Promise<void>;
|
|
699
|
+
GenerateImage(params: ImageParams): Promise<ServiceResponse>;
|
|
700
|
+
GenerateSpeech(params: SpeechParams): Promise<ServiceResponse>;
|
|
701
|
+
GenerateVideo(params: VideoParams): Promise<ServiceResponse>;
|
|
702
|
+
CheckVideoStatus(params: VideoStatusParams): Promise<ServiceResponse>;
|
|
703
|
+
ExtractData(params: ExtractParams): Promise<ServiceResponse>;
|
|
704
|
+
/**
|
|
705
|
+
* Check the status of an async job
|
|
706
|
+
* @param params - Job ID to check
|
|
707
|
+
* @returns Current job status with progress and result
|
|
708
|
+
*/
|
|
709
|
+
CheckJobStatus(params: CheckJobStatusParams): Promise<AsyncJobStatusResponse>;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Auth module interface
|
|
713
|
+
*/
|
|
714
|
+
interface AuthModule {
|
|
715
|
+
/**
|
|
716
|
+
* Check if user is authenticated
|
|
717
|
+
* @returns True if authenticated
|
|
718
|
+
*/
|
|
719
|
+
isAuthenticated(): Promise<boolean>;
|
|
720
|
+
/**
|
|
721
|
+
* Get current user info
|
|
722
|
+
* @returns Current user
|
|
723
|
+
*/
|
|
724
|
+
me(): Promise<UserInfo>;
|
|
725
|
+
/**
|
|
726
|
+
* Redirect to platform login page
|
|
727
|
+
* @param returnPath - Path to return to after login
|
|
728
|
+
*/
|
|
729
|
+
login(returnPath?: string): void;
|
|
730
|
+
/**
|
|
731
|
+
* Request a passwordless login code to email
|
|
732
|
+
* @param email - User email
|
|
733
|
+
* @param returnUrl - Optional return URL
|
|
734
|
+
*/
|
|
735
|
+
requestLoginCode(email: string, returnUrl?: string): Promise<{
|
|
736
|
+
success: boolean;
|
|
737
|
+
message?: string;
|
|
738
|
+
}>;
|
|
739
|
+
/**
|
|
740
|
+
* Verify the login code and set the session token
|
|
741
|
+
* @param email - User email
|
|
742
|
+
* @param code - Verification code
|
|
743
|
+
*/
|
|
744
|
+
verifyLoginCode(email: string, code: string): Promise<AuthResponse>;
|
|
745
|
+
/**
|
|
746
|
+
* Get available OAuth providers for this app
|
|
747
|
+
* Returns both platform providers (zero-config) and custom SSO providers
|
|
748
|
+
* @returns List of enabled OAuth providers
|
|
749
|
+
*/
|
|
750
|
+
getAvailableProviders(): Promise<OAuthProvidersResponse>;
|
|
751
|
+
/**
|
|
752
|
+
* Initiate OAuth login with any provider
|
|
753
|
+
* @param providerId - Provider ID (e.g., "google", "microsoft", "github")
|
|
754
|
+
* @param returnUrl - Optional return URL
|
|
755
|
+
*/
|
|
756
|
+
loginWithProvider(providerId: string, returnUrl?: string): void;
|
|
757
|
+
/**
|
|
758
|
+
* Initiate Google OAuth Login
|
|
759
|
+
* @deprecated Use loginWithProvider("google", returnUrl) instead
|
|
760
|
+
* @param returnUrl - Optional return URL
|
|
761
|
+
*/
|
|
762
|
+
loginWithGoogle(returnUrl?: string): void;
|
|
763
|
+
/**
|
|
764
|
+
* Logout current user
|
|
765
|
+
*/
|
|
766
|
+
logout(): Promise<void>;
|
|
767
|
+
/**
|
|
768
|
+
* Refresh access token
|
|
769
|
+
* @returns New auth response
|
|
770
|
+
*/
|
|
771
|
+
refreshToken(): Promise<AuthResponse>;
|
|
772
|
+
/**
|
|
773
|
+
* Update current user info
|
|
774
|
+
* @param data - Updated user data
|
|
775
|
+
* @returns Updated user
|
|
776
|
+
*/
|
|
777
|
+
updateMe(data: Partial<UserInfo>): Promise<UserInfo>;
|
|
778
|
+
/**
|
|
779
|
+
* Update current user profile
|
|
780
|
+
* Alias for updateMe with clearer naming
|
|
781
|
+
* @param data - Updated user data
|
|
782
|
+
* @returns Updated user
|
|
783
|
+
*/
|
|
784
|
+
updateProfile(data: Partial<UserInfo>): Promise<UserInfo>;
|
|
785
|
+
/** @deprecated Use me() instead */
|
|
786
|
+
getCurrentUser(): Promise<UserInfo>;
|
|
787
|
+
/**
|
|
788
|
+
* Subscribe to user state changes (for React auth state sync)
|
|
789
|
+
* Called when user logs in, logs out, or updates profile
|
|
790
|
+
* @param callback - Function to call with new user (or null on logout)
|
|
791
|
+
* @returns Unsubscribe function
|
|
792
|
+
*/
|
|
793
|
+
onUserChange(callback: (user: UserInfo | null) => void): () => void;
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Service role client interface (elevated admin operations)
|
|
797
|
+
* Available when serviceToken is provided in config
|
|
798
|
+
*/
|
|
799
|
+
interface ServiceRoleClient {
|
|
800
|
+
/** Collection operations with service role privileges */
|
|
801
|
+
collections: Record<string, CollectionClass>;
|
|
802
|
+
/** @deprecated Use collections instead */
|
|
803
|
+
entities?: Record<string, CollectionClass>;
|
|
804
|
+
/** Service operations with service role privileges (new flat structure) */
|
|
805
|
+
services: Record<string, IntegrationMethod>;
|
|
806
|
+
/** @deprecated Use services instead. Integration operations with service role privileges */
|
|
807
|
+
integrations: Record<string, Record<string, IntegrationMethod>>;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Main Omnikit Client interface
|
|
811
|
+
*/
|
|
812
|
+
/**
|
|
813
|
+
* Cached app metadata for instant access (no API call, no flicker).
|
|
814
|
+
* Values are loaded from localStorage cache or initial config.
|
|
815
|
+
*/
|
|
816
|
+
interface CachedMetadata {
|
|
817
|
+
/** App ID */
|
|
818
|
+
id: string;
|
|
819
|
+
/** App name */
|
|
820
|
+
name: string;
|
|
821
|
+
/** Logo URL (empty string if none) */
|
|
822
|
+
logoUrl: string;
|
|
823
|
+
/** Thumbnail URL */
|
|
824
|
+
thumbnailUrl: string;
|
|
825
|
+
/** App visibility ('public' | 'private' | 'public_with_login') */
|
|
826
|
+
visibility: string;
|
|
827
|
+
/** Enabled platform OAuth providers (e.g., ['google', 'microsoft']) */
|
|
828
|
+
platformAuthProviders: string[];
|
|
829
|
+
}
|
|
830
|
+
interface OmnikitClient {
|
|
831
|
+
/** App ID */
|
|
832
|
+
appId: string;
|
|
833
|
+
/** API base URL */
|
|
834
|
+
baseUrl: string;
|
|
835
|
+
/**
|
|
836
|
+
* App metadata - available instantly without API call (no flicker!).
|
|
837
|
+
* Uses localStorage cache with build-time fallback.
|
|
838
|
+
* @example
|
|
839
|
+
* <img src={omnikit.metadata.logoUrl} alt={omnikit.metadata.name} />
|
|
840
|
+
* <span>{omnikit.metadata.name}</span>
|
|
841
|
+
*/
|
|
842
|
+
metadata: CachedMetadata;
|
|
843
|
+
/** Collection operations */
|
|
844
|
+
collections: Record<string, CollectionClass>;
|
|
845
|
+
/** @deprecated Use collections instead */
|
|
846
|
+
entities: Record<string, CollectionClass>;
|
|
847
|
+
/** Integration operations */
|
|
848
|
+
integrations: Record<string, Record<string, IntegrationMethod>>;
|
|
849
|
+
/** Authentication methods */
|
|
850
|
+
auth: AuthModule;
|
|
851
|
+
/**
|
|
852
|
+
* Service role operations (admin/elevated privileges)
|
|
853
|
+
* Only available when serviceToken is provided in config
|
|
854
|
+
* Throws error if accessed without serviceToken
|
|
855
|
+
*/
|
|
856
|
+
asServiceRole?: ServiceRoleClient;
|
|
857
|
+
/** @internal */
|
|
858
|
+
getAppMetadata(): Promise<AppSchema>;
|
|
859
|
+
/** @internal */
|
|
860
|
+
makeRequest(url: string, method?: string, data?: any, options?: RequestOptions): Promise<any>;
|
|
861
|
+
/** @internal */
|
|
862
|
+
setAuthToken(token: string): void;
|
|
863
|
+
/** @internal */
|
|
864
|
+
getAuthToken(): string | null;
|
|
865
|
+
/** @internal */
|
|
866
|
+
clearAuthToken(): void;
|
|
867
|
+
/** @internal */
|
|
868
|
+
ensureInitialized(): Promise<void>;
|
|
869
|
+
/**
|
|
870
|
+
* Invoke a backend function by name.
|
|
871
|
+
*
|
|
872
|
+
* Backend functions are defined in backend/functions/*.js and auto-deployed during build.
|
|
873
|
+
*
|
|
874
|
+
* @example
|
|
875
|
+
* ```typescript
|
|
876
|
+
* const result = await omnikit.invokeFunction('processPayment', {
|
|
877
|
+
* amount: 100,
|
|
878
|
+
* userId: 'abc123'
|
|
879
|
+
* });
|
|
880
|
+
* ```
|
|
881
|
+
*
|
|
882
|
+
* @param functionName - Name of the function (filename without .js extension)
|
|
883
|
+
* @param body - Optional request body to pass to the function
|
|
884
|
+
* @returns Response from the function
|
|
885
|
+
*/
|
|
886
|
+
invokeFunction(functionName: string, body?: Record<string, any>): Promise<any>;
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Request options for makeRequest
|
|
890
|
+
*/
|
|
891
|
+
interface RequestOptions {
|
|
892
|
+
/** Use service token instead of user token */
|
|
893
|
+
useServiceToken?: boolean;
|
|
894
|
+
/** Additional headers */
|
|
895
|
+
headers?: Record<string, string>;
|
|
896
|
+
/** Query parameters for GET requests */
|
|
897
|
+
queryParams?: Record<string, any>;
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Custom error class
|
|
901
|
+
*/
|
|
902
|
+
declare class OmnikitError$1 extends Error {
|
|
903
|
+
status?: number;
|
|
904
|
+
code?: string;
|
|
905
|
+
data?: any;
|
|
906
|
+
isAuthError?: boolean;
|
|
907
|
+
constructor(message: string, status?: number, code?: string, data?: any);
|
|
908
|
+
/**
|
|
909
|
+
* Check if error is a 404 Not Found
|
|
910
|
+
*/
|
|
911
|
+
isNotFound(): boolean;
|
|
912
|
+
/**
|
|
913
|
+
* Check if error is a 403 Forbidden
|
|
914
|
+
*/
|
|
915
|
+
isForbidden(): boolean;
|
|
916
|
+
/**
|
|
917
|
+
* Check if error is a 401 Unauthorized
|
|
918
|
+
*/
|
|
919
|
+
isUnauthorized(): boolean;
|
|
920
|
+
/**
|
|
921
|
+
* Check if error is a 400 Bad Request
|
|
922
|
+
*/
|
|
923
|
+
isBadRequest(): boolean;
|
|
924
|
+
/**
|
|
925
|
+
* Check if error is a 500 Internal Server Error
|
|
926
|
+
*/
|
|
927
|
+
isServerError(): boolean;
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Service definition from backend schema (flat structure)
|
|
931
|
+
*/
|
|
932
|
+
interface ServiceDefinition {
|
|
933
|
+
name: string;
|
|
934
|
+
path: string;
|
|
935
|
+
description: string;
|
|
936
|
+
method?: string;
|
|
937
|
+
category?: string;
|
|
938
|
+
async?: boolean;
|
|
939
|
+
params: Record<string, any>;
|
|
940
|
+
path_params?: string[] | null;
|
|
941
|
+
configurable?: boolean | null;
|
|
942
|
+
providers?: string[] | null;
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Template integration definition from backend schema
|
|
946
|
+
*/
|
|
947
|
+
interface TemplateDefinition {
|
|
948
|
+
name: string;
|
|
949
|
+
description: string;
|
|
950
|
+
category: string;
|
|
951
|
+
icon?: string;
|
|
952
|
+
requires_secret: string;
|
|
953
|
+
help_url: string;
|
|
954
|
+
methods: string[];
|
|
955
|
+
connected: boolean;
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Services schema response from backend (new flat structure)
|
|
959
|
+
*/
|
|
960
|
+
interface ServicesSchema {
|
|
961
|
+
services: ServiceDefinition[];
|
|
962
|
+
templates: TemplateDefinition[];
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* @deprecated Use ServiceDefinition instead
|
|
966
|
+
* Integration endpoint metadata from backend schema (legacy)
|
|
967
|
+
*/
|
|
968
|
+
interface IntegrationEndpoint {
|
|
969
|
+
name: string;
|
|
970
|
+
description?: string;
|
|
971
|
+
path: string;
|
|
972
|
+
method?: string;
|
|
973
|
+
path_params?: string[];
|
|
974
|
+
schema?: Record<string, any>;
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* @deprecated Use ServicesSchema instead
|
|
978
|
+
* Integration package metadata from backend schema (legacy)
|
|
979
|
+
*/
|
|
980
|
+
interface IntegrationPackage {
|
|
981
|
+
package_name: string;
|
|
982
|
+
package_description?: string;
|
|
983
|
+
endpoints: IntegrationEndpoint[];
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* @deprecated Use ServicesSchema instead
|
|
987
|
+
* Integration schema response from backend (legacy)
|
|
988
|
+
*/
|
|
989
|
+
interface IntegrationSchema {
|
|
990
|
+
installed_packages: IntegrationPackage[];
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Available voice options for Live Voice AI
|
|
994
|
+
*/
|
|
995
|
+
type LiveVoiceVoice = 'Puck' | 'Charon' | 'Kore' | 'Fenrir' | 'Aoede';
|
|
996
|
+
/**
|
|
997
|
+
* Status of the live voice session
|
|
998
|
+
*/
|
|
999
|
+
type LiveVoiceStatus = 'idle' | 'connecting' | 'listening' | 'processing' | 'speaking' | 'disconnected' | 'error';
|
|
1000
|
+
/**
|
|
1001
|
+
* Configuration for creating a live voice session
|
|
1002
|
+
*/
|
|
1003
|
+
interface LiveVoiceConfig {
|
|
1004
|
+
/**
|
|
1005
|
+
* System instruction to guide AI behavior
|
|
1006
|
+
* @example "You are a helpful customer service agent for a pizza shop."
|
|
1007
|
+
*/
|
|
1008
|
+
systemInstruction?: string;
|
|
1009
|
+
/**
|
|
1010
|
+
* Voice to use for AI responses
|
|
1011
|
+
* @default 'Puck'
|
|
1012
|
+
*/
|
|
1013
|
+
voice?: LiveVoiceVoice;
|
|
1014
|
+
/**
|
|
1015
|
+
* Called when transcript is received (user or assistant speech)
|
|
1016
|
+
* @param text - Transcribed text
|
|
1017
|
+
* @param role - Who spoke ('user' or 'assistant')
|
|
1018
|
+
*/
|
|
1019
|
+
onTranscript?: (text: string, role: 'user' | 'assistant') => void;
|
|
1020
|
+
/**
|
|
1021
|
+
* Called when session status changes
|
|
1022
|
+
* @param status - New session status
|
|
1023
|
+
*/
|
|
1024
|
+
onStatusChange?: (status: LiveVoiceStatus) => void;
|
|
1025
|
+
/**
|
|
1026
|
+
* Called when an error occurs
|
|
1027
|
+
* @param error - Error that occurred
|
|
1028
|
+
*/
|
|
1029
|
+
onError?: (error: Error) => void;
|
|
1030
|
+
/**
|
|
1031
|
+
* Called when session is started (with session ID)
|
|
1032
|
+
* @param sessionId - Unique session identifier
|
|
1033
|
+
*/
|
|
1034
|
+
onSessionStarted?: (sessionId: string) => void;
|
|
1035
|
+
/**
|
|
1036
|
+
* Called when session ends
|
|
1037
|
+
* @param durationSeconds - Total session duration in seconds
|
|
1038
|
+
*/
|
|
1039
|
+
onSessionEnded?: (durationSeconds: number) => void;
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Live voice session interface for managing real-time voice conversations
|
|
1043
|
+
*/
|
|
1044
|
+
interface LiveVoiceSession {
|
|
1045
|
+
/**
|
|
1046
|
+
* Start the voice session
|
|
1047
|
+
* Requests microphone permission and establishes WebSocket connection
|
|
1048
|
+
*/
|
|
1049
|
+
start(): Promise<void>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Stop the voice session
|
|
1052
|
+
* Closes WebSocket and releases microphone
|
|
1053
|
+
*/
|
|
1054
|
+
stop(): Promise<void>;
|
|
1055
|
+
/**
|
|
1056
|
+
* Interrupt the AI while it's speaking
|
|
1057
|
+
* Use this when user wants to cut off the AI mid-sentence
|
|
1058
|
+
*/
|
|
1059
|
+
interrupt(): void;
|
|
1060
|
+
/**
|
|
1061
|
+
* Whether the session is currently active
|
|
1062
|
+
*/
|
|
1063
|
+
readonly isActive: boolean;
|
|
1064
|
+
/**
|
|
1065
|
+
* Current session status
|
|
1066
|
+
*/
|
|
1067
|
+
readonly status: LiveVoiceStatus;
|
|
1068
|
+
/**
|
|
1069
|
+
* Session ID (available after connection)
|
|
1070
|
+
*/
|
|
1071
|
+
readonly sessionId: string | null;
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Message types sent from client to server over WebSocket
|
|
1075
|
+
*/
|
|
1076
|
+
interface LiveVoiceClientMessage {
|
|
1077
|
+
type: 'audio' | 'config' | 'interrupt' | 'end';
|
|
1078
|
+
data?: ArrayBuffer;
|
|
1079
|
+
systemInstruction?: string;
|
|
1080
|
+
voice?: LiveVoiceVoice;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Message types sent from server to client over WebSocket
|
|
1084
|
+
*/
|
|
1085
|
+
interface LiveVoiceServerMessage {
|
|
1086
|
+
type: 'audio' | 'transcript' | 'status' | 'error' | 'session_started' | 'session_ended';
|
|
1087
|
+
data?: ArrayBuffer;
|
|
1088
|
+
text?: string;
|
|
1089
|
+
role?: 'user' | 'assistant';
|
|
1090
|
+
status?: LiveVoiceStatus;
|
|
1091
|
+
message?: string;
|
|
1092
|
+
code?: string;
|
|
1093
|
+
session_id?: string;
|
|
1094
|
+
duration_seconds?: number;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* Omnikit SDK v2.0 - Main Client
|
|
1099
|
+
*
|
|
1100
|
+
* Features:
|
|
1101
|
+
* - Auto-initialization on first use (no explicit initialize() required)
|
|
1102
|
+
* - Service role pattern for admin operations
|
|
1103
|
+
* - Automatic token detection from URL or localStorage
|
|
1104
|
+
* - Simplified integration access (no .call() needed)
|
|
1105
|
+
* - Enhanced collection operations (bulkCreate, bulkDelete, import, deleteAll)
|
|
1106
|
+
* - Improved auth module (isAuthenticated, me, updateMe)
|
|
1107
|
+
*/
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* Enhanced error class with helper methods
|
|
1111
|
+
*/
|
|
1112
|
+
declare class OmnikitError extends Error implements OmnikitError$1 {
|
|
1113
|
+
status?: number;
|
|
1114
|
+
code?: string;
|
|
1115
|
+
data?: any;
|
|
1116
|
+
isAuthError?: boolean;
|
|
1117
|
+
constructor(message: string, status?: number, code?: string, data?: any);
|
|
1118
|
+
isNotFound(): boolean;
|
|
1119
|
+
isForbidden(): boolean;
|
|
1120
|
+
isUnauthorized(): boolean;
|
|
1121
|
+
isBadRequest(): boolean;
|
|
1122
|
+
isServerError(): boolean;
|
|
1123
|
+
}
|
|
1124
|
+
declare class APIClient implements OmnikitClient {
|
|
1125
|
+
appId: string;
|
|
1126
|
+
baseUrl: string;
|
|
1127
|
+
private userToken;
|
|
1128
|
+
private _serviceToken;
|
|
1129
|
+
private _apiKey;
|
|
1130
|
+
private initialized;
|
|
1131
|
+
private initPromise;
|
|
1132
|
+
private _collections;
|
|
1133
|
+
private _services;
|
|
1134
|
+
private _integrations;
|
|
1135
|
+
private _auth;
|
|
1136
|
+
private _asServiceRole?;
|
|
1137
|
+
private _metadata;
|
|
1138
|
+
private _metadataListeners;
|
|
1139
|
+
private _userListeners;
|
|
1140
|
+
constructor(config: OmnikitConfig);
|
|
1141
|
+
/**
|
|
1142
|
+
* Load metadata from localStorage cache, falling back to initial config
|
|
1143
|
+
* Guards localStorage access for Deno/Node compatibility
|
|
1144
|
+
*/
|
|
1145
|
+
private loadCachedMetadata;
|
|
1146
|
+
/**
|
|
1147
|
+
* Update metadata cache in localStorage
|
|
1148
|
+
* IMPORTANT: Mutate in place to preserve object reference for exports
|
|
1149
|
+
*/
|
|
1150
|
+
private updateMetadataCache;
|
|
1151
|
+
/**
|
|
1152
|
+
* App metadata - available instantly without API call (no flicker!)
|
|
1153
|
+
*/
|
|
1154
|
+
get metadata(): {
|
|
1155
|
+
id: string;
|
|
1156
|
+
name: string;
|
|
1157
|
+
logoUrl: string;
|
|
1158
|
+
thumbnailUrl: string;
|
|
1159
|
+
visibility: string;
|
|
1160
|
+
platformAuthProviders: string[];
|
|
1161
|
+
};
|
|
1162
|
+
/**
|
|
1163
|
+
* Subscribe to metadata updates (for React components to trigger re-render)
|
|
1164
|
+
* @returns Unsubscribe function
|
|
1165
|
+
*/
|
|
1166
|
+
onMetadataChange(callback: () => void): () => void;
|
|
1167
|
+
/**
|
|
1168
|
+
* Subscribe to user state changes (for React auth state sync)
|
|
1169
|
+
* Called when user logs in, logs out, or updates profile
|
|
1170
|
+
* @returns Unsubscribe function
|
|
1171
|
+
*/
|
|
1172
|
+
onUserChange(callback: (user: UserInfo | null) => void): () => void;
|
|
1173
|
+
/**
|
|
1174
|
+
* Emit user change event to all listeners
|
|
1175
|
+
*/
|
|
1176
|
+
private emitUserChange;
|
|
1177
|
+
/**
|
|
1178
|
+
* Lazy getter for collections - auto-initializes on first access
|
|
1179
|
+
*/
|
|
1180
|
+
get collections(): Record<string, CollectionClass>;
|
|
1181
|
+
/**
|
|
1182
|
+
* @deprecated Use collections instead. This alias exists for backward compatibility.
|
|
1183
|
+
*/
|
|
1184
|
+
get entities(): Record<string, CollectionClass>;
|
|
1185
|
+
/**
|
|
1186
|
+
* Lazy getter for services (new flat structure) - auto-initializes on first access
|
|
1187
|
+
* Usage: omnikit.services.SendEmail({ to, subject, body })
|
|
1188
|
+
*/
|
|
1189
|
+
get services(): Record<string, IntegrationMethod>;
|
|
1190
|
+
/**
|
|
1191
|
+
* @deprecated Use services instead for flat access
|
|
1192
|
+
* Lazy getter for integrations - auto-initializes on first access
|
|
1193
|
+
*/
|
|
1194
|
+
get integrations(): Record<string, Record<string, IntegrationMethod>>;
|
|
1195
|
+
/**
|
|
1196
|
+
* Lazy getter for auth - auto-initializes on first access
|
|
1197
|
+
*/
|
|
1198
|
+
get auth(): AuthModule;
|
|
1199
|
+
/**
|
|
1200
|
+
* Lazy getter for service role operations
|
|
1201
|
+
* Only available when serviceToken is provided
|
|
1202
|
+
*/
|
|
1203
|
+
get asServiceRole(): ServiceRoleClient;
|
|
1204
|
+
/**
|
|
1205
|
+
* Create auth proxy that auto-initializes
|
|
1206
|
+
*/
|
|
1207
|
+
private createAuthProxy;
|
|
1208
|
+
/**
|
|
1209
|
+
* Convert PascalCase to snake_case
|
|
1210
|
+
* Example: PdfDocument -> pdf_document, UserProfile -> user_profile
|
|
1211
|
+
*/
|
|
1212
|
+
private toSnakeCase;
|
|
1213
|
+
/**
|
|
1214
|
+
* Create collections proxy that auto-initializes
|
|
1215
|
+
* @param useServiceToken - Whether to use service token for requests
|
|
1216
|
+
*/
|
|
1217
|
+
private createCollectionsProxy;
|
|
1218
|
+
/**
|
|
1219
|
+
* Poll for job completion with progress callbacks
|
|
1220
|
+
* @param jobId - Job ID to poll
|
|
1221
|
+
* @param options - Async options (onStatusChange, pollInterval, timeout)
|
|
1222
|
+
* @returns Final job result
|
|
1223
|
+
*/
|
|
1224
|
+
private pollJobUntilComplete;
|
|
1225
|
+
/**
|
|
1226
|
+
* Stream LLM response token by token via SSE
|
|
1227
|
+
* @param params - LLM request parameters with streaming callbacks
|
|
1228
|
+
* @returns Promise that resolves to the complete response string
|
|
1229
|
+
*/
|
|
1230
|
+
private streamLLMResponse;
|
|
1231
|
+
/**
|
|
1232
|
+
* Create services proxy that auto-initializes (new flat structure)
|
|
1233
|
+
* @param useServiceToken - Whether to use service token for requests
|
|
1234
|
+
*/
|
|
1235
|
+
private createServicesProxy;
|
|
1236
|
+
/**
|
|
1237
|
+
* @deprecated Use createServicesProxy instead
|
|
1238
|
+
* Create integrations proxy that auto-initializes
|
|
1239
|
+
* @param useServiceToken - Whether to use service token for requests
|
|
1240
|
+
*/
|
|
1241
|
+
private createIntegrationsProxy;
|
|
1242
|
+
/**
|
|
1243
|
+
* Ensure SDK is initialized (auto-initializes once on first call)
|
|
1244
|
+
*/
|
|
1245
|
+
ensureInitialized(): Promise<void>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Initialize SDK by fetching app schema and integration endpoints
|
|
1248
|
+
* This happens automatically on first use - no need to call explicitly
|
|
1249
|
+
*/
|
|
1250
|
+
private initialize;
|
|
1251
|
+
/**
|
|
1252
|
+
* Fetch app schema from backend
|
|
1253
|
+
*/
|
|
1254
|
+
private fetchAppSchema;
|
|
1255
|
+
/**
|
|
1256
|
+
* Fetch integration schema from backend
|
|
1257
|
+
* Returns ServicesSchema (new flat format) or IntegrationSchema (legacy)
|
|
1258
|
+
*/
|
|
1259
|
+
private fetchIntegrationSchema;
|
|
1260
|
+
/**
|
|
1261
|
+
* Create collection classes from schema
|
|
1262
|
+
*/
|
|
1263
|
+
private createCollections;
|
|
1264
|
+
/**
|
|
1265
|
+
* Create a single collection class with all CRUD operations
|
|
1266
|
+
* Automatically enhances User collection with convenience methods
|
|
1267
|
+
*/
|
|
1268
|
+
private createCollectionClass;
|
|
1269
|
+
/**
|
|
1270
|
+
* Create services from new flat schema (recommended)
|
|
1271
|
+
* Services are exposed as omnikit.services.ServiceName
|
|
1272
|
+
*/
|
|
1273
|
+
private createServicesFromSchema;
|
|
1274
|
+
/**
|
|
1275
|
+
* Create a service method from ServiceDefinition
|
|
1276
|
+
*/
|
|
1277
|
+
private createServiceMethod;
|
|
1278
|
+
/**
|
|
1279
|
+
* Handle file upload via presigned URL flow
|
|
1280
|
+
* Supports both public and private file uploads based on path
|
|
1281
|
+
*/
|
|
1282
|
+
private handleFileUpload;
|
|
1283
|
+
/**
|
|
1284
|
+
* @deprecated Use createServicesFromSchema instead
|
|
1285
|
+
* Create integration methods from legacy backend schema
|
|
1286
|
+
*/
|
|
1287
|
+
private createIntegrationsFromSchema;
|
|
1288
|
+
/**
|
|
1289
|
+
* @deprecated Backend now returns final method names
|
|
1290
|
+
* Format endpoint name to PascalCase method name (legacy)
|
|
1291
|
+
*/
|
|
1292
|
+
private formatMethodName;
|
|
1293
|
+
/**
|
|
1294
|
+
* Create integration method that calls backend endpoint
|
|
1295
|
+
*/
|
|
1296
|
+
private createIntegrationMethod;
|
|
1297
|
+
/**
|
|
1298
|
+
* Normalize integration response to add common aliases for bulletproof access
|
|
1299
|
+
* Prevents runtime errors from AI-generated code using wrong property names
|
|
1300
|
+
*/
|
|
1301
|
+
private normalizeIntegrationResponse;
|
|
1302
|
+
/**
|
|
1303
|
+
* HTTP request helper with JSON
|
|
1304
|
+
*/
|
|
1305
|
+
makeRequest(url: string, method?: string, data?: any, options?: RequestOptions): Promise<any>;
|
|
1306
|
+
/**
|
|
1307
|
+
* HTTP request helper with FormData (for file uploads)
|
|
1308
|
+
*/
|
|
1309
|
+
private makeRequestWithFormData;
|
|
1310
|
+
/**
|
|
1311
|
+
* Get app metadata (for internal use)
|
|
1312
|
+
*/
|
|
1313
|
+
getAppMetadata(): Promise<AppSchema>;
|
|
1314
|
+
/**
|
|
1315
|
+
* Set auth token
|
|
1316
|
+
*/
|
|
1317
|
+
setAuthToken(token: string): void;
|
|
1318
|
+
/**
|
|
1319
|
+
* Get current auth token
|
|
1320
|
+
*/
|
|
1321
|
+
getAuthToken(): string | null;
|
|
1322
|
+
/**
|
|
1323
|
+
* Clear auth token
|
|
1324
|
+
*/
|
|
1325
|
+
clearAuthToken(): void;
|
|
1326
|
+
/**
|
|
1327
|
+
* Create a live voice session for real-time voice conversation with AI.
|
|
1328
|
+
*
|
|
1329
|
+
* The session manages WebSocket communication, microphone capture, and audio playback.
|
|
1330
|
+
*
|
|
1331
|
+
* @example
|
|
1332
|
+
* ```typescript
|
|
1333
|
+
* const session = omnikit.createLiveVoiceSession({
|
|
1334
|
+
* systemInstruction: 'You are a helpful assistant.',
|
|
1335
|
+
* voice: 'Puck',
|
|
1336
|
+
* onTranscript: (text, role) => console.log(`${role}: ${text}`),
|
|
1337
|
+
* onStatusChange: (status) => console.log(`Status: ${status}`),
|
|
1338
|
+
* onError: (error) => console.error(error),
|
|
1339
|
+
* });
|
|
1340
|
+
*
|
|
1341
|
+
* await session.start();
|
|
1342
|
+
* // ... user speaks, AI responds ...
|
|
1343
|
+
* await session.stop();
|
|
1344
|
+
* ```
|
|
1345
|
+
*
|
|
1346
|
+
* @param config - Optional configuration for the voice session
|
|
1347
|
+
* @returns A LiveVoiceSession object to control the session
|
|
1348
|
+
*/
|
|
1349
|
+
createLiveVoiceSession(config?: LiveVoiceConfig): LiveVoiceSession;
|
|
1350
|
+
/**
|
|
1351
|
+
* Invoke a backend function by name.
|
|
1352
|
+
*
|
|
1353
|
+
* Backend functions are deployed to Supabase Edge Functions and can be invoked
|
|
1354
|
+
* from the frontend using this method.
|
|
1355
|
+
*
|
|
1356
|
+
* @example
|
|
1357
|
+
* ```typescript
|
|
1358
|
+
* // Invoke a function
|
|
1359
|
+
* const result = await omnikit.invokeFunction('processPayment', {
|
|
1360
|
+
* amount: 100,
|
|
1361
|
+
* userId: 'abc123'
|
|
1362
|
+
* });
|
|
1363
|
+
* console.log(result.transactionId); // Direct access to function response
|
|
1364
|
+
* ```
|
|
1365
|
+
*
|
|
1366
|
+
* @param functionName - Name of the function to invoke (matches filename without .js)
|
|
1367
|
+
* @param body - Optional request body to send to the function
|
|
1368
|
+
* @returns Response data from the function (unwrapped)
|
|
1369
|
+
* @throws Error if the function invocation fails
|
|
1370
|
+
*/
|
|
1371
|
+
invokeFunction(functionName: string, body?: Record<string, any>): Promise<any>;
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Factory function to create an Omnikit client
|
|
1375
|
+
*
|
|
1376
|
+
* @example
|
|
1377
|
+
* ```typescript
|
|
1378
|
+
* import { createClient } from '@omnikit/sdk';
|
|
1379
|
+
*
|
|
1380
|
+
* const omnikit = createClient({
|
|
1381
|
+
* appId: 'your-app-id',
|
|
1382
|
+
* // token auto-detected from URL or localStorage
|
|
1383
|
+
* });
|
|
1384
|
+
*
|
|
1385
|
+
* // Ready to use immediately - no initialize() needed!
|
|
1386
|
+
* const users = await omnikit.collections.User.list();
|
|
1387
|
+
* ```
|
|
1388
|
+
*/
|
|
1389
|
+
declare function createClient(config: OmnikitConfig): OmnikitClient;
|
|
1390
|
+
|
|
1391
|
+
/**
|
|
1392
|
+
* Live Voice Session Implementation
|
|
1393
|
+
*
|
|
1394
|
+
* Manages real-time bidirectional voice communication with Gemini Live API.
|
|
1395
|
+
* Handles microphone capture, audio playback, and WebSocket communication.
|
|
1396
|
+
*/
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1399
|
+
* Implementation of LiveVoiceSession
|
|
1400
|
+
*/
|
|
1401
|
+
declare class LiveVoiceSessionImpl implements LiveVoiceSession {
|
|
1402
|
+
private config?;
|
|
1403
|
+
private ws;
|
|
1404
|
+
private audioContext;
|
|
1405
|
+
private mediaStream;
|
|
1406
|
+
private scriptProcessor;
|
|
1407
|
+
private sourceNode;
|
|
1408
|
+
private gainNode;
|
|
1409
|
+
private playbackQueue;
|
|
1410
|
+
private isPlaying;
|
|
1411
|
+
private _isActive;
|
|
1412
|
+
private _status;
|
|
1413
|
+
private _sessionId;
|
|
1414
|
+
private baseUrl;
|
|
1415
|
+
private appId;
|
|
1416
|
+
private token;
|
|
1417
|
+
constructor(baseUrl: string, appId: string, token: string | null, config?: LiveVoiceConfig | undefined);
|
|
1418
|
+
get isActive(): boolean;
|
|
1419
|
+
get status(): LiveVoiceStatus;
|
|
1420
|
+
get sessionId(): string | null;
|
|
1421
|
+
/**
|
|
1422
|
+
* Start the voice session
|
|
1423
|
+
*/
|
|
1424
|
+
start(): Promise<void>;
|
|
1425
|
+
/**
|
|
1426
|
+
* Stop the voice session
|
|
1427
|
+
*/
|
|
1428
|
+
stop(): Promise<void>;
|
|
1429
|
+
/**
|
|
1430
|
+
* Interrupt the AI while speaking
|
|
1431
|
+
*/
|
|
1432
|
+
interrupt(): void;
|
|
1433
|
+
/**
|
|
1434
|
+
* Build WebSocket URL with auth and config
|
|
1435
|
+
*/
|
|
1436
|
+
private buildWebSocketUrl;
|
|
1437
|
+
/**
|
|
1438
|
+
* Connect to WebSocket server
|
|
1439
|
+
*/
|
|
1440
|
+
private connectWebSocket;
|
|
1441
|
+
/**
|
|
1442
|
+
* Handle incoming WebSocket messages
|
|
1443
|
+
*/
|
|
1444
|
+
private handleMessage;
|
|
1445
|
+
/**
|
|
1446
|
+
* Handle incoming audio data from Gemini
|
|
1447
|
+
*/
|
|
1448
|
+
private handleAudioData;
|
|
1449
|
+
/**
|
|
1450
|
+
* Play next audio chunk from queue
|
|
1451
|
+
*/
|
|
1452
|
+
private playNextChunk;
|
|
1453
|
+
/**
|
|
1454
|
+
* Set up audio capture from microphone
|
|
1455
|
+
*/
|
|
1456
|
+
private setupAudioCapture;
|
|
1457
|
+
/**
|
|
1458
|
+
* Simple linear resampling
|
|
1459
|
+
*/
|
|
1460
|
+
private resample;
|
|
1461
|
+
/**
|
|
1462
|
+
* Update status and notify callback
|
|
1463
|
+
*/
|
|
1464
|
+
private setStatus;
|
|
1465
|
+
/**
|
|
1466
|
+
* Clean up all resources
|
|
1467
|
+
*/
|
|
1468
|
+
private cleanup;
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
export { APIClient, type AppMetadata, type AppSchema, type AsyncJobCreatedResponse, type AsyncJobStatus, type AsyncJobStatusResponse, type AsyncJobType, type AsyncOptions, type AuthModule, type AuthResponse, type BuiltInIntegration, type BulkResult, type CachedMetadata, type CheckJobStatusParams, type CollectionClass, type CollectionDefinition, type CollectionField, type CollectionRecord, type EmailParams, type Entity, type EntityClass, type EntityDefinition, type EntityField, type EntityRecord, type ExtractParams, type ImageParams, type ImportResult, type InitialMetadata, type IntegrationEndpoint, type IntegrationMethod, type IntegrationPackage, type IntegrationSchema, type LLMMessage, type LLMModel, type LLMParams, type LLMStreamEvent, type LLMStreamResult, type ListOptions, type LiveVoiceClientMessage, type LiveVoiceConfig, type LiveVoiceServerMessage, type LiveVoiceSession, LiveVoiceSessionImpl, type LiveVoiceStatus, type LiveVoiceVoice, type OAuthProvider, type OAuthProvidersResponse, type OmnikitClient, type OmnikitConfig, OmnikitError, type QueryOptions, type RequestOptions, type SMSParams, type ServiceDefinition, type ServiceResponse, type ServiceRoleClient, type ServicesSchema, type SpeechParams, type TemplateDefinition, type UserCollectionClass, type UserEntityClass, type UserInfo, type VideoParams, type VideoStatusParams, createClient };
|