grpc-resilient 1.0.0 → 1.1.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.
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Gateway gRPC Client Types
3
+ *
4
+ * Type definitions for API Gateway/Proxy gRPC client infrastructure.
5
+ * Designed for services that act as reverse proxies to multiple backend services.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /**
10
+ * Connection state for gateway clients
11
+ * @category Gateway
12
+ */
13
+ export var GatewayConnectionState;
14
+ (function (GatewayConnectionState) {
15
+ /** Not connected to the backend service */
16
+ GatewayConnectionState["DISCONNECTED"] = "DISCONNECTED";
17
+ /** Initial connection attempt in progress */
18
+ GatewayConnectionState["CONNECTING"] = "CONNECTING";
19
+ /** Successfully connected and ready */
20
+ GatewayConnectionState["CONNECTED"] = "CONNECTED";
21
+ /** Reconnecting after connection loss */
22
+ GatewayConnectionState["RECONNECTING"] = "RECONNECTING";
23
+ })(GatewayConnectionState || (GatewayConnectionState = {}));
24
+ /**
25
+ * Default configuration values for gateway clients
26
+ * @category Gateway
27
+ */
28
+ export const GATEWAY_DEFAULT_CONFIG = {
29
+ timeoutMs: 5000,
30
+ retryCount: 3,
31
+ retryDelayMs: 1000,
32
+ maxReconnectAttempts: Infinity,
33
+ maxReconnectDelayMs: 30000,
34
+ initialReconnectDelayMs: 1000,
35
+ useTls: false,
36
+ keepaliveTimeMs: 30000,
37
+ keepaliveTimeoutMs: 10000,
38
+ };
39
+ /**
40
+ * Default metrics values
41
+ * @category Gateway
42
+ */
43
+ export const GATEWAY_DEFAULT_METRICS = {
44
+ totalCalls: 0,
45
+ successfulCalls: 0,
46
+ failedCalls: 0,
47
+ totalRetries: 0,
48
+ avgLatencyMs: 0,
49
+ maxLatencyMs: 0,
50
+ minLatencyMs: Infinity,
51
+ lastResetAt: new Date(),
52
+ };
53
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/gateway/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;GAGG;AACH,MAAM,CAAN,IAAY,sBASX;AATD,WAAY,sBAAsB;IAChC,2CAA2C;IAC3C,uDAA6B,CAAA;IAC7B,6CAA6C;IAC7C,mDAAyB,CAAA;IACzB,uCAAuC;IACvC,iDAAuB,CAAA;IACvB,yCAAyC;IACzC,uDAA6B,CAAA;AAC/B,CAAC,EATW,sBAAsB,KAAtB,sBAAsB,QASjC;AA8ID;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,CAAC;IACb,YAAY,EAAE,IAAI;IAClB,oBAAoB,EAAE,QAAQ;IAC9B,mBAAmB,EAAE,KAAK;IAC1B,uBAAuB,EAAE,IAAI;IAC7B,MAAM,EAAE,KAAK;IACb,eAAe,EAAE,KAAK;IACtB,kBAAkB,EAAE,KAAK;CACjB,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAyB;IAC3D,UAAU,EAAE,CAAC;IACb,eAAe,EAAE,CAAC;IAClB,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,QAAQ;IACtB,WAAW,EAAE,IAAI,IAAI,EAAE;CACxB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -49,4 +49,5 @@ export { createGrpcClient, type ProtoConfig } from './ProtoLoader.js';
49
49
  export { executeGrpcCall, getClientMethod, mapGrpcError, isRetryableError, isConnectionError, sleep, type CallConfig, type CallMetadata, } from './CallExecutor.js';
50
50
  export { fastHash, generateCacheKey } from './utils.js';
51
51
  export { ConnectionState, DEFAULT_CONFIG, DEFAULT_METRICS, type GrpcLogger, type ResilientClientConfig, type CallOptions, type ClientHealth, type ClientMetrics, type CacheEntry, } from './types.js';
52
+ export * as gateway from './gateway/index.js';
52
53
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,eAAe,EACf,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,EACL,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGxD,OAAO,EACL,eAAe,EACf,cAAc,EACd,eAAe,EACf,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,eAAe,EACf,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,EACL,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGxD,OAAO,EACL,eAAe,EACf,cAAc,EACd,eAAe,EACf,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AAIpB,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -53,4 +53,7 @@ export { executeGrpcCall, getClientMethod, mapGrpcError, isRetryableError, isCon
53
53
  export { fastHash, generateCacheKey } from './utils.js';
54
54
  // Types
55
55
  export { ConnectionState, DEFAULT_CONFIG, DEFAULT_METRICS, } from './types.js';
56
+ // Gateway module (for API Gateways/Proxies)
57
+ // Import from 'grpc-resilient/gateway' for better tree-shaking
58
+ export * as gateway from './gateway/index.js';
56
59
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,cAAc;AACd,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,qBAAqB;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAyB,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAoB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,eAAe,EACf,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,GAGN,MAAM,mBAAmB,CAAC;AAE3B,YAAY;AACZ,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAExD,QAAQ;AACR,OAAO,EACL,eAAe,EACf,cAAc,EACd,eAAe,GAOhB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,cAAc;AACd,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,qBAAqB;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAyB,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAoB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,eAAe,EACf,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,GAGN,MAAM,mBAAmB,CAAC;AAE3B,YAAY;AACZ,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAExD,QAAQ;AACR,OAAO,EACL,eAAe,EACf,cAAc,EACd,eAAe,GAOhB,MAAM,YAAY,CAAC;AAEpB,4CAA4C;AAC5C,+DAA+D;AAC/D,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "grpc-resilient",
3
- "version": "1.0.0",
4
- "description": "Production-ready gRPC client with retry, reconnection, fallback cache, and metrics for Node.js",
3
+ "version": "1.1.0",
4
+ "description": "Production-ready gRPC client with retry, reconnection, fallback cache, and metrics for Node.js microservices and API gateways",
5
5
  "author": "berkeerdo",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -11,6 +11,10 @@
11
11
  ".": {
12
12
  "import": "./dist/index.js",
13
13
  "types": "./dist/index.d.ts"
14
+ },
15
+ "./gateway": {
16
+ "import": "./dist/gateway/index.js",
17
+ "types": "./dist/gateway/index.d.ts"
14
18
  }
15
19
  },
16
20
  "files": [
@@ -27,6 +31,12 @@
27
31
  "circuit-breaker",
28
32
  "fallback-cache",
29
33
  "microservices",
34
+ "api-gateway",
35
+ "gateway",
36
+ "proxy",
37
+ "bff",
38
+ "tls",
39
+ "mtls",
30
40
  "typescript",
31
41
  "nodejs",
32
42
  "grpc-js"
@@ -64,8 +74,8 @@
64
74
  "lru-cache": "^11.0.0"
65
75
  },
66
76
  "peerDependencies": {
67
- "@grpc/grpc-js": "^1.9.0 || ^1.10.0 || ^1.11.0 || ^1.12.0 || ^1.13.0 || ^1.14.0",
68
- "@grpc/proto-loader": "^0.7.0"
77
+ "@grpc/grpc-js": ">=1.9.0",
78
+ "@grpc/proto-loader": ">=0.7.0"
69
79
  },
70
80
  "devDependencies": {
71
81
  "@commitlint/cli": "^19.0.0",