@mdf.js/openc2-core
Version:
MMS - API Core - OpenC2
69 lines • 2.96 kB
TypeScript
/**
* Copyright 2024 Mytra Control S.L. All rights reserved.
*
* Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
* or at https://opensource.org/licenses/MIT.
*/
import { Health, Layer } from '@mdf.js/core';
import { RetryOptions } from '@mdf.js/utils';
import EventEmitter from 'events';
import { Control, ProducerAdapter } from '../../../types';
export declare class AdapterWrapper extends EventEmitter implements Layer.App.Resource {
private readonly adapter;
/** Operation retry options */
private readonly retryOptions;
/** Flag to indicate that an unhealthy status has been emitted recently */
private lastStatusEmitted?;
/** Indicate if the last operation was finished with error */
private lastOperationError?;
/** Date of the last operation performed */
private lastOperationDate?;
/** Perform the publication of the message in the underlayer transport system */
private readonly publishOriginal;
/**
* Create a new instance of AdapterWrapper
* @param adapter - adapter instance
* @param retryOptions - options for job retry operations
*/
constructor(adapter: ProducerAdapter, retryOptions?: RetryOptions);
/** Component name */
get name(): string;
/** Component identifier */
get componentId(): string;
/** Connect the OpenC2 Adapter to the underlayer transport system */
start(): Promise<void>;
/** Disconnect the OpenC2 Adapter to the underlayer transport system */
stop(): Promise<void>;
/** Close the OpenC2 Adapter to the underlayer transport system */
close(): Promise<void>;
/**
* Check if the adapter implements the mandatory methods
* @throws Crash if the adapter does not implement the mandatory methods
*/
private checkMandatoryMethods;
/**
* Perform the retry functionality for a promise
* @param task - promise to execute
* @param funcArgs - promise arguments
* @param options - control execution options
* @returns
*/
private wrappedOperation;
/** Overall component status */
get status(): Health.Status;
/** Emit the status if it's different from the last emitted status */
private emitStatus;
/** Register an error in the adapter operation */
private readonly onOperationError;
/** Register an error in the adapter operation */
private readonly onOperationSuccess;
/** Perform the publication of the message in the underlayer transport system */
readonly publish: (message: Control.Message) => Promise<Control.ResponseMessage | Control.ResponseMessage[] | void>;
/**
* Return the status of the adapter in a standard format
* @returns _check object_ as defined in the draft standard
* https://datatracker.ietf.org/doc/html/draft-inadarei-api-health-check-05
*/
get checks(): Health.Checks;
}
//# sourceMappingURL=AdapterWrapper.d.ts.map