@vercel/routing-utils 2.2.1 → 3.1.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/schemas.js CHANGED
@@ -1,289 +1,329 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.trailingSlashSchema = exports.cleanUrlsSchema = exports.headersSchema = exports.redirectsSchema = exports.rewritesSchema = exports.routesSchema = exports.hasSchema = void 0;
4
- exports.hasSchema = {
5
- description: 'An array of requirements that are needed to match',
6
- type: 'array',
7
- maxItems: 16,
8
- items: {
9
- anyOf: [
10
- {
11
- type: 'object',
12
- additionalProperties: false,
13
- required: ['type', 'value'],
14
- properties: {
15
- type: {
16
- description: 'The type of request element to check',
17
- type: 'string',
18
- enum: ['host'],
19
- },
20
- value: {
21
- description: 'A regular expression used to match the value. Named groups can be used in the destination',
22
- type: 'string',
23
- maxLength: 4096,
24
- },
25
- },
26
- },
27
- {
28
- type: 'object',
29
- additionalProperties: false,
30
- required: ['type', 'key'],
31
- properties: {
32
- type: {
33
- description: 'The type of request element to check',
34
- type: 'string',
35
- enum: ['header', 'cookie', 'query'],
36
- },
37
- key: {
38
- description: 'The name of the element contained in the particular type',
39
- type: 'string',
40
- maxLength: 4096,
41
- },
42
- value: {
43
- description: 'A regular expression used to match the value. Named groups can be used in the destination',
44
- type: 'string',
45
- maxLength: 4096,
46
- },
47
- },
48
- },
49
- ],
50
- },
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
51
9
  };
52
- /**
53
- * An ajv schema for the routes array
54
- */
55
- exports.routesSchema = {
56
- type: 'array',
57
- maxItems: 1024,
58
- deprecated: true,
59
- description: 'A list of routes objects used to rewrite paths to point towards other internal or external paths',
60
- example: [{ dest: 'https://docs.example.com', src: '/docs' }],
61
- items: {
62
- anyOf: [
63
- {
64
- type: 'object',
65
- required: ['src'],
66
- additionalProperties: false,
67
- properties: {
68
- src: {
69
- type: 'string',
70
- maxLength: 4096,
71
- },
72
- dest: {
73
- type: 'string',
74
- maxLength: 4096,
75
- },
76
- headers: {
77
- type: 'object',
78
- additionalProperties: false,
79
- minProperties: 1,
80
- maxProperties: 100,
81
- patternProperties: {
82
- '^.{1,256}$': {
83
- type: 'string',
84
- maxLength: 4096,
85
- },
86
- },
87
- },
88
- methods: {
89
- type: 'array',
90
- maxItems: 10,
91
- items: {
92
- type: 'string',
93
- maxLength: 32,
94
- },
95
- },
96
- caseSensitive: {
97
- type: 'boolean',
98
- },
99
- important: {
100
- type: 'boolean',
101
- },
102
- user: {
103
- type: 'boolean',
104
- },
105
- continue: {
106
- type: 'boolean',
107
- },
108
- override: {
109
- type: 'boolean',
110
- },
111
- check: {
112
- type: 'boolean',
113
- },
114
- isInternal: {
115
- type: 'boolean',
116
- },
117
- status: {
118
- type: 'integer',
119
- minimum: 100,
120
- maximum: 999,
121
- },
122
- locale: {
123
- type: 'object',
124
- additionalProperties: false,
125
- minProperties: 1,
126
- properties: {
127
- redirect: {
128
- type: 'object',
129
- additionalProperties: false,
130
- minProperties: 1,
131
- maxProperties: 100,
132
- patternProperties: {
133
- '^.{1,256}$': {
134
- type: 'string',
135
- maxLength: 4096,
136
- },
137
- },
138
- },
139
- value: {
140
- type: 'string',
141
- maxLength: 4096,
142
- },
143
- path: {
144
- type: 'string',
145
- maxLength: 4096,
146
- },
147
- cookie: {
148
- type: 'string',
149
- maxLength: 4096,
150
- },
151
- default: {
152
- type: 'string',
153
- maxLength: 4096,
154
- },
155
- },
156
- },
157
- middleware: { type: 'number' },
158
- middlewarePath: { type: 'string' },
159
- middlewareRawSrc: {
160
- type: 'array',
161
- items: {
162
- type: 'string',
163
- },
164
- },
165
- has: exports.hasSchema,
166
- missing: exports.hasSchema,
167
- },
168
- },
169
- {
170
- type: 'object',
171
- required: ['handle'],
172
- additionalProperties: false,
173
- properties: {
174
- handle: {
175
- type: 'string',
176
- maxLength: 32,
177
- enum: ['error', 'filesystem', 'hit', 'miss', 'resource', 'rewrite'],
178
- },
179
- },
180
- },
181
- ],
182
- },
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
183
17
  };
184
- exports.rewritesSchema = {
185
- type: 'array',
186
- maxItems: 1024,
187
- description: 'A list of rewrite definitions.',
188
- items: {
189
- type: 'object',
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var schemas_exports = {};
20
+ __export(schemas_exports, {
21
+ cleanUrlsSchema: () => cleanUrlsSchema,
22
+ hasSchema: () => hasSchema,
23
+ headersSchema: () => headersSchema,
24
+ redirectsSchema: () => redirectsSchema,
25
+ rewritesSchema: () => rewritesSchema,
26
+ routesSchema: () => routesSchema,
27
+ trailingSlashSchema: () => trailingSlashSchema
28
+ });
29
+ module.exports = __toCommonJS(schemas_exports);
30
+ const hasSchema = {
31
+ description: "An array of requirements that are needed to match",
32
+ type: "array",
33
+ maxItems: 16,
34
+ items: {
35
+ anyOf: [
36
+ {
37
+ type: "object",
190
38
  additionalProperties: false,
191
- required: ['source', 'destination'],
39
+ required: ["type", "value"],
192
40
  properties: {
193
- source: {
194
- description: 'A pattern that matches each incoming pathname (excluding querystring).',
195
- type: 'string',
196
- maxLength: 4096,
197
- },
198
- destination: {
199
- description: 'An absolute pathname to an existing resource or an external URL.',
200
- type: 'string',
201
- maxLength: 4096,
202
- },
203
- has: exports.hasSchema,
204
- missing: exports.hasSchema,
205
- },
206
- },
207
- };
208
- exports.redirectsSchema = {
209
- title: 'Redirects',
210
- type: 'array',
211
- maxItems: 1024,
212
- description: 'A list of redirect definitions.',
213
- items: {
214
- type: 'object',
41
+ type: {
42
+ description: "The type of request element to check",
43
+ type: "string",
44
+ enum: ["host"]
45
+ },
46
+ value: {
47
+ description: "A regular expression used to match the value. Named groups can be used in the destination",
48
+ type: "string",
49
+ maxLength: 4096
50
+ }
51
+ }
52
+ },
53
+ {
54
+ type: "object",
215
55
  additionalProperties: false,
216
- required: ['source', 'destination'],
56
+ required: ["type", "key"],
217
57
  properties: {
218
- source: {
219
- description: 'A pattern that matches each incoming pathname (excluding querystring).',
220
- type: 'string',
221
- maxLength: 4096,
222
- },
223
- destination: {
224
- description: 'A location destination defined as an absolute pathname or external URL.',
225
- type: 'string',
226
- maxLength: 4096,
227
- },
228
- permanent: {
229
- description: 'A boolean to toggle between permanent and temporary redirect. When `true`, the status code is `308`. When `false` the status code is `307`.',
230
- type: 'boolean',
231
- },
232
- statusCode: {
233
- private: true,
234
- type: 'integer',
235
- minimum: 100,
236
- maximum: 999,
237
- },
238
- has: exports.hasSchema,
239
- missing: exports.hasSchema,
240
- },
241
- },
58
+ type: {
59
+ description: "The type of request element to check",
60
+ type: "string",
61
+ enum: ["header", "cookie", "query"]
62
+ },
63
+ key: {
64
+ description: "The name of the element contained in the particular type",
65
+ type: "string",
66
+ maxLength: 4096
67
+ },
68
+ value: {
69
+ description: "A regular expression used to match the value. Named groups can be used in the destination",
70
+ type: "string",
71
+ maxLength: 4096
72
+ }
73
+ }
74
+ }
75
+ ]
76
+ }
242
77
  };
243
- exports.headersSchema = {
244
- type: 'array',
245
- maxItems: 1024,
246
- description: 'A list of header definitions.',
247
- items: {
248
- type: 'object',
78
+ const routesSchema = {
79
+ type: "array",
80
+ maxItems: 1024,
81
+ deprecated: true,
82
+ description: "A list of routes objects used to rewrite paths to point towards other internal or external paths",
83
+ example: [{ dest: "https://docs.example.com", src: "/docs" }],
84
+ items: {
85
+ anyOf: [
86
+ {
87
+ type: "object",
88
+ required: ["src"],
249
89
  additionalProperties: false,
250
- required: ['source', 'headers'],
251
90
  properties: {
252
- source: {
253
- description: 'A pattern that matches each incoming pathname (excluding querystring)',
254
- type: 'string',
255
- maxLength: 4096,
256
- },
257
- headers: {
258
- description: 'An array of key/value pairs representing each response header.',
259
- type: 'array',
260
- maxItems: 1024,
261
- items: {
262
- type: 'object',
263
- additionalProperties: false,
264
- required: ['key', 'value'],
265
- properties: {
266
- key: {
267
- type: 'string',
268
- maxLength: 4096,
269
- },
270
- value: {
271
- type: 'string',
272
- maxLength: 4096,
273
- },
274
- },
275
- },
91
+ src: {
92
+ type: "string",
93
+ maxLength: 4096
94
+ },
95
+ dest: {
96
+ type: "string",
97
+ maxLength: 4096
98
+ },
99
+ headers: {
100
+ type: "object",
101
+ additionalProperties: false,
102
+ minProperties: 1,
103
+ maxProperties: 100,
104
+ patternProperties: {
105
+ "^.{1,256}$": {
106
+ type: "string",
107
+ maxLength: 4096
108
+ }
109
+ }
110
+ },
111
+ methods: {
112
+ type: "array",
113
+ maxItems: 10,
114
+ items: {
115
+ type: "string",
116
+ maxLength: 32
117
+ }
118
+ },
119
+ caseSensitive: {
120
+ type: "boolean"
121
+ },
122
+ important: {
123
+ type: "boolean"
124
+ },
125
+ user: {
126
+ type: "boolean"
127
+ },
128
+ continue: {
129
+ type: "boolean"
130
+ },
131
+ override: {
132
+ type: "boolean"
133
+ },
134
+ check: {
135
+ type: "boolean"
136
+ },
137
+ isInternal: {
138
+ type: "boolean"
139
+ },
140
+ status: {
141
+ type: "integer",
142
+ minimum: 100,
143
+ maximum: 999
144
+ },
145
+ locale: {
146
+ type: "object",
147
+ additionalProperties: false,
148
+ minProperties: 1,
149
+ properties: {
150
+ redirect: {
151
+ type: "object",
152
+ additionalProperties: false,
153
+ minProperties: 1,
154
+ maxProperties: 100,
155
+ patternProperties: {
156
+ "^.{1,256}$": {
157
+ type: "string",
158
+ maxLength: 4096
159
+ }
160
+ }
161
+ },
162
+ value: {
163
+ type: "string",
164
+ maxLength: 4096
165
+ },
166
+ path: {
167
+ type: "string",
168
+ maxLength: 4096
169
+ },
170
+ cookie: {
171
+ type: "string",
172
+ maxLength: 4096
173
+ },
174
+ default: {
175
+ type: "string",
176
+ maxLength: 4096
177
+ }
178
+ }
179
+ },
180
+ middleware: { type: "number" },
181
+ middlewarePath: { type: "string" },
182
+ middlewareRawSrc: {
183
+ type: "array",
184
+ items: {
185
+ type: "string"
186
+ }
187
+ },
188
+ has: hasSchema,
189
+ missing: hasSchema
190
+ }
191
+ },
192
+ {
193
+ type: "object",
194
+ required: ["handle"],
195
+ additionalProperties: false,
196
+ properties: {
197
+ handle: {
198
+ type: "string",
199
+ maxLength: 32,
200
+ enum: ["error", "filesystem", "hit", "miss", "resource", "rewrite"]
201
+ }
202
+ }
203
+ }
204
+ ]
205
+ }
206
+ };
207
+ const rewritesSchema = {
208
+ type: "array",
209
+ maxItems: 1024,
210
+ description: "A list of rewrite definitions.",
211
+ items: {
212
+ type: "object",
213
+ additionalProperties: false,
214
+ required: ["source", "destination"],
215
+ properties: {
216
+ source: {
217
+ description: "A pattern that matches each incoming pathname (excluding querystring).",
218
+ type: "string",
219
+ maxLength: 4096
220
+ },
221
+ destination: {
222
+ description: "An absolute pathname to an existing resource or an external URL.",
223
+ type: "string",
224
+ maxLength: 4096
225
+ },
226
+ has: hasSchema,
227
+ missing: hasSchema,
228
+ statusCode: {
229
+ description: "An optional integer to override the status code of the response.",
230
+ type: "integer",
231
+ minimum: 100,
232
+ maximum: 999
233
+ }
234
+ }
235
+ }
236
+ };
237
+ const redirectsSchema = {
238
+ title: "Redirects",
239
+ type: "array",
240
+ maxItems: 1024,
241
+ description: "A list of redirect definitions.",
242
+ items: {
243
+ type: "object",
244
+ additionalProperties: false,
245
+ required: ["source", "destination"],
246
+ properties: {
247
+ source: {
248
+ description: "A pattern that matches each incoming pathname (excluding querystring).",
249
+ type: "string",
250
+ maxLength: 4096
251
+ },
252
+ destination: {
253
+ description: "A location destination defined as an absolute pathname or external URL.",
254
+ type: "string",
255
+ maxLength: 4096
256
+ },
257
+ permanent: {
258
+ description: "A boolean to toggle between permanent and temporary redirect. When `true`, the status code is `308`. When `false` the status code is `307`.",
259
+ type: "boolean"
260
+ },
261
+ statusCode: {
262
+ description: "An optional integer to define the status code of the redirect.",
263
+ private: true,
264
+ type: "integer",
265
+ minimum: 100,
266
+ maximum: 999
267
+ },
268
+ has: hasSchema,
269
+ missing: hasSchema
270
+ }
271
+ }
272
+ };
273
+ const headersSchema = {
274
+ type: "array",
275
+ maxItems: 1024,
276
+ description: "A list of header definitions.",
277
+ items: {
278
+ type: "object",
279
+ additionalProperties: false,
280
+ required: ["source", "headers"],
281
+ properties: {
282
+ source: {
283
+ description: "A pattern that matches each incoming pathname (excluding querystring)",
284
+ type: "string",
285
+ maxLength: 4096
286
+ },
287
+ headers: {
288
+ description: "An array of key/value pairs representing each response header.",
289
+ type: "array",
290
+ maxItems: 1024,
291
+ items: {
292
+ type: "object",
293
+ additionalProperties: false,
294
+ required: ["key", "value"],
295
+ properties: {
296
+ key: {
297
+ type: "string",
298
+ maxLength: 4096
276
299
  },
277
- has: exports.hasSchema,
278
- missing: exports.hasSchema,
279
- },
280
- },
300
+ value: {
301
+ type: "string",
302
+ maxLength: 4096
303
+ }
304
+ }
305
+ }
306
+ },
307
+ has: hasSchema,
308
+ missing: hasSchema
309
+ }
310
+ }
281
311
  };
282
- exports.cleanUrlsSchema = {
283
- description: 'When set to `true`, all HTML files and Serverless Functions will have their extension removed. When visiting a path that ends with the extension, a 308 response will redirect the client to the extensionless path.',
284
- type: 'boolean',
312
+ const cleanUrlsSchema = {
313
+ description: "When set to `true`, all HTML files and Serverless Functions will have their extension removed. When visiting a path that ends with the extension, a 308 response will redirect the client to the extensionless path.",
314
+ type: "boolean"
285
315
  };
286
- exports.trailingSlashSchema = {
287
- description: 'When `false`, visiting a path that ends with a forward slash will respond with a `308` status code and redirect to the path without the trailing slash.',
288
- type: 'boolean',
316
+ const trailingSlashSchema = {
317
+ description: "When `false`, visiting a path that ends with a forward slash will respond with a `308` status code and redirect to the path without the trailing slash.",
318
+ type: "boolean"
289
319
  };
320
+ // Annotate the CommonJS export names for ESM import in node:
321
+ 0 && (module.exports = {
322
+ cleanUrlsSchema,
323
+ hasSchema,
324
+ headersSchema,
325
+ redirectsSchema,
326
+ rewritesSchema,
327
+ routesSchema,
328
+ trailingSlashSchema
329
+ });