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