@asyncapi/react-component
Version:
A React component for AsyncAPI specification.
106 lines • 3.17 kB
TypeScript
/// <reference types="react" />
import { AsyncAPIDocumentInterface, BaseModel } from '@asyncapi/parser';
export type PropsSchema = string | FetchingSchemaInterface | AsyncAPIDocumentInterface | object;
export type NullableAsyncApi = AsyncAPIDocumentInterface | null;
export interface AsyncApiState {
validatedSchema: NullableAsyncApi;
error?: ErrorObject;
}
export declare function isFetchingSchemaInterface(schema: PropsSchema): schema is FetchingSchemaInterface;
export interface FetchingSchemaInterface {
url: string;
requestOptions?: RequestInit;
}
export interface ParserReturn {
asyncapi?: AsyncAPIDocumentInterface;
error?: ErrorObject;
}
export declare enum PayloadType {
SEND = "send",
RECEIVE = "receive",
REQUEST = "request",
REPLY = "reply"
}
export interface MessageExample {
name?: string;
summary?: string;
example: unknown;
}
export interface ValidationError {
title: string;
location?: {
jsonPointer: string;
startLine: number;
startColumn: number;
startOffset: number;
endLine: number;
endColumn: number;
endOffset: number;
};
}
export interface ErrorObject {
type: string;
title: string;
detail?: string;
parsedJSON?: unknown;
validationErrors?: ValidationError[];
location?: {
startLine: number;
startColumn: number;
startOffset: number;
};
refs?: {
title: string;
jsonPointer: string;
startLine: number;
startColumn: number;
startOffset: number;
endLine: number;
endColumn: number;
endOffset: number;
}[];
}
export interface ExtensionComponentProps<V = any> {
propertyName: string;
propertyValue: V;
document: AsyncAPIDocumentInterface;
parent: BaseModel;
}
export declare enum PluginSlot {
OPERATION = "operation",
INFO = "info"
}
export interface PluginContext {
schema?: PropsSchema;
}
export interface ComponentSlotProps {
context: PluginContext;
onClose?: () => void;
}
export interface AsyncApiPlugin {
name: string;
version: string;
description?: string;
install(api: PluginAPI): void;
}
export type PluginInstance = AsyncApiPlugin | React.ComponentType<ComponentSlotProps>;
export type EventListener = (...args: unknown[]) => void;
export interface MessageBus {
on(eventName: string, callback: (data: unknown) => void): void;
off(eventName: string, callback: (data: unknown) => void): void;
emit(eventName: string, data: unknown): void;
listeners(eventName: string): EventListener[];
eventNames(): string[];
}
export interface PluginAPI {
registerComponent(slot: PluginSlot, component: React.ComponentType<ComponentSlotProps>, options?: {
priority?: number;
label?: string;
}): void;
onSpecLoaded(callback: (spec: unknown) => void): void;
getContext(): PluginContext;
on(eventName: string, callback: (data: unknown) => void): void;
off(eventName: string, callback: (data: unknown) => void): void;
emit(eventName: string, data: unknown): void;
}
//# sourceMappingURL=types.d.ts.map