@rayondigital/nest-dapr 0.9.63 → 0.9.64

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.
@@ -64,7 +64,11 @@ class ActorProxyBuilder {
64
64
  return __awaiter(this, void 0, void 0, function* () {
65
65
  const actorManager = this.actorRuntimeService.getActorManager(actorTypeClassName);
66
66
  const requestBody = JSON.stringify(args);
67
- return yield actorManager.invoke(actorId, methodName, Buffer.from(requestBody));
67
+ const result = yield actorManager.invoke(actorId, methodName, Buffer.from(requestBody));
68
+ if (serializable_error_1.SerializableError.isSerializableError(result)) {
69
+ throw serializable_error_1.SerializableError.fromJSON(result);
70
+ }
71
+ return result;
68
72
  });
69
73
  }
70
74
  callExternalActorMethod(actorTypeClassName, actorId, methodName, args) {
@@ -78,7 +82,10 @@ class ActorProxyBuilder {
78
82
  const body = yield this.prepareBody(this.daprContextService, args, originalBody);
79
83
  const result = yield this.actorClient.actor.invoke(actorTypeClassName, actorId, methodName, body, correlationId, traceId);
80
84
  if (serializable_error_1.SerializableError.isSerializableError(result)) {
81
- throw serializable_error_1.SerializableError.fromJSON(result);
85
+ const error = serializable_error_1.SerializableError.fromJSON(result);
86
+ error.correlationId = correlationId;
87
+ error.traceId = traceId;
88
+ throw error;
82
89
  }
83
90
  return result;
84
91
  });
@@ -161,10 +161,10 @@ let NestActorManager = NestActorManager_1 = class NestActorManager {
161
161
  actor_1.default.prototype.handlerMethod = function (req, res) {
162
162
  var _a;
163
163
  return __awaiter(this, void 0, void 0, function* () {
164
- const { actorTypeName, actorId, methodName } = req.params;
165
- const body = req.body;
166
- const dataSerialized = this.serializer.serialize(body);
167
164
  try {
165
+ const { actorTypeName, actorId, methodName } = req.params;
166
+ const body = req.body;
167
+ const dataSerialized = this.serializer.serialize(body);
168
168
  const result = yield ActorRuntime_1.default.getInstance(this.client.daprClient).invoke(actorTypeName, actorId, methodName, dataSerialized);
169
169
  res.statusCode = HttpStatusCode_enum_1.default.OK;
170
170
  return this.handleResult(res, result);
@@ -1,11 +1,17 @@
1
1
  export declare class SerializableError extends Error {
2
2
  statusCode: number;
3
3
  $type: string;
4
+ correlationId?: string;
5
+ traceId?: string;
4
6
  constructor(message: string, statusCode?: number);
5
7
  toJSON(): {
6
8
  name: string;
7
9
  message: string;
8
10
  statusCode: number;
11
+ correlationId: string;
12
+ traceId: string;
13
+ stack: string;
14
+ $type: string;
9
15
  };
10
16
  static fromJSON(json: any): SerializableError;
11
17
  static isSerializableError(error: any): error is SerializableError;
@@ -1,21 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SerializableError = void 0;
4
+ const serializableErrorTypeName = 'SerializableError';
4
5
  class SerializableError extends Error {
5
6
  constructor(message, statusCode = 400) {
6
7
  super(message);
7
8
  this.statusCode = statusCode;
8
- this.$type = 'SerializableError';
9
+ this.$type = serializableErrorTypeName;
9
10
  }
10
11
  toJSON() {
12
+ if (!this.stack) {
13
+ Error.captureStackTrace(this, SerializableError);
14
+ }
11
15
  return {
12
16
  name: this.name,
13
17
  message: this.message,
14
18
  statusCode: this.statusCode,
19
+ correlationId: this.correlationId,
20
+ traceId: this.traceId,
21
+ stack: this.stack,
22
+ $type: serializableErrorTypeName,
15
23
  };
16
24
  }
17
25
  static fromJSON(json) {
18
- return new SerializableError(json.message, json.statusCode);
26
+ var _a;
27
+ const error = new SerializableError(json.message, json.statusCode);
28
+ error.$type = (_a = json.$type) !== null && _a !== void 0 ? _a : serializableErrorTypeName;
29
+ error.correlationId = json.correlationId;
30
+ error.traceId = json.traceId;
31
+ error.stack = json.stack;
32
+ error.name = json.name;
33
+ return error;
19
34
  }
20
35
  static isSerializableError(error) {
21
36
  if (error instanceof SerializableError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rayondigital/nest-dapr",
3
- "version": "0.9.63",
3
+ "version": "0.9.64",
4
4
  "description": "Develop NestJs microservices using Dapr pubsub, actors and other bindings",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",