@medusajs/types
Version:
Medusa Types definition
104 lines • 4.18 kB
TypeScript
import { Prettify } from "../common";
import { IndexQueryInput, QueryResultSet } from "../index-data/query-config/query-input-config";
import { RemoteJoinerOptions, RemoteJoinerQuery } from "../joiner";
import { RemoteQueryEntryPoints } from "./remote-query-entry-points";
import { RemoteQueryInput, RemoteQueryObjectConfig, RemoteQueryObjectFromStringResult } from "./remote-query-object-from-string";
export type RemoteQueryFunctionReturnPagination = {
skip: number;
take: number;
count: number;
};
/**
* The GraphResultSet presents a typed output for the
* result returned by the underlying remote query
*/
export type GraphResultSet<TEntry extends string> = {
data: TEntry extends keyof RemoteQueryEntryPoints ? RemoteQueryEntryPoints[TEntry][] : any[];
metadata?: RemoteQueryFunctionReturnPagination;
};
/**
* QueryGraphFunction is a wrapper on top of remoteQuery
* that simplifies the input it accepts and returns
* a normalized/consistent output.
*/
export type QueryGraphFunction = {
<const TEntry extends string>(queryConfig: RemoteQueryInput<TEntry>, options?: RemoteJoinerOptions): Promise<Prettify<GraphResultSet<TEntry>>>;
};
/**
* QueryIndexFunction is a wrapper on top of indexModule
* that simplifies the input it accepts and returns
* a normalized/consistent output.
*/
export type QueryIndexFunction = {
<const TEntry extends string>(queryOptions: IndexQueryInput<TEntry>): Promise<Prettify<QueryResultSet<TEntry>>>;
};
export type RemoteQueryFunction = {
/**
* Query wrapper to provide specific API's and pre processing around remoteQuery.query
* @param queryConfig
* @param options
*/
<const TEntry extends string>(queryConfig: RemoteQueryObjectConfig<TEntry>, options?: RemoteJoinerOptions): Promise<any>;
/**
* Query wrapper to provide specific API's and pre processing around remoteQuery.query
* @param queryConfig
* @param options
*/
<const TConfig extends RemoteQueryObjectFromStringResult<any>>(queryConfig: TConfig, options?: RemoteJoinerOptions): Promise<any>;
/**
* Query wrapper to provide specific API's and pre processing around remoteQuery.query
* @param query
* @param options
*/
(query: RemoteJoinerQuery, options?: RemoteJoinerOptions): Promise<any>;
/**
* Graph function uses the remoteQuery under the hood and
* returns a result set
*/
graph: QueryGraphFunction;
/**
* Index function uses the index module to query and remoteQuery to hydrate the data
* returns a result set
*/
index: QueryIndexFunction;
/**
* Query wrapper to provide specific GraphQL like API around remoteQuery.query
* @param query
* @param variables
* @param options
*/
gql: (query: string, variables?: Record<string, unknown>, options?: RemoteJoinerOptions) => Promise<any>;
};
export interface Query {
/**
* Query wrapper to provide specific API's and pre processing around remoteQuery.query
* @param queryConfig
* @param options
*/
query<const TEntry extends string>(queryConfig: RemoteQueryObjectConfig<TEntry>, options?: RemoteJoinerOptions): Promise<any>;
/**
* Query wrapper to provide specific API's and pre processing around remoteQuery.query
* @param queryConfig
* @param options
*/
query<const TConfig extends RemoteQueryObjectFromStringResult<any>>(queryConfig: TConfig, options?: RemoteJoinerOptions): Promise<any>;
/**
* Query wrapper to provide specific API's and pre processing around remoteQuery.query
* @param query
* @param options
*/
query(query: RemoteJoinerQuery, options?: RemoteJoinerOptions): Promise<any>;
/**
* Graph function uses the remoteQuery under the hood and
* returns a result set
*/
graph: QueryGraphFunction;
/**
* Query wrapper to provide specific GraphQL like API around remoteQuery.query
* @param query
* @param variables
* @param options
*/
gql: (query: string, variables?: Record<string, unknown>, options?: RemoteJoinerOptions) => Promise<any>;
}
//# sourceMappingURL=remote-query.d.ts.map