@rayondigital/nest-dapr 0.9.29 → 0.9.30

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.
@@ -3,4 +3,4 @@ export interface DaprPubSubMetadata {
3
3
  topicName: string;
4
4
  route?: string;
5
5
  }
6
- export declare const DaprPubSub: (name: string, topicName: string, route?: string) => MethodDecorator;
6
+ export declare const DaprPubSub: (options: DaprPubSubMetadata) => MethodDecorator;
@@ -3,9 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DaprPubSub = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const constants_1 = require("./constants");
6
- const DaprPubSub = (name, topicName, route) => (0, common_1.SetMetadata)(constants_1.DAPR_PUBSUB_METADATA, {
7
- name,
8
- topicName,
9
- route,
10
- });
6
+ const DaprPubSub = (options) => (0, common_1.SetMetadata)(constants_1.DAPR_PUBSUB_METADATA, options);
11
7
  exports.DaprPubSub = DaprPubSub;
@@ -127,14 +127,17 @@ let DaprLoader = DaprLoader_1 = class DaprLoader {
127
127
  }));
128
128
  }
129
129
  subscribeToDaprPubSubEventIfListener(instance, methodKey) {
130
+ var _a, _b;
130
131
  return __awaiter(this, void 0, void 0, function* () {
131
132
  const daprPubSubMetadata = this.daprMetadataAccessor.getDaprPubSubHandlerMetadata(instance[methodKey]);
132
133
  if (!daprPubSubMetadata) {
133
134
  return;
134
135
  }
135
- const { name, topicName, route } = daprPubSubMetadata;
136
+ const name = (_a = daprPubSubMetadata.name) !== null && _a !== void 0 ? _a : (_b = this.options.pubsubOptions) === null || _b === void 0 ? void 0 : _b.defaultName;
137
+ const { topicName, route } = daprPubSubMetadata;
136
138
  this.logger.log(`Subscribing to Dapr: ${name}, Topic: ${topicName}${route ? ' on route ' + route : ''}`);
137
139
  yield this.daprServer.pubsub.subscribe(name, topicName, (data) => __awaiter(this, void 0, void 0, function* () {
140
+ var _c, _d;
138
141
  try {
139
142
  const result = yield instance[methodKey].call(instance, data);
140
143
  if (result && result in dapr_1.DaprPubSubStatusEnum) {
@@ -144,8 +147,8 @@ let DaprLoader = DaprLoader_1 = class DaprLoader {
144
147
  }
145
148
  catch (err) {
146
149
  this.logger.error(err, `Error in pubsub handler ${topicName}`);
147
- if (this.options.onPubSubError) {
148
- const response = this.options.onPubSubError(name, topicName, err);
150
+ if ((_c = this.options.pubsubOptions) === null || _c === void 0 ? void 0 : _c.onError) {
151
+ const response = (_d = this.options.pubsubOptions) === null || _d === void 0 ? void 0 : _d.onError(name, topicName, err);
149
152
  if (response == dapr_1.DaprPubSubStatusEnum.RETRY) {
150
153
  this.logger.log(`Retrying pubsub handler ${topicName} operation`);
151
154
  }
@@ -7,8 +7,8 @@ export interface DaprModuleOptions {
7
7
  serverPort?: string;
8
8
  communicationProtocol?: CommunicationProtocolEnum;
9
9
  clientOptions?: DaprClientOptions;
10
- onPubSubError?: (name: string, topicName: string, error: any) => DaprPubSubStatusEnum;
11
10
  actorOptions?: DaprModuleActorOptions;
11
+ pubsubOptions?: DaprModulePubSubOptions;
12
12
  disabled?: boolean;
13
13
  contextProvider?: DaprContextProvider;
14
14
  catchErrors?: boolean;
@@ -19,6 +19,10 @@ export interface DaprModuleActorOptions {
19
19
  typeNamePrefix?: string;
20
20
  allowInternalCalls?: boolean;
21
21
  }
22
+ export interface DaprModulePubSubOptions {
23
+ defaultName?: string;
24
+ onError?: (name: string, topicName: string, error: any) => DaprPubSubStatusEnum;
25
+ }
22
26
  export declare enum DaprContextProvider {
23
27
  None = "none",
24
28
  ALS = "als",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rayondigital/nest-dapr",
3
- "version": "0.9.29",
3
+ "version": "0.9.30",
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",