CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-lightdash--common

tessl install tessl/npm-lightdash--common@0.2231.5

Shared TypeScript library for the Lightdash platform containing common types, utilities, and business logic for analytics workflows

Agent Success

Agent success rate when using this tile

72%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.09x

Baseline

Agent success rate without this tile

66%

task.mdevals/scenario-4/

Multi-Table Data Model Builder

Build a function that creates data model configurations with multiple tables connected through join relationships.

@generates

Requirements

Create a function that constructs a data model configuration combining multiple tables. The function should:

  1. Accept a base table and a list of tables to join
  2. Configure join types (LEFT, INNER, FULL) with SQL ON clauses
  3. Specify relationship types between tables (ONE_TO_MANY, MANY_TO_ONE, ONE_TO_ONE)
  4. Return a complete configuration object

Test Cases

  • Creating a model with base table "orders" and LEFT joining "customers" ON "orders.customer_id = customers.id" with relationship "one-to-many" returns a config with both tables and correct join settings @test

  • Creating a model with "orders" base table, LEFT joining "customers" and INNER joining "products" with their ON clauses should include both joins in the configuration @test

  • Creating a model with FULL join type and "one-to-one" relationship should correctly set the join type in the returned configuration @test

API

interface JoinConfig {
  tableName: string;
  joinType: 'left' | 'inner' | 'full' | 'right';
  sqlOn: string;
  relationship: 'one-to-many' | 'many-to-one' | 'one-to-one' | 'many-to-many';
}

interface TableConfig {
  name: string;
  sqlTable: string;
}

interface JoinedTable extends TableConfig {
  sqlOn: string;
  type: 'left' | 'inner' | 'full' | 'right';
}

interface ExploreConfig {
  name: string;
  baseTable: string;
  joinedTables: JoinedTable[];
}

export function createExplore(
  baseName: string,
  baseTable: TableConfig,
  joins: JoinConfig[]
): ExploreConfig;

Dependencies { .dependencies }

@lightdash/common { .dependency }

Provides the core type system and utilities for building data exploration models with join configurations.

@satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@lightdash/common@0.2231.x
tile.json