npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

delphi-node-sdk

v0.1.22

Published

A NodeJS SDK for the Delphi API

Downloads

291

Readme

Delphi SDK

The Delphi SDK provides an easy-to-use TypeScript interface for interacting with various analytics platforms such as dbt, Lightdash, Looker, Metabase, and Cube.js. It allows you to generate queries, refine them, obtain answers, create charts, search entities, and more.

Installation

To install the Delphi SDK, use the following command:

npm install delphi-node-sdk

Usage

First, import the DelphiApi class from the SDK:

import { DelphiApi } from 'delphi-node-sdk';

Initializing the API client

Create a new instance of the DelphiApi class with your credentials:

const delphi = new DelphiApi({
  clientId: 'your-client-id',
  apiKey: 'your-api-key',
});

Error handling

The SDK will throw a DelphiError if there's a problem with the API request. To handle errors, use a try-catch block:

try {
  const response = await delphi.someMethod(request);
} catch (error) {
  console.error('An error occurred:', error);
}

Methods

The DelphiApi class provides the following methods.

Please refer to the types folder for details on the request and response objects of each method.

generateDbtMetricsQuery

generateDbtMetricsQuery(request: DbtMetricsQueryRequest): Promise<DbtMetricsQueryResponse>

Generates a dbt metrics query based on the provided request.

generateLightdashQuery

generateLightdashQuery(request: LightdashQueryRequest): Promise<LightdashQueryResponse>

Generates a Lightdash query based on the provided request.

generateLookerQuery

generateLookerQuery(request: LookerQueryRequest): Promise<LookerQueryResponse>

Generates a Looker query based on the provided request.

generateMetabaseQuery

generateMetabaseQuery(request: MetabaseQueryRequest): Promise<MetabaseQueryResponse>

Generates a Metabase query based on the provided request.

generateCubeQuery

generateCubeQuery(request: CubeQueryRequest): Promise<CubeQueryResponse>

Generates a Cube.js query based on the provided request.

summarizeQuery

summarizeQuery(request: SummarizeQueryRequest): Promise<SummarizeQueryResponse>

Summarizes the given query to provide a human-readable summary.

refineQuery

refineQuery<T extends Query>(request: RefineQueryRequest<T>): Promise<RefineQueryResponse<T>>

Refines the given query based on the provided request, returning an optimized or more specific query.

answerFromData

answerFromData(request: GetAnswerRequest): Promise<GetAnswerResponse>

Retrieves an answer from the data based on the provided request.

chartFromData

chartFromData(request: GetAnswerRequest): Promise<GetChartResponse>

Generates a chart from the data based on the provided request.

searchEntities

searchEntities<T extends Document>(request: SearchEntitiesRequest<T>): Promise<SearchEntitiesResponse<T>>

Searches for entities in the data based on the provided request, returning a list of matching entities.

postValidatedQuery

postValidatedQuery(request: PostValidatedQueryRequest): Promise<void>

Posts a validated query to the API, storing it for future reference.

getValidatedQueries

getValidatedQueries(request: GetValidatedQueryRequest): Promise<GetValidatedQueryResponse[]>

Retrieves a list of validated queries based on the provided request.

classifyMessage

classifyMessage(request: ClassifyMessageRequest): Promise<ClassifyMessageResponse>

Classifies a given message based on the provided request, returning a classification result.

chat

chat(request: ChatRequest): Promise<ChatResponse>

Sends a chat request to the API and returns a chat response.

Example

Here's an example of how to generate a Lightdash query:

import { DelphiApi, LightdashQueryRequest } from 'delphi-sdk';

const delphi = new DelphiApi({
  clientId: 'your-client-id',
  apiKey: 'your-api-key',
});

async function generateQuery() {
  const request: LightdashQueryRequest = {
    // Your request data here
  };

  try {
    const response = await delphi.generateLightdashQuery(request);
    console.log('Generated Lightdash query:', response);
  } catch (error) {
    console.error('An error occurred:', error);
  }
}

generateQuery();

Make sure to replace 'your-client-id' and 'your-api-key' with your actual credentials, and fill in the request object with the required data.

Development

  1. yarn
  2. yarn build
  3. yarn link
  4. (In the projects you are using this, such as the Delphi Frontend or Slack App) yarn link delphi-node-sdk
  5. After making any changes here, run yarn build again so that your applications get your changes
  6. Bump the version number in package.json before pushing changes.