UNPKG

@oystehr/sdk

Version:

Oystehr SDK

51 lines (50 loc) 2.08 kB
import { OystehrConfig } from '../config'; import { FhirBundle, FhirResource } from '../resources/types'; export declare const defaultProjectApiUrl = "https://project-api.zapehr.com/v1"; /** * Optional parameter that can be passed to the client methods. It allows * overriding the access token or project ID, and setting various headers, * such as 'Content-Type'. */ export interface OystehrClientRequest { /** * The access token to use for the request. If not provided, the access token from `oystehr.init()` will be used. */ accessToken?: string; /** * The project ID to use for the request. If not provided, the project ID from `oystehr.init()` will be used. */ projectId?: string; /** * The value of the 'Content-Type' header to use for the request. */ contentType?: string; /** * Unique identifier for this request. */ requestId?: string; } interface InternalClientRequest extends OystehrClientRequest { ifMatch?: string; } type FhirData<T extends FhirResource> = T | T[] | FhirBundle<T>; export type FhirFetcherResponse<T extends FhirData<FhirResource> = any> = T; export declare class SDKResource { protected readonly config: OystehrConfig; constructor(config: OystehrConfig); protected request(path: string, method: string, baseUrlThunk: () => string): FetcherFunction; protected fhirRequest<T extends FhirResource = any>(path: string, method: string): (params: any, request?: InternalClientRequest) => Promise<FhirFetcherResponse<T>>; } export type FetcherError = { message: string; code: number; }; export type FetcherResponse = any; export type FetcherFunction = (params?: Record<string, any> | [any] | InternalClientRequest, request?: InternalClientRequest) => Promise<FetcherResponse>; /** * Adds params to a URLSearchParams object in such a way as to preserve array values. * @param params params * @param search URLSearchParams object */ export declare function addParamsToSearch(params: Record<string, unknown>, search: URLSearchParams): void; export {};