@boltic/sdk 0.0.7 → 0.0.8
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 +106 -0
- package/dist/databases/index.d.ts +263 -40
- package/dist/databases/index.js +1 -1
- package/dist/databases/index.js.map +1 -1
- package/dist/databases/index.mjs +2 -2
- package/dist/databases/index.mjs.map +1 -1
- package/dist/databases/test-client-BuQuW6Y-.js +2 -0
- package/dist/databases/test-client-BuQuW6Y-.js.map +1 -0
- package/dist/databases/{test-client-rQ1AmTo6.mjs → test-client-D8i2zDgI.mjs} +994 -171
- package/dist/databases/test-client-D8i2zDgI.mjs.map +1 -0
- package/dist/databases/testing.d.ts +249 -103
- package/dist/databases/testing.js +1 -1
- package/dist/databases/testing.mjs +1 -1
- package/dist/sdk.js +929 -171
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.mjs +929 -171
- package/dist/sdk.mjs.map +1 -1
- package/dist/types/index.d.ts +213 -40
- package/package.json +11 -8
- package/dist/databases/test-client-DfOmma3t.js +0 -2
- package/dist/databases/test-client-DfOmma3t.js.map +0 -1
- package/dist/databases/test-client-rQ1AmTo6.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -116,6 +116,99 @@ const currentDb = client.getCurrentDatabase();
|
|
|
116
116
|
console.log('Current database:', currentDb);
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
+
## Custom Databases
|
|
120
|
+
|
|
121
|
+
By default, all `tables`, `columns`, `records`, `indexes`, and `sql` operations run against your **default Boltic Cloud database**. You can create additional databases and switch between them using `client.databases` + `client.useDatabase()`.
|
|
122
|
+
|
|
123
|
+
### Creating a Database
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
const { data: database, error } = await client.databases.create({
|
|
127
|
+
db_name: 'My Custom Database',
|
|
128
|
+
// db_internal_name: 'my_custom_db', // optional; auto-derived if omitted
|
|
129
|
+
// resource_id: 'boltic' // optional (default). For custom resources, use a connector id starting with 'btb-'
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
if (error) {
|
|
133
|
+
console.error('Failed to create database:', error.message);
|
|
134
|
+
} else {
|
|
135
|
+
console.log('Created database:', database.db_internal_name);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Listing Databases
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
const { data: databases, error } = await client.databases.findAll({
|
|
143
|
+
page: { page_no: 1, page_size: 10 },
|
|
144
|
+
sort: [{ field: 'db_name', direction: 'asc' }],
|
|
145
|
+
// connector_id: 'btb-abc123xyz', // optional: list databases for a custom resource
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
if (!error) {
|
|
149
|
+
databases.forEach((db) =>
|
|
150
|
+
console.log(`${db.db_name} (${db.db_internal_name})`)
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Getting a Database (or Default Database)
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
const { data: db, error } = await client.databases.findOne('my_custom_db');
|
|
159
|
+
const { data: defaultDb } = await client.databases.getDefault();
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Updating a Database (Display Name)
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
const result = await client.databases.update('my_custom_db', {
|
|
166
|
+
db_name: 'Updated Database Name',
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Deleting a Database (Async) + Polling Status
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
const { data: job, error } = await client.databases.delete('old_db_slug');
|
|
174
|
+
|
|
175
|
+
if (error) {
|
|
176
|
+
console.error('Failed to delete database:', error.message);
|
|
177
|
+
} else {
|
|
178
|
+
console.log('Deletion job started:', job.job_id);
|
|
179
|
+
|
|
180
|
+
const { data: status } = await client.databases.pollDeleteStatus(job.job_id);
|
|
181
|
+
console.log('Deletion status:', status.status, '-', status.message);
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Listing Database Jobs
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
const { data: jobs } = await client.databases.listJobs({
|
|
189
|
+
deleted_by_me: true,
|
|
190
|
+
page: { page_no: 1, page_size: 20 },
|
|
191
|
+
sort: [{ field: 'created_at', direction: 'desc' }],
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Switching Database Context
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
// Switch to a custom database (by internal name / slug)
|
|
199
|
+
await client.useDatabase('my_custom_db');
|
|
200
|
+
|
|
201
|
+
// All subsequent operations target this database
|
|
202
|
+
await client.tables.findAll();
|
|
203
|
+
await client.records.findAll('users');
|
|
204
|
+
|
|
205
|
+
// Inspect current context (null means default database)
|
|
206
|
+
console.log(client.getCurrentDatabase());
|
|
207
|
+
|
|
208
|
+
// Switch back to default database
|
|
209
|
+
await client.useDatabase();
|
|
210
|
+
```
|
|
211
|
+
|
|
119
212
|
## Table Operations
|
|
120
213
|
|
|
121
214
|
### Reserved Columns
|
|
@@ -925,6 +1018,19 @@ main().catch(console.error);
|
|
|
925
1018
|
### Core Client
|
|
926
1019
|
|
|
927
1020
|
- **`createClient(apiKey: string, options?: ClientOptions)`**: Initialize the Boltic client
|
|
1021
|
+
- **`client.useDatabase(dbInternalName?: string)`**: Switch the active database context (omit/reset to use default database)
|
|
1022
|
+
- **`client.getCurrentDatabase()`**: Get the current database context (`null` means default database)
|
|
1023
|
+
|
|
1024
|
+
### Databases (Custom Databases)
|
|
1025
|
+
|
|
1026
|
+
- **`client.databases.create(data)`**: Create a new database
|
|
1027
|
+
- **`client.databases.findAll(options?)`**: List active databases with optional pagination/sorting/filtering
|
|
1028
|
+
- **`client.databases.findOne(dbInternalName, options?)`**: Get a database by internal name (slug)
|
|
1029
|
+
- **`client.databases.getDefault()`**: Get the default database
|
|
1030
|
+
- **`client.databases.update(dbInternalName, data)`**: Update database display name
|
|
1031
|
+
- **`client.databases.delete(dbInternalName)`**: Delete a database (starts an async job; default database cannot be deleted)
|
|
1032
|
+
- **`client.databases.listJobs(options?)`**: List database jobs (primarily deletion jobs)
|
|
1033
|
+
- **`client.databases.pollDeleteStatus(jobId)`**: Poll status of an async deletion job
|
|
928
1034
|
|
|
929
1035
|
### Tables
|
|
930
1036
|
|
|
@@ -102,10 +102,44 @@ export declare class BolticClient {
|
|
|
102
102
|
private recordResource;
|
|
103
103
|
private sqlResource;
|
|
104
104
|
private indexResource;
|
|
105
|
+
private databaseResource;
|
|
105
106
|
private currentDatabase;
|
|
106
107
|
private clientOptions;
|
|
107
108
|
constructor(apiKey: string, options?: ClientOptions);
|
|
109
|
+
/**
|
|
110
|
+
* Get current database context
|
|
111
|
+
*/
|
|
108
112
|
getCurrentDatabase(): DatabaseContext | null;
|
|
113
|
+
/**
|
|
114
|
+
* Switch to a different database using its internal name (slug).
|
|
115
|
+
* All subsequent operations will use this database.
|
|
116
|
+
*
|
|
117
|
+
* If no internal name is provided, the SDK will switch back to the default database.
|
|
118
|
+
*
|
|
119
|
+
* @param dbInternalName - Database internal name/slug to switch to. If omitted or empty, default DB is used.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* // Switch to a specific database by slug
|
|
124
|
+
* await client.useDatabase('my_database_slug');
|
|
125
|
+
*
|
|
126
|
+
* // Switch back to default database
|
|
127
|
+
* await client.useDatabase();
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
useDatabase(dbInternalName?: string): Promise<void>;
|
|
131
|
+
get databases(): {
|
|
132
|
+
create: (data: DatabaseCreateRequest) => Promise<BolticErrorResponse | BolticSuccessResponse<DatabaseRecord>>;
|
|
133
|
+
findAll: (options?: DatabaseQueryOptions) => Promise<BolticErrorResponse | BolticListResponse<DatabaseRecord>>;
|
|
134
|
+
findOne: (dbInternalName: string, options?: {
|
|
135
|
+
fields?: string[];
|
|
136
|
+
}) => Promise<BolticErrorResponse | BolticSuccessResponse<DatabaseRecord>>;
|
|
137
|
+
getDefault: () => Promise<BolticErrorResponse | BolticSuccessResponse<DatabaseRecord>>;
|
|
138
|
+
update: (dbInternalName: string, data: DatabaseUpdateRequest) => Promise<BolticErrorResponse | BolticSuccessResponse<DatabaseRecord>>;
|
|
139
|
+
delete: (dbInternalName: string) => Promise<BolticErrorResponse | BolticSuccessResponse<DatabaseDeletionJobResponse>>;
|
|
140
|
+
listJobs: (options?: DatabaseJobQueryOptions) => Promise<BolticErrorResponse | BolticListResponse<DatabaseJobRecord>>;
|
|
141
|
+
pollDeleteStatus: (jobId: string) => Promise<BolticErrorResponse | BolticSuccessResponse<DatabaseDeletionStatusResponse>>;
|
|
142
|
+
};
|
|
109
143
|
get tables(): {
|
|
110
144
|
create: (data: TableCreateRequest) => Promise<BolticSuccessResponse<TableCreateResponse>>;
|
|
111
145
|
findAll: (options?: TableQueryOptions) => Promise<ApiResponse<TableRecord>>;
|
|
@@ -113,8 +147,8 @@ export declare class BolticClient {
|
|
|
113
147
|
findByName: (name: string) => Promise<BolticErrorResponse | BolticSuccessResponse<TableRecord | null>>;
|
|
114
148
|
findOne: (options: TableQueryOptions) => Promise<BolticErrorResponse | BolticSuccessResponse<TableRecord | null>>;
|
|
115
149
|
update: (name: string, data: TableUpdateRequest) => Promise<BolticErrorResponse | BolticSuccessResponse<TableRecord>>;
|
|
116
|
-
delete: (name: string) => Promise<BolticErrorResponse | BolticSuccessResponse<
|
|
117
|
-
|
|
150
|
+
delete: (name: string) => Promise<BolticErrorResponse | BolticSuccessResponse<{
|
|
151
|
+
message: string;
|
|
118
152
|
}>>;
|
|
119
153
|
rename: (oldName: string, newName: string) => Promise<BolticSuccessResponse<TableRecord>>;
|
|
120
154
|
setAccess: (request: {
|
|
@@ -129,9 +163,9 @@ export declare class BolticClient {
|
|
|
129
163
|
findOne: (tableName: string, columnName: string) => Promise<BolticErrorResponse | BolticSuccessResponse<ColumnDetails>>;
|
|
130
164
|
findById: (tableName: string, columnId: string) => Promise<BolticErrorResponse | BolticSuccessResponse<ColumnDetails>>;
|
|
131
165
|
update: (tableName: string, columnName: string, updates: ColumnUpdateRequest) => Promise<BolticErrorResponse | BolticSuccessResponse<ColumnDetails>>;
|
|
132
|
-
delete: (tableName: string, columnName: string) => Promise<BolticErrorResponse | BolticSuccessResponse<
|
|
133
|
-
|
|
134
|
-
|
|
166
|
+
delete: (tableName: string, columnName: string) => Promise<BolticErrorResponse | BolticSuccessResponse<{
|
|
167
|
+
success: boolean;
|
|
168
|
+
message?: string | undefined;
|
|
135
169
|
}>>;
|
|
136
170
|
};
|
|
137
171
|
get indexes(): {
|
|
@@ -141,15 +175,10 @@ export declare class BolticClient {
|
|
|
141
175
|
};
|
|
142
176
|
table(name: string): TableBuilder;
|
|
143
177
|
from(tableName: string): {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
update: (columnName: string, updates: ColumnUpdateRequest) => Promise<BolticErrorResponse | BolticSuccessResponse<ColumnDetails>>;
|
|
149
|
-
delete: (columnName: string) => Promise<BolticErrorResponse | BolticSuccessResponse< {
|
|
150
|
-
success: boolean;
|
|
151
|
-
message?: string | undefined;
|
|
152
|
-
}>>;
|
|
178
|
+
indexes: () => {
|
|
179
|
+
addIndex: (payload: AddIndexRequest) => Promise<BolticErrorResponse | BolticSuccessResponse<AddIndexResponse>>;
|
|
180
|
+
listIndexes: (query: ListIndexesQuery) => Promise<BolticErrorResponse | BolticSuccessResponse<ListIndexesResponse>>;
|
|
181
|
+
deleteIndex: (indexName: string) => Promise<BolticErrorResponse | BolticSuccessResponse<DeleteIndexResponse>>;
|
|
153
182
|
};
|
|
154
183
|
records: () => {
|
|
155
184
|
insert: (data: RecordData) => Promise<BolticErrorResponse | BolticSuccessResponse<RecordWithId>>;
|
|
@@ -159,19 +188,13 @@ export declare class BolticClient {
|
|
|
159
188
|
findOne: (recordId: string) => Promise<BolticErrorResponse | BolticSuccessResponse<RecordWithId>>;
|
|
160
189
|
update: (options: RecordUpdateOptions) => Promise<BolticErrorResponse | BolticListResponse<RecordWithId>>;
|
|
161
190
|
updateById: (recordId: string, data: RecordData) => Promise<BolticErrorResponse | BolticSuccessResponse<RecordWithId>>;
|
|
162
|
-
delete: (options: RecordDeleteOptions) => Promise<BolticErrorResponse | BolticSuccessResponse<
|
|
163
|
-
|
|
191
|
+
delete: (options: RecordDeleteOptions) => Promise<BolticErrorResponse | BolticSuccessResponse<{
|
|
192
|
+
message: string;
|
|
164
193
|
}>>;
|
|
165
|
-
deleteById: (recordId: string) => Promise<BolticErrorResponse | BolticSuccessResponse<
|
|
166
|
-
|
|
194
|
+
deleteById: (recordId: string) => Promise<BolticErrorResponse | BolticSuccessResponse<{
|
|
195
|
+
message: string;
|
|
167
196
|
}>>;
|
|
168
197
|
};
|
|
169
|
-
record: () => RecordBuilder;
|
|
170
|
-
indexes: () => {
|
|
171
|
-
addIndex: (payload: AddIndexRequest) => Promise<BolticErrorResponse | BolticSuccessResponse<AddIndexResponse>>;
|
|
172
|
-
listIndexes: (query: ListIndexesQuery) => Promise<BolticErrorResponse | BolticSuccessResponse<ListIndexesResponse>>;
|
|
173
|
-
deleteIndex: (indexName: string) => Promise<BolticErrorResponse | BolticSuccessResponse<DeleteIndexResponse>>;
|
|
174
|
-
};
|
|
175
198
|
};
|
|
176
199
|
get records(): {
|
|
177
200
|
insert: (tableName: string, data: RecordData) => Promise<BolticErrorResponse | BolticSuccessResponse<RecordWithId>>;
|
|
@@ -182,11 +205,11 @@ export declare class BolticClient {
|
|
|
182
205
|
findOne: (tableName: string, recordId: string) => Promise<BolticErrorResponse | BolticSuccessResponse<RecordWithId>>;
|
|
183
206
|
update: (tableName: string, options: RecordUpdateOptions) => Promise<BolticErrorResponse | BolticListResponse<RecordWithId>>;
|
|
184
207
|
updateById: (tableName: string, recordId: string, data: RecordData) => Promise<BolticErrorResponse | BolticSuccessResponse<RecordWithId>>;
|
|
185
|
-
delete: (tableName: string, options: RecordDeleteOptions) => Promise<BolticErrorResponse | BolticSuccessResponse<
|
|
186
|
-
|
|
208
|
+
delete: (tableName: string, options: RecordDeleteOptions) => Promise<BolticErrorResponse | BolticSuccessResponse<{
|
|
209
|
+
message: string;
|
|
187
210
|
}>>;
|
|
188
|
-
deleteById: (tableName: string, recordId: string) => Promise<BolticErrorResponse | BolticSuccessResponse<
|
|
189
|
-
|
|
211
|
+
deleteById: (tableName: string, recordId: string) => Promise<BolticErrorResponse | BolticSuccessResponse<{
|
|
212
|
+
message: string;
|
|
190
213
|
}>>;
|
|
191
214
|
};
|
|
192
215
|
record(tableName: string): RecordBuilder;
|
|
@@ -587,8 +610,167 @@ export declare function createTestClient(options?: MockClientOptions): BolticCli
|
|
|
587
610
|
export declare interface CrudOperations<TCreate, TUpdate, TResult, TQuery = unknown> extends CreateOperation<TCreate, TResult>, ReadOperation<TQuery, TResult>, UpdateOperation<TUpdate, TResult>, DeleteOperation {
|
|
588
611
|
}
|
|
589
612
|
|
|
613
|
+
/**
|
|
614
|
+
* Database API endpoint definition
|
|
615
|
+
*/
|
|
616
|
+
export declare interface DatabaseApiEndpoint {
|
|
617
|
+
path: string;
|
|
618
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
619
|
+
authenticated: boolean;
|
|
620
|
+
rateLimit?: {
|
|
621
|
+
requests: number;
|
|
622
|
+
window: number;
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
|
|
590
626
|
declare interface DatabaseContext {
|
|
591
|
-
|
|
627
|
+
databaseId?: string;
|
|
628
|
+
dbInternalName?: string;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Request to create a new database
|
|
633
|
+
*/
|
|
634
|
+
export declare interface DatabaseCreateRequest {
|
|
635
|
+
db_name: string;
|
|
636
|
+
db_internal_name?: string;
|
|
637
|
+
resource_id?: string;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Database deletion job initial response
|
|
642
|
+
*/
|
|
643
|
+
export declare interface DatabaseDeletionJobResponse {
|
|
644
|
+
job_id: string;
|
|
645
|
+
db_id: string;
|
|
646
|
+
status: 'pending';
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Database deletion status response
|
|
651
|
+
*/
|
|
652
|
+
export declare interface DatabaseDeletionStatusResponse {
|
|
653
|
+
jobId: string;
|
|
654
|
+
status: DatabaseJobStatus;
|
|
655
|
+
message: string;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Database Job action enum
|
|
660
|
+
*/
|
|
661
|
+
export declare type DatabaseJobAction = 'DELETE';
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Request to list database jobs
|
|
665
|
+
*/
|
|
666
|
+
export declare interface DatabaseJobListRequest {
|
|
667
|
+
page?: PaginationParams;
|
|
668
|
+
sort?: SortParams[];
|
|
669
|
+
filters?: FilterParams[];
|
|
670
|
+
deleted_by_me?: boolean;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Database job query options for SDK methods
|
|
675
|
+
*/
|
|
676
|
+
export declare interface DatabaseJobQueryOptions {
|
|
677
|
+
deleted_by_me?: boolean;
|
|
678
|
+
page?: PaginationParams;
|
|
679
|
+
sort?: SortParams[];
|
|
680
|
+
filters?: FilterParams[];
|
|
681
|
+
fields?: string[];
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Database job record from API
|
|
686
|
+
*/
|
|
687
|
+
export declare interface DatabaseJobRecord {
|
|
688
|
+
id: string;
|
|
689
|
+
account_id: string;
|
|
690
|
+
resource_id: string;
|
|
691
|
+
type: string;
|
|
692
|
+
action: DatabaseJobAction;
|
|
693
|
+
db_id: string;
|
|
694
|
+
db_internal_name: string;
|
|
695
|
+
db_username: string;
|
|
696
|
+
job_status: DatabaseJobStatus;
|
|
697
|
+
total_dbs: number;
|
|
698
|
+
successful_dbs: number;
|
|
699
|
+
failed_dbs: number;
|
|
700
|
+
error: string | null;
|
|
701
|
+
is_read: boolean;
|
|
702
|
+
created_by: string;
|
|
703
|
+
created_at: string;
|
|
704
|
+
updated_at: string;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Database Job status enum
|
|
709
|
+
*/
|
|
710
|
+
export declare type DatabaseJobStatus = 'pending' | 'in_progress' | 'success' | 'failed';
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Query parameters for list databases endpoint
|
|
714
|
+
*/
|
|
715
|
+
export declare interface DatabaseListQueryParams {
|
|
716
|
+
connector_id?: string;
|
|
717
|
+
add_default_if_missing?: 'true' | 'false';
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Request to list databases
|
|
722
|
+
*/
|
|
723
|
+
export declare interface DatabaseListRequest {
|
|
724
|
+
page?: PaginationParams;
|
|
725
|
+
sort?: SortParams[];
|
|
726
|
+
filters?: FilterParams[];
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Database query options for SDK methods
|
|
731
|
+
*/
|
|
732
|
+
export declare interface DatabaseQueryOptions {
|
|
733
|
+
connector_id?: string;
|
|
734
|
+
add_default_if_missing?: boolean;
|
|
735
|
+
page?: PaginationParams;
|
|
736
|
+
sort?: SortParams[];
|
|
737
|
+
filters?: FilterParams[];
|
|
738
|
+
fields?: string[];
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* Database record from API
|
|
743
|
+
*/
|
|
744
|
+
export declare interface DatabaseRecord {
|
|
745
|
+
id: string;
|
|
746
|
+
account_id: string;
|
|
747
|
+
db_name: string;
|
|
748
|
+
db_internal_name: string;
|
|
749
|
+
db_username: string;
|
|
750
|
+
resource_id: string;
|
|
751
|
+
status: DatabaseStatus;
|
|
752
|
+
is_default: boolean;
|
|
753
|
+
rank: number;
|
|
754
|
+
created_by: string;
|
|
755
|
+
updated_by: string;
|
|
756
|
+
created_at: string;
|
|
757
|
+
updated_at: string;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* Database Management API Types
|
|
762
|
+
* Based on DATABASE_MANAGEMENT_API_CONTRACT.md
|
|
763
|
+
*/
|
|
764
|
+
/**
|
|
765
|
+
* Database status enum
|
|
766
|
+
*/
|
|
767
|
+
export declare type DatabaseStatus = 'ACTIVE' | 'INACTIVE';
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Request to update a database
|
|
771
|
+
*/
|
|
772
|
+
export declare interface DatabaseUpdateRequest {
|
|
773
|
+
db_name: string;
|
|
592
774
|
}
|
|
593
775
|
|
|
594
776
|
declare const DateFormatEnum: Readonly<{
|
|
@@ -752,6 +934,15 @@ export declare class FilterBuilder {
|
|
|
752
934
|
clear(): FilterBuilder;
|
|
753
935
|
}
|
|
754
936
|
|
|
937
|
+
/**
|
|
938
|
+
* Filter parameters
|
|
939
|
+
*/
|
|
940
|
+
export declare interface FilterParams {
|
|
941
|
+
field: string;
|
|
942
|
+
operator: string;
|
|
943
|
+
values: any[];
|
|
944
|
+
}
|
|
945
|
+
|
|
755
946
|
/**
|
|
756
947
|
* Formats error for logging/debugging
|
|
757
948
|
*/
|
|
@@ -898,6 +1089,24 @@ declare interface PaginationInfo_2 {
|
|
|
898
1089
|
pages: number;
|
|
899
1090
|
}
|
|
900
1091
|
|
|
1092
|
+
/**
|
|
1093
|
+
* Pagination metadata in response
|
|
1094
|
+
*/
|
|
1095
|
+
export declare interface PaginationMetadata {
|
|
1096
|
+
total_count: number;
|
|
1097
|
+
current_page: number;
|
|
1098
|
+
per_page: number;
|
|
1099
|
+
total_pages?: number;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* Pagination parameters
|
|
1104
|
+
*/
|
|
1105
|
+
export declare interface PaginationParams {
|
|
1106
|
+
page_no?: number;
|
|
1107
|
+
page_size?: number;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
901
1110
|
declare type PhoneFormatType = '+91 123 456 7890' | '(123) 456-7890' | '+1 (123) 456-7890' | '+91 12 3456 7890';
|
|
902
1111
|
|
|
903
1112
|
export declare interface QueryOperator<T = unknown> {
|
|
@@ -1101,37 +1310,37 @@ declare class RecordResource {
|
|
|
1101
1310
|
/**
|
|
1102
1311
|
* Insert a single record
|
|
1103
1312
|
*/
|
|
1104
|
-
insert(tableName: string, data: RecordData): Promise<BolticSuccessResponse<RecordWithId> | BolticErrorResponse>;
|
|
1313
|
+
insert(tableName: string, data: RecordData, dbId?: string): Promise<BolticSuccessResponse<RecordWithId> | BolticErrorResponse>;
|
|
1105
1314
|
/**
|
|
1106
1315
|
* Insert multiple records in bulk
|
|
1107
1316
|
*/
|
|
1108
|
-
insertMany(tableName: string, records: RecordData[], options?: RecordBulkInsertOptions): Promise<RecordBulkInsertResponse | BolticErrorResponse>;
|
|
1317
|
+
insertMany(tableName: string, records: RecordData[], options?: RecordBulkInsertOptions, dbId?: string): Promise<RecordBulkInsertResponse | BolticErrorResponse>;
|
|
1109
1318
|
/**
|
|
1110
1319
|
* Get a single record by ID
|
|
1111
1320
|
*/
|
|
1112
|
-
get(tableName: string, recordId: string): Promise<BolticSuccessResponse<RecordWithId> | BolticErrorResponse>;
|
|
1321
|
+
get(tableName: string, recordId: string, dbId?: string): Promise<BolticSuccessResponse<RecordWithId> | BolticErrorResponse>;
|
|
1113
1322
|
/**
|
|
1114
1323
|
* List records with filtering and pagination
|
|
1115
1324
|
*/
|
|
1116
|
-
list(tableName: string, options?: RecordQueryOptions): Promise<BolticListResponse<RecordWithId> | BolticErrorResponse>;
|
|
1325
|
+
list(tableName: string, options?: RecordQueryOptions, dbId?: string): Promise<BolticListResponse<RecordWithId> | BolticErrorResponse>;
|
|
1117
1326
|
/**
|
|
1118
1327
|
* Update records by filters
|
|
1119
1328
|
*/
|
|
1120
|
-
update(tableName: string, options: RecordUpdateOptions): Promise<BolticListResponse<RecordWithId> | BolticErrorResponse>;
|
|
1329
|
+
update(tableName: string, options: RecordUpdateOptions, dbId?: string): Promise<BolticListResponse<RecordWithId> | BolticErrorResponse>;
|
|
1121
1330
|
/**
|
|
1122
1331
|
* Update a single record by ID
|
|
1123
1332
|
*/
|
|
1124
|
-
updateById(tableName: string, recordId: string, data: RecordData): Promise<BolticSuccessResponse<RecordWithId> | BolticErrorResponse>;
|
|
1333
|
+
updateById(tableName: string, recordId: string, data: RecordData, dbId?: string): Promise<BolticSuccessResponse<RecordWithId> | BolticErrorResponse>;
|
|
1125
1334
|
/**
|
|
1126
1335
|
* Unified delete method that supports both record IDs and filters
|
|
1127
1336
|
*/
|
|
1128
|
-
delete(tableName: string, options: RecordDeleteOptions): Promise<BolticSuccessResponse<{
|
|
1337
|
+
delete(tableName: string, options: RecordDeleteOptions, dbId?: string): Promise<BolticSuccessResponse<{
|
|
1129
1338
|
message: string;
|
|
1130
1339
|
}> | BolticErrorResponse>;
|
|
1131
1340
|
/**
|
|
1132
1341
|
* Delete a single record by ID
|
|
1133
1342
|
*/
|
|
1134
|
-
deleteById(tableName: string, recordId: string): Promise<BolticSuccessResponse<{
|
|
1343
|
+
deleteById(tableName: string, recordId: string, dbId?: string): Promise<BolticSuccessResponse<{
|
|
1135
1344
|
message: string;
|
|
1136
1345
|
}> | BolticErrorResponse>;
|
|
1137
1346
|
/**
|
|
@@ -1241,6 +1450,14 @@ export declare class SchemaHelpers {
|
|
|
1241
1450
|
}>): FieldDefinition[];
|
|
1242
1451
|
}
|
|
1243
1452
|
|
|
1453
|
+
/**
|
|
1454
|
+
* Sort parameters
|
|
1455
|
+
*/
|
|
1456
|
+
export declare interface SortParams {
|
|
1457
|
+
field: string;
|
|
1458
|
+
direction: 'asc' | 'desc';
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1244
1461
|
export declare class SqlResource {
|
|
1245
1462
|
private sqlApiClient;
|
|
1246
1463
|
constructor(client: BaseClient);
|
|
@@ -1253,7 +1470,7 @@ export declare class SqlResource {
|
|
|
1253
1470
|
* @returns AsyncIterable<string> for streaming SQL generation
|
|
1254
1471
|
*
|
|
1255
1472
|
*/
|
|
1256
|
-
textToSQL(prompt: string, options?: TextToSQLOptions): Promise<AsyncIterable<string>>;
|
|
1473
|
+
textToSQL(prompt: string, options?: TextToSQLOptions, dbId?: string): Promise<AsyncIterable<string>>;
|
|
1257
1474
|
/**
|
|
1258
1475
|
* Execute SQL query with built-in safety measures and performance optimization
|
|
1259
1476
|
*
|
|
@@ -1261,7 +1478,7 @@ export declare class SqlResource {
|
|
|
1261
1478
|
* @returns Promise<ExecuteSQLApiResponse> with raw API response following Boltic API Response Structure
|
|
1262
1479
|
*
|
|
1263
1480
|
*/
|
|
1264
|
-
executeSQL(query: string): Promise<ExecuteSQLApiResponse | BolticErrorResponse>;
|
|
1481
|
+
executeSQL(query: string, dbId?: string): Promise<ExecuteSQLApiResponse | BolticErrorResponse>;
|
|
1265
1482
|
}
|
|
1266
1483
|
|
|
1267
1484
|
export declare interface SuccessResponse<T> {
|
|
@@ -1445,6 +1662,7 @@ declare interface TableBuilderOptions {
|
|
|
1445
1662
|
declare interface TableCreateOptions {
|
|
1446
1663
|
is_ai_generated_schema?: boolean;
|
|
1447
1664
|
is_template?: boolean;
|
|
1665
|
+
db_id?: string;
|
|
1448
1666
|
}
|
|
1449
1667
|
|
|
1450
1668
|
export declare interface TableCreateRequest {
|
|
@@ -1472,6 +1690,7 @@ declare interface TableListOptions extends TableQueryOptions {
|
|
|
1472
1690
|
page?: number;
|
|
1473
1691
|
pageSize?: number;
|
|
1474
1692
|
isShared?: boolean;
|
|
1693
|
+
db_id?: string;
|
|
1475
1694
|
}
|
|
1476
1695
|
|
|
1477
1696
|
export declare interface TableListResponse {
|
|
@@ -1545,6 +1764,7 @@ declare class TablesApiClient {
|
|
|
1545
1764
|
*/
|
|
1546
1765
|
getTable(tableId: string, options?: {
|
|
1547
1766
|
fields?: Array<keyof TableRecord>;
|
|
1767
|
+
db_id?: string;
|
|
1548
1768
|
}): Promise<BolticSuccessResponse_2<TableRecord> | BolticErrorResponse_2>;
|
|
1549
1769
|
/**
|
|
1550
1770
|
* Update an existing table
|
|
@@ -1554,11 +1774,14 @@ declare class TablesApiClient {
|
|
|
1554
1774
|
description?: string;
|
|
1555
1775
|
is_shared?: boolean;
|
|
1556
1776
|
fields?: Array<keyof TableRecord>;
|
|
1777
|
+
db_id?: string;
|
|
1557
1778
|
}): Promise<BolticSuccessResponse_2<TableRecord> | BolticErrorResponse_2>;
|
|
1558
1779
|
/**
|
|
1559
1780
|
* Delete a table
|
|
1560
1781
|
*/
|
|
1561
|
-
deleteTable(tableId: string
|
|
1782
|
+
deleteTable(tableId: string, options?: {
|
|
1783
|
+
db_id?: string;
|
|
1784
|
+
}): Promise<BolticSuccessResponse_2<{
|
|
1562
1785
|
message: string;
|
|
1563
1786
|
}> | BolticErrorResponse_2>;
|
|
1564
1787
|
private buildHeaders;
|
package/dist/databases/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./test-client-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./test-client-BuQuW6Y-.js");class i{constructor(e){this.queryOptions={},this.updateData={},this.tableName=e.tableName,this.columnResource=e.columnResource}where(e){return this.queryOptions.where={...this.queryOptions.where,...e},this}orderBy(e,i="asc"){return this.queryOptions.sort||(this.queryOptions.sort=[]),this.queryOptions.sort.push({field:e,order:i}),this}limit(e){return this.queryOptions.limit=e,this}offset(e){return this.queryOptions.offset=e,this}select(e){return this.queryOptions.fields=e,this}set(e){return this.updateData={...this.updateData,...e},this}async findAll(){return this.columnResource.findAll(this.tableName,this.queryOptions)}async get(){var e;return(null==(e=this.queryOptions.where)?void 0:e.name)?this.columnResource.get(this.tableName,this.queryOptions.where.name):{error:{code:"MISSING_COLUMN_NAME",message:"Column name is required for get operation"}}}async update(){var e;return(null==(e=this.queryOptions.where)?void 0:e.name)?this.columnResource.update(this.tableName,this.queryOptions.where.name,this.updateData):{error:{code:"MISSING_COLUMN_NAME",message:"Column name is required for update operation"}}}async delete(){var e;return(null==(e=this.queryOptions.where)?void 0:e.name)?this.columnResource.delete(this.tableName,this.queryOptions.where.name):{error:{code:"MISSING_COLUMN_NAME",message:"Column name is required for delete operation"}}}getQueryOptions(){return{...this.queryOptions}}getUpdateData(){return{...this.updateData}}}exports.ApiError=e.ApiError,exports.BolticClient=e.BolticClient,exports.ENV_CONFIGS=e.ENV_CONFIGS,exports.FILTER_OPERATORS=e.FILTER_OPERATORS,exports.FilterBuilder=e.FilterBuilder,exports.REGION_CONFIGS=e.REGION_CONFIGS,exports.SqlResource=e.SqlResource,exports.ValidationError=e.ValidationError,exports.buildApiFilters=e.buildApiFilters,exports.createErrorResponse=e.createErrorResponse,exports.createErrorWithContext=e.createErrorWithContext,exports.createFilter=e.createFilter,exports.createMockResponse=e.createMockResponse,exports.createRecordBuilder=e.createRecordBuilder,exports.createTableBuilder=e.createTableBuilder,exports.createTestClient=e.createTestClient,exports.formatError=e.formatError,exports.getHttpStatusCode=e.getHttpStatusCode,exports.isErrorResponse=e.isErrorResponse,exports.isListResponse=e.isListResponse,exports.isNetworkError=e.isNetworkError,exports.mapFiltersToWhere=e.mapFiltersToWhere,exports.mapWhereToFilters=e.mapWhereToFilters,exports.normalizeFilters=e.normalizeFilters,exports.ColumnHelpers=class{static fieldToUpdateRequest(e){return{name:e.name,type:e.type,description:e.description,is_nullable:e.is_nullable,is_unique:e.is_unique,is_indexed:e.is_indexed,is_visible:e.is_visible,is_primary_key:e.is_primary_key,is_readonly:e.is_readonly,field_order:e.field_order,default_value:e.default_value,alignment:e.alignment,decimals:e.decimals,currency_format:e.currency_format,selectable_items:e.selectable_items,multiple_selections:e.multiple_selections,phone_format:e.phone_format,date_format:e.date_format,time_format:e.time_format,timezone:e.timezone,vector_dimension:e.vector_dimension}}static applyDefaultValues(e){if(!e.name||!e.type)throw new Error("Column name and type are required");return{name:e.name,type:e.type,is_nullable:!0,is_unique:!1,is_indexed:!1,is_primary_key:!1,is_visible:!0,is_readonly:!1,field_order:1,alignment:"left",multiple_selections:!1,...e}}static createColumnDefinition(e,i,r={}){return this.applyDefaultValues({name:e,type:i,...r})}static getColumnTypeDisplayName(e){return{text:"Text","long-text":"Long Text",number:"Number",currency:"Currency",checkbox:"Checkbox",dropdown:"Dropdown",email:"Email","phone-number":"Phone Number",link:"Link",json:"JSON","date-time":"Date & Time",vector:"Vector",halfvec:"Half Vector",sparsevec:"Sparse Vector"}[e]||e}},exports.SchemaHelpers=class{static textField(e,i={}){return{name:e,type:"text",is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:1,...i}}static numberField(e,i={}){return{name:e,type:"number",is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:1,decimals:"0.00",...i}}static currencyField(e,i="USD",r={}){return{name:e,type:"currency",is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:1,decimals:"0.00",currency_format:i,...r}}static dropdownField(e,i,r={}){return{name:e,type:"dropdown",is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:1,selection_source:"provide-static-list",selectable_items:i,multiple_selections:!1,...r}}static vectorField(e,i,r={}){return{name:e,type:"vector",is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:1,vector_dimension:i,...r}}static jsonField(e,i={}){return{name:e,type:"json",is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:1,...i}}static dateTimeField(e,i={}){return{name:e,type:"date-time",is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:1,date_format:"YYYY-MM-DD",time_format:"HH:mm:ss",...i}}static emailField(e,i={}){return{name:e,type:"email",is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:1,...i}}static longTextField(e,i={}){return{name:e,type:"long-text",is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:1,...i}}static linkField(e,i={}){return{name:e,type:"link",is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:1,...i}}static phoneNumberField(e,i="international",r={}){return{name:e,type:"phone-number",is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:1,phone_format:i,...r}}static checkboxField(e,i={}){return{name:e,type:"checkbox",is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:1,default_value:!1,...i}}static halfVectorField(e,i,r={}){return{name:e,type:"halfvec",is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:1,vector_dimension:i,...r}}static sparseVectorField(e,i,r={}){return{name:e,type:"sparsevec",is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:1,vector_dimension:i,...r}}static createBasicSchema(e){return e.map((e,i)=>({name:e.name,type:e.type,is_nullable:!0,is_primary_key:!1,is_unique:!1,is_visible:!0,is_readonly:!1,is_indexed:!1,field_order:i+1}))}},exports.VERSION="1.0.0",exports.createClient=function(i,r={}){return new e.BolticClient(i,r)},exports.createColumnBuilder=function(e){return new i(e)};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|