@exulu/backend 1.69.0 → 1.69.1

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.
@@ -881,16 +881,25 @@ function durationToDays(duration) {
881
881
  return n;
882
882
  }
883
883
  }
884
+ function subtractDuration(date, duration) {
885
+ const m = /^\s*(\d+(?:\.\d+)?)\s*(mo|[a-z]+)?\s*$/i.exec(String(duration ?? ""));
886
+ const unit = m ? (m[2] ?? "d").toLowerCase() : "d";
887
+ const n = m ? parseFloat(m[1]) : NaN;
888
+ if (unit === "mo" && Number.isFinite(n) && n > 0) {
889
+ const result = new Date(date);
890
+ result.setUTCMonth(result.getUTCMonth() - Math.round(n));
891
+ return result;
892
+ }
893
+ return new Date(date.getTime() - durationToDays(duration) * DAY_MS);
894
+ }
884
895
  function windowStartYmd(reset_at, duration) {
885
- const days = durationToDays(duration);
886
- const windowMs = days * DAY_MS;
887
896
  const now = Date.now();
888
897
  const reset = reset_at ? new Date(reset_at) : null;
889
898
  const resetMs = reset && !Number.isNaN(reset.getTime()) ? reset.getTime() : null;
890
- const trailingStart = new Date(now - windowMs);
899
+ const trailingStart = subtractDuration(new Date(now), duration);
891
900
  if (resetMs !== null) {
892
901
  if (resetMs > now) {
893
- const periodStart = new Date(resetMs - windowMs);
902
+ const periodStart = subtractDuration(reset, duration);
894
903
  return ymd(periodStart > trailingStart ? periodStart : trailingStart);
895
904
  } else {
896
905
  return ymd(reset > trailingStart ? reset : trailingStart);
@@ -1621,7 +1630,7 @@ var ExuluTool = class _ExuluTool {
1621
1630
  });
1622
1631
  providerapikey = resolved.apiKey;
1623
1632
  }
1624
- const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-ET6UI7YG.js");
1633
+ const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-MXLGIOCT.js");
1625
1634
  const tools = await convertExuluToolsToAiSdkTools2(
1626
1635
  [this],
1627
1636
  [],
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  convertExuluToolsToAiSdkTools
3
- } from "./chunk-IVC2M56U.js";
3
+ } from "./chunk-PJSDLFXL.js";
4
4
  export {
5
5
  convertExuluToolsToAiSdkTools
6
6
  };
package/dist/index.cjs CHANGED
@@ -2747,16 +2747,25 @@ function durationToDays(duration) {
2747
2747
  return n;
2748
2748
  }
2749
2749
  }
2750
+ function subtractDuration(date, duration) {
2751
+ const m = /^\s*(\d+(?:\.\d+)?)\s*(mo|[a-z]+)?\s*$/i.exec(String(duration ?? ""));
2752
+ const unit = m ? (m[2] ?? "d").toLowerCase() : "d";
2753
+ const n = m ? parseFloat(m[1]) : NaN;
2754
+ if (unit === "mo" && Number.isFinite(n) && n > 0) {
2755
+ const result = new Date(date);
2756
+ result.setUTCMonth(result.getUTCMonth() - Math.round(n));
2757
+ return result;
2758
+ }
2759
+ return new Date(date.getTime() - durationToDays(duration) * DAY_MS);
2760
+ }
2750
2761
  function windowStartYmd(reset_at, duration) {
2751
- const days = durationToDays(duration);
2752
- const windowMs = days * DAY_MS;
2753
2762
  const now = Date.now();
2754
2763
  const reset = reset_at ? new Date(reset_at) : null;
2755
2764
  const resetMs = reset && !Number.isNaN(reset.getTime()) ? reset.getTime() : null;
2756
- const trailingStart = new Date(now - windowMs);
2765
+ const trailingStart = subtractDuration(new Date(now), duration);
2757
2766
  if (resetMs !== null) {
2758
2767
  if (resetMs > now) {
2759
- const periodStart = new Date(resetMs - windowMs);
2768
+ const periodStart = subtractDuration(reset, duration);
2760
2769
  return ymd(periodStart > trailingStart ? periodStart : trailingStart);
2761
2770
  } else {
2762
2771
  return ymd(reset > trailingStart ? reset : trailingStart);
package/dist/index.js CHANGED
@@ -88,7 +88,7 @@ import {
88
88
  vectorSearch,
89
89
  waitForLiteLLMReady,
90
90
  withRetry
91
- } from "./chunk-IVC2M56U.js";
91
+ } from "./chunk-PJSDLFXL.js";
92
92
  import {
93
93
  findLiteLLMModel
94
94
  } from "./chunk-YCE44CMU.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exulu/backend",
3
3
  "author": "Qventu Bv.",
4
- "version": "1.69.0",
4
+ "version": "1.69.1",
5
5
  "main": "./dist/index.js",
6
6
  "private": false,
7
7
  "publishConfig": {