@rayondigital/nest-dapr 0.9.35 → 0.9.37
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,11 @@ 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): Promise<void>;
|
|
21
|
-
publish(name: string, producerId: string, topic: string, payload: any, buffer: boolean, metadata?: any): Promise<void>;
|
|
22
|
-
publish(producerId: string, topic: string, payload: any, buffer: boolean, metadata?: any): 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
23
|
publish(producerId: string, topic: string, payload: any): Promise<void>;
|
|
24
|
-
publishBulk(name: string, producerId: string, topic: string, payloads: any[], metadata?: any): Promise<void>;
|
|
25
|
-
publishBulk(producerId: string, topic: string, payloads: any[], metadata?: any): Promise<void>;
|
|
24
|
+
publishBulk(name: string, producerId: string, topic: string, payloads: any[], metadata?: any, contentType?: string): Promise<void>;
|
|
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
27
|
}
|
|
@@ -84,10 +84,11 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
84
84
|
}));
|
|
85
85
|
}
|
|
86
86
|
publishBulkDirectly(messages) {
|
|
87
|
+
var _a;
|
|
87
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
89
|
if (messages.length === 1) {
|
|
89
90
|
const message = messages[0];
|
|
90
|
-
yield this.publishDirectly(message.name, message.topic, message.payload, message.producerId, message.metadata);
|
|
91
|
+
yield this.publishDirectly(message.name, message.topic, message.payload, message.producerId, message.metadata, false, message.contentType);
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
93
94
|
const grouped = messages.reduce((acc, message) => {
|
|
@@ -102,11 +103,12 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
102
103
|
const [name, topic, producerId] = key.split(':');
|
|
103
104
|
const messages = grouped[key];
|
|
104
105
|
if (messages.length === 1) {
|
|
105
|
-
yield this.publishDirectly(name, topic, messages[0].payload, producerId, messages[0].metadata);
|
|
106
|
+
yield this.publishDirectly(name, topic, messages[0].payload, producerId, messages[0].metadata, false, messages[0].contentType);
|
|
106
107
|
continue;
|
|
107
108
|
}
|
|
108
109
|
try {
|
|
109
|
-
|
|
110
|
+
const contentType = (_a = messages[0].contentType) !== null && _a !== void 0 ? _a : 'application/json';
|
|
111
|
+
yield this.daprClient.pubsub.publishBulk(name, topic, messages.map((m) => m.payload), producerId ? { metadata: { partitionKey: producerId }, contentType } : undefined);
|
|
110
112
|
}
|
|
111
113
|
catch (error) {
|
|
112
114
|
yield this.handleError(messages, error);
|
|
@@ -114,12 +116,16 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
114
116
|
}
|
|
115
117
|
});
|
|
116
118
|
}
|
|
117
|
-
publishDirectly(name, topic, payload, producerId, metadata, fireAndForget = false) {
|
|
119
|
+
publishDirectly(name, topic, payload, producerId, metadata, fireAndForget = false, contentType) {
|
|
118
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
119
121
|
try {
|
|
120
122
|
if (!name)
|
|
121
123
|
name = this.defaultName;
|
|
122
|
-
|
|
124
|
+
if (!contentType)
|
|
125
|
+
contentType = 'application/json';
|
|
126
|
+
const options = {
|
|
127
|
+
contentType,
|
|
128
|
+
};
|
|
123
129
|
if (metadata) {
|
|
124
130
|
options['metadata'] = metadata;
|
|
125
131
|
}
|
|
@@ -128,7 +134,12 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
128
134
|
}
|
|
129
135
|
if (fireAndForget) {
|
|
130
136
|
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
131
|
-
|
|
137
|
+
try {
|
|
138
|
+
yield this.daprClient.pubsub.publish(name, topic, payload, options);
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
yield this.handleError([{ producerId, name, topic, payload, metadata }], error);
|
|
142
|
+
}
|
|
132
143
|
}));
|
|
133
144
|
return;
|
|
134
145
|
}
|
|
@@ -147,20 +158,23 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
147
158
|
let payload;
|
|
148
159
|
let buffer;
|
|
149
160
|
let metadata;
|
|
150
|
-
|
|
151
|
-
|
|
161
|
+
let contentType;
|
|
162
|
+
if (args.length === 7) {
|
|
163
|
+
[name, producerId, topic, payload, buffer, metadata, contentType] = args;
|
|
152
164
|
}
|
|
153
165
|
else {
|
|
154
|
-
[producerId, topic, payload, buffer, metadata] = args;
|
|
166
|
+
[producerId, topic, payload, buffer, metadata, contentType] = args;
|
|
155
167
|
name = this.defaultName;
|
|
156
168
|
}
|
|
157
169
|
if (!name)
|
|
158
170
|
name = this.defaultName;
|
|
171
|
+
if (!contentType)
|
|
172
|
+
contentType = 'application/json';
|
|
159
173
|
if (buffer === undefined || buffer) {
|
|
160
|
-
this.buffer.next({ name, producerId, topic, payload, metadata });
|
|
174
|
+
this.buffer.next({ name, producerId, topic, payload, metadata, contentType });
|
|
161
175
|
return;
|
|
162
176
|
}
|
|
163
|
-
yield this.publishDirectly(name, topic, payload, producerId, true);
|
|
177
|
+
yield this.publishDirectly(name, topic, payload, producerId, metadata, true, contentType);
|
|
164
178
|
});
|
|
165
179
|
}
|
|
166
180
|
publishBulk(...args) {
|
|
@@ -170,25 +184,28 @@ let DaprPubSubClient = DaprPubSubClient_1 = class DaprPubSubClient {
|
|
|
170
184
|
let topic;
|
|
171
185
|
let payloads;
|
|
172
186
|
let metadata;
|
|
173
|
-
|
|
174
|
-
|
|
187
|
+
let contentType;
|
|
188
|
+
if (args.length === 6) {
|
|
189
|
+
[name, producerId, topic, payloads, metadata, contentType] = args;
|
|
175
190
|
}
|
|
176
|
-
else if (args.length ===
|
|
177
|
-
[producerId, topic, payloads, metadata] = args;
|
|
191
|
+
else if (args.length === 5) {
|
|
192
|
+
[producerId, topic, payloads, metadata, contentType] = args;
|
|
178
193
|
name = this.defaultName;
|
|
179
194
|
}
|
|
180
|
-
else
|
|
195
|
+
else {
|
|
181
196
|
[producerId, topic, payloads] = args;
|
|
182
197
|
name = this.defaultName;
|
|
183
198
|
}
|
|
184
199
|
if (!name)
|
|
185
200
|
name = this.defaultName;
|
|
201
|
+
if (!contentType)
|
|
202
|
+
contentType = 'application/json';
|
|
186
203
|
if (payloads.length === 1) {
|
|
187
|
-
yield this.publishDirectly(name, topic, payloads[0], producerId, metadata);
|
|
204
|
+
yield this.publishDirectly(name, topic, payloads[0], producerId, metadata, true, contentType);
|
|
188
205
|
return;
|
|
189
206
|
}
|
|
190
207
|
for (const payload of payloads) {
|
|
191
|
-
this.buffer.next({ name, producerId, topic, payload, metadata });
|
|
208
|
+
this.buffer.next({ name, producerId, topic, payload, metadata, contentType });
|
|
192
209
|
}
|
|
193
210
|
});
|
|
194
211
|
}
|
package/package.json
CHANGED