reduct-js
Version:
ReductStore Client SDK for Javascript/NodeJS/Typescript
31 lines (30 loc) • 1.18 kB
JavaScript
export var QuotaType;
(function (QuotaType) {
QuotaType[QuotaType["NONE"] = 0] = "NONE";
QuotaType[QuotaType["FIFO"] = 1] = "FIFO";
QuotaType[QuotaType["HARD"] = 2] = "HARD";
})(QuotaType || (QuotaType = {}));
/**
* Represents bucket settings
*/
export class BucketSettings {
static parse(data) {
const { max_block_size, max_block_records, quota_type, quota_size } = data;
return {
maxBlockSize: max_block_size !== undefined ? BigInt(max_block_size) : undefined,
maxBlockRecords: max_block_records !== undefined ? BigInt(max_block_records) : undefined,
// @ts-ignore
quotaType: quota_type !== undefined ? QuotaType[quota_type] : undefined,
quotaSize: quota_size !== undefined ? BigInt(quota_size) : undefined,
};
}
static serialize(settings) {
const { maxBlockSize, maxBlockRecords, quotaType, quotaSize } = settings;
return {
max_block_size: maxBlockSize,
max_block_records: maxBlockRecords,
quota_type: quotaType !== undefined ? QuotaType[quotaType] : undefined,
quota_size: quotaSize,
};
}
}