@vercel/config 0.0.33 → 0.0.35

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/router.d.ts CHANGED
@@ -267,9 +267,13 @@ export interface Transform {
267
267
  */
268
268
  export interface Route {
269
269
  /** Pattern to match request paths using path-to-regexp syntax */
270
- src: string;
270
+ src?: string;
271
+ /** Alias for `src`. A pattern that matches each incoming pathname (excluding querystring). */
272
+ source?: string;
271
273
  /** Optional destination for rewrite/redirect */
272
274
  dest?: string;
275
+ /** Alias for `dest`. An absolute pathname to an existing resource or an external URL. */
276
+ destination?: string;
273
277
  /** Array of HTTP methods to match. If not provided, matches all methods */
274
278
  methods?: string[];
275
279
  /** Array of transforms to apply */
@@ -280,6 +284,8 @@ export interface Route {
280
284
  missing?: Condition[];
281
285
  /** Status code for the response */
282
286
  status?: number;
287
+ /** Alias for `status`. An optional integer to override the status code of the response. */
288
+ statusCode?: number;
283
289
  /** Headers to set (alternative to using transforms) */
284
290
  headers?: Record<string, string>;
285
291
  /** Environment variables referenced in dest or transforms */
package/dist/router.js CHANGED
@@ -380,10 +380,34 @@ class Router {
380
380
  * });
381
381
  */
382
382
  route(config) {
383
- this.validateSourcePattern(config.src);
383
+ if (config.src && config.source) {
384
+ throw new Error('Route cannot define both `src` and `source`. Use one or the other.');
385
+ }
386
+ if (config.dest && config.destination) {
387
+ throw new Error('Route cannot define both `dest` and `destination`. Use one or the other.');
388
+ }
389
+ if (config.status !== undefined && config.statusCode !== undefined) {
390
+ throw new Error('Route cannot define both `status` and `statusCode`. Use one or the other.');
391
+ }
392
+ const src = config.src ?? config.source;
393
+ if (!src) {
394
+ throw new Error('Route must define either `src` or `source`.');
395
+ }
396
+ this.validateSourcePattern(src);
397
+ // Normalize aliases to canonical names (src/dest/status)
398
+ config.src = src;
399
+ delete config.source;
400
+ if (config.destination !== undefined) {
401
+ config.dest = config.destination;
402
+ delete config.destination;
403
+ }
404
+ if (config.statusCode !== undefined) {
405
+ config.status = config.statusCode;
406
+ delete config.statusCode;
407
+ }
384
408
  // Auto-extract env vars from each transform if not already specified
385
409
  if (config.transforms) {
386
- const pathParams = this.extractPathParams(config.src);
410
+ const pathParams = this.extractPathParams(src);
387
411
  for (const transform of config.transforms) {
388
412
  if (!transform.env && transform.args) {
389
413
  const envVars = extractEnvVars(transform.args, pathParams);
package/dist/types.d.ts CHANGED
@@ -293,7 +293,6 @@ export interface VercelConfig {
293
293
  rewrites?: RouteType[];
294
294
  /**
295
295
  * A list of routes objects used to rewrite paths to point towards other internal or external paths
296
- * @deprecated
297
296
  */
298
297
  routes?: RouteType[];
299
298
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/config",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "description": "A TypeScript SDK for programmatically configuring Vercel projects",
5
5
  "license": "MIT",
6
6
  "homepage": "https://vercel.com/docs/projects/project-configuration",
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "pretty-cache-header": "^1.0.0",
38
38
  "zod": "^3.22.0",
39
- "@vercel/routing-utils": "5.3.3"
39
+ "@vercel/routing-utils": "6.0.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "20.11.0",