mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #31060 from RuLeZzz1987/master
added types for `rabbitmq-schema`
This commit is contained in:
Vendored
+71
@@ -0,0 +1,71 @@
|
||||
// Type definitions for rabbitmq-schema 2.0
|
||||
// Project: https://github.com/tjmehta/rabbitmq-schema
|
||||
// Definitions by: Alex Duka <https://github.com/rulezzz1987>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
interface Binding {
|
||||
destination: Exchange | Queue;
|
||||
source: Exchange;
|
||||
args?: object;
|
||||
routingPattern?: string;
|
||||
}
|
||||
|
||||
interface TopicBinding extends Binding {
|
||||
routingPattern: string;
|
||||
}
|
||||
|
||||
interface DirectBinding extends Binding {
|
||||
routingPattern: string;
|
||||
}
|
||||
|
||||
interface Topology {
|
||||
options?: object;
|
||||
}
|
||||
|
||||
interface Exchange extends Topology {
|
||||
exchange: string;
|
||||
type: string;
|
||||
bindings: Binding[];
|
||||
}
|
||||
|
||||
interface FanoutExchange extends Exchange {
|
||||
type: 'fanout';
|
||||
}
|
||||
|
||||
interface TopicExchange extends Exchange {
|
||||
type: 'topic';
|
||||
bindings: TopicBinding[];
|
||||
}
|
||||
|
||||
interface DirectExchange extends Exchange {
|
||||
type: 'direct';
|
||||
bindings: DirectBinding[];
|
||||
}
|
||||
|
||||
interface Queue extends Topology {
|
||||
queue: string;
|
||||
messageSchema: object;
|
||||
}
|
||||
|
||||
declare class RabbitMQSchema {
|
||||
constructor(schema: Topology | Topology[], parentPath?: string);
|
||||
|
||||
getExchanges(): Exchange[];
|
||||
|
||||
getBindings(): Binding[];
|
||||
|
||||
getQueues(): Queue[];
|
||||
|
||||
getDirectBindings(): DirectBinding[];
|
||||
|
||||
validate(schema: Topology | Topology[], parentPath?: string): void;
|
||||
|
||||
validateMessage<T>(exchangeName: string, routingPattern: string, message: T): T;
|
||||
|
||||
getQueueByName(name: string): Queue | void;
|
||||
|
||||
getExchangeByName(name: string): Exchange | void;
|
||||
}
|
||||
|
||||
export = RabbitMQSchema;
|
||||
@@ -0,0 +1,16 @@
|
||||
import RabbitMqSchema = require('rabbitmq-schema');
|
||||
|
||||
const topology = {};
|
||||
|
||||
const rabbitSchema = new RabbitMqSchema({}, '');
|
||||
|
||||
rabbitSchema.getExchanges();
|
||||
rabbitSchema.getBindings();
|
||||
rabbitSchema.getQueues();
|
||||
rabbitSchema.getDirectBindings();
|
||||
|
||||
rabbitSchema.getQueueByName('images.jpeg.get');
|
||||
rabbitSchema.getExchangeByName('images');
|
||||
|
||||
rabbitSchema.validate(topology);
|
||||
rabbitSchema.validateMessage('images', 'images.jpeg.get', {testMsg: 'ok'});
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"strictFunctionTypes": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"rabbitmq-schema-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user