@vercel/config 0.0.16 → 0.0.17

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/README.md CHANGED
@@ -13,7 +13,8 @@ npm install @vercel/config
13
13
  Create a `vercel.ts` file in your project root:
14
14
 
15
15
  ```typescript
16
- import { createRouter, VercelConfig } from '@vercel/config/v1';
16
+ import { createRouter } from '@vercel/config';
17
+ import type { VercelConfig } from '@vercel/config';
17
18
 
18
19
  const router = createRouter();
19
20
 
@@ -21,15 +22,11 @@ export const config: VercelConfig = {
21
22
  buildCommand: 'npm run build',
22
23
  framework: 'nextjs',
23
24
 
24
- routes: [
25
- // Headers
26
- router.cacheControl('/static/(.*)', {
27
- public: true,
28
- maxAge: '1 week',
29
- immutable: true
30
- }),
25
+ rewrites: [
26
+ // Simple rewrite
27
+ router.rewrite('/api/(.*)', 'https://backend.api.example.com/$1'),
31
28
 
32
- // Rewrites with transforms
29
+ // Rewrite with transforms
33
30
  router.rewrite('/users/:userId', 'https://api.example.com/users/$1',
34
31
  ({ userId, env }) => ({
35
32
  requestHeaders: {
@@ -37,12 +34,21 @@ export const config: VercelConfig = {
37
34
  'authorization': `Bearer ${env.API_TOKEN}`
38
35
  }
39
36
  })
40
- ),
41
-
42
- // Simple redirects
37
+ )
38
+ ],
39
+
40
+ redirects: [
43
41
  router.redirect('/old-docs', '/docs', { permanent: true })
44
42
  ],
45
43
 
44
+ headers: [
45
+ router.cacheControl('/static/(.*)', {
46
+ public: true,
47
+ maxAge: '1 week',
48
+ immutable: true
49
+ })
50
+ ],
51
+
46
52
  crons: [
47
53
  { path: '/api/cleanup', schedule: '0 0 * * *' }
48
54
  ]
@@ -53,7 +59,6 @@ export const config: VercelConfig = {
53
59
 
54
60
  - **Type-safe configuration** - Full TypeScript support with IDE autocomplete
55
61
  - **Readable syntax** - Helper methods like `router.redirect()`, `router.rewrite()`, `router.header()`
56
- - **Static validation** - Catch configuration errors at development time
57
62
  - **Transforms** - Modify request/response headers and query parameters on the fly
58
63
  - **Conditions** - Advanced routing with `has` and `missing` conditions
59
64
  - **CLI tools** - `compile` and `validate` commands for development
@@ -84,39 +89,11 @@ npx @vercel/config validate
84
89
  npx @vercel/config generate
85
90
  ```
86
91
 
87
- ## Validation
88
-
89
- Static fields are validated to ensure they only contain literal values (strings, booleans, objects with primitives):
90
-
91
- ```typescript
92
- // ✅ Valid - static string
93
- export const buildCommand = 'npm run build';
94
-
95
- // ❌ Invalid - computed value
96
- export const buildCommand = process.env.BUILD_CMD;
97
-
98
- // ✅ Valid - static object
99
- export const git = {
100
- deploymentEnabled: {
101
- 'main': true,
102
- 'dev': false
103
- }
104
- };
105
- ```
106
-
107
- Static fields that are validated:
108
- - `buildCommand`, `devCommand`, `installCommand`
109
- - `framework`, `nodeVersion`, `outputDirectory`
110
- - `github.enabled`, `github.autoAlias`, `github.autoJobCancelation`
111
- - `git.deploymentEnabled`
112
- - `relatedProjects`
113
-
114
92
  ## Important Notes
115
93
 
116
- - **One config file only**: You cannot have both `vercel.ts` and `vercel.json`. The build will fail if both exist.
117
-
118
-
119
- - **Versioned API**: Use `@vercel/config/v1` for imports to enable future versioning.
94
+ - **One config file only**: You cannot have both `vercel.ts` and `vercel.json`.
95
+ - **Transforms compile to routes**: When you add transforms to rewrites/redirects (like `requestHeaders`), they're compiled to the lower-level `routes` primitive internally.
96
+ - **Automatic compilation**: The Vercel CLI compiles `vercel.ts` automatically.
120
97
 
121
98
  ## Learn More
122
99
 
package/dist/types.d.ts CHANGED
@@ -206,3 +206,7 @@ export interface VercelConfig {
206
206
  */
207
207
  nodeVersion?: string;
208
208
  }
209
+ /**
210
+ * Runtime placeholder for VercelConfig to allow named imports.
211
+ */
212
+ export declare const VercelConfig: {};
package/dist/types.js CHANGED
@@ -4,3 +4,8 @@
4
4
  * https://openapi.vercel.sh/vercel.json
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.VercelConfig = void 0;
8
+ /**
9
+ * Runtime placeholder for VercelConfig to allow named imports.
10
+ */
11
+ exports.VercelConfig = {};
@@ -1,9 +1,5 @@
1
- /**
2
- * @vercel/config/v1 - Main API entry point
3
- *
4
- * Usage:
5
- * import { createRouter, VercelConfig } from '@vercel/config/v1';
6
- */
7
1
  export { createRouter, Router } from "../router";
8
2
  export * from "../router";
9
- export type { VercelConfig, Redirect, Rewrite, HeaderRule, Condition, RouteType } from "../types";
3
+ export { VercelConfig } from "../types";
4
+ export type { Redirect, Rewrite, HeaderRule, Condition, RouteType } from "../types";
5
+ export { validateStaticString, validateStaticBoolean, validateStaticObject, validateStaticStringArray, validateStaticFields } from "../utils/validation";
package/dist/v1/index.js CHANGED
@@ -1,10 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * @vercel/config/v1 - Main API entry point
4
- *
5
- * Usage:
6
- * import { createRouter, VercelConfig } from '@vercel/config/v1';
7
- */
8
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
3
  if (k2 === undefined) k2 = k;
10
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -20,8 +14,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
15
  };
22
16
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.Router = exports.createRouter = void 0;
17
+ exports.validateStaticFields = exports.validateStaticStringArray = exports.validateStaticObject = exports.validateStaticBoolean = exports.validateStaticString = exports.VercelConfig = exports.Router = exports.createRouter = void 0;
24
18
  var router_1 = require("../router");
25
19
  Object.defineProperty(exports, "createRouter", { enumerable: true, get: function () { return router_1.createRouter; } });
26
20
  Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return router_1.Router; } });
27
21
  __exportStar(require("../router"), exports);
22
+ var types_1 = require("../types");
23
+ Object.defineProperty(exports, "VercelConfig", { enumerable: true, get: function () { return types_1.VercelConfig; } });
24
+ var validation_1 = require("../utils/validation");
25
+ Object.defineProperty(exports, "validateStaticString", { enumerable: true, get: function () { return validation_1.validateStaticString; } });
26
+ Object.defineProperty(exports, "validateStaticBoolean", { enumerable: true, get: function () { return validation_1.validateStaticBoolean; } });
27
+ Object.defineProperty(exports, "validateStaticObject", { enumerable: true, get: function () { return validation_1.validateStaticObject; } });
28
+ Object.defineProperty(exports, "validateStaticStringArray", { enumerable: true, get: function () { return validation_1.validateStaticStringArray; } });
29
+ Object.defineProperty(exports, "validateStaticFields", { enumerable: true, get: function () { return validation_1.validateStaticFields; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/config",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "A TypeScript SDK for programmatically generating Vercel configuration files",
5
5
  "bugs": {
6
6
  "url": "https://github.com/vercel/router-sdk/issues"
@@ -11,22 +11,18 @@
11
11
  },
12
12
  "author": "Vercel",
13
13
  "license": "MIT",
14
- "main": "dist/index.js",
15
- "types": "dist/index.d.ts",
16
- "exports": {
17
- ".": "./dist/index.js",
18
- "./v1": "./dist/v1/index.js"
19
- },
14
+ "main": "dist/v1/index.js",
15
+ "types": "dist/v1/index.d.ts",
20
16
  "typesVersions": {
21
17
  "*": {
22
- ".": [
23
- "dist/index.d.ts"
24
- ],
25
18
  "v1": [
26
19
  "dist/v1/index.d.ts"
27
20
  ]
28
21
  }
29
22
  },
23
+ "exports": {
24
+ "./v1": "./dist/v1/index.js"
25
+ },
30
26
  "bin": {
31
27
  "@vercel/config": "./dist/cli.js"
32
28
  },
package/dist/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export { createRouter, Router } from "./router";
2
- export * from "./router";
3
- export type { VercelConfig, Redirect, Rewrite, HeaderRule, Condition, RouteType } from "./types";
4
- export { validateStaticString, validateStaticBoolean, validateStaticObject, validateStaticStringArray, validateStaticFields } from "./utils/validation";
package/dist/index.js DELETED
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.validateStaticFields = exports.validateStaticStringArray = exports.validateStaticObject = exports.validateStaticBoolean = exports.validateStaticString = exports.Router = exports.createRouter = void 0;
18
- var router_1 = require("./router");
19
- Object.defineProperty(exports, "createRouter", { enumerable: true, get: function () { return router_1.createRouter; } });
20
- Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return router_1.Router; } });
21
- __exportStar(require("./router"), exports);
22
- var validation_1 = require("./utils/validation");
23
- Object.defineProperty(exports, "validateStaticString", { enumerable: true, get: function () { return validation_1.validateStaticString; } });
24
- Object.defineProperty(exports, "validateStaticBoolean", { enumerable: true, get: function () { return validation_1.validateStaticBoolean; } });
25
- Object.defineProperty(exports, "validateStaticObject", { enumerable: true, get: function () { return validation_1.validateStaticObject; } });
26
- Object.defineProperty(exports, "validateStaticStringArray", { enumerable: true, get: function () { return validation_1.validateStaticStringArray; } });
27
- Object.defineProperty(exports, "validateStaticFields", { enumerable: true, get: function () { return validation_1.validateStaticFields; } });