@scarletdb/sdk 0.1.1 → 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
@@ -5,37 +5,46 @@ Official TypeScript SDK for [Scarlet DB](https://scarletdb.space) - The modern B
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @scarlet/sdk
8
+ npm install @scarletdb/sdk
9
9
  # or
10
- pnpm add @scarlet/sdk
10
+ pnpm add @scarletdb/sdk
11
11
  # or
12
- yarn add @scarlet/sdk
12
+ yarn add @scarletdb/sdk
13
+ # or
14
+ bun add @scarletdb/sdk
13
15
  ```
14
16
 
15
- ## Quick Start
17
+ ## Quick Start (Server)
16
18
 
17
- ```typescript
18
- import { Scarlet } from '@scarlet/sdk';
19
+ ```ts
20
+ import { createScarlet } from '@scarletdb/sdk'
19
21
 
20
- // Initialize with your project API key
21
- const db = new Scarlet({
22
- apiKey: 'sk_live_your_api_key',
23
- });
22
+ const scarlet = createScarlet({
23
+ projectId: 'YOUR_PROJECT_ID',
24
+ apiKey: process.env.SCARLET_API_KEY!,
25
+ url: 'https://api.scarletdb.space',
26
+ })
27
+
28
+ const { rows } = await scarlet.from('users').select().limit(10).execute()
29
+ console.log(rows)
30
+ ```
24
31
 
25
- // Query data
26
- const users = await db.from('users').select().limit(10);
32
+ ## Quick Start (Browser)
27
33
 
28
- // Insert data
29
- await db.from('users').insert({
30
- name: 'John Doe',
31
- email: 'john@example.com',
32
- });
34
+ Do not ship secret API keys to the browser. Use a publishable key to mint short-lived tokens, and enable proof-of-possession.
33
35
 
34
- // Update data
35
- await db.from('users').update({ active: true }).where({ id: 1 });
36
+ ```ts
37
+ import { createScarlet } from '@scarletdb/sdk'
36
38
 
37
- // Delete data
38
- await db.from('users').delete().where({ id: 1 });
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)
39
48
  ```
40
49
 
41
50
  ## Features
@@ -46,26 +55,27 @@ Fluent query builder for CRUD operations on your database tables.
46
55
 
47
56
  ```typescript
48
57
  // Select with filters
49
- const activeUsers = await db
58
+ const activeUsers = await scarlet
50
59
  .from('users')
51
60
  .select('id', 'name', 'email')
52
61
  .where({ active: true })
53
62
  .orderBy('created_at', 'desc')
54
- .limit(20);
63
+ .limit(20)
64
+ .execute();
55
65
 
56
66
  // Insert single row
57
- const newUser = await db.from('users').insert({
67
+ const { row: newUser } = await scarlet.from('users').insert({
58
68
  name: 'Jane',
59
69
  email: 'jane@example.com',
60
- }).single();
70
+ });
61
71
 
62
72
  // Update with filters
63
- await db.from('users')
64
- .update({ last_login: new Date() })
65
- .where({ id: userId });
73
+ await scarlet.from('users')
74
+ .where({ id: userId })
75
+ .update({ last_login: new Date() });
66
76
 
67
77
  // Delete with filters
68
- await db.from('users').delete().where({ id: userId });
78
+ await scarlet.from('users').where({ id: userId }).delete();
69
79
  ```
70
80
 
71
81
  ### 📁 Storage
@@ -74,16 +84,14 @@ Upload, download, and manage files in cloud storage.
74
84
 
75
85
  ```typescript
76
86
  // Upload a file
77
- await db.storage.upload('avatars', file);
78
-
79
- // Get public URL
80
- const url = db.storage.getPublicUrl('avatars', 'avatar.png');
87
+ const uploaded = await scarlet.storage.upload('avatars', file, { randomId: true });
88
+ console.log(uploaded.url);
81
89
 
82
90
  // List files in bucket
83
- const files = await db.storage.list('avatars');
91
+ const files = await scarlet.storage.list('avatars');
84
92
 
85
93
  // Delete a file
86
- await db.storage.delete('avatars', 'old-avatar.png');
94
+ await scarlet.storage.delete('avatars', 'old-avatar.png');
87
95
  ```
88
96
 
89
97
  ### 📧 Email
@@ -92,7 +100,7 @@ Send transactional emails with custom domains.
92
100
 
93
101
  ```typescript
94
102
  // Send an email
95
- await db.email.send({
103
+ await scarlet.email.send({
96
104
  from: 'hello@myapp.com',
97
105
  to: 'user@email.com',
98
106
  subject: 'Welcome to MyApp!',
@@ -100,7 +108,7 @@ await db.email.send({
100
108
  });
101
109
 
102
110
  // List configured domains
103
- const domains = await db.email.listDomains();
111
+ const domains = await scarlet.email.listDomains();
104
112
  ```
105
113
 
106
114
  ### 🤖 AI Queries
@@ -109,50 +117,34 @@ Natural language to SQL conversion powered by AI.
109
117
 
110
118
  ```typescript
111
119
  // Query with natural language
112
- 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');
113
121
 
114
122
  console.log(result.sql); // Generated SQL
115
- console.log(result.rows); // Query results
116
- ```
117
-
118
- ### 🔧 Raw SQL
119
-
120
- Execute raw SQL queries when you need full control.
121
-
122
- ```typescript
123
- // Parameterized query (safe)
124
- const result = await db.sql(
125
- 'SELECT * FROM users WHERE created_at > $1 AND status = $2',
126
- [lastWeek, 'active']
127
- );
128
-
129
- // Access results
130
- console.log(result.rows);
131
- console.log(result.rowCount);
123
+ console.log(result.data); // Query results
132
124
  ```
133
125
 
134
126
  ## Configuration
135
127
 
136
128
  ```typescript
137
- const db = new Scarlet({
138
- // Required: Your project API key
139
- apiKey: 'sk_live_...',
140
-
141
- // Optional: Custom API URL (defaults to production)
142
- baseUrl: 'https://api.scarletdb.space',
143
-
144
- // 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!,
145
133
  timeout: 30000,
146
- });
134
+ })
147
135
  ```
148
136
 
149
137
  ## Error Handling
150
138
 
151
139
  ```typescript
152
- import { Scarlet, ScarletError } from '@scarlet/sdk';
140
+ import { createScarlet, ScarletError } from '@scarletdb/sdk';
153
141
 
154
142
  try {
155
- 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' });
156
148
  } catch (error) {
157
149
  if (error instanceof ScarletError) {
158
150
  console.error('Scarlet Error:', error.message);
@@ -175,8 +167,8 @@ interface User {
175
167
  }
176
168
 
177
169
  // Type-safe queries
178
- const users = await db.from<User>('users').select();
179
- // users is typed as User[]
170
+ const { rows } = await scarlet.from<User>('users').select().execute()
171
+ // rows is typed as User[]
180
172
  ```
181
173
 
182
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 };