@e-techsolutions/e-baas-sdk 1.0.2 → 1.0.4
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 +42 -0
- package/dist/index.d.ts +174 -5
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ const ebaas = createClient('https://your-project.e-baas.apiservices.app.br', 'yo
|
|
|
22
22
|
|
|
23
23
|
- **Authentication** - Email/password and OAuth providers (Google, GitHub, Facebook)
|
|
24
24
|
- **Database** - PostgreSQL with real-time subscriptions and RPC support
|
|
25
|
+
- **Custom Database** - Use your own PostgreSQL database with automatic detection
|
|
25
26
|
- **Storage** - File uploads with CDN integration and image transformations
|
|
26
27
|
- **Realtime** - WebSocket subscriptions for live data updates
|
|
27
28
|
- **Edge Functions** - Serverless functions with dual runtime (Node.js VM + Deno) and native SDK integration
|
|
@@ -90,6 +91,47 @@ const { data, error } = await ebaas.rpc('get_user_stats', {
|
|
|
90
91
|
});
|
|
91
92
|
```
|
|
92
93
|
|
|
94
|
+
### Custom Database
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
// Configure with automatic custom database detection
|
|
98
|
+
const ebaas = createClient(url, key, {
|
|
99
|
+
database: {
|
|
100
|
+
workspaceId: 'your-workspace-id',
|
|
101
|
+
autoDetectCustomDatabase: true
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Configure custom database credentials
|
|
106
|
+
const credentials = {
|
|
107
|
+
host: 'your-postgres-host.com',
|
|
108
|
+
port: 5432,
|
|
109
|
+
database: 'your_custom_db',
|
|
110
|
+
username: 'db_user',
|
|
111
|
+
password: 'db_password',
|
|
112
|
+
schema: 'custom_schema',
|
|
113
|
+
sslEnabled: true
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// Test connection
|
|
117
|
+
const testResult = await ebaas.database.testCustomConnection(credentials);
|
|
118
|
+
if (testResult.success) {
|
|
119
|
+
await ebaas.database.configureCustomDatabase(credentials);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Check status
|
|
123
|
+
const status = ebaas.getCustomDatabaseStatus();
|
|
124
|
+
console.log('Using custom database:', status.hasConfig);
|
|
125
|
+
|
|
126
|
+
// Use with different schema
|
|
127
|
+
const data = await ebaas.database
|
|
128
|
+
.schema('custom_schema')
|
|
129
|
+
.from('users')
|
|
130
|
+
.select('*');
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
For detailed information about custom database features, see [Custom Database Guide](./CUSTOM_DATABASE_GUIDE.md).
|
|
134
|
+
|
|
93
135
|
### Storage
|
|
94
136
|
|
|
95
137
|
```typescript
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HttpClient as HttpClient$1, EBaaSError as EBaaSError$1 } from 'infra';
|
|
2
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
3
|
import { SelectOptions as SelectOptions$1, InsertOptions as InsertOptions$1, UpdateOptions as UpdateOptions$1, DeleteOptions as DeleteOptions$1 } from 'infra/types/common';
|
|
3
4
|
import { Socket } from 'socket.io-client';
|
|
4
5
|
import { EventEmitter } from 'eventemitter3';
|
|
5
|
-
import { AxiosRequestConfig } from 'axios';
|
|
6
6
|
|
|
7
7
|
interface HttpClientConfig {
|
|
8
8
|
url: string;
|
|
@@ -47,6 +47,15 @@ declare class EBaaSError extends Error {
|
|
|
47
47
|
toString(): string;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
interface CustomDatabaseCredentials {
|
|
51
|
+
host: string;
|
|
52
|
+
port: number;
|
|
53
|
+
database: string;
|
|
54
|
+
username: string;
|
|
55
|
+
password: string;
|
|
56
|
+
schema?: string;
|
|
57
|
+
sslEnabled?: boolean;
|
|
58
|
+
}
|
|
50
59
|
interface EBaaSClientOptions {
|
|
51
60
|
supabaseUrl: string;
|
|
52
61
|
supabaseKey: string;
|
|
@@ -62,6 +71,11 @@ interface EBaaSClientOptions {
|
|
|
62
71
|
global?: {
|
|
63
72
|
headers?: Record<string, string>;
|
|
64
73
|
};
|
|
74
|
+
database?: {
|
|
75
|
+
customCredentials?: CustomDatabaseCredentials;
|
|
76
|
+
autoDetectCustomDatabase?: boolean;
|
|
77
|
+
workspaceId?: string;
|
|
78
|
+
};
|
|
65
79
|
};
|
|
66
80
|
}
|
|
67
81
|
interface DatabaseFilters {
|
|
@@ -167,11 +181,89 @@ declare class AuthClient {
|
|
|
167
181
|
private handleAuthError;
|
|
168
182
|
}
|
|
169
183
|
|
|
184
|
+
interface CustomDatabaseConfig {
|
|
185
|
+
id: string;
|
|
186
|
+
postgresHost: string;
|
|
187
|
+
postgresPort: number;
|
|
188
|
+
postgresDatabase: string;
|
|
189
|
+
postgresUsername: string;
|
|
190
|
+
postgresSchema: string;
|
|
191
|
+
sslEnabled: boolean;
|
|
192
|
+
lastConnectionTest: string;
|
|
193
|
+
isActive: boolean;
|
|
194
|
+
}
|
|
195
|
+
interface CustomDatabaseDetectionResult {
|
|
196
|
+
hasCustomDatabase: boolean;
|
|
197
|
+
config?: CustomDatabaseConfig;
|
|
198
|
+
credentials?: CustomDatabaseCredentials;
|
|
199
|
+
}
|
|
200
|
+
declare class CustomDatabaseManager {
|
|
201
|
+
private httpClient;
|
|
202
|
+
private workspaceId?;
|
|
203
|
+
private detectedConfig?;
|
|
204
|
+
constructor(httpClient: HttpClient, workspaceId?: string);
|
|
205
|
+
/**
|
|
206
|
+
* Detecta automaticamente se o workspace usa banco customizado
|
|
207
|
+
*/
|
|
208
|
+
detectCustomDatabase(): Promise<CustomDatabaseDetectionResult>;
|
|
209
|
+
/**
|
|
210
|
+
* Testa conexão com banco customizado
|
|
211
|
+
*/
|
|
212
|
+
testConnection(credentials: CustomDatabaseCredentials): Promise<{
|
|
213
|
+
success: boolean;
|
|
214
|
+
message: string;
|
|
215
|
+
}>;
|
|
216
|
+
/**
|
|
217
|
+
* Configura credenciais customizadas para o workspace
|
|
218
|
+
*/
|
|
219
|
+
configureCustomDatabase(credentials: CustomDatabaseCredentials): Promise<CustomDatabaseConfig>;
|
|
220
|
+
/**
|
|
221
|
+
* Remove configuração de banco customizado
|
|
222
|
+
*/
|
|
223
|
+
removeCustomDatabase(): Promise<void>;
|
|
224
|
+
/**
|
|
225
|
+
* Retorna a configuração detectada em cache
|
|
226
|
+
*/
|
|
227
|
+
getDetectedConfig(): CustomDatabaseDetectionResult | undefined;
|
|
228
|
+
/**
|
|
229
|
+
* Verifica se tem configuração customizada em cache
|
|
230
|
+
*/
|
|
231
|
+
hasCustomDatabase(): boolean;
|
|
232
|
+
/**
|
|
233
|
+
* Retorna as credenciais customizadas se disponíveis
|
|
234
|
+
*/
|
|
235
|
+
getCustomCredentials(): CustomDatabaseCredentials | undefined;
|
|
236
|
+
/**
|
|
237
|
+
* Atualiza o workspace ID
|
|
238
|
+
*/
|
|
239
|
+
setWorkspaceId(workspaceId: string): void;
|
|
240
|
+
/**
|
|
241
|
+
* Retorna o workspace ID atual
|
|
242
|
+
*/
|
|
243
|
+
getWorkspaceId(): string | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* Retorna informações sobre o status do banco customizado
|
|
246
|
+
*/
|
|
247
|
+
getStatus(): {
|
|
248
|
+
workspaceId?: string;
|
|
249
|
+
hasConfig: boolean;
|
|
250
|
+
lastDetection?: Date;
|
|
251
|
+
configDetails?: {
|
|
252
|
+
host: string;
|
|
253
|
+
port: number;
|
|
254
|
+
database: string;
|
|
255
|
+
schema: string;
|
|
256
|
+
sslEnabled: boolean;
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
170
261
|
declare class QueryBuilder<T = any> {
|
|
171
262
|
private httpClient;
|
|
172
263
|
private table;
|
|
264
|
+
private schema?;
|
|
173
265
|
private query;
|
|
174
|
-
constructor(httpClient: HttpClient$1, table: string);
|
|
266
|
+
constructor(httpClient: HttpClient$1, table: string, schema?: string);
|
|
175
267
|
select(columns?: string, options?: SelectOptions$1): this;
|
|
176
268
|
insert(data: Partial<T> | Partial<T>[], options?: InsertOptions$1): Promise<{
|
|
177
269
|
data: T[] | null;
|
|
@@ -220,10 +312,59 @@ declare class QueryBuilder<T = any> {
|
|
|
220
312
|
|
|
221
313
|
declare class DatabaseClient {
|
|
222
314
|
private httpClient;
|
|
223
|
-
|
|
315
|
+
private customDatabaseManager;
|
|
316
|
+
private currentSchema?;
|
|
317
|
+
constructor(httpClient: HttpClient$1, workspaceId?: string);
|
|
224
318
|
from(table: string): QueryBuilder;
|
|
225
319
|
rpc(fn: string, args?: Record<string, any>): Promise<any>;
|
|
226
320
|
schema(schema: string): DatabaseClient;
|
|
321
|
+
/**
|
|
322
|
+
* Detecta automaticamente se o workspace usa banco customizado
|
|
323
|
+
*/
|
|
324
|
+
detectCustomDatabase(): Promise<CustomDatabaseDetectionResult>;
|
|
325
|
+
/**
|
|
326
|
+
* Testa conexão com credenciais customizadas
|
|
327
|
+
*/
|
|
328
|
+
testCustomConnection(credentials: CustomDatabaseCredentials): Promise<{
|
|
329
|
+
success: boolean;
|
|
330
|
+
message: string;
|
|
331
|
+
}>;
|
|
332
|
+
/**
|
|
333
|
+
* Configura banco customizado para o workspace
|
|
334
|
+
*/
|
|
335
|
+
configureCustomDatabase(credentials: CustomDatabaseCredentials): Promise<CustomDatabaseConfig>;
|
|
336
|
+
/**
|
|
337
|
+
* Remove configuração de banco customizado
|
|
338
|
+
*/
|
|
339
|
+
removeCustomDatabase(): Promise<void>;
|
|
340
|
+
/**
|
|
341
|
+
* Verifica se o workspace está usando banco customizado
|
|
342
|
+
*/
|
|
343
|
+
isUsingCustomDatabase(): boolean;
|
|
344
|
+
/**
|
|
345
|
+
* Retorna informações sobre o banco customizado
|
|
346
|
+
*/
|
|
347
|
+
getCustomDatabaseStatus(): {
|
|
348
|
+
workspaceId?: string;
|
|
349
|
+
hasConfig: boolean;
|
|
350
|
+
lastDetection?: Date;
|
|
351
|
+
configDetails?: {
|
|
352
|
+
host: string;
|
|
353
|
+
port: number;
|
|
354
|
+
database: string;
|
|
355
|
+
schema: string;
|
|
356
|
+
sslEnabled: boolean;
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* Atualiza o workspace ID (útil quando o usuário troca de workspace)
|
|
361
|
+
*/
|
|
362
|
+
setWorkspaceId(workspaceId: string): void;
|
|
363
|
+
/**
|
|
364
|
+
* Inicializa a detecção automática do banco customizado
|
|
365
|
+
* Deve ser chamado após a autenticação se autoDetectCustomDatabase estiver habilitado
|
|
366
|
+
*/
|
|
367
|
+
initialize(): Promise<void>;
|
|
227
368
|
}
|
|
228
369
|
|
|
229
370
|
interface StorageFile {
|
|
@@ -604,6 +745,7 @@ declare class EBaaSClient {
|
|
|
604
745
|
readonly realtime: RealtimeClient;
|
|
605
746
|
readonly functions: FunctionsClient;
|
|
606
747
|
private httpClient;
|
|
748
|
+
private options?;
|
|
607
749
|
constructor(supabaseUrl: string, supabaseKey: string, options?: EBaaSClientOptions['options']);
|
|
608
750
|
from(table: string): QueryBuilder<any>;
|
|
609
751
|
rpc(fn: string, args?: Record<string, any>): Promise<any>;
|
|
@@ -613,10 +755,37 @@ declare class EBaaSClient {
|
|
|
613
755
|
data: any;
|
|
614
756
|
error: EBaaSError | null;
|
|
615
757
|
}>;
|
|
758
|
+
/**
|
|
759
|
+
* Inicializa a detecção automática de banco customizado
|
|
760
|
+
*/
|
|
761
|
+
private initializeCustomDatabase;
|
|
762
|
+
/**
|
|
763
|
+
* Atualiza o workspace ID para todos os módulos que precisam
|
|
764
|
+
*/
|
|
765
|
+
setWorkspaceId(workspaceId: string): Promise<void>;
|
|
766
|
+
/**
|
|
767
|
+
* Configura credenciais customizadas diretamente
|
|
768
|
+
*/
|
|
769
|
+
configureCustomDatabase(credentials: CustomDatabaseCredentials): Promise<void>;
|
|
770
|
+
/**
|
|
771
|
+
* Retorna informações sobre o banco customizado
|
|
772
|
+
*/
|
|
773
|
+
getCustomDatabaseStatus(): {
|
|
774
|
+
workspaceId?: string;
|
|
775
|
+
hasConfig: boolean;
|
|
776
|
+
lastDetection?: Date;
|
|
777
|
+
configDetails?: {
|
|
778
|
+
host: string;
|
|
779
|
+
port: number;
|
|
780
|
+
database: string;
|
|
781
|
+
schema: string;
|
|
782
|
+
sslEnabled: boolean;
|
|
783
|
+
};
|
|
784
|
+
};
|
|
616
785
|
}
|
|
617
786
|
declare function createClient(supabaseUrl: string, supabaseKey: string, options?: EBaaSClientOptions['options']): EBaaSClient;
|
|
618
787
|
|
|
619
788
|
declare const version = "1.0.0";
|
|
620
789
|
|
|
621
|
-
export { AuthClient, DatabaseClient, EBaaSClient, EBaaSError, FunctionsClient, HttpClient, QueryBuilder, RealtimeChannel, RealtimeClient, StorageBucket, StorageClient, createClient, version };
|
|
622
|
-
export type { AuthResponse, AuthSession, AuthUser, BroadcastFilter, Bucket, BucketOptions, ChannelSubscription, DatabaseFilters, DeleteOptions, EBaaSClientOptions, EdgeFunction, FunctionDeployOptions, FunctionInvokeOptions, FunctionListResponse, FunctionResponse, InsertOptions, OAuthProvider, PostgresChangesFilter, PresenceFilter, PresenceState, QueryOptions, RealtimeClientOptions, RealtimeEvent, SelectOptions, SignInData, SignUpData, StorageDownloadOptions, StorageFile, StorageListOptions, StorageUploadOptions, StorageUsage, UpdateOptions };
|
|
790
|
+
export { AuthClient, CustomDatabaseManager, DatabaseClient, EBaaSClient, EBaaSError, FunctionsClient, HttpClient, QueryBuilder, RealtimeChannel, RealtimeClient, StorageBucket, StorageClient, createClient, version };
|
|
791
|
+
export type { AuthResponse, AuthSession, AuthUser, BroadcastFilter, Bucket, BucketOptions, ChannelSubscription, CustomDatabaseConfig, CustomDatabaseCredentials, CustomDatabaseDetectionResult, DatabaseFilters, DeleteOptions, EBaaSClientOptions, EdgeFunction, FunctionDeployOptions, FunctionInvokeOptions, FunctionListResponse, FunctionResponse, InsertOptions, OAuthProvider, PostgresChangesFilter, PresenceFilter, PresenceState, QueryOptions, RealtimeClientOptions, RealtimeEvent, SelectOptions, SignInData, SignUpData, StorageDownloadOptions, StorageFile, StorageListOptions, StorageUploadOptions, StorageUsage, UpdateOptions };
|