@scarletdb/sdk 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,30 +14,37 @@ yarn add @scarletdb/sdk
14
14
  bun add @scarletdb/sdk
15
15
  ```
16
16
 
17
- ## Quick Start
17
+ ## Quick Start (Server)
18
18
 
19
- ```typescript
20
- import { Scarlet } from '@scarletdb/sdk';
19
+ ```ts
20
+ import { createScarlet } from '@scarletdb/sdk'
21
21
 
22
- // Initialize with your project API key
23
- const db = new Scarlet({
24
- apiKey: 'sk_live_your_api_key',
25
- });
22
+ const scarlet = createScarlet({
23
+ projectId: 'YOUR_PROJECT_ID',
24
+ apiKey: process.env.SCARLET_API_KEY!,
25
+ url: 'https://api.scarletdb.space',
26
+ })
26
27
 
27
- // Query data
28
- const users = await db.from('users').select().limit(10);
28
+ const { rows } = await scarlet.from('users').select().limit(10).execute()
29
+ console.log(rows)
30
+ ```
29
31
 
30
- // Insert data
31
- await db.from('users').insert({
32
- name: 'John Doe',
33
- email: 'john@example.com',
34
- });
32
+ ## Quick Start (Browser)
35
33
 
36
- // Update data
37
- await db.from('users').update({ active: true }).where({ id: 1 });
34
+ Do not ship secret API keys to the browser. Use a publishable key to mint short-lived tokens, and enable proof-of-possession.
38
35
 
39
- // Delete data
40
- await db.from('users').delete().where({ id: 1 });
36
+ ```ts
37
+ import { createScarlet } from '@scarletdb/sdk'
38
+
39
+ const scarlet = createScarlet({
40
+ projectId: 'YOUR_PROJECT_ID',
41
+ url: 'https://api.scarletdb.space',
42
+ publishableKey: 'pk_***************',
43
+ enableDpop: true,
44
+ })
45
+
46
+ const { rows } = await scarlet.from('users').select().limit(10).execute()
47
+ console.log(rows)
41
48
  ```
42
49
 
43
50
  ## Features
@@ -48,26 +55,27 @@ Fluent query builder for CRUD operations on your database tables.
48
55
 
49
56
  ```typescript
50
57
  // Select with filters
51
- const activeUsers = await db
58
+ const activeUsers = await scarlet
52
59
  .from('users')
53
60
  .select('id', 'name', 'email')
54
61
  .where({ active: true })
55
62
  .orderBy('created_at', 'desc')
56
- .limit(20);
63
+ .limit(20)
64
+ .execute();
57
65
 
58
66
  // Insert single row
59
- const newUser = await db.from('users').insert({
67
+ const { row: newUser } = await scarlet.from('users').insert({
60
68
  name: 'Jane',
61
69
  email: 'jane@example.com',
62
- }).single();
70
+ });
63
71
 
64
72
  // Update with filters
65
- await db.from('users')
66
- .update({ last_login: new Date() })
67
- .where({ id: userId });
73
+ await scarlet.from('users')
74
+ .where({ id: userId })
75
+ .update({ last_login: new Date() });
68
76
 
69
77
  // Delete with filters
70
- await db.from('users').delete().where({ id: userId });
78
+ await scarlet.from('users').where({ id: userId }).delete();
71
79
  ```
72
80
 
73
81
  ### 📁 Storage
@@ -76,16 +84,14 @@ Upload, download, and manage files in cloud storage.
76
84
 
77
85
  ```typescript
78
86
  // Upload a file
79
- await db.storage.upload('avatars', file);
80
-
81
- // Get public URL
82
- const url = db.storage.getPublicUrl('avatars', 'avatar.png');
87
+ const uploaded = await scarlet.storage.upload('avatars', file, { randomId: true });
88
+ console.log(uploaded.url);
83
89
 
84
90
  // List files in bucket
85
- const files = await db.storage.list('avatars');
91
+ const files = await scarlet.storage.list('avatars');
86
92
 
87
93
  // Delete a file
88
- await db.storage.delete('avatars', 'old-avatar.png');
94
+ await scarlet.storage.delete('avatars', 'old-avatar.png');
89
95
  ```
90
96
 
91
97
  ### 📧 Email
@@ -94,7 +100,7 @@ Send transactional emails with custom domains.
94
100
 
95
101
  ```typescript
96
102
  // Send an email
97
- await db.email.send({
103
+ await scarlet.email.send({
98
104
  from: 'hello@myapp.com',
99
105
  to: 'user@email.com',
100
106
  subject: 'Welcome to MyApp!',
@@ -102,7 +108,7 @@ await db.email.send({
102
108
  });
103
109
 
104
110
  // List configured domains
105
- const domains = await db.email.listDomains();
111
+ const domains = await scarlet.email.listDomains();
106
112
  ```
107
113
 
108
114
  ### 🤖 AI Queries
@@ -111,50 +117,34 @@ Natural language to SQL conversion powered by AI.
111
117
 
112
118
  ```typescript
113
119
  // Query with natural language
114
- const result = await db.ai.query('Show me all users who signed up last week');
120
+ const result = await scarlet.ai.query('Show me all users who signed up last week');
115
121
 
116
122
  console.log(result.sql); // Generated SQL
117
- console.log(result.rows); // Query results
118
- ```
119
-
120
- ### 🔧 Raw SQL
121
-
122
- Execute raw SQL queries when you need full control.
123
-
124
- ```typescript
125
- // Parameterized query (safe)
126
- const result = await db.sql(
127
- 'SELECT * FROM users WHERE created_at > $1 AND status = $2',
128
- [lastWeek, 'active']
129
- );
130
-
131
- // Access results
132
- console.log(result.rows);
133
- console.log(result.rowCount);
123
+ console.log(result.data); // Query results
134
124
  ```
135
125
 
136
126
  ## Configuration
137
127
 
138
128
  ```typescript
139
- const db = new Scarlet({
140
- // Required: Your project API key
141
- apiKey: 'sk_live_...',
142
-
143
- // Optional: Custom API URL (defaults to production)
144
- baseUrl: 'https://api.scarletdb.space',
145
-
146
- // Optional: Request timeout in ms (default: 30000)
129
+ const scarlet = createScarlet({
130
+ projectId: 'YOUR_PROJECT_ID',
131
+ url: 'https://api.scarletdb.space',
132
+ apiKey: process.env.SCARLET_API_KEY!,
147
133
  timeout: 30000,
148
- });
134
+ })
149
135
  ```
150
136
 
151
137
  ## Error Handling
152
138
 
153
139
  ```typescript
154
- import { Scarlet, ScarletError } from '@scarletdb/sdk';
140
+ import { createScarlet, ScarletError } from '@scarletdb/sdk';
155
141
 
156
142
  try {
157
- await db.from('users').insert({ email: 'invalid' });
143
+ const scarlet = createScarlet({
144
+ projectId: 'YOUR_PROJECT_ID',
145
+ apiKey: process.env.SCARLET_API_KEY!,
146
+ })
147
+ await scarlet.from('users').insert({ email: 'invalid' });
158
148
  } catch (error) {
159
149
  if (error instanceof ScarletError) {
160
150
  console.error('Scarlet Error:', error.message);
@@ -177,8 +167,8 @@ interface User {
177
167
  }
178
168
 
179
169
  // Type-safe queries
180
- const users = await db.from<User>('users').select();
181
- // users is typed as User[]
170
+ const { rows } = await scarlet.from<User>('users').select().execute()
171
+ // rows is typed as User[]
182
172
  ```
183
173
 
184
174
  ## License
package/dist/index.d.mts CHANGED
@@ -2,10 +2,16 @@
2
2
  * Scarlet SDK - Type Definitions
3
3
  */
4
4
  interface ScarletConfig {
5
- /** Project API key (required) */
6
- apiKey: string;
7
- /** Base URL for the API (defaults to production) */
8
- baseUrl?: string;
5
+ projectId: string;
6
+ apiKey?: string;
7
+ publishableKey?: string;
8
+ token?: string;
9
+ getToken?: () => Promise<string>;
10
+ url?: string;
11
+ coreUrl?: string;
12
+ engineUrl?: string;
13
+ tokenEndpoint?: string;
14
+ enableDpop?: boolean;
9
15
  /** Request timeout in milliseconds (default: 30000) */
10
16
  timeout?: number;
11
17
  }
@@ -99,19 +105,10 @@ interface EmailLog {
99
105
  error?: string;
100
106
  }
101
107
  interface AIQueryResult {
102
- /** Generated SQL query */
108
+ success: boolean;
103
109
  sql: string;
104
- /** Natural language explanation */
105
110
  explanation: string;
106
- /** Query execution results */
107
- result: {
108
- rows: Record<string, unknown>[];
109
- fields: {
110
- name: string;
111
- dataType: number;
112
- }[];
113
- };
114
- /** Error if query failed */
111
+ data: Record<string, unknown>[];
115
112
  error?: string;
116
113
  details?: string;
117
114
  }
@@ -144,24 +141,24 @@ interface APIResponse<T> {
144
141
  */
145
142
 
146
143
  interface ClientConfig {
147
- apiKey: string;
148
144
  baseUrl: string;
149
145
  timeout: number;
146
+ getAuthHeaders: (params: {
147
+ method: string;
148
+ url: string;
149
+ }) => Promise<Record<string, string>>;
150
150
  }
151
151
  declare class HttpClient {
152
152
  private readonly config;
153
153
  constructor(config: ClientConfig);
154
154
  request<T>(options: RequestOptions): Promise<APIResponse<T>>;
155
155
  private handleErrorResponse;
156
- get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
157
- post<T>(path: string, body?: unknown): Promise<T>;
158
- patch<T>(path: string, body?: unknown): Promise<T>;
159
- put<T>(path: string, body?: unknown): Promise<T>;
160
- delete<T>(path: string, body?: unknown): Promise<T>;
161
- /**
162
- * Upload file using multipart/form-data
163
- */
164
- upload<T>(path: string, file: Blob, fileName?: string): Promise<T>;
156
+ get<T>(path: string, params?: Record<string, string | number | boolean | undefined>, headers?: Record<string, string>): Promise<T>;
157
+ post<T>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
158
+ patch<T>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
159
+ put<T>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
160
+ delete<T>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
161
+ postForm<T>(path: string, form: FormData): Promise<T>;
165
162
  }
166
163
 
167
164
  /**
@@ -172,11 +169,11 @@ declare class HttpClient {
172
169
  declare class QueryBuilder<T = Record<string, unknown>> {
173
170
  private readonly client;
174
171
  private readonly table;
175
- private _columns;
176
- private _where;
177
- private _orderBy?;
172
+ private _fields;
173
+ private _filters;
174
+ private _sort?;
175
+ private _page?;
178
176
  private _limit?;
179
- private _offset?;
180
177
  constructor(client: HttpClient, table: string);
181
178
  /**
182
179
  * Select specific columns (default: all)
@@ -196,14 +193,12 @@ declare class QueryBuilder<T = Record<string, unknown>> {
196
193
  * Order results
197
194
  */
198
195
  orderBy(column: keyof T & string, direction?: OrderDirection): this;
196
+ page(page: number): this;
199
197
  /**
200
198
  * Limit results
201
199
  */
202
200
  limit(count: number): this;
203
- /**
204
- * Offset results (for pagination)
205
- */
206
- offset(count: number): this;
201
+ private buildQueryParams;
207
202
  /**
208
203
  * Execute SELECT query
209
204
  */
@@ -237,8 +232,8 @@ declare class QueryBuilder<T = Record<string, unknown>> {
237
232
 
238
233
  declare class StorageModule {
239
234
  private readonly client;
240
- private readonly baseUrl;
241
- constructor(client: HttpClient, baseUrl: string);
235
+ private readonly projectId;
236
+ constructor(client: HttpClient, projectId: string);
242
237
  /**
243
238
  * Create a new storage bucket
244
239
  */
@@ -252,7 +247,16 @@ declare class StorageModule {
252
247
  /**
253
248
  * Upload a file to a bucket
254
249
  */
255
- upload(bucket: string, file: Blob | File, options?: UploadOptions): Promise<StorageFile>;
250
+ upload(bucket: string, file: Blob | File, options?: UploadOptions & {
251
+ randomId?: boolean;
252
+ cacheDuration?: number;
253
+ }): Promise<{
254
+ fileId: string;
255
+ url: string;
256
+ key: string;
257
+ bucket: string;
258
+ fileName: string;
259
+ }>;
256
260
  /**
257
261
  * List files in a bucket
258
262
  */
@@ -264,7 +268,6 @@ declare class StorageModule {
264
268
  /**
265
269
  * Get public URL for a file (bucket must be public)
266
270
  */
267
- getPublicUrl(bucket: string, fileName: string): string;
268
271
  /**
269
272
  * Delete a file
270
273
  */
@@ -287,7 +290,9 @@ declare class StorageModule {
287
290
 
288
291
  declare class EmailModule {
289
292
  private readonly client;
290
- constructor(client: HttpClient);
293
+ private readonly projectId;
294
+ constructor(client: HttpClient, projectId: string);
295
+ private headers;
291
296
  /**
292
297
  * Send a transactional email
293
298
  */
@@ -325,7 +330,8 @@ declare class EmailModule {
325
330
 
326
331
  declare class AIModule {
327
332
  private readonly client;
328
- constructor(client: HttpClient);
333
+ private readonly projectId;
334
+ constructor(client: HttpClient, projectId: string);
329
335
  /**
330
336
  * Execute a natural language query
331
337
  * Converts natural language to SQL and executes it
@@ -336,40 +342,12 @@ declare class AIModule {
336
342
  * console.log(result.rows); // Query results
337
343
  */
338
344
  query(prompt: string): Promise<AIQueryResult>;
339
- /**
340
- * Generate SQL from natural language without executing
341
- */
342
345
  generateSQL(prompt: string): Promise<{
343
346
  sql: string;
344
347
  explanation: string;
345
348
  }>;
346
349
  }
347
350
 
348
- /**
349
- * Scarlet SDK - SQL Module
350
- * Raw SQL query execution
351
- */
352
-
353
- declare class SQLModule {
354
- private readonly client;
355
- constructor(client: HttpClient);
356
- /**
357
- * Execute a parameterized SQL query
358
- *
359
- * @example
360
- * const result = await db.sql.query(
361
- * 'SELECT * FROM users WHERE created_at > $1',
362
- * [new Date('2024-01-01')]
363
- * );
364
- */
365
- query<T = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<SQLResult<T>>;
366
- /**
367
- * Execute raw SQL without parameter binding
368
- * ⚠️ Use with caution - ensure input is sanitized
369
- */
370
- unsafe<T = Record<string, unknown>>(sql: string): Promise<SQLResult<T>>;
371
- }
372
-
373
351
  /**
374
352
  * Scarlet SDK - Error Classes
375
353
  */
@@ -434,7 +412,8 @@ declare class RateLimitError extends ScarletError {
434
412
  * Main Scarlet SDK client
435
413
  */
436
414
  declare class Scarlet {
437
- private readonly client;
415
+ private readonly engineClient;
416
+ private readonly coreClient;
438
417
  private readonly _data;
439
418
  /** Storage module for file operations */
440
419
  readonly storage: StorageModule;
@@ -442,10 +421,7 @@ declare class Scarlet {
442
421
  readonly email: EmailModule;
443
422
  /** AI module for natural language queries */
444
423
  readonly ai: AIModule;
445
- /** SQL module for raw queries */
446
- readonly sql: SQLModule & {
447
- <T = Record<string, unknown>>(strings: TemplateStringsArray, ...values: unknown[]): Promise<SQLResult<T>>;
448
- };
424
+ readonly projectId: string;
449
425
  constructor(config: ScarletConfig);
450
426
  /**
451
427
  * Start a query on a table
@@ -455,5 +431,6 @@ declare class Scarlet {
455
431
  */
456
432
  from<T = Record<string, unknown>>(table: string): QueryBuilder<T>;
457
433
  }
434
+ declare function createScarlet(config: ScarletConfig): Scarlet;
458
435
 
459
- export { type AIQueryResult, type APIResponse, AuthenticationError, type DeleteResult, type EmailDomain, type EmailLog, type FilterOperator, type FilterValue, type InsertResult, type ListFilesOptions, NetworkError, NotFoundError, type OrderDirection, QueryBuilder, type QueryResult, RateLimitError, type RequestOptions, type SQLResult, Scarlet, type ScarletConfig, ScarletError, type SendEmailOptions, type StorageBucket, type StorageFile, type UpdateResult, type UploadOptions, ValidationError, type WhereCondition };
436
+ export { type AIQueryResult, type APIResponse, AuthenticationError, type DeleteResult, type EmailDomain, type EmailLog, type FilterOperator, type FilterValue, type InsertResult, type ListFilesOptions, NetworkError, NotFoundError, type OrderDirection, QueryBuilder, type QueryResult, RateLimitError, type RequestOptions, type SQLResult, Scarlet, type ScarletConfig, ScarletError, type SendEmailOptions, type StorageBucket, type StorageFile, type UpdateResult, type UploadOptions, ValidationError, type WhereCondition, createScarlet };
package/dist/index.d.ts CHANGED
@@ -2,10 +2,16 @@
2
2
  * Scarlet SDK - Type Definitions
3
3
  */
4
4
  interface ScarletConfig {
5
- /** Project API key (required) */
6
- apiKey: string;
7
- /** Base URL for the API (defaults to production) */
8
- baseUrl?: string;
5
+ projectId: string;
6
+ apiKey?: string;
7
+ publishableKey?: string;
8
+ token?: string;
9
+ getToken?: () => Promise<string>;
10
+ url?: string;
11
+ coreUrl?: string;
12
+ engineUrl?: string;
13
+ tokenEndpoint?: string;
14
+ enableDpop?: boolean;
9
15
  /** Request timeout in milliseconds (default: 30000) */
10
16
  timeout?: number;
11
17
  }
@@ -99,19 +105,10 @@ interface EmailLog {
99
105
  error?: string;
100
106
  }
101
107
  interface AIQueryResult {
102
- /** Generated SQL query */
108
+ success: boolean;
103
109
  sql: string;
104
- /** Natural language explanation */
105
110
  explanation: string;
106
- /** Query execution results */
107
- result: {
108
- rows: Record<string, unknown>[];
109
- fields: {
110
- name: string;
111
- dataType: number;
112
- }[];
113
- };
114
- /** Error if query failed */
111
+ data: Record<string, unknown>[];
115
112
  error?: string;
116
113
  details?: string;
117
114
  }
@@ -144,24 +141,24 @@ interface APIResponse<T> {
144
141
  */
145
142
 
146
143
  interface ClientConfig {
147
- apiKey: string;
148
144
  baseUrl: string;
149
145
  timeout: number;
146
+ getAuthHeaders: (params: {
147
+ method: string;
148
+ url: string;
149
+ }) => Promise<Record<string, string>>;
150
150
  }
151
151
  declare class HttpClient {
152
152
  private readonly config;
153
153
  constructor(config: ClientConfig);
154
154
  request<T>(options: RequestOptions): Promise<APIResponse<T>>;
155
155
  private handleErrorResponse;
156
- get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
157
- post<T>(path: string, body?: unknown): Promise<T>;
158
- patch<T>(path: string, body?: unknown): Promise<T>;
159
- put<T>(path: string, body?: unknown): Promise<T>;
160
- delete<T>(path: string, body?: unknown): Promise<T>;
161
- /**
162
- * Upload file using multipart/form-data
163
- */
164
- upload<T>(path: string, file: Blob, fileName?: string): Promise<T>;
156
+ get<T>(path: string, params?: Record<string, string | number | boolean | undefined>, headers?: Record<string, string>): Promise<T>;
157
+ post<T>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
158
+ patch<T>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
159
+ put<T>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
160
+ delete<T>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
161
+ postForm<T>(path: string, form: FormData): Promise<T>;
165
162
  }
166
163
 
167
164
  /**
@@ -172,11 +169,11 @@ declare class HttpClient {
172
169
  declare class QueryBuilder<T = Record<string, unknown>> {
173
170
  private readonly client;
174
171
  private readonly table;
175
- private _columns;
176
- private _where;
177
- private _orderBy?;
172
+ private _fields;
173
+ private _filters;
174
+ private _sort?;
175
+ private _page?;
178
176
  private _limit?;
179
- private _offset?;
180
177
  constructor(client: HttpClient, table: string);
181
178
  /**
182
179
  * Select specific columns (default: all)
@@ -196,14 +193,12 @@ declare class QueryBuilder<T = Record<string, unknown>> {
196
193
  * Order results
197
194
  */
198
195
  orderBy(column: keyof T & string, direction?: OrderDirection): this;
196
+ page(page: number): this;
199
197
  /**
200
198
  * Limit results
201
199
  */
202
200
  limit(count: number): this;
203
- /**
204
- * Offset results (for pagination)
205
- */
206
- offset(count: number): this;
201
+ private buildQueryParams;
207
202
  /**
208
203
  * Execute SELECT query
209
204
  */
@@ -237,8 +232,8 @@ declare class QueryBuilder<T = Record<string, unknown>> {
237
232
 
238
233
  declare class StorageModule {
239
234
  private readonly client;
240
- private readonly baseUrl;
241
- constructor(client: HttpClient, baseUrl: string);
235
+ private readonly projectId;
236
+ constructor(client: HttpClient, projectId: string);
242
237
  /**
243
238
  * Create a new storage bucket
244
239
  */
@@ -252,7 +247,16 @@ declare class StorageModule {
252
247
  /**
253
248
  * Upload a file to a bucket
254
249
  */
255
- upload(bucket: string, file: Blob | File, options?: UploadOptions): Promise<StorageFile>;
250
+ upload(bucket: string, file: Blob | File, options?: UploadOptions & {
251
+ randomId?: boolean;
252
+ cacheDuration?: number;
253
+ }): Promise<{
254
+ fileId: string;
255
+ url: string;
256
+ key: string;
257
+ bucket: string;
258
+ fileName: string;
259
+ }>;
256
260
  /**
257
261
  * List files in a bucket
258
262
  */
@@ -264,7 +268,6 @@ declare class StorageModule {
264
268
  /**
265
269
  * Get public URL for a file (bucket must be public)
266
270
  */
267
- getPublicUrl(bucket: string, fileName: string): string;
268
271
  /**
269
272
  * Delete a file
270
273
  */
@@ -287,7 +290,9 @@ declare class StorageModule {
287
290
 
288
291
  declare class EmailModule {
289
292
  private readonly client;
290
- constructor(client: HttpClient);
293
+ private readonly projectId;
294
+ constructor(client: HttpClient, projectId: string);
295
+ private headers;
291
296
  /**
292
297
  * Send a transactional email
293
298
  */
@@ -325,7 +330,8 @@ declare class EmailModule {
325
330
 
326
331
  declare class AIModule {
327
332
  private readonly client;
328
- constructor(client: HttpClient);
333
+ private readonly projectId;
334
+ constructor(client: HttpClient, projectId: string);
329
335
  /**
330
336
  * Execute a natural language query
331
337
  * Converts natural language to SQL and executes it
@@ -336,40 +342,12 @@ declare class AIModule {
336
342
  * console.log(result.rows); // Query results
337
343
  */
338
344
  query(prompt: string): Promise<AIQueryResult>;
339
- /**
340
- * Generate SQL from natural language without executing
341
- */
342
345
  generateSQL(prompt: string): Promise<{
343
346
  sql: string;
344
347
  explanation: string;
345
348
  }>;
346
349
  }
347
350
 
348
- /**
349
- * Scarlet SDK - SQL Module
350
- * Raw SQL query execution
351
- */
352
-
353
- declare class SQLModule {
354
- private readonly client;
355
- constructor(client: HttpClient);
356
- /**
357
- * Execute a parameterized SQL query
358
- *
359
- * @example
360
- * const result = await db.sql.query(
361
- * 'SELECT * FROM users WHERE created_at > $1',
362
- * [new Date('2024-01-01')]
363
- * );
364
- */
365
- query<T = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<SQLResult<T>>;
366
- /**
367
- * Execute raw SQL without parameter binding
368
- * ⚠️ Use with caution - ensure input is sanitized
369
- */
370
- unsafe<T = Record<string, unknown>>(sql: string): Promise<SQLResult<T>>;
371
- }
372
-
373
351
  /**
374
352
  * Scarlet SDK - Error Classes
375
353
  */
@@ -434,7 +412,8 @@ declare class RateLimitError extends ScarletError {
434
412
  * Main Scarlet SDK client
435
413
  */
436
414
  declare class Scarlet {
437
- private readonly client;
415
+ private readonly engineClient;
416
+ private readonly coreClient;
438
417
  private readonly _data;
439
418
  /** Storage module for file operations */
440
419
  readonly storage: StorageModule;
@@ -442,10 +421,7 @@ declare class Scarlet {
442
421
  readonly email: EmailModule;
443
422
  /** AI module for natural language queries */
444
423
  readonly ai: AIModule;
445
- /** SQL module for raw queries */
446
- readonly sql: SQLModule & {
447
- <T = Record<string, unknown>>(strings: TemplateStringsArray, ...values: unknown[]): Promise<SQLResult<T>>;
448
- };
424
+ readonly projectId: string;
449
425
  constructor(config: ScarletConfig);
450
426
  /**
451
427
  * Start a query on a table
@@ -455,5 +431,6 @@ declare class Scarlet {
455
431
  */
456
432
  from<T = Record<string, unknown>>(table: string): QueryBuilder<T>;
457
433
  }
434
+ declare function createScarlet(config: ScarletConfig): Scarlet;
458
435
 
459
- export { type AIQueryResult, type APIResponse, AuthenticationError, type DeleteResult, type EmailDomain, type EmailLog, type FilterOperator, type FilterValue, type InsertResult, type ListFilesOptions, NetworkError, NotFoundError, type OrderDirection, QueryBuilder, type QueryResult, RateLimitError, type RequestOptions, type SQLResult, Scarlet, type ScarletConfig, ScarletError, type SendEmailOptions, type StorageBucket, type StorageFile, type UpdateResult, type UploadOptions, ValidationError, type WhereCondition };
436
+ export { type AIQueryResult, type APIResponse, AuthenticationError, type DeleteResult, type EmailDomain, type EmailLog, type FilterOperator, type FilterValue, type InsertResult, type ListFilesOptions, NetworkError, NotFoundError, type OrderDirection, QueryBuilder, type QueryResult, RateLimitError, type RequestOptions, type SQLResult, Scarlet, type ScarletConfig, ScarletError, type SendEmailOptions, type StorageBucket, type StorageFile, type UpdateResult, type UploadOptions, ValidationError, type WhereCondition, createScarlet };