reduct-js
Version:
ReductStore Client SDK for Javascript/NodeJS/Typescript
54 lines (53 loc) • 1.69 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import Stream from "stream";
import { Buffer } from "buffer";
import { AxiosInstance } from "axios";
import { WriteOptions } from "./Bucket";
export type LabelMap = Record<string, string | number | boolean | bigint>;
/**
* Represents a record in an entry for reading
*/
export declare class ReadableRecord {
readonly time: bigint;
readonly size: bigint;
readonly last: boolean;
readonly stream: Stream;
readonly labels: LabelMap;
readonly contentType: string | undefined;
private readonly arrayBuffer;
/**
* Constructor which should be call from Bucket
* @internal
*/
constructor(time: bigint, size: bigint, last: boolean, head: boolean, stream: Stream, labels: LabelMap, contentType?: string, arrayBuffer?: ArrayBuffer);
/**
* Read content of record
*/
read(): Promise<Buffer>;
/**
* Read content of record and convert to string
*/
readAsString(): Promise<string>;
}
/**
* Represents a record in an entry for writing
*/
export declare class WritableRecord {
private readonly bucketName;
private readonly entryName;
private readonly httpClient;
private readonly options;
/**
* Constructor for stream
* @internal
*/
constructor(bucketName: string, entryName: string, options: WriteOptions, httpClient: AxiosInstance);
/**
* Write data to record asynchronously
* @param data stream of buffer with data
* @param size size of data in bytes (only for streams)
*/
write(data: Buffer | string | Stream, size?: bigint | number): Promise<void>;
}