@owox/backend 0.32.0-next-20260819141141 → 0.32.0
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.
|
@@ -24,6 +24,7 @@ export declare class GoogleChatReportWriter extends BaseEmailReportWriter {
|
|
|
24
24
|
protected readonly logger: Logger;
|
|
25
25
|
readonly type = DataDestinationType.GOOGLE_CHAT;
|
|
26
26
|
private googleChatCredentials?;
|
|
27
|
+
private channelEmailRecipients?;
|
|
27
28
|
private usesEmailDelivery;
|
|
28
29
|
constructor(emailProvider: EmailProviderFacade, markdownParser: MarkdownParser, chatPublicOriginService: PublicOriginService, insightTemplateFacade: DataMartInsightTemplateFacadeImpl, eventDispatcher: OwoxEventDispatcher, credentialsResolver: DataDestinationCredentialsResolver, sourceDataService: InsightTemplateSourceDataService, insightTemplateService: InsightTemplateService, sourceUsageService: InsightTemplateSourceUsageService, webhookClient: GoogleChatWebhookClient);
|
|
29
30
|
protected prepareDeliveryCredentials(report: Report): Promise<void>;
|
|
@@ -218,6 +218,7 @@ let GoogleChatReportWriter = GoogleChatReportWriter_1 = class GoogleChatReportWr
|
|
|
218
218
|
logger = new common_1.Logger(GoogleChatReportWriter_1.name);
|
|
219
219
|
type = data_destination_type_enum_1.DataDestinationType.GOOGLE_CHAT;
|
|
220
220
|
googleChatCredentials;
|
|
221
|
+
channelEmailRecipients;
|
|
221
222
|
usesEmailDelivery = false;
|
|
222
223
|
constructor(emailProvider, markdownParser, chatPublicOriginService, insightTemplateFacade, eventDispatcher, credentialsResolver, sourceDataService, insightTemplateService, sourceUsageService, webhookClient) {
|
|
223
224
|
super(emailProvider, markdownParser, chatPublicOriginService, insightTemplateFacade, eventDispatcher, credentialsResolver, sourceDataService, insightTemplateService, sourceUsageService);
|
|
@@ -229,18 +230,29 @@ let GoogleChatReportWriter = GoogleChatReportWriter_1 = class GoogleChatReportWr
|
|
|
229
230
|
const parsed = google_chat_credentials_schema_1.GoogleChatCredentialsSchema.safeParse(resolvedCredentials);
|
|
230
231
|
if (parsed.success) {
|
|
231
232
|
this.googleChatCredentials = parsed.data;
|
|
233
|
+
this.channelEmailRecipients = undefined;
|
|
232
234
|
this.usesEmailDelivery = false;
|
|
233
235
|
return;
|
|
234
236
|
}
|
|
235
|
-
|
|
237
|
+
const emailCredentials = email_credentials_schema_1.EmailCredentialsSchema.safeParse(resolvedCredentials);
|
|
238
|
+
if (!emailCredentials.success) {
|
|
236
239
|
throw new Error('Google Chat destination has neither valid webhook nor channel-email credentials');
|
|
237
240
|
}
|
|
241
|
+
this.googleChatCredentials = undefined;
|
|
242
|
+
this.channelEmailRecipients = emailCredentials.data.to;
|
|
238
243
|
this.usesEmailDelivery = true;
|
|
239
244
|
await super.prepareDeliveryCredentials(report);
|
|
240
245
|
}
|
|
241
246
|
async sendRenderedMessage(markdownContent) {
|
|
242
247
|
if (this.usesEmailDelivery) {
|
|
243
248
|
await super.sendRenderedMessage(markdownContent);
|
|
249
|
+
this.executionLogger?.log({
|
|
250
|
+
type: 'google_chat_sent',
|
|
251
|
+
deliveryMethod: 'channel_email',
|
|
252
|
+
destinationId: this.report.dataDestination.id,
|
|
253
|
+
destinationTitle: this.report.dataDestination.title,
|
|
254
|
+
recipients: this.channelEmailRecipients,
|
|
255
|
+
});
|
|
244
256
|
return;
|
|
245
257
|
}
|
|
246
258
|
if (!this.googleChatCredentials) {
|
|
@@ -253,21 +265,32 @@ let GoogleChatReportWriter = GoogleChatReportWriter_1 = class GoogleChatReportWr
|
|
|
253
265
|
dataMartTitle: this.report.dataMart.title,
|
|
254
266
|
reportUrl,
|
|
255
267
|
});
|
|
268
|
+
const spaceId = new URL(this.googleChatCredentials.webhookUrl).pathname.split('/')[3];
|
|
269
|
+
const deliveryDetails = {
|
|
270
|
+
deliveryMethod: 'incoming_webhook',
|
|
271
|
+
destinationId: this.report.dataDestination.id,
|
|
272
|
+
destinationTitle: this.report.dataDestination.title,
|
|
273
|
+
spaceId,
|
|
274
|
+
};
|
|
256
275
|
for (let index = 0; index < messages.length; index += 1) {
|
|
257
276
|
if (index > 0) {
|
|
258
277
|
await new Promise(resolve => setTimeout(resolve, GOOGLE_CHAT_WRITE_INTERVAL_MS));
|
|
259
278
|
}
|
|
260
279
|
try {
|
|
261
280
|
await this.webhookClient.send(this.googleChatCredentials.webhookUrl, messages[index]);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
281
|
+
if (messages.length > 1) {
|
|
282
|
+
this.executionLogger?.log({
|
|
283
|
+
type: 'google_chat_part_sent',
|
|
284
|
+
...deliveryDetails,
|
|
285
|
+
part: index + 1,
|
|
286
|
+
totalParts: messages.length,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
267
289
|
}
|
|
268
290
|
catch (error) {
|
|
269
291
|
this.executionLogger?.log({
|
|
270
292
|
type: 'google_chat_part_failed',
|
|
293
|
+
...deliveryDetails,
|
|
271
294
|
part: index + 1,
|
|
272
295
|
totalParts: messages.length,
|
|
273
296
|
deliveredParts: index,
|
|
@@ -277,6 +300,7 @@ let GoogleChatReportWriter = GoogleChatReportWriter_1 = class GoogleChatReportWr
|
|
|
277
300
|
}
|
|
278
301
|
this.executionLogger?.log({
|
|
279
302
|
type: 'google_chat_sent',
|
|
303
|
+
...deliveryDetails,
|
|
280
304
|
messageCount: messages.length,
|
|
281
305
|
});
|
|
282
306
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owox/backend",
|
|
3
|
-
"version": "0.32.0
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "OWOX Data Marts Backend - Full-stack data orchestration platform",
|
|
5
5
|
"author": "OWOX",
|
|
6
6
|
"license": "ELv2",
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
"@opentelemetry/exporter-trace-otlp-http": "^0.220.0",
|
|
87
87
|
"@opentelemetry/sdk-trace-base": "^2.9.0",
|
|
88
88
|
"@opentelemetry/sdk-trace-node": "^2.9.0",
|
|
89
|
-
"@owox/connectors": "0.32.0
|
|
90
|
-
"@owox/idp-protocol": "0.32.0
|
|
91
|
-
"@owox/internal-helpers": "0.32.0
|
|
89
|
+
"@owox/connectors": "0.32.0",
|
|
90
|
+
"@owox/idp-protocol": "0.32.0",
|
|
91
|
+
"@owox/internal-helpers": "0.32.0",
|
|
92
92
|
"better-sqlite3": "^12.2.0",
|
|
93
93
|
"class-transformer": "^0.5.1",
|
|
94
94
|
"class-validator": "^0.14.2",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"@nestjs/testing": "^11.1.2",
|
|
130
130
|
"@owox/eslint-config": "*",
|
|
131
131
|
"@owox/prettier-config": "*",
|
|
132
|
-
"@owox/test-utils": "
|
|
132
|
+
"@owox/test-utils": "*",
|
|
133
133
|
"@swc/cli": "^0.6.0",
|
|
134
134
|
"@swc/core": "^1.10.7",
|
|
135
135
|
"@types/better-sqlite3": "^7.6.13",
|