@kadoa/node-sdk 0.19.2 → 0.19.3

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/index.mjs CHANGED
@@ -3,7 +3,6 @@ import { URL as URL$1, URLSearchParams } from 'url';
3
3
  import createDebug from 'debug';
4
4
  import { upperFirst, camelCase, merge } from 'es-toolkit';
5
5
  import assert from 'assert';
6
- import { z } from 'zod';
7
6
  import { v4 } from 'uuid';
8
7
 
9
8
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
@@ -4815,13 +4814,33 @@ var NotificationChannelType = {
4815
4814
  };
4816
4815
 
4817
4816
  // src/domains/notifications/notification-channels.service.ts
4818
- var emailChannelConfigSchema = z.object({
4819
- recipients: z.array(z.email()).min(1, "Recipients are required for email channel"),
4820
- from: z.email().refine(
4821
- (email) => email.endsWith("@kadoa.com"),
4822
- "From email address must end with @kadoa.com"
4823
- ).optional()
4824
- });
4817
+ var EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
4818
+ function validateEmailChannelConfig(config) {
4819
+ const issues = [];
4820
+ if (!config.recipients?.length) {
4821
+ issues.push({ message: "Recipients are required for email channel" });
4822
+ } else {
4823
+ for (const email of config.recipients) {
4824
+ if (!EMAIL_REGEX.test(email)) {
4825
+ issues.push({ message: `Invalid email address: ${email}` });
4826
+ }
4827
+ }
4828
+ }
4829
+ if (config.from !== void 0) {
4830
+ if (!EMAIL_REGEX.test(config.from)) {
4831
+ issues.push({ message: `Invalid from email address: ${config.from}` });
4832
+ } else if (!config.from.endsWith("@kadoa.com")) {
4833
+ issues.push({ message: "From email address must end with @kadoa.com" });
4834
+ }
4835
+ }
4836
+ if (issues.length > 0) {
4837
+ throw new KadoaSdkException("Invalid email channel config", {
4838
+ code: KadoaErrorCode.VALIDATION_ERROR,
4839
+ details: { issues }
4840
+ });
4841
+ }
4842
+ return config;
4843
+ }
4825
4844
  var _NotificationChannelsService = class _NotificationChannelsService {
4826
4845
  constructor(notificationsApi, userService) {
4827
4846
  this.api = notificationsApi;
@@ -4931,16 +4950,7 @@ var _NotificationChannelsService = class _NotificationChannelsService {
4931
4950
  recipients = [user.email];
4932
4951
  }
4933
4952
  const config = merge(defaults, { recipients });
4934
- const result = emailChannelConfigSchema.safeParse(config);
4935
- if (!result.success) {
4936
- throw new KadoaSdkException(`Invalid email channel config`, {
4937
- code: KadoaErrorCode.VALIDATION_ERROR,
4938
- details: {
4939
- issues: result.error.issues
4940
- }
4941
- });
4942
- }
4943
- return result.data;
4953
+ return validateEmailChannelConfig(config);
4944
4954
  }
4945
4955
  async buildSlackChannelConfig(defaults) {
4946
4956
  return defaults;
@@ -5227,7 +5237,7 @@ var WSS_API_URI = process.env.KADOA_WSS_API_URI ?? "wss://realtime.kadoa.com";
5227
5237
  var REALTIME_API_URI = process.env.KADOA_REALTIME_API_URI ?? "https://realtime.kadoa.com";
5228
5238
 
5229
5239
  // src/version.ts
5230
- var SDK_VERSION = "0.19.2";
5240
+ var SDK_VERSION = "0.19.3";
5231
5241
  var SDK_NAME = "kadoa-node-sdk";
5232
5242
  var SDK_LANGUAGE = "node";
5233
5243
 
@@ -5530,7 +5540,7 @@ async function checkForUpdates() {
5530
5540
  `\u26A0\uFE0F A new version of ${SDK_NAME} is available: ${latestVersion} (current: ${SDK_VERSION}). Update with: npm install ${PACKAGE_NAME}@latest`
5531
5541
  );
5532
5542
  }
5533
- } catch (error) {
5543
+ } catch {
5534
5544
  }
5535
5545
  }
5536
5546
  function isNewerVersion(version1, version2) {