librelinkup-api-client
Version:
An unofficial API for Libre Link Up (glucose monitoring system/CGM)
62 lines (61 loc) • 2.16 kB
TypeScript
import { GlucoseReading } from "./reading";
import { RawGlucoseReading, LibreUser, MeasurementColor, Trend } from "./types";
/**
* Parse a Libre User object.
* @param user The user object to parse.
* @returns The parsed user object.
*/
export declare const parseUser: (user: Record<string, any>) => LibreUser;
/**
* @description Parse unix timestamps to Date objects.
* @param timestamp The unix timestamp to parse.
* @returns The parsed date.
*/
export declare const parseUnixTimestamp: (timestamp: number) => Date;
/**
* @description Parse a glucose reading.
* @param rawReading The raw glucose reading coming from the server to parse.
* @param connection The connection object to use for parsing. Used for calculating isHigh and isLow.
* @returns The parsed glucose reading.
*/
export declare const parseGlucoseReading: (rawReading: RawGlucoseReading, options: {
targetHigh: number;
targetLow: number;
}) => Readonly<{
timestamp: Date;
value: number;
measurementColor: MeasurementColor;
isHigh: boolean;
isLow: boolean;
trend: Trend;
}>;
/**
* @description Sort by timestamp.
* @param a The first item to compare.
* @param b The second item to compare.
* @returns The comparison result.
*
* @example
* .sort(sortByTimestamp)
*/
export declare const sortByTimestamp: (a: GlucoseReading, b: GlucoseReading) => number;
/**
* @description Parse the trend of glucose reading.
* @param trend The current trend.
* @param defaultTrend The default trend to use if trend is undefined.
* @returns The parsed trend.
*/
export declare const parseTrend: (trend: number | undefined, defaultTrend?: Trend) => Trend;
/**
* @description Get the trend type of glucose reading.
* @param trend The current trend.
* @param defaultTrend The default trend to use if trend is undefined.
* @returns The trend type.
*/
export declare const getTrendType: (trend: number | undefined, defaultTrend?: Trend) => string;
/**
* @description Encrypt message in sha256.
* @param message The message to be encrypted.
* @returns The encrypted message.
*/
export declare const encryptSha256: (message: string) => Promise<string>;