@lakutata/nats 1.5.0 → 1.5.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/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.5.2](https://github.com/lakutata/lakutata-packages/compare/@lakutata/nats@1.5.1...@lakutata/nats@1.5.2) (2026-01-11)
7
+
8
+ **Note:** Version bump only for package @lakutata/nats
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.5.1](https://github.com/lakutata/lakutata-packages/compare/@lakutata/nats@1.5.0...@lakutata/nats@1.5.1) (2025-12-28)
15
+
16
+ **Note:** Version bump only for package @lakutata/nats
17
+
18
+
19
+
20
+
21
+
6
22
  # [1.5.0](https://github.com/lakutata/lakutata-packages/compare/@lakutata/nats@1.4.0...@lakutata/nats@1.5.0) (2025-12-27)
7
23
 
8
24
 
@@ -5,7 +5,7 @@ const helper_1 = require("lakutata/helper");
5
5
  function MessagePackCodec() {
6
6
  return {
7
7
  encode(d) {
8
- return helper_1.MessagePack.encode([d]);
8
+ return helper_1.MessagePack.encode(JSON.parse(JSON.stringify([d])));
9
9
  },
10
10
  decode(a) {
11
11
  const [res] = helper_1.MessagePack.decode(a);
@@ -1,5 +1,6 @@
1
1
  import { Exception } from 'lakutata';
2
2
  export declare class ServiceInvokeException extends Exception {
3
3
  errno: string | number;
4
+ service?: string;
4
5
  }
5
6
  //# sourceMappingURL=ServiceInvokeException.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceInvokeException.d.ts","sourceRoot":"","sources":["../../src/exceptions/ServiceInvokeException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAA;AAElC,qBAAa,sBAAuB,SAAQ,SAAS;IAC1C,KAAK,EAAE,MAAM,GAAG,MAAM,CAAqB;CACrD"}
1
+ {"version":3,"file":"ServiceInvokeException.d.ts","sourceRoot":"","sources":["../../src/exceptions/ServiceInvokeException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAA;AAElC,qBAAa,sBAAuB,SAAQ,SAAS;IAC1C,KAAK,EAAE,MAAM,GAAG,MAAM,CAAqB;IAE3C,OAAO,CAAC,EAAC,MAAM,CAAA;CACzB"}
@@ -14,8 +14,9 @@ export declare class ServiceResponseCodec {
14
14
  /**
15
15
  * Decode service response
16
16
  * @param response
17
+ * @param serviceId
17
18
  */
18
- static decode(response: ServiceResponse): any;
19
+ static decode(response: ServiceResponse, serviceId?: string): any;
19
20
  }
20
21
  export {};
21
22
  //# sourceMappingURL=ServiceResponseCodec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceResponseCodec.d.ts","sourceRoot":"","sources":["../../src/lib/ServiceResponseCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAA;AAGlC,UAAU,eAAe;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI,CAAA;IACxC,QAAQ,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAAA;CAC/B;AAED,qBAAa,oBAAoB;IAC7B;;;;OAIG;WACW,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,GAAG,eAAe;IAYlE;;;OAGG;WACW,MAAM,CAAC,QAAQ,EAAE,eAAe,GAAG,GAAG;CAQvD"}
1
+ {"version":3,"file":"ServiceResponseCodec.d.ts","sourceRoot":"","sources":["../../src/lib/ServiceResponseCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAA;AAGlC,UAAU,eAAe;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI,CAAA;IACxC,QAAQ,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAAA;CAC/B;AAED,qBAAa,oBAAoB;IAC7B;;;;OAIG;WACW,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,GAAG,eAAe;IAYlE;;;;OAIG;WACW,MAAM,CAAC,QAAQ,EAAE,eAAe,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,GAAG;CAS3E"}
@@ -22,11 +22,14 @@ class ServiceResponseCodec {
22
22
  /**
23
23
  * Decode service response
24
24
  * @param response
25
+ * @param serviceId
25
26
  */
26
- static decode(response) {
27
+ static decode(response, serviceId) {
27
28
  if (!response.success) {
28
29
  const remoteError = response.error;
29
30
  const serviceInvokeException = new ServiceInvokeException_1.ServiceInvokeException(remoteError.message || 'Unknown Error');
31
+ if (serviceId)
32
+ serviceInvokeException.service = serviceId;
30
33
  throw Object.assign(serviceInvokeException, response.error);
31
34
  }
32
35
  return response.payload;
@@ -44,7 +44,7 @@ let ServiceProxy = class ServiceProxy extends lakutata_1.Provider {
44
44
  */
45
45
  async invoke(input, timeout = 60 * 60 * 1000) {
46
46
  const response = await this.nats.request(this.serviceId, input, timeout);
47
- return ServiceResponseCodec_1.ServiceResponseCodec.decode(response);
47
+ return ServiceResponseCodec_1.ServiceResponseCodec.decode(response, this.serviceId);
48
48
  }
49
49
  /**
50
50
  * On service event
@@ -52,11 +52,11 @@ class TestComponent extends lakutata_1.Component {
52
52
  this.self.on('testEvt', handler2);
53
53
  // this.nats.onServiceEvent(this.app.appId, 'testEvt', handler1)
54
54
  // this.nats.onServiceEvent(this.app.appId, 'testEvt', handler2)
55
- setInterval(() => {
56
- this.nats.emitServiceEvent('testEvt', 123, 456);
57
- }, 1000);
55
+ // setInterval(() => {
56
+ // this.nats.emitServiceEvent('testEvt', 123, 456)
57
+ // }, 1000)
58
58
  try {
59
- console.log(await this.self.invoke({ test: true }));
59
+ console.log(await this.self.invoke({ test: true, start: new Date() }));
60
60
  }
61
61
  catch (e) {
62
62
  // console.error(JSON.parse(JSON.stringify(e)))
@@ -78,6 +78,7 @@ __decorate([
78
78
  ], TestComponent.prototype, "self", void 0);
79
79
  class TestController extends entrypoint_1.Controller {
80
80
  async test(inp) {
81
+ console.log(inp);
81
82
  // throw new Error('fuck')
82
83
  // throw new NatsForbiddenException('fuck')
83
84
  // return 'hahahah'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lakutata/nats",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "Lakutata NATS Client",
5
5
  "keywords": [
6
6
  "lakutata",
@@ -32,5 +32,5 @@
32
32
  "lakutata": "^2.0.117",
33
33
  "nats": "^2.29.3"
34
34
  },
35
- "gitHead": "1ea372cfbee322cc6d5bd88152af90d654442ab8"
35
+ "gitHead": "7b37eadf0960460f5a8624709ab5c4bc6032f531"
36
36
  }