@rayondigital/nest-dapr 0.9.38 → 0.9.39
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.
|
@@ -17,11 +17,12 @@ 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(name: string, topic: string, payload: any, producerId?: string, metadata?: any, fireAndForget?: boolean, contentType?: string): Promise<void>;
|
|
21
|
-
publish(name: string, producerId: string, topic: string, payload: any, buffer: boolean, metadata?: any, contentType?: string): Promise<void>;
|
|
22
|
-
publish(producerId: string, topic: string, payload: any, buffer: boolean, metadata?: any, contentType?: string): Promise<void>;
|
|
23
|
-
publish(producerId: string, topic: string, payload: any): Promise<void>;
|
|
20
|
+
protected publishDirectly(id: string, name: string, topic: string, payload: any, producerId?: string, metadata?: any, fireAndForget?: boolean, contentType?: string): Promise<void>;
|
|
21
|
+
publish(id: string, name: string, producerId: string, topic: string, payload: any, buffer: boolean, metadata?: any, contentType?: string): Promise<void>;
|
|
22
|
+
publish(id: string, producerId: string, topic: string, payload: any, buffer: boolean, metadata?: any, contentType?: string): Promise<void>;
|
|
23
|
+
publish(id: string, producerId: string, topic: string, payload: any): Promise<void>;
|
|
24
24
|
publishBulk(name: string, producerId: string, topic: string, payloads: any[], metadata?: any, contentType?: string): Promise<void>;
|
|
25
25
|
publishBulk(producerId: string, topic: string, payloads: any[], metadata?: any, contentType?: string): Promise<void>;
|
|
26
26
|
publishBulk(producerId: string, topic: string, payloads: any[]): Promise<void>;
|
|
27
|
+
private getMessageId;
|
|
27
28
|
}
|
|
@@ -20,6 +20,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
var DaprPubSubClient_1;
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.DaprPubSubClient = void 0;
|
|
23
|
+
const crypto_1 = require("crypto");
|
|
23
24
|
const dapr_1 = require("@dapr/dapr");
|
|
24
25
|
const common_1 = require("@nestjs/common");
|
|
25
26
|
const rxjs_1 = require("rxjs");
|
|
@@ -88,7 +89,7 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
88
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
90
|
if (messages.length === 1) {
|
|
90
91
|
const message = messages[0];
|
|
91
|
-
yield this.publishDirectly(message.name, message.topic, message.payload, message.producerId, message.metadata, false, message.contentType);
|
|
92
|
+
yield this.publishDirectly(message.id, message.name, message.topic, message.payload, message.producerId, message.metadata, false, message.contentType);
|
|
92
93
|
return;
|
|
93
94
|
}
|
|
94
95
|
const grouped = messages.reduce((acc, message) => {
|
|
@@ -112,7 +113,9 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
112
113
|
if (response.failedMessages) {
|
|
113
114
|
const failedMessages = response.failedMessages.map((m, i) => {
|
|
114
115
|
var _a;
|
|
116
|
+
const messageId = this.getMessageId(m.message.event, m.message.entryID);
|
|
115
117
|
return {
|
|
118
|
+
id: messageId,
|
|
116
119
|
name,
|
|
117
120
|
topic,
|
|
118
121
|
payload: m.message.event,
|
|
@@ -129,7 +132,7 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
129
132
|
}
|
|
130
133
|
});
|
|
131
134
|
}
|
|
132
|
-
publishDirectly(name, topic, payload, producerId, metadata, fireAndForget = false, contentType) {
|
|
135
|
+
publishDirectly(id, name, topic, payload, producerId, metadata, fireAndForget = false, contentType) {
|
|
133
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
137
|
try {
|
|
135
138
|
if (!name)
|
|
@@ -154,7 +157,7 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
154
157
|
}
|
|
155
158
|
}
|
|
156
159
|
catch (error) {
|
|
157
|
-
yield this.handleError([{ producerId, name, topic, payload, metadata }], error);
|
|
160
|
+
yield this.handleError([{ id: id !== null && id !== void 0 ? id : (0, crypto_1.randomUUID)(), producerId, name, topic, payload, metadata }], error);
|
|
158
161
|
}
|
|
159
162
|
}));
|
|
160
163
|
return;
|
|
@@ -165,12 +168,13 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
165
168
|
}
|
|
166
169
|
}
|
|
167
170
|
catch (error) {
|
|
168
|
-
yield this.handleError([{ producerId, name, topic, payload, metadata }], error);
|
|
171
|
+
yield this.handleError([{ id: id !== null && id !== void 0 ? id : (0, crypto_1.randomUUID)(), producerId, name, topic, payload, metadata }], error);
|
|
169
172
|
}
|
|
170
173
|
});
|
|
171
174
|
}
|
|
172
175
|
publish(...args) {
|
|
173
176
|
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
let id;
|
|
174
178
|
let name;
|
|
175
179
|
let producerId;
|
|
176
180
|
let topic;
|
|
@@ -178,11 +182,11 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
178
182
|
let buffer;
|
|
179
183
|
let metadata;
|
|
180
184
|
let contentType;
|
|
181
|
-
if (args.length ===
|
|
182
|
-
[name, producerId, topic, payload, buffer, metadata, contentType] = args;
|
|
185
|
+
if (args.length === 8) {
|
|
186
|
+
[id, name, producerId, topic, payload, buffer, metadata, contentType] = args;
|
|
183
187
|
}
|
|
184
188
|
else {
|
|
185
|
-
[producerId, topic, payload, buffer, metadata, contentType] = args;
|
|
189
|
+
[id, producerId, topic, payload, buffer, metadata, contentType] = args;
|
|
186
190
|
name = this.defaultName;
|
|
187
191
|
}
|
|
188
192
|
if (!name)
|
|
@@ -190,10 +194,10 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
190
194
|
if (!contentType)
|
|
191
195
|
contentType = 'application/json';
|
|
192
196
|
if (buffer === undefined || buffer) {
|
|
193
|
-
this.buffer.next({ name, producerId, topic, payload, metadata, contentType });
|
|
197
|
+
this.buffer.next({ id: id !== null && id !== void 0 ? id : (0, crypto_1.randomUUID)(), name, producerId, topic, payload, metadata, contentType });
|
|
194
198
|
return;
|
|
195
199
|
}
|
|
196
|
-
yield this.publishDirectly(name, topic, payload, producerId, metadata, true, contentType);
|
|
200
|
+
yield this.publishDirectly(id !== null && id !== void 0 ? id : (0, crypto_1.randomUUID)(), name, topic, payload, producerId, metadata, true, contentType);
|
|
197
201
|
});
|
|
198
202
|
}
|
|
199
203
|
publishBulk(...args) {
|
|
@@ -220,14 +224,27 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
220
224
|
if (!contentType)
|
|
221
225
|
contentType = 'application/json';
|
|
222
226
|
if (payloads.length === 1) {
|
|
223
|
-
|
|
227
|
+
const messageId = this.getMessageId(payloads[0]);
|
|
228
|
+
yield this.publishDirectly(messageId, name, topic, payloads[0], producerId, metadata, true, contentType);
|
|
224
229
|
return;
|
|
225
230
|
}
|
|
226
231
|
for (const payload of payloads) {
|
|
227
|
-
this.buffer.next({
|
|
232
|
+
this.buffer.next({
|
|
233
|
+
id: this.getMessageId(payloads),
|
|
234
|
+
name,
|
|
235
|
+
producerId,
|
|
236
|
+
topic,
|
|
237
|
+
payload,
|
|
238
|
+
metadata,
|
|
239
|
+
contentType,
|
|
240
|
+
});
|
|
228
241
|
}
|
|
229
242
|
});
|
|
230
243
|
}
|
|
244
|
+
getMessageId(payload, defaultValue) {
|
|
245
|
+
var _a, _b, _c, _d;
|
|
246
|
+
return (_d = (_c = (_b = (_a = payload.id) !== null && _a !== void 0 ? _a : payload.messageId) !== null && _b !== void 0 ? _b : payload.correlationId) !== null && _c !== void 0 ? _c : defaultValue) !== null && _d !== void 0 ? _d : (0, crypto_1.randomUUID)();
|
|
247
|
+
}
|
|
231
248
|
};
|
|
232
249
|
DaprPubSubClient = DaprPubSubClient_1 = __decorate([
|
|
233
250
|
(0, common_1.Injectable)(),
|
package/package.json
CHANGED