@serve.zone/platformclient 2.4.0 → 3.0.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.
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.platformclient.d.ts +11 -1
- package/dist_ts/classes.platformclient.js +64 -32
- package/dist_ts/coremail/classes.coremailconnector.d.ts +72 -0
- package/dist_ts/coremail/classes.coremailconnector.js +663 -0
- package/dist_ts/email/classes.emailconnector.d.ts +0 -8
- package/dist_ts/email/classes.emailconnector.js +3 -29
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +2 -1
- package/dist_ts/plugins.d.ts +2 -2
- package/dist_ts/plugins.js +3 -3
- package/dist_ts/webpush/classes.webpushconnector.js +2 -23
- package/package.json +8 -8
- package/readme.md +55 -26
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.platformclient.ts +77 -34
- package/ts/coremail/classes.coremailconnector.ts +931 -0
- package/ts/email/classes.emailconnector.ts +2 -34
- package/ts/index.ts +1 -0
- package/ts/plugins.ts +2 -2
- package/ts/webpush/classes.webpushconnector.ts +1 -28
|
@@ -51,8 +51,6 @@ export interface IServiceMailSendOptions {
|
|
|
51
51
|
to: string | string[];
|
|
52
52
|
cc?: string | string[];
|
|
53
53
|
bcc?: string | string[];
|
|
54
|
-
/** One bare mailbox address rendered as the authoritative Reply-To header by dcrouter. */
|
|
55
|
-
replyTo?: string;
|
|
56
54
|
subject: string;
|
|
57
55
|
text?: string;
|
|
58
56
|
html?: string;
|
|
@@ -60,19 +58,6 @@ export interface IServiceMailSendOptions {
|
|
|
60
58
|
attachments?: IServiceMailAttachment[];
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
export type TServiceMailSubmissionErrorCode =
|
|
64
|
-
plugins.servezoneInterfaces.data.TMailSubmissionErrorCode;
|
|
65
|
-
|
|
66
|
-
export class ServiceMailSubmissionError extends Error {
|
|
67
|
-
constructor(
|
|
68
|
-
public readonly code: TServiceMailSubmissionErrorCode,
|
|
69
|
-
messageArg: string,
|
|
70
|
-
) {
|
|
71
|
-
super(messageArg);
|
|
72
|
-
this.name = 'ServiceMailSubmissionError';
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
61
|
export interface IServiceMailSendResult {
|
|
77
62
|
messageId?: string;
|
|
78
63
|
spoolItemId?: string;
|
|
@@ -246,7 +231,6 @@ export class SzEmailConnector {
|
|
|
246
231
|
to: this.listToArray(optionsArg.to),
|
|
247
232
|
cc: optionsArg.cc ? this.listToArray(optionsArg.cc) : undefined,
|
|
248
233
|
bcc: optionsArg.bcc ? this.listToArray(optionsArg.bcc) : undefined,
|
|
249
|
-
...(optionsArg.replyTo !== undefined ? { replyTo: optionsArg.replyTo } : {}),
|
|
250
234
|
subject: optionsArg.subject,
|
|
251
235
|
text: optionsArg.text,
|
|
252
236
|
html: optionsArg.html,
|
|
@@ -259,11 +243,7 @@ export class SzEmailConnector {
|
|
|
259
243
|
},
|
|
260
244
|
});
|
|
261
245
|
if (!result.accepted) {
|
|
262
|
-
|
|
263
|
-
if (result.errorCode) {
|
|
264
|
-
throw new ServiceMailSubmissionError(result.errorCode, message);
|
|
265
|
-
}
|
|
266
|
-
throw new Error(message);
|
|
246
|
+
throw new Error(result.message || 'service mail was not accepted by dcrouter');
|
|
267
247
|
}
|
|
268
248
|
return {
|
|
269
249
|
messageId: result.spoolItemId,
|
|
@@ -404,19 +384,7 @@ export class SzEmailConnector {
|
|
|
404
384
|
}
|
|
405
385
|
|
|
406
386
|
private async readMailEnvVar(envNameArg: string): Promise<string | undefined> {
|
|
407
|
-
return await this.platformClientRef.getConfiguredEnvVar(envNameArg)
|
|
408
|
-
|| this.getCredentialEnvVarFromBindings(envNameArg);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
private getCredentialEnvVarFromBindings(envNameArg: string): string | undefined {
|
|
412
|
-
for (const binding of this.platformClientRef.platformBindings || []) {
|
|
413
|
-
if (binding.desiredState === 'disabled' || binding.status === 'failed') continue;
|
|
414
|
-
if (binding.capability !== 'email') continue;
|
|
415
|
-
for (const credential of binding.credentials || []) {
|
|
416
|
-
const value = credential.env?.[envNameArg];
|
|
417
|
-
if (value) return value;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
387
|
+
return await this.platformClientRef.getConfiguredEnvVar(envNameArg);
|
|
420
388
|
}
|
|
421
389
|
|
|
422
390
|
private hasAnyMailEnvValue(envArg?: {
|
package/ts/index.ts
CHANGED
package/ts/plugins.ts
CHANGED
|
@@ -17,11 +17,11 @@ export {
|
|
|
17
17
|
|
|
18
18
|
// @api.global scope
|
|
19
19
|
import * as typedrequest from '@api.global/typedrequest';
|
|
20
|
-
import * as
|
|
20
|
+
import * as typedrequestInterfaces from '@api.global/typedrequest-interfaces';
|
|
21
21
|
import * as typedsocket from '@api.global/typedsocket';
|
|
22
22
|
|
|
23
23
|
export {
|
|
24
24
|
typedrequest,
|
|
25
|
-
|
|
25
|
+
typedrequestInterfaces,
|
|
26
26
|
typedsocket,
|
|
27
27
|
}
|
|
@@ -238,34 +238,7 @@ export class SzWebPushConnector {
|
|
|
238
238
|
if (this.hasCredentialBundleValue(directEnv)) {
|
|
239
239
|
return directEnv;
|
|
240
240
|
}
|
|
241
|
-
|
|
242
|
-
const bindingCredentialBundles: Array<Partial<IServiceWebPushCredentials>> = [];
|
|
243
|
-
for (const binding of this.platformClientRef.platformBindings || []) {
|
|
244
|
-
if (
|
|
245
|
-
binding.capability !== 'pushnotification'
|
|
246
|
-
|| binding.desiredState !== 'enabled'
|
|
247
|
-
|| binding.status !== 'ready'
|
|
248
|
-
) {
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
for (const credential of binding.credentials || []) {
|
|
252
|
-
const credentialBundle = this.normalizeCredentialBundle({
|
|
253
|
-
typedUrl: credential.env?.WEB_PUSH_TYPED_URL,
|
|
254
|
-
credentialId: credential.env?.WEB_PUSH_API_CREDENTIAL_ID,
|
|
255
|
-
credentialSecret: credential.env?.WEB_PUSH_API_CREDENTIAL_SECRET,
|
|
256
|
-
});
|
|
257
|
-
if (this.hasCredentialBundleValue(credentialBundle)) {
|
|
258
|
-
bindingCredentialBundles.push(credentialBundle);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
if (bindingCredentialBundles.length > 1) {
|
|
264
|
-
throw new Error(
|
|
265
|
-
'Multiple ready Web Push credential bundles are configured; exactly one is required',
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
return bindingCredentialBundles[0] || {};
|
|
241
|
+
return {};
|
|
269
242
|
}
|
|
270
243
|
|
|
271
244
|
private normalizeCredentialBundle(bundleArg: {
|