@vercel/routing-utils 5.0.6 → 5.0.8

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
@@ -162,6 +162,195 @@ const hasSchema = {
162
162
  ]
163
163
  }
164
164
  };
165
+ const transformsSchema = {
166
+ description: "A list of transform rules to adjust the query parameters of a request or HTTP headers of request or response",
167
+ type: "array",
168
+ minItems: 1,
169
+ items: {
170
+ type: "object",
171
+ additionalProperties: false,
172
+ required: ["type", "op", "target"],
173
+ properties: {
174
+ type: {
175
+ description: "The scope of the transform to apply",
176
+ type: "string",
177
+ enum: ["request.headers", "request.query", "response.headers"]
178
+ },
179
+ op: {
180
+ description: "The operation to perform on the target",
181
+ type: "string",
182
+ enum: ["append", "set", "delete"]
183
+ },
184
+ target: {
185
+ description: "The target of the transform",
186
+ type: "object",
187
+ required: ["key"],
188
+ properties: {
189
+ // re is not supported for transforms. Once supported, replace target.key with matchableValueSchema
190
+ key: {
191
+ description: "A value to match against. Can be a string or a condition operation object (without regex support)",
192
+ anyOf: [
193
+ {
194
+ description: "A valid header name (letters, numbers, hyphens, underscores)",
195
+ type: "string",
196
+ maxLength: 4096
197
+ },
198
+ {
199
+ description: "A condition operation object",
200
+ type: "object",
201
+ additionalProperties: false,
202
+ minProperties: 1,
203
+ properties: {
204
+ eq: {
205
+ description: "Equal to",
206
+ anyOf: [
207
+ {
208
+ type: "string",
209
+ maxLength: 4096
210
+ },
211
+ {
212
+ type: "number"
213
+ }
214
+ ]
215
+ },
216
+ neq: {
217
+ description: "Not equal",
218
+ type: "string",
219
+ maxLength: 4096
220
+ },
221
+ inc: {
222
+ description: "In array",
223
+ type: "array",
224
+ items: {
225
+ type: "string",
226
+ maxLength: 4096
227
+ }
228
+ },
229
+ ninc: {
230
+ description: "Not in array",
231
+ type: "array",
232
+ items: {
233
+ type: "string",
234
+ maxLength: 4096
235
+ }
236
+ },
237
+ pre: {
238
+ description: "Starts with",
239
+ type: "string",
240
+ maxLength: 4096
241
+ },
242
+ suf: {
243
+ description: "Ends with",
244
+ type: "string",
245
+ maxLength: 4096
246
+ },
247
+ gt: {
248
+ description: "Greater than",
249
+ type: "number"
250
+ },
251
+ gte: {
252
+ description: "Greater than or equal to",
253
+ type: "number"
254
+ },
255
+ lt: {
256
+ description: "Less than",
257
+ type: "number"
258
+ },
259
+ lte: {
260
+ description: "Less than or equal to",
261
+ type: "number"
262
+ }
263
+ }
264
+ }
265
+ ]
266
+ }
267
+ }
268
+ },
269
+ args: {
270
+ description: "The arguments to the operation",
271
+ anyOf: [
272
+ {
273
+ type: "string",
274
+ maxLength: 4096
275
+ },
276
+ {
277
+ type: "array",
278
+ minItems: 1,
279
+ items: {
280
+ type: "string",
281
+ maxLength: 4096
282
+ }
283
+ }
284
+ ]
285
+ }
286
+ },
287
+ allOf: [
288
+ {
289
+ if: {
290
+ properties: {
291
+ op: {
292
+ enum: ["append", "set"]
293
+ }
294
+ }
295
+ },
296
+ then: {
297
+ required: ["args"]
298
+ }
299
+ },
300
+ {
301
+ if: {
302
+ allOf: [
303
+ {
304
+ properties: {
305
+ type: {
306
+ enum: ["request.headers", "response.headers"]
307
+ }
308
+ }
309
+ },
310
+ {
311
+ properties: {
312
+ op: {
313
+ enum: ["set", "append"]
314
+ }
315
+ }
316
+ }
317
+ ]
318
+ },
319
+ then: {
320
+ properties: {
321
+ target: {
322
+ properties: {
323
+ key: {
324
+ if: {
325
+ type: "string"
326
+ },
327
+ then: {
328
+ pattern: "^[a-zA-Z0-9_-]+$"
329
+ }
330
+ }
331
+ }
332
+ },
333
+ args: {
334
+ anyOf: [
335
+ {
336
+ type: "string",
337
+ pattern: "^[a-zA-Z0-9_ :;.,\"'?!(){}\\[\\]@<>=+*#$&`|~\\^%/-]+$"
338
+ },
339
+ {
340
+ type: "array",
341
+ items: {
342
+ type: "string",
343
+ pattern: "^[a-zA-Z0-9_ :;.,\"'?!(){}\\[\\]@<>=+*#$&`|~\\^%/-]+$"
344
+ }
345
+ }
346
+ ]
347
+ }
348
+ }
349
+ }
350
+ }
351
+ ]
352
+ }
353
+ };
165
354
  const routesSchema = {
166
355
  type: "array",
167
356
  maxItems: 2048,
@@ -274,7 +463,8 @@ const routesSchema = {
274
463
  },
275
464
  has: hasSchema,
276
465
  missing: hasSchema,
277
- mitigate: mitigateSchema
466
+ mitigate: mitigateSchema,
467
+ transforms: transformsSchema
278
468
  }
279
469
  },
280
470
  {
package/dist/types.d.ts CHANGED
@@ -29,6 +29,25 @@ export type HasField = Array<{
29
29
  key: string;
30
30
  value?: MatchableValue;
31
31
  }>;
32
+ type Transform = {
33
+ type: 'request.headers' | 'request.query' | 'response.headers';
34
+ op: 'append' | 'set' | 'delete';
35
+ target: {
36
+ key: string | {
37
+ eq?: string | number;
38
+ neq?: string;
39
+ inc?: string[];
40
+ ninc?: string[];
41
+ pre?: string;
42
+ suf?: string;
43
+ gt?: number;
44
+ gte?: number;
45
+ lt?: number;
46
+ lte?: number;
47
+ };
48
+ };
49
+ args?: string | string[];
50
+ };
32
51
  export type RouteWithSrc = {
33
52
  src: string;
34
53
  dest?: string;
@@ -47,6 +66,7 @@ export type RouteWithSrc = {
47
66
  mitigate?: {
48
67
  action: MitigateAction;
49
68
  };
69
+ transforms?: Transform[];
50
70
  locale?: {
51
71
  redirect?: Record<string, string>;
52
72
  cookie?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/routing-utils",
3
- "version": "5.0.6",
3
+ "version": "5.0.8",
4
4
  "description": "Vercel routing utilities",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",