@vercel/routing-utils 5.0.7 → 5.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.d.ts CHANGED
@@ -190,7 +190,6 @@ export declare const hasSchema: {
190
190
  */
191
191
  export declare const routesSchema: {
192
192
  readonly type: "array";
193
- readonly maxItems: 2048;
194
193
  readonly deprecated: true;
195
194
  readonly description: "A list of routes objects used to rewrite paths to point towards other internal or external paths";
196
195
  readonly example: readonly [{
@@ -691,6 +690,176 @@ export declare const routesSchema: {
691
690
  };
692
691
  };
693
692
  };
693
+ readonly transforms: {
694
+ readonly description: "A list of transform rules to adjust the query parameters of a request or HTTP headers of request or response";
695
+ readonly type: "array";
696
+ readonly minItems: 1;
697
+ readonly items: {
698
+ readonly type: "object";
699
+ readonly additionalProperties: false;
700
+ readonly required: readonly ["type", "op", "target"];
701
+ readonly properties: {
702
+ readonly type: {
703
+ readonly description: "The scope of the transform to apply";
704
+ readonly type: "string";
705
+ readonly enum: readonly ["request.headers", "request.query", "response.headers"];
706
+ };
707
+ readonly op: {
708
+ readonly description: "The operation to perform on the target";
709
+ readonly type: "string";
710
+ readonly enum: readonly ["append", "set", "delete"];
711
+ };
712
+ readonly target: {
713
+ readonly description: "The target of the transform";
714
+ readonly type: "object";
715
+ readonly required: readonly ["key"];
716
+ readonly properties: {
717
+ readonly key: {
718
+ readonly description: "A value to match against. Can be a string or a condition operation object (without regex support)";
719
+ readonly anyOf: readonly [{
720
+ readonly description: "A valid header name (letters, numbers, hyphens, underscores)";
721
+ readonly type: "string";
722
+ readonly maxLength: 4096;
723
+ }, {
724
+ readonly description: "A condition operation object";
725
+ readonly type: "object";
726
+ readonly additionalProperties: false;
727
+ readonly minProperties: 1;
728
+ readonly properties: {
729
+ readonly eq: {
730
+ readonly description: "Equal to";
731
+ readonly anyOf: readonly [{
732
+ readonly type: "string";
733
+ readonly maxLength: 4096;
734
+ }, {
735
+ readonly type: "number";
736
+ }];
737
+ };
738
+ readonly neq: {
739
+ readonly description: "Not equal";
740
+ readonly type: "string";
741
+ readonly maxLength: 4096;
742
+ };
743
+ readonly inc: {
744
+ readonly description: "In array";
745
+ readonly type: "array";
746
+ readonly items: {
747
+ readonly type: "string";
748
+ readonly maxLength: 4096;
749
+ };
750
+ };
751
+ readonly ninc: {
752
+ readonly description: "Not in array";
753
+ readonly type: "array";
754
+ readonly items: {
755
+ readonly type: "string";
756
+ readonly maxLength: 4096;
757
+ };
758
+ };
759
+ readonly pre: {
760
+ readonly description: "Starts with";
761
+ readonly type: "string";
762
+ readonly maxLength: 4096;
763
+ };
764
+ readonly suf: {
765
+ readonly description: "Ends with";
766
+ readonly type: "string";
767
+ readonly maxLength: 4096;
768
+ };
769
+ readonly gt: {
770
+ readonly description: "Greater than";
771
+ readonly type: "number";
772
+ };
773
+ readonly gte: {
774
+ readonly description: "Greater than or equal to";
775
+ readonly type: "number";
776
+ };
777
+ readonly lt: {
778
+ readonly description: "Less than";
779
+ readonly type: "number";
780
+ };
781
+ readonly lte: {
782
+ readonly description: "Less than or equal to";
783
+ readonly type: "number";
784
+ };
785
+ };
786
+ }];
787
+ };
788
+ };
789
+ };
790
+ readonly args: {
791
+ readonly description: "The arguments to the operation";
792
+ readonly anyOf: readonly [{
793
+ readonly type: "string";
794
+ readonly maxLength: 4096;
795
+ }, {
796
+ readonly type: "array";
797
+ readonly minItems: 1;
798
+ readonly items: {
799
+ readonly type: "string";
800
+ readonly maxLength: 4096;
801
+ };
802
+ }];
803
+ };
804
+ };
805
+ readonly allOf: readonly [{
806
+ readonly if: {
807
+ readonly properties: {
808
+ readonly op: {
809
+ readonly enum: readonly ["append", "set"];
810
+ };
811
+ };
812
+ };
813
+ readonly then: {
814
+ readonly required: readonly ["args"];
815
+ };
816
+ }, {
817
+ readonly if: {
818
+ readonly allOf: readonly [{
819
+ readonly properties: {
820
+ readonly type: {
821
+ readonly enum: readonly ["request.headers", "response.headers"];
822
+ };
823
+ };
824
+ }, {
825
+ readonly properties: {
826
+ readonly op: {
827
+ readonly enum: readonly ["set", "append"];
828
+ };
829
+ };
830
+ }];
831
+ };
832
+ readonly then: {
833
+ readonly properties: {
834
+ readonly target: {
835
+ readonly properties: {
836
+ readonly key: {
837
+ readonly if: {
838
+ readonly type: "string";
839
+ };
840
+ readonly then: {
841
+ readonly pattern: "^[a-zA-Z0-9_-]+$";
842
+ };
843
+ };
844
+ };
845
+ };
846
+ readonly args: {
847
+ readonly anyOf: readonly [{
848
+ readonly type: "string";
849
+ readonly pattern: "^[a-zA-Z0-9_ :;.,\"'?!(){}\\[\\]@<>=+*#$&`|~\\^%/-]+$";
850
+ }, {
851
+ readonly type: "array";
852
+ readonly items: {
853
+ readonly type: "string";
854
+ readonly pattern: "^[a-zA-Z0-9_ :;.,\"'?!(){}\\[\\]@<>=+*#$&`|~\\^%/-]+$";
855
+ };
856
+ }];
857
+ };
858
+ };
859
+ };
860
+ }];
861
+ };
862
+ };
694
863
  };
695
864
  }, {
696
865
  readonly type: "object";
package/dist/schemas.js CHANGED
@@ -162,9 +162,197 @@ 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
- maxItems: 2048,
168
356
  deprecated: true,
169
357
  description: "A list of routes objects used to rewrite paths to point towards other internal or external paths",
170
358
  example: [{ dest: "https://docs.example.com", src: "/docs" }],
@@ -274,7 +462,8 @@ const routesSchema = {
274
462
  },
275
463
  has: hasSchema,
276
464
  missing: hasSchema,
277
- mitigate: mitigateSchema
465
+ mitigate: mitigateSchema,
466
+ transforms: transformsSchema
278
467
  }
279
468
  },
280
469
  {
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.7",
3
+ "version": "5.1.0",
4
4
  "description": "Vercel routing utilities",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",