@develit-services/notification 0.0.17 → 0.0.19
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.
- package/dist/export/worker.cjs +10 -18
- package/dist/export/worker.d.cts +1 -1
- package/dist/export/worker.d.mts +1 -1
- package/dist/export/worker.d.ts +1 -1
- package/dist/export/worker.mjs +11 -19
- package/dist/export/wrangler.cjs +4 -0
- package/dist/export/wrangler.d.cts +2 -4
- package/dist/export/wrangler.d.mts +2 -4
- package/dist/export/wrangler.d.ts +2 -4
- package/dist/export/wrangler.mjs +4 -0
- package/package.json +1 -1
package/dist/export/worker.cjs
CHANGED
|
@@ -70,18 +70,15 @@ class EcomailConnector extends IEmailConnector {
|
|
|
70
70
|
}
|
|
71
71
|
const emEmail = this.convertEmail(email);
|
|
72
72
|
const uri = emEmail.message.template_id ? "https://api2.ecomailapp.cz/transactional/send-template" : "https://api2.ecomailapp.cz/transactional/send-message";
|
|
73
|
-
const [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
})
|
|
82
|
-
);
|
|
73
|
+
const [_, error] = await backendSdk.useFetch(uri, {
|
|
74
|
+
method: "POST",
|
|
75
|
+
headers: {
|
|
76
|
+
"Content-Type": "application/json",
|
|
77
|
+
key: this.API_KEY
|
|
78
|
+
},
|
|
79
|
+
body: JSON.stringify(emEmail)
|
|
80
|
+
});
|
|
83
81
|
if (error) throw error;
|
|
84
|
-
return data;
|
|
85
82
|
}
|
|
86
83
|
convertEmail(email) {
|
|
87
84
|
const toContacts = this.convertContacts(email.to);
|
|
@@ -402,20 +399,15 @@ class NotificationServiceBase extends backendSdk.develitWorker(
|
|
|
402
399
|
initiator: { service, userId }
|
|
403
400
|
}
|
|
404
401
|
} = params;
|
|
405
|
-
if (!this.emailConnector)
|
|
402
|
+
if (!this.emailConnector) {
|
|
406
403
|
this.emailConnector = await initiateEmailConnector(
|
|
407
404
|
this.env.EMAIL_PROVIDER,
|
|
408
405
|
this.env.EMAIL_API_KEY,
|
|
409
406
|
this.env.EMAIL_SMTP_HOST,
|
|
410
407
|
this.env.EMAIL_SENDER
|
|
411
408
|
);
|
|
412
|
-
const response = await this.emailConnector.sendEmail(email);
|
|
413
|
-
if (!response?.ok) {
|
|
414
|
-
throw backendSdk.createInternalError(null, {
|
|
415
|
-
message: `Could not send email: ${JSON.stringify(await response?.json())}`,
|
|
416
|
-
status: 500
|
|
417
|
-
});
|
|
418
409
|
}
|
|
410
|
+
await this.emailConnector.sendEmail(email);
|
|
419
411
|
const { command } = await createAuditLogCommand({
|
|
420
412
|
db: this.db,
|
|
421
413
|
auditLog: {
|
package/dist/export/worker.d.cts
CHANGED
|
@@ -63,7 +63,7 @@ declare abstract class IEmailConnector {
|
|
|
63
63
|
SMTP_HOST: string;
|
|
64
64
|
SENDER: IContact;
|
|
65
65
|
});
|
|
66
|
-
abstract sendEmail(email: IEmail): Promise<
|
|
66
|
+
abstract sendEmail(email: IEmail): Promise<void>;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
declare const sendEmailInputSchema: z$1.ZodObject<{
|
package/dist/export/worker.d.mts
CHANGED
|
@@ -63,7 +63,7 @@ declare abstract class IEmailConnector {
|
|
|
63
63
|
SMTP_HOST: string;
|
|
64
64
|
SENDER: IContact;
|
|
65
65
|
});
|
|
66
|
-
abstract sendEmail(email: IEmail): Promise<
|
|
66
|
+
abstract sendEmail(email: IEmail): Promise<void>;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
declare const sendEmailInputSchema: z$1.ZodObject<{
|
package/dist/export/worker.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ declare abstract class IEmailConnector {
|
|
|
63
63
|
SMTP_HOST: string;
|
|
64
64
|
SENDER: IContact;
|
|
65
65
|
});
|
|
66
|
-
abstract sendEmail(email: IEmail): Promise<
|
|
66
|
+
abstract sendEmail(email: IEmail): Promise<void>;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
declare const sendEmailInputSchema: z$1.ZodObject<{
|
package/dist/export/worker.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useFetch, createInternalError, uuidv4, develitWorker, useResult, cloudflareQueue, action } from '@develit-io/backend-sdk';
|
|
2
2
|
import z$1, { z } from 'zod';
|
|
3
3
|
import { z as z$2 } from 'zod/v4';
|
|
4
4
|
import twilio from 'twilio';
|
|
@@ -61,18 +61,15 @@ class EcomailConnector extends IEmailConnector {
|
|
|
61
61
|
}
|
|
62
62
|
const emEmail = this.convertEmail(email);
|
|
63
63
|
const uri = emEmail.message.template_id ? "https://api2.ecomailapp.cz/transactional/send-template" : "https://api2.ecomailapp.cz/transactional/send-message";
|
|
64
|
-
const [
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
})
|
|
73
|
-
);
|
|
64
|
+
const [_, error] = await useFetch(uri, {
|
|
65
|
+
method: "POST",
|
|
66
|
+
headers: {
|
|
67
|
+
"Content-Type": "application/json",
|
|
68
|
+
key: this.API_KEY
|
|
69
|
+
},
|
|
70
|
+
body: JSON.stringify(emEmail)
|
|
71
|
+
});
|
|
74
72
|
if (error) throw error;
|
|
75
|
-
return data;
|
|
76
73
|
}
|
|
77
74
|
convertEmail(email) {
|
|
78
75
|
const toContacts = this.convertContacts(email.to);
|
|
@@ -393,20 +390,15 @@ class NotificationServiceBase extends develitWorker(
|
|
|
393
390
|
initiator: { service, userId }
|
|
394
391
|
}
|
|
395
392
|
} = params;
|
|
396
|
-
if (!this.emailConnector)
|
|
393
|
+
if (!this.emailConnector) {
|
|
397
394
|
this.emailConnector = await initiateEmailConnector(
|
|
398
395
|
this.env.EMAIL_PROVIDER,
|
|
399
396
|
this.env.EMAIL_API_KEY,
|
|
400
397
|
this.env.EMAIL_SMTP_HOST,
|
|
401
398
|
this.env.EMAIL_SENDER
|
|
402
399
|
);
|
|
403
|
-
const response = await this.emailConnector.sendEmail(email);
|
|
404
|
-
if (!response?.ok) {
|
|
405
|
-
throw createInternalError(null, {
|
|
406
|
-
message: `Could not send email: ${JSON.stringify(await response?.json())}`,
|
|
407
|
-
status: 500
|
|
408
|
-
});
|
|
409
400
|
}
|
|
401
|
+
await this.emailConnector.sendEmail(email);
|
|
410
402
|
const { command } = await createAuditLogCommand({
|
|
411
403
|
db: this.db,
|
|
412
404
|
auditLog: {
|
package/dist/export/wrangler.cjs
CHANGED
|
@@ -13,10 +13,8 @@ interface NotificationServiceEnvironmentConfig {
|
|
|
13
13
|
email: string;
|
|
14
14
|
};
|
|
15
15
|
EMAIL_SMTP_HOST: string;
|
|
16
|
-
EMAIL_API_KEY: string;
|
|
17
16
|
SMS_PROVIDER: 'twilio';
|
|
18
17
|
SMS_ACCOUNT_ID: string;
|
|
19
|
-
SMS_AUTH_TOKEN: string;
|
|
20
18
|
SMS_SERVICE_ID: string | number;
|
|
21
19
|
SLACK_WEBHOOKS: [string];
|
|
22
20
|
};
|
|
@@ -53,12 +51,12 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
|
|
|
53
51
|
email: string;
|
|
54
52
|
};
|
|
55
53
|
EMAIL_SMTP_HOST: string;
|
|
56
|
-
EMAIL_API_KEY: string;
|
|
57
54
|
SMS_PROVIDER: "twilio";
|
|
58
55
|
SMS_ACCOUNT_ID: string;
|
|
59
|
-
SMS_AUTH_TOKEN: string;
|
|
60
56
|
SMS_SERVICE_ID: string | number;
|
|
61
57
|
SLACK_WEBHOOKS: [string];
|
|
58
|
+
EMAIL_API_KEY: string;
|
|
59
|
+
SMS_AUTH_TOKEN: string;
|
|
62
60
|
};
|
|
63
61
|
d1_databases: {
|
|
64
62
|
binding: string;
|
|
@@ -13,10 +13,8 @@ interface NotificationServiceEnvironmentConfig {
|
|
|
13
13
|
email: string;
|
|
14
14
|
};
|
|
15
15
|
EMAIL_SMTP_HOST: string;
|
|
16
|
-
EMAIL_API_KEY: string;
|
|
17
16
|
SMS_PROVIDER: 'twilio';
|
|
18
17
|
SMS_ACCOUNT_ID: string;
|
|
19
|
-
SMS_AUTH_TOKEN: string;
|
|
20
18
|
SMS_SERVICE_ID: string | number;
|
|
21
19
|
SLACK_WEBHOOKS: [string];
|
|
22
20
|
};
|
|
@@ -53,12 +51,12 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
|
|
|
53
51
|
email: string;
|
|
54
52
|
};
|
|
55
53
|
EMAIL_SMTP_HOST: string;
|
|
56
|
-
EMAIL_API_KEY: string;
|
|
57
54
|
SMS_PROVIDER: "twilio";
|
|
58
55
|
SMS_ACCOUNT_ID: string;
|
|
59
|
-
SMS_AUTH_TOKEN: string;
|
|
60
56
|
SMS_SERVICE_ID: string | number;
|
|
61
57
|
SLACK_WEBHOOKS: [string];
|
|
58
|
+
EMAIL_API_KEY: string;
|
|
59
|
+
SMS_AUTH_TOKEN: string;
|
|
62
60
|
};
|
|
63
61
|
d1_databases: {
|
|
64
62
|
binding: string;
|
|
@@ -13,10 +13,8 @@ interface NotificationServiceEnvironmentConfig {
|
|
|
13
13
|
email: string;
|
|
14
14
|
};
|
|
15
15
|
EMAIL_SMTP_HOST: string;
|
|
16
|
-
EMAIL_API_KEY: string;
|
|
17
16
|
SMS_PROVIDER: 'twilio';
|
|
18
17
|
SMS_ACCOUNT_ID: string;
|
|
19
|
-
SMS_AUTH_TOKEN: string;
|
|
20
18
|
SMS_SERVICE_ID: string | number;
|
|
21
19
|
SLACK_WEBHOOKS: [string];
|
|
22
20
|
};
|
|
@@ -53,12 +51,12 @@ declare function defineNotificationServiceWrangler(config: NotificationServiceWr
|
|
|
53
51
|
email: string;
|
|
54
52
|
};
|
|
55
53
|
EMAIL_SMTP_HOST: string;
|
|
56
|
-
EMAIL_API_KEY: string;
|
|
57
54
|
SMS_PROVIDER: "twilio";
|
|
58
55
|
SMS_ACCOUNT_ID: string;
|
|
59
|
-
SMS_AUTH_TOKEN: string;
|
|
60
56
|
SMS_SERVICE_ID: string | number;
|
|
61
57
|
SLACK_WEBHOOKS: [string];
|
|
58
|
+
EMAIL_API_KEY: string;
|
|
59
|
+
SMS_AUTH_TOKEN: string;
|
|
62
60
|
};
|
|
63
61
|
d1_databases: {
|
|
64
62
|
binding: string;
|
package/dist/export/wrangler.mjs
CHANGED