@kadoa/node-sdk 0.19.1 → 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, {
@@ -4590,7 +4589,11 @@ var ExtractionBuilderService = class {
4590
4589
  navigationMode,
4591
4590
  extraction,
4592
4591
  additionalData,
4593
- bypassPreview
4592
+ bypassPreview,
4593
+ userPrompt,
4594
+ interval,
4595
+ schedules,
4596
+ location
4594
4597
  }) {
4595
4598
  let entity = "ai-detection";
4596
4599
  if (extraction) {
@@ -4602,6 +4605,9 @@ var ExtractionBuilderService = class {
4602
4605
  entity = builtSchema.entityName ? { name: builtSchema.entityName, fields: builtSchema.fields } : { fields: builtSchema.fields };
4603
4606
  }
4604
4607
  }
4608
+ if (userPrompt) {
4609
+ this._userPrompt = userPrompt;
4610
+ }
4605
4611
  this._options = {
4606
4612
  urls,
4607
4613
  name,
@@ -4609,7 +4615,11 @@ var ExtractionBuilderService = class {
4609
4615
  navigationMode: navigationMode || "single-page",
4610
4616
  entity,
4611
4617
  bypassPreview: bypassPreview ?? false,
4612
- additionalData
4618
+ additionalData,
4619
+ userPrompt,
4620
+ interval,
4621
+ schedules,
4622
+ location
4613
4623
  };
4614
4624
  return this;
4615
4625
  }
@@ -4671,15 +4681,12 @@ var ExtractionBuilderService = class {
4671
4681
  fields: typeof entity === "object" && "fields" in entity ? entity.fields : []
4672
4682
  };
4673
4683
  } else {
4674
- resolvedEntity = await this.entityResolverService.resolveEntity(
4675
- entity,
4676
- {
4677
- link: urls[0],
4678
- location: this._options.location,
4679
- navigationMode,
4680
- selectorMode: useSelectorMode
4681
- }
4682
- );
4684
+ resolvedEntity = await this.entityResolverService.resolveEntity(entity, {
4685
+ link: urls[0],
4686
+ location: this._options.location,
4687
+ navigationMode,
4688
+ selectorMode: useSelectorMode
4689
+ });
4683
4690
  }
4684
4691
  const workflow = await this.workflowsCoreService.create({
4685
4692
  urls,
@@ -4807,13 +4814,33 @@ var NotificationChannelType = {
4807
4814
  };
4808
4815
 
4809
4816
  // src/domains/notifications/notification-channels.service.ts
4810
- var emailChannelConfigSchema = z.object({
4811
- recipients: z.array(z.email()).min(1, "Recipients are required for email channel"),
4812
- from: z.email().refine(
4813
- (email) => email.endsWith("@kadoa.com"),
4814
- "From email address must end with @kadoa.com"
4815
- ).optional()
4816
- });
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
+ }
4817
4844
  var _NotificationChannelsService = class _NotificationChannelsService {
4818
4845
  constructor(notificationsApi, userService) {
4819
4846
  this.api = notificationsApi;
@@ -4923,16 +4950,7 @@ var _NotificationChannelsService = class _NotificationChannelsService {
4923
4950
  recipients = [user.email];
4924
4951
  }
4925
4952
  const config = merge(defaults, { recipients });
4926
- const result = emailChannelConfigSchema.safeParse(config);
4927
- if (!result.success) {
4928
- throw new KadoaSdkException(`Invalid email channel config`, {
4929
- code: KadoaErrorCode.VALIDATION_ERROR,
4930
- details: {
4931
- issues: result.error.issues
4932
- }
4933
- });
4934
- }
4935
- return result.data;
4953
+ return validateEmailChannelConfig(config);
4936
4954
  }
4937
4955
  async buildSlackChannelConfig(defaults) {
4938
4956
  return defaults;
@@ -5219,7 +5237,7 @@ var WSS_API_URI = process.env.KADOA_WSS_API_URI ?? "wss://realtime.kadoa.com";
5219
5237
  var REALTIME_API_URI = process.env.KADOA_REALTIME_API_URI ?? "https://realtime.kadoa.com";
5220
5238
 
5221
5239
  // src/version.ts
5222
- var SDK_VERSION = "0.19.1";
5240
+ var SDK_VERSION = "0.19.3";
5223
5241
  var SDK_NAME = "kadoa-node-sdk";
5224
5242
  var SDK_LANGUAGE = "node";
5225
5243
 
@@ -5522,7 +5540,7 @@ async function checkForUpdates() {
5522
5540
  `\u26A0\uFE0F A new version of ${SDK_NAME} is available: ${latestVersion} (current: ${SDK_VERSION}). Update with: npm install ${PACKAGE_NAME}@latest`
5523
5541
  );
5524
5542
  }
5525
- } catch (error) {
5543
+ } catch {
5526
5544
  }
5527
5545
  }
5528
5546
  function isNewerVersion(version1, version2) {