Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

3.9 KB
Raw Blame

NocoDB Integrations

This monorepo contains the integration framework and various integrations for NocoDB.

Structure

nocodb-integrations/
β”œβ”€β”€ core/                      # Core integration framework
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ auth-github/           # GitHub auth integration
β”‚   β”œβ”€β”€ ai-openai/             # OpenAI integration
β”‚   └── ...                    # Other integrations

Development

Prerequisites

  • Node.js >= 22
  • pnpm >= 9

Setup

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run tests
pnpm test

Testing

The repository includes a comprehensive testing setup:

# Run tests for all packages
pnpm test

# Run tests with coverage for all packages
pnpm test:coverage

# Run tests for a specific package
pnpm --filter @noco-integrations/openai-ai test

Each integration package contains its own tests in a tests/ directory. All tests use Vitest as the testing framework.

Creating a New Integration

Alternatively, you can create a new package manually:

  1. Create a new package in the packages directory
  2. Follow the integration package structure:
    
    

provider-type/ β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ index.ts # Main entry point β”‚ β”œβ”€β”€ manifest.ts # Integration metadata β”‚ β”œβ”€β”€ form.ts # Configuration form β”‚ └── integration.ts # Integration implementation β”œβ”€β”€ tests/ # Tests for the integration β”œβ”€β”€ package.json β”œβ”€β”€ tsconfig.json └── README.md


3. Implement the required interfaces from `@noco-integrations/core`
4. Add tests for your integration

## Sync Integration Standardization Guidelines

This document outlines the standards and best practices for creating and maintaining sync integrations in the NocoDB integrations monorepo.

### Structure

Every sync integration should follow this structure:

packages/[provider]-sync/ β”œβ”€β”€ package.json # Dependencies and metadata β”œβ”€β”€ tsconfig.json # TypeScript configuration └── src/ β”œβ”€β”€ index.ts # Integration entry point β”œβ”€β”€ integration.ts # Implementation class β”œβ”€β”€ form.ts # Configuration UI definition └── manifest.ts # Integration metadata


### Implementation Standards

1. **Class Structure**
   - Extend the `SyncIntegration` abstract class
   - Implement all required methods:
     - `getDestinationSchema()`
     - `fetchData()`
     - `formatData()`
     - `getIncrementalKey()`

2. **Error Handling**
   - Use try/catch blocks for all API calls
   - Log errors with descriptive messages
   - Include provider-specific error codes where possible

3. **Pagination**
   - Implement proper pagination for all API endpoints
   - Use provider-specific pagination mechanisms

4. **Data Mapping**
   - Follow consistent patterns when mapping provider data to NocoDB schema
   - Use helper methods for complex mappings

5. **Authentication**
   - Use auth integrations correctly
   - Handle token refresh when needed

### Code Style

1. **Naming Conventions**
   - Class name: `[Provider]SyncIntegration`
   - File names: lowercase with hyphens
   - Config interface: `[Provider]SyncPayload`

2. **Logging**
   - Use the built-in `this.log()` method
   - Format log messages as `[Provider Sync] Message`

3. **Comments**
   - Document complex logic or workarounds

### Configuration Form

1. **Required Fields**
   - Authentication integration selection
   - Provider-specific identifiers (repo, project, etc.)

2. **Optional Fields**
   - Data filtering options (e.g., include closed items)
   - Sync frequency settings

### Testing

1. **Manual Testing**
   - Test with real provider accounts
   - Verify incremental sync works correctly

2. **Automated Testing**
   - Create unit tests for data mapping functions
   - Use mocks for API responses