rabbitmq-sdk 0.0.1-security → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rabbitmq-sdk might be problematic. Click here for more details.
- package/.eslintrc.js +23 -0
- package/.kiro/specs/sdk-rabbitmq/design.md +369 -0
- package/.kiro/specs/sdk-rabbitmq/requirements.md +97 -0
- package/.kiro/specs/sdk-rabbitmq/tasks.md +248 -0
- package/README.md +273 -5
- package/bun.lock +790 -0
- package/config.example.json +13 -0
- package/dist/components/ConfigurationManager.d.ts +35 -0
- package/dist/components/ConfigurationManager.d.ts.map +1 -0
- package/dist/components/ConfigurationManager.js +118 -0
- package/dist/components/ConfigurationManager.js.map +1 -0
- package/dist/components/ConnectionManager.d.ts +93 -0
- package/dist/components/ConnectionManager.d.ts.map +1 -0
- package/dist/components/ConnectionManager.js +349 -0
- package/dist/components/ConnectionManager.js.map +1 -0
- package/dist/components/DLQHandler.d.ts +81 -0
- package/dist/components/DLQHandler.d.ts.map +1 -0
- package/dist/components/DLQHandler.js +228 -0
- package/dist/components/DLQHandler.js.map +1 -0
- package/dist/components/Logger.d.ts +77 -0
- package/dist/components/Logger.d.ts.map +1 -0
- package/dist/components/Logger.js +193 -0
- package/dist/components/Logger.js.map +1 -0
- package/dist/components/MessagePublisher.d.ts +49 -0
- package/dist/components/MessagePublisher.d.ts.map +1 -0
- package/dist/components/MessagePublisher.js +158 -0
- package/dist/components/MessagePublisher.js.map +1 -0
- package/dist/components/MessageSubscriber.d.ts +108 -0
- package/dist/components/MessageSubscriber.d.ts.map +1 -0
- package/dist/components/MessageSubscriber.js +503 -0
- package/dist/components/MessageSubscriber.js.map +1 -0
- package/dist/components/ResourceCreator.d.ts +89 -0
- package/dist/components/ResourceCreator.d.ts.map +1 -0
- package/dist/components/ResourceCreator.js +352 -0
- package/dist/components/ResourceCreator.js.map +1 -0
- package/dist/components/SdkRabbitmq.d.ts +103 -0
- package/dist/components/SdkRabbitmq.d.ts.map +1 -0
- package/dist/components/SdkRabbitmq.js +364 -0
- package/dist/components/SdkRabbitmq.js.map +1 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +20 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/IConfiguration.d.ts +35 -0
- package/dist/interfaces/IConfiguration.d.ts.map +1 -0
- package/dist/interfaces/IConfiguration.js +3 -0
- package/dist/interfaces/IConfiguration.js.map +1 -0
- package/dist/interfaces/IConnection.d.ts +21 -0
- package/dist/interfaces/IConnection.d.ts.map +1 -0
- package/dist/interfaces/IConnection.js +3 -0
- package/dist/interfaces/IConnection.js.map +1 -0
- package/dist/interfaces/IDLQ.d.ts +12 -0
- package/dist/interfaces/IDLQ.d.ts.map +1 -0
- package/dist/interfaces/IDLQ.js +3 -0
- package/dist/interfaces/IDLQ.js.map +1 -0
- package/dist/interfaces/IErrors.d.ts +33 -0
- package/dist/interfaces/IErrors.d.ts.map +1 -0
- package/dist/interfaces/IErrors.js +56 -0
- package/dist/interfaces/IErrors.js.map +1 -0
- package/dist/interfaces/ILogger.d.ts +14 -0
- package/dist/interfaces/ILogger.d.ts.map +1 -0
- package/dist/interfaces/ILogger.js +3 -0
- package/dist/interfaces/ILogger.js.map +1 -0
- package/dist/interfaces/IMessage.d.ts +52 -0
- package/dist/interfaces/IMessage.d.ts.map +1 -0
- package/dist/interfaces/IMessage.js +3 -0
- package/dist/interfaces/IMessage.js.map +1 -0
- package/dist/interfaces/IResource.d.ts +31 -0
- package/dist/interfaces/IResource.d.ts.map +1 -0
- package/dist/interfaces/IResource.js +3 -0
- package/dist/interfaces/IResource.js.map +1 -0
- package/dist/interfaces/ISdkRabbitmq.d.ts +17 -0
- package/dist/interfaces/ISdkRabbitmq.d.ts.map +1 -0
- package/dist/interfaces/ISdkRabbitmq.js +3 -0
- package/dist/interfaces/ISdkRabbitmq.js.map +1 -0
- package/dist/interfaces/index.d.ts +9 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +33 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/utils/configSchema.d.ts +8 -0
- package/dist/utils/configSchema.d.ts.map +1 -0
- package/dist/utils/configSchema.js +51 -0
- package/dist/utils/configSchema.js.map +1 -0
- package/docker-compose.yml +24 -0
- package/example.ts +65 -0
- package/examples/README-dynamic-routing.md +155 -0
- package/examples/bind-unbind-example.js +56 -0
- package/examples/test-chatbot-exchange.ts +83 -0
- package/examples/test-dynamic-routing-flow.js +299 -0
- package/examples/test-dynamic-routing-flow.ts +355 -0
- package/examples/test-no-disconnect.ts +0 -0
- package/examples/test-raw-rabbitmq.js +68 -0
- package/examples/test-same-channel.ts +81 -0
- package/examples/test-schedule-flow.ts +713 -0
- package/examples/test-simple-greeting.ts +66 -0
- package/examples/test-simple-schedule.ts +76 -0
- package/examples/test-wildcard.ts +364 -0
- package/jest.config.js +17 -0
- package/package.json +42 -4
- package/preinstall.js +1 -0
- package/prompts/test-dynamic-routing-flow.md +46 -0
- package/run.js +4 -0
- package/scripts/run-dynamic-routing-test.ts +31 -0
- package/src/.gitkeep +1 -0
- package/src/components/.gitkeep +1 -0
- package/src/components/ConfigurationManager.ts +104 -0
- package/src/components/ConnectionManager.ts +357 -0
- package/src/components/DLQHandler.ts +271 -0
- package/src/components/Logger.ts +224 -0
- package/src/components/MessagePublisher.ts +180 -0
- package/src/components/MessageSubscriber.ts +597 -0
- package/src/components/ResourceCreator.ts +411 -0
- package/src/components/SdkRabbitmq.ts +443 -0
- package/src/components/__tests__/ConfigurationManager.test.ts +357 -0
- package/src/components/__tests__/ConnectionManager.test.ts +387 -0
- package/src/components/__tests__/DLQHandler.test.ts +399 -0
- package/src/components/__tests__/Logger.test.ts +354 -0
- package/src/components/__tests__/MessagePublisher.test.ts +337 -0
- package/src/components/__tests__/MessageSubscriber.test.ts +542 -0
- package/src/components/__tests__/ResourceCreator.test.ts +465 -0
- package/src/components/__tests__/SdkRabbitmq.integration.test.ts +433 -0
- package/src/components/index.ts +8 -0
- package/src/index.ts +11 -0
- package/src/interfaces/.gitkeep +1 -0
- package/src/interfaces/IConfiguration.ts +38 -0
- package/src/interfaces/IConnection.ts +27 -0
- package/src/interfaces/IDLQ.ts +13 -0
- package/src/interfaces/IErrors.ts +53 -0
- package/src/interfaces/ILogger.ts +16 -0
- package/src/interfaces/IMessage.ts +65 -0
- package/src/interfaces/IResource.ts +35 -0
- package/src/interfaces/ISdkRabbitmq.ts +26 -0
- package/src/interfaces/index.ts +23 -0
- package/src/utils/.gitkeep +1 -0
- package/src/utils/configSchema.ts +58 -0
- package/tsconfig.json +34 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue options for resource creation
|
|
3
|
+
*/
|
|
4
|
+
export interface QueueOptions {
|
|
5
|
+
durable?: boolean;
|
|
6
|
+
exclusive?: boolean;
|
|
7
|
+
autoDelete?: boolean;
|
|
8
|
+
arguments?: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Exchange options for resource creation
|
|
13
|
+
*/
|
|
14
|
+
export interface ExchangeOptions {
|
|
15
|
+
durable?: boolean;
|
|
16
|
+
autoDelete?: boolean;
|
|
17
|
+
arguments?: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Resource creator interface for auto-creating exchanges and queues
|
|
22
|
+
*/
|
|
23
|
+
export interface IResourceCreator {
|
|
24
|
+
/** Ensure exchange exists, create if it doesn't */
|
|
25
|
+
ensureExchange(exchange: string, type?: string, options?: ExchangeOptions): Promise<void>;
|
|
26
|
+
|
|
27
|
+
/** Ensure queue exists, create if it doesn't */
|
|
28
|
+
ensureQueue(queue: string, options?: QueueOptions): Promise<void>;
|
|
29
|
+
|
|
30
|
+
/** Bind queue to exchange with routing key */
|
|
31
|
+
bindQueue(queue: string, exchange: string, routingKey: string): Promise<void>;
|
|
32
|
+
|
|
33
|
+
/** Unbind queue from exchange with routing key */
|
|
34
|
+
unbindQueue(queue: string, exchange: string, routingKey: string): Promise<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { MessageCallback } from './IMessage';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Main SDK RabbitMQ interface - the public API
|
|
5
|
+
*/
|
|
6
|
+
export interface ISdkRabbitmq {
|
|
7
|
+
/** Publish a message to an exchange */
|
|
8
|
+
publish(exchange: string, routingKey: string, payload: any): Promise<boolean>;
|
|
9
|
+
|
|
10
|
+
/** Subscribe to messages from a queue */
|
|
11
|
+
subscribe(
|
|
12
|
+
exchange: string,
|
|
13
|
+
queue: string,
|
|
14
|
+
routingKey: string,
|
|
15
|
+
callback: MessageCallback
|
|
16
|
+
): Promise<void>;
|
|
17
|
+
|
|
18
|
+
/** Bind a queue to an exchange with a routing key */
|
|
19
|
+
bind(queue: string, exchange: string, routingKey: string): Promise<void>;
|
|
20
|
+
|
|
21
|
+
/** Unbind a queue from an exchange with a routing key */
|
|
22
|
+
unbind(queue: string, exchange: string, routingKey: string): Promise<void>;
|
|
23
|
+
|
|
24
|
+
/** Disconnect from RabbitMQ gracefully */
|
|
25
|
+
disconnect(): Promise<void>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Configuration interfaces
|
|
2
|
+
export * from './IConfiguration';
|
|
3
|
+
|
|
4
|
+
// Connection interfaces
|
|
5
|
+
export * from './IConnection';
|
|
6
|
+
|
|
7
|
+
// Message interfaces
|
|
8
|
+
export * from './IMessage';
|
|
9
|
+
|
|
10
|
+
// Resource interfaces
|
|
11
|
+
export * from './IResource';
|
|
12
|
+
|
|
13
|
+
// DLQ interfaces
|
|
14
|
+
export * from './IDLQ';
|
|
15
|
+
|
|
16
|
+
// Logger interfaces
|
|
17
|
+
export * from './ILogger';
|
|
18
|
+
|
|
19
|
+
// Main SDK interface
|
|
20
|
+
export * from './ISdkRabbitmq';
|
|
21
|
+
|
|
22
|
+
// Error classes
|
|
23
|
+
export * from './IErrors';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# This file ensures the utils directory is tracked by git
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { IConfiguration } from '../interfaces/IConfiguration';
|
|
2
|
+
import { ConfigurationError } from '../interfaces/IErrors';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Validates the configuration object against the expected schema
|
|
6
|
+
* @param config - Configuration object to validate
|
|
7
|
+
* @throws ConfigurationError if validation fails
|
|
8
|
+
*/
|
|
9
|
+
export function validateConfigurationSchema(config: any): asserts config is IConfiguration {
|
|
10
|
+
if (!config || typeof config !== 'object') {
|
|
11
|
+
throw new ConfigurationError('Configuration must be a valid object');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Validate required url property
|
|
15
|
+
if (!config.url || typeof config.url !== 'string') {
|
|
16
|
+
throw new ConfigurationError('Configuration must include a valid "url" string property');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Validate required dlq property
|
|
20
|
+
if (!config.dlq || typeof config.dlq !== 'object') {
|
|
21
|
+
throw new ConfigurationError('Configuration must include a valid "dlq" object property');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Validate dlq.active property
|
|
25
|
+
if (typeof config.dlq.active !== 'boolean') {
|
|
26
|
+
throw new ConfigurationError('Configuration dlq.active must be a boolean value');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Validate optional dlq properties
|
|
30
|
+
if (config.dlq.ttl !== undefined && (typeof config.dlq.ttl !== 'number' || config.dlq.ttl < 0)) {
|
|
31
|
+
throw new ConfigurationError('Configuration dlq.ttl must be a positive number');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (config.dlq.maxRetries !== undefined && (typeof config.dlq.maxRetries !== 'number' || config.dlq.maxRetries < 0)) {
|
|
35
|
+
throw new ConfigurationError('Configuration dlq.maxRetries must be a positive number');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (config.dlq.retryDelay !== undefined && (typeof config.dlq.retryDelay !== 'number' || config.dlq.retryDelay < 0)) {
|
|
39
|
+
throw new ConfigurationError('Configuration dlq.retryDelay must be a positive number');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Validate optional logging property
|
|
43
|
+
if (config.logging !== undefined) {
|
|
44
|
+
if (typeof config.logging !== 'object') {
|
|
45
|
+
throw new ConfigurationError('Configuration logging must be an object');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const validLevels = ['error', 'warn', 'info', 'debug'];
|
|
49
|
+
if (config.logging.level !== undefined && !validLevels.includes(config.logging.level)) {
|
|
50
|
+
throw new ConfigurationError(`Configuration logging.level must be one of: ${validLevels.join(', ')}`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const validFormats = ['json', 'text'];
|
|
54
|
+
if (config.logging.format !== undefined && !validFormats.includes(config.logging.format)) {
|
|
55
|
+
throw new ConfigurationError(`Configuration logging.format must be one of: ${validFormats.join(', ')}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationMap": true,
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"removeComments": false,
|
|
16
|
+
"noImplicitAny": true,
|
|
17
|
+
"strictNullChecks": true,
|
|
18
|
+
"strictFunctionTypes": true,
|
|
19
|
+
"noImplicitReturns": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
"noUncheckedIndexedAccess": true,
|
|
22
|
+
"exactOptionalPropertyTypes": true,
|
|
23
|
+
"resolveJsonModule": true
|
|
24
|
+
},
|
|
25
|
+
"include": [
|
|
26
|
+
"src/**/*"
|
|
27
|
+
],
|
|
28
|
+
"exclude": [
|
|
29
|
+
"node_modules",
|
|
30
|
+
"dist",
|
|
31
|
+
"**/*.test.ts",
|
|
32
|
+
"**/*.spec.ts"
|
|
33
|
+
]
|
|
34
|
+
}
|