UNPKG

reduct-js

Version:

ReductStore Client SDK for Javascript/NodeJS/Typescript

85 lines (84 loc) 1.7 kB
class DiagnosticsErrorOriginal { constructor() { this.count = 0; this.last_message = ""; } } /** * Diagnostics error */ export class DiagnosticsError { constructor() { /** * Number of errors */ this.count = 0; /** * Last error message */ this.lastMessage = ""; } static parse(data) { return { count: data.count, lastMessage: data.last_message, }; } } class OrigianlDiagnosticsItem { constructor() { this.ok = 0n; this.errored = 0n; this.errors = {}; } } /** * Diagnostics item */ export class DiagnosticsItem { constructor() { /** * Number of successful operations */ this.ok = 0n; /** * Number of failed operations */ this.errored = 0n; /** * Errors */ this.errors = {}; } static parse(data) { return { ok: BigInt(data.ok), errored: BigInt(data.errored), errors: Object.fromEntries(Object.entries(data.errors).map(([key, value]) => [ Number(key), DiagnosticsError.parse(value), ])), }; } } export class OriginalDiagnostics { constructor() { this.hourly = new OrigianlDiagnosticsItem(); } } /** * Diagnostics */ export class Diagnostics { constructor() { /** * Hourly diagnostics */ this.hourly = new DiagnosticsItem(); } static parse(data) { return { hourly: DiagnosticsItem.parse(data.hourly), }; } }