@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.
@@ -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
- const message = result.message || 'service mail was not accepted by dcrouter';
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
@@ -1,3 +1,4 @@
1
1
  export * from './classes.platformclient.js';
2
+ export * from './coremail/classes.coremailconnector.js';
2
3
  export * from './email/classes.emailconnector.js';
3
4
  export * from './webpush/classes.webpushconnector.js';
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 typedserver from '@api.global/typedserver';
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
- typedserver,
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: {