@boltic/sdk 0.1.2 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Boltic SDK
2
2
 
3
- Boltic SDK is an open-source TypeScript library, developed by Fynd, designed to empower developers worldwide with integration to the Boltic platform. Effortlessly manage databases, tables, columns, records, and run SQL queries to build robust, modern applications with ease and confidence.
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
- // Use the client for database operations
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
@@ -486,33 +492,6 @@ const bulkNoValidationResult = await client.records.insertMany(
486
492
 
487
493
  - Unlike single insert(), insertMany() requires complete records. All required fields must be provided in insertMany() call.
488
494
 
489
- ### Bulk Insert Operations
490
-
491
- The SDK provides an efficient `insertMany()` method for inserting multiple records in a single API call:
492
-
493
- ```typescript
494
- // Bulk insert with validation (default behavior)
495
- const records = [
496
- { name: 'User 1', email: 'user1@example.com', age: 25 },
497
- { name: 'User 2', email: 'user2@example.com', age: 30 },
498
- { name: 'User 3', email: 'user3@example.com', age: 35 },
499
- ];
500
-
501
- const result = await client.records.insertMany('users', records);
502
-
503
- if (result.error) {
504
- console.error('Bulk insertion failed:', result.error);
505
- } else {
506
- console.log(`Successfully inserted ${result.data.insert_count} records`);
507
- console.log('Response:', result.data);
508
- }
509
-
510
- // Bulk insert without validation (faster, less safe)
511
- const resultNoValidation = await client.records.insertMany('users', records, {
512
- validation: false,
513
- });
514
- ```
515
-
516
495
  ### Querying Records
517
496
 
518
497
  ```typescript
@@ -660,6 +639,33 @@ const deleteWithFilters = await client.records.delete('users', {
660
639
  });
661
640
  ```
662
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
+
663
669
  ## SQL Operations
664
670
 
665
671
  The Boltic SDK provides powerful SQL capabilities including natural language to SQL conversion and direct SQL query execution.
@@ -734,55 +740,27 @@ if (result.error) {
734
740
  }
735
741
  }
736
742
 
737
- // When joining or comparing id fields with other columns, cast to text using ::text
738
- const joinQuery = await client.sql.executeSQL(`
739
- SELECT u.name, p.title
740
- FROM "users" u
741
- JOIN "posts" p ON u.id::text = p.user_id
742
- `);
743
743
  ```
744
744
 
745
- **Note:** When joining or comparing an `id` field with a different-typed column, you need to cast using `::text` (e.g., `u.id::text = p.user_id`) since `id` fields are UUID type.
746
-
747
- ### Working with UUID ID Fields in SQL
745
+ ### UUID Casting in Joins
748
746
 
749
- **Important:** The `id` field in Boltic tables contains UUID values. When joining tables or comparing `id` fields with other column types, you must cast the `id` field to text using `::text`:
747
+ The `id` field uses PostgreSQL's UUID type. When joining or comparing `id` with text columns, cast with `::text`:
750
748
 
751
749
  ```typescript
752
- const query = `
750
+ const result = await client.sql.executeSQL(`
753
751
  SELECT u.name, p.title
754
752
  FROM "users" u
755
753
  JOIN "posts" p ON u.id::text = p.user_id
756
- `;
757
-
758
- const result = await client.sql.executeSQL(query);
759
-
760
- // More examples of UUID casting:
761
-
762
- // Filtering by UUID id
763
- const filterByIdQuery = `
764
- SELECT * FROM "users"
765
- WHERE id::text = 'some-uuid-string'
766
- `;
754
+ `);
767
755
 
768
- // Joining multiple tables with UUID references
769
- const complexJoinQuery = `
756
+ // Multi-table joins with UUID casting
757
+ const complex = await client.sql.executeSQL(`
770
758
  SELECT u.name, p.title, c.content
771
759
  FROM "users" u
772
760
  JOIN "posts" p ON u.id::text = p.user_id
773
761
  JOIN "comments" c ON p.id::text = c.post_id
774
- WHERE u.id::text IN ('uuid1', 'uuid2', 'uuid3')
775
- `;
776
-
777
- // Using UUID id in subqueries
778
- const subqueryExample = `
779
- SELECT * FROM "users" u
780
- WHERE u.id::text IN (
781
- SELECT DISTINCT user_id
782
- FROM "posts"
783
- WHERE created_at > '2024-01-01'
784
- )
785
- `;
762
+ WHERE u.id::text IN ('uuid1', 'uuid2')
763
+ `);
786
764
  ```
787
765
 
788
766
  **Why UUID Casting is Required:**
@@ -812,6 +790,135 @@ try {
812
790
  }
813
791
  ```
814
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
+
815
922
  ## Advanced Features
816
923
 
817
924
  ### Vector Columns for AI/ML
@@ -928,83 +1035,12 @@ Each region has its own API endpoints and environment configurations.
928
1035
 
929
1036
  The SDK supports both ES modules and CommonJS:
930
1037
 
931
- ### ES Modules (Recommended)
932
-
933
1038
  ```typescript
1039
+ // ES Modules / TypeScript (recommended)
934
1040
  import { createClient } from '@boltic/sdk';
935
- ```
936
-
937
- ### CommonJS
938
-
939
- ```javascript
940
- const { createClient } = require('@boltic/sdk');
941
- ```
942
-
943
- ### TypeScript
944
-
945
- ```typescript
946
- import { createClient, ClientOptions, BolticClient } from '@boltic/sdk';
947
-
948
- const options: ClientOptions = {
949
- region: 'asia-south1',
950
- debug: true,
951
- timeout: 30000,
952
- maxRetries: 3,
953
- };
954
1041
 
955
- const client: BolticClient = createClient('your-api-key', options);
956
- ```
957
-
958
- ## File Format Examples
959
-
960
- ### JavaScript (.js)
961
-
962
- ```javascript
1042
+ // CommonJS
963
1043
  const { createClient } = require('@boltic/sdk');
964
-
965
- const client = createClient('your-api-key');
966
-
967
- async function main() {
968
- const tables = await client.tables.findAll();
969
- console.log('Tables:', tables);
970
- }
971
-
972
- main().catch(console.error);
973
- ```
974
-
975
- ### TypeScript (.ts)
976
-
977
- ```typescript
978
- import { createClient, ClientOptions } from '@boltic/sdk';
979
-
980
- const options: ClientOptions = {
981
- region: 'asia-south1',
982
- debug: true,
983
- };
984
-
985
- const client = createClient('your-api-key', options);
986
-
987
- async function main(): Promise<void> {
988
- const tables = await client.tables.findAll();
989
- console.log('Tables:', tables);
990
- }
991
-
992
- main().catch(console.error);
993
- ```
994
-
995
- ### ES Modules (.mjs)
996
-
997
- ```javascript
998
- import { createClient } from '@boltic/sdk';
999
-
1000
- const client = createClient('your-api-key');
1001
-
1002
- async function main() {
1003
- const tables = await client.tables.findAll();
1004
- console.log('Tables:', tables);
1005
- }
1006
-
1007
- main().catch(console.error);
1008
1044
  ```
1009
1045
 
1010
1046
  ## API Reference
@@ -1060,20 +1096,29 @@ main().catch(console.error);
1060
1096
  - **`client.sql.textToSQL(prompt, options?)`**: Convert natural language to SQL query (streaming)
1061
1097
  - **`client.sql.executeSQL(query)`**: Execute SQL query with safety measures
1062
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
+
1063
1108
  ## Examples and Demos
1064
1109
 
1065
1110
  Check out the comprehensive demo files for complete usage examples:
1066
1111
 
1067
- - **[Comprehensive Database Operations Demo](./src/services/databases/examples/basic/comprehensive-database-operations-demo.ts)** - Complete SDK functionality demo
1068
- - **[SQL Operations Demo](./src/services/databases/examples/basic/comprehensive-sql-operations-demo.ts)** - SQL operations and text-to-SQL demo
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
1069
1115
 
1070
- These demos cover:
1116
+ Run any example:
1071
1117
 
1072
- - All column types and their properties
1073
- - Advanced filtering and querying
1074
- - Error handling patterns
1075
- - Vector operations
1076
- - 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
+ ```
1077
1122
 
1078
1123
  ## Development
1079
1124