JSPM

sqlite-db-odata4

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q25999F
  • License MIT

Complete OData v4 implementation for SQLite with advanced features including batch operations, delta links, full-text search, aggregations, and framework integrations

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sqlite-db-odata4) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    ๐Ÿš€ Complete OData v4 Implementation for SQLite

    A comprehensive, production-ready OData v4 implementation for SQLite with advanced features including batch operations, delta links, full-text search, aggregations, and framework integrations.

    โœจ Features

    • ๐Ÿ”ง Core OData v4 Support - Complete query builder and executor
    • ๐Ÿ”— $expand Operations - JOIN operations with relationship support
    • ๐Ÿ” Full-Text Search - SQLite FTS5 integration with $search
    • ๐Ÿ“Š Aggregations - $apply with GROUP BY and aggregate functions
    • ๐Ÿงฎ Computed Properties - $compute with dynamic calculations
    • ๐Ÿ“ฆ Batch Operations - OData v4 batch request/response handling
    • ๐Ÿ“ˆ Delta Links - Change tracking with delta tokens
    • ๐ŸŒ Framework Integrations - Express.js and Astro support
    • โœ… TDD & ISP - Test-driven development with interface segregation
    • ๐Ÿ”’ Type Safety - Full TypeScript support with strict mode

    ๐Ÿ“ฆ Published Packages

    Core Packages

    Package Version Description
    odata-sqlite-contracts npm Core interfaces and contracts
    odata-sqlite-core npm SQL builder and query executor
    odata-sqlite-expand npm $expand (JOIN) operations
    odata-sqlite-search npm Full-text search with FTS5
    odata-sqlite-aggregation npm $apply aggregations
    odata-sqlite-compute npm $compute computed properties
    odata-sqlite-batch npm Batch operations
    odata-sqlite-delta npm Delta links and change tracking

    Framework Integrations

    Package Version Description
    odata-sqlite-express npm Express.js integration
    odata-sqlite-astro npm Astro integration

    ๐Ÿš€ Quick Start

    Installation

    # Core functionality
    npm install odata-sqlite-core odata-sqlite-contracts
    
    # Advanced features
    npm install odata-sqlite-expand odata-sqlite-search odata-sqlite-aggregation odata-sqlite-compute
    
    # Batch operations and delta links
    npm install odata-sqlite-batch odata-sqlite-delta
    
    # Framework integration
    npm install odata-sqlite-express  # For Express.js
    npm install odata-sqlite-astro    # For Astro

    Basic Usage

    import { SQLBuilder, ConnectionAdapter } from 'odata-sqlite-core';
    import { LocalSQLiteAdapter } from 'odata-sqlite-core';
    
    // Setup database connection
    const adapter = new LocalSQLiteAdapter('database.db');
    const builder = new SQLBuilder();
    
    // Build OData query
    const query = builder.buildSelectQuery('Products', {
      filter: 'price gt 100',
      top: 10,
      orderBy: 'price desc',
      select: 'id,name,price'
    });
    
    // Execute query
    const result = await adapter.query(query.sql, query.params);

    Express.js Integration

    import express from 'express';
    import { ExpressODataHandler } from 'odata-sqlite-express';
    
    const app = express();
    const handler = new ExpressODataHandler({
      connection: adapter,
      schemas: { Products, Categories }
    });
    
    // Register OData routes
    app.use('/api/odata', handler.createRouter());

    Advanced Features

    Batch Operations

    import { BatchBuilder } from 'odata-sqlite-batch';
    
    const batchBuilder = new BatchBuilder();
    const batchRequest = `
    --batch_boundary
    Content-Type: multipart/mixed; boundary=batch_boundary
    
    --batch_boundary
    Content-Type: application/http
    
    GET /api/odata/Products HTTP/1.1
    
    --batch_boundary
    Content-Type: application/http
    
    POST /api/odata/Products HTTP/1.1
    Content-Type: application/json
    
    {"name": "New Product", "price": 99.99}
    --batch_boundary--
    `;
    
    const result = await batchBuilder.executeBatch(batchRequest, adapter);
    import { DeltaTracker } from 'odata-sqlite-delta';
    
    const deltaTracker = new DeltaTracker();
    
    // Track changes
    deltaTracker.trackChange('Products', 1, 'create');
    deltaTracker.trackChange('Products', 1, 'update');
    
    // Generate delta link
    const deltaLink = deltaTracker.generateDeltaLink(
      'http://localhost:3000/api/odata/Products',
      'Products',
      Date.now()
    );
    import { SearchProvider } from 'odata-sqlite-search';
    
    const searchProvider = new SearchProvider();
    const searchResult = searchProvider.buildSearchQuery(
      'laptop computer',
      'products_fts',
      ['name', 'description']
    );

    ๐Ÿงช Testing

    All packages include comprehensive test suites:

    # Run all tests
    npm test
    
    # Run with coverage
    npm run test:coverage
    
    # Run integration tests
    npm run test:integration

    ๐Ÿ“š Documentation

    Core Concepts

    • OData v4 Compliance - Full implementation of OData v4 specification
    • SQLite Integration - Works with both local SQLite and Turso cloud
    • Type Safety - Complete TypeScript support with strict mode
    • Performance - Optimized query building and execution

    Query Options Supported

    • $filter - Complex filtering with operators
    • $select - Field selection
    • $orderby - Sorting with multiple fields
    • $top / $skip - Pagination
    • $expand - Relationship expansion
    • $search - Full-text search
    • $apply - Aggregations and grouping
    • $compute - Computed properties
    • $count - Result counting
    • $batch - Batch operations
    • $deltatoken - Change tracking

    Database Support

    • Local SQLite - Using better-sqlite3
    • Turso Cloud - Using @libsql/client
    • Custom Adapters - Extensible connection system

    ๐Ÿ—๏ธ Architecture

    The library follows clean architecture principles with clear separation of concerns:

    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                    Framework Integrations                   โ”‚
    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
    โ”‚  โ”‚   Express.js    โ”‚  โ”‚     Astro       โ”‚  โ”‚   Custom    โ”‚ โ”‚
    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                    Advanced Features                        โ”‚
    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
    โ”‚  โ”‚    Batch    โ”‚  โ”‚    Delta    โ”‚  โ”‚    Aggregations     โ”‚ โ”‚
    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                      Core Features                          โ”‚
    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
    โ”‚  โ”‚    Expand   โ”‚  โ”‚   Search    โ”‚  โ”‚      Compute        โ”‚ โ”‚
    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                        Core Layer                           โ”‚
    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
    โ”‚  โ”‚   SQL Builder   โ”‚  โ”‚   Connection    โ”‚  โ”‚  Contracts  โ”‚ โ”‚
    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                    Database Layer                           โ”‚
    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
    โ”‚  โ”‚   Local SQLite  โ”‚  โ”‚   Turso Cloud   โ”‚  โ”‚   Custom    โ”‚ โ”‚
    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

    ๐ŸŽฏ Use Cases

    E-commerce Applications

    • Product catalog with filtering and search
    • Order management with relationships
    • Customer analytics with aggregations

    Content Management Systems

    • Article search and categorization
    • Media library management
    • User activity tracking

    Business Intelligence

    • Data analytics and reporting
    • Real-time dashboards
    • Change tracking and auditing

    ๐Ÿ”ง Development

    Prerequisites

    • Node.js 18+
    • TypeScript 5+
    • SQLite 3.x

    Setup

    git clone https://github.com/your-username/sqlite-db-odata4.git
    cd sqlite-db-odata4
    npm install
    npm run build

    Contributing

    1. Fork the repository
    2. Create a feature branch
    3. Write tests first (TDD)
    4. Implement the feature
    5. Ensure all tests pass
    6. Submit a pull request

    ๐Ÿ“„ License

    MIT License - see LICENSE file for details.

    ๐Ÿค Support

    ๐Ÿ™ Acknowledgments

    • OData v4 specification contributors
    • SQLite development team
    • Turso/libSQL team
    • Express.js and Astro communities

    Built with โค๏ธ by The Happiest Software Engineer in the Universe