@squidcloud/client
Version:
A typescript implementation of the Squid client
73 lines (72 loc) • 2.5 kB
TypeScript
import { IntegrationId } from '../public-types/communication.public-types';
/**
* Represents the type of native query request, either relational, elastic or MongoDB.
* @category Database
*/
export type NativeQueryRequestType = 'relational' | 'mongo' | 'elasticsearch' | 'pure';
interface BaseNativeQueryContext {
/** Type of the native query request. */
type: NativeQueryRequestType;
/** Identifier for the integration. */
integrationId: IntegrationId;
}
/**
* Context for executing a relational database query.
* @category Database
*/
export interface RelationalNativeQueryContext extends BaseNativeQueryContext {
/** Specifies that the query is for a relational database. */
type: 'relational';
/** SQL query string to be executed. */
query: string;
/** Parameters to be used in the query. */
params: Record<string, any>;
}
/**
* Context for executing a MongoDB query.
* @category Database
*/
export interface MongoNativeQueryContext extends BaseNativeQueryContext {
/** Specifies that the query is for a Mongo database. */
type: 'mongo';
/** Name of the MongoDB collection to query. */
collectionName: string;
/** Array of aggregation pipeline stages. */
aggregationPipeline: Array<any | undefined>;
}
/**
* Context for executing an Elasticsearch query.
* @category Database
*/
export interface ElasticsearchNativeQueryContext {
/** Specifies that the query is for an Elasticsearch database. */
type: 'elasticsearch';
/** Elasticsearch index to query. */
index: string;
/** Elasticsearch query string. */
endpoint?: string;
/** HTTP method to use for the request. */
method?: 'GET' | 'POST';
/** Body of the request. */
body: Record<string, any>;
/** Headers to include in the request. */
integrationId: IntegrationId;
}
/**
* Context for executing a pure database query.
* @category Database
*/
export interface PureNativeQueryContext extends BaseNativeQueryContext {
/** Specifies that the query is for a relational database. */
type: 'pure';
/** SQL query string to be executed. */
query: string;
/** Parameters to be used in the query. */
params: Record<string, any>;
}
/**
* Union type representing either a relational or MongoDB native query context.
* @category Database
*/
export type NativeQueryContext = RelationalNativeQueryContext | MongoNativeQueryContext | ElasticsearchNativeQueryContext | PureNativeQueryContext;
export {};