0.1.22 • Published 4 months ago

delphi-node-sdk v0.1.22

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

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.
0.1.22

4 months ago

0.1.21

4 months ago

0.1.20

4 months ago

0.1.19

5 months ago

0.1.18

5 months ago

0.1.17

5 months ago

0.1.16

5 months ago

0.1.15

5 months ago

0.1.14

5 months ago

0.1.13

5 months ago

0.1.10

5 months ago

0.1.11

5 months ago

0.1.12

5 months ago

0.1.9

5 months ago

0.1.8

5 months ago

0.0.84

8 months ago

0.0.85

8 months ago

0.0.80

8 months ago

0.0.81

8 months ago

0.0.82

8 months ago

0.0.83

8 months ago

0.0.73

8 months ago

0.0.74

8 months ago

0.0.75

8 months ago

0.0.76

8 months ago

0.0.77

8 months ago

0.0.78

8 months ago

0.0.79

8 months ago

0.0.70

8 months ago

0.0.71

8 months ago

0.0.72

8 months ago

0.1.0

8 months ago

0.1.2

7 months ago

0.1.1

7 months ago

0.1.7

6 months ago

0.1.4

6 months ago

0.1.3

6 months ago

0.1.6

6 months ago

0.1.5

6 months ago

0.0.62

10 months ago

0.0.63

9 months ago

0.0.64

9 months ago

0.0.65

9 months ago

0.0.66

9 months ago

0.0.67

9 months ago

0.0.68

9 months ago

0.0.69

9 months ago

0.0.60

10 months ago

0.0.61

10 months ago

0.0.59

10 months ago

0.0.53

11 months ago

0.0.54

10 months ago

0.0.55

10 months ago

0.0.56

10 months ago

0.0.57

10 months ago

0.0.58

10 months ago

0.0.51

11 months ago

0.0.52

11 months ago

0.0.50

11 months ago

0.0.45

1 year ago

0.0.46

1 year ago

0.0.47

1 year ago

0.0.48

12 months ago

0.0.49

12 months ago

0.0.40

1 year ago

0.0.41

1 year ago

0.0.42

1 year ago

0.0.43

1 year ago

0.0.44

1 year ago

0.0.37

1 year ago

0.0.38

1 year ago

0.0.39

1 year ago

0.0.30

1 year ago

0.0.31

1 year ago

0.0.32

1 year ago

0.0.33

1 year ago

0.0.34

1 year ago

0.0.35

1 year ago

0.0.36

1 year ago

0.0.28

1 year ago

0.0.29

1 year ago

0.0.22

1 year ago

0.0.23

1 year ago

0.0.24

1 year ago

0.0.25

1 year ago

0.0.26

1 year ago

0.0.27

1 year ago

0.0.20

1 year ago

0.0.21

1 year ago

0.0.10

1 year ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.3

1 year ago

0.0.15

1 year ago

0.0.9

1 year ago

0.0.16

1 year ago

0.0.8

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.1-rc.0

1 year ago