@vercel/config 0.0.23 → 0.0.25

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2017 Vercel, Inc.
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -19,45 +19,43 @@ import type { VercelConfig } from '@vercel/config/v1';
19
19
  export const config: VercelConfig = {
20
20
  buildCommand: 'npm run build',
21
21
  framework: 'nextjs',
22
-
22
+
23
23
  rewrites: [
24
24
  // Simple rewrite
25
25
  routes.rewrite('/api/(.*)', 'https://backend.api.example.com/$1'),
26
-
26
+
27
27
  // Rewrite with transforms (no path params)
28
28
  routes.rewrite('/(.*)', 'https://api.example.com/$1', {
29
29
  requestHeaders: {
30
- 'authorization': `Bearer ${deploymentEnv('API_TOKEN')}`
31
- }
30
+ authorization: `Bearer ${deploymentEnv('API_TOKEN')}`,
31
+ },
32
32
  }),
33
-
33
+
34
34
  // Type-safe path parameters with callback
35
- routes.rewrite('/users/:userId/posts/:postId', 'https://api.example.com/users/$1/posts/$2',
35
+ routes.rewrite(
36
+ '/users/:userId/posts/:postId',
37
+ 'https://api.example.com/users/$1/posts/$2',
36
38
  ({ userId, postId }) => ({
37
39
  requestHeaders: {
38
40
  'x-user-id': userId,
39
41
  'x-post-id': postId,
40
- 'authorization': `Bearer ${deploymentEnv('API_KEY')}`
41
- }
42
+ authorization: `Bearer ${deploymentEnv('API_KEY')}`,
43
+ },
42
44
  })
43
- )
44
- ],
45
-
46
- redirects: [
47
- routes.redirect('/old-docs', '/docs', { permanent: true })
45
+ ),
48
46
  ],
49
47
 
48
+ redirects: [routes.redirect('/old-docs', '/docs', { permanent: true })],
49
+
50
50
  headers: [
51
51
  routes.cacheControl('/static/(.*)', {
52
52
  public: true,
53
53
  maxAge: '1 week',
54
- immutable: true
55
- })
54
+ immutable: true,
55
+ }),
56
56
  ],
57
57
 
58
- crons: [
59
- { path: '/api/cleanup', schedule: '0 0 * * *' }
60
- ]
58
+ crons: [{ path: '/api/cleanup', schedule: '0 0 * * *' }],
61
59
  };
62
60
  ```
63
61
 
@@ -74,6 +72,7 @@ export const config: VercelConfig = {
74
72
  ## Build-Time Compilation
75
73
 
76
74
  Your `vercel.ts` is automatically compiled to `vercel.json` during:
75
+
77
76
  ```bash
78
77
  vercel build
79
78
  vercel dev
package/dist/cli.js CHANGED
@@ -40,15 +40,15 @@ const ROUTE_BASED_EXPORTS = new Set([
40
40
  'headers',
41
41
  'env',
42
42
  'cacheControl',
43
- '__esModule'
43
+ '__esModule',
44
44
  ]);
45
45
  /**
46
46
  * Read the user's vercel.ts file and collect both default export and export const declarations
47
47
  */
48
48
  async function configureRouter() {
49
49
  var _a;
50
- const vercelTsPath = (0, path_1.resolve)(process.cwd(), "vercel.ts");
51
- const routerConfigPath = (0, path_1.resolve)(process.cwd(), "router.config.ts");
50
+ const vercelTsPath = (0, path_1.resolve)(process.cwd(), 'vercel.ts');
51
+ const routerConfigPath = (0, path_1.resolve)(process.cwd(), 'router.config.ts');
52
52
  // Prefer vercel.ts, fallback to router.config.ts
53
53
  const configPath = (0, fs_2.existsSync)(vercelTsPath) ? vercelTsPath : routerConfigPath;
54
54
  // Import the entire module to get both default and named exports
@@ -65,7 +65,7 @@ async function configureRouter() {
65
65
  // Merge: export const declarations take precedence over default export
66
66
  return {
67
67
  ...routerConfig,
68
- ...exportedConstants
68
+ ...exportedConstants,
69
69
  };
70
70
  }
71
71
  /**
@@ -78,7 +78,7 @@ async function compileConfig() {
78
78
  console.log(json);
79
79
  }
80
80
  catch (error) {
81
- console.error("Failed to compile config:", error);
81
+ console.error('Failed to compile config:', error);
82
82
  process.exit(1);
83
83
  }
84
84
  }
@@ -86,21 +86,20 @@ async function compileConfig() {
86
86
  * Validate the vercel.ts config
87
87
  */
88
88
  async function validateConfig() {
89
- var _a, _b, _c, _d;
90
89
  try {
91
90
  const config = await configureRouter();
92
91
  // Validate static fields
93
92
  (0, validation_1.validateStaticFields)(config);
94
- console.log("✓ Config is valid");
93
+ console.log('✓ Config is valid');
95
94
  console.log(` - buildCommand: ${config.buildCommand || '(not set)'}`);
96
95
  console.log(` - framework: ${config.framework || '(not set)'}`);
97
- console.log(` - routes: ${((_a = config.routes) === null || _a === void 0 ? void 0 : _a.length) || 0} route(s)`);
98
- console.log(` - redirects: ${((_b = config.redirects) === null || _b === void 0 ? void 0 : _b.length) || 0} redirect(s)`);
99
- console.log(` - rewrites: ${((_c = config.rewrites) === null || _c === void 0 ? void 0 : _c.length) || 0} rewrite(s)`);
100
- console.log(` - headers: ${((_d = config.headers) === null || _d === void 0 ? void 0 : _d.length) || 0} header(s)`);
96
+ console.log(` - routes: ${config.routes?.length || 0} route(s)`);
97
+ console.log(` - redirects: ${config.redirects?.length || 0} redirect(s)`);
98
+ console.log(` - rewrites: ${config.rewrites?.length || 0} rewrite(s)`);
99
+ console.log(` - headers: ${config.headers?.length || 0} header(s)`);
101
100
  }
102
101
  catch (error) {
103
- console.error("✗ Config validation failed:");
102
+ console.error('✗ Config validation failed:');
104
103
  console.error(` ${error}`);
105
104
  process.exit(1);
106
105
  }
@@ -112,12 +111,12 @@ async function generateVercelConfig() {
112
111
  try {
113
112
  const config = await configureRouter();
114
113
  const json = JSON.stringify(config, null, 2);
115
- const outputPath = (0, path_1.resolve)(process.cwd(), "vercel.json");
114
+ const outputPath = (0, path_1.resolve)(process.cwd(), 'vercel.json');
116
115
  (0, fs_1.writeFileSync)(outputPath, json);
117
- console.log("Successfully generated vercel.json");
116
+ console.log('Successfully generated vercel.json');
118
117
  }
119
118
  catch (error) {
120
- console.error("Failed to generate vercel.json:", error);
119
+ console.error('Failed to generate vercel.json:', error);
121
120
  process.exit(1);
122
121
  }
123
122
  }
@@ -146,5 +145,8 @@ async function main() {
146
145
  }
147
146
  // Run if this file is executed directly
148
147
  if (require.main === module) {
149
- main();
148
+ main().catch(err => {
149
+ console.error('Error:', err);
150
+ process.exit(1);
151
+ });
150
152
  }
package/dist/router.d.ts CHANGED
@@ -280,6 +280,11 @@ export interface Route {
280
280
  headers?: Record<string, string>;
281
281
  /** Environment variables referenced in dest or transforms */
282
282
  env?: string[];
283
+ /**
284
+ * When true (default), external rewrites will respect the Cache-Control header from the origin.
285
+ * When false, caching is disabled for this rewrite.
286
+ */
287
+ respectOriginCacheControl?: boolean;
283
288
  }
284
289
  /**
285
290
  * Represents a single HTTP header key/value pair.
@@ -447,6 +452,11 @@ export interface RewriteRule {
447
452
  missing?: Condition[];
448
453
  /** Internal field: transforms generated from requestHeaders/responseHeaders/requestQuery */
449
454
  transforms?: Transform[];
455
+ /**
456
+ * When true (default), external rewrites will respect the Cache-Control header from the origin.
457
+ * When false, caching is disabled for this rewrite.
458
+ */
459
+ respectOriginCacheControl?: boolean;
450
460
  }
451
461
  /**
452
462
  * CronRule defines a scheduled function invocation on Vercel.
@@ -540,14 +550,16 @@ export declare class Router {
540
550
  requestHeaders?: Record<string, string | string[]>;
541
551
  responseHeaders?: Record<string, string | string[]>;
542
552
  requestQuery?: Record<string, string | string[]>;
553
+ respectOriginCacheControl?: boolean;
543
554
  }): Rewrite | Route;
544
- rewrite<T extends string>(source: T, destination: string, options: ({
555
+ rewrite<T extends string>(source: T, destination: string, options: {
545
556
  has?: Condition[];
546
557
  missing?: Condition[];
547
558
  requestHeaders?: Record<string, string | string[]>;
548
559
  responseHeaders?: Record<string, string | string[]>;
549
560
  requestQuery?: Record<string, string | string[]>;
550
- }) & Record<never, never>): Rewrite | Route;
561
+ respectOriginCacheControl?: boolean;
562
+ } & Record<never, never>): Rewrite | Route;
551
563
  /**
552
564
  * Creates a redirect rule. Returns either a Redirect object (simple case) or Route with transforms.
553
565
  *
package/dist/router.js CHANGED
@@ -86,7 +86,7 @@ class Router {
86
86
  else {
87
87
  options = optionsOrCallback;
88
88
  }
89
- const { has, missing, requestHeaders, responseHeaders, requestQuery } = options || {};
89
+ const { has, missing, requestHeaders, responseHeaders, requestQuery, respectOriginCacheControl, } = options || {};
90
90
  // Check if any transforms were provided
91
91
  const hasTransforms = requestHeaders || responseHeaders || requestQuery;
92
92
  if (hasTransforms) {
@@ -147,6 +147,8 @@ class Router {
147
147
  route.has = has;
148
148
  if (missing)
149
149
  route.missing = missing;
150
+ if (respectOriginCacheControl !== undefined)
151
+ route.respectOriginCacheControl = respectOriginCacheControl;
150
152
  // Extract env vars from destination
151
153
  const destEnvVars = extractEnvVars(destination, pathParams);
152
154
  if (destEnvVars.length > 0) {
@@ -168,6 +170,8 @@ class Router {
168
170
  route.has = has;
169
171
  if (missing)
170
172
  route.missing = missing;
173
+ if (respectOriginCacheControl !== undefined)
174
+ route.respectOriginCacheControl = respectOriginCacheControl;
171
175
  return route;
172
176
  }
173
177
  // Simple rewrite without transforms or env vars
@@ -179,6 +183,8 @@ class Router {
179
183
  rewrite.has = has;
180
184
  if (missing)
181
185
  rewrite.missing = missing;
186
+ if (respectOriginCacheControl !== undefined)
187
+ rewrite.respectOriginCacheControl = respectOriginCacheControl;
182
188
  return rewrite;
183
189
  }
184
190
  redirect(source, destination, optionsOrCallback) {
@@ -360,10 +366,10 @@ class Router {
360
366
  getConfig() {
361
367
  // Separate rewrites into those that need to be routes vs. legacy rewrites
362
368
  // Routes are needed for: transforms, methods, or custom status
363
- const rewritesNeedingRoutes = this.rewriteRules.filter((r) => r.transforms || r.methods || r.status);
364
- const legacyRewrites = this.rewriteRules.filter((r) => !r.transforms && !r.methods && !r.status);
369
+ const rewritesNeedingRoutes = this.rewriteRules.filter(r => r.transforms || r.methods || r.status);
370
+ const legacyRewrites = this.rewriteRules.filter(r => !r.transforms && !r.methods && !r.status);
365
371
  // Convert rewrites to routes
366
- const routesFromRewrites = rewritesNeedingRoutes.map((rewrite) => {
372
+ const routesFromRewrites = rewritesNeedingRoutes.map(rewrite => {
367
373
  const route = {
368
374
  src: rewrite.source,
369
375
  dest: rewrite.destination,
@@ -437,7 +443,13 @@ class Router {
437
443
  return route;
438
444
  });
439
445
  // Combine all routes: redirects, legacy rewrites, rewrites with transforms, explicit routes, and headers as routes
440
- const combinedRoutes = [...routesFromRedirects, ...routesFromLegacyRewrites, ...routesFromRewrites, ...this.routeRules, ...routesFromHeaders];
446
+ const combinedRoutes = [
447
+ ...routesFromRedirects,
448
+ ...routesFromLegacyRewrites,
449
+ ...routesFromRewrites,
450
+ ...this.routeRules,
451
+ ...routesFromHeaders,
452
+ ];
441
453
  const config = {
442
454
  routes: combinedRoutes,
443
455
  };
@@ -470,7 +482,7 @@ class Router {
470
482
  },
471
483
  {
472
484
  type: 'Before Filesystem Rewrites',
473
- rules: this.rewriteRules.filter((rewrite) => rewrite.source.startsWith('/api/') ||
485
+ rules: this.rewriteRules.filter(rewrite => rewrite.source.startsWith('/api/') ||
474
486
  rewrite.source.startsWith('/_next/')),
475
487
  },
476
488
  {
@@ -479,23 +491,23 @@ class Router {
479
491
  },
480
492
  {
481
493
  type: 'After Filesystem Rewrites',
482
- rules: this.rewriteRules.filter((rewrite) => !rewrite.source.startsWith('/api/') &&
494
+ rules: this.rewriteRules.filter(rewrite => !rewrite.source.startsWith('/api/') &&
483
495
  !rewrite.source.startsWith('/_next/') &&
484
496
  rewrite.source !== '/(.*)'),
485
497
  },
486
498
  {
487
499
  type: 'Fallback Rewrites',
488
- rules: this.rewriteRules.filter((rewrite) => rewrite.source === '/(.*)'),
500
+ rules: this.rewriteRules.filter(rewrite => rewrite.source === '/(.*)'),
489
501
  },
490
502
  ];
491
503
  return tree
492
- .map((node) => {
504
+ .map(node => {
493
505
  const rules = node.rules.length > 0
494
506
  ? node.rules
495
- .map((rule) => {
507
+ .map(rule => {
496
508
  if ('headers' in rule) {
497
509
  const headersStr = rule.headers
498
- .map((h) => `${h.key}: ${h.value}`)
510
+ .map(h => `${h.key}: ${h.value}`)
499
511
  .join(', ');
500
512
  return ` ${rule.source} [${headersStr}]`;
501
513
  }
package/dist/types.d.ts CHANGED
@@ -168,6 +168,7 @@ export interface Rewrite {
168
168
  destination: string;
169
169
  has?: Condition[];
170
170
  missing?: Condition[];
171
+ respectOriginCacheControl?: boolean;
171
172
  }
172
173
  /**
173
174
  * Header rule matching vercel.json schema
@@ -18,12 +18,12 @@ const zod_1 = require("zod");
18
18
  */
19
19
  function validateRegexPattern(pattern) {
20
20
  // Check for common path-to-regexp syntax errors
21
- if (pattern.includes("(?!") && !pattern.includes("((?!")) {
21
+ if (pattern.includes('(?!') && !pattern.includes('((?!')) {
22
22
  throw new Error(`Invalid path-to-regexp pattern: Negative lookaheads must be wrapped in a group. ` +
23
23
  `Use "((?!pattern).*)" instead of "(?!pattern)". Pattern: ${pattern}`);
24
24
  }
25
25
  // Check for invalid wildcard patterns
26
- if (pattern.includes("/*") || pattern.includes("/**")) {
26
+ if (pattern.includes('/*') || pattern.includes('/**')) {
27
27
  throw new Error(`Invalid path-to-regexp pattern: Use '(.*)' instead of '*' for wildcards. ` +
28
28
  `Pattern: ${pattern}`);
29
29
  }
@@ -55,15 +55,15 @@ const cronPartSchema = zod_1.z.object({
55
55
  .regex(/^(\*|[1-9]|1[0-2]|\*\/[0-9]+|[1-9]-[1-9]|1[0-2]-1[0-2](,[1-9]-[1-9]|,1[0-2]-1[0-2])*)$/),
56
56
  dayOfWeek: zod_1.z
57
57
  .string()
58
- .regex(/^(\*|[0-6]|\*\/[0-9]+|[0-6]-[0-6](,[0-6]-[0-6])*)$/)
58
+ .regex(/^(\*|[0-6]|\*\/[0-9]+|[0-6]-[0-6](,[0-6]-[0-6])*)$/),
59
59
  });
60
60
  /**
61
61
  * Parses a cron expression into its parts
62
62
  */
63
63
  function parseCronExpression(expression) {
64
- const parts = expression.split(" ");
64
+ const parts = expression.split(' ');
65
65
  if (parts.length !== 5) {
66
- throw new Error("Invalid cron expression: must have 5 parts");
66
+ throw new Error('Invalid cron expression: must have 5 parts');
67
67
  }
68
68
  const [minute, hour, dayOfMonth, month, dayOfWeek] = parts;
69
69
  return cronPartSchema.parse({
@@ -71,7 +71,7 @@ function parseCronExpression(expression) {
71
71
  hour,
72
72
  dayOfMonth,
73
73
  month,
74
- dayOfWeek
74
+ dayOfWeek,
75
75
  });
76
76
  }
77
77
  exports.parseCronExpression = parseCronExpression;
@@ -153,7 +153,9 @@ function validateStaticObject(value, fieldName) {
153
153
  `Got ${typeof value}.`);
154
154
  }
155
155
  for (const [key, val] of Object.entries(value)) {
156
- if (typeof val !== 'boolean' && typeof val !== 'string' && typeof val !== 'number') {
156
+ if (typeof val !== 'boolean' &&
157
+ typeof val !== 'string' &&
158
+ typeof val !== 'number') {
157
159
  throw new Error(`Field "${fieldName}.${key}" must contain only static primitive values (string, number, boolean). ` +
158
160
  `Got ${typeof val}.`);
159
161
  }
@@ -186,7 +188,14 @@ exports.validateStaticStringArray = validateStaticStringArray;
186
188
  */
187
189
  function validateStaticFields(config) {
188
190
  // Validate string fields
189
- const stringFields = ['buildCommand', 'devCommand', 'installCommand', 'framework', 'nodeVersion', 'outputDirectory'];
191
+ const stringFields = [
192
+ 'buildCommand',
193
+ 'devCommand',
194
+ 'installCommand',
195
+ 'framework',
196
+ 'nodeVersion',
197
+ 'outputDirectory',
198
+ ];
190
199
  for (const field of stringFields) {
191
200
  if (config[field] !== undefined && config[field] !== null) {
192
201
  validateStaticString(config[field], field);
@@ -1,5 +1,5 @@
1
- export { createRoutes, routes, Router } from "../router";
2
- export * from "../router";
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";
1
+ export { createRoutes, routes, Router } from '../router';
2
+ export * from '../router';
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';
@@ -4,4 +4,4 @@
4
4
  * Usage:
5
5
  * /// <reference types="@vercel/config/v1/types" />
6
6
  */
7
- export type { VercelConfig, Framework, FunctionConfig, CronJob, GitDeploymentConfig, GitConfig, GithubConfig, ImageConfig, Header, Condition, Redirect, Rewrite, HeaderRule, RouteType, WildcardDomain, BuildConfig, BuildItem } from "../types";
7
+ export type { VercelConfig, Framework, FunctionConfig, CronJob, GitDeploymentConfig, GitConfig, GithubConfig, ImageConfig, Header, Condition, Redirect, Rewrite, HeaderRule, RouteType, WildcardDomain, BuildConfig, BuildItem, } from '../types';
package/package.json CHANGED
@@ -1,16 +1,14 @@
1
1
  {
2
2
  "name": "@vercel/config",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "A TypeScript SDK for programmatically configuring Vercel projects",
5
- "bugs": {
6
- "url": "https://github.com/vercel/config/issues"
7
- },
5
+ "license": "MIT",
6
+ "homepage": "https://vercel.com/docs/projects/project-configuration",
8
7
  "repository": {
9
8
  "type": "git",
10
- "url": "https://github.com/vercel/config"
9
+ "url": "https://github.com/vercel/vercel.git",
10
+ "directory": "packages/config"
11
11
  },
12
- "author": "Vercel",
13
- "license": "MIT",
14
12
  "main": "dist/v1/index.js",
15
13
  "types": "dist/v1/index.d.ts",
16
14
  "typesVersions": {
@@ -40,26 +38,20 @@
40
38
  "zod": "^3.22.0"
41
39
  },
42
40
  "devDependencies": {
43
- "@changesets/cli": "^2.27.12",
44
- "@types/node": "^18.0.0",
45
- "@typescript-eslint/eslint-plugin": "^5.0.0",
46
- "@typescript-eslint/parser": "^5.0.0",
47
- "eslint": "^8.0.0",
48
- "prettier": "^2.8.0",
49
- "tsx": "^4.7.0",
50
- "typescript": "^4.9.0",
51
- "vitest": "^1.0.0"
41
+ "@types/node": "14.18.33",
42
+ "tsx": "4.7.0",
43
+ "typescript": "4.9.5",
44
+ "vite": "^5.1.6",
45
+ "vitest": "^2.0.1"
52
46
  },
53
47
  "publishConfig": {
54
- "access": "restricted"
48
+ "access": "public"
55
49
  },
56
50
  "scripts": {
57
51
  "build": "tsc",
58
- "format": "prettier --write \"src/**/*.ts\"",
59
52
  "generate-types": "tsx scripts/generate-types.ts",
60
- "lint": "eslint . --ext .ts",
61
- "release": "npm run build && changeset publish",
62
- "test": "vitest",
63
- "version-packages": "changeset version"
53
+ "vitest-run": "vitest -c ../../vitest.config.mts",
54
+ "vitest-unit": "glob --absolute 'src/**/*.test.ts'",
55
+ "type-check": "tsc --noEmit"
64
56
  }
65
57
  }