next-rest-framework
Version:
Next REST Framework - Type-safe, self-documenting APIs for Next.js
1,353 lines (1,331 loc) • 120 kB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// package.json
var require_package = __commonJS({
"package.json"(exports2, module2) {
module2.exports = {
name: "next-rest-framework",
version: "5.1.6",
description: "Next REST Framework - Type-safe, self-documenting APIs for Next.js",
keywords: [
"nextjs",
"rest",
"api",
"next-rest-framework"
],
homepage: "https://next-rest-framework.vercel.app",
bugs: {
url: "https://github.com/blomqma/next-rest-framework/issues",
email: "blomqma@omg.lol"
},
license: "ISC",
author: "Markus Blomqvist <blomqma@omg.lol>",
files: [
"dist"
],
main: "dist/index.js",
module: "dist/index.mjs",
types: "dist/index.d.ts",
repository: {
type: "git",
url: "https://github.com/blomqma/next-rest-framework.git",
directory: "packages/next-rest-framework"
},
scripts: {
lint: "tsc",
test: "jest",
"test:watch": "jest --watch",
build: "tsup --dts"
},
bin: {
"next-rest-framework": "./dist/cli/index.js"
},
dependencies: {
chalk: "4.1.2",
commander: "10.0.1",
esbuild: "0.19.11",
lodash: "4.17.21",
prettier: "3.0.2",
"tiny-glob": "0.2.9",
"zod-to-json-schema": "3.21.4"
},
devDependencies: {
"@types/jest": "29.5.4",
"@types/lodash": "4.14.197",
jest: "29.6.4",
"node-mocks-http": "1.13.0",
"openapi-types": "12.1.3",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
tsup: "8.0.1",
typescript: "*",
next: "*",
zod: "*"
}
};
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/i18n/detect-domain-locale.js
var require_detect_domain_locale = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/i18n/detect-domain-locale.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
Object.defineProperty(exports2, "detectDomainLocale", {
enumerable: true,
get: function() {
return detectDomainLocale;
}
});
function detectDomainLocale(domainItems, hostname, detectedLocale) {
if (!domainItems)
return;
if (detectedLocale) {
detectedLocale = detectedLocale.toLowerCase();
}
for (const item of domainItems) {
var _item_domain, _item_locales;
const domainHostname = (_item_domain = item.domain) == null ? void 0 : _item_domain.split(":", 1)[0].toLowerCase();
if (hostname === domainHostname || detectedLocale === item.defaultLocale.toLowerCase() || ((_item_locales = item.locales) == null ? void 0 : _item_locales.some((locale) => locale.toLowerCase() === detectedLocale))) {
return item;
}
}
}
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/remove-trailing-slash.js
var require_remove_trailing_slash = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/remove-trailing-slash.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
Object.defineProperty(exports2, "removeTrailingSlash", {
enumerable: true,
get: function() {
return removeTrailingSlash;
}
});
function removeTrailingSlash(route2) {
return route2.replace(/\/$/, "") || "/";
}
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/parse-path.js
var require_parse_path = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/parse-path.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
Object.defineProperty(exports2, "parsePath", {
enumerable: true,
get: function() {
return parsePath;
}
});
function parsePath(path) {
const hashIndex = path.indexOf("#");
const queryIndex = path.indexOf("?");
const hasQuery = queryIndex > -1 && (hashIndex < 0 || queryIndex < hashIndex);
if (hasQuery || hashIndex > -1) {
return {
pathname: path.substring(0, hasQuery ? queryIndex : hashIndex),
query: hasQuery ? path.substring(queryIndex, hashIndex > -1 ? hashIndex : void 0) : "",
hash: hashIndex > -1 ? path.slice(hashIndex) : ""
};
}
return {
pathname: path,
query: "",
hash: ""
};
}
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/add-path-prefix.js
var require_add_path_prefix = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/add-path-prefix.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
Object.defineProperty(exports2, "addPathPrefix", {
enumerable: true,
get: function() {
return addPathPrefix;
}
});
var _parsepath = require_parse_path();
function addPathPrefix(path, prefix) {
if (!path.startsWith("/") || !prefix) {
return path;
}
const { pathname, query, hash } = (0, _parsepath.parsePath)(path);
return "" + prefix + pathname + query + hash;
}
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/add-path-suffix.js
var require_add_path_suffix = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/add-path-suffix.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
Object.defineProperty(exports2, "addPathSuffix", {
enumerable: true,
get: function() {
return addPathSuffix;
}
});
var _parsepath = require_parse_path();
function addPathSuffix(path, suffix) {
if (!path.startsWith("/") || !suffix) {
return path;
}
const { pathname, query, hash } = (0, _parsepath.parsePath)(path);
return "" + pathname + suffix + query + hash;
}
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/path-has-prefix.js
var require_path_has_prefix = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/path-has-prefix.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
Object.defineProperty(exports2, "pathHasPrefix", {
enumerable: true,
get: function() {
return pathHasPrefix;
}
});
var _parsepath = require_parse_path();
function pathHasPrefix(path, prefix) {
if (typeof path !== "string") {
return false;
}
const { pathname } = (0, _parsepath.parsePath)(path);
return pathname === prefix || pathname.startsWith(prefix + "/");
}
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/add-locale.js
var require_add_locale = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/add-locale.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
Object.defineProperty(exports2, "addLocale", {
enumerable: true,
get: function() {
return addLocale;
}
});
var _addpathprefix = require_add_path_prefix();
var _pathhasprefix = require_path_has_prefix();
function addLocale(path, locale, defaultLocale, ignorePrefix) {
if (!locale || locale === defaultLocale)
return path;
const lower = path.toLowerCase();
if (!ignorePrefix) {
if ((0, _pathhasprefix.pathHasPrefix)(lower, "/api"))
return path;
if ((0, _pathhasprefix.pathHasPrefix)(lower, "/" + locale.toLowerCase()))
return path;
}
return (0, _addpathprefix.addPathPrefix)(path, "/" + locale);
}
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/format-next-pathname-info.js
var require_format_next_pathname_info = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/format-next-pathname-info.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
Object.defineProperty(exports2, "formatNextPathnameInfo", {
enumerable: true,
get: function() {
return formatNextPathnameInfo;
}
});
var _removetrailingslash = require_remove_trailing_slash();
var _addpathprefix = require_add_path_prefix();
var _addpathsuffix = require_add_path_suffix();
var _addlocale = require_add_locale();
function formatNextPathnameInfo(info) {
let pathname = (0, _addlocale.addLocale)(info.pathname, info.locale, info.buildId ? void 0 : info.defaultLocale, info.ignorePrefix);
if (info.buildId || !info.trailingSlash) {
pathname = (0, _removetrailingslash.removeTrailingSlash)(pathname);
}
if (info.buildId) {
pathname = (0, _addpathsuffix.addPathSuffix)((0, _addpathprefix.addPathPrefix)(pathname, "/_next/data/" + info.buildId), info.pathname === "/" ? "index.json" : ".json");
}
pathname = (0, _addpathprefix.addPathPrefix)(pathname, info.basePath);
return !info.buildId && info.trailingSlash ? !pathname.endsWith("/") ? (0, _addpathsuffix.addPathSuffix)(pathname, "/") : pathname : (0, _removetrailingslash.removeTrailingSlash)(pathname);
}
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/get-hostname.js
var require_get_hostname = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/get-hostname.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
Object.defineProperty(exports2, "getHostname", {
enumerable: true,
get: function() {
return getHostname;
}
});
function getHostname(parsed, headers) {
let hostname;
if ((headers == null ? void 0 : headers.host) && !Array.isArray(headers.host)) {
hostname = headers.host.toString().split(":", 1)[0];
} else if (parsed.hostname) {
hostname = parsed.hostname;
} else
return;
return hostname.toLowerCase();
}
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/i18n/normalize-locale-path.js
var require_normalize_locale_path = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/i18n/normalize-locale-path.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
Object.defineProperty(exports2, "normalizeLocalePath", {
enumerable: true,
get: function() {
return normalizeLocalePath;
}
});
function normalizeLocalePath(pathname, locales) {
let detectedLocale;
const pathnameParts = pathname.split("/");
(locales || []).some((locale) => {
if (pathnameParts[1] && pathnameParts[1].toLowerCase() === locale.toLowerCase()) {
detectedLocale = locale;
pathnameParts.splice(1, 1);
pathname = pathnameParts.join("/") || "/";
return true;
}
return false;
});
return {
pathname,
detectedLocale
};
}
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/remove-path-prefix.js
var require_remove_path_prefix = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/remove-path-prefix.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
Object.defineProperty(exports2, "removePathPrefix", {
enumerable: true,
get: function() {
return removePathPrefix;
}
});
var _pathhasprefix = require_path_has_prefix();
function removePathPrefix(path, prefix) {
if (!(0, _pathhasprefix.pathHasPrefix)(path, prefix)) {
return path;
}
const withoutPrefix = path.slice(prefix.length);
if (withoutPrefix.startsWith("/")) {
return withoutPrefix;
}
return "/" + withoutPrefix;
}
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/get-next-pathname-info.js
var require_get_next_pathname_info = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/shared/lib/router/utils/get-next-pathname-info.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
Object.defineProperty(exports2, "getNextPathnameInfo", {
enumerable: true,
get: function() {
return getNextPathnameInfo;
}
});
var _normalizelocalepath = require_normalize_locale_path();
var _removepathprefix = require_remove_path_prefix();
var _pathhasprefix = require_path_has_prefix();
function getNextPathnameInfo(pathname, options) {
var _options_nextConfig;
const { basePath, i18n, trailingSlash } = (_options_nextConfig = options.nextConfig) != null ? _options_nextConfig : {};
const info = {
pathname,
trailingSlash: pathname !== "/" ? pathname.endsWith("/") : trailingSlash
};
if (basePath && (0, _pathhasprefix.pathHasPrefix)(info.pathname, basePath)) {
info.pathname = (0, _removepathprefix.removePathPrefix)(info.pathname, basePath);
info.basePath = basePath;
}
let pathnameNoDataPrefix = info.pathname;
if (info.pathname.startsWith("/_next/data/") && info.pathname.endsWith(".json")) {
const paths = info.pathname.replace(/^\/_next\/data\//, "").replace(/\.json$/, "").split("/");
const buildId = paths[0];
info.buildId = buildId;
pathnameNoDataPrefix = paths[1] !== "index" ? "/" + paths.slice(1).join("/") : "/";
if (options.parseData === true) {
info.pathname = pathnameNoDataPrefix;
}
}
if (i18n) {
let result = options.i18nProvider ? options.i18nProvider.analyze(info.pathname) : (0, _normalizelocalepath.normalizeLocalePath)(info.pathname, i18n.locales);
info.locale = result.detectedLocale;
var _result_pathname;
info.pathname = (_result_pathname = result.pathname) != null ? _result_pathname : info.pathname;
if (!result.detectedLocale && info.buildId) {
result = options.i18nProvider ? options.i18nProvider.analyze(pathnameNoDataPrefix) : (0, _normalizelocalepath.normalizeLocalePath)(pathnameNoDataPrefix, i18n.locales);
if (result.detectedLocale) {
info.locale = result.detectedLocale;
}
}
}
return info;
}
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/web/next-url.js
var require_next_url = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/web/next-url.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
Object.defineProperty(exports2, "NextURL", {
enumerable: true,
get: function() {
return NextURL;
}
});
var _detectdomainlocale = require_detect_domain_locale();
var _formatnextpathnameinfo = require_format_next_pathname_info();
var _gethostname = require_get_hostname();
var _getnextpathnameinfo = require_get_next_pathname_info();
var REGEX_LOCALHOST_HOSTNAME = /(?!^https?:\/\/)(127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|\[::1\]|localhost)/;
function parseURL(url, base) {
return new URL(String(url).replace(REGEX_LOCALHOST_HOSTNAME, "localhost"), base && String(base).replace(REGEX_LOCALHOST_HOSTNAME, "localhost"));
}
var Internal = Symbol("NextURLInternal");
var NextURL = class _NextURL {
constructor(input, baseOrOpts, opts) {
let base;
let options;
if (typeof baseOrOpts === "object" && "pathname" in baseOrOpts || typeof baseOrOpts === "string") {
base = baseOrOpts;
options = opts || {};
} else {
options = opts || baseOrOpts || {};
}
this[Internal] = {
url: parseURL(input, base ?? options.base),
options,
basePath: ""
};
this.analyze();
}
analyze() {
var _this_Internal_options_nextConfig_i18n, _this_Internal_options_nextConfig, _this_Internal_domainLocale, _this_Internal_options_nextConfig_i18n1, _this_Internal_options_nextConfig1;
const info = (0, _getnextpathnameinfo.getNextPathnameInfo)(this[Internal].url.pathname, {
nextConfig: this[Internal].options.nextConfig,
parseData: !process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE,
i18nProvider: this[Internal].options.i18nProvider
});
const hostname = (0, _gethostname.getHostname)(this[Internal].url, this[Internal].options.headers);
this[Internal].domainLocale = this[Internal].options.i18nProvider ? this[Internal].options.i18nProvider.detectDomainLocale(hostname) : (0, _detectdomainlocale.detectDomainLocale)((_this_Internal_options_nextConfig = this[Internal].options.nextConfig) == null ? void 0 : (_this_Internal_options_nextConfig_i18n = _this_Internal_options_nextConfig.i18n) == null ? void 0 : _this_Internal_options_nextConfig_i18n.domains, hostname);
const defaultLocale = ((_this_Internal_domainLocale = this[Internal].domainLocale) == null ? void 0 : _this_Internal_domainLocale.defaultLocale) || ((_this_Internal_options_nextConfig1 = this[Internal].options.nextConfig) == null ? void 0 : (_this_Internal_options_nextConfig_i18n1 = _this_Internal_options_nextConfig1.i18n) == null ? void 0 : _this_Internal_options_nextConfig_i18n1.defaultLocale);
this[Internal].url.pathname = info.pathname;
this[Internal].defaultLocale = defaultLocale;
this[Internal].basePath = info.basePath ?? "";
this[Internal].buildId = info.buildId;
this[Internal].locale = info.locale ?? defaultLocale;
this[Internal].trailingSlash = info.trailingSlash;
}
formatPathname() {
return (0, _formatnextpathnameinfo.formatNextPathnameInfo)({
basePath: this[Internal].basePath,
buildId: this[Internal].buildId,
defaultLocale: !this[Internal].options.forceLocale ? this[Internal].defaultLocale : void 0,
locale: this[Internal].locale,
pathname: this[Internal].url.pathname,
trailingSlash: this[Internal].trailingSlash
});
}
formatSearch() {
return this[Internal].url.search;
}
get buildId() {
return this[Internal].buildId;
}
set buildId(buildId) {
this[Internal].buildId = buildId;
}
get locale() {
return this[Internal].locale ?? "";
}
set locale(locale) {
var _this_Internal_options_nextConfig_i18n, _this_Internal_options_nextConfig;
if (!this[Internal].locale || !((_this_Internal_options_nextConfig = this[Internal].options.nextConfig) == null ? void 0 : (_this_Internal_options_nextConfig_i18n = _this_Internal_options_nextConfig.i18n) == null ? void 0 : _this_Internal_options_nextConfig_i18n.locales.includes(locale))) {
throw new TypeError(`The NextURL configuration includes no locale "${locale}"`);
}
this[Internal].locale = locale;
}
get defaultLocale() {
return this[Internal].defaultLocale;
}
get domainLocale() {
return this[Internal].domainLocale;
}
get searchParams() {
return this[Internal].url.searchParams;
}
get host() {
return this[Internal].url.host;
}
set host(value) {
this[Internal].url.host = value;
}
get hostname() {
return this[Internal].url.hostname;
}
set hostname(value) {
this[Internal].url.hostname = value;
}
get port() {
return this[Internal].url.port;
}
set port(value) {
this[Internal].url.port = value;
}
get protocol() {
return this[Internal].url.protocol;
}
set protocol(value) {
this[Internal].url.protocol = value;
}
get href() {
const pathname = this.formatPathname();
const search = this.formatSearch();
return `${this.protocol}//${this.host}${pathname}${search}${this.hash}`;
}
set href(url) {
this[Internal].url = parseURL(url);
this.analyze();
}
get origin() {
return this[Internal].url.origin;
}
get pathname() {
return this[Internal].url.pathname;
}
set pathname(value) {
this[Internal].url.pathname = value;
}
get hash() {
return this[Internal].url.hash;
}
set hash(value) {
this[Internal].url.hash = value;
}
get search() {
return this[Internal].url.search;
}
set search(value) {
this[Internal].url.search = value;
}
get password() {
return this[Internal].url.password;
}
set password(value) {
this[Internal].url.password = value;
}
get username() {
return this[Internal].url.username;
}
set username(value) {
this[Internal].url.username = value;
}
get basePath() {
return this[Internal].basePath;
}
set basePath(value) {
this[Internal].basePath = value.startsWith("/") ? value : `/${value}`;
}
toString() {
return this.href;
}
toJSON() {
return this.href;
}
[Symbol.for("edge-runtime.inspect.custom")]() {
return {
href: this.href,
origin: this.origin,
protocol: this.protocol,
username: this.username,
password: this.password,
host: this.host,
hostname: this.hostname,
port: this.port,
pathname: this.pathname,
search: this.search,
searchParams: this.searchParams,
hash: this.hash
};
}
clone() {
return new _NextURL(String(this), this[Internal].options);
}
};
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/web/utils.js
var require_utils = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/web/utils.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
function _export(target, all) {
for (var name in all)
Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports2, {
fromNodeOutgoingHttpHeaders: function() {
return fromNodeOutgoingHttpHeaders;
},
splitCookiesString: function() {
return splitCookiesString;
},
toNodeOutgoingHttpHeaders: function() {
return toNodeOutgoingHttpHeaders;
},
validateURL: function() {
return validateURL;
}
});
function fromNodeOutgoingHttpHeaders(nodeHeaders) {
const headers = new Headers();
for (let [key, value] of Object.entries(nodeHeaders)) {
const values = Array.isArray(value) ? value : [
value
];
for (let v of values) {
if (typeof v === "undefined")
continue;
if (typeof v === "number") {
v = v.toString();
}
headers.append(key, v);
}
}
return headers;
}
function splitCookiesString(cookiesString) {
var cookiesStrings = [];
var pos = 0;
var start;
var ch;
var lastComma;
var nextStart;
var cookiesSeparatorFound;
function skipWhitespace() {
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
pos += 1;
}
return pos < cookiesString.length;
}
function notSpecialChar() {
ch = cookiesString.charAt(pos);
return ch !== "=" && ch !== ";" && ch !== ",";
}
while (pos < cookiesString.length) {
start = pos;
cookiesSeparatorFound = false;
while (skipWhitespace()) {
ch = cookiesString.charAt(pos);
if (ch === ",") {
lastComma = pos;
pos += 1;
skipWhitespace();
nextStart = pos;
while (pos < cookiesString.length && notSpecialChar()) {
pos += 1;
}
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
cookiesSeparatorFound = true;
pos = nextStart;
cookiesStrings.push(cookiesString.substring(start, lastComma));
start = pos;
} else {
pos = lastComma + 1;
}
} else {
pos += 1;
}
}
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
}
}
return cookiesStrings;
}
function toNodeOutgoingHttpHeaders(headers) {
const nodeHeaders = {};
const cookies = [];
if (headers) {
for (const [key, value] of headers.entries()) {
if (key.toLowerCase() === "set-cookie") {
cookies.push(...splitCookiesString(value));
nodeHeaders[key] = cookies.length === 1 ? cookies[0] : cookies;
} else {
nodeHeaders[key] = value;
}
}
}
return nodeHeaders;
}
function validateURL(url) {
try {
return String(new URL(String(url)));
} catch (error) {
throw new Error(`URL is malformed "${String(url)}". Please use only absolute URLs - https://nextjs.org/docs/messages/middleware-relative-urls`, {
cause: error
});
}
}
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/web/error.js
var require_error = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/web/error.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
function _export(target, all) {
for (var name in all)
Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports2, {
PageSignatureError: function() {
return PageSignatureError;
},
RemovedPageError: function() {
return RemovedPageError;
},
RemovedUAError: function() {
return RemovedUAError;
}
});
var PageSignatureError = class extends Error {
constructor({ page }) {
super(`The middleware "${page}" accepts an async API directly with the form:
export function middleware(request, event) {
return NextResponse.redirect('/new-location')
}
Read more: https://nextjs.org/docs/messages/middleware-new-signature
`);
}
};
var RemovedPageError = class extends Error {
constructor() {
super(`The request.page has been deprecated in favour of \`URLPattern\`.
Read more: https://nextjs.org/docs/messages/middleware-request-page
`);
}
};
var RemovedUAError = class extends Error {
constructor() {
super(`The request.ua has been removed in favour of \`userAgent\` function.
Read more: https://nextjs.org/docs/messages/middleware-parse-user-agent
`);
}
};
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/@edge-runtime/cookies/index.js
var require_cookies = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/@edge-runtime/cookies/index.js"(exports2, module2) {
"use strict";
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
var __getOwnPropNames2 = Object.getOwnPropertyNames;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __export2 = (target, all) => {
for (var name in all)
__defProp2(target, name, { get: all[name], enumerable: true });
};
var __copyProps2 = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames2(from))
if (!__hasOwnProp2.call(to, key) && key !== except)
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var src_exports2 = {};
__export2(src_exports2, {
RequestCookies: () => RequestCookies,
ResponseCookies: () => ResponseCookies,
parseCookie: () => parseCookie,
parseSetCookie: () => parseSetCookie,
stringifyCookie: () => stringifyCookie
});
module2.exports = __toCommonJS2(src_exports2);
function stringifyCookie(c) {
var _a;
const attrs = [
"path" in c && c.path && `Path=${c.path}`,
"expires" in c && (c.expires || c.expires === 0) && `Expires=${(typeof c.expires === "number" ? new Date(c.expires) : c.expires).toUTCString()}`,
"maxAge" in c && typeof c.maxAge === "number" && `Max-Age=${c.maxAge}`,
"domain" in c && c.domain && `Domain=${c.domain}`,
"secure" in c && c.secure && "Secure",
"httpOnly" in c && c.httpOnly && "HttpOnly",
"sameSite" in c && c.sameSite && `SameSite=${c.sameSite}`,
"priority" in c && c.priority && `Priority=${c.priority}`
].filter(Boolean);
return `${c.name}=${encodeURIComponent((_a = c.value) != null ? _a : "")}; ${attrs.join("; ")}`;
}
function parseCookie(cookie) {
const map = /* @__PURE__ */ new Map();
for (const pair of cookie.split(/; */)) {
if (!pair)
continue;
const splitAt = pair.indexOf("=");
if (splitAt === -1) {
map.set(pair, "true");
continue;
}
const [key, value] = [pair.slice(0, splitAt), pair.slice(splitAt + 1)];
try {
map.set(key, decodeURIComponent(value != null ? value : "true"));
} catch {
}
}
return map;
}
function parseSetCookie(setCookie) {
if (!setCookie) {
return void 0;
}
const [[name, value], ...attributes] = parseCookie(setCookie);
const {
domain,
expires,
httponly,
maxage,
path,
samesite,
secure,
priority
} = Object.fromEntries(
attributes.map(([key, value2]) => [key.toLowerCase(), value2])
);
const cookie = {
name,
value: decodeURIComponent(value),
domain,
...expires && { expires: new Date(expires) },
...httponly && { httpOnly: true },
...typeof maxage === "string" && { maxAge: Number(maxage) },
path,
...samesite && { sameSite: parseSameSite(samesite) },
...secure && { secure: true },
...priority && { priority: parsePriority(priority) }
};
return compact(cookie);
}
function compact(t) {
const newT = {};
for (const key in t) {
if (t[key]) {
newT[key] = t[key];
}
}
return newT;
}
var SAME_SITE = ["strict", "lax", "none"];
function parseSameSite(string) {
string = string.toLowerCase();
return SAME_SITE.includes(string) ? string : void 0;
}
var PRIORITY = ["low", "medium", "high"];
function parsePriority(string) {
string = string.toLowerCase();
return PRIORITY.includes(string) ? string : void 0;
}
function splitCookiesString(cookiesString) {
if (!cookiesString)
return [];
var cookiesStrings = [];
var pos = 0;
var start;
var ch;
var lastComma;
var nextStart;
var cookiesSeparatorFound;
function skipWhitespace() {
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
pos += 1;
}
return pos < cookiesString.length;
}
function notSpecialChar() {
ch = cookiesString.charAt(pos);
return ch !== "=" && ch !== ";" && ch !== ",";
}
while (pos < cookiesString.length) {
start = pos;
cookiesSeparatorFound = false;
while (skipWhitespace()) {
ch = cookiesString.charAt(pos);
if (ch === ",") {
lastComma = pos;
pos += 1;
skipWhitespace();
nextStart = pos;
while (pos < cookiesString.length && notSpecialChar()) {
pos += 1;
}
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
cookiesSeparatorFound = true;
pos = nextStart;
cookiesStrings.push(cookiesString.substring(start, lastComma));
start = pos;
} else {
pos = lastComma + 1;
}
} else {
pos += 1;
}
}
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
}
}
return cookiesStrings;
}
var RequestCookies = class {
constructor(requestHeaders) {
this._parsed = /* @__PURE__ */ new Map();
this._headers = requestHeaders;
const header = requestHeaders.get("cookie");
if (header) {
const parsed = parseCookie(header);
for (const [name, value] of parsed) {
this._parsed.set(name, { name, value });
}
}
}
[Symbol.iterator]() {
return this._parsed[Symbol.iterator]();
}
/**
* The amount of cookies received from the client
*/
get size() {
return this._parsed.size;
}
get(...args) {
const name = typeof args[0] === "string" ? args[0] : args[0].name;
return this._parsed.get(name);
}
getAll(...args) {
var _a;
const all = Array.from(this._parsed);
if (!args.length) {
return all.map(([_, value]) => value);
}
const name = typeof args[0] === "string" ? args[0] : (_a = args[0]) == null ? void 0 : _a.name;
return all.filter(([n]) => n === name).map(([_, value]) => value);
}
has(name) {
return this._parsed.has(name);
}
set(...args) {
const [name, value] = args.length === 1 ? [args[0].name, args[0].value] : args;
const map = this._parsed;
map.set(name, { name, value });
this._headers.set(
"cookie",
Array.from(map).map(([_, value2]) => stringifyCookie(value2)).join("; ")
);
return this;
}
/**
* Delete the cookies matching the passed name or names in the request.
*/
delete(names) {
const map = this._parsed;
const result = !Array.isArray(names) ? map.delete(names) : names.map((name) => map.delete(name));
this._headers.set(
"cookie",
Array.from(map).map(([_, value]) => stringifyCookie(value)).join("; ")
);
return result;
}
/**
* Delete all the cookies in the cookies in the request.
*/
clear() {
this.delete(Array.from(this._parsed.keys()));
return this;
}
/**
* Format the cookies in the request as a string for logging
*/
[Symbol.for("edge-runtime.inspect.custom")]() {
return `RequestCookies ${JSON.stringify(Object.fromEntries(this._parsed))}`;
}
toString() {
return [...this._parsed.values()].map((v) => `${v.name}=${encodeURIComponent(v.value)}`).join("; ");
}
};
var ResponseCookies = class {
constructor(responseHeaders) {
this._parsed = /* @__PURE__ */ new Map();
var _a, _b, _c;
this._headers = responseHeaders;
const setCookie = (_c = (_b = (_a = responseHeaders.getSetCookie) == null ? void 0 : _a.call(responseHeaders)) != null ? _b : responseHeaders.get("set-cookie")) != null ? _c : [];
const cookieStrings = Array.isArray(setCookie) ? setCookie : splitCookiesString(setCookie);
for (const cookieString of cookieStrings) {
const parsed = parseSetCookie(cookieString);
if (parsed)
this._parsed.set(parsed.name, parsed);
}
}
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-get CookieStore#get} without the Promise.
*/
get(...args) {
const key = typeof args[0] === "string" ? args[0] : args[0].name;
return this._parsed.get(key);
}
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-getAll CookieStore#getAll} without the Promise.
*/
getAll(...args) {
var _a;
const all = Array.from(this._parsed.values());
if (!args.length) {
return all;
}
const key = typeof args[0] === "string" ? args[0] : (_a = args[0]) == null ? void 0 : _a.name;
return all.filter((c) => c.name === key);
}
has(name) {
return this._parsed.has(name);
}
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-set CookieStore#set} without the Promise.
*/
set(...args) {
const [name, value, cookie] = args.length === 1 ? [args[0].name, args[0].value, args[0]] : args;
const map = this._parsed;
map.set(name, normalizeCookie({ name, value, ...cookie }));
replace(map, this._headers);
return this;
}
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-delete CookieStore#delete} without the Promise.
*/
delete(...args) {
const [name, path, domain] = typeof args[0] === "string" ? [args[0]] : [args[0].name, args[0].path, args[0].domain];
return this.set({ name, path, domain, value: "", expires: /* @__PURE__ */ new Date(0) });
}
[Symbol.for("edge-runtime.inspect.custom")]() {
return `ResponseCookies ${JSON.stringify(Object.fromEntries(this._parsed))}`;
}
toString() {
return [...this._parsed.values()].map(stringifyCookie).join("; ");
}
};
function replace(bag, headers) {
headers.delete("set-cookie");
for (const [, value] of bag) {
const serialized = stringifyCookie(value);
headers.append("set-cookie", serialized);
}
}
function normalizeCookie(cookie = { name: "", value: "" }) {
if (typeof cookie.expires === "number") {
cookie.expires = new Date(cookie.expires);
}
if (cookie.maxAge) {
cookie.expires = new Date(Date.now() + cookie.maxAge * 1e3);
}
if (cookie.path === null || cookie.path === void 0) {
cookie.path = "/";
}
return cookie;
}
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/web/spec-extension/cookies.js
var require_cookies2 = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/web/spec-extension/cookies.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
function _export(target, all) {
for (var name in all)
Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports2, {
RequestCookies: function() {
return _cookies.RequestCookies;
},
ResponseCookies: function() {
return _cookies.ResponseCookies;
}
});
var _cookies = require_cookies();
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/web/spec-extension/request.js
var require_request = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/web/spec-extension/request.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
function _export(target, all) {
for (var name in all)
Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports2, {
INTERNALS: function() {
return INTERNALS;
},
NextRequest: function() {
return NextRequest2;
}
});
var _nexturl = require_next_url();
var _utils = require_utils();
var _error = require_error();
var _cookies = require_cookies2();
var INTERNALS = Symbol("internal request");
var NextRequest2 = class extends Request {
constructor(input, init = {}) {
const url = typeof input !== "string" && "url" in input ? input.url : String(input);
(0, _utils.validateURL)(url);
if (input instanceof Request)
super(input, init);
else
super(url, init);
const nextUrl = new _nexturl.NextURL(url, {
headers: (0, _utils.toNodeOutgoingHttpHeaders)(this.headers),
nextConfig: init.nextConfig
});
this[INTERNALS] = {
cookies: new _cookies.RequestCookies(this.headers),
geo: init.geo || {},
ip: init.ip,
nextUrl,
url: process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE ? url : nextUrl.toString()
};
}
[Symbol.for("edge-runtime.inspect.custom")]() {
return {
cookies: this.cookies,
geo: this.geo,
ip: this.ip,
nextUrl: this.nextUrl,
url: this.url,
// rest of props come from Request
bodyUsed: this.bodyUsed,
cache: this.cache,
credentials: this.credentials,
destination: this.destination,
headers: Object.fromEntries(this.headers),
integrity: this.integrity,
keepalive: this.keepalive,
method: this.method,
mode: this.mode,
redirect: this.redirect,
referrer: this.referrer,
referrerPolicy: this.referrerPolicy,
signal: this.signal
};
}
get cookies() {
return this[INTERNALS].cookies;
}
get geo() {
return this[INTERNALS].geo;
}
get ip() {
return this[INTERNALS].ip;
}
get nextUrl() {
return this[INTERNALS].nextUrl;
}
/**
* @deprecated
* `page` has been deprecated in favour of `URLPattern`.
* Read more: https://nextjs.org/docs/messages/middleware-request-page
*/
get page() {
throw new _error.RemovedPageError();
}
/**
* @deprecated
* `ua` has been removed in favour of \`userAgent\` function.
* Read more: https://nextjs.org/docs/messages/middleware-parse-user-agent
*/
get ua() {
throw new _error.RemovedUAError();
}
get url() {
return this[INTERNALS].url;
}
};
}
});
// ../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/web/spec-extension/response.js
var require_response = __commonJS({
"../../node_modules/.pnpm/next@14.0.3_@babel+core@7.22.11_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/web/spec-extension/response.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", {
value: true
});
Object.defineProperty(exports2, "NextResponse", {
enumerable: true,
get: function() {
return NextResponse5;
}
});
var _nexturl = require_next_url();
var _utils = require_utils();
var _cookies = require_cookies2();
var INTERNALS = Symbol("internal response");
var REDIRECTS = /* @__PURE__ */ new Set([
301,
302,
303,
307,
308
]);
function handleMiddlewareField(init, headers) {
var _init_request;
if (init == null ? void 0 : (_init_request = init.request) == null ? void 0 : _init_request.headers) {
if (!(init.request.headers instanceof Headers)) {
throw new Error("request.headers must be an instance of Headers");
}
const keys = [];
for (const [key, value] of init.request.headers) {
headers.set("x-middleware-request-" + key, value);
keys.push(key);
}
headers.set("x-middleware-override-headers", keys.join(","));
}
}
var NextResponse5 = class _NextResponse extends Response {
constructor(body, init = {}) {
super(body, init);
this[INTERNALS] = {
cookies: new _cookies.ResponseCookies(this.headers),
url: init.url ? new _nexturl.NextURL(init.url, {
headers: (0, _utils.toNodeOutgoingHttpHeaders)(this.headers),
nextConfig: init.nextConfig
}) : void 0
};
}
[Symbol.for("edge-runtime.inspect.custom")]() {
return {
cookies: this.cookies,
url: this.url,
// rest of props come from Response
body: this.body,
bodyUsed: this.bodyUsed,
headers: Object.fromEntries(this.headers),
ok: this.ok,
redirected: this.redirected,
status: this.status,
statusText: this.statusText,
type: this.type
};
}
get cookies() {
return this[INTERNALS].cookies;
}
static json(body, init) {
const response = Response.json(body, init);
return new _NextResponse(response.body, response);
}
static redirect(url, init) {
const status = typeof init === "number" ? init : (init == null ? void 0 : init.status) ?? 307;
if (!REDIRECTS.has(status)) {
throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');
}
const initObj = typeof init === "object" ? init : {};
const headers = new Headers(initObj == null ? void 0 : initObj.headers);
headers.set("Location", (0, _utils.