@hiai-gg/docsmint 2.0.4 → 2.1.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.
- package/README.md +67 -2
- package/dist/backend/index.js +22540 -2807
- package/dist/backend-account-runtime-cleanup.js +2 -1
- package/dist/backend-api-key-facade.js +2 -1
- package/dist/backend-pipeline-cancellation.js +2 -1
- package/dist/client.d.ts +33 -7
- package/dist/client.js +55 -1
- package/dist/frontend/{HiAiEditor-DDpfdQEg.js → HiAiEditor-D6ad_auS.js} +2 -2
- package/dist/frontend/{SettingsDialog-DzlYW50I.js → SettingsDialog-B8Oswuqb.js} +4 -4
- package/dist/frontend/{Sidebar-rFiVen96.js → Sidebar-BV0IDqTS.js} +1 -1
- package/dist/frontend/api/settings.js +1 -1
- package/dist/frontend/app-shell.js +2 -2
- package/dist/frontend/{auth-client-CXR-7mIO.js → auth-client-C5EyWdAF.js} +416 -349
- package/dist/frontend/components/editor/compact-editor.js +1 -1
- package/dist/frontend/components/editor/document-editor.js +1 -1
- package/dist/frontend/components/settings.js +1 -1
- package/dist/frontend/components/sidebar.js +1 -1
- package/dist/frontend/{db-Dya0HRhS.js → db-CgTtukT4.js} +1 -1
- package/dist/frontend/{identity-BOA7Jejv.js → identity-CNhtuCJV.js} +1 -1
- package/dist/frontend/offline/identity.js +1 -1
- package/dist/frontend/{settings-BRcYFQa_.js → settings-CHx4wBwb.js} +1 -1
- package/dist/frontend-ssr/api/settings.js +1 -1
- package/dist/frontend-ssr/app-shell.js +2 -2
- package/dist/frontend-ssr/assets/{HiAiEditor-Bj6tiE97.js → HiAiEditor-Cj3B2Dt6.js} +2 -2
- package/dist/frontend-ssr/assets/{SettingsDialog-h4SFwpUa.js → SettingsDialog-DAT-Zxu0.js} +4 -4
- package/dist/frontend-ssr/assets/{Sidebar-BFBpsd3L.js → Sidebar-B_Ey6QNL.js} +1 -1
- package/dist/frontend-ssr/assets/{auth-client-BC4hSFKF.js → auth-client-CITU3xkE.js} +308 -227
- package/dist/frontend-ssr/assets/{db-C3rFdTZa.js → db-DxRzq-kx.js} +1 -1
- package/dist/frontend-ssr/assets/{identity-DNIo1bgc.js → identity-B7ngLQzZ.js} +1 -1
- package/dist/frontend-ssr/assets/{settings-DWCpfCPj.js → settings-BRxvn30Y.js} +1 -1
- package/dist/frontend-ssr/components/editor/compact-editor.js +1 -1
- package/dist/frontend-ssr/components/editor/document-editor.js +1 -1
- package/dist/frontend-ssr/components/settings.js +1 -1
- package/dist/frontend-ssr/components/sidebar.js +1 -1
- package/dist/frontend-ssr/offline/identity.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lifecycle-runtime.js +4 -1
- package/dist/mcp-cli.js +301 -22
- package/dist/mcp-server.d.ts +92 -23
- package/dist/mcp-server.js +469 -22
- package/dist/types.d.ts +68 -1
- package/package.json +2 -2
- package/packages/cli/src/index.ts +1 -1
- package/packages/db/src/schema.ts +3 -1
- package/server.json +2 -2
|
@@ -3,7 +3,7 @@ import { env } from "@better-auth/core/env";
|
|
|
3
3
|
import { BetterAuthError } from "@better-auth/core/error";
|
|
4
4
|
import { isSafeUrlScheme } from "@better-auth/core/utils/url";
|
|
5
5
|
import { capitalizeFirstLetter, toKebabCase } from "@better-auth/core/utils/string";
|
|
6
|
-
//#region ../node_modules/.bun/better-auth@1.7.
|
|
6
|
+
//#region ../node_modules/.bun/better-auth@1.7.7+7ee5f890295c53f0/node_modules/better-auth/dist/client/broadcast-channel.mjs
|
|
7
7
|
var kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
|
|
8
8
|
var now$1 = () => Math.floor(Date.now() / 1e3);
|
|
9
9
|
var WindowBroadcastChannel = class {
|
|
@@ -46,7 +46,7 @@ function getGlobalBroadcastChannel(name = "better-auth.message") {
|
|
|
46
46
|
return globalThis[kBroadcastChannel];
|
|
47
47
|
}
|
|
48
48
|
//#endregion
|
|
49
|
-
//#region ../node_modules/.bun/better-auth@1.7.
|
|
49
|
+
//#region ../node_modules/.bun/better-auth@1.7.7+7ee5f890295c53f0/node_modules/better-auth/dist/client/equality.mjs
|
|
50
50
|
function isPlainObject$1(value) {
|
|
51
51
|
if (typeof value !== "object" || value === null) return false;
|
|
52
52
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -86,7 +86,7 @@ function withEquality(store, isEqual) {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
//#endregion
|
|
89
|
-
//#region ../node_modules/.bun/better-auth@1.7.
|
|
89
|
+
//#region ../node_modules/.bun/better-auth@1.7.7+7ee5f890295c53f0/node_modules/better-auth/dist/client/focus-manager.mjs
|
|
90
90
|
var kFocusManager = Symbol.for("better-auth:focus-manager");
|
|
91
91
|
var WindowFocusManager = class {
|
|
92
92
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -115,7 +115,7 @@ function getGlobalFocusManager() {
|
|
|
115
115
|
return globalThis[kFocusManager];
|
|
116
116
|
}
|
|
117
117
|
//#endregion
|
|
118
|
-
//#region ../node_modules/.bun/better-auth@1.7.
|
|
118
|
+
//#region ../node_modules/.bun/better-auth@1.7.7+7ee5f890295c53f0/node_modules/better-auth/dist/client/online-manager.mjs
|
|
119
119
|
var kOnlineManager = Symbol.for("better-auth:online-manager");
|
|
120
120
|
var WindowOnlineManager = class {
|
|
121
121
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -147,7 +147,7 @@ function getGlobalOnlineManager() {
|
|
|
147
147
|
return globalThis[kOnlineManager];
|
|
148
148
|
}
|
|
149
149
|
//#endregion
|
|
150
|
-
//#region ../node_modules/.bun/better-auth@1.7.
|
|
150
|
+
//#region ../node_modules/.bun/better-auth@1.7.7+7ee5f890295c53f0/node_modules/better-auth/dist/client/parser.mjs
|
|
151
151
|
var PROTO_POLLUTION_PATTERNS = {
|
|
152
152
|
proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
|
|
153
153
|
constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
|
|
@@ -216,7 +216,15 @@ function parseJSON(value, options = { strict: true }) {
|
|
|
216
216
|
return betterJSONParse(value, options);
|
|
217
217
|
}
|
|
218
218
|
//#endregion
|
|
219
|
-
//#region ../node_modules/.bun/better-auth@1.7.
|
|
219
|
+
//#region ../node_modules/.bun/better-auth@1.7.7+7ee5f890295c53f0/node_modules/better-auth/dist/client/query-atom.mjs
|
|
220
|
+
var kAuthQuery = Symbol.for("better-auth:auth-query");
|
|
221
|
+
function createAuthQueryAtom(initialValue) {
|
|
222
|
+
const queryAtom = atom(initialValue);
|
|
223
|
+
Object.defineProperty(queryAtom, kAuthQuery, { value: true });
|
|
224
|
+
return queryAtom;
|
|
225
|
+
}
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region ../node_modules/.bun/better-auth@1.7.7+7ee5f890295c53f0/node_modules/better-auth/dist/client/session-refresh.mjs
|
|
220
228
|
var now = () => Math.floor(Date.now() / 1e3);
|
|
221
229
|
/**
|
|
222
230
|
* Rate limit: don't refetch on focus if a session request was made within this many seconds
|
|
@@ -343,7 +351,7 @@ function createSessionRefreshManager(opts) {
|
|
|
343
351
|
};
|
|
344
352
|
}
|
|
345
353
|
//#endregion
|
|
346
|
-
//#region ../node_modules/.bun/better-auth@1.7.
|
|
354
|
+
//#region ../node_modules/.bun/better-auth@1.7.7+7ee5f890295c53f0/node_modules/better-auth/dist/utils/url.mjs
|
|
347
355
|
var SLASH_CHAR_CODE = "/".charCodeAt(0);
|
|
348
356
|
function trimTrailingSlashes(value) {
|
|
349
357
|
let end = value.length;
|
|
@@ -421,7 +429,7 @@ function getOrigin(url) {
|
|
|
421
429
|
}
|
|
422
430
|
}
|
|
423
431
|
//#endregion
|
|
424
|
-
//#region ../node_modules/.bun/better-auth@1.7.
|
|
432
|
+
//#region ../node_modules/.bun/better-auth@1.7.7+7ee5f890295c53f0/node_modules/better-auth/dist/client/fetch-plugins.mjs
|
|
425
433
|
var redirectPlugin = {
|
|
426
434
|
id: "redirect",
|
|
427
435
|
name: "Redirect",
|
|
@@ -436,7 +444,7 @@ var redirectPlugin = {
|
|
|
436
444
|
} }
|
|
437
445
|
};
|
|
438
446
|
//#endregion
|
|
439
|
-
//#region ../node_modules/.bun/better-auth@1.7.
|
|
447
|
+
//#region ../node_modules/.bun/better-auth@1.7.7+7ee5f890295c53f0/node_modules/better-auth/dist/client/session-atom.mjs
|
|
440
448
|
var isServer = () => typeof window === "undefined";
|
|
441
449
|
var SESSION_MOUNT_DEDUPE_INTERVAL = STORE_UNMOUNT_DELAY;
|
|
442
450
|
function hydrateSessionAtom(sessionAtom, session) {
|
|
@@ -479,7 +487,7 @@ function getSessionAtom($fetch, options) {
|
|
|
479
487
|
freshUntil = 0;
|
|
480
488
|
});
|
|
481
489
|
const refetch = (queryParams) => fetchSession(queryParams);
|
|
482
|
-
const session =
|
|
490
|
+
const session = createAuthQueryAtom({
|
|
483
491
|
data: null,
|
|
484
492
|
error: null,
|
|
485
493
|
isPending: true,
|
|
@@ -638,27 +646,7 @@ function createDefu(merger) {
|
|
|
638
646
|
}
|
|
639
647
|
var defu = createDefu();
|
|
640
648
|
//#endregion
|
|
641
|
-
//#region ../node_modules/.bun/@better-fetch+fetch@1.3.
|
|
642
|
-
var __defProp = Object.defineProperty;
|
|
643
|
-
var __defProps = Object.defineProperties;
|
|
644
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
645
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
646
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
647
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
648
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
649
|
-
enumerable: true,
|
|
650
|
-
configurable: true,
|
|
651
|
-
writable: true,
|
|
652
|
-
value
|
|
653
|
-
}) : obj[key] = value;
|
|
654
|
-
var __spreadValues = (a, b) => {
|
|
655
|
-
for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
656
|
-
if (__getOwnPropSymbols) {
|
|
657
|
-
for (var prop of __getOwnPropSymbols(b)) if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
658
|
-
}
|
|
659
|
-
return a;
|
|
660
|
-
};
|
|
661
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
649
|
+
//#region ../node_modules/.bun/@better-fetch+fetch@1.3.2/node_modules/@better-fetch/fetch/dist/index.js
|
|
662
650
|
var BetterFetchError = class extends Error {
|
|
663
651
|
constructor(status, statusText, error) {
|
|
664
652
|
super(statusText || status.toString(), { cause: error });
|
|
@@ -669,31 +657,32 @@ var BetterFetchError = class extends Error {
|
|
|
669
657
|
}
|
|
670
658
|
};
|
|
671
659
|
var initializePlugins = async (url, options) => {
|
|
672
|
-
var _a, _b, _c, _d, _e, _f;
|
|
673
660
|
let opts = options || {};
|
|
674
661
|
const hooks = {
|
|
675
|
-
onRequest: [options
|
|
676
|
-
onResponse: [options
|
|
677
|
-
onSuccess: [options
|
|
678
|
-
onError: [options
|
|
679
|
-
onRetry: [options
|
|
662
|
+
onRequest: [options === null || options === void 0 ? void 0 : options.onRequest],
|
|
663
|
+
onResponse: [options === null || options === void 0 ? void 0 : options.onResponse],
|
|
664
|
+
onSuccess: [options === null || options === void 0 ? void 0 : options.onSuccess],
|
|
665
|
+
onError: [options === null || options === void 0 ? void 0 : options.onError],
|
|
666
|
+
onRetry: [options === null || options === void 0 ? void 0 : options.onRetry]
|
|
680
667
|
};
|
|
681
|
-
if (!options || !(options
|
|
668
|
+
if (!options || !(options === null || options === void 0 ? void 0 : options.plugins)) return {
|
|
682
669
|
url,
|
|
683
670
|
options: opts,
|
|
684
671
|
hooks
|
|
685
672
|
};
|
|
686
|
-
for (const plugin of (options
|
|
673
|
+
for (const plugin of (options === null || options === void 0 ? void 0 : options.plugins) || []) {
|
|
674
|
+
var _plugin$hooks, _plugin$hooks2, _plugin$hooks3, _plugin$hooks4, _plugin$hooks5;
|
|
687
675
|
if (plugin.init) {
|
|
688
|
-
|
|
676
|
+
var _plugin$init;
|
|
677
|
+
const pluginRes = await ((_plugin$init = plugin.init) === null || _plugin$init === void 0 ? void 0 : _plugin$init.call(plugin, url.toString(), opts));
|
|
689
678
|
opts = pluginRes.options || opts;
|
|
690
679
|
url = pluginRes.url;
|
|
691
680
|
}
|
|
692
|
-
hooks.onRequest.push((
|
|
693
|
-
hooks.onResponse.push((
|
|
694
|
-
hooks.onSuccess.push((
|
|
695
|
-
hooks.onError.push((
|
|
696
|
-
hooks.onRetry.push((
|
|
681
|
+
hooks.onRequest.push((_plugin$hooks = plugin.hooks) === null || _plugin$hooks === void 0 ? void 0 : _plugin$hooks.onRequest);
|
|
682
|
+
hooks.onResponse.push((_plugin$hooks2 = plugin.hooks) === null || _plugin$hooks2 === void 0 ? void 0 : _plugin$hooks2.onResponse);
|
|
683
|
+
hooks.onSuccess.push((_plugin$hooks3 = plugin.hooks) === null || _plugin$hooks3 === void 0 ? void 0 : _plugin$hooks3.onSuccess);
|
|
684
|
+
hooks.onError.push((_plugin$hooks4 = plugin.hooks) === null || _plugin$hooks4 === void 0 ? void 0 : _plugin$hooks4.onError);
|
|
685
|
+
hooks.onRetry.push((_plugin$hooks5 = plugin.hooks) === null || _plugin$hooks5 === void 0 ? void 0 : _plugin$hooks5.onRetry);
|
|
697
686
|
}
|
|
698
687
|
return {
|
|
699
688
|
url,
|
|
@@ -737,10 +726,81 @@ function createRetryStrategy(options) {
|
|
|
737
726
|
default: throw new Error("Invalid retry strategy");
|
|
738
727
|
}
|
|
739
728
|
}
|
|
729
|
+
var methods = [
|
|
730
|
+
"get",
|
|
731
|
+
"post",
|
|
732
|
+
"put",
|
|
733
|
+
"patch",
|
|
734
|
+
"delete"
|
|
735
|
+
];
|
|
736
|
+
function parseMethodModifier(path) {
|
|
737
|
+
if (!path.startsWith("@")) return {
|
|
738
|
+
method: void 0,
|
|
739
|
+
path
|
|
740
|
+
};
|
|
741
|
+
const separator = path.indexOf("/");
|
|
742
|
+
const method = path.slice(1, separator === -1 ? void 0 : separator);
|
|
743
|
+
if (!methods.includes(method)) return {
|
|
744
|
+
method: void 0,
|
|
745
|
+
path
|
|
746
|
+
};
|
|
747
|
+
return {
|
|
748
|
+
method,
|
|
749
|
+
path: separator === -1 ? path : path.slice(separator + 1)
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
var isReservedPathSegment = (value) => value === "." || value === "..";
|
|
753
|
+
var encodeLiteralPathSegment = (segment) => segment.split(":").map((part) => encodeURIComponent(part)).join(":");
|
|
754
|
+
function resolvePathSegment(segment, pathParams) {
|
|
755
|
+
const pathParam = pathParams.get(segment);
|
|
756
|
+
if (pathParam === void 0) return encodeLiteralPathSegment(segment);
|
|
757
|
+
if (isReservedPathSegment(pathParam)) throw new TypeError("Path parameters cannot be reserved path segments");
|
|
758
|
+
return encodeURIComponent(pathParam);
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Normalize URL
|
|
762
|
+
*/
|
|
763
|
+
function getURL$1(url, option) {
|
|
764
|
+
const { baseURL, params, query } = option || {
|
|
765
|
+
query: {},
|
|
766
|
+
params: {},
|
|
767
|
+
baseURL: ""
|
|
768
|
+
};
|
|
769
|
+
let basePath = url.startsWith("http") ? url.split("/").slice(0, 3).join("/") : baseURL || "";
|
|
770
|
+
const { path: requestPath } = parseMethodModifier(url);
|
|
771
|
+
if (requestPath !== url) url = `/${requestPath}`;
|
|
772
|
+
if (!basePath.endsWith("/")) basePath += "/";
|
|
773
|
+
let [path, urlQuery] = url.replace(basePath, "").split("?");
|
|
774
|
+
const queryParams = new URLSearchParams(urlQuery);
|
|
775
|
+
for (const [key, value] of Object.entries(query || {})) {
|
|
776
|
+
if (value == null) continue;
|
|
777
|
+
let serializedValue;
|
|
778
|
+
if (typeof value === "string") serializedValue = value;
|
|
779
|
+
else if (Array.isArray(value)) {
|
|
780
|
+
for (const val of value) queryParams.append(key, val);
|
|
781
|
+
continue;
|
|
782
|
+
} else serializedValue = JSON.stringify(value);
|
|
783
|
+
queryParams.set(key, serializedValue);
|
|
784
|
+
}
|
|
785
|
+
const pathParams = /* @__PURE__ */ new Map();
|
|
786
|
+
if (params) if (Array.isArray(params)) {
|
|
787
|
+
const paramPaths = path.split("/").filter((p) => p.startsWith(":"));
|
|
788
|
+
for (const [index, key] of paramPaths.entries()) {
|
|
789
|
+
const value = params[index];
|
|
790
|
+
pathParams.set(key, String(value));
|
|
791
|
+
}
|
|
792
|
+
} else for (const [key, value] of Object.entries(params)) pathParams.set(`:${key}`, String(value));
|
|
793
|
+
path = path.split("/").map((segment) => resolvePathSegment(segment, pathParams)).join("/");
|
|
794
|
+
path = path.replace(/^\/+/, "");
|
|
795
|
+
let queryParamString = queryParams.toString();
|
|
796
|
+
queryParamString = queryParamString.length > 0 ? `?${queryParamString}`.replace(/\+/g, "%20") : "";
|
|
797
|
+
if (!basePath.startsWith("http")) return `${basePath}${path}${queryParamString}`;
|
|
798
|
+
return new URL(`${path}${queryParamString}`, basePath);
|
|
799
|
+
}
|
|
740
800
|
var getAuthHeader = async (options) => {
|
|
741
801
|
const headers = {};
|
|
742
802
|
const getValue = async (value) => typeof value === "function" ? await value() : value;
|
|
743
|
-
if (options
|
|
803
|
+
if (options === null || options === void 0 ? void 0 : options.auth) {
|
|
744
804
|
if (options.auth.type === "Bearer") {
|
|
745
805
|
const token = await getValue(options.auth.token);
|
|
746
806
|
if (!token) return headers;
|
|
@@ -752,7 +812,7 @@ var getAuthHeader = async (options) => {
|
|
|
752
812
|
} else if (options.auth.type === "Custom") {
|
|
753
813
|
const [prefix, value] = await Promise.all([getValue(options.auth.prefix), getValue(options.auth.value)]);
|
|
754
814
|
if (!value) return headers;
|
|
755
|
-
headers["authorization"] = `${prefix
|
|
815
|
+
headers["authorization"] = `${prefix !== null && prefix !== void 0 ? prefix : ""} ${value}`;
|
|
756
816
|
}
|
|
757
817
|
}
|
|
758
818
|
return headers;
|
|
@@ -800,7 +860,7 @@ function isFunction(value) {
|
|
|
800
860
|
return typeof value === "function";
|
|
801
861
|
}
|
|
802
862
|
function getFetch(options) {
|
|
803
|
-
if (options
|
|
863
|
+
if (options === null || options === void 0 ? void 0 : options.customFetchImpl) return options.customFetchImpl;
|
|
804
864
|
if (typeof globalThis !== "undefined" && isFunction(globalThis.fetch)) return globalThis.fetch;
|
|
805
865
|
if (typeof window !== "undefined" && isFunction(window.fetch)) return window.fetch;
|
|
806
866
|
throw new Error("No fetch implementation found");
|
|
@@ -820,9 +880,9 @@ function mergeHeaders(...sources) {
|
|
|
820
880
|
return merged;
|
|
821
881
|
}
|
|
822
882
|
async function getHeaders(opts) {
|
|
823
|
-
const headers = new Headers(mergeHeaders(opts
|
|
883
|
+
const headers = new Headers(mergeHeaders(opts === null || opts === void 0 ? void 0 : opts.headers, await getAuthHeader(opts)));
|
|
824
884
|
if (!headers.has("content-type")) {
|
|
825
|
-
const contentType = detectContentType(opts
|
|
885
|
+
const contentType = detectContentType(opts === null || opts === void 0 ? void 0 : opts.body);
|
|
826
886
|
if (contentType) headers.set("content-type", contentType);
|
|
827
887
|
}
|
|
828
888
|
return headers;
|
|
@@ -844,18 +904,14 @@ function getBody(options, headers) {
|
|
|
844
904
|
return JSON.stringify(body);
|
|
845
905
|
}
|
|
846
906
|
function getMethod$1(url, options) {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
if (
|
|
850
|
-
|
|
851
|
-
if (!methods.includes(pMethod)) return (options == null ? void 0 : options.body) ? "POST" : "GET";
|
|
852
|
-
return pMethod.toUpperCase();
|
|
853
|
-
}
|
|
854
|
-
return (options == null ? void 0 : options.body) ? "POST" : "GET";
|
|
907
|
+
if (options === null || options === void 0 ? void 0 : options.method) return options.method.toUpperCase();
|
|
908
|
+
const { method } = parseMethodModifier(url);
|
|
909
|
+
if (method) return method.toUpperCase();
|
|
910
|
+
return (options === null || options === void 0 ? void 0 : options.body) ? "POST" : "GET";
|
|
855
911
|
}
|
|
856
912
|
function getTimeout(options, controller) {
|
|
857
913
|
let abortTimeout;
|
|
858
|
-
if (!(options
|
|
914
|
+
if (!(options === null || options === void 0 ? void 0 : options.signal) && (options === null || options === void 0 ? void 0 : options.timeout)) abortTimeout = setTimeout(() => controller === null || controller === void 0 ? void 0 : controller.abort(), options === null || options === void 0 ? void 0 : options.timeout);
|
|
859
915
|
return {
|
|
860
916
|
abortTimeout,
|
|
861
917
|
clearTimeout: () => {
|
|
@@ -863,11 +919,11 @@ function getTimeout(options, controller) {
|
|
|
863
919
|
}
|
|
864
920
|
};
|
|
865
921
|
}
|
|
866
|
-
var ValidationError = class
|
|
922
|
+
var ValidationError = class ValidationError extends Error {
|
|
867
923
|
constructor(issues, message) {
|
|
868
924
|
super(message || JSON.stringify(issues, null, 2));
|
|
869
925
|
this.issues = issues;
|
|
870
|
-
Object.setPrototypeOf(this,
|
|
926
|
+
Object.setPrototypeOf(this, ValidationError.prototype);
|
|
871
927
|
}
|
|
872
928
|
};
|
|
873
929
|
async function parseStandardSchema(schema, input) {
|
|
@@ -875,186 +931,100 @@ async function parseStandardSchema(schema, input) {
|
|
|
875
931
|
if (result.issues) throw new ValidationError(result.issues);
|
|
876
932
|
return result.value;
|
|
877
933
|
}
|
|
878
|
-
|
|
879
|
-
"
|
|
880
|
-
"
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
var applySchemaPlugin = (config) => ({
|
|
886
|
-
id: "apply-schema",
|
|
887
|
-
name: "Apply Schema",
|
|
888
|
-
version: "1.0.0",
|
|
889
|
-
async init(url, options) {
|
|
890
|
-
var _a, _b, _c, _d;
|
|
891
|
-
const schema = ((_b = (_a = config.plugins) == null ? void 0 : _a.find((plugin) => {
|
|
892
|
-
var _a2;
|
|
893
|
-
return ((_a2 = plugin.schema) == null ? void 0 : _a2.config) ? url.startsWith(plugin.schema.config.baseURL || "") || url.startsWith(plugin.schema.config.prefix || "") : false;
|
|
894
|
-
})) == null ? void 0 : _b.schema) || config.schema;
|
|
895
|
-
if (schema) {
|
|
896
|
-
let urlKey = url;
|
|
897
|
-
if ((_c = schema.config) == null ? void 0 : _c.prefix) {
|
|
898
|
-
if (urlKey.startsWith(schema.config.prefix)) {
|
|
899
|
-
urlKey = urlKey.replace(schema.config.prefix, "");
|
|
900
|
-
if (schema.config.baseURL) url = url.replace(schema.config.prefix, schema.config.baseURL);
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
if ((_d = schema.config) == null ? void 0 : _d.baseURL) {
|
|
904
|
-
if (urlKey.startsWith(schema.config.baseURL)) urlKey = urlKey.replace(schema.config.baseURL, "");
|
|
905
|
-
}
|
|
906
|
-
if (urlKey.startsWith("/") && urlKey.charAt(1) === "@") urlKey = urlKey.substring(1);
|
|
907
|
-
const keySchema = schema.schema[urlKey];
|
|
908
|
-
if (keySchema) {
|
|
909
|
-
let validatedHeaders = options == null ? void 0 : options.headers;
|
|
910
|
-
if (keySchema.headers && !(options == null ? void 0 : options.disableValidation)) {
|
|
911
|
-
const normalizedHeaders = {};
|
|
912
|
-
if (options == null ? void 0 : options.headers) {
|
|
913
|
-
if (options.headers instanceof Headers) options.headers.forEach((value, key) => {
|
|
914
|
-
normalizedHeaders[key.toLowerCase()] = value;
|
|
915
|
-
});
|
|
916
|
-
else if (typeof options.headers === "object") {
|
|
917
|
-
for (const [key, value] of Object.entries(options.headers)) if (value !== null && value !== void 0) normalizedHeaders[key.toLowerCase()] = value;
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
const validated = await parseStandardSchema(keySchema.headers, normalizedHeaders);
|
|
921
|
-
const finalHeaders = {};
|
|
922
|
-
for (const [key, value] of Object.entries(validated)) finalHeaders[key.toLowerCase()] = value;
|
|
923
|
-
validatedHeaders = finalHeaders;
|
|
924
|
-
}
|
|
925
|
-
let opts = __spreadProps(__spreadValues({}, options), {
|
|
926
|
-
method: keySchema.method,
|
|
927
|
-
output: keySchema.output,
|
|
928
|
-
headers: validatedHeaders
|
|
929
|
-
});
|
|
930
|
-
if (!(options == null ? void 0 : options.disableValidation)) opts = __spreadProps(__spreadValues({}, opts), {
|
|
931
|
-
body: keySchema.input ? await parseStandardSchema(keySchema.input, options == null ? void 0 : options.body) : options == null ? void 0 : options.body,
|
|
932
|
-
params: keySchema.params ? await parseStandardSchema(keySchema.params, options == null ? void 0 : options.params) : options == null ? void 0 : options.params,
|
|
933
|
-
query: keySchema.query ? await parseStandardSchema(keySchema.query, options == null ? void 0 : options.query) : options == null ? void 0 : options.query
|
|
934
|
-
});
|
|
935
|
-
return {
|
|
936
|
-
url,
|
|
937
|
-
options: opts
|
|
938
|
-
};
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
return {
|
|
942
|
-
url,
|
|
943
|
-
options
|
|
944
|
-
};
|
|
945
|
-
}
|
|
946
|
-
});
|
|
947
|
-
var createFetch = (config) => {
|
|
948
|
-
async function $fetch(url, options) {
|
|
949
|
-
const opts = __spreadProps(__spreadValues(__spreadValues({}, config), options), {
|
|
950
|
-
headers: mergeHeaders(config == null ? void 0 : config.headers, options == null ? void 0 : options.headers),
|
|
951
|
-
plugins: [
|
|
952
|
-
...(config == null ? void 0 : config.plugins) || [],
|
|
953
|
-
applySchemaPlugin(config || {}),
|
|
954
|
-
...(options == null ? void 0 : options.plugins) || []
|
|
955
|
-
]
|
|
956
|
-
});
|
|
957
|
-
if (config == null ? void 0 : config.catchAllError) try {
|
|
958
|
-
return await betterFetch(url, opts);
|
|
959
|
-
} catch (error) {
|
|
960
|
-
return {
|
|
961
|
-
data: null,
|
|
962
|
-
error: {
|
|
963
|
-
status: 500,
|
|
964
|
-
statusText: "Fetch Error",
|
|
965
|
-
message: "Fetch related error. Captured by catchAllError option. See error property for more details.",
|
|
966
|
-
error
|
|
967
|
-
}
|
|
968
|
-
};
|
|
969
|
-
}
|
|
970
|
-
return await betterFetch(url, opts);
|
|
971
|
-
}
|
|
972
|
-
return $fetch;
|
|
973
|
-
};
|
|
974
|
-
var isReservedPathSegment = (value) => value === "." || value === "..";
|
|
975
|
-
function encodePathSegment(segment, pathParams) {
|
|
976
|
-
let pathSegment = segment;
|
|
977
|
-
for (const [key, value] of pathParams) pathSegment = pathSegment.replace(key, value);
|
|
978
|
-
if (isReservedPathSegment(pathSegment)) throw new TypeError("Path parameters cannot be reserved path segments");
|
|
979
|
-
return encodeURIComponent(pathSegment);
|
|
934
|
+
function _typeof(o) {
|
|
935
|
+
"@babel/helpers - typeof";
|
|
936
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
937
|
+
return typeof o;
|
|
938
|
+
} : function(o) {
|
|
939
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
940
|
+
}, _typeof(o);
|
|
980
941
|
}
|
|
981
|
-
function
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
if (url.startsWith("@")) {
|
|
989
|
-
const m = url.toString().split("@")[1].split("/")[0];
|
|
990
|
-
if (methods.includes(m)) url = url.replace(`@${m}/`, "/");
|
|
942
|
+
function toPrimitive(t, r) {
|
|
943
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
944
|
+
var e = t[Symbol.toPrimitive];
|
|
945
|
+
if (void 0 !== e) {
|
|
946
|
+
var i = e.call(t, r || "default");
|
|
947
|
+
if ("object" != _typeof(i)) return i;
|
|
948
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
991
949
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
950
|
+
return ("string" === r ? String : Number)(t);
|
|
951
|
+
}
|
|
952
|
+
function toPropertyKey(t) {
|
|
953
|
+
var i = toPrimitive(t, "string");
|
|
954
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
955
|
+
}
|
|
956
|
+
function _defineProperty(e, r, t) {
|
|
957
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
958
|
+
value: t,
|
|
959
|
+
enumerable: !0,
|
|
960
|
+
configurable: !0,
|
|
961
|
+
writable: !0
|
|
962
|
+
}) : e[r] = t, e;
|
|
963
|
+
}
|
|
964
|
+
function ownKeys(e, r) {
|
|
965
|
+
var t = Object.keys(e);
|
|
966
|
+
if (Object.getOwnPropertySymbols) {
|
|
967
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
968
|
+
r && (o = o.filter(function(r) {
|
|
969
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
970
|
+
})), t.push.apply(t, o);
|
|
1004
971
|
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
972
|
+
return t;
|
|
973
|
+
}
|
|
974
|
+
function _objectSpread2(e) {
|
|
975
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
976
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
977
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
978
|
+
_defineProperty(e, r, t[r]);
|
|
979
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
980
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
981
|
+
});
|
|
1014
982
|
}
|
|
1015
|
-
|
|
1016
|
-
path = path.replace(/^\/+/, "");
|
|
1017
|
-
let queryParamString = queryParams.toString();
|
|
1018
|
-
queryParamString = queryParamString.length > 0 ? `?${queryParamString}`.replace(/\+/g, "%20") : "";
|
|
1019
|
-
if (!basePath.startsWith("http")) return `${basePath}${path}${queryParamString}`;
|
|
1020
|
-
return new URL(`${path}${queryParamString}`, basePath);
|
|
983
|
+
return e;
|
|
1021
984
|
}
|
|
1022
985
|
var betterFetch = async (url, options) => {
|
|
1023
|
-
var
|
|
986
|
+
var _opts$signal, _options$body, _options$jsonParser;
|
|
1024
987
|
const { hooks, url: __url, options: opts } = await initializePlugins(url, options);
|
|
1025
988
|
const fetch = getFetch(opts);
|
|
1026
989
|
const controller = new AbortController();
|
|
1027
|
-
const signal = (
|
|
1028
|
-
const _url =
|
|
990
|
+
const signal = (_opts$signal = opts.signal) !== null && _opts$signal !== void 0 ? _opts$signal : controller.signal;
|
|
991
|
+
const _url = getURL$1(__url, opts);
|
|
1029
992
|
const headers = await getHeaders(opts);
|
|
1030
993
|
const body = getBody(opts, headers);
|
|
1031
994
|
const method = getMethod$1(__url, opts);
|
|
1032
|
-
const context =
|
|
995
|
+
const context = _objectSpread2(_objectSpread2({}, opts), {}, {
|
|
1033
996
|
url: _url,
|
|
1034
997
|
headers,
|
|
1035
998
|
body,
|
|
1036
999
|
method,
|
|
1037
1000
|
signal
|
|
1038
1001
|
});
|
|
1002
|
+
/**
|
|
1003
|
+
* Run all on request hooks
|
|
1004
|
+
*/
|
|
1039
1005
|
for (const onRequest of hooks.onRequest) if (onRequest) {
|
|
1040
1006
|
const res = await onRequest(context);
|
|
1041
1007
|
if (typeof res === "object" && res !== null) Object.assign(context, res);
|
|
1042
1008
|
}
|
|
1043
|
-
if ("pipeTo" in context && typeof context.pipeTo === "function" || typeof (
|
|
1009
|
+
if ("pipeTo" in context && typeof context.pipeTo === "function" || typeof (options === null || options === void 0 || (_options$body = options.body) === null || _options$body === void 0 ? void 0 : _options$body.pipe) === "function") {
|
|
1044
1010
|
if (!("duplex" in context)) context.duplex = "half";
|
|
1045
1011
|
}
|
|
1046
|
-
const { clearTimeout
|
|
1012
|
+
const { clearTimeout } = getTimeout(opts, controller);
|
|
1047
1013
|
let response = await fetch(context.url, context);
|
|
1048
|
-
|
|
1014
|
+
clearTimeout();
|
|
1049
1015
|
const responseContext = {
|
|
1050
1016
|
response,
|
|
1051
1017
|
request: context
|
|
1052
1018
|
};
|
|
1053
1019
|
for (const onResponse of hooks.onResponse) if (onResponse) {
|
|
1054
|
-
|
|
1020
|
+
var _options$hookOptions;
|
|
1021
|
+
const r = await onResponse(_objectSpread2(_objectSpread2({}, responseContext), {}, { response: (options === null || options === void 0 || (_options$hookOptions = options.hookOptions) === null || _options$hookOptions === void 0 ? void 0 : _options$hookOptions.cloneResponse) ? response.clone() : response }));
|
|
1055
1022
|
if (r instanceof Response) response = r;
|
|
1056
1023
|
else if (typeof r === "object" && r !== null) response = r.response;
|
|
1057
1024
|
}
|
|
1025
|
+
/**
|
|
1026
|
+
* OK Branch
|
|
1027
|
+
*/
|
|
1058
1028
|
if (response.ok) {
|
|
1059
1029
|
if (!(context.method !== "HEAD")) return {
|
|
1060
1030
|
data: "",
|
|
@@ -1067,54 +1037,165 @@ var betterFetch = async (url, options) => {
|
|
|
1067
1037
|
request: context
|
|
1068
1038
|
};
|
|
1069
1039
|
if (responseType === "json" || responseType === "text") {
|
|
1040
|
+
var _context$jsonParser;
|
|
1070
1041
|
const text = await response.text();
|
|
1071
|
-
successContext.data = await ((
|
|
1042
|
+
successContext.data = await ((_context$jsonParser = context.jsonParser) !== null && _context$jsonParser !== void 0 ? _context$jsonParser : jsonParse)(text);
|
|
1072
1043
|
} else successContext.data = await response[responseType]();
|
|
1073
|
-
|
|
1044
|
+
/**
|
|
1045
|
+
* Parse the data if the output schema is defined
|
|
1046
|
+
*/
|
|
1047
|
+
if (context === null || context === void 0 ? void 0 : context.output) {
|
|
1074
1048
|
if (context.output && !context.disableValidation) successContext.data = await parseStandardSchema(context.output, successContext.data);
|
|
1075
1049
|
}
|
|
1076
|
-
for (const onSuccess of hooks.onSuccess) if (onSuccess)
|
|
1077
|
-
|
|
1050
|
+
for (const onSuccess of hooks.onSuccess) if (onSuccess) {
|
|
1051
|
+
var _options$hookOptions2;
|
|
1052
|
+
await onSuccess(_objectSpread2(_objectSpread2({}, successContext), {}, { response: (options === null || options === void 0 || (_options$hookOptions2 = options.hookOptions) === null || _options$hookOptions2 === void 0 ? void 0 : _options$hookOptions2.cloneResponse) ? response.clone() : response }));
|
|
1053
|
+
}
|
|
1054
|
+
if (options === null || options === void 0 ? void 0 : options.throw) return successContext.data;
|
|
1078
1055
|
return {
|
|
1079
1056
|
data: successContext.data,
|
|
1080
1057
|
error: null
|
|
1081
1058
|
};
|
|
1082
1059
|
}
|
|
1083
|
-
const parser = (
|
|
1060
|
+
const parser = (_options$jsonParser = options === null || options === void 0 ? void 0 : options.jsonParser) !== null && _options$jsonParser !== void 0 ? _options$jsonParser : jsonParse;
|
|
1084
1061
|
const responseText = await response.text();
|
|
1085
1062
|
const isJSONResponse = isJSONParsable(responseText);
|
|
1086
1063
|
const errorObject = isJSONResponse ? await parser(responseText) : null;
|
|
1064
|
+
/**
|
|
1065
|
+
* Error Branch
|
|
1066
|
+
*/
|
|
1087
1067
|
const errorContext = {
|
|
1088
1068
|
response,
|
|
1089
1069
|
responseText,
|
|
1090
1070
|
request: context,
|
|
1091
|
-
error:
|
|
1071
|
+
error: _objectSpread2(_objectSpread2({}, errorObject), {}, {
|
|
1092
1072
|
status: response.status,
|
|
1093
1073
|
statusText: response.statusText
|
|
1094
1074
|
})
|
|
1095
1075
|
};
|
|
1096
|
-
for (const onError of hooks.onError) if (onError)
|
|
1097
|
-
|
|
1076
|
+
for (const onError of hooks.onError) if (onError) {
|
|
1077
|
+
var _options$hookOptions3;
|
|
1078
|
+
await onError(_objectSpread2(_objectSpread2({}, errorContext), {}, { response: (options === null || options === void 0 || (_options$hookOptions3 = options.hookOptions) === null || _options$hookOptions3 === void 0 ? void 0 : _options$hookOptions3.cloneResponse) ? response.clone() : response }));
|
|
1079
|
+
}
|
|
1080
|
+
if (options === null || options === void 0 ? void 0 : options.retry) {
|
|
1081
|
+
var _options$retryAttempt;
|
|
1098
1082
|
const retryStrategy = createRetryStrategy(options.retry);
|
|
1099
|
-
const _retryAttempt = (
|
|
1083
|
+
const _retryAttempt = (_options$retryAttempt = options.retryAttempt) !== null && _options$retryAttempt !== void 0 ? _options$retryAttempt : 0;
|
|
1100
1084
|
if (await retryStrategy.shouldAttemptRetry(_retryAttempt, response)) {
|
|
1101
1085
|
for (const onRetry of hooks.onRetry) if (onRetry) await onRetry(responseContext);
|
|
1102
1086
|
const delay = retryStrategy.getDelay(_retryAttempt);
|
|
1103
1087
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1104
|
-
return await betterFetch(url,
|
|
1088
|
+
return await betterFetch(url, _objectSpread2(_objectSpread2({}, options), {}, { retryAttempt: _retryAttempt + 1 }));
|
|
1105
1089
|
}
|
|
1106
1090
|
}
|
|
1107
|
-
if (options
|
|
1091
|
+
if (options === null || options === void 0 ? void 0 : options.throw) throw new BetterFetchError(response.status, response.statusText, isJSONResponse ? errorObject : responseText);
|
|
1108
1092
|
return {
|
|
1109
1093
|
data: null,
|
|
1110
|
-
error:
|
|
1094
|
+
error: _objectSpread2(_objectSpread2({}, errorObject), {}, {
|
|
1111
1095
|
status: response.status,
|
|
1112
1096
|
statusText: response.statusText
|
|
1113
1097
|
})
|
|
1114
1098
|
};
|
|
1115
1099
|
};
|
|
1100
|
+
var applySchemaPlugin = (config) => ({
|
|
1101
|
+
id: "apply-schema",
|
|
1102
|
+
name: "Apply Schema",
|
|
1103
|
+
version: "1.0.0",
|
|
1104
|
+
async init(url, options) {
|
|
1105
|
+
var _config$plugins;
|
|
1106
|
+
let opts = _objectSpread2(_objectSpread2({}, options), config.query !== void 0 && { query: _objectSpread2(_objectSpread2({}, config.query), options === null || options === void 0 ? void 0 : options.query) });
|
|
1107
|
+
const schema = ((_config$plugins = config.plugins) === null || _config$plugins === void 0 || (_config$plugins = _config$plugins.find((plugin) => {
|
|
1108
|
+
var _plugin$schema;
|
|
1109
|
+
return ((_plugin$schema = plugin.schema) === null || _plugin$schema === void 0 ? void 0 : _plugin$schema.config) ? url.startsWith(plugin.schema.config.baseURL || "") || url.startsWith(plugin.schema.config.prefix || "") : false;
|
|
1110
|
+
})) === null || _config$plugins === void 0 ? void 0 : _config$plugins.schema) || config.schema;
|
|
1111
|
+
if (schema) {
|
|
1112
|
+
var _schema$config, _schema$config2;
|
|
1113
|
+
let urlKey = url;
|
|
1114
|
+
if ((_schema$config = schema.config) === null || _schema$config === void 0 ? void 0 : _schema$config.prefix) {
|
|
1115
|
+
if (urlKey.startsWith(schema.config.prefix)) {
|
|
1116
|
+
urlKey = urlKey.replace(schema.config.prefix, "");
|
|
1117
|
+
if (schema.config.baseURL) url = url.replace(schema.config.prefix, schema.config.baseURL);
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
if ((_schema$config2 = schema.config) === null || _schema$config2 === void 0 ? void 0 : _schema$config2.baseURL) {
|
|
1121
|
+
if (urlKey.startsWith(schema.config.baseURL)) urlKey = urlKey.replace(schema.config.baseURL, "");
|
|
1122
|
+
}
|
|
1123
|
+
if (urlKey.startsWith("/") && urlKey.charAt(1) === "@") urlKey = urlKey.substring(1);
|
|
1124
|
+
const keySchema = schema.schema[urlKey];
|
|
1125
|
+
if (keySchema) {
|
|
1126
|
+
var _keySchema$method;
|
|
1127
|
+
const { method: schemaMethod, path } = parseMethodModifier(urlKey);
|
|
1128
|
+
if (schemaMethod) url = url.slice(0, url.length - urlKey.length) + path;
|
|
1129
|
+
let validatedHeaders = options === null || options === void 0 ? void 0 : options.headers;
|
|
1130
|
+
if (keySchema.headers && !(options === null || options === void 0 ? void 0 : options.disableValidation)) {
|
|
1131
|
+
const normalizedHeaders = {};
|
|
1132
|
+
if (options === null || options === void 0 ? void 0 : options.headers) {
|
|
1133
|
+
if (options.headers instanceof Headers) options.headers.forEach((value, key) => {
|
|
1134
|
+
normalizedHeaders[key.toLowerCase()] = value;
|
|
1135
|
+
});
|
|
1136
|
+
else if (typeof options.headers === "object") {
|
|
1137
|
+
for (const [key, value] of Object.entries(options.headers)) if (value !== null && value !== void 0) normalizedHeaders[key.toLowerCase()] = value;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
const validated = await parseStandardSchema(keySchema.headers, normalizedHeaders);
|
|
1141
|
+
const finalHeaders = {};
|
|
1142
|
+
for (const [key, value] of Object.entries(validated)) finalHeaders[key.toLowerCase()] = value;
|
|
1143
|
+
validatedHeaders = finalHeaders;
|
|
1144
|
+
}
|
|
1145
|
+
const method = (_keySchema$method = keySchema.method) !== null && _keySchema$method !== void 0 ? _keySchema$method : schemaMethod;
|
|
1146
|
+
opts = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, opts), method !== void 0 && { method }), keySchema.output !== void 0 && { output: keySchema.output }), validatedHeaders !== void 0 && { headers: validatedHeaders });
|
|
1147
|
+
if (!(options === null || options === void 0 ? void 0 : options.disableValidation)) {
|
|
1148
|
+
if (keySchema.query) {
|
|
1149
|
+
opts.query = await parseStandardSchema(keySchema.query, options === null || options === void 0 ? void 0 : options.query);
|
|
1150
|
+
if (opts.query !== null && typeof opts.query === "object") {
|
|
1151
|
+
const defaults = _objectSpread2({}, config.query);
|
|
1152
|
+
for (const key of Object.keys(defaults)) if ((options === null || options === void 0 ? void 0 : options.query) && Object.prototype.hasOwnProperty.call(options.query, key)) defaults[key] = options.query[key];
|
|
1153
|
+
opts.query = _objectSpread2(_objectSpread2({}, defaults), opts.query);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
opts = _objectSpread2(_objectSpread2({}, opts), {}, {
|
|
1157
|
+
body: keySchema.input ? await parseStandardSchema(keySchema.input, options === null || options === void 0 ? void 0 : options.body) : options === null || options === void 0 ? void 0 : options.body,
|
|
1158
|
+
params: keySchema.params ? await parseStandardSchema(keySchema.params, options === null || options === void 0 ? void 0 : options.params) : options === null || options === void 0 ? void 0 : options.params
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
return {
|
|
1162
|
+
url,
|
|
1163
|
+
options: opts
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
return _objectSpread2({ url }, (options !== void 0 || config.query !== void 0) && { options: opts });
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
var createFetch = (config) => {
|
|
1171
|
+
async function $fetch(url, options) {
|
|
1172
|
+
const opts = _objectSpread2(_objectSpread2(_objectSpread2({}, config), options), {}, {
|
|
1173
|
+
headers: mergeHeaders(config === null || config === void 0 ? void 0 : config.headers, options === null || options === void 0 ? void 0 : options.headers),
|
|
1174
|
+
plugins: [
|
|
1175
|
+
...(config === null || config === void 0 ? void 0 : config.plugins) || [],
|
|
1176
|
+
applySchemaPlugin(config || {}),
|
|
1177
|
+
...(options === null || options === void 0 ? void 0 : options.plugins) || []
|
|
1178
|
+
]
|
|
1179
|
+
});
|
|
1180
|
+
if (config === null || config === void 0 ? void 0 : config.catchAllError) try {
|
|
1181
|
+
return await betterFetch(url, opts);
|
|
1182
|
+
} catch (error) {
|
|
1183
|
+
return {
|
|
1184
|
+
data: null,
|
|
1185
|
+
error: {
|
|
1186
|
+
status: 500,
|
|
1187
|
+
statusText: "Fetch Error",
|
|
1188
|
+
message: "Fetch related error. Captured by catchAllError option. See error property for more details.",
|
|
1189
|
+
error
|
|
1190
|
+
}
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
return await betterFetch(url, opts);
|
|
1194
|
+
}
|
|
1195
|
+
return $fetch;
|
|
1196
|
+
};
|
|
1116
1197
|
//#endregion
|
|
1117
|
-
//#region ../node_modules/.bun/better-auth@1.7.
|
|
1198
|
+
//#region ../node_modules/.bun/better-auth@1.7.7+7ee5f890295c53f0/node_modules/better-auth/dist/client/config.mjs
|
|
1118
1199
|
var resolvePublicAuthUrl = (basePath) => {
|
|
1119
1200
|
if (typeof process === "undefined") return void 0;
|
|
1120
1201
|
const path = basePath ?? "/api/auth";
|
|
@@ -1129,6 +1210,7 @@ var resolvePublicAuthUrl = (basePath) => {
|
|
|
1129
1210
|
} catch {}
|
|
1130
1211
|
}
|
|
1131
1212
|
};
|
|
1213
|
+
var matchesSessionSignal = (path) => path === "/sign-out" || path === "/update-user" || path === "/update-session" || path === "/sign-up/email" || path === "/sign-in/email" || path === "/delete-user" || path === "/verify-email" || path === "/revoke-sessions" || path === "/revoke-session" || path === "/revoke-other-sessions" || path === "/change-email" || path === "/change-password";
|
|
1132
1214
|
var getClientConfig = (options, loadEnv) => {
|
|
1133
1215
|
const isCredentialsSupported = "credentials" in Request.prototype;
|
|
1134
1216
|
const baseURL = getBaseURL(options?.baseURL, options?.basePath, void 0, loadEnv) ?? resolvePublicAuthUrl(options?.basePath) ?? "/api/auth";
|
|
@@ -1182,9 +1264,7 @@ var getClientConfig = (options, loadEnv) => {
|
|
|
1182
1264
|
};
|
|
1183
1265
|
const atomListeners = [{
|
|
1184
1266
|
signal: "$sessionSignal",
|
|
1185
|
-
matcher
|
|
1186
|
-
return path === "/sign-out" || path === "/update-user" || path === "/update-session" || path === "/sign-up/email" || path === "/sign-in/email" || path === "/delete-user" || path === "/verify-email" || path === "/revoke-sessions" || path === "/revoke-session" || path === "/revoke-other-sessions" || path === "/change-email" || path === "/change-password";
|
|
1187
|
-
},
|
|
1267
|
+
matcher: matchesSessionSignal,
|
|
1188
1268
|
callback(path) {
|
|
1189
1269
|
if (path === "/sign-out") broadcastSessionUpdate("signout");
|
|
1190
1270
|
else if (path === "/update-user" || path === "/update-session") broadcastSessionUpdate("updateUser");
|
|
@@ -1214,17 +1294,18 @@ var getClientConfig = (options, loadEnv) => {
|
|
|
1214
1294
|
pluginPathMethods,
|
|
1215
1295
|
atomListeners,
|
|
1216
1296
|
hydrateSession,
|
|
1297
|
+
$sessionSignal,
|
|
1217
1298
|
$fetch,
|
|
1218
1299
|
$store
|
|
1219
1300
|
};
|
|
1220
1301
|
};
|
|
1221
1302
|
//#endregion
|
|
1222
|
-
//#region ../node_modules/.bun/better-auth@1.7.
|
|
1303
|
+
//#region ../node_modules/.bun/better-auth@1.7.7+7ee5f890295c53f0/node_modules/better-auth/dist/utils/is-atom.mjs
|
|
1223
1304
|
function isAtom(value) {
|
|
1224
1305
|
return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
|
|
1225
1306
|
}
|
|
1226
1307
|
//#endregion
|
|
1227
|
-
//#region ../node_modules/.bun/better-auth@1.7.
|
|
1308
|
+
//#region ../node_modules/.bun/better-auth@1.7.7+7ee5f890295c53f0/node_modules/better-auth/dist/client/proxy.mjs
|
|
1228
1309
|
function getMethod(path, knownPathMethods, args) {
|
|
1229
1310
|
const method = knownPathMethods[path];
|
|
1230
1311
|
const { fetchOptions, query: _query, ...body } = args || {};
|
|
@@ -1299,7 +1380,7 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
|
|
|
1299
1380
|
return createProxy();
|
|
1300
1381
|
}
|
|
1301
1382
|
//#endregion
|
|
1302
|
-
//#region ../node_modules/.bun/better-auth@1.7.
|
|
1383
|
+
//#region ../node_modules/.bun/better-auth@1.7.7+7ee5f890295c53f0/node_modules/better-auth/dist/client/vanilla.mjs
|
|
1303
1384
|
function createAuthClient(options) {
|
|
1304
1385
|
const { pluginPathMethods, pluginsActions, pluginsAtoms, hydrateSession, $fetch, atomListeners, $store } = getClientConfig(options);
|
|
1305
1386
|
const resolvedHooks = {};
|