@exulu/backend 1.69.0 → 1.69.2
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
|
|
899
|
+
const trailingStart = subtractDuration(new Date(now), duration);
|
|
891
900
|
if (resetMs !== null) {
|
|
892
901
|
if (resetMs > now) {
|
|
893
|
-
const periodStart =
|
|
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-
|
|
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
|
[],
|
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
|
|
2765
|
+
const trailingStart = subtractDuration(new Date(now), duration);
|
|
2757
2766
|
if (resetMs !== null) {
|
|
2758
2767
|
if (resetMs > now) {
|
|
2759
|
-
const periodStart =
|
|
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);
|
|
@@ -11178,10 +11187,11 @@ init_auth();
|
|
|
11178
11187
|
var requestValidators = {
|
|
11179
11188
|
authenticate: async (req) => {
|
|
11180
11189
|
const rawApiKey = req.headers["exulu-api-key"] || req.headers["x-api-key"];
|
|
11181
|
-
const
|
|
11190
|
+
const stripped = rawApiKey?.replace(/^Bearer\s+/i, "") ?? null;
|
|
11191
|
+
const apikey = stripped?.includes("/") ? stripped : void 0;
|
|
11182
11192
|
const { db: db2 } = await postgresClient();
|
|
11183
11193
|
let authtoken = null;
|
|
11184
|
-
if (
|
|
11194
|
+
if (!apikey) {
|
|
11185
11195
|
authtoken = await getToken((req.headers["authorization"] || req.headers["x-api-key"]) ?? "");
|
|
11186
11196
|
}
|
|
11187
11197
|
return await authentication({
|
package/dist/index.js
CHANGED
|
@@ -88,7 +88,7 @@ import {
|
|
|
88
88
|
vectorSearch,
|
|
89
89
|
waitForLiteLLMReady,
|
|
90
90
|
withRetry
|
|
91
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-PJSDLFXL.js";
|
|
92
92
|
import {
|
|
93
93
|
findLiteLLMModel
|
|
94
94
|
} from "./chunk-YCE44CMU.js";
|
|
@@ -213,10 +213,11 @@ import "express";
|
|
|
213
213
|
var requestValidators = {
|
|
214
214
|
authenticate: async (req) => {
|
|
215
215
|
const rawApiKey = req.headers["exulu-api-key"] || req.headers["x-api-key"];
|
|
216
|
-
const
|
|
216
|
+
const stripped = rawApiKey?.replace(/^Bearer\s+/i, "") ?? null;
|
|
217
|
+
const apikey = stripped?.includes("/") ? stripped : void 0;
|
|
217
218
|
const { db } = await postgresClient();
|
|
218
219
|
let authtoken = null;
|
|
219
|
-
if (
|
|
220
|
+
if (!apikey) {
|
|
220
221
|
authtoken = await getToken((req.headers["authorization"] || req.headers["x-api-key"]) ?? "");
|
|
221
222
|
}
|
|
222
223
|
return await authentication({
|