UNPKG

@paultaku/node-mock-server

Version:

A TypeScript-based mock server with automatic Swagger-based mock file generation

1,166 lines 33.4 kB
/** * API Contract: Create Endpoint * Feature: 003-add-endpoint * Endpoint: POST /_mock/endpoints * * This contract defines the request/response schema for creating new mock endpoints * through the dashboard UI. It uses Zod for runtime validation and TypeScript type * inference to ensure type safety across frontend and backend. */ import { z } from "zod"; /** * Supported HTTP methods for mock endpoints */ export declare const HttpMethodSchema: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>; export type HttpMethod = z.infer<typeof HttpMethodSchema>; /** * Endpoint path validation rules: * - Must start with / * - Can contain: letters, numbers, hyphens, slashes, curly braces (for params) * - Cannot contain invalid file system characters: : | < > " * ? * - Cannot start with /_mock/ (reserved for management API) * - Max length: 500 characters */ export declare const EndpointPathSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>; /** * Request body schema for POST /_mock/endpoints * * Example: * { * "path": "/pet/status/{id}", * "method": "GET" * } */ export declare const CreateEndpointRequestSchema: z.ZodObject<{ /** * API endpoint path * @example "/users" * @example "/pet/status/{id}" * @example "/api/v1/products/{productId}/reviews" */ path: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>; /** * HTTP method for the endpoint * @example "GET" * @example "POST" */ method: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>; }, "strip", z.ZodTypeAny, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; }, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; }>; export type CreateEndpointRequest = z.infer<typeof CreateEndpointRequestSchema>; /** * Success response schema (HTTP 201 Created) * * Example: * { * "success": true, * "message": "Endpoint created successfully", * "endpoint": { * "path": "/pet/status/{id}", * "method": "GET", * "filesCreated": [ * "success-200.json", * "unexpected-error-default.json", * "status.json" * ], * "availableAt": "http://localhost:3000/pet/status/123", * "mockDirectory": "/mock/pet/status/{id}/GET" * } * } */ export declare const CreateEndpointSuccessSchema: z.ZodObject<{ /** * Indicates successful endpoint creation */ success: z.ZodLiteral<true>; /** * Human-readable success message */ message: z.ZodString; /** * Details about the created endpoint */ endpoint: z.ZodObject<{ /** * The endpoint path that was created */ path: z.ZodString; /** * The HTTP method for the endpoint */ method: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>; /** * List of files that were generated */ filesCreated: z.ZodArray<z.ZodString, "many">; /** * Example URL where the endpoint is now available * (with path parameters replaced with example values) */ availableAt: z.ZodString; /** * File system directory where mock files are stored */ mockDirectory: z.ZodString; }, "strip", z.ZodTypeAny, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; filesCreated: string[]; mockDirectory: string; availableAt: string; }, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; filesCreated: string[]; mockDirectory: string; availableAt: string; }>; }, "strip", z.ZodTypeAny, { message: string; success: true; endpoint: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; filesCreated: string[]; mockDirectory: string; availableAt: string; }; }, { message: string; success: true; endpoint: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; filesCreated: string[]; mockDirectory: string; availableAt: string; }; }>; export type CreateEndpointSuccessResponse = z.infer<typeof CreateEndpointSuccessSchema>; /** * Error response schema (HTTP 400, 409, 500) * * Example (400 Validation Error): * { * "error": "Validation failed", * "details": [ * { "field": "path", "message": "Path is required" }, * { "field": "method", "message": "Invalid enum value. Expected 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'" } * ] * } * * Example (409 Duplicate): * { * "error": "Endpoint already exists", * "existingEndpoint": { * "path": "/users", * "method": "GET", * "mockDirectory": "/mock/users/GET" * } * } * * Example (500 Server Error): * { * "error": "Failed to create endpoint files", * "detail": "EACCES: permission denied, mkdir '/mock/users'" * } */ export declare const CreateEndpointErrorSchema: z.ZodObject<{ /** * Error message describing what went wrong */ error: z.ZodString; /** * Validation error details (for 400 errors) */ details: z.ZodOptional<z.ZodArray<z.ZodObject<{ /** * Field that failed validation */ field: z.ZodString; /** * Validation error message */ message: z.ZodString; }, "strip", z.ZodTypeAny, { message: string; field: string; }, { message: string; field: string; }>, "many">>; /** * Server error detail (for 500 errors) */ detail: z.ZodOptional<z.ZodString>; /** * Existing endpoint info (for 409 duplicate errors) */ existingEndpoint: z.ZodOptional<z.ZodObject<{ path: z.ZodString; method: z.ZodString; mockDirectory: z.ZodString; }, "strip", z.ZodTypeAny, { path: string; method: string; mockDirectory: string; }, { path: string; method: string; mockDirectory: string; }>>; }, "strip", z.ZodTypeAny, { error: string; details?: { message: string; field: string; }[] | undefined; detail?: string | undefined; existingEndpoint?: { path: string; method: string; mockDirectory: string; } | undefined; }, { error: string; details?: { message: string; field: string; }[] | undefined; detail?: string | undefined; existingEndpoint?: { path: string; method: string; mockDirectory: string; } | undefined; }>; export type CreateEndpointErrorResponse = z.infer<typeof CreateEndpointErrorSchema>; /** * Expected HTTP status codes for this endpoint */ export declare const HTTP_STATUS: { /** * 201 Created - Endpoint was successfully created */ readonly CREATED: 201; /** * 400 Bad Request - Validation failed (invalid path, method, etc.) */ readonly BAD_REQUEST: 400; /** * 409 Conflict - Endpoint with same path and method already exists */ readonly CONFLICT: 409; /** * 500 Internal Server Error - File system error, permission denied, etc. */ readonly INTERNAL_ERROR: 500; }; /** * Validate a request against the schema */ export declare function validateCreateEndpointRequest(data: unknown): { success: true; data: CreateEndpointRequest; } | { success: false; errors: z.ZodError; }; /** * Format Zod errors for API response */ export declare function formatValidationErrors(zodError: z.ZodError): CreateEndpointErrorResponse; /** * Endpoint configuration schema for scenarios * * Defines how a single endpoint should behave within a scenario: * - Which mock response file to use * - Response delay in milliseconds */ export declare const EndpointConfigurationSchema: z.ZodObject<{ /** * API endpoint path (must start with /) * @example "/pet/status" * @example "/user/login" */ path: z.ZodString; /** * HTTP method for the endpoint * @example "GET" * @example "POST" */ method: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>; /** * Name of the mock response file to use (must end with .json) * @example "success-200.json" * @example "error-404.json" */ selectedMockFile: z.ZodString; /** * Response delay in milliseconds (0-60000ms = 0-60 seconds) * @default 0 */ delayMillisecond: z.ZodDefault<z.ZodNumber>; }, "strip", z.ZodTypeAny, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }>; export type EndpointConfiguration = z.infer<typeof EndpointConfigurationSchema>; /** * Scenario metadata schema * * Auto-generated tracking information for scenario lifecycle */ export declare const ScenarioMetadataSchema: z.ZodObject<{ /** * ISO 8601 timestamp of scenario creation (immutable) * @example "2025-11-29T10:00:00.000Z" */ createdAt: z.ZodString; /** * ISO 8601 timestamp of last modification * @example "2025-11-29T10:15:00.000Z" */ lastModified: z.ZodString; /** * Incremental version number (starts at 1) */ version: z.ZodNumber; }, "strip", z.ZodTypeAny, { version: number; createdAt: string; lastModified: string; }, { version: number; createdAt: string; lastModified: string; }>; export type ScenarioMetadata = z.infer<typeof ScenarioMetadataSchema>; /** * Scenario schema with duplicate endpoint detection * * A scenario is a named collection of endpoint configurations. * Validation includes: * - Name format: 1-50 characters, alphanumeric + hyphens only * - At least one endpoint configuration required * - No duplicate endpoints (same path + method) */ export declare const ScenarioSchema: z.ZodEffects<z.ZodObject<{ /** * Unique scenario identifier * - 1-50 characters * - Alphanumeric and hyphens only * @example "testing" * @example "error-scenarios" */ name: z.ZodString; /** * Array of endpoint configurations (minimum 1 required) */ endpointConfigurations: z.ZodArray<z.ZodObject<{ /** * API endpoint path (must start with /) * @example "/pet/status" * @example "/user/login" */ path: z.ZodString; /** * HTTP method for the endpoint * @example "GET" * @example "POST" */ method: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>; /** * Name of the mock response file to use (must end with .json) * @example "success-200.json" * @example "error-404.json" */ selectedMockFile: z.ZodString; /** * Response delay in milliseconds (0-60000ms = 0-60 seconds) * @default 0 */ delayMillisecond: z.ZodDefault<z.ZodNumber>; }, "strip", z.ZodTypeAny, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }>, "many">; /** * Auto-generated metadata */ metadata: z.ZodObject<{ /** * ISO 8601 timestamp of scenario creation (immutable) * @example "2025-11-29T10:00:00.000Z" */ createdAt: z.ZodString; /** * ISO 8601 timestamp of last modification * @example "2025-11-29T10:15:00.000Z" */ lastModified: z.ZodString; /** * Incremental version number (starts at 1) */ version: z.ZodNumber; }, "strip", z.ZodTypeAny, { version: number; createdAt: string; lastModified: string; }, { version: number; createdAt: string; lastModified: string; }>; }, "strip", z.ZodTypeAny, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }>, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }>; export type Scenario = z.infer<typeof ScenarioSchema>; /** * Active scenario reference schema * * Tracks which scenario is currently active (stored in _active.json) */ export declare const ActiveScenarioReferenceSchema: z.ZodObject<{ /** * Name of the currently active scenario (null if none) */ activeScenario: z.ZodNullable<z.ZodString>; /** * ISO 8601 timestamp of when the active scenario was last updated * @example "2025-11-29T10:15:00.000Z" */ lastUpdated: z.ZodString; }, "strip", z.ZodTypeAny, { activeScenario: string | null; lastUpdated: string; }, { activeScenario: string | null; lastUpdated: string; }>; export type ActiveScenarioReference = z.infer<typeof ActiveScenarioReferenceSchema>; /** * Request schema for creating a new scenario * * Example: * { * "name": "testing", * "endpointConfigurations": [ * { * "path": "/pet/status", * "method": "GET", * "selectedMockFile": "success-200.json", * "delayMillisecond": 1000 * } * ] * } */ export declare const CreateScenarioRequestSchema: z.ZodEffects<z.ZodObject<{ /** * Unique scenario name (1-50 chars, alphanumeric + hyphens) */ name: z.ZodString; /** * Array of endpoint configurations (minimum 1 required) */ endpointConfigurations: z.ZodArray<z.ZodObject<{ /** * API endpoint path (must start with /) * @example "/pet/status" * @example "/user/login" */ path: z.ZodString; /** * HTTP method for the endpoint * @example "GET" * @example "POST" */ method: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>; /** * Name of the mock response file to use (must end with .json) * @example "success-200.json" * @example "error-404.json" */ selectedMockFile: z.ZodString; /** * Response delay in milliseconds (0-60000ms = 0-60 seconds) * @default 0 */ delayMillisecond: z.ZodDefault<z.ZodNumber>; }, "strip", z.ZodTypeAny, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }>, "many">; }, "strip", z.ZodTypeAny, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }[]; }, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }[]; }>, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }[]; }, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }[]; }>; export type CreateScenarioRequest = z.infer<typeof CreateScenarioRequestSchema>; /** * Request schema for updating an existing scenario * * Example: * { * "endpointConfigurations": [ * { * "path": "/pet/status", * "method": "GET", * "selectedMockFile": "error-500.json", * "delayMillisecond": 2000 * } * ] * } */ export declare const UpdateScenarioRequestSchema: z.ZodEffects<z.ZodObject<{ /** * Updated array of endpoint configurations (minimum 1 required) */ endpointConfigurations: z.ZodArray<z.ZodObject<{ /** * API endpoint path (must start with /) * @example "/pet/status" * @example "/user/login" */ path: z.ZodString; /** * HTTP method for the endpoint * @example "GET" * @example "POST" */ method: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>; /** * Name of the mock response file to use (must end with .json) * @example "success-200.json" * @example "error-404.json" */ selectedMockFile: z.ZodString; /** * Response delay in milliseconds (0-60000ms = 0-60 seconds) * @default 0 */ delayMillisecond: z.ZodDefault<z.ZodNumber>; }, "strip", z.ZodTypeAny, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }>, "many">; }, "strip", z.ZodTypeAny, { endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }[]; }, { endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }[]; }>, { endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }[]; }, { endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }[]; }>; export type UpdateScenarioRequest = z.infer<typeof UpdateScenarioRequestSchema>; /** * Success response schema for scenario creation/update * * Example: * { * "scenario": { ... }, * "message": "Scenario 'testing' created and activated successfully" * } */ export declare const ScenarioResponseSchema: z.ZodObject<{ /** * The created or updated scenario */ scenario: z.ZodEffects<z.ZodObject<{ /** * Unique scenario identifier * - 1-50 characters * - Alphanumeric and hyphens only * @example "testing" * @example "error-scenarios" */ name: z.ZodString; /** * Array of endpoint configurations (minimum 1 required) */ endpointConfigurations: z.ZodArray<z.ZodObject<{ /** * API endpoint path (must start with /) * @example "/pet/status" * @example "/user/login" */ path: z.ZodString; /** * HTTP method for the endpoint * @example "GET" * @example "POST" */ method: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>; /** * Name of the mock response file to use (must end with .json) * @example "success-200.json" * @example "error-404.json" */ selectedMockFile: z.ZodString; /** * Response delay in milliseconds (0-60000ms = 0-60 seconds) * @default 0 */ delayMillisecond: z.ZodDefault<z.ZodNumber>; }, "strip", z.ZodTypeAny, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }>, "many">; /** * Auto-generated metadata */ metadata: z.ZodObject<{ /** * ISO 8601 timestamp of scenario creation (immutable) * @example "2025-11-29T10:00:00.000Z" */ createdAt: z.ZodString; /** * ISO 8601 timestamp of last modification * @example "2025-11-29T10:15:00.000Z" */ lastModified: z.ZodString; /** * Incremental version number (starts at 1) */ version: z.ZodNumber; }, "strip", z.ZodTypeAny, { version: number; createdAt: string; lastModified: string; }, { version: number; createdAt: string; lastModified: string; }>; }, "strip", z.ZodTypeAny, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }>, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }>; /** * Success message */ message: z.ZodString; }, "strip", z.ZodTypeAny, { message: string; scenario: { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }; }, { message: string; scenario: { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }; }>; export type ScenarioResponse = z.infer<typeof ScenarioResponseSchema>; /** * Response schema for listing all scenarios * * Example: * { * "scenarios": [...], * "activeScenario": "testing" * } */ export declare const ListScenariosResponseSchema: z.ZodObject<{ /** * Array of all saved scenarios */ scenarios: z.ZodArray<z.ZodEffects<z.ZodObject<{ /** * Unique scenario identifier * - 1-50 characters * - Alphanumeric and hyphens only * @example "testing" * @example "error-scenarios" */ name: z.ZodString; /** * Array of endpoint configurations (minimum 1 required) */ endpointConfigurations: z.ZodArray<z.ZodObject<{ /** * API endpoint path (must start with /) * @example "/pet/status" * @example "/user/login" */ path: z.ZodString; /** * HTTP method for the endpoint * @example "GET" * @example "POST" */ method: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>; /** * Name of the mock response file to use (must end with .json) * @example "success-200.json" * @example "error-404.json" */ selectedMockFile: z.ZodString; /** * Response delay in milliseconds (0-60000ms = 0-60 seconds) * @default 0 */ delayMillisecond: z.ZodDefault<z.ZodNumber>; }, "strip", z.ZodTypeAny, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }, { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }>, "many">; /** * Auto-generated metadata */ metadata: z.ZodObject<{ /** * ISO 8601 timestamp of scenario creation (immutable) * @example "2025-11-29T10:00:00.000Z" */ createdAt: z.ZodString; /** * ISO 8601 timestamp of last modification * @example "2025-11-29T10:15:00.000Z" */ lastModified: z.ZodString; /** * Incremental version number (starts at 1) */ version: z.ZodNumber; }, "strip", z.ZodTypeAny, { version: number; createdAt: string; lastModified: string; }, { version: number; createdAt: string; lastModified: string; }>; }, "strip", z.ZodTypeAny, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }>, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }, { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }>, "many">; /** * Name of currently active scenario (null if none) */ activeScenario: z.ZodNullable<z.ZodString>; }, "strip", z.ZodTypeAny, { scenarios: { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; delayMillisecond: number; selectedMockFile: string; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }[]; activeScenario: string | null; }, { scenarios: { name: string; endpointConfigurations: { path: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; selectedMockFile: string; delayMillisecond?: number | undefined; }[]; metadata: { version: number; createdAt: string; lastModified: string; }; }[]; activeScenario: string | null; }>; export type ListScenariosResponse = z.infer<typeof ListScenariosResponseSchema>; /** * Response schema for getting the active scenario * * Example: * { * "activeScenario": "testing", * "lastUpdated": "2025-11-29T10:15:00.000Z" * } */ export declare const ActiveScenarioResponseSchema: z.ZodObject<{ /** * Name of the currently active scenario (null if none) */ activeScenario: z.ZodNullable<z.ZodString>; /** * ISO 8601 timestamp of when active scenario was last updated */ lastUpdated: z.ZodString; }, "strip", z.ZodTypeAny, { activeScenario: string | null; lastUpdated: string; }, { activeScenario: string | null; lastUpdated: string; }>; export type ActiveScenarioResponse = z.infer<typeof ActiveScenarioResponseSchema>; /** * Response schema for scenario deletion * * Example: * { * "message": "Scenario 'testing' deleted successfully" * } */ export declare const DeleteScenarioResponseSchema: z.ZodObject<{ /** * Success message */ message: z.ZodString; }, "strip", z.ZodTypeAny, { message: string; }, { message: string; }>; export type DeleteScenarioResponse = z.infer<typeof DeleteScenarioResponseSchema>; /** * Scenario API error response schema * * Example (400 Validation Error): * { * "error": "Validation failed", * "field": "endpointConfigurations", * "constraint": "Scenario must contain at least one endpoint configuration" * } * * Example (409 Duplicate): * { * "error": "Scenario with name 'testing' already exists" * } * * Example (404 Not Found): * { * "error": "Scenario 'testing' not found" * } */ export declare const ScenarioErrorResponseSchema: z.ZodObject<{ /** * Error message */ error: z.ZodString; /** * Field that failed validation (for validation errors) */ field: z.ZodOptional<z.ZodString>; /** * Validation constraint that was violated (for validation errors) */ constraint: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { error: string; field?: string | undefined; constraint?: string | undefined; }, { error: string; field?: string | undefined; constraint?: string | undefined; }>; export type ScenarioErrorResponse = z.infer<typeof ScenarioErrorResponseSchema>; /** * Validate a create scenario request */ export declare function validateCreateScenarioRequest(data: unknown): { success: true; data: CreateScenarioRequest; } | { success: false; errors: z.ZodError; }; /** * Validate an update scenario request */ export declare function validateUpdateScenarioRequest(data: unknown): { success: true; data: UpdateScenarioRequest; } | { success: false; errors: z.ZodError; }; /** * Validate a scenario object */ export declare function validateScenario(data: unknown): { success: true; data: Scenario; } | { success: false; errors: z.ZodError; }; /** * Format Zod errors for scenario API response */ export declare function formatScenarioValidationErrors(zodError: z.ZodError): ScenarioErrorResponse; //# sourceMappingURL=validation-schemas.d.ts.map