2.6.1 • Published 3 months ago

@tunnelhub/sdk v2.6.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

TunnelHub SDK

TunnelHub SDK is a robust TypeScript library for implementing automated integrations with logging and tracing capabilities on the TunnelHub platform.

Overview

The SDK provides a foundation for building reliable data integrations with features including:

  • Delta detection and synchronization
  • Batch processing capabilities
  • Comprehensive logging and monitoring
  • Error handling and retry mechanisms
  • AWS infrastructure integration

Installation

npm install @tunnelhub/sdk

Core Concepts

Integration Flows

The SDK provides three main types of integration flows:

  1. Delta Integration Flow (DeltaIntegrationFlow)

    • Tracks changes between source and target systems
    • Handles insert, update, and delete operations
    • Maintains state between executions
    • Best for synchronization scenarios
  2. Batch Delta Integration Flow (BatchDeltaIntegrationFlow)

    • Extends Delta Integration Flow
    • Processes items in configurable batch sizes
    • Optimized for large datasets
    • Supports bulk operations
  3. No Delta Integration Flow (NoDeltaIntegrationFlow)

    • Simple one-way data transfer
    • No state tracking between executions
    • Available in single and batch variants
    • Ideal for one-time or streaming data transfers

Key Components

Automation Logs

The SDK automatically handles logging through the AutomationLog class, capturing:

  • Operation type (INSERT, UPDATE, DELETE, NODELTA, TRANSFER)
  • Status (SUCCESS, FAIL, NEUTRAL)
  • Timestamps
  • Detailed error messages
  • Operation payloads

Delta Tracking

AutomationDelta manages state between executions:

  • Stores previous execution state
  • Enables change detection
  • Persists in both DynamoDB and S3
  • Handles large datasets efficiently

Parameters & Configuration

  • Environment-specific configurations
  • Custom parameter management
  • Secure credential storage
  • System connection details

Usage Examples

Creating a Delta Integration

class MyDeltaIntegration extends DeltaIntegrationFlow<MyDataType> {
    protected async loadSourceSystemData(): Promise<MyDataType[]> {
        // Implement source system data loading
    }

    protected async loadTargetSystemData(): Promise<MyDataType[]> {
        // Implement target system data loading
    }

    protected async insertAction(item: MyDataType): Promise<IntegrationMessageReturn> {
        // Implement insert logic
    }

    protected async updateAction(oldItem: MyDataType, newItem: MyDataType): Promise<IntegrationMessageReturn> {
        // Implement update logic
    }

    protected async deleteAction(item: MyDataType): Promise<IntegrationMessageReturn> {
        // Implement delete logic
    }

    protected defineMetadata(): Array<Metadata> {
        return [
            {
                fieldName: 'id',
                fieldLabel: 'ID',
                fieldType: 'TEXT'
            }
            // Add more metadata fields
        ];
    }
}

Creating a Batch Integration

class MyBatchIntegration extends BatchDeltaIntegrationFlow<MyDataType> {
    constructor(event: ProcessorPayload, context?: LambdaContext) {
        super(event, ['id'], ['name', 'value'], context);
        this.packageSize = 100; // Set batch size
    }

    protected async batchInsertAction(items: MyDataType[]): Promise<IntegrationMessageReturnBatch[]> {
        // Implement batch insert logic
    }

    protected async batchUpdateAction(oldItems: MyDataType[], newItems: MyDataType[]): Promise<IntegrationMessageReturnBatch[]> {
        // Implement batch update logic
    }

    protected async batchDeleteAction(items: MyDataType[]): Promise<IntegrationMessageReturnBatch[]> {
        // Implement batch delete logic
    }
}

Additional Features

Data Store

  • Conversion table management
  • Sequence generation
  • System configuration storage

API Integration

  • Built-in middleware for API Gateway
  • Request/response logging
  • Error handling

AWS Integration

  • DynamoDB integration
  • S3 storage
  • Lambda context handling
  • ECS task tracking

Best Practices

  1. Error Handling

    • Implement proper try-catch blocks
    • Use appropriate error statuses
    • Provide meaningful error messages
  2. Performance

    • Use batch operations for large datasets
    • Implement proper indexing in database queries
    • Monitor memory usage
  3. Logging

    • Include relevant context in logs
    • Use appropriate log levels
    • Monitor execution statistics
  4. Delta Management

    • Choose appropriate key fields
    • Implement proper change detection
    • Handle data consistency

Environment Variables

The following environment variables are required only when using the API integration features:

  • TH_TENANT_ID: Tenant identifier
  • TH_ENVIRONMENT_ID: Environment identifier
  • TH_EXPIRATION_PERIOD: Log retention period in days

Contributing

Please read our Contributing Guidelines for details on submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For detailed documentation, visit https://docs.tunnelhub.io

For support queries, contact support@tunnelhub.io

2.6.1

3 months ago

2.6.0

3 months ago

2.5.0

4 months ago

2.2.9

4 months ago

2.2.8

4 months ago

2.2.6

5 months ago

2.2.1

5 months ago

2.2.3

5 months ago

2.2.2

5 months ago

2.2.5

5 months ago

2.2.4

5 months ago

2.0.3

5 months ago

2.0.2

5 months ago

2.0.5

5 months ago

2.0.4

5 months ago

2.0.7

5 months ago

2.0.6

5 months ago

2.0.9

5 months ago

2.0.8

5 months ago

2.0.1

5 months ago

2.0.0

5 months ago

2.2.0

5 months ago

2.1.2

5 months ago

2.1.1

5 months ago

2.0.11

5 months ago

2.0.12

5 months ago

2.0.10

5 months ago

2.1.0

5 months ago

2.0.0-beta.51

5 months ago

2.0.0-beta.50

5 months ago

2.0.0-beta.53

5 months ago

2.0.0-beta.52

5 months ago

2.0.0-beta.40

5 months ago

2.0.0-beta.44

5 months ago

2.0.0-beta.43

5 months ago

2.0.0-beta.42

5 months ago

2.0.0-beta.48

5 months ago

2.0.0-beta.47

5 months ago

2.0.0-beta.46

5 months ago

2.0.0-beta.45

5 months ago

2.0.0-beta.49

5 months ago

2.0.0-beta.33

5 months ago

2.0.0-beta.32

5 months ago

2.0.0-beta.37

5 months ago

2.0.0-beta.36

5 months ago

2.0.0-beta.35

5 months ago

2.0.0-beta.34

5 months ago

2.0.0-beta.39

5 months ago

2.0.0-beta.38

5 months ago

2.0.0-beta.22

6 months ago

2.0.0-beta.21

6 months ago

2.0.0-beta.20

6 months ago

2.0.0-beta.26

6 months ago

2.0.0-beta.25

6 months ago

2.0.0-beta.24

6 months ago

2.0.0-beta.23

6 months ago

2.0.0-beta.29

6 months ago

2.0.0-beta.28

6 months ago

2.0.0-beta.27

6 months ago

2.0.0-beta.11

6 months ago

2.0.0-beta.10

6 months ago

2.0.0-beta.15

6 months ago

2.0.0-beta.14

6 months ago

2.0.0-beta.13

6 months ago

2.0.0-beta.12

6 months ago

2.0.0-beta.19

6 months ago

2.0.0-beta.18

6 months ago

2.0.0-beta.17

6 months ago

2.0.0-beta.16

6 months ago

2.0.0-beta.9

6 months ago

2.0.0-beta.8

6 months ago

2.0.0-beta.7

6 months ago

2.0.0-beta.2

6 months ago

2.0.0-beta.1

6 months ago

2.0.0-beta.6

6 months ago

2.0.0-beta.5

6 months ago

2.0.0-beta.4

6 months ago

2.0.0-beta.3

6 months ago

2.0.0-beta.31

6 months ago

2.0.0-beta.30

6 months ago

1.4.3

9 months ago

1.4.2

9 months ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.5

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.1-2

1 year ago

1.3.1-1

1 year ago

1.3.1-0

1 year ago

1.2.0

2 years ago

1.1.1

2 years ago

1.0.121

2 years ago

1.1.0

2 years ago

1.0.120

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.1.3

2 years ago

1.3.0

2 years ago

1.1.2

2 years ago

1.3.0-0

2 years ago

1.3.0-4

2 years ago

1.3.0-3

2 years ago

1.3.0-2

2 years ago

1.3.0-1

2 years ago

1.3.0-8

2 years ago

1.0.118

2 years ago

1.3.0-7

2 years ago

1.0.117

2 years ago

1.3.0-6

2 years ago

1.3.0-5

2 years ago

1.0.119

2 years ago

1.3.0-9

2 years ago

1.3.0-11

2 years ago

1.3.0-10

2 years ago

1.3.0-13

2 years ago

1.3.0-12

2 years ago

1.2.9

2 years ago

1.3.0-15

2 years ago

1.3.0-14

2 years ago

1.2.10

2 years ago

1.2.11

2 years ago

1.0.116

2 years ago

1.0.115

2 years ago