@metlo/testing
Advanced tools
Comparing version
@@ -56,4 +56,13 @@ "use strict"; | ||
const validateEndpointFilter = (endpoint, permFilter, endpointEntities, defaultResource) => { | ||
if (permFilter.method && permFilter.method != endpoint.method) { | ||
return false; | ||
if (permFilter.method) { | ||
if (typeof permFilter.method == "string") { | ||
if (permFilter.method != endpoint.method) { | ||
return false; | ||
} | ||
} | ||
else { | ||
if (!permFilter.method.includes(endpoint.method)) { | ||
return false; | ||
} | ||
} | ||
} | ||
@@ -60,0 +69,0 @@ if (permFilter.host && !endpoint.host.match(new RegExp(permFilter.host))) { |
@@ -27,3 +27,3 @@ import { ResourceConfigParseRes, TemplateConfig } from "../types/resource_config"; | ||
path?: string | undefined; | ||
method?: import("../types/enums").RestMethod | undefined; | ||
method?: import("../types/enums").RestMethod | import("../types/enums").RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -30,0 +30,0 @@ contains_resource?: { |
@@ -83,3 +83,3 @@ import { z, ZodError } from "zod"; | ||
host: z.ZodOptional<z.ZodString>; | ||
method: z.ZodOptional<z.ZodNativeEnum<typeof RestMethod>>; | ||
method: z.ZodOptional<z.ZodUnion<[z.ZodNativeEnum<typeof RestMethod>, z.ZodArray<z.ZodNativeEnum<typeof RestMethod>, "many">]>>; | ||
path: z.ZodOptional<z.ZodString>; | ||
@@ -98,3 +98,3 @@ contains_resource: z.ZodOptional<z.ZodObject<{ | ||
path?: string | undefined; | ||
method?: RestMethod | undefined; | ||
method?: RestMethod | RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -108,3 +108,3 @@ contains_resource?: { | ||
path?: string | undefined; | ||
method?: RestMethod | undefined; | ||
method?: RestMethod | RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -126,3 +126,3 @@ contains_resource?: { | ||
host: z.ZodOptional<z.ZodString>; | ||
method: z.ZodOptional<z.ZodNativeEnum<typeof RestMethod>>; | ||
method: z.ZodOptional<z.ZodUnion<[z.ZodNativeEnum<typeof RestMethod>, z.ZodArray<z.ZodNativeEnum<typeof RestMethod>, "many">]>>; | ||
path: z.ZodOptional<z.ZodString>; | ||
@@ -141,3 +141,3 @@ contains_resource: z.ZodOptional<z.ZodObject<{ | ||
path?: string | undefined; | ||
method?: RestMethod | undefined; | ||
method?: RestMethod | RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -151,3 +151,3 @@ contains_resource?: { | ||
path?: string | undefined; | ||
method?: RestMethod | undefined; | ||
method?: RestMethod | RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -165,3 +165,3 @@ contains_resource?: { | ||
path?: string | undefined; | ||
method?: RestMethod | undefined; | ||
method?: RestMethod | RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -179,3 +179,3 @@ contains_resource?: { | ||
path?: string | undefined; | ||
method?: RestMethod | undefined; | ||
method?: RestMethod | RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -197,3 +197,3 @@ contains_resource?: { | ||
path?: string | undefined; | ||
method?: RestMethod | undefined; | ||
method?: RestMethod | RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -215,3 +215,3 @@ contains_resource?: { | ||
path?: string | undefined; | ||
method?: RestMethod | undefined; | ||
method?: RestMethod | RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -354,3 +354,3 @@ contains_resource?: { | ||
host: z.ZodOptional<z.ZodString>; | ||
method: z.ZodOptional<z.ZodNativeEnum<typeof RestMethod>>; | ||
method: z.ZodOptional<z.ZodUnion<[z.ZodNativeEnum<typeof RestMethod>, z.ZodArray<z.ZodNativeEnum<typeof RestMethod>, "many">]>>; | ||
path: z.ZodOptional<z.ZodString>; | ||
@@ -369,3 +369,3 @@ contains_resource: z.ZodOptional<z.ZodObject<{ | ||
path?: string | undefined; | ||
method?: RestMethod | undefined; | ||
method?: RestMethod | RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -379,3 +379,3 @@ contains_resource?: { | ||
path?: string | undefined; | ||
method?: RestMethod | undefined; | ||
method?: RestMethod | RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -393,3 +393,3 @@ contains_resource?: { | ||
path?: string | undefined; | ||
method?: RestMethod | undefined; | ||
method?: RestMethod | RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -407,3 +407,3 @@ contains_resource?: { | ||
path?: string | undefined; | ||
method?: RestMethod | undefined; | ||
method?: RestMethod | RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -425,3 +425,3 @@ contains_resource?: { | ||
path?: string | undefined; | ||
method?: RestMethod | undefined; | ||
method?: RestMethod | RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -443,3 +443,3 @@ contains_resource?: { | ||
path?: string | undefined; | ||
method?: RestMethod | undefined; | ||
method?: RestMethod | RestMethod[] | undefined; | ||
host?: string | undefined; | ||
@@ -446,0 +446,0 @@ contains_resource?: { |
@@ -36,3 +36,5 @@ "use strict"; | ||
host: zod_1.z.string().optional(), | ||
method: zod_1.z.nativeEnum(enums_1.RestMethod).optional(), | ||
method: zod_1.z | ||
.union([zod_1.z.nativeEnum(enums_1.RestMethod), zod_1.z.nativeEnum(enums_1.RestMethod).array()]) | ||
.optional(), | ||
path: zod_1.z.string().optional(), | ||
@@ -39,0 +41,0 @@ contains_resource: ContainsResourceFilterSchema.optional(), |
{ | ||
"name": "@metlo/testing", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1227355
0.08%13170
0.08%