@access-dlsu/leapify 0.260507.4 → 0.260524.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.
Files changed (139) hide show
  1. package/dist/app.d.ts.map +1 -1
  2. package/dist/auth/auth.d.ts.map +1 -1
  3. package/dist/auth/middleware.d.ts.map +1 -1
  4. package/dist/chunk-64MMUYMK.cjs +167 -0
  5. package/dist/chunk-64MMUYMK.cjs.map +1 -0
  6. package/dist/chunk-AKCERDGP.js +161 -0
  7. package/dist/chunk-AKCERDGP.js.map +1 -0
  8. package/dist/client/auth.d.ts +1 -13
  9. package/dist/client/auth.d.ts.map +1 -1
  10. package/dist/client/index.cjs +55 -841
  11. package/dist/client/index.cjs.map +1 -1
  12. package/dist/client/index.d.ts +3 -8
  13. package/dist/client/index.d.ts.map +1 -1
  14. package/dist/client/index.js +53 -839
  15. package/dist/client/index.js.map +1 -1
  16. package/dist/client/turnstile.d.ts +25 -0
  17. package/dist/client/turnstile.d.ts.map +1 -0
  18. package/dist/client/types.d.ts +2 -15
  19. package/dist/client/types.d.ts.map +1 -1
  20. package/dist/db/migrate.d.ts.map +1 -1
  21. package/dist/db/schema/classes.d.ts +0 -19
  22. package/dist/db/schema/classes.d.ts.map +1 -1
  23. package/dist/db/schema/site-config.d.ts +0 -83
  24. package/dist/db/schema/site-config.d.ts.map +1 -1
  25. package/dist/index.cjs +687 -38309
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.ts +3 -5
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +541 -38156
  30. package/dist/index.js.map +1 -1
  31. package/dist/lib/middleware/cors.d.ts.map +1 -1
  32. package/dist/lib/middleware/rate-limit.d.ts.map +1 -1
  33. package/dist/lib/middleware/referer-guard.d.ts.map +1 -1
  34. package/dist/lib/middleware/turnstile-challenge.cjs +29 -0
  35. package/dist/lib/middleware/turnstile-challenge.cjs.map +1 -0
  36. package/dist/lib/middleware/turnstile-challenge.d.ts +45 -0
  37. package/dist/lib/middleware/turnstile-challenge.d.ts.map +1 -0
  38. package/dist/lib/middleware/turnstile-challenge.js +4 -0
  39. package/dist/lib/middleware/turnstile-challenge.js.map +1 -0
  40. package/dist/queues/jobs.d.ts +0 -5
  41. package/dist/queues/jobs.d.ts.map +1 -1
  42. package/dist/routes/classes.d.ts.map +1 -1
  43. package/dist/routes/faqs.d.ts.map +1 -1
  44. package/dist/routes/site-config.d.ts.map +1 -1
  45. package/dist/routes/themes.d.ts.map +1 -1
  46. package/dist/routes/uploads.d.ts.map +1 -1
  47. package/dist/types.d.ts +5 -26
  48. package/dist/types.d.ts.map +1 -1
  49. package/dist/worker-handler.d.ts +1 -0
  50. package/dist/worker-handler.d.ts.map +1 -1
  51. package/dist/worker.js +704 -64338
  52. package/dist/worker.js.map +1 -1
  53. package/package.json +155 -153
  54. package/dist/bun-sqlite-dialect-na--YwnN-NIYANHVJ.cjs +0 -162
  55. package/dist/bun-sqlite-dialect-na--YwnN-NIYANHVJ.cjs.map +0 -1
  56. package/dist/bun-sqlite-dialect-na--YwnN-XVQNOKSL.js +0 -160
  57. package/dist/bun-sqlite-dialect-na--YwnN-XVQNOKSL.js.map +0 -1
  58. package/dist/chunk-4DPT2KQR.cjs +0 -467
  59. package/dist/chunk-4DPT2KQR.cjs.map +0 -1
  60. package/dist/chunk-5JKLV7IE.cjs +0 -2962
  61. package/dist/chunk-5JKLV7IE.cjs.map +0 -1
  62. package/dist/chunk-5OQD5ALM.cjs +0 -76
  63. package/dist/chunk-5OQD5ALM.cjs.map +0 -1
  64. package/dist/chunk-6MMWL46O.cjs +0 -7170
  65. package/dist/chunk-6MMWL46O.cjs.map +0 -1
  66. package/dist/chunk-BFMJDSDI.cjs +0 -2297
  67. package/dist/chunk-BFMJDSDI.cjs.map +0 -1
  68. package/dist/chunk-EGRHWZRV.js +0 -3
  69. package/dist/chunk-EGRHWZRV.js.map +0 -1
  70. package/dist/chunk-EMMSS5I5.cjs +0 -37
  71. package/dist/chunk-EMMSS5I5.cjs.map +0 -1
  72. package/dist/chunk-FUCJEA2S.js +0 -6196
  73. package/dist/chunk-FUCJEA2S.js.map +0 -1
  74. package/dist/chunk-G3PMV62Z.js +0 -33
  75. package/dist/chunk-G3PMV62Z.js.map +0 -1
  76. package/dist/chunk-GNRL67OU.js +0 -2949
  77. package/dist/chunk-GNRL67OU.js.map +0 -1
  78. package/dist/chunk-HHNEB7YR.js +0 -8
  79. package/dist/chunk-HHNEB7YR.js.map +0 -1
  80. package/dist/chunk-IQEWVHLM.js +0 -889
  81. package/dist/chunk-IQEWVHLM.js.map +0 -1
  82. package/dist/chunk-JIZPYG6H.js +0 -72
  83. package/dist/chunk-JIZPYG6H.js.map +0 -1
  84. package/dist/chunk-JPVIXCF5.cjs +0 -10
  85. package/dist/chunk-JPVIXCF5.cjs.map +0 -1
  86. package/dist/chunk-JQSZJWBN.cjs +0 -3075
  87. package/dist/chunk-JQSZJWBN.cjs.map +0 -1
  88. package/dist/chunk-LJ5BSSYE.js +0 -2286
  89. package/dist/chunk-LJ5BSSYE.js.map +0 -1
  90. package/dist/chunk-MCOLCTFX.js +0 -213
  91. package/dist/chunk-MCOLCTFX.js.map +0 -1
  92. package/dist/chunk-MKWVLWVJ.cjs +0 -219
  93. package/dist/chunk-MKWVLWVJ.cjs.map +0 -1
  94. package/dist/chunk-MNEW2V4T.js +0 -447
  95. package/dist/chunk-MNEW2V4T.js.map +0 -1
  96. package/dist/chunk-MY37YE52.js +0 -3034
  97. package/dist/chunk-MY37YE52.js.map +0 -1
  98. package/dist/chunk-NKIQRCOM.cjs +0 -4
  99. package/dist/chunk-NKIQRCOM.cjs.map +0 -1
  100. package/dist/chunk-OK6RVPEH.cjs +0 -6200
  101. package/dist/chunk-OK6RVPEH.cjs.map +0 -1
  102. package/dist/chunk-RFP2X2FA.cjs +0 -903
  103. package/dist/chunk-RFP2X2FA.cjs.map +0 -1
  104. package/dist/chunk-XJSWMHDL.js +0 -7142
  105. package/dist/chunk-XJSWMHDL.js.map +0 -1
  106. package/dist/client/pow.d.ts +0 -28
  107. package/dist/client/pow.d.ts.map +0 -1
  108. package/dist/cron/lifecycle-check.d.ts +0 -10
  109. package/dist/cron/lifecycle-check.d.ts.map +0 -1
  110. package/dist/d1-sqlite-dialect-C2B7YsIT-6TVV7EJ5.js +0 -122
  111. package/dist/d1-sqlite-dialect-C2B7YsIT-6TVV7EJ5.js.map +0 -1
  112. package/dist/d1-sqlite-dialect-C2B7YsIT-PE74FLHQ.cjs +0 -124
  113. package/dist/d1-sqlite-dialect-C2B7YsIT-PE74FLHQ.cjs.map +0 -1
  114. package/dist/dist-DZHA5VYX.cjs +0 -260
  115. package/dist/dist-DZHA5VYX.cjs.map +0 -1
  116. package/dist/dist-RRQUBLLO.js +0 -258
  117. package/dist/dist-RRQUBLLO.js.map +0 -1
  118. package/dist/kysely-adapter-C76KJVG7.js +0 -10
  119. package/dist/kysely-adapter-C76KJVG7.js.map +0 -1
  120. package/dist/kysely-adapter-TGY4UUP5.cjs +0 -27
  121. package/dist/kysely-adapter-TGY4UUP5.cjs.map +0 -1
  122. package/dist/lib/middleware/pow-challenge.cjs +0 -29
  123. package/dist/lib/middleware/pow-challenge.cjs.map +0 -1
  124. package/dist/lib/middleware/pow-challenge.d.ts +0 -58
  125. package/dist/lib/middleware/pow-challenge.d.ts.map +0 -1
  126. package/dist/lib/middleware/pow-challenge.js +0 -4
  127. package/dist/lib/middleware/pow-challenge.js.map +0 -1
  128. package/dist/node-sqlite-dialect-B3H37T3R.cjs +0 -162
  129. package/dist/node-sqlite-dialect-B3H37T3R.cjs.map +0 -1
  130. package/dist/node-sqlite-dialect-GDP7ZE54.js +0 -160
  131. package/dist/node-sqlite-dialect-GDP7ZE54.js.map +0 -1
  132. package/dist/routes/contentful-sync.d.ts +0 -4
  133. package/dist/routes/contentful-sync.d.ts.map +0 -1
  134. package/dist/services/contentful-management.d.ts +0 -38
  135. package/dist/services/contentful-management.d.ts.map +0 -1
  136. package/dist/services/contentful.d.ts +0 -97
  137. package/dist/services/contentful.d.ts.map +0 -1
  138. package/dist/services/snapshot.d.ts +0 -95
  139. package/dist/services/snapshot.d.ts.map +0 -1
@@ -1,903 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk4DPT2KQR_cjs = require('./chunk-4DPT2KQR.cjs');
4
-
5
- // node_modules/better-auth/dist/package.mjs
6
- var version = "1.6.9";
7
-
8
- // node_modules/better-auth/dist/version.mjs
9
- var PACKAGE_VERSION = version;
10
-
11
- // node_modules/better-auth/dist/utils/wildcard.mjs
12
- function escapeRegExpChar(char) {
13
- if (char === "-" || char === "^" || char === "$" || char === "+" || char === "." || char === "(" || char === ")" || char === "|" || char === "[" || char === "]" || char === "{" || char === "}" || char === "*" || char === "?" || char === "\\") return `\\${char}`;
14
- else return char;
15
- }
16
- function escapeRegExpString(str) {
17
- let result = "";
18
- for (let i = 0; i < str.length; i++) result += escapeRegExpChar(str[i]);
19
- return result;
20
- }
21
- function transform(pattern, separator = true) {
22
- if (Array.isArray(pattern)) return `(?:${pattern.map((p) => `^${transform(p, separator)}$`).join("|")})`;
23
- let separatorSplitter = "";
24
- let separatorMatcher = "";
25
- let wildcard = ".";
26
- if (separator === true) {
27
- separatorSplitter = "/";
28
- separatorMatcher = "[/\\\\]";
29
- wildcard = "[^/\\\\]";
30
- } else if (separator) {
31
- separatorSplitter = separator;
32
- separatorMatcher = escapeRegExpString(separatorSplitter);
33
- if (separatorMatcher.length > 1) {
34
- separatorMatcher = `(?:${separatorMatcher})`;
35
- wildcard = `((?!${separatorMatcher}).)`;
36
- } else wildcard = `[^${separatorMatcher}]`;
37
- }
38
- const requiredSeparator = separator ? `${separatorMatcher}+?` : "";
39
- const optionalSeparator = separator ? `${separatorMatcher}*?` : "";
40
- const segments = separator ? pattern.split(separatorSplitter) : [pattern];
41
- let result = "";
42
- for (let s = 0; s < segments.length; s++) {
43
- const segment = segments[s];
44
- const nextSegment = segments[s + 1];
45
- let currentSeparator = "";
46
- if (!segment && s > 0) continue;
47
- if (separator) if (s === segments.length - 1) currentSeparator = optionalSeparator;
48
- else if (nextSegment !== "**") currentSeparator = requiredSeparator;
49
- else currentSeparator = "";
50
- if (separator && segment === "**") {
51
- if (currentSeparator) {
52
- result += s === 0 ? "" : currentSeparator;
53
- result += `(?:${wildcard}*?${currentSeparator})*?`;
54
- }
55
- continue;
56
- }
57
- for (let c = 0; c < segment.length; c++) {
58
- const char = segment[c];
59
- if (char === "\\") {
60
- if (c < segment.length - 1) {
61
- result += escapeRegExpChar(segment[c + 1]);
62
- c++;
63
- }
64
- } else if (char === "?") result += wildcard;
65
- else if (char === "*") result += `${wildcard}*?`;
66
- else result += escapeRegExpChar(char);
67
- }
68
- result += currentSeparator;
69
- }
70
- return result;
71
- }
72
- function isMatch(regexp, sample) {
73
- if (typeof sample !== "string") throw new TypeError(`Sample must be a string, but ${typeof sample} given`);
74
- return regexp.test(sample);
75
- }
76
- function wildcardMatch(pattern, options) {
77
- if (typeof pattern !== "string" && !Array.isArray(pattern)) throw new TypeError(`The first argument must be a single pattern string or an array of patterns, but ${typeof pattern} given`);
78
- if (typeof options === "string" || typeof options === "boolean") options = { separator: options };
79
- if (arguments.length === 2 && !(typeof options === "undefined" || typeof options === "object" && options !== null && !Array.isArray(options))) throw new TypeError(`The second argument must be an options object or a string/boolean separator, but ${typeof options} given`);
80
- options = options || {};
81
- if (options.separator === "\\") throw new Error("\\ is not a valid separator because it is used for escaping. Try setting the separator to `true` instead");
82
- const regexpPattern = transform(pattern, options.separator);
83
- const regexp = new RegExp(`^${regexpPattern}$`, options.flags);
84
- const fn = isMatch.bind(null, regexp);
85
- fn.options = options;
86
- fn.pattern = pattern;
87
- fn.regexp = regexp;
88
- return fn;
89
- }
90
-
91
- // node_modules/better-auth/dist/utils/url.mjs
92
- function isLoopbackForDevScheme(host) {
93
- const hostname = host.replace(/:\d+$/, "").replace(/^\[|\]$/g, "").toLowerCase();
94
- return hostname === "localhost" || hostname.endsWith(".localhost") || hostname === "::1" || hostname.startsWith("127.");
95
- }
96
- function checkHasPath(url) {
97
- try {
98
- return (new URL(url).pathname.replace(/\/+$/, "") || "/") !== "/";
99
- } catch {
100
- throw new chunk4DPT2KQR_cjs.BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`);
101
- }
102
- }
103
- function assertHasProtocol(url) {
104
- try {
105
- const parsedUrl = new URL(url);
106
- if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new chunk4DPT2KQR_cjs.BetterAuthError(`Invalid base URL: ${url}. URL must include 'http://' or 'https://'`);
107
- } catch (error) {
108
- if (error instanceof chunk4DPT2KQR_cjs.BetterAuthError) throw error;
109
- throw new chunk4DPT2KQR_cjs.BetterAuthError(`Invalid base URL: ${url}. Please provide a valid base URL.`, { cause: error });
110
- }
111
- }
112
- function withPath(url, path = "/api/auth") {
113
- assertHasProtocol(url);
114
- if (checkHasPath(url)) return url;
115
- const trimmedUrl = url.replace(/\/+$/, "");
116
- if (!path || path === "/") return trimmedUrl;
117
- path = path.startsWith("/") ? path : `/${path}`;
118
- return `${trimmedUrl}${path}`;
119
- }
120
- function validateProxyHeader(header, type) {
121
- if (!header || header.trim() === "") return false;
122
- if (type === "proto") return header === "http" || header === "https";
123
- if (type === "host") {
124
- if ([
125
- /\.\./,
126
- /\0/,
127
- /[\s]/,
128
- /^[.]/,
129
- /[<>'"]/,
130
- /javascript:/i,
131
- /file:/i,
132
- /data:/i
133
- ].some((pattern) => pattern.test(header))) return false;
134
- return /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(header) || /^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(header) || /^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(header) || /^localhost(:[0-9]{1,5})?$/i.test(header);
135
- }
136
- return false;
137
- }
138
- function getBaseURL(url, path, request, loadEnv, trustedProxyHeaders) {
139
- if (url) return withPath(url, path);
140
- if (loadEnv !== false) {
141
- const fromEnv = chunk4DPT2KQR_cjs.env.BETTER_AUTH_URL || chunk4DPT2KQR_cjs.env.NEXT_PUBLIC_BETTER_AUTH_URL || chunk4DPT2KQR_cjs.env.PUBLIC_BETTER_AUTH_URL || chunk4DPT2KQR_cjs.env.NUXT_PUBLIC_BETTER_AUTH_URL || chunk4DPT2KQR_cjs.env.NUXT_PUBLIC_AUTH_URL || (chunk4DPT2KQR_cjs.env.BASE_URL !== "/" ? chunk4DPT2KQR_cjs.env.BASE_URL : void 0);
142
- if (fromEnv) return withPath(fromEnv, path);
143
- }
144
- const fromRequest = request?.headers.get("x-forwarded-host");
145
- const fromRequestProto = request?.headers.get("x-forwarded-proto");
146
- if (fromRequest && fromRequestProto && trustedProxyHeaders) {
147
- if (validateProxyHeader(fromRequestProto, "proto") && validateProxyHeader(fromRequest, "host")) try {
148
- return withPath(`${fromRequestProto}://${fromRequest}`, path);
149
- } catch (_error) {
150
- }
151
- }
152
- if (request) {
153
- const url2 = getOrigin(request.url);
154
- if (!url2) throw new chunk4DPT2KQR_cjs.BetterAuthError("Could not get origin from request. Please provide a valid base URL.");
155
- return withPath(url2, path);
156
- }
157
- if (typeof window !== "undefined" && window.location) return withPath(window.location.origin, path);
158
- }
159
- function getOrigin(url) {
160
- try {
161
- const parsedUrl = new URL(url);
162
- return parsedUrl.origin === "null" ? null : parsedUrl.origin;
163
- } catch {
164
- return null;
165
- }
166
- }
167
- function getProtocol(url) {
168
- try {
169
- return new URL(url).protocol;
170
- } catch {
171
- return null;
172
- }
173
- }
174
- function getHost(url) {
175
- try {
176
- return new URL(url).host;
177
- } catch {
178
- return null;
179
- }
180
- }
181
- function isDynamicBaseURLConfig(config) {
182
- return typeof config === "object" && config !== null && "allowedHosts" in config && Array.isArray(config.allowedHosts);
183
- }
184
- function isRequestLike(value) {
185
- if (value instanceof Request) return true;
186
- if (typeof value !== "object" || value === null || Object.prototype.toString.call(value) !== "[object Request]") return false;
187
- const v = value;
188
- return typeof v.url === "string" && typeof v.headers === "object" && v.headers !== null && typeof v.headers.get === "function";
189
- }
190
- function getHostFromSource(source, trustedProxyHeaders) {
191
- const headers = isRequestLike(source) ? source.headers : source;
192
- if (trustedProxyHeaders) {
193
- const forwardedHost = headers.get("x-forwarded-host");
194
- if (forwardedHost && validateProxyHeader(forwardedHost, "host")) return forwardedHost;
195
- }
196
- const host = headers.get("host");
197
- if (host && validateProxyHeader(host, "host")) return host;
198
- if (isRequestLike(source)) try {
199
- return new URL(source.url).host;
200
- } catch {
201
- return null;
202
- }
203
- return null;
204
- }
205
- function getProtocolFromSource(source, configProtocol, trustedProxyHeaders) {
206
- if (configProtocol === "http" || configProtocol === "https") return configProtocol;
207
- const headers = isRequestLike(source) ? source.headers : source;
208
- if (trustedProxyHeaders) {
209
- const forwardedProto = headers.get("x-forwarded-proto");
210
- if (forwardedProto && validateProxyHeader(forwardedProto, "proto")) return forwardedProto;
211
- }
212
- if (isRequestLike(source)) try {
213
- const url = new URL(source.url);
214
- if (url.protocol === "http:" || url.protocol === "https:") return url.protocol.slice(0, -1);
215
- } catch {
216
- }
217
- const host = getHostFromSource(source, trustedProxyHeaders);
218
- if (host && isLoopbackForDevScheme(host)) return "http";
219
- return "https";
220
- }
221
- var matchesHostPattern = (host, pattern) => {
222
- if (!host || !pattern) return false;
223
- const normalizedHost = host.replace(/^https?:\/\//, "").split("/")[0].toLowerCase();
224
- const normalizedPattern = pattern.replace(/^https?:\/\//, "").split("/")[0].toLowerCase();
225
- if (normalizedPattern.includes("*") || normalizedPattern.includes("?")) return wildcardMatch(normalizedPattern)(normalizedHost);
226
- return normalizedHost.toLowerCase() === normalizedPattern.toLowerCase();
227
- };
228
- function resolveDynamicBaseURL(config, source, basePath, trustedProxyHeaders) {
229
- const host = getHostFromSource(source, trustedProxyHeaders);
230
- if (!host) {
231
- if (config.fallback) return withPath(config.fallback, basePath);
232
- throw new chunk4DPT2KQR_cjs.BetterAuthError("Could not determine host from request headers. Please provide a fallback URL in your baseURL config.");
233
- }
234
- if (config.allowedHosts.some((pattern) => matchesHostPattern(host, pattern))) return withPath(`${getProtocolFromSource(source, config.protocol, trustedProxyHeaders)}://${host}`, basePath);
235
- if (config.fallback) return withPath(config.fallback, basePath);
236
- throw new chunk4DPT2KQR_cjs.BetterAuthError(`Host "${host}" is not in the allowed hosts list. Allowed hosts: ${config.allowedHosts.join(", ")}. Add this host to your allowedHosts config or provide a fallback URL.`);
237
- }
238
- function resolveBaseURL(config, basePath, source, loadEnv, trustedProxyHeaders) {
239
- if (isDynamicBaseURLConfig(config)) {
240
- if (source) return resolveDynamicBaseURL(config, source, basePath, trustedProxyHeaders);
241
- if (config.fallback) return withPath(config.fallback, basePath);
242
- return getBaseURL(void 0, basePath, void 0, loadEnv, trustedProxyHeaders);
243
- }
244
- const request = isRequestLike(source) ? source : void 0;
245
- if (typeof config === "string") return getBaseURL(config, basePath, request, loadEnv, trustedProxyHeaders);
246
- return getBaseURL(void 0, basePath, request, loadEnv, trustedProxyHeaders);
247
- }
248
-
249
- // node_modules/defu/dist/defu.mjs
250
- function isPlainObject(value) {
251
- if (value === null || typeof value !== "object") {
252
- return false;
253
- }
254
- const prototype = Object.getPrototypeOf(value);
255
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
256
- return false;
257
- }
258
- if (Symbol.iterator in value) {
259
- return false;
260
- }
261
- if (Symbol.toStringTag in value) {
262
- return Object.prototype.toString.call(value) === "[object Module]";
263
- }
264
- return true;
265
- }
266
- function _defu(baseObject, defaults, namespace = ".", merger) {
267
- if (!isPlainObject(defaults)) {
268
- return _defu(baseObject, {}, namespace, merger);
269
- }
270
- const object = { ...defaults };
271
- for (const key of Object.keys(baseObject)) {
272
- if (key === "__proto__" || key === "constructor") {
273
- continue;
274
- }
275
- const value = baseObject[key];
276
- if (value === null || value === void 0) {
277
- continue;
278
- }
279
- if (merger && merger(object, key, value, namespace)) {
280
- continue;
281
- }
282
- if (Array.isArray(value) && Array.isArray(object[key])) {
283
- object[key] = [...value, ...object[key]];
284
- } else if (isPlainObject(value) && isPlainObject(object[key])) {
285
- object[key] = _defu(
286
- value,
287
- object[key],
288
- (namespace ? `${namespace}.` : "") + key.toString(),
289
- merger
290
- );
291
- } else {
292
- object[key] = value;
293
- }
294
- }
295
- return object;
296
- }
297
- function createDefu(merger) {
298
- return (...arguments_) => (
299
- // eslint-disable-next-line unicorn/no-array-reduce
300
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
301
- );
302
- }
303
- var defu = createDefu();
304
-
305
- // node_modules/@better-fetch/fetch/dist/index.js
306
- var __defProp = Object.defineProperty;
307
- var __defProps = Object.defineProperties;
308
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
309
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
310
- var __hasOwnProp = Object.prototype.hasOwnProperty;
311
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
312
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
313
- var __spreadValues = (a, b) => {
314
- for (var prop in b || (b = {}))
315
- if (__hasOwnProp.call(b, prop))
316
- __defNormalProp(a, prop, b[prop]);
317
- if (__getOwnPropSymbols)
318
- for (var prop of __getOwnPropSymbols(b)) {
319
- if (__propIsEnum.call(b, prop))
320
- __defNormalProp(a, prop, b[prop]);
321
- }
322
- return a;
323
- };
324
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
325
- var BetterFetchError = class extends Error {
326
- constructor(status, statusText, error) {
327
- super(statusText || status.toString(), {
328
- cause: error
329
- });
330
- this.status = status;
331
- this.statusText = statusText;
332
- this.error = error;
333
- Error.captureStackTrace(this, this.constructor);
334
- }
335
- };
336
- var initializePlugins = async (url, options) => {
337
- var _a, _b, _c, _d, _e, _f;
338
- let opts = options || {};
339
- const hooks = {
340
- onRequest: [options == null ? void 0 : options.onRequest],
341
- onResponse: [options == null ? void 0 : options.onResponse],
342
- onSuccess: [options == null ? void 0 : options.onSuccess],
343
- onError: [options == null ? void 0 : options.onError],
344
- onRetry: [options == null ? void 0 : options.onRetry]
345
- };
346
- if (!options || !(options == null ? void 0 : options.plugins)) {
347
- return {
348
- url,
349
- options: opts,
350
- hooks
351
- };
352
- }
353
- for (const plugin of (options == null ? void 0 : options.plugins) || []) {
354
- if (plugin.init) {
355
- const pluginRes = await ((_a = plugin.init) == null ? void 0 : _a.call(plugin, url.toString(), options));
356
- opts = pluginRes.options || opts;
357
- url = pluginRes.url;
358
- }
359
- hooks.onRequest.push((_b = plugin.hooks) == null ? void 0 : _b.onRequest);
360
- hooks.onResponse.push((_c = plugin.hooks) == null ? void 0 : _c.onResponse);
361
- hooks.onSuccess.push((_d = plugin.hooks) == null ? void 0 : _d.onSuccess);
362
- hooks.onError.push((_e = plugin.hooks) == null ? void 0 : _e.onError);
363
- hooks.onRetry.push((_f = plugin.hooks) == null ? void 0 : _f.onRetry);
364
- }
365
- return {
366
- url,
367
- options: opts,
368
- hooks
369
- };
370
- };
371
- var LinearRetryStrategy = class {
372
- constructor(options) {
373
- this.options = options;
374
- }
375
- shouldAttemptRetry(attempt, response) {
376
- if (this.options.shouldRetry) {
377
- return Promise.resolve(
378
- attempt < this.options.attempts && this.options.shouldRetry(response)
379
- );
380
- }
381
- return Promise.resolve(attempt < this.options.attempts);
382
- }
383
- getDelay() {
384
- return this.options.delay;
385
- }
386
- };
387
- var ExponentialRetryStrategy = class {
388
- constructor(options) {
389
- this.options = options;
390
- }
391
- shouldAttemptRetry(attempt, response) {
392
- if (this.options.shouldRetry) {
393
- return Promise.resolve(
394
- attempt < this.options.attempts && this.options.shouldRetry(response)
395
- );
396
- }
397
- return Promise.resolve(attempt < this.options.attempts);
398
- }
399
- getDelay(attempt) {
400
- const delay = Math.min(
401
- this.options.maxDelay,
402
- this.options.baseDelay * 2 ** attempt
403
- );
404
- return delay;
405
- }
406
- };
407
- function createRetryStrategy(options) {
408
- if (typeof options === "number") {
409
- return new LinearRetryStrategy({
410
- type: "linear",
411
- attempts: options,
412
- delay: 1e3
413
- });
414
- }
415
- switch (options.type) {
416
- case "linear":
417
- return new LinearRetryStrategy(options);
418
- case "exponential":
419
- return new ExponentialRetryStrategy(options);
420
- default:
421
- throw new Error("Invalid retry strategy");
422
- }
423
- }
424
- var getAuthHeader = async (options) => {
425
- const headers = {};
426
- const getValue = async (value) => typeof value === "function" ? await value() : value;
427
- if (options == null ? void 0 : options.auth) {
428
- if (options.auth.type === "Bearer") {
429
- const token = await getValue(options.auth.token);
430
- if (!token) {
431
- return headers;
432
- }
433
- headers["authorization"] = `Bearer ${token}`;
434
- } else if (options.auth.type === "Basic") {
435
- const [username, password] = await Promise.all([
436
- getValue(options.auth.username),
437
- getValue(options.auth.password)
438
- ]);
439
- if (!username || !password) {
440
- return headers;
441
- }
442
- headers["authorization"] = `Basic ${btoa(`${username}:${password}`)}`;
443
- } else if (options.auth.type === "Custom") {
444
- const [prefix, value] = await Promise.all([
445
- getValue(options.auth.prefix),
446
- getValue(options.auth.value)
447
- ]);
448
- if (!value) {
449
- return headers;
450
- }
451
- headers["authorization"] = `${prefix != null ? prefix : ""} ${value}`;
452
- }
453
- }
454
- return headers;
455
- };
456
- var JSON_RE = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
457
- function detectResponseType(request) {
458
- const _contentType = request.headers.get("content-type");
459
- const textTypes = /* @__PURE__ */ new Set([
460
- "image/svg",
461
- "application/xml",
462
- "application/xhtml",
463
- "application/html"
464
- ]);
465
- if (!_contentType) {
466
- return "json";
467
- }
468
- const contentType = _contentType.split(";").shift() || "";
469
- if (JSON_RE.test(contentType)) {
470
- return "json";
471
- }
472
- if (textTypes.has(contentType) || contentType.startsWith("text/")) {
473
- return "text";
474
- }
475
- return "blob";
476
- }
477
- function isJSONParsable(value) {
478
- try {
479
- JSON.parse(value);
480
- return true;
481
- } catch (error) {
482
- return false;
483
- }
484
- }
485
- function isJSONSerializable(value) {
486
- if (value === void 0) {
487
- return false;
488
- }
489
- const t = typeof value;
490
- if (t === "string" || t === "number" || t === "boolean" || t === null) {
491
- return true;
492
- }
493
- if (t !== "object") {
494
- return false;
495
- }
496
- if (Array.isArray(value)) {
497
- return true;
498
- }
499
- if (value.buffer) {
500
- return false;
501
- }
502
- return value.constructor && value.constructor.name === "Object" || typeof value.toJSON === "function";
503
- }
504
- function jsonParse(text) {
505
- try {
506
- return JSON.parse(text);
507
- } catch (error) {
508
- return text;
509
- }
510
- }
511
- function isFunction(value) {
512
- return typeof value === "function";
513
- }
514
- function getFetch(options) {
515
- if (options == null ? void 0 : options.customFetchImpl) {
516
- return options.customFetchImpl;
517
- }
518
- if (typeof globalThis !== "undefined" && isFunction(globalThis.fetch)) {
519
- return globalThis.fetch;
520
- }
521
- if (typeof window !== "undefined" && isFunction(window.fetch)) {
522
- return window.fetch;
523
- }
524
- throw new Error("No fetch implementation found");
525
- }
526
- async function getHeaders(opts) {
527
- const headers = new Headers(opts == null ? void 0 : opts.headers);
528
- const authHeader = await getAuthHeader(opts);
529
- for (const [key, value] of Object.entries(authHeader || {})) {
530
- headers.set(key, value);
531
- }
532
- if (!headers.has("content-type")) {
533
- const t = detectContentType(opts == null ? void 0 : opts.body);
534
- if (t) {
535
- headers.set("content-type", t);
536
- }
537
- }
538
- return headers;
539
- }
540
- function detectContentType(body) {
541
- if (isJSONSerializable(body)) {
542
- return "application/json";
543
- }
544
- return null;
545
- }
546
- function getBody(options) {
547
- if (!(options == null ? void 0 : options.body)) {
548
- return null;
549
- }
550
- const headers = new Headers(options == null ? void 0 : options.headers);
551
- if (isJSONSerializable(options.body) && !headers.has("content-type")) {
552
- for (const [key, value] of Object.entries(options == null ? void 0 : options.body)) {
553
- if (value instanceof Date) {
554
- options.body[key] = value.toISOString();
555
- }
556
- }
557
- return JSON.stringify(options.body);
558
- }
559
- if (headers.has("content-type") && headers.get("content-type") === "application/x-www-form-urlencoded") {
560
- if (isJSONSerializable(options.body)) {
561
- return new URLSearchParams(options.body).toString();
562
- }
563
- return options.body;
564
- }
565
- return options.body;
566
- }
567
- function getMethod(url, options) {
568
- var _a;
569
- if (options == null ? void 0 : options.method) {
570
- return options.method.toUpperCase();
571
- }
572
- if (url.startsWith("@")) {
573
- const pMethod = (_a = url.split("@")[1]) == null ? void 0 : _a.split("/")[0];
574
- if (!methods.includes(pMethod)) {
575
- return (options == null ? void 0 : options.body) ? "POST" : "GET";
576
- }
577
- return pMethod.toUpperCase();
578
- }
579
- return (options == null ? void 0 : options.body) ? "POST" : "GET";
580
- }
581
- function getTimeout(options, controller) {
582
- let abortTimeout;
583
- if (!(options == null ? void 0 : options.signal) && (options == null ? void 0 : options.timeout)) {
584
- abortTimeout = setTimeout(() => controller == null ? void 0 : controller.abort(), options == null ? void 0 : options.timeout);
585
- }
586
- return {
587
- abortTimeout,
588
- clearTimeout: () => {
589
- if (abortTimeout) {
590
- clearTimeout(abortTimeout);
591
- }
592
- }
593
- };
594
- }
595
- var ValidationError = class _ValidationError extends Error {
596
- constructor(issues, message) {
597
- super(message || JSON.stringify(issues, null, 2));
598
- this.issues = issues;
599
- Object.setPrototypeOf(this, _ValidationError.prototype);
600
- }
601
- };
602
- async function parseStandardSchema(schema, input) {
603
- const result = await schema["~standard"].validate(input);
604
- if (result.issues) {
605
- throw new ValidationError(result.issues);
606
- }
607
- return result.value;
608
- }
609
- var methods = ["get", "post", "put", "patch", "delete"];
610
- var applySchemaPlugin = (config) => ({
611
- id: "apply-schema",
612
- name: "Apply Schema",
613
- version: "1.0.0",
614
- async init(url, options) {
615
- var _a, _b, _c, _d;
616
- const schema = ((_b = (_a = config.plugins) == null ? void 0 : _a.find(
617
- (plugin) => {
618
- var _a2;
619
- return ((_a2 = plugin.schema) == null ? void 0 : _a2.config) ? url.startsWith(plugin.schema.config.baseURL || "") || url.startsWith(plugin.schema.config.prefix || "") : false;
620
- }
621
- )) == null ? void 0 : _b.schema) || config.schema;
622
- if (schema) {
623
- let urlKey = url;
624
- if ((_c = schema.config) == null ? void 0 : _c.prefix) {
625
- if (urlKey.startsWith(schema.config.prefix)) {
626
- urlKey = urlKey.replace(schema.config.prefix, "");
627
- if (schema.config.baseURL) {
628
- url = url.replace(schema.config.prefix, schema.config.baseURL);
629
- }
630
- }
631
- }
632
- if ((_d = schema.config) == null ? void 0 : _d.baseURL) {
633
- if (urlKey.startsWith(schema.config.baseURL)) {
634
- urlKey = urlKey.replace(schema.config.baseURL, "");
635
- }
636
- }
637
- const keySchema = schema.schema[urlKey];
638
- if (keySchema) {
639
- let opts = __spreadProps(__spreadValues({}, options), {
640
- method: keySchema.method,
641
- output: keySchema.output
642
- });
643
- if (!(options == null ? void 0 : options.disableValidation)) {
644
- opts = __spreadProps(__spreadValues({}, opts), {
645
- body: keySchema.input ? await parseStandardSchema(keySchema.input, options == null ? void 0 : options.body) : options == null ? void 0 : options.body,
646
- params: keySchema.params ? await parseStandardSchema(keySchema.params, options == null ? void 0 : options.params) : options == null ? void 0 : options.params,
647
- query: keySchema.query ? await parseStandardSchema(keySchema.query, options == null ? void 0 : options.query) : options == null ? void 0 : options.query
648
- });
649
- }
650
- return {
651
- url,
652
- options: opts
653
- };
654
- }
655
- }
656
- return {
657
- url,
658
- options
659
- };
660
- }
661
- });
662
- var createFetch = (config) => {
663
- async function $fetch(url, options) {
664
- const opts = __spreadProps(__spreadValues(__spreadValues({}, config), options), {
665
- plugins: [...(config == null ? void 0 : config.plugins) || [], applySchemaPlugin(config || {}), ...(options == null ? void 0 : options.plugins) || []]
666
- });
667
- if (config == null ? void 0 : config.catchAllError) {
668
- try {
669
- return await betterFetch(url, opts);
670
- } catch (error) {
671
- return {
672
- data: null,
673
- error: {
674
- status: 500,
675
- statusText: "Fetch Error",
676
- message: "Fetch related error. Captured by catchAllError option. See error property for more details.",
677
- error
678
- }
679
- };
680
- }
681
- }
682
- return await betterFetch(url, opts);
683
- }
684
- return $fetch;
685
- };
686
- function getURL2(url, option) {
687
- const { baseURL, params, query } = option || {
688
- query: {},
689
- params: {},
690
- baseURL: ""
691
- };
692
- let basePath = url.startsWith("http") ? url.split("/").slice(0, 3).join("/") : baseURL || "";
693
- if (url.startsWith("@")) {
694
- const m = url.toString().split("@")[1].split("/")[0];
695
- if (methods.includes(m)) {
696
- url = url.replace(`@${m}/`, "/");
697
- }
698
- }
699
- if (!basePath.endsWith("/")) basePath += "/";
700
- let [path, urlQuery] = url.replace(basePath, "").split("?");
701
- const queryParams = new URLSearchParams(urlQuery);
702
- for (const [key, value] of Object.entries(query || {})) {
703
- if (value == null) continue;
704
- let serializedValue;
705
- if (typeof value === "string") {
706
- serializedValue = value;
707
- } else if (Array.isArray(value)) {
708
- for (const val of value) {
709
- queryParams.append(key, val);
710
- }
711
- continue;
712
- } else {
713
- serializedValue = JSON.stringify(value);
714
- }
715
- queryParams.set(key, serializedValue);
716
- }
717
- if (params) {
718
- if (Array.isArray(params)) {
719
- const paramPaths = path.split("/").filter((p) => p.startsWith(":"));
720
- for (const [index, key] of paramPaths.entries()) {
721
- const value = params[index];
722
- path = path.replace(key, value);
723
- }
724
- } else {
725
- for (const [key, value] of Object.entries(params)) {
726
- path = path.replace(`:${key}`, String(value));
727
- }
728
- }
729
- }
730
- path = path.split("/").map(encodeURIComponent).join("/");
731
- if (path.startsWith("/")) path = path.slice(1);
732
- let queryParamString = queryParams.toString();
733
- queryParamString = queryParamString.length > 0 ? `?${queryParamString}`.replace(/\+/g, "%20") : "";
734
- if (!basePath.startsWith("http")) {
735
- return `${basePath}${path}${queryParamString}`;
736
- }
737
- const _url = new URL(`${path}${queryParamString}`, basePath);
738
- return _url;
739
- }
740
- var betterFetch = async (url, options) => {
741
- var _a, _b, _c, _d, _e, _f, _g, _h;
742
- const {
743
- hooks,
744
- url: __url,
745
- options: opts
746
- } = await initializePlugins(url, options);
747
- const fetch = getFetch(opts);
748
- const controller = new AbortController();
749
- const signal = (_a = opts.signal) != null ? _a : controller.signal;
750
- const _url = getURL2(__url, opts);
751
- const body = getBody(opts);
752
- const headers = await getHeaders(opts);
753
- const method = getMethod(__url, opts);
754
- let context = __spreadProps(__spreadValues({}, opts), {
755
- url: _url,
756
- headers,
757
- body,
758
- method,
759
- signal
760
- });
761
- for (const onRequest of hooks.onRequest) {
762
- if (onRequest) {
763
- const res = await onRequest(context);
764
- if (typeof res === "object" && res !== null) {
765
- context = res;
766
- }
767
- }
768
- }
769
- if ("pipeTo" in context && typeof context.pipeTo === "function" || typeof ((_b = options == null ? void 0 : options.body) == null ? void 0 : _b.pipe) === "function") {
770
- if (!("duplex" in context)) {
771
- context.duplex = "half";
772
- }
773
- }
774
- const { clearTimeout: clearTimeout2 } = getTimeout(opts, controller);
775
- let response = await fetch(context.url, context);
776
- clearTimeout2();
777
- const responseContext = {
778
- response,
779
- request: context
780
- };
781
- for (const onResponse of hooks.onResponse) {
782
- if (onResponse) {
783
- const r = await onResponse(__spreadProps(__spreadValues({}, responseContext), {
784
- response: ((_c = options == null ? void 0 : options.hookOptions) == null ? void 0 : _c.cloneResponse) ? response.clone() : response
785
- }));
786
- if (r instanceof Response) {
787
- response = r;
788
- } else if (typeof r === "object" && r !== null) {
789
- response = r.response;
790
- }
791
- }
792
- }
793
- if (response.ok) {
794
- const hasBody = context.method !== "HEAD";
795
- if (!hasBody) {
796
- return {
797
- data: "",
798
- error: null
799
- };
800
- }
801
- const responseType = detectResponseType(response);
802
- const successContext = {
803
- data: null,
804
- response,
805
- request: context
806
- };
807
- if (responseType === "json" || responseType === "text") {
808
- const text = await response.text();
809
- const parser2 = (_d = context.jsonParser) != null ? _d : jsonParse;
810
- successContext.data = await parser2(text);
811
- } else {
812
- successContext.data = await response[responseType]();
813
- }
814
- if (context == null ? void 0 : context.output) {
815
- if (context.output && !context.disableValidation) {
816
- successContext.data = await parseStandardSchema(
817
- context.output,
818
- successContext.data
819
- );
820
- }
821
- }
822
- for (const onSuccess of hooks.onSuccess) {
823
- if (onSuccess) {
824
- await onSuccess(__spreadProps(__spreadValues({}, successContext), {
825
- response: ((_e = options == null ? void 0 : options.hookOptions) == null ? void 0 : _e.cloneResponse) ? response.clone() : response
826
- }));
827
- }
828
- }
829
- if (options == null ? void 0 : options.throw) {
830
- return successContext.data;
831
- }
832
- return {
833
- data: successContext.data,
834
- error: null
835
- };
836
- }
837
- const parser = (_f = options == null ? void 0 : options.jsonParser) != null ? _f : jsonParse;
838
- const responseText = await response.text();
839
- const isJSONResponse = isJSONParsable(responseText);
840
- const errorObject = isJSONResponse ? await parser(responseText) : null;
841
- const errorContext = {
842
- response,
843
- responseText,
844
- request: context,
845
- error: __spreadProps(__spreadValues({}, errorObject), {
846
- status: response.status,
847
- statusText: response.statusText
848
- })
849
- };
850
- for (const onError of hooks.onError) {
851
- if (onError) {
852
- await onError(__spreadProps(__spreadValues({}, errorContext), {
853
- response: ((_g = options == null ? void 0 : options.hookOptions) == null ? void 0 : _g.cloneResponse) ? response.clone() : response
854
- }));
855
- }
856
- }
857
- if (options == null ? void 0 : options.retry) {
858
- const retryStrategy = createRetryStrategy(options.retry);
859
- const _retryAttempt = (_h = options.retryAttempt) != null ? _h : 0;
860
- if (await retryStrategy.shouldAttemptRetry(_retryAttempt, response)) {
861
- for (const onRetry of hooks.onRetry) {
862
- if (onRetry) {
863
- await onRetry(responseContext);
864
- }
865
- }
866
- const delay = retryStrategy.getDelay(_retryAttempt);
867
- await new Promise((resolve) => setTimeout(resolve, delay));
868
- return await betterFetch(url, __spreadProps(__spreadValues({}, options), {
869
- retryAttempt: _retryAttempt + 1
870
- }));
871
- }
872
- }
873
- if (options == null ? void 0 : options.throw) {
874
- throw new BetterFetchError(
875
- response.status,
876
- response.statusText,
877
- isJSONResponse ? errorObject : responseText
878
- );
879
- }
880
- return {
881
- data: null,
882
- error: __spreadProps(__spreadValues({}, errorObject), {
883
- status: response.status,
884
- statusText: response.statusText
885
- })
886
- };
887
- };
888
-
889
- exports.PACKAGE_VERSION = PACKAGE_VERSION;
890
- exports.betterFetch = betterFetch;
891
- exports.createDefu = createDefu;
892
- exports.createFetch = createFetch;
893
- exports.defu = defu;
894
- exports.getBaseURL = getBaseURL;
895
- exports.getHost = getHost;
896
- exports.getOrigin = getOrigin;
897
- exports.getProtocol = getProtocol;
898
- exports.isDynamicBaseURLConfig = isDynamicBaseURLConfig;
899
- exports.isRequestLike = isRequestLike;
900
- exports.resolveBaseURL = resolveBaseURL;
901
- exports.wildcardMatch = wildcardMatch;
902
- //# sourceMappingURL=chunk-RFP2X2FA.cjs.map
903
- //# sourceMappingURL=chunk-RFP2X2FA.cjs.map