@boltic/sdk 0.1.1 → 0.1.3
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 +192 -154
- package/dist/databases/index.d.ts +214 -93
- package/dist/databases/index.js +1 -1
- package/dist/databases/index.js.map +1 -1
- package/dist/databases/index.mjs +1 -1
- package/dist/databases/index.mjs.map +1 -1
- package/dist/databases/test-client-BEAX5vfC.mjs +2 -0
- package/dist/databases/test-client-BEAX5vfC.mjs.map +1 -0
- package/dist/databases/test-client-BgkvBtst.js +2 -0
- package/dist/databases/test-client-BgkvBtst.js.map +1 -0
- package/dist/databases/testing.d.ts +204 -94
- package/dist/databases/testing.js +1 -1
- package/dist/databases/testing.mjs +1 -1
- package/dist/sdk.js +915 -711
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.mjs +916 -712
- package/dist/sdk.mjs.map +1 -1
- package/dist/types/index.d.ts +464 -83
- package/package.json +2 -1
- package/dist/databases/test-client-Bo_BCApL.js +0 -2
- package/dist/databases/test-client-Bo_BCApL.js.map +0 -1
- package/dist/databases/test-client-C9T839dW.mjs +0 -2
- package/dist/databases/test-client-C9T839dW.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Boltic SDK
|
|
2
2
|
|
|
3
|
-
Boltic SDK is an open-source TypeScript library, developed by Fynd,
|
|
3
|
+
Boltic SDK is an open-source TypeScript library, developed by Fynd, for integrating with the Boltic platform. Manage databases, tables, records, run SQL queries, and execute workflow integrations to build robust, modern applications.
|
|
4
4
|
|
|
5
5
|
## Documentation
|
|
6
6
|
|
|
@@ -8,6 +8,7 @@ Boltic SDK is an open-source TypeScript library, developed by Fynd, designed to
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
+
|
|
11
12
|
- 🔧 **Full TypeScript Support**: Comprehensive type definitions and IntelliSense
|
|
12
13
|
- 🚀 **Modern Architecture**: ES modules and CommonJS support
|
|
13
14
|
- 🔐 **Built-in Authentication**: Integrated API key management
|
|
@@ -17,6 +18,8 @@ Boltic SDK is an open-source TypeScript library, developed by Fynd, designed to
|
|
|
17
18
|
- 🔍 **Advanced Filtering**: Comprehensive query operators
|
|
18
19
|
- 🛠️ **Helper Classes**: Schema and column creation utilities
|
|
19
20
|
- 🎯 **Vector Support**: AI/ML vector fields with multiple precisions
|
|
21
|
+
- **Workflow Operations** — Execute integration activities, poll for results, manage credentials
|
|
22
|
+
- **Multi-Region Support** — Asia Pacific and US Central regions
|
|
20
23
|
|
|
21
24
|
## Prerequisites
|
|
22
25
|
|
|
@@ -40,10 +43,13 @@ const client = createClient('your-api-key', {
|
|
|
40
43
|
debug: false,
|
|
41
44
|
});
|
|
42
45
|
|
|
43
|
-
//
|
|
46
|
+
// Database operations
|
|
44
47
|
const tables = client.tables;
|
|
45
48
|
const columns = client.columns;
|
|
46
49
|
const records = client.records;
|
|
50
|
+
|
|
51
|
+
// Workflow operations
|
|
52
|
+
const workflow = client.workflow;
|
|
47
53
|
```
|
|
48
54
|
|
|
49
55
|
## Authentication
|
|
@@ -309,17 +315,11 @@ const tableByName = await client.tables.findByName('users');
|
|
|
309
315
|
// Update table properties
|
|
310
316
|
const updateResult = await client.tables.update('users', {
|
|
311
317
|
name: 'updated_users',
|
|
312
|
-
|
|
318
|
+
description: 'Updated description',
|
|
313
319
|
});
|
|
314
320
|
|
|
315
321
|
// Rename table
|
|
316
322
|
const renameResult = await client.tables.rename('users', 'new_users');
|
|
317
|
-
|
|
318
|
-
// Set table access
|
|
319
|
-
const accessResult = await client.tables.setAccess({
|
|
320
|
-
table_name: 'new_users',
|
|
321
|
-
is_shared: true,
|
|
322
|
-
});
|
|
323
323
|
```
|
|
324
324
|
|
|
325
325
|
### Deleting Tables
|
|
@@ -492,33 +492,6 @@ const bulkNoValidationResult = await client.records.insertMany(
|
|
|
492
492
|
|
|
493
493
|
- Unlike single insert(), insertMany() requires complete records. All required fields must be provided in insertMany() call.
|
|
494
494
|
|
|
495
|
-
### Bulk Insert Operations
|
|
496
|
-
|
|
497
|
-
The SDK provides an efficient `insertMany()` method for inserting multiple records in a single API call:
|
|
498
|
-
|
|
499
|
-
```typescript
|
|
500
|
-
// Bulk insert with validation (default behavior)
|
|
501
|
-
const records = [
|
|
502
|
-
{ name: 'User 1', email: 'user1@example.com', age: 25 },
|
|
503
|
-
{ name: 'User 2', email: 'user2@example.com', age: 30 },
|
|
504
|
-
{ name: 'User 3', email: 'user3@example.com', age: 35 },
|
|
505
|
-
];
|
|
506
|
-
|
|
507
|
-
const result = await client.records.insertMany('users', records);
|
|
508
|
-
|
|
509
|
-
if (result.error) {
|
|
510
|
-
console.error('Bulk insertion failed:', result.error);
|
|
511
|
-
} else {
|
|
512
|
-
console.log(`Successfully inserted ${result.data.insert_count} records`);
|
|
513
|
-
console.log('Response:', result.data);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
// Bulk insert without validation (faster, less safe)
|
|
517
|
-
const resultNoValidation = await client.records.insertMany('users', records, {
|
|
518
|
-
validation: false,
|
|
519
|
-
});
|
|
520
|
-
```
|
|
521
|
-
|
|
522
495
|
### Querying Records
|
|
523
496
|
|
|
524
497
|
```typescript
|
|
@@ -666,6 +639,33 @@ const deleteWithFilters = await client.records.delete('users', {
|
|
|
666
639
|
});
|
|
667
640
|
```
|
|
668
641
|
|
|
642
|
+
### Bulk Insert Operations
|
|
643
|
+
|
|
644
|
+
The SDK provides an efficient `insertMany()` method for inserting multiple records in a single API call:
|
|
645
|
+
|
|
646
|
+
```typescript
|
|
647
|
+
// Bulk insert with validation (default behavior)
|
|
648
|
+
const records = [
|
|
649
|
+
{ name: 'User 1', email: 'user1@example.com', age: 25 },
|
|
650
|
+
{ name: 'User 2', email: 'user2@example.com', age: 30 },
|
|
651
|
+
{ name: 'User 3', email: 'user3@example.com', age: 35 },
|
|
652
|
+
];
|
|
653
|
+
|
|
654
|
+
const result = await client.records.insertMany('users', records);
|
|
655
|
+
|
|
656
|
+
if (result.error) {
|
|
657
|
+
console.error('Bulk insertion failed:', result.error);
|
|
658
|
+
} else {
|
|
659
|
+
console.log(`Successfully inserted ${result.data.insert_count} records`);
|
|
660
|
+
console.log('Response:', result.data);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// Bulk insert without validation (faster, less safe)
|
|
664
|
+
const resultNoValidation = await client.records.insertMany('users', records, {
|
|
665
|
+
validation: false,
|
|
666
|
+
});
|
|
667
|
+
```
|
|
668
|
+
|
|
669
669
|
## SQL Operations
|
|
670
670
|
|
|
671
671
|
The Boltic SDK provides powerful SQL capabilities including natural language to SQL conversion and direct SQL query execution.
|
|
@@ -740,55 +740,27 @@ if (result.error) {
|
|
|
740
740
|
}
|
|
741
741
|
}
|
|
742
742
|
|
|
743
|
-
// When joining or comparing id fields with other columns, cast to text using ::text
|
|
744
|
-
const joinQuery = await client.sql.executeSQL(`
|
|
745
|
-
SELECT u.name, p.title
|
|
746
|
-
FROM "users" u
|
|
747
|
-
JOIN "posts" p ON u.id::text = p.user_id
|
|
748
|
-
`);
|
|
749
743
|
```
|
|
750
744
|
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
### Working with UUID ID Fields in SQL
|
|
745
|
+
### UUID Casting in Joins
|
|
754
746
|
|
|
755
|
-
|
|
747
|
+
The `id` field uses PostgreSQL's UUID type. When joining or comparing `id` with text columns, cast with `::text`:
|
|
756
748
|
|
|
757
749
|
```typescript
|
|
758
|
-
const
|
|
750
|
+
const result = await client.sql.executeSQL(`
|
|
759
751
|
SELECT u.name, p.title
|
|
760
752
|
FROM "users" u
|
|
761
753
|
JOIN "posts" p ON u.id::text = p.user_id
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
const result = await client.sql.executeSQL(query);
|
|
765
|
-
|
|
766
|
-
// More examples of UUID casting:
|
|
767
|
-
|
|
768
|
-
// Filtering by UUID id
|
|
769
|
-
const filterByIdQuery = `
|
|
770
|
-
SELECT * FROM "users"
|
|
771
|
-
WHERE id::text = 'some-uuid-string'
|
|
772
|
-
`;
|
|
754
|
+
`);
|
|
773
755
|
|
|
774
|
-
//
|
|
775
|
-
const
|
|
756
|
+
// Multi-table joins with UUID casting
|
|
757
|
+
const complex = await client.sql.executeSQL(`
|
|
776
758
|
SELECT u.name, p.title, c.content
|
|
777
759
|
FROM "users" u
|
|
778
760
|
JOIN "posts" p ON u.id::text = p.user_id
|
|
779
761
|
JOIN "comments" c ON p.id::text = c.post_id
|
|
780
|
-
WHERE u.id::text IN ('uuid1', 'uuid2'
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
// Using UUID id in subqueries
|
|
784
|
-
const subqueryExample = `
|
|
785
|
-
SELECT * FROM "users" u
|
|
786
|
-
WHERE u.id::text IN (
|
|
787
|
-
SELECT DISTINCT user_id
|
|
788
|
-
FROM "posts"
|
|
789
|
-
WHERE created_at > '2024-01-01'
|
|
790
|
-
)
|
|
791
|
-
`;
|
|
762
|
+
WHERE u.id::text IN ('uuid1', 'uuid2')
|
|
763
|
+
`);
|
|
792
764
|
```
|
|
793
765
|
|
|
794
766
|
**Why UUID Casting is Required:**
|
|
@@ -818,6 +790,135 @@ try {
|
|
|
818
790
|
}
|
|
819
791
|
```
|
|
820
792
|
|
|
793
|
+
## Workflow Operations
|
|
794
|
+
|
|
795
|
+
The SDK provides workflow integration capabilities — execute activities against third-party integrations, poll for results, browse available integrations, and fetch form schemas.
|
|
796
|
+
|
|
797
|
+
### Executing an Integration Activity
|
|
798
|
+
|
|
799
|
+
Execute an activity and automatically poll until completion:
|
|
800
|
+
|
|
801
|
+
```typescript
|
|
802
|
+
const result = await client.workflow.executeIntegration({
|
|
803
|
+
data: {
|
|
804
|
+
type: 'apiActivity',
|
|
805
|
+
name: 'api1',
|
|
806
|
+
properties: {
|
|
807
|
+
method: 'get',
|
|
808
|
+
endpoint: 'https://dummyjson.com/products',
|
|
809
|
+
query_params: {},
|
|
810
|
+
headers: {},
|
|
811
|
+
body: null,
|
|
812
|
+
body_type: 'none',
|
|
813
|
+
api_timeout: 30000,
|
|
814
|
+
maximum_timeout: 60000,
|
|
815
|
+
integration_slug: 'blt-int.api',
|
|
816
|
+
},
|
|
817
|
+
},
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
if (result.error) {
|
|
821
|
+
console.error('Execution failed:', result.error);
|
|
822
|
+
} else {
|
|
823
|
+
console.log('Execution result:', result.data);
|
|
824
|
+
}
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
### Fire-and-Forget Execution
|
|
828
|
+
|
|
829
|
+
Return immediately after triggering the activity without waiting for completion:
|
|
830
|
+
|
|
831
|
+
```typescript
|
|
832
|
+
const result = await client.workflow.executeIntegration({
|
|
833
|
+
data: {
|
|
834
|
+
type: 'apiActivity',
|
|
835
|
+
name: 'api1',
|
|
836
|
+
properties: {
|
|
837
|
+
method: 'get',
|
|
838
|
+
endpoint: 'https://dummyjson.com/products',
|
|
839
|
+
integration_slug: 'blt-int.api',
|
|
840
|
+
},
|
|
841
|
+
},
|
|
842
|
+
executeOnly: true,
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
if (!result.error) {
|
|
846
|
+
const executionId = result.data.execution_id;
|
|
847
|
+
console.log('Execution started:', executionId);
|
|
848
|
+
}
|
|
849
|
+
```
|
|
850
|
+
|
|
851
|
+
### Getting Execution Result by ID
|
|
852
|
+
|
|
853
|
+
Retrieve the result of a previously triggered execution:
|
|
854
|
+
|
|
855
|
+
```typescript
|
|
856
|
+
const result = await client.workflow.getIntegrationExecuteById('execution-id-here');
|
|
857
|
+
|
|
858
|
+
if (!result.error) {
|
|
859
|
+
console.log('Execution data:', result.data);
|
|
860
|
+
}
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
### Listing Available Integrations
|
|
864
|
+
|
|
865
|
+
```typescript
|
|
866
|
+
const result = await client.workflow.getIntegrations();
|
|
867
|
+
|
|
868
|
+
if (!result.error) {
|
|
869
|
+
console.log('Integrations:', result.data);
|
|
870
|
+
}
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
### Getting Credentials for an Integration
|
|
874
|
+
|
|
875
|
+
```typescript
|
|
876
|
+
const result = await client.workflow.getCredentials({
|
|
877
|
+
entity: 'asana',
|
|
878
|
+
});
|
|
879
|
+
|
|
880
|
+
if (!result.error) {
|
|
881
|
+
console.log('Credentials:', result.data);
|
|
882
|
+
}
|
|
883
|
+
```
|
|
884
|
+
|
|
885
|
+
### Getting Integration Resource Schema
|
|
886
|
+
|
|
887
|
+
Fetch the available resources and operations for an integration:
|
|
888
|
+
|
|
889
|
+
```typescript
|
|
890
|
+
const result = await client.workflow.getIntegrationResource({
|
|
891
|
+
integration_slug: 'blt-int.asana',
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
if (!result.error) {
|
|
895
|
+
console.log('Resources & operations:', result.data);
|
|
896
|
+
}
|
|
897
|
+
```
|
|
898
|
+
|
|
899
|
+
### Getting Integration Form Schema
|
|
900
|
+
|
|
901
|
+
Fetch the input form fields for a specific integration resource and operation. Returns default values by default, or a JSON Schema when `asJsonSchema: true`:
|
|
902
|
+
|
|
903
|
+
```typescript
|
|
904
|
+
// Get default values for each field
|
|
905
|
+
const defaults = await client.workflow.getIntegrationForm({
|
|
906
|
+
integration_slug: 'blt-int.asana',
|
|
907
|
+
resource: 'project',
|
|
908
|
+
operation: 'create',
|
|
909
|
+
secret: 'credential-secret-here',
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
// Get JSON Schema describing the expected input shape
|
|
913
|
+
const schema = await client.workflow.getIntegrationForm({
|
|
914
|
+
integration_slug: 'blt-int.asana',
|
|
915
|
+
resource: 'project',
|
|
916
|
+
operation: 'create',
|
|
917
|
+
secret: 'credential-secret-here',
|
|
918
|
+
asJsonSchema: true,
|
|
919
|
+
});
|
|
920
|
+
```
|
|
921
|
+
|
|
821
922
|
## Advanced Features
|
|
822
923
|
|
|
823
924
|
### Vector Columns for AI/ML
|
|
@@ -934,85 +1035,14 @@ Each region has its own API endpoints and environment configurations.
|
|
|
934
1035
|
|
|
935
1036
|
The SDK supports both ES modules and CommonJS:
|
|
936
1037
|
|
|
937
|
-
### ES Modules (Recommended)
|
|
938
|
-
|
|
939
1038
|
```typescript
|
|
1039
|
+
// ES Modules / TypeScript (recommended)
|
|
940
1040
|
import { createClient } from '@boltic/sdk';
|
|
941
|
-
```
|
|
942
1041
|
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
```javascript
|
|
1042
|
+
// CommonJS
|
|
946
1043
|
const { createClient } = require('@boltic/sdk');
|
|
947
1044
|
```
|
|
948
1045
|
|
|
949
|
-
### TypeScript
|
|
950
|
-
|
|
951
|
-
```typescript
|
|
952
|
-
import { createClient, ClientOptions, BolticClient } from '@boltic/sdk';
|
|
953
|
-
|
|
954
|
-
const options: ClientOptions = {
|
|
955
|
-
region: 'asia-south1',
|
|
956
|
-
debug: true,
|
|
957
|
-
timeout: 30000,
|
|
958
|
-
maxRetries: 3,
|
|
959
|
-
};
|
|
960
|
-
|
|
961
|
-
const client: BolticClient = createClient('your-api-key', options);
|
|
962
|
-
```
|
|
963
|
-
|
|
964
|
-
## File Format Examples
|
|
965
|
-
|
|
966
|
-
### JavaScript (.js)
|
|
967
|
-
|
|
968
|
-
```javascript
|
|
969
|
-
const { createClient } = require('@boltic/sdk');
|
|
970
|
-
|
|
971
|
-
const client = createClient('your-api-key');
|
|
972
|
-
|
|
973
|
-
async function main() {
|
|
974
|
-
const tables = await client.tables.findAll();
|
|
975
|
-
console.log('Tables:', tables);
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
main().catch(console.error);
|
|
979
|
-
```
|
|
980
|
-
|
|
981
|
-
### TypeScript (.ts)
|
|
982
|
-
|
|
983
|
-
```typescript
|
|
984
|
-
import { createClient, ClientOptions } from '@boltic/sdk';
|
|
985
|
-
|
|
986
|
-
const options: ClientOptions = {
|
|
987
|
-
region: 'asia-south1',
|
|
988
|
-
debug: true,
|
|
989
|
-
};
|
|
990
|
-
|
|
991
|
-
const client = createClient('your-api-key', options);
|
|
992
|
-
|
|
993
|
-
async function main(): Promise<void> {
|
|
994
|
-
const tables = await client.tables.findAll();
|
|
995
|
-
console.log('Tables:', tables);
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
main().catch(console.error);
|
|
999
|
-
```
|
|
1000
|
-
|
|
1001
|
-
### ES Modules (.mjs)
|
|
1002
|
-
|
|
1003
|
-
```javascript
|
|
1004
|
-
import { createClient } from '@boltic/sdk';
|
|
1005
|
-
|
|
1006
|
-
const client = createClient('your-api-key');
|
|
1007
|
-
|
|
1008
|
-
async function main() {
|
|
1009
|
-
const tables = await client.tables.findAll();
|
|
1010
|
-
console.log('Tables:', tables);
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
main().catch(console.error);
|
|
1014
|
-
```
|
|
1015
|
-
|
|
1016
1046
|
## API Reference
|
|
1017
1047
|
|
|
1018
1048
|
### Core Client
|
|
@@ -1040,7 +1070,6 @@ main().catch(console.error);
|
|
|
1040
1070
|
- **`client.tables.findByName(name)`**: Get table by name
|
|
1041
1071
|
- **`client.tables.update(identifier, data)`**: Update table properties
|
|
1042
1072
|
- **`client.tables.rename(oldName, newName)`**: Rename a table
|
|
1043
|
-
- **`client.tables.setAccess(data)`**: Update table access settings
|
|
1044
1073
|
- **`client.tables.delete(name)`**: Delete a table by name
|
|
1045
1074
|
|
|
1046
1075
|
### Columns
|
|
@@ -1067,20 +1096,29 @@ main().catch(console.error);
|
|
|
1067
1096
|
- **`client.sql.textToSQL(prompt, options?)`**: Convert natural language to SQL query (streaming)
|
|
1068
1097
|
- **`client.sql.executeSQL(query)`**: Execute SQL query with safety measures
|
|
1069
1098
|
|
|
1099
|
+
### Workflow Operations
|
|
1100
|
+
|
|
1101
|
+
- **`client.workflow.executeIntegration(params)`**: Execute an integration activity. Polls until completion by default; set `executeOnly: true` to return immediately.
|
|
1102
|
+
- **`client.workflow.getIntegrationExecuteById(executionId)`**: Get the result of a workflow execution by run ID
|
|
1103
|
+
- **`client.workflow.getIntegrations(params?)`**: List available integrations with optional pagination
|
|
1104
|
+
- **`client.workflow.getCredentials(params)`**: Fetch credentials for an integration entity
|
|
1105
|
+
- **`client.workflow.getIntegrationResource(params)`**: Fetch the resource/operation schema for an integration
|
|
1106
|
+
- **`client.workflow.getIntegrationForm(params)`**: Fetch form field schema for a specific resource + operation. Returns default values or JSON Schema (`asJsonSchema: true`).
|
|
1107
|
+
|
|
1070
1108
|
## Examples and Demos
|
|
1071
1109
|
|
|
1072
1110
|
Check out the comprehensive demo files for complete usage examples:
|
|
1073
1111
|
|
|
1074
|
-
- **[
|
|
1075
|
-
- **[SQL Operations Demo](./src/services/databases/examples/basic/comprehensive-sql-operations-demo.ts)** -
|
|
1112
|
+
- **[Database Operations Demo](./src/services/databases/examples/basic/comprehensive-database-operations-demo.ts)** — Tables, columns, records, indexes, filters, bulk ops
|
|
1113
|
+
- **[SQL Operations Demo](./src/services/databases/examples/basic/comprehensive-sql-operations-demo.ts)** — Text-to-SQL conversion and SQL query execution
|
|
1114
|
+
- **[Workflow Integration Demo](./src/services/workflows/examples/workflow-test.ts)** — Execute activities, poll results, list integrations, fetch form schemas
|
|
1076
1115
|
|
|
1077
|
-
|
|
1116
|
+
Run any example:
|
|
1078
1117
|
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
- SQL operations and text-to-SQL conversion
|
|
1118
|
+
```bash
|
|
1119
|
+
npx tsx src/services/workflows/examples/workflow-test.ts all
|
|
1120
|
+
npx tsx src/services/databases/examples/basic/comprehensive-database-operations-demo.ts
|
|
1121
|
+
```
|
|
1084
1122
|
|
|
1085
1123
|
## Development
|
|
1086
1124
|
|