Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docstrings streamline #52

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export class DuneClient {
/// Table Management Interface
table: TableAPI;

/**
* Constructor for the DuneClient.
*
* @param {string} apiKey
* @returns Execution Results
*/
constructor(apiKey: string) {
this.exec = new ExecutionAPI(apiKey);
this.query = new QueryAPI(apiKey);
Expand Down
16 changes: 12 additions & 4 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import { GetResultParams } from "./types/requestArgs";

// Seconds between checking execution status
/*
* Seconds between checking execution status
*/
export const POLL_FREQUENCY_SECONDS = 1;
// This is the expiry time on old query results.
/*
* This is the expiry time on old query results.
*/
export const THREE_MONTHS_IN_HOURS = 2191;
// Headers used for pagination in CSV results
/*
* Headers used for pagination in CSV results
*/
export const DUNE_CSV_NEXT_URI_HEADER = "x-dune-next-uri";
export const DUNE_CSV_NEXT_OFFSET_HEADER = "x-dune-next-offset";
// Default maximum number of rows to retrieve per batch of results
/*
* Default maximum number of rows to retrieve per batch of results
*/
export const MAX_NUM_ROWS_PER_BATCH = 32_000;

export const DEFAULT_GET_PARAMS: GetResultParams = {
Expand Down
4 changes: 3 additions & 1 deletion src/types/error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/// Basic Error structure meant to represent Dune API errors.
/*
* Basic Error structure meant to represent Dune API errors.
*/
export class DuneError extends Error {
constructor(msg: string) {
super(msg);
Expand Down
52 changes: 38 additions & 14 deletions src/types/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,57 @@ import { QueryParameter } from "./queryParameter";

/**
* Enriched structure representing all data constituting a DuneQuery.
* Modeling the CRUD operation response for `get_query`
* Modeling the CRUD operation response for 'get_query'
* https://docs.dune.com/api-reference/queries/endpoint/read#example-return
*/
export interface DuneQuery {
/// Description of the query.
/**
* Description of the query.
*/
description: string;
/// Indicates if the query is archived.
/// Note: This is as close as a user can get to deleting a query.
/**
* Indicates if the query is archived.
* Note: This is as close as a user can get to deleting a query.
*/
is_archived: boolean;
/// Indicates if the query is private.
/**
* Indicates if the query is private.
*/
is_private: boolean;
/// Indicates if the query is unsaved.
/**
* Indicates if the query is unsaved.
*/
is_unsaved: boolean;
/// Name of the query.
/**
* Name of the query.
*/
name: string;
/// Dune user who owns the query.
/**
* Dune user who owns the query.
*/
owner: string;
/// Parameters with their names and default values.
/**
* Parameters with their names and default values.
*/
parameters: QueryParameter[];
/// The query engine used to execute the query.
/**
* The query engine used to execute the query.
*/
query_engine: string;
/// Unique identifier of the query.
/**
* Unique identifier of the query.
*/
query_id: number;
/// Raw SQL of the query.
/**
* Raw SQL of the query.
*/
query_sql: string;
/// Tags associated with the query.
/**
* Tags associated with the query.
*/
tags: string[];
/// Version of the query.
/**
* Version of the query.
*/
version: number;
}
8 changes: 6 additions & 2 deletions src/types/queryParameter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/// All supported Dune Query Parameter types.
/*
* All supported Dune Query Parameter types.
*/
export enum ParameterType {
/// Note that text fields may also be used for varbinary data types.
TEXT = "text",
Expand All @@ -7,7 +9,9 @@ export enum ParameterType {
ENUM = "enum",
}

/// Class representing Dune Query Parameters with convience constructor methods for each type.
/*
* Class representing Dune Query Parameters with convience constructor methods for each type.
*/
export class QueryParameter {
type: ParameterType;
value: string;
Expand Down
Loading
Loading