@vercel/redwood 2.3.2 → 2.3.4

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 (2) hide show
  1. package/dist/index.js +300 -11
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1049,14 +1049,26 @@ var require_superstatic = __commonJS({
1049
1049
  }
1050
1050
  return hasItems;
1051
1051
  };
1052
+ function getStringValueForRegex(value) {
1053
+ if (typeof value === "string") {
1054
+ return value;
1055
+ }
1056
+ if (value && typeof value === "object" && value !== null) {
1057
+ if ("re" in value && typeof value.re === "string") {
1058
+ return value.re;
1059
+ }
1060
+ }
1061
+ return null;
1062
+ }
1052
1063
  function collectHasSegments(has) {
1053
1064
  const hasSegments = /* @__PURE__ */ new Set();
1054
1065
  for (const hasItem of has || []) {
1055
1066
  if (!hasItem.value && "key" in hasItem) {
1056
1067
  hasSegments.add(hasItem.key);
1057
1068
  }
1058
- if (hasItem.value) {
1059
- for (const match of hasItem.value.matchAll(namedGroupsRegex)) {
1069
+ const stringValue = getStringValueForRegex(hasItem.value);
1070
+ if (stringValue) {
1071
+ for (const match of stringValue.matchAll(namedGroupsRegex)) {
1060
1072
  if (match[1]) {
1061
1073
  hasSegments.add(match[1]);
1062
1074
  }
@@ -1404,6 +1416,101 @@ var require_schemas = __commonJS({
1404
1416
  trailingSlashSchema: () => trailingSlashSchema
1405
1417
  });
1406
1418
  module2.exports = __toCommonJS2(schemas_exports);
1419
+ var mitigateSchema = {
1420
+ description: "Mitigation action to take on a route",
1421
+ type: "object",
1422
+ additionalProperties: false,
1423
+ required: ["action"],
1424
+ properties: {
1425
+ action: {
1426
+ description: "The mitigation action to take",
1427
+ type: "string",
1428
+ enum: ["challenge", "deny"]
1429
+ }
1430
+ }
1431
+ };
1432
+ var matchableValueSchema = {
1433
+ description: "A value to match against. Can be a string (regex) or a condition operation object",
1434
+ anyOf: [
1435
+ {
1436
+ description: "A regular expression used to match thev value. Named groups can be used in the destination.",
1437
+ type: "string",
1438
+ maxLength: 4096
1439
+ },
1440
+ {
1441
+ description: "A condition operation object",
1442
+ type: "object",
1443
+ additionalProperties: false,
1444
+ minProperties: 1,
1445
+ properties: {
1446
+ eq: {
1447
+ description: "Equal to",
1448
+ anyOf: [
1449
+ {
1450
+ type: "string",
1451
+ maxLength: 4096
1452
+ },
1453
+ {
1454
+ type: "number"
1455
+ }
1456
+ ]
1457
+ },
1458
+ neq: {
1459
+ description: "Not equal",
1460
+ type: "string",
1461
+ maxLength: 4096
1462
+ },
1463
+ inc: {
1464
+ description: "In array",
1465
+ type: "array",
1466
+ items: {
1467
+ type: "string",
1468
+ maxLength: 4096
1469
+ }
1470
+ },
1471
+ ninc: {
1472
+ description: "Not in array",
1473
+ type: "array",
1474
+ items: {
1475
+ type: "string",
1476
+ maxLength: 4096
1477
+ }
1478
+ },
1479
+ pre: {
1480
+ description: "Starts with",
1481
+ type: "string",
1482
+ maxLength: 4096
1483
+ },
1484
+ suf: {
1485
+ description: "Ends with",
1486
+ type: "string",
1487
+ maxLength: 4096
1488
+ },
1489
+ re: {
1490
+ description: "Regex",
1491
+ type: "string",
1492
+ maxLength: 4096
1493
+ },
1494
+ gt: {
1495
+ description: "Greater than",
1496
+ type: "number"
1497
+ },
1498
+ gte: {
1499
+ description: "Greater than or equal to",
1500
+ type: "number"
1501
+ },
1502
+ lt: {
1503
+ description: "Less than",
1504
+ type: "number"
1505
+ },
1506
+ lte: {
1507
+ description: "Less than or equal to",
1508
+ type: "number"
1509
+ }
1510
+ }
1511
+ }
1512
+ ]
1513
+ };
1407
1514
  var hasSchema = {
1408
1515
  description: "An array of requirements that are needed to match",
1409
1516
  type: "array",
@@ -1420,11 +1527,7 @@ var require_schemas = __commonJS({
1420
1527
  type: "string",
1421
1528
  enum: ["host"]
1422
1529
  },
1423
- value: {
1424
- description: "A regular expression used to match the value. Named groups can be used in the destination",
1425
- type: "string",
1426
- maxLength: 4096
1427
- }
1530
+ value: matchableValueSchema
1428
1531
  }
1429
1532
  },
1430
1533
  {
@@ -1442,10 +1545,195 @@ var require_schemas = __commonJS({
1442
1545
  type: "string",
1443
1546
  maxLength: 4096
1444
1547
  },
1445
- value: {
1446
- description: "A regular expression used to match the value. Named groups can be used in the destination",
1548
+ value: matchableValueSchema
1549
+ }
1550
+ }
1551
+ ]
1552
+ }
1553
+ };
1554
+ var transformsSchema = {
1555
+ description: "A list of transform rules to adjust the query parameters of a request or HTTP headers of request or response",
1556
+ type: "array",
1557
+ minItems: 1,
1558
+ items: {
1559
+ type: "object",
1560
+ additionalProperties: false,
1561
+ required: ["type", "op", "target"],
1562
+ properties: {
1563
+ type: {
1564
+ description: "The scope of the transform to apply",
1565
+ type: "string",
1566
+ enum: ["request.headers", "request.query", "response.headers"]
1567
+ },
1568
+ op: {
1569
+ description: "The operation to perform on the target",
1570
+ type: "string",
1571
+ enum: ["append", "set", "delete"]
1572
+ },
1573
+ target: {
1574
+ description: "The target of the transform",
1575
+ type: "object",
1576
+ required: ["key"],
1577
+ properties: {
1578
+ // re is not supported for transforms. Once supported, replace target.key with matchableValueSchema
1579
+ key: {
1580
+ description: "A value to match against. Can be a string or a condition operation object (without regex support)",
1581
+ anyOf: [
1582
+ {
1583
+ description: "A valid header name (letters, numbers, hyphens, underscores)",
1584
+ type: "string",
1585
+ maxLength: 4096
1586
+ },
1587
+ {
1588
+ description: "A condition operation object",
1589
+ type: "object",
1590
+ additionalProperties: false,
1591
+ minProperties: 1,
1592
+ properties: {
1593
+ eq: {
1594
+ description: "Equal to",
1595
+ anyOf: [
1596
+ {
1597
+ type: "string",
1598
+ maxLength: 4096
1599
+ },
1600
+ {
1601
+ type: "number"
1602
+ }
1603
+ ]
1604
+ },
1605
+ neq: {
1606
+ description: "Not equal",
1607
+ type: "string",
1608
+ maxLength: 4096
1609
+ },
1610
+ inc: {
1611
+ description: "In array",
1612
+ type: "array",
1613
+ items: {
1614
+ type: "string",
1615
+ maxLength: 4096
1616
+ }
1617
+ },
1618
+ ninc: {
1619
+ description: "Not in array",
1620
+ type: "array",
1621
+ items: {
1622
+ type: "string",
1623
+ maxLength: 4096
1624
+ }
1625
+ },
1626
+ pre: {
1627
+ description: "Starts with",
1628
+ type: "string",
1629
+ maxLength: 4096
1630
+ },
1631
+ suf: {
1632
+ description: "Ends with",
1633
+ type: "string",
1634
+ maxLength: 4096
1635
+ },
1636
+ gt: {
1637
+ description: "Greater than",
1638
+ type: "number"
1639
+ },
1640
+ gte: {
1641
+ description: "Greater than or equal to",
1642
+ type: "number"
1643
+ },
1644
+ lt: {
1645
+ description: "Less than",
1646
+ type: "number"
1647
+ },
1648
+ lte: {
1649
+ description: "Less than or equal to",
1650
+ type: "number"
1651
+ }
1652
+ }
1653
+ }
1654
+ ]
1655
+ }
1656
+ }
1657
+ },
1658
+ args: {
1659
+ description: "The arguments to the operation",
1660
+ anyOf: [
1661
+ {
1447
1662
  type: "string",
1448
1663
  maxLength: 4096
1664
+ },
1665
+ {
1666
+ type: "array",
1667
+ minItems: 1,
1668
+ items: {
1669
+ type: "string",
1670
+ maxLength: 4096
1671
+ }
1672
+ }
1673
+ ]
1674
+ }
1675
+ },
1676
+ allOf: [
1677
+ {
1678
+ if: {
1679
+ properties: {
1680
+ op: {
1681
+ enum: ["append", "set"]
1682
+ }
1683
+ }
1684
+ },
1685
+ then: {
1686
+ required: ["args"]
1687
+ }
1688
+ },
1689
+ {
1690
+ if: {
1691
+ allOf: [
1692
+ {
1693
+ properties: {
1694
+ type: {
1695
+ enum: ["request.headers", "response.headers"]
1696
+ }
1697
+ }
1698
+ },
1699
+ {
1700
+ properties: {
1701
+ op: {
1702
+ enum: ["set", "append"]
1703
+ }
1704
+ }
1705
+ }
1706
+ ]
1707
+ },
1708
+ then: {
1709
+ properties: {
1710
+ target: {
1711
+ properties: {
1712
+ key: {
1713
+ if: {
1714
+ type: "string"
1715
+ },
1716
+ then: {
1717
+ pattern: "^[a-zA-Z0-9_-]+$"
1718
+ }
1719
+ }
1720
+ }
1721
+ },
1722
+ args: {
1723
+ anyOf: [
1724
+ {
1725
+ type: "string",
1726
+ pattern: "^[a-zA-Z0-9_ :;.,\"'?!(){}\\[\\]@<>=+*#$&`|~\\^%/-]+$"
1727
+ },
1728
+ {
1729
+ type: "array",
1730
+ items: {
1731
+ type: "string",
1732
+ pattern: "^[a-zA-Z0-9_ :;.,\"'?!(){}\\[\\]@<>=+*#$&`|~\\^%/-]+$"
1733
+ }
1734
+ }
1735
+ ]
1736
+ }
1449
1737
  }
1450
1738
  }
1451
1739
  }
@@ -1454,7 +1742,6 @@ var require_schemas = __commonJS({
1454
1742
  };
1455
1743
  var routesSchema = {
1456
1744
  type: "array",
1457
- maxItems: 2048,
1458
1745
  deprecated: true,
1459
1746
  description: "A list of routes objects used to rewrite paths to point towards other internal or external paths",
1460
1747
  example: [{ dest: "https://docs.example.com", src: "/docs" }],
@@ -1563,7 +1850,9 @@ var require_schemas = __commonJS({
1563
1850
  }
1564
1851
  },
1565
1852
  has: hasSchema,
1566
- missing: hasSchema
1853
+ missing: hasSchema,
1854
+ mitigate: mitigateSchema,
1855
+ transforms: transformsSchema
1567
1856
  }
1568
1857
  },
1569
1858
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/redwood",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@vercel/nft": "0.29.2",
17
- "@vercel/static-config": "3.1.0",
17
+ "@vercel/static-config": "3.1.1",
18
18
  "semver": "6.3.1",
19
19
  "ts-morph": "12.0.0"
20
20
  },
@@ -22,8 +22,8 @@
22
22
  "@types/aws-lambda": "8.10.19",
23
23
  "@types/node": "14.18.33",
24
24
  "@types/semver": "6.0.0",
25
- "@vercel/build-utils": "10.6.0",
26
- "@vercel/routing-utils": "5.0.4",
25
+ "@vercel/build-utils": "10.6.7",
26
+ "@vercel/routing-utils": "5.1.1",
27
27
  "execa": "3.2.0",
28
28
  "fs-extra": "11.1.0",
29
29
  "jest-junit": "16.0.0"