@naman_deep_singh/communication-core 1.2.0 → 1.2.2

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @naman_deep_singh/communication-core
2
2
 
3
- **Version** - 1.2.0
3
+ **Version** - 1.2.2
4
4
 
5
5
  > Core interfaces and abstract classes for building a comprehensive service-to-service communication layer in TypeScript
6
6
 
@@ -88,17 +88,20 @@ This core package enables building 5 specialized subpackages:
88
88
  communication-protocols/
89
89
  ├── src/
90
90
  │ ├── http/
91
- │ │ ├── HttpProtocol.ts # extends BaseProtocol
92
- │ │ ├── HttpConnectionPool.ts # extends BaseConnectionPool
93
- │ │ └── HttpInterceptor.ts # implements IInterceptor
91
+ │ │ ├── HTTPProtocol.ts # extends BaseProtocol
92
+ │ │ ├── HTTPConnectionPool.ts # extends BaseConnectionPool
93
+ │ │ └── HTTPInterceptor.ts # implements BaseInterceptor
94
+ | | └── index.ts
94
95
  │ ├── grpc/
95
- │ │ ├── GrpcProtocol.ts # extends BaseProtocol
96
- │ │ ├── GrpcConnectionPool.ts # extends BaseConnectionPool
97
- │ │ └── GrpcInterceptor.ts # implements IInterceptor
96
+ │ │ ├── GRPCProtocol.ts # extends BaseProtocol
97
+ │ │ ├── GRPCConnectionPool.ts # extends BaseConnectionPool
98
+ │ │ └── GRPCInterceptor.ts # implements IInterceptor
99
+ | | └── index.ts
98
100
  │ ├── websocket/
99
101
  │ │ ├── WebSocketProtocol.ts # extends BaseProtocol
100
102
  │ │ ├── WebSocketConnectionPool.ts
101
103
  │ │ └── WebSocketInterceptor.ts
104
+ | | └── index.ts
102
105
  │ └── index.ts
103
106
  ├── package.json
104
107
  └── README.md
@@ -108,8 +111,8 @@ communication-protocols/
108
111
 
109
112
  **Usage**:
110
113
  ```typescript
111
- import { HttpProtocol } from '@naman_deep_singh/communication-protocols/http';
112
- import { GrpcProtocol } from '@naman_deep_singh/communication-protocols/grpc';
114
+ import { HTTPProtocol } from '@naman_deep_singh/communication-protocols/http';
115
+ import { GRPCProtocol } from '@naman_deep_singh/communication-protocols/grpc';
113
116
  ```
114
117
 
115
118
  ### 2. **@naman_deep_singh/communication-resilience**
@@ -123,14 +126,17 @@ communication-resilience/
123
126
  │ │ ├── CircuitBreakerImpl.ts # implements ICircuitBreaker
124
127
  │ │ ├── CircuitBreakerState.ts # State management
125
128
  │ │ └── CircuitBreakerMetrics.ts # Failure tracking
129
+ | | └── index.ts
126
130
  │ ├── retry/
127
131
  │ │ ├── ExponentialBackoffRetry.ts # implements IRetryStrategy
128
132
  │ │ ├── LinearBackoffRetry.ts # implements IRetryStrategy
129
133
  │ │ ├── FixedDelayRetry.ts # implements IRetryStrategy
130
134
  │ │ └── JitterRetry.ts # implements IRetryStrategy
135
+ | | └── index.ts
131
136
  │ ├── policies/
132
137
  │ │ ├── RetryPolicy.ts
133
138
  │ │ └── CircuitBreakerPolicy.ts
139
+ | | └── index.ts
134
140
  │ └── index.ts
135
141
  ├── package.json
136
142
  └── README.md
@@ -153,16 +159,20 @@ communication-discovery/
153
159
  │ │ ├── ConsulServiceDiscoverer.ts # extends BaseServiceDiscoverer
154
160
  │ │ ├── ConsulHealthChecker.ts
155
161
  │ │ └── ConsulWatcher.ts
162
+ | | └── index.ts
156
163
  │ ├── etcd/
157
164
  │ │ ├── EtcdServiceDiscoverer.ts # extends BaseServiceDiscoverer
158
165
  │ │ ├── EtcdHealthChecker.ts
159
166
  │ │ └── EtcdWatcher.ts
167
+ | | └── index.ts
160
168
  │ ├── kubernetes/
161
169
  │ │ ├── K8sServiceDiscoverer.ts # extends BaseServiceDiscoverer
162
170
  │ │ ├── K8sHealthChecker.ts
163
171
  │ │ └── K8sWatcher.ts
172
+ | | └── index.ts
164
173
  │ ├── static/
165
174
  │ │ └── StaticServiceDiscoverer.ts # For testing/development
175
+ | | └── index.ts
166
176
  │ └── index.ts
167
177
  ├── package.json
168
178
  └── README.md
@@ -189,12 +199,15 @@ communication-load-balancing/
189
199
  │ │ ├── LeastConnectionsStrategy.ts # implements ILoadBalanceStrategy
190
200
  │ │ ├── RandomStrategy.ts # implements ILoadBalanceStrategy
191
201
  │ │ └── ConsistentHashStrategy.ts # implements ILoadBalanceStrategy
202
+ | | └── index.ts
192
203
  │ ├── health/
193
204
  │ │ ├── HealthAwareLoadBalancer.ts
194
205
  │ │ └── HealthScorer.ts
206
+ | | └── index.ts
195
207
  │ ├── metrics/
196
208
  │ │ ├── LoadBalancerMetrics.ts
197
209
  │ │ └── ConnectionTracker.ts
210
+ | | └── index.ts
198
211
  │ └── index.ts
199
212
  ├── package.json
200
213
  └── README.md
@@ -217,18 +230,22 @@ communication-client/
217
230
  │ │ ├── CommunicationClient.ts # implements IClient
218
231
  │ │ ├── ClientFactory.ts # implements IClientFactory
219
232
  │ │ └── ClientBuilder.ts # Fluent builder pattern
233
+ | | └── index.ts
220
234
  │ ├── pipeline/
221
235
  │ │ ├── RequestPipeline.ts
222
236
  │ │ ├── ResponsePipeline.ts
223
237
  │ │ └── InterceptorChain.ts
238
+ | | └── index.ts
224
239
  │ ├── middleware/
225
240
  │ │ ├── LoggingInterceptor.ts
226
241
  │ │ ├── MetricsInterceptor.ts
227
242
  │ │ ├── TracingInterceptor.ts
228
243
  │ │ └── AuthInterceptor.ts
244
+ | | └── index.ts
229
245
  │ ├── events/
230
246
  │ │ ├── ClientEventEmitter.ts
231
247
  │ │ └── ClientEvents.ts
248
+ | | └── index.ts
232
249
  │ └── index.ts
233
250
  ├── package.json
234
251
  └── README.md
@@ -240,7 +257,7 @@ import { CommunicationClient, ClientBuilder } from '@naman_deep_singh/communicat
240
257
 
241
258
  // Fluent builder pattern
242
259
  const client = new ClientBuilder()
243
- .withProtocol(new HttpProtocol())
260
+ .withProtocol(new HTTPProtocol())
244
261
  .withServiceDiscovery(new ConsulServiceDiscoverer(consulConfig))
245
262
  .withLoadBalancer(new RoundRobinStrategy())
246
263
  .withCircuitBreaker(new CircuitBreakerImpl(cbConfig))
@@ -251,7 +268,7 @@ const client = new ClientBuilder()
251
268
  ## Development Roadmap
252
269
 
253
270
  ### Phase 1: Protocols Foundation (Week 1-2)
254
- - Implement `HttpProtocol` with connection pooling
271
+ - Implement `HTTPProtocol` with connection pooling
255
272
  - Add basic interceptor support
256
273
  - Create comprehensive tests
257
274
 
@@ -291,7 +308,7 @@ import {
291
308
  // Implementations come from subpackages:
292
309
 
293
310
  // From communication-protocols
294
- const protocol: IProtocol = new HttpProtocol({
311
+ const protocol: IProtocol = new HTTPProtocol({
295
312
  timeout: 5000,
296
313
  maxConnections: 100
297
314
  });
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * HTTP methods
7
7
  */
8
- export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
8
+ export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
9
9
  /**
10
10
  * Protocol types supported
11
11
  */
@@ -148,7 +148,7 @@ export interface BaseProtocolConfig {
148
148
  /**
149
149
  * HTTP protocol configuration
150
150
  */
151
- export interface HttpProtocolConfig extends BaseProtocolConfig {
151
+ export interface HTTPProtocolConfig extends BaseProtocolConfig {
152
152
  /** Base URL */
153
153
  baseUrl?: string;
154
154
  /** Default headers */
@@ -167,7 +167,7 @@ export interface HttpProtocolConfig extends BaseProtocolConfig {
167
167
  /**
168
168
  * gRPC protocol configuration
169
169
  */
170
- export interface GrpcProtocolConfig extends BaseProtocolConfig {
170
+ export interface GRPCProtocolConfig extends BaseProtocolConfig {
171
171
  /** gRPC endpoint */
172
172
  endpoint: string;
173
173
  /** Use SSL/TLS */
@@ -2,8 +2,8 @@
2
2
  * Type definitions for communication layer
3
3
  * @packageDocumentation
4
4
  */
5
- export type { HttpMethod, ProtocolType, ServiceDiscoveryType, LoadBalanceStrategy, CircuitBreakerState, BackoffStrategy, SerializationFormat, LogLevel, ClientConfig, ServiceDiscoveryConfig, LoadBalancingConfig, ResilienceConfig, CircuitBreakerConfig, RetryPolicyConfig, TimeoutConfig, BulkheadConfig, FallbackConfig, ConnectionPoolConfig, CompressionConfig, RateLimitConfig, BaseProtocolConfig, HttpProtocolConfig, GrpcProtocolConfig, WebSocketProtocolConfig, InterceptorConfig, SerializationConfig, LoggingConfig, MetricsConfig, CacheConfig, } from './config.js';
6
- export type { BaseRequest, HttpRequest, GrpcRequest, WebSocketRequest, RetryConfig, CircuitBreakerRequestConfig, Request, RequestOptions, RequestContext, } from './request.js';
7
- export type { BaseResponse, HttpResponse, GrpcResponse, WebSocketResponse, ErrorResponse, PaginatedResponse, StreamResponse, Response, } from './response.js';
5
+ export type { HTTPMethod, ProtocolType, ServiceDiscoveryType, LoadBalanceStrategy, CircuitBreakerState, BackoffStrategy, SerializationFormat, LogLevel, ClientConfig, ServiceDiscoveryConfig, LoadBalancingConfig, ResilienceConfig, CircuitBreakerConfig, RetryPolicyConfig, TimeoutConfig, BulkheadConfig, FallbackConfig, ConnectionPoolConfig, CompressionConfig, RateLimitConfig, BaseProtocolConfig, HTTPProtocolConfig, GRPCProtocolConfig, WebSocketProtocolConfig, InterceptorConfig, SerializationConfig, LoggingConfig, MetricsConfig, CacheConfig, } from './config.js';
6
+ export type { BaseRequest, HTTPRequest, GRPCRequest, WebSocketRequest, RetryConfig, CircuitBreakerRequestConfig, Request, RequestOptions, RequestContext, } from './request.js';
7
+ export type { BaseResponse, HTTPResponse, GRPCResponse, WebSocketResponse, ErrorResponse, PaginatedResponse, StreamResponse, Response, } from './response.js';
8
8
  export type { ServiceInstance, ServiceRegistration, WatchCallback, UnwatchFunction, HealthCheckResult, ServiceEndpoint, ServiceDependency, ServiceMetrics, ServiceRegistryConfig, ServiceInstanceFilter, ServiceDiscoveryResult, } from './service.js';
9
9
  export type { BaseEvent, CircuitBreakerEvent, RetryEvent, ServiceDiscoveryEvent, LoadBalancingEvent, ProtocolEvent, ConnectionEvent, MetricsEvent, CacheEvent, InterceptorEvent, CommunicationEvent, EventListener, EventEmitter, } from './events.js';
@@ -2,7 +2,7 @@
2
2
  * Request types and interfaces for communication layer
3
3
  * @packageDocumentation
4
4
  */
5
- import type { HttpMethod } from './config.js';
5
+ import type { HTTPMethod } from './config.js';
6
6
  /**
7
7
  * Base request interface for all protocols
8
8
  */
@@ -25,9 +25,9 @@ export interface BaseRequest {
25
25
  /**
26
26
  * HTTP-specific request
27
27
  */
28
- export interface HttpRequest extends BaseRequest {
28
+ export interface HTTPRequest extends BaseRequest {
29
29
  /** HTTP method */
30
- method: HttpMethod;
30
+ method: HTTPMethod;
31
31
  /** Request URL */
32
32
  url: string;
33
33
  /** Request body */
@@ -42,7 +42,7 @@ export interface HttpRequest extends BaseRequest {
42
42
  /**
43
43
  * gRPC-specific request
44
44
  */
45
- export interface GrpcRequest extends BaseRequest {
45
+ export interface GRPCRequest extends BaseRequest {
46
46
  /** gRPC service name */
47
47
  service: string;
48
48
  /** gRPC method name */
@@ -102,7 +102,7 @@ export interface CircuitBreakerRequestConfig {
102
102
  /**
103
103
  * Union type of all request types
104
104
  */
105
- export type Request = HttpRequest | GrpcRequest | WebSocketRequest;
105
+ export type Request = HTTPRequest | GRPCRequest | WebSocketRequest;
106
106
  /**
107
107
  * Request options for client calls
108
108
  */
@@ -2,7 +2,7 @@
2
2
  * Response types and interfaces for communication layer
3
3
  * @packageDocumentation
4
4
  */
5
- import type { HttpStatusCode } from '@naman_deep_singh/http-response';
5
+ import { HTTPStatusCode } from "@naman_deep_singh/http-response";
6
6
  /**
7
7
  * Base response interface for all protocols
8
8
  */
@@ -29,9 +29,9 @@ export interface BaseResponse<T = unknown> {
29
29
  /**
30
30
  * HTTP-specific response
31
31
  */
32
- export interface HttpResponse<T = unknown> extends BaseResponse<T> {
32
+ export interface HTTPResponse<T = unknown> extends BaseResponse<T> {
33
33
  /** HTTP status code */
34
- status: HttpStatusCode;
34
+ status: HTTPStatusCode;
35
35
  /** Response URL */
36
36
  url: string;
37
37
  /** Redirected URL if any */
@@ -44,7 +44,7 @@ export interface HttpResponse<T = unknown> extends BaseResponse<T> {
44
44
  /**
45
45
  * gRPC-specific response
46
46
  */
47
- export interface GrpcResponse<T = unknown> extends BaseResponse<T> {
47
+ export interface GRPCResponse<T = unknown> extends BaseResponse<T> {
48
48
  /** gRPC status code */
49
49
  grpcCode: number;
50
50
  /** gRPC status message */
@@ -152,4 +152,4 @@ export interface StreamResponse<T = unknown> {
152
152
  /**
153
153
  * Union type of all response types
154
154
  */
155
- export type Response<T = unknown> = HttpResponse<T> | GrpcResponse<T> | WebSocketResponse<T>;
155
+ export type Response<T = unknown> = HTTPResponse<T> | GRPCResponse<T> | WebSocketResponse<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naman_deep_singh/communication-core",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Core interfaces and abstract classes for building a comprehensive service-to-service communication layer with protocols, resilience patterns, service discovery, and load balancing",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -71,9 +71,9 @@
71
71
  "typescript": "^5.9.3"
72
72
  },
73
73
  "dependencies": {
74
- "@naman_deep_singh/errors": "^2.3.1",
75
- "@naman_deep_singh/http-response": "^3.3.2",
76
- "@naman_deep_singh/utils": "^2.6.2",
74
+ "@naman_deep_singh/errors": "^2.3.4",
75
+ "@naman_deep_singh/http-response": "^3.3.4",
76
+ "@naman_deep_singh/utils": "^2.6.4",
77
77
  "@types/node": "^25.0.1"
78
78
  },
79
79
  "publishConfig": {
@@ -83,6 +83,6 @@
83
83
  "build": "pnpm run build:types && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json",
84
84
  "build:types": "tsc -p tsconfig.types.json",
85
85
  "clean": "rimraf dist",
86
- "clean:js": "find src -type f -name \"*.js\" -delete"
86
+ "clean:js": "find src -type f -name '*.js' -delete"
87
87
  }
88
88
  }