@vercel/routing-utils 1.13.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
+ import { GetRoutesProps, NormalizedRoutes, Route, RouteWithHandle } from './types';
2
+ export { appendRoutesToPhase } from './append';
3
+ export { mergeRoutes } from './merge';
1
4
  export * from './schemas';
2
- export * from './types';
3
- import { Route, Handler, NormalizedRoutes, GetRoutesProps } from './types';
4
5
  export { getCleanUrls } from './superstatic';
5
- export { mergeRoutes } from './merge';
6
- export { appendRoutesToPhase } from './append';
6
+ export * from './types';
7
7
  declare const VALID_HANDLE_VALUES: readonly ["filesystem", "hit", "miss", "rewrite", "error", "resource"];
8
8
  export declare type HandleValue = typeof VALID_HANDLE_VALUES[number];
9
- export declare function isHandler(route: Route): route is Handler;
9
+ export declare function isHandler(route: Route): route is RouteWithHandle;
10
10
  export declare function isValidHandleValue(handle: string): handle is HandleValue;
11
11
  export declare function normalizeRoutes(inputRoutes: Route[] | null): NormalizedRoutes;
12
- export declare function getTransformedRoutes({ nowConfig, }: GetRoutesProps): NormalizedRoutes;
12
+ export declare function getTransformedRoutes(vercelConfig: GetRoutesProps): NormalizedRoutes;
package/dist/index.js CHANGED
@@ -10,17 +10,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.getTransformedRoutes = exports.normalizeRoutes = exports.isValidHandleValue = exports.isHandler = exports.appendRoutesToPhase = exports.mergeRoutes = exports.getCleanUrls = void 0;
13
+ exports.getTransformedRoutes = exports.normalizeRoutes = exports.isValidHandleValue = exports.isHandler = exports.getCleanUrls = exports.mergeRoutes = exports.appendRoutesToPhase = void 0;
14
14
  const url_1 = require("url");
15
- __exportStar(require("./schemas"), exports);
16
- __exportStar(require("./types"), exports);
17
15
  const superstatic_1 = require("./superstatic");
18
- var superstatic_2 = require("./superstatic");
19
- Object.defineProperty(exports, "getCleanUrls", { enumerable: true, get: function () { return superstatic_2.getCleanUrls; } });
20
- var merge_1 = require("./merge");
21
- Object.defineProperty(exports, "mergeRoutes", { enumerable: true, get: function () { return merge_1.mergeRoutes; } });
22
16
  var append_1 = require("./append");
23
17
  Object.defineProperty(exports, "appendRoutesToPhase", { enumerable: true, get: function () { return append_1.appendRoutesToPhase; } });
18
+ var merge_1 = require("./merge");
19
+ Object.defineProperty(exports, "mergeRoutes", { enumerable: true, get: function () { return merge_1.mergeRoutes; } });
20
+ __exportStar(require("./schemas"), exports);
21
+ var superstatic_2 = require("./superstatic");
22
+ Object.defineProperty(exports, "getCleanUrls", { enumerable: true, get: function () { return superstatic_2.getCleanUrls; } });
23
+ __exportStar(require("./types"), exports);
24
24
  const VALID_HANDLE_VALUES = [
25
25
  'filesystem',
26
26
  'hit',
@@ -184,9 +184,9 @@ function createError(code, allErrors, link, action) {
184
184
  function notEmpty(value) {
185
185
  return value !== null && value !== undefined;
186
186
  }
187
- function getTransformedRoutes({ nowConfig, }) {
188
- const { cleanUrls, rewrites, redirects, headers, trailingSlash } = nowConfig;
189
- let { routes = null } = nowConfig;
187
+ function getTransformedRoutes(vercelConfig) {
188
+ const { cleanUrls, rewrites, redirects, headers, trailingSlash } = vercelConfig;
189
+ let { routes = null } = vercelConfig;
190
190
  if (routes) {
191
191
  const hasNewProperties = typeof cleanUrls !== 'undefined' ||
192
192
  typeof trailingSlash !== 'undefined' ||
package/dist/types.d.ts CHANGED
@@ -15,7 +15,7 @@ export declare type HasField = Array<{
15
15
  key: string;
16
16
  value?: string;
17
17
  }>;
18
- export declare type Source = {
18
+ export declare type RouteWithSrc = {
19
19
  src: string;
20
20
  dest?: string;
21
21
  headers?: {
@@ -44,19 +44,24 @@ export declare type Source = {
44
44
  */
45
45
  middleware?: number;
46
46
  };
47
- export declare type Handler = {
47
+ export declare type RouteWithHandle = {
48
48
  handle: HandleValue;
49
49
  src?: string;
50
50
  dest?: string;
51
51
  status?: number;
52
52
  };
53
- export declare type Route = Source | Handler;
53
+ export declare type Route = RouteWithSrc | RouteWithHandle;
54
54
  export declare type NormalizedRoutes = {
55
55
  routes: Route[] | null;
56
56
  error: RouteApiError | null;
57
57
  };
58
58
  export interface GetRoutesProps {
59
- nowConfig: VercelConfig;
59
+ routes?: Route[];
60
+ cleanUrls?: boolean;
61
+ rewrites?: Rewrite[];
62
+ redirects?: Redirect[];
63
+ headers?: Header[];
64
+ trailingSlash?: boolean;
60
65
  }
61
66
  export interface MergeRoutesProps {
62
67
  userRoutes?: Route[] | null | undefined;
@@ -67,16 +72,6 @@ export interface Build {
67
72
  entrypoint: string;
68
73
  routes?: Route[];
69
74
  }
70
- export interface VercelConfig {
71
- name?: string;
72
- version?: number;
73
- routes?: Route[];
74
- cleanUrls?: boolean;
75
- rewrites?: Rewrite[];
76
- redirects?: Redirect[];
77
- headers?: Header[];
78
- trailingSlash?: boolean;
79
- }
80
75
  export interface Rewrite {
81
76
  source: string;
82
77
  destination: string;
@@ -115,13 +110,3 @@ export interface AppendRoutesToPhaseProps {
115
110
  */
116
111
  phase: HandleValue;
117
112
  }
118
- /** @deprecated Use VercelConfig instead. */
119
- export declare type NowConfig = VercelConfig;
120
- /** @deprecated Use Rewrite instead. */
121
- export declare type NowRewrite = Rewrite;
122
- /** @deprecated Use Redirect instead. */
123
- export declare type NowRedirect = Redirect;
124
- /** @deprecated Use Header instead. */
125
- export declare type NowHeader = Header;
126
- /** @deprecated Use HeaderKeyValue instead. */
127
- export declare type NowHeaderKeyValue = HeaderKeyValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/routing-utils",
3
- "version": "1.13.4",
3
+ "version": "2.0.0",
4
4
  "description": "Vercel routing utilities",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -24,6 +24,7 @@
24
24
  "path-to-regexp": "6.1.0"
25
25
  },
26
26
  "devDependencies": {
27
+ "@types/jest": "27.4.1",
27
28
  "@types/node": "12.12.20",
28
29
  "ajv": "^6.0.0",
29
30
  "typescript": "4.3.4"
@@ -31,5 +32,5 @@
31
32
  "optionalDependencies": {
32
33
  "ajv": "^6.0.0"
33
34
  },
34
- "gitHead": "de0d2fba0b32588726a2799015eaff4e6bb65ffb"
35
+ "gitHead": "bef1aec76609ae661f084dcc391edd66f891f0b4"
35
36
  }