@rayondigital/nest-dapr 0.9.47 → 0.9.49
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.
|
@@ -68,7 +68,7 @@ let NestActorManager = NestActorManager_1 = class NestActorManager {
|
|
|
68
68
|
setupReentrancy() {
|
|
69
69
|
ActorClientHTTP_1.default.prototype.invoke = function (actorType, actorId, methodName, body, reentrancyId) {
|
|
70
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const urlSafeId =
|
|
71
|
+
const urlSafeId = actorId.getURLSafeId();
|
|
72
72
|
const result = yield this.client.execute(`/actors/${actorType}/${urlSafeId}/method/${methodName}`, {
|
|
73
73
|
method: 'POST',
|
|
74
74
|
body,
|
|
@@ -17,12 +17,8 @@ export declare class DaprPubSubClient implements OnApplicationShutdown {
|
|
|
17
17
|
onApplicationShutdown(signal?: string): Promise<void>;
|
|
18
18
|
protected setupBufferSubscription(): void;
|
|
19
19
|
protected publishBulkDirectly(messages: PublishMessage[]): Promise<void>;
|
|
20
|
-
protected publishDirectly(
|
|
21
|
-
publish(
|
|
22
|
-
|
|
23
|
-
publish(id: string, producerId: string, topic: string, payload: any): Promise<boolean>;
|
|
24
|
-
publishBulk(name: string, producerId: string, topic: string, payloads: any[], metadata?: any, contentType?: string): Promise<boolean>;
|
|
25
|
-
publishBulk(producerId: string, topic: string, payloads: any[], metadata?: any, contentType?: string): Promise<boolean>;
|
|
26
|
-
publishBulk(producerId: string, topic: string, payloads: any[]): Promise<boolean>;
|
|
20
|
+
protected publishDirectly(pubSubName: string, topic: string, payload: any, producerId?: string, metadata?: any, fireAndForget?: boolean, contentType?: string): Promise<boolean>;
|
|
21
|
+
publish(pubSubName: string, producerId: string, topic: string, payload: any, buffer?: boolean, metadata?: any, contentType?: string): Promise<boolean>;
|
|
22
|
+
publishBulk(pubSubName: string, producerId: string, topic: string, payloads: any[], metadata?: any, contentType?: string): Promise<boolean>;
|
|
27
23
|
private getMessageId;
|
|
28
24
|
}
|
|
@@ -89,11 +89,11 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
89
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
90
|
if (messages.length === 1) {
|
|
91
91
|
const message = messages[0];
|
|
92
|
-
yield this.publishDirectly(message.
|
|
92
|
+
yield this.publishDirectly(message.pubSubName, message.topic, message.payload, message.producerId, message.metadata, false, message.contentType);
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
95
|
const grouped = messages.reduce((acc, message) => {
|
|
96
|
-
const key = `${message.
|
|
96
|
+
const key = `${message.pubSubName}:${message.topic}:${message.producerId}`;
|
|
97
97
|
if (!acc[key]) {
|
|
98
98
|
acc[key] = [];
|
|
99
99
|
}
|
|
@@ -101,23 +101,21 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
101
101
|
return acc;
|
|
102
102
|
}, {});
|
|
103
103
|
for (const key in grouped) {
|
|
104
|
-
const [
|
|
104
|
+
const [pubSubName, topic, producerId] = key.split(':');
|
|
105
105
|
const messages = grouped[key];
|
|
106
106
|
if (messages.length === 1) {
|
|
107
|
-
yield this.publishDirectly(
|
|
107
|
+
yield this.publishDirectly(pubSubName, topic, messages[0].payload, producerId, messages[0].metadata, false, messages[0].contentType);
|
|
108
108
|
continue;
|
|
109
109
|
}
|
|
110
110
|
try {
|
|
111
111
|
const contentType = (_a = messages[0].contentType) !== null && _a !== void 0 ? _a : 'application/json';
|
|
112
|
-
const response = yield this.daprClient.pubsub.publishBulk(
|
|
112
|
+
const response = yield this.daprClient.pubsub.publishBulk(pubSubName, topic, messages.map((m) => m.payload), producerId ? { metadata: { partitionKey: producerId }, contentType } : undefined);
|
|
113
113
|
if (response !== undefined && response.failedMessages && response.failedMessages.length > 0) {
|
|
114
114
|
const error = (_c = (_b = response.failedMessages[0]) === null || _b === void 0 ? void 0 : _b.error) !== null && _c !== void 0 ? _c : new Error('Unable to publish message');
|
|
115
|
-
const failedMessages = response.failedMessages.map((m
|
|
115
|
+
const failedMessages = response.failedMessages.map((m) => {
|
|
116
116
|
var _a;
|
|
117
|
-
const messageId = this.getMessageId(m.message.event, m.message.entryID);
|
|
118
117
|
return {
|
|
119
|
-
|
|
120
|
-
name,
|
|
118
|
+
pubSubName: pubSubName,
|
|
121
119
|
topic,
|
|
122
120
|
payload: m.message.event,
|
|
123
121
|
metadata: m.message.metadata,
|
|
@@ -133,11 +131,11 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
133
131
|
}
|
|
134
132
|
});
|
|
135
133
|
}
|
|
136
|
-
publishDirectly(
|
|
134
|
+
publishDirectly(pubSubName, topic, payload, producerId, metadata, fireAndForget = false, contentType) {
|
|
137
135
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
136
|
try {
|
|
139
|
-
if (!
|
|
140
|
-
|
|
137
|
+
if (!pubSubName)
|
|
138
|
+
pubSubName = this.defaultName;
|
|
141
139
|
if (!contentType)
|
|
142
140
|
contentType = 'application/json';
|
|
143
141
|
const options = {
|
|
@@ -152,89 +150,55 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
152
150
|
if (fireAndForget) {
|
|
153
151
|
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
154
152
|
try {
|
|
155
|
-
const response = yield this.daprClient.pubsub.publish(
|
|
153
|
+
const response = yield this.daprClient.pubsub.publish(pubSubName, topic, payload, options);
|
|
156
154
|
if (response !== undefined && response.error) {
|
|
157
155
|
throw response.error;
|
|
158
156
|
}
|
|
159
157
|
}
|
|
160
158
|
catch (error) {
|
|
161
|
-
yield this.handleError([{
|
|
159
|
+
yield this.handleError([{ producerId, pubSubName, topic, payload, metadata }], error);
|
|
162
160
|
return false;
|
|
163
161
|
}
|
|
164
162
|
}));
|
|
165
163
|
return true;
|
|
166
164
|
}
|
|
167
|
-
const response = yield this.daprClient.pubsub.publish(
|
|
165
|
+
const response = yield this.daprClient.pubsub.publish(pubSubName, topic, payload, options);
|
|
168
166
|
if (response !== undefined && response.error) {
|
|
169
167
|
throw response.error;
|
|
170
168
|
}
|
|
171
169
|
return true;
|
|
172
170
|
}
|
|
173
171
|
catch (error) {
|
|
174
|
-
yield this.handleError([{
|
|
172
|
+
yield this.handleError([{ producerId, pubSubName, topic, payload, metadata }], error);
|
|
175
173
|
return false;
|
|
176
174
|
}
|
|
177
175
|
});
|
|
178
176
|
}
|
|
179
|
-
publish(
|
|
177
|
+
publish(pubSubName, producerId, topic, payload, buffer = true, metadata, contentType) {
|
|
180
178
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
let producerId;
|
|
184
|
-
let topic;
|
|
185
|
-
let payload;
|
|
186
|
-
let buffer;
|
|
187
|
-
let metadata;
|
|
188
|
-
let contentType;
|
|
189
|
-
if (args.length === 8) {
|
|
190
|
-
[id, name, producerId, topic, payload, buffer, metadata, contentType] = args;
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
[id, producerId, topic, payload, buffer, metadata, contentType] = args;
|
|
194
|
-
name = this.defaultName;
|
|
195
|
-
}
|
|
196
|
-
if (!name)
|
|
197
|
-
name = this.defaultName;
|
|
179
|
+
if (!pubSubName)
|
|
180
|
+
pubSubName = this.defaultName;
|
|
198
181
|
if (!contentType)
|
|
199
182
|
contentType = 'application/json';
|
|
200
183
|
if (buffer === undefined || buffer) {
|
|
201
|
-
this.buffer.next({
|
|
184
|
+
this.buffer.next({ pubSubName, producerId, topic, payload, metadata, contentType });
|
|
202
185
|
return;
|
|
203
186
|
}
|
|
204
|
-
return yield this.publishDirectly(
|
|
187
|
+
return yield this.publishDirectly(pubSubName, topic, payload, producerId, metadata, true, contentType);
|
|
205
188
|
});
|
|
206
189
|
}
|
|
207
|
-
publishBulk(
|
|
190
|
+
publishBulk(pubSubName, producerId, topic, payloads, metadata, contentType) {
|
|
208
191
|
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
let topic;
|
|
212
|
-
let payloads;
|
|
213
|
-
let metadata;
|
|
214
|
-
let contentType;
|
|
215
|
-
if (args.length === 6) {
|
|
216
|
-
[name, producerId, topic, payloads, metadata, contentType] = args;
|
|
217
|
-
}
|
|
218
|
-
else if (args.length === 5) {
|
|
219
|
-
[producerId, topic, payloads, metadata, contentType] = args;
|
|
220
|
-
name = this.defaultName;
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
[producerId, topic, payloads] = args;
|
|
224
|
-
name = this.defaultName;
|
|
225
|
-
}
|
|
226
|
-
if (!name)
|
|
227
|
-
name = this.defaultName;
|
|
192
|
+
if (!pubSubName)
|
|
193
|
+
pubSubName = this.defaultName;
|
|
228
194
|
if (!contentType)
|
|
229
195
|
contentType = 'application/json';
|
|
230
196
|
if (payloads.length === 1) {
|
|
231
|
-
|
|
232
|
-
return yield this.publishDirectly(messageId, name, topic, payloads[0], producerId, metadata, true, contentType);
|
|
197
|
+
return yield this.publishDirectly(pubSubName, topic, payloads[0], producerId, metadata, true, contentType);
|
|
233
198
|
}
|
|
234
199
|
for (const payload of payloads) {
|
|
235
200
|
this.buffer.next({
|
|
236
|
-
|
|
237
|
-
name,
|
|
201
|
+
pubSubName,
|
|
238
202
|
producerId,
|
|
239
203
|
topic,
|
|
240
204
|
payload,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rayondigital/nest-dapr",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.49",
|
|
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",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"eventemitter2": "^6.0.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@dapr/dapr": "^3.
|
|
32
|
+
"@dapr/dapr": "^3.3.1",
|
|
33
33
|
"async-lock": "^1.4.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|