@mdf.js/openc2-core
Version:
MMS - API Core - OpenC2
39 lines • 1.6 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 { Jobs } from '@mdf.js/core';
import { Crash } from '@mdf.js/crash';
import EventEmitter from 'events';
import { Control } from '../types';
import { Model } from './oc2.model';
export type CommandResponse = Control.ResponseMessage | Control.ResponseMessage[];
export type CommandResponseHandler = (error?: Crash | Error, message?: CommandResponse) => void;
export declare interface Service {
/** Event emitted when a command is received */
on(event: 'command', listener: (message: Control.CommandMessage, done: CommandResponseHandler) => void): this;
}
/** Service class */
export declare class Service extends EventEmitter {
private readonly model;
/**
* Create an instance of service
* @param model - model instance
*/
constructor(model: Model);
/** Return array of messages used as fifo registry */
messages(): Promise<Control.Message[]>;
/** Return array of jobs used as fifo registry */
jobs(): Promise<Jobs.Result<'command'>[]>;
/** Return array of pendingJobs used as fifo registry */
pendingJobs(): Promise<Jobs.Result<'command'>[]>;
/**
* Execute a command over the producer or consumer
* @param message - message to be processed
* @returns - response message
*/
command(message: Control.CommandMessage): Promise<CommandResponse | undefined>;
}
//# sourceMappingURL=oc2.service.d.ts.map