mock-config-server
Advanced tools
Comparing version 3.5.0 to 3.6.0
@@ -6,6 +6,6 @@ #!/usr/bin/env node | ||
}); | ||
const pleaseUpgradeNode = require("please-upgrade-node"); | ||
const packageJson = require("../../package.json"); | ||
const pleaseUpgradeNode = require('please-upgrade-node'); | ||
const packageJson = require('../../package.json'); | ||
pleaseUpgradeNode(packageJson); | ||
const { cli } = require("./cli"); | ||
const { cli } = require('./cli'); | ||
cli(); |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (!configFilePath) { | ||
throw new Error("Cannot find config file mock-server.config.(ts|mts|cts|js|mjs|cjs)"); | ||
throw new Error('Cannot find config file mock-server.config.(ts|mts|cts|js|mjs|cjs)'); | ||
} | ||
@@ -25,4 +25,4 @@ const buildOptions = { | ||
bundle: true, | ||
platform: "node", | ||
target: "esnext", | ||
platform: 'node', | ||
target: 'esnext', | ||
minifySyntax: true, | ||
@@ -32,3 +32,3 @@ minify: true, | ||
metafile: false, | ||
logLevel: "info", | ||
logLevel: 'info', | ||
plugins: [] | ||
@@ -38,3 +38,3 @@ }; | ||
const watchPlugin = { | ||
name: "watch", | ||
name: 'watch', | ||
setup: (build)=>{ | ||
@@ -41,0 +41,0 @@ let instance; |
@@ -22,15 +22,15 @@ "use strict"; | ||
baseUrl: { | ||
alias: "b", | ||
description: "Set base url for mock server", | ||
type: "string" | ||
alias: 'b', | ||
description: 'Set base url for mock server', | ||
type: 'string' | ||
}, | ||
port: { | ||
alias: "p", | ||
description: "Set port for server", | ||
type: "number" | ||
alias: 'p', | ||
description: 'Set port for server', | ||
type: 'number' | ||
}, | ||
staticPath: { | ||
alias: "s", | ||
description: "Set static path for mock server", | ||
type: "string" | ||
alias: 's', | ||
description: 'Set static path for mock server', | ||
type: 'string' | ||
} | ||
@@ -40,20 +40,20 @@ }; | ||
const processArgv = (0, _helpers.hideBin)(process.argv); | ||
if (processArgv.includes("init")) { | ||
if (processArgv.includes('init')) { | ||
const argv = (0, _yargs.default)(processArgv).options(initOptions).parse(); | ||
return (0, _init.init)(argv); | ||
} | ||
const argv = (0, _yargs.default)(processArgv).usage("mcs [options]").epilogue("More info: https://github.com/siberiacancode/mock-config-server#readme").options({ | ||
const argv = (0, _yargs.default)(processArgv).usage('mcs [options]').epilogue('More info: https://github.com/siberiacancode/mock-config-server#readme').options({ | ||
...initOptions, | ||
config: { | ||
alias: "c", | ||
description: "Set path to config file", | ||
type: "string" | ||
alias: 'c', | ||
description: 'Set path to config file', | ||
type: 'string' | ||
}, | ||
watch: { | ||
alias: "w", | ||
description: "Enables server restart after config file changes", | ||
type: "boolean" | ||
alias: 'w', | ||
description: 'Enables server restart after config file changes', | ||
type: 'boolean' | ||
} | ||
}).version().alias("version", "v").help().alias("help", "h").parse(); | ||
}).version().alias('version', 'v').help().alias('help', 'h').parse(); | ||
(0, _build.build)(argv); | ||
}; |
@@ -20,4 +20,4 @@ "use strict"; | ||
const createTemplate = (options)=>{ | ||
const language = options.withTypescript ? "ts" : "js"; | ||
const templatePath = _nodepath.default.join(__dirname, "..", `templates/${language}/${options.apiType}`); | ||
const language = options.withTypescript ? 'ts' : 'js'; | ||
const templatePath = _nodepath.default.join(__dirname, '..', `templates/${language}/${options.apiType}`); | ||
_nodefs.default.cpSync(`${templatePath}/mock-requests`, `${_constants.APP_PATH}/mock-requests`, { | ||
@@ -27,4 +27,4 @@ recursive: true, | ||
}); | ||
let mockServerConfig = _nodefs.default.readFileSync(`${templatePath}/mock-server.config.${language}`, "utf8"); | ||
if (options.staticPath !== "/") { | ||
let mockServerConfig = _nodefs.default.readFileSync(`${templatePath}/mock-server.config.${language}`, 'utf8'); | ||
if (options.staticPath !== '/') { | ||
mockServerConfig = mockServerConfig.replace(`port: ${_constants.DEFAULT.PORT}`, `port: ${_constants.DEFAULT.PORT},\n staticPath: '${options.staticPath}'`); | ||
@@ -31,0 +31,0 @@ } |
@@ -12,4 +12,4 @@ "use strict"; | ||
const getValidationMessageFromPath = (path)=>path.reduce((validationMessageAcc, pathElement)=>{ | ||
if (typeof pathElement === "number") return `${validationMessageAcc}[${pathElement}]`; | ||
if (typeof pathElement === 'number') return `${validationMessageAcc}[${pathElement}]`; | ||
return `${validationMessageAcc}.${pathElement}`; | ||
}, ""); | ||
}, ''); |
@@ -12,6 +12,6 @@ "use strict"; | ||
const DATA_RESOLVING_PROPERTIES = [ | ||
"data", | ||
"file", | ||
"queue" | ||
'data', | ||
'file', | ||
'queue' | ||
]; | ||
const isOnlyRequestedDataResolvingPropertyExists = (object, requestedDataResolvingProperty)=>DATA_RESOLVING_PROPERTIES.every((dataResolvingProperty)=>dataResolvingProperty === requestedDataResolvingProperty ? dataResolvingProperty in object : !(dataResolvingProperty in object)); |
@@ -15,3 +15,3 @@ "use strict"; | ||
if (!configSourceCode) { | ||
throw new Error("Cannot handle source code of mock-server.config.(ts|js)"); | ||
throw new Error('Cannot handle source code of mock-server.config.(ts|js)'); | ||
} | ||
@@ -21,8 +21,8 @@ const mockServerConfigExports = (0, _resolveExportsFromSourceCode.resolveExportsFromSourceCode)(configSourceCode); | ||
if (!mockServerConfig) { | ||
throw new Error("Cannot handle exports of mock-server.config.(ts|js)"); | ||
throw new Error('Cannot handle exports of mock-server.config.(ts|js)'); | ||
} | ||
if (!(0, _helpers.isPlainObject)(mockServerConfig)) { | ||
throw new Error("configuration should be plain object; see our doc (https://www.npmjs.com/package/mock-config-server) for more information"); | ||
throw new Error('configuration should be plain object; see our doc (https://www.npmjs.com/package/mock-config-server) for more information'); | ||
} | ||
return mockServerConfig; | ||
}; |
@@ -15,4 +15,4 @@ "use strict"; | ||
// eslint-disable-next-line no-underscore-dangle | ||
moduleInstance._compile(sourceCode, ""); | ||
moduleInstance._compile(sourceCode, ''); | ||
return moduleInstance.exports; | ||
}; |
@@ -26,29 +26,29 @@ "use strict"; | ||
{ | ||
name: "withTypescript", | ||
type: "toggle", | ||
message: "Would you like to use TypeScript?", | ||
name: 'withTypescript', | ||
type: 'toggle', | ||
message: 'Would you like to use TypeScript?', | ||
initial: true, | ||
active: "Yes", | ||
inactive: "No" | ||
active: 'Yes', | ||
inactive: 'No' | ||
}, | ||
{ | ||
type: "select", | ||
name: "apiType", | ||
message: "Choose api type", | ||
type: 'select', | ||
name: 'apiType', | ||
message: 'Choose api type', | ||
initial: 0, | ||
choices: [ | ||
{ | ||
title: "Rest", | ||
description: "Rest api sample", | ||
value: "rest" | ||
title: 'Rest', | ||
description: 'Rest api sample', | ||
value: 'rest' | ||
}, | ||
{ | ||
title: "GraphQL", | ||
description: "GraphQL api sample", | ||
value: "graphql" | ||
title: 'GraphQL', | ||
description: 'GraphQL api sample', | ||
value: 'graphql' | ||
}, | ||
{ | ||
title: "Both", | ||
description: "Rest api and GraphQL api sample", | ||
value: "full" | ||
title: 'Both', | ||
description: 'Rest api and GraphQL api sample', | ||
value: 'full' | ||
} | ||
@@ -58,6 +58,6 @@ ] | ||
{ | ||
name: "baseUrl", | ||
type: argv.baseUrl ? null : "text", | ||
message: "Base url (must start with a forward slash):", | ||
initial: "/", | ||
name: 'baseUrl', | ||
type: argv.baseUrl ? null : 'text', | ||
message: 'Base url (must start with a forward slash):', | ||
initial: '/', | ||
validate: (baseUrl)=>{ | ||
@@ -68,3 +68,3 @@ try { | ||
} catch { | ||
return "Invalid base url value"; | ||
return 'Invalid base url value'; | ||
} | ||
@@ -74,5 +74,5 @@ } | ||
{ | ||
name: "port", | ||
type: argv.port ? null : "number", | ||
message: "Port:", | ||
name: 'port', | ||
type: argv.port ? null : 'number', | ||
message: 'Port:', | ||
initial: 31299, | ||
@@ -84,3 +84,3 @@ validate: (port)=>{ | ||
} catch (error) { | ||
return "Invalid port value"; | ||
return 'Invalid port value'; | ||
} | ||
@@ -90,6 +90,6 @@ } | ||
{ | ||
name: "staticPath", | ||
type: argv.staticPath ? null : "text", | ||
message: "Static path (must start with a forward slash):", | ||
initial: "/", | ||
name: 'staticPath', | ||
type: argv.staticPath ? null : 'text', | ||
message: 'Static path (must start with a forward slash):', | ||
initial: '/', | ||
validate: (staticPath)=>{ | ||
@@ -100,3 +100,3 @@ try { | ||
} catch { | ||
return "Invalid static path value"; | ||
return 'Invalid static path value'; | ||
} | ||
@@ -107,3 +107,3 @@ } | ||
onCancel: ()=>{ | ||
throw new Error("❌ Operation cancelled"); | ||
throw new Error('❌ Operation cancelled'); | ||
} | ||
@@ -116,7 +116,7 @@ }); | ||
var _process_env_npm_config_user_agent; | ||
const userAgent = (_process_env_npm_config_user_agent = process.env.npm_config_user_agent) !== null && _process_env_npm_config_user_agent !== void 0 ? _process_env_npm_config_user_agent : ""; | ||
const userAgent = (_process_env_npm_config_user_agent = process.env.npm_config_user_agent) !== null && _process_env_npm_config_user_agent !== void 0 ? _process_env_npm_config_user_agent : ''; | ||
// eslint-disable-next-line no-nested-ternary | ||
const packageManager = /pnpm/.test(userAgent) ? "pnpm" : /yarn/.test(userAgent) ? "yarn" : "npx"; | ||
console.log("\n"); | ||
console.log(_ansicolors.default.bold("\uD83C\uDF89 Thanks for using mock-config-server! \uD83C\uDF89")); | ||
const packageManager = /pnpm/.test(userAgent) ? 'pnpm' : /yarn/.test(userAgent) ? 'yarn' : 'npx'; | ||
console.log('\n'); | ||
console.log(_ansicolors.default.bold('🎉 Thanks for using mock-config-server! 🎉')); | ||
console.log(`start command: ${_ansicolors.default.bold(_ansicolors.default.green(`${packageManager} mcs`))}`); | ||
@@ -123,0 +123,0 @@ } catch (cancelled) { |
@@ -30,13 +30,13 @@ #!/usr/bin/env node | ||
}; | ||
if (!mergedMockServerConfig.rest && !mergedMockServerConfig.graphql && "configs" in mergedMockServerConfig) { | ||
if (!mergedMockServerConfig.rest && !mergedMockServerConfig.graphql && 'configs' in mergedMockServerConfig) { | ||
const mergedApiMockServerConfig = mergedMockServerConfig; | ||
if (Array.isArray(mergedApiMockServerConfig.configs) && (0, _helpers.isPlainObject)(mergedApiMockServerConfig.configs[0]) && "path" in mergedApiMockServerConfig.configs[0]) { | ||
(0, _validateApiMockServerConfig.validateApiMockServerConfig)(mergedApiMockServerConfig, "rest"); | ||
if (Array.isArray(mergedApiMockServerConfig.configs) && (0, _helpers.isPlainObject)(mergedApiMockServerConfig.configs[0]) && 'path' in mergedApiMockServerConfig.configs[0]) { | ||
(0, _validateApiMockServerConfig.validateApiMockServerConfig)(mergedApiMockServerConfig, 'rest'); | ||
return (0, _server.startRestMockServer)(mergedApiMockServerConfig); | ||
} | ||
if (Array.isArray(mergedApiMockServerConfig.configs) && (0, _helpers.isPlainObject)(mergedApiMockServerConfig.configs[0]) && ("query" in mergedApiMockServerConfig.configs[0] || "operationName" in mergedApiMockServerConfig.configs[0])) { | ||
(0, _validateApiMockServerConfig.validateApiMockServerConfig)(mergedApiMockServerConfig, "graphql"); | ||
if (Array.isArray(mergedApiMockServerConfig.configs) && (0, _helpers.isPlainObject)(mergedApiMockServerConfig.configs[0]) && ('query' in mergedApiMockServerConfig.configs[0] || 'operationName' in mergedApiMockServerConfig.configs[0])) { | ||
(0, _validateApiMockServerConfig.validateApiMockServerConfig)(mergedApiMockServerConfig, 'graphql'); | ||
return (0, _server.startGraphQLMockServer)(mergedApiMockServerConfig); | ||
} | ||
(0, _validateApiMockServerConfig.validateApiMockServerConfig)(mergedApiMockServerConfig, "rest"); | ||
(0, _validateApiMockServerConfig.validateApiMockServerConfig)(mergedApiMockServerConfig, 'rest'); | ||
return (0, _server.startRestMockServer)(mergedApiMockServerConfig); | ||
@@ -43,0 +43,0 @@ } |
@@ -10,3 +10,3 @@ import { z } from 'zod'; | ||
}, "strict", z.ZodTypeAny, { | ||
origin: (string | RegExp | (string | RegExp)[] | ((...args: unknown[]) => unknown)) & (string | RegExp | (string | RegExp)[] | ((...args: unknown[]) => unknown) | undefined); | ||
origin: string | RegExp | (string | RegExp)[] | ((...args: unknown[]) => unknown); | ||
methods?: ("GET" | "POST" | "DELETE" | "PUT" | "PATCH" | "OPTIONS")[] | undefined; | ||
@@ -18,3 +18,3 @@ allowedHeaders?: string[] | undefined; | ||
}, { | ||
origin: (string | RegExp | (string | RegExp)[] | ((...args: unknown[]) => unknown)) & (string | RegExp | (string | RegExp)[] | ((...args: unknown[]) => unknown) | undefined); | ||
origin: string | RegExp | (string | RegExp)[] | ((...args: unknown[]) => unknown); | ||
methods?: ("GET" | "POST" | "DELETE" | "PUT" | "PATCH" | "OPTIONS")[] | undefined; | ||
@@ -21,0 +21,0 @@ allowedHeaders?: string[] | undefined; |
@@ -24,8 +24,8 @@ "use strict"; | ||
methods: _zod.z.array(_zod.z.enum([ | ||
"GET", | ||
"POST", | ||
"PUT", | ||
"DELETE", | ||
"PATCH", | ||
"OPTIONS" | ||
'GET', | ||
'POST', | ||
'PUT', | ||
'DELETE', | ||
'PATCH', | ||
'OPTIONS' | ||
])).optional(), | ||
@@ -32,0 +32,0 @@ allowedHeaders: _zod.z.array(_zod.z.string()).optional(), |
import { z } from 'zod'; | ||
export declare const graphqlConfigSchema: z.ZodObject<{ | ||
baseUrl: z.ZodOptional<z.ZodString>; | ||
configs: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
configs: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
operationName: z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>; | ||
query: z.ZodOptional<z.ZodString>; | ||
operationName: z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>; | ||
}, { | ||
operationType: z.ZodEnum<["query", "mutation"]>; | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data: z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodAny]>; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
data?: any; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
time?: number | undefined; | ||
data?: any; | ||
}, z.ZodTypeDef, { | ||
time?: number | undefined; | ||
data?: any; | ||
}>>, "many">; | ||
settings: z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodObject<z.objectUtil.extendShape<{ | ||
polling: z.ZodOptional<z.ZodBoolean>; | ||
status: z.ZodOptional<z.ZodNumber>; | ||
delay: z.ZodOptional<z.ZodNumber>; | ||
}, { | ||
polling: z.ZodLiteral<true>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
polling: true; | ||
@@ -44,8 +41,16 @@ status?: number | undefined; | ||
}>; | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
data?: any; | ||
time?: number | undefined; | ||
}, z.ZodTypeDef, { | ||
data?: any; | ||
time?: number | undefined; | ||
}>>, "many">; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -57,4 +62,4 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
@@ -67,16 +72,16 @@ queue: unknown[]; | ||
}; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>]>, "many">; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
routes: ({ | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -88,6 +93,6 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
})[]; | ||
operationName: (string | RegExp) & (string | RegExp | undefined); | ||
operationName: string | RegExp; | ||
operationType: "query" | "mutation"; | ||
@@ -98,38 +103,35 @@ query?: string | undefined; | ||
routes: unknown[]; | ||
operationName: (string | RegExp) & (string | RegExp | undefined); | ||
operationName: string | RegExp; | ||
operationType: "query" | "mutation"; | ||
query?: string | undefined; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
operationName: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>>; | ||
query: z.ZodString; | ||
operationName: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>>; | ||
}, { | ||
operationType: z.ZodEnum<["query", "mutation"]>; | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data: z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodAny]>; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
data?: any; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
time?: number | undefined; | ||
data?: any; | ||
}, z.ZodTypeDef, { | ||
time?: number | undefined; | ||
data?: any; | ||
}>>, "many">; | ||
settings: z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodObject<z.objectUtil.extendShape<{ | ||
polling: z.ZodOptional<z.ZodBoolean>; | ||
status: z.ZodOptional<z.ZodNumber>; | ||
delay: z.ZodOptional<z.ZodNumber>; | ||
}, { | ||
polling: z.ZodLiteral<true>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
polling: true; | ||
@@ -143,8 +145,16 @@ status?: number | undefined; | ||
}>; | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
data?: any; | ||
time?: number | undefined; | ||
}, z.ZodTypeDef, { | ||
data?: any; | ||
time?: number | undefined; | ||
}>>, "many">; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -156,4 +166,4 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
@@ -166,17 +176,17 @@ queue: unknown[]; | ||
}; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>]>, "many">; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
query: string; | ||
routes: ({ | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -188,8 +198,8 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
})[]; | ||
operationType: "query" | "mutation"; | ||
interceptors?: any; | ||
operationName?: string | RegExp | undefined; | ||
interceptors?: any; | ||
}, { | ||
@@ -199,4 +209,4 @@ query: string; | ||
operationType: "query" | "mutation"; | ||
interceptors?: unknown; | ||
operationName?: string | RegExp | undefined; | ||
interceptors?: unknown; | ||
}>>]>, "many">; | ||
@@ -208,9 +218,9 @@ interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -222,6 +232,6 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
})[]; | ||
operationName: (string | RegExp) & (string | RegExp | undefined); | ||
operationName: string | RegExp; | ||
operationType: "query" | "mutation"; | ||
@@ -234,9 +244,9 @@ query?: string | undefined; | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -248,15 +258,15 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
})[]; | ||
operationType: "query" | "mutation"; | ||
interceptors?: any; | ||
operationName?: string | RegExp | undefined; | ||
interceptors?: any; | ||
})[]; | ||
interceptors?: any; | ||
baseUrl?: string | undefined; | ||
interceptors?: any; | ||
}, { | ||
configs: unknown[]; | ||
interceptors?: unknown; | ||
baseUrl?: string | undefined; | ||
interceptors?: unknown; | ||
}>; |
@@ -19,4 +19,4 @@ "use strict"; | ||
operationType: _zod.z.enum([ | ||
"query", | ||
"mutation" | ||
'query', | ||
'mutation' | ||
]), | ||
@@ -41,4 +41,4 @@ routes: _zod.z.array(_routeConfigSchema.routeConfigSchema), | ||
const requestConfigSchema = _zod.z.union([ | ||
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && "operationName" in value).pipe(operationNameRequestConfigSchema), | ||
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && "query" in value).pipe(queryRequestConfigSchema) | ||
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && 'operationName' in value).pipe(operationNameRequestConfigSchema), | ||
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && 'query' in value).pipe(queryRequestConfigSchema) | ||
]); | ||
@@ -45,0 +45,0 @@ const graphqlConfigSchema = _zod.z.strictObject({ |
import { z } from 'zod'; | ||
export declare const routeConfigSchema: z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
export declare const routeConfigSchema: z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data: z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodAny]>; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
data?: any; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
time?: number | undefined; | ||
data?: any; | ||
}, z.ZodTypeDef, { | ||
time?: number | undefined; | ||
data?: any; | ||
}>>, "many">; | ||
settings: z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodObject<z.objectUtil.extendShape<{ | ||
polling: z.ZodOptional<z.ZodBoolean>; | ||
status: z.ZodOptional<z.ZodNumber>; | ||
delay: z.ZodOptional<z.ZodNumber>; | ||
}, { | ||
polling: z.ZodLiteral<true>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
polling: true; | ||
@@ -38,8 +34,16 @@ status?: number | undefined; | ||
}>; | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
data?: any; | ||
time?: number | undefined; | ||
}, z.ZodTypeDef, { | ||
data?: any; | ||
time?: number | undefined; | ||
}>>, "many">; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -51,4 +55,4 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
@@ -61,4 +65,4 @@ queue: unknown[]; | ||
}; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>]>; |
@@ -25,5 +25,3 @@ "use strict"; | ||
})).optional(), | ||
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema.pick({ | ||
response: true | ||
})).optional() | ||
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional() | ||
}); | ||
@@ -46,4 +44,4 @@ const dataRouteConfigSchema = _zod.z.strictObject({ | ||
const routeConfigSchema = _zod.z.union([ | ||
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, "data")).pipe(dataRouteConfigSchema), | ||
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, "queue")).pipe(queueRouteConfigSchema) | ||
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, 'data')).pipe(dataRouteConfigSchema), | ||
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, 'queue')).pipe(queueRouteConfigSchema) | ||
]); |
import { z } from 'zod'; | ||
export declare const queueSchema: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
data?: any; | ||
time?: number | undefined; | ||
}, z.ZodTypeDef, { | ||
data?: any; | ||
}, z.ZodTypeDef, { | ||
time?: number | undefined; | ||
data?: any; | ||
}>>, "many">; |
@@ -20,3 +20,3 @@ "use strict"; | ||
}), [ | ||
"data" | ||
'data' | ||
])); |
@@ -8,45 +8,42 @@ import { z } from 'zod'; | ||
method: z.ZodLiteral<RestMethod>; | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data: z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodAny]>; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
data?: any; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
file: z.ZodString; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
file: string; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
file: string; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
time?: number | undefined; | ||
data?: any; | ||
}, z.ZodTypeDef, { | ||
time?: number | undefined; | ||
data?: any; | ||
}>>, "many">; | ||
settings: z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodObject<z.objectUtil.extendShape<{ | ||
polling: z.ZodOptional<z.ZodBoolean>; | ||
status: z.ZodOptional<z.ZodNumber>; | ||
delay: z.ZodOptional<z.ZodNumber>; | ||
}, { | ||
polling: z.ZodLiteral<true>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
polling: true; | ||
@@ -60,8 +57,16 @@ status?: number | undefined; | ||
}>; | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
data?: any; | ||
time?: number | undefined; | ||
}, z.ZodTypeDef, { | ||
data?: any; | ||
time?: number | undefined; | ||
}>>, "many">; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -73,4 +78,4 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
@@ -83,4 +88,4 @@ queue: unknown[]; | ||
}; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>]>, "many">; | ||
@@ -91,14 +96,14 @@ interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
file: string; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -110,12 +115,12 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
})[]; | ||
path: (string | RegExp) & (string | RegExp | undefined); | ||
method: "get" | "post" | "delete" | "put" | "patch" | "options"; | ||
path: string | RegExp; | ||
method: RestMethod; | ||
interceptors?: any; | ||
}, { | ||
routes: unknown[]; | ||
path: (string | RegExp) & (string | RegExp | undefined); | ||
method: "get" | "post" | "delete" | "put" | "patch" | "options"; | ||
path: string | RegExp; | ||
method: RestMethod; | ||
interceptors?: unknown; | ||
@@ -125,45 +130,42 @@ }>, z.ZodObject<{ | ||
method: z.ZodLiteral<RestMethod>; | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data: z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodAny]>; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
data?: any; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
file: z.ZodString; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
file: string; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
file: string; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
time?: number | undefined; | ||
data?: any; | ||
}, z.ZodTypeDef, { | ||
time?: number | undefined; | ||
data?: any; | ||
}>>, "many">; | ||
settings: z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodObject<z.objectUtil.extendShape<{ | ||
polling: z.ZodOptional<z.ZodBoolean>; | ||
status: z.ZodOptional<z.ZodNumber>; | ||
delay: z.ZodOptional<z.ZodNumber>; | ||
}, { | ||
polling: z.ZodLiteral<true>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
polling: true; | ||
@@ -177,8 +179,16 @@ status?: number | undefined; | ||
}>; | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
data?: any; | ||
time?: number | undefined; | ||
}, z.ZodTypeDef, { | ||
data?: any; | ||
time?: number | undefined; | ||
}>>, "many">; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -190,4 +200,4 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
@@ -200,4 +210,4 @@ queue: unknown[]; | ||
}; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>]>, "many">; | ||
@@ -208,14 +218,14 @@ interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
file: string; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -227,12 +237,12 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
})[]; | ||
path: (string | RegExp) & (string | RegExp | undefined); | ||
method: "get" | "post" | "delete" | "put" | "patch" | "options"; | ||
path: string | RegExp; | ||
method: RestMethod; | ||
interceptors?: any; | ||
}, { | ||
routes: unknown[]; | ||
path: (string | RegExp) & (string | RegExp | undefined); | ||
method: "get" | "post" | "delete" | "put" | "patch" | "options"; | ||
path: string | RegExp; | ||
method: RestMethod; | ||
interceptors?: unknown; | ||
@@ -242,45 +252,42 @@ }>, z.ZodObject<{ | ||
method: z.ZodLiteral<RestMethod>; | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data: z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodAny]>; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
data?: any; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
file: z.ZodString; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
file: string; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
file: string; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
time?: number | undefined; | ||
data?: any; | ||
}, z.ZodTypeDef, { | ||
time?: number | undefined; | ||
data?: any; | ||
}>>, "many">; | ||
settings: z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodObject<z.objectUtil.extendShape<{ | ||
polling: z.ZodOptional<z.ZodBoolean>; | ||
status: z.ZodOptional<z.ZodNumber>; | ||
delay: z.ZodOptional<z.ZodNumber>; | ||
}, { | ||
polling: z.ZodLiteral<true>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
polling: true; | ||
@@ -294,8 +301,16 @@ status?: number | undefined; | ||
}>; | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
data?: any; | ||
time?: number | undefined; | ||
}, z.ZodTypeDef, { | ||
data?: any; | ||
time?: number | undefined; | ||
}>>, "many">; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -307,4 +322,4 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
@@ -317,4 +332,4 @@ queue: unknown[]; | ||
}; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>]>, "many">; | ||
@@ -325,14 +340,14 @@ interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
file: string; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -344,12 +359,12 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
})[]; | ||
path: (string | RegExp) & (string | RegExp | undefined); | ||
method: "get" | "post" | "delete" | "put" | "patch" | "options"; | ||
path: string | RegExp; | ||
method: RestMethod; | ||
interceptors?: any; | ||
}, { | ||
routes: unknown[]; | ||
path: (string | RegExp) & (string | RegExp | undefined); | ||
method: "get" | "post" | "delete" | "put" | "patch" | "options"; | ||
path: string | RegExp; | ||
method: RestMethod; | ||
interceptors?: unknown; | ||
@@ -359,45 +374,42 @@ }>, z.ZodObject<{ | ||
method: z.ZodLiteral<RestMethod>; | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data: z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodAny]>; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
data?: any; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
file: z.ZodString; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
file: string; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
file: string; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
time?: number | undefined; | ||
data?: any; | ||
}, z.ZodTypeDef, { | ||
time?: number | undefined; | ||
data?: any; | ||
}>>, "many">; | ||
settings: z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodObject<z.objectUtil.extendShape<{ | ||
polling: z.ZodOptional<z.ZodBoolean>; | ||
status: z.ZodOptional<z.ZodNumber>; | ||
delay: z.ZodOptional<z.ZodNumber>; | ||
}, { | ||
polling: z.ZodLiteral<true>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
polling: true; | ||
@@ -411,8 +423,16 @@ status?: number | undefined; | ||
}>; | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
data?: any; | ||
time?: number | undefined; | ||
}, z.ZodTypeDef, { | ||
data?: any; | ||
time?: number | undefined; | ||
}>>, "many">; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -424,4 +444,4 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
@@ -434,4 +454,4 @@ queue: unknown[]; | ||
}; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>]>, "many">; | ||
@@ -442,14 +462,14 @@ interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
file: string; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -461,12 +481,12 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
})[]; | ||
path: (string | RegExp) & (string | RegExp | undefined); | ||
method: "get" | "post" | "delete" | "put" | "patch" | "options"; | ||
path: string | RegExp; | ||
method: RestMethod; | ||
interceptors?: any; | ||
}, { | ||
routes: unknown[]; | ||
path: (string | RegExp) & (string | RegExp | undefined); | ||
method: "get" | "post" | "delete" | "put" | "patch" | "options"; | ||
path: string | RegExp; | ||
method: RestMethod; | ||
interceptors?: unknown; | ||
@@ -476,45 +496,42 @@ }>, z.ZodObject<{ | ||
method: z.ZodLiteral<RestMethod>; | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data: z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodAny]>; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
data?: any; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
file: z.ZodString; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
file: string; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
file: string; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
time?: number | undefined; | ||
data?: any; | ||
}, z.ZodTypeDef, { | ||
time?: number | undefined; | ||
data?: any; | ||
}>>, "many">; | ||
settings: z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodObject<z.objectUtil.extendShape<{ | ||
polling: z.ZodOptional<z.ZodBoolean>; | ||
status: z.ZodOptional<z.ZodNumber>; | ||
delay: z.ZodOptional<z.ZodNumber>; | ||
}, { | ||
polling: z.ZodLiteral<true>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
polling: true; | ||
@@ -528,8 +545,16 @@ status?: number | undefined; | ||
}>; | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
data?: any; | ||
time?: number | undefined; | ||
}, z.ZodTypeDef, { | ||
data?: any; | ||
time?: number | undefined; | ||
}>>, "many">; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -541,4 +566,4 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
@@ -551,4 +576,4 @@ queue: unknown[]; | ||
}; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>]>, "many">; | ||
@@ -559,14 +584,14 @@ interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
file: string; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -578,12 +603,12 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
})[]; | ||
path: (string | RegExp) & (string | RegExp | undefined); | ||
method: "get" | "post" | "delete" | "put" | "patch" | "options"; | ||
path: string | RegExp; | ||
method: RestMethod; | ||
interceptors?: any; | ||
}, { | ||
routes: unknown[]; | ||
path: (string | RegExp) & (string | RegExp | undefined); | ||
method: "get" | "post" | "delete" | "put" | "patch" | "options"; | ||
path: string | RegExp; | ||
method: RestMethod; | ||
interceptors?: unknown; | ||
@@ -593,45 +618,42 @@ }>, z.ZodObject<{ | ||
method: z.ZodLiteral<RestMethod>; | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
routes: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data: z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodAny]>; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
data?: any; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
file: z.ZodString; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
file: string; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
file: string; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
time?: number | undefined; | ||
data?: any; | ||
}, z.ZodTypeDef, { | ||
time?: number | undefined; | ||
data?: any; | ||
}>>, "many">; | ||
settings: z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodObject<z.objectUtil.extendShape<{ | ||
polling: z.ZodOptional<z.ZodBoolean>; | ||
status: z.ZodOptional<z.ZodNumber>; | ||
delay: z.ZodOptional<z.ZodNumber>; | ||
}, { | ||
polling: z.ZodLiteral<true>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
polling: true; | ||
@@ -645,8 +667,16 @@ status?: number | undefined; | ||
}>; | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
data?: any; | ||
time?: number | undefined; | ||
}, z.ZodTypeDef, { | ||
data?: any; | ||
time?: number | undefined; | ||
}>>, "many">; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -658,4 +688,4 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
@@ -668,4 +698,4 @@ queue: unknown[]; | ||
}; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>]>, "many">; | ||
@@ -676,14 +706,14 @@ interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
file: string; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -695,12 +725,12 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
})[]; | ||
path: (string | RegExp) & (string | RegExp | undefined); | ||
method: "get" | "post" | "delete" | "put" | "patch" | "options"; | ||
path: string | RegExp; | ||
method: RestMethod; | ||
interceptors?: any; | ||
}, { | ||
routes: unknown[]; | ||
path: (string | RegExp) & (string | RegExp | undefined); | ||
method: "get" | "post" | "delete" | "put" | "patch" | "options"; | ||
path: string | RegExp; | ||
method: RestMethod; | ||
interceptors?: unknown; | ||
@@ -713,14 +743,14 @@ }>]>, "many">; | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
file: string; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
} | { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -732,20 +762,20 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
})[]; | ||
path: (string | RegExp) & (string | RegExp | undefined); | ||
method: "get" | "post" | "delete" | "put" | "patch" | "options"; | ||
path: string | RegExp; | ||
method: RestMethod; | ||
interceptors?: any; | ||
}[]; | ||
interceptors?: any; | ||
baseUrl?: string | undefined; | ||
interceptors?: any; | ||
}, { | ||
configs: { | ||
routes: unknown[]; | ||
path: (string | RegExp) & (string | RegExp | undefined); | ||
method: "get" | "post" | "delete" | "put" | "patch" | "options"; | ||
path: string | RegExp; | ||
method: RestMethod; | ||
interceptors?: unknown; | ||
}[]; | ||
interceptors?: unknown; | ||
baseUrl?: string | undefined; | ||
interceptors?: unknown; | ||
}>; |
@@ -26,8 +26,8 @@ "use strict"; | ||
const requestConfigSchema = _zod.z.union([ | ||
baseRequestConfigSchema("get"), | ||
baseRequestConfigSchema("post"), | ||
baseRequestConfigSchema("put"), | ||
baseRequestConfigSchema("delete"), | ||
baseRequestConfigSchema("patch"), | ||
baseRequestConfigSchema("options") | ||
baseRequestConfigSchema('get'), | ||
baseRequestConfigSchema('post'), | ||
baseRequestConfigSchema('put'), | ||
baseRequestConfigSchema('delete'), | ||
baseRequestConfigSchema('patch'), | ||
baseRequestConfigSchema('options') | ||
]); | ||
@@ -34,0 +34,0 @@ const restConfigSchema = _zod.z.strictObject({ |
import { z } from 'zod'; | ||
import type { RestMethod } from '../../../../src/utils/types'; | ||
export declare const routeConfigSchema: (method: RestMethod) => z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
export declare const routeConfigSchema: (method: RestMethod) => z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
data: z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodAny]>; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
data?: any; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
data?: any; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
file: z.ZodString; | ||
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
file: string; | ||
interceptors?: any; | ||
entities?: any; | ||
settings?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
file: string; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
settings?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{ | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
time?: number | undefined; | ||
data?: any; | ||
}, z.ZodTypeDef, { | ||
time?: number | undefined; | ||
data?: any; | ||
}>>, "many">; | ||
settings: z.ZodObject<{ | ||
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{ | ||
settings: z.ZodObject<z.objectUtil.extendShape<{ | ||
polling: z.ZodOptional<z.ZodBoolean>; | ||
status: z.ZodOptional<z.ZodNumber>; | ||
delay: z.ZodOptional<z.ZodNumber>; | ||
}, { | ||
polling: z.ZodLiteral<true>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
polling: true; | ||
@@ -54,8 +51,16 @@ status?: number | undefined; | ||
}>; | ||
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{ | ||
data?: any; | ||
time?: number | undefined; | ||
}, z.ZodTypeDef, { | ||
data?: any; | ||
time?: number | undefined; | ||
}>>, "many">; | ||
}, { | ||
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>; | ||
}, "strict", z.ZodTypeAny, { | ||
}>, "strict", z.ZodTypeAny, { | ||
queue: { | ||
data?: any; | ||
time?: number | undefined; | ||
data?: any; | ||
}[]; | ||
@@ -67,4 +72,4 @@ settings: { | ||
}; | ||
interceptors?: any; | ||
entities?: any; | ||
interceptors?: any; | ||
}, { | ||
@@ -77,4 +82,4 @@ queue: unknown[]; | ||
}; | ||
interceptors?: unknown; | ||
entities?: unknown; | ||
interceptors?: unknown; | ||
}>>]>; |
@@ -19,5 +19,5 @@ "use strict"; | ||
const METHODS_WITH_BODY = [ | ||
"post", | ||
"put", | ||
"patch" | ||
'post', | ||
'put', | ||
'patch' | ||
]; | ||
@@ -38,5 +38,3 @@ const entitiesByEntityNameSchema = (method)=>{ | ||
entities: entitiesByEntityNameSchema(method).optional(), | ||
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema.pick({ | ||
response: true | ||
})).optional() | ||
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional() | ||
}); | ||
@@ -65,5 +63,5 @@ const dataRouteConfigSchema = (method)=>_zod.z.strictObject({ | ||
const routeConfigSchema = (method)=>_zod.z.union([ | ||
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, "data")).pipe(dataRouteConfigSchema(method)), | ||
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, "file")).pipe(fileRouteConfigSchema(method)), | ||
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, "queue")).pipe(queueRouteConfigSchema(method)) | ||
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, 'data')).pipe(dataRouteConfigSchema(method)), | ||
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, 'file')).pipe(fileRouteConfigSchema(method)), | ||
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, 'queue')).pipe(queueRouteConfigSchema(method)) | ||
]); |
@@ -7,7 +7,5 @@ import { z } from 'zod'; | ||
checkMode: "equals" | "notEquals"; | ||
value: ((string | number | boolean | { | ||
value: string | number | boolean | { | ||
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null; | ||
} | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[]) & (string | number | boolean | { | ||
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null; | ||
} | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | undefined)) | null; | ||
} | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null; | ||
} | { | ||
@@ -20,7 +18,5 @@ checkMode: "exists" | "notExists"; | ||
checkMode: "equals" | "notEquals"; | ||
value: ((string | number | boolean | { | ||
value: string | number | boolean | { | ||
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null; | ||
} | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[]) & (string | number | boolean | { | ||
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null; | ||
} | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | undefined)) | null; | ||
} | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null; | ||
} | { | ||
@@ -27,0 +23,0 @@ checkMode: "exists" | "notExists"; |
@@ -24,5 +24,5 @@ "use strict"; | ||
const _requiredPropertiesSchema = require("../requiredPropertiesSchema/requiredPropertiesSchema"); | ||
/* ----- Plain entity schema ----- */ const topLevelPlainEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion("checkMode", [ | ||
/* ----- Plain entity schema ----- */ const topLevelPlainEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion('checkMode', [ | ||
_zod.z.strictObject({ | ||
checkMode: _zod.z.literal("function"), | ||
checkMode: _zod.z.literal('function'), | ||
value: _zod.z.function() | ||
@@ -38,7 +38,7 @@ }), | ||
]), [ | ||
"checkMode" | ||
'checkMode' | ||
]); | ||
const propertyLevelPlainEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion("checkMode", [ | ||
const propertyLevelPlainEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion('checkMode', [ | ||
_zod.z.strictObject({ | ||
checkMode: _zod.z.literal("function"), | ||
checkMode: _zod.z.literal('function'), | ||
value: _zod.z.function() | ||
@@ -51,3 +51,3 @@ }), | ||
_zod.z.strictObject({ | ||
checkMode: _zod.z.literal("regExp"), | ||
checkMode: _zod.z.literal('regExp'), | ||
value: _zod.z.union([ | ||
@@ -69,3 +69,3 @@ _zod.z.instanceof(RegExp), | ||
]), [ | ||
"checkMode" | ||
'checkMode' | ||
]); | ||
@@ -99,9 +99,9 @@ const nonCheckModeRecordSchema = (recordSchema)=>(0, _plainObjectSchema.plainObjectSchema)(recordSchema.and(_zod.z.object({ | ||
]); | ||
const mappedEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion("checkMode", [ | ||
const mappedEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion('checkMode', [ | ||
_zod.z.strictObject({ | ||
checkMode: _zod.z.literal("function"), | ||
checkMode: _zod.z.literal('function'), | ||
value: _zod.z.function() | ||
}), | ||
_zod.z.strictObject({ | ||
checkMode: _zod.z.literal("regExp"), | ||
checkMode: _zod.z.literal('regExp'), | ||
value: _zod.z.union([ | ||
@@ -123,3 +123,3 @@ _zod.z.instanceof(RegExp), | ||
]), [ | ||
"checkMode" | ||
'checkMode' | ||
]); | ||
@@ -126,0 +126,0 @@ const mappedEntitySchema = (0, _plainObjectSchema.plainObjectSchema)(_zod.z.record(_zod.z.union([ |
import { z } from 'zod'; | ||
import type { PlainObject } from '../../../../src/utils/types'; | ||
export declare const requiredPropertiesSchema: <T extends PlainObject>(schema: z.ZodType<T, z.ZodTypeDef, T>, requiredProperties: (keyof T)[]) => z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<T, z.ZodTypeDef, T>>; | ||
export declare const requiredPropertiesSchema: <T extends PlainObject>(schema: z.ZodType<T>, requiredProperties: (keyof T)[]) => z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<T, z.ZodTypeDef, T>>; |
@@ -20,3 +20,3 @@ "use strict"; | ||
const _zod = require("zod"); | ||
const stringForwardSlashSchema = _zod.z.string().startsWith("/"); | ||
const stringJsonFilenameSchema = _zod.z.string().endsWith(".json"); | ||
const stringForwardSlashSchema = _zod.z.string().startsWith('/'); | ||
const stringJsonFilenameSchema = _zod.z.string().endsWith('.json'); |
@@ -24,3 +24,3 @@ "use strict"; | ||
if (!mockServerConfig.configs && !mockServerConfig.database && !mockServerConfig.staticPath) { | ||
throw new Error("Configuration should contain at least one of these configs: configs | database | staticPath; see our doc (https://github.com/siberiacancode/mock-config-server) for more information"); | ||
throw new Error('Configuration should contain at least one of these configs: configs | database | staticPath; see our doc (https://github.com/siberiacancode/mock-config-server) for more information'); | ||
} | ||
@@ -35,6 +35,6 @@ const isConfigsContainAtLeastOneElement = Array.isArray(mockServerConfig.configs) && !!mockServerConfig.configs.length; | ||
database: _databaseConfigSchema.databaseConfigSchema.optional(), | ||
...isConfigsContainAtLeastOneElement && api === "graphql" && { | ||
...isConfigsContainAtLeastOneElement && api === 'graphql' && { | ||
configs: _graphqlConfigSchema.graphqlConfigSchema.shape.configs | ||
}, | ||
...isConfigsContainAtLeastOneElement && api === "rest" && { | ||
...isConfigsContainAtLeastOneElement && api === 'rest' && { | ||
configs: _restConfigSchema.restConfigSchema.shape.configs | ||
@@ -41,0 +41,0 @@ } |
@@ -24,3 +24,3 @@ "use strict"; | ||
if (!mockServerConfig.rest && !mockServerConfig.graphql && !mockServerConfig.database && !mockServerConfig.staticPath) { | ||
throw new Error("Configuration should contain at least one of these configs: rest | graphql | database | staticPath; see our doc (https://github.com/siberiacancode/mock-config-server) for more information"); | ||
throw new Error('Configuration should contain at least one of these configs: rest | graphql | database | staticPath; see our doc (https://github.com/siberiacancode/mock-config-server) for more information'); | ||
} | ||
@@ -27,0 +27,0 @@ const mockServerConfigSchema = _zod.z.strictObject({ |
@@ -13,3 +13,3 @@ "use strict"; | ||
const _storages = require("./storages"); | ||
const isVariableJsonFile = (variable)=>typeof variable === "string" && variable.endsWith(".json"); | ||
const isVariableJsonFile = (variable)=>typeof variable === 'string' && variable.endsWith('.json'); | ||
const createDatabaseRoutes = (router, { data, routes })=>{ | ||
@@ -19,3 +19,3 @@ if (routes) { | ||
(0, _helpers.createRewrittenDatabaseRoutes)(router, storage.read()); | ||
router.route("/__routes").get((_request, response)=>{ | ||
router.route('/__routes').get((_request, response)=>{ | ||
response.json(storage.read()); | ||
@@ -28,3 +28,3 @@ }); | ||
(0, _helpers.createNestedDatabaseRoutes)(router, nestedDatabase, storage); | ||
router.route("/__db").get((_request, response)=>{ | ||
router.route('/__db').get((_request, response)=>{ | ||
response.json(storage.read()); | ||
@@ -31,0 +31,0 @@ }); |
@@ -14,3 +14,3 @@ "use strict"; | ||
for(let i = 0; i < array.length; i += 1){ | ||
if (typeof array[i].id === "number" && array[i].id > maxId) { | ||
if (typeof array[i].id === 'number' && array[i].id > maxId) { | ||
maxId = array[i].id; | ||
@@ -17,0 +17,0 @@ } |
@@ -26,3 +26,3 @@ "use strict"; | ||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control | ||
response.set("Cache-control", "max-age=0, must-revalidate"); | ||
response.set('Cache-control', 'max-age=0, must-revalidate'); | ||
return response.json(data); | ||
@@ -37,2 +37,12 @@ } | ||
} | ||
if (_sort1) { | ||
data = (0, _sort.sort)(data, request.query); | ||
} | ||
if (_begin || _end) { | ||
var _request_query__begin; | ||
data = data.slice((_request_query__begin = request.query._begin) !== null && _request_query__begin !== void 0 ? _request_query__begin : 0, request.query._end); | ||
response.set('X-Total-Count', data.length); | ||
} | ||
// ✅ important: | ||
// The pagination should be last because it changes the form of the response | ||
if (_page) { | ||
@@ -42,3 +52,3 @@ data = (0, _pagination.pagination)(data, request.query); | ||
const links = {}; | ||
const fullUrl = `${request.protocol}://${request.get("host")}${request.originalUrl}`; | ||
const fullUrl = `${request.protocol}://${request.get('host')}${request.originalUrl}`; | ||
if (data._link.first) { | ||
@@ -63,14 +73,6 @@ links.first = fullUrl.replace(`page=${data._link.current}`, `page=${data._link.first}`); | ||
} | ||
if (_sort1) { | ||
data = (0, _sort.sort)(data, request.query); | ||
} | ||
if (_begin || _end) { | ||
var _request_query__begin; | ||
data = data.slice((_request_query__begin = request.query._begin) !== null && _request_query__begin !== void 0 ? _request_query__begin : 0, request.query._end); | ||
response.set("X-Total-Count", data.length); | ||
} | ||
// ✅ important: | ||
// set 'Cache-Control' header for explicit browsers response revalidate | ||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control | ||
response.set("Cache-control", "no-cache"); | ||
response.set('Cache-control', 'no-cache'); | ||
response.json(data); | ||
@@ -89,3 +91,3 @@ }); | ||
], newResource); | ||
response.set("Location", `${request.url}/${newResourceId}`); | ||
response.set('Location', `${request.url}/${newResourceId}`); | ||
response.status(201).json(newResource); | ||
@@ -103,3 +105,3 @@ }); | ||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control | ||
response.set("Cache-control", "no-cache"); | ||
response.set('Cache-control', 'no-cache'); | ||
response.json(storage.read([ | ||
@@ -106,0 +108,0 @@ key, |
@@ -24,6 +24,6 @@ "use strict"; | ||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control | ||
response.set("Cache-control", "no-cache"); | ||
response.set('Cache-control', 'no-cache'); | ||
return response.json(data); | ||
} | ||
data = data.filter((element)=>typeof element === "object" && element !== null); | ||
data = data.filter((element)=>typeof element === 'object' && element !== null); | ||
const { _page, _limit, _begin, _end, _sort: _sort1, _order, _q, ...filters } = request.query; | ||
@@ -36,2 +36,12 @@ if (Object.keys(filters).length) { | ||
} | ||
if (_sort1) { | ||
data = (0, _sort.sort)(data, request.query); | ||
} | ||
if (_begin || _end) { | ||
var _request_query__begin; | ||
data = data.slice((_request_query__begin = request.query._begin) !== null && _request_query__begin !== void 0 ? _request_query__begin : 0, request.query._end); | ||
response.set('X-Total-Count', data.length); | ||
} | ||
// ✅ important: | ||
// The pagination should be last because it changes the form of the response | ||
if (_page) { | ||
@@ -41,3 +51,3 @@ data = (0, _pagination.pagination)(data, request.query); | ||
const links = {}; | ||
const fullUrl = `${request.protocol}://${request.get("host")}${request.originalUrl}`; | ||
const fullUrl = `${request.protocol}://${request.get('host')}${request.originalUrl}`; | ||
if (data._link.first) { | ||
@@ -62,14 +72,6 @@ links.first = fullUrl.replace(`page=${data._link.current}`, `page=${data._link.first}`); | ||
} | ||
if (_sort1) { | ||
data = (0, _sort.sort)(data, request.query); | ||
} | ||
if (_begin || _end) { | ||
var _request_query__begin; | ||
data = data.slice((_request_query__begin = request.query._begin) !== null && _request_query__begin !== void 0 ? _request_query__begin : 0, request.query._end); | ||
response.set("X-Total-Count", data.length); | ||
} | ||
// ✅ important: | ||
// set 'Cache-Control' header for explicit browsers response revalidate | ||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control | ||
response.set("Cache-control", "no-cache"); | ||
response.set('Cache-control', 'no-cache'); | ||
response.json(data); | ||
@@ -79,3 +81,3 @@ }); | ||
storage.write(key, request.body); | ||
response.set("Location", request.url); | ||
response.set('Location', request.url); | ||
response.status(201).json(request.body); | ||
@@ -82,0 +84,0 @@ }); |
@@ -13,2 +13,3 @@ "use strict"; | ||
const OPERATORS = { | ||
eq: (a, b)=>`${a}` === `${b}`, | ||
neq: (a, b)=>`${a}` !== `${b}`, | ||
@@ -24,23 +25,28 @@ gt: (a, b)=>+a > +b, | ||
ew: (a, b)=>a.endsWith(b), | ||
new: (a, b)=>!a.endsWith(b) | ||
new: (a, b)=>!a.endsWith(b), | ||
some: (a, b)=>a.some((element)=>`${element}` === `${b}`) | ||
}; | ||
const OPERATORS_KEYS = Object.keys(OPERATORS); | ||
const OPERATOR_REGEXP = new RegExp(`^(.+)_(${OPERATORS_KEYS.join("|")})$`); | ||
const OPERATOR_REGEXP = new RegExp(`^(.+)_(${OPERATORS_KEYS.join('|')})$`); | ||
const getEntities = (object, key)=>{ | ||
const parts = key.match(OPERATOR_REGEXP); | ||
if (parts) { | ||
const [, element, operator] = parts; | ||
if (!parts) { | ||
return { | ||
element: object[element], | ||
operator: operator | ||
operator: 'eq', | ||
element: object[key] | ||
}; | ||
} | ||
const [, element, operator] = parts; | ||
if (operator === 'some') { | ||
const array = Object.entries(object).filter(([objectKey])=>new RegExp(`^${element}.\\d$`).test(objectKey)); | ||
return { | ||
operator, | ||
element: array.map(([, value])=>value) | ||
}; | ||
} | ||
return { | ||
element: object[key] | ||
element: object[element], | ||
operator: operator | ||
}; | ||
}; | ||
const filtered = (element, value, operator)=>{ | ||
if (!operator) return `${element}` === value; | ||
return OPERATORS[operator](element, value); | ||
}; | ||
const filter = (array, filters)=>array.filter((arrayElement)=>{ | ||
@@ -51,7 +57,7 @@ const flattenedArrayElement = (0, _flat.flatten)(arrayElement); | ||
const { element, operator } = getEntities(flattenedArrayElement, key); | ||
return filter.some((value)=>filtered(element, value, operator)); | ||
return filter.some((value)=>OPERATORS[operator](element, value)); | ||
} | ||
const { element, operator } = getEntities(flattenedArrayElement, key); | ||
return filtered(element, filter, operator); | ||
return OPERATORS[operator](element, filter); | ||
}); | ||
}); |
@@ -21,3 +21,3 @@ "use strict"; | ||
for(const key in obj){ | ||
if (typeof obj[key] === "object" && obj[key] !== null) { | ||
if (typeof obj[key] === 'object' && obj[key] !== null) { | ||
if (searchInNestedObjects(obj[key], searchText)) { | ||
@@ -33,3 +33,3 @@ return true; | ||
const search = (array, searchText)=>array.filter((element)=>{ | ||
if (typeof searchText === "string") { | ||
if (typeof searchText === 'string') { | ||
return searchInNestedObjects(element, searchText); | ||
@@ -40,3 +40,3 @@ } | ||
} | ||
throw new Error("search technical error"); | ||
throw new Error('search technical error'); | ||
}); |
@@ -12,5 +12,5 @@ "use strict"; | ||
const _flat = require("flat"); | ||
const DEFAULT_ORDER = "asc"; | ||
const DEFAULT_ORDER = 'asc'; | ||
const getOrder = (order)=>{ | ||
if (order === "asc" || order === "desc") return order; | ||
if (order === 'asc' || order === 'desc') return order; | ||
return DEFAULT_ORDER; | ||
@@ -22,6 +22,6 @@ }; | ||
if (!flattenedA[key] || !flattenedB[key]) return 0; | ||
if (typeof flattenedA[key] === "string" && typeof flattenedB[key] === "string") { | ||
return order === "asc" ? flattenedA[key].localeCompare(flattenedB[key]) : flattenedB[key].localeCompare(flattenedA[key]); | ||
if (typeof flattenedA[key] === 'string' && typeof flattenedB[key] === 'string') { | ||
return order === 'asc' ? flattenedA[key].localeCompare(flattenedB[key]) : flattenedB[key].localeCompare(flattenedA[key]); | ||
} | ||
return order === "asc" ? Number(flattenedA[key]) - Number(flattenedB[key]) : Number(flattenedB[key]) - Number(flattenedA[key]); | ||
return order === 'asc' ? Number(flattenedA[key]) - Number(flattenedB[key]) : Number(flattenedB[key]) - Number(flattenedA[key]); | ||
}); | ||
@@ -28,0 +28,0 @@ const sort = (array, queries)=>{ |
@@ -12,3 +12,3 @@ "use strict"; | ||
const _helpers = require("../../../../../utils/helpers"); | ||
const isAllArrayElementsHaveValidTypeId = (array)=>array.every((element)=>(0, _helpers.isPlainObject)(element) && (typeof element.id === "number" || typeof element.id === "string")); | ||
const isAllArrayElementsHaveValidTypeId = (array)=>array.every((element)=>(0, _helpers.isPlainObject)(element) && (typeof element.id === 'number' || typeof element.id === 'string')); | ||
const isAllArrayElementsHaveUniqueId = (array)=>{ | ||
@@ -15,0 +15,0 @@ const uniqueIdsCount = new Set(array.map(({ id })=>id)).size; |
@@ -27,3 +27,3 @@ "use strict"; | ||
this.fileWriter = new _FileWriter.FileWriter(filePath); | ||
this.data = JSON.parse(_fs.default.readFileSync(filePath, "utf-8")); | ||
this.data = JSON.parse(_fs.default.readFileSync(filePath, 'utf-8')); | ||
} | ||
@@ -30,0 +30,0 @@ read(key) { |
@@ -41,3 +41,3 @@ "use strict"; | ||
this.writeIsLocked = true; | ||
await _fs.default.promises.writeFile(this.filePath, data, "utf-8"); | ||
await _fs.default.promises.writeFile(this.filePath, data, 'utf-8'); | ||
this.writeIsLocked = false; | ||
@@ -44,0 +44,0 @@ // ✅ important: |
@@ -17,7 +17,7 @@ "use strict"; | ||
const graphqlMiddleware = async (request, response, next)=>{ | ||
var _matchedRequestConfig_interceptors, _matchedRouteConfig_settings, _matchedRouteConfig_settings1, _matchedRouteConfig_interceptors, _matchedRequestConfig_interceptors1, _graphqlConfig_interceptors, _matchedRouteConfig_settings2; | ||
var _matchedRequestConfig_interceptors, _matchedRouteConfig_interceptors, _matchedRouteConfig_settings, _matchedRouteConfig_settings1, _matchedRouteConfig_interceptors1, _matchedRequestConfig_interceptors1, _graphqlConfig_interceptors, _matchedRouteConfig_settings2; | ||
const graphQLInput = (0, _helpers.getGraphQLInput)(request); | ||
if (!graphQLInput.query) { | ||
return response.status(400).json({ | ||
message: "Query is missing, you must pass a valid GraphQL query" | ||
message: 'Query is missing, you must pass a valid GraphQL query' | ||
}); | ||
@@ -28,3 +28,3 @@ } | ||
return response.status(400).json({ | ||
message: "Query is invalid, you must use a valid GraphQL query" | ||
message: 'Query is invalid, you must use a valid GraphQL query' | ||
}); | ||
@@ -35,4 +35,4 @@ } | ||
if (requestConfig.operationType !== query.operationType) return false; | ||
if ("query" in requestConfig && requestConfig.query.replace(/\s+/gi, " ") !== ((_graphQLInput_query = graphQLInput.query) === null || _graphQLInput_query === void 0 ? void 0 : _graphQLInput_query.replace(/\s+/gi, " "))) return false; | ||
if ("operationName" in requestConfig) { | ||
if ('query' in requestConfig && requestConfig.query.replace(/\s+/gi, ' ') !== ((_graphQLInput_query = graphQLInput.query) === null || _graphQLInput_query === void 0 ? void 0 : _graphQLInput_query.replace(/\s+/gi, ' '))) return false; | ||
if ('operationName' in requestConfig) { | ||
if (!query.operationName) return false; | ||
@@ -47,7 +47,6 @@ if (requestConfig.operationName instanceof RegExp) return new RegExp(requestConfig.operationName).test(query.operationName); | ||
} | ||
const requestInterceptor = (_matchedRequestConfig_interceptors = matchedRequestConfig.interceptors) === null || _matchedRequestConfig_interceptors === void 0 ? void 0 : _matchedRequestConfig_interceptors.request; | ||
if (requestInterceptor) { | ||
if ((_matchedRequestConfig_interceptors = matchedRequestConfig.interceptors) === null || _matchedRequestConfig_interceptors === void 0 ? void 0 : _matchedRequestConfig_interceptors.request) { | ||
await (0, _helpers.callRequestInterceptor)({ | ||
request, | ||
interceptor: requestInterceptor | ||
interceptor: matchedRequestConfig.interceptors.request | ||
}); | ||
@@ -61,7 +60,7 @@ } | ||
// ✅ important: check whole variables as plain value strictly if descriptor used for variables | ||
const isEntityVariablesByTopLevelDescriptor = entityName === "variables" && (0, _helpers.isEntityDescriptor)(entityDescriptorOrValue); | ||
const isEntityVariablesByTopLevelDescriptor = entityName === 'variables' && (0, _helpers.isEntityDescriptor)(entityDescriptorOrValue); | ||
if (isEntityVariablesByTopLevelDescriptor) { | ||
return (0, _helpers.resolveEntityValues)(checkMode, graphQLInput.variables, entityDescriptorValue); | ||
} | ||
const isEntityVariablesByTopLevelArray = entityName === "variables" && Array.isArray(entityDescriptorOrValue); | ||
const isEntityVariablesByTopLevelArray = entityName === 'variables' && Array.isArray(entityDescriptorOrValue); | ||
if (isEntityVariablesByTopLevelArray) { | ||
@@ -73,5 +72,5 @@ return entityDescriptorOrValue.some((entityDescriptorOrValueElement)=>(0, _helpers.resolveEntityValues)(checkMode, graphQLInput.variables, entityDescriptorOrValueElement)); | ||
const { checkMode, value: descriptorValue } = (0, _helpers.convertToEntityDescriptor)(entityValue); | ||
const flattenEntity = (0, _flat.flatten)(entityName === "variables" ? graphQLInput.variables : request[entityName]); | ||
const flattenEntity = (0, _flat.flatten)(entityName === 'variables' ? graphQLInput.variables : request[entityName]); | ||
// ✅ important: transform header keys to lower case because browsers send headers in lowercase | ||
return (0, _helpers.resolveEntityValues)(checkMode, flattenEntity[entityName === "headers" ? entityKey.toLowerCase() : entityKey], descriptorValue); | ||
return (0, _helpers.resolveEntityValues)(checkMode, flattenEntity[entityName === 'headers' ? entityKey.toLowerCase() : entityKey], descriptorValue); | ||
}); | ||
@@ -83,4 +82,10 @@ }); | ||
} | ||
if ((_matchedRouteConfig_interceptors = matchedRouteConfig.interceptors) === null || _matchedRouteConfig_interceptors === void 0 ? void 0 : _matchedRouteConfig_interceptors.request) { | ||
await (0, _helpers.callRequestInterceptor)({ | ||
request, | ||
interceptor: matchedRouteConfig.interceptors.request | ||
}); | ||
} | ||
let matchedRouteConfigData = null; | ||
if (((_matchedRouteConfig_settings = matchedRouteConfig.settings) === null || _matchedRouteConfig_settings === void 0 ? void 0 : _matchedRouteConfig_settings.polling) && "queue" in matchedRouteConfig) { | ||
if (((_matchedRouteConfig_settings = matchedRouteConfig.settings) === null || _matchedRouteConfig_settings === void 0 ? void 0 : _matchedRouteConfig_settings.polling) && 'queue' in matchedRouteConfig) { | ||
if (!matchedRouteConfig.queue.length) return next(); | ||
@@ -111,7 +116,7 @@ const shallowMatchedRouteConfig = matchedRouteConfig; | ||
} | ||
if ("data" in matchedRouteConfig) { | ||
if ('data' in matchedRouteConfig) { | ||
matchedRouteConfigData = matchedRouteConfig.data; | ||
} | ||
var _matchedRouteConfig_entities; | ||
const resolvedData = typeof matchedRouteConfigData === "function" ? await matchedRouteConfigData(request, (_matchedRouteConfig_entities = matchedRouteConfig.entities) !== null && _matchedRouteConfig_entities !== void 0 ? _matchedRouteConfig_entities : {}) : matchedRouteConfigData; | ||
const resolvedData = typeof matchedRouteConfigData === 'function' ? await matchedRouteConfigData(request, (_matchedRouteConfig_entities = matchedRouteConfig.entities) !== null && _matchedRouteConfig_entities !== void 0 ? _matchedRouteConfig_entities : {}) : matchedRouteConfigData; | ||
if ((_matchedRouteConfig_settings1 = matchedRouteConfig.settings) === null || _matchedRouteConfig_settings1 === void 0 ? void 0 : _matchedRouteConfig_settings1.status) { | ||
@@ -123,3 +128,3 @@ response.statusCode = matchedRouteConfig.settings.status; | ||
// this code should place before response interceptors for giving opportunity to rewrite 'Cache-Control' header | ||
if (matchedRequestConfig.operationType === "query") response.set("Cache-control", "no-cache"); | ||
if (matchedRequestConfig.operationType === 'query') response.set('Cache-control', 'no-cache'); | ||
const data = await (0, _helpers.callResponseInterceptors)({ | ||
@@ -130,3 +135,3 @@ data: resolvedData, | ||
interceptors: { | ||
routeInterceptor: (_matchedRouteConfig_interceptors = matchedRouteConfig.interceptors) === null || _matchedRouteConfig_interceptors === void 0 ? void 0 : _matchedRouteConfig_interceptors.response, | ||
routeInterceptor: (_matchedRouteConfig_interceptors1 = matchedRouteConfig.interceptors) === null || _matchedRouteConfig_interceptors1 === void 0 ? void 0 : _matchedRouteConfig_interceptors1.response, | ||
requestInterceptor: (_matchedRequestConfig_interceptors1 = matchedRequestConfig.interceptors) === null || _matchedRequestConfig_interceptors1 === void 0 ? void 0 : _matchedRequestConfig_interceptors1.response, | ||
@@ -142,5 +147,5 @@ apiInterceptor: (_graphqlConfig_interceptors = graphqlConfig.interceptors) === null || _graphqlConfig_interceptors === void 0 ? void 0 : _graphqlConfig_interceptors.response, | ||
}; | ||
router.route("/").get((0, _helpers.asyncHandler)(graphqlMiddleware)); | ||
router.route("/").post((0, _helpers.asyncHandler)(graphqlMiddleware)); | ||
router.route('/').get((0, _helpers.asyncHandler)(graphqlMiddleware)); | ||
router.route('/').post((0, _helpers.asyncHandler)(graphqlMiddleware)); | ||
return router; | ||
}; |
@@ -24,3 +24,3 @@ "use strict"; | ||
// check that actual value check modes does not have `value` for compare | ||
if (variables.checkMode === "exists" || variables.checkMode === "notExists") { | ||
if (variables.checkMode === 'exists' || variables.checkMode === 'notExists') { | ||
routeConfigWeight += 1; | ||
@@ -27,0 +27,0 @@ return routeConfigWeight; |
@@ -14,10 +14,10 @@ "use strict"; | ||
const cookies = {}; | ||
const cookiePairs = cookieHeader.split(";"); | ||
const cookiePairs = cookieHeader.split(';'); | ||
cookiePairs.forEach((cookie)=>{ | ||
const [name, value] = cookie.trim().split("="); | ||
const [name, value] = cookie.trim().split('='); | ||
if (!name) return; | ||
var _value_trim; | ||
cookies[name.trim()] = (_value_trim = value === null || value === void 0 ? void 0 : value.trim()) !== null && _value_trim !== void 0 ? _value_trim : ""; | ||
cookies[name.trim()] = (_value_trim = value === null || value === void 0 ? void 0 : value.trim()) !== null && _value_trim !== void 0 ? _value_trim : ''; | ||
}); | ||
return cookies; | ||
}; |
@@ -20,3 +20,3 @@ "use strict"; | ||
let allowedOrigins = []; | ||
if (typeof cors.origin === "function") { | ||
if (typeof cors.origin === 'function') { | ||
const origins = await cors.origin(request); | ||
@@ -38,14 +38,14 @@ allowedOrigins = (0, _helpers1.getAllowedOrigins)(origins); | ||
if (isRequestOriginAllowed) { | ||
response.setHeader("Access-Control-Allow-Origin", origin); | ||
response.setHeader('Access-Control-Allow-Origin', origin); | ||
var _cors_credentials; | ||
response.setHeader("Access-Control-Allow-Credentials", `${(_cors_credentials = cors.credentials) !== null && _cors_credentials !== void 0 ? _cors_credentials : _constants.DEFAULT.CORS.CREDENTIALS}`); | ||
response.setHeader('Access-Control-Allow-Credentials', `${(_cors_credentials = cors.credentials) !== null && _cors_credentials !== void 0 ? _cors_credentials : _constants.DEFAULT.CORS.CREDENTIALS}`); | ||
var _cors_exposedHeaders; | ||
response.setHeader("Access-Control-Expose-Headers", (_cors_exposedHeaders = cors.exposedHeaders) !== null && _cors_exposedHeaders !== void 0 ? _cors_exposedHeaders : _constants.DEFAULT.CORS.EXPOSED_HEADERS); | ||
if (request.method === "OPTIONS") { | ||
response.setHeader('Access-Control-Expose-Headers', (_cors_exposedHeaders = cors.exposedHeaders) !== null && _cors_exposedHeaders !== void 0 ? _cors_exposedHeaders : _constants.DEFAULT.CORS.EXPOSED_HEADERS); | ||
if (request.method === 'OPTIONS') { | ||
var _cors_methods; | ||
response.setHeader("Access-Control-Allow-Methods", (_cors_methods = cors.methods) !== null && _cors_methods !== void 0 ? _cors_methods : _constants.DEFAULT.CORS.METHODS); | ||
response.setHeader('Access-Control-Allow-Methods', (_cors_methods = cors.methods) !== null && _cors_methods !== void 0 ? _cors_methods : _constants.DEFAULT.CORS.METHODS); | ||
var _cors_allowedHeaders; | ||
response.setHeader("Access-Control-Allow-Headers", (_cors_allowedHeaders = cors.allowedHeaders) !== null && _cors_allowedHeaders !== void 0 ? _cors_allowedHeaders : _constants.DEFAULT.CORS.ALLOWED_HEADERS); | ||
response.setHeader('Access-Control-Allow-Headers', (_cors_allowedHeaders = cors.allowedHeaders) !== null && _cors_allowedHeaders !== void 0 ? _cors_allowedHeaders : _constants.DEFAULT.CORS.ALLOWED_HEADERS); | ||
var _cors_maxAge; | ||
response.setHeader("Access-Control-Max-Age", (_cors_maxAge = cors.maxAge) !== null && _cors_maxAge !== void 0 ? _cors_maxAge : _constants.DEFAULT.CORS.MAX_AGE); | ||
response.setHeader('Access-Control-Max-Age', (_cors_maxAge = cors.maxAge) !== null && _cors_maxAge !== void 0 ? _cors_maxAge : _constants.DEFAULT.CORS.MAX_AGE); | ||
response.sendStatus(204); | ||
@@ -52,0 +52,0 @@ return response.end(); |
@@ -15,3 +15,3 @@ "use strict"; | ||
} | ||
if (typeof origin === "string" || origin instanceof RegExp) { | ||
if (typeof origin === 'string' || origin instanceof RegExp) { | ||
return [ | ||
@@ -21,3 +21,3 @@ origin | ||
} | ||
throw new Error("Invalid cors origin format"); | ||
throw new Error('Invalid cors origin format'); | ||
}; |
@@ -14,6 +14,6 @@ "use strict"; | ||
const connections = {}; | ||
serverWithDestroyer.on("connection", (connection)=>{ | ||
serverWithDestroyer.on('connection', (connection)=>{ | ||
const key = `${connection.remoteAddress}:${connection.remotePort}`; | ||
connections[key] = connection; | ||
connection.on("close", ()=>{ | ||
connection.on('close', ()=>{ | ||
delete connections[key]; | ||
@@ -20,0 +20,0 @@ }); |
@@ -21,3 +21,3 @@ "use strict"; | ||
var _error_message; | ||
const message = `Message: ${(_error_message = error.message) !== null && _error_message !== void 0 ? _error_message : "Internal server error"}\n\n${error.stack}`; | ||
const message = `Message: ${(_error_message = error.message) !== null && _error_message !== void 0 ? _error_message : 'Internal server error'}\n\n${error.stack}`; | ||
response.status(error.status || 500).send(message); | ||
@@ -24,0 +24,0 @@ // ✅ important: |
@@ -14,10 +14,10 @@ "use strict"; | ||
server.use((request, response, next)=>{ | ||
response.setHeader("Access-Control-Allow-Origin", _constants.DEFAULT.CORS.ORIGIN); | ||
response.setHeader("Access-Control-Allow-Credentials", `${_constants.DEFAULT.CORS.CREDENTIALS}`); | ||
response.setHeader("Access-Control-Expose-Headers", _constants.DEFAULT.CORS.EXPOSED_HEADERS); | ||
const isPreflightRequest = request.method === "OPTIONS" && request.headers.origin && request.headers["access-control-request-method"] && request.headers["access-control-request-headers"]; | ||
response.setHeader('Access-Control-Allow-Origin', _constants.DEFAULT.CORS.ORIGIN); | ||
response.setHeader('Access-Control-Allow-Credentials', `${_constants.DEFAULT.CORS.CREDENTIALS}`); | ||
response.setHeader('Access-Control-Expose-Headers', _constants.DEFAULT.CORS.EXPOSED_HEADERS); | ||
const isPreflightRequest = request.method === 'OPTIONS' && request.headers.origin && request.headers['access-control-request-method'] && request.headers['access-control-request-headers']; | ||
if (isPreflightRequest) { | ||
response.setHeader("Access-Control-Allow-Methods", _constants.DEFAULT.CORS.METHODS); | ||
response.setHeader("Access-Control-Allow-Headers", _constants.DEFAULT.CORS.ALLOWED_HEADERS); | ||
response.setHeader("Access-Control-Max-Age", _constants.DEFAULT.CORS.MAX_AGE); | ||
response.setHeader('Access-Control-Allow-Methods', _constants.DEFAULT.CORS.METHODS); | ||
response.setHeader('Access-Control-Allow-Headers', _constants.DEFAULT.CORS.ALLOWED_HEADERS); | ||
response.setHeader('Access-Control-Max-Age', _constants.DEFAULT.CORS.MAX_AGE); | ||
response.sendStatus(204); | ||
@@ -24,0 +24,0 @@ return response.end(); |
@@ -15,3 +15,3 @@ "use strict"; | ||
// ✅ important: operationName is always second word in 'query' query param | ||
const actualOperationName = (_url_searchParams_get = url.searchParams.get("query")) === null || _url_searchParams_get === void 0 ? void 0 : _url_searchParams_get.split(" ")[1]; | ||
const actualOperationName = (_url_searchParams_get = url.searchParams.get('query')) === null || _url_searchParams_get === void 0 ? void 0 : _url_searchParams_get.split(' ')[1]; | ||
const actualUrlMeaningful = `${url.pathname}/${actualOperationName}`; | ||
@@ -18,0 +18,0 @@ const graphqlUrlSuggestions = requestConfigs.reduce((acc, requestConfig)=>{ |
@@ -27,5 +27,5 @@ "use strict"; | ||
const urlSuggestion = patternUrlParts.map((_patternUrlPart, index)=>{ | ||
if (patternUrlParts[index].startsWith(":")) return actualUrlParts[index]; | ||
if (patternUrlParts[index].startsWith(':')) return actualUrlParts[index]; | ||
return patternUrlParts[index]; | ||
}).join("/"); | ||
}).join('/'); | ||
const suggestionWithQueryParams = `/${urlSuggestion}${url.search}`; | ||
@@ -32,0 +32,0 @@ acc.push({ |
@@ -11,2 +11,2 @@ "use strict"; | ||
}); | ||
const getActualRestUrlMeaningfulString = (actualUrlParts, patternUrlParts)=>actualUrlParts.filter((_actualUrlPart, index)=>!patternUrlParts[index].startsWith(":")).join(""); | ||
const getActualRestUrlMeaningfulString = (actualUrlParts, patternUrlParts)=>actualUrlParts.filter((_actualUrlPart, index)=>!patternUrlParts[index].startsWith(':')).join(''); |
@@ -11,2 +11,2 @@ "use strict"; | ||
}); | ||
const getPatternRestUrlMeaningfulString = (patternUrlParts)=>patternUrlParts.filter((urlPatternPart)=>!urlPatternPart.startsWith(":")).join(""); | ||
const getPatternRestUrlMeaningfulString = (patternUrlParts)=>patternUrlParts.filter((urlPatternPart)=>!urlPatternPart.startsWith(':')).join(''); |
@@ -20,11 +20,11 @@ "use strict"; | ||
method: request.method, | ||
path: `${serverBaseUrl !== null && serverBaseUrl !== void 0 ? serverBaseUrl : ""}${(_rest_baseUrl = rest === null || rest === void 0 ? void 0 : rest.baseUrl) !== null && _rest_baseUrl !== void 0 ? _rest_baseUrl : ""}${request.path}` | ||
path: `${serverBaseUrl !== null && serverBaseUrl !== void 0 ? serverBaseUrl : ''}${(_rest_baseUrl = rest === null || rest === void 0 ? void 0 : rest.baseUrl) !== null && _rest_baseUrl !== void 0 ? _rest_baseUrl : ''}${request.path}` | ||
}; | ||
})) !== null && _rest_configs_filter_map !== void 0 ? _rest_configs_filter_map : []; | ||
var _graphql_configs_filter_map; | ||
const graphqlRequestConfigs = (_graphql_configs_filter_map = graphql === null || graphql === void 0 ? void 0 : graphql.configs.filter((request)=>"operationName" in request && !(request.operationName instanceof RegExp)).map((request)=>{ | ||
const graphqlRequestConfigs = (_graphql_configs_filter_map = graphql === null || graphql === void 0 ? void 0 : graphql.configs.filter((request)=>'operationName' in request && !(request.operationName instanceof RegExp)).map((request)=>{ | ||
var _graphql_baseUrl; | ||
return { | ||
operationType: request.operationType, | ||
operationName: `${serverBaseUrl !== null && serverBaseUrl !== void 0 ? serverBaseUrl : ""}${(_graphql_baseUrl = graphql === null || graphql === void 0 ? void 0 : graphql.baseUrl) !== null && _graphql_baseUrl !== void 0 ? _graphql_baseUrl : ""} ${request.operationName}` | ||
operationName: `${serverBaseUrl !== null && serverBaseUrl !== void 0 ? serverBaseUrl : ''}${(_graphql_baseUrl = graphql === null || graphql === void 0 ? void 0 : graphql.baseUrl) !== null && _graphql_baseUrl !== void 0 ? _graphql_baseUrl : ''} ${request.operationName}` | ||
}; | ||
@@ -34,3 +34,3 @@ })) !== null && _graphql_configs_filter_map !== void 0 ? _graphql_configs_filter_map : []; | ||
var _request_headers_accept, _request_headers_accept1; | ||
const url = new URL(`${request.protocol}://${request.get("host")}${request.originalUrl}`); | ||
const url = new URL(`${request.protocol}://${request.get('host')}${request.originalUrl}`); | ||
let restRequestSuggestions = []; | ||
@@ -50,5 +50,5 @@ if (rest) { | ||
} | ||
const isRequestSupportHtml = ((_request_headers_accept = request.headers.accept) === null || _request_headers_accept === void 0 ? void 0 : _request_headers_accept.includes("text/html")) || ((_request_headers_accept1 = request.headers.accept) === null || _request_headers_accept1 === void 0 ? void 0 : _request_headers_accept1.includes("*/*")); | ||
const isRequestSupportHtml = ((_request_headers_accept = request.headers.accept) === null || _request_headers_accept === void 0 ? void 0 : _request_headers_accept.includes('text/html')) || ((_request_headers_accept1 = request.headers.accept) === null || _request_headers_accept1 === void 0 ? void 0 : _request_headers_accept1.includes('*/*')); | ||
if (isRequestSupportHtml) { | ||
response.status(404).render("pages/404", { | ||
response.status(404).render('pages/404', { | ||
restRequestSuggestions, | ||
@@ -60,3 +60,3 @@ graphqlRequestSuggestions | ||
response.status(404).json({ | ||
message: "Request or page not found. Similar requests in data", | ||
message: 'Request or page not found. Similar requests in data', | ||
data: { | ||
@@ -63,0 +63,0 @@ restRequestSuggestions, |
@@ -12,3 +12,3 @@ "use strict"; | ||
const _helpers = require("../../../utils/helpers"); | ||
const requestInterceptorMiddleware = ({ server, path = "*", interceptor })=>{ | ||
const requestInterceptorMiddleware = ({ server, path = '*', interceptor })=>{ | ||
server.use(path, (0, _helpers.asyncHandler)(async (request, _response, next)=>{ | ||
@@ -15,0 +15,0 @@ await (0, _helpers.callRequestInterceptor)({ |
@@ -23,3 +23,3 @@ "use strict"; | ||
staticPath.forEach((staticPath)=>{ | ||
const isPathObject = typeof staticPath === "object"; | ||
const isPathObject = typeof staticPath === 'object'; | ||
if (isPathObject) { | ||
@@ -33,3 +33,3 @@ server.use((0, _helpers.urlJoin)(baseUrl, staticPath.prefix), _express.default.static((0, _helpers.urlJoin)(_constants.APP_PATH, staticPath.path))); | ||
} | ||
const isStaticPathObject = typeof staticPath === "object"; | ||
const isStaticPathObject = typeof staticPath === 'object'; | ||
if (isStaticPathObject) { | ||
@@ -36,0 +36,0 @@ server.use((0, _helpers.urlJoin)(baseUrl, staticPath.prefix), _express.default.static((0, _helpers.urlJoin)(_constants.APP_PATH, staticPath.path))); |
@@ -23,8 +23,7 @@ "use strict"; | ||
router.route(requestConfig.path)[requestConfig.method]((0, _helpers.asyncHandler)(async (request, response, next)=>{ | ||
var _requestConfig_interceptors, _matchedRouteConfig_settings, _matchedRouteConfig_settings1, _matchedRouteConfig_interceptors, _requestConfig_interceptors1, _restConfig_interceptors, _matchedRouteConfig_settings2; | ||
const requestInterceptor = (_requestConfig_interceptors = requestConfig.interceptors) === null || _requestConfig_interceptors === void 0 ? void 0 : _requestConfig_interceptors.request; | ||
if (requestInterceptor) { | ||
var _requestConfig_interceptors, _matchedRouteConfig_interceptors, _matchedRouteConfig_settings, _matchedRouteConfig_settings1, _matchedRouteConfig_interceptors1, _requestConfig_interceptors1, _restConfig_interceptors, _matchedRouteConfig_settings2; | ||
if ((_requestConfig_interceptors = requestConfig.interceptors) === null || _requestConfig_interceptors === void 0 ? void 0 : _requestConfig_interceptors.request) { | ||
await (0, _helpers.callRequestInterceptor)({ | ||
request, | ||
interceptor: requestInterceptor | ||
interceptor: requestConfig.interceptors.request | ||
}); | ||
@@ -39,3 +38,3 @@ } | ||
// check whole body as plain value strictly if descriptor used for body | ||
const isEntityBodyByTopLevelDescriptor = entityName === "body" && (0, _helpers.isEntityDescriptor)(entityDescriptorOrValue); | ||
const isEntityBodyByTopLevelDescriptor = entityName === 'body' && (0, _helpers.isEntityDescriptor)(entityDescriptorOrValue); | ||
if (isEntityBodyByTopLevelDescriptor) { | ||
@@ -46,3 +45,3 @@ // ✅ important: | ||
} | ||
const isEntityBodyByTopLevelArray = entityName === "body" && Array.isArray(entityDescriptorOrValue); | ||
const isEntityBodyByTopLevelArray = entityName === 'body' && Array.isArray(entityDescriptorOrValue); | ||
if (isEntityBodyByTopLevelArray) { | ||
@@ -58,3 +57,3 @@ return entityDescriptorOrValue.some((entityDescriptorOrValueElement)=>// ✅ important: | ||
// ✅ important: transform header keys to lower case because browsers send headers in lowercase | ||
return (0, _helpers.resolveEntityValues)(checkMode, flattenEntity[entityName === "headers" ? entityKey.toLowerCase() : entityKey], descriptorValue); | ||
return (0, _helpers.resolveEntityValues)(checkMode, flattenEntity[entityName === 'headers' ? entityKey.toLowerCase() : entityKey], descriptorValue); | ||
}); | ||
@@ -66,4 +65,10 @@ }); | ||
} | ||
if ((_matchedRouteConfig_interceptors = matchedRouteConfig.interceptors) === null || _matchedRouteConfig_interceptors === void 0 ? void 0 : _matchedRouteConfig_interceptors.request) { | ||
await (0, _helpers.callRequestInterceptor)({ | ||
request, | ||
interceptor: matchedRouteConfig.interceptors.request | ||
}); | ||
} | ||
let matchedRouteConfigData = null; | ||
if (((_matchedRouteConfig_settings = matchedRouteConfig.settings) === null || _matchedRouteConfig_settings === void 0 ? void 0 : _matchedRouteConfig_settings.polling) && "queue" in matchedRouteConfig) { | ||
if (((_matchedRouteConfig_settings = matchedRouteConfig.settings) === null || _matchedRouteConfig_settings === void 0 ? void 0 : _matchedRouteConfig_settings.polling) && 'queue' in matchedRouteConfig) { | ||
if (!matchedRouteConfig.queue.length) return next(); | ||
@@ -94,10 +99,10 @@ const shallowMatchedRouteConfig = matchedRouteConfig; | ||
} | ||
if ("data" in matchedRouteConfig) { | ||
if ('data' in matchedRouteConfig) { | ||
matchedRouteConfigData = matchedRouteConfig.data; | ||
} | ||
if ("file" in matchedRouteConfig) { | ||
if ('file' in matchedRouteConfig) { | ||
if (!(0, _helpers.isFilePathValid)(matchedRouteConfig.file)) return next(); | ||
} | ||
var _matchedRouteConfig_entities; | ||
const resolvedData = typeof matchedRouteConfigData === "function" ? await matchedRouteConfigData(request, (_matchedRouteConfig_entities = matchedRouteConfig.entities) !== null && _matchedRouteConfig_entities !== void 0 ? _matchedRouteConfig_entities : {}) : matchedRouteConfigData; | ||
const resolvedData = typeof matchedRouteConfigData === 'function' ? await matchedRouteConfigData(request, (_matchedRouteConfig_entities = matchedRouteConfig.entities) !== null && _matchedRouteConfig_entities !== void 0 ? _matchedRouteConfig_entities : {}) : matchedRouteConfigData; | ||
if ((_matchedRouteConfig_settings1 = matchedRouteConfig.settings) === null || _matchedRouteConfig_settings1 === void 0 ? void 0 : _matchedRouteConfig_settings1.status) { | ||
@@ -109,3 +114,3 @@ response.statusCode = matchedRouteConfig.settings.status; | ||
// this code should place before response interceptors for giving opportunity to rewrite 'Cache-Control' header | ||
if (request.method === "GET") response.set("Cache-control", "no-cache"); | ||
if (request.method === 'GET') response.set('Cache-control', 'no-cache'); | ||
const data = await (0, _helpers.callResponseInterceptors)({ | ||
@@ -116,3 +121,3 @@ data: resolvedData, | ||
interceptors: { | ||
routeInterceptor: (_matchedRouteConfig_interceptors = matchedRouteConfig.interceptors) === null || _matchedRouteConfig_interceptors === void 0 ? void 0 : _matchedRouteConfig_interceptors.response, | ||
routeInterceptor: (_matchedRouteConfig_interceptors1 = matchedRouteConfig.interceptors) === null || _matchedRouteConfig_interceptors1 === void 0 ? void 0 : _matchedRouteConfig_interceptors1.response, | ||
requestInterceptor: (_requestConfig_interceptors1 = requestConfig.interceptors) === null || _requestConfig_interceptors1 === void 0 ? void 0 : _requestConfig_interceptors1.response, | ||
@@ -126,3 +131,3 @@ apiInterceptor: (_restConfig_interceptors = restConfig.interceptors) === null || _restConfig_interceptors === void 0 ? void 0 : _restConfig_interceptors.response, | ||
} | ||
if ("file" in matchedRouteConfig) { | ||
if ('file' in matchedRouteConfig) { | ||
return response.sendFile(_path.default.resolve(matchedRouteConfig.file)); | ||
@@ -129,0 +134,0 @@ } |
@@ -25,3 +25,3 @@ "use strict"; | ||
// check that actual value check modes does not have `value` for compare | ||
if (body.checkMode === "exists" || body.checkMode === "notExists") { | ||
if (body.checkMode === 'exists' || body.checkMode === 'notExists') { | ||
routeConfigWeight += 1; | ||
@@ -28,0 +28,0 @@ return routeConfigWeight; |
@@ -24,5 +24,5 @@ "use strict"; | ||
const { cors, staticPath, data, routes } = databaseMockServerConfig; | ||
server.set("view engine", "ejs"); | ||
server.set("views", (0, _helpers.urlJoin)(__dirname, "../../static/views")); | ||
server.use(_express.default.static((0, _helpers.urlJoin)(__dirname, "../../static/views"))); | ||
server.set('view engine', 'ejs'); | ||
server.set('views', (0, _helpers.urlJoin)(__dirname, '../../static/views')); | ||
server.use(_express.default.static((0, _helpers.urlJoin)(__dirname, '../../static/views'))); | ||
server.use(_bodyparser.default.urlencoded({ | ||
@@ -32,5 +32,5 @@ extended: false | ||
server.use(_bodyparser.default.json({ | ||
limit: "10mb" | ||
limit: '10mb' | ||
})); | ||
server.set("json spaces", 2); | ||
server.set('json spaces', 2); | ||
server.use(_bodyparser.default.text()); | ||
@@ -46,3 +46,3 @@ (0, _middlewares.cookieParseMiddleware)(server); | ||
var _databaseMockServerConfig_baseUrl; | ||
const baseUrl = (_databaseMockServerConfig_baseUrl = databaseMockServerConfig.baseUrl) !== null && _databaseMockServerConfig_baseUrl !== void 0 ? _databaseMockServerConfig_baseUrl : "/"; | ||
const baseUrl = (_databaseMockServerConfig_baseUrl = databaseMockServerConfig.baseUrl) !== null && _databaseMockServerConfig_baseUrl !== void 0 ? _databaseMockServerConfig_baseUrl : '/'; | ||
if (cors) { | ||
@@ -49,0 +49,0 @@ (0, _middlewares.corsMiddleware)(server, cors); |
@@ -25,5 +25,5 @@ "use strict"; | ||
const { cors, staticPath, configs, database, interceptors } = graphqlMockServerConfig; | ||
server.set("view engine", "ejs"); | ||
server.set("views", (0, _helpers.urlJoin)(__dirname, "../../static/views")); | ||
server.use(_express.default.static((0, _helpers.urlJoin)(__dirname, "../../static/views"))); | ||
server.set('view engine', 'ejs'); | ||
server.set('views', (0, _helpers.urlJoin)(__dirname, '../../static/views')); | ||
server.use(_express.default.static((0, _helpers.urlJoin)(__dirname, '../../static/views'))); | ||
server.use(_bodyparser.default.urlencoded({ | ||
@@ -33,5 +33,5 @@ extended: false | ||
server.use(_bodyparser.default.json({ | ||
limit: "10mb" | ||
limit: '10mb' | ||
})); | ||
server.set("json spaces", 2); | ||
server.set('json spaces', 2); | ||
server.use(_bodyparser.default.text()); | ||
@@ -47,3 +47,3 @@ (0, _middlewares.cookieParseMiddleware)(server); | ||
var _graphqlMockServerConfig_baseUrl; | ||
const baseUrl = (_graphqlMockServerConfig_baseUrl = graphqlMockServerConfig.baseUrl) !== null && _graphqlMockServerConfig_baseUrl !== void 0 ? _graphqlMockServerConfig_baseUrl : "/"; | ||
const baseUrl = (_graphqlMockServerConfig_baseUrl = graphqlMockServerConfig.baseUrl) !== null && _graphqlMockServerConfig_baseUrl !== void 0 ? _graphqlMockServerConfig_baseUrl : '/'; | ||
if (cors) { | ||
@@ -50,0 +50,0 @@ (0, _middlewares.corsMiddleware)(server, cors); |
@@ -26,5 +26,5 @@ "use strict"; | ||
const { cors, staticPath, rest, graphql, database, interceptors } = mockServerConfig; | ||
server.set("view engine", "ejs"); | ||
server.set("views", (0, _helpers.urlJoin)(__dirname, "../../static/views")); | ||
server.use(_express.default.static((0, _helpers.urlJoin)(__dirname, "../../static/views"))); | ||
server.set('view engine', 'ejs'); | ||
server.set('views', (0, _helpers.urlJoin)(__dirname, '../../static/views')); | ||
server.use(_express.default.static((0, _helpers.urlJoin)(__dirname, '../../static/views'))); | ||
server.use(_bodyparser.default.urlencoded({ | ||
@@ -34,5 +34,5 @@ extended: false | ||
server.use(_bodyparser.default.json({ | ||
limit: "10mb" | ||
limit: '10mb' | ||
})); | ||
server.set("json spaces", 2); | ||
server.set('json spaces', 2); | ||
server.use(_bodyparser.default.text()); | ||
@@ -48,3 +48,3 @@ (0, _middlewares.cookieParseMiddleware)(server); | ||
var _mockServerConfig_baseUrl; | ||
const baseUrl = (_mockServerConfig_baseUrl = mockServerConfig.baseUrl) !== null && _mockServerConfig_baseUrl !== void 0 ? _mockServerConfig_baseUrl : "/"; | ||
const baseUrl = (_mockServerConfig_baseUrl = mockServerConfig.baseUrl) !== null && _mockServerConfig_baseUrl !== void 0 ? _mockServerConfig_baseUrl : '/'; | ||
if (cors) { | ||
@@ -66,3 +66,3 @@ (0, _middlewares.corsMiddleware)(server, cors); | ||
var _rest_baseUrl; | ||
const restBaseUrl = (0, _helpers.urlJoin)(baseUrl, (_rest_baseUrl = rest.baseUrl) !== null && _rest_baseUrl !== void 0 ? _rest_baseUrl : "/"); | ||
const restBaseUrl = (0, _helpers.urlJoin)(baseUrl, (_rest_baseUrl = rest.baseUrl) !== null && _rest_baseUrl !== void 0 ? _rest_baseUrl : '/'); | ||
const apiRequestInterceptor = (_rest_interceptors = rest.interceptors) === null || _rest_interceptors === void 0 ? void 0 : _rest_interceptors.request; | ||
@@ -86,3 +86,3 @@ if (apiRequestInterceptor) { | ||
var _graphql_baseUrl; | ||
const graphqlBaseUrl = (0, _helpers.urlJoin)(baseUrl, (_graphql_baseUrl = graphql.baseUrl) !== null && _graphql_baseUrl !== void 0 ? _graphql_baseUrl : "/"); | ||
const graphqlBaseUrl = (0, _helpers.urlJoin)(baseUrl, (_graphql_baseUrl = graphql.baseUrl) !== null && _graphql_baseUrl !== void 0 ? _graphql_baseUrl : '/'); | ||
const apiRequestInterceptor = (_graphql_interceptors = graphql.interceptors) === null || _graphql_interceptors === void 0 ? void 0 : _graphql_interceptors.request; | ||
@@ -89,0 +89,0 @@ if (apiRequestInterceptor) { |
@@ -25,5 +25,5 @@ "use strict"; | ||
const { cors, staticPath, configs, database, interceptors } = restMockServerConfig; | ||
server.set("view engine", "ejs"); | ||
server.set("views", (0, _helpers.urlJoin)(__dirname, "../../static/views")); | ||
server.use(_express.default.static((0, _helpers.urlJoin)(__dirname, "../../static/views"))); | ||
server.set('view engine', 'ejs'); | ||
server.set('views', (0, _helpers.urlJoin)(__dirname, '../../static/views')); | ||
server.use(_express.default.static((0, _helpers.urlJoin)(__dirname, '../../static/views'))); | ||
server.use(_bodyparser.default.urlencoded({ | ||
@@ -33,5 +33,5 @@ extended: false | ||
server.use(_bodyparser.default.json({ | ||
limit: "10mb" | ||
limit: '10mb' | ||
})); | ||
server.set("json spaces", 2); | ||
server.set('json spaces', 2); | ||
server.use(_bodyparser.default.text()); | ||
@@ -47,3 +47,3 @@ (0, _middlewares.cookieParseMiddleware)(server); | ||
var _restMockServerConfig_baseUrl; | ||
const baseUrl = (_restMockServerConfig_baseUrl = restMockServerConfig.baseUrl) !== null && _restMockServerConfig_baseUrl !== void 0 ? _restMockServerConfig_baseUrl : "/"; | ||
const baseUrl = (_restMockServerConfig_baseUrl = restMockServerConfig.baseUrl) !== null && _restMockServerConfig_baseUrl !== void 0 ? _restMockServerConfig_baseUrl : '/'; | ||
if (cors) { | ||
@@ -50,0 +50,0 @@ (0, _middlewares.corsMiddleware)(server, cors); |
@@ -38,16 +38,16 @@ "use strict"; | ||
const CHECK_ACTUAL_VALUE_CHECK_MODES = [ | ||
"exists", | ||
"notExists" | ||
'exists', | ||
'notExists' | ||
]; | ||
const COMPARE_WITH_DESCRIPTOR_ANY_VALUE_CHECK_MODES = [ | ||
"equals", | ||
"notEquals" | ||
'equals', | ||
'notEquals' | ||
]; | ||
const COMPARE_WITH_DESCRIPTOR_STRING_VALUE_CHECK_MODES = [ | ||
"includes", | ||
"notIncludes", | ||
"startsWith", | ||
"notStartsWith", | ||
"endsWith", | ||
"notEndsWith" | ||
'includes', | ||
'notIncludes', | ||
'startsWith', | ||
'notStartsWith', | ||
'endsWith', | ||
'notEndsWith' | ||
]; | ||
@@ -59,4 +59,4 @@ const COMPARE_WITH_DESCRIPTOR_VALUE_CHECK_MODES = [ | ||
const CALCULATE_BY_DESCRIPTOR_VALUE_CHECK_MODES = [ | ||
"regExp", | ||
"function" | ||
'regExp', | ||
'function' | ||
]; | ||
@@ -71,10 +71,10 @@ const CHECK_MODES = [ | ||
...COMPARE_WITH_DESCRIPTOR_ANY_VALUE_CHECK_MODES, | ||
"function" | ||
'function' | ||
]; | ||
const NEGATION_CHECK_MODES = [ | ||
"notExists", | ||
"notEquals", | ||
"notIncludes", | ||
"notStartsWith", | ||
"notEndsWith" | ||
'notExists', | ||
'notEquals', | ||
'notIncludes', | ||
'notStartsWith', | ||
'notEndsWith' | ||
]; |
@@ -14,6 +14,6 @@ "use strict"; | ||
CORS: { | ||
ORIGIN: "*", | ||
METHODS: "GET,OPTIONS,PUT,PATCH,POST,DELETE", | ||
ALLOWED_HEADERS: "*", | ||
EXPOSED_HEADERS: "*", | ||
ORIGIN: '*', | ||
METHODS: 'GET,OPTIONS,PUT,PATCH,POST,DELETE', | ||
ALLOWED_HEADERS: '*', | ||
EXPOSED_HEADERS: '*', | ||
CREDENTIALS: true, | ||
@@ -20,0 +20,0 @@ MAX_AGE: 3600 |
@@ -17,24 +17,24 @@ "use strict"; | ||
const checkFunction = (checkMode, actualValue, descriptorValue)=>{ | ||
if (checkMode === "function" && typeof descriptorValue === "function") return descriptorValue(actualValue, checkFunction); | ||
if (checkMode === 'function' && typeof descriptorValue === 'function') return descriptorValue(actualValue, checkFunction); | ||
const actualValueString = String(actualValue); | ||
if (checkMode === "regExp" && (0, _isRegExp.isRegExp)(descriptorValue)) return descriptorValue.test(actualValueString); | ||
const isActualValueUndefined = typeof actualValue === "undefined"; | ||
if (checkMode === "exists") return !isActualValueUndefined; | ||
if (checkMode === "notExists") return isActualValueUndefined; | ||
if (checkMode === 'regExp' && (0, _isRegExp.isRegExp)(descriptorValue)) return descriptorValue.test(actualValueString); | ||
const isActualValueUndefined = typeof actualValue === 'undefined'; | ||
if (checkMode === 'exists') return !isActualValueUndefined; | ||
if (checkMode === 'notExists') return isActualValueUndefined; | ||
// ✅ important: | ||
// cast values to string for ignore types of values | ||
const descriptorValueString = String(descriptorValue); | ||
if (checkMode === "equals") return actualValueString === descriptorValueString; | ||
if (checkMode === "notEquals") return actualValueString !== descriptorValueString; | ||
if (checkMode === "includes") return actualValueString.includes(descriptorValueString); | ||
if (checkMode === "notIncludes") return !actualValueString.includes(descriptorValueString); | ||
if (checkMode === "startsWith") return actualValueString.startsWith(descriptorValueString); | ||
if (checkMode === "notStartsWith") return !actualValueString.startsWith(descriptorValueString); | ||
if (checkMode === "endsWith") return actualValueString.endsWith(descriptorValueString); | ||
if (checkMode === "notEndsWith") return !actualValueString.endsWith(descriptorValueString); | ||
throw new Error("Wrong checkMode"); | ||
if (checkMode === 'equals') return actualValueString === descriptorValueString; | ||
if (checkMode === 'notEquals') return actualValueString !== descriptorValueString; | ||
if (checkMode === 'includes') return actualValueString.includes(descriptorValueString); | ||
if (checkMode === 'notIncludes') return !actualValueString.includes(descriptorValueString); | ||
if (checkMode === 'startsWith') return actualValueString.startsWith(descriptorValueString); | ||
if (checkMode === 'notStartsWith') return !actualValueString.startsWith(descriptorValueString); | ||
if (checkMode === 'endsWith') return actualValueString.endsWith(descriptorValueString); | ||
if (checkMode === 'notEndsWith') return !actualValueString.endsWith(descriptorValueString); | ||
throw new Error('Wrong checkMode'); | ||
}; | ||
const resolveEntityValues = (checkMode, actualValue, descriptorValue)=>{ | ||
if (checkMode === "function") return descriptorValue(actualValue, checkFunction); | ||
if (checkMode === "exists" || checkMode === "notExists") return checkFunction(checkMode, actualValue, descriptorValue); | ||
if (checkMode === 'function') return descriptorValue(actualValue, checkFunction); | ||
if (checkMode === 'exists' || checkMode === 'notExists') return checkFunction(checkMode, actualValue, descriptorValue); | ||
// ✅ actual: primitive, descriptor: primitive | ||
@@ -56,3 +56,3 @@ const isActualValuePrimitive = (0, _isPrimitive.isPrimitive)(actualValue); | ||
if (isActualValuePrimitive && isDescriptorValueObject) { | ||
if (checkMode === "regExp") return checkFunction(checkMode, actualValue, descriptorValue); | ||
if (checkMode === 'regExp') return checkFunction(checkMode, actualValue, descriptorValue); | ||
// ✅ important: resolving primitive with object make no sense | ||
@@ -75,3 +75,3 @@ return isNegativeCheckMode; | ||
if (isActualValueArray && isDescriptorValueObject) { | ||
if (checkMode === "regExp") return actualValue.some((actualValueElement)=>checkFunction(checkMode, actualValueElement, descriptorValue)); | ||
if (checkMode === 'regExp') return actualValue.some((actualValueElement)=>checkFunction(checkMode, actualValueElement, descriptorValue)); | ||
// ✅ important: resolving array with object make no sense | ||
@@ -87,3 +87,3 @@ return isNegativeCheckMode; | ||
// ✅ important: any object can not pass RegExp check | ||
if (checkMode === "regExp") return false; | ||
if (checkMode === 'regExp') return false; | ||
const flattenActualValue = (0, _flat.flatten)(actualValue); | ||
@@ -106,3 +106,3 @@ if (isNegativeCheckMode) { | ||
// ✅ important: any object can not pass RegExp check | ||
if (checkMode === "regExp") return false; | ||
if (checkMode === 'regExp') return false; | ||
const flattenActualValue = (0, _flat.flatten)(actualValue); | ||
@@ -109,0 +109,0 @@ const flattenDescriptorValue = (0, _flat.flatten)(descriptorValue); |
@@ -13,4 +13,4 @@ "use strict"; | ||
const convertToEntityDescriptor = (valueOrDescriptor)=>(0, _isEntityDescriptor.isEntityDescriptor)(valueOrDescriptor) ? valueOrDescriptor : { | ||
checkMode: "equals", | ||
checkMode: 'equals', | ||
value: valueOrDescriptor | ||
}; |
@@ -12,2 +12,2 @@ "use strict"; | ||
const _isPlainObject = require("../../isPlainObject/isPlainObject"); | ||
const isEntityDescriptor = (value)=>(0, _isPlainObject.isPlainObject)(value) && "checkMode" in value; | ||
const isEntityDescriptor = (value)=>(0, _isPlainObject.isPlainObject)(value) && 'checkMode' in value; |
@@ -12,3 +12,3 @@ "use strict"; | ||
const getGraphQLInput = (request)=>{ | ||
if (request.method === "GET") { | ||
if (request.method === 'GET') { | ||
const { query, variables } = request.query; | ||
@@ -19,6 +19,6 @@ // ✅ important: | ||
query: query === null || query === void 0 ? void 0 : query.toString(), | ||
variables: typeof variables === "string" ? JSON.parse(variables) : variables | ||
variables: typeof variables === 'string' ? JSON.parse(variables) : variables | ||
}; | ||
} | ||
if (request.method === "POST") { | ||
if (request.method === 'POST') { | ||
const { query, variables } = request.body; | ||
@@ -25,0 +25,0 @@ return { |
@@ -14,3 +14,3 @@ "use strict"; | ||
var _operationDefinition_name; | ||
const operationDefinition = node.definitions.find((definition)=>definition.kind === "OperationDefinition"); | ||
const operationDefinition = node.definitions.find((definition)=>definition.kind === 'OperationDefinition'); | ||
var _operationDefinition_name_value; | ||
@@ -17,0 +17,0 @@ return { |
@@ -11,2 +11,2 @@ "use strict"; | ||
}); | ||
const isPlainObject = (value)=>typeof value === "object" && !Array.isArray(value) && value !== null && !(value instanceof RegExp); | ||
const isPlainObject = (value)=>typeof value === 'object' && !Array.isArray(value) && value !== null && !(value instanceof RegExp); |
@@ -11,2 +11,2 @@ "use strict"; | ||
}); | ||
const convertWin32PathToUnix = (win32Path)=>win32Path.replace(/^\\\\\?\\/, "").replace(/\\/g, "/").replace(/\/\/+/g, "/"); | ||
const convertWin32PathToUnix = (win32Path)=>win32Path.replace(/^\\\\\?\\/, '').replace(/\\/g, '/').replace(/\/\/+/g, '/'); |
@@ -12,2 +12,2 @@ "use strict"; | ||
const _removeLeadingAndTrailingSlashes = require("../removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes"); | ||
const getUrlParts = (url)=>(0, _removeLeadingAndTrailingSlashes.removeLeadingAndTrailingSlashes)(url).split("/"); | ||
const getUrlParts = (url)=>(0, _removeLeadingAndTrailingSlashes.removeLeadingAndTrailingSlashes)(url).split('/'); |
@@ -11,2 +11,2 @@ "use strict"; | ||
}); | ||
const removeLeadingAndTrailingSlashes = (string)=>string.replace(/^\/+|\/+$/g, ""); | ||
const removeLeadingAndTrailingSlashes = (string)=>string.replace(/^\/+|\/+$/g, ''); |
@@ -20,4 +20,4 @@ "use strict"; | ||
const urlJoin = (...paths)=>{ | ||
const pathsToJoin = _os.default.platform() === "win32" ? paths.map((path)=>(0, _convertWin32PathToUnix.convertWin32PathToUnix)(path)) : paths; | ||
const pathsToJoin = _os.default.platform() === 'win32' ? paths.map((path)=>(0, _convertWin32PathToUnix.convertWin32PathToUnix)(path)) : paths; | ||
return _path.default.posix.join(...pathsToJoin); | ||
}; |
@@ -35,3 +35,3 @@ import type { Request } from 'express'; | ||
entities?: GraphQLEntitiesByEntityName; | ||
interceptors?: Pick<Interceptors, 'response'>; | ||
interceptors?: Interceptors; | ||
}; | ||
@@ -38,0 +38,0 @@ interface BaseGraphQLRequestConfig { |
@@ -39,3 +39,3 @@ import type { Request } from 'express'; | ||
entities?: RestEntitiesByEntityName<Method>; | ||
interceptors?: Pick<Interceptors, 'response'>; | ||
interceptors?: Interceptors; | ||
}; | ||
@@ -42,0 +42,0 @@ export type RestPathString = `/${string}`; |
{ | ||
"name": "mock-config-server", | ||
"version": "3.5.0", | ||
"version": "3.6.0", | ||
"description": "Tool that easily and quickly imitates server operation, create full fake api in few steps", | ||
@@ -53,3 +53,3 @@ "author": { | ||
"dev": "nodemon --watch src --watch bin --watch mock-server.config.* -e js,ts,ejs --exec \"yarn start\"", | ||
"test": "jest", | ||
"unit-test": "vitest", | ||
"lint": "eslint . --ext .ts --no-error-on-unmatched-pattern --fix", | ||
@@ -75,3 +75,3 @@ "stylelint": "stylelint \"src/static/**/*.css\" --fix", | ||
"@types/express": "^4.17.21", | ||
"@types/flat": "^5.0.2", | ||
"@types/flat": "^5.0.5", | ||
"@types/prompts": "^2.4.9", | ||
@@ -81,31 +81,29 @@ "@types/yargs": "^17.0.32", | ||
"body-parser": "^1.20.2", | ||
"ejs": "^3.1.9", | ||
"esbuild": "^0.19.11", | ||
"express": "^4.18.2", | ||
"express-urlrewrite": "^2.0.1", | ||
"ejs": "^3.1.10", | ||
"esbuild": "^0.21.4", | ||
"express": "^4.19.2", | ||
"express-urlrewrite": "^2.0.2", | ||
"flat": "^5.0.2", | ||
"graphql": "^16.6.0", | ||
"graphql": "^16.8.1", | ||
"please-upgrade-node": "^3.2.0", | ||
"prompts": "^2.4.2", | ||
"yargs": "^17.7.2", | ||
"zod": "^3.22.4" | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@siberiacancode/eslint": "^1.0.3", | ||
"@siberiacancode/jest": "^1.0.2", | ||
"@siberiacancode/prettier": "^1.0.1", | ||
"@siberiacancode/stylelint": "^1.0.2", | ||
"@siberiacancode/eslint": "^1.1.1", | ||
"@siberiacancode/prettier": "^1.1.1", | ||
"@siberiacancode/stylelint": "^1.1.1", | ||
"@siberiacancode/vitest": "^1.2.3", | ||
"@swc/cli": "^0.3.12", | ||
"@swc/core": "^1.4.12", | ||
"@swc/jest": "^0.2.36", | ||
"@types/jest": "^29.5.11", | ||
"@swc/core": "^1.5.24", | ||
"@types/supertest": "^6.0.2", | ||
"husky": "^8.0.3", | ||
"lint-staged": "^15.2.0", | ||
"nodemon": "^3.0.3", | ||
"husky": "^9.0.11", | ||
"lint-staged": "^15.2.5", | ||
"nodemon": "^3.1.2", | ||
"shx": "^0.3.4", | ||
"style-loader": "^3.3.4", | ||
"supertest": "^6.3.4", | ||
"tsc-alias": "^1.8.8", | ||
"typescript": "^5.3.3" | ||
"style-loader": "^4.0.0", | ||
"supertest": "^7.0.0", | ||
"tsc-alias": "^1.8.10", | ||
"typescript": "^5.4.5" | ||
}, | ||
@@ -112,0 +110,0 @@ "homepage": "https://github.com/siberiacancode/mock-config-server", |
@@ -573,2 +573,4 @@ # 🎉 Mock Config Server | ||
> request interceptors (except interceptor for route) are called regardless of whether the server found a route match or not. So changes in request interceptors can affect whether the server finds the route or not | ||
##### Request | ||
@@ -575,0 +577,0 @@ |
15
7061
881
352136
+ Added@esbuild/aix-ppc64@0.21.5(transitive)
+ Added@esbuild/android-arm@0.21.5(transitive)
+ Added@esbuild/android-arm64@0.21.5(transitive)
+ Added@esbuild/android-x64@0.21.5(transitive)
+ Added@esbuild/darwin-arm64@0.21.5(transitive)
+ Added@esbuild/darwin-x64@0.21.5(transitive)
+ Added@esbuild/freebsd-arm64@0.21.5(transitive)
+ Added@esbuild/freebsd-x64@0.21.5(transitive)
+ Added@esbuild/linux-arm@0.21.5(transitive)
+ Added@esbuild/linux-arm64@0.21.5(transitive)
+ Added@esbuild/linux-ia32@0.21.5(transitive)
+ Added@esbuild/linux-loong64@0.21.5(transitive)
+ Added@esbuild/linux-mips64el@0.21.5(transitive)
+ Added@esbuild/linux-ppc64@0.21.5(transitive)
+ Added@esbuild/linux-riscv64@0.21.5(transitive)
+ Added@esbuild/linux-s390x@0.21.5(transitive)
+ Added@esbuild/linux-x64@0.21.5(transitive)
+ Added@esbuild/netbsd-x64@0.21.5(transitive)
+ Added@esbuild/openbsd-x64@0.21.5(transitive)
+ Added@esbuild/sunos-x64@0.21.5(transitive)
+ Added@esbuild/win32-arm64@0.21.5(transitive)
+ Added@esbuild/win32-ia32@0.21.5(transitive)
+ Added@esbuild/win32-x64@0.21.5(transitive)
+ Addedesbuild@0.21.5(transitive)
- Removed@esbuild/aix-ppc64@0.19.12(transitive)
- Removed@esbuild/android-arm@0.19.12(transitive)
- Removed@esbuild/android-arm64@0.19.12(transitive)
- Removed@esbuild/android-x64@0.19.12(transitive)
- Removed@esbuild/darwin-arm64@0.19.12(transitive)
- Removed@esbuild/darwin-x64@0.19.12(transitive)
- Removed@esbuild/freebsd-arm64@0.19.12(transitive)
- Removed@esbuild/freebsd-x64@0.19.12(transitive)
- Removed@esbuild/linux-arm@0.19.12(transitive)
- Removed@esbuild/linux-arm64@0.19.12(transitive)
- Removed@esbuild/linux-ia32@0.19.12(transitive)
- Removed@esbuild/linux-loong64@0.19.12(transitive)
- Removed@esbuild/linux-mips64el@0.19.12(transitive)
- Removed@esbuild/linux-ppc64@0.19.12(transitive)
- Removed@esbuild/linux-riscv64@0.19.12(transitive)
- Removed@esbuild/linux-s390x@0.19.12(transitive)
- Removed@esbuild/linux-x64@0.19.12(transitive)
- Removed@esbuild/netbsd-x64@0.19.12(transitive)
- Removed@esbuild/openbsd-x64@0.19.12(transitive)
- Removed@esbuild/sunos-x64@0.19.12(transitive)
- Removed@esbuild/win32-arm64@0.19.12(transitive)
- Removed@esbuild/win32-ia32@0.19.12(transitive)
- Removed@esbuild/win32-x64@0.19.12(transitive)
- Removedesbuild@0.19.12(transitive)
Updated@types/flat@^5.0.5
Updatedejs@^3.1.10
Updatedesbuild@^0.21.4
Updatedexpress@^4.19.2
Updatedexpress-urlrewrite@^2.0.2
Updatedgraphql@^16.8.1
Updatedzod@^3.23.8