@backflow.sdk/admin 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.
@@ -0,0 +1,2499 @@
1
+ interface RequestContext {
2
+ method: string;
3
+ path: string;
4
+ params?: Record<string, unknown>;
5
+ body?: unknown;
6
+ startTime: number;
7
+ }
8
+ interface ResponseContext extends RequestContext {
9
+ status: number;
10
+ duration: number;
11
+ response?: unknown;
12
+ error?: Error;
13
+ }
14
+ type RequestMiddleware = (ctx: RequestContext) => RequestContext | void | Promise<RequestContext | void>;
15
+ type ResponseMiddleware = (ctx: ResponseContext) => void | Promise<void>;
16
+ interface BackflowMiddleware {
17
+ onRequest?: RequestMiddleware;
18
+ onResponse?: ResponseMiddleware;
19
+ }
20
+ interface BackflowConfig {
21
+ clientKey?: string;
22
+ getAuthToken?: () => Promise<string>;
23
+ endpoint?: string;
24
+ middleware?: BackflowMiddleware;
25
+ debug?: boolean;
26
+ }
27
+ interface RequestOptions extends Omit<RequestInit, "body"> {
28
+ params?: Record<string, string | number | boolean | undefined>;
29
+ body?: unknown;
30
+ }
31
+ type HttpMethod = "get" | "post" | "put" | "patch" | "delete";
32
+ interface BackflowResponse<T> {
33
+ data: T;
34
+ status: number;
35
+ headers: Headers;
36
+ }
37
+ interface BackflowError extends Error {
38
+ status: number;
39
+ code?: string;
40
+ details?: unknown;
41
+ }
42
+ interface SSESubscribeHandlers<T = unknown> {
43
+ onConnected?: () => void;
44
+ onComplete?: (data: T) => void;
45
+ onFailed?: (error: string) => void;
46
+ onProgress?: (progress: number, message?: string) => void;
47
+ onWarning?: (message: string) => void;
48
+ onError?: (error: Event) => void;
49
+ }
50
+ type DatabaseProvider = 'supabase' | 'firebase' | 'sqlite' | 'custom' | string;
51
+ type DatabaseFilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'in' | 'is';
52
+ interface DatabaseFilter {
53
+ column: string;
54
+ operator: DatabaseFilterOperator;
55
+ value: unknown;
56
+ }
57
+ interface ChainedDatabaseQuery {
58
+ table: string;
59
+ operation?: 'select' | 'insert' | 'update' | 'delete';
60
+ filters?: DatabaseFilter[];
61
+ data?: Record<string, unknown>;
62
+ select?: string;
63
+ single?: boolean;
64
+ order?: {
65
+ column: string;
66
+ ascending?: boolean;
67
+ };
68
+ limit?: number;
69
+ offset?: number;
70
+ as: string;
71
+ }
72
+ interface DatabaseIntegrationAction {
73
+ type: 'database';
74
+ action: 'select' | 'insert' | 'update' | 'upsert' | 'delete';
75
+ table: string;
76
+ data?: Record<string, unknown>;
77
+ filters?: DatabaseFilter[];
78
+ select?: string;
79
+ orderBy?: {
80
+ column: string;
81
+ direction?: 'asc' | 'desc';
82
+ };
83
+ limit?: number;
84
+ offset?: number;
85
+ single?: boolean;
86
+ provider?: DatabaseProvider;
87
+ or?: Omit<DatabaseIntegrationAction, 'type' | 'action' | 'or' | 'chain'>[];
88
+ chain?: ChainedDatabaseQuery[];
89
+ saveResponseAs?: string;
90
+ }
91
+
92
+ declare class BackflowClient {
93
+ private config;
94
+ private tokenCache;
95
+ private tokenPromise;
96
+ constructor(config: BackflowConfig);
97
+ private exchangeApiKeyForToken;
98
+ private getToken;
99
+ get endpoint(): string;
100
+ request<T>(path: string, options?: RequestOptions): Promise<T>;
101
+ get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
102
+ post<T>(path: string, body?: unknown, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
103
+ put<T>(path: string, body?: unknown, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
104
+ patch<T>(path: string, body?: unknown, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
105
+ delete<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
106
+ upload<T>(path: string, files: File | File[], metadata?: Record<string, string>): Promise<T>;
107
+ createWebSocket(room: string): WebSocket;
108
+ subscribeSSE<T = unknown>(path: string, handlers: SSESubscribeHandlers<T>): () => void;
109
+ }
110
+
111
+ declare class AgentAnalysisResource {
112
+ private client;
113
+ constructor(client: BackflowClient);
114
+ /** Retrieve cached analysis results from a previous scan */
115
+ get(executionId: string): Promise<unknown>;
116
+ /** Apply fixes from cached analysis. In hybrid mode, returns fix instructions for local MCP execution. */
117
+ createApply(executionId: string, data: Record<string, unknown>): Promise<unknown>;
118
+ }
119
+
120
+ declare class AnalyticsResource$1 {
121
+ private client;
122
+ constructor(client: BackflowClient);
123
+ /** Get high-level analytics overview (tenant-isolated) */
124
+ list(): Promise<unknown>;
125
+ /** Get endpoint statistics (tenant-isolated) */
126
+ listEndpoints(): Promise<unknown>;
127
+ /** Get recent errors (tenant-isolated) */
128
+ listErrors(): Promise<unknown>;
129
+ /** Get device type breakdown (tenant-isolated) */
130
+ listDevices(): Promise<unknown>;
131
+ /** Get geographic distribution of requests (tenant-isolated) */
132
+ listGeography(): Promise<unknown>;
133
+ /** Get time series data (tenant-isolated) */
134
+ listTimeseries(): Promise<unknown>;
135
+ /** Get endpoints that haven't been called recently (tenant-isolated) */
136
+ listUnusedEndpoints(): Promise<unknown>;
137
+ }
138
+
139
+ declare class ApiKeysResource$1 {
140
+ private client;
141
+ constructor(client: BackflowClient);
142
+ /** List API keys */
143
+ list(): Promise<unknown>;
144
+ /** Create API key */
145
+ create(data: Record<string, unknown>): Promise<unknown>;
146
+ /** Revoke API key */
147
+ delete(keyId: string): Promise<unknown>;
148
+ /** Rotate API key */
149
+ rotate(keyId: string, data: Record<string, unknown>): Promise<unknown>;
150
+ }
151
+
152
+ declare class AppsResource$1 {
153
+ private client;
154
+ constructor(client: BackflowClient);
155
+ /** Create a new app (available to all authenticated users) */
156
+ create(data: Record<string, unknown>): Promise<unknown>;
157
+ /** Get current app usage and limits */
158
+ list(): Promise<unknown>;
159
+ /** Update app settings (name and environment only) */
160
+ patch(data: Record<string, unknown>): Promise<unknown>;
161
+ }
162
+
163
+ declare class AssetsResource {
164
+ private client;
165
+ constructor(client: BackflowClient);
166
+ /** Upload asset to R2 with Firebase metadata */
167
+ create(data: Record<string, unknown>): Promise<unknown>;
168
+ /** List user assets */
169
+ list(): Promise<unknown>;
170
+ /** Get asset by ID */
171
+ get(id: string): Promise<unknown>;
172
+ /** Delete asset from R2 and Firebase */
173
+ delete(id: string): Promise<unknown>;
174
+ /** Update asset metadata */
175
+ updateMetadata(id: string, data: Record<string, unknown>): Promise<unknown>;
176
+ }
177
+
178
+ declare class AuthenticationResource {
179
+ private client;
180
+ constructor(client: BackflowClient);
181
+ /** Login with email and password. Returns JWT token if MFA is disabled, or requires MFA verification if enabled. */
182
+ create(data: Record<string, unknown>): Promise<unknown>;
183
+ /** Complete login with MFA verification. Supports TOTP tokens and backup codes. */
184
+ createMfa(data: Record<string, unknown>): Promise<unknown>;
185
+ /** Verify MFA token without full login. Production endpoint for token validation. */
186
+ createVerifyMfaToken(data: Record<string, unknown>): Promise<unknown>;
187
+ /** Switch to a different tenant. Returns a new JWT with tenantId claim. */
188
+ createSwitchTenant(data: Record<string, unknown>): Promise<unknown>;
189
+ /** Exchange API key for JWT token. Used by SDK for programmatic access. */
190
+ createToken(data: Record<string, unknown>): Promise<unknown>;
191
+ /** Request password reset email */
192
+ createForgotPassword(data: Record<string, unknown>): Promise<unknown>;
193
+ /** Verify password reset token is valid */
194
+ createVerifyResetToken(data: Record<string, unknown>): Promise<unknown>;
195
+ /** Reset password with valid token */
196
+ createResetPassword(data: Record<string, unknown>): Promise<unknown>;
197
+ }
198
+
199
+ declare class BillingResource {
200
+ private client;
201
+ constructor(client: BackflowClient);
202
+ /** Get all available billing plans with feature limits */
203
+ list(): Promise<unknown>;
204
+ /** Get current usage statistics against plan limits (tenant-isolated) */
205
+ listUsage(): Promise<unknown>;
206
+ /** Get current subscription status and details (tenant-isolated) */
207
+ listSubscription(): Promise<unknown>;
208
+ /** Request to upgrade to a different plan (tenant-isolated) */
209
+ create(data: Record<string, unknown>): Promise<unknown>;
210
+ /** List products from tenant's Polar organization */
211
+ listProducts(): Promise<unknown>;
212
+ /** Create a product in tenant's Polar organization */
213
+ createProducts(data: Record<string, unknown>): Promise<unknown>;
214
+ /** Create a checkout session for a user in tenant's Polar org */
215
+ createCheckout(data: Record<string, unknown>): Promise<unknown>;
216
+ /** List customers from tenant's Polar organization */
217
+ listCustomers(): Promise<unknown>;
218
+ /** List subscriptions from tenant's Polar organization */
219
+ listSubscriptions(): Promise<unknown>;
220
+ /** Cancel a subscription in tenant's Polar organization */
221
+ delete(id: string): Promise<unknown>;
222
+ /** Get customer subscription state from tenant's Polar organization */
223
+ state(id: string): Promise<unknown>;
224
+ /** Stripe webhook handler for subscription events */
225
+ createStripe(data: Record<string, unknown>): Promise<unknown>;
226
+ /** Polar webhook handler for subscription events */
227
+ createPolar(data: Record<string, unknown>): Promise<unknown>;
228
+ }
229
+
230
+ declare class CacheResource$1 {
231
+ private client;
232
+ constructor(client: BackflowClient);
233
+ /** Get cache statistics including hit rate, memory usage, and item count */
234
+ list(): Promise<unknown>;
235
+ /** Clear all items from the cache and reset statistics */
236
+ delete(): Promise<unknown>;
237
+ /** Invalidate all cache entries that match a given pattern */
238
+ create(data: Record<string, unknown>): Promise<unknown>;
239
+ /** Reset cache hit/miss statistics while preserving cached data */
240
+ createResetStats(data: Record<string, unknown>): Promise<unknown>;
241
+ }
242
+
243
+ declare class ConfigResource {
244
+ private client;
245
+ constructor(client: BackflowClient);
246
+ /** Get active tenant configuration */
247
+ list(): Promise<unknown>;
248
+ /** Upload or update tenant configuration */
249
+ create(data: Record<string, unknown>): Promise<unknown>;
250
+ /** List configuration versions */
251
+ listVersions(): Promise<unknown>;
252
+ /** Rollback configuration */
253
+ createRollback(version: string, data: Record<string, unknown>): Promise<unknown>;
254
+ /** Get available webhook events */
255
+ listEvents(): Promise<unknown>;
256
+ }
257
+
258
+ declare class DefaultResource {
259
+ private client;
260
+ constructor(client: BackflowClient);
261
+ /** GET /tenant/debug/raw-query */
262
+ list(): Promise<unknown>;
263
+ }
264
+
265
+ declare class DeploymentResource {
266
+ private client;
267
+ constructor(client: BackflowClient);
268
+ /** Get deployment information */
269
+ list(): Promise<unknown>;
270
+ /** Get server information */
271
+ listServer(): Promise<unknown>;
272
+ /** Get full deployment status */
273
+ listStatus(): Promise<unknown>;
274
+ /** Get Cloud Run service URL */
275
+ listUrl(): Promise<unknown>;
276
+ /** Server-Sent Events (SSE) stream for real-time deployment status updates. Sends periodic status updates and heartbeats. */
277
+ listStream(): Promise<unknown>;
278
+ /** Filtered Server-Sent Events (SSE) stream for specific deployment event types. Filter by status, server, or url events. */
279
+ listEvents(): Promise<unknown>;
280
+ }
281
+
282
+ declare class DomainsResource$1 {
283
+ private client;
284
+ constructor(client: BackflowClient);
285
+ /** List domains */
286
+ list(): Promise<unknown>;
287
+ /** Add domain */
288
+ create(data: Record<string, unknown>): Promise<unknown>;
289
+ /** Remove domain */
290
+ delete(domain: string): Promise<unknown>;
291
+ /** Verify domain */
292
+ createVerify(domain: string, data: Record<string, unknown>): Promise<unknown>;
293
+ /** Get verification instructions */
294
+ verification(domain: string): Promise<unknown>;
295
+ }
296
+
297
+ declare class EmbeddingsResource$1 {
298
+ private client;
299
+ constructor(client: BackflowClient);
300
+ /** List all embedded documents with chunk counts and metadata */
301
+ list(): Promise<unknown>;
302
+ /** Upload and process a document for vector embeddings with automatic chunking. Supports various content types (code, documentation, articles) with optimized chunking strategies for RAG. */
303
+ create(data: Record<string, unknown>): Promise<unknown>;
304
+ /** Search within a specific document using semantic similarity. Performs vector search within document chunks. */
305
+ search(documentId: string): Promise<unknown>;
306
+ /** Search across all embedded documents using semantic similarity */
307
+ listSearch(): Promise<unknown>;
308
+ /** Delete all chunks and embeddings for a document. Removes the document from the vector store. */
309
+ delete(documentId: string): Promise<unknown>;
310
+ /** Process multiple documents (up to 50) for vector embeddings in a single batch. Supports both raw text and file references (PDF, DOCX, TXT, MD). Uses 3 concurrent processing threads. */
311
+ createBatch(data: Record<string, unknown>): Promise<unknown>;
312
+ }
313
+
314
+ declare class FeedbackResource {
315
+ private client;
316
+ constructor(client: BackflowClient);
317
+ /** Submit feedback for a workflow execution. Used to optimize and improve workflow performance based on user ratings and suggestions. */
318
+ create(data: Record<string, unknown>): Promise<unknown>;
319
+ /** Get feedback trends and analytics. Analyzes workflow feedback to identify patterns and areas for improvement. */
320
+ list(): Promise<unknown>;
321
+ }
322
+
323
+ declare class FilesResource$1 {
324
+ private client;
325
+ constructor(client: BackflowClient);
326
+ /** Upload a single file with entity association and tenant isolation */
327
+ create(data: Record<string, unknown>): Promise<unknown>;
328
+ /** Upload multiple files with entity association and tenant isolation */
329
+ createUploadMultiple(data: Record<string, unknown>): Promise<unknown>;
330
+ /** List files for an entity with pagination */
331
+ get(entityType: string, entityId: string): Promise<unknown>;
332
+ /** Delete all files for an entity */
333
+ delete(entityType: string, entityId: string): Promise<unknown>;
334
+ /** Download file via secure signed URL redirect (5 minute expiry) */
335
+ getDownload(bucket: string, path: string): Promise<unknown>;
336
+ /** Get a signed URL for file access (max 30 seconds expiry) */
337
+ getSignedUrl(bucket: string, path: string): Promise<unknown>;
338
+ /** Delete a file from storage */
339
+ deleteDELETE(bucket: string, path: string): Promise<unknown>;
340
+ /** Upload JSON content to storage */
341
+ createUploadJson(data: Record<string, unknown>): Promise<unknown>;
342
+ }
343
+
344
+ declare class GithubResource$1 {
345
+ private client;
346
+ constructor(client: BackflowClient);
347
+ /** Get GitHub repositories for a user */
348
+ get(username: string): Promise<unknown>;
349
+ /** Get file or directory contents from a GitHub repository */
350
+ getContent(owner: string, repo: string, path: string): Promise<unknown>;
351
+ /** Create or update a file in a GitHub repository */
352
+ updateContent(owner: string, repo: string, path: string, data: Record<string, unknown>): Promise<unknown>;
353
+ /** Delete a file from a GitHub repository */
354
+ deleteContent(owner: string, repo: string, path: string): Promise<unknown>;
355
+ /** Compare two commits and view the diff */
356
+ getCompare(owner: string, repo: string, basehead: string): Promise<unknown>;
357
+ /** Get a single commit with its changes */
358
+ getCommit(owner: string, repo: string, ref: string): Promise<unknown>;
359
+ /** List commits in a repository */
360
+ commits(owner: string, repo: string): Promise<unknown>;
361
+ /** Get pull request details */
362
+ getPull(owner: string, repo: string, pull_number: string): Promise<unknown>;
363
+ /** List files changed in a pull request with diffs */
364
+ files(owner: string, repo: string, pull_number: string): Promise<unknown>;
365
+ }
366
+
367
+ declare class GoalsResource {
368
+ private client;
369
+ constructor(client: BackflowClient);
370
+ /** Configure goal evaluation rules for a workflow. Sets KPIs, success criteria, and evaluation parameters. */
371
+ create(data: Record<string, unknown>): Promise<unknown>;
372
+ /** Manually trigger goal evaluation for a workflow. Evaluates workflow performance against configured KPIs and success criteria. */
373
+ createEvaluate(workflowId: string, data: Record<string, unknown>): Promise<unknown>;
374
+ /** Get evaluation history for a workflow. Returns all historical goal evaluation records. */
375
+ get(workflowId: string): Promise<unknown>;
376
+ /** Start scheduled goal evaluation. Automatically evaluates all active workflows at specified intervals. */
377
+ createStart(data: Record<string, unknown>): Promise<unknown>;
378
+ /** Stop scheduled goal evaluation. Cancels automatic workflow evaluations. */
379
+ createStop(data: Record<string, unknown>): Promise<unknown>;
380
+ /** Evaluate all active workflows. Generates evaluation reports for all workflows with configured goals. */
381
+ createEvaluateAll(data: Record<string, unknown>): Promise<unknown>;
382
+ }
383
+
384
+ declare class GoogleDriveResource {
385
+ private client;
386
+ constructor(client: BackflowClient);
387
+ /** List files in Google Drive */
388
+ list(): Promise<unknown>;
389
+ /** Get file metadata from Google Drive */
390
+ get(fileId: string): Promise<unknown>;
391
+ /** Update file metadata (rename, move) */
392
+ patch(fileId: string, data: Record<string, unknown>): Promise<unknown>;
393
+ /** Delete a file from Google Drive */
394
+ delete(fileId: string): Promise<unknown>;
395
+ /** Download file content from Google Drive */
396
+ download(fileId: string): Promise<unknown>;
397
+ /** Search for PDF files in Google Drive */
398
+ listPdfs(): Promise<unknown>;
399
+ }
400
+
401
+ declare class JiraResource {
402
+ private client;
403
+ constructor(client: BackflowClient);
404
+ /** Search JIRA issues using JQL */
405
+ list(): Promise<unknown>;
406
+ /** Get JIRA issue details */
407
+ get(issueKey: string): Promise<unknown>;
408
+ /** Update a JIRA issue */
409
+ update(issueKey: string, data: Record<string, unknown>): Promise<unknown>;
410
+ /** Delete a JIRA issue */
411
+ delete(issueKey: string): Promise<unknown>;
412
+ /** Create a new JIRA issue */
413
+ create(data: Record<string, unknown>): Promise<unknown>;
414
+ /** Get available transitions for a JIRA issue */
415
+ transitions(issueKey: string): Promise<unknown>;
416
+ /** Transition a JIRA issue to new status */
417
+ createTransition(issueKey: string, data: Record<string, unknown>): Promise<unknown>;
418
+ /** Get comments for a JIRA issue */
419
+ comments(issueKey: string): Promise<unknown>;
420
+ /** Add comment to a JIRA issue */
421
+ createComment(issueKey: string, data: Record<string, unknown>): Promise<unknown>;
422
+ /** Assign a JIRA issue to a user */
423
+ updateAssign(issueKey: string, data: Record<string, unknown>): Promise<unknown>;
424
+ /** Get all JIRA projects */
425
+ listProjects(): Promise<unknown>;
426
+ /** Get JIRA project details */
427
+ getProjects(projectKey: string): Promise<unknown>;
428
+ /** Get current authenticated JIRA user */
429
+ listMe(): Promise<unknown>;
430
+ /** Search JIRA users */
431
+ listSearch(): Promise<unknown>;
432
+ /** Get all JIRA issue types */
433
+ listIssueTypes(): Promise<unknown>;
434
+ /** Get all JIRA priority levels */
435
+ listPriorities(): Promise<unknown>;
436
+ }
437
+
438
+ declare class LlmResource {
439
+ private client;
440
+ constructor(client: BackflowClient);
441
+ /** POST /llm/stream */
442
+ create(data: Record<string, unknown>): Promise<unknown>;
443
+ /** GET /llm/models */
444
+ list(): Promise<unknown>;
445
+ }
446
+
447
+ declare class McpToolsResource {
448
+ private client;
449
+ constructor(client: BackflowClient);
450
+ /** List all available MCP tools from connected servers. Returns tools, connection status, and server information. */
451
+ list(): Promise<unknown>;
452
+ /** Execute a Model Context Protocol (MCP) tool. MCP tools provide external capabilities like file system access, database queries, and API calls to LLM workflows. */
453
+ create(data: Record<string, unknown>): Promise<unknown>;
454
+ }
455
+
456
+ declare class MfaResource {
457
+ private client;
458
+ constructor(client: BackflowClient);
459
+ /** Initialize MFA setup for the authenticated user. Generates TOTP secret, QR code, and backup codes. Requires JWT authentication. */
460
+ create(data: Record<string, unknown>): Promise<unknown>;
461
+ /** Verify MFA setup with a TOTP token from authenticator app and enable MFA for the account. Requires JWT authentication. */
462
+ createVerify(data: Record<string, unknown>): Promise<unknown>;
463
+ /** Disable MFA for the authenticated user. Requires current valid MFA token for security verification. */
464
+ createDisable(data: Record<string, unknown>): Promise<unknown>;
465
+ /** Check MFA status for the authenticated user. Returns whether MFA is enabled and setup dates. */
466
+ list(): Promise<unknown>;
467
+ /** Generate new backup codes for MFA recovery. Invalidates all previous backup codes. Requires current MFA token for security. */
468
+ createRegenerateBackupCodes(data: Record<string, unknown>): Promise<unknown>;
469
+ /** Validate an MFA token without side effects. Useful for protecting sensitive operations with MFA verification. */
470
+ createValidate(data: Record<string, unknown>): Promise<unknown>;
471
+ }
472
+
473
+ declare class MigrationResource {
474
+ private client;
475
+ constructor(client: BackflowClient);
476
+ /** Get database migration SQL and instructions */
477
+ list(): Promise<unknown>;
478
+ /** Check if database migration has been applied */
479
+ listStatus(): Promise<unknown>;
480
+ /** Get quick migration with RLS disabled for development */
481
+ listQuickFix(): Promise<unknown>;
482
+ }
483
+
484
+ declare class PolarResource {
485
+ private client;
486
+ constructor(client: BackflowClient);
487
+ /** Create a Polar checkout session */
488
+ create(data: Record<string, unknown>): Promise<unknown>;
489
+ /** Retrieve a Polar checkout session */
490
+ get(checkoutId: string): Promise<unknown>;
491
+ /** Create a Polar subscription */
492
+ createSubscriptions(data: Record<string, unknown>): Promise<unknown>;
493
+ /** Cancel a Polar subscription */
494
+ delete(subscriptionId: string): Promise<unknown>;
495
+ /** List Polar products */
496
+ list(): Promise<unknown>;
497
+ /** Create a Polar product */
498
+ createProducts(data: Record<string, unknown>): Promise<unknown>;
499
+ /** Retrieve a Polar order */
500
+ getOrders(orderId: string): Promise<unknown>;
501
+ /** Create a Polar benefit */
502
+ createBenefits(data: Record<string, unknown>): Promise<unknown>;
503
+ /** Grant a Polar benefit to a customer */
504
+ createGrants(data: Record<string, unknown>): Promise<unknown>;
505
+ }
506
+
507
+ declare class ProjectsResource {
508
+ private client;
509
+ constructor(client: BackflowClient);
510
+ /** List version history for a project with pagination and date range filter */
511
+ versions(id: string): Promise<unknown>;
512
+ /** Create a new project version record (Pro tier) */
513
+ createVersion(id: string, data: Record<string, unknown>): Promise<unknown>;
514
+ /** Delete all versions for a project and their R2 files (parallel) */
515
+ deleteAllVersions(id: string): Promise<unknown>;
516
+ /** Get a specific version record */
517
+ getVersion(id: string, versionId: string): Promise<unknown>;
518
+ /** Delete a specific project version and its R2 files */
519
+ deleteVersion(id: string, versionId: string): Promise<unknown>;
520
+ /** Rollback project to a previous version (Pro tier) */
521
+ rollback(id: string, version: string, data: Record<string, unknown>): Promise<unknown>;
522
+ /** Save project with parallel R2 uploads and Firestore updates */
523
+ updateSave(projectId: string, data: Record<string, unknown>): Promise<unknown>;
524
+ /** Save project and execute content as workflow */
525
+ saveAndRun(projectId: string, data: Record<string, unknown>): Promise<unknown>;
526
+ /** Get project by ID */
527
+ get(id: string): Promise<unknown>;
528
+ /** Update project metadata (title, description, etc.) */
529
+ patch(id: string, data: Record<string, unknown>): Promise<unknown>;
530
+ /** Delete project and all related files/versions (parallel) */
531
+ delete(id: string): Promise<unknown>;
532
+ /** List all shares for a project */
533
+ shares(id: string): Promise<unknown>;
534
+ /** Share a project with another user */
535
+ share(id: string, data: Record<string, unknown>): Promise<unknown>;
536
+ /** Remove share access from a user */
537
+ deleteShare(id: string, userId: string): Promise<unknown>;
538
+ /** Get public project by ID (no auth required) */
539
+ public(projectId: string): Promise<unknown>;
540
+ /** Toggle project public/private status with optional email notification */
541
+ patchPublic(id: string, data: Record<string, unknown>): Promise<unknown>;
542
+ /** List all projects shared with the current user */
543
+ list(): Promise<unknown>;
544
+ /** Update project files (add/remove attached assets) */
545
+ patchFile(id: string, data: Record<string, unknown>): Promise<unknown>;
546
+ }
547
+
548
+ declare class PublishResource {
549
+ private client;
550
+ constructor(client: BackflowClient);
551
+ /** Initialize publishing system - checks database setup */
552
+ create(data: Record<string, unknown>): Promise<unknown>;
553
+ /** Verify database migration was applied */
554
+ createVerify(data: Record<string, unknown>): Promise<unknown>;
555
+ /** Publish an entity (checks database readiness automatically) */
556
+ createEntity(data: Record<string, unknown>): Promise<unknown>;
557
+ }
558
+
559
+ declare class QueuesResource$1 {
560
+ private client;
561
+ constructor(client: BackflowClient);
562
+ /** Get all queues and their statistics (tenant-isolated) */
563
+ list(): Promise<unknown>;
564
+ /** Get statistics for a specific queue (tenant-isolated) */
565
+ stats(name: string): Promise<unknown>;
566
+ /** Get jobs from a queue (tenant-isolated) */
567
+ jobs(name: string): Promise<unknown>;
568
+ /** Add a job to the queue (with tenant isolation) */
569
+ createJob(name: string, data: Record<string, unknown>): Promise<unknown>;
570
+ /** Get a specific job (tenant-isolated) */
571
+ getJob(name: string, jobId: string): Promise<unknown>;
572
+ /** Retry a failed job (tenant-isolated) */
573
+ retry(name: string, jobId: string, data: Record<string, unknown>): Promise<unknown>;
574
+ /** Pause a queue (admin only - affects all tenants) */
575
+ pause(name: string, data: Record<string, unknown>): Promise<unknown>;
576
+ /** Resume a paused queue (admin only - affects all tenants) */
577
+ resume(name: string, data: Record<string, unknown>): Promise<unknown>;
578
+ /** Clean old jobs from queue (tenant-isolated) */
579
+ createClean(name: string, data: Record<string, unknown>): Promise<unknown>;
580
+ /** Get detailed performance metrics for a queue */
581
+ metrics(name: string): Promise<unknown>;
582
+ }
583
+
584
+ declare class SearchResource$1 {
585
+ private client;
586
+ constructor(client: BackflowClient);
587
+ /** Fast search across an entity with configurable modes (exact, fuzzy, hybrid) */
588
+ get(entity: string): Promise<unknown>;
589
+ /** Index entity records for vector search */
590
+ create(data: Record<string, unknown>): Promise<unknown>;
591
+ /** Delete and reindex all records for an entity */
592
+ createReindex(data: Record<string, unknown>): Promise<unknown>;
593
+ /** Delete all indexed records for an entity */
594
+ delete(entity: string): Promise<unknown>;
595
+ /** Get search index statistics */
596
+ list(): Promise<unknown>;
597
+ }
598
+
599
+ declare class SecretsResource$1 {
600
+ private client;
601
+ constructor(client: BackflowClient);
602
+ /** List secrets */
603
+ list(): Promise<unknown>;
604
+ /** Store a secret */
605
+ create(data: Record<string, unknown>): Promise<unknown>;
606
+ /** Delete a secret */
607
+ delete(key: string): Promise<unknown>;
608
+ /** Rotate a secret */
609
+ rotate(key: string, data: Record<string, unknown>): Promise<unknown>;
610
+ }
611
+
612
+ declare class StripeResource {
613
+ private client;
614
+ constructor(client: BackflowClient);
615
+ /** Create a Stripe customer */
616
+ create(data: Record<string, unknown>): Promise<unknown>;
617
+ /** Create a Stripe payment intent */
618
+ createPaymentIntents(data: Record<string, unknown>): Promise<unknown>;
619
+ /** Create a Stripe subscription */
620
+ createSubscriptions(data: Record<string, unknown>): Promise<unknown>;
621
+ }
622
+
623
+ declare class SystemResource {
624
+ private client;
625
+ constructor(client: BackflowClient);
626
+ /** Get comprehensive system information including routes, providers, and integrations */
627
+ list(): Promise<unknown>;
628
+ /** Get detailed information about all registered routes including tenant-specific custom routes */
629
+ listRoutes(): Promise<unknown>;
630
+ /** Get detailed information about all available integrations */
631
+ listIntegrations(): Promise<unknown>;
632
+ /** Get information about the versioning system and how to use it */
633
+ listVersioning(): Promise<unknown>;
634
+ /** Get information about the caching system */
635
+ listCache(): Promise<unknown>;
636
+ /** Get information about the multi-tenancy system */
637
+ listMultiTenancy(): Promise<unknown>;
638
+ /** Get information about tenant configuration management */
639
+ listTenantConfig(): Promise<unknown>;
640
+ /** Get information about role-based access control */
641
+ listRbac(): Promise<unknown>;
642
+ /** Get information about rate limiting */
643
+ listRateLimiting(): Promise<unknown>;
644
+ /** Get information about the queue system */
645
+ listQueues(): Promise<unknown>;
646
+ /** Get information about the events system */
647
+ listEvents(): Promise<unknown>;
648
+ /** Get information about webhooks */
649
+ listWebhooks(): Promise<unknown>;
650
+ /** Get information about file storage */
651
+ listFileStorage(): Promise<unknown>;
652
+ /** Get information about multi-factor authentication */
653
+ listMfa(): Promise<unknown>;
654
+ /** Get information about analytics */
655
+ listAnalytics(): Promise<unknown>;
656
+ /** Get information about billing and subscriptions */
657
+ listBilling(): Promise<unknown>;
658
+ /** Get information about notifications */
659
+ listNotifications(): Promise<unknown>;
660
+ /** Get information about WebSocket and real-time features */
661
+ listWebsocket(): Promise<unknown>;
662
+ /** Get information about the agent and AI system */
663
+ listAgent(): Promise<unknown>;
664
+ /** Get information about authentication */
665
+ listAuth(): Promise<unknown>;
666
+ /** Get information about encryption and security */
667
+ listEncryption(): Promise<unknown>;
668
+ /** Get information about database migrations */
669
+ listMigrations(): Promise<unknown>;
670
+ /** Get information about route aliasing */
671
+ listRouteAliasing(): Promise<unknown>;
672
+ /** Get information about the publishing system */
673
+ listPublishing(): Promise<unknown>;
674
+ /** Get information about deployment tracking */
675
+ listDeployment(): Promise<unknown>;
676
+ /** Get information about OpenAPI documentation */
677
+ listOpenapi(): Promise<unknown>;
678
+ /** Get information about gRPC support */
679
+ listGrpc(): Promise<unknown>;
680
+ /** Get information about microservices architecture */
681
+ listMicroservices(): Promise<unknown>;
682
+ /** Get information about domain management */
683
+ listDomains(): Promise<unknown>;
684
+ /** Get information about LLM streaming */
685
+ listLlmStreaming(): Promise<unknown>;
686
+ /** Get information about user usage tracking */
687
+ listUserUsage(): Promise<unknown>;
688
+ }
689
+
690
+ declare class TeamsResource {
691
+ private client;
692
+ constructor(client: BackflowClient);
693
+ /** Get all teams */
694
+ list(): Promise<unknown>;
695
+ /** Create a new team */
696
+ create(data: Record<string, unknown>): Promise<unknown>;
697
+ /** Get team by ID */
698
+ get(id: string): Promise<unknown>;
699
+ /** Update team metadata (name, description, members) */
700
+ update(id: string, data: Record<string, unknown>): Promise<unknown>;
701
+ /** Delete team */
702
+ delete(id: string): Promise<unknown>;
703
+ /** Get all projects for a team */
704
+ projects(id: string): Promise<unknown>;
705
+ }
706
+
707
+ declare class TenantIntegrationsResource$1 {
708
+ private client;
709
+ constructor(client: BackflowClient);
710
+ /** List integrations */
711
+ list(): Promise<unknown>;
712
+ /** Create or update integration */
713
+ create(data: Record<string, unknown>): Promise<unknown>;
714
+ /** Get integration */
715
+ get(integrationId: string): Promise<unknown>;
716
+ /** Delete integration */
717
+ delete(integrationId: string): Promise<unknown>;
718
+ /** Clone from default */
719
+ createClone(integrationId: string, data: Record<string, unknown>): Promise<unknown>;
720
+ }
721
+
722
+ declare class TenantJobsResource$1 {
723
+ private client;
724
+ constructor(client: BackflowClient);
725
+ /** List job definitions */
726
+ list(): Promise<unknown>;
727
+ /** Create or update job definition */
728
+ create(data: Record<string, unknown>): Promise<unknown>;
729
+ /** Get job definition */
730
+ get(jobDefId: string): Promise<unknown>;
731
+ /** Delete job definition */
732
+ delete(jobDefId: string): Promise<unknown>;
733
+ /** Enqueue job from definition */
734
+ createEnqueue(data: Record<string, unknown>): Promise<unknown>;
735
+ /** Get job execution history */
736
+ listHistory(): Promise<unknown>;
737
+ }
738
+
739
+ declare class TenantLimitsResource {
740
+ private client;
741
+ constructor(client: BackflowClient);
742
+ /** Get user limits configuration */
743
+ list(): Promise<unknown>;
744
+ /** Update user limits configuration */
745
+ update(data: Record<string, unknown>): Promise<unknown>;
746
+ /** Get usage statistics */
747
+ listUsage(): Promise<unknown>;
748
+ /** Check if action is allowed */
749
+ create(data: Record<string, unknown>): Promise<unknown>;
750
+ /** Get storage limits configuration */
751
+ listStorage(): Promise<unknown>;
752
+ /** Update storage limits configuration */
753
+ updateStorage(data: Record<string, unknown>): Promise<unknown>;
754
+ /** Get storage usage statistics */
755
+ listGET2(): Promise<unknown>;
756
+ /** Check if file upload is allowed */
757
+ createCheck(data: Record<string, unknown>): Promise<unknown>;
758
+ /** Get storage usage by user */
759
+ listByUser(): Promise<unknown>;
760
+ /** Get resource limits configuration */
761
+ listResources(): Promise<unknown>;
762
+ /** Update resource limits configuration */
763
+ updateResources(data: Record<string, unknown>): Promise<unknown>;
764
+ /** Get available resource types */
765
+ listDefinitions(): Promise<unknown>;
766
+ /** Get resource usage statistics */
767
+ listGET3(): Promise<unknown>;
768
+ /** Check if resource action is allowed */
769
+ createPOST2(data: Record<string, unknown>): Promise<unknown>;
770
+ /** Track resource usage */
771
+ createTrack(data: Record<string, unknown>): Promise<unknown>;
772
+ /** Get limit for specific collection */
773
+ get(collection: string): Promise<unknown>;
774
+ /** Set limit for specific collection */
775
+ updateLimits(collection: string, data: Record<string, unknown>): Promise<unknown>;
776
+ /** Remove limit for specific collection */
777
+ delete(collection: string): Promise<unknown>;
778
+ }
779
+
780
+ declare class TenantRbacResource {
781
+ private client;
782
+ constructor(client: BackflowClient);
783
+ /** Get RBAC configuration */
784
+ list(): Promise<unknown>;
785
+ /** Update RBAC configuration */
786
+ update(data: Record<string, unknown>): Promise<unknown>;
787
+ /** List all roles */
788
+ listRoles(): Promise<unknown>;
789
+ /** Create a new role */
790
+ create(data: Record<string, unknown>): Promise<unknown>;
791
+ /** Update a role */
792
+ updateRoles(name: string, data: Record<string, unknown>): Promise<unknown>;
793
+ /** Delete a role */
794
+ delete(name: string): Promise<unknown>;
795
+ }
796
+
797
+ declare class TenantWebhookReceiversResource {
798
+ private client;
799
+ constructor(client: BackflowClient);
800
+ /** List webhook receivers */
801
+ list(): Promise<unknown>;
802
+ /** Create webhook receiver */
803
+ create(data: Record<string, unknown>): Promise<unknown>;
804
+ /** Get webhook receiver */
805
+ get(id: string): Promise<unknown>;
806
+ /** Update webhook receiver */
807
+ update(id: string, data: Record<string, unknown>): Promise<unknown>;
808
+ /** Delete webhook receiver */
809
+ delete(id: string): Promise<unknown>;
810
+ }
811
+
812
+ declare class TenantWebhooksResource {
813
+ private client;
814
+ constructor(client: BackflowClient);
815
+ /** List webhooks */
816
+ list(): Promise<unknown>;
817
+ /** Create webhook */
818
+ create(data: Record<string, unknown>): Promise<unknown>;
819
+ /** Get webhook */
820
+ get(id: string): Promise<unknown>;
821
+ /** Update webhook */
822
+ update(id: string, data: Record<string, unknown>): Promise<unknown>;
823
+ /** Delete webhook */
824
+ delete(id: string): Promise<unknown>;
825
+ }
826
+
827
+ declare class TenantWorkflowsResource$1 {
828
+ private client;
829
+ constructor(client: BackflowClient);
830
+ /** List workflows */
831
+ list(): Promise<unknown>;
832
+ /** Create or update workflow */
833
+ create(data: Record<string, unknown>): Promise<unknown>;
834
+ /** Get workflow */
835
+ get(workflowId: string): Promise<unknown>;
836
+ /** Delete workflow */
837
+ delete(workflowId: string): Promise<unknown>;
838
+ /** Clone from default */
839
+ createClone(workflowId: string, data: Record<string, unknown>): Promise<unknown>;
840
+ }
841
+
842
+ declare class ToolDiscoveryResource {
843
+ private client;
844
+ constructor(client: BackflowClient);
845
+ /** Get all registered tools including MCP, user-configured, and built-in tools */
846
+ list(): Promise<unknown>;
847
+ /** Search for tools using text query, category, tags, capabilities, and performance filters */
848
+ create(data: Record<string, unknown>): Promise<unknown>;
849
+ /** Search for tools using natural language semantic similarity */
850
+ createSemanticSearch(data: Record<string, unknown>): Promise<unknown>;
851
+ /** Use AI to automatically select appropriate tools based on a natural language goal */
852
+ createSelect(data: Record<string, unknown>): Promise<unknown>;
853
+ /** Get tool recommendations based on goal and historical performance data */
854
+ createRecommend(data: Record<string, unknown>): Promise<unknown>;
855
+ /** Get performance metrics (success rate, latency, usage) for a specific tool */
856
+ metrics(toolName: string): Promise<unknown>;
857
+ /** Index all registered tools for semantic search using embeddings */
858
+ createIndex(data: Record<string, unknown>): Promise<unknown>;
859
+ }
860
+
861
+ declare class TrackingResource {
862
+ private client;
863
+ constructor(client: BackflowClient);
864
+ /** Get MCP call statistics for the tenant */
865
+ list(): Promise<unknown>;
866
+ /** Get field-level change history for an entity */
867
+ history(entityType: string, entityId: string): Promise<unknown>;
868
+ /** Get change history for a specific field */
869
+ getField(entityType: string, entityId: string, fieldName: string): Promise<unknown>;
870
+ /** Get tracking buffer status (AI usage buffer size) */
871
+ listStatus(): Promise<unknown>;
872
+ /** Manually flush tracking buffers to database */
873
+ create(data: Record<string, unknown>): Promise<unknown>;
874
+ }
875
+
876
+ declare class TwitterResource {
877
+ private client;
878
+ constructor(client: BackflowClient);
879
+ /** Search X (Twitter) tweets by query */
880
+ list(): Promise<unknown>;
881
+ /** Get details of a specific tweet */
882
+ get(tweetId: string): Promise<unknown>;
883
+ /** Delete a tweet */
884
+ delete(tweetId: string): Promise<unknown>;
885
+ /** Post a new tweet */
886
+ create(data: Record<string, unknown>): Promise<unknown>;
887
+ /** Like a tweet */
888
+ createLike(userId: string, data: Record<string, unknown>): Promise<unknown>;
889
+ /** Unlike a tweet */
890
+ deleteLike(userId: string, tweetId: string): Promise<unknown>;
891
+ /** Retweet a tweet */
892
+ createRetweet(userId: string, data: Record<string, unknown>): Promise<unknown>;
893
+ /** Remove a retweet */
894
+ deleteRetweet(userId: string, tweetId: string): Promise<unknown>;
895
+ /** Get user information by username */
896
+ getUsername(username: string): Promise<unknown>;
897
+ /** Get user information by user ID */
898
+ getUsers(userId: string): Promise<unknown>;
899
+ /** Get authenticated user information */
900
+ listMe(): Promise<unknown>;
901
+ /** Get recent tweets from a user */
902
+ tweets(userId: string): Promise<unknown>;
903
+ /** Follow a user */
904
+ createFollowing(userId: string, data: Record<string, unknown>): Promise<unknown>;
905
+ /** Unfollow a user */
906
+ deleteFollowing(userId: string, targetUserId: string): Promise<unknown>;
907
+ /** Get followers of a user */
908
+ followers(userId: string): Promise<unknown>;
909
+ /** Get users that a user is following */
910
+ followingList(userId: string): Promise<unknown>;
911
+ /** Get users who liked a tweet */
912
+ likedBy(tweetId: string): Promise<unknown>;
913
+ /** Get users who retweeted a tweet */
914
+ retweetedBy(tweetId: string): Promise<unknown>;
915
+ /** Get tweets in a conversation thread */
916
+ getConversations(conversationId: string): Promise<unknown>;
917
+ /** Get tweets liked by a user */
918
+ likedTweets(userId: string): Promise<unknown>;
919
+ }
920
+
921
+ declare class UsageResource$1 {
922
+ private client;
923
+ constructor(client: BackflowClient);
924
+ /** Get unified usage metrics for a user across AI, API, and integrations */
925
+ get(userId: string): Promise<unknown>;
926
+ /** Get a brief summary of user usage */
927
+ summary(userId: string): Promise<unknown>;
928
+ /** Get usage metrics for the authenticated user */
929
+ list(): Promise<unknown>;
930
+ }
931
+
932
+ declare class UsersResource {
933
+ private client;
934
+ constructor(client: BackflowClient);
935
+ /** Get all users */
936
+ list(): Promise<unknown>;
937
+ /** Get user by ID */
938
+ get(id: string): Promise<unknown>;
939
+ /** Create a new user */
940
+ create(data: Record<string, unknown>): Promise<unknown>;
941
+ /** Update user */
942
+ update(id: string, data: Record<string, unknown>): Promise<unknown>;
943
+ /** Delete user */
944
+ delete(id: string): Promise<unknown>;
945
+ }
946
+
947
+ declare class WebsocketResource {
948
+ private client;
949
+ constructor(client: BackflowClient);
950
+ /** WebSocket API Documentation */
951
+ list(): Promise<unknown>;
952
+ }
953
+
954
+ declare class WorkflowsResource$1 {
955
+ private client;
956
+ constructor(client: BackflowClient);
957
+ /** Orchestrate a task by ID. Executes predefined task orchestration logic. */
958
+ create(data: Record<string, unknown>): Promise<unknown>;
959
+ /** Execute an agentic workflow with tools and steps. Workflows define a series of actions that can call LLMs, APIs, shell commands, and MCP tools. */
960
+ createWorkflow(data: Record<string, unknown>): Promise<unknown>;
961
+ /** List all workflow executions with date range filter and pagination. */
962
+ list(): Promise<unknown>;
963
+ /** Delete all workflow executions and their activity records */
964
+ delete(): Promise<unknown>;
965
+ /** Delete a specific workflow execution and all its activity records */
966
+ deleteExecutions(workflowId: string): Promise<unknown>;
967
+ /** Get execution history for a workflow by ID. Returns all historical execution records. */
968
+ history(workflowId: string): Promise<unknown>;
969
+ /** Resume a paused workflow execution. Allows continuing or cancelling execution with optional user input. */
970
+ createResume(data: Record<string, unknown>): Promise<unknown>;
971
+ /** Request pause for a running workflow. The workflow will pause after the current step completes. */
972
+ pause(executionId: string, data: Record<string, unknown>): Promise<unknown>;
973
+ /** Cancel a running workflow. The workflow will stop after the current step completes. */
974
+ cancel(executionId: string, data: Record<string, unknown>): Promise<unknown>;
975
+ /** Get background execution status for workflows that returned early */
976
+ status(executionId: string): Promise<unknown>;
977
+ /** Retry a workflow execution. Can restart from beginning or resume from last checkpoint. */
978
+ retry(executionId: string, data: Record<string, unknown>): Promise<unknown>;
979
+ /** Health check endpoint with detailed component status. Returns status of embeddings, vector store, MCP servers, and database. */
980
+ listHealth(): Promise<unknown>;
981
+ /** Automatically generate and execute a workflow from a natural language goal using AI */
982
+ createDynamic(data: Record<string, unknown>): Promise<unknown>;
983
+ }
984
+
985
+ declare class WorkspacesResource {
986
+ private client;
987
+ constructor(client: BackflowClient);
988
+ /** Get all workspaces */
989
+ list(): Promise<unknown>;
990
+ /** Create a new workspace */
991
+ create(data: Record<string, unknown>): Promise<unknown>;
992
+ /** Get workspace by ID */
993
+ get(id: string): Promise<unknown>;
994
+ /** Update workspace */
995
+ update(id: string, data: Record<string, unknown>): Promise<unknown>;
996
+ /** Delete workspace */
997
+ delete(id: string): Promise<unknown>;
998
+ }
999
+
1000
+ interface AIChatOptions {
1001
+ messages: Array<{
1002
+ role: string;
1003
+ content: string;
1004
+ }>;
1005
+ projectContext?: unknown;
1006
+ }
1007
+ interface AIChatResponse {
1008
+ chatResponse: {
1009
+ message: string;
1010
+ suggestions?: string[];
1011
+ };
1012
+ }
1013
+ declare class AIResource {
1014
+ private client;
1015
+ constructor(client: BackflowClient);
1016
+ chat(options: AIChatOptions): Promise<AIChatResponse>;
1017
+ }
1018
+
1019
+ interface PresenceData {
1020
+ projectId: string;
1021
+ cursor?: unknown;
1022
+ selection?: unknown;
1023
+ }
1024
+ declare class CollaborationResource {
1025
+ private client;
1026
+ constructor(client: BackflowClient);
1027
+ presence(data: PresenceData): Promise<{
1028
+ success: boolean;
1029
+ }>;
1030
+ }
1031
+
1032
+ interface HighResExportOptions {
1033
+ format: 'png' | 'svg' | 'pdf';
1034
+ scale: number;
1035
+ content: unknown;
1036
+ contentType?: string;
1037
+ }
1038
+ interface HighResExportResult {
1039
+ export: string;
1040
+ r2Upload: {
1041
+ url: string;
1042
+ };
1043
+ }
1044
+ declare class ExportsResource {
1045
+ private client;
1046
+ constructor(client: BackflowClient);
1047
+ highRes(options: HighResExportOptions): Promise<HighResExportResult>;
1048
+ }
1049
+
1050
+ interface UserMetrics {
1051
+ role?: string;
1052
+ teamSize?: string;
1053
+ useCase?: string;
1054
+ createdAt?: string;
1055
+ updatedAt?: string;
1056
+ }
1057
+ interface UserProfile {
1058
+ uid: string;
1059
+ email?: string;
1060
+ displayName?: string;
1061
+ photoURL?: string;
1062
+ emailVerified?: boolean;
1063
+ }
1064
+ interface UpdateProfileOptions {
1065
+ displayName?: string;
1066
+ photoURL?: string;
1067
+ }
1068
+ declare class UserResource {
1069
+ private client;
1070
+ constructor(client: BackflowClient);
1071
+ createMetrics(metrics: UserMetrics): Promise<{
1072
+ success: boolean;
1073
+ }>;
1074
+ getMetrics(): Promise<{
1075
+ data: UserMetrics;
1076
+ }>;
1077
+ updateMetrics(metrics: Partial<UserMetrics>): Promise<{
1078
+ success: boolean;
1079
+ }>;
1080
+ getProfile(): Promise<{
1081
+ user: UserProfile;
1082
+ }>;
1083
+ updateProfile(options: UpdateProfileOptions): Promise<{
1084
+ success: boolean;
1085
+ user: UserProfile;
1086
+ }>;
1087
+ }
1088
+
1089
+ interface RouteInfo {
1090
+ path: string;
1091
+ method: string;
1092
+ description?: string;
1093
+ tags?: string[];
1094
+ }
1095
+ interface CollectionInfo {
1096
+ collection: string;
1097
+ routes: RouteInfo[];
1098
+ }
1099
+ interface EntityRecord {
1100
+ id: string;
1101
+ [key: string]: unknown;
1102
+ }
1103
+ interface ListEntitiesOptions {
1104
+ limit?: number;
1105
+ offset?: number;
1106
+ includeDeleted?: boolean;
1107
+ }
1108
+ interface GetEntityOptions {
1109
+ includeDeleted?: boolean;
1110
+ }
1111
+ interface DeleteEntityOptions {
1112
+ hard?: boolean;
1113
+ softDelete?: boolean;
1114
+ }
1115
+ interface DeleteEntityResult {
1116
+ success: boolean;
1117
+ softDeleted?: boolean;
1118
+ }
1119
+ interface RestoreEntityResult {
1120
+ success: boolean;
1121
+ data?: EntityRecord;
1122
+ }
1123
+ interface ListEntitiesResult {
1124
+ data: EntityRecord[];
1125
+ count?: number;
1126
+ }
1127
+ type ValidationPreset = "email" | "url" | "phone-us" | "phone-intl" | "uuid" | "slug" | "username" | "password" | "name" | "currency" | "percentage" | "date" | "datetime" | "time" | "ip" | "ipv4" | "ipv6" | "mac-address" | "credit-card" | "postal-code-us" | "ssn" | "hex-color" | "json";
1128
+ type FieldType = "text" | "varchar" | "integer" | "bigint" | "decimal" | "boolean" | "timestamp" | "date" | "json" | "jsonb" | "array" | "uuid" | "enum";
1129
+ interface SchemaField {
1130
+ name: string;
1131
+ source: "builtin" | "route" | "entity";
1132
+ type?: FieldType;
1133
+ required?: boolean;
1134
+ preset?: ValidationPreset;
1135
+ min?: number;
1136
+ max?: number;
1137
+ pattern?: string;
1138
+ enum?: string[];
1139
+ }
1140
+ interface CollectionSchema {
1141
+ collection: string;
1142
+ fields: SchemaField[];
1143
+ }
1144
+ interface ValidationResult$1 {
1145
+ valid: boolean;
1146
+ errors?: Array<{
1147
+ field: string;
1148
+ message: string;
1149
+ }>;
1150
+ }
1151
+ declare class EntitiesResource {
1152
+ private client;
1153
+ constructor(client: BackflowClient);
1154
+ listCollections(): Promise<CollectionInfo[]>;
1155
+ list(collection: string, options?: ListEntitiesOptions): Promise<ListEntitiesResult>;
1156
+ get(collection: string, id: string, options?: GetEntityOptions): Promise<EntityRecord>;
1157
+ create(collection: string, data: Record<string, unknown>): Promise<EntityRecord>;
1158
+ update(collection: string, id: string, data: Record<string, unknown>): Promise<EntityRecord>;
1159
+ delete(collection: string, id: string, options?: DeleteEntityOptions): Promise<DeleteEntityResult>;
1160
+ restore(collection: string, id: string): Promise<RestoreEntityResult>;
1161
+ getSchema(): Promise<CollectionSchema[]>;
1162
+ /**
1163
+ * Get schema for a specific collection
1164
+ */
1165
+ getCollectionSchema(collection: string): Promise<CollectionSchema | null>;
1166
+ /**
1167
+ * Validate data against a collection's schema (client-side)
1168
+ */
1169
+ validate(collection: string, data: Record<string, unknown>): Promise<ValidationResult$1>;
1170
+ private validatePreset;
1171
+ /**
1172
+ * Create with validation (validates before sending to server)
1173
+ */
1174
+ createValidated(collection: string, data: Record<string, unknown>): Promise<{
1175
+ data?: EntityRecord;
1176
+ errors?: ValidationResult$1["errors"];
1177
+ }>;
1178
+ /**
1179
+ * Update with validation (validates before sending to server)
1180
+ */
1181
+ updateValidated(collection: string, id: string, data: Record<string, unknown>): Promise<{
1182
+ data?: EntityRecord;
1183
+ errors?: ValidationResult$1["errors"];
1184
+ }>;
1185
+ }
1186
+
1187
+ interface FileUploadOptions {
1188
+ bucket?: string;
1189
+ entityType?: string;
1190
+ entityId?: string;
1191
+ }
1192
+ interface FileMetadata {
1193
+ id: string;
1194
+ bucket: string;
1195
+ path: string;
1196
+ url: string;
1197
+ size: number;
1198
+ content_type: string;
1199
+ uploaded_at: string;
1200
+ uploaded_by: string;
1201
+ tenant_id: string;
1202
+ entity_type: string;
1203
+ entity_id: string;
1204
+ created_at?: {
1205
+ _seconds: number;
1206
+ _nanoseconds: number;
1207
+ } | string;
1208
+ }
1209
+ interface SignedUrlResponse {
1210
+ success: boolean;
1211
+ signedUrl: string;
1212
+ expiresAt: string;
1213
+ }
1214
+ declare class FilesResource {
1215
+ private client;
1216
+ constructor(client: BackflowClient);
1217
+ upload(file: File, options?: FileUploadOptions): Promise<FileMetadata>;
1218
+ uploadMultiple(files: File[], options?: FileUploadOptions): Promise<FileMetadata[]>;
1219
+ list(entityType: string, entityId: string, options?: {
1220
+ limit?: number;
1221
+ offset?: number;
1222
+ }): Promise<FileMetadata[]>;
1223
+ getSignedUrl(bucket: string, key: string, expiresIn?: number): Promise<SignedUrlResponse>;
1224
+ download(bucket: string, key: string): Promise<Blob>;
1225
+ delete(bucket: string, key: string): Promise<{
1226
+ success: boolean;
1227
+ }>;
1228
+ deleteByEntity(entityType: string, entityId: string): Promise<{
1229
+ success: boolean;
1230
+ deleted: number;
1231
+ }>;
1232
+ uploadJson(options: {
1233
+ content: string;
1234
+ filename: string;
1235
+ entityType?: string;
1236
+ entityId?: string;
1237
+ bucket?: string;
1238
+ }): Promise<{
1239
+ upload: {
1240
+ url: string;
1241
+ key: string;
1242
+ bucket: string;
1243
+ path: string;
1244
+ };
1245
+ }>;
1246
+ }
1247
+
1248
+ declare const TOOL_TYPES: readonly ["llm_call", "api_call", "shell_command", "web_search", "file_edit", "git_command", "mcp_tool", "storage", "database", "notification", "workflow", "rag", "cache", "emit_event"];
1249
+ declare const TRIGGER_TYPES: readonly ["manual", "cron", "webhook", "event"];
1250
+ declare const NOTIFY_CHANNELS: readonly ["email", "sms", "whatsapp", "push", "slack"];
1251
+ declare const NOTIFY_PRIORITIES: readonly ["low", "normal", "high", "urgent"];
1252
+ declare const DB_OPERATIONS: readonly ["get", "query", "insert", "update", "upsert", "delete", "deletewhere", "arrayRemove", "updateArrayElement", "count"];
1253
+ declare const STORAGE_OPERATIONS: readonly ["get", "download", "put", "upload", "list", "signedUrl", "delete", "deleteByPrefix", "url", "publicUrl"];
1254
+ declare const CACHE_OPERATIONS: readonly ["get", "set", "delete", "invalidate"];
1255
+ declare const LLM_PROVIDERS: readonly ["openai", "anthropic", "google", "openrouter", "lmstudio", "custom", "claude", "ollama"];
1256
+ declare const CLI_PROVIDERS: readonly ["claude", "openai", "aider", "anthropic", "claude-cli", "openai-cli", "ollama-cli"];
1257
+ declare const DB_PROVIDERS: readonly ["firebase", "supabase", "sqlite", "custom"];
1258
+ declare const HTTP_METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE"];
1259
+ declare const RAG_MODES: readonly ["single", "accumulate", "iterative"];
1260
+ declare const CHUNKING_STRATEGIES: readonly ["fixed_size", "recursive", "token_based", "semantic"];
1261
+ declare const IMAGE_DETAILS: readonly ["auto", "low", "high"];
1262
+ declare const CONDITION_OPERATORS: readonly ["$eq", "$ne", "$gt", "$gte", "$lt", "$lte", "$in", "$exists"];
1263
+ type ToolType = typeof TOOL_TYPES[number];
1264
+ type TriggerType = typeof TRIGGER_TYPES[number];
1265
+ type NotifyChannel = typeof NOTIFY_CHANNELS[number];
1266
+ type NotifyPriority = typeof NOTIFY_PRIORITIES[number];
1267
+ interface PropertyValidation {
1268
+ type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'enum';
1269
+ required: boolean;
1270
+ multiselect?: boolean;
1271
+ options?: readonly string[];
1272
+ itemType?: PropertyValidation;
1273
+ properties?: Record<string, PropertyValidation>;
1274
+ description?: string;
1275
+ default?: unknown;
1276
+ }
1277
+ interface WorkflowValidationSchema {
1278
+ root: Record<string, PropertyValidation>;
1279
+ tool: Record<string, PropertyValidation>;
1280
+ step: Record<string, PropertyValidation>;
1281
+ trigger: Record<string, PropertyValidation>;
1282
+ pausePoint: Record<string, PropertyValidation>;
1283
+ notify: Record<string, PropertyValidation>;
1284
+ workflow: Record<string, PropertyValidation>;
1285
+ fileAttachment: Record<string, PropertyValidation>;
1286
+ imageAttachment: Record<string, PropertyValidation>;
1287
+ conditionOperators: Record<string, PropertyValidation>;
1288
+ }
1289
+ declare const WORKFLOW_VALIDATION_SCHEMA: WorkflowValidationSchema;
1290
+ interface WorkflowConfig {
1291
+ id?: string;
1292
+ name?: string;
1293
+ steps: WorkflowStep[];
1294
+ tools?: WorkflowTool[];
1295
+ masterContext?: string;
1296
+ }
1297
+ interface WorkflowStep {
1298
+ id: string;
1299
+ action: string;
1300
+ params?: Record<string, unknown>;
1301
+ dependsOn?: string[];
1302
+ parallel?: boolean;
1303
+ earlyReturn?: boolean;
1304
+ queueAsJob?: boolean;
1305
+ condition?: string;
1306
+ pausePoint?: PausePoint;
1307
+ files?: string[];
1308
+ images?: string[];
1309
+ }
1310
+ interface PausePoint {
1311
+ requireApproval?: boolean;
1312
+ message?: string;
1313
+ metadata?: Record<string, unknown>;
1314
+ notify?: NotifyConfig;
1315
+ }
1316
+ interface NotifyConfig {
1317
+ enabled?: boolean;
1318
+ channels?: NotifyChannel[];
1319
+ priority?: NotifyPriority;
1320
+ userId?: string;
1321
+ }
1322
+ interface WorkflowTool {
1323
+ name: string;
1324
+ type: ToolType;
1325
+ description?: string;
1326
+ endpoint?: string;
1327
+ params?: Record<string, unknown>;
1328
+ }
1329
+ interface WorkflowExecution {
1330
+ id: string;
1331
+ workflowId: string;
1332
+ status: 'pending' | 'running' | 'paused' | 'completed' | 'failed' | 'cancelled' | 'accepted';
1333
+ result?: unknown;
1334
+ error?: string;
1335
+ channel?: string;
1336
+ jobId?: string;
1337
+ startedAt: string;
1338
+ completedAt?: string;
1339
+ }
1340
+ interface BackgroundExecutionStatus {
1341
+ executionId: string;
1342
+ workflowId: string;
1343
+ status: 'running' | 'completed' | 'failed' | 'cancelled';
1344
+ completedSteps: string[];
1345
+ pendingSteps: string[];
1346
+ error?: string;
1347
+ }
1348
+ interface WorkflowProgressEvent {
1349
+ stepId: string;
1350
+ status: string;
1351
+ result?: unknown;
1352
+ error?: string;
1353
+ }
1354
+ interface WorkflowActivityEvent {
1355
+ timestamp: string;
1356
+ type: string;
1357
+ stepId?: string;
1358
+ data?: unknown;
1359
+ }
1360
+ interface WorkflowSubscribeHandlers {
1361
+ onProgress?: (event: WorkflowProgressEvent) => void;
1362
+ onComplete?: (execution: WorkflowExecution) => void;
1363
+ onError?: (error: unknown) => void;
1364
+ }
1365
+ declare class WorkflowsResource {
1366
+ private client;
1367
+ constructor(client: BackflowClient);
1368
+ execute(config: WorkflowConfig): Promise<WorkflowExecution>;
1369
+ get(executionId: string): Promise<WorkflowExecution>;
1370
+ list(params?: {
1371
+ limit?: number;
1372
+ page?: number;
1373
+ startDate?: string;
1374
+ endDate?: string;
1375
+ }): Promise<{
1376
+ executions: WorkflowExecution[];
1377
+ pagination: {
1378
+ page: number;
1379
+ limit: number;
1380
+ total: number;
1381
+ hasMore: boolean;
1382
+ };
1383
+ }>;
1384
+ getHistory(workflowId: string): Promise<{
1385
+ history: WorkflowActivityEvent[];
1386
+ }>;
1387
+ pause(executionId: string): Promise<{
1388
+ success: boolean;
1389
+ message: string;
1390
+ }>;
1391
+ resume(executionId: string, options?: {
1392
+ continue?: boolean;
1393
+ userInput?: unknown;
1394
+ }): Promise<{
1395
+ success: boolean;
1396
+ result?: unknown;
1397
+ }>;
1398
+ cancel(executionId: string): Promise<{
1399
+ success: boolean;
1400
+ message: string;
1401
+ }>;
1402
+ getStatus(executionId: string): Promise<BackgroundExecutionStatus>;
1403
+ retry(executionId: string): Promise<{
1404
+ success: boolean;
1405
+ message: string;
1406
+ }>;
1407
+ rerun(workflowId: string): Promise<WorkflowExecution>;
1408
+ delete(workflowId: string): Promise<{
1409
+ success: boolean;
1410
+ }>;
1411
+ deleteAll(): Promise<{
1412
+ success: boolean;
1413
+ deleted: number;
1414
+ }>;
1415
+ subscribe(executionId: string, handlers: WorkflowSubscribeHandlers): () => void;
1416
+ getValidationSchema(): WorkflowValidationSchema;
1417
+ getSchemaFor(section: keyof WorkflowValidationSchema): Record<string, PropertyValidation>;
1418
+ getToolTypes(): readonly string[];
1419
+ getTriggerTypes(): readonly string[];
1420
+ getNotifyChannels(): readonly string[];
1421
+ getNotifyPriorities(): readonly string[];
1422
+ getDbOperations(): readonly string[];
1423
+ getStorageOperations(): readonly string[];
1424
+ validateProperty(section: keyof WorkflowValidationSchema, property: string, value: unknown): {
1425
+ valid: boolean;
1426
+ error?: string;
1427
+ };
1428
+ }
1429
+ declare const TOOL_PARAM_CONTEXT: Record<string, string[]>;
1430
+ interface PromptContextOptions {
1431
+ sections?: (keyof WorkflowValidationSchema)[];
1432
+ toolType?: string;
1433
+ compact?: boolean;
1434
+ }
1435
+ declare function toPromptContext(options?: PromptContextOptions): string;
1436
+ declare function toCompactContext(toolType?: string): string;
1437
+
1438
+ interface CacheStats {
1439
+ enabled: boolean;
1440
+ hits: number;
1441
+ misses: number;
1442
+ hitRate: number;
1443
+ size: number;
1444
+ memory?: {
1445
+ usedMB: number;
1446
+ maxMB: number;
1447
+ percentage: number;
1448
+ };
1449
+ }
1450
+ interface CacheInvalidationResult {
1451
+ success: boolean;
1452
+ message: string;
1453
+ pattern: string;
1454
+ }
1455
+ declare class CacheResource {
1456
+ private client;
1457
+ constructor(client: BackflowClient);
1458
+ getStats(): Promise<CacheStats>;
1459
+ flush(): Promise<{
1460
+ success: boolean;
1461
+ message: string;
1462
+ }>;
1463
+ invalidate(pattern: string): Promise<CacheInvalidationResult>;
1464
+ invalidateRoute(method: string, path: string): Promise<CacheInvalidationResult>;
1465
+ resetStats(): Promise<{
1466
+ success: boolean;
1467
+ message: string;
1468
+ }>;
1469
+ }
1470
+
1471
+ type Environment = 'development' | 'staging' | 'production';
1472
+ interface TenantConfigData {
1473
+ name?: string;
1474
+ environment?: Environment;
1475
+ routes?: unknown[];
1476
+ integrations?: Record<string, unknown>;
1477
+ agent?: Record<string, unknown>;
1478
+ database?: Record<string, unknown>;
1479
+ notifications?: Record<string, unknown>;
1480
+ rateLimit?: Record<string, unknown>;
1481
+ webhooks?: Record<string, unknown>;
1482
+ cache?: Record<string, unknown>;
1483
+ [key: string]: unknown;
1484
+ }
1485
+ interface TenantConfigResponse {
1486
+ name?: string;
1487
+ environment?: Environment;
1488
+ config: TenantConfigData;
1489
+ version: number;
1490
+ updatedAt: string;
1491
+ planTier?: string;
1492
+ isolationLevel?: string;
1493
+ }
1494
+ interface SecretMetadata {
1495
+ key: string;
1496
+ type?: string;
1497
+ provider?: string;
1498
+ description?: string;
1499
+ createdAt: string;
1500
+ expiresAt?: string;
1501
+ }
1502
+ interface ApiKeyMetadata {
1503
+ id: string;
1504
+ keyPrefix: string;
1505
+ name: string;
1506
+ scopes: string[];
1507
+ expiresAt?: string;
1508
+ lastUsedAt?: string;
1509
+ useCount: number;
1510
+ createdAt: string;
1511
+ isActive: boolean;
1512
+ }
1513
+ interface CreateApiKeyResult {
1514
+ id: string;
1515
+ key: string;
1516
+ prefix: string;
1517
+ name: string;
1518
+ scopes: string[];
1519
+ expiresAt?: string;
1520
+ }
1521
+ interface TenantDomain {
1522
+ domain: string;
1523
+ type: 'primary' | 'alias';
1524
+ verified: boolean;
1525
+ verificationToken?: string;
1526
+ verificationMethod?: 'dns' | 'http';
1527
+ sslStatus: 'pending' | 'active' | 'failed';
1528
+ createdAt: string;
1529
+ updatedAt?: string;
1530
+ }
1531
+ interface VerificationInstructions {
1532
+ method: 'dns' | 'http';
1533
+ domain: string;
1534
+ dnsRecord?: {
1535
+ type: string;
1536
+ name: string;
1537
+ value: string;
1538
+ };
1539
+ httpPath?: string;
1540
+ httpContent?: string;
1541
+ }
1542
+ interface AddDomainResult {
1543
+ domain: TenantDomain;
1544
+ verificationInstructions: VerificationInstructions;
1545
+ }
1546
+ interface TenantApp {
1547
+ id: string;
1548
+ name: string;
1549
+ parentTenantId?: string;
1550
+ planTier: string;
1551
+ createdAt: string;
1552
+ isActive: boolean;
1553
+ environment?: string;
1554
+ createdBy?: string;
1555
+ createdFor?: string;
1556
+ isNewTenant?: boolean;
1557
+ }
1558
+ interface CreateAppOptions {
1559
+ name: string;
1560
+ environment?: 'development' | 'staging' | 'production';
1561
+ config?: Record<string, unknown>;
1562
+ }
1563
+ interface UpdateSettingsOptions {
1564
+ name?: string;
1565
+ environment?: 'development' | 'staging' | 'production';
1566
+ }
1567
+ interface UpdateSettingsResponse {
1568
+ success: boolean;
1569
+ version: number;
1570
+ message: string;
1571
+ }
1572
+ interface AppUsage {
1573
+ current: number;
1574
+ limit: number;
1575
+ percentage: number;
1576
+ planTier: string;
1577
+ canCreate: boolean;
1578
+ }
1579
+ interface TenantRole {
1580
+ name: string;
1581
+ description?: string;
1582
+ permissions: string[];
1583
+ parentRole?: string;
1584
+ }
1585
+ interface TenantRBACConfig {
1586
+ enabled: boolean;
1587
+ roles: TenantRole[];
1588
+ defaultRole?: string;
1589
+ }
1590
+ type GateAction = 'login' | 'upgrade';
1591
+ interface EntityLimitConfig {
1592
+ limit: number;
1593
+ gateAction?: GateAction;
1594
+ tiers?: Record<string, number>;
1595
+ scope?: 'user' | 'tenant';
1596
+ }
1597
+ interface UserLimitsConfig {
1598
+ enabled: boolean;
1599
+ defaultGateAction: GateAction;
1600
+ entityLimits?: Record<string, EntityLimitConfig>;
1601
+ }
1602
+ interface UsageStats {
1603
+ collection: string;
1604
+ current: number;
1605
+ limit: number;
1606
+ percentage: number;
1607
+ gateAction: GateAction;
1608
+ }
1609
+ interface CheckLimitResult {
1610
+ allowed: boolean;
1611
+ gateAction: GateAction;
1612
+ reason?: string;
1613
+ usage: {
1614
+ current: number;
1615
+ limit: number;
1616
+ };
1617
+ upgrade?: {
1618
+ tier: string;
1619
+ newLimit: number;
1620
+ };
1621
+ }
1622
+ interface StorageTierLimit {
1623
+ maxStorageMB: number;
1624
+ maxFileSizeMB?: number;
1625
+ }
1626
+ interface StorageLimitsConfig {
1627
+ enabled: boolean;
1628
+ scope: 'user' | 'tenant';
1629
+ tiers?: Record<string, StorageTierLimit>;
1630
+ gateAction: GateAction;
1631
+ }
1632
+ interface StorageUsageStats {
1633
+ currentBytes: number;
1634
+ currentMB: number;
1635
+ limitMB: number;
1636
+ percentage: number;
1637
+ fileCount: number;
1638
+ gateAction: GateAction;
1639
+ }
1640
+ interface StorageCheckResult {
1641
+ allowed: boolean;
1642
+ gateAction: GateAction;
1643
+ reason?: string;
1644
+ usage: {
1645
+ currentMB: number;
1646
+ limitMB: number;
1647
+ };
1648
+ upgrade?: {
1649
+ tier: string;
1650
+ newLimitMB: number;
1651
+ };
1652
+ }
1653
+ interface StorageByUser {
1654
+ userId: string;
1655
+ totalBytes: number;
1656
+ totalMB: number;
1657
+ fileCount: number;
1658
+ }
1659
+ type MetricType = 'count' | 'tokens' | 'cost' | 'bytes' | 'connections' | 'duration' | 'requests';
1660
+ type PeriodType = 'minute' | 'hour' | 'day' | 'month';
1661
+ type ResourceGateAction = 'block' | 'warn' | 'upgrade';
1662
+ type ResourceScope = 'user' | 'tenant';
1663
+ type ResourceCategory = 'compute' | 'storage' | 'network' | 'ai' | 'custom';
1664
+ interface ResourceDefinition {
1665
+ resource: string;
1666
+ metrics: MetricType[];
1667
+ description: string;
1668
+ category: ResourceCategory;
1669
+ }
1670
+ interface ResourceLimitConditions {
1671
+ roles?: string[];
1672
+ userTier?: string;
1673
+ }
1674
+ interface ResourceLimit {
1675
+ resource: string;
1676
+ metric: MetricType;
1677
+ period: PeriodType;
1678
+ limit: number;
1679
+ scope?: ResourceScope;
1680
+ tiers?: Record<string, number>;
1681
+ conditions?: ResourceLimitConditions;
1682
+ gateAction?: ResourceGateAction;
1683
+ }
1684
+ interface ResourceUsageStats {
1685
+ resource: string;
1686
+ metric: MetricType;
1687
+ period: PeriodType;
1688
+ current: number;
1689
+ limit: number;
1690
+ percentage: number;
1691
+ scope: ResourceScope;
1692
+ }
1693
+ interface ResourceCheckResult {
1694
+ allowed: boolean;
1695
+ gateAction: ResourceGateAction;
1696
+ reason?: string;
1697
+ usage: {
1698
+ current: number;
1699
+ limit: number;
1700
+ };
1701
+ upgrade?: {
1702
+ tier: string;
1703
+ newLimit: number;
1704
+ };
1705
+ warning?: boolean;
1706
+ }
1707
+ interface ResourceCheckContext {
1708
+ roles?: string[];
1709
+ userTier?: string;
1710
+ }
1711
+ declare class TenantResource {
1712
+ private client;
1713
+ constructor(client: BackflowClient);
1714
+ getConfig(): Promise<TenantConfigResponse>;
1715
+ updateConfig(config: Partial<TenantConfigData>, options?: {
1716
+ planTier?: string;
1717
+ isolationLevel?: string;
1718
+ metadata?: Record<string, unknown>;
1719
+ }): Promise<TenantConfigResponse>;
1720
+ updateSettings(settings: UpdateSettingsOptions): Promise<UpdateSettingsResponse>;
1721
+ get secrets(): SecretsResource;
1722
+ get apiKeys(): ApiKeysResource;
1723
+ get cache(): CacheResource;
1724
+ get domains(): DomainsResource;
1725
+ get apps(): AppsResource;
1726
+ get limits(): LimitsResource;
1727
+ get workflows(): TenantWorkflowsResource;
1728
+ get integrations(): TenantIntegrationsResource;
1729
+ get jobs(): TenantJobsResource;
1730
+ get rbac(): RBACResource;
1731
+ }
1732
+ declare class SecretsResource {
1733
+ private client;
1734
+ constructor(client: BackflowClient);
1735
+ set(key: string, value: string, metadata?: {
1736
+ type?: string;
1737
+ provider?: string;
1738
+ description?: string;
1739
+ }, expiresAt?: string): Promise<{
1740
+ success: boolean;
1741
+ }>;
1742
+ list(): Promise<SecretMetadata[]>;
1743
+ delete(key: string): Promise<{
1744
+ success: boolean;
1745
+ }>;
1746
+ rotate(key: string, newValue: string, gracePeriodDays?: number): Promise<{
1747
+ success: boolean;
1748
+ }>;
1749
+ }
1750
+ declare class ApiKeysResource {
1751
+ private client;
1752
+ constructor(client: BackflowClient);
1753
+ create(name: string, options?: {
1754
+ scopes?: string[];
1755
+ expiresAt?: Date;
1756
+ }): Promise<CreateApiKeyResult>;
1757
+ list(): Promise<ApiKeyMetadata[]>;
1758
+ revoke(keyId: string): Promise<{
1759
+ success: boolean;
1760
+ }>;
1761
+ rotate(keyId: string, gracePeriodDays?: number): Promise<CreateApiKeyResult>;
1762
+ }
1763
+ declare class DomainsResource {
1764
+ private client;
1765
+ constructor(client: BackflowClient);
1766
+ list(): Promise<TenantDomain[]>;
1767
+ add(domain: string, type?: 'primary' | 'alias'): Promise<AddDomainResult>;
1768
+ remove(domain: string): Promise<{
1769
+ success: boolean;
1770
+ }>;
1771
+ verify(domain: string): Promise<{
1772
+ verified: boolean;
1773
+ message?: string;
1774
+ }>;
1775
+ getVerificationInstructions(domain: string): Promise<VerificationInstructions>;
1776
+ }
1777
+ declare class AppsResource {
1778
+ private client;
1779
+ constructor(client: BackflowClient);
1780
+ list(): Promise<TenantApp[]>;
1781
+ create(options: CreateAppOptions): Promise<TenantApp>;
1782
+ delete(appId: string): Promise<{
1783
+ success: boolean;
1784
+ }>;
1785
+ getUsage(): Promise<AppUsage>;
1786
+ }
1787
+ declare class LimitsResource {
1788
+ private client;
1789
+ constructor(client: BackflowClient);
1790
+ get(): Promise<UserLimitsConfig>;
1791
+ update(config: Partial<UserLimitsConfig>): Promise<{
1792
+ success: boolean;
1793
+ message: string;
1794
+ }>;
1795
+ getLimit(collection: string): Promise<EntityLimitConfig | null>;
1796
+ setLimit(collection: string, config: EntityLimitConfig): Promise<{
1797
+ success: boolean;
1798
+ message: string;
1799
+ }>;
1800
+ deleteLimit(collection: string): Promise<{
1801
+ success: boolean;
1802
+ message: string;
1803
+ }>;
1804
+ getUsage(userId?: string): Promise<Record<string, UsageStats>>;
1805
+ check(userId: string, collection: string, action: 'create', userTier?: string): Promise<CheckLimitResult>;
1806
+ get storage(): StorageLimitsResource;
1807
+ get resources(): ResourceLimitsResource;
1808
+ }
1809
+ declare class StorageLimitsResource {
1810
+ private client;
1811
+ constructor(client: BackflowClient);
1812
+ getConfig(): Promise<StorageLimitsConfig | null>;
1813
+ updateConfig(config: Partial<StorageLimitsConfig>): Promise<{
1814
+ success: boolean;
1815
+ message: string;
1816
+ }>;
1817
+ getUsage(userId?: string, userTier?: string): Promise<StorageUsageStats | null>;
1818
+ check(userId: string, fileSizeBytes: number, userTier?: string): Promise<StorageCheckResult>;
1819
+ getByUser(): Promise<StorageByUser[]>;
1820
+ }
1821
+ declare class ResourceLimitsResource {
1822
+ private client;
1823
+ constructor(client: BackflowClient);
1824
+ getConfig(): Promise<ResourceLimit[]>;
1825
+ updateConfig(limits: ResourceLimit[]): Promise<{
1826
+ success: boolean;
1827
+ message: string;
1828
+ }>;
1829
+ getDefinitions(): Promise<ResourceDefinition[]>;
1830
+ getUsage(userId?: string, resource?: string): Promise<ResourceUsageStats[]>;
1831
+ check(resource: string, metric: MetricType, options?: {
1832
+ userId?: string;
1833
+ amount?: number;
1834
+ context?: ResourceCheckContext;
1835
+ }): Promise<ResourceCheckResult>;
1836
+ track(resource: string, metric: MetricType, options?: {
1837
+ userId?: string;
1838
+ amount?: number;
1839
+ }): Promise<{
1840
+ success: boolean;
1841
+ }>;
1842
+ }
1843
+ interface TenantWorkflowDefinition {
1844
+ id: string;
1845
+ name: string;
1846
+ description?: string;
1847
+ tools?: unknown[];
1848
+ workflows?: unknown[];
1849
+ trigger?: {
1850
+ type: 'manual' | 'event' | 'schedule' | 'webhook';
1851
+ config?: unknown;
1852
+ };
1853
+ [key: string]: unknown;
1854
+ }
1855
+ interface TenantWorkflow {
1856
+ id: string;
1857
+ tenantId: string;
1858
+ workflowId: string;
1859
+ name: string;
1860
+ description?: string;
1861
+ triggerType: 'manual' | 'event' | 'schedule' | 'webhook';
1862
+ isActive: boolean;
1863
+ version: number;
1864
+ definition: TenantWorkflowDefinition;
1865
+ isDefault?: boolean;
1866
+ createdAt?: string;
1867
+ updatedAt?: string;
1868
+ }
1869
+ declare class TenantWorkflowsResource {
1870
+ private client;
1871
+ constructor(client: BackflowClient);
1872
+ list(): Promise<TenantWorkflow[]>;
1873
+ get(workflowId: string): Promise<TenantWorkflow>;
1874
+ save(definition: TenantWorkflowDefinition): Promise<TenantWorkflow>;
1875
+ delete(workflowId: string): Promise<{
1876
+ success: boolean;
1877
+ }>;
1878
+ cloneFromDefault(workflowId: string): Promise<TenantWorkflow>;
1879
+ }
1880
+ interface TenantIntegrationDefinition {
1881
+ name: string;
1882
+ displayName?: string;
1883
+ description?: string;
1884
+ version?: string;
1885
+ baseUrl: string;
1886
+ auth?: {
1887
+ type: 'none' | 'bearer' | 'api_key' | 'oauth2' | 'basic';
1888
+ [key: string]: unknown;
1889
+ };
1890
+ defaultHeaders?: Record<string, string>;
1891
+ timeout?: number;
1892
+ endpoints?: unknown[];
1893
+ [key: string]: unknown;
1894
+ }
1895
+ interface TenantIntegration {
1896
+ id: string;
1897
+ tenantId: string;
1898
+ integrationId: string;
1899
+ name: string;
1900
+ displayName?: string;
1901
+ description?: string;
1902
+ baseUrl: string;
1903
+ authType: 'none' | 'bearer' | 'api_key' | 'oauth2' | 'basic';
1904
+ isActive: boolean;
1905
+ version: number;
1906
+ definition: TenantIntegrationDefinition;
1907
+ isDefault?: boolean;
1908
+ createdAt?: string;
1909
+ updatedAt?: string;
1910
+ }
1911
+ declare class TenantIntegrationsResource {
1912
+ private client;
1913
+ constructor(client: BackflowClient);
1914
+ list(): Promise<TenantIntegration[]>;
1915
+ get(integrationId: string): Promise<TenantIntegration>;
1916
+ save(definition: TenantIntegrationDefinition): Promise<TenantIntegration>;
1917
+ delete(integrationId: string): Promise<{
1918
+ success: boolean;
1919
+ }>;
1920
+ cloneFromDefault(integrationId: string): Promise<TenantIntegration>;
1921
+ }
1922
+ interface TenantJobDefinition {
1923
+ id: string;
1924
+ name: string;
1925
+ description?: string;
1926
+ queueName: string;
1927
+ handler: string;
1928
+ defaultOptions?: {
1929
+ attempts?: number;
1930
+ backoff?: {
1931
+ type: 'exponential' | 'fixed';
1932
+ delay: number;
1933
+ };
1934
+ delay?: number;
1935
+ priority?: number;
1936
+ timeout?: number;
1937
+ };
1938
+ defaultPayload?: unknown;
1939
+ }
1940
+ interface TenantJobDef {
1941
+ id: string;
1942
+ tenantId: string;
1943
+ jobDefId: string;
1944
+ name: string;
1945
+ description?: string;
1946
+ queueName: string;
1947
+ handler: string;
1948
+ defaultOptions?: TenantJobDefinition['defaultOptions'];
1949
+ defaultPayload?: unknown;
1950
+ isActive: boolean;
1951
+ createdAt?: string;
1952
+ updatedAt?: string;
1953
+ }
1954
+ interface TenantJobExecution {
1955
+ id: string;
1956
+ tenantId: string;
1957
+ jobDefId: string;
1958
+ jobId: string;
1959
+ queueName: string;
1960
+ status: 'pending' | 'active' | 'completed' | 'failed' | 'delayed';
1961
+ payload: unknown;
1962
+ result?: unknown;
1963
+ error?: string;
1964
+ attempts: number;
1965
+ startedAt?: string;
1966
+ completedAt?: string;
1967
+ createdAt: string;
1968
+ }
1969
+ declare class TenantJobsResource {
1970
+ private client;
1971
+ constructor(client: BackflowClient);
1972
+ listDefinitions(): Promise<TenantJobDef[]>;
1973
+ getDefinition(jobDefId: string): Promise<TenantJobDef>;
1974
+ saveDefinition(definition: TenantJobDefinition): Promise<TenantJobDef>;
1975
+ deleteDefinition(jobDefId: string): Promise<{
1976
+ success: boolean;
1977
+ }>;
1978
+ enqueue(jobDefId: string, payload?: unknown, options?: {
1979
+ delay?: number;
1980
+ priority?: number;
1981
+ }): Promise<TenantJobExecution>;
1982
+ listHistory(options?: {
1983
+ jobDefId?: string;
1984
+ limit?: number;
1985
+ offset?: number;
1986
+ }): Promise<TenantJobExecution[]>;
1987
+ }
1988
+ declare class RBACResource {
1989
+ private client;
1990
+ constructor(client: BackflowClient);
1991
+ getConfig(): Promise<TenantRBACConfig>;
1992
+ updateConfig(config: Partial<TenantRBACConfig>): Promise<{
1993
+ success: boolean;
1994
+ message: string;
1995
+ }>;
1996
+ listRoles(): Promise<TenantRole[]>;
1997
+ createRole(role: TenantRole): Promise<{
1998
+ success: boolean;
1999
+ message: string;
2000
+ role: TenantRole;
2001
+ }>;
2002
+ updateRole(name: string, updates: Omit<TenantRole, 'name'>): Promise<{
2003
+ success: boolean;
2004
+ message: string;
2005
+ role: TenantRole;
2006
+ }>;
2007
+ deleteRole(name: string): Promise<{
2008
+ success: boolean;
2009
+ message: string;
2010
+ }>;
2011
+ }
2012
+
2013
+ type EmbeddingContentType = 'article' | 'code' | 'conversation' | 'document' | 'general';
2014
+ interface EmbedDocumentOptions {
2015
+ document: string;
2016
+ documentId?: string;
2017
+ contentType?: EmbeddingContentType;
2018
+ metadata?: Record<string, unknown>;
2019
+ subscribable?: boolean;
2020
+ }
2021
+ interface EmbeddingResult {
2022
+ documentId: string;
2023
+ chunksCreated: number;
2024
+ success: boolean;
2025
+ }
2026
+ interface SubscribableResponse {
2027
+ accepted: true;
2028
+ jobId: string;
2029
+ subscribe: {
2030
+ sse: string;
2031
+ websocket: {
2032
+ path: string;
2033
+ channel: string;
2034
+ };
2035
+ poll: string;
2036
+ };
2037
+ }
2038
+ interface BatchEmbeddingDocument {
2039
+ document: string;
2040
+ documentId?: string;
2041
+ metadata?: Record<string, unknown>;
2042
+ }
2043
+ interface BatchEmbeddingResult {
2044
+ results: EmbeddingResult[];
2045
+ totalChunks: number;
2046
+ success: boolean;
2047
+ }
2048
+ interface DocumentSearchResult {
2049
+ content: string;
2050
+ score: number;
2051
+ metadata?: Record<string, unknown>;
2052
+ }
2053
+ interface EmbeddedDocument {
2054
+ documentId: string;
2055
+ chunkCount: number;
2056
+ metadata: Record<string, unknown>;
2057
+ }
2058
+ declare class EmbeddingsResource {
2059
+ private client;
2060
+ constructor(client: BackflowClient);
2061
+ listDocuments(limit?: number): Promise<{
2062
+ success: boolean;
2063
+ documents: EmbeddedDocument[];
2064
+ }>;
2065
+ embedDocument(options: EmbedDocumentOptions & {
2066
+ subscribable: true;
2067
+ }): Promise<SubscribableResponse>;
2068
+ embedDocument(options: EmbedDocumentOptions & {
2069
+ subscribable?: false;
2070
+ }): Promise<EmbeddingResult>;
2071
+ embedBatch(documents: BatchEmbeddingDocument[], contentType?: EmbeddingContentType): Promise<BatchEmbeddingResult>;
2072
+ search(documentId: string, query: string, limit?: number): Promise<{
2073
+ results: DocumentSearchResult[];
2074
+ }>;
2075
+ delete(documentId: string): Promise<{
2076
+ success: boolean;
2077
+ }>;
2078
+ semanticSearch(query: string, limit?: number): Promise<{
2079
+ results: DocumentSearchResult[];
2080
+ }>;
2081
+ }
2082
+
2083
+ interface UsageMetrics {
2084
+ userId: string;
2085
+ apiCalls: number;
2086
+ tokensUsed: number;
2087
+ storageUsed: number;
2088
+ workflowsRun: number;
2089
+ period: string;
2090
+ }
2091
+ interface UsageSummary {
2092
+ total: UsageMetrics;
2093
+ breakdown: {
2094
+ date: string;
2095
+ metrics: Partial<UsageMetrics>;
2096
+ }[];
2097
+ }
2098
+ declare class UsageResource {
2099
+ private client;
2100
+ constructor(client: BackflowClient);
2101
+ getMyUsage(): Promise<UsageMetrics>;
2102
+ getUserUsage(userId: string, options?: {
2103
+ startDate?: string;
2104
+ endDate?: string;
2105
+ }): Promise<UsageMetrics>;
2106
+ getSummary(userId: string): Promise<UsageSummary>;
2107
+ }
2108
+
2109
+ interface ProjectAnalytics {
2110
+ views: number;
2111
+ edits: number;
2112
+ collaborators: number;
2113
+ lastActive: string;
2114
+ }
2115
+ declare class AnalyticsResource {
2116
+ private client;
2117
+ constructor(client: BackflowClient);
2118
+ project(projectId: string): Promise<ProjectAnalytics>;
2119
+ }
2120
+
2121
+ interface GithubImportResult {
2122
+ diagram: unknown;
2123
+ r2Upload: {
2124
+ url: string;
2125
+ };
2126
+ }
2127
+ declare class GithubResource {
2128
+ private client;
2129
+ constructor(client: BackflowClient);
2130
+ import(owner: string, repo: string, options: {
2131
+ path: string;
2132
+ ref?: string;
2133
+ githubToken: string;
2134
+ }): Promise<GithubImportResult>;
2135
+ repos(): Promise<unknown[]>;
2136
+ contents(owner: string, repo: string, path?: string): Promise<unknown>;
2137
+ branches(owner: string, repo: string): Promise<unknown[]>;
2138
+ pulls(owner: string, repo: string): Promise<unknown[]>;
2139
+ getPull(owner: string, repo: string, pullNumber: string): Promise<unknown>;
2140
+ files(owner: string, repo: string, pullNumber: string): Promise<unknown[]>;
2141
+ }
2142
+
2143
+ declare class QueuesResource {
2144
+ private client;
2145
+ constructor(client: BackflowClient);
2146
+ /** Get all queues and their statistics (tenant-isolated) */
2147
+ list(): Promise<unknown>;
2148
+ /** Get statistics for a specific queue (tenant-isolated) */
2149
+ stats(name: string): Promise<unknown>;
2150
+ /** Get jobs from a queue (tenant-isolated) */
2151
+ jobs(name: string): Promise<unknown>;
2152
+ /** Add a job to the queue (with tenant isolation) */
2153
+ createJob(name: string, data: Record<string, unknown>): Promise<unknown>;
2154
+ /** Get a specific job (tenant-isolated) */
2155
+ getJob(name: string, jobId: string): Promise<unknown>;
2156
+ /** Retry a failed job (tenant-isolated) */
2157
+ retry(name: string, jobId: string, data: Record<string, unknown>): Promise<unknown>;
2158
+ /** Pause a queue (admin only - affects all tenants) */
2159
+ pause(name: string, data: Record<string, unknown>): Promise<unknown>;
2160
+ /** Resume a paused queue (admin only - affects all tenants) */
2161
+ resume(name: string, data: Record<string, unknown>): Promise<unknown>;
2162
+ /** Clean old jobs from queue (tenant-isolated) */
2163
+ createClean(name: string, data: Record<string, unknown>): Promise<unknown>;
2164
+ /** Get detailed performance metrics for a queue */
2165
+ metrics(name: string): Promise<unknown>;
2166
+ /** Subscribe to job updates via SSE. Returns unsubscribe function. */
2167
+ subscribe<T = unknown>(sseUrl: string, handlers: {
2168
+ onConnected?: () => void;
2169
+ onComplete?: (result: T) => void;
2170
+ onFailed?: (error: string) => void;
2171
+ onProgress?: (progress: number, message?: string) => void;
2172
+ onWarning?: (warning: string) => void;
2173
+ onError?: (error: Event) => void;
2174
+ }): () => void;
2175
+ }
2176
+
2177
+ type SearchMode = 'exact' | 'fuzzy' | 'hybrid';
2178
+ interface SearchOptions {
2179
+ q: string;
2180
+ mode?: SearchMode;
2181
+ limit?: number;
2182
+ threshold?: number;
2183
+ }
2184
+ interface SearchMeta {
2185
+ entity: string;
2186
+ query: string;
2187
+ mode: SearchMode;
2188
+ cached: boolean;
2189
+ latency: number;
2190
+ total: number;
2191
+ }
2192
+ interface SearchResponse<T = Record<string, unknown>> {
2193
+ results: T[];
2194
+ meta: SearchMeta;
2195
+ }
2196
+ interface IndexOptions {
2197
+ entity: string;
2198
+ ids?: string[];
2199
+ batchSize?: number;
2200
+ }
2201
+ interface IndexResult {
2202
+ success: boolean;
2203
+ entity: string;
2204
+ indexed: number;
2205
+ latency: number;
2206
+ }
2207
+ interface ReindexOptions {
2208
+ entity: string;
2209
+ batchSize?: number;
2210
+ }
2211
+ interface ReindexResult {
2212
+ success: boolean;
2213
+ entity: string;
2214
+ deleted: number;
2215
+ indexed: number;
2216
+ latency: number;
2217
+ }
2218
+ interface DeleteIndexResult {
2219
+ success: boolean;
2220
+ entity: string;
2221
+ deleted: number;
2222
+ latency: number;
2223
+ }
2224
+ interface SearchStats {
2225
+ enabled: boolean;
2226
+ configuredEntities: string[];
2227
+ defaultMode: SearchMode;
2228
+ cacheTTL: number;
2229
+ }
2230
+ interface SearchEntityConfig {
2231
+ searchFields: string[];
2232
+ filters?: Array<{
2233
+ column: string;
2234
+ operator: string;
2235
+ value: unknown;
2236
+ }>;
2237
+ idField?: string;
2238
+ }
2239
+ interface SearchConfig {
2240
+ enabled: boolean;
2241
+ defaultMode: SearchMode;
2242
+ defaultLimit: number;
2243
+ cacheTTL: number;
2244
+ threshold: number;
2245
+ entities: Record<string, SearchEntityConfig>;
2246
+ }
2247
+ interface ValidationError {
2248
+ field: string;
2249
+ message: string;
2250
+ }
2251
+ interface ValidationResult {
2252
+ valid: boolean;
2253
+ errors: ValidationError[];
2254
+ }
2255
+ /**
2256
+ * Context-aware field validator for search configuration
2257
+ *
2258
+ * @example
2259
+ * ```typescript
2260
+ * const validator = new SearchConfigValidator();
2261
+ *
2262
+ * // Validate entity config
2263
+ * const result = validator.validateEntityConfig('products', {
2264
+ * searchFields: ['name', 'description'],
2265
+ * filters: [{ column: 'is_active', operator: 'eq', value: true }]
2266
+ * });
2267
+ *
2268
+ * if (!result.valid) {
2269
+ * console.error('Validation errors:', result.errors);
2270
+ * }
2271
+ * ```
2272
+ */
2273
+ declare class SearchConfigValidator {
2274
+ private validOperators;
2275
+ private validModes;
2276
+ /**
2277
+ * Validate search options for a query
2278
+ */
2279
+ validateSearchOptions(options: SearchOptions): ValidationResult;
2280
+ /**
2281
+ * Validate entity configuration
2282
+ */
2283
+ validateEntityConfig(entity: string, config: SearchEntityConfig): ValidationResult;
2284
+ /**
2285
+ * Validate full search configuration
2286
+ */
2287
+ validateConfig(config: Partial<SearchConfig>): ValidationResult;
2288
+ }
2289
+ /**
2290
+ * Search resource for fast entity search
2291
+ *
2292
+ * @example
2293
+ * ```typescript
2294
+ * import { createBackflow } from '@backflow/sdk';
2295
+ *
2296
+ * const backflow = createBackflow({ apiKey: 'your-api-key' });
2297
+ *
2298
+ * // Search products with hybrid mode (vector + cache)
2299
+ * const results = await backflow.search.query('products', {
2300
+ * q: 'wireless headphones',
2301
+ * mode: 'hybrid',
2302
+ * limit: 10
2303
+ * });
2304
+ *
2305
+ * console.log(`Found ${results.meta.total} results in ${results.meta.latency}ms`);
2306
+ * console.log('Cached:', results.meta.cached);
2307
+ *
2308
+ * // Index products for vector search
2309
+ * await backflow.search.index({ entity: 'products' });
2310
+ *
2311
+ * // Search with exact mode (faster, no typo tolerance)
2312
+ * const exact = await backflow.search.query('products', {
2313
+ * q: 'Sony WH-1000XM5',
2314
+ * mode: 'exact'
2315
+ * });
2316
+ *
2317
+ * // Search with fuzzy mode (semantic, typo tolerant)
2318
+ * const fuzzy = await backflow.search.query('products', {
2319
+ * q: 'wireles headfones',
2320
+ * mode: 'fuzzy',
2321
+ * threshold: 0.6
2322
+ * });
2323
+ * ```
2324
+ */
2325
+ declare class SearchResource {
2326
+ private client;
2327
+ readonly validator: SearchConfigValidator;
2328
+ constructor(client: BackflowClient);
2329
+ /**
2330
+ * Search an entity
2331
+ *
2332
+ * @param entity - Entity/table name to search
2333
+ * @param options - Search options
2334
+ * @returns Search results with metadata
2335
+ *
2336
+ * @example
2337
+ * ```typescript
2338
+ * // Basic search
2339
+ * const results = await backflow.search.query('products', { q: 'laptop' });
2340
+ *
2341
+ * // Advanced search with all options
2342
+ * const results = await backflow.search.query('products', {
2343
+ * q: 'gaming laptop',
2344
+ * mode: 'hybrid', // 'exact' | 'fuzzy' | 'hybrid'
2345
+ * limit: 20, // max results
2346
+ * threshold: 0.7 // similarity threshold for fuzzy/hybrid
2347
+ * });
2348
+ *
2349
+ * // Access results
2350
+ * results.results.forEach(product => {
2351
+ * console.log(product.name, product._score); // _score for fuzzy results
2352
+ * });
2353
+ * ```
2354
+ */
2355
+ query<T = Record<string, unknown>>(entity: string, options: SearchOptions): Promise<SearchResponse<T>>;
2356
+ /**
2357
+ * Index entity records for vector search
2358
+ *
2359
+ * @param options - Index options
2360
+ * @returns Index result
2361
+ *
2362
+ * @example
2363
+ * ```typescript
2364
+ * // Index all products
2365
+ * const result = await backflow.search.index({ entity: 'products' });
2366
+ * console.log(`Indexed ${result.indexed} records in ${result.latency}ms`);
2367
+ *
2368
+ * // Index specific records
2369
+ * await backflow.search.index({
2370
+ * entity: 'products',
2371
+ * ids: ['prod_123', 'prod_456'],
2372
+ * batchSize: 50
2373
+ * });
2374
+ * ```
2375
+ */
2376
+ index(options: IndexOptions): Promise<IndexResult>;
2377
+ /**
2378
+ * Delete and reindex all records for an entity
2379
+ *
2380
+ * @param options - Reindex options
2381
+ * @returns Reindex result
2382
+ *
2383
+ * @example
2384
+ * ```typescript
2385
+ * // Reindex all products
2386
+ * const result = await backflow.search.reindex({ entity: 'products' });
2387
+ * console.log(`Deleted ${result.deleted}, indexed ${result.indexed}`);
2388
+ * ```
2389
+ */
2390
+ reindex(options: ReindexOptions): Promise<ReindexResult>;
2391
+ /**
2392
+ * Delete all indexed records for an entity
2393
+ *
2394
+ * @param entity - Entity name
2395
+ * @returns Delete result
2396
+ *
2397
+ * @example
2398
+ * ```typescript
2399
+ * await backflow.search.delete('products');
2400
+ * ```
2401
+ */
2402
+ delete(entity: string): Promise<DeleteIndexResult>;
2403
+ /**
2404
+ * Get search statistics
2405
+ *
2406
+ * @returns Search configuration stats
2407
+ *
2408
+ * @example
2409
+ * ```typescript
2410
+ * const stats = await backflow.search.stats();
2411
+ * console.log('Configured entities:', stats.configuredEntities);
2412
+ * console.log('Default mode:', stats.defaultMode);
2413
+ * ```
2414
+ */
2415
+ stats(): Promise<SearchStats>;
2416
+ }
2417
+
2418
+ declare class IntegrationsResource {
2419
+ private client;
2420
+ readonly stripe: StripeResource;
2421
+ readonly polar: PolarResource;
2422
+ constructor(client: BackflowClient);
2423
+ }
2424
+ declare class BackflowSDK {
2425
+ private client;
2426
+ readonly agentAnalysis: AgentAnalysisResource;
2427
+ readonly apikeys: ApiKeysResource$1;
2428
+ readonly apps: AppsResource$1;
2429
+ readonly assets: AssetsResource;
2430
+ readonly authentication: AuthenticationResource;
2431
+ readonly billing: BillingResource;
2432
+ readonly cache: CacheResource$1;
2433
+ readonly config: ConfigResource;
2434
+ readonly default: DefaultResource;
2435
+ readonly deployment: DeploymentResource;
2436
+ readonly domains: DomainsResource$1;
2437
+ readonly feedback: FeedbackResource;
2438
+ readonly goals: GoalsResource;
2439
+ readonly googleDrive: GoogleDriveResource;
2440
+ readonly jira: JiraResource;
2441
+ readonly llm: LlmResource;
2442
+ readonly mcptools: McpToolsResource;
2443
+ readonly mfa: MfaResource;
2444
+ readonly migration: MigrationResource;
2445
+ readonly projects: ProjectsResource;
2446
+ readonly publish: PublishResource;
2447
+ readonly secrets: SecretsResource$1;
2448
+ readonly system: SystemResource;
2449
+ readonly teams: TeamsResource;
2450
+ readonly tenantIntegrations: TenantIntegrationsResource$1;
2451
+ readonly tenantJobs: TenantJobsResource$1;
2452
+ readonly tenantLimits: TenantLimitsResource;
2453
+ readonly tenantRbac: TenantRbacResource;
2454
+ readonly tenantWebhookReceivers: TenantWebhookReceiversResource;
2455
+ readonly tenantWebhooks: TenantWebhooksResource;
2456
+ readonly tenantWorkflows: TenantWorkflowsResource$1;
2457
+ readonly tooldiscovery: ToolDiscoveryResource;
2458
+ readonly tracking: TrackingResource;
2459
+ readonly twitter: TwitterResource;
2460
+ readonly users: UsersResource;
2461
+ readonly websocket: WebsocketResource;
2462
+ readonly workspaces: WorkspacesResource;
2463
+ readonly integrations: IntegrationsResource;
2464
+ readonly files: FilesResource;
2465
+ readonly workflows: WorkflowsResource;
2466
+ readonly tenant: TenantResource;
2467
+ readonly embeddings: EmbeddingsResource;
2468
+ readonly usage: UsageResource;
2469
+ readonly analytics: AnalyticsResource;
2470
+ readonly github: GithubResource;
2471
+ readonly queues: QueuesResource;
2472
+ readonly search: SearchResource;
2473
+ readonly ai: AIResource;
2474
+ readonly collaboration: CollaborationResource;
2475
+ readonly webhooks: (projectId: string) => {
2476
+ trigger: (data: {
2477
+ event: string;
2478
+ data: unknown;
2479
+ }) => Promise<unknown>;
2480
+ };
2481
+ readonly exports: ExportsResource;
2482
+ readonly user: UserResource;
2483
+ readonly entities: EntitiesResource;
2484
+ constructor(config: BackflowConfig);
2485
+ get endpoint(): string;
2486
+ get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
2487
+ post<T>(path: string, data?: unknown, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
2488
+ put<T>(path: string, data?: unknown, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
2489
+ patch<T>(path: string, data?: unknown, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
2490
+ delete<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
2491
+ }
2492
+ type BackflowSDKWithDynamicResources = BackflowSDK & {
2493
+ [key: string]: {
2494
+ [method: string]: (...args: unknown[]) => Promise<unknown>;
2495
+ };
2496
+ };
2497
+ declare function createBackflow(config: BackflowConfig): BackflowSDKWithDynamicResources;
2498
+
2499
+ export { AgentAnalysisResource, AnalyticsResource$1 as AnalyticsResource, ApiKeysResource$1 as ApiKeysResource, AppsResource$1 as AppsResource, AssetsResource, AuthenticationResource, BackflowSDK as Backflow, BackflowClient, type BackflowConfig, type BackflowError, type BackflowResponse, BackflowSDK, type BackflowSDKWithDynamicResources, BillingResource, CACHE_OPERATIONS, CHUNKING_STRATEGIES, CLI_PROVIDERS, CONDITION_OPERATORS, CacheResource$1 as CacheResource, ConfigResource, DB_OPERATIONS, DB_PROVIDERS, type DatabaseFilter, type DatabaseFilterOperator, type DatabaseIntegrationAction, type DatabaseProvider, DefaultResource, DeploymentResource, DomainsResource$1 as DomainsResource, EmbeddingsResource$1 as EmbeddingsResource, FeedbackResource, FilesResource$1 as FilesResource, GithubResource$1 as GithubResource, GoalsResource, GoogleDriveResource, HTTP_METHODS, type HttpMethod, IMAGE_DETAILS, JiraResource, LLM_PROVIDERS, LlmResource, McpToolsResource, MfaResource, MigrationResource, NOTIFY_CHANNELS, NOTIFY_PRIORITIES, type NotifyChannel, type NotifyConfig, type NotifyPriority, type PausePoint, PolarResource, ProjectsResource, type PromptContextOptions, type PropertyValidation, PublishResource, QueuesResource$1 as QueuesResource, RAG_MODES, type RequestOptions, type SSESubscribeHandlers, STORAGE_OPERATIONS, SearchResource$1 as SearchResource, SecretsResource$1 as SecretsResource, StripeResource, SystemResource, TOOL_PARAM_CONTEXT, TOOL_TYPES, TRIGGER_TYPES, TeamsResource, TenantIntegrationsResource$1 as TenantIntegrationsResource, TenantJobsResource$1 as TenantJobsResource, TenantLimitsResource, TenantRbacResource, TenantWebhookReceiversResource, TenantWebhooksResource, TenantWorkflowsResource$1 as TenantWorkflowsResource, ToolDiscoveryResource, type ToolType, TrackingResource, type TriggerType, TwitterResource, UsageResource$1 as UsageResource, UsersResource, WORKFLOW_VALIDATION_SCHEMA, WebsocketResource, type WorkflowValidationSchema, WorkflowsResource$1 as WorkflowsResource, WorkspacesResource, createBackflow, toCompactContext, toPromptContext };