@vercel/redwood 2.4.9 → 2.4.11
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/dist/index.js +150 -26
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -928,7 +928,7 @@ var require_superstatic = __commonJS({
|
|
|
928
928
|
route.missing = r.missing;
|
|
929
929
|
}
|
|
930
930
|
return route;
|
|
931
|
-
} catch (
|
|
931
|
+
} catch (_e) {
|
|
932
932
|
throw new Error(`Failed to parse redirect: ${JSON.stringify(r)}`);
|
|
933
933
|
}
|
|
934
934
|
});
|
|
@@ -961,7 +961,7 @@ var require_superstatic = __commonJS({
|
|
|
961
961
|
route.status = r.statusCode;
|
|
962
962
|
}
|
|
963
963
|
return route;
|
|
964
|
-
} catch (
|
|
964
|
+
} catch (_e) {
|
|
965
965
|
throw new Error(`Failed to parse rewrite: ${JSON.stringify(r)}`);
|
|
966
966
|
}
|
|
967
967
|
});
|
|
@@ -1172,7 +1172,7 @@ var require_superstatic = __commonJS({
|
|
|
1172
1172
|
if (attemptDirectCompile) {
|
|
1173
1173
|
try {
|
|
1174
1174
|
return (0, import_path_to_regexp.compile)(value, { validate: false })(indexes);
|
|
1175
|
-
} catch (
|
|
1175
|
+
} catch (_e) {
|
|
1176
1176
|
}
|
|
1177
1177
|
}
|
|
1178
1178
|
for (const key of Object.keys(indexes)) {
|
|
@@ -1390,6 +1390,76 @@ var require_merge = __commonJS({
|
|
|
1390
1390
|
}
|
|
1391
1391
|
});
|
|
1392
1392
|
|
|
1393
|
+
// ../routing-utils/dist/service-route-ownership.js
|
|
1394
|
+
var require_service_route_ownership = __commonJS({
|
|
1395
|
+
"../routing-utils/dist/service-route-ownership.js"(exports, module2) {
|
|
1396
|
+
"use strict";
|
|
1397
|
+
var __defProp2 = Object.defineProperty;
|
|
1398
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
1399
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
1400
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
1401
|
+
var __export2 = (target, all) => {
|
|
1402
|
+
for (var name in all)
|
|
1403
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
1404
|
+
};
|
|
1405
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
1406
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
1407
|
+
for (let key of __getOwnPropNames2(from))
|
|
1408
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
1409
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
1410
|
+
}
|
|
1411
|
+
return to;
|
|
1412
|
+
};
|
|
1413
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
1414
|
+
var service_route_ownership_exports = {};
|
|
1415
|
+
__export2(service_route_ownership_exports, {
|
|
1416
|
+
getOwnershipGuard: () => getOwnershipGuard2,
|
|
1417
|
+
normalizeRoutePrefix: () => normalizeRoutePrefix2,
|
|
1418
|
+
scopeRouteSourceToOwnership: () => scopeRouteSourceToOwnership2
|
|
1419
|
+
});
|
|
1420
|
+
module2.exports = __toCommonJS2(service_route_ownership_exports);
|
|
1421
|
+
function normalizeRoutePrefix2(routePrefix) {
|
|
1422
|
+
let normalized = routePrefix.startsWith("/") ? routePrefix : `/${routePrefix}`;
|
|
1423
|
+
if (normalized !== "/" && normalized.endsWith("/")) {
|
|
1424
|
+
normalized = normalized.slice(0, -1);
|
|
1425
|
+
}
|
|
1426
|
+
return normalized || "/";
|
|
1427
|
+
}
|
|
1428
|
+
function escapeForRegex(value) {
|
|
1429
|
+
return value.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
|
|
1430
|
+
}
|
|
1431
|
+
function toPrefixMatcher(routePrefix) {
|
|
1432
|
+
return `${escapeForRegex(routePrefix)}(?:/|$)`;
|
|
1433
|
+
}
|
|
1434
|
+
function isDescendantPrefix(candidate, prefix) {
|
|
1435
|
+
return candidate !== prefix && candidate.startsWith(`${prefix}/`);
|
|
1436
|
+
}
|
|
1437
|
+
function getOwnershipGuard2(ownerPrefix, allRoutePrefixes) {
|
|
1438
|
+
const owner = normalizeRoutePrefix2(ownerPrefix);
|
|
1439
|
+
const normalizedPrefixes = Array.from(
|
|
1440
|
+
new Set(allRoutePrefixes.map(normalizeRoutePrefix2))
|
|
1441
|
+
);
|
|
1442
|
+
const nonRootPrefixes = normalizedPrefixes.filter((prefix) => prefix !== "/").sort((a, b) => b.length - a.length);
|
|
1443
|
+
if (owner === "/") {
|
|
1444
|
+
return nonRootPrefixes.map((prefix) => `(?!${toPrefixMatcher(prefix)})`).join("");
|
|
1445
|
+
}
|
|
1446
|
+
const descendants = nonRootPrefixes.filter(
|
|
1447
|
+
(prefix) => isDescendantPrefix(prefix, owner)
|
|
1448
|
+
);
|
|
1449
|
+
const positive = `(?=${toPrefixMatcher(owner)})`;
|
|
1450
|
+
const negative = descendants.map((prefix) => `(?!${toPrefixMatcher(prefix)})`).join("");
|
|
1451
|
+
return `${positive}${negative}`;
|
|
1452
|
+
}
|
|
1453
|
+
function scopeRouteSourceToOwnership2(source, ownershipGuard) {
|
|
1454
|
+
if (!ownershipGuard) {
|
|
1455
|
+
return source;
|
|
1456
|
+
}
|
|
1457
|
+
const inner = source.startsWith("^") ? source.slice(1) : source;
|
|
1458
|
+
return `^${ownershipGuard}(?:${inner})`;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
});
|
|
1462
|
+
|
|
1393
1463
|
// ../routing-utils/dist/schemas.js
|
|
1394
1464
|
var require_schemas = __commonJS({
|
|
1395
1465
|
"../routing-utils/dist/schemas.js"(exports, module2) {
|
|
@@ -1699,6 +1769,7 @@ var require_schemas = __commonJS({
|
|
|
1699
1769
|
}
|
|
1700
1770
|
}
|
|
1701
1771
|
},
|
|
1772
|
+
// biome-ignore lint/suspicious/noThenProperty: JSON Schema if/then keyword
|
|
1702
1773
|
then: {
|
|
1703
1774
|
required: ["args"]
|
|
1704
1775
|
}
|
|
@@ -1722,6 +1793,7 @@ var require_schemas = __commonJS({
|
|
|
1722
1793
|
}
|
|
1723
1794
|
]
|
|
1724
1795
|
},
|
|
1796
|
+
// biome-ignore lint/suspicious/noThenProperty: JSON Schema if/then keyword
|
|
1725
1797
|
then: {
|
|
1726
1798
|
properties: {
|
|
1727
1799
|
target: {
|
|
@@ -1730,6 +1802,7 @@ var require_schemas = __commonJS({
|
|
|
1730
1802
|
if: {
|
|
1731
1803
|
type: "string"
|
|
1732
1804
|
},
|
|
1805
|
+
// biome-ignore lint/suspicious/noThenProperty: JSON Schema if/then keyword
|
|
1733
1806
|
then: {
|
|
1734
1807
|
pattern: "^[a-zA-Z0-9_-]+$"
|
|
1735
1808
|
}
|
|
@@ -1759,24 +1832,31 @@ var require_schemas = __commonJS({
|
|
|
1759
1832
|
};
|
|
1760
1833
|
var routesSchema = {
|
|
1761
1834
|
type: "array",
|
|
1762
|
-
deprecated: true,
|
|
1763
1835
|
description: "A list of routes objects used to rewrite paths to point towards other internal or external paths",
|
|
1764
1836
|
example: [{ dest: "https://docs.example.com", src: "/docs" }],
|
|
1765
1837
|
items: {
|
|
1766
1838
|
anyOf: [
|
|
1767
1839
|
{
|
|
1768
1840
|
type: "object",
|
|
1769
|
-
required: ["src"],
|
|
1841
|
+
anyOf: [{ required: ["src"] }, { required: ["source"] }],
|
|
1770
1842
|
additionalProperties: false,
|
|
1771
1843
|
properties: {
|
|
1772
1844
|
src: {
|
|
1773
1845
|
type: "string",
|
|
1774
1846
|
maxLength: 4096
|
|
1775
1847
|
},
|
|
1848
|
+
source: {
|
|
1849
|
+
type: "string",
|
|
1850
|
+
maxLength: 4096
|
|
1851
|
+
},
|
|
1776
1852
|
dest: {
|
|
1777
1853
|
type: "string",
|
|
1778
1854
|
maxLength: 4096
|
|
1779
1855
|
},
|
|
1856
|
+
destination: {
|
|
1857
|
+
type: "string",
|
|
1858
|
+
maxLength: 4096
|
|
1859
|
+
},
|
|
1780
1860
|
headers: {
|
|
1781
1861
|
type: "object",
|
|
1782
1862
|
additionalProperties: false,
|
|
@@ -1801,6 +1881,7 @@ var require_schemas = __commonJS({
|
|
|
1801
1881
|
type: "boolean"
|
|
1802
1882
|
},
|
|
1803
1883
|
important: {
|
|
1884
|
+
deprecated: true,
|
|
1804
1885
|
type: "boolean"
|
|
1805
1886
|
},
|
|
1806
1887
|
user: {
|
|
@@ -1810,6 +1891,7 @@ var require_schemas = __commonJS({
|
|
|
1810
1891
|
type: "boolean"
|
|
1811
1892
|
},
|
|
1812
1893
|
override: {
|
|
1894
|
+
deprecated: true,
|
|
1813
1895
|
type: "boolean"
|
|
1814
1896
|
},
|
|
1815
1897
|
check: {
|
|
@@ -1823,6 +1905,11 @@ var require_schemas = __commonJS({
|
|
|
1823
1905
|
minimum: 100,
|
|
1824
1906
|
maximum: 999
|
|
1825
1907
|
},
|
|
1908
|
+
statusCode: {
|
|
1909
|
+
type: "integer",
|
|
1910
|
+
minimum: 100,
|
|
1911
|
+
maximum: 999
|
|
1912
|
+
},
|
|
1826
1913
|
locale: {
|
|
1827
1914
|
type: "object",
|
|
1828
1915
|
additionalProperties: false,
|
|
@@ -1888,6 +1975,7 @@ var require_schemas = __commonJS({
|
|
|
1888
1975
|
},
|
|
1889
1976
|
{
|
|
1890
1977
|
type: "object",
|
|
1978
|
+
deprecated: true,
|
|
1891
1979
|
required: ["handle"],
|
|
1892
1980
|
additionalProperties: false,
|
|
1893
1981
|
properties: {
|
|
@@ -2127,11 +2215,14 @@ var require_dist3 = __commonJS({
|
|
|
2127
2215
|
__export2(src_exports2, {
|
|
2128
2216
|
appendRoutesToPhase: () => import_append.appendRoutesToPhase,
|
|
2129
2217
|
getCleanUrls: () => import_superstatic2.getCleanUrls,
|
|
2218
|
+
getOwnershipGuard: () => import_service_route_ownership.getOwnershipGuard,
|
|
2130
2219
|
getTransformedRoutes: () => getTransformedRoutes2,
|
|
2131
2220
|
isHandler: () => isHandler,
|
|
2132
2221
|
isValidHandleValue: () => isValidHandleValue,
|
|
2133
2222
|
mergeRoutes: () => import_merge.mergeRoutes,
|
|
2223
|
+
normalizeRoutePrefix: () => import_service_route_ownership.normalizeRoutePrefix,
|
|
2134
2224
|
normalizeRoutes: () => normalizeRoutes,
|
|
2225
|
+
scopeRouteSourceToOwnership: () => import_service_route_ownership.scopeRouteSourceToOwnership,
|
|
2135
2226
|
sourceToRegex: () => import_superstatic2.sourceToRegex
|
|
2136
2227
|
});
|
|
2137
2228
|
module2.exports = __toCommonJS2(src_exports2);
|
|
@@ -2139,6 +2230,7 @@ var require_dist3 = __commonJS({
|
|
|
2139
2230
|
var import_superstatic = require_superstatic();
|
|
2140
2231
|
var import_append = require_append();
|
|
2141
2232
|
var import_merge = require_merge();
|
|
2233
|
+
var import_service_route_ownership = require_service_route_ownership();
|
|
2142
2234
|
__reExport(src_exports2, require_schemas(), module2.exports);
|
|
2143
2235
|
var import_superstatic2 = require_superstatic();
|
|
2144
2236
|
__reExport(src_exports2, require_types(), module2.exports);
|
|
@@ -2157,6 +2249,35 @@ var require_dist3 = __commonJS({
|
|
|
2157
2249
|
function isValidHandleValue(handle) {
|
|
2158
2250
|
return validHandleValues.has(handle);
|
|
2159
2251
|
}
|
|
2252
|
+
function convertRouteAliases(route, index) {
|
|
2253
|
+
if (route.source !== void 0) {
|
|
2254
|
+
if (route.src !== void 0) {
|
|
2255
|
+
throw new Error(
|
|
2256
|
+
`Route at index ${index} cannot define both \`src\` and \`source\`. Please use only one.`
|
|
2257
|
+
);
|
|
2258
|
+
}
|
|
2259
|
+
route.src = route.source;
|
|
2260
|
+
delete route.source;
|
|
2261
|
+
}
|
|
2262
|
+
if (route.destination !== void 0) {
|
|
2263
|
+
if (route.dest !== void 0) {
|
|
2264
|
+
throw new Error(
|
|
2265
|
+
`Route at index ${index} cannot define both \`dest\` and \`destination\`. Please use only one.`
|
|
2266
|
+
);
|
|
2267
|
+
}
|
|
2268
|
+
route.dest = route.destination;
|
|
2269
|
+
delete route.destination;
|
|
2270
|
+
}
|
|
2271
|
+
if (route.statusCode !== void 0) {
|
|
2272
|
+
if (route.status !== void 0) {
|
|
2273
|
+
throw new Error(
|
|
2274
|
+
`Route at index ${index} cannot define both \`status\` and \`statusCode\`. Please use only one.`
|
|
2275
|
+
);
|
|
2276
|
+
}
|
|
2277
|
+
route.status = route.statusCode;
|
|
2278
|
+
delete route.statusCode;
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2160
2281
|
function normalizeRoutes(inputRoutes) {
|
|
2161
2282
|
if (!inputRoutes || inputRoutes.length === 0) {
|
|
2162
2283
|
return { routes: inputRoutes, error: null };
|
|
@@ -2167,6 +2288,13 @@ var require_dist3 = __commonJS({
|
|
|
2167
2288
|
inputRoutes.forEach((r, i) => {
|
|
2168
2289
|
const route = { ...r };
|
|
2169
2290
|
routes.push(route);
|
|
2291
|
+
if (!isHandler(route)) {
|
|
2292
|
+
try {
|
|
2293
|
+
convertRouteAliases(route, i);
|
|
2294
|
+
} catch (err) {
|
|
2295
|
+
errors.push(err.message);
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2170
2298
|
const keys = Object.keys(route);
|
|
2171
2299
|
if (isHandler(route)) {
|
|
2172
2300
|
const { handle } = route;
|
|
@@ -2202,12 +2330,12 @@ var require_dist3 = __commonJS({
|
|
|
2202
2330
|
if (handleValue === "hit") {
|
|
2203
2331
|
if (route.dest) {
|
|
2204
2332
|
errors.push(
|
|
2205
|
-
`Route at index ${i} cannot define \`dest\` after \`handle: hit\`.`
|
|
2333
|
+
`Route at index ${i} cannot define \`dest\`/\`destination\` after \`handle: hit\`.`
|
|
2206
2334
|
);
|
|
2207
2335
|
}
|
|
2208
2336
|
if (route.status) {
|
|
2209
2337
|
errors.push(
|
|
2210
|
-
`Route at index ${i} cannot define \`status\` after \`handle: hit\`.`
|
|
2338
|
+
`Route at index ${i} cannot define \`status\`/\`statusCode\` after \`handle: hit\`.`
|
|
2211
2339
|
);
|
|
2212
2340
|
}
|
|
2213
2341
|
if (!route.continue) {
|
|
@@ -2228,7 +2356,7 @@ var require_dist3 = __commonJS({
|
|
|
2228
2356
|
}
|
|
2229
2357
|
} else {
|
|
2230
2358
|
errors.push(
|
|
2231
|
-
`Route at index ${i} must define either \`
|
|
2359
|
+
`Route at index ${i} must define either \`src\` or \`source\` property.`
|
|
2232
2360
|
);
|
|
2233
2361
|
}
|
|
2234
2362
|
});
|
|
@@ -2243,8 +2371,8 @@ var require_dist3 = __commonJS({
|
|
|
2243
2371
|
function checkRegexSyntax(type, index, src) {
|
|
2244
2372
|
try {
|
|
2245
2373
|
new RegExp(src);
|
|
2246
|
-
} catch (
|
|
2247
|
-
const prop = type === "Route" ? "src" : "source";
|
|
2374
|
+
} catch (_err) {
|
|
2375
|
+
const prop = type === "Route" ? "src`/`source" : "source";
|
|
2248
2376
|
return `${type} at index ${index} has invalid \`${prop}\` regular expression "${src}".`;
|
|
2249
2377
|
}
|
|
2250
2378
|
return null;
|
|
@@ -2258,7 +2386,7 @@ var require_dist3 = __commonJS({
|
|
|
2258
2386
|
const destinationSegments = /* @__PURE__ */ new Set();
|
|
2259
2387
|
try {
|
|
2260
2388
|
sourceSegments = new Set((0, import_superstatic.sourceToRegex)(source).segments);
|
|
2261
|
-
} catch (
|
|
2389
|
+
} catch (_err) {
|
|
2262
2390
|
return {
|
|
2263
2391
|
message: `${type} at index ${index} has invalid \`source\` pattern "${source}".`,
|
|
2264
2392
|
link: "https://vercel.link/invalid-route-source-pattern"
|
|
@@ -2279,7 +2407,7 @@ var require_dist3 = __commonJS({
|
|
|
2279
2407
|
(name) => destinationSegments.add(name)
|
|
2280
2408
|
);
|
|
2281
2409
|
}
|
|
2282
|
-
} catch (
|
|
2410
|
+
} catch (_err) {
|
|
2283
2411
|
}
|
|
2284
2412
|
const hasSegments = (0, import_superstatic.collectHasSegments)(has);
|
|
2285
2413
|
for (const segment of destinationSegments) {
|
|
@@ -2317,20 +2445,8 @@ var require_dist3 = __commonJS({
|
|
|
2317
2445
|
}
|
|
2318
2446
|
function getTransformedRoutes2(vercelConfig) {
|
|
2319
2447
|
const { cleanUrls, rewrites, redirects, headers, trailingSlash } = vercelConfig;
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
const hasNewProperties = typeof cleanUrls !== "undefined" || typeof trailingSlash !== "undefined" || typeof redirects !== "undefined" || typeof headers !== "undefined" || typeof rewrites !== "undefined";
|
|
2323
|
-
if (hasNewProperties) {
|
|
2324
|
-
const error = createError(
|
|
2325
|
-
"invalid_mixed_routes",
|
|
2326
|
-
"If `rewrites`, `redirects`, `headers`, `cleanUrls` or `trailingSlash` are used, then `routes` cannot be present.",
|
|
2327
|
-
"https://vercel.link/mix-routing-props",
|
|
2328
|
-
"Learn More"
|
|
2329
|
-
);
|
|
2330
|
-
return { routes, error };
|
|
2331
|
-
}
|
|
2332
|
-
return normalizeRoutes(routes);
|
|
2333
|
-
}
|
|
2448
|
+
const { routes: userRoutes = null } = vercelConfig;
|
|
2449
|
+
let routes = null;
|
|
2334
2450
|
if (typeof cleanUrls !== "undefined") {
|
|
2335
2451
|
const normalized = normalizeRoutes(
|
|
2336
2452
|
(0, import_superstatic.convertCleanUrls)(cleanUrls, trailingSlash)
|
|
@@ -2351,6 +2467,14 @@ var require_dist3 = __commonJS({
|
|
|
2351
2467
|
routes = routes || [];
|
|
2352
2468
|
routes.push(...normalized.routes || []);
|
|
2353
2469
|
}
|
|
2470
|
+
if (userRoutes) {
|
|
2471
|
+
const normalized = normalizeRoutes(userRoutes);
|
|
2472
|
+
if (normalized.error) {
|
|
2473
|
+
return { routes, error: normalized.error };
|
|
2474
|
+
}
|
|
2475
|
+
routes = routes || [];
|
|
2476
|
+
routes.push(...normalized.routes || []);
|
|
2477
|
+
}
|
|
2354
2478
|
if (typeof redirects !== "undefined") {
|
|
2355
2479
|
const code = "invalid_redirect";
|
|
2356
2480
|
const regexErrorMessage = redirects.map((r, i) => checkRegexSyntax("Redirect", i, r.source)).find(notEmpty);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/redwood",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.11",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://vercel.com/docs",
|
|
@@ -13,20 +13,20 @@
|
|
|
13
13
|
"directory": "packages/redwood"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@vercel/nft": "1.
|
|
16
|
+
"@vercel/nft": "1.4.0",
|
|
17
17
|
"semver": "6.3.1",
|
|
18
18
|
"ts-morph": "12.0.0",
|
|
19
|
-
"@vercel/static-config": "3.
|
|
19
|
+
"@vercel/static-config": "3.2.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/aws-lambda": "8.10.19",
|
|
23
|
-
"@types/node": "
|
|
23
|
+
"@types/node": "20.11.0",
|
|
24
24
|
"@types/semver": "6.0.0",
|
|
25
25
|
"execa": "3.2.0",
|
|
26
26
|
"fs-extra": "11.1.0",
|
|
27
27
|
"jest-junit": "16.0.0",
|
|
28
|
-
"@vercel/
|
|
29
|
-
"@vercel/
|
|
28
|
+
"@vercel/build-utils": "13.8.2",
|
|
29
|
+
"@vercel/routing-utils": "6.0.2"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "node ../../utils/build-builder.mjs",
|